Skip to content

Commit

Permalink
Build the Virtual Console patches with make gold_vc and `make silve…
Browse files Browse the repository at this point in the history
…r_vc` (#74)
  • Loading branch information
vulcandth authored Mar 14, 2022
1 parent fddd1c1 commit 3d58fb9
Show file tree
Hide file tree
Showing 27 changed files with 2,271 additions and 26 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
*.attrmap binary diff=hex
*.tilemap binary diff=hex

# Declare files that will always have CRLF line endings on checkout.
*.patch.template text eol=crlf linguist-language=INI

# these are generated but just in case
*.lz binary diff=hex
*.2bpp binary diff=hex
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# compiled roms
*.gbc
*.gb
*.patch

# rgbds extras
*.map
Expand Down
100 changes: 76 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,34 +1,45 @@
roms := pokegold.gbc pokesilver.gbc pokegold_debug.gbc pokesilver_debug.gbc
roms := \
pokegold.gbc \
pokesilver.gbc \
pokegold_debug.gbc \
pokesilver_debug.gbc
patches := \
pokegold.patch \
pokesilver.patch

rom_obj := \
audio.o \
home.o \
main.o \
wram.o \
data/text/common.o \
data/maps/map_data.o \
data/pokemon/egg_moves.o \
data/pokemon/evos_attacks.o \
engine/movie/credits.o \
engine/overworld/events.o \
gfx/misc.o \
gfx/sprites.o \
gfx/tilesets.o
audio.o \
home.o \
main.o \
wram.o \
data/text/common.o \
data/maps/map_data.o \
data/pokemon/egg_moves.o \
data/pokemon/evos_attacks.o \
engine/movie/credits.o \
engine/overworld/events.o \
gfx/misc.o \
gfx/sprites.o \
gfx/tilesets.o

# Distinguish asm files which are game-exclusive for building (*_[gold|silver].asm)
gs_excl_asm := \
data/pokemon/dex_entries \
gfx/pics

gold_excl_obj := $(addsuffix _gold.o,$(gs_excl_asm))
silver_excl_obj := $(addsuffix _silver.o,$(gs_excl_asm))
gold_debug_excl_obj := $(addsuffix _gold_debug.o,$(gs_excl_asm))
gold_excl_obj := $(addsuffix _gold.o,$(gs_excl_asm))
silver_excl_obj := $(addsuffix _silver.o,$(gs_excl_asm))
gold_debug_excl_obj := $(addsuffix _gold_debug.o,$(gs_excl_asm))
silver_debug_excl_obj := $(addsuffix _silver_debug.o,$(gs_excl_asm))
gold_vc_excl_obj := $(addsuffix _gold_vc.o,$(gs_excl_asm))
silver_vc_excl_obj := $(addsuffix _silver_vc.o,$(gs_excl_asm))

pokegold_obj := $(rom_obj:.o=_gold.o) $(gold_excl_obj)
pokesilver_obj := $(rom_obj:.o=_silver.o) $(silver_excl_obj)
pokegold_debug_obj := $(rom_obj:.o=_gold_debug.o) $(gold_debug_excl_obj)
pokesilver_debug_obj := $(rom_obj:.o=_silver_debug.o) $(silver_debug_excl_obj)
pokegold_obj := $(rom_obj:.o=_gold.o) $(gold_excl_obj)
pokesilver_obj := $(rom_obj:.o=_silver.o) $(silver_excl_obj)
pokegold_debug_obj := $(rom_obj:.o=_gold_debug.o) $(gold_debug_excl_obj)
pokesilver_debug_obj := $(rom_obj:.o=_silver_debug.o) $(silver_debug_excl_obj)
pokegold_vc_obj := $(rom_obj:.o=_gold_vc.o) $(gold_vc_excl_obj)
pokesilver_vc_obj := $(rom_obj:.o=_silver_vc.o) $(silver_vc_excl_obj)


### Build tools
Expand Down Expand Up @@ -59,15 +70,37 @@ gold: pokegold.gbc
silver: pokesilver.gbc
gold_debug: pokegold_debug.gbc
silver_debug: pokesilver_debug.gbc
gold_vc: pokegold.patch
silver_vc: pokesilver.patch

clean: tidy
find gfx \( -name "*.[12]bpp" -o -name "*.lz" -o -name "*.gbcpal" -o -name "*.dimensions" -o -name "*.sgb.tilemap" \) -delete
find gfx \
\( -name "*.[12]bpp" \
-o -name "*.lz" \
-o -name "*.gbcpal" \
-o -name "*.dimensions" \
-o -name "*.sgb.tilemap" \) \
-delete

tidy:
$(RM) $(roms) $(pokegold_obj) $(pokesilver_obj) $(pokegold_debug_obj) $(pokesilver_debug_obj) $(roms:.gbc=.map) $(roms:.gbc=.sym) rgbdscheck.o
$(RM) $(roms) \
$(roms:.gbc=.sym) \
$(roms:.gbc=.map) \
$(patches) \
$(patches:.patch=_vc.gbc) \
$(patches:.patch=_vc.sym) \
$(patches:.patch=_vc.map) \
$(patches:%.patch=vc/%.constants.sym) \
$(pokegold_obj) \
$(pokesilver_obj) \
$(pokegold_vc_obj) \
$(pokesilver_vc_obj) \
$(pokegold_debug_obj) \
$(pokesilver_debug_obj) \
rgbdscheck.o
$(MAKE) clean -C tools/

compare: $(roms)
compare: $(roms) $(patches)
@$(SHA1) -c roms.sha1

tools:
Expand All @@ -84,6 +117,11 @@ $(pokegold_obj): RGBASMFLAGS += -D _GOLD
$(pokesilver_obj): RGBASMFLAGS += -D _SILVER
$(pokegold_debug_obj): RGBASMFLAGS += -D _GOLD -D _DEBUG
$(pokesilver_debug_obj): RGBASMFLAGS += -D _SILVER -D _DEBUG
$(pokegold_vc_obj): RGBASMFLAGS += -D _GOLD -D _GOLD_VC
$(pokesilver_vc_obj): RGBASMFLAGS += -D _SILVER -D _GOLD_VC

%.patch: vc/%.constants.sym %_vc.gbc %.gbc vc/%.patch.template
tools/make_patch $*_vc.sym $^ $@

rgbdscheck.o: rgbdscheck.asm
$(RGBASM) -o $@ $<
Expand Down Expand Up @@ -111,6 +149,10 @@ $(foreach obj, $(filter-out $(gold_debug_excl_obj), $(pokegold_debug_obj)), \
$(eval $(call DEP,$(obj),$(obj:_gold_debug.o=.asm))))
$(foreach obj, $(filter-out $(silver_debug_excl_obj), $(pokesilver_debug_obj)), \
$(eval $(call DEP,$(obj),$(obj:_silver_debug.o=.asm))))
$(foreach obj, $(filter-out $(gold_vc_excl_obj), $(pokegold_vc_obj)), \
$(eval $(call DEP,$(obj),$(obj:_gold_vc.o=.asm))))
$(foreach obj, $(filter-out $(silver_vc_excl_obj), $(pokesilver_vc_obj)), \
$(eval $(call DEP,$(obj),$(obj:_silver_vc.o=.asm))))

# Dependencies for game-exclusive objects (keep _gold and _silver in asm file basenames)
$(foreach obj, $(gold_excl_obj) $(silver_excl_obj), \
Expand All @@ -119,6 +161,14 @@ $(foreach obj, $(gold_debug_excl_obj), \
$(eval $(call DEP,$(obj),$(obj:_gold_debug.o=_gold.asm))))
$(foreach obj, $(silver_debug_excl_obj), \
$(eval $(call DEP,$(obj),$(obj:_silver_debug.o=_silver.asm))))
$(foreach obj, $(gold_vc_excl_obj), \
$(eval $(call DEP,$(obj),$(obj:_gold_vc.o=_gold.asm))))
$(foreach obj, $(silver_vc_excl_obj), \
$(eval $(call DEP,$(obj),$(obj:_silver_vc.o=_silver.asm))))

# Dependencies for VC files that need to run scan_includes
%.constants.sym: %.constants.asm $(shell tools/scan_includes %.constants.asm) | rgbdscheck.o
$(RGBASM) $< > $@

endif

Expand All @@ -127,6 +177,8 @@ pokegold_opt = -cjsv -t POKEMON_GLD -i AAUE -k 01 -l 0x33 -m 0x10 -r 3 -
pokesilver_opt = -cjsv -t POKEMON_SLV -i AAXE -k 01 -l 0x33 -m 0x10 -r 3 -p 0
pokegold_debug_opt = -cjsv -t POKEMON_GLD -i AAUE -k 01 -l 0x33 -m 0x10 -r 3 -p 0
pokesilver_debug_opt = -cjsv -t POKEMON_SLV -i AAXE -k 01 -l 0x33 -m 0x10 -r 3 -p 0
pokegold_vc_opt = -cjsv -t POKEMON_GLD -i AAUE -k 01 -l 0x33 -m 0x10 -r 3 -p 0
pokesilver_vc_opt = -cjsv -t POKEMON_SLV -i AAXE -k 01 -l 0x33 -m 0x10 -r 3 -p 0

%.gbc: $$(%_obj) layout.link
$(RGBLINK) -n $*.sym -m $*.map -l layout.link -o $@ $(filter %.o,$^)
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ It builds the following ROMs:
- Pokemon - Silver Version (UE) [C][!].gbc `sha1: 49b163f7e57702bc939d642a18f591de55d92dae`
- mons2_gld_ps3_debug.bin `sha1: 53783c57378122805c5b4859d19e1a224f02a1ed`
- mons2_slv_ps3_debug.bin `sha1: 4c2fafebdbc7551f4cd3f348bdd17e420b93b6e7`
- DMGAAUP0.J56.patch `sha1: b8253b915ade89c784c71adfdb11cf60bc1f7b59`
- DMGAAXP0.J57.patch `sha1: a38c0dec807e8a9e3626a0ec0fdf96bfb795ef3a`

To set up the repository, see [INSTALL.md](INSTALL.md).

Expand Down
6 changes: 6 additions & 0 deletions engine/battle/battle_transition.asm
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ DoBattleTransition:
ld hl, hVBlank
ld a, [hl]
push af
vc_hook FPA_link_fight_begin
ld [hl], $1

.loop
Expand Down Expand Up @@ -48,6 +49,7 @@ DoBattleTransition:
ldh [hSCY], a

pop af
vc_hook FPA_link_fight_End4
ldh [hVBlank], a
call DelayFrame
ret
Expand Down Expand Up @@ -260,6 +262,7 @@ StartTrainerBattle_Flash:
dc 0, 0, 0, 1

StartTrainerBattle_SetUpForWavyOutro:
vc_hook FPA_link_fight_End0
farcall RespawnPlayerAndOpponent

call StartTrainerBattle_NextScene
Expand Down Expand Up @@ -316,6 +319,7 @@ StartTrainerBattle_SineWave:
ret

StartTrainerBattle_SetUpForSpinOutro:
vc_hook FPA_link_fight_End1
farcall RespawnPlayerAndOpponent
call StartTrainerBattle_NextScene
xor a
Expand Down Expand Up @@ -456,6 +460,7 @@ ENDM
.wedge5: db 4, 0, 3, 0, 3, 0, 2, 0, 2, 0, 1, 0, 1, 0, 1, -1

StartTrainerBattle_SetUpForRandomScatterOutro:
vc_hook FPA_link_fight_End2
farcall RespawnPlayerAndOpponent
call StartTrainerBattle_NextScene
ld a, $10
Expand Down Expand Up @@ -674,6 +679,7 @@ StartTrainerBattle_DrawSineWave:
calc_sine_wave

StartTrainerBattle_ZoomToBlack:
vc_hook FPA_link_fight_End3
farcall RespawnPlayerAndOpponent
ld de, .boxes

Expand Down
17 changes: 17 additions & 0 deletions engine/battle/core.asm
Original file line number Diff line number Diff line change
Expand Up @@ -5671,6 +5671,7 @@ LinkBattleSendReceiveAction:

.use_move
ld [wPlayerLinkAction], a
vc_hook send_byt2
callfar PlaceWaitingText

.waiting
Expand All @@ -5680,20 +5681,35 @@ LinkBattleSendReceiveAction:
inc a
jr z, .waiting

vc_hook send_byt2_ret
vc_patch send_byt2_wait
if DEF(_GOLD_VC) || DEF(_SILVER_VC)
ld b, 26
else
ld b, 10
endc
vc_patch_end
.receive
call DelayFrame
call LinkTransfer
dec b
jr nz, .receive

vc_hook send_dummy
vc_patch send_dummy_wait
if DEF(_GOLD_VC) || DEF(_SILVER_VC)
ld b, 26
else
ld b, 10
endc
vc_patch_end
.acknowledge
call DelayFrame
call LinkDataReceived
dec b
jr nz, .acknowledge

vc_hook send_dummy_end
ret

LoadEnemyMon:
Expand Down Expand Up @@ -8544,6 +8560,7 @@ InitBattleDisplay:
predef PlaceGraphic
xor a
ldh [hWY], a
vc_hook fight_begin
ldh [rWY], a
call WaitBGMap
call HideSprites
Expand Down
3 changes: 3 additions & 0 deletions engine/battle_anims/anim_commands.asm
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ BattleAnimRunScript:
bit 7, a
jr nz, .disabled

vc_hook Reduce_move_anim_flashing
call BattleAnimClearHud
call RunBattleAnimScript

Expand Down Expand Up @@ -142,6 +143,7 @@ BattleAnimRestoreHuds:
call BattleAnimDelayFrame
call BattleAnimDelayFrame
call WaitTop
vc_hook Stop_reducing_move_anim_flashing
ret

BattleAnimRequestPals:
Expand Down Expand Up @@ -646,6 +648,7 @@ BattleAnimCmd_5GFX:
xor a
ld [wBattleAnimGFXTempTileID], a
.loop
vc_hook FPA_042801_Begin
ld a, [wBattleAnimGFXTempTileID]
cp (vTiles1 - vTiles0) / LEN_2BPP_TILE - BATTLEANIM_BASE_TILE
ret nc
Expand Down
6 changes: 6 additions & 0 deletions engine/events/print_unown.asm
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,13 @@ _UnownPrinter:
jr nz, .pressed_b

ldh a, [hJoyPressed]
vc_patch print_forbid_1
if DEF(_GOLD_VC) || DEF(_SILVER_VC)
and 0
else
and A_BUTTON
endc
vc_patch_end
jr nz, .pressed_a

call .LeftRight
Expand Down
1 change: 1 addition & 0 deletions engine/gfx/color.asm
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,7 @@ _PushSGBPals:

InitSGBBorder:
call CheckCGB
vc_hook Network_RESET
ret nz

; SGB/DMG only
Expand Down
Loading

0 comments on commit 3d58fb9

Please sign in to comment.