Relabel some map_object struct fields (#1029)

This commit is contained in:
vulcandth 2023-01-03 21:16:08 -06:00 committed by GitHub
parent 2d40e99d11
commit c01409be5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 37 additions and 28 deletions

View File

@ -104,10 +104,14 @@ DEF MAPOBJECT_Y_COORD rb ; 2
DEF MAPOBJECT_X_COORD rb ; 3
DEF MAPOBJECT_MOVEMENT rb ; 4
DEF MAPOBJECT_RADIUS rb ; 5
DEF MAPOBJECT_HOUR rb ; 6
DEF MAPOBJECT_HOUR_1 rb ; 6
DEF MAPOBJECT_HOUR_2 rb ; 7
rsset MAPOBJECT_HOUR_2
DEF MAPOBJECT_TIMEOFDAY rb ; 7
DEF MAPOBJECT_COLOR rb ; 8
DEF MAPOBJECT_RANGE rb ; 9
DEF MAPOBJECT_PALETTE rb ; 8
rsset MAPOBJECT_PALETTE
DEF MAPOBJECT_TYPE rb ; 8
DEF MAPOBJECT_SIGHT_RANGE rb ; 9
DEF MAPOBJECT_SCRIPT_POINTER rw ; a
DEF MAPOBJECT_EVENT_FLAG rw ; c
rb_skip 2
@ -115,6 +119,9 @@ DEF MAPOBJECT_LENGTH EQU _RS
DEF NUM_OBJECTS EQU 16
DEF PLAYER_OBJECT EQU 0
DEF MAPOBJECT_PALETTE_MASK EQU %11110000
DEF MAPOBJECT_TYPE_MASK EQU %00001111
; SpriteMovementData struct members (see data/sprites/map_objects.asm)
rsreset
DEF SPRITEMOVEATTR_MOVEMENT rb ; 0

View File

@ -546,10 +546,10 @@ TryObjectEvent:
ldh a, [hLastTalked]
call GetMapObject
ld hl, MAPOBJECT_COLOR
ld hl, MAPOBJECT_TYPE
add hl, bc
ld a, [hl]
and %00001111
and MAPOBJECT_TYPE_MASK
; BUG: TryObjectEvent arbitrary code execution (see docs/bugs_and_glitches.md)
push bc

View File

@ -27,7 +27,7 @@ SpawnPlayer:
call PlayerSpawn_ConvertCoords
ld a, PLAYER_OBJECT
call GetMapObject
ld hl, MAPOBJECT_COLOR
ld hl, MAPOBJECT_PALETTE
add hl, bc
ln e, PAL_NPC_RED, OBJECTTYPE_SCRIPT
ld a, [wPlayerSpriteSetupFlags]
@ -188,10 +188,10 @@ CopyMapObjectToObjectStruct:
call GetSpritePalette
ld [wTempObjectCopyPalette], a
ld hl, MAPOBJECT_COLOR
ld hl, MAPOBJECT_PALETTE
add hl, bc
ld a, [hl]
and $f0
and MAPOBJECT_PALETTE_MASK
jr z, .skip_color_override
swap a
and PALETTE_MASK
@ -203,7 +203,7 @@ CopyMapObjectToObjectStruct:
ld a, [hl]
ld [wTempObjectCopyMovement], a
ld hl, MAPOBJECT_RANGE
ld hl, MAPOBJECT_SIGHT_RANGE
add hl, bc
ld a, [hl]
ld [wTempObjectCopyRange], a

View File

@ -227,7 +227,7 @@ CheckObjectVisibility::
ret
CheckObjectTime::
ld hl, MAPOBJECT_HOUR
ld hl, MAPOBJECT_HOUR_1
add hl, bc
ld a, [hl]
cp -1
@ -264,10 +264,10 @@ CheckObjectTime::
db NITE
.check_hour
ld hl, MAPOBJECT_HOUR
ld hl, MAPOBJECT_HOUR_1
add hl, bc
ld d, [hl]
ld hl, MAPOBJECT_TIMEOFDAY
ld hl, MAPOBJECT_HOUR_2
add hl, bc
ld e, [hl]
ld hl, hHours

View File

@ -31,10 +31,10 @@ _CheckTrainerBattle::
jr z, .next
; Is a trainer
ld hl, MAPOBJECT_COLOR
ld hl, MAPOBJECT_TYPE
add hl, de
ld a, [hl]
and $f
and MAPOBJECT_TYPE_MASK
cp OBJECTTYPE_TRAINER
jr nz, .next
@ -51,7 +51,7 @@ _CheckTrainerBattle::
jr nc, .next
; ...within their sight range
ld hl, MAPOBJECT_RANGE
ld hl, MAPOBJECT_SIGHT_RANGE
add hl, de
ld a, [hl]
cp b

View File

@ -330,18 +330,20 @@ MACRO object_struct
ENDM
MACRO map_object
\1ObjectStructID:: db
\1ObjectSprite:: db
\1ObjectYCoord:: db
\1ObjectXCoord:: db
\1ObjectMovement:: db
\1ObjectRadius:: db
\1ObjectHour:: db
\1ObjectTimeOfDay:: db
\1ObjectColor:: db
\1ObjectRange:: db
\1ObjectScript:: dw
\1ObjectEventFlag:: dw
\1ObjectStructID:: db
\1ObjectSprite:: db
\1ObjectYCoord:: db
\1ObjectXCoord:: db
\1ObjectMovement:: db
\1ObjectRadius:: db
\1ObjectHour1:: db
\1ObjectHour2::
\1ObjectTimeOfDay:: db
\1ObjectPalette::
\1ObjectType:: db
\1ObjectSightRange:: db
\1ObjectScript:: dw
\1ObjectEventFlag:: dw
ds 2
ENDM

View File

@ -114,7 +114,7 @@ MACRO object_event
; * if h1 == h2, the object_event will always appear
; * if h1 == -1, h2 is treated as a time-of-day value:
; a combo of MORN, DAY, and/or NITE, or -1 to always appear
;\9: color: a PAL_NPC_* constant, or 0 for sprite default
;\9: palette: a PAL_NPC_* constant, or 0 for sprite default
;\<10>: function: a OBJECTTYPE_* constant
;\<11>: sight range: applies to OBJECTTYPE_TRAINER
;\<12>: script pointer