Rename the `object_struct` field labels and constants (#1005)

Fixes #990
This commit is contained in:
Rangi 2022-09-12 09:15:44 -04:00 committed by GitHub
parent 4c239a6f65
commit 41d5ea0482
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 442 additions and 431 deletions

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

File diff suppressed because it is too large Load Diff

View File

@ -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

View File

@ -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]

View File

@ -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]

View File

@ -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]

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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]

View File

@ -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

View File

@ -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"

View File

@ -1,3 +1,5 @@
; Coordinate macros
DEF hlcoord EQUS "coord hl,"
DEF bccoord EQUS "coord bc,"
DEF decoord EQUS "coord de,"

View File

@ -1,3 +1,5 @@
; Far calls to another bank
MACRO farcall ; bank, address
ld a, BANK(\1)
ld hl, \1

View File

@ -1,3 +1,5 @@
; Graphics macros
MACRO assert_valid_rgb
rept _NARG
assert 0 <= (\1) && (\1) <= 31, "RGB channel must be 0-31"

View File

@ -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"

View File

@ -1,3 +1,5 @@
; Predef function calls
MACRO lda_predef
; Some functions load the predef id
; without immediately calling Predef.

View File

@ -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

View File

@ -1,3 +1,5 @@
; Virtual Console macros
MACRO vc_hook
if DEF(_CRYSTAL11_VC)
.VC_\1::

View File

@ -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