From 042fc4bfe5f55df87712d33b6f832a591b136f1a Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 16 Nov 2015 21:46:36 -0500 Subject: Split up some more banks in main.asm --- engine/money.asm | 209 + engine/pokecenter_pc.asm | 705 ++ engine/timeset.asm | 771 ++ event/buena.asm | 2 +- event/daycare.asm | 768 ++ event/field_moves.asm | 312 + event/magnet_train.asm | 485 + home/menu.asm | 6 +- main.asm | 25290 ++++++++++++++++++++------------------------- wram.asm | 2 +- 10 files changed, 14276 insertions(+), 14274 deletions(-) create mode 100755 engine/money.asm create mode 100755 engine/pokecenter_pc.asm create mode 100755 engine/timeset.asm create mode 100755 event/daycare.asm create mode 100755 event/field_moves.asm create mode 100755 event/magnet_train.asm diff --git a/engine/money.asm b/engine/money.asm new file mode 100755 index 000000000..5935a23e7 --- /dev/null +++ b/engine/money.asm @@ -0,0 +1,209 @@ +GiveMoney:: ; 15fd7 + ld a, $3 + call AddMoney + ld bc, MaxMoney + ld a, $3 + call CompareMoney + jr z, .asm_15ff5 + jr c, .asm_15ff5 + ld hl, MaxMoney + ld a, [hli] + ld [de], a + inc de + ld a, [hli] + ld [de], a + inc de + ld a, [hli] + ld [de], a + scf + ret + +.asm_15ff5 + and a + ret +; 15ff7 + +MaxMoney: ; 15ff7 + dt 999999 +; 15ffa + + +TakeMoney:: ; 15ffa + ld a, 3 + call SubtractMoney + jr nc, .asm_16009 + xor a + ld [de], a + inc de + ld [de], a + inc de + ld [de], a + scf + ret + +.asm_16009 + and a + ret +; 1600b + +CompareMoney:: ; 1600b + ld a, $3 +CompareFunds: ; 1600d + push hl + push de + push bc + ld h, b + ld l, c + ld c, $0 + ld b, a +.loop1 + dec a + jr z, .done + inc de + inc hl + jr .loop1 + +.done + and a +.loop2 + ld a, [de] + sbc [hl] + jr z, .okay + inc c + +.okay + dec de + dec hl + dec b + jr nz, .loop2 + jr c, .set_carry + ld a, c + and a + jr .skip_carry + +.set_carry + ld a, $1 + and a + scf + +.skip_carry + pop bc + pop de + pop hl + ret +; 16035 + +SubtractMoney: ; 16035 + ld a, 3 +SubtractFunds: ; 16037 + push hl + push de + push bc + ld h, b + ld l, c + ld b, a + ld c, 0 +.loop + dec a + jr z, .done + inc de + inc hl + jr .loop + +.done + and a +.loop2 + ld a, [de] + sbc [hl] + ld [de], a + dec de + dec hl + dec b + jr nz, .loop2 + pop bc + pop de + pop hl + ret +; 16053 + +AddMoney: ; 16053 + ld a, $3 +AddFunds: ; 16055 + push hl + push de + push bc + ld h, b + ld l, c + ld b, a +.loop1 + dec a + jr z, .done + inc de + inc hl + jr .loop1 + +.done + and a +.loop2 + ld a, [de] + adc [hl] + ld [de], a + dec de + dec hl + dec b + jr nz, .loop2 + pop bc + pop de + pop hl + ret +; 1606f + +GiveCoins:: ; 1606f + ld a, 2 + ld de, Coins + call AddFunds + ld a, 2 + ld bc, .maxcoins + call CompareFunds + jr c, .not_maxed + ld hl, .maxcoins + ld a, [hli] + ld [de], a + inc de + ld a, [hli] + ld [de], a + scf + ret + +.not_maxed + and a + ret +; 1608d + +.maxcoins: ; 1608d + bigdw 9999 +; 1608f + + +TakeCoins:: ; 1608f + ld a, 2 + ld de, Coins + call SubtractFunds + jr nc, .asm_1609f + xor a + ld [de], a + inc de + ld [de], a + scf + ret + +.asm_1609f + and a + ret +; 160a1 + +CheckCoins:: ; 160a1 + ld a, $2 + ld de, Coins + jp CompareFunds +; 160a9 diff --git a/engine/pokecenter_pc.asm b/engine/pokecenter_pc.asm new file mode 100755 index 000000000..ee37edca5 --- /dev/null +++ b/engine/pokecenter_pc.asm @@ -0,0 +1,705 @@ +PokemonCenterPC: ; 1559a + call PC_CheckPartyForPokemon + ret c + call PC_PlayBootSound + ld hl, UnknownText_0x15a27 + call PC_DisplayText + ld hl, UnknownText_0x15a2c + call PC_DisplayTextWaitMenu + ld hl, .TopMenu + call LoadMenuDataHeader +.loop + xor a + ld [hBGMapMode], a + call .ChooseWhichPCListToUse + ld [wcf76], a + call DoNthMenu + jr c, .shutdown + ld a, [MenuSelection] + ld hl, .JumpTable + call MenuJumptable + jr nc, .loop + +.shutdown + call PC_PlayShutdownSound + call ExitMenu + call WriteBackup + ret +; 155d6 + +.TopMenu: ; 0x155d6 + db $48 ; flags + db 00, 00 ; start coords + db 12, 15 ; end coords + dw .MenuData2 + db 1 ; default option +; 0x155de + +.MenuData2: ; 0x155de + db $a0 ; flags + db 0 ; items + dw .WhichPC + dw PlaceNthMenuStrings + dw .JumpTable +; 0x155e6 + +.JumpTable: ; 155e6 + dw PlayersPC, .String_PlayersPC + dw BillsPC, .String_BillsPC + dw OaksPC, .String_OaksPC + dw HallOfFamePC, .String_HallOfFame + dw TurnOffPC, .String_TurnOff +; 155fa + +.String_PlayersPC: db "'s PC@" +.String_BillsPC: db "BILL's PC@" +.String_OaksPC: db "PROF.OAK's PC@" +.String_HallOfFame: db "HALL OF FAME@" +.String_TurnOff: db "TURN OFF@" +; 1562c + +.WhichPC: ; 1562c + ; before pokedex + db 3 ; items + db 1, 0, 4 ; bill's, player's, turn off + db -1 + + ; before Hall Of Fame + db 4 ; items + db 1, 0, 2, 4 ; bill's, player's, oak's, turn off + db -1 + + ; postgame + db 5 ; items + db 1, 0, 2, 3, 4 ; bill's, player's, oak's, hall of fame, turn off + db -1 +; 1563e + +.ChooseWhichPCListToUse: ; 1563e + call CheckReceivedDex + jr nz, .got_dex + ld a, $0 + ret + +.got_dex + ld a, [wHallOfFameCount] + and a + ld a, $1 + ret z + ld a, $2 + ret +; 15650 + +PC_CheckPartyForPokemon: ; 15650 + ld a, [PartyCount] + and a + ret nz + ld de, SFX_CHOOSE_PC_OPTION + call PlaySFX + ld hl, UnknownText_0x15663 + call PC_DisplayText + scf + ret +; 15663 + +UnknownText_0x15663: ; 0x15663 + ; Bzzzzt! You must have a #MON to use this! + text_jump UnknownText_0x1c1328 + db "@" +; 0x15668 + +BillsPC: ; 15668 + call PC_PlayChoosePCSound + ld hl, UnknownText_0x15a31 + call PC_DisplayText + callba _BillsPC + and a + ret +; 15679 (5:5679) + +PlayersPC: ; 15679 + call PC_PlayChoosePCSound + ld hl, UnknownText_0x15a36 + call PC_DisplayText + ld b, $0 + call _PlayersPC + and a + ret +; 15689 + +OaksPC: ; 15689 + call PC_PlayChoosePCSound + ld hl, UnknownText_0x15a3b + call PC_DisplayText + callba ProfOaksPC + and a + ret +; 1569a + +HallOfFamePC: ; 1569a + call PC_PlayChoosePCSound + call FadeToMenu + callba _HallOfFamePC + call Function2b3c + and a + ret +; 156ab + +TurnOffPC: ; 156ab + ld hl, UnknownText_0x15a40 + call PrintText + scf + ret +; 156b3 + +PC_PlayBootSound: ; 156b3 + ld de, SFX_BOOT_PC + jr PC_WaitPlaySFX + +PC_PlayShutdownSound: ; 156b8 + ld de, SFX_SHUT_DOWN_PC + call PC_WaitPlaySFX + call WaitSFX + ret + +PC_PlayChoosePCSound: ; 156c2 + ld de, SFX_CHOOSE_PC_OPTION + jr PC_WaitPlaySFX + +Function156c7: ; 156c7 + ld de, SFX_SWITCH_POKEMON + call PC_WaitPlaySFX + ld de, SFX_SWITCH_POKEMON + +PC_WaitPlaySFX: ; 156d0 + push de + call WaitSFX + pop de + call PlaySFX + ret +; 156d9 + +Function156d9: ; 156d9 + call PC_PlayBootSound + ld hl, UnknownText_0x156ff + call PC_DisplayText + ld b, $1 + call _PlayersPC + and a + jr nz, .asm_156f9 + call OverworldTextModeSwitch + call Function321c + call UpdateSprites + call PC_PlayShutdownSound + ld c, $0 + ret + +.asm_156f9 + call ClearBGPalettes + ld c, $1 + ret +; 156ff + +UnknownText_0x156ff: ; 0x156ff + ; turned on the PC. + text_jump UnknownText_0x1c1353 + db "@" +; 0x15704 + +_PlayersPC: ; 15704 + ld a, b + ld [wcf76], a + ld hl, UnknownText_0x157cc + call PC_DisplayTextWaitMenu + call Function15715 + call ExitMenu + ret +; 15715 + +Function15715: ; 15715 + xor a + ld [wd0d7], a + ld [wd0dd], a + ld hl, KrissPCMenuData + call LoadMenuDataHeader +.asm_15722 + call UpdateTimePals + call DoNthMenu + jr c, .asm_15731 + call MenuJumptable + jr nc, .asm_15722 + jr .asm_15732 + +.asm_15731 + xor a + +.asm_15732 + call ExitMenu + ret +; 15736 + +KrissPCMenuData: ; 0x15736 + db %01000000 + db 0, 0 ; top left corner coords (y, x) + db 12, 15 ; bottom right corner coords (y, x) + dw .KrissPCMenuData2 + db 1 ; default selected option + +.KrissPCMenuData2 + db %10100000 ; bit7 + db 0 ; # items? + dw .KrissPCMenuList1 + dw PlaceNthMenuStrings + dw .KrissPCMenuPointers + +.KrissPCMenuPointers ; 0x15746 + dw KrisWithdrawItemMenu, .WithdrawItem + dw KrisDepositItemMenu, .DepositItem + dw KrisTossItemMenu, .TossItem + dw KrisMailBoxMenu, .MailBox + dw KrisDecorationMenu, .Decoration + dw KrisLogOffMenu, .LogOff + dw KrisLogOffMenu, .TurnOff + +.WithdrawItem db "WITHDRAW ITEM@" +.DepositItem db "DEPOSIT ITEM@" +.TossItem db "TOSS ITEM@" +.MailBox db "MAIL BOX@" +.Decoration db "DECORATION@" +.TurnOff db "TURN OFF@" +.LogOff db "LOG OFF@" + +WITHDRAW_ITEM EQU 0 +DEPOSIT_ITEM EQU 1 +TOSS_ITEM EQU 2 +MAIL_BOX EQU 3 +DECORATION EQU 4 +TURN_OFF EQU 5 +LOG_OFF EQU 6 + +.KrissPCMenuList1 + db 5 + db WITHDRAW_ITEM + db DEPOSIT_ITEM + db TOSS_ITEM + db MAIL_BOX + db TURN_OFF + db -1 + +.KrissPCMenuList2 + db 6 + db WITHDRAW_ITEM + db DEPOSIT_ITEM + db TOSS_ITEM + db MAIL_BOX + db DECORATION + db LOG_OFF + db -1 + +PC_DisplayTextWaitMenu: ; 157bb + ld a, [Options] + push af + set NO_TEXT_SCROLL, a + ld [Options], a + call MenuTextBox + pop af + ld [Options], a + ret +; 157cc + +UnknownText_0x157cc: ; 0x157cc + ; What do you want to do? + text_jump UnknownText_0x1c1368 + db "@" +; 0x157d1 + +KrisWithdrawItemMenu: ; 0x157d1 + call LoadStandardMenuDataHeader + callba ClearPCItemScreen +.asm_157da + call Function15985 + jr c, .asm_157e4 + call Function157e9 + jr .asm_157da + +.asm_157e4 + call Function2b3c + xor a + ret +; 0x157e9 + +Function157e9: ; 0x157e9 + ; check if the item has a quantity + callba _CheckTossableItem + ld a, [wItemAttributeParamBuffer] + and a + jr z, .askquantity + + ; items without quantity are always ×1 + ld a, 1 + ld [wItemQuantityChangeBuffer], a + jr .withdraw + +.askquantity + ld hl, .HowManyText + call MenuTextBox + callba Function24fbf + call ExitMenu + call ExitMenu + jr c, .done + +.withdraw + ld a, [wItemQuantityChangeBuffer] + ld [Buffer1], a ; quantity + ld a, [wd107] + ld [Buffer2], a + ld hl, NumItems + call ReceiveItem + jr nc, .PackFull + ld a, [Buffer1] + ld [wItemQuantityChangeBuffer], a + ld a, [Buffer2] + ld [wd107], a + ld hl, PCItems + call TossItem + predef PartyMonItemName + ld hl, .WithdrewText + call MenuTextBox + xor a + ld [hBGMapMode], a + call ExitMenu + ret + +.PackFull + ld hl, .NoRoomText + call MenuTextBoxBackup + ret + +.done + ret +; 0x15850 + +.HowManyText ; 0x15850 + text_jump _KrissPCHowManyWithdrawText + db "@" + +.WithdrewText ; 0x15855 + text_jump _KrissPCWithdrewItemsText + db "@" + +.NoRoomText ; 0x1585a + text_jump _KrissPCNoRoomWithdrawText + db "@" + + +KrisTossItemMenu: ; 0x1585f + call LoadStandardMenuDataHeader + callba ClearPCItemScreen +.asm_15868 + call Function15985 + jr c, .asm_15878 + ld de, PCItems + callba Function129f4 + jr .asm_15868 + +.asm_15878 + call Function2b3c + xor a + ret +; 0x1587d + + +KrisDecorationMenu: ; 0x1587d + callba _KrisDecorationMenu + ld a, c + and a + ret z + scf + ret +; 0x15888 + + +KrisLogOffMenu: ; 0x15888 + xor a + scf + ret +; 0x1588b + + +KrisDepositItemMenu: ; 0x1588b + call Function158b8 + jr c, .asm_158b6 + call DisableSpriteUpdates + call LoadStandardMenuDataHeader + callba Function106a5 +.asm_1589c + callba Function106be + ld a, [wcf66] + and a + jr z, .asm_158b3 + call Function158cc + callba CheckRegisteredItem + jr .asm_1589c + +.asm_158b3 + call Function2b3c + +.asm_158b6 + xor a + ret +; 0x158b8 + +Function158b8: ; 0x158b8 + callba Function129d5 + ret nc + ld hl, UnknownText_0x158c7 + call MenuTextBoxBackup + scf + ret +; 0x158c7 + +UnknownText_0x158c7: ; 0x158c7 + ; No items here! + text_jump UnknownText_0x1c13df + db "@" +; 0x158cc + + +Function158cc: ; 0x158cc + ld a, [wc2ce] + push af + ld a, $0 + ld [wc2ce], a + callba CheckItemMenu + ld a, [wItemAttributeParamBuffer] + ld hl, .jumptable + rst JumpTable + pop af + ld [wc2ce], a + ret +; 0x158e7 + +.jumptable: ; 0x158e7 + dw .tossable + dw .no_toss + dw .no_toss + dw .no_toss + dw .tossable + dw .tossable + dw .tossable + +.no_toss: + ret + +.tossable: + ld a, [Buffer1] + push af + ld a, [Buffer2] + push af + call Function1590a + pop af + ld [Buffer2], a + pop af + ld [Buffer1], a + ret +; 0x1590a + +Function1590a: ; 0x1590a + callba _CheckTossableItem + ld a, [wItemAttributeParamBuffer] + and a + jr z, .asm_1591d + ld a, $1 + ld [wItemQuantityChangeBuffer], a + jr .asm_15933 + +.asm_1591d + ld hl, .HowManyText + call MenuTextBox + callba Function24fbf + push af + call ExitMenu + call ExitMenu + pop af + jr c, .asm_1596c + +.asm_15933 + ld a, [wItemQuantityChangeBuffer] + ld [Buffer1], a + ld a, [wd107] + ld [Buffer2], a + ld hl, PCItems + call ReceiveItem + jr nc, .asm_15965 + ld a, [Buffer1] + ld [wItemQuantityChangeBuffer], a + ld a, [Buffer2] + ld [wd107], a + ld hl, NumItems + call TossItem + predef PartyMonItemName + ld hl, .DepositText + call PrintText + ret + +.asm_15965 + ld hl, .NoRoomText + call PrintText + ret + +.asm_1596c + and a + ret +; 0x1596e + + +.HowManyText ; 0x1596e + text_jump _KrissPCHowManyDepositText + db "@" + +.DepositText ; 0x15973 + text_jump _KrissPCDepositItemsText + db "@" + +.NoRoomText ; 0x15978 + text_jump _KrissPCNoRoomDepositText + db "@" + + +KrisMailBoxMenu: ; 0x1597d + callba _KrisMailBoxMenu + xor a + ret +; 0x15985 + + +Function15985: ; 0x15985 + xor a + ld [wd0e3], a +.asm_15989 + ld a, [wc2ce] + push af + ld a, $0 + ld [wc2ce], a + ld hl, MenuData15a08 + call CopyMenuDataHeader + hlcoord 0, 0 + ld b, $a + ld c, $12 + call TextBox + ld a, [wd0d7] + ld [wMenuCursorBuffer], a + ld a, [wd0dd] + ld [wd0e4], a + call HandleScrollingMenu + ld a, [wd0e4] + ld [wd0dd], a + ld a, [MenuSelection2] + ld [wd0d7], a + pop af + ld [wc2ce], a + ld a, [wd0e3] + and a + jr nz, .asm_159d8 + ld a, [wcf73] + cp $2 + jr z, .asm_15a06 + cp $1 + jr z, .asm_159fb + cp $4 + jr z, .asm_159f2 + jr .asm_159f8 + +.asm_159d8 + ld a, [wcf73] + cp $2 + jr z, .asm_159e9 + cp $1 + jr z, .asm_159ef + cp $4 + jr z, .asm_159ef + jr .asm_159f8 + +.asm_159e9 + xor a + ld [wd0e3], a + jr .asm_159f8 + +.asm_159ef + call Function156c7 + +.asm_159f2 + callba Function2490c + +.asm_159f8 + jp .asm_15989 + +.asm_159fb + callba Function24706 + call Function1bee + and a + ret + +.asm_15a06 + scf + ret +; 0x15a08 + +MenuData15a08: ; 0x15a08 + db %01000000 + db 1, 4 ; start coords + db 10, 18 ; end coords + dw .MenuData2 + db 1 ; default option + +.MenuData2 + db %10110000 + db 4, 8 ; rows/cols? + db 2 ; horizontal spacing? + dbw 0, PCItems + dba PlaceMenuItemName + dba PlaceMenuItemQuantity + dba Function244c3 + +PC_DisplayText: ; 15a20 + call MenuTextBox + call ExitMenu + ret +; 15a27 + + +UnknownText_0x15a27: ; 0x15a27 + ; turned on the PC. + text_jump UnknownText_0x1c144d + db "@" +; 0x15a2c + +UnknownText_0x15a2c: ; 0x15a2c + ; Access whose PC? + text_jump UnknownText_0x1c1462 + db "@" +; 0x15a31 + +UnknownText_0x15a31: ; 0x15a31 + ; BILL's PC accessed. #MON Storage System opened. + text_jump UnknownText_0x1c1474 + db "@" +; 0x15a36 + +UnknownText_0x15a36: ; 0x15a36 + ; Accessed own PC. Item Storage System opened. + text_jump UnknownText_0x1c14a4 + db "@" +; 0x15a3b + +UnknownText_0x15a3b: ; 0x15a3b + ; PROF.OAK's PC accessed. #DEX Rating System opened. + text_jump UnknownText_0x1c14d2 + db "@" +; 0x15a40 + +UnknownText_0x15a40: ; 0x15a40 + ; … Link closed… + text_jump UnknownText_0x1c1505 + db "@" +; 0x15a45 diff --git a/engine/timeset.asm b/engine/timeset.asm new file mode 100755 index 000000000..00cdf9cac --- /dev/null +++ b/engine/timeset.asm @@ -0,0 +1,771 @@ +InitClock: ; 90672 (24:4672) +; Ask the player to set the time. + ld a, [hInMenu] + push af + ld a, $1 + ld [hInMenu], a + + ld a, $0 + ld [wc2ce], a + ld a, $10 + ld [MusicFade], a + ld a, MUSIC_NONE % $100 + ld [MusicFadeIDLo], a + ld a, MUSIC_NONE / $100 + ld [MusicFadeIDHi], a + ld c, 8 + call DelayFrames + call Function4dd + call ClearTileMap + call ClearSprites + ld b, SCGB_08 + call GetSGBLayout + xor a + ld [hBGMapMode], a + call LoadStandardFont + ld de, GFX_908fb + ld hl, VTiles2 tile $00 + lb bc, BANK(GFX_908fb), 1 + call Request1bpp + ld de, GFX_90903 + ld hl, VTiles2 tile $01 + lb bc, BANK(GFX_90903), 1 + call Request1bpp + ld de, GFX_9090b + ld hl, VTiles2 tile $02 + lb bc, BANK(GFX_9090b), 1 + call Request1bpp + call .ClearScreen + call WaitBGMap + call Function4a3 + ld hl, UnknownText_0x90874 + call PrintText + ld hl, wc608 + ld bc, 50 + xor a + call ByteFill + ld a, $a + ld [wInitHourBuffer], a + +.loop + ld hl, UnknownText_0x90879 + call PrintText + hlcoord 3, 7 + ld b, 2 + ld c, 15 + call TextBox + hlcoord 11, 7 + ld [hl], $1 + hlcoord 11, 10 + ld [hl], $2 + hlcoord 4, 9 + call DisplayHourOClock + ld c, 10 + call DelayFrames + +.SetHourLoop + call JoyTextDelay + call SetHour + jr nc, .SetHourLoop + + ld a, [wInitHourBuffer] + ld [StringBuffer2 + 1], a + call .ClearScreen + ld hl, UnknownText_0x90886 + call PrintText + call YesNoBox + jr nc, .HourIsSet + call .ClearScreen + jr .loop + +.HourIsSet + ld hl, UnknownText_0x9089a + call PrintText + hlcoord 11, 7 + lb bc, 2, 7 + call TextBox + hlcoord 15, 7 + ld [hl], $1 + hlcoord 15, 10 + ld [hl], $2 + hlcoord 12, 9 + call DisplayMinutesWithMinString + ld c, 10 + call DelayFrames + +.SetMinutesLoop + call JoyTextDelay + call SetMinutes + jr nc, .SetMinutesLoop + + ld a, [BattleMonNick + 5] + ld [StringBuffer2 + 2], a + call .ClearScreen + ld hl, UnknownText_0x908a4 + call PrintText + call YesNoBox + jr nc, .MinutesAreSet + call .ClearScreen + jr .HourIsSet + +.MinutesAreSet + call Function658 + ld hl, OakText_ResponseToSetTime + call PrintText + call WaitPressAorB_BlinkCursor + pop af + ld [hInMenu], a + ret + +.ClearScreen: ; 90783 (24:4783) + xor a + ld [hBGMapMode], a + hlcoord 0, 0 + ld bc, SCREEN_HEIGHT * SCREEN_WIDTH + xor a + call ByteFill + ld a, $1 + ld [hBGMapMode], a + ret + +SetHour: ; 90795 (24:4795) + ld a, [hJoyPressed] + and A_BUTTON + jr nz, .Confirm + + ld hl, hJoyLast + ld a, [hl] + and D_UP + jr nz, .up + ld a, [hl] + and D_DOWN + jr nz, .down + call DelayFrame + and a + ret + +.down + ld hl, wInitHourBuffer + ld a, [hl] + and a + jr nz, .DecreaseThroughMidnight + ld a, 23 + 1 +.DecreaseThroughMidnight + dec a + ld [hl], a + jr .okay + +.up + ld hl, wInitHourBuffer + ld a, [hl] + cp 23 + jr c, .AdvanceThroughMidnight + ld a, -1 +.AdvanceThroughMidnight + inc a + ld [hl], a + +.okay + hlcoord 4, 9 + ld a, " " + ld bc, 15 + call ByteFill + hlcoord 4, 9 + call DisplayHourOClock + call WaitBGMap + and a + ret + +.Confirm + scf + ret + +DisplayHourOClock: ; 907de (24:47de) + push hl + ld a, [wInitHourBuffer] + ld c, a + ld e, l + ld d, h + call PrintHour + inc hl + ld de, String_oclock + call PlaceString + pop hl + ret +; 907f1 (24:47f1) + +Function907f1: ; 907f1 + ld h, d + ld l, e + push hl + call DisplayHourOClock + pop de +rept 2 + inc de +endr + ld a, $9c + ld [de], a + inc de + push de + ld hl, $3 + add hl, de + ld a, [de] + inc de + ld [hli], a + ld a, [de] + ld [hl], a + pop hl + call DisplayMinutesWithMinString +rept 3 + inc hl +endr + ret +; 90810 + +SetMinutes: ; 90810 (24:4810) + ld a, [hJoyPressed] + and A_BUTTON + jr nz, .asm_90857 + ld hl, hJoyLast + ld a, [hl] + and D_UP + jr nz, .asm_90835 + ld a, [hl] + and D_DOWN + jr nz, .asm_90828 + call DelayFrame + and a + ret +.asm_90828 + ld hl, BattleMonNick + 5 + ld a, [hl] + and a + jr nz, .asm_90831 + ld a, 59 + 1 +.asm_90831 + dec a + ld [hl], a + jr .asm_90841 +.asm_90835 + ld hl, BattleMonNick + 5 + ld a, [hl] + cp 59 + jr c, .asm_9083f + ld a, -1 +.asm_9083f + inc a + ld [hl], a +.asm_90841 + hlcoord 12, 9 + ld a, " " + ld bc, 7 + call ByteFill + hlcoord 12, 9 + call DisplayMinutesWithMinString + call WaitBGMap + and a + ret +.asm_90857 + scf + ret + +DisplayMinutesWithMinString: ; 90859 (24:4859) + ld de, BattleMonNick + 5 + call PrintTwoDigitNumberRightAlign + inc hl + ld de, String_min + call PlaceString + ret + +PrintTwoDigitNumberRightAlign: ; 90867 (24:4867) + push hl + ld a, " " + ld [hli], a + ld [hl], a + pop hl + lb bc, PRINTNUM_RIGHTALIGN | 1, 2 + call PrintNum + ret +; 90874 (24:4874) + +UnknownText_0x90874: ; 0x90874 + ; Zzz… Hm? Wha…? You woke me up! Will you check the clock for me? + text_jump UnknownText_0x1bc29c + db "@" +; 0x90879 + +UnknownText_0x90879: ; 0x90879 + ; What time is it? + text_jump UnknownText_0x1bc2eb + db "@" +; 0x9087e + +String_oclock: + db "o'clock@" +; 90886 + +UnknownText_0x90886: ; 0x90886 + ; What?@ @ + text_jump UnknownText_0x1bc2fd + start_asm + hlcoord 1, 16 + call DisplayHourOClock + ld hl, UnknownText_0x90895 + ret +; 90895 (24:4895) + +UnknownText_0x90895: ; 0x90895 + ; ? + text_jump UnknownText_0x1bc305 + db "@" +; 0x9089a + +UnknownText_0x9089a: ; 0x9089a + ; How many minutes? + text_jump UnknownText_0x1bc308 + db "@" +; 0x9089f + +String_min: + db "min.@" +; 908a4 + +UnknownText_0x908a4: ; 0x908a4 + ; Whoa!@ @ + text_jump UnknownText_0x1bc31b + start_asm +; 0x908a9 + hlcoord 7, 14 + call DisplayMinutesWithMinString + ld hl, UnknownText_0x908b3 + ret +; 908b3 (24:48b3) + +UnknownText_0x908b3: ; 0x908b3 + ; ? + text_jump UnknownText_0x1bc323 + db "@" +; 0x908b8 + +OakText_ResponseToSetTime: ; 0x908b8 + start_asm + decoord 1, 14 + ld a, [wInitHourBuffer] + ld c, a + call PrintHour + ld [hl], ":" + inc hl + ld de, BattleMonNick + 5 + lb bc, PRINTNUM_LEADINGZEROS | 1, 2 + call PrintNum + ld b, h + ld c, l + ld a, [wInitHourBuffer] + cp 4 + jr c, .NITE + cp 11 + jr c, .MORN + cp 18 + jr c, .DAY +.NITE + ld hl, .sodark + ret +.MORN + ld hl, .overslept + ret +.DAY + ld hl, .yikes + ret +; 908ec (24:48ec) + +.overslept: ; 0x908ec + ; ! I overslept! + text_jump UnknownText_0x1bc326 + db "@" +; 0x908f1 + +.yikes: ; 0x908f1 + ; ! Yikes! I over- slept! + text_jump UnknownText_0x1bc336 + db "@" +; 0x908f6 + +.sodark: ; 0x908f6 + ; ! No wonder it's so dark! + text_jump UnknownText_0x1bc34f + db "@" +; 0x908fb + +GFX_908fb: ; 908fb +INCBIN "gfx/unknown/0908fb.2bpp" +GFX_90903: ; 90903 +INCBIN "gfx/unknown/090903.2bpp" +GFX_9090b: ; 9090b +INCBIN "gfx/unknown/09090b.2bpp" +; 90913 + +Special_SetDayOfWeek: ; 90913 + ld a, [hInMenu] + push af + ld a, $1 + ld [hInMenu], a + ld de, GFX_90903 + ld hl, VTiles1 tile $6f + lb bc, BANK(GFX_90903), 1 + call Request1bpp + ld de, GFX_9090b + ld hl, VTiles1 tile $75 + lb bc, BANK(GFX_9090b), 1 + call Request1bpp + xor a + ld [wd002], a +.asm_90936 + hlcoord 0, 12 + lb bc, 4, 18 + call TextBox + call LoadStandardMenuDataHeader + ld hl, UnknownText_0x90a3f + call PrintText + hlcoord 9, 3 + ld b, 2 + ld c, 9 + call TextBox + hlcoord 14, 3 + ld [hl], $ef + hlcoord 14, 6 + ld [hl], $f5 + hlcoord 10, 5 + call Function909de + call Function321c + ld c, 10 + call DelayFrames +.asm_9096a + call JoyTextDelay + call Function90993 + jr nc, .asm_9096a + call ExitMenu + call UpdateSprites + ld hl, UnknownText_0x90a44 + call PrintText + call YesNoBox + jr c, .asm_90936 + ld a, [wd002] + ld [StringBuffer2], a + call Function663 + call LoadStandardFont + pop af + ld [hInMenu], a + ret +; 90993 + +Function90993: ; 90993 + ld a, [hJoyPressed] + and A_BUTTON + jr z, .asm_9099b + scf + ret + +.asm_9099b + ld hl, hJoyLast + ld a, [hl] + and D_UP + jr nz, .asm_909ba + ld a, [hl] + and D_DOWN + jr nz, .asm_909ad + call DelayFrame + and a + ret + +.asm_909ad + ld hl, wd002 + ld a, [hl] + and a + jr nz, .asm_909b6 + ld a, 6 + 1 + +.asm_909b6 + dec a + ld [hl], a + jr .asm_909c6 + +.asm_909ba + ld hl, wd002 + ld a, [hl] + cp 6 + jr c, .asm_909c4 + ld a, -1 + +.asm_909c4 + inc a + ld [hl], a + +.asm_909c6 + xor a + ld [hBGMapMode], a + hlcoord 10, 4 + ld b, $2 + ld c, $9 + call ClearBox + hlcoord 10, 5 + call Function909de + call WaitBGMap + and a + ret +; 909de + +Function909de: ; 909de + push hl + ld a, [wd002] + ld e, a + ld d, 0 + ld hl, WeekdaysStrings +rept 2 + add hl, de +endr + ld a, [hli] + ld d, [hl] + ld e, a + pop hl + call PlaceString + ret +; 909f2 + +WeekdaysStrings: ; 909f2 + dw Sunday + dw Monday + dw Tuesday + dw Wednesday + dw Thursday + dw Friday + dw Saturday + dw Sunday + +Sunday: db " SUNDAY@" +Monday: db " MONDAY@" +Tuesday: db " TUESDAY@" +Wednesday: db "WEDNESDAY@" +Thursday: db "THURSDAY@" +Friday: db " FRIDAY@" +Saturday: db "SATURDAY@" + + +UnknownText_0x90a3f: ; 0x90a3f + ; What day is it? + text_jump UnknownText_0x1bc369 + db "@" +; 0x90a44 + +UnknownText_0x90a44: ; 0x90a44 + start_asm + hlcoord 1, 14 + call Function909de + ld hl, UnknownText_0x90a4f + ret +; 90a4f (24:4a4f) + +UnknownText_0x90a4f: ; 0x90a4f + ; , is it? + text_jump UnknownText_0x1bc37a + db "@" +; 0x90a54 + +Special_InitialSetDSTFlag: ; 90a54 + ld a, [wDST] + set 7, a + ld [wDST], a + hlcoord 1, 14 + lb bc, 3, 18 + call ClearBox + ld hl, UnknownText_0x90a6c + call PlaceWholeStringInBoxAtOnce + ret +; 90a6c + +UnknownText_0x90a6c: ; 90a6c + start_asm + call UpdateTime + ld a, [hHours] + ld b, a + ld a, [hMinutes] + ld c, a + decoord 1, 14 + callba PrintHoursMins + ld hl, TextJump_DSTIsThatOK + ret +; 90a83 (24:4a83) + +TextJump_DSTIsThatOK: ; 0x90a83 + ; DST, is that OK? + text_jump Text_DSTIsThatOK + db "@" +; 0x90a88 + +Special_InitialClearDSTFlag: ; 90a88 + ld a, [wDST] + res 7, a + ld [wDST], a + hlcoord 1, 14 + lb bc, 3, 18 + call ClearBox + ld hl, UnknownText_0x90aa0 + call PlaceWholeStringInBoxAtOnce + ret +; 90aa0 + +UnknownText_0x90aa0: ; 90aa0 + start_asm + call UpdateTime + ld a, [hHours] + ld b, a + ld a, [hMinutes] + ld c, a + decoord 1, 14 + callba PrintHoursMins + ld hl, UnknownText_0x90ab7 + ret +; 90ab7 + +UnknownText_0x90ab7: ; 0x90ab7 + ; , is that OK? + text_jump UnknownText_0x1c5ff1 + db "@" +; 0x90abc + +Function90abc: ; 90abc + hlcoord 1, 14 + lb bc, 3, SCREEN_WIDTH - 2 + call ClearBox + ld hl, UnknownText_0x90acc + call PlaceWholeStringInBoxAtOnce + ret +; 90acc + +UnknownText_0x90acc: ; 0x90acc + start_asm + + call UpdateTime + + hlcoord 1, 14 + ld [hl], "R" + inc hl + ld [hl], "T" + inc hl + ld [hl], " " + inc hl + + ld de, hRTCDayLo + call Function90b23 + + hlcoord 1, 16 + ld [hl], "D" + inc hl + ld [hl], "F" + inc hl + ld [hl], " " + inc hl + + ld de, StartDay + call Function90b23 + + ld [hl], " " + inc hl + + ld a, [wDST] + bit 7, a + jr z, .off + + ld [hl], "O" + inc hl + ld [hl], "N" + inc hl + jr .done + +.off + ld [hl], "O" + inc hl + ld [hl], "F" + inc hl + ld [hl], "F" + inc hl + +.done + ld hl, UnknownText_0x90b13 + ret +; 90b13 + +UnknownText_0x90b13: ; 0x90b13 + text "Now on DEBUG…" + prompt +; 0x90b23 + +Function90b23: ; 90b23 + lb bc, 1, 3 + call PrintNum + ld [hl], "." + inc hl + inc de + lb bc, PRINTNUM_LEADINGZEROS | 1, 2 + call PrintNum + ld [hl], ":" + inc hl + inc de + lb bc, PRINTNUM_LEADINGZEROS | 1, 2 + call PrintNum + ret +; 90b3e + +PrintHour: ; 90b3e (24:4b3e) + ld l, e + ld h, d + push bc + call GetTimeOfDayString + call PlaceString + ld l, c + ld h, b + inc hl + pop bc + call AdjustHourForAMorPM + ld [wd265], a + ld de, wd265 + call PrintTwoDigitNumberRightAlign + ret + +GetTimeOfDayString: ; 90b58 (24:4b58) + ld a, c + cp 4 + jr c, .nite + cp 10 + jr c, .morn + cp 18 + jr c, .day +.nite + ld de, .NITE + ret +.morn + ld de, .MORN + ret +.day + ld de, .DAY + ret +; 90b71 (24:4b71) + +.NITE: db "NITE@" +.MORN: db "MORN@" +.DAY: db "DAY@" +; 90b7f + +AdjustHourForAMorPM: +; Convert the hour stored in c (0-23) to a 1-12 value + ld a, c + or a + jr z, .midnight + cp 12 + ret c + ret z + sub 12 + ret + +.midnight + ld a, 12 + ret diff --git a/event/buena.asm b/event/buena.asm index 3662f110d..7079c0259 100644 --- a/event/buena.asm +++ b/event/buena.asm @@ -11,7 +11,7 @@ SpecialBuenasPassword: ; 8af6b add $2 ld [wMenuBorderRightCoord], a call BackUpTiles - call Function1e5d ; menu + call DoNthMenu ; menu callba Function4ae5e ld b, $0 ld a, [MenuSelection] diff --git a/event/daycare.asm b/event/daycare.asm new file mode 100755 index 000000000..3ea64d38c --- /dev/null +++ b/event/daycare.asm @@ -0,0 +1,768 @@ +Special_DayCareMan: ; 166d6 + ld hl, wDaycareMan + bit 0, [hl] + jr nz, .asm_166fe + ld hl, wDaycareMan + ld a, $0 + call Function1678f + jr c, .asm_16724 + call Function16798 + jr c, .asm_16721 + callba Functionde2a + ld hl, wDaycareMan + set 0, [hl] + call Function167f6 + call Function16a3b + ret + +.asm_166fe + callba Functione698 + ld hl, wBreedMon1Nick + call Function1686d + call Function16807 + jr c, .asm_16721 + callba Functiondd21 + call Function16850 + ld hl, wDaycareMan + res 0, [hl] + res 5, [hl] + jr .asm_16724 + +.asm_16721 + call Function1689b + +.asm_16724 + ld a, $13 + call Function1689b + ret +; 1672a + +Special_DayCareLady: ; 1672a + ld hl, wDaycareLady + bit 0, [hl] + jr nz, .asm_16752 + ld hl, wDaycareLady + ld a, $2 + call Function16781 + jr c, .asm_1677b + call Function16798 + jr c, .asm_16778 + callba Functionde37 + ld hl, wDaycareLady + set 0, [hl] + call Function167f6 + call Function16a3b + ret + +.asm_16752 + callba Functione6b3 + ld hl, wBreedMon2Nick + call Function1686d + call Function16807 + jr c, .asm_16778 + callba Functiondd42 + call Function16850 + ld hl, wDaycareLady + res 0, [hl] + ld hl, wDaycareMan + res 5, [hl] + jr .asm_1677b + +.asm_16778 + call Function1689b + +.asm_1677b + ld a, $13 + call Function1689b + ret +; 16781 + +Function16781: ; 16781 + bit 7, [hl] + jr nz, .asm_16788 + set 7, [hl] + inc a + +.asm_16788 + call Function1689b + call YesNoBox + ret +; 1678f + +Function1678f: ; 1678f + set 7, [hl] + call Function1689b + call YesNoBox + ret +; 16798 + +Function16798: ; 16798 + ld a, [PartyCount] + cp 2 + jr c, .asm_167e5 + ld a, 4 + call Function1689b + ld b, 6 + callba Function5001d + jr c, .asm_167dd + ld a, [CurPartySpecies] + cp EGG + jr z, .asm_167e1 + callba CheckCurPartyMonFainted + jr c, .asm_167e9 + ld hl, PartyMon1Item + ld bc, PARTYMON_STRUCT_LENGTH + ld a, [CurPartyMon] + call AddNTimes + ld d, [hl] + callba ItemIsMail + jr c, .asm_167ed + ld hl, PartyMonNicknames + ld a, [CurPartyMon] + call GetNick + and a + ret + +.asm_167dd + ld a, $12 + scf + ret + +.asm_167e1 + ld a, $6 + scf + ret + +.asm_167e5 + ld a, $7 + scf + ret + +.asm_167e9 + ld a, $8 + scf + ret + +.asm_167ed + ld a, $a + scf + ret +; 167f1 + +UnknownText_0x167f1: ; 0x167f1 + ; + text_jump UnknownText_0x1bdaa7 + db "@" +; 0x167f6 + +Function167f6: ; 167f6 + ld a, $5 + call Function1689b + ld a, [CurPartySpecies] + call PlayCry + ld a, $9 + call Function1689b + ret +; 16807 + +Function16807: ; 16807 + ld a, [StringBuffer2 + 1] + and a + jr nz, .asm_16819 + ld a, $f + call Function1689b + call YesNoBox + jr c, .asm_16844 + jr .asm_1682d + +.asm_16819 + ld a, $b + call Function1689b + call YesNoBox + jr c, .asm_16844 + ld a, $c + call Function1689b + call YesNoBox + jr c, .asm_16844 + +.asm_1682d + ld de, Money + ld bc, StringBuffer2 + 2 + callba CompareMoney + jr c, .asm_16848 + ld a, [PartyCount] + cp $6 + jr nc, .asm_1684c + and a + ret + +.asm_16844 + ld a, $12 + scf + ret + +.asm_16848 + ld a, $11 + scf + ret + +.asm_1684c + ld a, $10 + scf + ret +; 16850 + +Function16850: ; 16850 + ld bc, StringBuffer2 + 2 + ld de, Money + callba TakeMoney + ld a, $d + call Function1689b + ld a, [CurPartySpecies] + call PlayCry + ld a, $e + call Function1689b + ret +; 1686d + +Function1686d: ; 1686d + ld a, b + ld [StringBuffer2], a + ld a, d + ld [StringBuffer2 + 1], a + ld de, StringBuffer1 + ld bc, NAME_LENGTH + call CopyBytes + ld hl, 0 + ld bc, $64 + ld a, [StringBuffer2 + 1] + call AddNTimes + ld de, $64 + add hl, de + xor a + ld [StringBuffer2 + 2], a + ld a, h + ld [StringBuffer2 + 3], a + ld a, l + ld [StringBuffer2 + 4], a + ret +; 1689b + +Function1689b: ; 1689b + ld e, a + ld d, 0 + ld hl, TextTable_168aa +rept 2 + add hl, de +endr + ld a, [hli] + ld h, [hl] + ld l, a + call PrintText + ret +; 168aa + +TextTable_168aa: ; 168aa + dw UnknownText_0x168d2 + dw UnknownText_0x168d7 + dw UnknownText_0x168dc + dw UnknownText_0x168e1 + dw UnknownText_0x168e6 + dw UnknownText_0x168ff + dw UnknownText_0x168f0 + dw UnknownText_0x168eb + dw UnknownText_0x168fa + dw UnknownText_0x16904 + dw UnknownText_0x168f5 + dw UnknownText_0x16909 + dw UnknownText_0x1690e + dw UnknownText_0x16913 + dw UnknownText_0x16918 + dw UnknownText_0x1691d + dw UnknownText_0x16922 + dw UnknownText_0x16927 + dw UnknownText_0x1692c + dw UnknownText_0x16931 +; 168d2 + +UnknownText_0x168d2: ; 0x168d2 + ; I'm the DAY-CARE MAN. Want me to raise a #MON? + text_jump UnknownText_0x1bdaa9 + db "@" +; 0x168d7 + +UnknownText_0x168d7: ; 0x168d7 + ; I'm the DAY-CARE MAN. Do you know about EGGS? I was raising #MON with my wife, you see. We were shocked to find an EGG! How incredible is that? So, want me to raise a #MON? + text_jump UnknownText_0x1bdad8 + db "@" +; 0x168dc + +UnknownText_0x168dc: ; 0x168dc + ; I'm the DAY-CARE LADY. Should I raise a #MON for you? + text_jump UnknownText_0x1bdb85 + db "@" +; 0x168e1 + +UnknownText_0x168e1: ; 0x168e1 + ; I'm the DAY-CARE LADY. Do you know about EGGS? My husband and I were raising some #MON, you see. We were shocked to find an EGG! How incredible could that be? Should I raise a #MON for you? + text_jump UnknownText_0x1bdbbb + db "@" +; 0x168e6 + +UnknownText_0x168e6: ; 0x168e6 + ; What should I raise for you? + text_jump UnknownText_0x1bdc79 + db "@" +; 0x168eb + +UnknownText_0x168eb: ; 0x168eb + ; Oh? But you have just one #MON. + text_jump UnknownText_0x1bdc97 + db "@" +; 0x168f0 + +UnknownText_0x168f0: ; 0x168f0 + ; Sorry, but I can't accept an EGG. + text_jump UnknownText_0x1bdcb8 + db "@" +; 0x168f5 + +UnknownText_0x168f5: ; 0x168f5 + ; Remove MAIL before you come see me. + text_jump UnknownText_0x1bdcda + db "@" +; 0x168fa + +UnknownText_0x168fa: ; 0x168fa + ; If you give me that, what will you battle with? + text_jump UnknownText_0x1bdcff + db "@" +; 0x168ff + +UnknownText_0x168ff: ; 0x168ff + ; OK. I'll raise your @ . + text_jump UnknownText_0x1bdd30 + db "@" +; 0x16904 + +UnknownText_0x16904: ; 0x16904 + ; Come back for it later. + text_jump UnknownText_0x1bdd4b + db "@" +; 0x16909 + +UnknownText_0x16909: ; 0x16909 + ; Are we geniuses or what? Want to see your @ ? + text_jump UnknownText_0x1bdd64 + db "@" +; 0x1690e + +UnknownText_0x1690e: ; 0x1690e + ; Your @ has grown a lot. By level, it's grown by @ . If you want your #MON back, it will cost ¥@ . + text_jump UnknownText_0x1bdd96 + db "@" +; 0x16913 + +UnknownText_0x16913: ; 0x16913 + ; Perfect! Here's your #MON. + text_jump UnknownText_0x1bde04 + db "@" +; 0x16918 + +UnknownText_0x16918: ; 0x16918 + ; got back @ . + text_jump UnknownText_0x1bde1f + db "@" +; 0x1691d + +UnknownText_0x1691d: ; 0x1691d + ; Huh? Back already? Your @ needs a little more time with us. If you want your #MON back, it will cost ¥100. + text_jump UnknownText_0x1bde32 + db "@" +; 0x16922 + +UnknownText_0x16922: ; 0x16922 + ; You have no room for it. + text_jump UnknownText_0x1bdea2 + db "@" +; 0x16927 + +UnknownText_0x16927: ; 0x16927 + ; You don't have enough money. + text_jump UnknownText_0x1bdebc + db "@" +; 0x1692c + +UnknownText_0x1692c: ; 0x1692c + ; Oh, fine then. + text_jump UnknownText_0x1bded9 + db "@" +; 0x16931 + +UnknownText_0x16931: ; 0x16931 + ; Come again. + text_jump UnknownText_0x1bdee9 + db "@" +; 0x16936 + +Special_DayCareManOutside: ; 16936 + ld hl, wDaycareMan + bit 6, [hl] + jr nz, Function16949 + ld hl, UnknownText_0x16944 + call PrintText + ret + +UnknownText_0x16944: ; 0x16944 + ; Not yet… + text_jump UnknownText_0x1bdef6 + db "@" +; 0x16949 + +Function16949: ; 16949 + ld hl, UnknownText_0x16993 + call PrintText + call YesNoBox + jr c, .asm_1697c + ld a, [PartyCount] + cp PARTY_LENGTH + jr nc, .asm_16987 + call Function169ac + ld hl, wDaycareMan + res 6, [hl] + call Function16a3b + ld hl, UnknownText_0x16998 + call PrintText + ld de, SFX_GET_EGG_FROM_DAYCARE_LADY + call PlaySFX + ld c, 120 + call DelayFrames + ld hl, UnknownText_0x1699d + jr .asm_1697f + +.asm_1697c + ld hl, UnknownText_0x169a2 + +.asm_1697f + call PrintText + xor a + ld [ScriptVar], a + ret + +.asm_16987 + ld hl, UnknownText_0x169a7 + call PrintText + ld a, $1 + ld [ScriptVar], a + ret +; 16993 + +UnknownText_0x16993: ; 0x16993 + ; Ah, it's you! We were raising your #MON, and my goodness, were we surprised! Your #MON had an EGG! We don't know how it got there, but your #MON had it. You want it? + text_jump UnknownText_0x1bdf00 + db "@" +; 0x16998 + +UnknownText_0x16998: ; 0x16998 + ; received the EGG! + text_jump UnknownText_0x1bdfa5 + db "@" +; 0x1699d + +UnknownText_0x1699d: ; 0x1699d + ; Take good care of it. + text_jump UnknownText_0x1bdfba + db "@" +; 0x169a2 + +UnknownText_0x169a2: ; 0x169a2 + ; Well then, I'll keep it. Thanks! + text_jump UnknownText_0x1bdfd1 + db "@" +; 0x169a7 + +UnknownText_0x169a7: ; 0x169a7 + ; You have no room in your party. Come back later. + text_jump UnknownText_0x1bdff2 + db "@" +; 0x169ac + +Function169ac: ; 169ac + ld a, [wEggMonLevel] + ld [CurPartyLevel], a + ld hl, PartyCount + ld a, [hl] + cp PARTY_LENGTH + jr nc, .asm_16a2f + inc a + ld [hl], a + ld c, a + ld b, 0 + add hl, bc + ld a, EGG + ld [hli], a + ld a, [wEggMonSpecies] + ld [CurSpecies], a + ld [CurPartySpecies], a + ld a, $ff + ld [hl], a + ld hl, PartyMonNicknames + ld bc, PKMN_NAME_LENGTH + call Function16a31 + ld hl, wEggNick + call CopyBytes + ld hl, PartyMonOT + ld bc, NAME_LENGTH + call Function16a31 + ld hl, wEggOT + call CopyBytes + ld hl, PartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH + call Function16a31 + ld hl, wEggMon + ld bc, wEggMonEnd - wEggMon + call CopyBytes + call GetBaseData + ld a, [PartyCount] + dec a + ld hl, PartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH + call AddNTimes + ld b, h + ld c, l + ld hl, MON_ID + 1 + add hl, bc + push hl + ld hl, MON_MAXHP + add hl, bc + ld d, h + ld e, l + pop hl + push bc + ld b, $0 + predef CalcPkmnStats + pop bc + ld hl, MON_HP + add hl, bc + xor a + ld [hli], a + ld [hl], a + and a + ret + +.asm_16a2f + scf + ret +; 16a31 + +Function16a31: ; 16a31 + ld a, [PartyCount] + dec a + call AddNTimes + ld d, h + ld e, l + ret +; 16a3b + +Function16a3b: ; 16a3b + ld a, [wDaycareLady] + bit 0, a + ret z + ld a, [wDaycareMan] + bit 0, a + ret z + callab Function16e1d + ld a, [wd265] + and a + ret z + inc a + ret z + ld hl, wDaycareMan + set 5, [hl] +.asm_16a59 + call Random + cp 150 + jr c, .asm_16a59 + ld [wStepsToEgg], a + jp Function16a66 +; 16a66 + +Function16a66: ; 16a66 + xor a + ld hl, wEggMon + ld bc, wEggMonEnd - wEggMon + call ByteFill + ld hl, wEggNick + ld bc, PKMN_NAME_LENGTH + call ByteFill + ld hl, wEggOT + ld bc, NAME_LENGTH + call ByteFill + ld a, [wBreedMon1DVs] + ld [TempMonDVs], a + ld a, [wBreedMon1DVs + 1] + ld [TempMonDVs + 1], a + ld a, [wBreedMon1Species] + ld [CurPartySpecies], a + ld a, $3 + ld [MonType], a + ld a, [wBreedMon1Species] + cp DITTO + ld a, $1 + jr z, .asm_16ab6 + ld a, [wBreedMon2Species] + cp DITTO + ld a, $0 + jr z, .asm_16ab6 + callba GetGender + ld a, $0 + jr z, .asm_16ab6 + inc a + +.asm_16ab6 + ld [wDittoInDaycare], a + and a + ld a, [wBreedMon1Species] + jr z, .asm_16ac2 + ld a, [wBreedMon2Species] + +.asm_16ac2 + ld [CurPartySpecies], a + callab GetPreEvolution + callab GetPreEvolution + ld a, EGG_LEVEL + ld [CurPartyLevel], a + + ld a, [CurPartySpecies] + cp NIDORAN_F + jr nz, .asm_16ae8 + call Random + cp $80 + ld a, NIDORAN_F + jr c, .asm_16ae8 + ld a, NIDORAN_M +.asm_16ae8 + ld [CurPartySpecies], a + ld [CurSpecies], a + ld [wEggMonSpecies], a + + call GetBaseData + ld hl, wEggNick + ld de, String_16be0 + call CopyName2 + ld hl, PlayerName + ld de, wEggOT + ld bc, NAME_LENGTH + call CopyBytes + xor a + ld [wEggMonItem], a + ld de, wEggMonMoves + xor a + ld [Buffer1], a + predef FillMoves + callba Function170bf + ld hl, wEggMonID + ld a, [PlayerID] + ld [hli], a + ld a, [PlayerID + 1] + ld [hl], a + ld a, [CurPartyLevel] + ld d, a + callab CalcExpAtLevel + ld hl, wEggMonExp + ld a, [hMultiplicand] + ld [hli], a + ld a, [$ffb5] + ld [hli], a + ld a, [$ffb6] + ld [hl], a + xor a + ld b, $a + ld hl, wEggMonStatExp +.asm_16b46 + ld [hli], a + dec b + jr nz, .asm_16b46 + ld hl, wEggMonDVs + call Random + ld [hli], a + ld [TempMonDVs], a + call Random + ld [hld], a + ld [TempMonDVs + 1], a + ld de, wBreedMon1DVs + ld a, [wBreedMon1Species] + cp DITTO + jr z, .asm_16b98 + ld de, wBreedMon2DVs + ld a, [wBreedMon2Species] + cp DITTO + jr z, .asm_16b98 + ld a, $3 + ld [MonType], a + push hl + callba GetGender + pop hl + ld de, wBreedMon1DVs + ld bc, wBreedMon2DVs + jr c, .asm_16bab + jr z, .asm_16b90 + ld a, [wDittoInDaycare] + and a + jr z, .asm_16b98 + ld d, b + ld e, c + jr .asm_16b98 + +.asm_16b90 + ld a, [wDittoInDaycare] + and a + jr nz, .asm_16b98 + ld d, b + ld e, c + +.asm_16b98 + ld a, [de] + inc de + and $f + ld b, a + ld a, [hl] + and $f0 + add b + ld [hli], a + ld a, [de] + and $7 + ld b, a + ld a, [hl] + and $f8 + add b + ld [hl], a + +.asm_16bab + ld hl, StringBuffer1 + ld de, wd050 + ld bc, NAME_LENGTH + call CopyBytes + ld hl, wEggMonMoves + ld de, wEggMonPP + predef FillPP + ld hl, wd050 + ld de, StringBuffer1 + ld bc, NAME_LENGTH + call CopyBytes + ld a, [BaseEggSteps] + ld hl, wEggMonHappiness + ld [hli], a + xor a +rept 2 + ld [hli], a +endr + ld [hl], a + ld a, [CurPartyLevel] + ld [wEggMonLevel], a + ret +; 16be0 + +String_16be0: ; 16be0 + db "EGG@" +; 16be4 diff --git a/event/field_moves.asm b/event/field_moves.asm new file mode 100755 index 000000000..d6fa4a0bb --- /dev/null +++ b/event/field_moves.asm @@ -0,0 +1,312 @@ +PlayWhirlpoolSound: ; 8c7d4 + call WaitSFX + ld de, SFX_SURF + call PlaySFX + call WaitSFX + ret +; 8c7e1 + +BlindingFlash: ; 8c7e1 + callba FadeOutPalettes + ld hl, StatusFlags + set 2, [hl] + callba Function8c0e5 + callba Function8c001 + ld b, SCGB_09 + call GetSGBLayout + callba Function49409 + callba FadeInPalettes + ret +; 8c80a + +ShakeHeadbuttTree: ; 8c80a + callba Function8cf53 + ld de, CutGrassGFX + ld hl, VTiles1 + lb bc, BANK(CutGrassGFX), 4 + call Request2bpp + ld de, HeadbuttTreeGFX + ld hl, VTiles1 tile $04 + lb bc, BANK(HeadbuttTreeGFX), 8 + call Request2bpp + call Function8cad3 + ld a, SPRITE_ANIM_INDEX_1B + call _InitSpriteAnimStruct + ld hl, $3 + add hl, bc + ld [hl], $84 + ld a, $90 + ld [wc3b5], a + callba Function8cf7a + call GetHeadbuttTreeRelativeLocation + ld a, $20 + ld [wcf64], a + call WaitSFX + ld de, SFX_SANDSTORM + call PlaySFX +.loop + ld hl, wcf64 + ld a, [hl] + and a + jr z, .done + dec [hl] + ld a, $90 + ld [wc3b5], a + callba Function8cf7a + call DelayFrame + jr .loop + +.done + call OverworldTextModeSwitch + call WaitBGMap + xor a + ld [hBGMapMode], a + callba Function8cf53 + ld hl, Sprites + $90 + ld bc, $10 + xor a + call ByteFill + ld de, Font + ld hl, VTiles1 + lb bc, BANK(Font), $c + call Get1bpp + call ReplaceKrisSprite + ret +; 8c893 + +HeadbuttTreeGFX: ; 8c893 +INCBIN "gfx/unknown/08c893.2bpp" +; 8c913 + +GetHeadbuttTreeRelativeLocation: ; 8c913 + xor a + ld [hBGMapMode], a + ld a, [PlayerDirection] + and %00001100 + srl a + ld e, a + ld d, 0 + ld hl, TreeRelativeLocationTable + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + + ld a, $5 + ld [hli], a + ld [hld], a + ld bc, SCREEN_WIDTH + add hl, bc + ld [hli], a + ld [hld], a + call WaitBGMap + xor a + ld [hBGMapMode], a + ret +; 8c938 + +TreeRelativeLocationTable: ; 8c938 + dwcoord 8, 8 + 2 ; RIGHT + dwcoord 8, 8 - 2 ; LEFT + dwcoord 8 - 2, 8 ; DOWN + dwcoord 8 + 2, 8 ; UP +; 8c940 + +OWCutAnimation: ; 8c940 + ld a, e + and $1 + ld [wJumptableIndex], a + call .LoadCutGFX + call WaitSFX + ld de, SFX_PLACE_PUZZLE_PIECE_DOWN + call PlaySFX +.loop + ld a, [wJumptableIndex] + bit 7, a + jr nz, .finish + ld a, $90 + ld [wc3b5], a + callab Function8cf7a + call OWCutJumptable + call DelayFrame + jr .loop + +.finish + ret +; 8c96d + +.LoadCutGFX: ; 8c96d + callab Function8cf53 ; pointless to farcall + ld de, CutGrassGFX + ld hl, VTiles1 + lb bc, BANK(CutGrassGFX), 4 + call Request2bpp + ld de, CutTreeGFX + ld hl, VTiles1 tile $4 + lb bc, BANK(CutTreeGFX), 4 + call Request2bpp + ret +; 8c98c + +CutTreeGFX: ; c898c +INCBIN "gfx/misc/cut_tree.2bpp" +; c89cc + +CutGrassGFX: ; 8c9cc +INCBIN "gfx/misc/cut_grass.2bpp" +; 8ca0c + +OWCutJumptable: ; 8ca0c + ld a, [wJumptableIndex] + ld e, a + ld d, 0 + ld hl, .jumptable +rept 2 + add hl, de +endr + ld a, [hli] + ld h, [hl] + ld l, a + jp [hl] +; 8ca1b + + +.jumptable: ; 8ca1b (23:4a1b) + dw Function8ca23 + dw Function8ca3c + dw Function8ca5c + dw Function8ca64 + + +Function8ca23: ; 8ca23 (23:4a23) + call Function8cad3 + ld a, SPRITE_ANIM_INDEX_17 ; leaf + call _InitSpriteAnimStruct + ld hl, $3 + add hl, bc + ld [hl], $84 + ld a, $20 + ld [wcf64], a + ld hl, wJumptableIndex +rept 2 + inc [hl] +endr + ret + +Function8ca3c: ; 8ca3c (23:4a3c) + call Function8ca8e + xor a + call Function8ca73 + ld a, $10 + call Function8ca73 + ld a, $20 + call Function8ca73 + ld a, $30 + call Function8ca73 + ld a, $20 + ld [wcf64], a + ld hl, wJumptableIndex + inc [hl] + ret + +Function8ca5c: ; 8ca5c (23:4a5c) + ld a, $1 + ld [hBGMapMode], a + ld hl, wJumptableIndex + inc [hl] + +Function8ca64: ; 8ca64 (23:4a64) + ld hl, wcf64 + ld a, [hl] + and a + jr z, .asm_8ca6d + dec [hl] + ret +.asm_8ca6d + ld hl, wJumptableIndex + set 7, [hl] + ret + +Function8ca73: ; 8ca73 (23:4a73) + push de + push af + ld a, SPRITE_ANIM_INDEX_16 ; fly takeoff + call _InitSpriteAnimStruct + ld hl, $3 + add hl, bc + ld [hl], $80 + ld hl, $e + add hl, bc + ld [hl], $4 + pop af + ld hl, $c + add hl, bc + ld [hl], a + pop de + ret + +Function8ca8e: ; 8ca8e (23:4a8e) + ld de, 0 + ld a, [wd197] + bit 0, a + jr z, .asm_8ca9a + set 0, e +.asm_8ca9a + ld a, [wd196] + bit 0, a + jr z, .asm_8caa3 + set 1, e +.asm_8caa3 + ld a, [PlayerDirection] + and $c + add e + ld e, a + ld hl, Unknown_8cab3 +rept 2 + add hl, de +endr + ld e, [hl] + inc hl + ld d, [hl] + ret +; 8cab3 (23:4ab3) + +Unknown_8cab3: ; 8cab3 + db $58, $60 + db $48, $60 + db $58, $70 + db $48, $70 + db $58, $40 + db $48, $40 + db $58, $50 + db $48, $50 + db $38, $60 + db $48, $60 + db $38, $50 + db $48, $50 + db $58, $60 + db $68, $60 + db $58, $50 + db $68, $50 +; 8cad3 + +Function8cad3: ; 8cad3 (23:4ad3) + ld a, [PlayerDirection] + and $c + srl a + ld e, a + ld d, 0 + ld hl, Unknown_8cae5 + add hl, de + ld e, [hl] + inc hl + ld d, [hl] + ret +; 8cae5 (23:4ae5) + +Unknown_8cae5: ; 8cae5 + db $50, $68 + db $50, $48 + db $40, $58 + db $60, $58 +; 8caed diff --git a/event/magnet_train.asm b/event/magnet_train.asm new file mode 100755 index 000000000..2c215ee63 --- /dev/null +++ b/event/magnet_train.asm @@ -0,0 +1,485 @@ +Special_MagnetTrain: ; 8cc04 + ld a, [ScriptVar] + and a + jr nz, .ToGoldenrod + ld a, 1 ; forwards + lb bc, $40, $60 + ld de, $fca0 + jr .continue + +.ToGoldenrod + ld a, -1 ; backwards + lb bc, $c0, $a0 + ld de, $b460 + +.continue + ld h, a + ld a, [rSVBK] + push af + ld a, $5 + ld [rSVBK], a + ld a, h + ld [w5_d191], a + ld a, c + ld [w5_d192], a + ld a, b + ld [w5_d193], a + ld a, e + ld [w5_d194], a + ld a, d + ld [w5_d195], a + ld a, [hSCX] + push af + ld a, [hSCY] + push af + call Function8ccc9 + ld hl, hVBlank + ld a, [hl] + push af + ld [hl], $1 +.loop + ld a, [wJumptableIndex] + and a + jr z, .initialize + bit 7, a + jr nz, .done + callab Function8cf69 + call Function8cdf7 + call Function8cc99 + call Function3b0c + call DelayFrame + jr .loop + +.initialize + call Function8ceae + jr .loop + +.done + pop af + ld [hVBlank], a + call ClearBGPalettes + xor a + ld [hLCDStatCustom], a + ld [hLCDStatCustom + 1], a + ld [hLCDStatCustom + 2], a + ld [hSCX], a + ld [Requested2bppSource], a + ld [Requested2bppSource + 1], a + ld [Requested2bppDest], a + ld [Requested2bppDest + 1], a + ld [Requested2bpp], a + call ClearTileMap + pop af + ld [hSCY], a + pop af + ld [hSCX], a + xor a + ld [hBGMapMode], a + pop af + ld [rSVBK], a + ret +; 8cc99 + +Function8cc99: ; 8cc99 + ld hl, LYOverridesBackup + ld c, $2f + ld a, [wcf64] + add a + ld [hSCX], a + call Function8ccc4 + ld c, $30 + ld a, [wcf65] + call Function8ccc4 + ld c, $31 + ld a, [wcf64] + add a + call Function8ccc4 + ld a, [wd191] + ld d, a + ld hl, wcf64 + ld a, [hl] +rept 2 + add d +endr + ld [hl], a + ret +; 8ccc4 + +Function8ccc4: ; 8ccc4 +.asm_8ccc4 + ld [hli], a + dec c + jr nz, .asm_8ccc4 + ret +; 8ccc9 + +Function8ccc9: ; 8ccc9 + call ClearBGPalettes + call ClearSprites + call DisableLCD + callab Function8cf53 + call SetMagnetTrainPals + call DrawMagnetTrain + ld a, $90 + ld [hWY], a + call EnableLCD + xor a + ld [hBGMapMode], a + ld [hSCX], a + ld [hSCY], a + ld a, [rSVBK] + push af + ld a, $1 + ld [rSVBK], a + callba GetPlayerIcon + pop af + ld [rSVBK], a + ld hl, VTiles0 + ld c, $4 + call Request2bpp + ld hl, $c0 + add hl, de + ld d, h + ld e, l + ld hl, VTiles0 tile $04 + ld c, $4 + call Request2bpp + call Function8cda6 + ld hl, wJumptableIndex + xor a + ld [hli], a + ld a, [wd192] +rept 3 + ld [hli], a +endr + ld de, MUSIC_MAGNET_TRAIN + call PlayMusic2 + ret +; 8cd27 + +DrawMagnetTrain: ; 8cd27 + ld hl, VBGMap0 + xor a +.asm_8cd2b + call GetMagnetTrainBGTiles + ld b, 32 / 2 + call .FillAlt + inc a + cp $12 + jr c, .asm_8cd2b + ld hl, VBGMap0 tile $0c + ld de, MagnetTrainTilemap1 + ld c, 20 + call .FillLine + ld hl, VBGMap0 tile $0e + ld de, MagnetTrainTilemap2 + ld c, 20 + call .FillLine + ld hl, VBGMap0 tile $10 + ld de, MagnetTrainTilemap3 + ld c, 20 + call .FillLine + ld hl, VBGMap0 tile $12 + ld de, MagnetTrainTilemap4 + ld c, 20 + call .FillLine + ret +; 8cd65 + +.FillLine ; 8cd65 + ld a, [de] + inc de + ld [hli], a + dec c + jr nz, .FillLine + ret +; 8cd6c + +.FillAlt ; 8cd6c + ld [hl], e + inc hl + ld [hl], d + inc hl + dec b + jr nz, .FillAlt + ret +; 8cd74 + +GetMagnetTrainBGTiles: ; 8cd74 + push hl + ld e, a + ld d, 0 + ld hl, MagnetTrainBGTiles +rept 2 + add hl, de +endr + ld e, [hl] + inc hl + ld d, [hl] + pop hl + ret +; 8cd82 + +MagnetTrainBGTiles: ; 8cd82 +; Alternating tiles for each line +; of the Magnet Train tilemap. + db $4c, $4d ; bush + db $5c, $5d ; bush + db $4c, $4d ; bush + db $5c, $5d ; bush + db $08, $08 ; fence + db $18, $18 ; fence + db $1f, $1f ; track + db $31, $31 ; track + db $11, $11 ; track + db $11, $11 ; track + db $0d, $0d ; track + db $31, $31 ; track + db $04, $04 ; fence + db $18, $18 ; fence + db $4c, $4d ; bush + db $5c, $5d ; bush + db $4c, $4d ; bush + db $5c, $5d ; bush +; 8cda6 + +Function8cda6: ; 8cda6 + ld hl, LYOverrides + ld bc, $90 + ld a, [wd192] + call ByteFill + ld hl, LYOverridesBackup + ld bc, $90 + ld a, [wd192] + call ByteFill + ld a, $43 + ld [hLCDStatCustom], a + ret +; 8cdc3 + +SetMagnetTrainPals: ; 8cdc3 + ld a, $1 + ld [rVBK], a + + ; bushes + ld hl, VBGMap0 + ld bc, 8 tiles + ld a, $2 + call ByteFill + + ; train + ld hl, VBGMap0 tile $08 + ld bc, 20 tiles + xor a + call ByteFill + + ; more bushes + ld hl, VBGMap0 tile $1c + ld bc, 8 tiles + ld a, $2 + call ByteFill + + ; train window + ld hl, VBGMap0 tile $10 + 7 + ld bc, 6 + ld a, $4 + call ByteFill + + ld a, $0 + ld [rVBK], a + ret +; 8cdf7 + +Function8cdf7: ; 8cdf7 + ld a, [wJumptableIndex] + ld e, a + ld d, 0 + ld hl, Jumptable_8ce06 +rept 2 + add hl, de +endr + ld a, [hli] + ld h, [hl] + ld l, a + jp [hl] +; 8ce06 + +Jumptable_8ce06: ; 8ce06 + dw Function8ce19 + dw Function8ce6d + dw Function8ce47 + dw Function8ce6d + dw Function8ce7a + dw Function8ce6d + dw Function8cea2 +; 8ce14 + +Function8ce14: ; 8ce14 + ld hl, wJumptableIndex + inc [hl] + ret +; 8ce19 + +Function8ce19: ; 8ce19 + ld d, $55 + ld a, [wd194 + 1] + ld e, a + ld b, SPRITE_ANIM_INDEX_15 + ld a, [rSVBK] + push af + ld a, $1 + ld [rSVBK], a + ld a, [PlayerGender] + bit 0, a + jr z, .asm_8ce31 + ld b, SPRITE_ANIM_INDEX_1F + +.asm_8ce31 + pop af + ld [rSVBK], a + ld a, b + call _InitSpriteAnimStruct + ld hl, $3 + add hl, bc + ld [hl], $0 + call Function8ce14 + ld a, $80 + ld [wcf66], a + ret +; 8ce47 + +Function8ce47: ; 8ce47 + ld hl, wd193 + ld a, [wcf65] + cp [hl] + jr z, .asm_8ce64 + ld e, a + ld a, [wd191] + xor $ff + inc a + add e + ld [wcf65], a + ld hl, wc3c0 + ld a, [wd191] + add [hl] + ld [hl], a + ret + +.asm_8ce64 + call Function8ce14 + ld a, $80 + ld [wcf66], a + ret +; 8ce6d + +Function8ce6d: ; 8ce6d + ld hl, wcf66 + ld a, [hl] + and a + jr z, .asm_8ce76 + dec [hl] + ret + +.asm_8ce76 + call Function8ce14 + ret +; 8ce7a + +Function8ce7a: ; 8ce7a + ld hl, wd194 + ld a, [wcf65] + cp [hl] + jr z, .asm_8ce9e + ld e, a + ld a, [wd191] + xor $ff + inc a + ld d, a + ld a, e +rept 2 + add d +endr + ld [wcf65], a + ld hl, wc3c0 + ld a, [wd191] + ld d, a + ld a, [hl] +rept 2 + add d +endr + ld [hl], a + ret + + ret + +.asm_8ce9e + call Function8ce14 + ret +; 8cea2 + +Function8cea2: ; 8cea2 + ld a, $80 + ld [wJumptableIndex], a + ld de, SFX_TRAIN_ARRIVED + call PlaySFX + ret +; 8ceae + +Function8ceae: ; 8ceae + callba Function8cf69 + call Function8cdf7 + call Function8cc99 + call Function3b0c + call DelayFrame + ld a, [rSVBK] + push af + ld a, $1 + ld [rSVBK], a + ld a, [TimeOfDayPal] + push af + ld a, [wPermission] + push af + ld a, [TimeOfDay] + and $3 + ld [TimeOfDayPal], a + ld a, $1 + ld [wPermission], a + ld b, SCGB_09 + call GetSGBLayout + call UpdateTimePals + ld a, [rBGP] + ld [wcfc7], a + ld a, [rOBP0] + ld [wcfc8], a + ld a, [rOBP1] + ld [wcfc9], a + pop af + ld [wPermission], a + pop af + ld [TimeOfDayPal], a + pop af + ld [rSVBK], a + ret +; 8ceff + +MagnetTrainTilemap1: + db $1f, $05, $06, $0a, $0a + db $0a, $09, $0a, $0a, $0a + db $0a, $0a, $0a, $09, $0a + db $0a, $0a, $0b, $0c, $1f +MagnetTrainTilemap2: + db $14, $15, $16, $1a, $1a + db $1a, $19, $1a, $1a, $1a + db $1a, $1a, $1a, $19, $1a + db $1a, $1a, $1b, $1c, $1d +MagnetTrainTilemap3: + db $24, $25, $26, $27, $07 + db $2f, $29, $28, $28, $28 + db $28, $28, $28, $29, $07 + db $2f, $2a, $2b, $2c, $2d +MagnetTrainTilemap4: + db $20, $1f, $2e, $1f, $17 + db $00, $2e, $1f, $1f, $1f + db $1f, $1f, $1f, $2e, $17 + db $00, $1f, $2e, $1f, $0f +; 8cf4f diff --git a/home/menu.asm b/home/menu.asm index 30497a44c..bf6427151 100644 --- a/home/menu.asm +++ b/home/menu.asm @@ -227,7 +227,7 @@ Function1e35:: ; 1e35 ret ; 1e5d -Function1e5d:: ; 1e5d +DoNthMenu:: ; 1e5d call MenuFunc_1e7f call MenuWriteText call Function1eff @@ -438,7 +438,7 @@ Function1f79:: ; 1f79 ret ; 1f8d -Function1f8d:: ; 1f8d +PlaceNthMenuStrings:: ; 1f8d push de ld a, [MenuSelection] call Function1fb1 @@ -464,7 +464,7 @@ endr ret ; 1fa7 -Function1fa7:: ; 1fa7 +MenuJumptable:: ; 1fa7 ld a, [MenuSelection] call Function1fb1 ld a, [hli] diff --git a/main.asm b/main.asm index 63480f92c..672d0d44c 100644 --- a/main.asm +++ b/main.asm @@ -9791,7 +9791,7 @@ InitNickname: ; e3de ret ; e3fd -Functione3fd: ; e3fd +_BillsPC: ; e3fd call Functione40a ret c call Functione41c @@ -9851,7 +9851,7 @@ Functione443: ; e443 (3:6443) xor a ld [wcf76], a ld [hBGMapMode], a - call Function1e5d + call DoNthMenu jr c, .cancel ld a, [wMenuCursorBuffer] push af @@ -11479,5931 +11479,4353 @@ INCLUDE "engine/spawn_points.asm" INCLUDE "engine/map_setup.asm" -PokemonCenterPC: ; 1559a - call PC_CheckPartyForPokemon - ret c - call PC_PlayBootSound - ld hl, UnknownText_0x15a27 - call PC_DisplayText - ld hl, UnknownText_0x15a2c - call PC_DisplayTextWaitMenu - ld hl, .TopMenu - call LoadMenuDataHeader -.loop - xor a - ld [hBGMapMode], a - call Function1563e - ld [wcf76], a - call Function1e5d - jr c, .shutdown - ld a, [MenuSelection] - ld hl, .JumpTable - call Function1fa7 - jr nc, .loop - -.shutdown - call Function156b8 - call ExitMenu - call WriteBackup - ret -; 155d6 +INCLUDE "engine/pokecenter_pc.asm" -.TopMenu: ; 0x155d6 - db $48 ; flags - db 00, 00 ; start coords - db 12, 15 ; end coords - dw .MenuData2 - db 1 ; default option -; 0x155de +INCLUDE "engine/mart.asm" -.MenuData2: ; 0x155de - db $a0 ; flags - db 0 ; items - dw .WhichPC - dw Function1f8d - dw .JumpTable -; 0x155e6 - -.JumpTable: ; 155e6 - dw Function15679, .String_PlayersPC - dw Function15668, .String_BillsPC - dw Function15689, .String_OaksPC - dw Function1569a, .String_HallOfFame - dw Function156ab, .String_TurnOff -; 155fa - -.String_PlayersPC: db "'s PC@" -.String_BillsPC: db "BILL's PC@" -.String_OaksPC: db "PROF.OAK's PC@" -.String_HallOfFame: db "HALL OF FAME@" -.String_TurnOff: db "TURN OFF@" -; 1562c - -.WhichPC: ; 1562c - ; before pokedex - db 3 ; items - db 1, 0, 4 ; bill's, player's, turn off - db -1 +INCLUDE "engine/money.asm" - ; before Hall Of Fame - db 4 ; items - db 1, 0, 2, 4 ; bill's, player's, oak's, turn off - db -1 +INCLUDE "items/marts.asm" - ; postgame - db 5 ; items - db 1, 0, 2, 3, 4 ; bill's, player's, oak's, hall of fame, turn off - db -1 -; 1563e +INCLUDE "event/mom.asm" -Function1563e: ; 1563e - call CheckReceivedDex - jr nz, .asm_15646 - ld a, $0 - ret +INCLUDE "event/daycare.asm" -.asm_15646 - ld a, [wd95e] +Function16be4: ; 16be4 + ld a, [UnownDex] and a - ld a, $1 ret z - ld a, $2 - ret -; 15650 - -PC_CheckPartyForPokemon: ; 15650 - ld a, [PartyCount] - and a - ret nz - ld de, SFX_CHOOSE_PC_OPTION - call PlaySFX - ld hl, UnknownText_0x15663 - call PC_DisplayText - scf - ret -; 15663 - -UnknownText_0x15663: ; 0x15663 - ; Bzzzzt! You must have a #MON to use this! - text_jump UnknownText_0x1c1328 - db "@" -; 0x15668 - -Function15668: ; 15668 - call Function156c2 - ld hl, UnknownText_0x15a31 - call PC_DisplayText - callba Functione3fd - and a - ret -; 15679 (5:5679) - -Function15679: ; 15679 - call Function156c2 - ld hl, UnknownText_0x15a36 - call PC_DisplayText - ld b, $0 - call Function15704 - and a - ret -; 15689 -Function15689: ; 15689 - call Function156c2 - ld hl, UnknownText_0x15a3b - call PC_DisplayText - callba ProfOaksPC - and a - ret -; 1569a + ld a, [hInMenu] + push af + ld a, $1 + ld [hInMenu], a + ld a, [Options] + push af + set NO_TEXT_SCROLL, a + ld [Options], a + call ClearBGPalettes + call ClearTileMap -Function1569a: ; 1569a - call Function156c2 - call FadeToMenu - callba Function86650 - call Function2b3c - and a - ret -; 156ab + ld de, UnownDexATile + ld hl, VTiles1 tile $6f + lb bc, BANK(UnownDexBTile), 1 + call Request1bpp -Function156ab: ; 156ab - ld hl, UnknownText_0x15a40 - call PrintText - scf - ret -; 156b3 + ld de, UnownDexBTile + ld hl, VTiles1 tile $75 + lb bc, BANK(UnownDexBTile), 1 + call Request1bpp -PC_PlayBootSound: ; 156b3 - ld de, SFX_BOOT_PC - jr Function156d0 + hlcoord 0, 0 + lb bc, 3, 18 + call TextBox -Function156b8: ; 156b8 - ld de, SFX_SHUT_DOWN_PC - call Function156d0 - call WaitSFX - ret + hlcoord 0, 5 + lb bc, 7, 7 + call TextBox -Function156c2: ; 156c2 - ld de, SFX_CHOOSE_PC_OPTION - jr Function156d0 + hlcoord 0, 14 + lb bc, 2, 18 + call TextBox -Function156c7: ; 156c7 - ld de, SFX_SWITCH_POKEMON - call Function156d0 - ld de, SFX_SWITCH_POKEMON + hlcoord 1, 2 + ld de, AlphRuinsStampString + call PlaceString -Function156d0: ; 156d0 - push de - call WaitSFX - pop de - call PlaySFX - ret -; 156d9 + hlcoord 1, 16 + ld de, UnownDexDoWhatString + call PlaceString -Function156d9: ; 156d9 - call PC_PlayBootSound - ld hl, UnknownText_0x156ff - call PC_DisplayText - ld b, $1 - call Function15704 - and a - jr nz, .asm_156f9 - call OverworldTextModeSwitch - call Function321c - call UpdateSprites - call Function156b8 - ld c, $0 - ret + hlcoord 10, 6 + ld de, UnownDexMenuString + call PlaceString -.asm_156f9 - call ClearBGPalettes - ld c, $1 - ret -; 156ff + xor a + ld [wJumptableIndex], a + call Function16cc8 + call WaitBGMap -UnknownText_0x156ff: ; 0x156ff - ; turned on the PC. - text_jump UnknownText_0x1c1353 - db "@" -; 0x15704 + ld a, UNOWN + ld [CurPartySpecies], a + xor a + ld [TempMonDVs], a + ld [TempMonDVs + 1], a -Function15704: ; 15704 - ld a, b - ld [wcf76], a - ld hl, UnknownText_0x157cc - call PC_DisplayTextWaitMenu - call Function15715 - call ExitMenu - ret -; 15715 + ld b, SCGB_1C + call GetSGBLayout + call SetPalettes -Function15715: ; 15715 - xor a - ld [wd0d7], a - ld [wd0dd], a - ld hl, KrissPCMenuData - call LoadMenuDataHeader -.asm_15722 - call UpdateTimePals - call Function1e5d - jr c, .asm_15731 - call Function1fa7 - jr nc, .asm_15722 - jr .asm_15732 +.joy_loop + call JoyTextDelay -.asm_15731 - xor a + ld a, [hJoyPressed] + and B_BUTTON + jr nz, .pressed_b -.asm_15732 - call ExitMenu - ret -; 15736 - -KrissPCMenuData: ; 0x15736 - db %01000000 - db 0, 0 ; top left corner coords (y, x) - db 12, 15 ; bottom right corner coords (y, x) - dw .KrissPCMenuData2 - db 1 ; default selected option - -.KrissPCMenuData2 - db %10100000 ; bit7 - db 0 ; # items? - dw .KrissPCMenuList1 - dw Function1f8d - dw .KrissPCMenuPointers - -.KrissPCMenuPointers ; 0x15746 - dw KrisWithdrawItemMenu, .WithdrawItem - dw KrisDepositItemMenu, .DepositItem - dw KrisTossItemMenu, .TossItem - dw KrisMailBoxMenu, .MailBox - dw KrisDecorationMenu, .Decoration - dw KrisLogOffMenu, .LogOff - dw KrisLogOffMenu, .TurnOff - -.WithdrawItem db "WITHDRAW ITEM@" -.DepositItem db "DEPOSIT ITEM@" -.TossItem db "TOSS ITEM@" -.MailBox db "MAIL BOX@" -.Decoration db "DECORATION@" -.TurnOff db "TURN OFF@" -.LogOff db "LOG OFF@" - -WITHDRAW_ITEM EQU 0 -DEPOSIT_ITEM EQU 1 -TOSS_ITEM EQU 2 -MAIL_BOX EQU 3 -DECORATION EQU 4 -TURN_OFF EQU 5 -LOG_OFF EQU 6 - -.KrissPCMenuList1 - db 5 - db WITHDRAW_ITEM - db DEPOSIT_ITEM - db TOSS_ITEM - db MAIL_BOX - db TURN_OFF - db -1 + ld a, [hJoyPressed] + and A_BUTTON + jr nz, .pressed_a -.KrissPCMenuList2 - db 6 - db WITHDRAW_ITEM - db DEPOSIT_ITEM - db TOSS_ITEM - db MAIL_BOX - db DECORATION - db LOG_OFF - db -1 + call Function16ca0 + call DelayFrame + jr .joy_loop -PC_DisplayTextWaitMenu: ; 157bb - ld a, [Options] +.pressed_a + ld a, [wJumptableIndex] push af - set NO_TEXT_SCROLL, a - ld [Options], a - call MenuTextBox + callba Function84560 + call RestartMapMusic + pop af + ld [wJumptableIndex], a + jr .joy_loop + +.pressed_b pop af ld [Options], a + pop af + ld [hInMenu], a + call ReturnToMapFromSubmenu ret -; 157cc - -UnknownText_0x157cc: ; 0x157cc - ; What do you want to do? - text_jump UnknownText_0x1c1368 - db "@" -; 0x157d1 +; 16ca0 -KrisWithdrawItemMenu: ; 0x157d1 - call LoadStandardMenuDataHeader - callba ClearPCItemScreen -.asm_157da - call Function15985 - jr c, .asm_157e4 - call Function157e9 - jr .asm_157da - -.asm_157e4 - call Function2b3c - xor a +Function16ca0: ; 16ca0 + ld a, [hJoyLast] + and D_RIGHT + jr nz, .press_right + ld a, [hJoyLast] + and D_LEFT + jr nz, .press_left ret -; 0x157e9 -Function157e9: ; 0x157e9 - ; check if the item has a quantity - callba _CheckTossableItem - ld a, [wItemAttributeParamBuffer] +.press_left + ld hl, wJumptableIndex + ld a, [hl] and a - jr z, .askquantity - - ; items without quantity are always ×1 - ld a, 1 - ld [wItemQuantityChangeBuffer], a - jr .withdraw + jr nz, .wrap_around_left + ld [hl], $1b -.askquantity - ld hl, .HowManyText - call MenuTextBox - callba Function24fbf - call ExitMenu - call ExitMenu - jr c, .done +.wrap_around_left + dec [hl] + jr .return -.withdraw - ld a, [wItemQuantityChangeBuffer] - ld [Buffer1], a ; quantity - ld a, [wd107] - ld [Buffer2], a - ld hl, NumItems - call ReceiveItem - jr nc, .PackFull - ld a, [Buffer1] - ld [wItemQuantityChangeBuffer], a - ld a, [Buffer2] - ld [wd107], a - ld hl, PCItems - call TossItem - predef PartyMonItemName - ld hl, .WithdrewText - call MenuTextBox - xor a - ld [hBGMapMode], a - call ExitMenu - ret +.press_right + ld hl, wJumptableIndex + ld a, [hl] + cp $1a + jr c, .wrap_around_right + ld [hl], $ff -.PackFull - ld hl, .NoRoomText - call MenuTextBoxBackup - ret +.wrap_around_right + inc [hl] -.done +.return + call Function16cc8 ret -; 0x15850 - -.HowManyText ; 0x15850 - text_jump _KrissPCHowManyWithdrawText - db "@" - -.WithdrewText ; 0x15855 - text_jump _KrissPCWithdrewItemsText - db "@" - -.NoRoomText ; 0x1585a - text_jump _KrissPCNoRoomWithdrawText - db "@" - +; 16cc8 -KrisTossItemMenu: ; 0x1585f - call LoadStandardMenuDataHeader - callba ClearPCItemScreen -.asm_15868 - call Function15985 - jr c, .asm_15878 - ld de, PCItems - callba Function129f4 - jr .asm_15868 - -.asm_15878 - call Function2b3c +Function16cc8: ; 16cc8 + ld a, [wJumptableIndex] + cp 26 + jr z, Function16d20 + inc a + ld [UnownLetter], a + ld a, UNOWN + ld [CurPartySpecies], a + xor a + ld [wc2c6], a + ld de, VTiles2 + predef GetFrontpic + call Function16cff + hlcoord 1, 6 xor a + ld [hFillBox], a + lb bc, 7, 7 + predef FillBox + ld de, VTiles2 tile $31 + callba Functione0000 ret -; 0x1587d - +; 16cff -KrisDecorationMenu: ; 0x1587d - callba _KrisDecorationMenu - ld a, c - and a - ret z - scf - ret -; 0x15888 +Function16cff: ; 16cff + ld a, [rSVBK] + push af + ld a, $6 + ld [rSVBK], a + ld a, BANK(sScratch) + call GetSRAMBank + ld de, w6_d000 + ld hl, sScratch + ld a, [hROMBank] + ld b, a + ld c, $31 + call Get2bpp + call CloseSRAM -KrisLogOffMenu: ; 0x15888 - xor a - scf + pop af + ld [rSVBK], a ret -; 0x1588b - - -KrisDepositItemMenu: ; 0x1588b - call Function158b8 - jr c, .asm_158b6 - call DisableSpriteUpdates - call LoadStandardMenuDataHeader - callba Function106a5 -.asm_1589c - callba Function106be - ld a, [wcf66] - and a - jr z, .asm_158b3 - call Function158cc - callba CheckRegisteredItem - jr .asm_1589c - -.asm_158b3 - call Function2b3c +; 16d20 -.asm_158b6 +Function16d20: ; 16d20 + hlcoord 1, 6 + lb bc, 7, 7 + call ClearBox + hlcoord 1, 9 + ld de, UnownDexVacantString + call PlaceString + xor a + call GetSRAMBank + ld hl, sScratch + ld bc, $31 tiles xor a + call ByteFill + ld hl, VTiles2 tile $31 + ld de, sScratch + ld c, $31 + ld a, [hROMBank] + ld b, a + call Get2bpp + call CloseSRAM + ld c, 20 + call DelayFrames ret -; 0x158b8 +; 16d57 -Function158b8: ; 0x158b8 - callba Function129d5 - ret nc - ld hl, UnknownText_0x158c7 - call MenuTextBoxBackup - scf - ret -; 0x158c7 +AlphRuinsStampString: + db " ALPH RUINS STAMP@" -UnknownText_0x158c7: ; 0x158c7 - ; No items here! - text_jump UnknownText_0x1c13df - db "@" -; 0x158cc +UnownDexDoWhatString: + db "Do what?@" +UnownDexMenuString: + db "♂ PRINT" + next "♀ CANCEL" + next "← PREVIOUS" + next "→ NEXT" + db "@" -Function158cc: ; 0x158cc - ld a, [wc2ce] - push af - ld a, $0 - ld [wc2ce], a - callba CheckItemMenu - ld a, [wItemAttributeParamBuffer] - ld hl, .jumptable - rst JumpTable - pop af - ld [wc2ce], a - ret -; 0x158e7 +UnownDexVacantString: + db "VACANT@" +; 16d9c -.jumptable: ; 0x158e7 - dw .maybe_use - dw .no_use - dw .no_use - dw .no_use - dw .maybe_use - dw .maybe_use - dw .maybe_use +UnownDexATile: ; 16d9c +INCBIN "gfx/unknown/016d9c.1bpp" +UnownDexBTile: ; 16da4 +INCBIN "gfx/unknown/016da4.1bpp" +; 16dac -.no_use: +Function16dac: ; 16dac + hlcoord 0, 0 + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT + ld a, " " + call ByteFill + hlcoord 7, 11 + ld a, $31 + ld [hFillBox], a + lb bc, 7, 7 + predef FillBox ret +; 16dc7 -.maybe_use: - ld a, [Buffer1] - push af - ld a, [Buffer2] - push af - call Function1590a - pop af - ld [Buffer2], a - pop af - ld [Buffer1], a - ret -; 0x1590a +PhotoStudio: ; 16dc7 + ld hl, .Text_AskWhichMon + call PrintText + callba SelectMonFromParty + jr c, .cancel + ld a, [CurPartySpecies] + cp EGG + jr z, .egg -Function1590a: ; 0x1590a - callba _CheckTossableItem - ld a, [wItemAttributeParamBuffer] + ld hl, .Text_HoldStill + call PrintText + call DisableSpriteUpdates + callba Function8461a + call Function2b74 + ld a, [$ffac] and a - jr z, .asm_1591d - ld a, $1 - ld [wItemQuantityChangeBuffer], a - jr .asm_15933 + jr nz, .cancel + ld hl, .Text_Presto + jr .print_text -.asm_1591d - ld hl, .HowManyText - call MenuTextBox - callba Function24fbf - push af - call ExitMenu - call ExitMenu - pop af - jr c, .asm_1596c +.cancel + ld hl, .Text_NoPicture + jr .print_text -.asm_15933 - ld a, [wItemQuantityChangeBuffer] - ld [Buffer1], a - ld a, [wd107] - ld [Buffer2], a - ld hl, PCItems - call ReceiveItem - jr nc, .asm_15965 - ld a, [Buffer1] - ld [wItemQuantityChangeBuffer], a - ld a, [Buffer2] - ld [wd107], a - ld hl, NumItems - call TossItem - predef PartyMonItemName - ld hl, .DepositText - call PrintText - ret +.egg + ld hl, .Text_Egg -.asm_15965 - ld hl, .NoRoomText +.print_text call PrintText ret +; 16e04 -.asm_1596c - and a - ret -; 0x1596e - - -.HowManyText ; 0x1596e - text_jump _KrissPCHowManyDepositText +.Text_AskWhichMon: ; 0x16e04 + ; Which #MON should I photo- graph? + text_jump UnknownText_0x1be024 db "@" +; 0x16e09 -.DepositText ; 0x15973 - text_jump _KrissPCDepositItemsText +.Text_HoldStill: ; 0x16e09 + ; All righty. Hold still for a bit. + text_jump UnknownText_0x1be047 db "@" +; 0x16e0e -.NoRoomText ; 0x15978 - text_jump _KrissPCNoRoomDepositText +.Text_Presto: ; 0x16e0e + ; Presto! All done. Come again, OK? + text_jump UnknownText_0x1be06a db "@" +; 0x16e13 +.Text_NoPicture: ; 0x16e13 + ; Oh, no picture? Come again, OK? + text_jump UnknownText_0x1c0000 + db "@" +; 0x16e18 -KrisMailBoxMenu: ; 0x1597d - callba _KrisMailBoxMenu - xor a - ret -; 0x15985 +.Text_Egg: ; 0x16e18 + ; An EGG? My talent is worth more… + text_jump UnknownText_0x1c0021 + db "@" +; 0x16e1d +INCLUDE "engine/breeding/egg.asm" -Function15985: ; 0x15985 - xor a - ld [wd0e3], a -.asm_15989 - ld a, [wc2ce] - push af - ld a, $0 - ld [wc2ce], a - ld hl, MenuData15a08 - call CopyMenuDataHeader - hlcoord 0, 0 - ld b, $a - ld c, $12 - call TextBox - ld a, [wd0d7] - ld [wMenuCursorBuffer], a - ld a, [wd0dd] - ld [wd0e4], a - call HandleScrollingMenu - ld a, [wd0e4] - ld [wd0dd], a - ld a, [MenuSelection2] - ld [wd0d7], a - pop af - ld [wc2ce], a - ld a, [wd0e3] - and a - jr nz, .asm_159d8 - ld a, [wcf73] - cp $2 - jr z, .asm_15a06 - cp $1 - jr z, .asm_159fb - cp $4 - jr z, .asm_159f2 - jr .asm_159f8 +SECTION "Tileset Data 1", ROMX, BANK[TILESETS_1] -.asm_159d8 - ld a, [wcf73] - cp $2 - jr z, .asm_159e9 - cp $1 - jr z, .asm_159ef - cp $4 - jr z, .asm_159ef - jr .asm_159f8 +INCLUDE "tilesets/data_1.asm" -.asm_159e9 - xor a - ld [wd0e3], a - jr .asm_159f8 -.asm_159ef - call Function156c7 +SECTION "Roofs", ROMX, BANK[ROOFS] -.asm_159f2 - callba Function2490c +INCLUDE "tilesets/roofs.asm" -.asm_159f8 - jp .asm_15989 -.asm_159fb - callba Function24706 - call Function1bee - and a - ret +SECTION "Tileset Data 2", ROMX, BANK[TILESETS_2] -.asm_15a06 - scf - ret -; 0x15a08 +INCLUDE "tilesets/data_2.asm" -MenuData15a08: ; 0x15a08 - db %01000000 - db 1, 4 ; start coords - db 10, 18 ; end coords - dw .MenuData2 - db 1 ; default option -.MenuData2 - db %10110000 - db 4, 8 ; rows/cols? - db 2 ; horizontal spacing? - dbw 0, PCItems - dba PlaceMenuItemName - dba PlaceMenuItemQuantity - dba Function244c3 - -PC_DisplayText: ; 15a20 - call MenuTextBox - call ExitMenu - ret -; 15a27 +SECTION "bank8", ROMX, BANK[$8] -UnknownText_0x15a27: ; 0x15a27 - ; turned on the PC. - text_jump UnknownText_0x1c144d - db "@" -; 0x15a2c +INCLUDE "engine/clock_reset.asm" -UnknownText_0x15a2c: ; 0x15a2c - ; Access whose PC? - text_jump UnknownText_0x1c1462 - db "@" -; 0x15a31 +SECTION "Tileset Data 3", ROMX, BANK[TILESETS_3] -UnknownText_0x15a31: ; 0x15a31 - ; BILL's PC accessed. #MON Storage System opened. - text_jump UnknownText_0x1c1474 - db "@" -; 0x15a36 +INCLUDE "tilesets/data_3.asm" -UnknownText_0x15a36: ; 0x15a36 - ; Accessed own PC. Item Storage System opened. - text_jump UnknownText_0x1c14a4 - db "@" -; 0x15a3b -UnknownText_0x15a3b: ; 0x15a3b - ; PROF.OAK's PC accessed. #DEX Rating System opened. - text_jump UnknownText_0x1c14d2 - db "@" -; 0x15a40 +SECTION "bank9", ROMX, BANK[$9] -UnknownText_0x15a40: ; 0x15a40 - ; … Link closed… - text_jump UnknownText_0x1c1505 - db "@" -; 0x15a45 +StringBufferPointers:: ; 24000 + dw StringBuffer3 + dw StringBuffer4 + dw StringBuffer5 + dw StringBuffer2 + dw StringBuffer1 + dw EnemyMonNick + dw BattleMonNick +; 2400e +INCLUDE "engine/menu.asm" -INCLUDE "engine/mart.asm" +_BackUpTiles:: ; 24374 + ld a, [rSVBK] + push af + ld a, $7 + ld [rSVBK], a -GiveMoney:: ; 15fd7 - ld a, $3 - call AddMoney - ld bc, MaxMoney - ld a, $3 - call CompareMoney - jr z, .asm_15ff5 - jr c, .asm_15ff5 - ld hl, MaxMoney - ld a, [hli] - ld [de], a - inc de - ld a, [hli] - ld [de], a - inc de - ld a, [hli] - ld [de], a - scf - ret - -.asm_15ff5 - and a - ret -; 15ff7 - -MaxMoney: ; 15ff7 - dt 999999 -; 15ffa - - -TakeMoney:: ; 15ffa - ld a, 3 - call SubtractMoney - jr nc, .asm_16009 - xor a - ld [de], a - inc de - ld [de], a - inc de - ld [de], a - scf - ret - -.asm_16009 - and a - ret -; 1600b - -CompareMoney:: ; 1600b - ld a, $3 -CompareFunds: ; 1600d - push hl - push de - push bc - ld h, b - ld l, c - ld c, $0 - ld b, a -.loop1 - dec a - jr z, .done - inc de + ld hl, wcf71 + ld e, [hl] inc hl - jr .loop1 - -.done - and a -.loop2 - ld a, [de] - sbc [hl] - jr z, .okay - inc c + ld d, [hl] + push de -.okay + ld b, $10 + ld hl, wMenuFlags +.loop + ld a, [hli] + ld [de], a dec de - dec hl dec b - jr nz, .loop2 - jr c, .set_carry - ld a, c - and a - jr .skip_carry + jr nz, .loop -.set_carry - ld a, $1 - and a - scf +; If bit 6 or 7 of the menu flags is set, set bit 0 of the address +; at 7:[wcf71], and draw the menu using the coordinates from the header. +; Otherwise, reset bit 0 of 7:[wcf71]. + ld a, [wMenuFlags] + bit 6, a + jr nz, .bit_6 + bit 7, a + jr z, .not_bit_7 -.skip_carry - pop bc - pop de - pop hl - ret -; 16035 +.bit_6 + ld hl, wcf71 + ld a, [hli] + ld h, [hl] + ld l, a + set 0, [hl] + call MenuBoxCoord2Tile + call .copy + call MenuBoxCoord2Attr + call .copy + jr .done -SubtractMoney: ; 16035 - ld a, 3 -SubtractFunds: ; 16037 +.not_bit_7 + pop hl ; last-pushed register was de push hl - push de - push bc - ld h, b - ld l, c - ld b, a - ld c, 0 -.loop - dec a - jr z, .done - inc de - inc hl - jr .loop + ld a, [hld] + ld l, [hl] + ld h, a + res 0, [hl] .done - and a -.loop2 - ld a, [de] - sbc [hl] + pop hl + call .ret ; empty function + ld a, h ld [de], a dec de - dec hl - dec b - jr nz, .loop2 - pop bc - pop de - pop hl + ld a, l + ld [de], a + dec de + ld hl, wcf71 + ld [hl], e + inc hl + ld [hl], d + + pop af + ld [rSVBK], a + ld hl, wcf78 + inc [hl] ret -; 16053 +; 243cd -AddMoney: ; 16053 - ld a, $3 -AddFunds: ; 16055 - push hl - push de +.copy: ; 243cd + call GetMenuBoxDims + inc b + inc c + call .ret ; empty function + +.row push bc - ld h, b - ld l, c - ld b, a -.loop1 - dec a - jr z, .done - inc de - inc hl - jr .loop1 + push hl -.done - and a -.loop2 - ld a, [de] - adc [hl] +.col + ld a, [hli] ld [de], a dec de - dec hl - dec b - jr nz, .loop2 - pop bc - pop de + dec c + jr nz, .col + pop hl - ret -; 1606f + ld bc, SCREEN_WIDTH + add hl, bc + pop bc + dec b + jr nz, .row -GiveCoins:: ; 1606f - ld a, 2 - ld de, Coins - call AddFunds - ld a, 2 - ld bc, .maxcoins - call CompareFunds - jr c, .not_maxed - ld hl, .maxcoins - ld a, [hli] - ld [de], a - inc de - ld a, [hli] - ld [de], a - scf ret +; 243e7 -.not_maxed - and a +.ret: ; 243e7 ret -; 1608d - -.maxcoins: ; 1608d - bigdw 9999 -; 1608f - +; 243e8 -TakeCoins:: ; 1608f - ld a, 2 - ld de, Coins - call SubtractFunds - jr nc, .asm_1609f +Function243e8:: ; 243e8 xor a - ld [de], a - inc de - ld [de], a - scf - ret - -.asm_1609f - and a - ret -; 160a1 - -CheckCoins:: ; 160a1 - ld a, $2 - ld de, Coins - jp CompareFunds -; 160a9 + ld [hBGMapMode], a + ld a, [rSVBK] + push af + ld a, $7 + ld [rSVBK], a -INCLUDE "items/marts.asm" + call Function1c7e + ld a, l + or h + jp z, Function2445d + ld a, l + ld [wcf71], a + ld a, h + ld [wcf72], a + call Function1c47 + ld a, [wMenuFlags] + bit 0, a + jr z, .next + ld d, h + ld e, l + call RestoreTileBackup -INCLUDE "event/mom.asm" +.next + call Function1c7e + ld a, h + or l + jr z, .done + call Function1c47 -Special_DayCareMan: ; 166d6 - ld hl, wDaycareMan - bit 0, [hl] - jr nz, .asm_166fe - ld hl, wDaycareMan - ld a, $0 - call Function1678f - jr c, .asm_16724 - call Function16798 - jr c, .asm_16721 - callba Functionde2a - ld hl, wDaycareMan - set 0, [hl] - call Function167f6 - call Function16a3b +.done + pop af + ld [rSVBK], a + ld hl, wcf78 + dec [hl] ret +; 24423 -.asm_166fe - callba Functione698 - ld hl, wBreedMon1Nick - call Function1686d - call Function16807 - jr c, .asm_16721 - callba Functiondd21 - call Function16850 - ld hl, wDaycareMan - res 0, [hl] - res 5, [hl] - jr .asm_16724 - -.asm_16721 - call Function1689b - -.asm_16724 - ld a, $13 - call Function1689b - ret -; 1672a -Special_DayCareLady: ; 1672a - ld hl, wDaycareLady - bit 0, [hl] - jr nz, .asm_16752 - ld hl, wDaycareLady - ld a, $2 - call Function16781 - jr c, .asm_1677b - call Function16798 - jr c, .asm_16778 - callba Functionde37 - ld hl, wDaycareLady - set 0, [hl] - call Function167f6 - call Function16a3b - ret - -.asm_16752 - callba Functione6b3 - ld hl, wBreedMon2Nick - call Function1686d - call Function16807 - jr c, .asm_16778 - callba Functiondd42 - call Function16850 - ld hl, wDaycareLady - res 0, [hl] - ld hl, wDaycareMan - res 5, [hl] - jr .asm_1677b - -.asm_16778 - call Function1689b - -.asm_1677b - ld a, $13 - call Function1689b - ret -; 16781 - -Function16781: ; 16781 - bit 7, [hl] - jr nz, .asm_16788 - set 7, [hl] - inc a - -.asm_16788 - call Function1689b - call YesNoBox - ret -; 1678f - -Function1678f: ; 1678f - set 7, [hl] - call Function1689b - call YesNoBox - ret -; 16798 - -Function16798: ; 16798 - ld a, [PartyCount] - cp 2 - jr c, .asm_167e5 - ld a, 4 - call Function1689b - ld b, 6 - callba Function5001d - jr c, .asm_167dd - ld a, [CurPartySpecies] - cp EGG - jr z, .asm_167e1 - callba CheckCurPartyMonFainted - jr c, .asm_167e9 - ld hl, PartyMon1Item - ld bc, PARTYMON_STRUCT_LENGTH - ld a, [CurPartyMon] - call AddNTimes - ld d, [hl] - callba ItemIsMail - jr c, .asm_167ed - ld hl, PartyMonNicknames - ld a, [CurPartyMon] - call GetNick - and a - ret +Function24423: ; 24423 + ld a, [VramState] + bit 0, a + ret z + xor a + call GetSRAMBank + hlcoord 0, 0 + ld de, sScratch + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT + call CopyBytes + call CloseSRAM + call OverworldTextModeSwitch + xor a + call GetSRAMBank + ld hl, sScratch + decoord 0, 0 + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT +.asm_2444c + ld a, [hl] + cp $61 + jr c, .asm_24452 + ld [de], a -.asm_167dd - ld a, $12 - scf +.asm_24452 + inc hl + inc de + dec bc + ld a, c + or b + jr nz, .asm_2444c + call CloseSRAM ret +; 2445d -.asm_167e1 - ld a, $6 - scf - ret +Function2445d: ; 2445d + ld hl, UnknownText_0x24468 + call PrintText + call WaitBGMap +.asm_24466 + jr .asm_24466 +; 24468 -.asm_167e5 - ld a, $7 - scf - ret +UnknownText_0x24468: ; 24468 + text_jump UnknownText_0x1c46b7 + db "@" +; 2446d -.asm_167e9 - ld a, $8 - scf - ret +Function2446d:: ; 2446d + ld a, [wMenuData2Flags] + ld b, a + ld hl, wcfa1 + ld a, [wMenuBorderTopCoord] + inc a + bit 6, b + jr nz, .asm_2447d + inc a -.asm_167ed - ld a, $a - scf - ret -; 167f1 +.asm_2447d + ld [hli], a + ld a, [wMenuBorderLeftCoord] + inc a + ld [hli], a + ld a, [wMenuData2Items] + ld [hli], a + ld a, $1 + ld [hli], a + ld [hl], $0 + bit 5, b + jr z, .asm_24492 + set 5, [hl] -UnknownText_0x167f1: ; 0x167f1 - ; - text_jump UnknownText_0x1bdaa7 - db "@" -; 0x167f6 +.asm_24492 + ld a, [wMenuFlags] + bit 4, a + jr z, .asm_2449b + set 6, [hl] -Function167f6: ; 167f6 - ld a, $5 - call Function1689b - ld a, [CurPartySpecies] - call PlayCry - ld a, $9 - call Function1689b - ret -; 16807 +.asm_2449b + inc hl + xor a + ld [hli], a + ld a, $20 + ld [hli], a + ld a, $1 + bit 0, b + jr nz, .asm_244a9 + add $2 -Function16807: ; 16807 - ld a, [StringBuffer2 + 1] +.asm_244a9 + ld [hli], a + ld a, [wMenuCursorBuffer] and a - jr nz, .asm_16819 - ld a, $f - call Function1689b - call YesNoBox - jr c, .asm_16844 - jr .asm_1682d - -.asm_16819 - ld a, $b - call Function1689b - call YesNoBox - jr c, .asm_16844 - ld a, $c - call Function1689b - call YesNoBox - jr c, .asm_16844 + jr z, .asm_244b7 + ld c, a + ld a, [wMenuData2Items] + cp c + jr nc, .asm_244b9 -.asm_1682d - ld de, Money - ld bc, StringBuffer2 + 2 - callba CompareMoney - jr c, .asm_16848 - ld a, [PartyCount] - cp $6 - jr nc, .asm_1684c - and a - ret +.asm_244b7 + ld c, $1 -.asm_16844 - ld a, $12 - scf +.asm_244b9 + ld [hl], c + inc hl + ld a, $1 + ld [hli], a + xor a +rept 3 + ld [hli], a +endr ret +; 244c3 -.asm_16848 - ld a, $11 - scf - ret -.asm_1684c - ld a, $10 - scf +Function244c3: ; 0x244c3 + ld a, [MenuSelection] + ld [CurSpecies], a + hlcoord 0, 12 + ld b, 4 + ld c, SCREEN_WIDTH - 2 + call TextBox + ld a, [MenuSelection] + cp -1 + ret z + decoord 1, 14 + callba PrintItemDescription ret -; 16850 +; 0x244e3 -Function16850: ; 16850 - ld bc, StringBuffer2 + 2 - ld de, Money - callba TakeMoney - ld a, $d - call Function1689b +Pokepic:: ; 244e3 + ld hl, MenuDataHeader_0x24547 + call CopyMenuDataHeader + call MenuBox + call UpdateSprites + call Function321c + ld b, SCGB_12 + call GetSGBLayout + xor a + ld [hBGMapMode], a ld a, [CurPartySpecies] - call PlayCry - ld a, $e - call Function1689b + ld [CurSpecies], a + call GetBaseData + ld de, VTiles1 + predef GetFrontpic + ld a, [wMenuBorderTopCoord] + inc a + ld b, a + ld a, [wMenuBorderLeftCoord] + inc a + ld c, a + call Coord2Tile + ld a, $80 + ld [hFillBox], a + lb bc, 7, 7 + predef FillBox + call WaitBGMap ret -; 1686d +; 24528 -Function1686d: ; 1686d - ld a, b - ld [StringBuffer2], a - ld a, d - ld [StringBuffer2 + 1], a - ld de, StringBuffer1 - ld bc, NAME_LENGTH - call CopyBytes - ld hl, 0 - ld bc, $64 - ld a, [StringBuffer2 + 1] - call AddNTimes - ld de, $64 - add hl, de +PokepicYesOrNo:: ; 24528 + ld hl, MenuDataHeader_0x24547 + call CopyMenuDataHeader + call ClearMenuBoxInterior + call WaitBGMap + call ClearSGB xor a - ld [StringBuffer2 + 2], a - ld a, h - ld [StringBuffer2 + 3], a - ld a, l - ld [StringBuffer2 + 4], a + ld [hBGMapMode], a + call OverworldTextModeSwitch + call Function321c + call UpdateSprites + call LoadStandardFont ret -; 1689b +; 24547 -Function1689b: ; 1689b - ld e, a - ld d, 0 - ld hl, TextTable_168aa -rept 2 - add hl, de -endr - ld a, [hli] - ld h, [hl] - ld l, a - call PrintText - ret -; 168aa - -TextTable_168aa: ; 168aa - dw UnknownText_0x168d2 - dw UnknownText_0x168d7 - dw UnknownText_0x168dc - dw UnknownText_0x168e1 - dw UnknownText_0x168e6 - dw UnknownText_0x168ff - dw UnknownText_0x168f0 - dw UnknownText_0x168eb - dw UnknownText_0x168fa - dw UnknownText_0x16904 - dw UnknownText_0x168f5 - dw UnknownText_0x16909 - dw UnknownText_0x1690e - dw UnknownText_0x16913 - dw UnknownText_0x16918 - dw UnknownText_0x1691d - dw UnknownText_0x16922 - dw UnknownText_0x16927 - dw UnknownText_0x1692c - dw UnknownText_0x16931 -; 168d2 - -UnknownText_0x168d2: ; 0x168d2 - ; I'm the DAY-CARE MAN. Want me to raise a #MON? - text_jump UnknownText_0x1bdaa9 - db "@" -; 0x168d7 - -UnknownText_0x168d7: ; 0x168d7 - ; I'm the DAY-CARE MAN. Do you know about EGGS? I was raising #MON with my wife, you see. We were shocked to find an EGG! How incredible is that? So, want me to raise a #MON? - text_jump UnknownText_0x1bdad8 - db "@" -; 0x168dc - -UnknownText_0x168dc: ; 0x168dc - ; I'm the DAY-CARE LADY. Should I raise a #MON for you? - text_jump UnknownText_0x1bdb85 - db "@" -; 0x168e1 - -UnknownText_0x168e1: ; 0x168e1 - ; I'm the DAY-CARE LADY. Do you know about EGGS? My husband and I were raising some #MON, you see. We were shocked to find an EGG! How incredible could that be? Should I raise a #MON for you? - text_jump UnknownText_0x1bdbbb - db "@" -; 0x168e6 - -UnknownText_0x168e6: ; 0x168e6 - ; What should I raise for you? - text_jump UnknownText_0x1bdc79 - db "@" -; 0x168eb - -UnknownText_0x168eb: ; 0x168eb - ; Oh? But you have just one #MON. - text_jump UnknownText_0x1bdc97 - db "@" -; 0x168f0 - -UnknownText_0x168f0: ; 0x168f0 - ; Sorry, but I can't accept an EGG. - text_jump UnknownText_0x1bdcb8 - db "@" -; 0x168f5 - -UnknownText_0x168f5: ; 0x168f5 - ; Remove MAIL before you come see me. - text_jump UnknownText_0x1bdcda - db "@" -; 0x168fa - -UnknownText_0x168fa: ; 0x168fa - ; If you give me that, what will you battle with? - text_jump UnknownText_0x1bdcff - db "@" -; 0x168ff - -UnknownText_0x168ff: ; 0x168ff - ; OK. I'll raise your @ . - text_jump UnknownText_0x1bdd30 - db "@" -; 0x16904 - -UnknownText_0x16904: ; 0x16904 - ; Come back for it later. - text_jump UnknownText_0x1bdd4b - db "@" -; 0x16909 - -UnknownText_0x16909: ; 0x16909 - ; Are we geniuses or what? Want to see your @ ? - text_jump UnknownText_0x1bdd64 - db "@" -; 0x1690e - -UnknownText_0x1690e: ; 0x1690e - ; Your @ has grown a lot. By level, it's grown by @ . If you want your #MON back, it will cost ¥@ . - text_jump UnknownText_0x1bdd96 - db "@" -; 0x16913 - -UnknownText_0x16913: ; 0x16913 - ; Perfect! Here's your #MON. - text_jump UnknownText_0x1bde04 - db "@" -; 0x16918 - -UnknownText_0x16918: ; 0x16918 - ; got back @ . - text_jump UnknownText_0x1bde1f - db "@" -; 0x1691d - -UnknownText_0x1691d: ; 0x1691d - ; Huh? Back already? Your @ needs a little more time with us. If you want your #MON back, it will cost ¥100. - text_jump UnknownText_0x1bde32 - db "@" -; 0x16922 - -UnknownText_0x16922: ; 0x16922 - ; You have no room for it. - text_jump UnknownText_0x1bdea2 - db "@" -; 0x16927 - -UnknownText_0x16927: ; 0x16927 - ; You don't have enough money. - text_jump UnknownText_0x1bdebc - db "@" -; 0x1692c - -UnknownText_0x1692c: ; 0x1692c - ; Oh, fine then. - text_jump UnknownText_0x1bded9 - db "@" -; 0x16931 - -UnknownText_0x16931: ; 0x16931 - ; Come again. - text_jump UnknownText_0x1bdee9 - db "@" -; 0x16936 - -Special_DayCareManOutside: ; 16936 - ld hl, wDaycareMan - bit 6, [hl] - jr nz, Function16949 - ld hl, UnknownText_0x16944 - call PrintText - ret - -UnknownText_0x16944: ; 0x16944 - ; Not yet… - text_jump UnknownText_0x1bdef6 - db "@" -; 0x16949 - -Function16949: ; 16949 - ld hl, UnknownText_0x16993 - call PrintText - call YesNoBox - jr c, .asm_1697c - ld a, [PartyCount] - cp PARTY_LENGTH - jr nc, .asm_16987 - call Function169ac - ld hl, wDaycareMan - res 6, [hl] - call Function16a3b - ld hl, UnknownText_0x16998 - call PrintText - ld de, SFX_GET_EGG_FROM_DAYCARE_LADY - call PlaySFX - ld c, 120 - call DelayFrames - ld hl, UnknownText_0x1699d - jr .asm_1697f - -.asm_1697c - ld hl, UnknownText_0x169a2 +MenuDataHeader_0x24547: ; 0x24547 + db $40 ; flags + db 04, 06 ; start coords + db 13, 14 ; end coords + dw NULL + db 1 ; default option +; 0x2454f -.asm_1697f - call PrintText +LoadObjectMasks: ; 2454f + ld hl, wObjectMasks xor a - ld [ScriptVar], a - ret - -.asm_16987 - ld hl, UnknownText_0x169a7 - call PrintText - ld a, $1 - ld [ScriptVar], a - ret -; 16993 - -UnknownText_0x16993: ; 0x16993 - ; Ah, it's you! We were raising your #MON, and my goodness, were we surprised! Your #MON had an EGG! We don't know how it got there, but your #MON had it. You want it? - text_jump UnknownText_0x1bdf00 - db "@" -; 0x16998 - -UnknownText_0x16998: ; 0x16998 - ; received the EGG! - text_jump UnknownText_0x1bdfa5 - db "@" -; 0x1699d - -UnknownText_0x1699d: ; 0x1699d - ; Take good care of it. - text_jump UnknownText_0x1bdfba - db "@" -; 0x169a2 - -UnknownText_0x169a2: ; 0x169a2 - ; Well then, I'll keep it. Thanks! - text_jump UnknownText_0x1bdfd1 - db "@" -; 0x169a7 - -UnknownText_0x169a7: ; 0x169a7 - ; You have no room in your party. Come back later. - text_jump UnknownText_0x1bdff2 - db "@" -; 0x169ac - -Function169ac: ; 169ac - ld a, [wEggMonLevel] - ld [CurPartyLevel], a - ld hl, PartyCount - ld a, [hl] - cp PARTY_LENGTH - jr nc, .asm_16a2f - inc a - ld [hl], a - ld c, a - ld b, 0 + ld bc, NUM_OBJECTS + call ByteFill + nop + ld bc, MapObjects + ld de, wObjectMasks + xor a +.loop + push af + push bc + push de + call GetObjectTimeMask + jr c, .next + call CheckObjectFlag +.next + pop de + ld [de], a + inc de + pop bc + ld hl, OBJECT_LENGTH add hl, bc - ld a, EGG - ld [hli], a - ld a, [wEggMonSpecies] - ld [CurSpecies], a - ld [CurPartySpecies], a - ld a, $ff - ld [hl], a - ld hl, PartyMonNicknames - ld bc, PKMN_NAME_LENGTH - call Function16a31 - ld hl, wEggNick - call CopyBytes - ld hl, PartyMonOT - ld bc, NAME_LENGTH - call Function16a31 - ld hl, wEggOT - call CopyBytes - ld hl, PartyMon1 - ld bc, PARTYMON_STRUCT_LENGTH - call Function16a31 - ld hl, wEggMon - ld bc, wEggMonEnd - wEggMon - call CopyBytes - call GetBaseData - ld a, [PartyCount] - dec a - ld hl, PartyMon1 - ld bc, PARTYMON_STRUCT_LENGTH - call AddNTimes ld b, h ld c, l - ld hl, MON_ID + 1 - add hl, bc - push hl - ld hl, MON_MAXHP + pop af + inc a + cp NUM_OBJECTS + jr nz, .loop + ret + +CheckObjectFlag: ; 2457d (9:457d) + ld hl, MAPOBJECT_SPRITE add hl, bc - ld d, h - ld e, l - pop hl - push bc - ld b, $0 - predef CalcPkmnStats - pop bc - ld hl, MON_HP + ld a, [hl] + and a + jr z, .masked + ld hl, MAPOBJECT_EVENT_FLAG add hl, bc - xor a - ld [hli], a - ld [hl], a + ld a, [hli] + ld e, a + ld a, [hl] + ld d, a + cp -1 + jr nz, .check + ld a, e + cp -1 + jr z, .unmasked + jr .masked +.check + ld b, CHECK_FLAG + call EventFlagAction + ld a, c and a + jr nz, .masked +.unmasked + xor a ret -.asm_16a2f +.masked + ld a, -1 scf ret -; 16a31 -Function16a31: ; 16a31 - ld a, [PartyCount] - dec a - call AddNTimes - ld d, h - ld e, l +GetObjectTimeMask: ; 245a7 (9:45a7) + call CheckObjectTime + ld a, -1 + ret c + xor a ret -; 16a3b -Function16a3b: ; 16a3b - ld a, [wDaycareLady] - bit 0, a - ret z - ld a, [wDaycareMan] - bit 0, a - ret z - callab Function16e1d - ld a, [wd265] - and a - ret z - inc a - ret z - ld hl, wDaycareMan - set 5, [hl] -.asm_16a59 - call Random - cp 150 - jr c, .asm_16a59 - ld [wStepsToEgg], a - jp Function16a66 -; 16a66 -Function16a66: ; 16a66 +Function245af:: ; 245af xor a - ld hl, wEggMon - ld bc, wEggMonEnd - wEggMon - call ByteFill - ld hl, wEggNick - ld bc, PKMN_NAME_LENGTH - call ByteFill - ld hl, wEggOT - ld bc, NAME_LENGTH - call ByteFill - ld a, [wBreedMon1DVs] - ld [TempMonDVs], a - ld a, [wBreedMon1DVs + 1] - ld [TempMonDVs + 1], a - ld a, [wBreedMon1Species] - ld [CurPartySpecies], a - ld a, $3 - ld [MonType], a - ld a, [wBreedMon1Species] - cp DITTO - ld a, $1 - jr z, .asm_16ab6 - ld a, [wBreedMon2Species] - cp DITTO - ld a, $0 - jr z, .asm_16ab6 - callba GetGender - ld a, $0 - jr z, .asm_16ab6 + ld [wcf73], a + ld [hBGMapMode], a inc a + ld [hInMenu], a + call ClearObjectStructsa + call Function24764 + call Function247dd + call Function245f1 + call Function321c + xor a + ld [hBGMapMode], a + ret +; 245cb -.asm_16ab6 - ld [wDittoInDaycare], a - and a - ld a, [wBreedMon1Species] - jr z, .asm_16ac2 - ld a, [wBreedMon2Species] +Function245cb:: ; 245cb +.loop + call MenuJoyAction + jp c, .exit + call z, .zero + jr .loop +; 245d6 -.asm_16ac2 - ld [CurPartySpecies], a - callab GetPreEvolution - callab GetPreEvolution - ld a, EGG_LEVEL - ld [CurPartyLevel], a +.exit: ; 245d6 + call Function1ff8 + ld [wcf73], a + ld a, 0 + ld [hInMenu], a + ret +; 245e1 - ld a, [CurPartySpecies] - cp NIDORAN_F - jr nz, .asm_16ae8 - call Random - cp $80 - ld a, NIDORAN_F - jr c, .asm_16ae8 - ld a, NIDORAN_M -.asm_16ae8 - ld [CurPartySpecies], a - ld [CurSpecies], a - ld [wEggMonSpecies], a - - call GetBaseData - ld hl, wEggNick - ld de, String_16be0 - call CopyName2 - ld hl, PlayerName - ld de, wEggOT - ld bc, NAME_LENGTH - call CopyBytes - xor a - ld [wEggMonItem], a - ld de, wEggMonMoves - xor a - ld [Buffer1], a - predef FillMoves - callba Function170bf - ld hl, wEggMonID - ld a, [PlayerID] - ld [hli], a - ld a, [PlayerID + 1] - ld [hl], a - ld a, [CurPartyLevel] - ld d, a - callab CalcExpAtLevel - ld hl, wEggMonExp - ld a, [hMultiplicand] - ld [hli], a - ld a, [$ffb5] - ld [hli], a - ld a, [$ffb6] - ld [hl], a +.zero: ; 245e1 + call Function245f1 + ld a, 1 + ld [hBGMapMode], a + ld c, 3 + call DelayFrames xor a - ld b, $a - ld hl, wEggMonStatExp -.asm_16b46 - ld [hli], a - dec b - jr nz, .asm_16b46 - ld hl, wEggMonDVs - call Random - ld [hli], a - ld [TempMonDVs], a - call Random - ld [hld], a - ld [TempMonDVs + 1], a - ld de, wBreedMon1DVs - ld a, [wBreedMon1Species] - cp DITTO - jr z, .asm_16b98 - ld de, wBreedMon2DVs - ld a, [wBreedMon2Species] - cp DITTO - jr z, .asm_16b98 - ld a, $3 - ld [MonType], a - push hl - callba GetGender - pop hl - ld de, wBreedMon1DVs - ld bc, wBreedMon2DVs - jr c, .asm_16bab - jr z, .asm_16b90 - ld a, [wDittoInDaycare] - and a - jr z, .asm_16b98 - ld d, b - ld e, c - jr .asm_16b98 - -.asm_16b90 - ld a, [wDittoInDaycare] - and a - jr nz, .asm_16b98 - ld d, b - ld e, c - -.asm_16b98 - ld a, [de] - inc de - and $f - ld b, a - ld a, [hl] - and $f0 - add b - ld [hli], a - ld a, [de] - and $7 - ld b, a - ld a, [hl] - and $f8 - add b - ld [hl], a + ld [hBGMapMode], a + ret +; 245f1 -.asm_16bab - ld hl, StringBuffer1 - ld de, wd050 - ld bc, NAME_LENGTH - call CopyBytes - ld hl, wEggMonMoves - ld de, wEggMonPP - predef FillPP - ld hl, wd050 - ld de, StringBuffer1 - ld bc, NAME_LENGTH - call CopyBytes - ld a, [BaseEggSteps] - ld hl, wEggMonHappiness - ld [hli], a +Function245f1: ; 245f1 xor a -rept 2 - ld [hli], a -endr - ld [hl], a - ld a, [CurPartyLevel] - ld [wEggMonLevel], a + ld [hBGMapMode], a + ld hl, Options + ld a, [hl] + push af + set NO_TEXT_SCROLL, [hl] + call Function247f0 + call Function2488b + call Function248b8 + pop af + ld [Options], a ret -; 16be0 +; 24609 -String_16be0: ; 16be0 - db "EGG@" -; 16be4 +MenuJoyAction: ; 24609 +.loop + call Function1bd3 + ld a, [hJoyLast] + and D_PAD + ld b, a + ld a, [hJoyPressed] + and BUTTONS + or b + bit 0, a ; A + jp nz, .a_button + bit 1, a ; B + jp nz, .b_button + bit 2, a ; Select + jp nz, .select + bit 3, a ; Start + jp nz, .start + bit 4, a ; Right + jp nz, .d_right + bit 5, a ; Left + jp nz, .d_left + bit 6, a ; Up + jp nz, .d_up + bit 7, a ; Down + jp nz, .d_down + jr .loop +; 24640 -Function16be4: ; 16be4 - ld a, [UnownDex] +.unreferenced: ; unreferenced + ld a, -1 and a - ret z - - ld a, [hInMenu] - push af - ld a, $1 - ld [hInMenu], a - ld a, [Options] - push af - set NO_TEXT_SCROLL, a - ld [Options], a - call ClearBGPalettes - call ClearTileMap + ret +; 24644 - ld de, UnownDexATile - ld hl, VTiles1 tile $6f - lb bc, BANK(UnownDexBTile), 1 - call Request1bpp - ld de, UnownDexBTile - ld hl, VTiles1 tile $75 - lb bc, BANK(UnownDexBTile), 1 - call Request1bpp +.a_button: ; 24644 + call Function1bee + ld a, [MenuSelection2] + dec a + call Function248d5 + ld a, [MenuSelection] + ld [CurItem], a + ld a, [wcf75] + ld [wItemQuantityBuffer], a + call Function246fc + dec a + ld [wcf77], a + ld [wd107], a + ld a, [MenuSelection] + cp -1 + jr z, .b_button + ld a, A_BUTTON + scf + ret +; 2466f - hlcoord 0, 0 - lb bc, 3, 18 - call TextBox +.b_button: ; 2466f + ld a, B_BUTTON + scf + ret +; 24673 - hlcoord 0, 5 - lb bc, 7, 7 - call TextBox +.select: ; 24673 + ld a, [wMenuData2Flags] + bit 7, a + jp z, xor_a_dec_a + ld a, [MenuSelection2] + dec a + call Function248d5 + ld a, [MenuSelection] + cp -1 + jp z, xor_a_dec_a + call Function246fc + dec a + ld [wcf77], a + ld a, SELECT + scf + ret +; 24695 - hlcoord 0, 14 - lb bc, 2, 18 - call TextBox +.start: ; 24695 + ld a, [wMenuData2Flags] + bit 6, a + jp z, xor_a_dec_a + ld a, START + scf + ret +; 246a1 - hlcoord 1, 2 - ld de, AlphRuinsStampString - call PlaceString +.d_left: ; 246a1 + ld hl, wcfa6 + bit 7, [hl] + jp z, xor_a_dec_a + ld a, [wMenuData2Flags] + bit 3, a + jp z, xor_a_dec_a + ld a, D_LEFT + scf + ret +; 246b5 - hlcoord 1, 16 - ld de, UnownDexDoWhatString - call PlaceString +.d_right: ; 246b5 + ld hl, wcfa6 + bit 7, [hl] + jp z, xor_a_dec_a + ld a, [wMenuData2Flags] + bit 2, a + jp z, xor_a_dec_a + ld a, D_RIGHT + scf + ret +; 246c9 - hlcoord 10, 6 - ld de, UnownDexMenuString - call PlaceString +.d_up: ; 246c9 + ld hl, wcfa6 + bit 7, [hl] + jp z, xor_a + ld hl, wd0e4 + ld a, [hl] + and a + jr z, .xor_dec_up + dec [hl] + jp xor_a - xor a - ld [wJumptableIndex], a - call Function16cc8 - call WaitBGMap - - ld a, UNOWN - ld [CurPartySpecies], a - xor a - ld [TempMonDVs], a - ld [TempMonDVs + 1], a - - ld b, SCGB_1C - call GetSGBLayout - call SetPalettes - -.joy_loop - call JoyTextDelay - - ld a, [hJoyPressed] - and B_BUTTON - jr nz, .pressed_b - - ld a, [hJoyPressed] - and A_BUTTON - jr nz, .pressed_a +.xor_dec_up + jp xor_a_dec_a +; 246df - call Function16ca0 - call DelayFrame - jr .joy_loop +.d_down: ; 246df + ld hl, wcfa6 + bit 7, [hl] + jp z, xor_a + ld hl, wd0e4 + ld a, [wMenuData2Items] + add [hl] + ld b, a + ld a, [wd144] + cp b + jr c, .xor_dec_down + inc [hl] + jp xor_a -.pressed_a - ld a, [wJumptableIndex] - push af - callba Function84560 - call RestartMapMusic - pop af - ld [wJumptableIndex], a - jr .joy_loop +.xor_dec_down + jp xor_a_dec_a +; 246fc -.pressed_b - pop af - ld [Options], a - pop af - ld [hInMenu], a - call ReturnToMapFromSubmenu +Function246fc: ; 246fc + ld a, [wd0e4] + ld c, a + ld a, [MenuSelection2] + add c + ld c, a ret -; 16ca0 +; 24706 -Function16ca0: ; 16ca0 - ld a, [hJoyLast] - and D_RIGHT - jr nz, .press_right - ld a, [hJoyLast] - and D_LEFT - jr nz, .press_left +Function24706: ; 24706 (9:4706) + call MenuBoxCoord2Tile + ld de, SCREEN_WIDTH + add hl, de + ld de, 2 * SCREEN_WIDTH + ld a, [wMenuData2Items] +.asm_24713 + ld [hl], " " + add hl, de + dec a + jr nz, .asm_24713 ret -.press_left - ld hl, wJumptableIndex - ld a, [hl] - and a - jr nz, .wrap_around_left - ld [hl], $1b +ClearObjectStructsa: ; 2471a +; Get the value of (wcf95):(wcf96,wcf97) and store it in wd144. + ld hl, wcf96 + ld a, [hli] + ld h, [hl] + ld l, a + ld a, [wcf95] + call GetFarByte + ld [wd144], a +; if ([wd144] + 1) < [wMenuData2Items] + [wd0e4]: [wd0e4] = max(([wd144] + 1) - [wMenuData2Items], 0) + ld a, [wMenuData2Items] + ld c, a + ld a, [wd0e4] + add c + ld c, a + ld a, [wd144] + inc a + cp c + jr nc, .skip + ld a, [wMenuData2Items] + ld c, a + ld a, [wd144] + inc a + sub c + jr nc, .store + xor a -.wrap_around_left - dec [hl] - jr .return +.store + ld [wd0e4], a -.press_right - ld hl, wJumptableIndex - ld a, [hl] - cp $1a - jr c, .wrap_around_right - ld [hl], $ff +.skip + ld a, [wd0e4] + ld c, a + ld a, [wMenuCursorBuffer] + add c + ld b, a + ld a, [wd144] + inc a + cp b + jr c, .asm_2475a + jr nc, .asm_24763 -.wrap_around_right - inc [hl] +.asm_2475a + xor a + ld [wd0e4], a + ld a, $1 + ld [wMenuCursorBuffer], a -.return - call Function16cc8 +.asm_24763 ret -; 16cc8 +; 24764 -Function16cc8: ; 16cc8 - ld a, [wJumptableIndex] - cp 26 - jr z, Function16d20 +Function24764: ; 24764 + ld a, [wMenuData2Flags] + ld c, a + ld a, [wd144] + ld b, a + ld a, [wMenuBorderTopCoord] + add $1 + ld [wcfa1], a + ld a, [wMenuBorderLeftCoord] + add $0 + ld [wcfa2], a + ld a, [wMenuData2Items] + cp b + jr c, .asm_24786 + jr z, .asm_24786 + ld a, b inc a - ld [UnownLetter], a - ld a, UNOWN - ld [CurPartySpecies], a - xor a - ld [wc2c6], a - ld de, VTiles2 - predef GetFrontpic - call Function16cff - hlcoord 1, 6 + +.asm_24786 + ld [wcfa3], a + ld a, $1 + ld [wcfa4], a + ld a, $8c + bit 2, c + jr z, .asm_24796 + set 0, a + +.asm_24796 + bit 3, c + jr z, .asm_2479c + set 1, a + +.asm_2479c + ld [wcfa5], a xor a - ld [hFillBox], a - lb bc, 7, 7 - predef FillBox - ld de, VTiles2 tile $31 - callba Functione0000 - ret -; 16cff + ld [wcfa6], a + ld a, $20 + ld [wcfa7], a + ld a, $c3 + bit 7, c + jr z, .asm_247b0 + add $4 -Function16cff: ; 16cff - ld a, [rSVBK] - push af - ld a, $6 - ld [rSVBK], a +.asm_247b0 + bit 6, c + jr z, .asm_247b6 + add $8 - ld a, BANK(sScratch) - call GetSRAMBank - ld de, w6_d000 - ld hl, sScratch - ld a, [hROMBank] +.asm_247b6 + ld [wcfa8], a + ld a, [wcfa3] ld b, a - ld c, $31 - call Get2bpp - call CloseSRAM + ld a, [wMenuCursorBuffer] + and a + jr z, .asm_247c8 + cp b + jr z, .asm_247ca + jr c, .asm_247ca - pop af - ld [rSVBK], a - ret -; 16d20 +.asm_247c8 + ld a, $1 -Function16d20: ; 16d20 - hlcoord 1, 6 - lb bc, 7, 7 - call ClearBox - hlcoord 1, 9 - ld de, UnownDexVacantString - call PlaceString +.asm_247ca + ld [MenuSelection2], a + ld a, $1 + ld [wcfaa], a xor a - call GetSRAMBank - ld hl, sScratch - ld bc, $31 tiles - xor a - call ByteFill - ld hl, VTiles2 tile $31 - ld de, sScratch - ld c, $31 - ld a, [hROMBank] - ld b, a - call Get2bpp - call CloseSRAM - ld c, 20 - call DelayFrames + ld [wcfac], a + ld [wcfad], a + ld [wcfab], a ret -; 16d57 - -AlphRuinsStampString: - db " ALPH RUINS STAMP@" - -UnownDexDoWhatString: - db "Do what?@" - -UnownDexMenuString: - db "♂ PRINT" - next "♀ CANCEL" - next "← PREVIOUS" - next "→ NEXT" - db "@" - -UnownDexVacantString: - db "VACANT@" -; 16d9c +; 247dd -UnownDexATile: ; 16d9c -INCBIN "gfx/unknown/016d9c.1bpp" -UnownDexBTile: ; 16da4 -INCBIN "gfx/unknown/016da4.1bpp" -; 16dac +Function247dd: ; 247dd + ld a, [wd144] + ld c, a + ld a, [wd0e3] + and a + jr z, .asm_247ef + dec a + cp c + jr c, .asm_247ef + xor a + ld [wd0e3], a -Function16dac: ; 16dac - hlcoord 0, 0 - ld bc, SCREEN_WIDTH * SCREEN_HEIGHT - ld a, " " - call ByteFill - hlcoord 7, 11 - ld a, $31 - ld [hFillBox], a - lb bc, 7, 7 - predef FillBox +.asm_247ef ret -; 16dc7 - -PhotoStudio: ; 16dc7 - ld hl, .Text_AskWhichMon - call PrintText - callba SelectMonFromParty - jr c, .cancel - ld a, [CurPartySpecies] - cp EGG - jr z, .egg +; 247f0 - ld hl, .Text_HoldStill - call PrintText - call DisableSpriteUpdates - callba Function8461a - call Function2b74 - ld a, [$ffac] +Function247f0: ; 247f0 + call ClearWholeMenuBox + ld a, [wMenuData2Flags] + bit 4, a + jr z, .asm_2480d + ld a, [wd0e4] and a - jr nz, .cancel - ld hl, .Text_Presto - jr .print_text - -.cancel - ld hl, .Text_NoPicture - jr .print_text + jr z, .asm_2480d + ld a, [wMenuBorderTopCoord] + ld b, a + ld a, [wMenuBorderRightCoord] + ld c, a + call Coord2Tile + ld [hl], $61 -.egg - ld hl, .Text_Egg +.asm_2480d + call MenuBoxCoord2Tile + ld bc, $15 + add hl, bc + ld a, [wMenuData2Items] + ld b, a + ld c, $0 +.asm_2481a + ld a, [wd0e4] + add c + ld [wcf77], a + ld a, c + call Function248d5 + ld a, [MenuSelection] + cp $ff + jr z, .asm_24851 + push bc + push hl + call Function2486e + pop hl + ld bc, $28 + add hl, bc + pop bc + inc c + ld a, c + cp b + jr nz, .asm_2481a + ld a, [wMenuData2Flags] + bit 4, a + jr z, .asm_24850 + ld a, [wMenuBorderBottomCoord] + ld b, a + ld a, [wMenuBorderRightCoord] + ld c, a + call Coord2Tile + ld [hl], $ee -.print_text - call PrintText +.asm_24850 ret -; 16e04 - -.Text_AskWhichMon: ; 0x16e04 - ; Which #MON should I photo- graph? - text_jump UnknownText_0x1be024 - db "@" -; 0x16e09 - -.Text_HoldStill: ; 0x16e09 - ; All righty. Hold still for a bit. - text_jump UnknownText_0x1be047 - db "@" -; 0x16e0e -.Text_Presto: ; 0x16e0e - ; Presto! All done. Come again, OK? - text_jump UnknownText_0x1be06a - db "@" -; 0x16e13 +.asm_24851 + ld a, [wMenuData2Flags] + bit 0, a + jr nz, .asm_24866 + ld de, .string_2485f + call PlaceString + ret -.Text_NoPicture: ; 0x16e13 - ; Oh, no picture? Come again, OK? - text_jump UnknownText_0x1c0000 - db "@" -; 0x16e18 +.string_2485f + db "CANCEL@" -.Text_Egg: ; 0x16e18 - ; An EGG? My talent is worth more… - text_jump UnknownText_0x1c0021 - db "@" -; 0x16e1d +.asm_24866 + ld d, h + ld e, l + ld hl, wcf98 + jp CallPointerAt +; 2486e -INCLUDE "engine/breeding/egg.asm" +Function2486e: ; 2486e + push hl + ld d, h + ld e, l + ld hl, wcf98 + call CallPointerAt + pop hl + ld a, [wcf93] + and a + jr z, .asm_2488a + ld e, a + ld d, $0 + add hl, de + ld d, h + ld e, l + ld hl, wcf9b + call CallPointerAt -SECTION "Tileset Data 1", ROMX, BANK[TILESETS_1] +.asm_2488a + ret +; 2488b -INCLUDE "tilesets/data_1.asm" +Function2488b: ; 2488b + ld a, [wd0e3] + and a + jr z, .asm_248b7 + ld b, a + ld a, [wd0e4] + cp b + jr nc, .asm_248b7 + ld c, a + ld a, [wMenuData2Items] + add c + cp b + jr c, .asm_248b7 + ld a, b + sub c + dec a + add a + add $1 + ld c, a + ld a, [wMenuBorderTopCoord] + add c + ld b, a + ld a, [wMenuBorderLeftCoord] + add $0 + ld c, a + call Coord2Tile + ld [hl], $ec +.asm_248b7 + ret +; 248b8 -SECTION "Roofs", ROMX, BANK[ROOFS] +Function248b8: ; 248b8 + ld a, [wMenuData2Flags] + bit 5, a + ret z + bit 1, a + jr z, .asm_248c7 + ld a, [wd0e3] + and a + ret nz -INCLUDE "tilesets/roofs.asm" +.asm_248c7 + ld a, [MenuSelection2] + dec a + call Function248d5 + ld hl, wcf9e + call CallPointerAt + ret +; 248d5 - -SECTION "Tileset Data 2", ROMX, BANK[TILESETS_2] - -INCLUDE "tilesets/data_2.asm" - - - -SECTION "bank8", ROMX, BANK[$8] - -INCLUDE "engine/clock_reset.asm" - -SECTION "Tileset Data 3", ROMX, BANK[TILESETS_3] - -INCLUDE "tilesets/data_3.asm" - - -SECTION "bank9", ROMX, BANK[$9] - -StringBufferPointers:: ; 24000 - dw StringBuffer3 - dw StringBuffer4 - dw StringBuffer5 - dw StringBuffer2 - dw StringBuffer1 - dw EnemyMonNick - dw BattleMonNick -; 2400e - -INCLUDE "engine/menu.asm" - -_BackUpTiles:: ; 24374 - ld a, [rSVBK] - push af - ld a, $7 - ld [rSVBK], a - - ld hl, wcf71 - ld e, [hl] - inc hl - ld d, [hl] +Function248d5: ; 248d5 push de - - ld b, $10 - ld hl, wMenuFlags -.loop - ld a, [hli] - ld [de], a - dec de - dec b - jr nz, .loop - -; If bit 6 or 7 of the menu flags is set, set bit 0 of the address -; at 7:[wcf71], and draw the menu using the coordinates from the header. -; Otherwise, reset bit 0 of 7:[wcf71]. - ld a, [wMenuFlags] - bit 6, a - jr nz, .bit_6 - bit 7, a - jr z, .not_bit_7 - -.bit_6 - ld hl, wcf71 + push hl + ld e, a + ld a, [wd0e4] + add e + ld e, a + ld d, $0 + ld hl, wcf96 ld a, [hli] ld h, [hl] ld l, a - set 0, [hl] - call MenuBoxCoord2Tile - call .copy - call MenuBoxCoord2Attr - call .copy - jr .done + inc hl + ld a, [wcf94] + cp $1 + jr z, .asm_248f2 + cp $2 + jr z, .asm_248f1 -.not_bit_7 - pop hl ; last-pushed register was de - push hl - ld a, [hld] - ld l, [hl] - ld h, a - res 0, [hl] +.asm_248f1 + add hl, de -.done - pop hl - call .ret ; empty function - ld a, h - ld [de], a - dec de - ld a, l - ld [de], a - dec de - ld hl, wcf71 - ld [hl], e +.asm_248f2 + add hl, de + ld a, [wcf95] + call GetFarByte + ld [MenuSelection], a + ld [CurItem], a inc hl - ld [hl], d - - pop af - ld [rSVBK], a - ld hl, wcf78 - inc [hl] + ld a, [wcf95] + call GetFarByte + ld [wcf75], a + pop hl + pop de ret -; 243cd +; 2490c -.copy: ; 243cd - call GetMenuBoxDims - inc b - inc c - call .ret ; empty function -.row +Function2490c: ; 2490c (9:490c) + ld a, [wd0e3] + and a + jr z, .asm_2493d + ld b, a + ld a, [wcf77] + inc a + cp b + jr z, .asm_24945 + ld a, [wcf77] + call Function24a5c + ld a, [hl] + cp $ff + ret z + ld a, [wd0e3] + dec a + ld [wd0e3], a + call Function249a7 + jp c, Function249d1 + ld a, [wcf77] + ld c, a + ld a, [wd0e3] + cp c + jr c, .asm_2497a + jr .asm_2494a +.asm_2493d + ld a, [wcf77] + inc a + ld [wd0e3], a + ret +.asm_24945 + xor a + ld [wd0e3], a + ret +.asm_2494a + ld a, [wd0e3] + call Function24a40 + ld a, [wcf77] + ld d, a + ld a, [wd0e3] + ld e, a + call Function24a6c push bc + ld a, [wd0e3] + call Function24a5c + dec hl push hl - -.col - ld a, [hli] - ld [de], a - dec de - dec c - jr nz, .col - - pop hl - ld bc, SCREEN_WIDTH + call Function24a80 add hl, bc + ld d, h + ld e, l + pop hl pop bc - dec b - jr nz, .row - - ret -; 243e7 - -.ret: ; 243e7 - ret -; 243e8 - -Function243e8:: ; 243e8 + call Function24aab + ld a, [wcf77] + call Function24a4d xor a - ld [hBGMapMode], a - - ld a, [rSVBK] - push af - ld a, $7 - ld [rSVBK], a - - call Function1c7e - ld a, l - or h - jp z, Function2445d - ld a, l - ld [wcf71], a - ld a, h - ld [wcf72], a - call Function1c47 - ld a, [wMenuFlags] - bit 0, a - jr z, .next + ld [wd0e3], a + ret +.asm_2497a + ld a, [wd0e3] + call Function24a40 + ld a, [wcf77] + ld d, a + ld a, [wd0e3] + ld e, a + call Function24a6c + push bc + ld a, [wd0e3] + call Function24a5c ld d, h ld e, l - call RestoreTileBackup - -.next - call Function1c7e - ld a, h - or l - jr z, .done - call Function1c47 - -.done - pop af - ld [rSVBK], a - ld hl, wcf78 - dec [hl] + call Function24a80 + add hl, bc + pop bc + call CopyBytes + ld a, [wcf77] + call Function24a4d + xor a + ld [wd0e3], a ret -; 24423 - -Function24423: ; 24423 - ld a, [VramState] - bit 0, a - ret z +Function249a7: ; 249a7 (9:49a7) + ld a, [wd0e3] + call Function24a5c + ld d, h + ld e, l + ld a, [wcf77] + call Function24a5c + ld a, [de] + cp [hl] + jr nz, .asm_249cd + ld a, [wcf77] + call Function24a97 + cp $63 + jr z, .asm_249cd + ld a, [wd0e3] + call Function24a97 + cp $63 + jr nz, .asm_249cf +.asm_249cd + and a + ret +.asm_249cf + scf + ret + +Function249d1: ; 249d1 (9:49d1) + ld a, [wd0e3] + call Function24a5c + inc hl + push hl + ld a, [wcf77] + call Function24a5c + inc hl + ld a, [hl] + pop hl + add [hl] + cp $64 + jr c, .asm_24a01 + sub $63 + push af + ld a, [wcf77] + call Function24a5c + inc hl + ld [hl], $63 + ld a, [wd0e3] + call Function24a5c + inc hl + pop af + ld [hl], a xor a - call GetSRAMBank - hlcoord 0, 0 - ld de, sScratch - ld bc, SCREEN_WIDTH * SCREEN_HEIGHT - call CopyBytes - call CloseSRAM - call OverworldTextModeSwitch + ld [wd0e3], a + ret +.asm_24a01 + push af + ld a, [wcf77] + call Function24a5c + inc hl + pop af + ld [hl], a + ld hl, wcf96 + ld a, [hli] + ld h, [hl] + ld l, a + ld a, [wd0e3] + cp [hl] + jr nz, .asm_24a25 + dec [hl] + ld a, [wd0e3] + call Function24a5c + ld [hl], $ff xor a - call GetSRAMBank - ld hl, sScratch - decoord 0, 0 - ld bc, SCREEN_WIDTH * SCREEN_HEIGHT -.asm_2444c - ld a, [hl] - cp $61 - jr c, .asm_24452 + ld [wd0e3], a + ret +.asm_24a25 + dec [hl] + call Function24a80 + push bc + ld a, [wd0e3] + call Function24a5c + pop bc + push hl + add hl, bc + pop de +.asm_24a34 + ld a, [hli] ld [de], a - -.asm_24452 - inc hl inc de - dec bc - ld a, c - or b - jr nz, .asm_2444c - call CloseSRAM + cp $ff + jr nz, .asm_24a34 + xor a + ld [wd0e3], a ret -; 2445d - -Function2445d: ; 2445d - ld hl, UnknownText_0x24468 - call PrintText - call WaitBGMap -.asm_24466 - jr .asm_24466 -; 24468 - -UnknownText_0x24468: ; 24468 - text_jump UnknownText_0x1c46b7 - db "@" -; 2446d - -Function2446d:: ; 2446d - ld a, [wMenuData2Flags] - ld b, a - ld hl, wcfa1 - ld a, [wMenuBorderTopCoord] - inc a - bit 6, b - jr nz, .asm_2447d - inc a -.asm_2447d - ld [hli], a - ld a, [wMenuBorderLeftCoord] - inc a - ld [hli], a - ld a, [wMenuData2Items] - ld [hli], a - ld a, $1 - ld [hli], a - ld [hl], $0 - bit 5, b - jr z, .asm_24492 - set 5, [hl] +Function24a40: ; 24a40 (9:4a40) + call Function24a5c + ld de, wd002 + call Function24a80 + call CopyBytes + ret -.asm_24492 - ld a, [wMenuFlags] - bit 4, a - jr z, .asm_2449b - set 6, [hl] +Function24a4d: ; 24a4d (9:4a4d) + call Function24a5c + ld d, h + ld e, l + ld hl, wd002 + call Function24a80 + call CopyBytes + ret -.asm_2449b +Function24a5c: ; 24a5c (9:4a5c) + push af + call Function24a80 + ld hl, wcf96 + ld a, [hli] + ld h, [hl] + ld l, a inc hl - xor a - ld [hli], a - ld a, $20 - ld [hli], a - ld a, $1 - bit 0, b - jr nz, .asm_244a9 - add $2 + pop af + call AddNTimes + ret -.asm_244a9 - ld [hli], a - ld a, [wMenuCursorBuffer] - and a - jr z, .asm_244b7 +Function24a6c: ; 24a6c (9:4a6c) + push hl + call Function24a80 + ld a, d + sub e + jr nc, .asm_24a76 + dec a + cpl +.asm_24a76 + ld hl, 0 + call AddNTimes + ld b, h + ld c, l + pop hl + ret + +Function24a80: ; 24a80 (9:4a80) + push hl + ld a, [wcf94] ld c, a - ld a, [wMenuData2Items] - cp c - jr nc, .asm_244b9 + ld b, 0 + ld hl, Unknown_24a91 +rept 2 + add hl, bc +endr + ld c, [hl] + inc hl + ld b, [hl] + pop hl + ret +; 24a91 (9:4a91) -.asm_244b7 - ld c, $1 +Unknown_24a91: ; 24a91 + dw 0, 1, 2 +; 24a97 -.asm_244b9 - ld [hl], c +Function24a97: ; 24a97 (9:4a97) + push af + call Function24a80 + ld a, c + cp $2 + jr nz, .asm_24aa7 + pop af + call Function24a5c inc hl + ld a, [hl] + ret +.asm_24aa7 + pop af ld a, $1 - ld [hli], a - xor a -rept 3 - ld [hli], a -endr ret -; 244c3 - -Function244c3: ; 0x244c3 - ld a, [MenuSelection] - ld [CurSpecies], a - hlcoord 0, 12 - ld b, 4 - ld c, SCREEN_WIDTH - 2 - call TextBox +Function24aab: ; 24aab (9:4aab) + ld a, [hld] + ld [de], a + dec de + dec bc + ld a, b + or c + jr nz, Function24aab + ret + +PlaceMenuItemName: ; 0x24ab4 + push de ld a, [MenuSelection] - cp -1 - ret z - decoord 1, 14 - callba PrintItemDescription + ld [wNamedObjectIndexBuffer], a + call GetItemName + pop hl + call PlaceString ret -; 0x244e3 +; 0x24ac3 -Pokepic:: ; 244e3 - ld hl, MenuDataHeader_0x24547 - call CopyMenuDataHeader - call MenuBox - call UpdateSprites - call Function321c - ld b, SCGB_12 - call GetSGBLayout - xor a - ld [hBGMapMode], a - ld a, [CurPartySpecies] - ld [CurSpecies], a - call GetBaseData - ld de, VTiles1 - predef GetFrontpic - ld a, [wMenuBorderTopCoord] - inc a - ld b, a - ld a, [wMenuBorderLeftCoord] - inc a - ld c, a - call Coord2Tile - ld a, $80 - ld [hFillBox], a - lb bc, 7, 7 - predef FillBox - call WaitBGMap +PlaceMenuItemQuantity: ; 0x24ac3 + push de + ld a, [MenuSelection] + ld [CurItem], a + callba _CheckTossableItem + ld a, [wItemAttributeParamBuffer] + pop hl + and a + jr nz, .done + ld de, $15 + add hl, de + ld [hl], "×" + inc hl + ld de, wcf75 + lb bc, 1, 2 + call PrintNum + +.done ret -; 24528 +; 0x24ae8 -PokepicYesOrNo:: ; 24528 - ld hl, MenuDataHeader_0x24547 +Function24ae8: ; 24ae8 + ld hl, MenuDataHeader_0x24b15 call CopyMenuDataHeader - call ClearMenuBoxInterior - call WaitBGMap - call ClearSGB - xor a - ld [hBGMapMode], a - call OverworldTextModeSwitch - call Function321c - call UpdateSprites - call LoadStandardFont + jr Function24b01 + +Function24af0: ; 24af0 + ld hl, MenuDataHeader_0x24b1d + call CopyMenuDataHeader + jr Function24b01 + +Function24af8: ; 24af8 + ld hl, MenuDataHeader_0x24b15 + ld de, $b + call Function1e2e + +Function24b01: ; 24b01 + call MenuBox + call MenuBoxCoord2Tile + ld de, $15 + add hl, de + ld de, Money + lb bc, PRINTNUM_MONEY | 3, 6 + call PrintNum ret -; 24547 +; 24b15 -MenuDataHeader_0x24547: ; 0x24547 +MenuDataHeader_0x24b15: ; 0x24b15 db $40 ; flags - db 04, 06 ; start coords - db 13, 14 ; end coords + db 00, 11 ; start coords + db 02, 19 ; end coords dw NULL db 1 ; default option -; 0x2454f - -LoadObjectMasks: ; 2454f - ld hl, wObjectMasks - xor a - ld bc, NUM_OBJECTS - call ByteFill - nop - ld bc, MapObjects - ld de, wObjectMasks - xor a -.loop - push af - push bc - push de - call GetObjectTimeMask - jr c, .next - call CheckObjectFlag -.next - pop de - ld [de], a - inc de - pop bc - ld hl, OBJECT_LENGTH - add hl, bc - ld b, h - ld c, l - pop af - inc a - cp NUM_OBJECTS - jr nz, .loop - ret - -CheckObjectFlag: ; 2457d (9:457d) - ld hl, MAPOBJECT_SPRITE - add hl, bc - ld a, [hl] - and a - jr z, .masked - ld hl, MAPOBJECT_EVENT_FLAG - add hl, bc - ld a, [hli] - ld e, a - ld a, [hl] - ld d, a - cp -1 - jr nz, .check - ld a, e - cp -1 - jr z, .unmasked - jr .masked -.check - ld b, CHECK_FLAG - call EventFlagAction - ld a, c - and a - jr nz, .masked -.unmasked - xor a - ret +; 0x24b1d -.masked - ld a, -1 - scf - ret +MenuDataHeader_0x24b1d: ; 0x24b1d + db $40 ; flags + db 11, 00 ; start coords + db 13, 08 ; end coords + dw NULL + db 1 ; default option +; 0x24b25 -GetObjectTimeMask: ; 245a7 (9:45a7) - call CheckObjectTime - ld a, -1 - ret c - xor a +Special_DisplayCoinCaseBalance: ; 24b25 + ; Place a text box of size 1x7 at 11, 0. + hlcoord 11, 0 + ld b, 1 + ld c, 7 + call TextBox + hlcoord 12, 0 + ld de, CoinString + call PlaceString + hlcoord 17, 1 + ld de, ShowMoney_TerminatorString + call PlaceString + ld de, Coins + lb bc, 2, 4 + hlcoord 13, 1 + call PrintNum ret +; 24b4e - -Function245af:: ; 245af - xor a - ld [wcf73], a - ld [hBGMapMode], a - inc a - ld [hInMenu], a - call ClearObjectStructsa - call Function24764 - call Function247dd - call Function245f1 - call Function321c - xor a - ld [hBGMapMode], a +Special_DisplayMoneyAndCoinBalance: ; 24b4e + hlcoord 5, 0 + ld b, 3 + ld c, 13 + call TextBox + hlcoord 6, 1 + ld de, MoneyString + call PlaceString + hlcoord 12, 1 + ld de, Money + lb bc, PRINTNUM_MONEY | 3, 6 + call PrintNum + hlcoord 6, 3 + ld de, CoinString + call PlaceString + hlcoord 15, 3 + ld de, Coins + lb bc, 2, 4 + call PrintNum ret -; 245cb +; 24b83 -Function245cb:: ; 245cb -.loop - call MenuJoyAction - jp c, .exit - call z, .zero - jr .loop -; 245d6 +MoneyString: ; 24b83 + db "MONEY@" +CoinString: ; 24b89 + db "COIN@" +ShowMoney_TerminatorString: ; 24b8e + db "@" +; 24b8f -.exit: ; 245d6 - call Function1ff8 - ld [wcf73], a - ld a, 0 - ld [hInMenu], a - ret -; 245e1 - -.zero: ; 245e1 - call Function245f1 - ld a, 1 - ld [hBGMapMode], a - ld c, 3 - call DelayFrames - xor a - ld [hBGMapMode], a - ret -; 245f1 - -Function245f1: ; 245f1 - xor a - ld [hBGMapMode], a +Function24b8f: ; 24b8f +; unreferenced, related to safari? ld hl, Options ld a, [hl] push af set NO_TEXT_SCROLL, [hl] - call Function247f0 - call Function2488b - call Function248b8 + hlcoord 0, 0 + ld b, 3 + ld c, 7 + call TextBox + hlcoord 1, 1 + ld de, wSafariTimeRemaining + lb bc, 2, 3 + call PrintNum + hlcoord 4, 1 + ld de, .slash_500 + call PlaceString + hlcoord 1, 3 + ld de, .booru_ko + call PlaceString + hlcoord 5, 3 + ld de, wSafariBallsRemaining + lb bc, 1, 2 + call PrintNum pop af ld [Options], a ret -; 24609 +; 24bcf -MenuJoyAction: ; 24609 -.loop - call Function1bd3 - ld a, [hJoyLast] - and D_PAD - ld b, a - ld a, [hJoyPressed] - and BUTTONS - or b - bit 0, a ; A - jp nz, .a_button - bit 1, a ; B - jp nz, .b_button - bit 2, a ; Select - jp nz, .select - bit 3, a ; Start - jp nz, .start - bit 4, a ; Right - jp nz, .d_right - bit 5, a ; Left - jp nz, .d_left - bit 6, a ; Up - jp nz, .d_up - bit 7, a ; Down - jp nz, .d_down - jr .loop -; 24640 +.slash_500: ; 24bcf + db "/500@" +.booru_ko: ; 24bd4 + db "ボール こ@" +; 24bdc -.unreferenced: ; unreferenced - ld a, -1 - and a +Function24bdc: ; 24bdc + hlcoord 0, 0 + ld b, $5 + ld c, $11 + call TextBox ret -; 24644 +; 24be7 +Function24be7: ; 24be7 + ld hl, Options + ld a, [hl] + push af + set 4, [hl] + call Function24bdc + hlcoord 1, 5 + ld de, String24c52 + call PlaceString + hlcoord 8, 5 + ld de, wSafariBallsRemaining + lb bc, PRINTNUM_RIGHTALIGN | 1, 2 + call PrintNum + hlcoord 1, 1 + ld de, String24c4b + call PlaceString + ld a, [wContestMon] + and a + ld de, String24c59 + jr z, .asm_24c1e + ld [wd265], a + call GetPokemonName -.a_button: ; 24644 - call Function1bee - ld a, [MenuSelection2] - dec a - call Function248d5 - ld a, [MenuSelection] - ld [CurItem], a - ld a, [wcf75] - ld [wItemQuantityBuffer], a - call Function246fc - dec a - ld [wcf77], a - ld [wd107], a - ld a, [MenuSelection] - cp -1 - jr z, .b_button - ld a, A_BUTTON - scf - ret -; 2466f +.asm_24c1e + hlcoord 8, 1 + call PlaceString + ld a, [wContestMon] + and a + jr z, .asm_24c3e + hlcoord 1, 3 + ld de, String24c5e + call PlaceString + ld a, [wContestMonLevel] + ld h, b + ld l, c + inc hl + ld c, $3 + call Function3842 -.b_button: ; 2466f - ld a, B_BUTTON - scf +.asm_24c3e + pop af + ld [Options], a ret -; 24673 +; 24c43 -.select: ; 24673 - ld a, [wMenuData2Flags] - bit 7, a - jp z, xor_a_dec_a - ld a, [MenuSelection2] - dec a - call Function248d5 - ld a, [MenuSelection] - cp -1 - jp z, xor_a_dec_a - call Function246fc +String24c43: ; 24c43 + db "ボール こ@" +String24c4b: ; 24c4b + db "CAUGHT@" +String24c52: ; 24c52 + db "BALLS:@" +String24c59: ; 24c59 + db "None@" +String24c5e: ; 24c5e + db "LEVEL@" +; 24c64 + + +FindApricornsInBag: ; 24c64 +; Checks the bag for Apricorns. + ld hl, Buffer1 + xor a + ld [hli], a dec a - ld [wcf77], a - ld a, SELECT - scf - ret -; 24695 + ld bc, 10 + call ByteFill -.start: ; 24695 - ld a, [wMenuData2Flags] - bit 6, a - jp z, xor_a_dec_a - ld a, START - scf - ret -; 246a1 + ld hl, .ApricornBalls +.loop + ld a, [hl] + cp -1 + jr z, .done + push hl + ld [CurItem], a + ld hl, NumItems + call CheckItem + pop hl + jr nc, .nope + ld a, [hl] + call .addtobuffer +.nope +rept 2 + inc hl +endr + jr .loop -.d_left: ; 246a1 - ld hl, wcfa6 - bit 7, [hl] - jp z, xor_a_dec_a - ld a, [wMenuData2Flags] - bit 3, a - jp z, xor_a_dec_a - ld a, D_LEFT +.done + ld a, [Buffer1] + and a + ret nz scf ret -; 246b5 +; 24c94 -.d_right: ; 246b5 - ld hl, wcfa6 - bit 7, [hl] - jp z, xor_a_dec_a - ld a, [wMenuData2Flags] - bit 2, a - jp z, xor_a_dec_a - ld a, D_RIGHT - scf +.addtobuffer: ; 24c94 + push hl + ld hl, Buffer1 + inc [hl] + ld e, [hl] + ld d, 0 + add hl, de + ld [hl], a + pop hl ret -; 246c9 +; 24ca0 -.d_up: ; 246c9 - ld hl, wcfa6 - bit 7, [hl] - jp z, xor_a - ld hl, wd0e4 - ld a, [hl] - and a - jr z, .xor_dec_up - dec [hl] - jp xor_a +.ApricornBalls: ; 24ca0 + db RED_APRICORN, LEVEL_BALL + db BLU_APRICORN, LURE_BALL + db YLW_APRICORN, MOON_BALL + db GRN_APRICORN, FRIEND_BALL + db WHT_APRICORN, FAST_BALL + db BLK_APRICORN, HEAVY_BALL + db PNK_APRICORN, LOVE_BALL + db -1 +; 24caf -.xor_dec_up - jp xor_a_dec_a -; 246df -.d_down: ; 246df - ld hl, wcfa6 - bit 7, [hl] - jp z, xor_a - ld hl, wd0e4 - ld a, [wMenuData2Items] - add [hl] - ld b, a - ld a, [wd144] - cp b - jr c, .xor_dec_down - inc [hl] - jp xor_a +MonMenuOptionStrings: ; 24caf + db "STATS@" + db "SWITCH@" + db "ITEM@" + db "CANCEL@" + db "MOVE@" + db "MAIL@" + db "ERROR!@" +; 24cd9 -.xor_dec_down - jp xor_a_dec_a -; 246fc +MonMenuOptions: ; 24cd9 -Function246fc: ; 246fc - ld a, [wd0e4] - ld c, a - ld a, [MenuSelection2] - add c - ld c, a - ret -; 24706 +; Moves + db MONMENU_FIELD_MOVE, MONMENU_CUT, CUT + db MONMENU_FIELD_MOVE, MONMENU_FLY, FLY + db MONMENU_FIELD_MOVE, MONMENU_SURF, SURF + db MONMENU_FIELD_MOVE, MONMENU_STRENGTH, STRENGTH + db MONMENU_FIELD_MOVE, MONMENU_FLASH, FLASH + db MONMENU_FIELD_MOVE, MONMENU_WATERFALL, WATERFALL + db MONMENU_FIELD_MOVE, MONMENU_WHIRLPOOL, WHIRLPOOL + db MONMENU_FIELD_MOVE, MONMENU_DIG, DIG + db MONMENU_FIELD_MOVE, MONMENU_TELEPORT, TELEPORT + db MONMENU_FIELD_MOVE, MONMENU_SOFTBOILED, SOFTBOILED + db MONMENU_FIELD_MOVE, MONMENU_HEADBUTT, HEADBUTT + db MONMENU_FIELD_MOVE, MONMENU_ROCKSMASH, ROCK_SMASH + db MONMENU_FIELD_MOVE, MONMENU_MILKDRINK, MILK_DRINK + db MONMENU_FIELD_MOVE, MONMENU_SWEETSCENT, SWEET_SCENT -Function24706: ; 24706 (9:4706) - call MenuBoxCoord2Tile - ld de, SCREEN_WIDTH - add hl, de - ld de, 2 * SCREEN_WIDTH - ld a, [wMenuData2Items] -.asm_24713 - ld [hl], " " - add hl, de - dec a - jr nz, .asm_24713 - ret +; Options + db MONMENU_MENUOPTION, MONMENU_STATS, 1 ; STATS + db MONMENU_MENUOPTION, MONMENU_SWITCH, 2 ; SWITCH + db MONMENU_MENUOPTION, MONMENU_ITEM, 3 ; ITEM + db MONMENU_MENUOPTION, MONMENU_CANCEL, 4 ; CANCEL + db MONMENU_MENUOPTION, MONMENU_MOVE, 5 ; MOVE + db MONMENU_MENUOPTION, MONMENU_MAIL, 6 ; MAIL + db MONMENU_MENUOPTION, MONMENU_ERROR, 7 ; ERROR! -ClearObjectStructsa: ; 2471a -; Get the value of (wcf95):(wcf96,wcf97) and store it in wd144. - ld hl, wcf96 - ld a, [hli] - ld h, [hl] - ld l, a - ld a, [wcf95] - call GetFarByte - ld [wd144], a -; if ([wd144] + 1) < [wMenuData2Items] + [wd0e4]: [wd0e4] = max(([wd144] + 1) - [wMenuData2Items], 0) - ld a, [wMenuData2Items] - ld c, a - ld a, [wd0e4] - add c - ld c, a - ld a, [wd144] - inc a - cp c - jr nc, .skip - ld a, [wMenuData2Items] - ld c, a - ld a, [wd144] - inc a - sub c - jr nc, .store + db -1 +; 24d19 + +MonSubmenu: ; 24d19 xor a + ld [hBGMapMode], a + call GetMonSubmenuItems + callba Function8ea4a + ld hl, .MenuDataHeader + call LoadMenuDataHeader + call .GetTopCoord + call PopulateMonMenu -.store - ld [wd0e4], a + ld a, 1 + ld [hBGMapMode], a + call MonMenuLoop + ld [MenuSelection], a -.skip - ld a, [wd0e4] - ld c, a - ld a, [wMenuCursorBuffer] - add c + call ExitMenu + ret +; 24d3f + +.MenuDataHeader: ; 24d3f + db $40 ; tile backup + db 00, 06 ; start coords + db 17, 19 ; end coords + dw 0 + db 1 ; default option +; 24d47 + +.GetTopCoord: ; 24d47 +; TopCoord = 1 + BottomCoord - 2 * (NumSubmenuItems + 1) + ld a, [Buffer1] + inc a + add a ld b, a - ld a, [wd144] + ld a, [wMenuBorderBottomCoord] + sub b inc a - cp b - jr c, .asm_2475a - jr nc, .asm_24763 + ld [wMenuBorderTopCoord], a + call MenuBox + ret +; 24d59 -.asm_2475a - xor a - ld [wd0e4], a - ld a, $1 - ld [wMenuCursorBuffer], a +MonMenuLoop: ; 24d59 +.loop + ld a, $a0 ; flags + ld [wMenuData2Flags], a + ld a, [Buffer1] ; items + ld [wMenuData2Items], a + call Function1c10 + ld hl, wcfa5 + set 6, [hl] + call Function1bc9 + ld de, SFX_READ_TEXT_2 + call PlaySFX + ld a, [hJoyPressed] + bit 0, a ; A + jr nz, .select + bit 1, a ; B + jr nz, .cancel + jr .loop -.asm_24763 +.cancel + ld a, MONMENU_CANCEL ; CANCEL ret -; 24764 -Function24764: ; 24764 - ld a, [wMenuData2Flags] +.select + ld a, [MenuSelection2] + dec a ld c, a - ld a, [wd144] - ld b, a - ld a, [wMenuBorderTopCoord] - add $1 - ld [wcfa1], a - ld a, [wMenuBorderLeftCoord] - add $0 - ld [wcfa2], a - ld a, [wMenuData2Items] - cp b - jr c, .asm_24786 - jr z, .asm_24786 - ld a, b - inc a - -.asm_24786 - ld [wcfa3], a - ld a, $1 - ld [wcfa4], a - ld a, $8c - bit 2, c - jr z, .asm_24796 - set 0, a - -.asm_24796 - bit 3, c - jr z, .asm_2479c - set 1, a + ld b, 0 + ld hl, Buffer2 + add hl, bc + ld a, [hl] + ret +; 24d91 -.asm_2479c - ld [wcfa5], a - xor a - ld [wcfa6], a - ld a, $20 - ld [wcfa7], a - ld a, $c3 - bit 7, c - jr z, .asm_247b0 - add $4 +PopulateMonMenu: ; 24d91 + call MenuBoxCoord2Tile + ld bc, $2a ; 42 + add hl, bc + ld de, Buffer2 +.loop + ld a, [de] + inc de + cp -1 + ret z + push de + push hl + call GetMonMenuString + pop hl + call PlaceString + ld bc, $28 ; 40 + add hl, bc + pop de + jr .loop +; 24db0 -.asm_247b0 - bit 6, c - jr z, .asm_247b6 - add $8 - -.asm_247b6 - ld [wcfa8], a - ld a, [wcfa3] - ld b, a - ld a, [wMenuCursorBuffer] - and a - jr z, .asm_247c8 - cp b - jr z, .asm_247ca - jr c, .asm_247ca - -.asm_247c8 - ld a, $1 - -.asm_247ca - ld [MenuSelection2], a - ld a, $1 - ld [wcfaa], a - xor a - ld [wcfac], a - ld [wcfad], a - ld [wcfab], a +GetMonMenuString: ; 24db0 + ld hl, MonMenuOptions + 1 + ld de, 3 + call IsInArray + dec hl + ld a, [hli] + cp 1 + jr z, .NotMove + inc hl + ld a, [hl] + ld [wd265], a + call GetMoveName ret -; 247dd -Function247dd: ; 247dd - ld a, [wd144] - ld c, a - ld a, [wd0e3] - and a - jr z, .asm_247ef +.NotMove + inc hl + ld a, [hl] dec a - cp c - jr c, .asm_247ef - xor a - ld [wd0e3], a - -.asm_247ef + ld hl, MonMenuOptionStrings + call GetNthString + ld d, h + ld e, l ret -; 247f0 +; 24dd4 -Function247f0: ; 247f0 - call ClearWholeMenuBox - ld a, [wMenuData2Flags] - bit 4, a - jr z, .asm_2480d - ld a, [wd0e4] +GetMonSubmenuItems: ; 24dd4 + call ResetMonSubmenu + ld a, [CurPartySpecies] + cp EGG + jr z, .egg + ld a, [wLinkMode] and a - jr z, .asm_2480d - ld a, [wMenuBorderTopCoord] - ld b, a - ld a, [wMenuBorderRightCoord] - ld c, a - call Coord2Tile - ld [hl], $61 - -.asm_2480d - call MenuBoxCoord2Tile - ld bc, $15 - add hl, bc - ld a, [wMenuData2Items] - ld b, a - ld c, $0 -.asm_2481a - ld a, [wd0e4] - add c - ld [wcf77], a - ld a, c - call Function248d5 - ld a, [MenuSelection] - cp $ff - jr z, .asm_24851 + jr nz, .skip_moves + ld a, MON_MOVES + call GetPartyParamLocation + ld d, h + ld e, l + ld c, NUM_MOVES +.loop push bc + push de + ld a, [de] + and a + jr z, .next push hl - call Function2486e + call IsFieldMove pop hl - ld bc, $28 - add hl, bc + jr nc, .next + call AddMonMenuItem + +.next + pop de + inc de pop bc - inc c - ld a, c - cp b - jr nz, .asm_2481a - ld a, [wMenuData2Flags] - bit 4, a - jr z, .asm_24850 - ld a, [wMenuBorderBottomCoord] - ld b, a - ld a, [wMenuBorderRightCoord] - ld c, a - call Coord2Tile - ld [hl], $ee + dec c + jr nz, .loop -.asm_24850 +.skip_moves + ld a, MONMENU_STATS + call AddMonMenuItem + ld a, MONMENU_SWITCH + call AddMonMenuItem + ld a, MONMENU_MOVE + call AddMonMenuItem + ld a, [wLinkMode] + and a + jr nz, .skip2 + push hl + ld a, MON_ITEM + call GetPartyParamLocation + ld d, [hl] + callba ItemIsMail + pop hl + ld a, MONMENU_MAIL + jr c, .ok + ld a, MONMENU_ITEM + +.ok + call AddMonMenuItem + +.skip2 + ld a, [Buffer1] + cp NUM_MON_SUBMENU_ITEMS + jr z, .ok2 + ld a, MONMENU_CANCEL + call AddMonMenuItem + +.ok2 + call TerminateMonSubmenu ret -.asm_24851 - ld a, [wMenuData2Flags] - bit 0, a - jr nz, .asm_24866 - ld de, .string_2485f - call PlaceString +.egg + ld a, MONMENU_STATS + call AddMonMenuItem + ld a, MONMENU_SWITCH + call AddMonMenuItem + ld a, MONMENU_CANCEL + call AddMonMenuItem + call TerminateMonSubmenu ret +; 24e52 -.string_2485f - db "CANCEL@" +IsFieldMove: ; 24e52 + ld b, a + ld hl, MonMenuOptions +.next + ld a, [hli] + cp -1 + jr z, .nope + cp MONMENU_MENUOPTION + jr z, .nope + ld d, [hl] + inc hl + ld a, [hli] + cp b + jr nz, .next + ld a, d + scf -.asm_24866 - ld d, h - ld e, l - ld hl, wcf98 - jp CallPointerAt -; 2486e +.nope + ret +; 24e68 -Function2486e: ; 2486e - push hl - ld d, h - ld e, l - ld hl, wcf98 - call CallPointerAt - pop hl - ld a, [wcf93] - and a - jr z, .asm_2488a +ResetMonSubmenu: ; 24e68 + xor a + ld [Buffer1], a + ld hl, Buffer2 + ld bc, NUM_MON_SUBMENU_ITEMS + 1 + call ByteFill + ret +; 24e76 + +TerminateMonSubmenu: ; 24e76 + ld a, [Buffer1] ld e, a ld d, $0 + ld hl, Buffer2 add hl, de - ld d, h - ld e, l - ld hl, wcf9b - call CallPointerAt + ld [hl], -1 + ret +; 24e83 -.asm_2488a +AddMonMenuItem: ; 24e83 + push hl + push de + push af + ld a, [Buffer1] + ld e, a + inc a + ld [Buffer1], a + ld d, $0 + ld hl, Buffer2 + add hl, de + pop af + ld [hl], a + pop de + pop hl ret -; 2488b +; 24e99 -Function2488b: ; 2488b - ld a, [wd0e3] - and a - jr z, .asm_248b7 - ld b, a - ld a, [wd0e4] - cp b - jr nc, .asm_248b7 - ld c, a - ld a, [wMenuData2Items] - add c - cp b - jr c, .asm_248b7 - ld a, b - sub c - dec a - add a - add $1 - ld c, a - ld a, [wMenuBorderTopCoord] - add c - ld b, a - ld a, [wMenuBorderLeftCoord] - add $0 - ld c, a - call Coord2Tile - ld [hl], $ec +Function24e99: ; 24e99 +; BattleMonMenu + ld hl, MenuDataHeader_0x24ed4 + call CopyMenuDataHeader + xor a + ld [hBGMapMode], a + call MenuBox + call UpdateSprites + call Function1c89 + call WaitBGMap + call CopyMenuData2 + ld a, [wMenuData2Flags] + bit 7, a + jr z, .asm_24ed0 + call Function1c10 + ld hl, wcfa5 + set 6, [hl] + call Function1bc9 + ld de, SFX_READ_TEXT_2 + call PlaySFX + ld a, [hJoyPressed] + bit 1, a + jr z, .asm_24ed2 + ret z -.asm_248b7 +.asm_24ed0 + scf ret -; 248b8 -Function248b8: ; 248b8 - ld a, [wMenuData2Flags] - bit 5, a - ret z - bit 1, a - jr z, .asm_248c7 - ld a, [wd0e3] +.asm_24ed2 and a - ret nz - -.asm_248c7 - ld a, [MenuSelection2] - dec a - call Function248d5 - ld hl, wcf9e - call CallPointerAt ret -; 248d5 +; 24ed4 -Function248d5: ; 248d5 - push de - push hl - ld e, a - ld a, [wd0e4] - add e - ld e, a - ld d, $0 - ld hl, wcf96 - ld a, [hli] - ld h, [hl] - ld l, a - inc hl - ld a, [wcf94] - cp $1 - jr z, .asm_248f2 - cp $2 - jr z, .asm_248f1 +MenuDataHeader_0x24ed4: ; 24ed4 + db $00 ; flags + db 11, 11 ; start coords + db 17, 19 ; end coords + dw MenuData2_0x24edc + db 1 ; default option +; 24edc -.asm_248f1 - add hl, de +MenuData2_0x24edc: ; 24edc + db $c0 ; flags + db 3 ; items + db "SWITCH@" + db "STATS@" + db "CANCEL@" +; 24ef2 -.asm_248f2 - add hl, de - ld a, [wcf95] - call GetFarByte - ld [MenuSelection], a - ld [CurItem], a - inc hl - ld a, [wcf95] - call GetFarByte - ld [wcf75], a - pop hl - pop de + +LoadBattleMenu: ; 24ef2 + ld hl, BattleMenuDataHeader + call LoadMenuDataHeader + ld a, [wd0d2] + ld [wMenuCursorBuffer], a + call Function2039 + ld a, [wMenuCursorBuffer] + ld [wd0d2], a + call ExitMenu ret -; 2490c +; 24f0b -Function2490c: ; 2490c (9:490c) - ld a, [wd0e3] - and a - jr z, .asm_2493d - ld b, a - ld a, [wcf77] - inc a - cp b - jr z, .asm_24945 - ld a, [wcf77] - call Function24a5c - ld a, [hl] - cp $ff - ret z - ld a, [wd0e3] - dec a - ld [wd0e3], a - call Function249a7 - jp c, Function249d1 - ld a, [wcf77] - ld c, a - ld a, [wd0e3] - cp c - jr c, .asm_2497a - jr .asm_2494a -.asm_2493d - ld a, [wcf77] - inc a - ld [wd0e3], a - ret -.asm_24945 - xor a - ld [wd0e3], a - ret -.asm_2494a - ld a, [wd0e3] - call Function24a40 - ld a, [wcf77] - ld d, a - ld a, [wd0e3] - ld e, a - call Function24a6c - push bc - ld a, [wd0e3] - call Function24a5c - dec hl - push hl - call Function24a80 - add hl, bc - ld d, h - ld e, l - pop hl - pop bc - call Function24aab - ld a, [wcf77] - call Function24a4d - xor a - ld [wd0e3], a - ret -.asm_2497a - ld a, [wd0e3] - call Function24a40 - ld a, [wcf77] - ld d, a - ld a, [wd0e3] - ld e, a - call Function24a6c - push bc - ld a, [wd0e3] - call Function24a5c - ld d, h - ld e, l - call Function24a80 - add hl, bc - pop bc - call CopyBytes - ld a, [wcf77] - call Function24a4d - xor a - ld [wd0e3], a - ret +SafariBattleMenu: ; 24f0b +; untranslated + ld hl, MenuDataHeader_0x24f4e + call LoadMenuDataHeader + jr Function24f19 +; 24f13 -Function249a7: ; 249a7 (9:49a7) - ld a, [wd0e3] - call Function24a5c - ld d, h - ld e, l - ld a, [wcf77] - call Function24a5c - ld a, [de] - cp [hl] - jr nz, .asm_249cd - ld a, [wcf77] - call Function24a97 - cp $63 - jr z, .asm_249cd - ld a, [wd0e3] - call Function24a97 - cp $63 - jr nz, .asm_249cf -.asm_249cd - and a - ret -.asm_249cf - scf +ContestBattleMenu: ; 24f13 + ld hl, MenuDataHeader_0x24f89 + call LoadMenuDataHeader +; 24f19 + +Function24f19: ; 24f19 + ld a, [wd0d2] + ld [wMenuCursorBuffer], a + call InterpretMenu + ld a, [wMenuCursorBuffer] + ld [wd0d2], a + call ExitMenu ret +; 24f2c -Function249d1: ; 249d1 (9:49d1) - ld a, [wd0e3] - call Function24a5c - inc hl - push hl - ld a, [wcf77] - call Function24a5c - inc hl - ld a, [hl] - pop hl - add [hl] - cp $64 - jr c, .asm_24a01 - sub $63 - push af - ld a, [wcf77] - call Function24a5c - inc hl - ld [hl], $63 - ld a, [wd0e3] - call Function24a5c - inc hl - pop af - ld [hl], a - xor a - ld [wd0e3], a - ret -.asm_24a01 - push af - ld a, [wcf77] - call Function24a5c - inc hl - pop af - ld [hl], a - ld hl, wcf96 - ld a, [hli] - ld h, [hl] - ld l, a - ld a, [wd0e3] - cp [hl] - jr nz, .asm_24a25 - dec [hl] - ld a, [wd0e3] - call Function24a5c - ld [hl], $ff - xor a - ld [wd0e3], a - ret -.asm_24a25 - dec [hl] - call Function24a80 - push bc - ld a, [wd0e3] - call Function24a5c - pop bc - push hl - add hl, bc - pop de -.asm_24a34 - ld a, [hli] - ld [de], a - inc de - cp $ff - jr nz, .asm_24a34 - xor a - ld [wd0e3], a - ret -Function24a40: ; 24a40 (9:4a40) - call Function24a5c - ld de, wd002 - call Function24a80 - call CopyBytes - ret +BattleMenuDataHeader: ; 24f2c + db $40 ; flags + db 12, 08 ; start coords + db 17, 19 ; end coords + dw MenuData_0x24f34 + db 1 ; default option +; 24f34 -Function24a4d: ; 24a4d (9:4a4d) - call Function24a5c - ld d, h - ld e, l - ld hl, wd002 - call Function24a80 - call CopyBytes - ret +MenuData_0x24f34: ; 0x24f34 + db $81 ; flags + dn 2, 2 ; rows, columns + db 6 ; spacing + dba Strings24f3d + dbw $09, 0 +; 0x24f3d -Function24a5c: ; 24a5c (9:4a5c) - push af - call Function24a80 - ld hl, wcf96 - ld a, [hli] - ld h, [hl] - ld l, a - inc hl - pop af - call AddNTimes - ret +Strings24f3d: ; 0x24f3d + db "FIGHT@" + db $4a, "@" + db "PACK@" + db "RUN@" +; 24f4e -Function24a6c: ; 24a6c (9:4a6c) - push hl - call Function24a80 - ld a, d - sub e - jr nc, .asm_24a76 - dec a - cpl -.asm_24a76 - ld hl, 0 - call AddNTimes - ld b, h - ld c, l - pop hl - ret -Function24a80: ; 24a80 (9:4a80) - push hl - ld a, [wcf94] - ld c, a - ld b, 0 - ld hl, Unknown_24a91 -rept 2 - add hl, bc -endr - ld c, [hl] - inc hl - ld b, [hl] - pop hl - ret -; 24a91 (9:4a91) +MenuDataHeader_0x24f4e: ; 24f4e + db $40 ; flags + db 12, 00 ; start coords + db 17, 19 ; end coords + dw MenuData_0x24f56 + db 1 ; default option +; 24f56 -Unknown_24a91: ; 24a91 - dw 0, 1, 2 -; 24a97 +MenuData_0x24f56: ; 24f56 + db $81 ; flags + dn 2, 2 ; rows, columns + db 11 ; spacing + dba Strings24f5f + dba Function24f7c +; 24f5f -Function24a97: ; 24a97 (9:4a97) - push af - call Function24a80 - ld a, c - cp $2 - jr nz, .asm_24aa7 - pop af - call Function24a5c - inc hl - ld a, [hl] - ret -.asm_24aa7 - pop af - ld a, $1 - ret +Strings24f5f: ; 24f5f + db "サファりボール× @" ; "SAFARI BALL× @" + db "エサをなげる@" ; "THROW BAIT" + db "いしをなげる@" ; "THROW ROCK" + db "にげる@" ; "RUN" +; 24f7c -Function24aab: ; 24aab (9:4aab) - ld a, [hld] - ld [de], a - dec de - dec bc - ld a, b - or c - jr nz, Function24aab +Function24f7c: ; 24f7c + hlcoord 17, 13 + ld de, wSafariBallsRemaining + lb bc, PRINTNUM_LEADINGZEROS | 1, 2 + call PrintNum ret +; 24f89 -PlaceMenuItemName: ; 0x24ab4 - push de - ld a, [MenuSelection] - ld [wNamedObjectIndexBuffer], a - call GetItemName - pop hl - call PlaceString - ret -; 0x24ac3 -PlaceMenuItemQuantity: ; 0x24ac3 - push de - ld a, [MenuSelection] - ld [CurItem], a - callba _CheckTossableItem - ld a, [wItemAttributeParamBuffer] - pop hl - and a - jr nz, .done - ld de, $15 - add hl, de - ld [hl], "×" - inc hl - ld de, wcf75 - lb bc, 1, 2 +MenuDataHeader_0x24f89: ; 24f89 + db $40 ; flags + db 12, 02 ; start coords + db 17, 19 ; end coords + dw MenuData_0x24f91 + db 1 ; default option +; 24f91 + +MenuData_0x24f91: ; 24f91 + db $81 ; flags + dn 2, 2 ; rows, columns + db 12 ; spacing + dba Strings24f9a + dba Function24fb2 +; 24f9a + +Strings24f9a: ; 24f9a + db "FIGHT@" + db "", "@" + db "PARKBALL× @" + db "RUN@" +; 24fb2 + +Function24fb2: ; 24fb2 + hlcoord 13, 16 + ld de, wParkBallsRemaining + lb bc, PRINTNUM_LEADINGZEROS | 1, 2 call PrintNum + ret +; 24fbf -.done + +Function24fbf: ; 24fbf + ld hl, MenuDataHeader_0x250ed + call LoadMenuDataHeader + call Function24ff9 ret -; 0x24ae8 +; 24fc9 -Function24ae8: ; 24ae8 - ld hl, MenuDataHeader_0x24b15 - call CopyMenuDataHeader - jr Function24b01 -Function24af0: ; 24af0 - ld hl, MenuDataHeader_0x24b1d - call CopyMenuDataHeader - jr Function24b01 +Function24fc9: ; 24fc9 + callba GetItemPrice +Function24fcf: ; 24fcf + ld a, d + ld [Buffer1], a + ld a, e + ld [Buffer2], a + ld hl, MenuDataHeader_0x250f5 + call LoadMenuDataHeader + call Function24ff9 + ret +; 24fe1 -Function24af8: ; 24af8 - ld hl, MenuDataHeader_0x24b15 - ld de, $b - call Function1e2e +Function24fe1: ; 24fe1 + callba GetItemPrice + ld a, d + ld [Buffer1], a + ld a, e + ld [Buffer2], a + ld hl, MenuDataHeader_0x250fd + call LoadMenuDataHeader + call Function24ff9 + ret +; 24ff9 -Function24b01: ; 24b01 - call MenuBox - call MenuBoxCoord2Tile - ld de, $15 - add hl, de - ld de, Money - lb bc, PRINTNUM_MONEY | 3, 6 - call PrintNum +Function24ff9: ; 24ff9 + ld a, $1 + ld [wItemQuantityChangeBuffer], a +.asm_24ffe + call Function25072 + call Function2500e + jr nc, .asm_24ffe + cp $ff + jr nz, .asm_2500c + scf ret -; 24b15 -MenuDataHeader_0x24b15: ; 0x24b15 - db $40 ; flags - db 00, 11 ; start coords - db 02, 19 ; end coords - dw NULL - db 1 ; default option -; 0x24b1d +.asm_2500c + and a + ret +; 2500e -MenuDataHeader_0x24b1d: ; 0x24b1d - db $40 ; flags - db 11, 00 ; start coords - db 13, 08 ; end coords - dw NULL - db 1 ; default option -; 0x24b25 +Function2500e: ; 2500e + call Function354b + bit 1, c + jr nz, .asm_2502b + bit 0, c + jr nz, .asm_2502f + bit 7, c + jr nz, .asm_25033 + bit 6, c + jr nz, .asm_2503f + bit 5, c + jr nz, .asm_2504d + bit 4, c + jr nz, .asm_2505f + and a + ret -Special_DisplayCoinCaseBalance: ; 24b25 - ; Place a text box of size 1x7 at 11, 0. - hlcoord 11, 0 - ld b, 1 - ld c, 7 - call TextBox - hlcoord 12, 0 - ld de, CoinString - call PlaceString - hlcoord 17, 1 - ld de, ShowMoney_TerminatorString - call PlaceString - ld de, Coins - lb bc, 2, 4 - hlcoord 13, 1 - call PrintNum +.asm_2502b + ld a, $ff + scf ret -; 24b4e -Special_DisplayMoneyAndCoinBalance: ; 24b4e - hlcoord 5, 0 - ld b, 3 - ld c, 13 - call TextBox - hlcoord 6, 1 - ld de, MoneyString - call PlaceString - hlcoord 12, 1 - ld de, Money - lb bc, PRINTNUM_MONEY | 3, 6 - call PrintNum - hlcoord 6, 3 - ld de, CoinString - call PlaceString - hlcoord 15, 3 - ld de, Coins - lb bc, 2, 4 - call PrintNum +.asm_2502f + ld a, $0 + scf ret -; 24b83 -MoneyString: ; 24b83 - db "MONEY@" -CoinString: ; 24b89 - db "COIN@" -ShowMoney_TerminatorString: ; 24b8e - db "@" -; 24b8f +.asm_25033 + ld hl, wItemQuantityChangeBuffer + dec [hl] + jr nz, .asm_2503d + ld a, [wItemQuantityBuffer] + ld [hl], a -Function24b8f: ; 24b8f -; unreferenced, related to safari? - ld hl, Options - ld a, [hl] - push af - set NO_TEXT_SCROLL, [hl] - hlcoord 0, 0 - ld b, 3 - ld c, 7 - call TextBox - hlcoord 1, 1 - ld de, wSafariTimeRemaining - lb bc, 2, 3 - call PrintNum - hlcoord 4, 1 - ld de, .slash_500 - call PlaceString - hlcoord 1, 3 - ld de, .booru_ko - call PlaceString - hlcoord 5, 3 - ld de, wSafariBallsRemaining - lb bc, 1, 2 - call PrintNum - pop af - ld [Options], a +.asm_2503d + and a ret -; 24bcf -.slash_500: ; 24bcf - db "/500@" -.booru_ko: ; 24bd4 - db "ボール こ@" -; 24bdc +.asm_2503f + ld hl, wItemQuantityChangeBuffer + inc [hl] + ld a, [wItemQuantityBuffer] + cp [hl] + jr nc, .asm_2504b + ld [hl], $1 -Function24bdc: ; 24bdc - hlcoord 0, 0 - ld b, $5 - ld c, $11 - call TextBox +.asm_2504b + and a ret -; 24be7 -Function24be7: ; 24be7 - ld hl, Options - ld a, [hl] - push af - set 4, [hl] - call Function24bdc - hlcoord 1, 5 - ld de, String24c52 - call PlaceString - hlcoord 8, 5 - ld de, wSafariBallsRemaining - lb bc, PRINTNUM_RIGHTALIGN | 1, 2 - call PrintNum - hlcoord 1, 1 - ld de, String24c4b - call PlaceString - ld a, [wContestMon] - and a - ld de, String24c59 - jr z, .asm_24c1e - ld [wd265], a - call GetPokemonName +.asm_2504d + ld a, [wItemQuantityChangeBuffer] + sub $a + jr c, .asm_25058 + jr z, .asm_25058 + jr .asm_2505a -.asm_24c1e - hlcoord 8, 1 - call PlaceString - ld a, [wContestMon] +.asm_25058 + ld a, $1 + +.asm_2505a + ld [wItemQuantityChangeBuffer], a and a - jr z, .asm_24c3e - hlcoord 1, 3 - ld de, String24c5e - call PlaceString - ld a, [wContestMonLevel] - ld h, b - ld l, c - inc hl - ld c, $3 - call Function3842 + ret -.asm_24c3e - pop af - ld [Options], a +.asm_2505f + ld a, [wItemQuantityChangeBuffer] + add $a + ld b, a + ld a, [wItemQuantityBuffer] + cp b + jr nc, .asm_2506c + ld b, a + +.asm_2506c + ld a, b + ld [wItemQuantityChangeBuffer], a + and a ret -; 24c43 +; 25072 -String24c43: ; 24c43 - db "ボール こ@" -String24c4b: ; 24c4b - db "CAUGHT@" -String24c52: ; 24c52 - db "BALLS:@" -String24c59: ; 24c59 - db "None@" -String24c5e: ; 24c5e - db "LEVEL@" -; 24c64 +Function25072: ; 25072 + call MenuBox + call MenuBoxCoord2Tile + ld de, $15 + add hl, de + ld [hl], $f1 + inc hl + ld de, wItemQuantityChangeBuffer + lb bc, PRINTNUM_LEADINGZEROS | 1, 2 + call PrintNum + ld a, [wMenuData2Pointer] + ld e, a + ld a, [wMenuData2Pointer + 1] + ld d, a + ld a, [wMenuDataBank] + call FarCall_de + ret +; 25097 -FindApricornsInBag: ; 24c64 -; Checks the bag for Apricorns. - ld hl, Buffer1 - xor a - ld [hli], a - dec a - ld bc, 10 - call ByteFill +Function25097: ; 25097 + ret +; 25098 - ld hl, .ApricornBalls -.loop - ld a, [hl] - cp -1 - jr z, .done - push hl - ld [CurItem], a - ld hl, NumItems - call CheckItem - pop hl - jr nc, .nope - ld a, [hl] - call .addtobuffer -.nope -rept 2 - inc hl -endr - jr .loop +Function25098: ; 25098 + call Function250a9 + call Function250d1 + ret +; 2509f -.done +Function2509f: ; 2509f + call Function250a9 + call Function250c1 + call Function250d1 + ret +; 250a9 + +Function250a9: ; 250a9 + xor a + ld [hMultiplicand + 0], a ld a, [Buffer1] - and a - ret nz - scf + ld [hMultiplicand + 1], a + ld a, [Buffer2] + ld [hMultiplicand + 2], a + ld a, [wItemQuantityChangeBuffer] + ld [hMultiplier], a + push hl + call Multiply + pop hl ret -; 24c94 +; 250c1 -.addtobuffer: ; 24c94 +Function250c1: ; 250c1 push hl - ld hl, Buffer1 - inc [hl] - ld e, [hl] - ld d, 0 - add hl, de + ld hl, hMultiplicand + ld a, [hl] + srl a + ld [hli], a + ld a, [hl] + rra + ld [hli], a + ld a, [hl] + rra ld [hl], a pop hl ret -; 24ca0 - -.ApricornBalls: ; 24ca0 - db RED_APRICORN, LEVEL_BALL - db BLU_APRICORN, LURE_BALL - db YLW_APRICORN, MOON_BALL - db GRN_APRICORN, FRIEND_BALL - db WHT_APRICORN, FAST_BALL - db BLK_APRICORN, HEAVY_BALL - db PNK_APRICORN, LOVE_BALL - db -1 -; 24caf - - -MonMenuOptionStrings: ; 24caf - db "STATS@" - db "SWITCH@" - db "ITEM@" - db "CANCEL@" - db "MOVE@" - db "MAIL@" - db "ERROR!@" -; 24cd9 - -MonMenuOptions: ; 24cd9 - -; Moves - db MONMENU_FIELD_MOVE, MONMENU_CUT, CUT - db MONMENU_FIELD_MOVE, MONMENU_FLY, FLY - db MONMENU_FIELD_MOVE, MONMENU_SURF, SURF - db MONMENU_FIELD_MOVE, MONMENU_STRENGTH, STRENGTH - db MONMENU_FIELD_MOVE, MONMENU_FLASH, FLASH - db MONMENU_FIELD_MOVE, MONMENU_WATERFALL, WATERFALL - db MONMENU_FIELD_MOVE, MONMENU_WHIRLPOOL, WHIRLPOOL - db MONMENU_FIELD_MOVE, MONMENU_DIG, DIG - db MONMENU_FIELD_MOVE, MONMENU_TELEPORT, TELEPORT - db MONMENU_FIELD_MOVE, MONMENU_SOFTBOILED, SOFTBOILED - db MONMENU_FIELD_MOVE, MONMENU_HEADBUTT, HEADBUTT - db MONMENU_FIELD_MOVE, MONMENU_ROCKSMASH, ROCK_SMASH - db MONMENU_FIELD_MOVE, MONMENU_MILKDRINK, MILK_DRINK - db MONMENU_FIELD_MOVE, MONMENU_SWEETSCENT, SWEET_SCENT - -; Options - db MONMENU_MENUOPTION, MONMENU_STATS, 1 ; STATS - db MONMENU_MENUOPTION, MONMENU_SWITCH, 2 ; SWITCH - db MONMENU_MENUOPTION, MONMENU_ITEM, 3 ; ITEM - db MONMENU_MENUOPTION, MONMENU_CANCEL, 4 ; CANCEL - db MONMENU_MENUOPTION, MONMENU_MOVE, 5 ; MOVE - db MONMENU_MENUOPTION, MONMENU_MAIL, 6 ; MAIL - db MONMENU_MENUOPTION, MONMENU_ERROR, 7 ; ERROR! - - db -1 -; 24d19 +; 250d1 -MonSubmenu: ; 24d19 - xor a - ld [hBGMapMode], a - call GetMonSubmenuItems - callba Function8ea4a - ld hl, .MenuDataHeader - call LoadMenuDataHeader - call .GetTopCoord - call PopulateMonMenu +Function250d1: ; 250d1 + push hl + ld hl, hMoneyTemp + ld a, [hMultiplicand] + ld [hli], a + ld a, [$ffb5] + ld [hli], a + ld a, [$ffb6] + ld [hl], a + pop hl + inc hl + ld de, hMoneyTemp + lb bc, PRINTNUM_MONEY | 3, 6 + call PrintNum + call WaitBGMap + ret +; 250ed - ld a, 1 - ld [hBGMapMode], a - call MonMenuLoop - ld [MenuSelection], a +MenuDataHeader_0x250ed: ; 0x250ed + db $40 ; flags + db 09, 15 ; start coords + db 11, 19 ; end coords + dw Function25097 + db 0 ; default option +; 0x250f5 - call ExitMenu - ret -; 24d3f +MenuDataHeader_0x250f5: ; 0x250f5 + db $40 ; flags + db 15, 07 ; start coords + db 17, 19 ; end coords + dw Function25098 + db -1 ; default option +; 0x250fd -.MenuDataHeader: ; 24d3f - db $40 ; tile backup - db 00, 06 ; start coords +MenuDataHeader_0x250fd: ; 0x250fd + db $40 ; flags + db 15, 07 ; start coords db 17, 19 ; end coords - dw 0 - db 1 ; default option -; 24d47 + dw Function2509f + db 0 ; default option +; 0x25105 -.GetTopCoord: ; 24d47 -; TopCoord = 1 + BottomCoord - 2 * (NumSubmenuItems + 1) - ld a, [Buffer1] - inc a - add a - ld b, a - ld a, [wMenuBorderBottomCoord] - sub b - inc a - ld [wMenuBorderTopCoord], a - call MenuBox +Function25105: ; 25105 + ld a, [VramState] + push af + xor a + ld [VramState], a + ld hl, Options + ld a, [hl] + push af + set 4, [hl] + call Function2513b +.asm_25117 + call UpdateTime + call JoyTextDelay + ld a, [wJumptableIndex] + bit 7, a + jr nz, .asm_25132 + ld a, [hJoyLast] + and B_BUTTON + jr nz, .asm_25132 + call Function2518e + call DelayFrame + jr .asm_25117 +.asm_25132 + pop af + ld [Options], a + pop af + ld [VramState], a ret -; 24d59 -MonMenuLoop: ; 24d59 -.loop - ld a, $a0 ; flags - ld [wMenuData2Flags], a - ld a, [Buffer1] ; items - ld [wMenuData2Items], a - call Function1c10 - ld hl, wcfa5 - set 6, [hl] - call Function1bc9 - ld de, SFX_READ_TEXT_2 - call PlaySFX - ld a, [hJoyPressed] - bit 0, a ; A - jr nz, .select - bit 1, a ; B - jr nz, .cancel - jr .loop - -.cancel - ld a, MONMENU_CANCEL ; CANCEL +Function2513b: ; 2513b (9:513b) + call ClearBGPalettes + call ClearSprites + call ClearTileMap + call DisableLCD + callba Function8833e + ld hl, CardRightCornerGFX + ld de, VTiles2 tile $1c + ld bc, $10 + ld a, BANK(CardRightCornerGFX) + call FarCopyBytes + ld hl, CardStatusGFX + ld de, VTiles2 tile $29 + ld bc, $60 + $500 + ld a, BANK(CardStatusGFX) + call FarCopyBytes + call Function25299 + hlcoord 0, 8 + ld d, $6 + call Function253b0 + call EnableLCD + call WaitBGMap + ld b, SCGB_15 + call GetSGBLayout + call SetPalettes + call WaitBGMap + ld hl, wJumptableIndex + xor a +rept 3 + ld [hli], a +endr + ld [hl], a ret -.select - ld a, [MenuSelection2] - dec a - ld c, a - ld b, 0 - ld hl, Buffer2 - add hl, bc - ld a, [hl] +Function2518e: ; 2518e (9:518e) + ld a, [wJumptableIndex] + ld e, a + ld d, $0 + ld hl, Jumptable_2519d +rept 2 + add hl, de +endr + ld a, [hli] + ld h, [hl] + ld l, a + jp [hl] + +Jumptable_2519d: ; 2519d (9:519d) + dw Function251b6 + dw Function251d7 + dw Function251f4 + dw Function25221 + dw Function2524c + dw Function25279 + dw Function251b0 + + +Function251ab: ; 251ab (9:51ab) + ld hl, wJumptableIndex + inc [hl] ret -; 24d91 -PopulateMonMenu: ; 24d91 - call MenuBoxCoord2Tile - ld bc, $2a ; 42 - add hl, bc - ld de, Buffer2 -.loop - ld a, [de] - inc de - cp -1 - ret z - push de - push hl - call GetMonMenuString - pop hl - call PlaceString - ld bc, $28 ; 40 - add hl, bc - pop de - jr .loop -; 24db0 +Function251b0: ; 251b0 (9:51b0) + ld hl, wJumptableIndex + set 7, [hl] + ret -GetMonMenuString: ; 24db0 - ld hl, MonMenuOptions + 1 - ld de, 3 - call IsInArray - dec hl - ld a, [hli] - cp 1 - jr z, .NotMove - inc hl - ld a, [hl] - ld [wd265], a - call GetMoveName +Function251b6: ; 251b6 (9:51b6) + call ClearSprites + hlcoord 0, 8 + ld d, $6 + call Function253b0 + call WaitBGMap + ld de, CardStatusGFX + ld hl, VTiles2 tile $29 + lb bc, BANK(CardStatusGFX), $6 + $50 + call Request2bpp + call Function2530a + call Function251ab ret -.NotMove - inc hl +Function251d7: ; 251d7 (9:51d7) + call Function25415 + ld hl, hJoyLast ld a, [hl] - dec a - ld hl, MonMenuOptionStrings - call GetNthString - ld d, h - ld e, l + and D_RIGHT | A_BUTTON + jr nz, .asm_251e3 ret -; 24dd4 +.asm_251e3 + ld a, $2 + ld [wJumptableIndex], a + ret +; 251e9 (9:51e9) -GetMonSubmenuItems: ; 24dd4 - call ResetMonSubmenu - ld a, [CurPartySpecies] - cp EGG - jr z, .egg - ld a, [wLinkMode] - and a - jr nz, .skip_moves - ld a, MON_MOVES - call GetPartyParamLocation - ld d, h - ld e, l - ld c, NUM_MOVES -.loop - push bc - push de - ld a, [de] +Function251e9: ; 251e9 + ld a, [KantoBadges] and a - jr z, .next - push hl - call IsFieldMove - pop hl - jr nc, .next - call AddMonMenuItem + ret z + ld a, $4 + ld [wJumptableIndex], a + ret +; 251f4 -.next - pop de - inc de - pop bc - dec c - jr nz, .loop +Function251f4: ; 251f4 (9:51f4) + call ClearSprites + hlcoord 0, 8 + ld d, $6 + call Function253b0 + call WaitBGMap + ld de, LeaderGFX + ld hl, VTiles2 tile $29 + lb bc, BANK(LeaderGFX), $56 + call Request2bpp + ld de, BadgeGFX + ld hl, VTiles0 tile $00 + lb bc, BANK(BadgeGFX), $2c + call Request2bpp + call Function2536c + call Function251ab + ret -.skip_moves - ld a, MONMENU_STATS - call AddMonMenuItem - ld a, MONMENU_SWITCH - call AddMonMenuItem - ld a, MONMENU_MOVE - call AddMonMenuItem - ld a, [wLinkMode] +Function25221: ; 25221 (9:5221) + ld hl, Unknown_254c9 + call Function25438 + ld hl, hJoyLast + ld a, [hl] + and A_BUTTON + jr nz, Function25246 + ld a, [hl] + and D_LEFT + jr nz, .asm_25235 + ret +.asm_25235 + ld a, $0 + ld [wJumptableIndex], a + ret +; 2523b (9:523b) + +Function2523b: ; 2523b + ld a, [KantoBadges] and a - jr nz, .skip2 - push hl - ld a, MON_ITEM - call GetPartyParamLocation - ld d, [hl] - callba ItemIsMail - pop hl - ld a, MONMENU_MAIL - jr c, .ok - ld a, MONMENU_ITEM + ret z + ld a, $4 + ld [wJumptableIndex], a + ret +; 25246 -.ok - call AddMonMenuItem +Function25246: ; 25246 + ld a, $6 + ld [wJumptableIndex], a + ret -.skip2 - ld a, [Buffer1] - cp NUM_MON_SUBMENU_ITEMS - jr z, .ok2 - ld a, MONMENU_CANCEL - call AddMonMenuItem - -.ok2 - call TerminateMonSubmenu - ret - -.egg - ld a, MONMENU_STATS - call AddMonMenuItem - ld a, MONMENU_SWITCH - call AddMonMenuItem - ld a, MONMENU_CANCEL - call AddMonMenuItem - call TerminateMonSubmenu - ret -; 24e52 - -IsFieldMove: ; 24e52 - ld b, a - ld hl, MonMenuOptions -.next - ld a, [hli] - cp -1 - jr z, .nope - cp MONMENU_MENUOPTION - jr z, .nope - ld d, [hl] - inc hl - ld a, [hli] - cp b - jr nz, .next - ld a, d - scf - -.nope +Function2524c: ; 2524c (9:524c) + call ClearSprites + hlcoord 0, 8 + ld d, $6 + call Function253b0 + call WaitBGMap + ld de, LeaderGFX2 + ld hl, VTiles2 tile $29 + lb bc, BANK(LeaderGFX2), $56 + call Request2bpp + ld de, BadgeGFX2 + ld hl, VTiles0 tile $00 + lb bc, BANK(BadgeGFX2), $2c + call Request2bpp + call Function2536c + call Function251ab ret -; 24e68 -ResetMonSubmenu: ; 24e68 - xor a - ld [Buffer1], a - ld hl, Buffer2 - ld bc, NUM_MON_SUBMENU_ITEMS + 1 - call ByteFill +Function25279: ; 25279 (9:5279) + ld hl, Unknown_254c9 + call Function25438 + ld hl, hJoyLast + ld a, [hl] + and D_LEFT + jr nz, .asm_2528d + ld a, [hl] + and D_RIGHT + jr nz, .asm_25293 ret -; 24e76 - -TerminateMonSubmenu: ; 24e76 - ld a, [Buffer1] - ld e, a - ld d, $0 - ld hl, Buffer2 - add hl, de - ld [hl], -1 +.asm_2528d + ld a, $2 + ld [wJumptableIndex], a ret -; 24e83 - -AddMonMenuItem: ; 24e83 - push hl - push de - push af - ld a, [Buffer1] - ld e, a - inc a - ld [Buffer1], a - ld d, $0 - ld hl, Buffer2 - add hl, de - pop af - ld [hl], a - pop de - pop hl +.asm_25293 + ld a, $0 + ld [wJumptableIndex], a ret -; 24e99 -Function24e99: ; 24e99 -; BattleMonMenu - ld hl, MenuDataHeader_0x24ed4 - call CopyMenuDataHeader +Function25299: ; 25299 (9:5299) + hlcoord 0, 0 + ld d, $5 + call Function253b0 + hlcoord 2, 2 + ld de, String_252ec + call PlaceString + hlcoord 2, 4 + ld de, Tilemap_252f9 + call Function253a8 + hlcoord 7, 2 + ld de, PlayerName + call PlaceString + hlcoord 5, 4 + ld de, PlayerID + lb bc, PRINTNUM_LEADINGZEROS | 2, 5 + call PrintNum + hlcoord 7, 6 + ld de, Money + lb bc, PRINTNUM_MONEY | 3, 6 + call PrintNum + hlcoord 1, 3 + ld de, Tilemap_252fc + call Function253a8 + hlcoord 14, 1 + lb bc, 5, 7 xor a - ld [hBGMapMode], a - call MenuBox - call UpdateSprites - call Function1c89 - call WaitBGMap - call CopyMenuData2 - ld a, [wMenuData2Flags] - bit 7, a - jr z, .asm_24ed0 - call Function1c10 - ld hl, wcfa5 - set 6, [hl] - call Function1bc9 - ld de, SFX_READ_TEXT_2 - call PlaySFX - ld a, [hJoyPressed] - bit 1, a - jr z, .asm_24ed2 - ret z - -.asm_24ed0 - scf - ret - -.asm_24ed2 - and a + ld [hFillBox], a + predef FillBox ret -; 24ed4 +; 252ec (9:52ec) -MenuDataHeader_0x24ed4: ; 24ed4 - db $00 ; flags - db 11, 11 ; start coords - db 17, 19 ; end coords - dw MenuData2_0x24edc - db 1 ; default option -; 24edc +String_252ec: ; 252ec + db "NAME/" + next "" + next "MONEY@" -MenuData2_0x24edc: ; 24edc - db $c0 ; flags - db 3 ; items - db "SWITCH@" - db "STATS@" - db "CANCEL@" -; 24ef2 +Tilemap_252f9: ; 252f9 + db $27, $28, $ff ; ID NO +Tilemap_252fc: ; 252fc + db $25, $25, $25, $25, $25, $25, $25, $25, $25, $25, $25, $25, $26, $ff ; ____________> +; 2530a -LoadBattleMenu: ; 24ef2 - ld hl, BattleMenuDataHeader - call LoadMenuDataHeader - ld a, [wd0d2] - ld [wMenuCursorBuffer], a - call Function2039 - ld a, [wMenuCursorBuffer] - ld [wd0d2], a - call ExitMenu +Function2530a: ; 2530a (9:530a) + hlcoord 2, 10 + ld de, String_2534c + call PlaceString + hlcoord 10, 15 + ld de, String_2535c + call PlaceString + ld hl, PokedexCaught + ld b, $20 + call CountSetBits + ld de, wd265 + hlcoord 15, 10 + lb bc, 1, 3 + call PrintNum + call Function25415 + hlcoord 2, 8 + ld de, Tilemap_25366 + call Function253a8 + ld a, [StatusFlags] ; pokedex + bit 0, a + ret nz + hlcoord 1, 9 + lb bc, 2, 17 + call ClearBox ret -; 24f0b - +; 2534c (9:534c) -SafariBattleMenu: ; 24f0b -; untranslated - ld hl, MenuDataHeader_0x24f4e - call LoadMenuDataHeader - jr Function24f19 -; 24f13 +String_2534c: ; 2534c + db "#DEX" + next "PLAY TIME" + db "@" -ContestBattleMenu: ; 24f13 - ld hl, MenuDataHeader_0x24f89 - call LoadMenuDataHeader -; 24f19 +String_2535b: ; 2535b + db "@" -Function24f19: ; 24f19 - ld a, [wd0d2] - ld [wMenuCursorBuffer], a - call InterpretMenu - ld a, [wMenuCursorBuffer] - ld [wd0d2], a - call ExitMenu - ret -; 24f2c +String_2535c: ; 2535c + db " BADGES▶@" +Tilemap_25366: ; 25366 + db $29, $2a, $2b, $2c, $2d, $ff +; 2536c -BattleMenuDataHeader: ; 24f2c - db $40 ; flags - db 12, 08 ; start coords - db 17, 19 ; end coords - dw MenuData_0x24f34 - db 1 ; default option -; 24f34 - -MenuData_0x24f34: ; 0x24f34 - db $81 ; flags - dn 2, 2 ; rows, columns - db 6 ; spacing - dba Strings24f3d - dbw $09, 0 -; 0x24f3d - -Strings24f3d: ; 0x24f3d - db "FIGHT@" - db $4a, "@" - db "PACK@" - db "RUN@" -; 24f4e - - -MenuDataHeader_0x24f4e: ; 24f4e - db $40 ; flags - db 12, 00 ; start coords - db 17, 19 ; end coords - dw MenuData_0x24f56 - db 1 ; default option -; 24f56 - -MenuData_0x24f56: ; 24f56 - db $81 ; flags - dn 2, 2 ; rows, columns - db 11 ; spacing - dba Strings24f5f - dba Function24f7c -; 24f5f - -Strings24f5f: ; 24f5f - db "サファりボール× @" ; "SAFARI BALL× @" - db "エサをなげる@" ; "THROW BAIT" - db "いしをなげる@" ; "THROW ROCK" - db "にげる@" ; "RUN" -; 24f7c - -Function24f7c: ; 24f7c - hlcoord 17, 13 - ld de, wSafariBallsRemaining - lb bc, PRINTNUM_LEADINGZEROS | 1, 2 - call PrintNum +Function2536c: ; 2536c (9:536c) + hlcoord 2, 8 + ld de, Tilemap_253a2 + call Function253a8 + hlcoord 2, 10 + ld a, $29 + ld c, $4 +.asm_2537c + call Function253f4 +rept 4 + inc hl +endr + dec c + jr nz, .asm_2537c + hlcoord 2, 13 + ld a, $51 + ld c, $4 +.asm_2538d + call Function253f4 +rept 4 + inc hl +endr + dec c + jr nz, .asm_2538d + xor a + ld [wcf64], a + ld hl, Unknown_254c9 + call Function25448 ret -; 24f89 +; 253a2 (9:53a2) +Tilemap_253a2: ; 253a2 + db $79, $7a, $7b, $7c, $7d, $ff ; "BADGES" +; 253a8 -MenuDataHeader_0x24f89: ; 24f89 - db $40 ; flags - db 12, 02 ; start coords - db 17, 19 ; end coords - dw MenuData_0x24f91 - db 1 ; default option -; 24f91 +Function253a8: ; 253a8 (9:53a8) + ld a, [de] + cp $ff + ret z + ld [hli], a + inc de + jr Function253a8 -MenuData_0x24f91: ; 24f91 - db $81 ; flags - dn 2, 2 ; rows, columns - db 12 ; spacing - dba Strings24f9a - dba Function24fb2 -; 24f9a +Function253b0: ; 253b0 (9:53b0) + ld e, $14 +.asm_253b2 + ld a, $23 + ld [hli], a + dec e + jr nz, .asm_253b2 + ld a, $23 + ld [hli], a + ld e, $11 + ld a, $7f +.asm_253bf + ld [hli], a + dec e + jr nz, .asm_253bf + ld a, $1c + ld [hli], a + ld a, $23 + ld [hli], a +.asm_253c9 + ld a, $23 + ld [hli], a + ld e, $12 + ld a, $7f +.asm_253d0 + ld [hli], a + dec e + jr nz, .asm_253d0 + ld a, $23 + ld [hli], a + dec d + jr nz, .asm_253c9 + ld a, $23 + ld [hli], a + ld a, $24 + ld [hli], a + ld e, $11 + ld a, $7f +.asm_253e4 + ld [hli], a + dec e + jr nz, .asm_253e4 + ld a, $23 + ld [hli], a + ld e, $14 +.asm_253ed + ld a, $23 + ld [hli], a + dec e + jr nz, .asm_253ed + ret -Strings24f9a: ; 24f9a - db "FIGHT@" - db "", "@" - db "PARKBALL× @" - db "RUN@" -; 24fb2 +Function253f4: ; 253f4 (9:53f4) + push de + push hl + ld [hli], a + inc a + ld [hli], a + inc a + ld [hli], a + inc a + ld [hli], a + inc a + ld de, $11 + add hl, de + ld [hli], a + inc a + ld [hli], a + inc a + ld [hli], a + inc a + ld de, $11 + add hl, de + ld [hli], a + inc a + ld [hli], a + inc a + ld [hli], a + inc a + pop hl + pop de + ret -Function24fb2: ; 24fb2 - hlcoord 13, 16 - ld de, wParkBallsRemaining +Function25415: ; 25415 (9:5415) + hlcoord 11, 12 + ld de, GameTimeHours + lb bc, 2, 4 + call PrintNum + inc hl + ld de, GameTimeMinutes lb bc, PRINTNUM_LEADINGZEROS | 1, 2 call PrintNum + ld a, [hVBlankCounter] + and $1f + ret nz + hlcoord 15, 12 + ld a, [hl] + xor $51 + ld [hl], a ret -; 24fbf +Function25438: ; 25438 (9:5438) + ld a, [hVBlankCounter] + and $7 + ret nz + ld a, [wcf64] + inc a + and $7 + ld [wcf64], a + jr Function25448 -Function24fbf: ; 24fbf - ld hl, MenuDataHeader_0x250ed - call LoadMenuDataHeader - call Function24ff9 +Function25448: ; 25448 (9:5448) + ld a, [hli] + ld e, a + ld a, [hli] + ld d, a + ld a, [de] + ld c, a + ld de, Sprites + ld b, 8 +.asm_25453 + srl c + push bc + jr nc, .asm_25472 + push hl + ld a, [hli] + ld b, a + ld a, [hli] + ld c, a + ld a, [hli] + ld [wcf66], a + ld a, [wcf64] + add l + ld l, a + ld a, 0 + adc h + ld h, a + ld a, [hl] + ld [wcf65], a + call Function2547b + pop hl +.asm_25472 + ld bc, $b + add hl, bc + pop bc + dec b + jr nz, .asm_25453 ret -; 24fc9 +Function2547b: ; 2547b (9:547b) + ld a, [wcf65] + and $80 + jr nz, .asm_25487 + ld hl, Unknown_254a7 + jr .asm_2548a +.asm_25487 + ld hl, Unknown_254b8 +.asm_2548a + ld a, [hli] + cp $ff + ret z + add b + ld [de], a + inc de + ld a, [hli] + add c + ld [de], a + inc de + ld a, [wcf65] + and $7f + add [hl] + ld [de], a + inc hl + inc de + ld a, [wcf66] + add [hl] + ld [de], a + inc hl + inc de + jr .asm_2548a +; 254a7 (9:54a7) -Function24fc9: ; 24fc9 - callba GetItemPrice -Function24fcf: ; 24fcf - ld a, d - ld [Buffer1], a - ld a, e - ld [Buffer2], a - ld hl, MenuDataHeader_0x250f5 - call LoadMenuDataHeader - call Function24ff9 - ret -; 24fe1 +Unknown_254a7: ; 254a7 + db $00, $00, $00, $00 + db $00, $08, $01, $00 + db $08, $00, $02, $00 + db $08, $08, $03, $00 + db $ff -Function24fe1: ; 24fe1 - callba GetItemPrice - ld a, d - ld [Buffer1], a - ld a, e - ld [Buffer2], a - ld hl, MenuDataHeader_0x250fd - call LoadMenuDataHeader - call Function24ff9 - ret -; 24ff9 +Unknown_254b8: ; 254b8 + db $00, $00, $01, $20 + db $00, $08, $00, $20 + db $08, $00, $03, $20 + db $08, $08, $02, $20 + db $ff -Function24ff9: ; 24ff9 - ld a, $1 - ld [wItemQuantityChangeBuffer], a -.asm_24ffe - call Function25072 - call Function2500e - jr nc, .asm_24ffe - cp $ff - jr nz, .asm_2500c - scf - ret +Unknown_254c9: ; 254c9 +; Template OAM data for each badge on the trainer card. +; Format: + ; y, x, palette + ; cycle 1: face tile, in1 tile, in2 tile, in3 tile + ; cycle 2: face tile, in1 tile, in2 tile, in3 tile -.asm_2500c - and a - ret -; 2500e + dw JohtoBadges -Function2500e: ; 2500e - call Function354b - bit 1, c - jr nz, .asm_2502b - bit 0, c - jr nz, .asm_2502f - bit 7, c - jr nz, .asm_25033 - bit 6, c - jr nz, .asm_2503f - bit 5, c - jr nz, .asm_2504d - bit 4, c - jr nz, .asm_2505f - and a - ret + ; Zephyrbadge + db $68, $18, $00 + db $00, $20, $24, $20 | $80 + db $00, $20, $24, $20 | $80 -.asm_2502b - ld a, $ff - scf - ret + ; Hivebadge + db $68, $38, $00 + db $04, $20, $24, $20 | $80 + db $04, $20, $24, $20 | $80 -.asm_2502f - ld a, $0 - scf - ret + ; Plainbadge + db $68, $58, $00 + db $08, $20, $24, $20 | $80 + db $08, $20, $24, $20 | $80 -.asm_25033 - ld hl, wItemQuantityChangeBuffer - dec [hl] - jr nz, .asm_2503d - ld a, [wItemQuantityBuffer] - ld [hl], a + ; Fogbadge + db $68, $78, $00 + db $0c, $20, $24, $20 | $80 + db $0c, $20, $24, $20 | $80 -.asm_2503d - and a - ret + ; Mineralbadge + db $80, $38, $00 + db $10, $20, $24, $20 | $80 + db $10, $20, $24, $20 | $80 -.asm_2503f - ld hl, wItemQuantityChangeBuffer - inc [hl] - ld a, [wItemQuantityBuffer] - cp [hl] - jr nc, .asm_2504b - ld [hl], $1 + ; Stormbadge + db $80, $18, $00 + db $14, $20, $24, $20 | $80 + db $14, $20, $24, $20 | $80 -.asm_2504b - and a - ret + ; Glacierbadge + db $80, $58, $00 + db $18, $20, $24, $20 | $80 + db $18, $20, $24, $20 | $80 -.asm_2504d - ld a, [wItemQuantityChangeBuffer] - sub $a - jr c, .asm_25058 - jr z, .asm_25058 - jr .asm_2505a + ; Risingbadge + ; X-flips on alternate cycles. + db $80, $78, $00 + db $1c, $20, $24, $20 | $80 + db $1c | $80, $20, $24, $20 | $80 +; 25523 -.asm_25058 - ld a, $1 +CardStatusGFX: INCBIN "gfx/misc/card_status.2bpp" -.asm_2505a - ld [wItemQuantityChangeBuffer], a - and a - ret +LeaderGFX: INCBIN "gfx/misc/leaders.w24.2bpp" +LeaderGFX2: INCBIN "gfx/misc/leaders.w24.2bpp" +BadgeGFX: INCBIN "gfx/misc/badges.2bpp" +BadgeGFX2: INCBIN "gfx/misc/badges.2bpp" -.asm_2505f - ld a, [wItemQuantityChangeBuffer] - add $a - ld b, a - ld a, [wItemQuantityBuffer] - cp b - jr nc, .asm_2506c - ld b, a +CardRightCornerGFX: INCBIN "gfx/misc/card_right_corner.2bpp" -.asm_2506c - ld a, b - ld [wItemQuantityChangeBuffer], a - and a - ret -; 25072 -Function25072: ; 25072 - call MenuBox - call MenuBoxCoord2Tile - ld de, $15 - add hl, de - ld [hl], $f1 - inc hl - ld de, wItemQuantityChangeBuffer - lb bc, PRINTNUM_LEADINGZEROS | 1, 2 - call PrintNum - ld a, [wMenuData2Pointer] - ld e, a - ld a, [wMenuData2Pointer + 1] - ld d, a - ld a, [wMenuDataBank] - call FarCall_de +ProfOaksPC: ; 0x265d3 + ld hl, OakPCText1 + call MenuTextBox + call YesNoBox + jr c, .shutdown + call ProfOaksPCBoot ; player chose "yes"? +.shutdown + ld hl, OakPCText4 + call PrintText + call JoyWaitAorB + call ExitMenu ret -; 25097 - +; 0x265ee -Function25097: ; 25097 +ProfOaksPCBoot ; 0x265ee + ld hl, OakPCText2 + call PrintText + call Rate + call PlaySFX ; sfx loaded by previous Rate function call + call JoyWaitAorB + call WaitSFX ret -; 25098 +; 0x26601 -Function25098: ; 25098 - call Function250a9 - call Function250d1 +Function26601: ; 0x26601 + call Rate + push de + ld de, MUSIC_NONE + call PlayMusic + pop de + call PlaySFX + call JoyWaitAorB + call WaitSFX ret -; 2509f +; 0x26616 -Function2509f: ; 2509f - call Function250a9 - call Function250c1 - call Function250d1 - ret -; 250a9 +Rate: ; 0x26616 +; calculate Seen/Owned + ld hl, PokedexSeen + ld b, EndPokedexSeen - PokedexSeen + call CountSetBits + ld [wd002], a + ld hl, PokedexCaught + ld b, EndPokedexCaught - PokedexCaught + call CountSetBits + ld [wd003], a -Function250a9: ; 250a9 - xor a - ld [hMultiplicand + 0], a - ld a, [Buffer1] - ld [hMultiplicand + 1], a - ld a, [Buffer2] - ld [hMultiplicand + 2], a - ld a, [wItemQuantityChangeBuffer] - ld [hMultiplier], a - push hl - call Multiply - pop hl +; print appropriate rating + call ClearOakRatingBuffers + ld hl, OakPCText3 + call PrintText + call JoyWaitAorB + ld a, [wd003] + ld hl, OakRatings + call FindOakRating + push de + call PrintText + pop de ret -; 250c1 +; 0x26647 -Function250c1: ; 250c1 - push hl - ld hl, hMultiplicand - ld a, [hl] - srl a - ld [hli], a - ld a, [hl] - rra - ld [hli], a - ld a, [hl] - rra - ld [hl], a - pop hl +ClearOakRatingBuffers: ; 0x26647 + ld hl, StringBuffer3 + ld de, wd002 + call ClearOakRatingBuffer + ld hl, StringBuffer4 + ld de, wd003 + call ClearOakRatingBuffer ret -; 250d1 +; 0x2665a -Function250d1: ; 250d1 +ClearOakRatingBuffer: ; 0x2665a push hl - ld hl, hMoneyTemp - ld a, [hMultiplicand] - ld [hli], a - ld a, [$ffb5] - ld [hli], a - ld a, [$ffb6] - ld [hl], a + ld a, "@" + ld bc, ITEM_NAME_LENGTH + call ByteFill pop hl - inc hl - ld de, hMoneyTemp - lb bc, PRINTNUM_MONEY | 3, 6 + lb bc, PRINTNUM_RIGHTALIGN | 1, 3 call PrintNum - call WaitBGMap - ret -; 250ed - -MenuDataHeader_0x250ed: ; 0x250ed - db $40 ; flags - db 09, 15 ; start coords - db 11, 19 ; end coords - dw Function25097 - db 0 ; default option -; 0x250f5 - -MenuDataHeader_0x250f5: ; 0x250f5 - db $40 ; flags - db 15, 07 ; start coords - db 17, 19 ; end coords - dw Function25098 - db -1 ; default option -; 0x250fd - -MenuDataHeader_0x250fd: ; 0x250fd - db $40 ; flags - db 15, 07 ; start coords - db 17, 19 ; end coords - dw Function2509f - db 0 ; default option -; 0x25105 - -Function25105: ; 25105 - ld a, [VramState] - push af - xor a - ld [VramState], a - ld hl, Options - ld a, [hl] - push af - set 4, [hl] - call Function2513b -.asm_25117 - call UpdateTime - call JoyTextDelay - ld a, [wJumptableIndex] - bit 7, a - jr nz, .asm_25132 - ld a, [hJoyLast] - and B_BUTTON - jr nz, .asm_25132 - call Function2518e - call DelayFrame - jr .asm_25117 -.asm_25132 - pop af - ld [Options], a - pop af - ld [VramState], a ret +; 0x2666b -Function2513b: ; 2513b (9:513b) - call ClearBGPalettes - call ClearSprites - call ClearTileMap - call DisableLCD - callba Function8833e - ld hl, CardRightCornerGFX - ld de, VTiles2 tile $1c - ld bc, $10 - ld a, BANK(CardRightCornerGFX) - call FarCopyBytes - ld hl, CardStatusGFX - ld de, VTiles2 tile $29 - ld bc, $60 + $500 - ld a, BANK(CardStatusGFX) - call FarCopyBytes - call Function25299 - hlcoord 0, 8 - ld d, $6 - call Function253b0 - call EnableLCD - call WaitBGMap - ld b, SCGB_15 - call GetSGBLayout - call SetPalettes - call WaitBGMap - ld hl, wJumptableIndex - xor a -rept 3 - ld [hli], a +FindOakRating: ; 0x2666b +; return sound effect in de +; return text pointer in hl + nop + ld c, a +.loop + ld a, [hli] + cp c + jr nc, .match +rept 4 + inc hl endr - ld [hl], a - ret + jr .loop -Function2518e: ; 2518e (9:518e) - ld a, [wJumptableIndex] +.match + ld a, [hli] ld e, a - ld d, $0 - ld hl, Jumptable_2519d -rept 2 - add hl, de -endr + ld a, [hli] + ld d, a ld a, [hli] ld h, [hl] ld l, a - jp [hl] + ret +; 0x2667f -Jumptable_2519d: ; 2519d (9:519d) - dw Function251b6 - dw Function251d7 - dw Function251f4 - dw Function25221 - dw Function2524c - dw Function25279 - dw Function251b0 +OakRatings: ; 0x2667f +; db count (if number caught ≤ this number, then this entry is used) +; dw sound effect +; dw text pointer + db 9 + dw SFX_DEX_FANFARE_LESS_THAN_20 + dw OakRating01 -Function251ab: ; 251ab (9:51ab) - ld hl, wJumptableIndex - inc [hl] - ret + db 19 + dw SFX_DEX_FANFARE_LESS_THAN_20 + dw OakRating02 -Function251b0: ; 251b0 (9:51b0) - ld hl, wJumptableIndex - set 7, [hl] - ret + db 34 + dw SFX_DEX_FANFARE_20_49 + dw OakRating03 -Function251b6: ; 251b6 (9:51b6) - call ClearSprites - hlcoord 0, 8 - ld d, $6 - call Function253b0 - call WaitBGMap - ld de, CardStatusGFX - ld hl, VTiles2 tile $29 - lb bc, BANK(CardStatusGFX), $6 + $50 - call Request2bpp - call Function2530a - call Function251ab - ret + db 49 + dw SFX_DEX_FANFARE_20_49 + dw OakRating04 -Function251d7: ; 251d7 (9:51d7) - call Function25415 - ld hl, hJoyLast - ld a, [hl] - and D_RIGHT | A_BUTTON - jr nz, .asm_251e3 - ret -.asm_251e3 - ld a, $2 - ld [wJumptableIndex], a - ret -; 251e9 (9:51e9) + db 64 + dw SFX_DEX_FANFARE_50_79 + dw OakRating05 -Function251e9: ; 251e9 - ld a, [KantoBadges] - and a - ret z - ld a, $4 - ld [wJumptableIndex], a - ret -; 251f4 + db 79 + dw SFX_DEX_FANFARE_50_79 + dw OakRating06 -Function251f4: ; 251f4 (9:51f4) - call ClearSprites - hlcoord 0, 8 - ld d, $6 - call Function253b0 - call WaitBGMap - ld de, LeaderGFX - ld hl, VTiles2 tile $29 - lb bc, BANK(LeaderGFX), $56 - call Request2bpp - ld de, BadgeGFX - ld hl, VTiles0 tile $00 - lb bc, BANK(BadgeGFX), $2c - call Request2bpp - call Function2536c - call Function251ab - ret + db 94 + dw SFX_DEX_FANFARE_80_109 + dw OakRating07 -Function25221: ; 25221 (9:5221) - ld hl, Unknown_254c9 - call Function25438 - ld hl, hJoyLast - ld a, [hl] - and A_BUTTON - jr nz, Function25246 - ld a, [hl] - and D_LEFT - jr nz, .asm_25235 - ret -.asm_25235 - ld a, $0 - ld [wJumptableIndex], a - ret -; 2523b (9:523b) + db 109 + dw SFX_DEX_FANFARE_80_109 + dw OakRating08 -Function2523b: ; 2523b - ld a, [KantoBadges] - and a - ret z - ld a, $4 - ld [wJumptableIndex], a - ret -; 25246 + db 124 + dw SFX_CAUGHT_MON + dw OakRating09 -Function25246: ; 25246 - ld a, $6 - ld [wJumptableIndex], a - ret + db 139 + dw SFX_CAUGHT_MON + dw OakRating10 -Function2524c: ; 2524c (9:524c) - call ClearSprites - hlcoord 0, 8 - ld d, $6 - call Function253b0 - call WaitBGMap - ld de, LeaderGFX2 - ld hl, VTiles2 tile $29 - lb bc, BANK(LeaderGFX2), $56 - call Request2bpp - ld de, BadgeGFX2 - ld hl, VTiles0 tile $00 - lb bc, BANK(BadgeGFX2), $2c - call Request2bpp - call Function2536c - call Function251ab - ret + db 154 + dw SFX_DEX_FANFARE_140_169 + dw OakRating11 -Function25279: ; 25279 (9:5279) - ld hl, Unknown_254c9 - call Function25438 - ld hl, hJoyLast - ld a, [hl] - and D_LEFT - jr nz, .asm_2528d - ld a, [hl] - and D_RIGHT - jr nz, .asm_25293 - ret -.asm_2528d - ld a, $2 - ld [wJumptableIndex], a - ret -.asm_25293 - ld a, $0 - ld [wJumptableIndex], a - ret + db 169 + dw SFX_DEX_FANFARE_140_169 + dw OakRating12 -Function25299: ; 25299 (9:5299) - hlcoord 0, 0 - ld d, $5 - call Function253b0 - hlcoord 2, 2 - ld de, String_252ec - call PlaceString - hlcoord 2, 4 - ld de, Tilemap_252f9 - call Function253a8 - hlcoord 7, 2 - ld de, PlayerName - call PlaceString - hlcoord 5, 4 - ld de, PlayerID - lb bc, PRINTNUM_LEADINGZEROS | 2, 5 - call PrintNum - hlcoord 7, 6 - ld de, Money - lb bc, PRINTNUM_MONEY | 3, 6 - call PrintNum - hlcoord 1, 3 - ld de, Tilemap_252fc - call Function253a8 - hlcoord 14, 1 - lb bc, 5, 7 - xor a - ld [hFillBox], a - predef FillBox - ret -; 252ec (9:52ec) + db 184 + dw SFX_DEX_FANFARE_170_199 + dw OakRating13 -String_252ec: ; 252ec - db "NAME/" - next "" - next "MONEY@" + db 199 + dw SFX_DEX_FANFARE_170_199 + dw OakRating14 -Tilemap_252f9: ; 252f9 - db $27, $28, $ff ; ID NO + db 214 + dw SFX_DEX_FANFARE_200_229 + dw OakRating15 -Tilemap_252fc: ; 252fc - db $25, $25, $25, $25, $25, $25, $25, $25, $25, $25, $25, $25, $26, $ff ; ____________> -; 2530a + db 229 + dw SFX_DEX_FANFARE_200_229 + dw OakRating16 -Function2530a: ; 2530a (9:530a) - hlcoord 2, 10 - ld de, String_2534c - call PlaceString - hlcoord 10, 15 - ld de, String_2535c - call PlaceString - ld hl, PokedexCaught - ld b, $20 - call CountSetBits - ld de, wd265 - hlcoord 15, 10 - lb bc, 1, 3 - call PrintNum - call Function25415 - hlcoord 2, 8 - ld de, Tilemap_25366 - call Function253a8 - ld a, [StatusFlags] ; pokedex - bit 0, a - ret nz - hlcoord 1, 9 - lb bc, 2, 17 - call ClearBox - ret -; 2534c (9:534c) + db 239 + dw SFX_DEX_FANFARE_230_PLUS + dw OakRating17 -String_2534c: ; 2534c - db "#DEX" - next "PLAY TIME" - db "@" + db 248 + dw SFX_DEX_FANFARE_230_PLUS + dw OakRating18 -String_2535b: ; 2535b + db 255 + dw SFX_DEX_FANFARE_230_PLUS + dw OakRating19 + +OakPCText1: ; 0x266de + text_jump _OakPCText1 db "@" -String_2535c: ; 2535c - db " BADGES▶@" +OakPCText2: ; 0x266e3 + text_jump _OakPCText2 + db "@" -Tilemap_25366: ; 25366 - db $29, $2a, $2b, $2c, $2d, $ff -; 2536c +OakPCText3: ; 0x266e8 + text_jump _OakPCText3 + db "@" -Function2536c: ; 2536c (9:536c) - hlcoord 2, 8 - ld de, Tilemap_253a2 - call Function253a8 - hlcoord 2, 10 - ld a, $29 - ld c, $4 -.asm_2537c - call Function253f4 -rept 4 - inc hl -endr - dec c - jr nz, .asm_2537c - hlcoord 2, 13 - ld a, $51 - ld c, $4 -.asm_2538d - call Function253f4 -rept 4 - inc hl -endr - dec c - jr nz, .asm_2538d - xor a - ld [wcf64], a - ld hl, Unknown_254c9 - call Function25448 - ret -; 253a2 (9:53a2) +OakRating01: + text_jump _OakRating01 + db "@" -Tilemap_253a2: ; 253a2 - db $79, $7a, $7b, $7c, $7d, $ff ; "BADGES" -; 253a8 +OakRating02: + text_jump _OakRating02 + db "@" -Function253a8: ; 253a8 (9:53a8) - ld a, [de] - cp $ff - ret z - ld [hli], a - inc de - jr Function253a8 +OakRating03: + text_jump _OakRating03 + db "@" -Function253b0: ; 253b0 (9:53b0) - ld e, $14 -.asm_253b2 - ld a, $23 - ld [hli], a - dec e - jr nz, .asm_253b2 - ld a, $23 - ld [hli], a - ld e, $11 - ld a, $7f -.asm_253bf - ld [hli], a - dec e - jr nz, .asm_253bf - ld a, $1c - ld [hli], a - ld a, $23 - ld [hli], a -.asm_253c9 - ld a, $23 - ld [hli], a - ld e, $12 - ld a, $7f -.asm_253d0 - ld [hli], a - dec e - jr nz, .asm_253d0 - ld a, $23 - ld [hli], a - dec d - jr nz, .asm_253c9 - ld a, $23 - ld [hli], a - ld a, $24 - ld [hli], a - ld e, $11 - ld a, $7f -.asm_253e4 - ld [hli], a - dec e - jr nz, .asm_253e4 - ld a, $23 - ld [hli], a - ld e, $14 -.asm_253ed - ld a, $23 - ld [hli], a - dec e - jr nz, .asm_253ed - ret +OakRating04: + text_jump _OakRating04 + db "@" -Function253f4: ; 253f4 (9:53f4) - push de - push hl - ld [hli], a - inc a - ld [hli], a - inc a - ld [hli], a - inc a - ld [hli], a - inc a - ld de, $11 - add hl, de - ld [hli], a - inc a - ld [hli], a - inc a - ld [hli], a - inc a - ld de, $11 - add hl, de - ld [hli], a - inc a - ld [hli], a - inc a - ld [hli], a - inc a - pop hl - pop de - ret +OakRating05: + text_jump _OakRating05 + db "@" -Function25415: ; 25415 (9:5415) - hlcoord 11, 12 - ld de, GameTimeHours - lb bc, 2, 4 - call PrintNum - inc hl - ld de, GameTimeMinutes - lb bc, PRINTNUM_LEADINGZEROS | 1, 2 - call PrintNum - ld a, [hVBlankCounter] - and $1f - ret nz - hlcoord 15, 12 - ld a, [hl] - xor $51 - ld [hl], a - ret +OakRating06: + text_jump _OakRating06 + db "@" -Function25438: ; 25438 (9:5438) - ld a, [hVBlankCounter] - and $7 - ret nz - ld a, [wcf64] - inc a - and $7 - ld [wcf64], a - jr Function25448 +OakRating07: + text_jump _OakRating07 + db "@" -Function25448: ; 25448 (9:5448) - ld a, [hli] - ld e, a - ld a, [hli] - ld d, a - ld a, [de] - ld c, a - ld de, Sprites - ld b, 8 -.asm_25453 - srl c - push bc - jr nc, .asm_25472 - push hl - ld a, [hli] - ld b, a - ld a, [hli] - ld c, a - ld a, [hli] - ld [wcf66], a - ld a, [wcf64] - add l - ld l, a - ld a, 0 - adc h - ld h, a - ld a, [hl] - ld [wcf65], a - call Function2547b - pop hl -.asm_25472 - ld bc, $b - add hl, bc - pop bc - dec b - jr nz, .asm_25453 - ret +OakRating08: + text_jump _OakRating08 + db "@" -Function2547b: ; 2547b (9:547b) - ld a, [wcf65] - and $80 - jr nz, .asm_25487 - ld hl, Unknown_254a7 - jr .asm_2548a -.asm_25487 - ld hl, Unknown_254b8 -.asm_2548a - ld a, [hli] - cp $ff - ret z - add b - ld [de], a - inc de - ld a, [hli] - add c - ld [de], a - inc de - ld a, [wcf65] - and $7f - add [hl] - ld [de], a - inc hl - inc de - ld a, [wcf66] - add [hl] - ld [de], a - inc hl - inc de - jr .asm_2548a -; 254a7 (9:54a7) +OakRating09: + text_jump _OakRating09 + db "@" -Unknown_254a7: ; 254a7 - db $00, $00, $00, $00 - db $00, $08, $01, $00 - db $08, $00, $02, $00 - db $08, $08, $03, $00 - db $ff +OakRating10: + text_jump _OakRating10 + db "@" -Unknown_254b8: ; 254b8 - db $00, $00, $01, $20 - db $00, $08, $00, $20 - db $08, $00, $03, $20 - db $08, $08, $02, $20 - db $ff +OakRating11: + text_jump _OakRating11 + db "@" -Unknown_254c9: ; 254c9 -; Template OAM data for each badge on the trainer card. -; Format: - ; y, x, palette - ; cycle 1: face tile, in1 tile, in2 tile, in3 tile - ; cycle 2: face tile, in1 tile, in2 tile, in3 tile +OakRating12: + text_jump _OakRating12 + db "@" - dw JohtoBadges +OakRating13: + text_jump _OakRating13 + db "@" - ; Zephyrbadge - db $68, $18, $00 - db $00, $20, $24, $20 | $80 - db $00, $20, $24, $20 | $80 +OakRating14: + text_jump _OakRating14 + db "@" - ; Hivebadge - db $68, $38, $00 - db $04, $20, $24, $20 | $80 - db $04, $20, $24, $20 | $80 +OakRating15: + text_jump _OakRating15 + db "@" - ; Plainbadge - db $68, $58, $00 - db $08, $20, $24, $20 | $80 - db $08, $20, $24, $20 | $80 +OakRating16: + text_jump _OakRating16 + db "@" - ; Fogbadge - db $68, $78, $00 - db $0c, $20, $24, $20 | $80 - db $0c, $20, $24, $20 | $80 +OakRating17: + text_jump _OakRating17 + db "@" - ; Mineralbadge - db $80, $38, $00 - db $10, $20, $24, $20 | $80 - db $10, $20, $24, $20 | $80 - - ; Stormbadge - db $80, $18, $00 - db $14, $20, $24, $20 | $80 - db $14, $20, $24, $20 | $80 - - ; Glacierbadge - db $80, $58, $00 - db $18, $20, $24, $20 | $80 - db $18, $20, $24, $20 | $80 +OakRating18: + text_jump _OakRating18 + db "@" - ; Risingbadge - ; X-flips on alternate cycles. - db $80, $78, $00 - db $1c, $20, $24, $20 | $80 - db $1c | $80, $20, $24, $20 | $80 -; 25523 +OakRating19: + text_jump _OakRating19 + db "@" -CardStatusGFX: INCBIN "gfx/misc/card_status.2bpp" +OakPCText4: ; 0x2674c + text_jump _OakPCText4 + db "@" -LeaderGFX: INCBIN "gfx/misc/leaders.w24.2bpp" -LeaderGFX2: INCBIN "gfx/misc/leaders.w24.2bpp" -BadgeGFX: INCBIN "gfx/misc/badges.2bpp" -BadgeGFX2: INCBIN "gfx/misc/badges.2bpp" -CardRightCornerGFX: INCBIN "gfx/misc/card_right_corner.2bpp" +InitDecorations: ; 26751 (9:6751) + ld a, DECO_FEATHERY_BED + ld [Bed], a + ld a, DECO_TOWN_MAP + ld [Poster], a + ret +_KrisDecorationMenu: ; 0x2675c + ld a, [wcf76] + push af + ld hl, MenuDataHeader_0x2679a + call LoadMenuDataHeader + xor a + ld [wd1ee], a + ld a, $1 + ld [wd1ef], a +.asm_2676f + ld a, [wd1ef] + ld [wMenuCursorBuffer], a + call Function26806 + call DoNthMenu + ld a, [MenuSelection2] + ld [wd1ef], a + jr c, .asm_2678e + ld a, [MenuSelection] + ld hl, Unknown_267aa + call MenuJumptable + jr nc, .asm_2676f -ProfOaksPC: ; 0x265d3 - ld hl, OakPCText1 - call MenuTextBox - call YesNoBox - jr c, .shutdown - call ProfOaksPCBoot ; player chose "yes"? -.shutdown - ld hl, OakPCText4 - call PrintText - call JoyWaitAorB +.asm_2678e call ExitMenu + pop af + ld [wcf76], a + ld a, [wd1ee] + ld c, a ret -; 0x265ee +; 0x2679a -ProfOaksPCBoot ; 0x265ee - ld hl, OakPCText2 - call PrintText - call Rate - call PlaySFX ; sfx loaded by previous Rate function call - call JoyWaitAorB - call WaitSFX - ret -; 0x26601 +MenuDataHeader_0x2679a: ; 0x2679a + db $40 ; flags + db 00, 05 ; start coords + db 17, 19 ; end coords + dw MenuData2_0x267a2 + db 1 ; default option +; 0x267a2 -Function26601: ; 0x26601 - call Rate - push de - ld de, MUSIC_NONE - call PlayMusic - pop de - call PlaySFX - call JoyWaitAorB - call WaitSFX - ret -; 0x26616 +MenuData2_0x267a2: ; 0x267a2 + db $a0 ; flags + db 0 ; items + dw wd002 + dw PlaceNthMenuStrings + dw Unknown_267aa +; 0x267aa -Rate: ; 0x26616 -; calculate Seen/Owned - ld hl, PokedexSeen - ld b, EndPokedexSeen - PokedexSeen - call CountSetBits - ld [wd002], a - ld hl, PokedexCaught - ld b, EndPokedexCaught - PokedexCaught - call CountSetBits - ld [wd003], a +Unknown_267aa: ; 267aa + dw Function268b5, .bed + dw Function268ca, .carpet + dw Function268df, .plant + dw Function268f3, .poster + dw Function26908, .game + dw Function2691d, .ornament + dw Function26945, .big_doll + dw Function26959, .exit -; print appropriate rating - call ClearOakRatingBuffers - ld hl, OakPCText3 - call PrintText - call JoyWaitAorB - ld a, [wd003] - ld hl, OakRatings - call FindOakRating - push de - call PrintText - pop de - ret -; 0x26647 +.bed db "BED@" +.carpet db "CARPET@" +.plant db "PLANT@" +.poster db "POSTER@" +.game db "GAME CONSOLE@" +.ornament db "ORNAMENT@" +.big_doll db "BIG DOLL@" +.exit db "EXIT@" +; 26806 -ClearOakRatingBuffers: ; 0x26647 - ld hl, StringBuffer3 +Function26806: ; 26806 + xor a + ld [wcf76], a + call Function26822 + call Function2683a + ld a, $7 + call Function26830 + ld hl, StringBuffer2 ld de, wd002 - call ClearOakRatingBuffer - ld hl, StringBuffer4 - ld de, wd003 - call ClearOakRatingBuffer + ld bc, $d + call CopyBytes ret -; 0x2665a -ClearOakRatingBuffer: ; 0x2665a - push hl - ld a, "@" - ld bc, ITEM_NAME_LENGTH +Function26822: ; 26822 (9:6822) + ld hl, StringBuffer2 + xor a + ld [hli], a + ld bc, ITEM_NAME_LENGTH - 1 + ld a, -1 call ByteFill - pop hl - lb bc, PRINTNUM_RIGHTALIGN | 1, 3 - call PrintNum ret -; 0x2666b -FindOakRating: ; 0x2666b -; return sound effect in de -; return text pointer in hl - nop - ld c, a -.loop - ld a, [hli] - cp c - jr nc, .match -rept 4 - inc hl -endr - jr .loop +Function26830: ; 26830 (9:6830) + ld hl, StringBuffer2 + inc [hl] + ld e, [hl] + ld d, 0 + add hl, de + ld [hl], a + ret -.match +Function2683a: ; 2683a (9:683a) + ld hl, Jumptable_26855 +.loop ld a, [hli] ld e, a ld a, [hli] ld d, a - ld a, [hli] - ld h, [hl] - ld l, a + or e + jr z, .done + push hl + call _de_ + pop hl + jr nc, .next + ld a, [hl] + push hl + call Function26830 + pop hl +.next + inc hl + jr .loop +.done ret -; 0x2667f - -OakRatings: ; 0x2667f -; db count (if number caught ≤ this number, then this entry is used) -; dw sound effect -; dw text pointer +; 26855 (9:6855) - db 9 - dw SFX_DEX_FANFARE_LESS_THAN_20 - dw OakRating01 +Jumptable_26855: ; 26855 + dwb Function268bd, 0 ; bed + dwb Function268d2, 1 ; carpet + dwb Function268e7, 2 ; plant + dwb Function268fb, 3 ; poster + dwb Function26910, 4 ; game console + dwb Function26925, 5 ; ornament + dwb Function2694d, 6 ; big doll + dw 0 ; end +; 2686c - db 19 - dw SFX_DEX_FANFARE_LESS_THAN_20 - dw OakRating02 +Function2686c: ; 2686c + xor a + ld hl, wd002 + ld [hli], a + ld a, -1 + ld bc, $10 + call ByteFill + ret +; 2687a - db 34 - dw SFX_DEX_FANFARE_20_49 - dw OakRating03 - - db 49 - dw SFX_DEX_FANFARE_20_49 - dw OakRating04 - - db 64 - dw SFX_DEX_FANFARE_50_79 - dw OakRating05 +CheckAllDecorationFlags: ; 2687a +.loop + ld a, [hli] + cp -1 + jr z, .done + push hl + push af + ld b, CHECK_FLAG + call DecorationFlagAction + ld a, c + and a + pop bc + ld a, b + call nz, Function26891 + pop hl + jr .loop - db 79 - dw SFX_DEX_FANFARE_50_79 - dw OakRating06 +.done + ret +; 26891 - db 94 - dw SFX_DEX_FANFARE_80_109 - dw OakRating07 +Function26891: ; 26891 + ld hl, wd002 + inc [hl] + ld e, [hl] + ld d, $0 + add hl, de + ld [hl], a + ret +; 2689b - db 109 - dw SFX_DEX_FANFARE_80_109 - dw OakRating08 +Function2689b: ; 2689b + push bc + push hl + call Function2686c + pop hl + call CheckAllDecorationFlags + pop bc + ld a, [wd002] + and a + ret z + ld a, c + call Function26891 + ld a, $0 + call Function26891 + scf + ret +; 268b5 - db 124 - dw SFX_CAUGHT_MON - dw OakRating09 +Function268b5: ; 268b5 + call Function268bd + call Function2695b + xor a + ret +; 268bd - db 139 - dw SFX_CAUGHT_MON - dw OakRating10 +Function268bd: ; 268bd + ld hl, Unknown_268c5 + ld c, 1 + jp Function2689b +; 268c5 - db 154 - dw SFX_DEX_FANFARE_140_169 - dw OakRating11 +Unknown_268c5: ; 268c5 + db 2, 3, 4, 5, $ff +; 268ca - db 169 - dw SFX_DEX_FANFARE_140_169 - dw OakRating12 +Function268ca: ; 268ca + call Function268d2 + call Function2695b + xor a + ret +; 268d2 - db 184 - dw SFX_DEX_FANFARE_170_199 - dw OakRating13 +Function268d2: ; 268d2 + ld hl, Unknown_268da + ld c, 6 + jp Function2689b +; 268da - db 199 - dw SFX_DEX_FANFARE_170_199 - dw OakRating14 +Unknown_268da: ; 268da + db 7, 8, 9, 10, $ff +; 268df - db 214 - dw SFX_DEX_FANFARE_200_229 - dw OakRating15 +Function268df: ; 268df + call Function268e7 + call Function2695b + xor a + ret +; 268e7 - db 229 - dw SFX_DEX_FANFARE_200_229 - dw OakRating16 +Function268e7: ; 268e7 + ld hl, Unknown_268ef + ld c, 11 + jp Function2689b +; 268ef - db 239 - dw SFX_DEX_FANFARE_230_PLUS - dw OakRating17 +Unknown_268ef: ; 268ef + db 12, 13, 14, $ff +; 268f3 - db 248 - dw SFX_DEX_FANFARE_230_PLUS - dw OakRating18 +Function268f3: ; 268f3 + call Function268fb + call Function2695b + xor a + ret +; 268fb - db 255 - dw SFX_DEX_FANFARE_230_PLUS - dw OakRating19 +Function268fb: ; 268fb + ld hl, Unknown_26903 + ld c, 15 + jp Function2689b +; 26903 -OakPCText1: ; 0x266de - text_jump _OakPCText1 - db "@" +Unknown_26903: ; 26903 + db 16, 17, 18, 19, $ff +; 26908 -OakPCText2: ; 0x266e3 - text_jump _OakPCText2 - db "@" +Function26908: ; 26908 + call Function26910 + call Function2695b + xor a + ret +; 26910 -OakPCText3: ; 0x266e8 - text_jump _OakPCText3 - db "@" +Function26910: ; 26910 + ld hl, Unknown_26918 + ld c, 20 + jp Function2689b +; 26918 -OakRating01: - text_jump _OakRating01 - db "@" +Unknown_26918: ; 26918 + db 21, 22, 23, 24, $ff +; 2691d -OakRating02: - text_jump _OakRating02 - db "@" +Function2691d: ; 2691d + call Function26925 + call Function2695b + xor a + ret +; 26925 -OakRating03: - text_jump _OakRating03 - db "@" +Function26925: ; 26925 + ld hl, Unknown_2692d + ld c, 29 + jp Function2689b +; 2692d -OakRating04: - text_jump _OakRating04 - db "@" +Unknown_2692d: ; 2692d + db 30, 31, 32, 33, 34, 35, 36, 37, 38, 39 + db 40, 41, 42, 43, 44, 45, 46, 47, 48, 49 + db 50, 51, 52, -1 +; 26945 -OakRating05: - text_jump _OakRating05 - db "@" +Function26945: ; 26945 + call Function2694d + call Function2695b + xor a + ret +; 2694d -OakRating06: - text_jump _OakRating06 - db "@" +Function2694d: ; 2694d + ld hl, Unknown_26955 + ld c, 25 + jp Function2689b +; 26955 -OakRating07: - text_jump _OakRating07 - db "@" +Unknown_26955: ; 26955 + db 26, 27, 28, -1 +; 26959 -OakRating08: - text_jump _OakRating08 - db "@" +Function26959: ; 26959 + scf + ret +; 2695b -OakRating09: - text_jump _OakRating09 - db "@" +Function2695b: ; 2695b + ld a, [wd002] + and a + jr z, .empty + cp 8 + jr nc, .beyond_eight + xor a + ld [wcf76], a + ld hl, MenuDataHeader_0x269b5 + call LoadMenuDataHeader + call DoNthMenu + jr c, .no_action_1 + call DoDecorationAction2 -OakRating10: - text_jump _OakRating10 - db "@" +.no_action_1 + call ExitMenu + ret -OakRating11: - text_jump _OakRating11 - db "@" - -OakRating12: - text_jump _OakRating12 - db "@" - -OakRating13: - text_jump _OakRating13 - db "@" - -OakRating14: - text_jump _OakRating14 - db "@" - -OakRating15: - text_jump _OakRating15 - db "@" - -OakRating16: - text_jump _OakRating16 - db "@" - -OakRating17: - text_jump _OakRating17 - db "@" - -OakRating18: - text_jump _OakRating18 - db "@" - -OakRating19: - text_jump _OakRating19 - db "@" - -OakPCText4: ; 0x2674c - text_jump _OakPCText4 - db "@" - - -InitDecorations: ; 26751 (9:6751) - ld a, DECO_FEATHERY_BED - ld [Bed], a - ld a, DECO_TOWN_MAP - ld [Poster], a - ret - -_KrisDecorationMenu: ; 0x2675c - ld a, [wcf76] - push af - ld hl, MenuDataHeader_0x2679a - call LoadMenuDataHeader +.beyond_eight + ld hl, wd002 + ld e, [hl] + dec [hl] + ld d, 0 + add hl, de + ld [hl], -1 + call LoadStandardMenuDataHeader + ld hl, MenuDataHeader_0x269c5 + call CopyMenuDataHeader xor a - ld [wd1ee], a - ld a, $1 - ld [wd1ef], a -.asm_2676f - ld a, [wd1ef] - ld [wMenuCursorBuffer], a - call Function26806 - call Function1e5d - ld a, [MenuSelection2] - ld [wd1ef], a - jr c, .asm_2678e - ld a, [MenuSelection] - ld hl, Unknown_267aa - call Function1fa7 - jr nc, .asm_2676f + ld [hBGMapMode], a + call Function352f + xor a + ld [wd0e4], a + call HandleScrollingMenu + ld a, [wcf73] + cp 2 + jr z, .no_action_2 + call DoDecorationAction2 -.asm_2678e +.no_action_2 call ExitMenu - pop af - ld [wcf76], a - ld a, [wd1ee] - ld c, a ret -; 0x2679a -MenuDataHeader_0x2679a: ; 0x2679a +.empty + ld hl, UnknownText_0x269b0 + call MenuTextBoxBackup + ret +; 269b0 + +UnknownText_0x269b0: ; 0x269b0 + ; There's nothing to choose. + text_jump UnknownText_0x1bc471 + db "@" +; 0x269b5 + +MenuDataHeader_0x269b5: ; 0x269b5 db $40 ; flags - db 00, 05 ; start coords + db 00, 00 ; start coords db 17, 19 ; end coords - dw MenuData2_0x267a2 + dw MenuData2_0x269bd db 1 ; default option -; 0x267a2 +; 0x269bd -MenuData2_0x267a2: ; 0x267a2 +MenuData2_0x269bd: ; 0x269bd db $a0 ; flags db 0 ; items dw wd002 - dw Function1f8d - dw Unknown_267aa -; 0x267aa + dw DecorationMenuFunction + dw DecorationAttributes +; 0x269c5 -Unknown_267aa: ; 267aa - dw Function268b5, .bed - dw Function268ca, .carpet - dw Function268df, .plant - dw Function268f3, .poster - dw Function26908, .game - dw Function2691d, .ornament - dw Function26945, .big_doll - dw Function26959, .exit +MenuDataHeader_0x269c5: ; 0x269c5 + db $40 ; flags + db 01, 01 ; start coords + db 16, 18 ; end coords + dw MenuData2_0x269cd + db 1 ; default option +; 0x269cd -.bed db "BED@" -.carpet db "CARPET@" -.plant db "PLANT@" -.poster db "POSTER@" -.game db "GAME CONSOLE@" -.ornament db "ORNAMENT@" -.big_doll db "BIG DOLL@" -.exit db "EXIT@" -; 26806 +MenuData2_0x269cd: ; 0x269cd + db $10 ; flags + db 8, 0 ; rows, columns + db 1 ; horizontal spacing + dbw 0, wd002 ; text pointer + dba DecorationMenuFunction + dbw 0, 0 + dbw 0, 0 +; 269dd -Function26806: ; 26806 - xor a - ld [wcf76], a - call Function26822 - call Function2683a - ld a, $7 - call Function26830 - ld hl, StringBuffer2 - ld de, wd002 - ld bc, $d - call CopyBytes + +GetDecorationData: ; 269dd + ld hl, DecorationAttributes + ld bc, 6 + call AddNTimes ret +; 269e7 -Function26822: ; 26822 (9:6822) - ld hl, StringBuffer2 - xor a - ld [hli], a - ld bc, ITEM_NAME_LENGTH - 1 - ld a, -1 - call ByteFill +GetDecorationName: ; 269e7 + push hl + call GetDecorationData + call GetDecoName + pop hl + call CopyName2 ret +; 269f3 -Function26830: ; 26830 (9:6830) - ld hl, StringBuffer2 - inc [hl] - ld e, [hl] - ld d, 0 +DecorationMenuFunction: ; 269f3 + ld a, [MenuSelection] + push de + call GetDecorationData + call GetDecoName + pop hl + call PlaceString + ret +; 26a02 + +DoDecorationAction2: ; 26a02 + ld a, [MenuSelection] + call GetDecorationData + ld de, 2 ; function 2 add hl, de - ld [hl], a + ld a, [hl] + ld hl, .DecoActions + rst JumpTable ret +; 26a12 -Function2683a: ; 2683a (9:683a) - ld hl, Jumptable_26855 -.loop +.DecoActions: ; 26a12 + dw DecoAction_nothing + dw DecoAction_setupbed + dw DecoAction_putawaybed + dw DecoAction_setupcarpet + dw DecoAction_putawaycarpet + dw DecoAction_setupplant + dw DecoAction_putawayplant + dw DecoAction_setupposter + dw DecoAction_putawayposter + dw DecoAction_setupconsole + dw DecoAction_putawayconsole + dw DecoAction_setupbigdoll + dw DecoAction_putawaybigdoll + dw DecoAction_setupornament + dw DecoAction_putawayornament +; 26a30 + + +GetDecorationFlag: ; 26a30 + call GetDecorationData + ld de, 3 ; event flag + add hl, de ld a, [hli] + ld d, [hl] ld e, a - ld a, [hli] - ld d, a - or e - jr z, .done - push hl - call _de_ - pop hl - jr nc, .next - ld a, [hl] - push hl - call Function26830 - pop hl -.next - inc hl - jr .loop -.done ret -; 26855 (9:6855) +; 26a3b -Jumptable_26855: ; 26855 - dwb Function268bd, 0 ; bed - dwb Function268d2, 1 ; carpet - dwb Function268e7, 2 ; plant - dwb Function268fb, 3 ; poster - dwb Function26910, 4 ; game console - dwb Function26925, 5 ; ornament - dwb Function2694d, 6 ; big doll - dw 0 ; end -; 2686c - -Function2686c: ; 2686c - xor a - ld hl, wd002 - ld [hli], a - ld a, -1 - ld bc, $10 - call ByteFill - ret -; 2687a - -CheckAllDecorationFlags: ; 2687a -.loop - ld a, [hli] - cp -1 - jr z, .done - push hl - push af - ld b, CHECK_FLAG - call DecorationFlagAction - ld a, c - and a +DecorationFlagAction: ; 26a3b + push bc + call GetDecorationFlag pop bc - ld a, b - call nz, Function26891 - pop hl - jr .loop - -.done + call EventFlagAction ret -; 26891 +; 26a44 -Function26891: ; 26891 - ld hl, wd002 - inc [hl] - ld e, [hl] - ld d, $0 +GetDecorationSprite: ; 26a44 + ld a, c + call GetDecorationData + ld de, 5 ; sprite add hl, de - ld [hl], a + ld a, [hl] + ld c, a ret -; 2689b +; 26a4f -Function2689b: ; 2689b - push bc - push hl - call Function2686c - pop hl - call CheckAllDecorationFlags - pop bc - ld a, [wd002] - and a - ret z - ld a, c - call Function26891 - ld a, $0 - call Function26891 - scf - ret -; 268b5 +decoration: MACRO + ; type, name, command, event flag, tile/sprite + db \1, \2, \3 + dw \4 + db \5 +ENDM -Function268b5: ; 268b5 - call Function268bd - call Function2695b - xor a - ret -; 268bd +DecorationAttributes: ; 26a4f + decoration DECO_PLANT, $00, $0, EVENT_GAVE_KURT_APRICORNS, $00 + decoration DECO_PLANT, PUT_IT_AWAY, PUT_AWAY_BED, EVENT_GAVE_KURT_APRICORNS, $00 + decoration DECO_BED, FEATHERY_BED, SET_UP_BED, EVENT_DECO_BED_1, $1b + decoration DECO_BED, PINK_BED, SET_UP_BED, EVENT_DECO_BED_2, $1c + decoration DECO_BED, POLKADOT_BED, SET_UP_BED, EVENT_DECO_BED_3, $1d + decoration DECO_BED, PIKACHU_BED, SET_UP_BED, EVENT_DECO_BED_4, $1e + decoration DECO_PLANT, PUT_IT_AWAY, PUT_AWAY_CARPET, EVENT_GAVE_KURT_APRICORNS, $00 + decoration DECO_CARPET, RED_CARPET, SET_UP_CARPET, EVENT_DECO_CARPET_1, $08 + decoration DECO_CARPET, BLUE_CARPET, SET_UP_CARPET, EVENT_DECO_CARPET_2, $0b + decoration DECO_CARPET, YELLOW_CARPET, SET_UP_CARPET, EVENT_DECO_CARPET_3, $0e + decoration DECO_CARPET, GREEN_CARPET, SET_UP_CARPET, EVENT_DECO_CARPET_4, $11 + decoration DECO_PLANT, PUT_IT_AWAY, PUT_AWAY_PLANT, EVENT_GAVE_KURT_APRICORNS, $00 + decoration DECO_PLANT, MAGNAPLANT, SET_UP_PLANT, EVENT_DECO_PLANT_1, $20 + decoration DECO_PLANT, TROPICPLANT, SET_UP_PLANT, EVENT_DECO_PLANT_2, $21 + decoration DECO_PLANT, JUMBOPLANT, SET_UP_PLANT, EVENT_DECO_PLANT_3, $22 + decoration DECO_PLANT, PUT_IT_AWAY, PUT_AWAY_POSTER, EVENT_GAVE_KURT_APRICORNS, $00 + decoration DECO_PLANT, TOWN_MAP_D, SET_UP_POSTER, EVENT_DECO_PLANT_4, $1f + decoration DECO_POSTER, PIKACHU, SET_UP_POSTER, EVENT_DECO_POSTER_1, $23 + decoration DECO_POSTER, CLEFAIRY, SET_UP_POSTER, EVENT_DECO_POSTER_2, $24 + decoration DECO_POSTER, JIGGLYPUFF, SET_UP_POSTER, EVENT_DECO_POSTER_3, $25 + decoration DECO_PLANT, PUT_IT_AWAY, PUT_AWAY_CONSOLE, EVENT_GAVE_KURT_APRICORNS, $00 + decoration DECO_PLANT, FAMICOM, SET_UP_CONSOLE, EVENT_DECO_FAMICOM, SPRITE_FAMICOM + decoration DECO_PLANT, SUPER_NES, SET_UP_CONSOLE, EVENT_DECO_SNES, SPRITE_SNES + decoration DECO_PLANT, NINTENDO_64, SET_UP_CONSOLE, EVENT_DECO_N64, SPRITE_N64 + decoration DECO_PLANT, VIRTUAL_BOY, SET_UP_CONSOLE, EVENT_DECO_VIRTUAL_BOY, SPRITE_VIRTUAL_BOY + decoration DECO_PLANT, PUT_IT_AWAY, PUT_AWAY_BIG_DOLL, EVENT_GAVE_KURT_APRICORNS, $00 + decoration DECO_BIGDOLL, SNORLAX, SET_UP_BIG_DOLL, EVENT_DECO_BIG_SNORLAX_DOLL, SPRITE_BIG_SNORLAX + decoration DECO_BIGDOLL, ONIX, SET_UP_BIG_DOLL, EVENT_DECO_BIG_ONIX_DOLL, SPRITE_BIG_ONIX + decoration DECO_BIGDOLL, LAPRAS, SET_UP_BIG_DOLL, EVENT_DECO_BIG_LAPRAS_DOLL, SPRITE_BIG_LAPRAS + decoration DECO_PLANT, PUT_IT_AWAY, PUT_AWAY_DOLL, EVENT_GAVE_KURT_APRICORNS, $00 + decoration DECO_DOLL, PIKACHU, SET_UP_DOLL, EVENT_DECO_PIKACHU_DOLL, SPRITE_PIKACHU + decoration DECO_PLANT, SURF_PIKA_DOLL, SET_UP_DOLL, EVENT_DECO_SURFING_PIKACHU_DOLL, SPRITE_SURFING_PIKACHU + decoration DECO_DOLL, CLEFAIRY, SET_UP_DOLL, EVENT_DECO_CLEFAIRY_DOLL, SPRITE_CLEFAIRY + decoration DECO_DOLL, JIGGLYPUFF, SET_UP_DOLL, EVENT_DECO_JIGGLYPUFF_DOLL, SPRITE_JIGGLYPUFF + decoration DECO_DOLL, BULBASAUR, SET_UP_DOLL, EVENT_DECO_BULBASAUR_DOLL, SPRITE_BULBASAUR + decoration DECO_DOLL, CHARMANDER, SET_UP_DOLL, EVENT_DECO_CHARMANDER_DOLL, SPRITE_CHARMANDER + decoration DECO_DOLL, SQUIRTLE, SET_UP_DOLL, EVENT_DECO_SQUIRTLE_DOLL, SPRITE_SQUIRTLE + decoration DECO_DOLL, POLIWAG, SET_UP_DOLL, EVENT_DECO_POLIWAG_DOLL, SPRITE_POLIWAG + decoration DECO_DOLL, DIGLETT, SET_UP_DOLL, EVENT_DECO_DIGLETT_DOLL, SPRITE_DIGLETT + decoration DECO_DOLL, STARYU, SET_UP_DOLL, EVENT_DECO_STARMIE_DOLL, SPRITE_STARMIE + decoration DECO_DOLL, MAGIKARP, SET_UP_DOLL, EVENT_DECO_MAGIKARP_DOLL, SPRITE_MAGIKARP + decoration DECO_DOLL, ODDISH, SET_UP_DOLL, EVENT_DECO_ODDISH_DOLL, SPRITE_ODDISH + decoration DECO_DOLL, GENGAR, SET_UP_DOLL, EVENT_DECO_GENGAR_DOLL, SPRITE_GENGAR + decoration DECO_DOLL, SHELLDER, SET_UP_DOLL, EVENT_DECO_SHELLDER_DOLL, SPRITE_SHELLDER + decoration DECO_DOLL, GRIMER, SET_UP_DOLL, EVENT_DECO_GRIMER_DOLL, SPRITE_GRIMER + decoration DECO_DOLL, VOLTORB, SET_UP_DOLL, EVENT_DECO_VOLTORB_DOLL, SPRITE_VOLTORB + decoration DECO_DOLL, WEEDLE, SET_UP_DOLL, EVENT_DECO_WEEDLE_DOLL, SPRITE_WEEDLE + decoration DECO_DOLL, UNOWN, SET_UP_DOLL, EVENT_DECO_UNOWN_DOLL, SPRITE_UNOWN + decoration DECO_DOLL, GEODUDE, SET_UP_DOLL, EVENT_DECO_GEODUDE_DOLL, SPRITE_GEODUDE + decoration DECO_DOLL, MACHOP, SET_UP_DOLL, EVENT_DECO_MACHOP_DOLL, SPRITE_MACHOP + decoration DECO_DOLL, TENTACOOL, SET_UP_DOLL, EVENT_DECO_TENTACOOL_DOLL, SPRITE_TENTACOOL + decoration DECO_PLANT, GOLD_TROPHY, SET_UP_DOLL, EVENT_DECO_GOLD_TROPHY, SPRITE_GOLD_TROPHY + decoration DECO_PLANT, SILVER_TROPHY, SET_UP_DOLL, EVENT_DECO_SILVER_TROPHY, SPRITE_SILVER_TROPHY +; 26b8d -Function268bd: ; 268bd - ld hl, Unknown_268c5 - ld c, 1 - jp Function2689b -; 268c5 -Unknown_268c5: ; 268c5 - db 2, 3, 4, 5, $ff -; 268ca +DecorationNames: ; 26b8d + db "CANCEL@" + db "PUT IT AWAY@" + db "MAGNAPLANT@" + db "TROPICPLANT@" + db "JUMBOPLANT@" + db "TOWN MAP@" + db "NES@" + db "SUPER NES@" + db "NINTENDO 64@" + db "VIRTUAL BOY@" + db "GOLD TROPHY@" + db "SILVER TROPHY@" + db "SURF PIKACHU DOLL@" + db " BED@" + db " CARPET@" + db " POSTER@" + db " DOLL@" + db "BIG @" + db "FEATHERY@" + db "PIKACHU@" + db "PINK@" + db "POLKADOT@" + db "RED@" + db "BLUE@" + db "YELLOW@" + db "GREEN@" +; 26c72 -Function268ca: ; 268ca - call Function268d2 - call Function2695b - xor a +GetDecoName: ; 26c72 + ld a, [hli] + ld e, [hl] + ld bc, StringBuffer2 + push bc + ld hl, .NameFunctions + rst JumpTable + pop de ret -; 268d2 +; 26c7e -Function268d2: ; 268d2 - ld hl, Unknown_268da - ld c, 6 - jp Function2689b -; 268da +.NameFunctions: ; 26c7e + dw .invalid + dw .plant + dw .bed + dw .carpet + dw .poster + dw .doll + dw .bigdoll +; 26c8c -Unknown_268da: ; 268da - db 7, 8, 9, 10, $ff -; 268df -Function268df: ; 268df - call Function268e7 - call Function2695b - xor a +.invalid: ; 26c8c ret -; 268e7 +; 26c8d -Function268e7: ; 268e7 - ld hl, Unknown_268ef - ld c, 11 - jp Function2689b -; 268ef +.plant: ; 26c8d + ld a, e + jr .getdeconame -Unknown_268ef: ; 268ef - db 12, 13, 14, $ff -; 268f3 +.bed: ; 26c90 + call .plant + ld a, _BED + jr .getdeconame -Function268f3: ; 268f3 - call Function268fb - call Function2695b - xor a - ret -; 268fb +.carpet: ; 26c97 + call .plant + ld a, _CARPET + jr .getdeconame -Function268fb: ; 268fb - ld hl, Unknown_26903 - ld c, 15 - jp Function2689b -; 26903 +.poster: ; 26c9e + ld a, e + call .getpokename + ld a, _POSTER + jr .getdeconame -Unknown_26903: ; 26903 - db 16, 17, 18, 19, $ff -; 26908 +.doll: ; 26ca6 + ld a, e + call .getpokename + ld a, _DOLL + jr .getdeconame -Function26908: ; 26908 - call Function26910 - call Function2695b - xor a - ret -; 26910 - -Function26910: ; 26910 - ld hl, Unknown_26918 - ld c, 20 - jp Function2689b -; 26918 - -Unknown_26918: ; 26918 - db 21, 22, 23, 24, $ff -; 2691d +.bigdoll: ; 26cae + push de + ld a, BIG_ + call .getdeconame + pop de + ld a, e + jr .getpokename -Function2691d: ; 2691d - call Function26925 - call Function2695b - xor a - ret -; 26925 +.unused: ; 26cb8 + push de + call .getdeconame + pop de + ld a, e + jr .getdeconame -Function26925: ; 26925 - ld hl, Unknown_2692d - ld c, 29 - jp Function2689b -; 2692d +.getpokename: ; 26cc0 + push bc + ld [wd265], a + call GetPokemonName + pop bc + jr .copy -Unknown_2692d: ; 2692d - db 30, 31, 32, 33, 34, 35, 36, 37, 38, 39 - db 40, 41, 42, 43, 44, 45, 46, 47, 48, 49 - db 50, 51, 52, -1 -; 26945 +.getdeconame: ; 26cca + call ._getdeconame + jr .copy -Function26945: ; 26945 - call Function2694d - call Function2695b - xor a +._getdeconame: ; 26ccf + push bc + ld hl, DecorationNames + call GetNthString + ld d, h + ld e, l + pop bc ret -; 2694d - -Function2694d: ; 2694d - ld hl, Unknown_26955 - ld c, 25 - jp Function2689b -; 26955 -Unknown_26955: ; 26955 - db 26, 27, 28, -1 -; 26959 +.copy: ; 26cda + ld h, b + ld l, c + call CopyName2 + dec hl + ld b, h + ld c, l + ret +; 26ce3 -Function26959: ; 26959 +DecoAction_nothing: ; 26ce3 scf ret -; 2695b +; 26ce5 -Function2695b: ; 2695b - ld a, [wd002] - and a - jr z, .empty - cp 8 - jr nc, .beyond_eight - xor a - ld [wcf76], a - ld hl, MenuDataHeader_0x269b5 - call LoadMenuDataHeader - call Function1e5d - jr c, .no_action_1 - call DoDecorationAction2 +DecoAction_setupbed: ; 26ce5 + ld hl, Bed + jp DecoAction_TrySetItUp +; 26ceb -.no_action_1 - call ExitMenu - ret +DecoAction_putawaybed: ; 26ceb + ld hl, Bed + jp DecoAction_TryPutItAway +; 26cf1 -.beyond_eight - ld hl, wd002 - ld e, [hl] - dec [hl] - ld d, 0 - add hl, de - ld [hl], -1 - call LoadStandardMenuDataHeader - ld hl, MenuDataHeader_0x269c5 - call CopyMenuDataHeader - xor a - ld [hBGMapMode], a - call Function352f - xor a - ld [wd0e4], a - call HandleScrollingMenu - ld a, [wcf73] - cp 2 - jr z, .no_action_2 - call DoDecorationAction2 +DecoAction_setupcarpet: ; 26cf1 + ld hl, Carpet + jp DecoAction_TrySetItUp +; 26cf7 -.no_action_2 - call ExitMenu - ret +DecoAction_putawaycarpet: ; 26cf7 + ld hl, Carpet + jp DecoAction_TryPutItAway +; 26cfd -.empty - ld hl, UnknownText_0x269b0 - call MenuTextBoxBackup - ret -; 269b0 +DecoAction_setupplant: ; 26cfd + ld hl, Plant + jp DecoAction_TrySetItUp +; 26d03 -UnknownText_0x269b0: ; 0x269b0 - ; There's nothing to choose. - text_jump UnknownText_0x1bc471 - db "@" -; 0x269b5 +DecoAction_putawayplant: ; 26d03 + ld hl, Plant + jp DecoAction_TryPutItAway +; 26d09 -MenuDataHeader_0x269b5: ; 0x269b5 - db $40 ; flags - db 00, 00 ; start coords - db 17, 19 ; end coords - dw MenuData2_0x269bd - db 1 ; default option -; 0x269bd +DecoAction_setupposter: ; 26d09 + ld hl, Poster + jp DecoAction_TrySetItUp +; 26d0f -MenuData2_0x269bd: ; 0x269bd - db $a0 ; flags - db 0 ; items - dw wd002 - dw DecorationMenuFunction - dw DecorationAttributes -; 0x269c5 +DecoAction_putawayposter: ; 26d0f + ld hl, Poster + jp DecoAction_TryPutItAway +; 26d15 -MenuDataHeader_0x269c5: ; 0x269c5 - db $40 ; flags - db 01, 01 ; start coords - db 16, 18 ; end coords - dw MenuData2_0x269cd - db 1 ; default option -; 0x269cd +DecoAction_setupconsole: ; 26d15 + ld hl, Console + jp DecoAction_TrySetItUp +; 26d1b -MenuData2_0x269cd: ; 0x269cd - db $10 ; flags - db 8, 0 ; rows, columns - db 1 ; horizontal spacing - dbw 0, wd002 ; text pointer - dba DecorationMenuFunction - dbw 0, 0 - dbw 0, 0 -; 269dd +DecoAction_putawayconsole: ; 26d1b + ld hl, Console + jp DecoAction_TryPutItAway +; 26d21 +DecoAction_setupbigdoll: ; 26d21 + ld hl, BigDoll + jp DecoAction_TrySetItUp +; 26d27 -GetDecorationData: ; 269dd - ld hl, DecorationAttributes - ld bc, 6 - call AddNTimes - ret -; 269e7 +DecoAction_putawaybigdoll: ; 26d27 + ld hl, BigDoll + jp DecoAction_TryPutItAway +; 26d2d -GetDecorationName: ; 269e7 +DecoAction_TrySetItUp: ; 26d2d + ld a, [hl] + ld [Buffer1], a push hl - call GetDecorationData - call GetDecoName + call DecoAction_SetItUp + jr c, .failed + ld a, 1 + ld [wd1ee], a pop hl - call CopyName2 + ld a, [MenuSelection] + ld [hl], a + xor a ret -; 269f3 -DecorationMenuFunction: ; 269f3 - ld a, [MenuSelection] - push de - call GetDecorationData - call GetDecoName +.failed pop hl - call PlaceString + xor a ret -; 26a02 +; 26d46 -DoDecorationAction2: ; 26a02 +DecoAction_SetItUp: ; 26d46 +; See if there's anything of the same type already out + ld a, [Buffer1] + and a + jr z, .nothingthere +; See if that item is already out + ld b, a ld a, [MenuSelection] - call GetDecorationData - ld de, 2 ; function 2 - add hl, de - ld a, [hl] - ld hl, .DecoActions - rst JumpTable + cp b + jr z, .alreadythere +; Put away the item that's already out, and set up the new one + ld a, [MenuSelection] + ld hl, StringBuffer4 + call GetDecorationName + ld a, [Buffer1] + ld hl, StringBuffer3 + call GetDecorationName + ld hl, UnknownText_0x26ee0 + call MenuTextBoxBackup + xor a ret -; 26a12 - -.DecoActions: ; 26a12 - dw DecoAction_nothing - dw DecoAction_setupbed - dw DecoAction_putawaybed - dw DecoAction_setupcarpet - dw DecoAction_putawaycarpet - dw DecoAction_setupplant - dw DecoAction_putawayplant - dw DecoAction_setupposter - dw DecoAction_putawayposter - dw DecoAction_setupconsole - dw DecoAction_putawayconsole - dw DecoAction_setupbigdoll - dw DecoAction_putawaybigdoll - dw DecoAction_setupornament - dw DecoAction_putawayornament -; 26a30 - -GetDecorationFlag: ; 26a30 - call GetDecorationData - ld de, 3 ; event flag - add hl, de - ld a, [hli] - ld d, [hl] - ld e, a +.nothingthere + ld a, [MenuSelection] + ld hl, StringBuffer3 + call GetDecorationName + ld hl, UnknownText_0x26edb + call MenuTextBoxBackup + xor a ret -; 26a3b -DecorationFlagAction: ; 26a3b - push bc - call GetDecorationFlag - pop bc - call EventFlagAction +.alreadythere + ld hl, UnknownText_0x26ee5 + call MenuTextBoxBackup + scf ret -; 26a44 +; 26d86 -GetDecorationSprite: ; 26a44 - ld a, c - call GetDecorationData - ld de, 5 ; sprite - add hl, de +DecoAction_TryPutItAway: ; 26d86 +; If there is no item of that type already set, there is nothing to put away. ld a, [hl] - ld c, a + ld [Buffer1], a + xor a + ld [hl], a + ld a, [Buffer1] + and a + jr z, .nothingthere +; Put it away. + ld a, $1 + ld [wd1ee], a + ld a, [Buffer1] + ld [MenuSelection], a + ld hl, StringBuffer3 + call GetDecorationName + ld hl, UnknownText_0x26ed1 + call MenuTextBoxBackup + xor a ret -; 26a4f - -decoration: MACRO - ; type, name, command, event flag, tile/sprite - db \1, \2, \3 - dw \4 - db \5 -ENDM - -DecorationAttributes: ; 26a4f - decoration DECO_PLANT, $00, $0, EVENT_GAVE_KURT_APRICORNS, $00 - decoration DECO_PLANT, PUT_IT_AWAY, PUT_AWAY_BED, EVENT_GAVE_KURT_APRICORNS, $00 - decoration DECO_BED, FEATHERY_BED, SET_UP_BED, EVENT_DECO_BED_1, $1b - decoration DECO_BED, PINK_BED, SET_UP_BED, EVENT_DECO_BED_2, $1c - decoration DECO_BED, POLKADOT_BED, SET_UP_BED, EVENT_DECO_BED_3, $1d - decoration DECO_BED, PIKACHU_BED, SET_UP_BED, EVENT_DECO_BED_4, $1e - decoration DECO_PLANT, PUT_IT_AWAY, PUT_AWAY_CARPET, EVENT_GAVE_KURT_APRICORNS, $00 - decoration DECO_CARPET, RED_CARPET, SET_UP_CARPET, EVENT_DECO_CARPET_1, $08 - decoration DECO_CARPET, BLUE_CARPET, SET_UP_CARPET, EVENT_DECO_CARPET_2, $0b - decoration DECO_CARPET, YELLOW_CARPET, SET_UP_CARPET, EVENT_DECO_CARPET_3, $0e - decoration DECO_CARPET, GREEN_CARPET, SET_UP_CARPET, EVENT_DECO_CARPET_4, $11 - decoration DECO_PLANT, PUT_IT_AWAY, PUT_AWAY_PLANT, EVENT_GAVE_KURT_APRICORNS, $00 - decoration DECO_PLANT, MAGNAPLANT, SET_UP_PLANT, EVENT_DECO_PLANT_1, $20 - decoration DECO_PLANT, TROPICPLANT, SET_UP_PLANT, EVENT_DECO_PLANT_2, $21 - decoration DECO_PLANT, JUMBOPLANT, SET_UP_PLANT, EVENT_DECO_PLANT_3, $22 - decoration DECO_PLANT, PUT_IT_AWAY, PUT_AWAY_POSTER, EVENT_GAVE_KURT_APRICORNS, $00 - decoration DECO_PLANT, TOWN_MAP_D, SET_UP_POSTER, EVENT_DECO_PLANT_4, $1f - decoration DECO_POSTER, PIKACHU, SET_UP_POSTER, EVENT_DECO_POSTER_1, $23 - decoration DECO_POSTER, CLEFAIRY, SET_UP_POSTER, EVENT_DECO_POSTER_2, $24 - decoration DECO_POSTER, JIGGLYPUFF, SET_UP_POSTER, EVENT_DECO_POSTER_3, $25 - decoration DECO_PLANT, PUT_IT_AWAY, PUT_AWAY_CONSOLE, EVENT_GAVE_KURT_APRICORNS, $00 - decoration DECO_PLANT, FAMICOM, SET_UP_CONSOLE, EVENT_DECO_FAMICOM, SPRITE_FAMICOM - decoration DECO_PLANT, SUPER_NES, SET_UP_CONSOLE, EVENT_DECO_SNES, SPRITE_SNES - decoration DECO_PLANT, NINTENDO_64, SET_UP_CONSOLE, EVENT_DECO_N64, SPRITE_N64 - decoration DECO_PLANT, VIRTUAL_BOY, SET_UP_CONSOLE, EVENT_DECO_VIRTUAL_BOY, SPRITE_VIRTUAL_BOY - decoration DECO_PLANT, PUT_IT_AWAY, PUT_AWAY_BIG_DOLL, EVENT_GAVE_KURT_APRICORNS, $00 - decoration DECO_BIGDOLL, SNORLAX, SET_UP_BIG_DOLL, EVENT_DECO_BIG_SNORLAX_DOLL, SPRITE_BIG_SNORLAX - decoration DECO_BIGDOLL, ONIX, SET_UP_BIG_DOLL, EVENT_DECO_BIG_ONIX_DOLL, SPRITE_BIG_ONIX - decoration DECO_BIGDOLL, LAPRAS, SET_UP_BIG_DOLL, EVENT_DECO_BIG_LAPRAS_DOLL, SPRITE_BIG_LAPRAS - decoration DECO_PLANT, PUT_IT_AWAY, PUT_AWAY_DOLL, EVENT_GAVE_KURT_APRICORNS, $00 - decoration DECO_DOLL, PIKACHU, SET_UP_DOLL, EVENT_DECO_PIKACHU_DOLL, SPRITE_PIKACHU - decoration DECO_PLANT, SURF_PIKA_DOLL, SET_UP_DOLL, EVENT_DECO_SURFING_PIKACHU_DOLL, SPRITE_SURFING_PIKACHU - decoration DECO_DOLL, CLEFAIRY, SET_UP_DOLL, EVENT_DECO_CLEFAIRY_DOLL, SPRITE_CLEFAIRY - decoration DECO_DOLL, JIGGLYPUFF, SET_UP_DOLL, EVENT_DECO_JIGGLYPUFF_DOLL, SPRITE_JIGGLYPUFF - decoration DECO_DOLL, BULBASAUR, SET_UP_DOLL, EVENT_DECO_BULBASAUR_DOLL, SPRITE_BULBASAUR - decoration DECO_DOLL, CHARMANDER, SET_UP_DOLL, EVENT_DECO_CHARMANDER_DOLL, SPRITE_CHARMANDER - decoration DECO_DOLL, SQUIRTLE, SET_UP_DOLL, EVENT_DECO_SQUIRTLE_DOLL, SPRITE_SQUIRTLE - decoration DECO_DOLL, POLIWAG, SET_UP_DOLL, EVENT_DECO_POLIWAG_DOLL, SPRITE_POLIWAG - decoration DECO_DOLL, DIGLETT, SET_UP_DOLL, EVENT_DECO_DIGLETT_DOLL, SPRITE_DIGLETT - decoration DECO_DOLL, STARYU, SET_UP_DOLL, EVENT_DECO_STARMIE_DOLL, SPRITE_STARMIE - decoration DECO_DOLL, MAGIKARP, SET_UP_DOLL, EVENT_DECO_MAGIKARP_DOLL, SPRITE_MAGIKARP - decoration DECO_DOLL, ODDISH, SET_UP_DOLL, EVENT_DECO_ODDISH_DOLL, SPRITE_ODDISH - decoration DECO_DOLL, GENGAR, SET_UP_DOLL, EVENT_DECO_GENGAR_DOLL, SPRITE_GENGAR - decoration DECO_DOLL, SHELLDER, SET_UP_DOLL, EVENT_DECO_SHELLDER_DOLL, SPRITE_SHELLDER - decoration DECO_DOLL, GRIMER, SET_UP_DOLL, EVENT_DECO_GRIMER_DOLL, SPRITE_GRIMER - decoration DECO_DOLL, VOLTORB, SET_UP_DOLL, EVENT_DECO_VOLTORB_DOLL, SPRITE_VOLTORB - decoration DECO_DOLL, WEEDLE, SET_UP_DOLL, EVENT_DECO_WEEDLE_DOLL, SPRITE_WEEDLE - decoration DECO_DOLL, UNOWN, SET_UP_DOLL, EVENT_DECO_UNOWN_DOLL, SPRITE_UNOWN - decoration DECO_DOLL, GEODUDE, SET_UP_DOLL, EVENT_DECO_GEODUDE_DOLL, SPRITE_GEODUDE - decoration DECO_DOLL, MACHOP, SET_UP_DOLL, EVENT_DECO_MACHOP_DOLL, SPRITE_MACHOP - decoration DECO_DOLL, TENTACOOL, SET_UP_DOLL, EVENT_DECO_TENTACOOL_DOLL, SPRITE_TENTACOOL - decoration DECO_PLANT, GOLD_TROPHY, SET_UP_DOLL, EVENT_DECO_GOLD_TROPHY, SPRITE_GOLD_TROPHY - decoration DECO_PLANT, SILVER_TROPHY, SET_UP_DOLL, EVENT_DECO_SILVER_TROPHY, SPRITE_SILVER_TROPHY -; 26b8d +.nothingthere + ld hl, UnknownText_0x26ed6 + call MenuTextBoxBackup + xor a + ret +; 26db3 -DecorationNames: ; 26b8d - db "CANCEL@" - db "PUT IT AWAY@" - db "MAGNAPLANT@" - db "TROPICPLANT@" - db "JUMBOPLANT@" - db "TOWN MAP@" - db "NES@" - db "SUPER NES@" - db "NINTENDO 64@" - db "VIRTUAL BOY@" - db "GOLD TROPHY@" - db "SILVER TROPHY@" - db "SURF PIKACHU DOLL@" - db " BED@" - db " CARPET@" - db " POSTER@" - db " DOLL@" - db "BIG @" - db "FEATHERY@" - db "PIKACHU@" - db "PINK@" - db "POLKADOT@" - db "RED@" - db "BLUE@" - db "YELLOW@" - db "GREEN@" -; 26c72 +DecoAction_setupornament: ; 26db3 + ld hl, UnknownText_0x26e41 + call DecoAction_AskWhichSide + jr c, .cancel + call DecoAction_SetItUp_Ornament + jr c, .cancel + ld a, $1 + ld [wd1ee], a + jr DecoAction_FinishUp_Ornament -GetDecoName: ; 26c72 - ld a, [hli] - ld e, [hl] - ld bc, StringBuffer2 - push bc - ld hl, .NameFunctions - rst JumpTable - pop de +.cancel + xor a ret -; 26c7e -.NameFunctions: ; 26c7e - dw .invalid - dw .plant - dw .bed - dw .carpet - dw .poster - dw .doll - dw .bigdoll -; 26c8c +DecoAction_putawayornament: ; 26dc9 + ld hl, UnknownText_0x26e6b + call DecoAction_AskWhichSide + jr nc, .incave + xor a + ret +.incave + call DecoAction_PutItAway_Ornament -.invalid: ; 26c8c +DecoAction_FinishUp_Ornament: ; 26dd6 + call QueryWhichSide + ld a, [wd1ec] + ld [hl], a + ld a, [wd1ed] + ld [de], a + xor a ret -; 26c8d +; 26de3 -.plant: ; 26c8d - ld a, e - jr .getdeconame - -.bed: ; 26c90 - call .plant - ld a, _BED - jr .getdeconame - -.carpet: ; 26c97 - call .plant - ld a, _CARPET - jr .getdeconame - -.poster: ; 26c9e - ld a, e - call .getpokename - ld a, _POSTER - jr .getdeconame - -.doll: ; 26ca6 - ld a, e - call .getpokename - ld a, _DOLL - jr .getdeconame - -.bigdoll: ; 26cae - push de - ld a, BIG_ - call .getdeconame - pop de - ld a, e - jr .getpokename - -.unused: ; 26cb8 - push de - call .getdeconame - pop de - ld a, e - jr .getdeconame - -.getpokename: ; 26cc0 - push bc - ld [wd265], a - call GetPokemonName - pop bc - jr .copy - -.getdeconame: ; 26cca - call ._getdeconame - jr .copy - -._getdeconame: ; 26ccf - push bc - ld hl, DecorationNames - call GetNthString - ld d, h - ld e, l - pop bc - ret - -.copy: ; 26cda - ld h, b - ld l, c - call CopyName2 - dec hl - ld b, h - ld c, l - ret -; 26ce3 - -DecoAction_nothing: ; 26ce3 - scf - ret -; 26ce5 - -DecoAction_setupbed: ; 26ce5 - ld hl, Bed - jp DecoAction_TrySetItUp -; 26ceb - -DecoAction_putawaybed: ; 26ceb - ld hl, Bed - jp DecoAction_TryPutItAway -; 26cf1 - -DecoAction_setupcarpet: ; 26cf1 - ld hl, Carpet - jp DecoAction_TrySetItUp -; 26cf7 - -DecoAction_putawaycarpet: ; 26cf7 - ld hl, Carpet - jp DecoAction_TryPutItAway -; 26cfd - -DecoAction_setupplant: ; 26cfd - ld hl, Plant - jp DecoAction_TrySetItUp -; 26d03 - -DecoAction_putawayplant: ; 26d03 - ld hl, Plant - jp DecoAction_TryPutItAway -; 26d09 - -DecoAction_setupposter: ; 26d09 - ld hl, Poster - jp DecoAction_TrySetItUp -; 26d0f - -DecoAction_putawayposter: ; 26d0f - ld hl, Poster - jp DecoAction_TryPutItAway -; 26d15 - -DecoAction_setupconsole: ; 26d15 - ld hl, Console - jp DecoAction_TrySetItUp -; 26d1b - -DecoAction_putawayconsole: ; 26d1b - ld hl, Console - jp DecoAction_TryPutItAway -; 26d21 - -DecoAction_setupbigdoll: ; 26d21 - ld hl, BigDoll - jp DecoAction_TrySetItUp -; 26d27 - -DecoAction_putawaybigdoll: ; 26d27 - ld hl, BigDoll - jp DecoAction_TryPutItAway -; 26d2d - -DecoAction_TrySetItUp: ; 26d2d - ld a, [hl] - ld [Buffer1], a - push hl - call DecoAction_SetItUp - jr c, .failed - ld a, 1 - ld [wd1ee], a - pop hl - ld a, [MenuSelection] - ld [hl], a - xor a - ret - -.failed - pop hl - xor a - ret -; 26d46 - -DecoAction_SetItUp: ; 26d46 -; See if there's anything of the same type already out - ld a, [Buffer1] - and a - jr z, .nothingthere -; See if that item is already out - ld b, a - ld a, [MenuSelection] - cp b - jr z, .alreadythere -; Put away the item that's already out, and set up the new one - ld a, [MenuSelection] - ld hl, StringBuffer4 - call GetDecorationName - ld a, [Buffer1] - ld hl, StringBuffer3 - call GetDecorationName - ld hl, UnknownText_0x26ee0 - call MenuTextBoxBackup - xor a - ret +DecoAction_SetItUp_Ornament: ; 26de3 + ld a, [wd1ec] + and a + jr z, .nothingthere + ld b, a + ld a, [MenuSelection] + cp b + jr z, .failed + ld a, b + ld hl, StringBuffer3 + call GetDecorationName + ld a, [MenuSelection] + ld hl, StringBuffer4 + call GetDecorationName + ld a, [MenuSelection] + ld [wd1ec], a + call .getwhichside + ld hl, UnknownText_0x26ee0 + call MenuTextBoxBackup + xor a + ret .nothingthere + ld a, [MenuSelection] + ld [wd1ec], a + call .getwhichside ld a, [MenuSelection] ld hl, StringBuffer3 call GetDecorationName @@ -17412,29 +15834,40 @@ DecoAction_SetItUp: ; 26d46 xor a ret -.alreadythere +.failed ld hl, UnknownText_0x26ee5 call MenuTextBoxBackup scf ret -; 26d86 +; 26e33 -DecoAction_TryPutItAway: ; 26d86 -; If there is no item of that type already set, there is nothing to put away. - ld a, [hl] - ld [Buffer1], a +.getwhichside: ; 26e33 + ld a, [MenuSelection] + ld b, a + ld a, [wd1ed] + cp b + ret nz xor a - ld [hl], a - ld a, [Buffer1] + ld [wd1ed], a + ret +; 26e41 + +UnknownText_0x26e41: ; 0x26e41 + ; Which side do you want to put it on? + text_jump UnknownText_0x1bc48c + db "@" +; 0x26e46 + +DecoAction_PutItAway_Ornament: ; 26e46 + ld a, [wd1ec] and a jr z, .nothingthere -; Put it away. - ld a, $1 - ld [wd1ee], a - ld a, [Buffer1] - ld [MenuSelection], a ld hl, StringBuffer3 call GetDecorationName + ld a, $1 + ld [wd1ee], a + xor a + ld [wd1ec], a ld hl, UnknownText_0x26ed1 call MenuTextBoxBackup xor a @@ -17445,151 +15878,37 @@ DecoAction_TryPutItAway: ; 26d86 call MenuTextBoxBackup xor a ret -; 26db3 +; 26e6b -DecoAction_setupornament: ; 26db3 - ld hl, UnknownText_0x26e41 - call DecoAction_AskWhichSide - jr c, .cancel - call DecoAction_SetItUp_Ornament - jr c, .cancel - ld a, $1 - ld [wd1ee], a - jr DecoAction_FinishUp_Ornament +UnknownText_0x26e6b: ; 0x26e6b + ; Which side do you want to put away? + text_jump UnknownText_0x1bc4b2 + db "@" +; 0x26e70 -.cancel +DecoAction_AskWhichSide: ; 26e70 + call MenuTextBox + ld hl, MenuDataHeader_0x26eab + call GetMenu2 + call ExitMenu + call CopyMenuData2 + jr c, .nope + ld a, [MenuSelection2] + cp 3 + jr z, .nope + ld [Buffer2], a + call QueryWhichSide + ld a, [hl] + ld [wd1ec], a + ld a, [de] + ld [wd1ed], a xor a ret -DecoAction_putawayornament: ; 26dc9 - ld hl, UnknownText_0x26e6b - call DecoAction_AskWhichSide - jr nc, .incave - xor a +.nope + scf ret - -.incave - call DecoAction_PutItAway_Ornament - -DecoAction_FinishUp_Ornament: ; 26dd6 - call QueryWhichSide - ld a, [wd1ec] - ld [hl], a - ld a, [wd1ed] - ld [de], a - xor a - ret -; 26de3 - -DecoAction_SetItUp_Ornament: ; 26de3 - ld a, [wd1ec] - and a - jr z, .nothingthere - ld b, a - ld a, [MenuSelection] - cp b - jr z, .failed - ld a, b - ld hl, StringBuffer3 - call GetDecorationName - ld a, [MenuSelection] - ld hl, StringBuffer4 - call GetDecorationName - ld a, [MenuSelection] - ld [wd1ec], a - call .getwhichside - ld hl, UnknownText_0x26ee0 - call MenuTextBoxBackup - xor a - ret - -.nothingthere - ld a, [MenuSelection] - ld [wd1ec], a - call .getwhichside - ld a, [MenuSelection] - ld hl, StringBuffer3 - call GetDecorationName - ld hl, UnknownText_0x26edb - call MenuTextBoxBackup - xor a - ret - -.failed - ld hl, UnknownText_0x26ee5 - call MenuTextBoxBackup - scf - ret -; 26e33 - -.getwhichside: ; 26e33 - ld a, [MenuSelection] - ld b, a - ld a, [wd1ed] - cp b - ret nz - xor a - ld [wd1ed], a - ret -; 26e41 - -UnknownText_0x26e41: ; 0x26e41 - ; Which side do you want to put it on? - text_jump UnknownText_0x1bc48c - db "@" -; 0x26e46 - -DecoAction_PutItAway_Ornament: ; 26e46 - ld a, [wd1ec] - and a - jr z, .nothingthere - ld hl, StringBuffer3 - call GetDecorationName - ld a, $1 - ld [wd1ee], a - xor a - ld [wd1ec], a - ld hl, UnknownText_0x26ed1 - call MenuTextBoxBackup - xor a - ret - -.nothingthere - ld hl, UnknownText_0x26ed6 - call MenuTextBoxBackup - xor a - ret -; 26e6b - -UnknownText_0x26e6b: ; 0x26e6b - ; Which side do you want to put away? - text_jump UnknownText_0x1bc4b2 - db "@" -; 0x26e70 - -DecoAction_AskWhichSide: ; 26e70 - call MenuTextBox - ld hl, MenuDataHeader_0x26eab - call GetMenu2 - call ExitMenu - call CopyMenuData2 - jr c, .nope - ld a, [MenuSelection2] - cp 3 - jr z, .nope - ld [Buffer2], a - call QueryWhichSide - ld a, [hl] - ld [wd1ec], a - ld a, [de] - ld [wd1ed], a - xor a - ret - -.nope - scf - ret -; 26e9a +; 26e9a QueryWhichSide: ; 26e9a ld hl, RightOrnament @@ -30326,10003 +28645,8436 @@ Function4e0e7: ; 4e0e7 (13:60e7) jr z, .asm_4e111 inc a ld d, a - callba CalcExpAtLevel -rept 2 - ld hl, TempMonExp + 2 -endr - ld a, [$ffb6] - sub [hl] - dec hl - ld [wd1ec], a - ld a, [$ffb5] - sbc [hl] - dec hl - ld [Buffer2], a ; wd1eb (aliases: MovementType) - ld a, [hQuotient] - sbc [hl] - ld [Buffer1], a ; wd1ea (aliases: MagikarpLength) - ret -.asm_4e111 - ld hl, Buffer1 ; wd1ea (aliases: MagikarpLength) - xor a -rept 2 - ld [hli], a -endr - ld [hl], a - ret -; 4e119 (13:6119) - -String_4e119: ; 4e119 - db "STATUS/" - next "TYPE/@" -; 4e127 - -String_4e127: ; 4e127 - db "OK @" -; 4e12b - -String_4e12b: ; 4e12b - db "EXP POINTS@" -; 4e136 - -String_4e136: ; 4e136 - db "LEVEL UP@" -; 4e13f - -String_4e13f: ; 4e13f - db "TO@" -; 4e142 - -String_4e142: ; 4e142 - db "#RUS@" -; 4e147 - -Function4e147: ; 4e147 (13:6147) - ld de, String_4e1a0 - hlcoord 0, 8 - call PlaceString - call Function4e189 - hlcoord 8, 8 - call PlaceString - ld de, String_4e1a9 - hlcoord 0, 10 - call PlaceString - ld hl, TempMonMoves - ld de, wListMoves_MoveIndicesBuffer - ld bc, NUM_MOVES - call CopyBytes - hlcoord 8, 10 - ld a, SCREEN_WIDTH * 2 - ld [Buffer1], a - predef ListMoves - hlcoord 12, 11 - ld a, $28 - ld [Buffer1], a - predef Function50c50 - ret - -Function4e189: ; 4e189 (13:6189) - ld de, String_4e1a5 - ld a, [TempMonItem] - and a - ret z - ld b, a - callba Function28771 - ld a, b - ld [wd265], a - call GetItemName - ret -; 4e1a0 (13:61a0) - -String_4e1a0: ; 4e1a0 - db "ITEM@" -; 4e1a5 - -String_4e1a5: ; 4e1a5 - db "---@" -; 4e1a9 - -String_4e1a9: ; 4e1a9 - db "MOVE@" -; 4e1ae - -Function4e1ae: ; 4e1ae (13:61ae) - call Function4e1cc - hlcoord 10, 8 - ld de, $14 - ld b, $a - ld a, $31 -.asm_4e1bb - ld [hl], a - add hl, de - dec b - jr nz, .asm_4e1bb - hlcoord 11, 8 - ld bc, $6 - predef PrintTempMonStats - ret - -Function4e1cc: ; 4e1cc (13:61cc) - ld de, IDNoString - hlcoord 0, 9 - call PlaceString - ld de, OTString - hlcoord 0, 12 - call PlaceString - hlcoord 2, 10 - lb bc, PRINTNUM_LEADINGZEROS | 2, 5 - ld de, TempMonID - call PrintNum - ld hl, Unknown_4e216 - call Function4e528 - call Function4e505 - callba CheckNickErrors - hlcoord 2, 13 - call PlaceString - ld a, [TempMonCaughtGender] - and a - jr z, .asm_4e215 - cp $7f - jr z, .asm_4e215 - and $80 - ld a, "♂" - jr z, .asm_4e211 - ld a, "♀" -.asm_4e211 - hlcoord 9, 13 - ld [hl], a -.asm_4e215 - ret -; 4e216 (13:6216) - -Unknown_4e216: ; 4e216 - dw PartyMonOT - dw OTPartyMonOT - dw sBoxMonOT - dw wd00d -; 4e21e - -IDNoString: ; 4e21e - db $73, "№.@" - -OTString: ; 4e222 - db "OT/@" -; 4e226 - - -Function4e226: ; 4e226 (13:6226) - ld hl, TempMonDVs - predef GetUnownLetter - call Function4e2ad - jr c, .asm_4e238 - and a - jr z, .asm_4e23f - jr .asm_4e246 -.asm_4e238 - call Function4e271 - call SetPalettes - ret -.asm_4e23f - call Function4e253 - call SetPalettes - ret -.asm_4e246 - call SetPalettes - call Function4e253 - ld a, [CurPartySpecies] - call PlayCry2 - ret - -Function4e253: ; 4e253 (13:6253) - ld hl, wcf64 - set 5, [hl] - ld a, [CurPartySpecies] - cp UNOWN - jr z, .asm_4e266 - hlcoord 0, 0 - call PrepMonFrontpic - ret -.asm_4e266 - xor a - ld [wc2c6], a - hlcoord 0, 0 - call _PrepMonFrontpic - ret - -Function4e271: ; 4e271 (13:6271) - ld a, [CurPartySpecies] - cp UNOWN - jr z, .asm_4e281 - ld a, $1 - ld [wc2c6], a - call Function4e289 - ret -.asm_4e281 - xor a - ld [wc2c6], a - call Function4e289 - ret - -Function4e289: ; 4e289 (13:6289) - ld a, [CurPartySpecies] - call IsAPokemon - ret c - call Function4e307 - ld de, VTiles2 tile $00 - predef Function5108b - hlcoord 0, 0 - ld d, $0 - ld e, $2 - predef LoadMonAnimation - ld hl, wcf64 - set 6, [hl] - ret - -Function4e2ad: ; 4e2ad (13:62ad) - ld a, [MonType] - ld hl, Jumptable_4e2b5 - rst JumpTable - ret - -Jumptable_4e2b5: ; 4e2b5 (13:62b5) - dw Function4e2bf - dw Function4e2cf - dw Function4e2d1 - dw Function4e2ed - dw Function4e301 - - -Function4e2bf: ; 4e2bf (13:62bf) - ld a, [CurPartyMon] - ld hl, PartyMons ; wdcdf (aliases: PartyMon1, PartyMon1Species) - ld bc, PARTYMON_STRUCT_LENGTH - call AddNTimes - ld b, h - ld c, l - jr Function4e2f2 - -Function4e2cf: ; 4e2cf (13:62cf) - xor a - ret - -Function4e2d1: ; 4e2d1 (13:62d1) - ld hl, sBoxMons - ld bc, $30 - ld a, [CurPartyMon] - call AddNTimes - ld b, h - ld c, l - ld a, $1 - call GetSRAMBank - call Function4e2f2 - push af - call CloseSRAM - pop af - ret - -Function4e2ed: ; 4e2ed (13:62ed) - ld bc, TempMonSpecies ; wd10e (aliases: TempMon) - jr Function4e2f2 - -Function4e2f2: ; 4e2f2 (13:62f2) - ld a, [CurPartySpecies] - cp EGG - jr z, .asm_4e2fe - call CheckFaintedFrzSlp - jr c, Function4e305 -.asm_4e2fe - xor a - scf - ret - -Function4e301: ; 4e301 (13:6301) - ld a, $1 - and a - ret -Function4e305: ; 4e305 (13:6305) - xor a - ret - -Function4e307: ; 4e307 (13:6307) - nop - push hl - push de - push bc - push af - call DelayFrame - ld a, [rVBK] - push af - ld a, $1 - ld [rVBK], a - ld de, TextBoxSpaceGFX - lb bc, BANK(TextBoxSpaceGFX), 1 - ld hl, VTiles2 tile $7f - call Get2bpp - pop af - ld [rVBK], a - pop af - pop bc - pop de - pop hl - ret -; 4e32a (13:632a) - -Unknown_4e32a: ; 4e32a -; A blank tile? - ds 16 -; 4e33a - -EggStatsScreen: ; 4e33a - xor a - ld [hBGMapMode], a - ld hl, wcda1 - call SetHPPal - ld b, SCGB_03 - call GetSGBLayout - call Function4df8f - ld de, EggString - hlcoord 8, 1 - call PlaceString - ld de, IDNoString - hlcoord 8, 3 - call PlaceString - ld de, OTString - hlcoord 8, 5 - call PlaceString - ld de, FiveQMarkString - hlcoord 11, 3 - call PlaceString - ld de, FiveQMarkString - hlcoord 11, 5 - call PlaceString - ld a, [TempMonHappiness] ; egg status - ld de, EggSoonString - cp $6 - jr c, .picked - ld de, EggCloseString - cp $b - jr c, .picked - ld de, EggMoreTimeString - cp $29 - jr c, .picked - ld de, EggALotMoreTimeString -.picked - hlcoord 1, 9 - call PlaceString - ld hl, wcf64 - set 5, [hl] - call SetPalettes ; pals - call DelayFrame - hlcoord 0, 0 - call PrepMonFrontpic - callba Function10402d - call Function4e497 - - ld a, [TempMonHappiness] - cp 6 - ret nc - ld de, SFX_2_BOOPS - call PlaySFX - ret -; 0x4e3c0 - -EggString: ; 4e3c0 - db "EGG@" - -FiveQMarkString: ; 4e3c4 - db "?????@" - -EggSoonString: ; 0x4e3ca - db "It's making sounds" - next "inside. It's going" - next "to hatch soon!@" - -EggCloseString: ; 0x4e3fd - db "It moves around" - next "inside sometimes." - next "It must be close" - next "to hatching.@" - -EggMoreTimeString: ; 0x4e43d - db "Wonder what's" - next "inside? It needs" - next "more time, though.@" - -EggALotMoreTimeString: ; 0x4e46e - db "This EGG needs a" - next "lot more time to" - next "hatch.@" -; 0x4e497 - - -Function4e497: ; 4e497 (13:6497) - call Function4e2ad - ret nc - ld a, [TempMonHappiness] - ld e, $7 - cp $6 - jr c, .asm_4e4ab - ld e, $8 - cp $b - jr c, .asm_4e4ab - ret -.asm_4e4ab - push de - ld a, $1 - ld [wc2c6], a - call Function4e307 - ld de, VTiles2 tile $00 - predef Function5108b - pop de - hlcoord 0, 0 - ld d, $0 - predef LoadMonAnimation - ld hl, wcf64 - set 6, [hl] - ret - -Function4e4cd: ; 4e4cd (13:64cd) - hlcoord 13, 5 - ld a, $36 - call Function4e4f7 - hlcoord 15, 5 - ld a, $36 - call Function4e4f7 - hlcoord 17, 5 - ld a, $36 - call Function4e4f7 - ld a, c - cp $2 - ld a, $3a - hlcoord 13, 5 - jr c, Function4e4f7 - hlcoord 15, 5 - jr z, Function4e4f7 - hlcoord 17, 5 - -Function4e4f7: ; 4e4f7 (13:64f7) - push bc - ld [hli], a - inc a - ld [hld], a - ld bc, $14 - add hl, bc - inc a - ld [hli], a - inc a - ld [hl], a - pop bc - ret - -Function4e505: ; 4e505 (13:6505) - ld de, StringBuffer1 - ld bc, $b - jr .asm_4e50d -.asm_4e50d - ld a, [MonType] - cp BOXMON - jr nz, .asm_4e522 - ld a, BANK(sBoxMonNicknames) - call GetSRAMBank - push de - call CopyBytes - pop de - call CloseSRAM - ret -.asm_4e522 - push de - call CopyBytes - pop de - ret - -Function4e528: ; 4e528 (13:6528) - ld a, [MonType] - add a - ld c, a - ld b, 0 - add hl, bc - ld a, [hli] - ld h, [hl] - ld l, a - ld a, [MonType] - cp $3 - ret z - ld a, [CurPartyMon] - jp SkipNames - - -CheckFaintedFrzSlp: ; 4e53f - ld hl, MON_HP - add hl, bc - ld a, [hli] - or [hl] - jr z, .fainted_frz_slp - ld hl, MON_STATUS - add hl, bc - ld a, [hl] - and (1 << FRZ) | SLP - jr nz, .fainted_frz_slp - and a - ret - -.fainted_frz_slp - scf - ret -; 4e554 - - -CatchTutorial:: ; 4e554 - ld a, [BattleType] - dec a - ld c, a - ld hl, .jumptable - ld b, 0 -rept 2 - add hl, bc -endr - ld a, [hli] - ld h, [hl] - ld l, a - jp [hl] -; 4e564 - -.jumptable: ; 4e564 (13:6564) - dw .DudeTutorial - dw .DudeTutorial - dw .DudeTutorial - -.DudeTutorial: ; 4e56a (13:656a) -; Back up your name to your Mom's name. - ld hl, PlayerName - ld de, MomsName - ld bc, NAME_LENGTH - call CopyBytes -; Copy Dude's name to your name - ld hl, .Dude - ld de, PlayerName - ld bc, NAME_LENGTH - call CopyBytes - - call .LoadDudeData - - xor a - ld [hJoyDown], a - ld [hJoyPressed], a - ld a, [Options] - push af - and $f8 - add $3 - ld [Options], a - ld hl, .AutoInput - ld a, BANK(.AutoInput) - call StartAutoInput - callab StartBattle - call StopAutoInput - pop af - - ld [Options], a - ld hl, MomsName - ld de, PlayerName - ld bc, NAME_LENGTH - call CopyBytes - ret - -.LoadDudeData: ; 4e5b7 (13:65b7) - ld hl, OTPartyMon1 - ld [hl], BULBASAUR - inc hl - ld [hl], POTION - inc hl - ld [hl], POUND - inc hl - ld [hl], $ff - ld hl, OTPartyMon1Exp + 2 - ld [hl], $0 - inc hl - ld [hl], $ff - ld hl, OTPartyMon1CaughtGender - ld a, $1 - ld [hli], a - ld a, $5 -rept 2 - ld [hli], a -endr - ld [hl], $ff - ret -; 4e5da (13:65da) - -.Dude: ; 4e5da - db "DUDE@" -; 4e5df - -.AutoInput: ; 4e5df - db NO_INPUT, $ff ; end -; 4e5e1 - -INCLUDE "engine/evolution_animation.asm" - -Function4e929: ; mobile function - ld h, b - ld l, c - call Function4e930 - ld c, a - ret -; 4e930 - -Function4e930: ; 4e930 - ld a, [hli] - xor [hl] - ld c, a - jr z, .skip_male_trainers - srl c - srl c -.male_trainer_loop - srl c - ld a, c - cp MaleTrainersEnd - MaleTrainers - 1 - jr nc, .male_trainer_loop - inc c - -.skip_male_trainers - ld a, [de] - cp $1 - ld hl, MaleTrainers - jr nz, .finished - - ld hl, FemaleTrainers - ld a, c - and a - jr z, .finished - -.female_trainer_loop - srl c - ld a, c - cp FemaleTrainersEnd - FemaleTrainers - 1 - jr nc, .female_trainer_loop - inc c - -.finished - ld b, $0 - add hl, bc - ld a, [hl] - ret -; 4e95d - -MaleTrainers: ; 4e95d - db BURGLAR - db YOUNGSTER - db SCHOOLBOY - db BIRD_KEEPER - db POKEMANIAC - db GENTLEMAN - db BUG_CATCHER - db FISHER - db SWIMMERM - db SAILOR - db SUPER_NERD - db GUITARIST - db HIKER - db FIREBREATHER - db BLACKBELT_T - db PSYCHIC_T - db CAMPER - db COOLTRAINERM - db BOARDER - db JUGGLER - db POKEFANM - db OFFICER - db SAGE - db BIKER - db SCIENTIST -MaleTrainersEnd: -; 4e976 - -FemaleTrainers: ; 4e976 - db MEDIUM - db LASS - db BEAUTY - db SKIER - db TEACHER - db SWIMMERF - db PICNICKER - db KIMONO_GIRL - db POKEFANF - db COOLTRAINERF -FemaleTrainersEnd: -; 4e980 - - -INCLUDE "battle/sliding_intro.asm" - - -Function4ea0a: ; 4ea0a - ld a, c - push af - call SpeechTextBox - call MobileTextBorder - pop af - dec a - ld bc, $c - ld hl, w5_dc1a - call AddNTimes - ld de, wcd53 - ld bc, $c - ld a, $5 ; BANK(w5_dc1a) - call FarCopyWRAM - - ld a, [rSVBK] - push af - ld a, $1 - ld [rSVBK], a - - ld bc, wcd53 - decoord 1, 14 - callba Function11c0c6 - - pop af - ld [rSVBK], a - - ld c, 180 - call DelayFrames - ret -; 4ea44 - - - -CheckBattleScene: ; 4ea44 -; Return carry if battle scene is turned off. - - ld a, 0 - ld hl, wLinkMode - call GetFarWRAMByte - cp LINK_MOBILE - jr z, .mobile - - ld a, [Options] - bit BATTLE_SCENE, a - jr nz, .off - - and a - ret - -.mobile - ld a, [wcd2f] - and a - jr nz, .asm_4ea72 - - ld a, $4 - call GetSRAMBank - ld a, [$a60c] - ld c, a - call CloseSRAM - - ld a, c - bit 0, c - jr z, .off - - and a - ret - -.asm_4ea72 - ld a, $5 - ld hl, wdc00 - call GetFarWRAMByte - bit 0, a - jr z, .off - - and a - ret - -.off - scf - ret -; 4ea82 - - -INCLUDE "misc/gbc_only.asm" - -INCLUDE "event/poke_seer.asm" - - -SECTION "bank14", ROMX, BANK[$14] - -INCLUDE "engine/party_menu.asm" -INCLUDE "event/poisonstep.asm" -INCLUDE "event/sweet_scent.asm" -INCLUDE "event/squirtbottle.asm" -INCLUDE "event/card_key.asm" -INCLUDE "event/basement_key.asm" -INCLUDE "event/sacred_ash.asm" - -CopyPkmnToTempMon: ; 5084a -; gets the BaseData of a Pkmn -; and copys the PkmnStructure to TempMon - - ld a, [CurPartyMon] - ld e, a - call GetPkmnSpecies - ld a, [CurPartySpecies] - ld [CurSpecies], a - call GetBaseData - - ld a, [MonType] - ld hl, PartyMon1Species - ld bc, PARTYMON_STRUCT_LENGTH - and a - jr z, .copywholestruct - ld hl, OTPartyMon1Species - ld bc, PARTYMON_STRUCT_LENGTH - cp OTPARTYMON - jr z, .copywholestruct - ld bc, BOXMON_STRUCT_LENGTH - callab Functione5bb - jr .done - -.copywholestruct - ld a, [CurPartyMon] - call AddNTimes - ld de, TempMon - ld bc, PARTYMON_STRUCT_LENGTH - call CopyBytes - -.done - ret -; 5088b - - -Function5088b: ; 5088b - ld bc, wd018 - jr Function50893 -; 50890 - -Function50890: ; 50890 - ld bc, TempMon - ; fallthrough -; 50893 - -Function50893: ; 50893 - ld hl, MON_LEVEL - add hl, bc - ld a, [hl] - ld [CurPartyLevel], a - ld hl, MON_MAXHP - add hl, bc - ld d, h - ld e, l - ld hl, MON_EXP + 2 - add hl, bc - push bc - ld b, $1 - predef CalcPkmnStats - pop bc - ld hl, MON_HP - add hl, bc - ld d, h - ld e, l - ld a, [CurPartySpecies] - cp EGG - jr nz, .asm_508c1 - xor a - ld [de], a - inc de - ld [de], a - jr .asm_508cd - -.asm_508c1 - push bc - ld hl, MON_MAXHP - add hl, bc - ld bc, 2 - call CopyBytes - pop bc - -.asm_508cd - ld hl, MON_STATUS - add hl, bc - xor a - ld [hli], a - ld [hl], a - ret -; 508d5 - -GetPkmnSpecies: ; 508d5 -; [MonType] has the type of the Pkmn -; e = Nr. of Pkmn (i.e. [CurPartyMon]) - - ld a, [MonType] - and a ; PARTYMON - jr z, .partymon - cp OTPARTYMON - jr z, .otpartymon - cp BOXMON - jr z, .boxmon - cp BREEDMON - jr z, .breedmon - ; WILDMON - -.partymon - ld hl, PartySpecies - jr .done - -.otpartymon - ld hl, OTPartySpecies - jr .done - -.boxmon - ld a, BANK(sBoxSpecies) - call GetSRAMBank - ld hl, sBoxSpecies - call .done - call CloseSRAM - ret - -.breedmon - ld a, [wBreedMon1Species] - jr .done2 - -.done - ld d, 0 - add hl, de - ld a, [hl] - -.done2 - ld [CurPartySpecies], a - ret -; 5090d - - -INCLUDE "text/types.asm" - - -Function50a28: ; 50a28 - ld hl, Strings50a42 - ld a, [TrainerClass] - dec a - ld c, a - ld b, 0 -rept 2 - add hl, bc -endr - ld a, [hli] - ld h, [hl] - ld l, a - ld de, StringBuffer1 -.copy - ld a, [hli] - ld [de], a - inc de - cp "@" - jr nz, .copy - ret -; 50a42 - -Strings50a42: ; 50a42 -; Untranslated trainer class names from Red. - - dw .Youngster - dw .BugCatcher - dw .Lass - dw OTName - dw .JrTrainerM - dw .JrTrainerF - dw .Pokemaniac - dw .SuperNerd - dw OTName - dw OTName - dw .Burglar - dw .Engineer - dw .Jack - dw OTName - dw .Swimmer - dw OTName - dw OTName - dw .Beauty - dw OTName - dw .Rocker - dw .Juggler - dw OTName - dw OTName - dw .Blackbelt - dw OTName - dw .ProfOak - dw .Chief - dw .Scientist - dw OTName - dw .Rocket - dw .CooltrainerM - dw .CooltrainerF - dw OTName - dw OTName - dw OTName - dw OTName - dw OTName - dw OTName - dw OTName - dw OTName - dw OTName - dw OTName - dw OTName - dw OTName - dw OTName - dw OTName - dw OTName - -.Youngster db "たんパン@" -.BugCatcher db "むしとり@" -.Lass db "ミニスカ@" -.JrTrainerM db "ボーイ@" -.JrTrainerF db "ガール@" -.Pokemaniac db "マニア@" -.SuperNerd db "りかけい@" -.Burglar db "どろぼう@" -.Engineer db "ォヤジ@" -.Jack db "ジャック@" -.Swimmer db "かいパン@" -.Beauty db "おねえさん@" -.Rocker db "グループ@" -.Juggler db "ジャグラー@" -.Blackbelt db "からて@" -.ProfOak db "ォーキド@" -.Chief db "チーフ@" -.Scientist db "けんきゅういん@" -.Rocket db "だんいん@" -.CooltrainerM db "エりート♂@" -.CooltrainerF db "エりート♀@" -; 50b0a - - -DrawPlayerHP: ; 50b0a - ld a, $1 - jr DrawHP - -DrawEnemyHP: ; 50b0e - ld a, $2 - -DrawHP: ; 50b10 - ld [wd10a], a - push hl - push bc - ld a, [MonType] - cp BOXMON - jr z, .asm_50b30 - - ld a, [TempMonHP] - ld b, a - ld a, [TempMonHP + 1] - ld c, a - -; Any HP? - or b - jr nz, .asm_50b30 - - xor a - ld c, a - ld e, a - ld a, 6 - ld d, a - jp .asm_50b4a - -.asm_50b30 - ld a, [TempMonMaxHP] - ld d, a - ld a, [TempMonMaxHP + 1] - ld e, a - ld a, [MonType] - cp BOXMON - jr nz, .asm_50b41 - - ld b, d - ld c, e - -.asm_50b41 - predef DrawPartyMenuHPBar - ld a, 6 - ld d, a - ld c, a - -.asm_50b4a - ld a, c - pop bc - ld c, a - pop hl - push de - push hl - push hl - call DrawBattleHPBar - pop hl - -; Print HP - ld bc, $15 ; move (1,1) - add hl, bc - ld de, TempMonHP - ld a, [MonType] - cp BOXMON - jr nz, .asm_50b66 - ld de, TempMonMaxHP -.asm_50b66 - lb bc, 2, 3 - call PrintNum - - ld a, "/" - ld [hli], a - -; Print max HP - ld de, TempMonMaxHP - lb bc, 2, 3 - call PrintNum - pop hl - pop de - ret -; 50b7b - - -PrintTempMonStats: ; 50b7b -; Print TempMon's stats at hl, with spacing bc. - push bc - push hl - ld de, .StatNames - call PlaceString - pop hl - pop bc - add hl, bc - ld bc, SCREEN_WIDTH - add hl, bc - ld de, TempMonAttack - lb bc, 2, 3 - call .PrintStat - ld de, TempMonDefense - call .PrintStat - ld de, TempMonSpclAtk - call .PrintStat - ld de, TempMonSpclDef - call .PrintStat - ld de, TempMonSpeed - jp PrintNum -; 50bab - -.PrintStat: ; 50bab - push hl - call PrintNum - pop hl - ld de, SCREEN_WIDTH * 2 - add hl, de - ret -; 50bb5 - -.StatNames: ; 50bb5 - db "ATTACK" - next "DEFENSE" - next "SPCL.ATK" - next "SPCL.DEF" - next "SPEED" - next "@" -; 50bdd - - -GetGender: ; 50bdd -; Return the gender of a given monster (CurPartyMon/CurOTMon/CurWildMon). -; When calling this function, a should be set to an appropriate MonType value. - -; return values: -; a = 1: f = nc|nz; male -; a = 0: f = nc|z; female -; f = c: genderless - -; This is determined by comparing the Attack and Speed DVs -; with the species' gender ratio. - - -; Figure out what type of monster struct we're looking at. - -; 0: PartyMon - ld hl, PartyMon1DVs - ld bc, PARTYMON_STRUCT_LENGTH - ld a, [MonType] - and a - jr z, .PartyMon - -; 1: OTPartyMon - ld hl, OTPartyMon1DVs - dec a - jr z, .PartyMon - -; 2: sBoxMon - ld hl, sBoxMon1DVs - ld bc, BOXMON_STRUCT_LENGTH - dec a - jr z, .sBoxMon - -; 3: Unknown - ld hl, TempMonDVs - dec a - jr z, .DVs - -; else: WildMon - ld hl, EnemyMonDVs - jr .DVs - - -; Get our place in the party/box. - -.PartyMon -.sBoxMon - ld a, [CurPartyMon] - call AddNTimes - - -.DVs - -; sBoxMon data is read directly from SRAM. - ld a, [MonType] - cp BOXMON - ld a, 1 - call z, GetSRAMBank - -; Attack DV - ld a, [hli] - and $f0 - ld b, a -; Speed DV - ld a, [hl] - and $f0 - swap a - -; Put our DVs together. - or b - ld b, a - -; Close SRAM if we were dealing with a sBoxMon. - ld a, [MonType] - cp BOXMON - call z, CloseSRAM - - -; We need the gender ratio to do anything with this. - push bc - ld a, [CurPartySpecies] - dec a - ld hl, BaseData + BaseGender - CurBaseData - ld bc, BaseData1 - BaseData - call AddNTimes - pop bc - - ld a, BANK(BaseData) - call GetFarByte - - -; The higher the ratio, the more likely the monster is to be female. - - cp $ff - jr z, .Genderless - - and a - jr z, .Male - - cp $fe - jr z, .Female - -; Values below the ratio are male, and vice versa. - cp b - jr c, .Male - -.Female - xor a - ret - -.Male - ld a, 1 - and a - ret - -.Genderless - scf - ret -; 50c50 - -Function50c50: ; 50c50 - ld a, [wd0eb] - inc a - ld c, a - ld a, $4 - sub c - ld b, a - push hl - ld a, [Buffer1] - ld e, a - ld d, $0 - ld a, $3e - call Function50cc9 - ld a, b - and a - jr z, .asm_50c6f - ld c, a - ld a, $e3 - call Function50cc9 - -.asm_50c6f - pop hl -rept 3 - inc hl -endr - ld d, h - ld e, l - ld hl, TempMonMoves - ld b, 0 -.asm_50c7a - ld a, [hli] - and a - jr z, .asm_50cc8 - push bc - push hl - push de - ld hl, MenuSelection2 - ld a, [hl] - push af - ld [hl], b - push hl - callab GetMaxPPOfMove - pop hl - pop af - ld [hl], a - pop de - pop hl - push hl - ld bc, TempMonPP - (TempMonMoves + 1) - add hl, bc - ld a, [hl] - and $3f - ld [StringBuffer1 + 4], a - ld h, d - ld l, e - push hl - ld de, StringBuffer1 + 4 - lb bc, 1, 2 - call PrintNum - ld a, $f3 - ld [hli], a - ld de, wd265 - lb bc, 1, 2 - call PrintNum - pop hl - ld a, [Buffer1] - ld e, a - ld d, 0 - add hl, de - ld d, h - ld e, l - pop hl - pop bc - inc b - ld a, b - cp NUM_MOVES - jr nz, .asm_50c7a - -.asm_50cc8 - ret -; 50cc9 - -Function50cc9: ; 50cc9 -.asm_50cc9 - ld [hli], a - ld [hld], a - add hl, de - dec c - jr nz, .asm_50cc9 - ret -; 50cd0 - -Function50cd0: ; 50cd0 -.asm_50cd0 - ld [hl], $32 - inc hl - ld [hl], $3e - dec hl - add hl, de - dec c - jr nz, .asm_50cd0 - ret -; 50cdb - -Function50cdb: ; unreferenced predef - push hl - push hl - ld hl, PartyMonNicknames - ld a, [CurPartyMon] - call GetNick - pop hl - call PlaceString - call CopyPkmnToTempMon - pop hl - ld a, [CurPartySpecies] - cp EGG - jr z, .asm_50d09 - push hl - ld bc, -12 - add hl, bc - ld b, $0 - call DrawEnemyHP - pop hl - ld bc, 5 - add hl, bc - push de - call PrintLevel - pop de - -.asm_50d09 - ret -; 50d0a - - -PlaceStatusString: ; 50d0a - push de -rept 2 - inc de -endr - ld a, [de] - ld b, a - inc de - ld a, [de] - or b - pop de - jr nz, PlaceNonFaintStatus - push de - ld de, FntString - call CopyStatusString - pop de - ld a, $1 - and a - ret -; 50d22 - -FntString: ; 50d22 - db "FNT@" -; 50d25 - -CopyStatusString: ; 50d25 - ld a, [de] - inc de - ld [hli], a - ld a, [de] - inc de - ld [hli], a - ld a, [de] - ld [hl], a - ret -; 50d2e - -PlaceNonFaintStatus: ; 50d2e - push de - ld a, [de] - ld de, PsnString - bit PSN, a - jr nz, .place - ld de, BrnString - bit BRN, a - jr nz, .place - ld de, FrzString - bit FRZ, a - jr nz, .place - ld de, ParString - bit PAR, a - jr nz, .place - ld de, SlpString - and SLP - jr z, .no_status - -.place - call CopyStatusString - ld a, $1 - and a - -.no_status - pop de - ret -; 50d5b - -SlpString: db "SLP@" -PsnString: db "PSN@" -BrnString: db "BRN@" -FrzString: db "FRZ@" -ParString: db "PAR@" -; 50d6f - -ListMoves: ; 50d6f -; List moves at hl, spaced every [Buffer1] tiles. - ld de, wListMoves_MoveIndicesBuffer - ld b, $0 -.moves_loop - ld a, [de] - inc de - and a - jr z, .no_more_moves - push de - push hl - push hl - ld [CurSpecies], a - ld a, MOVE_NAME - ld [wNamedObjectTypeBuffer], a - call GetName - ld de, StringBuffer1 - pop hl - push bc - call PlaceString - pop bc - ld a, b - ld [wd0eb], a - inc b - pop hl - push bc - ld a, [Buffer1] - ld c, a - ld b, 0 - add hl, bc - pop bc - pop de - ld a, b - cp NUM_MOVES - jr z, .done - jr .moves_loop - -.no_more_moves - ld a, b -.nonmove_loop - push af - ld [hl], "-" - ld a, [Buffer1] - ld c, a - ld b, 0 - add hl, bc - pop af - inc a - cp NUM_MOVES - jr nz, .nonmove_loop - -.done - ret -; 50db9 - -Function50db9: ; 50db9 - ld a, [wd263] - - cp $1 - jr nz, .check_party_ot_name - ld hl, OTPartyCount - ld de, OTPartyMonOT - ld a, ENEMY_OT_NAME - jr .done -.check_party_ot_name - - cp $4 - jr nz, .check_mon_name - ld hl, PartyCount - ld de, PartyMonOT - ld a, PARTY_OT_NAME - jr .done -.check_mon_name - - cp $5 - jr nz, .check_item_name - ld hl, CurMart - ld de, PokemonNames - ld a, PKMN_NAME - jr .done -.check_item_name - - cp $2 - jr nz, .check_ob_item_name - ld hl, NumItems - ld de, ItemNames - ld a, ITEM_NAME - jr .done -.check_ob_item_name - - ld hl, CurMart - ld de, ItemNames - ld a, ITEM_NAME - -.done - ld [wNamedObjectTypeBuffer], a - ld a, l - ld [wd100], a - ld a, h - ld [wd101], a - ld a, e - ld [wd102], a - ld a, d - ld [wd103], a - ld bc, ItemAttributes - ld a, c - ld [wd104], a - ld a, b - ld [wd105], a - ret -; 50e1b - - -CalcLevel: ; 50e1b - ld a, [TempMonSpecies] - ld [CurSpecies], a - call GetBaseData - ld d, 1 -.next_level - inc d - ld a, d - cp (MAX_LEVEL + 1) % $100 - jr z, .got_level - call CalcExpAtLevel - push hl - ld hl, TempMonExp + 2 - ld a, [hProduct + 3] - ld c, a - ld a, [hld] - sub c - ld a, [hProduct + 2] - ld c, a - ld a, [hld] - sbc c - ld a, [hProduct + 1] - ld c, a - ld a, [hl] - sbc c - pop hl - jr nc, .next_level - -.got_level - dec d - ret -; 50e47 - - - -CalcExpAtLevel: ; 50e47 -; (a/b)*n**3 + c*n**2 + d*n - e - ld a, [BaseGrowthRate] -rept 2 - add a -endr - ld c, a - ld b, 0 - ld hl, GrowthRates - add hl, bc -; Cube the level - call .LevelSquared - ld a, d - ld [hMultiplier], a - call Multiply - -; Multiply by a - ld a, [hl] - and $f0 - swap a - ld [hMultiplier], a - call Multiply -; Divide by b - ld a, [hli] - and $f - ld [hDivisor], a - ld b, 4 - call Divide -; Push the cubic term to the stack - ld a, [hQuotient + 0] - push af - ld a, [hQuotient + 1] - push af - ld a, [hQuotient + 2] - push af -; Square the level and multiply by the lower 7 bits of c - call .LevelSquared - ld a, [hl] - and $7f - ld [hMultiplier], a - call Multiply -; Push the absolute value of the quadratic term to the stack - ld a, [hProduct + 1] - push af - ld a, [hProduct + 2] - push af - ld a, [hProduct + 3] - push af - ld a, [hli] - push af -; Multiply the level by d - xor a - ld [hMultiplicand + 0], a - ld [hMultiplicand + 1], a - ld a, d - ld [hMultiplicand + 2], a - ld a, [hli] - ld [hMultiplier], a - call Multiply -; Subtract e - ld b, [hl] - ld a, [hProduct + 3] - sub b - ld [hMultiplicand + 2], a - ld b, $0 - ld a, [hProduct + 2] - sbc b - ld [hMultiplicand + 1], a - ld a, [hProduct + 1] - sbc b - ld [hMultiplicand], a -; If bit 7 of c is set, c is negative; otherwise, it's positive - pop af - and $80 - jr nz, .subtract -; Add c*n**2 to (d*n - e) - pop bc - ld a, [hProduct + 3] - add b - ld [hMultiplicand + 2], a - pop bc - ld a, [hProduct + 2] - adc b - ld [hMultiplicand + 1], a - pop bc - ld a, [hProduct + 1] - adc b - ld [hMultiplicand], a - jr .done_quadratic - -.subtract -; Subtract c*n**2 from (d*n - e) - pop bc - ld a, [hProduct + 3] - sub b - ld [hMultiplicand + 2], a - pop bc - ld a, [hProduct + 2] - sbc b - ld [hMultiplicand + 1], a - pop bc - ld a, [hProduct + 1] - sbc b - ld [hMultiplicand], a - -.done_quadratic -; Add (a/b)*n**3 to (d*n - e +/- c*n**2) - pop bc - ld a, [hProduct + 3] - add b - ld [hMultiplicand + 2], a - pop bc - ld a, [hProduct + 2] - adc b - ld [hMultiplicand + 1], a - pop bc - ld a, [hProduct + 1] - adc b - ld [hMultiplicand], a - ret -; 50eed - -.LevelSquared: ; 50eed - xor a - ld [hMultiplicand + 0], a - ld [hMultiplicand + 1], a - ld a, d - ld [hMultiplicand + 2], a - ld [hMultiplier], a - jp Multiply -; 50efa - -GrowthRates: ; 50efa - -growth_rate: MACRO -; [1]/[2]*n**3 + [3]*n**2 + [4]*n - [5] - dn \1, \2 - if \3 & $80 ; signed - db -\3 | $80 - else - db \3 - endc - db \4, \5 -ENDM - - growth_rate 1, 1, 0, 0, 0 ; Medium Fast - growth_rate 3, 4, 10, 0, 30 ; Slightly Fast - growth_rate 3, 4, 20, 0, 70 ; Slightly Slow - growth_rate 6, 5, -15, 100, 140 ; Medium Slow - growth_rate 4, 5, 0, 0, 0 ; Fast - growth_rate 5, 4, 0, 0, 0 ; Slow -; 50f12 - -_SwitchPartyMons: - ld a, [wd0e3] - dec a - ld [wd1ec], a - ld b, a - ld a, [MenuSelection2] - dec a - ld [Buffer2], a ; wd1eb (aliases: MovementType) - cp b - jr z, .skip - call .SwapPartymonViaSRAM - ld a, [wd1ec] - call .ClearSprite - ld a, [Buffer2] ; wd1eb (aliases: MovementType) - call .ClearSprite -.skip - ret - -.ClearSprite: ; 50f34 (14:4f34) - push af - hlcoord 0, 1 - ld bc, 2 * SCREEN_WIDTH - call AddNTimes - ld bc, 2 * SCREEN_WIDTH - ld a, " " - call ByteFill - pop af - ld hl, Sprites - ld bc, $10 - call AddNTimes - ld de, $4 - ld c, $4 -.gfx_loop - ld [hl], $a0 - add hl, de - dec c - jr nz, .gfx_loop - ld de, SFX_SWITCH_POKEMON - call WaitPlaySFX - ret - -.SwapPartymonViaSRAM: ; 50f62 (14:4f62) - push hl - push de - push bc - ld bc, PartySpecies - ld a, [Buffer2] ; wd1eb (aliases: MovementType) - ld l, a - ld h, $0 - add hl, bc - ld d, h - ld e, l - ld a, [Buffer3] - ld l, a - ld h, $0 - add hl, bc - ld a, [hl] - push af - ld a, [de] - ld [hl], a - pop af - ld [de], a - ld a, [Buffer2] ; wd1eb (aliases: MovementType) - ld hl, PartyMons ; wdcdf (aliases: PartyMon1, PartyMon1Species) - ld bc, PARTYMON_STRUCT_LENGTH - call AddNTimes - push hl - ld de, wd002 - ld bc, PARTYMON_STRUCT_LENGTH - call CopyBytes - ld a, [Buffer3] - ld hl, PartyMons ; wdcdf (aliases: PartyMon1, PartyMon1Species) - ld bc, PARTYMON_STRUCT_LENGTH - call AddNTimes - pop de - push hl - ld bc, PARTYMON_STRUCT_LENGTH - call CopyBytes - pop de - ld hl, wd002 - ld bc, PARTYMON_STRUCT_LENGTH - call CopyBytes - ld a, [Buffer2] ; wd1eb (aliases: MovementType) - ld hl, PartyMonOT - call SkipNames - push hl - call .CopyNameTowd002 - ld a, [Buffer3] - ld hl, PartyMonOT - call SkipNames - pop de - push hl - call .CopyName - pop de - ld hl, wd002 - call .CopyName - ld hl, PartyMonNicknames - ld a, [Buffer2] ; wd1eb (aliases: MovementType) - call SkipNames - push hl - call .CopyNameTowd002 - ld hl, PartyMonNicknames - ld a, [Buffer3] - call SkipNames - pop de - push hl - call .CopyName - pop de - ld hl, wd002 - call .CopyName - ld hl, sPartyScratch1 - ld a, [Buffer2] ; wd1eb (aliases: MovementType) - ld bc, SCRATCHMON_STRUCT_LENGTH - call AddNTimes - push hl - ld de, wd002 - ld bc, SCRATCHMON_STRUCT_LENGTH - ld a, BANK(sPartyScratch1) - call GetSRAMBank - call CopyBytes - ld hl, sPartyScratch1 - ld a, [Buffer3] - ld bc, SCRATCHMON_STRUCT_LENGTH - call AddNTimes - pop de - push hl - ld bc, SCRATCHMON_STRUCT_LENGTH - call CopyBytes - pop de - ld hl, wd002 - ld bc, SCRATCHMON_STRUCT_LENGTH - call CopyBytes - call CloseSRAM - pop bc - pop de - pop hl + callba CalcExpAtLevel +rept 2 + ld hl, TempMonExp + 2 +endr + ld a, [$ffb6] + sub [hl] + dec hl + ld [wd1ec], a + ld a, [$ffb5] + sbc [hl] + dec hl + ld [Buffer2], a ; wd1eb (aliases: MovementType) + ld a, [hQuotient] + sbc [hl] + ld [Buffer1], a ; wd1ea (aliases: MagikarpLength) + ret +.asm_4e111 + ld hl, Buffer1 ; wd1ea (aliases: MagikarpLength) + xor a +rept 2 + ld [hli], a +endr + ld [hl], a ret +; 4e119 (13:6119) -.CopyNameTowd002: ; 51036 (14:5036) - ld de, wd002 +String_4e119: ; 4e119 + db "STATUS/" + next "TYPE/@" +; 4e127 -.CopyName: ; 51039 (14:5039) - ld bc, NAME_LENGTH - call CopyBytes - ret +String_4e127: ; 4e127 + db "OK @" +; 4e12b -GetUnownLetter: ; 51040 -; Return Unown letter in UnownLetter based on DVs at hl +String_4e12b: ; 4e12b + db "EXP POINTS@" +; 4e136 -; Take the middle 2 bits of each DV and place them in order: -; atk def spd spc -; .ww..xx. .yy..zz. +String_4e136: ; 4e136 + db "LEVEL UP@" +; 4e13f - ; atk - ld a, [hl] - and %01100000 - sla a - ld b, a - ; def - ld a, [hli] - and %00000110 - swap a - srl a - or b - ld b, a +String_4e13f: ; 4e13f + db "TO@" +; 4e142 - ; spd - ld a, [hl] - and %01100000 - swap a - sla a - or b - ld b, a - ; spc - ld a, [hl] - and %00000110 - srl a - or b +String_4e142: ; 4e142 + db "#RUS@" +; 4e147 -; Divide by 10 to get 0-25 - ld [hDividend + 3], a - xor a - ld [hDividend], a - ld [hDividend + 1], a - ld [hDividend + 2], a - ld a, 10 - ld [hDivisor], a - ld b, 4 - call Divide +Function4e147: ; 4e147 (13:6147) + ld de, String_4e1a0 + hlcoord 0, 8 + call PlaceString + call Function4e189 + hlcoord 8, 8 + call PlaceString + ld de, String_4e1a9 + hlcoord 0, 10 + call PlaceString + ld hl, TempMonMoves + ld de, wListMoves_MoveIndicesBuffer + ld bc, NUM_MOVES + call CopyBytes + hlcoord 8, 10 + ld a, SCREEN_WIDTH * 2 + ld [Buffer1], a + predef ListMoves + hlcoord 12, 11 + ld a, $28 + ld [Buffer1], a + predef Function50c50 + ret -; Increment to get 1-26 - ld a, [hQuotient + 2] - inc a - ld [UnownLetter], a +Function4e189: ; 4e189 (13:6189) + ld de, String_4e1a5 + ld a, [TempMonItem] + and a + ret z + ld b, a + callba Function28771 + ld a, b + ld [wd265], a + call GetItemName ret -; 51077 +; 4e1a0 (13:61a0) + +String_4e1a0: ; 4e1a0 + db "ITEM@" +; 4e1a5 +String_4e1a5: ; 4e1a5 + db "---@" +; 4e1a9 -GetFrontpic: ; 51077 - ld a, [CurPartySpecies] - ld [CurSpecies], a - call IsAPokemon - ret c - ld a, [rSVBK] - push af - call _GetFrontpic - pop af - ld [rSVBK], a +String_4e1a9: ; 4e1a9 + db "MOVE@" +; 4e1ae + +Function4e1ae: ; 4e1ae (13:61ae) + call Function4e1cc + hlcoord 10, 8 + ld de, $14 + ld b, $a + ld a, $31 +.asm_4e1bb + ld [hl], a + add hl, de + dec b + jr nz, .asm_4e1bb + hlcoord 11, 8 + ld bc, $6 + predef PrintTempMonStats ret -; 5108b -Function5108b: ; 5108b - ld a, [CurPartySpecies] - ld [CurSpecies], a - call IsAPokemon - ret c - ld a, [rSVBK] - push af - xor a - ld [hBGMapMode], a - call _GetFrontpic - call Function51103 - pop af - ld [rSVBK], a +Function4e1cc: ; 4e1cc (13:61cc) + ld de, IDNoString + hlcoord 0, 9 + call PlaceString + ld de, OTString + hlcoord 0, 12 + call PlaceString + hlcoord 2, 10 + lb bc, PRINTNUM_LEADINGZEROS | 2, 5 + ld de, TempMonID + call PrintNum + ld hl, Unknown_4e216 + call Function4e528 + call Function4e505 + callba CheckNickErrors + hlcoord 2, 13 + call PlaceString + ld a, [TempMonCaughtGender] + and a + jr z, .asm_4e215 + cp $7f + jr z, .asm_4e215 + and $80 + ld a, "♂" + jr z, .asm_4e211 + ld a, "♀" +.asm_4e211 + hlcoord 9, 13 + ld [hl], a +.asm_4e215 ret -; 510a5 +; 4e216 (13:6216) -_GetFrontpic: ; 510a5 - push de - call GetBaseData - ld a, [BasePicSize] - and $f - ld b, a - push bc - call GetFrontpicPointer - ld a, $6 - ld [rSVBK], a - ld a, b - ld de, w6_d000 + $800 - call FarDecompress - pop bc - ld hl, w6_d000 - ld de, w6_d000 + $800 - call Function512ab - pop hl - push hl - ld de, w6_d000 - ld c, 7 * 7 - ld a, [hROMBank] - ld b, a - call Get2bpp - pop hl +Unknown_4e216: ; 4e216 + dw PartyMonOT + dw OTPartyMonOT + dw sBoxMonOT + dw wd00d +; 4e21e + +IDNoString: ; 4e21e + db $73, "№.@" + +OTString: ; 4e222 + db "OT/@" +; 4e226 + + +Function4e226: ; 4e226 (13:6226) + ld hl, TempMonDVs + predef GetUnownLetter + call Function4e2ad + jr c, .asm_4e238 + and a + jr z, .asm_4e23f + jr .asm_4e246 +.asm_4e238 + call Function4e271 + call SetPalettes + ret +.asm_4e23f + call Function4e253 + call SetPalettes + ret +.asm_4e246 + call SetPalettes + call Function4e253 + ld a, [CurPartySpecies] + call PlayCry2 ret -; 510d7 - -GetFrontpicPointer: ; 510d7 -GLOBAL PicPointers, UnownPicPointers +Function4e253: ; 4e253 (13:6253) + ld hl, wcf64 + set 5, [hl] ld a, [CurPartySpecies] cp UNOWN - jr z, .unown - ld a, [CurPartySpecies] - ld d, BANK(PicPointers) - jr .ok - -.unown - ld a, [UnownLetter] - ld d, BANK(UnownPicPointers) - -.ok - ld hl, PicPointers ; UnownPicPointers - dec a - ld bc, 6 - call AddNTimes - ld a, d - call GetFarByte - call FixPicBank - push af - inc hl - ld a, d - call GetFarHalfword - pop bc + jr z, .asm_4e266 + hlcoord 0, 0 + call PrepMonFrontpic ret -; 51103 - -Function51103: ; 51103 - ld a, $1 - ld [rVBK], a - push hl - ld de, w6_d000 - ld c, 7 * 7 - ld a, [hROMBank] - ld b, a - call Get2bpp - pop hl - ld de, 7 * 7 * $10 - add hl, de - push hl - ld a, $1 - ld hl, BasePicSize - call GetFarWRAMByte - pop hl - and $f - ld de, w6_d000 + $800 + 5 * 5 * $10 - ld c, 5 * 5 - cp 5 - jr z, .asm_5113b - ld de, w6_d000 + $800 + 6 * 6 * $10 - ld c, 6 * 6 - cp 6 - jr z, .asm_5113b - ld de, w6_d000 + $800 + 7 * 7 * $10 - ld c, 7 * 7 -.asm_5113b - - push hl - push bc - call Function5114f - pop bc - pop hl - ld de, w6_d000 - ld a, [hROMBank] - ld b, a - call Get2bpp +.asm_4e266 xor a - ld [rVBK], a + ld [wc2c6], a + hlcoord 0, 0 + call _PrepMonFrontpic ret -; 5114f -Function5114f: ; 5114f - ld hl, w6_d000 - swap c - ld a, c - and $f - ld b, a - ld a, c - and $f0 - ld c, a - push bc - call Function512f2 - pop bc -.asm_51161 - push bc - ld c, $0 - call Function512f2 - pop bc - dec b - jr nz, .asm_51161 +Function4e271: ; 4e271 (13:6271) + ld a, [CurPartySpecies] + cp UNOWN + jr z, .asm_4e281 + ld a, $1 + ld [wc2c6], a + call Function4e289 + ret +.asm_4e281 + xor a + ld [wc2c6], a + call Function4e289 ret -; 5116c -GetBackpic: ; 5116c +Function4e289: ; 4e289 (13:6289) ld a, [CurPartySpecies] call IsAPokemon ret c - - ld a, [CurPartySpecies] - ld b, a - ld a, [UnownLetter] - ld c, a - ld a, [rSVBK] - push af - ld a, $6 - ld [rSVBK], a - push de - - ; These are assumed to be at the same - ; address in their respective banks. - GLOBAL PicPointers, UnownPicPointers - ld hl, PicPointers ; UnownPicPointers - ld a, b - ld d, BANK(PicPointers) - cp UNOWN - jr nz, .ok - ld a, c - ld d, BANK(UnownPicPointers) -.ok - dec a - ld bc, 6 - call AddNTimes - ld bc, 3 - add hl, bc - ld a, d - call GetFarByte - call FixPicBank - push af - inc hl - ld a, d - call GetFarHalfword - ld de, w6_d000 - pop af - call FarDecompress - ld hl, w6_d000 - ld c, 6 * 6 - call Function5127c - pop hl - ld de, w6_d000 - ld a, [hROMBank] - ld b, a - call Get2bpp - pop af - ld [rSVBK], a + call Function4e307 + ld de, VTiles2 tile $00 + predef Function5108b + hlcoord 0, 0 + ld d, $0 + ld e, $2 + predef LoadMonAnimation + ld hl, wcf64 + set 6, [hl] ret -; 511c5 - -FixPicBank: ; 511c5 -; This is a thing for some reason. - push hl - push bc - sub PICS_1 - $36 - ld c, a - ld b, 0 - ld hl, Unknown_511d4 - add hl, bc - ld a, [hl] - pop bc - pop hl +Function4e2ad: ; 4e2ad (13:62ad) + ld a, [MonType] + ld hl, Jumptable_4e2b5 + rst JumpTable ret -; 511d4 -Unknown_511d4: ; 511d4 - db PICS_1 - db PICS_2 - db PICS_3 - db PICS_4 - db PICS_5 - db PICS_6 - db PICS_7 - db PICS_8 - db PICS_9 - db PICS_10 - db PICS_11 - db PICS_12 - db PICS_13 - db PICS_14 - db PICS_15 - db PICS_16 - db PICS_17 - db PICS_18 - db PICS_19 - db PICS_19 + 1 - db PICS_19 + 2 - db PICS_19 + 3 - db PICS_19 + 4 - db PICS_19 + 5 +Jumptable_4e2b5: ; 4e2b5 (13:62b5) + dw Function4e2bf + dw Function4e2cf + dw Function4e2d1 + dw Function4e2ed + dw Function4e301 -Function511ec: ; 511ec - ld a, c - push de - ld hl, PicPointers - dec a - ld bc, 6 - call AddNTimes - ld a, BANK(PicPointers) - call GetFarByte - call FixPicBank - push af - inc hl - ld a, BANK(PicPointers) - call GetFarHalfword - pop af - pop de - call FarDecompress - ret -; 0x5120d +Function4e2bf: ; 4e2bf (13:62bf) + ld a, [CurPartyMon] + ld hl, PartyMons ; wdcdf (aliases: PartyMon1, PartyMon1Species) + ld bc, PARTYMON_STRUCT_LENGTH + call AddNTimes + ld b, h + ld c, l + jr Function4e2f2 -GetTrainerPic: ; 5120d - ld a, [TrainerClass] - and a - ret z - cp NUM_TRAINER_CLASSES - ret nc - call WaitBGMap +Function4e2cf: ; 4e2cf (13:62cf) xor a - ld [hBGMapMode], a - ld hl, TrainerPicPointers - ld a, [TrainerClass] - dec a - ld bc, 3 + ret + +Function4e2d1: ; 4e2d1 (13:62d1) + ld hl, sBoxMons + ld bc, $30 + ld a, [CurPartyMon] call AddNTimes - ld a, [rSVBK] - push af - ld a, $6 - ld [rSVBK], a - push de - ld a, BANK(TrainerPicPointers) - call GetFarByte - call FixPicBank + ld b, h + ld c, l + ld a, $1 + call GetSRAMBank + call Function4e2f2 push af - inc hl - ld a, BANK(TrainerPicPointers) - call GetFarHalfword - pop af - ld de, w6_d000 - call FarDecompress - pop hl - ld de, w6_d000 - ld c, 7 * 7 - ld a, [hROMBank] - ld b, a - call Get2bpp + call CloseSRAM pop af - ld [rSVBK], a - call WaitBGMap - ld a, $1 - ld [hBGMapMode], a ret -; 5125d - +Function4e2ed: ; 4e2ed (13:62ed) + ld bc, TempMonSpecies ; wd10e (aliases: TempMon) + jr Function4e2f2 -DecompressPredef: ; 5125d -; Decompress lz data from b:hl to scratch space at 6:d000, then copy it to address de. +Function4e2f2: ; 4e2f2 (13:62f2) + ld a, [CurPartySpecies] + cp EGG + jr z, .asm_4e2fe + call CheckFaintedFrzSlp + jr c, Function4e305 +.asm_4e2fe + xor a + scf + ret - ld a, [rSVBK] - push af - ld a, 6 - ld [rSVBK], a +Function4e301: ; 4e301 (13:6301) + ld a, $1 + and a + ret +Function4e305: ; 4e305 (13:6305) + xor a + ret +Function4e307: ; 4e307 (13:6307) + nop + push hl push de push bc - ld a, b - ld de, w6_d000 - call FarDecompress - pop bc - ld de, w6_d000 - pop hl - ld a, [hROMBank] - ld b, a + push af + call DelayFrame + ld a, [rVBK] + push af + ld a, $1 + ld [rVBK], a + ld de, TextBoxSpaceGFX + lb bc, BANK(TextBoxSpaceGFX), 1 + ld hl, VTiles2 tile $7f call Get2bpp - pop af - ld [rSVBK], a + ld [rVBK], a + pop af + pop bc + pop de + pop hl ret -; 5127c - +; 4e32a (13:632a) -Function5127c: ; 5127c - push de - push bc - ld a, [wc2c6] - and a - jr z, .asm_512a8 - ld a, c - cp 7 * 7 - ld de, 7 * 7 * $10 - jr z, .asm_51296 - cp 6 * 6 - ld de, 6 * 6 * $10 - jr z, .asm_51296 - ld de, 5 * 5 * $10 +Unknown_4e32a: ; 4e32a +; A blank tile? + ds 16 +; 4e33a -.asm_51296 - ld a, [hl] - ld b, $0 - ld c, $8 -.asm_5129b - rra - rl b - dec c - jr nz, .asm_5129b - ld a, b - ld [hli], a - dec de - ld a, e - or d - jr nz, .asm_51296 +EggStatsScreen: ; 4e33a + xor a + ld [hBGMapMode], a + ld hl, wcda1 + call SetHPPal + ld b, SCGB_03 + call GetSGBLayout + call Function4df8f + ld de, EggString + hlcoord 8, 1 + call PlaceString + ld de, IDNoString + hlcoord 8, 3 + call PlaceString + ld de, OTString + hlcoord 8, 5 + call PlaceString + ld de, FiveQMarkString + hlcoord 11, 3 + call PlaceString + ld de, FiveQMarkString + hlcoord 11, 5 + call PlaceString + ld a, [TempMonHappiness] ; egg status + ld de, EggSoonString + cp $6 + jr c, .picked + ld de, EggCloseString + cp $b + jr c, .picked + ld de, EggMoreTimeString + cp $29 + jr c, .picked + ld de, EggALotMoreTimeString +.picked + hlcoord 1, 9 + call PlaceString + ld hl, wcf64 + set 5, [hl] + call SetPalettes ; pals + call DelayFrame + hlcoord 0, 0 + call PrepMonFrontpic + callba Function10402d + call Function4e497 -.asm_512a8 - pop bc - pop de + ld a, [TempMonHappiness] + cp 6 + ret nc + ld de, SFX_2_BOOPS + call PlaySFX ret -; 512ab +; 0x4e3c0 -Function512ab: ; 512ab - ld a, b - cp 6 - jr z, .six - cp 5 - jr z, .five +EggString: ; 4e3c0 + db "EGG@" -.seven - ld c, $70 - call Function512f2 - dec b - jr nz, .seven - ret +FiveQMarkString: ; 4e3c4 + db "?????@" -.six - ld c, $70 - xor a - call .Fill -.asm_512c3 - ld c, $10 - xor a - call .Fill - ld c, $60 - call Function512f2 - dec b - jr nz, .asm_512c3 - ret +EggSoonString: ; 0x4e3ca + db "It's making sounds" + next "inside. It's going" + next "to hatch soon!@" -.five - ld c, $70 - xor a - call .Fill -.asm_512d8 - ld c, $20 - xor a - call .Fill - ld c, $50 - call Function512f2 - dec b - jr nz, .asm_512d8 - ld c, $70 - xor a - call .Fill - ret +EggCloseString: ; 0x4e3fd + db "It moves around" + next "inside sometimes." + next "It must be close" + next "to hatching.@" + +EggMoreTimeString: ; 0x4e43d + db "Wonder what's" + next "inside? It needs" + next "more time, though.@" -.Fill - ld [hli], a - dec c - jr nz, .Fill - ret -; 512f2 +EggALotMoreTimeString: ; 0x4e46e + db "This EGG needs a" + next "lot more time to" + next "hatch.@" +; 0x4e497 -Function512f2: ; 512f2 - ld a, [wc2c6] - and a - jr nz, .asm_512ff -.asm_512f8 - ld a, [de] - inc de - ld [hli], a - dec c - jr nz, .asm_512f8 + +Function4e497: ; 4e497 (13:6497) + call Function4e2ad + ret nc + ld a, [TempMonHappiness] + ld e, $7 + cp $6 + jr c, .asm_4e4ab + ld e, $8 + cp $b + jr c, .asm_4e4ab + ret +.asm_4e4ab + push de + ld a, $1 + ld [wc2c6], a + call Function4e307 + ld de, VTiles2 tile $00 + predef Function5108b + pop de + hlcoord 0, 0 + ld d, $0 + predef LoadMonAnimation + ld hl, wcf64 + set 6, [hl] ret -.asm_512ff +Function4e4cd: ; 4e4cd (13:64cd) + hlcoord 13, 5 + ld a, $36 + call Function4e4f7 + hlcoord 15, 5 + ld a, $36 + call Function4e4f7 + hlcoord 17, 5 + ld a, $36 + call Function4e4f7 + ld a, c + cp $2 + ld a, $3a + hlcoord 13, 5 + jr c, Function4e4f7 + hlcoord 15, 5 + jr z, Function4e4f7 + hlcoord 17, 5 + +Function4e4f7: ; 4e4f7 (13:64f7) push bc -.asm_51300 - ld a, [de] - inc de - ld b, a - xor a - rept 8 - rr b - rla - endr ld [hli], a - dec c - jr nz, .asm_51300 + inc a + ld [hld], a + ld bc, $14 + add hl, bc + inc a + ld [hli], a + inc a + ld [hl], a pop bc ret -; 51322 -Function51322: ; 51322 - ld a, BANK(sBoxCount) +Function4e505: ; 4e505 (13:6505) + ld de, StringBuffer1 + ld bc, $b + jr .asm_4e50d +.asm_4e50d + ld a, [MonType] + cp BOXMON + jr nz, .asm_4e522 + ld a, BANK(sBoxMonNicknames) call GetSRAMBank - ld hl, sBoxCount - call Function513cb - ld a, [sBoxCount] - dec a - ld [wd265], a - ld hl, sBoxMonNicknames - ld bc, PKMN_NAME_LENGTH - ld de, wd002 - call Function513e0 - ld a, [sBoxCount] - dec a - ld [wd265], a - ld hl, sBoxMonOT - ld bc, NAME_LENGTH - ld de, wd00d - call Function513e0 - ld a, [sBoxCount] - dec a - ld [wd265], a - ld hl, sBoxMons - ld bc, BOXMON_STRUCT_LENGTH - ld de, wd018 - call Function513e0 - ld hl, wd01a - ld de, TempMonMoves - ld bc, NUM_MOVES - call CopyBytes - ld hl, wd02f - ld de, TempMonPP - ld bc, NUM_MOVES + push de call CopyBytes - ld a, [CurPartyMon] - ld b, a - callba Functiondcb6 - jp CloseSRAM -; 5138b - -Function5138b: ; 5138b - ld hl, PartyCount - call Function513cb - ld a, [PartyCount] - dec a - ld [wd265], a - ld hl, PartyMonNicknames - ld bc, PKMN_NAME_LENGTH - ld de, wd002 - call Function513e0 - ld a, [PartyCount] - dec a - ld [wd265], a - ld hl, PartyMonOT - ld bc, NAME_LENGTH - ld de, wd00d - call Function513e0 - ld a, [PartyCount] - dec a - ld [wd265], a - ld hl, PartyMons - ld bc, PARTYMON_STRUCT_LENGTH - ld de, wd018 - call Function513e0 - ret -; 513cb - -Function513cb: ; 513cb - inc [hl] - inc hl - ld a, [CurPartyMon] - ld c, a - ld b, 0 - add hl, bc - ld a, [CurPartySpecies] - ld c, a -.asm_513d8 - ld a, [hl] - ld [hl], c - inc hl - inc c - ld c, a - jr nz, .asm_513d8 + pop de + call CloseSRAM ret -; 513e0 - -Function513e0: ; 513e0 - push de - push hl - push bc - ld a, [wd265] - dec a - call AddNTimes - push hl - add hl, bc - ld d, h - ld e, l - pop hl -.asm_513ef - push bc - ld a, [wd265] - ld b, a - ld a, [CurPartyMon] - cp b - pop bc - jr z, .asm_51415 - push hl +.asm_4e522 push de - push bc call CopyBytes - pop bc - pop de - pop hl - push hl - ld a, l - sub c - ld l, a - ld a, h - sbc b - ld h, a pop de - ld a, [wd265] - dec a - ld [wd265], a - jr .asm_513ef - -.asm_51415 - pop bc - pop hl - ld a, [CurPartyMon] - call AddNTimes - ld d, h - ld e, l - pop hl - call CopyBytes ret -; 51424 - -BaseData:: -INCLUDE "data/base_stats.asm" - -PokemonNames:: -INCLUDE "data/pokemon_names.asm" - -Unknown_53d84: ; unreferenced - db $1a, $15 - db $33, $16 - db $4b, $17 - db $62, $18 - db $79, $19 - db $90, $1a - db $a8, $1b - db $c4, $1c - db $e0, $1d - db $f6, $1e - db $ff, $1f - db $ff, $20 -; 53d9c -UnknownEggPic:: ; 53d9c -; Another egg pic. This is shifted up a few pixels. -INCBIN "gfx/misc/unknown_egg.5x5.2bpp.lz" -; 53e2e +Function4e528: ; 4e528 (13:6528) + ld a, [MonType] + add a + ld c, a + ld b, 0 + add hl, bc + ld a, [hli] + ld h, [hl] + ld l, a + ld a, [MonType] + cp $3 + ret z + ld a, [CurPartyMon] + jp SkipNames -SECTION "bank19", ROMX, BANK[$19] +CheckFaintedFrzSlp: ; 4e53f + ld hl, MON_HP + add hl, bc + ld a, [hli] + or [hl] + jr z, .fainted_frz_slp + ld hl, MON_STATUS + add hl, bc + ld a, [hl] + and (1 << FRZ) | SLP + jr nz, .fainted_frz_slp + and a + ret -INCLUDE "text/phone/extra.asm" +.fainted_frz_slp + scf + ret +; 4e554 +CatchTutorial:: ; 4e554 + ld a, [BattleType] + dec a + ld c, a + ld hl, .jumptable + ld b, 0 +rept 2 + add hl, bc +endr + ld a, [hli] + ld h, [hl] + ld l, a + jp [hl] +; 4e564 -SECTION "bank20", ROMX, BANK[$20] +.jumptable: ; 4e564 (13:6564) + dw .DudeTutorial + dw .DudeTutorial + dw .DudeTutorial +.DudeTutorial: ; 4e56a (13:656a) +; Back up your name to your Mom's name. + ld hl, PlayerName + ld de, MomsName + ld bc, NAME_LENGTH + call CopyBytes +; Copy Dude's name to your name + ld hl, .Dude + ld de, PlayerName + ld bc, NAME_LENGTH + call CopyBytes -DoPlayerMovement:: ; 80000 + call .LoadDudeData - call GetMovementInput - ld a, movement_step_sleep_1 - ld [MovementAnimation], a xor a - ld [wd041], a - call GetPlayerMovement - ld c, a - ld a, [MovementAnimation] - ld [wc2de], a - ret -; 80017 + ld [hJoyDown], a + ld [hJoyPressed], a + ld a, [Options] + push af + and $f8 + add $3 + ld [Options], a + ld hl, .AutoInput + ld a, BANK(.AutoInput) + call StartAutoInput + callab StartBattle + call StopAutoInput + pop af + ld [Options], a + ld hl, MomsName + ld de, PlayerName + ld bc, NAME_LENGTH + call CopyBytes + ret -GetMovementInput: ; 80017 +.LoadDudeData: ; 4e5b7 (13:65b7) + ld hl, OTPartyMon1 + ld [hl], BULBASAUR + inc hl + ld [hl], POTION + inc hl + ld [hl], POUND + inc hl + ld [hl], $ff + ld hl, OTPartyMon1Exp + 2 + ld [hl], $0 + inc hl + ld [hl], $ff + ld hl, OTPartyMon1CaughtGender + ld a, $1 + ld [hli], a + ld a, $5 +rept 2 + ld [hli], a +endr + ld [hl], $ff + ret +; 4e5da (13:65da) - ld a, [hJoyDown] - ld [CurInput], a +.Dude: ; 4e5da + db "DUDE@" +; 4e5df -; Standing downhill instead moves down. +.AutoInput: ; 4e5df + db NO_INPUT, $ff ; end +; 4e5e1 - ld hl, BikeFlags - bit 2, [hl] ; downhill - ret z +INCLUDE "engine/evolution_animation.asm" +Function4e929: ; mobile function + ld h, b + ld l, c + call Function4e930 ld c, a - and D_PAD - ret nz - - ld a, c - or D_DOWN - ld [CurInput], a ret -; 8002d - +; 4e930 -GetPlayerMovement: ; 8002d +Function4e930: ; 4e930 + ld a, [hli] + xor [hl] + ld c, a + jr z, .skip_male_trainers + srl c + srl c +.male_trainer_loop + srl c + ld a, c + cp MaleTrainersEnd - MaleTrainers - 1 + jr nc, .male_trainer_loop + inc c - ld a, [PlayerState] - cp PLAYER_NORMAL - jr z, .Normal - cp PLAYER_SURF - jr z, .Surf - cp PLAYER_SURF_PIKA - jr z, .Surf - cp PLAYER_BIKE - jr z, .Normal - cp PLAYER_SLIP - jr z, .Ice +.skip_male_trainers + ld a, [de] + cp $1 + ld hl, MaleTrainers + jr nz, .finished -.Normal - call CheckForcedMovementInput - call GetMovementAction - call CheckTileMovement - ret c - call CheckTurning - ret c - call TryStep - ret c - call TryJumpLedge - ret c - call CheckEdgeWarp - ret c - jr .NotMoving + ld hl, FemaleTrainers + ld a, c + and a + jr z, .finished -.Surf - call CheckForcedMovementInput - call GetMovementAction - call CheckTileMovement - ret c - call CheckTurning - ret c - call TrySurfStep - ret c - jr .NotMoving +.female_trainer_loop + srl c + ld a, c + cp FemaleTrainersEnd - FemaleTrainers - 1 + jr nc, .female_trainer_loop + inc c -.Ice - call CheckForcedMovementInput - call GetMovementAction - call CheckTileMovement - ret c - call CheckTurning - ret c - call TryStep - ret c - call TryJumpLedge - ret c - call CheckEdgeWarp - ret c - ld a, [WalkingDirection] - cp STANDING - jr z, .HitWall - call PlayBump -.HitWall - call StandInPlace - xor a +.finished + ld b, $0 + add hl, bc + ld a, [hl] ret +; 4e95d -.NotMoving - ld a, [WalkingDirection] - cp STANDING - jr z, .Standing +MaleTrainers: ; 4e95d + db BURGLAR + db YOUNGSTER + db SCHOOLBOY + db BIRD_KEEPER + db POKEMANIAC + db GENTLEMAN + db BUG_CATCHER + db FISHER + db SWIMMERM + db SAILOR + db SUPER_NERD + db GUITARIST + db HIKER + db FIREBREATHER + db BLACKBELT_T + db PSYCHIC_T + db CAMPER + db COOLTRAINERM + db BOARDER + db JUGGLER + db POKEFANM + db OFFICER + db SAGE + db BIKER + db SCIENTIST +MaleTrainersEnd: +; 4e976 -; Walking into an edge warp won't bump. - ld a, [EngineBuffer4] - and a - jr nz, .CantMove - call PlayBump -.CantMove - call WalkInPlace - xor a - ret +FemaleTrainers: ; 4e976 + db MEDIUM + db LASS + db BEAUTY + db SKIER + db TEACHER + db SWIMMERF + db PICNICKER + db KIMONO_GIRL + db POKEFANF + db COOLTRAINERF +FemaleTrainersEnd: +; 4e980 -.Standing - call StandInPlace - xor a - ret -; 800b7 +INCLUDE "battle/sliding_intro.asm" -CheckTileMovement: ; 800b7 -; Tiles such as waterfalls and warps move the player -; in a given direction, overriding input. - ld a, [PlayerNextTile] - ld c, a - call CheckWhirlpoolTile - jr c, .asm_800c4 - ld a, 3 - scf - ret +Function4ea0a: ; 4ea0a + ld a, c + push af + call SpeechTextBox + call MobileTextBorder + pop af + dec a + ld bc, $c + ld hl, w5_dc1a + call AddNTimes + ld de, wcd53 + ld bc, $c + ld a, $5 ; BANK(w5_dc1a) + call FarCopyWRAM -.asm_800c4 - and $f0 - cp $30 ; moving water - jr z, .water - cp $40 ; moving land 1 - jr z, .land1 - cp $50 ; moving land 2 - jr z, .land2 - cp $70 ; warps - jr z, .warps - jr .asm_8013c + ld a, [rSVBK] + push af + ld a, $1 + ld [rSVBK], a -.water - ld a, c - and 3 - ld c, a - ld b, 0 - ld hl, .water_table - add hl, bc - ld a, [hl] - ld [WalkingDirection], a - jr .asm_8013e + ld bc, wcd53 + decoord 1, 14 + callba Function11c0c6 -.water_table - db RIGHT - db LEFT - db UP - db DOWN + pop af + ld [rSVBK], a -.land1 - ld a, c - and 7 - ld c, a - ld b, 0 - ld hl, .land1_table - add hl, bc - ld a, [hl] - cp STANDING - jr z, .asm_8013c - ld [WalkingDirection], a - jr .asm_8013e + ld c, 180 + call DelayFrames + ret +; 4ea44 -.land1_table - db STANDING - db RIGHT - db LEFT - db UP - db DOWN - db STANDING - db STANDING - db STANDING -.land2 - ld a, c - and 7 - ld c, a - ld b, 0 - ld hl, .land2_table - add hl, bc - ld a, [hl] - cp STANDING - jr z, .asm_8013c - ld [WalkingDirection], a - jr .asm_8013e -.land2_table - db RIGHT - db LEFT - db UP - db DOWN - db STANDING - db STANDING - db STANDING - db STANDING +CheckBattleScene: ; 4ea44 +; Return carry if battle scene is turned off. -.warps - ld a, c - cp $71 ; door - jr z, .down - cp $79 - jr z, .down - cp $7a ; stairs - jr z, .down - cp $7b ; cave - jr nz, .asm_8013c + ld a, 0 + ld hl, wLinkMode + call GetFarWRAMByte + cp LINK_MOBILE + jr z, .mobile -.down - ld a, DOWN - ld [WalkingDirection], a - jr .asm_8013e + ld a, [Options] + bit BATTLE_SCENE, a + jr nz, .off -.asm_8013c - xor a + and a ret -.asm_8013e - ld a, STEP_WALK - call DoStep - ld a, 5 - scf - ret -; 80147 +.mobile + ld a, [wcd2f] + and a + jr nz, .asm_4ea72 + ld a, $4 + call GetSRAMBank + ld a, [$a60c] + ld c, a + call CloseSRAM -CheckTurning: ; 80147 -; If the player is turning, change direction first. This also lets -; the player change facing without moving by tapping a direction. + ld a, c + bit 0, c + jr z, .off - ld a, [wd04e] - cp 0 - jr nz, .asm_80169 - ld a, [WalkingDirection] - cp STANDING - jr z, .asm_80169 + and a + ret - ld e, a - ld a, [PlayerDirection] - rrca - rrca - and 3 - cp e - jr z, .asm_80169 +.asm_4ea72 + ld a, $5 + ld hl, wdc00 + call GetFarWRAMByte + bit 0, a + jr z, .off - ld a, STEP_TURN - call DoStep - ld a, 2 - scf + and a ret -.asm_80169 - xor a +.off + scf ret -; 8016b +; 4ea82 -TryStep: ; 8016b +INCLUDE "misc/gbc_only.asm" -; Surfing actually calls TrySurfStep directly instead of passing through here. - ld a, [PlayerState] - cp PLAYER_SURF - jr z, TrySurfStep - cp PLAYER_SURF_PIKA - jr z, TrySurfStep +INCLUDE "event/poke_seer.asm" - call CheckLandPermissions - jr c, .bump - call IsNPCInFront - and a - jr z, .bump - cp 2 - jr z, .bump +SECTION "bank14", ROMX, BANK[$14] - ld a, [PlayerNextTile] - call CheckIceTile - jr nc, .ice +INCLUDE "engine/party_menu.asm" +INCLUDE "event/poisonstep.asm" +INCLUDE "event/sweet_scent.asm" +INCLUDE "event/squirtbottle.asm" +INCLUDE "event/card_key.asm" +INCLUDE "event/basement_key.asm" +INCLUDE "event/sacred_ash.asm" -; Downhill riding is slower when not moving down. - call CheckRiding - jr nz, .walk +CopyPkmnToTempMon: ; 5084a +; gets the BaseData of a Pkmn +; and copys the PkmnStructure to TempMon - ld hl, BikeFlags - bit 2, [hl] ; downhill - jr z, .fast + ld a, [CurPartyMon] + ld e, a + call GetPkmnSpecies + ld a, [CurPartySpecies] + ld [CurSpecies], a + call GetBaseData - ld a, [WalkingDirection] - cp DOWN - jr z, .fast + ld a, [MonType] + ld hl, PartyMon1Species + ld bc, PARTYMON_STRUCT_LENGTH + and a + jr z, .copywholestruct + ld hl, OTPartyMon1Species + ld bc, PARTYMON_STRUCT_LENGTH + cp OTPARTYMON + jr z, .copywholestruct + ld bc, BOXMON_STRUCT_LENGTH + callab Functione5bb + jr .done - ld a, STEP_WALK - call DoStep - scf - ret +.copywholestruct + ld a, [CurPartyMon] + call AddNTimes + ld de, TempMon + ld bc, PARTYMON_STRUCT_LENGTH + call CopyBytes -.fast - ld a, STEP_BIKE - call DoStep - scf +.done ret +; 5088b -.walk - ld a, STEP_WALK - call DoStep - scf - ret -.ice - ld a, STEP_ICE - call DoStep - scf - ret +Function5088b: ; 5088b + ld bc, wd018 + jr Function50893 +; 50890 -; unused? +Function50890: ; 50890 + ld bc, TempMon + ; fallthrough +; 50893 + +Function50893: ; 50893 + ld hl, MON_LEVEL + add hl, bc + ld a, [hl] + ld [CurPartyLevel], a + ld hl, MON_MAXHP + add hl, bc + ld d, h + ld e, l + ld hl, MON_EXP + 2 + add hl, bc + push bc + ld b, $1 + predef CalcPkmnStats + pop bc + ld hl, MON_HP + add hl, bc + ld d, h + ld e, l + ld a, [CurPartySpecies] + cp EGG + jr nz, .asm_508c1 xor a - ret + ld [de], a + inc de + ld [de], a + jr .asm_508cd -.bump +.asm_508c1 + push bc + ld hl, MON_MAXHP + add hl, bc + ld bc, 2 + call CopyBytes + pop bc + +.asm_508cd + ld hl, MON_STATUS + add hl, bc xor a + ld [hli], a + ld [hl], a ret -; 801c0 - +; 508d5 -TrySurfStep: ; 801c0 +GetPkmnSpecies: ; 508d5 +; [MonType] has the type of the Pkmn +; e = Nr. of Pkmn (i.e. [CurPartyMon]) - call CheckWaterPermissions - ld [wd040], a - jr c, .bump + ld a, [MonType] + and a ; PARTYMON + jr z, .partymon + cp OTPARTYMON + jr z, .otpartymon + cp BOXMON + jr z, .boxmon + cp BREEDMON + jr z, .breedmon + ; WILDMON - call IsNPCInFront - ld [wd03f], a - and a - jr z, .bump - cp 2 - jr z, .bump +.partymon + ld hl, PartySpecies + jr .done - ld a, [wd040] - and a - jr nz, .ExitWater +.otpartymon + ld hl, OTPartySpecies + jr .done - ld a, STEP_WALK - call DoStep - scf +.boxmon + ld a, BANK(sBoxSpecies) + call GetSRAMBank + ld hl, sBoxSpecies + call .done + call CloseSRAM ret -.ExitWater - call WaterToLandSprite - call PlayMapMusic - ld a, STEP_WALK - call DoStep - ld a, 6 - scf +.breedmon + ld a, [wBreedMon1Species] + jr .done2 + +.done + ld d, 0 + add hl, de + ld a, [hl] + +.done2 + ld [CurPartySpecies], a ret +; 5090d -.bump - xor a + +INCLUDE "text/types.asm" + + +Function50a28: ; 50a28 + ld hl, Strings50a42 + ld a, [TrainerClass] + dec a + ld c, a + ld b, 0 +rept 2 + add hl, bc +endr + ld a, [hli] + ld h, [hl] + ld l, a + ld de, StringBuffer1 +.copy + ld a, [hli] + ld [de], a + inc de + cp "@" + jr nz, .copy ret -; 801f3 +; 50a42 +Strings50a42: ; 50a42 +; Untranslated trainer class names from Red. -TryJumpLedge: ; 801f3 - ld a, [PlayerNextTile] - ld e, a - and $f0 - cp $a0 ; ledge - jr nz, .DontJump + dw .Youngster + dw .BugCatcher + dw .Lass + dw OTName + dw .JrTrainerM + dw .JrTrainerF + dw .Pokemaniac + dw .SuperNerd + dw OTName + dw OTName + dw .Burglar + dw .Engineer + dw .Jack + dw OTName + dw .Swimmer + dw OTName + dw OTName + dw .Beauty + dw OTName + dw .Rocker + dw .Juggler + dw OTName + dw OTName + dw .Blackbelt + dw OTName + dw .ProfOak + dw .Chief + dw .Scientist + dw OTName + dw .Rocket + dw .CooltrainerM + dw .CooltrainerF + dw OTName + dw OTName + dw OTName + dw OTName + dw OTName + dw OTName + dw OTName + dw OTName + dw OTName + dw OTName + dw OTName + dw OTName + dw OTName + dw OTName + dw OTName - ld a, e - and 7 - ld e, a - ld d, 0 - ld hl, .data_8021e - add hl, de - ld a, [FacingDirection] - and [hl] - jr z, .DontJump +.Youngster db "たんパン@" +.BugCatcher db "むしとり@" +.Lass db "ミニスカ@" +.JrTrainerM db "ボーイ@" +.JrTrainerF db "ガール@" +.Pokemaniac db "マニア@" +.SuperNerd db "りかけい@" +.Burglar db "どろぼう@" +.Engineer db "ォヤジ@" +.Jack db "ジャック@" +.Swimmer db "かいパン@" +.Beauty db "おねえさん@" +.Rocker db "グループ@" +.Juggler db "ジャグラー@" +.Blackbelt db "からて@" +.ProfOak db "ォーキド@" +.Chief db "チーフ@" +.Scientist db "けんきゅういん@" +.Rocket db "だんいん@" +.CooltrainerM db "エりート♂@" +.CooltrainerF db "エりート♀@" +; 50b0a - ld de, SFX_JUMP_OVER_LEDGE - call PlaySFX - ld a, STEP_LEDGE - call DoStep - ld a, 7 - scf - ret -.DontJump - xor a - ret +DrawPlayerHP: ; 50b0a + ld a, $1 + jr DrawHP -.data_8021e - db FACE_RIGHT - db FACE_LEFT - db FACE_UP - db FACE_DOWN - db FACE_RIGHT | FACE_DOWN - db FACE_DOWN | FACE_LEFT - db FACE_UP | FACE_RIGHT - db FACE_UP | FACE_LEFT -; 80226 +DrawEnemyHP: ; 50b0e + ld a, $2 +DrawHP: ; 50b10 + ld [wd10a], a + push hl + push bc + ld a, [MonType] + cp BOXMON + jr z, .asm_50b30 -CheckEdgeWarp: ; 80226 + ld a, [TempMonHP] + ld b, a + ld a, [TempMonHP + 1] + ld c, a -; Bug: Since no case is made for STANDING here, it will check -; [.edgewarps + $ff]. This resolves to $3e at $8035a. -; This causes wd041 to be nonzero when standing on tile $3e, -; making bumps silent. +; Any HP? + or b + jr nz, .asm_50b30 - ld a, [WalkingDirection] + xor a + ld c, a ld e, a - ld d, 0 - ld hl, .EdgeWarps - add hl, de - ld a, [PlayerNextTile] - cp [hl] - jr nz, .nope - - ld a, 1 - ld [wd041], a - ld a, [WalkingDirection] - cp STANDING - jr z, .nope + ld a, 6 + ld d, a + jp .asm_50b4a +.asm_50b30 + ld a, [TempMonMaxHP] + ld d, a + ld a, [TempMonMaxHP + 1] ld e, a - ld a, [PlayerDirection] - rrca - rrca - and 3 - cp e - jr nz, .nope - call WarpCheck - jr nc, .nope + ld a, [MonType] + cp BOXMON + jr nz, .asm_50b41 - call StandInPlace - scf - ld a, 1 - ret + ld b, d + ld c, e -.nope - xor a - ret +.asm_50b41 + predef DrawPartyMenuHPBar + ld a, 6 + ld d, a + ld c, a -.EdgeWarps - db $70, $78, $76, $7e -; 8025f +.asm_50b4a + ld a, c + pop bc + ld c, a + pop hl + push de + push hl + push hl + call DrawBattleHPBar + pop hl + +; Print HP + ld bc, $15 ; move (1,1) + add hl, bc + ld de, TempMonHP + ld a, [MonType] + cp BOXMON + jr nz, .asm_50b66 + ld de, TempMonMaxHP +.asm_50b66 + lb bc, 2, 3 + call PrintNum + ld a, "/" + ld [hli], a -DoStep: ; 8025f - ld e, a - ld d, 0 - ld hl, .Steps -rept 2 - add hl, de -endr - ld a, [hli] - ld h, [hl] - ld l, a +; Print max HP + ld de, TempMonMaxHP + lb bc, 2, 3 + call PrintNum + pop hl + pop de + ret +; 50b7b - ld a, [WalkingDirection] - ld e, a - cp STANDING - jp z, StandInPlace - add hl, de - ld a, [hl] - ld [MovementAnimation], a +PrintTempMonStats: ; 50b7b +; Print TempMon's stats at hl, with spacing bc. + push bc + push hl + ld de, .StatNames + call PlaceString + pop hl + pop bc + add hl, bc + ld bc, SCREEN_WIDTH + add hl, bc + ld de, TempMonAttack + lb bc, 2, 3 + call .PrintStat + ld de, TempMonDefense + call .PrintStat + ld de, TempMonSpclAtk + call .PrintStat + ld de, TempMonSpclDef + call .PrintStat + ld de, TempMonSpeed + jp PrintNum +; 50bab - ld hl, .WalkInPlace +.PrintStat: ; 50bab + push hl + call PrintNum + pop hl + ld de, SCREEN_WIDTH * 2 add hl, de - ld a, [hl] - ld [wd04e], a - - ld a, 4 ret +; 50bb5 -.Steps - dw .Slow - dw .Walk - dw .Bike - dw .Ledge - dw .Ice - dw .Turn - dw .BackwardsLedge - dw .WalkInPlace - -.Slow - slow_step_down - slow_step_up - slow_step_left - slow_step_right -.Walk - step_down - step_up - step_left - step_right -.Bike - big_step_down - big_step_up - big_step_left - big_step_right -.Ledge - jump_step_down - jump_step_up - jump_step_left - jump_step_right -.Ice - fast_slide_step_down - fast_slide_step_up - fast_slide_step_left - fast_slide_step_right -.BackwardsLedge - jump_step_up - jump_step_down - jump_step_right - jump_step_left -.Turn - half_step_down - half_step_up - half_step_left - half_step_right -.WalkInPlace - db $80 + movement_turn_head_down - db $80 + movement_turn_head_up - db $80 + movement_turn_head_left - db $80 + movement_turn_head_right -; 802b3 +.StatNames: ; 50bb5 + db "ATTACK" + next "DEFENSE" + next "SPCL.ATK" + next "SPCL.DEF" + next "SPEED" + next "@" +; 50bdd -StandInPlace: ; 802b3 - ld a, 0 - ld [wd04e], a - ld a, movement_step_sleep_1 - ld [MovementAnimation], a - xor a - ret -; 802bf +GetGender: ; 50bdd +; Return the gender of a given monster (CurPartyMon/CurOTMon/CurWildMon). +; When calling this function, a should be set to an appropriate MonType value. +; return values: +; a = 1: f = nc|nz; male +; a = 0: f = nc|z; female +; f = c: genderless -WalkInPlace: ; 802bf - ld a, 0 - ld [wd04e], a - ld a, movement_step_bump - ld [MovementAnimation], a - xor a - ret -; 802cb +; This is determined by comparing the Attack and Speed DVs +; with the species' gender ratio. -CheckForcedMovementInput: ; 802cb -; When sliding on ice, input is forced to remain in the same direction. +; Figure out what type of monster struct we're looking at. - call CheckStandingOnIce - ret nc +; 0: PartyMon + ld hl, PartyMon1DVs + ld bc, PARTYMON_STRUCT_LENGTH + ld a, [MonType] + and a + jr z, .PartyMon - ld a, [wd04e] - cp 0 - ret z +; 1: OTPartyMon + ld hl, OTPartyMon1DVs + dec a + jr z, .PartyMon - and 3 - ld e, a - ld d, 0 - ld hl, .data_802e8 - add hl, de - ld a, [CurInput] - and BUTTONS - or [hl] - ld [CurInput], a - ret +; 2: sBoxMon + ld hl, sBoxMon1DVs + ld bc, BOXMON_STRUCT_LENGTH + dec a + jr z, .sBoxMon -.data_802e8 - db D_DOWN, D_UP, D_LEFT, D_RIGHT -; 802ec +; 3: Unknown + ld hl, TempMonDVs + dec a + jr z, .DVs +; else: WildMon + ld hl, EnemyMonDVs + jr .DVs -GetMovementAction: ; 802ec -; Poll player input and update movement info. - ld hl, .table - ld de, .table2 - .table1 - ld a, [CurInput] - bit 7, a - jr nz, .down - bit 6, a - jr nz, .up - bit 5, a - jr nz, .left - bit 4, a - jr nz, .right -; Standing - jr .update +; Get our place in the party/box. -.down add hl, de -.up add hl, de -.left add hl, de -.right add hl, de +.PartyMon +.sBoxMon + ld a, [CurPartyMon] + call AddNTimes -.update - ld a, [hli] - ld [WalkingDirection], a - ld a, [hli] - ld [FacingDirection], a - ld a, [hli] - ld [WalkingX], a - ld a, [hli] - ld [WalkingY], a + +.DVs + +; sBoxMon data is read directly from SRAM. + ld a, [MonType] + cp BOXMON + ld a, 1 + call z, GetSRAMBank + +; Attack DV ld a, [hli] - ld h, [hl] - ld l, a + and $f0 + ld b, a +; Speed DV ld a, [hl] - ld [WalkingTile], a + and $f0 + swap a + +; Put our DVs together. + or b + ld b, a + +; Close SRAM if we were dealing with a sBoxMon. + ld a, [MonType] + cp BOXMON + call z, CloseSRAM + + +; We need the gender ratio to do anything with this. + push bc + ld a, [CurPartySpecies] + dec a + ld hl, BaseData + BaseGender - CurBaseData + ld bc, BaseData1 - BaseData + call AddNTimes + pop bc + + ld a, BANK(BaseData) + call GetFarByte + + +; The higher the ratio, the more likely the monster is to be female. + + cp $ff + jr z, .Genderless + + and a + jr z, .Male + + cp $fe + jr z, .Female + +; Values below the ratio are male, and vice versa. + cp b + jr c, .Male + +.Female + xor a ret -.table -; struct: -; walk direction -; facing -; x movement -; y movement -; tile collision pointer -.table1 - db STANDING, FACE_CURRENT, 0, 0 - dw PlayerNextTile -.table2 - db RIGHT, FACE_RIGHT, 1, 0 - dw TileRight - db LEFT, FACE_LEFT, -1, 0 - dw TileLeft - db UP, FACE_UP, 0, -1 - dw TileUp - db DOWN, FACE_DOWN, 0, 1 - dw TileDown -; 80341 +.Male + ld a, 1 + and a + ret +.Genderless + scf + ret +; 50c50 -IsNPCInFront: ; 80341 -; Returns 0 if there is an NPC in front that you can't move -; Returns 1 if there is no NPC in front -; Returns 2 if there is a movable NPC in front - ld a, 0 - ld [hMapObjectIndexBuffer], a -; Load the next X coordinate into d - ld a, [PlayerNextMapX] - ld d, a - ld a, [WalkingX] - add d - ld d, a -; Load the next Y coordinate into e - ld a, [PlayerNextMapY] +Function50c50: ; 50c50 + ld a, [wd0eb] + inc a + ld c, a + ld a, $4 + sub c + ld b, a + push hl + ld a, [Buffer1] ld e, a - ld a, [WalkingY] - add e + ld d, $0 + ld a, $3e + call Function50cc9 + ld a, b + and a + jr z, .asm_50c6f + ld c, a + ld a, $e3 + call Function50cc9 + +.asm_50c6f + pop hl +rept 3 + inc hl +endr + ld d, h + ld e, l + ld hl, TempMonMoves + ld b, 0 +.asm_50c7a + ld a, [hli] + and a + jr z, .asm_50cc8 + push bc + push hl + push de + ld hl, MenuSelection2 + ld a, [hl] + push af + ld [hl], b + push hl + callab GetMaxPPOfMove + pop hl + pop af + ld [hl], a + pop de + pop hl + push hl + ld bc, TempMonPP - (TempMonMoves + 1) + add hl, bc + ld a, [hl] + and $3f + ld [StringBuffer1 + 4], a + ld h, d + ld l, e + push hl + ld de, StringBuffer1 + 4 + lb bc, 1, 2 + call PrintNum + ld a, $f3 + ld [hli], a + ld de, wd265 + lb bc, 1, 2 + call PrintNum + pop hl + ld a, [Buffer1] ld e, a -; Find an object struct with coordinates equal to d,e - ld bc, ObjectStructs ; redundant - callba IsNPCAtCoord - jr nc, .nope - call Function8036f - jr c, .no_bump + ld d, 0 + add hl, de + ld d, h + ld e, l + pop hl + pop bc + inc b + ld a, b + cp NUM_MOVES + jr nz, .asm_50c7a -; .bump - xor a +.asm_50cc8 ret +; 50cc9 -.nope - ld a, 1 +Function50cc9: ; 50cc9 +.asm_50cc9 + ld [hli], a + ld [hld], a + add hl, de + dec c + jr nz, .asm_50cc9 ret +; 50cd0 -.no_bump - ld a, 2 +Function50cd0: ; 50cd0 +.asm_50cd0 + ld [hl], $32 + inc hl + ld [hl], $3e + dec hl + add hl, de + dec c + jr nz, .asm_50cd0 ret -; 8036f - - -Function8036f: ; 8036f - - ld hl, BikeFlags - bit 0, [hl] ; using strength - jr z, .nope - - ld hl, OBJECT_DIRECTION_WALKING - add hl, bc - ld a, [hl] - cp STANDING - jr nz, .nope - - ld hl, OBJECT_PALETTE - add hl, bc - bit 6, [hl] - jr z, .nope +; 50cdb - ld hl, OBJECT_FLAGS2 +Function50cdb: ; unreferenced predef + push hl + push hl + ld hl, PartyMonNicknames + ld a, [CurPartyMon] + call GetNick + pop hl + call PlaceString + call CopyPkmnToTempMon + pop hl + ld a, [CurPartySpecies] + cp EGG + jr z, .asm_50d09 + push hl + ld bc, -12 add hl, bc - set 2, [hl] - - ld a, [WalkingDirection] - ld d, a - ld hl, OBJECT_RANGE + ld b, $0 + call DrawEnemyHP + pop hl + ld bc, 5 add hl, bc - ld a, [hl] - and $fc - or d - ld [hl], a - - scf - ret - -.nope - xor a - ret -; 8039e - - -CheckLandPermissions: ; 8039e -; Return 0 if walking onto land and tile permissions allow it. -; Otherwise, return carry. - - ld a, [TilePermissions] - ld d, a - ld a, [FacingDirection] - and d - jr nz, .NotWalkable - - ld a, [WalkingTile] - call CheckWalkable - jr c, .NotWalkable - - xor a - ret + push de + call PrintLevel + pop de -.NotWalkable - scf +.asm_50d09 ret -; 803b4 - -CheckWaterPermissions: ; 803b4 -; Return 0 if moving in water, or 1 if moving onto land. -; Otherwise, return carry. - - ld a, [TilePermissions] - ld d, a - ld a, [FacingDirection] - and d - jr nz, .NotSurfable +; 50d0a - ld a, [WalkingTile] - call CheckSurfable - jr c, .NotSurfable +PlaceStatusString: ; 50d0a + push de +rept 2 + inc de +endr + ld a, [de] + ld b, a + inc de + ld a, [de] + or b + pop de + jr nz, PlaceNonFaintStatus + push de + ld de, FntString + call CopyStatusString + pop de + ld a, $1 and a ret +; 50d22 -.NotSurfable - scf - ret -; 803ca - - -CheckRiding: ; 803ca +FntString: ; 50d22 + db "FNT@" +; 50d25 - ld a, [PlayerState] - cp PLAYER_BIKE - ret z - cp PLAYER_SLIP +CopyStatusString: ; 50d25 + ld a, [de] + inc de + ld [hli], a + ld a, [de] + inc de + ld [hli], a + ld a, [de] + ld [hl], a ret -; 803d3 +; 50d2e +PlaceNonFaintStatus: ; 50d2e + push de + ld a, [de] + ld de, PsnString + bit PSN, a + jr nz, .place + ld de, BrnString + bit BRN, a + jr nz, .place + ld de, FrzString + bit FRZ, a + jr nz, .place + ld de, ParString + bit PAR, a + jr nz, .place + ld de, SlpString + and SLP + jr z, .no_status -CheckWalkable: ; 803d3 -; Return 0 if tile a is land. Otherwise, return carry. +.place + call CopyStatusString + ld a, $1 + and a - call GetTileCollision - and a ; land - ret z - scf +.no_status + pop de ret -; 803da - - -CheckSurfable: ; 803da -; Return 0 if tile a is water, or 1 if land. -; Otherwise, return carry. +; 50d5b - call GetTileCollision - cp 1 - jr z, .Water +SlpString: db "SLP@" +PsnString: db "PSN@" +BrnString: db "BRN@" +FrzString: db "FRZ@" +ParString: db "PAR@" +; 50d6f -; Can walk back onto land from water. +ListMoves: ; 50d6f +; List moves at hl, spaced every [Buffer1] tiles. + ld de, wListMoves_MoveIndicesBuffer + ld b, $0 +.moves_loop + ld a, [de] + inc de and a - jr z, .Land + jr z, .no_more_moves + push de + push hl + push hl + ld [CurSpecies], a + ld a, MOVE_NAME + ld [wNamedObjectTypeBuffer], a + call GetName + ld de, StringBuffer1 + pop hl + push bc + call PlaceString + pop bc + ld a, b + ld [wd0eb], a + inc b + pop hl + push bc + ld a, [Buffer1] + ld c, a + ld b, 0 + add hl, bc + pop bc + pop de + ld a, b + cp NUM_MOVES + jr z, .done + jr .moves_loop - jr .Neither +.no_more_moves + ld a, b +.nonmove_loop + push af + ld [hl], "-" + ld a, [Buffer1] + ld c, a + ld b, 0 + add hl, bc + pop af + inc a + cp NUM_MOVES + jr nz, .nonmove_loop -.Water - xor a +.done ret +; 50db9 -.Land - ld a, 1 - and a - ret +Function50db9: ; 50db9 + ld a, [wd263] -.Neither - scf - ret -; 803ee + cp $1 + jr nz, .check_party_ot_name + ld hl, OTPartyCount + ld de, OTPartyMonOT + ld a, ENEMY_OT_NAME + jr .done +.check_party_ot_name + cp $4 + jr nz, .check_mon_name + ld hl, PartyCount + ld de, PartyMonOT + ld a, PARTY_OT_NAME + jr .done +.check_mon_name -PlayBump: ; 803ee + cp $5 + jr nz, .check_item_name + ld hl, CurMart + ld de, PokemonNames + ld a, PKMN_NAME + jr .done +.check_item_name - call CheckSFX - ret c - ld de, SFX_BUMP - call PlaySFX - ret -; 803f9 + cp $2 + jr nz, .check_ob_item_name + ld hl, NumItems + ld de, ItemNames + ld a, ITEM_NAME + jr .done +.check_ob_item_name + ld hl, CurMart + ld de, ItemNames + ld a, ITEM_NAME -WaterToLandSprite: ; 803f9 - push bc - ld a, PLAYER_NORMAL - ld [PlayerState], a - call ReplaceKrisSprite ; UpdateSprites - pop bc +.done + ld [wNamedObjectTypeBuffer], a + ld a, l + ld [wd100], a + ld a, h + ld [wd101], a + ld a, e + ld [wd102], a + ld a, d + ld [wd103], a + ld bc, ItemAttributes + ld a, c + ld [wd104], a + ld a, b + ld [wd105], a ret -; 80404 - +; 50e1b -CheckStandingOnIce:: ; 80404 - ld a, [wd04e] - cp 0 - jr z, .nope - cp $f0 - jr z, .nope - ld a, [PlayerNextTile] - call CheckIceTile - jr nc, .yep - ld a, [PlayerState] - cp PLAYER_SLIP - jr nz, .nope -.yep - scf - ret +CalcLevel: ; 50e1b + ld a, [TempMonSpecies] + ld [CurSpecies], a + call GetBaseData + ld d, 1 +.next_level + inc d + ld a, d + cp (MAX_LEVEL + 1) % $100 + jr z, .got_level + call CalcExpAtLevel + push hl + ld hl, TempMonExp + 2 + ld a, [hProduct + 3] + ld c, a + ld a, [hld] + sub c + ld a, [hProduct + 2] + ld c, a + ld a, [hld] + sbc c + ld a, [hProduct + 1] + ld c, a + ld a, [hl] + sbc c + pop hl + jr nc, .next_level -.nope - and a +.got_level + dec d ret -; 80422 - - -Function80422:: ; 80422 - ld hl, wc2de - ld a, movement_step_sleep_1 - cp [hl] - ret z +; 50e47 - ld [hl], a - ld a, 0 - ld [wd04e], a - ret -; 80430 +CalcExpAtLevel: ; 50e47 +; (a/b)*n**3 + c*n**2 + d*n - e + ld a, [BaseGrowthRate] +rept 2 + add a +endr + ld c, a + ld b, 0 + ld hl, GrowthRates + add hl, bc +; Cube the level + call .LevelSquared + ld a, d + ld [hMultiplier], a + call Multiply -EngineFlagAction:: ; 80430 -; Do action b on engine flag de -; -; b = 0: reset flag -; = 1: set flag -; > 1: check flag, result in c -; -; Setting/resetting does not return a result. +; Multiply by a + ld a, [hl] + and $f0 + swap a + ld [hMultiplier], a + call Multiply +; Divide by b + ld a, [hli] + and $f + ld [hDivisor], a + ld b, 4 + call Divide +; Push the cubic term to the stack + ld a, [hQuotient + 0] + push af + ld a, [hQuotient + 1] + push af + ld a, [hQuotient + 2] + push af +; Square the level and multiply by the lower 7 bits of c + call .LevelSquared + ld a, [hl] + and $7f + ld [hMultiplier], a + call Multiply +; Push the absolute value of the quadratic term to the stack + ld a, [hProduct + 1] + push af + ld a, [hProduct + 2] + push af + ld a, [hProduct + 3] + push af + ld a, [hli] + push af +; Multiply the level by d + xor a + ld [hMultiplicand + 0], a + ld [hMultiplicand + 1], a + ld a, d + ld [hMultiplicand + 2], a + ld a, [hli] + ld [hMultiplier], a + call Multiply +; Subtract e + ld b, [hl] + ld a, [hProduct + 3] + sub b + ld [hMultiplicand + 2], a + ld b, $0 + ld a, [hProduct + 2] + sbc b + ld [hMultiplicand + 1], a + ld a, [hProduct + 1] + sbc b + ld [hMultiplicand], a +; If bit 7 of c is set, c is negative; otherwise, it's positive + pop af + and $80 + jr nz, .subtract +; Add c*n**2 to (d*n - e) + pop bc + ld a, [hProduct + 3] + add b + ld [hMultiplicand + 2], a + pop bc + ld a, [hProduct + 2] + adc b + ld [hMultiplicand + 1], a + pop bc + ld a, [hProduct + 1] + adc b + ld [hMultiplicand], a + jr .done_quadratic +.subtract +; Subtract c*n**2 from (d*n - e) + pop bc + ld a, [hProduct + 3] + sub b + ld [hMultiplicand + 2], a + pop bc + ld a, [hProduct + 2] + sbc b + ld [hMultiplicand + 1], a + pop bc + ld a, [hProduct + 1] + sbc b + ld [hMultiplicand], a -; 16-bit flag ids are considered invalid, but it's nice -; to know that the infrastructure is there. +.done_quadratic +; Add (a/b)*n**3 to (d*n - e +/- c*n**2) + pop bc + ld a, [hProduct + 3] + add b + ld [hMultiplicand + 2], a + pop bc + ld a, [hProduct + 2] + adc b + ld [hMultiplicand + 1], a + pop bc + ld a, [hProduct + 1] + adc b + ld [hMultiplicand], a + ret +; 50eed +.LevelSquared: ; 50eed + xor a + ld [hMultiplicand + 0], a + ld [hMultiplicand + 1], a ld a, d - cp 0 - jr z, .ceiling - jr c, .read ; cp 0 can't set carry! - jr .invalid - -; There are only $a2 engine flags, so -; anything beyond that is invalid too. + ld [hMultiplicand + 2], a + ld [hMultiplier], a + jp Multiply +; 50efa -.ceiling - ld a, e - cp NUM_ENGINE_FLAGS - jr c, .read +GrowthRates: ; 50efa -; Invalid flags are treated as flag 00. +growth_rate: MACRO +; [1]/[2]*n**3 + [3]*n**2 + [4]*n - [5] + dn \1, \2 + if \3 & $80 ; signed + db -\3 | $80 + else + db \3 + endc + db \4, \5 +ENDM -.invalid - xor a - ld e, a - ld d, a + growth_rate 1, 1, 0, 0, 0 ; Medium Fast + growth_rate 3, 4, 10, 0, 30 ; Slightly Fast + growth_rate 3, 4, 20, 0, 70 ; Slightly Slow + growth_rate 6, 5, -15, 100, 140 ; Medium Slow + growth_rate 4, 5, 0, 0, 0 ; Fast + growth_rate 5, 4, 0, 0, 0 ; Slow +; 50f12 -; Get this flag's location. +_SwitchPartyMons: + ld a, [wd0e3] + dec a + ld [wd1ec], a + ld b, a + ld a, [MenuSelection2] + dec a + ld [Buffer2], a ; wd1eb (aliases: MovementType) + cp b + jr z, .skip + call .SwapPartymonViaSRAM + ld a, [wd1ec] + call .ClearSprite + ld a, [Buffer2] ; wd1eb (aliases: MovementType) + call .ClearSprite +.skip + ret -.read - ld hl, EngineFlags -; location -rept 2 - add hl, de -endr -; bit +.ClearSprite: ; 50f34 (14:4f34) + push af + hlcoord 0, 1 + ld bc, 2 * SCREEN_WIDTH + call AddNTimes + ld bc, 2 * SCREEN_WIDTH + ld a, " " + call ByteFill + pop af + ld hl, Sprites + ld bc, $10 + call AddNTimes + ld de, $4 + ld c, $4 +.gfx_loop + ld [hl], $a0 add hl, de - -; location - ld e, [hl] - inc hl - ld d, [hl] - inc hl -; bit - ld c, [hl] - -; What are we doing with this flag? - - ld a, b - cp 1 - jr c, .reset ; b = 0 - jr z, .set ; b = 1 - -; Return the given flag in c. -.check - ld a, [de] - and c - ld c, a + dec c + jr nz, .gfx_loop + ld de, SFX_SWITCH_POKEMON + call WaitPlaySFX ret -; Set the given flag. -.set +.SwapPartymonViaSRAM: ; 50f62 (14:4f62) + push hl + push de + push bc + ld bc, PartySpecies + ld a, [Buffer2] ; wd1eb (aliases: MovementType) + ld l, a + ld h, $0 + add hl, bc + ld d, h + ld e, l + ld a, [Buffer3] + ld l, a + ld h, $0 + add hl, bc + ld a, [hl] + push af ld a, [de] - or c + ld [hl], a + pop af ld [de], a + ld a, [Buffer2] ; wd1eb (aliases: MovementType) + ld hl, PartyMons ; wdcdf (aliases: PartyMon1, PartyMon1Species) + ld bc, PARTYMON_STRUCT_LENGTH + call AddNTimes + push hl + ld de, wd002 + ld bc, PARTYMON_STRUCT_LENGTH + call CopyBytes + ld a, [Buffer3] + ld hl, PartyMons ; wdcdf (aliases: PartyMon1, PartyMon1Species) + ld bc, PARTYMON_STRUCT_LENGTH + call AddNTimes + pop de + push hl + ld bc, PARTYMON_STRUCT_LENGTH + call CopyBytes + pop de + ld hl, wd002 + ld bc, PARTYMON_STRUCT_LENGTH + call CopyBytes + ld a, [Buffer2] ; wd1eb (aliases: MovementType) + ld hl, PartyMonOT + call SkipNames + push hl + call .CopyNameTowd002 + ld a, [Buffer3] + ld hl, PartyMonOT + call SkipNames + pop de + push hl + call .CopyName + pop de + ld hl, wd002 + call .CopyName + ld hl, PartyMonNicknames + ld a, [Buffer2] ; wd1eb (aliases: MovementType) + call SkipNames + push hl + call .CopyNameTowd002 + ld hl, PartyMonNicknames + ld a, [Buffer3] + call SkipNames + pop de + push hl + call .CopyName + pop de + ld hl, wd002 + call .CopyName + ld hl, sPartyScratch1 + ld a, [Buffer2] ; wd1eb (aliases: MovementType) + ld bc, SCRATCHMON_STRUCT_LENGTH + call AddNTimes + push hl + ld de, wd002 + ld bc, SCRATCHMON_STRUCT_LENGTH + ld a, BANK(sPartyScratch1) + call GetSRAMBank + call CopyBytes + ld hl, sPartyScratch1 + ld a, [Buffer3] + ld bc, SCRATCHMON_STRUCT_LENGTH + call AddNTimes + pop de + push hl + ld bc, SCRATCHMON_STRUCT_LENGTH + call CopyBytes + pop de + ld hl, wd002 + ld bc, SCRATCHMON_STRUCT_LENGTH + call CopyBytes + call CloseSRAM + pop bc + pop de + pop hl ret -; Reset the given flag. -.reset - ld a, c - cpl ; AND all bits except the one in question - ld c, a - ld a, [de] - and c - ld [de], a +.CopyNameTowd002: ; 51036 (14:5036) + ld de, wd002 + +.CopyName: ; 51039 (14:5039) + ld bc, NAME_LENGTH + call CopyBytes ret -; 80462 +GetUnownLetter: ; 51040 +; Return Unown letter in UnownLetter based on DVs at hl -EngineFlags: ; 80462 -INCLUDE "engine/engine_flags.asm" -; 80648 +; Take the middle 2 bits of each DV and place them in order: +; atk def spd spc +; .ww..xx. .yy..zz. + ; atk + ld a, [hl] + and %01100000 + sla a + ld b, a + ; def + ld a, [hli] + and %00000110 + swap a + srl a + or b + ld b, a + ; spd + ld a, [hl] + and %01100000 + swap a + sla a + or b + ld b, a + ; spc + ld a, [hl] + and %00000110 + srl a + or b -_GetVarAction:: ; 80648 (20:4648) - ld a, c - cp NUM_VARS - jr c, .valid +; Divide by 10 to get 0-25 + ld [hDividend + 3], a xor a -.valid - ld c, a - ld b, 0 - ld hl, .VarActionTable -rept 3 - add hl, bc -endr - ld e, [hl] - inc hl - ld d, [hl] - inc hl - ld b, [hl] - ld a, b - and RETVAR_EXECUTE - jr nz, .call - ld a, b - and RETVAR_ADDR_DE - ret nz - ld a, [de] - jr .loadstringbuffer2 + ld [hDividend], a + ld [hDividend + 1], a + ld [hDividend + 2], a + ld a, 10 + ld [hDivisor], a + ld b, 4 + call Divide -.call - call _de_ +; Increment to get 1-26 + ld a, [hQuotient + 2] + inc a + ld [UnownLetter], a ret +; 51077 -.loadstringbuffer2: ; 8066c (20:466c) - ld de, StringBuffer2 - ld [de], a + +GetFrontpic: ; 51077 + ld a, [CurPartySpecies] + ld [CurSpecies], a + call IsAPokemon + ret c + ld a, [rSVBK] + push af + call _GetFrontpic + pop af + ld [rSVBK], a ret -; 80671 (20:4671) +; 5108b -.VarActionTable: ; 80671 -; $00: copy [de] to StringBuffer2 -; $40: return address in de -; $80: call function - dwb StringBuffer2, RETVAR_STRBUF2 - dwb PartyCount, RETVAR_STRBUF2 - dwb .BattleResult, RETVAR_EXECUTE - dwb BattleType, RETVAR_ADDR_DE - dwb TimeOfDay, RETVAR_STRBUF2 - dwb .CountCaughtMons, RETVAR_EXECUTE - dwb .CountSeenMons, RETVAR_EXECUTE - dwb .CountBadges, RETVAR_EXECUTE - dwb PlayerState, RETVAR_ADDR_DE - dwb .PlayerFacing, RETVAR_EXECUTE - dwb hHours, RETVAR_STRBUF2 - dwb .DayOfWeek, RETVAR_EXECUTE - dwb MapGroup, RETVAR_STRBUF2 - dwb MapNumber, RETVAR_STRBUF2 - dwb .UnownCaught, RETVAR_EXECUTE - dwb wPermission, RETVAR_STRBUF2 - dwb .BoxFreeSpace, RETVAR_EXECUTE - dwb wBugContestMinsRemaining, RETVAR_STRBUF2 - dwb XCoord, RETVAR_STRBUF2 - dwb YCoord, RETVAR_STRBUF2 - dwb wSpecialPhoneCallID, RETVAR_STRBUF2 - dwb wcf64, RETVAR_STRBUF2 - dwb wKurtApricornQuantity, RETVAR_STRBUF2 - dwb wCurrentCaller, RETVAR_ADDR_DE - dwb wBlueCardBalance, RETVAR_ADDR_DE - dwb wBuenasPassword, RETVAR_ADDR_DE - dwb wdc58, RETVAR_STRBUF2 - dwb NULL, RETVAR_STRBUF2 -; 806c5 +Function5108b: ; 5108b + ld a, [CurPartySpecies] + ld [CurSpecies], a + call IsAPokemon + ret c + ld a, [rSVBK] + push af + xor a + ld [hBGMapMode], a + call _GetFrontpic + call Function51103 + pop af + ld [rSVBK], a + ret +; 510a5 -.CountCaughtMons: ; 806c5 -; Caught mons. - ld hl, PokedexCaught - ld b, EndPokedexCaught - PokedexCaught - call CountSetBits - ld a, [wd265] - jp .loadstringbuffer2 -; 806d3 +_GetFrontpic: ; 510a5 + push de + call GetBaseData + ld a, [BasePicSize] + and $f + ld b, a + push bc + call GetFrontpicPointer + ld a, $6 + ld [rSVBK], a + ld a, b + ld de, w6_d000 + $800 + call FarDecompress + pop bc + ld hl, w6_d000 + ld de, w6_d000 + $800 + call Function512ab + pop hl + push hl + ld de, w6_d000 + ld c, 7 * 7 + ld a, [hROMBank] + ld b, a + call Get2bpp + pop hl + ret +; 510d7 -.CountSeenMons: ; 806d3 -; Seen mons. - ld hl, PokedexSeen - ld b, EndPokedexSeen - PokedexSeen - call CountSetBits - ld a, [wd265] - jp .loadstringbuffer2 -; 806e1 +GetFrontpicPointer: ; 510d7 +GLOBAL PicPointers, UnownPicPointers -.CountBadges: ; 806e1 -; Number of owned badges. - ld hl, Badges - ld b, 2 - call CountSetBits - ld a, [wd265] - jp .loadstringbuffer2 -; 806ef + ld a, [CurPartySpecies] + cp UNOWN + jr z, .unown + ld a, [CurPartySpecies] + ld d, BANK(PicPointers) + jr .ok -.PlayerFacing: ; 806ef -; The direction the player is facing. - ld a, [PlayerDirection] - and $c - rrca - rrca - jp .loadstringbuffer2 -; 806f9 +.unown + ld a, [UnownLetter] + ld d, BANK(UnownPicPointers) -.DayOfWeek: ; 806f9 -; The day of the week. - call GetWeekday - jp .loadstringbuffer2 -; 806ff +.ok + ld hl, PicPointers ; UnownPicPointers + dec a + ld bc, 6 + call AddNTimes + ld a, d + call GetFarByte + call FixPicBank + push af + inc hl + ld a, d + call GetFarHalfword + pop bc + ret +; 51103 + +Function51103: ; 51103 + ld a, $1 + ld [rVBK], a + push hl + ld de, w6_d000 + ld c, 7 * 7 + ld a, [hROMBank] + ld b, a + call Get2bpp + pop hl + ld de, 7 * 7 * $10 + add hl, de + push hl + ld a, $1 + ld hl, BasePicSize + call GetFarWRAMByte + pop hl + and $f + ld de, w6_d000 + $800 + 5 * 5 * $10 + ld c, 5 * 5 + cp 5 + jr z, .asm_5113b + ld de, w6_d000 + $800 + 6 * 6 * $10 + ld c, 6 * 6 + cp 6 + jr z, .asm_5113b + ld de, w6_d000 + $800 + 7 * 7 * $10 + ld c, 7 * 7 +.asm_5113b -.UnownCaught: ; 806ff -; Number of unique Unown caught. - call .count - ld a, b - jp .loadstringbuffer2 + push hl + push bc + call Function5114f + pop bc + pop hl + ld de, w6_d000 + ld a, [hROMBank] + ld b, a + call Get2bpp + xor a + ld [rVBK], a + ret +; 5114f -.count - ld hl, UnownDex - ld b, 0 -.loop - ld a, [hli] - and a - ret z - inc b - ld a, b - cp 26 - jr c, .loop +Function5114f: ; 5114f + ld hl, w6_d000 + swap c + ld a, c + and $f + ld b, a + ld a, c + and $f0 + ld c, a + push bc + call Function512f2 + pop bc +.asm_51161 + push bc + ld c, $0 + call Function512f2 + pop bc + dec b + jr nz, .asm_51161 ret -; 80715 +; 5116c -.BoxFreeSpace: ; 80715 -; Remaining slots in the current box. - ld a, BANK(sBoxCount) - call GetSRAMBank - ld hl, sBoxCount - ld a, MONS_PER_BOX - sub [hl] +GetBackpic: ; 5116c + ld a, [CurPartySpecies] + call IsAPokemon + ret c + + ld a, [CurPartySpecies] ld b, a - call CloseSRAM + ld a, [UnownLetter] + ld c, a + ld a, [rSVBK] + push af + ld a, $6 + ld [rSVBK], a + push de + + ; These are assumed to be at the same + ; address in their respective banks. + GLOBAL PicPointers, UnownPicPointers + ld hl, PicPointers ; UnownPicPointers ld a, b - jp .loadstringbuffer2 -; 80728 + ld d, BANK(PicPointers) + cp UNOWN + jr nz, .ok + ld a, c + ld d, BANK(UnownPicPointers) +.ok + dec a + ld bc, 6 + call AddNTimes + ld bc, 3 + add hl, bc + ld a, d + call GetFarByte + call FixPicBank + push af + inc hl + ld a, d + call GetFarHalfword + ld de, w6_d000 + pop af + call FarDecompress + ld hl, w6_d000 + ld c, 6 * 6 + call Function5127c + pop hl + ld de, w6_d000 + ld a, [hROMBank] + ld b, a + call Get2bpp + pop af + ld [rSVBK], a + ret +; 511c5 -.BattleResult: ; 80728 - ld a, [wBattleResult] - and $3f - jp .loadstringbuffer2 -; 80730 +FixPicBank: ; 511c5 +; This is a thing for some reason. + push hl + push bc + sub PICS_1 - $36 + ld c, a + ld b, 0 + ld hl, Unknown_511d4 + add hl, bc + ld a, [hl] + pop bc + pop hl + ret +; 511d4 -BattleText:: -INCLUDE "text/battle.asm" +Unknown_511d4: ; 511d4 + db PICS_1 + db PICS_2 + db PICS_3 + db PICS_4 + db PICS_5 + db PICS_6 + db PICS_7 + db PICS_8 + db PICS_9 + db PICS_10 + db PICS_11 + db PICS_12 + db PICS_13 + db PICS_14 + db PICS_15 + db PICS_16 + db PICS_17 + db PICS_18 + db PICS_19 + db PICS_19 + 1 + db PICS_19 + 2 + db PICS_19 + 3 + db PICS_19 + 4 + db PICS_19 + 5 +Function511ec: ; 511ec + ld a, c + push de + ld hl, PicPointers + dec a + ld bc, 6 + call AddNTimes + ld a, BANK(PicPointers) + call GetFarByte + call FixPicBank + push af + inc hl + ld a, BANK(PicPointers) + call GetFarHalfword + pop af + pop de + call FarDecompress + ret +; 0x5120d -ColorTest: ; 818ac -; A debug menu to test monster and trainer palettes at runtime. - ld a, [hCGB] - and a - jr nz, .asm_818b5 - ld a, [hSGB] +GetTrainerPic: ; 5120d + ld a, [TrainerClass] and a ret z - -.asm_818b5 - ld a, [hInMenu] + cp NUM_TRAINER_CLASSES + ret nc + call WaitBGMap + xor a + ld [hBGMapMode], a + ld hl, TrainerPicPointers + ld a, [TrainerClass] + dec a + ld bc, 3 + call AddNTimes + ld a, [rSVBK] + push af + ld a, $6 + ld [rSVBK], a + push de + ld a, BANK(TrainerPicPointers) + call GetFarByte + call FixPicBank push af + inc hl + ld a, BANK(TrainerPicPointers) + call GetFarHalfword + pop af + ld de, w6_d000 + call FarDecompress + pop hl + ld de, w6_d000 + ld c, 7 * 7 + ld a, [hROMBank] + ld b, a + call Get2bpp + pop af + ld [rSVBK], a + call WaitBGMap ld a, $1 - ld [hInMenu], a - call DisableLCD - call Function81948 - call Function8197c - call Function819a7 - call Function818f4 - call EnableLCD - ld de, MUSIC_NONE - call PlayMusic - xor a - ld [wJumptableIndex], a - ld [wcf66], a - ld [wd003], a -.asm_818de - ld a, [wJumptableIndex] - bit 7, a - jr nz, .asm_818f0 - call Function81a74 - call Function81f5e - call DelayFrame - jr .asm_818de + ld [hBGMapMode], a + ret +; 5125d + + + +DecompressPredef: ; 5125d +; Decompress lz data from b:hl to scratch space at 6:d000, then copy it to address de. + + ld a, [rSVBK] + push af + ld a, 6 + ld [rSVBK], a + + push de + push bc + ld a, b + ld de, w6_d000 + call FarDecompress + pop bc + ld de, w6_d000 + pop hl + ld a, [hROMBank] + ld b, a + call Get2bpp -.asm_818f0 pop af - ld [hInMenu], a + ld [rSVBK], a ret -; 818f4 +; 5127c -Function818f4: ; 818f4 - ld a, [wd002] - and a - jr nz, Function81911 - ld hl, PokemonPalettes -Function818fd: ; 818fd - ld de, OverworldMap - ld c, NUM_POKEMON + 1 -.asm_81902 +Function5127c: ; 5127c + push de push bc - push hl - call Function81928 - pop hl - ld bc, 8 - add hl, bc - pop bc + ld a, [wc2c6] + and a + jr z, .asm_512a8 + ld a, c + cp 7 * 7 + ld de, 7 * 7 * $10 + jr z, .asm_51296 + cp 6 * 6 + ld de, 6 * 6 * $10 + jr z, .asm_51296 + ld de, 5 * 5 * $10 + +.asm_51296 + ld a, [hl] + ld b, $0 + ld c, $8 +.asm_5129b + rra + rl b dec c - jr nz, .asm_81902 - ret + jr nz, .asm_5129b + ld a, b + ld [hli], a + dec de + ld a, e + or d + jr nz, .asm_51296 -Function81911: ; 81911 - ld hl, TrainerPalettes - ld de, OverworldMap - ld c, NUM_TRAINER_CLASSES -.asm_81919 - push bc - push hl - call Function81928 - pop hl - ld bc, 4 - add hl, bc +.asm_512a8 pop bc - dec c - jr nz, .asm_81919 + pop de ret -; 81928 +; 512ab -Function81928: ; 81928 - ld a, BANK(PokemonPalettes) ; BANK(TrainerPalettes) - call GetFarByte - ld [de], a - inc de - inc hl - ld a, BANK(PokemonPalettes) ; BANK(TrainerPalettes) - call GetFarByte - ld [de], a - inc de - inc hl - ld a, BANK(PokemonPalettes) ; BANK(TrainerPalettes) - call GetFarByte - ld [de], a - inc de - inc hl - ld a, BANK(PokemonPalettes) ; BANK(TrainerPalettes) - call GetFarByte - ld [de], a - inc de +Function512ab: ; 512ab + ld a, b + cp 6 + jr z, .six + cp 5 + jr z, .five + +.seven + ld c, $70 + call Function512f2 + dec b + jr nz, .seven ret -; 81948 -Function81948: ; 81948 - ld a, $1 - ld [rVBK], a - ld hl, VTiles0 - ld bc, sScratch - VTiles0 +.six + ld c, $70 xor a - call ByteFill - ld a, $0 - ld [rVBK], a - ld hl, VTiles0 - ld bc, sScratch - VTiles0 + call .Fill +.asm_512c3 + ld c, $10 xor a - call ByteFill - hlcoord 0, 0, AttrMap - ld bc, SCREEN_WIDTH * SCREEN_HEIGHT + call .Fill + ld c, $60 + call Function512f2 + dec b + jr nz, .asm_512c3 + ret + +.five + ld c, $70 xor a - call ByteFill - hlcoord 0, 0 - ld bc, SCREEN_WIDTH * SCREEN_HEIGHT + call .Fill +.asm_512d8 + ld c, $20 xor a - call ByteFill - call ClearSprites + call .Fill + ld c, $50 + call Function512f2 + dec b + jr nz, .asm_512d8 + ld c, $70 + xor a + call .Fill ret -; 8197c -Function8197c: ; 8197c - ld hl, DebugColorTestGFX + $10 - ld de, VTiles2 tile $6a - ld bc, $160 - call CopyBytes - ld hl, DebugColorTestGFX - ld de, VTiles0 - ld bc, $10 - call CopyBytes - call LoadStandardFont - ld hl, VTiles1 - lb bc, 8, 0 -.asm_8199d - ld a, [hl] - xor $ff +.Fill ld [hli], a - dec bc - ld a, c - or b - jr nz, .asm_8199d - ret -; 819a7 - -Function819a7: ; 819a7 - ld a, [hCGB] - and a - ret z - ld a, [rSVBK] - push af - ld a, $5 - ld [rSVBK], a - ld hl, Palette_819f4 - ld de, BGPals - ld bc, $80 - call CopyBytes - ld a, $80 - ld [rBGPI], a - ld hl, Palette_819f4 - ld c, $40 - xor a -.asm_819c8 - ld [rBGPD], a - dec c - jr nz, .asm_819c8 - ld a, $80 - ld [rOBPI], a - ld hl, Palette_81a34 - ld c, $40 -.asm_819d6 - ld a, [hli] - ld [rOBPD], a dec c - jr nz, .asm_819d6 - ld a, $94 - ld [wc608], a - ld a, $52 - ld [wc608 + 1], a - ld a, $4a - ld [wc608 + 2], a - ld a, $29 - ld [wc608 + 3], a - pop af - ld [rSVBK], a + jr nz, .Fill ret -; 819f4 - -Palette_819f4: ; 819f4 - ; white - RGB 31, 31, 31 - RGB 31, 31, 31 - RGB 31, 31, 31 - RGB 00, 00, 00 - - ; red - RGB 31, 00, 00 - RGB 31, 00, 00 - RGB 31, 00, 00 - RGB 00, 00, 00 - - ; green - RGB 00, 31, 00 - RGB 00, 31, 00 - RGB 00, 31, 00 - RGB 00, 00, 00 - - ; blue - RGB 00, 00, 31 - RGB 00, 00, 31 - RGB 00, 00, 31 - RGB 00, 00, 00 +; 512f2 - RGB 31, 31, 31 - RGB 31, 31, 31 - RGB 31, 31, 31 - RGB 00, 00, 00 +Function512f2: ; 512f2 + ld a, [wc2c6] + and a + jr nz, .asm_512ff +.asm_512f8 + ld a, [de] + inc de + ld [hli], a + dec c + jr nz, .asm_512f8 + ret - RGB 31, 31, 31 - RGB 31, 31, 31 - RGB 31, 31, 31 - RGB 00, 00, 00 +.asm_512ff + push bc +.asm_51300 + ld a, [de] + inc de + ld b, a + xor a + rept 8 + rr b + rla + endr + ld [hli], a + dec c + jr nz, .asm_51300 + pop bc + ret +; 51322 - RGB 31, 31, 31 - RGB 31, 31, 31 - RGB 31, 31, 31 - RGB 00, 00, 00 +Function51322: ; 51322 + ld a, BANK(sBoxCount) + call GetSRAMBank + ld hl, sBoxCount + call Function513cb + ld a, [sBoxCount] + dec a + ld [wd265], a + ld hl, sBoxMonNicknames + ld bc, PKMN_NAME_LENGTH + ld de, wd002 + call Function513e0 + ld a, [sBoxCount] + dec a + ld [wd265], a + ld hl, sBoxMonOT + ld bc, NAME_LENGTH + ld de, wd00d + call Function513e0 + ld a, [sBoxCount] + dec a + ld [wd265], a + ld hl, sBoxMons + ld bc, BOXMON_STRUCT_LENGTH + ld de, wd018 + call Function513e0 + ld hl, wd01a + ld de, TempMonMoves + ld bc, NUM_MOVES + call CopyBytes + ld hl, wd02f + ld de, TempMonPP + ld bc, NUM_MOVES + call CopyBytes + ld a, [CurPartyMon] + ld b, a + callba Functiondcb6 + jp CloseSRAM +; 5138b - RGB 31, 31, 31 - RGB 31, 31, 31 - RGB 31, 31, 31 - RGB 00, 00, 00 +Function5138b: ; 5138b + ld hl, PartyCount + call Function513cb + ld a, [PartyCount] + dec a + ld [wd265], a + ld hl, PartyMonNicknames + ld bc, PKMN_NAME_LENGTH + ld de, wd002 + call Function513e0 + ld a, [PartyCount] + dec a + ld [wd265], a + ld hl, PartyMonOT + ld bc, NAME_LENGTH + ld de, wd00d + call Function513e0 + ld a, [PartyCount] + dec a + ld [wd265], a + ld hl, PartyMons + ld bc, PARTYMON_STRUCT_LENGTH + ld de, wd018 + call Function513e0 + ret +; 513cb -Palette_81a34: ; 81a34 - RGB 31, 31, 31 - RGB 31, 31, 31 - RGB 31, 31, 31 - RGB 00, 00, 00 +Function513cb: ; 513cb + inc [hl] + inc hl + ld a, [CurPartyMon] + ld c, a + ld b, 0 + add hl, bc + ld a, [CurPartySpecies] + ld c, a +.asm_513d8 + ld a, [hl] + ld [hl], c + inc hl + inc c + ld c, a + jr nz, .asm_513d8 + ret +; 513e0 - RGB 31, 31, 31 - RGB 31, 31, 31 - RGB 31, 31, 31 - RGB 00, 00, 00 +Function513e0: ; 513e0 + push de + push hl + push bc + ld a, [wd265] + dec a + call AddNTimes + push hl + add hl, bc + ld d, h + ld e, l + pop hl +.asm_513ef + push bc + ld a, [wd265] + ld b, a + ld a, [CurPartyMon] + cp b + pop bc + jr z, .asm_51415 + push hl + push de + push bc + call CopyBytes + pop bc + pop de + pop hl + push hl + ld a, l + sub c + ld l, a + ld a, h + sbc b + ld h, a + pop de + ld a, [wd265] + dec a + ld [wd265], a + jr .asm_513ef - RGB 31, 31, 31 - RGB 31, 31, 31 - RGB 31, 31, 31 - RGB 00, 00, 00 +.asm_51415 + pop bc + pop hl + ld a, [CurPartyMon] + call AddNTimes + ld d, h + ld e, l + pop hl + call CopyBytes + ret +; 51424 - RGB 31, 31, 31 - RGB 31, 31, 31 - RGB 31, 31, 31 - RGB 00, 00, 00 +BaseData:: +INCLUDE "data/base_stats.asm" - RGB 31, 31, 31 - RGB 31, 31, 31 - RGB 31, 31, 31 - RGB 00, 00, 00 +PokemonNames:: +INCLUDE "data/pokemon_names.asm" - ; red - RGB 31, 31, 31 - RGB 31, 00, 00 - RGB 31, 00, 00 - RGB 00, 00, 00 +Unknown_53d84: ; unreferenced + db $1a, $15 + db $33, $16 + db $4b, $17 + db $62, $18 + db $79, $19 + db $90, $1a + db $a8, $1b + db $c4, $1c + db $e0, $1d + db $f6, $1e + db $ff, $1f + db $ff, $20 +; 53d9c - ; green - RGB 31, 31, 31 - RGB 00, 31, 00 - RGB 00, 31, 00 - RGB 00, 00, 00 +UnknownEggPic:: ; 53d9c +; Another egg pic. This is shifted up a few pixels. +INCBIN "gfx/misc/unknown_egg.5x5.2bpp.lz" +; 53e2e - ; blue - RGB 31, 31, 31 - RGB 00, 00, 31 - RGB 00, 00, 31 - RGB 00, 00, 00 -; 81a74 -Function81a74: ; 81a74 - call JoyTextDelay - ld a, [wJumptableIndex] - cp $4 - jr nc, .asm_81a8b - ld hl, hJoyLast - ld a, [hl] - and SELECT - jr nz, .asm_81a9a - ld a, [hl] - and START - jr nz, .asm_81aab +SECTION "bank19", ROMX, BANK[$19] -.asm_81a8b - ld a, [wJumptableIndex] - ld e, a - ld d, 0 - ld hl, Jumptable_81acf -rept 2 - add hl, de -endr - ld a, [hli] - ld h, [hl] - ld l, a - jp [hl] +INCLUDE "text/phone/extra.asm" -.asm_81a9a - call Function81eca - call Function81ac3 - ld e, a - ld a, [wcf66] - inc a - cp e - jr c, .asm_81aba - xor a - jr .asm_81aba -.asm_81aab - call Function81eca - ld a, [wcf66] - dec a - cp $ff - jr nz, .asm_81aba - call Function81ac3 - dec a -.asm_81aba - ld [wcf66], a - ld a, $0 - ld [wJumptableIndex], a - ret -; 81ac3 +SECTION "bank20", ROMX, BANK[$20] -Function81ac3: ; 81ac3 -; Looping back around the pic set. - ld a, [wd002] - and a - jr nz, .asm_81acc - ld a, NUM_POKEMON ; CELEBI - ret -.asm_81acc - ld a, NUM_TRAINER_CLASSES - 1 ; MYSTICALMAN +DoPlayerMovement:: ; 80000 + + call GetMovementInput + ld a, movement_step_sleep_1 + ld [MovementAnimation], a + xor a + ld [wd041], a + call GetPlayerMovement + ld c, a + ld a, [MovementAnimation] + ld [wc2de], a ret -; 81acf +; 80017 -Jumptable_81acf: ; 81acf - dw Function81adb - dw Function81c18 - dw Function81c33 - dw Function81cc2 - dw Function81d8e - dw Function81daf -; 81adb -Function81adb: ; 81adb - xor a - ld [hBGMapMode], a - hlcoord 0, 0 - ld bc, SCREEN_WIDTH * SCREEN_HEIGHT - ld a, $6f - call ByteFill - hlcoord 1, 3 - lb bc, 7, 18 - ld a, $6c - call Bank20_FillBoxWithByte - hlcoord 11, 0 - lb bc, 2, 3 - ld a, $6d - call Bank20_FillBoxWithByte - hlcoord 16, 0 - lb bc, 2, 3 - ld a, $6e - call Bank20_FillBoxWithByte - call Function81bc0 - call Function81bf4 - ld a, [wcf66] - inc a - ld [CurPartySpecies], a - ld [wd265], a - hlcoord 0, 1 - ld de, wd265 - lb bc, PRINTNUM_LEADINGZEROS | 1, 3 - call PrintNum - ld a, [wd002] - and a - jr nz, .asm_81b7a - ld a, $1 - ld [UnownLetter], a - call GetPokemonName - hlcoord 4, 1 - call PlaceString - xor a - ld [wc2c6], a - hlcoord 12, 3 - call _PrepMonFrontpic - ld de, VTiles2 tile $31 - predef GetBackpic - ld a, $31 - ld [hFillBox], a - hlcoord 2, 4 - lb bc, 6, 6 - predef FillBox - ld a, [wd003] - and a - jr z, .asm_81b66 - ld de, String_81baf - jr .asm_81b69 +GetMovementInput: ; 80017 -.asm_81b66 - ld de, String_81bb4 + ld a, [hJoyDown] + ld [CurInput], a -.asm_81b69 - hlcoord 7, 17 - call PlaceString - hlcoord 0, 17 - ld de, String_81bb9 - call PlaceString - jr .asm_81ba9 +; Standing downhill instead moves down. -.asm_81b7a - ld a, [wd265] - ld [TrainerClass], a - callab Function3957b - ld de, StringBuffer1 - hlcoord 4, 1 - call PlaceString - ld de, VTiles2 - callab GetTrainerPic - xor a - ld [TempEnemyMonSpecies], a - ld [hFillBox], a - hlcoord 2, 3 - lb bc, 7, 7 - predef FillBox + ld hl, BikeFlags + bit 2, [hl] ; downhill + ret z -.asm_81ba9 - ld a, $1 - ld [wJumptableIndex], a + ld c, a + and D_PAD + ret nz + + ld a, c + or D_DOWN + ld [CurInput], a ret -; 81baf +; 8002d -String_81baf: db "レア", $6f, $6f, "@" ; rare (shiny) -String_81bb4: db "ノーマル@" ; normal -String_81bb9: db $7a, "きりかえ▶@" ; (A) switches -; 81bc0 -Function81bc0: ; 81bc0 - decoord 0, 11, AttrMap - hlcoord 2, 11 - ld a, $1 - call Function81bde - decoord 0, 13, AttrMap - hlcoord 2, 13 - ld a, $2 - call Function81bde - decoord 0, 15, AttrMap - hlcoord 2, 15 - ld a, $3 +GetPlayerMovement: ; 8002d -Function81bde: ; 81bde - push af - ld a, $6a - ld [hli], a - ld bc, $f - ld a, $6b - call ByteFill - ld l, e - ld h, d - pop af - ld bc, $28 - call ByteFill - ret -; 81bf4 + ld a, [PlayerState] + cp PLAYER_NORMAL + jr z, .Normal + cp PLAYER_SURF + jr z, .Surf + cp PLAYER_SURF_PIKA + jr z, .Surf + cp PLAYER_BIKE + jr z, .Normal + cp PLAYER_SLIP + jr z, .Ice -Function81bf4: ; 81bf4 - ld a, [wcf66] - inc a - ld l, a - ld h, $0 -rept 2 - add hl, hl -endr - ld de, OverworldMap - add hl, de - ld de, wc608 - ld bc, 4 - call CopyBytes - xor a - ld [wcf64], a - ld [wcf65], a - ld de, wc608 - call Function81ea5 - ret -; 81c18 +.Normal + call CheckForcedMovementInput + call GetMovementAction + call CheckTileMovement + ret c + call CheckTurning + ret c + call TryStep + ret c + call TryJumpLedge + ret c + call CheckEdgeWarp + ret c + jr .NotMoving -Function81c18: ; 81c18 - ld a, [hCGB] - and a - jr z, .asm_81c2a - ld a, $2 - ld [hBGMapMode], a - call DelayFrame - call DelayFrame - call DelayFrame +.Surf + call CheckForcedMovementInput + call GetMovementAction + call CheckTileMovement + ret c + call CheckTurning + ret c + call TrySurfStep + ret c + jr .NotMoving -.asm_81c2a - call WaitBGMap - ld a, $2 - ld [wJumptableIndex], a +.Ice + call CheckForcedMovementInput + call GetMovementAction + call CheckTileMovement + ret c + call CheckTurning + ret c + call TryStep + ret c + call TryJumpLedge + ret c + call CheckEdgeWarp + ret c + ld a, [WalkingDirection] + cp STANDING + jr z, .HitWall + call PlayBump +.HitWall + call StandInPlace + xor a ret -; 81c33 -Function81c33: ; 81c33 - ld a, [hCGB] +.NotMoving + ld a, [WalkingDirection] + cp STANDING + jr z, .Standing + +; Walking into an edge warp won't bump. + ld a, [EngineBuffer4] and a - jr z, .asm_81c69 - ld a, [rSVBK] - push af - ld a, $5 - ld [rSVBK], a - ld hl, BGPals - ld de, wc608 - ld c, $1 - call Function81ee3 - hlcoord 10, 2 - ld de, wc608 - call Function81ca7 - hlcoord 15, 2 - ld de, wc608 + 2 - call Function81ca7 - ld a, $1 - ld [hCGBPalUpdate], a - ld a, $3 - ld [wJumptableIndex], a - pop af - ld [rSVBK], a + jr nz, .CantMove + call PlayBump +.CantMove + call WalkInPlace + xor a ret -.asm_81c69 - ld hl, wcda9 - ld a, $1 - ld [hli], a - ld a, $ff - ld [hli], a - ld a, $7f - ld [hli], a - ld a, [wc608] - ld [hli], a - ld a, [wc608 + 1] - ld [hli], a - ld a, [wc608 + 2] - ld [hli], a - ld a, [wc608 + 3] - ld [hli], a +.Standing + call StandInPlace xor a -rept 2 - ld [hli], a -endr - ld [hl], a - ld hl, wcda9 - call Function81f0c - hlcoord 10, 2 - ld de, wc608 - call Function81ca7 - hlcoord 15, 2 - ld de, wc608 + 2 - call Function81ca7 - ld a, $3 - ld [wJumptableIndex], a ret -; 81ca7 +; 800b7 -Function81ca7: ; 81ca7 -rept 3 - inc hl -endr - ld a, [de] - call Function81cbc - ld a, [de] - swap a - call Function81cbc - inc de - ld a, [de] - call Function81cbc - ld a, [de] - swap a -Function81cbc: ; 81cbc - and $f - add $70 - ld [hld], a +CheckTileMovement: ; 800b7 +; Tiles such as waterfalls and warps move the player +; in a given direction, overriding input. + + ld a, [PlayerNextTile] + ld c, a + call CheckWhirlpoolTile + jr c, .asm_800c4 + ld a, 3 + scf ret -; 81cc2 -Function81cc2: ; 81cc2 - ld a, [hJoyLast] - and B_BUTTON - jr nz, .asm_81cdf - ld a, [hJoyLast] - and A_BUTTON - jr nz, .asm_81ce5 - ld a, [wcf64] - and $3 - ld e, a - ld d, 0 - ld hl, Jumptable_81d02 -rept 2 - add hl, de -endr - ld a, [hli] - ld h, [hl] - ld l, a - jp [hl] +.asm_800c4 + and $f0 + cp $30 ; moving water + jr z, .water + cp $40 ; moving land 1 + jr z, .land1 + cp $50 ; moving land 2 + jr z, .land2 + cp $70 ; warps + jr z, .warps + jr .asm_8013c -.asm_81cdf - ld a, $4 - ld [wJumptableIndex], a - ret +.water + ld a, c + and 3 + ld c, a + ld b, 0 + ld hl, .water_table + add hl, bc + ld a, [hl] + ld [WalkingDirection], a + jr .asm_8013e -.asm_81ce5 - ld a, [wd002] - and a - ret nz - ld a, [wd003] - xor $4 - ld [wd003], a +.water_table + db RIGHT + db LEFT + db UP + db DOWN + +.land1 + ld a, c + and 7 ld c, a ld b, 0 - ld hl, PokemonPalettes + ld hl, .land1_table add hl, bc - call Function818fd - ld a, $0 - ld [wJumptableIndex], a + ld a, [hl] + cp STANDING + jr z, .asm_8013c + ld [WalkingDirection], a + jr .asm_8013e + +.land1_table + db STANDING + db RIGHT + db LEFT + db UP + db DOWN + db STANDING + db STANDING + db STANDING + +.land2 + ld a, c + and 7 + ld c, a + ld b, 0 + ld hl, .land2_table + add hl, bc + ld a, [hl] + cp STANDING + jr z, .asm_8013c + ld [WalkingDirection], a + jr .asm_8013e + +.land2_table + db RIGHT + db LEFT + db UP + db DOWN + db STANDING + db STANDING + db STANDING + db STANDING + +.warps + ld a, c + cp $71 ; door + jr z, .down + cp $79 + jr z, .down + cp $7a ; stairs + jr z, .down + cp $7b ; cave + jr nz, .asm_8013c + +.down + ld a, DOWN + ld [WalkingDirection], a + jr .asm_8013e + +.asm_8013c + xor a ret -; 81d02 -Jumptable_81d02: ; 81d02 - dw Function81d0a - dw Function81d34 - dw Function81d46 - dw Function81d58 -; 81d0a +.asm_8013e + ld a, STEP_WALK + call DoStep + ld a, 5 + scf + ret +; 80147 + + +CheckTurning: ; 80147 +; If the player is turning, change direction first. This also lets +; the player change facing without moving by tapping a direction. + + ld a, [wd04e] + cp 0 + jr nz, .asm_80169 + ld a, [WalkingDirection] + cp STANDING + jr z, .asm_80169 + + ld e, a + ld a, [PlayerDirection] + rrca + rrca + and 3 + cp e + jr z, .asm_80169 -Function81d0a: ; 81d0a - ld hl, hJoyLast - ld a, [hl] - and D_DOWN - jr nz, Function81d89 - ld a, [hl] - and D_LEFT - jr nz, .asm_81d1d - ld a, [hl] - and D_RIGHT - jr nz, .asm_81d28 + ld a, STEP_TURN + call DoStep + ld a, 2 + scf ret -.asm_81d1d +.asm_80169 xor a - ld [wcf65], a - ld de, wc608 - call Function81ea5 ret +; 8016b -.asm_81d28 - ld a, $1 - ld [wcf65], a - ld de, wc608 + 2 - call Function81ea5 - ret -Function81d34: ; 81d34 - ld hl, hJoyLast - ld a, [hl] - and D_DOWN - jr nz, Function81d89 - ld a, [hl] - and D_UP - jr nz, Function81d84 - ld hl, wc608 + 10 - jr Function81d63 +TryStep: ; 8016b -Function81d46: ; 81d46 - ld hl, hJoyLast - ld a, [hl] - and D_DOWN - jr nz, Function81d89 - ld a, [hl] - and D_UP - jr nz, Function81d84 - ld hl, wc608 + 11 - jr Function81d63 +; Surfing actually calls TrySurfStep directly instead of passing through here. + ld a, [PlayerState] + cp PLAYER_SURF + jr z, TrySurfStep + cp PLAYER_SURF_PIKA + jr z, TrySurfStep -Function81d58: ; 81d58 - ld hl, hJoyLast - ld a, [hl] - and D_UP - jr nz, Function81d84 - ld hl, wc608 + 12 + call CheckLandPermissions + jr c, .bump -Function81d63: ; 81d63 - ld a, [hJoyLast] - and D_RIGHT - jr nz, Function81d70 - ld a, [hJoyLast] - and D_LEFT - jr nz, Function81d77 - ret + call IsNPCInFront + and a + jr z, .bump + cp 2 + jr z, .bump -Function81d70: ; 81d70 - ld a, [hl] - cp $1f - ret nc - inc [hl] - jr Function81d7b + ld a, [PlayerNextTile] + call CheckIceTile + jr nc, .ice -Function81d77: ; 81d77 - ld a, [hl] - and a - ret z - dec [hl] +; Downhill riding is slower when not moving down. + call CheckRiding + jr nz, .walk -Function81d7b: ; 81d7b - call Function81e67 - ld a, $2 - ld [wJumptableIndex], a - ret + ld hl, BikeFlags + bit 2, [hl] ; downhill + jr z, .fast -Function81d84: ; 81d84 - ld hl, wcf64 - dec [hl] - ret + ld a, [WalkingDirection] + cp DOWN + jr z, .fast -Function81d89: ; 81d89 - ld hl, wcf64 - inc [hl] + ld a, STEP_WALK + call DoStep + scf ret -; 81d8e -Function81d8e: ; 81d8e - hlcoord 0, 10 - ld bc, $a0 - ld a, $6f - call ByteFill - hlcoord 2, 12 - ld de, String_81fcd - call PlaceString - xor a - ld [wd004], a - call Function81df4 - ld a, $5 - ld [wJumptableIndex], a +.fast + ld a, STEP_BIKE + call DoStep + scf ret -; 81daf -Function81daf: ; 81daf - ld hl, hJoyPressed - ld a, [hl] - and B_BUTTON - jr nz, .asm_81dbb - call Function81dc7 +.walk + ld a, STEP_WALK + call DoStep + scf ret -.asm_81dbb - ld a, $0 - ld [wJumptableIndex], a +.ice + ld a, STEP_ICE + call DoStep + scf ret -; 81dc1 -Function81dc1: ; 81dc1 - ld hl, wJumptableIndex - set 7, [hl] +; unused? + xor a ret -; 81dc7 -Function81dc7: ; 81dc7 - ld hl, hJoyLast - ld a, [hl] - and D_UP - jr nz, .asm_81dd5 - ld a, [hl] - and D_DOWN - jr nz, .asm_81de2 +.bump + xor a ret +; 801c0 -.asm_81dd5 - ld a, [wd004] - cp $3b - jr z, .asm_81ddf - inc a - jr .asm_81ded -.asm_81ddf - xor a - jr .asm_81ded +TrySurfStep: ; 801c0 -.asm_81de2 - ld a, [wd004] + call CheckWaterPermissions + ld [wd040], a + jr c, .bump + + call IsNPCInFront + ld [wd03f], a and a - jr z, .asm_81deb - dec a - jr .asm_81ded + jr z, .bump + cp 2 + jr z, .bump -.asm_81deb - ld a, $3b + ld a, [wd040] + and a + jr nz, .ExitWater -.asm_81ded - ld [wd004], a - call Function81df4 + ld a, STEP_WALK + call DoStep + scf ret -; 81df4 -Function81df4: ; 81df4 - hlcoord 10, 11 - call Function81e5e - hlcoord 10, 12 - call Function81e5e - hlcoord 10, 13 - call Function81e5e - hlcoord 10, 14 - call Function81e5e - ld a, [wd004] - inc a - ld [wd265], a - predef GetTMHMMove - ld a, [wd265] - ld [wd262], a - call GetMoveName - hlcoord 10, 12 - call PlaceString - ld a, [wd004] - call Function81e55 - ld [CurItem], a - predef CanLearnTMHMMove - ld a, c - and a - ld de, String_81e46 - jr nz, .asm_81e3f - ld de, String_81e4d +.ExitWater + call WaterToLandSprite + call PlayMapMusic + ld a, STEP_WALK + call DoStep + ld a, 6 + scf + ret -.asm_81e3f - hlcoord 10, 14 - call PlaceString +.bump + xor a ret -; 81e46 +; 801f3 -String_81e46: db "おぼえられる@" ; can be taught -String_81e4d: db "おぼえられない@" ; cannot be taught -; 81e55 -Function81e55: ; 81e55 - cp $32 - jr c, .asm_81e5b -rept 2 - inc a -endr +TryJumpLedge: ; 801f3 + ld a, [PlayerNextTile] + ld e, a + and $f0 + cp $a0 ; ledge + jr nz, .DontJump -.asm_81e5b - add $bf + ld a, e + and 7 + ld e, a + ld d, 0 + ld hl, .data_8021e + add hl, de + ld a, [FacingDirection] + and [hl] + jr z, .DontJump + + ld de, SFX_JUMP_OVER_LEDGE + call PlaySFX + ld a, STEP_LEDGE + call DoStep + ld a, 7 + scf ret -; 81e5e -Function81e5e: ; 81e5e - ld bc, $a - ld a, $6f - call ByteFill +.DontJump + xor a ret -; 81e67 -Function81e67: ; 81e67 - ld a, [wc608 + 10] - and $1f +.data_8021e + db FACE_RIGHT + db FACE_LEFT + db FACE_UP + db FACE_DOWN + db FACE_RIGHT | FACE_DOWN + db FACE_DOWN | FACE_LEFT + db FACE_UP | FACE_RIGHT + db FACE_UP | FACE_LEFT +; 80226 + + +CheckEdgeWarp: ; 80226 + +; Bug: Since no case is made for STANDING here, it will check +; [.edgewarps + $ff]. This resolves to $3e at $8035a. +; This causes wd041 to be nonzero when standing on tile $3e, +; making bumps silent. + + ld a, [WalkingDirection] ld e, a - ld a, [wc608 + 11] - and $7 - sla a - swap a - or e + ld d, 0 + ld hl, .EdgeWarps + add hl, de + ld a, [PlayerNextTile] + cp [hl] + jr nz, .nope + + ld a, 1 + ld [wd041], a + ld a, [WalkingDirection] + cp STANDING + jr z, .nope + ld e, a - ld a, [wc608 + 11] - and $18 - sla a - swap a - ld d, a - ld a, [wc608 + 12] - and $1f - sla a - sla a - or d - ld d, a - ld a, [wcf65] - and a - jr z, .asm_81e9c - ld a, e - ld [wc608 + 2], a - ld a, d - ld [wc608 + 3], a - ret + ld a, [PlayerDirection] + rrca + rrca + and 3 + cp e + jr nz, .nope + call WarpCheck + jr nc, .nope -.asm_81e9c - ld a, e - ld [wc608], a - ld a, d - ld [wc608 + 1], a + call StandInPlace + scf + ld a, 1 ret -; 81ea5 -Function81ea5: ; 81ea5 - ld a, [de] - and $1f - ld [wc608 + 10], a - ld a, [de] - and $e0 - swap a - srl a - ld b, a - inc de - ld a, [de] - and $3 - swap a - srl a - or b - ld [wc608 + 11], a - ld a, [de] - and $7c - srl a - srl a - ld [wc608 + 12], a +.nope + xor a ret -; 81eca -Function81eca: ; 81eca - ld a, [wcf66] - inc a - ld l, a - ld h, $0 +.EdgeWarps + db $70, $78, $76, $7e +; 8025f + + +DoStep: ; 8025f + ld e, a + ld d, 0 + ld hl, .Steps rept 2 - add hl, hl + add hl, de endr - ld de, OverworldMap + ld a, [hli] + ld h, [hl] + ld l, a + + ld a, [WalkingDirection] + ld e, a + cp STANDING + jp z, StandInPlace + add hl, de - ld e, l - ld d, h - ld hl, wc608 - ld bc, 4 - call CopyBytes + ld a, [hl] + ld [MovementAnimation], a + + ld hl, .WalkInPlace + add hl, de + ld a, [hl] + ld [wd04e], a + + ld a, 4 ret -; 81ee3 -Function81ee3: ; 81ee3 -.asm_81ee3 - ld a, $ff - ld [hli], a - ld a, $7f - ld [hli], a - ld a, [de] - inc de - ld [hli], a - ld a, [de] - inc de - ld [hli], a - ld a, [de] - inc de - ld [hli], a - ld a, [de] - inc de - ld [hli], a +.Steps + dw .Slow + dw .Walk + dw .Bike + dw .Ledge + dw .Ice + dw .Turn + dw .BackwardsLedge + dw .WalkInPlace + +.Slow + slow_step_down + slow_step_up + slow_step_left + slow_step_right +.Walk + step_down + step_up + step_left + step_right +.Bike + big_step_down + big_step_up + big_step_left + big_step_right +.Ledge + jump_step_down + jump_step_up + jump_step_left + jump_step_right +.Ice + fast_slide_step_down + fast_slide_step_up + fast_slide_step_left + fast_slide_step_right +.BackwardsLedge + jump_step_up + jump_step_down + jump_step_right + jump_step_left +.Turn + half_step_down + half_step_up + half_step_left + half_step_right +.WalkInPlace + db $80 + movement_turn_head_down + db $80 + movement_turn_head_up + db $80 + movement_turn_head_left + db $80 + movement_turn_head_right +; 802b3 + + +StandInPlace: ; 802b3 + ld a, 0 + ld [wd04e], a + ld a, movement_step_sleep_1 + ld [MovementAnimation], a xor a -rept 2 - ld [hli], a -endr - dec c - jr nz, .asm_81ee3 ret -; 81efc +; 802bf -Bank20_FillBoxWithByte: ; 81efc -; For some reason, we have another copy of FillBoxWithByte here -.row - push bc - push hl -.col - ld [hli], a - dec c - jr nz, .col - pop hl - ld bc, SCREEN_WIDTH - add hl, bc - pop bc - dec b - jr nz, .row - ret -; 81f0c -Function81f0c: ; 81f0c - ld a, [wcfbe] - push af - set 7, a - ld [wcfbe], a - call Function81f1d - pop af - ld [wcfbe], a +WalkInPlace: ; 802bf + ld a, 0 + ld [wd04e], a + ld a, movement_step_bump + ld [MovementAnimation], a + xor a ret -; 81f1d +; 802cb -Function81f1d: ; 81f1d - ld a, [hl] - and $7 + +CheckForcedMovementInput: ; 802cb +; When sliding on ice, input is forced to remain in the same direction. + + call CheckStandingOnIce + ret nc + + ld a, [wd04e] + cp 0 ret z - ld b, a -.asm_81f22 - push bc - xor a - ld [rJOYP], a - ld a, $30 - ld [rJOYP], a - ld b, $10 -.asm_81f2c - ld e, $8 - ld a, [hli] - ld d, a -.asm_81f30 - bit 0, d - ld a, $10 - jr nz, .asm_81f38 - ld a, $20 -.asm_81f38 - ld [rJOYP], a - ld a, $30 - ld [rJOYP], a - rr d - dec e - jr nz, .asm_81f30 - dec b - jr nz, .asm_81f2c - ld a, $20 - ld [rJOYP], a - ld a, $30 - ld [rJOYP], a - ld de, 7000 -.asm_81f51 - nop - nop - nop - dec de - ld a, d - or e - jr nz, .asm_81f51 - pop bc - dec b - jr nz, .asm_81f22 + and 3 + ld e, a + ld d, 0 + ld hl, .data_802e8 + add hl, de + ld a, [CurInput] + and BUTTONS + or [hl] + ld [CurInput], a ret -; 81f5e -Function81f5e: ; 81f5e - ld a, $6f - hlcoord 10, 0 - ld [hl], a - hlcoord 15, 0 - ld [hl], a - hlcoord 1, 11 - ld [hl], a - hlcoord 1, 13 - ld [hl], a - hlcoord 1, 15 - ld [hl], a - ld a, [wJumptableIndex] - cp $3 - jr nz, .asm_81fc9 - ld a, [wcf64] - and a - jr z, .asm_81f8d - dec a - hlcoord 1, 11 - ld bc, 2 * SCREEN_WIDTH - call AddNTimes - ld [hl], $ed +.data_802e8 + db D_DOWN, D_UP, D_LEFT, D_RIGHT +; 802ec -.asm_81f8d - ld a, [wcf65] - and a - jr z, .asm_81f98 - hlcoord 15, 0 - jr .asm_81f9b -.asm_81f98 - hlcoord 10, 0 +GetMovementAction: ; 802ec +; Poll player input and update movement info. -.asm_81f9b - ld [hl], $ed - ld b, $70 - ld c, $5 - ld hl, Sprites - ld de, wc608 + 10 - call .asm_81fb7 - ld de, wc608 + 11 - call .asm_81fb7 - ld de, wc608 + 12 - call .asm_81fb7 - ret + ld hl, .table + ld de, .table2 - .table1 + ld a, [CurInput] + bit 7, a + jr nz, .down + bit 6, a + jr nz, .up + bit 5, a + jr nz, .left + bit 4, a + jr nz, .right +; Standing + jr .update -.asm_81fb7 - ld a, b - ld [hli], a - ld a, [de] -rept 2 - add a -endr - add $18 - ld [hli], a - xor a - ld [hli], a - ld a, c - ld [hli], a - ld a, $10 - add b - ld b, a - inc c - ret +.down add hl, de +.up add hl, de +.left add hl, de +.right add hl, de -.asm_81fc9 - call ClearSprites +.update + ld a, [hli] + ld [WalkingDirection], a + ld a, [hli] + ld [FacingDirection], a + ld a, [hli] + ld [WalkingX], a + ld a, [hli] + ld [WalkingY], a + ld a, [hli] + ld h, [hl] + ld l, a + ld a, [hl] + ld [WalkingTile], a ret -; 81fcd -String_81fcd: ; 81fcd - db "おわりますか?" ; Are you finished? - next "はい", $f2, $f2, $f2, $7a ; YES (A) - next "いいえ", $f2, $f2, $7b ; NO (B) - db "@" -; 81fe3 +.table +; struct: +; walk direction +; facing +; x movement +; y movement +; tile collision pointer +.table1 + db STANDING, FACE_CURRENT, 0, 0 + dw PlayerNextTile +.table2 + db RIGHT, FACE_RIGHT, 1, 0 + dw TileRight + db LEFT, FACE_LEFT, -1, 0 + dw TileLeft + db UP, FACE_UP, 0, -1 + dw TileUp + db DOWN, FACE_DOWN, 0, 1 + dw TileDown +; 80341 -DebugColorTestGFX: -INCBIN "gfx/debug/color_test.2bpp" +IsNPCInFront: ; 80341 +; Returns 0 if there is an NPC in front that you can't move +; Returns 1 if there is no NPC in front +; Returns 2 if there is a movable NPC in front + ld a, 0 + ld [hMapObjectIndexBuffer], a +; Load the next X coordinate into d + ld a, [PlayerNextMapX] + ld d, a + ld a, [WalkingX] + add d + ld d, a +; Load the next Y coordinate into e + ld a, [PlayerNextMapY] + ld e, a + ld a, [WalkingY] + add e + ld e, a +; Find an object struct with coordinates equal to d,e + ld bc, ObjectStructs ; redundant + callba IsNPCAtCoord + jr nc, .nope + call Function8036f + jr c, .no_bump + +; .bump + xor a + ret -TilesetColorTest: +.nope + ld a, 1 ret - xor a - ld [wJumptableIndex], a - ld [wcf64], a - ld [wcf65], a - ld [wcf66], a - ld [hMapAnims], a - call ClearSprites - call OverworldTextModeSwitch - call Function3200 - xor a - ld [hBGMapMode], a - ld de, DebugColorTestGFX + $10 - ld hl, VTiles2 tile $6a - lb bc, BANK(DebugColorTestGFX), $16 - call Request2bpp - ld de, DebugColorTestGFX - ld hl, VTiles1 - lb bc, BANK(DebugColorTestGFX), 1 - call Request2bpp - ld a, VBGMap1 / $100 - ld [hBGMapAddress + 1], a - hlcoord 0, 0 - ld bc, SCREEN_WIDTH * SCREEN_HEIGHT - ld a, $6f - call ByteFill - hlcoord 0, 0, AttrMap - ld bc, SCREEN_WIDTH * SCREEN_HEIGHT - ld a, $7 - call ByteFill - ld de, $15 - ld a, $6c - call Function821d2 - ld de, $1a - ld a, $6d - call Function821d2 - ld de, $1f - ld a, $6e - call Function821d2 - ld de, $24 - ld a, $6f - call Function821d2 - call Function821f4 - call Function8220f - call Function3200 - ld [wJumptableIndex], a - ld a, $40 - ld [hWY], a + +.no_bump + ld a, 2 ret -; 821d2 +; 8036f -Function821d2: ; 821d2 - hlcoord 0, 0 - call Function821de -Function821d8: ; 821d8 - ld a, [wcf64] - hlcoord 0, 0, AttrMap +Function8036f: ; 8036f -Function821de: ; 821de - add hl, de -rept 4 - ld [hli], a -endr - ld bc, $10 + ld hl, BikeFlags + bit 0, [hl] ; using strength + jr z, .nope + + ld hl, OBJECT_DIRECTION_WALKING add hl, bc -rept 4 - ld [hli], a -endr - ld bc, $10 + ld a, [hl] + cp STANDING + jr nz, .nope + + ld hl, OBJECT_PALETTE add hl, bc -rept 4 - ld [hli], a -endr - ret -; 821f4 + bit 6, [hl] + jr z, .nope -Function821f4: ; 821f4 - hlcoord 2, 4 - call Function82203 - hlcoord 2, 6 - call Function82203 - hlcoord 2, 8 + ld hl, OBJECT_FLAGS2 + add hl, bc + set 2, [hl] -Function82203: ; 82203 - ld a, $6a - ld [hli], a - ld bc, $10 - 1 - ld a, $6b - call ByteFill + ld a, [WalkingDirection] + ld d, a + ld hl, OBJECT_RANGE + add hl, bc + ld a, [hl] + and $fc + or d + ld [hl], a + + scf ret -; 8220f -Function8220f: ; 8220f - ld a, [rSVBK] - push af - ld a, $5 - ld [rSVBK], a - ld a, [wcf64] - ld l, a - ld h, $0 -rept 3 - add hl, hl -endr - ld de, wMapPals - add hl, de - ld de, wc608 - ld bc, 8 - call CopyBytes - ld de, wc608 - call Function81ea5 - pop af - ld [rSVBK], a +.nope + xor a ret -; 82236 +; 8039e -Function82236: ; 82236 - ld hl, hJoyLast - ld a, [hl] - and SELECT - jr nz, .loop7 - ld a, [hl] - and B_BUTTON - jr nz, .asm_82299 - call Function822f0 - ret +CheckLandPermissions: ; 8039e +; Return 0 if walking onto land and tile permissions allow it. +; Otherwise, return carry. -.loop7 - ld hl, wcf64 - ld a, [hl] - inc a - and $7 - cp $7 - jr nz, .asm_82253 - xor a + ld a, [TilePermissions] + ld d, a + ld a, [FacingDirection] + and d + jr nz, .NotWalkable -.asm_82253 - ld [hl], a - ld de, $15 - call Function821d8 - ld de, $1a - call Function821d8 - ld de, $1f - call Function821d8 - ld de, $24 - call Function821d8 - ld a, [rSVBK] - push af - ld a, $5 - ld [rSVBK], a - ld hl, BGPals - ld a, [wcf64] - ld bc, 8 - call AddNTimes - ld de, wc608 - ld bc, 8 - call CopyBytes - pop af - ld [rSVBK], a - ld a, $2 - ld [hBGMapMode], a - ld c, 3 - call DelayFrames - ld a, $1 - ld [hBGMapMode], a + ld a, [WalkingTile] + call CheckWalkable + jr c, .NotWalkable + + xor a ret -.asm_82299 - call ClearSprites - ld a, [hWY] - xor $d0 - ld [hWY], a +.NotWalkable + scf ret -; 822a3 +; 803b4 -Function822a3: ; 822a3 - ld a, [rSVBK] - push af - ld a, $5 - ld [rSVBK], a - ld hl, BGPals - ld a, [wcf64] - ld bc, 8 - call AddNTimes - ld e, l - ld d, h - ld hl, wc608 - ld bc, 8 - call CopyBytes - hlcoord 1, 0 - ld de, wc608 - call Function81ca7 - hlcoord 6, 0 - ld de, wc608 + 2 - call Function81ca7 - hlcoord 11, 0 - ld de, wc608 + 4 - call Function81ca7 - hlcoord 16, 0 - ld de, wc608 + 6 - call Function81ca7 - pop af - ld [rSVBK], a - ld a, $1 - ld [hCGBPalUpdate], a - call DelayFrame +CheckWaterPermissions: ; 803b4 +; Return 0 if moving in water, or 1 if moving onto land. +; Otherwise, return carry. + + ld a, [TilePermissions] + ld d, a + ld a, [FacingDirection] + and d + jr nz, .NotSurfable + + ld a, [WalkingTile] + call CheckSurfable + jr c, .NotSurfable + + and a ret -; 822f0 -Function822f0: ; 822f0 - ld a, [wcf65] - and 3 - ld e, a - ld d, 0 - ld hl, .jumptable -rept 2 - add hl, de -endr - ld a, [hli] - ld h, [hl] - ld l, a - jp [hl] -; 82301 +.NotSurfable + scf + ret +; 803ca -.jumptable: ; 82301 - dw Function82309 - dw Function82339 - dw Function8234b - dw Function8235d -; 82309 -Function82309: ; 82309 - ld hl, hJoyLast - ld a, [hl] - and D_DOWN - jr nz, Function8238c - ld a, [hl] - and D_LEFT - jr nz, .asm_8231c - ld a, [hl] - and D_RIGHT - jr nz, .asm_82322 +CheckRiding: ; 803ca + + ld a, [PlayerState] + cp PLAYER_BIKE + ret z + cp PLAYER_SLIP ret +; 803d3 -.asm_8231c - ld a, [wcf66] - dec a - jr .asm_82326 -.asm_82322 - ld a, [wcf66] - inc a +CheckWalkable: ; 803d3 +; Return 0 if tile a is land. Otherwise, return carry. -.asm_82326 - and $3 - ld [wcf66], a - ld e, a - ld d, $0 - ld hl, wc608 -rept 2 - add hl, de -endr - ld e, l - ld d, h - call Function81ea5 + call GetTileCollision + and a ; land + ret z + scf ret +; 803da -Function82339: ; 82338 - ld hl, hJoyLast - ld a, [hl] - and D_DOWN - jr nz, Function8238c - ld a, [hl] - and D_UP - jr nz, Function82387 - ld hl, wc608 + 10 - jr Function82368 -Function8234b: ; 8234b - ld hl, hJoyLast - ld a, [hl] - and D_DOWN - jr nz, Function8238c - ld a, [hl] - and D_UP - jr nz, Function82387 - ld hl, wc608 + 11 - jr Function82368 +CheckSurfable: ; 803da +; Return 0 if tile a is water, or 1 if land. +; Otherwise, return carry. -Function8235d: ; 8235d - ld hl, hJoyLast - ld a, [hl] - and D_UP - jr nz, Function82387 - ld hl, wc608 + 12 + call GetTileCollision + cp 1 + jr z, .Water -Function82368: ; 82368 - ld a, [hJoyLast] - and D_RIGHT - jr nz, .asm_82375 - ld a, [hJoyLast] - and D_LEFT - jr nz, .asm_8237c - ret +; Can walk back onto land from water. + and a + jr z, .Land -.asm_82375 - ld a, [hl] - cp $1f - ret nc - inc [hl] - jr .asm_82380 + jr .Neither -.asm_8237c - ld a, [hl] +.Water + xor a + ret + +.Land + ld a, 1 and a - ret z - dec [hl] + ret -.asm_82380 - call Function82391 - call Function822a3 +.Neither + scf ret +; 803ee -Function82387: ; 82387 - ld hl, wcf65 - dec [hl] + +PlayBump: ; 803ee + + call CheckSFX + ret c + ld de, SFX_BUMP + call PlaySFX ret +; 803f9 -Function8238c: ; 8238c - ld hl, wcf65 - inc [hl] + +WaterToLandSprite: ; 803f9 + push bc + ld a, PLAYER_NORMAL + ld [PlayerState], a + call ReplaceKrisSprite ; UpdateSprites + pop bc ret -; 82391 +; 80404 -Function82391: ; 82391 - ld a, [wc608 + 10] - and $1f - ld e, a - ld a, [wc608 + 11] - and $7 - sla a - swap a - or e - ld e, a - ld a, [wc608 + 11] - and $18 - sla a - swap a - ld d, a - ld a, [wc608 + 12] - and $1f - sla a - sla a - or d - ld d, a - ld a, [wcf66] - ld c, a - ld b, $0 - ld hl, wc608 -rept 2 - add hl, bc -endr - ld a, e - ld [hli], a - ld [hl], d + +CheckStandingOnIce:: ; 80404 + ld a, [wd04e] + cp 0 + jr z, .nope + cp $f0 + jr z, .nope + ld a, [PlayerNextTile] + call CheckIceTile + jr nc, .yep + ld a, [PlayerState] + cp PLAYER_SLIP + jr nz, .nope + +.yep + scf ret -; 823c6 -Function823c6: ; 823c6 +.nope + and a ret +; 80422 -Function823c7: ; 823c7 + +Function80422:: ; 80422 + ld hl, wc2de + ld a, movement_step_sleep_1 + cp [hl] + ret z + + ld [hl], a + ld a, 0 + ld [wd04e], a ret -; 823c8 +; 80430 + + + +EngineFlagAction:: ; 80430 +; Do action b on engine flag de +; +; b = 0: reset flag +; = 1: set flag +; > 1: check flag, result in c +; +; Setting/resetting does not return a result. + + +; 16-bit flag ids are considered invalid, but it's nice +; to know that the infrastructure is there. + + ld a, d + cp 0 + jr z, .ceiling + jr c, .read ; cp 0 can't set carry! + jr .invalid +; There are only $a2 engine flags, so +; anything beyond that is invalid too. + +.ceiling + ld a, e + cp NUM_ENGINE_FLAGS + jr c, .read -SECTION "bank21", ROMX, BANK[$21] +; Invalid flags are treated as flag 00. -Function84000: ; 84000 - ld hl, OverworldMap - lb bc, 4, 12 - xor a - call Function842ab - xor a - ld [rSB], a - ld [rSC], a - ld [wc2d5], a - ld hl, wc2d4 - set 0, [hl] - ld a, [GBPrinter] - ld [wcbfb], a +.invalid xor a - ld [wJumptableIndex], a - ret -; 84022 - -Function84022: ; 84022 - ld a, [wJumptableIndex] ld e, a - ld d, 0 - ld hl, Jumptable_84031 + ld d, a + +; Get this flag's location. + +.read + ld hl, EngineFlags +; location rept 2 add hl, de endr - ld a, [hli] - ld h, [hl] - ld l, a - jp [hl] -; 84031 +; bit + add hl, de +; location + ld e, [hl] + inc hl + ld d, [hl] + inc hl +; bit + ld c, [hl] -Jumptable_84031: ; 84031 (21:4031) - dw Function84077 - dw Function84143 - dw Function84120 - dw Function84099 - dw Function84180 - dw Function8412e - dw Function840c5 - dw Function84180 - dw Function84120 - dw Function840de - dw Function84180 - dw Function84120 - dw Function841a1 - dw Function84063 - dw Function8406d - dw Function84120 - dw Function84103 - dw Function84071 - dw Function841b0 - dw Function841b3 +; What are we doing with this flag? + ld a, b + cp 1 + jr c, .reset ; b = 0 + jr z, .set ; b = 1 -Function84059: ; 84059 (21:4059) - ld hl, wJumptableIndex - inc [hl] +; Return the given flag in c. +.check + ld a, [de] + and c + ld c, a ret -Function8405e: ; 8405e (21:405e) - ld hl, wJumptableIndex - dec [hl] +; Set the given flag. +.set + ld a, [de] + or c + ld [de], a ret -Function84063: ; 84063 (21:4063) - xor a - ld [wca89], a - ld hl, wJumptableIndex - set 7, [hl] +; Reset the given flag. +.reset + ld a, c + cpl ; AND all bits except the one in question + ld c, a + ld a, [de] + and c + ld [de], a ret +; 80462 -Function8406d: ; 8406d (21:406d) - call Function84059 - ret -Function84071: ; 84071 (21:4071) - ld a, $1 - ld [wJumptableIndex], a - ret +EngineFlags: ; 80462 +INCLUDE "engine/engine_flags.asm" +; 80648 -Function84077: ; 84077 (21:4077) - call Function841fb - ld hl, Unknown_842b7 - call Function841e2 - xor a - ld [wca8e], a - ld [wca8f], a - ld a, [wcf65] - ld [wca81], a - call Function84059 - call Function841c3 - ld a, $1 - ld [wcbf8], a - ret -Function84099: ; 84099 (21:4099) - call Function841fb - ld hl, wca81 - ld a, [hl] - and a - jr z, Function840c5 - ld hl, Unknown_842c3 - call Function841e2 - call Function84260 - ld a, $80 - ld [wca8e], a - ld a, $2 - ld [wca8f], a - call Function84219 - call Function84059 - call Function841c3 - ld a, $2 - ld [wcbf8], a - ret -Function840c5: ; 840c5 (21:40c5) - ld a, $6 - ld [wJumptableIndex], a - ld hl, Unknown_842c9 - call Function841e2 +_GetVarAction:: ; 80648 (20:4648) + ld a, c + cp NUM_VARS + jr c, .valid xor a - ld [wca8e], a - ld [wca8f], a - call Function84059 - call Function841c3 - ret +.valid + ld c, a + ld b, 0 + ld hl, .VarActionTable +rept 3 + add hl, bc +endr + ld e, [hl] + inc hl + ld d, [hl] + inc hl + ld b, [hl] + ld a, b + and RETVAR_EXECUTE + jr nz, .call + ld a, b + and RETVAR_ADDR_DE + ret nz + ld a, [de] + jr .loadstringbuffer2 -Function840de: ; 840de (21:40de) - call Function841fb - ld hl, Unknown_842bd - call Function841e2 - call Function84249 - ld a, $4 - ld [wca8e], a - ld a, $0 - ld [wca8f], a - call Function84219 - call Function84059 - call Function841c3 - ld a, $3 - ld [wcbf8], a +.call + call _de_ ret -Function84103: ; 84103 (21:4103) - call Function841fb - ld hl, Unknown_842b7 - call Function841e2 - xor a - ld [wca8e], a - ld [wca8f], a - ld a, [wcf65] - ld [wca81], a - call Function84059 - call Function841c3 +.loadstringbuffer2: ; 8066c (20:466c) + ld de, StringBuffer2 + ld [de], a ret +; 80671 (20:4671) -Function84120: ; 84120 (21:4120) - ld hl, wca8b - inc [hl] - ld a, [hl] - cp $6 - ret c - xor a - ld [hl], a - call Function84059 - ret +.VarActionTable: ; 80671 +; $00: copy [de] to StringBuffer2 +; $40: return address in de +; $80: call function + dwb StringBuffer2, RETVAR_STRBUF2 + dwb PartyCount, RETVAR_STRBUF2 + dwb .BattleResult, RETVAR_EXECUTE + dwb BattleType, RETVAR_ADDR_DE + dwb TimeOfDay, RETVAR_STRBUF2 + dwb .CountCaughtMons, RETVAR_EXECUTE + dwb .CountSeenMons, RETVAR_EXECUTE + dwb .CountBadges, RETVAR_EXECUTE + dwb PlayerState, RETVAR_ADDR_DE + dwb .PlayerFacing, RETVAR_EXECUTE + dwb hHours, RETVAR_STRBUF2 + dwb .DayOfWeek, RETVAR_EXECUTE + dwb MapGroup, RETVAR_STRBUF2 + dwb MapNumber, RETVAR_STRBUF2 + dwb .UnownCaught, RETVAR_EXECUTE + dwb wPermission, RETVAR_STRBUF2 + dwb .BoxFreeSpace, RETVAR_EXECUTE + dwb wBugContestMinsRemaining, RETVAR_STRBUF2 + dwb XCoord, RETVAR_STRBUF2 + dwb YCoord, RETVAR_STRBUF2 + dwb wSpecialPhoneCallID, RETVAR_STRBUF2 + dwb wcf64, RETVAR_STRBUF2 + dwb wKurtApricornQuantity, RETVAR_STRBUF2 + dwb wCurrentCaller, RETVAR_ADDR_DE + dwb wBlueCardBalance, RETVAR_ADDR_DE + dwb wBuenasPassword, RETVAR_ADDR_DE + dwb wdc58, RETVAR_STRBUF2 + dwb NULL, RETVAR_STRBUF2 +; 806c5 + +.CountCaughtMons: ; 806c5 +; Caught mons. + ld hl, PokedexCaught + ld b, EndPokedexCaught - PokedexCaught + call CountSetBits + ld a, [wd265] + jp .loadstringbuffer2 +; 806d3 -Function8412e: ; 8412e (21:412e) - ld hl, wca8b - inc [hl] - ld a, [hl] - cp $6 - ret c - xor a - ld [hl], a - ld hl, wca81 - dec [hl] - call Function8405e - call Function8405e - ret +.CountSeenMons: ; 806d3 +; Seen mons. + ld hl, PokedexSeen + ld b, EndPokedexSeen - PokedexSeen + call CountSetBits + ld a, [wd265] + jp .loadstringbuffer2 +; 806e1 -Function84143: ; 84143 (21:4143) - ld a, [wc2d5] - and a - ret nz - ld a, [wca88] - cp $ff - jr nz, .printer_connected - ld a, [wca89] - cp $ff - jr z, .printer_error +.CountBadges: ; 806e1 +; Number of owned badges. + ld hl, Badges + ld b, 2 + call CountSetBits + ld a, [wd265] + jp .loadstringbuffer2 +; 806ef -.printer_connected - ld a, [wca88] - cp $81 - jr nz, .printer_error - ld a, [wca89] - cp $0 - jr nz, .printer_error - ld hl, wc2d4 - set 1, [hl] - ld a, $5 - ld [wca8a], a - call Function84059 - ret +.PlayerFacing: ; 806ef +; The direction the player is facing. + ld a, [PlayerDirection] + and $c + rrca + rrca + jp .loadstringbuffer2 +; 806f9 -.printer_error - ld a, $ff - ld [wca88], a - ld [wca89], a - ld a, $e - ld [wJumptableIndex], a - ret +.DayOfWeek: ; 806f9 +; The day of the week. + call GetWeekday + jp .loadstringbuffer2 +; 806ff -Function84180: ; 84180 (21:4180) - ld a, [wc2d5] - and a - ret nz - ld a, [wca89] - and $f0 - jr nz, .asm_8419b - ld a, [wca89] - and $1 - jr nz, .asm_84197 - call Function84059 - ret -.asm_84197 - call Function8405e - ret -.asm_8419b - ld a, $12 - ld [wJumptableIndex], a - ret +.UnownCaught: ; 806ff +; Number of unique Unown caught. + call .count + ld a, b + jp .loadstringbuffer2 -Function841a1: ; 841a1 (21:41a1) - ld a, [wc2d5] +.count + ld hl, UnownDex + ld b, 0 +.loop + ld a, [hli] and a - ret nz - ld a, [wca89] - and $f3 - ret nz - call Function84059 + ret z + inc b + ld a, b + cp 26 + jr c, .loop ret +; 80715 -Function841b0: ; 841b0 (21:41b0) - call Function84059 +.BoxFreeSpace: ; 80715 +; Remaining slots in the current box. + ld a, BANK(sBoxCount) + call GetSRAMBank + ld hl, sBoxCount + ld a, MONS_PER_BOX + sub [hl] + ld b, a + call CloseSRAM + ld a, b + jp .loadstringbuffer2 +; 80728 -Function841b3: ; 841b3 (21:41b3) - ld a, [wc2d5] - and a - ret nz - ld a, [wca89] - and $f0 - ret nz - xor a - ld [wJumptableIndex], a - ret +.BattleResult: ; 80728 + ld a, [wBattleResult] + and $3f + jp .loadstringbuffer2 +; 80730 -Function841c3: ; 841c3 (21:41c3) - ld a, [wc2d5] - and a - jr nz, Function841c3 - xor a - ld [wca8c], a - ld [wca8d], a - ld a, $1 - ld [wc2d5], a - ld a, $88 - ld [rSB], a - ld a, $1 - ld [rSC], a - ld a, $81 - ld [rSC], a - ret -Function841e2: ; 841e2 (21:41e2) - ld a, [hli] - ld [wca82], a - ld a, [hli] - ld [wca83], a - ld a, [hli] - ld [wca84], a - ld a, [hli] - ld [wca85], a - ld a, [hli] - ld [wca86], a - ld a, [hl] - ld [wca87], a - ret +BattleText:: +INCLUDE "text/battle.asm" -Function841fb: ; 841fb (21:41fb) - xor a - ld hl, wca82 -rept 3 - ld [hli], a -endr - ld [hl], a - ld hl, wca86 - ld [hli], a - ld [hl], a - xor a - ld [wca8e], a - ld [wca8f], a - ld hl, OverworldMap - ld bc, $280 - call Function842ab - ret -Function84219: ; 84219 (21:4219) - ld hl, 0 - ld bc, $4 - ld de, wca82 - call Function8423c - ld a, [wca8e] - ld c, a - ld a, [wca8f] - ld b, a - ld de, OverworldMap - call Function8423c - ld a, l - ld [wca86], a - ld a, h - ld [wca87], a - ret +ColorTest: ; 818ac +; A debug menu to test monster and trainer palettes at runtime. -Function8423c: ; 8423c (21:423c) - ld a, [de] - inc de - add l - jr nc, .asm_84242 - inc h -.asm_84242 - ld l, a - dec bc - ld a, c - or b - jr nz, Function8423c - ret + ld a, [hCGB] + and a + jr nz, .asm_818b5 + ld a, [hSGB] + and a + ret z + +.asm_818b5 + ld a, [hInMenu] + push af + ld a, $1 + ld [hInMenu], a + call DisableLCD + call Function81948 + call Function8197c + call Function819a7 + call Function818f4 + call EnableLCD + ld de, MUSIC_NONE + call PlayMusic + xor a + ld [wJumptableIndex], a + ld [wcf66], a + ld [wd003], a +.asm_818de + ld a, [wJumptableIndex] + bit 7, a + jr nz, .asm_818f0 + call Function81a74 + call Function81f5e + call DelayFrame + jr .asm_818de -Function84249: ; 84249 (21:4249) - ld a, $1 - ld [OverworldMap], a - ld a, [wcbfa] - ld [wc801], a - ld a, $e4 - ld [wc802], a - ld a, [wcbfb] - ld [wc803], a +.asm_818f0 + pop af + ld [hInMenu], a ret +; 818f4 -Function84260: ; 84260 (21:4260) - ld a, [wca81] - xor $ff - ld d, a - ld a, [wcf65] - inc a - add d - ld hl, wca90 - ld de, $28 -.asm_84271 +Function818f4: ; 818f4 + ld a, [wd002] and a - jr z, .asm_84278 - add hl, de - dec a - jr .asm_84271 -.asm_84278 - ld e, l - ld d, h - ld hl, OverworldMap - ld c, $28 -.asm_8427f - ld a, [de] - inc de + jr nz, Function81911 + ld hl, PokemonPalettes + +Function818fd: ; 818fd + ld de, OverworldMap + ld c, NUM_POKEMON + 1 +.asm_81902 push bc - push de push hl - swap a - ld d, a - and $f0 - ld e, a - ld a, d - and $f - ld d, a - and $8 - ld a, d - jr nz, .asm_84297 - or $90 - jr .asm_84299 -.asm_84297 - or $80 -.asm_84299 - ld d, a - lb bc, $21, 1 - call Request2bpp + call Function81928 pop hl - ld de, $10 - add hl, de - pop de + ld bc, 8 + add hl, bc pop bc dec c - jr nz, .asm_8427f + jr nz, .asm_81902 ret -Function842ab: ; 842ab - push de - ld e, a -.asm_842ad - ld [hl], e - inc hl - dec bc - ld a, c - or b - jr nz, .asm_842ad - ld a, e - pop de +Function81911: ; 81911 + ld hl, TrainerPalettes + ld de, OverworldMap + ld c, NUM_TRAINER_CLASSES +.asm_81919 + push bc + push hl + call Function81928 + pop hl + ld bc, 4 + add hl, bc + pop bc + dec c + jr nz, .asm_81919 ret -; 842b7 - -Unknown_842b7: db 1, 0, $00, 0, 1, 0 -Unknown_842bd: db 2, 0, $04, 0, 0, 0 -Unknown_842c3: db 4, 0, $80, 2, 0, 0 -Unknown_842c9: db 4, 0, $00, 0, 4, 0 -Unknown_842cf: db 8, 0, $00, 0, 8, 0 ; unused -Unknown_842d5: db 15, 0, $00, 0, 15, 0 ; unused -; 842db - - -Function842db:: ; 842db - ld a, [wc2d5] - add a - ld e, a - ld d, 0 - ld hl, Jumptable_842ea - add hl, de - ld a, [hli] - ld h, [hl] - ld l, a - jp [hl] -; 842ea - +; 81928 -Jumptable_842ea: ; 842ea (21:42ea) - dw Function8432f - dw Function84330 - dw Function84339 - dw Function84343 - dw Function8434d - dw Function84357 - dw Function84361 - dw Function8438b - dw Function84395 - dw Function8439f - dw Function843a8 - dw Function843b6 - dw Function84330 - dw Function843c0 - dw Function843c9 - dw Function843c9 - dw Function843c9 - dw Function843c0 - dw Function843c9 - dw Function8439f - dw Function843a8 - dw Function843e6 - dw Function84330 - dw Function843d2 - dw Function843c9 - dw Function843c9 - dw Function843c9 - dw Function843d2 - dw Function843c9 - dw Function8439f - dw Function843a8 - dw Function843b6 +Function81928: ; 81928 + ld a, BANK(PokemonPalettes) ; BANK(TrainerPalettes) + call GetFarByte + ld [de], a + inc de + inc hl + ld a, BANK(PokemonPalettes) ; BANK(TrainerPalettes) + call GetFarByte + ld [de], a + inc de + inc hl + ld a, BANK(PokemonPalettes) ; BANK(TrainerPalettes) + call GetFarByte + ld [de], a + inc de + inc hl + ld a, BANK(PokemonPalettes) ; BANK(TrainerPalettes) + call GetFarByte + ld [de], a + inc de + ret +; 81948 +Function81948: ; 81948 + ld a, $1 + ld [rVBK], a + ld hl, VTiles0 + ld bc, sScratch - VTiles0 + xor a + call ByteFill + ld a, $0 + ld [rVBK], a + ld hl, VTiles0 + ld bc, sScratch - VTiles0 + xor a + call ByteFill + hlcoord 0, 0, AttrMap + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT + xor a + call ByteFill + hlcoord 0, 0 + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT + xor a + call ByteFill + call ClearSprites + ret +; 8197c -Function8432a: ; 8432a (21:432a) - ld hl, wc2d5 - inc [hl] +Function8197c: ; 8197c + ld hl, DebugColorTestGFX + $10 + ld de, VTiles2 tile $6a + ld bc, $160 + call CopyBytes + ld hl, DebugColorTestGFX + ld de, VTiles0 + ld bc, $10 + call CopyBytes + call LoadStandardFont + ld hl, VTiles1 + lb bc, 8, 0 +.asm_8199d + ld a, [hl] + xor $ff + ld [hli], a + dec bc + ld a, c + or b + jr nz, .asm_8199d ret +; 819a7 -Function8432f: ; 8432f (21:432f) +Function819a7: ; 819a7 + ld a, [hCGB] + and a + ret z + ld a, [rSVBK] + push af + ld a, $5 + ld [rSVBK], a + ld hl, Palette_819f4 + ld de, BGPals + ld bc, $80 + call CopyBytes + ld a, $80 + ld [rBGPI], a + ld hl, Palette_819f4 + ld c, $40 + xor a +.asm_819c8 + ld [rBGPD], a + dec c + jr nz, .asm_819c8 + ld a, $80 + ld [rOBPI], a + ld hl, Palette_81a34 + ld c, $40 +.asm_819d6 + ld a, [hli] + ld [rOBPD], a + dec c + jr nz, .asm_819d6 + ld a, $94 + ld [wc608], a + ld a, $52 + ld [wc608 + 1], a + ld a, $4a + ld [wc608 + 2], a + ld a, $29 + ld [wc608 + 3], a + pop af + ld [rSVBK], a ret +; 819f4 -Function84330: ; 84330 (21:4330) - ld a, $33 - call Function843db - call Function8432a - ret +Palette_819f4: ; 819f4 + ; white + RGB 31, 31, 31 + RGB 31, 31, 31 + RGB 31, 31, 31 + RGB 00, 00, 00 -Function84339: ; 84339 (21:4339) - ld a, [wca82] - call Function843db - call Function8432a - ret + ; red + RGB 31, 00, 00 + RGB 31, 00, 00 + RGB 31, 00, 00 + RGB 00, 00, 00 -Function84343: ; 84343 (21:4343) - ld a, [wca83] - call Function843db - call Function8432a - ret + ; green + RGB 00, 31, 00 + RGB 00, 31, 00 + RGB 00, 31, 00 + RGB 00, 00, 00 -Function8434d: ; 8434d (21:434d) - ld a, [wca84] - call Function843db - call Function8432a - ret + ; blue + RGB 00, 00, 31 + RGB 00, 00, 31 + RGB 00, 00, 31 + RGB 00, 00, 00 -Function84357: ; 84357 (21:4357) - ld a, [wca85] - call Function843db - call Function8432a - ret + RGB 31, 31, 31 + RGB 31, 31, 31 + RGB 31, 31, 31 + RGB 00, 00, 00 -Function84361: ; 84361 (21:4361) - ld hl, wca8e - ld a, [hli] - ld d, [hl] - ld e, a - or d - jr z, .asm_84388 - dec de - ld [hl], d - dec hl - ld [hl], e - ld a, [wca8c] - ld e, a - ld a, [wca8d] - ld d, a - ld hl, OverworldMap - add hl, de - inc de - ld a, e - ld [wca8c], a - ld a, d - ld [wca8d], a - ld a, [hl] - call Function843db - ret -.asm_84388 - call Function8432a + RGB 31, 31, 31 + RGB 31, 31, 31 + RGB 31, 31, 31 + RGB 00, 00, 00 -Function8438b: ; 8438b (21:438b) - ld a, [wca86] - call Function843db - call Function8432a - ret + RGB 31, 31, 31 + RGB 31, 31, 31 + RGB 31, 31, 31 + RGB 00, 00, 00 -Function84395: ; 84395 (21:4395) - ld a, [wca87] - call Function843db - call Function8432a - ret + RGB 31, 31, 31 + RGB 31, 31, 31 + RGB 31, 31, 31 + RGB 00, 00, 00 -Function8439f: ; 8439f (21:439f) - ld a, $0 - call Function843db - call Function8432a - ret +Palette_81a34: ; 81a34 + RGB 31, 31, 31 + RGB 31, 31, 31 + RGB 31, 31, 31 + RGB 00, 00, 00 -Function843a8: ; 843a8 (21:43a8) - ld a, [rSB] - ld [wca88], a - ld a, $0 - call Function843db - call Function8432a - ret + RGB 31, 31, 31 + RGB 31, 31, 31 + RGB 31, 31, 31 + RGB 00, 00, 00 -Function843b6: ; 843b6 (21:43b6) - ld a, [rSB] - ld [wca89], a - xor a - ld [wc2d5], a - ret + RGB 31, 31, 31 + RGB 31, 31, 31 + RGB 31, 31, 31 + RGB 00, 00, 00 -Function843c0: ; 843c0 (21:43c0) - ld a, $f - call Function843db - call Function8432a - ret + RGB 31, 31, 31 + RGB 31, 31, 31 + RGB 31, 31, 31 + RGB 00, 00, 00 -Function843c9: ; 843c9 (21:43c9) - ld a, $0 - call Function843db - call Function8432a - ret + RGB 31, 31, 31 + RGB 31, 31, 31 + RGB 31, 31, 31 + RGB 00, 00, 00 -Function843d2: ; 843d2 (21:43d2) - ld a, $8 - call Function843db - call Function8432a - ret + ; red + RGB 31, 31, 31 + RGB 31, 00, 00 + RGB 31, 00, 00 + RGB 00, 00, 00 -Function843db: ; 843db (21:43db) - ld [rSB], a - ld a, $1 - ld [rSC], a - ld a, $81 - ld [rSC], a - ret + ; green + RGB 31, 31, 31 + RGB 00, 31, 00 + RGB 00, 31, 00 + RGB 00, 00, 00 -Function843e6: ; 843e6 (21:43e6) - ld a, [rSB] - ld [wca89], a - xor a - ld [wc2d5], a - ret + ; blue + RGB 31, 31, 31 + RGB 00, 00, 31 + RGB 00, 00, 31 + RGB 00, 00, 00 +; 81a74 -Function843f0: ; 843f0 -.asm_843f0 +Function81a74: ; 81a74 call JoyTextDelay - call Function846f6 - jr c, .asm_8440f ld a, [wJumptableIndex] - bit 7, a - jr nz, .asm_8440d - call Function84022 - call Function84757 - call Function84785 - call DelayFrame - jr .asm_843f0 + cp $4 + jr nc, .asm_81a8b + ld hl, hJoyLast + ld a, [hl] + and SELECT + jr nz, .asm_81a9a + ld a, [hl] + and START + jr nz, .asm_81aab -.asm_8440d - and a - ret +.asm_81a8b + ld a, [wJumptableIndex] + ld e, a + ld d, 0 + ld hl, Jumptable_81acf +rept 2 + add hl, de +endr + ld a, [hli] + ld h, [hl] + ld l, a + jp [hl] + +.asm_81a9a + call Function81eca + call Function81ac3 + ld e, a + ld a, [wcf66] + inc a + cp e + jr c, .asm_81aba + xor a + jr .asm_81aba + +.asm_81aab + call Function81eca + ld a, [wcf66] + dec a + cp $ff + jr nz, .asm_81aba + call Function81ac3 + dec a -.asm_8440f - scf +.asm_81aba + ld [wcf66], a + ld a, $0 + ld [wJumptableIndex], a ret -; 84411 +; 81ac3 -Function84411: ; 84411 - xor a - ld [wc2d4], a - ld [wc2d5], a +Function81ac3: ; 81ac3 +; Looping back around the pic set. + ld a, [wd002] + and a + jr nz, .asm_81acc + ld a, NUM_POKEMON ; CELEBI ret -; 84419 -Function84419: ; 84419 - push af - call Function84000 - pop af - ld [wcbfa], a - call Function84728 +.asm_81acc + ld a, NUM_TRAINER_CLASSES - 1 ; MYSTICALMAN ret -; 84425 +; 81acf -Function84425: ; 84425 - call ReturnToMapFromSubmenu - call Function84753 - ret -; 8442c +Jumptable_81acf: ; 81acf + dw Function81adb + dw Function81c18 + dw Function81c33 + dw Function81cc2 + dw Function81d8e + dw Function81daf +; 81adb -Function8442c: ; 8442c - ld a, [wcf65] - push af - ld hl, VTiles1 - ld de, FontInversed - lb bc, BANK(FontInversed), $80 - call Request1bpp - xor a - ld [$ffac], a - call Function8474c - ld a, [rIE] - push af - xor a - ld [rIF], a - ld a, $9 - ld [rIE], a - call Function84000 - ld a, $10 - ld [wcbfa], a - callba Function1dc1b0 - call ClearTileMap - ld a, $e4 - call DmgToCgbBGPals - call DelayFrame - ld hl, hVBlank - ld a, [hl] - push af - ld [hl], $4 - ld a, $8 - ld [wcf65], a - call Function84742 - call Function843f0 - jr c, .asm_8449d - call Function84411 - ld c, 12 - call DelayFrames +Function81adb: ; 81adb xor a ld [hBGMapMode], a - call Function84000 - ld a, $3 - ld [wcbfa], a - callba Function1dc213 - call Function84742 - ld a, $4 - ld [wcf65], a - call Function843f0 + hlcoord 0, 0 + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT + ld a, $6f + call ByteFill + hlcoord 1, 3 + lb bc, 7, 18 + ld a, $6c + call Bank20_FillBoxWithByte + hlcoord 11, 0 + lb bc, 2, 3 + ld a, $6d + call Bank20_FillBoxWithByte + hlcoord 16, 0 + lb bc, 2, 3 + ld a, $6e + call Bank20_FillBoxWithByte + call Function81bc0 + call Function81bf4 + ld a, [wcf66] + inc a + ld [CurPartySpecies], a + ld [wd265], a + hlcoord 0, 1 + ld de, wd265 + lb bc, PRINTNUM_LEADINGZEROS | 1, 3 + call PrintNum + ld a, [wd002] + and a + jr nz, .asm_81b7a + ld a, $1 + ld [UnownLetter], a + call GetPokemonName + hlcoord 4, 1 + call PlaceString + xor a + ld [wc2c6], a + hlcoord 12, 3 + call _PrepMonFrontpic + ld de, VTiles2 tile $31 + predef GetBackpic + ld a, $31 + ld [hFillBox], a + hlcoord 2, 4 + lb bc, 6, 6 + predef FillBox + ld a, [wd003] + and a + jr z, .asm_81b66 + ld de, String_81baf + jr .asm_81b69 -.asm_8449d - pop af - ld [hVBlank], a - call Function84411 +.asm_81b66 + ld de, String_81bb4 + +.asm_81b69 + hlcoord 7, 17 + call PlaceString + hlcoord 0, 17 + ld de, String_81bb9 + call PlaceString + jr .asm_81ba9 + +.asm_81b7a + ld a, [wd265] + ld [TrainerClass], a + callab Function3957b + ld de, StringBuffer1 + hlcoord 4, 1 + call PlaceString + ld de, VTiles2 + callab GetTrainerPic xor a - ld [rIF], a - pop af - ld [rIE], a - call Function84425 - ld c, $8 -.asm_844ae - call LowVolume - call DelayFrame - dec c - jr nz, .asm_844ae - pop af - ld [wcf65], a + ld [TempEnemyMonSpecies], a + ld [hFillBox], a + hlcoord 2, 3 + lb bc, 7, 7 + predef FillBox + +.asm_81ba9 + ld a, $1 + ld [wJumptableIndex], a ret -; 844bc +; 81baf -Function844bc: ; 844bc (21:44bc) - ld a, [wcf65] - push af - ld a, $9 - ld [wcf65], a - ld a, e - ld [wd004], a - ld a, d - ld [StartFlypoint], a - ld a, b - ld [EndFlypoint], a - ld a, c - ld [MovementBuffer], a - xor a - ld [$ffac], a - ld [wd003], a - call Function8474c - ld a, [rIE] - push af - xor a - ld [rIF], a - ld a, $9 - ld [rIE], a - ld hl, hVBlank - ld a, [hl] - push af - ld [hl], $4 - xor a - ld [hBGMapMode], a - call Function84817 - ld a, $10 - call Function84419 - call Function84559 - jr c, .asm_84545 - call Function84411 - ld c, 12 - call DelayFrames - xor a - ld [hBGMapMode], a - call Function8486f - ld a, $0 - call Function84419 - call Function84559 - jr c, .asm_84545 - call Function84411 - ld c, 12 - call DelayFrames - xor a - ld [hBGMapMode], a - call Function84893 - ld a, $0 - call Function84419 - call Function84559 - jr c, .asm_84545 - call Function84411 - ld c, 12 - call DelayFrames - xor a - ld [hBGMapMode], a - call Function848b7 +String_81baf: db "レア", $6f, $6f, "@" ; rare (shiny) +String_81bb4: db "ノーマル@" ; normal +String_81bb9: db $7a, "きりかえ▶@" ; (A) switches +; 81bc0 + +Function81bc0: ; 81bc0 + decoord 0, 11, AttrMap + hlcoord 2, 11 + ld a, $1 + call Function81bde + decoord 0, 13, AttrMap + hlcoord 2, 13 + ld a, $2 + call Function81bde + decoord 0, 15, AttrMap + hlcoord 2, 15 ld a, $3 - call Function84419 - call Function84559 -.asm_84545 + +Function81bde: ; 81bde + push af + ld a, $6a + ld [hli], a + ld bc, $f + ld a, $6b + call ByteFill + ld l, e + ld h, d pop af - ld [hVBlank], a - call Function84411 + ld bc, $28 + call ByteFill + ret +; 81bf4 + +Function81bf4: ; 81bf4 + ld a, [wcf66] + inc a + ld l, a + ld h, $0 +rept 2 + add hl, hl +endr + ld de, OverworldMap + add hl, de + ld de, wc608 + ld bc, 4 + call CopyBytes xor a - ld [rIF], a - pop af - ld [rIE], a - call Function84425 - pop af + ld [wcf64], a ld [wcf65], a + ld de, wc608 + call Function81ea5 ret +; 81c18 -Function84559: ; 84559 (21:4559) - call Function84742 - call Function843f0 +Function81c18: ; 81c18 + ld a, [hCGB] + and a + jr z, .asm_81c2a + ld a, $2 + ld [hBGMapMode], a + call DelayFrame + call DelayFrame + call DelayFrame + +.asm_81c2a + call WaitBGMap + ld a, $2 + ld [wJumptableIndex], a ret +; 81c33 -Function84560: ; 84560 - ld a, [wcf65] - push af - xor a - ld [$ffac], a - call Function8474c - ld a, [rIE] - push af - xor a - ld [rIF], a - ld a, $9 - ld [rIE], a - ld hl, hVBlank - ld a, [hl] +Function81c33: ; 81c33 + ld a, [hCGB] + and a + jr z, .asm_81c69 + ld a, [rSVBK] push af - ld [hl], $4 + ld a, $5 + ld [rSVBK], a + ld hl, BGPals + ld de, wc608 + ld c, $1 + call Function81ee3 + hlcoord 10, 2 + ld de, wc608 + call Function81ca7 + hlcoord 15, 2 + ld de, wc608 + 2 + call Function81ca7 + ld a, $1 + ld [hCGBPalUpdate], a + ld a, $3 + ld [wJumptableIndex], a + pop af + ld [rSVBK], a + ret + +.asm_81c69 + ld hl, wcda9 + ld a, $1 + ld [hli], a + ld a, $ff + ld [hli], a + ld a, $7f + ld [hli], a + ld a, [wc608] + ld [hli], a + ld a, [wc608 + 1] + ld [hli], a + ld a, [wc608 + 2] + ld [hli], a + ld a, [wc608 + 3] + ld [hli], a xor a - ld [hBGMapMode], a - call LoadTileMapToTempTileMap - callba Function16dac - ld a, $0 - call Function84419 - call Call_LoadTempTileMapToTileMap - call Function84742 - ld a, $9 - ld [wcf65], a -.asm_84597 - call JoyTextDelay - call Function846f6 - jr c, .asm_845c0 - ld a, [wJumptableIndex] - bit 7, a - jr nz, .asm_845c0 - call Function84022 - ld a, [wJumptableIndex] - cp $2 - jr nc, .asm_845b5 +rept 2 + ld [hli], a +endr + ld [hl], a + ld hl, wcda9 + call Function81f0c + hlcoord 10, 2 + ld de, wc608 + call Function81ca7 + hlcoord 15, 2 + ld de, wc608 + 2 + call Function81ca7 ld a, $3 - ld [wca81], a + ld [wJumptableIndex], a + ret +; 81ca7 -.asm_845b5 - call Function84757 - call Function84785 - call DelayFrame - jr .asm_84597 +Function81ca7: ; 81ca7 +rept 3 + inc hl +endr + ld a, [de] + call Function81cbc + ld a, [de] + swap a + call Function81cbc + inc de + ld a, [de] + call Function81cbc + ld a, [de] + swap a -.asm_845c0 - pop af - ld [hVBlank], a - call Function84411 - call Call_LoadTempTileMapToTileMap - xor a - ld [rIF], a - pop af - ld [rIE], a - pop af - ld [wcf65], a +Function81cbc: ; 81cbc + and $f + add $70 + ld [hld], a ret -; 845d4 +; 81cc2 -Function845d4: ; 845d4 - call Function845db - call Function84425 +Function81cc2: ; 81cc2 + ld a, [hJoyLast] + and B_BUTTON + jr nz, .asm_81cdf + ld a, [hJoyLast] + and A_BUTTON + jr nz, .asm_81ce5 + ld a, [wcf64] + and $3 + ld e, a + ld d, 0 + ld hl, Jumptable_81d02 +rept 2 + add hl, de +endr + ld a, [hli] + ld h, [hl] + ld l, a + jp [hl] + +.asm_81cdf + ld a, $4 + ld [wJumptableIndex], a ret -; 845db -Function845db: ; 845db - ld a, [wcf65] - push af - xor a - ld [$ffac], a - call Function8474c - ld a, [rIE] - push af - xor a - ld [rIF], a - ld a, $9 - ld [rIE], a - xor a - ld [hBGMapMode], a - ld a, $13 - call Function84419 - ld hl, hVBlank - ld a, [hl] - push af - ld [hl], $4 - ld a, $9 - ld [wcf65], a - call Function843f0 - pop af - ld [hVBlank], a - call Function84411 - call Function84735 - xor a - ld [rIF], a - pop af - ld [rIE], a - pop af - ld [wcf65], a +.asm_81ce5 + ld a, [wd002] + and a + ret nz + ld a, [wd003] + xor $4 + ld [wd003], a + ld c, a + ld b, 0 + ld hl, PokemonPalettes + add hl, bc + call Function818fd + ld a, $0 + ld [wJumptableIndex], a ret -; 8461a +; 81d02 -Function8461a: ; 8461a - ld a, [wcf65] - push af - xor a - ld [$ffac], a - call Function8474c - ld a, [rIE] - push af - xor a - ld [rIF], a - ld a, $9 - ld [rIE], a - xor a - ld [hBGMapMode], a - callba Function1dc381 - ld a, $10 - call Function84419 - ld hl, hVBlank +Jumptable_81d02: ; 81d02 + dw Function81d0a + dw Function81d34 + dw Function81d46 + dw Function81d58 +; 81d0a + +Function81d0a: ; 81d0a + ld hl, hJoyLast ld a, [hl] - push af - ld [hl], $4 - ld a, $8 - ld [wcf65], a - call Function84742 - call Function843f0 - jr c, .asm_84671 - call Function84411 - ld c, 12 - call DelayFrames + and D_DOWN + jr nz, Function81d89 + ld a, [hl] + and D_LEFT + jr nz, .asm_81d1d + ld a, [hl] + and D_RIGHT + jr nz, .asm_81d28 + ret + +.asm_81d1d xor a - ld [hBGMapMode], a - callba Function1dc47b - ld a, $3 - call Function84419 - ld a, $9 ld [wcf65], a - call Function84742 - call Function843f0 + ld de, wc608 + call Function81ea5 + ret -.asm_84671 - pop af - ld [hVBlank], a - call Function84411 - call Function84735 - xor a - ld [rIF], a - pop af - ld [rIE], a - call Function84425 - pop af +.asm_81d28 + ld a, $1 ld [wcf65], a + ld de, wc608 + 2 + call Function81ea5 ret -; 84688 -Function84688: ; 84688 - ld a, [wcf65] - push af - callba Function1dd709 - xor a - ld [$ffac], a - call Function8474c - ld a, [rIE] - push af - xor a - ld [rIF], a - ld a, $9 - ld [rIE], a - ld hl, hVBlank +Function81d34: ; 81d34 + ld hl, hJoyLast ld a, [hl] - push af - ld [hl], $4 - ld a, $10 - call Function84419 - call Function84742 - ld a, $9 - ld [wcf65], a - call Function843f0 - jr c, .asm_846e2 - call Function84411 - ld c, 12 - call DelayFrames - call LoadTileMapToTempTileMap - xor a - ld [hBGMapMode], a - callba Function1dd7ae - ld a, $3 - call Function84419 - call Call_LoadTempTileMapToTileMap - call Function84742 - ld a, $9 - ld [wcf65], a - call Function843f0 + and D_DOWN + jr nz, Function81d89 + ld a, [hl] + and D_UP + jr nz, Function81d84 + ld hl, wc608 + 10 + jr Function81d63 -.asm_846e2 - pop af - ld [hVBlank], a - call Function84411 - xor a - ld [rIF], a - pop af - ld [rIE], a - call Function84425 - pop af - ld [wcf65], a - ret -; 846f6 +Function81d46: ; 81d46 + ld hl, hJoyLast + ld a, [hl] + and D_DOWN + jr nz, Function81d89 + ld a, [hl] + and D_UP + jr nz, Function81d84 + ld hl, wc608 + 11 + jr Function81d63 -Function846f6: ; 846f6 - ld a, [hJoyDown] - and B_BUTTON - jr nz, .asm_846fe - and a +Function81d58: ; 81d58 + ld hl, hJoyLast + ld a, [hl] + and D_UP + jr nz, Function81d84 + ld hl, wc608 + 12 + +Function81d63: ; 81d63 + ld a, [hJoyLast] + and D_RIGHT + jr nz, Function81d70 + ld a, [hJoyLast] + and D_LEFT + jr nz, Function81d77 ret -.asm_846fe - ld a, [wca80] - cp $c - jr nz, .asm_84722 -.asm_84705 - ld a, [wc2d5] - and a - jr nz, .asm_84705 - ld a, $16 - ld [wc2d5], a - ld a, $88 - ld [rSB], a - ld a, $1 - ld [rSC], a - ld a, $81 - ld [rSC], a -.asm_8471c - ld a, [wc2d5] +Function81d70: ; 81d70 + ld a, [hl] + cp $1f + ret nc + inc [hl] + jr Function81d7b + +Function81d77: ; 81d77 + ld a, [hl] and a - jr nz, .asm_8471c + ret z + dec [hl] -.asm_84722 - ld a, $1 - ld [$ffac], a - scf +Function81d7b: ; 81d7b + call Function81e67 + ld a, $2 + ld [wJumptableIndex], a ret -; 84728 -Function84728: ; 84728 - hlcoord 0, 0 - ld de, wca90 - ld bc, SCREEN_WIDTH * SCREEN_HEIGHT - call CopyBytes +Function81d84: ; 81d84 + ld hl, wcf64 + dec [hl] ret -; 84735 -Function84735: ; 84735 - ld hl, wca90 - decoord 0, 0 - ld bc, SCREEN_WIDTH * SCREEN_HEIGHT - call CopyBytes +Function81d89: ; 81d89 + ld hl, wcf64 + inc [hl] ret -; 84742 +; 81d8e -Function84742: ; 84742 +Function81d8e: ; 81d8e + hlcoord 0, 10 + ld bc, $a0 + ld a, $6f + call ByteFill + hlcoord 2, 12 + ld de, String_81fcd + call PlaceString xor a - ld [hJoyReleased], a - ld [hJoyPressed], a - ld [hJoyDown], a - ld [hJoyLast], a + ld [wd004], a + call Function81df4 + ld a, $5 + ld [wJumptableIndex], a + ret +; 81daf + +Function81daf: ; 81daf + ld hl, hJoyPressed + ld a, [hl] + and B_BUTTON + jr nz, .asm_81dbb + call Function81dc7 ret -; 8474c -Function8474c: ; 8474c - ld de, MUSIC_PRINTER - call PlayMusic2 +.asm_81dbb + ld a, $0 + ld [wJumptableIndex], a ret -; 84753 +; 81dc1 -Function84753: ; 84753 - call RestartMapMusic +Function81dc1: ; 81dc1 + ld hl, wJumptableIndex + set 7, [hl] ret -; 84757 - -Function84757: ; 84757 - ld a, [wca88] - cp -1 - jr nz, .printer_connected - ld a, [wca89] - cp -1 - jr z, .error_2 +; 81dc7 -.printer_connected - ld a, [wca89] - and %11100000 - ret z ; no error +Function81dc7: ; 81dc7 + ld hl, hJoyLast + ld a, [hl] + and D_UP + jr nz, .asm_81dd5 + ld a, [hl] + and D_DOWN + jr nz, .asm_81de2 + ret - bit 7, a - jr nz, .error_1 - bit 6, a - jr nz, .error_4 - ld a, 6 ; error 3 - jr .load_text_index +.asm_81dd5 + ld a, [wd004] + cp $3b + jr z, .asm_81ddf + inc a + jr .asm_81ded -.error_4 - ld a, 7 ; error 4 - jr .load_text_index +.asm_81ddf + xor a + jr .asm_81ded -.error_1 - ld a, 4 ; error 1 - jr .load_text_index +.asm_81de2 + ld a, [wd004] + and a + jr z, .asm_81deb + dec a + jr .asm_81ded -.error_2 - ld a, 5 ; error 2 +.asm_81deb + ld a, $3b -.load_text_index - ld [wcbf8], a +.asm_81ded + ld [wd004], a + call Function81df4 ret -; 84785 +; 81df4 -Function84785: ; 84785 - ld a, [wcbf8] - and a - ret z - push af - xor a - ld [hBGMapMode], a - hlcoord 0, 5 - lb bc, 10, 18 - call TextBox - pop af - ld e, a - ld d, 0 - ld hl, PrinterStatusStringPointers -rept 2 - add hl, de -endr - ld e, [hl] - inc hl - ld d, [hl] - hlcoord 1, 7 - ld a, BANK(GBPrinterStrings) - call FarString - hlcoord 2, 15 - ld de, String_PressBToCancel +Function81df4: ; 81df4 + hlcoord 10, 11 + call Function81e5e + hlcoord 10, 12 + call Function81e5e + hlcoord 10, 13 + call Function81e5e + hlcoord 10, 14 + call Function81e5e + ld a, [wd004] + inc a + ld [wd265], a + predef GetTMHMMove + ld a, [wd265] + ld [wd262], a + call GetMoveName + hlcoord 10, 12 call PlaceString - ld a, $1 - ld [hBGMapMode], a - xor a - ld [wcbf8], a - ret -; 847bd - -Function847bd: ; 847bd - ld a, [wcbf8] + ld a, [wd004] + call Function81e55 + ld [CurItem], a + predef CanLearnTMHMMove + ld a, c and a - ret z - push af - xor a - ld [hBGMapMode], a - hlcoord 2, 4 - lb bc, 13, 16 - call ClearBox - pop af - ld e, a - ld d, 0 - ld hl, PrinterStatusStringPointers -rept 2 - add hl, de -endr - ld e, [hl] - inc hl - ld d, [hl] - hlcoord 4, 7 - ld a, BANK(GBPrinterStrings) - call FarString - hlcoord 4, 15 - ld de, String_PressBToCancel - call PlaceString - ld a, $1 - ld [hBGMapMode], a - xor a - ld [wcbf8], a - ret -; 847f5 - -String_PressBToCancel: - db "Press B to Cancel@" -; 84807 - -PrinterStatusStringPointers: ; 84807 - dw String_1dc275 ; @ - dw String_1dc276 ; CHECKING LINK - dw String_1dc289 ; TRANSMITTING - dw String_1dc29c ; PRINTING - dw String_1dc2ad ; error 1 - dw String_1dc2e2 ; error 2 - dw String_1dc317 ; error 3 - dw String_1dc34c ; error 4 -; 84817 + ld de, String_81e46 + jr nz, .asm_81e3f + ld de, String_81e4d -Function84817: ; 84817 (21:4817) - xor a - ld [wd002], a - hlcoord 0, 0 - ld bc, SCREEN_HEIGHT * SCREEN_WIDTH - ld a, " " - call ByteFill - call Function84a0e - hlcoord 0, 0 - ld bc, 9 * SCREEN_WIDTH - ld a, " " - call ByteFill - call Function849e9 - call Function849d7 - hlcoord 4, 3 - ld de, String_84865 - call PlaceString - ld a, [wd007] - ld bc, BOX_NAME_LENGTH - ld hl, wBoxNames - call AddNTimes - ld d, h - ld e, l - hlcoord 6, 5 +.asm_81e3f + hlcoord 10, 14 call PlaceString - ld a, $1 - call Function849c6 - hlcoord 2, 9 - ld c, $3 - call Function848e7 ret -; 84865 (21:4865) +; 81e46 -String_84865: - db "#MON LIST@" -; 8486f +String_81e46: db "おぼえられる@" ; can be taught +String_81e4d: db "おぼえられない@" ; cannot be taught +; 81e55 -Function8486f: ; 8486f (21:486f) - hlcoord 0, 0 - ld bc, SCREEN_HEIGHT * SCREEN_WIDTH - ld a, " " - call ByteFill - call Function84a0e - call Function849e9 - ld a, [wd003] - and a - ret nz - ld a, $4 - call Function849c6 - hlcoord 2, 0 - ld c, $6 - call Function848e7 - ret +Function81e55: ; 81e55 + cp $32 + jr c, .asm_81e5b +rept 2 + inc a +endr -Function84893: ; 84893 (21:4893) - hlcoord 0, 0 - ld bc, SCREEN_HEIGHT * SCREEN_WIDTH - ld a, " " - call ByteFill - call Function84a0e - call Function849e9 - ld a, [wd003] - and a - ret nz - ld a, $a - call Function849c6 - hlcoord 2, 0 - ld c, $6 - call Function848e7 +.asm_81e5b + add $bf ret +; 81e5e -Function848b7: ; 848b7 (21:48b7) - hlcoord 0, 0 - ld bc, SCREEN_HEIGHT * SCREEN_WIDTH - ld a, " " +Function81e5e: ; 81e5e + ld bc, $a + ld a, $6f call ByteFill - call Function84a0e - hlcoord 1, 15 - lb bc, 2, 18 - call ClearBox - call Function849e9 - call Function849fc - ld a, [wd003] + ret +; 81e67 + +Function81e67: ; 81e67 + ld a, [wc608 + 10] + and $1f + ld e, a + ld a, [wc608 + 11] + and $7 + sla a + swap a + or e + ld e, a + ld a, [wc608 + 11] + and $18 + sla a + swap a + ld d, a + ld a, [wc608 + 12] + and $1f + sla a + sla a + or d + ld d, a + ld a, [wcf65] and a - ret nz - ld a, $10 - call Function849c6 - hlcoord 2, 0 - ld c, $5 - call Function848e7 + jr z, .asm_81e9c + ld a, e + ld [wc608 + 2], a + ld a, d + ld [wc608 + 3], a ret -Function848e7: ; 848e7 (21:48e7) - ld a, [EndFlypoint] - call GetSRAMBank +.asm_81e9c + ld a, e + ld [wc608], a + ld a, d + ld [wc608 + 1], a + ret +; 81ea5 -Function848ed: ; 848ed (21:48ed) - ld a, c - and a - jp z, Function84986 - dec c +Function81ea5: ; 81ea5 ld a, [de] - cp $ff - jp z, Function84981 - ld [wd265], a - ld [CurPartySpecies], a - push bc - push hl - push de - push hl - ld bc, $10 - ld a, " " - call ByteFill - pop hl - push hl - call GetBasePokemonName - pop hl - push hl - call PlaceString - ld a, [CurPartySpecies] - cp $fd - pop hl - jr z, .ok2 - ld bc, $b - add hl, bc - call Function8498a - ld bc, $9 - add hl, bc - ld a, $f3 - ld [hli], a - push hl - ld bc, $e - ld a, " " - call ByteFill - pop hl - push hl - ld a, [wd004] + and $1f + ld [wc608 + 10], a + ld a, [de] + and $e0 + swap a + srl a + ld b, a + inc de + ld a, [de] + and $3 + swap a + srl a + or b + ld [wc608 + 11], a + ld a, [de] + and $7c + srl a + srl a + ld [wc608 + 12], a + ret +; 81eca + +Function81eca: ; 81eca + ld a, [wcf66] + inc a ld l, a - ld a, [StartFlypoint] - ld h, a - ld bc, $372 - add hl, bc - ld bc, $b - ld a, [wd002] - call AddNTimes + ld h, $0 +rept 2 + add hl, hl +endr + ld de, OverworldMap + add hl, de ld e, l ld d, h - pop hl + ld hl, wc608 + ld bc, 4 + call CopyBytes + ret +; 81ee3 + +Function81ee3: ; 81ee3 +.asm_81ee3 + ld a, $ff + ld [hli], a + ld a, $7f + ld [hli], a + ld a, [de] + inc de + ld [hli], a + ld a, [de] + inc de + ld [hli], a + ld a, [de] + inc de + ld [hli], a + ld a, [de] + inc de + ld [hli], a + xor a +rept 2 + ld [hli], a +endr + dec c + jr nz, .asm_81ee3 + ret +; 81efc + +Bank20_FillBoxWithByte: ; 81efc +; For some reason, we have another copy of FillBoxWithByte here +.row + push bc push hl - call PlaceString +.col + ld [hli], a + dec c + jr nz, .col pop hl - ld bc, $b - add hl, bc - push hl - ld a, [wd004] - ld l, a - ld a, [StartFlypoint] - ld h, a - ld bc, $35 + ld bc, SCREEN_WIDTH add hl, bc - ld bc, $20 - ld a, [wd002] - call AddNTimes + pop bc + dec b + jr nz, .row + ret +; 81f0c + +Function81f0c: ; 81f0c + ld a, [wcfbe] + push af + set 7, a + ld [wcfbe], a + call Function81f1d + pop af + ld [wcfbe], a + ret +; 81f1d + +Function81f1d: ; 81f1d ld a, [hl] - pop hl - call Function383d -.ok2 - ld hl, wd002 - inc [hl] - pop de - pop hl - ld bc, $3c - add hl, bc + and $7 + ret z + ld b, a +.asm_81f22 + push bc + xor a + ld [rJOYP], a + ld a, $30 + ld [rJOYP], a + ld b, $10 +.asm_81f2c + ld e, $8 + ld a, [hli] + ld d, a +.asm_81f30 + bit 0, d + ld a, $10 + jr nz, .asm_81f38 + ld a, $20 + +.asm_81f38 + ld [rJOYP], a + ld a, $30 + ld [rJOYP], a + rr d + dec e + jr nz, .asm_81f30 + dec b + jr nz, .asm_81f2c + ld a, $20 + ld [rJOYP], a + ld a, $30 + ld [rJOYP], a + ld de, 7000 +.asm_81f51 + nop + nop + nop + dec de + ld a, d + or e + jr nz, .asm_81f51 pop bc - inc de - jp Function848ed + dec b + jr nz, .asm_81f22 + ret +; 81f5e -Function84981: ; 84981 (21:4981) - ld a, $1 - ld [wd003], a +Function81f5e: ; 81f5e + ld a, $6f + hlcoord 10, 0 + ld [hl], a + hlcoord 15, 0 + ld [hl], a + hlcoord 1, 11 + ld [hl], a + hlcoord 1, 13 + ld [hl], a + hlcoord 1, 15 + ld [hl], a + ld a, [wJumptableIndex] + cp $3 + jr nz, .asm_81fc9 + ld a, [wcf64] + and a + jr z, .asm_81f8d + dec a + hlcoord 1, 11 + ld bc, 2 * SCREEN_WIDTH + call AddNTimes + ld [hl], $ed -Function84986: ; 84986 (21:4986) - call CloseSRAM +.asm_81f8d + ld a, [wcf65] + and a + jr z, .asm_81f98 + hlcoord 15, 0 + jr .asm_81f9b + +.asm_81f98 + hlcoord 10, 0 + +.asm_81f9b + ld [hl], $ed + ld b, $70 + ld c, $5 + ld hl, Sprites + ld de, wc608 + 10 + call .asm_81fb7 + ld de, wc608 + 11 + call .asm_81fb7 + ld de, wc608 + 12 + call .asm_81fb7 ret -Function8498a: ; 8498a (21:498a) - push hl - ld a, [wd004] - ld l, a - ld a, [StartFlypoint] - ld h, a - ld bc, $2b - add hl, bc - ld bc, $20 - ld a, [wd002] - call AddNTimes - ld de, TempMonDVs - ld a, [hli] - ld [de], a - inc de - ld a, [hli] - ld [de], a - ld a, [wd002] - ld [CurPartyMon], a - ld a, $3 - ld [MonType], a - callba GetGender - ld a, $7f - jr c, .asm_849c3 - ld a, $ef - jr nz, .asm_849c3 - ld a, $f5 -.asm_849c3 - pop hl +.asm_81fb7 + ld a, b ld [hli], a + ld a, [de] +rept 2 + add a +endr + add $18 + ld [hli], a + xor a + ld [hli], a + ld a, c + ld [hli], a + ld a, $10 + add b + ld b, a + inc c ret -Function849c6: ; 849c6 (21:49c6) - push hl - ld e, a - ld d, $0 - ld a, [wd004] - ld l, a - ld a, [StartFlypoint] - ld h, a - add hl, de - ld e, l - ld d, h - pop hl +.asm_81fc9 + call ClearSprites ret +; 81fcd -Function849d7: ; 849d7 (21:49d7) +String_81fcd: ; 81fcd + db "おわりますか?" ; Are you finished? + next "はい", $f2, $f2, $f2, $7a ; YES (A) + next "いいえ", $f2, $f2, $7b ; NO (B) + db "@" +; 81fe3 + +DebugColorTestGFX: +INCBIN "gfx/debug/color_test.2bpp" + + +TilesetColorTest: + ret + xor a + ld [wJumptableIndex], a + ld [wcf64], a + ld [wcf65], a + ld [wcf66], a + ld [hMapAnims], a + call ClearSprites + call OverworldTextModeSwitch + call Function3200 + xor a + ld [hBGMapMode], a + ld de, DebugColorTestGFX + $10 + ld hl, VTiles2 tile $6a + lb bc, BANK(DebugColorTestGFX), $16 + call Request2bpp + ld de, DebugColorTestGFX + ld hl, VTiles1 + lb bc, BANK(DebugColorTestGFX), 1 + call Request2bpp + ld a, VBGMap1 / $100 + ld [hBGMapAddress + 1], a hlcoord 0, 0 - ld a, $79 - ld [hli], a - ld a, $7a - ld c, $12 -.asm_849e1 - ld [hli], a - dec c - jr nz, .asm_849e1 - ld a, $7b - ld [hl], a + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT + ld a, $6f + call ByteFill + hlcoord 0, 0, AttrMap + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT + ld a, $7 + call ByteFill + ld de, $15 + ld a, $6c + call Function821d2 + ld de, $1a + ld a, $6d + call Function821d2 + ld de, $1f + ld a, $6e + call Function821d2 + ld de, $24 + ld a, $6f + call Function821d2 + call Function821f4 + call Function8220f + call Function3200 + ld [wJumptableIndex], a + ld a, $40 + ld [hWY], a ret +; 821d2 -Function849e9: ; 849e9 (21:49e9) +Function821d2: ; 821d2 hlcoord 0, 0 - ld de, $13 - ld c, $12 -.asm_849f1 - ld a, $7c - ld [hl], a - add hl, de - ld a, $7c - ld [hli], a - dec c - jr nz, .asm_849f1 - ret + call Function821de -Function849fc: ; 849fc (21:49fc) - hlcoord 0, 17 - ld a, $7d +Function821d8: ; 821d8 + ld a, [wcf64] + hlcoord 0, 0, AttrMap + +Function821de: ; 821de + add hl, de +rept 4 ld [hli], a - ld a, $7a - ld c, $12 -.asm_84a06 +endr + ld bc, $10 + add hl, bc +rept 4 ld [hli], a - dec c - jr nz, .asm_84a06 - ld a, $7e - ld [hl], a - ret - -Function84a0e: ; 84a0e (21:4a0e) - hlcoord 2, 0 - ld c, $6 -.asm_84a13 - push bc - push hl - ld de, String84a25 - call PlaceString - pop hl - ld bc, $3c +endr + ld bc, $10 add hl, bc - pop bc - dec c - jr nz, .asm_84a13 - ret -; 84a25 (21:4a25) - -String84a25: ; 84a25 - db " ------@" -; 84a2e - +rept 4 + ld [hli], a +endr + ret +; 821f4 -INCLUDE "battle/anim_gfx.asm" +Function821f4: ; 821f4 + hlcoord 2, 4 + call Function82203 + hlcoord 2, 6 + call Function82203 + hlcoord 2, 8 +Function82203: ; 82203 + ld a, $6a + ld [hli], a + ld bc, $10 - 1 + ld a, $6b + call ByteFill + ret +; 8220f -HallOfFame:: ; 0x8640e - call Function8648e - ld a, [StatusFlags] +Function8220f: ; 8220f + ld a, [rSVBK] push af - ld a, 1 - ld [wc2cd], a - call DisableSpriteUpdates - ld a, SPAWN_LANCE - ld [wSpawnAfterChampion], a - - ; Enable the Pokégear map to cycle through all of Kanto - ld hl, StatusFlags - set 6, [hl] ; hall of fame + ld a, $5 + ld [rSVBK], a + ld a, [wcf64] + ld l, a + ld h, $0 +rept 3 + add hl, hl +endr + ld de, wMapPals + add hl, de + ld de, wc608 + ld bc, 8 + call CopyBytes + ld de, wc608 + call Function81ea5 + pop af + ld [rSVBK], a + ret +; 82236 - callba Function14da0 - ld hl, wd95e +Function82236: ; 82236 + ld hl, hJoyLast ld a, [hl] - cp 200 - jr nc, .ok - inc [hl] -.ok - callba SaveGameData - call GetHallOfFameParty - callba AddHallOfFameEntry - - xor a - ld [wc2cd], a - call Function864c3 - pop af - ld b, a - callba Function109847 + and SELECT + jr nz, .loop7 + ld a, [hl] + and B_BUTTON + jr nz, .asm_82299 + call Function822f0 ret -; 0x86455 -RedCredits:: ; 86455 - ld a, MUSIC_NONE % $100 - ld [MusicFadeIDLo], a - ld a, MUSIC_NONE / $100 - ld [MusicFadeIDHi], a - ld a, $a - ld [MusicFade], a - callba FadeOutPalettes +.loop7 + ld hl, wcf64 + ld a, [hl] + inc a + and $7 + cp $7 + jr nz, .asm_82253 xor a - ld [VramState], a - ld [hMapAnims], a - callba Function4e8c2 - ld c, 8 + +.asm_82253 + ld [hl], a + ld de, $15 + call Function821d8 + ld de, $1a + call Function821d8 + ld de, $1f + call Function821d8 + ld de, $24 + call Function821d8 + ld a, [rSVBK] + push af + ld a, $5 + ld [rSVBK], a + ld hl, BGPals + ld a, [wcf64] + ld bc, 8 + call AddNTimes + ld de, wc608 + ld bc, 8 + call CopyBytes + pop af + ld [rSVBK], a + ld a, $2 + ld [hBGMapMode], a + ld c, 3 call DelayFrames - call DisableSpriteUpdates - ld a, SPAWN_RED - ld [wSpawnAfterChampion], a - ld a, [StatusFlags] - ld b, a - callba Function109847 + ld a, $1 + ld [hBGMapMode], a ret -; 8648e - -Function8648e: ; 8648e - ld a, MUSIC_NONE % $100 - ld [MusicFadeIDLo], a - ld a, MUSIC_NONE / $100 - ld [MusicFadeIDHi], a - ld a, 10 - ld [MusicFade], a - callba FadeOutPalettes - xor a - ld [VramState], a - ld [hMapAnims], a - callba Function4e881 - ld c, 100 - jp DelayFrames -; 864b4 -Function864b4: ; 864b4 - push de - ld de, MUSIC_NONE - call PlayMusic - call DelayFrame - pop de - call PlayMusic +.asm_82299 + call ClearSprites + ld a, [hWY] + xor $d0 + ld [hWY], a ret -; 864c3 +; 822a3 -Function864c3: ; 864c3 - xor a - ld [wJumptableIndex], a - call Function8671c - jr c, .done - ld de, SCREEN_WIDTH - call Function864b4 - xor a - ld [wcf64], a -.loop +Function822a3: ; 822a3 + ld a, [rSVBK] + push af + ld a, $5 + ld [rSVBK], a + ld hl, BGPals ld a, [wcf64] - cp 6 - jr nc, .done - ld hl, wc608 + 1 - ld bc, $10 + ld bc, 8 call AddNTimes - ld a, [hl] - cp -1 - jr z, .done - push hl - call Function865b5 - pop hl - call Function8650c - jr c, .done - ld hl, wcf64 - inc [hl] - jr .loop - -.done - call Function86810 - ld a, $4 - ld [MusicFade], a - call FadeToWhite - ld c, 8 - call DelayFrames + ld e, l + ld d, h + ld hl, wc608 + ld bc, 8 + call CopyBytes + hlcoord 1, 0 + ld de, wc608 + call Function81ca7 + hlcoord 6, 0 + ld de, wc608 + 2 + call Function81ca7 + hlcoord 11, 0 + ld de, wc608 + 4 + call Function81ca7 + hlcoord 16, 0 + ld de, wc608 + 6 + call Function81ca7 + pop af + ld [rSVBK], a + ld a, $1 + ld [hCGBPalUpdate], a + call DelayFrame ret -; 8650c +; 822f0 -Function8650c: ; 8650c - call Function86748 - ld de, String_8652c - hlcoord 1, 2 - call PlaceString - call WaitBGMap - decoord 6, 5 - ld c, $6 - predef Functiond066e - ld c, 60 - call DelayFrames - and a - ret -; 8652c +Function822f0: ; 822f0 + ld a, [wcf65] + and 3 + ld e, a + ld d, 0 + ld hl, .jumptable +rept 2 + add hl, de +endr + ld a, [hli] + ld h, [hl] + ld l, a + jp [hl] +; 82301 + +.jumptable: ; 82301 + dw Function82309 + dw Function82339 + dw Function8234b + dw Function8235d +; 82309 -String_8652c: - db "New Hall of Famer!@" -; 8653f +Function82309: ; 82309 + ld hl, hJoyLast + ld a, [hl] + and D_DOWN + jr nz, Function8238c + ld a, [hl] + and D_LEFT + jr nz, .asm_8231c + ld a, [hl] + and D_RIGHT + jr nz, .asm_82322 + ret +.asm_8231c + ld a, [wcf66] + dec a + jr .asm_82326 -GetHallOfFameParty: ; 8653f - ld hl, OverworldMap - ld bc, HOF_LENGTH - xor a - call ByteFill - ld a, [wd95e] - ld de, OverworldMap - ld [de], a - inc de - ld hl, PartySpecies - ld c, 0 -.next - ld a, [hli] - cp -1 - jr z, .done - cp EGG - jr nz, .mon - inc c - jr .next +.asm_82322 + ld a, [wcf66] + inc a -.mon - push hl - push de - push bc +.asm_82326 + and $3 + ld [wcf66], a + ld e, a + ld d, $0 + ld hl, wc608 +rept 2 + add hl, de +endr + ld e, l + ld d, h + call Function81ea5 + ret - ld a, c - ld hl, PartyMons - ld bc, PARTYMON_STRUCT_LENGTH - call AddNTimes - ld c, l - ld b, h +Function82339: ; 82338 + ld hl, hJoyLast + ld a, [hl] + and D_DOWN + jr nz, Function8238c + ld a, [hl] + and D_UP + jr nz, Function82387 + ld hl, wc608 + 10 + jr Function82368 - ld hl, MON_SPECIES - add hl, bc +Function8234b: ; 8234b + ld hl, hJoyLast ld a, [hl] - ld [de], a - inc de + and D_DOWN + jr nz, Function8238c + ld a, [hl] + and D_UP + jr nz, Function82387 + ld hl, wc608 + 11 + jr Function82368 - ld hl, MON_ID - add hl, bc - ld a, [hli] - ld [de], a - inc de +Function8235d: ; 8235d + ld hl, hJoyLast ld a, [hl] - ld [de], a - inc de + and D_UP + jr nz, Function82387 + ld hl, wc608 + 12 - ld hl, MON_DVS - add hl, bc - ld a, [hli] - ld [de], a - inc de +Function82368: ; 82368 + ld a, [hJoyLast] + and D_RIGHT + jr nz, .asm_82375 + ld a, [hJoyLast] + and D_LEFT + jr nz, .asm_8237c + ret + +.asm_82375 ld a, [hl] - ld [de], a - inc de + cp $1f + ret nc + inc [hl] + jr .asm_82380 - ld hl, MON_LEVEL - add hl, bc +.asm_8237c ld a, [hl] - ld [de], a - inc de + and a + ret z + dec [hl] - pop bc - push bc - ld a, c - ld hl, PartyMonNicknames - ld bc, PKMN_NAME_LENGTH - call AddNTimes - ld bc, PKMN_NAME_LENGTH - 1 - call CopyBytes +.asm_82380 + call Function82391 + call Function822a3 + ret - pop bc - inc c - pop de - ld hl, HOF_MON_LENGTH - add hl, de - ld e, l - ld d, h - pop hl - jr .next +Function82387: ; 82387 + ld hl, wcf65 + dec [hl] + ret -.done - ld a, $ff - ld [de], a +Function8238c: ; 8238c + ld hl, wcf65 + inc [hl] ret -; 865b5 +; 82391 -Function865b5: ; 865b5 - push hl - call ClearBGPalettes - callba Function4e906 - pop hl - ld a, [hli] - ld [TempMonSpecies], a - ld [CurPartySpecies], a +Function82391: ; 82391 + ld a, [wc608 + 10] + and $1f + ld e, a + ld a, [wc608 + 11] + and $7 + sla a + swap a + or e + ld e, a + ld a, [wc608 + 11] + and $18 + sla a + swap a + ld d, a + ld a, [wc608 + 12] + and $1f + sla a + sla a + or d + ld d, a + ld a, [wcf66] + ld c, a + ld b, $0 + ld hl, wc608 rept 2 - inc hl + add hl, bc endr - ld a, [hli] - ld [TempMonDVs], a - ld a, [hli] - ld [TempMonDVs + 1], a - ld hl, TempMonDVs - predef GetUnownLetter - hlcoord 0, 0 - ld bc, SCREEN_WIDTH * SCREEN_HEIGHT - ld a, " " - call ByteFill - ld de, VTiles2 tile $31 - predef GetBackpic - ld a, $31 - ld [hFillBox], a - hlcoord 6, 6 - lb bc, 6, 6 - predef FillBox - ld a, $d0 - ld [hSCY], a - ld a, $90 - ld [hSCX], a - call WaitBGMap + ld a, e + ld [hli], a + ld [hl], d + ret +; 823c6 + +Function823c6: ; 823c6 + ret + +Function823c7: ; 823c7 + ret +; 823c8 + + +SECTION "bank21", ROMX, BANK[$21] + +Function84000: ; 84000 + ld hl, OverworldMap + lb bc, 4, 12 xor a - ld [hBGMapMode], a - ld b, SCGB_1A - call GetSGBLayout - call SetPalettes - call Function86635 + call Function842ab xor a - ld [wc2c6], a - hlcoord 0, 0 - ld bc, SCREEN_WIDTH * SCREEN_HEIGHT - ld a, " " - call ByteFill - hlcoord 6, 5 - call _PrepMonFrontpic - call WaitBGMap + ld [rSB], a + ld [rSC], a + ld [wc2d5], a + ld hl, wc2d4 + set 0, [hl] + ld a, [GBPrinter] + ld [wcbfb], a xor a - ld [hBGMapMode], a - ld [hSCY], a - call Function86643 + ld [wJumptableIndex], a ret -; 86635 - -Function86635: ; 86635 -.asm_86635 - ld a, [hSCX] - cp $70 - ret z - add $4 - ld [hSCX], a - call DelayFrame - jr .asm_86635 -; 86643 +; 84022 -Function86643: ; 86643 -.asm_86643 - ld a, [hSCX] - and a - ret z +Function84022: ; 84022 + ld a, [wJumptableIndex] + ld e, a + ld d, 0 + ld hl, Jumptable_84031 rept 2 - dec a + add hl, de endr - ld [hSCX], a - call DelayFrame - jr .asm_86643 -; 86650 + ld a, [hli] + ld h, [hl] + ld l, a + jp [hl] +; 84031 -Function86650: ; 86650 - call LoadFontsBattleExtra - xor a - ld [wJumptableIndex], a -.asm_86657 - call Function8671c - ret c - call Function86665 - ret c + +Jumptable_84031: ; 84031 (21:4031) + dw Function84077 + dw Function84143 + dw Function84120 + dw Function84099 + dw Function84180 + dw Function8412e + dw Function840c5 + dw Function84180 + dw Function84120 + dw Function840de + dw Function84180 + dw Function84120 + dw Function841a1 + dw Function84063 + dw Function8406d + dw Function84120 + dw Function84103 + dw Function84071 + dw Function841b0 + dw Function841b3 + + +Function84059: ; 84059 (21:4059) ld hl, wJumptableIndex inc [hl] - jr .asm_86657 -; 86665 + ret -Function86665: ; 86665 +Function8405e: ; 8405e (21:405e) + ld hl, wJumptableIndex + dec [hl] + ret + +Function84063: ; 84063 (21:4063) xor a - ld [wcf64], a -.asm_86669 - call Function86692 - jr c, .asm_86690 -.asm_8666e - call JoyTextDelay - ld hl, hJoyLast - ld a, [hl] - and B_BUTTON - jr nz, .asm_8668e - ld a, [hl] - and A_BUTTON - jr nz, .asm_86688 - ld a, [hl] - and START - jr nz, .asm_86690 - call DelayFrame - jr .asm_8666e + ld [wca89], a + ld hl, wJumptableIndex + set 7, [hl] + ret -.asm_86688 - ld hl, wcf64 - inc [hl] - jr .asm_86669 +Function8406d: ; 8406d (21:406d) + call Function84059 + ret -.asm_8668e - scf +Function84071: ; 84071 (21:4071) + ld a, $1 + ld [wJumptableIndex], a ret -.asm_86690 - and a +Function84077: ; 84077 (21:4077) + call Function841fb + ld hl, Unknown_842b7 + call Function841e2 + xor a + ld [wca8e], a + ld [wca8f], a + ld a, [wcf65] + ld [wca81], a + call Function84059 + call Function841c3 + ld a, $1 + ld [wcbf8], a ret -; 86692 -Function86692: ; 86692 -; Print the number of times the player has entered the Hall of Fame. -; If that number is above 200, print "HOF Master!" instead. - ld a, [wcf64] - cp $6 - jr nc, .asm_866a7 - ld hl, wc608 + 1 - ld bc, $10 - call AddNTimes +Function84099: ; 84099 (21:4099) + call Function841fb + ld hl, wca81 ld a, [hl] - cp $ff - jr nz, .asm_866a9 + and a + jr z, Function840c5 + ld hl, Unknown_842c3 + call Function841e2 + call Function84260 + ld a, $80 + ld [wca8e], a + ld a, $2 + ld [wca8f], a + call Function84219 + call Function84059 + call Function841c3 + ld a, $2 + ld [wcbf8], a + ret -.asm_866a7 - scf +Function840c5: ; 840c5 (21:40c5) + ld a, $6 + ld [wJumptableIndex], a + ld hl, Unknown_842c9 + call Function841e2 + xor a + ld [wca8e], a + ld [wca8f], a + call Function84059 + call Function841c3 ret -.asm_866a9 - push hl - call ClearBGPalettes - pop hl - call Function86748 - ld a, [wc608] - cp 200 + 1 - jr c, .asm_866c6 - ld de, String_866fc - hlcoord 1, 2 - call PlaceString - hlcoord 13, 2 - jr .asm_866de +Function840de: ; 840de (21:40de) + call Function841fb + ld hl, Unknown_842bd + call Function841e2 + call Function84249 + ld a, $4 + ld [wca8e], a + ld a, $0 + ld [wca8f], a + call Function84219 + call Function84059 + call Function841c3 + ld a, $3 + ld [wcbf8], a + ret -.asm_866c6 - ld de, String_8670c - hlcoord 1, 2 - call PlaceString - hlcoord 2, 2 - ld de, wc608 - lb bc, 1, 3 - call PrintNum - hlcoord 11, 2 +Function84103: ; 84103 (21:4103) + call Function841fb + ld hl, Unknown_842b7 + call Function841e2 + xor a + ld [wca8e], a + ld [wca8f], a + ld a, [wcf65] + ld [wca81], a + call Function84059 + call Function841c3 + ret -.asm_866de - ld de, String_866fb - call PlaceString - call WaitBGMap - ld b, SCGB_1A - call GetSGBLayout - call SetPalettes - decoord 6, 5 - ld c, $6 - predef Functiond066e +Function84120: ; 84120 (21:4120) + ld hl, wca8b + inc [hl] + ld a, [hl] + cp $6 + ret c + xor a + ld [hl], a + call Function84059 + ret + +Function8412e: ; 8412e (21:412e) + ld hl, wca8b + inc [hl] + ld a, [hl] + cp $6 + ret c + xor a + ld [hl], a + ld hl, wca81 + dec [hl] + call Function8405e + call Function8405e + ret + +Function84143: ; 84143 (21:4143) + ld a, [wc2d5] and a + ret nz + ld a, [wca88] + cp $ff + jr nz, .printer_connected + ld a, [wca89] + cp $ff + jr z, .printer_error + +.printer_connected + ld a, [wca88] + cp $81 + jr nz, .printer_error + ld a, [wca89] + cp $0 + jr nz, .printer_error + ld hl, wc2d4 + set 1, [hl] + ld a, $5 + ld [wca8a], a + call Function84059 ret -; 866fb - -String_866fb: - db "@" -; 866fc - -String_866fc: - db " HOF Master!@" -; 8670c - -String_8670c: - db " -Time Famer@" -; 8671c +.printer_error + ld a, $ff + ld [wca88], a + ld [wca89], a + ld a, $e + ld [wJumptableIndex], a + ret -Function8671c: ; 8671c - ld a, [wJumptableIndex] - cp NUM_HOF_TEAMS - jr nc, .asm_86746 - ld hl, sHallOfFame - ld bc, HOF_LENGTH - call AddNTimes - ld a, BANK(sHallOfFame) - call GetSRAMBank - ld a, [hl] - and a - jr z, .asm_86743 - ld de, wc608 - ld bc, HOF_LENGTH - call CopyBytes - call CloseSRAM +Function84180: ; 84180 (21:4180) + ld a, [wc2d5] and a + ret nz + ld a, [wca89] + and $f0 + jr nz, .asm_8419b + ld a, [wca89] + and $1 + jr nz, .asm_84197 + call Function84059 ret - -.asm_86743 - call CloseSRAM - -.asm_86746 - scf +.asm_84197 + call Function8405e + ret +.asm_8419b + ld a, $12 + ld [wJumptableIndex], a ret -; 86748 -Function86748: ; 86748 - xor a - ld [hBGMapMode], a - ld a, [hli] - ld [TempMonSpecies], a - ld a, [hli] - ld [TempMonID], a - ld a, [hli] - ld [TempMonID + 1], a - ld a, [hli] - ld [TempMonDVs], a - ld a, [hli] - ld [TempMonDVs + 1], a - ld a, [hli] - ld [TempMonLevel], a - ld de, StringBuffer2 - ld bc, 10 - call CopyBytes - ld a, "@" - ld [StringBuffer2 + 10], a - hlcoord 0, 0 - ld bc, SCREEN_WIDTH * SCREEN_HEIGHT - ld a, " " - call ByteFill - hlcoord 0, 0 - lb bc, 3, SCREEN_WIDTH - 2 - call TextBox - hlcoord 0, 12 - lb bc, 4, SCREEN_WIDTH - 2 - call TextBox - ld a, [TempMonSpecies] - ld [CurPartySpecies], a - ld [wd265], a - ld hl, TempMonDVs - predef GetUnownLetter - xor a - ld [wc2c6], a - hlcoord 6, 5 - call _PrepMonFrontpic - ld a, [CurPartySpecies] - cp EGG - jr z, .asm_867f8 - hlcoord 1, 13 - ld a, $74 - ld [hli], a - ld [hl], $f2 - hlcoord 3, 13 - ld de, wd265 - lb bc, PRINTNUM_LEADINGZEROS | 1, 3 - call PrintNum - call GetBasePokemonName - hlcoord 7, 13 - call PlaceString - ld a, $3 - ld [MonType], a - callba GetGender - ld a, $7f - jr c, .asm_867e2 - ld a, $ef - jr nz, .asm_867e2 - ld a, $f5 +Function841a1: ; 841a1 (21:41a1) + ld a, [wc2d5] + and a + ret nz + ld a, [wca89] + and $f3 + ret nz + call Function84059 + ret -.asm_867e2 - hlcoord 18, 13 - ld [hli], a - hlcoord 8, 14 - ld a, $f3 - ld [hli], a - ld de, StringBuffer2 - call PlaceString - hlcoord 1, 16 - call PrintLevel +Function841b0: ; 841b0 (21:41b0) + call Function84059 -.asm_867f8 - hlcoord 7, 16 - ld a, $73 - ld [hli], a - ld a, $74 - ld [hli], a - ld [hl], $f3 - hlcoord 10, 16 - ld de, TempMonID - lb bc, PRINTNUM_LEADINGZEROS | 2, 5 - call PrintNum +Function841b3: ; 841b3 (21:41b3) + ld a, [wc2d5] + and a + ret nz + ld a, [wca89] + and $f0 + ret nz + xor a + ld [wJumptableIndex], a ret -; 86810 -Function86810: ; 86810 - call ClearBGPalettes - ld hl, VTiles2 tile $63 - ld de, FontExtra + $d0 - lb bc, BANK(FontExtra), 1 - call Request2bpp - hlcoord 0, 0 - ld bc, SCREEN_WIDTH * SCREEN_HEIGHT - ld a, " " - call ByteFill - callba GetPlayerBackpic - ld a, $31 - ld [hFillBox], a - hlcoord 6, 6 - lb bc, 6, 6 - predef FillBox - ld a, $d0 - ld [hSCY], a - ld a, $90 - ld [hSCX], a - call WaitBGMap - xor a - ld [hBGMapMode], a - ld [CurPartySpecies], a - ld b, SCGB_1A - call GetSGBLayout - call SetPalettes - call Function86635 - xor a - ld [wc2c6], a - hlcoord 0, 0 - ld bc, SCREEN_WIDTH * SCREEN_HEIGHT - ld a, " " - call ByteFill - callba Function88840 - xor a - ld [hFillBox], a - hlcoord 12, 5 - lb bc, 7, 7 - predef FillBox - ld a, $c0 - ld [hSCX], a - call WaitBGMap - xor a - ld [hBGMapMode], a - ld [hSCY], a - call Function86643 +Function841c3: ; 841c3 (21:41c3) + ld a, [wc2d5] + and a + jr nz, Function841c3 xor a - ld [hBGMapMode], a - hlcoord 0, 2 - lb bc, 8, 9 - call TextBox - hlcoord 0, 12 - lb bc, 4, 18 - call TextBox - hlcoord 2, 4 - ld de, PlayerName - call PlaceString - hlcoord 1, 6 - ld a, $73 - ld [hli], a - ld a, $74 - ld [hli], a - ld [hl], $f3 - hlcoord 4, 6 - ld de, PlayerID - lb bc, PRINTNUM_LEADINGZEROS | 2, 5 - call PrintNum - hlcoord 1, 8 - ld de, .PlayTime - call PlaceString - hlcoord 3, 9 - ld de, GameTimeHours - lb bc, 2, 3 - call PrintNum - ld [hl], $63 - inc hl - ld de, GameTimeMinutes - lb bc, PRINTNUM_LEADINGZEROS | 1, 2 - call PrintNum - call WaitBGMap - callba Function26601 + ld [wca8c], a + ld [wca8d], a + ld a, $1 + ld [wc2d5], a + ld a, $88 + ld [rSB], a + ld a, $1 + ld [rSC], a + ld a, $81 + ld [rSC], a ret -; 868ed - -.PlayTime - db "PLAY TIME@" -; 868f7 - -SECTION "bank22", ROMX, BANK[$22] +Function841e2: ; 841e2 (21:41e2) + ld a, [hli] + ld [wca82], a + ld a, [hli] + ld [wca83], a + ld a, [hli] + ld [wca84], a + ld a, [hli] + ld [wca85], a + ld a, [hli] + ld [wca86], a + ld a, [hl] + ld [wca87], a + ret -INCLUDE "event/kurt.asm" +Function841fb: ; 841fb (21:41fb) + xor a + ld hl, wca82 +rept 3 + ld [hli], a +endr + ld [hl], a + ld hl, wca86 + ld [hli], a + ld [hl], a + xor a + ld [wca8e], a + ld [wca8f], a + ld hl, OverworldMap + ld bc, $280 + call Function842ab + ret -Function88248: ; 88248 - ld c, CAL - ld a, [PlayerGender] - bit 0, a - jr z, .okay - ld c, KAREN +Function84219: ; 84219 (21:4219) + ld hl, 0 + ld bc, $4 + ld de, wca82 + call Function8423c + ld a, [wca8e] + ld c, a + ld a, [wca8f] + ld b, a + ld de, OverworldMap + call Function8423c + ld a, l + ld [wca86], a + ld a, h + ld [wca87], a + ret -.okay +Function8423c: ; 8423c (21:423c) + ld a, [de] + inc de + add l + jr nc, .asm_84242 + inc h +.asm_84242 + ld l, a + dec bc ld a, c - ld [TrainerClass], a + or b + jr nz, Function8423c ret -; 88258 - -MovePlayerPicRight: ; 88258 - hlcoord 6, 4 - ld de, 1 - jr MovePlayerPic -MovePlayerPicLeft: ; 88260 - hlcoord 13, 4 - ld de, -1 - ; fallthrough +Function84249: ; 84249 (21:4249) + ld a, $1 + ld [OverworldMap], a + ld a, [wcbfa] + ld [wc801], a + ld a, $e4 + ld [wc802], a + ld a, [wcbfb] + ld [wc803], a + ret -MovePlayerPic: ; 88266 -; Move player pic at hl by de * 7 tiles. - ld c, $8 -.loop +Function84260: ; 84260 (21:4260) + ld a, [wca81] + xor $ff + ld d, a + ld a, [wcf65] + inc a + add d + ld hl, wca90 + ld de, $28 +.asm_84271 + and a + jr z, .asm_84278 + add hl, de + dec a + jr .asm_84271 +.asm_84278 + ld e, l + ld d, h + ld hl, OverworldMap + ld c, $28 +.asm_8427f + ld a, [de] + inc de push bc - push hl push de - xor a - ld [hBGMapMode], a - lb bc, 7, 7 - predef FillBox - xor a - ld [hBGMapThird], a - call WaitBGMap - call DelayFrame - pop de + push hl + swap a + ld d, a + and $f0 + ld e, a + ld a, d + and $f + ld d, a + and $8 + ld a, d + jr nz, .asm_84297 + or $90 + jr .asm_84299 +.asm_84297 + or $80 +.asm_84299 + ld d, a + lb bc, $21, 1 + call Request2bpp pop hl + ld de, $10 add hl, de + pop de pop bc dec c - ret z - push hl - push bc - ld a, l - sub e - ld l, a - ld a, h - sbc d - ld h, a - lb bc, 7, 7 - call ClearBox - pop bc - pop hl - jr .loop -; 88297 + jr nz, .asm_8427f + ret -ShowPlayerNamingChoices: ; 88297 - ld hl, ChrisNameMenuHeader - ld a, [PlayerGender] - bit 0, a - jr z, .GotGender - ld hl, KrisNameMenuHeader -.GotGender - call LoadMenuDataHeader - call InterpretMenu2 - ld a, [MenuSelection2] - dec a - call CopyNameFromMenu - call WriteBackup +Function842ab: ; 842ab + push de + ld e, a +.asm_842ad + ld [hl], e + inc hl + dec bc + ld a, c + or b + jr nz, .asm_842ad + ld a, e + pop de ret -; 882b5 +; 842b7 -ChrisNameMenuHeader: ; 882b5 - db $40 ; flags - db 00, 00 ; start coords - db 11, 10 ; end coords - dw MenuData2_0x882be - db 1 ; ???? - db 0 ; default option -; 882be +Unknown_842b7: db 1, 0, $00, 0, 1, 0 +Unknown_842bd: db 2, 0, $04, 0, 0, 0 +Unknown_842c3: db 4, 0, $80, 2, 0, 0 +Unknown_842c9: db 4, 0, $00, 0, 4, 0 +Unknown_842cf: db 8, 0, $00, 0, 8, 0 ; unused +Unknown_842d5: db 15, 0, $00, 0, 15, 0 ; unused +; 842db -MenuData2_0x882be: ; 882be - db $91 ; flags - db 5 ; items - db "NEW NAME@" -Unknown_882c9: ; 882c9 - db "CHRIS@" - db "MAT@" - db "ALLAN@" - db "JON@" - db 2 ; displacement - db " NAME @" ; title -; 882e5 -KrisNameMenuHeader: ; 882e5 - db $40 ; flags - db 00, 00 ; start coords - db 11, 10 ; end coords - dw MenuData2_0x882ee - db 1 ; ???? - db 0 ; default option -; 882ee +Function842db:: ; 842db + ld a, [wc2d5] + add a + ld e, a + ld d, 0 + ld hl, Jumptable_842ea + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + jp [hl] +; 842ea -MenuData2_0x882ee: ; 882ee - db $91 ; flags - db 5 ; items - db "NEW NAME@" -Unknown_882f9: ; 882f9 - db "KRIS@" - db "AMANDA@" - db "JUANA@" - db "JODI@" - db 2 ; displacement - db " NAME @" ; title -; 88318 -GetPlayerNameArray: ; 88318 This Function is never called - ld hl, PlayerName - ld de, Unknown_882c9 - ld a, [PlayerGender] - bit 0, a - jr z, .done - ld de, Unknown_882f9 +Jumptable_842ea: ; 842ea (21:42ea) + dw Function8432f + dw Function84330 + dw Function84339 + dw Function84343 + dw Function8434d + dw Function84357 + dw Function84361 + dw Function8438b + dw Function84395 + dw Function8439f + dw Function843a8 + dw Function843b6 + dw Function84330 + dw Function843c0 + dw Function843c9 + dw Function843c9 + dw Function843c9 + dw Function843c0 + dw Function843c9 + dw Function8439f + dw Function843a8 + dw Function843e6 + dw Function84330 + dw Function843d2 + dw Function843c9 + dw Function843c9 + dw Function843c9 + dw Function843d2 + dw Function843c9 + dw Function8439f + dw Function843a8 + dw Function843b6 + -.done - call InitName +Function8432a: ; 8432a (21:432a) + ld hl, wc2d5 + inc [hl] ret -; 8832c -GetPlayerIcon: ; 8832c -; Get the player icon corresponding to gender - -; Male - ld de, ChrisSpriteGFX - ld b, BANK(ChrisSpriteGFX) +Function8432f: ; 8432f (21:432f) + ret - ld a, [PlayerGender] - bit 0, a - jr z, .done +Function84330: ; 84330 (21:4330) + ld a, $33 + call Function843db + call Function8432a + ret -; Female - ld de, KrisSpriteGFX - ld b, BANK(KrisSpriteGFX) +Function84339: ; 84339 (21:4339) + ld a, [wca82] + call Function843db + call Function8432a + ret -.done +Function84343: ; 84343 (21:4343) + ld a, [wca83] + call Function843db + call Function8432a ret -; 8833e -Function8833e: ; 8833e - ld hl, ChrisCardPic - ld a, [PlayerGender] - bit 0, a - jr z, .GotClass - ld hl, KrisCardPic -.GotClass - ld de, VTiles2 tile $00 - ld bc, $230 - ld a, BANK(ChrisCardPic) ; BANK(KrisCardPic) - call FarCopyBytes - ld hl, CardGFX - ld de, VTiles2 tile $23 - ld bc, $60 - ld a, BANK(CardGFX) - call FarCopyBytes +Function8434d: ; 8434d (21:434d) + ld a, [wca84] + call Function843db + call Function8432a ret -; 88365 (22:4365) -ChrisCardPic: ; 88365 -INCBIN "gfx/misc/chris_card.5x7.2bpp" -; 88595 +Function84357: ; 84357 (21:4357) + ld a, [wca85] + call Function843db + call Function8432a + ret -KrisCardPic: ; 88595 -INCBIN "gfx/misc/kris_card.5x7.2bpp" -; 887c5 +Function84361: ; 84361 (21:4361) + ld hl, wca8e + ld a, [hli] + ld d, [hl] + ld e, a + or d + jr z, .asm_84388 + dec de + ld [hl], d + dec hl + ld [hl], e + ld a, [wca8c] + ld e, a + ld a, [wca8d] + ld d, a + ld hl, OverworldMap + add hl, de + inc de + ld a, e + ld [wca8c], a + ld a, d + ld [wca8d], a + ld a, [hl] + call Function843db + ret +.asm_84388 + call Function8432a -CardGFX: ; 887c5 -INCBIN "gfx/misc/trainer_card.2bpp" -; 88825 +Function8438b: ; 8438b (21:438b) + ld a, [wca86] + call Function843db + call Function8432a + ret +Function84395: ; 84395 (21:4395) + ld a, [wca87] + call Function843db + call Function8432a + ret -GetPlayerBackpic: ; 88825 - ld a, [PlayerGender] - bit 0, a - jr z, GetChrisBackpic - call GetKrisBackpic +Function8439f: ; 8439f (21:439f) + ld a, $0 + call Function843db + call Function8432a ret -GetChrisBackpic: ; 88830 - ld hl, ChrisBackpic - ld b, BANK(ChrisBackpic) - ld de, VTiles2 tile $31 - ld c, 7 * 7 - predef DecompressPredef +Function843a8: ; 843a8 (21:43a8) + ld a, [rSB] + ld [wca88], a + ld a, $0 + call Function843db + call Function8432a ret -; 88840 -Function88840: ; 88840 - call WaitBGMap +Function843b6: ; 843b6 (21:43b6) + ld a, [rSB] + ld [wca89], a xor a - ld [hBGMapMode], a - ld e, 0 - ld a, [PlayerGender] - bit 0, a - jr z, .GotClass - ld e, 1 - -.GotClass - ld a, e - ld [TrainerClass], a - ld de, ChrisPic - ld a, [PlayerGender] - bit 0, a - jr z, .GotPic - ld de, KrisPic + ld [wc2d5], a + ret -.GotPic - ld hl, VTiles2 - ld b, BANK(ChrisPic) ; BANK(KrisPic) - ld c, 7 * 7 - call Get2bpp - call WaitBGMap - ld a, $1 - ld [hBGMapMode], a +Function843c0: ; 843c0 (21:43c0) + ld a, $f + call Function843db + call Function8432a ret -; 88874 +Function843c9: ; 843c9 (21:43c9) + ld a, $0 + call Function843db + call Function8432a + ret +Function843d2: ; 843d2 (21:43d2) + ld a, $8 + call Function843db + call Function8432a + ret -DrawIntroPlayerPic: ; 88874 -; Draw the player pic at (6,4). +Function843db: ; 843db (21:43db) + ld [rSB], a + ld a, $1 + ld [rSC], a + ld a, $81 + ld [rSC], a + ret -; Get class - ld e, 0 - ld a, [PlayerGender] - bit 0, a - jr z, .GotClass - ld e, 1 -.GotClass - ld a, e - ld [TrainerClass], a +Function843e6: ; 843e6 (21:43e6) + ld a, [rSB] + ld [wca89], a + xor a + ld [wc2d5], a + ret -; Load pic - ld de, ChrisPic - ld a, [PlayerGender] - bit 0, a - jr z, .GotPic - ld de, KrisPic -.GotPic - ld hl, VTiles2 - ld b, BANK(ChrisPic) ; BANK(KrisPic) - ld c, 7 * 7 ; dimensions - call Get2bpp +Function843f0: ; 843f0 +.asm_843f0 + call JoyTextDelay + call Function846f6 + jr c, .asm_8440f + ld a, [wJumptableIndex] + bit 7, a + jr nz, .asm_8440d + call Function84022 + call Function84757 + call Function84785 + call DelayFrame + jr .asm_843f0 -; Draw - xor a - ld [hFillBox], a - hlcoord 6, 4 - lb bc, 7, 7 - predef FillBox +.asm_8440d + and a ret -; 888a9 +.asm_8440f + scf + ret +; 84411 -ChrisPic: ; 888a9 -INCBIN "gfx/misc/chris.7x7.2bpp" -; 88bb9 - -KrisPic: ; 88bb9 -INCBIN "gfx/misc/kris.7x7.2bpp" -; 88ec9 +Function84411: ; 84411 + xor a + ld [wc2d4], a + ld [wc2d5], a + ret +; 84419 +Function84419: ; 84419 + push af + call Function84000 + pop af + ld [wcbfa], a + call Function84728 + ret +; 84425 -GetKrisBackpic: ; 88ec9 -; Kris's backpic is uncompressed. - ld de, KrisBackpic - ld hl, VTiles2 tile $31 - lb bc, BANK(KrisBackpic), 7 * 7 ; dimensions - call Get2bpp +Function84425: ; 84425 + call ReturnToMapFromSubmenu + call Function84753 ret -; 88ed6 +; 8442c -KrisBackpic: ; 88ed6 -INCBIN "gfx/misc/kris_back.6x6.2bpp" -; 89116 +Function8442c: ; 8442c + ld a, [wcf65] + push af + ld hl, VTiles1 + ld de, FontInversed + lb bc, BANK(FontInversed), $80 + call Request1bpp + xor a + ld [$ffac], a + call Function8474c + ld a, [rIE] + push af + xor a + ld [rIF], a + ld a, $9 + ld [rIE], a + call Function84000 + ld a, $10 + ld [wcbfa], a + callba Function1dc1b0 + call ClearTileMap + ld a, $e4 + call DmgToCgbBGPals + call DelayFrame + ld hl, hVBlank + ld a, [hl] + push af + ld [hl], $4 + ld a, $8 + ld [wcf65], a + call Function84742 + call Function843f0 + jr c, .asm_8449d + call Function84411 + ld c, 12 + call DelayFrames + xor a + ld [hBGMapMode], a + call Function84000 + ld a, $3 + ld [wcbfa], a + callba Function1dc213 + call Function84742 + ld a, $4 + ld [wcf65], a + call Function843f0 +.asm_8449d + pop af + ld [hVBlank], a + call Function84411 + xor a + ld [rIF], a + pop af + ld [rIE], a + call Function84425 + ld c, $8 +.asm_844ae + call LowVolume + call DelayFrame + dec c + jr nz, .asm_844ae + pop af + ld [wcf65], a + ret +; 844bc -String_89116: - db "-----@" -; 8911c +Function844bc: ; 844bc (21:44bc) + ld a, [wcf65] + push af + ld a, $9 + ld [wcf65], a + ld a, e + ld [wd004], a + ld a, d + ld [StartFlypoint], a + ld a, b + ld [EndFlypoint], a + ld a, c + ld [MovementBuffer], a + xor a + ld [$ffac], a + ld [wd003], a + call Function8474c + ld a, [rIE] + push af + xor a + ld [rIF], a + ld a, $9 + ld [rIE], a + ld hl, hVBlank + ld a, [hl] + push af + ld [hl], $4 + xor a + ld [hBGMapMode], a + call Function84817 + ld a, $10 + call Function84419 + call Function84559 + jr c, .asm_84545 + call Function84411 + ld c, 12 + call DelayFrames + xor a + ld [hBGMapMode], a + call Function8486f + ld a, $0 + call Function84419 + call Function84559 + jr c, .asm_84545 + call Function84411 + ld c, 12 + call DelayFrames + xor a + ld [hBGMapMode], a + call Function84893 + ld a, $0 + call Function84419 + call Function84559 + jr c, .asm_84545 + call Function84411 + ld c, 12 + call DelayFrames + xor a + ld [hBGMapMode], a + call Function848b7 + ld a, $3 + call Function84419 + call Function84559 +.asm_84545 + pop af + ld [hVBlank], a + call Function84411 + xor a + ld [rIF], a + pop af + ld [rIE], a + call Function84425 + pop af + ld [wcf65], a + ret -INCLUDE "misc/mobile_22.asm" -INCLUDE "event/unown.asm" -INCLUDE "event/buena.asm" -INCLUDE "event/dratini.asm" -INCLUDE "event/battle_tower.asm" -INCLUDE "misc/mobile_22_2.asm" +Function84559: ; 84559 (21:4559) + call Function84742 + call Function843f0 + ret +Function84560: ; 84560 + ld a, [wcf65] + push af + xor a + ld [$ffac], a + call Function8474c + ld a, [rIE] + push af + xor a + ld [rIF], a + ld a, $9 + ld [rIE], a + ld hl, hVBlank + ld a, [hl] + push af + ld [hl], $4 + xor a + ld [hBGMapMode], a + call LoadTileMapToTempTileMap + callba Function16dac + ld a, $0 + call Function84419 + call Call_LoadTempTileMapToTileMap + call Function84742 + ld a, $9 + ld [wcf65], a +.asm_84597 + call JoyTextDelay + call Function846f6 + jr c, .asm_845c0 + ld a, [wJumptableIndex] + bit 7, a + jr nz, .asm_845c0 + call Function84022 + ld a, [wJumptableIndex] + cp $2 + jr nc, .asm_845b5 + ld a, $3 + ld [wca81], a -SECTION "bank23", ROMX, BANK[$23] +.asm_845b5 + call Function84757 + call Function84785 + call DelayFrame + jr .asm_84597 -Predef35: ; 8c000 -Predef36: +.asm_845c0 + pop af + ld [hVBlank], a + call Function84411 + call Call_LoadTempTileMapToTileMap + xor a + ld [rIF], a + pop af + ld [rIE], a + pop af + ld [wcf65], a ret -; 8c001 +; 845d4 +Function845d4: ; 845d4 + call Function845db + call Function84425 + ret +; 845db -INCLUDE "engine/timeofdaypals.asm" -INCLUDE "engine/battle_start.asm" +Function845db: ; 845db + ld a, [wcf65] + push af + xor a + ld [$ffac], a + call Function8474c + ld a, [rIE] + push af + xor a + ld [rIF], a + ld a, $9 + ld [rIE], a + xor a + ld [hBGMapMode], a + ld a, $13 + call Function84419 + ld hl, hVBlank + ld a, [hl] + push af + ld [hl], $4 + ld a, $9 + ld [wcf65], a + call Function843f0 + pop af + ld [hVBlank], a + call Function84411 + call Function84735 + xor a + ld [rIF], a + pop af + ld [rIE], a + pop af + ld [wcf65], a + ret +; 8461a -Function8c7c9: ; unreferenced - ld a, $1 +Function8461a: ; 8461a + ld a, [wcf65] + push af + xor a + ld [$ffac], a + call Function8474c + ld a, [rIE] + push af + xor a + ld [rIF], a + ld a, $9 + ld [rIE], a + xor a ld [hBGMapMode], a - call WaitBGMap + callba Function1dc381 + ld a, $10 + call Function84419 + ld hl, hVBlank + ld a, [hl] + push af + ld [hl], $4 + ld a, $8 + ld [wcf65], a + call Function84742 + call Function843f0 + jr c, .asm_84671 + call Function84411 + ld c, 12 + call DelayFrames xor a ld [hBGMapMode], a + callba Function1dc47b + ld a, $3 + call Function84419 + ld a, $9 + ld [wcf65], a + call Function84742 + call Function843f0 + +.asm_84671 + pop af + ld [hVBlank], a + call Function84411 + call Function84735 + xor a + ld [rIF], a + pop af + ld [rIE], a + call Function84425 + pop af + ld [wcf65], a ret -; 8c7d4 +; 84688 -PlayWhirlpoolSound: ; 8c7d4 - call WaitSFX - ld de, SFX_SURF - call PlaySFX - call WaitSFX +Function84688: ; 84688 + ld a, [wcf65] + push af + callba Function1dd709 + xor a + ld [$ffac], a + call Function8474c + ld a, [rIE] + push af + xor a + ld [rIF], a + ld a, $9 + ld [rIE], a + ld hl, hVBlank + ld a, [hl] + push af + ld [hl], $4 + ld a, $10 + call Function84419 + call Function84742 + ld a, $9 + ld [wcf65], a + call Function843f0 + jr c, .asm_846e2 + call Function84411 + ld c, 12 + call DelayFrames + call LoadTileMapToTempTileMap + xor a + ld [hBGMapMode], a + callba Function1dd7ae + ld a, $3 + call Function84419 + call Call_LoadTempTileMapToTileMap + call Function84742 + ld a, $9 + ld [wcf65], a + call Function843f0 + +.asm_846e2 + pop af + ld [hVBlank], a + call Function84411 + xor a + ld [rIF], a + pop af + ld [rIE], a + call Function84425 + pop af + ld [wcf65], a ret -; 8c7e1 +; 846f6 -BlindingFlash: ; 8c7e1 - callba FadeOutPalettes - ld hl, StatusFlags - set 2, [hl] - callba Function8c0e5 - callba Function8c001 - ld b, SCGB_09 - call GetSGBLayout - callba Function49409 - callba FadeInPalettes +Function846f6: ; 846f6 + ld a, [hJoyDown] + and B_BUTTON + jr nz, .asm_846fe + and a ret -; 8c80a -ShakeHeadbuttTree: ; 8c80a - callba Function8cf53 - ld de, CutGrassGFX - ld hl, VTiles1 - lb bc, BANK(CutGrassGFX), 4 - call Request2bpp - ld de, HeadbuttTreeGFX - ld hl, VTiles1 tile $04 - lb bc, BANK(HeadbuttTreeGFX), 8 - call Request2bpp - call Function8cad3 - ld a, SPRITE_ANIM_INDEX_1B - call _InitSpriteAnimStruct - ld hl, $3 - add hl, bc - ld [hl], $84 - ld a, $90 - ld [wc3b5], a - callba Function8cf7a - call GetHeadbuttTreeRelativeLocation - ld a, $20 - ld [wcf64], a - call WaitSFX - ld de, SFX_SANDSTORM - call PlaySFX -.loop - ld hl, wcf64 - ld a, [hl] +.asm_846fe + ld a, [wca80] + cp $c + jr nz, .asm_84722 +.asm_84705 + ld a, [wc2d5] and a - jr z, .done - dec [hl] - ld a, $90 - ld [wc3b5], a - callba Function8cf7a - call DelayFrame - jr .loop + jr nz, .asm_84705 + ld a, $16 + ld [wc2d5], a + ld a, $88 + ld [rSB], a + ld a, $1 + ld [rSC], a + ld a, $81 + ld [rSC], a +.asm_8471c + ld a, [wc2d5] + and a + jr nz, .asm_8471c -.done - call OverworldTextModeSwitch - call WaitBGMap - xor a - ld [hBGMapMode], a - callba Function8cf53 - ld hl, Sprites + $90 - ld bc, $10 - xor a - call ByteFill - ld de, Font - ld hl, VTiles1 - lb bc, BANK(Font), $c - call Get1bpp - call ReplaceKrisSprite +.asm_84722 + ld a, $1 + ld [$ffac], a + scf ret -; 8c893 +; 84728 -HeadbuttTreeGFX: ; 8c893 -INCBIN "gfx/unknown/08c893.2bpp" -; 8c913 +Function84728: ; 84728 + hlcoord 0, 0 + ld de, wca90 + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT + call CopyBytes + ret +; 84735 -GetHeadbuttTreeRelativeLocation: ; 8c913 - xor a - ld [hBGMapMode], a - ld a, [PlayerDirection] - and %00001100 - srl a - ld e, a - ld d, 0 - ld hl, TreeRelativeLocationTable - add hl, de - ld a, [hli] - ld h, [hl] - ld l, a +Function84735: ; 84735 + ld hl, wca90 + decoord 0, 0 + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT + call CopyBytes + ret +; 84742 - ld a, $5 - ld [hli], a - ld [hld], a - ld bc, SCREEN_WIDTH - add hl, bc - ld [hli], a - ld [hld], a - call WaitBGMap +Function84742: ; 84742 xor a - ld [hBGMapMode], a + ld [hJoyReleased], a + ld [hJoyPressed], a + ld [hJoyDown], a + ld [hJoyLast], a + ret +; 8474c + +Function8474c: ; 8474c + ld de, MUSIC_PRINTER + call PlayMusic2 ret -; 8c938 +; 84753 -TreeRelativeLocationTable: ; 8c938 - dwcoord 8, 8 + 2 ; RIGHT - dwcoord 8, 8 - 2 ; LEFT - dwcoord 8 - 2, 8 ; DOWN - dwcoord 8 + 2, 8 ; UP -; 8c940 +Function84753: ; 84753 + call RestartMapMusic + ret +; 84757 + +Function84757: ; 84757 + ld a, [wca88] + cp -1 + jr nz, .printer_connected + ld a, [wca89] + cp -1 + jr z, .error_2 + +.printer_connected + ld a, [wca89] + and %11100000 + ret z ; no error -OWCutAnimation: ; 8c940 - ld a, e - and $1 - ld [wJumptableIndex], a - call .LoadCutGFX - call WaitSFX - ld de, SFX_PLACE_PUZZLE_PIECE_DOWN - call PlaySFX -.loop - ld a, [wJumptableIndex] bit 7, a - jr nz, .finish - ld a, $90 - ld [wc3b5], a - callab Function8cf7a - call OWCutJumptable - call DelayFrame - jr .loop + jr nz, .error_1 + bit 6, a + jr nz, .error_4 + ld a, 6 ; error 3 + jr .load_text_index -.finish - ret -; 8c96d +.error_4 + ld a, 7 ; error 4 + jr .load_text_index -.LoadCutGFX: ; 8c96d - callab Function8cf53 ; pointless to farcall - ld de, CutGrassGFX - ld hl, VTiles1 - lb bc, BANK(CutGrassGFX), 4 - call Request2bpp - ld de, CutTreeGFX - ld hl, VTiles1 tile $4 - lb bc, BANK(CutTreeGFX), 4 - call Request2bpp - ret -; 8c98c +.error_1 + ld a, 4 ; error 1 + jr .load_text_index -CutTreeGFX: ; c898c -INCBIN "gfx/misc/cut_tree.2bpp" -; c89cc +.error_2 + ld a, 5 ; error 2 -CutGrassGFX: ; 8c9cc -INCBIN "gfx/misc/cut_grass.2bpp" -; 8ca0c +.load_text_index + ld [wcbf8], a + ret +; 84785 -OWCutJumptable: ; 8ca0c - ld a, [wJumptableIndex] +Function84785: ; 84785 + ld a, [wcbf8] + and a + ret z + push af + xor a + ld [hBGMapMode], a + hlcoord 0, 5 + lb bc, 10, 18 + call TextBox + pop af ld e, a ld d, 0 - ld hl, .jumptable + ld hl, PrinterStatusStringPointers rept 2 add hl, de endr - ld a, [hli] - ld h, [hl] - ld l, a - jp [hl] -; 8ca1b - - -.jumptable: ; 8ca1b (23:4a1b) - dw Function8ca23 - dw Function8ca3c - dw Function8ca5c - dw Function8ca64 - + ld e, [hl] + inc hl + ld d, [hl] + hlcoord 1, 7 + ld a, BANK(GBPrinterStrings) + call FarString + hlcoord 2, 15 + ld de, String_PressBToCancel + call PlaceString + ld a, $1 + ld [hBGMapMode], a + xor a + ld [wcbf8], a + ret +; 847bd -Function8ca23: ; 8ca23 (23:4a23) - call Function8cad3 - ld a, SPRITE_ANIM_INDEX_17 ; leaf - call _InitSpriteAnimStruct - ld hl, $3 - add hl, bc - ld [hl], $84 - ld a, $20 - ld [wcf64], a - ld hl, wJumptableIndex +Function847bd: ; 847bd + ld a, [wcbf8] + and a + ret z + push af + xor a + ld [hBGMapMode], a + hlcoord 2, 4 + lb bc, 13, 16 + call ClearBox + pop af + ld e, a + ld d, 0 + ld hl, PrinterStatusStringPointers rept 2 - inc [hl] + add hl, de endr + ld e, [hl] + inc hl + ld d, [hl] + hlcoord 4, 7 + ld a, BANK(GBPrinterStrings) + call FarString + hlcoord 4, 15 + ld de, String_PressBToCancel + call PlaceString + ld a, $1 + ld [hBGMapMode], a + xor a + ld [wcbf8], a ret +; 847f5 + +String_PressBToCancel: + db "Press B to Cancel@" +; 84807 + +PrinterStatusStringPointers: ; 84807 + dw String_1dc275 ; @ + dw String_1dc276 ; CHECKING LINK + dw String_1dc289 ; TRANSMITTING + dw String_1dc29c ; PRINTING + dw String_1dc2ad ; error 1 + dw String_1dc2e2 ; error 2 + dw String_1dc317 ; error 3 + dw String_1dc34c ; error 4 +; 84817 -Function8ca3c: ; 8ca3c (23:4a3c) - call Function8ca8e +Function84817: ; 84817 (21:4817) xor a - call Function8ca73 - ld a, $10 - call Function8ca73 - ld a, $20 - call Function8ca73 - ld a, $30 - call Function8ca73 - ld a, $20 - ld [wcf64], a - ld hl, wJumptableIndex - inc [hl] + ld [wd002], a + hlcoord 0, 0 + ld bc, SCREEN_HEIGHT * SCREEN_WIDTH + ld a, " " + call ByteFill + call Function84a0e + hlcoord 0, 0 + ld bc, 9 * SCREEN_WIDTH + ld a, " " + call ByteFill + call Function849e9 + call Function849d7 + hlcoord 4, 3 + ld de, String_84865 + call PlaceString + ld a, [wd007] + ld bc, BOX_NAME_LENGTH + ld hl, wBoxNames + call AddNTimes + ld d, h + ld e, l + hlcoord 6, 5 + call PlaceString + ld a, $1 + call Function849c6 + hlcoord 2, 9 + ld c, $3 + call Function848e7 ret +; 84865 (21:4865) -Function8ca5c: ; 8ca5c (23:4a5c) - ld a, $1 - ld [hBGMapMode], a - ld hl, wJumptableIndex - inc [hl] +String_84865: + db "#MON LIST@" +; 8486f -Function8ca64: ; 8ca64 (23:4a64) - ld hl, wcf64 - ld a, [hl] +Function8486f: ; 8486f (21:486f) + hlcoord 0, 0 + ld bc, SCREEN_HEIGHT * SCREEN_WIDTH + ld a, " " + call ByteFill + call Function84a0e + call Function849e9 + ld a, [wd003] and a - jr z, .asm_8ca6d - dec [hl] + ret nz + ld a, $4 + call Function849c6 + hlcoord 2, 0 + ld c, $6 + call Function848e7 ret -.asm_8ca6d - ld hl, wJumptableIndex - set 7, [hl] + +Function84893: ; 84893 (21:4893) + hlcoord 0, 0 + ld bc, SCREEN_HEIGHT * SCREEN_WIDTH + ld a, " " + call ByteFill + call Function84a0e + call Function849e9 + ld a, [wd003] + and a + ret nz + ld a, $a + call Function849c6 + hlcoord 2, 0 + ld c, $6 + call Function848e7 + ret + +Function848b7: ; 848b7 (21:48b7) + hlcoord 0, 0 + ld bc, SCREEN_HEIGHT * SCREEN_WIDTH + ld a, " " + call ByteFill + call Function84a0e + hlcoord 1, 15 + lb bc, 2, 18 + call ClearBox + call Function849e9 + call Function849fc + ld a, [wd003] + and a + ret nz + ld a, $10 + call Function849c6 + hlcoord 2, 0 + ld c, $5 + call Function848e7 ret -Function8ca73: ; 8ca73 (23:4a73) +Function848e7: ; 848e7 (21:48e7) + ld a, [EndFlypoint] + call GetSRAMBank + +Function848ed: ; 848ed (21:48ed) + ld a, c + and a + jp z, Function84986 + dec c + ld a, [de] + cp $ff + jp z, Function84981 + ld [wd265], a + ld [CurPartySpecies], a + push bc + push hl push de - push af - ld a, SPRITE_ANIM_INDEX_16 ; fly takeoff - call _InitSpriteAnimStruct - ld hl, $3 + push hl + ld bc, $10 + ld a, " " + call ByteFill + pop hl + push hl + call GetBasePokemonName + pop hl + push hl + call PlaceString + ld a, [CurPartySpecies] + cp $fd + pop hl + jr z, .ok2 + ld bc, $b add hl, bc - ld [hl], $80 - ld hl, $e + call Function8498a + ld bc, $9 add hl, bc - ld [hl], $4 - pop af - ld hl, $c + ld a, $f3 + ld [hli], a + push hl + ld bc, $e + ld a, " " + call ByteFill + pop hl + push hl + ld a, [wd004] + ld l, a + ld a, [StartFlypoint] + ld h, a + ld bc, $372 add hl, bc - ld [hl], a + ld bc, $b + ld a, [wd002] + call AddNTimes + ld e, l + ld d, h + pop hl + push hl + call PlaceString + pop hl + ld bc, $b + add hl, bc + push hl + ld a, [wd004] + ld l, a + ld a, [StartFlypoint] + ld h, a + ld bc, $35 + add hl, bc + ld bc, $20 + ld a, [wd002] + call AddNTimes + ld a, [hl] + pop hl + call Function383d +.ok2 + ld hl, wd002 + inc [hl] pop de - ret + pop hl + ld bc, $3c + add hl, bc + pop bc + inc de + jp Function848ed -Function8ca8e: ; 8ca8e (23:4a8e) - ld de, 0 - ld a, [wd197] - bit 0, a - jr z, .asm_8ca9a - set 0, e -.asm_8ca9a - ld a, [wd196] - bit 0, a - jr z, .asm_8caa3 - set 1, e -.asm_8caa3 - ld a, [PlayerDirection] - and $c - add e - ld e, a - ld hl, Unknown_8cab3 -rept 2 - add hl, de -endr - ld e, [hl] - inc hl - ld d, [hl] - ret -; 8cab3 (23:4ab3) - -Unknown_8cab3: ; 8cab3 - db $58, $60 - db $48, $60 - db $58, $70 - db $48, $70 - db $58, $40 - db $48, $40 - db $58, $50 - db $48, $50 - db $38, $60 - db $48, $60 - db $38, $50 - db $48, $50 - db $58, $60 - db $68, $60 - db $58, $50 - db $68, $50 -; 8cad3 - -Function8cad3: ; 8cad3 (23:4ad3) - ld a, [PlayerDirection] - and $c - srl a - ld e, a - ld d, 0 - ld hl, Unknown_8cae5 - add hl, de - ld e, [hl] - inc hl - ld d, [hl] - ret -; 8cae5 (23:4ae5) +Function84981: ; 84981 (21:4981) + ld a, $1 + ld [wd003], a -Unknown_8cae5: ; 8cae5 - db $50, $68 - db $50, $48 - db $40, $58 - db $60, $58 -; 8caed +Function84986: ; 84986 (21:4986) + call CloseSRAM + ret -Function8caed: ; 8caed - call DelayFrame - ld a, [VramState] - push af - xor a - ld [VramState], a - call Function8cb9b - lb de, $54, $50 - ld a, SPRITE_ANIM_INDEX_0A - call _InitSpriteAnimStruct - ld hl, $3 - add hl, bc - ld [hl], $84 - ld hl, $2 +Function8498a: ; 8498a (21:498a) + push hl + ld a, [wd004] + ld l, a + ld a, [StartFlypoint] + ld h, a + ld bc, $2b add hl, bc - ld [hl], $16 - ld a, $80 - ld [wcf64], a -.asm_8cb14 - ld a, [wJumptableIndex] - bit 7, a - jr nz, .asm_8cb2e - ld a, $0 - ld [wc3b5], a - callab Function8cf7a - call Function8cbc8 - call DelayFrame - jr .asm_8cb14 -.asm_8cb2e - pop af - ld [VramState], a + ld bc, $20 + ld a, [wd002] + call AddNTimes + ld de, TempMonDVs + ld a, [hli] + ld [de], a + inc de + ld a, [hli] + ld [de], a + ld a, [wd002] + ld [CurPartyMon], a + ld a, $3 + ld [MonType], a + callba GetGender + ld a, $7f + jr c, .asm_849c3 + ld a, $ef + jr nz, .asm_849c3 + ld a, $f5 +.asm_849c3 + pop hl + ld [hli], a ret -; 8cb33 -Function8cb33: ; 8cb33 - call DelayFrame - ld a, [VramState] - push af - xor a - ld [VramState], a - call Function8cb9b - lb de, $fc, $50 - ld a, SPRITE_ANIM_INDEX_0A - call _InitSpriteAnimStruct - ld hl, $3 - add hl, bc - ld [hl], $84 - ld hl, $2 - add hl, bc - ld [hl], $18 - ld hl, $f - add hl, bc - ld [hl], $58 - ld a, $40 - ld [wcf64], a -.asm_8cb60 - ld a, [wJumptableIndex] - bit 7, a - jr nz, .asm_8cb7a - ld a, $0 - ld [wc3b5], a - callab Function8cf7a - call Function8cbc8 - call DelayFrame - jr .asm_8cb60 -.asm_8cb7a - pop af - ld [VramState], a - call Function8cb82 +Function849c6: ; 849c6 (21:49c6) + push hl + ld e, a + ld d, $0 + ld a, [wd004] + ld l, a + ld a, [StartFlypoint] + ld h, a + add hl, de + ld e, l + ld d, h + pop hl ret -Function8cb82: ; 8cb82 (23:4b82) - ld hl, Sprites + 2 - xor a - ld c, $4 -.asm_8cb88 +Function849d7: ; 849d7 (21:49d7) + hlcoord 0, 0 + ld a, $79 ld [hli], a -rept 3 - inc hl -endr - inc a - dec c - jr nz, .asm_8cb88 - ld hl, Sprites + $10 - ld bc, $90 - xor a - call ByteFill + ld a, $7a + ld c, $12 +.asm_849e1 + ld [hli], a + dec c + jr nz, .asm_849e1 + ld a, $7b + ld [hl], a ret -Function8cb9b: ; 8cb9b (23:4b9b) - callab Function8cf53 - ld de, CutGrassGFX - ld hl, VTiles1 tile $00 - lb bc, BANK(CutGrassGFX), 4 - call Request2bpp - ld a, [CurPartyMon] - ld hl, PartySpecies - ld e, a - ld d, 0 +Function849e9: ; 849e9 (21:49e9) + hlcoord 0, 0 + ld de, $13 + ld c, $12 +.asm_849f1 + ld a, $7c + ld [hl], a add hl, de - ld a, [hl] - ld [wd265], a - ld e, $84 - callba Function8e9bc - xor a - ld [wJumptableIndex], a + ld a, $7c + ld [hli], a + dec c + jr nz, .asm_849f1 ret -Function8cbc8: ; 8cbc8 (23:4bc8) - call Function8cbe6 - ld hl, wcf64 - ld a, [hl] - and a - jr z, .asm_8cbe0 - dec [hl] - cp $40 - ret c - and $7 - ret nz - ld de, SFX_FLY - call PlaySFX - ret -.asm_8cbe0 - ld hl, wJumptableIndex - set 7, [hl] +Function849fc: ; 849fc (21:49fc) + hlcoord 0, 17 + ld a, $7d + ld [hli], a + ld a, $7a + ld c, $12 +.asm_84a06 + ld [hli], a + dec c + jr nz, .asm_84a06 + ld a, $7e + ld [hl], a ret -Function8cbe6: ; 8cbe6 (23:4be6) - ld hl, wcf65 - ld a, [hl] - inc [hl] - and $7 - ret nz - ld a, [hl] - and $18 - sla a - add $40 - ld d, a - ld e, $0 - ld a, SPRITE_ANIM_INDEX_18 ; fly land - call _InitSpriteAnimStruct - ld hl, $3 +Function84a0e: ; 84a0e (21:4a0e) + hlcoord 2, 0 + ld c, $6 +.asm_84a13 + push bc + push hl + ld de, String84a25 + call PlaceString + pop hl + ld bc, $3c add hl, bc - ld [hl], $80 + pop bc + dec c + jr nz, .asm_84a13 ret +; 84a25 (21:4a25) -Special_MagnetTrain: ; 8cc04 - ld a, [ScriptVar] - and a - jr nz, .ToGoldenrod - ld a, 1 ; forwards - lb bc, $40, $60 - ld de, $fca0 - jr .continue +String84a25: ; 84a25 + db " ------@" +; 84a2e -.ToGoldenrod - ld a, -1 ; backwards - lb bc, $c0, $a0 - ld de, $b460 -.continue - ld h, a - ld a, [rSVBK] - push af - ld a, $5 - ld [rSVBK], a - ld a, h - ld [w5_d191], a - ld a, c - ld [w5_d192], a - ld a, b - ld [w5_d193], a - ld a, e - ld [w5_d194], a - ld a, d - ld [w5_d195], a - ld a, [hSCX] - push af - ld a, [hSCY] - push af - call Function8ccc9 - ld hl, hVBlank - ld a, [hl] +INCLUDE "battle/anim_gfx.asm" + + +HallOfFame:: ; 0x8640e + call Function8648e + ld a, [StatusFlags] push af - ld [hl], $1 -.loop - ld a, [wJumptableIndex] - and a - jr z, .initialize - bit 7, a - jr nz, .done - callab Function8cf69 - call Function8cdf7 - call Function8cc99 - call Function3b0c - call DelayFrame - jr .loop + ld a, 1 + ld [wc2cd], a + call DisableSpriteUpdates + ld a, SPAWN_LANCE + ld [wSpawnAfterChampion], a -.initialize - call Function8ceae - jr .loop + ; Enable the Pokégear map to cycle through all of Kanto + ld hl, StatusFlags + set 6, [hl] ; hall of fame -.done - pop af - ld [hVBlank], a - call ClearBGPalettes - xor a - ld [hLCDStatCustom], a - ld [hLCDStatCustom + 1], a - ld [hLCDStatCustom + 2], a - ld [hSCX], a - ld [Requested2bppSource], a - ld [Requested2bppSource + 1], a - ld [Requested2bppDest], a - ld [Requested2bppDest + 1], a - ld [Requested2bpp], a - call ClearTileMap - pop af - ld [hSCY], a - pop af - ld [hSCX], a - xor a - ld [hBGMapMode], a - pop af - ld [rSVBK], a - ret -; 8cc99 + callba Function14da0 -Function8cc99: ; 8cc99 - ld hl, LYOverridesBackup - ld c, $2f - ld a, [wcf64] - add a - ld [hSCX], a - call Function8ccc4 - ld c, $30 - ld a, [wcf65] - call Function8ccc4 - ld c, $31 - ld a, [wcf64] - add a - call Function8ccc4 - ld a, [wd191] - ld d, a - ld hl, wcf64 + ld hl, wHallOfFameCount ld a, [hl] -rept 2 - add d -endr - ld [hl], a - ret -; 8ccc4 - -Function8ccc4: ; 8ccc4 -.asm_8ccc4 - ld [hli], a - dec c - jr nz, .asm_8ccc4 - ret -; 8ccc9 + cp 200 + jr nc, .ok + inc [hl] +.ok + callba SaveGameData + call GetHallOfFameParty + callba AddHallOfFameEntry -Function8ccc9: ; 8ccc9 - call ClearBGPalettes - call ClearSprites - call DisableLCD - callab Function8cf53 - call SetMagnetTrainPals - call DrawMagnetTrain - ld a, $90 - ld [hWY], a - call EnableLCD xor a - ld [hBGMapMode], a - ld [hSCX], a - ld [hSCY], a - ld a, [rSVBK] - push af - ld a, $1 - ld [rSVBK], a - callba GetPlayerIcon + ld [wc2cd], a + call Function864c3 pop af - ld [rSVBK], a - ld hl, VTiles0 - ld c, $4 - call Request2bpp - ld hl, $c0 - add hl, de - ld d, h - ld e, l - ld hl, VTiles0 tile $04 - ld c, $4 - call Request2bpp - call Function8cda6 - ld hl, wJumptableIndex - xor a - ld [hli], a - ld a, [wd192] -rept 3 - ld [hli], a -endr - ld de, MUSIC_MAGNET_TRAIN - call PlayMusic2 + ld b, a + callba Function109847 ret -; 8cd27 +; 0x86455 -DrawMagnetTrain: ; 8cd27 - ld hl, VBGMap0 +RedCredits:: ; 86455 + ld a, MUSIC_NONE % $100 + ld [MusicFadeIDLo], a + ld a, MUSIC_NONE / $100 + ld [MusicFadeIDHi], a + ld a, $a + ld [MusicFade], a + callba FadeOutPalettes xor a -.asm_8cd2b - call GetMagnetTrainBGTiles - ld b, 32 / 2 - call .FillAlt - inc a - cp $12 - jr c, .asm_8cd2b - ld hl, VBGMap0 tile $0c - ld de, MagnetTrainTilemap1 - ld c, 20 - call .FillLine - ld hl, VBGMap0 tile $0e - ld de, MagnetTrainTilemap2 - ld c, 20 - call .FillLine - ld hl, VBGMap0 tile $10 - ld de, MagnetTrainTilemap3 - ld c, 20 - call .FillLine - ld hl, VBGMap0 tile $12 - ld de, MagnetTrainTilemap4 - ld c, 20 - call .FillLine + ld [VramState], a + ld [hMapAnims], a + callba Function4e8c2 + ld c, 8 + call DelayFrames + call DisableSpriteUpdates + ld a, SPAWN_RED + ld [wSpawnAfterChampion], a + ld a, [StatusFlags] + ld b, a + callba Function109847 ret -; 8cd65 +; 8648e -.FillLine ; 8cd65 - ld a, [de] - inc de - ld [hli], a - dec c - jr nz, .FillLine - ret -; 8cd6c +Function8648e: ; 8648e + ld a, MUSIC_NONE % $100 + ld [MusicFadeIDLo], a + ld a, MUSIC_NONE / $100 + ld [MusicFadeIDHi], a + ld a, 10 + ld [MusicFade], a + callba FadeOutPalettes + xor a + ld [VramState], a + ld [hMapAnims], a + callba Function4e881 + ld c, 100 + jp DelayFrames +; 864b4 -.FillAlt ; 8cd6c - ld [hl], e - inc hl - ld [hl], d - inc hl - dec b - jr nz, .FillAlt +Function864b4: ; 864b4 + push de + ld de, MUSIC_NONE + call PlayMusic + call DelayFrame + pop de + call PlayMusic ret -; 8cd74 +; 864c3 -GetMagnetTrainBGTiles: ; 8cd74 +Function864c3: ; 864c3 + xor a + ld [wJumptableIndex], a + call Function8671c + jr c, .done + ld de, SCREEN_WIDTH + call Function864b4 + xor a + ld [wcf64], a +.loop + ld a, [wcf64] + cp 6 + jr nc, .done + ld hl, wc608 + 1 + ld bc, $10 + call AddNTimes + ld a, [hl] + cp -1 + jr z, .done push hl - ld e, a - ld d, 0 - ld hl, MagnetTrainBGTiles -rept 2 - add hl, de -endr - ld e, [hl] - inc hl - ld d, [hl] + call Function865b5 pop hl + call Function8650c + jr c, .done + ld hl, wcf64 + inc [hl] + jr .loop + +.done + call Function86810 + ld a, $4 + ld [MusicFade], a + call FadeToWhite + ld c, 8 + call DelayFrames ret -; 8cd82 - -MagnetTrainBGTiles: ; 8cd82 -; Alternating tiles for each line -; of the Magnet Train tilemap. - db $4c, $4d ; bush - db $5c, $5d ; bush - db $4c, $4d ; bush - db $5c, $5d ; bush - db $08, $08 ; fence - db $18, $18 ; fence - db $1f, $1f ; track - db $31, $31 ; track - db $11, $11 ; track - db $11, $11 ; track - db $0d, $0d ; track - db $31, $31 ; track - db $04, $04 ; fence - db $18, $18 ; fence - db $4c, $4d ; bush - db $5c, $5d ; bush - db $4c, $4d ; bush - db $5c, $5d ; bush -; 8cda6 - -Function8cda6: ; 8cda6 - ld hl, LYOverrides - ld bc, $90 - ld a, [wd192] - call ByteFill - ld hl, LYOverridesBackup - ld bc, $90 - ld a, [wd192] - call ByteFill - ld a, $43 - ld [hLCDStatCustom], a +; 8650c + +Function8650c: ; 8650c + call Function86748 + ld de, String_8652c + hlcoord 1, 2 + call PlaceString + call WaitBGMap + decoord 6, 5 + ld c, $6 + predef Functiond066e + ld c, 60 + call DelayFrames + and a ret -; 8cdc3 +; 8652c -SetMagnetTrainPals: ; 8cdc3 - ld a, $1 - ld [rVBK], a +String_8652c: + db "New Hall of Famer!@" +; 8653f - ; bushes - ld hl, VBGMap0 - ld bc, 8 tiles - ld a, $2 - call ByteFill - ; train - ld hl, VBGMap0 tile $08 - ld bc, 20 tiles +GetHallOfFameParty: ; 8653f + ld hl, OverworldMap + ld bc, HOF_LENGTH xor a call ByteFill + ld a, [wHallOfFameCount] + ld de, OverworldMap + ld [de], a + inc de + ld hl, PartySpecies + ld c, 0 +.next + ld a, [hli] + cp -1 + jr z, .done + cp EGG + jr nz, .mon + inc c + jr .next - ; more bushes - ld hl, VBGMap0 tile $1c - ld bc, 8 tiles - ld a, $2 - call ByteFill +.mon + push hl + push de + push bc - ; train window - ld hl, VBGMap0 tile $10 + 7 - ld bc, 6 - ld a, $4 - call ByteFill + ld a, c + ld hl, PartyMons + ld bc, PARTYMON_STRUCT_LENGTH + call AddNTimes + ld c, l + ld b, h - ld a, $0 - ld [rVBK], a - ret -; 8cdf7 + ld hl, MON_SPECIES + add hl, bc + ld a, [hl] + ld [de], a + inc de -Function8cdf7: ; 8cdf7 - ld a, [wJumptableIndex] - ld e, a - ld d, 0 - ld hl, Jumptable_8ce06 -rept 2 - add hl, de -endr + ld hl, MON_ID + add hl, bc ld a, [hli] - ld h, [hl] - ld l, a - jp [hl] -; 8ce06 - -Jumptable_8ce06: ; 8ce06 - dw Function8ce19 - dw Function8ce6d - dw Function8ce47 - dw Function8ce6d - dw Function8ce7a - dw Function8ce6d - dw Function8cea2 -; 8ce14 - -Function8ce14: ; 8ce14 - ld hl, wJumptableIndex - inc [hl] - ret -; 8ce19 + ld [de], a + inc de + ld a, [hl] + ld [de], a + inc de -Function8ce19: ; 8ce19 - ld d, $55 - ld a, [wd194 + 1] - ld e, a - ld b, SPRITE_ANIM_INDEX_15 - ld a, [rSVBK] - push af - ld a, $1 - ld [rSVBK], a - ld a, [PlayerGender] - bit 0, a - jr z, .asm_8ce31 - ld b, SPRITE_ANIM_INDEX_1F + ld hl, MON_DVS + add hl, bc + ld a, [hli] + ld [de], a + inc de + ld a, [hl] + ld [de], a + inc de -.asm_8ce31 - pop af - ld [rSVBK], a - ld a, b - call _InitSpriteAnimStruct - ld hl, $3 + ld hl, MON_LEVEL add hl, bc - ld [hl], $0 - call Function8ce14 - ld a, $80 - ld [wcf66], a + ld a, [hl] + ld [de], a + inc de + + pop bc + push bc + ld a, c + ld hl, PartyMonNicknames + ld bc, PKMN_NAME_LENGTH + call AddNTimes + ld bc, PKMN_NAME_LENGTH - 1 + call CopyBytes + + pop bc + inc c + pop de + ld hl, HOF_MON_LENGTH + add hl, de + ld e, l + ld d, h + pop hl + jr .next + +.done + ld a, $ff + ld [de], a ret -; 8ce47 +; 865b5 -Function8ce47: ; 8ce47 - ld hl, wd193 - ld a, [wcf65] - cp [hl] - jr z, .asm_8ce64 - ld e, a - ld a, [wd191] - xor $ff - inc a - add e - ld [wcf65], a - ld hl, wc3c0 - ld a, [wd191] - add [hl] - ld [hl], a +Function865b5: ; 865b5 + push hl + call ClearBGPalettes + callba Function4e906 + pop hl + ld a, [hli] + ld [TempMonSpecies], a + ld [CurPartySpecies], a +rept 2 + inc hl +endr + ld a, [hli] + ld [TempMonDVs], a + ld a, [hli] + ld [TempMonDVs + 1], a + ld hl, TempMonDVs + predef GetUnownLetter + hlcoord 0, 0 + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT + ld a, " " + call ByteFill + ld de, VTiles2 tile $31 + predef GetBackpic + ld a, $31 + ld [hFillBox], a + hlcoord 6, 6 + lb bc, 6, 6 + predef FillBox + ld a, $d0 + ld [hSCY], a + ld a, $90 + ld [hSCX], a + call WaitBGMap + xor a + ld [hBGMapMode], a + ld b, SCGB_1A + call GetSGBLayout + call SetPalettes + call Function86635 + xor a + ld [wc2c6], a + hlcoord 0, 0 + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT + ld a, " " + call ByteFill + hlcoord 6, 5 + call _PrepMonFrontpic + call WaitBGMap + xor a + ld [hBGMapMode], a + ld [hSCY], a + call Function86643 ret +; 86635 -.asm_8ce64 - call Function8ce14 - ld a, $80 - ld [wcf66], a - ret -; 8ce6d +Function86635: ; 86635 +.loop + ld a, [hSCX] + cp $70 + ret z + add $4 + ld [hSCX], a + call DelayFrame + jr .loop +; 86643 -Function8ce6d: ; 8ce6d - ld hl, wcf66 - ld a, [hl] +Function86643: ; 86643 +.loop + ld a, [hSCX] and a - jr z, .asm_8ce76 - dec [hl] - ret - -.asm_8ce76 - call Function8ce14 - ret -; 8ce7a - -Function8ce7a: ; 8ce7a - ld hl, wd194 - ld a, [wcf65] - cp [hl] - jr z, .asm_8ce9e - ld e, a - ld a, [wd191] - xor $ff - inc a - ld d, a - ld a, e -rept 2 - add d -endr - ld [wcf65], a - ld hl, wc3c0 - ld a, [wd191] - ld d, a - ld a, [hl] + ret z rept 2 - add d + dec a endr - ld [hl], a - ret - - ret - -.asm_8ce9e - call Function8ce14 - ret -; 8cea2 + ld [hSCX], a + call DelayFrame + jr .loop +; 86650 -Function8cea2: ; 8cea2 - ld a, $80 +_HallOfFamePC: ; 86650 + call LoadFontsBattleExtra + xor a ld [wJumptableIndex], a - ld de, SFX_TRAIN_ARRIVED - call PlaySFX - ret -; 8ceae +.loop + call Function8671c + ret c + call Function86665 + ret c + ld hl, wJumptableIndex + inc [hl] + jr .loop +; 86665 -Function8ceae: ; 8ceae - callba Function8cf69 - call Function8cdf7 - call Function8cc99 - call Function3b0c +Function86665: ; 86665 + xor a + ld [wcf64], a +.next + call Function86692 + jr c, .start_button +.loop + call JoyTextDelay + ld hl, hJoyLast + ld a, [hl] + and B_BUTTON + jr nz, .b_button + ld a, [hl] + and A_BUTTON + jr nz, .a_button + ld a, [hl] + and START + jr nz, .start_button call DelayFrame - ld a, [rSVBK] - push af - ld a, $1 - ld [rSVBK], a - ld a, [TimeOfDayPal] - push af - ld a, [wPermission] - push af - ld a, [TimeOfDay] - and $3 - ld [TimeOfDayPal], a - ld a, $1 - ld [wPermission], a - ld b, SCGB_09 - call GetSGBLayout - call UpdateTimePals - ld a, [rBGP] - ld [wcfc7], a - ld a, [rOBP0] - ld [wcfc8], a - ld a, [rOBP1] - ld [wcfc9], a - pop af - ld [wPermission], a - pop af - ld [TimeOfDayPal], a - pop af - ld [rSVBK], a - ret -; 8ceff - -MagnetTrainTilemap1: - db $1f, $05, $06, $0a, $0a - db $0a, $09, $0a, $0a, $0a - db $0a, $0a, $0a, $09, $0a - db $0a, $0a, $0b, $0c, $1f -MagnetTrainTilemap2: - db $14, $15, $16, $1a, $1a - db $1a, $19, $1a, $1a, $1a - db $1a, $1a, $1a, $19, $1a - db $1a, $1a, $1b, $1c, $1d -MagnetTrainTilemap3: - db $24, $25, $26, $27, $07 - db $2f, $29, $28, $28, $28 - db $28, $28, $28, $29, $07 - db $2f, $2a, $2b, $2c, $2d -MagnetTrainTilemap4: - db $20, $1f, $2e, $1f, $17 - db $00, $2e, $1f, $1f, $1f - db $1f, $1f, $1f, $2e, $17 - db $00, $1f, $2e, $1f, $0f -; 8cf4f - -Function8cf4f: ; 8cf4f - call Function3238 - ret -; 8cf53 - - -INCLUDE "engine/sprites.asm" + jr .loop -Function8e79d: ; 8e79d - ld a, [hSGB] - ld de, GFX_8e7f4 - and a - jr z, .asm_8e7a8 - ld de, GFX_8e804 +.a_button + ld hl, wcf64 + inc [hl] + jr .next -.asm_8e7a8 - ld hl, VTiles0 - lb bc, BANK(GFX_8e7f4), 1 - call Request2bpp - ld c, $8 - ld d, $0 -.asm_8e7b5 - push bc - call Function8e7c6 - call DelayFrame - pop bc -rept 2 - inc d -endr - dec c - jr nz, .asm_8e7b5 - call ClearSprites +.b_button + scf ret -; 8e7c6 -Function8e7c6: ; 8e7c6 - ld hl, Sprites - ld c, $8 -.asm_8e7cb - ld a, c +.start_button and a - ret z - dec c - ld a, c - sla a - sla a - sla a - push af - push de - push hl - call Function8e72c - pop hl - pop de - add $68 - ld [hli], a - pop af - push de - push hl - call Function8e72a - pop hl - pop de - add $54 - ld [hli], a - ld a, $0 - ld [hli], a - ld a, $6 - ld [hli], a - jr .asm_8e7cb -; 8e7f4 - -GFX_8e7f4: ; 8e7f4 -INCBIN "gfx/unknown/08e7f4.2bpp" -GFX_8e804: ; 8e804 -INCBIN "gfx/unknown/08e804.2bpp" - -InefficientlyClear121BytesAtwc300: ; 8e814 - push hl - push de - push bc - push af - ld hl, wc300 - ld bc, wc3c1 - wc300 -.loop - ld [hl], $0 - inc hl - dec bc - ld a, c - or b - jr nz, .loop - pop af - pop bc - pop de - pop hl ret -; 8e82b +; 86692 -Function8e82b: ; 8e82b - ld a, e - 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) - ld c, 8 +Function86692: ; 86692 +; Print the number of times the player has entered the Hall of Fame. +; If that number is above 200, print "HOF Master!" instead. + ld a, [wcf64] + cp $6 + jr nc, .fail + ld hl, wc608 + 1 + ld bc, $10 + call AddNTimes + ld a, [hl] + cp $ff + jr nz, .okay + +.fail + scf ret -; 8e83f -Function8e83f: ; 8e83f +.okay push hl - push de - push bc - call Function8e849 - pop bc - pop de + call ClearBGPalettes pop hl - ret -; 8e849 + call Function86748 + ld a, [wc608] + cp 200 + 1 + jr c, .print_num_hof + ld de, String_866fc + hlcoord 1, 2 + call PlaceString + hlcoord 13, 2 + jr .finish + +.print_num_hof + ld de, String_8670c + hlcoord 1, 2 + call PlaceString + hlcoord 2, 2 + ld de, wc608 + lb bc, 1, 3 + call PrintNum + hlcoord 11, 2 -Function8e849: ; 8e849 - ld d, 0 - ld hl, Jumptable_8e854 -rept 2 - add hl, de -endr - ld a, [hli] - ld h, [hl] - ld l, a - jp [hl] -; 8e854 +.finish + ld de, String_866fb + call PlaceString + call WaitBGMap + ld b, SCGB_1A + call GetSGBLayout + call SetPalettes + decoord 6, 5 + ld c, $6 + predef Functiond066e + and a + ret +; 866fb +String_866fb: + db "@" +; 866fc -Jumptable_8e854: ; 8e854 (23:6854) - dw Function8e8d5 - dw Function8e961 - dw Function8e97d - dw Function8e99a - dw Function8e898 - dw Function8e8b1 - dw Function8e862 +String_866fc: + db " HOF Master!@" +; 8670c +String_8670c: + db " -Time Famer@" +; 8671c -Function8e862: ; 8e862 (23:6862) - call Function8e908 - call Function8e86c - call Function8e936 - ret -Function8e86c: ; 8e86c (23:686c) - push bc - ld a, [hObjectStructIndexBuffer] - ld hl, PartyMon1Item - ld bc, PARTYMON_STRUCT_LENGTH +Function8671c: ; 8671c + ld a, [wJumptableIndex] + cp NUM_HOF_TEAMS + jr nc, .full + ld hl, sHallOfFame + ld bc, HOF_LENGTH call AddNTimes - pop bc + ld a, BANK(sHallOfFame) + call GetSRAMBank ld a, [hl] and a - jr z, .asm_8e890 - push hl - push bc - ld d, a - callab ItemIsMail - pop bc - pop hl - jr c, .asm_8e88e - ld a, $6 - jr .asm_8e892 -.asm_8e88e - ld a, $5 -.asm_8e890 - ld a, $4 -.asm_8e892 - ld hl, $1 - add hl, bc - ld [hl], a - ret - -Function8e898: ; 8e898 (23:6898) - call Function8e8d5 - ld hl, $2 - add hl, bc - ld a, $0 - ld [hl], a - ld hl, $4 - add hl, bc - ld a, $48 - ld [hl], a - ld hl, $5 - add hl, bc - ld a, $48 - ld [hl], a + jr z, .fail + ld de, wc608 + ld bc, HOF_LENGTH + call CopyBytes + call CloseSRAM + and a ret -Function8e8b1: ; 8e8b1 (23:68b1) - call Function8e908 - call Function8e936 - ld hl, $2 - add hl, bc - ld a, $0 - ld [hl], a - ld hl, $4 - add hl, bc - ld a, $18 - ld [hl], a - ld hl, $5 - add hl, bc - ld a, $60 - ld [hl], a - ld a, c - ld [wc608], a - ld a, b - ld [wc608 + 1], a - ret +.fail + call CloseSRAM -Function8e8d5: ; 8e8d5 (23:68d5) - call Function8e908 - call Function8e8df - call Function8e936 +.full + scf ret +; 86748 -Function8e8df: ; 8e8df (23:68df) - push bc - ld a, [hObjectStructIndexBuffer] - ld hl, PartyMon1Item - ld bc, $30 - call AddNTimes - pop bc - ld a, [hl] - and a - ret z - push hl - push bc - ld d, a - callab ItemIsMail - pop bc - pop hl - jr c, .asm_8e900 +Function86748: ; 86748 + xor a + ld [hBGMapMode], a + ld a, [hli] + ld [TempMonSpecies], a + ld a, [hli] + ld [TempMonID], a + ld a, [hli] + ld [TempMonID + 1], a + ld a, [hli] + ld [TempMonDVs], a + ld a, [hli] + ld [TempMonDVs + 1], a + ld a, [hli] + ld [TempMonLevel], a + ld de, StringBuffer2 + ld bc, 10 + call CopyBytes + ld a, "@" + ld [StringBuffer2 + 10], a + hlcoord 0, 0 + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT + ld a, " " + call ByteFill + hlcoord 0, 0 + lb bc, 3, SCREEN_WIDTH - 2 + call TextBox + hlcoord 0, 12 + lb bc, 4, SCREEN_WIDTH - 2 + call TextBox + ld a, [TempMonSpecies] + ld [CurPartySpecies], a + ld [wd265], a + ld hl, TempMonDVs + predef GetUnownLetter + xor a + ld [wc2c6], a + hlcoord 6, 5 + call _PrepMonFrontpic + ld a, [CurPartySpecies] + cp EGG + jr z, .print_id_no + hlcoord 1, 13 + ld a, $74 + ld [hli], a + ld [hl], $f2 + hlcoord 3, 13 + ld de, wd265 + lb bc, PRINTNUM_LEADINGZEROS | 1, 3 + call PrintNum + call GetBasePokemonName + hlcoord 7, 13 + call PlaceString ld a, $3 - jr .asm_8e902 -.asm_8e900 - ld a, $2 -.asm_8e902 - ld hl, $1 - add hl, bc - ld [hl], a - ret + ld [MonType], a + callba GetGender + ld a, " " + jr c, .got_gender + ld a, "♂" + jr nz, .got_gender + ld a, "♀" -Function8e908: ; 8e908 (23:6908) - ld a, [wc3b7] - push af - ld a, [hObjectStructIndexBuffer] - ld hl, PartySpecies - ld e, a - ld d, $0 - add hl, de - ld a, [hl] - call ReadMonMenuIcon - ld [CurIcon], a - call Function8e9db - ld a, [hObjectStructIndexBuffer] -; y coord -rept 4 - add a -endr - add $1c - ld d, a -; x coord - ld e, $10 -; type is partymon icon - ld a, SPRITE_ANIM_INDEX_00 - call InitSpriteAnimStruct - pop af - ld hl, $3 - add hl, bc - ld [hl], a +.got_gender + hlcoord 18, 13 + ld [hli], a + hlcoord 8, 14 + ld a, "/" + ld [hli], a + ld de, StringBuffer2 + call PlaceString + hlcoord 1, 16 + call PrintLevel + +.print_id_no + hlcoord 7, 16 + ld a, "" + ld [hli], a + ld a, "№" + ld [hli], a + ld [hl], "/" + hlcoord 10, 16 + ld de, TempMonID + lb bc, PRINTNUM_LEADINGZEROS | 2, 5 + call PrintNum ret +; 86810 -Function8e936: ; 8e936 (23:6936) - push bc - ld a, [hObjectStructIndexBuffer] - ld b, a - call Function8e94c - ld a, b - pop bc - ld hl, $9 - add hl, bc - ld [hl], a - rlca - rlca - ld hl, $d - add hl, bc - ld [hl], a +Function86810: ; 86810 + call ClearBGPalettes + ld hl, VTiles2 tile $63 + ld de, FontExtra + $d0 + lb bc, BANK(FontExtra), 1 + call Request2bpp + hlcoord 0, 0 + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT + ld a, " " + call ByteFill + callba GetPlayerBackpic + ld a, $31 + ld [hFillBox], a + hlcoord 6, 6 + lb bc, 6, 6 + predef FillBox + ld a, $d0 + ld [hSCY], a + ld a, $90 + ld [hSCX], a + call WaitBGMap + xor a + ld [hBGMapMode], a + ld [CurPartySpecies], a + ld b, SCGB_1A + call GetSGBLayout + call SetPalettes + call Function86635 + xor a + ld [wc2c6], a + hlcoord 0, 0 + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT + ld a, " " + call ByteFill + callba Function88840 + xor a + ld [hFillBox], a + hlcoord 12, 5 + lb bc, 7, 7 + predef FillBox + ld a, $c0 + ld [hSCX], a + call WaitBGMap + xor a + ld [hBGMapMode], a + ld [hSCY], a + call Function86643 + xor a + ld [hBGMapMode], a + hlcoord 0, 2 + lb bc, 8, 9 + call TextBox + hlcoord 0, 12 + lb bc, 4, 18 + call TextBox + hlcoord 2, 4 + ld de, PlayerName + call PlaceString + hlcoord 1, 6 + ld a, $73 + ld [hli], a + ld a, $74 + ld [hli], a + ld [hl], $f3 + hlcoord 4, 6 + ld de, PlayerID + lb bc, PRINTNUM_LEADINGZEROS | 2, 5 + call PrintNum + hlcoord 1, 8 + ld de, .PlayTime + call PlaceString + hlcoord 3, 9 + ld de, GameTimeHours + lb bc, 2, 3 + call PrintNum + ld [hl], $63 + inc hl + ld de, GameTimeMinutes + lb bc, PRINTNUM_LEADINGZEROS | 1, 2 + call PrintNum + call WaitBGMap + callba Function26601 ret +; 868ed -Function8e94c: ; 8e94c (23:694c) - callba PlacePartymonHPBar - call GetHPPal - ld e, d - ld d, 0 - ld hl, Unknown_8e95e - add hl, de - ld b, [hl] - ret -; 8e95e (23:695e) +.PlayTime + db "PLAY TIME@" +; 868f7 -Unknown_8e95e: ; 8e95e - db $00, $40, $80 -; 8e961 -Function8e961: ; 8e961 (23:6961) - ld a, [wd265] - call ReadMonMenuIcon - ld [CurIcon], a - xor a - call GetIconGFX - lb de, $24, $20 - ld a, SPRITE_ANIM_INDEX_00 - call InitSpriteAnimStruct - ld hl, $2 - add hl, bc - ld [hl], $0 - ret +SECTION "bank22", ROMX, BANK[$22] -Function8e97d: ; 8e97d (23:697d) - ld a, [wd265] - call ReadMonMenuIcon - ld [CurIcon], a - xor a - call GetIconGFX - ld d, $1a - ld e, $24 - ld a, SPRITE_ANIM_INDEX_00 - call InitSpriteAnimStruct - ld hl, $2 - add hl, bc - ld [hl], $0 - ret +INCLUDE "event/kurt.asm" -Function8e99a: ; 8e99a (23:699a) - ld a, [wd265] - call ReadMonMenuIcon - ld [CurIcon], a - ld a, $62 - ld [wc3b7], a - call Function8e9db - ret +Function88248: ; 88248 + ld c, CAL + ld a, [PlayerGender] + bit 0, a + jr z, .okay + ld c, KAREN -GetSpeciesIcon: ; 8e9ac -; Load species icon into VRAM at tile a - push de - ld a, [wd265] - call ReadMonMenuIcon - ld [CurIcon], a - pop de - ld a, e - call GetIconGFX +.okay + ld a, c + ld [TrainerClass], a ret -; 8e9bc +; 88258 +MovePlayerPicRight: ; 88258 + hlcoord 6, 4 + ld de, 1 + jr MovePlayerPic -Function8e9bc: ; 8e9bc (23:69bc) - push de - ld a, [wd265] - call ReadMonMenuIcon - ld [CurIcon], a - pop de - ld a, e - call GetIcon_a - ret -; 8e9cc (23:69cc) +MovePlayerPicLeft: ; 88260 + hlcoord 13, 4 + ld de, -1 + ; fallthrough -Function8e9cc: ; 8e9cc +MovePlayerPic: ; 88266 +; Move player pic at hl by de * 7 tiles. + ld c, $8 +.loop + push bc + push hl push de - ld a, [wd265] - call ReadMonMenuIcon - ld [CurIcon], a + xor a + ld [hBGMapMode], a + lb bc, 7, 7 + predef FillBox + xor a + ld [hBGMapThird], a + call WaitBGMap + call DelayFrame pop de - call GetIcon_de + pop hl + add hl, de + pop bc + dec c + ret z + push hl + push bc + ld a, l + sub e + ld l, a + ld a, h + sbc d + ld h, a + lb bc, 7, 7 + call ClearBox + pop bc + pop hl + jr .loop +; 88297 + +ShowPlayerNamingChoices: ; 88297 + ld hl, ChrisNameMenuHeader + ld a, [PlayerGender] + bit 0, a + jr z, .GotGender + ld hl, KrisNameMenuHeader +.GotGender + call LoadMenuDataHeader + call InterpretMenu2 + ld a, [MenuSelection2] + dec a + call CopyNameFromMenu + call WriteBackup ret -; 8e9db +; 882b5 + +ChrisNameMenuHeader: ; 882b5 + db $40 ; flags + db 00, 00 ; start coords + db 11, 10 ; end coords + dw MenuData2_0x882be + db 1 ; ???? + db 0 ; default option +; 882be -Function8e9db: ; 8e9db (23:69db) - ld a, [wc3b7] +MenuData2_0x882be: ; 882be + db $91 ; flags + db 5 ; items + db "NEW NAME@" +Unknown_882c9: ; 882c9 + db "CHRIS@" + db "MAT@" + db "ALLAN@" + db "JON@" + db 2 ; displacement + db " NAME @" ; title +; 882e5 -GetIconGFX: ; 8e9de - call GetIcon_a - ld de, $80 ; 8 tiles - add hl, de - ld de, HeldItemIcons - lb bc, BANK(HeldItemIcons), 2 - call GetGFXUnlessMobile - ld a, [wc3b7] - add 10 - ld [wc3b7], a - ret +KrisNameMenuHeader: ; 882e5 + db $40 ; flags + db 00, 00 ; start coords + db 11, 10 ; end coords + dw MenuData2_0x882ee + db 1 ; ???? + db 0 ; default option +; 882ee -HeldItemIcons: -INCBIN "gfx/icon/mail.2bpp" -INCBIN "gfx/icon/item.2bpp" -; 8ea17 +MenuData2_0x882ee: ; 882ee + db $91 ; flags + db 5 ; items + db "NEW NAME@" +Unknown_882f9: ; 882f9 + db "KRIS@" + db "AMANDA@" + db "JUANA@" + db "JODI@" + db 2 ; displacement + db " NAME @" ; title +; 88318 -GetIcon_de: ; 8ea17 -; Load icon graphics into VRAM starting from tile de. - ld l, e - ld h, d - jr GetIcon +GetPlayerNameArray: ; 88318 This Function is never called + ld hl, PlayerName + ld de, Unknown_882c9 + ld a, [PlayerGender] + bit 0, a + jr z, .done + ld de, Unknown_882f9 -GetIcon_a: ; 8ea1b -; Load icon graphics into VRAM starting from tile a. - ld l, a - ld h, 0 +.done + call InitName + ret +; 8832c -GetIcon: ; 8ea1e -; Load icon graphics into VRAM starting from tile hl. +GetPlayerIcon: ; 8832c +; Get the player icon corresponding to gender -; One tile is 16 bytes long. -rept 4 - add hl, hl -endr +; Male + ld de, ChrisSpriteGFX + ld b, BANK(ChrisSpriteGFX) - ld de, VTiles0 - add hl, de - push hl + ld a, [PlayerGender] + bit 0, a + jr z, .done -; The icons are contiguous, in order and of the same -; size, so the pointer table is somewhat redundant. - ld a, [CurIcon] - push hl - ld l, a - ld h, 0 - add hl, hl - ld de, IconPointers - add hl, de - ld a, [hli] - ld e, a - ld d, [hl] - pop hl +; Female + ld de, KrisSpriteGFX + ld b, BANK(KrisSpriteGFX) - lb bc, BANK(Icons), 8 - call GetGFXUnlessMobile +.done + ret +; 8833e - pop hl +Function8833e: ; 8833e + ld hl, ChrisCardPic + ld a, [PlayerGender] + bit 0, a + jr z, .GotClass + ld hl, KrisCardPic +.GotClass + ld de, VTiles2 tile $00 + ld bc, $230 + ld a, BANK(ChrisCardPic) ; BANK(KrisCardPic) + call FarCopyBytes + ld hl, CardGFX + ld de, VTiles2 tile $23 + ld bc, $60 + ld a, BANK(CardGFX) + call FarCopyBytes ret -; 8ea3f +; 88365 (22:4365) -GetGFXUnlessMobile: ; 8ea3f - ld a, [wLinkMode] - cp LINK_MOBILE - jp nz, Request2bpp - jp Get2bpp_2 -; 8ea4a +ChrisCardPic: ; 88365 +INCBIN "gfx/misc/chris_card.5x7.2bpp" +; 88595 -Function8ea4a: ; 8ea4a - ld hl, wc314 - ld e, $6 - ld a, [MenuSelection2] - ld d, a -.loop - ld a, [hl] - and a - jr z, .next - cp d - jr z, .loadwithtwo - ld a, $0 - jr .ok +KrisCardPic: ; 88595 +INCBIN "gfx/misc/kris_card.5x7.2bpp" +; 887c5 -.loadwithtwo - ld a, $2 +CardGFX: ; 887c5 +INCBIN "gfx/misc/trainer_card.2bpp" +; 88825 -.ok - push hl - ld c, l - ld b, h - ld hl, $2 - add hl, bc - ld [hl], a - pop hl -.next - ld bc, $10 - add hl, bc - dec e - jr nz, .loop +GetPlayerBackpic: ; 88825 + ld a, [PlayerGender] + bit 0, a + jr z, GetChrisBackpic + call GetKrisBackpic ret -; 8ea71 -Function8ea71: ; 8ea71 - ld hl, wc314 - ld e, $6 -.loop - ld a, [hl] - and a - jr z, .zero - push hl - ld c, l - ld b, h - ld hl, $2 - add hl, bc - ld [hl], $1 - pop hl -.zero - ld bc, $10 - add hl, bc - dec e - jr nz, .loop +GetChrisBackpic: ; 88830 + ld hl, ChrisBackpic + ld b, BANK(ChrisBackpic) + ld de, VTiles2 tile $31 + ld c, 7 * 7 + predef DecompressPredef ret -; 8ea8c (23:6a8c) +; 88840 -Function8ea8c: ; 8ea8c - ld hl, wc314 - ld e, $6 - ld a, [wd0e3] - ld d, a -.asm_8ea95 - ld a, [hl] - and a - jr z, .asm_8eaab - cp d - jr z, .asm_8eaa0 - ld a, $3 - jr .asm_8eaa2 -.asm_8eaa0 - ld a, $2 -.asm_8eaa2 - push hl - ld c, l - ld b, h - ld hl, $2 - add hl, bc - ld [hl], a - pop hl -.asm_8eaab - ld bc, $10 - add hl, bc - dec e - jr nz, .asm_8ea95 +Function88840: ; 88840 + call WaitBGMap + xor a + ld [hBGMapMode], a + ld e, 0 + ld a, [PlayerGender] + bit 0, a + jr z, .GotClass + ld e, 1 + +.GotClass + ld a, e + ld [TrainerClass], a + ld de, ChrisPic + ld a, [PlayerGender] + bit 0, a + jr z, .GotPic + ld de, KrisPic + +.GotPic + ld hl, VTiles2 + ld b, BANK(ChrisPic) ; BANK(KrisPic) + ld c, 7 * 7 + call Get2bpp + call WaitBGMap + ld a, $1 + ld [hBGMapMode], a ret +; 88874 -INCLUDE "menu/mon_icons.asm" - -SECTION "bank24", ROMX, BANK[$24] +DrawIntroPlayerPic: ; 88874 +; Draw the player pic at (6,4). -INCLUDE "engine/phone.asm" +; Get class + ld e, 0 + ld a, [PlayerGender] + bit 0, a + jr z, .GotClass + ld e, 1 +.GotClass + ld a, e + ld [TrainerClass], a -InitClock: ; 90672 (24:4672) -; Ask the player to set the time. - ld a, [hInMenu] - push af - ld a, $1 - ld [hInMenu], a +; Load pic + ld de, ChrisPic + ld a, [PlayerGender] + bit 0, a + jr z, .GotPic + ld de, KrisPic +.GotPic + ld hl, VTiles2 + ld b, BANK(ChrisPic) ; BANK(KrisPic) + ld c, 7 * 7 ; dimensions + call Get2bpp - ld a, $0 - ld [wc2ce], a - ld a, $10 - ld [MusicFade], a - ld a, MUSIC_NONE % $100 - ld [MusicFadeIDLo], a - ld a, MUSIC_NONE / $100 - ld [MusicFadeIDHi], a - ld c, 8 - call DelayFrames - call Function4dd - call ClearTileMap - call ClearSprites - ld b, SCGB_08 - call GetSGBLayout - xor a - ld [hBGMapMode], a - call LoadStandardFont - ld de, GFX_908fb - ld hl, VTiles2 tile $00 - lb bc, BANK(GFX_908fb), 1 - call Request1bpp - ld de, GFX_90903 - ld hl, VTiles2 tile $01 - lb bc, BANK(GFX_90903), 1 - call Request1bpp - ld de, GFX_9090b - ld hl, VTiles2 tile $02 - lb bc, BANK(GFX_9090b), 1 - call Request1bpp - call .ClearScreen - call WaitBGMap - call Function4a3 - ld hl, UnknownText_0x90874 - call PrintText - ld hl, wc608 - ld bc, 50 +; Draw xor a - call ByteFill - ld a, $a - ld [wInitHourBuffer], a + ld [hFillBox], a + hlcoord 6, 4 + lb bc, 7, 7 + predef FillBox + ret +; 888a9 -.loop - ld hl, UnknownText_0x90879 - call PrintText - hlcoord 3, 7 - ld b, 2 - ld c, 15 - call TextBox - hlcoord 11, 7 - ld [hl], $1 - hlcoord 11, 10 - ld [hl], $2 - hlcoord 4, 9 - call DisplayHourOClock - ld c, 10 - call DelayFrames -.SetHourLoop - call JoyTextDelay - call SetHour - jr nc, .SetHourLoop +ChrisPic: ; 888a9 +INCBIN "gfx/misc/chris.7x7.2bpp" +; 88bb9 - ld a, [wInitHourBuffer] - ld [StringBuffer2 + 1], a - call .ClearScreen - ld hl, UnknownText_0x90886 - call PrintText - call YesNoBox - jr nc, .HourIsSet - call .ClearScreen - jr .loop +KrisPic: ; 88bb9 +INCBIN "gfx/misc/kris.7x7.2bpp" +; 88ec9 -.HourIsSet - ld hl, UnknownText_0x9089a - call PrintText - hlcoord 11, 7 - lb bc, 2, 7 - call TextBox - hlcoord 15, 7 - ld [hl], $1 - hlcoord 15, 10 - ld [hl], $2 - hlcoord 12, 9 - call DisplayMinutesWithMinString - ld c, 10 - call DelayFrames -.SetMinutesLoop - call JoyTextDelay - call SetMinutes - jr nc, .SetMinutesLoop +GetKrisBackpic: ; 88ec9 +; Kris's backpic is uncompressed. + ld de, KrisBackpic + ld hl, VTiles2 tile $31 + lb bc, BANK(KrisBackpic), 7 * 7 ; dimensions + call Get2bpp + ret +; 88ed6 - ld a, [BattleMonNick + 5] - ld [StringBuffer2 + 2], a - call .ClearScreen - ld hl, UnknownText_0x908a4 - call PrintText - call YesNoBox - jr nc, .MinutesAreSet - call .ClearScreen - jr .HourIsSet +KrisBackpic: ; 88ed6 +INCBIN "gfx/misc/kris_back.6x6.2bpp" +; 89116 -.MinutesAreSet - call Function658 - ld hl, OakText_ResponseToSetTime - call PrintText - call WaitPressAorB_BlinkCursor - pop af - ld [hInMenu], a - ret -.ClearScreen: ; 90783 (24:4783) - xor a - ld [hBGMapMode], a - hlcoord 0, 0 - ld bc, SCREEN_HEIGHT * SCREEN_WIDTH - xor a - call ByteFill - ld a, $1 - ld [hBGMapMode], a - ret +String_89116: + db "-----@" +; 8911c -SetHour: ; 90795 (24:4795) - ld a, [hJoyPressed] - and A_BUTTON - jr nz, .Confirm +INCLUDE "misc/mobile_22.asm" +INCLUDE "event/unown.asm" +INCLUDE "event/buena.asm" +INCLUDE "event/dratini.asm" +INCLUDE "event/battle_tower.asm" +INCLUDE "misc/mobile_22_2.asm" - ld hl, hJoyLast - ld a, [hl] - and D_UP - jr nz, .up - ld a, [hl] - and D_DOWN - jr nz, .down - call DelayFrame - and a + +SECTION "bank23", ROMX, BANK[$23] + +Predef35: ; 8c000 +Predef36: ret +; 8c001 -.down - ld hl, wInitHourBuffer - ld a, [hl] - and a - jr nz, .DecreaseThroughMidnight - ld a, 23 + 1 -.DecreaseThroughMidnight - dec a - ld [hl], a - jr .okay -.up - ld hl, wInitHourBuffer - ld a, [hl] - cp 23 - jr c, .AdvanceThroughMidnight - ld a, -1 -.AdvanceThroughMidnight - inc a - ld [hl], a +INCLUDE "engine/timeofdaypals.asm" +INCLUDE "engine/battle_start.asm" -.okay - hlcoord 4, 9 - ld a, " " - ld bc, 15 - call ByteFill - hlcoord 4, 9 - call DisplayHourOClock +Function8c7c9: ; unreferenced + ld a, $1 + ld [hBGMapMode], a call WaitBGMap - and a + xor a + ld [hBGMapMode], a ret +; 8c7d4 -.Confirm - scf +INCLUDE "event/field_moves.asm" + +Function8caed: ; 8caed + call DelayFrame + ld a, [VramState] + push af + xor a + ld [VramState], a + call Function8cb9b + lb de, $54, $50 + ld a, SPRITE_ANIM_INDEX_0A + call _InitSpriteAnimStruct + ld hl, $3 + add hl, bc + ld [hl], $84 + ld hl, $2 + add hl, bc + ld [hl], $16 + ld a, $80 + ld [wcf64], a +.asm_8cb14 + ld a, [wJumptableIndex] + bit 7, a + jr nz, .asm_8cb2e + ld a, $0 + ld [wc3b5], a + callab Function8cf7a + call Function8cbc8 + call DelayFrame + jr .asm_8cb14 +.asm_8cb2e + pop af + ld [VramState], a ret +; 8cb33 -DisplayHourOClock: ; 907de (24:47de) - push hl - ld a, [wInitHourBuffer] - ld c, a - ld e, l - ld d, h - call PrintHour - inc hl - ld de, String_oclock - call PlaceString - pop hl +Function8cb33: ; 8cb33 + call DelayFrame + ld a, [VramState] + push af + xor a + ld [VramState], a + call Function8cb9b + lb de, $fc, $50 + ld a, SPRITE_ANIM_INDEX_0A + call _InitSpriteAnimStruct + ld hl, $3 + add hl, bc + ld [hl], $84 + ld hl, $2 + add hl, bc + ld [hl], $18 + ld hl, $f + add hl, bc + ld [hl], $58 + ld a, $40 + ld [wcf64], a +.asm_8cb60 + ld a, [wJumptableIndex] + bit 7, a + jr nz, .asm_8cb7a + ld a, $0 + ld [wc3b5], a + callab Function8cf7a + call Function8cbc8 + call DelayFrame + jr .asm_8cb60 +.asm_8cb7a + pop af + ld [VramState], a + call Function8cb82 ret -; 907f1 (24:47f1) -Function907f1: ; 907f1 - ld h, d - ld l, e - push hl - call DisplayHourOClock - pop de -rept 2 - inc de -endr - ld a, $9c - ld [de], a - inc de - push de - ld hl, $3 - add hl, de - ld a, [de] - inc de +Function8cb82: ; 8cb82 (23:4b82) + ld hl, Sprites + 2 + xor a + ld c, $4 +.asm_8cb88 ld [hli], a - ld a, [de] - ld [hl], a - pop hl - call DisplayMinutesWithMinString rept 3 inc hl endr + inc a + dec c + jr nz, .asm_8cb88 + ld hl, Sprites + $10 + ld bc, $90 + xor a + call ByteFill ret -; 90810 -SetMinutes: ; 90810 (24:4810) - ld a, [hJoyPressed] - and A_BUTTON - jr nz, .asm_90857 - ld hl, hJoyLast - ld a, [hl] - and D_UP - jr nz, .asm_90835 +Function8cb9b: ; 8cb9b (23:4b9b) + callab Function8cf53 + ld de, CutGrassGFX + ld hl, VTiles1 tile $00 + lb bc, BANK(CutGrassGFX), 4 + call Request2bpp + ld a, [CurPartyMon] + ld hl, PartySpecies + ld e, a + ld d, 0 + add hl, de ld a, [hl] - and D_DOWN - jr nz, .asm_90828 - call DelayFrame - and a + ld [wd265], a + ld e, $84 + callba Function8e9bc + xor a + ld [wJumptableIndex], a ret -.asm_90828 - ld hl, BattleMonNick + 5 - ld a, [hl] - and a - jr nz, .asm_90831 - ld a, 59 + 1 -.asm_90831 - dec a - ld [hl], a - jr .asm_90841 -.asm_90835 - ld hl, BattleMonNick + 5 + +Function8cbc8: ; 8cbc8 (23:4bc8) + call Function8cbe6 + ld hl, wcf64 ld a, [hl] - cp 59 - jr c, .asm_9083f - ld a, -1 -.asm_9083f - inc a - ld [hl], a -.asm_90841 - hlcoord 12, 9 - ld a, " " - ld bc, 7 - call ByteFill - hlcoord 12, 9 - call DisplayMinutesWithMinString - call WaitBGMap and a + jr z, .asm_8cbe0 + dec [hl] + cp $40 + ret c + and $7 + ret nz + ld de, SFX_FLY + call PlaySFX ret -.asm_90857 - scf - ret - -DisplayMinutesWithMinString: ; 90859 (24:4859) - ld de, BattleMonNick + 5 - call PrintTwoDigitNumberRightAlign - inc hl - ld de, String_min - call PlaceString +.asm_8cbe0 + ld hl, wJumptableIndex + set 7, [hl] ret -PrintTwoDigitNumberRightAlign: ; 90867 (24:4867) - push hl - ld a, " " - ld [hli], a - ld [hl], a - pop hl - lb bc, PRINTNUM_RIGHTALIGN | 1, 2 - call PrintNum +Function8cbe6: ; 8cbe6 (23:4be6) + ld hl, wcf65 + ld a, [hl] + inc [hl] + and $7 + ret nz + ld a, [hl] + and $18 + sla a + add $40 + ld d, a + ld e, $0 + ld a, SPRITE_ANIM_INDEX_18 ; fly land + call _InitSpriteAnimStruct + ld hl, $3 + add hl, bc + ld [hl], $80 ret -; 90874 (24:4874) - -UnknownText_0x90874: ; 0x90874 - ; Zzz… Hm? Wha…? You woke me up! Will you check the clock for me? - text_jump UnknownText_0x1bc29c - db "@" -; 0x90879 - -UnknownText_0x90879: ; 0x90879 - ; What time is it? - text_jump UnknownText_0x1bc2eb - db "@" -; 0x9087e -String_oclock: - db "o'clock@" -; 90886 +INCLUDE "event/magnet_train.asm" -UnknownText_0x90886: ; 0x90886 - ; What?@ @ - text_jump UnknownText_0x1bc2fd - start_asm - hlcoord 1, 16 - call DisplayHourOClock - ld hl, UnknownText_0x90895 +Function8cf4f: ; 8cf4f + call Function3238 ret -; 90895 (24:4895) +; 8cf53 -UnknownText_0x90895: ; 0x90895 - ; ? - text_jump UnknownText_0x1bc305 - db "@" -; 0x9089a -UnknownText_0x9089a: ; 0x9089a - ; How many minutes? - text_jump UnknownText_0x1bc308 - db "@" -; 0x9089f +INCLUDE "engine/sprites.asm" -String_min: - db "min.@" -; 908a4 +Function8e79d: ; 8e79d + ld a, [hSGB] + ld de, GFX_8e7f4 + and a + jr z, .asm_8e7a8 + ld de, GFX_8e804 -UnknownText_0x908a4: ; 0x908a4 - ; Whoa!@ @ - text_jump UnknownText_0x1bc31b - start_asm -; 0x908a9 - hlcoord 7, 14 - call DisplayMinutesWithMinString - ld hl, UnknownText_0x908b3 +.asm_8e7a8 + ld hl, VTiles0 + lb bc, BANK(GFX_8e7f4), 1 + call Request2bpp + ld c, $8 + ld d, $0 +.asm_8e7b5 + push bc + call Function8e7c6 + call DelayFrame + pop bc +rept 2 + inc d +endr + dec c + jr nz, .asm_8e7b5 + call ClearSprites ret -; 908b3 (24:48b3) +; 8e7c6 -UnknownText_0x908b3: ; 0x908b3 - ; ? - text_jump UnknownText_0x1bc323 - db "@" -; 0x908b8 +Function8e7c6: ; 8e7c6 + ld hl, Sprites + ld c, $8 +.asm_8e7cb + ld a, c + and a + ret z + dec c + ld a, c + sla a + sla a + sla a + push af + push de + push hl + call Function8e72c + pop hl + pop de + add $68 + ld [hli], a + pop af + push de + push hl + call Function8e72a + pop hl + pop de + add $54 + ld [hli], a + ld a, $0 + ld [hli], a + ld a, $6 + ld [hli], a + jr .asm_8e7cb +; 8e7f4 -OakText_ResponseToSetTime: ; 0x908b8 - start_asm - decoord 1, 14 - ld a, [wInitHourBuffer] - ld c, a - call PrintHour - ld [hl], ":" +GFX_8e7f4: ; 8e7f4 +INCBIN "gfx/unknown/08e7f4.2bpp" +GFX_8e804: ; 8e804 +INCBIN "gfx/unknown/08e804.2bpp" + +InefficientlyClear121BytesAtwc300: ; 8e814 + push hl + push de + push bc + push af + ld hl, wc300 + ld bc, wc3c1 - wc300 +.loop + ld [hl], $0 inc hl - ld de, BattleMonNick + 5 - lb bc, PRINTNUM_LEADINGZEROS | 1, 2 - call PrintNum - ld b, h - ld c, l - ld a, [wInitHourBuffer] - cp 4 - jr c, .NITE - cp 11 - jr c, .MORN - cp 18 - jr c, .DAY -.NITE - ld hl, .sodark + dec bc + ld a, c + or b + jr nz, .loop + pop af + pop bc + pop de + pop hl ret -.MORN - ld hl, .overslept +; 8e82b + +Function8e82b: ; 8e82b + ld a, e + 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) + ld c, 8 ret -.DAY - ld hl, .yikes +; 8e83f + +Function8e83f: ; 8e83f + push hl + push de + push bc + call Function8e849 + pop bc + pop de + pop hl ret -; 908ec (24:48ec) +; 8e849 -.overslept: ; 0x908ec - ; ! I overslept! - text_jump UnknownText_0x1bc326 - db "@" -; 0x908f1 +Function8e849: ; 8e849 + ld d, 0 + ld hl, Jumptable_8e854 +rept 2 + add hl, de +endr + ld a, [hli] + ld h, [hl] + ld l, a + jp [hl] +; 8e854 + + +Jumptable_8e854: ; 8e854 (23:6854) + dw Function8e8d5 + dw Function8e961 + dw Function8e97d + dw Function8e99a + dw Function8e898 + dw Function8e8b1 + dw Function8e862 -.yikes: ; 0x908f1 - ; ! Yikes! I over- slept! - text_jump UnknownText_0x1bc336 - db "@" -; 0x908f6 -.sodark: ; 0x908f6 - ; ! No wonder it's so dark! - text_jump UnknownText_0x1bc34f - db "@" -; 0x908fb +Function8e862: ; 8e862 (23:6862) + call Function8e908 + call Function8e86c + call Function8e936 + ret -GFX_908fb: ; 908fb -INCBIN "gfx/unknown/0908fb.2bpp" -GFX_90903: ; 90903 -INCBIN "gfx/unknown/090903.2bpp" -GFX_9090b: ; 9090b -INCBIN "gfx/unknown/09090b.2bpp" -; 90913 +Function8e86c: ; 8e86c (23:686c) + push bc + ld a, [hObjectStructIndexBuffer] + ld hl, PartyMon1Item + ld bc, PARTYMON_STRUCT_LENGTH + call AddNTimes + pop bc + ld a, [hl] + and a + jr z, .asm_8e890 + push hl + push bc + ld d, a + callab ItemIsMail + pop bc + pop hl + jr c, .asm_8e88e + ld a, $6 + jr .asm_8e892 +.asm_8e88e + ld a, $5 +.asm_8e890 + ld a, $4 +.asm_8e892 + ld hl, $1 + add hl, bc + ld [hl], a + ret -Special_SetDayOfWeek: ; 90913 - ld a, [hInMenu] - push af - ld a, $1 - ld [hInMenu], a - ld de, GFX_90903 - ld hl, VTiles1 tile $6f - lb bc, BANK(GFX_90903), 1 - call Request1bpp - ld de, GFX_9090b - ld hl, VTiles1 tile $75 - lb bc, BANK(GFX_9090b), 1 - call Request1bpp - xor a - ld [wd002], a -.asm_90936 - hlcoord 0, 12 - lb bc, 4, 18 - call TextBox - call LoadStandardMenuDataHeader - ld hl, UnknownText_0x90a3f - call PrintText - hlcoord 9, 3 - ld b, 2 - ld c, 9 - call TextBox - hlcoord 14, 3 - ld [hl], $ef - hlcoord 14, 6 - ld [hl], $f5 - hlcoord 10, 5 - call Function909de - call Function321c - ld c, 10 - call DelayFrames -.asm_9096a - call JoyTextDelay - call Function90993 - jr nc, .asm_9096a - call ExitMenu - call UpdateSprites - ld hl, UnknownText_0x90a44 - call PrintText - call YesNoBox - jr c, .asm_90936 - ld a, [wd002] - ld [StringBuffer2], a - call Function663 - call LoadStandardFont - pop af - ld [hInMenu], a +Function8e898: ; 8e898 (23:6898) + call Function8e8d5 + ld hl, $2 + add hl, bc + ld a, $0 + ld [hl], a + ld hl, $4 + add hl, bc + ld a, $48 + ld [hl], a + ld hl, $5 + add hl, bc + ld a, $48 + ld [hl], a ret -; 90993 -Function90993: ; 90993 - ld a, [hJoyPressed] - and A_BUTTON - jr z, .asm_9099b - scf +Function8e8b1: ; 8e8b1 (23:68b1) + call Function8e908 + call Function8e936 + ld hl, $2 + add hl, bc + ld a, $0 + ld [hl], a + ld hl, $4 + add hl, bc + ld a, $18 + ld [hl], a + ld hl, $5 + add hl, bc + ld a, $60 + ld [hl], a + ld a, c + ld [wc608], a + ld a, b + ld [wc608 + 1], a ret -.asm_9099b - ld hl, hJoyLast - ld a, [hl] - and D_UP - jr nz, .asm_909ba - ld a, [hl] - and D_DOWN - jr nz, .asm_909ad - call DelayFrame - and a +Function8e8d5: ; 8e8d5 (23:68d5) + call Function8e908 + call Function8e8df + call Function8e936 ret -.asm_909ad - ld hl, wd002 +Function8e8df: ; 8e8df (23:68df) + push bc + ld a, [hObjectStructIndexBuffer] + ld hl, PartyMon1Item + ld bc, $30 + call AddNTimes + pop bc ld a, [hl] and a - jr nz, .asm_909b6 - ld a, 6 + 1 - -.asm_909b6 - dec a + ret z + push hl + push bc + ld d, a + callab ItemIsMail + pop bc + pop hl + jr c, .asm_8e900 + ld a, $3 + jr .asm_8e902 +.asm_8e900 + ld a, $2 +.asm_8e902 + ld hl, $1 + add hl, bc ld [hl], a - jr .asm_909c6 + ret -.asm_909ba - ld hl, wd002 +Function8e908: ; 8e908 (23:6908) + ld a, [wc3b7] + push af + ld a, [hObjectStructIndexBuffer] + ld hl, PartySpecies + ld e, a + ld d, $0 + add hl, de ld a, [hl] - cp 6 - jr c, .asm_909c4 - ld a, -1 - -.asm_909c4 - inc a + call ReadMonMenuIcon + ld [CurIcon], a + call Function8e9db + ld a, [hObjectStructIndexBuffer] +; y coord +rept 4 + add a +endr + add $1c + ld d, a +; x coord + ld e, $10 +; type is partymon icon + ld a, SPRITE_ANIM_INDEX_00 + call InitSpriteAnimStruct + pop af + ld hl, $3 + add hl, bc ld [hl], a + ret -.asm_909c6 - xor a - ld [hBGMapMode], a - hlcoord 10, 4 - ld b, $2 - ld c, $9 - call ClearBox - hlcoord 10, 5 - call Function909de - call WaitBGMap - and a +Function8e936: ; 8e936 (23:6936) + push bc + ld a, [hObjectStructIndexBuffer] + ld b, a + call Function8e94c + ld a, b + pop bc + ld hl, $9 + add hl, bc + ld [hl], a + rlca + rlca + ld hl, $d + add hl, bc + ld [hl], a ret -; 909de -Function909de: ; 909de - push hl - ld a, [wd002] - ld e, a +Function8e94c: ; 8e94c (23:694c) + callba PlacePartymonHPBar + call GetHPPal + ld e, d ld d, 0 - ld hl, WeekdaysStrings -rept 2 + ld hl, Unknown_8e95e add hl, de -endr - ld a, [hli] - ld d, [hl] - ld e, a - pop hl - call PlaceString + ld b, [hl] ret -; 909f2 - -WeekdaysStrings: ; 909f2 - dw Sunday - dw Monday - dw Tuesday - dw Wednesday - dw Thursday - dw Friday - dw Saturday - dw Sunday - -Sunday: db " SUNDAY@" -Monday: db " MONDAY@" -Tuesday: db " TUESDAY@" -Wednesday: db "WEDNESDAY@" -Thursday: db "THURSDAY@" -Friday: db " FRIDAY@" -Saturday: db "SATURDAY@" - - -UnknownText_0x90a3f: ; 0x90a3f - ; What day is it? - text_jump UnknownText_0x1bc369 - db "@" -; 0x90a44 +; 8e95e (23:695e) -UnknownText_0x90a44: ; 0x90a44 - start_asm - hlcoord 1, 14 - call Function909de - ld hl, UnknownText_0x90a4f +Unknown_8e95e: ; 8e95e + db $00, $40, $80 +; 8e961 + +Function8e961: ; 8e961 (23:6961) + ld a, [wd265] + call ReadMonMenuIcon + ld [CurIcon], a + xor a + call GetIconGFX + lb de, $24, $20 + ld a, SPRITE_ANIM_INDEX_00 + call InitSpriteAnimStruct + ld hl, $2 + add hl, bc + ld [hl], $0 ret -; 90a4f (24:4a4f) -UnknownText_0x90a4f: ; 0x90a4f - ; , is it? - text_jump UnknownText_0x1bc37a - db "@" -; 0x90a54 +Function8e97d: ; 8e97d (23:697d) + ld a, [wd265] + call ReadMonMenuIcon + ld [CurIcon], a + xor a + call GetIconGFX + ld d, $1a + ld e, $24 + ld a, SPRITE_ANIM_INDEX_00 + call InitSpriteAnimStruct + ld hl, $2 + add hl, bc + ld [hl], $0 + ret -Special_InitialSetDSTFlag: ; 90a54 - ld a, [wDST] - set 7, a - ld [wDST], a - hlcoord 1, 14 - lb bc, 3, 18 - call ClearBox - ld hl, UnknownText_0x90a6c - call PlaceWholeStringInBoxAtOnce +Function8e99a: ; 8e99a (23:699a) + ld a, [wd265] + call ReadMonMenuIcon + ld [CurIcon], a + ld a, $62 + ld [wc3b7], a + call Function8e9db ret -; 90a6c -UnknownText_0x90a6c: ; 90a6c - start_asm - call UpdateTime - ld a, [hHours] - ld b, a - ld a, [hMinutes] - ld c, a - decoord 1, 14 - callba PrintHoursMins - ld hl, TextJump_DSTIsThatOK +GetSpeciesIcon: ; 8e9ac +; Load species icon into VRAM at tile a + push de + ld a, [wd265] + call ReadMonMenuIcon + ld [CurIcon], a + pop de + ld a, e + call GetIconGFX ret -; 90a83 (24:4a83) +; 8e9bc -TextJump_DSTIsThatOK: ; 0x90a83 - ; DST, is that OK? - text_jump Text_DSTIsThatOK - db "@" -; 0x90a88 -Special_InitialClearDSTFlag: ; 90a88 - ld a, [wDST] - res 7, a - ld [wDST], a - hlcoord 1, 14 - lb bc, 3, 18 - call ClearBox - ld hl, UnknownText_0x90aa0 - call PlaceWholeStringInBoxAtOnce +Function8e9bc: ; 8e9bc (23:69bc) + push de + ld a, [wd265] + call ReadMonMenuIcon + ld [CurIcon], a + pop de + ld a, e + call GetIcon_a ret -; 90aa0 +; 8e9cc (23:69cc) -UnknownText_0x90aa0: ; 90aa0 - start_asm - call UpdateTime - ld a, [hHours] - ld b, a - ld a, [hMinutes] - ld c, a - decoord 1, 14 - callba PrintHoursMins - ld hl, UnknownText_0x90ab7 +Function8e9cc: ; 8e9cc + push de + ld a, [wd265] + call ReadMonMenuIcon + ld [CurIcon], a + pop de + call GetIcon_de ret -; 90ab7 +; 8e9db -UnknownText_0x90ab7: ; 0x90ab7 - ; , is that OK? - text_jump UnknownText_0x1c5ff1 - db "@" -; 0x90abc +Function8e9db: ; 8e9db (23:69db) + ld a, [wc3b7] -Function90abc: ; 90abc - hlcoord 1, 14 - lb bc, 3, SCREEN_WIDTH - 2 - call ClearBox - ld hl, UnknownText_0x90acc - call PlaceWholeStringInBoxAtOnce +GetIconGFX: ; 8e9de + call GetIcon_a + ld de, $80 ; 8 tiles + add hl, de + ld de, HeldItemIcons + lb bc, BANK(HeldItemIcons), 2 + call GetGFXUnlessMobile + ld a, [wc3b7] + add 10 + ld [wc3b7], a ret -; 90acc -UnknownText_0x90acc: ; 0x90acc - start_asm +HeldItemIcons: +INCBIN "gfx/icon/mail.2bpp" +INCBIN "gfx/icon/item.2bpp" +; 8ea17 - call UpdateTime +GetIcon_de: ; 8ea17 +; Load icon graphics into VRAM starting from tile de. + ld l, e + ld h, d + jr GetIcon - hlcoord 1, 14 - ld [hl], "R" - inc hl - ld [hl], "T" - inc hl - ld [hl], " " - inc hl +GetIcon_a: ; 8ea1b +; Load icon graphics into VRAM starting from tile a. + ld l, a + ld h, 0 - ld de, hRTCDayLo - call Function90b23 +GetIcon: ; 8ea1e +; Load icon graphics into VRAM starting from tile hl. - hlcoord 1, 16 - ld [hl], "D" - inc hl - ld [hl], "F" - inc hl - ld [hl], " " - inc hl +; One tile is 16 bytes long. +rept 4 + add hl, hl +endr - ld de, StartDay - call Function90b23 + ld de, VTiles0 + add hl, de + push hl - ld [hl], " " - inc hl +; The icons are contiguous, in order and of the same +; size, so the pointer table is somewhat redundant. + ld a, [CurIcon] + push hl + ld l, a + ld h, 0 + add hl, hl + ld de, IconPointers + add hl, de + ld a, [hli] + ld e, a + ld d, [hl] + pop hl - ld a, [wDST] - bit 7, a - jr z, .off + lb bc, BANK(Icons), 8 + call GetGFXUnlessMobile - ld [hl], "O" - inc hl - ld [hl], "N" - inc hl - jr .done + pop hl + ret +; 8ea3f -.off - ld [hl], "O" - inc hl - ld [hl], "F" - inc hl - ld [hl], "F" - inc hl +GetGFXUnlessMobile: ; 8ea3f + ld a, [wLinkMode] + cp LINK_MOBILE + jp nz, Request2bpp + jp Get2bpp_2 +; 8ea4a -.done - ld hl, UnknownText_0x90b13 - ret -; 90b13 +Function8ea4a: ; 8ea4a + ld hl, wc314 + ld e, $6 + ld a, [MenuSelection2] + ld d, a +.loop + ld a, [hl] + and a + jr z, .next + cp d + jr z, .loadwithtwo + ld a, $0 + jr .ok -UnknownText_0x90b13: ; 0x90b13 - text "Now on DEBUG…" - prompt -; 0x90b23 +.loadwithtwo + ld a, $2 -Function90b23: ; 90b23 - lb bc, 1, 3 - call PrintNum - ld [hl], "." - inc hl - inc de - lb bc, PRINTNUM_LEADINGZEROS | 1, 2 - call PrintNum - ld [hl], ":" - inc hl - inc de - lb bc, PRINTNUM_LEADINGZEROS | 1, 2 - call PrintNum - ret -; 90b3e +.ok + push hl + ld c, l + ld b, h + ld hl, $2 + add hl, bc + ld [hl], a + pop hl -PrintHour: ; 90b3e (24:4b3e) - ld l, e - ld h, d - push bc - call GetTimeOfDayString - call PlaceString - ld l, c - ld h, b - inc hl - pop bc - call AdjustHourForAMorPM - ld [wd265], a - ld de, wd265 - call PrintTwoDigitNumberRightAlign +.next + ld bc, $10 + add hl, bc + dec e + jr nz, .loop ret +; 8ea71 -GetTimeOfDayString: ; 90b58 (24:4b58) - ld a, c - cp 4 - jr c, .nite - cp 10 - jr c, .morn - cp 18 - jr c, .day -.nite - ld de, .NITE - ret -.morn - ld de, .MORN +Function8ea71: ; 8ea71 + ld hl, wc314 + ld e, $6 +.loop + ld a, [hl] + and a + jr z, .zero + push hl + ld c, l + ld b, h + ld hl, $2 + add hl, bc + ld [hl], $1 + pop hl +.zero + ld bc, $10 + add hl, bc + dec e + jr nz, .loop ret -.day - ld de, .DAY +; 8ea8c (23:6a8c) + +Function8ea8c: ; 8ea8c + ld hl, wc314 + ld e, $6 + ld a, [wd0e3] + ld d, a +.asm_8ea95 + ld a, [hl] + and a + jr z, .asm_8eaab + cp d + jr z, .asm_8eaa0 + ld a, $3 + jr .asm_8eaa2 +.asm_8eaa0 + ld a, $2 +.asm_8eaa2 + push hl + ld c, l + ld b, h + ld hl, $2 + add hl, bc + ld [hl], a + pop hl +.asm_8eaab + ld bc, $10 + add hl, bc + dec e + jr nz, .asm_8ea95 ret -; 90b71 (24:4b71) -.NITE: db "NITE@" -.MORN: db "MORN@" -.DAY: db "DAY@" -; 90b7f -AdjustHourForAMorPM: -; Convert the hour stored in c (0-23) to a 1-12 value - ld a, c - or a - jr z, .midnight - cp 12 - ret c - ret z - sub 12 - ret +INCLUDE "menu/mon_icons.asm" -.midnight - ld a, 12 - ret +SECTION "bank24", ROMX, BANK[$24] + +INCLUDE "engine/phone.asm" +INCLUDE "engine/timeset.asm" INCLUDE "engine/pokegear.asm" INCLUDE "data/wild/fish.asm" diff --git a/wram.asm b/wram.asm index 72536ab76..f8a9f1406 100644 --- a/wram.asm +++ b/wram.asm @@ -2402,7 +2402,7 @@ RegisteredItem:: ; d95c PlayerState:: ; d95d ds 1 -wd95e:: ds 2 +wHallOfFameCount:: ds 2 wd960:: ds 2 MooMooBerries:: ; d962 ds 1 ; how many berries fed to MooMoo -- cgit v1.2.3