Sync map data macros
This commit is contained in:
@@ -47,6 +47,8 @@ sound/**/*.bin
|
|||||||
sound/songs/midi/*.s
|
sound/songs/midi/*.s
|
||||||
src/data/items.h
|
src/data/items.h
|
||||||
src/data/wild_encounters.h
|
src/data/wild_encounters.h
|
||||||
|
src/data/region_map/region_map_entries.h
|
||||||
|
src/data/region_map/region_map_entry_strings.h
|
||||||
tags
|
tags
|
||||||
tools/agbcc
|
tools/agbcc
|
||||||
tools/binutils
|
tools/binutils
|
||||||
|
|||||||
+78
-35
@@ -1,32 +1,44 @@
|
|||||||
.macro map map_id
|
@ 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
|
||||||
|
.macro map map_id:req
|
||||||
.byte \map_id >> 8 @ map group
|
.byte \map_id >> 8 @ map group
|
||||||
.byte \map_id & 0xFF @ map num
|
.byte \map_id & 0xFF @ map num
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
.macro map_script type, address
|
@ Defines a map script. 'type' is any MAP_SCRIPT_* constant (see include/constants/map_scripts.h)
|
||||||
|
.macro map_script type:req, script:req
|
||||||
.byte \type
|
.byte \type
|
||||||
.4byte \address
|
.4byte \script
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
.macro map_script_2 word1, word2, address
|
@ Defines an entry in a map script table (for either ON_WARP_INTO_MAP_TABLE or ON_FRAME_TABLE)
|
||||||
.2byte \word1
|
.macro map_script_2 var:req, compare:req, script:req
|
||||||
.2byte \word2
|
.2byte \var
|
||||||
.4byte \address
|
.2byte \compare
|
||||||
|
.4byte \script
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
|
@ 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
|
.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
|
||||||
.byte \index
|
.byte \index
|
||||||
.byte \gfx
|
.byte \gfx
|
||||||
.byte OBJ_KIND_NORMAL
|
.byte OBJ_KIND_NORMAL
|
||||||
.space 1 @ Padding
|
.space 1 @ Padding
|
||||||
.2byte \x, \y
|
.2byte \x, \y
|
||||||
.byte \elevation, \movement_type, ((\y_radius << 4) | \x_radius), 0
|
.byte \elevation
|
||||||
.2byte \trainer_type, \sight_radius_tree_etc
|
.byte \movement_type
|
||||||
|
.byte ((\y_radius << 4) | \x_radius)
|
||||||
|
.space 1 @ Padding
|
||||||
|
.2byte \trainer_type
|
||||||
|
.2byte \sight_radius_tree_etc
|
||||||
.4byte \script
|
.4byte \script
|
||||||
.2byte \event_flag, 0
|
.2byte \event_flag
|
||||||
|
.space 2 @ Padding
|
||||||
inc _num_npcs
|
inc _num_npcs
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
|
@ 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
|
||||||
.macro clone_event index:req, gfx:req, x:req, y:req, target_local_id:req, target_map_id:req
|
.macro clone_event index:req, gfx:req, x:req, y:req, target_local_id:req, target_map_id:req
|
||||||
.byte \index
|
.byte \index
|
||||||
.byte \gfx
|
.byte \gfx
|
||||||
@@ -41,45 +53,71 @@
|
|||||||
inc _num_npcs
|
inc _num_npcs
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
.macro warp_def x, y, byte, warp, map_id
|
@ Defines a warp event for map data. Mirrors the struct layout of WarpEvent in include/global.fieldmap.h
|
||||||
|
.macro warp_def x:req, y:req, elevation:req, warpId:req, map_id:req
|
||||||
.2byte \x, \y
|
.2byte \x, \y
|
||||||
.byte \byte, \warp
|
.byte \elevation
|
||||||
|
.byte \warpId
|
||||||
.byte \map_id & 0xFF @ map num
|
.byte \map_id & 0xFF @ map num
|
||||||
.byte \map_id >> 8 @ map group
|
.byte \map_id >> 8 @ map group
|
||||||
inc _num_warps
|
inc _num_warps
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
.macro coord_event x, y, byte1, byte2, word1, word2, word3, script
|
@ Defines a coord event for map data. Mirrors the struct layout of CoordEvent in include/global.fieldmap.h
|
||||||
|
.macro coord_event x:req, y:req, elevation:req, var:req, varValue:req, script:req
|
||||||
.2byte \x, \y
|
.2byte \x, \y
|
||||||
.byte \byte1, \byte2
|
.byte \elevation
|
||||||
.2byte \word1, \word2, \word3
|
.space 1 @ Padding
|
||||||
|
.2byte \var
|
||||||
|
.2byte \varValue
|
||||||
|
.space 2 @ Padding
|
||||||
.4byte \script
|
.4byte \script
|
||||||
inc _num_traps
|
inc _num_traps
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
.macro bg_event x, y, byte, kind, word, arg6, arg7, arg8
|
@ 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' is used differently depending on the bg event type. 'arg7' and 'arg8' are only used by bg_hidden_item_event.
|
||||||
|
@ See macros below.
|
||||||
|
.macro bg_event x:req, y, elevation:req, kind:req, arg6:req, arg7, arg8
|
||||||
.2byte \x, \y
|
.2byte \x, \y
|
||||||
.byte \byte, \kind
|
.byte \elevation
|
||||||
.2byte \word
|
.byte \kind
|
||||||
.if \kind < 5
|
.space 2 @ Padding
|
||||||
.4byte \arg6
|
.if \kind != BG_EVENT_HIDDEN_ITEM
|
||||||
|
.4byte \arg6
|
||||||
.else
|
.else
|
||||||
.2byte \arg6
|
.2byte \arg6
|
||||||
.byte \arg7, \arg8
|
.byte \arg7
|
||||||
|
.byte \arg8
|
||||||
.endif
|
.endif
|
||||||
inc _num_signs
|
inc _num_signs
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
.macro bg_hidden_item_event x, y, height, item, flag, quantity, underfoot
|
@ 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)
|
||||||
bg_event \x, \y, \height, 7, 0, \item, \flag, \quantity | (\underfoot << 7)
|
.macro bg_sign_event x:req, y:req, elevation:req, facing_dir:req, script:req
|
||||||
|
bg_event \x, \y, \elevation, \facing_dir, \script
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
.macro map_events npcs, warps, traps, signs
|
@ Defines a background hidden item event for map data
|
||||||
|
.macro bg_hidden_item_event x:req, y:req, elevation:req, item:req, flag:req, quantity:req, underfoot:req
|
||||||
|
bg_event \x, \y, \elevation, BG_EVENT_HIDDEN_ITEM, \item, \flag, \quantity | (\underfoot << 7)
|
||||||
|
.endm
|
||||||
|
|
||||||
|
@ Defines a background secret base event for map data.
|
||||||
|
@ Unused by FRLG
|
||||||
|
.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
|
||||||
|
.endm
|
||||||
|
|
||||||
|
@ Defines the table of event data for a map. Mirrors the struct layout of MapEvents in include/global.fieldmap.h
|
||||||
|
.macro map_events npcs:req, warps:req, traps:req, signs:req
|
||||||
.byte _num_npcs, _num_warps, _num_traps, _num_signs
|
.byte _num_npcs, _num_warps, _num_traps, _num_signs
|
||||||
.4byte \npcs, \warps, \traps, \signs
|
.4byte \npcs, \warps, \traps, \signs
|
||||||
reset_map_events
|
reset_map_events
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
|
@ Resets the event counters used to track how many events a map has. Run when the events table is created by map_events
|
||||||
.macro reset_map_events
|
.macro reset_map_events
|
||||||
.set _num_npcs, 0
|
.set _num_npcs, 0
|
||||||
.set _num_warps, 0
|
.set _num_warps, 0
|
||||||
@@ -87,23 +125,28 @@
|
|||||||
.set _num_signs, 0
|
.set _num_signs, 0
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
|
@ Initialize the event counters for the first map
|
||||||
reset_map_events
|
reset_map_events
|
||||||
|
|
||||||
|
@ 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
|
||||||
|
.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
|
||||||
|
|
||||||
.equiv connection_down, 1
|
@ Defines a map connection. Mirrors the struct layout of MapConnection in include/global.fieldmap.h
|
||||||
.equiv connection_up, 2
|
.macro connection direction:req, offset:req, map:req
|
||||||
.equiv connection_left, 3
|
.byte connection_\direction
|
||||||
.equiv connection_right, 4
|
.space 3 @ Padding
|
||||||
.equiv connection_dive, 5
|
|
||||||
.equiv connection_emerge, 6
|
|
||||||
|
|
||||||
.macro connection direction, offset, map, filler
|
|
||||||
.4byte connection_\direction
|
|
||||||
.4byte \offset
|
.4byte \offset
|
||||||
map \map
|
map \map
|
||||||
.space 2
|
.space 2 @ Padding
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
|
@ Defines the flags for a map header. Mirrors the layout of the bitfield in struct MapHeader in include/global.fieldmap.h
|
||||||
.macro map_header_flags allow_cycling:req, allow_escaping:req, allow_running:req, show_map_name:req
|
.macro map_header_flags allow_cycling:req, allow_escaping:req, allow_running:req, show_map_name:req
|
||||||
.byte \allow_cycling
|
.byte \allow_cycling
|
||||||
.byte ((\show_map_name & 1) << 2) | ((\allow_running & 1) << 1) | ((\allow_escaping & 1) << 0)
|
.byte ((\show_map_name & 1) << 2) | ((\allow_running & 1) << 1) | ((\allow_escaping & 1) << 0)
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#include "constants/global.h"
|
||||||
#include "constants/layouts.h"
|
#include "constants/layouts.h"
|
||||||
#include "constants/maps.h"
|
#include "constants/maps.h"
|
||||||
#include "constants/region_map_sections.h"
|
#include "constants/region_map_sections.h"
|
||||||
|
|||||||
@@ -8,5 +8,6 @@
|
|||||||
#define BG_EVENT_PLAYER_FACING_WEST 4
|
#define BG_EVENT_PLAYER_FACING_WEST 4
|
||||||
|
|
||||||
#define BG_EVENT_HIDDEN_ITEM 7
|
#define BG_EVENT_HIDDEN_ITEM 7
|
||||||
|
#define BG_EVENT_SECRET_BASE 8
|
||||||
|
|
||||||
#endif // GUARD_CONSTANTS_EVENT_BG_H
|
#endif // GUARD_CONSTANTS_EVENT_BG_H
|
||||||
|
|||||||
@@ -115,4 +115,13 @@
|
|||||||
#define DIR_NORTHWEST 7
|
#define DIR_NORTHWEST 7
|
||||||
#define DIR_NORTHEAST 8
|
#define DIR_NORTHEAST 8
|
||||||
|
|
||||||
|
#define CONNECTION_INVALID -1
|
||||||
|
#define CONNECTION_NONE 0
|
||||||
|
#define CONNECTION_SOUTH 1
|
||||||
|
#define CONNECTION_NORTH 2
|
||||||
|
#define CONNECTION_WEST 3
|
||||||
|
#define CONNECTION_EAST 4
|
||||||
|
#define CONNECTION_DIVE 5
|
||||||
|
#define CONNECTION_EMERGE 6
|
||||||
|
|
||||||
#endif //GUARD_CONSTANTS_GLOBAL_H
|
#endif //GUARD_CONSTANTS_GLOBAL_H
|
||||||
|
|||||||
@@ -50,18 +50,6 @@ enum
|
|||||||
TILE_TERRAIN_WATERFALL,
|
TILE_TERRAIN_WATERFALL,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
CONNECTION_INVALID = -1,
|
|
||||||
CONNECTION_NONE,
|
|
||||||
CONNECTION_SOUTH,
|
|
||||||
CONNECTION_NORTH,
|
|
||||||
CONNECTION_WEST,
|
|
||||||
CONNECTION_EAST,
|
|
||||||
CONNECTION_DIVE,
|
|
||||||
CONNECTION_EMERGE
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef void (*TilesetCB)(void);
|
typedef void (*TilesetCB)(void);
|
||||||
|
|
||||||
struct Tileset
|
struct Tileset
|
||||||
|
|||||||
@@ -340,9 +340,9 @@ string generate_firered_map_events_text(Json map_data) {
|
|||||||
text << "\tcoord_event "
|
text << "\tcoord_event "
|
||||||
<< coord_event["x"].int_value() << ", "
|
<< coord_event["x"].int_value() << ", "
|
||||||
<< coord_event["y"].int_value() << ", "
|
<< coord_event["y"].int_value() << ", "
|
||||||
<< coord_event["elevation"].int_value() << ", 0, "
|
<< coord_event["elevation"].int_value() << ", "
|
||||||
<< coord_event["var"].string_value() << ", "
|
<< coord_event["var"].string_value() << ", "
|
||||||
<< coord_event["var_value"].string_value() << ", 0, "
|
<< coord_event["var_value"].string_value() << ", "
|
||||||
<< coord_event["script"].string_value() << "\n";
|
<< coord_event["script"].string_value() << "\n";
|
||||||
}
|
}
|
||||||
else if (coord_event["type"] == "weather") {
|
else if (coord_event["type"] == "weather") {
|
||||||
@@ -363,11 +363,11 @@ string generate_firered_map_events_text(Json map_data) {
|
|||||||
text << bgs_label << "::\n";
|
text << bgs_label << "::\n";
|
||||||
for (auto &bg_event : map_data["bg_events"].array_items()) {
|
for (auto &bg_event : map_data["bg_events"].array_items()) {
|
||||||
if (bg_event["type"] == "sign") {
|
if (bg_event["type"] == "sign") {
|
||||||
text << "\tbg_event "
|
text << "\tbg_sign_event "
|
||||||
<< bg_event["x"].int_value() << ", "
|
<< bg_event["x"].int_value() << ", "
|
||||||
<< bg_event["y"].int_value() << ", "
|
<< bg_event["y"].int_value() << ", "
|
||||||
<< bg_event["elevation"].int_value() << ", "
|
<< bg_event["elevation"].int_value() << ", "
|
||||||
<< bg_event["player_facing_dir"].string_value() << ", 0,"
|
<< bg_event["player_facing_dir"].string_value() << ", "
|
||||||
<< bg_event["script"].string_value() << "\n";
|
<< bg_event["script"].string_value() << "\n";
|
||||||
}
|
}
|
||||||
else if (bg_event["type"] == "hidden_item") {
|
else if (bg_event["type"] == "hidden_item") {
|
||||||
|
|||||||
Reference in New Issue
Block a user