-
Notifications
You must be signed in to change notification settings - Fork 991
Portable PC in the START menu
Here we are with a novel tutorial, on how to add a portable PC in the START menu, which conveniently has just the space for one more voice :D I made it so that it appears together with the POKéDEX voice right after we get the, well, POKéDEX item, as I didn't feel like at all handling any weird interaction for the player having or not having a Pokémon. Of course it can be made available only after the player get the first mon, as it is the POKéMON voice itself.
Anyway, we need to edit just four files.
In engine/menus/start_sub_menus.asm
, add the following:
StartMenu_PortablePC:: ; new
ld a, [wCurMap] ; we don't want to cheese the Elite4, do we?
cp LORELEIS_ROOM
jr z, .cantUseItHere
cp BRUNOS_ROOM
jr z, .cantUseItHere
cp AGATHAS_ROOM
jr z, .cantUseItHere
cp LANCES_ROOM
jr z, .cantUseItHere
; if none of the above cp is met, let's open the pc and do the things
callfar ActivatePC ; main part
jr .done
.cantUseItHere ; no cheese!
ld hl, CantUsePCHere
call PrintText
.done
call LoadScreenTilesFromBuffer2 ; restore saved screen
call LoadTextBoxTilePatterns
call UpdateSprites
jp RedisplayStartMenu
CantUsePCHere:
text_far _CantUsePCHere
text_end
In data/text/text_2.asm
(or really, in any file, for what matters, but here it made the most sense to me), add the following:
_CantUsePCHere:: ; new, for portablePC
text "You cannot use"
line "this here!"
prompt
(yes, prompt
and not done
, otherwise it will autoclose immediately)
We need to edit engine/menus/draw_start_menu.asm
in the following ways:
DrawStartMenu::
CheckEvent EVENT_GOT_POKEDEX
; menu with pokedex + portablePC
hlcoord 10, 0
- lb bc, 14, 8
+ lb bc, 16, 8 ; edited for portablePC
jr nz, .drawTextBoxBorder
; shorter menu if the player doesn't have the pokedex + portablePC
hlcoord 10, 0
lb bc, 12, 8
.drawTextBoxBorder
[...]
CheckEvent EVENT_GOT_POKEDEX
; case for not having pokedex + portablePC
ld a, $06
jr z, .storeMenuItemCount
; case for having pokedex + portablePC
ld de, StartMenuPokedexText
call PrintStartMenuItem
- ld a, $07
+ ld a, $08 ; edited for portablePC
.storeMenuItemCount
[...]
.printSaveOrResetText
call PrintStartMenuItem
ld de, StartMenuOptionText
call PrintStartMenuItem
+ CheckEvent EVENT_GOT_POKEDEX ; new, for portablePC
+ jr z, .dontPrintPortablePC ; new, for portablePC
+ ld de, StartMenuPortablePCText ; new, for portablePC
+ call PrintStartMenuItem ; new, for portablePC
+.dontPrintPortablePC ; new, for portablePC
+ ld de, StartMenuExitText
call PlaceString
[...]
StartMenuOptionText:
db "OPTION@"
+StartMenuPortablePCText: ; new
+ db "PORT.PC@"
PrintStartMenuItem:
[...]
Finally, edit home/start_menu.asm
, as it follows:
[...]
; if the player pressed tried to go past the top item, wrap around to the bottom
CheckEvent EVENT_GOT_POKEDEX
- ld a, 6 ; there are 7 menu items with the pokedex, so the max index is 6
+ ld a, 7 ; edited; there are 8 menu items with the pokedex + portablePC, so the max index is 7
jr nz, .wrapMenuItemId
- dec a ; there are only 6 menu items without the pokedex
+ ld a, 5 ; there are only 6 menu items without the pokedex + portablePC
.wrapMenuItemId
[...]
; if the player pressed tried to go past the bottom item, wrap around to the top
CheckEvent EVENT_GOT_POKEDEX
ld a, [wCurrentMenuItem]
- ld c, 7 ; there are 7 menu items with the pokedex
+ ld c, 8 ; edited, there are 8 menu items with the pokedex + portablePC
jr nz, .checkIfPastBottom
- dec c ; there are only 6 menu items without the pokedex
+ ld c, 6 ; edited, there are only 6 menu items without the pokedex + portablePC
.checkIfPastBottom
[...]
CheckEvent EVENT_GOT_POKEDEX
ld a, [wCurrentMenuItem]
jr nz, .displayMenuItem
- inc a ; adjust position to account for missing pokedex menu item
+ inc a ; adjust position to account for missing pokedex menu item; from my understanding and testings this can stay the same, but please check
.displayMenuItem
cp 0
jp z, StartMenu_Pokedex
cp 1
jp z, StartMenu_Pokemon
cp 2
jp z, StartMenu_Item
cp 3
jp z, StartMenu_TrainerInfo
cp 4
jp z, StartMenu_SaveReset
cp 5
jp z, StartMenu_Option
+ ; new/edited
+ cp 6
+ jp z, .exitOrPortablePC
+ jr CloseStartMenu
+ .exitOrPortablePC
+ CheckEvent + EVENT_GOT_POKEDEX
+ jr z, CloseStartMenu
+ jp StartMenu_PortablePC
+ ; back to vanilla
; EXIT falls through to here
[...]
And we're done! Enjoy your portable PC! :)