summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Allow-more-than-15-object_events-per-map.md79
1 files changed, 39 insertions, 40 deletions
diff --git a/Allow-more-than-15-object_events-per-map.md b/Allow-more-than-15-object_events-per-map.md
index dcf4189..18915b7 100644
--- a/Allow-more-than-15-object_events-per-map.md
+++ b/Allow-more-than-15-object_events-per-map.md
@@ -44,55 +44,54 @@ That's it! We just added space for maps to define 17 total `object_event`s. (Plu
Let's look at how it works. `wMapObjects` is an array of `map_object` structs, one for each possible object (including the player). You can see what data is stored for each `map_object` in the macro definition in [macros/wram.asm](../blob/master/macros/wram.asm):
```asm
-map_object: MACRO
-\1ObjectStructID:: db
-\1ObjectSprite:: db
-\1ObjectYCoord:: db
-\1ObjectXCoord:: db
-\1ObjectMovement:: db
-\1ObjectRadius:: db
-\1ObjectHour:: db
-\1ObjectTimeOfDay:: db
-\1ObjectColor:: db
-\1ObjectRange:: db
-\1ObjectScript:: dw
-\1ObjectEventFlag:: dw
+ map_object: MACRO
+ \1ObjectStructID:: db
+ \1ObjectSprite:: db
+ \1ObjectYCoord:: db
+ \1ObjectXCoord:: db
+ \1ObjectMovement:: db
+ \1ObjectRadius:: db
+ \1ObjectHour:: db
+ \1ObjectTimeOfDay:: db
+ \1ObjectColor:: db
+ \1ObjectRange:: db
+ \1ObjectScript:: dw
+ \1ObjectEventFlag:: dw
ds 2
-ENDM
+ ENDM
```
This is all the same data that gets declared by the `object_event` macro, defined in [macros/scripts/maps.asm](../blob/master/macros/scripts/maps.asm):
```asm
-object_event: MACRO
-;\1: x: left to right, starts at 0
-;\2: y: top to bottom, starts at 0
-;\3: sprite: a SPRITE_* constant
-;\4: movement function: a SPRITEMOVEDATA_* constant
-;\5, \6: movement radius: x, y
-;\7, \8: hour limits: h1, h2 (0-23)
-; * if h1 < h2, the object_event will only appear from h1 to h2
-; * if h1 > h2, the object_event will not appear from h2 to h1
-; * 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
-;\10: function: a OBJECTTYPE_* constant
-;\11: sight range: applies to OBJECTTYPE_TRAINER
-;\12: script pointer
-;\13: event flag: an EVENT_* constant, or -1 to always appear
+ object_event: MACRO
+ ;\1: x: left to right, starts at 0
+ ;\2: y: top to bottom, starts at 0
+ ;\3: sprite: a SPRITE_* constant
+ ;\4: movement function: a SPRITEMOVEDATA_* constant
+ ;\5, \6: movement radius: x, y
+ ;\7, \8: hour limits: h1, h2 (0-23)
+ ; * if h1 < h2, the object_event will only appear from h1 to h2
+ ; * if h1 > h2, the object_event will not appear from h2 to h1
+ ; * 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
+ ;\<10>: function: a OBJECTTYPE_* constant
+ ;\<11>: sight range: applies to OBJECTTYPE_TRAINER
+ ;\<12>: script pointer
+ ;\<13>: event flag: an EVENT_* constant, or -1 to always appear
db \3, \2 + 4, \1 + 4, \4
dn \6, \5
db \7, \8
- shift
- dn \8, \9
- shift
- db \9
- shift
- dw \9
- shift
- dw \9
-ENDM
+ dn \9, \<10>
+ db \<11>
+ dw \<12>, \<13>
+ ; the dummy PlayerObjectTemplate object_event has no def_object_events
+ if DEF(_NUM_OBJECT_EVENTS)
+ {_NUM_OBJECT_EVENTS} = {_NUM_OBJECT_EVENTS} + 1
+ endc
+ ENDM
```
`wObjectMasks` is likewise an array of mask bytes, one for each possible object. If the mask is −1, the object is hidden.