shithub: pokecrystal

Download patch

ref: c01409be5a9930d6f0687ce53c1c898e1855c884
parent: 2d40e99d1127fcfd1625274a24b95153b47fd836
author: vulcandth <[email protected]>
date: Tue Jan 3 16:16:08 EST 2023

Relabel some `map_object` struct fields (#1029)


--- a/constants/map_object_constants.asm
+++ b/constants/map_object_constants.asm
@@ -104,10 +104,14 @@
 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
@@ -114,6 +118,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
--- a/engine/overworld/events.asm
+++ b/engine/overworld/events.asm
@@ -546,10 +546,10 @@
 
 	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
--- a/engine/overworld/player_object.asm
+++ b/engine/overworld/player_object.asm
@@ -27,7 +27,7 @@
 	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 @@
 	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 @@
 	ld a, [hl]
 	ld [wTempObjectCopyMovement], a
 
-	ld hl, MAPOBJECT_RANGE
+	ld hl, MAPOBJECT_SIGHT_RANGE
 	add hl, bc
 	ld a, [hl]
 	ld [wTempObjectCopyRange], a
--- a/home/map_objects.asm
+++ b/home/map_objects.asm
@@ -227,7 +227,7 @@
 	ret
 
 CheckObjectTime::
-	ld hl, MAPOBJECT_HOUR
+	ld hl, MAPOBJECT_HOUR_1
 	add hl, bc
 	ld a, [hl]
 	cp -1
@@ -264,10 +264,10 @@
 	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
--- a/home/trainers.asm
+++ b/home/trainers.asm
@@ -31,10 +31,10 @@
 	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 @@
 	jr nc, .next
 
 ; ...within their sight range
-	ld hl, MAPOBJECT_RANGE
+	ld hl, MAPOBJECT_SIGHT_RANGE
 	add hl, de
 	ld a, [hl]
 	cp b
--- a/macros/ram.asm
+++ b/macros/ram.asm
@@ -330,18 +330,20 @@
 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
 
--- a/macros/scripts/maps.asm
+++ b/macros/scripts/maps.asm
@@ -114,7 +114,7 @@
 ;  * 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