diff options
-rw-r--r-- | Customizable-Pokédex-Color.md | 203 |
1 files changed, 108 insertions, 95 deletions
diff --git a/Customizable-Pokédex-Color.md b/Customizable-Pokédex-Color.md index 7be8aef..0a3ddf1 100644 --- a/Customizable-Pokédex-Color.md +++ b/Customizable-Pokédex-Color.md @@ -1,34 +1,43 @@ Ever wanted the color of your Pokédex to be something besides red? This is rather simple to implement in pokecrystal. All that's needed is a WRAM byte, and reworking some already existing code. -## 1. Create a WRAM Byte +## Contents + +1. [Create a new WRAM byte](#1-create-a-new-wram-byte) +2. [Create color constants](#2-create-color-constants) +3. [Add the Color option](#3-add-the-color-option) +4. [Making the Pokédex load the color](#4-making-the-pok%C3%A9dex-load-the-color) +5. [Closing](#5-closing) + + +## 1. Create a new WRAM Byte Edit [wram.asm](../blob/master/wram.asm): ```diff -wPokegearFlags:: -; bit 0: map -; bit 1: radio -; bit 2: phone -; bit 3: expn -; bit 7: on/off + wPokegearFlags:: + ; bit 0: map + ; bit 1: radio + ; bit 2: phone + ; bit 3: expn + ; bit 7: on/off db -wRadioTuningKnob:: db -wLastDexMode:: db + wRadioTuningKnob:: db + wLastDexMode:: db - ds 1 +wCurPokedexColor:: db ; current dex color -wWhichRegisteredItem:: db ; d95b -wRegisteredItem:: db ; d95c + wWhichRegisteredItem:: db + wRegisteredItem:: db ``` +To start we create a WRAM byte. `wLastDexMode` has room after it and is also used by [engine\pokedex\pokedex.asm](../blob/master/engine/pokedex/pokedex.asm). -To start we create a wram byte. `wLastDexMode` has room after it and is also used by [engine\pokedex\pokedex.asm](../blob/master/engine/pokedex/pokedex.asm). -## 2. Create Constants +## 2. Create color constants -Edit [constants\wram_constants.asm](../blob/master/constants/wram_constants.asm). +Now we need some constants that'll be used to figure out which color is selected. Edit [constants\wram_constants.asm](../blob/master/constants/wram_constants.asm): ```diff -; wCurDexMode:: ; c7d4 + ; wCurDexMode:: const_def const DEXMODE_NEW const DEXMODE_OLD @@ -48,7 +57,7 @@ Edit [constants\wram_constants.asm](../blob/master/constants/wram_constants.asm) + const DEXCOLOR_GRAY + const DEXCOLOR_MEWTWO -; wMonType:: ; cf5f + ; wMonType:: const_def const PARTYMON ; 0 const OTPARTYMON ; 1 @@ -57,14 +66,12 @@ Edit [constants\wram_constants.asm](../blob/master/constants/wram_constants.asm) const WILDMON ; 4 ``` -Now we need some constants that'll be used to figure out which color is seleceted. - -## 3. Add the Color Option +## 3. Add the Color option Edit [engine\pokedex\pokedex.asm](../blob/master/engine/pokedex/pokedex.asm). ```diff -; Pokedex_RunJumptable.Jumptable indexes + ; Pokedex_RunJumptable.Jumptable indexes const_def const DEXSTATE_MAIN_SCR const DEXSTATE_UPDATE_MAIN_SCR @@ -86,8 +93,8 @@ Edit [engine\pokedex\pokedex.asm](../blob/master/engine/pokedex/pokedex.asm). First is to create the `const` DEXSTATEs that'll be used to determine the Color options screen. ```diff -.Jumptable: -; entries correspond to DEXSTATE_* constants + .Jumptable: + ; entries correspond to DEXSTATE_* constants dw Pokedex_InitMainScreen dw Pokedex_UpdateMainScreen dw Pokedex_InitDexEntryScreen @@ -108,13 +115,14 @@ First is to create the `const` DEXSTATEs that'll be used to determine the Color And to create the jumptable data for those screens. ```diff -Pokedex_InitOptionScreen: + Pokedex_InitOptionScreen: xor a ldh [hBGMapMode], a call ClearSprites call Pokedex_DrawOptionScreenBG call Pokedex_InitArrowCursor -- ld a, [wCurDexMode] ; Index of the topmost visible item in a scrolling menu ??? +- ; point cursor to the current dex mode (modes == menu item indexes) +- ld a, [wCurDexMode] ld [wDexArrowCursorPosIndex], a call Pokedex_DisplayModeDescription call WaitBGMap @@ -126,10 +134,10 @@ Pokedex_InitOptionScreen: This is to make sure the options menu starts at the top of the screen whenever the player enters it. Otherwise it'd begin at the second option. ```diff -Pokedex_UpdateOptionScreen: -... + Pokedex_UpdateOptionScreen: + ... -.NoUnownModeArrowCursorData: + .NoUnownModeArrowCursorData: - db D_UP | D_DOWN, 3 - dwcoord 2, 4 ; NEW - dwcoord 2, 6 ; OLD @@ -140,7 +148,7 @@ Pokedex_UpdateOptionScreen: + dwcoord 2, 5 ; ABC + dwcoord 2, 6 ; COLOR -.ArrowCursorData: + .ArrowCursorData: - db D_UP | D_DOWN, 4 - dwcoord 2, 4 ; NEW - dwcoord 2, 6 ; OLD @@ -157,20 +165,20 @@ Pokedex_UpdateOptionScreen: Here we're adding the color option to the cursor jumptable. You may notice that the `dwcoord` are changed as well. This is because in order to fit an extra option on the screen, along with a description of said option, we need to remove the space between each option. ```diff -.MenuActionJumptable: + .MenuActionJumptable: dw .MenuAction_NewMode dw .MenuAction_OldMode dw .MenuAction_ABCMode + dw .MenuAction_ColorOption dw .MenuAction_UnownMode -... + ... +.MenuAction_ColorOption + call Pokedex_BlackOutBG + ld a, DEXSTATE_COLOR_OPTION + ld [wJumptableIndex], a + ret -.MenuAction_UnownMode: + .MenuAction_UnownMode: call Pokedex_BlackOutBG ld a, DEXSTATE_UNOWN_MODE ld [wJumptableIndex], a @@ -178,7 +186,7 @@ Here we're adding the color option to the cursor jumptable. You may notice that ``` Adding the Color option to the `.MenuActionJumptable`. As you can see, the menu action is a copy of the Unown Dex action, but it takes us to the color option instead. -``` +```asm Pokedex_InitColorOption: xor a ldh [hBGMapMode], a @@ -190,14 +198,13 @@ Pokedex_InitColorOption: call WaitBGMap ld a, SCGB_POKEDEX_SEARCH_OPTION call Pokedex_GetSGBLayout - call Pokedex_IncrementDexPointer - ret + jp Pokedex_IncrementDexPointer ``` -Here is the actual color option screen code, that should be placed after `Pokedex_UnownModeUpdateCursorGfx` Its a modified `Pokedex_InitOptionScreen` that will also remember cursor's location on the screen. +Here is the actual color option screen code, that should be placed after `Pokedex_UnownModeUpdateCursorGfx`. It's a modified version of `Pokedex_InitOptionScreen` that will also remember the cursor's location on the screen. ```diff -Pokedex_DrawOptionScreenBG: + Pokedex_DrawOptionScreenBG: call Pokedex_FillBackgroundColor2 hlcoord 0, 2 lb bc, 8, 18 @@ -232,7 +239,7 @@ Pokedex_DrawOptionScreenBG: call PlaceString ret -.Title: + .Title: db $3b, " OPTION ", $3c, -1 -.Modes: @@ -257,10 +264,10 @@ Pokedex_DrawOptionScreenBG: db "UNOWN MODE@" ``` -This is where we add the text displayed by the dex in the options menu. We had to change it from `.Modes` since it would force there to be a space between each line of the options, this way we guarantee that each line will be uniform. +This is where we add the text displayed by the Pokédex in the options menu. We had to change it from `.Modes` since it would force there to be a space between each line of the options, this way we guarantee that each line will be uniform. -``` -Pokedex_DrawColorScreenBG: +```asm + Pokedex_DrawColorScreenBG: call Pokedex_FillBackgroundColor2 hlcoord 0, 2 lb bc, 14, 18 @@ -297,43 +304,42 @@ Pokedex_DrawColorScreenBG: call Pokedex_PlaceString hlcoord 3, 12 ld de, .Mewtwo - call Pokedex_PlaceString - ret + jp Pokedex_PlaceString -.Title: + .Title: db $3b, " COLORS ", $3c, -1 -.Red + .Red db "RED ", $4f, -1 -.Blue + .Blue db "BLUE ", $4f, -1 -.Purple + .Purple db "PURPLE ", $4f, -1 -.Brown + .Brown db "BROWN ", $4f, -1 -.Green + .Green db "GREEN ", $4f, -1 -.Pink + .Pink db "PINK ", $4f, -1 -.Yellow + .Yellow db "YELLOW ", $4f, -1 -.Cyan + .Cyan db "CYAN ", $4f, -1 -.Gray + .Gray db "GRAY ", $4f, -1 -.Mewtwo + .Mewtwo db "MEWTWO ", $4f, -1 -Pokedex_UpdateColorOption: + Pokedex_UpdateColorOption: ld de, .ArrowCursorData call Pokedex_MoveArrowCursor ld hl, hJoyPressed @@ -345,7 +351,7 @@ Pokedex_UpdateColorOption: jr nz, .do_menu_action ret -.ArrowCursorData: + .ArrowCursorData: db D_UP | D_DOWN, 10 dwcoord 2, 3 ; Red dwcoord 2, 4 ; Blue @@ -358,19 +364,19 @@ Pokedex_UpdateColorOption: dwcoord 2, 11 ; Gray dwcoord 2, 12 ; Mewtwo -.do_menu_action + .do_menu_action ld a, [wDexArrowCursorPosIndex] ld hl, .MenuActionJumptable call Pokedex_LoadPointer jp hl -.return_to_main_screen + .return_to_main_screen call Pokedex_BlackOutBG ld a, DEXSTATE_MAIN_SCR ld [wJumptableIndex], a ret -.MenuActionJumptable: + .MenuActionJumptable: dw .MenuAction_Red dw .MenuAction_Blue dw .MenuAction_Purple @@ -382,46 +388,46 @@ Pokedex_UpdateColorOption: dw .MenuAction_Gray dw .MenuAction_Mewtwo -.MenuAction_Red + .MenuAction_Red ld b, DEXCOLOR_RED jr .ChangeColor -.MenuAction_Blue + .MenuAction_Blue ld b, DEXCOLOR_BLUE jr .ChangeColor -.MenuAction_Purple + .MenuAction_Purple ld b, DEXCOLOR_PURPLE jr .ChangeColor -.MenuAction_Brown + .MenuAction_Brown ld b, DEXCOLOR_BROWN jr .ChangeColor -.MenuAction_Green + .MenuAction_Green ld b, DEXCOLOR_GREEN jr .ChangeColor -.MenuAction_Pink + .MenuAction_Pink ld b, DEXCOLOR_PINK jr .ChangeColor -.MenuAction_Yellow + .MenuAction_Yellow ld b, DEXCOLOR_YELLOW jr .ChangeColor -.MenuAction_Cyan + .MenuAction_Cyan ld b, DEXCOLOR_CYAN jr .ChangeColor -.MenuAction_Gray + .MenuAction_Gray ld b, DEXCOLOR_GRAY jr .ChangeColor -.MenuAction_Mewtwo + .MenuAction_Mewtwo ld b, DEXCOLOR_MEWTWO -.ChangeColor: + .ChangeColor: ld a, [wCurPokedexColor] cp b jr z, .skip_changing_color @@ -429,20 +435,21 @@ Pokedex_UpdateColorOption: ld a, b ld [wCurPokedexColor], a -.skip_changing_color + .skip_changing_color call Pokedex_BlackOutBG ld a, DEXSTATE_COLOR_OPTION ld [wJumptableIndex], a ret ``` + This should be placed immediately after `.UnownMode`. This is the bread and butter of the color options screen. So let's break it down into its parts: -`Pokedex_DrawColorScreenBG` Is actually what creates the color option screen. Its a copy of the already used `Pokedex_DrawOptionScreenBG`, just adjusted to what we need. `Pokedex_UpdateColorOption` is similarly a copy of `Pokedex_UpdateOptionScreen`, but modified to remove the extra window at the bottom, since the colors don't really need descriptions. Also it uses the same button actions as that screen. This is optional, but the reason we've added the Pokéball symbol beside each color option is because that is the only use of the lighter color in the palette, and will give the player an additional idea of what the color will look like on a whole, without having to completely leave the menu. +`Pokedex_DrawColorScreenBG` is actually what creates the color option screen. It's a copy of the already used `Pokedex_DrawOptionScreenBG`, just adjusted to what we need. `Pokedex_UpdateColorOption` is similarly a copy of `Pokedex_UpdateOptionScreen`, but modified to remove the extra window at the bottom, since the colors don't really need descriptions. Also it uses the same button actions as that screen. This is optional, but the reason we've added the Poké Ball symbol beside each color option is because that is the only use of the lighter color in the palette, and will give the player an additional idea of what the color will look like on a whole, without having to completely leave the menu. -Now the `.MenuActionJumptable` is a copy of the same one used by the options screen to update the Pokédex mode its in, but modified in a way that it loads `wCurPokedexColor` we created earilier with one of the corresponding palettes and then updates the screen so to apply the color. +Now the `.MenuActionJumptable` is a copy of the same one used by the options screen to update the Pokédex mode it's in, but modified in a way that it loads `wCurPokedexColor` we created earilier with one of the corresponding palettes and then updates the screen so to apply the color. ```diff -Pokedex_DisplayModeDescription: + Pokedex_DisplayModeDescription: xor a ldh [hBGMapMode], a hlcoord 0, 12 @@ -459,22 +466,22 @@ Pokedex_DisplayModeDescription: ldh [hBGMapMode], a ret -.Modes: + .Modes: dw .NewMode dw .OldMode dw .ABCMode + dw .Color dw .UnownMode -.NewMode: + .NewMode: db "<PK><MN> are listed by" next "evolution type.@" -.OldMode: + .OldMode: db "<PK><MN> are listed by" next "official type.@" -.ABCMode: + .ABCMode: db "<PK><MN> are listed" next "alphabetically.@" @@ -482,24 +489,23 @@ Pokedex_DisplayModeDescription: + db "Change the color" + next "of the border.@" -.UnownMode: + .UnownMode: db "UNOWN are listed" next "in catching order.@" ``` -And finally this adds a desctription. +And finally this adds a description for our new Pokédex menu option. ## 4. Making the Pokédex load the color -Now that everything's set up on the Pokédex side, we need it to actually load the correct color. Doing some digging reveals that what we need is located in: +Now that everything's set up on the Pokédex side, we need it to actually load the correct color. Doing some digging reveals that what we need is located in [engine\gfx\cgb_layouts.asm](../blob/master/engine/gfx/cgb_layouts.asm). -[engine\gfx\cgb_layouts.asm](../blob/master/engine/gfx/cgb_layouts.asm). - -Searching the file for the default Pokédex color (`PREDEFPAL_POKEDEX`) will show it in `_CGB_Pokedex`, `_CGB_PokedexSearchOption`, and `_CGB_PokedexUnownMode`. +Searching the file for the default Pokédex color (`PREDEFPAL_POKEDEX`) will show it in `_CGB_Pokedex`, `_CGB_PokedexSearchOption`, and `_CGB_PokedexUnownMode`: ```diff -_CGB_Pokedex: + _CGB_Pokedex: ld de, wBGPals1 +- ld a, PREDEFPAL_POKEDEX + call CheckPokedexColor call GetPredefPal call LoadHLPaletteIntoDE ; dex interface palette @@ -516,49 +522,56 @@ _CGB_Pokedex: + cp DEXCOLOR_BLUE + jr nz, .Purple + ld a, PREDEFPAL_TRADE_TUBE -+ jr .setColor ++ ret ++ +.Purple + cp DEXCOLOR_PURPLE + jr nz, .Brown + ld a, PREDEFPAL_RB_PURPLEMON -+ jr .setColor ++ ret ++ +.Brown + cp DEXCOLOR_BROWN + jr nz, .Green + ld a, PREDEFPAL_RB_BROWNMON -+ jr .setColor ++ ret ++ +.Green + cp DEXCOLOR_GREEN + jr nz, .Pink + ld a, PREDEFPAL_RB_GREENMON -+ jr .setColor ++ ret ++ +.Pink + cp DEXCOLOR_PINK + jr nz, .Yellow + ld a, PREDEFPAL_RB_PINKMON -+ jr .setColor ++ ret ++ +.Yellow + cp DEXCOLOR_YELLOW + jr nz, .Cyan + ld a, PREDEFPAL_RB_YELLOWMON -+ jr .setColor ++ ret ++ +.Cyan + cp DEXCOLOR_CYAN + jr nz, .Gray + ld a, PREDEFPAL_RB_CYANMON -+ jr .setColor ++ ret ++ +.Gray + cp DEXCOLOR_GRAY + jr nz, .Red + ld a, PREDEFPAL_CGB_BADGE -+ jr .setColor ++ ret ++ +.Red + ld a, PREDEFPAL_POKEDEX -+.setColor + ret -PokedexQuestionMarkPalette: -INCLUDE "gfx/pokedex/question_mark.pal" + PokedexQuestionMarkPalette: + INCLUDE "gfx/pokedex/question_mark.pal" ``` We replaced the inital load of `PREDEFPAL_POKEDEX` with `CheckPokedexColor` that finds the correct color and sets it. Do this for the other two mentioned locations and your done. |