From c9a3048c33b59e25775e90bb707630ddbf978f71 Mon Sep 17 00:00:00 2001 From: pikalaxalt Date: Sun, 5 Jun 2016 15:18:40 -0400 Subject: Split bank 3e --- wram.asm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'wram.asm') diff --git a/wram.asm b/wram.asm index be995089..541397d1 100755 --- a/wram.asm +++ b/wram.asm @@ -408,7 +408,7 @@ wc634:: ; c634 ds 1 wc635:: ; c635 ds 1 -wc636:: ; c636 +wYellowIntroAnimatedObjectStructPointer:: ; c636 ds 2 ; c638 @@ -426,7 +426,9 @@ wc700:: ; c700 wc710:: ; c710 ds $f0 wc800:: ; c800 - ds $178 + ds $10 +wc810:: ; c810 + ds $168 wPrinterTileBuffer:: ; c978 ds SCREEN_HEIGHT * SCREEN_WIDTH -- cgit v1.3.1-sl0p From ea4e4353ca8d0eba6f3bb66bb2be370e0e854f2d Mon Sep 17 00:00:00 2001 From: pikalaxalt Date: Sun, 5 Jun 2016 16:57:54 -0400 Subject: Resolve hardcoded WRAM labels in engine/printer.asm --- engine/palettes.asm | 50 +++--- engine/pikachu_pic_animation.asm | 2 +- engine/printer.asm | 303 +++++++++++++++++----------------- engine/surfing_minigame.asm | 11 +- engine/yellow_intro.asm | 345 ++++++++++++++++++++------------------- wram.asm | 120 ++++++++++---- 6 files changed, 455 insertions(+), 376 deletions(-) mode change 100755 => 100644 engine/printer.asm (limited to 'wram.asm') diff --git a/engine/palettes.asm b/engine/palettes.asm index f5a3ed49..636e5e97 100755 --- a/engine/palettes.asm +++ b/engine/palettes.asm @@ -164,9 +164,9 @@ SetPal_Overworld: ; 71fa5 (1c:5fa5) cp BRUNOS_ROOM jr z, .caveOrBruno cp TRADE_CENTER - jr z, .asm_71ffd + jr z, .trade_center_colosseum cp COLOSSEUM - jr z, .asm_71ffd + jr z, .trade_center_colosseum .normalDungeonOrBuilding ld a, [wLastMap] ; town or route that current dungeon or building is located .townOrRoute @@ -181,17 +181,21 @@ SetPal_Overworld: ; 71fa5 (1c:5fa5) ld a, SET_PAL_OVERWORLD ld [wDefaultPaletteCommand], a ret + .PokemonTowerOrAgatha ld a, PAL_GREYMON - 1 jr .town + .caveOrBruno ld a, PAL_CAVE - 1 jr .town + .Lorelei xor a jr .town -.asm_71ffd - ld a, $18 + +.trade_center_colosseum + ld a, PAL_GREYMON - 1 jr .town ; used when a Pokemon is the only thing on the screen @@ -313,17 +317,17 @@ DeterminePaletteIDOutOfBattle: ; 72094 (1c:6094) ld a, [hl] ret -Func_720ad:: ; 720ad (1c:60ad) +YellowIntroPaletteAction:: ; 720ad (1c:60ad) ld a, e and a - jr nz, Func_720bd + jr nz, .asm_720bd ld hl, PalPacket_Generic ld a, [hGBC] and a jp z, SendSGBPacket jp InitGBCPalettes -Func_720bd:: ; 720bd (1c:60bd) +.asm_720bd ld hl, UnknownPalPacket_72811 ld a, [hGBC] and a @@ -343,12 +347,12 @@ Func_720bd:: ; 720bd (1c:60bd) call TransferCurBGPData ret -Func_720e3:: ; 720e3 (1c:60e3) +LoadOverworldPikachuFrontpicPalettes:: ; 720e3 (1c:60e3) ld hl, PalPacket_Empty ld de, wPalPacket ld bc, $10 call CopyData - call Func_7213b + call GetPal_Pikachu ld hl, wPartyMenuBlkPacket ld [hl], a ld hl, wPartyMenuBlkPacket + 2 @@ -357,12 +361,13 @@ Func_720e3:: ; 720e3 (1c:60e3) ld hl, wPalPacket ld a, [hGBC] and a - jr nz, .asm_72109 + jr nz, .cgb_1 call SendSGBPacket - jr .asm_7210c -.asm_72109 + jr .okay_1 + +.cgb_1 call InitGBCPalettes -.asm_7210c +.okay_1 ld hl, BlkPacket_WholeScreen ld de, wPalPacket ld bc, $10 @@ -381,15 +386,16 @@ Func_720e3:: ; 720e3 (1c:60e3) ld hl, wPalPacket ld a, [hGBC] and a - jr nz, .asm_72137 + jr nz, .cgb_2 call SendSGBPacket - jr .asm_7213a -.asm_72137 + jr .okay_2 + +.cgb_2 call InitGBCPalettes -.asm_7213a +.okay_2 ret -Func_7213b:: ; 7213b (1c:613b) +GetPal_Pikachu:: ; 7213b (1c:613b) ; similar to SetPal_Overworld ld a, [wCurMapTileset] cp CEMETERY @@ -420,17 +426,21 @@ Func_7213b:: ; 7213b (1c:613b) .town inc a ; a town's pallete ID is its map ID + 1 ret + .PokemonTowerOrAgatha ld a, PAL_GREYMON - 1 jr .town + .caveOrBruno ld a, PAL_CAVE - 1 jr .town + .Lorelei - xor a + xor a ; PAL_PALLET - 1 jr .town + .battleOrTradeCenter - ld a, $18 + ld a, PAL_GREYMON - 1 jr .town InitPartyMenuBlkPacket: ; 7217f (1c:617f) diff --git a/engine/pikachu_pic_animation.asm b/engine/pikachu_pic_animation.asm index bfac6962..38045a05 100755 --- a/engine/pikachu_pic_animation.asm +++ b/engine/pikachu_pic_animation.asm @@ -1774,7 +1774,7 @@ StarterPikachuEmotionCommand_5: ; fd9d0 (3f:59d0) Func_fd9e4: call Func_fda2c - callab Func_720e3 + callab LoadOverworldPikachuFrontpicPalettes call Func_fd9ff call LoadCurrentPikaPicAnimScriptPointer call Func_fda9a diff --git a/engine/printer.asm b/engine/printer.asm old mode 100755 new mode 100644 index d2e5c6e3..51a5c9ed --- a/engine/printer.asm +++ b/engine/printer.asm @@ -13,9 +13,9 @@ Func_e8785: ld hl, wUnknownSerialFlag_d49a set 0, [hl] ld a, [wd498] - ld [$cae3], a + ld [wcae3], a pop af - ld [$caf4], a + ld [wcaf4], a ret ; e87a8 @@ -65,7 +65,7 @@ Func_e87e4: Func_e87e9: xor a - ld [$c971], a + ld [wc971], a ld hl, wOverworldMap set 7, [hl] ret @@ -84,19 +84,19 @@ Func_e87fd: ld hl, Data_e8a3a call Func_e8968 xor a - ld [$c976], a - ld [$c977], a - ld a, [$caf4] - ld [$c6e9], a + ld [wc976], a + ld [wc977], a + ld a, [wcaf4] + ld [wc6e9], a call Func_e87df call Func_e8949 ld a, $01 - ld [$cae0], a + ld [wPrinterStatusIndicator], a ret Func_e881f: call Func_e8981 - ld hl, $c6e9 + ld hl, wc6e9 ld a, [hl] and a jr z, Func_e884b @@ -104,14 +104,14 @@ Func_e881f: call Func_e8968 call Func_e89e6 ld a, $80 - ld [$c976], a + ld [wc976], a ld a, $02 - ld [$c977], a + ld [wc977], a call Func_e899f call Func_e87df call Func_e8949 ld a, $02 - ld [$cae0], a + ld [wPrinterStatusIndicator], a ret Func_e884b: @@ -120,8 +120,8 @@ Func_e884b: ld hl, Data_e8a4c call Func_e8968 xor a - ld [$c976], a - ld [$c977], a + ld [wc976], a + ld [wc977], a call Func_e87df call Func_e8949 ret @@ -132,14 +132,14 @@ Func_e8864: call Func_e8968 call Func_e89cf ld a, $04 - ld [$c976], a + ld [wc976], a ld a, $00 - ld [$c977], a + ld [wc977], a call Func_e899f call Func_e87df call Func_e8949 ld a, $03 - ld [$cae0], a + ld [wPrinterStatusIndicator], a ret Func_e8889: @@ -147,16 +147,16 @@ Func_e8889: ld hl, Data_e8a3a call Func_e8968 xor a - ld [$c976], a - ld [$c977], a - ld a, [$caf4] - ld [$c6e9], a + ld [wc976], a + ld [wc977], a + ld a, [wcaf4] + ld [wc6e9], a call Func_e87df call Func_e8949 ret Func_e88a6: - ld hl, $c973 + ld hl, wc973 inc [hl] ld a, [hl] cp a, $06 @@ -167,14 +167,14 @@ Func_e88a6: ret Func_e88b4: - ld hl, $c973 + ld hl, wc973 inc [hl] ld a, [hl] cp a, $06 ret c xor a ld [hl], a - ld hl, $c6e9 + ld hl, wc6e9 dec [hl] call Func_e87e4 call Func_e87e4 @@ -184,30 +184,30 @@ Func_e88c9: ld a, [wUnknownSerialFlag_d49b] and a ret nz - ld a, [$c970] + ld a, [wc970] cp a, $ff jr nz, .asm_e88dc - ld a, [$c971] + ld a, [wc971] cp a, $ff jr z, .asm_e88f8 .asm_e88dc - ld a, [$c970] + ld a, [wc970] cp a, $81 jr nz, .asm_e88f8 - ld a, [$c971] + ld a, [wc971] cp a, $00 jr nz, .asm_e88f8 ld hl, wUnknownSerialFlag_d49a set 1, [hl] ld a, $05 - ld [$c972], a + ld [wc972], a call Func_e87df ret .asm_e88f8 ld a, $ff - ld [$c970], a - ld [$c971], a + ld [wc970], a + ld [wc971], a ld a, $0e ld [wOverworldMap], a ret @@ -216,10 +216,10 @@ Func_e8906: ld a, [wUnknownSerialFlag_d49b] and a ret nz - ld a, [$c971] + ld a, [wc971] and a, $f0 jr nz, .asm_e8921 - ld a, [$c971] + ld a, [wc971] and a, $01 jr nz, .asm_e891d call Func_e87df @@ -238,7 +238,7 @@ Func_e8927: ld a, [wUnknownSerialFlag_d49b] and a ret nz - ld a, [$c971] + ld a, [wc971] and a, $f3 ret nz call Func_e87df @@ -250,7 +250,7 @@ Func_e8939: ld a, [wUnknownSerialFlag_d49b] and a ret nz - ld a, [$c971] + ld a, [wc971] and a, $f0 ret nz xor a @@ -263,8 +263,8 @@ Func_e8949: and a jr nz, .asm_e8949 xor a - ld [$c974], a - ld [$c975], a + ld [wc974], a + ld [wc975], a ld a, $01 ld [wUnknownSerialFlag_d49b], a ld a, $88 @@ -277,33 +277,33 @@ Func_e8949: Func_e8968: ld a, [hli] - ld [$c6ea], a + ld [wc6ea], a ld a, [hli] - ld [$c6eb], a + ld [wc6eb], a ld a, [hli] - ld [$c6ec], a + ld [wc6ec], a ld a, [hli] - ld [$c6ed], a + ld [wc6ed], a ld a, [hli] - ld [$c6ee], a + ld [wc6ee], a ld a, [hl] - ld [$c6ef], a + ld [wc6ef], a ret Func_e8981: xor a - ld hl, $c6ea + ld hl, wc6ea ld [hli], a ld [hli], a ld [hli], a ld [hl], a - ld hl, $c6ee + ld hl, wc6ee ld [hli], a ld [hl], a xor a - ld [$c976], a - ld [$c977], a - ld hl, $c6f0 + ld [wc976], a + ld [wc977], a + ld hl, wc6f0 ld bc, $0280 call Func_e8a2e ret @@ -311,18 +311,18 @@ Func_e8981: Func_e899f: ld hl, $0000 ld bc, $0004 - ld de, $c6ea + ld de, wc6ea call Func_e89c2 - ld a, [$c976] + ld a, [wc976] ld c, a - ld a, [$c977] + ld a, [wc977] ld b, a - ld de, $c6f0 + ld de, wc6f0 call Func_e89c2 ld a, l - ld [$c6ee], a + ld [wc6ee], a ld a, h - ld [$c6ef], a + ld [wc6ef], a ret Func_e89c2: @@ -342,19 +342,19 @@ Func_e89c2: Func_e89cf: ld a, $01 - ld [$c6f0], a - ld a, [$cae2] - ld [$c6f1], a + ld [wc6f0], a + ld a, [wcae2] + ld [wc6f1], a ld a, $e4 - ld [$c6f2], a - ld a, [$cae3] - ld [$c6f3], a + ld [wc6f2], a + ld a, [wcae3] + ld [wc6f3], a ret Func_e89e6: - ld a, [$c6e9] + ld a, [wc6e9] ld b, a - ld a, [$caf4] + ld a, [wcaf4] sub b ld hl, wPrinterTileBuffer ld de, $0028 @@ -368,7 +368,7 @@ Func_e89e6: .asm_e89fb ld e, l ld d, h - ld hl, $c6f0 + ld hl, wc6f0 ld c, $28 .asm_e8a02 ld a, [de] @@ -492,31 +492,31 @@ Func_e8ab3: ret Func_e8abc: - ld a, [$c6ea] + ld a, [wc6ea] call Func_e8b5f call Func_e8aad ret Func_e8ac6: - ld a, [$c6eb] + ld a, [wc6eb] call Func_e8b5f call Func_e8aad ret Func_e8ad0: - ld a, [$c6ec] + ld a, [wc6ec] call Func_e8b5f call Func_e8aad ret Func_e8ada: - ld a, [$c6ed] + ld a, [wc6ed] call Func_e8b5f call Func_e8aad ret Func_e8ae4: - ld hl, $c976 + ld hl, wc976 ld e, [hl] inc hl ld d, [hl] @@ -527,17 +527,17 @@ Func_e8ae4: ld [hl], d dec hl ld [hl], e - ld a, [$c974] + ld a, [wc974] ld e, a - ld a, [$c975] + ld a, [wc975] ld d, a - ld hl, $c6f0 + ld hl, wc6f0 add hl, de inc de ld a, e - ld [$c974], a + ld [wc974], a ld a, d - ld [$c975], a + ld [wc975], a ld a, [hl] call Func_e8b5f ret @@ -545,13 +545,13 @@ Func_e8ae4: .asm_e8b0c call Func_e8aad Func_e8b0f: - ld a, [$c6ee] + ld a, [wc6ee] call Func_e8b5f call Func_e8aad ret Func_e8b19: - ld a, [$c6ef] + ld a, [wc6ef] call Func_e8b5f call Func_e8aad ret @@ -564,7 +564,7 @@ Func_e8b23: Func_e8b2c: ld a, [rSB] - ld [$c970], a + ld [wc970], a ld a, $00 call Func_e8b5f call Func_e8aad @@ -572,7 +572,7 @@ Func_e8b2c: Func_e8b3a: ld a, [rSB] - ld [$c971], a + ld [wc971], a xor a ld [wUnknownSerialFlag_d49b], a ret @@ -605,16 +605,16 @@ Func_e8b5f: Func_e8b6a: ld a, [rSB] - ld [$c971], a + ld [wc971], a xor a ld [wUnknownSerialFlag_d49b], a ret Func_e8b74: ; e8b74 (3a:4b74) - ld a, [$cfca] + ld a, [wUpdateSpritesEnabled] push af xor a - ld [$cfca], a + ld [wUpdateSpritesEnabled], a ld [$ffdb], a call Func_e8f24 ld a, [rIE] @@ -627,7 +627,7 @@ Func_e8b74: ; e8b74 (3a:4b74) ld [$ffba], a call Func_e8c30 call Func_e8785 - ld a, [$caf9] + ld a, [wcaf9] and a jr z, .asm_e8b9e ld a, $10 @@ -636,7 +636,7 @@ Func_e8b74: ; e8b74 (3a:4b74) .asm_e8b9e ld a, $13 .asm_e8ba0 - ld [$cae2], a + ld [wcae2], a call Func_e8efc call ClearScreen callab Func_401c2 @@ -645,7 +645,7 @@ Func_e8b74: ; e8b74 (3a:4b74) ld [$ffba], a call Func_e8c0c jr c, .asm_e8bf4 - ld a, [$caf9] + ld a, [wcaf9] and a jr z, .asm_e8bf4 xor a @@ -660,7 +660,7 @@ Func_e8b74: ; e8b74 (3a:4b74) ld a, $07 call Func_e8785 ld a, $03 - ld [$cae2], a + ld [wcae2], a call Func_e8efc call LoadScreenTilesFromBuffer1 ld a, $01 @@ -677,7 +677,7 @@ Func_e8b74: ; e8b74 (3a:4b74) call Func_0f3d call Func_e8f3b pop af - ld [$cfca], a + ld [wUpdateSpritesEnabled], a ret Func_e8c0c: @@ -686,12 +686,12 @@ Func_e8c0c: call JoypadLowSensitivity call Func_e8eca jr c, .asm_e8c2e - ld a, [$c6e8] + ld a, [wc6e8] bit 7, a jr nz, .asm_e8c2c call Func_e87a8 - call Func_e8f51 - call Func_e8f82 + call GBPrinter_CheckForErrors + call GBPrinter_UpdateStatusMessage call DelayFrame jr .asm_e8c0f @@ -706,12 +706,12 @@ Func_e8c0c: Func_e8c30: callab Func_4039c ld a, l - ld [$caf5], a + ld [wcaf5], a ld a, h - ld [$caf6], a + ld [wcaf6], a ld a, $00 - rla - ld [$caf9], a + rla ; copy carry flag state to bit 0 + ld [wcaf9], a and a jr z, .asm_e8c4d ld a, $05 @@ -740,19 +740,19 @@ Func_e8c5c: ld [rIE], a call Func_e8783 ld a, $13 - ld [$cae2], a + ld [wcae2], a call Func_e8efc call Func_e8f16 .asm_e8c7d call JoypadLowSensitivity call Func_e8eca jr c, .asm_e8c9a - ld a, [$c6e8] + ld a, [wc6e8] bit 7, a jr nz, .asm_e8c9a call Func_e87a8 - call Func_e8f51 - call Func_e8f82 + call GBPrinter_CheckForErrors + call GBPrinter_UpdateStatusMessage call DelayFrame jr .asm_e8c7d @@ -782,7 +782,7 @@ Func_e8cb1: ld [rIE], a call Func_e8783 ld a, $10 - ld [$cae2], a + ld [wcae2], a call Func_e8efc call Func_e8d11 jr c, .asm_e8cfa @@ -797,7 +797,7 @@ Func_e8cb1: call Func_e9ad3 call Func_e8783 ld a, $03 - ld [$cae2], a + ld [wcae2], a call Func_e8efc call LoadScreenTilesFromBuffer1 call Func_e8d11 @@ -820,12 +820,12 @@ Func_e8d11: call JoypadLowSensitivity call Func_e8eca jr c, .asm_e8d33 - ld a, [$c6e8] + ld a, [wc6e8] bit 7, a jr nz, .asm_e8d31 call Func_e87a8 - call Func_e8f51 - call Func_e8f82 + call GBPrinter_CheckForErrors + call GBPrinter_UpdateStatusMessage call DelayFrame jr .asm_e8d14 @@ -861,7 +861,7 @@ Func_e8d35:: ; e8d35 (3a:4e79) call Func_e988a call Func_e8783 ld a, $10 - ld [$cae2], a + ld [wcae2], a call Func_e8efc call LoadScreenTilesFromBuffer1 call Func_e8dfb @@ -876,7 +876,7 @@ Func_e8d35:: ; e8d35 (3a:4e79) call Func_e98ec call Func_e8783 ld a, $00 - ld [$cae2], a + ld [wcae2], a call Func_e8efc call LoadScreenTilesFromBuffer1 call Func_e8dfb @@ -891,7 +891,7 @@ Func_e8d35:: ; e8d35 (3a:4e79) call Func_e9907 call Func_e8783 ld a, $00 - ld [$cae2], a + ld [wcae2], a call Func_e8efc call LoadScreenTilesFromBuffer1 call Func_e8dfb @@ -906,7 +906,7 @@ Func_e8d35:: ; e8d35 (3a:4e79) call Func_e9922 call Func_e8783 ld a, $03 - ld [$cae2], a + ld [wcae2], a call Func_e8efc call LoadScreenTilesFromBuffer1 call Func_e8dfb @@ -939,8 +939,8 @@ Func_e8dfb: ; e8dfb bit 7, a jr nz, .asm_e8e1b call Func_e87a8 - call Func_e8f51 - call Func_e8f82 + call GBPrinter_CheckForErrors + call GBPrinter_UpdateStatusMessage call DelayFrame jr .asm_e8dfe @@ -969,7 +969,7 @@ Func_e8e24: ; e8e24 ld [rIE], a call Func_e8783 ld a, $13 - ld [$cae2], a + ld [wcae2], a call Func_e8efc call Func_e8f16 .asm_e8e45 @@ -980,8 +980,8 @@ Func_e8e24: ; e8e24 bit 7, a jr nz, .asm_e8e62 call Func_e87a8 - call Func_e8f51 - call Func_e8f82 + call GBPrinter_CheckForErrors + call GBPrinter_UpdateStatusMessage call DelayFrame jr .asm_e8e45 @@ -1012,7 +1012,7 @@ Func_e8e79: ; e8e79 (3a:4e79) ld [rIE], a call Func_e8783 ld a, $13 - ld [$cae2], a + ld [wcae2], a ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a call Func_e8efc @@ -1127,43 +1127,44 @@ Func_e8f42: ; e8f42 (3a:4f42) jr nz, .asm_e8f4a ret -Func_e8f51: ; e8f51 (3a:4f51) - ld a, [$c970] +GBPrinter_CheckForErrors: ; e8f51 (3a:4f51) + ld a, [wc970] cp $81 - jr z, .asm_e8f62 - ld a, [$c971] + jr z, .check_other_errors + ld a, [wc971] cp $ff - jr z, .asm_e8f7c + jr z, .error2 xor a - jr .asm_e8f7e + jr .load_status -.asm_e8f62 - ld a, [$c971] +.check_other_errors + ld a, [wc971] and $e0 ret z bit 7, a - jr nz, .asm_e8f78 + jr nz, .error1 bit 6, a - jr nz, .asm_e8f74 + jr nz, .error4 + ; error 3 ld a, 6 - jr .asm_e8f7e + jr .load_status -.asm_e8f74 +.error4 ld a, 7 - jr .asm_e8f7e + jr .load_status -.asm_e8f78 +.error1 ld a, 4 - jr .asm_e8f7e + jr .load_status -.asm_e8f7c +.error2 ld a, 5 -.asm_e8f7e - ld [wcae0], a +.load_status + ld [wPrinterStatusIndicator], a ret -Func_e8f82: - ld a, [wcae0] +GBPrinter_UpdateStatusMessage: + ld a, [wPrinterStatusIndicator] and a ret z push af @@ -1189,55 +1190,55 @@ Func_e8f82: ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a xor a - ld [wcae0], a + ld [wPrinterStatusIndicator], a ret String_e8fb8: db "Press B to Cancel@" Table_e8fca: - dw String_e8fdc - dw String_e8fdd - dw String_e8ff0 - dw String_e9003 - dw String_e9014 - dw String_e9049 - dw String_e907e - dw String_e90b3 - dw String_e90e8 - -String_e8fdc: + dw .Blank + dw .CheckingLink + dw .Transmitting + dw .Printing + dw .Error1 + dw .Error2 + dw .Error3 + dw .Error4 + dw .WrongDevice + +.Blank: db "@" -String_e8fdd: +.CheckingLink: db "" next " CHECKING LINK...@" -String_e8ff0: +.Transmitting: db "" next " TRANSMITTING...@" -String_e9003: +.Printing: db "" next " PRINTING...@" -String_e9014: +.Error1: db " Printer Error 1" next "" next "Check the Game Boy" next "Printer Manual.@" -String_e9049: +.Error2: db " Printer Error 2" next "" next "Check the Game Boy" next "Printer Manual.@" -String_e907e: +.Error3: db " Printer Error 3" next "" next "Check the Game Boy" next "Printer Manual.@" -String_e90b3: +.Error4: db " Printer Error 4" next "" next "Check the Game Boy" next "Printer Manual.@" -String_e90e8: +.WrongDevice: db "This is not the" next "Game Boy Printer!@" diff --git a/engine/surfing_minigame.asm b/engine/surfing_minigame.asm index 0e64444a..d7c7816e 100755 --- a/engine/surfing_minigame.asm +++ b/engine/surfing_minigame.asm @@ -1697,8 +1697,8 @@ Func_f8b92: jr nz, .asm_f8bb0 .asm_f8ba6 call WaitForSoundToFinish - ld e, $1b - call Func_f8bcb + ldpikacry e, PikachuCry28 + call SurfingMinigame_PlayPikaCryIfSurfingPikaInParty and a ret @@ -1708,14 +1708,14 @@ Func_f8b92: ld a, [wc5dd] ld [wd496], a call WaitForSoundToFinish - ld e, $21 - call Func_f8bcb + ldpikacry e, PikachuCry34 + call SurfingMinigame_PlayPikaCryIfSurfingPikaInParty ld a, SFX_GET_ITEM2_4_2 call PlaySound scf ret -Func_f8bcb: ; f8bcb (3e:4bcb) +SurfingMinigame_PlayPikaCryIfSurfingPikaInParty: ; f8bcb (3e:4bcb) push de callab IsSurfingPikachuInThePlayersParty pop de @@ -2734,6 +2734,7 @@ Func_f9404: INCLUDE "data/animated_objects_3e_1.asm" Unkn_f96c5: +; a sine wave with amplitude 2 db 0, 0, 0, 1, 1, 1, 1, 2 db 2, 2, 1, 1, 1, 1, 0, 0 db 0, 0, 0, -1, -1, -1, -1, -2 diff --git a/engine/yellow_intro.asm b/engine/yellow_intro.asm index 3e414319..5aad4d33 100755 --- a/engine/yellow_intro.asm +++ b/engine/yellow_intro.asm @@ -10,7 +10,7 @@ PlayIntroScene: call InitYellowIntroGFXAndMusic call DelayFrame .loop - ld a, [wc634] + ld a, [wYellowIntroCurrentScene] bit 7, a jr nz, .go_to_title_screen call JoypadLowSensitivity @@ -21,7 +21,7 @@ PlayIntroScene: ld a, $0 ld [wCurrentAnimatedObjectOAMBufferOffset], a call RunObjectAnimations - ld a, [wc634] + ld a, [wYellowIntroCurrentScene] cp $7 call z, Func_f98a2 cp $b @@ -65,7 +65,6 @@ Func_f98a2: ld a, [wOAMBuffer + 16 * 4 + 3] or $1 ld [wOAMBuffer + 16 * 4 + 3], a -Func_f98b8: ld a, [wOAMBuffer + 18 * 4 + 3] or $1 ld [wOAMBuffer + 18 * 4 + 3], a @@ -96,37 +95,37 @@ Func_f98cb: ret Func_f98fc: - ld a, [wc634] + ld a, [wYellowIntroCurrentScene] ld hl, Jumptable_f9906 call Func_fa06e jp [hl] Jumptable_f9906: - dw Func_f992f - dw Func_f995f - dw Func_f996a - dw Func_f9a08 - dw Func_f9a1e - dw Func_f9a60 - dw Func_f9a6b - dw Func_f9ab1 - dw Func_f9ad8 - dw Func_f9af9 - dw Func_f9b04 - dw Func_f9bf6 - dw Func_f9cac - dw Func_f9d12 - dw Func_f9d22 - dw Func_f9d8f - dw Func_f9dbf - dw Func_f9e12 - -Func_f992a: - ld hl, wc634 + dw YellowIntroScene0 ; running pika 1 + dw YellowIntroScene1 ; wait last + dw YellowIntroScene2 ; pikachu kick + dw YellowIntroScene3 ; wait last + dw YellowIntroScene4 ; running pika 2 + dw YellowIntroScene5 ; wait last + dw YellowIntroScene6 ; surfing pika + dw YellowIntroScene7 ; wait last + dw YellowIntroScene8 ; running pika 3 + dw YellowIntroScene9 ; wait last + dw YellowIntroScene10 ; flying pika + dw YellowIntroScene11 ; wait last + dw YellowIntroScene12 ; pika close up + dw YellowIntroScene13 ; wait last + dw YellowIntroScene14 ; pika thunderbolt + dw YellowIntroScene15 ; wait last + dw YellowIntroScene16 ; fade to white + dw YellowIntroScene17 ; wait and quit + +YellowIntro_NextScene: + ld hl, wYellowIntroCurrentScene inc [hl] ret -Func_f992f: +YellowIntroScene0: xor a ld [hLCDCPointer], a lb de, $58, $58 @@ -145,20 +144,20 @@ Func_f992f: call UpdateGBCPal_BGP call UpdateGBCPal_OBP0 call UpdateGBCPal_OBP1 - ld a, $82 - ld [wc635], a - call Func_f992a + ld a, 130 + ld [wYellowIntroSceneTimer], a + call YellowIntro_NextScene ret -Func_f995f: - call Func_f9e41 +YellowIntroScene1: + call YellowIntro_CheckFrameTimerDecrement ret nc call YellowIntro_MaskCurrentAnimatedObjectStruct - call Func_f992a + call YellowIntro_NextScene ret -Func_f996a: - call Func_f9e80 +YellowIntroScene2: + call YellowIntro_BlankPalsDelay2AndDisableLCD ld c, $8 call UpdateMusicCTimes xor a @@ -167,64 +166,66 @@ Func_f996a: ld bc, $400 xor a call Bank3E_FillMemory - call Func_f9996 + call YellowIntroScene2_PlaceGraphic lb de, $58, $b8 ; overloaded ld a, $4 ; overloaded - call Func_f99d2 + call LoadYellowIntroFlyingSpeedBars ld a, $1 call Func_f9e9a - call Func_f9e35 - call Func_f992a + call YellowIntro_SetTimerFor128Frames + call YellowIntro_NextScene ret -Func_f9996: - ld hl, $98d4 +YellowIntroScene2_PlaceGraphic: + ld hl, $98d4 ; (20, 6) ld de, $20 ld b, $6 ld a, $90 -.asm_f99a0 +.row ld c, $6 push af push hl -.asm_f99a4 +.col ld [hli], a inc a dec c - jr nz, .asm_f99a4 + jr nz, .col pop hl add hl, de pop af add $10 dec b - jr nz, .asm_f99a0 + jr nz, .row ld a, [hGBC] and a - jr z, .asm_f99d1 - ld hl, $98d4 + jr z, .dmg_sgb + ; We can actually set palettes! + ld hl, $98d4 ; (20, 6) ld de, $20 ld b, $6 ld a, $1 ld [rVBK], a -.asm_f99c2 +.attr_row ld c, $6 push hl -.asm_f99c5 +.attr_col ld [hli], a dec c - jr nz, .asm_f99c5 + jr nz, .attr_col pop hl add hl, de dec b - jr nz, .asm_f99c2 + jr nz, .attr_row xor a ld [rVBK], a -.asm_f99d1 +.dmg_sgb ret -Func_f99d2: - ld hl, Unkn_f99f0 +LoadYellowIntroFlyingSpeedBars: + ld hl, YellowIntroFlyingSpeedBarData ld a, $8 -.asm_f99d7 +.loop +; Spawn object $8 at indicated coordinates with indicated speeds push af ld e, [hl] inc hl @@ -242,10 +243,11 @@ Func_f99d2: pop hl pop af dec a - jr nz, .asm_f99d7 + jr nz, .loop ret -Unkn_f99f0: +YellowIntroFlyingSpeedBarData: + ; y, x, speed db $d0, $20, $02 db $f0, $30, $04 db $d0, $40, $06 @@ -255,9 +257,9 @@ Unkn_f99f0: db $e0, $80, $04 db $f0, $90, $02 -Func_f9a08: - call Func_f9e41 - jr c, .asm_f9a17 +YellowIntroScene3: + call YellowIntro_CheckFrameTimerDecrement + jr c, .expired ld a, [hSCX] cp $68 ret z @@ -265,38 +267,39 @@ Func_f9a08: ld [hSCX], a ret -.asm_f9a17 +.expired call MaskAllAnimatedObjectStructs - call Func_f992a + call YellowIntro_NextScene ret -Func_f9a1e: - call Func_f9e80 +YellowIntroScene4: + call YellowIntro_BlankPalsDelay2AndDisableLCD ld c, $5 call UpdateMusicCTimes ld a, [hGBC] and a - jr z, .asm_f9a47 + jr z, .dmg_sgb + ; We can actually set palettes! ld hl, $98d4 ld de, $20 ld b, $6 ld a, $1 ld [rVBK], a xor a -.asm_f9a38 +.attr_row ld c, $6 push hl -.asm_f9a3b +.attr_col ld [hli], a dec c - jr nz, .asm_f9a3b + jr nz, .attr_col pop hl add hl, de dec b - jr nz, .asm_f9a38 + jr nz, .attr_row xor a ld [rVBK], a -.asm_f9a47 +.dmg_sgb xor a ld [hLCDCPointer], a call Func_f9e5f @@ -305,24 +308,24 @@ Func_f9a1e: call YellowIntro_SpawnAnimatedObjectAndSavePointer xor a call Func_f9e9a - call Func_f9e35 - call Func_f992a + call YellowIntro_SetTimerFor128Frames + call YellowIntro_NextScene ret -Func_f9a60: - call Func_f9e41 +YellowIntroScene5: + call YellowIntro_CheckFrameTimerDecrement ret nc call YellowIntro_MaskCurrentAnimatedObjectStruct - call Func_f992a + call YellowIntro_NextScene ret -Func_f9a6b: - call Func_f9e80 +YellowIntroScene6: + call YellowIntro_BlankPalsDelay2AndDisableLCD ld c, $5 call UpdateMusicCTimes ld a, $42 ld [hLCDCPointer], a - call Func_f9ec4 + call YellowIntro_Copy8BitSineWave ld hl, vBGMap0 ld bc, $60 xor a @@ -346,18 +349,18 @@ Func_f9a6b: call YellowIntro_SpawnAnimatedObjectAndSavePointer ld a, $1 call Func_f9e9a - call Func_f9e3b - call Func_f992a + call YellowIntro_SetTimerFor88Frames + call YellowIntro_NextScene ret -Func_f9ab1: - call Func_f9e41 - jr c, .asm_f9ad1 +YellowIntroScene7: + call YellowIntro_CheckFrameTimerDecrement + jr c, .expired ld hl, hSCX inc [hl] inc [hl] - ld hl, wc800 - ld de, wc800 + 1 + ld hl, wYellowIntroSurfingPikaSineWaveBuffer + ld de, wYellowIntroSurfingPikaSineWaveBuffer + 1 ld a, [hl] push af ld c, $ff @@ -369,16 +372,16 @@ Func_f9ab1: jr nz, .shift_loop pop af ld [hl], a - call Prep7TileTransferFromC810ToC710 + call Request7TileTransferFromC810ToC710 ret -.asm_f9ad1 +.expired call YellowIntro_MaskCurrentAnimatedObjectStruct - call Func_f992a + call YellowIntro_NextScene ret -Func_f9ad8: - call Func_f9e80 +YellowIntroScene8: + call YellowIntro_BlankPalsDelay2AndDisableLCD ld c, $5 call UpdateMusicCTimes xor a @@ -389,19 +392,19 @@ Func_f9ad8: call YellowIntro_SpawnAnimatedObjectAndSavePointer xor a call Func_f9e9a - call Func_f9e35 - call Func_f992a + call YellowIntro_SetTimerFor128Frames + call YellowIntro_NextScene ret -Func_f9af9: - call Func_f9e41 +YellowIntroScene9: + call YellowIntro_CheckFrameTimerDecrement ret nc call YellowIntro_MaskCurrentAnimatedObjectStruct - call Func_f992a + call YellowIntro_NextScene ret -Func_f9b04: - call Func_f9e80 +YellowIntroScene10: + call YellowIntro_BlankPalsDelay2AndDisableLCD ld c, $5 call UpdateMusicCTimes xor a @@ -431,8 +434,8 @@ Func_f9b04: call YellowIntro_SpawnAnimatedObjectAndSavePointer ld a, $1 call Func_f9e9a - call Func_f9e35 - call Func_f992a + call YellowIntro_SetTimerFor128Frames + call YellowIntro_NextScene ret .FillBGMapBox: @@ -457,20 +460,20 @@ Unkn_f9b6e: INCBIN "gfx/unknown_f9b6e.map" Unkn_f9be6: INCBIN "gfx/unknown_f9be6.map" Unkn_f9bf2: INCBIN "gfx/unknown_f9bf2.map" -Func_f9bf6: - call Func_f9e41 - jr c, .asm_f9c25 - ld a, [wc635] +YellowIntroScene11: + call YellowIntro_CheckFrameTimerDecrement + jr c, .expired + ld a, [wYellowIntroSceneTimer] and $7 ret nz - ld a, [wc635] + ld a, [wYellowIntroSceneTimer] and $8 sla a sla a sla a ld e, a ld d, $0 - ld hl, GFX_f9c2c + ld hl, YellowIntroCloudGFX1 add hl, de ld a, l ld [H_VBCOPYSRC], a @@ -484,16 +487,16 @@ Func_f9bf6: ld [H_VBCOPYSIZE], a ret -.asm_f9c25 +.expired call YellowIntro_MaskCurrentAnimatedObjectStruct - call Func_f992a + call YellowIntro_NextScene ret -GFX_f9c2c: INCBIN "gfx/unknown_f9c2c.2bpp" -GFX_f9c6c: INCBIN "gfx/unknown_f9c6c.2bpp" ; indirectly referenced +YellowIntroCloudGFX1: INCBIN "gfx/unknown_f9c2c.2bpp" +YellowIntroCloudGFX2: INCBIN "gfx/unknown_f9c6c.2bpp" ; indirectly referenced -Func_f9cac: - call Func_f9e80 +YellowIntroScene12: + call YellowIntro_BlankPalsDelay2AndDisableLCD ld c, $5 call UpdateMusicCTimes xor a @@ -510,51 +513,54 @@ Func_f9cac: ld bc, $80 ld a, $1 call Bank3E_FillMemory + + ; paste 8x12 graphic into vBGMap0 at (5, 6) starting at tile 4, skipping 4 vtiles at the end of each row ld hl, $98c5 ld de, $20 ld a, $4 - ld b, $8 -.asm_f9ce1 - ld c, $c + ld b, 8 +.row + ld c, 12 push hl -.asm_f9ce4 +.col ld [hli], a inc a dec c - jr nz, .asm_f9ce4 + jr nz, .col pop hl add hl, de add $4 dec b - jr nz, .asm_f9ce1 - ld hl, $98c4 + jr nz, .row + + ld hl, $98c4 ; (4, 6) ld [hl], $3 - ld hl, $98e4 + ld hl, $98e4 ; (4, 7) ld [hl], $74 - ld hl, $99a5 + ld hl, $99a5 ; (5, 5) ld [hl], $0 lb de, $60, $58 ld a, $9 call YellowIntro_SpawnAnimatedObjectAndSavePointer xor a call Func_f9e9a - call Func_f9e35 - call Func_f992a + call YellowIntro_SetTimerFor128Frames + call YellowIntro_NextScene ret -Func_f9d12: - call Func_f9e41 +YellowIntroScene13: + call YellowIntro_CheckFrameTimerDecrement ret nc lb de, $68, $58 ld a, $a call SpawnAnimatedObject - call Func_f992a + call YellowIntro_NextScene ret -Func_f9d22: - ld de, Unkn_f9dd6 - call Func_f9e4d - jr c, .asm_f9d3c +YellowIntroScene14: + ld de, YellowIntroPalSequence_f9dd6 + call YellowIntro_LoadDMGPalAndIncrementCounter + jr c, .expired ld [rBGP], a ld [rOBP0], a and $f0 @@ -564,7 +570,7 @@ Func_f9d22: call UpdateGBCPal_OBP1 ret -.asm_f9d3c +.expired call MaskAllAnimatedObjectStructs call YellowIntro_BlankOAMBuffer ld hl, wTileMap @@ -594,15 +600,15 @@ Func_f9d22: lb de, $58, $58 ld a, $7 call YellowIntro_SpawnAnimatedObjectAndSavePointer - call Func_f992a + call YellowIntro_NextScene ld a, $28 - ld [wc635], a + ld [wYellowIntroSceneTimer], a ret -Func_f9d8f: - call Func_f9e41 - jr c, .asm_f9dad - ld a, [wc635] +YellowIntroScene15: + call YellowIntro_CheckFrameTimerDecrement + jr c, .expired + ld a, [wYellowIntroSceneTimer] and $3 ret nz ld a, [rOBP0] @@ -615,7 +621,7 @@ Func_f9d8f: call UpdateGBCPal_OBP0 ret -.asm_f9dad +.expired xor a ld [hLCDCPointer], a ld a, $e4 @@ -623,22 +629,22 @@ Func_f9d8f: ld [rOBP0], a call UpdateGBCPal_BGP call UpdateGBCPal_OBP0 - call Func_f992a -Func_f9dbf: - ld de, Unkn_f9e0a - call Func_f9e4d - jr c, .asm_f9dd2 + call YellowIntro_NextScene +YellowIntroScene16: + ld de, YellowIntroPalSequence_f9e0a + call YellowIntro_LoadDMGPalAndIncrementCounter + jr c, .expired ld [rOBP0], a ld [rBGP], a call UpdateGBCPal_BGP call UpdateGBCPal_OBP0 ret -.asm_f9dd2 - call Func_f992a +.expired + call YellowIntro_NextScene ret -Unkn_f9dd6: +YellowIntroPalSequence_f9dd6: db $e4, $c0, $c0, $e4 db $e4, $c0, $c0, $e4 db $e4, $c0, $c0, $e4 @@ -653,14 +659,14 @@ Unkn_f9dd6: db $e4, $c0, $c0, $e4 db $e4, $c0, $c0, $ff -Unkn_f9e0a: +YellowIntroPalSequence_f9e0a: db $e4, $90, $90, $40 db $40, $00, $00, $ff -Func_f9e12: +YellowIntroScene17: ld c, 64 call DelayFrames - ld hl, wc634 + ld hl, wYellowIntroCurrentScene set 7, [hl] ret @@ -680,18 +686,18 @@ YellowIntro_MaskCurrentAnimatedObjectStruct: call MaskCurrentAnimatedObjectStruct ret -Func_f9e35: - ld a, $80 - ld [wc635], a +YellowIntro_SetTimerFor128Frames: + ld a, 128 + ld [wYellowIntroSceneTimer], a ret -Func_f9e3b: - ld a, $58 - ld [wc635], a +YellowIntro_SetTimerFor88Frames: + ld a, 88 + ld [wYellowIntroSceneTimer], a ret -Func_f9e41: - ld hl, wc635 +YellowIntro_CheckFrameTimerDecrement: + ld hl, wYellowIntroSceneTimer ld a, [hl] and a jr z, .asm_f9e4b @@ -703,8 +709,8 @@ Func_f9e41: scf ret -Func_f9e4d: - ld hl, wc635 +YellowIntro_LoadDMGPalAndIncrementCounter: + ld hl, wYellowIntroSceneTimer ld a, [hl] inc [hl] ld l, a @@ -735,7 +741,7 @@ Func_f9e5f: call Bank3E_FillMemory ret -Func_f9e80: +YellowIntro_BlankPalsDelay2AndDisableLCD: xor a ld [rBGP], a ld [rOBP0], a @@ -750,7 +756,7 @@ Func_f9e80: Func_f9e9a: ld e, a - callab Func_720ad + callab YellowIntroPaletteAction xor a ld [hSCX], a ld [hSCY], a @@ -768,26 +774,29 @@ Func_f9e9a: call UpdateGBCPal_OBP1 ret -Func_f9ec4: - ld de, wc800 +YellowIntro_Copy8BitSineWave: + ; Copy this sine wave into wYellowIntroSurfingPikaSineWaveBuffer 8 times (end just before wc900) + ld de, wYellowIntroSurfingPikaSineWaveBuffer ld a, $8 -.asm_f9ec9 +.loop push af - ld hl, Unkn_f9ed8 - ld bc, $20 + ld hl, .SineWave + ld bc, .SineWaveEnd - .SineWave call Bank3E_CopyData pop af dec a - jr nz, .asm_f9ec9 + jr nz, .loop ret -Unkn_f9ed8: +.SineWave: +; a sine wave with amplitude 4 db 0, 0, 1, 2, 2, 3, 3, 3 db 4, 3, 3, 3, 2, 2, 1, 0 db 0, 0, -1, -2, -2, -3, -3, -3 db -4, -3, -3, -3, -2, -2, -1, 0 +.SineWaveEnd: -Prep7TileTransferFromC810ToC710: +Request7TileTransferFromC810ToC710: ld a, wc810 % $100 ld [H_VBCOPYSRC], a ld a, wc810 / $100 @@ -837,7 +846,7 @@ InitYellowIntroGFXAndMusic: ld b, $8 call RunPaletteCommand xor a - ld hl, wc634 + ld hl, wYellowIntroCurrentScene ld [hli], a ld [hli], a ld [hli], a diff --git a/wram.asm b/wram.asm index 541397d1..bff4283f 100755 --- a/wram.asm +++ b/wram.asm @@ -404,8 +404,11 @@ wc632:: ; c632 ds 1 wc633:: ; c633 ds 1 + +wYellowIntroCurrentScene:: ; c634 wc634:: ; c634 ds 1 +wYellowIntroSceneTimer:: ; c635 wc635:: ; c635 ds 1 wYellowIntroAnimatedObjectStructPointer:: ; c636 @@ -420,20 +423,75 @@ wYellowIntroAnimatedObjectStructPointer:: ; c636 wTempPic:: wOverworldMap:: ; c6e8 ; ds 1300 - ds $18 +wc6e8:: ; c6e8 + ds 1 +wc6e9:: ; c6e9 + ds 1 +wc6ea:: ; c6ea + ds 1 +wc6eb:: ; c6eb + ds 1 +wc6ec:: ; c6ec + ds 1 +wc6ed:: ; c6ed + ds 1 +wc6ee:: ; c6ee + ds 1 +wc6ef:: ; c6ef + ds 1 +wc6f0:: ; c6f0 + ds 1 +wc6f1:: ; c6f1 + ds 1 +wc6f2:: ; c6f2 + ds 1 +wc6f3:: ; c6f3 + ds 13 wc700:: ; c700 ds $10 wc710:: ; c710 ds $f0 -wc800:: ; c800 +wYellowIntroSurfingPikaSineWaveBuffer:: ; c800 + ; ds $100 ds $10 wc810:: ; c810 - ds $168 - + ds $f0 + +; c900 + ds $70 + +wc970:: ; c970 + ds 1 +wc971:: ; c971 + ds 1 +wc972:: ; c972 + ds 1 +wc973:: ; c973 + ds 1 +wc974:: ; c974 + ds 1 +wc975:: ; c975 + ds 1 +wc976:: ; c976 + ds 1 +wc977:: ; c977 + ds 1 wPrinterTileBuffer:: ; c978 ds SCREEN_HEIGHT * SCREEN_WIDTH -wcae0:: ; cae0 - ds 284 +wPrinterStatusIndicator:: ; cae0 + ds 2 +wcae2:: ; cae2 + ds 1 +wcae3:: ; cae3 + ds 17 +wcaf4:: ; caf4 + ds 1 +wcaf5:: ; caf5 + ds 1 +wcaf6:: ; caf6 + ds 3 +wcaf9:: ; caf9 + ds 259 wRedrawRowOrColumnSrcTiles:: ; cbfc ; the tiles of the row or column to be redrawn by RedrawRowOrColumn @@ -1595,22 +1653,22 @@ wMaxItemQuantity:: ; cf97 ; LoadMonData copies mon data here wLoadedMon:: party_struct wLoadedMon ; cf98 -wFontLoaded:: ; cfc4 +wFontLoaded:: ; cfc3 ; bit 0: The space in VRAM that is used to store walk animation tile patterns ; for the player and NPCs is in use for font tile patterns. ; This means that NPC movement must be disabled. ; The other bits are unused. ds 1 -wWalkCounter:: ; cfc5 +wWalkCounter:: ; cfc4 ; walk animation counter ds 1 -wTileInFrontOfPlayer:: ; cfc6 +wTileInFrontOfPlayer:: ; cfc5 ; background tile number in front of the player (either 1 or 2 steps ahead) ds 1 -wAudioFadeOutControl:: ; cfc7 +wAudioFadeOutControl:: ; cfc6 ; The desired fade counter reload value is stored here prior to calling ; PlaySound in order to cause the current music to fade out before the new ; music begins playing. Storing 0 causes no fade out to occur and the new music @@ -1622,13 +1680,13 @@ wAudioFadeOutControl:: ; cfc7 ; audio, it zeroes this variable and starts playing the sound ID stored in it. ds 1 -wAudioFadeOutCounterReloadValue:: ; cfc8 +wAudioFadeOutCounterReloadValue:: ; cfc7 ds 1 -wAudioFadeOutCounter:: ; cfc9 +wAudioFadeOutCounter:: ; cfc8 ds 1 -wLastMusicSoundID:: ; cfca +wLastMusicSoundID:: ; cfc9 ; This is used to determine whether the default music is already playing when ; attempting to play the default music (in order to avoid restarting the same ; music) and whether the music has already been stopped when attempting to @@ -1640,45 +1698,45 @@ wLastMusicSoundID:: ; cfca ; the music). ds 1 -wUpdateSpritesEnabled:: ; cfcb +wUpdateSpritesEnabled:: ; cfca ; $00 = causes sprites to be hidden and the value to change to $ff ; $01 = enabled ; $ff = disabled ; other values aren't used ds 1 -wEnemyMoveNum:: ; cfcc +wEnemyMoveNum:: ; cfcb ds 1 -wEnemyMoveEffect:: ; cfcd +wEnemyMoveEffect:: ; cfcc ds 1 -wEnemyMovePower:: ; cfce +wEnemyMovePower:: ; cfcd ds 1 -wEnemyMoveType:: ; cfcf +wEnemyMoveType:: ; cfce ds 1 -wEnemyMoveAccuracy:: ; cfd0 +wEnemyMoveAccuracy:: ; cfcf ds 1 -wEnemyMoveMaxPP:: ; cfd1 +wEnemyMoveMaxPP:: ; cfd0 ds 1 -wPlayerMoveNum:: ; cfd2 +wPlayerMoveNum:: ; cfd1 ds 1 -wPlayerMoveEffect:: ; cfd3 +wPlayerMoveEffect:: ; cfd2 ds 1 -wPlayerMovePower:: ; cfd4 +wPlayerMovePower:: ; cfd3 ds 1 -wPlayerMoveType:: ; cfd5 +wPlayerMoveType:: ; cfd4 ds 1 -wPlayerMoveAccuracy:: ; cfd6 +wPlayerMoveAccuracy:: ; cfd5 ds 1 -wPlayerMoveMaxPP:: ; cfd7 +wPlayerMoveMaxPP:: ; cfd6 ds 1 -wEnemyMonSpecies2:: ; cfd8 +wEnemyMonSpecies2:: ; cfd7 ds 1 -wBattleMonSpecies2:: ; cfd9 +wBattleMonSpecies2:: ; cfd8 ds 1 -wEnemyMonNick:: ds NAME_LENGTH ; cfda +wEnemyMonNick:: ds NAME_LENGTH ; cfd9 wEnemyMon:: ; cfe5 ; The wEnemyMon struct reaches past 0xcfff, @@ -1708,9 +1766,9 @@ wEnemyMonAttack:: dw wEnemyMonDefense:: dw wEnemyMonSpeed:: dw wEnemyMonSpecial:: dw -wEnemyMonPP:: ds 3 ; NUM_MOVES - 2 +wEnemyMonPP:: ds 3 ; NUM_MOVES - 1 SECTION "WRAM Bank 1", WRAMX, BANK[1] - ds 1 ; NUM_MOVES - 2 + ds 1 ; NUM_MOVES - 3 wEnemyMonBaseStats:: ds 5 wEnemyMonCatchRate:: ds 1 -- cgit v1.3.1-sl0p From 0e9d0481b897c6afe7cd7c0ea5c23562379ad8ca Mon Sep 17 00:00:00 2001 From: pikalaxalt Date: Mon, 6 Jun 2016 08:23:52 -0400 Subject: Printer-related labels --- engine/menu/main_menu.asm | 2 +- engine/menu/options.asm | 4 +- engine/oak_speech.asm | 4 +- engine/printer.asm | 856 +++++++--------------------------------------- engine/printer/serial.asm | 620 +++++++++++++++++++++++++++++++++ engine/unknown_ea3ea.asm | 10 +- home.asm | 10 +- home/serial.asm | 10 +- hram.asm | 2 + wram.asm | 40 ++- 10 files changed, 789 insertions(+), 769 deletions(-) create mode 100755 engine/printer/serial.asm (limited to 'wram.asm') diff --git a/engine/menu/main_menu.asm b/engine/menu/main_menu.asm index 48346a02..3f1ca0e8 100755 --- a/engine/menu/main_menu.asm +++ b/engine/menu/main_menu.asm @@ -128,7 +128,7 @@ InitOptions: ; 5bff (1:5bff) ld a,3 ; medium speed ld [wOptions],a ld a,64 ; audio? - ld [wd498], a + ld [wPrinterSettings], a ret Func_5cc1: ; 5cc1 (1:5cc1) diff --git a/engine/menu/options.asm b/engine/menu/options.asm index 5d3c82cb..4b8eb883 100644 --- a/engine/menu/options.asm +++ b/engine/menu/options.asm @@ -272,7 +272,7 @@ OptionsMenu_GBPrinterBrightness: ; 41e0c (10:5e0c) ld a, d .asm_41e2e ld b, a - ld [wd498], a + ld [wPrinterSettings], a .asm_41e32 ld b, $0 ld hl, GBPrinterOptionStringsPointerTable @@ -305,7 +305,7 @@ DarkestPrintText: ; 41e72 (10:5e72) db "DARKEST @" Func_41e7b: ; 41e7b (10:5e7b) - ld a, [wd498] + ld a, [wPrinterSettings] and a jr z, .asm_41e93 cp $20 diff --git a/engine/oak_speech.asm b/engine/oak_speech.asm index 5cbfbee1..6b43574a 100755 --- a/engine/oak_speech.asm +++ b/engine/oak_speech.asm @@ -5,7 +5,7 @@ SetDefaultNames: ; 5e27 (1:5e27) push af ld a, [wd732] push af - ld a, [wd498] + ld a, [wPrinterSettings] push af ld hl, wPlayerName ld bc, wBoxDataEnd - wPlayerName @@ -20,7 +20,7 @@ SetDefaultNames: ; 5e27 (1:5e27) ld [wd496], a ld [wd497], a pop af - ld [wd498], a + ld [wPrinterSettings], a pop af ld [wd732], a pop af diff --git a/engine/printer.asm b/engine/printer.asm index 51a5c9ed..aa5c6ced 100644 --- a/engine/printer.asm +++ b/engine/printer.asm @@ -1,614 +1,4 @@ -Func_e8783: ; e8783 (3a:4783) - ld a, 9 -Func_e8785: - push af - ld hl, wOverworldMap - lb bc, 4, 13 - xor a - call Func_e8a2e - xor a - ld [rSB], a - ld [rSC], a - ld [wUnknownSerialFlag_d49b], a - ld hl, wUnknownSerialFlag_d49a - set 0, [hl] - ld a, [wd498] - ld [wcae3], a - pop af - ld [wcaf4], a - ret - -; e87a8 -Func_e87a8: ; e87a8 (3a:47a8) - ld a, [wOverworldMap] - ld e, a - ld d, 0 - ld hl, Jumptable_e87b7 - add hl, de - add hl, de - ld a, [hli] - ld h, [hl] - ld l, a - jp [hl] - -Jumptable_e87b7: - dw Func_e87fd - dw Func_e88c9 - dw Func_e88a6 - dw Func_e881f - dw Func_e8906 - dw Func_e88b4 - dw Func_e884b - dw Func_e8906 - dw Func_e88a6 - dw Func_e8864 - dw Func_e8906 - dw Func_e88a6 - dw Func_e8927 - dw Func_e87e9 - dw Func_e87f3 - dw Func_e88a6 - dw Func_e8889 - dw Func_e87f7 - dw Func_e8936 - dw Func_e8939 - -Func_e87df: - ld hl, wOverworldMap - inc [hl] - ret - -Func_e87e4: - ld hl, wOverworldMap - dec [hl] - ret - -Func_e87e9: - xor a - ld [wc971], a - ld hl, wOverworldMap - set 7, [hl] - ret - -Func_e87f3: - call Func_e87df - ret - -Func_e87f7: - ld a, $01 - ld [wOverworldMap], a - ret - -Func_e87fd: - call Func_e8981 - ld hl, Data_e8a3a - call Func_e8968 - xor a - ld [wc976], a - ld [wc977], a - ld a, [wcaf4] - ld [wc6e9], a - call Func_e87df - call Func_e8949 - ld a, $01 - ld [wPrinterStatusIndicator], a - ret - -Func_e881f: - call Func_e8981 - ld hl, wc6e9 - ld a, [hl] - and a - jr z, Func_e884b - ld hl, Data_e8a46 - call Func_e8968 - call Func_e89e6 - ld a, $80 - ld [wc976], a - ld a, $02 - ld [wc977], a - call Func_e899f - call Func_e87df - call Func_e8949 - ld a, $02 - ld [wPrinterStatusIndicator], a - ret - -Func_e884b: - ld a, $06 - ld [wOverworldMap], a - ld hl, Data_e8a4c - call Func_e8968 - xor a - ld [wc976], a - ld [wc977], a - call Func_e87df - call Func_e8949 - ret - -Func_e8864: - call Func_e8981 - ld hl, Data_e8a40 - call Func_e8968 - call Func_e89cf - ld a, $04 - ld [wc976], a - ld a, $00 - ld [wc977], a - call Func_e899f - call Func_e87df - call Func_e8949 - ld a, $03 - ld [wPrinterStatusIndicator], a - ret - -Func_e8889: - call Func_e8981 - ld hl, Data_e8a3a - call Func_e8968 - xor a - ld [wc976], a - ld [wc977], a - ld a, [wcaf4] - ld [wc6e9], a - call Func_e87df - call Func_e8949 - ret - -Func_e88a6: - ld hl, wc973 - inc [hl] - ld a, [hl] - cp a, $06 - ret c - xor a - ld [hl], a - call Func_e87df - ret - -Func_e88b4: - ld hl, wc973 - inc [hl] - ld a, [hl] - cp a, $06 - ret c - xor a - ld [hl], a - ld hl, wc6e9 - dec [hl] - call Func_e87e4 - call Func_e87e4 - ret - -Func_e88c9: - ld a, [wUnknownSerialFlag_d49b] - and a - ret nz - ld a, [wc970] - cp a, $ff - jr nz, .asm_e88dc - ld a, [wc971] - cp a, $ff - jr z, .asm_e88f8 -.asm_e88dc - ld a, [wc970] - cp a, $81 - jr nz, .asm_e88f8 - ld a, [wc971] - cp a, $00 - jr nz, .asm_e88f8 - ld hl, wUnknownSerialFlag_d49a - set 1, [hl] - ld a, $05 - ld [wc972], a - call Func_e87df - ret - -.asm_e88f8 - ld a, $ff - ld [wc970], a - ld [wc971], a - ld a, $0e - ld [wOverworldMap], a - ret - -Func_e8906: - ld a, [wUnknownSerialFlag_d49b] - and a - ret nz - ld a, [wc971] - and a, $f0 - jr nz, .asm_e8921 - ld a, [wc971] - and a, $01 - jr nz, .asm_e891d - call Func_e87df - ret - -.asm_e891d - call Func_e87e4 - ret - -.asm_e8921 - ld a, $12 - ld [wOverworldMap], a - ret - -Func_e8927: - ld a, [wUnknownSerialFlag_d49b] - and a - ret nz - ld a, [wc971] - and a, $f3 - ret nz - call Func_e87df - ret - -Func_e8936: - call Func_e87df -Func_e8939: - ld a, [wUnknownSerialFlag_d49b] - and a - ret nz - ld a, [wc971] - and a, $f0 - ret nz - xor a - ld [wOverworldMap], a - ret - -Func_e8949: -.asm_e8949 - ld a, [wUnknownSerialFlag_d49b] - and a - jr nz, .asm_e8949 - xor a - ld [wc974], a - ld [wc975], a - ld a, $01 - ld [wUnknownSerialFlag_d49b], a - ld a, $88 - ld [rSB], a - ld a, $01 - ld [rSC], a - ld a, $81 - ld [rSC], a - ret - -Func_e8968: - ld a, [hli] - ld [wc6ea], a - ld a, [hli] - ld [wc6eb], a - ld a, [hli] - ld [wc6ec], a - ld a, [hli] - ld [wc6ed], a - ld a, [hli] - ld [wc6ee], a - ld a, [hl] - ld [wc6ef], a - ret - -Func_e8981: - xor a - ld hl, wc6ea - ld [hli], a - ld [hli], a - ld [hli], a - ld [hl], a - ld hl, wc6ee - ld [hli], a - ld [hl], a - xor a - ld [wc976], a - ld [wc977], a - ld hl, wc6f0 - ld bc, $0280 - call Func_e8a2e - ret - -Func_e899f: - ld hl, $0000 - ld bc, $0004 - ld de, wc6ea - call Func_e89c2 - ld a, [wc976] - ld c, a - ld a, [wc977] - ld b, a - ld de, wc6f0 - call Func_e89c2 - ld a, l - ld [wc6ee], a - ld a, h - ld [wc6ef], a - ret - -Func_e89c2: -.asm_e89c2 - ld a, [de] - inc de - add l - jr nc, .asm_e89c8 - inc h -.asm_e89c8 - ld l, a - dec bc - ld a, c - or b - jr nz, .asm_e89c2 - ret - -Func_e89cf: - ld a, $01 - ld [wc6f0], a - ld a, [wcae2] - ld [wc6f1], a - ld a, $e4 - ld [wc6f2], a - ld a, [wcae3] - ld [wc6f3], a - ret - -Func_e89e6: - ld a, [wc6e9] - ld b, a - ld a, [wcaf4] - sub b - ld hl, wPrinterTileBuffer - ld de, $0028 -.asm_e89f4 - and a - jr z, .asm_e89fb - add hl, de - dec a - jr .asm_e89f4 - -.asm_e89fb - ld e, l - ld d, h - ld hl, wc6f0 - ld c, $28 -.asm_e8a02 - ld a, [de] - inc de - push bc - push de - push hl - swap a - ld d, a - and a, $f0 - ld e, a - ld a, d - and a, $0f - ld d, a - and a, $08 - ld a, d - jr nz, .asm_e8a1a - or a, $90 - jr .asm_e8a1c - -.asm_e8a1a - or a, $80 -.asm_e8a1c - ld d, a - ld bc, $3a01 - call CopyVideoData - pop hl - ld de, $0010 - add hl, de - pop de - pop bc - dec c - jr nz, .asm_e8a02 - ret - -Func_e8a2e: ; e8a2e (3a:4a2e) - push de - ld e, a -.asm_e8a30 - ld [hl], e - inc hl - dec bc - ld a, c - or b - jr nz, .asm_e8a30 - ld a, e - pop de - ret - -Data_e8a3a: - db $01, $00, $00, $00, $01, $00 -Data_e8a40: - db $02, $00, $04, $00, $00, $00 -Data_e8a46: - db $04, $00, $80, $02, $00, $00 -Data_e8a4c: - db $04, $00, $00, $00, $04, $00 -Data_e8a52: - db $08, $00, $00, $00, $08, $00 -Data_e8a58: - db $0f, $00, $00, $00, $0f, $00 - -Func_e8a5e: ; e8a5e (3a:4a5e) - ld a, [wUnknownSerialFlag_d49b] - ld e, a - ld d, 0 - ld hl, Jumptable_e8a6d - add hl, de - add hl, de - ld a, [hli] - ld h, [hl] - ld l, a - jp [hl] - -Jumptable_e8a6d: - dw Func_e8ab2 - dw Func_e8ab3 - dw Func_e8abc - dw Func_e8ac6 - dw Func_e8ad0 - dw Func_e8ada - dw Func_e8ae4 - dw Func_e8b0f - dw Func_e8b19 - dw Func_e8b23 - dw Func_e8b2c - dw Func_e8b3a - dw Func_e8ab3 - dw Func_e8b44 - dw Func_e8b4d - dw Func_e8b4d - dw Func_e8b4d - dw Func_e8b44 - dw Func_e8b4d - dw Func_e8b23 - dw Func_e8b2c - dw Func_e8b6a - dw Func_e8ab3 - dw Func_e8b56 - dw Func_e8b4d - dw Func_e8b4d - dw Func_e8b4d - dw Func_e8b56 - dw Func_e8b4d - dw Func_e8b23 - dw Func_e8b2c - dw Func_e8b3a - -Func_e8aad: - ld hl, wUnknownSerialFlag_d49b - inc [hl] - ret - -Func_e8ab2: - ret - -Func_e8ab3: - ld a, $33 - call Func_e8b5f - call Func_e8aad - ret - -Func_e8abc: - ld a, [wc6ea] - call Func_e8b5f - call Func_e8aad - ret - -Func_e8ac6: - ld a, [wc6eb] - call Func_e8b5f - call Func_e8aad - ret - -Func_e8ad0: - ld a, [wc6ec] - call Func_e8b5f - call Func_e8aad - ret - -Func_e8ada: - ld a, [wc6ed] - call Func_e8b5f - call Func_e8aad - ret - -Func_e8ae4: - ld hl, wc976 - ld e, [hl] - inc hl - ld d, [hl] - ld a, e - or d - jr z, .asm_e8b0c - dec de - ld [hl], d - dec hl - ld [hl], e - ld a, [wc974] - ld e, a - ld a, [wc975] - ld d, a - ld hl, wc6f0 - add hl, de - inc de - ld a, e - ld [wc974], a - ld a, d - ld [wc975], a - ld a, [hl] - call Func_e8b5f - ret - -.asm_e8b0c - call Func_e8aad -Func_e8b0f: - ld a, [wc6ee] - call Func_e8b5f - call Func_e8aad - ret - -Func_e8b19: - ld a, [wc6ef] - call Func_e8b5f - call Func_e8aad - ret - -Func_e8b23: - ld a, $00 - call Func_e8b5f - call Func_e8aad - ret - -Func_e8b2c: - ld a, [rSB] - ld [wc970], a - ld a, $00 - call Func_e8b5f - call Func_e8aad - ret - -Func_e8b3a: - ld a, [rSB] - ld [wc971], a - xor a - ld [wUnknownSerialFlag_d49b], a - ret - -Func_e8b44: - ld a, $0f - call Func_e8b5f - call Func_e8aad - ret - -Func_e8b4d: - ld a, $00 - call Func_e8b5f - call Func_e8aad - ret - -Func_e8b56: - ld a, $08 - call Func_e8b5f - call Func_e8aad - ret - -Func_e8b5f: - ld [rSB], a - ld a, $01 - ld [rSC], a - ld a, $81 - ld [rSC], a - ret - -Func_e8b6a: - ld a, [rSB] - ld [wc971], a - xor a - ld [wUnknownSerialFlag_d49b], a - ret +INCLUDE "engine/printer/serial.asm" Func_e8b74: ; e8b74 (3a:4b74) ld a, [wUpdateSpritesEnabled] @@ -616,12 +6,12 @@ Func_e8b74: ; e8b74 (3a:4b74) xor a ld [wUpdateSpritesEnabled], a ld [$ffdb], a - call Func_e8f24 + call Printer_PlayPrinterMusic ld a, [rIE] push af xor a ld [rIF], a - ld a, $09 + ld a, $9 ld [rIE], a xor a ld [$ffba], a @@ -637,11 +27,11 @@ Func_e8b74: ; e8b74 (3a:4b74) ld a, $13 .asm_e8ba0 ld [wcae2], a - call Func_e8efc + call Printer_CopyTileMapToPrinterTileBuffer call ClearScreen callab Func_401c2 callab Func_4027c - ld a, $01 + ld a, $1 ld [$ffba], a call Func_e8c0c jr c, .asm_e8bf4 @@ -649,44 +39,44 @@ Func_e8b74: ; e8b74 (3a:4b74) and a jr z, .asm_e8bf4 xor a - ld [wUnknownSerialFlag_d49a], a - ld [wUnknownSerialFlag_d49b], a - ld c, $0c + ld [wPrinterConnectionOpen], a + ld [wPrinterOpcode], a + ld c, $c call DelayFrames call SaveScreenTilesToBuffer1 xor a ld [$ffba], a call Func_e8c50 - ld a, $07 + ld a, $7 call Func_e8785 - ld a, $03 + ld a, $3 ld [wcae2], a - call Func_e8efc + call Printer_CopyTileMapToPrinterTileBuffer call LoadScreenTilesFromBuffer1 - ld a, $01 + ld a, $1 ld [$ffba], a call Func_e8c0c .asm_e8bf4 xor a - ld [wUnknownSerialFlag_d49a], a - ld [wUnknownSerialFlag_d49b], a + ld [wPrinterConnectionOpen], a + ld [wPrinterOpcode], a xor a ld [rIF], a pop af ld [rIE], a call Func_0f3d - call Func_e8f3b + call Printer_PlayMapMusic pop af ld [wUpdateSpritesEnabled], a ret Func_e8c0c: - call Func_e8f16 + call Printer_ResetJoypadHRAM .asm_e8c0f call JoypadLowSensitivity - call Func_e8eca + call Printer_CheckPressingB jr c, .asm_e8c2e - ld a, [wc6e8] + ld a, [wPrinterReceiveJumptableIndex] bit 7, a jr nz, .asm_e8c2c call Func_e87a8 @@ -709,16 +99,16 @@ Func_e8c30: ld [wcaf5], a ld a, h ld [wcaf6], a - ld a, $00 + ld a, $0 rla ; copy carry flag state to bit 0 ld [wcaf9], a and a jr z, .asm_e8c4d - ld a, $05 + ld a, $5 jr .asm_e8c4f .asm_e8c4d - ld a, $09 + ld a, $9 .asm_e8c4f ret @@ -730,24 +120,24 @@ Func_e8c50: Func_e8c5c: xor a ld [$ffdb], a - call Func_e8f24 + call Printer_PlayPrinterMusic call Func_e910a ld a, [rIE] push af xor a ld [rIF], a - ld a, $09 + ld a, $9 ld [rIE], a call Func_e8783 ld a, $13 ld [wcae2], a - call Func_e8efc - call Func_e8f16 + call Printer_CopyTileMapToPrinterTileBuffer + call Printer_ResetJoypadHRAM .asm_e8c7d call JoypadLowSensitivity - call Func_e8eca + call Printer_CheckPressingB jr c, .asm_e8c9a - ld a, [wc6e8] + ld a, [wPrinterReceiveJumptableIndex] bit 7, a jr nz, .asm_e8c9a call Func_e87a8 @@ -758,69 +148,69 @@ Func_e8c5c: .asm_e8c9a xor a - ld [wUnknownSerialFlag_d49a], a - ld [wUnknownSerialFlag_d49b], a - call Func_e8f09 + ld [wPrinterConnectionOpen], a + ld [wPrinterOpcode], a + call Printer_CopyTileMapFromPrinterTileBuffer xor a ld [rIF], a pop af ld [rIE], a call Func_0f3d - call Func_e8f3b + call Printer_PlayMapMusic ret Func_e8cb1: xor a ld [$ffdb], a - call Func_e8f24 + call Printer_PlayPrinterMusic call _DisplayDiploma ld a, [rIE] push af xor a ld [rIF], a - ld a, $09 + ld a, $9 ld [rIE], a call Func_e8783 ld a, $10 ld [wcae2], a - call Func_e8efc + call Printer_CopyTileMapToPrinterTileBuffer call Func_e8d11 jr c, .asm_e8cfa xor a - ld [wUnknownSerialFlag_d49a], a - ld [wUnknownSerialFlag_d49b], a - ld c, $0c + ld [wPrinterConnectionOpen], a + ld [wPrinterOpcode], a + ld c, $c call DelayFrames call SaveScreenTilesToBuffer1 xor a ld [$ffba], a call Func_e9ad3 call Func_e8783 - ld a, $03 + ld a, $3 ld [wcae2], a - call Func_e8efc + call Printer_CopyTileMapToPrinterTileBuffer call LoadScreenTilesFromBuffer1 call Func_e8d11 .asm_e8cfa xor a - ld [wUnknownSerialFlag_d49a], a - ld [wUnknownSerialFlag_d49b], a - call Func_e8f09 + ld [wPrinterConnectionOpen], a + ld [wPrinterOpcode], a + call Printer_CopyTileMapFromPrinterTileBuffer xor a ld [rIF], a pop af ld [rIE], a call Func_0f3d - call Func_e8f3b + call Printer_PlayMapMusic ret Func_e8d11: - call Func_e8f16 + call Printer_ResetJoypadHRAM .asm_e8d14 call JoypadLowSensitivity - call Func_e8eca + call Printer_CheckPressingB jr c, .asm_e8d33 - ld a, [wc6e8] + ld a, [wPrinterReceiveJumptableIndex] bit 7, a jr nz, .asm_e8d31 call Func_e87a8 @@ -847,13 +237,13 @@ Func_e8d35:: ; e8d35 (3a:4e79) push af xor a ld [wUpdateSpritesEnabled], a - ld [hItemCounter], a - call Func_e8f24 + ld [hCanceledPrinting], a + call Printer_PlayPrinterMusic ld a, [rIE] push af xor a ld [rIF], a - ld a, $09 + ld a, $9 ld [rIE], a call SaveScreenTilesToBuffer1 xor a @@ -862,64 +252,64 @@ Func_e8d35:: ; e8d35 (3a:4e79) call Func_e8783 ld a, $10 ld [wcae2], a - call Func_e8efc + call Printer_CopyTileMapToPrinterTileBuffer call LoadScreenTilesFromBuffer1 call Func_e8dfb jr c, .asm_e8ddc xor a - ld [wUnknownSerialFlag_d49a], a - ld [wUnknownSerialFlag_d49b], a + ld [wPrinterConnectionOpen], a + ld [wPrinterOpcode], a ld c, 12 call DelayFrames xor a ld [H_AUTOBGTRANSFERENABLED], a call Func_e98ec call Func_e8783 - ld a, $00 + ld a, $0 ld [wcae2], a - call Func_e8efc + call Printer_CopyTileMapToPrinterTileBuffer call LoadScreenTilesFromBuffer1 call Func_e8dfb jr c, .asm_e8ddc xor a - ld [wUnknownSerialFlag_d49a], a - ld [wUnknownSerialFlag_d49b], a + ld [wPrinterConnectionOpen], a + ld [wPrinterOpcode], a ld c, 12 call DelayFrames xor a ld [H_AUTOBGTRANSFERENABLED], a call Func_e9907 call Func_e8783 - ld a, $00 + ld a, $0 ld [wcae2], a - call Func_e8efc + call Printer_CopyTileMapToPrinterTileBuffer call LoadScreenTilesFromBuffer1 call Func_e8dfb jr c, .asm_e8ddc xor a - ld [wUnknownSerialFlag_d49a], a - ld [wUnknownSerialFlag_d49b], a + ld [wPrinterConnectionOpen], a + ld [wPrinterOpcode], a ld c, 12 call DelayFrames xor a ld [H_AUTOBGTRANSFERENABLED], a call Func_e9922 call Func_e8783 - ld a, $03 + ld a, $3 ld [wcae2], a - call Func_e8efc + call Printer_CopyTileMapToPrinterTileBuffer call LoadScreenTilesFromBuffer1 call Func_e8dfb .asm_e8ddc xor a - ld [wUnknownSerialFlag_d49a], a - ld [wUnknownSerialFlag_d49b], a + ld [wPrinterConnectionOpen], a + ld [wPrinterOpcode], a xor a ld [rIF], a pop af ld [rIE], a call Func_0f3d - call Func_e8f3b + call Printer_PlayMapMusic pop af ld [wUpdateSpritesEnabled], a ret @@ -930,12 +320,12 @@ Func_e8df4: ; e8df4 ret Func_e8dfb: ; e8dfb - call Func_e8f16 + call Printer_ResetJoypadHRAM .asm_e8dfe call JoypadLowSensitivity - call Func_e8eca + call Printer_CheckPressingB jr c, .asm_e8e1d - ld a, [wOverworldMap] + ld a, [wPrinterReceiveJumptableIndex] bit 7, a jr nz, .asm_e8e1b call Func_e87a8 @@ -958,25 +348,25 @@ String_e8e1f: ; e8e1f Func_e8e24: ; e8e24 xor a - ld [hItemCounter], a - call Func_e8f24 + ld [hCanceledPrinting], a + call Printer_PlayPrinterMusic call Func_ea3ea ld a, [rIE] push af xor a ld [rIF], a - ld a, $09 + ld a, $9 ld [rIE], a call Func_e8783 ld a, $13 ld [wcae2], a - call Func_e8efc - call Func_e8f16 + call Printer_CopyTileMapToPrinterTileBuffer + call Printer_ResetJoypadHRAM .asm_e8e45 call JoypadLowSensitivity - call Func_e8eca + call Printer_CheckPressingB jr c, .asm_e8e62 - ld a, [wOverworldMap] + ld a, [wPrinterReceiveJumptableIndex] bit 7, a jr nz, .asm_e8e62 call Func_e87a8 @@ -987,15 +377,15 @@ Func_e8e24: ; e8e24 .asm_e8e62 xor a - ld [wUnknownSerialFlag_d49a], a - ld [wUnknownSerialFlag_d49b], a - call Func_e8f09 + ld [wPrinterConnectionOpen], a + ld [wPrinterOpcode], a + call Printer_CopyTileMapFromPrinterTileBuffer xor a ld [rIF], a pop af ld [rIE], a call Func_0f3d - call Func_e8f3b + call Printer_PlayMapMusic ret Func_e8e79: ; e8e79 (3a:4e79) @@ -1008,17 +398,17 @@ Func_e8e79: ; e8e79 (3a:4e79) push af xor a ld [rIF], a - ld a, $09 + ld a, $9 ld [rIE], a call Func_e8783 ld a, $13 ld [wcae2], a ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a - call Func_e8efc + call Printer_CopyTileMapToPrinterTileBuffer call Func_ea573 .asm_e8e9c - ld a, [wOverworldMap] + ld a, [wPrinterReceiveJumptableIndex] bit 7, a jr nz, .asm_e8eae call Func_ea5d1 @@ -1028,10 +418,10 @@ Func_e8e79: ; e8e79 (3a:4e79) .asm_e8eae xor a - ld [wUnknownSerialFlag_d49a], a - ld [wUnknownSerialFlag_d49b], a + ld [wPrinterConnectionOpen], a + ld [wPrinterOpcode], a ld hl, wOAMBuffer + 32 * 4 - ld bc, $0020 + ld bc, 8 * 4 xor a call FillMemory xor a @@ -1044,54 +434,54 @@ Func_e8e79: ; e8e79 (3a:4e79) pop af ret -Func_e8eca: ; e8eca (3a:4eca) +Printer_CheckPressingB: ; e8eca (3a:4eca) ld a, [hJoyHeld] and B_BUTTON - jr nz, .asm_e8ed2 + jr nz, .quit and a ret -.asm_e8ed2 - ld a, [wOverworldMap] - cp $0c - jr nz, .asm_e8ef6 -.asm_e8ed9 - ld a, [wUnknownSerialFlag_d49b] +.quit + ld a, [wPrinterReceiveJumptableIndex] + cp $c + jr nz, .already_done +.wait_current_task + ld a, [wPrinterOpcode] and a - jr nz, .asm_e8ed9 + jr nz, .wait_current_task ld a, $16 - ld [wUnknownSerialFlag_d49b], a + ld [wPrinterOpcode], a ld a, $88 ld [rSB], a - ld a, $01 + ld a, $1 ld [rSC], a ld a, $81 ld [rSC], a -.asm_e8ef0 - ld a, [wUnknownSerialFlag_d49b] +.wait_send_cancel + ld a, [wPrinterOpcode] and a - jr nz, .asm_e8ef0 -.asm_e8ef6 - ld a, $01 - ld [hItemCounter], a + jr nz, .wait_send_cancel +.already_done + ld a, $1 + ld [hCanceledPrinting], a scf ret -Func_e8efc: ; e8efc (3a:4efc) +Printer_CopyTileMapToPrinterTileBuffer: ; e8efc (3a:4efc) coord hl, 0, 0 coord de, 0, 0, wPrinterTileBuffer ld bc, SCREEN_HEIGHT * SCREEN_WIDTH call CopyData ret -Func_e8f09: ; e8f09 (3a:4f09) +Printer_CopyTileMapFromPrinterTileBuffer: ; e8f09 (3a:4f09) coord hl, 0, 0, wPrinterTileBuffer coord de, 0, 0 ld bc, SCREEN_HEIGHT * SCREEN_WIDTH call CopyData ret -Func_e8f16: ; e8f16 (3a:4f16) +Printer_ResetJoypadHRAM: ; e8f16 (3a:4f16) xor a ld [hJoyLast], a ld [hJoyReleased], a @@ -1101,8 +491,8 @@ Func_e8f16: ; e8f16 (3a:4f16) ld [hJoy6], a ret -Func_e8f24: ; e8f24 (3a:4f24) - call Func_e8f42 +Printer_PlayPrinterMusic: ; e8f24 (3a:4f24) + call Printer_FadeOutMusicAndWait ld a, [wAudioROMBank] ld [wAudioSavedROMBank], a ld a, BANK(Music_GBPrinter) @@ -1112,19 +502,19 @@ Func_e8f24: ; e8f24 (3a:4f24) call PlaySound ret -Func_e8f3b: ; e8f3b (3a:4f3b) - call Func_e8f42 +Printer_PlayMapMusic: ; e8f3b (3a:4f3b) + call Printer_FadeOutMusicAndWait call PlayDefaultMusic ret -Func_e8f42: ; e8f42 (3a:4f42) +Printer_FadeOutMusicAndWait: ; e8f42 (3a:4f42) ld a, $4 ld [wAudioFadeOutControl], a call StopAllMusic -.asm_e8f4a +.wait_music_stop ld a, [wAudioFadeOutControl] and a - jr nz, .asm_e8f4a + jr nz, .wait_music_stop ret GBPrinter_CheckForErrors: ; e8f51 (3a:4f51) @@ -1139,7 +529,7 @@ GBPrinter_CheckForErrors: ; e8f51 (3a:4f51) .check_other_errors ld a, [wc971] - and $e0 + and %11100000 ret z bit 7, a jr nz, .error1 @@ -1176,7 +566,7 @@ GBPrinter_UpdateStatusMessage: pop af ld e, a ld d, $0 - ld hl, Table_e8fca + ld hl, .PrinterStatusMessages add hl, de add hl, de ld e, [hl] @@ -1185,7 +575,7 @@ GBPrinter_UpdateStatusMessage: coord hl, 1, 7 call PlaceString coord hl, 2, 15 - ld de, String_e8fb8 + ld de, .PressBToCancel call PlaceString ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a @@ -1193,10 +583,10 @@ GBPrinter_UpdateStatusMessage: ld [wPrinterStatusIndicator], a ret -String_e8fb8: +.PressBToCancel: db "Press B to Cancel@" -Table_e8fca: +.PrinterStatusMessages: dw .Blank dw .CheckingLink dw .Transmitting @@ -1257,7 +647,7 @@ Func_e910a: call Func_e91b5 coord hl, 19, 0 call Func_e91b5 - ld a, $04 + ld a, $4 coord hl, 0, 0 ld [hl], a coord hl, 0, 17 @@ -1312,9 +702,9 @@ Func_e910a: Func_e91a9: ld c, SCREEN_WIDTH / 2 .asm_e91ab - ld [hl], $00 + ld [hl], $0 inc hl - ld [hl], $01 + ld [hl], $1 inc hl dec c jr nz, .asm_e91ab @@ -1324,9 +714,9 @@ Func_e91b5: ld c, SCREEN_HEIGHT / 2 ld de, SCREEN_WIDTH .asm_e91ba - ld [hl], $02 + ld [hl], $2 add hl, de - ld [hl], $03 + ld [hl], $3 add hl, de dec c jr nz, .asm_e91ba @@ -1427,7 +817,7 @@ Func_e988a: ld [hl], a coord hl, 4, 9 ld de, wBoxSpecies - ld c, $03 + ld c, $3 call Func_e994e ret diff --git a/engine/printer/serial.asm b/engine/printer/serial.asm new file mode 100755 index 00000000..0c9a70ed --- /dev/null +++ b/engine/printer/serial.asm @@ -0,0 +1,620 @@ +Func_e8783: ; e8783 (3a:4783) + ld a, 9 +Func_e8785: + push af + ld hl, wPrinterData + ld bc, wPrinterDataEnd - wPrinterData + xor a + call Printer_FillMemory + xor a + ld [rSB], a + ld [rSC], a + ld [wPrinterOpcode], a + ld hl, wPrinterConnectionOpen + set 0, [hl] + ld a, [wPrinterSettings] + ld [wPrinterSettingsTempCopy], a + pop af + ld [wcaf4], a + ret + +; e87a8 +Func_e87a8: ; e87a8 (3a:47a8) + ld a, [wPrinterReceiveJumptableIndex] + ld e, a + ld d, 0 + ld hl, .Jumptable + add hl, de + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + jp [hl] + +.Jumptable: + dw Printer_InitSerial ; 00 + dw Func_e88c9 ; 01 + dw Func_e88a6 ; 02 + dw Func_e881f ; 03 + dw Func_e8906 ; 04 + dw Func_e88b4 ; 05 + dw Func_e884b ; 06 + dw Func_e8906 ; 07 + dw Func_e88a6 ; 08 + dw Func_e8864 ; 09 + dw Func_e8906 ; 0a + dw Func_e88a6 ; 0b + dw Func_e8927 ; 0c + dw Printer_Quit ; 0d + dw Printer_Next_ ; 0e + dw Func_e88a6 ; 10 + dw Func_e8889 ; 11 + dw Printer_LoopBack ; 12 + dw Func_e8936 ; 13 + dw Func_e8939 ; 14 + +Printer_Next: + ld hl, wPrinterReceiveJumptableIndex + inc [hl] + ret + +Printer_Back: + ld hl, wPrinterReceiveJumptableIndex + dec [hl] + ret + +Printer_Quit: + xor a + ld [wc971], a + ld hl, wPrinterReceiveJumptableIndex + set 7, [hl] + ret + +Printer_Next_: + call Printer_Next + ret + +Printer_LoopBack: + ld a, $1 + ld [wPrinterReceiveJumptableIndex], a + ret + +Printer_InitSerial: + call Func_e8981 + ld hl, PrinterDataPacket1 + call Func_e8968 + xor a + ld [wPrinterDataSize], a + ld [wPrinterDataSize + 1], a + ld a, [wcaf4] + ld [wc6e9], a + call Printer_Next + call Func_e8949 + ld a, $1 + ld [wPrinterStatusIndicator], a + ret + +Func_e881f: + call Func_e8981 + ld hl, wc6e9 + ld a, [hl] + and a + jr z, Func_e884b + ld hl, PrinterDataPacket3 + call Func_e8968 + call Func_e89e6 + ld a, $80 + ld [wPrinterDataSize], a + ld a, $2 + ld [wPrinterDataSize + 1], a + call ComputePrinterChecksum + call Printer_Next + call Func_e8949 + ld a, $2 + ld [wPrinterStatusIndicator], a + ret + +Func_e884b: + ld a, $6 + ld [wPrinterReceiveJumptableIndex], a + ld hl, PrinterDataPacket4 + call Func_e8968 + xor a + ld [wPrinterDataSize], a + ld [wPrinterDataSize + 1], a + call Printer_Next + call Func_e8949 + ret + +Func_e8864: + call Func_e8981 + ld hl, PrinterDataPacket2 + call Func_e8968 + call Func_e89cf + ld a, $4 + ld [wPrinterDataSize], a + ld a, $0 + ld [wPrinterDataSize + 1], a + call ComputePrinterChecksum + call Printer_Next + call Func_e8949 + ld a, $3 + ld [wPrinterStatusIndicator], a + ret + +Func_e8889: + call Func_e8981 + ld hl, PrinterDataPacket1 + call Func_e8968 + xor a + ld [wPrinterDataSize], a + ld [wPrinterDataSize + 1], a + ld a, [wcaf4] + ld [wc6e9], a + call Printer_Next + call Func_e8949 + ret + +Func_e88a6: + ld hl, wc973 + inc [hl] + ld a, [hl] + cp a, $6 + ret c + xor a + ld [hl], a + call Printer_Next + ret + +Func_e88b4: + ld hl, wc973 + inc [hl] + ld a, [hl] + cp a, $6 + ret c + xor a + ld [hl], a + ld hl, wc6e9 + dec [hl] + call Printer_Back + call Printer_Back + ret + +Func_e88c9: + ld a, [wPrinterOpcode] + and a + ret nz + ld a, [wc970] + cp a, $ff + jr nz, .asm_e88dc + ld a, [wc971] + cp a, $ff + jr z, .asm_e88f8 +.asm_e88dc + ld a, [wc970] + cp a, $81 + jr nz, .asm_e88f8 + ld a, [wc971] + cp a, $0 + jr nz, .asm_e88f8 + ld hl, wPrinterConnectionOpen + set 1, [hl] + ld a, $5 + ld [wc972], a + call Printer_Next + ret + +.asm_e88f8 + ld a, $ff + ld [wc970], a + ld [wc971], a + ld a, $e + ld [wPrinterReceiveJumptableIndex], a + ret + +Func_e8906: + ld a, [wPrinterOpcode] + and a + ret nz + ld a, [wc971] + and a, $f0 + jr nz, .asm_e8921 + ld a, [wc971] + and a, $1 + jr nz, .asm_e891d + call Printer_Next + ret + +.asm_e891d + call Printer_Back + ret + +.asm_e8921 + ld a, $12 + ld [wPrinterReceiveJumptableIndex], a + ret + +Func_e8927: + ld a, [wPrinterOpcode] + and a + ret nz + ld a, [wc971] + and a, $f3 + ret nz + call Printer_Next + ret + +Func_e8936: + call Printer_Next +Func_e8939: + ld a, [wPrinterOpcode] + and a + ret nz + ld a, [wc971] + and a, $f0 + ret nz + xor a + ld [wPrinterReceiveJumptableIndex], a + ret + +Func_e8949: +.wait_printer_operation + ld a, [wPrinterOpcode] + and a + jr nz, .wait_printer_operation + xor a + ld [wc974], a + ld [wc975], a + ld a, $1 + ld [wPrinterOpcode], a + ld a, $88 + ld [rSB], a + ld a, $1 + ld [rSC], a + ld a, $81 + ld [rSC], a + ret + +Func_e8968: + ld a, [hli] + ld [wPrinterDataHeader], a + ld a, [hli] + ld [wPrinterDataHeader + 1], a + ld a, [hli] + ld [wPrinterDataHeader + 2], a + ld a, [hli] + ld [wPrinterDataHeader + 3], a + ld a, [hli] + ld [wPrinterChecksum], a + ld a, [hl] + ld [wPrinterChecksum + 1], a + ret + +Func_e8981: + xor a + ld hl, wPrinterDataHeader + ld [hli], a + ld [hli], a + ld [hli], a + ld [hl], a + ld hl, wPrinterChecksum + ld [hli], a + ld [hl], a + xor a + ld [wPrinterDataSize], a + ld [wPrinterDataSize + 1], a + ld hl, wPrinterSerialReceived + ld bc, $280 + call Printer_FillMemory + ret + +ComputePrinterChecksum: + ld hl, $0 + ld bc, $4 + ld de, wPrinterDataHeader + call .AddToChecksum + ld a, [wPrinterDataSize] + ld c, a + ld a, [wPrinterDataSize + 1] + ld b, a + ld de, wPrinterSerialReceived + call .AddToChecksum + ld a, l + ld [wPrinterChecksum], a + ld a, h + ld [wPrinterChecksum + 1], a + ret + +.AddToChecksum: +.loop + ld a, [de] + inc de + add l + jr nc, .no_carry + inc h +.no_carry + ld l, a + dec bc + ld a, c + or b + jr nz, .loop + ret + +Func_e89cf: + ld a, $1 + ld [wPrinterSerialReceived], a + ld a, [wcae2] + ld [wPrinterStatusReceived], a + ld a, $e4 + ld [wc6f2], a + ld a, [wPrinterSettingsTempCopy] + ld [wc6f3], a + ret + +Func_e89e6: + ld a, [wc6e9] + ld b, a + ld a, [wcaf4] + sub b + ld hl, wPrinterTileBuffer + ld de, $28 +.asm_e89f4 + and a + jr z, .asm_e89fb + add hl, de + dec a + jr .asm_e89f4 + +.asm_e89fb + ld e, l + ld d, h + ld hl, wPrinterSerialReceived + ld c, $28 +.asm_e8a02 + ld a, [de] + inc de + push bc + push de + push hl + swap a + ld d, a + and a, $f0 + ld e, a + ld a, d + and a, $f + ld d, a + and a, $8 + ld a, d + jr nz, .asm_e8a1a + or a, $90 + jr .asm_e8a1c + +.asm_e8a1a + or a, $80 +.asm_e8a1c + ld d, a + ld bc, $3a01 + call CopyVideoData + pop hl + ld de, $10 + add hl, de + pop de + pop bc + dec c + jr nz, .asm_e8a02 + ret + +Printer_FillMemory: ; e8a2e (3a:4a2e) + push de + ld e, a +.loop + ld [hl], e + inc hl + dec bc + ld a, c + or b + jr nz, .loop + ld a, e + pop de + ret + +PrinterDataPacket1: + db 1, 0, $00, 0 + dw 1 +PrinterDataPacket2: + db 2, 0, $04, 0 + dw 0 +PrinterDataPacket3: + db 4, 0, $80, 2 + dw 0 +PrinterDataPacket4: + db 4, 0, $00, 0 + dw 4 +PrinterDataPacket5: ; unused + db 8, 0, $00, 0 + dw 8 +PrinterDataPacket6: ; unused + db 15, 0, $00, 0 + dw 15 + +PrinterSerial_: ; e8a5e (3a:4a5e) + ld a, [wPrinterOpcode] + ld e, a + ld d, 0 + ld hl, .Jumptable + add hl, de + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + jp [hl] + +.Jumptable: + dw .Nop + + dw .SignalTransmissionStart + dw .SendHeaderByte1 + dw .SendHeaderByte2 + dw .SendHeaderByte3 + dw .SendHeaderByte4 + dw .DataByte + dw .SendChecksumLo + dw .SendChecksumHi + dw .SignalTransmissionEnd + dw .Receive1 + dw .Receive2 + + dw .SignalTransmissionStart + dw .Send_0F + dw .Send_00 + dw .Send_00 + dw .Send_00 + dw .Send_0F + dw .Send_00 + dw .SignalTransmissionEnd + dw .Receive1 + dw .Receive2_ + + dw .SignalTransmissionStart + dw .SignalQuit + dw .Send_00 + dw .Send_00 + dw .Send_00 + dw .SignalQuit + dw .Send_00 + dw .SignalTransmissionEnd + dw .Receive1 + dw .Receive2 + +.NextInstruction: + ld hl, wPrinterOpcode + inc [hl] + ret + +.Nop: + ret + +.SignalTransmissionStart: + ld a, $33 + call .SendByte + call .NextInstruction + ret + +.SendHeaderByte1: + ld a, [wPrinterDataHeader] + call .SendByte + call .NextInstruction + ret + +.SendHeaderByte2: + ld a, [wPrinterDataHeader + 1] + call .SendByte + call .NextInstruction + ret + +.SendHeaderByte3: + ld a, [wPrinterDataHeader + 2] + call .SendByte + call .NextInstruction + ret + +.SendHeaderByte4: + ld a, [wPrinterDataHeader + 3] + call .SendByte + call .NextInstruction + ret + +.DataByte: + ld hl, wPrinterDataSize + ld e, [hl] + inc hl + ld d, [hl] + ld a, e + or d + jr z, .sent_last_byte + dec de + ld [hl], d + dec hl + ld [hl], e + ld a, [wc974] + ld e, a + ld a, [wc975] + ld d, a + ld hl, wPrinterSerialReceived + add hl, de + inc de + ld a, e + ld [wc974], a + ld a, d + ld [wc975], a + ld a, [hl] + call .SendByte + ret + +.sent_last_byte + call .NextInstruction +.SendChecksumLo: + ld a, [wPrinterChecksum] + call .SendByte + call .NextInstruction + ret + +.SendChecksumHi: + ld a, [wPrinterChecksum + 1] + call .SendByte + call .NextInstruction + ret + +.SignalTransmissionEnd: + ld a, $0 + call .SendByte + call .NextInstruction + ret + +.Receive1: + ld a, [rSB] + ld [wc970], a + ld a, $0 + call .SendByte + call .NextInstruction + ret + +.Receive2: + ld a, [rSB] + ld [wc971], a + xor a + ld [wPrinterOpcode], a + ret + +.Send_0F: + ld a, $f + call .SendByte + call .NextInstruction + ret + +.Send_00: + ld a, $0 + call .SendByte + call .NextInstruction + ret + +.SignalQuit: + ld a, $8 + call .SendByte + call .NextInstruction + ret + +.SendByte: + ld [rSB], a + ld a, $1 + ld [rSC], a + ld a, $81 + ld [rSC], a + ret + +.Receive2_: + ld a, [rSB] + ld [wc971], a + xor a + ld [wPrinterOpcode], a + ret diff --git a/engine/unknown_ea3ea.asm b/engine/unknown_ea3ea.asm index c00785b4..39f3de7e 100755 --- a/engine/unknown_ea3ea.asm +++ b/engine/unknown_ea3ea.asm @@ -398,7 +398,7 @@ Func_ea6d2: ; ea6d2 (3a:66d2) ld a, [$c971] cp a, $00 jr nz, .asm_ea6fb - ld hl, wUnknownSerialFlag_d49a + ld hl, wPrinterConnectionOpen set 1, [hl] call Func_ea606 ret @@ -441,7 +441,7 @@ Func_ea721: ; ea721 (3a:6721) Func_ea72f: ; ea72f (3a:672f) call Func_ea606 Func_ea732: ; ea732 (3a:6732) - ld a, [wUnknownSerialFlag_d49b] + ld a, [wPrinterOpcode] and a ret nz ld a, [$c971] @@ -452,7 +452,7 @@ Func_ea732: ; ea732 (3a:6732) ret Func_ea742: ; ea742 (3a:6742) - ld a, [wUnknownSerialFlag_d49b] + ld a, [wPrinterOpcode] and a jr nz, .asm_ea74a and a @@ -464,11 +464,11 @@ Func_ea742: ; ea742 (3a:6742) Func_ea74c: ; ea74c (3a:674c) .asm_ea74c - ld a, [wUnknownSerialFlag_d49b] + ld a, [wPrinterOpcode] and a jr nz, .asm_ea74c ld a, $01 - ld [wUnknownSerialFlag_d49b], a + ld [wPrinterOpcode], a xor a ld [$c974], a ld [$c975], a diff --git a/home.asm b/home.asm index 426812e4..50469047 100644 --- a/home.asm +++ b/home.asm @@ -2120,15 +2120,15 @@ ChooseFlyDestination:: ; 2f9a (0:2f9a) res 4, [hl] jpba LoadTownMap_Fly -Func_2fa7:: ; 2fa7 (0:2fa7) - homecall Func_e8a5e +PrinterSerial:: ; 2fa7 (0:2fa7) + homecall PrinterSerial_ ret SerialFunction:: ; 2fb7 (0:2fb7) - ld a, [wUnknownSerialFlag_d49a] + ld a, [wPrinterConnectionOpen] bit 0, a ret z - ld a, [wUnknownSerialFlag_d49b] + ld a, [wPrinterOpcode] and a ret nz ld hl, wOverworldMap+650 @@ -2139,7 +2139,7 @@ SerialFunction:: ; 2fb7 (0:2fb7) xor a ld [hl], a ld a, $0c - ld [wUnknownSerialFlag_d49b], a + ld [wPrinterOpcode], a ld a, $88 ld [rSB], a ld a, $1 diff --git a/home/serial.asm b/home/serial.asm index c8e64f38..c8c7cbe9 100644 --- a/home/serial.asm +++ b/home/serial.asm @@ -3,9 +3,9 @@ Serial:: ; 1f78 (0:1f78) push bc push de push hl - ld a, [wUnknownSerialFlag_d49a] - bit 0,a - jp nz,Func_2162 + ld a, [wPrinterConnectionOpen] + bit 0, a + jp nz, PrinterSerial__ ld a, [hSerialConnectionStatus] inc a jr z, .connectionNotYetEstablished @@ -314,8 +314,8 @@ Serial_TryEstablishingExternallyClockedConnection:: ; 22fa (0:22fa) ld [rSC], a ret -Func_2162:: ; 2162 (0:2162) - call Func_2fa7 +PrinterSerial__:: ; 2162 (0:2162) + call PrinterSerial pop hl pop de pop bc diff --git a/hram.asm b/hram.asm index 5138b239..0b5cb8b0 100644 --- a/hram.asm +++ b/hram.asm @@ -271,6 +271,8 @@ H_CURRENTSPRITEOFFSET EQU $FFDA ; multiple of $10 hItemCounter EQU $FFDB +hCanceledPrinting EQU $FFDB + hGymGateIndex EQU $FFDB hGymTrashCanRandNumMask EQU $FFDB diff --git a/wram.asm b/wram.asm index bff4283f..d967a8e8 100755 --- a/wram.asm +++ b/wram.asm @@ -420,13 +420,17 @@ wYellowIntroAnimatedObjectStructPointer:: ; c636 ; c698 ds 80 -wTempPic:: +wTempPic:: ; c6e8 +wPrinterData:: ; c6e8 wOverworldMap:: ; c6e8 ; ds 1300 -wc6e8:: ; c6e8 +wPrinterReceiveJumptableIndex:: ; c6e8 ds 1 wc6e9:: ; c6e9 ds 1 + +; Printer data header +wPrinterDataHeader:: ; c6ea wc6ea:: ; c6ea ds 1 wc6eb:: ; c6eb @@ -435,14 +439,18 @@ wc6ec:: ; c6ec ds 1 wc6ed:: ; c6ed ds 1 -wc6ee:: ; c6ee - ds 1 -wc6ef:: ; c6ef - ds 1 -wc6f0:: ; c6f0 +wPrinterChecksum:: ; c6ee + dw + +wPrinterSerialReceived:: ; c6f0 ds 1 -wc6f1:: ; c6f1 +wPrinterStatusReceived:: ; c6f1 +; bit 7: set if error 1 (battery low) +; bit 6: set if error 4 (too hot or cold) +; bit 5: set if error 3 (paper jammed or empty) +; if this and the previous byte are both $ff: error 2 (connection error) ds 1 + wc6f2:: ; c6f2 ds 1 wc6f3:: ; c6f3 @@ -472,20 +480,20 @@ wc974:: ; c974 ds 1 wc975:: ; c975 ds 1 -wc976:: ; c976 - ds 1 -wc977:: ; c977 - ds 1 +wPrinterDataSize:: ; c976 + dw wPrinterTileBuffer:: ; c978 ds SCREEN_HEIGHT * SCREEN_WIDTH wPrinterStatusIndicator:: ; cae0 ds 2 wcae2:: ; cae2 ds 1 -wcae3:: ; cae3 +wPrinterSettingsTempCopy:: ; cae3 ds 17 wcaf4:: ; caf4 ds 1 +wPrinterDataEnd:: ; caf5 + wcaf5:: ; caf5 ds 1 wcaf6:: ; caf6 @@ -2780,11 +2788,11 @@ wPreventBlackout:: ds 1 ; d492 wd495:: ds 1 wd496:: ds 1 wd497:: ds 1 -wd498:: ds 1 +wPrinterSettings:: ds 1 wUnknownSerialFlag_d499:: ds 1 ; d498 -wUnknownSerialFlag_d49a:: ds 1 ; d499 -wUnknownSerialFlag_d49b:: ds 1 ; d49a +wPrinterConnectionOpen:: ds 1 ; d499 +wPrinterOpcode:: ds 1 ; d49a wd49c:: ds 1 ; d49b ds 19 -- cgit v1.3.1-sl0p From aafed67874b49180b4640eeaf5b20981c24ce9fc Mon Sep 17 00:00:00 2001 From: pikalaxalt Date: Mon, 6 Jun 2016 08:47:11 -0400 Subject: More printer labels --- constants/hide_show_constants.asm | 3 ++ engine/bank3c.asm | 14 ++++-- engine/printer.asm | 59 +++++++++++++---------- engine/printer/serial.asm | 98 +++++++++++++++++++-------------------- engine/surfing_minigame.asm | 2 +- home/overworld.asm | 11 +++-- wram.asm | 6 ++- 7 files changed, 111 insertions(+), 82 deletions(-) (limited to 'wram.asm') diff --git a/constants/hide_show_constants.asm b/constants/hide_show_constants.asm index 10cffac8..fb4116d7 100755 --- a/constants/hide_show_constants.asm +++ b/constants/hide_show_constants.asm @@ -240,3 +240,6 @@ const HS_SEAFOAM_ISLANDS_5_BOULDER_1 ; E9 const HS_SEAFOAM_ISLANDS_5_BOULDER_2 ; EA const HS_ARTICUNO ; EB + const HS_DAISY_SITTING_COPY ; EC + const HS_DAISY_WALKING_COPY ; ED + const HS_TOWN_MAP_COPY ; EE diff --git a/engine/bank3c.asm b/engine/bank3c.asm index 44382257..4fa185e0 100644 --- a/engine/bank3c.asm +++ b/engine/bank3c.asm @@ -264,6 +264,7 @@ Func_f0a54:: ; f0a54 (3c:4a54) ret Func_f0a55:: ; f0a55 (3c:4a55) +; referenced in an unused function ld hl, Pointer_f0a76 ; 3c:4a76 .loop ld a, [hli] @@ -281,7 +282,7 @@ Func_f0a55:: ; f0a55 (3c:4a55) .asm_f0a68 ld a, [hli] ld c, a - ld b, $0 + ld b, 0 ld a, [hli] ld h, [hl] ld l, a @@ -290,8 +291,15 @@ Func_f0a55:: ; f0a55 (3c:4a55) ret Pointer_f0a76:: ; f0a76 (3c:4a76) - db $27, $07, $7b, $4a, $ff - db $01, $ec, $02, $ed, $03, $ee, $ff + dbbw BLUES_HOUSE, Pointer_f0a7bEnd - Pointer_f0a7b, Pointer_f0a7b + db $ff + +Pointer_f0a7b: + db 1, HS_DAISY_SITTING_COPY + db 2, HS_DAISY_WALKING_COPY + db 3, HS_TOWN_MAP_COPY + db $ff +Pointer_f0a7bEnd: Func_f0a82: ; f0a82 ld a, [wd472] diff --git a/engine/printer.asm b/engine/printer.asm index aa5c6ced..38730aa1 100644 --- a/engine/printer.asm +++ b/engine/printer.asm @@ -1,3 +1,14 @@ + const_def + const PRINTER_STATUS_BLANK + const PRINTER_STATUS_CHECKING_LINK + const PRINTER_STATUS_TRANSMITTING + const PRINTER_STATUS_PRINTING + const PRINTER_ERROR_1 + const PRINTER_ERROR_2 + const PRINTER_ERROR_3 + const PRINTER_ERROR_4 + const PRINTER_ERROR_WRONG_DEVICE + INCLUDE "engine/printer/serial.asm" Func_e8b74: ; e8b74 (3a:4b74) @@ -5,7 +16,7 @@ Func_e8b74: ; e8b74 (3a:4b74) push af xor a ld [wUpdateSpritesEnabled], a - ld [$ffdb], a + ld [hCanceledPrinting], a call Printer_PlayPrinterMusic ld a, [rIE] push af @@ -14,7 +25,7 @@ Func_e8b74: ; e8b74 (3a:4b74) ld a, $9 ld [rIE], a xor a - ld [$ffba], a + ld [H_AUTOBGTRANSFERENABLED], a call Func_e8c30 call Func_e8785 ld a, [wcaf9] @@ -32,7 +43,7 @@ Func_e8b74: ; e8b74 (3a:4b74) callab Func_401c2 callab Func_4027c ld a, $1 - ld [$ffba], a + ld [H_AUTOBGTRANSFERENABLED], a call Func_e8c0c jr c, .asm_e8bf4 ld a, [wcaf9] @@ -45,7 +56,7 @@ Func_e8b74: ; e8b74 (3a:4b74) call DelayFrames call SaveScreenTilesToBuffer1 xor a - ld [$ffba], a + ld [H_AUTOBGTRANSFERENABLED], a call Func_e8c50 ld a, $7 call Func_e8785 @@ -54,7 +65,7 @@ Func_e8b74: ; e8b74 (3a:4b74) call Printer_CopyTileMapToPrinterTileBuffer call LoadScreenTilesFromBuffer1 ld a, $1 - ld [$ffba], a + ld [H_AUTOBGTRANSFERENABLED], a call Func_e8c0c .asm_e8bf4 xor a @@ -64,7 +75,7 @@ Func_e8b74: ; e8b74 (3a:4b74) ld [rIF], a pop af ld [rIE], a - call Func_0f3d + call ReloadMapAfterPrinter call Printer_PlayMapMusic pop af ld [wUpdateSpritesEnabled], a @@ -76,7 +87,7 @@ Func_e8c0c: call JoypadLowSensitivity call Printer_CheckPressingB jr c, .asm_e8c2e - ld a, [wPrinterReceiveJumptableIndex] + ld a, [wPrinterSendState] bit 7, a jr nz, .asm_e8c2c call Func_e87a8 @@ -119,7 +130,7 @@ Func_e8c50: Func_e8c5c: xor a - ld [$ffdb], a + ld [hCanceledPrinting], a call Printer_PlayPrinterMusic call Func_e910a ld a, [rIE] @@ -137,7 +148,7 @@ Func_e8c5c: call JoypadLowSensitivity call Printer_CheckPressingB jr c, .asm_e8c9a - ld a, [wPrinterReceiveJumptableIndex] + ld a, [wPrinterSendState] bit 7, a jr nz, .asm_e8c9a call Func_e87a8 @@ -155,13 +166,13 @@ Func_e8c5c: ld [rIF], a pop af ld [rIE], a - call Func_0f3d + call ReloadMapAfterPrinter call Printer_PlayMapMusic ret Func_e8cb1: xor a - ld [$ffdb], a + ld [hCanceledPrinting], a call Printer_PlayPrinterMusic call _DisplayDiploma ld a, [rIE] @@ -183,7 +194,7 @@ Func_e8cb1: call DelayFrames call SaveScreenTilesToBuffer1 xor a - ld [$ffba], a + ld [H_AUTOBGTRANSFERENABLED], a call Func_e9ad3 call Func_e8783 ld a, $3 @@ -200,7 +211,7 @@ Func_e8cb1: ld [rIF], a pop af ld [rIE], a - call Func_0f3d + call ReloadMapAfterPrinter call Printer_PlayMapMusic ret @@ -210,7 +221,7 @@ Func_e8d11: call JoypadLowSensitivity call Printer_CheckPressingB jr c, .asm_e8d33 - ld a, [wPrinterReceiveJumptableIndex] + ld a, [wPrinterSendState] bit 7, a jr nz, .asm_e8d31 call Func_e87a8 @@ -308,7 +319,7 @@ Func_e8d35:: ; e8d35 (3a:4e79) ld [rIF], a pop af ld [rIE], a - call Func_0f3d + call ReloadMapAfterPrinter call Printer_PlayMapMusic pop af ld [wUpdateSpritesEnabled], a @@ -325,7 +336,7 @@ Func_e8dfb: ; e8dfb call JoypadLowSensitivity call Printer_CheckPressingB jr c, .asm_e8e1d - ld a, [wPrinterReceiveJumptableIndex] + ld a, [wPrinterSendState] bit 7, a jr nz, .asm_e8e1b call Func_e87a8 @@ -366,7 +377,7 @@ Func_e8e24: ; e8e24 call JoypadLowSensitivity call Printer_CheckPressingB jr c, .asm_e8e62 - ld a, [wPrinterReceiveJumptableIndex] + ld a, [wPrinterSendState] bit 7, a jr nz, .asm_e8e62 call Func_e87a8 @@ -384,7 +395,7 @@ Func_e8e24: ; e8e24 ld [rIF], a pop af ld [rIE], a - call Func_0f3d + call ReloadMapAfterPrinter call Printer_PlayMapMusic ret @@ -408,7 +419,7 @@ Func_e8e79: ; e8e79 (3a:4e79) call Printer_CopyTileMapToPrinterTileBuffer call Func_ea573 .asm_e8e9c - ld a, [wPrinterReceiveJumptableIndex] + ld a, [wPrinterSendState] bit 7, a jr nz, .asm_e8eae call Func_ea5d1 @@ -442,7 +453,7 @@ Printer_CheckPressingB: ; e8eca (3a:4eca) ret .quit - ld a, [wPrinterReceiveJumptableIndex] + ld a, [wPrinterSendState] cp $c jr nz, .already_done .wait_current_task @@ -536,19 +547,19 @@ GBPrinter_CheckForErrors: ; e8f51 (3a:4f51) bit 6, a jr nz, .error4 ; error 3 - ld a, 6 + ld a, PRINTER_ERROR_3 jr .load_status .error4 - ld a, 7 + ld a, PRINTER_ERROR_4 jr .load_status .error1 - ld a, 4 + ld a, PRINTER_ERROR_1 jr .load_status .error2 - ld a, 5 + ld a, PRINTER_ERROR_2 .load_status ld [wPrinterStatusIndicator], a ret diff --git a/engine/printer/serial.asm b/engine/printer/serial.asm index 0c9a70ed..568a00f8 100755 --- a/engine/printer/serial.asm +++ b/engine/printer/serial.asm @@ -20,7 +20,7 @@ Func_e8785: ; e87a8 Func_e87a8: ; e87a8 (3a:47a8) - ld a, [wPrinterReceiveJumptableIndex] + ld a, [wPrinterSendState] ld e, a ld d, 0 ld hl, .Jumptable @@ -54,19 +54,19 @@ Func_e87a8: ; e87a8 (3a:47a8) dw Func_e8939 ; 14 Printer_Next: - ld hl, wPrinterReceiveJumptableIndex + ld hl, wPrinterSendState inc [hl] ret Printer_Back: - ld hl, wPrinterReceiveJumptableIndex + ld hl, wPrinterSendState dec [hl] ret Printer_Quit: xor a ld [wc971], a - ld hl, wPrinterReceiveJumptableIndex + ld hl, wPrinterSendState set 7, [hl] ret @@ -76,60 +76,60 @@ Printer_Next_: Printer_LoopBack: ld a, $1 - ld [wPrinterReceiveJumptableIndex], a + ld [wPrinterSendState], a ret Printer_InitSerial: - call Func_e8981 + call ResetPrinterData ld hl, PrinterDataPacket1 - call Func_e8968 + call CopyPrinterDataHeader xor a ld [wPrinterDataSize], a ld [wPrinterDataSize + 1], a ld a, [wcaf4] ld [wc6e9], a call Printer_Next - call Func_e8949 - ld a, $1 + call Printer_PrepareToSend + ld a, PRINTER_STATUS_CHECKING_LINK ld [wPrinterStatusIndicator], a ret Func_e881f: - call Func_e8981 + call ResetPrinterData ld hl, wc6e9 ld a, [hl] and a jr z, Func_e884b ld hl, PrinterDataPacket3 - call Func_e8968 + call CopyPrinterDataHeader call Func_e89e6 - ld a, $80 + ld a, (wPrinterSendDataSourceEnd - wPrinterSendDataSource) % $100 ld [wPrinterDataSize], a - ld a, $2 + ld a, (wPrinterSendDataSourceEnd - wPrinterSendDataSource) / $100 ld [wPrinterDataSize + 1], a call ComputePrinterChecksum call Printer_Next - call Func_e8949 - ld a, $2 + call Printer_PrepareToSend + ld a, PRINTER_STATUS_TRANSMITTING ld [wPrinterStatusIndicator], a ret Func_e884b: ld a, $6 - ld [wPrinterReceiveJumptableIndex], a + ld [wPrinterSendState], a ld hl, PrinterDataPacket4 - call Func_e8968 + call CopyPrinterDataHeader xor a ld [wPrinterDataSize], a ld [wPrinterDataSize + 1], a call Printer_Next - call Func_e8949 + call Printer_PrepareToSend ret Func_e8864: - call Func_e8981 + call ResetPrinterData ld hl, PrinterDataPacket2 - call Func_e8968 + call CopyPrinterDataHeader call Func_e89cf ld a, $4 ld [wPrinterDataSize], a @@ -137,22 +137,22 @@ Func_e8864: ld [wPrinterDataSize + 1], a call ComputePrinterChecksum call Printer_Next - call Func_e8949 - ld a, $3 + call Printer_PrepareToSend + ld a, PRINTER_STATUS_PRINTING ld [wPrinterStatusIndicator], a ret Func_e8889: - call Func_e8981 + call ResetPrinterData ld hl, PrinterDataPacket1 - call Func_e8968 + call CopyPrinterDataHeader xor a ld [wPrinterDataSize], a ld [wPrinterDataSize + 1], a ld a, [wcaf4] ld [wc6e9], a call Printer_Next - call Func_e8949 + call Printer_PrepareToSend ret Func_e88a6: @@ -209,7 +209,7 @@ Func_e88c9: ld [wc970], a ld [wc971], a ld a, $e - ld [wPrinterReceiveJumptableIndex], a + ld [wPrinterSendState], a ret Func_e8906: @@ -231,7 +231,7 @@ Func_e8906: .asm_e8921 ld a, $12 - ld [wPrinterReceiveJumptableIndex], a + ld [wPrinterSendState], a ret Func_e8927: @@ -254,10 +254,10 @@ Func_e8939: and a, $f0 ret nz xor a - ld [wPrinterReceiveJumptableIndex], a + ld [wPrinterSendState], a ret -Func_e8949: +Printer_PrepareToSend: .wait_printer_operation ld a, [wPrinterOpcode] and a @@ -275,7 +275,7 @@ Func_e8949: ld [rSC], a ret -Func_e8968: +CopyPrinterDataHeader: ld a, [hli] ld [wPrinterDataHeader], a ld a, [hli] @@ -290,7 +290,7 @@ Func_e8968: ld [wPrinterChecksum + 1], a ret -Func_e8981: +ResetPrinterData: xor a ld hl, wPrinterDataHeader ld [hli], a @@ -303,8 +303,8 @@ Func_e8981: xor a ld [wPrinterDataSize], a ld [wPrinterDataSize + 1], a - ld hl, wPrinterSerialReceived - ld bc, $280 + ld hl, wPrinterSendDataSource + ld bc, wPrinterSendDataSourceEnd - wPrinterSendDataSource call Printer_FillMemory ret @@ -317,7 +317,7 @@ ComputePrinterChecksum: ld c, a ld a, [wPrinterDataSize + 1] ld b, a - ld de, wPrinterSerialReceived + ld de, wPrinterSendDataSource call .AddToChecksum ld a, l ld [wPrinterChecksum], a @@ -357,20 +357,20 @@ Func_e89e6: ld a, [wcaf4] sub b ld hl, wPrinterTileBuffer - ld de, $28 -.asm_e89f4 + ld de, 2 * SCREEN_WIDTH +.get_row and a - jr z, .asm_e89fb + jr z, .got_row add hl, de dec a - jr .asm_e89f4 + jr .get_row -.asm_e89fb +.got_row ld e, l ld d, h - ld hl, wPrinterSerialReceived - ld c, $28 -.asm_e8a02 + ld hl, wPrinterSendDataSource + ld c, 2 * SCREEN_WIDTH +.loop ld a, [de] inc de push bc @@ -385,15 +385,15 @@ Func_e89e6: ld d, a and a, $8 ld a, d - jr nz, .asm_e8a1a + jr nz, .vchars1 or a, $90 - jr .asm_e8a1c + jr .got_addr -.asm_e8a1a +.vchars1 or a, $80 -.asm_e8a1c +.got_addr ld d, a - ld bc, $3a01 + lb bc, BANK(Func_e89e6), 1 call CopyVideoData pop hl ld de, $10 @@ -401,7 +401,7 @@ Func_e89e6: pop de pop bc dec c - jr nz, .asm_e8a02 + jr nz, .loop ret Printer_FillMemory: ; e8a2e (3a:4a2e) @@ -540,7 +540,7 @@ PrinterSerial_: ; e8a5e (3a:4a5e) ld e, a ld a, [wc975] ld d, a - ld hl, wPrinterSerialReceived + ld hl, wPrinterSendDataSource add hl, de inc de ld a, e diff --git a/engine/surfing_minigame.asm b/engine/surfing_minigame.asm index d7c7816e..6a37eb10 100755 --- a/engine/surfing_minigame.asm +++ b/engine/surfing_minigame.asm @@ -50,7 +50,7 @@ SurfingPikachuMinigame: xor a ld [rSTAT], a call RunDefaultPaletteCommand - call Func_0f16 + call ReloadMapAfterSurfingMinigame call PlayDefaultMusic call GBPalNormal pop af diff --git a/home/overworld.asm b/home/overworld.asm index 1368dc9d..18829022 100644 --- a/home/overworld.asm +++ b/home/overworld.asm @@ -1811,9 +1811,11 @@ LoadPlayerSpriteGraphicsCommon:: ; 0d8f (0:0d8f) ; function to load data from the map header LoadMapHeader:: ; 0dab (0:0dab) callba MarkTownVisitedAndLoadMissableObjects - jr .asm_0dbd + jr asm_0dbd + +Func_0db5:: ; XXX callba Func_f0a55 ; 3c:4a55 -.asm_0dbd +asm_0dbd ld a, [wCurMapTileset] ld [wUnusedD119], a ld a, [wCurMap] @@ -2005,7 +2007,7 @@ LoadScreenRelatedData:: ; 0f0c (0:0f0c) call LoadCurrentMapView ret -Func_0f16:: ; 0f16 (0:0f16) +ReloadMapAfterSurfingMinigame:: ; 0f16 (0:0f16) ld a, [H_LOADEDROMBANK] push af call DisableLCD @@ -2021,7 +2023,8 @@ Func_0f16:: ; 0f16 (0:0f16) pop af call BankswitchCommon jr asm_0f4d -Func_0f3d:: ; 0f3d (0:0f3d) + +ReloadMapAfterPrinter:: ; 0f3d (0:0f3d) ld a, [H_LOADEDROMBANK] push af ld a, [wCurMap] diff --git a/wram.asm b/wram.asm index d967a8e8..c5b443f3 100755 --- a/wram.asm +++ b/wram.asm @@ -424,7 +424,7 @@ wTempPic:: ; c6e8 wPrinterData:: ; c6e8 wOverworldMap:: ; c6e8 ; ds 1300 -wPrinterReceiveJumptableIndex:: ; c6e8 +wPrinterSendState:: ; c6e8 ds 1 wc6e9:: ; c6e9 ds 1 @@ -442,6 +442,9 @@ wc6ed:: ; c6ed wPrinterChecksum:: ; c6ee dw +wPrinterSendDataSource:: ; c6f0 +; a 40-tile buffer +; ds $280 wPrinterSerialReceived:: ; c6f0 ds 1 wPrinterStatusReceived:: ; c6f1 @@ -467,6 +470,7 @@ wc810:: ; c810 ; c900 ds $70 +wPrinterSendDataSourceEnd:: ; c970 wc970:: ; c970 ds 1 -- cgit v1.3.1-sl0p From 96a58ce52ac4b8c4c8b2ecbf0f185d1ebda10a6e Mon Sep 17 00:00:00 2001 From: pikalaxalt Date: Mon, 6 Jun 2016 12:09:36 -0400 Subject: Split out pikachu engine functions; sprite state data macros --- constants/pikachu_emotion_constants.asm | 4 +- constants/sprite_constants.asm | 2 + engine/bank3c.asm | 200 +- engine/bank3f.asm | 563 ++--- engine/hidden_object_functions14.asm | 2 +- engine/hidden_object_functions17.asm | 2 +- engine/hidden_object_functions18.asm | 6 +- engine/hidden_object_functions3.asm | 2 +- engine/hidden_object_functions7.asm | 6 +- engine/items/items.asm | 2437 ++++++++++---------- engine/menu/bills_pc.asm | 6 +- engine/overworld/card_key.asm | 2 +- engine/overworld/check_player_state.asm | 4 +- engine/overworld/cut.asm | 2 +- .../get_coords_tile_in_front_of_player.asm | 4 +- engine/overworld/hidden_objects.asm | 2 +- engine/overworld/ledges.asm | 2 +- engine/overworld/map_sprite_functions1.asm | 2 +- engine/overworld/map_sprites.asm | 124 +- engine/overworld/movement.asm | 4 +- engine/overworld/player_animations.asm | 6 +- engine/overworld/pokecenter.asm | 2 +- engine/overworld/ssanne.asm | 2 +- engine/overworld/step_functions.asm | 2 +- engine/overworld/try_pushing_boulder.asm | 2 +- engine/pikachu_emotions.asm | 674 ++++++ engine/pikachu_movement.asm | 1039 +++++++++ engine/pikachu_pcm.asm | 154 ++ engine/pikachu_pic_animation.asm | 1713 +------------- engine/surfing_minigame.asm | 2 +- home/overworld.asm | 66 +- home/pikachu.asm | 29 +- main.asm | 4 +- scripts/beach_house.asm | 8 +- scripts/billshouse.asm | 14 +- scripts/billshouse2.asm | 6 +- scripts/cinnabargym.asm | 2 +- scripts/cinnabarisland.asm | 2 +- scripts/copycatshouse2f.asm | 2 +- scripts/daycarem.asm | 2 +- scripts/fanclub.asm | 10 +- scripts/mansion1.asm | 2 +- scripts/mansion2.asm | 2 +- scripts/mansion3.asm | 2 +- scripts/mansion4.asm | 2 +- scripts/oakslab.asm | 6 +- scripts/oakslab2.asm | 4 +- scripts/pallettown.asm | 2 +- scripts/pewtercity.asm | 2 +- scripts/pewterpokecenter.asm | 2 +- scripts/pokemontower7.asm | 2 +- scripts/redshouse1f2.asm | 2 +- scripts/route11gateupstairs.asm | 2 +- scripts/route12gateupstairs.asm | 2 +- scripts/route22.asm | 2 +- scripts/route22gate.asm | 2 +- scripts/route23.asm | 2 +- scripts/route25.asm | 2 +- scripts/safarizoneentrance.asm | 6 +- scripts/vermilioncity.asm | 6 +- scripts/viridiancity.asm | 6 +- scripts/viridiancity2.asm | 2 +- wram.asm | 84 +- 63 files changed, 3743 insertions(+), 3518 deletions(-) create mode 100755 engine/pikachu_emotions.asm create mode 100755 engine/pikachu_movement.asm create mode 100755 engine/pikachu_pcm.asm (limited to 'wram.asm') diff --git a/constants/pikachu_emotion_constants.asm b/constants/pikachu_emotion_constants.asm index 22c1d8ea..ff56082a 100644 --- a/constants/pikachu_emotion_constants.asm +++ b/constants/pikachu_emotion_constants.asm @@ -47,12 +47,12 @@ pikaemotion_emotebubble: MACRO db \1 ENDM -pikaemotion_4: MACRO +pikaemotion_movement: MACRO db PIKAEMOTION_4 dw \1 ENDM -pikaemotion_5: MACRO +pikaemotion_pikapic: MACRO db PIKAEMOTION_5 db \1 ENDM diff --git a/constants/sprite_constants.asm b/constants/sprite_constants.asm index ae0c9dfa..3349e374 100755 --- a/constants/sprite_constants.asm +++ b/constants/sprite_constants.asm @@ -85,6 +85,8 @@ const_value = 1 const SPRITE_CHANSEY ; $44 const SPRITE_JESSIE ; $45 const SPRITE_JAMES ; $46 + + ; 4-tile sprites const SPRITE_BALL ; $47 const SPRITE_OMANYTE ; $48 const SPRITE_BOULDER ; $49 diff --git a/engine/bank3c.asm b/engine/bank3c.asm index 4fa185e0..0028d1fc 100644 --- a/engine/bank3c.asm +++ b/engine/bank3c.asm @@ -1,158 +1,4 @@ -PlayPikachuSoundClip:: ; f0000 (3c:4000) - ld a, e - ld e, a - ld d, $0 - ld hl, PikachuCriesPointerTable - add hl, de - add hl, de - add hl, de - ld b, [hl] ; bank of pikachu cry data - inc hl - ld a, [hli] ; cry data pointer - ld h, [hl] - ld l, a - ld c, $4 -.loop - dec c - jr z, .done_delay - call DelayFrame - jr .loop - -.done_delay - di - push bc - push hl - ld a, $80 - ld [rNR52], a - ld a, $77 - ld [rNR50], a - xor a - ld [rNR30], a - ld hl, $ff30 ; wave data - ld de, wRedrawRowOrColumnSrcTiles -.saveWaveDataLoop - ld a, [hl] - ld [de], a - inc de - ld a, $ff - ld [hli], a - ld a, l - cp $40 ; end of wave data - jr nz, .saveWaveDataLoop - ld a, $80 - ld [rNR30], a - ld a, [rNR51] - or $44 - ld [rNR51], a - ld a, $ff - ld [rNR31], a - ld a, $20 - ld [rNR32], a - ld a, $ff - ld [rNR33], a - ld a, $87 - ld [rNR34], a - pop hl - pop bc - call PlayPikachuPCM - xor a - ld [wc0f3], a - ld [wc0f4], a - ld a, $80 - ld [rNR52], a - xor a - ld [rNR30], a - ld hl, $ff30 - ld de, wRedrawRowOrColumnSrcTiles -.reloadWaveDataLoop - ld a, [de] - inc de - ld [hli], a - ld a, l - cp $40 ; end of wave data - jr nz, .reloadWaveDataLoop - ld a, $80 - ld [rNR30], a - ld a, [rNR51] - and $bb - ld [rNR51], a - xor a - ld [wChannelSoundIDs+CH4], a - ld [wChannelSoundIDs+CH5], a - ld [wChannelSoundIDs+CH6], a - ld [wChannelSoundIDs+CH7], a - ld a, [H_LOADEDROMBANK] - ei - ret - -PikachuCriesPointerTable: ; f008e (3c:408e) -; format: -; db bank -; dw pointer to cry - -; bank 21 - pikacry_def PikachuCry1 ; 21:4000 - pikacry_def PikachuCry2 ; 21:491a - pikacry_def PikachuCry3 ; 21:4fdc - pikacry_def PikachuCry4 ; 21:59ee - -; bank 22 - pikacry_def PikachuCry5 ; 22:4000 - pikacry_def PikachuCry6 ; 22:5042 - pikacry_def PikachuCry7 ; 22:6254 - -; bank 23 - pikacry_def PikachuCry8 ; 23:4000 - pikacry_def PikachuCry9 ; 23:50ca - pikacry_def PikachuCry10 ; 23:5e0c - -; bank 24 - pikacry_def PikachuCry11 ; 24:4000 - pikacry_def PikachuCry12 ; 24:4722 - pikacry_def PikachuCry13 ; 24:54a4 - -; bank 25 - pikacry_def PikachuCry14 ; 25:4000 - pikacry_def PikachuCry15 ; 25:589a - -; banks 31-34, in no particular order - - pikacry_def PikachuCry16 ; 31:4000 - pikacry_def PikachuCry17 ; 34:4000 - pikacry_def PikachuCry18 ; 31:549a - pikacry_def PikachuCry19 ; 33:4000 - pikacry_def PikachuCry20 ; 32:4000 - pikacry_def PikachuCry21 ; 32:6002 - pikacry_def PikachuCry22 ; 31:63a4 - pikacry_def PikachuCry23 ; 34:4862 - pikacry_def PikachuCry24 ; 33:5632 - pikacry_def PikachuCry25 ; 34:573c - pikacry_def PikachuCry26 ; 33:725c - -; bank 35 - pikacry_def PikachuCry27 ; 35:4000 - pikacry_def PikachuCry28 ; 35:4b5a - pikacry_def PikachuCry29 ; 35:5da4 - pikacry_def PikachuCry30 ; 35:69ce - pikacry_def PikachuCry31 ; 35:6e80 - -; bank 36 - pikacry_def PikachuCry32 ; 36:4000 - pikacry_def PikachuCry33 ; 36:458a - pikacry_def PikachuCry34 ; 36:523c - -; bank 37 - pikacry_def PikachuCry35 ; 37:4000 - pikacry_def PikachuCry36 ; 37:522a - -; banks 36-38 - pikacry_def PikachuCry37 ; 38:4000 - pikacry_def PikachuCry38 ; 38:4dfa - pikacry_def PikachuCry39 ; 37:6e0c - pikacry_def PikachuCry40 ; 38:5a64 - pikacry_def PikachuCry41 ; 36:6746 - pikacry_def PikachuCry42 ; 38:6976 - +INCLUDE "engine/pikachu_pcm.asm" INCLUDE "engine/overworld/advance_player_sprite.asm" ResetStatusAndHalveMoneyOnBlackout:: ; f0274 (3c:4274) @@ -169,30 +15,30 @@ ResetStatusAndHalveMoneyOnBlackout:: ; f0274 (3c:4274) ld [wNPCMovementScriptPointerTableNum], a ld [wFlags_0xcd60], a - ld [$ff9f], a - ld [$ff9f + 1], a - ld [$ff9f + 2], a + ld [hMoney], a + ld [hMoney + 1], a + ld [hMoney + 2], a call HasEnoughMoney jr c, .lostmoney ; never happens ; Halve the player's money. ld a, [wPlayerMoney] - ld [$ff9f], a + ld [hMoney], a ld a, [wPlayerMoney + 1] - ld [$ff9f + 1], a + ld [hMoney + 1], a ld a, [wPlayerMoney + 2] - ld [$ff9f + 2], a + ld [hMoney + 2], a xor a - ld [$ffa2], a - ld [$ffa3], a + ld [hDivideBCDDivisor], a + ld [hDivideBCDDivisor + 1], a ld a, 2 - ld [$ffa4], a + ld [hDivideBCDDivisor + 2], a predef DivideBCDPredef3 - ld a, [$ffa2] + ld a, [hDivideBCDQuotient] ld [wPlayerMoney], a - ld a, [$ffa2 + 1] + ld a, [hDivideBCDQuotient + 1] ld [wPlayerMoney + 1], a - ld a, [$ffa2 + 2] + ld a, [hDivideBCDQuotient + 2] ld [wPlayerMoney + 2], a .lostmoney @@ -217,10 +63,12 @@ Func_f02da:: ; f02da (3c:42da) cp a, $ff jr nz, .asm_f02e5 ret + .asm_f02ee ld hl, wd126 set 6, [hl] ret + .asm_f02f4 ld hl, wd126 set 5, [hl] @@ -301,7 +149,7 @@ Pointer_f0a7b: db $ff Pointer_f0a7bEnd: -Func_f0a82: ; f0a82 +TryApplyPikachuMovementData: ; f0a82 ld a, [wd472] bit 7, a ret z @@ -325,8 +173,8 @@ Func_f0a82: ; f0a82 pop af ld [wUpdateSpritesEnabled], a pop hl - call Func_159b ; homecall Func_fd2a1 - pikachu movement script? - callab Func_fcba1 + call ApplyPikachuMovementData + callab RefreshPikachuFollow ret Pic_f0abf: ; f0abf (3c:4abf) @@ -365,7 +213,7 @@ INCLUDE "scripts/pewterpokecenter2.asm" Func_f1e22: ld hl, PikachuMovementData_f1e2b ld b, SPRITE_FACING_RIGHT - call Func_f0a82 + call TryApplyPikachuMovementData ret PikachuMovementData_f1e2b: @@ -382,7 +230,7 @@ INCLUDE "scripts/celadonmansion3_2.asm" Func_f1f23: ld hl, PikachuMovementData_f1f2c ld b, SPRITE_FACING_DOWN - call Func_f0a82 + call TryApplyPikachuMovementData ret PikachuMovementData_f1f2c: @@ -444,10 +292,10 @@ Func_f2cee: Func_f2cf4: ; should return to a, instead returns to b call Random swap a - cp $55 + cp 1 * $ff / 3 ld b, 0 ret c - cp $aa + cp 2 * $ff / 3 ld b, 1 ret c ld b, 2 @@ -459,7 +307,7 @@ Func_f2d06: ret Func_f2d0c: - ld hl, GymTrashCans3a + ld hl, GymTrashCans3c ld a, [wGymTrashCanIndex] ld c, a ld b, 0 @@ -480,7 +328,7 @@ Func_f2d0c: ld [wSecondLockTrashCanIndex + 1], a ret -GymTrashCans3a: ; f2d31 (3c:6d31) +GymTrashCans3c: ; f2d31 (3c:6d31) ; First byte: number of trashcan entries ; Following four byte pairs: indices for the second trash can. ; BUG: Rows that have 3 trashcan entries are sampled incorrectly. diff --git a/engine/bank3f.asm b/engine/bank3f.asm index 85674ec4..37aca92f 100644 --- a/engine/bank3f.asm +++ b/engine/bank3f.asm @@ -26,123 +26,122 @@ Func_fc4fa:: ; fc4fa (3f:44fa) ld hl, wPikachuOverworldStateFlags bit 4, [hl] res 4, [hl] - jr nz, .asm_fc515 + jr nz, .normal_spawn_state call EnablePikachuFollowingPlayer - call Func_fc523 + call ClearPikachuSpriteStateData ld a, $ff - ld [wSpriteStateData1 + $f2], a + ld [wPikachuSpriteImageIdx], a call ClearPikachuFollowCommandBuffer - call Func_fc5bc + call CalculatePikachuFacingDirection ret -.asm_fc515 - call Func_fc53f +.normal_spawn_state + call CalculatePikachuPlacementCoords xor a - ld [wd431], a - ld a, [wSpriteStateData1 + $9] - ld [wSpriteStateData1 + $f9], a + ld [wPikachuSpawnState], a + ld a, [wPlayerFacingDirection] + ld [wPikachuFacingDirection], a ret -Func_fc523:: ; fc523 (3f:4523) - ld hl, wSpriteStateData1 + $f0 - call Func_fc52c - ld hl, wSpriteStateData2 + $f0 -Func_fc52c:: ; fc52c (3f:4523) +ClearPikachuSpriteStateData:: ; fc523 (3f:4523) + ld hl, wPikachuPictureID + call .clear + ld hl, wPikachuSpriteStateData2 +.clear ld bc, $10 xor a call FillMemory ret Func_fc534:: ; fc534 (3f:4534) - call Func_fc53f - call Func_fc5bc + call CalculatePikachuPlacementCoords + call CalculatePikachuFacingDirection xor a - ld [wd431], a + ld [wPikachuSpawnState], a ret -Func_fc53f:: ; fc53f (3f:453f) - ld bc, wSpriteStateData1 + $f0 +CalculatePikachuPlacementCoords:: ; fc53f (3f:453f) + ld bc, wPikachuPictureID ld a, [wYCoord] add $4 ld e, a ld a, [wXCoord] add $4 ld d, a - ld a, [wd431] + ld a, [wPikachuSpawnState] and a - jr z, .asm_fc5aa + jr z, .load_coords cp $1 - jr z, .asm_fc59e + jr z, .right_of_player cp $2 - jr z, .asm_fc584 + jr z, .check_player_facing2 cp $3 - jr z, .asm_fc5aa + jr z, .load_coords cp $4 - jr z, .asm_fc5a4 + jr z, .below_player cp $5 - jr z, .asm_fc5a7 + jr z, .above_player cp $6 - jr z, .asm_fc5a1 + jr z, .left_of_player cp $7 - jr z, .asm_fc572 - jr .asm_fc59e + jr z, .check_player_facing + jr .right_of_player -.asm_fc572 - ld a, [wSpriteStateData1 + $9] +.check_player_facing + ld a, [wPlayerFacingDirection] and a ; SPRITE_FACING_DOWN - jr z, .asm_fc5a4 + jr z, .below_player cp SPRITE_FACING_UP - jr z, .asm_fc5a7 + jr z, .above_player cp SPRITE_FACING_LEFT - jr z, .asm_fc5a1 + jr z, .left_of_player cp SPRITE_FACING_RIGHT - jr z, .asm_fc59e -.asm_fc584 - ld a, [wSpriteStateData1 + $9] + jr z, .right_of_player +.check_player_facing2 + ld a, [wPlayerFacingDirection] and a - jr nz, .asm_fc58d + jr nz, .check_up dec e - jr .asm_fc5aa + jr .load_coords -.asm_fc58d +.check_up cp SPRITE_FACING_UP - jr nz, .asm_fc594 + jr nz, .check_left inc e - jr .asm_fc5aa + jr .load_coords -.asm_fc594 +.check_left cp SPRITE_FACING_LEFT - jr nz, .asm_fc59b + jr nz, .left_of_player_2 inc d - jr .asm_fc5aa + jr .load_coords -.asm_fc59b +.left_of_player_2 dec d - jr .asm_fc5aa + jr .load_coords -.asm_fc59e +.right_of_player inc d - jr .asm_fc5aa + jr .load_coords -.asm_fc5a1 +.left_of_player dec d - jr .asm_fc5aa + jr .load_coords -.asm_fc5a4 +.below_player inc e - jr .asm_fc5aa + jr .load_coords -.asm_fc5a7 +.above_player dec e - jr .asm_fc5aa ; useless jr -.asm_fc5aa - ld hl, $104 + jr .load_coords ; useless jr +.load_coords + ld hl, wPlayerMapY - wPlayerSpriteStateData1 add hl, bc ld [hl], e inc hl ld [hl], d inc hl -Func_fc4b2:: ; fc4b2 (3f:44b2) ld [hl], $fe push hl ld hl, wd472 @@ -150,139 +149,164 @@ Func_fc4b2:: ; fc4b2 (3f:44b2) pop hl ret -Func_fc5bc:: ; fc5bc (3f:45bc) +CalculatePikachuFacingDirection:: ; fc5bc (3f:45bc) ld a, $49 - ld [wSpriteStateData1 + $f0], a + ld [wPikachuPictureID], a ld a, $ff - ld [wSpriteStateData1 + $f2], a - ld a, [wd431] + ld [wPikachuSpriteImageIdx], a + ld a, [wPikachuSpawnState] and a - jr z, .asm_fc5e4 + jr z, .copy_player_facing cp $1 - jr z, .asm_fc5e4 + jr z, .copy_player_facing cp $3 - jr z, .asm_fc5eb + jr z, .force_facing_down cp $4 - jr z, .asm_fc5e4 + jr z, .copy_player_facing cp $6 - jr z, .asm_fc5e4 + jr z, .copy_player_facing cp $7 - jr z, .asm_fc5f1 + jr z, .face_the_other_way call Func_fccb2 ret -.asm_fc5e4 - ld a, [wSpriteStateData1 + $9] - ld [wSpriteStateData1 + $f9], a +.copy_player_facing + ld a, [wPlayerFacingDirection] + ld [wPikachuFacingDirection], a ret -.asm_fc5eb - ld a, $0 - ld [wSpriteStateData1 + $f9], a +.force_facing_down + ld a, SPRITE_FACING_DOWN + ld [wPikachuFacingDirection], a ret -.asm_fc5f1 - ld a, [wSpriteStateData1 + $9] +.face_the_other_way + ld a, [wPlayerFacingDirection] xor $4 - ld [wSpriteStateData1 + $f9], a + ld [wPikachuFacingDirection], a ret -Func_fc5fa:: ; fc5fa (3f:45fa) +CalculatePikachuSpawnState1:: ; fc5fa (3f:45fa) ld a, [wCurMap] cp OAKS_LAB - jr z, .asm_fc63d + jr z, .oaks_lab cp ROUTE_22_GATE - jr z, .asm_fc62d + jr z, .route_22_gate cp MT_MOON_2 - jr z, .asm_fc635 + jr z, .mt_moon_2 cp ROCK_TUNNEL_1 - jr z, .asm_fc645 + jr z, .rock_tunnel_1 ld a, [wCurMap] ld hl, Pointer_fc64b - call Func_1568 ; similar to IsInArray, but not the same - jr c, .asm_fc639 + call Pikachu_IsInArray ; similar to IsInArray, but not the same + jr c, .map_list_1 ld a, [wCurMap] ld hl, Pointer_fc653 - call Func_1568 - jr nc, .asm_fc641 - ld a, [wSpriteStateData1 + $9] + call Pikachu_IsInArray + jr nc, .not_map_list_2 + ld a, [wPlayerFacingDirection] and a - jr nz, .asm_fc641 + jr nz, .not_map_list_2 ld a, $3 - jr .asm_fc647 + jr .load -.asm_fc62d - ld a, [wSpriteStateData1 + $9] +.route_22_gate + ld a, [wPlayerFacingDirection] and a - jr z, .asm_fc645 - jr .asm_fc641 + jr z, .rock_tunnel_1 + jr .not_map_list_2 -.asm_fc635 +.mt_moon_2 ld a, $3 - jr .asm_fc647 + jr .load -.asm_fc639 +.map_list_1 ld a, $4 - jr .asm_fc647 + jr .load -.asm_fc63d +.oaks_lab ld a, $6 - jr .asm_fc647 + jr .load -.asm_fc641 +.not_map_list_2 ld a, $1 - jr .asm_fc647 + jr .load -.asm_fc645 +.rock_tunnel_1 ld a, $3 -.asm_fc647 - ld [wd431], a +.load + ld [wPikachuSpawnState], a ret Pointer_fc64b:: ; fc64b (3f:464b) - db $c2, $4c, $4f, $ba, $be, $b8, $54, $ff + db VICTORY_ROAD_2 + db ROUTE_7_GATE + db ROUTE_8_GATE + db ROUTE_16_GATE_1F + db ROUTE_18_GATE_1F + db ROUTE_15_GATE_1F + db ROUTE_11_GATE_1F + db $ff Pointer_fc653:: ; fc653 (3f:4653) - db $2f, $e6, $3e, $5e, $80, $31, $a4, $ff - -Func_fc65b:: ; fc65b (3f:465b) + db VIRIDIAN_FOREST_EXIT + db CERULEAN_HOUSE_2 + db TRASHED_HOUSE + db VERMILION_DOCK + db CELADON_MANSION_1 + db ROUTE_2_GATE + db FUCHSIA_HOUSE_3 + db $ff + +CalculatePikachuSpawnState2:: ; fc65b (3f:465b) ld a, [wCurMap] cp VIRIDIAN_FOREST_EXIT - jr z, .asm_fc673 + jr z, .viridian_forest_exit cp VIRIDIAN_FOREST_ENTRANCE - jr z, .asm_fc67c + jr z, .viridian_forest_entrance ld a, [wCurMap] ld hl, Pointer_fc68e - call Func_1568 - jr c, .asm_fc688 - jr .asm_fc684 + call Pikachu_IsInArray + jr c, .in_array + jr .not_in_array -.asm_fc673 - ld a, [wSpriteStateData1 + $9] +.viridian_forest_exit + ld a, [wPlayerFacingDirection] cp SPRITE_FACING_UP - jr z, .asm_fc688 - jr .asm_fc684 + jr z, .in_array + jr .not_in_array -.asm_fc67c - ld a, [wSpriteStateData1 + $9] +.viridian_forest_entrance + ld a, [wPlayerFacingDirection] and a ; SPRITE_FACING_DOWN - jr z, .asm_fc684 - jr .asm_fc688 + jr z, .not_in_array + jr .in_array -.asm_fc684 +.not_in_array ld a, $0 - jr .asm_fc68a + jr .load_spawn_state -.asm_fc688 +.in_array ld a, $1 -.asm_fc68a - ld [wd431], a +.load_spawn_state + ld [wPikachuSpawnState], a ret Pointer_fc68e:: ; fc68e (3f:468e) - db $33, $dd, $df, $e0, $e1, $de, $ec, $7f, $a8, $a9, $aa, $ff - -Func_fc69a:: ; fc69a (3f:469a) + db VIRIDIAN_FOREST + db SAFARI_ZONE_REST_HOUSE_1 + db SAFARI_ZONE_REST_HOUSE_2 + db SAFARI_ZONE_REST_HOUSE_3 + db SAFARI_ZONE_REST_HOUSE_4 + db SAFARI_ZONE_SECRET_HOUSE + db SILPH_CO_ELEVATOR + db CELADON_MART_ELEVATOR + db CINNABAR_LAB_2 + db CINNABAR_LAB_3 + db CINNABAR_LAB_4 + db $ff + +CalculatePikachuSpawnState3:: ; fc69a (3f:469a) ld a, [wCurMap] cp ROUTE_22_GATE jr z, .asm_fc6a7 @@ -291,13 +315,13 @@ Func_fc69a:: ; fc69a (3f:469a) jr .asm_fc6bd .asm_fc6a7 - ld a, [wSpriteStateData1 + $9] + ld a, [wPlayerFacingDirection] cp SPRITE_FACING_UP jr z, .asm_fc6b9 jr .asm_fc6bd .asm_fc6b0 - ld a, [wSpriteStateData1 + $9] + ld a, [wPlayerFacingDirection] cp SPRITE_FACING_UP jr z, .asm_fc6b9 jr .asm_fc6bd @@ -311,7 +335,7 @@ Func_fc69a:: ; fc69a (3f:469a) jr .asm_fc6c1 .asm_fc6c1 - ld [wd431], a + ld [wPikachuSpawnState], a ret Func_fc6c5:: ; fc6c5 (3f:46c5) @@ -328,7 +352,7 @@ Func_fc6cd:: ; fc6cd (3f:46cd) pop hl ret -Func_fc6d5:: ; fc6d5 (3f:46d5) +SpawnPikachu_:: ; fc6d5 (3f:46d5) call Func_fc6cd call Func_fc727 ret nc @@ -336,8 +360,8 @@ Func_fc6d5:: ; fc6d5 (3f:46d5) call Func_fcd25 pop bc ret c - ld bc, wSpriteStateData1 + $f0 - ld hl, $1 + ld bc, wPikachuPictureID + ld hl, wSprite01MovementStatus - wSprite01SpriteStateData1 add hl, bc bit 7, [hl] jp nz, asm_fc745 @@ -380,21 +404,21 @@ Func_fc726: ; fc726 (3f:4726) Func_fc727: ; fc727 (3f:4727) call Func_fc4dd - jr nc, .asm_fc73b - ld a, [wSpriteStateData1 + $f1] + jr nc, .dont_spawn + ld a, [wPikachuMovementStatus] and a - jr nz, .asm_fc739 + jr nz, .already_spawned push bc push hl call Func_fc534 pop hl pop bc -.asm_fc739 +.already_spawned scf ret -.asm_fc73b - ld hl, wSpriteStateData1 + $f2 +.dont_spawn + ld hl, wPikachuSpriteImageIdx ld [hl], $ff dec hl ld [hl], $0 @@ -402,22 +426,22 @@ Func_fc727: ; fc727 (3f:4727) ret asm_fc745: ; fc745 (3f:4745) - ld hl, $1 + ld hl, wSprite01MovementStatus - wSprite01SpriteStateData1 add hl, bc res 7, [hl] - ld hl, wSpriteStateData2 - wSpriteStateData1 + ld hl, wSprite01WalkAnimationCounter - wSprite01SpriteStateData1 add hl, bc ld [hl], a call CheckPikachuFollowingPlayer jr nz, .asm_fc75f - ld a, [wSpriteStateData1 + $9] + ld a, [wPlayerFacingDirection] xor $4 - ld hl, $9 + ld hl, wSprite01FacingDirection - wSprite01SpriteStateData1 add hl, bc ld [hl], a .asm_fc75f xor a - ld hl, $7 + ld hl, wSprite01IntraAnimFrameCounter - wSprite01SpriteStateData1 add hl, bc ld [hli], a ld [hl], a @@ -426,7 +450,7 @@ asm_fc745: ; fc745 (3f:4745) asm_fc76a: ; fc76a (3f:476a) xor a - ld hl, $7 + ld hl, wSprite01IntraAnimFrameCounter - wSprite01SpriteStateData1 add hl, bc ld [hli], a ld [hl], a @@ -437,21 +461,21 @@ asm_fc76a: ; fc76a (3f:476a) callab InitializeSpriteScreenPosition pop bc .asm_fc783 - ld hl, $1 + ld hl, wSprite01MovementStatus - wSprite01SpriteStateData1 add hl, bc ld [hl], $1 - ld hl, wSpriteStateData2 - wSpriteStateData1 + ld hl, wSprite01WalkAnimationCounter - wSprite01SpriteStateData1 add hl, bc ld [hl], $0 - call Func_fcba1 + call RefreshPikachuFollow ret Func_fc793: ; fc793 (3f:4793) - call Func_fcba1 + call RefreshPikachuFollow push bc callab InitializeSpriteScreenPosition pop bc - ld hl, $2 + ld hl, wSprite01SpriteImageIdx - wSprite01SpriteStateData1 add hl, bc ld [hl], $ff dec hl @@ -472,12 +496,12 @@ Func_fc7aa: ; fc7aa (3f:47aa) ld e, l ld a, [de] inc de - ld hl, $9 + ld hl, wSprite01FacingDirection - wSprite01SpriteStateData1 add hl, bc ld [hl], a ld a, [de] inc de - ld hl, $5 + ld hl, wSprite01XStepVector - wSprite01SpriteStateData1 add hl, bc ld [hl], a dec hl @@ -486,7 +510,7 @@ Func_fc7aa: ; fc7aa (3f:47aa) ld [hl], a inc de ld a, [de] - ld hl, $1 + ld hl, wSprite01MovementStatus - wSprite01SpriteStateData1 add hl, bc ld [hl], a cp $4 @@ -496,27 +520,27 @@ Func_fc7aa: ; fc7aa (3f:47aa) jp Func_fc9b4 Pointer_fc7e3: ; fc7e3 (3f:47e3) - db $0, $0 - db $1, $3 - db $4, $0 - db $ff, $3 - db $8, $ff - db $0, $3 - db $c, $1 - db $0, $3 - db $0, $0 - db $1, $4 - db $4, $0 - db $ff, $4 - db $8, $ff - db $0, $4 - db $c, $1 - db $0, $4 + db 0, 0 + db 1, 3 + db 4, 0 + db -1, 3 + db 8, -1 + db 0, 3 + db 12, 1 + db 0, 3 + db 0, 0 + db 1, 4 + db 4, 0 + db -1, 4 + db 8, -1 + db 0, 4 + db 12, 1 + db 0, 4 Func_fc803: ; fc803 (3f:4803) call Func_fcae2 ret c - ld hl, wSpriteStateData2 - wSpriteStateData1 + ld hl, wSprite01WalkAnimationCounter - wSprite01SpriteStateData1 add hl, bc dec [hl] jr nz, .asm_fc823 @@ -528,12 +552,12 @@ Func_fc803: ; fc803 (3f:4803) ld [hl], $20 call Random and $c - ld hl, $9 + ld hl, wSprite01FacingDirection - wSprite01SpriteStateData1 add hl, bc ld [hl], a .asm_fc823 xor a - ld hl, $7 + ld hl, wSprite01IntraAnimFrameCounter - wSprite01SpriteStateData1 add hl, bc ld [hli], a ld [hl], a @@ -548,10 +572,10 @@ Func_fc82e: ; fc82e (3f:482e) ret Func_fc835: ; fc835 (3f:4835) - ld hl, wSpriteStateData2 - wSpriteStateData1 + ld hl, wSprite01WalkAnimationCounter - wSprite01SpriteStateData1 add hl, bc ld [hl], $10 - ld hl, $1 + ld hl, wSprite01MovementStatus - wSprite01SpriteStateData1 add hl, bc ld [hl], $1 ret @@ -584,16 +608,16 @@ Func_fc862: ; fc862 (3f:4862) add a add a and $c - ld hl, $9 + ld hl, wSprite01FacingDirection - wSprite01SpriteStateData1 add hl, bc ld [hl], a - ld hl, $1 + ld hl, wSprite01MovementStatus - wSprite01SpriteStateData1 add hl, bc ld [hl], $6 xor a ld [wd432], a ld [wd433], a - ld hl, wSpriteStateData2 - wSpriteStateData1 + ld hl, wSprite01WalkAnimationCounter - wSprite01SpriteStateData1 add hl, bc ld [hl], $11 asm_fc87f: ; fc87f (3f:487f) @@ -604,7 +628,7 @@ asm_fc87f: ; fc87f (3f:487f) call Func_fc82e jr c, Func_fc8c7 call Func_fc6c5 - ld hl, $4 + ld hl, wSprite01YPixels - wSprite01SpriteStateData1 add hl, bc ld a, [hl] sub e @@ -614,14 +638,14 @@ asm_fc87f: ; fc87f (3f:487f) ld a, [hl] sub d ld d, a - ld hl, wSpriteStateData2 - wSpriteStateData1 + ld hl, wSprite01WalkAnimationCounter - wSprite01SpriteStateData1 add hl, bc ld a, [hl] dec a add a - add $d6 + add Pointer_fc8d6 % $100 ld l, a - ld a, $48 + ld a, Pointer_fc8d6 / $100 adc $0 ld h, a ld a, [hli] @@ -632,20 +656,20 @@ asm_fc87f: ; fc87f (3f:487f) ld [wd433], a add d ld d, a - ld hl, $4 + ld hl, wSprite01YPixels - wSprite01SpriteStateData1 add hl, bc ld [hl], e inc hl inc hl ld [hl], d - ld hl, wSpriteStateData2 - wSpriteStateData1 + ld hl, wSprite01WalkAnimationCounter - wSprite01SpriteStateData1 add hl, bc dec [hl] ret nz jp Func_fc835 Func_fc8c7: ; fc8c7 (3f:48c7) - ld hl, $4 + ld hl, wSprite01YPixels - wSprite01SpriteStateData1 add hl, bc ld a, [hl] sub e @@ -658,26 +682,36 @@ Func_fc8c7: ; fc8c7 (3f:48c7) jp Func_fc835 Pointer_fc8d6: ; fc8d6 (3f:48d6) - db $0, $0, $fe, $1, $fc - db $2, $fe, $3, $0, $4 - db $fe, $3, $fc, $2, $fe - db $1, $0, $0, $fe, $ff - db $fc, $fe, $fe, $fd, $0 - db $fc, $fe, $fd, $fc, $fe - db $fe, $ff, $00, $00 + db 0, 0 + db -2, 1 + db -4, 2 + db -2, 3 + db 0, 4 + db -2, 3 + db -4, 2 + db -2, 1 + db 0, 0 + db -2, -1 + db -4, -2 + db -2, -3 + db 0, -4 + db -2, -3 + db -4, -2 + db -2, -1 + db 0, 0 Func_fc8f8: ; fc8f8 (3f:48f8) - ld hl, $1 + ld hl, wSprite01MovementStatus - wSprite01SpriteStateData1 add hl, bc ld [hl], $7 - ld hl, wSpriteStateData2 - wSpriteStateData1 + ld hl, wSprite01WalkAnimationCounter - wSprite01SpriteStateData1 add hl, bc ld [hl], $30 asm_fc904: ; fc904 (3f:4904) call Func_fc82e jp c, Func_fc835 call Func_fc6c5 - ld hl, $7 + ld hl, wSprite01IntraAnimFrameCounter - wSprite01SpriteStateData1 add hl, bc ld a, [hl] inc a @@ -692,24 +726,24 @@ asm_fc904: ; fc904 (3f:4904) ld [hl], a .asm_fc91f call Func_fca99 - ld hl, wSpriteStateData2 - wSpriteStateData1 + ld hl, wSprite01WalkAnimationCounter - wSprite01SpriteStateData1 add hl, bc dec [hl] ret nz jp Func_fc835 Func_fc92b: ; fc92b (3f:492b) - ld hl, wSpriteStateData2 - wSpriteStateData1 + ld hl, wSprite01WalkAnimationCounter - wSprite01SpriteStateData1 add hl, bc ld [hl], $20 - ld hl, $1 + ld hl, wSprite01MovementStatus - wSprite01SpriteStateData1 add hl, bc ld [hl], $8 asm_fc937: ; fc937 (3f:4937) call Func_fc82e jp c, Func_fc835 call Func_fc6c5 - ld hl, $7 + ld hl, wSprite01IntraAnimFrameCounter - wSprite01SpriteStateData1 add hl, bc ld a, [hl] inc a @@ -723,24 +757,24 @@ asm_fc937: ; fc937 (3f:4937) ld [hl], a .asm_fc951 call Func_fca99 - ld hl, wSpriteStateData2 - wSpriteStateData1 + ld hl, wSprite01WalkAnimationCounter - wSprite01SpriteStateData1 add hl, bc dec [hl] ret nz jp Func_fc835 Func_fc95d: ; fc95d (3f:495d) - ld hl, wSpriteStateData2 - wSpriteStateData1 + ld hl, wSprite01WalkAnimationCounter - wSprite01SpriteStateData1 add hl, bc ld [hl], $20 - ld hl, $1 + ld hl, wSprite01MovementStatus - wSprite01SpriteStateData1 add hl, bc ld [hl], $9 asm_fc969: ; fc969 (3f:4969) call Func_fc82e jp c, Func_fc835 call Func_fc6c5 - ld hl, $7 + ld hl, wSprite01IntraAnimFrameCounter - wSprite01SpriteStateData1 add hl, bc ld a, [hl] inc a @@ -749,14 +783,14 @@ asm_fc969: ; fc969 (3f:4969) jr nz, .asm_fc988 xor a ld [hl], a - ld hl, $9 + ld hl, wSprite01FacingDirection - wSprite01SpriteStateData1 add hl, bc ld a, [hl] call Func_fc994 ld [hl], a .asm_fc988 call Func_fca99 - ld hl, wSpriteStateData2 - wSpriteStateData1 + ld hl, wSprite01WalkAnimationCounter - wSprite01SpriteStateData1 add hl, bc dec [hl] ret nz @@ -790,11 +824,12 @@ Pointer_fc9ac: ; fc9ac (3f:49ac) db SPRITE_FACING_DOWN, SPRITE_FACING_LEFT, SPRITE_FACING_UP, SPRITE_FACING_RIGHT db SPRITE_FACING_DOWN, SPRITE_FACING_LEFT, SPRITE_FACING_UP, SPRITE_FACING_RIGHT Pointer_fc9ac_End: + Func_fc9b4: ; fc9b4 (3f:49b4) - ld hl, wSpriteStateData2 - wSpriteStateData1 + ld hl, wSprite01WalkAnimationCounter - wSprite01SpriteStateData1 add hl, bc ld [hl], $8 - ld hl, $1 + ld hl, wSprite01MovementStatus - wSprite01SpriteStateData1 add hl, bc ld [hl], $3 call Func_fca38 @@ -802,22 +837,22 @@ asm_fc9c3: ; fc9c3 (3f:49c3) call Func_fca4b call Func_fca7e call Func_fca99 - ld hl, $100 + ld hl, wSprite01WalkAnimationCounter - wSprite01SpriteStateData1 add hl, bc dec [hl] ret nz call Func_fca75 call Func_fccb2 - ld hl, $1 + ld hl, wSprite01MovementStatus - wSprite01SpriteStateData1 add hl, bc ld [hl], $1 ret Func_fc9df: ; fc9df (3f:49df) - ld hl, wSpriteStateData2 - wSpriteStateData1 + ld hl, wSprite01WalkAnimationCounter - wSprite01SpriteStateData1 add hl, bc ld [hl], $4 - ld hl, $1 + ld hl, wSprite01MovementStatus - wSprite01SpriteStateData1 add hl, bc ld [hl], $5 call Func_fca38 @@ -825,22 +860,22 @@ asm_fc9ee: ; fc9ee (3f:49ee) call asm_fca59 call Func_fca7e call Func_fca99 - ld hl, wSpriteStateData2 - wSpriteStateData1 + ld hl, wSprite01WalkAnimationCounter - wSprite01SpriteStateData1 add hl, bc dec [hl] ret nz call Func_fca75 call Func_fccb2 - ld hl, $1 + ld hl, wSprite01MovementStatus - wSprite01SpriteStateData1 add hl, bc ld [hl], $1 ret Func_fca0a: ; fca0a (3f:4a0a) - ld hl, wSpriteStateData2 - wSpriteStateData1 + ld hl, wSprite01WalkAnimationCounter - wSprite01SpriteStateData1 add hl, bc ld [hl], $8 - ld hl, $1 + ld hl, wSprite01MovementStatus - wSprite01SpriteStateData1 add hl, bc ld [hl], $4 call Func_fca38 @@ -849,25 +884,25 @@ asm_fca1c: ; fca1c (3f:4a1c) call asm_fca59 call Func_fca7e call Func_fca99 - ld hl, wSpriteStateData2 - wSpriteStateData1 + ld hl, wSprite01WalkAnimationCounter - wSprite01SpriteStateData1 add hl, bc dec [hl] ret nz call Func_fca75 call Func_fccb2 - ld hl, $1 + ld hl, wSprite01MovementStatus - wSprite01SpriteStateData1 add hl, bc ld [hl], $1 ret Func_fca38: ; fca38 (3f:4a38) - ld hl, $3 + ld hl, wSprite01YStepVector - wSprite01SpriteStateData1 add hl, bc ld e, [hl] inc hl inc hl ld d, [hl] - ld hl, $104 + ld hl, wSprite01MapY - wSprite01SpriteStateData1 add hl, bc ld a, [hl] add e @@ -885,7 +920,7 @@ Func_fca4b: ; fca4b (3f:4a4b) bit 6, a jr nz, Func_fca68 asm_fca59: ; fca59 (3f:4a59) - ld hl, $3 + ld hl, wSprite01YStepVector - wSprite01SpriteStateData1 add hl, bc ld a, [hli] add a @@ -900,7 +935,7 @@ asm_fca59: ; fca59 (3f:4a59) ret Func_fca68: ; fca68 (3f:4a68) - ld hl, $3 + ld hl, wSprite01YStepVector - wSprite01SpriteStateData1 add hl, bc ld a, [hli] add a @@ -913,7 +948,7 @@ Func_fca68: ; fca68 (3f:4a68) ret Func_fca75: ; fca75 (3f:4a75) - ld hl, $3 + ld hl, wSprite01YStepVector - wSprite01SpriteStateData1 add hl, bc xor a ld [hli], a @@ -927,7 +962,7 @@ Func_fca7e: ; fca7e (3f:4a7e) jr nc, .asm_fca87 ld d, $5 .asm_fca87 - ld hl, $7 + ld hl, wSprite01IntraAnimFrameCounter - wSprite01SpriteStateData1 add hl, bc ld a, [hl] inc a @@ -947,7 +982,7 @@ Func_fca99: ; fca99 (3f:4a99) ld a, [wPikachuOverworldStateFlags] bit 3, a jr nz, .asm_fcad1 - ld hl, $10e + ld hl, wSprite01SpriteImageBaseOffset - wSprite01SpriteStateData1 add hl, bc ld a, [hl] dec a @@ -956,7 +991,7 @@ Func_fca99: ; fca99 (3f:4a99) ld a, [wd736] bit 7, a jr nz, .asm_fcad8 - ld hl, $9 + ld hl, wSprite01FacingDirection - wSprite01SpriteStateData1 add hl, bc ld a, [hl] or d @@ -969,32 +1004,32 @@ Func_fca99: ; fca99 (3f:4a99) jr .asm_fcacb .asm_fcac4 - ld hl, $8 + ld hl, wSprite01AnimFrameCounter - wSprite01SpriteStateData1 add hl, bc ld a, d or [hl] ld d, a .asm_fcacb - ld hl, $2 + ld hl, wSprite01SpriteImageIdx - wSprite01SpriteStateData1 add hl, bc ld [hl], d ret .asm_fcad1 - ld hl, $2 + ld hl, wSprite01SpriteImageIdx - wSprite01SpriteStateData1 add hl, bc ld [hl], $ff ret .asm_fcad8 - ld a, [wSpriteStateData1 + $2] + ld a, [wPlayerSpriteImageIdx] and $f or d - ld [wSpriteStateData1 + $f2], a + ld [wPikachuSpriteImageIdx], a ret Func_fcae2: ; fcae2 (3f:4ae2) - ld hl, $104 + ld hl, wSprite01MapY - wSprite01SpriteStateData1 add hl, bc ld a, [wYCoord] add $4 @@ -1005,7 +1040,7 @@ Func_fcae2: ; fcae2 (3f:4ae2) add $4 cp [hl] jr nz, .asm_fcaff - ld hl, $2 + ld hl, wSprite01SpriteImageIdx - wSprite01SpriteStateData1 add hl, bc ld [hl], $ff scf @@ -1015,58 +1050,58 @@ Func_fcae2: ; fcae2 (3f:4ae2) and a ret -Func_fcb01: ; fcb01 (3f:4b01) +IsPikachuRightNextToPlayer: ; fcb01 (3f:4b01) push bc push de push hl - ld bc, wSpriteStateData1 + $f0 + ld bc, wPikachuPictureID ld a, [wXCoord] add $4 ld d, a ld a, [wYCoord] add $4 ld e, a - ld hl, $104 + ld hl, wPlayerMapY - wPlayerSpriteStateData1 add hl, bc ld a, [hl] sub e and a - jr z, .asm_fcb30 + jr z, .equal cp $ff - jr z, .asm_fcb26 + jr z, .one_away cp $1 - jr z, .asm_fcb26 - jr .asm_fcb48 + jr z, .one_away + jr .bad -.asm_fcb26 - ld hl, $105 +.one_away + ld hl, wPlayerMapX - wPlayerSpriteStateData1 add hl, bc ld a, [hl] sub d - jr z, .asm_fcb43 - jr .asm_fcb48 + jr z, .good + jr .bad -.asm_fcb30 - ld hl, $105 +.equal + ld hl, wPlayerMapX - wPlayerSpriteStateData1 add hl, bc ld a, [hl] sub d cp $ff - jr z, .asm_fcb43 + jr z, .good cp $1 - jr z, .asm_fcb43 + jr z, .good and a - jr z, .asm_fcb43 - jr .asm_fcb48 + jr z, .good + jr .bad -.asm_fcb43 +.good pop hl pop de pop bc scf ret -.asm_fcb48 +.bad pop hl pop de pop bc @@ -1079,14 +1114,14 @@ GetPikachuFacingDirectionAndReturnToE: ; fcb4d (3f:4b4d) ret GetPikachuFacingDirection: ; fcb52 (3f:4b52) - ld bc, wSpriteStateData1 + $f0 + ld bc, wPikachuPictureID ld a, [wXCoord] add $4 ld d, a ld a, [wYCoord] add $4 ld e, a - ld hl, wSpriteStateData2 - wSpriteStateData1 + 4 + ld hl, wPlayerMapY - wPlayerSpriteStateData1 add hl, bc ld a, [hl] cp e @@ -1100,7 +1135,7 @@ GetPikachuFacingDirection: ; fcb52 (3f:4b52) ret .asm_fcb71 - ld hl, wSpriteStateData2 - wSpriteStateData1 + 5 + ld hl, wPlayerMapX - wPlayerSpriteStateData1 add hl, bc ld a, [hl] cp d @@ -1138,7 +1173,7 @@ AppendPikachuFollowCommandToBuffer: ; fcb94 (3f:4b94) ld [hl], a ret -Func_fcba1: ; fcba1 (3f:4ba1) +RefreshPikachuFollow: ; fcba1 (3f:4ba1) call ClearPikachuFollowCommandBuffer call GetPikachuFollowCommand ret c @@ -1146,8 +1181,8 @@ Func_fcba1: ; fcba1 (3f:4ba1) ret GetPikachuFollowCommand: ; fcbac (3f:4bac) - ld bc, wSpriteStateData1 + $f0 - ld hl, wSpriteStateData2 - wSpriteStateData1 + 4 + ld bc, wPikachuPictureID + ld hl, wPlayerMapY - wPlayerSpriteStateData1 add hl, bc ld a, [wYCoord] add $4 @@ -1178,7 +1213,7 @@ GetPikachuFollowCommand: ; fcbac (3f:4bac) ret .checkXCoord - ld hl, wSpriteStateData2 - wSpriteStateData1 + 5 + ld hl, wPlayerMapX - wPlayerSpriteStateData1 add hl, bc ld a, [wXCoord] add $4 @@ -1369,7 +1404,7 @@ Func_fccb2:: ; fccb2 (3f:4cb2) ld a, [wXCoord] add $4 ld e, a - ld a, [wSpriteStateData2 + $f4] + ld a, [wPikachuMapY] cp d jr z, .asm_fccd9 ld a, SPRITE_FACING_DOWN @@ -1378,7 +1413,7 @@ Func_fccb2:: ; fccb2 (3f:4cb2) jr .asm_fccea .asm_fccd9 - ld a, [wSpriteStateData2 + $f5] + ld a, [wPikachuMapX] cp e jr z, .asm_fcce7 ld a, SPRITE_FACING_RIGHT @@ -1387,9 +1422,9 @@ Func_fccb2:: ; fccb2 (3f:4cb2) jr .asm_fccea .asm_fcce7 - ld a, [wSpriteStateData1 + $9] + ld a, [wPlayerFacingDirection] .asm_fccea - ld [wSpriteStateData1 + $f9], a + ld [wPikachuFacingDirection], a ret Func_fccee: ; fccee (3f:4cee) @@ -1799,6 +1834,8 @@ IsSurfingPikachuInThePlayersParty:: ; fceab (3f:4eab) and a ret +INCLUDE "engine/pikachu_emotions.asm" +INCLUDE "engine/pikachu_movement.asm" INCLUDE "engine/pikachu_pic_animation.asm" Func_fe66e: diff --git a/engine/hidden_object_functions14.asm b/engine/hidden_object_functions14.asm index 0724f962..e69e802c 100755 --- a/engine/hidden_object_functions14.asm +++ b/engine/hidden_object_functions14.asm @@ -89,7 +89,7 @@ FightingDojoText: ; 5298a (14:698a) db "@" PrintIndigoPlateauHQText: ; 5298f (14:698f) - ld a, [wSpriteStateData1 + 9] + ld a, [wPlayerFacingDirection] cp SPRITE_FACING_UP ret nz call EnableAutoTextBoxDrawing diff --git a/engine/hidden_object_functions17.asm b/engine/hidden_object_functions17.asm index 8e5920d5..31f9befc 100755 --- a/engine/hidden_object_functions17.asm +++ b/engine/hidden_object_functions17.asm @@ -14,7 +14,7 @@ RedBedroomPCText: ; 5db8e (17:5b8e) db $fc ; FuncTX_ItemStoragePC Route15GateLeftBinoculars: ; 5db8f (17:5b8f) - ld a, [wSpriteStateData1 + 9] + ld a, [wPlayerFacingDirection] cp SPRITE_FACING_UP ret nz call EnableAutoTextBoxDrawing diff --git a/engine/hidden_object_functions18.asm b/engine/hidden_object_functions18.asm index 443f8369..cdba142b 100755 --- a/engine/hidden_object_functions18.asm +++ b/engine/hidden_object_functions18.asm @@ -3,7 +3,7 @@ GymStatues: ; 625e8 (18:65e8) ; if in a gym and don’t have the corresponding badge, a = GymStatueText1_id and jp PrintPredefTextID ; else ret call EnableAutoTextBoxDrawing - ld a, [wSpriteStateData1 + 9] + ld a, [wPlayerFacingDirection] cp SPRITE_FACING_UP ret nz ld hl, .BadgeFlags @@ -64,7 +64,7 @@ PrintBenchGuyText: ; 6245d (18:645d) .match ld a, [hli] ld b, a - ld a, [wSpriteStateData1 + 9] + ld a, [wPlayerFacingDirection] cp b jr nz, .loop ; player isn't facing left at the bench guy ld a, [hl] @@ -192,7 +192,7 @@ BookcaseText: ; 62511 (18:6511) db "@" OpenPokemonCenterPC: ; 62516 (18:6516) - ld a, [wSpriteStateData1 + 9] + ld a, [wPlayerFacingDirection] cp SPRITE_FACING_UP ; check to see if player is facing up ret nz call EnableAutoTextBoxDrawing diff --git a/engine/hidden_object_functions3.asm b/engine/hidden_object_functions3.asm index e43ae451..78da8274 100755 --- a/engine/hidden_object_functions3.asm +++ b/engine/hidden_object_functions3.asm @@ -1,6 +1,6 @@ ; prints text for bookshelves in buildings without sign events PrintBookshelfText: ; f9de (3:79de) - ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction + ld a, [wPlayerFacingDirection] ; player's sprite facing direction cp SPRITE_FACING_UP jr nz, .noMatch ; facing up diff --git a/engine/hidden_object_functions7.asm b/engine/hidden_object_functions7.asm index 3108a836..c49c04bd 100755 --- a/engine/hidden_object_functions7.asm +++ b/engine/hidden_object_functions7.asm @@ -115,7 +115,7 @@ GameOverText: ; 1e3aa (7:63aa) db "@" PrintCinnabarQuiz: ; 1e3af (7:63af) - ld a, [wSpriteStateData1 + 9] + ld a, [wPlayerFacingDirection] cp SPRITE_FACING_UP ret nz call EnableAutoTextBoxDrawing @@ -366,7 +366,7 @@ MagazinesText: ; 1e544 (7:6544) BillsHousePC: ; 1e549 (7:6549) call EnableAutoTextBoxDrawing - ld a, [wSpriteStateData1 + 9] + ld a, [wPlayerFacingDirection] cp SPRITE_FACING_UP ret nz CheckEvent EVENT_LEFT_BILLS_HOUSE_AFTER_HELPING @@ -497,7 +497,7 @@ BillsHousePokemonListText2: ; 1e67f (7:667f) db "@" DisplayOakLabEmailText: ; 1e684 (7:6684) - ld a, [wSpriteStateData1 + 9] + ld a, [wPlayerFacingDirection] cp SPRITE_FACING_UP ret nz call EnableAutoTextBoxDrawing diff --git a/engine/items/items.asm b/engine/items/items.asm index f37f9f47..e147f5a5 100755 --- a/engine/items/items.asm +++ b/engine/items/items.asm @@ -1,18 +1,18 @@ UseItem_: ; d2ed (3:52ed) - ld a,1 - ld [wActionResultOrTookBattleTurn],a ; initialise to success value - ld a,[wcf91] ;contains item_ID - cp a,HM_01 - jp nc,ItemUseTMHM - ld hl,ItemUsePtrTable + ld a, 1 + ld [wActionResultOrTookBattleTurn], a ; initialise to success value + ld a, [wcf91] ;contains item_ID + cp a, HM_01 + jp nc, ItemUseTMHM + ld hl, ItemUsePtrTable dec a add a - ld c,a - ld b,0 - add hl,bc - ld a,[hli] - ld h,[hl] - ld l,a + ld c, a + ld b, 0 + add hl, bc + ld a, [hli] + ld h, [hl] + ld l, a jp [hl] ItemUsePtrTable: ; d307 (3:5307) @@ -101,135 +101,137 @@ ItemUsePtrTable: ; d307 (3:5307) dw ItemUsePPRestore ; MAX_ELIXER ItemUseBall: ; d3ad (3:53ad) - ld a,[wIsInBattle] + ld a, [wIsInBattle] and a - jp z,ItemUseNotTime ; not in battle + jp z, ItemUseNotTime ; not in battle dec a - jp nz,ThrowBallAtTrainerMon - ld a,[wBattleType] + jp nz, ThrowBallAtTrainerMon + ld a, [wBattleType] cp $1 - jr z,.UseBall + jr z, .UseBall cp $4 ; pikachu battle? - jr z,.UseBall - ld a,[wPartyCount] ;is Party full? - cp a,PARTY_LENGTH - jr nz,.UseBall - ld a,[wNumInBox] ;is Box full? - cp a,MONS_PER_BOX - jp z,BoxFullCannotThrowBall + jr z, .UseBall + ld a, [wPartyCount] ;is Party full? + cp a, PARTY_LENGTH + jr nz, .UseBall + ld a, [wNumInBox] ;is Box full? + cp a, MONS_PER_BOX + jp z, BoxFullCannotThrowBall .UseBall ;ok, you can use a ball xor a - ld [wCapturedMonSpecies],a - ld a,[wBattleType] - cp a,2 ;SafariBattle - jr nz,.skipSafariZoneCode + ld [wCapturedMonSpecies], a + ld a, [wBattleType] + cp a, 2 ;SafariBattle + jr nz, .skipSafariZoneCode .safariZone ; remove a Safari Ball from inventory - ld hl,wNumSafariBalls + ld hl, wNumSafariBalls dec [hl] .skipSafariZoneCode call RunDefaultPaletteCommand - ld a,$43 - ld [wd11e],a + ld a, $43 + ld [wd11e], a call LoadScreenTilesFromBuffer1 ;restore screenBuffer from Backup - ld hl,ItemUseText00 + ld hl, ItemUseText00 call PrintText callab IsGhostBattle - ld b,$10 - jp z,.next12 - ld a,[wBattleType] + ld b, $10 + jp z, .next12 + ld a, [wBattleType] cp $1 - jr z,.oldManBattle + jr z, .oldManBattle cp $4 - jr z,.oldManBattle ; pikachu battle technically old man battle + jr z, .oldManBattle ; pikachu battle technically old man battle jr .notOldManBattle + .oldManBattle - ld hl,wGrassRate - ld de,wPlayerName - ld bc,NAME_LENGTH + ld hl, wGrassRate + ld de, wPlayerName + ld bc, NAME_LENGTH call CopyData ; save the player's name in the Wild Monster data ld a, [wBattleType] cp $1 - jp nz,.BallSuccess - ld a,$1 + jp nz, .BallSuccess + ld a, $1 ld [wCapturedMonSpecies], a ld a, [wd74c] bit 7, a ld b, $63 - jp nz,.next12 + jp nz, .next12 jp .BallSuccess + .notOldManBattle - ld a,[wCurMap] - cp a,POKEMONTOWER_6 - jr nz,.loop - ld a,[wEnemyMonSpecies2] - cp a,MAROWAK - ld b,$10 - jp z,.next12 + ld a, [wCurMap] + cp a, POKEMONTOWER_6 + jr nz, .loop + ld a, [wEnemyMonSpecies2] + cp a, MAROWAK + ld b, $10 + jp z, .next12 ; if not fighting ghost Marowak, loop until a random number in the current ; pokeball's allowed range is found .loop call Random - ld b,a - ld hl,wcf91 + ld b, a + ld hl, wcf91 .asm_d54a - ld a,[hl] - cp a,MASTER_BALL - jp z,.BallSuccess - cp a,POKE_BALL - jr z,.checkForAilments - ld a,200 + ld a, [hl] + cp a, MASTER_BALL + jp z, .BallSuccess + cp a, POKE_BALL + jr z, .checkForAilments + ld a, 200 cp b - jr c,.loop ;get only numbers <= 200 for Great Ball - ld a,[hl] - cp a,GREAT_BALL - jr z,.checkForAilments - ld a,150 ;get only numbers <= 150 for Ultra Ball + jr c, .loop ;get only numbers <= 200 for Great Ball + ld a, [hl] + cp a, GREAT_BALL + jr z, .checkForAilments + ld a, 150 ;get only numbers <= 150 for Ultra Ball cp b - jr c,.loop + jr c, .loop .checkForAilments ; pokemon can be caught more easily with any (primary) status ailment ; Frozen/Asleep pokemon are relatively even easier to catch ; for Frozen/Asleep pokemon, any random number from 0-24 ensures a catch. ; for the others, a random number from 0-11 ensures a catch. - ld a,[wEnemyMonStatus] ;status ailments + ld a, [wEnemyMonStatus] ;status ailments and a - jr z,.noAilments + jr z, .noAilments and a, 1 << FRZ | SLP ;is frozen and/or asleep? - ld c,12 - jr z,.notFrozenOrAsleep - ld c,25 + ld c, 12 + jr z, .notFrozenOrAsleep + ld c, 25 .notFrozenOrAsleep - ld a,b + ld a, b sub c - jp c,.BallSuccess - ld b,a + jp c, .BallSuccess + ld b, a .noAilments push bc ;save RANDOM number xor a - ld [H_MULTIPLICAND],a - ld hl,wEnemyMonMaxHP - ld a,[hli] - ld [H_MULTIPLICAND + 1],a - ld a,[hl] - ld [H_MULTIPLICAND + 2],a - ld a,255 - ld [H_MULTIPLIER],a + ld [H_MULTIPLICAND], a + ld hl, wEnemyMonMaxHP + ld a, [hli] + ld [H_MULTIPLICAND + 1], a + ld a, [hl] + ld [H_MULTIPLICAND + 2], a + ld a, 255 + ld [H_MULTIPLIER], a call Multiply ; MaxHP * 255 - ld a,[wcf91] + ld a, [wcf91] cp GREAT_BALL - ld a,12 ;any other BallFactor - jr nz,.next7 - ld a,8 + ld a, 12 ;any other BallFactor + jr nz, .next7 + ld a, 8 .next7 - ld [H_DIVISOR],a - ld b,4 ; number of bytes in dividend + ld [H_DIVISOR], a + ld b, 4 ; number of bytes in dividend call Divide - ld hl,wEnemyMonHP - ld a,[hli] - ld b,a - ld a,[hl] + ld hl, wEnemyMonHP + ld a, [hli] + ld b, a + ld a, [hl] ; explanation: we have a 16-bit value equal to [b << 8 | a]. ; This number is divided by 4. The result is 8 bit (reg. a). @@ -239,242 +241,247 @@ ItemUseBall: ; d3ad (3:53ad) srl b rr a ; a = current HP / 4 and a - jr nz,.next8 + jr nz, .next8 inc a .next8 - ld [H_DIVISOR],a - ld b,4 + ld [H_DIVISOR], a + ld b, 4 call Divide ; ((MaxHP * 255) / BallFactor) / (CurHP / 4) - ld a,[H_QUOTIENT + 2] + ld a, [H_QUOTIENT + 2] and a - jr z,.next9 - ld a,255 - ld [H_QUOTIENT + 3],a + jr z, .next9 + ld a, 255 + ld [H_QUOTIENT + 3], a .next9 pop bc - ld a,[wEnemyMonCatchRate] ;enemy: Catch Rate + ld a, [wEnemyMonCatchRate] ;enemy: Catch Rate cp b - jr c,.next10 - ld a,[H_QUOTIENT + 2] + jr c, .next10 + ld a, [H_QUOTIENT + 2] and a - jr nz,.BallSuccess ; if ((MaxHP * 255) / BallFactor) / (CurHP / 4) > 0x255, automatic success + jr nz, .BallSuccess ; if ((MaxHP * 255) / BallFactor) / (CurHP / 4) > 0x255, automatic success call Random - ld b,a - ld a,[H_QUOTIENT + 3] + ld b, a + ld a, [H_QUOTIENT + 3] cp b - jr c,.next10 + jr c, .next10 .BallSuccess jr .BallSuccess2 + .next10 - ld a,[H_QUOTIENT + 3] - ld [wd11e],a + ld a, [H_QUOTIENT + 3] + ld [wd11e], a xor a - ld [H_MULTIPLICAND],a - ld [H_MULTIPLICAND + 1],a - ld a,[wEnemyMonCatchRate] ;enemy: Catch Rate - ld [H_MULTIPLICAND + 2],a - ld a,100 - ld [H_MULTIPLIER],a + ld [H_MULTIPLICAND], a + ld [H_MULTIPLICAND + 1], a + ld a, [wEnemyMonCatchRate] ;enemy: Catch Rate + ld [H_MULTIPLICAND + 2], a + ld a, 100 + ld [H_MULTIPLIER], a call Multiply ; CatchRate * 100 - ld a,[wcf91] - ld b,255 + ld a, [wcf91] + ld b, 255 cp POKE_BALL - jr z,.next11 - ld b,200 + jr z, .next11 + ld b, 200 cp GREAT_BALL - jr z,.next11 - ld b,150 + jr z, .next11 + ld b, 150 cp ULTRA_BALL - jr z,.next11 + jr z, .next11 .next11 - ld a,b - ld [H_DIVISOR],a - ld b,4 + ld a, b + ld [H_DIVISOR], a + ld b, 4 call Divide - ld a,[H_QUOTIENT + 2] + ld a, [H_QUOTIENT + 2] and a - ld b,$63 - jr nz,.next12 - ld a,[wd11e] - ld [H_MULTIPLIER],a + ld b, $63 + jr nz, .next12 + ld a, [wd11e] + ld [H_MULTIPLIER], a call Multiply - ld a,255 - ld [H_DIVISOR],a - ld b,4 + ld a, 255 + ld [H_DIVISOR], a + ld b, 4 call Divide - ld a,[wEnemyMonStatus] ;status ailments + ld a, [wEnemyMonStatus] ;status ailments and a - jr z,.next13 + jr z, .next13 and 1 << FRZ | SLP - ld b,5 - jr z,.next14 - ld b,10 + ld b, 5 + jr z, .next14 + ld b, 10 .next14 - ld a,[H_QUOTIENT + 3] + ld a, [H_QUOTIENT + 3] add b - ld [H_QUOTIENT + 3],a + ld [H_QUOTIENT + 3], a .next13 - ld a,[H_QUOTIENT + 3] - cp a,10 - ld b,$20 - jr c,.next12 - cp a,30 - ld b,$61 - jr c,.next12 - cp a,70 - ld b,$62 - jr c,.next12 - ld b,$63 + ld a, [H_QUOTIENT + 3] + cp a, 10 + ld b, $20 + jr c, .next12 + cp a, 30 + ld b, $61 + jr c, .next12 + cp a, 70 + ld b, $62 + jr c, .next12 + ld b, $63 .next12 - ld a,b - ld [wPokeBallAnimData],a + ld a, b + ld [wPokeBallAnimData], a .BallSuccess2 - ld c,20 + ld c, 20 call DelayFrames - ld a,TOSS_ANIM - ld [wAnimationID],a + ld a, TOSS_ANIM + ld [wAnimationID], a xor a - ld [H_WHOSETURN],a - ld [wAnimationType],a - ld [wDamageMultipliers],a - ld a,[wWhichPokemon] + ld [H_WHOSETURN], a + ld [wAnimationType], a + ld [wDamageMultipliers], a + ld a, [wWhichPokemon] push af - ld a,[wcf91] + ld a, [wcf91] push af predef MoveAnimation pop af - ld [wcf91],a + ld [wcf91], a pop af - ld [wWhichPokemon],a - ld a,[wPokeBallAnimData] - cp a,$10 - ld hl,ItemUseBallText00 - jp z,.printText0 - cp a,$20 - ld hl,ItemUseBallText01 - jp z,.printText0 - cp a,$61 - ld hl,ItemUseBallText02 - jp z,.printText0 - cp a,$62 - ld hl,ItemUseBallText03 - jp z,.printText0 - cp a,$63 - ld hl,ItemUseBallText04 - jp z,.printText0 - ld hl,wEnemyMonHP ;current HP - ld a,[hli] + ld [wWhichPokemon], a + ld a, [wPokeBallAnimData] + cp a, $10 + ld hl, ItemUseBallText00 + jp z, .printText0 + cp a, $20 + ld hl, ItemUseBallText01 + jp z, .printText0 + cp a, $61 + ld hl, ItemUseBallText02 + jp z, .printText0 + cp a, $62 + ld hl, ItemUseBallText03 + jp z, .printText0 + cp a, $63 + ld hl, ItemUseBallText04 + jp z, .printText0 + ld hl, wEnemyMonHP ;current HP + ld a, [hli] push af - ld a,[hli] + ld a, [hli] push af ;backup currentHP... inc hl - ld a,[hl] + ld a, [hl] push af ;...and status ailments push hl - ld hl,wEnemyBattleStatus3 - bit Transformed,[hl] - jr z,.next15 - ld a,$4c - ld [wEnemyMonSpecies2],a + ld hl, wEnemyBattleStatus3 + bit Transformed, [hl] + jr z, .next15 + ld a, $4c + ld [wEnemyMonSpecies2], a jr .next16 + .next15 - set Transformed,[hl] - ld hl,wTransformedEnemyMonOriginalDVs - ld a,[wEnemyMonDVs] - ld [hli],a - ld a,[wEnemyMonDVs + 1] - ld [hl],a + set Transformed, [hl] + ld hl, wTransformedEnemyMonOriginalDVs + ld a, [wEnemyMonDVs] + ld [hli], a + ld a, [wEnemyMonDVs + 1] + ld [hl], a .next16 - ld a,[wcf91] + ld a, [wcf91] push af - ld a,[wEnemyMonSpecies2] - ld [wcf91],a - ld a,[wEnemyMonLevel] - ld [wCurEnemyLVL],a + ld a, [wEnemyMonSpecies2] + ld [wcf91], a + ld a, [wEnemyMonLevel] + ld [wCurEnemyLVL], a callab LoadEnemyMonData pop af - ld [wcf91],a + ld [wcf91], a pop hl pop af - ld [hld],a + ld [hld], a dec hl pop af - ld [hld],a + ld [hld], a pop af - ld [hl],a - ld a,[wEnemyMonSpecies] ;enemy - ld [wCapturedMonSpecies],a - ld [wcf91],a - ld [wd11e],a - ld a,[wBattleType] + ld [hl], a + ld a, [wEnemyMonSpecies] ;enemy + ld [wCapturedMonSpecies], a + ld [wcf91], a + ld [wd11e], a + ld a, [wBattleType] cp $1 - jp z,.printText1 ; just barely out of reach for a relative jump + jp z, .printText1 ; just barely out of reach for a relative jump cp $4 - jr z,.printText1 - ld hl,ItemUseBallText05 + jr z, .printText1 + ld hl, ItemUseBallText05 call PrintText predef IndexToPokedex - ld a,[wd11e] + ld a, [wd11e] dec a - ld c,a - ld b,FLAG_TEST - ld hl,wPokedexOwned + ld c, a + ld b, FLAG_TEST + ld hl, wPokedexOwned predef FlagActionPredef - ld a,c + ld a, c push af - ld a,[wd11e] + ld a, [wd11e] dec a - ld c,a - ld b,FLAG_SET + ld c, a + ld b, FLAG_SET predef FlagActionPredef pop af and a - jr nz,.checkParty - ld hl,ItemUseBallText06 + jr nz, .checkParty + ld hl, ItemUseBallText06 call PrintText call ClearSprites - ld a,[wEnemyMonSpecies] ;caught mon_ID - ld [wd11e],a + ld a, [wEnemyMonSpecies] ;caught mon_ID + ld [wd11e], a predef ShowPokedexData .checkParty ld a, $1 ld [wd49c], a ld a, $85 ld [wPikachuMood], a - ld a,[wPartyCount] + ld a, [wPartyCount] cp PARTY_LENGTH ;is party full? - jr z,.sendToBox + jr z, .sendToBox xor a ; PLAYER_PARTY_DATA - ld [wMonDataLocation],a + ld [wMonDataLocation], a call ClearSprites ld hl, .emptyString call PrintText call AddPartyMon ;add mon to Party jr .End + .sendToBox call ClearSprites call SendNewMonToBox - ld hl,ItemUseBallText07 + ld hl, ItemUseBallText07 ld a, [wd7f1] bit 0, a - jr nz,.sendToBox2 - ld hl,ItemUseBallText08 + jr nz, .sendToBox2 + ld hl, ItemUseBallText08 .sendToBox2 call PrintText jr .End + .printText1 - ld hl,ItemUseBallText05 + ld hl, ItemUseBallText05 .printText0 call PrintText call ClearSprites .End - ld a,[wBattleType] + ld a, [wBattleType] and a ret nz - ld hl,wNumBagItems + ld hl, wNumBagItems inc a - ld [wItemQuantity],a + ld [wItemQuantity], a jp RemoveItemFromInventory + .emptyString db "@" @@ -503,7 +510,7 @@ ItemUseBallText05: ; d6b0 (3:56b0) ;"All right! {MonName} was caught!" ;play sound TX_FAR _ItemUseBallText05 - db $12,$06 + db $12, $06 db "@" ItemUseBallText07: ; d6b7 (3:59b7) ;"X was transferred to Bill's PC" @@ -518,46 +525,47 @@ ItemUseBallText06: ; d6c1 (3:56c1) ;"New DEX data will be added..." ;play sound TX_FAR _ItemUseBallText06 - db $13,$06 + db $13, $06 db "@" ItemUseTownMap: ; d6c8 (3:56c8) - ld a,[wIsInBattle] + ld a, [wIsInBattle] and a - jp nz,ItemUseNotTime + jp nz, ItemUseNotTime jpba DisplayTownMap ItemUseBicycle: ; d6d7 (3:56d7) - ld a,[wIsInBattle] + ld a, [wIsInBattle] and a - jp nz,ItemUseNotTime - ld a,[wWalkBikeSurfState] - ld [wWalkBikeSurfStateCopy],a - cp a,2 ; is the player surfing? - jp z,ItemUseNotTime + jp nz, ItemUseNotTime + ld a, [wWalkBikeSurfState] + ld [wWalkBikeSurfStateCopy], a + cp a, 2 ; is the player surfing? + jp z, ItemUseNotTime dec a ; is player already bicycling? - jr nz,.tryToGetOnBike + jr nz, .tryToGetOnBike .getOffBike call ItemUseReloadOverworldData xor a - ld [wWalkBikeSurfState],a ; change player state to walking + ld [wWalkBikeSurfState], a ; change player state to walking ld a, $00 - ld [wd431], a + ld [wPikachuSpawnState], a call PlayDefaultMusic ; play walking music - ld hl,GotOffBicycleText + ld hl, GotOffBicycleText jp PrintText + .tryToGetOnBike call IsBikeRidingAllowed - jp nc,NoCyclingAllowedHere + jp nc, NoCyclingAllowedHere call ItemUseReloadOverworldData xor a ; no keys pressed - ld [hJoyHeld],a ; current joypad state + ld [hJoyHeld], a ; current joypad state ld a, $1 - ld [wWalkBikeSurfState],a ; change player state to bicycling + ld [wWalkBikeSurfState], a ; change player state to bicycling call PlayDefaultMusic ; play bike riding music xor a - ld [wWalkBikeSurfState],a - ld hl,GotOnBicycleText + ld [wWalkBikeSurfState], a + ld hl, GotOnBicycleText call PrintText ld a, $1 ld [wWalkBikeSurfState], a @@ -565,79 +573,82 @@ ItemUseBicycle: ; d6d7 (3:56d7) ; used for Surf out-of-battle effect ItemUseSurfboard: ; d725 (3:5725) - ld a,[wWalkBikeSurfState] - ld [wWalkBikeSurfStateCopy],a - cp a,2 ; is the player already surfing? - jr z,.tryToStopSurfing + ld a, [wWalkBikeSurfState] + ld [wWalkBikeSurfStateCopy], a + cp a, 2 ; is the player already surfing? + jr z, .tryToStopSurfing .tryToSurf call IsNextTileShoreOrWater - jp nc,SurfingAttemptFailed - ld hl,TilePairCollisionsWater + jp nc, SurfingAttemptFailed + ld hl, TilePairCollisionsWater call CheckForTilePairCollisions - jp c,SurfingAttemptFailed + jp c, SurfingAttemptFailed .surf call .makePlayerMoveForward - ld hl,wd730 - set 7,[hl] - ld a,2 - ld [wWalkBikeSurfState],a ; change player state to surfing + ld hl, wd730 + set 7, [hl] + ld a, 2 + ld [wWalkBikeSurfState], a ; change player state to surfing call PlayDefaultMusic ; play surfing music - ld hl,SurfingGotOnText + ld hl, SurfingGotOnText jp PrintText + .tryToStopSurfing xor a - ld [hSpriteIndexOrTextID],a - ld d,16 ; talking range in pixels (normal range) + ld [hSpriteIndexOrTextID], a + ld d, 16 ; talking range in pixels (normal range) call IsSpriteInFrontOfPlayer2 - res 7,[hl] - ld a,[hSpriteIndexOrTextID] + res 7, [hl] + ld a, [hSpriteIndexOrTextID] and a ; is there a sprite in the way? - jr nz,.cannotStopSurfing - ld hl,TilePairCollisionsWater + jr nz, .cannotStopSurfing + ld hl, TilePairCollisionsWater call CheckForTilePairCollisions - jr c,.cannotStopSurfing - ld a,[wTileInFrontOfPlayer] - ld c,a + jr c, .cannotStopSurfing + ld a, [wTileInFrontOfPlayer] + ld c, a call IsTilePassable - jr nc,.stopSurfing + jr nc, .stopSurfing .cannotStopSurfing - ld hl,SurfingNoPlaceToGetOffText + ld hl, SurfingNoPlaceToGetOffText jp PrintText + .stopSurfing call .makePlayerMoveForward - ld a,$3 - ld [wd431], a - ld hl,wPikachuOverworldStateFlags - set 5,[hl] - ld hl,wd730 - set 7,[hl] + ld a, $3 + ld [wPikachuSpawnState], a + ld hl, wPikachuOverworldStateFlags + set 5, [hl] + ld hl, wd730 + set 7, [hl] xor a - ld [wWalkBikeSurfState],a ; change player state to walking + ld [wWalkBikeSurfState], a ; change player state to walking dec a - ld [wJoyIgnore],a + ld [wJoyIgnore], a call PlayDefaultMusic ; play walking music call GBPalWhiteOutWithDelay3 jp LoadWalkingPlayerSpriteGraphics + ; uses a simulated button press to make the player move forward .makePlayerMoveForward - ld a,[wPlayerDirection] ; direction the player is going - bit PLAYER_DIR_BIT_UP,a - ld b,D_UP - jr nz,.storeSimulatedButtonPress - bit PLAYER_DIR_BIT_DOWN,a - ld b,D_DOWN - jr nz,.storeSimulatedButtonPress - bit PLAYER_DIR_BIT_LEFT,a - ld b,D_LEFT - jr nz,.storeSimulatedButtonPress - ld b,D_RIGHT + ld a, [wPlayerDirection] ; direction the player is going + bit PLAYER_DIR_BIT_UP, a + ld b, D_UP + jr nz, .storeSimulatedButtonPress + bit PLAYER_DIR_BIT_DOWN, a + ld b, D_DOWN + jr nz, .storeSimulatedButtonPress + bit PLAYER_DIR_BIT_LEFT, a + ld b, D_LEFT + jr nz, .storeSimulatedButtonPress + ld b, D_RIGHT .storeSimulatedButtonPress - ld a,b - ld [wSimulatedJoypadStatesEnd],a + ld a, b + ld [wSimulatedJoypadStatesEnd], a xor a - ld [wWastedByteCD39],a + ld [wWastedByteCD39], a inc a - ld [wSimulatedJoypadStatesIndex],a + ld [wSimulatedJoypadStatesIndex], a ret SurfingGotOnText: ; d7c1 (3:57c1) @@ -652,25 +663,25 @@ ItemUsePokedex: ; d7cb (3:57cb) predef_jump ShowPokedexMenu ItemUseEvoStone: ; d7d0 (3:57d0) - ld a,[wIsInBattle] + ld a, [wIsInBattle] and a - jp nz,ItemUseNotTime - ld a,[wWhichPokemon] + jp nz, ItemUseNotTime + ld a, [wWhichPokemon] push af - ld a,[wcf91] - ld [wEvoStoneItemID],a + ld a, [wcf91] + ld [wEvoStoneItemID], a push af - ld a,EVO_STONE_PARTY_MENU - ld [wPartyMenuTypeOrMessageID],a - ld a,$ff - ld [wUpdateSpritesEnabled],a + ld a, EVO_STONE_PARTY_MENU + ld [wPartyMenuTypeOrMessageID], a + ld a, $ff + ld [wUpdateSpritesEnabled], a call DisplayPartyMenu ld a, [wcf91] ld [wLoadedMon], a pop bc - jr c,.canceledItemUse - ld a,b - ld [wcf91],a + jr c, .canceledItemUse + ld a, b + ld [wcf91], a call Func_d85d jr nc, .noEffect callab IsThisPartymonStarterPikachu_Party @@ -687,24 +698,26 @@ ItemUseEvoStone: ; d7d0 (3:57d0) ld a, $82 ld [wPikachuMood], a jr .canceledItemUse + .notPlayerPikachu - ld a,SFX_HEAL_AILMENT + ld a, SFX_HEAL_AILMENT call PlaySoundWaitForCurrent call WaitForSoundToFinish - ld a,$01 - ld [wForceEvolution],a + ld a, $01 + ld [wForceEvolution], a callab TryEvolvingMon ; try to evolve pokemon pop af - ld [wWhichPokemon],a - ld hl,wNumBagItems - ld a,1 ; remove 1 stone - ld [wItemQuantity],a + ld [wWhichPokemon], a + ld hl, wNumBagItems + ld a, 1 ; remove 1 stone + ld [wItemQuantity], a jp RemoveItemFromInventory + .noEffect call ItemUseNoEffect .canceledItemUse xor a - ld [wActionResultOrTookBattleTurn],a ; item not used + ld [wActionResultOrTookBattleTurn], a ; item not used pop af ret @@ -748,6 +761,7 @@ Func_d85d: ; d85d (3:585d) jr nz, .loop scf ret + .cannotEvolveWithUsedStone and a ret @@ -757,42 +771,43 @@ RefusingText: ; d8a2 (3:58a2) db "@" ItemUseVitamin: ; d8a7 (3:58a7) - ld a,[wIsInBattle] + ld a, [wIsInBattle] and a - jp nz,ItemUseNotTime + jp nz, ItemUseNotTime ItemUseMedicine: ; d8ae (3:58ae) - ld a,[wPartyCount] + ld a, [wPartyCount] and a - jp z,Func_e4bf - ld a,[wWhichPokemon] + jp z, Func_e4bf + ld a, [wWhichPokemon] push af - ld a,[wcf91] + ld a, [wcf91] push af - ld a,USE_ITEM_PARTY_MENU - ld [wPartyMenuTypeOrMessageID],a - ld a,$ff - ld [wUpdateSpritesEnabled],a - ld a,[wPseudoItemID] + ld a, USE_ITEM_PARTY_MENU + ld [wPartyMenuTypeOrMessageID], a + ld a, $ff + ld [wUpdateSpritesEnabled], a + ld a, [wPseudoItemID] and a ; using Softboiled? - jr z,.notUsingSoftboiled + jr z, .notUsingSoftboiled ; if using softboiled call GoBackToPartyMenu jr .getPartyMonDataAddress + .notUsingSoftboiled call DisplayPartyMenu .getPartyMonDataAddress - jp c,.canceledItemUse - ld hl,wPartyMons - ld bc,wPartyMon2 - wPartyMon1 - ld a,[wWhichPokemon] + jp c, .canceledItemUse + ld hl, wPartyMons + ld bc, wPartyMon2 - wPartyMon1 + ld a, [wWhichPokemon] call AddNTimes - ld a,[wWhichPokemon] - ld [wUsedItemOnWhichPokemon],a - ld d,a - ld a,[wcf91] - ld e,a - ld [wd0b5],a + ld a, [wWhichPokemon] + ld [wUsedItemOnWhichPokemon], a + ld d, a + ld a, [wcf91] + ld e, a + ld [wd0b5], a pop af push af cp $28 @@ -804,90 +819,92 @@ ItemUseMedicine: ; d8ae (3:58ae) pop hl .asm_d906 pop af - ld [wcf91],a + ld [wcf91], a pop af - ld [wWhichPokemon],a - ld a,[wPseudoItemID] + ld [wWhichPokemon], a + ld a, [wPseudoItemID] and a ; using Softboiled? - jr z,.checkItemType + jr z, .checkItemType ; if using softboiled - ld a,[wWhichPokemon] + ld a, [wWhichPokemon] cp d ; is the pokemon trying to use softboiled on itself? - jr z,ItemUseMedicine ; if so, force another choice + jr z, ItemUseMedicine ; if so, force another choice .checkItemType - ld a,[wcf91] - cp a,REVIVE - jr nc,.healHP ; if it's a Revive or Max Revive - cp a,FULL_HEAL - jr z,.cureStatusAilment ; if it's a Full Heal - cp a,HP_UP - jp nc,.useVitamin ; if it's a vitamin or Rare Candy - cp a,FULL_RESTORE - jr nc,.healHP ; if it's a Full Restore or one of the potions + ld a, [wcf91] + cp a, REVIVE + jr nc, .healHP ; if it's a Revive or Max Revive + cp a, FULL_HEAL + jr z, .cureStatusAilment ; if it's a Full Heal + cp a, HP_UP + jp nc, .useVitamin ; if it's a vitamin or Rare Candy + cp a, FULL_RESTORE + jr nc, .healHP ; if it's a Full Restore or one of the potions ; fall through if it's one of the status-specifc healing items .cureStatusAilment - ld bc,4 - add hl,bc ; hl now points to status - ld a,[wcf91] + ld bc, 4 + add hl, bc ; hl now points to status + ld a, [wcf91] lb bc, ANTIDOTE_MSG, 1 << PSN - cp a,ANTIDOTE - jr z,.checkMonStatus + cp a, ANTIDOTE + jr z, .checkMonStatus lb bc, BURN_HEAL_MSG, 1 << BRN - cp a,BURN_HEAL - jr z,.checkMonStatus + cp a, BURN_HEAL + jr z, .checkMonStatus lb bc, ICE_HEAL_MSG, 1 << FRZ - cp a,ICE_HEAL - jr z,.checkMonStatus + cp a, ICE_HEAL + jr z, .checkMonStatus lb bc, AWAKENING_MSG, SLP - cp a,AWAKENING - jr z,.checkMonStatus + cp a, AWAKENING + jr z, .checkMonStatus lb bc, PARALYZ_HEAL_MSG, 1 << PAR - cp a,PARLYZ_HEAL - jr z,.checkMonStatus + cp a, PARLYZ_HEAL + jr z, .checkMonStatus lb bc, FULL_HEAL_MSG, $ff ; Full Heal .checkMonStatus - ld a,[hl] ; pokemon's status + ld a, [hl] ; pokemon's status and c ; does the pokemon have a status ailment the item can cure? - jp z,.healingItemNoEffect + jp z, .healingItemNoEffect ; if the pokemon has a status the item can heal xor a - ld [hl],a ; remove the status ailment in the party data - ld a,b - ld [wPartyMenuTypeOrMessageID],a ; the message to display for the item used - ld a,[wPlayerMonNumber] + ld [hl], a ; remove the status ailment in the party data + ld a, b + ld [wPartyMenuTypeOrMessageID], a ; the message to display for the item used + ld a, [wPlayerMonNumber] cp d ; is pokemon the item was used on active in battle? - jp nz,.doneHealing + jp nz, .doneHealing ; if it is active in battle xor a - ld [wBattleMonStatus],a ; remove the status ailment in the in-battle pokemon data + ld [wBattleMonStatus], a ; remove the status ailment in the in-battle pokemon data push hl - ld hl,wPlayerBattleStatus3 - res BadlyPoisoned,[hl] ; heal Toxic status + ld hl, wPlayerBattleStatus3 + res BadlyPoisoned, [hl] ; heal Toxic status pop hl - ld bc,30 - add hl,bc ; hl now points to party stats - ld de,wBattleMonMaxHP - ld bc,10 + ld bc, 30 + add hl, bc ; hl now points to party stats + ld de, wBattleMonMaxHP + ld bc, 10 call CopyData ; copy party stats to in-battle stat data predef DoubleOrHalveSelectedStats jp .doneHealing + .healHP inc hl ; hl = address of current HP - ld a,[hli] - ld b,a - ld [wHPBarOldHP+1],a - ld a,[hl] - ld c,a - ld [wHPBarOldHP],a ; current HP stored at wHPBarOldHP (2 bytes, big-endian) + ld a, [hli] + ld b, a + ld [wHPBarOldHP+1], a + ld a, [hl] + ld c, a + ld [wHPBarOldHP], a ; current HP stored at wHPBarOldHP (2 bytes, big-endian) or b - jr nz,.notFainted + jr nz, .notFainted .fainted - ld a,[wcf91] - cp a,REVIVE - jr z,.updateInBattleFaintedData - cp a,MAX_REVIVE - jr z,.updateInBattleFaintedData + ld a, [wcf91] + cp a, REVIVE + jr z, .updateInBattleFaintedData + cp a, MAX_REVIVE + jr z, .updateInBattleFaintedData jp .healingItemNoEffect + .updateInBattleFaintedData ld a, [wWhichPokemon] push af @@ -903,486 +920,499 @@ ItemUseMedicine: ; d8ae (3:58ae) pop af ld [wWhichPokemon], a - ld a,[wIsInBattle] + ld a, [wIsInBattle] and a - jr z,.compareCurrentHPToMaxHP + jr z, .compareCurrentHPToMaxHP push hl push de push bc - ld a,[wUsedItemOnWhichPokemon] - ld c,a - ld hl,wPartyFoughtCurrentEnemyFlags - ld b,FLAG_TEST + ld a, [wUsedItemOnWhichPokemon] + ld c, a + ld hl, wPartyFoughtCurrentEnemyFlags + ld b, FLAG_TEST predef FlagActionPredef - ld a,c + ld a, c and a - jr z,.next - ld a,[wUsedItemOnWhichPokemon] - ld c,a - ld hl,wPartyGainExpFlags - ld b,FLAG_SET + jr z, .next + ld a, [wUsedItemOnWhichPokemon] + ld c, a + ld hl, wPartyGainExpFlags + ld b, FLAG_SET predef FlagActionPredef .next pop bc pop de pop hl jr .compareCurrentHPToMaxHP + .notFainted - ld a,[wcf91] - cp a,REVIVE - jp z,.healingItemNoEffect - cp a,MAX_REVIVE - jp z,.healingItemNoEffect + ld a, [wcf91] + cp a, REVIVE + jp z, .healingItemNoEffect + cp a, MAX_REVIVE + jp z, .healingItemNoEffect .compareCurrentHPToMaxHP push hl push bc - ld bc,32 - add hl,bc ; hl now points to max HP + ld bc, 32 + add hl, bc ; hl now points to max HP pop bc - ld a,[hli] + ld a, [hli] cp b - jr nz,.skipComparingLSB ; no need to compare the LSB's if the MSB's don't match - ld a,[hl] + jr nz, .skipComparingLSB ; no need to compare the LSB's if the MSB's don't match + ld a, [hl] cp c .skipComparingLSB pop hl - jr nz,.notFullHP + jr nz, .notFullHP .fullHP ; if the pokemon's current HP equals its max HP - ld a,[wcf91] - cp a,FULL_RESTORE - jp nz,.healingItemNoEffect + ld a, [wcf91] + cp a, FULL_RESTORE + jp nz, .healingItemNoEffect inc hl inc hl - ld a,[hld] ; status ailment + ld a, [hld] ; status ailment and a ; does the pokemon have a status ailment? - jp z,.healingItemNoEffect - ld a,FULL_HEAL - ld [wcf91],a + jp z, .healingItemNoEffect + ld a, FULL_HEAL + ld [wcf91], a dec hl dec hl dec hl jp .cureStatusAilment + .notFullHP ; if the pokemon's current HP doesn't equal its max HP xor a - ld [wLowHealthAlarm],a ;disable low health alarm - ld [wChannelSoundIDs + CH4],a + ld [wLowHealthAlarm], a ;disable low health alarm + ld [wChannelSoundIDs + CH4], a push hl push de - ld bc,32 - add hl,bc ; hl now points to max HP - ld a,[hli] - ld [wHPBarMaxHP+1],a - ld a,[hl] - ld [wHPBarMaxHP],a ; max HP stored at wHPBarMaxHP (2 bytes, big-endian) - ld a,[wPseudoItemID] + ld bc, 32 + add hl, bc ; hl now points to max HP + ld a, [hli] + ld [wHPBarMaxHP+1], a + ld a, [hl] + ld [wHPBarMaxHP], a ; max HP stored at wHPBarMaxHP (2 bytes, big-endian) + ld a, [wPseudoItemID] and a ; using Softboiled? - jp z,.notUsingSoftboiled2 + jp z, .notUsingSoftboiled2 ; if using softboiled - ld hl,wHPBarMaxHP - ld a,[hli] + ld hl, wHPBarMaxHP + ld a, [hli] push af - ld a,[hli] + ld a, [hli] push af - ld a,[hli] + ld a, [hli] push af - ld a,[hl] + ld a, [hl] push af - ld hl,wPartyMon1MaxHP - ld a,[wWhichPokemon] - ld bc,wPartyMon2 - wPartyMon1 + ld hl, wPartyMon1MaxHP + ld a, [wWhichPokemon] + ld bc, wPartyMon2 - wPartyMon1 call AddNTimes - ld a,[hli] - ld [wHPBarMaxHP + 1],a - ld [H_DIVIDEND],a - ld a,[hl] - ld [wHPBarMaxHP],a - ld [H_DIVIDEND + 1],a - ld a,5 - ld [H_DIVISOR],a - ld b,2 ; number of bytes + ld a, [hli] + ld [wHPBarMaxHP + 1], a + ld [H_DIVIDEND], a + ld a, [hl] + ld [wHPBarMaxHP], a + ld [H_DIVIDEND + 1], a + ld a, 5 + ld [H_DIVISOR], a + ld b, 2 ; number of bytes call Divide ; get 1/5 of max HP of pokemon that used Softboiled - ld bc,wPartyMon1HP - wPartyMon1MaxHP - add hl,bc ; hl now points to LSB of current HP of pokemon that used Softboiled + ld bc, wPartyMon1HP - wPartyMon1MaxHP + add hl, bc ; hl now points to LSB of current HP of pokemon that used Softboiled ; subtract 1/5 of max HP from current HP of pokemon that used Softboiled - ld a,[H_QUOTIENT + 3] + ld a, [H_QUOTIENT + 3] push af - ld b,a - ld a,[hl] - ld [wHPBarOldHP],a + ld b, a + ld a, [hl] + ld [wHPBarOldHP], a sub b - ld [hld],a - ld [wHPBarNewHP],a - ld a,[H_QUOTIENT + 2] - ld b,a - ld a,[hl] - ld [wHPBarOldHP+1],a + ld [hld], a + ld [wHPBarNewHP], a + ld a, [H_QUOTIENT + 2] + ld b, a + ld a, [hl] + ld [wHPBarOldHP+1], a sbc b - ld [hl],a - ld [wHPBarNewHP+1],a + ld [hl], a + ld [wHPBarNewHP+1], a coord hl, 4, 1 - ld a,[wWhichPokemon] - ld bc,2 * SCREEN_WIDTH + ld a, [wWhichPokemon] + ld bc, 2 * SCREEN_WIDTH call AddNTimes ; calculate coordinates of HP bar of pokemon that used Softboiled - ld a,SFX_HEAL_HP + ld a, SFX_HEAL_HP call PlaySoundWaitForCurrent - ld a,[hFlags_0xFFFA] - set 0,a - ld [hFlags_0xFFFA],a - ld a,$02 - ld [wHPBarType],a + ld a, [hFlags_0xFFFA] + set 0, a + ld [hFlags_0xFFFA], a + ld a, $02 + ld [wHPBarType], a predef UpdateHPBar2 ; animate HP bar decrease of pokemon that used Softboiled - ld a,[hFlags_0xFFFA] - res 0,a - ld [hFlags_0xFFFA],a + ld a, [hFlags_0xFFFA] + res 0, a + ld [hFlags_0xFFFA], a pop af - ld b,a ; store heal amount (1/5 of max HP) - ld hl,wHPBarOldHP + 1 + ld b, a ; store heal amount (1/5 of max HP) + ld hl, wHPBarOldHP + 1 pop af - ld [hld],a + ld [hld], a pop af - ld [hld],a + ld [hld], a pop af - ld [hld],a + ld [hld], a pop af - ld [hl],a + ld [hl], a jr .addHealAmount + .notUsingSoftboiled2 - ld a,[wcf91] - cp a,SODA_POP - ld b,60 ; Soda Pop heal amount - jr z,.addHealAmount - ld b,80 ; Lemonade heal amount - jr nc,.addHealAmount - cp a,FRESH_WATER - ld b,50 ; Fresh Water heal amount - jr z,.addHealAmount - cp a,SUPER_POTION - ld b,200 ; Hyper Potion heal amount - jr c,.addHealAmount - ld b,50 ; Super Potion heal amount - jr z,.addHealAmount - ld b,20 ; Potion heal amount + ld a, [wcf91] + cp a, SODA_POP + ld b, 60 ; Soda Pop heal amount + jr z, .addHealAmount + ld b, 80 ; Lemonade heal amount + jr nc, .addHealAmount + cp a, FRESH_WATER + ld b, 50 ; Fresh Water heal amount + jr z, .addHealAmount + cp a, SUPER_POTION + ld b, 200 ; Hyper Potion heal amount + jr c, .addHealAmount + ld b, 50 ; Super Potion heal amount + jr z, .addHealAmount + ld b, 20 ; Potion heal amount .addHealAmount pop de pop hl - ld a,[hl] + ld a, [hl] add b - ld [hld],a - ld [wHPBarNewHP],a - ld a,[hl] - ld [wHPBarNewHP+1],a - jr nc,.noCarry + ld [hld], a + ld [wHPBarNewHP], a + ld a, [hl] + ld [wHPBarNewHP+1], a + jr nc, .noCarry inc [hl] - ld a,[hl] - ld [wHPBarNewHP + 1],a + ld a, [hl] + ld [wHPBarNewHP + 1], a .noCarry push de inc hl - ld d,h - ld e,l ; de now points to current HP - ld hl,33 - add hl,de ; hl now points to max HP - ld a,[wcf91] - cp a,REVIVE - jr z,.setCurrentHPToHalfMaxHP - ld a,[hld] - ld b,a - ld a,[de] + ld d, h + ld e, l ; de now points to current HP + ld hl, 33 + add hl, de ; hl now points to max HP + ld a, [wcf91] + cp a, REVIVE + jr z, .setCurrentHPToHalfMaxHP + ld a, [hld] + ld b, a + ld a, [de] sub b dec de - ld b,[hl] - ld a,[de] + ld b, [hl] + ld a, [de] sbc b - jr nc,.setCurrentHPToMaxHp ; if current HP exceeds max HP after healing - ld a,[wcf91] - cp a,HYPER_POTION - jr c,.setCurrentHPToMaxHp ; if using a Full Restore or Max Potion - cp a,MAX_REVIVE - jr z,.setCurrentHPToMaxHp ; if using a Max Revive + jr nc, .setCurrentHPToMaxHp ; if current HP exceeds max HP after healing + ld a, [wcf91] + cp a, HYPER_POTION + jr c, .setCurrentHPToMaxHp ; if using a Full Restore or Max Potion + cp a, MAX_REVIVE + jr z, .setCurrentHPToMaxHp ; if using a Max Revive jr .updateInBattleData + .setCurrentHPToHalfMaxHP dec hl dec de - ld a,[hli] + ld a, [hli] srl a - ld [de],a - ld [wHPBarNewHP+1],a - ld a,[hl] + ld [de], a + ld [wHPBarNewHP+1], a + ld a, [hl] rr a inc de - ld [de],a - ld [wHPBarNewHP],a + ld [de], a + ld [wHPBarNewHP], a dec de jr .doneHealingPartyHP + .setCurrentHPToMaxHp - ld a,[hli] - ld [de],a - ld [wHPBarNewHP+1],a + ld a, [hli] + ld [de], a + ld [wHPBarNewHP+1], a inc de - ld a,[hl] - ld [de],a - ld [wHPBarNewHP],a + ld a, [hl] + ld [de], a + ld [wHPBarNewHP], a dec de .doneHealingPartyHP ; done updating the pokemon's current HP in the party data structure - ld a,[wcf91] - cp a,FULL_RESTORE - jr nz,.updateInBattleData - ld bc,-31 - add hl,bc + ld a, [wcf91] + cp a, FULL_RESTORE + jr nz, .updateInBattleData + ld bc, -31 + add hl, bc xor a - ld [hl],a ; remove the status ailment in the party data + ld [hl], a ; remove the status ailment in the party data .updateInBattleData - ld h,d - ld l,e + ld h, d + ld l, e pop de - ld a,[wPlayerMonNumber] + ld a, [wPlayerMonNumber] cp d ; is pokemon the item was used on active in battle? - jr nz,.calculateHPBarCoords + jr nz, .calculateHPBarCoords ; copy party HP to in-battle HP - ld a,[hli] - ld [wBattleMonHP],a - ld a,[hld] - ld [wBattleMonHP + 1],a - ld a,[wcf91] - cp a,FULL_RESTORE - jr nz,.calculateHPBarCoords + ld a, [hli] + ld [wBattleMonHP], a + ld a, [hld] + ld [wBattleMonHP + 1], a + ld a, [wcf91] + cp a, FULL_RESTORE + jr nz, .calculateHPBarCoords xor a - ld [wBattleMonStatus],a ; remove the status ailment in the in-battle pokemon data + ld [wBattleMonStatus], a ; remove the status ailment in the in-battle pokemon data .calculateHPBarCoords - ld hl,wOAMBuffer + $90 - ld bc,2 * 20 + ld hl, wOAMBuffer + $90 + ld bc, 2 * 20 inc d .calculateHPBarCoordsLoop - add hl,bc + add hl, bc dec d - jr nz,.calculateHPBarCoordsLoop + jr nz, .calculateHPBarCoordsLoop jr .doneHealing + .healingItemNoEffect call ItemUseNoEffect jp .done + .doneHealing - ld a,[wPseudoItemID] + ld a, [wPseudoItemID] and a ; using Softboiled? - jr nz,.skipRemovingItem ; no item to remove if using Softboiled + jr nz, .skipRemovingItem ; no item to remove if using Softboiled push hl call RemoveUsedItem pop hl .skipRemovingItem - ld a,[wcf91] - cp a,FULL_RESTORE - jr c,.playStatusAilmentCuringSound - cp a,FULL_HEAL - jr z,.playStatusAilmentCuringSound - ld a,SFX_HEAL_HP + ld a, [wcf91] + cp a, FULL_RESTORE + jr c, .playStatusAilmentCuringSound + cp a, FULL_HEAL + jr z, .playStatusAilmentCuringSound + ld a, SFX_HEAL_HP call PlaySoundWaitForCurrent - ld a,[hFlags_0xFFFA] - set 0,a - ld [hFlags_0xFFFA],a - ld a,$02 - ld [wHPBarType],a + ld a, [hFlags_0xFFFA] + set 0, a + ld [hFlags_0xFFFA], a + ld a, $02 + ld [wHPBarType], a predef UpdateHPBar2 ; animate the HP bar lengthening - ld a,[hFlags_0xFFFA] - res 0,a - ld [hFlags_0xFFFA],a - ld a,REVIVE_MSG - ld [wPartyMenuTypeOrMessageID],a - ld a,[wcf91] - cp a,REVIVE - jr z,.showHealingItemMessage - cp a,MAX_REVIVE - jr z,.showHealingItemMessage - ld a,POTION_MSG - ld [wPartyMenuTypeOrMessageID],a + ld a, [hFlags_0xFFFA] + res 0, a + ld [hFlags_0xFFFA], a + ld a, REVIVE_MSG + ld [wPartyMenuTypeOrMessageID], a + ld a, [wcf91] + cp a, REVIVE + jr z, .showHealingItemMessage + cp a, MAX_REVIVE + jr z, .showHealingItemMessage + ld a, POTION_MSG + ld [wPartyMenuTypeOrMessageID], a jr .showHealingItemMessage + .playStatusAilmentCuringSound - ld a,SFX_HEAL_AILMENT + ld a, SFX_HEAL_AILMENT call PlaySoundWaitForCurrent .showHealingItemMessage xor a - ld [H_AUTOBGTRANSFERENABLED],a + ld [H_AUTOBGTRANSFERENABLED], a call ClearScreen dec a - ld [wUpdateSpritesEnabled],a + ld [wUpdateSpritesEnabled], a call RedrawPartyMenu ; redraws the party menu and displays the message - ld a,1 - ld [H_AUTOBGTRANSFERENABLED],a - ld c,50 + ld a, 1 + ld [H_AUTOBGTRANSFERENABLED], a + ld c, 50 call DelayFrames call WaitForTextScrollButtonPress jr .done + .canceledItemUse xor a - ld [wActionResultOrTookBattleTurn],a ; item use failed + ld [wActionResultOrTookBattleTurn], a ; item use failed pop af pop af .done - ld a,[wPseudoItemID] + ld a, [wPseudoItemID] and a ; using Softboiled? ret nz ; if so, return call GBPalWhiteOut - call z,RunDefaultPaletteCommand - ld a,[wIsInBattle] + call z, RunDefaultPaletteCommand + ld a, [wIsInBattle] and a ret nz jp ReloadMapData + .useVitamin push hl - ld a,[hl] - ld [wd0b5],a - ld [wd11e],a - ld bc,33 - add hl,bc ; hl now points to level - ld a,[hl] ; a = level - ld [wCurEnemyLVL],a ; store level + ld a, [hl] + ld [wd0b5], a + ld [wd11e], a + ld bc, 33 + add hl, bc ; hl now points to level + ld a, [hl] ; a = level + ld [wCurEnemyLVL], a ; store level call GetMonHeader push de - ld a,d - ld hl,wPartyMonNicks + ld a, d + ld hl, wPartyMonNicks call GetPartyMonName pop de pop hl - ld a,[wcf91] - cp a,RARE_CANDY - jp z,.useRareCandy + ld a, [wcf91] + cp a, RARE_CANDY + jp z, .useRareCandy push hl - sub a,HP_UP + sub a, HP_UP add a - ld bc,17 - add hl,bc + ld bc, 17 + add hl, bc add l - ld l,a - jr nc,.noCarry2 + ld l, a + jr nc, .noCarry2 inc h .noCarry2 - ld a,10 - ld b,a - ld a,[hl] ; a = MSB of stat experience of the appropriate stat - cp a,100 ; is there already at least 25600 (256 * 100) stat experience? - jr nc,.vitaminNoEffect ; if so, vitamins can't add any more + ld a, 10 + ld b, a + ld a, [hl] ; a = MSB of stat experience of the appropriate stat + cp a, 100 ; is there already at least 25600 (256 * 100) stat experience? + jr nc, .vitaminNoEffect ; if so, vitamins can't add any more add b ; add 2560 (256 * 10) stat experience - jr nc,.noCarry3 ; a carry should be impossible here, so this will always jump - ld a,255 + jr nc, .noCarry3 ; a carry should be impossible here, so this will always jump + ld a, 255 .noCarry3 - ld [hl],a + ld [hl], a pop hl call .recalculateStats - ld hl,VitaminText - ld a,[wcf91] - sub a,HP_UP - 1 - ld c,a + ld hl, VitaminText + ld a, [wcf91] + sub a, HP_UP - 1 + ld c, a .statNameLoop ; loop to get the address of the name of the stat the vitamin increases dec c - jr z,.gotStatName + jr z, .gotStatName .statNameInnerLoop - ld a,[hli] - ld b,a - ld a,$50 + ld a, [hli] + ld b, a + ld a, $50 cp b - jr nz,.statNameInnerLoop + jr nz, .statNameInnerLoop jr .statNameLoop + .gotStatName - ld de,wcf4b - ld bc,10 + ld de, wcf4b + ld bc, 10 call CopyData ; copy the stat's name to wcf4b - ld a,SFX_HEAL_AILMENT + ld a, SFX_HEAL_AILMENT call PlaySound - ld hl,VitaminStatRoseText + ld hl, VitaminStatRoseText call PrintText jp RemoveUsedItem + .vitaminNoEffect pop hl - ld hl,VitaminNoEffectText + ld hl, VitaminNoEffectText call PrintText jp GBPalWhiteOut + .recalculateStats - ld bc,34 - add hl,bc - ld d,h - ld e,l ; de now points to stats - ld bc,-18 - add hl,bc ; hl now points to byte 3 of experience - ld b,1 + ld bc, 34 + add hl, bc + ld d, h + ld e, l ; de now points to stats + ld bc, -18 + add hl, bc ; hl now points to byte 3 of experience + ld b, 1 jp CalcStats ; recalculate stats .useRareCandy push hl - ld bc,33 - add hl,bc ; hl now points to level - ld a,[hl] ; a = level + ld bc, 33 + add hl, bc ; hl now points to level + ld a, [hl] ; a = level cp a, MAX_LEVEL - jr z,.vitaminNoEffect ; can't raise level above 100 + jr z, .vitaminNoEffect ; can't raise level above 100 inc a - ld [hl],a ; store incremented level - ld [wCurEnemyLVL],a + ld [hl], a ; store incremented level + ld [wCurEnemyLVL], a push hl push de - ld d,a + ld d, a callab CalcExperience ; calculate experience for next level and store it at $ff96 pop de pop hl - ld bc,-19 - add hl,bc ; hl now points to experience + ld bc, -19 + add hl, bc ; hl now points to experience ; update experience to minimum for new level - ld a,[hExperience] - ld [hli],a - ld a,[hExperience + 1] - ld [hli],a - ld a,[hExperience + 2] - ld [hl],a + ld a, [hExperience] + ld [hli], a + ld a, [hExperience + 1] + ld [hli], a + ld a, [hExperience + 2] + ld [hl], a pop hl - ld a,[wWhichPokemon] + ld a, [wWhichPokemon] push af - ld a,[wcf91] + ld a, [wcf91] push af push de push hl - ld bc,34 - add hl,bc ; hl now points to MSB of max HP - ld a,[hli] - ld b,a - ld c,[hl] + ld bc, 34 + add hl, bc ; hl now points to MSB of max HP + ld a, [hli] + ld b, a + ld c, [hl] pop hl push bc push hl call .recalculateStats pop hl - ld bc,35 ; hl now points to LSB of max HP - add hl,bc + ld bc, 35 ; hl now points to LSB of max HP + add hl, bc pop bc - ld a,[hld] + ld a, [hld] sub c - ld c,a - ld a,[hl] + ld c, a + ld a, [hl] sbc b - ld b,a ; bc = the amount of max HP gained from leveling up + ld b, a ; bc = the amount of max HP gained from leveling up ; add the amount gained to the current HP - ld de,-32 - add hl,de ; hl now points to MSB of current HP - ld a,[hl] + ld de, -32 + add hl, de ; hl now points to MSB of current HP + ld a, [hl] add c - ld [hld],a - ld a,[hl] + ld [hld], a + ld a, [hl] adc b - ld [hl],a - ld a,RARE_CANDY_MSG - ld [wPartyMenuTypeOrMessageID],a + ld [hl], a + ld a, RARE_CANDY_MSG + ld [wPartyMenuTypeOrMessageID], a call RedrawPartyMenu pop de - ld a,d - ld [wWhichPokemon],a - ld a,e - ld [wd11e],a + ld a, d + ld [wWhichPokemon], a + ld a, e + ld [wd11e], a xor a ; PLAYER_PARTY_DATA - ld [wMonDataLocation],a + ld [wMonDataLocation], a call LoadMonData - ld d,$01 + ld d, $01 callab PrintStatsBox ; display new stats text box call WaitForTextScrollButtonPress ; wait for button press xor a ; PLAYER_PARTY_DATA - ld [wMonDataLocation],a + ld [wMonDataLocation], a predef LearnMoveFromLevelUp ; learn level up move, if any xor a - ld [wForceEvolution],a + ld [wForceEvolution], a callabd_ModifyPikachuHappiness PIKAHAPPY_LEVELUP ld a, [wWhichPokemon] push af @@ -1390,15 +1420,15 @@ ItemUseMedicine: ; d8ae (3:58ae) ld [wWhichPokemon], a callab Func_2fd6a ; evolve pokemon, if appropriate pop af - ld [wWhichPokemon],a + ld [wWhichPokemon], a callab TryEvolvingMon - ld a,$01 - ld [wUpdateSpritesEnabled],a + ld a, $01 + ld [wUpdateSpritesEnabled], a pop af - ld [wcf91],a + ld [wcf91], a pop af - ld [wWhichPokemon],a + ld [wWhichPokemon], a jp RemoveUsedItem VitaminStatRoseText: ; dd44 (3:5d44) @@ -1417,50 +1447,50 @@ VitaminText: ; dd4e (3:5d4e) db "SPECIAL@" ItemUseBait: ; dd72 (3:5d72) - ld hl,ThrewBaitText + ld hl, ThrewBaitText call PrintText - ld hl,wEnemyMonCatchRate ; catch rate + ld hl, wEnemyMonCatchRate ; catch rate srl [hl] ; halve catch rate - ld a,BAIT_ANIM - ld hl,wSafariBaitFactor ; bait factor - ld de,wSafariEscapeFactor ; escape factor + ld a, BAIT_ANIM + ld hl, wSafariBaitFactor ; bait factor + ld de, wSafariEscapeFactor ; escape factor jr BaitRockCommon ItemUseRock: ; dd87 (3:5d87) - ld hl,ThrewRockText + ld hl, ThrewRockText call PrintText - ld hl,wEnemyMonCatchRate ; catch rate - ld a,[hl] + ld hl, wEnemyMonCatchRate ; catch rate + ld a, [hl] add a ; double catch rate - jr nc,.noCarry - ld a,$ff + jr nc, .noCarry + ld a, $ff .noCarry - ld [hl],a - ld a,ROCK_ANIM - ld hl,wSafariEscapeFactor ; escape factor - ld de,wSafariBaitFactor ; bait factor + ld [hl], a + ld a, ROCK_ANIM + ld hl, wSafariEscapeFactor ; escape factor + ld de, wSafariBaitFactor ; bait factor BaitRockCommon: ; dd9f (3:5d9f) - ld [wAnimationID],a + ld [wAnimationID], a xor a - ld [wAnimationType],a - ld [H_WHOSETURN],a - ld [de],a ; zero escape factor (for bait), zero bait factor (for rock) + ld [wAnimationType], a + ld [H_WHOSETURN], a + ld [de], a ; zero escape factor (for bait), zero bait factor (for rock) .randomLoop ; loop until a random number less than 5 is generated call Random - and a,7 - cp a,5 - jr nc,.randomLoop + and a, 7 + cp a, 5 + jr nc, .randomLoop inc a ; increment the random number, giving a range from 1 to 5 inclusive - ld b,a - ld a,[hl] + ld b, a + ld a, [hl] add b ; increase bait factor (for bait), increase escape factor (for rock) - jr nc,.noCarry - ld a,$ff + jr nc, .noCarry + ld a, $ff .noCarry - ld [hl],a + ld [hl], a predef MoveAnimation ; do animation - ld c,70 + ld c, 70 jp DelayFrames ThrewBaitText: ; ddc6 (3:5dc6) @@ -1473,46 +1503,47 @@ ThrewRockText: ; ddca (3:5dca) ; also used for Dig out-of-battle effect ItemUseEscapeRope: ; ddcf (3:5dcf) - ld a,[wIsInBattle] + ld a, [wIsInBattle] and a - jr nz,.notUsable - ld a,[wCurMap] - cp a,AGATHAS_ROOM - jr z,.notUsable - cp a,BILLS_HOUSE - jr z,.notUsable - cp a,POKEMON_FAN_CLUB - jr z,.notUsable - ld a,[wCurMapTileset] - ld b,a - ld hl,EscapeRopeTilesets + jr nz, .notUsable + ld a, [wCurMap] + cp a, AGATHAS_ROOM + jr z, .notUsable + cp a, BILLS_HOUSE + jr z, .notUsable + cp a, POKEMON_FAN_CLUB + jr z, .notUsable + ld a, [wCurMapTileset] + ld b, a + ld hl, EscapeRopeTilesets .loop - ld a,[hli] - cp a,$ff - jr z,.notUsable + ld a, [hli] + cp a, $ff + jr z, .notUsable cp b - jr nz,.loop - ld hl,wd732 - set 3,[hl] - set 6,[hl] + jr nz, .loop + ld hl, wd732 + set 3, [hl] + set 6, [hl] call Func_1510 - ld hl,wd72e - res 4,[hl] - ld hl,wd790 - res 7,[hl] + ld hl, wd72e + res 4, [hl] + ld hl, wd790 + res 7, [hl] xor a - ld [wNumSafariBalls],a - ld [wSafariZoneEntranceCurScript],a + ld [wNumSafariBalls], a + ld [wSafariZoneEntranceCurScript], a inc a - ld [wEscapedFromBattle],a - ld [wActionResultOrTookBattleTurn],a ; item used - ld a,[wPseudoItemID] + ld [wEscapedFromBattle], a + ld [wActionResultOrTookBattleTurn], a ; item used + ld a, [wPseudoItemID] and a ; using Dig? ret nz ; if so, return call ItemUseReloadOverworldData - ld c,30 + ld c, 30 call DelayFrames jp RemoveUsedItem + .notUsable jp ItemUseNotTime @@ -1521,23 +1552,23 @@ EscapeRopeTilesets: ; de28 (3:5e28) db $ff ; terminator ItemUseRepel: ; de2e (3:5e2e) - ld b,100 + ld b, 100 ItemUseRepelCommon: ; e005 (3:6005) - ld a,[wIsInBattle] + ld a, [wIsInBattle] and a - jp nz,ItemUseNotTime - ld a,b - ld [wRepelRemainingSteps],a + jp nz, ItemUseNotTime + ld a, b + ld [wRepelRemainingSteps], a jp PrintItemUseTextAndRemoveItem ; handles X Accuracy item ItemUseXAccuracy: ; de3e (3:5e3e) - ld a,[wIsInBattle] + ld a, [wIsInBattle] and a - jp z,ItemUseNotTime - ld hl,wPlayerBattleStatus2 - set UsingXAccuracy,[hl] ; X Accuracy bit + jp z, ItemUseNotTime + ld hl, wPlayerBattleStatus2 + set UsingXAccuracy, [hl] ; X Accuracy bit callabd_ModifyPikachuHappiness PIKAHAPPY_USEDXITEM jp PrintItemUseTextAndRemoveItem @@ -1545,40 +1576,43 @@ ItemUseXAccuracy: ; de3e (3:5e3e) ; The Card Key is handled in a different way. ItemUseCardKey: ; de57 (3:de57) xor a - ld [wUnusedD71F],a + ld [wUnusedD71F], a call GetTileAndCoordsInFrontOfPlayer - ld a,[GetTileAndCoordsInFrontOfPlayer] ; $4586 - cp a,$18 - jr nz,.next0 - ld hl,CardKeyTable1 + ld a, [GetTileAndCoordsInFrontOfPlayer] ; $4586 + cp a, $18 + jr nz, .next0 + ld hl, CardKeyTable1 jr .next1 + .next0 - cp a,$24 - jr nz,.next2 - ld hl,CardKeyTable2 + cp a, $24 + jr nz, .next2 + ld hl, CardKeyTable2 jr .next1 + .next2 - cp a,$5e - jp nz,ItemUseNotTime - ld hl,CardKeyTable3 + cp a, $5e + jp nz, ItemUseNotTime + ld hl, CardKeyTable3 .next1 - ld a,[wCurMap] - ld b,a + ld a, [wCurMap] + ld b, a .loop - ld a,[hli] - cp a,$ff - jp z,ItemUseNotTime + ld a, [hli] + cp a, $ff + jp z, ItemUseNotTime cp b - jr nz,.nextEntry1 - ld a,[hli] + jr nz, .nextEntry1 + ld a, [hli] cp d - jr nz,.nextEntry2 - ld a,[hli] + jr nz, .nextEntry2 + ld a, [hli] cp e - jr nz,.nextEntry3 - ld a,[hl] - ld [wUnusedD71F],a + jr nz, .nextEntry3 + ld a, [hl] + ld [wUnusedD71F], a jr .done + .nextEntry1 inc hl .nextEntry2 @@ -1586,14 +1620,15 @@ ItemUseCardKey: ; de57 (3:de57) .nextEntry3 inc hl jr .loop + .done - ld hl,ItemUseText00 + ld hl, ItemUseText00 call PrintText - ld hl,wd728 - set 7,[hl] + ld hl, wd728 + set 7, [hl] ret -; These tables are probably supposed to be door locations in Silph Co., +; These tables are probably supposed to be door locations in Silph Co., ; but they are unused. ; The reason there are 3 tables is unknown. @@ -1604,48 +1639,48 @@ ItemUseCardKey: ; de57 (3:de57) ; 03: ID? CardKeyTable1: ; dea7 (3:5ea7) - db SILPH_CO_2F,$04,$04,$00 - db SILPH_CO_2F,$04,$05,$01 - db SILPH_CO_4F,$0C,$04,$02 - db SILPH_CO_4F,$0C,$05,$03 - db SILPH_CO_7F,$06,$0A,$04 - db SILPH_CO_7F,$06,$0B,$05 - db SILPH_CO_9F,$04,$12,$06 - db SILPH_CO_9F,$04,$13,$07 - db SILPH_CO_10F,$08,$0A,$08 - db SILPH_CO_10F,$08,$0B,$09 + db SILPH_CO_2F, $04, $04, $00 + db SILPH_CO_2F, $04, $05, $01 + db SILPH_CO_4F, $0C, $04, $02 + db SILPH_CO_4F, $0C, $05, $03 + db SILPH_CO_7F, $06, $0A, $04 + db SILPH_CO_7F, $06, $0B, $05 + db SILPH_CO_9F, $04, $12, $06 + db SILPH_CO_9F, $04, $13, $07 + db SILPH_CO_10F, $08, $0A, $08 + db SILPH_CO_10F, $08, $0B, $09 db $ff CardKeyTable2: ; ded0 (3:5ed0) - db SILPH_CO_3F,$08,$09,$0A - db SILPH_CO_3F,$09,$09,$0B - db SILPH_CO_5F,$04,$07,$0C - db SILPH_CO_5F,$05,$07,$0D - db SILPH_CO_6F,$0C,$05,$0E - db SILPH_CO_6F,$0D,$05,$0F - db SILPH_CO_8F,$08,$07,$10 - db SILPH_CO_8F,$09,$07,$11 - db SILPH_CO_9F,$08,$03,$12 - db SILPH_CO_9F,$09,$03,$13 + db SILPH_CO_3F, $08, $09, $0A + db SILPH_CO_3F, $09, $09, $0B + db SILPH_CO_5F, $04, $07, $0C + db SILPH_CO_5F, $05, $07, $0D + db SILPH_CO_6F, $0C, $05, $0E + db SILPH_CO_6F, $0D, $05, $0F + db SILPH_CO_8F, $08, $07, $10 + db SILPH_CO_8F, $09, $07, $11 + db SILPH_CO_9F, $08, $03, $12 + db SILPH_CO_9F, $09, $03, $13 db $ff CardKeyTable3: ; def9 (3:5ef9) - db SILPH_CO_11F,$08,$09,$14 - db SILPH_CO_11F,$09,$09,$15 + db SILPH_CO_11F, $08, $09, $14 + db SILPH_CO_11F, $09, $09, $15 db $ff ItemUsePokedoll: ; df02 (3:5f02) - ld a,[wIsInBattle] + ld a, [wIsInBattle] dec a - jp nz,ItemUseNotTime - ld a,$01 - ld [wEscapedFromBattle],a + jp nz, ItemUseNotTime + ld a, $01 + ld [wEscapedFromBattle], a jp PrintItemUseTextAndRemoveItem ItemUseGuardSpec: ; df11 (3:5f11) - ld a,[wIsInBattle] + ld a, [wIsInBattle] and a - jp z,ItemUseNotTime + jp z, ItemUseNotTime ld a, [wWhichPokemon] push af @@ -1655,22 +1690,22 @@ ItemUseGuardSpec: ; df11 (3:5f11) pop af ld [wWhichPokemon], a - ld hl,wPlayerBattleStatus2 - set ProtectedByMist,[hl] ; Mist bit + ld hl, wPlayerBattleStatus2 + set ProtectedByMist, [hl] ; Mist bit jp PrintItemUseTextAndRemoveItem ItemUseSuperRepel: ; df38 (3:5f38) - ld b,200 + ld b, 200 jp ItemUseRepelCommon ItemUseMaxRepel: ; df3d (3:5f3d) - ld b,250 + ld b, 250 jp ItemUseRepelCommon ItemUseDireHit: ; df42 (3:5f42) - ld a,[wIsInBattle] + ld a, [wIsInBattle] and a - jp z,ItemUseNotTime + jp z, ItemUseNotTime ld a, [wWhichPokemon] push af @@ -1680,35 +1715,36 @@ ItemUseDireHit: ; df42 (3:5f42) pop af ld [wWhichPokemon], a - ld hl,wPlayerBattleStatus2 - set GettingPumped,[hl] ; Focus Energy bit + ld hl, wPlayerBattleStatus2 + set GettingPumped, [hl] ; Focus Energy bit jp PrintItemUseTextAndRemoveItem ItemUseXStat: ; df69 (3:df69) - ld a,[wIsInBattle] + ld a, [wIsInBattle] and a - jr nz,.inBattle + jr nz, .inBattle call ItemUseNotTime - ld a,2 - ld [wActionResultOrTookBattleTurn],a ; item not used + ld a, 2 + ld [wActionResultOrTookBattleTurn], a ; item not used ret + .inBattle - ld hl,wPlayerMoveNum - ld a,[hli] + ld hl, wPlayerMoveNum + ld a, [hli] push af ; save [wPlayerMoveNum] - ld a,[hl] + ld a, [hl] push af ; save [wPlayerMoveEffect] push hl - ld a,[wcf91] - sub a,X_ATTACK - ATTACK_UP1_EFFECT - ld [hl],a ; store player move effect + ld a, [wcf91] + sub a, X_ATTACK - ATTACK_UP1_EFFECT + ld [hl], a ; store player move effect call PrintItemUseTextAndRemoveItem - ld a,XSTATITEM_ANIM ; X stat item animation ID - ld [wPlayerMoveNum],a + ld a, XSTATITEM_ANIM ; X stat item animation ID + ld [wPlayerMoveNum], a call LoadScreenTilesFromBuffer1 ; restore saved screen call Delay3 xor a - ld [H_WHOSETURN],a ; set turn to player's turn + ld [H_WHOSETURN], a ; set turn to player's turn callba StatModifierUpEffect ; do stat increase move ld a, [wWhichPokemon] @@ -1721,110 +1757,114 @@ ItemUseXStat: ; df69 (3:df69) pop hl pop af - ld [hld],a ; restore [wPlayerMoveEffect] + ld [hld], a ; restore [wPlayerMoveEffect] pop af - ld [hl],a ; restore [wPlayerMoveNum] + ld [hl], a ; restore [wPlayerMoveNum] ret ItemUsePokeflute: ; dfbd (3:5fbd) - ld a,[wIsInBattle] + ld a, [wIsInBattle] and a - jr nz,.inBattle + jr nz, .inBattle ; if not in battle call ItemUseReloadOverworldData - ld a,[wCurMap] - cp a,ROUTE_12 - jr nz,.notRoute12 + ld a, [wCurMap] + cp a, ROUTE_12 + jr nz, .notRoute12 ld a, [wd7d8] bit 7, a - jr nz,.noSnorlaxOrPikachuToWakeUp + jr nz, .noSnorlaxOrPikachuToWakeUp ; if the player hasn't beaten Route 12 Snorlax - ld hl,Route12SnorlaxFluteCoords + ld hl, Route12SnorlaxFluteCoords call ArePlayerCoordsInArray - jr nc,.noSnorlaxOrPikachuToWakeUp - ld hl,PlayedFluteHadEffectText + jr nc, .noSnorlaxOrPikachuToWakeUp + ld hl, PlayedFluteHadEffectText call PrintText ld hl, wd7d8 set 6, [hl] ret + .notRoute12 - cp a,ROUTE_16 - jr nz,.notRoute16 + cp a, ROUTE_16 + jr nz, .notRoute16 ld a, [wd7e0] bit 1, a - jr nz,.noSnorlaxOrPikachuToWakeUp + jr nz, .noSnorlaxOrPikachuToWakeUp ; if the player hasn't beaten Route 16 Snorlax - ld hl,Route16SnorlaxFluteCoords + ld hl, Route16SnorlaxFluteCoords call ArePlayerCoordsInArray - jr nc,.noSnorlaxOrPikachuToWakeUp - ld hl,PlayedFluteHadEffectText + jr nc, .noSnorlaxOrPikachuToWakeUp + ld hl, PlayedFluteHadEffectText call PrintText ld hl, wd7e0 set 0, [hl] ret + .notRoute16 - cp a,PEWTER_POKECENTER - jr nz,.noSnorlaxOrPikachuToWakeUp + cp a, PEWTER_POKECENTER + jr nz, .noSnorlaxOrPikachuToWakeUp call CheckPikachuFollowingPlayer - jr z,.noSnorlaxOrPikachuToWakeUp - callab Func_fcb01 - jr nc,.noSnorlaxOrPikachuToWakeUp + jr z, .noSnorlaxOrPikachuToWakeUp + callab IsPikachuRightNextToPlayer + jr nc, .noSnorlaxOrPikachuToWakeUp ld hl, PlayedFluteHadEffectText call PrintText call ItemUseReloadOverworldData ld e, $1a callab Func_fd001 ret + .noSnorlaxOrPikachuToWakeUp - ld hl,PlayedFluteNoEffectText + ld hl, PlayedFluteNoEffectText jp PrintText + .inBattle xor a - ld [wWereAnyMonsAsleep],a - ld b,~SLP & $ff - ld hl,wPartyMon1Status + ld [wWereAnyMonsAsleep], a + ld b, $ff ^ SLP + ld hl, wPartyMon1Status call WakeUpEntireParty - ld a,[wIsInBattle] + ld a, [wIsInBattle] dec a ; is it a trainer battle? - jr z,.skipWakingUpEnemyParty + jr z, .skipWakingUpEnemyParty ; if it's a trainer battle - ld hl,wEnemyMon1Status + ld hl, wEnemyMon1Status call WakeUpEntireParty .skipWakingUpEnemyParty - ld hl,wBattleMonStatus - ld a,[hl] + ld hl, wBattleMonStatus + ld a, [hl] and b ; remove Sleep status - ld [hl],a - ld hl,wEnemyMonStatus - ld a,[hl] - ld c,a + ld [hl], a + ld hl, wEnemyMonStatus + ld a, [hl] + ld c, a and b ; remove Sleep status - ld [hl],a - ld a,c - and a,SLP - jr z,.asm_e063 - ld a,$1 - ld [wWereAnyMonsAsleep],a + ld [hl], a + ld a, c + and a, SLP + jr z, .asm_e063 + ld a, $1 + ld [wWereAnyMonsAsleep], a .asm_e063 call LoadScreenTilesFromBuffer2 ; restore saved screen - ld a,[wWereAnyMonsAsleep] + ld a, [wWereAnyMonsAsleep] and a ; were any pokemon asleep before playing the flute? - ld hl,PlayedFluteNoEffectText - jp z,PrintText ; if no pokemon were asleep + ld hl, PlayedFluteNoEffectText + jp z, PrintText ; if no pokemon were asleep ; if some pokemon were asleep - ld hl,PlayedFluteHadEffectText + ld hl, PlayedFluteHadEffectText call PrintText - ld a,[wLowHealthAlarm] - and a,$80 - jr nz,.skipMusic + ld a, [wLowHealthAlarm] + and a, $80 + jr nz, .skipMusic call WaitForSoundToFinish ; wait for sound to end callba Music_PokeFluteInBattle ; play in-battle pokeflute music .musicWaitLoop ; wait for music to finish playing - ld a,[wChannelSoundIDs + CH6] + ld a, [wChannelSoundIDs + CH6] and a ; music off? - jr nz,.musicWaitLoop + jr nz, .musicWaitLoop .skipMusic - ld hl,FluteWokeUpText + ld hl, FluteWokeUpText jp PrintText ; wakes up all party pokemon @@ -1835,40 +1875,40 @@ ItemUsePokeflute: ; dfbd (3:5fbd) ; OUTPUT: ; [wWereAnyMonsAsleep]: set to 1 if any pokemon were asleep WakeUpEntireParty: ; e094 (3:6094) - ld de,44 - ld c,6 + ld de, 44 + ld c, 6 .loop - ld a,[hl] + ld a, [hl] push af - and a,SLP ; is pokemon asleep? - jr z,.notAsleep - ld a,1 - ld [wWereAnyMonsAsleep],a ; indicate that a pokemon had to be woken up + and a, SLP ; is pokemon asleep? + jr z, .notAsleep + ld a, 1 + ld [wWereAnyMonsAsleep], a ; indicate that a pokemon had to be woken up .notAsleep pop af and b ; remove Sleep status - ld [hl],a - add hl,de + ld [hl], a + add hl, de dec c - jr nz,.loop + jr nz, .loop ret ; Format: ; 00: Y ; 01: X Route12SnorlaxFluteCoords: ; e0ac (3:60ac) - db 62,9 ; one space West of Snorlax - db 61,10 ; one space North of Snorlax - db 63,10 ; one space South of Snorlax - db 62,11 ; one space East of Snorlax + db 62, 9 ; one space West of Snorlax + db 61, 10 ; one space North of Snorlax + db 63, 10 ; one space South of Snorlax + db 62, 11 ; one space East of Snorlax db $ff ; terminator ; Format: ; 00: Y ; 01: X Route16SnorlaxFluteCoords: ; e0b5 (3:60b5) - db 10,27 ; one space East of Snorlax - db 10,25 ; one space West of Snorlax + db 10, 27 ; one space East of Snorlax + db 10, 25 ; one space West of Snorlax db $ff ; terminator PlayedFluteNoEffectText: ; e0ba (3:60ba) @@ -1883,27 +1923,27 @@ PlayedFluteHadEffectText: ; e0c4 (3:60c4) TX_FAR _PlayedFluteHadEffectText db $06 TX_ASM - ld a,[wIsInBattle] + ld a, [wIsInBattle] and a - jr nz,.done + jr nz, .done ; play out-of-battle pokeflute music call StopAllMusic ; turn off music ld a, SFX_POKEFLUTE ld c, BANK(SFX_Pokeflute) call PlayMusic .musicWaitLoop ; wait for music to finish playing - ld a,[wChannelSoundIDs + CH2] + ld a, [wChannelSoundIDs + CH2] cp a, SFX_POKEFLUTE - jr z,.musicWaitLoop + jr z, .musicWaitLoop call PlayDefaultMusic ; start playing normal music again .done jp TextScriptEnd ; end text ItemUseCoinCase: ; e0e7 (3:60e7) - ld a,[wIsInBattle] + ld a, [wIsInBattle] and a - jp nz,ItemUseNotTime - ld hl,CoinCaseNumCoinsText + jp nz, ItemUseNotTime + ld hl, CoinCaseNumCoinsText jp PrintText CoinCaseNumCoinsText: ; e0f1 (3:60f1) @@ -1919,7 +1959,7 @@ ItemUseOldRod: ; e0f9 (3:60f9) ItemUseGoodRod: ; e106 (3:6106) call FishingInit - jp c,ItemUseNotTime + jp c, ItemUseNotTime .RandomLoop call Random srl a @@ -1928,17 +1968,17 @@ ItemUseGoodRod: ; e106 (3:6106) cp 2 jr nc, .RandomLoop ; choose which monster appears - ld hl,GoodRodMons + ld hl, GoodRodMons add a - ld c,a - ld b,0 - add hl,bc - ld b,[hl] + ld c, a + ld b, 0 + add hl, bc + ld b, [hl] inc hl - ld c,[hl] + ld c, [hl] and a .SetBite - ld a,0 + ld a, 0 rla xor 1 jr RodResponse @@ -1964,6 +2004,7 @@ ItemUseSuperRod: ; e130 (3:6130) xor a ld [wRodResponse], a jr DoNotGenerateFishingEncounter + RodResponse: ; e15b (3:615b) ld [wRodResponse], a @@ -1993,30 +2034,32 @@ DoNotGenerateFishingEncounter: ; e16e (3:616e) ; checks if fishing is possible and if so, runs initialization code common to all rods ; unsets carry if fishing is possible, sets carry if not FishingInit: ; e182 (3:6182) - ld a,[wIsInBattle] + ld a, [wIsInBattle] and a - jr z,.notInBattle + jr z, .notInBattle scf ; can't fish during battle ret + .notInBattle call IsNextTileShoreOrWater - jr nc,.cannotFish - ld a,[wWalkBikeSurfState] - cp a,2 ; Surfing? - jr z,.cannotFish + jr nc, .cannotFish + ld a, [wWalkBikeSurfState] + cp a, 2 ; Surfing? + jr z, .cannotFish call ItemUseReloadOverworldData - ld hl,ItemUseText00 + ld hl, ItemUseText00 call PrintText - ld a,SFX_HEAL_AILMENT + ld a, SFX_HEAL_AILMENT call PlaySound ld a, $2 ld [wd49c], a ld a, $81 ld [wPikachuMood], a - ld c,80 + ld c, 80 call DelayFrames and a ret + .cannotFish scf ; can't fish when surfing ret @@ -2025,22 +2068,22 @@ ItemUseOaksParcel: ; e1b7 (3:61b7) jp ItemUseNotYoursToUse ItemUseItemfinder: ; e1ba (3:61ba) - ld a,[wIsInBattle] + ld a, [wIsInBattle] and a - jp nz,ItemUseNotTime + jp nz, ItemUseNotTime call ItemUseReloadOverworldData callba HiddenItemNear ; check for hidden items - ld hl,ItemfinderFoundNothingText - jr nc,.printText ; if no hidden items - ld c,4 + ld hl, ItemfinderFoundNothingText + jr nc, .printText ; if no hidden items + ld c, 4 .loop - ld a,SFX_HEALING_MACHINE + ld a, SFX_HEALING_MACHINE call PlaySoundWaitForCurrent - ld a,SFX_PURCHASE + ld a, SFX_PURCHASE call PlaySoundWaitForCurrent dec c - jr nz,.loop - ld hl,ItemfinderFoundItemText + jr nz, .loop + ld hl, ItemfinderFoundItemText .printText jp PrintText @@ -2053,23 +2096,24 @@ ItemfinderFoundNothingText: ; e1eb (3:61eb) db "@" ItemUsePPUp: ; e1f0 (3:61f0) - ld a,[wIsInBattle] + ld a, [wIsInBattle] and a - jp nz,ItemUseNotTime + jp nz, ItemUseNotTime ItemUsePPRestore: ; e1f7 (3:61f7) - ld a,[wWhichPokemon] + ld a, [wWhichPokemon] push af - ld a,[wcf91] - ld [wPPRestoreItem],a + ld a, [wcf91] + ld [wPPRestoreItem], a .chooseMon xor a - ld [wUpdateSpritesEnabled],a - ld a,USE_ITEM_PARTY_MENU - ld [wPartyMenuTypeOrMessageID],a + ld [wUpdateSpritesEnabled], a + ld a, USE_ITEM_PARTY_MENU + ld [wPartyMenuTypeOrMessageID], a call DisplayPartyMenu - jr nc,.chooseMove + jr nc, .chooseMove jp .itemNotUsed + .chooseMove ld a, [wIsInBattle] and a @@ -2084,121 +2128,127 @@ ItemUsePPRestore: ; e1f7 (3:61f7) jr z, .usePPItem call ItemUseNotTime jp .itemNotUsed + .usePPItem - ld a,[wPPRestoreItem] - cp a,ELIXER - jp nc,.useElixir ; if Elixir or Max Elixir - ld a,$02 - ld [wMoveMenuType],a - ld hl,RaisePPWhichTechniqueText - ld a,[wPPRestoreItem] - cp a,ETHER ; is it a PP Up? - jr c,.printWhichTechniqueMessage ; if so, print the raise PP message - ld hl,RestorePPWhichTechniqueText ; otherwise, print the restore PP message + ld a, [wPPRestoreItem] + cp a, ELIXER + jp nc, .useElixir ; if Elixir or Max Elixir + ld a, $02 + ld [wMoveMenuType], a + ld hl, RaisePPWhichTechniqueText + ld a, [wPPRestoreItem] + cp a, ETHER ; is it a PP Up? + jr c, .printWhichTechniqueMessage ; if so, print the raise PP message + ld hl, RestorePPWhichTechniqueText ; otherwise, print the restore PP message .printWhichTechniqueMessage call PrintText xor a - ld [wPlayerMoveListIndex],a + ld [wPlayerMoveListIndex], a callab MoveSelectionMenu ; move selection menu - ld a,0 - ld [wPlayerMoveListIndex],a - jr nz,.chooseMon - ld hl,wPartyMon1Moves + ld a, 0 + ld [wPlayerMoveListIndex], a + jr nz, .chooseMon + ld hl, wPartyMon1Moves ld bc, wPartyMon2 - wPartyMon1 call GetSelectedMoveOffset push hl - ld a,[hl] - ld [wd11e],a + ld a, [hl] + ld [wd11e], a call GetMoveName call CopyStringToCF4B ; copy name to wcf4b pop hl - ld a,[wPPRestoreItem] - cp a,ETHER - jr nc,.useEther ; if Ether or Max Ether + ld a, [wPPRestoreItem] + cp a, ETHER + jr nc, .useEther ; if Ether or Max Ether .usePPUp - ld bc,21 - add hl,bc - ld a,[hl] ; move PP - cp a,3 << 6 ; have 3 PP Ups already been used? - jr c,.PPNotMaxedOut - ld hl,PPMaxedOutText + ld bc, 21 + add hl, bc + ld a, [hl] ; move PP + cp a, 3 << 6 ; have 3 PP Ups already been used? + jr c, .PPNotMaxedOut + ld hl, PPMaxedOutText call PrintText jr .chooseMove + .PPNotMaxedOut - ld a,[hl] - add a,1 << 6 ; increase PP Up count by 1 - ld [hl],a - ld a,1 ; 1 PP Up used - ld [wd11e],a + ld a, [hl] + add a, 1 << 6 ; increase PP Up count by 1 + ld [hl], a + ld a, 1 ; 1 PP Up used + ld [wd11e], a call RestoreBonusPP ; add the bonus PP to current PP ld a, SFX_HEAL_AILMENT call PlaySound - ld hl,PPIncreasedText + ld hl, PPIncreasedText call PrintText .done pop af - ld [wWhichPokemon],a + ld [wWhichPokemon], a call GBPalWhiteOut call RunDefaultPaletteCommand jp RemoveUsedItem + .afterRestoringPP ; after using a (Max) Ether/Elixir - ld a,[wWhichPokemon] - ld b,a - ld a,[wPlayerMonNumber] + ld a, [wWhichPokemon] + ld b, a + ld a, [wPlayerMonNumber] cp b ; is the pokemon whose PP was restored active in battle? - jr nz,.skipUpdatingInBattleData - ld hl,wPartyMon1PP + jr nz, .skipUpdatingInBattleData + ld hl, wPartyMon1PP ld bc, wPartyMon2 - wPartyMon1 call AddNTimes - ld de,wBattleMonPP - ld bc,4 + ld de, wBattleMonPP + ld bc, 4 call CopyData ; copy party data to in-battle data .skipUpdatingInBattleData - ld a,SFX_HEAL_AILMENT + ld a, SFX_HEAL_AILMENT call PlaySound - ld hl,PPRestoredText + ld hl, PPRestoredText call PrintText jr .done + .useEther call .restorePP - jr nz,.afterRestoringPP + jr nz, .afterRestoringPP jp .noEffect + ; unsets zero flag if PP was restored, sets zero flag if not ; however, this is bugged for Max Ethers and Max Elixirs (see below) .restorePP xor a ; PLAYER_PARTY_DATA - ld [wMonDataLocation],a + ld [wMonDataLocation], a call GetMaxPP - ld hl,wPartyMon1Moves + ld hl, wPartyMon1Moves ld bc, wPartyMon2 - wPartyMon1 call GetSelectedMoveOffset ld bc, wPartyMon1PP - wPartyMon1Moves - add hl,bc ; hl now points to move's PP - ld a,[wMaxPP] - ld b,a - ld a,[wPPRestoreItem] - cp a,MAX_ETHER - jr z,.fullyRestorePP - ld a,[hl] ; move PP - and a,%00111111 ; lower 6 bit bits store current PP + add hl, bc ; hl now points to move's PP + ld a, [wMaxPP] + ld b, a + ld a, [wPPRestoreItem] + cp a, MAX_ETHER + jr z, .fullyRestorePP + ld a, [hl] ; move PP + and a, %00111111 ; lower 6 bit bits store current PP cp b ; does current PP equal max PP? ret z ; if so, return - add a,10 ; increase current PP by 10 + add a, 10 ; increase current PP by 10 ; b holds the max PP amount and b will hold the new PP amount. -; So, if the new amount meets or exceeds the max amount, +; So, if the new amount meets or exceeds the max amount, ; cap the amount to the max amount by leaving b unchanged. ; Otherwise, store the new amount in b. cp b ; does the new amount meet or exceed the maximum? - jr nc,.storeNewAmount - ld b,a + jr nc, .storeNewAmount + ld b, a .storeNewAmount - ld a,[hl] ; move PP - and a,%11000000 ; PP Up counter bits + ld a, [hl] ; move PP + and a, %11000000 ; PP Up counter bits add b - ld [hl],a + ld [hl], a ret + .fullyRestorePP - ld a,[hl] ; move PP + ld a, [hl] ; move PP ; Note that this code has a bug. It doesn't mask out the upper two bits, which ; are used to count how many PP Ups have been used on the move. So, Max Ethers ; and Max Elixirs will not be detected as having no effect on a move with full @@ -2206,39 +2256,40 @@ ItemUsePPRestore: ; e1f7 (3:61f7) cp b ; does current PP equal max PP? ret z jr .storeNewAmount + .useElixir ; decrement the item ID so that ELIXER becomes ETHER and MAX_ELIXER becomes MAX_ETHER - ld hl,wPPRestoreItem + ld hl, wPPRestoreItem dec [hl] dec [hl] xor a - ld hl,wCurrentMenuItem - ld [hli],a - ld [hl],a ; zero the counter for number of moves that had their PP restored - ld b,4 + ld hl, wCurrentMenuItem + ld [hli], a + ld [hl], a ; zero the counter for number of moves that had their PP restored + ld b, 4 ; loop through each move and restore PP .elixirLoop push bc - ld hl,wPartyMon1Moves + ld hl, wPartyMon1Moves ld bc, wPartyMon2 - wPartyMon1 call GetSelectedMoveOffset - ld a,[hl] + ld a, [hl] and a ; does the current slot have a move? - jr z,.nextMove + jr z, .nextMove call .restorePP - jr z,.nextMove + jr z, .nextMove ; if some PP was restored - ld hl,wTileBehindCursor ; counter for number of moves that had their PP restored + ld hl, wTileBehindCursor ; counter for number of moves that had their PP restored inc [hl] .nextMove - ld hl,wCurrentMenuItem + ld hl, wCurrentMenuItem inc [hl] pop bc dec b - jr nz,.elixirLoop - ld a,[wTileBehindCursor] + jr nz, .elixirLoop + ld a, [wTileBehindCursor] and a ; did any moves have their PP restored? - jp nz,.afterRestoringPP + jp nz, .afterRestoringPP .noEffect call ItemUseNoEffect .itemNotUsed @@ -2246,7 +2297,7 @@ ItemUsePPRestore: ; e1f7 (3:61f7) call RunDefaultPaletteCommand pop af xor a - ld [wActionResultOrTookBattleTurn],a ; item use failed + ld [wActionResultOrTookBattleTurn], a ; item use failed ret RaisePPWhichTechniqueText: ; e358 (3:6358) @@ -2274,63 +2325,64 @@ UnusableItem: ; e371 (3:6371) jp ItemUseNotTime ItemUseTMHM: ; e374 (3:6374) - ld a,[wIsInBattle] + ld a, [wIsInBattle] and a - jp nz,ItemUseNotTime - ld a,[wcf91] - sub a,TM_01 + jp nz, ItemUseNotTime + ld a, [wcf91] + sub a, TM_01 push af - jr nc,.skipAdding - add a,55 ; if item is an HM, add 55 + jr nc, .skipAdding + add a, 55 ; if item is an HM, add 55 .skipAdding inc a - ld [wd11e],a + ld [wd11e], a predef TMToMove ; get move ID from TM/HM ID - ld a,[wd11e] - ld [wMoveNum],a + ld a, [wd11e] + ld [wMoveNum], a call GetMoveName call CopyStringToCF4B ; copy name to wcf4b pop af - ld hl,BootedUpTMText - jr nc,.printBootedUpMachineText - ld hl,BootedUpHMText + ld hl, BootedUpTMText + jr nc, .printBootedUpMachineText + ld hl, BootedUpHMText .printBootedUpMachineText call PrintText - ld hl,TeachMachineMoveText + ld hl, TeachMachineMoveText call PrintText coord hl, 14, 7 lb bc, 8, 15 - ld a,TWO_OPTION_MENU - ld [wTextBoxID],a + ld a, TWO_OPTION_MENU + ld [wTextBoxID], a call DisplayTextBoxID ; yes/no menu - ld a,[wCurrentMenuItem] + ld a, [wCurrentMenuItem] and a - jr z,.useMachine - ld a,2 - ld [wActionResultOrTookBattleTurn],a ; item not used + jr z, .useMachine + ld a, 2 + ld [wActionResultOrTookBattleTurn], a ; item not used ret + .useMachine - ld a,[wWhichPokemon] + ld a, [wWhichPokemon] push af - ld a,[wcf91] + ld a, [wcf91] push af .chooseMon - ld hl,wcf4b - ld de,wTempMoveNameBuffer - ld bc,14 + ld hl, wcf4b + ld de, wTempMoveNameBuffer + ld bc, 14 call CopyData ; save the move name because DisplayPartyMenu will overwrite it - ld a,$ff - ld [wUpdateSpritesEnabled],a - ld a,TMHM_PARTY_MENU - ld [wPartyMenuTypeOrMessageID],a + ld a, $ff + ld [wUpdateSpritesEnabled], a + ld a, TMHM_PARTY_MENU + ld [wPartyMenuTypeOrMessageID], a call DisplayPartyMenu push af - ld hl,wTempMoveNameBuffer - ld de,wcf4b - ld bc,14 + ld hl, wTempMoveNameBuffer + ld de, wcf4b + ld bc, 14 call CopyData pop af - jr nc,.checkIfAbleToLearnMove + jr nc, .checkIfAbleToLearnMove ; if the player canceled teaching the move pop af pop af @@ -2341,45 +2393,46 @@ ItemUseTMHM: ; e374 (3:6374) .checkIfAbleToLearnMove predef CanLearnTM ; check if the pokemon can learn the move push bc - ld a,[wWhichPokemon] - ld hl,wPartyMonNicks + ld a, [wWhichPokemon] + ld hl, wPartyMonNicks call GetPartyMonName pop bc - ld a,c + ld a, c and a ; can the pokemon learn the move? - jr nz,.checkIfAlreadyLearnedMove + jr nz, .checkIfAlreadyLearnedMove ; if the pokemon can't learn the move - ld a,SFX_DENIED + ld a, SFX_DENIED call PlaySoundWaitForCurrent - ld hl,MonCannotLearnMachineMoveText + ld hl, MonCannotLearnMachineMoveText call PrintText jr .chooseMon + .checkIfAlreadyLearnedMove callab CheckIfMoveIsKnown ; check if the pokemon already knows the move - jr c,.chooseMon + jr c, .chooseMon predef LearnMove ; teach move ld a, [wWhichPokemon] ld d, a pop af - ld [wcf91],a + ld [wcf91], a pop af - ld [wWhichPokemon],a - ld a,b + ld [wWhichPokemon], a + ld a, b and a ret z - ld a,[wWhichPokemon] + ld a, [wWhichPokemon] push af - ld a,d - ld [wWhichPokemon],a + ld a, d + ld [wWhichPokemon], a callabd_ModifyPikachuHappiness PIKAHAPPY_USEDTMHM callab IsThisPartymonStarterPikachu_Party - jr nc,.notTeachingThunderboltOrThunderToPikachu - ld a,[wcf91] - cp a,TM_24 ; are we teaching thunderbolt to the player pikachu? - jr z,.teachingThunderboltOrThunderToPlayerPikachu - cp a,TM_25 ; are we teaching thunder then? - jr nz,.notTeachingThunderboltOrThunderToPikachu + jr nc, .notTeachingThunderboltOrThunderToPikachu + ld a, [wcf91] + cp a, TM_24 ; are we teaching thunderbolt to the player pikachu? + jr z, .teachingThunderboltOrThunderToPlayerPikachu + cp a, TM_25 ; are we teaching thunder then? + jr nz, .notTeachingThunderboltOrThunderToPikachu .teachingThunderboltOrThunderToPlayerPikachu ld a, $5 ld [wd49c], a @@ -2389,7 +2442,7 @@ ItemUseTMHM: ; e374 (3:6374) pop af ld [wWhichPokemon], a - ld a,[wcf91] + ld a, [wcf91] call IsItemHM ret c jp RemoveUsedItem @@ -2411,28 +2464,28 @@ MonCannotLearnMachineMoveText: ; e492 (3:6492) db "@" PrintItemUseTextAndRemoveItem: ; e497 (3:6497) - ld hl,ItemUseText00 + ld hl, ItemUseText00 call PrintText - ld a,SFX_HEAL_AILMENT + ld a, SFX_HEAL_AILMENT call PlaySound call WaitForTextScrollButtonPress ; wait for button press RemoveUsedItem: ; e4a5 (3:64a5) - ld hl,wNumBagItems - ld a,1 ; one item - ld [wItemQuantity],a + ld hl, wNumBagItems + ld a, 1 ; one item + ld [wItemQuantity], a jp RemoveItemFromInventory ItemUseNoEffect: ; e4b0 (3:64b0) - ld hl,ItemUseNoEffectText + ld hl, ItemUseNoEffectText jr ItemUseFailed ItemUseNotTime: ; e4b5 (3:64b5) - ld hl,ItemUseNotTimeText + ld hl, ItemUseNotTimeText jr ItemUseFailed ItemUseNotYoursToUse: ; e4ba (3:64ba) - ld hl,ItemUseNotYoursToUseText + ld hl, ItemUseNotYoursToUseText jr ItemUseFailed Func_e4bf: ; e4bf (3:64bf) @@ -2440,34 +2493,35 @@ Func_e4bf: ; e4bf (3:64bf) ld [wActionResultOrTookBattleTurn], a ld hl, DontHavePokemonText jp PrintText + ThrowBallAtTrainerMon: ; e4ca (3:64ca) call RunDefaultPaletteCommand call LoadScreenTilesFromBuffer1 ; restore saved screen call Delay3 - ld a,TOSS_ANIM - ld [wAnimationID],a + ld a, TOSS_ANIM + ld [wAnimationID], a predef MoveAnimation ; do animation - ld hl,ThrowBallAtTrainerMonText1 + ld hl, ThrowBallAtTrainerMonText1 call PrintText - ld hl,ThrowBallAtTrainerMonText2 + ld hl, ThrowBallAtTrainerMonText2 call PrintText jr RemoveUsedItem NoCyclingAllowedHere: ; e4eb (3:64eb) - ld hl,NoCyclingAllowedHereText + ld hl, NoCyclingAllowedHereText jr ItemUseFailed BoxFullCannotThrowBall: ; e4f0 (3:64f0) - ld hl,BoxFullCannotThrowBallText + ld hl, BoxFullCannotThrowBallText jr ItemUseFailed SurfingAttemptFailed: ; e4f5 (3:64f5) - ld hl,NoSurfingHereText + ld hl, NoSurfingHereText ItemUseFailed: ; e4f8 (3:64f8) xor a - ld [wActionResultOrTookBattleTurn],a ; item use failed + ld [wActionResultOrTookBattleTurn], a ; item use failed jp PrintText ItemUseNotTimeText: ; e4ff (3:64ff) @@ -2530,37 +2584,37 @@ GotOffBicycleText: ; e540 (3:6540) ; [wWhichPokemon] = index of pokemon in party ; [wCurrentMenuItem] = index of move (when using a PP Up) RestoreBonusPP: ; e54a (3:654a) - ld hl,wPartyMon1Moves + ld hl, wPartyMon1Moves ld bc, wPartyMon2 - wPartyMon1 - ld a,[wWhichPokemon] + ld a, [wWhichPokemon] call AddNTimes push hl - ld de,wNormalMaxPPList - 1 + ld de, wNormalMaxPPList - 1 predef LoadMovePPs ; loads the normal max PP of each of the pokemon's moves to wNormalMaxPPList pop hl ld c, wPartyMon1PP - wPartyMon1Moves - ld b,0 - add hl,bc ; hl now points to move 1 PP - ld de,wNormalMaxPPList - ld b,0 ; initialize move counter to zero + ld b, 0 + add hl, bc ; hl now points to move 1 PP + ld de, wNormalMaxPPList + ld b, 0 ; initialize move counter to zero ; loop through the pokemon's moves .loop inc b - ld a,b - cp a,5 ; reached the end of the pokemon's moves? + ld a, b + cp a, 5 ; reached the end of the pokemon's moves? ret z ; if so, return - ld a,[wUsingPPUp] + ld a, [wUsingPPUp] dec a ; using a PP Up? - jr nz,.skipMenuItemIDCheck + jr nz, .skipMenuItemIDCheck ; if using a PP Up, check if this is the move it's being used on - ld a,[wCurrentMenuItem] + ld a, [wCurrentMenuItem] inc a cp b - jr nz,.nextMove + jr nz, .nextMove .skipMenuItemIDCheck - ld a,[hl] - and a,%11000000 ; have any PP Ups been used? - call nz,AddBonusPP ; if so, add bonus PP + ld a, [hl] + and a, %11000000 ; have any PP Ups been used? + call nz, AddBonusPP ; if so, add bonus PP .nextMove inc hl inc de @@ -2573,38 +2627,38 @@ RestoreBonusPP: ; e54a (3:654a) ; [hl] = move PP AddBonusPP: ; e586 (3:6586) push bc - ld a,[de] ; normal max PP of move - ld [H_DIVIDEND + 3],a + ld a, [de] ; normal max PP of move + ld [H_DIVIDEND + 3], a xor a - ld [H_DIVIDEND],a - ld [H_DIVIDEND + 1],a - ld [H_DIVIDEND + 2],a - ld a,5 - ld [H_DIVISOR],a - ld b,4 + ld [H_DIVIDEND], a + ld [H_DIVIDEND + 1], a + ld [H_DIVIDEND + 2], a + ld a, 5 + ld [H_DIVISOR], a + ld b, 4 call Divide - ld a,[hl] ; move PP - ld b,a + ld a, [hl] ; move PP + ld b, a swap a - and a,%1111 + and a, %1111 srl a srl a - ld c,a ; c = number of PP Ups used + ld c, a ; c = number of PP Ups used .loop - ld a,[H_QUOTIENT + 3] - cp a,8 ; is the amount greater than or equal to 8? - jr c,.addAmount - ld a,7 ; cap the amount at 7 + ld a, [H_QUOTIENT + 3] + cp a, 8 ; is the amount greater than or equal to 8? + jr c, .addAmount + ld a, 7 ; cap the amount at 7 .addAmount add b - ld b,a - ld a,[wUsingPPUp] + ld b, a + ld a, [wUsingPPUp] dec a ; is the player using a PP Up right now? - jr z,.done ; if so, only add the bonus once + jr z, .done ; if so, only add the bonus once dec c - jr nz,.loop + jr nz, .loop .done - ld [hl],b + ld [hl], b pop bc ret @@ -2621,74 +2675,75 @@ AddBonusPP: ; e586 (3:6586) ; OUTPUT: ; [wMaxPP] = max PP GetMaxPP: ; e5bb (3:65bb) - ld a,[wMonDataLocation] + ld a, [wMonDataLocation] and a - ld hl,wPartyMon1Moves - ld bc,wPartyMon2 - wPartyMon1 - jr z,.sourceWithMultipleMon - ld hl,wEnemyMon1Moves + ld hl, wPartyMon1Moves + ld bc, wPartyMon2 - wPartyMon1 + jr z, .sourceWithMultipleMon + ld hl, wEnemyMon1Moves dec a - jr z,.sourceWithMultipleMon - ld hl,wBoxMon1Moves - ld bc,wBoxMon2 - wBoxMon1 + jr z, .sourceWithMultipleMon + ld hl, wBoxMon1Moves + ld bc, wBoxMon2 - wBoxMon1 dec a - jr z,.sourceWithMultipleMon - ld hl,wDayCareMonMoves + jr z, .sourceWithMultipleMon + ld hl, wDayCareMonMoves dec a - jr z,.sourceWithOneMon - ld hl,wBattleMonMoves ; player's in-battle pokemon + jr z, .sourceWithOneMon + ld hl, wBattleMonMoves ; player's in-battle pokemon .sourceWithOneMon call GetSelectedMoveOffset2 jr .next + .sourceWithMultipleMon call GetSelectedMoveOffset .next - ld a,[hl] + ld a, [hl] dec a push hl - ld hl,Moves - ld bc,MoveEnd - Moves + ld hl, Moves + ld bc, MoveEnd - Moves call AddNTimes - ld de,wcd6d - ld a,BANK(Moves) + ld de, wcd6d + ld a, BANK(Moves) call FarCopyData - ld de,wcd6d + 5 ; PP is byte 5 of move data - ld a,[de] - ld b,a ; b = normal max PP + ld de, wcd6d + 5 ; PP is byte 5 of move data + ld a, [de] + ld b, a ; b = normal max PP pop hl push bc - ld bc,wPartyMon1PP - wPartyMon1Moves ; PP offset if not player's in-battle pokemon data - ld a,[wMonDataLocation] - cp a,4 ; player's in-battle pokemon? - jr nz,.addPPOffset - ld bc,wBattleMonPP - wBattleMonMoves ; PP offset if player's in-battle pokemon data + ld bc, wPartyMon1PP - wPartyMon1Moves ; PP offset if not player's in-battle pokemon data + ld a, [wMonDataLocation] + cp a, 4 ; player's in-battle pokemon? + jr nz, .addPPOffset + ld bc, wBattleMonPP - wBattleMonMoves ; PP offset if player's in-battle pokemon data .addPPOffset - add hl,bc - ld a,[hl] ; a = current PP - and a,%11000000 ; get PP Up count + add hl, bc + ld a, [hl] ; a = current PP + and a, %11000000 ; get PP Up count pop bc or b ; place normal max PP in 6 lower bits of a - ld h,d - ld l,e + ld h, d + ld l, e inc hl ; hl = wcd73 - ld [hl],a + ld [hl], a xor a ; add the bonus for the existing PP Up count - ld [wUsingPPUp],a + ld [wUsingPPUp], a call AddBonusPP ; add bonus PP from PP Ups - ld a,[hl] - and a,%00111111 ; mask out the PP Up count - ld [wMaxPP],a ; store max PP + ld a, [hl] + and a, %00111111 ; mask out the PP Up count + ld [wMaxPP], a ; store max PP ret GetSelectedMoveOffset: ; e627 (3:6627) - ld a,[wWhichPokemon] + ld a, [wWhichPokemon] call AddNTimes GetSelectedMoveOffset2: ; e62d (3:662d) - ld a,[wCurrentMenuItem] - ld c,a - ld b,0 - add hl,bc + ld a, [wCurrentMenuItem] + ld c, a + ld b, 0 + add hl, bc ret ; confirms the item toss and then tosses the item @@ -2701,49 +2756,50 @@ GetSelectedMoveOffset2: ; e62d (3:662d) ; clears carry flag if the item is tossed, sets carry flag if not TossItem_: ; e635 (3:6635) push hl - ld a,[wcf91] + ld a, [wcf91] call IsItemHM pop hl - jr c,.tooImportantToToss + jr c, .tooImportantToToss push hl call IsKeyItem_ - ld a,[wIsKeyItem] + ld a, [wIsKeyItem] pop hl and a - jr nz,.tooImportantToToss + jr nz, .tooImportantToToss push hl - ld a,[wcf91] - ld [wd11e],a + ld a, [wcf91] + ld [wd11e], a call GetItemName call CopyStringToCF4B ; copy name to wcf4b - ld hl,IsItOKToTossItemText + ld hl, IsItOKToTossItemText call PrintText coord hl, 14, 7 lb bc, 8, 15 - ld a,TWO_OPTION_MENU - ld [wTextBoxID],a + ld a, TWO_OPTION_MENU + ld [wTextBoxID], a call DisplayTextBoxID ; yes/no menu - ld a,[wMenuExitMethod] - cp a,CHOSE_SECOND_ITEM + ld a, [wMenuExitMethod] + cp a, CHOSE_SECOND_ITEM pop hl scf ret z ; return if the player chose No ; if the player chose Yes push hl - ld a,[wWhichPokemon] + ld a, [wWhichPokemon] call RemoveItemFromInventory - ld a,[wcf91] - ld [wd11e],a + ld a, [wcf91] + ld [wd11e], a call GetItemName call CopyStringToCF4B ; copy name to wcf4b - ld hl,ThrewAwayItemText + ld hl, ThrewAwayItemText call PrintText pop hl and a ret + .tooImportantToToss push hl - ld hl,TooImportantToTossText + ld hl, TooImportantToTossText call PrintText pop hl scf @@ -2769,32 +2825,32 @@ TooImportantToTossText: ; e6a3 (3:66a3) ; 00: item is not key item ; 01: item is key item IsKeyItem_: ; e6a8 (3:66a8) - ld a,$01 - ld [wIsKeyItem],a - ld a,[wcf91] - cp a,HM_01 ; is the item an HM or TM? - jr nc,.checkIfItemIsHM + ld a, $01 + ld [wIsKeyItem], a + ld a, [wcf91] + cp a, HM_01 ; is the item an HM or TM? + jr nc, .checkIfItemIsHM ; if the item is not an HM or TM push af - ld hl,KeyItemBitfield - ld de,wBuffer - ld bc,15 ; only 11 bytes are actually used + ld hl, KeyItemBitfield + ld de, wBuffer + ld bc, 15 ; only 11 bytes are actually used call CopyData pop af dec a - ld c,a - ld hl,wBuffer - ld b,FLAG_TEST + ld c, a + ld hl, wBuffer + ld b, FLAG_TEST predef FlagActionPredef - ld a,c + ld a, c and a ret nz .checkIfItemIsHM - ld a,[wcf91] + ld a, [wcf91] call IsItemHM ret c xor a - ld [wIsKeyItem],a + ld [wIsKeyItem], a ret INCLUDE "data/key_items.asm" @@ -2977,10 +3033,10 @@ SendNewMonToBox: ; e6e8 (3:66e8) IsNextTileShoreOrWater: ; e808 (3:6808) ld a, [wCurMapTileset] ld hl, WaterTilesets - ld de,1 + ld de, 1 call IsInArray ; does the current map allow surfing? ret nc ; if not, return - ld hl,WaterTile + ld hl, WaterTile ld a, [wCurMapTileset] cp SHIP_PORT ; Vermilion Dock tileset jr z, .skipShoreTiles ; if it's the Vermilion Dock tileset @@ -2988,10 +3044,10 @@ IsNextTileShoreOrWater: ; e808 (3:6808) jr z, .skipShoreTiles cp DOJO ; usual eastern shore tile jr z, .skipShoreTiles - ld hl,ShoreTiles + ld hl, ShoreTiles .skipShoreTiles - ld a,[wTileInFrontOfPlayer] - ld de,$1 + ld a, [wTileInFrontOfPlayer] + ld de, $1 call IsInArray ret @@ -3039,6 +3095,7 @@ FindWildLocationsOfMon: ; e848 (3:6848) inc hl inc c jr .loop + .done ld a, $ff ; list terminator ld [de], a diff --git a/engine/menu/bills_pc.asm b/engine/menu/bills_pc.asm index a3f6f7fc..280b9df8 100644 --- a/engine/menu/bills_pc.asm +++ b/engine/menu/bills_pc.asm @@ -553,7 +553,7 @@ CableClubLeftGameboy:: ; 21867 (8:5867) ld a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK ret z - ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction + ld a, [wPlayerFacingDirection] ; player's sprite facing direction cp SPRITE_FACING_RIGHT ret nz ld a, [wCurMap] @@ -570,7 +570,7 @@ CableClubRightGameboy:: ; 21887 (8:5887) ld a, [hSerialConnectionStatus] cp USING_INTERNAL_CLOCK ret z - ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction + ld a, [wPlayerFacingDirection] ; player's sprite facing direction cp SPRITE_FACING_LEFT ret nz ld a, [wCurMap] @@ -587,7 +587,7 @@ JustAMomentText:: ; 218a7 (8:58a7) TX_FAR _JustAMomentText db "@" - ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction + ld a, [wPlayerFacingDirection] ; player's sprite facing direction cp SPRITE_FACING_UP ret nz call EnableAutoTextBoxDrawing diff --git a/engine/overworld/card_key.asm b/engine/overworld/card_key.asm index 48b2380d..62d1d4fb 100755 --- a/engine/overworld/card_key.asm +++ b/engine/overworld/card_key.asm @@ -89,7 +89,7 @@ GetCoordsInFrontOfPlayer: ; 5265f (14:665f) ld d, a ld a, [wXCoord] ld e, a - ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction + ld a, [wPlayerFacingDirection] ; player's sprite facing direction and a jr nz, .notFacingDown ; facing down diff --git a/engine/overworld/check_player_state.asm b/engine/overworld/check_player_state.asm index 157649a7..0fc73bc7 100644 --- a/engine/overworld/check_player_state.asm +++ b/engine/overworld/check_player_state.asm @@ -90,7 +90,7 @@ IsPlayerFacingEdgeOfMap: ; c148 (3:4148) push hl push de push bc - ld a, [wSpriteStateData1 + 9] ; player sprite's facing direction + ld a, [wPlayerFacingDirection] ; player sprite's facing direction srl a ld c, a ld b, $0 @@ -160,7 +160,7 @@ IsWarpTileInFrontOfPlayer: ; c197 (3:4197) ld a, [wCurMap] cp SS_ANNE_5 jr z, .ssAnne5 - ld a, [wSpriteStateData1 + 9] ; player sprite's facing direction + ld a, [wPlayerFacingDirection] ; player sprite's facing direction srl a ld c, a ld b, 0 diff --git a/engine/overworld/cut.asm b/engine/overworld/cut.asm index 3978cb9c..488bc4de 100755 --- a/engine/overworld/cut.asm +++ b/engine/overworld/cut.asm @@ -188,7 +188,7 @@ ReplaceTreeTileBlock: ; ef1f (3:6f1f) ld h, [hl] ld l, a add hl, bc - ld a, [wSpriteStateData1 + 9] ; player sprite's facing direction + ld a, [wPlayerFacingDirection] ; player sprite's facing direction and a jr z, .down cp SPRITE_FACING_UP diff --git a/engine/overworld/get_coords_tile_in_front_of_player.asm b/engine/overworld/get_coords_tile_in_front_of_player.asm index a0d38d7c..ce45e79c 100644 --- a/engine/overworld/get_coords_tile_in_front_of_player.asm +++ b/engine/overworld/get_coords_tile_in_front_of_player.asm @@ -6,7 +6,7 @@ _GetTileAndCoordsInFrontOfPlayer: ; c2d4 (3:42d4) ld d, a ld a, [wXCoord] ld e, a - ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction + ld a, [wPlayerFacingDirection] ; player's sprite facing direction and a ; cp SPRITE_FACING_DOWN jr nz, .notFacingDown ; facing down @@ -45,7 +45,7 @@ GetTileTwoStepsInFrontOfPlayer: ; c309 (3:4309) ld a, [hli] ld d, a ld e, [hl] - ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction + ld a, [wPlayerFacingDirection] ; player's sprite facing direction and a ; cp SPRITE_FACING_DOWN jr nz, .notFacingDown ; facing down diff --git a/engine/overworld/hidden_objects.asm b/engine/overworld/hidden_objects.asm index cba2a221..6e515b5a 100755 --- a/engine/overworld/hidden_objects.asm +++ b/engine/overworld/hidden_objects.asm @@ -61,7 +61,7 @@ CheckForHiddenObject: ; f25f8 (3c:65f8) ; checks if the coordinates in front of the player's sprite match Y in b and X in c ; [hCoordsInFrontOfPlayerMatch] = $00 if they match, $ff if they don't match CheckIfCoordsInFrontOfPlayerMatch: ; 46a01 (11:6a01) - ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction + ld a, [wPlayerFacingDirection] ; player's sprite facing direction cp SPRITE_FACING_UP jr z, .facingUp cp SPRITE_FACING_LEFT diff --git a/engine/overworld/ledges.asm b/engine/overworld/ledges.asm index a6ebd9be..5d95cb18 100755 --- a/engine/overworld/ledges.asm +++ b/engine/overworld/ledges.asm @@ -6,7 +6,7 @@ HandleLedges: ; 1a7f4 (6:67f4) and a ; OVERWORLD ret nz predef GetTileAndCoordsInFrontOfPlayer - ld a, [wSpriteStateData1 + 9] + ld a, [wPlayerFacingDirection] ld b, a aCoord 8, 9 ld c, a diff --git a/engine/overworld/map_sprite_functions1.asm b/engine/overworld/map_sprite_functions1.asm index 48eed56e..46479a9f 100644 --- a/engine/overworld/map_sprite_functions1.asm +++ b/engine/overworld/map_sprite_functions1.asm @@ -28,7 +28,7 @@ _UpdateSprites: ; 4bb7 (1:4bb7) and a jp z, UpdatePlayerSprite cp $f0 ; pikachu - jp z, Func_1552 + jp z, SpawnPikachu ld a, [hl] UpdateNonPlayerSprite: ; 4be3 (1:4be3) diff --git a/engine/overworld/map_sprites.asm b/engine/overworld/map_sprites.asm index 9f25c585..68f6b006 100755 --- a/engine/overworld/map_sprites.asm +++ b/engine/overworld/map_sprites.asm @@ -20,26 +20,26 @@ _InitMapSprites: ; 1401b (5:401b) ; Loads sprite set for outside maps (cities and routes) and sets VRAM slots. ; sets carry if the map is a city or route, unsets carry if not InitOutsideMapSprites: ; 14029 (5:4029) - ld a,[wCurMap] - cp a,REDS_HOUSE_1F ; is the map a city or a route (map ID less than $25)? + ld a, [wCurMap] + cp a, REDS_HOUSE_1F ; is the map a city or a route (map ID less than $25)? ret nc ; if not, return call GetSplitMapSpriteSetID ; if so, choose the appropriate one - ld b,a ; b = spriteSetID - ld a,[wFontLoaded] - bit 0,a ; reloading upper half of tile patterns after displaying text? - jr nz,.loadSpriteSet ; if so, forcibly reload the sprite set - ld a,[wSpriteSetID] + ld b, a ; b = spriteSetID + ld a, [wFontLoaded] + bit 0, a ; reloading upper half of tile patterns after displaying text? + jr nz, .loadSpriteSet ; if so, forcibly reload the sprite set + ld a, [wSpriteSetID] cp b ; has the sprite set ID changed? - jr z,.skipLoadingSpriteSet ; if not, don't load it again + jr z, .skipLoadingSpriteSet ; if not, don't load it again .loadSpriteSet - ld a,b - ld [wSpriteSetID],a + ld a, b + ld [wSpriteSetID], a dec a - ld c,a - ld b,0 + ld c, a + ld b, 0 ld a, (wSpriteSetID - wSpriteSet) - ld hl,SpriteSets + ld hl, SpriteSets call AddNTimes ; get sprite set offset ld de, wSpriteSet ld bc, (wSpriteSetID - wSpriteSet) @@ -64,8 +64,8 @@ LoadSpriteSetFromMapHeader: ; 14061 (5:4061) call FillMemory ld a, SPRITE_PIKACHU ; load Pikachu separately ld [wSpriteSet], a - ld hl,wSpriteStateData1 + $10 - ld a,$0e + ld hl, wSprite01SpriteStateData1 + ld a, 14 .storeVRAMSlotsLoop push af ld a, [hl] ; $C1X0 (picture ID) (zero if sprite slot is not used) @@ -79,13 +79,14 @@ LoadSpriteSetFromMapHeader: ; 14061 (5:4061) ld b, 2 call CheckIfPictureIDAlreadyLoaded jr .continue + .isFourTileSprite ; loop through the space reserved for regular picture IDs ld de, wSpriteSet ld b, 9 call CheckIfPictureIDAlreadyLoaded .continue - ld de, $10 + ld de, wSprite02SpriteStateData1 - wSprite01SpriteStateData1 add hl, de pop af dec a @@ -96,6 +97,7 @@ CheckIfPictureIDAlreadyLoaded: ; 1409b (5:409b) ; Check if the current picture ID has already had its tile patterns loaded. ; This done by looping through the previous sprite slots and seeing if any of ; their picture ID's match that of the current sprite slot. +.loop ld a, [de] and a ; is sprite set slot not taken up yet? jr z, .spriteSlotNotTaken ; if so, load it as it signifies we've reached @@ -106,7 +108,8 @@ CheckIfPictureIDAlreadyLoaded: ; 1409b (5:409b) dec b ; have we reached the end of the sprite set? jr z, .spriteNotAlreadyLoaded ; if so, we're done here inc de - jr CheckIfPictureIDAlreadyLoaded + jr .loop + .spriteSlotNotTaken ld a, c ld [de], a @@ -127,6 +130,7 @@ CheckForFourTileSprite: ; 140ac (5:40ac) ; regular sprite and a ret + .notYellowSprite scf ret @@ -140,6 +144,7 @@ LoadMapSpriteTilePatterns: ; 140b7 (5:40b7) call LoadStillTilePattern call LoadWalkingTilePattern jr .continue + .fourTileSprite call LoadStillTilePattern .continue @@ -202,7 +207,7 @@ GetSpriteVRAMAddress: ; 14018 (5:4108) SpriteVRAMAddresses: ; 14118 (5:4118) ; Equivalent to multiplying $C0 (number of bytes in 12 tiles) times the VRAM ; slot and adding the result to $8000 (the VRAM base address). - dw vChars0 + $c0 + dw vChars0 + $0c0 dw vChars0 + $180 dw vChars0 + $240 dw vChars0 + $300 @@ -211,8 +216,8 @@ SpriteVRAMAddresses: ; 14118 (5:4118) dw vChars0 + $540 dw vChars0 + $600 dw vChars0 + $6c0 - dw vChars0 + $780 - dw vChars0 + $7c0 + dw vChars0 + $780 ; 4-tile sprites + dw vChars0 + $7c0 ; 4-tile sprites ReadSpriteSheetData: ; 1412e (5:412e) ld a, [hVRAMSlot] @@ -246,12 +251,12 @@ ReadSpriteSheetData: ; 1412e (5:412e) Func_14150: ; 14150 (5:4150) ld a, $1 - ld [wSpriteStateData2 + $e], a ; vram slot for player + ld [wPlayerSpriteImageBaseOffset], a ; vram slot for player ld a, $2 - ld [wSpriteStateData2 + $fe], a ; vram slot for Pikachu + ld [wPikachuSpriteImageBaseOffset], a ; vram slot for Pikachu ld a, $e - ld hl, wSpriteStateData1 + $10 + ld hl, wSprite01SpriteStateData1 .loop ld [hVRAMSlot], a ; store current sprite set slot as a counter ld a, [hl] ; $c1x0 (picture ID) @@ -259,12 +264,12 @@ Func_14150: ; 14150 (5:4150) jr z, .spriteUnused call Func_14179 push hl - ld de, (wSpriteStateData2 + $e) - (wSpriteStateData1) ; $10e + ld de, (wPlayerSpriteImageBaseOffset) - (wSpriteStateData1) ; $10e add hl, de ; get $c2xe (sprite image base offset) ld [hl], a ; write offset pop hl .spriteUnused - ld de, $10 + ld de, wSprite02SpriteStateData1 - wSprite01SpriteStateData1 add hl, de ld a, [hVRAMSlot] dec a @@ -297,67 +302,68 @@ Func_14179: ; 14179 (5:4179) GetSplitMapSpriteSetID: ; 14193 (5:4193) ld e, a ld d, 0 - ld hl,MapSpriteSets + ld hl, MapSpriteSets add hl, de - ld a,[hl] ; a = spriteSetID - cp a,$f0 ; does the map have 2 sprite sets? + ld a, [hl] ; a = spriteSetID + cp a, $f0 ; does the map have 2 sprite sets? ret c ; Chooses the correct sprite set ID depending on the player's position within ; the map for maps with two sprite sets. - cp a,$f8 - jr z,.route20 - ld hl,SplitMapSpriteSets - and a,$0f + cp a, $f8 + jr z, .route20 + ld hl, SplitMapSpriteSets + and a, $0f dec a add a add a add l - ld l,a - jr nc,.noCarry + ld l, a + jr nc, .noCarry inc h .noCarry - ld a,[hli] ; determines whether the map is split East/West or North/South - cp a,$01 - ld a,[hli] ; position of dividing line - ld b,a - jr z,.eastWestDivide + ld a, [hli] ; determines whether the map is split East/West or North/South + cp a, $01 + ld a, [hli] ; position of dividing line + ld b, a + jr z, .eastWestDivide .northSouthDivide - ld a,[wYCoord] + ld a, [wYCoord] jr .compareCoord + .eastWestDivide - ld a,[wXCoord] + ld a, [wXCoord] .compareCoord cp b - jr c,.loadSpriteSetID + jr c, .loadSpriteSetID ; if in the East side or South side inc hl .loadSpriteSetID - ld a,[hl] + ld a, [hl] ret ; Uses sprite set $01 for West side and $0A for East side. ; Route 20 is a special case because the two map sections have a more complex ; shape instead of the map simply being split horizontally or vertically. .route20 - ld hl,wXCoord - ld a,[hl] - cp a,$2b - ld a,$01 + ld hl, wXCoord + ld a, [hl] + cp a, $2b + ld a, $01 ret c - ld a,[hl] - cp a,$3e - ld a,$0a + ld a, [hl] + cp a, $3e + ld a, $0a ret nc - ld a,[hl] - cp a,$37 - ld b,$08 - jr nc,.next - ld b,$0d + ld a, [hl] + cp a, $37 + ld b, $08 + jr nc, .next + ld b, $0d .next - ld a,[wYCoord] + ld a, [wYCoord] cp b - ld a,$0a + ld a, $0a ret c - ld a,$01 + ld a, $01 ret -INCLUDE "data/sprite_sets.asm" \ No newline at end of file +INCLUDE "data/sprite_sets.asm" diff --git a/engine/overworld/movement.asm b/engine/overworld/movement.asm index dfd1c012..6bd28dad 100644 --- a/engine/overworld/movement.asm +++ b/engine/overworld/movement.asm @@ -53,7 +53,7 @@ UpdatePlayerSprite: ; 4da5 (1:4da5) ld a, SPRITE_FACING_RIGHT jr .next .next - ld [wSpriteStateData1 + 9], a ; facing direction + ld [wPlayerFacingDirection], a ; facing direction ld a, [wFontLoaded] bit 0, a jr z, .moving @@ -89,7 +89,7 @@ UpdatePlayerSprite: ; 4da5 (1:4da5) Func_4e32: ; 4e32 (1:4e32) ld a, [wSpriteStateData1 + 8] ld b, a - ld a, [wSpriteStateData1 + 9] + ld a, [wPlayerFacingDirection] add b ld [wSpriteStateData1 + 2], a ret diff --git a/engine/overworld/player_animations.asm b/engine/overworld/player_animations.asm index d883f0e3..d0b1cde4 100755 --- a/engine/overworld/player_animations.asm +++ b/engine/overworld/player_animations.asm @@ -35,7 +35,7 @@ EnterMapAnim: ; 70567 (1c:4567) ld hl, wFacingDirectionList call PlayerSpinInPlace ld a, $1 - ld [wd431], a + ld [wPikachuSpawnState], a .restoreDefaultMusic call PlayDefaultMusic .done @@ -46,7 +46,7 @@ EnterMapAnim: ; 70567 (1c:4567) call DelayFrames call PlayerSpinWhileMovingDown ld a, $0 - ld [wd431], a + ld [wPikachuSpawnState], a jr .done .flyAnimation pop hl @@ -63,7 +63,7 @@ EnterMapAnim: ; 70567 (1c:4567) call DoFlyAnimation call LoadPlayerSpriteGraphics ld a, $1 - ld [wd431], a + ld [wPikachuSpawnState], a jr .restoreDefaultMusic FlyAnimationEnterScreenCoords: ; 705ed (1c:45ed) diff --git a/engine/overworld/pokecenter.asm b/engine/overworld/pokecenter.asm index b9307517..63137433 100755 --- a/engine/overworld/pokecenter.asm +++ b/engine/overworld/pokecenter.asm @@ -63,7 +63,7 @@ DisplayPokemonCenterDialogue_: ; 6d97 (1:6d97) callab IsStarterPikachuInOurParty call c, Func_6eaa ld a, $5 - ld [wd431], a + ld [wPikachuSpawnState], a call Func_1525 .doNotReturnPikachu lb bc, 1, 0 diff --git a/engine/overworld/ssanne.asm b/engine/overworld/ssanne.asm index ece4446d..d0d957be 100755 --- a/engine/overworld/ssanne.asm +++ b/engine/overworld/ssanne.asm @@ -32,7 +32,7 @@ AnimateBoulderDust: ; 7a0fb (1e:60fb) jp LoadPlayerSpriteGraphics GetMoveBoulderDustFunctionPointer: ; 7913f (1e:613f) - ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction + ld a, [wPlayerFacingDirection] ; player's sprite facing direction ld hl, MoveBoulderDustFunctionPointerTable ld c, a ld b, $0 diff --git a/engine/overworld/step_functions.asm b/engine/overworld/step_functions.asm index 58667e51..64d215a1 100644 --- a/engine/overworld/step_functions.asm +++ b/engine/overworld/step_functions.asm @@ -2,7 +2,7 @@ ApplyOutOfBattlePoisonDamage: ; c3de (3:43de) ld a, [wd730] add a jp c, .noBlackOut ; no black out if joypad states are being simulated - ld a, [wPreventBlackout] + ld a, [wd492] bit 7, a jp nz, .noBlackOut ld a, [wd72e] diff --git a/engine/overworld/try_pushing_boulder.asm b/engine/overworld/try_pushing_boulder.asm index 89e83ff9..b7e04092 100644 --- a/engine/overworld/try_pushing_boulder.asm +++ b/engine/overworld/try_pushing_boulder.asm @@ -38,7 +38,7 @@ Func_f0a7: ; f0a7 (3:70a7) jp nz, ResetBoulderPushFlags ld a, [hJoyHeld] ld b, a - ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction + ld a, [wPlayerFacingDirection] ; player's sprite facing direction cp SPRITE_FACING_UP jr z, .pushBoulderUp cp SPRITE_FACING_LEFT diff --git a/engine/pikachu_emotions.asm b/engine/pikachu_emotions.asm new file mode 100755 index 00000000..fdfb7813 --- /dev/null +++ b/engine/pikachu_emotions.asm @@ -0,0 +1,674 @@ +IsPlayerTalkingToPikachu:: ; fcf0c (3f:4f0c) + ld a, [wd436] + and a + ret z + ld a, [hSpriteIndexOrTextID] + cp $f + ret nz + call InitializePikachuTextID + xor a + ld [hSpriteIndexOrTextID], a + ld [wd436], a + ret + +InitializePikachuTextID: ; fcf20 (3f:4f20) + ld a, $d4 ; display + ld [hSpriteIndexOrTextID], a + xor a + ld [wPlayerMovingDirection], a + ld a, $1 + ld [wAutoTextBoxDrawingControl], a + call DisplayTextID + xor a + ld [wAutoTextBoxDrawingControl], a + ret + +DoStarterPikachuEmotions: ; fcf35 (3f:4f35) + ld e, a + ld d, $0 + add hl, de + add hl, de + ld e, [hl] + inc hl + ld d, [hl] +.loop + ld a, [de] + inc de + cp $ff + jr z, .done + ld c, a + ld b, $0 + ld hl, StarterPikachuEmotionsJumptable + add hl, bc + add hl, bc + ld a, [hli] + ld h, [hl] + ld l, a + call JumpToAddress + jr .loop +.done + ret + +StarterPikachuEmotionsJumptable: ; fcf54 (3f:4f54) + dw StarterPikachuEmotionCommand_nop ; 0 + dw StarterPikachuEmotionCommand_text ; 1 + dw StarterPikachuEmotionCommand_pcm ; 2 + dw StarterPikachuEmotionCommand_emote ; 3 + dw StarterPikachuEmotionCommand_movement ; 4 + dw StarterPikachuEmotionCommand_pikapic ; 5 + dw StarterPikachuEmotionCommand_subcmd ; 6 + dw StarterPikachuEmotionCommand_delay ; 7 + dw StarterPikachuEmotionCommand_nop2 ; 8 + dw StarterPikachuEmotionCommand_9 ; 9 + dw StarterPikachuEmotionCommand_nop3 ; a + +StarterPikachuEmotionCommand_nop: ; fcf6a (3f:4f6a) +StarterPikachuEmotionCommand_nop3: ; fcf6a (3f:4f6a) + ret + +StarterPikachuEmotionCommand_text: ; fcf6b (3f:4f6b) + ld a, [de] + ld l, a + inc de + ld a, [de] + ld h, a + inc de + push de + call PrintText + pop de + ret + +StarterPikachuEmotionCommand_pcm: ; fcf77 (3f:4f77) + ld a, [de] + inc de + push de + ld e, a + nop + call PlayPikachuSoundClip_ + pop de + ret + +PlayPikachuSoundClip_: ; fcf81 (3f:4f81) + cp $ff + ret z + callab PlayPikachuSoundClip + ret + +StarterPikachuEmotionCommand_emote: ; fcf8d (3f:4f8d) + ld a, [wUpdateSpritesEnabled] + push af + ld a, $ff + ld [wUpdateSpritesEnabled], a + ld a, [de] + inc de + push de + call ShowPikachuEmoteBubble + pop de + pop af + ld [wUpdateSpritesEnabled], a + ret + +ShowPikachuEmoteBubble: ; fcfa2 (3f:4fa2) + ld [wWhichEmotionBubble], a + ld a, $f + ld [wEmotionBubbleSpriteIndex], a + predef EmotionBubble + ret + +StarterPikachuEmotionCommand_movement: ; fcfb0 (3f:4fb0) + ld a, [de] + inc de + ld l, a + ld a, [de] + inc de + ld h, a + push de + ld b, BANK(DoStarterPikachuEmotions) + call ApplyPikachuMovementData_ + pop de + ret + +StarterPikachuEmotionCommand_delay: ; fcfbe (3f:4fbe) + ld a, [de] + inc de + push de + ld c, a + call DelayFrames + pop de + ret + +StarterPikachuEmotionCommand_subcmd: ; fcfc7 (3f:4fc7) + ld a, [de] + inc de + push de + ld e, a + ld d, $0 + ld hl, Jumptable_fcfda + add hl, de + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + call JumpToAddress + pop de + ret + +Jumptable_fcfda: + dw LoadPikachuSpriteIntoVRAM + dw LoadFontTilePatterns + dw Pikachu_LoadCurrentMapViewUpdateSpritesAndDelay3 + dw WaitForTextScrollButtonPress + dw PikachuPewterPokecenterCheck + dw PikachuFanClubCheck + dw PikachuBillsHouseCheck + +StarterPikachuEmotionCommand_nop2: ; fcfe8 (3f:4fe8) + ret + +StarterPikachuEmotionCommand_9: ; fcfe9 (3f:4fe9) + push de + call StarterPikachuEmotionCommand_turnawayfromplayer + call UpdateSprites + pop de + ret + +StarterPikachuEmotionCommand_turnawayfromplayer: ; fcff2 (3f:4ff2) + ld a, [wPlayerFacingDirection] + xor $4 + ld [wPikachuFacingDirection], a + ret + +DeletedFunction_fcffb: ; fcffb (3f:4ffb) +; Inexplicably empty. + rept 5 + nop + endr + ret + +Func_fd001:: ; fd001 (3f:5001) + ld a, e + jr load_expression + +Func_fd004:: ; fd004 (3f:5004) + call MapSpecificPikachuExpression + jr c, load_expression + call GetPikaPicAnimationScriptIndex + call DeletedFunction_fcffb +load_expression: ; fd00f (3f:500f) + ld [wExpressionNumber], a + ld hl, PikachuEmotionTable + call DoStarterPikachuEmotions + ret + +PikachuEmotionTable: ; fd019 (3f:4019) + dw PikachuEmotion0_fd115 + dw PikachuEmotion1_fd141 + dw PikachuEmotion2_fd116 + dw PikachuEmotion3_fd160 + dw PikachuEmotion4_fd136 + dw PikachuEmotion5_fd14d + dw PikachuEmotion6_fd153 + dw PikachuEmotion7_fd128 + dw PikachuEmotion8_fd147 + dw PikachuEmotion9_fd166 + dw PikachuEmotion10_fd11e + dw PikachuEmotion11_fd173 + dw PikachuEmotion12_fd17a + dw PikachuEmotion13_fd180 + dw PikachuEmotion14_fd189 + dw PikachuEmotion15_fd191 + dw PikachuEmotion16_fd197 + dw PikachuEmotion17_fd19d + dw PikachuEmotion18_fd1a3 + dw PikachuEmotion19_fd1a9 + dw PikachuEmotion20_fd1b1 + dw PikachuEmotion21_fd1b9 ; used a fishing rod + dw PikachuEmotion22_fd1c1 + dw PikachuEmotion23_fd1c7 + dw PikachuEmotion24_fd1cf + dw PikachuEmotion25_fd1d7 + dw PikachuEmotion26_fd1df ; wake up pikachu in pewter pokemon center + dw PikachuEmotion27_fd1eb + dw PikachuEmotion28_fd1f1 + dw PikachuEmotion29_fd1f7 + dw PikachuEmotion30_fd1fc + dw PikachuEmotion31_fd20a + dw PikachuEmotion32_fd213 + dw PikachuEmotion33_fd05d + +PikachuEmotion33_fd05d: ; fd05d (3f:505d) + db $ff + +MapSpecificPikachuExpression: ; fd05e (3f:505e) + ld a, [wCurMap] + cp POKEMON_FAN_CLUB + jr nz, .notFanClub + ld hl, wd492 + bit 7, [hl] + ld a, $1d + jr z, .set_carry + call CheckPikachuFollowingPlayer + ld a, $1e + jr nz, .set_carry + jr .asm_fd096 + +.notFanClub + ld a, [wCurMap] + cp PEWTER_POKECENTER + jr nz, .notPewterPokecenter + call CheckPikachuFollowingPlayer + ld a, $1a + jr nz, .set_carry + jr .asm_fd096 + +.notPewterPokecenter + callab Func_f24ae + ld a, e + cp $ff + jr nz, .set_carry + jr .asm_fd096 + +.asm_fd096 + call IsPlayerPikachuAsleepInParty + ld a, $b + jr c, .set_carry + callab Func_fce73 ; same bank + ld a, $1c + jr c, .set_carry + ld a, [wCurMap] + cp POKEMONTOWER_1 + jr c, .notInLavenderTower + cp POKEMONTOWER_7 + 1 + ld a, $16 + jr c, .set_carry +.notInLavenderTower + ld a, [wd49c] + and a + jr z, .no_carry + dec a + ld c, a + ld b, $0 + ld hl, Pointer_fd0cb + add hl, bc + ld a, [hl] + jr .set_carry + +.no_carry + and a + ret + +.set_carry + scf + ret + +Pointer_fd0cb: + db $12, $15, $17, $18, $19 + +IsPlayerPikachuAsleepInParty:: ; fd0d0 (3f:50d0) + xor a + ld [wWhichPokemon], a +.loop + ld a, [wWhichPokemon] + ld c, a + ld b, $0 + ld hl, wPartySpecies + add hl, bc + ld a, [hl] + cp $ff + jr z, .done + cp PIKACHU + jr nz, .curMonNotStarterPikachu + callab IsThisPartymonStarterPikachu + jr nc, .curMonNotStarterPikachu + ld a, [wWhichPokemon] + ld hl, wPartyMon1Status + ld bc, wPartyMon2 - wPartyMon1 + call AddNTimes + ld a, [hl] + and SLP + jr z, .done + jr .curMonSleepingPikachu +.curMonNotStarterPikachu + ld a, [wWhichPokemon] + cp PARTY_LENGTH - 1 + jr z, .done + inc a + ld [wWhichPokemon], a + jr .loop +.curMonSleepingPikachu + scf + ret +.done + and a + ret + +PikachuEmotion0_fd115: ; fd115 (3f:5115) + db $ff + +PikachuEmotion2_fd116: ; fd116 (3f:5116) + pikaemotion_dummy2 + pikaemotion_emotebubble SMILE_BUBBLE + pikaemotion_pcm PikachuCry35 + pikaemotion_pikapic $2 + db $ff + +PikachuEmotion10_fd11e: ; fd11e (3f:511e) + pikaemotion_dummy2 + pikaemotion_subcmd PIKAEMOTION_SUBCMD_LOADEXTRAPIKASPRITES + pikaemotion_emotebubble HEART_BUBBLE + pikaemotion_pcm PikachuCry5 + pikaemotion_pikapic $a + db $ff + +PikachuEmotion7_fd128: ; fd128 (3f:5128) + pikaemotion_dummy2 + pikaemotion_subcmd PIKAEMOTION_SUBCMD_LOADEXTRAPIKASPRITES + pikaemotion_movement Pointer_fd224 + pikaemotion_pcm PikachuCry1 + pikaemotion_movement Pointer_fd224 + pikaemotion_pikapic $7 + db $ff + +PikachuEmotion4_fd136: ; fd136 (3f:5136) + pikaemotion_dummy2 + pikaemotion_subcmd PIKAEMOTION_SUBCMD_LOADEXTRAPIKASPRITES + pikaemotion_movement Pointer_fd230 + pikaemotion_pcm PikachuCry29 + pikaemotion_pikapic $4 + db $ff + +PikachuEmotion1_fd141: ; fd141 (3f:5141) + pikaemotion_dummy2 + pikaemotion_pcm + pikaemotion_pikapic $1 + db $ff + +PikachuEmotion8_fd147: ; fd147 (3f:5147) + pikaemotion_dummy2 + pikaemotion_pcm PikachuCry39 + pikaemotion_pikapic $8 + db $ff + +PikachuEmotion5_fd14d: ; fd14d (3f:514d) + pikaemotion_dummy2 + pikaemotion_pcm PikachuCry31 + pikaemotion_pikapic $5 + db $ff + +PikachuEmotion6_fd153: ; fd153 (3f:5153) + pikaemotion_dummy2 + pikaemotion_subcmd PIKAEMOTION_SUBCMD_LOADEXTRAPIKASPRITES + pikaemotion_pcm + pikaemotion_movement Pointer_fd21e + pikaemotion_emotebubble SKULL_BUBBLE + pikaemotion_pikapic $6 + db $ff + +PikachuEmotion3_fd160: ; fd160 (3f:5160) + pikaemotion_dummy2 + pikaemotion_pcm PikachuCry40 + pikaemotion_pikapic $3 + db $ff + +PikachuEmotion9_fd166: ; fd166 (3f:5166) + pikaemotion_dummy2 + pikaemotion_subcmd PIKAEMOTION_SUBCMD_LOADEXTRAPIKASPRITES + pikaemotion_pcm PikachuCry6 + pikaemotion_movement Pointer_fd218 + pikaemotion_emotebubble SKULL_BUBBLE + pikaemotion_pikapic $9 + db $ff + +PikachuEmotion11_fd173: ; fd173 (3f:5173) + pikaemotion_emotebubble ZZZ_BUBBLE + pikaemotion_pcm PikachuCry37 + pikaemotion_pikapic $b + db $ff + +PikachuEmotion12_fd17a: ; fd17a (3f:517a) + pikaemotion_dummy2 + pikaemotion_pcm + pikaemotion_pikapic $c + db $ff + +PikachuEmotion13_fd180: ; fd180 (3f:5180) + pikaemotion_dummy2 + pikaemotion_subcmd PIKAEMOTION_SUBCMD_LOADEXTRAPIKASPRITES + pikaemotion_movement Pointer_fd21e + pikaemotion_pikapic $d + db $ff + +PikachuEmotion14_fd189: ; fd189 (3f:5189) + pikaemotion_dummy2 + pikaemotion_emotebubble BOLT_BUBBLE + pikaemotion_pcm PikachuCry10 + pikaemotion_pikapic $e + db $ff + +PikachuEmotion15_fd191: ; fd191 (3f:5191) + pikaemotion_dummy2 + pikaemotion_pcm PikachuCry34 + pikaemotion_pikapic $f + db $ff + +PikachuEmotion16_fd197: ; fd197 (3f:5197) + pikaemotion_dummy2 + pikaemotion_pcm PikachuCry33 + pikaemotion_pikapic $10 + db $ff + +PikachuEmotion17_fd19d: ; fd19d (3f:519d) + pikaemotion_dummy2 + pikaemotion_pcm PikachuCry13 + pikaemotion_pikapic $11 + db $ff + +PikachuEmotion18_fd1a3: ; fd1a3 (3f:51a3) + pikaemotion_dummy2 + pikaemotion_pcm + pikaemotion_pikapic $12 + db $ff + +PikachuEmotion19_fd1a9: ; fd1a9 (3f:51a9) + pikaemotion_dummy2 + pikaemotion_emotebubble HEART_BUBBLE + pikaemotion_pcm PikachuCry33 + pikaemotion_pikapic $13 + db $ff + +PikachuEmotion20_fd1b1: ; fd1b1 (3f:51b1) + pikaemotion_dummy2 + pikaemotion_emotebubble HEART_BUBBLE + pikaemotion_pcm PikachuCry5 + pikaemotion_pikapic $14 + db $ff + +PikachuEmotion21_fd1b9: ; fd1b9 (3f:51b9) + pikaemotion_dummy2 + pikaemotion_emotebubble FISH_BUBBLE + pikaemotion_pcm + pikaemotion_pikapic $15 + db $ff + +PikachuEmotion22_fd1c1: ; fd1c1 (3f:51c1) + pikaemotion_dummy2 + pikaemotion_pcm PikachuCry4 + pikaemotion_pikapic $16 + db $ff + +PikachuEmotion23_fd1c7: ; fd1c7 (3f:51c7) + pikaemotion_dummy2 + pikaemotion_pcm PikachuCry19 + pikaemotion_pikapic $17 + pikaemotion_subcmd PIKAEMOTION_SUBCMD_SHOWMAPVIEW + db $ff + +PikachuEmotion24_fd1cf: ; fd1cf (3f:51cf) + pikaemotion_dummy2 + pikaemotion_emotebubble EXCLAMATION_BUBBLE + pikaemotion_pcm + pikaemotion_pikapic $18 + db $ff + +PikachuEmotion25_fd1d7: ; fd1d7 (3f:51d7) + pikaemotion_dummy2 + pikaemotion_emotebubble BOLT_BUBBLE + pikaemotion_pcm PikachuCry35 + pikaemotion_pikapic $19 + db $ff + +PikachuEmotion26_fd1df: ; fd1df (3f:51df) + pikaemotion_dummy2 + pikaemotion_emotebubble ZZZ_BUBBLE + pikaemotion_pcm PikachuCry37 + pikaemotion_pikapic $1a + pikaemotion_subcmd PIKAEMOTION_SUBCMD_SHOWMAPVIEW + pikaemotion_subcmd PIKAEMOTION_SUBCMD_CHECKPEWTERCENTER + db $ff + +PikachuEmotion27_fd1eb: ; fd1eb (3f:51eb) + pikaemotion_dummy2 + pikaemotion_pcm PikachuCry9 + pikaemotion_pikapic $1b + db $ff + +PikachuEmotion28_fd1f1: ; fd1f1 (3f:51f1) + pikaemotion_dummy2 + pikaemotion_pcm PikachuCry15 + pikaemotion_pikapic $1c + db $ff + +PikachuEmotion29_fd1f7: ; fd1f7 (3f:51f7) + pikaemotion_pcm PikachuCry5 + pikaemotion_pikapic $a + db $ff + +PikachuEmotion30_fd1fc: ; fd1fc (3f:51fc) + pikaemotion_9 + pikaemotion_emotebubble HEART_BUBBLE + pikaemotion_pcm PikachuCry5 + pikaemotion_pikapic $14 + pikaemotion_subcmd PIKAEMOTION_SUBCMD_SHOWMAPVIEW + pikaemotion_subcmd PIKAEMOTION_SUBCMD_LOADFONT + pikaemotion_subcmd PIKAEMOTION_SUBCMD_CHECKLAVENDERTOWER + db $ff + +PikachuEmotion31_fd20a: ; fd20a (3f:520a) + pikaemotion_pcm PikachuCry19 + pikaemotion_pikapic $17 + pikaemotion_subcmd PIKAEMOTION_SUBCMD_SHOWMAPVIEW + pikaemotion_subcmd PIKAEMOTION_SUBCMD_CHECKBILLSHOUSE + db $ff + +PikachuEmotion32_fd213: ; fd213 (3f:5213) + pikaemotion_pcm PikachuCry26 + pikaemotion_pikapic $17 + db $ff + +Pointer_fd218: ; fd218 (3f:5218) + db $00 + db $39, $01 + db $3e, $1e + db $3f + +Pointer_fd21e: ; fd21e (3f:521e) + db $00 + db $39, $00 + db $3e, $1e + db $3f + +Pointer_fd224: ; fd224 (3f:5224) + db $00 + db $3c, $07, $2f + db $3c, $07, $2f + db $3f + +Pointer_fd22c: ; fd22c (3f:522c) + db $3b, $1f, $03 + db $3f + +Pointer_fd230: ; fd230 (3f:5230) + db $00 + db $3c, $0f, $1f + db $3c, $0f, $1f + db $3f + +Pointer_fd238: ; fd238 (3f:5238) + db $00 + db $05, $07 + db $39, $00 + db $05, $07 + db $06, $07 + db $39, $00 + db $06, $07 + db $08, $07 + db $39, $00 + db $08, $07 + db $07, $07 + db $39, $00 + db $07, $07 + db $3f + +Func_fd252: ; fd252 (3f:5252) + ld a, $40 + ld [h_0xFFFC], a + call LoadPikachuSpriteIntoVRAM + call Func_fd266 + and a + jr z, .asm_fd262 + call ApplyPikachuMovementData +.asm_fd262 + xor a + ld [h_0xFFFC], a + ret + +Func_fd266: + ld a, [wSpriteStateData2 + 15 * 16 + 4] + ld e, a + ld a, [wSpriteStateData2 + 15 * 16 + 5] + ld d, a + ld a, [wYCoord] + add 4 + cp e + jr z, .asm_fd280 + jr nc, .asm_fd27e + ld hl, Data_fd294 + ld a, 1 + ret + +.asm_fd27e + xor a + ret + +.asm_fd280 + ld a, [wXCoord] + add 4 + cp d + jr c, .asm_fd28e + ld hl, Data_fd299 + ld a, 2 + ret + +.asm_fd28e + ld hl, Data_fd29d + ld a, 3 + ret + +Data_fd294: + db $00 + db $36 + db $2b + db $34 + db $3f + +Data_fd299: + db $00 + db $36 + db $34 + db $3f + +Data_fd29d: + db $00 + db $36 + db $33 + db $3f diff --git a/engine/pikachu_movement.asm b/engine/pikachu_movement.asm new file mode 100755 index 00000000..fbb71ffd --- /dev/null +++ b/engine/pikachu_movement.asm @@ -0,0 +1,1039 @@ +ApplyPikachuMovementData_:: ; fd2a1 (3f:52a1) + ld a, b + ld [wPikachuMovementScriptBank], a + ld a, l + ld [wPikachuMovementScriptAddress], a + ld a, h + ld [wPikachuMovementScriptAddress + 1], a + call PikachuSwapSpriteStateData +.loop + call LoadPikachuMovementCommandData + jr nc, .done + call ExecutePikachuMovementCommand + jr .loop + +.done + call PikachuSwapSpriteStateData + call DelayFrame + ret + +PikachuSwapSpriteStateData: + ld a, [wUpdateSpritesEnabled] + push af + ld a, $ff + ld [wUpdateSpritesEnabled], a + push hl + push de + push bc + + ld hl, wSpriteStateData1 + ld de, wPikachuSpriteStateData1 + ld c, $10 + call SwapBytes3f + + ld hl, wSpriteStateData2 + ld de, wPikachuSpriteStateData2 + ld c, $10 + call SwapBytes3f + + pop bc + pop de + pop hl + pop af + ld [wUpdateSpritesEnabled], a + ret + +SwapBytes3f: +.loop + ld b, [hl] + ld a, [de] + ld [hli], a + ld a, b + ld [de], a + inc de + dec c + jr nz, .loop + ret + +LoadPikachuMovementCommandData: + call GetPikachuMovementScriptByte + cp $3f + ret z + ld c, a + ld b, 0 + ld hl, Data_fd3b0 + add hl, bc + add hl, bc + add hl, bc + add hl, bc + ld a, [hli] + ld [wPikaPicAnimPointer + 1], a + ld a, [hli] + cp $80 + jr nz, .no_param + call GetPikachuMovementScriptByte +.no_param + ld [wPikaPicAnimPointer], a + ld a, [hli] + ld [wPikaPicAnimCurGraphicID], a + ld a, [hli] + cp $80 + jr nz, .no_param2 + call GetPikachuMovementScriptByte +.no_param2 + ld [wPikaPicAnimPointerSetupFinished], a + xor a + ld [wPikaPicAnimTimer], a + scf + ret + +ExecutePikachuMovementCommand: + xor a + ld [wd44d], a + ld [wd457], a + ld [wd458], a + ld a, [wPlayerGrassPriority] + push af +.loop + ld bc, wSpriteStateData1 + ld a, [wPikaPicAnimPointer + 1] + ld hl, Jumptable_fd4ac + call .JumpTable + ld a, [wPikaPicAnimCurGraphicID] + ld hl, Jumptable_fd65c + call .JumpTable + call Func_fd36e + call Func_fd39d + call DelayFrame + call DelayFrame + ld hl, wd44d + bit 7, [hl] + jr z, .loop + pop af + ld [wPlayerGrassPriority], a + scf + ret + +.JumpTable: + ld e, a + ld d, 0 + add hl, de + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + jp [hl] + +Func_fd36e: + ld hl, 2 + add hl, bc + ld a, [wPikaPicAnimTimer + 1] + ld [hl], a + ld a, [wPikaSpriteY] + ld d, a + ld a, [wd456] + add d + ld hl, 4 + add hl, bc + ld [hl], a + ld a, [wPikaPicAnimDelay] + ld d, a + ld a, [wPikaPicTextboxStartY] + add d + ld hl, 6 + add hl, bc + ld [hl], a + ld hl, wd44d + bit 6, [hl] + ret z + ld hl, wPlayerGrassPriority - wSpriteStateData1 + add hl, bc + ld [hl], 0 + ret + +Func_fd39d: + ld hl, wd44d + bit 6, [hl] + res 6, [hl] + ld hl, wd736 + res 6, [hl] + ret z + set 6, [hl] + call Func_fd7f3 + ret + +Data_fd3b0: + db $01, $00, $00, $00 ; $00 + db $03, $80, $01, $00 ; $01 + db $04, $80, $01, $00 ; $02 + db $05, $80, $01, $00 ; $03 + db $06, $80, $01, $00 ; $04 + db $07, $80, $01, $00 ; $05 + db $08, $80, $01, $00 ; $06 + db $09, $80, $01, $00 ; $07 + db $0a, $80, $01, $00 ; $08 + db $03, $80, $06, $00 ; $09 + db $04, $80, $06, $00 ; $0a + db $05, $80, $06, $00 ; $0b + db $06, $80, $06, $00 ; $0c + db $07, $80, $06, $00 ; $0d + db $08, $80, $06, $00 ; $0e + db $09, $80, $06, $00 ; $0f + db $0a, $80, $06, $00 ; $10 + db $03, $80, $03, $80 ; $11 + db $04, $80, $03, $80 ; $12 + db $05, $80, $03, $80 ; $13 + db $06, $80, $03, $80 ; $14 + db $07, $80, $03, $80 ; $15 + db $08, $80, $03, $80 ; $16 + db $09, $80, $03, $80 ; $17 + db $0a, $80, $03, $80 ; $18 + db $03, $80, $07, $80 ; $19 + db $04, $80, $07, $80 ; $1a + db $05, $80, $07, $80 ; $1b + db $06, $80, $07, $80 ; $1c + db $0b, $27, $02, $00 ; $1d step down + db $0c, $27, $02, $00 ; $1e step up + db $0d, $27, $02, $00 ; $1f step left + db $0e, $27, $02, $00 ; $20 step right + db $0f, $27, $02, $00 ; $21 + db $10, $27, $02, $00 ; $22 + db $11, $27, $02, $00 ; $23 + db $12, $27, $02, $00 ; $24 + db $0b, $0f, $02, $00 ; $25 + db $0c, $0f, $02, $00 ; $26 + db $0d, $0f, $02, $00 ; $27 + db $0e, $0f, $02, $00 ; $28 + db $0f, $0f, $02, $00 ; $29 + db $10, $0f, $02, $00 ; $2a + db $11, $0f, $02, $00 ; $2b + db $12, $0f, $02, $00 ; $2c + db $0b, $0f, $08, $17 ; $2d + db $0c, $0f, $08, $17 ; $2e + db $0d, $0f, $08, $17 ; $2f + db $0e, $0f, $08, $17 ; $30 + db $0f, $0f, $08, $17 ; $31 + db $10, $0f, $08, $17 ; $32 + db $11, $0f, $08, $17 ; $33 + db $12, $0f, $08, $17 ; $34 + db $13, $0f, $06, $00 ; $35 look down + db $14, $0f, $06, $00 ; $36 look up + db $15, $0f, $06, $00 ; $37 look left + db $16, $0f, $06, $00 ; $38 look right + db $02, $80, $04, $00 ; $39 + db $02, $80, $05, $00 ; $3a + db $02, $80, $03, $80 ; $3b + db $02, $80, $07, $80 ; $3c + db $02, $80, $09, $80 ; $3d + db $02, $80, $06, $00 ; $3e + +Jumptable_fd4ac: + dw Func_fd4e5 + dw Func_fd4e9 + dw Func_fd504 + dw Func_fd50c + dw Func_fd511 + dw Func_fd518 + dw Func_fd52c + dw Func_fd540 + dw Func_fd553 + dw Func_fd566 + dw Func_fd579 + dw Func_fd5b1 + dw Func_fd5b5 + dw Func_fd5b9 + dw Func_fd5bd + dw Func_fd5c1 + dw Func_fd5c5 + dw Func_fd5c9 + dw Func_fd5cd + dw Func_fd5ea + dw Func_fd5ee + dw Func_fd5f2 + dw Func_fd5f6 + dw Func_fd4e5 + +Func_fd4dc: + ld a, [wd44d] + set 7, a + ld [wd44d], a + ret + +Func_fd4e5: + call Func_fd4dc + ret + +Func_fd4e9: + ld hl, 4 + add hl, bc + ld a, [hl] + ld [wPikaSpriteY], a + ld hl, 6 + add hl, bc + ld a, [hl] + ld [wPikaPicAnimDelay], a + xor a + ld [wd456], a + ld [wPikaPicTextboxStartY], a + call Func_fd4dc + ret + +Func_fd504: + call Func_fd775 + ret nz + call Func_fd4dc + ret + +Func_fd50c: + call GetObjectFacing + jr asm_fd58c + +Func_fd511: + call GetObjectFacing + xor %100 + jr asm_fd58c + +Func_fd518: + call GetObjectFacing + ld hl, Data_fd523 + call Func_fd5a0 + jr asm_fd58c + +Data_fd523: + db SPRITE_FACING_DOWN, SPRITE_FACING_RIGHT + db SPRITE_FACING_UP, SPRITE_FACING_LEFT + db SPRITE_FACING_LEFT, SPRITE_FACING_DOWN + db SPRITE_FACING_RIGHT, SPRITE_FACING_UP + db $ff + +Func_fd52c: + call GetObjectFacing + ld hl, Data_fd537 + call Func_fd5a0 + jr asm_fd58c + +Data_fd537: + db SPRITE_FACING_DOWN, SPRITE_FACING_LEFT + db SPRITE_FACING_UP, SPRITE_FACING_RIGHT + db SPRITE_FACING_LEFT, SPRITE_FACING_UP + db SPRITE_FACING_RIGHT, SPRITE_FACING_DOWN + db $ff + +Func_fd540: + call GetObjectFacing + ld hl, Data_fd54b + call Func_fd5a0 + jr asm_fd58c + +Data_fd54b: + db SPRITE_FACING_DOWN, SPRITE_FACING_UP | $10 + db SPRITE_FACING_UP, SPRITE_FACING_LEFT | $10 + db SPRITE_FACING_LEFT, SPRITE_FACING_DOWN | $10 + db SPRITE_FACING_RIGHT, SPRITE_FACING_RIGHT | $10 + +Func_fd553: + call GetObjectFacing + ld hl, Data_fd55e + call Func_fd5a0 + jr asm_fd58c + +Data_fd55e: + db SPRITE_FACING_DOWN, SPRITE_FACING_DOWN | $10 + db SPRITE_FACING_UP, SPRITE_FACING_RIGHT | $10 + db SPRITE_FACING_LEFT, SPRITE_FACING_LEFT | $10 + db SPRITE_FACING_RIGHT, SPRITE_FACING_UP | $10 + +Func_fd566: + call GetObjectFacing + ld hl, Data_fd571 + call Func_fd5a0 + jr asm_fd58c + +Data_fd571: + db SPRITE_FACING_DOWN, SPRITE_FACING_RIGHT | $10 + db SPRITE_FACING_UP, SPRITE_FACING_DOWN | $10 + db SPRITE_FACING_LEFT, SPRITE_FACING_UP | $10 + db SPRITE_FACING_RIGHT, SPRITE_FACING_LEFT | $10 + +Func_fd579: + call GetObjectFacing + ld hl, Data_fd584 + call Func_fd5a0 + jr asm_fd58c + +Data_fd584: + db SPRITE_FACING_DOWN, SPRITE_FACING_LEFT | $10 + db SPRITE_FACING_UP, SPRITE_FACING_UP | $10 + db SPRITE_FACING_LEFT, SPRITE_FACING_RIGHT | $10 + db SPRITE_FACING_RIGHT, SPRITE_FACING_DOWN | $10 + +asm_fd58c + rrca + rrca + and $7 + ld e, a + call Func_fd784 + ld d, a + call UpdatePikachuPosition + call Func_fd775 + ret nz + call Func_fd4dc + ret + +Func_fd5a0: + push de + ld d, a +.asm_fd5a2 + ld a, [hli] + cp d + jr z, .asm_fd5ad + inc hl + cp $ff + jr nz, .asm_fd5a2 + pop de + ret + +.asm_fd5ad + ld a, [hl] + pop de + scf + ret + +Func_fd5b1: + ld a, SPRITE_FACING_DOWN >> 2 + jr asm_fd5d1 + +Func_fd5b5: + ld a, SPRITE_FACING_UP >> 2 + jr asm_fd5d1 + +Func_fd5b9: + ld a, SPRITE_FACING_LEFT >> 2 + jr asm_fd5d1 + +Func_fd5bd: + ld a, SPRITE_FACING_RIGHT >> 2 + jr asm_fd5d1 + +Func_fd5c1: + ld e, 4 + jr asm_fd5d5 + +Func_fd5c5: + ld e, 5 + jr asm_fd5d5 + +Func_fd5c9: + ld e, 6 + jr asm_fd5d5 + +Func_fd5cd: + ld e, 7 + jr asm_fd5d5 + +asm_fd5d1 + ld e, a + call SetObjectFacing +asm_fd5d5 + call Func_fd784 + ld d, a + push de + call UpdatePikachuPosition + pop de + call Func_fd775 + ret nz + ld a, e + call Func_fd7cb + call Func_fd4dc + ret + +Func_fd5ea: + ld a, SPRITE_FACING_DOWN >> 2 + jr asm_fd5fa + +Func_fd5ee: + ld a, SPRITE_FACING_UP >> 2 + jr asm_fd5fa + +Func_fd5f2: + ld a, SPRITE_FACING_LEFT >> 2 + jr asm_fd5fa + +Func_fd5f6: + ld a, SPRITE_FACING_RIGHT >> 2 + jr asm_fd5fa + +asm_fd5fa + call SetObjectFacing + call Func_fd4dc + ret + +UpdatePikachuPosition: + push de + ld d, 0 + ld hl, Jumptable_fd60f + add hl, de + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + pop de + ld a, d + jp [hl] + +Jumptable_fd60f: + dw MovePikachuSpriteDown + dw MovePikachuSpriteUp + dw MovePikachuSpriteLeft + dw MovePikachuSpriteRight + dw MovePikachuSpriteDownLeft + dw MovePikachuSpriteDownRight + dw MovePikachuSpriteUpLeft + dw MovePikachuSpriteUpRight + +MovePikachuSpriteDown: + ld d, 0 + ld e, a + jr asm_fd64d + +MovePikachuSpriteUp: + ld d, 0 + cpl + inc a + ld e, a + jr asm_fd64d + +MovePikachuSpriteLeft: + cpl + inc a + ld d, a + ld e, 0 + jr asm_fd64d + +MovePikachuSpriteRight: + ld d, a + ld e, 0 + jr asm_fd64d + +MovePikachuSpriteDownLeft: + ld e, a + cpl + inc a + ld d, a + jr asm_fd64d + +MovePikachuSpriteDownRight: + ld e, a + ld d, a + jr asm_fd64d + +MovePikachuSpriteUpLeft: + cpl + inc a + ld e, a + ld d, a + jr asm_fd64d + +MovePikachuSpriteUpRight: + ld d, a + cpl + inc a + ld e, a + jr asm_fd64d + +asm_fd64d + ld a, [wPikaPicAnimDelay] + add d + ld [wPikaPicAnimDelay], a + ld a, [wPikaSpriteY] + add e + ld [wPikaSpriteY], a + ret + +Jumptable_fd65c: + dw Func_fd678 + dw Func_fd6a3 + dw Func_fd698 + dw Func_fd6f4 + dw Func_fd6ff + dw Func_fd718 + dw Func_fd68c + dw Func_fd6c6 + dw Func_fd6c0 + dw Func_fd6e2 + dw Func_fd68b + +Func_fd672: + ld hl, wd44d + set 6, [hl] + ret + +Func_fd678: + ld hl, 7 + add hl, bc + xor a + ld [hli], a + ld [hl], a + call Func_fd74a + ld d, a + call GetObjectFacing + or d + ld [wPikaPicAnimTimer + 1], a + ret + +Func_fd68b: + ret + +Func_fd68c: + call Func_fd74a + ld d, a + call Func_fd755 + or d + ld [wPikaPicAnimTimer + 1], a + ret + +Func_fd698: + call Func_fd74a + ld d, a + call GetObjectFacing + or d + ld d, a + jr asm_fd6ac + +Func_fd6a3: + call Func_fd74a + ld d, a + call Func_fd755 + or d + ld d, a +asm_fd6ac + ld hl, 8 + add hl, bc + call Func_fd78e + jr nz, .asm_fd6b6 + inc [hl] +.asm_fd6b6 + ld a, [hl] + rrca + rrca + and 3 + or d + ld [wPikaPicAnimTimer + 1], a + ret + +Func_fd6c0: + call GetObjectFacing + ld d, a + jr asm_fd6ca + +Func_fd6c6: + call Func_fd755 + ld d, a +asm_fd6ca + call Func_fd74a + or d + ld d, a + call Func_fd736 + or d + ld [wPikaPicAnimTimer + 1], a + call Func_fd79d + ld [wd456], a + and a + ret z + call Func_fd672 + ret + +Func_fd6e2: + call GetObjectFacing + ld d, a + call Func_fd74a + or d + ld [wPikaPicAnimTimer + 1], a + call Func_fd79d + ld [wd456], a + ret + +Func_fd6f4: + ld a, [wPikaPicAnimPointerSetupFinished] + and $40 + cp $40 + jr z, Func_fd6ff + jr Func_fd718 + +Func_fd6ff: + call Func_fd755 + ld d, a + call Func_fd78e + jr nz, .asm_fd710 + ld hl, Data_fd731 +.asm_fd70b + ld a, [hli] + cp d + jr nz, .asm_fd70b + ld d, [hl] +.asm_fd710 + call Func_fd74a + or d + ld [wPikaPicAnimTimer + 1], a + ret + +Func_fd718: + call Func_fd755 + ld d, a + call Func_fd78e + jr nz, .asm_fd529 + ld hl, Data_fd731End +.asm_fd524 + ld a, [hld] + cp d + jr nz, .asm_fd524 + ld d, [hl] +.asm_fd529 + call Func_fd74a + or d + ld [wPikaPicAnimTimer + 1], a + ret + +Data_fd731: + db SPRITE_FACING_DOWN + db SPRITE_FACING_LEFT + db SPRITE_FACING_UP + db SPRITE_FACING_RIGHT + db SPRITE_FACING_DOWN +Data_fd731End: + +Func_fd736: + push hl + ld hl, 7 + add hl, bc + ld a, [hl] + inc a + and $3 + ld [hli], a + jr nz, .asm_fd747 + ld a, [hl] + inc a + and $3 + ld [hl], a +.asm_fd747 + ld a, [hl] + pop hl + ret + +Func_fd74a: + push hl + ld hl, wSpriteStateData2 - wSpriteStateData1 + 14 + add hl, bc + ld a, [hl] + dec a + swap a + pop hl + ret + +Func_fd755: + push hl + ld hl, 2 + add hl, bc + ld a, [hl] + and $c + pop hl + ret + +GetObjectFacing: + push hl + ld hl, 9 + add hl, bc + ld a, [hl] + and $c + pop hl + ret + +SetObjectFacing: + push hl + ld hl, 9 + add hl, bc + add a + add a + and $c + ld [hl], a + pop hl + ret + +Func_fd775: + ld hl, wd457 + inc [hl] + ld a, [wPikaPicAnimPointer] + and $1f + inc a + cp [hl] + ret nz + ld [hl], 0 + ret + +Func_fd784: + ld a, [wPikaPicAnimPointer] + swap a + rrca + and $3 + inc a + ret + +Func_fd78e: + ld hl, wd458 + inc [hl] + ld a, [wPikaPicAnimPointerSetupFinished] + and $f + inc a + cp [hl] + ret nz + ld [hl], 0 + ret + +Func_fd79d: + call Func_fd7b2 + ld a, [wd458] + add e + ld [wd458], a + add $20 + ld e, a + push hl + push bc + call Sine_e + pop bc + pop hl + ret + +Func_fd7b2: + ld a, [wPikaPicAnimPointerSetupFinished] + and $f + inc a + ld d, a + ld a, [wPikaPicAnimPointerSetupFinished] + swap a + and $7 + ld e, a + ld a, 1 + jr z, .asm_fd7c9 +.asm_fd7c5 + add a + dec e + jr nz, .asm_fd7c5 +.asm_fd7c9 + ld e, a + ret + +Func_fd7cb: + push bc + ld c, a + ld b, 0 + ld hl, Data_fd7e3 + add hl, bc + add hl, bc + ld d, [hl] + inc hl + ld e, [hl] + pop bc + ld hl, wSpriteStateData2 - wSpriteStateData1 + 4 + add hl, bc + ld a, [hl] + add e + ld [hli], a + ld a, [hl] + add d + ld [hl], a + ret + +Data_fd7e3: + db 0, 1 + db 0, -1 + db -1, 0 + db 1, 0 + db -1, 1 + db 1, 1 + db -1, -1 + db 1, -1 + +Func_fd7f3: + push bc + push de + push hl + + ld bc, wOAMBuffer + 4 * 36 + ld a, [wPikaSpriteY] + ld e, a + ld a, [wPikaPicAnimDelay] + ld d, a + ld hl, Data_fd80b + call Func_fd814 + + pop hl + pop de + pop bc + ret + +Data_fd80b: + db $02 + db $0c, $00, $ff, 0 + db $0c, $08, $ff, 1 << OAM_X_FLIP + +Func_fd814: + ld a, e + add $10 + ld e, a + ld a, d + add $8 + ld d, a + ld a, [hli] +.asm_fd81d + push af + ld a, [hli] + add e + ld [bc], a + inc bc + ld a, [hli] + add d + ld [bc], a + inc bc + ld a, [hli] + ld [bc], a + inc bc + ld a, [hli] + ld [bc], a + inc bc + pop af + dec a + jr nz, .asm_fd81d + ret + +LoadPikachuShadowIntoVRAM: + ld hl, vNPCSprites2 + $7f * $10 + ld de, LedgeHoppingShadowGFX_3F + lb bc, BANK(LedgeHoppingShadowGFX_3F), (LedgeHoppingShadowGFX_3FEnd - LedgeHoppingShadowGFX_3F) / 8 + jp CopyVideoDataDoubleAlternate + +LedgeHoppingShadowGFX_3F: +INCBIN "gfx/ledge_hopping_shadow.1bpp" +LedgeHoppingShadowGFX_3FEnd: + +LoadPikachuBallIconIntoVRAM: + ld hl, vNPCSprites2 + $7e * $10 + ld de, GFX_fd86b + lb bc, BANK(GFX_fd86b), 1 + jp CopyVideoDataDoubleAlternate + +Func_fd851: + ld hl, vNPCSprites + $c * $10 + ld a, 3 +.asm_fd856 + push af + push hl + ld de, GFX_fd86b + lb bc, BANK(GFX_fd86b), 4 + call CopyVideoDataAlternate + pop hl + ld de, 4 * $10 + add hl, de + pop af + dec a + jr nz, .asm_fd856 + ret + +GFX_fd86b: +INCBIN "gfx/unknown_fd86b.2bpp" + +LoadPikachuSpriteIntoVRAM: ; fd8ab (3f:58ab) + ld de, PikachuSprite + lb bc, BANK(PikachuSprite), (SandshrewSprite - PikachuSprite) / 32 + ld hl, vNPCSprites + $c * $10 + push bc + call CopyVideoDataAlternate + ld de, PikachuSprite + $c * $10 + ld hl, vNPCSprites2 + $c * $10 + ld a, [h_0xFFFC] + and a + jr z, .load + ld de, PikachuSprite + $c * $10 + ld hl, vNPCSprites2 + $4c * $10 +.load + pop bc + call CopyVideoDataAlternate + call LoadPikachuShadowIntoVRAM + call LoadPikachuBallIconIntoVRAM + ret + +PikachuPewterPokecenterCheck: ; fd8d4 (3f:58d4) + ld a, [wCurMap] + cp PEWTER_POKECENTER + ret nz + call EnablePikachuFollowingPlayer + call StarterPikachuEmotionCommand_turnawayfromplayer + ret + +PikachuFanClubCheck: ; fd8e1 (3f:58e1) + ld a, [wCurMap] + cp POKEMON_FAN_CLUB + ret nz + call EnablePikachuFollowingPlayer + call StarterPikachuEmotionCommand_turnawayfromplayer + ret + +PikachuBillsHouseCheck: ; fd8ee (3f:58ee) + ld a, [wCurMap] + cp BILLS_HOUSE + ret nz + call EnablePikachuFollowingPlayer + ret + +Pikachu_LoadCurrentMapViewUpdateSpritesAndDelay3: ; fd8f8 (3f:58f8) + call LoadCurrentMapView + call UpdateSprites + call Delay3 + ret + +Cosine_e: ; cosine? + ld a, e + add $10 + jr asm_fd908 + +Sine_e: ; sine? + ld a, e +asm_fd908 + and $3f + cp $20 + jr nc, .asm_fd913 + call GetSine + ld a, h + ret + +.asm_fd913 + and $1f + call GetSine + ld a, h + cpl + inc a + ret + +GetSine: + ld e, a + ld a, d + ld d, 0 + ld hl, SineWave_3f + add hl, de + add hl, de + ld e, [hl] + inc hl + ld d, [hl] + ld hl, 0 +.asm_fd92b + srl a + jr nc, .asm_fd930 + add hl, de +.asm_fd930 + sla e + rl d + and a + jr nz, .asm_fd92b + ret + +SineWave_3f: + sine_wave $100 diff --git a/engine/pikachu_pcm.asm b/engine/pikachu_pcm.asm new file mode 100755 index 00000000..e0238468 --- /dev/null +++ b/engine/pikachu_pcm.asm @@ -0,0 +1,154 @@ +PlayPikachuSoundClip:: ; f0000 (3c:4000) + ld a, e + ld e, a + ld d, $0 + ld hl, PikachuCriesPointerTable + add hl, de + add hl, de + add hl, de + ld b, [hl] ; bank of pikachu cry data + inc hl + ld a, [hli] ; cry data pointer + ld h, [hl] + ld l, a + ld c, $4 +.loop + dec c + jr z, .done_delay + call DelayFrame + jr .loop + +.done_delay + di + push bc + push hl + ld a, $80 + ld [rNR52], a + ld a, $77 + ld [rNR50], a + xor a + ld [rNR30], a + ld hl, $ff30 ; wave data + ld de, wRedrawRowOrColumnSrcTiles +.saveWaveDataLoop + ld a, [hl] + ld [de], a + inc de + ld a, $ff + ld [hli], a + ld a, l + cp $40 ; end of wave data + jr nz, .saveWaveDataLoop + ld a, $80 + ld [rNR30], a + ld a, [rNR51] + or $44 + ld [rNR51], a + ld a, $ff + ld [rNR31], a + ld a, $20 + ld [rNR32], a + ld a, $ff + ld [rNR33], a + ld a, $87 + ld [rNR34], a + pop hl + pop bc + call PlayPikachuPCM + xor a + ld [wc0f3], a + ld [wc0f4], a + ld a, $80 + ld [rNR52], a + xor a + ld [rNR30], a + ld hl, $ff30 + ld de, wRedrawRowOrColumnSrcTiles +.reloadWaveDataLoop + ld a, [de] + inc de + ld [hli], a + ld a, l + cp $40 ; end of wave data + jr nz, .reloadWaveDataLoop + ld a, $80 + ld [rNR30], a + ld a, [rNR51] + and $bb + ld [rNR51], a + xor a + ld [wChannelSoundIDs+CH4], a + ld [wChannelSoundIDs+CH5], a + ld [wChannelSoundIDs+CH6], a + ld [wChannelSoundIDs+CH7], a + ld a, [H_LOADEDROMBANK] + ei + ret + +PikachuCriesPointerTable: ; f008e (3c:408e) +; format: +; db bank +; dw pointer to cry + +; bank 21 + pikacry_def PikachuCry1 ; 21:4000 + pikacry_def PikachuCry2 ; 21:491a + pikacry_def PikachuCry3 ; 21:4fdc + pikacry_def PikachuCry4 ; 21:59ee + +; bank 22 + pikacry_def PikachuCry5 ; 22:4000 + pikacry_def PikachuCry6 ; 22:5042 + pikacry_def PikachuCry7 ; 22:6254 + +; bank 23 + pikacry_def PikachuCry8 ; 23:4000 + pikacry_def PikachuCry9 ; 23:50ca + pikacry_def PikachuCry10 ; 23:5e0c + +; bank 24 + pikacry_def PikachuCry11 ; 24:4000 + pikacry_def PikachuCry12 ; 24:4722 + pikacry_def PikachuCry13 ; 24:54a4 + +; bank 25 + pikacry_def PikachuCry14 ; 25:4000 + pikacry_def PikachuCry15 ; 25:589a + +; banks 31-34, in no particular order + + pikacry_def PikachuCry16 ; 31:4000 + pikacry_def PikachuCry17 ; 34:4000 + pikacry_def PikachuCry18 ; 31:549a + pikacry_def PikachuCry19 ; 33:4000 + pikacry_def PikachuCry20 ; 32:4000 + pikacry_def PikachuCry21 ; 32:6002 + pikacry_def PikachuCry22 ; 31:63a4 + pikacry_def PikachuCry23 ; 34:4862 + pikacry_def PikachuCry24 ; 33:5632 + pikacry_def PikachuCry25 ; 34:573c + pikacry_def PikachuCry26 ; 33:725c + +; bank 35 + pikacry_def PikachuCry27 ; 35:4000 + pikacry_def PikachuCry28 ; 35:4b5a + pikacry_def PikachuCry29 ; 35:5da4 + pikacry_def PikachuCry30 ; 35:69ce + pikacry_def PikachuCry31 ; 35:6e80 + +; bank 36 + pikacry_def PikachuCry32 ; 36:4000 + pikacry_def PikachuCry33 ; 36:458a + pikacry_def PikachuCry34 ; 36:523c + +; bank 37 + pikacry_def PikachuCry35 ; 37:4000 + pikacry_def PikachuCry36 ; 37:522a + +; banks 36-38 + pikacry_def PikachuCry37 ; 38:4000 + pikacry_def PikachuCry38 ; 38:4dfa + pikacry_def PikachuCry39 ; 37:6e0c + pikacry_def PikachuCry40 ; 38:5a64 + pikacry_def PikachuCry41 ; 36:6746 + pikacry_def PikachuCry42 ; 38:6976 diff --git a/engine/pikachu_pic_animation.asm b/engine/pikachu_pic_animation.asm index 38045a05..226049f2 100755 --- a/engine/pikachu_pic_animation.asm +++ b/engine/pikachu_pic_animation.asm @@ -1,1714 +1,3 @@ -IsPlayerTalkingToPikachu:: ; fcf0c (3f:4f0c) - ld a, [wd436] - and a - ret z - ld a, [hSpriteIndexOrTextID] - cp $f - ret nz - call InitializePikachuTextID - xor a - ld [hSpriteIndexOrTextID], a - ld [wd436], a - ret - -InitializePikachuTextID: ; fcf20 (3f:4f20) - ld a, $d4 ; display - ld [hSpriteIndexOrTextID], a - xor a - ld [wPlayerMovingDirection], a - ld a, $1 - ld [wAutoTextBoxDrawingControl], a - call DisplayTextID - xor a - ld [wAutoTextBoxDrawingControl], a - ret - -DoStarterPikachuEmotions: ; fcf35 (3f:4f35) - ld e, a - ld d, $0 - add hl, de - add hl, de - ld e, [hl] - inc hl - ld d, [hl] -.loop - ld a, [de] - inc de - cp $ff - jr z, .done - ld c, a - ld b, $0 - ld hl, StarterPikachuEmotionsJumptable - add hl, bc - add hl, bc - ld a, [hli] - ld h, [hl] - ld l, a - call JumpToAddress - jr .loop -.done - ret - -StarterPikachuEmotionsJumptable: ; fcf54 (3f:4f54) - dw StarterPikachuEmotionCommand_nop ; 0 - dw StarterPikachuEmotionCommand_text ; 1 - dw StarterPikachuEmotionCommand_pcm ; 2 - dw StarterPikachuEmotionCommand_emote ; 3 - dw StarterPikachuEmotionCommand_4 ; 4 - dw StarterPikachuEmotionCommand_5 ; 5 - dw StarterPikachuEmotionCommand_subcmd ; 6 - dw StarterPikachuEmotionCommand_delay ; 7 - dw StarterPikachuEmotionCommand_nop2 ; 8 - dw StarterPikachuEmotionCommand_9 ; 9 - dw StarterPikachuEmotionCommand_nop3 ; a - -StarterPikachuEmotionCommand_nop: ; fcf6a (3f:4f6a) -StarterPikachuEmotionCommand_nop3: ; fcf6a (3f:4f6a) - ret - -StarterPikachuEmotionCommand_text: ; fcf6b (3f:4f6b) - ld a, [de] - ld l, a - inc de - ld a, [de] - ld h, a - inc de - push de - call PrintText - pop de - ret - -StarterPikachuEmotionCommand_pcm: ; fcf77 (3f:4f77) - ld a, [de] - inc de - push de - ld e, a - nop - call PlayPikachuSoundClip_ - pop de - ret - -PlayPikachuSoundClip_: ; fcf81 (3f:4f81) - cp $ff - ret z - callab PlayPikachuSoundClip - ret - -StarterPikachuEmotionCommand_emote: ; fcf8d (3f:4f8d) - ld a, [wUpdateSpritesEnabled] - push af - ld a, $ff - ld [wUpdateSpritesEnabled], a - ld a, [de] - inc de - push de - call ShowPikachuEmoteBubble - pop de - pop af - ld [wUpdateSpritesEnabled], a - ret - -ShowPikachuEmoteBubble: ; fcfa2 (3f:4fa2) - ld [wWhichEmotionBubble], a - ld a, $f - ld [wEmotionBubbleSpriteIndex], a - predef EmotionBubble - ret - -StarterPikachuEmotionCommand_4: ; fcfb0 (3f:4fb0) - ld a, [de] - inc de - ld l, a - ld a, [de] - inc de - ld h, a - push de - ld b, $3f - call Func_fd2a1 - pop de - ret - -StarterPikachuEmotionCommand_delay: ; fcfbe (3f:4fbe) - ld a, [de] - inc de - push de - ld c, a - call DelayFrames - pop de - ret - -StarterPikachuEmotionCommand_subcmd: ; fcfc7 (3f:4fc7) - ld a, [de] - inc de - push de - ld e, a - ld d, $0 - ld hl, Jumptable_fcfda - add hl, de - add hl, de - ld a, [hli] - ld h, [hl] - ld l, a - call JumpToAddress - pop de - ret - -Jumptable_fcfda: - dw LoadPikachuSpriteIntoVRAM - dw LoadFontTilePatterns - dw Pikachu_LoadCurrentMapViewUpdateSpritesAndDelay3 - dw WaitForTextScrollButtonPress - dw PikachuPewterPokecenterCheck - dw PikachuFanClubCheck - dw PikachuBillsHouseCheck - -StarterPikachuEmotionCommand_nop2: ; fcfe8 (3f:4fe8) - ret - -StarterPikachuEmotionCommand_9: ; fcfe9 (3f:4fe9) - push de - call Func_fcff2 - call UpdateSprites - pop de - ret - -Func_fcff2: ; fcff2 (3f:4ff2) - ld a, [wSpriteStateData1 + $9] - xor $4 - ld [wSpriteStateData1 + $f9], a - ret - -Func_fcffb: ; fcffb (3f:4ffb) -; Inexplicably empty. - rept 5 - nop - endr - ret - -Func_fd001:: ; fd001 (3f:5001) - ld a, e - jr asm_fd00f - -Func_fd004:: ; fd004 (3f:5004) - call Func_fd05e - jr c, asm_fd00f - call GetPikaPicAnimationScriptIndex - call Func_fcffb -asm_fd00f: ; fd00f (3f:500f) - ld [wExpressionNumber], a - ld hl, PikachuEmotionTable - call DoStarterPikachuEmotions - ret - -PikachuEmotionTable: ; fd019 (3f:4019) - dw PikachuEmotion0_fd115 - dw PikachuEmotion1_fd141 - dw PikachuEmotion2_fd116 - dw PikachuEmotion3_fd160 - dw PikachuEmotion4_fd136 - dw PikachuEmotion5_fd14d - dw PikachuEmotion6_fd153 - dw PikachuEmotion7_fd128 - dw PikachuEmotion8_fd147 - dw PikachuEmotion9_fd166 - dw PikachuEmotion10_fd11e - dw PikachuEmotion11_fd173 - dw PikachuEmotion12_fd17a - dw PikachuEmotion13_fd180 - dw PikachuEmotion14_fd189 - dw PikachuEmotion15_fd191 - dw PikachuEmotion16_fd197 - dw PikachuEmotion17_fd19d - dw PikachuEmotion18_fd1a3 - dw PikachuEmotion19_fd1a9 - dw PikachuEmotion20_fd1b1 - dw PikachuEmotion21_fd1b9 - dw PikachuEmotion22_fd1c1 - dw PikachuEmotion23_fd1c7 - dw PikachuEmotion24_fd1cf - dw PikachuEmotion25_fd1d7 - dw PikachuEmotion26_fd1df - dw PikachuEmotion27_fd1eb - dw PikachuEmotion28_fd1f1 - dw PikachuEmotion29_fd1f7 - dw PikachuEmotion30_fd1fc - dw PikachuEmotion31_fd20a - dw PikachuEmotion32_fd213 - dw PikachuEmotion33_fd05d - -PikachuEmotion33_fd05d: ; fd05d (3f:505d) - db $ff - -Func_fd05e: ; fd05e (3f:505e) - ld a, [wCurMap] - cp POKEMON_FAN_CLUB - jr nz, .notFanClub - ld hl, wPreventBlackout - bit 7, [hl] - ld a, $1d - jr z, .asm_fd0c9 - call CheckPikachuFollowingPlayer - ld a, $1e - jr nz, .asm_fd0c9 - jr .asm_fd096 -.notFanClub - ld a, [wCurMap] - cp PEWTER_POKECENTER - jr nz, .notPewterPokecenter - call CheckPikachuFollowingPlayer - ld a, $1a - jr nz, .asm_fd0c9 - jr .asm_fd096 -.notPewterPokecenter - callab Func_f24ae - ld a, e - cp $ff - jr nz, .asm_fd0c9 - jr .asm_fd096 -.asm_fd096 - call IsPlayerPikachuAsleepInParty - ld a, $b - jr c, .asm_fd0c9 - callab Func_fce73 ; same bank - ld a, $1c - jr c, .asm_fd0c9 - ld a, [wCurMap] - cp POKEMONTOWER_1 - jr c, .notInLavenderTower - cp POKEMONTOWER_7 + 1 - ld a, $16 - jr c, .asm_fd0c9 -.notInLavenderTower - ld a, [wd49c] - and a - jr z, .asm_fd0c7 - dec a - ld c, a - ld b, $0 - ld hl, Pointer_fd0cb - add hl, bc - ld a, [hl] - jr .asm_fd0c9 -.asm_fd0c7 - and a - ret -.asm_fd0c9 - scf - ret - -Pointer_fd0cb: - db $12, $15, $17, $18, $19 - -IsPlayerPikachuAsleepInParty:: ; fd0d0 (3f:50d0) - xor a - ld [wWhichPokemon], a -.loop - ld a, [wWhichPokemon] - ld c, a - ld b, $0 - ld hl, wPartySpecies - add hl, bc - ld a, [hl] - cp $ff - jr z, .done - cp PIKACHU - jr nz, .curMonNotStarterPikachu - callab IsThisPartymonStarterPikachu - jr nc, .curMonNotStarterPikachu - ld a, [wWhichPokemon] - ld hl, wPartyMon1Status - ld bc, wPartyMon2 - wPartyMon1 - call AddNTimes - ld a, [hl] - and SLP - jr z, .done - jr .curMonSleepingPikachu -.curMonNotStarterPikachu - ld a, [wWhichPokemon] - cp PARTY_LENGTH - 1 - jr z, .done - inc a - ld [wWhichPokemon], a - jr .loop -.curMonSleepingPikachu - scf - ret -.done - and a - ret - -PikachuEmotion0_fd115: ; fd115 (3f:5115) - db $ff - -PikachuEmotion2_fd116: ; fd116 (3f:5116) - pikaemotion_dummy2 - pikaemotion_emotebubble SMILE_BUBBLE - pikaemotion_pcm PikachuCry35 - pikaemotion_5 $2 - db $ff - -PikachuEmotion10_fd11e: ; fd11e (3f:511e) - pikaemotion_dummy2 - pikaemotion_subcmd PIKAEMOTION_SUBCMD_LOADEXTRAPIKASPRITES - pikaemotion_emotebubble HEART_BUBBLE - pikaemotion_pcm PikachuCry5 - pikaemotion_5 $a - db $ff - -PikachuEmotion7_fd128: ; fd128 (3f:5128) - pikaemotion_dummy2 - pikaemotion_subcmd PIKAEMOTION_SUBCMD_LOADEXTRAPIKASPRITES - pikaemotion_4 Pointer_fd224 - pikaemotion_pcm PikachuCry1 - pikaemotion_4 Pointer_fd224 - pikaemotion_5 $7 - db $ff - -PikachuEmotion4_fd136: ; fd136 (3f:5136) - pikaemotion_dummy2 - pikaemotion_subcmd PIKAEMOTION_SUBCMD_LOADEXTRAPIKASPRITES - pikaemotion_4 Pointer_fd230 - pikaemotion_pcm PikachuCry29 - pikaemotion_5 $4 - db $ff - -PikachuEmotion1_fd141: ; fd141 (3f:5141) - pikaemotion_dummy2 - pikaemotion_pcm - pikaemotion_5 $1 - db $ff - -PikachuEmotion8_fd147: ; fd147 (3f:5147) - pikaemotion_dummy2 - pikaemotion_pcm PikachuCry39 - pikaemotion_5 $8 - db $ff - -PikachuEmotion5_fd14d: ; fd14d (3f:514d) - pikaemotion_dummy2 - pikaemotion_pcm PikachuCry31 - pikaemotion_5 $5 - db $ff - -PikachuEmotion6_fd153: ; fd153 (3f:5153) - pikaemotion_dummy2 - pikaemotion_subcmd PIKAEMOTION_SUBCMD_LOADEXTRAPIKASPRITES - pikaemotion_pcm - pikaemotion_4 Pointer_fd21e - pikaemotion_emotebubble SKULL_BUBBLE - pikaemotion_5 $6 - db $ff - -PikachuEmotion3_fd160: ; fd160 (3f:5160) - pikaemotion_dummy2 - pikaemotion_pcm PikachuCry40 - pikaemotion_5 $3 - db $ff - -PikachuEmotion9_fd166: ; fd166 (3f:5166) - pikaemotion_dummy2 - pikaemotion_subcmd PIKAEMOTION_SUBCMD_LOADEXTRAPIKASPRITES - pikaemotion_pcm PikachuCry6 - pikaemotion_4 Pointer_fd218 - pikaemotion_emotebubble SKULL_BUBBLE - pikaemotion_5 $9 - db $ff - -PikachuEmotion11_fd173: ; fd173 (3f:5173) - pikaemotion_emotebubble ZZZ_BUBBLE - pikaemotion_pcm PikachuCry37 - pikaemotion_5 $b - db $ff - -PikachuEmotion12_fd17a: ; fd17a (3f:517a) - pikaemotion_dummy2 - pikaemotion_pcm - pikaemotion_5 $c - db $ff - -PikachuEmotion13_fd180: ; fd180 (3f:5180) - pikaemotion_dummy2 - pikaemotion_subcmd PIKAEMOTION_SUBCMD_LOADEXTRAPIKASPRITES - pikaemotion_4 Pointer_fd21e - pikaemotion_5 $d - db $ff - -PikachuEmotion14_fd189: ; fd189 (3f:5189) - pikaemotion_dummy2 - pikaemotion_emotebubble BOLT_BUBBLE - pikaemotion_pcm PikachuCry10 - pikaemotion_5 $e - db $ff - -PikachuEmotion15_fd191: ; fd191 (3f:5191) - pikaemotion_dummy2 - pikaemotion_pcm PikachuCry34 - pikaemotion_5 $f - db $ff - -PikachuEmotion16_fd197: ; fd197 (3f:5197) - pikaemotion_dummy2 - pikaemotion_pcm PikachuCry33 - pikaemotion_5 $10 - db $ff - -PikachuEmotion17_fd19d: ; fd19d (3f:519d) - pikaemotion_dummy2 - pikaemotion_pcm PikachuCry13 - pikaemotion_5 $11 - db $ff - -PikachuEmotion18_fd1a3: ; fd1a3 (3f:51a3) - pikaemotion_dummy2 - pikaemotion_pcm - pikaemotion_5 $12 - db $ff - -PikachuEmotion19_fd1a9: ; fd1a9 (3f:51a9) - pikaemotion_dummy2 - pikaemotion_emotebubble HEART_BUBBLE - pikaemotion_pcm PikachuCry33 - pikaemotion_5 $13 - db $ff - -PikachuEmotion20_fd1b1: ; fd1b1 (3f:51b1) - pikaemotion_dummy2 - pikaemotion_emotebubble HEART_BUBBLE - pikaemotion_pcm PikachuCry5 - pikaemotion_5 $14 - db $ff - -PikachuEmotion21_fd1b9: ; fd1b9 (3f:51b9) - pikaemotion_dummy2 - pikaemotion_emotebubble FISH_BUBBLE - pikaemotion_pcm - pikaemotion_5 $15 - db $ff - -PikachuEmotion22_fd1c1: ; fd1c1 (3f:51c1) - pikaemotion_dummy2 - pikaemotion_pcm PikachuCry4 - pikaemotion_5 $16 - db $ff - -PikachuEmotion23_fd1c7: ; fd1c7 (3f:51c7) - pikaemotion_dummy2 - pikaemotion_pcm PikachuCry19 - pikaemotion_5 $17 - pikaemotion_subcmd PIKAEMOTION_SUBCMD_SHOWMAPVIEW - db $ff - -PikachuEmotion24_fd1cf: ; fd1cf (3f:51cf) - pikaemotion_dummy2 - pikaemotion_emotebubble EXCLAMATION_BUBBLE - pikaemotion_pcm - pikaemotion_5 $18 - db $ff - -PikachuEmotion25_fd1d7: ; fd1d7 (3f:51d7) - pikaemotion_dummy2 - pikaemotion_emotebubble BOLT_BUBBLE - pikaemotion_pcm PikachuCry35 - pikaemotion_5 $19 - db $ff - -PikachuEmotion26_fd1df: ; fd1df (3f:51df) - pikaemotion_dummy2 - pikaemotion_emotebubble ZZZ_BUBBLE - pikaemotion_pcm PikachuCry37 - pikaemotion_5 $1a - pikaemotion_subcmd PIKAEMOTION_SUBCMD_SHOWMAPVIEW - pikaemotion_subcmd PIKAEMOTION_SUBCMD_CHECKPEWTERCENTER - db $ff - -PikachuEmotion27_fd1eb: ; fd1eb (3f:51eb) - pikaemotion_dummy2 - pikaemotion_pcm PikachuCry9 - pikaemotion_5 $1b - db $ff - -PikachuEmotion28_fd1f1: ; fd1f1 (3f:51f1) - pikaemotion_dummy2 - pikaemotion_pcm PikachuCry15 - pikaemotion_5 $1c - db $ff - -PikachuEmotion29_fd1f7: ; fd1f7 (3f:51f7) - pikaemotion_pcm PikachuCry5 - pikaemotion_5 $a - db $ff - -PikachuEmotion30_fd1fc: ; fd1fc (3f:51fc) - pikaemotion_9 - pikaemotion_emotebubble HEART_BUBBLE - pikaemotion_pcm PikachuCry5 - pikaemotion_5 $14 - pikaemotion_subcmd PIKAEMOTION_SUBCMD_SHOWMAPVIEW - pikaemotion_subcmd PIKAEMOTION_SUBCMD_LOADFONT - pikaemotion_subcmd PIKAEMOTION_SUBCMD_CHECKLAVENDERTOWER - db $ff - -PikachuEmotion31_fd20a: ; fd20a (3f:520a) - pikaemotion_pcm PikachuCry19 - pikaemotion_5 $17 - pikaemotion_subcmd PIKAEMOTION_SUBCMD_SHOWMAPVIEW - pikaemotion_subcmd PIKAEMOTION_SUBCMD_CHECKBILLSHOUSE - db $ff - -PikachuEmotion32_fd213: ; fd213 (3f:5213) - pikaemotion_pcm PikachuCry26 - pikaemotion_5 $17 - db $ff - -Pointer_fd218: ; fd218 (3f:5218) - - db $00 - db $39, $01 - db $3e, $1e - db $3f - -Pointer_fd21e: ; fd21e (3f:521e) - db $00 - db $39, $00 - db $3e, $1e - db $3f - -Pointer_fd224: ; fd224 (3f:5224) - db $00 - db $3c, $07, $2f - db $3c, $07, $2f - db $3f - -Pointer_fd22c: ; fd22c (3f:522c) - db $3b, $1f, $03 - db $3f - -Pointer_fd230: ; fd230 (3f:5230) - db $00 - db $3c, $0f, $1f - db $3c, $0f, $1f - db $3f - -Pointer_fd238: ; fd238 (3f:5238) - db $00 - db $05, $07 - db $39, $00 - db $05, $07 - db $06, $07 - db $39, $00 - db $06, $07 - db $08, $07 - db $39, $00 - db $08, $07 - db $07, $07 - db $39, $00 - db $07, $07 - db $3f - -Func_fd252: ; fd252 (3f:5252) - ld a, $40 - ld [h_0xFFFC], a - call LoadPikachuSpriteIntoVRAM - call Func_fd266 - and a - jr z, .asm_fd262 - call Func_159b -.asm_fd262 - xor a - ld [h_0xFFFC], a - ret - -Func_fd266: - ld a, [wSpriteStateData2 + 15 * 16 + 4] - ld e, a - ld a, [wSpriteStateData2 + 15 * 16 + 5] - ld d, a - ld a, [wYCoord] - add 4 - cp e - jr z, .asm_fd280 - jr nc, .asm_fd27e - ld hl, Data_fd294 - ld a, 1 - ret - -.asm_fd27e - xor a - ret - -.asm_fd280 - ld a, [wXCoord] - add 4 - cp d - jr c, .asm_fd28e - ld hl, Data_fd299 - ld a, 2 - ret - -.asm_fd28e - ld hl, Data_fd29d - ld a, 3 - ret - -Data_fd294: - db $00 - db $36 - db $2b - db $34 - db $3f - -Data_fd299: - db $00 - db $36 - db $34 - db $3f - -Data_fd29d: - db $00 - db $36 - db $33 - db $3f - -Func_fd2a1:: ; fd2a1 (3f:52a1) - ld a, b - ld [wd44a], a - ld a, l - ld [wd44b], a - ld a, h - ld [wd44b + 1], a - call PikachuSwapSpriteStateData -.loop - call Func_fd2f5 - jr nc, .done - call Func_fd329 - jr .loop - -.done - call PikachuSwapSpriteStateData - call DelayFrame - ret - -PikachuSwapSpriteStateData: - ld a, [wUpdateSpritesEnabled] - push af - ld a, $ff - ld [wUpdateSpritesEnabled], a - push hl - push de - push bc - - ld hl, wSpriteStateData1 - ld de, wSpriteStateData1 + $f0 - ld c, $10 - call SwapBytes3f - - ld hl, wSpriteStateData2 - ld de, wSpriteStateData2 + $f0 - ld c, $10 - call SwapBytes3f - - pop bc - pop de - pop hl - pop af - ld [wUpdateSpritesEnabled], a - ret - -SwapBytes3f: -.loop - ld b, [hl] - ld a, [de] - ld [hli], a - ld a, b - ld [de], a - inc de - dec c - jr nz, .loop - ret - -Func_fd2f5: - call Func_157c - cp $3f - ret z - ld c, a - ld b, 0 - ld hl, Data_fd3b0 - add hl, bc - add hl, bc - add hl, bc - add hl, bc - ld a, [hli] - ld [wPikaPicAnimPointer + 1], a - ld a, [hli] - cp $80 - jr nz, .asm_fd311 - call Func_157c -.asm_fd311 - ld [wPikaPicAnimPointer], a - ld a, [hli] - ld [wPikaPicAnimCurGraphicID], a - ld a, [hli] - cp $80 - jr nz, .asm_fd320 - call Func_157c -.asm_fd320 - ld [wPikaPicAnimPointerSetupFinished], a - xor a - ld [wPikaPicAnimTimer], a - scf - ret - -Func_fd329: - xor a - ld [$d44c], a - ld [wd457], a - ld [wd458], a - ld a, [wSpriteStateData2 + 7] - push af -.asm_fd337 - ld bc, wSpriteStateData1 - ld a, [wPikaPicAnimPointer + 1] - ld hl, Jumptable_fd4ac - call Func_fd365 - ld a, [wPikaPicAnimCurGraphicID] - ld hl, Jumptable_fd65c - call Func_fd365 - call Func_fd36e - call Func_fd39d - call DelayFrame - call DelayFrame - ld hl, $d44c - bit 7, [hl] - jr z, .asm_fd337 - pop af - ld [wSpriteStateData2 + 7], a - scf - ret - -Func_fd365: - ld e, a - ld d, 0 - add hl, de - add hl, de - ld a, [hli] - ld h, [hl] - ld l, a - jp [hl] - -Func_fd36e: - ld hl, 2 - add hl, bc - ld a, [wPikaPicAnimTimer + 1] - ld [hl], a - ld a, [wPikaSpriteY] - ld d, a - ld a, [wd456] - add d - ld hl, 4 - add hl, bc - ld [hl], a - ld a, [wPikaPicAnimDelay] - ld d, a - ld a, [wPikaPicTextboxStartY] - add d - ld hl, 6 - add hl, bc - ld [hl], a - ld hl, $d44c - bit 6, [hl] - ret z - ld hl, wSpriteStateData2 + 7 - wSpriteStateData1 - add hl, bc - ld [hl], 0 - ret - -Func_fd39d: - ld hl, $d44c - bit 6, [hl] - res 6, [hl] - ld hl, wd736 - res 6, [hl] - ret z - set 6, [hl] - call Func_fd7f3 - ret - -Data_fd3b0: - db $01, $00, $00, $00 ; $00 - db $03, $80, $01, $00 ; $01 - db $04, $80, $01, $00 ; $02 - db $05, $80, $01, $00 ; $03 - db $06, $80, $01, $00 ; $04 - db $07, $80, $01, $00 ; $05 - db $08, $80, $01, $00 ; $06 - db $09, $80, $01, $00 ; $07 - db $0a, $80, $01, $00 ; $08 - db $03, $80, $06, $00 ; $09 - db $04, $80, $06, $00 ; $0a - db $05, $80, $06, $00 ; $0b - db $06, $80, $06, $00 ; $0c - db $07, $80, $06, $00 ; $0d - db $08, $80, $06, $00 ; $0e - db $09, $80, $06, $00 ; $0f - db $0a, $80, $06, $00 ; $10 - db $03, $80, $03, $80 ; $11 - db $04, $80, $03, $80 ; $12 - db $05, $80, $03, $80 ; $13 - db $06, $80, $03, $80 ; $14 - db $07, $80, $03, $80 ; $15 - db $08, $80, $03, $80 ; $16 - db $09, $80, $03, $80 ; $17 - db $0a, $80, $03, $80 ; $18 - db $03, $80, $07, $80 ; $19 - db $04, $80, $07, $80 ; $1a - db $05, $80, $07, $80 ; $1b - db $06, $80, $07, $80 ; $1c - db $0b, $27, $02, $00 ; $1d step down - db $0c, $27, $02, $00 ; $1e step up - db $0d, $27, $02, $00 ; $1f step left - db $0e, $27, $02, $00 ; $20 step right - db $0f, $27, $02, $00 ; $21 - db $10, $27, $02, $00 ; $22 - db $11, $27, $02, $00 ; $23 - db $12, $27, $02, $00 ; $24 - db $0b, $0f, $02, $00 ; $25 - db $0c, $0f, $02, $00 ; $26 - db $0d, $0f, $02, $00 ; $27 - db $0e, $0f, $02, $00 ; $28 - db $0f, $0f, $02, $00 ; $29 - db $10, $0f, $02, $00 ; $2a - db $11, $0f, $02, $00 ; $2b - db $12, $0f, $02, $00 ; $2c - db $0b, $0f, $08, $17 ; $2d - db $0c, $0f, $08, $17 ; $2e - db $0d, $0f, $08, $17 ; $2f - db $0e, $0f, $08, $17 ; $30 - db $0f, $0f, $08, $17 ; $31 - db $10, $0f, $08, $17 ; $32 - db $11, $0f, $08, $17 ; $33 - db $12, $0f, $08, $17 ; $34 - db $13, $0f, $06, $00 ; $35 look down - db $14, $0f, $06, $00 ; $36 look up - db $15, $0f, $06, $00 ; $37 look left - db $16, $0f, $06, $00 ; $38 look right - db $02, $80, $04, $00 ; $39 - db $02, $80, $05, $00 ; $3a - db $02, $80, $03, $80 ; $3b - db $02, $80, $07, $80 ; $3c - db $02, $80, $09, $80 ; $3d - db $02, $80, $06, $00 ; $3e - -Jumptable_fd4ac: - dw Func_fd4e5 - dw Func_fd4e9 - dw Func_fd504 - dw Func_fd50c - dw Func_fd511 - dw Func_fd518 - dw Func_fd52c - dw Func_fd540 - dw Func_fd553 - dw Func_fd566 - dw Func_fd579 - dw Func_fd5b1 - dw Func_fd5b5 - dw Func_fd5b9 - dw Func_fd5bd - dw Func_fd5c1 - dw Func_fd5c5 - dw Func_fd5c9 - dw Func_fd5cd - dw Func_fd5ea - dw Func_fd5ee - dw Func_fd5f2 - dw Func_fd5f6 - dw Func_fd4e5 - -Func_fd4dc: - ld a, [$d44c] - set 7, a - ld [$d44c], a - ret - -Func_fd4e5: - call Func_fd4dc - ret - -Func_fd4e9: - ld hl, 4 - add hl, bc - ld a, [hl] - ld [wPikaSpriteY], a - ld hl, 6 - add hl, bc - ld a, [hl] - ld [wPikaPicAnimDelay], a - xor a - ld [wd456], a - ld [wPikaPicTextboxStartY], a - call Func_fd4dc - ret - -Func_fd504: - call Func_fd775 - ret nz - call Func_fd4dc - ret - -Func_fd50c: - call GetObjectFacing - jr asm_fd58c - -Func_fd511: - call GetObjectFacing - xor %100 - jr asm_fd58c - -Func_fd518: - call GetObjectFacing - ld hl, Data_fd523 - call Func_fd5a0 - jr asm_fd58c - -Data_fd523: - db SPRITE_FACING_DOWN, SPRITE_FACING_RIGHT - db SPRITE_FACING_UP, SPRITE_FACING_LEFT - db SPRITE_FACING_LEFT, SPRITE_FACING_DOWN - db SPRITE_FACING_RIGHT, SPRITE_FACING_UP - db $ff - -Func_fd52c: - call GetObjectFacing - ld hl, Data_fd537 - call Func_fd5a0 - jr asm_fd58c - -Data_fd537: - db SPRITE_FACING_DOWN, SPRITE_FACING_LEFT - db SPRITE_FACING_UP, SPRITE_FACING_RIGHT - db SPRITE_FACING_LEFT, SPRITE_FACING_UP - db SPRITE_FACING_RIGHT, SPRITE_FACING_DOWN - db $ff - -Func_fd540: - call GetObjectFacing - ld hl, Data_fd54b - call Func_fd5a0 - jr asm_fd58c - -Data_fd54b: - db SPRITE_FACING_DOWN, SPRITE_FACING_UP | $10 - db SPRITE_FACING_UP, SPRITE_FACING_LEFT | $10 - db SPRITE_FACING_LEFT, SPRITE_FACING_DOWN | $10 - db SPRITE_FACING_RIGHT, SPRITE_FACING_RIGHT | $10 - -Func_fd553: - call GetObjectFacing - ld hl, Data_fd55e - call Func_fd5a0 - jr asm_fd58c - -Data_fd55e: - db SPRITE_FACING_DOWN, SPRITE_FACING_DOWN | $10 - db SPRITE_FACING_UP, SPRITE_FACING_RIGHT | $10 - db SPRITE_FACING_LEFT, SPRITE_FACING_LEFT | $10 - db SPRITE_FACING_RIGHT, SPRITE_FACING_UP | $10 - -Func_fd566: - call GetObjectFacing - ld hl, Data_fd571 - call Func_fd5a0 - jr asm_fd58c - -Data_fd571: - db SPRITE_FACING_DOWN, SPRITE_FACING_RIGHT | $10 - db SPRITE_FACING_UP, SPRITE_FACING_DOWN | $10 - db SPRITE_FACING_LEFT, SPRITE_FACING_UP | $10 - db SPRITE_FACING_RIGHT, SPRITE_FACING_LEFT | $10 - -Func_fd579: - call GetObjectFacing - ld hl, Data_fd584 - call Func_fd5a0 - jr asm_fd58c - -Data_fd584: - db SPRITE_FACING_DOWN, SPRITE_FACING_LEFT | $10 - db SPRITE_FACING_UP, SPRITE_FACING_UP | $10 - db SPRITE_FACING_LEFT, SPRITE_FACING_RIGHT | $10 - db SPRITE_FACING_RIGHT, SPRITE_FACING_DOWN | $10 - -asm_fd58c - rrca - rrca - and $7 - ld e, a - call Func_fd784 - ld d, a - call UpdatePikachuPosition - call Func_fd775 - ret nz - call Func_fd4dc - ret - -Func_fd5a0: - push de - ld d, a -.asm_fd5a2 - ld a, [hli] - cp d - jr z, .asm_fd5ad - inc hl - cp $ff - jr nz, .asm_fd5a2 - pop de - ret - -.asm_fd5ad - ld a, [hl] - pop de - scf - ret - -Func_fd5b1: - ld a, SPRITE_FACING_DOWN >> 2 - jr asm_fd5d1 - -Func_fd5b5: - ld a, SPRITE_FACING_UP >> 2 - jr asm_fd5d1 - -Func_fd5b9: - ld a, SPRITE_FACING_LEFT >> 2 - jr asm_fd5d1 - -Func_fd5bd: - ld a, SPRITE_FACING_RIGHT >> 2 - jr asm_fd5d1 - -Func_fd5c1: - ld e, 4 - jr asm_fd5d5 - -Func_fd5c5: - ld e, 5 - jr asm_fd5d5 - -Func_fd5c9: - ld e, 6 - jr asm_fd5d5 - -Func_fd5cd: - ld e, 7 - jr asm_fd5d5 - -asm_fd5d1 - ld e, a - call SetObjectFacing -asm_fd5d5 - call Func_fd784 - ld d, a - push de - call UpdatePikachuPosition - pop de - call Func_fd775 - ret nz - ld a, e - call Func_fd7cb - call Func_fd4dc - ret - -Func_fd5ea: - ld a, SPRITE_FACING_DOWN >> 2 - jr asm_fd5fa - -Func_fd5ee: - ld a, SPRITE_FACING_UP >> 2 - jr asm_fd5fa - -Func_fd5f2: - ld a, SPRITE_FACING_LEFT >> 2 - jr asm_fd5fa - -Func_fd5f6: - ld a, SPRITE_FACING_RIGHT >> 2 - jr asm_fd5fa - -asm_fd5fa - call SetObjectFacing - call Func_fd4dc - ret - -UpdatePikachuPosition: - push de - ld d, 0 - ld hl, Jumptable_fd60f - add hl, de - add hl, de - ld a, [hli] - ld h, [hl] - ld l, a - pop de - ld a, d - jp [hl] - -Jumptable_fd60f: - dw MovePikachuSpriteDown - dw MovePikachuSpriteUp - dw MovePikachuSpriteLeft - dw MovePikachuSpriteRight - dw MovePikachuSpriteDownLeft - dw MovePikachuSpriteDownRight - dw MovePikachuSpriteUpLeft - dw MovePikachuSpriteUpRight - -MovePikachuSpriteDown: - ld d, 0 - ld e, a - jr asm_fd64d - -MovePikachuSpriteUp: - ld d, 0 - cpl - inc a - ld e, a - jr asm_fd64d - -MovePikachuSpriteLeft: - cpl - inc a - ld d, a - ld e, 0 - jr asm_fd64d - -MovePikachuSpriteRight: - ld d, a - ld e, 0 - jr asm_fd64d - -MovePikachuSpriteDownLeft: - ld e, a - cpl - inc a - ld d, a - jr asm_fd64d - -MovePikachuSpriteDownRight: - ld e, a - ld d, a - jr asm_fd64d - -MovePikachuSpriteUpLeft: - cpl - inc a - ld e, a - ld d, a - jr asm_fd64d - -MovePikachuSpriteUpRight: - ld d, a - cpl - inc a - ld e, a - jr asm_fd64d - -asm_fd64d - ld a, [wPikaPicAnimDelay] - add d - ld [wPikaPicAnimDelay], a - ld a, [wPikaSpriteY] - add e - ld [wPikaSpriteY], a - ret - -Jumptable_fd65c: - dw Func_fd678 - dw Func_fd6a3 - dw Func_fd698 - dw Func_fd6f4 - dw Func_fd6ff - dw Func_fd718 - dw Func_fd68c - dw Func_fd6c6 - dw Func_fd6c0 - dw Func_fd6e2 - dw Func_fd68b - -Func_fd672: - ld hl, $d44c - set 6, [hl] - ret - -Func_fd678: - ld hl, 7 - add hl, bc - xor a - ld [hli], a - ld [hl], a - call Func_fd74a - ld d, a - call GetObjectFacing - or d - ld [wPikaPicAnimTimer + 1], a - ret - -Func_fd68b: - ret - -Func_fd68c: - call Func_fd74a - ld d, a - call Func_fd755 - or d - ld [wPikaPicAnimTimer + 1], a - ret - -Func_fd698: - call Func_fd74a - ld d, a - call GetObjectFacing - or d - ld d, a - jr asm_fd6ac - -Func_fd6a3: - call Func_fd74a - ld d, a - call Func_fd755 - or d - ld d, a -asm_fd6ac - ld hl, 8 - add hl, bc - call Func_fd78e - jr nz, .asm_fd6b6 - inc [hl] -.asm_fd6b6 - ld a, [hl] - rrca - rrca - and 3 - or d - ld [wPikaPicAnimTimer + 1], a - ret - -Func_fd6c0: - call GetObjectFacing - ld d, a - jr asm_fd6ca - -Func_fd6c6: - call Func_fd755 - ld d, a -asm_fd6ca - call Func_fd74a - or d - ld d, a - call Func_fd736 - or d - ld [wPikaPicAnimTimer + 1], a - call Func_fd79d - ld [wd456], a - and a - ret z - call Func_fd672 - ret - -Func_fd6e2: - call GetObjectFacing - ld d, a - call Func_fd74a - or d - ld [wPikaPicAnimTimer + 1], a - call Func_fd79d - ld [wd456], a - ret - -Func_fd6f4: - ld a, [wPikaPicAnimPointerSetupFinished] - and $40 - cp $40 - jr z, Func_fd6ff - jr Func_fd718 - -Func_fd6ff: - call Func_fd755 - ld d, a - call Func_fd78e - jr nz, .asm_fd710 - ld hl, Data_fd731 -.asm_fd70b - ld a, [hli] - cp d - jr nz, .asm_fd70b - ld d, [hl] -.asm_fd710 - call Func_fd74a - or d - ld [wPikaPicAnimTimer + 1], a - ret - -Func_fd718: - call Func_fd755 - ld d, a - call Func_fd78e - jr nz, .asm_fd529 - ld hl, Data_fd731End -.asm_fd524 - ld a, [hld] - cp d - jr nz, .asm_fd524 - ld d, [hl] -.asm_fd529 - call Func_fd74a - or d - ld [wPikaPicAnimTimer + 1], a - ret - -Data_fd731: - db SPRITE_FACING_DOWN - db SPRITE_FACING_LEFT - db SPRITE_FACING_UP - db SPRITE_FACING_RIGHT - db SPRITE_FACING_DOWN -Data_fd731End: - -Func_fd736: - push hl - ld hl, 7 - add hl, bc - ld a, [hl] - inc a - and $3 - ld [hli], a - jr nz, .asm_fd747 - ld a, [hl] - inc a - and $3 - ld [hl], a -.asm_fd747 - ld a, [hl] - pop hl - ret - -Func_fd74a: - push hl - ld hl, wSpriteStateData2 - wSpriteStateData1 + 14 - add hl, bc - ld a, [hl] - dec a - swap a - pop hl - ret - -Func_fd755: - push hl - ld hl, 2 - add hl, bc - ld a, [hl] - and $c - pop hl - ret - -GetObjectFacing: - push hl - ld hl, 9 - add hl, bc - ld a, [hl] - and $c - pop hl - ret - -SetObjectFacing: - push hl - ld hl, 9 - add hl, bc - add a - add a - and $c - ld [hl], a - pop hl - ret - -Func_fd775: - ld hl, wd457 - inc [hl] - ld a, [wPikaPicAnimPointer] - and $1f - inc a - cp [hl] - ret nz - ld [hl], 0 - ret - -Func_fd784: - ld a, [wPikaPicAnimPointer] - swap a - rrca - and $3 - inc a - ret - -Func_fd78e: - ld hl, wd458 - inc [hl] - ld a, [wPikaPicAnimPointerSetupFinished] - and $f - inc a - cp [hl] - ret nz - ld [hl], 0 - ret - -Func_fd79d: - call Func_fd7b2 - ld a, [wd458] - add e - ld [wd458], a - add $20 - ld e, a - push hl - push bc - call Sine_e - pop bc - pop hl - ret - -Func_fd7b2: - ld a, [wPikaPicAnimPointerSetupFinished] - and $f - inc a - ld d, a - ld a, [wPikaPicAnimPointerSetupFinished] - swap a - and $7 - ld e, a - ld a, 1 - jr z, .asm_fd7c9 -.asm_fd7c5 - add a - dec e - jr nz, .asm_fd7c5 -.asm_fd7c9 - ld e, a - ret - -Func_fd7cb: - push bc - ld c, a - ld b, 0 - ld hl, Data_fd7e3 - add hl, bc - add hl, bc - ld d, [hl] - inc hl - ld e, [hl] - pop bc - ld hl, wSpriteStateData2 - wSpriteStateData1 + 4 - add hl, bc - ld a, [hl] - add e - ld [hli], a - ld a, [hl] - add d - ld [hl], a - ret - -Data_fd7e3: - db 0, 1 - db 0, -1 - db -1, 0 - db 1, 0 - db -1, 1 - db 1, 1 - db -1, -1 - db 1, -1 - -Func_fd7f3: - push bc - push de - push hl - - ld bc, wOAMBuffer + 4 * 36 - ld a, [wPikaSpriteY] - ld e, a - ld a, [wPikaPicAnimDelay] - ld d, a - ld hl, Data_fd80b - call Func_fd814 - - pop hl - pop de - pop bc - ret - -Data_fd80b: - db $02 - db $0c, $00, $ff, 0 - db $0c, $08, $ff, 1 << OAM_X_FLIP - -Func_fd814: - ld a, e - add $10 - ld e, a - ld a, d - add $8 - ld d, a - ld a, [hli] -.asm_fd81d - push af - ld a, [hli] - add e - ld [bc], a - inc bc - ld a, [hli] - add d - ld [bc], a - inc bc - ld a, [hli] - ld [bc], a - inc bc - ld a, [hli] - ld [bc], a - inc bc - pop af - dec a - jr nz, .asm_fd81d - ret - -LoadPikachuShadowIntoVRAM: - ld hl, vNPCSprites2 + $7f * $10 - ld de, LedgeHoppingShadowGFX_3F - lb bc, BANK(LedgeHoppingShadowGFX_3F), (LedgeHoppingShadowGFX_3FEnd - LedgeHoppingShadowGFX_3F) / 8 - jp CopyVideoDataDoubleAlternate - -LedgeHoppingShadowGFX_3F: -INCBIN "gfx/ledge_hopping_shadow.1bpp" -LedgeHoppingShadowGFX_3FEnd: - -LoadPikachuBallIconIntoVRAM: - ld hl, vNPCSprites2 + $7e * $10 - ld de, GFX_fd86b - lb bc, BANK(GFX_fd86b), 1 - jp CopyVideoDataDoubleAlternate - -Func_fd851: - ld hl, vNPCSprites + $c * $10 - ld a, 3 -.asm_fd856 - push af - push hl - ld de, GFX_fd86b - lb bc, BANK(GFX_fd86b), 4 - call CopyVideoDataAlternate - pop hl - ld de, 4 * $10 - add hl, de - pop af - dec a - jr nz, .asm_fd856 - ret - -GFX_fd86b: -INCBIN "gfx/unknown_fd86b.2bpp" - -LoadPikachuSpriteIntoVRAM: ; fd8ab (3f:58ab) - ld de, PikachuSprite - lb bc, BANK(PikachuSprite), (SandshrewSprite - PikachuSprite) / 32 - ld hl, vNPCSprites + $c * $10 - push bc - call CopyVideoDataAlternate - ld de, PikachuSprite + $c * $10 - ld hl, vNPCSprites2 + $c * $10 - ld a, [h_0xFFFC] - and a - jr z, .load - ld de, PikachuSprite + $c * $10 - ld hl, vNPCSprites2 + $4c * $10 -.load - pop bc - call CopyVideoDataAlternate - call LoadPikachuShadowIntoVRAM - call LoadPikachuBallIconIntoVRAM - ret - -PikachuPewterPokecenterCheck: ; fd8d4 (3f:58d4) - ld a, [wCurMap] - cp PEWTER_POKECENTER - ret nz - call EnablePikachuFollowingPlayer - call Func_fcff2 - ret - -PikachuFanClubCheck: ; fd8e1 (3f:58e1) - ld a, [wCurMap] - cp POKEMON_FAN_CLUB - ret nz - call EnablePikachuFollowingPlayer - call Func_fcff2 - ret - -PikachuBillsHouseCheck: ; fd8ee (3f:58ee) - ld a, [wCurMap] - cp BILLS_HOUSE - ret nz - call EnablePikachuFollowingPlayer - ret - -Pikachu_LoadCurrentMapViewUpdateSpritesAndDelay3: ; fd8f8 (3f:58f8) - call LoadCurrentMapView - call UpdateSprites - call Delay3 - ret - -Cosine_e: ; cosine? - ld a, e - add $10 - jr asm_fd908 - -Sine_e: ; sine? - ld a, e -asm_fd908 - and $3f - cp $20 - jr nc, .asm_fd913 - call GetSine - ld a, h - ret - -.asm_fd913 - and $1f - call GetSine - ld a, h - cpl - inc a - ret - -GetSine: - ld e, a - ld a, d - ld d, 0 - ld hl, SineWave_3f - add hl, de - add hl, de - ld e, [hl] - inc hl - ld d, [hl] - ld hl, 0 -.asm_fd92b - srl a - jr nc, .asm_fd930 - add hl, de -.asm_fd930 - sla e - rl d - and a - jr nz, .asm_fd92b - ret - -SineWave_3f: - sine_wave $100 - GetPikaPicAnimationScriptIndex: ; fd978 (3f:5978) ld hl, PikachuMoodLookupTable ld a, [wPikachuMood] @@ -1757,7 +46,7 @@ PikaPicAnimationScriptPointerLookupTable: db $fa, $11, $11, $10, $0a, $0a db $ff, $11, $11, $13, $14, $14 -StarterPikachuEmotionCommand_5: ; fd9d0 (3f:59d0) +StarterPikachuEmotionCommand_pikapic: ; fd9d0 (3f:59d0) ld a, [H_AUTOBGTRANSFERENABLED] push af xor a diff --git a/engine/surfing_minigame.asm b/engine/surfing_minigame.asm index 6a37eb10..c1533583 100755 --- a/engine/surfing_minigame.asm +++ b/engine/surfing_minigame.asm @@ -85,7 +85,7 @@ Func_f80a8: ret Func_f80ac: - ld hl, wPreventBlackout + ld hl, wd492 bit 1, [hl] ret z ld a, [hJoyPressed] diff --git a/home/overworld.asm b/home/overworld.asm index 18829022..de062f46 100644 --- a/home/overworld.asm +++ b/home/overworld.asm @@ -70,6 +70,7 @@ OverworldLoopLessDelay:: ; 0245 (0:0245) jr z, .notSimulating ld a, [hJoyHeld] jr .checkIfStartIsPressed + .notSimulating ld a, [hJoyPressed] .checkIfStartIsPressed @@ -79,6 +80,7 @@ OverworldLoopLessDelay:: ; 0245 (0:0245) xor a ld [hSpriteIndexOrTextID], a ; start menu text ID jp .displayDialogue + .startButtonNotPressed bit 0, a ; A button jp z, .checkIfDownButtonIsPressed @@ -116,6 +118,7 @@ OverworldLoopLessDelay:: ; 0245 (0:0245) xor a ld [wLinkTimeoutCounter], a jp EnterMap + ; predef LoadSAV ; ld a, [wCurMap] ; ld [wDestinationMap], a @@ -129,6 +132,7 @@ OverworldLoopLessDelay:: ; 0245 (0:0245) and a jp nz, .newBattle jp OverworldLoop + .noDirectionButtonsPressed call UpdateSprites ; 231c ld hl, wFlags_0xcd60 @@ -146,6 +150,7 @@ OverworldLoopLessDelay:: ; 0245 (0:0245) ld [wPlayerMovingDirection], a ; zero the direction .overworldloop jp OverworldLoop + .checkIfDownButtonIsPressed ld a, [hJoyHeld] ; current joypad state bit 7, a ; down button @@ -154,6 +159,7 @@ OverworldLoopLessDelay:: ; 0245 (0:0245) ld [wSpriteStateData1 + 3], a ; delta Y ld a, PLAYER_DIR_DOWN jr .handleDirectionButtonPress + .checkIfUpButtonIsPressed bit 6, a ; up button jr z, .checkIfLeftButtonIsPressed @@ -161,6 +167,7 @@ OverworldLoopLessDelay:: ; 0245 (0:0245) ld [wSpriteStateData1 + 3], a ; delta Y ld a, PLAYER_DIR_UP jr .handleDirectionButtonPress + .checkIfLeftButtonIsPressed bit 5, a ; left button jr z, .checkIfRightButtonIsPressed @@ -168,6 +175,7 @@ OverworldLoopLessDelay:: ; 0245 (0:0245) ld [wSpriteStateData1 + 5], a ; delta X ld a, PLAYER_DIR_LEFT jr .handleDirectionButtonPress + .checkIfRightButtonIsPressed bit 4, a ; right button jr z, .noDirectionButtonsPressed @@ -199,6 +207,7 @@ OverworldLoopLessDelay:: ; 0245 (0:0245) call NewBattle jp c, .battleOccurred jp OverworldLoop + .noDirectionChange ld a, [wPlayerDirection] ; current direction ld [wPlayerMovingDirection], a ; save direction @@ -221,6 +230,7 @@ OverworldLoopLessDelay:: ; 0245 (0:0245) pop hl jp c, CheckWarpsCollision jp OverworldLoop + .surfing call CollisionCheckOnWater jp c, OverworldLoop @@ -229,6 +239,7 @@ OverworldLoopLessDelay:: ; 0245 (0:0245) ld [wWalkCounter], a callab Func_fcc08 jr .moveAhead2 + .moveAhead call IsSpinning call UpdateSprites ; move sprites @@ -402,6 +413,7 @@ CheckWarpsNoCollisionLoop:: ; 04d5 (0:04d5) and D_DOWN | D_UP | D_LEFT | D_RIGHT jr z, CheckWarpsNoCollisionRetry2 ; if directional buttons aren't being pressed, do not pass through the warp jr WarpFound1 + CheckWarpsNoCollisionRetry1:: ; 050f (0:050f) inc hl @@ -413,6 +425,7 @@ ContinueCheckWarpsNoCollisionLoop:: ; 0512 (0:0512) dec c ; decrement number of warps jp nz, CheckWarpsNoCollisionLoop jp CheckMapConnections + ; check if the player has stepped onto a warp after having collided CheckWarpsCollision:: ; 051a (0:051a) @@ -435,6 +448,7 @@ CheckWarpsCollision:: ; 051a (0:051a) ld a, [hl] ld [hWarpDestinationMap], a jr WarpFound2 + .retry1 inc hl .retry2 @@ -471,10 +485,12 @@ WarpFound2:: ; 054a (0:054a) ld [wMapPalOffset], a call GBFadeOutToBlack .notRockTunnel - callab Func_fc5fa ; 3f:45fa + callab CalculatePikachuSpawnState1 ; 3f:45fa call PlayMapChangeSound jr .done -; for maps that can have the 0xFF destination map, which means to return to the outside map; not all these maps are necessarily indoors, though + +; for maps that can have the 0xFF destination map, which means to return to the outside map +; not all these maps are necessarily indoors, though .indoorMaps ld a, [hWarpDestinationMap] ; destination map cp $ff @@ -490,16 +506,18 @@ WarpFound2:: ; 054a (0:054a) ld hl, wd732 set 3, [hl] jr .skipMapChangeSound + .notWarpPad call PlayMapChangeSound .skipMapChangeSound ld hl, wd736 res 0, [hl] res 1, [hl] - callab Func_fc65b ; 3f:465b + callab CalculatePikachuSpawnState2 ; 3f:465b jr .done + .goBackOutside - callab Func_fc69a ; 3f:469a + callab CalculatePikachuSpawnState3 ; 3f:469a ld a, [wLastMap] ld [wCurMap], a call PlayMapChangeSound @@ -548,6 +566,7 @@ CheckMapConnections:: ; 05db (0:05db) ld a, h ld [wCurrentTileBlockMapViewPointer + 1], a jp .loadNewMap + .checkEastMap ld b, a ld a, [wCurrentMapWidth2] ; map width @@ -584,6 +603,7 @@ CheckMapConnections:: ; 05db (0:05db) ld a, h ld [wCurrentTileBlockMapViewPointer + 1], a jp .loadNewMap + .checkNorthMap ld a, [wYCoord] cp $ff @@ -610,6 +630,7 @@ CheckMapConnections:: ; 05db (0:05db) ld a, h ld [wCurrentTileBlockMapViewPointer + 1], a jp .loadNewMap + .checkSouthMap ld b, a ld a, [wCurrentMapHeight2] @@ -641,7 +662,7 @@ CheckMapConnections:: ; 05db (0:05db) ld hl, wPikachuOverworldStateFlags set 4, [hl] ld a, $2 - ld [wd431], a + ld [wPikachuSpawnState], a call LoadMapHeader ; 0dab (0:0dab) call PlayDefaultMusicFadeOutCurrent ; music ld b, SET_PAL_OVERWORLD @@ -651,6 +672,7 @@ CheckMapConnections:: ; 05db (0:05db) call InitMapSprites call LoadTileBlockMap jp OverworldLoopLessDelay + .didNotEnterConnectedMap jp OverworldLoop @@ -666,6 +688,7 @@ PlayMapChangeSound:: ; 06ef (0:06ef) jr nz, .didNotGoThroughDoor ld a, $ad ; SFX_GO_INSIDE jr .playSound + .didNotGoThroughDoor ld a, $b5 ; SFX_GO_OUTSIDE .playSound @@ -713,6 +736,7 @@ ExtraWarpCheck:: ; 071a (0:071a) .useFunction1 ld hl, IsPlayerFacingEdgeOfMap jr .doBankswitch + .useFunction2 ld hl, IsWarpTileInFrontOfPlayer .doBankswitch @@ -779,6 +803,7 @@ Func_07c4:: ; 07c4 (0:07c4) ret z call PlayDefaultMusic ret + LoadPlayerSpriteGraphics:: ; 07d7 (0:07d7) ; Load sprite graphics based on whether the player is standing, biking, or surfing. @@ -1073,7 +1098,7 @@ IsSpriteInFrontOfPlayer:: ; 0983 (0:0983) ld d, $10 ; talking range in pixels (normal range) IsSpriteInFrontOfPlayer2:: ; 0985 (0:0985) lb bc, $3c, $40 ; Y and X position of player sprite - ld a, [wSpriteStateData1 + 9] ; direction the player is facing + ld a, [wPlayerFacingDirection] ; direction the player is facing .checkIfPlayerFacingUp cp SPRITE_FACING_UP jr nz, .checkIfPlayerFacingDown @@ -1083,6 +1108,7 @@ IsSpriteInFrontOfPlayer2:: ; 0985 (0:0985) ld b, a ld a, PLAYER_DIR_UP jr .doneCheckingDirection + .checkIfPlayerFacingDown cp SPRITE_FACING_DOWN jr nz, .checkIfPlayerFacingRight @@ -1092,6 +1118,7 @@ IsSpriteInFrontOfPlayer2:: ; 0985 (0:0985) ld b, a ld a, PLAYER_DIR_DOWN jr .doneCheckingDirection + .checkIfPlayerFacingRight cp SPRITE_FACING_RIGHT jr nz, .playerFacingLeft @@ -1101,6 +1128,7 @@ IsSpriteInFrontOfPlayer2:: ; 0985 (0:0985) ld c, a ld a, PLAYER_DIR_RIGHT jr .doneCheckingDirection + .playerFacingLeft ; facing left ld a, c @@ -1140,6 +1168,7 @@ IsSpriteInFrontOfPlayer2:: ; 0985 (0:0985) jr nz, .spriteLoop xor a ret + .foundSpriteInFrontOfPlayer pop hl ld a, l @@ -1157,6 +1186,7 @@ IsSpriteInFrontOfPlayer2:: ; 0985 (0:0985) .dontwritetowd436 scf ret + SignLoop:: ; 09f2 (0:09f2) ; search if a player is facing a sign @@ -1171,6 +1201,7 @@ SignLoop:: ; 09f2 (0:09f2) jr z, .yCoordMatched inc hl jr .retry + .yCoordMatched ld a, [hli] ; sign X cp e @@ -1189,6 +1220,7 @@ SignLoop:: ; 09f2 (0:09f2) pop hl scf ret + .retry dec b jr nz, .signLoop @@ -1248,6 +1280,7 @@ CollisionCheckOnLand:: ; 0a1c (0:0a1c) .setCarry scf ret + .noCollision and a ret @@ -1300,6 +1333,7 @@ CheckForTilePairCollisions:: ; 0aa6 (0:0aa6) .retry inc hl jr .tilePairCollisionLoop + .tilesetMatches ld a, [wTilePlayerStandingOn] ; tile the player is on ld b, a @@ -1311,12 +1345,14 @@ CheckForTilePairCollisions:: ; 0aa6 (0:0aa6) cp b jr z, .currentTileMatchesSecondInPair jr .retry + .currentTileMatchesFirstInPair inc hl ld a, [hl] cp c jr z, .foundMatch jr .tilePairCollisionLoop + .currentTileMatchesSecondInPair dec hl ld a, [hli] @@ -1326,6 +1362,7 @@ CheckForTilePairCollisions:: ; 0aa6 (0:0aa6) .foundMatch scf ret + .noMatch and a ret @@ -1480,6 +1517,7 @@ CopyToRedrawRowOrColumnSrcTiles:: ; 0baa (0:0baa) dec c jr nz, .loop ret + ScheduleSouthRowRedraw:: ; 0bb6 (0:0bb6) coord hl, 0, 16 @@ -1601,6 +1639,7 @@ JoypadOverworld:: ; 0c51 (0:0c51) call ForceBikeDown call AreInputsSimulated ret + ForceBikeDown:: ; 0c65 (0:0c65) ld a, [wFlags_D733] @@ -1615,6 +1654,7 @@ ForceBikeDown:: ; 0c65 (0:0c65) ld a, D_DOWN ld [hJoyHeld], a ; on the cycling road, if there isn't a trainer and the player isn't pressing buttons, simulate a down press ret + AreInputsSimulated:: ; 0c7b (0:0c7b) ld a, [wd730] @@ -1634,6 +1674,7 @@ AreInputsSimulated:: ; 0c7b (0:0c7b) ld [hJoyPressed], a ld [hJoyReleased], a ret + ; if done simulating button presses .doneSimulating @@ -1650,6 +1691,7 @@ AreInputsSimulated:: ; 0c7b (0:0c7b) ld hl, wd730 res 7, [hl] ret + GetSimulatedInput:: ; 0cb3 (0:0cb3) ld hl, wSimulatedJoypadStatesIndex @@ -1666,6 +1708,7 @@ GetSimulatedInput:: ; 0cb3 (0:0cb3) pop de scf ret + .endofsimulatedinputs and a ret @@ -1708,6 +1751,7 @@ CollisionCheckOnWater:: ; 0cca (0:0cca) .setCarry scf jr .done + .checkIfVermilionDockTileset ld a, [wCurMapTileset] ; tileset cp SHIP_PORT ; Vermilion Dock tileset @@ -1715,7 +1759,7 @@ CollisionCheckOnWater:: ; 0cca (0:0cca) jr .stopSurfing ; if it is the boarding platform tile, stop surfing .stopSurfing ; based game freak ld a, $3 - ld [wd431], a + ld [wPikachuSpawnState], a ld hl, wPikachuOverworldStateFlags set 5, [hl] xor a @@ -1723,6 +1767,7 @@ CollisionCheckOnWater:: ; 0cca (0:0cca) call LoadPlayerSpriteGraphics call PlayDefaultMusic jr .noCollision + .noCollision ; ...and they do the same mistake twice and a .done @@ -1762,6 +1807,7 @@ LoadWalkingPlayerSpriteGraphics:: ; 0d5e (0:0d5e) ld b, BANK(RedSprite) ld de, RedSprite ; $4180 jr LoadPlayerSpriteGraphicsCommon + LoadSurfingPlayerSpriteGraphics2:: ; 0d69 (0:0d69) ld a, [wd473] @@ -1779,6 +1825,7 @@ LoadSurfingPlayerSpriteGraphics2:: ; 0d69 (0:0d69) ld b, BANK(SurfingPikachuSprite) ld de, SurfingPikachuSprite ; 3f:6def jr LoadPlayerSpriteGraphicsCommon + LoadSurfingPlayerSpriteGraphics:: ; 0d83 (0:0d83) ld b, BANK(RedSprite) ; not sure, but probably same bank (5) @@ -1970,6 +2017,7 @@ CopySignData:: ; 0eb3 (0:0eb3) dec a jr nz, .signcopyloop ret + ; function to load map data LoadMapData:: ; 1241 (0:1241) @@ -2217,6 +2265,7 @@ ZeroSpriteStateData:: ; 1050 (0:1050) dec b jr nz, .loop ret + DisableRegularSprites:: ; 1060 (0:1060) ; initialize all C100-C1FF sprite entries to disabled (other than player's and pikachu) @@ -2229,6 +2278,7 @@ DisableRegularSprites:: ; 1060 (0:1060) dec c jr nz, .loop ret + LoadSprite:: ; 106f (0:106f) push hl @@ -2259,6 +2309,7 @@ LoadSprite:: ; 106f (0:106f) ld [hl], a pop hl ret + .trainerSprite ld a, [hli] @@ -2274,6 +2325,7 @@ LoadSprite:: ; 106f (0:106f) ld [hl], a ; store trainer number in byte 1 of the entry pop hl ret + .itemBallSprite ld a, [hli] diff --git a/home/pikachu.asm b/home/pikachu.asm index bd750773..f3ab9b8e 100755 --- a/home/pikachu.asm +++ b/home/pikachu.asm @@ -2,7 +2,7 @@ Func_1510:: ; 1510 (0:1510) push hl ld hl, wPikachuOverworldStateFlags set 7, [hl] - ld hl, wSpriteStateData1 + $f2 ; pikachu data? + ld hl, wPikachuSpriteImageIdx ; pikachu data? ld [hl], $ff pop hl ret @@ -25,7 +25,7 @@ Func_152d:: ; 152d (0:152d) push hl ld hl, wPikachuOverworldStateFlags set 3, [hl] - ld hl, wSpriteStateData1 + $f2 ; pikachu data? + ld hl, wPikachuSpriteImageIdx ; pikachu data? ld [hl], $ff pop hl ret @@ -51,42 +51,43 @@ CheckPikachuFollowingPlayer:: ; 154a (0:154a) pop hl ret -Func_1552:: ; 1552 (0:1552) +SpawnPikachu:: ; 1552 (0:1552) ld a, [hl] dec a swap a ld [hTilePlayerStandingOn], a - homecall Func_fc6d5 ; 3f:46d5 + homecall SpawnPikachu_ ; 3f:46d5 ret -Func_1568:: ; 1568 (0:1568) +Pikachu_IsInArray:: ; 1568 (0:1568) ld b, $0 ld c, a -.asm_156b +.loop inc b ld a, [hli] cp $ff - jr z, .asm_1578 + jr z, .not_in_array cp c - jr nz, .asm_156b + jr nz, .loop dec b dec hl scf ret -.asm_1578 + +.not_in_array dec b dec hl and a ret -Func_157c:: ; 157c (0:157c) +GetPikachuMovementScriptByte:: ; 157c (0:157c) push hl push bc ld a, [H_LOADEDROMBANK] push af - ld a, [wd44a] + ld a, [wPikachuMovementScriptBank] call BankswitchCommon - ld hl, wd44b + ld hl, wPikachuMovementScriptAddress ld c, [hl] inc hl ld b, [hl] @@ -103,11 +104,11 @@ Func_157c:: ; 157c (0:157c) pop hl ret -Func_159b:: ; 159b (0:159b) +ApplyPikachuMovementData:: ; 159b (0:159b) ld a, [H_LOADEDROMBANK] ld b, a push af - callbs Func_fd2a1 + callbs ApplyPikachuMovementData_ pop af call BankswitchCommon ret diff --git a/main.asm b/main.asm index cc67186d..12b1d645 100755 --- a/main.asm +++ b/main.asm @@ -689,7 +689,7 @@ Func_2fd6a: ; 2fd6a (b:7d6a) callab IsThisPartymonStarterPikachu_Party ret nc ld a, $3 - ld [wd431], a + ld [wPikachuSpawnState], a ret INCLUDE "engine/battle/scale_sprites.asm" @@ -1186,7 +1186,7 @@ MtMoon3Script_4a325: ; pikachu-related function? pop af ld [wUpdateSpritesEnabled], a pop hl - call Func_159b + call ApplyPikachuMovementData ret INCLUDE "data/mapHeaders/safarizonewest.asm" diff --git a/scripts/beach_house.asm b/scripts/beach_house.asm index fb0d78f2..d43e0977 100644 --- a/scripts/beach_house.asm +++ b/scripts/beach_house.asm @@ -19,7 +19,7 @@ SurfinDudeText: call PrintText jr .done .next - ld hl, wPreventBlackout + ld hl, wd492 bit 0, [hl] set 0, [hl] jr nz, .next2 @@ -36,7 +36,7 @@ SurfinDudeText: ld a, 1 ld [wDoNotWaitForButtonPressAfterDisplayingText], a callba SurfingPikachuMinigame - ld hl, wPreventBlackout + ld hl, wd492 set 1, [hl] jr .done .asm_f226b @@ -133,7 +133,7 @@ BeachHouseSign4Text: bit 6, a jr z, .asm_f2369 - ld hl, wPreventBlackout + ld hl, wd492 bit 1, [hl] jr z, .next2 ld a, 0 @@ -141,7 +141,7 @@ BeachHouseSign4Text: .next2 ld hl, .BeachHousePrinterText2 call PrintText - ld a, [wPreventBlackout] + ld a, [wd492] bit 1, a jr z, .asm_f236f diff --git a/scripts/billshouse.asm b/scripts/billshouse.asm index 5d6d668f..c93d86df 100755 --- a/scripts/billshouse.asm +++ b/scripts/billshouse.asm @@ -19,7 +19,7 @@ BillsHouseScriptPointers: ; 1e776 (7:6776) dw BillsHouseScript9 BillsHouseScript_1e09e: - ld hl, wPreventBlackout + ld hl, wd492 bit 7, [hl] set 7, [hl] ret nz @@ -58,7 +58,7 @@ BillsHouseScript1: ; 1e783 (7:6783) BillsHouseScript2: ld a, $ff ld [wJoyIgnore], a - ld a, [wSpriteStateData1 + 9] + ld a, [wPlayerFacingDirection] and a ; cp SPRITE_FACING_DOWN ld de, MovementData_1e79c jr nz, .notDown @@ -100,12 +100,12 @@ BillsHouseScript3: ; 1e7a6 (7:67a6) call CheckPikachuFollowingPlayer jr z, .asm_1e13e ld hl, PikachuMovementData_1e14d - ld a, [wSpriteStateData1 + 9] + ld a, [wPlayerFacingDirection] and a ; cp SPRITE_FACING_DOWN jr nz, .asm_1e133 ld hl, PikachuMovementData_1e152 .asm_1e133 - call Func_159b + call ApplyPikachuMovementData callab InitializePikachuTextID .asm_1e13e xor a @@ -169,7 +169,7 @@ BillsHouseScript5: ld [hSpriteFacingDirection], a call SetSpriteFacingDirectionAndDelay ld hl, PikachuMovementData_1e1a9 - call Func_159b + call ApplyPikachuMovementData ld a, $f ld [wEmotionBubbleSpriteIndex], a ld a, $0 @@ -212,7 +212,7 @@ BillsHouseScript7: xor a ld [wPlayerMovingDirection], a ld a, SPRITE_FACING_UP - ld [wSpriteStateData1 + 9], a + ld [wPlayerFacingDirection], a ld a, $FF ^ (A_BUTTON | B_BUTTON) ld [wJoyIgnore], a ld de, RLE_1e219 @@ -236,7 +236,7 @@ BillsHouseScript8: xor a ld [wPlayerMovingDirection], a ld a, SPRITE_FACING_UP - ld [wSpriteStateData1 + 9], a + ld [wPlayerFacingDirection], a ld a, $2 ld [H_SPRITEINDEX], a ld a, SPRITE_FACING_DOWN diff --git a/scripts/billshouse2.asm b/scripts/billshouse2.asm index 87a39969..2ae17ae6 100755 --- a/scripts/billshouse2.asm +++ b/scripts/billshouse2.asm @@ -114,7 +114,7 @@ Func_f24d5: call UpdateSprites call UpdateSprites ld hl, Data_f2505 - call Func_159b + call ApplyPikachuMovementData ld a, $f ; pikachu ld [wEmotionBubbleSpriteIndex], a ld a, $1 @@ -135,10 +135,10 @@ Data_f2505: Func_f250b: ld hl, Data_f251c ld b, SPRITE_FACING_UP - call Func_f0a82 + call TryApplyPikachuMovementData ld hl, Data_f2521 ld b, SPRITE_FACING_RIGHT - call Func_f0a82 + call TryApplyPikachuMovementData ret Data_f251c: diff --git a/scripts/cinnabargym.asm b/scripts/cinnabargym.asm index 8ae77507..4ad26a42 100755 --- a/scripts/cinnabargym.asm +++ b/scripts/cinnabargym.asm @@ -112,7 +112,7 @@ CinnabarGymScript_74fa3: ld a, b cp e ret nz - call Func_159b + call ApplyPikachuMovementData ret CinnabarGymScript1: ; 757dc (1d:57dc) diff --git a/scripts/cinnabarisland.asm b/scripts/cinnabarisland.asm index 3a2e9a2b..a6fa3af7 100755 --- a/scripts/cinnabarisland.asm +++ b/scripts/cinnabarisland.asm @@ -35,7 +35,7 @@ CinnabarIslandScript0: ; 1ca38 (7:4a38) ld [wSimulatedJoypadStatesEnd], a call StartSimulatingJoypadStates xor a - ld [wSpriteStateData1 + 9], a + ld [wPlayerFacingDirection], a ld [wJoyIgnore], a ld a, $1 ld [W_CINNABARISLANDCURSCRIPT], a diff --git a/scripts/copycatshouse2f.asm b/scripts/copycatshouse2f.asm index 74dbb1c5..6d896ce7 100755 --- a/scripts/copycatshouse2f.asm +++ b/scripts/copycatshouse2f.asm @@ -82,7 +82,7 @@ CopycatsHouse2FText6: ; 5ccfe (17:4cfe) CopycatsHouse2FText7: ; 5cd03 (17:4d03) TX_ASM - ld a, [wSpriteStateData1 + 9] + ld a, [wPlayerFacingDirection] cp SPRITE_FACING_UP ld hl, CopycatsHouse2FText_5cd1c jr nz, .notUp diff --git a/scripts/daycarem.asm b/scripts/daycarem.asm index b80b3dac..82622285 100755 --- a/scripts/daycarem.asm +++ b/scripts/daycarem.asm @@ -218,7 +218,7 @@ DayCareMText1: ; 56254 (15:6254) .withdrewPikachuFromDayCare ld a, $6 - ld [wd431], a + ld [wPikachuSpawnState], a ; GameFreak... TriHard ld hl, Func_fc4fa diff --git a/scripts/fanclub.asm b/scripts/fanclub.asm index a03fd2d7..fbc6d959 100755 --- a/scripts/fanclub.asm +++ b/scripts/fanclub.asm @@ -10,18 +10,18 @@ FanClubScriptPointers: dw FanClubScript2 FanClubScript1: - ld hl, wPreventBlackout + ld hl, wd492 bit 7, [hl] call z, FanClubScript_59a44 - ld hl, wPreventBlackout + ld hl, wd492 set 7, [hl] ret FanClubScript2: - ld hl, wPreventBlackout + ld hl, wd492 bit 7, [hl] call z, FanClubScript_59a39 - ld hl, wPreventBlackout + ld hl, wd492 set 7, [hl] ret @@ -50,7 +50,7 @@ FanClubScript_59a44: ld [wEmotionBubbleSpriteIndex], a predef EmotionBubble ld hl, PikachuMovementScript_59a8c - call Func_159b + call ApplyPikachuMovementData ld a, $2 ld [wSpriteStateData1 + 3 * $10 + 1], a ; Seel xor a ; SPRITE_FACING_DOWN diff --git a/scripts/mansion1.asm b/scripts/mansion1.asm index bbfb0a0b..c6381678 100755 --- a/scripts/mansion1.asm +++ b/scripts/mansion1.asm @@ -46,7 +46,7 @@ Mansion1ReplaceBlock: ; 44310 (11:4310) ret Mansion1Script_Switches: ; 44316 (11:4316) - ld a, [wSpriteStateData1 + 9] + ld a, [wPlayerFacingDirection] cp SPRITE_FACING_UP ret nz xor a diff --git a/scripts/mansion2.asm b/scripts/mansion2.asm index 22bc2b12..2162b3fc 100755 --- a/scripts/mansion2.asm +++ b/scripts/mansion2.asm @@ -42,7 +42,7 @@ Mansion2Script_5202f: ; 5202f (14:602f) predef_jump ReplaceTileBlock Mansion2Script_Switches: ; 52037 (14:6037) - ld a, [wSpriteStateData1 + 9] + ld a, [wPlayerFacingDirection] cp SPRITE_FACING_UP ret nz xor a diff --git a/scripts/mansion3.asm b/scripts/mansion3.asm index e49667ef..9333912d 100755 --- a/scripts/mansion3.asm +++ b/scripts/mansion3.asm @@ -73,7 +73,7 @@ Mansion3Script_5225b: ; 5225b (14:625b) ret Mansion3Script_Switches: ; 5227a (14:627a) - ld a, [wSpriteStateData1 + 9] + ld a, [wPlayerFacingDirection] cp SPRITE_FACING_UP ret nz xor a diff --git a/scripts/mansion4.asm b/scripts/mansion4.asm index 59ee3704..d3a1ded6 100755 --- a/scripts/mansion4.asm +++ b/scripts/mansion4.asm @@ -44,7 +44,7 @@ Mansion4Script_523cf: ; 523cf (14:63cf) ret Mansion4Script_Switches: ; 52420 (14:6420) - ld a, [wSpriteStateData1 + 9] + ld a, [wPlayerFacingDirection] cp SPRITE_FACING_UP ret nz xor a diff --git a/scripts/oakslab.asm b/scripts/oakslab.asm index 43464d77..585d0ae4 100755 --- a/scripts/oakslab.asm +++ b/scripts/oakslab.asm @@ -466,15 +466,15 @@ OaksLabScript16: ret nz xor a .asm_1c707 - ld [wSpriteStateData1 + 9], a + ld [wPlayerFacingDirection], a ret OaksLabScript17: ; Pikachu comes out ld a, SPRITE_FACING_UP - ld [wSpriteStateData1 + 9], a + ld [wPlayerFacingDirection], a ld a, $2 - ld [wd431], a + ld [wPikachuSpawnState], a callba Func_fc4fa call Func_1525 ld a, $1a diff --git a/scripts/oakslab2.asm b/scripts/oakslab2.asm index fef72470..5e4e98a4 100755 --- a/scripts/oakslab2.asm +++ b/scripts/oakslab2.asm @@ -4,13 +4,13 @@ Func_f1be0: jr z, .asm_f1bf0 ld b, SPRITE_FACING_DOWN ld hl, Data_f1bf9 - call Func_f0a82 + call TryApplyPikachuMovementData ret .asm_f1bf0 ld b, SPRITE_FACING_LEFT ld hl, Data_f1bfe - call Func_f0a82 + call TryApplyPikachuMovementData ret Data_f1bf9: diff --git a/scripts/pallettown.asm b/scripts/pallettown.asm index 73f50e3e..f29eacd1 100755 --- a/scripts/pallettown.asm +++ b/scripts/pallettown.asm @@ -174,7 +174,7 @@ PalletTownScript5: ; 18f56 (6:4f56) PalletTownScript6: ; 18f87 (6:4f87) xor a - ld [wSpriteStateData1 + 9], a + ld [wPlayerFacingDirection], a ld a, $1 ld [wSpriteIndex], a xor a diff --git a/scripts/pewtercity.asm b/scripts/pewtercity.asm index 1e9a922a..93806878 100755 --- a/scripts/pewtercity.asm +++ b/scripts/pewtercity.asm @@ -1,6 +1,6 @@ PewterCityScript: ; 192f5 (6:52f5) call EnableAutoTextBoxDrawing - ld hl, wPreventBlackout + ld hl, wd492 res 7, [hl] ld hl, PewterCityScriptPointers ld a, [W_PEWTERCITYCURSCRIPT] diff --git a/scripts/pewterpokecenter.asm b/scripts/pewterpokecenter.asm index 70cf17f6..3835c0c9 100755 --- a/scripts/pewterpokecenter.asm +++ b/scripts/pewterpokecenter.asm @@ -1,5 +1,5 @@ PewterPokecenterScript: ; 5c587 (17:4587) - ld hl, wPreventBlackout + ld hl, wd492 set 7, [hl] call Serial_TryEstablishingExternallyClockedConnection call EnableAutoTextBoxDrawing diff --git a/scripts/pokemontower7.asm b/scripts/pokemontower7.asm index abf6104d..77394447 100755 --- a/scripts/pokemontower7.asm +++ b/scripts/pokemontower7.asm @@ -235,7 +235,7 @@ PokemonTower7Script11: ld [wMissableObjectIndex], a predef HideObject ld a, SPRITE_FACING_UP - ld [wSpriteStateData1 + 9], a + ld [wPlayerFacingDirection], a ld a, LAVENDER_HOUSE_1 ld [hWarpDestinationMap], a ld a, $1 diff --git a/scripts/redshouse1f2.asm b/scripts/redshouse1f2.asm index 0ddd22d6..7fd98d41 100755 --- a/scripts/redshouse1f2.asm +++ b/scripts/redshouse1f2.asm @@ -40,7 +40,7 @@ MomHealText2: ; 481c1 (12:41c1) Func_f1bc4: ld hl, TVWrongSideText - ld a, [wSpriteStateData1 + 9] + ld a, [wPlayerFacingDirection] cp SPRITE_FACING_UP jp nz, .notUp ld hl, StandByMeText diff --git a/scripts/route11gateupstairs.asm b/scripts/route11gateupstairs.asm index e41e46e5..320f8606 100755 --- a/scripts/route11gateupstairs.asm +++ b/scripts/route11gateupstairs.asm @@ -47,7 +47,7 @@ Route11GateUpstairsText_494a3: ; 494a3 (12:54a3) Route11GateUpstairsText3: ; 494a8 (12:54a8) TX_ASM - ld a, [wSpriteStateData1 + 9] + ld a, [wPlayerFacingDirection] cp SPRITE_FACING_UP jp nz, GateUpstairsScript_PrintIfFacingUp CheckEvent EVENT_BEAT_ROUTE12_SNORLAX diff --git a/scripts/route12gateupstairs.asm b/scripts/route12gateupstairs.asm index e7ad5cbf..12b7b242 100755 --- a/scripts/route12gateupstairs.asm +++ b/scripts/route12gateupstairs.asm @@ -64,7 +64,7 @@ Route12GateUpstairsText_495c4: ; 495c4 (12:55c4) db "@" GateUpstairsScript_PrintIfFacingUp: ; 495c9 (12:55c9) - ld a, [wSpriteStateData1 + 9] + ld a, [wPlayerFacingDirection] cp SPRITE_FACING_UP jr z, .up ld a, $1 diff --git a/scripts/route22.asm b/scripts/route22.asm index 5ea8178f..db46efa1 100755 --- a/scripts/route22.asm +++ b/scripts/route22.asm @@ -153,7 +153,7 @@ Route22Script2: ; 50fb5 (14:4fb5) ld a, $1 ld [W_RIVALSTARTER], a .asm_50fc9 - ld a, [wSpriteStateData1 + 9] + ld a, [wPlayerFacingDirection] and a ; cp SPRITE_FACING_DOWN jr nz, .notDown ld a, SPRITE_FACING_UP diff --git a/scripts/route22gate.asm b/scripts/route22gate.asm index c957e4a6..7f38db70 100755 --- a/scripts/route22gate.asm +++ b/scripts/route22gate.asm @@ -40,7 +40,7 @@ Route22GateScript_1e6ba: ; 1e6ba (7:66ba) ld [wSimulatedJoypadStatesIndex], a ld a, D_DOWN ld [wSimulatedJoypadStatesEnd], a - ld [wSpriteStateData1 + 9], a + ld [wPlayerFacingDirection], a ld [wJoyIgnore], a jp StartSimulatingJoypadStates diff --git a/scripts/route23.asm b/scripts/route23.asm index f324963b..d26edb2e 100755 --- a/scripts/route23.asm +++ b/scripts/route23.asm @@ -118,7 +118,7 @@ Route23Script_512d8: ; 512d8 (14:52d8) ld a, D_DOWN ld [wSimulatedJoypadStatesEnd], a xor a - ld [wSpriteStateData1 + 9], a + ld [wPlayerFacingDirection], a ld [wJoyIgnore], a jp StartSimulatingJoypadStates diff --git a/scripts/route25.asm b/scripts/route25.asm index 20dcc890..9883f056 100755 --- a/scripts/route25.asm +++ b/scripts/route25.asm @@ -9,7 +9,7 @@ Route25Script: ; 515cb (14:55cb) ret Route25Script_515e1: ; 515e1 (14:55e1) - ld hl, wPreventBlackout + ld hl, wd492 res 2, [hl] res 3, [hl] res 4, [hl] diff --git a/scripts/safarizoneentrance.asm b/scripts/safarizoneentrance.asm index df80f4e1..a83944fc 100755 --- a/scripts/safarizoneentrance.asm +++ b/scripts/safarizoneentrance.asm @@ -26,7 +26,7 @@ SafariZoneEntranceScriptPointers: ; 751d9 (1d:51d9) xor a ld [hJoyHeld], a ld a, SPRITE_FACING_RIGHT - ld [wSpriteStateData1 + 9], a + ld [wPlayerFacingDirection], a ld a, [wCoordIndex] cp $1 jr z, .asm_7520f @@ -160,7 +160,7 @@ SafariZoneEntranceTextPointers: ; 752b9 (1d:52b9) ld hl, .SafariZoneEntranceText_753bb call PrintText xor a - ld [wSpriteStateData1 + 9], a + ld [wPlayerFacingDirection], a ld a, D_DOWN ld c, $3 call SafariZoneEntranceAutoWalk @@ -172,7 +172,7 @@ SafariZoneEntranceTextPointers: ; 752b9 (1d:52b9) ld hl, .SafariZoneEntranceText_753c0 call PrintText ld a, SPRITE_FACING_UP - ld [wSpriteStateData1 + 9], a + ld [wPlayerFacingDirection], a ld a, D_UP ld c, $1 call SafariZoneEntranceAutoWalk diff --git a/scripts/vermilioncity.asm b/scripts/vermilioncity.asm index a8fc8ce7..4e4a4959 100755 --- a/scripts/vermilioncity.asm +++ b/scripts/vermilioncity.asm @@ -1,6 +1,6 @@ VermilionCityScript: ; 197a1 (6:57a1) call EnableAutoTextBoxDrawing - ld hl, wPreventBlackout + ld hl, wd492 res 7, [hl] ld hl, wd126 bit 6, [hl] @@ -53,7 +53,7 @@ VermilionCityScriptPointers: ; 197dc (6:57dc) dw VermilionCityScript4 VermilionCityScript0: ; 197e6 (6:57e6) - ld a, [wSpriteStateData1 + 9] + ld a, [wPlayerFacingDirection] and a ; cp SPRITE_FACING_DOWN jr nz, .asm_198de ld hl, CoordsData_19823 @@ -176,7 +176,7 @@ VermilionCityText3: ; 198b1 (6:58b1) TX_ASM CheckEvent EVENT_SS_ANNE_LEFT jr nz, .asm_198f6 - ld a, [wSpriteStateData1 + 9] + ld a, [wPlayerFacingDirection] cp SPRITE_FACING_RIGHT jr z, .asm_198c8 ld hl, VermilionCityCoords1 diff --git a/scripts/viridiancity.asm b/scripts/viridiancity.asm index c20285bc..319e0106 100755 --- a/scripts/viridiancity.asm +++ b/scripts/viridiancity.asm @@ -54,7 +54,7 @@ ViridianCityScript_1905b: ld a, D_DOWN ld [wSimulatedJoypadStatesEnd], a xor a - ld [wSpriteStateData1 + 9], a + ld [wPlayerFacingDirection], a ld [wJoyIgnore], a ld [hJoyHeld], a ld a, $6 @@ -161,7 +161,7 @@ ViridianCityScript_1914d: ld a, D_DOWN ld [wSimulatedJoypadStatesEnd], a xor a - ld [wSpriteStateData1 + 9], a + ld [wPlayerFacingDirection], a ld [wJoyIgnore], a ret @@ -180,7 +180,7 @@ ViridianCityScript_19162: ld [hSpriteFacingDirection], a call SetSpriteFacingDirectionAndDelay ld a, $8 - ld [wSpriteStateData1 + 9], a + ld [wPlayerFacingDirection], a ld a, $8 ld [hSpriteIndexOrTextID], a call DisplayTextID diff --git a/scripts/viridiancity2.asm b/scripts/viridiancity2.asm index 80ae3924..8e8b51db 100755 --- a/scripts/viridiancity2.asm +++ b/scripts/viridiancity2.asm @@ -207,7 +207,7 @@ ViridianCityText_f19fc: Func_f1a01: ld hl, Data_f1a0a ld b, SPRITE_FACING_RIGHT - call Func_f0a82 + call TryApplyPikachuMovementData ret Data_f1a0a: diff --git a/wram.asm b/wram.asm index c5b443f3..6dd0cdba 100755 --- a/wram.asm +++ b/wram.asm @@ -228,7 +228,39 @@ wSpriteStateData1:: ; c100 ; C1xD ; C1xE ; C1xF - ds $10 * $10 +spritestatedata1: MACRO +w\1SpriteStateData1:: +w\1PictureID:: db +w\1MovementStatus:: db +w\1SpriteImageIdx:: db +w\1YStepVector:: db +w\1YPixels:: db +w\1XStepVector:: db +w\1XPixels:: db +w\1IntraAnimFrameCounter:: db +w\1AnimFrameCounter:: db +w\1FacingDirection:: db + ds 6 +w\1SpriteStateData1End:: +endm + + spritestatedata1 Player + spritestatedata1 Sprite01 + spritestatedata1 Sprite02 + spritestatedata1 Sprite03 + spritestatedata1 Sprite04 + spritestatedata1 Sprite05 + spritestatedata1 Sprite06 + spritestatedata1 Sprite07 + spritestatedata1 Sprite08 + spritestatedata1 Sprite09 + spritestatedata1 Sprite10 + spritestatedata1 Sprite11 + spritestatedata1 Sprite12 + spritestatedata1 Sprite13 + spritestatedata1 Sprite14 + spritestatedata1 Pikachu + ; ds $10 * $10 ;SECTION "Sprite State Data 2", WRAM0[$c200] @@ -253,7 +285,40 @@ wSpriteStateData2:: ; c200 ; C2xD ; C2xE: sprite image base offset (in video ram, player always has value 1, used to compute c1x2) ; C2xF - ds $10 * $10 +spritestatedata2: MACRO +w\1SpriteStateData2:: +w\1WalkAnimationCounter:: db + ds 1 +w\1YDisplacement:: db +w\1XDisplacement:: db +w\1MapY:: db +w\1MapX:: db +w\1MovementByte1:: db +w\1GrassPriority:: db +w\1MovementDelay:: db + ds 5 +w\1SpriteImageBaseOffset:: db + ds 1 +w\1SpriteStateData2End:: +endm + + spritestatedata2 Player + spritestatedata2 Sprite01 + spritestatedata2 Sprite02 + spritestatedata2 Sprite03 + spritestatedata2 Sprite04 + spritestatedata2 Sprite05 + spritestatedata2 Sprite06 + spritestatedata2 Sprite07 + spritestatedata2 Sprite08 + spritestatedata2 Sprite09 + spritestatedata2 Sprite10 + spritestatedata2 Sprite11 + spritestatedata2 Sprite12 + spritestatedata2 Sprite13 + spritestatedata2 Sprite14 + spritestatedata2 Pikachu + ; ds $10 * $10 wSpriteDataEnd:: @@ -2735,7 +2800,7 @@ wDestinationWarpID:: ; d42f ds 1 wPikachuOverworldStateFlags:: ds 1 ; d42f -wd431:: ds 1 ; d430 +wPikachuSpawnState:: ds 1 ; d430 wd432:: ds 1 ; d431 wd433:: ds 1 ; d432 wd434:: ds 1 @@ -2749,11 +2814,12 @@ wExpressionNumber:: ; d447 wExpressionNumber2:: ds 1 -wd44a:: ds 1 ; d449 -wd44b:: ds 1 -wd44c:: ds 1 -wd44d:: ds 1 -wPikaPicAnimPointer:: dw ; d44d +wPikachuMovementScriptBank:: ds 1 ; d449 +wPikachuMovementScriptAddress:: dw ; d44a +wd44d:: ds 1 ; d44c + +wCurPikaMovementData:: ; +wPikaPicAnimPointer:: dw ; d44d wPikaPicAnimPointerSetupFinished:: ds 1 ; d44f wPikaPicAnimCurGraphicID:: ds 1 wPikaPicAnimTimer:: ds 2 ; d451 @@ -2785,7 +2851,7 @@ wd47a:: ds 1 ds 24 -wPreventBlackout:: ds 1 ; d492 +wd492:: ds 1 ; d492 ds 1 -- cgit v1.3.1-sl0p From 48fce68a828602239d8aa7c03a726d0a2e2a591a Mon Sep 17 00:00:00 2001 From: pikalaxalt Date: Mon, 6 Jun 2016 15:42:12 -0400 Subject: Split out Pikachu-related data --- data/pikachu_emotions.asm | 266 +++++++++++++++++++++ data/pikachu_pic_animation.asm | 397 +++++++++++++++++++++++++++++++ engine/pikachu_emotions.asm | 267 +-------------------- engine/pikachu_pic_animation.asm | 489 ++------------------------------------- macros.asm | 6 + wram.asm | 15 +- 6 files changed, 701 insertions(+), 739 deletions(-) create mode 100755 data/pikachu_emotions.asm create mode 100755 data/pikachu_pic_animation.asm (limited to 'wram.asm') diff --git a/data/pikachu_emotions.asm b/data/pikachu_emotions.asm new file mode 100755 index 00000000..a1d902c3 --- /dev/null +++ b/data/pikachu_emotions.asm @@ -0,0 +1,266 @@ +PikachuEmotion0_fd115: ; fd115 (3f:5115) + db $ff + +PikachuEmotion2_fd116: ; fd116 (3f:5116) + pikaemotion_dummy2 + pikaemotion_emotebubble SMILE_BUBBLE + pikaemotion_pcm PikachuCry35 + pikaemotion_pikapic $2 + db $ff + +PikachuEmotion10_fd11e: ; fd11e (3f:511e) + pikaemotion_dummy2 + pikaemotion_subcmd PIKAEMOTION_SUBCMD_LOADEXTRAPIKASPRITES + pikaemotion_emotebubble HEART_BUBBLE + pikaemotion_pcm PikachuCry5 + pikaemotion_pikapic $a + db $ff + +PikachuEmotion7_fd128: ; fd128 (3f:5128) + pikaemotion_dummy2 + pikaemotion_subcmd PIKAEMOTION_SUBCMD_LOADEXTRAPIKASPRITES + pikaemotion_movement Pointer_fd224 + pikaemotion_pcm PikachuCry1 + pikaemotion_movement Pointer_fd224 + pikaemotion_pikapic $7 + db $ff + +PikachuEmotion4_fd136: ; fd136 (3f:5136) + pikaemotion_dummy2 + pikaemotion_subcmd PIKAEMOTION_SUBCMD_LOADEXTRAPIKASPRITES + pikaemotion_movement Pointer_fd230 + pikaemotion_pcm PikachuCry29 + pikaemotion_pikapic $4 + db $ff + +PikachuEmotion1_fd141: ; fd141 (3f:5141) + pikaemotion_dummy2 + pikaemotion_pcm + pikaemotion_pikapic $1 + db $ff + +PikachuEmotion8_fd147: ; fd147 (3f:5147) + pikaemotion_dummy2 + pikaemotion_pcm PikachuCry39 + pikaemotion_pikapic $8 + db $ff + +PikachuEmotion5_fd14d: ; fd14d (3f:514d) + pikaemotion_dummy2 + pikaemotion_pcm PikachuCry31 + pikaemotion_pikapic $5 + db $ff + +PikachuEmotion6_fd153: ; fd153 (3f:5153) + pikaemotion_dummy2 + pikaemotion_subcmd PIKAEMOTION_SUBCMD_LOADEXTRAPIKASPRITES + pikaemotion_pcm + pikaemotion_movement Pointer_fd21e + pikaemotion_emotebubble SKULL_BUBBLE + pikaemotion_pikapic $6 + db $ff + +PikachuEmotion3_fd160: ; fd160 (3f:5160) + pikaemotion_dummy2 + pikaemotion_pcm PikachuCry40 + pikaemotion_pikapic $3 + db $ff + +PikachuEmotion9_fd166: ; fd166 (3f:5166) + pikaemotion_dummy2 + pikaemotion_subcmd PIKAEMOTION_SUBCMD_LOADEXTRAPIKASPRITES + pikaemotion_pcm PikachuCry6 + pikaemotion_movement Pointer_fd218 + pikaemotion_emotebubble SKULL_BUBBLE + pikaemotion_pikapic $9 + db $ff + +PikachuEmotion11_fd173: ; fd173 (3f:5173) + pikaemotion_emotebubble ZZZ_BUBBLE + pikaemotion_pcm PikachuCry37 + pikaemotion_pikapic $b + db $ff + +PikachuEmotion12_fd17a: ; fd17a (3f:517a) + pikaemotion_dummy2 + pikaemotion_pcm + pikaemotion_pikapic $c + db $ff + +PikachuEmotion13_fd180: ; fd180 (3f:5180) + pikaemotion_dummy2 + pikaemotion_subcmd PIKAEMOTION_SUBCMD_LOADEXTRAPIKASPRITES + pikaemotion_movement Pointer_fd21e + pikaemotion_pikapic $d + db $ff + +PikachuEmotion14_fd189: ; fd189 (3f:5189) + pikaemotion_dummy2 + pikaemotion_emotebubble BOLT_BUBBLE + pikaemotion_pcm PikachuCry10 + pikaemotion_pikapic $e + db $ff + +PikachuEmotion15_fd191: ; fd191 (3f:5191) + pikaemotion_dummy2 + pikaemotion_pcm PikachuCry34 + pikaemotion_pikapic $f + db $ff + +PikachuEmotion16_fd197: ; fd197 (3f:5197) + pikaemotion_dummy2 + pikaemotion_pcm PikachuCry33 + pikaemotion_pikapic $10 + db $ff + +PikachuEmotion17_fd19d: ; fd19d (3f:519d) + pikaemotion_dummy2 + pikaemotion_pcm PikachuCry13 + pikaemotion_pikapic $11 + db $ff + +PikachuEmotion18_fd1a3: ; fd1a3 (3f:51a3) + pikaemotion_dummy2 + pikaemotion_pcm + pikaemotion_pikapic $12 + db $ff + +PikachuEmotion19_fd1a9: ; fd1a9 (3f:51a9) + pikaemotion_dummy2 + pikaemotion_emotebubble HEART_BUBBLE + pikaemotion_pcm PikachuCry33 + pikaemotion_pikapic $13 + db $ff + +PikachuEmotion20_fd1b1: ; fd1b1 (3f:51b1) + pikaemotion_dummy2 + pikaemotion_emotebubble HEART_BUBBLE + pikaemotion_pcm PikachuCry5 + pikaemotion_pikapic $14 + db $ff + +PikachuEmotion21_fd1b9: ; fd1b9 (3f:51b9) + pikaemotion_dummy2 + pikaemotion_emotebubble FISH_BUBBLE + pikaemotion_pcm + pikaemotion_pikapic $15 + db $ff + +PikachuEmotion22_fd1c1: ; fd1c1 (3f:51c1) + pikaemotion_dummy2 + pikaemotion_pcm PikachuCry4 + pikaemotion_pikapic $16 + db $ff + +PikachuEmotion23_fd1c7: ; fd1c7 (3f:51c7) + pikaemotion_dummy2 + pikaemotion_pcm PikachuCry19 + pikaemotion_pikapic $17 + pikaemotion_subcmd PIKAEMOTION_SUBCMD_SHOWMAPVIEW + db $ff + +PikachuEmotion24_fd1cf: ; fd1cf (3f:51cf) + pikaemotion_dummy2 + pikaemotion_emotebubble EXCLAMATION_BUBBLE + pikaemotion_pcm + pikaemotion_pikapic $18 + db $ff + +PikachuEmotion25_fd1d7: ; fd1d7 (3f:51d7) + pikaemotion_dummy2 + pikaemotion_emotebubble BOLT_BUBBLE + pikaemotion_pcm PikachuCry35 + pikaemotion_pikapic $19 + db $ff + +PikachuEmotion26_fd1df: ; fd1df (3f:51df) + pikaemotion_dummy2 + pikaemotion_emotebubble ZZZ_BUBBLE + pikaemotion_pcm PikachuCry37 + pikaemotion_pikapic $1a + pikaemotion_subcmd PIKAEMOTION_SUBCMD_SHOWMAPVIEW + pikaemotion_subcmd PIKAEMOTION_SUBCMD_CHECKPEWTERCENTER + db $ff + +PikachuEmotion27_fd1eb: ; fd1eb (3f:51eb) + pikaemotion_dummy2 + pikaemotion_pcm PikachuCry9 + pikaemotion_pikapic $1b + db $ff + +PikachuEmotion28_fd1f1: ; fd1f1 (3f:51f1) + pikaemotion_dummy2 + pikaemotion_pcm PikachuCry15 + pikaemotion_pikapic $1c + db $ff + +PikachuEmotion29_fd1f7: ; fd1f7 (3f:51f7) + pikaemotion_pcm PikachuCry5 + pikaemotion_pikapic $a + db $ff + +PikachuEmotion30_fd1fc: ; fd1fc (3f:51fc) + pikaemotion_9 + pikaemotion_emotebubble HEART_BUBBLE + pikaemotion_pcm PikachuCry5 + pikaemotion_pikapic $14 + pikaemotion_subcmd PIKAEMOTION_SUBCMD_SHOWMAPVIEW + pikaemotion_subcmd PIKAEMOTION_SUBCMD_LOADFONT + pikaemotion_subcmd PIKAEMOTION_SUBCMD_CHECKLAVENDERTOWER + db $ff + +PikachuEmotion31_fd20a: ; fd20a (3f:520a) + pikaemotion_pcm PikachuCry19 + pikaemotion_pikapic $17 + pikaemotion_subcmd PIKAEMOTION_SUBCMD_SHOWMAPVIEW + pikaemotion_subcmd PIKAEMOTION_SUBCMD_CHECKBILLSHOUSE + db $ff + +PikachuEmotion32_fd213: ; fd213 (3f:5213) + pikaemotion_pcm PikachuCry26 + pikaemotion_pikapic $17 + db $ff + +Pointer_fd218: ; fd218 (3f:5218) + db $00 + db $39, $01 + db $3e, $1e + db $3f + +Pointer_fd21e: ; fd21e (3f:521e) + db $00 + db $39, $00 + db $3e, $1e + db $3f + +Pointer_fd224: ; fd224 (3f:5224) + db $00 + db $3c, $07, $2f + db $3c, $07, $2f + db $3f + +Pointer_fd22c: ; fd22c (3f:522c) + db $3b, $1f, $03 + db $3f + +Pointer_fd230: ; fd230 (3f:5230) + db $00 + db $3c, $0f, $1f + db $3c, $0f, $1f + db $3f + +Pointer_fd238: ; fd238 (3f:5238) + db $00 + db $05, $07 + db $39, $00 + db $05, $07 + db $06, $07 + db $39, $00 + db $06, $07 + db $08, $07 + db $39, $00 + db $08, $07 + db $07, $07 + db $39, $00 + db $07, $07 + db $3f diff --git a/data/pikachu_pic_animation.asm b/data/pikachu_pic_animation.asm new file mode 100755 index 00000000..f1f6bd68 --- /dev/null +++ b/data/pikachu_pic_animation.asm @@ -0,0 +1,397 @@ +Data_fe242: + db 4, %11000000 + db 4, %11100100 + db 4, %11000000 + db 4, %11100100 + db 4, %11000000 + db 4, %11100100 + db 4, %11000000 + db 4, %11100100 + db 4, %11000000 + db 4, %11100100 + db 4, %11000000 + db 4, %11100100 + db 4, %11000000 + db 4, %11100100 + db 4, %11000000 + db 4, %11100100 + db 4, %11000000 + db 4, %11100100 + db 4, %11000000 + db 4, %11100100 + db $ff + +Data_fe26b: ; fe26b (3f:626b) + pikapic_loadgfx Pic_e4000 + pikapic_loadgfx Pic_e49d1 + pikapic_loadgfx PikachuSprite + pikapic_object $1, $80, $0, $0 + pikapic_object $2, $b2, $5, $5 + pikapic_object $3, $b6, $5, $5 + pikapic_waitbgmap + pikapic_cry + pikapic_looptofinish + +Data_fe28a: ; fe28a (3f:628a) + pikapic_setduration 40 + pikapic_loadgfx Pic_e4000 + pikapic_loadgfx GFX_e40cc + pikapic_object $4, $80, $0, $0 + pikapic_object $6, $99, $0, $0 + pikapic_waitbgmap + pikapic_cry PikachuCry3 + pikapic_looptofinish + +Data_fe2a4: ; fe2a4 (3f:62a4) + pikapic_setduration 44 + pikapic_loadgfx Pic_e411c + pikapic_loadgfx GFX_e41d2 + pikapic_object $4, $80, $0, $0 + pikapic_object $7, $99, $0, $0 + pikapic_waitbgmap + pikapic_cry + pikapic_looptofinish + +Data_fe2be: ; fe2be (3f:62be) + pikapic_setduration 80 + pikapic_loadgfx Pic_e4272 + pikapic_loadgfx GFX_e4323 + pikapic_object $4, $80, $0, $0 + pikapic_object $8, $99, $0, $0 + pikapic_waitbgmap + pikapic_cry + pikapic_looptofinish + +Data_fe2d8: ; fe2d8 (3f:62d8) + pikapic_setduration 70 + pikapic_loadgfx Pic_e4383 + pikapic_loadgfx GFX_e444b + pikapic_object $4, $80, $0, $0 + pikapic_object $9, $99, $0, $0 + pikapic_waitbgmap + pikapic_cry + pikapic_looptofinish + +Data_fe2f2: ; fe2f2 (3f:62f2) + pikapic_setduration 32 + pikapic_loadgfx Pic_e458b + pikapic_loadgfx GFX_e463b + pikapic_object $4, $80, $0, $0 + pikapic_object $a, $99, $0, $0 + pikapic_waitbgmap + pikapic_cry + pikapic_looptofinish + +Data_fe30c: ; fe30c (3f:630c) + pikapic_setduration 50 + pikapic_loadgfx Pic_e467b + pikapic_loadgfx GFX_e472e + pikapic_object $4, $80, $0, $0 + pikapic_object $b, $99, $0, $0 + pikapic_waitbgmap + pikapic_cry PikachuCry38 + pikapic_looptofinish + +Data_fe326: ; fe326 (3f:6326) + pikapic_setduration 58 + pikapic_loadgfx Pic_e476e + pikapic_loadgfx GFX_e4841 + pikapic_object $4, $80, $0, $0 + pikapic_object $c, $99, $0, $0 + pikapic_waitbgmap + pikapic_cry + pikapic_looptofinish + +Data_fe340: ; fe340 (3f:6340) + pikapic_setduration 44 + pikapic_loadgfx Pic_e49d1 + pikapic_loadgfx GFX_e4a99 + pikapic_object $4, $80, $0, $0 + pikapic_object $d, $99, $0, $0 + pikapic_waitbgmap + pikapic_cry + pikapic_looptofinish + +Data_fe35a: ; fe35a (3f:635a) + pikapic_setduration 56 + pikapic_loadgfx Pic_e4b39 + pikapic_loadgfx GFX_e4bde + pikapic_object $4, $80, $0, $0 + pikapic_object $e, $99, $0, $0 + pikapic_waitbgmap + pikapic_cry + pikapic_looptofinish + +Data_fe374: ; fe374 (3f:6374) + pikapic_setduration 56 + pikapic_loadgfx Pic_e4c3e + pikapic_loadgfx GFX_e4ce0 + pikapic_loadgfx GFX_e4e70 + pikapic_object $4, $80, $0, $0 + pikapic_object $10, $99, $0, $0 + pikapic_waitbgmap + pikapic_cry + pikapic_looptofinish + +Data_fe390: ; fe390 (3f:6390) + pikapic_setduration 100 + pikapic_loadgfx Pic_e5000 + pikapic_loadgfx GFX_e50af + pikapic_object $4, $80, $0, $0 + pikapic_object $11, $99, $0, $0 + pikapic_waitbgmap + pikapic_cry + pikapic_looptofinish + +Data_fe3aa: ; fe3aa (3f:63aa) + pikapic_setduration 50 + pikapic_loadgfx Pic_e523f + pikapic_loadgfx GFX_e52fe + pikapic_object $4, $80, $0, $0 + pikapic_object $12, $99, $0, $0 + pikapic_waitbgmap + pikapic_cry PikachuCry25 + pikapic_looptofinish + +Data_fe3c4: ; fe3c4 (3f:63c4) + pikapic_setduration 50 + pikapic_loadgfx Pic_e548e + pikapic_loadgfx GFX_e5541 + pikapic_object $4, $80, $0, $0 + pikapic_object $13, $99, $0, $0 + pikapic_waitbgmap + pikapic_cry + pikapic_looptofinish + +Data_fe3de: ; fe3de (3f:63de) + pikapic_setduration 40 + pikapic_loadgfx Pic_e56d1 + pikapic_loadgfx GFX_e5794 + pikapic_object $4, $80, $0, $0 + pikapic_object $14, $99, $0, $0 + pikapic_waitbgmap + pikapic_cry + pikapic_looptofinish + +Data_fe3f8: ; fe3f8 (3f:63f8) + pikapic_setduration 50 + pikapic_loadgfx Pic_e5924 + pikapic_loadgfx GFX_e59ed + pikapic_object $4, $80, $0, $0 + pikapic_object $15, $99, $0, $0 + pikapic_waitbgmap + pikapic_cry + pikapic_looptofinish + +Data_fe412: ; fe412 (3f:6412) + pikapic_setduration 32 + pikapic_loadgfx Pic_e5b7d + pikapic_loadgfx GFX_e5c4d + pikapic_object $4, $80, $0, $0 + pikapic_object $16, $99, $0, $0 + pikapic_waitbgmap + pikapic_cry + pikapic_looptofinish + +Data_fe42c: ; fe42c (3f:642c) + pikapic_setduration 100 + pikapic_loadgfx Pic_e5ddd + pikapic_loadgfx GFX_e5e90 + pikapic_object $4, $80, $0, $0 + pikapic_object $17, $99, $0, $0 + pikapic_waitbgmap + pikapic_cry + pikapic_looptofinish + +Data_fe446: ; fe446 (3f:6446) + pikapic_setduration 32 + pikapic_loadgfx GFX_e6020 + pikapic_loadgfx GFX_e61b0 + pikapic_object $5, $80, $0, $0 + pikapic_object $18, $99, $0, $0 + pikapic_waitbgmap + pikapic_cry PikachuCry18 + pikapic_looptofinish + +Data_fe460: ; fe460 (3f:6460) + pikapic_setduration 44 + pikapic_loadgfx Pic_e6340 + pikapic_loadgfx GFX_e63f7 + pikapic_object $4, $80, $0, $0 + pikapic_object $19, $99, $0, $0 + pikapic_waitbgmap + pikapic_cry + pikapic_looptofinish + +Data_fe47a: ; fe47a (3f:647a) + pikapic_setduration 50 + pikapic_loadgfx Pic_e6587 + pikapic_loadgfx GFX_e6646 + pikapic_object $4, $80, $0, $0 + pikapic_object $1a, $99, $0, $0 + pikapic_waitbgmap + pikapic_cry + pikapic_looptofinish + +Data_fe494: ; fe494 (3f:6494) + pikapic_setduration 40 + pikapic_loadgfx Pic_e67d6 + pikapic_loadgfx GFX_e682f + pikapic_loadgfx GFX_e69bf + pikapic_loadgfx GFX_e6b4f + pikapic_loadgfx GFX_e6cdf + pikapic_object $4, $80, $0, $0 + pikapic_object $1b, $99, $0, $0 + pikapic_waitbgmap + pikapic_cry PikachuCry20 + pikapic_looptofinish + +Data_fe4b4: ; fe4b4 (3f:64b4) + pikapic_setduration 40 + pikapic_loadgfx GFX_e6e6f + pikapic_loadgfx GFX_e6fff + pikapic_object $5, $80, $0, $0 + pikapic_object $1c, $99, $0, $0 + pikapic_waitbgmap + pikapic_cry + pikapic_looptofinish + +Data_fe4ce: ; fe4ce (3f:64ce) + pikapic_setduration 70 + pikapic_loadgfx GFX_e718f + pikapic_loadgfx GFX_e731f + pikapic_object $5, $80, $0, $0 + pikapic_object $1d, $99, $0, $0 + pikapic_waitbgmap + pikapic_cry + pikapic_looptofinish + +Data_fe4e8: ; fe4e8 (3f:64e8) + pikapic_setduration 60 + pikapic_loadgfx GFX_e74af + pikapic_loadgfx GFX_e763f + pikapic_object $5, $80, $0, $0 + pikapic_object $1e, $99, $0, $0 + pikapic_waitbgmap + pikapic_cry + pikapic_looptofinish + +Data_fe502: ; fe502 (3f:6502) + pikapic_setduration 50 + pikapic_loadgfx Pic_e77cf + pikapic_loadgfx GFX_e7863 + pikapic_loadgfx GFX_e79f3 + pikapic_object $4, $80, $0, $0 + pikapic_object $1f, $99, $0, $0 + pikapic_waitbgmap + pikapic_cry + pikapic_writebyte 13 + pikapic_waitbgmap + pikapic_thunderbolt + pikapic_ret + +Data_fe51f: ; fe51f (3f:651f) + pikapic_waitbgmap + +Data_fe520: ; fe520 (3f:6520) + pikapic_setduration 100 + pikapic_loadgfx Pic_e5000 + pikapic_loadgfx GFX_e50af + pikapic_loadgfx GFX_e7b83 + pikapic_loadgfx GFX_e7d13 + pikapic_object $4, $80, $0, $0 + pikapic_object $20, $99, $0, $0 + pikapic_waitbgmap + pikapic_cry + pikapic_looptofinish + +Data_fe53e: ; fe53e (3f:653e) + pikapic_setduration 30 + pikapic_loadgfx Pic_f0abf + pikapic_loadgfx GFX_f0b64 + pikapic_object $4, $80, $0, $0 + pikapic_object $21, $99, $0, $0 + pikapic_waitbgmap + pikapic_cry + pikapic_looptofinish + +Data_fe558: ; fe558 (3f:6558) + pikapic_setduration 64 + pikapic_loadgfx Pic_f0cf4 + pikapic_loadgfx GFX_f0d82 + pikapic_object $4, $80, $0, $0 + pikapic_object $22, $99, $0, $0 + pikapic_waitbgmap + pikapic_cry + pikapic_looptofinish + +PikaPicAnimGFXHeaders: +pikapicanimgfx: MACRO +\2_id:: + db \1 ; size + dba \2 ; pointer + endm + + dbbw 1, $39,$0000 ; 00 + pikapicanimgfx -1, Pic_e4000 ; 01 + pikapicanimgfx 5, GFX_e40cc ; 02 + pikapicanimgfx -1, Pic_e411c ; 03 + pikapicanimgfx 10, GFX_e41d2 ; 04 + pikapicanimgfx -1, Pic_e4272 ; 05 + pikapicanimgfx 6, GFX_e4323 ; 06 + pikapicanimgfx -1, Pic_e4383 ; 07 + pikapicanimgfx 20, GFX_e444b ; 08 + pikapicanimgfx -1, Pic_e458b ; 09 + pikapicanimgfx 4, GFX_e463b ; 0a + pikapicanimgfx -1, Pic_e467b ; 0b + pikapicanimgfx 4, GFX_e472e ; 0c + pikapicanimgfx -1, Pic_e476e ; 0d + pikapicanimgfx 25, GFX_e4841 ; 0e + pikapicanimgfx -1, Pic_e49d1 ; 0f + pikapicanimgfx 10, GFX_e4a99 ; 00 + pikapicanimgfx -1, Pic_e4b39 ; 11 + pikapicanimgfx 6, GFX_e4bde ; 12 + pikapicanimgfx -1, Pic_e4c3e ; 13 + pikapicanimgfx 25, GFX_e4ce0 ; 14 + pikapicanimgfx 25, GFX_e4e70 ; 15 + pikapicanimgfx -1, Pic_e5000 ; 16 + pikapicanimgfx 25, GFX_e50af ; 17 + pikapicanimgfx -1, Pic_e523f ; 18 + pikapicanimgfx 25, GFX_e52fe ; 19 + pikapicanimgfx -1, Pic_e548e ; 1a + pikapicanimgfx 25, GFX_e5541 ; 1b + pikapicanimgfx -1, Pic_e56d1 ; 1c + pikapicanimgfx 25, GFX_e5794 ; 1d + pikapicanimgfx -1, Pic_e5924 ; 1e + pikapicanimgfx 25, GFX_e59ed ; 1f + pikapicanimgfx -1, Pic_e5b7d ; 20 + pikapicanimgfx 25, GFX_e5c4d ; 21 + pikapicanimgfx -1, Pic_e5ddd ; 22 + pikapicanimgfx 25, GFX_e5e90 ; 23 + pikapicanimgfx 25, GFX_e6020 ; 24 + pikapicanimgfx 25, GFX_e61b0 ; 25 + pikapicanimgfx -1, Pic_e6340 ; 26 + pikapicanimgfx 25, GFX_e63f7 ; 27 + pikapicanimgfx -1, Pic_e6587 ; 28 + pikapicanimgfx 25, GFX_e6646 ; 29 + pikapicanimgfx -1, Pic_e67d6 ; 2a + pikapicanimgfx 25, GFX_e682f ; 2b + pikapicanimgfx 25, GFX_e69bf ; 2c + pikapicanimgfx 25, GFX_e6b4f ; 2d + pikapicanimgfx 25, GFX_e6cdf ; 2e + pikapicanimgfx 25, GFX_e6e6f ; 2f + pikapicanimgfx 25, GFX_e6fff ; 30 + pikapicanimgfx 25, GFX_e718f ; 31 + pikapicanimgfx 25, GFX_e731f ; 32 + pikapicanimgfx 25, GFX_e74af ; 33 + pikapicanimgfx 25, GFX_e763f ; 34 + pikapicanimgfx -1, Pic_e77cf ; 35 + pikapicanimgfx 25, GFX_e7863 ; 36 + pikapicanimgfx 25, GFX_e79f3 ; 37 + pikapicanimgfx 25, GFX_e7b83 ; 38 + pikapicanimgfx 25, GFX_e7d13 ; 39 + pikapicanimgfx -1, Pic_f0abf ; 3a + pikapicanimgfx 25, GFX_f0b64 ; 3b + pikapicanimgfx -1, Pic_f0cf4 ; 3c + pikapicanimgfx 25, GFX_f0d82 ; 3d + pikapicanimgfx 24, PikachuSprite ; 3e diff --git a/engine/pikachu_emotions.asm b/engine/pikachu_emotions.asm index b474770e..9040e612 100755 --- a/engine/pikachu_emotions.asm +++ b/engine/pikachu_emotions.asm @@ -342,272 +342,7 @@ IsPlayerPikachuAsleepInParty:: ; fd0d0 (3f:50d0) and a ret -PikachuEmotion0_fd115: ; fd115 (3f:5115) - db $ff - -PikachuEmotion2_fd116: ; fd116 (3f:5116) - pikaemotion_dummy2 - pikaemotion_emotebubble SMILE_BUBBLE - pikaemotion_pcm PikachuCry35 - pikaemotion_pikapic $2 - db $ff - -PikachuEmotion10_fd11e: ; fd11e (3f:511e) - pikaemotion_dummy2 - pikaemotion_subcmd PIKAEMOTION_SUBCMD_LOADEXTRAPIKASPRITES - pikaemotion_emotebubble HEART_BUBBLE - pikaemotion_pcm PikachuCry5 - pikaemotion_pikapic $a - db $ff - -PikachuEmotion7_fd128: ; fd128 (3f:5128) - pikaemotion_dummy2 - pikaemotion_subcmd PIKAEMOTION_SUBCMD_LOADEXTRAPIKASPRITES - pikaemotion_movement Pointer_fd224 - pikaemotion_pcm PikachuCry1 - pikaemotion_movement Pointer_fd224 - pikaemotion_pikapic $7 - db $ff - -PikachuEmotion4_fd136: ; fd136 (3f:5136) - pikaemotion_dummy2 - pikaemotion_subcmd PIKAEMOTION_SUBCMD_LOADEXTRAPIKASPRITES - pikaemotion_movement Pointer_fd230 - pikaemotion_pcm PikachuCry29 - pikaemotion_pikapic $4 - db $ff - -PikachuEmotion1_fd141: ; fd141 (3f:5141) - pikaemotion_dummy2 - pikaemotion_pcm - pikaemotion_pikapic $1 - db $ff - -PikachuEmotion8_fd147: ; fd147 (3f:5147) - pikaemotion_dummy2 - pikaemotion_pcm PikachuCry39 - pikaemotion_pikapic $8 - db $ff - -PikachuEmotion5_fd14d: ; fd14d (3f:514d) - pikaemotion_dummy2 - pikaemotion_pcm PikachuCry31 - pikaemotion_pikapic $5 - db $ff - -PikachuEmotion6_fd153: ; fd153 (3f:5153) - pikaemotion_dummy2 - pikaemotion_subcmd PIKAEMOTION_SUBCMD_LOADEXTRAPIKASPRITES - pikaemotion_pcm - pikaemotion_movement Pointer_fd21e - pikaemotion_emotebubble SKULL_BUBBLE - pikaemotion_pikapic $6 - db $ff - -PikachuEmotion3_fd160: ; fd160 (3f:5160) - pikaemotion_dummy2 - pikaemotion_pcm PikachuCry40 - pikaemotion_pikapic $3 - db $ff - -PikachuEmotion9_fd166: ; fd166 (3f:5166) - pikaemotion_dummy2 - pikaemotion_subcmd PIKAEMOTION_SUBCMD_LOADEXTRAPIKASPRITES - pikaemotion_pcm PikachuCry6 - pikaemotion_movement Pointer_fd218 - pikaemotion_emotebubble SKULL_BUBBLE - pikaemotion_pikapic $9 - db $ff - -PikachuEmotion11_fd173: ; fd173 (3f:5173) - pikaemotion_emotebubble ZZZ_BUBBLE - pikaemotion_pcm PikachuCry37 - pikaemotion_pikapic $b - db $ff - -PikachuEmotion12_fd17a: ; fd17a (3f:517a) - pikaemotion_dummy2 - pikaemotion_pcm - pikaemotion_pikapic $c - db $ff - -PikachuEmotion13_fd180: ; fd180 (3f:5180) - pikaemotion_dummy2 - pikaemotion_subcmd PIKAEMOTION_SUBCMD_LOADEXTRAPIKASPRITES - pikaemotion_movement Pointer_fd21e - pikaemotion_pikapic $d - db $ff - -PikachuEmotion14_fd189: ; fd189 (3f:5189) - pikaemotion_dummy2 - pikaemotion_emotebubble BOLT_BUBBLE - pikaemotion_pcm PikachuCry10 - pikaemotion_pikapic $e - db $ff - -PikachuEmotion15_fd191: ; fd191 (3f:5191) - pikaemotion_dummy2 - pikaemotion_pcm PikachuCry34 - pikaemotion_pikapic $f - db $ff - -PikachuEmotion16_fd197: ; fd197 (3f:5197) - pikaemotion_dummy2 - pikaemotion_pcm PikachuCry33 - pikaemotion_pikapic $10 - db $ff - -PikachuEmotion17_fd19d: ; fd19d (3f:519d) - pikaemotion_dummy2 - pikaemotion_pcm PikachuCry13 - pikaemotion_pikapic $11 - db $ff - -PikachuEmotion18_fd1a3: ; fd1a3 (3f:51a3) - pikaemotion_dummy2 - pikaemotion_pcm - pikaemotion_pikapic $12 - db $ff - -PikachuEmotion19_fd1a9: ; fd1a9 (3f:51a9) - pikaemotion_dummy2 - pikaemotion_emotebubble HEART_BUBBLE - pikaemotion_pcm PikachuCry33 - pikaemotion_pikapic $13 - db $ff - -PikachuEmotion20_fd1b1: ; fd1b1 (3f:51b1) - pikaemotion_dummy2 - pikaemotion_emotebubble HEART_BUBBLE - pikaemotion_pcm PikachuCry5 - pikaemotion_pikapic $14 - db $ff - -PikachuEmotion21_fd1b9: ; fd1b9 (3f:51b9) - pikaemotion_dummy2 - pikaemotion_emotebubble FISH_BUBBLE - pikaemotion_pcm - pikaemotion_pikapic $15 - db $ff - -PikachuEmotion22_fd1c1: ; fd1c1 (3f:51c1) - pikaemotion_dummy2 - pikaemotion_pcm PikachuCry4 - pikaemotion_pikapic $16 - db $ff - -PikachuEmotion23_fd1c7: ; fd1c7 (3f:51c7) - pikaemotion_dummy2 - pikaemotion_pcm PikachuCry19 - pikaemotion_pikapic $17 - pikaemotion_subcmd PIKAEMOTION_SUBCMD_SHOWMAPVIEW - db $ff - -PikachuEmotion24_fd1cf: ; fd1cf (3f:51cf) - pikaemotion_dummy2 - pikaemotion_emotebubble EXCLAMATION_BUBBLE - pikaemotion_pcm - pikaemotion_pikapic $18 - db $ff - -PikachuEmotion25_fd1d7: ; fd1d7 (3f:51d7) - pikaemotion_dummy2 - pikaemotion_emotebubble BOLT_BUBBLE - pikaemotion_pcm PikachuCry35 - pikaemotion_pikapic $19 - db $ff - -PikachuEmotion26_fd1df: ; fd1df (3f:51df) - pikaemotion_dummy2 - pikaemotion_emotebubble ZZZ_BUBBLE - pikaemotion_pcm PikachuCry37 - pikaemotion_pikapic $1a - pikaemotion_subcmd PIKAEMOTION_SUBCMD_SHOWMAPVIEW - pikaemotion_subcmd PIKAEMOTION_SUBCMD_CHECKPEWTERCENTER - db $ff - -PikachuEmotion27_fd1eb: ; fd1eb (3f:51eb) - pikaemotion_dummy2 - pikaemotion_pcm PikachuCry9 - pikaemotion_pikapic $1b - db $ff - -PikachuEmotion28_fd1f1: ; fd1f1 (3f:51f1) - pikaemotion_dummy2 - pikaemotion_pcm PikachuCry15 - pikaemotion_pikapic $1c - db $ff - -PikachuEmotion29_fd1f7: ; fd1f7 (3f:51f7) - pikaemotion_pcm PikachuCry5 - pikaemotion_pikapic $a - db $ff - -PikachuEmotion30_fd1fc: ; fd1fc (3f:51fc) - pikaemotion_9 - pikaemotion_emotebubble HEART_BUBBLE - pikaemotion_pcm PikachuCry5 - pikaemotion_pikapic $14 - pikaemotion_subcmd PIKAEMOTION_SUBCMD_SHOWMAPVIEW - pikaemotion_subcmd PIKAEMOTION_SUBCMD_LOADFONT - pikaemotion_subcmd PIKAEMOTION_SUBCMD_CHECKLAVENDERTOWER - db $ff - -PikachuEmotion31_fd20a: ; fd20a (3f:520a) - pikaemotion_pcm PikachuCry19 - pikaemotion_pikapic $17 - pikaemotion_subcmd PIKAEMOTION_SUBCMD_SHOWMAPVIEW - pikaemotion_subcmd PIKAEMOTION_SUBCMD_CHECKBILLSHOUSE - db $ff - -PikachuEmotion32_fd213: ; fd213 (3f:5213) - pikaemotion_pcm PikachuCry26 - pikaemotion_pikapic $17 - db $ff - -Pointer_fd218: ; fd218 (3f:5218) - db $00 - db $39, $01 - db $3e, $1e - db $3f - -Pointer_fd21e: ; fd21e (3f:521e) - db $00 - db $39, $00 - db $3e, $1e - db $3f - -Pointer_fd224: ; fd224 (3f:5224) - db $00 - db $3c, $07, $2f - db $3c, $07, $2f - db $3f - -Pointer_fd22c: ; fd22c (3f:522c) - db $3b, $1f, $03 - db $3f - -Pointer_fd230: ; fd230 (3f:5230) - db $00 - db $3c, $0f, $1f - db $3c, $0f, $1f - db $3f - -Pointer_fd238: ; fd238 (3f:5238) - db $00 - db $05, $07 - db $39, $00 - db $05, $07 - db $06, $07 - db $39, $00 - db $06, $07 - db $08, $07 - db $39, $00 - db $08, $07 - db $07, $07 - db $39, $00 - db $07, $07 - db $3f +INCLUDE "data/pikachu_emotions.asm" Func_fd252: ; fd252 (3f:5252) ld a, $40 diff --git a/engine/pikachu_pic_animation.asm b/engine/pikachu_pic_animation.asm index 226049f2..1ec102f1 100755 --- a/engine/pikachu_pic_animation.asm +++ b/engine/pikachu_pic_animation.asm @@ -62,26 +62,26 @@ StarterPikachuEmotionCommand_pikapic: ; fd9d0 (3f:59d0) ret Func_fd9e4: - call Func_fda2c + call PlacePikapicTextBoxBorder callab LoadOverworldPikachuFrontpicPalettes - call Func_fd9ff + call ResetPikaPicAnimBuffer call LoadCurrentPikaPicAnimScriptPointer call Func_fda9a - call Func_fda2c + call PlacePikapicTextBoxBorder call RunDefaultPaletteCommand ret -Func_fd9ff: - ld hl, wPikaPicAnimPointer - ld bc, $11 +ResetPikaPicAnimBuffer: + ld hl, wCurPikaMovementData + ld bc, wCurPikaMovementDataEnd - wCurPikaMovementData xor a call FillMemory ld hl, wPikaPicAnimObjectDataBufferSize - ld bc, $21 + ld bc, wPikaPicAnimObjectDataBufferEnd - wPikaPicAnimObjectDataBufferSize xor a call FillMemory - call Func_fe15c - ld hl, $64 + call ClearPikaPicUsedGFXBuffer + ld hl, 100 ld a, l ld [wPikaPicAnimTimer], a ld a, h @@ -92,7 +92,7 @@ Func_fd9ff: ld [wPikaPicTextboxStartY], a ret -Func_fda2c: +PlacePikapicTextBoxBorder: xor a ld [H_AUTOBGTRANSFERENABLED], a coord hl, 6, 5 @@ -1121,9 +1121,9 @@ DecompressRequestPikaPicAnimGFX: ; fe128 .failed ret -Func_fe15c: - ld hl, wNPCMovementDirections - ld bc, $11 +ClearPikaPicUsedGFXBuffer: + ld hl, wPikaPicUsedGFXCount + ld bc, wPikaPicUsedGFXEnd - wPikaPicUsedGFXCount xor a call FillMemory ret @@ -1146,7 +1146,7 @@ GetPikaPicVRAMAddressForNewGFX: CheckIfThereIsRoomForPikaPicAnimGFX: push bc push hl - ld hl, wNPCMovementDirections + 1 + ld hl, wPikaPicUsedGFX ld c, 8 .loop ld a, [hl] @@ -1169,12 +1169,12 @@ CheckIfThereIsRoomForPikaPicAnimGFX: .empty ld [hl], d inc hl - ld a, [wNPCMovementDirections] + ld a, [wPikaPicUsedGFXCount] add $80 ld [hl], a - ld a, [wNPCMovementDirections] + ld a, [wPikaPicUsedGFXCount] add e - ld [wNPCMovementDirections], a + ld [wPikaPicUsedGFXCount], a cp $80 jr z, .asm_fe1a7 jr nc, .failed @@ -1194,7 +1194,7 @@ LookUpTileOffsetForCurrentPikaPicAnimGFX: push bc push hl ld b, a - ld hl, wNPCMovementDirections + 1 + ld hl, wPikaPicUsedGFX ld c, 8 .loop ld a, [hli] @@ -1284,455 +1284,4 @@ GetDMGBGPalForPikaThunderbolt: call DelayFrames ret -Data_fe242: - db 4, %11000000 - db 4, %11100100 - db 4, %11000000 - db 4, %11100100 - db 4, %11000000 - db 4, %11100100 - db 4, %11000000 - db 4, %11100100 - db 4, %11000000 - db 4, %11100100 - db 4, %11000000 - db 4, %11100100 - db 4, %11000000 - db 4, %11100100 - db 4, %11000000 - db 4, %11100100 - db 4, %11000000 - db 4, %11100100 - db 4, %11000000 - db 4, %11100100 - db $ff - -Data_fe26b: ; fe26b (3f:626b) - pikapic_loadgfx Pic_e4000 - pikapic_loadgfx Pic_e49d1 - pikapic_loadgfx PikachuSprite - pikapic_object $1, $80, $0, $0 - pikapic_object $2, $b2, $5, $5 - pikapic_object $3, $b6, $5, $5 - pikapic_waitbgmap - pikapic_cry -Data_fe286: ; fe286 (3f:6286) - pikapic_waitbgmap - pikapic_jump Data_fe286 - -Data_fe28a: ; fe28a (3f:628a) - pikapic_setduration 40 - pikapic_loadgfx Pic_e4000 - pikapic_loadgfx GFX_e40cc - pikapic_object $4, $80, $0, $0 - pikapic_object $6, $99, $0, $0 - pikapic_waitbgmap - pikapic_cry PikachuCry3 -Data_fe2a0: ; fe2a0 (3f:62a0) - pikapic_waitbgmap - pikapic_jump Data_fe2a0 - -Data_fe2a4: ; fe2a4 (3f:62a4) - pikapic_setduration 44 - pikapic_loadgfx Pic_e411c - pikapic_loadgfx GFX_e41d2 - pikapic_object $4, $80, $0, $0 - pikapic_object $7, $99, $0, $0 - pikapic_waitbgmap - pikapic_cry -Data_fe2ba: ; fe2ba (3f:62ba) - pikapic_waitbgmap - pikapic_jump Data_fe2ba - -Data_fe2be: ; fe2be (3f:62be) - pikapic_setduration 80 - pikapic_loadgfx Pic_e4272 - pikapic_loadgfx GFX_e4323 - pikapic_object $4, $80, $0, $0 - pikapic_object $8, $99, $0, $0 - pikapic_waitbgmap - pikapic_cry -Data_fe2d4: ; fe2d4 (3f:62d4) - pikapic_waitbgmap - pikapic_jump Data_fe2d4 - -Data_fe2d8: ; fe2d8 (3f:62d8) - pikapic_setduration 70 - pikapic_loadgfx Pic_e4383 - pikapic_loadgfx GFX_e444b - pikapic_object $4, $80, $0, $0 - pikapic_object $9, $99, $0, $0 - pikapic_waitbgmap - pikapic_cry -Data_fe2ee: ; fe2ee (3f:62ee) - pikapic_waitbgmap - pikapic_jump Data_fe2ee - -Data_fe2f2: ; fe2f2 (3f:62f2) - pikapic_setduration 32 - pikapic_loadgfx Pic_e458b - pikapic_loadgfx GFX_e463b - pikapic_object $4, $80, $0, $0 - pikapic_object $a, $99, $0, $0 - pikapic_waitbgmap - pikapic_cry -Data_fe308: ; fe308 (3f:6308) - pikapic_waitbgmap - pikapic_jump Data_fe308 - -Data_fe30c: ; fe30c (3f:630c) - pikapic_setduration 50 - pikapic_loadgfx Pic_e467b - pikapic_loadgfx GFX_e472e - pikapic_object $4, $80, $0, $0 - pikapic_object $b, $99, $0, $0 - pikapic_waitbgmap - pikapic_cry PikachuCry38 -Data_fe322: ; fe322 (3f:6322) - pikapic_waitbgmap - pikapic_jump Data_fe322 - -Data_fe326: ; fe326 (3f:6326) - pikapic_setduration 58 - pikapic_loadgfx Pic_e476e - pikapic_loadgfx GFX_e4841 - pikapic_object $4, $80, $0, $0 - pikapic_object $c, $99, $0, $0 - pikapic_waitbgmap - pikapic_cry -Data_fe33c: ; fe33c (3f:633c) - pikapic_waitbgmap - pikapic_jump Data_fe33c - -Data_fe340: ; fe340 (3f:6340) - pikapic_setduration 44 - pikapic_loadgfx Pic_e49d1 - pikapic_loadgfx GFX_e4a99 - pikapic_object $4, $80, $0, $0 - pikapic_object $d, $99, $0, $0 - pikapic_waitbgmap - pikapic_cry -Data_fe356: ; fe356 (3f:6356) - pikapic_waitbgmap - pikapic_jump Data_fe356 - -Data_fe35a: ; fe35a (3f:635a) - pikapic_setduration 56 - pikapic_loadgfx Pic_e4b39 - pikapic_loadgfx GFX_e4bde - pikapic_object $4, $80, $0, $0 - pikapic_object $e, $99, $0, $0 - pikapic_waitbgmap - pikapic_cry -Data_fe370: ; fe370 (3f:6370) - pikapic_waitbgmap - pikapic_jump Data_fe370 - -Data_fe374: ; fe374 (3f:6374) - pikapic_setduration 56 - pikapic_loadgfx Pic_e4c3e - pikapic_loadgfx GFX_e4ce0 - pikapic_loadgfx GFX_e4e70 - pikapic_object $4, $80, $0, $0 - pikapic_object $10, $99, $0, $0 - pikapic_waitbgmap - pikapic_cry -Data_fe38c: ; fe38c (3f:638c) - pikapic_waitbgmap - pikapic_jump Data_fe38c - -Data_fe390: ; fe390 (3f:6390) - pikapic_setduration 100 - pikapic_loadgfx Pic_e5000 - pikapic_loadgfx GFX_e50af - pikapic_object $4, $80, $0, $0 - pikapic_object $11, $99, $0, $0 - pikapic_waitbgmap - pikapic_cry -Data_fe3a6: ; fe3a6 (3f:63a6) - pikapic_waitbgmap - pikapic_jump Data_fe3a6 - -Data_fe3aa: ; fe3aa (3f:63aa) - pikapic_setduration 50 - pikapic_loadgfx Pic_e523f - pikapic_loadgfx GFX_e52fe - pikapic_object $4, $80, $0, $0 - pikapic_object $12, $99, $0, $0 - pikapic_waitbgmap - pikapic_cry PikachuCry25 -Data_fe3c0: ; fe3c0 (3f:63c0) - pikapic_waitbgmap - pikapic_jump Data_fe3c0 - -Data_fe3c4: ; fe3c4 (3f:63c4) - pikapic_setduration 50 - pikapic_loadgfx Pic_e548e - pikapic_loadgfx GFX_e5541 - pikapic_object $4, $80, $0, $0 - pikapic_object $13, $99, $0, $0 - pikapic_waitbgmap - pikapic_cry -Data_fe3da: ; fe3da (3f:63da) - pikapic_waitbgmap - pikapic_jump Data_fe3da - -Data_fe3de: ; fe3de (3f:63de) - pikapic_setduration 40 - pikapic_loadgfx Pic_e56d1 - pikapic_loadgfx GFX_e5794 - pikapic_object $4, $80, $0, $0 - pikapic_object $14, $99, $0, $0 - pikapic_waitbgmap - pikapic_cry -Data_fe3f4: ; fe3f4 (3f:63f4) - pikapic_waitbgmap - pikapic_jump Data_fe3f4 - -Data_fe3f8: ; fe3f8 (3f:63f8) - pikapic_setduration 50 - pikapic_loadgfx Pic_e5924 - pikapic_loadgfx GFX_e59ed - pikapic_object $4, $80, $0, $0 - pikapic_object $15, $99, $0, $0 - pikapic_waitbgmap - pikapic_cry -Data_fe40e: ; fe40e (3f:640e) - pikapic_waitbgmap - pikapic_jump Data_fe40e - -Data_fe412: ; fe412 (3f:6412) - pikapic_setduration 32 - pikapic_loadgfx Pic_e5b7d - pikapic_loadgfx GFX_e5c4d - pikapic_object $4, $80, $0, $0 - pikapic_object $16, $99, $0, $0 - pikapic_waitbgmap - pikapic_cry -Data_fe428: ; fe428 (3f:6428) - pikapic_waitbgmap - pikapic_jump Data_fe428 - -Data_fe42c: ; fe42c (3f:642c) - pikapic_setduration 100 - pikapic_loadgfx Pic_e5ddd - pikapic_loadgfx GFX_e5e90 - pikapic_object $4, $80, $0, $0 - pikapic_object $17, $99, $0, $0 - pikapic_waitbgmap - pikapic_cry -Data_fe442: ; fe442 (3f:6442) - pikapic_waitbgmap - pikapic_jump Data_fe442 - -Data_fe446: ; fe446 (3f:6446) - pikapic_setduration 32 - pikapic_loadgfx GFX_e6020 - pikapic_loadgfx GFX_e61b0 - pikapic_object $5, $80, $0, $0 - pikapic_object $18, $99, $0, $0 - pikapic_waitbgmap - pikapic_cry PikachuCry18 -Data_fe45c: ; fe45c (3f:645c) - pikapic_waitbgmap - pikapic_jump Data_fe45c - -Data_fe460: ; fe460 (3f:6460) - pikapic_setduration 44 - pikapic_loadgfx Pic_e6340 - pikapic_loadgfx GFX_e63f7 - pikapic_object $4, $80, $0, $0 - pikapic_object $19, $99, $0, $0 - pikapic_waitbgmap - pikapic_cry -Data_fe476: ; fe476 (3f:6476) - pikapic_waitbgmap - pikapic_jump Data_fe476 - -Data_fe47a: ; fe47a (3f:647a) - pikapic_setduration 50 - pikapic_loadgfx Pic_e6587 - pikapic_loadgfx GFX_e6646 - pikapic_object $4, $80, $0, $0 - pikapic_object $1a, $99, $0, $0 - pikapic_waitbgmap - pikapic_cry -Data_fe490: ; fe490 (3f:6490) - pikapic_waitbgmap - pikapic_jump Data_fe490 - -Data_fe494: ; fe494 (3f:6494) - pikapic_setduration 40 - pikapic_loadgfx Pic_e67d6 - pikapic_loadgfx GFX_e682f - pikapic_loadgfx GFX_e69bf - pikapic_loadgfx GFX_e6b4f - pikapic_loadgfx GFX_e6cdf - pikapic_object $4, $80, $0, $0 - pikapic_object $1b, $99, $0, $0 - pikapic_waitbgmap - pikapic_cry PikachuCry20 -Data_fe4b0: ; fe4b0 (3f:64b0) - pikapic_waitbgmap - pikapic_jump Data_fe4b0 - -Data_fe4b4: ; fe4b4 (3f:64b4) - pikapic_setduration 40 - pikapic_loadgfx GFX_e6e6f - pikapic_loadgfx GFX_e6fff - pikapic_object $5, $80, $0, $0 - pikapic_object $1c, $99, $0, $0 - pikapic_waitbgmap - pikapic_cry -Data_fe4ca: ; fe4ca (3f:64ca) - pikapic_waitbgmap - pikapic_jump Data_fe4ca - -Data_fe4ce: ; fe4ce (3f:64ce) - pikapic_setduration 70 - pikapic_loadgfx GFX_e718f - pikapic_loadgfx GFX_e731f - pikapic_object $5, $80, $0, $0 - pikapic_object $1d, $99, $0, $0 - pikapic_waitbgmap - pikapic_cry -Data_fe4e4: ; fe4e4 (3f:64e4) - pikapic_waitbgmap - pikapic_jump Data_fe4e4 - -Data_fe4e8: ; fe4e8 (3f:64e8) - pikapic_setduration 60 - pikapic_loadgfx GFX_e74af - pikapic_loadgfx GFX_e763f - pikapic_object $5, $80, $0, $0 - pikapic_object $1e, $99, $0, $0 - pikapic_waitbgmap - pikapic_cry -Data_fe4fe: ; fe4fe (3f:64fe) - pikapic_waitbgmap - pikapic_jump Data_fe4fe - -Data_fe502: ; fe502 (3f:6502) - pikapic_setduration 50 - pikapic_loadgfx Pic_e77cf - pikapic_loadgfx GFX_e7863 - pikapic_loadgfx GFX_e79f3 - pikapic_object $4, $80, $0, $0 - pikapic_object $1f, $99, $0, $0 - pikapic_waitbgmap - pikapic_cry - pikapic_writebyte 13 - pikapic_waitbgmap - pikapic_thunderbolt - pikapic_ret - -Data_fe51f: ; fe51f (3f:651f) - pikapic_waitbgmap -Data_fe520: ; fe520 (3f:6520) - pikapic_setduration 100 - pikapic_loadgfx Pic_e5000 - pikapic_loadgfx GFX_e50af - pikapic_loadgfx GFX_e7b83 - pikapic_loadgfx GFX_e7d13 - pikapic_object $4, $80, $0, $0 - pikapic_object $20, $99, $0, $0 - pikapic_waitbgmap - pikapic_cry -Data_fe53a: ; fe53a (3f:653a) - pikapic_waitbgmap - pikapic_jump Data_fe53a - -Data_fe53e: ; fe53e (3f:653e) - pikapic_setduration 30 - pikapic_loadgfx Pic_f0abf - pikapic_loadgfx GFX_f0b64 - pikapic_object $4, $80, $0, $0 - pikapic_object $21, $99, $0, $0 - pikapic_waitbgmap - pikapic_cry -Data_fe554: ; fe554 (3f:6554) - pikapic_waitbgmap - pikapic_jump Data_fe554 - -Data_fe558: ; fe558 (3f:6558) - pikapic_setduration 64 - pikapic_loadgfx Pic_f0cf4 - pikapic_loadgfx GFX_f0d82 - pikapic_object $4, $80, $0, $0 - pikapic_object $22, $99, $0, $0 - pikapic_waitbgmap - pikapic_cry -Data_fe56e: ; fe56e (3f:656e) - pikapic_waitbgmap - pikapic_jump Data_fe56e - -PikaPicAnimGFXHeaders: -pikapicanimgfx: MACRO -\2_id:: - db \1 - dba \2 - endm - - dbbw $01, $39, $0000 - pikapicanimgfx -1, Pic_e4000 ; 01 - pikapicanimgfx 5, GFX_e40cc ; 02 - pikapicanimgfx -1, Pic_e411c ; 03 - pikapicanimgfx 10, GFX_e41d2 ; 04 - pikapicanimgfx -1, Pic_e4272 ; 05 - pikapicanimgfx 6, GFX_e4323 ; 06 - pikapicanimgfx -1, Pic_e4383 ; 07 - pikapicanimgfx 20, GFX_e444b ; 08 - pikapicanimgfx -1, Pic_e458b ; 09 - pikapicanimgfx 4, GFX_e463b ; 0a - pikapicanimgfx -1, Pic_e467b ; 0b - pikapicanimgfx 4, GFX_e472e ; 0c - pikapicanimgfx -1, Pic_e476e ; 0d - pikapicanimgfx 25, GFX_e4841 ; 0e - pikapicanimgfx -1, Pic_e49d1 ; 0f - pikapicanimgfx 10, GFX_e4a99 ; 00 - pikapicanimgfx -1, Pic_e4b39 ; 11 - pikapicanimgfx 6, GFX_e4bde ; 12 - pikapicanimgfx -1, Pic_e4c3e ; 13 - pikapicanimgfx 25, GFX_e4ce0 ; 14 - pikapicanimgfx 25, GFX_e4e70 ; 15 - pikapicanimgfx -1, Pic_e5000 ; 16 - pikapicanimgfx 25, GFX_e50af ; 17 - pikapicanimgfx -1, Pic_e523f ; 18 - pikapicanimgfx 25, GFX_e52fe ; 19 - pikapicanimgfx -1, Pic_e548e ; 1a - pikapicanimgfx 25, GFX_e5541 ; 1b - pikapicanimgfx -1, Pic_e56d1 ; 1c - pikapicanimgfx 25, GFX_e5794 ; 1d - pikapicanimgfx -1, Pic_e5924 ; 1e - pikapicanimgfx 25, GFX_e59ed ; 1f - pikapicanimgfx -1, Pic_e5b7d ; 20 - pikapicanimgfx 25, GFX_e5c4d ; 21 - pikapicanimgfx -1, Pic_e5ddd ; 22 - pikapicanimgfx 25, GFX_e5e90 ; 23 - pikapicanimgfx 25, GFX_e6020 ; 24 - pikapicanimgfx 25, GFX_e61b0 ; 25 - pikapicanimgfx -1, Pic_e6340 ; 26 - pikapicanimgfx 25, GFX_e63f7 ; 27 - pikapicanimgfx -1, Pic_e6587 ; 28 - pikapicanimgfx 25, GFX_e6646 ; 29 - pikapicanimgfx -1, Pic_e67d6 ; 2a - pikapicanimgfx 25, GFX_e682f ; 2b - pikapicanimgfx 25, GFX_e69bf ; 2c - pikapicanimgfx 25, GFX_e6b4f ; 2d - pikapicanimgfx 25, GFX_e6cdf ; 2e - pikapicanimgfx 25, GFX_e6e6f ; 2f - pikapicanimgfx 25, GFX_e6fff ; 30 - pikapicanimgfx 25, GFX_e718f ; 31 - pikapicanimgfx 25, GFX_e731f ; 32 - pikapicanimgfx 25, GFX_e74af ; 33 - pikapicanimgfx 25, GFX_e763f ; 34 - pikapicanimgfx -1, Pic_e77cf ; 35 - pikapicanimgfx 25, GFX_e7863 ; 36 - pikapicanimgfx 25, GFX_e79f3 ; 37 - pikapicanimgfx 25, GFX_e7b83 ; 38 - pikapicanimgfx 25, GFX_e7d13 ; 39 - pikapicanimgfx -1, Pic_f0abf ; 3a - pikapicanimgfx 25, GFX_f0b64 ; 3b - pikapicanimgfx -1, Pic_f0cf4 ; 3c - pikapicanimgfx 25, GFX_f0d82 ; 3d - pikapicanimgfx 24, PikachuSprite ; 3e +INCLUDE "data/pikachu_pic_animation.asm" diff --git a/macros.asm b/macros.asm index b0c38140..3d51f030 100644 --- a/macros.asm +++ b/macros.asm @@ -942,3 +942,9 @@ pikapic_waitbgmap: macro ; d pikapic_ret: macro ; e db pikapic_ret_command endm + +pikapic_looptofinish: macro +.loop\@ + pikapic_waitbgmap + pikapic_jump .loop\@ + endm diff --git a/wram.asm b/wram.asm index 6dd0cdba..3136ffd8 100755 --- a/wram.asm +++ b/wram.asm @@ -790,8 +790,11 @@ wAnimationType:: ; cc5b ; values between 0-6. Shake screen horizontally, shake screen vertically, blink Pokemon... wNPCMovementDirections:: ; cc5b + +wPikaPicUsedGFXCount:: ; cc5b ds 1 +wPikaPicUsedGFX:: ; cc5c wDexRatingNumMonsOwned:: ; cc5c ds 1 @@ -804,7 +807,9 @@ wSlotMachineSavedROMBank:: ; cc5e ; ROM back to return to when the player is done with the slot machine ds 1 - ds 26 + ds 13 +wPikaPicUsedGFXEnd:: ; cc6c + ds 13 wAnimPalette:: ; cc79 ds 1 @@ -833,7 +838,9 @@ wPikaPicAnimObjectDataBuffer:: ; cc98 wNumStepsToTake:: ; cca1 ; used in Pallet Town scripted movement - ds 49 + ds 23 +wPikaPicAnimObjectDataBufferEnd:: ;ccb8 + ds 26 wRLEByteCount:: ; ccd2 ds 1 @@ -2834,7 +2841,9 @@ wd458:: ds 1 ; d458 wCurPikaPicAnimObject:: ; d459 wCurPikaPicAnimObjectIndex:: ds 1 wCurPikaPicAnimObjectGraphicID:: dw - ds 19 + ds 2 +wCurPikaMovementDataEnd:: + ds 17 wPikachuHappiness:: ds 1 ; d46f wPikachuMood:: ds 1 ; d470 -- cgit v1.3.1-sl0p From 9346a39a8a2eb17f92cdd439ecc122201046e680 Mon Sep 17 00:00:00 2001 From: pikalaxalt Date: Tue, 7 Jun 2016 22:18:07 -0400 Subject: Printer labels --- engine/bank3d.asm | 142 +++++++++++++++-------------- engine/battle/core.asm | 2 +- engine/diploma_3a.asm | 6 +- engine/menu/bills_pc.asm | 2 +- engine/menu/pokedex.asm | 80 +++++++++++----- engine/oak_speech.asm | 6 +- engine/printer.asm | 218 ++++++++++++++++++++++---------------------- engine/printer/serial.asm | 180 ++++++++++++++++++------------------ engine/surfing_minigame.asm | 6 +- engine/titlescreen.asm | 137 +++++++++++++++------------- engine/titlescreen2.asm | 2 +- scripts/beach_house.asm | 2 +- scripts/beach_house2.asm | 2 +- scripts/celadonmansion3.asm | 2 +- scripts/fanclub.asm | 2 +- wram.asm | 36 ++++---- 16 files changed, 437 insertions(+), 388 deletions(-) (limited to 'wram.asm') diff --git a/engine/bank3d.asm b/engine/bank3d.asm index f86bcf21..bf84e096 100644 --- a/engine/bank3d.asm +++ b/engine/bank3d.asm @@ -3,49 +3,49 @@ INCLUDE "engine/battle/link_battle_versus_text.asm" INCLUDE "engine/battle/unused_stats_functions.asm" INCLUDE "engine/battle/scroll_draw_trainer_pic.asm" -Func_f429f:: ; f429f (3d:429f) +StarterPikachuBattleEntranceAnimation: ; f429f (3d:429f) coord hl, 0, 5 - ld c, $0 -.asm_f42a4 + ld c, 0 +.loop1 inc c ld a, c - cp $9 + cp 9 ret z - ld d, $5b + ld d, 7 * 13 push bc push hl -.asm_f42ad - call Func_f42c2 +.loop2 + call .PlaceColumn dec hl ld a, d - sub $7 + sub 7 ld d, a dec c - jr nz, .asm_f42ad - ld c, $2 + jr nz, .loop2 + ld c, 2 call DelayFrames pop hl pop bc inc hl - jr .asm_f42a4 + jr .loop1 -Func_f42c2:: ; f42c2 (3d:f42c2) +.PlaceColumn: ; f42c2 (3d:f42c2) push hl push de push bc - ld e, $7 -.loop + ld e, 7 +.loop3 ld a, d - cp $31 - jr nc, .asm_f42ce + cp 7 * 7 + jr nc, .okay ld a, $7f -.asm_f42ce +.okay ld [hl], a - ld bc, $14 + ld bc, SCREEN_WIDTH add hl, bc inc d dec e - jr nz, .loop + jr nz, .loop3 pop bc pop de pop hl @@ -172,56 +172,56 @@ PikachuMoods: ; f43a6 (3d:43a6) db $6c ; Unknown (d = 10) db $00 ; Unknown (d = 11) -RedPicBack:: INCBIN "pic/trainer/redb.pic" -OldManPic:: INCBIN "pic/trainer/oldman.pic" -ProfOakPicBack:: INCBIN "pic/ytrainer/prof.oakb.pic" +RedPicBack: INCBIN "pic/trainer/redb.pic" +OldManPic: INCBIN "pic/trainer/oldman.pic" +ProfOakPicBack: INCBIN "pic/ytrainer/prof.oakb.pic" -Func_f453f:: ; f453f (3d:453f) +LoadYellowTitleScreenGFX: ; f453f (3d:453f) ld hl, PokemonLogoGraphics ld de, vChars2 - ld bc, $730 + ld bc, 115 * $10 ld a, BANK(PokemonLogoGraphics) ; redundant because this function is in bank3d call FarCopyData - ld hl, YellowLogoGraphics+$230 - ld de, vChars0+$fd0 - ld bc, $30 + ld hl, YellowLogoGraphics + 35 * $10 + ld de, vChars0 + 253 * $10 + ld bc, 3 * $10 ld a, BANK(YellowLogoGraphics) call FarCopyData - ld hl, YellowLogoGraphics+$260 + ld hl, YellowLogoGraphics + 38 * $10 ld de, vChars1 - ld bc, $400 + ld bc, 64 * $10 ld a, BANK(YellowLogoGraphics) call FarCopyData - ld hl, YellowLogoGraphics+$660 - ld de, vChars0+$f00 - ld bc, $c0 + ld hl, YellowLogoGraphics + 102 * $10 + ld de, vChars0 + 240 * $10 + ld bc, 12 * $10 ld a, BANK(YellowLogoGraphics) call FarCopyData ret -Func_f4578:: ; f4578 (3d:4578) +TitleScreen_PlacePokemonLogo: ; f4578 (3d:4578) coord hl, 2, 1 - ld de, Pointer_f45f9 - ld bc, 7 << 8 | 16 ; 16x7 (xy) - call CopyScreenArea + ld de, TitleScreenPokemonLogoTilemap + lb bc, 7, 16 + call Bank3D_CopyBox ret -Func_f4585:: ; f4585 (3d:4585) +TitleScreen_PlacePikaSpeechBubble: ; f4585 (3d:4585) coord hl, 6, 4 - ld de, Pointer_f4673 - ld bc, 4 << 8 | 7 ; 7x4 (xy) - call CopyScreenArea + ld de, TitleScreenPikaBubbleTilemap + lb bc, 4, 7 + call Bank3D_CopyBox coord hl, 9, 8 ld [hl], $64 inc hl ld [hl], $65 ret -Func_f459a:: ; f459a (3d:459a) +TitleScreen_PlacePikachu: ; f459a (3d:459a) coord hl, 4, 8 - ld de, Pointer_f468f - ld bc, 9 << 8 | 12 ; 12x9 (xy) - call CopyScreenArea + ld de, TitleScreenPikachuTilemap + lb bc, 9, 12 + call Bank3D_CopyBox coord hl, 16, 10 ld [hl], $96 coord hl, 16, 11 @@ -230,13 +230,13 @@ Func_f459a:: ; f459a (3d:459a) ld [hl], $a7 coord hl, 16, 13 ld [hl], $b1 - ld hl, Pointer_f45c7 + ld hl, TitleScreenPikachuEyesOAMData ld de, wOAMBuffer ld bc, $20 call CopyData ret -Pointer_f45c7: ; f45c7 (3d:45c7) +TitleScreenPikachuEyesOAMData: ; f45c7 (3d:45c7) db $60, $40, $f1, $22 db $60, $48, $f0, $22 db $68, $40, $f3, $22 @@ -246,25 +246,26 @@ Pointer_f45c7: ; f45c7 (3d:45c7) db $68, $60, $f2, $02 db $68, $68, $f3, $02 -CopyScreenArea:: ; f45e7 (3d:45e7) +Bank3D_CopyBox: ; f45e7 (3d:45e7) ; copy cxb (xy) screen area from de to hl +.row push bc push hl -.loop +.col ld a, [de] inc de ld [hli], a dec c - jr nz, .loop + jr nz, .col pop hl - ld bc, $14 + ld bc, SCREEN_WIDTH add hl, bc pop bc dec b - jr nz, CopyScreenArea + jr nz, .row ret -Pointer_f45f9: ; f45f9 (3d:45f9) +TitleScreenPokemonLogoTilemap: ; f45f9 (3d:45f9) ; 16x7 (xy) db $f4, $f4, $f4, $f4, $f4, $f4, $49, $f4, $72, $30, $f4, $f4, $f4, $f4, $f4, $f4 db $fd, $01, $02, $03, $04, $05, $06, $07, $08, $09, $0a, $0b, $f4, $0d, $0e, $0f @@ -274,17 +275,18 @@ Pointer_f45f9: ; f45f9 (3d:45f9) db $f4, $41, $42, $43, $44, $45, $46, $47, $48, $f4, $4a, $4b, $4c, $4d, $4e, $4f db $f4, $6a, $6b, $6c, $6d, $f4, $f4, $f4, $f4, $f4, $f4, $6e, $6f, $70, $71, $f4 -Pointer_f4669:: ; f4669 (3d:4669) +Pointer_f4669: ; f4669 (3d:4669) +; Unreferenced db $47, $48, $49, $4a, $4b, $4c, $4d, $4e, $4f, $5f -Pointer_f4673:: ; f4673 (3d:4673) +TitleScreenPikaBubbleTilemap: ; f4673 (3d:4673) ; 7x4 (xy) db $24, $25, $66, $67, $68, $69, $2a db $50, $51, $52, $53, $54, $55, $56 db $57, $58, $59, $5a, $5b, $5c, $5d db $6d, $5e, $5f, $60, $61, $62, $63 -Pointer_f468f:: ; f468f (3d:468f) +TitleScreenPikachuTilemap: ; f468f (3d:468f) ; 12x9 (xy) db $80, $81, $82, $83, $00, $00, $00, $00, $84, $85, $86, $87 db $88, $89, $8a, $8b, $8c, $8d, $8d, $8e, $8f, $8a, $90, $91 @@ -298,15 +300,17 @@ Pointer_f468f:: ; f468f (3d:468f) ; f46f9 (3d:46f9) PokemonLogoGraphics: INCBIN "gfx/pokemon_logo.2bpp" +PokemonLogoGraphicsEnd: YellowLogoGraphics: INCBIN "gfx/yellow_titlescreen.2bpp" +YellowLogoGraphicsEnd: INCLUDE "engine/menu/link_menu.asm" -HandleMenuInputDouble:: ; f5a40 (3d:5a40) +HandleMenuInputDouble: ; f5a40 (3d:5a40) xor a ld [wPartyMenuAnimMonEnabled], a -HandleMenuInputPokemonSelectionDouble:: ; f5a44 (3d:5a44) +HandleMenuInputPokemonSelectionDouble: ; f5a44 (3d:5a44) ld a, [H_DOWNARROWBLINKCNT1] push af ld a, [H_DOWNARROWBLINKCNT2] @@ -318,7 +322,7 @@ HandleMenuInputPokemonSelectionDouble:: ; f5a44 (3d:5a44) .loop1 xor a ld [wAnimCounter], a ; counter for pokemon shaking animation - call Func_f5ab0 + call .UpdateCursorTile call JoypadLowSensitivity ld a, [hJoy5] and a ; was a key pressed? @@ -376,7 +380,7 @@ HandleMenuInputPokemonSelectionDouble:: ; f5a44 (3d:5a44) ld a, [hJoy5] ret -Func_f5ab0:: ; f5ab0 (3d:5ab0) +.UpdateCursorTile: ; f5ab0 (3d:5ab0) ld a, [wTopMenuItemY] and a jr z, .asm_f5ac0 @@ -427,12 +431,12 @@ Func_f5ab0:: ; f5ab0 (3d:5ab0) ld a, l ld [wMenuCursorLocation], a ld a, h - ld [wMenuCursorLocation+1], a + ld [wMenuCursorLocation + 1], a ld a, [wCurrentMenuItem] ld [wLastMenuItem], a ret -PrintStrengthTxt:: ; f5b06 (3d:5b06) +PrintStrengthTxt: ; f5b06 (3d:5b06) ld hl, wd728 set 0, [hl] ld hl, Text_f5b17 @@ -440,7 +444,7 @@ PrintStrengthTxt:: ; f5b06 (3d:5b06) ld hl, Text_f5b28 jp PrintText -Text_f5b17:: ; f5b17 (3d:5b17) +Text_f5b17: ; f5b17 (3d:5b17) TX_FAR _UsedStrengthText ; 2d:417e TX_ASM ld a, [wcf91] @@ -448,11 +452,11 @@ Text_f5b17:: ; f5b17 (3d:5b17) call Delay3 jp TextScriptEnd -Text_f5b28:: ; f5b28 (3d:5b28) +Text_f5b28: ; f5b28 (3d:5b28) TX_FAR _CanMoveBouldersText ; 2d:4193 db "@" -CheckForForcedBikeSurf:: ; f5b2d (3d:5b2d) +CheckForForcedBikeSurf: ; f5b2d (3d:5b2d) ld hl, wd728 set 1, [hl] ld a, [wd732] @@ -476,19 +480,19 @@ CheckForForcedBikeSurf:: ; f5b2d (3d:5b2d) ld hl, CyclingIsFunText jp PrintText -CoordsData_f5b64:: ; f5b64 (3d:5b64) +CoordsData_f5b64: ; f5b64 (3d:5b64) db 11, 07 db $ff -CurrentTooFastText:: ; f5b67 (3d:5b67) +CurrentTooFastText: ; f5b67 (3d:5b67) TX_FAR _CurrentTooFastText ; 2d:41ab db "@" -CyclingIsFunText:: ; f5b6c (3d:5b6c) +CyclingIsFunText: ; f5b6c (3d:5b6c) TX_FAR _CyclingIsFunText ; 2d:41ca db "@" -AddItemToInventory_:: ; f5b70 (3d:5b70) +AddItemToInventory_: ; f5b70 (3d:5b70) ld a, [wItemQuantity] ; a = item quantity push af push bc @@ -640,7 +644,7 @@ BlankLeaderNames: INCBIN "gfx/blank_leader_names.2bpp" CircleTile: INCBIN "gfx/circle_tile.2bpp" BadgeNumbersTileGraphics: INCBIN "gfx/badge_numbers.2bpp" -ReadSuperRodData:: ; f5ea4 (3d:5ea4) +ReadSuperRodData: ; f5ea4 (3d:5ea4) ld a, [wCurMap] ld c, a ld hl, FishingSlots diff --git a/engine/battle/core.asm b/engine/battle/core.asm index b69a88c5..cb81bf04 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -1898,7 +1898,7 @@ SendOutMon: ; 3ccfb (f:4cfb) ld [H_WHOSETURN], a ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a - callab Func_f429f + callab StarterPikachuBattleEntranceAnimation callab IsPlayerPikachuAsleepInParty ld e, $24 jr c, .asm_3cd81 diff --git a/engine/diploma_3a.asm b/engine/diploma_3a.asm index c8a7e740..520d9f96 100755 --- a/engine/diploma_3a.asm +++ b/engine/diploma_3a.asm @@ -82,11 +82,11 @@ Func_e9ad3: ld de, Tilemap_e9b3e coord hl, 6, 2 lb bc, 10, 12 - call Func_e925d + call Diploma_Surfing_CopyBox ld de, Tilemap_e9bb6 coord hl, 5, 13 lb bc, 1, 11 - call Func_e925d + call Diploma_Surfing_CopyBox ld de, String_e9bd5 coord hl, 2, 15 call PlaceString @@ -105,7 +105,7 @@ Func_e9ad3: ld de, TileMap_e9bc1 coord hl, 2, 0 lb bc, 4, 5 - call Func_e925d + call Diploma_Surfing_CopyBox ret Tilemap_e9b3e: diff --git a/engine/menu/bills_pc.asm b/engine/menu/bills_pc.asm index 280b9df8..9055a9d2 100644 --- a/engine/menu/bills_pc.asm +++ b/engine/menu/bills_pc.asm @@ -204,7 +204,7 @@ ExitBillsPC: ; 2153e (8:553e) ret BillsPCPrintBox: ; 21562 (8:5562) - callab Func_e8d35 + callab PrintPCBox jp BillsPCMenu BillsPCDeposit: ; 2156d (8:556d) diff --git a/engine/menu/pokedex.asm b/engine/menu/pokedex.asm index 298816c1..c8a37f2e 100755 --- a/engine/menu/pokedex.asm +++ b/engine/menu/pokedex.asm @@ -13,7 +13,7 @@ ShowPokedexMenu: ; 40000 (10:4000) ld [hJoy7], a .setUpGraphics callab LoadPokedexTilePatterns -.asm_40025 +.loop ld b, SET_PAL_GENERIC call RunPaletteCommand .doPokemonListMenu @@ -44,6 +44,7 @@ ShowPokedexMenu: ; 40000 (10:4000) call GBPalWhiteOutWithDelay3 call RunDefaultPaletteCommand jp ReloadMapData + .goToSideMenu call HandlePokedexSideMenu dec b @@ -51,7 +52,7 @@ ShowPokedexMenu: ; 40000 (10:4000) dec b jr z, .doPokemonListMenu ; if pokemon not seen or player pressed B button dec b - jr z, .asm_40025 + jr z, .loop jp .setUpGraphics ; if pokemon data or area was shown ; handles the menu on the lower right in the pokedex screen @@ -133,6 +134,7 @@ HandlePokedexSideMenu: ; 40070 (10:4070) call DrawTileLine ; cover up the menu cursor in the pokemon list pop bc ret + .buttonBPressed push bc coord hl, 15, 8 @@ -141,20 +143,24 @@ HandlePokedexSideMenu: ; 40070 (10:4070) call DrawTileLine ; cover up the menu cursor in the side menu pop bc jr .exitSideMenu + .choseData call ShowPokedexDataInternal ld b, 0 jr .exitSideMenu + ; play pokemon cry .choseCry ld a, [wd11e] call GetCryData call PlaySound jr .handleMenuInput + .choseArea predef LoadTownMap_Nest ; display pokemon areas ld b, 0 jr .exitSideMenu + .chosePrint ld a, [hTilesetType] push af @@ -162,7 +168,7 @@ HandlePokedexSideMenu: ; 40070 (10:4070) ld [hTilesetType], a ld a, [wd11e] ld [wcf91], a - callab Func_e8b74 + callab PrintPokedexEntry xor a ld [H_AUTOBGTRANSFERENABLED], a call ClearScreen @@ -174,17 +180,17 @@ HandlePokedexSideMenu: ; 40070 (10:4070) ; handles the list of pokemon on the left of the pokedex screen ; sets carry flag if player presses A, unsets carry flag if player presses B HandlePokedexListMenu: ; 40140 (10:4140) - call Func_401c2 + call Pokedex_DrawInterface .loop - call Func_4027c + call Pokedex_PlacePokemonList call GBPalNormal call HandleMenuInput - bit 1, a ; was the B button pressed? + bit BIT_B_BUTTON, a ; was the B button pressed? jp nz, .buttonBPressed - bit 0, a ; was the A button pressed? + bit BIT_A_BUTTON, a ; was the A button pressed? jp nz, .buttonAPressed .checkIfUpPressed - bit 6, a ; was Up pressed? + bit BIT_D_UP, a ; was Up pressed? jr z, .checkIfDownPressed .upPressed ; scroll up one row ld a, [wListScrollOffset] @@ -193,8 +199,9 @@ HandlePokedexListMenu: ; 40140 (10:4140) dec a ld [wListScrollOffset], a jp .loop + .checkIfDownPressed - bit 7, a ; was Down pressed? + bit BIT_D_DOWN, a ; was Down pressed? jr z, .checkIfRightPressed .downPressed ; scroll down one row ld a, [wDexMaxSeenMon] @@ -208,8 +215,9 @@ HandlePokedexListMenu: ; 40140 (10:4140) inc a ld [wListScrollOffset], a jp .loop + .checkIfRightPressed - bit 4, a ; was Right pressed? + bit BIT_D_RIGHT, a ; was Right pressed? jr z, .checkIfLeftPressed .rightPressed ; scroll down 7 rows ld a, [wDexMaxSeenMon] @@ -226,8 +234,9 @@ HandlePokedexListMenu: ; 40140 (10:4140) ld a, b ld [wListScrollOffset], a jp .loop + .checkIfLeftPressed ; scroll up 7 rows - bit 5, a ; was Left pressed? + bit BIT_D_LEFT, a ; was Left pressed? jr z, .buttonAPressed .leftPressed ld a, [wListScrollOffset] @@ -237,14 +246,16 @@ HandlePokedexListMenu: ; 40140 (10:4140) xor a ld [wListScrollOffset], a jp .loop + .buttonAPressed scf ret + .buttonBPressed and a ret -Func_401c2: ; 401c2 (10:41c2) +Pokedex_DrawInterface: ; 401c2 (10:41c2) xor a ld [H_AUTOBGTRANSFERENABLED], a ; draw the horizontal line separating the seen and owned amounts from the menu @@ -300,6 +311,7 @@ Func_401c2: ; 401c2 (10:41c2) dec c jr nz, .maxSeenPokemonInnerLoop jr .maxSeenPokemonLoop + .storeMaxSeenPokemon ld a, b ld [wDexMaxSeenMon], a @@ -333,7 +345,7 @@ PokedexMenuItemsText: ; 40264 (10:4264) next "PRNT" next "QUIT@" -Func_4027c: ; 4027c (10:427c) +Pokedex_PlacePokemonList: ; 4027c (10:427c) xor a ld [H_AUTOBGTRANSFERENABLED], a coord hl, 4, 2 @@ -381,6 +393,7 @@ Func_4027c: ; 4027c (10:427c) jr nz, .getPokemonName ; if the player has seen the pokemon ld de, .dashedLine ; print a dashed line in place of the name if the player hasn't seen the pokemon jr .skipGettingName + .dashedLine ; for unseen pokemon in the list db "----------@" .getPokemonName @@ -442,8 +455,8 @@ ShowPokedexDataInternal: ; 40323 (10:4323) call RunPaletteCommand pop af ld [wd11e], a - call Func_4039c - call c, Func_404ae + call DrawDexEntryOnScreen + call c, Pokedex_PrintFlavorTextAtRow11 .waitForButtonPress call JoypadLowSensitivity ld a, [hJoy5] @@ -461,6 +474,7 @@ ShowPokedexDataInternal: ; 40323 (10:4323) ld a, $77 ; max volume ld [rNR50], a ret + HeightWeightText: ; 40370 (10:4370) db "HT ?", $60, "??", $61 @@ -478,22 +492,27 @@ PokedexDataDividerLine: ; 40387 (10:4387) db $6B, $69, $6B, $69, $6A db "@" -Func_4039c: ; 4039c (10:439c) +DrawDexEntryOnScreen: ; 4039c (10:439c) call ClearScreen + coord hl, 0, 0 ld de, 1 lb bc, $64, SCREEN_WIDTH call DrawTileLine ; draw top border + coord hl, 0, 17 ld b, $6f call DrawTileLine ; draw bottom border + coord hl, 0, 1 ld de, 20 lb bc, $66, $10 call DrawTileLine ; draw left border + coord hl, 19, 1 ld b, $67 call DrawTileLine ; draw right border + ld a, $63 ; upper left corner tile Coorda 0, 0 ld a, $65 ; upper right corner tile @@ -501,16 +520,21 @@ Func_4039c: ; 4039c (10:439c) ld a, $6c ; lower left corner tile Coorda 0, 17 ld a, $6e ; lower right corner tile + Coorda 19, 17 coord hl, 0, 9 + ld de, PokedexDataDividerLine call PlaceString ; draw horizontal divider line + coord hl, 9, 6 ld de, HeightWeightText call PlaceString + call GetMonName coord hl, 9, 2 call PlaceString + ld hl, PokedexEntryPointers ld a, [wd11e] dec a @@ -521,14 +545,17 @@ Func_4039c: ; 4039c (10:439c) ld a, [hli] ld e, a ld d, [hl] ; de = address of pokedex entry + coord hl, 9, 4 call PlaceString ; print species name + ld h, b ld l, c push de ld a, [wd11e] push af call IndexToPokedex + coord hl, 2, 8 ld a, "№" ld [hli], a @@ -537,6 +564,7 @@ Func_4039c: ; 4039c (10:439c) ld de, wd11e lb bc, LEADING_ZEROES | 1, 3 call PrintNumber ; print pokedex number + ld hl, wPokedexOwned call IsPokemonBitSet pop af @@ -544,10 +572,12 @@ Func_4039c: ; 4039c (10:439c) ld a, [wcf91] ld [wd0b5], a pop de + push af push bc push de push hl + call Delay3 call GBPalNormal call GetMonHeader ; load pokemon picture location @@ -555,13 +585,16 @@ Func_4039c: ; 4039c (10:439c) call LoadFlippedFrontSpriteByMonIndex ; draw pokemon picture ld a, [wcf91] call PlayCry ; play pokemon cry + pop hl pop de pop bc pop af + ld a, c and a ret z ; if the pokemon has not been owned, don't print the height, weight, or description + inc de ; de = address of feet (height) ld a, [de] ; reads feet, but a is overwritten without being used coord hl, 12, 6 @@ -617,9 +650,9 @@ Func_4039c: ; 4039c (10:439c) scf ret -Func_404ae: ; 404ae (10:44ae) +Pokedex_PrintFlavorTextAtRow11: ; 404ae (10:44ae) coord bc, 1, 11 -Func_404b1: ; 404b1 (10:44b1) +Pokedex_PrintFlavorTextAtBC: ; 404b1 (10:44b1) ld a, 2 ld [$fff9], a call TextCommandProcessor ; print pokedex description text @@ -627,7 +660,7 @@ Func_404b1: ; 404b1 (10:44b1) ld [$fff9], a ret -Func_404bc: ; 404bc (10:44bc) +Pokedex_PrepareDexEntryForPrinting: ; 404bc (10:44bc) coord hl, 0, 0 ld de, SCREEN_WIDTH lb bc, $66, $d @@ -643,19 +676,20 @@ Func_404bc: ; 404bc (10:44bc) Coorda 0, 13 ld a, $6e Coorda 19, 13 - ld a, [wOverworldMap+$40d] + ld a, [wPrinterPokedexEntryTextPointer] ld l, a - ld a, [wOverworldMap+$40e] + ld a, [wPrinterPokedexEntryTextPointer + 1] ld h, a coord bc, 1, 1 ld a, [hFlags_0xFFFA] set 3, a ld [hFlags_0xFFFA], a - call Func_404b1 + call Pokedex_PrintFlavorTextAtBC ld a, [hFlags_0xFFFA] res 3, a ld [hFlags_0xFFFA], a ret + ; draws a line of tiles ; INPUT: @@ -714,4 +748,4 @@ IndexToPokedex: ; 4109d (10:509d) pop bc ret -INCLUDE "data/pokedex_order.asm" \ No newline at end of file +INCLUDE "data/pokedex_order.asm" diff --git a/engine/oak_speech.asm b/engine/oak_speech.asm index 6b43574a..346df99b 100755 --- a/engine/oak_speech.asm +++ b/engine/oak_speech.asm @@ -16,9 +16,9 @@ SetDefaultNames: ; 5e27 (1:5e27) xor a call FillMemory xor a - ld [wd495], a - ld [wd496], a - ld [wd497], a + ld [wSurfingMinigameHiScore], a + ld [wSurfingMinigameHiScore + 1], a + ld [wSurfingMinigameHiScore + 2], a pop af ld [wPrinterSettings], a pop af diff --git a/engine/printer.asm b/engine/printer.asm index 38730aa1..929173db 100644 --- a/engine/printer.asm +++ b/engine/printer.asm @@ -11,7 +11,7 @@ INCLUDE "engine/printer/serial.asm" -Func_e8b74: ; e8b74 (3a:4b74) +PrintPokedexEntry: ; e8b74 (3a:4b74) ld a, [wUpdateSpritesEnabled] push af xor a @@ -26,29 +26,29 @@ Func_e8b74: ; e8b74 (3a:4b74) ld [rIE], a xor a ld [H_AUTOBGTRANSFERENABLED], a - call Func_e8c30 - call Func_e8785 - ld a, [wcaf9] + call Printer_GetDexEntryRegisters + call Printer_StartTransmission + ld a, [wPrinterPokedexMonIsOwned] and a - jr z, .asm_e8b9e - ld a, $10 - jr .asm_e8ba0 + jr z, .not_caught + ld a, 16 + jr .got_size -.asm_e8b9e - ld a, $13 -.asm_e8ba0 +.not_caught + ld a, 19 +.got_size ld [wcae2], a call Printer_CopyTileMapToPrinterTileBuffer call ClearScreen - callab Func_401c2 - callab Func_4027c + callab Pokedex_DrawInterface + callab Pokedex_PlacePokemonList ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a - call Func_e8c0c - jr c, .asm_e8bf4 - ld a, [wcaf9] + call .TryPrintPage + jr c, .finish_printing + ld a, [wPrinterPokedexMonIsOwned] and a - jr z, .asm_e8bf4 + jr z, .finish_printing xor a ld [wPrinterConnectionOpen], a ld [wPrinterOpcode], a @@ -57,17 +57,17 @@ Func_e8b74: ; e8b74 (3a:4b74) call SaveScreenTilesToBuffer1 xor a ld [H_AUTOBGTRANSFERENABLED], a - call Func_e8c50 + call Printer_PrepareDexEntryForPrinting ld a, $7 - call Func_e8785 + call Printer_StartTransmission ld a, $3 ld [wcae2], a call Printer_CopyTileMapToPrinterTileBuffer call LoadScreenTilesFromBuffer1 ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a - call Func_e8c0c -.asm_e8bf4 + call .TryPrintPage +.finish_printing xor a ld [wPrinterConnectionOpen], a ld [wPrinterOpcode], a @@ -81,83 +81,83 @@ Func_e8b74: ; e8b74 (3a:4b74) ld [wUpdateSpritesEnabled], a ret -Func_e8c0c: +.TryPrintPage: call Printer_ResetJoypadHRAM -.asm_e8c0f +.print_loop call JoypadLowSensitivity call Printer_CheckPressingB - jr c, .asm_e8c2e + jr c, .pressed_b ld a, [wPrinterSendState] bit 7, a - jr nz, .asm_e8c2c - call Func_e87a8 + jr nz, .completed + call PrinterTransmissionJumptable call GBPrinter_CheckForErrors call GBPrinter_UpdateStatusMessage call DelayFrame - jr .asm_e8c0f + jr .print_loop -.asm_e8c2c +.completed and a ret -.asm_e8c2e +.pressed_b scf ret -Func_e8c30: - callab Func_4039c +Printer_GetDexEntryRegisters: + callab DrawDexEntryOnScreen ld a, l - ld [wcaf5], a + ld [wPrinterPokedexEntryTextPointer], a ld a, h - ld [wcaf6], a + ld [wPrinterPokedexEntryTextPointer + 1], a ld a, $0 rla ; copy carry flag state to bit 0 - ld [wcaf9], a + ld [wPrinterPokedexMonIsOwned], a and a - jr z, .asm_e8c4d + jr z, .not_caught ld a, $5 - jr .asm_e8c4f + jr .got_num_rows -.asm_e8c4d +.not_caught ld a, $9 -.asm_e8c4f +.got_num_rows ret -Func_e8c50: +Printer_PrepareDexEntryForPrinting: call ClearScreen - callab Func_404bc + callab Pokedex_PrepareDexEntryForPrinting ret -Func_e8c5c: +PrintSurfingMinigameHighScore: xor a ld [hCanceledPrinting], a call Printer_PlayPrinterMusic - call Func_e910a + call Printer_PrepareSurfingMinigameHighScoreTileMap ld a, [rIE] push af xor a ld [rIF], a ld a, $9 ld [rIE], a - call Func_e8783 + call StartTransmission_Send9Rows ld a, $13 ld [wcae2], a call Printer_CopyTileMapToPrinterTileBuffer call Printer_ResetJoypadHRAM -.asm_e8c7d +.loop call JoypadLowSensitivity call Printer_CheckPressingB - jr c, .asm_e8c9a + jr c, .quit ld a, [wPrinterSendState] bit 7, a - jr nz, .asm_e8c9a - call Func_e87a8 + jr nz, .quit + call PrinterTransmissionJumptable call GBPrinter_CheckForErrors call GBPrinter_UpdateStatusMessage call DelayFrame - jr .asm_e8c7d + jr .loop -.asm_e8c9a +.quit xor a ld [wPrinterConnectionOpen], a ld [wPrinterOpcode], a @@ -170,7 +170,7 @@ Func_e8c5c: call Printer_PlayMapMusic ret -Func_e8cb1: +PrintDiploma: xor a ld [hCanceledPrinting], a call Printer_PlayPrinterMusic @@ -181,7 +181,7 @@ Func_e8cb1: ld [rIF], a ld a, $9 ld [rIE], a - call Func_e8783 + call StartTransmission_Send9Rows ld a, $10 ld [wcae2], a call Printer_CopyTileMapToPrinterTileBuffer @@ -196,7 +196,7 @@ Func_e8cb1: xor a ld [H_AUTOBGTRANSFERENABLED], a call Func_e9ad3 - call Func_e8783 + call StartTransmission_Send9Rows ld a, $3 ld [wcae2], a call Printer_CopyTileMapToPrinterTileBuffer @@ -224,7 +224,7 @@ Func_e8d11: ld a, [wPrinterSendState] bit 7, a jr nz, .asm_e8d31 - call Func_e87a8 + call PrinterTransmissionJumptable call GBPrinter_CheckForErrors call GBPrinter_UpdateStatusMessage call DelayFrame @@ -238,9 +238,7 @@ Func_e8d11: scf ret - - -Func_e8d35:: ; e8d35 (3a:4e79) +PrintPCBox:: ; e8d35 (3a:4e79) ld a, [wBoxDataStart] and a jp z, Func_e8df4 @@ -260,7 +258,7 @@ Func_e8d35:: ; e8d35 (3a:4e79) xor a ld [H_AUTOBGTRANSFERENABLED], a call Func_e988a - call Func_e8783 + call StartTransmission_Send9Rows ld a, $10 ld [wcae2], a call Printer_CopyTileMapToPrinterTileBuffer @@ -275,7 +273,7 @@ Func_e8d35:: ; e8d35 (3a:4e79) xor a ld [H_AUTOBGTRANSFERENABLED], a call Func_e98ec - call Func_e8783 + call StartTransmission_Send9Rows ld a, $0 ld [wcae2], a call Printer_CopyTileMapToPrinterTileBuffer @@ -290,7 +288,7 @@ Func_e8d35:: ; e8d35 (3a:4e79) xor a ld [H_AUTOBGTRANSFERENABLED], a call Func_e9907 - call Func_e8783 + call StartTransmission_Send9Rows ld a, $0 ld [wcae2], a call Printer_CopyTileMapToPrinterTileBuffer @@ -305,7 +303,7 @@ Func_e8d35:: ; e8d35 (3a:4e79) xor a ld [H_AUTOBGTRANSFERENABLED], a call Func_e9922 - call Func_e8783 + call StartTransmission_Send9Rows ld a, $3 ld [wcae2], a call Printer_CopyTileMapToPrinterTileBuffer @@ -339,7 +337,7 @@ Func_e8dfb: ; e8dfb ld a, [wPrinterSendState] bit 7, a jr nz, .asm_e8e1b - call Func_e87a8 + call PrinterTransmissionJumptable call GBPrinter_CheckForErrors call GBPrinter_UpdateStatusMessage call DelayFrame @@ -357,7 +355,7 @@ String_e8e1f: ; e8e1f TX_FAR _NoPokemonText db "@" -Func_e8e24: ; e8e24 +PrintFanClubPortrait: ; e8e24 xor a ld [hCanceledPrinting], a call Printer_PlayPrinterMusic @@ -368,7 +366,7 @@ Func_e8e24: ; e8e24 ld [rIF], a ld a, $9 ld [rIE], a - call Func_e8783 + call StartTransmission_Send9Rows ld a, $13 ld [wcae2], a call Printer_CopyTileMapToPrinterTileBuffer @@ -380,7 +378,7 @@ Func_e8e24: ; e8e24 ld a, [wPrinterSendState] bit 7, a jr nz, .asm_e8e62 - call Func_e87a8 + call PrinterTransmissionJumptable call GBPrinter_CheckForErrors call GBPrinter_UpdateStatusMessage call DelayFrame @@ -411,23 +409,23 @@ Func_e8e79: ; e8e79 (3a:4e79) ld [rIF], a ld a, $9 ld [rIE], a - call Func_e8783 + call StartTransmission_Send9Rows ld a, $13 ld [wcae2], a ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a call Printer_CopyTileMapToPrinterTileBuffer call Func_ea573 -.asm_e8e9c +.loop ld a, [wPrinterSendState] bit 7, a - jr nz, .asm_e8eae + jr nz, .quit call Func_ea5d1 call Func_ea5b7 call DelayFrame - jr .asm_e8e9c + jr .loop -.asm_e8eae +.quit xor a ld [wPrinterConnectionOpen], a ld [wPrinterOpcode], a @@ -529,17 +527,17 @@ Printer_FadeOutMusicAndWait: ; e8f42 (3a:4f42) ret GBPrinter_CheckForErrors: ; e8f51 (3a:4f51) - ld a, [wc970] + ld a, [wPrinterHandshake] cp $81 jr z, .check_other_errors - ld a, [wc971] + ld a, [wPrinterStatusFlags] cp $ff jr z, .error2 xor a jr .load_status .check_other_errors - ld a, [wc971] + ld a, [wPrinterStatusFlags] and %11100000 ret z bit 7, a @@ -643,7 +641,7 @@ GBPrinter_UpdateStatusMessage: db "This is not the" next "Game Boy Printer!@" -Func_e910a: +Printer_PrepareSurfingMinigameHighScoreTileMap: call GBPalWhiteOutWithDelay3 call ClearScreen ld de, SurfingPikachu2Graphics @@ -651,13 +649,13 @@ Func_e910a: lb bc, BANK(SurfingPikachu2Graphics), (SurfingPikachu2GraphicsEnd - SurfingPikachu2Graphics) / $10 call CopyVideoData coord hl, 0, 0 - call Func_e91a9 + call .PlaceRowAlternatingTiles coord hl, 0, 17 - call Func_e91a9 + call .PlaceRowAlternatingTiles coord hl, 0, 0 - call Func_e91b5 + call .PlaceColumnAlternatingTiles coord hl, 19, 0 - call Func_e91b5 + call .PlaceColumnAlternatingTiles ld a, $4 coord hl, 0, 0 ld [hl], a @@ -667,41 +665,41 @@ Func_e910a: ld [hl], a coord hl, 19, 17 ld [hl], a - ld de, Data_e91c4 + ld de, .Tilemap1 coord hl, 10, 8 lb bc, 3, 8 - call Func_e925d - ld de, Data_e91dc + call Diploma_Surfing_CopyBox + ld de, .Tilemap2 coord hl, 2, 11 lb bc, 6, 16 - call Func_e925d - ld de, String_e923c + call Diploma_Surfing_CopyBox + ld de, .PikachusBeachString coord hl, 3, 2 call PlaceString - ld de, String_e924b + ld de, .HiScoreString coord hl, 9, 4 call PlaceString - ld de, String_e9256 + ld de, .PointsString coord hl, 12, 6 call PlaceString ld de, wPlayerName ld hl, wPlayerName ld bc, 0 -.asm_e9182 +.find_end_of_name ld a, [hli] inc c cp "@" - jr nz, .asm_e9182 + jr nz, .find_end_of_name ld a, 8 sub c - jr nc, .asm_e918e + jr nc, .got_name_length xor a -.asm_e918e +.got_name_length ld c, a coord hl, 2, 4 add hl, bc call PlaceString - call Func_e926f + call CopySurfingMinigameScore ld b, 8 call RunPaletteCommand ld a, $1 @@ -710,35 +708,35 @@ Func_e910a: call GBPalNormal ret -Func_e91a9: +.PlaceRowAlternatingTiles: ld c, SCREEN_WIDTH / 2 -.asm_e91ab +.row_loop ld [hl], $0 inc hl ld [hl], $1 inc hl dec c - jr nz, .asm_e91ab + jr nz, .row_loop ret -Func_e91b5: +.PlaceColumnAlternatingTiles: ld c, SCREEN_HEIGHT / 2 ld de, SCREEN_WIDTH -.asm_e91ba +.col_loop ld [hl], $2 add hl, de ld [hl], $3 add hl, de dec c - jr nz, .asm_e91ba + jr nz, .col_loop ret -Data_e91c4: + +.Tilemap1: db $7f, $7f, $10, $11, $12, $13, $14, $15 db $0f, $3c, $3d, $3e, $20, $21, $30, $31 db $4c, $4d, $4e, $50, $34, $1a, $51, $2d - -Data_e91dc: +.Tilemap2: db $7f, $7f, $7f, $7f, $7f, $7f, $16, $17, $18, $19, $7f, $1b, $1c, $1d, $1e, $1f db $7f, $7f, $22, $23, $24, $25, $26, $27, $28, $29, $2a, $2b, $2c, $7f, $2e, $2f db $7f, $7f, $32, $33, $33, $35, $36, $37, $38, $39, $3a, $3b, $7f, $7f, $7f, $3f @@ -746,39 +744,38 @@ Data_e91dc: db $52, $52, $52, $53, $54, $55, $56, $57, $58, $59, $5a, $5b, $5c, $5d, $5d, $5e db $7f, $7f, $7f, $05, $06, $07, $08, $09, $0a, $0b, $0c, $0d, $0e, $7f, $7f, $7f - -String_e923c: +.PikachusBeachString: db "Pikachu's Beach@" -String_e924b: +.HiScoreString: db "'s Hi-Score@" -String_e9256: +.PointsString: db "Points@" -Func_e925d: -.asm_e925d +Diploma_Surfing_CopyBox: +.y push bc push hl -.asm_e925f +.x ld a, [de] inc de ld [hli], a dec c - jr nz, .asm_e925f + jr nz, .x pop hl ld bc, SCREEN_WIDTH add hl, bc pop bc dec b - jr nz, .asm_e925d + jr nz, .y ret -Func_e926f: - ld de, wd496 +CopySurfingMinigameScore: + ld de, wSurfingMinigameHiScore + 1 coord hl, 7, 6 ld a, [de] - call Func_e927a + call .BCDConvertScore ld a, [de] -Func_e927a: +.BCDConvertScore: ld c, a swap a and $f @@ -832,7 +829,6 @@ Func_e988a: call Func_e994e ret - String_e98db: db "POKéMON LIST@" String_e98e8: db "BOX@" diff --git a/engine/printer/serial.asm b/engine/printer/serial.asm index 568a00f8..54d31a15 100755 --- a/engine/printer/serial.asm +++ b/engine/printer/serial.asm @@ -1,6 +1,6 @@ -Func_e8783: ; e8783 (3a:4783) +StartTransmission_Send9Rows: ; e8783 (3a:4783) ld a, 9 -Func_e8785: +Printer_StartTransmission: push af ld hl, wPrinterData ld bc, wPrinterDataEnd - wPrinterData @@ -15,11 +15,11 @@ Func_e8785: ld a, [wPrinterSettings] ld [wPrinterSettingsTempCopy], a pop af - ld [wcaf4], a + ld [wPrinterQueueLength], a ret ; e87a8 -Func_e87a8: ; e87a8 (3a:47a8) +PrinterTransmissionJumptable: ; e87a8 (3a:47a8) ld a, [wPrinterSendState] ld e, a ld d, 0 @@ -33,25 +33,27 @@ Func_e87a8: ; e87a8 (3a:47a8) .Jumptable: dw Printer_InitSerial ; 00 - dw Func_e88c9 ; 01 - dw Func_e88a6 ; 02 - dw Func_e881f ; 03 - dw Func_e8906 ; 04 - dw Func_e88b4 ; 05 - dw Func_e884b ; 06 - dw Func_e8906 ; 07 - dw Func_e88a6 ; 08 - dw Func_e8864 ; 09 - dw Func_e8906 ; 0a - dw Func_e88a6 ; 0b - dw Func_e8927 ; 0c + dw Printer_CheckConnectionStatus ; 01 + dw Printer_WaitSerial ; 02 + dw Printer_StartTransmittingTilemap ; 03 + dw Printer_TransmissionLoop ; 04 + dw Printer_WaitSerialAndLoopBack2 ; 05 + dw Printer_EndTilemapTransmission ; 06 + dw Printer_TransmissionLoop ; 07 + dw Printer_WaitSerial ; 08 + + dw Printer_SignalSendHeader ; 09 + dw Printer_TransmissionLoop ; 0a + dw Printer_WaitSerial ; 0b + dw Printer_WaitUntilFinished ; 0c dw Printer_Quit ; 0d + dw Printer_Next_ ; 0e - dw Func_e88a6 ; 10 - dw Func_e8889 ; 11 - dw Printer_LoopBack ; 12 - dw Func_e8936 ; 13 - dw Func_e8939 ; 14 + dw Printer_WaitSerial ; 0f + dw Printer_SignalLoopBack ; 10 + dw Printer_LoopBack ; 11 + dw Printer_WaitLoopBack ; 12 + dw Printer_WaitLoopBack_ ; 13 Printer_Next: ld hl, wPrinterSendState @@ -65,7 +67,7 @@ Printer_Back: Printer_Quit: xor a - ld [wc971], a + ld [wPrinterStatusFlags], a ld hl, wPrinterSendState set 7, [hl] ret @@ -86,23 +88,23 @@ Printer_InitSerial: xor a ld [wPrinterDataSize], a ld [wPrinterDataSize + 1], a - ld a, [wcaf4] - ld [wc6e9], a + ld a, [wPrinterQueueLength] + ld [wPrinterRowIndex], a call Printer_Next call Printer_PrepareToSend ld a, PRINTER_STATUS_CHECKING_LINK ld [wPrinterStatusIndicator], a ret -Func_e881f: +Printer_StartTransmittingTilemap: call ResetPrinterData - ld hl, wc6e9 + ld hl, wPrinterRowIndex ld a, [hl] and a - jr z, Func_e884b + jr z, Printer_EndTilemapTransmission ld hl, PrinterDataPacket3 call CopyPrinterDataHeader - call Func_e89e6 + call Printer_Convert2RowsTo2bpp ld a, (wPrinterSendDataSourceEnd - wPrinterSendDataSource) % $100 ld [wPrinterDataSize], a ld a, (wPrinterSendDataSourceEnd - wPrinterSendDataSource) / $100 @@ -114,7 +116,7 @@ Func_e881f: ld [wPrinterStatusIndicator], a ret -Func_e884b: +Printer_EndTilemapTransmission: ld a, $6 ld [wPrinterSendState], a ld hl, PrinterDataPacket4 @@ -126,11 +128,11 @@ Func_e884b: call Printer_PrepareToSend ret -Func_e8864: +Printer_SignalSendHeader: call ResetPrinterData ld hl, PrinterDataPacket2 call CopyPrinterDataHeader - call Func_e89cf + call Printer_StageHeaderForSend ld a, $4 ld [wPrinterDataSize], a ld a, $0 @@ -142,85 +144,85 @@ Func_e8864: ld [wPrinterStatusIndicator], a ret -Func_e8889: +Printer_SignalLoopBack: call ResetPrinterData ld hl, PrinterDataPacket1 call CopyPrinterDataHeader xor a ld [wPrinterDataSize], a ld [wPrinterDataSize + 1], a - ld a, [wcaf4] - ld [wc6e9], a + ld a, [wPrinterQueueLength] + ld [wPrinterRowIndex], a call Printer_Next call Printer_PrepareToSend ret -Func_e88a6: - ld hl, wc973 +Printer_WaitSerial: + ld hl, wPrinterSerialFrameDelay inc [hl] ld a, [hl] - cp a, $6 + cp $6 ret c xor a ld [hl], a call Printer_Next ret -Func_e88b4: - ld hl, wc973 +Printer_WaitSerialAndLoopBack2: + ld hl, wPrinterSerialFrameDelay inc [hl] ld a, [hl] - cp a, $6 + cp $6 ret c xor a ld [hl], a - ld hl, wc6e9 + ld hl, wPrinterRowIndex dec [hl] call Printer_Back call Printer_Back ret -Func_e88c9: +Printer_CheckConnectionStatus: ld a, [wPrinterOpcode] and a ret nz - ld a, [wc970] - cp a, $ff + ld a, [wPrinterHandshake] + cp $ff jr nz, .asm_e88dc - ld a, [wc971] - cp a, $ff + ld a, [wPrinterStatusFlags] + cp $ff jr z, .asm_e88f8 .asm_e88dc - ld a, [wc970] - cp a, $81 + ld a, [wPrinterHandshake] + cp $81 jr nz, .asm_e88f8 - ld a, [wc971] - cp a, $0 + ld a, [wPrinterStatusFlags] + cp $0 jr nz, .asm_e88f8 ld hl, wPrinterConnectionOpen set 1, [hl] ld a, $5 - ld [wc972], a + ld [wHandshakeFrameDelay], a call Printer_Next ret .asm_e88f8 ld a, $ff - ld [wc970], a - ld [wc971], a + ld [wPrinterHandshake], a + ld [wPrinterStatusFlags], a ld a, $e ld [wPrinterSendState], a ret -Func_e8906: +Printer_TransmissionLoop: ld a, [wPrinterOpcode] and a ret nz - ld a, [wc971] - and a, $f0 + ld a, [wPrinterStatusFlags] + and $f0 jr nz, .asm_e8921 - ld a, [wc971] - and a, $1 + ld a, [wPrinterStatusFlags] + and $1 jr nz, .asm_e891d call Printer_Next ret @@ -234,24 +236,24 @@ Func_e8906: ld [wPrinterSendState], a ret -Func_e8927: +Printer_WaitUntilFinished: ld a, [wPrinterOpcode] and a ret nz - ld a, [wc971] - and a, $f3 + ld a, [wPrinterStatusFlags] + and $f3 ret nz call Printer_Next ret -Func_e8936: +Printer_WaitLoopBack: call Printer_Next -Func_e8939: +Printer_WaitLoopBack_: ld a, [wPrinterOpcode] and a ret nz - ld a, [wc971] - and a, $f0 + ld a, [wPrinterStatusFlags] + and $f0 ret nz xor a ld [wPrinterSendState], a @@ -263,8 +265,8 @@ Printer_PrepareToSend: and a jr nz, .wait_printer_operation xor a - ld [wc974], a - ld [wc975], a + ld [wPrinterSendByteOffset], a + ld [wPrinterSendByteOffset + 1], a ld a, $1 ld [wPrinterOpcode], a ld a, $88 @@ -340,21 +342,21 @@ ComputePrinterChecksum: jr nz, .loop ret -Func_e89cf: +Printer_StageHeaderForSend: ld a, $1 - ld [wPrinterSerialReceived], a + ld [wPrinterSendDataSource], a ld a, [wcae2] - ld [wPrinterStatusReceived], a - ld a, $e4 - ld [wc6f2], a + ld [wPrinterSendDataSource + 1], a + ld a, %11100100 + ld [wPrinterSendDataSource + 2], a ld a, [wPrinterSettingsTempCopy] - ld [wc6f3], a + ld [wPrinterSendDataSource + 3], a ret -Func_e89e6: - ld a, [wc6e9] +Printer_Convert2RowsTo2bpp: + ld a, [wPrinterRowIndex] ld b, a - ld a, [wcaf4] + ld a, [wPrinterQueueLength] sub b ld hl, wPrinterTileBuffer ld de, 2 * SCREEN_WIDTH @@ -378,22 +380,22 @@ Func_e89e6: push hl swap a ld d, a - and a, $f0 + and $f0 ld e, a ld a, d - and a, $f + and $f ld d, a - and a, $8 + and $8 ld a, d jr nz, .vchars1 - or a, $90 + or $90 jr .got_addr .vchars1 - or a, $80 + or $80 .got_addr ld d, a - lb bc, BANK(Func_e89e6), 1 + lb bc, BANK(Printer_Convert2RowsTo2bpp), 1 call CopyVideoData pop hl ld de, $10 @@ -536,17 +538,17 @@ PrinterSerial_: ; e8a5e (3a:4a5e) ld [hl], d dec hl ld [hl], e - ld a, [wc974] + ld a, [wPrinterSendByteOffset] ld e, a - ld a, [wc975] + ld a, [wPrinterSendByteOffset + 1] ld d, a ld hl, wPrinterSendDataSource add hl, de inc de ld a, e - ld [wc974], a + ld [wPrinterSendByteOffset], a ld a, d - ld [wc975], a + ld [wPrinterSendByteOffset + 1], a ld a, [hl] call .SendByte ret @@ -573,7 +575,7 @@ PrinterSerial_: ; e8a5e (3a:4a5e) .Receive1: ld a, [rSB] - ld [wc970], a + ld [wPrinterHandshake], a ld a, $0 call .SendByte call .NextInstruction @@ -581,7 +583,7 @@ PrinterSerial_: ; e8a5e (3a:4a5e) .Receive2: ld a, [rSB] - ld [wc971], a + ld [wPrinterStatusFlags], a xor a ld [wPrinterOpcode], a ret @@ -614,7 +616,7 @@ PrinterSerial_: ; e8a5e (3a:4a5e) .Receive2_: ld a, [rSB] - ld [wc971], a + ld [wPrinterStatusFlags], a xor a ld [wPrinterOpcode], a ret diff --git a/engine/surfing_minigame.asm b/engine/surfing_minigame.asm index c1533583..f70e8119 100755 --- a/engine/surfing_minigame.asm +++ b/engine/surfing_minigame.asm @@ -1685,7 +1685,7 @@ Tilemap_f8b8d: db $2b,$2c,$25,$28,$2d Func_f8b92: - ld hl, wd496 + ld hl, wSurfingMinigameHiScore + 1 ld a, [wc5dd] cp [hl] jr c, .asm_f8ba6 @@ -1704,9 +1704,9 @@ Func_f8b92: .asm_f8bb0 ld a, [wc5dc] - ld [wd495], a + ld [wSurfingMinigameHiScore], a ld a, [wc5dd] - ld [wd496], a + ld [wSurfingMinigameHiScore + 1], a call WaitForSoundToFinish ldpikacry e, PikachuCry34 call SurfingMinigame_PlayPikaCryIfSurfingPikaInParty diff --git a/engine/titlescreen.asm b/engine/titlescreen.asm index 3928e49a..a8a65dba 100755 --- a/engine/titlescreen.asm +++ b/engine/titlescreen.asm @@ -42,22 +42,22 @@ DisplayTitleScreen: ; 4171 (1:4171) ld a, BANK(NineTile) call FarCopyData ld hl, GamefreakLogoGraphics ; 4:4d78 - ld de, vTitleLogo + $650 - ld bc, $90 + ld de, vTitleLogo + 101 * $10 + ld bc, 9 * $10 ld a, BANK(GamefreakLogoGraphics) call FarCopyData - callab Func_f453f + callab LoadYellowTitleScreenGFX ld hl, vBGMap0 ld bc, (vBGMap1 + $400) - vBGMap0 ld a, " " call FillMemory - callab Func_f4578 - call Func_4418 + callab TitleScreen_PlacePokemonLogo + call FillSpriteBuffer0WithAA call .WriteCopyrightTiles call SaveScreenTilesToBuffer2 call LoadScreenTilesFromBuffer2 call EnableLCD - callab Func_f459a + callab TitleScreen_PlacePikachu ld a, $9b call TitleScreenCopyTileMapToVRAM call SaveScreenTilesToBuffer1 @@ -136,7 +136,7 @@ DisplayTitleScreen: ; 4171 (1:4171) call PlaySound ; scroll game version in from the right - callab Func_f4585 + callab TitleScreen_PlacePikaSpeechBubble ld a, SCREEN_HEIGHT_PIXELS ld [hWY], a call Delay3 @@ -147,15 +147,15 @@ DisplayTitleScreen: ; 4171 (1:4171) ld a, MUSIC_TITLE_SCREEN ld [wNewSoundID], a call PlaySound -.asm_428f +.loop xor a ld [wUnusedCC5B], a - ld [wTitleMonSpecies], a - ld [wTitleMonSpecies+1], a - ld [wTitleMonSpecies+2], a - ld [wTitleMonSpecies+3], a + ld [wTitleScreenScene], a + ld [wTitleScreenScene + 1], a + ld [wTitleScreenScene + 2], a + ld [wTitleScreenScene + 3], a ld a, $f - ld [wTitleMonSpecies+4], a + ld [wTitleScreenScene + 4], a .titleScreenLoop call IncrementResetCounter jp c, .doTitlescreenReset @@ -163,12 +163,13 @@ DisplayTitleScreen: ; 4171 (1:4171) call JoypadLowSensitivity ld a, [hJoyHeld] cp D_UP | SELECT | B_BUTTON - jr z, .asm_42bf + jr z, .go_to_main_menu and A_BUTTON | START - jr nz, .asm_42bf - call Func_4390 + jr nz, .go_to_main_menu + call DoTitleScreenFunction jr .titleScreenLoop -.asm_42bf + +.go_to_main_menu ld e, $a call TitleScreen_PlayPikachuPCM call GBPalWhiteOutWithDelay3 @@ -190,24 +191,28 @@ DisplayTitleScreen: ; 4171 (1:4171) cp D_UP | SELECT | B_BUTTON jp z, .doClearSaveDialogue jp MainMenu + .asm_42f0 ; 42f0 (1:42f0) +; unreferenced callab Func_e8e79 - jp .asm_428f + jp .loop .asm_42fb ; 42fb (1:42fb) - ld a, [wTitleMonSpecies+4] +; unreferenced + ld a, [wTitleScreenScene + 4] inc a cp $2a jr c, .asm_4305 ld a, $f .asm_4305 - ld [wTitleMonSpecies+4], a + ld [wTitleScreenScene + 4], a ld e, a callab PlayPikachuSoundClip xor a - ld [wTitleMonSpecies+2], a - ld [wTitleMonSpecies+3], a + ld [wTitleScreenScene + 2], a + ld [wTitleScreenScene + 3], a jp .titleScreenLoop + .doTitlescreenReset ; 431b (1:431b) ld [wAudioFadeOutControl], a call StopAllMusic @@ -216,6 +221,7 @@ DisplayTitleScreen: ; 4171 (1:4171) and a jr nz, .audioFadeLoop jp Init + .doClearSaveDialogue ; 432a (1:432a) jpba DoClearSaveDialogue @@ -249,49 +255,54 @@ CopyrightTextString: ; 4355 (1:4355) TitleScreen_PlayPikachuPCM: ; 4387 (1:4387) callab PlayPikachuSoundClip ret + -Func_4390: ; 4390 (1:4390) - call Func_43de - ld a, [wTitleMonSpecies] +DoTitleScreenFunction: ; 4390 (1:4390) + call .CheckTimer + ld a, [wTitleScreenScene] ld e, a ld d, 0 - ld hl, PointerTable_43a2 + ld hl, .Jumptable add hl, de add hl, de ld a, [hli] ld h, [hl] ld l, a - jp hl + jp [hl] + -PointerTable_43a2: ; 43a2 (1:43a2) - dw Func_43be - dw Func_43c3 - dw Func_43d9 - dw Func_43d9 - dw Func_43c7 - dw Func_43d9 - dw Func_43d9 - dw Func_43c3 - dw Func_43d9 - dw Func_43d9 - dw Func_43bf - dw Func_43ba +.Jumptable: ; 43a2 (1:43a2) + dw .Nop + dw .BlinkHalf + dw .BlinkWait + dw .BlinkWait + dw .BlinkClosed + dw .BlinkWait + dw .BlinkWait + dw .BlinkHalf + dw .BlinkWait + dw .BlinkWait + dw .BlinkOpen + dw .GoBackToStart -Func_43ba: ; 43ba (1:43ba) +.GoBackToStart: ; 43ba (1:43ba) xor a - ld [wTitleMonSpecies], a -Func_43be + ld [wTitleScreenScene], a +.Nop ret + -Func_43bf: ; 43bf (1:43bf) +.BlinkOpen: ; 43bf (1:43bf) ld e, 0 - jr asm_43c9 -Func_43c3: ; 43c3 (1:43c3) + jr .LoadBlinkFrame + +.BlinkHalf: ; 43c3 (1:43c3) ld e, 4 - jr asm_43c9 -Func_43c7: ; 43c7 (1:43c7) + jr .LoadBlinkFrame + +.BlinkClosed: ; 43c7 (1:43c7) ld e, 8 -asm_43c9: ; 43c9 (1:43c9) +.LoadBlinkFrame: ; 43c9 (1:43c9) ld hl, wOAMBuffer + 2 ld c, 8 .loop @@ -304,36 +315,38 @@ asm_43c9: ; 43c9 (1:43c9) inc hl dec c jr nz, .loop -Func_43d9: ; 43d9 (1:43d9) - ld hl, wTitleMonSpecies +.BlinkWait: ; 43d9 (1:43d9) + ld hl, wTitleScreenScene inc [hl] ret + -Func_43de: ; 43de (1:43de) - ld hl, wTitleMonSpecies + 1 +.CheckTimer: ; 43de (1:43de) + ld hl, wTitleScreenTimer ld a, [hl] inc [hl] and a - jr z, .asm_43ed + jr z, .restart cp $80 - jr z, .asm_43ed + jr z, .restart cp $90 ret nz -.asm_43ed +.restart ld a, $1 - ld [wTitleMonSpecies], a + ld [wTitleScreenScene], a ret ; copy text of fixed length NAME_LENGTH (like player name, rival name, mon names, ...) CopyFixedLengthText: ; 43f3 (1:43f3) ld bc, NAME_LENGTH jp CopyData + NintenText: db "NINTEN@" SonyText: db "SONY@" IncrementResetCounter: ; 4405 (1:4405) - ld hl, wTitleMonSpecies + 2 + ld hl, wTitleScreenScene + 2 ld e, [hl] inc hl ld d, [hl] @@ -346,16 +359,18 @@ IncrementResetCounter: ; 4405 (1:4405) ld [hl], e and a ret + .doReset scf ret + -Func_4418: ; 4418 (1:4418) +FillSpriteBuffer0WithAA: ; 4418 (1:4418) xor a call SwitchSRAMBankAndLatchClockData - ld hl, $a000 + ld hl, S_SPRITEBUFFER0 ld bc, $20 ld a, $aa call FillMemory call PrepareRTCDataAndDisableSRAM - ret \ No newline at end of file + ret diff --git a/engine/titlescreen2.asm b/engine/titlescreen2.asm index dec37da2..cf4506bc 100755 --- a/engine/titlescreen2.asm +++ b/engine/titlescreen2.asm @@ -91,7 +91,7 @@ TitleBallYTable: ; 374fa (d:74fa) TitleScreenAnimateBallIfStarterOut: ; 37506 (d:7506) ; Animate the TitleBall if a starter just got scrolled out. - ld a, [wTitleMonSpecies] + ld a, [wTitleScreenScene] cp STARTER1 jr z, .ok cp STARTER2 diff --git a/scripts/beach_house.asm b/scripts/beach_house.asm index d43e0977..b0daa01f 100644 --- a/scripts/beach_house.asm +++ b/scripts/beach_house.asm @@ -158,7 +158,7 @@ BeachHouseSign4Text: set 6, [hl] xor a ld [wUpdateSpritesEnabled], a - callab Func_e910a + callab Printer_PrepareSurfingMinigameHighScoreTileMap call WaitForTextScrollButtonPress ld hl, wd730 res 6, [hl] diff --git a/scripts/beach_house2.asm b/scripts/beach_house2.asm index a2dd2114..eb2f56b4 100755 --- a/scripts/beach_house2.asm +++ b/scripts/beach_house2.asm @@ -4,7 +4,7 @@ Func_f23d0: ; f23d0 ld [wUpdateSpritesEnabled], a ld hl, wd730 set 6, [hl] - callab Func_e8c5c + callab PrintSurfingMinigameHighScore ld hl, wd730 res 6, [hl] call GBPalWhiteOutWithDelay3 diff --git a/scripts/celadonmansion3.asm b/scripts/celadonmansion3.asm index 191d9304..51f61e94 100755 --- a/scripts/celadonmansion3.asm +++ b/scripts/celadonmansion3.asm @@ -58,7 +58,7 @@ GraphicArtistText: ; 487a8 (12:47a8) ld [wUpdateSpritesEnabled], a ld hl, wd730 set 6, [hl] - callab Func_e8cb1 + callab PrintDiploma ld hl, wd730 res 6, [hl] call GBPalWhiteOutWithDelay3 diff --git a/scripts/fanclub.asm b/scripts/fanclub.asm index d1dffea6..21be1443 100755 --- a/scripts/fanclub.asm +++ b/scripts/fanclub.asm @@ -244,7 +244,7 @@ FanClubText5: ld [wUpdateSpritesEnabled], a ld hl, wd730 set 6, [hl] - callab Func_e8e24 + callab PrintFanClubPortrait ld hl, wd730 res 6, [hl] call GBPalWhiteOutWithDelay3 diff --git a/wram.asm b/wram.asm index 3136ffd8..a64a30c0 100755 --- a/wram.asm +++ b/wram.asm @@ -491,7 +491,7 @@ wOverworldMap:: ; c6e8 ; ds 1300 wPrinterSendState:: ; c6e8 ds 1 -wc6e9:: ; c6e9 +wPrinterRowIndex:: ; c6e9 ds 1 ; Printer data header @@ -537,18 +537,16 @@ wc810:: ; c810 ds $70 wPrinterSendDataSourceEnd:: ; c970 -wc970:: ; c970 +wPrinterHandshake:: ; c970 ds 1 -wc971:: ; c971 +wPrinterStatusFlags:: ; c971 ds 1 -wc972:: ; c972 +wHandshakeFrameDelay:: ; c972 ds 1 -wc973:: ; c973 - ds 1 -wc974:: ; c974 - ds 1 -wc975:: ; c975 +wPrinterSerialFrameDelay:: ; c973 ds 1 +wPrinterSendByteOffset:: ; c974 + dw wPrinterDataSize:: ; c976 dw wPrinterTileBuffer:: ; c978 @@ -559,15 +557,14 @@ wcae2:: ; cae2 ds 1 wPrinterSettingsTempCopy:: ; cae3 ds 17 -wcaf4:: ; caf4 +wPrinterQueueLength:: ; caf4 ds 1 wPrinterDataEnd:: ; caf5 -wcaf5:: ; caf5 - ds 1 -wcaf6:: ; caf6 - ds 3 -wcaf9:: ; caf9 +wPrinterPokedexEntryTextPointer:: ; caf5 + dw + ds 2 +wPrinterPokedexMonIsOwned:: ; caf9 ds 259 wRedrawRowOrColumnSrcTiles:: ; cbfc @@ -1133,7 +1130,7 @@ wWhichBadge:: ; cd3d wPriceTemp:: ; cd3d ; 3-byte BCD number -wTitleMonSpecies:: ; cd3d +wTitleScreenScene:: ; cd3d wPlayerCharacterOAMTile:: ; cd3d @@ -1196,6 +1193,8 @@ wTrainerSpriteOffset:: ; cd3d wUnusedCD3D:: ; cd3d ds 1 +wTitleScreenTimer:: ; cd3e + wHUDPokeballGfxOffsetX:: ; cd3e ; difference in X between the next ball and the current one @@ -2864,9 +2863,8 @@ wd492:: ds 1 ; d492 ds 1 -wd495:: ds 1 -wd496:: ds 1 -wd497:: ds 1 +wSurfingMinigameHiScore:: ds 2 ; 4-digit BCD little-endian + ds 1 wPrinterSettings:: ds 1 wUnknownSerialFlag_d499:: ds 1 ; d498 -- cgit v1.3.1-sl0p From e181c27c5e396aea254b471b182df3237eeb03ce Mon Sep 17 00:00:00 2001 From: pikalaxalt Date: Wed, 8 Jun 2016 00:23:55 -0400 Subject: Is this an OAM printer? --- engine/printer.asm | 106 +++++----- engine/unknown_ea3ea.asm | 494 ++++++++++++++++++++++++----------------------- wram.asm | 15 +- 3 files changed, 316 insertions(+), 299 deletions(-) (limited to 'wram.asm') diff --git a/engine/printer.asm b/engine/printer.asm index 929173db..d4cc8192 100644 --- a/engine/printer.asm +++ b/engine/printer.asm @@ -257,7 +257,7 @@ PrintPCBox:: ; e8d35 (3a:4e79) call SaveScreenTilesToBuffer1 xor a ld [H_AUTOBGTRANSFERENABLED], a - call Func_e988a + call PrintPCBox_DrawPage1 call StartTransmission_Send9Rows ld a, $10 ld [wcae2], a @@ -272,7 +272,7 @@ PrintPCBox:: ; e8d35 (3a:4e79) call DelayFrames xor a ld [H_AUTOBGTRANSFERENABLED], a - call Func_e98ec + call PrintPCBox_DrawPage2 call StartTransmission_Send9Rows ld a, $0 ld [wcae2], a @@ -287,7 +287,7 @@ PrintPCBox:: ; e8d35 (3a:4e79) call DelayFrames xor a ld [H_AUTOBGTRANSFERENABLED], a - call Func_e9907 + call PrintPCBox_DrawPage3 call StartTransmission_Send9Rows ld a, $0 ld [wcae2], a @@ -302,7 +302,7 @@ PrintPCBox:: ; e8d35 (3a:4e79) call DelayFrames xor a ld [H_AUTOBGTRANSFERENABLED], a - call Func_e9922 + call PrintPCBox_DrawPage4 call StartTransmission_Send9Rows ld a, $3 ld [wcae2], a @@ -791,79 +791,79 @@ CopySurfingMinigameScore: SurfingPikachu2Graphics: INCBIN "gfx/surfing_pikachu_2.2bpp" SurfingPikachu2GraphicsEnd: -Func_e988a: +PrintPCBox_DrawPage1: xor a ld [wBoxNumString], a call ClearScreen - call Func_e99de + call PrintPCBox_PlaceHorizontalLines coord hl, 0, 0 ld bc, 11 * SCREEN_WIDTH ld a, " " call FillMemory - call Func_e99b9 - call Func_e99a7 + call PrintPCBox_DrawLeftAndRightBorders + call PrintPCBox_DrawTopBorder coord hl, 4, 4 - ld de, String_e98db + ld de, .PokemonListString call PlaceString coord hl, 7, 6 - ld de, String_e98e8 + ld de, .BoxString call PlaceString coord hl, 11, 6 ld a, [wCurrentBoxNum] and $7f cp 9 - jr c, .asm_e98cc + jr c, .less_than_9 sub 9 ld [hl], "1" inc hl add "0" - jr .asm_e98ce + jr .placed_box_number -.asm_e98cc +.less_than_9 add "1" -.asm_e98ce +.placed_box_number ld [hl], a coord hl, 4, 9 ld de, wBoxSpecies ld c, $3 - call Func_e994e + call PrintPCBox_PlaceBoxMonInfo ret -String_e98db: db "POKéMON LIST@" -String_e98e8: db "BOX@" +.PokemonListString: db "POKéMON LIST@" +.BoxString: db "BOX@" -Func_e98ec: +PrintPCBox_DrawPage2: call ClearScreen - call Func_e99de - call Func_e99b9 + call PrintPCBox_PlaceHorizontalLines + call PrintPCBox_DrawLeftAndRightBorders ld a, [wBoxDataStart] cp 4 ret c coord hl, 4, 0 ld de, wBoxSpecies + 3 ld c, 6 - call Func_e994e + call PrintPCBox_PlaceBoxMonInfo ret -Func_e9907: +PrintPCBox_DrawPage3: call ClearScreen - call Func_e99de - call Func_e99b9 + call PrintPCBox_PlaceHorizontalLines + call PrintPCBox_DrawLeftAndRightBorders ld a, [wBoxDataStart] cp 10 ret c coord hl, 4, 0 ld de, wBoxSpecies + 9 ld c, 6 - call Func_e994e + call PrintPCBox_PlaceBoxMonInfo ret -Func_e9922: +PrintPCBox_DrawPage4: call ClearScreen - call Func_e99de - call Func_e99b9 + call PrintPCBox_PlaceHorizontalLines + call PrintPCBox_DrawLeftAndRightBorders coord hl, 0, 15 - call Func_e99cf + call PrintPCBox_DrawBottomBorderAtHL coord hl, 0, 16 ld bc, 2 * SCREEN_WIDTH ld a, " " @@ -874,18 +874,18 @@ Func_e9922: coord hl, 4, 0 ld de, wBoxSpecies + 15 ld c, 5 - call Func_e994e + call PrintPCBox_PlaceBoxMonInfo ret -Func_e994e: -.asm_e994e +PrintPCBox_PlaceBoxMonInfo: +.loop ld a, c and a - jr z, .asm_e99a6 + jr z, .done dec c ld a, [de] cp $ff - jr z, .asm_e99a6 + jr z, .done ld [wd11e], a push bc push hl @@ -927,73 +927,73 @@ Func_e994e: add hl, bc pop bc inc de - jr .asm_e994e + jr .loop -.asm_e99a6 +.done ret -Func_e99a7: +PrintPCBox_DrawTopBorder: coord hl, 0, 0 ld a, $79 ld [hli], a ld a, $7a ld c, SCREEN_WIDTH - 2 -.asm_e99b1 +.loop ld [hli], a dec c - jr nz, .asm_e99b1 + jr nz, .loop ld a, $7b ld [hl], a ret -Func_e99b9: +PrintPCBox_DrawLeftAndRightBorders: coord hl, 0, 0 ld de, SCREEN_WIDTH - 1 ld c, SCREEN_HEIGHT -.asm_e99c1 +.loop ld a, $7c ld [hl], a add hl, de ld a, $7c ld [hli], a dec c - jr nz, .asm_e99c1 + jr nz, .loop ret -Func_e99cc: +PrintPCBox_DrawBottomBorder: coord hl, 0, 17 -Func_e99cf: +PrintPCBox_DrawBottomBorderAtHL: ld a, $7d ld [hli], a ld a, $7a ld c, SCREEN_WIDTH - 2 -.asm_e99b1 +.loop ld [hli], a dec c - jr nz, .asm_e99b1 + jr nz, .loop ld a, $7e ld [hl], a ret -Func_e99de: +PrintPCBox_PlaceHorizontalLines: coord hl, 4, 0 ld c, 6 - call Func_e99eb + call .PlaceHorizontalLine coord hl, 6, 1 ld c, 6 -Func_e99eb: -.asm_e99eb +.PlaceHorizontalLine: +.loop push bc push hl - ld de, String_e99fd + ld de, .HorizontalLineString call PlaceString pop hl ld bc, 3 * SCREEN_WIDTH add hl, bc pop bc dec c - jr nz, .asm_e99eb + jr nz, .loop ret -String_e99fd: +.HorizontalLineString: db "----------@" diff --git a/engine/unknown_ea3ea.asm b/engine/unknown_ea3ea.asm index 39f3de7e..9962649d 100755 --- a/engine/unknown_ea3ea.asm +++ b/engine/unknown_ea3ea.asm @@ -19,11 +19,11 @@ Func_ea3ea: ; ea3ea (3a:63ea) call LoadMonData ld hl, wTileMap - lb bc, $10, $12 + lb bc, 16, 18 call TextBoxBorder coord hl, 0, 12 - lb bc, $04, $12 + lb bc, 4, 18 call TextBoxBorder coord hl, 3, 10 @@ -46,7 +46,7 @@ Func_ea3ea: ; ea3ea (3a:63ea) ld [wPokeBallAnimData], a ld [wd0b5], a ld hl, wPartyMonNicks - call Func_ea511 + call .GetNamePointer coord hl, 8, 2 call PlaceString @@ -65,16 +65,16 @@ Func_ea3ea: ; ea3ea (3a:63ea) call PrintNumber coord hl, 8, 4 - ld de, String_ea52f + ld de, .OT call PlaceString ld hl, wPartyMonOT - call Func_ea511 + call .GetNamePointer coord hl, 9, 5 call PlaceString coord hl, 9, 6 - ld de, String_ea533 + ld de, .IDNo call PlaceString coord hl, 13, 6 @@ -83,7 +83,7 @@ Func_ea3ea: ; ea3ea (3a:63ea) call PrintNumber coord hl, 9, 8 - ld de, String_ea537 + ld de, .Stats ld a, [hFlags_0xFFFA] set 2, a ld [hFlags_0xFFFA], a @@ -115,24 +115,24 @@ Func_ea3ea: ; ea3ea (3a:63ea) coord hl, 1, 13 ld a, [wLoadedMonMoves] - call Func_ea51d + call .PlaceMoveName coord hl, 1, 14 ld a, [wLoadedMonMoves + 1] - call Func_ea51d + call .PlaceMoveName coord hl, 1, 15 ld a, [wLoadedMonMoves + 2] - call Func_ea51d + call .PlaceMoveName coord hl, 1, 16 ld a, [wLoadedMonMoves + 3] - call Func_ea51d + call .PlaceMoveName - ld b, $04 ; SET_PAL_STATUS_SCREEN + ld b, $4 ; SET_PAL_STATUS_SCREEN call RunPaletteCommand - ld a, $01 + ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a call Delay3 call GBPalNormal @@ -140,7 +140,7 @@ Func_ea3ea: ; ea3ea (3a:63ea) call LoadFlippedFrontSpriteByMonIndex ret -Func_ea511: ; ea511 (3a:6511) +.GetNamePointer: ; ea511 (3a:6511) ld bc, NAME_LENGTH ld a, [wWhichPokemon] call AddNTimes @@ -148,36 +148,36 @@ Func_ea511: ; ea511 (3a:6511) ld d, h ret -Func_ea51d: ; ea51d (3a:651d) +.PlaceMoveName: ; ea51d (3a:651d) and a - jr z, .asm_e6528 + jr z, .no_move ld [wPokeBallAnimData], a call GetMoveName - jr .asm_ea52b + jr .place_string -.asm_e6528 - ld de, String_ea554 -.asm_ea52b +.no_move + ld de, .Blank +.place_string call PlaceString ret ; ea52f -String_ea52f: +.OT: db "OT/@" ; ea533 -String_ea533: +.IDNo: db $73, "№/@" ; ea537 -String_ea537: +.Stats: db "ATTACK" next "DEFENSE" next "SPEED" next "SPECIAL@" ; ea554 -String_ea554: ; ea554 (3a:6554) +.Blank: ; ea554 (3a:6554) db "--------------@" GFX_ea563: ; ea563 (3a:6563) @@ -195,8 +195,8 @@ Func_ea573: ; ea573 (3a:6573) call CopyVideoData ld hl, wOAMBuffer + 32 * 4 - ld a, $08 - ld c, $08 + ld a, $8 + ld c, $8 .loop ld [hl], $10 inc hl @@ -204,9 +204,9 @@ Func_ea573: ; ea573 (3a:6573) inc hl ld [hl], $fe inc hl - ld [hl], $00 + ld [hl], $0 inc hl - add $08 + add $8 dec c jr nz, .loop ret @@ -218,7 +218,7 @@ GFX_ea597End: Func_ea5b7: ; ea5b7 (3a:65b7) ld hl, wOAMBuffer + 32 * 4 + 2 ld de, 4 - ld a, [$c971] + ld a, [wPrinterStatusFlags] ld c, 8 .asm_ea5c2 sla a @@ -235,7 +235,7 @@ Func_ea5b7: ; ea5b7 (3a:65b7) ret Func_ea5d1: ; ea5d1 (3a:65d1) - ld a, [wOverworldMap] + ld a, [wPrinterSendState] ld e, a ld d, 0 ld hl, Jumptable_ea5e0 @@ -269,19 +269,19 @@ Jumptable_ea5e0: Func_ea606: ; ea606 (3a:6606) - ld hl, wOverworldMap + ld hl, wPrinterSendState inc [hl] ret Func_ea60b: ; ea60b (3a:660b) - ld hl, wOverworldMap + ld hl, wPrinterSendState dec [hl] ret Func_ea610: ; ea610 (3a:6610) xor a - ld [$c971], a - ld hl, wOverworldMap + ld [wPrinterStatusFlags], a + ld hl, wPrinterSendState set 7, [hl] ret @@ -291,7 +291,7 @@ Func_ea61a: ; ea61a (3a:661a) Func_ea61e: ; ea61e (3a:661e) xor a - ld [wOverworldMap], a + ld [wPrinterSendState], a ret Func_ea623: ; ea623 (3a:6623) @@ -299,19 +299,19 @@ Func_ea623: ; ea623 (3a:6623) ld hl, Data_ea9de call Func_ea76b xor a - ld [$c976], a - ld [$c977], a - ld a, [$caf4] - ld [$c6e9], a + ld [wPrinterDataSize], a + ld [wPrinterDataSize + 1], a + ld a, [wPrinterQueueLength] + ld [wPrinterRowIndex], a call Func_ea606 call Func_ea74c - ld a, $01 - ld [$cae0], a + ld a, $1 + ld [wPrinterStatusIndicator], a ret Func_ea645: ; ea645 (3a:6645) call Func_ea784 - ld hl, $c6e9 + ld hl, wPrinterRowIndex ld a, [hl] and a jr z, Func_ea671 @@ -319,24 +319,24 @@ Func_ea645: ; ea645 (3a:6645) call Func_ea76b call Func_ea7e9 ld a, $80 - ld [$c976], a - ld a, $02 - ld [$c977], a + ld [wPrinterDataSize], a + ld a, $2 + ld [wPrinterDataSize + 1], a call Func_ea7a2 call Func_ea606 call Func_ea74c - ld a, $02 - ld [$cae0], a + ld a, $2 + ld [wPrinterStatusIndicator], a ret Func_ea671: ; ea671 (3a:6671) - ld a, $06 - ld [wOverworldMap], a + ld a, $6 + ld [wPrinterSendState], a ld hl, Data_ea9f0 call Func_ea76b xor a - ld [$c976], a - ld [$c977], a + ld [wPrinterDataSize], a + ld [wPrinterDataSize + 1], a call Func_ea606 call Func_ea74c ret @@ -346,22 +346,22 @@ Func_ea68a: ; ea68a (3a:668a) ld hl, Data_ea9e4 call Func_ea76b call Func_ea7d2 - ld a, $04 - ld [$c976], a - ld a, $00 - ld [$c977], a + ld a, $4 + ld [wPrinterDataSize], a + ld a, $0 + ld [wPrinterDataSize + 1], a call Func_ea7a2 call Func_ea606 call Func_ea74c - ld a, $03 - ld [$cae0], a + ld a, $3 + ld [wPrinterStatusIndicator], a ret Func_ea6af: ; ea6af (3a:66af) - ld hl, $c973 + ld hl, wPrinterSerialFrameDelay inc [hl] ld a, [hl] - cp a, $06 + cp a, $6 ret c xor a ld [hl], a @@ -369,14 +369,14 @@ Func_ea6af: ; ea6af (3a:66af) ret Func_ea6bd: ; ea6bd (3a:66bd) - ld hl, $c973 + ld hl, wPrinterSerialFrameDelay inc [hl] ld a, [hl] cp 6 ret c xor a ld [hl], a - ld hl, $c6e9 + ld hl, wPrinterRowIndex dec [hl] call Func_ea60b call Func_ea60b @@ -385,18 +385,18 @@ Func_ea6bd: ; ea6bd (3a:66bd) Func_ea6d2: ; ea6d2 (3a:66d2) call Func_ea742 ret c - ld a, [$c970] + ld a, [wPrinterHandshake] cp a, $ff jr nz, .asm_ea6e4 - ld a, [$c971] + ld a, [wPrinterStatusFlags] cp a, $ff jr z, .asm_ea6fb .asm_ea6e4 - ld a, [$c970] + ld a, [wPrinterHandshake] cp a, $81 jr nz, .asm_ea6fb - ld a, [$c971] - cp a, $00 + ld a, [wPrinterStatusFlags] + cp a, $0 jr nz, .asm_ea6fb ld hl, wPrinterConnectionOpen set 1, [hl] @@ -404,18 +404,18 @@ Func_ea6d2: ; ea6d2 (3a:66d2) ret .asm_ea6fb - ld a, $0e - ld [wOverworldMap], a + ld a, $e + ld [wPrinterSendState], a ret Func_ea701: ; ea701 (3a:6701) call Func_ea742 ret c - ld a, [$c971] + ld a, [wPrinterStatusFlags] and $f0 jr nz, .asm_ea71b - ld a, [$c971] - and $01 + ld a, [wPrinterStatusFlags] + and $1 jr nz, .asm_ea717 call Func_ea606 ret @@ -426,13 +426,13 @@ Func_ea701: ; ea701 (3a:6701) .asm_ea71b ld a, $11 - ld [wOverworldMap], a + ld [wPrinterSendState], a ret Func_ea721: ; ea721 (3a:6721) call Func_ea742 ret c - ld a, [$c971] + ld a, [wPrinterStatusFlags] and $f3 ret nz call Func_ea606 @@ -444,11 +444,11 @@ Func_ea732: ; ea732 (3a:6732) ld a, [wPrinterOpcode] and a ret nz - ld a, [$c971] + ld a, [wPrinterStatusFlags] and $f0 ret nz xor a - ld [wOverworldMap], a + ld [wPrinterSendState], a ret Func_ea742: ; ea742 (3a:6742) @@ -467,14 +467,14 @@ Func_ea74c: ; ea74c (3a:674c) ld a, [wPrinterOpcode] and a jr nz, .asm_ea74c - ld a, $01 + ld a, $1 ld [wPrinterOpcode], a xor a - ld [$c974], a - ld [$c975], a + ld [wPrinterSendByteOffset], a + ld [wPrinterSendByteOffset + 1], a ld a, $88 ld [rSB], a - ld a, $01 + ld a, $1 ld [rSC], a ld a, $81 ld [rSC], a @@ -482,52 +482,52 @@ Func_ea74c: ; ea74c (3a:674c) Func_ea76b: ; ea76b (3a:676b) ld a, [hli] - ld [$c6ea], a + ld [wPrinterDataHeader], a ld a, [hli] - ld [$c6eb], a + ld [wPrinterDataHeader + 1], a ld a, [hli] - ld [$c6ec], a + ld [wPrinterDataHeader + 2], a ld a, [hli] - ld [$c6ed], a + ld [wPrinterDataHeader + 3], a ld a, [hli] - ld [$c6ee], a + ld [wPrinterDataHeader + 4], a ld a, [hl] - ld [$c6ef], a + ld [wPrinterDataHeader + 5], a ret Func_ea784: ; ea784 (3a:6784) xor a - ld hl, $c6ea + ld hl, wPrinterDataHeader ld [hli], a ld [hli], a ld [hli], a ld [hl], a - ld hl, $c6ee + ld hl, wPrinterDataHeader + 4 ld [hli], a ld [hl], a xor a - ld [$c976], a - ld [$c977], a - ld hl, $c6f0 + ld [wPrinterDataSize], a + ld [wPrinterDataSize + 1], a + ld hl, wPrinterSendDataSource ld bc, $280 call FillMemory ret Func_ea7a2: ; ea7a2 (3a:67a2) - ld hl, $0000 - ld bc, $0004 - ld de, $c6ea + ld hl, $0 + ld bc, $4 + ld de, wPrinterDataHeader call Func_ea7c5 - ld a, [$c976] + ld a, [wPrinterDataSize] ld c, a - ld a, [$c977] + ld a, [wPrinterDataSize + 1] ld b, a - ld de, $c6f0 + ld de, wPrinterSendDataSource call Func_ea7c5 ld a, l - ld [$c6ee], a + ld [wPrinterDataHeader + 4], a ld a, h - ld [$c6ef], a + ld [wPrinterDataHeader + 5], a ret Func_ea7c5: ; ea7c5 (3a:67c5) @@ -546,36 +546,36 @@ Func_ea7c5: ; ea7c5 (3a:67c5) ret Func_ea7d2: ; ea7d2 (3a:67d2) - ld a, $01 - ld [$c6f0], a - ld a, [$cae2] - ld [$c6f1], a + ld a, $1 + ld [wPrinterSendDataSource], a + ld a, [wcae2] + ld [wPrinterStatusReceived], a ld a, $e4 - ld [$c6f2], a - ld a, [$cae3] - ld [$c6f3], a + ld [wc6f2], a + ld a, [wPrinterSettingsTempCopy] + ld [wc6f3], a ret Func_ea7e9: ; ea7e9 (3a:67e9) - ld a, [$c6e9] + ld a, [wPrinterRowIndex] ld b, a - ld a, [$caf4] + ld a, [wPrinterQueueLength] sub b - ld hl, $c978 - ld de, $0028 -.asm_ea7f7 + ld hl, wPrinterTileBuffer + ld de, $28 +.get_start_addr and a - jr z, .asm_ea7fe + jr z, .start_working add hl, de dec a - jr .asm_ea7f7 + jr .get_start_addr -.asm_ea7fe +.start_working ld e, l ld d, h - ld hl, $c6f0 + ld hl, wPrinterSendDataSource ld c, $28 -.asm_ea805 +.prep_loop ld a, [de] inc de push bc @@ -586,47 +586,47 @@ Func_ea7e9: ; ea7e9 (3a:67e9) and $f0 ld e, a ld a, d - and $0f + and $f ld d, a - and $08 + and $8 ld a, d - jr nz, .asm_ea81d + jr nz, .vtiles1 or $90 - jr .asm_ea81f + jr .got_vram_address -.asm_ea81d +.vtiles1 or $80 -.asm_ea81f +.got_vram_address ld d, a - lb bc, $3a, $01 + lb bc, BANK(Func_ea7e9), $1 call CopyVideoData pop hl - ld de, $0010 + ld de, $10 add hl, de pop de pop bc dec c - jr nz, .asm_ea805 - call Func_ea834 + jr nz, .prep_loop + call .UnnecessaryCall ret -Func_ea834: ; ea834 (3a:6834) - ld hl, $cbdc - ld bc, $0020 +.UnnecessaryCall: ; ea834 (3a:6834) + ld hl, wcbdc + ld bc, $20 xor a call FillMemory - ld hl, $c300 + ld hl, wOAMBuffer ld c, $28 -.asm_ea843 +.master_loop push bc push hl - call Func_ea860 - jr nc, .asm_ea856 - call Func_ea886 - call Func_ea8a1 - call Func_ea902 - call Func_ea999 -.asm_ea856 + call .AreWePrintingThisSegment + jr nc, .skip_segment + call .GetVRAMAddress + call .GetOAMFlags + call .ApplyObjectPalettes + call .PlaceObject +.skip_segment pop hl inc hl inc hl @@ -634,44 +634,44 @@ Func_ea834: ; ea834 (3a:6834) inc hl pop bc dec c - jr nz, .asm_ea843 + jr nz, .master_loop ret -Func_ea860: ; ea860 (3a:6860) - ld a, [$c6e9] +.AreWePrintingThisSegment: ; ea860 (3a:6860) + ld a, [wPrinterRowIndex] ld b, a - ld a, [$caf4] + ld a, [wPrinterQueueLength] sub b ld c, a ld b, $10 -.asm_ea86b +.add_n_times ld a, c and a - jr z, .asm_ea876 + jr z, .check ld a, b add $10 ld b, a dec c - jr .asm_ea86b + jr .add_n_times -.asm_ea876 +.check ld a, b ld e, a add $10 ld d, a ld a, [hl] cp e - jr c, .asm_ea884 + jr c, .not_printing cp d - jr nc, .asm_ea884 + jr nc, .not_printing scf ret -.asm_ea884 +.not_printing and a ret -Func_ea886: ; ea886 (3a:6886) +.GetVRAMAddress: ; ea886 (3a:6886) push hl inc hl inc hl @@ -681,81 +681,81 @@ Func_ea886: ; ea886 (3a:6886) and $f0 ld e, a ld a, d - and $0f + and $f or $80 ld d, a - ld hl, $cbdc - lb bc, $3a, $01 + ld hl, wcbdc + lb bc, BANK(.GetVRAMAddress), $1 call CopyVideoData pop hl ret -Func_ea8a1: ; ea8a1 (3a:68a1) +.GetOAMFlags: ; ea8a1 (3a:68a1) push hl inc hl inc hl inc hl ld a, [hl] - call Func_ea8ab + call .DoBitOperation pop hl ret -Func_ea8ab: ; ea8ab (3a:68ab) +.DoBitOperation: ; ea8ab (3a:68ab) and $60 swap a ld e, a ld d, 0 - ld hl, Jumptable_ea8ba + ld hl, .Jumptable add hl, de ld a, [hli] ld h, [hl] ld l, a jp [hl] -Jumptable_ea8ba: ; ea8ba (3a:68ba) - dw Func_ea8c2 - dw Func_ea8c3 - dw Func_ea8c7 - dw Func_ea8cb +.Jumptable: ; ea8ba (3a:68ba) + dw .nop + dw .one + dw .two + dw .both -Func_ea8c2: ; ea8c2 (3a:68c2) +.nop: ; ea8c2 (3a:68c2) ret -Func_ea8c3: ; ea8c3 (3a:68c3) - call Func_ea8d2 +.one: ; ea8c3 (3a:68c3) + call .Invert ret -Func_ea8c7: ; ea8c7 (3a:68c7) - call Func_ea8e8 +.two: ; ea8c7 (3a:68c7) + call .Swap ret -Func_ea8cb: ; ea8cb (3a:68cb) - call Func_ea8d2 - call Func_ea8e8 +.both: ; ea8cb (3a:68cb) + call .Invert + call .Swap ret -Func_ea8d2: ; ea8d2 (3a:68d2) - ld hl, $cbdc +.Invert: ; ea8d2 (3a:68d2) + ld hl, wcbdc ld c, 16 -.asm_ea8d7 +.byte_loop ld d, [hl] ld a, 0 ld b, 8 -.asm_ea8dc +.bit_loop sla d rr a dec b - jr nz, .asm_ea8dc + jr nz, .bit_loop ld [hli], a dec c - jr nz, .asm_ea8d7 + jr nz, .byte_loop ret -Func_ea8e8: ; ea8e8 (3a:68e8) - ld hl, $cbdc - ld de, $cbea - ld c, $04 -.asm_ea8f0 +.Swap: ; ea8e8 (3a:68e8) + ld hl, wcbdc + ld de, wcbea + ld c, $4 +.swap_loop ld b, [hl] ld a, [de] ld [hli], a @@ -771,19 +771,19 @@ Func_ea8e8: ; ea8e8 (3a:68e8) dec de dec de dec c - jr nz, .asm_ea8f0 + jr nz, .swap_loop ret -Func_ea902: ; ea902 (3a:6902) +.ApplyObjectPalettes: ; ea902 (3a:6902) push hl - ld hl, $cbdc - ld de, $cbec - ld a, $08 -.asm_ea90b + ld hl, wcbdc + ld de, wcbec + ld a, 8 +.loop1 push af - ld bc, $0000 - ld a, $08 -.asm_ea911 + ld bc, $0 + ld a, 8 +.loop2 push af xor a rlc [hl] @@ -794,12 +794,12 @@ Func_ea902: ; ea902 (3a:6902) dec hl push hl push de - call Func_ea936 + call .ExpandPalettesToBC pop de pop hl pop af dec a - jr nz, .asm_ea911 + jr nz, .loop2 inc hl inc hl ld a, b @@ -810,19 +810,19 @@ Func_ea902: ; ea902 (3a:6902) inc de pop af dec a - jr nz, .asm_ea90b + jr nz, .loop1 pop hl ret -Func_ea936 ; ea936 (3a:6936) - call Func_ea93d - call Func_ea96d +.ExpandPalettesToBC: ; ea936 (3a:6936) + call .GetPaletteFunction + call .ApplyPaletteFunction ret -Func_ea93d: ; ea93d (3a:693d) +.GetPaletteFunction: ; ea93d (3a:693d) ld e, a ld d, 0 - ld hl, Jumptable_ea949 + ld hl, .PalJumptable add hl, de add hl, de ld a, [hli] @@ -830,41 +830,41 @@ Func_ea93d: ; ea93d (3a:693d) ld l, a jp [hl] -Jumptable_ea949: ; ea949 (3a:6949) - dw Func_ea951 - dw Func_ea95f - dw Func_ea956 - dw Func_ea966 +.PalJumptable: ; ea949 (3a:6949) + dw .Pal0 + dw .Pal1 + dw .Pal2 + dw .Pal3 -Func_ea951: ; ea951 (3a:6951) +.Pal0: ; ea951 (3a:6951) ld a, [rOBP0] - and $03 + and $3 ret -Func_ea956: ; ea956 (3a:6956) +.Pal2: ; ea956 (3a:6956) ld a, [rOBP0] - and $0c + and $c srl a srl a ret -Func_ea95f: ; ea95f (3a:695f) +.Pal1: ; ea95f (3a:695f) ld a, [rOBP0] and $30 swap a ret -Func_ea966: ; ea966 (3a:6966) +.Pal3: ; ea966 (3a:6966) ld a, [rOBP0] and $c0 rlca rlca ret -Func_ea96d: ; ea96d (3a:696d) +.ApplyPaletteFunction: ; ea96d (3a:696d) ld e, a ld d, 0 - ld hl, Jumptable_ea979 + ld hl, .PalFunJumptable add hl, de add hl, de ld a, [hli] @@ -872,62 +872,62 @@ Func_ea96d: ; ea96d (3a:696d) ld l, a jp [hl] -Jumptable_ea979: ; ea979 (3a:6979) - dw Func_ea981 - dw Func_ea986 - dw Func_ea98c - dw Func_ea992 +.PalFunJumptable: ; ea979 (3a:6979) + dw .zero_zero + dw .one_zero + dw .zero_one + dw .one_one -Func_ea981: ; ea981 (3a:6981) +.zero_zero: ; ea981 (3a:6981) sla b sla c ret -Func_ea986: ; ea986 (3a:6986) +.one_zero: ; ea986 (3a:6986) scf rl b sla c ret -Func_ea98c: ; ea98c (3a:698c) +.zero_one: ; ea98c (3a:698c) sla b scf rl c ret -Func_ea992: ; ea992 (3a:6992) +.one_one: ; ea992 (3a:6992) scf rl b scf rl c ret -Func_ea999: ; ea999 (3a:6999) +.PlaceObject: ; ea999 (3a:6999) push hl ld a, [hli] ld c, [hl] - and $08 - jr nz, .asm_ea9a5 - ld hl, $c6f0 - jr .asm_ea9a8 - -.asm_ea9a5 - ld hl, $c830 -.asm_ea9a8 - ld b, $00 + and $8 + jr nz, .use_wc830 + ld hl, wPrinterSendDataSource + jr .got_data_source + +.use_wc830 + ld hl, wc830 +.got_data_source + ld b, $0 ld a, c - and $f8 - sub $08 + and %11111000 + sub $8 ld c, a sla c rl b add hl, bc ld e, l ld d, h - ld hl, $cbec - ld c, $08 -.asm_ea9bc - call Func_ea9d0 + ld hl, wcbec + ld c, $8 +.coord_copy_loop + call .GetBitMask ld a, [de] and b or [hl] @@ -941,14 +941,14 @@ Func_ea999: ; ea999 (3a:6999) inc hl inc de dec c - jr nz, .asm_ea9bc + jr nz, .coord_copy_loop pop hl ret -Func_ea9d0: ; ea9d0 (3a:69d0) +.GetBitMask: ; ea9d0 (3a:69d0) push hl push de - ld de, $fff0 + ld de, -$10 add hl, de ld a, [hli] or [hl] @@ -959,14 +959,20 @@ Func_ea9d0: ; ea9d0 (3a:69d0) ret Data_ea9de: ; ea9de - db $01, $00, $00, $00, $01, $00 + db 1, 0, $00, 0 + dw 1 Data_ea9e4: ; ea9e4 - db $02, $00, $04, $00, $00, $00 + db 2, 0, $04, 0 + dw 0 Data_ea9ea: ; ea9ea - db $04, $00, $80, $02, $00, $00 + db 4, 0, $80, 2 + dw 0 Data_ea9f0: ; ea9f0 - db $04, $00, $00, $00, $04, $00 + db 4, 0, $00, 0 + dw 4 Data_ea9f6: ; ea9f6 - db $08, $00, $00, $00, $08, $00 + db 8, 0, $00, 0 + dw 8 Data_ea9fc: ; ea9fc - db $0f, $00, $00, $00, $0f, $00 + db 15, 0, $00, 0 + dw 15 diff --git a/wram.asm b/wram.asm index a64a30c0..cb60a9b5 100755 --- a/wram.asm +++ b/wram.asm @@ -531,7 +531,9 @@ wYellowIntroSurfingPikaSineWaveBuffer:: ; c800 ; ds $100 ds $10 wc810:: ; c810 - ds $f0 + ds $20 +wc830:: ; c830 + ds $d0 ; c900 ds $70 @@ -565,7 +567,16 @@ wPrinterPokedexEntryTextPointer:: ; caf5 dw ds 2 wPrinterPokedexMonIsOwned:: ; caf9 - ds 259 + ds 227 + +wcbdc:: ; cbdc + ds 14 + +wcbea:: ; cbea + ds 2 + +wcbec:: ; cbec + ds 16 wRedrawRowOrColumnSrcTiles:: ; cbfc ; the tiles of the row or column to be redrawn by RedrawRowOrColumn -- cgit v1.3.1-sl0p From 19656f9dee2671838983ab407e901bd6bb49006a Mon Sep 17 00:00:00 2001 From: pikalaxalt Date: Wed, 8 Jun 2016 01:05:34 -0400 Subject: No more standalone WRAM addresses in the Event Flags array --- constants/event_constants.asm | 2 + constants/event_macros.asm | 10 ++ engine/hall_of_fame.asm | 3 +- engine/items/items.asm | 207 ++++++++++++++++++++---------------------- engine/menu/start_menu.asm | 91 +++++++++---------- home.asm | 61 ++++++------- home/overworld.asm | 6 +- scripts/billshouse.asm | 3 +- scripts/oakslab.asm | 6 +- scripts/rockethideout4.asm | 3 +- wram.asm | 134 +-------------------------- 11 files changed, 197 insertions(+), 329 deletions(-) (limited to 'wram.asm') diff --git a/constants/event_constants.asm b/constants/event_constants.asm index 2d1fab45..9c40b013 100644 --- a/constants/event_constants.asm +++ b/constants/event_constants.asm @@ -2560,3 +2560,5 @@ const_value = 0 const EVENT_9FD ; 9FD, (D886, bit 5) const EVENT_9FE ; 9FE, (D886, bit 6) const EVENT_9FF ; 9FF, (D886, bit 7) + +NUM_EVENT_FLAGS EQU const_value diff --git a/constants/event_macros.asm b/constants/event_macros.asm index bf0a95b5..a3ce9746 100644 --- a/constants/event_macros.asm +++ b/constants/event_macros.asm @@ -57,6 +57,16 @@ event_byte = ((\2) / 8) ld \1, wEventFlags + event_byte ENDM +EventFlagAddressa: MACRO +event_byte = ((\1) / 8) + ld [wEventFlags + event_byte], a + ENDM + +aEventFlagAddress: MACRO +event_byte = ((\1) / 8) + ld a, [wEventFlags + event_byte] + ENDM + ;\1 = event index CheckEventHL: MACRO event_byte = ((\1) / 8) diff --git a/engine/hall_of_fame.asm b/engine/hall_of_fame.asm index 9649da5d..ee138737 100755 --- a/engine/hall_of_fame.asm +++ b/engine/hall_of_fame.asm @@ -223,8 +223,7 @@ HoFLoadMonPlayerPicTileIDs: ; 703c7 (1c:43c7) predef_jump CopyTileIDsFromList HoFDisplayPlayerStats: ; 703d1 (1c:43d1) - ld hl, wd747 - set 3, [hl] + SetEvent EVENT_HALL_OF_FAME_DEX_RATING predef DisplayDexRating coord hl, 0, 4 lb bc, 6, 10 diff --git a/engine/items/items.asm b/engine/items/items.asm index cffcb5b3..197e5e5d 100755 --- a/engine/items/items.asm +++ b/engine/items/items.asm @@ -2,7 +2,7 @@ UseItem_: ; d2ed (3:52ed) ld a, 1 ld [wActionResultOrTookBattleTurn], a ; initialise to success value ld a, [wcf91] ;contains item_ID - cp a, HM_01 + cp HM_01 jp nc, ItemUseTMHM ld hl, ItemUsePtrTable dec a @@ -112,17 +112,17 @@ ItemUseBall: ; d3ad (3:53ad) cp $4 ; pikachu battle? jr z, .UseBall ld a, [wPartyCount] ;is Party full? - cp a, PARTY_LENGTH + cp PARTY_LENGTH jr nz, .UseBall ld a, [wNumInBox] ;is Box full? - cp a, MONS_PER_BOX + cp MONS_PER_BOX jp z, BoxFullCannotThrowBall .UseBall ;ok, you can use a ball xor a ld [wCapturedMonSpecies], a ld a, [wBattleType] - cp a, 2 ;SafariBattle + cp 2 ;SafariBattle jr nz, .skipSafariZoneCode .safariZone ; remove a Safari Ball from inventory @@ -151,22 +151,21 @@ ItemUseBall: ; d3ad (3:53ad) ld bc, NAME_LENGTH call CopyData ; save the player's name in the Wild Monster data ld a, [wBattleType] - cp $1 + cp MASTER_BALL jp nz, .BallSuccess ld a, $1 ld [wCapturedMonSpecies], a - ld a, [wd74c] - bit 7, a + CheckEvent EVENT_02F ld b, $63 jp nz, .next12 jp .BallSuccess .notOldManBattle ld a, [wCurMap] - cp a, POKEMONTOWER_6 + cp POKEMONTOWER_6 jr nz, .loop ld a, [wEnemyMonSpecies2] - cp a, MAROWAK + cp MAROWAK ld b, $10 jp z, .next12 ; if not fighting ghost Marowak, loop until a random number in the current @@ -177,15 +176,15 @@ ItemUseBall: ; d3ad (3:53ad) ld hl, wcf91 .asm_d54a ld a, [hl] - cp a, MASTER_BALL + cp MASTER_BALL jp z, .BallSuccess - cp a, POKE_BALL + cp POKE_BALL jr z, .checkForAilments ld a, 200 cp b jr c, .loop ;get only numbers <= 200 for Great Ball ld a, [hl] - cp a, GREAT_BALL + cp GREAT_BALL jr z, .checkForAilments ld a, 150 ;get only numbers <= 150 for Ultra Ball cp b @@ -198,7 +197,7 @@ ItemUseBall: ; d3ad (3:53ad) ld a, [wEnemyMonStatus] ;status ailments and a jr z, .noAilments - and a, 1 << FRZ | SLP ;is frozen and/or asleep? + and 1 << FRZ | SLP ;is frozen and/or asleep? ld c, 12 jr z, .notFrozenOrAsleep ld c, 25 @@ -318,13 +317,13 @@ ItemUseBall: ; d3ad (3:53ad) ld [H_QUOTIENT + 3], a .next13 ld a, [H_QUOTIENT + 3] - cp a, 10 + cp 10 ld b, $20 jr c, .next12 - cp a, 30 + cp 30 ld b, $61 jr c, .next12 - cp a, 70 + cp 70 ld b, $62 jr c, .next12 ld b, $63 @@ -350,19 +349,19 @@ ItemUseBall: ; d3ad (3:53ad) pop af ld [wWhichPokemon], a ld a, [wPokeBallAnimData] - cp a, $10 + cp $10 ld hl, ItemUseBallText00 jp z, .printText0 - cp a, $20 + cp $20 ld hl, ItemUseBallText01 jp z, .printText0 - cp a, $61 + cp $61 ld hl, ItemUseBallText02 jp z, .printText0 - cp a, $62 + cp $62 ld hl, ItemUseBallText03 jp z, .printText0 - cp a, $63 + cp $63 ld hl, ItemUseBallText04 jp z, .printText0 ld hl, wEnemyMonHP ;current HP @@ -460,8 +459,7 @@ ItemUseBall: ; d3ad (3:53ad) call ClearSprites call SendNewMonToBox ld hl, ItemUseBallText07 - ld a, [wd7f1] - bit 0, a + CheckEvent EVENT_MET_BILL jr nz, .sendToBox2 ld hl, ItemUseBallText08 .sendToBox2 @@ -540,7 +538,7 @@ ItemUseBicycle: ; d6d7 (3:56d7) jp nz, ItemUseNotTime ld a, [wWalkBikeSurfState] ld [wWalkBikeSurfStateCopy], a - cp a, 2 ; is the player surfing? + cp 2 ; is the player surfing? jp z, ItemUseNotTime dec a ; is player already bicycling? jr nz, .tryToGetOnBike @@ -575,7 +573,7 @@ ItemUseBicycle: ; d6d7 (3:56d7) ItemUseSurfboard: ; d725 (3:5725) ld a, [wWalkBikeSurfState] ld [wWalkBikeSurfStateCopy], a - cp a, 2 ; is the player already surfing? + cp 2 ; is the player already surfing? jr z, .tryToStopSurfing .tryToSurf call IsNextTileShoreOrWater @@ -831,13 +829,13 @@ ItemUseMedicine: ; d8ae (3:58ae) jr z, ItemUseMedicine ; if so, force another choice .checkItemType ld a, [wcf91] - cp a, REVIVE + cp REVIVE jr nc, .healHP ; if it's a Revive or Max Revive - cp a, FULL_HEAL + cp FULL_HEAL jr z, .cureStatusAilment ; if it's a Full Heal - cp a, HP_UP + cp HP_UP jp nc, .useVitamin ; if it's a vitamin or Rare Candy - cp a, FULL_RESTORE + cp FULL_RESTORE jr nc, .healHP ; if it's a Full Restore or one of the potions ; fall through if it's one of the status-specifc healing items .cureStatusAilment @@ -845,19 +843,19 @@ ItemUseMedicine: ; d8ae (3:58ae) add hl, bc ; hl now points to status ld a, [wcf91] lb bc, ANTIDOTE_MSG, 1 << PSN - cp a, ANTIDOTE + cp ANTIDOTE jr z, .checkMonStatus lb bc, BURN_HEAL_MSG, 1 << BRN - cp a, BURN_HEAL + cp BURN_HEAL jr z, .checkMonStatus lb bc, ICE_HEAL_MSG, 1 << FRZ - cp a, ICE_HEAL + cp ICE_HEAL jr z, .checkMonStatus lb bc, AWAKENING_MSG, SLP - cp a, AWAKENING + cp AWAKENING jr z, .checkMonStatus lb bc, PARALYZ_HEAL_MSG, 1 << PAR - cp a, PARLYZ_HEAL + cp PARLYZ_HEAL jr z, .checkMonStatus lb bc, FULL_HEAL_MSG, $ff ; Full Heal .checkMonStatus @@ -899,9 +897,9 @@ ItemUseMedicine: ; d8ae (3:58ae) jr nz, .notFainted .fainted ld a, [wcf91] - cp a, REVIVE + cp REVIVE jr z, .updateInBattleFaintedData - cp a, MAX_REVIVE + cp MAX_REVIVE jr z, .updateInBattleFaintedData jp .healingItemNoEffect @@ -947,9 +945,9 @@ ItemUseMedicine: ; d8ae (3:58ae) .notFainted ld a, [wcf91] - cp a, REVIVE + cp REVIVE jp z, .healingItemNoEffect - cp a, MAX_REVIVE + cp MAX_REVIVE jp z, .healingItemNoEffect .compareCurrentHPToMaxHP push hl @@ -967,7 +965,7 @@ ItemUseMedicine: ; d8ae (3:58ae) jr nz, .notFullHP .fullHP ; if the pokemon's current HP equals its max HP ld a, [wcf91] - cp a, FULL_RESTORE + cp FULL_RESTORE jp nz, .healingItemNoEffect inc hl inc hl @@ -1068,15 +1066,15 @@ ItemUseMedicine: ; d8ae (3:58ae) .notUsingSoftboiled2 ld a, [wcf91] - cp a, SODA_POP + cp SODA_POP ld b, 60 ; Soda Pop heal amount jr z, .addHealAmount ld b, 80 ; Lemonade heal amount jr nc, .addHealAmount - cp a, FRESH_WATER + cp FRESH_WATER ld b, 50 ; Fresh Water heal amount jr z, .addHealAmount - cp a, SUPER_POTION + cp SUPER_POTION ld b, 200 ; Hyper Potion heal amount jr c, .addHealAmount ld b, 50 ; Super Potion heal amount @@ -1103,7 +1101,7 @@ ItemUseMedicine: ; d8ae (3:58ae) ld hl, 33 add hl, de ; hl now points to max HP ld a, [wcf91] - cp a, REVIVE + cp REVIVE jr z, .setCurrentHPToHalfMaxHP ld a, [hld] ld b, a @@ -1115,9 +1113,9 @@ ItemUseMedicine: ; d8ae (3:58ae) sbc b jr nc, .setCurrentHPToMaxHp ; if current HP exceeds max HP after healing ld a, [wcf91] - cp a, HYPER_POTION + cp HYPER_POTION jr c, .setCurrentHPToMaxHp ; if using a Full Restore or Max Potion - cp a, MAX_REVIVE + cp MAX_REVIVE jr z, .setCurrentHPToMaxHp ; if using a Max Revive jr .updateInBattleData @@ -1147,7 +1145,7 @@ ItemUseMedicine: ; d8ae (3:58ae) dec de .doneHealingPartyHP ; done updating the pokemon's current HP in the party data structure ld a, [wcf91] - cp a, FULL_RESTORE + cp FULL_RESTORE jr nz, .updateInBattleData ld bc, -31 add hl, bc @@ -1166,7 +1164,7 @@ ItemUseMedicine: ; d8ae (3:58ae) ld a, [hld] ld [wBattleMonHP + 1], a ld a, [wcf91] - cp a, FULL_RESTORE + cp FULL_RESTORE jr nz, .calculateHPBarCoords xor a ld [wBattleMonStatus], a ; remove the status ailment in the in-battle pokemon data @@ -1193,9 +1191,9 @@ ItemUseMedicine: ; d8ae (3:58ae) pop hl .skipRemovingItem ld a, [wcf91] - cp a, FULL_RESTORE + cp FULL_RESTORE jr c, .playStatusAilmentCuringSound - cp a, FULL_HEAL + cp FULL_HEAL jr z, .playStatusAilmentCuringSound ld a, SFX_HEAL_HP call PlaySoundWaitForCurrent @@ -1211,9 +1209,9 @@ ItemUseMedicine: ; d8ae (3:58ae) ld a, REVIVE_MSG ld [wPartyMenuTypeOrMessageID], a ld a, [wcf91] - cp a, REVIVE + cp REVIVE jr z, .showHealingItemMessage - cp a, MAX_REVIVE + cp MAX_REVIVE jr z, .showHealingItemMessage ld a, POTION_MSG ld [wPartyMenuTypeOrMessageID], a @@ -1269,10 +1267,10 @@ ItemUseMedicine: ; d8ae (3:58ae) pop de pop hl ld a, [wcf91] - cp a, RARE_CANDY + cp RARE_CANDY jp z, .useRareCandy push hl - sub a, HP_UP + sub HP_UP add a ld bc, 17 add hl, bc @@ -1284,7 +1282,7 @@ ItemUseMedicine: ; d8ae (3:58ae) ld a, 10 ld b, a ld a, [hl] ; a = MSB of stat experience of the appropriate stat - cp a, 100 ; is there already at least 25600 (256 * 100) stat experience? + cp 100 ; is there already at least 25600 (256 * 100) stat experience? jr nc, .vitaminNoEffect ; if so, vitamins can't add any more add b ; add 2560 (256 * 10) stat experience jr nc, .noCarry3 ; a carry should be impossible here, so this will always jump @@ -1295,7 +1293,7 @@ ItemUseMedicine: ; d8ae (3:58ae) call .recalculateStats ld hl, VitaminText ld a, [wcf91] - sub a, HP_UP - 1 + sub HP_UP - 1 ld c, a .statNameLoop ; loop to get the address of the name of the stat the vitamin increases dec c @@ -1338,7 +1336,7 @@ ItemUseMedicine: ; d8ae (3:58ae) ld bc, 33 add hl, bc ; hl now points to level ld a, [hl] ; a = level - cp a, MAX_LEVEL + cp MAX_LEVEL jr z, .vitaminNoEffect ; can't raise level above 100 inc a ld [hl], a ; store incremented level @@ -1478,8 +1476,8 @@ BaitRockCommon: ; dd9f (3:5d9f) ld [de], a ; zero escape factor (for bait), zero bait factor (for rock) .randomLoop ; loop until a random number less than 5 is generated call Random - and a, 7 - cp a, 5 + and 7 + cp 5 jr nc, .randomLoop inc a ; increment the random number, giving a range from 1 to 5 inclusive ld b, a @@ -1507,18 +1505,18 @@ ItemUseEscapeRope: ; ddcf (3:5dcf) and a jr nz, .notUsable ld a, [wCurMap] - cp a, AGATHAS_ROOM + cp AGATHAS_ROOM jr z, .notUsable - cp a, BILLS_HOUSE + cp BILLS_HOUSE jr z, .notUsable - cp a, POKEMON_FAN_CLUB + cp POKEMON_FAN_CLUB jr z, .notUsable ld a, [wCurMapTileset] ld b, a ld hl, EscapeRopeTilesets .loop ld a, [hli] - cp a, $ff + cp $ff jr z, .notUsable cp b jr nz, .loop @@ -1528,8 +1526,7 @@ ItemUseEscapeRope: ; ddcf (3:5dcf) call Func_1510 ld hl, wd72e res 4, [hl] - ld hl, wd790 - res 7, [hl] + ResetEvent EVENT_IN_SAFARI_ZONE xor a ld [wNumSafariBalls], a ld [wSafariZoneEntranceCurScript], a @@ -1579,19 +1576,19 @@ ItemUseCardKey: ; de57 (3:de57) ld [wUnusedD71F], a call GetTileAndCoordsInFrontOfPlayer ld a, [GetTileAndCoordsInFrontOfPlayer] ; $4586 - cp a, $18 + cp $18 jr nz, .next0 ld hl, CardKeyTable1 jr .next1 .next0 - cp a, $24 + cp $24 jr nz, .next2 ld hl, CardKeyTable2 jr .next1 .next2 - cp a, $5e + cp $5e jp nz, ItemUseNotTime ld hl, CardKeyTable3 .next1 @@ -1599,7 +1596,7 @@ ItemUseCardKey: ; de57 (3:de57) ld b, a .loop ld a, [hli] - cp a, $ff + cp $ff jp z, ItemUseNotTime cp b jr nz, .nextEntry1 @@ -1736,7 +1733,7 @@ ItemUseXStat: ; df69 (3:df69) push af ; save [wPlayerMoveEffect] push hl ld a, [wcf91] - sub a, X_ATTACK - ATTACK_UP1_EFFECT + sub X_ATTACK - ATTACK_UP1_EFFECT ld [hl], a ; store player move effect call PrintItemUseTextAndRemoveItem ld a, XSTATITEM_ANIM ; X stat item animation ID @@ -1769,10 +1766,9 @@ ItemUsePokeflute: ; dfbd (3:5fbd) ; if not in battle call ItemUseReloadOverworldData ld a, [wCurMap] - cp a, ROUTE_12 + cp ROUTE_12 jr nz, .notRoute12 - ld a, [wd7d8] - bit 7, a + CheckEvent EVENT_BEAT_ROUTE12_SNORLAX jr nz, .noSnorlaxOrPikachuToWakeUp ; if the player hasn't beaten Route 12 Snorlax ld hl, Route12SnorlaxFluteCoords @@ -1780,15 +1776,13 @@ ItemUsePokeflute: ; dfbd (3:5fbd) jr nc, .noSnorlaxOrPikachuToWakeUp ld hl, PlayedFluteHadEffectText call PrintText - ld hl, wd7d8 - set 6, [hl] + SetEvent EVENT_FIGHT_ROUTE12_SNORLAX ret .notRoute12 - cp a, ROUTE_16 + cp ROUTE_16 jr nz, .notRoute16 - ld a, [wd7e0] - bit 1, a + CheckEvent EVENT_BEAT_ROUTE16_SNORLAX jr nz, .noSnorlaxOrPikachuToWakeUp ; if the player hasn't beaten Route 16 Snorlax ld hl, Route16SnorlaxFluteCoords @@ -1796,12 +1790,11 @@ ItemUsePokeflute: ; dfbd (3:5fbd) jr nc, .noSnorlaxOrPikachuToWakeUp ld hl, PlayedFluteHadEffectText call PrintText - ld hl, wd7e0 - set 0, [hl] + SetEvent EVENT_FIGHT_ROUTE16_SNORLAX ret .notRoute16 - cp a, PEWTER_POKECENTER + cp PEWTER_POKECENTER jr nz, .noSnorlaxOrPikachuToWakeUp call CheckPikachuFollowingPlayer jr z, .noSnorlaxOrPikachuToWakeUp @@ -1841,7 +1834,7 @@ ItemUsePokeflute: ; dfbd (3:5fbd) and b ; remove Sleep status ld [hl], a ld a, c - and a, SLP + and SLP jr z, .asm_e063 ld a, $1 ld [wWereAnyMonsAsleep], a @@ -1855,7 +1848,7 @@ ItemUsePokeflute: ; dfbd (3:5fbd) ld hl, PlayedFluteHadEffectText call PrintText ld a, [wLowHealthAlarm] - and a, $80 + and $80 jr nz, .skipMusic call WaitForSoundToFinish ; wait for sound to end callba Music_PokeFluteInBattle ; play in-battle pokeflute music @@ -1880,7 +1873,7 @@ WakeUpEntireParty: ; e094 (3:6094) .loop ld a, [hl] push af - and a, SLP ; is pokemon asleep? + and SLP ; is pokemon asleep? jr z, .notAsleep ld a, 1 ld [wWereAnyMonsAsleep], a ; indicate that a pokemon had to be woken up @@ -1933,7 +1926,7 @@ PlayedFluteHadEffectText: ; e0c4 (3:60c4) call PlayMusic .musicWaitLoop ; wait for music to finish playing ld a, [wChannelSoundIDs + CH2] - cp a, SFX_POKEFLUTE + cp SFX_POKEFLUTE jr z, .musicWaitLoop call PlayDefaultMusic ; start playing normal music again .done @@ -2043,7 +2036,7 @@ FishingInit: ; e182 (3:6182) call IsNextTileShoreOrWater jr nc, .cannotFish ld a, [wWalkBikeSurfState] - cp a, 2 ; Surfing? + cp 2 ; Surfing? jr z, .cannotFish call ItemUseReloadOverworldData ld hl, ItemUseText00 @@ -2130,13 +2123,13 @@ ItemUsePPRestore: ; e1f7 (3:61f7) .usePPItem ld a, [wPPRestoreItem] - cp a, ELIXER + cp ELIXER jp nc, .useElixir ; if Elixir or Max Elixir ld a, $02 ld [wMoveMenuType], a ld hl, RaisePPWhichTechniqueText ld a, [wPPRestoreItem] - cp a, ETHER ; is it a PP Up? + cp ETHER ; is it a PP Up? jr c, .printWhichTechniqueMessage ; if so, print the raise PP message ld hl, RestorePPWhichTechniqueText ; otherwise, print the restore PP message .printWhichTechniqueMessage @@ -2157,13 +2150,13 @@ ItemUsePPRestore: ; e1f7 (3:61f7) call CopyStringToCF4B ; copy name to wcf4b pop hl ld a, [wPPRestoreItem] - cp a, ETHER + cp ETHER jr nc, .useEther ; if Ether or Max Ether .usePPUp ld bc, 21 add hl, bc ld a, [hl] ; move PP - cp a, 3 << 6 ; have 3 PP Ups already been used? + cp 3 << 6 ; have 3 PP Ups already been used? jr c, .PPNotMaxedOut ld hl, PPMaxedOutText call PrintText @@ -2171,7 +2164,7 @@ ItemUsePPRestore: ; e1f7 (3:61f7) .PPNotMaxedOut ld a, [hl] - add a, 1 << 6 ; increase PP Up count by 1 + add 1 << 6 ; increase PP Up count by 1 ld [hl], a ld a, 1 ; 1 PP Up used ld [wd11e], a @@ -2225,13 +2218,13 @@ ItemUsePPRestore: ; e1f7 (3:61f7) ld a, [wMaxPP] ld b, a ld a, [wPPRestoreItem] - cp a, MAX_ETHER + cp MAX_ETHER jr z, .fullyRestorePP ld a, [hl] ; move PP - and a, %00111111 ; lower 6 bit bits store current PP + and %00111111 ; lower 6 bit bits store current PP cp b ; does current PP equal max PP? ret z ; if so, return - add a, 10 ; increase current PP by 10 + add 10 ; increase current PP by 10 ; b holds the max PP amount and b will hold the new PP amount. ; So, if the new amount meets or exceeds the max amount, ; cap the amount to the max amount by leaving b unchanged. @@ -2241,7 +2234,7 @@ ItemUsePPRestore: ; e1f7 (3:61f7) ld b, a .storeNewAmount ld a, [hl] ; move PP - and a, %11000000 ; PP Up counter bits + and %11000000 ; PP Up counter bits add b ld [hl], a ret @@ -2328,10 +2321,10 @@ ItemUseTMHM: ; e374 (3:6374) and a jp nz, ItemUseNotTime ld a, [wcf91] - sub a, TM_01 + sub TM_01 push af jr nc, .skipAdding - add a, 55 ; if item is an HM, add 55 + add 55 ; if item is an HM, add 55 .skipAdding inc a ld [wd11e], a @@ -2428,9 +2421,9 @@ ItemUseTMHM: ; e374 (3:6374) callab IsThisPartymonStarterPikachu_Party jr nc, .notTeachingThunderboltOrThunderToPikachu ld a, [wcf91] - cp a, TM_24 ; are we teaching thunderbolt to the player pikachu? + cp TM_24 ; are we teaching thunderbolt to the player pikachu? jr z, .teachingThunderboltOrThunderToPlayerPikachu - cp a, TM_25 ; are we teaching thunder then? + cp TM_25 ; are we teaching thunder then? jr nz, .notTeachingThunderboltOrThunderToPikachu .teachingThunderboltOrThunderToPlayerPikachu ld a, $5 @@ -2599,7 +2592,7 @@ RestoreBonusPP: ; e54a (3:654a) .loop inc b ld a, b - cp a, 5 ; reached the end of the pokemon's moves? + cp 5 ; reached the end of the pokemon's moves? ret z ; if so, return ld a, [wUsingPPUp] dec a ; using a PP Up? @@ -2611,7 +2604,7 @@ RestoreBonusPP: ; e54a (3:654a) jr nz, .nextMove .skipMenuItemIDCheck ld a, [hl] - and a, %11000000 ; have any PP Ups been used? + and %11000000 ; have any PP Ups been used? call nz, AddBonusPP ; if so, add bonus PP .nextMove inc hl @@ -2638,13 +2631,13 @@ AddBonusPP: ; e586 (3:6586) ld a, [hl] ; move PP ld b, a swap a - and a, %1111 + and %1111 srl a srl a ld c, a ; c = number of PP Ups used .loop ld a, [H_QUOTIENT + 3] - cp a, 8 ; is the amount greater than or equal to 8? + cp 8 ; is the amount greater than or equal to 8? jr c, .addAmount ld a, 7 ; cap the amount at 7 .addAmount @@ -2712,13 +2705,13 @@ GetMaxPP: ; e5bb (3:65bb) push bc ld bc, wPartyMon1PP - wPartyMon1Moves ; PP offset if not player's in-battle pokemon data ld a, [wMonDataLocation] - cp a, 4 ; player's in-battle pokemon? + cp 4 ; player's in-battle pokemon? jr nz, .addPPOffset ld bc, wBattleMonPP - wBattleMonMoves ; PP offset if player's in-battle pokemon data .addPPOffset add hl, bc ld a, [hl] ; a = current PP - and a, %11000000 ; get PP Up count + and %11000000 ; get PP Up count pop bc or b ; place normal max PP in 6 lower bits of a ld h, d @@ -2729,7 +2722,7 @@ GetMaxPP: ; e5bb (3:65bb) ld [wUsingPPUp], a call AddBonusPP ; add bonus PP from PP Ups ld a, [hl] - and a, %00111111 ; mask out the PP Up count + and %00111111 ; mask out the PP Up count ld [wMaxPP], a ; store max PP ret @@ -2777,7 +2770,7 @@ TossItem_: ; e635 (3:6635) ld [wTextBoxID], a call DisplayTextBoxID ; yes/no menu ld a, [wMenuExitMethod] - cp a, CHOSE_SECOND_ITEM + cp CHOSE_SECOND_ITEM pop hl scf ret z ; return if the player chose No @@ -2826,7 +2819,7 @@ IsKeyItem_: ; e6a8 (3:66a8) ld a, $01 ld [wIsKeyItem], a ld a, [wcf91] - cp a, HM_01 ; is the item an HM or TM? + cp HM_01 ; is the item an HM or TM? jr nc, .checkIfItemIsHM ; if the item is not an HM or TM push af diff --git a/engine/menu/start_menu.asm b/engine/menu/start_menu.asm index 8a9ad229..3eeb1c07 100755 --- a/engine/menu/start_menu.asm +++ b/engine/menu/start_menu.asm @@ -1,7 +1,7 @@ DisplayStartMenu:: ; 29d1 (0:29d1) switchbank StartMenu_Pokedex ; also bank for other functions - ld a,[wWalkBikeSurfState] ; walking/biking/surfing - ld [wWalkBikeSurfStateCopy],a + ld a, [wWalkBikeSurfState] ; walking/biking/surfing + ld [wWalkBikeSurfStateCopy], a ld a, $8f ; (SFX_02_3f - SFX_Headers_02) / 3 ; Start menu sound call PlaySound @@ -12,76 +12,73 @@ RedisplayStartMenu_DoNotDrawStartMenu: ; 29e9 (0:29e9) call UpdateSprites .loop call HandleMenuInput - ld b,a + ld b, a .checkIfUpPressed - bit 6,a ; was Up pressed? - jr z,.checkIfDownPressed - ld a,[wCurrentMenuItem] ; menu selection + bit 6, a ; was Up pressed? + jr z, .checkIfDownPressed + ld a, [wCurrentMenuItem] ; menu selection and a - jr nz,.loop - ld a,[wLastMenuItem] + jr nz, .loop + ld a, [wLastMenuItem] and a - jr nz,.loop + jr nz, .loop ; if the player pressed tried to go past the top item, wrap around to the bottom - ld a,[wd74b] - bit 5,a ; does the player have the pokedex? - ld a,6 ; there are 7 menu items with the pokedex, so the max index is 6 - jr nz,.wrapMenuItemId + CheckEvent EVENT_GOT_POKEDEX ; does the player have the pokedex? + ld a, 6 ; there are 7 menu items with the pokedex, so the max index is 6 + jr nz, .wrapMenuItemId dec a ; there are only 6 menu items without the pokedex .wrapMenuItemId - ld [wCurrentMenuItem],a + ld [wCurrentMenuItem], a call EraseMenuCursor jr .loop .checkIfDownPressed - bit 7,a - jr z,.buttonPressed + bit 7, a + jr z, .buttonPressed ; if the player pressed tried to go past the bottom item, wrap around to the top - ld a,[wd74b] - bit 5,a ; does the player have the pokedex? - ld a,[wCurrentMenuItem] - ld c,7 ; there are 7 menu items with the pokedex - jr nz,.checkIfPastBottom + CheckEvent EVENT_GOT_POKEDEX ; does the player have the pokedex? + ld a, [wCurrentMenuItem] + ld c, 7 ; there are 7 menu items with the pokedex + jr nz, .checkIfPastBottom dec c ; there are only 6 menu items without the pokedex .checkIfPastBottom cp c - jr nz,.loop + jr nz, .loop ; the player went past the bottom, so wrap to the top xor a - ld [wCurrentMenuItem],a + ld [wCurrentMenuItem], a call EraseMenuCursor jr .loop .buttonPressed ; A, B, or Start button pressed call PlaceUnfilledArrowMenuCursor - ld a,[wCurrentMenuItem] - ld [wBattleAndStartSavedMenuItem],a ; save current menu selection - ld a,b - and a,%00001010 ; was the Start button or B button pressed? - jp nz,CloseStartMenu + ld a, [wCurrentMenuItem] + ld [wBattleAndStartSavedMenuItem], a ; save current menu selection + ld a, b + and a, %00001010 ; was the Start button or B button pressed? + jp nz, CloseStartMenu call SaveScreenTilesToBuffer2 ; copy background from wTileMap to wTileMapBackup2 - ld a,[wd74b] - bit 5,a ; does the player have the pokedex? - ld a,[wCurrentMenuItem] - jr nz,.displayMenuItem + CheckEvent EVENT_GOT_POKEDEX ; does the player have the pokedex? + ld a, [wCurrentMenuItem] + jr nz, .displayMenuItem inc a ; adjust position to account for missing pokedex menu item .displayMenuItem - cp a,0 - jp z,StartMenu_Pokedex - cp a,1 - jp z,StartMenu_Pokemon - cp a,2 - jp z,StartMenu_Item - cp a,3 - jp z,StartMenu_TrainerInfo - cp a,4 - jp z,StartMenu_SaveReset - cp a,5 - jp z,StartMenu_Option + cp a, 0 + jp z, StartMenu_Pokedex + cp a, 1 + jp z, StartMenu_Pokemon + cp a, 2 + jp z, StartMenu_Item + cp a, 3 + jp z, StartMenu_TrainerInfo + cp a, 4 + jp z, StartMenu_SaveReset + cp a, 5 + jp z, StartMenu_Option ; EXIT falls through to here CloseStartMenu:: ; 2a72 (0:2a72) call Joypad - ld a,[hJoyPressed] - bit 0,a ; was A button newly pressed? - jr nz,CloseStartMenu + ld a, [hJoyPressed] + bit 0, a ; was A button newly pressed? + jr nz, CloseStartMenu call LoadTextBoxTilePatterns jp CloseTextDisplay diff --git a/home.asm b/home.asm index 50469047..e4d71256 100644 --- a/home.asm +++ b/home.asm @@ -168,7 +168,7 @@ ReadJoypad:: ; 01c8 (0:01c8) INCLUDE "home/overworld.asm" CheckForUserInterruption:: ; 10ba (0:10ba) -; Return carry if Up+Select+B, Start or A are pressed in c frames. +; Return carry if Up + Select + B, Start or A are pressed in c frames. ; Used only in the intro and title screen. call DelayFrame @@ -780,7 +780,7 @@ UncompressMonSprite:: ; 1407 (0:1407) ld a, [hli] ld [W_SPRITEINPUTPTR], a ; fetch sprite input pointer ld a, [hl] - ld [W_SPRITEINPUTPTR+1], a + ld [W_SPRITEINPUTPTR + 1], a ; define (by index number) the bank that a pokemon's image is in ; index = Mew, bank 1 ; index = Kabutops fossil, bank $B @@ -1323,14 +1323,13 @@ DisplayPlayerBlackedOutText:: ; 2988 (0:2988) ld a, [wd732] res 5, a ; reset forced to use bike bit ld [wd732], a - ld a, [wd790] - bit 7, a + CheckEvent EVENT_IN_SAFARI_ZONE jr z, .didnotblackoutinsafari xor a ld [wNumSafariBalls], a ld [wSafariSteps], a - ld [wSafariSteps+1], a - ld [wd790], a + ld [wSafariSteps + 1], a + EventFlagAddressa EVENT_IN_SAFARI_ZONE ld [wcf0d], a ld [wSafariZoneEntranceCurScript], a .didnotblackoutinsafari @@ -2131,7 +2130,7 @@ SerialFunction:: ; 2fb7 (0:2fb7) ld a, [wPrinterOpcode] and a ret nz - ld hl, wOverworldMap+650 + ld hl, wOverworldMap + 650 inc [hl] ld a, [hl] cp $6 @@ -2351,7 +2350,7 @@ StoreTrainerHeaderPointer:: ; 30f3 (0:30f3) ld a, h ld [wTrainerHeaderPtr], a ld a, l - ld [wTrainerHeaderPtr+1], a + ld [wTrainerHeaderPtr + 1], a ret ; executes the current map script from the function pointer array provided in hl. @@ -3781,10 +3780,10 @@ CalcStats:: ; 392b (0:392b) .statsLoop inc c call CalcStat - ld a, [H_MULTIPLICAND+1] + ld a, [H_MULTIPLICAND + 1] ld [de], a inc de - ld a, [H_MULTIPLICAND+2] + ld a, [H_MULTIPLICAND + 2] ld [de], a inc de ld a, c @@ -3818,12 +3817,12 @@ CalcStat:: ; 393f (0:393f) .statExpLoop ; calculates ceil(Sqrt(stat exp)) in b xor a ld [H_MULTIPLICAND], a - ld [H_MULTIPLICAND+1], a + ld [H_MULTIPLICAND + 1], a inc b ; increment current stat exp bonus ld a, b cp $ff jr z, .statExpDone - ld [H_MULTIPLICAND+2], a + ld [H_MULTIPLICAND + 2], a ld [H_MULTIPLIER], a call Multiply ld a, [hld] @@ -3912,9 +3911,9 @@ CalcStat:: ; 393f (0:393f) jr nc, .noCarry2 inc d ; da = (Base + IV) * 2 + ceil(Sqrt(stat exp)) / 4 .noCarry2 - ld [H_MULTIPLICAND+2], a + ld [H_MULTIPLICAND + 2], a ld a, d - ld [H_MULTIPLICAND+1], a + ld [H_MULTIPLICAND + 1], a xor a ld [H_MULTIPLICAND], a ld a, [wCurEnemyLVL] @@ -3922,10 +3921,10 @@ CalcStat:: ; 393f (0:393f) call Multiply ; ((Base + IV) * 2 + ceil(Sqrt(stat exp)) / 4) * Level ld a, [H_MULTIPLICAND] ld [H_DIVIDEND], a - ld a, [H_MULTIPLICAND+1] - ld [H_DIVIDEND+1], a - ld a, [H_MULTIPLICAND+2] - ld [H_DIVIDEND+2], a + ld a, [H_MULTIPLICAND + 1] + ld [H_DIVIDEND + 1], a + ld a, [H_MULTIPLICAND + 2] + ld [H_DIVIDEND + 2], a ld a, $64 ld [H_DIVISOR], a ld a, $3 @@ -3937,38 +3936,38 @@ CalcStat:: ; 393f (0:393f) jr nz, .notHPStat ld a, [wCurEnemyLVL] ld b, a - ld a, [H_MULTIPLICAND+2] + ld a, [H_MULTIPLICAND + 2] add b - ld [H_MULTIPLICAND+2], a + ld [H_MULTIPLICAND + 2], a jr nc, .noCarry3 - ld a, [H_MULTIPLICAND+1] + ld a, [H_MULTIPLICAND + 1] inc a - ld [H_MULTIPLICAND+1], a ; HP: (((Base + IV) * 2 + ceil(Sqrt(stat exp)) / 4) * Level) / 100 + Level + ld [H_MULTIPLICAND + 1], a ; HP: (((Base + IV) * 2 + ceil(Sqrt(stat exp)) / 4) * Level) / 100 + Level .noCarry3 - ld a, 10 ; +10 for HP stat + ld a, 10 ; + 10 for HP stat .notHPStat ld b, a - ld a, [H_MULTIPLICAND+2] + ld a, [H_MULTIPLICAND + 2] add b - ld [H_MULTIPLICAND+2], a + ld [H_MULTIPLICAND + 2], a jr nc, .noCarry4 - ld a, [H_MULTIPLICAND+1] + ld a, [H_MULTIPLICAND + 1] inc a ; non-HP: (((Base + IV) * 2 + ceil(Sqrt(stat exp)) / 4) * Level) / 100 + 5 - ld [H_MULTIPLICAND+1], a ; HP: (((Base + IV) * 2 + ceil(Sqrt(stat exp)) / 4) * Level) / 100 + Level + 10 + ld [H_MULTIPLICAND + 1], a ; HP: (((Base + IV) * 2 + ceil(Sqrt(stat exp)) / 4) * Level) / 100 + Level + 10 .noCarry4 - ld a, [H_MULTIPLICAND+1] ; check for overflow (>999) + ld a, [H_MULTIPLICAND + 1] ; check for overflow (>999) cp 999 / $100 + 1 jr nc, .overflow cp 999 / $100 jr c, .noOverflow - ld a, [H_MULTIPLICAND+2] + ld a, [H_MULTIPLICAND + 2] cp 999 % $100 + 1 jr c, .noOverflow .overflow ld a, 999 / $100 ; overflow: cap at 999 - ld [H_MULTIPLICAND+1], a + ld [H_MULTIPLICAND + 1], a ld a, 999 % $100 - ld [H_MULTIPLICAND+2], a + ld [H_MULTIPLICAND + 2], a .noOverflow pop bc pop de diff --git a/home/overworld.asm b/home/overworld.asm index e1312df1..f29cfd51 100644 --- a/home/overworld.asm +++ b/home/overworld.asm @@ -255,8 +255,7 @@ OverworldLoopLessDelay:: ; 0245 (0:0245) jp nz, CheckMapConnections ; it seems like this check will never succeed (the other place where CheckMapConnections is run works) ; walking animation finished call StepCountCheck - ld a, [wd790] - bit 7, a ; in the safari zone? + CheckEvent EVENT_IN_SAFARI_ZONE ; in the safari zone? jr z, .notSafariZone callba SafariZoneCheckSteps ld a, [wSafariZoneGameOver] @@ -288,8 +287,7 @@ OverworldLoopLessDelay:: ; 0245 (0:0245) ld a, [wCurMap] cp CINNABAR_GYM jr nz, .notCinnabarGym - ld hl, wd79b - set 7, [hl] + SetEvent EVENT_2A7 .notCinnabarGym ld hl, wd72e set 5, [hl] diff --git a/scripts/billshouse.asm b/scripts/billshouse.asm index a3a86d74..b288a9fe 100755 --- a/scripts/billshouse.asm +++ b/scripts/billshouse.asm @@ -23,8 +23,7 @@ BillsHouseScript_1e09e: bit 7, [hl] set 7, [hl] ret nz - ld hl, wd7f2 - bit 5, [hl] + CheckEventHL EVENT_MET_BILL_2 jr z, .asm_1e0af jr .asm_1e0b3 diff --git a/scripts/oakslab.asm b/scripts/oakslab.asm index 71e900eb..6648acb1 100755 --- a/scripts/oakslab.asm +++ b/scripts/oakslab.asm @@ -129,8 +129,7 @@ OaksLabScript4: ; 1cbd2 (7:445f) ret OaksLabScript5: ; 1cbfd (7:4bfd) - ld hl, wd74b - set 1, [hl] + SetEvent EVENT_OAK_ASKED_TO_CHOOSE_MON ld a, $fc ld [wJoyIgnore], a ld a, $d @@ -392,8 +391,7 @@ OaksLabScript14: xor a ld [wSpriteStateData1 + 1 * $10 + 9], a predef HealParty - ld hl, wd74b - set 3, [hl] + SetEvent EVENT_BATTLED_RIVAL_IN_OAKS_LAB ld a, $f ld [W_OAKSLABCURSCRIPT], a ret diff --git a/scripts/rockethideout4.asm b/scripts/rockethideout4.asm index 30ed3f24..d0e6f567 100755 --- a/scripts/rockethideout4.asm +++ b/scripts/rockethideout4.asm @@ -266,8 +266,7 @@ RocketHideout4Script13: xor a ld [hJoyHeld], a ld [wJoyIgnore], a - ld hl, wd81b - set 2, [hl] + SetEvent EVENT_BEAT_ROCKET_HIDEOUT_4_TRAINER_0 ld a, $0 call RocketHideout4Script_4551e ret diff --git a/wram.asm b/wram.asm index 79a86bfc..008d0d0c 100755 --- a/wram.asm +++ b/wram.asm @@ -3403,143 +3403,17 @@ wSecondLockTrashCanIndex:: ; d744 ds 2 -wEventFlags:: -wd747:: ds 3 ; below here are mostly in game flags -wd74a:: ds 1 +wEventFlags:: ; d747 +; below here are mostly in game flags -wd74b:: ; d74b +; d74b ; bit 0: Prof. Oak has lead the player to the north end of his lab ; bit 1: Prof. Oak has asked the player to choose a pokemon ; bit 2: the player and the rival have received their pokemon ; bit 3: the player has battled the rival in Oak's lab ; bit 4: Prof. Oak has given the player 5 pokeballs ; bit 5: received pokedex - ds 1 - -wd74c:: ds 2 -wd74e:: ds 3 -wd751:: ds 1 -wd752:: ds 2 -wd754:: ds 1 -wd755:: ds 5 -wd75a:: ds 1 -wd75b:: ds 3 -wd75e:: ds 1 -wd75f:: ds 5 -wd764:: ds 1 -wd765:: ds 1 -wd766:: ds 1 -wd767:: ds 1 -wd768:: ds 1 -wd769:: ds 3 -wd76c:: ds 5 -wd771:: ds 2 -wd773:: ds 4 -wd777:: ds 1 -wd778:: ds 4 -wd77c:: ds 1 -wd77d:: ds 1 -wd77e:: ds 5 -wd783:: ds 11 -wd78e:: ds 2 -wd790:: ds 2 -wd792:: ds 4 -wd796:: ds 2 -wd798:: ds 2 -wd79a:: ds 1 -wd79b:: ds 1 -wd79c:: ds 5 -wd7a1:: ds 2 -wd7a3:: ds 12 -wd7af:: ds 2 -wd7b1:: ds 2 -wd7b3:: ds 1 -wd7b4:: ds 5 -wd7b9:: ds 4 -wd7bd:: ds 2 -wd7bf:: ds 3 -wd7c2:: ds 1 -wd7c3:: ds 2 -wd7c5:: ds 1 -wd7c6:: ds 3 -wd7c9:: ds 4 -wd7cd:: ds 2 -wd7cf:: ds 2 -wd7d1:: ds 1 -wd7d2:: ds 1 -wd7d3:: ds 2 -wd7d5:: ds 1 -wd7d6:: ds 1 -wd7d7:: ds 1 -wd7d8:: ds 1 -wd7d9:: ds 2 -wd7db:: ds 2 -wd7dd:: ds 2 -wd7df:: ds 1 -wd7e0:: ds 1 -wd7e1:: ds 2 -wd7e3:: ds 2 -wd7e5:: ds 2 -wd7e7:: ds 1 -wd7e8:: ds 1 -wd7e9:: ds 2 -wd7eb:: ds 2 -wd7ed:: ds 1 -wd7ee:: ds 1 -wd7ef:: ds 1 -wd7f0:: ds 1 -wd7f1:: ds 1 -wd7f2:: ds 1 -wd7f3:: ds 2 -wd7f5:: ds 1 -wd7f6:: ds 9 -wd7ff:: ds 4 -wd803:: ds 2 -wd805:: ds 2 -wd807:: ds 2 -wd809:: ds 10 -wd813:: ds 2 -wd815:: ds 1 -wd816:: ds 1 -wd817:: ds 2 -wd819:: ds 2 -wd81b:: ds 10 -wd825:: ds 1 -wd826:: ds 1 -wd827:: ds 1 -wd828:: ds 1 -wd829:: ds 1 -wd82a:: ds 1 -wd82b:: ds 1 -wd82c:: ds 1 -wd82d:: ds 1 -wd82e:: ds 1 -wd82f:: ds 1 -wd830:: ds 1 -wd831:: ds 1 -wd832:: ds 1 -wd833:: ds 1 -wd834:: ds 1 -wd835:: ds 1 -wd836:: ds 1 -wd837:: ds 1 -wd838:: ds 15 -wd847:: ds 2 -wd849:: ds 2 -wd84b:: ds 12 -wd857:: ds 8 -wd85f:: ds 4 -wd863:: ds 1 -wd864:: ds 1 -wd865:: ds 1 -wd866:: ds 1 -wd867:: ds 2 -wd869:: ds 20 -wd87d:: ds 2 -wd87f:: ds 1 -wd880:: ds 1 -wd881:: ds 1 -wd882:: ds 5 + flag_array NUM_EVENT_FLAGS wLinkEnemyTrainerName:: ; d887 ; linked game's trainer name -- cgit v1.3.1-sl0p From 42a9f7e8fd9f2f56a271cd5378467bb6a0f5bd21 Mon Sep 17 00:00:00 2001 From: pikalaxalt Date: Wed, 8 Jun 2016 01:35:56 -0400 Subject: Fix WRAM address comments beyond the former site of wGBC --- wram.asm | 811 ++++++++++++++++++++++++++++++++------------------------------- 1 file changed, 406 insertions(+), 405 deletions(-) (limited to 'wram.asm') diff --git a/wram.asm b/wram.asm index 008d0d0c..f5a1188c 100755 --- a/wram.asm +++ b/wram.asm @@ -1636,26 +1636,26 @@ wScriptedNPCWalkCounter:: ; cf18 ds 1 -wOnSGB:: ; cf1b +wOnSGB:: ; cf1a ; if running on SGB, it's 1, else it's 0 ds 1 -wDefaultPaletteCommand:: ; cf1c +wDefaultPaletteCommand:: ; cf1b ds 1 -wPlayerHPBarColor:: ; cf1d +wPlayerHPBarColor:: ; cf1c -wWholeScreenPaletteMonSpecies:: ; cf1d +wWholeScreenPaletteMonSpecies:: ; cf1c ; species of the mon whose palette is used for the whole screen ds 1 -wEnemyHPBarColor:: ; cf1e +wEnemyHPBarColor:: ; cf1d ds 1 ; 0: green ; 1: yellow ; 2: red -wPartyMenuHPBarColors:: ; cf1f +wPartyMenuHPBarColors:: ; cf1e ds 6 wStatusScreenHPBarColor:: ; cf25 @@ -1676,76 +1676,76 @@ wPartyMenuBlkPacket:: ; cf2e wPartyHPBarAttributes:: ; cf36 ds 20 -wExpAmountGained:: ; cf4b +wExpAmountGained:: ; cf4a ; 2-byte big-endian number ; the total amount of exp a mon gained wcf4b:: ds 2 ; storage buffer for various strings -wGainBoostedExp:: ; cf4d +wGainBoostedExp:: ; cf4c ds 1 ds 17 -wGymCityName:: ; cf5f +wGymCityName:: ; cf5e ds 17 -wGymLeaderName:: ; cf70 +wGymLeaderName:: ; cf6f ds NAME_LENGTH -wItemList:: ; cf7b +wItemList:: ; cf7a ds 16 -wListPointer:: ; cf8b +wListPointer:: ; cf8a ds 2 -wUnusedCF8D:: ; cf8d +wUnusedCF8D:: ; cf8c ; 2 bytes ; used to store pointers, but never read ds 2 -wItemPrices:: ; cf8f +wItemPrices:: ; cf8e ds 2 -wcf91:: ds 1 ; used with a lot of things (too much to list here) +wcf91:: ds 1 ; used with a lot of things (too much to list here) ; cf90 -wWhichPokemon:: ; cf92 +wWhichPokemon:: ; cf91 ; which pokemon you selected ds 1 -wPrintItemPrices:: ; cf93 +wPrintItemPrices:: ; cf92 ; if non-zero, then print item prices when displaying lists ds 1 -wHPBarType:: ; cf94 +wHPBarType:: ; cf93 ; type of HP bar ; $00 = enemy HUD in battle ; $01 = player HUD in battle / status screen ; $02 = party menu -wListMenuID:: ; cf94 +wListMenuID:: ; cf93 ; ID used by DisplayListMenuID ds 1 -wRemoveMonFromBox:: ; cf95 +wRemoveMonFromBox:: ; cf94 ; if non-zero, RemovePokemon will remove the mon from the current box, ; else it will remove the mon from the party -wMoveMonType:: ; cf95 +wMoveMonType:: ; cf94 ; 0 = move from box to party ; 1 = move from party to box ; 2 = move from daycare to party ; 3 = move from party to daycare ds 1 -wItemQuantity:: ; cf96 +wItemQuantity:: ; cf95 ds 1 -wMaxItemQuantity:: ; cf97 +wMaxItemQuantity:: ; cf96 ds 1 ; LoadMonData copies mon data here -wLoadedMon:: party_struct wLoadedMon ; cf98 +wLoadedMon:: party_struct wLoadedMon ; cf97 wFontLoaded:: ; cfc3 ; bit 0: The space in VRAM that is used to store walk animation tile patterns @@ -1832,7 +1832,7 @@ wBattleMonSpecies2:: ; cfd8 wEnemyMonNick:: ds NAME_LENGTH ; cfd9 -wEnemyMon:: ; cfe5 +wEnemyMon:: ; cfe4 ; The wEnemyMon struct reaches past 0xcfff, ; the end of wram bank 0 on cgb. ; This has no significance on dmg, where wram @@ -1868,64 +1868,64 @@ wEnemyMonBaseStats:: ds 5 wEnemyMonCatchRate:: ds 1 wEnemyMonBaseExp:: ds 1 -wBattleMonNick:: ds NAME_LENGTH ; d009 -wBattleMon:: battle_struct wBattleMon ; d014 +wBattleMonNick:: ds NAME_LENGTH ; d008 +wBattleMon:: battle_struct wBattleMon ; d013 -wTrainerClass:: ; d031 +wTrainerClass:: ; d030 ds 1 ds 1 -wTrainerPicPointer:: ; d033 +wTrainerPicPointer:: ; d032 ds 2 ds 1 -wTempMoveNameBuffer:: ; d036 +wTempMoveNameBuffer:: ; d035 -wLearnMoveMonName:: ; d036 +wLearnMoveMonName:: ; d035 ; The name of the mon that is learning a move. ds 16 -wTrainerBaseMoney:: ; d046 +wTrainerBaseMoney:: ; d045 ; 2-byte BCD number ; money received after battle = base money × level of highest-level enemy mon ds 2 -wMissableObjectCounter:: ; d048 +wMissableObjectCounter:: ; d047 ds 1 ds 1 -wTrainerName:: ; d04a +wTrainerName:: ; d049 ; 13 bytes for the letters of the opposing trainer ; the name is terminated with $50 with possible ; unused trailing letters ds 13 -wIsInBattle:: ; d057 +wIsInBattle:: ; d056 ; lost battle, this is -1 ; no battle, this is 0 ; wild battle, this is 1 ; trainer battle, this is 2 ds 1 -wPartyGainExpFlags:: ; d058 +wPartyGainExpFlags:: ; d057 ; flags that indicate which party members should be be given exp when GainExperience is called flag_array 6 -wCurOpponent:: ; d059 +wCurOpponent:: ; d058 ; in a wild battle, this is the species of pokemon ; in a trainer battle, this is the trainer class + 200 ds 1 -wBattleType:: ; d05a +wBattleType:: ; d059 ; in normal battle, this is 0 ; in old man battle, this is 1 ; in safari battle, this is 2 ds 1 -wDamageMultipliers:: ; d05b +wDamageMultipliers:: ; d05a ; bits 0-6: Effectiveness ; $0 = immune ; $5 = not very effective @@ -1934,34 +1934,34 @@ wDamageMultipliers:: ; d05b ; bit 7: STAB ds 1 -wLoneAttackNo:: ; d05c +wLoneAttackNo:: ; d05b ; which entry in LoneAttacks to use -wGymLeaderNo:: ; d05c +wGymLeaderNo:: ; d05b ; it's actually the same thing as ^ ds 1 -wTrainerNo:: ; d05d +wTrainerNo:: ; d05c ; which instance of [youngster, lass, etc] is this? ds 1 -wCriticalHitOrOHKO:: ; d05e +wCriticalHitOrOHKO:: ; d05d ; $00 = normal attack ; $01 = critical hit ; $02 = successful OHKO ; $ff = failed OHKO ds 1 -wMoveMissed:: ; d05f +wMoveMissed:: ; d05e ds 1 -wPlayerStatsToDouble:: ; d060 +wPlayerStatsToDouble:: ; d05f ; always 0 ds 1 -wPlayerStatsToHalve:: ; d061 +wPlayerStatsToHalve:: ; d060 ; always 0 ds 1 -wPlayerBattleStatus1:: ; d062 +wPlayerBattleStatus1:: ; d061 ; bit 0 - bide ; bit 1 - thrash / petal dance ; bit 2 - attacking multiple times (e.g. double kick) @@ -1972,7 +1972,7 @@ wPlayerBattleStatus1:: ; d062 ; bit 7 - confusion ds 1 -wPlayerBattleStatus2:: ; d063 +wPlayerBattleStatus2:: ; d062 ; bit 0 - X Accuracy effect ; bit 1 - protected by "mist" ; bit 2 - focus energy effect @@ -1982,99 +1982,99 @@ wPlayerBattleStatus2:: ; d063 ; bit 7 - leech seeded ds 1 -wPlayerBattleStatus3:: ; d064 +wPlayerBattleStatus3:: ; d063 ; bit 0 - toxic ; bit 1 - light screen ; bit 2 - reflect ; bit 3 - tranformed ds 1 -wEnemyStatsToDouble:: ; d065 +wEnemyStatsToDouble:: ; d064 ; always 0 ds 1 -wEnemyStatsToHalve:: ; d066 +wEnemyStatsToHalve:: ; d065 ; always 0 ds 1 -wEnemyBattleStatus1:: ; d067 +wEnemyBattleStatus1:: ; d066 ds 1 -wEnemyBattleStatus2:: ; d068 +wEnemyBattleStatus2:: ; d067 ds 1 -wEnemyBattleStatus3:: ; d069 +wEnemyBattleStatus3:: ; d068 ds 1 -wPlayerNumAttacksLeft:: +wPlayerNumAttacksLeft:: ; d069 ; when the player is attacking multiple times, the number of attacks left ds 1 -W_PLAYERCONFUSEDCOUNTER:: ; d06b +W_PLAYERCONFUSEDCOUNTER:: ; d06a ds 1 -wPlayerToxicCounter:: ; d06c +wPlayerToxicCounter:: ; d06b ds 1 -wPlayerDisabledMove:: ; d06d +wPlayerDisabledMove:: ; d06c ; high nibble: which move is disabled (1-4) ; low nibble: disable turns left ds 1 ds 1 -wEnemyNumAttacksLeft:: ; d06f +wEnemyNumAttacksLeft:: ; d06e ; when the enemy is attacking multiple times, the number of attacks left ds 1 -W_ENEMYCONFUSEDCOUNTER:: ; d070 +W_ENEMYCONFUSEDCOUNTER:: ; d06f ds 1 -wEnemyToxicCounter:: ; d071 +wEnemyToxicCounter:: ; d070 ds 1 -wEnemyDisabledMove:: ; d072 +wEnemyDisabledMove:: ; d071 ; high nibble: which move is disabled (1-4) ; low nibble: disable turns left ds 1 ds 1 -wPlayerNumHits:: ; d074 +wPlayerNumHits:: ; d073 ; number of hits by player in attacks like Double Slap, etc. -wPlayerBideAccumulatedDamage:: ; d074 +wPlayerBideAccumulatedDamage:: ; d073 ; the amount of damage accumulated by the player while biding (2 bytes) -wUnknownSerialCounter2:: ; d075 +wUnknownSerialCounter2:: ; d073 ; 2 bytes ds 4 -wEscapedFromBattle:: +wEscapedFromBattle:: ; d077 ; non-zero when an item or move that allows escape from battle was used ds 1 -wAmountMoneyWon:: ; d079 +wAmountMoneyWon:: ; d078 ; 3-byte BCD number -wObjectToHide:: ; d079 +wObjectToHide:: ; d078 ds 1 -wObjectToShow:: ; d07a +wObjectToShow:: ; d079 ds 1 ds 1 -wAnimationID:: ; d07c +wAnimationID:: ; d07b ; ID number of the current battle animation ds 1 -wNamingScreenType:: ; d07d +wNamingScreenType:: ; d07c -wPartyMenuTypeOrMessageID:: ; d07d +wPartyMenuTypeOrMessageID:: ; d07c -wTempTilesetNumTiles:: ; d07d +wTempTilesetNumTiles:: ; d07c ; temporary storage for the number of tiles in a tileset ds 1 -wSavedListScrollOffset:: ; d07e +wSavedListScrollOffset:: ; d07d ; used by the pokemart code to save the existing value of wListScrollOffset ; so that it can be restored when the player is done with the pokemart NPC ds 1 @@ -2082,71 +2082,71 @@ wSavedListScrollOffset:: ; d07e ds 2 ; base coordinates of frame block -wBaseCoordX:: ; d081 +wBaseCoordX:: ; d080 ds 1 -wBaseCoordY:: ; d082 +wBaseCoordY:: ; d081 ds 1 ; low health alarm counter/enable ; high bit = enable, others = timer to cycle frequencies -wLowHealthAlarm:: ds 1 ; d083 +wLowHealthAlarm:: ds 1 ; d082 -wFBTileCounter:: ; d084 +wFBTileCounter:: ; d083 ; counts how many tiles of the current frame block have been drawn ds 1 -wMovingBGTilesCounter2:: ; d085 +wMovingBGTilesCounter2:: ; d084 ds 1 -wSubAnimFrameDelay:: ; d086 +wSubAnimFrameDelay:: ; d085 ; duration of each frame of the current subanimation in terms of screen refreshes ds 1 -wSubAnimCounter:: ; d087 +wSubAnimCounter:: ; d086 ; counts the number of subentries left in the current subanimation ds 1 -wSaveFileStatus:: ; d088 +wSaveFileStatus:: ; d087 ; 1 = no save file or save file is corrupted ; 2 = save file exists and no corruption has been detected ds 1 -wNumFBTiles:: ; d089 +wNumFBTiles:: ; d088 ; number of tiles in current battle animation frame block ds 1 -wFlashScreenLongCounter:: ; d08a +wFlashScreenLongCounter:: ; d089 -wSpiralBallsBaseY:: ; d08a +wSpiralBallsBaseY:: ; d089 -wFallingObjectMovementByte:: ; d08a +wFallingObjectMovementByte:: ; d089 ; bits 0-6: index into FallingObjects_DeltaXs array (0 - 8) ; bit 7: direction; 0 = right, 1 = left -wNumShootingBalls:: ; d08a +wNumShootingBalls:: ; d089 -wTradedMonMovingRight:: ; d08a +wTradedMonMovingRight:: ; d089 ; $01 if mon is moving from left gameboy to right gameboy; $00 if vice versa -wOptionsInitialized:: ; d08a +wOptionsInitialized:: ; d089 -wNewSlotMachineBallTile:: ; d08a +wNewSlotMachineBallTile:: ; d089 -wCoordAdjustmentAmount:: ; d08a +wCoordAdjustmentAmount:: ; d089 ; how much to add to the X/Y coord -wUnusedD08A:: ; d08a +wUnusedD08A:: ; d089 ds 1 -wSpiralBallsBaseX:: ; d08b +wSpiralBallsBaseX:: ; d08a -wNumFallingObjects:: ; d08b +wNumFallingObjects:: ; d08a -wSlideMonDelay:: ; d08b +wSlideMonDelay:: ; d08a -wAnimCounter:: ; d08b +wAnimCounter:: ; d08a ; generic counter variable for various animations -wSubAnimTransform:: ; d08b +wSubAnimTransform:: ; d08a ; controls what transformations are applied to the subanimation ; 01: flip horizontally and vertically ; 02: flip horizontally and translate downwards 40 pixels @@ -2154,52 +2154,52 @@ wSubAnimTransform:: ; d08b ; 04: reverse the subanimation ds 1 -wEndBattleWinTextPointer:: ; d08c +wEndBattleWinTextPointer:: ; d08b ds 2 -wEndBattleLoseTextPointer:: ; d08e +wEndBattleLoseTextPointer:: ; d08d ds 2 ds 2 -wEndBattleTextRomBank:: ; d092 +wEndBattleTextRomBank:: ; d091 ds 1 ds 1 -wSubAnimAddrPtr:: ; d094 +wSubAnimAddrPtr:: ; d093 ; the address _of the address_ of the current subanimation entry ds 2 -wSlotMachineAllowMatchesCounter:: ; d096 +wSlotMachineAllowMatchesCounter:: ; d095 ; If non-zero, the allow matches flag is always set. ; There is a 1/256 (~0.4%) chance that this value will be set to 60, which is ; the only way it can increase. Winning certain payout amounts will decrement it ; or zero it. -wSubAnimSubEntryAddr:: ; d096 +wSubAnimSubEntryAddr:: ; d095 ; the address of the current subentry of the current subanimation ds 2 ds 2 -wOutwardSpiralTileMapPointer:: ; d09a +wOutwardSpiralTileMapPointer:: ; d099 ds 1 -wPartyMenuAnimMonEnabled:: ; d09b +wPartyMenuAnimMonEnabled:: ; d09a -wTownMapSpriteBlinkingEnabled:: ; d09b +wTownMapSpriteBlinkingEnabled:: ; d09a ; non-zero when enabled. causes nest locations to blink on and off. ; the town selection cursor will blink regardless of what this value is -wUnusedD09B:: ; d09b +wUnusedD09B:: ; d09a ds 1 -wFBDestAddr:: ; d09c +wFBDestAddr:: ; d09b ; current destination address in OAM for frame blocks (big endian) ds 2 -wFBMode:: ; d09e +wFBMode:: ; d09d ; controls how the frame blocks are put together to form frames ; specifically, after finishing drawing the frame block, the frame block's mode determines what happens ; 00: clean OAM buffer and delay @@ -2208,172 +2208,172 @@ wFBMode:: ; d09e ; 04: delay, without cleaning OAM buffer, and do not advance [wFBDestAddr], so that the next frame block will overwrite this one ds 1 -wLinkCableAnimBulgeToggle:: ; d09f +wLinkCableAnimBulgeToggle:: ; d09e ; 0 = small ; 1 = big -wIntroNidorinoBaseTile:: ; d09f +wIntroNidorinoBaseTile:: ; d09e -wOutwardSpiralCurrentDirection:: ; d09f +wOutwardSpiralCurrentDirection:: ; d09e -wDropletTile:: ; d09f +wDropletTile:: ; d09e -wNewTileBlockID:: ; d09f +wNewTileBlockID:: ; d09e -wWhichBattleAnimTileset:: ; d09f +wWhichBattleAnimTileset:: ; d09e -wSquishMonCurrentDirection:: ; d09f +wSquishMonCurrentDirection:: ; d09e ; 0 = left ; 1 = right -wSlideMonUpBottomRowLeftTile:: ; d09f +wSlideMonUpBottomRowLeftTile:: ; d09e ; the tile ID of the leftmost tile in the bottom row in AnimationSlideMonUp_ ds 1 -wDisableVBlankWYUpdate:: ds 1 ; if non-zero, don't update WY during V-blank +wDisableVBlankWYUpdate:: ds 1 ; if non-zero, don't update WY during V-blank ; d09f -W_SPRITECURPOSX:: ; d0a1 +W_SPRITECURPOSX:: ; d0a0 ds 1 -W_SPRITECURPOSY:: ; d0a2 +W_SPRITECURPOSY:: ; d0a1 ds 1 -W_SPRITEWITDH:: ; d0a3 +W_SPRITEWITDH:: ; d0a2 ds 1 -W_SPRITEHEIGHT:: ; d0a4 +W_SPRITEHEIGHT:: ; d0a3 ds 1 -W_SPRITEINPUTCURBYTE:: ; d0a5 +W_SPRITEINPUTCURBYTE:: ; d0a4 ; current input byte ds 1 -W_SPRITEINPUTBITCOUNTER:: ; d0a6 +W_SPRITEINPUTBITCOUNTER:: ; d0a5 ; bit offset of last read input bit ds 1 -W_SPRITEOUTPUTBITOFFSET:: ; d0a7; determines where in the output byte the two bits are placed. Each byte contains four columns (2bpp data) +W_SPRITEOUTPUTBITOFFSET:: ; d0a6; determines where in the output byte the two bits are placed. Each byte contains four columns (2bpp data) ; 3 -> XX000000 1st column ; 2 -> 00XX0000 2nd column ; 1 -> 0000XX00 3rd column ; 0 -> 000000XX 4th column ds 1 -W_SPRITELOADFLAGS:: ; d0a8 +W_SPRITELOADFLAGS:: ; d0a7 ; bit 0 determines used buffer (0 -> $a188, 1 -> $a310) ; bit 1 loading last sprite chunk? (there are at most 2 chunks per load operation) ds 1 -W_SPRITEUNPACKMODE:: ; d0a9 +W_SPRITEUNPACKMODE:: ; d0a8 ds 1 -wSpriteFlipped:: ; d0aa +wSpriteFlipped:: ; d0a9 ds 1 -W_SPRITEINPUTPTR:: ; d0ab +W_SPRITEINPUTPTR:: ; d0aa ; pointer to next input byte ds 2 -W_SPRITEOUTPUTPTR:: ; d0ad +W_SPRITEOUTPUTPTR:: ; d0ac ; pointer to current output byte ds 2 -W_SPRITEOUTPUTPTRCACHED:: ; d0af +W_SPRITEOUTPUTPTRCACHED:: ; d0ae ; used to revert pointer for different bit offsets ds 2 -W_SPRITEDECODETABLE0PTR:: ; d0b1 +W_SPRITEDECODETABLE0PTR:: ; d0b0 ; pointer to differential decoding table (assuming initial value 0) ds 2 -W_SPRITEDECODETABLE1PTR:: ; d0b3 +W_SPRITEDECODETABLE1PTR:: ; d0b2 ; pointer to differential decoding table (assuming initial value 1) ds 2 -wd0b5:: ds 1 ; used as a temp storage area for Pokemon Species, and other Pokemon/Battle related things +wd0b5:: ds 1 ; used as a temp storage area for Pokemon Species, and other Pokemon/Battle related things ; d0b4 -wNameListType:: ; d0b6 +wNameListType:: ; d0b5 ds 1 -wPredefBank:: ; d0b7 +wPredefBank:: ; d0b6 ds 1 -wMonHeader:: ; d0b8 +wMonHeader:: ; d0b7 -wMonHIndex:: ; d0b8 +wMonHIndex:: ; d0b7 ; In the ROM base stats data stucture, this is the dex number, but it is ; overwritten with the internal index number after the header is copied to WRAM. ds 1 -wMonHBaseStats:: ; d0b9 -W_MONHBASEHP:: ; d0b9 +wMonHBaseStats:: ; d0b8 +W_MONHBASEHP:: ; d0b8 ds 1 -wMonHBaseAttack:: ; d0ba +wMonHBaseAttack:: ; d0b9 ds 1 -wMonHBaseDefense:: ; d0bb +wMonHBaseDefense:: ; d0ba ds 1 -wMonHBaseSpeed:: ; d0bc +wMonHBaseSpeed:: ; d0bb ds 1 -wMonHBaseSpecial:: ; d0bd +wMonHBaseSpecial:: ; d0bc ds 1 -wMonHTypes:: ; d0be -wMonHType1:: ; d0be +wMonHTypes:: ; d0bd +wMonHType1:: ; d0bd ds 1 -wMonHType2:: ; d0bf +wMonHType2:: ; d0be ds 1 -wMonHCatchRate:: ; d0c0 +wMonHCatchRate:: ; d0bf ds 1 -wMonHBaseEXP:: ; d0c1 +wMonHBaseEXP:: ; d0c0 ds 1 -wMonHSpriteDim:: ; d0c2 +wMonHSpriteDim:: ; d0c1 ds 1 -wMonHFrontSprite:: ; d0c3 +wMonHFrontSprite:: ; d0c2 ds 2 -wMonHBackSprite:: ; d0c5 +wMonHBackSprite:: ; d0c4 ds 2 -wMonHMoves:: ; d0c7 +wMonHMoves:: ; d0c6 ds 4 -wMonHGrowthRate:: ; d0cb +wMonHGrowthRate:: ; d0ca ds 1 -wMonHLearnset:: ; d0cc +wMonHLearnset:: ; d0cb ; bit field flag_array 50 + 5 ds 1 -wSavedTilesetType:: ; d0d4 +wSavedTilesetType:: ; d0d3 ; saved at the start of a battle and then written back at the end of the battle ds 1 ds 2 -wDamage:: ; d0d7 +wDamage:: ; d0d6 ds 2 ds 2 -wRepelRemainingSteps:: ; d0db +wRepelRemainingSteps:: ; d0da ds 1 -wMoves:: ; d0dc +wMoves:: ; d0db ; list of moves for FormatMovesString ds 4 -wMoveNum:: ; d0e0 +wMoveNum:: ; d0df ds 1 -wMovesString:: ; d0e1 +wMovesString:: ; d0e0 ds 56 -wUnusedD119:: ; d119 +wUnusedD119:: ; d118 ds 1 -wWalkBikeSurfStateCopy:: ; d11a +wWalkBikeSurfStateCopy:: ; d119 ; wWalkBikeSurfState is sometimes copied here, but it doesn't seem to be used for anything ds 1 -wInitListType:: ; d11b +wInitListType:: ; d11a ; the type of list for InitList to init ds 1 -wCapturedMonSpecies:: ; d11c +wCapturedMonSpecies:: ; d11b ; 0 if no mon was captured ds 1 -wFirstMonsNotOutYet:: ; d11d +wFirstMonsNotOutYet:: ; d11c ; Non-zero when the first player mon and enemy mon haven't been sent out yet. ; It prevents the game from asking if the player wants to choose another mon ; when the enemy sends out their first mon and suppresses the "no will to fight" @@ -2383,74 +2383,74 @@ wFirstMonsNotOutYet:: ; d11d ; lower nybble: number of shakes ; upper nybble: number of animations to play -wPokeBallAnimData:: ; d11e +wPokeBallAnimData:: ; d11d -wUsingPPUp:: ; d11e +wUsingPPUp:: ; d11d -wMaxPP:: ; d11e +wMaxPP:: ; d11d ; 0 for player, non-zero for enemy -wCalculateWhoseStats:: ; d11e +wCalculateWhoseStats:: ; d11d -wTypeEffectiveness:: ; d11e +wTypeEffectiveness:: ; d11d -wMoveType:: ; d11e +wMoveType:: ; d11d -wNumSetBits:: ; d11e +wNumSetBits:: ; d11d wd11e:: ds 1 ; used as a Pokemon and Item storage value. Also used as an output value for CountSetBits -wForcePlayerToChooseMon:: ; d11f +wForcePlayerToChooseMon:: ; d11e ; When this value is non-zero, the player isn't allowed to exit the party menu ; by pressing B and not choosing a mon. ds 1 -wNumRunAttempts:: +wNumRunAttempts:: ; d11f ; number of times the player has tried to run from battle ds 1 -wEvolutionOccurred:: ; d121 +wEvolutionOccurred:: ; d120 ds 1 -wVBlankSavedROMBank:: ; d122 +wVBlankSavedROMBank:: ; d121 ds 1 -wFarCopyDataSavedROMBank:: ; d123 +wFarCopyDataSavedROMBank:: ; d122 ds 1 -wIsKeyItem:: ; d124 +wIsKeyItem:: ; d123 ds 1 -wTextBoxID:: ; d125 +wTextBoxID:: ; d124 ds 1 -wd126:: ds 1 ; not exactly sure what this is used for, but it seems to be used as a multipurpose temp flag value +wd126:: ds 1 ; not exactly sure what this is used for, but it seems to be used as a multipurpose temp flag value ; d125 -wCurEnemyLVL:: ; d127 +wCurEnemyLVL:: ; d126 ds 1 -wItemListPointer:: ; d128 +wItemListPointer:: ; d127 ; pointer to list of items terminated by $FF ds 2 -wListCount:: +wListCount:: ; d129 ; number of entries in a list ds 1 -wLinkState:: ; d12b +wLinkState:: ; d12a ds 1 -wTwoOptionMenuID:: ; d12c +wTwoOptionMenuID:: ; d12b ds 1 -wChosenMenuItem:: ; d12d +wChosenMenuItem:: ; d12c ; the id of the menu item the player ultimately chose -wOutOfBattleBlackout:: ; d12d +wOutOfBattleBlackout:: ; d12c ; non-zero when the whole party has fainted due to out-of-battle poison damage ds 1 -wMenuExitMethod:: ; d12e +wMenuExitMethod:: ; d12d ; the way the user exited a menu ; for list menus and the buy/sell/quit menu: ; $01 = the user pressed A to choose a menu item @@ -2460,118 +2460,118 @@ wMenuExitMethod:: ; d12e ; $02 = the user pressed B or pressed A with the second menu item selected ds 1 -wDungeonWarpDataEntrySize:: ; d12f +wDungeonWarpDataEntrySize:: ; d12e ; the size is always 6, so they didn't need a variable in RAM for this -wWhichPewterGuy:: ; d12f +wWhichPewterGuy:: ; d12e ; 0 = museum guy ; 1 = gym guy -wWhichPrizeWindow:: ; d12f +wWhichPrizeWindow:: ; d12e ; there are 3 windows, from 0 to 2 -wGymGateTileBlock:: ; d12f +wGymGateTileBlock:: ; d12e ; a horizontal or vertical gate block ds 1 -wSavedSpriteScreenY:: ; d130 +wSavedSpriteScreenY:: ; d12f ds 1 -wSavedSpriteScreenX:: ; d131 +wSavedSpriteScreenX:: ; d130 ds 1 -wSavedSpriteMapY:: ; d132 +wSavedSpriteMapY:: ; d131 ds 1 -wSavedSpriteMapX:: ; d133 +wSavedSpriteMapX:: ; d132 ds 1 ds 5 -wWhichPrize:: ; d139 +wWhichPrize:: ; d138 ds 1 -wIgnoreInputCounter:: ; d13a +wIgnoreInputCounter:: ; d139 ; counts downward each frame ; when it hits 0, bit 5 (ignore input bit) of wd730 is reset ds 1 -wStepCounter:: ; d13b +wStepCounter:: ; d13a ; counts down once every step ds 1 -wNumberOfNoRandomBattleStepsLeft:: ; d13c +wNumberOfNoRandomBattleStepsLeft:: ; d13b ; after a battle, you have at least 3 steps before a random battle can occur ds 1 -wPrize1:: ; d13d +wPrize1:: ; d13c ds 1 -wPrize2:: ; d13e +wPrize2:: ; d13d ds 1 -wPrize3:: ; d13f +wPrize3:: ; d13e ds 1 ds 1 -wSerialRandomNumberListBlock:: ; d141 +wSerialRandomNumberListBlock:: ; d140 ; the first 7 bytes are the preamble -wPrize1Price:: ; d141 +wPrize1Price:: ; d140 ds 2 -wPrize2Price:: ; d143 +wPrize2Price:: ; d142 ds 2 -wPrize3Price:: ; d145 +wPrize3Price:: ; d144 ds 2 ds 1 -wLinkBattleRandomNumberList:: ; d148 +wLinkBattleRandomNumberList:: ; d147 ; shared list of 9 random numbers, indexed by wLinkBattleRandomNumberListIndex ds 10 -wSerialPlayerDataBlock:: ; d152 +wSerialPlayerDataBlock:: ; d151 ; the first 6 bytes are the preamble -wPseudoItemID:: ; d152 +wPseudoItemID:: ; d151 ; When a real item is being used, this is 0. ; When a move is acting as an item, this is the ID of the item it's acting as. ; For example, out-of-battle Dig is executed using a fake Escape Rope item. In ; that case, this would be ESCAPE_ROPE. ds 1 -wUnusedD153:: ; d153 +wUnusedD153:: ; d152 ds 1 ds 2 -wEvoStoneItemID:: ; d156 +wEvoStoneItemID:: ; d155 ds 1 -wSavedNPCMovementDirections2Index:: ; d157 +wSavedNPCMovementDirections2Index:: ; d156 ds 1 -wPlayerName:: ; d158 +wPlayerName:: ; d157 ds NAME_LENGTH wPartyDataStart:: -wPartyCount:: ds 1 ; d163 -wPartySpecies:: ds PARTY_LENGTH ; d164 -wPartyEnd:: ds 1 ; d16a +wPartyCount:: ds 1 ; d162 +wPartySpecies:: ds PARTY_LENGTH ; d163 +wPartyEnd:: ds 1 ; d169 wPartyMons:: -wPartyMon1:: party_struct wPartyMon1 ; d16b -wPartyMon2:: party_struct wPartyMon2 ; d197 -wPartyMon3:: party_struct wPartyMon3 ; d1c3 -wPartyMon4:: party_struct wPartyMon4 ; d1ef -wPartyMon5:: party_struct wPartyMon5 ; d21b -wPartyMon6:: party_struct wPartyMon6 ; d247 +wPartyMon1:: party_struct wPartyMon1 ; d16a +wPartyMon2:: party_struct wPartyMon2 ; d196 +wPartyMon3:: party_struct wPartyMon3 ; d1c2 +wPartyMon4:: party_struct wPartyMon4 ; d1ee +wPartyMon5:: party_struct wPartyMon5 ; d21a +wPartyMon6:: party_struct wPartyMon6 ; d246 -wPartyMonOT:: ds NAME_LENGTH * PARTY_LENGTH ; d273 -wPartyMonNicks:: ds NAME_LENGTH * PARTY_LENGTH ; d2b5 +wPartyMonOT:: ds NAME_LENGTH * PARTY_LENGTH ; d272 +wPartyMonNicks:: ds NAME_LENGTH * PARTY_LENGTH ; d2b4 wPartyMonNicksEnd:: wPartyDataEnd:: @@ -2579,29 +2579,29 @@ wPartyDataEnd:: wMainDataStart:: -wPokedexOwned:: ; d2f6 +wPokedexOwned:: ; d2f5 flag_array NUM_POKEMON wPokedexOwnedEnd:: -wPokedexSeen:: ; d30a +wPokedexSeen:: ; d309 flag_array NUM_POKEMON wPokedexSeenEnd:: -wNumBagItems:: ; d31d +wNumBagItems:: ; d31c ds 1 -wBagItems:: ; d31e +wBagItems:: ; d31d ; item, quantity ds 20 * 2 ds 1 ; end -wPlayerMoney:: ; d347 +wPlayerMoney:: ; d346 ds 3 ; BCD -wRivalName:: ; d34a +wRivalName:: ; d349 ds NAME_LENGTH -wOptions:: ; d355 +wOptions:: ; d354 ; bit 7 = battle animation ; 0: On ; 1: Off @@ -2614,205 +2614,205 @@ wOptions:: ; d355 ; 5: Slow ds 1 -wObtainedBadges:: ; d356 +wObtainedBadges:: ; d355 ds 1 ds 1 -wLetterPrintingDelayFlags:: ; d358 +wLetterPrintingDelayFlags:: ; d357 ; bit 0: If 0, limit the delay to 1 frame. Note that this has no effect if ; the delay has been disabled entirely through bit 1 of this variable ; or bit 6 of wd730. ; bit 1: If 0, no delay. ds 1 -wPlayerID:: ; d359 +wPlayerID:: ; d358 ds 2 -wMapMusicSoundID:: ; d35b +wMapMusicSoundID:: ; d35a ds 1 -wMapMusicROMBank:: ; d35c +wMapMusicROMBank:: ; d35b ds 1 -wMapPalOffset:: ; d35d +wMapPalOffset:: ; d35c ; offset subtracted from FadePal4 to get the background and object palettes for the current map ; normally, it is 0. it is 6 when Flash is needed, causing FadePal2 to be used instead of FadePal4 ds 1 -wCurMap:: ; d35e +wCurMap:: ; d35d ds 1 -wCurrentTileBlockMapViewPointer:: ; d35f +wCurrentTileBlockMapViewPointer:: ; d35e ; pointer to the upper left corner of the current view in the tile block map ds 2 -wYCoord:: ; d361 +wYCoord:: ; d360 ; player’s position on the current map ds 1 -wXCoord:: ; d362 +wXCoord:: ; d361 ds 1 -wYBlockCoord:: ; d363 +wYBlockCoord:: ; d362 ; player's y position (by block) ds 1 -wXBlockCoord:: ; d364 +wXBlockCoord:: ; d363 ds 1 -wLastMap:: ; d365 +wLastMap:: ; d364 ds 1 -wUnusedD366:: ; d366 +wUnusedD366:: ; d365 ds 1 -wCurMapTileset:: ; d367 +wCurMapTileset:: ; d366 ds 1 -wCurMapHeight:: ; d368 +wCurMapHeight:: ; d367 ; blocks ds 1 -wCurMapWidth:: ; d369 +wCurMapWidth:: ; d368 ; blocks ds 1 -W_MAPDATAPTR:: ; d36a +W_MAPDATAPTR:: ; d369 ds 2 -wMapTextPtr:: ; d36c +wMapTextPtr:: ; d36b ds 2 -W_MAPSCRIPTPTR:: ; d36e +W_MAPSCRIPTPTR:: ; d36d ds 2 -W_MAPCONNECTIONS:: ; d370 +W_MAPCONNECTIONS:: ; d36f ; connection byte ds 1 -W_MAPCONN1PTR:: ; d371 +W_MAPCONN1PTR:: ; d370 ds 1 -wNorthConnectionStripSrc:: ; d372 +wNorthConnectionStripSrc:: ; d371 ds 2 -wNorthConnectionStripDest:: ; d374 +wNorthConnectionStripDest:: ; d373 ds 2 -wNorthConnectionStripWidth:: ; d376 +wNorthConnectionStripWidth:: ; d375 ds 1 -wNorthConnectedMapWidth:: ; d377 +wNorthConnectedMapWidth:: ; d376 ds 1 -wNorthConnectedMapYAlignment:: ; d378 +wNorthConnectedMapYAlignment:: ; d377 ds 1 -wNorthConnectedMapXAlignment:: ; d379 +wNorthConnectedMapXAlignment:: ; d378 ds 1 -wNorthConnectedMapViewPointer:: ; d37a +wNorthConnectedMapViewPointer:: ; d379 ds 2 -W_MAPCONN2PTR:: ; d37c +W_MAPCONN2PTR:: ; d37b ds 1 -wSouthConnectionStripSrc:: ; d37d +wSouthConnectionStripSrc:: ; d37c ds 2 -wSouthConnectionStripDest:: ; d37f: +wSouthConnectionStripDest:: ; d37e ds 2 -wSouthConnectionStripWidth:: ; d381 +wSouthConnectionStripWidth:: ; d380 ds 1 -wSouthConnectedMapWidth:: ; d382 +wSouthConnectedMapWidth:: ; d381 ds 1 -wSouthConnectedMapYAlignment:: ; d383 +wSouthConnectedMapYAlignment:: ; d382 ds 1 -wSouthConnectedMapXAlignment:: ; d384 +wSouthConnectedMapXAlignment:: ; d383 ds 1 -wSouthConnectedMapViewPointer:: ; d385 +wSouthConnectedMapViewPointer:: ; d384 ds 2 -W_MAPCONN3PTR:: ; d387 +W_MAPCONN3PTR:: ; d386 ds 1 -wWestConnectionStripSrc:: ; d388 +wWestConnectionStripSrc:: ; d387 ds 2 -wWestConnectionStripDest:: ; d38a +wWestConnectionStripDest:: ; d389 ds 2 -wWestConnectionStripHeight:: ; d38c +wWestConnectionStripHeight:: ; d38b ds 1 -wWestConnectedMapWidth:: ; d38d +wWestConnectedMapWidth:: ; d38c ds 1 -wWestConnectedMapYAlignment:: ; d38e +wWestConnectedMapYAlignment:: ; d38d ds 1 -wWestConnectedMapXAlignment:: ; d38f +wWestConnectedMapXAlignment:: ; d38e ds 1 -wWestConnectedMapViewPointer:: ; d390 +wWestConnectedMapViewPointer:: ; d38f ds 2 -W_MAPCONN4PTR:: ; d392 +W_MAPCONN4PTR:: ; d391 ds 1 -wEastConnectionStripSrc:: ; d393 +wEastConnectionStripSrc:: ; d392 ds 2 -wEastConnectionStripDest:: ; d395 +wEastConnectionStripDest:: ; d394 ds 2 -wEastConnectionStripHeight:: ; d397 +wEastConnectionStripHeight:: ; d396 ds 1 -wEastConnectedMapWidth:: ; d398 +wEastConnectedMapWidth:: ; d397 ds 1 -wEastConnectedMapYAlignment:: ; d399 +wEastConnectedMapYAlignment:: ; d398 ds 1 -wEastConnectedMapXAlignment:: ; d39a +wEastConnectedMapXAlignment:: ; d399 ds 1 -wEastConnectedMapViewPointer:: ; d39b +wEastConnectedMapViewPointer:: ; d39a ds 2 -wSpriteSet:: ; d39d +wSpriteSet:: ; d39c ; sprite set for the current map (11 sprite picture ID's) ds 11 -wSpriteSetID:: ; d3a8 +wSpriteSetID:: ; d3a7 ; sprite set ID for the current map ds 1 -wObjectDataPointerTemp:: ; d3a9 +wObjectDataPointerTemp:: ; d3a8 ds 2 ds 2 -wMapBackgroundTile:: ; d3ad +wMapBackgroundTile:: ; d3ac ; the tile shown outside the boundaries of the map ds 1 -wNumberOfWarps:: ; d3ae +wNumberOfWarps:: ; d3ad ; number of warps in current map ds 1 -wWarpEntries:: ; d3af +wWarpEntries:: ; d3ae ; current map warp entries ds 128 -wDestinationWarpID:: ; d42f +wDestinationWarpID:: ; d42e ; if $ff, the player's coordinates are not updated when entering the map ds 1 @@ -2820,15 +2820,15 @@ wPikachuOverworldStateFlags:: ds 1 ; d42f wPikachuSpawnState:: ds 1 ; d430 wd432:: ds 1 ; d431 wd433:: ds 1 ; d432 -wd434:: ds 1 -wd435:: ds 1 -wd436:: ds 1 -wPikachuFollowCommandBufferSize:: ds 1 -wPikachuFollowCommandBuffer:: ds 16 +wd434:: ds 1 ; d433 +wd435:: ds 1 ; d434 +wd436:: ds 1 ; d435 +wPikachuFollowCommandBufferSize:: ds 1 ; d436 +wPikachuFollowCommandBuffer:: ds 16 ; d437 wExpressionNumber:: ; d447 ds 1 -wExpressionNumber2:: +wExpressionNumber2:: ; d448 ds 1 wPikachuMovementScriptBank:: ds 1 ; d449 @@ -2849,24 +2849,24 @@ wd456:: ds 1 ; d456 wd457:: ds 1 ; d457 wd458:: ds 1 ; d458 wCurPikaPicAnimObject:: ; d459 -wCurPikaPicAnimObjectIndex:: ds 1 -wCurPikaPicAnimObjectGraphicID:: dw +wCurPikaPicAnimObjectIndex:: ds 1 ; d459 +wCurPikaPicAnimObjectGraphicID:: dw ; d45a ds 2 -wCurPikaMovementDataEnd:: +wCurPikaMovementDataEnd:: ; d45e ds 17 wPikachuHappiness:: ds 1 ; d46f wPikachuMood:: ds 1 ; d470 -wd472:: ds 1 -wd473:: ds 1 +wd472:: ds 1 ; d471 +wd473:: ds 1 ; d472 ds 1 -wd475:: ds 1 +wd475:: ds 1 ; d474 ds 4 -wd47a:: ds 1 +wd47a:: ds 1 ; d479 ds 24 @@ -2885,121 +2885,121 @@ wd49c:: ds 1 ; d49b ds 19 -wNumSigns:: ; d4b0 +wNumSigns:: ; d4af ; number of signs in the current map (up to 16) ds 1 -wSignCoords:: ; d4b1 +wSignCoords:: ; d4b0 ; 2 bytes each ; Y, X ds 32 -wSignTextIDs:: ; d4d1 +wSignTextIDs:: ; d4d0 ds 16 -wNumSprites:: ; d4e1 +wNumSprites:: ; d4e0 ; number of sprites on the current map ds 1 ; these two variables track the X and Y offset in blocks from the last special warp used ; they don't seem to be used for anything -wYOffsetSinceLastSpecialWarp:: ; d4e2 +wYOffsetSinceLastSpecialWarp:: ; d4e1 ds 1 -wXOffsetSinceLastSpecialWarp:: ; d4e3 +wXOffsetSinceLastSpecialWarp:: ; d4e2 ds 1 -wMapSpriteData:: ; d4e4 +wMapSpriteData:: ; d4e3 ; two bytes per sprite (movement byte 2, text ID) ds 32 -wMapSpriteExtraData:: ; d504 +wMapSpriteExtraData:: ; d503 ; two bytes per sprite (trainer class/item ID, trainer set ID) ds 32 -wCurrentMapHeight2:: ; d524 +wCurrentMapHeight2:: ; d523 ; map height in 2x2 meta-tiles ds 1 -wCurrentMapWidth2:: ; d525 +wCurrentMapWidth2:: ; d524 ; map width in 2x2 meta-tiles ds 1 -wMapViewVRAMPointer:: ; d526 +wMapViewVRAMPointer:: ; d525 ; the address of the upper left corner of the visible portion of the BG tile map in VRAM ds 2 ; In the comments for the player direction variables below, "moving" refers to ; both walking and changing facing direction without taking a step. -wPlayerMovingDirection:: ; d528 +wPlayerMovingDirection:: ; d527 ; if the player is moving, the current direction ; if the player is not moving, zero ; map scripts write to this in order to change the player's facing direction ds 1 -wPlayerLastStopDirection:: ; d529 +wPlayerLastStopDirection:: ; d528 ; the direction in which the player was moving before the player last stopped ds 1 -wPlayerDirection:: ; d52a +wPlayerDirection:: ; d529 ; if the player is moving, the current direction ; if the player is not moving, the last the direction in which the player moved ds 1 -wTilesetBank:: ; d52b +wTilesetBank:: ; d52a ds 1 -W_TILESETBLOCKSPTR:: ; d52c +W_TILESETBLOCKSPTR:: ; d52b ; maps blocks (4x4 tiles) to tiles ds 2 -wTilesetGFXPtr:: ; d52e +wTilesetGFXPtr:: ; d52d ds 2 -wTilesetCollisionPtr:: ; d530 +wTilesetCollisionPtr:: ; d52f ; list of all walkable tiles ds 2 -W_TILESETTALKINGOVERTILES:: ; d532 +W_TILESETTALKINGOVERTILES:: ; d531 ds 3 -wGrassTile:: ; d535 +wGrassTile:: ; d534 ds 1 ds 4 -wNumBoxItems:: ; d53a +wNumBoxItems:: ; d539 ds 1 -wBoxItems:: ; d53b +wBoxItems:: ; d53a ; item, quantity ds 50 * 2 ds 1 ; end -wCurrentBoxNum:: ; d5a0 +wCurrentBoxNum:: ; d59f ; bits 0-6: box number ; bit 7: whether the player has changed boxes before ds 2 -wNumHoFTeams:: ; d5a2 +wNumHoFTeams:: ; d5a1 ; number of HOF teams ds 1 -wUnusedD5A3:: ; d5a3 +wUnusedD5A3:: ; d5a2 ds 1 -wPlayerCoins:: ; d5a4 +wPlayerCoins:: ; d5a3 ds 2 ; BCD -wMissableObjectFlags:: ; d5a6 +wMissableObjectFlags:: ; d5a5 ; bit array of missable objects. set = removed ds 32 -wMissableObjectFlagsEnd:: +wMissableObjectFlagsEnd:: ; d5c5 ds 7 -wd5cd:: ds 1 ; temp copy of c1x2 (sprite facing/anim) +wd5cd:: ds 1 ; temp copy of c1x2 (sprite facing/anim) ; d5cc -wMissableObjectList:: ; d5ce +wMissableObjectList:: ; d5cd ; each entry consists of 2 bytes ; * the sprite ID (depending on the current map) ; * the missable object index (global, used for wMissableObjectFlags) @@ -3223,17 +3223,17 @@ W_ROUTE18GATECURSCRIPT:: ; d668 ds 1 ds 78 -wGameProgressFlagsEnd:: +wGameProgressFlagsEnd:: ; d6b7 ds 56 -wObtainedHiddenItemsFlags:: +wObtainedHiddenItemsFlags:: ; d6ef ds 14 -wObtainedHiddenCoinsFlags:: +wObtainedHiddenCoinsFlags:: ; d6fd ds 2 -wWalkBikeSurfState:: ; d700 +wWalkBikeSurfState:: ; d6ff ; $00 = walking ; $01 = biking ; $02 = surfing @@ -3241,95 +3241,96 @@ wWalkBikeSurfState:: ; d700 ds 10 -wTownVisitedFlag:: ; d70b +wTownVisitedFlag:: ; d70a flag_array 13 -wSafariSteps:: ; d70d +wSafariSteps:: ; d70c ; starts at 502 ds 2 -W_FOSSILITEM:: ; d70f +W_FOSSILITEM:: ; d70e ; item given to cinnabar lab ds 1 -W_FOSSILMON:: ; d710 +W_FOSSILMON:: ; d70f ; mon that will result from the item ds 1 ds 2 -W_ENEMYMONORTRAINERCLASS:: ; d713 +W_ENEMYMONORTRAINERCLASS:: ; d712 ; trainer classes start at 200 ds 1 -wPlayerJumpingYScreenCoordsIndex:: ; d714 +wPlayerJumpingYScreenCoordsIndex:: ; d713 ds 1 -W_RIVALSTARTER:: ; d715 +W_RIVALSTARTER:: ; d714 ds 1 ds 1 -W_PLAYERSTARTER:: ; d717 +W_PLAYERSTARTER:: ; d716 ds 1 -wBoulderSpriteIndex:: ; d718 +wBoulderSpriteIndex:: ; d717 ; sprite index of the boulder the player is trying to push ds 1 -wLastBlackoutMap:: ; d719 +wLastBlackoutMap:: ; d718 ds 1 -wDestinationMap:: ; d71a +wDestinationMap:: ; d719 ; destination map (for certain types of special warps, not ordinary walking) ds 1 -wUnusedD71B:: ; d71b +wUnusedD71B:: ; d71a ds 1 -wTileInFrontOfBoulderAndBoulderCollisionResult:: ; d71c +wTileInFrontOfBoulderAndBoulderCollisionResult:: ; d71b ; used to store the tile in front of the boulder when trying to push a boulder ; also used to store the result of the collision check ($ff for a collision and $00 for no collision) ds 1 -wDungeonWarpDestinationMap:: ; d71d +wDungeonWarpDestinationMap:: ; d71c ; destination map for dungeon warps ds 1 -wWhichDungeonWarp:: ; d71e +wWhichDungeonWarp:: ; d71d ; which dungeon warp within the source map was used ds 1 -wUnusedD71F:: ; d71f +wUnusedD71F:: ; d71e ds 1 ds 8 -wd728:: +wd728:: ; d727 ; bit 0: using Strength outside of battle ds 1 ds 1 -wBeatGymFlags:: ; d72a +wBeatGymFlags:: ; d729 ; redundant because it matches wObtainedBadges ; used to determine whether to show name on statue and in two NPC text scripts ds 1 ds 1 -wd72c:: ; d72c +wd72c:: ; d72b ; bit 0: if not set, the 3 minimum steps between random battles have passed ds 1 wd72d:: ds 1 ; misc temp flags? (in some scripts, bit 6 and 7 set after a special battle (e.g. gym leaders) has been won) ; also used as a start menu flag + ; d72c -wd72e:: +wd72e:: ; d72d ; bit 7: set if scripted NPC movement has been initialised ds 2 ; more temp misc flags, used with npc movement, main menu and other stuff -wd730:: +wd730:: ; d72f ; bit 0: NPC sprite being moved by script ; bit 5: ignore joypad input ; bit 6: print text with no delay between each letter @@ -3338,7 +3339,7 @@ wd730:: ds 1 -wd732:: ; d732 +wd732:: ; d731 ; bit 0: play time being counted ; bit 1: remnant of debug mode? not set by the game code. ; if it is set @@ -3352,21 +3353,21 @@ wd732:: ; d732 ; bit 6: map destination is [wLastBlackoutMap] (usually the last used pokemon center, but could be the player's house) ds 1 -wFlags_D733:: ; d733 +wFlags_D733:: ; d732 ; bit 0: running a test battle ; bit 4: use variable [W_CURMAPSCRIPT] instead of the provided index for next frame's map script (used to start battle when talking to trainers) ; bit 7: used fly out of battle ds 1 -wBeatLorelei:: ; d734 +wBeatLorelei:: ; d733 ; bit 1: set when you beat Lorelei and reset in Indigo Plateau lobby ; the game uses this to tell when Elite 4 events need to be reset ds 1 -wd735:: ; d735 +wd735:: ; d734 ds 1 -wd736:: ; d736 +wd736:: ; d735 ; bit 0: check if the player is standing on a door and make him walk down a step if so ; bit 1: the player is currently stepping down from a door ; bit 2: standing on a warp @@ -3374,36 +3375,36 @@ wd736:: ; d736 ; bit 7: player sprite spinning due to spin tiles (Rocket hidehout / Viridian Gym) ds 1 -wCompletedInGameTradeFlags:: ; d737 +wCompletedInGameTradeFlags:: ; d736 ds 2 ds 2 -wWarpedFromWhichWarp:: ; d73b +wWarpedFromWhichWarp:: ; d73a ds 1 -wWarpedFromWhichMap:: ; d73c +wWarpedFromWhichMap:: ; d73b ds 1 ds 2 -wCardKeyDoorY:: ; d73f +wCardKeyDoorY:: ; d73e ds 1 -wCardKeyDoorX:: ; d740 +wCardKeyDoorX:: ; d73f ds 1 ds 2 -wFirstLockTrashCanIndex:: ; d743 +wFirstLockTrashCanIndex:: ; d742 ds 1 -wSecondLockTrashCanIndex:: ; d744 +wSecondLockTrashCanIndex:: ; d743 ds 1 ds 2 -wEventFlags:: ; d747 +wEventFlags:: ; d746 ; below here are mostly in game flags ; d74b @@ -3415,29 +3416,29 @@ wEventFlags:: ; d747 ; bit 5: received pokedex flag_array NUM_EVENT_FLAGS -wLinkEnemyTrainerName:: ; d887 +wLinkEnemyTrainerName:: ; d886 ; linked game's trainer name -wGrassRate:: ; d887 +wGrassRate:: ; d886 ds 1 -wGrassMons:: ; d888 +wGrassMons:: ; d887 ; ds 20 ds 11 ; Overload wGrassMons -wSerialEnemyDataBlock:: ; d893 +wSerialEnemyDataBlock:: ; d892 ds 9 -wEnemyPartyCount:: ds 1 ; d89c -wEnemyPartyMons:: ds PARTY_LENGTH + 1 ; d89d +wEnemyPartyCount:: ds 1 ; d89b +wEnemyPartyMons:: ds PARTY_LENGTH + 1 ; d89c -wWaterRate:: db ; d8a4 -wWaterMons:: db ; d8a5 +wWaterRate:: db ; d8a3 +wWaterMons:: db ; d8a4 ds wWaterRate - @ -wEnemyMons:: ; d8a4 +wEnemyMons:: ; d8a3 wEnemyMon1:: party_struct wEnemyMon1 wEnemyMon2:: party_struct wEnemyMon2 wEnemyMon3:: party_struct wEnemyMon3 @@ -3445,69 +3446,69 @@ wEnemyMon4:: party_struct wEnemyMon4 wEnemyMon5:: party_struct wEnemyMon5 wEnemyMon6:: party_struct wEnemyMon6 -wEnemyMonOT:: ds NAME_LENGTH * PARTY_LENGTH ; d9ac -wEnemyMonNicks:: ds NAME_LENGTH * PARTY_LENGTH ; d9ee +wEnemyMonOT:: ds NAME_LENGTH * PARTY_LENGTH ; d9ab +wEnemyMonNicks:: ds NAME_LENGTH * PARTY_LENGTH ; d9ed -wTrainerHeaderPtr:: ; da30 +wTrainerHeaderPtr:: ; da2f ds 2 ds 6 -wOpponentAfterWrongAnswer:: ; da38 +wOpponentAfterWrongAnswer:: ; da37 ; the trainer the player must face after getting a wrong answer in the Cinnabar ; gym quiz -wUnusedDA38:: ; da38 +wUnusedDA38:: ; da37 ds 1 -W_CURMAPSCRIPT:: ; da39 +W_CURMAPSCRIPT:: ; da38 ; index of current map script, mostly used as index for function pointer array ; mostly copied from map-specific map script pointer and wirtten back later ds 1 ds 6 -wPlayTimeHours:: ; da40 +wPlayTimeHours:: ; da3f ds 2 -wPlayTimeMinutes:: ; da42 +wPlayTimeMinutes:: ; da41 ds 2 -wPlayTimeSeconds:: ; da44 +wPlayTimeSeconds:: ; da43 ds 1 -wPlayTimeFrames:: ; da45 +wPlayTimeFrames:: ; da44 ds 1 -wSafariZoneGameOver:: ; da46 +wSafariZoneGameOver:: ; da45 ds 1 -wNumSafariBalls:: ; da47 +wNumSafariBalls:: ; da46 ds 1 -wDayCareInUse:: ; da48 +wDayCareInUse:: ; da47 ; 0 if no pokemon is in the daycare ; 1 if pokemon is in the daycare ds 1 -wDayCareMonName:: ds NAME_LENGTH ; da49 -wDayCareMonOT:: ds NAME_LENGTH ; da54 +wDayCareMonName:: ds NAME_LENGTH ; da48 +wDayCareMonOT:: ds NAME_LENGTH ; da53 -wDayCareMon:: box_struct wDayCareMon ; da5f +wDayCareMon:: box_struct wDayCareMon ; da5e wMainDataEnd:: wBoxDataStart:: -wNumInBox:: ds 1 ; da80 -wBoxSpecies:: ds MONS_PER_BOX + 1 +wNumInBox:: ds 1 ; da7f +wBoxSpecies:: ds MONS_PER_BOX + 1 ; da80 wBoxMons:: -wBoxMon1:: box_struct wBoxMon1 ; da96 -wBoxMon2:: ds box_struct_length * (MONS_PER_BOX + -1) ; dab7 +wBoxMon1:: box_struct wBoxMon1 ; da95 +wBoxMon2:: ds box_struct_length * (MONS_PER_BOX + -1) ; dab6 -wBoxMonOT:: ds NAME_LENGTH * MONS_PER_BOX ; dd2a -wBoxMonNicks:: ds NAME_LENGTH * MONS_PER_BOX ; de06 +wBoxMonOT:: ds NAME_LENGTH * MONS_PER_BOX ; dd29 +wBoxMonNicks:: ds NAME_LENGTH * MONS_PER_BOX ; de05 wBoxMonNicksEnd:: ; dee1 wBoxDataEnd:: -- cgit v1.3.1-sl0p