Skip to content

Commit

Permalink
Use exported constants for VC patch
Browse files Browse the repository at this point in the history
  • Loading branch information
vulcandth committed Dec 26, 2024
1 parent 61c9ba5 commit e03af7c
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 51 deletions.
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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


Expand Down
1 change: 1 addition & 0 deletions constants/gfx_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ DEF SCREEN_WIDTH EQU 20 ; tiles
DEF SCREEN_HEIGHT EQU 18 ; tiles
DEF SCREEN_WIDTH_PX EQU SCREEN_WIDTH * TILE_WIDTH ; pixels
DEF SCREEN_HEIGHT_PX EQU SCREEN_HEIGHT * TILE_WIDTH ; pixels
EXPORT SCREEN_HEIGHT_PX ; needed for VC patch

DEF BG_MAP_WIDTH EQU 32 ; tiles
DEF BG_MAP_HEIGHT EQU 32 ; tiles
Expand Down
7 changes: 7 additions & 0 deletions constants/input_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,10 @@ DEF NO_INPUT EQU %00000000

DEF BUTTONS EQU A_BUTTON | B_BUTTON | SELECT | START
DEF D_PAD EQU D_RIGHT | D_LEFT | D_UP | D_DOWN

; needed for VC patch
EXPORT NO_INPUT
EXPORT A_BUTTON
EXPORT B_BUTTON
EXPORT D_UP
EXPORT D_DOWN
4 changes: 4 additions & 0 deletions constants/map_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -502,3 +502,7 @@ ENDM
endgroup

DEF NUM_MAP_GROUPS EQU const_value ; 26

; needed for VC patch
EXPORT MAPGROUP_CIANWOOD
EXPORT MAP_CIANWOOD_PHOTO_STUDIO
10 changes: 10 additions & 0 deletions constants/move_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,16 @@
const BEAT_UP ; fb
DEF NUM_ATTACKS EQU const_value - 1

; needed for VC patch
EXPORT FISSURE
EXPORT SELFDESTRUCT
EXPORT THUNDER
EXPORT FLASH
EXPORT EXPLOSION
EXPORT HORN_DRILL
EXPORT HYPER_BEAM
EXPORT PRESENT

; Battle animations use the same constants as the moves up to this point
const_next $ff
const ANIM_SWEET_SCENT_2 ; ff
Expand Down
1 change: 1 addition & 0 deletions macros/scripts/battle_anims.asm
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ MACRO anim_obj
ENDM

const anim_1gfx_command ; $d1
EXPORT anim_1gfx_command ; needed for VC patch
MACRO anim_1gfx
db anim_1gfx_command
db \1 ; gfx1
Expand Down
13 changes: 6 additions & 7 deletions tools/make_patch.c
Original file line number Diff line number Diff line change
@@ -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"

Expand Down Expand Up @@ -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);
Expand Down
39 changes: 0 additions & 39 deletions vc/pokecrystal11.constants.asm

This file was deleted.

0 comments on commit e03af7c

Please sign in to comment.