1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
|
This tutorial is for how to add a new species of Pokémon, allowing up to 253 species. As an example, we'll add Munchlax.
## Contents
1. [Define a species constant](#1-define-a-species-constant)
2. [Give it a name](#2-give-it-a-name)
3. [Define its base data](#3-define-its-base-data)
4. [Define its evolutions and level-up learnset](#4-define-its-evolutions-and-level-up-learnset)
5. [Define its egg moves](#5-define-its-egg-moves)
6. [Define its cry](#6-define-its-cry)
7. [Define its icon](#7-define-its-icon)
8. [Define its Pokédex entry](#8-define-its-pokédex-entry)
9. [Design its footprint](#9-design-its-footprint)
10. [Design its sprites and animation](#10-design-its-sprites-and-animation)
11. [Include and point to the sprite and animation data](#11-include-and-point-to-the-sprite-and-animation-data)
12. [Adding up to 253 Pokémon](#12-adding-up-to-253-pokémon)
## 1. Define a species constant
Edit [constants/pokemon_constants.asm](../blob/master/constants/pokemon_constants.asm):
```diff
; pokemon ids
; indexes for:
; - PokemonNames (see data/pokemon/names.asm)
; - BaseData (see data/pokemon/base_stats.asm)
; - EvosAttacksPointers (see data/pokemon/evos_attacks_pointers.asm)
; - EggMovePointers (see data/pokemon/egg_move_pointers.asm)
; - PokemonCries (see data/pokemon/cries.asm)
; - MonMenuIcons (see data/pokemon/menu_icons.asm)
; - PokemonPicPointers (see data/pokemon/pic_pointers.asm)
; - PokemonPalettes (see data/pokemon/palettes.asm)
; - PokedexDataPointerTable (see data/pokemon/dex_entry_pointers.asm)
; - AlphabeticalPokedexOrder (see data/pokemon/dex_order_alpha.asm)
; - EZChat_SortedPokemon (see data/pokemon/ezchat_order.asm)
; - NewPokedexOrder (see data/pokemon/dex_order_new.asm)
; - Pokered_MonIndices (see data/pokemon/gen1_order.asm)
; - AnimationPointers (see gfx/pokemon/anim_pointers.asm)
; - AnimationIdlePointers (see gfx/pokemon/idle_pointers.asm)
; - BitmasksPointers (see gfx/pokemon/bitmask_pointers.asm)
; - FramesPointers (see gfx/pokemon/frame_pointers.asm)
; - Footprints (see gfx/footprints.asm)
const_def 1
const BULBASAUR ; 01
...
const MEW ; 97
JOHTO_POKEMON EQU const_value
const CHIKORITA ; 98
...
const CELEBI ; fb
+ const MUNCHLAX ; fc
NUM_POKEMON EQU const_value + -1
- const MON_FC ; fc
const EGG ; fd
const MON_FE ; fe
```
Some things to notice here:
- Species constants are in national dex order; in fact, they're used as Pokédex IDs, so Munchlax is going to appear as #252.
- `JOHTO_POKEMON` is defined right before the first Johto Pokémon, and `NUM_POKEMON` is defined right after the last non-Egg Pokémon.
- There are a lot of data tables associated with Pokémon species! We'll go over them one by one.
# 2. Give it a name
Edit [data/pokemon/names.asm](../blob/master/data/pokemon/names.asm):
```diff
PokemonNames::
db "BULBASAUR@"
...
db "CELEBI@@@@"
- db "?????@@@@@"
+ db "MUNCHLAX@@"
db "EGG@@@@@@@"
db "?????@@@@@"
db "?????@@@@@"
db "?????@@@@@"
```
All the names are exactly 10 characters long, with "@" as padding. Names that are 10 characters long anyway, like "CHARMELEON", don't have any padding.
(Aside: if you make names lowercase, be careful—going from "FARFETCH'D" to "Farfetch'd" will lower the character count by 1 since `'d` is a single character, so that would need to become `"Farfetch'd@"`.)
## 3. Define its base data
Create **data/pokemon/base_stats/munchlax.asm**; you can start with [data/pokemon/base_stats/snorlax.asm](../blob/master/data/pokemon/base_stats/snorlax.asm) as a guide.
There's a lot of base data here:
```diff
+ db MUNCHLAX ; 252
+
+ db 135, 85, 40, 5, 40, 85
+ ; hp atk def spd sat sdf
+
+ db NORMAL, NORMAL ; type
+ db 50 ; catch rate
+ db 94 ; base exp
+ db LEFTOVERS, LEFTOVERS ; items
+ db GENDER_F12_5 ; gender ratio
+ db 100 ; unknown 1
+ db 40 ; step cycles to hatch
+ db 5 ; unknown 2
+ INCBIN "gfx/pokemon/munchlax/front.dimensions"
+ db 0, 0, 0, 0 ; padding
+ db GROWTH_SLOW ; growth rate
+ dn EGG_NONE, EGG_NONE ; egg groups
+
+ ; tm/hm learnset
+ tmhm DYNAMICPUNCH, HEADBUTT, CURSE, ROLLOUT, TOXIC, ZAP_CANNON, ROCK_SMASH, PSYCH_UP, HIDDEN_POWER, SUNNY_DAY, SNORE, BLIZZARD, HYPER_BEAM, ICY_WIND, PROTECT, RAIN_DANCE, ENDURE, FRUSTRATION, SOLARBEAM, THUNDER, EARTHQUAKE, RETURN, PSYCHIC_M, SHADOW_BALL, MUD_SLAP, DOUBLE_TEAM, ICE_PUNCH, SWAGGER, SLEEP_TALK, SANDSTORM, FIRE_BLAST, DEFENSE_CURL, THUNDERPUNCH, REST, ATTRACT, FIRE_PUNCH, SURF, STRENGTH, FLAMETHROWER, THUNDERBOLT, ICE_BEAM
+ ; end
```
From top to bottom, what it all means:
- **species:** This is just used for declaring which ROM bank the Pokédex entry is stored it. It's arguably [a design flaw](../blob/master/docs/design_flaws.md#pokédex-entry-banks-are-derived-from-their-species-ids), since the exact species ID is insignificant, but it's not a big deal; just put the correct species here and move on.
- **base stats:** HP, Attack, Defense, Speed, Special Attack, and Special Defense, each from 1 to 255.
- **type:** The primary and secondary types. Single-type Pokémon just repeat their type twice.
- **catch rate:** A factor in the formula for capturing wild Pokémon. Lower rates are harder to capture. The highest value, 255, is used for common Pokémon like Hoothoot and Rattata; legendaries like Mewtwo and Ho-Oh get as low as 3.
- **base experience yield:** A factor in the formula for awarding experience. Higher values give more experience. As usual, since this is a single byte (`db`), its maximum is 255. (Chansey and Blissey both have 255 base exp.)
- **items:** A common item (23% chance) and a rare item (2% chance) that might be held by this Pokémon in the wild.
- **gender ratio:** The likelihood that an Egg of this Pokémon will be female. Lower values are more likely to be male, with 0 being 100% male, 254 being 100% female, and 255 being genderless (like Magnemite or Staryu). There are named constants for the few values that get officially used:
- `GENDER_F0`: 100% male
- `GENDER_F12_5`: 7/8 male, 1/8 female
- `GENDER_F25`: 3/4 male, 1/4 female
- `GENDER_F50`: 1/2 male, 1/2 female
- `GENDER_F75`: 1/4 male, 3/4 female
- `GENDER_F100`: 100% female
- `GENDER_UNKNOWN`: genderless
- **unknown 1:** An unused value that's always 100.
- **step cycles to hatch:** How many step cycles it takes for an Egg of this Pokémon to hatch. Each step cycle is 256 steps long.
- **unknown 2:** An unused value that's always 5. (In the [leaked G/S prototype from the Space World 1997 demo](https://github.com/pret/pokegold-spaceworld), this value was always 70.)
- **front.dimensions:** The size of the Pokémon's front sprite. The front.dimensions file contains a single byte that's one of three valid values: $55 for a 40x40-pixel (5x5-tile) sprite, $66 for 48x48 pixels (6x6 tiles), or $77 for 56x56 pixels (7x7 tiles). It's automatically generated from the front.png sprite image (we'll get to this later).
- **padding:** Four unused bytes that are always 0s. (In the G/S prototype, these values were pointers to the front and back sprites.)
- **growth rate:** The formula that's used to determine experience point thresholds for reaching each level. (The formula coefficients are defined in [data/growth_rates.asm](../blob/master/data/growth_rates.asm).) Valid values:
- `GROWTH_MEDIUM_FAST`: *exp* = *L*³ (1,000,000 exp = level 100)
- `GROWTH_SLIGHTLY_FAST`: *exp* = (3/4)*L*³ + 10*L*² − 30 (849,970 exp = level 100); unused
- `GROWTH_SLIGHTLY_SLOW`: *exp* = (3/4)*L*³ + 20*L*² − 70 (949,930 exp = level 100); unused
- `GROWTH_MEDIUM_SLOW`: *exp* = (6/5)*L*³ − 15*L*² + 100*L* − 140 (1,059,860 exp = level 100)
- `GROWTH_FAST`: *exp* = (4/5)*L*³ (800,000 exp = level 100)
- `GROWTH_SLOW`: *exp* = (5/4)*L*³ (1,250,000 exp = level 100)
- **egg groups:** The two egg groups this Pokémon is in. Two Pokémon have to share an Egg group to breed. The 15 valid Egg groups (including `EGG_NONE` for sterile Pokémon like babies and legendaries) are defined in [constants/pokemon_data_constants.asm](../blob/master/constants/pokemon_data_constants.asm).
- **TM/HM learnset:** A list of which TMs, HMs, and tutor moves this Pokémon can learn, passed to the `tmhm` macro. Valid values are defined in [constants/item_constants.asm](../blob/master/constants/item_constants.asm) with the `add_tm`, `add_hm`, and `add_mt` macros.
Then edit [data/pokemon/base_stats.asm](../blob/master/data/pokemon/base_stats.asm):
```diff
BaseData::
INCLUDE "data/pokemon/base_stats/bulbasaur.asm"
...
INCLUDE "data/pokemon/base_stats/celebi.asm"
+INCLUDE "data/pokemon/base_stats/munchlax.asm"
```
## 4. Define its evolutions and level-up learnset
Edit [data/pokemon/evos_attacks_pointers.asm](../blob/master/data/pokemon/evos_attacks_pointers.asm):
```diff
EvosAttacksPointers::
dw BulbasaurEvosAttacks
...
dw CelebiEvosAttacks
+ dw MunchlaxEvosAttacks
```
Then edit [data/pokemon/evos_attacks.asm](../blob/master/data/pokemon/evos_attacks.asm):
```diff
+MunchlaxEvosAttacks:
+ db EVOLVE_HAPPINESS, TR_ANYTIME, SNORLAX
+ db 0 ; no more evolutions
+ db 1, TACKLE
+ db 1, METRONOME
+ db 8, AMNESIA
+ db 15, DEFENSE_CURL
+ db 22, BELLY_DRUM
+ db 29, HEADBUTT
+ db 36, SCREECH
+ db 36, REST
+ db 43, BODY_SLAM
+ db 50, ROLLOUT
+ db 57, HYPER_BEAM
+ db 0 ; no more level-up moves
```
The comment at the top of evos_attacks.asm explains the data structure:
```
EvosAttacks::
; Evos+attacks data structure:
; - Evolution methods:
; * db EVOLVE_LEVEL, level, species
; * db EVOLVE_ITEM, used item, species
; * db EVOLVE_TRADE, held item (or -1 for none), species
; * db EVOLVE_HAPPINESS, TR_* constant (ANYTIME, MORNDAY, NITE), species
; * db EVOLVE_STAT, level, ATK_*_DEF constant (LT, GT, EQ), species
; - db 0 ; no more evolutions
; - Learnset (in increasing level order):
; * db level, move
; - db 0 ; no more level-up moves
```
Munchlax evolves into Snorlax through happiness; and its level-up moves are copied from Snorlax, with a couple replacements (Metronome and Screech).
Note that the order of the `EvosAttacksPointers` matters, since the entries pair up with the species constants, but the `EvosAttacks` data is unordered. I just put Munchlax's data at the end of the file.
## 5. Define its egg moves
Edit [data/pokemon/egg_move_pointers.asm](../blob/master/data/pokemon/egg_move_pointers.asm):
```diff
EggMovePointers::
dw BulbasaurEggMoves
...
dw AerodactylEggMoves
- dw SnorlaxEggMoves
+ dw NoEggMoves
dw NoEggMoves
...
dw NoEggMoves
+ dw MunchlaxEggMoves
```
Then edit [data/pokemon/egg_moves.asm](../blob/master/data/pokemon/egg_moves.asm):
```diff
-SnorlaxEggMoves:
+MunchlaxEggMoves:
db LICK
db -1 ; end
```
Note that since Snorlax will now lay Munchlax eggs, it doesn't need Egg moves of its own, and its set of Egg moves can just be reused for Munchlax. Like the level-up moves, this data is unordered, since the `EggMovePointers` table is used to access particular sets.
## 6. Define its cry
Edit [data/pokemon/cries.asm](../blob/master/data/pokemon/cries.asm):
```diff
PokemonCries::
; entries correspond to constants/pokemon_constants.asm
mon_cry CRY_BULBASAUR, $080, $081 ; BULBASAUR
...
mon_cry CRY_ENTEI, $14a, $111 ; CELEBI
- mon_cry CRY_NIDORAN_M, 0, 0 ; 252
+ mon_cry CRY_GRIMER, $065, $080 ; MUNCHLAX
mon_cry CRY_NIDORAN_M, 0, 0 ; 253
mon_cry CRY_NIDORAN_M, 0, 0 ; 254
mon_cry CRY_NIDORAN_M, 0, 0 ; 255
```
The three values passed to `mon_cry` are a cry index, a pitch, and a length. Defining your own cries is similar to writing original music, and well beyond the scope of this tutorial. So just pick a cry from [constants/cry_constants.asm](../blob/master/constants/cry_constants.asm) and tweak the pitch and length until it sounds okay. I simply copied Snorlax's cry for Munchlax, with a slightly higher pitch and shorter length.
## 7. Define its icon
Edit [data/pokemon/menu_icons.asm](../blob/master/data/pokemon/menu_icons.asm):
```diff
MonMenuIcons:
db ICON_BULBASAUR ; BULBASAUR
...
db ICON_HUMANSHAPE ; CELEBI
+ db ICON_SNORLAX ; MUNCHLAX
```
Valid icons are in [constants/icon_constants.asm](../blob/master/constants/icon_constants.asm). They're used in the party menu and Day-Care.
## 8. Define its Pokédex entry
Create **data/pokemon/dex_entries/munchlax.asm**:
```diff
+ db "BIG EATER@" ; species name
+ dw 200, 2315 ; height, weight
+
+ db "In its desperation"
+ next "to gulp down food,"
+ next "it forgets about"
+
+ page "the food it has"
+ next "hidden under its"
+ next "fur.@"
```
- The species name can be up to 10 characters (technically 11 will still fit in the Pokédex window). Be sure to end it with a "@".
- The height and weight values are in imperial units. 200 = 2 feet 0 inches; 2315 = 231.5 pounds.
- The entry text is in two pages; the first starts with `db`, the second with `page`. Each page can fit three lines with 18 characters each. Here it's visual size that matters—`"#MON"` counts as 7 characters because it prints as "POKéMON". Again, be sure to end it with a "@".
Edit [data/pokemon/dex_entry_pointers.asm](../blob/master/data/pokemon/dex_entry_pointers.asm):
```diff
PokedexDataPointerTable:
; entries correspond to constants/pokemon_constants.asm
dw BulbasaurPokedexEntry
...
dw CelebiPokedexEntry
+ dw MunchlaxPokedexEntry
```
Then edit [data/pokemon/dex_entries.asm](../blob/master/data/pokemon/dex_entries.asm):
```diff
SECTION "Pokedex Entries 193-251", ROMX
PokedexEntries4::
YanmaPokedexEntry:: INCLUDE "data/pokemon/dex_entries/yanma.asm"
...
CelebiPokedexEntry:: INCLUDE "data/pokemon/dex_entries/celebi.asm"
+MunchlaxPokedexEntry:: INCLUDE "data/pokemon/dex_entries/munchlax.asm"
```
Each of the four sections in dex_entries.asm holds 64 Pokédex entries. Each section is in a different ROM bank, decided by which range the Pokémon's species ID is in: 1–64, 65–128, 129–192, or 193–256. The order of entries within each section doesn't actually matter, since they're accessed directly via `PokedexDataPointerTable`, but avoid confusion and just keep them in numerical order.
Now the Pokédex entry exists, and will be listed correctly in "Old Pokédex Mode" (the Gen 2 equivalent of national order). But we need to define the new Pokémon's place in "New Pokédex Mode (regional order) and "A to Z Mode" (alphabetical order).
Edit [data/pokemon/dex_order_new.asm](../blob/master/data/pokemon/dex_order_new.asm):
```diff
NewPokedexOrder:
db CHIKORITA
...
db AERODACTYL
+ db MUNCHLAX
db SNORLAX
db BULBASAUR
...
db CELEBI
```
Then edit [data/pokemon/dex_order_alpha.asm](../blob/master/data/pokemon/dex_order_alpha.asm):
```diff
AlphabeticalPokedexOrder:
db ABRA
...
db MUK
+ db MUNCHLAX
db MURKROW
...
db ZUBAT
```
That's all for the Pokédex.
## 9. Design its footprint
Create **gfx/footprints/munchlax.png**:

Then edit [gfx/footprints.asm](../blob/master/gfx/footprints.asm):
```diff
; Footprints are 2x2 tiles each, but are stored as a 16x64-tile image
; (32 rows of 8 footprints per row).
; That means there's a row of the top two tiles for eight footprints,
; then a row of the bottom two tiles for those eight footprints.
; These macros help extract the first and the last two tiles, respectively.
footprint_top EQUS "0, 2 * LEN_1BPP_TILE"
footprint_bottom EQUS "2 * LEN_1BPP_TILE, 2 * LEN_1BPP_TILE"
; Entries correspond to Pokémon species, two apiece, 8 tops then 8 bottoms
...
; 249-256 top halves
INCBIN "gfx/footprints/lugia.1bpp", footprint_top
INCBIN "gfx/footprints/ho_oh.1bpp", footprint_top
INCBIN "gfx/footprints/celebi.1bpp", footprint_top
-INCBIN "gfx/footprints/252.1bpp", footprint_top
+INCBIN "gfx/footprints/munchlax.1bpp", footprint_top
INCBIN "gfx/footprints/253.1bpp", footprint_top
INCBIN "gfx/footprints/254.1bpp", footprint_top
INCBIN "gfx/footprints/255.1bpp", footprint_top
INCBIN "gfx/footprints/256.1bpp", footprint_top
; 249-256 bottom halves
INCBIN "gfx/footprints/lugia.1bpp", footprint_bottom
INCBIN "gfx/footprints/ho_oh.1bpp", footprint_bottom
INCBIN "gfx/footprints/celebi.1bpp", footprint_bottom
-INCBIN "gfx/footprints/252.1bpp", footprint_bottom
+INCBIN "gfx/footprints/munchlax.1bpp", footprint_bottom
INCBIN "gfx/footprints/253.1bpp", footprint_bottom
INCBIN "gfx/footprints/254.1bpp", footprint_bottom
INCBIN "gfx/footprints/255.1bpp", footprint_bottom
INCBIN "gfx/footprints/256.1bpp", footprint_bottom
```
Notice how the footprints are broken into top and bottom halves; you may want to [correct this design flaw](../blob/master/docs/design_flaws.md#footprints-are-split-into-top-and-bottom-halves). (It won't have a visible consequence on the game, but it makes for cleaner code and data.)
(Running `make` later will automatically create munchlax.1bpp from munchlax.png. Since it's a 1bpp file (**one** **b**it **p**er **p**ixel) you can only use black and white in the image.)
## 10. Design its sprites and animation
This is a bit complicated. We need a front sprite with an animation sequence; a back sprite; and normal and shiny color palettes for both.
Create **gfx/pokemon/munchlax/front.png**:

And **gfx/pokemon/munchlax/back.png**:

front.png is a vertical strip of unique animation frames. Frames are all the same size; valid sizes are 40x40, 48x48, or 56x56. Here we have five frames, each 48x48 pixels. back.png is always 48x48. Both sprites have to use the same four colors: white, black, and the same two arbitrary hues.
Next create **gfx/pokemon/munchlax/shiny.pal**:
```diff
+ RGB 22, 22, 12
+ RGB 07, 15, 25
```
These two colors will be used for shiny Munchlax, along with the standard black and white. The lighter color should come first.
Now create **gfx/pokemon/munchlax/anim.asm**:
```diff
+ frame 0, 08
+ frame 1, 08
+ frame 0, 08
+ frame 2, 24
+ frame 3, 08
+ frame 4, 08
+ frame 3, 08
+ frame 3, 08
+ frame 0, 16
+ endanim
```
And finally **gfx/pokemon/munchlax/anim_idle.asm**:
```diff
+ frame 1, 08
+ frame 0, 08
+ frame 1, 08
+ endanim
```
anim.asm defines the main sprite animation sequence; anim_idle.asm defines an extra one that gets played in some contexts (notably *not* when a Pokémon is encountered in battle). A full description of the animation script commands is at [docs/pic_animations.md](../blob/master/docs/pic_animations.md).
This Munchlax animation was designed by SCMidna. But you're more likely to have a single static front sprite than a whole animated sequence of frames. In that case, you can save the one sprite as front.png (so it will be a single square frame, not a vertical strip of them), and just put `endanim` as the full contents of anim.asm and anim_idle.asm. Or if none of your sprites will be animated, follow [this tutorial](Remove-Pokémon-sprite-animations) to remove the entire animation system, freeing up even more space for game content.
When you `make` the ROM, a number of sprite-related files will be automatically generated for you:
- **front.gbcpal:** Like shiny.pal, but for the normal colors; derived from front.png.
- **front.dimensions:** The size of the still sprite from front.png.
- **front.animated.2bpp.lz:** The compressed tiles needed to animate the sprite. Animation frames tend to have lots of duplicate tiles, since only parts of a Pokémon move at a time, so each unique tile only exists once.
- **bitmask.asm:** A sequence of masks that define which spots in each frame are changed from the still sprite.
- **frames.asm:** A sequence of lists that declare the tile IDs with which to fill in the changed spots in each frame.
There are two main reasons to pay attention to these auto-generated files. One, you want to make sure that front.gbcpal got its colors in the right order, and have shiny.pal match it. Two, if your animation appears corrupt, you want to make sure that frames.asm isn't using too high tile IDs. A 40x40 sprite can use IDs $00 to $31; a 48x48 sprite can use up to $47; a 56x56 sprite can use up to $61. If you see IDs above those limits, edit your front.png frames so they use fewer unique tiles, or follow [this tutorial](Increase-Pokémon-sprite-animation-size) to allow any animation to use 255 tiles ($00 to $FF but skipping $7F).
(Older versions of pokecrystal generated normal.pal and normal.gbcpal files instead of front.gbcpal, but this was redundant work and could mislead users into editing normal.pal directly, so as of September 2018 they were removed.)
Anyway, all that's left is to `INCLUDE` and point to the new data!
## 11. Include and point to the sprite and animation data
Edit [data/pokemon/pic_pointers.asm](../blob/master/data/pokemon/pic_pointers.asm):
```diff
PokemonPicPointers::
; entries correspond to Pokémon species, two apiece
dba_pic BulbasaurFrontpic
dba_pic BulbasaurBackpic
...
dba_pic CelebiFrontpic
dba_pic CelebiBackpic
- dbw -1, -1 ; unused
- dbw -1, -1 ; unused
+ dba_pic MunchlaxFrontpic
+ dba_pic MunchlaxBackpic
dba_pic EggPic
dbw -1, -1 ; unused
```
We have to use `dba_pic` here instead of a standard `dba`—declaring the bank and address of `MunchlaxFrontpic` and `MunchlaxBackpic`—because of [another design flaw](../blob/master/docs/design_flaws.md#pic-banks-are-offset-by-pics_fix). I strongly recommend removing the whole `FixPicBank` routine from [engine/gfx/load_pics.asm](../blob/master/engine/gfx/load_pics.asm), including all four calls to it in that file, and just using `dba` here; then you'll be able to `INCBIN` sprites in arbitrary banks.
Edit [gfx/pics.asm](../blob/master/gfx/pics.asm):
```diff
SECTION "Pics 19", ROMX
-; Seems to be an accidental copy of the previous bank
-
-INCBIN "gfx/pokemon/spinarak/back.2bpp.lz"
-...
-INCBIN "gfx/pokemon/unown_r/back.2bpp.lz"
+MunchlaxFrontpic: INCBIN "gfx/pokemon/munchlax/front.animated.2bpp.lz"
+MunchlaxBackpic: INCBIN "gfx/pokemon/munchlax/back.2bpp.lz"
```
(If you *don't* fix the `dba_pic` design flaw, you'll have to put your sprites in the "Pics *N*" sections, which are compatible with `dba_pic`. "Pics 19" isn't used for anything useful—all its contents are unused duplicates of "Pics 18"—and it has a whole bank to itself, so it's the easiest place to start adding new sprites. (The other sections, includng "Pics 20" through "Pics 24", have limited remaining space since they already contain some sprites and/or share their banks with other sections.) But if you have a lot of new sprites to add, you risk overflowing the banks, and it's hard to fit sprites within fixed bank limits. By using just `dba`, you can create new sections with a few sprites each, that will automatically be placed wherever they can fit in the ROM.)
Anyway, edit [data/pokemon/palettes.asm](../blob/master/data/pokemon/palettes.asm):
```diff
PokemonPalettes:
; entries correspond to Pokémon species, two apiece
; Each front.gbcpal is generated from the corresponding .png, and
; only the middle two colors are included, not black or white.
; Shiny palettes are defined directly, not generated.
; 000
RGB 30, 22, 17
RGB 16, 14, 19
; 000 shiny
RGB 30, 22, 17
RGB 16, 14, 19
INCBIN "gfx/pokemon/bulbasaur/front.gbcpal", middle_colors
INCLUDE "gfx/pokemon/bulbasaur/shiny.pal"
...
INCBIN "gfx/pokemon/celebi/front.gbcpal", middle_colors
INCLUDE "gfx/pokemon/celebi/shiny.pal"
-; 252
- RGB 30, 26, 11
- RGB 23, 16, 00
-; 252 shiny
- RGB 30, 26, 11
- RGB 23, 16, 00
+INCBIN "gfx/pokemon/munchlax/front.gbcpal", middle_colors
+INCLUDE "gfx/pokemon/munchlax/shiny.pal"
INCBIN "gfx/pokemon/egg/front.gbcpal", middle_colors
INCLUDE "gfx/pokemon/egg/shiny.pal"
; 254
RGB 30, 26, 11
RGB 23, 16, 00
; 254 shiny
RGB 30, 26, 11
RGB 23, 16, 00
; 255
RGB 23, 23, 23
RGB 17, 17, 17
; 255 shiny
RGB 23, 23, 23
RGB 17, 17, 17
```
(Older versions of pokecrystal would `INCLUDE "normal.pal"` instead of `INCBIN "front.gbcpal"`, as discussed earlier.)
Edit [gfx/pokemon/anim_pointers.asm](../blob/master/gfx/pokemon/anim_pointers.asm):
```diff
AnimationPointers:
dw BulbasaurAnimation
...
dw CelebiAnimation
+ dw MunchlaxAnimation
```
Edit [gfx/pokemon/anims.asm](../blob/master/gfx/pokemon/anims.asm):
```diff
PicAnimations:
BulbasaurAnimation: INCLUDE "gfx/pokemon/bulbasaur/anim.asm"
...
CelebiAnimation: INCLUDE "gfx/pokemon/celebi/anim.asm"
+MunchlaxAnimation: INCLUDE "gfx/pokemon/munchlax/anim.asm"
EggAnimation: INCLUDE "gfx/pokemon/egg/anim.asm"
```
Edit [gfx/pokemon/idle_pointers.asm](../blob/master/gfx/pokemon/idle_pointers.asm):
```diff
AnimationIdlePointers:
dw BulbasaurAnimationIdle
...
dw CelebiAnimationIdle
+ dw MunchlaxAnimationIdle
```
Edit [gfx/pokemon/idles.asm](../blob/master/gfx/pokemon/idles.asm):
```diff
BulbasaurAnimationIdle: INCLUDE "gfx/pokemon/bulbasaur/anim_idle.asm"
...
CelebiAnimationIdle: INCLUDE "gfx/pokemon/celebi/anim_idle.asm"
+MunchlaxAnimationIdle: INCLUDE "gfx/pokemon/munchlax/anim_idle.asm"
EggAnimationIdle: INCLUDE "gfx/pokemon/egg/anim_idle.asm"
```
Edit [gfx/pokemon/bitmask_pointers.asm](../blob/master/gfx/pokemon/bitmask_pointers.asm):
```diff
BitmasksPointers:
dw BulbasaurBitmasks
...
dw CelebiBitmasks
+ dw MunchlaxBitmasks
```
Edit [gfx/pokemon/bitmasks.asm](../blob/master/gfx/pokemon/bitmasks.asm):
```diff
BulbasaurBitmasks: INCLUDE "gfx/pokemon/bulbasaur/bitmask.asm"
...
CelebiBitmasks: INCLUDE "gfx/pokemon/celebi/bitmask.asm"
+MunchlaxBitmasks: INCLUDE "gfx/pokemon/munchlax/bitmask.asm"
EggBitmasks: INCLUDE "gfx/pokemon/egg/bitmask.asm"
```
Edit [gfx/pokemon/frame_pointers.asm](../blob/master/gfx/pokemon/frame_pointers.asm):
```diff
FramesPointers:
dw BulbasaurFrames
...
dw CelebiFrames
+ dw MunchlaxFrames
```
Finally, edit [gfx/pokemon/johto_frames.asm](../blob/master/gfx/pokemon/johto_frames.asm):
```diff
JohtoFrames:
ChikoritaFrames: INCLUDE "gfx/pokemon/chikorita/frames.asm"
...
CelebiFrames: INCLUDE "gfx/pokemon/celebi/frames.asm"
+MunchlaxFrames: INCLUDE "gfx/pokemon/munchlax/frames.asm"
EggFrames: INCLUDE "gfx/pokemon/egg/frames.asm"
```
Note that we edited johto_frames.asm, not kanto_frames.asm, because `MUNCHLAX` comes after `JOHTO_POKEMON` in [constants/pokemon_constants.asm](../blob/master/constants/pokemon_constants.asm).
That's it—we're done! Munchlax works just like every other Pokémon.

## 12. Adding up to 253 Pokémon
We just added Pokémon #252; adding #253 is basically the same. However, instead of just replacing `MON_FE` the way we replaced `MON_FC`, I would recommend swapping `MON_FE` and `EGG`. That way `MON_FE` is $FD and `EGG` is $FE.
This has multiple benefits:
- Pokémon IDs will be contiguous, from #1 to #253. No #254 with a missing #253 where Egg exists.
- Many data tables don't have an entry for `EGG` since it would be superfluous. But if there were a Pokémon #254, they would need filler entries for #253 in order to reach entry #254.
- `EGG` does not count as a Pokémon, so if it came before a valid Pokémon ID, then `NUM_POKEMON` would have to be adjusted to compensate, and certain other checks in the code would no longer be able to assume that any ID below some number *N* is a valid one.
It's easy to do; just make sure that the various tables have their entries in the right order: Bulbasaur, Ivysaur, Venusaur, …, Celebi, #252, #253, Egg.
Unfortunately, you can't have more than 253 Pokémon. IDs are one byte each, so they have 256 possible values. Of those values, $00 indicates a lack of a Pokémon; $FF (−1) is an end-of-list marker; and $FD is `EGG` (though you can change this to $FE, as discussed above). If you value having a 254th Pokémon more than allowing breeding, you could replace `EGG`, but you would also have to carefully remove a lot of code that treats `EGG` specially.
|