From 9bbb65166e4f7674bbdec7b1314b0cf42b43a923 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 29 Dec 2015 13:15:58 -0500 Subject: [PATCH] More movement stuff --- battle/core.asm | 15 +- battle/effect_commands.asm | 3 - battle/used_move_text.asm | 20 +- data/map_objects.asm | 44 ++ engine/breeding/egg.asm | 2 +- engine/learn.asm | 33 +- engine/mail.asm | 6 +- engine/map_object_action.asm | 323 +++++++++++ engine/map_objects.asm | 996 ++++++++-------------------------- engine/movement.asm | 38 +- engine/npctrade.asm | 1 - engine/player_movement.asm | 846 +++++++++++++++++++++++++++++ engine/timeset.asm | 2 - event/bug_contest_judging.asm | 3 - home/map_objects.asm | 4 +- macros/movement.asm | 30 +- main.asm | 870 +---------------------------- misc/mobile_22_2.asm | 3 - wram.asm | 13 +- 19 files changed, 1510 insertions(+), 1742 deletions(-) create mode 100755 data/map_objects.asm create mode 100755 engine/map_object_action.asm create mode 100755 engine/player_movement.asm diff --git a/battle/core.asm b/battle/core.asm index 3dc8a4dc0..d36735e79 100644 --- a/battle/core.asm +++ b/battle/core.asm @@ -5508,7 +5508,7 @@ EnemyMonEntrance: ; 3e3ff ; 3e40b BattleMonEntrance: ; 3e40b - call BattleMonNickComma_TextBox + call WithdrawPkmnText ld c, 50 call DelayFrames @@ -8103,8 +8103,6 @@ JumpText_GoForItPkmn: ; 3f2df JumpText_YourFoesWeakGetmPkmn: ; 3f2e6 text_jump Text_YourFoesWeakGetmPkmn start_asm -; 3f2eb - Function_TextJump_BattleMonNick01: ; 3f2eb ld hl, TextJump_BattleMonNick01 ret @@ -8115,18 +8113,13 @@ TextJump_BattleMonNick01: ; 3f2ef db "@" ; 3f2f4 - -BattleMonNickComma_TextBox: ; 3f2f4 - ld hl, TextJump_BattleMonNickComma +WithdrawPkmnText: ; 3f2f4 + ld hl, .WithdrawPkmnText jp BattleTextBox -; 3f2fa -TextJump_BattleMonNickComma: ; 3f2fa +.WithdrawPkmnText text_jump Text_BattleMonNickComma start_asm -; 3f2ff - -WithdrawPkmnText: ; 3f2ff ; Print text to withdraw Pkmn ; depending on HP the message is different push de diff --git a/battle/effect_commands.asm b/battle/effect_commands.asm index 0c7eafbc5..0425cda5d 100644 --- a/battle/effect_commands.asm +++ b/battle/effect_commands.asm @@ -5949,7 +5949,6 @@ BattleCommand_StatUpMessage: ; 363b8 .stat text_jump UnknownText_0x1c0cc6 start_asm - ld hl, .up ld a, [LoweredStat] and $f0 @@ -5983,7 +5982,6 @@ BattleCommand_StatDownMessage: ; 363e9 .stat text_jump UnknownText_0x1c0ceb start_asm - ld hl, .fell ld a, [LoweredStat] and $f0 @@ -7345,7 +7343,6 @@ BattleCommand_Charge: ; 36b4d .UsedText text_jump UnknownText_0x1c0d0e ; "[USER]" start_asm - ld a, BATTLE_VARS_MOVE_ANIM call GetBattleVar cp RAZOR_WIND diff --git a/battle/used_move_text.asm b/battle/used_move_text.asm index dac38dbef..b526d1233 100755 --- a/battle/used_move_text.asm +++ b/battle/used_move_text.asm @@ -11,7 +11,6 @@ UsedMoveText: ; 105db9 text_jump _ActorNameText start_asm - ld a, [hBattleTurn] and a jr nz, .start @@ -67,30 +66,26 @@ UsedMoveText: ; 105db9 UsedMove1Text: ; 105e04 text_jump _UsedMove1Text start_asm - jr Function105e10 + jr UsedMoveText_CheckObedience ; 105e0b UsedMove2Text: ; 105e0b text_jump _UsedMove2Text start_asm -; 105e10 - -Function105e10: ; 105e10 +UsedMoveText_CheckObedience: ; 105e10 ; check obedience ld a, [AlreadyDisobeyed] and a - jr z, GetMoveNameText + jr z, .GetMoveNameText ; print "instead," - ld hl, UsedInsteadText + ld hl, .UsedInsteadText ret ; 105e1a -UsedInsteadText: ; 105e1a +.UsedInsteadText text_jump _UsedInsteadText start_asm -; 105e1f - -GetMoveNameText: ; 105e1f +.GetMoveNameText ld hl, MoveNameText ret ; 105e23 @@ -98,9 +93,6 @@ GetMoveNameText: ; 105e1f MoveNameText: ; 105e23 text_jump _MoveNameText start_asm -; 105e28 - -GetUsedMoveTextEnder: ; 105e28 ; get start address ld hl, .endusedmovetexts diff --git a/data/map_objects.asm b/data/map_objects.asm new file mode 100755 index 000000000..715b1d1b9 --- /dev/null +++ b/data/map_objects.asm @@ -0,0 +1,44 @@ +sprite_movement_data: macro + db \1, \2, \3, \4, \5 + dn \6, 0 +endm + + ; function, facing, action, flags1, flags2, palette flags + sprite_movement_data SPRITEMOVEFN_00, DOWN, PERSON_ACTION_STAND, $02, $00, %0000 ; 00 + sprite_movement_data SPRITEMOVEFN_STANDING, DOWN, PERSON_ACTION_STAND, $0c, $00, %0000 ; 01 + sprite_movement_data SPRITEMOVEFN_RANDOM_WALK_XY, DOWN, PERSON_ACTION_STAND, $00, $00, %0000 ; 02 + sprite_movement_data SPRITEMOVEFN_SLOW_RANDOM_SPIN, DOWN, PERSON_ACTION_STAND, $00, $00, %0000 ; 03 + sprite_movement_data SPRITEMOVEFN_RANDOM_WALK_Y, DOWN, PERSON_ACTION_STAND, $00, $00, %0000 ; 04 + sprite_movement_data SPRITEMOVEFN_RANDOM_WALK_X, DOWN, PERSON_ACTION_STAND, $00, $00, %0000 ; 05 + sprite_movement_data SPRITEMOVEFN_STANDING, DOWN, PERSON_ACTION_STAND, $00, $00, %0000 ; 06 + sprite_movement_data SPRITEMOVEFN_STANDING, UP, PERSON_ACTION_STAND, $00, $00, %0000 ; 07 + sprite_movement_data SPRITEMOVEFN_STANDING, LEFT, PERSON_ACTION_STAND, $00, $00, %0000 ; 08 + sprite_movement_data SPRITEMOVEFN_STANDING, RIGHT, PERSON_ACTION_STAND, $00, $00, %0000 ; 09 + sprite_movement_data SPRITEMOVEFN_FAST_RANDOM_SPIN, DOWN, PERSON_ACTION_STAND, $00, $00, %0000 ; 0a + sprite_movement_data SPRITEMOVEFN_OBEY_DPAD, DOWN, PERSON_ACTION_STAND, $02, $00, %0000 ; 0b + sprite_movement_data SPRITEMOVEFN_08, DOWN, PERSON_ACTION_STAND, $00, $00, %0000 ; 0c + sprite_movement_data SPRITEMOVEFN_09, DOWN, PERSON_ACTION_STAND, $00, $00, %0000 ; 0d + sprite_movement_data SPRITEMOVEFN_0A, DOWN, PERSON_ACTION_STAND, $00, $00, %0000 ; 0e + sprite_movement_data SPRITEMOVEFN_0B, DOWN, PERSON_ACTION_STAND, $00, $00, %0000 ; 0f + sprite_movement_data SPRITEMOVEFN_0C, DOWN, PERSON_ACTION_STAND, $00, $00, %0000 ; 10 + sprite_movement_data SPRITEMOVEFN_0D, DOWN, PERSON_ACTION_STAND, $00, $00, %0000 ; 11 + sprite_movement_data SPRITEMOVEFN_0E, DOWN, PERSON_ACTION_STAND, $00, $00, %0000 ; 12 + sprite_movement_data SPRITEMOVEFN_FOLLOW, DOWN, PERSON_ACTION_STAND, $02, $00, %0000 ; 13 + sprite_movement_data SPRITEMOVEFN_SCRIPTED, DOWN, PERSON_ACTION_STAND, $02, $00, %0000 ; 14 + sprite_movement_data SPRITEMOVEFN_BIG_SNORLAX, DOWN, PERSON_ACTION_09, $2e, $01, %1100 ; 15 + sprite_movement_data SPRITEMOVEFN_BOUNCE, DOWN, PERSON_ACTION_0A, $2e, $00, %0000 ; 16 + sprite_movement_data SPRITEMOVEFN_STANDING, DOWN, PERSON_ACTION_STAND, $0c, $00, %0000 ; 17 + sprite_movement_data SPRITEMOVEFN_STANDING, DOWN, PERSON_ACTION_STAND, $2e, $10, %0000 ; 18 + sprite_movement_data SPRITEMOVEFN_STRENGTH, DOWN, PERSON_ACTION_STAND, $2e, $00, %0100 ; 19 + sprite_movement_data SPRITEMOVEFN_FOLLOWNOTEXACT, DOWN, PERSON_ACTION_STAND, $02, $00, %0000 ; 1a + sprite_movement_data SPRITEMOVEFN_SHADOW, DOWN, PERSON_ACTION_00, $8e, $01, %0000 ; 1b + sprite_movement_data SPRITEMOVEFN_EMOTE, DOWN, PERSON_ACTION_EMOTE, $8e, $02, %0000 ; 1c + sprite_movement_data SPRITEMOVEFN_SCREENSHAKE, DOWN, PERSON_ACTION_00, $82, $00, %0000 ; 1d + sprite_movement_data SPRITEMOVEFN_SPIN_COUNTERCLOCKWISE, LEFT, PERSON_ACTION_STAND, $00, $00, %0000 ; 1e + sprite_movement_data SPRITEMOVEFN_SPIN_CLOCKWISE, RIGHT, PERSON_ACTION_STAND, $00, $00, %0000 ; 1f + sprite_movement_data SPRITEMOVEFN_STRENGTH, DOWN, PERSON_ACTION_0C, $2e, $01, %1100 ; 20 + sprite_movement_data SPRITEMOVEFN_STRENGTH, DOWN, PERSON_ACTION_0D, $2e, $01, %1100 ; 21 + sprite_movement_data SPRITEMOVEFN_BOULDERDUST, DOWN, PERSON_ACTION_0E, $8e, $01, %0000 ; 22 + sprite_movement_data SPRITEMOVEFN_GRASS, DOWN, PERSON_ACTION_0F, $8e, $02, %0000 ; 23 + sprite_movement_data SPRITEMOVEFN_RANDOM_WALK_XY, DOWN, PERSON_ACTION_STAND, $00, $00, %0010 ; 24 + sprite_movement_data SPRITEMOVEFN_00, DOWN, PERSON_ACTION_STAND, $00, $00, %0000 ; 25 \ No newline at end of file diff --git a/engine/breeding/egg.asm b/engine/breeding/egg.asm index c9d401403..0573e2ecd 100755 --- a/engine/breeding/egg.asm +++ b/engine/breeding/egg.asm @@ -8,7 +8,7 @@ CheckBreedmonCompatibility: ; 16e1d ld [TempMonDVs], a ld a, [wBreedMon1DVs + 1] ld [TempMonDVs + 1], a - ld a, $3 + ld a, BREEDMON ld [MonType], a predef GetGender jr c, .genderless diff --git a/engine/learn.asm b/engine/learn.asm index e5ffabc62..64e73c910 100755 --- a/engine/learn.asm +++ b/engine/learn.asm @@ -51,7 +51,7 @@ LearnMove: ; 6508 .not_disabled call GetMoveName - ld hl, UnknownText_0x6684 ; 1, 2 and… + ld hl, Text_1_2_and_Poof ; 1, 2 and… call PrintText pop de pop hl @@ -102,18 +102,18 @@ LearnMove: ; 6508 jp .learned .cancel - ld hl, UnknownText_0x6675 ; Stop learning ? + ld hl, Text_StopLearning ; Stop learning ? call PrintText call YesNoBox jp c, .loop - ld hl, UnknownText_0x667a ; did not learn . + ld hl, Text_DidNotLearn ; did not learn . call PrintText ld b, 0 ret .learned - ld hl, UnknownText_0x666b ; learned ! + ld hl, Text_LearnedMove ; learned ! call PrintText ld b, 1 ret @@ -121,7 +121,7 @@ LearnMove: ; 6508 ForgetMove: ; 65d3 push hl - ld hl, UnknownText_0x667f + ld hl, Text_TryingToLearn call PrintText call YesNoBox pop hl @@ -135,7 +135,7 @@ ForgetMove: ; 65d3 pop hl .loop push hl - ld hl, UnknownText_0x6670 + ld hl, Text_ForgetWhich call PrintText hlcoord 5, 2 ld b, NUM_MOVES * 2 @@ -192,7 +192,7 @@ ForgetMove: ; 65d3 ret .hmmove - ld hl, UnknownText_0x669a + ld hl, Text_CantForgetHM call PrintText pop hl jr .loop @@ -202,55 +202,54 @@ ForgetMove: ; 65d3 ret ; 666b -UnknownText_0x666b: ; 666b +Text_LearnedMove: ; 666b ; learned ! text_jump UnknownText_0x1c5660 db "@" ; 6670 -UnknownText_0x6670: ; 6670 +Text_ForgetWhich: ; 6670 ; Which move should be forgotten? text_jump UnknownText_0x1c5678 db "@" ; 6675 -UnknownText_0x6675: ; 6675 +Text_StopLearning: ; 6675 ; Stop learning ? text_jump UnknownText_0x1c5699 db "@" ; 667a -UnknownText_0x667a: ; 667a +Text_DidNotLearn: ; 667a ; did not learn . text_jump UnknownText_0x1c56af db "@" ; 667f -UnknownText_0x667f: ; 667f +Text_TryingToLearn: ; 667f ; is trying to learn . But can't learn more than ; four moves. Delete an older move to make room for ? text_jump UnknownText_0x1c56c9 db "@" ; 6684 -UnknownText_0x6684: ; 6684 +Text_1_2_and_Poof: ; 6684 text_jump UnknownText_0x1c5740 ; 1, 2 and… start_asm push de ld de, SFX_SWITCH_POKEMON call PlaySFX pop de - ld hl, UnknownText_0x6695 + ld hl, .PoofForgot ret -; 6695 -UnknownText_0x6695: ; 6695 +.PoofForgot ; Poof! forgot . And… text_jump UnknownText_0x1c574e db "@" ; 669a -UnknownText_0x669a: ; 669a +Text_CantForgetHM: ; 669a ; HM moves can't be forgotten now. text_jump UnknownText_0x1c5772 db "@" diff --git a/engine/mail.asm b/engine/mail.asm index ab07e937e..133a2976e 100755 --- a/engine/mail.asm +++ b/engine/mail.asm @@ -208,12 +208,12 @@ GivePokeItem:: ; 446cc push bc push af ld hl, sPartyMail - ld bc, $2f + ld bc, MAIL_STRUCT_LENGTH call AddNTimes ld d, h ld e, l ld hl, wd002 - ld bc, $21 + ld bc, MAIL_MSG_LENGTH + 1 ld a, BANK(sPartyMail) call GetSRAMBank call CopyBytes @@ -222,7 +222,7 @@ GivePokeItem:: ; 446cc ld hl, PartyMonOT ld bc, NAME_LENGTH call AddNTimes - ld bc, $a + ld bc, NAME_LENGTH - 1 call CopyBytes pop af ld hl, PartyMon1ID diff --git a/engine/map_object_action.asm b/engine/map_object_action.asm new file mode 100755 index 000000000..b7f98e8d7 --- /dev/null +++ b/engine/map_object_action.asm @@ -0,0 +1,323 @@ + ld hl, OBJECT_ACTION + add hl, bc + ld a, [hl] + ld l, a + ld h, 0 + add hl, hl + add hl, hl + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + call _hl_ + ret +; 445f + +Pointers445f: ; 445f + dw SetFacingStanding, SetFacingStanding ; 00 + dw Function44b5, SetFacingCurrent ; 01 standing? + dw Function44c1, SetFacingCurrent ; 02 walking? + dw Function4508, SetFacingCurrent ; 03 bumping? + dw Function4529, SetFacingCurrent ; 04 + dw Function4539, SetFacingStanding ; 05 + dw Function456e, Function456e ; 06 + dw Function457b, SetFacingStanding ; 07 + dw Function4582, Function4582 ; 08 + dw Function4589, Function4589 ; 09 + dw Function4590, Function45a4 ; 0a + dw Function45ab, SetFacingCurrent ; 0c + dw Function45be, Function45be ; 0b + dw Function45c5, Function45c5 ; 0d + dw Function45da, SetFacingStanding ; 0e + dw Function45ed, SetFacingStanding ; 0f + dw Function44e4, SetFacingCurrent ; 10 +; 44a3 + +SetFacingStanding: ; 44a3 + ld hl, OBJECT_FACING_STEP + add hl, bc + ld [hl], STANDING + ret +; 44aa + +SetFacingCurrent: ; 44aa + call GetSpriteDirection + or 0 ; useless + ld hl, OBJECT_FACING_STEP + add hl, bc + ld [hl], a + ret +; 44b5 + +Function44b5: ; 44b5 + ld hl, OBJECT_FACING_STEP + add hl, bc + ld a, [hl] + and 1 + jr nz, Function44c1 + jp SetFacingCurrent +; 44c1 + +Function44c1: ; 44c1 + ld hl, OBJECT_FLAGS1 + add hl, bc + bit SLIDING, [hl] + jp nz, SetFacingCurrent + + ld hl, OBJECT_STEP_FRAME + add hl, bc + ld a, [hl] + inc a + and %00001111 + ld [hl], a + + rrca + rrca + and %00000011 + ld d, a + + call GetSpriteDirection + or 0 ; useless + or d + ld hl, OBJECT_FACING_STEP + add hl, bc + ld [hl], a + ret +; 44e4 + +Function44e4: ; 44e4 + ld hl, OBJECT_FLAGS1 + add hl, bc + bit SLIDING, [hl] + jp nz, SetFacingCurrent + + ld hl, OBJECT_STEP_FRAME + add hl, bc + ld a, [hl] + add 2 + and %00001111 + ld [hl], a + + rrca + rrca + and %00000011 + ld d, a + + call GetSpriteDirection + or 0 ; useless + or d + ld hl, OBJECT_FACING_STEP + add hl, bc + ld [hl], a + ret +; 4508 + +Function4508: ; 4508 + ld hl, OBJECT_FLAGS1 + add hl, bc + bit SLIDING, [hl] + jp nz, SetFacingCurrent + + ld hl, OBJECT_STEP_FRAME + add hl, bc + inc [hl] + + ld a, [hl] + rrca + rrca + rrca + and %00000011 + ld d, a + + call GetSpriteDirection + or 0 ; useless + or d + ld hl, OBJECT_FACING_STEP + add hl, bc + ld [hl], a + ret +; 4529 + +Function4529: ; 4529 + call Function453f + ld hl, OBJECT_FACING + add hl, bc + ld a, [hl] + or 0 ; useless + ld hl, OBJECT_FACING_STEP + add hl, bc + ld [hl], a + ret +; 4539 + +Function4539: ; 4539 + call Function453f + jp SetFacingStanding +; 453f + +Function453f: ; 453f + ld hl, OBJECT_STEP_FRAME + add hl, bc + ld a, [hl] + and %11110000 + ld e, a + + ld a, [hl] + inc a + and %00001111 + ld d, a + cp 4 + jr c, .ok + + ld d, 0 + ld a, e + add $10 + and %00110000 + ld e, a + +.ok + ld a, d + or e + ld [hl], a + + swap e + ld d, 0 + ld hl, .Directions + add hl, de + ld a, [hl] + ld hl, OBJECT_FACING + add hl, bc + ld [hl], a + ret +; 456a + +.Directions ; 456a + db OW_DOWN, OW_RIGHT, OW_UP, OW_LEFT +; 456e + +Function456e: ; 456e + call GetSpriteDirection + rrca + rrca + add $10 + ld hl, OBJECT_FACING_STEP + add hl, bc + ld [hl], a + ret +; 457b + +Function457b: ; 457b + ld hl, OBJECT_FACING_STEP + add hl, bc + ld [hl], FACING_15 + ret +; 4582 + +Function4582: ; 4582 emote + ld hl, OBJECT_FACING_STEP + add hl, bc + ld [hl], FACING_EMOTE + ret +; 4589 + +Function4589: ; 4589 + ld hl, OBJECT_FACING_STEP + add hl, bc + ld [hl], FACING_17 + ret +; 4590 + +Function4590: ; 4590 + ld hl, OBJECT_STEP_FRAME + add hl, bc + ld a, [hl] + inc a + and %00001111 + ld [hl], a + and %00001000 + jr z, Function45a4 + ld hl, OBJECT_FACING_STEP + add hl, bc + ld [hl], FACING_04 + ret +; 45a4 + +Function45a4: ; 45a4 + ld hl, OBJECT_FACING_STEP + add hl, bc + ld [hl], 0 + ret +; 45ab + +Function45ab: ; 45ab + ld hl, OBJECT_STEP_FRAME + add hl, bc + ld a, [hl] + inc a + ld [hl], a + and %00001100 + rrca + rrca + add $18 + ld hl, OBJECT_FACING_STEP + add hl, bc + ld [hl], a + ret +; 45be + +Function45be: ; 45be + ld hl, OBJECT_FACING_STEP + add hl, bc + ld [hl], FACING_16 + ret +; 45c5 + +Function45c5: ; 45c5 + ld a, [VariableSprites + SPRITE_BIG_DOLL - SPRITE_VARS] + ld d, FACING_17 + cp SPRITE_BIG_SNORLAX + jr z, .ok + cp SPRITE_BIG_LAPRAS + jr z, .ok + ld d, FACING_16 + +.ok + ld hl, OBJECT_FACING_STEP + add hl, bc + ld [hl], d + ret +; 45da + +Function45da: ; 45da + ld hl, OBJECT_STEP_FRAME + add hl, bc + inc [hl] + ld a, [hl] + + ld hl, OBJECT_FACING_STEP + add hl, bc + and 2 + ld a, FACING_1C + jr z, .ok + inc a ; FACING_1D +.ok + ld [hl], a + ret +; 45ed + +Function45ed: ; 45ed + ld hl, OBJECT_STEP_FRAME + add hl, bc + inc [hl] + ld a, [hl] + ld hl, OBJECT_FACING_STEP + add hl, bc + and 4 + ld a, FACING_1E + jr z, .ok + inc a ; FACING_1F + +.ok + ld [hl], a + ret +; 4600 diff --git a/engine/map_objects.asm b/engine/map_objects.asm index cd272bdc9..ce83ba9f2 100644 --- a/engine/map_objects.asm +++ b/engine/map_objects.asm @@ -2,53 +2,9 @@ INCLUDE "engine/facings.asm" SpriteMovementData:: ; 4273 +INCLUDE "data/map_objects.asm" -sprite_movement_data: macro - db \1, \2, \3, \4, \5 - dn \6, 0 - endm - ; function, facing, action, flags1, flags2, palette flags - sprite_movement_data SPRITEMOVEFN_00, DOWN, PERSON_ACTION_STAND, $02, $00, %0000 ; 00 - sprite_movement_data SPRITEMOVEFN_STANDING, DOWN, PERSON_ACTION_STAND, $0c, $00, %0000 ; 01 - sprite_movement_data SPRITEMOVEFN_RANDOM_WALK_XY, DOWN, PERSON_ACTION_STAND, $00, $00, %0000 ; 02 - sprite_movement_data SPRITEMOVEFN_SLOW_RANDOM_SPIN, DOWN, PERSON_ACTION_STAND, $00, $00, %0000 ; 03 - sprite_movement_data SPRITEMOVEFN_RANDOM_WALK_Y, DOWN, PERSON_ACTION_STAND, $00, $00, %0000 ; 04 - sprite_movement_data SPRITEMOVEFN_RANDOM_WALK_X, DOWN, PERSON_ACTION_STAND, $00, $00, %0000 ; 05 - sprite_movement_data SPRITEMOVEFN_STANDING, DOWN, PERSON_ACTION_STAND, $00, $00, %0000 ; 06 - sprite_movement_data SPRITEMOVEFN_STANDING, UP, PERSON_ACTION_STAND, $00, $00, %0000 ; 07 - sprite_movement_data SPRITEMOVEFN_STANDING, LEFT, PERSON_ACTION_STAND, $00, $00, %0000 ; 08 - sprite_movement_data SPRITEMOVEFN_STANDING, RIGHT, PERSON_ACTION_STAND, $00, $00, %0000 ; 09 - sprite_movement_data SPRITEMOVEFN_FAST_RANDOM_SPIN, DOWN, PERSON_ACTION_STAND, $00, $00, %0000 ; 0a - sprite_movement_data SPRITEMOVEFN_OBEY_DPAD, DOWN, PERSON_ACTION_STAND, $02, $00, %0000 ; 0b - sprite_movement_data SPRITEMOVEFN_08, DOWN, PERSON_ACTION_STAND, $00, $00, %0000 ; 0c - sprite_movement_data SPRITEMOVEFN_09, DOWN, PERSON_ACTION_STAND, $00, $00, %0000 ; 0d - sprite_movement_data SPRITEMOVEFN_0A, DOWN, PERSON_ACTION_STAND, $00, $00, %0000 ; 0e - sprite_movement_data SPRITEMOVEFN_0B, DOWN, PERSON_ACTION_STAND, $00, $00, %0000 ; 0f - sprite_movement_data SPRITEMOVEFN_0C, DOWN, PERSON_ACTION_STAND, $00, $00, %0000 ; 10 - sprite_movement_data SPRITEMOVEFN_0D, DOWN, PERSON_ACTION_STAND, $00, $00, %0000 ; 11 - sprite_movement_data SPRITEMOVEFN_0E, DOWN, PERSON_ACTION_STAND, $00, $00, %0000 ; 12 - sprite_movement_data SPRITEMOVEFN_FOLLOW, DOWN, PERSON_ACTION_STAND, $02, $00, %0000 ; 13 - sprite_movement_data SPRITEMOVEFN_SCRIPTED, DOWN, PERSON_ACTION_STAND, $02, $00, %0000 ; 14 - sprite_movement_data SPRITEMOVEFN_BIG_SNORLAX, DOWN, PERSON_ACTION_09, $2e, $01, %1100 ; 15 - sprite_movement_data SPRITEMOVEFN_BOUNCE, DOWN, PERSON_ACTION_0A, $2e, $00, %0000 ; 16 - sprite_movement_data SPRITEMOVEFN_STANDING, DOWN, PERSON_ACTION_STAND, $0c, $00, %0000 ; 17 - sprite_movement_data SPRITEMOVEFN_STANDING, DOWN, PERSON_ACTION_STAND, $2e, $10, %0000 ; 18 - sprite_movement_data SPRITEMOVEFN_STRENGTH, DOWN, PERSON_ACTION_STAND, $2e, $00, %0100 ; 19 - sprite_movement_data SPRITEMOVEFN_FOLLOWNOTEXACT, DOWN, PERSON_ACTION_STAND, $02, $00, %0000 ; 1a - sprite_movement_data SPRITEMOVEFN_SHADOW, DOWN, PERSON_ACTION_00, $8e, $01, %0000 ; 1b - sprite_movement_data SPRITEMOVEFN_EMOTE, DOWN, PERSON_ACTION_EMOTE, $8e, $02, %0000 ; 1c - sprite_movement_data SPRITEMOVEFN_SCREENSHAKE, DOWN, PERSON_ACTION_00, $82, $00, %0000 ; 1d - sprite_movement_data SPRITEMOVEFN_SPIN_COUNTERCLOCKWISE, LEFT, PERSON_ACTION_STAND, $00, $00, %0000 ; 1e - sprite_movement_data SPRITEMOVEFN_SPIN_CLOCKWISE, RIGHT, PERSON_ACTION_STAND, $00, $00, %0000 ; 1f - sprite_movement_data SPRITEMOVEFN_STRENGTH, DOWN, PERSON_ACTION_0C, $2e, $01, %1100 ; 20 - sprite_movement_data SPRITEMOVEFN_STRENGTH, DOWN, PERSON_ACTION_0D, $2e, $01, %1100 ; 21 - sprite_movement_data SPRITEMOVEFN_BOULDERDUST, DOWN, PERSON_ACTION_0E, $8e, $01, %0000 ; 22 - sprite_movement_data SPRITEMOVEFN_GRASS, DOWN, PERSON_ACTION_0F, $8e, $02, %0000 ; 23 - sprite_movement_data SPRITEMOVEFN_RANDOM_WALK_XY, DOWN, PERSON_ACTION_STAND, $00, $00, %0010 ; 24 - sprite_movement_data SPRITEMOVEFN_00, DOWN, PERSON_ACTION_STAND, $00, $00, %0000 ; 25 ; 4357 - - DeleteMapObject:: ; 4357 push bc ld hl, OBJECT_MAP_OBJECT_INDEX @@ -69,7 +25,6 @@ DeleteMapObject:: ; 4357 ld hl, OBJECT_SPRITE add hl, bc ld [hl], -1 - .ok pop bc ret @@ -78,12 +33,11 @@ DeleteMapObject:: ; 4357 Function437b: ; 437b call .CheckObjectStillVisible ret c - call Function43f3 - call Function4427 + call .HandleStepType + call .HandleObjectAction ret -; 4386 -.CheckObjectStillVisible: ; 4386 +.CheckObjectStillVisible ld hl, OBJECT_FLAGS2 add hl, bc res 6, [hl] @@ -133,7 +87,6 @@ Function437b: ; 437b jr c, .ok2 cp MAPOBJECT_SCREEN_HEIGHT jr nc, .ok2 - .yes and a ret @@ -153,23 +106,20 @@ Function437b: ; 437b set 6, [hl] and a ret -; 43f3 -Function43f3: ; 43f3 +.HandleStepType ld hl, OBJECT_STEP_TYPE add hl, bc ld a, [hl] and a jr z, .zero - ld hl, OBJECT_FLAGS2 add hl, bc bit 5, [hl] jr nz, .bit5 - cp STEP_TYPE_SLEEP jr z, .one - jr .ok + jr .ok3 .zero call ObjectMovementReset @@ -177,10 +127,8 @@ Function43f3: ; 43f3 add hl, bc bit 5, [hl] jr nz, .bit5 - .one call MapObjectMovementPattern - ld hl, OBJECT_STEP_TYPE add hl, bc ld a, [hl] @@ -188,32 +136,27 @@ Function43f3: ; 43f3 ret z cp STEP_TYPE_SLEEP ret z - -.ok +.ok3 ld hl, Pointers4b45 rst JumpTable ret .bit5 ret -; 4427 -Function4427: ; 4427 +.HandleObjectAction ld hl, OBJECT_FLAGS1 add hl, bc bit INVISIBLE, [hl] jr nz, SetFacingStanding - ld hl, OBJECT_FLAGS2 add hl, bc bit 6, [hl] jr nz, SetFacingStanding - bit 5, [hl] - jr nz, Function4448 - - ld de, Pointers445f - jr Function444d + jr nz, asm_4448 + ld de, Pointers445f ; use first column + jr asm_444d ; 4440 Function4440: ; 4440 @@ -221,385 +164,55 @@ Function4440: ; 4440 add hl, bc bit INVISIBLE, [hl] jr nz, SetFacingStanding -Function4448: ; 4448 +asm_4448 ; use second column ld de, Pointers445f + 2 - jr Function444d + jr asm_444d ; 444d -Function444d: ; 444d +asm_444d ; call [4 * ObjectStructs[ObjInd, OBJECT_ACTION] + de] - ld hl, OBJECT_ACTION - add hl, bc - ld a, [hl] - ld l, a - ld h, 0 - add hl,hl - add hl,hl - add hl, de - ld a, [hli] - ld h, [hl] - ld l, a - call _hl_ - ret -; 445f - -Pointers445f: ; 445f - dw SetFacingStanding, SetFacingStanding ; 00 - dw Function44b5, SetFacingCurrent ; 01 standing? - dw Function44c1, SetFacingCurrent ; 02 walking? - dw Function4508, SetFacingCurrent ; 03 bumping? - dw Function4529, SetFacingCurrent ; 04 - dw Function4539, SetFacingStanding ; 05 - dw Function456e, Function456e ; 06 - dw Function457b, SetFacingStanding ; 07 - dw Function4582, Function4582 ; 08 - dw Function4589, Function4589 ; 09 - dw Function4590, Function45a4 ; 0a - dw Function45ab, SetFacingCurrent ; 0c - dw Function45be, Function45be ; 0b - dw Function45c5, Function45c5 ; 0d - dw Function45da, SetFacingStanding ; 0e - dw Function45ed, SetFacingStanding ; 0f - dw Function44e4, SetFacingCurrent ; 10 -; 44a3 - -SetFacingStanding: ; 44a3 - ld hl, OBJECT_FACING_STEP - add hl, bc - ld [hl], STANDING - ret -; 44aa - -SetFacingCurrent: ; 44aa - call GetSpriteDirection - or 0 ; useless - ld hl, OBJECT_FACING_STEP - add hl, bc - ld [hl], a - ret -; 44b5 - -Function44b5: ; 44b5 - ld hl, OBJECT_FACING_STEP - add hl, bc - ld a, [hl] - and 1 - jr nz, Function44c1 - jp SetFacingCurrent -; 44c1 - -Function44c1: ; 44c1 - ld hl, OBJECT_FLAGS1 - add hl, bc - bit SLIDING, [hl] - jp nz, SetFacingCurrent - - ld hl, OBJECT_STEP_FRAME - add hl, bc - ld a, [hl] - inc a - and %00001111 - ld [hl], a - - rrca - rrca - and %00000011 - ld d, a - - call GetSpriteDirection - or 0 ; useless - or d - ld hl, OBJECT_FACING_STEP - add hl, bc - ld [hl], a - ret -; 44e4 - -Function44e4: ; 44e4 - ld hl, OBJECT_FLAGS1 - add hl, bc - bit SLIDING, [hl] - jp nz, SetFacingCurrent - - ld hl, OBJECT_STEP_FRAME - add hl, bc - ld a, [hl] - add 2 - and %00001111 - ld [hl], a - - rrca - rrca - and %00000011 - ld d, a - - call GetSpriteDirection - or 0 ; useless - or d - ld hl, OBJECT_FACING_STEP - add hl, bc - ld [hl], a - ret -; 4508 - -Function4508: ; 4508 - ld hl, OBJECT_FLAGS1 - add hl, bc - bit SLIDING, [hl] - jp nz, SetFacingCurrent - - ld hl, OBJECT_STEP_FRAME - add hl, bc - inc [hl] - - ld a, [hl] - rrca - rrca - rrca - and %00000011 - ld d, a - - call GetSpriteDirection - or 0 ; useless - or d - ld hl, OBJECT_FACING_STEP - add hl, bc - ld [hl], a - ret -; 4529 - -Function4529: ; 4529 - call Function453f - ld hl, OBJECT_FACING - add hl, bc - ld a, [hl] - or 0 ; useless - ld hl, OBJECT_FACING_STEP - add hl, bc - ld [hl], a - ret -; 4539 - -Function4539: ; 4539 - call Function453f - jp SetFacingStanding -; 453f - -Function453f: ; 453f - ld hl, OBJECT_STEP_FRAME - add hl, bc - ld a, [hl] - and %11110000 - ld e, a - - ld a, [hl] - inc a - and %00001111 - ld d, a - cp 4 - jr c, .ok - - ld d, 0 - ld a, e - add $10 - and %00110000 - ld e, a - -.ok - ld a, d - or e - ld [hl], a - - swap e - ld d, 0 - ld hl, .Directions - add hl, de - ld a, [hl] - ld hl, OBJECT_FACING - add hl, bc - ld [hl], a - ret -; 456a - -.Directions ; 456a - db OW_DOWN, OW_RIGHT, OW_UP, OW_LEFT -; 456e - -Function456e: ; 456e - call GetSpriteDirection - rrca - rrca - add $10 - ld hl, OBJECT_FACING_STEP - add hl, bc - ld [hl], a - ret -; 457b - -Function457b: ; 457b - ld hl, OBJECT_FACING_STEP - add hl, bc - ld [hl], FACING_15 - ret -; 4582 - -Function4582: ; 4582 emote - ld hl, OBJECT_FACING_STEP - add hl, bc - ld [hl], FACING_EMOTE - ret -; 4589 - -Function4589: ; 4589 - ld hl, OBJECT_FACING_STEP - add hl, bc - ld [hl], FACING_17 - ret -; 4590 - -Function4590: ; 4590 - ld hl, OBJECT_STEP_FRAME - add hl, bc - ld a, [hl] - inc a - and %00001111 - ld [hl], a - and %00001000 - jr z, Function45a4 - ld hl, OBJECT_FACING_STEP - add hl, bc - ld [hl], FACING_04 - ret -; 45a4 - -Function45a4: ; 45a4 - ld hl, OBJECT_FACING_STEP - add hl, bc - ld [hl], 0 - ret -; 45ab - -Function45ab: ; 45ab - ld hl, OBJECT_STEP_FRAME - add hl, bc - ld a, [hl] - inc a - ld [hl], a - and %00001100 - rrca - rrca - add $18 - ld hl, OBJECT_FACING_STEP - add hl, bc - ld [hl], a - ret -; 45be - -Function45be: ; 45be - ld hl, OBJECT_FACING_STEP - add hl, bc - ld [hl], FACING_16 - ret -; 45c5 - -Function45c5: ; 45c5 - ld a, [VariableSprites + SPRITE_BIG_DOLL - SPRITE_VARS] - ld d, FACING_17 - cp SPRITE_BIG_SNORLAX - jr z, .ok - cp SPRITE_BIG_LAPRAS - jr z, .ok - ld d, FACING_16 - -.ok - ld hl, OBJECT_FACING_STEP - add hl, bc - ld [hl], d - ret -; 45da - -Function45da: ; 45da - ld hl, OBJECT_STEP_FRAME - add hl, bc - inc [hl] - ld a, [hl] - - ld hl, OBJECT_FACING_STEP - add hl, bc - and 2 - ld a, FACING_1C - jr z, .ok - inc a ; FACING_1D -.ok - ld [hl], a - ret -; 45ed - -Function45ed: ; 45ed - ld hl, OBJECT_STEP_FRAME - add hl, bc - inc [hl] - ld a, [hl] - ld hl, OBJECT_FACING_STEP - add hl, bc - and 4 - ld a, FACING_1E - jr z, .ok - inc a ; FACING_1F - -.ok - ld [hl], a - ret -; 4600 +INCLUDE "engine/map_object_action.asm" CopyNextCoordsTileToStandingCoordsTile: ; 4600 - ld hl, OBJECT_NEXT_MAP_X add hl, bc ld a, [hl] ld hl, OBJECT_MAP_X add hl, bc ld [hl], a - ld hl, OBJECT_NEXT_MAP_Y add hl, bc ld a, [hl] ld hl, OBJECT_MAP_Y add hl, bc ld [hl], a - ld hl, OBJECT_NEXT_TILE add hl, bc ld a, [hl] ld hl, OBJECT_STANDING_TILE add hl, bc ld [hl], a - call SetTallGrassFlags ld hl, OBJECT_NEXT_TILE add hl, bc ld a, [hl] - call UselessAndA ret ; 462a Function462a: ; 462a - ld hl, OBJECT_MAP_X add hl, bc ld a, [hl] ld hl, OBJECT_NEXT_MAP_X add hl, bc ld [hl], a - ld hl, OBJECT_MAP_Y add hl, bc ld a, [hl] ld hl, OBJECT_NEXT_MAP_Y add hl, bc ld [hl], a - ret ; 463f @@ -612,7 +225,6 @@ UpdateTallGrassFlags: ; 463f add hl, bc ld a, [hl] call SetTallGrassFlags - .ok ld hl, OBJECT_NEXT_TILE add hl, bc @@ -631,7 +243,6 @@ SetTallGrassFlags: ; 4661 jr z, .set call CheckGrassTile jr c, .reset - .set ld hl, OBJECT_FLAGS2 add hl, bc @@ -683,11 +294,9 @@ InitStep: ; 4690 ld [hl], a GetNextTile: ; 46a6 call GetStepVector - ld hl, OBJECT_STEP_DURATION add hl, bc ld [hl], a - ld a, d call GetStepVectorSign ld hl, OBJECT_MAP_X @@ -697,7 +306,6 @@ GetNextTile: ; 46a6 add hl, bc ld [hl], a ld d, a - ld a, e call GetStepVectorSign ld hl, OBJECT_MAP_Y @@ -707,34 +315,27 @@ GetNextTile: ; 46a6 add hl, bc ld [hl], a ld e, a - push bc call GetCoordTile pop bc - ld hl, OBJECT_NEXT_TILE add hl, bc ld [hl], a - ret ; 46d7 AddStepVector: ; 46d7 - call GetStepVector - ld hl, OBJECT_SPRITE_X add hl, bc ld a, [hl] add d ld [hl], a - ld hl, OBJECT_SPRITE_Y add hl, bc ld a, [hl] add e ld [hl], a - ret ; 46e9 @@ -777,18 +378,14 @@ StepVectors: ; 4700 db -4, 0, 4, 4 db 4, 0, 4, 4 ; 4730 - GetStepVectorSign: ; 4730 add a ret z ; 0 or 128 - ld a, 1 ret nc ; 1 - 127 - ld a, -1 ret ; 129 - 255 ; 4738 - UpdatePlayerStep: ; 4738 ld hl, OBJECT_DIRECTION_WALKING add hl, bc @@ -808,6 +405,7 @@ UpdatePlayerStep: ; 4738 ; 4759 Function4759: ; 4759 +; unreferenced push bc ld e, a ld d, 0 @@ -836,7 +434,7 @@ RestoreDefaultMovement: ; 4769 ret .ok - ld a, 6 + ld a, SPRITEMOVEFN_STANDING ret ; 4780 @@ -885,7 +483,6 @@ IncrementObjectStructField28: ; 47a2 ; 47a8 Object28AnonymousJumptable: ; 47a8 -; anonymous dw ld hl, OBJECT_28 add hl, bc ld a, [hl] @@ -936,10 +533,8 @@ MapObjectMovementPattern: ; 47dd ld hl, .Pointers rst JumpTable ret -; 47e9 .Pointers ; 47e9 - dw .Null_00 ; 00 dw .RandomWalkY ; 01 dw .RandomWalkX ; 02 @@ -968,35 +563,30 @@ MapObjectMovementPattern: ; 47dd dw .MovementSpinCounterclockwise ; 19 dw .MovementBoulderDust ; 1a dw .MovementShakingGrass ; 1b -; 4821 -.Null_00: ; 4821 +.Null_00 ret -; 4822 -.RandomWalkY: ; 4822 +.RandomWalkY call Random ld a, [hRandomAdd] and %00000001 jp .RandomWalkContinue -; 482c -.RandomWalkX: ; 482c +.RandomWalkX call Random ld a, [hRandomAdd] and %00000001 or %00000010 jp .RandomWalkContinue -; 4838 -.RandomWalkXY: ; 4838 +.RandomWalkXY call Random ld a, [hRandomAdd] and %00000011 jp .RandomWalkContinue -; 4842 -.RandomSpin1: ; 4842 +.RandomSpin1 call Random ld a, [hRandomAdd] and %00001100 @@ -1004,9 +594,8 @@ MapObjectMovementPattern: ; 47dd add hl, bc ld [hl], a jp RandomStepDuration_Slow -; 4851 -.RandomSpin2: ; 4851 +.RandomSpin2 ld hl, OBJECT_FACING add hl, bc ld a, [hl] @@ -1018,13 +607,11 @@ MapObjectMovementPattern: ; 47dd cp d jr nz, .keep xor %00001100 - .keep ld [hl], a jp RandomStepDuration_Fast -; 4869 -.Standing: ; 4869 +.Standing call Function462a call EndSpriteMovement ld hl, OBJECT_ACTION @@ -1034,73 +621,59 @@ MapObjectMovementPattern: ; 47dd add hl, bc ld [hl], STEP_TYPE_05 ret -; 487c -.ObeyDPad: ; 487c +.ObeyDPad ld hl, Function5000 jp HandleMovementData -; 4882 -.Movement08: ; 4882 +.Movement08 ld hl, Function5015 jp HandleMovementData -; 4888 -.Movement09: ; 4888 +.Movement09 ld hl, Function5026 jp HandleMovementData -; 488e -.Movement0a: ; 488e - jp Function5037 -; 4891 +.Movement0a + jp _GetMovementPerson -.Movement0b: ; 4891 - jp Function5037 -; 4894 +.Movement0b + jp _GetMovementPerson -.Movement0c: ; 4894 - jp Function5037 -; 4897 +.Movement0c + jp _GetMovementPerson -.Movement0d: ; 4897 +.Movement0d ld hl, Function5000 jp HandleMovementData -; 489d -.Movement0e: ; 489d - jp Function5037 -; 48a0 +.Movement0e + jp _GetMovementPerson -.Follow: ; 48a0 - ld hl, Function54e6 +.Follow + ld hl, GetFollowerNextMovementByte jp HandleMovementData -; 48a6 -.Script: ; 48a6 - ld hl, Function500e +.Script + ld hl, GetMovementByte jp HandleMovementData -; 48ac -.Strength: ; 48ac +.Strength call MovementAnonymousJumptable dw .Strength_Start dw .Strength_Stop -; 48b3 -.Strength_Start: ; 48b3 +.Strength_Start ld hl, OBJECT_NEXT_TILE add hl, bc ld a, [hl] call CheckPitTile jr z, .on_pit - ld hl, OBJECT_FLAGS2 add hl, bc bit 2, [hl] res 2, [hl] jr z, .ok - ld hl, OBJECT_RANGE add hl, bc ld a, [hl] @@ -1109,7 +682,6 @@ MapObjectMovementPattern: ; 47dd call InitStep call Function6ec1 jr c, .ok2 - ld de, SFX_STRENGTH call PlaySFX call SpawnStrengthBoulderDust @@ -1121,7 +693,6 @@ MapObjectMovementPattern: ; 47dd .ok2 call Function462a - .ok ld hl, OBJECT_DIRECTION_WALKING add hl, bc @@ -1130,27 +701,22 @@ MapObjectMovementPattern: ; 47dd .on_pit call IncrementObjectMovementByteIndex - -.Strength_Stop: ; 48f8 +.Strength_Stop ld hl, OBJECT_DIRECTION_WALKING add hl, bc ld [hl], STANDING ret -; 48ff -.FollowNotExact: ; 48ff +.FollowNotExact ld hl, OBJECT_NEXT_MAP_X add hl, bc ld d, [hl] - ld hl, OBJECT_NEXT_MAP_Y add hl, bc ld e, [hl] - ld hl, OBJECT_RANGE add hl, bc ld a, [hl] - push bc call GetObjectStruct ld hl, OBJECT_DIRECTION_WALKING @@ -1158,7 +724,6 @@ MapObjectMovementPattern: ; 47dd ld a, [hl] cp STANDING jr z, .standing - ld hl, OBJECT_MAP_X add hl, bc ld a, [hl] @@ -1184,7 +749,6 @@ MapObjectMovementPattern: ; 47dd .less2 ld a, 1 - .done ld d, a ld hl, OBJECT_DIRECTION_WALKING @@ -1204,9 +768,8 @@ MapObjectMovementPattern: ; 47dd add hl, bc ld [hl], PERSON_ACTION_STAND ret -; 4958 -.MovementBigStanding: ; 4958 +.MovementBigStanding call EndSpriteMovement ld hl, OBJECT_DIRECTION_WALKING add hl, bc @@ -1218,9 +781,8 @@ MapObjectMovementPattern: ; 47dd add hl, bc ld [hl], STEP_TYPE_04 ret -; 496e -.MovementBouncing: ; 496e +.MovementBouncing call EndSpriteMovement ld hl, OBJECT_DIRECTION_WALKING add hl, bc @@ -1232,26 +794,23 @@ MapObjectMovementPattern: ; 47dd add hl, bc ld [hl], STEP_TYPE_04 ret -; 4984 -.MovementSpinCounterclockwise: ; 4984 +.MovementSpinCounterclockwise call MovementAnonymousJumptable dw .MovementSpinInit dw .MovementSpinRepeat dw .MovementSpinTurnLeft -; 498d -.MovementSpinClockwise: ; 498d +.MovementSpinClockwise call MovementAnonymousJumptable dw .MovementSpinInit dw .MovementSpinRepeat dw .MovementSpinTurnRight -; 4996 -.MovementSpinInit: ; 4996 +.MovementSpinInit call EndSpriteMovement call IncrementObjectMovementByteIndex -.MovementSpinRepeat: ; 499c +.MovementSpinRepeat ld hl, OBJECT_ACTION add hl, bc ld [hl], PERSON_ACTION_STAND @@ -1267,29 +826,24 @@ MapObjectMovementPattern: ; 47dd ld [hl], STEP_TYPE_03 call IncrementObjectMovementByteIndex ret -; 49b8 -.MovementSpinTurnLeft: ; 49b8 +.MovementSpinTurnLeft ld de, .DirectionData_Counterclockwise call .MovementSpinNextFacing jr .MovementSpinCounterclockwise -; 49c0 .DirectionData_Counterclockwise ; 49c0 db OW_RIGHT, OW_LEFT, OW_DOWN, OW_UP -; 49c4 -.MovementSpinTurnRight: ; 49c4 +.MovementSpinTurnRight ld de, .DirectionData_Clockwise call .MovementSpinNextFacing jr .MovementSpinClockwise -; 49cc .DirectionData_Clockwise ; 49cc db OW_LEFT, OW_RIGHT, OW_UP, OW_DOWN -; 49d0 -.MovementSpinNextFacing: ; 49d0 +.MovementSpinNextFacing ld hl, OBJECT_FACING add hl, bc ld a, [hl] @@ -1305,9 +859,8 @@ MapObjectMovementPattern: ; 47dd ld [hl], a call DecrementObjectMovementByteIndex ret -; 49e5 -.MovementShadow: ; 49e5 +.MovementShadow call ._MovementShadow_Grass_Emote_BoulderDust ld hl, OBJECT_ACTION add hl, bc @@ -1331,7 +884,6 @@ MapObjectMovementPattern: ; 47dd cp UP jr z, .ok_13 ld d, 1 * 8 + 4 - .ok_13 ld hl, OBJECT_SPRITE_Y_OFFSET add hl, bc @@ -1343,9 +895,8 @@ MapObjectMovementPattern: ; 47dd add hl, bc ld [hl], STEP_TYPE_TRACKING_OBJECT ret -; 4a21 -.MovementEmote: ; 4a21 +.MovementEmote call EndSpriteMovement call ._MovementShadow_Grass_Emote_BoulderDust ld hl, OBJECT_ACTION @@ -1364,9 +915,8 @@ MapObjectMovementPattern: ; 47dd add hl, bc ld [hl], STEP_TYPE_TRACKING_OBJECT ret -; 4a46 -.MovementBoulderDust: ; 4a46 +.MovementBoulderDust call EndSpriteMovement call ._MovementShadow_Grass_Emote_BoulderDust ld hl, OBJECT_ACTION @@ -1387,8 +937,8 @@ MapObjectMovementPattern: ; 47dd ld e, a ld d, 0 ld hl, .data_4a81 - add hl,de - add hl,de + add hl, de + add hl, de ld d, [hl] inc hl ld e, [hl] @@ -1402,7 +952,6 @@ MapObjectMovementPattern: ; 47dd add hl, bc ld [hl], STEP_TYPE_TRACKING_OBJECT ret -; 4a81 .data_4a81 ; 4a81 ; x, y @@ -1410,9 +959,8 @@ MapObjectMovementPattern: ; 47dd db 0, 8 db 6, 2 db -6, 2 -; 4a89 -.MovementShakingGrass: ; 4a89 +.MovementShakingGrass call EndSpriteMovement call ._MovementShadow_Grass_Emote_BoulderDust ld hl, OBJECT_ACTION @@ -1429,9 +977,8 @@ MapObjectMovementPattern: ; 47dd add hl, bc ld [hl], STEP_TYPE_TRACKING_OBJECT ret -; 4aa8 -._MovementShadow_Grass_Emote_BoulderDust: ; 4aa8 +._MovementShadow_Grass_Emote_BoulderDust ld hl, OBJECT_RANGE add hl, bc ld a, [hl] @@ -1446,9 +993,8 @@ MapObjectMovementPattern: ; 47dd inc hl ld [hl], d ret -; 4abc -.MovementScreenShake: ; 4abc +.MovementScreenShake call EndSpriteMovement ld hl, OBJECT_ACTION add hl, bc @@ -1467,9 +1013,8 @@ MapObjectMovementPattern: ; 47dd add hl, bc ld [hl], STEP_TYPE_15 ret -; 4ade -._MovementScreenShake: ; 4ade +._MovementScreenShake ld d, a and %00111111 ld e, a @@ -1485,23 +1030,19 @@ MapObjectMovementPattern: ; 47dd ret z add a jr .loop -; 4af0 -.RandomWalkContinue: ; 4af0 +.RandomWalkContinue call InitStep call Function6ec1 ; check whether the object can move in that direction jr c, .NewDuration - call UpdateTallGrassFlags ld hl, OBJECT_ACTION add hl, bc ld [hl], PERSON_ACTION_STEP - ld hl, wCenteredObject ld a, [hMapObjectIndexBuffer] cp [hl] jr z, .load_6 - ld hl, OBJECT_STEP_TYPE add hl, bc ld [hl], STEP_TYPE_07 @@ -1513,7 +1054,7 @@ MapObjectMovementPattern: ; 47dd ld [hl], STEP_TYPE_PLAYER_WALK ret -.NewDuration: ; 4b17 +.NewDuration call EndSpriteMovement call Function462a RandomStepDuration_Slow: ; 4b1d @@ -1545,36 +1086,35 @@ SetRandomStepDuration: ; 4b2d Pointers4b45: ; 4b45 ; These pointers use OBJECT_STEP_TYPE. See constants/sprite_constants.asm - dw ObjectMovementReset ; 00 - dw MapObjectMovementPattern ; 01 + dw MapObjectMovementPattern ; unused dw NPCStep ; 02 npc walk - dw Function4ddd ; 03 - dw Function4e21 ; 04 - dw Function4e0c ; 05 + dw StepType03 ; 03 + dw StepType04 ; 04 + dw StepType05 ; 05 dw PlayerStep ; 06 player walk - dw Function4e47 ; 07 + dw StepType07 ; 07 dw NPCJump ; 08 npc jump step dw PlayerJump ; 09 player jump step - dw PlayerOrNPCHalfStep ; 0a half step - dw Function4dff ; 0b + dw PlayerOrNPCTurnStep ; 0a half step + dw StepTypeBump ; 0b dw TeleportFrom ; 0c teleport from dw TeleportTo ; 0d teleport to dw Skyfall ; 0e skyfall - dw Function4ecd ; 0f + dw StepType0f ; 0f dw GotBiteStep ; 10 dw RockSmashStep ; 11 dw ReturnDigStep ; 12 - dw Function4f04 ; 13 - dw Function4f33 ; 14 - dw Function4f33 ; 15 - dw Function4f77 ; 16 - dw Function4f7a ; 17 - dw Function4df0 ; 18 + dw StepTypeTrackingObject ; 13 + dw StepType14 ; 14 + dw StepType15 ; 15 + dw StepType16 ; 16 + dw StepType17 ; 17 + dw StepType18 ; 18 dw SkyfallTop ; 19 ; 4b79 -Function4b79: ; 4b79 +WaitStep_InPlace: ; 4b79 ld hl, OBJECT_STEP_DURATION add hl, bc dec [hl] @@ -1588,11 +1128,10 @@ Function4b79: ; 4b79 NPCJump: ; 4b86 call Object28AnonymousJumptable ; anonymous dw - dw Function4b8d - dw Function4ba9 -; 4b8d + dw .Jump + dw .Land -Function4b8d: ; 4b8d +.Jump call AddStepVector call UpdateJumpPosition ld hl, OBJECT_STEP_DURATION @@ -1606,9 +1145,8 @@ Function4b8d: ; 4b8d res 3, [hl] call IncrementObjectStructField28 ret -; 4ba9 -Function4ba9: ; 4ba9 +.Land call AddStepVector call UpdateJumpPosition ld hl, OBJECT_STEP_DURATION @@ -1629,13 +1167,12 @@ PlayerJump: ; 4bbf dw .stepjump dw .initland dw .stepland -; 4bca -.initjump: ; 4bca +.initjump ld hl, wPlayerStepFlags set 7, [hl] call IncrementObjectStructField28 -.stepjump: ; 4bd2 +.stepjump call UpdateJumpPosition call UpdatePlayerStep ld hl, OBJECT_STEP_DURATION @@ -1651,14 +1188,13 @@ PlayerJump: ; 4bbf set 4, [hl] call IncrementObjectStructField28 ret -; 4bf2 -.initland: ; 4bf2 +.initland call GetNextTile ld hl, wPlayerStepFlags set 7, [hl] call IncrementObjectStructField28 -.stepland: ; 4bfd +.stepland call UpdateJumpPosition call UpdatePlayerStep ld hl, OBJECT_STEP_DURATION @@ -1677,21 +1213,21 @@ PlayerJump: ; 4bbf TeleportFrom: ; 4c18 call Object28AnonymousJumptable ; anonymous dw - dw Function4c23 - dw Function4c32 - dw Function4c42 - dw Function4c5d + dw .InitSpin + dw .DoSpin + dw .InitSpinRise + dw .DoSpinRise ; 4c23 -Function4c23: ; 4c23 +.InitSpin ld hl, OBJECT_STEP_FRAME add hl, bc ld [hl], 0 ld hl, OBJECT_STEP_DURATION add hl, bc - ld [hl], $10 + ld [hl], 16 call IncrementObjectStructField28 -Function4c32: ; 4c32 +.DoSpin ld hl, OBJECT_ACTION add hl, bc ld [hl], PERSON_ACTION_SPIN @@ -1701,9 +1237,8 @@ Function4c32: ; 4c32 ret nz call IncrementObjectStructField28 ret -; 4c42 -Function4c42: ; 4c42 +.InitSpinRise ld hl, OBJECT_STEP_FRAME add hl, bc ld [hl], 0 @@ -1712,12 +1247,12 @@ Function4c42: ; 4c42 ld [hl], $10 ld hl, OBJECT_STEP_DURATION add hl, bc - ld [hl], $10 + ld [hl], 16 ld hl, OBJECT_FLAGS2 add hl, bc res 3, [hl] call IncrementObjectStructField28 -Function4c5d: ; 4c5d +.DoSpinRise ld hl, OBJECT_ACTION add hl, bc ld [hl], PERSON_ACTION_SPIN @@ -1748,33 +1283,33 @@ Function4c5d: ; 4c5d TeleportTo: ; 4c89 call Object28AnonymousJumptable ; anonymous dw - dw Function4c9a - dw Function4caa - dw Function4cb3 - dw Function4cc9 - dw Function4ceb - dw Function4cf5 - dw Function4d01 + dw .InitWait + dw .DoWait + dw .InitDescent + dw .DoDescent + dw .InitFinalSpin + dw .DoFinalSpin + dw .FinishStep ; 4c9a -Function4c9a: ; 4c9a +.InitWait ld hl, OBJECT_ACTION add hl, bc ld [hl], PERSON_ACTION_00 ld hl, OBJECT_STEP_DURATION add hl, bc - ld [hl], $10 + ld [hl], 16 call IncrementObjectStructField28 ret ; 4caa -Function4caa: ; 4caa +.DoWait ld hl, OBJECT_STEP_DURATION add hl, bc dec [hl] ret nz call IncrementObjectStructField28 -Function4cb3: ; 4cb3 +.InitDescent ld hl, OBJECT_STEP_FRAME add hl, bc ld [hl], 0 @@ -1783,12 +1318,12 @@ Function4cb3: ; 4cb3 ld [hl], 0 ld hl, OBJECT_STEP_DURATION add hl, bc - ld [hl], $10 + ld [hl], 16 call IncrementObjectStructField28 ret ; 4cc9 -Function4cc9: ; 4cc9 +.DoDescent ld hl, OBJECT_ACTION add hl, bc ld [hl], PERSON_ACTION_SPIN @@ -1808,15 +1343,15 @@ Function4cc9: ; 4cc9 dec [hl] ret nz call IncrementObjectStructField28 -Function4ceb: ; 4ceb +.InitFinalSpin ld hl, OBJECT_STEP_DURATION add hl, bc - ld [hl], $10 + ld [hl], 16 call IncrementObjectStructField28 ret ; 4cf5 -Function4cf5: ; 4cf5 +.DoFinalSpin ld hl, OBJECT_ACTION add hl, bc ld [hl], PERSON_ACTION_SPIN @@ -1824,7 +1359,7 @@ Function4cf5: ; 4cf5 add hl, bc dec [hl] ret nz -Function4d01: ; 4d01 +.FinishStep ld hl, OBJECT_STEP_FRAME add hl, bc ld [hl], 0 @@ -1840,21 +1375,21 @@ Function4d01: ; 4d01 Skyfall: ; 4d14 call Object28AnonymousJumptable ; anonymous dw - dw Function4d1f - dw Function4d2e - dw Function4d4f - dw Function4d6b + dw .Init + dw .Step + dw .Fall + dw .Finish ; 4d1f -Function4d1f: ; 4d1f +.Init ld hl, OBJECT_ACTION add hl, bc ld [hl], PERSON_ACTION_00 ld hl, OBJECT_STEP_DURATION add hl, bc - ld [hl], $10 + ld [hl], 16 call IncrementObjectStructField28 -Function4d2e: ; 4d2e +.Step ld hl, OBJECT_STEP_DURATION add hl, bc dec [hl] @@ -1870,9 +1405,9 @@ Function4d2e: ; 4d2e ld [hl], 0 ld hl, OBJECT_STEP_DURATION add hl, bc - ld [hl], $10 + ld [hl], 16 call IncrementObjectStructField28 -Function4d4f: ; 4d4f +.Fall ld hl, OBJECT_31 add hl, bc inc [hl] @@ -1889,7 +1424,7 @@ Function4d4f: ; 4d4f dec [hl] ret nz call IncrementObjectStructField28 -Function4d6b: ; 4d6b +.Finish ld hl, OBJECT_STEP_FRAME add hl, bc ld [hl], 0 @@ -1905,11 +1440,11 @@ Function4d6b: ; 4d6b GotBiteStep: ; 4d7e call Object28AnonymousJumptable ; anonymous dw - dw Function4d85 - dw Function4d94 + dw .Init + dw .Run ; 4d85 -Function4d85: ; 4d85 +.Init ld hl, OBJECT_STEP_DURATION add hl, bc ld [hl], 8 @@ -1917,7 +1452,7 @@ Function4d85: ; 4d85 add hl, bc ld [hl], 0 call IncrementObjectStructField28 -Function4d94: ; 4d94 +.Run ld hl, OBJECT_SPRITE_Y_OFFSET add hl, bc ld a, [hl] @@ -1937,11 +1472,11 @@ Function4d94: ; 4d94 ; 4daf RockSmashStep: ; 4daf - call Function4db5 - jp Function4b79 + call .Step + jp WaitStep_InPlace ; 4db5 -Function4db5: ; 4db5 +.Step ld hl, OBJECT_STEP_DURATION add hl, bc ld a, [hl] @@ -1949,7 +1484,6 @@ Function4db5: ; 4db5 ld a, PERSON_ACTION_STAND jr z, .yes ld a, PERSON_ACTION_00 - .yes ld hl, OBJECT_ACTION add hl, bc @@ -1965,15 +1499,14 @@ ReturnDigStep: ; 4dc8 ld a, PERSON_ACTION_SPIN jr z, .yes ld a, PERSON_ACTION_SPIN_FLICKER - .yes ld hl, OBJECT_ACTION add hl, bc ld [hl], a - jp Function4b79 + jp WaitStep_InPlace ; 4ddd -Function4ddd: ; 4ddd +StepType03: ; 4ddd ld hl, OBJECT_DIRECTION_WALKING add hl, bc ld [hl], STANDING @@ -1987,7 +1520,7 @@ Function4ddd: ; 4ddd ret ; 4df0 -Function4df0: ; 4df0 +StepType18: ; 4df0 ld hl, OBJECT_DIRECTION_WALKING add hl, bc ld [hl], STANDING @@ -1998,7 +1531,7 @@ Function4df0: ; 4df0 jp DeleteMapObject ; 4dff -Function4dff: ; 4dff +StepTypeBump: ; 4dff ld hl, OBJECT_STEP_DURATION add hl, bc dec [hl] @@ -2009,21 +1542,20 @@ Function4dff: ; 4dff ret ; 4e0c -Function4e0c: ; 4e0c +StepType05: ; 4e0c call Object28AnonymousJumptable ; anonymous dw - dw Function4e13 - dw Function4e21 -; 4e13 + dw .Reset + dw StepType04 -Function4e13: ; 4e13 +.Reset call RestoreDefaultMovement call GetInitialFacing ld hl, OBJECT_FACING add hl, bc ld [hl], a call IncrementObjectStructField28 -Function4e21: ; 4e21 +StepType04: ; 4e21 call MobileFn_4fb2 ld hl, OBJECT_DIRECTION_WALKING add hl, bc @@ -2048,7 +1580,7 @@ NPCStep: ; 4e2b ret ; 4e47 -Function4e47: ; 4e47 +StepType07: ; 4e47 call AddStepVector ld hl, OBJECT_STEP_DURATION add hl, bc @@ -2064,19 +1596,17 @@ PlayerStep: ; 4e56 ; anonymous dw dw .init dw .step -; 4e5d -.init: ; 4e5d +.init ld hl, wPlayerStepFlags set 7, [hl] call IncrementObjectStructField28 -.step: ; 4e65 +.step call UpdatePlayerStep ld hl, OBJECT_STEP_DURATION add hl, bc dec [hl] ret nz - ld hl, wPlayerStepFlags set 6, [hl] call CopyNextCoordsTileToStandingCoordsTile @@ -2089,16 +1619,15 @@ PlayerStep: ; 4e56 ret ; 4e83 -PlayerOrNPCHalfStep: ; 4e83 +PlayerOrNPCTurnStep: ; 4e83 call Object28AnonymousJumptable ; anonymous dw dw .init1 dw .step1 dw .init2 dw .step2 -; 4e8e -.init1: ; 4e8e +.init1 ld hl, OBJECT_DIRECTION_WALKING add hl, bc ld [hl], STANDING @@ -2110,13 +1639,13 @@ PlayerOrNPCHalfStep: ; 4e83 add hl, bc ld [hl], 2 call IncrementObjectStructField28 -.step1: ; 4ea4 +.step1 ld hl, OBJECT_STEP_DURATION add hl, bc dec [hl] ret nz call IncrementObjectStructField28 -.init2: ; 4ead +.init2 ld hl, OBJECT_29 ; new facing add hl, bc ld a, [hl] @@ -2127,7 +1656,7 @@ PlayerOrNPCHalfStep: ; 4e83 add hl, bc ld [hl], 2 call IncrementObjectStructField28 -.step2: ; 4ec0 +.step2 ld hl, OBJECT_STEP_DURATION add hl, bc dec [hl] @@ -2138,7 +1667,7 @@ PlayerOrNPCHalfStep: ; 4e83 ret ; 4ecd -Function4ecd: ; 4ecd +StepType0f: ; 4ecd call AddStepVector ld hl, OBJECT_STEP_DURATION add hl, bc @@ -2170,7 +1699,7 @@ Function4ecd: ; 4ecd ret ; 4f04 -Function4f04: ; 4f04 +StepTypeTrackingObject: ; 4f04 ld hl, OBJECT_29 add hl, bc ld e, [hl] @@ -2200,25 +1729,24 @@ Function4f04: ; 4f04 ret z dec [hl] ret nz - .nope jp DeleteMapObject ; 4f33 -Function4f33: ; 4f33 +StepType14: ; 4f33 +StepType15: ; 4f33 call Object28AnonymousJumptable ; anonymous dw - dw Function4f3a - dw Function4f43 -; 4f3a + dw .Init + dw .Run -Function4f3a: ; 4f3a +.Init xor a ld hl, OBJECT_29 add hl, bc ld [hl], a call IncrementObjectStructField28 -Function4f43: ; 4f43 +.Run ld hl, OBJECT_29 add hl, bc ld d, [hl] @@ -2230,7 +1758,7 @@ Function4f43: ; 4f43 dec [hl] jr z, .ok ld a, [hl] - call Function4f6c + call .GetSign ld hl, OBJECT_29 add hl, bc ld [hl], a @@ -2243,9 +1771,8 @@ Function4f43: ; 4f43 .ok call DeleteMapObject ret -; 4f6c -Function4f6c: ; 4f6c +.GetSign ld hl, OBJECT_30 add hl, bc and 1 @@ -2256,26 +1783,25 @@ Function4f6c: ; 4f6c ret ; 4f77 -Function4f77: ; 4f77 +StepType16: ; 4f77 call Object28AnonymousJumptable ; ???? ; 4f7a - -Function4f7a: ; 4f7a +StepType17: ; 4f7a call Object28AnonymousJumptable ; anonymous dw - dw SkyfallTop - dw SkyfallTop - dw SkyfallTop + dw .null + dw .null + dw .null +.null ; 4f83 SkyfallTop: ; 4f83 call Object28AnonymousJumptable ; anonymous dw - dw Function4f8a - dw Function4f99 -; 4f8a + dw .Init + dw .Run -Function4f8a: ; 4f8a +.Init ld hl, OBJECT_ACTION add hl, bc ld [hl], PERSON_ACTION_10 @@ -2283,9 +1809,8 @@ Function4f8a: ; 4f8a add hl, bc ld [hl], 16 call IncrementObjectStructField28 -; 4f99 -Function4f99: ; 4f99 +.Run: ld hl, OBJECT_STEP_DURATION add hl, bc dec [hl] @@ -2319,12 +1844,10 @@ MobileFn_4fb2: mobile add hl, bc ld [hl], a ret -; 4fcd .y ; 4fcd db 0, -1, -2, -3, -4, -3, -2, -1 ; 4fd5 - UpdateJumpPosition: ; 4fd5 call GetStepVector ld a, h @@ -2343,29 +1866,27 @@ UpdateJumpPosition: ; 4fd5 add hl, bc ld [hl], a ret -; 4ff0 .y ; 4ff0 db -4, -6, -8, -10, -11, -12, -12, -12 db -11, -10, -9, -8, -6, -4, 0, 0 ; 5000 - Function5000: ; unscripted? -; copy [wc2de] to [wc2df] - ld a, [wc2de] - ld hl, wc2df +; copy [wPlayerNextMovement] to [wPlayerMovement] + ld a, [wPlayerNextMovement] + ld hl, wPlayerMovement ld [hl], a -; load [wc2de] with movement_step_sleep_1 +; load [wPlayerNextMovement] with movement_step_sleep_1 ld a, movement_step_sleep_1 - ld [wc2de], a -; recover the previous value of [wc2de] + ld [wPlayerNextMovement], a +; recover the previous value of [wPlayerNextMovement] ld a, [hl] ret ; 500e -Function500e: ; scripted +GetMovementByte: ld hl, wMovementDataPointer - call Function1aae + call _GetMovementByte ret ; 5015 @@ -2375,7 +1896,7 @@ Function5015: ; 5015 ld e, [hl] inc [hl] ld d, 0 - ld hl, wMovementPerson + ld hl, wc2e2 ld a, [hli] ld h, [hl] ld l, a @@ -2399,7 +1920,7 @@ Function5026: ; 5026 ret ; 5037 -Function5037: ; 5037 +_GetMovementPerson: ; 5037 ld hl, GetMovementPerson jp HandleMovementData ; 503d @@ -2410,19 +1931,18 @@ GetMovementPerson: ; 503d ; 5041 HandleMovementData: ; 5041 - call CopyMovementPointer + call .StorePointer .loop xor a - ld [wc2ea], a - call GetMovementByte + ld [wMovementByteWasControlSwitch], a + call JumpMovementPointer call DoMovementFunction - ld a, [wc2ea] + ld a, [wMovementByteWasControlSwitch] and a jr nz, .loop ret -; 5055 -CopyMovementPointer: ; 5055 +.StorePointer ld a, l ld [wMovementPointer], a ld a, h @@ -2430,7 +1950,7 @@ CopyMovementPointer: ; 5055 ret ; 505e -GetMovementByte: ; 505e +JumpMovementPointer: ; 505e ld hl, wMovementPointer ld a, [hli] ld h, [hl] @@ -2440,7 +1960,7 @@ GetMovementByte: ; 505e ContinueReadingMovement: ; 5065 ld a, 1 - ld [wc2ea], a + ld [wMovementByteWasControlSwitch], a ret ; 506b @@ -2453,12 +1973,9 @@ DoMovementFunction: ; 506b ret ; 5075 - -; 5075 INCLUDE "engine/movement.asm" ; 54b8 - ApplyMovementToFollower: ; 54b8 ld e, a ld a, [wObjectFollow_Follower] @@ -2470,30 +1987,30 @@ ApplyMovementToFollower: ; 54b8 cp d ret nz ld a, e - cp $3e + cp movement_step_sleep_1 ret z - cp $47 + cp movement_step_end ret z - cp $4b + cp movement_step_4b ret z - cp $50 + cp movement_step_bump ret z - cp $8 + cp movement_turn_step_right + 1 ret c push af - ld hl, wd4d0 + ld hl, wFollowerMovementQueueLength inc [hl] ld e, [hl] ld d, 0 - ld hl, wd4d1 + ld hl, wFollowMovementQueue add hl, de pop af ld [hl], a ret ; 54e6 -Function54e6: ; 54e6 - ld hl, wd4d0 +GetFollowerNextMovementByte: ; 54e6 + ld hl, wFollowerMovementQueueLength ld a, [hl] and a jr z, .done @@ -2502,7 +2019,7 @@ Function54e6: ; 54e6 dec [hl] ld e, a ld d, 0 - ld hl, wd4d1 + ld hl, wFollowMovementQueue add hl, de inc e ld a, -1 @@ -2515,14 +2032,12 @@ Function54e6: ; 54e6 ret .done - call Function550a + call .CancelFollowIfLeaderMissing ret c - ld a, movement_step_sleep_1 ret -; 550a -Function550a: ; 550a +.CancelFollowIfLeaderMissing ld a, [wObjectFollow_Leader] cp -1 jr z, .nope @@ -2538,7 +2053,7 @@ Function550a: ; 550a ret .nope - ld a, $ff + ld a, -1 ld [wObjectFollow_Follower], a ld a, movement_step_end scf @@ -2557,7 +2072,6 @@ SpawnShadow: ; 5529 ; vtile, palette, movement db $00, PAL_OW_SILVER, SPRITEMOVEDATA_SHADOW ; 5538 - SpawnStrengthBoulderDust: ; 5538 push bc ld de, .BoulderDustObject @@ -2569,7 +2083,6 @@ SpawnStrengthBoulderDust: ; 5538 .BoulderDustObject db $00, PAL_OW_SILVER, SPRITEMOVEDATA_BOULDERDUST ; 5547 - SpawnEmote: ; 5547 push bc ld de, .EmoteObject @@ -2581,7 +2094,6 @@ SpawnEmote: ; 5547 .EmoteObject db $00, PAL_OW_SILVER, SPRITEMOVEDATA_EMOTE ; 5556 - ShakeGrass: ; 5556 push bc ld de, .data_5562 @@ -2593,7 +2105,6 @@ ShakeGrass: ; 5556 .data_5562 db $00, PAL_OW_TREE, SPRITEMOVEDATA_GRASS ; 5565 - ShakeScreen: ; 5565 push bc push af @@ -2608,7 +2119,6 @@ ShakeScreen: ; 5565 .ScreenShakeObject db $00, PAL_OW_SILVER, SPRITEMOVEDATA_SCREENSHAKE ; 5579 - DespawnEmote: ; 5579 push bc ld a, [hMapObjectIndexBuffer] @@ -2616,9 +2126,8 @@ DespawnEmote: ; 5579 call .DeleteEmote pop bc ret -; 5582 -.DeleteEmote: ; 5582 +.DeleteEmote ld de, ObjectStructs ld a, NUM_OBJECT_STRUCTS .loop @@ -2637,7 +2146,6 @@ DespawnEmote: ; 5579 ld bc, OBJECT_STRUCT_LENGTH call ByteFill pop bc - .next ld hl, OBJECT_STRUCT_LENGTH add hl, de @@ -2652,7 +2160,6 @@ DespawnEmote: ; 5579 InitTempObject: ; 55ac call FindFirstEmptyObjectStruct ret nc - ld d, h ld e, l callba CopyTempObjectToObjectStruct @@ -2668,7 +2175,6 @@ CopyTempObjectData: ; 55b9 inc hl ld [hl], -1 inc hl - ld a, [de] inc de ld [hli], a @@ -2677,10 +2183,8 @@ CopyTempObjectData: ; 55b9 ld [hli], a ld a, [de] ld [hli], a - ld a, [hMapObjectIndexBuffer] ld [hli], a - push hl ld hl, OBJECT_NEXT_MAP_X add hl, bc @@ -2689,7 +2193,6 @@ CopyTempObjectData: ; 55b9 add hl, bc ld e, [hl] pop hl - ld [hl], d inc hl ld [hl], e @@ -2702,7 +2205,6 @@ Function55e0:: ; 55e0 ld a, [VramState] bit 0, a ret z - ld bc, ObjectStructs xor a .loop @@ -2710,7 +2212,6 @@ Function55e0:: ; 55e0 call GetObjectSprite jr z, .ok call Function565c - .ok ld hl, OBJECT_STRUCT_LENGTH add hl, bc @@ -2727,16 +2228,13 @@ Function5602: ; 5602, called at battle start call Function5645 ; clear sprites ld a, PLAYER call Function5629 ; respawn player - ld a, [wBattleScriptFlags] bit 7, a jr z, .ok - ld a, [hLastTalked] and a jr z, .ok call Function5629 ; respawn opponent - .ok call _UpdateSprites ret @@ -2753,21 +2251,17 @@ Function561d: ; 561d Function5629: ; 5629 cp NUM_OBJECTS ret nc - call GetMapObject ld hl, MAPOBJECT_OBJECT_STRUCT_ID add hl, bc ld a, [hl] cp -1 ret z - cp NUM_OBJECT_STRUCTS ret nc - call GetObjectStruct call GetObjectSprite ret z - call Function5673 ret ; 5645 @@ -2851,7 +2345,6 @@ Function56a3: ; 56a3 add $b cp d jr c, .nope - .equal_x ld a, [YCoord] cp e @@ -2860,7 +2353,6 @@ Function56a3: ; 56a3 add $a cp e jr c, .nope - .equal_y xor a ret @@ -2884,14 +2376,12 @@ Function56cd: ; 56cd jr nc, .ok1 cp $a0 jp nc, .nope - .ok1 and %00000111 ld d, 2 cp 4 jr c, .ok2 ld d, 3 - .ok2 ld a, [hl] srl a @@ -2900,7 +2390,6 @@ Function56cd: ; 56cd cp SCREEN_WIDTH jr c, .ok3 sub $20 - .ok3 ld [hUsedSpriteIndex], a ld a, [wFollowNotExactPersonY] @@ -2916,14 +2405,12 @@ Function56cd: ; 56cd jr nc, .ok4 cp $90 jr nc, .nope - .ok4 and %00000111 ld e, 2 cp 4 jr c, .ok5 ld e, 3 - .ok5 ld a, [hl] srl a @@ -2932,7 +2419,6 @@ Function56cd: ; 56cd cp $12 jr c, .ok6 sub $20 - .ok6 ld [hUsedSpriteTile], a ld hl, OBJECT_PALETTE @@ -2945,7 +2431,6 @@ Function56cd: ; 56cd ld a, e add 2 ld e, a - .ok7 ld a, d ld [hFFBF], a @@ -2971,11 +2456,9 @@ Function56cd: ; 56cd ld a, [hl] cp $60 jr nc, .nope - .ok8 dec d jr nz, .next - .ok9 dec e jr nz, .loop @@ -2991,9 +2474,8 @@ Function576a:: ; 576a call .ResetStepVector call Function5781 ret -; 5771 -.ResetStepVector: ; 5771 +.ResetStepVector xor a ld [wPlayerStepVectorX], a ld [wPlayerStepVectorY], a @@ -3011,7 +2493,6 @@ Function5781: ; 5781 call GetObjectSprite jr z, .next call Function437b - .next ld hl, OBJECT_STRUCT_LENGTH add hl, bc @@ -3026,8 +2507,8 @@ Function5781: ; 5781 Function579d: ; 579d ld a, $3e - ld [wc2de], a - ld [wc2df], a + ld [wPlayerNextMovement], a + ld [wPlayerMovement], a xor a ld [wd04e], a ld [PlayerObjectStepFrame], a @@ -3073,14 +2554,12 @@ SetPlayerPalette: ; 57e2 ld a, d and %10000000 ret z - ld bc, 0 ; debug? ld hl, OBJECT_FACING add hl, bc ld a, [hl] or d ld [hl], a - ld a, d swap a and %00000111 @@ -3103,7 +2582,7 @@ StartFollow:: ; 5803 ret c ld a, c call SetFollowerIfVisible - callba Function848a + callba QueueFollowerFirstStep ret ; 5815 @@ -3189,7 +2668,6 @@ Function587a: ; 587a ld hl, OBJECT_FLAGS2 add hl, bc set 5, [hl] - .next ld hl, OBJECT_STRUCT_LENGTH add hl, bc @@ -3235,7 +2713,6 @@ Function58b9:: ; 58b9 ld hl, OBJECT_FLAGS2 add hl, bc res 5, [hl] - .next ld hl, OBJECT_STRUCT_LENGTH add hl, bc @@ -3264,18 +2741,15 @@ Function58e3: ; 58e3 ld a, [hl] cp -1 jp z, Function5903 ; a jr would have been appropriate here - push bc call GetMapObject ld hl, MAPOBJECT_MOVEMENT add hl, bc ld a, [hl] pop bc - ld hl, OBJECT_MOVEMENTTYPE add hl, bc ld [hl], a - ld hl, OBJECT_STEP_TYPE add hl, bc ld [hl], STEP_TYPE_00 @@ -3294,7 +2768,6 @@ Function5903: ; 5903 ld hl, OBJECT_MOVEMENTTYPE add hl, bc ld [hl], a - ld hl, OBJECT_STEP_TYPE add hl, bc ld [hl], STEP_TYPE_00 @@ -3306,7 +2779,6 @@ Function5903: ; 5903 db SPRITEMOVEDATA_STANDING_LEFT db SPRITEMOVEDATA_STANDING_RIGHT ; 5920 - _UpdateSprites:: ; 5920 ld a, [VramState] bit 0, a @@ -3322,15 +2794,13 @@ _UpdateSprites:: ; 5920 pop af ld [hOAMUpdate], a ret -; 593a -.fill: ; 593a +.fill ld a, [VramState] bit 1, a ld b, SpritesEnd % $100 jr z, .ok ld b, 28 * 4 - .ok ld a, [hUsedSpriteIndex] cp b @@ -3358,24 +2828,20 @@ Function5958: ; 5958 ld e, a ld bc, ObjectStructs ld a, NUM_OBJECT_STRUCTS - .loop push af call GetObjectSprite jr z, .skip - ld hl, OBJECT_SPRITE_X add hl, bc ld a, [hl] add d ld [hl], a - ld hl, OBJECT_SPRITE_Y add hl, bc ld a, [hl] add e ld [hl], a - .skip ld hl, OBJECT_STRUCT_LENGTH add hl, bc @@ -3384,7 +2850,6 @@ Function5958: ; 5958 pop af dec a jr nz, .loop - xor a ld [wFollowNotExactPersonX], a ld [wFollowNotExactPersonY], a @@ -3406,28 +2871,24 @@ PRIORITY_HIGH EQU $30 ld c, PRIORITY_LOW call .InitSpritesByPriority ret -; 59a4 -.DeterminePriorities: ; 59a4 +.DeterminePriorities xor a - ld hl, wc2eb + ld hl, wMovementPointer ld bc, NUM_OBJECT_STRUCTS call ByteFill - ld d, 0 ld bc, ObjectStructs - ld hl, wc2eb + ld hl, wMovementPointer .loop push hl call GetObjectSprite jr z, .skip - ld hl, OBJECT_FACING_STEP add hl, bc ld a, [hl] cp STANDING jr z, .skip - ; Define the sprite priority. ld e, PRIORITY_LOW ld hl, OBJECT_FLAGS2 @@ -3457,16 +2918,14 @@ PRIORITY_HIGH EQU $30 ld a, d or e ld [hli], a - .next inc d ld a, d cp NUM_OBJECT_STRUCTS jr nz, .loop ret -; 59f3 -.InitSpritesByPriority: ; 59f3 +.InitSpritesByPriority ld hl, wMovementPointer .next_sprite ld a, [hli] @@ -3475,7 +2934,6 @@ PRIORITY_HIGH EQU $30 ret z cp c jr nz, .next_sprite - push bc push hl ld a, d @@ -3485,21 +2943,18 @@ PRIORITY_HIGH EQU $30 pop hl pop bc jr .next_sprite -; 5a0d -.InitSprite: ; 5a0d +.InitSprite ld hl, OBJECT_SPRITE_TILE add hl, bc ld a, [hl] and %01111111 ld [hFFC1], a - xor a bit 7, [hl] jr nz, .skip1 or %00001000 .skip1 - ld hl, OBJECT_FLAGS2 add hl, bc ld e, [hl] @@ -3507,12 +2962,10 @@ PRIORITY_HIGH EQU $30 jr z, .skip2 or %10000000 .skip2 - bit 4, e jr z, .skip3 or %00010000 .skip3 - ld hl, OBJECT_PALETTE add hl, bc ld d, a @@ -3520,44 +2973,34 @@ PRIORITY_HIGH EQU $30 and %00000111 or d ld d, a - xor a bit 3, e jr z, .skip4 or %10000000 .skip4 ld [hFFC2], a - ld hl, OBJECT_SPRITE_X add hl, bc ld a, [hl] - ld hl, OBJECT_SPRITE_X_OFFSET add hl, bc add [hl] - add 8 - ld e, a ld a, [wFollowNotExactPersonX] add e ld [hFFBF], a - ld hl, OBJECT_SPRITE_Y add hl, bc ld a, [hl] - ld hl, OBJECT_SPRITE_Y_OFFSET add hl, bc add [hl] - add 12 - ld e, a ld a, [wFollowNotExactPersonY] add e ld [hFFC0], a - ld hl, OBJECT_FACING_STEP add hl, bc ld a, [hl] @@ -3565,7 +3008,6 @@ PRIORITY_HIGH EQU $30 jp z, .done cp NUM_FACINGS jp nc, .done - ld l, a ld h, 0 add hl, hl @@ -3574,7 +3016,6 @@ PRIORITY_HIGH EQU $30 ld a, [hli] ld h, [hl] ld l, a - ld a, [hUsedSpriteIndex] ld c, a ld b, Sprites / $100 @@ -3583,25 +3024,19 @@ PRIORITY_HIGH EQU $30 add c cp SpritesEnd % $100 jr nc, .full - .addsprite ld a, [hFFC0] add [hl] inc hl - ld [bc], a inc c - ld a, [hFFBF] add [hl] inc hl - ld [bc], a inc c - ld e, [hl] inc hl - ld a, [hFFC1] bit 2, e jr z, .nope1 @@ -3609,10 +3044,8 @@ PRIORITY_HIGH EQU $30 .nope1 add [hl] inc hl - ld [bc], a inc c - ld a, e bit 1, a jr z, .nope2 @@ -3623,15 +3056,12 @@ PRIORITY_HIGH EQU $30 or d ld [bc], a inc c - ld a, [hUsedSpriteTile] dec a ld [hUsedSpriteTile], a jr nz, .addsprite - ld a, c ld [hUsedSpriteIndex], a - .done xor a ret @@ -3639,19 +3069,17 @@ PRIORITY_HIGH EQU $30 .full scf ret -; 5ac2 -.GetObjectStructPointer: ; 5ac2 +.GetObjectStructPointer ld c, a ld b, 0 ld hl, .Addresses - add hl,bc - add hl,bc + add hl, bc + add hl, bc ld c, [hl] inc hl ld b, [hl] ret -; 5ace .Addresses ; 5ace dw PlayerStruct diff --git a/engine/movement.asm b/engine/movement.asm index fc297cfee..ca3ac55b5 100644 --- a/engine/movement.asm +++ b/engine/movement.asm @@ -3,10 +3,10 @@ MovementPointers: ; 5075 dw Movement_turn_head_up ; 01 dw Movement_turn_head_left ; 02 dw Movement_turn_head_right ; 03 - dw Movement_half_step_down ; 04 - dw Movement_half_step_up ; 05 - dw Movement_half_step_left ; 06 - dw Movement_half_step_right ; 07 + dw Movement_turn_step_down ; 04 + dw Movement_turn_step_up ; 05 + dw Movement_turn_step_left ; 06 + dw Movement_turn_step_right ; 07 dw Movement_slow_step_down ; 08 dw Movement_slow_step_up ; 09 dw Movement_slow_step_left ; 0a @@ -130,7 +130,7 @@ Movement_step_dig: ; 5145 ld hl, OBJECT_ACTION add hl, bc ld [hl], PERSON_ACTION_SPIN - call GetMovementByte + call JumpMovementPointer ld hl, OBJECT_STEP_DURATION add hl, bc ld [hl], a @@ -150,7 +150,7 @@ Movement_return_dig: ; 516a ld hl, OBJECT_STEP_FRAME add hl, bc ld [hl], a - call GetMovementByte + call JumpMovementPointer ld hl, OBJECT_STEP_DURATION add hl, bc ld [hl], a @@ -174,7 +174,7 @@ Movement_fish_got_bite: ; 5189 ; 5196 Movement_rock_smash: ; 5196 - call GetMovementByte + call JumpMovementPointer ld hl, OBJECT_STEP_DURATION add hl, bc ld [hl], a @@ -233,7 +233,7 @@ Movement_48: ; 51db add hl, bc ld [hl], $0 - call GetMovementByte + call JumpMovementPointer ld hl, OBJECT_STEP_DURATION add hl, bc ld [hl], a @@ -311,7 +311,7 @@ Movement_step_sleep: ; 5242 ; parameters: ; duration (DecimalParam) - call GetMovementByte + call JumpMovementPointer jr Movement_step_sleep_common Movement_step_sleep_common: ; 5247 @@ -429,7 +429,7 @@ Movement_step_shake: ; 52d5 ; parameters: ; displacement (DecimalParam) - call GetMovementByte + call JumpMovementPointer call ShakeScreen jp ContinueReadingMovement ; 52de @@ -709,23 +709,23 @@ Movement_fast_jump_step_right: ; 53eb ; 53f0 -Movement_half_step_down: ; 53f0 +Movement_turn_step_down: ; 53f0 ld a, OW_DOWN - jr HalfStep + jr TurnStep -Movement_half_step_up: ; 53f4 +Movement_turn_step_up: ; 53f4 ld a, OW_UP - jr HalfStep + jr TurnStep -Movement_half_step_left: ; 53f8 +Movement_turn_step_left: ; 53f8 ld a, OW_LEFT - jr HalfStep + jr TurnStep -Movement_half_step_right: ; 53fc +Movement_turn_step_right: ; 53fc ld a, OW_RIGHT - jr HalfStep + jr TurnStep -HalfStep: ; 5400 +TurnStep: ; 5400 ld hl, OBJECT_29 ; new facing add hl, bc ld [hl], a diff --git a/engine/npctrade.asm b/engine/npctrade.asm index 3499a0134..7342f8a6c 100755 --- a/engine/npctrade.asm +++ b/engine/npctrade.asm @@ -511,7 +511,6 @@ TradedForText: ; 0xfcf80 ; traded givemon for getmon text_jump UnknownText_0x1bd429 start_asm - ld de, MUSIC_NONE call PlayMusic call DelayFrame diff --git a/engine/player_movement.asm b/engine/player_movement.asm new file mode 100755 index 000000000..a57e5cef1 --- /dev/null +++ b/engine/player_movement.asm @@ -0,0 +1,846 @@ +DoPlayerMovement:: ; 80000 + + call .GetDPad + ld a, movement_step_sleep_1 + ld [MovementAnimation], a + xor a + ld [wd041], a + call .TranslateIntoMovement + ld c, a + ld a, [MovementAnimation] + ld [wPlayerNextMovement], a + ret + +.GetDPad + + ld a, [hJoyDown] + ld [CurInput], a + +; Standing downhill instead moves down. + + ld hl, BikeFlags + bit 2, [hl] ; downhill + ret z + + ld c, a + and D_PAD + ret nz + + ld a, c + or D_DOWN + ld [CurInput], a + ret +; 8002d + +.TranslateIntoMovement + ld a, [PlayerState] + cp PLAYER_NORMAL + jr z, .Normal + cp PLAYER_SURF + jr z, .Surf + cp PLAYER_SURF_PIKA + jr z, .Surf + cp PLAYER_BIKE + jr z, .Normal + cp PLAYER_SLIP + jr z, .Ice + +.Normal + call .CheckForced + call .GetAction + call .CheckTile + ret c + call .CheckTurning + ret c + call .TryStep + ret c + call .TryJump + ret c + call .CheckWarp + ret c + jr .NotMoving + +.Surf + call .CheckForced + call .GetAction + call .CheckTile + ret c + call .CheckTurning + ret c + call .TrySurf + ret c + jr .NotMoving + +.Ice + call .CheckForced + call .GetAction + call .CheckTile + ret c + call .CheckTurning + ret c + call .TryStep + ret c + call .TryJump + ret c + call .CheckWarp + ret c + ld a, [WalkingDirection] + cp STANDING + jr z, .HitWall + call .BumpSound +.HitWall + call .StandInPlace + xor a + ret + +.NotMoving + ld a, [WalkingDirection] + cp STANDING + jr z, .Standing + +; Walking into an edge warp won't bump. + ld a, [EngineBuffer4] + and a + jr nz, .CantMove + call .BumpSound +.CantMove + call ._WalkInPlace + xor a + ret + +.Standing + call .StandInPlace + xor a + ret +; 800b7 + +.CheckTile: ; 800b7 +; Tiles such as waterfalls and warps move the player +; in a given direction, overriding input. + + ld a, [PlayerNextTile] + ld c, a + call CheckWhirlpoolTile + jr c, .asm_800c4 + ld a, 3 + scf + ret + +.asm_800c4 + and $f0 + cp $30 ; moving water + jr z, .water + cp $40 ; moving land 1 + jr z, .land1 + cp $50 ; moving land 2 + jr z, .land2 + cp $70 ; warps + jr z, .warps + jr .asm_8013c + +.water + ld a, c + and 3 + ld c, a + ld b, 0 + ld hl, .water_table + add hl, bc + ld a, [hl] + ld [WalkingDirection], a + jr .asm_8013e + +.water_table + db RIGHT + db LEFT + db UP + db DOWN + +.land1 + ld a, c + and 7 + ld c, a + ld b, 0 + ld hl, .land1_table + add hl, bc + ld a, [hl] + cp STANDING + jr z, .asm_8013c + ld [WalkingDirection], a + jr .asm_8013e + +.land1_table + db STANDING + db RIGHT + db LEFT + db UP + db DOWN + db STANDING + db STANDING + db STANDING + +.land2 + ld a, c + and 7 + ld c, a + ld b, 0 + ld hl, .land2_table + add hl, bc + ld a, [hl] + cp STANDING + jr z, .asm_8013c + ld [WalkingDirection], a + jr .asm_8013e + +.land2_table + db RIGHT + db LEFT + db UP + db DOWN + db STANDING + db STANDING + db STANDING + db STANDING + +.warps + ld a, c + cp $71 ; door + jr z, .down + cp $79 + jr z, .down + cp $7a ; stairs + jr z, .down + cp $7b ; cave + jr nz, .asm_8013c + +.down + ld a, DOWN + ld [WalkingDirection], a + jr .asm_8013e + +.asm_8013c + xor a + ret + +.asm_8013e + ld a, STEP_WALK + call .DoStep + ld a, 5 + scf + ret +; 80147 + +.CheckTurning: ; 80147 +; If the player is turning, change direction first. This also lets +; the player change facing without moving by tapping a direction. + + ld a, [wd04e] + cp 0 + jr nz, .asm_80169 + ld a, [WalkingDirection] + cp STANDING + jr z, .asm_80169 + + ld e, a + ld a, [PlayerDirection] + rrca + rrca + and 3 + cp e + jr z, .asm_80169 + + ld a, STEP_TURN + call .DoStep + ld a, 2 + scf + ret + +.asm_80169 + xor a + ret +; 8016b + +.TryStep: ; 8016b + +; Surfing actually calls .TrySurf directly instead of passing through here. + ld a, [PlayerState] + cp PLAYER_SURF + jr z, .TrySurf + cp PLAYER_SURF_PIKA + jr z, .TrySurf + + call .CheckLandPerms + jr c, .bump + + call .CheckNPC + and a + jr z, .bump + cp 2 + jr z, .bump + + ld a, [PlayerNextTile] + call CheckIceTile + jr nc, .ice + +; Downhill riding is slower when not moving down. + call .BikeCheck + jr nz, .walk + + ld hl, BikeFlags + bit 2, [hl] ; downhill + jr z, .fast + + ld a, [WalkingDirection] + cp DOWN + jr z, .fast + + ld a, STEP_WALK + call .DoStep + scf + ret + +.fast + ld a, STEP_BIKE + call .DoStep + scf + ret + +.walk + ld a, STEP_WALK + call .DoStep + scf + ret + +.ice + ld a, STEP_ICE + call .DoStep + scf + ret + +; unused? + xor a + ret + +.bump + xor a + ret +; 801c0 + +.TrySurf: ; 801c0 + + call .CheckSurfPerms + ld [wd040], a + jr c, .surf_bump + + call .CheckNPC + ld [wd03f], a + and a + jr z, .surf_bump + cp 2 + jr z, .surf_bump + + ld a, [wd040] + and a + jr nz, .ExitWater + + ld a, STEP_WALK + call .DoStep + scf + ret + +.ExitWater + call .GetOutOfWater + call PlayMapMusic + ld a, STEP_WALK + call .DoStep + ld a, 6 + scf + ret + +.surf_bump + xor a + ret +; 801f3 + +.TryJump: ; 801f3 + ld a, [PlayerNextTile] + ld e, a + and $f0 + cp $a0 ; ledge + jr nz, .DontJump + + ld a, e + and 7 + ld e, a + ld d, 0 + ld hl, .data_8021e + add hl, de + ld a, [FacingDirection] + and [hl] + jr z, .DontJump + + ld de, SFX_JUMP_OVER_LEDGE + call PlaySFX + ld a, STEP_LEDGE + call .DoStep + ld a, 7 + scf + ret + +.DontJump + xor a + ret + +.data_8021e + db FACE_RIGHT + db FACE_LEFT + db FACE_UP + db FACE_DOWN + db FACE_RIGHT | FACE_DOWN + db FACE_DOWN | FACE_LEFT + db FACE_UP | FACE_RIGHT + db FACE_UP | FACE_LEFT +; 80226 + +.CheckWarp: ; 80226 + +; Bug: Since no case is made for STANDING here, it will check +; [.edgewarps + $ff]. This resolves to $3e at $8035a. +; This causes wd041 to be nonzero when standing on tile $3e, +; making bumps silent. + + ld a, [WalkingDirection] + ld e, a + ld d, 0 + ld hl, .EdgeWarps + add hl, de + ld a, [PlayerNextTile] + cp [hl] + jr nz, .not_warp + + ld a, 1 + ld [wd041], a + ld a, [WalkingDirection] + cp STANDING + jr z, .not_warp + + ld e, a + ld a, [PlayerDirection] + rrca + rrca + and 3 + cp e + jr nz, .not_warp + call WarpCheck + jr nc, .not_warp + + call .StandInPlace + scf + ld a, 1 + ret + +.not_warp + xor a + ret + +.EdgeWarps + db $70, $78, $76, $7e +; 8025f + +.DoStep: ; 8025f + ld e, a + ld d, 0 + ld hl, .Steps + add hl, de + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + + ld a, [WalkingDirection] + ld e, a + cp STANDING + jp z, .StandInPlace + + add hl, de + ld a, [hl] + ld [MovementAnimation], a + + ld hl, .InPlace + add hl, de + ld a, [hl] + ld [wd04e], a + + ld a, 4 + ret + +.Steps + dw .SlowStep + dw .NormalStep + dw .FastStep + dw .JumpStep + dw .SlideStep + dw .TurningStep + dw .BackJumpStep + dw .InPlace + +.SlowStep + slow_step_down + slow_step_up + slow_step_left + slow_step_right +.NormalStep + step_down + step_up + step_left + step_right +.FastStep + big_step_down + big_step_up + big_step_left + big_step_right +.JumpStep + jump_step_down + jump_step_up + jump_step_left + jump_step_right +.SlideStep + fast_slide_step_down + fast_slide_step_up + fast_slide_step_left + fast_slide_step_right +.BackJumpStep + jump_step_up + jump_step_down + jump_step_right + jump_step_left +.TurningStep + turn_step_down + turn_step_up + turn_step_left + turn_step_right +.InPlace + db $80 + movement_turn_head_down + db $80 + movement_turn_head_up + db $80 + movement_turn_head_left + db $80 + movement_turn_head_right +; 802b3 + +.StandInPlace: ; 802b3 + ld a, 0 + ld [wd04e], a + ld a, movement_step_sleep_1 + ld [MovementAnimation], a + xor a + ret +; 802bf + +._WalkInPlace: ; 802bf + ld a, 0 + ld [wd04e], a + ld a, movement_step_bump + ld [MovementAnimation], a + xor a + ret +; 802cb + +.CheckForced: ; 802cb +; When sliding on ice, input is forced to remain in the same direction. + + call CheckStandingOnIce + ret nc + + ld a, [wd04e] + cp 0 + ret z + + and 3 + ld e, a + ld d, 0 + ld hl, .forced_dpad + add hl, de + ld a, [CurInput] + and BUTTONS + or [hl] + ld [CurInput], a + ret + +.forced_dpad + db D_DOWN, D_UP, D_LEFT, D_RIGHT +; 802ec + +.GetAction: ; 802ec +; Poll player input and update movement info. + + ld hl, .table + ld de, .table2 - .table1 + ld a, [CurInput] + bit D_DOWN_F, a + jr nz, .d_down + bit D_UP_F, a + jr nz, .d_up + bit D_LEFT_F, a + jr nz, .d_left + bit D_RIGHT_F, a + jr nz, .d_right +; Standing + jr .update + +.d_down add hl, de +.d_up add hl, de +.d_left add hl, de +.d_right add hl, de + +.update + ld a, [hli] + ld [WalkingDirection], a + ld a, [hli] + ld [FacingDirection], a + ld a, [hli] + ld [WalkingX], a + ld a, [hli] + ld [WalkingY], a + ld a, [hli] + ld h, [hl] + ld l, a + ld a, [hl] + ld [WalkingTile], a + ret + +.table +; struct: +; walk direction +; facing +; x movement +; y movement +; tile collision pointer +.table1 + db STANDING, FACE_CURRENT, 0, 0 + dw PlayerNextTile +.table2 + db RIGHT, FACE_RIGHT, 1, 0 + dw TileRight + db LEFT, FACE_LEFT, -1, 0 + dw TileLeft + db UP, FACE_UP, 0, -1 + dw TileUp + db DOWN, FACE_DOWN, 0, 1 + dw TileDown +; 80341 + +.CheckNPC: ; 80341 +; Returns 0 if there is an NPC in front that you can't move +; Returns 1 if there is no NPC in front +; Returns 2 if there is a movable NPC in front + ld a, 0 + ld [hMapObjectIndexBuffer], a +; Load the next X coordinate into d + ld a, [PlayerNextMapX] + ld d, a + ld a, [WalkingX] + add d + ld d, a +; Load the next Y coordinate into e + ld a, [PlayerNextMapY] + ld e, a + ld a, [WalkingY] + add e + ld e, a +; Find an object struct with coordinates equal to d,e + ld bc, ObjectStructs ; redundant + callba IsNPCAtCoord + jr nc, .is_npc + call .CheckStrengthBoulder + jr c, .no_bump + + xor a + ret + +.is_npc + ld a, 1 + ret + +.no_bump + ld a, 2 + ret +; 8036f + +.CheckStrengthBoulder: ; 8036f + + ld hl, BikeFlags + bit 0, [hl] ; using strength + jr z, .not_boulder + + ld hl, OBJECT_DIRECTION_WALKING + add hl, bc + ld a, [hl] + cp STANDING + jr nz, .not_boulder + + ld hl, OBJECT_PALETTE + add hl, bc + bit 6, [hl] + jr z, .not_boulder + + ld hl, OBJECT_FLAGS2 + add hl, bc + set 2, [hl] + + ld a, [WalkingDirection] + ld d, a + ld hl, OBJECT_RANGE + add hl, bc + ld a, [hl] + and $fc + or d + ld [hl], a + + scf + ret + +.not_boulder + xor a + ret +; 8039e + +.CheckLandPerms: ; 8039e +; Return 0 if walking onto land and tile permissions allow it. +; Otherwise, return carry. + + ld a, [TilePermissions] + ld d, a + ld a, [FacingDirection] + and d + jr nz, .NotWalkable + + ld a, [WalkingTile] + call .CheckWalkable + jr c, .NotWalkable + + xor a + ret + +.NotWalkable + scf + ret +; 803b4 + +.CheckSurfPerms: ; 803b4 +; Return 0 if moving in water, or 1 if moving onto land. +; Otherwise, return carry. + + ld a, [TilePermissions] + ld d, a + ld a, [FacingDirection] + and d + jr nz, .NotSurfable + + ld a, [WalkingTile] + call .CheckSurfable + jr c, .NotSurfable + + and a + ret + +.NotSurfable + scf + ret +; 803ca + +.BikeCheck: ; 803ca + + ld a, [PlayerState] + cp PLAYER_BIKE + ret z + cp PLAYER_SLIP + ret +; 803d3 + +.CheckWalkable: ; 803d3 +; Return 0 if tile a is land. Otherwise, return carry. + + call GetTileCollision + and a ; land + ret z + scf + ret +; 803da + +.CheckSurfable: ; 803da +; Return 0 if tile a is water, or 1 if land. +; Otherwise, return carry. + + call GetTileCollision + cp 1 + jr z, .Water + +; Can walk back onto land from water. + and a + jr z, .Land + + jr .Neither + +.Water + xor a + ret + +.Land + ld a, 1 + and a + ret + +.Neither + scf + ret +; 803ee + +.BumpSound: ; 803ee + + call CheckSFX + ret c + ld de, SFX_BUMP + call PlaySFX + ret +; 803f9 + +.GetOutOfWater: ; 803f9 + push bc + ld a, PLAYER_NORMAL + ld [PlayerState], a + call ReplaceKrisSprite ; UpdateSprites + pop bc + ret +; 80404 + +CheckStandingOnIce:: ; 80404 + ld a, [wd04e] + cp 0 + jr z, .not_ice + cp $f0 + jr z, .not_ice + ld a, [PlayerNextTile] + call CheckIceTile + jr nc, .yep + ld a, [PlayerState] + cp PLAYER_SLIP + jr nz, .not_ice + +.yep + scf + ret + +.not_ice + and a + ret +; 80422 + +Function80422:: ; 80422 + ld hl, wPlayerNextMovement + ld a, movement_step_sleep_1 + cp [hl] + ret z + + ld [hl], a + ld a, 0 + ld [wd04e], a + ret +; 80430 diff --git a/engine/timeset.asm b/engine/timeset.asm index 801fb26e8..8f212bc4d 100755 --- a/engine/timeset.asm +++ b/engine/timeset.asm @@ -336,7 +336,6 @@ Text_WhoaMins: ; 0x908a4 ; Whoa!@ @ text_jump UnknownText_0x1bc31b start_asm -; 0x908a9 hlcoord 7, 14 call DisplayMinutesWithMinString ld hl, .QuestionMark @@ -645,7 +644,6 @@ DebugDisplayTime: ; 90abc .Text: ; 0x90acc start_asm - call UpdateTime hlcoord 1, 14 diff --git a/event/bug_contest_judging.asm b/event/bug_contest_judging.asm index 04a8ff8bb..420c46aac 100755 --- a/event/bug_contest_judging.asm +++ b/event/bug_contest_judging.asm @@ -63,9 +63,6 @@ BugContest_ThirdPlaceText: ; 0x13719 ; Placing third was @ , who caught a @ !@ @ text_jump ContestJudging_ThirdPlaceText start_asm -; 0x1371e - -BugContest_ThirdPlace: ; 1371e ld de, SFX_3RD_PLACE call PlaySFX call WaitSFX diff --git a/home/map_objects.asm b/home/map_objects.asm index 855e0af39..be2c8553a 100644 --- a/home/map_objects.asm +++ b/home/map_objects.asm @@ -460,7 +460,7 @@ LoadMovementDataPointer:: ; 19e9 ld hl, OBJECT_STEP_TYPE add hl, bc - ld [hl], 0 + ld [hl], STEP_TYPE_00 ld hl, VramState set 7, [hl] @@ -611,7 +611,7 @@ endr ret ; 1aae -Function1aae:: ; 1aae +_GetMovementByte:: ; 1aae ; Switch to the movement data bank ld a, [hROMBank] push af diff --git a/macros/movement.asm b/macros/movement.asm index c4134b570..fd4852e8a 100644 --- a/macros/movement.asm +++ b/macros/movement.asm @@ -1,3 +1,4 @@ + enum_start enum movement_turn_head_down @@ -20,24 +21,24 @@ turn_head_right: macro db movement_turn_head_right ; $03 endm - enum movement_half_step_down -half_step_down: macro - db movement_half_step_down ; $04 + enum movement_turn_step_down +turn_step_down: macro + db movement_turn_step_down ; $04 endm - enum movement_half_step_up -half_step_up: macro - db movement_half_step_up ; $05 + enum movement_turn_step_up +turn_step_up: macro + db movement_turn_step_up ; $05 endm - enum movement_half_step_left -half_step_left: macro - db movement_half_step_left ; $06 + enum movement_turn_step_left +turn_step_left: macro + db movement_turn_step_left ; $06 endm - enum movement_half_step_right -half_step_right: macro - db movement_half_step_right ; $07 + enum movement_turn_step_right +turn_step_right: macro + db movement_turn_step_right ; $07 endm enum movement_slow_step_down @@ -367,7 +368,10 @@ step_loop: macro db movement_step_loop ; $4a endm -__enum__ = $4c + enum movement_step_4b +step_4b: macro + db movement_step_4b ; $4b + endm enum movement_teleport_from teleport_from: macro diff --git a/main.asm b/main.asm index df1b80eee..3036ea876 100644 --- a/main.asm +++ b/main.asm @@ -1568,21 +1568,21 @@ GetRelativeFacing:: ; 8417 ret ; 848a -Function848a: ; 848a - call Function849d +QueueFollowerFirstStep: ; 848a + call .QueueFirstStep jr c, .same - ld [wd4d1], a + ld [wFollowMovementQueue], a xor a - ld [wd4d0], a + ld [wFollowerMovementQueueLength], a ret .same ld a, -1 - ld [wd4d0], a + ld [wFollowerMovementQueueLength], a ret ; 849d -Function849d: ; 849d +.QueueFirstStep ld a, [wObjectFollow_Leader] call GetObjectStruct ld hl, OBJECT_NEXT_MAP_X @@ -1600,12 +1600,12 @@ Function849d: ; 849d jr z, .check_y jr c, .left and a - ld a, $c + RIGHT + ld a, movement_step_right ret .left and a - ld a, $c + LEFT + ld a, movement_step_left ret .check_y @@ -1616,12 +1616,12 @@ Function849d: ; 849d jr z, .same_xy jr c, .up and a - ld a, $c + DOWN + ld a, movement_step_down ret .up and a - ld a, $c + UP + ld a, movement_step_up ret .same_xy @@ -11520,855 +11520,7 @@ INCLUDE "text/phone/extra.asm" SECTION "bank20", ROMX, BANK[$20] -DoPlayerMovement:: ; 80000 - - call GetMovementInput - ld a, movement_step_sleep_1 - ld [MovementAnimation], a - xor a - ld [wd041], a - call GetPlayerMovement - ld c, a - ld a, [MovementAnimation] - ld [wc2de], a - ret -; 80017 - -GetMovementInput: ; 80017 - - ld a, [hJoyDown] - ld [CurInput], a - -; Standing downhill instead moves down. - - ld hl, BikeFlags - bit 2, [hl] ; downhill - ret z - - ld c, a - and D_PAD - ret nz - - ld a, c - or D_DOWN - ld [CurInput], a - ret -; 8002d - -GetPlayerMovement: ; 8002d - - ld a, [PlayerState] - cp PLAYER_NORMAL - jr z, .Normal - cp PLAYER_SURF - jr z, .Surf - cp PLAYER_SURF_PIKA - jr z, .Surf - cp PLAYER_BIKE - jr z, .Normal - cp PLAYER_SLIP - jr z, .Ice - -.Normal - call CheckForcedMovementInput - call GetMovementAction - call CheckTileMovement - ret c - call CheckTurning - ret c - call TryStep - ret c - call TryJumpLedge - ret c - call CheckEdgeWarp - ret c - jr .NotMoving - -.Surf - call CheckForcedMovementInput - call GetMovementAction - call CheckTileMovement - ret c - call CheckTurning - ret c - call TrySurfStep - ret c - jr .NotMoving - -.Ice - call CheckForcedMovementInput - call GetMovementAction - call CheckTileMovement - ret c - call CheckTurning - ret c - call TryStep - ret c - call TryJumpLedge - ret c - call CheckEdgeWarp - ret c - ld a, [WalkingDirection] - cp STANDING - jr z, .HitWall - call PlayBump -.HitWall - call StandInPlace - xor a - ret - -.NotMoving - ld a, [WalkingDirection] - cp STANDING - jr z, .Standing - -; Walking into an edge warp won't bump. - ld a, [EngineBuffer4] - and a - jr nz, .CantMove - call PlayBump -.CantMove - call WalkInPlace - xor a - ret - -.Standing - call StandInPlace - xor a - ret -; 800b7 - -CheckTileMovement: ; 800b7 -; Tiles such as waterfalls and warps move the player -; in a given direction, overriding input. - - ld a, [PlayerNextTile] - ld c, a - call CheckWhirlpoolTile - jr c, .asm_800c4 - ld a, 3 - scf - ret - -.asm_800c4 - and $f0 - cp $30 ; moving water - jr z, .water - cp $40 ; moving land 1 - jr z, .land1 - cp $50 ; moving land 2 - jr z, .land2 - cp $70 ; warps - jr z, .warps - jr .asm_8013c - -.water - ld a, c - and 3 - ld c, a - ld b, 0 - ld hl, .water_table - add hl, bc - ld a, [hl] - ld [WalkingDirection], a - jr .asm_8013e - -.water_table - db RIGHT - db LEFT - db UP - db DOWN - -.land1 - ld a, c - and 7 - ld c, a - ld b, 0 - ld hl, .land1_table - add hl, bc - ld a, [hl] - cp STANDING - jr z, .asm_8013c - ld [WalkingDirection], a - jr .asm_8013e - -.land1_table - db STANDING - db RIGHT - db LEFT - db UP - db DOWN - db STANDING - db STANDING - db STANDING - -.land2 - ld a, c - and 7 - ld c, a - ld b, 0 - ld hl, .land2_table - add hl, bc - ld a, [hl] - cp STANDING - jr z, .asm_8013c - ld [WalkingDirection], a - jr .asm_8013e - -.land2_table - db RIGHT - db LEFT - db UP - db DOWN - db STANDING - db STANDING - db STANDING - db STANDING - -.warps - ld a, c - cp $71 ; door - jr z, .down - cp $79 - jr z, .down - cp $7a ; stairs - jr z, .down - cp $7b ; cave - jr nz, .asm_8013c - -.down - ld a, DOWN - ld [WalkingDirection], a - jr .asm_8013e - -.asm_8013c - xor a - ret - -.asm_8013e - ld a, STEP_WALK - call DoStep - ld a, 5 - scf - ret -; 80147 - -CheckTurning: ; 80147 -; If the player is turning, change direction first. This also lets -; the player change facing without moving by tapping a direction. - - ld a, [wd04e] - cp 0 - jr nz, .asm_80169 - ld a, [WalkingDirection] - cp STANDING - jr z, .asm_80169 - - ld e, a - ld a, [PlayerDirection] - rrca - rrca - and 3 - cp e - jr z, .asm_80169 - - ld a, STEP_TURN - call DoStep - ld a, 2 - scf - ret - -.asm_80169 - xor a - ret -; 8016b - -TryStep: ; 8016b - -; Surfing actually calls TrySurfStep directly instead of passing through here. - ld a, [PlayerState] - cp PLAYER_SURF - jr z, TrySurfStep - cp PLAYER_SURF_PIKA - jr z, TrySurfStep - - call CheckLandPermissions - jr c, .bump - - call IsNPCInFront - and a - jr z, .bump - cp 2 - jr z, .bump - - ld a, [PlayerNextTile] - call CheckIceTile - jr nc, .ice - -; Downhill riding is slower when not moving down. - call CheckRiding - jr nz, .walk - - ld hl, BikeFlags - bit 2, [hl] ; downhill - jr z, .fast - - ld a, [WalkingDirection] - cp DOWN - jr z, .fast - - ld a, STEP_WALK - call DoStep - scf - ret - -.fast - ld a, STEP_BIKE - call DoStep - scf - ret - -.walk - ld a, STEP_WALK - call DoStep - scf - ret - -.ice - ld a, STEP_ICE - call DoStep - scf - ret - -; unused? - xor a - ret - -.bump - xor a - ret -; 801c0 - -TrySurfStep: ; 801c0 - - call CheckWaterPermissions - ld [wd040], a - jr c, .bump - - call IsNPCInFront - ld [wd03f], a - and a - jr z, .bump - cp 2 - jr z, .bump - - ld a, [wd040] - and a - jr nz, .ExitWater - - ld a, STEP_WALK - call DoStep - scf - ret - -.ExitWater - call WaterToLandSprite - call PlayMapMusic - ld a, STEP_WALK - call DoStep - ld a, 6 - scf - ret - -.bump - xor a - ret -; 801f3 - -TryJumpLedge: ; 801f3 - ld a, [PlayerNextTile] - ld e, a - and $f0 - cp $a0 ; ledge - jr nz, .DontJump - - ld a, e - and 7 - ld e, a - ld d, 0 - ld hl, .data_8021e - add hl, de - ld a, [FacingDirection] - and [hl] - jr z, .DontJump - - ld de, SFX_JUMP_OVER_LEDGE - call PlaySFX - ld a, STEP_LEDGE - call DoStep - ld a, 7 - scf - ret - -.DontJump - xor a - ret - -.data_8021e - db FACE_RIGHT - db FACE_LEFT - db FACE_UP - db FACE_DOWN - db FACE_RIGHT | FACE_DOWN - db FACE_DOWN | FACE_LEFT - db FACE_UP | FACE_RIGHT - db FACE_UP | FACE_LEFT -; 80226 - -CheckEdgeWarp: ; 80226 - -; Bug: Since no case is made for STANDING here, it will check -; [.edgewarps + $ff]. This resolves to $3e at $8035a. -; This causes wd041 to be nonzero when standing on tile $3e, -; making bumps silent. - - ld a, [WalkingDirection] - ld e, a - ld d, 0 - ld hl, .EdgeWarps - add hl, de - ld a, [PlayerNextTile] - cp [hl] - jr nz, .nope - - ld a, 1 - ld [wd041], a - ld a, [WalkingDirection] - cp STANDING - jr z, .nope - - ld e, a - ld a, [PlayerDirection] - rrca - rrca - and 3 - cp e - jr nz, .nope - call WarpCheck - jr nc, .nope - - call StandInPlace - scf - ld a, 1 - ret - -.nope - xor a - ret - -.EdgeWarps - db $70, $78, $76, $7e -; 8025f - -DoStep: ; 8025f - ld e, a - ld d, 0 - ld hl, .Steps - add hl, de - add hl, de - ld a, [hli] - ld h, [hl] - ld l, a - - ld a, [WalkingDirection] - ld e, a - cp STANDING - jp z, StandInPlace - - add hl, de - ld a, [hl] - ld [MovementAnimation], a - - ld hl, .WalkInPlace - add hl, de - ld a, [hl] - ld [wd04e], a - - ld a, 4 - ret - -.Steps - dw .Slow - dw .Walk - dw .Bike - dw .Ledge - dw .Ice - dw .Turn - dw .BackwardsLedge - dw .WalkInPlace - -.Slow - slow_step_down - slow_step_up - slow_step_left - slow_step_right -.Walk - step_down - step_up - step_left - step_right -.Bike - big_step_down - big_step_up - big_step_left - big_step_right -.Ledge - jump_step_down - jump_step_up - jump_step_left - jump_step_right -.Ice - fast_slide_step_down - fast_slide_step_up - fast_slide_step_left - fast_slide_step_right -.BackwardsLedge - jump_step_up - jump_step_down - jump_step_right - jump_step_left -.Turn - half_step_down - half_step_up - half_step_left - half_step_right -.WalkInPlace - db $80 + movement_turn_head_down - db $80 + movement_turn_head_up - db $80 + movement_turn_head_left - db $80 + movement_turn_head_right -; 802b3 - -StandInPlace: ; 802b3 - ld a, 0 - ld [wd04e], a - ld a, movement_step_sleep_1 - ld [MovementAnimation], a - xor a - ret -; 802bf - -WalkInPlace: ; 802bf - ld a, 0 - ld [wd04e], a - ld a, movement_step_bump - ld [MovementAnimation], a - xor a - ret -; 802cb - -CheckForcedMovementInput: ; 802cb -; When sliding on ice, input is forced to remain in the same direction. - - call CheckStandingOnIce - ret nc - - ld a, [wd04e] - cp 0 - ret z - - and 3 - ld e, a - ld d, 0 - ld hl, .data_802e8 - add hl, de - ld a, [CurInput] - and BUTTONS - or [hl] - ld [CurInput], a - ret - -.data_802e8 - db D_DOWN, D_UP, D_LEFT, D_RIGHT -; 802ec - -GetMovementAction: ; 802ec -; Poll player input and update movement info. - - ld hl, .table - ld de, .table2 - .table1 - ld a, [CurInput] - bit 7, a - jr nz, .down - bit 6, a - jr nz, .up - bit 5, a - jr nz, .left - bit 4, a - jr nz, .right -; Standing - jr .update - -.down add hl, de -.up add hl, de -.left add hl, de -.right add hl, de - -.update - ld a, [hli] - ld [WalkingDirection], a - ld a, [hli] - ld [FacingDirection], a - ld a, [hli] - ld [WalkingX], a - ld a, [hli] - ld [WalkingY], a - ld a, [hli] - ld h, [hl] - ld l, a - ld a, [hl] - ld [WalkingTile], a - ret - -.table -; struct: -; walk direction -; facing -; x movement -; y movement -; tile collision pointer -.table1 - db STANDING, FACE_CURRENT, 0, 0 - dw PlayerNextTile -.table2 - db RIGHT, FACE_RIGHT, 1, 0 - dw TileRight - db LEFT, FACE_LEFT, -1, 0 - dw TileLeft - db UP, FACE_UP, 0, -1 - dw TileUp - db DOWN, FACE_DOWN, 0, 1 - dw TileDown -; 80341 - -IsNPCInFront: ; 80341 -; Returns 0 if there is an NPC in front that you can't move -; Returns 1 if there is no NPC in front -; Returns 2 if there is a movable NPC in front - ld a, 0 - ld [hMapObjectIndexBuffer], a -; Load the next X coordinate into d - ld a, [PlayerNextMapX] - ld d, a - ld a, [WalkingX] - add d - ld d, a -; Load the next Y coordinate into e - ld a, [PlayerNextMapY] - ld e, a - ld a, [WalkingY] - add e - ld e, a -; Find an object struct with coordinates equal to d,e - ld bc, ObjectStructs ; redundant - callba IsNPCAtCoord - jr nc, .nope - call Function8036f - jr c, .no_bump - -; .bump - xor a - ret - -.nope - ld a, 1 - ret - -.no_bump - ld a, 2 - ret -; 8036f - -Function8036f: ; 8036f - - ld hl, BikeFlags - bit 0, [hl] ; using strength - jr z, .nope - - ld hl, OBJECT_DIRECTION_WALKING - add hl, bc - ld a, [hl] - cp STANDING - jr nz, .nope - - ld hl, OBJECT_PALETTE - add hl, bc - bit 6, [hl] - jr z, .nope - - ld hl, OBJECT_FLAGS2 - add hl, bc - set 2, [hl] - - ld a, [WalkingDirection] - ld d, a - ld hl, OBJECT_RANGE - add hl, bc - ld a, [hl] - and $fc - or d - ld [hl], a - - scf - ret - -.nope - xor a - ret -; 8039e - -CheckLandPermissions: ; 8039e -; Return 0 if walking onto land and tile permissions allow it. -; Otherwise, return carry. - - ld a, [TilePermissions] - ld d, a - ld a, [FacingDirection] - and d - jr nz, .NotWalkable - - ld a, [WalkingTile] - call CheckWalkable - jr c, .NotWalkable - - xor a - ret - -.NotWalkable - scf - ret -; 803b4 - -CheckWaterPermissions: ; 803b4 -; Return 0 if moving in water, or 1 if moving onto land. -; Otherwise, return carry. - - ld a, [TilePermissions] - ld d, a - ld a, [FacingDirection] - and d - jr nz, .NotSurfable - - ld a, [WalkingTile] - call CheckSurfable - jr c, .NotSurfable - - and a - ret - -.NotSurfable - scf - ret -; 803ca - -CheckRiding: ; 803ca - - ld a, [PlayerState] - cp PLAYER_BIKE - ret z - cp PLAYER_SLIP - ret -; 803d3 - -CheckWalkable: ; 803d3 -; Return 0 if tile a is land. Otherwise, return carry. - - call GetTileCollision - and a ; land - ret z - scf - ret -; 803da - -CheckSurfable: ; 803da -; Return 0 if tile a is water, or 1 if land. -; Otherwise, return carry. - - call GetTileCollision - cp 1 - jr z, .Water - -; Can walk back onto land from water. - and a - jr z, .Land - - jr .Neither - -.Water - xor a - ret - -.Land - ld a, 1 - and a - ret - -.Neither - scf - ret -; 803ee - -PlayBump: ; 803ee - - call CheckSFX - ret c - ld de, SFX_BUMP - call PlaySFX - ret -; 803f9 - -WaterToLandSprite: ; 803f9 - push bc - ld a, PLAYER_NORMAL - ld [PlayerState], a - call ReplaceKrisSprite ; UpdateSprites - pop bc - ret -; 80404 - -CheckStandingOnIce:: ; 80404 - ld a, [wd04e] - cp 0 - jr z, .nope - cp $f0 - jr z, .nope - ld a, [PlayerNextTile] - call CheckIceTile - jr nc, .yep - ld a, [PlayerState] - cp PLAYER_SLIP - jr nz, .nope - -.yep - scf - ret - -.nope - and a - ret -; 80422 - -Function80422:: ; 80422 - ld hl, wc2de - ld a, movement_step_sleep_1 - cp [hl] - ret z - - ld [hl], a - ld a, 0 - ld [wd04e], a - ret -; 80430 +INCLUDE "engine/player_movement.asm" INCLUDE "engine/engine_flags.asm" ; 80648 diff --git a/misc/mobile_22_2.asm b/misc/mobile_22_2.asm index b14660d05..70fc96095 100644 --- a/misc/mobile_22_2.asm +++ b/misc/mobile_22_2.asm @@ -542,9 +542,6 @@ UnknownText_0x8b64c: ; 0x8b64c ; CARD FOLDER open.@ @ text_jump UnknownText_0x1bc288 start_asm -; 0x8b651 - -Function8b651: ; 8b651 ld de, SFX_TWINKLE call PlaySFX call WaitSFX diff --git a/wram.asm b/wram.asm index cdb18a6d1..056816e92 100644 --- a/wram.asm +++ b/wram.asm @@ -385,14 +385,14 @@ wLinkMode:: ; c2dc ScriptVar:: ; c2dd ds 1 -wc2de:: ds 1 -wc2df:: ds 1 +wPlayerNextMovement:: ds 1 +wPlayerMovement:: ds 1 ds 2 +wc2e2:: wMovementPerson:: ds 1 wMovementDataPointer:: ds 3 ; dba wc2e6:: ds 4 -wc2ea:: ds 1 -wc2eb:: +wMovementByteWasControlSwitch:: ds 1 wMovementPointer:: ds 2 ; c2eb ds 3 @@ -2601,9 +2601,8 @@ CurDay:: ; d4cb wObjectFollow_Leader:: ds 1 wObjectFollow_Follower:: ds 1 wCenteredObject:: ds 1 -wd4d0:: ds 1 -wd4d1:: ds 1 - ds 4 +wFollowerMovementQueueLength:: ds 1 +wFollowMovementQueue:: ds 5 ObjectStructs:: ; d4d6 object_struct: MACRO