Use exported constants for VC patch (#1161)
This commit is contained in:
6
Makefile
6
Makefile
@@ -117,7 +117,7 @@ $(pokecrystal_debug_obj): RGBASMFLAGS += -D _DEBUG
|
|||||||
$(pokecrystal11_debug_obj): RGBASMFLAGS += -D _CRYSTAL11 -D _DEBUG
|
$(pokecrystal11_debug_obj): RGBASMFLAGS += -D _CRYSTAL11 -D _DEBUG
|
||||||
$(pokecrystal11_vc_obj): RGBASMFLAGS += -D _CRYSTAL11 -D _CRYSTAL11_VC
|
$(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 $^ $@
|
tools/make_patch $*_vc.sym $^ $@
|
||||||
|
|
||||||
rgbdscheck.o: rgbdscheck.asm
|
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_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))))
|
$(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
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
@@ -28,7 +28,7 @@ The `.patch.template` file is the basis for the `.patch` file. Many numeric valu
|
|||||||
|
|
||||||
### vc/pokecrystal11.constants.asm
|
### 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.
|
The `.constants.asm` file is used to export the values of *constants* that are needed by `.patch.template`, so their values will appear in the `.sym` file along with *labels* (ROM banks and addresses).
|
||||||
|
|
||||||
|
|
||||||
### tools/make_patch.c
|
### tools/make_patch.c
|
||||||
@@ -38,13 +38,13 @@ The program used to convert a `.patch.template` into a `.patch` file.
|
|||||||
To convert `vc.patch.template` into `vc.patch`:
|
To convert `vc.patch.template` into `vc.patch`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
tools/make_patch labels.sym constants.sym patched.gbc original.gbc vc.patch.template vc.patch
|
tools/make_patch values.sym patched.gbc original.gbc vc.patch.template vc.patch
|
||||||
```
|
```
|
||||||
|
|
||||||
For example, this is what `make crystal11_vc` does:
|
For example, this is what `make crystal11_vc` does:
|
||||||
|
|
||||||
```bash
|
```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
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
@@ -69,3 +69,7 @@ INCLUDE "constants/trainer_constants.asm"
|
|||||||
INCLUDE "constants/trainer_data_constants.asm"
|
INCLUDE "constants/trainer_data_constants.asm"
|
||||||
INCLUDE "constants/type_constants.asm"
|
INCLUDE "constants/type_constants.asm"
|
||||||
INCLUDE "constants/battle_tower_constants.asm"
|
INCLUDE "constants/battle_tower_constants.asm"
|
||||||
|
|
||||||
|
if DEF(_CRYSTAL11_VC)
|
||||||
|
INCLUDE "vc/pokecrystal11.constants.asm"
|
||||||
|
endc
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
#define PROGRAM_NAME "make_patch"
|
#define PROGRAM_NAME "make_patch"
|
||||||
#define USAGE_OPTS "labels.sym constants.sym patched.gbc original.gbc vc.patch.template vc.patch"
|
#define USAGE_OPTS "values.sym patched.gbc original.gbc vc.patch.template vc.patch"
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
@@ -113,13 +113,14 @@ void parse_symbol_value(char *input, int *restrict bank, int *restrict address)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void parse_symbols(const char *filename, struct Symbol **symbols) {
|
struct Symbol *parse_symbols(const char *filename) {
|
||||||
FILE *file = xfopen(filename, 'r');
|
FILE *file = xfopen(filename, 'r');
|
||||||
struct Buffer *buffer = buffer_create(1);
|
struct Buffer *buffer = buffer_create(1);
|
||||||
|
|
||||||
enum { SYM_PRE, SYM_VALUE, SYM_SPACE, SYM_NAME } state = SYM_PRE;
|
enum { SYM_PRE, SYM_VALUE, SYM_SPACE, SYM_NAME } state = SYM_PRE;
|
||||||
int bank = 0;
|
int bank = 0;
|
||||||
int address = 0;
|
int address = 0;
|
||||||
|
struct Symbol *symbols = NULL;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
int c = getc(file);
|
int c = getc(file);
|
||||||
@@ -127,7 +128,7 @@ void parse_symbols(const char *filename, struct Symbol **symbols) {
|
|||||||
if (state == SYM_NAME) {
|
if (state == SYM_NAME) {
|
||||||
// The symbol name has ended; append the buffered symbol
|
// The symbol name has ended; append the buffered symbol
|
||||||
buffer_append(buffer, &(char []){'\0'});
|
buffer_append(buffer, &(char []){'\0'});
|
||||||
symbol_append(symbols, buffer->data, bank, address);
|
symbol_append(&symbols, buffer->data, bank, address);
|
||||||
}
|
}
|
||||||
// Skip to the next line, ignoring anything after the symbol value and name
|
// Skip to the next line, ignoring anything after the symbol value and name
|
||||||
state = SYM_PRE;
|
state = SYM_PRE;
|
||||||
@@ -156,6 +157,7 @@ void parse_symbols(const char *filename, struct Symbol **symbols) {
|
|||||||
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
buffer_free(buffer);
|
buffer_free(buffer);
|
||||||
|
return symbols;
|
||||||
}
|
}
|
||||||
|
|
||||||
int strfind(const char *s, const char *list[], int count) {
|
int strfind(const char *s, const char *list[], int count) {
|
||||||
@@ -449,20 +451,18 @@ bool verify_completeness(FILE *restrict orig_rom, FILE *restrict new_rom, struct
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
if (argc != 7) {
|
if (argc != 6) {
|
||||||
usage_exit(1);
|
usage_exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Symbol *symbols = NULL;
|
struct Symbol *symbols = parse_symbols(argv[1]);
|
||||||
parse_symbols(argv[1], &symbols);
|
|
||||||
parse_symbols(argv[2], &symbols);
|
|
||||||
|
|
||||||
FILE *new_rom = xfopen(argv[3], 'r');
|
FILE *new_rom = xfopen(argv[2], 'r');
|
||||||
FILE *orig_rom = xfopen(argv[4], 'r');
|
FILE *orig_rom = xfopen(argv[3], 'r');
|
||||||
struct Buffer *patches = process_template(argv[5], argv[6], new_rom, orig_rom, symbols);
|
struct Buffer *patches = process_template(argv[4], argv[5], new_rom, orig_rom, symbols);
|
||||||
|
|
||||||
if (!verify_completeness(orig_rom, new_rom, patches)) {
|
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);
|
symbol_free(symbols);
|
||||||
|
@@ -1,39 +1,34 @@
|
|||||||
; These are all the asm constants needed to make the crystal11_vc patch.
|
; 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]
|
; [fight begin]
|
||||||
vc_const SCREEN_HEIGHT_PX
|
EXPORT SCREEN_HEIGHT_PX
|
||||||
|
|
||||||
; [print forbid 2]
|
; [print forbid 2]
|
||||||
vc_const A_BUTTON
|
EXPORT A_BUTTON
|
||||||
; [print forbid 3]
|
; [print forbid 3]
|
||||||
vc_const MAPGROUP_CIANWOOD
|
EXPORT MAPGROUP_CIANWOOD
|
||||||
vc_const MAP_CIANWOOD_PHOTO_STUDIO
|
EXPORT MAP_CIANWOOD_PHOTO_STUDIO
|
||||||
; [print forbid 5]
|
; [print forbid 5]
|
||||||
vc_const NO_INPUT
|
EXPORT NO_INPUT
|
||||||
vc_const B_BUTTON
|
EXPORT B_BUTTON
|
||||||
vc_const D_UP
|
EXPORT D_UP
|
||||||
vc_const D_DOWN
|
EXPORT D_DOWN
|
||||||
|
|
||||||
; [FPA 001 Begin]
|
; [FPA 001 Begin]
|
||||||
vc_const FISSURE
|
EXPORT FISSURE
|
||||||
; [FPA 002 Begin]
|
; [FPA 002 Begin]
|
||||||
vc_const SELFDESTRUCT
|
EXPORT SELFDESTRUCT
|
||||||
; [FPA 003 Begin]
|
; [FPA 003 Begin]
|
||||||
vc_const THUNDER
|
EXPORT THUNDER
|
||||||
; [FPA 004 Begin]
|
; [FPA 004 Begin]
|
||||||
vc_const FLASH
|
EXPORT FLASH
|
||||||
; [FPA 005 Begin]
|
; [FPA 005 Begin]
|
||||||
vc_const EXPLOSION
|
EXPORT EXPLOSION
|
||||||
; [FPA 006 Begin]
|
; [FPA 006 Begin]
|
||||||
vc_const HORN_DRILL
|
EXPORT HORN_DRILL
|
||||||
; [FPA 007 Begin]
|
; [FPA 007 Begin]
|
||||||
vc_const HYPER_BEAM
|
EXPORT HYPER_BEAM
|
||||||
|
|
||||||
; [FPA 042801 Begin]
|
; [FPA 042801 Begin]
|
||||||
vc_const PRESENT
|
EXPORT PRESENT
|
||||||
vc_const anim_1gfx_command
|
EXPORT anim_1gfx_command
|
||||||
|
Reference in New Issue
Block a user