2022-01-24 00:26:22 +00:00
@ Most of the macros in this file are for arranging map event data , and are output by mapjson using data from each map ' s JSON file .
@ Takes a MAP constant and outputs the map group and map number as separate bytes
2022-01-23 23:51:56 +00:00
. macro map map_id : req
2018-06-15 04:00:09 +01:00
. byte \map_id >> 8 @ map group
. byte \map_id & 0xFF @ map num
2015-10-26 05:56:06 +00:00
. endm
2022-01-24 00:26:22 +00:00
@ Defines a map script . 'type' is any MAP_SCRIPT_ * constant ( see include / constants / map_scripts . h )
2022-01-23 23:51:56 +00:00
. macro map_script type : req , script : req
2017-10-24 03:18:49 +01:00
. byte \type
2022-01-23 23:51:56 +00:00
. 4 byte \script
2017-10-24 03:18:49 +01:00
. endm
2022-01-24 00:26:22 +00:00
@ Defines an entry in a map script table ( for either ON_WARP_INTO_MAP_TABLE or ON_FRAME_TABLE )
2022-01-23 23:51:56 +00:00
. macro map_script_2 var : req , compare : req , script : req
. 2 byte \var
. 2 byte \compare
. 4 byte \script
2017-10-24 03:18:49 +01:00
. endm
2023-02-08 18:11:10 +00:00
@ Defines an object event template for map data , to be used by a normal object . Mirrors the struct layout of ObjectEventTemplate in include / global . fieldmap . h
. macro object_event index : req , gfx : req , x : req , y : req , elevation : req , movement_type : req , x_radius : req , y_radius : req , trainer_type : req , sight_radius_tree_etc : req , script : req , event_flag : req
2022-01-23 23:51:56 +00:00
. byte \index
2023-01-07 22:54:21 +00:00
. 2 byte \gfx
2023-02-08 18:11:10 +00:00
. byte OBJ_KIND_NORMAL
2022-01-23 23:51:56 +00:00
. 2 byte \x , \y
. byte \elevation
. byte \movement_type
2024-01-14 20:35:45 +00:00
. if \x_radius > 15
@ This warning is relevant for GetItemBallIdAndAmountFromTemplate
. error " movementRangeX has a bitfield of 4 bytes, so values over 15 will overflow. Use a custom script for item balls that should give the player more than 15 items. "
. endif
2022-01-23 23:51:56 +00:00
. byte (( \y_radius << 4 ) | \x_radius )
2022-01-24 00:26:22 +00:00
. space 1 @ Padding
2022-01-23 23:51:56 +00:00
. 2 byte \trainer_type
. 2 byte \sight_radius_tree_etc
2017-10-24 03:18:49 +01:00
. 4 byte \script
2017-10-24 20:35:06 +01:00
. 2 byte \event_flag
2022-01-24 00:26:22 +00:00
. space 2 @ Padding
2017-10-24 03:18:49 +01:00
inc _num_npcs
. endm
2023-02-08 18:11:10 +00:00
@ Defines an object event template for map data , to be used by a clone object . Mirrors the struct layout of ObjectEventTemplate in include / global . fieldmap . h
@ NOTE : The handling for this type of event does not exist in Emerald by default ; it is exclusive to FRLG .
. macro clone_event index : req , gfx : req , x : req , y : req , target_local_id : req , target_map_id : req
. byte \index
. byte \gfx
. byte OBJ_KIND_CLONE
. space 1 @ Padding
. 2 byte \x , \y
. byte \target_local_id
. space 3 @ Padding
. 2 byte \target_map_id & 0xFF @ map num
. 2 byte \target_map_id >> 8 @ map group
. space 8 @ Padding
inc _num_npcs
. endm
2022-01-24 00:26:22 +00:00
@ Defines a warp event for map data . Mirrors the struct layout of WarpEvent in include / global . fieldmap . h
2022-01-23 23:51:56 +00:00
. macro warp_def x : req , y : req , elevation : req , warpId : req , map_id : req
2017-10-24 03:18:49 +01:00
. 2 byte \x , \y
2022-01-23 23:51:56 +00:00
. byte \elevation
. byte \warpId
2018-06-15 04:00:09 +01:00
. byte \map_id & 0xFF @ map num
. byte \map_id >> 8 @ map group
2017-10-24 03:18:49 +01:00
inc _num_warps
. endm
2022-01-24 00:26:22 +00:00
@ Defines a coord event for map data . Mirrors the struct layout of CoordEvent in include / global . fieldmap . h
2023-02-08 18:11:10 +00:00
. macro coord_event x : req , y : req , elevation : req , var : req , varValue : req , script : req
2017-10-24 03:18:49 +01:00
. 2 byte \x , \y
2022-01-23 23:51:56 +00:00
. byte \elevation
2022-01-24 00:26:22 +00:00
. space 1 @ Padding
2023-02-08 18:11:10 +00:00
. 2 byte \var
. 2 byte \varValue
2022-01-24 00:26:22 +00:00
. space 2 @ Padding
2017-10-24 03:18:49 +01:00
. 4 byte \script
inc _num_traps
. endm
2022-01-24 00:26:22 +00:00
@ Defines a weather coord event for map data . Any coord event is treated as a weather coord event if its script is NULL
2022-01-23 23:51:56 +00:00
. macro coord_weather_event x : req , y : req , elevation : req , weather : req
coord_event \x , \y , \elevation , \weather , 0 , NULL
2018-07-11 17:12:26 +01:00
. endm
2022-01-24 00:26:22 +00:00
@ Defines a generic background event for map data . Mirrors the struct layout of BgEvent in include / global . fieldmap . h
@ 'kind' is any BG_EVENT_ * constant ( see include / constants / event_bg . h ) .
@ 'arg6' and 'arg7' are used differently depending on the bg event type . See macros below
2022-01-23 23:51:56 +00:00
. macro bg_event x : req , y : req , elevation : req , kind : req , arg6 : req , arg7
2018-07-11 17:12:26 +01:00
. 2 byte \x , \y
2022-01-23 23:51:56 +00:00
. byte \elevation
. byte \kind
2022-01-24 00:26:22 +00:00
. space 2 @ Padding
2021-04-01 07:42:02 +01:00
. if \kind != BG_EVENT_HIDDEN_ITEM
2022-01-23 23:51:56 +00:00
. 4 byte \arg6
2017-10-24 03:18:49 +01:00
. else
2022-01-23 23:51:56 +00:00
. 2 byte \arg6
. 2 byte \arg7
2017-10-24 03:18:49 +01:00
. endif
inc _num_signs
. endm
2022-01-24 00:26:22 +00:00
@ Defines a background sign event for map data . 'facing_dir' is any of the BG_EVENT_PLAYER_FACING_ * constants ( see include / constants / event_bg . h )
2022-01-23 23:51:56 +00:00
. macro bg_sign_event x : req , y : req , elevation : req , facing_dir : req , script : req
bg_event \x , \y , \elevation , \facing_dir , \script
. endm
2022-01-24 00:26:22 +00:00
@ Defines a background hidden item event for map data
2022-01-23 23:51:56 +00:00
. macro bg_hidden_item_event x : req , y : req , elevation : req , item : req , flag : req
bg_event \x , \y , \elevation , BG_EVENT_HIDDEN_ITEM , \item , (( \flag ) - FLAG_HIDDEN_ITEMS_START )
2018-10-18 03:07:23 +01:00
. endm
2022-01-24 00:26:22 +00:00
@ Defines a background secret base event for map data
2022-01-23 23:51:56 +00:00
. macro bg_secret_base_event x : req , y : req , elevation : req , secret_base_id : req
bg_event \x , \y , \elevation , BG_EVENT_SECRET_BASE , \secret_base_id
2018-07-11 17:12:26 +01:00
. endm
2022-01-24 00:26:22 +00:00
@ Defines the table of event data for a map . Mirrors the struct layout of MapEvents in include / global . fieldmap . h
2022-01-23 23:51:56 +00:00
. macro map_events npcs : req , warps : req , traps : req , signs : req
2017-10-24 03:18:49 +01:00
. byte _num_npcs , _num_warps , _num_traps , _num_signs
. 4 byte \npcs , \warps , \traps , \signs
reset_map_events
. endm
2022-01-24 00:26:22 +00:00
@ Resets the event counters used to track how many events a map has . Run when the events table is created by map_events
2017-10-24 03:18:49 +01:00
. macro reset_map_events
. set _num_npcs , 0
. set _num_warps , 0
. set _num_traps , 0
. set _num_signs , 0
. endm
2022-01-24 00:26:22 +00:00
@ Initialize the event counters for the first map
2017-10-24 03:18:49 +01:00
reset_map_events
2022-01-24 00:26:22 +00:00
@ Directions for connecting maps
@ The map . json files will only have e . g . " down " as direction data , and this will be appended to " connection_ " by the connection macro
2022-01-23 23:51:56 +00:00
. equiv connection_down , CONNECTION_SOUTH
. equiv connection_up , CONNECTION_NORTH
. equiv connection_left , CONNECTION_WEST
. equiv connection_right , CONNECTION_EAST
. equiv connection_dive , CONNECTION_DIVE
. equiv connection_emerge , CONNECTION_EMERGE
2017-10-24 03:18:49 +01:00
2022-01-24 00:26:22 +00:00
@ Defines a map connection . Mirrors the struct layout of MapConnection in include / global . fieldmap . h
2022-01-23 23:51:56 +00:00
. macro connection direction : req , offset : req , map : req
2022-01-24 00:26:22 +00:00
. byte connection_\direction
. space 3 @ Padding
2017-10-24 03:18:49 +01:00
. 4 byte \offset
map \map
2022-01-24 00:26:22 +00:00
. space 2 @ Padding
2017-10-24 03:18:49 +01:00
. endm
2018-12-26 18:20:15 +00:00
2022-01-24 00:26:22 +00:00
@ Defines the flags for a map header . Mirrors the layout of the bitfield in struct MapHeader in include / global . fieldmap . h
2020-03-11 03:13:27 +00:00
. macro map_header_flags allow_cycling : req , allow_escaping : req , allow_running : req , show_map_name : req
. byte (( \show_map_name & 1 ) << 3 ) | (( \allow_running & 1 ) << 2 ) | (( \allow_escaping & 1 ) << 1 ) | \allow_cycling
2018-12-26 18:20:15 +00:00
. endm