diff options
-rw-r--r-- | Add-a-new-Pokémon.md | 2 | ||||
-rw-r--r-- | Add-a-new-party-menu-icon.md | 175 | ||||
-rw-r--r-- | Tutorials.md | 1 | ||||
-rw-r--r-- | screenshots/251-unique-icons.png | bin | 0 -> 3687 bytes | |||
-rw-r--r-- | screenshots/celebi-icon.png | bin | 0 -> 1121 bytes | |||
-rw-r--r-- | screenshots/gfx-icons-celebi.png | bin | 0 -> 195 bytes |
6 files changed, 176 insertions, 2 deletions
diff --git a/Add-a-new-Pokémon.md b/Add-a-new-Pokémon.md index b04668b..076d3ea 100644 --- a/Add-a-new-Pokémon.md +++ b/Add-a-new-Pokémon.md @@ -281,8 +281,6 @@ Edit [data/pokemon/menu_icons.asm](../blob/master/data/pokemon/menu_icons.asm): Valid icons are in [constants/icon_constants.asm](../blob/master/constants/icon_constants.asm). They're used in the party menu and Day-Care. -If you want a custom icon, you can define a new `ICON_*` constant, create a two-frame icon PNG in [gfx/icons](../tree/master/gfx/icons), `INCBIN` it as a 2bpp in [gfx/icons.asm](../blob/master/gfx/icons.asm), and update the corresponding pointer table in [data/icon_pointers.asm](../blob/master/data/icon_pointers.asm). Note that you can't simply add a unique icon for each Pokémon because they're all in one bank, and that's only large enough for 128 icons, not 251+. Updating the code to allow loading icons from multiple banks is left as an exercise for the reader (for now). - ## 8. Define its Pokédex entry diff --git a/Add-a-new-party-menu-icon.md b/Add-a-new-party-menu-icon.md new file mode 100644 index 0000000..05c574a --- /dev/null +++ b/Add-a-new-party-menu-icon.md @@ -0,0 +1,175 @@ +This tutorial is for how to add a new party menu icon (the same icons are used outside the Day-Care). As an example, we'll add one for Celebi. + + +## Contents + +1. [Define an icon constant](#1-define-an-icon-constant) +2. [Design its graphics](#2-design-its-graphics) +3. [Include and point to the graphics](#3-include-and-point-to-the-graphics) +4. [Use the icon for a Pokémon](#4-use-the-icon-for-a-pokémon) +5. [How to add a unique icon for each Pokémon](#5-how-to-add-a-unique-icon-for-each-pokémon) + + +## 1. Define an icon constant + +Edit [constants/icon_constants.asm](../blob/master/constants/icon_constants.asm): + +```diff + ; IconPointers indexes (see data/icon_pointers.asm) + const_def + const ICON_NULL + const ICON_POLIWAG + ... + const ICON_BIGMON ++ const ICON_CELEBI +``` + + +## 2. Design its graphics + +Create **gfx/icons/celebi.png**: + + + +It needs to have two frames stacked vertically, each 16x16 pixels, and use four colors: black, white, light gray (#AAAAAA), and dark gray (#555555). + +The example graphics are based on [gfx/overworld/celebi](../tree/master/gfx/overworld/celebi/), which are used for the Japanese- and Virtual Console–exclusive GS Ball event. + + +## 3. Include and point to the graphics + +Edit [data/icon_pointers.asm](../blob/master/data/icon_pointers.asm): + +```diff + IconPointers: + ; entries correspond to ICON_* constants + dw NullIcon + dw PoliwagIcon + ... + dw BigmonIcon ++ dw CelebiIcon +``` + +And edit [gfx/icons.asm](../blob/master/gfx/icons.asm): + +```diff + Icons: + NullIcon: + PoliwagIcon: INCBIN "gfx/icons/poliwag.2bpp" ; 0x8ec0d + ... + BigmonIcon: INCBIN "gfx/icons/bigmon.2bpp" ; 0x8fe8d ++CelebiIcon: INCBIN "gfx/icons/celebi.2bpp" +``` + + +## 4. Use the icon for a Pokémon + +Edit [data/pokemon/menu_icons.asm](../blob/master/data/pokemon/menu_icons.asm): + +```diff + MonMenuIcons: ; 8eac4 + ... +- db ICON_HUMANSHAPE ; CELEBI ++ db ICON_CELEBI ; CELEBI +``` + +That's all! + + + + +## 5. How to add a unique icon for each Pokémon + +It's common to want a unique icon for each Pokémon, like the ones from this set ([here are its still frames](screenshots/minidex.png)): + + + +But when you add all 251 icons at once, `make` gives an error: + +``` +ERROR: main.asm(315) -> engine/gfx/mon_icons.asm(471) -> gfx/icons.asm(42): + Section 'bank23' is too big (max size = 0x4000 bytes). +``` + +That many icons won't fit in one ROM bank. We'll have to split them into multiple sections. + +How many icons *can* fit in a bank? Well, a bank is $4000 = 16,384 bytes. An icon has two frames, each 16x16 pixels, encoded with two bits per pixel (hence "2bpp"), and eight bits are in a byte. So each icon uses 128 bytes, and 16,384 / 128 = 128 icons can fit in a bank. That means two banks will be enough for the 252 icons we need (251 Pokémon plus Egg). + +Edit [gfx/icons.asm](../blob/master/gfx/icons.asm): + +```diff +-Icons: +-NullIcon: +-BulbasaurIcon: INCBIN "gfx/icons/bulbasaur.2bpp" +-... +-CelebiIcon: INCBIN "gfx/icons/celebi.2bpp" ++SECTION "Mon Icons 1", ROMX ++ ++Icons1: ++NullIcon: ++BulbasaurIcon: INCBIN "gfx/icons/bulbasaur.2bpp" ++... ++TaurosIcon: INCBIN "gfx/icons/tauros.2bpp" ++ ++SECTION "Mon Icons 2", ROMX ++ ++Icons2: ++MagikarpIcon: INCBIN "gfx/icons/magikarp.2bpp" ++... ++CelebiIcon: INCBIN "gfx/icons/celebi.2bpp" +``` + +One section, "Mon Icons 1", contains icons #1 to #128. The next, "Mon Icons 2", contains #129 to #251 and Egg. When you run `make` they'll automatically be placed in banks that fit. Make sure the species are separated in order, so that we can tell which section a Pokémon's icon belongs in just by whether its species is greater than 128. + + +Now edit [engine/gfx/mon_icons.asm](../blob/master/engine/gfx/mon_icons.asm): + +```diff + LoadOverworldMonIcon: ; 8e82b + ld a, e ++ push af + call ReadMonMenuIcon + ld l, a + ld h, 0 + add hl, hl + ld de, IconPointers + add hl, de + ld a, [hli] + ld e, a + ld d, [hl] +- ld b, BANK(Icons) ++ pop af ++ cp MAGIKARP ; first species in "Mon Icons 2" ++ ld a, BANK(Icons1) ++ jr c, .ok ++ ld a, BANK(Icons2) ++.ok ++ ld b, a + ld c, 8 + ret + ; 8e83f + + ... + + GetIcon: ; 8ea1e + ; Load icon graphics into VRAM starting from tile hl. + + ... + +- lb bc, BANK(Icons), 8 ++ ld a, [wCurIcon] ++ cp MAGIKARP ; first species in "Mon Icons 2" ++ lb bc, BANK(Icons1), 8 ++ jr c, .ok ++ lb bc, BANK(Icons2), 8 ++.ok + call GetGFXUnlessMobile + + pop hl + ret + ; 8ea3f +``` + +Now all the icons will load correctly, in the party menu and in the overworld: + + diff --git a/Tutorials.md b/Tutorials.md index 8ebbf14..0a2cb84 100644 --- a/Tutorials.md +++ b/Tutorials.md @@ -17,6 +17,7 @@ Tutorials may use diff syntax to show edits: - [Move effect](Add-a-new-move-effect) - [Item (up to 254)](Add-different-kinds-of-new-items) - [TM (up to 120)](Add-a-new-TM) +- [Party menu icon (up to 253)](Add-a-new-party-menu-icon) - [Overworld sprite](Add-a-new-overworld-sprite) - [Sprite movement behavior](Add-a-new-sprite-movement-behavior) - [Music song](Add-a-new-music-song) diff --git a/screenshots/251-unique-icons.png b/screenshots/251-unique-icons.png Binary files differnew file mode 100644 index 0000000..9794d2d --- /dev/null +++ b/screenshots/251-unique-icons.png diff --git a/screenshots/celebi-icon.png b/screenshots/celebi-icon.png Binary files differnew file mode 100644 index 0000000..6ef0a25 --- /dev/null +++ b/screenshots/celebi-icon.png diff --git a/screenshots/gfx-icons-celebi.png b/screenshots/gfx-icons-celebi.png Binary files differnew file mode 100644 index 0000000..f18206a --- /dev/null +++ b/screenshots/gfx-icons-celebi.png |