From 9f5a3d8b5d3bf412837fc3d6301fd971e3c75329 Mon Sep 17 00:00:00 2001 From: vulcandth Date: Wed, 25 Dec 2024 21:27:12 -0600 Subject: [PATCH] Use exported constants for VC patch --- Makefile | 6 +----- docs/vc_patch.md | 9 ++------ includes.asm | 2 ++ tools/make_patch.c | 13 ++++++------ vc/pokecrystal11.constants.asm | 39 +++++++++++++++------------------- 5 files changed, 28 insertions(+), 41 deletions(-) diff --git a/Makefile b/Makefile index cd3852adaa8..ed76db4b204 100644 --- a/Makefile +++ b/Makefile @@ -117,7 +117,7 @@ $(pokecrystal_debug_obj): RGBASMFLAGS += -D _DEBUG $(pokecrystal11_debug_obj): RGBASMFLAGS += -D _CRYSTAL11 -D _DEBUG $(pokecrystal11_vc_obj): RGBASMFLAGS += -D _CRYSTAL11 -D _CRYSTAL11_VC -%.patch: vc/%.constants.sym %_vc.gbc %.gbc vc/%.patch.template +%.patch: %_vc.gbc %.gbc vc/%.patch.template tools/make_patch $*_vc.sym $^ $@ rgbdscheck.o: rgbdscheck.asm @@ -146,10 +146,6 @@ $(foreach obj, $(pokecrystal_debug_obj), $(eval $(call DEP,$(obj),$(obj:_debug.o $(foreach obj, $(pokecrystal11_debug_obj), $(eval $(call DEP,$(obj),$(obj:11_debug.o=.asm)))) $(foreach obj, $(pokecrystal11_vc_obj), $(eval $(call DEP,$(obj),$(obj:11_vc.o=.asm)))) -# Dependencies for VC files that need to run scan_includes -%.constants.sym: %.constants.asm $(shell tools/scan_includes %.constants.asm) $(preinclude_deps) | rgbdscheck.o - $(RGBASM) $(RGBASMFLAGS) $< > $@ - endif diff --git a/docs/vc_patch.md b/docs/vc_patch.md index cc0e916353c..783fe909952 100644 --- a/docs/vc_patch.md +++ b/docs/vc_patch.md @@ -26,11 +26,6 @@ There are a few files involved with building the `.patch` file, in addition to t The `.patch.template` file is the basis for the `.patch` file. Many numeric values in the `.patch` file are derived from the values of labels, constants, and ROM content; these values are abstracted into *commands* that get evaluated by `tools/make_patch` to output symbolic names as their actual values, formatted to match the original `.patch` file. -### vc/pokecrystal11.constants.asm - -The `.constants.asm` file is used to create a `.constants.sym` file. Typical `.sym` files only list the values of *labels* (ROM banks and addresses); this file is used to list *constants* that are needed by the `.patch.template`. Any constants that the `.patch.template` refers to must be explicitly printed here with the `vc_const` macro. - - ### tools/make_patch.c The program used to convert a `.patch.template` into a `.patch` file. @@ -38,13 +33,13 @@ The program used to convert a `.patch.template` into a `.patch` file. To convert `vc.patch.template` into `vc.patch`: ```bash -tools/make_patch labels.sym constants.sym patched.gbc original.gbc vc.patch.template vc.patch +tools/make_patch labels.sym patched.gbc original.gbc vc.patch.template vc.patch ``` For example, this is what `make crystal11_vc` does: ```bash -tools/make_patch pokecrystal11_vc.sym vc/pokecrystal11.constants.sym pokecrystal11_vc.gbc pokecrystal11.gbc vc/pokecrystal11.patch.template pokecrystal11.patch +tools/make_patch pokecrystal11_vc.sym pokecrystal11_vc.gbc pokecrystal11.gbc vc/pokecrystal11.patch.template pokecrystal11.patch ``` diff --git a/includes.asm b/includes.asm index 5d4c1c38d8c..9a79361cc65 100644 --- a/includes.asm +++ b/includes.asm @@ -69,3 +69,5 @@ INCLUDE "constants/trainer_constants.asm" INCLUDE "constants/trainer_data_constants.asm" INCLUDE "constants/type_constants.asm" INCLUDE "constants/battle_tower_constants.asm" + +INCLUDE "vc/pokecrystal11.constants.asm" diff --git a/tools/make_patch.c b/tools/make_patch.c index 3a36accdd87..706a42ccb84 100644 --- a/tools/make_patch.c +++ b/tools/make_patch.c @@ -1,5 +1,5 @@ #define PROGRAM_NAME "make_patch" -#define USAGE_OPTS "labels.sym constants.sym patched.gbc original.gbc vc.patch.template vc.patch" +#define USAGE_OPTS "labels.sym patched.gbc original.gbc vc.patch.template vc.patch" #include "common.h" @@ -449,20 +449,19 @@ bool verify_completeness(FILE *restrict orig_rom, FILE *restrict new_rom, struct } int main(int argc, char *argv[]) { - if (argc != 7) { + if (argc != 6) { usage_exit(1); } struct Symbol *symbols = NULL; parse_symbols(argv[1], &symbols); - parse_symbols(argv[2], &symbols); - FILE *new_rom = xfopen(argv[3], 'r'); - FILE *orig_rom = xfopen(argv[4], 'r'); - struct Buffer *patches = process_template(argv[5], argv[6], new_rom, orig_rom, symbols); + FILE *new_rom = xfopen(argv[2], 'r'); + FILE *orig_rom = xfopen(argv[3], 'r'); + struct Buffer *patches = process_template(argv[4], argv[5], new_rom, orig_rom, symbols); if (!verify_completeness(orig_rom, new_rom, patches)) { - fprintf(stderr, PROGRAM_NAME ": Warning: Not all ROM differences are defined by \"%s\"\n", argv[6]); + fprintf(stderr, PROGRAM_NAME ": Warning: Not all ROM differences are defined by \"%s\"\n", argv[5]); } symbol_free(symbols); diff --git a/vc/pokecrystal11.constants.asm b/vc/pokecrystal11.constants.asm index 8410f5f074c..f954e8b44e4 100644 --- a/vc/pokecrystal11.constants.asm +++ b/vc/pokecrystal11.constants.asm @@ -1,39 +1,34 @@ ; These are all the asm constants needed to make the crystal11_vc patch. -MACRO vc_const - DEF x = \1 - println "{02x:x} \1" ; same format as rgblink's .sym file -ENDM - ; [fight begin] - vc_const SCREEN_HEIGHT_PX +EXPORT SCREEN_HEIGHT_PX ; [print forbid 2] - vc_const A_BUTTON +EXPORT A_BUTTON ; [print forbid 3] - vc_const MAPGROUP_CIANWOOD - vc_const MAP_CIANWOOD_PHOTO_STUDIO +EXPORT MAPGROUP_CIANWOOD +EXPORT MAP_CIANWOOD_PHOTO_STUDIO ; [print forbid 5] - vc_const NO_INPUT - vc_const B_BUTTON - vc_const D_UP - vc_const D_DOWN +EXPORT NO_INPUT +EXPORT B_BUTTON +EXPORT D_UP +EXPORT D_DOWN ; [FPA 001 Begin] - vc_const FISSURE +EXPORT FISSURE ; [FPA 002 Begin] - vc_const SELFDESTRUCT +EXPORT SELFDESTRUCT ; [FPA 003 Begin] - vc_const THUNDER +EXPORT THUNDER ; [FPA 004 Begin] - vc_const FLASH +EXPORT FLASH ; [FPA 005 Begin] - vc_const EXPLOSION +EXPORT EXPLOSION ; [FPA 006 Begin] - vc_const HORN_DRILL +EXPORT HORN_DRILL ; [FPA 007 Begin] - vc_const HYPER_BEAM +EXPORT HYPER_BEAM ; [FPA 042801 Begin] - vc_const PRESENT - vc_const anim_1gfx_command +EXPORT PRESENT +EXPORT anim_1gfx_command