diff options
| author | vulcandth <vulcandth@gmail.com> | 2024-12-27 12:10:13 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-27 13:10:13 -0500 |
| commit | 0d4562d1b855bfa7965349e1a92deac0f5b89a27 (patch) | |
| tree | dc3696bd493d990070788ee6afa84857eed0f7fd /tools | |
| parent | Don't pass redundant label names to `table_width` and `list_start` (#484) (diff) | |
| download | pokeyellow-0d4562d1b855bfa7965349e1a92deac0f5b89a27.tar.gz pokeyellow-0d4562d1b855bfa7965349e1a92deac0f5b89a27.tar.xz pokeyellow-0d4562d1b855bfa7965349e1a92deac0f5b89a27.zip | |
Use exported constants for VC patch (#483)
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/make_patch.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/tools/make_patch.c b/tools/make_patch.c index 77a30683..d96bf216 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 "values.sym patched.gbc original.gbc vc.patch.template vc.patch" #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'); struct Buffer *buffer = buffer_create(1); enum { SYM_PRE, SYM_VALUE, SYM_SPACE, SYM_NAME } state = SYM_PRE; int bank = 0; int address = 0; + struct Symbol *symbols = NULL; for (;;) { int c = getc(file); @@ -127,7 +128,7 @@ void parse_symbols(const char *filename, struct Symbol **symbols) { if (state == SYM_NAME) { // The symbol name has ended; append the buffered symbol 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 state = SYM_PRE; @@ -156,6 +157,7 @@ void parse_symbols(const char *filename, struct Symbol **symbols) { fclose(file); buffer_free(buffer); + return symbols; } int strfind(const char *s, const char *list[], int count) { @@ -443,20 +445,18 @@ 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); + struct Symbol *symbols = parse_symbols(argv[1]); - 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); |
