From 41d5ea0482f4ef577df600d2d8b5cad70f74a396 Mon Sep 17 00:00:00 2001 From: Rangi <35663410+Rangi42@users.noreply.github.com> Date: Mon, 12 Sep 2022 09:15:44 -0400 Subject: [PATCH] Rename the `object_struct` field labels and constants (#1005) Fixes #990 --- constants/map_object_constants.asm | 70 ++--- constants/script_constants.asm | 15 +- docs/bugs_and_glitches.md | 2 +- engine/events/field_moves.asm | 4 +- engine/events/overworld.asm | 4 +- engine/overworld/cmd_queue.asm | 14 +- engine/overworld/events.asm | 6 +- engine/overworld/load_map_part.asm | 4 +- engine/overworld/map_object_action.asm | 40 +-- engine/overworld/map_objects.asm | 364 ++++++++++++------------- engine/overworld/movement.asm | 28 +- engine/overworld/npc_movement.asm | 66 ++--- engine/overworld/player_movement.asm | 18 +- engine/overworld/player_object.asm | 52 ++-- engine/overworld/player_step.asm | 8 +- engine/overworld/tile_events.asm | 10 +- engine/overworld/warp_connection.asm | 12 +- home/map.asm | 28 +- home/map_objects.asm | 26 +- home/stone_queue.asm | 4 +- home/trainers.asm | 12 +- macros.asm | 2 +- macros/coords.asm | 2 + macros/{rst.asm => farcall.asm} | 2 + macros/gfx.asm | 2 + macros/legacy.asm | 2 +- macros/predef.asm | 2 + macros/ram.asm | 66 ++--- macros/vc.asm | 2 + ram/wram.asm | 6 +- 30 files changed, 442 insertions(+), 431 deletions(-) rename macros/{rst.asm => farcall.asm} (90%) diff --git a/constants/map_object_constants.asm b/constants/map_object_constants.asm index 706e77053..b1a88ae09 100644 --- a/constants/map_object_constants.asm +++ b/constants/map_object_constants.asm @@ -1,43 +1,43 @@ ; object_struct members (see macros/ram.asm) rsreset -DEF OBJECT_SPRITE rb ; 00 -DEF OBJECT_MAP_OBJECT_INDEX rb ; 01 -DEF OBJECT_SPRITE_TILE rb ; 02 -DEF OBJECT_MOVEMENTTYPE rb ; 03 -DEF OBJECT_FLAGS1 rb ; 04 -DEF OBJECT_FLAGS2 rb ; 05 -DEF OBJECT_PALETTE rb ; 06 -DEF OBJECT_DIRECTION_WALKING rb ; 07 -DEF OBJECT_FACING rb ; 08 -DEF OBJECT_STEP_TYPE rb ; 09 -DEF OBJECT_STEP_DURATION rb ; 0a -DEF OBJECT_ACTION rb ; 0b -DEF OBJECT_STEP_FRAME rb ; 0c -DEF OBJECT_FACING_STEP rb ; 0d -DEF OBJECT_NEXT_TILE rb ; 0e -DEF OBJECT_STANDING_TILE rb ; 0f -DEF OBJECT_NEXT_MAP_X rb ; 10 -DEF OBJECT_NEXT_MAP_Y rb ; 11 -DEF OBJECT_MAP_X rb ; 12 -DEF OBJECT_MAP_Y rb ; 13 -DEF OBJECT_INIT_X rb ; 14 -DEF OBJECT_INIT_Y rb ; 15 -DEF OBJECT_RADIUS rb ; 16 -DEF OBJECT_SPRITE_X rb ; 17 -DEF OBJECT_SPRITE_Y rb ; 18 -DEF OBJECT_SPRITE_X_OFFSET rb ; 19 -DEF OBJECT_SPRITE_Y_OFFSET rb ; 1a -DEF OBJECT_MOVEMENT_BYTE_INDEX rb ; 1b -DEF OBJECT_1C rb ; 1c -DEF OBJECT_1D rb ; 1d -DEF OBJECT_1E rb ; 1e -DEF OBJECT_1F rb ; 1f -DEF OBJECT_RANGE rb ; 20 - rb_skip 7 +DEF OBJECT_SPRITE rb ; 00 +DEF OBJECT_MAP_OBJECT_INDEX rb ; 01 +DEF OBJECT_SPRITE_TILE rb ; 02 +DEF OBJECT_MOVEMENT_TYPE rb ; 03 +DEF OBJECT_FLAGS1 rb ; 04 +DEF OBJECT_FLAGS2 rb ; 05 +DEF OBJECT_PALETTE rb ; 06 +DEF OBJECT_WALKING rb ; 07 +DEF OBJECT_DIRECTION rb ; 08 +DEF OBJECT_STEP_TYPE rb ; 09 +DEF OBJECT_STEP_DURATION rb ; 0a +DEF OBJECT_ACTION rb ; 0b +DEF OBJECT_STEP_FRAME rb ; 0c +DEF OBJECT_FACING rb ; 0d +DEF OBJECT_TILE rb ; 0e +DEF OBJECT_LAST_TILE rb ; 0f +DEF OBJECT_MAP_X rb ; 10 +DEF OBJECT_MAP_Y rb ; 11 +DEF OBJECT_LAST_MAP_X rb ; 12 +DEF OBJECT_LAST_MAP_Y rb ; 13 +DEF OBJECT_INIT_X rb ; 14 +DEF OBJECT_INIT_Y rb ; 15 +DEF OBJECT_RADIUS rb ; 16 +DEF OBJECT_SPRITE_X rb ; 17 +DEF OBJECT_SPRITE_Y rb ; 18 +DEF OBJECT_SPRITE_X_OFFSET rb ; 19 +DEF OBJECT_SPRITE_Y_OFFSET rb ; 1a +DEF OBJECT_MOVEMENT_INDEX rb ; 1b +DEF OBJECT_STEP_INDEX rb ; 1c +DEF OBJECT_1D rb ; 1d +DEF OBJECT_1E rb ; 1e +DEF OBJECT_JUMP_HEIGHT rb ; 1f +DEF OBJECT_RANGE rb ; 20 + rb_skip 7 DEF OBJECT_LENGTH EQU _RS DEF NUM_OBJECT_STRUCTS EQU 13 ; see wObjectStructs -; object_struct OBJECT_FACING values +; object_struct OBJECT_DIRECTION values DEF OW_DOWN EQU DOWN << 2 DEF OW_UP EQU UP << 2 DEF OW_LEFT EQU LEFT << 2 diff --git a/constants/script_constants.asm b/constants/script_constants.asm index 88b091b05..899d65488 100644 --- a/constants/script_constants.asm +++ b/constants/script_constants.asm @@ -145,13 +145,14 @@ DEF NUM_BGEVENTS EQU const_value DEF NUM_OBJECT_TYPES EQU const_value ; command queue members -DEF CMDQUEUE_TYPE EQU 0 -DEF CMDQUEUE_ADDR EQU 1 -DEF CMDQUEUE_02 EQU 2 -DEF CMDQUEUE_03 EQU 3 -DEF CMDQUEUE_04 EQU 4 -DEF CMDQUEUE_05 EQU 5 -DEF CMDQUEUE_ENTRY_SIZE EQU 6 +rsreset +DEF CMDQUEUE_TYPE rb +DEF CMDQUEUE_ADDR rb +DEF CMDQUEUE_02 rb +DEF CMDQUEUE_03 rb +DEF CMDQUEUE_04 rb +DEF CMDQUEUE_JUMPTABLE_INDEX rb +DEF CMDQUEUE_ENTRY_SIZE EQU _RS DEF CMDQUEUE_CAPACITY EQU 4 ; HandleQueuedCommand.Jumptable indexes (see engine/overworld/events.asm) diff --git a/docs/bugs_and_glitches.md b/docs/bugs_and_glitches.md index 6a40bbee7..1547290f1 100644 --- a/docs/bugs_and_glitches.md +++ b/docs/bugs_and_glitches.md @@ -2074,7 +2074,7 @@ If `[wWalkingDirection]` is `STANDING` (`$FF`), this will check `[.EdgeWarps + $ ld d, 0 ld hl, .EdgeWarps add hl, de - ld a, [wPlayerStandingTile] + ld a, [wPlayerTile] cp [hl] jr nz, .not_warp diff --git a/engine/events/field_moves.asm b/engine/events/field_moves.asm index 2cc6b7060..addefb888 100644 --- a/engine/events/field_moves.asm +++ b/engine/events/field_moves.asm @@ -234,12 +234,12 @@ Cut_SpawnLeaf: Cut_GetLeafSpawnCoords: ld de, 0 - ld a, [wMetatileStandingX] + ld a, [wPlayerMetatileX] bit 0, a jr z, .left_side set 0, e .left_side - ld a, [wMetatileStandingY] + ld a, [wPlayerMetatileY] bit 0, a jr z, .top_side set 1, e diff --git a/engine/events/overworld.asm b/engine/events/overworld.asm index 19ee02764..8fa37c572 100644 --- a/engine/events/overworld.asm +++ b/engine/events/overworld.asm @@ -686,7 +686,7 @@ Script_UsedWaterfall: .CheckContinueWaterfall: xor a ld [wScriptVar], a - ld a, [wPlayerStandingTile] + ld a, [wPlayerTile] call CheckWaterfallTile ret z farcall StubbedTrainerRankings_Waterfall @@ -1693,7 +1693,7 @@ BikeFunction: jr .nope .ok - call GetPlayerStandingTile + call GetPlayerTile and $f ; lo nybble only jr nz, .nope ; not FLOOR_TILE xor a diff --git a/engine/overworld/cmd_queue.asm b/engine/overworld/cmd_queue.asm index f94bf5c64..cd8c5e4aa 100644 --- a/engine/overworld/cmd_queue.asm +++ b/engine/overworld/cmd_queue.asm @@ -135,7 +135,7 @@ HandleQueuedCommand: dba CmdQueue_Type4 CmdQueues_AnonJumptable: - ld hl, CMDQUEUE_05 + ld hl, CMDQUEUE_JUMPTABLE_INDEX add hl, bc ld a, [hl] pop hl @@ -143,13 +143,13 @@ CmdQueues_AnonJumptable: ret CmdQueues_IncAnonJumptableIndex: - ld hl, CMDQUEUE_05 + ld hl, CMDQUEUE_JUMPTABLE_INDEX add hl, bc inc [hl] ret CmdQueues_DecAnonJumptableIndex: - ld hl, CMDQUEUE_05 + ld hl, CMDQUEUE_JUMPTABLE_INDEX add hl, bc dec [hl] ret @@ -241,7 +241,7 @@ CmdQueue_Type3: .PlayerNotFacingDown: ld a, $7f ld [wd173], a - ld hl, CMDQUEUE_05 + ld hl, CMDQUEUE_JUMPTABLE_INDEX add hl, bc ld [hl], 0 ret @@ -266,19 +266,19 @@ CmdQueue_StoneTable: and a jr z, .next - ld hl, OBJECT_MOVEMENTTYPE + ld hl, OBJECT_MOVEMENT_TYPE add hl, de ld a, [hl] cp SPRITEMOVEDATA_STRENGTH_BOULDER jr nz, .next - ld hl, OBJECT_NEXT_TILE + ld hl, OBJECT_TILE add hl, de ld a, [hl] call CheckPitTile jr nz, .next - ld hl, OBJECT_DIRECTION_WALKING + ld hl, OBJECT_WALKING add hl, de ld a, [hl] cp STANDING diff --git a/engine/overworld/events.asm b/engine/overworld/events.asm index 7bd075010..bb6ee1676 100644 --- a/engine/overworld/events.asm +++ b/engine/overworld/events.asm @@ -349,7 +349,7 @@ CheckTileEvent: ret .warp_tile - ld a, [wPlayerStandingTile] + ld a, [wPlayerTile] call CheckPitTile jr nz, .not_pit ld a, PLAYEREVENT_FALL @@ -1191,7 +1191,7 @@ CanUseSweetScent:: jr nc, .no .ice_check - ld a, [wPlayerStandingTile] + ld a, [wPlayerTile] call CheckIceTile jr z, .no scf @@ -1262,7 +1262,7 @@ ChooseWildEncounter_BugContest:: ret TryWildEncounter_BugContest: - ld a, [wPlayerStandingTile] + ld a, [wPlayerTile] call CheckSuperTallGrassTile ld b, 40 percent jr z, .ok diff --git a/engine/overworld/load_map_part.asm b/engine/overworld/load_map_part.asm index da1436406..88a0b53cb 100644 --- a/engine/overworld/load_map_part.asm +++ b/engine/overworld/load_map_part.asm @@ -1,13 +1,13 @@ _LoadMapPart:: ld hl, wSurroundingTiles - ld a, [wMetatileStandingY] + ld a, [wPlayerMetatileY] and a jr z, .top_row ld bc, SURROUNDING_WIDTH * 2 add hl, bc .top_row - ld a, [wMetatileStandingX] + ld a, [wPlayerMetatileX] and a jr z, .left_column inc hl diff --git a/engine/overworld/map_object_action.asm b/engine/overworld/map_object_action.asm index 7018bded8..916131f05 100644 --- a/engine/overworld/map_object_action.asm +++ b/engine/overworld/map_object_action.asm @@ -22,7 +22,7 @@ ObjectActionPairPointers: assert_table_length NUM_OBJECT_ACTIONS SetFacingStanding: - ld hl, OBJECT_FACING_STEP + ld hl, OBJECT_FACING add hl, bc ld [hl], STANDING ret @@ -30,13 +30,13 @@ SetFacingStanding: SetFacingCurrent: call GetSpriteDirection or FACING_STEP_DOWN_0 ; useless - ld hl, OBJECT_FACING_STEP + ld hl, OBJECT_FACING add hl, bc ld [hl], a ret SetFacingStandAction: - ld hl, OBJECT_FACING_STEP + ld hl, OBJECT_FACING add hl, bc ld a, [hl] and 1 @@ -64,7 +64,7 @@ SetFacingStepAction: call GetSpriteDirection or FACING_STEP_DOWN_0 ; useless or d - ld hl, OBJECT_FACING_STEP + ld hl, OBJECT_FACING add hl, bc ld [hl], a ret @@ -90,7 +90,7 @@ SetFacingSkyfall: call GetSpriteDirection or FACING_STEP_DOWN_0 ; useless or d - ld hl, OBJECT_FACING_STEP + ld hl, OBJECT_FACING add hl, bc ld [hl], a ret @@ -115,18 +115,18 @@ SetFacingBumpAction: call GetSpriteDirection or FACING_STEP_DOWN_0 ; useless or d - ld hl, OBJECT_FACING_STEP + ld hl, OBJECT_FACING add hl, bc ld [hl], a ret SetFacingCounterclockwiseSpin: call CounterclockwiseSpinAction - ld hl, OBJECT_FACING + ld hl, OBJECT_DIRECTION add hl, bc ld a, [hl] or FACING_STEP_DOWN_0 ; useless - ld hl, OBJECT_FACING_STEP + ld hl, OBJECT_FACING add hl, bc ld [hl], a ret @@ -169,7 +169,7 @@ CounterclockwiseSpinAction: ld hl, .facings add hl, de ld a, [hl] - ld hl, OBJECT_FACING + ld hl, OBJECT_DIRECTION add hl, bc ld [hl], a ret @@ -185,25 +185,25 @@ SetFacingFish: rrca rrca add FACING_FISH_DOWN - ld hl, OBJECT_FACING_STEP + ld hl, OBJECT_FACING add hl, bc ld [hl], a ret SetFacingShadow: - ld hl, OBJECT_FACING_STEP + ld hl, OBJECT_FACING add hl, bc ld [hl], FACING_SHADOW ret SetFacingEmote: - ld hl, OBJECT_FACING_STEP + ld hl, OBJECT_FACING add hl, bc ld [hl], FACING_EMOTE ret SetFacingBigDollSym: - ld hl, OBJECT_FACING_STEP + ld hl, OBJECT_FACING add hl, bc ld [hl], FACING_BIG_DOLL_SYM ret @@ -217,13 +217,13 @@ SetFacingBounce: ld [hl], a and %00001000 jr z, SetFacingFreezeBounce - ld hl, OBJECT_FACING_STEP + ld hl, OBJECT_FACING add hl, bc ld [hl], FACING_STEP_UP_0 ret SetFacingFreezeBounce: - ld hl, OBJECT_FACING_STEP + ld hl, OBJECT_FACING add hl, bc ld [hl], FACING_STEP_DOWN_0 ret @@ -238,13 +238,13 @@ SetFacingWeirdTree: rrca rrca add FACING_WEIRD_TREE_0 - ld hl, OBJECT_FACING_STEP + ld hl, OBJECT_FACING add hl, bc ld [hl], a ret SetFacingBigDollAsym: - ld hl, OBJECT_FACING_STEP + ld hl, OBJECT_FACING add hl, bc ld [hl], FACING_BIG_DOLL_ASYM ret @@ -259,7 +259,7 @@ SetFacingBigDoll: ld d, FACING_BIG_DOLL_ASYM ; asymmetric .ok - ld hl, OBJECT_FACING_STEP + ld hl, OBJECT_FACING add hl, bc ld [hl], d ret @@ -270,7 +270,7 @@ SetFacingBoulderDust: inc [hl] ld a, [hl] - ld hl, OBJECT_FACING_STEP + ld hl, OBJECT_FACING add hl, bc and 2 ld a, FACING_BOULDER_DUST_1 @@ -286,7 +286,7 @@ SetFacingGrassShake: add hl, bc inc [hl] ld a, [hl] - ld hl, OBJECT_FACING_STEP + ld hl, OBJECT_FACING add hl, bc and 4 ld a, FACING_GRASS_1 diff --git a/engine/overworld/map_objects.asm b/engine/overworld/map_objects.asm index 93ffd9ba1..6d9a460c0 100644 --- a/engine/overworld/map_objects.asm +++ b/engine/overworld/map_objects.asm @@ -39,7 +39,7 @@ CheckObjectStillVisible: res OBJ_FLAGS2_6, [hl] ld a, [wXCoord] ld e, a - ld hl, OBJECT_NEXT_MAP_X + ld hl, OBJECT_MAP_X add hl, bc ld a, [hl] add 1 @@ -49,7 +49,7 @@ CheckObjectStillVisible: jr nc, .ok ld a, [wYCoord] ld e, a - ld hl, OBJECT_NEXT_MAP_Y + ld hl, OBJECT_MAP_Y add hl, bc ld a, [hl] add 1 @@ -182,43 +182,43 @@ CallObjectAction: INCLUDE "engine/overworld/map_object_action.asm" -CopyNextCoordsTileToStandingCoordsTile: - ld hl, OBJECT_NEXT_MAP_X - add hl, bc - ld a, [hl] +CopyCoordsTileToLastCoordsTile: 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_LAST_MAP_X + add hl, bc + ld [hl], a ld hl, OBJECT_MAP_Y add hl, bc + ld a, [hl] + ld hl, OBJECT_LAST_MAP_Y + add hl, bc ld [hl], a - ld hl, OBJECT_NEXT_TILE + ld hl, OBJECT_TILE add hl, bc ld a, [hl] - ld hl, OBJECT_STANDING_TILE + ld hl, OBJECT_LAST_TILE add hl, bc ld [hl], a call SetTallGrassFlags - ld hl, OBJECT_NEXT_TILE + ld hl, OBJECT_TILE add hl, bc ld a, [hl] call UselessAndA ret -CopyStandingCoordsTileToNextCoordsTile: +CopyLastCoordsToCoords: + ld hl, OBJECT_LAST_MAP_X + add hl, bc + ld a, [hl] 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 + ld hl, OBJECT_LAST_MAP_Y add hl, bc ld a, [hl] - ld hl, OBJECT_NEXT_MAP_Y + ld hl, OBJECT_MAP_Y add hl, bc ld [hl], a ret @@ -228,17 +228,17 @@ UpdateTallGrassFlags: add hl, bc bit OVERHEAD_F, [hl] jr z, .ok - ld hl, OBJECT_NEXT_TILE + ld hl, OBJECT_TILE add hl, bc ld a, [hl] call SetTallGrassFlags .ok - ld hl, OBJECT_NEXT_TILE + ld hl, OBJECT_TILE add hl, bc ld a, [hl] call UselessAndA ret c ; never happens - ld hl, OBJECT_STANDING_TILE + ld hl, OBJECT_LAST_TILE add hl, bc ld a, [hl] call UselessAndA @@ -270,19 +270,19 @@ EndSpriteMovement: ld hl, OBJECT_STEP_FRAME add hl, bc ld [hl], a - ld hl, OBJECT_MOVEMENT_BYTE_INDEX + ld hl, OBJECT_MOVEMENT_INDEX add hl, bc ld [hli], a - ld [hli], a ; OBJECT_1C + ld [hli], a ; OBJECT_STEP_INDEX ld [hli], a ; OBJECT_1D ld [hl], a ; OBJECT_1E - ld hl, OBJECT_DIRECTION_WALKING + ld hl, OBJECT_WALKING add hl, bc ld [hl], STANDING ret InitStep: - ld hl, OBJECT_DIRECTION_WALKING + ld hl, OBJECT_WALKING add hl, bc ld [hl], a ld hl, OBJECT_FLAGS1 @@ -292,7 +292,7 @@ InitStep: add a add a and %00001100 - ld hl, OBJECT_FACING + ld hl, OBJECT_DIRECTION add hl, bc ld [hl], a ; fallthrough @@ -304,26 +304,26 @@ GetNextTile: ld [hl], a ld a, d call GetStepVectorSign - ld hl, OBJECT_MAP_X + ld hl, OBJECT_LAST_MAP_X add hl, bc add [hl] - ld hl, OBJECT_NEXT_MAP_X + ld hl, OBJECT_MAP_X add hl, bc ld [hl], a ld d, a ld a, e call GetStepVectorSign - ld hl, OBJECT_MAP_Y + ld hl, OBJECT_LAST_MAP_Y add hl, bc add [hl] - ld hl, OBJECT_NEXT_MAP_Y + ld hl, OBJECT_MAP_Y add hl, bc ld [hl], a ld e, a push bc call GetCoordTile pop bc - ld hl, OBJECT_NEXT_TILE + ld hl, OBJECT_TILE add hl, bc ld [hl], a ret @@ -344,7 +344,7 @@ AddStepVector: GetStepVector: ; Return (x, y, duration, speed) in (d, e, a, h). - ld hl, OBJECT_DIRECTION_WALKING + ld hl, OBJECT_WALKING add hl, bc ld a, [hl] and %00001111 @@ -389,7 +389,7 @@ GetStepVectorSign: ret ; -127 to -1 UpdatePlayerStep: - ld hl, OBJECT_DIRECTION_WALKING + ld hl, OBJECT_WALKING add hl, bc ld a, [hl] and %00000011 @@ -436,78 +436,78 @@ RestoreDefaultMovement: ld a, SPRITEMOVEDATA_STANDING_DOWN ret -ObjectMovementByte_ZeroAnonJumptableIndex: ; unreferenced - ld hl, OBJECT_MOVEMENT_BYTE_INDEX +ObjectMovement_ZeroAnonJumptableIndex: ; unreferenced + ld hl, OBJECT_MOVEMENT_INDEX add hl, bc ld [hl], 0 ret -ObjectMovementByte_IncAnonJumptableIndex: - ld hl, OBJECT_MOVEMENT_BYTE_INDEX +ObjectMovement_IncAnonJumptableIndex: + ld hl, OBJECT_MOVEMENT_INDEX add hl, bc inc [hl] ret -ObjectMovementByte_DecAnonJumptableIndex: - ld hl, OBJECT_MOVEMENT_BYTE_INDEX +ObjectMovement_DecAnonJumptableIndex: + ld hl, OBJECT_MOVEMENT_INDEX add hl, bc dec [hl] ret -ObjectMovementByte_AnonJumptable: - ld hl, OBJECT_MOVEMENT_BYTE_INDEX +ObjectMovement_AnonJumptable: + ld hl, OBJECT_MOVEMENT_INDEX add hl, bc ld a, [hl] pop hl rst JumpTable ret -Field1c_ZeroAnonJumptableIndex: - ld hl, OBJECT_1C +ObjectStep_ZeroAnonJumptableIndex: + ld hl, OBJECT_STEP_INDEX add hl, bc ld [hl], 0 ret -Field1c_IncAnonJumptableIndex: - ld hl, OBJECT_1C +ObjectStep_IncAnonJumptableIndex: + ld hl, OBJECT_STEP_INDEX add hl, bc inc [hl] ret -Field1c_AnonJumptable: - ld hl, OBJECT_1C +ObjectStep_AnonJumptable: + ld hl, OBJECT_STEP_INDEX add hl, bc ld a, [hl] pop hl rst JumpTable ret -Field1c_GetAnonJumptableIndex: ; unreferenced - ld hl, OBJECT_1C +ObjectStep_GetAnonJumptableIndex: ; unreferenced + ld hl, OBJECT_STEP_INDEX add hl, bc ld a, [hl] ret -Field1c_SetAnonJumptableIndex: ; unreferenced - ld hl, OBJECT_1C +ObjectStep_SetAnonJumptableIndex: ; unreferenced + ld hl, OBJECT_STEP_INDEX add hl, bc ld [hl], a ret StepFunction_Reset: - ld hl, OBJECT_NEXT_MAP_X + ld hl, OBJECT_MAP_X add hl, bc ld d, [hl] - ld hl, OBJECT_NEXT_MAP_Y + ld hl, OBJECT_MAP_Y add hl, bc ld e, [hl] push bc call GetCoordTile pop bc - ld hl, OBJECT_NEXT_TILE + ld hl, OBJECT_TILE add hl, bc ld [hl], a - call CopyNextCoordsTileToStandingCoordsTile + call CopyCoordsTileToLastCoordsTile call EndSpriteMovement ld hl, OBJECT_STEP_TYPE add hl, bc @@ -515,7 +515,7 @@ StepFunction_Reset: ret StepFunction_FromMovement: - call Field1c_ZeroAnonJumptableIndex + call ObjectStep_ZeroAnonJumptableIndex call GetSpriteMovementFunction ld a, [hl] ld hl, .Pointers @@ -581,13 +581,13 @@ MovementFunction_RandomSpinSlow: call Random ldh a, [hRandomAdd] and %00001100 - ld hl, OBJECT_FACING + ld hl, OBJECT_DIRECTION add hl, bc ld [hl], a jp RandomStepDuration_Slow MovementFunction_RandomSpinFast: - ld hl, OBJECT_FACING + ld hl, OBJECT_DIRECTION add hl, bc ld a, [hl] and %00001100 @@ -603,7 +603,7 @@ MovementFunction_RandomSpinFast: jp RandomStepDuration_Fast MovementFunction_Standing: - call CopyStandingCoordsTileToNextCoordsTile + call CopyLastCoordsToCoords call EndSpriteMovement ld hl, OBJECT_ACTION add hl, bc @@ -614,15 +614,15 @@ MovementFunction_Standing: ret MovementFunction_ObeyDPad: - ld hl, GetPlayerNextMovementByte + ld hl, GetPlayerNextMovementIndex jp HandleMovementData MovementFunction_Indexed1: - ld hl, GetIndexedMovementByte1 + ld hl, GetIndexedMovementIndex1 jp HandleMovementData MovementFunction_Indexed2: - ld hl, GetIndexedMovementByte2 + ld hl, GetIndexedMovementIndex2 jp HandleMovementData MovementFunction_0a: @@ -635,28 +635,28 @@ MovementFunction_0c: jp _GetMovementObject MovementFunction_0d: - ld hl, GetPlayerNextMovementByte + ld hl, GetPlayerNextMovementIndex jp HandleMovementData MovementFunction_0e: jp _GetMovementObject MovementFunction_Follow: - ld hl, GetFollowerNextMovementByte + ld hl, GetFollowerNextMovementIndex jp HandleMovementData MovementFunction_Script: - ld hl, GetMovementByte + ld hl, GetMovementIndex jp HandleMovementData MovementFunction_Strength: - call ObjectMovementByte_AnonJumptable + call ObjectMovement_AnonJumptable .anon_dw dw .start dw .stop .start: - ld hl, OBJECT_NEXT_TILE + ld hl, OBJECT_TILE add hl, bc ld a, [hl] call CheckPitTile @@ -684,26 +684,26 @@ MovementFunction_Strength: ret .ok2 - call CopyStandingCoordsTileToNextCoordsTile + call CopyLastCoordsToCoords .ok - ld hl, OBJECT_DIRECTION_WALKING + ld hl, OBJECT_WALKING add hl, bc ld [hl], STANDING ret .on_pit - call ObjectMovementByte_IncAnonJumptableIndex + call ObjectMovement_IncAnonJumptableIndex .stop: - ld hl, OBJECT_DIRECTION_WALKING + ld hl, OBJECT_WALKING add hl, bc ld [hl], STANDING ret MovementFunction_FollowNotExact: - ld hl, OBJECT_NEXT_MAP_X + ld hl, OBJECT_MAP_X add hl, bc ld d, [hl] - ld hl, OBJECT_NEXT_MAP_Y + ld hl, OBJECT_MAP_Y add hl, bc ld e, [hl] ld hl, OBJECT_RANGE @@ -711,12 +711,12 @@ MovementFunction_FollowNotExact: ld a, [hl] push bc call GetObjectStruct - ld hl, OBJECT_DIRECTION_WALKING + ld hl, OBJECT_WALKING add hl, bc ld a, [hl] cp STANDING jr z, .standing - ld hl, OBJECT_MAP_X + ld hl, OBJECT_LAST_MAP_X add hl, bc ld a, [hl] cp d @@ -730,7 +730,7 @@ MovementFunction_FollowNotExact: jr .done .equal - ld hl, OBJECT_MAP_Y + ld hl, OBJECT_LAST_MAP_Y add hl, bc ld a, [hl] cp e @@ -743,7 +743,7 @@ MovementFunction_FollowNotExact: ld a, 1 .done ld d, a - ld hl, OBJECT_DIRECTION_WALKING + ld hl, OBJECT_WALKING add hl, bc ld a, [hl] and %00001100 @@ -753,7 +753,7 @@ MovementFunction_FollowNotExact: .standing pop bc - ld hl, OBJECT_DIRECTION_WALKING + ld hl, OBJECT_WALKING add hl, bc ld [hl], STANDING ld hl, OBJECT_ACTION @@ -763,7 +763,7 @@ MovementFunction_FollowNotExact: MovementFunction_BigStanding: call EndSpriteMovement - ld hl, OBJECT_DIRECTION_WALKING + ld hl, OBJECT_WALKING add hl, bc ld [hl], STANDING ld hl, OBJECT_ACTION @@ -776,7 +776,7 @@ MovementFunction_BigStanding: MovementFunction_Bouncing: call EndSpriteMovement - ld hl, OBJECT_DIRECTION_WALKING + ld hl, OBJECT_WALKING add hl, bc ld [hl], STANDING ld hl, OBJECT_ACTION @@ -788,14 +788,14 @@ MovementFunction_Bouncing: ret MovementFunction_SpinCounterclockwise: - call ObjectMovementByte_AnonJumptable + call ObjectMovement_AnonJumptable .anon_dw dw _MovementSpinInit dw _MovementSpinRepeat dw _MovementSpinTurnLeft MovementFunction_SpinClockwise: - call ObjectMovementByte_AnonJumptable + call ObjectMovement_AnonJumptable .anon_dw dw _MovementSpinInit dw _MovementSpinRepeat @@ -803,7 +803,7 @@ MovementFunction_SpinClockwise: _MovementSpinInit: call EndSpriteMovement - call ObjectMovementByte_IncAnonJumptableIndex + call ObjectMovement_IncAnonJumptableIndex ; fallthrough _MovementSpinRepeat: @@ -820,7 +820,7 @@ _MovementSpinRepeat: ld hl, OBJECT_STEP_TYPE add hl, bc ld [hl], STEP_TYPE_SLEEP - call ObjectMovementByte_IncAnonJumptableIndex + call ObjectMovement_IncAnonJumptableIndex ret _MovementSpinTurnLeft: @@ -846,7 +846,7 @@ _MovementSpinTurnRight: db OW_DOWN _MovementSpinNextFacing: - ld hl, OBJECT_FACING + ld hl, OBJECT_DIRECTION add hl, bc ld a, [hl] and %00001100 @@ -859,7 +859,7 @@ _MovementSpinNextFacing: ld a, [hl] pop hl ld [hl], a - call ObjectMovementByte_DecAnonJumptableIndex + call ObjectMovement_DecAnonJumptableIndex ret MovementFunction_Shadow: @@ -876,7 +876,7 @@ MovementFunction_Shadow: ld hl, OBJECT_STEP_DURATION add hl, bc ld [hl], a - ld hl, OBJECT_DIRECTION_WALKING + ld hl, OBJECT_WALKING add hl, de ld a, [hl] maskbits NUM_DIRECTIONS @@ -932,7 +932,7 @@ MovementFunction_BoulderDust: ld hl, OBJECT_STEP_DURATION add hl, bc ld [hl], a - ld hl, OBJECT_DIRECTION_WALKING + ld hl, OBJECT_WALKING add hl, de ld a, [hl] and %00000011 @@ -992,7 +992,7 @@ InitMovementField1dField1e: ld hl, OBJECT_1D add hl, bc ld [hl], e - inc hl + inc hl ; OBJECT_1E ld [hl], d ret @@ -1058,7 +1058,7 @@ _RandomWalkContinue: .new_duration: call EndSpriteMovement - call CopyStandingCoordsTileToNextCoordsTile + call CopyLastCoordsToCoords ; fallthrough RandomStepDuration_Slow: @@ -1075,7 +1075,7 @@ _SetRandomStepDuration: ld hl, OBJECT_STEP_DURATION add hl, bc ld [hl], a - ld hl, OBJECT_DIRECTION_WALKING + ld hl, OBJECT_WALKING add hl, bc ld [hl], STANDING ld hl, OBJECT_ACTION @@ -1128,7 +1128,7 @@ WaitStep_InPlace: ret StepFunction_NPCJump: - call Field1c_AnonJumptable + call ObjectStep_AnonJumptable .anon_dw dw .Jump dw .Land @@ -1140,12 +1140,12 @@ StepFunction_NPCJump: add hl, bc dec [hl] ret nz - call CopyNextCoordsTileToStandingCoordsTile + call CopyCoordsTileToLastCoordsTile call GetNextTile ld hl, OBJECT_FLAGS2 add hl, bc res OVERHEAD_F, [hl] - call Field1c_IncAnonJumptableIndex + call ObjectStep_IncAnonJumptableIndex ret .Land: @@ -1155,14 +1155,14 @@ StepFunction_NPCJump: add hl, bc dec [hl] ret nz - call CopyNextCoordsTileToStandingCoordsTile + call CopyCoordsTileToLastCoordsTile ld hl, OBJECT_STEP_TYPE add hl, bc ld [hl], STEP_TYPE_FROM_MOVEMENT ret StepFunction_PlayerJump: - call Field1c_AnonJumptable + call ObjectStep_AnonJumptable .anon_dw dw .initjump dw .stepjump @@ -1172,7 +1172,7 @@ StepFunction_PlayerJump: .initjump ld hl, wPlayerStepFlags set PLAYERSTEP_START_F, [hl] - call Field1c_IncAnonJumptableIndex + call ObjectStep_IncAnonJumptableIndex .stepjump call UpdateJumpPosition call UpdatePlayerStep @@ -1180,21 +1180,21 @@ StepFunction_PlayerJump: add hl, bc dec [hl] ret nz - call CopyNextCoordsTileToStandingCoordsTile + call CopyCoordsTileToLastCoordsTile ld hl, OBJECT_FLAGS2 add hl, bc res OVERHEAD_F, [hl] ld hl, wPlayerStepFlags set PLAYERSTEP_STOP_F, [hl] set PLAYERSTEP_MIDAIR_F, [hl] - call Field1c_IncAnonJumptableIndex + call ObjectStep_IncAnonJumptableIndex ret .initland call GetNextTile ld hl, wPlayerStepFlags set PLAYERSTEP_START_F, [hl] - call Field1c_IncAnonJumptableIndex + call ObjectStep_IncAnonJumptableIndex .stepland call UpdateJumpPosition call UpdatePlayerStep @@ -1204,14 +1204,14 @@ StepFunction_PlayerJump: ret nz ld hl, wPlayerStepFlags set PLAYERSTEP_STOP_F, [hl] - call CopyNextCoordsTileToStandingCoordsTile + call CopyCoordsTileToLastCoordsTile ld hl, OBJECT_STEP_TYPE add hl, bc ld [hl], STEP_TYPE_FROM_MOVEMENT ret StepFunction_TeleportFrom: - call Field1c_AnonJumptable + call ObjectStep_AnonJumptable .anon_dw dw .InitSpin dw .DoSpin @@ -1225,7 +1225,7 @@ StepFunction_TeleportFrom: ld hl, OBJECT_STEP_DURATION add hl, bc ld [hl], 16 - call Field1c_IncAnonJumptableIndex + call ObjectStep_IncAnonJumptableIndex .DoSpin: ld hl, OBJECT_ACTION add hl, bc @@ -1234,14 +1234,14 @@ StepFunction_TeleportFrom: add hl, bc dec [hl] ret nz - call Field1c_IncAnonJumptableIndex + call ObjectStep_IncAnonJumptableIndex ret .InitSpinRise: ld hl, OBJECT_STEP_FRAME add hl, bc ld [hl], 0 - ld hl, OBJECT_1F + ld hl, OBJECT_JUMP_HEIGHT add hl, bc ld [hl], $10 ld hl, OBJECT_STEP_DURATION @@ -1250,12 +1250,12 @@ StepFunction_TeleportFrom: ld hl, OBJECT_FLAGS2 add hl, bc res OVERHEAD_F, [hl] - call Field1c_IncAnonJumptableIndex + call ObjectStep_IncAnonJumptableIndex .DoSpinRise: ld hl, OBJECT_ACTION add hl, bc ld [hl], OBJECT_ACTION_SPIN - ld hl, OBJECT_1F + ld hl, OBJECT_JUMP_HEIGHT add hl, bc inc [hl] ld a, [hl] @@ -1279,7 +1279,7 @@ StepFunction_TeleportFrom: ret StepFunction_TeleportTo: - call Field1c_AnonJumptable + call ObjectStep_AnonJumptable .anon_dw dw .InitWait dw .DoWait @@ -1296,7 +1296,7 @@ StepFunction_TeleportTo: ld hl, OBJECT_STEP_DURATION add hl, bc ld [hl], 16 - call Field1c_IncAnonJumptableIndex + call ObjectStep_IncAnonJumptableIndex ret .DoWait: @@ -1304,25 +1304,25 @@ StepFunction_TeleportTo: add hl, bc dec [hl] ret nz - call Field1c_IncAnonJumptableIndex + call ObjectStep_IncAnonJumptableIndex .InitDescent: ld hl, OBJECT_STEP_FRAME add hl, bc ld [hl], 0 - ld hl, OBJECT_1F + ld hl, OBJECT_JUMP_HEIGHT add hl, bc ld [hl], 0 ld hl, OBJECT_STEP_DURATION add hl, bc ld [hl], 16 - call Field1c_IncAnonJumptableIndex + call ObjectStep_IncAnonJumptableIndex ret .DoDescent: ld hl, OBJECT_ACTION add hl, bc ld [hl], OBJECT_ACTION_SPIN - ld hl, OBJECT_1F + ld hl, OBJECT_JUMP_HEIGHT add hl, bc inc [hl] ld a, [hl] @@ -1337,12 +1337,12 @@ StepFunction_TeleportTo: add hl, bc dec [hl] ret nz - call Field1c_IncAnonJumptableIndex + call ObjectStep_IncAnonJumptableIndex .InitFinalSpin: ld hl, OBJECT_STEP_DURATION add hl, bc ld [hl], 16 - call Field1c_IncAnonJumptableIndex + call ObjectStep_IncAnonJumptableIndex ret .DoFinalSpin: @@ -1366,7 +1366,7 @@ StepFunction_TeleportTo: ret StepFunction_Skyfall: - call Field1c_AnonJumptable + call ObjectStep_AnonJumptable .anon_dw dw .Init dw .Step @@ -1380,7 +1380,7 @@ StepFunction_Skyfall: ld hl, OBJECT_STEP_DURATION add hl, bc ld [hl], 16 - call Field1c_IncAnonJumptableIndex + call ObjectStep_IncAnonJumptableIndex .Step: ld hl, OBJECT_STEP_DURATION add hl, bc @@ -1392,15 +1392,15 @@ StepFunction_Skyfall: ld hl, OBJECT_STEP_FRAME add hl, bc ld [hl], 0 - ld hl, OBJECT_1F + ld hl, OBJECT_JUMP_HEIGHT add hl, bc ld [hl], 0 ld hl, OBJECT_STEP_DURATION add hl, bc ld [hl], 16 - call Field1c_IncAnonJumptableIndex + call ObjectStep_IncAnonJumptableIndex .Fall: - ld hl, OBJECT_1F + ld hl, OBJECT_JUMP_HEIGHT add hl, bc inc [hl] ld a, [hl] @@ -1415,7 +1415,7 @@ StepFunction_Skyfall: add hl, bc dec [hl] ret nz - call Field1c_IncAnonJumptableIndex + call ObjectStep_IncAnonJumptableIndex .Finish: ld hl, OBJECT_STEP_FRAME add hl, bc @@ -1429,7 +1429,7 @@ StepFunction_Skyfall: ret StepFunction_GotBite: - call Field1c_AnonJumptable + call ObjectStep_AnonJumptable .anon_dw dw .Init dw .Run @@ -1441,7 +1441,7 @@ StepFunction_GotBite: ld hl, OBJECT_SPRITE_Y_OFFSET add hl, bc ld [hl], 0 - call Field1c_IncAnonJumptableIndex + call ObjectStep_IncAnonJumptableIndex .Run: ld hl, OBJECT_SPRITE_Y_OFFSET add hl, bc @@ -1493,7 +1493,7 @@ StepFunction_DigTo: jp WaitStep_InPlace StepFunction_Sleep: - ld hl, OBJECT_DIRECTION_WALKING + ld hl, OBJECT_WALKING add hl, bc ld [hl], STANDING ld hl, OBJECT_STEP_DURATION @@ -1506,7 +1506,7 @@ StepFunction_Sleep: ret StepFunction_Delete: - ld hl, OBJECT_DIRECTION_WALKING + ld hl, OBJECT_WALKING add hl, bc ld [hl], STANDING ld hl, OBJECT_STEP_DURATION @@ -1526,7 +1526,7 @@ StepFunction_Bump: ret StepFunction_Restore: - call Field1c_AnonJumptable + call ObjectStep_AnonJumptable .anon_dw dw .Reset dw StepFunction_Standing @@ -1534,15 +1534,15 @@ StepFunction_Restore: .Reset: call RestoreDefaultMovement call GetInitialFacing - ld hl, OBJECT_FACING + ld hl, OBJECT_DIRECTION add hl, bc ld [hl], a - call Field1c_IncAnonJumptableIndex + call ObjectStep_IncAnonJumptableIndex ; fallthrough StepFunction_Standing: call Stubbed_UpdateYOffset - ld hl, OBJECT_DIRECTION_WALKING + ld hl, OBJECT_WALKING add hl, bc ld [hl], STANDING ret @@ -1554,8 +1554,8 @@ StepFunction_NPCWalk: add hl, bc dec [hl] ret nz - call CopyNextCoordsTileToStandingCoordsTile - ld hl, OBJECT_DIRECTION_WALKING + call CopyCoordsTileToLastCoordsTile + ld hl, OBJECT_WALKING add hl, bc ld [hl], STANDING ld hl, OBJECT_STEP_TYPE @@ -1569,11 +1569,11 @@ StepFunction_ContinueWalk: add hl, bc dec [hl] ret nz - call CopyNextCoordsTileToStandingCoordsTile + call CopyCoordsTileToLastCoordsTile jp RandomStepDuration_Slow StepFunction_PlayerWalk: - call Field1c_AnonJumptable + call ObjectStep_AnonJumptable .anon_dw dw .init dw .step @@ -1581,7 +1581,7 @@ StepFunction_PlayerWalk: .init ld hl, wPlayerStepFlags set PLAYERSTEP_START_F, [hl] - call Field1c_IncAnonJumptableIndex + call ObjectStep_IncAnonJumptableIndex .step call UpdatePlayerStep ld hl, OBJECT_STEP_DURATION @@ -1590,8 +1590,8 @@ StepFunction_PlayerWalk: ret nz ld hl, wPlayerStepFlags set PLAYERSTEP_STOP_F, [hl] - call CopyNextCoordsTileToStandingCoordsTile - ld hl, OBJECT_DIRECTION_WALKING + call CopyCoordsTileToLastCoordsTile + ld hl, OBJECT_WALKING add hl, bc ld [hl], STANDING ld hl, OBJECT_STEP_TYPE @@ -1600,7 +1600,7 @@ StepFunction_PlayerWalk: ret StepFunction_Turn: - call Field1c_AnonJumptable + call ObjectStep_AnonJumptable .anon_dw dw .init1 dw .step1 @@ -1608,7 +1608,7 @@ StepFunction_Turn: dw .step2 .init1 - ld hl, OBJECT_DIRECTION_WALKING + ld hl, OBJECT_WALKING add hl, bc ld [hl], STANDING ld hl, OBJECT_STEP_FRAME @@ -1618,24 +1618,24 @@ StepFunction_Turn: ld hl, OBJECT_STEP_DURATION add hl, bc ld [hl], 2 - call Field1c_IncAnonJumptableIndex + call ObjectStep_IncAnonJumptableIndex .step1 ld hl, OBJECT_STEP_DURATION add hl, bc dec [hl] ret nz - call Field1c_IncAnonJumptableIndex + call ObjectStep_IncAnonJumptableIndex .init2 ld hl, OBJECT_1D ; new facing add hl, bc ld a, [hl] - ld hl, OBJECT_FACING + ld hl, OBJECT_DIRECTION add hl, bc ld [hl], a ld hl, OBJECT_STEP_DURATION add hl, bc ld [hl], 2 - call Field1c_IncAnonJumptableIndex + call ObjectStep_IncAnonJumptableIndex .step2 ld hl, OBJECT_STEP_DURATION add hl, bc @@ -1653,10 +1653,10 @@ StepFunction_StrengthBoulder: dec [hl] ret nz push bc - ld hl, OBJECT_NEXT_MAP_X + ld hl, OBJECT_MAP_X add hl, bc ld d, [hl] - ld hl, OBJECT_NEXT_MAP_Y + ld hl, OBJECT_MAP_Y add hl, bc ld e, [hl] ld hl, OBJECT_MAP_OBJECT_INDEX @@ -1668,8 +1668,8 @@ StepFunction_StrengthBoulder: ld hl, OBJECT_FLAGS2 add hl, bc res OBJ_FLAGS2_2, [hl] - call CopyNextCoordsTileToStandingCoordsTile - ld hl, OBJECT_DIRECTION_WALKING + call CopyCoordsTileToLastCoordsTile + ld hl, OBJECT_WALKING add hl, bc ld [hl], STANDING ld hl, OBJECT_STEP_TYPE @@ -1712,7 +1712,7 @@ StepFunction_TrackingObject: StepFunction_14: StepFunction_ScreenShake: - call Field1c_AnonJumptable + call ObjectStep_AnonJumptable .anon_dw dw .Init dw .Run @@ -1722,7 +1722,7 @@ StepFunction_ScreenShake: ld hl, OBJECT_1D add hl, bc ld [hl], a - call Field1c_IncAnonJumptableIndex + call ObjectStep_IncAnonJumptableIndex .Run: ld hl, OBJECT_1D add hl, bc @@ -1760,11 +1760,11 @@ StepFunction_ScreenShake: ret StepFunction_16: - call Field1c_AnonJumptable + call ObjectStep_AnonJumptable ; jumptable was dummied out here StepFunction_17: - call Field1c_AnonJumptable + call ObjectStep_AnonJumptable .anon_dw dw .null dw .null @@ -1772,7 +1772,7 @@ StepFunction_17: .null StepFunction_SkyfallTop: - call Field1c_AnonJumptable + call ObjectStep_AnonJumptable .anon_dw dw .Init dw .Run @@ -1784,7 +1784,7 @@ StepFunction_SkyfallTop: ld hl, OBJECT_STEP_DURATION add hl, bc ld [hl], 16 - call Field1c_IncAnonJumptableIndex + call ObjectStep_IncAnonJumptableIndex .Run: ld hl, OBJECT_STEP_DURATION @@ -1828,7 +1828,7 @@ Stubbed_UpdateYOffset: UpdateJumpPosition: call GetStepVector ld a, h - ld hl, OBJECT_1F + ld hl, OBJECT_JUMP_HEIGHT add hl, bc ld e, [hl] add e @@ -1848,7 +1848,7 @@ UpdateJumpPosition: db -4, -6, -8, -10, -11, -12, -12, -12 db -11, -10, -9, -8, -6, -4, 0, 0 -GetPlayerNextMovementByte: +GetPlayerNextMovementIndex: ; copy [wPlayerNextMovement] to [wPlayerMovement] ld a, [wPlayerNextMovement] ld hl, wPlayerMovement @@ -1860,13 +1860,13 @@ GetPlayerNextMovementByte: ld a, [hl] ret -GetMovementByte: +GetMovementIndex: ld hl, wMovementDataBank - call _GetMovementByte + call _GetMovementIndex ret -GetIndexedMovementByte1: - ld hl, OBJECT_MOVEMENT_BYTE_INDEX +GetIndexedMovementIndex1: + ld hl, OBJECT_MOVEMENT_INDEX add hl, bc ld e, [hl] inc [hl] @@ -1879,8 +1879,8 @@ GetIndexedMovementByte1: ld a, [hl] ret -GetIndexedMovementByte2: - ld hl, OBJECT_MOVEMENT_BYTE_INDEX +GetIndexedMovementIndex2: + ld hl, OBJECT_MOVEMENT_INDEX add hl, bc ld e, [hl] inc [hl] @@ -1905,10 +1905,10 @@ HandleMovementData: call .StorePointer .loop xor a - ld [wMovementByteWasControlSwitch], a + ld [wContinueReadingMovement], a call JumpMovementPointer call DoMovementFunction - ld a, [wMovementByteWasControlSwitch] + ld a, [wContinueReadingMovement] and a jr nz, .loop ret @@ -1928,8 +1928,8 @@ JumpMovementPointer: jp hl ContinueReadingMovement: - ld a, 1 - ld [wMovementByteWasControlSwitch], a + ld a, TRUE + ld [wContinueReadingMovement], a ret DoMovementFunction: @@ -1974,7 +1974,7 @@ ApplyMovementToFollower: ld [hl], a ret -GetFollowerNextMovementByte: +GetFollowerNextMovementIndex: ld hl, wFollowerMovementQueueLength ld a, [hl] and a @@ -2152,10 +2152,10 @@ CopyTempObjectData: ldh a, [hMapObjectIndex] ld [hli], a push hl - ld hl, OBJECT_NEXT_MAP_X + ld hl, OBJECT_MAP_X add hl, bc ld d, [hl] - ld hl, OBJECT_NEXT_MAP_Y + ld hl, OBJECT_MAP_Y add hl, bc ld e, [hl] pop hl @@ -2251,7 +2251,7 @@ UpdateObjectFrozen: jr c, SetFacing_Standing call CheckObjectOnScreen jr c, SetFacing_Standing - call UpdateObjectNextTile + call UpdateObjectTile farcall HandleFrozenObjectAction ; no need to farcall xor a ret @@ -2264,33 +2264,33 @@ UpdateRespawnedObjectFrozen: ret SetFacing_Standing: - ld hl, OBJECT_FACING_STEP + ld hl, OBJECT_FACING add hl, bc ld [hl], STANDING scf ret -UpdateObjectNextTile: +UpdateObjectTile: push bc - ld hl, OBJECT_NEXT_MAP_X + ld hl, OBJECT_MAP_X add hl, bc ld d, [hl] - ld hl, OBJECT_NEXT_MAP_Y + ld hl, OBJECT_MAP_Y add hl, bc ld e, [hl] call GetCoordTile pop bc - ld hl, OBJECT_NEXT_TILE + ld hl, OBJECT_TILE add hl, bc ld [hl], a farcall UpdateTallGrassFlags ; no need to farcall ret CheckObjectOnScreen: - ld hl, OBJECT_NEXT_MAP_X + ld hl, OBJECT_MAP_X add hl, bc ld d, [hl] - ld hl, OBJECT_NEXT_MAP_Y + ld hl, OBJECT_MAP_Y add hl, bc ld e, [hl] inc d @@ -2477,7 +2477,7 @@ RefreshPlayerSprite: ld [wPlayerMovement], a xor a ld [wPlayerTurningDirection], a - ld [wPlayerObjectStepFrame], a + ld [wPlayerStepFrame], a call TryResetPlayerAction farcall CheckWarpFacingDown call c, SpawnInFacingDown @@ -2517,7 +2517,7 @@ _SetPlayerPalette: and 1 << 7 ret z ld bc, 0 ; debug? - ld hl, OBJECT_FACING + ld hl, OBJECT_DIRECTION add hl, bc ld a, [hl] or d @@ -2569,7 +2569,7 @@ SetFollowerIfVisible: pop af call CheckObjectVisibility ret c - ld hl, OBJECT_MOVEMENTTYPE + ld hl, OBJECT_MOVEMENT_TYPE add hl, bc ld [hl], SPRITEMOVEDATA_FOLLOWING ld hl, OBJECT_STEP_TYPE @@ -2696,7 +2696,7 @@ ResetObject: add hl, bc ld a, [hl] pop bc - ld hl, OBJECT_MOVEMENTTYPE + ld hl, OBJECT_MOVEMENT_TYPE add hl, bc ld [hl], a ld hl, OBJECT_STEP_TYPE @@ -2713,7 +2713,7 @@ ResetObject: ld hl, .standing_movefns add hl, de ld a, [hl] - ld hl, OBJECT_MOVEMENTTYPE + ld hl, OBJECT_MOVEMENT_TYPE add hl, bc ld [hl], a ld hl, OBJECT_STEP_TYPE @@ -2831,7 +2831,7 @@ InitSprites: push hl call DoesObjectHaveASprite jr z, .skip - ld hl, OBJECT_FACING_STEP + ld hl, OBJECT_FACING add hl, bc ld a, [hl] cp STANDING @@ -2948,7 +2948,7 @@ InitSprites: ld a, [wPlayerBGMapOffsetY] add e ldh [hCurSpriteYPixel], a - ld hl, OBJECT_FACING_STEP + ld hl, OBJECT_FACING add hl, bc ld a, [hl] cp STANDING diff --git a/engine/overworld/movement.asm b/engine/overworld/movement.asm index 6a8e242b0..3129e186e 100644 --- a/engine/overworld/movement.asm +++ b/engine/overworld/movement.asm @@ -134,7 +134,7 @@ Movement_step_dig: ld hl, OBJECT_STEP_TYPE add hl, bc ld [hl], STEP_TYPE_SLEEP - ld hl, OBJECT_DIRECTION_WALKING + ld hl, OBJECT_WALKING add hl, bc ld [hl], STANDING ret @@ -150,7 +150,7 @@ Movement_return_dig: ld hl, OBJECT_STEP_DURATION add hl, bc ld [hl], a - ld hl, OBJECT_DIRECTION_WALKING + ld hl, OBJECT_WALKING add hl, bc ld [hl], STANDING ld hl, OBJECT_STEP_TYPE @@ -190,18 +190,18 @@ Movement_fish_cast_rod: ret Movement_step_loop: - ld hl, OBJECT_MOVEMENT_BYTE_INDEX + ld hl, OBJECT_MOVEMENT_INDEX add hl, bc ld [hl], $0 jp ContinueReadingMovement Movement_step_end: call RestoreDefaultMovement - ld hl, OBJECT_MOVEMENTTYPE + ld hl, OBJECT_MOVEMENT_TYPE add hl, bc ld [hl], a - ld hl, OBJECT_MOVEMENT_BYTE_INDEX + ld hl, OBJECT_MOVEMENT_INDEX add hl, bc ld [hl], $0 @@ -215,11 +215,11 @@ Movement_step_end: Movement_48: call RestoreDefaultMovement - ld hl, OBJECT_MOVEMENTTYPE + ld hl, OBJECT_MOVEMENT_TYPE add hl, bc ld [hl], a - ld hl, OBJECT_MOVEMENT_BYTE_INDEX + ld hl, OBJECT_MOVEMENT_INDEX add hl, bc ld [hl], $0 @@ -314,7 +314,7 @@ Movement_step_sleep_common: add hl, bc ld [hl], OBJECT_ACTION_STAND - ld hl, OBJECT_DIRECTION_WALKING + ld hl, OBJECT_WALKING add hl, bc ld [hl], STANDING ret @@ -333,7 +333,7 @@ Movement_step_bump: add hl, bc ld [hl], OBJECT_ACTION_BUMP - ld hl, OBJECT_DIRECTION_WALKING + ld hl, OBJECT_WALKING add hl, bc ld [hl], STANDING ret @@ -352,7 +352,7 @@ Movement_tree_shake: add hl, bc ld [hl], OBJECT_ACTION_WEIRD_TREE - ld hl, OBJECT_DIRECTION_WALKING + ld hl, OBJECT_WALKING add hl, bc ld [hl], STANDING ret @@ -426,7 +426,7 @@ Movement_turn_head_right: jr TurnHead TurnHead: - ld hl, OBJECT_FACING + ld hl, OBJECT_DIRECTION add hl, bc ld [hl], a @@ -434,7 +434,7 @@ TurnHead: add hl, bc ld [hl], OBJECT_ACTION_STAND - ld hl, OBJECT_DIRECTION_WALKING + ld hl, OBJECT_WALKING add hl, bc ld [hl], STANDING ret @@ -668,7 +668,7 @@ NormalStep: add hl, bc ld [hl], OBJECT_ACTION_STEP - ld hl, OBJECT_NEXT_TILE + ld hl, OBJECT_TILE add hl, bc ld a, [hl] call CheckSuperTallGrassTile @@ -747,7 +747,7 @@ SlideStep: JumpStep: call InitStep - ld hl, OBJECT_1F + ld hl, OBJECT_JUMP_HEIGHT add hl, bc ld [hl], $0 diff --git a/engine/overworld/npc_movement.asm b/engine/overworld/npc_movement.asm index 27fc39a7d..a47bdc44d 100644 --- a/engine/overworld/npc_movement.asm +++ b/engine/overworld/npc_movement.asm @@ -60,17 +60,17 @@ CanObjectMoveInDirection: WillObjectBumpIntoWater: call CanObjectLeaveTile ret c - ld hl, OBJECT_NEXT_MAP_X + ld hl, OBJECT_MAP_X add hl, bc ld d, [hl] - ld hl, OBJECT_NEXT_MAP_Y + ld hl, OBJECT_MAP_Y add hl, bc ld e, [hl] ld hl, OBJECT_PALETTE add hl, bc bit OAM_PRIORITY, [hl] jp nz, WillObjectRemainOnWater - ld hl, OBJECT_NEXT_TILE + ld hl, OBJECT_TILE add hl, bc ld a, [hl] ld d, a @@ -83,7 +83,7 @@ WillObjectBumpIntoWater: WillObjectBumpIntoLand: call CanObjectLeaveTile ret c - ld hl, OBJECT_NEXT_TILE + ld hl, OBJECT_TILE add hl, bc ld a, [hl] call GetTileCollision @@ -93,13 +93,13 @@ WillObjectBumpIntoLand: ret WillObjectBumpIntoTile: - ld hl, OBJECT_NEXT_TILE + ld hl, OBJECT_TILE add hl, bc ld a, [hl] call GetSideWallDirectionMask ret nc push af - ld hl, OBJECT_DIRECTION_WALKING + ld hl, OBJECT_WALKING add hl, bc ld a, [hl] maskbits NUM_DIRECTIONS @@ -120,13 +120,13 @@ WillObjectBumpIntoTile: db LEFT_MASK ; RIGHT CanObjectLeaveTile: - ld hl, OBJECT_STANDING_TILE + ld hl, OBJECT_LAST_TILE add hl, bc ld a, [hl] call GetSideWallDirectionMask ret nc push af - ld hl, OBJECT_DIRECTION_WALKING + ld hl, OBJECT_WALKING add hl, bc maskbits NUM_DIRECTIONS ld e, a @@ -177,7 +177,7 @@ GetSideWallDirectionMask: db DOWN_MASK | LEFT_MASK ; COLL_UP_LEFT_WALL/BUOY WillObjectRemainOnWater: - ld hl, OBJECT_DIRECTION_WALKING + ld hl, OBJECT_WALKING add hl, bc ld a, [hl] maskbits NUM_DIRECTIONS @@ -233,14 +233,14 @@ CheckFacingObject:: call CheckCounterTile jr nz, .not_counter - ld a, [wPlayerStandingMapX] + ld a, [wPlayerMapX] sub d cpl inc a add d ld d, a - ld a, [wPlayerStandingMapY] + ld a, [wPlayerMapY] sub e cpl inc a @@ -253,7 +253,7 @@ CheckFacingObject:: ldh [hMapObjectIndex], a call IsNPCAtCoord ret nc - ld hl, OBJECT_DIRECTION_WALKING + ld hl, OBJECT_WALKING add hl, bc ld a, [hl] cp STANDING @@ -266,10 +266,10 @@ CheckFacingObject:: ret WillObjectBumpIntoSomeoneElse: - ld hl, OBJECT_NEXT_MAP_X + ld hl, OBJECT_MAP_X add hl, bc ld d, [hl] - ld hl, OBJECT_NEXT_MAP_Y + ld hl, OBJECT_MAP_Y add hl, bc ld e, [hl] jr IsNPCAtCoord @@ -282,10 +282,10 @@ IsObjectFacingSomeoneElse: ; unreferenced ret .GetFacingCoords: - ld hl, OBJECT_NEXT_MAP_X + ld hl, OBJECT_MAP_X add hl, bc ld d, [hl] - ld hl, OBJECT_NEXT_MAP_Y + ld hl, OBJECT_MAP_Y add hl, bc ld e, [hl] call GetSpriteDirection @@ -333,12 +333,12 @@ IsNPCAtCoord: jr .continue .not_big - ld hl, OBJECT_NEXT_MAP_X + ld hl, OBJECT_MAP_X add hl, bc ld a, [hl] cp d jr nz, .check_current_coords - ld hl, OBJECT_NEXT_MAP_Y + ld hl, OBJECT_MAP_Y add hl, bc ld a, [hl] cp e @@ -352,12 +352,12 @@ IsNPCAtCoord: jr nz, .yes .check_current_coords - ld hl, OBJECT_MAP_X + ld hl, OBJECT_LAST_MAP_X add hl, bc ld a, [hl] cp d jr nz, .next - ld hl, OBJECT_MAP_Y + ld hl, OBJECT_LAST_MAP_Y add hl, bc ld a, [hl] cp e @@ -402,7 +402,7 @@ HasObjectReachedMovementLimit: ld a, [hl] add e ld e, a - ld hl, OBJECT_NEXT_MAP_X + ld hl, OBJECT_MAP_X add hl, bc ld a, [hl] cp d @@ -427,7 +427,7 @@ HasObjectReachedMovementLimit: ld a, [hl] add e ld e, a - ld hl, OBJECT_NEXT_MAP_Y + ld hl, OBJECT_MAP_Y add hl, bc ld a, [hl] cp d @@ -444,7 +444,7 @@ HasObjectReachedMovementLimit: ret IsObjectMovingOffEdgeOfScreen: - ld hl, OBJECT_NEXT_MAP_X + ld hl, OBJECT_MAP_X add hl, bc ld a, [wXCoord] cp [hl] @@ -455,7 +455,7 @@ IsObjectMovingOffEdgeOfScreen: jr c, .yes .check_y - ld hl, OBJECT_NEXT_MAP_Y + ld hl, OBJECT_MAP_Y add hl, bc ld a, [wYCoord] cp [hl] @@ -474,9 +474,9 @@ IsObjectMovingOffEdgeOfScreen: ret IsNPCAtPlayerCoord: ; unreferenced - ld a, [wPlayerStandingMapX] + ld a, [wPlayerMapX] ld d, a - ld a, [wPlayerStandingMapY] + ld a, [wPlayerMapY] ld e, a ld bc, wObjectStructs xor a @@ -485,7 +485,7 @@ IsNPCAtPlayerCoord: ; unreferenced call DoesObjectHaveASprite jr z, .next - ld hl, OBJECT_MOVEMENTTYPE + ld hl, OBJECT_MOVEMENT_TYPE add hl, bc ld a, [hl] cp SPRITEMOVEDATA_BIGDOLLSYM @@ -495,12 +495,12 @@ IsNPCAtPlayerCoord: ; unreferenced jr .next .not_big - ld hl, OBJECT_NEXT_MAP_Y + ld hl, OBJECT_MAP_Y add hl, bc ld a, [hl] cp e jr nz, .check_current_coords - ld hl, OBJECT_NEXT_MAP_X + ld hl, OBJECT_MAP_X add hl, bc ld a, [hl] cp d @@ -511,12 +511,12 @@ IsNPCAtPlayerCoord: ; unreferenced jr .yes .check_current_coords - ld hl, OBJECT_MAP_Y + ld hl, OBJECT_LAST_MAP_Y add hl, bc ld a, [hl] cp e jr nz, .next - ld hl, OBJECT_MAP_X + ld hl, OBJECT_LAST_MAP_X add hl, bc ld a, [hl] cp d @@ -540,14 +540,14 @@ IsNPCAtPlayerCoord: ; unreferenced ret WillObjectIntersectBigObject: - ld hl, OBJECT_NEXT_MAP_X + ld hl, OBJECT_MAP_X add hl, bc ld a, d sub [hl] jr c, .nope cp 2 ; big doll width jr nc, .nope - ld hl, OBJECT_NEXT_MAP_Y + ld hl, OBJECT_MAP_Y add hl, bc ld a, e sub [hl] diff --git a/engine/overworld/player_movement.asm b/engine/overworld/player_movement.asm index 03ce82b58..b0654e0f2 100644 --- a/engine/overworld/player_movement.asm +++ b/engine/overworld/player_movement.asm @@ -114,7 +114,7 @@ DoPlayerMovement:: ; Tiles such as waterfalls and warps move the player ; in a given direction, overriding input. - ld a, [wPlayerStandingTile] + ld a, [wPlayerTile] ld c, a call CheckWhirlpoolTile jr c, .not_whirlpool @@ -270,7 +270,7 @@ DoPlayerMovement:: cp 2 jr z, .bump - ld a, [wPlayerStandingTile] + ld a, [wPlayerTile] call CheckIceTile jr nc, .ice @@ -352,7 +352,7 @@ DoPlayerMovement:: ret .TryJump: - ld a, [wPlayerStandingTile] + ld a, [wPlayerTile] ld e, a and $f0 cp HI_NYBBLE_LEDGES @@ -398,7 +398,7 @@ DoPlayerMovement:: ld d, 0 ld hl, .EdgeWarps add hl, de - ld a, [wPlayerStandingTile] + ld a, [wPlayerTile] cp [hl] jr nz, .not_warp @@ -603,7 +603,7 @@ ENDM .action_table: .action_table_1 - player_action STANDING, FACE_CURRENT, 0, 0, wPlayerStandingTile + player_action STANDING, FACE_CURRENT, 0, 0, wPlayerTile .action_table_1_end player_action RIGHT, FACE_RIGHT, 1, 0, wTileRight player_action LEFT, FACE_LEFT, -1, 0, wTileLeft @@ -617,13 +617,13 @@ ENDM ld a, 0 ldh [hMapObjectIndex], a ; Load the next X coordinate into d - ld a, [wPlayerStandingMapX] + ld a, [wPlayerMapX] ld d, a ld a, [wWalkingX] add d ld d, a ; Load the next Y coordinate into e - ld a, [wPlayerStandingMapY] + ld a, [wPlayerMapY] ld e, a ld a, [wWalkingY] add e @@ -651,7 +651,7 @@ ENDM bit BIKEFLAGS_STRENGTH_ACTIVE_F, [hl] jr z, .not_boulder - ld hl, OBJECT_DIRECTION_WALKING + ld hl, OBJECT_WALKING add hl, bc ld a, [hl] cp STANDING @@ -788,7 +788,7 @@ CheckStandingOnIce:: jr z, .not_ice cp $f0 jr z, .not_ice - ld a, [wPlayerStandingTile] + ld a, [wPlayerTile] call CheckIceTile jr nc, .yep ld a, [wPlayerState] diff --git a/engine/overworld/player_object.asm b/engine/overworld/player_object.asm index 5e701eabc..e63db20d9 100644 --- a/engine/overworld/player_object.asm +++ b/engine/overworld/player_object.asm @@ -87,10 +87,10 @@ WriteObjectXY:: call CheckObjectVisibility ret c - ld hl, OBJECT_NEXT_MAP_X + ld hl, OBJECT_MAP_X add hl, bc ld d, [hl] - ld hl, OBJECT_NEXT_MAP_Y + ld hl, OBJECT_MAP_Y add hl, bc ld e, [hl] ldh a, [hMapObjectIndex] @@ -103,7 +103,7 @@ RefreshPlayerCoords: ld a, [wXCoord] add 4 ld d, a - ld hl, wPlayerStandingMapX + ld hl, wPlayerMapX sub [hl] ld [hl], d ld hl, wMapObjects + MAPOBJECT_X_COORD @@ -114,7 +114,7 @@ RefreshPlayerCoords: ld a, [wYCoord] add 4 ld e, a - ld hl, wPlayerStandingMapY + ld hl, wPlayerMapY sub [hl] ld [hl], e ld hl, wMapObjects + MAPOBJECT_Y_COORD @@ -447,7 +447,7 @@ CopyTempObjectToObjectStruct: add hl, de ld [hl], STEP_TYPE_RESET - ld hl, OBJECT_FACING_STEP + ld hl, OBJECT_FACING add hl, de ld [hl], STANDING @@ -467,7 +467,7 @@ CopyTempObjectToObjectStruct: add hl, de ld [hl], a - ld hl, OBJECT_NEXT_MAP_Y + ld hl, OBJECT_MAP_Y add hl, de ld [hl], a @@ -486,7 +486,7 @@ CopyTempObjectToObjectStruct: ld hl, OBJECT_INIT_X add hl, de ld [hl], a - ld hl, OBJECT_NEXT_MAP_X + ld hl, OBJECT_MAP_X add hl, de ld [hl], a ld hl, wXCoord @@ -557,19 +557,19 @@ TrainerWalkToPlayer: call GetObjectStruct ; get last talked coords, load to bc - ld hl, OBJECT_NEXT_MAP_X + ld hl, OBJECT_MAP_X add hl, bc ld a, [hl] - ld hl, OBJECT_NEXT_MAP_Y + ld hl, OBJECT_MAP_Y add hl, bc ld c, [hl] ld b, a ; get player coords, load to de - ld hl, OBJECT_NEXT_MAP_X + ld hl, OBJECT_MAP_X add hl, de ld a, [hl] - ld hl, OBJECT_NEXT_MAP_Y + ld hl, OBJECT_MAP_Y add hl, de ld e, [hl] ld d, a @@ -618,15 +618,15 @@ FollowNotExact:: ret c ; object 2 is now in bc, object 1 is now in de - ld hl, OBJECT_NEXT_MAP_X + ld hl, OBJECT_MAP_X add hl, bc ld a, [hl] - ld hl, OBJECT_NEXT_MAP_Y + ld hl, OBJECT_MAP_Y add hl, bc ld c, [hl] ld b, a - ld hl, OBJECT_NEXT_MAP_X + ld hl, OBJECT_MAP_X add hl, de ld a, [hl] cp b @@ -640,7 +640,7 @@ FollowNotExact:: jr .continue .same_x - ld hl, OBJECT_NEXT_MAP_Y + ld hl, OBJECT_MAP_Y add hl, de ld a, [hl] cp c @@ -653,7 +653,7 @@ FollowNotExact:: dec c .continue - ld hl, OBJECT_NEXT_MAP_X + ld hl, OBJECT_MAP_X add hl, de ld [hl], b ld a, b @@ -666,7 +666,7 @@ FollowNotExact:: ld hl, OBJECT_SPRITE_X add hl, de ld [hl], a - ld hl, OBJECT_NEXT_MAP_Y + ld hl, OBJECT_MAP_Y add hl, de ld [hl], c ld a, c @@ -683,7 +683,7 @@ FollowNotExact:: ld hl, OBJECT_RANGE add hl, de ld [hl], a - ld hl, OBJECT_MOVEMENTTYPE + ld hl, OBJECT_MOVEMENT_TYPE add hl, de ld [hl], SPRITEMOVEDATA_FOLLOWNOTEXACT ld hl, OBJECT_STEP_TYPE @@ -721,10 +721,10 @@ GetRelativeFacing:: ; load the coordinates of object d into bc ld a, d call GetObjectStruct - ld hl, OBJECT_NEXT_MAP_X + ld hl, OBJECT_MAP_X add hl, bc ld a, [hl] - ld hl, OBJECT_NEXT_MAP_Y + ld hl, OBJECT_MAP_Y add hl, bc ld c, [hl] ld b, a @@ -732,10 +732,10 @@ GetRelativeFacing:: ; load the coordinates of object e into de ld a, e call GetObjectStruct - ld hl, OBJECT_NEXT_MAP_X + ld hl, OBJECT_MAP_X add hl, bc ld d, [hl] - ld hl, OBJECT_NEXT_MAP_Y + ld hl, OBJECT_MAP_Y add hl, bc ld e, [hl] pop bc @@ -813,15 +813,15 @@ QueueFollowerFirstStep: .QueueFirstStep: ld a, [wObjectFollow_Leader] call GetObjectStruct - ld hl, OBJECT_NEXT_MAP_X + ld hl, OBJECT_MAP_X add hl, bc ld d, [hl] - ld hl, OBJECT_NEXT_MAP_Y + ld hl, OBJECT_MAP_Y add hl, bc ld e, [hl] ld a, [wObjectFollow_Follower] call GetObjectStruct - ld hl, OBJECT_NEXT_MAP_X + ld hl, OBJECT_MAP_X add hl, bc ld a, d cp [hl] @@ -837,7 +837,7 @@ QueueFollowerFirstStep: ret .check_y - ld hl, OBJECT_NEXT_MAP_Y + ld hl, OBJECT_MAP_Y add hl, bc ld a, e cp [hl] diff --git a/engine/overworld/player_step.asm b/engine/overworld/player_step.asm index b035face1..7a65bb1f5 100644 --- a/engine/overworld/player_step.asm +++ b/engine/overworld/player_step.asm @@ -158,7 +158,7 @@ UpdateOverworldMap: or HIGH(vBGMap0) ld [wBGMapAnchor + 1], a .not_overflowed - ld hl, wMetatileStandingY + ld hl, wPlayerMetatileY inc [hl] ld a, [hl] cp 2 ; was 1 @@ -189,7 +189,7 @@ UpdateOverworldMap: or HIGH(vBGMap0) ld [wBGMapAnchor + 1], a .not_underflowed - ld hl, wMetatileStandingY + ld hl, wPlayerMetatileY dec [hl] ld a, [hl] cp -1 ; was 0 @@ -221,7 +221,7 @@ UpdateOverworldMap: and $1f or d ld [wBGMapAnchor], a - ld hl, wMetatileStandingX + ld hl, wPlayerMetatileX dec [hl] ld a, [hl] cp -1 @@ -250,7 +250,7 @@ UpdateOverworldMap: and $1f or d ld [wBGMapAnchor], a - ld hl, wMetatileStandingX + ld hl, wPlayerMetatileX inc [hl] ld a, [hl] cp 2 diff --git a/engine/overworld/tile_events.asm b/engine/overworld/tile_events.asm index bb566c997..d5d07c156 100644 --- a/engine/overworld/tile_events.asm +++ b/engine/overworld/tile_events.asm @@ -1,6 +1,6 @@ CheckWarpCollision:: ; Is this tile a warp? - ld a, [wPlayerStandingTile] + ld a, [wPlayerTile] cp COLL_PIT jr z, .warp cp COLL_PIT_68 @@ -18,7 +18,7 @@ CheckWarpCollision:: CheckDirectionalWarp:: ; If this is a directional warp, clear carry (press the designated button to warp). ; Else, set carry (immediate warp). - ld a, [wPlayerStandingTile] + ld a, [wPlayerTile] cp COLL_WARP_CARPET_DOWN jr z, .directional cp COLL_WARP_CARPET_LEFT @@ -37,7 +37,7 @@ CheckDirectionalWarp:: CheckWarpFacingDown: ld de, 1 ld hl, .blocks - ld a, [wPlayerStandingTile] + ld a, [wPlayerTile] call IsInArray ret @@ -54,7 +54,7 @@ CheckWarpFacingDown: db -1 CheckGrassCollision:: - ld a, [wPlayerStandingTile] + ld a, [wPlayerTile] ld hl, .blocks ld de, 1 call IsInArray @@ -90,7 +90,7 @@ CheckCutCollision: db -1 GetWarpSFX:: - ld a, [wPlayerStandingTile] + ld a, [wPlayerTile] ld de, SFX_ENTER_DOOR cp COLL_DOOR ret z diff --git a/engine/overworld/warp_connection.asm b/engine/overworld/warp_connection.asm index eebbc91cf..89d8437a1 100644 --- a/engine/overworld/warp_connection.asm +++ b/engine/overworld/warp_connection.asm @@ -346,7 +346,7 @@ CheckMovingOffEdgeOfMap:: ret .down - ld a, [wPlayerStandingMapY] + ld a, [wPlayerMapY] sub 4 ld b, a ld a, [wMapHeight] @@ -357,7 +357,7 @@ CheckMovingOffEdgeOfMap:: ret .up - ld a, [wPlayerStandingMapY] + ld a, [wPlayerMapY] sub 4 cp -1 jr z, .ok @@ -365,7 +365,7 @@ CheckMovingOffEdgeOfMap:: ret .left - ld a, [wPlayerStandingMapX] + ld a, [wPlayerMapX] sub 4 cp -1 jr z, .ok @@ -373,7 +373,7 @@ CheckMovingOffEdgeOfMap:: ret .right - ld a, [wPlayerStandingMapX] + ld a, [wPlayerMapX] sub 4 ld b, a ld a, [wMapWidth] @@ -425,8 +425,8 @@ GetMapScreenCoords:: ld [wOverworldMapAnchor + 1], a ld a, [wYCoord] and 1 - ld [wMetatileStandingY], a + ld [wPlayerMetatileY], a ld a, [wXCoord] and 1 - ld [wMetatileStandingX], a + ld [wPlayerMetatileX], a ret diff --git a/home/map.asm b/home/map.asm index 03d3bad0a..14786eece 100644 --- a/home/map.asm +++ b/home/map.asm @@ -246,10 +246,10 @@ GetDestinationWarpNumber:: ret .GetDestinationWarpNumber: - ld a, [wPlayerStandingMapY] + ld a, [wPlayerMapY] sub 4 ld e, a - ld a, [wPlayerStandingMapX] + ld a, [wPlayerMapX] sub 4 ld d, a ld a, [wCurMapWarpCount] @@ -1514,16 +1514,16 @@ GetMovementPermissions:: call .LeftRight call .UpDown ; get coords of current tile - ld a, [wPlayerStandingMapX] + ld a, [wPlayerMapX] ld d, a - ld a, [wPlayerStandingMapY] + ld a, [wPlayerMapY] ld e, a call GetCoordTile - ld [wPlayerStandingTile], a + ld [wPlayerTile], a call .CheckHiNybble ret nz - ld a, [wPlayerStandingTile] + ld a, [wPlayerTile] and 7 ld hl, .MovementPermissionsData add l @@ -1548,9 +1548,9 @@ GetMovementPermissions:: db UP_MASK | LEFT_MASK .UpDown: - ld a, [wPlayerStandingMapX] + ld a, [wPlayerMapX] ld d, a - ld a, [wPlayerStandingMapY] + ld a, [wPlayerMapY] ld e, a push de @@ -1567,9 +1567,9 @@ GetMovementPermissions:: ret .LeftRight: - ld a, [wPlayerStandingMapX] + ld a, [wPlayerMapX] ld d, a - ld a, [wPlayerStandingMapY] + ld a, [wPlayerMapY] ld e, a push de @@ -1688,10 +1688,10 @@ GetFacingTileCoord:: ld h, [hl] ld l, a - ld a, [wPlayerStandingMapX] + ld a, [wPlayerMapX] add d ld d, a - ld a, [wPlayerStandingMapY] + ld a, [wPlayerMapY] add e ld e, a ld a, [hl] @@ -1861,10 +1861,10 @@ CheckCurrentMapCoordEvents:: call CheckScenes ld b, a ; Load your current coordinates into de. This will be used to check if your position is in the coord event table for the current map. - ld a, [wPlayerStandingMapX] + ld a, [wPlayerMapX] sub 4 ld d, a - ld a, [wPlayerStandingMapY] + ld a, [wPlayerMapY] sub 4 ld e, a diff --git a/home/map_objects.asm b/home/map_objects.asm index 9e80e8cbe..2b92b4491 100644 --- a/home/map_objects.asm +++ b/home/map_objects.asm @@ -71,14 +71,14 @@ DoesSpriteHaveFacings:: pop de ret -GetPlayerStandingTile:: - ld a, [wPlayerStandingTile] +GetPlayerTile:: + ld a, [wPlayerTile] call GetTileCollision ld b, a ret CheckOnWater:: - ld a, [wPlayerStandingTile] + ld a, [wPlayerTile] call GetTileCollision sub WATER_TILE ret z @@ -189,7 +189,7 @@ CheckWaterfallTile:: ret CheckStandingOnEntrance:: - ld a, [wPlayerStandingTile] + ld a, [wPlayerTile] cp COLL_DOOR ret z cp COLL_DOOR_79 @@ -404,7 +404,7 @@ LoadMovementDataPointer:: call CheckObjectVisibility ret c - ld hl, OBJECT_MOVEMENTTYPE + ld hl, OBJECT_MOVEMENT_TYPE add hl, bc ld [hl], SPRITEMOVEDATA_SCRIPTED @@ -447,7 +447,7 @@ FindFirstEmptyObjectStruct:: ret GetSpriteMovementFunction:: - ld hl, OBJECT_MOVEMENTTYPE + ld hl, OBJECT_MOVEMENT_TYPE add hl, bc ld a, [hl] cp NUM_SPRITEMOVEDATA @@ -500,7 +500,7 @@ CopySpriteMovementData:: ret .CopyData: - ld hl, OBJECT_MOVEMENTTYPE + ld hl, OBJECT_MOVEMENT_TYPE add hl, de ld [hl], a @@ -520,7 +520,7 @@ endr rlca rlca maskbits NUM_DIRECTIONS, 2 - ld hl, OBJECT_FACING + ld hl, OBJECT_DIRECTION add hl, de ld [hl], a @@ -549,16 +549,16 @@ endr ld [hl], a ret -_GetMovementByte:: +_GetMovementIndex:: ; Switch to the movement data bank ldh a, [hROMBank] push af ld a, [hli] rst Bankswitch -; Load the current script byte as given by OBJECT_MOVEMENT_BYTE_INDEX, and increment OBJECT_MOVEMENT_BYTE_INDEX +; Load the current script byte as given by OBJECT_MOVEMENT_INDEX, and increment OBJECT_MOVEMENT_INDEX ld a, [hli] ld d, [hl] - ld hl, OBJECT_MOVEMENT_BYTE_INDEX + ld hl, OBJECT_MOVEMENT_INDEX add hl, bc add [hl] ld e, a @@ -611,7 +611,7 @@ DoesObjectHaveASprite:: SetSpriteDirection:: ; preserves other flags push af - ld hl, OBJECT_FACING + ld hl, OBJECT_DIRECTION add hl, bc ld a, [hl] and %11110011 @@ -623,7 +623,7 @@ SetSpriteDirection:: ret GetSpriteDirection:: - ld hl, OBJECT_FACING + ld hl, OBJECT_DIRECTION add hl, bc ld a, [hl] maskbits NUM_DIRECTIONS, 2 diff --git a/home/stone_queue.asm b/home/stone_queue.asm index 482299d9c..cb4c652c6 100644 --- a/home/stone_queue.asm +++ b/home/stone_queue.asm @@ -38,10 +38,10 @@ HandleStoneQueue:: .IsObjectOnWarp: push de - ld hl, OBJECT_NEXT_MAP_X + ld hl, OBJECT_MAP_X add hl, de ld a, [hl] - ld hl, OBJECT_NEXT_MAP_Y + ld hl, OBJECT_MAP_Y add hl, de ld e, [hl] diff --git a/home/trainers.asm b/home/trainers.asm index ec9ddd3ca..7085dc324 100644 --- a/home/trainers.asm +++ b/home/trainers.asm @@ -138,19 +138,19 @@ FacingPlayerDistance:: ; Return carry if the sprite at bc is facing the player, ; its distance in d, and its direction in e. - ld hl, OBJECT_NEXT_MAP_X ; x + ld hl, OBJECT_MAP_X ; x add hl, bc ld d, [hl] - ld hl, OBJECT_NEXT_MAP_Y ; y + ld hl, OBJECT_MAP_Y ; y add hl, bc ld e, [hl] - ld a, [wPlayerStandingMapX] + ld a, [wPlayerMapX] cp d jr z, .CheckY - ld a, [wPlayerStandingMapY] + ld a, [wPlayerMapY] cp e jr z, .CheckX @@ -158,7 +158,7 @@ FacingPlayerDistance:: ret .CheckY: - ld a, [wPlayerStandingMapY] + ld a, [wPlayerMapY] sub e jr z, .NotFacing jr nc, .Above @@ -176,7 +176,7 @@ FacingPlayerDistance:: jr .CheckFacing .CheckX: - ld a, [wPlayerStandingMapX] + ld a, [wPlayerMapX] sub d jr z, .NotFacing jr nc, .Left diff --git a/macros.asm b/macros.asm index 0a92913d9..3eddc3feb 100644 --- a/macros.asm +++ b/macros.asm @@ -1,7 +1,7 @@ INCLUDE "macros/asserts.asm" INCLUDE "macros/const.asm" INCLUDE "macros/predef.asm" -INCLUDE "macros/rst.asm" +INCLUDE "macros/farcall.asm" INCLUDE "macros/data.asm" INCLUDE "macros/code.asm" INCLUDE "macros/gfx.asm" diff --git a/macros/coords.asm b/macros/coords.asm index 228afca95..e899e68e7 100644 --- a/macros/coords.asm +++ b/macros/coords.asm @@ -1,3 +1,5 @@ +; Coordinate macros + DEF hlcoord EQUS "coord hl," DEF bccoord EQUS "coord bc," DEF decoord EQUS "coord de," diff --git a/macros/rst.asm b/macros/farcall.asm similarity index 90% rename from macros/rst.asm rename to macros/farcall.asm index 5ae20ea55..b884c8f06 100644 --- a/macros/rst.asm +++ b/macros/farcall.asm @@ -1,3 +1,5 @@ +; Far calls to another bank + MACRO farcall ; bank, address ld a, BANK(\1) ld hl, \1 diff --git a/macros/gfx.asm b/macros/gfx.asm index 7c94ea157..630b131cd 100644 --- a/macros/gfx.asm +++ b/macros/gfx.asm @@ -1,3 +1,5 @@ +; Graphics macros + MACRO assert_valid_rgb rept _NARG assert 0 <= (\1) && (\1) <= 31, "RGB channel must be 0-31" diff --git a/macros/legacy.asm b/macros/legacy.asm index 048f83ca1..f3dcb6164 100644 --- a/macros/legacy.asm +++ b/macros/legacy.asm @@ -2,7 +2,7 @@ ; Allows porting scripts with as few edits as possible. ; Legacy support not in this file can be found by looking for the keyword: "LEGACY" -; macros/rst.asm +; macros/farcall.asm DEF callba EQUS "farcall" DEF callab EQUS "callfar" diff --git a/macros/predef.asm b/macros/predef.asm index bd101806f..a32b9a3ce 100644 --- a/macros/predef.asm +++ b/macros/predef.asm @@ -1,3 +1,5 @@ +; Predef function calls + MACRO lda_predef ; Some functions load the predef id ; without immediately calling Predef. diff --git a/macros/ram.asm b/macros/ram.asm index 8c099f88e..a1957aafc 100644 --- a/macros/ram.asm +++ b/macros/ram.asm @@ -1,4 +1,4 @@ -; Used in wram.asm +; Structures in RAM MACRO flag_array ds ((\1) + 7) / 8 @@ -283,38 +283,38 @@ MACRO slot_reel ENDM MACRO object_struct -\1Sprite:: db -\1MapObjectIndex:: db -\1SpriteTile:: db -\1MovementType:: db -\1Flags:: dw -\1Palette:: db -\1Walking:: db -\1Direction:: db -\1StepType:: db -\1StepDuration:: db -\1Action:: db -\1ObjectStepFrame:: db -\1Facing:: db -\1StandingTile:: db ; collision -\1LastTile:: db ; collision -\1StandingMapX:: db -\1StandingMapY:: db -\1LastMapX:: db -\1LastMapY:: db -\1ObjectInitX:: db -\1ObjectInitY:: db -\1Radius:: db -\1SpriteX:: db -\1SpriteY:: db -\1SpriteXOffset:: db -\1SpriteYOffset:: db -\1MovementByteIndex:: db -\1Field1c:: ds 1 -\1Field1d:: ds 1 -\1Field1e:: ds 1 -\1Field1f:: ds 1 -\1Range:: db +\1Sprite:: db +\1MapObjectIndex:: db +\1SpriteTile:: db +\1MovementType:: db +\1Flags:: dw +\1Palette:: db +\1Walking:: db +\1Direction:: db +\1StepType:: db +\1StepDuration:: db +\1Action:: db +\1StepFrame:: db +\1Facing:: db +\1Tile:: db +\1LastTile:: db +\1MapX:: db +\1MapY:: db +\1LastMapX:: db +\1LastMapY:: db +\1InitX:: db +\1InitY:: db +\1Radius:: db +\1SpriteX:: db +\1SpriteY:: db +\1SpriteXOffset:: db +\1SpriteYOffset:: db +\1MovementIndex:: db +\1StepIndex:: db +\1Field1d:: ds 1 +\1Field1e:: ds 1 +\1JumpHeight:: db +\1Range:: db ds 7 \1StructEnd:: ENDM diff --git a/macros/vc.asm b/macros/vc.asm index 639288aa4..b104cb524 100644 --- a/macros/vc.asm +++ b/macros/vc.asm @@ -1,3 +1,5 @@ +; Virtual Console macros + MACRO vc_hook if DEF(_CRYSTAL11_VC) .VC_\1:: diff --git a/ram/wram.asm b/ram/wram.asm index 4f8a8730a..fc85e5870 100644 --- a/ram/wram.asm +++ b/ram/wram.asm @@ -160,7 +160,7 @@ wIndexedMovement2Pointer:: dw ds 2 -wMovementByteWasControlSwitch:: db +wContinueReadingMovement:: db UNION wObjectPriorities:: ds NUM_OBJECT_STRUCTS @@ -2381,8 +2381,8 @@ wd173:: db ; related to command queue type 3 ENDU wOverworldMapAnchor:: dw -wMetatileStandingY:: db -wMetatileStandingX:: db +wPlayerMetatileY:: db +wPlayerMetatileX:: db wMapPartial:: wMapAttributesBank:: db