diff options
Diffstat (limited to 'engine/menus')
-rw-r--r-- | engine/menus/display_text_id_init.asm | 9 | ||||
-rw-r--r-- | engine/menus/draw_start_menu.asm | 8 | ||||
-rw-r--r-- | engine/menus/league_pc.asm | 5 | ||||
-rw-r--r-- | engine/menus/link_menu.asm | 910 | ||||
-rw-r--r-- | engine/menus/main_menu.asm | 451 | ||||
-rw-r--r-- | engine/menus/naming_screen.asm | 30 | ||||
-rw-r--r-- | engine/menus/options.asm | 443 | ||||
-rw-r--r-- | engine/menus/party_menu.asm | 22 | ||||
-rw-r--r-- | engine/menus/players_pc.asm | 7 | ||||
-rw-r--r-- | engine/menus/pokedex.asm | 354 | ||||
-rw-r--r-- | engine/menus/save.asm | 170 | ||||
-rw-r--r-- | engine/menus/start_sub_menus.asm | 38 | ||||
-rw-r--r-- | engine/menus/text_box.asm | 36 | ||||
-rw-r--r-- | engine/menus/unused_input.asm | 129 |
14 files changed, 1870 insertions, 742 deletions
diff --git a/engine/menus/display_text_id_init.asm b/engine/menus/display_text_id_init.asm index 6ce76e7f..17f290b4 100644 --- a/engine/menus/display_text_id_init.asm +++ b/engine/menus/display_text_id_init.asm @@ -14,19 +14,16 @@ DisplayTextIDInit:: CheckEvent EVENT_GOT_POKEDEX ; start menu with pokedex hlcoord 10, 0 - ld b, $0e - ld c, $08 + lb bc, 14, 8 jr nz, .drawTextBoxBorder ; start menu without pokedex hlcoord 10, 0 - ld b, $0c - ld c, $08 + lb bc, 12, 8 jr .drawTextBoxBorder ; if text ID is not 0 (i.e. not the start menu) then do a standard dialogue text box .notStartMenu hlcoord 0, 12 - ld b, $04 - ld c, $12 + lb bc, 4, 18 .drawTextBoxBorder call TextBoxBorder .skipDrawingTextBoxBorder diff --git a/engine/menus/draw_start_menu.asm b/engine/menus/draw_start_menu.asm index 00d385bc..7ca75ecb 100644 --- a/engine/menus/draw_start_menu.asm +++ b/engine/menus/draw_start_menu.asm @@ -3,13 +3,11 @@ DrawStartMenu:: CheckEvent EVENT_GOT_POKEDEX ; menu with pokedex hlcoord 10, 0 - ld b, $0e - ld c, $08 + lb bc, 14, 8 jr nz, .drawTextBoxBorder ; shorter menu if the player doesn't have the pokedex hlcoord 10, 0 - ld b, $0c - ld c, $08 + lb bc, 12, 8 .drawTextBoxBorder call TextBoxBorder ld a, D_DOWN | D_UP | START | B_BUTTON | A_BUTTON @@ -63,7 +61,7 @@ StartMenuPokedexText: db "POKéDEX@" StartMenuPokemonText: - db "POKéMON@" + db "#MON@" StartMenuItemText: db "ITEM@" diff --git a/engine/menus/league_pc.asm b/engine/menus/league_pc.asm index 533454ad..882565ca 100644 --- a/engine/menus/league_pc.asm +++ b/engine/menus/league_pc.asm @@ -100,8 +100,7 @@ LeaguePCShowMon: call LoadFrontSpriteByMonIndex call GBPalNormal hlcoord 0, 13 - ld b, 2 - ld c, $12 + lb bc, 2, 18 call TextBoxBorder hlcoord 1, 15 ld de, HallOfFameNoText @@ -110,7 +109,7 @@ LeaguePCShowMon: ld de, wHoFTeamNo lb bc, 1, 3 call PrintNumber - farjp HoFDisplayMonInfo + farjp Func_7033f HallOfFameNoText: db "HALL OF FAME No @" diff --git a/engine/menus/link_menu.asm b/engine/menus/link_menu.asm new file mode 100644 index 00000000..2f2db573 --- /dev/null +++ b/engine/menus/link_menu.asm @@ -0,0 +1,910 @@ +Func_f531b:: + ld c, $14 + call DelayFrames + ld a, $1 + ld [wBuffer], a + xor a + ld [wUnknownSerialFlag_d499], a + coord hl, 0, 0 + lb bc, 4, 5 + call TextBoxBorder + ld de, Text_f5791 + coord hl, 1, 2 + call PlaceString + coord hl, 8, 0 + lb bc, 8, 10 + call TextBoxBorder + coord hl, 10, 2 + ld de, Text_f579c + call PlaceString + coord hl, 0, 10 + lb bc, 6, 18 + call TextBoxBorder + call UpdateSprites + xor a + ld [wUnusedCD37], a + ld [wd72d], a + ld [wd11e], a + ld hl, wTopMenuItemY + ld a, $2 + ld [hli], a + ld a, $9 + ld [hli], a + xor a + ld [hli], a + inc hl + ld a, $3 + ld [hli], a + ld a, $3 + ld [hli], a + xor a + ld [hl], a +.asm_f5377 + call Func_f56bd + call HandleMenuInput + and $3 + add a + add a + ld b, a + ld a, [wCurrentMenuItem] + cp $3 + jr nz, .asm_f5390 + bit 2, b + jr z, .asm_f5390 + dec a + ld b, $8 +.asm_f5390 + add b + add $c0 + ld [wLinkMenuSelectionSendBuffer], a + ld [wLinkMenuSelectionSendBuffer+1], a +.asm_f5399 + ld hl, wLinkMenuSelectionSendBuffer + ld a, [hl] + ldh [hSerialSendData], a + call Serial_ExchangeByte + push af + ld hl, wLinkMenuSelectionSendBuffer + ld a, [hl] + ldh [hSerialSendData], a + call Serial_ExchangeByte + pop bc + cp b + jr nz, .asm_f5399 + and $f0 + cp $c0 + jr nz, .asm_f5399 + ld a, b + and $c + jr nz, .asm_f53c4 + ld a, [wLinkMenuSelectionSendBuffer] + and $c + jr z, .asm_f5377 + jr .asm_f53df +.asm_f53c4 + ld a, [wLinkMenuSelectionSendBuffer] + and $c + jr z, .asm_f53d1 + ldh a, [hSerialConnectionStatus] + cp $2 + jr z, .asm_f53df +.asm_f53d1 + ld a, $1 + ld [wd11e], a + ld a, b + ld [wLinkMenuSelectionSendBuffer], a + and $3 + ld [wCurrentMenuItem], a +.asm_f53df + call DelayFrame + call DelayFrame + ld hl, wLinkMenuSelectionSendBuffer + ld a, [hl] + ldh [hSerialSendData], a + call Serial_ExchangeByte + call Serial_ExchangeByte + ld b, $14 +.loop + call DelayFrame + call Serial_SendZeroByte + dec b + jr nz, .loop + ld b, " " + ld c, " " + ld d, " " + ld e, "▷" + ld a, [wLinkMenuSelectionSendBuffer] + bit 3, a + jr nz, .asm_f541a + ld b, e + ld e, c + ld a, [wCurrentMenuItem] + and a + jr z, .asm_f541a + ld c, b + ld b, d + dec a + jr z, .asm_f541a + ld d, c + ld c, b +.asm_f541a + ld a, b + ldcoord_a 9, 2 + ld a, c + ldcoord_a 9, 4 + ld a, d + ldcoord_a 9, 6 + ld a, e + ldcoord_a 9, 8 + ld c, 40 + call DelayFrames + ld a, [wLinkMenuSelectionSendBuffer] + bit 3, a + jr nz, asm_f547f + ld a, [wCurrentMenuItem] + cp $3 + jr z, asm_f547f + inc a + ld [wUnknownSerialFlag_d499], a + ld a, [wCurrentMenuItem] + ld hl, PointerTable_f5488 + ld c, a + ld b, $0 + add hl, bc + add hl, bc + ld a, [hli] + ld h, [hl] + ld l, a + ld de, .returnaddress + push de + jp hl +.returnaddress + ld [wLinkMenuSelectionSendBuffer], a + xor a + ld [wUnknownSerialCounter], a + ld [wUnknownSerialCounter+1], a + call Serial_SyncAndExchangeNybble + ld a, [wLinkMenuSelectionSendBuffer] + and a + jr nz, asm_f547c + ld a, [wLinkMenuSelectionReceiveBuffer] + and a + jr nz, Func_f5476 + xor a + ld [wUnknownSerialCounter], a + ld [wUnknownSerialCounter+1], a + and a + ret + +Func_f5476:: + ld hl, ColosseumIneligibleText + call PrintText +asm_f547c:: + jp Func_f531b + +asm_f547f:: + xor a + ld [wUnknownSerialCounter], a + ld [wUnknownSerialCounter+1], a + scf + ret + +PointerTable_f5488:: + dw PokeCup + dw PikaCup + dw PetitCup + +PokeCup:: + ld hl, wPartyCount + ld a, [hli] + cp $3 + jp nz, NotThreeMonsInParty + ld b, $3 +.loop + ld a, [hli] + cp MEW + jp z, MewInParty + dec b + jr nz, .loop + dec hl + dec hl + cp [hl] ; is third mon second mon? + jp z, DuplicateSpecies + dec hl ; wPartySpecies + cp [hl] ; is third mon first mon? + jp z, DuplicateSpecies + ld a, [hli] + cp [hl] ; is first mon second mon? + jp z, DuplicateSpecies + ld a, [wPartyMon1Level] + cp 56 + jp nc, LevelAbove55 + cp 50 + jp c, LevelUnder50 + ld b, a + ld a, [wPartyMon2Level] + cp 56 + jp nc, LevelAbove55 + cp 50 + jp c, LevelUnder50 + ld c, a + ld a, [wPartyMon3Level] + cp 56 + jp nc, LevelAbove55 + cp 50 + jp c, LevelUnder50 + add b + add c + cp 156 + jp nc, CombinedLevelsGreaterThan155 + xor a + ret + +PikaCup:: + ld hl, wPartyCount + ld a, [hli] + cp $3 + jp nz, NotThreeMonsInParty + ld b, $3 +.loop + ld a, [hli] ; wPartySpecies + cp MEW + jp z, MewInParty + dec b + jr nz, .loop + dec hl + dec hl + cp [hl] ; is third mon second mon? + jp z, DuplicateSpecies + dec hl ; wPartySpecies + cp [hl] ; is third mon first mon? + jp z, DuplicateSpecies + ld a, [hli] + cp [hl] ; is first mon second mon? + jp z, DuplicateSpecies + ld a, [wPartyMon1Level] + cp 21 + jp nc, LevelAbove20 + cp 15 + jp c, LevelUnder15 + ld b, a + ld a, [wPartyMon2Level] + cp 21 + jp nc, LevelAbove20 + cp 15 + jp c, LevelUnder15 + ld c, a + ld a, [wPartyMon3Level] + cp 21 + jp nc, LevelAbove20 + cp 15 + jp c, LevelUnder15 + add b + add c + cp 51 + jp nc, CombinedLevelsAbove50 + xor a + ret + +PetitCup:: + ld hl, wPartyCount + ld a, [hli] + cp $3 + jp nz, NotThreeMonsInParty + ld b, $3 +.loop + ld a, [hli] + cp MEW + jp z, MewInParty + dec b + jr nz, .loop + dec hl + dec hl + cp [hl] ; is third mon second mon? + jp z, DuplicateSpecies + dec hl ; wPartySpecies + cp [hl] ; is third mon first mon? + jp z, DuplicateSpecies + ld a, [hli] + cp [hl] ; is first mon second mon? + jp z, DuplicateSpecies + dec hl + ld a, [hl] + ld [wcf91], a + push hl + callfar Func_3b10f + pop hl + jp c, asm_f56ad + inc hl + ld a, [hl] + ld [wcf91], a + push hl + callfar Func_3b10f + pop hl + jp c, asm_f56ad + inc hl + ld a, [hl] + ld [wcf91], a + push hl + callfar Func_3b10f + pop hl + jp c, asm_f56ad + dec hl + dec hl + ld b, $3 +.bigloop + ld a, [hli] + push hl + push bc + push af + dec a + ld c, a + ld b, $0 + ld hl, PokedexEntryPointers + add hl, bc + add hl, bc + ld de, wcd6d + ld bc, $2 + ld a, BANK(PokedexEntryPointers) + call FarCopyData + ld hl, wcd6d + ld a, [hli] + ld h, [hl] + ld l, a + ld de, wcd6d + ld bc, $14 + ld a, BANK(PokedexEntryPointers) + call FarCopyData + ld hl, wcd6d +.loop2 + ld a, [hli] + cp "@" + jr nz, .loop2 + ld a, [hli] + cp $7 + jp nc, asm_f5689 + add a + add a + ld b, a + add a + add b + ld b, a + ld a, [hli] + add b + cp $51 + jp nc, asm_f5689 + ld a, [hli] + sub $b9 + ld a, [hl] + sbc $1 + jp nc, asm_f569b + pop af + pop bc + pop hl + dec b + jr nz, .bigloop + ld a, [wPartyMon1Level] + cp 31 + jp nc, LevelAbove30 + cp 25 + jp c, LevelUnder25 + ld b, a + ld a, [wPartyMon2Level] + cp 31 + jp nc, LevelAbove30 + cp 25 + jp c, LevelUnder25 + ld c, a + ld a, [wPartyMon3Level] + cp 31 + jp nc, LevelAbove30 + cp 25 + jp c, LevelUnder25 + add b + add c + cp 81 + jp nc, CombinedLevelsAbove80 + xor a + ret + +NotThreeMonsInParty:: + ld hl, Colosseum3MonsText + call PrintText + ld a, $1 + ret + +MewInParty:: + ld hl, ColosseumMewText + call PrintText + ld a, $2 + ret + +DuplicateSpecies:: + ld hl, ColosseumDifferentMonsText + call PrintText + ld a, $3 + ret + +LevelAbove55:: + ld hl, ColosseumMaxL55Text + call PrintText + ld a, $4 + ret + +LevelUnder50:: + ld hl, ColosseumMinL50Text + call PrintText + ld a, $5 + ret + +CombinedLevelsGreaterThan155:: + ld hl, ColosseumTotalL155Text + call PrintText + ld a, $6 + ret + +LevelAbove30:: + ld hl, ColosseumMaxL30Text + call PrintText + ld a, $7 + ret + +LevelUnder25:: + ld hl, ColosseumMinL25Text + call PrintText + ld a, $8 + ret + +CombinedLevelsAbove80:: + ld hl, ColosseumTotalL80Text + call PrintText + ld a, $9 + ret + +LevelAbove20:: + ld hl, ColosseumMaxL20Text + call PrintText + ld a, $a + ret + +LevelUnder15:: + ld hl, ColosseumMinL15Text + call PrintText + ld a, $b + ret + +CombinedLevelsAbove50:: + ld hl, ColosseumTotalL50Text + call PrintText + ld a, $c + ret + +asm_f5689:: + pop af + pop bc + pop hl + ld [wd11e], a + call GetMonName + ld hl, ColosseumHeightText + call PrintText + ld a, $d + ret + +asm_f569b:: + pop af + pop bc + pop hl + ld [wd11e], a + call GetMonName + ld hl, ColosseumWeightText + call PrintText + ld a, $e + ret + +asm_f56ad:: + ld a, [hl] + ld [wd11e], a + call GetMonName + ld hl, ColosseumEvolvedText + call PrintText + ld a, $f + ret + +Func_f56bd:: + xor a + ldh [hAutoBGTransferEnabled], a + coord hl, 1, 11 + lb bc, 6, 18 + call ClearScreenArea + ld a, [wCurrentMenuItem] + cp $3 + jr nc, .asm_f56e6 + ld hl, PointerTable_f56ee + ld a, [wCurrentMenuItem] + ld c, a + ld b, $0 + add hl, bc + add hl, bc + ld a, [hli] + ld h, [hl] + ld l, a + ld d, h + ld e, l + coord hl, 1, 12 + call PlaceString +.asm_f56e6 + call Delay3 + ld a, $1 + ldh [hAutoBGTransferEnabled], a + ret + +PointerTable_f56ee:: + dw Text_f56f4 + dw Text_f5728 + dw Text_f575b + +Text_f56f4:: + db "LVs of 3<PKMN>:50-55" + next "Sum of LVs:155 MAX" + next "MEW can't attend.@" + +Text_f5728:: + db "LVs of 3<PKMN>:15-20" + next "Sum of LVs:50 MAX" + next "MEW can't attend.@" + +Text_f575b:: + db "3 Basic <PKMN>.LV25-30" + next "Sum of LVs:80 MAX" + next "6’8” and 44lb MAX@" + +Text_f5791:: + db "View" + next "Rules@" + +Text_f579c:: + db "# Cup" + next "Pika Cup" + next "Petit Cup" + next "CANCEL@" + +Colosseum3MonsText:: + text_far _Colosseum3MonsText + text_end + +ColosseumMewText:: + text_far _ColosseumMewText + text_end + +ColosseumDifferentMonsText:: + text_far _ColosseumDifferentMonsText + text_end + +ColosseumMaxL55Text:: + text_far _ColosseumMaxL55Text + text_end + +ColosseumMinL50Text:: + text_far _ColosseumMinL50Text + text_end + +ColosseumTotalL155Text:: + text_far _ColosseumTotalL155Text + text_end + +ColosseumMaxL30Text:: + text_far _ColosseumMaxL30Text + text_end + +ColosseumMinL25Text:: + text_far _ColosseumMinL25Text + text_end + +ColosseumTotalL80Text:: + text_far _ColosseumTotalL80Text + text_end + +ColosseumMaxL20Text:: + text_far _ColosseumMaxL20Text + text_end + +ColosseumMinL15Text:: + text_far _ColosseumMinL15Text + text_end + +ColosseumTotalL50Text:: + text_far _ColosseumTotalL50Text + text_end + +ColosseumHeightText:: + text_far _ColosseumHeightText + text_end + +ColosseumWeightText:: + text_far _ColosseumWeightText + text_end + +ColosseumEvolvedText:: + text_far _ColosseumEvolvedText + text_end + +ColosseumIneligibleText:: + text_far _ColosseumIneligibleText + text_end + +LinkMenu: + xor a + ld [wLetterPrintingDelayFlags], a + ld hl, wd72e + set 6, [hl] + ld hl, TextTerminator_f5a16 + call PrintText + call SaveScreenTilesToBuffer1 + ld hl, ColosseumWhereToText + call PrintText + hlcoord 5, 3 + lb bc, 8, 13 + call TextBoxBorder + call UpdateSprites + hlcoord 7, 5 + ld de, TradeCenterText + call PlaceString + xor a + ld [wUnusedCD37], a + ld [wd72d], a + ld [wd11e], a + ld hl, wTopMenuItemY + ld a, $5 + ld [hli], a + ld a, $6 + ld [hli], a + xor a + ld [hli], a + inc hl + ld a, $3 + ld [hli], a + ld [hli], a + xor a + ld [hl], a +.waitForInputLoop + call HandleMenuInput + and A_BUTTON | B_BUTTON + add a + add a + ld b, a + ld a, [wCurrentMenuItem] + cp $3 + jr nz, .asm_f586b + bit 2, b + jr z, .asm_f586b + dec a + ld b, $8 +.asm_f586b + add b + add $d0 + ld [wLinkMenuSelectionSendBuffer], a + ld [wLinkMenuSelectionSendBuffer + 1], a +.exchangeMenuSelectionLoop + call Serial_ExchangeLinkMenuSelection + ld a, [wLinkMenuSelectionReceiveBuffer] + ld b, a + and $f0 + cp $d0 + jr z, .asm_f5c7d + ld a, [wLinkMenuSelectionReceiveBuffer + 1] + ld b, a + and $f0 + cp $d0 + jr nz, .exchangeMenuSelectionLoop +.asm_f5c7d + ld a, b + and $c ; did the enemy press A or B? + jr nz, .enemyPressedAOrB +; the enemy didn't press A or B + ld a, [wLinkMenuSelectionSendBuffer] + and $c ; did the player press A or B? + jr z, .waitForInputLoop ; if neither the player nor the enemy pressed A or B, try again + jr .doneChoosingMenuSelection ; if the player pressed A or B but the enemy didn't, use the player's selection +.enemyPressedAOrB + ld a, [wLinkMenuSelectionSendBuffer] + and $c ; did the player press A or B? + jr z, .useEnemyMenuSelection ; if the enemy pressed A or B but the player didn't, use the enemy's selection +; the enemy and the player both pressed A or B +; The gameboy that is clocking the connection wins. + ldh a, [hSerialConnectionStatus] + cp USING_INTERNAL_CLOCK + jr z, .doneChoosingMenuSelection +.useEnemyMenuSelection + ld a, $1 + ld [wd11e], a + ld a, b + ld [wLinkMenuSelectionSendBuffer], a + and $3 + ld [wCurrentMenuItem], a ; wCurrentMenuItem +.doneChoosingMenuSelection + ldh a, [hSerialConnectionStatus] + cp USING_INTERNAL_CLOCK + jr nz, .skipStartingTransfer + call DelayFrame + call DelayFrame + ld a, START_TRANSFER_INTERNAL_CLOCK + ldh [rSC], a +.skipStartingTransfer + ld b, " " + ld c, " " + ld d, " " + ld e, "▷" + ld a, [wLinkMenuSelectionSendBuffer] + and (B_BUTTON << 2) ; was B button pressed? + jr nz, .updateCursorPosition +; A button was pressed + ld a, [wCurrentMenuItem] + cp $2 + jp z, .asm_f5963 + ld b, e + ld e, c + ld a, [wCurrentMenuItem] + and a + jr z, .updateCursorPosition + ld c, b + ld b, d + dec a + jr z, .updateCursorPosition + ld d, c + ld c, b +.updateCursorPosition + call Func_f59ec + call LoadScreenTilesFromBuffer1 + ld a, [wLinkMenuSelectionSendBuffer] + and (B_BUTTON << 2) ; was B button pressed? + jr nz, .choseCancel ; cancel if B pressed + ld a, [wCurrentMenuItem] + cp $2 + jr z, .choseCancel + xor a + ld [wWalkBikeSurfState], a ; start walking + ld a, [wCurrentMenuItem] + and a + ld a, COLOSSEUM + jr nz, .next + ld a, TRADE_CENTER +.next + ld [wd72d], a + ld hl, ColosseumPleaseWaitText + call PrintText + ld c, 50 + call DelayFrames + ld hl, wd732 + res 1, [hl] + ld a, [wDefaultMap] + ld [wDestinationMap], a + callfar SpecialWarpIn + ld c, 20 + call DelayFrames + xor a + ld [wMenuJoypadPollCount], a + ld [wSerialExchangeNybbleSendData], a + inc a ; LINK_STATE_IN_CABLE_CLUB + ld [wLinkState], a + ld [wEnteringCableClub], a + jpfar SpecialEnterMap +.choseCancel + xor a + ld [wMenuJoypadPollCount], a + call Delay3 + callfar CloseLinkConnection + ld hl, ColosseumCanceledText + call PrintText + ld hl, wd72e + res 6, [hl] + ret + +.asm_f5963 + ld a, [wd11e] + and a + jr nz, .asm_f5974 + ld b, " " + ld c, " " + ld d, "▷" + ld e, " " + call Func_f59ec +.asm_f5974 + xor a + ld [wBuffer], a + ld a, $ff + ld [wSerialExchangeNybbleReceiveData], a + ld a, $b + ld [wLinkMenuSelectionSendBuffer], a + ld b, $78 +.loop + ldh a, [hSerialConnectionStatus] + cp $2 + call z, DelayFrame + dec b + jr z, .asm_f59b2 + call Serial_ExchangeNybble + call DelayFrame + ld a, [wSerialExchangeNybbleReceiveData] + inc a + jr z, .loop + ld b, $f +.loop2 + call DelayFrame + call Serial_ExchangeNybble + dec b + jr nz, .loop2 + ld b, $f +.loop3 + call DelayFrame + call Serial_SendZeroByte + dec b + jr nz, .loop3 + jr .asm_f59d6 + +.asm_f59b2 + xor a + ld [wUnknownSerialCounter], a + ld [wUnknownSerialCounter+1], a + ld a, [wd11e] + and a + jr z, .asm_f59cd + ld b, " " + ld c, " " + ld d, " " + ld e, "▷" + call Func_f59ec + jp .choseCancel + +.asm_f59cd + ld hl, ColosseumVersionText + call PrintText + jp .choseCancel + +.asm_f59d6 + ld b, " " + ld c, " " + ld d, "▷" + ld e, " " + call Func_f59ec + call Func_f531b + jp c, .choseCancel + ld a, $f0 + jp .next + +Func_f59ec:: + ld a, b + ldcoord_a 6, 5 + ld a, c + ldcoord_a 6, 7 + ld a, d + ldcoord_a 6, 9 + ld a, e + ldcoord_a 6, 11 + ld c, 40 + call DelayFrames + ret + +ColosseumWhereToText: + text_far _ColosseumWhereToText + text_end + +ColosseumPleaseWaitText: + text_far _ColosseumPleaseWaitText + text_end + +ColosseumCanceledText: + text_far _ColosseumCanceledText + text_end + +ColosseumVersionText: + text_far _ColosseumVersionText + text_end + +TextTerminator_f5a16: + text_end + +TradeCenterText: + db "TRADE CENTER" + next "COLOSSEUM" + next "COLOSSEUM2" + next "CANCEL@" diff --git a/engine/menus/main_menu.asm b/engine/menus/main_menu.asm index 95404cce..7d81d2f6 100644 --- a/engine/menus/main_menu.asm +++ b/engine/menus/main_menu.asm @@ -34,8 +34,7 @@ MainMenu: jr z, .noSaveFile ; there's a save file hlcoord 0, 0 - ld b, 6 - ld c, 13 + lb bc, 6, 13 call TextBoxBorder hlcoord 2, 2 ld de, ContinueText @@ -43,8 +42,7 @@ MainMenu: jr .next2 .noSaveFile hlcoord 0, 0 - ld b, 4 - ld c, 13 + lb bc, 4, 13 call TextBoxBorder hlcoord 2, 2 ld de, NewGameText @@ -129,179 +127,21 @@ InitOptions: ld [wLetterPrintingDelayFlags], a ld a, 3 ; medium speed ld [wOptions], a + ld a, 64 ; audio? + ld [wPrinterSettings], a ret -LinkMenu: - xor a - ld [wLetterPrintingDelayFlags], a - ld hl, wd72e - set 6, [hl] - ld hl, LinkMenuEmptyText - call PrintText - call SaveScreenTilesToBuffer1 - ld hl, WhereWouldYouLikeText - call PrintText - hlcoord 5, 5 - ld b, $6 - ld c, $d - call TextBoxBorder - call UpdateSprites - hlcoord 7, 7 - ld de, CableClubOptionsText - call PlaceString - xor a - ld [wUnusedCD37], a - ld [wd72d], a - ld hl, wTopMenuItemY - ld a, $7 - ld [hli], a - ld a, $6 - ld [hli], a - xor a - ld [hli], a - inc hl - ld a, $2 - ld [hli], a - inc a - ; ld a, A_BUTTON | B_BUTTON - ld [hli], a ; wMenuWatchedKeys - xor a - ld [hl], a -.waitForInputLoop - call HandleMenuInput - and A_BUTTON | B_BUTTON - add a - add a - ld b, a - ld a, [wCurrentMenuItem] - add b - add $d0 - ld [wLinkMenuSelectionSendBuffer], a - ld [wLinkMenuSelectionSendBuffer + 1], a -.exchangeMenuSelectionLoop - call Serial_ExchangeLinkMenuSelection - ld a, [wLinkMenuSelectionReceiveBuffer] - ld b, a - and $f0 - cp $d0 - jr z, .asm_5c7d - ld a, [wLinkMenuSelectionReceiveBuffer + 1] - ld b, a - and $f0 - cp $d0 - jr nz, .exchangeMenuSelectionLoop -.asm_5c7d - ld a, b - and $c ; did the enemy press A or B? - jr nz, .enemyPressedAOrB -; the enemy didn't press A or B - ld a, [wLinkMenuSelectionSendBuffer] - and $c ; did the player press A or B? - jr z, .waitForInputLoop ; if neither the player nor the enemy pressed A or B, try again - jr .doneChoosingMenuSelection ; if the player pressed A or B but the enemy didn't, use the player's selection -.enemyPressedAOrB - ld a, [wLinkMenuSelectionSendBuffer] - and $c ; did the player press A or B? - jr z, .useEnemyMenuSelection ; if the enemy pressed A or B but the player didn't, use the enemy's selection -; the enemy and the player both pressed A or B -; The gameboy that is clocking the connection wins. - ldh a, [hSerialConnectionStatus] - cp USING_INTERNAL_CLOCK - jr z, .doneChoosingMenuSelection -.useEnemyMenuSelection - ld a, b - ld [wLinkMenuSelectionSendBuffer], a - and $3 - ld [wCurrentMenuItem], a -.doneChoosingMenuSelection - ldh a, [hSerialConnectionStatus] - cp USING_INTERNAL_CLOCK - jr nz, .skipStartingTransfer - call DelayFrame - call DelayFrame - ld a, START_TRANSFER_INTERNAL_CLOCK - ldh [rSC], a -.skipStartingTransfer - ld b, " " - ld c, " " - ld d, "▷" - ld a, [wLinkMenuSelectionSendBuffer] - and (B_BUTTON << 2) ; was B button pressed? - jr nz, .updateCursorPosition -; A button was pressed - ld a, [wCurrentMenuItem] - cp $2 - jr z, .updateCursorPosition - ld c, d - ld d, b - dec a - jr z, .updateCursorPosition - ld b, c - ld c, d -.updateCursorPosition - ld a, b - ldcoord_a 6, 7 - ld a, c - ldcoord_a 6, 9 - ld a, d - ldcoord_a 6, 11 - ld c, 40 - call DelayFrames - call LoadScreenTilesFromBuffer1 - ld a, [wLinkMenuSelectionSendBuffer] - and (B_BUTTON << 2) ; was B button pressed? - jr nz, .choseCancel ; cancel if B pressed - ld a, [wCurrentMenuItem] - cp $2 - jr z, .choseCancel - xor a - ld [wWalkBikeSurfState], a ; start walking - ld a, [wCurrentMenuItem] - and a - ld a, COLOSSEUM - jr nz, .next - ld a, TRADE_CENTER -.next - ld [wd72d], a - ld hl, PleaseWaitText +Func_5cc1: +; unused? + ld a, $6d + cp $80 + ret c ; will always be executed + ld hl, NotEnoughMemoryText call PrintText - ld c, 50 - call DelayFrames - ld hl, wd732 - res 1, [hl] - ld a, [wDefaultMap] - ld [wDestinationMap], a - call SpecialWarpIn - ld c, 20 - call DelayFrames - xor a - ld [wMenuJoypadPollCount], a - ld [wSerialExchangeNybbleSendData], a - inc a ; LINK_STATE_IN_CABLE_CLUB - ld [wLinkState], a - ld [wEnteringCableClub], a - jr SpecialEnterMap -.choseCancel - xor a - ld [wMenuJoypadPollCount], a - call Delay3 - call CloseLinkConnection - ld hl, LinkCanceledText - call PrintText - ld hl, wd72e - res 6, [hl] ret -WhereWouldYouLikeText: - text_far _WhereWouldYouLikeText - text_end - -PleaseWaitText: - text_far _PleaseWaitText - text_end - -LinkCanceledText: - text_far _LinkCanceledText +NotEnoughMemoryText: + text_far _NotEnoughMemoryText text_end StartNewGame: @@ -309,6 +149,8 @@ StartNewGame: res 1, [hl] StartNewGameDebug: call OakSpeech + ld a, $8 + ld [wPlayerMovingDirection], a ld c, 20 call DelayFrames @@ -324,6 +166,7 @@ SpecialEnterMap:: call ResetPlayerSpriteData ld c, 20 call DelayFrames + call Func_5cc1 ld a, [wEnteringCableClub] and a ret nz @@ -338,17 +181,11 @@ NewGameText: db "NEW GAME" next "OPTION@" -CableClubOptionsText: - db "TRADE CENTER" - next "COLOSSEUM" - next "CANCEL@" - DisplayContinueGameInfo: xor a ldh [hAutoBGTransferEnabled], a hlcoord 4, 7 - ld b, 8 - ld c, 14 + lb bc, 8, 14 call TextBoxBorder hlcoord 5, 9 ld de, SaveScreenInfoText @@ -371,8 +208,7 @@ PrintSaveScreenText: xor a ldh [hAutoBGTransferEnabled], a hlcoord 4, 0 - ld b, $8 - ld c, $e + lb bc, 8, 14 call TextBoxBorder call LoadTextBoxTilePatterns call UpdateSprites @@ -430,259 +266,8 @@ SaveScreenInfoText: next "TIME@" DisplayOptionMenu: - hlcoord 0, 0 - ld b, 3 - ld c, 18 - call TextBoxBorder - hlcoord 0, 5 - ld b, 3 - ld c, 18 - call TextBoxBorder - hlcoord 0, 10 - ld b, 3 - ld c, 18 - call TextBoxBorder - hlcoord 1, 1 - ld de, TextSpeedOptionText - call PlaceString - hlcoord 1, 6 - ld de, BattleAnimationOptionText - call PlaceString - hlcoord 1, 11 - ld de, BattleStyleOptionText - call PlaceString - hlcoord 2, 16 - ld de, OptionMenuCancelText - call PlaceString - xor a - ld [wCurrentMenuItem], a - ld [wLastMenuItem], a - inc a - ld [wLetterPrintingDelayFlags], a - ld [wOptionsCancelCursorX], a - ld a, 3 ; text speed cursor Y coordinate - ld [wTopMenuItemY], a - call SetCursorPositionsFromOptions - ld a, [wOptionsTextSpeedCursorX] ; text speed cursor X coordinate - ld [wTopMenuItemX], a - ld a, $01 - ldh [hAutoBGTransferEnabled], a ; enable auto background transfer - call Delay3 -.loop - call PlaceMenuCursor - call SetOptionsFromCursorPositions -.getJoypadStateLoop - call JoypadLowSensitivity - ldh a, [hJoy5] - ld b, a - and A_BUTTON | B_BUTTON | START | D_RIGHT | D_LEFT | D_UP | D_DOWN ; any key besides select pressed? - jr z, .getJoypadStateLoop - bit 1, b ; B button pressed? - jr nz, .exitMenu - bit 3, b ; Start button pressed? - jr nz, .exitMenu - bit 0, b ; A button pressed? - jr z, .checkDirectionKeys - ld a, [wTopMenuItemY] - cp 16 ; is the cursor on Cancel? - jr nz, .loop -.exitMenu - ld a, SFX_PRESS_AB - call PlaySound + callfar DisplayOptionMenu_ ret -.eraseOldMenuCursor - ld [wTopMenuItemX], a - call EraseMenuCursor - jp .loop -.checkDirectionKeys - ld a, [wTopMenuItemY] - bit 7, b ; Down pressed? - jr nz, .downPressed - bit 6, b ; Up pressed? - jr nz, .upPressed - cp 8 ; cursor in Battle Animation section? - jr z, .cursorInBattleAnimation - cp 13 ; cursor in Battle Style section? - jr z, .cursorInBattleStyle - cp 16 ; cursor on Cancel? - jr z, .loop -.cursorInTextSpeed - bit 5, b ; Left pressed? - jp nz, .pressedLeftInTextSpeed - jp .pressedRightInTextSpeed -.downPressed - cp 16 - ld b, -13 - ld hl, wOptionsTextSpeedCursorX - jr z, .updateMenuVariables - ld b, 5 - cp 3 - inc hl - jr z, .updateMenuVariables - cp 8 - inc hl - jr z, .updateMenuVariables - ld b, 3 - inc hl - jr .updateMenuVariables -.upPressed - cp 8 - ld b, -5 - ld hl, wOptionsTextSpeedCursorX - jr z, .updateMenuVariables - cp 13 - inc hl - jr z, .updateMenuVariables - cp 16 - ld b, -3 - inc hl - jr z, .updateMenuVariables - ld b, 13 - inc hl -.updateMenuVariables - add b - ld [wTopMenuItemY], a - ld a, [hl] - ld [wTopMenuItemX], a - call PlaceUnfilledArrowMenuCursor - jp .loop -.cursorInBattleAnimation - ld a, [wOptionsBattleAnimCursorX] ; battle animation cursor X coordinate - xor $0b ; toggle between 1 and 10 - ld [wOptionsBattleAnimCursorX], a - jp .eraseOldMenuCursor -.cursorInBattleStyle - ld a, [wOptionsBattleStyleCursorX] ; battle style cursor X coordinate - xor $0b ; toggle between 1 and 10 - ld [wOptionsBattleStyleCursorX], a - jp .eraseOldMenuCursor -.pressedLeftInTextSpeed - ld a, [wOptionsTextSpeedCursorX] ; text speed cursor X coordinate - cp 1 - jr z, .updateTextSpeedXCoord - cp 7 - jr nz, .fromSlowToMedium - sub 6 - jr .updateTextSpeedXCoord -.fromSlowToMedium - sub 7 - jr .updateTextSpeedXCoord -.pressedRightInTextSpeed - ld a, [wOptionsTextSpeedCursorX] ; text speed cursor X coordinate - cp 14 - jr z, .updateTextSpeedXCoord - cp 7 - jr nz, .fromFastToMedium - add 7 - jr .updateTextSpeedXCoord -.fromFastToMedium - add 6 -.updateTextSpeedXCoord - ld [wOptionsTextSpeedCursorX], a ; text speed cursor X coordinate - jp .eraseOldMenuCursor - -TextSpeedOptionText: - db "TEXT SPEED" - next " FAST MEDIUM SLOW@" - -BattleAnimationOptionText: - db "BATTLE ANIMATION" - next " ON OFF@" - -BattleStyleOptionText: - db "BATTLE STYLE" - next " SHIFT SET@" - -OptionMenuCancelText: - db "CANCEL@" - -; sets the options variable according to the current placement of the menu cursors in the options menu -SetOptionsFromCursorPositions: - ld hl, TextSpeedOptionData - ld a, [wOptionsTextSpeedCursorX] ; text speed cursor X coordinate - ld c, a -.loop - ld a, [hli] - cp c - jr z, .textSpeedMatchFound - inc hl - jr .loop -.textSpeedMatchFound - ld a, [hl] - ld d, a - ld a, [wOptionsBattleAnimCursorX] ; battle animation cursor X coordinate - dec a - jr z, .battleAnimationOn -.battleAnimationOff - set 7, d - jr .checkBattleStyle -.battleAnimationOn - res 7, d -.checkBattleStyle - ld a, [wOptionsBattleStyleCursorX] ; battle style cursor X coordinate - dec a - jr z, .battleStyleShift -.battleStyleSet - set 6, d - jr .storeOptions -.battleStyleShift - res 6, d -.storeOptions - ld a, d - ld [wOptions], a - ret - -; reads the options variable and places menu cursors in the correct positions within the options menu -SetCursorPositionsFromOptions: - ld hl, TextSpeedOptionData + 1 - ld a, [wOptions] - ld c, a - and $3f - push bc - ld de, 2 - call IsInArray - pop bc - dec hl - ld a, [hl] - ld [wOptionsTextSpeedCursorX], a ; text speed cursor X coordinate - hlcoord 0, 3 - call .placeUnfilledRightArrow - sla c - ld a, 1 ; On - jr nc, .storeBattleAnimationCursorX - ld a, 10 ; Off -.storeBattleAnimationCursorX - ld [wOptionsBattleAnimCursorX], a ; battle animation cursor X coordinate - hlcoord 0, 8 - call .placeUnfilledRightArrow - sla c - ld a, 1 - jr nc, .storeBattleStyleCursorX - ld a, 10 -.storeBattleStyleCursorX - ld [wOptionsBattleStyleCursorX], a ; battle style cursor X coordinate - hlcoord 0, 13 - call .placeUnfilledRightArrow -; cursor in front of Cancel - hlcoord 0, 16 - ld a, 1 -.placeUnfilledRightArrow - ld e, a - ld d, 0 - add hl, de - ld [hl], "▷" - ret - -; table that indicates how the 3 text speed options affect frame delays -; Format: -; 00: X coordinate of menu cursor -; 01: delay after printing a letter (in frames) -TextSpeedOptionData: - db 14, 5 ; Slow - db 7, 3 ; Medium - db 1, 1 ; Fast - db 7 ; default X coordinate (Medium) - db -1 ; end CheckForPlayerNameInSRAM: ; Check if the player name data in SRAM has a string terminator character diff --git a/engine/menus/naming_screen.asm b/engine/menus/naming_screen.asm index 9347212e..553c47d0 100644 --- a/engine/menus/naming_screen.asm +++ b/engine/menus/naming_screen.asm @@ -5,8 +5,7 @@ AskName: ld a, [wIsInBattle] dec a hlcoord 0, 0 - ld b, 4 - ld c, 11 + lb bc, 4, 11 call z, ClearScreenArea ; only if in wild battle ld a, [wcf91] ld [wd11e], a @@ -94,8 +93,7 @@ DisplayNamingScreen: call LoadEDTile farcall LoadMonPartySpriteGfx hlcoord 0, 4 - ld b, 9 - ld c, 18 + lb bc, 9, 18 call TextBoxBorder call PrintNamingText ld a, 3 @@ -324,12 +322,28 @@ DisplayNamingScreen: jp EraseMenuCursor LoadEDTile: +; In Red/Blue, the bank for the ED_tile was defined incorrectly as bank0 +; Luckily, the MBC3 treats loading $0 into $2000-$2fff range as loading bank1 into $4000-$7fff range +; Because Yellow uses the MBC5, loading $0 into $2000 - $2fff range will load bank0 instead of bank1 and thus incorrectly load the tile +; Instead of defining the correct bank, GameFreak decided to simply copy the ED_Tile in the function during HBlank ld de, ED_Tile ld hl, vFont tile $70 - ld bc, (ED_TileEnd - ED_Tile) / $8 - ; to fix the graphical bug on poor emulators - ;lb bc, BANK(ED_Tile), (ED_TileEnd - ED_Tile) / $8 - jp CopyVideoDataDouble + ld c, $4 ; number of copies needed +.waitForHBlankLoop + ldh a, [rSTAT] + and %10 ; in HBlank? + jr nz, .waitForHBlankLoop + ld a, [de] + ld [hli], a + ld [hli], a + inc de + ld a, [de] + ld [hli], a + ld [hli], a + inc de + dec c + jr nz, .waitForHBlankLoop + ret ED_Tile: INCBIN "gfx/font/ED.1bpp" diff --git a/engine/menus/options.asm b/engine/menus/options.asm new file mode 100644 index 00000000..110bef2a --- /dev/null +++ b/engine/menus/options.asm @@ -0,0 +1,443 @@ +DisplayOptionMenu_: + call InitOptionsMenu +.optionMenuLoop + call JoypadLowSensitivity + ldh a, [hJoy5] + and START | B_BUTTON + jr nz, .exitOptionMenu + call OptionsControl + jr c, .dpadDelay + call GetOptionPointer + jr c, .exitOptionMenu +.dpadDelay + call OptionsMenu_UpdateCursorPosition + call DelayFrame + call DelayFrame + call DelayFrame + jr .optionMenuLoop +.exitOptionMenu + ret + +GetOptionPointer: + ld a, [wOptionsCursorLocation] + ld e, a + ld d, $0 + ld hl, OptionMenuJumpTable + add hl, de + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + jp hl ; jump to the function for the current highlighted option + +OptionMenuJumpTable: + dw OptionsMenu_TextSpeed + dw OptionsMenu_BattleAnimations + dw OptionsMenu_BattleStyle + dw OptionsMenu_SpeakerSettings + dw OptionsMenu_GBPrinterBrightness + dw OptionsMenu_Dummy + dw OptionsMenu_Dummy + dw OptionsMenu_Cancel + +OptionsMenu_TextSpeed: + call GetTextSpeed + ldh a, [hJoy5] + bit 4, a ; right + jr nz, .pressedRight + bit 5, a + jr nz, .pressedLeft + jr .asm_41ce0 +.pressedRight + ld a, c + cp $2 + jr c, .asm_41cca + ld c, $ff +.asm_41cca + inc c + ld a, e + jr .asm_41cd6 +.pressedLeft + ld a, c + and a + jr nz, .asm_41cd4 + ld c, $3 +.asm_41cd4 + dec c + ld a, d +.asm_41cd6 + ld b, a + ld a, [wOptions] + and $f0 + or b + ld [wOptions], a +.asm_41ce0 + ld b, $0 + ld hl, TextSpeedStringsPointerTable + add hl, bc + add hl, bc + ld e, [hl] + inc hl + ld d, [hl] + hlcoord 14, 2 + call PlaceString + and a + ret + +TextSpeedStringsPointerTable: + dw FastText + dw MidText + dw SlowText + +FastText: + db "FAST@" +MidText: + db "MID @" +SlowText: + db "SLOW@" + +GetTextSpeed: + ld a, [wOptions] + and $f + cp $5 + jr z, .slowTextOption + cp $1 + jr z, .fastTextOption +; mid text option + ld c, $1 + lb de, 1, 5 + ret +.slowTextOption + ld c, $2 + lb de, 3, 1 + ret +.fastTextOption + ld c, $0 + lb de, 5, 3 + ret + +OptionsMenu_BattleAnimations: + ldh a, [hJoy5] + and D_RIGHT | D_LEFT + jr nz, .asm_41d33 + ld a, [wOptions] + and $80 ; mask other bits + jr .asm_41d3b +.asm_41d33 + ld a, [wOptions] + xor $80 + ld [wOptions], a +.asm_41d3b + ld bc, $0 + sla a + rl c + ld hl, AnimationOptionStringsPointerTable + add hl, bc + add hl, bc + ld e, [hl] + inc hl + ld d, [hl] + hlcoord 14, 4 + call PlaceString + and a + ret + +AnimationOptionStringsPointerTable: + dw AnimationOnText + dw AnimationOffText + +AnimationOnText: + db "ON @" +AnimationOffText: + db "OFF@" + +OptionsMenu_BattleStyle: + ldh a, [hJoy5] + and D_LEFT | D_RIGHT + jr nz, .asm_41d6b + ld a, [wOptions] + and $40 ; mask other bits + jr .asm_41d73 +.asm_41d6b + ld a, [wOptions] + xor $40 + ld [wOptions], a +.asm_41d73 + ld bc, $0 + sla a + sla a + rl c + ld hl, BattleStyleOptionStringsPointerTable + add hl, bc + add hl, bc + ld e, [hl] + inc hl + ld d, [hl] + hlcoord 14, 6 + call PlaceString + and a + ret + +BattleStyleOptionStringsPointerTable: + dw BattleStyleShiftText + dw BattleStyleSetText + +BattleStyleShiftText: + db "SHIFT@" +BattleStyleSetText: + db "SET @" + +OptionsMenu_SpeakerSettings: + ld a, [wOptions] + and $30 + swap a + ld c, a + ldh a, [hJoy5] + bit 4, a + jr nz, .pressedRight + bit 5, a + jr nz, .pressedLeft + jr .asm_41dca +.pressedRight + ld a, c + inc a + and $3 + jr .asm_41dba +.pressedLeft + ld a, c + dec a + and $3 +.asm_41dba + ld c, a + swap a + ld b, a + xor a + ldh [rNR51], a + ld a, [wOptions] + and $cf + or b + ld [wOptions], a +.asm_41dca + ld b, $0 + ld hl, SpeakerOptionStringsPointerTable + add hl, bc + add hl, bc + ld e, [hl] + inc hl + ld d, [hl] + hlcoord 8, 8 + call PlaceString + and a + ret + +SpeakerOptionStringsPointerTable: + dw MonoSoundText + dw Earphone1SoundText + dw Earphone2SoundText + dw Earphone3SoundText + +MonoSoundText: + db "MONO @" +Earphone1SoundText: + db "EARPHONE1@" +Earphone2SoundText: + db "EARPHONE2@" +Earphone3SoundText: + db "EARPHONE3@" + +OptionsMenu_GBPrinterBrightness: + call Func_41e7b + ldh a, [hJoy5] + bit 4, a + jr nz, .pressedRight + bit 5, a + jr nz, .pressedLeft + jr .asm_41e32 +.pressedRight + ld a, c + cp $4 + jr c, .asm_41e22 + ld c, $ff +.asm_41e22 + inc c + ld a, e + jr .asm_41e2e +.pressedLeft + ld a, c + and a + jr nz, .asm_41e2c + ld c, $5 +.asm_41e2c + dec c + ld a, d +.asm_41e2e + ld b, a + ld [wPrinterSettings], a +.asm_41e32 + ld b, $0 + ld hl, GBPrinterOptionStringsPointerTable + add hl, bc + add hl, bc + ld e, [hl] + inc hl + ld d, [hl] + hlcoord 8, 10 + call PlaceString + and a + ret + +GBPrinterOptionStringsPointerTable: + dw LightestPrintText + dw LighterPrintText + dw NormalPrintText + dw DarkerPrintText + dw DarkestPrintText + +LightestPrintText: + db "LIGHTEST@" +LighterPrintText: + db "LIGHTER @" +NormalPrintText: + db "NORMAL @" +DarkerPrintText: + db "DARKER @" +DarkestPrintText: + db "DARKEST @" + +Func_41e7b: + ld a, [wPrinterSettings] + and a + jr z, .asm_41e93 + cp $20 + jr z, .asm_41e99 + cp $60 + jr z, .asm_41e9f + cp $7f + jr z, .asm_41ea5 + ld c, $2 + lb de, $20, $60 + ret +.asm_41e93 + ld c, $0 + lb de, $7f, $20 + ret +.asm_41e99 + ld c, $1 + lb de, $0, $40 + ret +.asm_41e9f + ld c, $3 + lb de, $40, $7f + ret +.asm_41ea5 + ld c, $4 + lb de, $60, $0 + ret + +OptionsMenu_Dummy: + and a + ret + +OptionsMenu_Cancel: + ldh a, [hJoy5] + and A_BUTTON + jr nz, .pressedCancel + and a + ret +.pressedCancel + scf + ret + +OptionsControl: + ld hl, wOptionsCursorLocation + ldh a, [hJoy5] + cp D_DOWN + jr z, .pressedDown + cp D_UP + jr z, .pressedUp + and a + ret +.pressedDown + ld a, [hl] + cp $7 + jr nz, .doNotWrapAround + ld [hl], $0 + scf + ret +.doNotWrapAround + cp $4 + jr c, .regularIncrement + ld [hl], $6 +.regularIncrement + inc [hl] + scf + ret +.pressedUp + ld a, [hl] + cp $7 + jr nz, .doNotMoveCursorToPrintOption + ld [hl], $4 + scf + ret +.doNotMoveCursorToPrintOption + and a + jr nz, .regularDecrement + ld [hl], $8 +.regularDecrement + dec [hl] + scf + ret + +OptionsMenu_UpdateCursorPosition: + hlcoord 1, 1 + ld de, SCREEN_WIDTH + ld c, 16 +.loop + ld [hl], " " + add hl, de + dec c + jr nz, .loop + hlcoord 1, 2 + ld bc, SCREEN_WIDTH * 2 + ld a, [wOptionsCursorLocation] + call AddNTimes + ld [hl], "▶" + ret + +InitOptionsMenu: + hlcoord 0, 0 + lb bc, SCREEN_HEIGHT - 2, SCREEN_WIDTH - 2 + call TextBoxBorder + hlcoord 2, 2 + ld de, AllOptionsText + call PlaceString + hlcoord 2, 16 + ld de, OptionMenuCancelText + call PlaceString + xor a + ld [wOptionsCursorLocation], a + ld c, 5 ; the number of options to loop through +.loop + push bc + call GetOptionPointer ; updates the next option + pop bc + ld hl, wOptionsCursorLocation + inc [hl] ; moves the cursor for the highlighted option + dec c + jr nz, .loop + xor a + ld [wOptionsCursorLocation], a + inc a + ldh [hAutoBGTransferEnabled], a + call Delay3 + ret + +AllOptionsText: + db "TEXT SPEED :" + next "ANIMATION :" + next "BATTLESTYLE:" + next "SOUND:" + next "PRINT:@" + +OptionMenuCancelText: + db "CANCEL@" diff --git a/engine/menus/party_menu.asm b/engine/menus/party_menu.asm index 6648ab54..32f47f6a 100644 --- a/engine/menus/party_menu.asm +++ b/engine/menus/party_menu.asm @@ -30,9 +30,17 @@ RedrawPartyMenu_:: call GetPartyMonName pop hl call PlaceString ; print the pokemon's name - farcall WriteMonPartySpriteOAMByPartyIndex ; place the appropriate pokemon icon ldh a, [hPartyMonIndex] ld [wWhichPokemon], a + callfar IsThisPartymonStarterPikachu_Party + jr nc, .regularMon + call CheckPikachuFollowingPlayer + jr z, .regularMon + ld a, $ff + ldh [hPartyMonIndex], a +.regularMon + farcall WriteMonPartySpriteOAMByPartyIndex ; place the appropriate pokemon icon + ld a, [wWhichPokemon] inc a ldh [hPartyMonIndex], a call LoadMonData @@ -69,14 +77,14 @@ RedrawPartyMenu_:: pop hl push hl ld bc, SCREEN_WIDTH + 1 ; down 1 row and right 1 column - ldh a, [hFlagsFFF6] + ldh a, [hFlagsFFFA] set 0, a - ldh [hFlagsFFF6], a + ldh [hFlagsFFFA], a add hl, bc predef DrawHP2 ; draw HP bar and prints current / max HP - ldh a, [hFlagsFFF6] + ldh a, [hFlagsFFFA] res 0, a - ldh [hFlagsFFF6], a + ldh [hFlagsFFFA], a call SetPartyMenuHPBarColor ; color the HP bar (on SGB) pop hl jr .printLevel @@ -90,8 +98,8 @@ RedrawPartyMenu_:: jr nz, .placeMoveLearnabilityString ld de, .notAbleToLearnMoveText .placeMoveLearnabilityString - ld bc, 20 + 9 ; down 1 row and right 9 columns push hl + ld bc, 20 + 9 ; down 1 row and right 9 columns add hl, bc call PlaceString pop hl @@ -157,9 +165,9 @@ RedrawPartyMenu_:: ; if it does match ld de, .ableToEvolveText .placeEvolutionStoneString - ld bc, 20 + 9 ; down 1 row and right 9 columns pop hl push hl + ld bc, 20 + 9 ; down 1 row and right 9 columns add hl, bc call PlaceString pop hl diff --git a/engine/menus/players_pc.asm b/engine/menus/players_pc.asm index 5461be51..1fac030b 100644 --- a/engine/menus/players_pc.asm +++ b/engine/menus/players_pc.asm @@ -1,6 +1,4 @@ PlayerPC:: - ld hl, wd730 - set 6, [hl] ld a, ITEM_NAME ld [wNameListType], a call SaveScreenTilesToBuffer1 @@ -17,14 +15,15 @@ PlayerPC:: call PrintText PlayerPCMenu: + ld hl, wd730 + set 6, [hl] ld a, [wParentMenuItem] ld [wCurrentMenuItem], a ld hl, wFlags_0xcd60 set 5, [hl] call LoadScreenTilesFromBuffer2 hlcoord 0, 0 - ld b, $8 - ld c, $e + lb bc, 8, 14 call TextBoxBorder call UpdateSprites hlcoord 2, 2 diff --git a/engine/menus/pokedex.asm b/engine/menus/pokedex.asm index 2af8d714..8e4fef19 100644 --- a/engine/menus/pokedex.asm +++ b/engine/menus/pokedex.asm @@ -12,9 +12,10 @@ ShowPokedexMenu: ld [wd11e], a ldh [hJoy7], a .setUpGraphics + callfar LoadPokedexTilePatterns +.loop ld b, SET_PAL_GENERIC call RunPaletteCommand - callfar LoadPokedexTilePatterns .doPokemonListMenu ld hl, wTopMenuItemY ld a, 3 @@ -43,12 +44,15 @@ ShowPokedexMenu: call GBPalWhiteOutWithDelay3 call RunDefaultPaletteCommand jp ReloadMapData + .goToSideMenu call HandlePokedexSideMenu dec b jr z, .exitPokedex ; if the player chose Quit dec b jr z, .doPokemonListMenu ; if pokemon not seen or player pressed B button + dec b + jr z, .loop jp .setUpGraphics ; if pokemon data or area was shown ; handles the menu on the lower right in the pokedex screen @@ -79,20 +83,21 @@ HandlePokedexSideMenu: jr z, .exitSideMenu call PokedexToIndex ld hl, wTopMenuItemY - ld a, 10 + ld a, 8 ld [hli], a ; top menu item Y ld a, 15 ld [hli], a ; top menu item X xor a ld [hli], a ; current menu item ID inc hl - ld a, 3 + ld a, 4 ld [hli], a ; max menu item ID - ;ld a, A_BUTTON | B_BUTTON + ld a, A_BUTTON | B_BUTTON ld [hli], a ; menu watched keys (A button and B button) xor a ld [hli], a ; old menu item ID ld [wMenuWatchMovingOutOfBounds], a + ldh [hJoy7], a .handleMenuInput call HandleMenuInput bit 1, a ; was the B button pressed? @@ -105,6 +110,8 @@ HandlePokedexSideMenu: jr z, .choseCry dec a jr z, .choseArea + dec a + jr z, .chosePrint .choseQuit ld b, 1 .exitSideMenu @@ -118,6 +125,8 @@ HandlePokedexSideMenu: ld [wLastMenuItem], a pop af ld [wCurrentMenuItem], a + ld a, $1 + ldh [hJoy7], a push bc hlcoord 0, 3 ld de, 20 @@ -128,9 +137,9 @@ HandlePokedexSideMenu: .buttonBPressed push bc - hlcoord 15, 10 + hlcoord 15, 8 ld de, 20 - lb bc, " ", 7 + lb bc, " ", 9 call DrawTileLine ; cover up the menu cursor in the side menu pop bc jr .exitSideMenu @@ -152,13 +161,105 @@ HandlePokedexSideMenu: ld b, 0 jr .exitSideMenu +.chosePrint + ldh a, [hTileAnimations] + push af + xor a + ldh [hTileAnimations], a + ld a, [wd11e] + ld [wcf91], a + callfar PrintPokedexEntry + xor a + ldh [hAutoBGTransferEnabled], a + call ClearScreen + pop af + ldh [hTileAnimations], a + ld b, $3 + jr .exitSideMenu + ; handles the list of pokemon on the left of the pokedex screen ; sets carry flag if player presses A, unsets carry flag if player presses B HandlePokedexListMenu: + call Pokedex_DrawInterface +.loop + call Pokedex_PlacePokemonList + call GBPalNormal + call HandleMenuInput + bit BIT_B_BUTTON, a ; was the B button pressed? + jp nz, .buttonBPressed + bit BIT_A_BUTTON, a ; was the A button pressed? + jp nz, .buttonAPressed +.checkIfUpPressed + bit BIT_D_UP, a ; was Up pressed? + jr z, .checkIfDownPressed +.upPressed ; scroll up one row + ld a, [wListScrollOffset] + and a + jp z, .loop + dec a + ld [wListScrollOffset], a + jp .loop + +.checkIfDownPressed + bit BIT_D_DOWN, a ; was Down pressed? + jr z, .checkIfRightPressed +.downPressed ; scroll down one row + ld a, [wDexMaxSeenMon] + cp 7 + jp c, .loop ; can't if the list is shorter than 7 + sub 7 + ld b, a + ld a, [wListScrollOffset] + cp b + jp z, .loop + inc a + ld [wListScrollOffset], a + jp .loop + +.checkIfRightPressed + bit BIT_D_RIGHT, a ; was Right pressed? + jr z, .checkIfLeftPressed +.rightPressed ; scroll down 7 rows + ld a, [wDexMaxSeenMon] + cp 7 + jp c, .loop ; can't if the list is shorter than 7 + sub 6 + ld b, a + ld a, [wListScrollOffset] + add 7 + ld [wListScrollOffset], a + cp b + jp c, .loop + dec b + ld a, b + ld [wListScrollOffset], a + jp .loop + +.checkIfLeftPressed ; scroll up 7 rows + bit BIT_D_LEFT, a ; was Left pressed? + jr z, .buttonAPressed +.leftPressed + ld a, [wListScrollOffset] + sub 7 + ld [wListScrollOffset], a + jp nc, .loop + xor a + ld [wListScrollOffset], a + jp .loop + +.buttonAPressed + scf + ret + +.buttonBPressed + and a + ret + +Pokedex_DrawInterface: xor a ldh [hAutoBGTransferEnabled], a ; draw the horizontal line separating the seen and owned amounts from the menu - hlcoord 15, 8 + hlcoord 15, 6 ld a, "─" ld [hli], a ld [hli], a @@ -175,26 +276,26 @@ HandlePokedexListMenu: ld b, wPokedexSeenEnd - wPokedexSeen call CountSetBits ld de, wNumSetBits - hlcoord 16, 3 + hlcoord 16, 2 lb bc, 1, 3 call PrintNumber ; print number of seen pokemon ld hl, wPokedexOwned ld b, wPokedexOwnedEnd - wPokedexOwned call CountSetBits ld de, wNumSetBits - hlcoord 16, 6 + hlcoord 16, 5 lb bc, 1, 3 call PrintNumber ; print number of owned pokemon - hlcoord 16, 2 + hlcoord 16, 1 ld de, PokedexSeenText call PlaceString - hlcoord 16, 5 + hlcoord 16, 4 ld de, PokedexOwnText call PlaceString hlcoord 1, 1 ld de, PokedexContentsText call PlaceString - hlcoord 16, 10 + hlcoord 16, 8 ld de, PokedexMenuItemsText call PlaceString ; find the highest pokedex number among the pokemon the player has seen @@ -214,7 +315,37 @@ HandlePokedexListMenu: .storeMaxSeenPokemon ld a, b ld [wDexMaxSeenMon], a + ret + +DrawPokedexVerticalLine: + ld c, 9 ; height of line + ld de, SCREEN_WIDTH ; width of screen + ld a, $71 ; vertical line tile .loop + ld [hl], a + add hl, de + xor 1 ; toggle between vertical line tile and box tile + dec c + jr nz, .loop + ret + +PokedexSeenText: + db "SEEN@" + +PokedexOwnText: + db "OWN@" + +PokedexContentsText: + db "CONTENTS@" + +PokedexMenuItemsText: + db "DATA" + next "CRY" + next "AREA" + next "PRNT" + next "QUIT@" + +Pokedex_PlacePokemonList: xor a ldh [hAutoBGTransferEnabled], a hlcoord 4, 2 @@ -282,98 +413,8 @@ HandlePokedexListMenu: ld a, 01 ldh [hAutoBGTransferEnabled], a call Delay3 - call GBPalNormal - call HandleMenuInput - bit 1, a ; was the B button pressed? - jp nz, .buttonBPressed -.checkIfUpPressed - bit 6, a ; was Up pressed? - jr z, .checkIfDownPressed -.upPressed ; scroll up one row - ld a, [wListScrollOffset] - and a - jp z, .loop - dec a - ld [wListScrollOffset], a - jp .loop -.checkIfDownPressed - bit 7, a ; was Down pressed? - jr z, .checkIfRightPressed -.downPressed ; scroll down one row - ld a, [wDexMaxSeenMon] - cp 7 - jp c, .loop ; can't if the list is shorter than 7 - sub 7 - ld b, a - ld a, [wListScrollOffset] - cp b - jp z, .loop - inc a - ld [wListScrollOffset], a - jp .loop -.checkIfRightPressed - bit 4, a ; was Right pressed? - jr z, .checkIfLeftPressed -.rightPressed ; scroll down 7 rows - ld a, [wDexMaxSeenMon] - cp 7 - jp c, .loop ; can't if the list is shorter than 7 - sub 6 - ld b, a - ld a, [wListScrollOffset] - add 7 - ld [wListScrollOffset], a - cp b - jp c, .loop - dec b - ld a, b - ld [wListScrollOffset], a - jp .loop -.checkIfLeftPressed ; scroll up 7 rows - bit 5, a ; was Left pressed? - jr z, .buttonAPressed -.leftPressed - ld a, [wListScrollOffset] - sub 7 - ld [wListScrollOffset], a - jp nc, .loop - xor a - ld [wListScrollOffset], a - jp .loop -.buttonAPressed - scf - ret -.buttonBPressed - and a - ret - -DrawPokedexVerticalLine: - ld c, 9 ; height of line - ld de, SCREEN_WIDTH - ld a, $71 ; vertical line tile -.loop - ld [hl], a - add hl, de - xor 1 ; toggle between vertical line tile and box tile - dec c - jr nz, .loop ret -PokedexSeenText: - db "SEEN@" - -PokedexOwnText: - db "OWN@" - -PokedexContentsText: - db "CONTENTS@" - -PokedexMenuItemsText: - db "DATA" - next "CRY" - next "AREA" - next "QUIT@" - ; tests if a pokemon's bit is set in the seen or owned pokemon bit fields ; INPUT: ; [wd11e] = pokedex number @@ -401,8 +442,11 @@ ShowPokedexDataInternal: set 1, [hl] ld a, $33 ; 3/7 volume ldh [rNR50], a + ldh a, [hTileAnimations] + push af + xor a + ldh [hTileAnimations], a call GBPalWhiteOut ; zero all palettes - call ClearScreen ld a, [wd11e] ; pokemon ID ld [wcf91], a push af @@ -410,10 +454,42 @@ ShowPokedexDataInternal: call RunPaletteCommand pop af ld [wd11e], a - ldh a, [hTileAnimations] - push af - xor a + call DrawDexEntryOnScreen + call c, Pokedex_PrintFlavorTextAtRow11 +.waitForButtonPress + call JoypadLowSensitivity + ldh a, [hJoy5] + and A_BUTTON | B_BUTTON + jr z, .waitForButtonPress + pop af ldh [hTileAnimations], a + call GBPalWhiteOut + call ClearScreen + call RunDefaultPaletteCommand + call LoadTextBoxTilePatterns + call GBPalNormal + ld hl, wd72c + res 1, [hl] + ld a, $77 ; max volume + ldh [rNR50], a + ret + +HeightWeightText: + db "HT ?′??″" + next "WT ???lb@" + +; XXX does anything point to this? +PokeText: + db "#@" + +; horizontal line that divides the pokedex text description from the rest of the data +PokedexDataDividerLine: + db $68, $69, $6B, $69, $6B, $69, $6B, $69, $6B, $6B + db $6B, $6B, $69, $6B, $69, $6B, $69, $6B, $69, $6A + db "@" + +DrawDexEntryOnScreen: + call ClearScreen hlcoord 0, 0 ld de, 1 @@ -512,7 +588,8 @@ ShowPokedexDataInternal: ld a, c and a - jp z, .waitForButtonPress ; if the pokemon has not been owned, don't print the height, weight, or description + ret z ; if the pokemon has not been owned, don't print the height, weight, or description + inc de ; de = address of feet (height) ld a, [de] ; reads feet, but a is overwritten without being used hlcoord 12, 6 @@ -565,43 +642,48 @@ ShowPokedexDataInternal: ldh [hDexWeight], a ; restore original value of [hDexWeight] pop hl inc hl ; hl = address of pokedex description text + scf + ret + +Pokedex_PrintFlavorTextAtRow11: bccoord 1, 11 +Pokedex_PrintFlavorTextAtBC: ld a, %10 ldh [hClearLetterPrintingDelayFlags], a call TextCommandProcessor ; print pokedex description text xor a ldh [hClearLetterPrintingDelayFlags], a -.waitForButtonPress - call JoypadLowSensitivity - ldh a, [hJoy5] - and A_BUTTON | B_BUTTON - jr z, .waitForButtonPress - pop af - ldh [hTileAnimations], a - call GBPalWhiteOut - call ClearScreen - call RunDefaultPaletteCommand - call LoadTextBoxTilePatterns - call GBPalNormal - ld hl, wd72c - res 1, [hl] - ld a, $77 ; max volume - ldh [rNR50], a ret -HeightWeightText: - db "HT ?′??″" - next "WT ???lb@" - -; XXX does anything point to this? -PokeText: - db "#@" - -; horizontal line that divides the pokedex text description from the rest of the data -PokedexDataDividerLine: - db $68, $69, $6B, $69, $6B, $69, $6B, $69, $6B, $6B - db $6B, $6B, $69, $6B, $69, $6B, $69, $6B, $69, $6A - db "@" +Pokedex_PrepareDexEntryForPrinting: + hlcoord 0, 0 + ld de, SCREEN_WIDTH + lb bc, $66, $d + call DrawTileLine + hlcoord 19, 0 + ld b, $67 + call DrawTileLine + hlcoord 0, 13 + ld de, $1 + lb bc, $6f, SCREEN_WIDTH + call DrawTileLine + ld a, $6c + ldcoord_a 0, 13 + ld a, $6e + ldcoord_a 19, 13 + ld a, [wPrinterPokedexEntryTextPointer] + ld l, a + ld a, [wPrinterPokedexEntryTextPointer + 1] + ld h, a + bccoord 1, 1 + ldh a, [hFlagsFFFA] + set 3, a + ldh [hFlagsFFFA], a + call Pokedex_PrintFlavorTextAtBC + ldh a, [hFlagsFFFA] + res 3, a + ldh [hFlagsFFFA], a + ret ; draws a line of tiles ; INPUT: diff --git a/engine/menus/save.asm b/engine/menus/save.asm index 194fb810..13fdf729 100644 --- a/engine/menus/save.asm +++ b/engine/menus/save.asm @@ -32,10 +32,8 @@ FileDataDestroyedText: text_end LoadSAV0: - ld a, SRAM_ENABLE - ld [MBC1SRamEnable], a + call EnableSRAMAndLatchClockData ld a, $1 - ld [MBC1SRamBankingMode], a ld [MBC1SRamBank], a ld hl, sPlayerName ; hero name located in SRAM ld bc, sMainDataCheckSum - sPlayerName ; but here checks the full SAV @@ -79,10 +77,8 @@ LoadSAV0: jp SAVGoodChecksum LoadSAV1: - ld a, SRAM_ENABLE - ld [MBC1SRamEnable], a + call EnableSRAMAndLatchClockData ld a, $1 - ld [MBC1SRamBankingMode], a ld [MBC1SRamBank], a ld hl, sPlayerName ; hero name located in SRAM ld bc, sMainDataCheckSum - sPlayerName ; but here checks the full SAV @@ -99,10 +95,8 @@ LoadSAV1: jp SAVGoodChecksum LoadSAV2: - ld a, SRAM_ENABLE - ld [MBC1SRamEnable], a + call EnableSRAMAndLatchClockData ld a, $1 - ld [MBC1SRamBankingMode], a ld [MBC1SRamBank], a ld hl, sPlayerName ; hero name located in SRAM ld bc, sMainDataCheckSum - sPlayerName ; but here checks the full SAV @@ -126,9 +120,7 @@ SAVBadCheckSum: scf SAVGoodChecksum: - ld a, $0 - ld [MBC1SRamBankingMode], a - ld [MBC1SRamEnable], a + call DisableSRAMAndPrepareClockData ret LoadSAVIgnoreBadCheckSum: @@ -139,12 +131,16 @@ LoadSAVIgnoreBadCheckSum: SaveSAV: farcall PrintSaveScreenText + ld c, 10 + call DelayFrames ld hl, WouldYouLikeToSaveText call SaveSAVConfirm and a ;|0 = Yes|1 = No| ret nz + ld c, 10 + call DelayFrames ld a, [wSaveFileStatus] - dec a + cp $1 jr z, .save call SAVCheckRandomID jr z, .save @@ -154,24 +150,20 @@ SaveSAV: ret nz .save call SaveSAVtoSRAM - hlcoord 1, 13 - lb bc, 4, 18 - call ClearScreenArea - hlcoord 1, 14 - ld de, NowSavingString - call PlaceString - ld c, 120 + ld hl, SavingText + call PrintText + ld c, 128 call DelayFrames ld hl, GameSavedText call PrintText + ld c, 10 + call DelayFrames ld a, SFX_SAVE call PlaySoundWaitForCurrent call WaitForSoundToFinish ld c, 30 - jp DelayFrames - -NowSavingString: - db "Now saving...@" + call DelayFrames + ret SaveSAVConfirm: call PrintText @@ -187,6 +179,10 @@ WouldYouLikeToSaveText: text_far _WouldYouLikeToSaveText text_end +SavingText: + text_far _SavingText + text_end + GameSavedText: text_far _GameSavedText text_end @@ -196,10 +192,8 @@ OlderFileWillBeErasedText: text_end SaveSAVtoSRAM0: - ld a, SRAM_ENABLE - ld [MBC1SRamEnable], a + call EnableSRAMAndLatchClockData ld a, $1 - ld [MBC1SRamBankingMode], a ld [MBC1SRamBank], a ld hl, wPlayerName ld de, sPlayerName @@ -223,17 +217,13 @@ SaveSAVtoSRAM0: ld bc, sMainDataCheckSum - sPlayerName call SAVCheckSum ld [sMainDataCheckSum], a - xor a - ld [MBC1SRamBankingMode], a - ld [MBC1SRamEnable], a + call DisableSRAMAndPrepareClockData ret SaveSAVtoSRAM1: ; stored pokémon - ld a, SRAM_ENABLE - ld [MBC1SRamEnable], a + call EnableSRAMAndLatchClockData ld a, $1 - ld [MBC1SRamBankingMode], a ld [MBC1SRamBank], a ld hl, wBoxDataStart ld de, sCurBoxData @@ -243,16 +233,12 @@ SaveSAVtoSRAM1: ld bc, sMainDataCheckSum - sPlayerName call SAVCheckSum ld [sMainDataCheckSum], a - xor a - ld [MBC1SRamBankingMode], a - ld [MBC1SRamEnable], a + call DisableSRAMAndPrepareClockData ret SaveSAVtoSRAM2: - ld a, SRAM_ENABLE - ld [MBC1SRamEnable], a + call EnableSRAMAndLatchClockData ld a, $1 - ld [MBC1SRamBankingMode], a ld [MBC1SRamBank], a ld hl, wPartyDataStart ld de, sPartyData @@ -262,13 +248,18 @@ SaveSAVtoSRAM2: ld de, sMainData ld bc, wPokedexSeenEnd - wPokedexOwned call CopyData + ld hl, wPikachuHappiness + ld de, sMainData + $179 + ld a, [hli] + ld [de], a + inc de + ld a, [hl] + ld [de], a ld hl, sPlayerName ld bc, sMainDataCheckSum - sPlayerName call SAVCheckSum ld [sMainDataCheckSum], a - xor a - ld [MBC1SRamBankingMode], a - ld [MBC1SRamEnable], a + call DisableSRAMAndPrepareClockData ret SaveSAVtoSRAM:: @@ -351,13 +342,16 @@ ChangeBox:: call z, EmptyAllSRAMBoxes ; if so, empty all boxes in SRAM call DisplayChangeBoxMenu call UpdateSprites - ld hl, hFlagsFFF6 + ld hl, hFlagsFFFA set 1, [hl] call HandleMenuInput - ld hl, hFlagsFFF6 + ld hl, hFlagsFFFA res 1, [hl] bit 1, a ; pressed b ret nz + ld a, $b6 + call PlaySoundWaitForCurrent + call WaitForSoundToFinish call GetBoxSRAMLocation ld e, l ld d, h @@ -380,9 +374,6 @@ ChangeBox:: call SaveSAVtoSRAM ld hl, wChangeBoxSavedMapTextPointer call SetMapTextPointer - ld a, SFX_SAVE - call PlaySoundWaitForCurrent - call WaitForSoundToFinish ret WhenYouChangeBoxText: @@ -392,10 +383,7 @@ WhenYouChangeBoxText: CopyBoxToOrFromSRAM: ; copy an entire box from hl to de with b as the SRAM bank push hl - ld a, SRAM_ENABLE - ld [MBC1SRamEnable], a - ld a, $1 - ld [MBC1SRamBankingMode], a + call EnableSRAMAndLatchClockData ld a, b ld [MBC1SRamBank], a ld bc, wBoxDataEnd - wBoxDataStart @@ -413,9 +401,7 @@ CopyBoxToOrFromSRAM: call SAVCheckSum ld [sBank2AllBoxesChecksum], a ; sBank3AllBoxesChecksum call CalcIndividualBoxCheckSums - xor a - ld [MBC1SRamBankingMode], a - ld [MBC1SRamEnable], a + call DisableSRAMAndPrepareClockData ret DisplayChangeBoxMenu: @@ -436,21 +422,19 @@ DisplayChangeBoxMenu: ld [wCurrentMenuItem], a ld [wLastMenuItem], a hlcoord 0, 0 - ld b, 2 - ld c, 9 + lb bc, 2, 9 call TextBoxBorder ld hl, ChooseABoxText call PrintText hlcoord 11, 0 - ld b, 12 - ld c, 7 + lb bc, 12, 7 call TextBoxBorder - ld hl, hFlagsFFF6 + ld hl, hFlagsFFFA set 2, [hl] ld de, BoxNames hlcoord 13, 1 call PlaceString - ld hl, hFlagsFFF6 + ld hl, hFlagsFFFA res 2, [hl] ld a, [wCurrentBoxNum] and $7f @@ -513,19 +497,14 @@ BoxNoText: EmptyAllSRAMBoxes: ; marks all boxes in SRAM as empty (initialisation for the first time the ; player changes the box) - ld a, SRAM_ENABLE - ld [MBC1SRamEnable], a - ld a, $1 - ld [MBC1SRamBankingMode], a + call EnableSRAMAndLatchClockData ld a, 2 ld [MBC1SRamBank], a call EmptySRAMBoxesInBank ld a, 3 ld [MBC1SRamBank], a call EmptySRAMBoxesInBank - xor a - ld [MBC1SRamBankingMode], a - ld [MBC1SRamEnable], a + call DisableSRAMAndPrepareClockData ret EmptySRAMBoxesInBank: @@ -559,19 +538,14 @@ EmptySRAMBox: GetMonCountsForAllBoxes: ld hl, wBoxMonCounts push hl - ld a, SRAM_ENABLE - ld [MBC1SRamEnable], a - ld a, $1 - ld [MBC1SRamBankingMode], a + call EnableSRAMAndLatchClockData ld a, $2 ld [MBC1SRamBank], a call GetMonCountsForBoxesInBank ld a, $3 ld [MBC1SRamBank], a call GetMonCountsForBoxesInBank - xor a - ld [MBC1SRamBankingMode], a - ld [MBC1SRamEnable], a + call DisableSRAMAndPrepareClockData pop hl ; copy the count for the current box from WRAM @@ -604,10 +578,8 @@ SAVCheckRandomID: ; checks if Sav file is the same by checking player's name 1st letter ; and the two random numbers generated at game beginning ; (which are stored at wPlayerID)s - ld a, $0a - ld [MBC1SRamEnable], a + call EnableSRAMAndLatchClockData ld a, $01 - ld [MBC1SRamBankingMode], a ld [MBC1SRamBank], a ld a, [sPlayerName] and a @@ -670,34 +642,23 @@ LoadHallOfFameTeams: ; fallthrough HallOfFame_Copy: - ld a, SRAM_ENABLE - ld [MBC1SRamEnable], a - ld a, $1 - ld [MBC1SRamBankingMode], a + call EnableSRAMAndLatchClockData xor a ld [MBC1SRamBank], a call CopyData - xor a - ld [MBC1SRamBankingMode], a - ld [MBC1SRamEnable], a + call DisableSRAMAndPrepareClockData ret ClearSAV: - ld a, SRAM_ENABLE - ld [MBC1SRamEnable], a - ld a, $1 - ld [MBC1SRamBankingMode], a - xor a - call PadSRAM_FF - ld a, $1 - call PadSRAM_FF - ld a, $2 - call PadSRAM_FF - ld a, $3 + call EnableSRAMAndLatchClockData + ld a, $4 +.loop + dec a + push af call PadSRAM_FF - xor a - ld [MBC1SRamBankingMode], a - ld [MBC1SRamEnable], a + pop af + jr nz, .loop + call DisableSRAMAndPrepareClockData ret PadSRAM_FF: @@ -706,3 +667,16 @@ PadSRAM_FF: ld bc, SRAM_End - SRAM_Begin ld a, $ff jp FillMemory + +EnableSRAMAndLatchClockData: + ld a, $1 + ld [MBC1SRamBankingMode], a + ld a, SRAM_ENABLE + ld [MBC1SRamEnable], a + ret + +DisableSRAMAndPrepareClockData: + ld a, SRAM_DISABLE + ld [MBC1SRamBankingMode], a + ld [MBC1SRamEnable], a + ret diff --git a/engine/menus/start_sub_menus.asm b/engine/menus/start_sub_menus.asm index c0448121..05a1fa56 100644 --- a/engine/menus/start_sub_menus.asm +++ b/engine/menus/start_sub_menus.asm @@ -144,11 +144,14 @@ StartMenu_Pokemon:: call ChooseFlyDestination ld a, [wd732] bit 3, a ; did the player decide to fly? - jp nz, .goBackToMap + jr nz, .asm_5d4c call LoadFontTilePatterns ld hl, wd72e set 1, [hl] jp StartMenu_Pokemon +.asm_5d4c + call Func_1510 + jp .goBackToMap .cut bit BIT_CASCADEBADGE, a jp z, .newBadgeRequired @@ -165,15 +168,28 @@ StartMenu_Pokemon:: bit 1, [hl] res 1, [hl] jp z, .loop + ld a, [wcf91] + cp STARTER_PIKACHU + jr z, .surfingPikachu + ld a, $1 + jr .continue +.surfingPikachu + ld a, $2 +.continue + ld [wd473], a ld a, SURFBOARD ld [wcf91], a ld [wPseudoItemID], a call UseItem ld a, [wActionResultOrTookBattleTurn] and a - jp z, .loop + jr z, .reloadNormalSprite call GBPalWhiteOutWithDelay3 jp .goBackToMap +.reloadNormalSprite + xor a + ld [wd473], a + jp .loop .strength bit BIT_RAINBOWBADGE, a jp z, .newBadgeRequired @@ -217,6 +233,7 @@ StartMenu_Pokemon:: ld hl, wd732 set 3, [hl] set 6, [hl] + call Func_1510 ld hl, wd72e set 1, [hl] res 4, [hl] @@ -307,11 +324,11 @@ StartMenu_Item:: call PrintText jr .exitMenu .notInCableClubRoom - ld bc, wNumBagItems + ; store item bag pointer in wListPointer (for DisplayListMenuID) ld hl, wListPointer - ld a, c - ld [hli], a - ld [hl], b ; store item bag pointer in wListPointer (for DisplayListMenuID) + ld [hl], LOW(wNumBagItems) + inc hl + ld [hl], HIGH(wNumBagItems) xor a ld [wPrintItemPrices], a ld a, ITEMLISTMENU @@ -469,10 +486,11 @@ StartMenu_TrainerInfo:: call LoadScreenTilesFromBuffer2 ; restore saved screen call RunDefaultPaletteCommand call ReloadMapData + farcall DrawStartMenu ; XXX what difference does this make? call LoadGBPal pop af ldh [hTileAnimations], a - jp RedisplayStartMenu + jp RedisplayStartMenu_DoNotDrawStartMenu ; loads tile patterns and draws everything except for gym leader faces / badges DrawTrainerInfo: @@ -506,7 +524,7 @@ DrawTrainerInfo: ld de, vChars2 tile $20 ld bc, 8 * 8 tiles ld a, BANK(GymLeaderFaceAndBadgeTileGraphics) - call FarCopyData2 + call FarCopyData ld hl, TextBoxGraphics ld de, 13 tiles add hl, de ; hl = colon tile pattern @@ -514,7 +532,7 @@ DrawTrainerInfo: ld bc, 1 tiles ld a, BANK(TextBoxGraphics) push bc - call FarCopyData2 + call FarCopyData pop bc ld hl, TrainerInfoTextBoxTileGraphics tile 8 ; background tile pattern ld de, vChars1 tile $57 @@ -566,7 +584,7 @@ DrawTrainerInfo: TrainerInfo_FarCopyData: ld a, BANK(TrainerInfoTextBoxTileGraphics) - jp FarCopyData2 + jp FarCopyData TrainerInfo_NameMoneyTimeText: db "NAME/" diff --git a/engine/menus/text_box.asm b/engine/menus/text_box.asm index 5253ec48..7a315af2 100644 --- a/engine/menus/text_box.asm +++ b/engine/menus/text_box.asm @@ -134,8 +134,7 @@ DisplayMoneyBox: ld [wTextBoxID], a call DisplayTextBoxID hlcoord 13, 1 - ld b, 1 - ld c, 6 + lb bc, 1, 6 call ClearScreenArea hlcoord 12, 1 ld de, wPlayerMoney @@ -277,36 +276,10 @@ DisplayTwoOptionMenu: pop hl add hl, bc call PlaceString - ld hl, wd730 - res 6, [hl] ; turn on the printing delay - ld a, [wTwoOptionMenuID] - cp NO_YES_MENU - jr nz, .notNoYesMenu -; No/Yes menu -; this menu type ignores the B button -; it only seems to be used when confirming the deletion of a save file - xor a - ld [wTwoOptionMenuID], a - ld a, [wFlags_0xcd60] - push af - push hl - ld hl, wFlags_0xcd60 - bit 5, [hl] - set 5, [hl] ; don't play sound when A or B is pressed in menu - pop hl -.noYesMenuInputLoop - call HandleMenuInput - bit 1, a ; A button pressed? - jr nz, .noYesMenuInputLoop ; try again if A was not pressed - pop af - pop hl - ld [wFlags_0xcd60], a - ld a, SFX_PRESS_AB - call PlaySound - jr .pressedAButton -.notNoYesMenu xor a ld [wTwoOptionMenuID], a + ld hl, wd730 + res 6, [hl] ; turn on the printing delay call HandleMenuInput pop hl bit 1, a ; A button pressed? @@ -395,8 +368,7 @@ DisplayFieldMoveMonMenu: ; no field moves hlcoord 11, 11 - ld b, 5 - ld c, 7 + lb bc, 5, 7 call TextBoxBorder call UpdateSprites ld a, 12 diff --git a/engine/menus/unused_input.asm b/engine/menus/unused_input.asm new file mode 100644 index 00000000..ad5c36df --- /dev/null +++ b/engine/menus/unused_input.asm @@ -0,0 +1,129 @@ +HandleMenuInputDuplicate: ; unreferenced + xor a + ld [wPartyMenuAnimMonEnabled], a + +HandleMenuInputPokemonSelectionDuplicate: ; unreferenced + ldh a, [hDownArrowBlinkCount1] + push af + ldh a, [hDownArrowBlinkCount2] + push af ; save existing values on stack + xor a + ldh [hDownArrowBlinkCount1], a ; blinking down arrow timing value 1 + ld a, 6 + ldh [hDownArrowBlinkCount2], a ; blinking down arrow timing value 2 +.loop1 + xor a + ld [wAnimCounter], a ; counter for pokemon shaking animation + call PlaceMenuCursorDuplicate + call JoypadLowSensitivity + ldh a, [hJoy5] + and a ; was a key pressed? + jr nz, .keyPressed + pop af + ldh [hDownArrowBlinkCount2], a + pop af + ldh [hDownArrowBlinkCount1], a ; restore previous values + xor a + ld [wMenuWrappingEnabled], a ; disable menu wrapping + ret +.keyPressed + xor a + ld [wCheckFor180DegreeTurn], a + ldh a, [hJoy5] + ld b, a + bit 6, a ; pressed Up key? + jr z, .checkIfDownPressed +.upPressed + ld a, [wCurrentMenuItem] ; selected menu item + and a ; already at the top of the menu? + jr z, .checkOtherKeys +.notAtTop + dec a + ld [wCurrentMenuItem], a ; move selected menu item up one space + jr .checkOtherKeys +.checkIfDownPressed + bit 7, a + jr z, .checkOtherKeys +.downPressed + ld a, [wCurrentMenuItem] + inc a + ld c, a + ld a, [wMaxMenuItem] + cp c + jr c, .checkOtherKeys + ld a, c + ld [wCurrentMenuItem], a +.checkOtherKeys + ld a, [wMenuWatchedKeys] + and b ; does the menu care about any of the pressed keys? + jp z, .loop1 +.checkIfAButtonOrBButtonPressed + ldh a, [hJoy5] + and A_BUTTON | B_BUTTON + jr z, .skipPlayingSound +.AButtonOrBButtonPressed + ld a, SFX_PRESS_AB + call PlaySound ; play sound +.skipPlayingSound + pop af + ldh [hDownArrowBlinkCount2], a + pop af + ldh [hDownArrowBlinkCount1], a ; restore previous values + ldh a, [hJoy5] + ret + +PlaceMenuCursorDuplicate: + ld a, [wTopMenuItemY] + and a + jr z, .asm_f5ac0 + hlcoord 0, 0 + ld bc, SCREEN_WIDTH +.loop + add hl, bc + dec a + jr nz, .loop +.asm_f5ac0 + ld a, [wTopMenuItemX] + ld b, $0 + ld c, a + add hl, bc + push hl + ld a, [wLastMenuItem] + and a + jr z, .asm_f5ad5 + ld bc, $28 +.loop2 + add hl, bc + dec a + jr nz, .loop2 +.asm_f5ad5 + ld a, [hl] + cp "▶" + jr nz, .asm_f5ade + ld a, [wTileBehindCursor] + ld [hl], a +.asm_f5ade + pop hl + ld a, [wCurrentMenuItem] + and a + jr z, .asm_f5aec + ld bc, $28 +.loop3 + add hl, bc + dec a + jr nz, .loop3 +.asm_f5aec + ld a, [hl] + cp "▶" + jr z, .asm_f5af4 + ld [wTileBehindCursor], a +.asm_f5af4 + ld a, "▶" + ld [hl], a + ld a, l + ld [wMenuCursorLocation], a + ld a, h + ld [wMenuCursorLocation + 1], a + ld a, [wCurrentMenuItem] + ld [wLastMenuItem], a + ret |