Skip to content

Commit 5336950

Browse files
authored
Use exported constants for VC patch (#124)
1 parent f8a7ac3 commit 5336950

File tree

5 files changed

+67
-73
lines changed

5 files changed

+67
-73
lines changed

Makefile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ endif
9090
$(pokeyellow_debug_obj): RGBASMFLAGS += -D _DEBUG
9191
$(pokeyellow_vc_obj): RGBASMFLAGS += -D _YELLOW_VC
9292

93-
%.patch: vc/%.constants.sym %_vc.gbc %.gbc vc/%.patch.template
93+
%.patch: %_vc.gbc %.gbc vc/%.patch.template
9494
tools/make_patch $*_vc.sym $^ $@
9595

9696
rgbdscheck.o: rgbdscheck.asm
@@ -116,10 +116,6 @@ $(foreach obj, $(pokeyellow_obj), $(eval $(call DEP,$(obj),$(obj:.o=.asm))))
116116
$(foreach obj, $(pokeyellow_debug_obj), $(eval $(call DEP,$(obj),$(obj:_debug.o=.asm))))
117117
$(foreach obj, $(pokeyellow_vc_obj), $(eval $(call DEP,$(obj),$(obj:_vc.o=.asm))))
118118

119-
# Dependencies for VC files that need to run scan_includes
120-
%.constants.sym: %.constants.asm $(shell tools/scan_includes %.constants.asm) $(preinclude_deps) | rgbdscheck.o
121-
$(RGBASM) $(RGBASMFLAGS) $< > $@
122-
123119
endif
124120

125121

includes.asm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,7 @@ INCLUDE "constants/text_constants.asm"
5353
INCLUDE "constants/menu_constants.asm"
5454
INCLUDE "constants/sprite_anim_constants.asm"
5555
INCLUDE "constants/pikachu_emotion_constants.asm"
56+
57+
IF DEF(_YELLOW_VC)
58+
INCLUDE "vc/pokeyellow.constants.asm"
59+
ENDC

tools/make_patch.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#define PROGRAM_NAME "make_patch"
2-
#define USAGE_OPTS "labels.sym constants.sym patched.gbc original.gbc vc.patch.template vc.patch"
2+
#define USAGE_OPTS "values.sym patched.gbc original.gbc vc.patch.template vc.patch"
33

44
#include "common.h"
55

@@ -113,21 +113,22 @@ void parse_symbol_value(char *input, int *restrict bank, int *restrict address)
113113
}
114114
}
115115

116-
void parse_symbols(const char *filename, struct Symbol **symbols) {
116+
struct Symbol *parse_symbols(const char *filename) {
117117
FILE *file = xfopen(filename, 'r');
118118
struct Buffer *buffer = buffer_create(1);
119119

120120
enum { SYM_PRE, SYM_VALUE, SYM_SPACE, SYM_NAME } state = SYM_PRE;
121121
int bank = 0;
122122
int address = 0;
123+
struct Symbol *symbols = NULL;
123124

124125
for (;;) {
125126
int c = getc(file);
126127
if (c == EOF || c == '\n' || c == '\r' || c == ';' || (state == SYM_NAME && (c == ' ' || c == '\t'))) {
127128
if (state == SYM_NAME) {
128129
// The symbol name has ended; append the buffered symbol
129130
buffer_append(buffer, &(char []){'\0'});
130-
symbol_append(symbols, buffer->data, bank, address);
131+
symbol_append(&symbols, buffer->data, bank, address);
131132
}
132133
// Skip to the next line, ignoring anything after the symbol value and name
133134
state = SYM_PRE;
@@ -156,6 +157,7 @@ void parse_symbols(const char *filename, struct Symbol **symbols) {
156157

157158
fclose(file);
158159
buffer_free(buffer);
160+
return symbols;
159161
}
160162

161163
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
443445
}
444446

445447
int main(int argc, char *argv[]) {
446-
if (argc != 7) {
448+
if (argc != 6) {
447449
usage_exit(1);
448450
}
449451

450-
struct Symbol *symbols = NULL;
451-
parse_symbols(argv[1], &symbols);
452-
parse_symbols(argv[2], &symbols);
452+
struct Symbol *symbols = parse_symbols(argv[1]);
453453

454-
FILE *new_rom = xfopen(argv[3], 'r');
455-
FILE *orig_rom = xfopen(argv[4], 'r');
456-
struct Buffer *patches = process_template(argv[5], argv[6], new_rom, orig_rom, symbols);
454+
FILE *new_rom = xfopen(argv[2], 'r');
455+
FILE *orig_rom = xfopen(argv[3], 'r');
456+
struct Buffer *patches = process_template(argv[4], argv[5], new_rom, orig_rom, symbols);
457457

458458
if (!verify_completeness(orig_rom, new_rom, patches)) {
459-
fprintf(stderr, PROGRAM_NAME ": Warning: Not all ROM differences are defined by \"%s\"\n", argv[6]);
459+
fprintf(stderr, PROGRAM_NAME ": Warning: Not all ROM differences are defined by \"%s\"\n", argv[5]);
460460
}
461461

462462
symbol_free(symbols);

vc/pokeyellow.constants.asm

Lines changed: 30 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,53 @@
11
; These are all the asm constants needed to make the yellow_vc patch.
22

3-
MACRO vc_const
4-
DEF x = \1
5-
PRINTLN "{02x:x} \1" ; same format as rgblink's .sym file
6-
ENDM
7-
83
; [FPA 001 Begin]
9-
vc_const "M"
10-
vc_const "E"
11-
vc_const "G"
12-
vc_const "A"
13-
vc_const "P"
14-
vc_const "X"
15-
vc_const "L"
16-
vc_const "S"
17-
vc_const "F"
18-
vc_const MEGA_PUNCH
4+
EXPORT DEF M_CHAR EQU "M"
5+
EXPORT DEF E_CHAR EQU "E"
6+
EXPORT DEF G_CHAR EQU "G"
7+
EXPORT DEF A_CHAR EQU "A"
8+
EXPORT DEF P_CHAR EQU "P"
9+
EXPORT DEF X_CHAR EQU "X"
10+
EXPORT DEF L_CHAR EQU "L"
11+
EXPORT DEF S_CHAR EQU "S"
12+
EXPORT DEF F_CHAR EQU "F"
13+
EXPORT MEGA_PUNCH
1914

2015
; [FPA 002 Begin]
21-
vc_const "U"
22-
vc_const "I"
23-
vc_const GUILLOTINE
16+
EXPORT DEF U_CHAR EQU "U"
17+
EXPORT DEF I_CHAR EQU "I"
18+
EXPORT GUILLOTINE
2419

2520
; [FPA 003 Begin]
26-
vc_const "K"
27-
vc_const MEGA_KICK
21+
EXPORT DEF K_CHAR EQU "K"
22+
EXPORT MEGA_KICK
2823

2924
; [FPA 004 Begin]
30-
vc_const "B"
31-
vc_const "Z"
32-
vc_const BLIZZARD
25+
EXPORT DEF B_CHAR EQU "B"
26+
EXPORT DEF Z_CHAR EQU "Z"
27+
EXPORT BLIZZARD
3328

3429
; [FPA 005 Begin]
35-
vc_const BUBBLEBEAM
30+
EXPORT BUBBLEBEAM
3631

3732
; [FPA 006 Begin]
38-
vc_const "H"
39-
vc_const "Y"
40-
vc_const HYPER_BEAM
33+
EXPORT DEF H_CHAR EQU "H"
34+
EXPORT DEF Y_CHAR EQU "Y"
35+
EXPORT HYPER_BEAM
4136

4237
; [FPA 007 Begin]
43-
vc_const "T"
44-
vc_const "N"
45-
vc_const THUNDERBOLT
38+
EXPORT DEF T_CHAR EQU "T"
39+
EXPORT DEF N_CHAR EQU "N"
40+
EXPORT THUNDERBOLT
4641

4742
; [FPA 008 Begin]
48-
vc_const HAZE
43+
EXPORT HAZE
4944

5045
; [FPA 009 Begin]
51-
vc_const "R"
52-
vc_const "F"
53-
vc_const REFLECT
46+
EXPORT DEF R_CHAR EQU "R"
47+
EXPORT REFLECT
5448

5549
; [FPA 010 Begin]
56-
vc_const SELFDESTRUCT
50+
EXPORT SELFDESTRUCT
5751

5852
; [FPA 011 Begin]
59-
vc_const EXPLOSION
53+
EXPORT EXPLOSION

vc/pokeyellow.patch.template

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ MotionBlur0 = 11
302302
ConditionType = 11
303303
ConditionValueA = {dws_ wStringBuffer wStringBuffer+1 wStringBuffer+2 wStringBuffer+3 wStringBuffer+5 wAnimationID 00 wStringBuffer wStringBuffer+1 wStringBuffer+2 wStringBuffer+3 wAnimationID 00 wStringBuffer wStringBuffer+1 wStringBuffer+2 wStringBuffer+3 wAnimationID}
304304
ConditionValueB = {dws_ == == == == == == || == == == == == || == == == == == }
305-
ConditionValueC = {dws_ "M" "E" "G" "A" "P" MEGA_PUNCH 00 "E" "X" "P" "L" MEGA_PUNCH 00 "S" "E" "L" "F" MEGA_PUNCH }
305+
ConditionValueC = {dws_ M_CHAR E_CHAR G_CHAR A_CHAR P_CHAR MEGA_PUNCH 00 E_CHAR X_CHAR P_CHAR L_CHAR MEGA_PUNCH 00 S_CHAR E_CHAR L_CHAR F_CHAR MEGA_PUNCH }
306306

307307
[FPA 001 End@Stop_reducing_move_anim_flashing_Mega_Punch]
308308
Mode = 3
@@ -311,7 +311,7 @@ Address = {hex @}
311311
ConditionType = 0
312312
ConditionValueA = {dws_ wStringBuffer wStringBuffer+1 wStringBuffer+2 wStringBuffer+3 wStringBuffer+5 wAnimationID}
313313
ConditionValueB = {dws_ == == == == == == }
314-
ConditionValueC = {dws_ "M" "E" "G" "A" "P" MEGA_PUNCH }
314+
ConditionValueC = {dws_ M_CHAR E_CHAR G_CHAR A_CHAR P_CHAR MEGA_PUNCH }
315315

316316
;rsm103725
317317
;Mem Write: pc32 = 0x781c5 addr = 0xd086 value = 0x3
@@ -325,7 +325,7 @@ MotionBlur0 = 7
325325
ConditionType = 0
326326
ConditionValueA = {dws_ wStringBuffer wStringBuffer+1 wStringBuffer+2 wStringBuffer+3 wAnimationID}
327327
ConditionValueB = {dws_ == == == == == }
328-
ConditionValueC = {dws_ "G" "U" "I" "L" GUILLOTINE }
328+
ConditionValueC = {dws_ G_CHAR U_CHAR I_CHAR L_CHAR GUILLOTINE }
329329

330330
[FPA 002 End@Stop_reducing_move_anim_flashing_Guillotine]
331331
Mode = 3
@@ -334,7 +334,7 @@ Address = {hex @}
334334
ConditionType = 0
335335
ConditionValueA = {dws_ wStringBuffer wStringBuffer+1 wStringBuffer+2 wStringBuffer+3 wAnimationID}
336336
ConditionValueB = {dws_ == == == == == }
337-
ConditionValueC = {dws_ "G" "U" "I" "L" GUILLOTINE }
337+
ConditionValueC = {dws_ G_CHAR U_CHAR I_CHAR L_CHAR GUILLOTINE }
338338

339339

340340
;rsm142438
@@ -349,7 +349,7 @@ MotionBlur0 = 10
349349
ConditionType = 0
350350
ConditionValueA = {dws_ wStringBuffer wStringBuffer+1 wStringBuffer+2 wStringBuffer+3 wStringBuffer+5 wAnimationID}
351351
ConditionValueB = {dws_ == == == == == == }
352-
ConditionValueC = {dws_ "M" "E" "G" "A" "K" MEGA_KICK }
352+
ConditionValueC = {dws_ M_CHAR E_CHAR G_CHAR A_CHAR K_CHAR MEGA_KICK }
353353

354354
[FPA 003 End@Stop_reducing_move_anim_flashing_Mega_Kick]
355355
Mode = 3
@@ -358,7 +358,7 @@ Address = {hex @}
358358
ConditionType = 0
359359
ConditionValueA = {dws_ wStringBuffer wStringBuffer+1 wStringBuffer+2 wStringBuffer+3 wStringBuffer+5 wAnimationID}
360360
ConditionValueB = {dws_ == == == == == == }
361-
ConditionValueC = {dws_ "M" "E" "G" "A" "K" MEGA_KICK }
361+
ConditionValueC = {dws_ M_CHAR E_CHAR G_CHAR A_CHAR K_CHAR MEGA_KICK }
362362

363363
;rsm154217 blizzard
364364
;No131
@@ -371,7 +371,7 @@ MotionBlur0 = 11
371371
ConditionType = 0
372372
ConditionValueA = {dws_ wStringBuffer wStringBuffer+1 wStringBuffer+2 wStringBuffer+3 wAnimationID}
373373
ConditionValueB = {dws_ == == == == == }
374-
ConditionValueC = {dws_ "B" "L" "I" "Z" BLIZZARD }
374+
ConditionValueC = {dws_ B_CHAR L_CHAR I_CHAR Z_CHAR BLIZZARD }
375375

376376
[FPA 004 End@Stop_reducing_move_anim_flashing_Blizzard]
377377
Mode = 3
@@ -380,7 +380,7 @@ Address = {hex @}
380380
ConditionType = 0
381381
ConditionValueA = {dws_ wStringBuffer wStringBuffer+1 wStringBuffer+2 wStringBuffer+3 wAnimationID}
382382
ConditionValueB = {dws_ == == == == == }
383-
ConditionValueC = {dws_ "B" "L" "I" "Z" BLIZZARD }
383+
ConditionValueC = {dws_ B_CHAR L_CHAR I_CHAR Z_CHAR BLIZZARD }
384384

385385

386386

@@ -395,7 +395,7 @@ MotionBlur0 = 15
395395
ConditionType = 0
396396
ConditionValueA = {dws_ wStringBuffer wStringBuffer+1 wStringBuffer+2 wStringBuffer+3 wAnimationID}
397397
ConditionValueB = {dws_ == == == == == }
398-
ConditionValueC = {dws_ "B" "U" "B" "B" BUBBLEBEAM }
398+
ConditionValueC = {dws_ B_CHAR U_CHAR B_CHAR B_CHAR BUBBLEBEAM }
399399

400400
[FPA 005 End@Stop_reducing_move_anim_flashing_Bubblebeam]
401401
Mode = 3
@@ -404,7 +404,7 @@ Address = {hex @}
404404
ConditionType = 0
405405
ConditionValueA = {dws_ wStringBuffer wStringBuffer+1 wStringBuffer+2 wStringBuffer+3 wAnimationID}
406406
ConditionValueB = {dws_ == == == == == }
407-
ConditionValueC = {dws_ "B" "U" "B" "B" BUBBLEBEAM }
407+
ConditionValueC = {dws_ B_CHAR U_CHAR B_CHAR B_CHAR BUBBLEBEAM }
408408

409409
;Mem Write: pc32 = 0xc2 addr = 0xcfd1 value = 0x3f
410410
;Pallte Write: pc32 =00078e79 00000048 e4
@@ -418,7 +418,7 @@ MotionBlur0 = 6
418418
ConditionType = 0
419419
ConditionValueA = {dws_ wStringBuffer wStringBuffer+1 wStringBuffer+2 wAnimationID}
420420
ConditionValueB = {dws_ == == == == }
421-
ConditionValueC = {dws_ "H" "Y" "P" HYPER_BEAM }
421+
ConditionValueC = {dws_ H_CHAR Y_CHAR P_CHAR HYPER_BEAM }
422422

423423
;rsm112921 thunderbolt
424424
;15 -- 13
@@ -432,7 +432,7 @@ MotionBlur0 = 13
432432
ConditionType = 0
433433
ConditionValueA = {dws_ wStringBuffer wStringBuffer+1 wStringBuffer+2 wStringBuffer+3 wAnimationID}
434434
ConditionValueB = {dws_ == == == == == }
435-
ConditionValueC = {dws_ "T" "H" "U" "N" THUNDERBOLT }
435+
ConditionValueC = {dws_ T_CHAR H_CHAR U_CHAR N_CHAR THUNDERBOLT }
436436

437437
[FPA 007 End@Stop_reducing_move_anim_flashing_Thunderbolt]
438438
Mode = 3
@@ -441,7 +441,7 @@ Address = {hex @}
441441
ConditionType = 0
442442
ConditionValueA = {dws_ wStringBuffer wStringBuffer+1 wStringBuffer+2 wStringBuffer+3 wAnimationID}
443443
ConditionValueB = {dws_ == == == == == }
444-
ConditionValueC = {dws_ "T" "H" "U" "N" THUNDERBOLT }
444+
ConditionValueC = {dws_ T_CHAR H_CHAR U_CHAR N_CHAR THUNDERBOLT }
445445
;
446446
;rsm130806 haze
447447
;No40 haze
@@ -454,7 +454,7 @@ MotionBlur0 = 28
454454
ConditionType = 0
455455
ConditionValueA = {dws_ wStringBuffer wStringBuffer+1 wStringBuffer+2 wStringBuffer+3 wAnimationID}
456456
ConditionValueB = {dws_ == == == == == }
457-
ConditionValueC = {dws_ "H" "A" "Z" "E" HAZE }
457+
ConditionValueC = {dws_ H_CHAR A_CHAR Z_CHAR E_CHAR HAZE }
458458

459459
[FPA 008 End@Stop_reducing_move_anim_flashing_Haze_Hyper_Beam]
460460
Mode = 3
@@ -463,7 +463,7 @@ Address = {hex @}
463463
ConditionType = 11
464464
ConditionValueA = {dws_ wStringBuffer wStringBuffer+1 wStringBuffer+2 wStringBuffer+3 wAnimationID 00 wStringBuffer wStringBuffer+1 wStringBuffer+2 wAnimationID}
465465
ConditionValueB = {dws_ == == == == == || == == == == }
466-
ConditionValueC = {dws_ "H" "A" "Z" "E" HAZE 00 "H" "Y" "P" HYPER_BEAM }
466+
ConditionValueC = {dws_ H_CHAR A_CHAR Z_CHAR E_CHAR HAZE 00 H_CHAR Y_CHAR P_CHAR HYPER_BEAM }
467467

468468

469469
;rsm131656 reflect
@@ -477,7 +477,7 @@ MotionBlur0 = 6
477477
ConditionType = 0
478478
ConditionValueA = {dws_ wStringBuffer wStringBuffer+1 wStringBuffer+2 wStringBuffer+3 wAnimationID}
479479
ConditionValueB = {dws_ == == == == == }
480-
ConditionValueC = {dws_ "R" "E" "F" "L" REFLECT }
480+
ConditionValueC = {dws_ R_CHAR E_CHAR F_CHAR L_CHAR REFLECT }
481481

482482
[FPA 009 End@Stop_reducing_move_anim_flashing_Reflect]
483483
Mode = 3
@@ -486,7 +486,7 @@ Address = {hex @}
486486
ConditionType = 0
487487
ConditionValueA = {dws_ wStringBuffer wStringBuffer+1 wStringBuffer+2 wStringBuffer+3 wAnimationID}
488488
ConditionValueB = {dws_ == == == == == }
489-
ConditionValueC = {dws_ "R" "E" "F" "L" REFLECT }
489+
ConditionValueC = {dws_ R_CHAR E_CHAR F_CHAR L_CHAR REFLECT }
490490

491491
;rsm132935 selfdestruct
492492
;No56
@@ -499,7 +499,7 @@ MotionBlur0 = 11
499499
ConditionType = 0
500500
ConditionValueA = {dws_ wStringBuffer wStringBuffer+1 wStringBuffer+2 wStringBuffer+3 wAnimationID}
501501
ConditionValueB = {dws_ == == == == == }
502-
ConditionValueC = {dws_ "S" "E" "L" "F" SELFDESTRUCT}
502+
ConditionValueC = {dws_ S_CHAR E_CHAR L_CHAR F_CHAR SELFDESTRUCT}
503503

504504
[FPA 010 End@Stop_reducing_move_anim_flashing_Self_Destruct]
505505
Mode = 3
@@ -508,7 +508,7 @@ Address = {hex @}
508508
ConditionType = 11
509509
ConditionValueA = {dws_ wStringBuffer wStringBuffer+1 wStringBuffer+2 wStringBuffer+3 wAnimationID 00 wStringBuffer wStringBuffer+1 wStringBuffer+2 wStringBuffer+3 wAnimationID}
510510
ConditionValueB = {dws_ == == == == == || == == == == == }
511-
ConditionValueC = {dws_ "S" "E" "L" "F" MEGA_PUNCH 00 "S" "E" "L" "F" SELFDESTRUCT}
511+
ConditionValueC = {dws_ S_CHAR E_CHAR L_CHAR F_CHAR MEGA_PUNCH 00 S_CHAR E_CHAR L_CHAR F_CHAR SELFDESTRUCT}
512512

513513
;rsm013740 explosion
514514
;No76
@@ -521,7 +521,7 @@ MotionBlur0 = 11
521521
ConditionType = 0
522522
ConditionValueA = {dws_ wStringBuffer wStringBuffer+1 wStringBuffer+2 wStringBuffer+3 wAnimationID}
523523
ConditionValueB = {dws_ == == == == == }
524-
ConditionValueC = {dws_ "E" "X" "P" "L" EXPLOSION }
524+
ConditionValueC = {dws_ E_CHAR X_CHAR P_CHAR L_CHAR EXPLOSION }
525525

526526
[FPA 011 End@Stop_reducing_move_anim_flashing_Explosion]
527527
Mode = 3
@@ -530,4 +530,4 @@ Address = {hex @}
530530
ConditionType = 11
531531
ConditionValueA = {dws_ wStringBuffer wStringBuffer+1 wStringBuffer+2 wStringBuffer+3 wAnimationID 00 wStringBuffer wStringBuffer+1 wStringBuffer+2 wStringBuffer+3 wAnimationID}
532532
ConditionValueB = {dws_ == == == == == || == == == == == }
533-
ConditionValueC = {dws_ "E" "X" "P" "L" MEGA_PUNCH 00 "E" "X" "P" "L" EXPLOSION }
533+
ConditionValueC = {dws_ E_CHAR X_CHAR P_CHAR L_CHAR MEGA_PUNCH 00 E_CHAR X_CHAR P_CHAR L_CHAR EXPLOSION }

0 commit comments

Comments
 (0)