pokecrystal-board/macros/scripts/maps.asm

299 lines
5.6 KiB
NASM
Raw Normal View History

MACRO map_id
2017-12-13 21:36:24 -08:00
;\1: map id
assert DEF(GROUP_\1) && DEF(MAP_\1), \
"Missing 'map_const \1' in constants/map_constants.asm"
2017-12-13 21:36:24 -08:00
db GROUP_\1, MAP_\1
2017-12-28 13:31:16 -08:00
ENDM
2017-12-13 21:36:24 -08:00
DEF object_const_def EQUS "const_def 2"
MACRO def_scene_scripts
REDEF _NUM_SCENE_SCRIPTS EQUS "_NUM_SCENE_SCRIPTS_\@"
2021-04-19 13:31:37 -07:00
db {_NUM_SCENE_SCRIPTS}
const_def
DEF {_NUM_SCENE_SCRIPTS} = 0
ENDM
MACRO scene_const
;\1: scene id constant
const \1
EXPORT \1
ENDM
MACRO scene_script
2017-12-13 21:36:24 -08:00
;\1: script pointer
;\2: scene id constant
2018-02-01 12:19:27 -08:00
dw \1
dw 0 ; filler
if _NARG == 2
scene_const \2
else
const_skip
endc
DEF {_NUM_SCENE_SCRIPTS} += 1
ENDM
MACRO def_callbacks
REDEF _NUM_CALLBACKS EQUS "_NUM_CALLBACKS_\@"
2021-04-19 13:31:37 -07:00
db {_NUM_CALLBACKS}
DEF {_NUM_CALLBACKS} = 0
2017-12-28 13:31:16 -08:00
ENDM
2017-12-13 21:36:24 -08:00
MACRO callback
;\1: type: a MAPCALLBACK_* constant
;\2: script pointer
dbw \1, \2
DEF {_NUM_CALLBACKS} += 1
ENDM
MACRO def_warp_events
REDEF _NUM_WARP_EVENTS EQUS "_NUM_WARP_EVENTS_\@"
2021-04-19 13:31:37 -07:00
db {_NUM_WARP_EVENTS}
DEF {_NUM_WARP_EVENTS} = 0
ENDM
MACRO warp_event
;\1: x: left to right, starts at 0
;\2: y: top to bottom, starts at 0
2018-02-01 18:54:00 -08:00
;\3: map id: from constants/map_constants.asm
;\4: warp destination: starts at 1
db \2, \1, \4
map_id \3
DEF {_NUM_WARP_EVENTS} += 1
ENDM
MACRO def_anchor_events
REDEF _NUM_ANCHOR_EVENTS EQUS "_NUM_ANCHOR_EVENTS_\@"
db {_NUM_ANCHOR_EVENTS}
DEF {_NUM_ANCHOR_EVENTS} = 0
ENDM
MACRO anchor_event
;\1: x coord
;\2: y coord
;\3: next space
; there is no \4. An anchor point can't act as an space with an effect (neither as a branch space)
db \1, \2, \3
DEF {_NUM_ANCHOR_EVENTS} += 1
ENDM
MACRO def_coord_events
REDEF _NUM_COORD_EVENTS EQUS "_NUM_COORD_EVENTS_\@"
2021-04-19 13:31:37 -07:00
db {_NUM_COORD_EVENTS}
DEF {_NUM_COORD_EVENTS} = 0
2017-12-28 13:31:16 -08:00
ENDM
2017-12-13 21:36:24 -08:00
MACRO coord_event
;\1: x: left to right, starts at 0
2017-12-13 21:36:24 -08:00
;\2: y: top to bottom, starts at 0
2018-02-01 12:19:27 -08:00
;\3: scene id: a SCENE_* constant; controlled by setscene/setmapscene
2017-12-13 21:36:24 -08:00
;\4: script pointer
db \3, \2, \1
db 0 ; filler
2017-12-13 21:36:24 -08:00
dw \4
2019-03-03 11:19:16 -08:00
dw 0 ; filler
DEF {_NUM_COORD_EVENTS} += 1
ENDM
MACRO def_bg_events
REDEF _NUM_BG_EVENTS EQUS "_NUM_BG_EVENTS_\@"
2021-04-19 13:31:37 -07:00
db {_NUM_BG_EVENTS}
DEF {_NUM_BG_EVENTS} = 0
2017-12-28 13:31:16 -08:00
ENDM
2017-12-13 21:36:24 -08:00
MACRO bg_event
;\1: x: left to right, starts at 0
;\2: y: top to bottom, starts at 0
;\3: function: a BGEVENT_* constant
2017-12-13 21:36:24 -08:00
;\4: script pointer
db \2, \1, \3
2017-12-13 21:36:24 -08:00
dw \4
DEF {_NUM_BG_EVENTS} += 1
ENDM
MACRO def_object_events
REDEF _NUM_OBJECT_EVENTS EQUS "_NUM_OBJECT_EVENTS_\@"
2021-04-19 13:31:37 -07:00
db {_NUM_OBJECT_EVENTS}
DEF {_NUM_OBJECT_EVENTS} = 0
2017-12-28 13:31:16 -08:00
ENDM
2017-12-13 21:36:24 -08:00
MACRO object_event
;\1: x: left to right, starts at 0
2017-12-13 21:36:24 -08:00
;\2: y: top to bottom, starts at 0
;\3: sprite: a SPRITE_* constant
2017-12-13 21:36:24 -08:00
;\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: 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
;\<13>: event flag: an EVENT_* constant, or -1 to always appear
db \3, \2 + 4, \1 + 4, \4
dn \6, \5
2017-12-13 21:36:24 -08:00
db \7, \8
dn \9, \<10>
db \<11>
dw \<12>, \<13>
; the dummy PlayerObjectTemplate object_event has no def_object_events
if DEF(_NUM_OBJECT_EVENTS)
DEF {_NUM_OBJECT_EVENTS} += 1
endc
2017-12-28 13:31:16 -08:00
ENDM
2017-12-13 21:36:24 -08:00
MACRO space
;\1: x coord
;\2: y coord
; [non-branch space]
;\3: effect (space type specific)
;\4: next space
; [branch space]
;\3: pointer to branch struct
db \1, \2
if _NARG == 4
db \3, \4
else
dw \3
endc
ENDM
2023-10-28 11:57:59 -07:00
MACRO branchdir
if !STRCMP("\1", "RIGHT")
DEF _NEXT_SPACE_RIGHT = \2
DEF _TECHNIQUES_RIGHT = \3
elif !STRCMP("\1", "LEFT")
DEF _NEXT_SPACE_LEFT = \2
DEF _TECHNIQUES_LEFT = \3
elif !STRCMP("\1", "UP")
DEF _NEXT_SPACE_UP = \2
DEF _TECHNIQUES_UP = \3
elif !STRCMP("\1", "DOWN")
DEF _NEXT_SPACE_DOWN = \2
DEF _TECHNIQUES_DOWN = \3
endc
ENDM
MACRO endbranch
if DEF(_NEXT_SPACE_RIGHT)
db {_NEXT_SPACE_RIGHT}
PURGE _NEXT_SPACE_RIGHT
else
db -1
endc
if DEF(_NEXT_SPACE_LEFT)
db {_NEXT_SPACE_LEFT}
PURGE _NEXT_SPACE_LEFT
else
db -1
endc
if DEF(_NEXT_SPACE_UP)
db {_NEXT_SPACE_UP}
PURGE _NEXT_SPACE_UP
else
db -1
endc
if DEF(_NEXT_SPACE_DOWN)
db {_NEXT_SPACE_DOWN}
PURGE _NEXT_SPACE_DOWN
else
db -1
endc
if DEF(_TECHNIQUES_RIGHT)
db {_TECHNIQUES_RIGHT}
PURGE _TECHNIQUES_RIGHT
else
db 0
endc
if DEF(_TECHNIQUES_LEFT)
db {_TECHNIQUES_LEFT}
PURGE _TECHNIQUES_LEFT
else
db 0
endc
if DEF(_TECHNIQUES_UP)
db {_TECHNIQUES_UP}
PURGE _TECHNIQUES_UP
else
db 0
endc
if DEF(_TECHNIQUES_DOWN)
db {_TECHNIQUES_DOWN}
PURGE _TECHNIQUES_DOWN
else
db 0
endc
ENDM
MACRO trainer
;\1: trainer group
;\2: trainer id
;\3: flag: an EVENT_* constant
2017-12-13 21:36:24 -08:00
;\4: seen text
;\5: win text
;\6: loss text
;\7: after-battle text
dw \3
db \1, \2
2017-12-13 21:36:24 -08:00
dw \4, \5, \6, \7
2017-12-28 13:31:16 -08:00
ENDM
2017-12-13 21:36:24 -08:00
MACRO talker
;\1: flag: an EVENT_* constant
;\2: OPTIONAL or MANDATORY
;\3: talker type: TEXT, SCRIPT
;\4: pointer to talker text or script
dw \1
db TALKEREVENTTYPE_\2 | TALKERTYPE_\3
dw \4
ENDM
MACRO itemball
2017-12-13 21:36:24 -08:00
;\1: item: from constants/item_constants.asm
;\2: quantity: default 1
if _NARG == 1
itemball \1, 1
else
db \1, \2
endc
2017-12-28 13:31:16 -08:00
ENDM
2017-12-13 21:36:24 -08:00
MACRO hiddenitem
;\1: item: from constants/item_constants.asm
;\2: flag: an EVENT_* constant
dwb \2, \1
ENDM
MACRO elevfloor
2017-12-13 21:36:24 -08:00
;\1: floor: a FLOOR_* constant
;\2: warp destination: starts at 1
;\3: map id
db \1, \2
map_id \3
2017-12-13 21:36:24 -08:00
ENDM
MACRO conditional_event
;\1: flag: an EVENT_* constant
;\2: script pointer
dw \1, \2
ENDM
MACRO cmdqueue
;\1: type: a CMDQUEUE_* constant
;\2: data pointer
dbw \1, \2
dw 0 ; filler
ENDM
MACRO stonetable
2017-12-13 21:36:24 -08:00
;\1: warp id
;\2: object_event id
2017-12-13 21:36:24 -08:00
;\3: script pointer
db \1, \2
dw \3
2017-12-28 13:31:16 -08:00
ENDM