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 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'engine/menu') 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 -- 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 'engine/menu') 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 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 'engine/menu') 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 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 'engine/menu') 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