summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvulcandth <vulcandth@gmail.com>2022-03-14 16:03:15 -0500
committerGitHub <noreply@github.com>2022-03-14 17:03:15 -0400
commit3d58fb95569be74c6c229118a425fa22628f1dc3 (patch)
tree5ddb4fbcefce4610963397d82cef2fb3b470e956
parentfddd1c132bd526cc9b15c14896becfc30288a049 (diff)
Build the Virtual Console patches with `make gold_vc` and `make silver_vc` (#74)
-rw-r--r--.gitattributes3
-rw-r--r--.gitignore1
-rw-r--r--Makefile100
-rw-r--r--README.md2
-rw-r--r--engine/battle/battle_transition.asm6
-rw-r--r--engine/battle/core.asm17
-rw-r--r--engine/battle_anims/anim_commands.asm3
-rw-r--r--engine/events/print_unown.asm6
-rw-r--r--engine/gfx/color.asm1
-rw-r--r--engine/link/link.asm52
-rw-r--r--engine/link/mystery_gift.asm36
-rw-r--r--engine/menus/menu.asm2
-rw-r--r--engine/overworld/scripting.asm1
-rw-r--r--engine/pokedex/pokedex.asm1
-rw-r--r--engine/pokemon/mail_2.asm6
-rw-r--r--home/serial.asm14
-rw-r--r--macros.asm1
-rw-r--r--macros/vc.asm27
-rw-r--r--roms.sha12
-rw-r--r--tools/.gitignore3
-rw-r--r--tools/Makefile1
-rw-r--r--tools/gfx.c2
-rw-r--r--tools/make_patch.c452
-rw-r--r--vc/pokegold.constants.asm59
-rw-r--r--vc/pokegold.patch.template716
-rw-r--r--vc/pokesilver.constants.asm59
-rw-r--r--vc/pokesilver.patch.template724
27 files changed, 2271 insertions, 26 deletions
diff --git a/.gitattributes b/.gitattributes
index 3cf462d9..12b95346 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -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
diff --git a/.gitignore b/.gitignore
index 9d179aae..810ca6f2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,6 +12,7 @@
# compiled roms
*.gbc
*.gb
+*.patch
# rgbds extras
*.map
diff --git a/Makefile b/Makefile
index 7977d429..1609a20c 100644
--- a/Makefile
+++ b/Makefile
@@ -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
@@ -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:
@@ -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 $@ $<
@@ -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), \
@@ -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
@@ -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,$^)
diff --git a/README.md b/README.md
index 4e17c116..882e4997 100644
--- a/README.md
+++ b/README.md
@@ -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).
diff --git a/engine/battle/battle_transition.asm b/engine/battle/battle_transition.asm
index f5b4effe..a9d6468b 100644
--- a/engine/battle/battle_transition.asm
+++ b/engine/battle/battle_transition.asm
@@ -21,6 +21,7 @@ DoBattleTransition:
ld hl, hVBlank
ld a, [hl]
push af
+ vc_hook FPA_link_fight_begin
ld [hl], $1
.loop
@@ -48,6 +49,7 @@ DoBattleTransition:
ldh [hSCY], a
pop af
+ vc_hook FPA_link_fight_End4
ldh [hVBlank], a
call DelayFrame
ret
@@ -260,6 +262,7 @@ StartTrainerBattle_Flash:
dc 0, 0, 0, 1
StartTrainerBattle_SetUpForWavyOutro:
+ vc_hook FPA_link_fight_End0
farcall RespawnPlayerAndOpponent
call StartTrainerBattle_NextScene
@@ -316,6 +319,7 @@ StartTrainerBattle_SineWave:
ret
StartTrainerBattle_SetUpForSpinOutro:
+ vc_hook FPA_link_fight_End1
farcall RespawnPlayerAndOpponent
call StartTrainerBattle_NextScene
xor a
@@ -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
@@ -674,6 +679,7 @@ StartTrainerBattle_DrawSineWave:
calc_sine_wave
StartTrainerBattle_ZoomToBlack:
+ vc_hook FPA_link_fight_End3
farcall RespawnPlayerAndOpponent
ld de, .boxes
diff --git a/engine/battle/core.asm b/engine/battle/core.asm
index 9f8c3421..e16ae0ad 100644
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -5671,6 +5671,7 @@ LinkBattleSendReceiveAction:
.use_move
ld [wPlayerLinkAction], a
+ vc_hook send_byt2
callfar PlaceWaitingText
.waiting
@@ -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:
@@ -8544,6 +8560,7 @@ InitBattleDisplay:
predef PlaceGraphic
xor a
ldh [hWY], a
+ vc_hook fight_begin
ldh [rWY], a
call WaitBGMap
call HideSprites
diff --git a/engine/battle_anims/anim_commands.asm b/engine/battle_anims/anim_commands.asm
index a16c076a..5b2a0778 100644
--- a/engine/battle_anims/anim_commands.asm
+++ b/engine/battle_anims/anim_commands.asm
@@ -39,6 +39,7 @@ BattleAnimRunScript:
bit 7, a
jr nz, .disabled
+ vc_hook Reduce_move_anim_flashing
call BattleAnimClearHud
call RunBattleAnimScript
@@ -142,6 +143,7 @@ BattleAnimRestoreHuds:
call BattleAnimDelayFrame
call BattleAnimDelayFrame
call WaitTop
+ vc_hook Stop_reducing_move_anim_flashing
ret
BattleAnimRequestPals:
@@ -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
diff --git a/engine/events/print_unown.asm b/engine/events/print_unown.asm
index 0d67ae72..73b217b7 100644
--- a/engine/events/print_unown.asm
+++ b/engine/events/print_unown.asm
@@ -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
diff --git a/engine/gfx/color.asm b/engine/gfx/color.asm
index 908a600b..9c0655e9 100644
--- a/engine/gfx/color.asm
+++ b/engine/gfx/color.asm
@@ -761,6 +761,7 @@ _PushSGBPals:
InitSGBBorder:
call CheckCGB
+ vc_hook Network_RESET
ret nz
; SGB/DMG only
diff --git a/engine/link/link.asm b/engine/link/link.asm
index d549dc47..110d6013 100644
--- a/engine/link/link.asm
+++ b/engine/link/link.asm
@@ -65,7 +65,13 @@ Gen2ToGen1LinkComms:
.player_1
ld de, MUSIC_NONE
call PlayMusic
+ vc_patch NetworkDelay1
+if DEF(_GOLD_VC) || DEF(_SILVER_VC)
+ ld c, 26
+else
ld c, 3
+endc
+ vc_patch_end
call DelayFrames
xor a
ldh [rIF], a
@@ -75,6 +81,7 @@ Gen2ToGen1LinkComms:
ld hl, wLinkBattleRNPreamble
ld de, wEnemyMon
ld bc, SERIAL_RN_PREAMBLE_LENGTH + SERIAL_RNS_LENGTH
+ vc_hook Network358
call Serial_ExchangeBytes
ld a, SERIAL_NO_DATA_BYTE
ld [de], a
@@ -82,6 +89,7 @@ Gen2ToGen1LinkComms:
ld hl, wLinkData
ld de, wOTPartyData
ld bc, SERIAL_PREAMBLE_LENGTH + NAME_LENGTH + 1 + PARTY_LENGTH + 1 + (REDMON_STRUCT_LENGTH + NAME_LENGTH * 2) * PARTY_LENGTH + 3
+ vc_hook Network359
call Serial_ExchangeBytes
ld a, SERIAL_NO_DATA_BYTE
ld [de], a
@@ -89,6 +97,7 @@ Gen2ToGen1LinkComms:
ld hl, wPlayerPatchLists
ld de, wOTPatchLists
ld bc, 200
+ vc_hook Network364
call Serial_ExchangeBytes
xor a
@@ -222,7 +231,13 @@ Gen2ToGen2LinkComms:
.player_1
ld de, MUSIC_NONE
call PlayMusic
+ vc_patch NetworkDelay4
+if DEF(_GOLD_VC) || DEF(_SILVER_VC)
+ ld c, 26
+else
ld c, 3
+endc
+ vc_patch_end
call DelayFrames
xor a
ldh [rIF], a
@@ -232,6 +247,7 @@ Gen2ToGen2LinkComms:
ld hl, wLinkBattleRNPreamble
ld de, wEnemyMon
ld bc, SERIAL_RN_PREAMBLE_LENGTH + SERIAL_RNS_LENGTH
+ vc_hook Network360
call Serial_ExchangeBytes
ld a, SERIAL_NO_DATA_BYTE
ld [de], a
@@ -239,6 +255,7 @@ Gen2ToGen2LinkComms:
ld hl, wLinkData
ld de, wOTPartyData
ld bc, SERIAL_PREAMBLE_LENGTH + NAME_LENGTH + 1 + PARTY_LENGTH + 1 + 2 + (PARTYMON_STRUCT_LENGTH + NAME_LENGTH * 2) * PARTY_LENGTH + 3
+ vc_hook Network361
call Serial_ExchangeBytes
ld a, SERIAL_NO_DATA_BYTE
ld [de], a
@@ -246,6 +263,7 @@ Gen2ToGen2LinkComms:
ld hl, wPlayerPatchLists
ld de, wOTPatchLists
ld bc, 200
+ vc_hook Network362
call Serial_ExchangeBytes
ld a, [wLinkMode]
@@ -254,6 +272,7 @@ Gen2ToGen2LinkComms:
ld hl, wLinkPlayerMail
ld de, wLinkOTMail
ld bc, wLinkPlayerMailEnd - wLinkPlayerMail
+ vc_hook Network363
call ExchangeBytes
.not_trading
@@ -1463,6 +1482,7 @@ ExitLinkCommunications:
ldh [rSC], a
ld a, (1 << rSC_ON) | (1 << rSC_CLOCK)
ldh [rSC], a
+ vc_hook ret_heya
ret
PlaceTradeScreenFooter:
@@ -1840,6 +1860,7 @@ LinkTrade:
hlcoord 1, 14
ld de, String_TradeCompleted
call PlaceString
+ vc_hook save_game_end
ld c, 50
call DelayFrames
ld a, [wLinkMode]
@@ -2027,10 +2048,19 @@ GetIncompatibleMonName:
ret
EnterTimeCapsule:
+ vc_patch NetworkDelay2
+if DEF(_GOLD_VC) || DEF(_SILVER_VC)
+ ld c, 26
+ call DelayFrames
+ ld a, $4
+ call Link_EnsureSync
+else
ld a, $4
call Link_EnsureSync
ld c, 40
call DelayFrames
+endc
+ vc_patch_end
xor a
ldh [hVBlank], a
inc a ; LINK_TIMECAPSULE
@@ -2074,6 +2104,7 @@ WaitForOtherPlayerToExit:
ld [hl], a
ldh [hVBlank], a
ld [wLinkMode], a
+ vc_hook term_exit
ret
SetBitsForLinkTradeRequest:
@@ -2138,6 +2169,7 @@ WaitForLinkedFriend:
ld a, (0 << rSC_ON) | (0 << rSC_CLOCK)
ldh [rSC], a
ld a, (1 << rSC_ON) | (0 << rSC_CLOCK)
+ vc_hook linkCable_fake_begin
ldh [rSC], a
ld a, [wLinkTimeoutFrames]
dec a
@@ -2230,7 +2262,13 @@ CheckLinkTimeout_Gen2:
ld a, $6
ld [wPlayerLinkAction], a
ld hl, wLinkTimeoutFrames
+ vc_patch NetworkDelay6
+if DEF(_GOLD_VC) || DEF(_SILVER_VC)
+ ld a, 3
+else
ld a, 1
+endc
+ vc_patch_end
ld [hli], a
ld [hl], 50
call Link_CheckCommunicationError
@@ -2251,9 +2289,11 @@ CheckLinkTimeout_Gen2:
Link_CheckCommunicationError:
xor a
ldh [hSerialReceivedNewData], a
+ vc_hook linkCable_fake_end
call WaitLinkTransfer
ld hl, wLinkTimeoutFrames
+ vc_hook Network_RECHECK
ld a, [hli]
inc a
jr nz, .load_true
@@ -2261,7 +2301,13 @@ Link_CheckCommunicationError:
inc a
jr nz, .load_true
+ vc_patch NetworkDelay3
+if DEF(_GOLD_VC) || DEF(_SILVER_VC)
+ ld b, 26
+else
ld b, 10
+endc
+ vc_patch_end
.loop
call DelayFrame
call LinkDataReceived
@@ -2287,8 +2333,10 @@ TryQuickSave:
ld a, [wChosenCableClubRoom]
push af
farcall Link_SaveGame
+ vc_hook linkCable_block_input
ld a, TRUE
jr nc, .return_result
+ vc_hook linkCable_block_input2
xor a ; FALSE
.return_result
ld [wScriptVar], a
@@ -2325,6 +2373,7 @@ CheckBothSelectedSameRoom:
ret
TimeCapsule:
+ vc_hook to_play2_mons1
ld a, LINK_TIMECAPSULE
ld [wLinkMode], a
call DisableSpriteUpdates
@@ -2335,6 +2384,7 @@ TimeCapsule:
ret
TradeCenter:
+ vc_hook to_play2_trade
ld a, LINK_TRADECENTER
ld [wLinkMode], a
call DisableSpriteUpdates
@@ -2345,6 +2395,7 @@ TradeCenter:
ret
Colosseum:
+ vc_hook to_play2_battle
ld a, LINK_COLOSSEUM
ld [wLinkMode], a
call DisableSpriteUpdates
@@ -2357,6 +2408,7 @@ Colosseum:
CloseLink:
ld c, 3
call DelayFrames
+ vc_hook room_check
jp Link_ResetSerialRegistersAfterLinkClosure
FailedLinkToPast:
diff --git a/engine/link/mystery_gift.asm b/engine/link/mystery_gift.asm
index 08d7f060..5c99a096 100644
--- a/engine/link/mystery_gift.asm
+++ b/engine/link/mystery_gift.asm
@@ -35,14 +35,23 @@ DoMysteryGift:
; Prepare the first of two messages for wMysteryGiftPartnerData
farcall StageDataForMysteryGift
call ClearMysteryGiftTrainer
+ vc_patch infrared_fake_0
+if DEF(_GOLD_VC) || DEF(_SILVER_VC)
+ farcall StagePartyDataForMysteryGift
+ call ClearMysteryGiftTrainer
+ nop
+else
ld a, 2
ld [wMysteryGiftMessageCount], a
ld a, wMysteryGiftPartnerDataEnd - wMysteryGiftPartnerData
ld [wMysteryGiftStagedDataLength], a
+endc
+ vc_patch_end
ldh a, [rIE]
push af
call ExchangeMysteryGiftData
+ vc_hook infrared_fake_4
ld d, a
xor a
ldh [rIF], a
@@ -256,6 +265,31 @@ DoMysteryGift:
ExchangeMysteryGiftData:
farcall ClearChannels
+ vc_patch infrared_fake
+if DEF(_GOLD_VC) || DEF(_SILVER_VC)
+ nop
+ vc_hook infrared_fake_5
+ nop
+ nop
+
+.restart ; same location as unpatched .restart
+ ld d, 239
+.loop
+ dec d
+ ld a, d
+ or a
+ jr nz, .loop
+ vc_hook infrared_fake_3
+ nop
+ cp MG_CANCELED
+ ret z
+ nop
+ nop
+ cp MG_OKAY
+ jr nz, .restart
+ ret
+ db LOW(hMGRole) ; unpatched byte left from 'ldh a, [hMGRole]'
+else
call InitializeIRCommunicationInterrupts
.restart
@@ -268,6 +302,8 @@ ExchangeMysteryGiftData:
jr nz, .restart
ldh a, [hMGRole]
+endc
+ vc_patch_end
cp IR_SENDER
jr z, SenderExchangeMysteryGiftDataPayloads
; receiver
diff --git a/engine/menus/menu.asm b/engine/menus/menu.asm
index 7ff696c9..0017172d 100644
--- a/engine/menus/menu.asm
+++ b/engine/menus/menu.asm
@@ -215,6 +215,7 @@ _ScrollingMenuJoypad::
jr .loopRTC
.pressed
+ vc_hook print_forbid_3
call _2DMenuInterpretJoypad
jp c, .done
ld a, [w2DMenuFlags1]
@@ -244,6 +245,7 @@ Menu_WasButtonPressed:
and a
ret z
scf
+ vc_hook print_forbid_2
ret
_2DMenuInterpretJoypad:
diff --git a/engine/overworld/scripting.asm b/engine/overworld/scripting.asm
index c29961cf..ff060f85 100644
--- a/engine/overworld/scripting.asm
+++ b/engine/overworld/scripting.asm
@@ -370,6 +370,7 @@ Script_yesorno:
ld a, TRUE
.no
ld [wScriptVar], a
+ vc_hook E_YESNO
ret
Script_loadmenu:
diff --git a/engine/pokedex/pokedex.asm b/engine/pokedex/pokedex.asm
index a895f357..c22775cb 100644
--- a/engine/pokedex/pokedex.asm
+++ b/engine/pokedex/pokedex.asm
@@ -356,6 +356,7 @@ Pokedex_UpdateDexEntryScreen:
ld a, [hl]
and B_BUTTON
jr nz, .return_to_prev_screen
+ vc_hook print_forbid_5
ld a, [hl]
and A_BUTTON
jr nz, .do_menu_action
diff --git a/engine/pokemon/mail_2.asm b/engine/pokemon/mail_2.asm
index 95402ea1..353a230c 100644
--- a/engine/pokemon/mail_2.asm
+++ b/engine/pokemon/mail_2.asm
@@ -48,7 +48,13 @@ ReadAnyMail:
ldh a, [hJoyPressed]
and A_BUTTON | B_BUTTON | START
jr z, .loop
+ vc_patch print_forbid_4
+if DEF(_GOLD_VC) || DEF(_SILVER_VC)
+ and 0
+else
and START
+endc
+ vc_patch_end
jr nz, .pressed_start
ret
diff --git a/home/serial.asm b/home/serial.asm
index 47494a85..177c2b8e 100644
--- a/home/serial.asm
+++ b/home/serial.asm
@@ -282,6 +282,7 @@ Serial_SyncAndExchangeNybble:: ; unreferenced
jp WaitLinkTransfer ; pointless
WaitLinkTransfer::
+ vc_hook send_send_buf2
ld a, $ff
ld [wOtherPlayerLinkAction], a
.loop
@@ -309,14 +310,26 @@ WaitLinkTransfer::
inc a
jr z, .loop
+ vc_patch Network10
+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_patch Network11
+if DEF(_GOLD_VC) || DEF(_SILVER_VC)
+ ld b, 26
+else
ld b, 10
+endc
+ vc_patch_end
.acknowledge
call DelayFrame
call LinkDataReceived
@@ -325,6 +338,7 @@ WaitLinkTransfer::
ld a, [wOtherPlayerLinkAction]
ld [wOtherPlayerLinkMode], a
+ vc_hook send_send_buf2_ret
ret
LinkTransfer::
diff --git a/macros.asm b/macros.asm
index 1c71cba8..93f424d9 100644
--- a/macros.asm
+++ b/macros.asm
@@ -6,6 +6,7 @@ INCLUDE "macros/data.asm"
INCLUDE "macros/code.asm"
INCLUDE "macros/gfx.asm"
INCLUDE "macros/coords.asm"
+INCLUDE "macros/vc.asm"
INCLUDE "macros/scripts/audio.asm"
INCLUDE "macros/scripts/maps.asm"
diff --git a/macros/vc.asm b/macros/vc.asm
new file mode 100644
index 00000000..3a04dc4c
--- /dev/null
+++ b/macros/vc.asm
@@ -0,0 +1,27 @@
+vc_hook: MACRO
+if DEF(_GOLD_VC) || DEF(_SILVER_VC)
+.VC_\1::
+endc
+ENDM
+
+vc_patch: MACRO
+if DEF(_GOLD_VC) || DEF(_SILVER_VC)
+ assert !DEF(CURRENT_VC_PATCH), "Already started a vc_patch"
+CURRENT_VC_PATCH EQUS "\1"
+.VC_{CURRENT_VC_PATCH}::
+endc
+ENDM
+
+vc_patch_end: MACRO
+if DEF(_GOLD_VC) || DEF(_SILVER_VC)
+ assert DEF(CURRENT_VC_PATCH), "No vc_patch started"
+.VC_{CURRENT_VC_PATCH}_End::
+ PURGE CURRENT_VC_PATCH
+endc
+ENDM
+
+vc_assert: MACRO
+if DEF(_GOLD_VC) || DEF(_SILVER_VC)
+ assert \#
+endc
+ENDM
diff --git a/roms.sha1 b/roms.sha1
index e3e7c1df..9bdad008 100644
--- a/roms.sha1
+++ b/roms.sha1
@@ -2,3 +2,5 @@ d8b8a3600a465308c9953dfa04f0081c05bdcb94 *pokegold.gbc
49b163f7e57702bc939d642a18f591de55d92dae *pokesilver.gbc
53783c57378122805c5b4859d19e1a224f02a1ed *pokegold_debug.gbc
4c2fafebdbc7551f4cd3f348bdd17e420b93b6e7 *pokesilver_debug.gbc
+b8253b915ade89c784c71adfdb11cf60bc1f7b59 *pokegold.patch
+a38c0dec807e8a9e3626a0ec0fdf96bfb795ef3a *pokesilver.patch
diff --git a/tools/.gitignore b/tools/.gitignore
index 0f4ea9f3..f2b24b55 100644
--- a/tools/.gitignore
+++ b/tools/.gitignore
@@ -1,5 +1,6 @@
+gfx
lzcomp
+make_patch
png_dimensions
scan_includes
-gfx
stadium
diff --git a/tools/Makefile b/tools/Makefile
index 294b1173..ae9456ae 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -6,6 +6,7 @@ CFLAGS := -O3 -std=c11 -Wall -Wextra -pedantic -Wno-missing-field-initializers
tools := \
lzcomp \
gfx \
+ make_patch \
png_dimensions \
scan_includes \
stadium
diff --git a/tools/gfx.c b/tools/gfx.c
index 4264e669..c8f0b03f 100644
--- a/tools/gfx.c
+++ b/tools/gfx.c
@@ -271,7 +271,7 @@ int main(int argc, char *argv[]) {
}
if (options.interleave) {
if (!options.png_file) {
- error_exit("--interleave needs --png to infer dimensions");
+ error_exit("--interleave needs --png to infer dimensions\n");
}
int width = read_png_width(options.png_file);
interleave(&graphic, width);
diff --git a/tools/make_patch.c b/tools/make_patch.c
new file mode 100644
index 00000000..136de0d5
--- /dev/null
+++ b/tools/make_patch.c
@@ -0,0 +1,452 @@
+#define PROGRAM_NAME "make_patch"
+#define USAGE_OPTS "labels.sym constants.sym patched.gbc original.gbc vc.patch.template vc.patch"
+
+#include "common.h"
+
+#include <ctype.h>
+
+struct Buffer {
+ size_t item_size;
+ size_t size;
+ size_t capacity;
+ void *data;
+};
+
+struct Symbol {
+ struct Symbol *next;
+ unsigned int address;
+ unsigned int offset;
+ char name[]; // C99 FAM
+};
+
+struct Patch {
+ unsigned int offset;
+ unsigned int size;
+};
+
+struct Buffer *buffer_create(size_t item_size) {
+ struct Buffer *buffer = xmalloc(sizeof(*buffer));
+ buffer->item_size = item_size;
+ buffer->size = 0;
+ buffer->capacity = 0x10;
+ buffer->data = xmalloc(buffer->capacity * item_size);
+ return buffer;
+}
+
+void buffer_append(struct Buffer *buffer, const void *item) {
+ if (buffer->size >= buffer->capacity) {
+ buffer->capacity = (buffer->capacity + 1) * 2;
+ buffer->data = xrealloc(buffer->data, buffer->capacity * buffer->item_size);
+ }
+ memcpy((char *)buffer->data + (buffer->size++ * buffer->item_size), item, buffer->item_size);
+}
+
+void buffer_free(struct Buffer *buffer) {
+ free(buffer->data);
+ free(buffer);
+}
+
+void symbol_append(struct Symbol **symbols, const char *name, int bank, int address) {
+ size_t name_len = strlen(name) + 1;
+ struct Symbol *symbol = xmalloc(sizeof(*symbol) + name_len);
+ symbol->address = address;
+ symbol->offset = bank > 0 && address < 0x8000 ? address + (bank - 1) * 0x4000 : address;
+ memcpy(symbol->name, name, name_len);
+ symbol->next = *symbols;
+ *symbols = symbol;
+}
+
+void symbol_free(struct Symbol *symbols) {
+ for (struct Symbol *next; symbols; symbols = next) {
+ next = symbols->next;
+ free(symbols);
+ }
+}
+
+const struct Symbol *symbol_find(const struct Symbol *symbols, const char *name) {
+ size_t name_len = strlen(name);
+ for (const struct Symbol *symbol = symbols; symbol; symbol = symbol->next) {
+ size_t sym_name_len = strlen(symbol->name);
+ if (name_len > sym_name_len) {
+ continue;
+ }
+ const char *sym_name = symbol->name;
+ if (name[0] == '.') {
+ // If `name` is a local label, compare it to the local part of `symbol->name`
+ sym_name += sym_name_len - name_len;
+ }
+ if (!strcmp(sym_name, name)) {
+ return symbol;
+ }
+ }
+ error_exit("Error: Unknown symbol: \"%s\"\n", name);
+}
+
+const struct Symbol *symbol_find_cat(const struct Symbol *symbols, const char *prefix, const char *suffix) {
+ char *sym_name = xmalloc(strlen(prefix) + strlen(suffix) + 1);
+ sprintf(sym_name, "%s%s", prefix, suffix);
+ const struct Symbol *symbol = symbol_find(symbols, sym_name);
+ free(sym_name);
+ return symbol;
+}
+
+int parse_number(const char *input, int base) {
+ char *endptr;
+ int n = (int)strtol(input, &endptr, base);
+ if (endptr == input || *endptr || n < 0) {
+ error_exit("Error: Cannot parse number: \"%s\"\n", input);
+ }
+ return n;
+}
+
+void parse_symbol_value(char *input, int *restrict bank, int *restrict address) {
+ char *colon = strchr(input, ':');
+ if (!colon) {
+ error_exit("Error: Cannot parse bank+address: \"%s\"\n", input);
+ }
+ *colon++ = '\0';
+ *bank = parse_number(input, 16);
+ *address = parse_number(colon, 16);
+}
+
+void parse_symbols(const char *filename, struct Symbol **symbols) {
+ 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;
+
+ for (;;) {
+ int c = getc(file);
+ if (c == EOF || c == '\n' || c == '\r' || c == ';' || (state == SYM_NAME && (c == ' ' || c == '\t'))) {
+ 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);
+ }
+ // Skip to the next line, ignoring anything after the symbol value and name
+ state = SYM_PRE;
+ while (c != EOF && c != '\n' && c != '\r') {
+ c = getc(file);
+ }
+ if (c == EOF) {
+ break;
+ }
+ } else if (c != ' ' && c != '\t') {
+ if (state == SYM_PRE || state == SYM_SPACE) {
+ // The symbol value or name has started; buffer its contents
+ if (++state == SYM_NAME) {
+ // The symbol name has started; parse the buffered value
+ buffer_append(buffer, &(char []){'\0'});
+ parse_symbol_value(buffer->data, &bank, &address);
+ }
+ buffer->size = 0;
+ }
+ buffer_append(buffer, &c);
+ } else if (state == SYM_VALUE) {
+ // The symbol value has ended; wait to see if a name comes after it
+ state = SYM_SPACE;
+ }
+ }
+
+ fclose(file);
+ buffer_free(buffer);
+}
+
+int parse_arg_value(const char *arg, bool absolute, const struct Symbol *symbols, const char *patch_name) {
+ // Comparison operators for "ConditionValueB" evaluate to their particular values
+ static const char *comparisons[] = {"==", ">", "<", ">=", "<=", "!=", "||"};
+ for (unsigned int i = 0; i < sizeof(comparisons) / sizeof(*comparisons); i++) {
+ if (!strcmp(arg, comparisons[i])) {
+ return i == 6 ? 0x11 : i; // "||" is 0x11
+ }
+ }
+
+ // Literal numbers evaluate to themselves
+ if (isdigit((unsigned)arg[0]) || arg[0] == '+') {
+ return parse_number(arg, 0);
+ }
+
+ // Symbols evaluate to their offset or address, plus an optional offset mod
+ int offset_mod = 0;
+ char *plus = strchr(arg, '+');
+ if (plus) {
+ offset_mod = parse_number(plus, 0);
+ *plus = '\0';
+ }
+ const char *sym_name = !strcmp(arg, "@") ? patch_name : arg; // "@" is the current patch label
+ const struct Symbol *symbol = symbol_find(symbols, sym_name);
+ return (absolute ? symbol->offset : symbol->address) + offset_mod;
+}
+
+void interpret_command(char *command, const struct Symbol *current_hook, const struct Symbol *symbols, struct Buffer *patches, FILE *restrict new_rom, FILE *restrict orig_rom, FILE *restrict output) {
+ // Strip all leading spaces and all but one trailing space
+ int x = 0;
+ for (int i = 0; command[i]; i++) {
+ if (!isspace((unsigned)command[i]) || (i > 0 && !isspace((unsigned)command[i - 1]))) {
+ command[x++] = command[i];
+ }
+ }
+ command[x - (x > 0 && isspace((unsigned)command[x - 1]))] = '\0';
+
+ // Count the arguments
+ int argc = 0;
+ for (const char *c = command; *c; c++) {
+ if (isspace((unsigned)*c)) {
+ argc++;
+ }
+ }
+
+ // Get the arguments
+ char *argv[argc]; // VLA
+ char *arg = command;
+ for (int i = 0; i < argc; i++) {
+ while (*arg && !isspace((unsigned)*arg)) {
+ arg++;
+ }
+ if (!*arg) {
+ break;
+ }
+ *arg++ = '\0';
+ argv[i] = arg;
+ }
+
+ // Use the arguments
+ if (!strcmp(command, "patch") || !strcmp(command, "PATCH") || !strcmp(command, "patch_") || !strcmp(command, "PATCH_")) {
+ if (argc > 2) {
+ error_exit("Error: Invalid arguments for command: \"%s\"\n", command);
+ }
+ if (!current_hook) {
+ error_exit("Error: No current patch for command: \"%s\"\n", command);
+ }
+ int current_offset = current_hook->offset + (argc > 0 ? parse_number(argv[0], 0) : 0);
+ if (fseek(orig_rom, current_offset, SEEK_SET)) {
+ error_exit("Error: Cannot seek to \"vc_patch %s\" in the original ROM\n", current_hook->name);
+ }
+ if (fseek(new_rom, current_offset, SEEK_SET)) {
+ error_exit("Error: Cannot seek to \"vc_patch %s\" in the new ROM\n", current_hook->name);
+ }
+ int length;
+ if (argc == 2) {
+ length = parse_number(argv[1], 0);
+ } else {
+ const struct Symbol *current_hook_end = symbol_find_cat(symbols, current_hook->name, "_End");
+ length = current_hook_end->offset - current_offset;
+ }
+ buffer_append(patches, &(struct Patch){current_offset, length});
+ bool modified = false;
+ if (length == 1) {
+ int c = getc(new_rom);
+ modified = c != getc(orig_rom);
+ fprintf(output, isupper((unsigned)command[0]) ? "0x%02X" : "0x%02x", c);
+ } else {
+ fprintf(output, command[strlen(command) - 1] == '_' ? "a%d: " : "a%d:", length);
+ for (int i = 0; i < length; i++) {
+ if (i) {
+ putc(' ', output);
+ }
+ int c = getc(new_rom);
+ modified |= c != getc(orig_rom);
+ fprintf(output, isupper((unsigned)command[0]) ? "%02X" : "%02x", c);
+ }
+ }
+ if (!modified) {
+ fprintf(stderr, PROGRAM_NAME ": Warning: \"vc_patch %s\" doesn't alter the ROM\n", current_hook->name);
+ }
+
+ } else if (!strcmp(command, "dws") || !strcmp(command, "DWS") || !strcmp(command, "dws_") || !strcmp(command, "DWS_")) {
+ if (argc < 1) {
+ error_exit("Error: Invalid arguments for command: \"%s\"\n", command);
+ }
+ fprintf(output, command[strlen(command) - 1] == '_' ? "a%d: " : "a%d:", argc * 2);
+ for (int i = 0; i < argc; i++) {
+ int value = parse_arg_value(argv[i], false, symbols, current_hook->name);
+ if (value > 0xffff) {
+ error_exit("Error: Invalid value for \"%s\" argument: 0x%x\n", command, value);
+ }
+ if (i) {
+ putc(' ', output);
+ }
+ fprintf(output, isupper((unsigned)command[0]) ? "%02X %02X": "%02x %02x", value & 0xff, value >> 8);
+ }
+
+ } else if (!strcmp(command, "db") || !strcmp(command, "DB") || !strcmp(command, "db_") || !strcmp(command, "DB_")) {
+ if (argc != 1) {
+ error_exit("Error: Invalid arguments for command: \"%s\"\n", command);
+ }
+ int value = parse_arg_value(argv[0], false, symbols, current_hook->name);
+ if (value > 0xff) {
+ error_exit("Error: Invalid value for \"%s\" argument: 0x%x\n", command, value);
+ }
+ fputs(command[strlen(command) - 1] == '_' ? "a1: " : "a1:", output);
+ fprintf(output, isupper((unsigned)command[0]) ? "%02X" : "%02x", value);
+
+ } else if (!strcmp(command, "hex") || !strcmp(command, "HEX") || !strcmp(command, "HEx") || !strcmp(command, "Hex") || !strcmp(command, "heX") || !strcmp(command, "hEX")) {
+ if (argc != 1 && argc != 2) {
+ error_exit("Error: Invalid arguments for command: \"%s\"\n", command);
+ }
+ int value = parse_arg_value(argv[0], true, symbols, current_hook->name);
+ int padding = argc > 1 ? parse_number(argv[1], 0) : 2;
+ if (!strcmp(command, "HEx")) {
+ fprintf(output, "0x%0*X%02x", padding - 2, value >> 8, value & 0xff);
+ } else if (!strcmp(command, "Hex")) {
+ fprintf(output, "0x%0*X%03x", padding - 3, value >> 12, value & 0xfff);
+ } else if (!strcmp(command, "heX")) {
+ fprintf(output, "0x%0*x%02X", padding - 2, value >> 8, value & 0xff);
+ } else if (!strcmp(command, "hEX")) {
+ fprintf(output, "0x%0*x%03X", padding - 3, value >> 12, value & 0xfff);
+ } else {
+ fprintf(output, isupper((unsigned)command[0]) ? "0x%0*X" : "0x%0*x", padding, value);
+ }
+
+ } else {
+ error_exit("Error: Unknown command: \"%s\"\n", command);
+ }
+}
+
+void skip_to_next_line(FILE *restrict input, FILE *restrict output) {
+ for (int c = getc(input); c != EOF; c = getc(input)) {
+ putc(c, output);
+ if (c == '\n' || c == '\r') {
+ break;
+ }
+ }
+}
+
+struct Buffer *process_template(const char *template_filename, const char *patch_filename, FILE *restrict new_rom, FILE *restrict orig_rom, const struct Symbol *symbols) {
+ FILE *input = xfopen(template_filename, 'r');
+ FILE *output = xfopen(patch_filename, 'w');
+
+ struct Buffer *patches = buffer_create(sizeof(struct Patch));
+ struct Buffer *buffer = buffer_create(1);
+
+ // The ROM checksum will always differ
+ buffer_append(patches, &(struct Patch){0x14e, 2});
+ // The Stadium data (see stadium.c) will always differ
+ unsigned int rom_size = (unsigned int)xfsize("", orig_rom);
+ unsigned int stadium_size = 24 + 6 + 2 + (rom_size / 0x2000) * 2;
+ buffer_append(patches, &(struct Patch){rom_size - stadium_size, stadium_size});
+
+ // Fill in the template
+ const struct Symbol *current_hook = NULL;
+ for (int c = getc(input); c != EOF; c = getc(input)) {
+ switch (c) {
+ case ';':
+ // ";" comments until the end of the line
+ putc(c, output);
+ skip_to_next_line(input, output);
+ break;
+
+ case '{':
+ // "{...}" is a template command; buffer its contents
+ buffer->size = 0;
+ for (c = getc(input); c != EOF && c != '}'; c = getc(input)) {
+ buffer_append(buffer, &c);
+ }
+ buffer_append(buffer, &(char []){'\0'});
+ // Interpret the command in the context of the current patch
+ interpret_command(buffer->data, current_hook, symbols, patches, new_rom, orig_rom, output);
+ break;
+
+ case '[':
+ // "[...]" is a patch label; buffer its contents
+ putc(c, output);
+ bool alternate = false;
+ buffer->size = 0;
+ for (c = getc(input); c != EOF; c = getc(input)) {
+ if (!alternate && c == '@') {
+ // "@" designates an alternate name for the ".VC_" label
+ alternate = true;
+ buffer->size = 0;
+ } else if (c == ']') {
+ putc(c, output);
+ break;
+ } else {
+ if (!alternate) {
+ putc(c, output);
+ if (!isalnum(c) && c != '_') {
+ // Convert non-identifier characters to underscores
+ c = '_';
+ }
+ }
+ buffer_append(buffer, &c);
+ }
+ }
+ buffer_append(buffer, &(char []){'\0'});
+ // The current patch should have a corresponding ".VC_" label
+ current_hook = symbol_find_cat(symbols, ".VC_", buffer->data);
+ skip_to_next_line(input, output);
+ break;
+
+ default:
+ putc(c, output);
+ }
+ }
+
+ rewind(orig_rom);
+ rewind(new_rom);
+
+ fclose(input);
+ fclose(output);
+ buffer_free(buffer);
+ return patches;
+}
+
+int compare_patch(const void *patch1, const void *patch2) {
+ unsigned int offset1 = ((const struct Patch *)patch1)->offset;
+ unsigned int offset2 = ((const struct Patch *)patch2)->offset;
+ return offset1 > offset2 ? 1 : offset1 < offset2 ? -1 : 0;
+}
+
+bool verify_completeness(FILE *restrict orig_rom, FILE *restrict new_rom, struct Buffer *patches) {
+ qsort(patches->data, patches->size, patches->item_size, compare_patch);
+ for (unsigned int offset = 0, index = 0; ; offset++) {
+ int orig_byte = getc(orig_rom);
+ int new_byte = getc(new_rom);
+ if (orig_byte == EOF || new_byte == EOF) {
+ return orig_byte == new_byte;
+ }
+ struct Patch *patch = &((struct Patch *)patches->data)[index];
+ if (index < patches->size && patch->offset == offset) {
+ if (fseek(orig_rom, patch->size, SEEK_CUR)) {
+ return false;
+ }
+ if (fseek(new_rom, patch->size, SEEK_CUR)) {
+ return false;
+ }
+ offset += patch->size;
+ index++;
+ } else if (orig_byte != new_byte) {
+ fprintf(stderr, PROGRAM_NAME ": Warning: Unpatched difference at offset: 0x%x\n", offset);
+ fprintf(stderr, " Original ROM value: 0x%02x\n", orig_byte);
+ fprintf(stderr, " Patched ROM value: 0x%02x\n", new_byte);
+ fprintf(stderr, " Current patch offset: 0x%06x\n", patch->offset);
+ return false;
+ }
+ }
+}
+
+int main(int argc, char *argv[]) {
+ if (argc != 7) {
+ 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);
+
+ if (!verify_completeness(orig_rom, new_rom, patches)) {
+ fprintf(stderr, PROGRAM_NAME ": Warning: Not all ROM differences are defined by \"%s\"\n", argv[6]);
+ }
+
+ symbol_free(symbols);
+ fclose(new_rom);
+ fclose(orig_rom);
+ buffer_free(patches);
+ return 0;
+}
diff --git a/vc/pokegold.constants.asm b/vc/pokegold.constants.asm
new file mode 100644
index 00000000..7e6f1185
--- /dev/null
+++ b/vc/pokegold.constants.asm
@@ -0,0 +1,59 @@
+INCLUDE "constants.asm"
+
+; These are all the asm constants needed to make the gold_vc patch.
+
+vc_const: MACRO
+x = \1
+ println "00:{04x:x} \1" ; same format as rgblink's .sym file
+ENDM
+
+; [FPA 001 Begin]
+ vc_const "F"
+ vc_const "I"
+ vc_const "S"
+ vc_const "U"
+ vc_const "R"
+
+; [FPA 002 Begin]
+ vc_const "E"
+ vc_const "L"
+ vc_const "D"
+
+; [FPA 003 Begin]
+ vc_const "T"
+ vc_const "H"
+ vc_const "N"
+
+; [FPA 004 Begin]
+ vc_const "Y"
+ vc_const "P"
+ ; "<SPACE>" is necessary since spaces separate template command arguments
+ charmap "<SPACE>", " "
+ vc_const "<SPACE>"
+
+; [FPA 005 Begin]
+ vc_const "O"
+
+; [FPA 006 Begin]
+ vc_const "X"
+
+; [FPA 007 Begin]
+ vc_const "A"
+ vc_const "@"
+
+; [FPA 042801 Begin]
+ vc_const ANIM_GFX_BUBBLE
+
+; [fight begin]
+ vc_const SCREEN_HEIGHT_PX
+
+; [print forbid 2]
+ vc_const NO_INPUT
+ vc_const A_BUTTON
+ vc_const B_BUTTON
+ vc_const D_UP
+ vc_const D_DOWN
+
+; [print forbid 3]
+ vc_const MAPGROUP_CIANWOOD
+ vc_const MAP_CIANWOOD_PHOTO_STUDIO
diff --git a/vc/pokegold.patch.template b/vc/pokegold.patch.template
new file mode 100644
index 00000000..9b3ae86a
--- /dev/null
+++ b/vc/pokegold.patch.template
@@ -0,0 +1,716 @@
+;Format Sample
+;[xxxx] ;User-defined Name (Max:31 chars)
+;Mode = 1 ;1:Fixcode; 2:Fixvalue; 3:Mask; 4:Palette; 5:Double Frame Buffer
+;Type = 0 ;0:Begin 1:End
+;Index = 0 ;Index
+;Address = x1F8000 ;ROM Address
+;MemAddress = x2000 ;RAM Address
+;Fixcode = 0 ;Mode1: Fixed Rom Code; Mode2: Fixed Value
+;DelayFrame = 0 ;Delay Frame
+;FadeFrame = 0 ;Fade Frame 0:Off
+;DarkEnable0 = 0 ;0:Off, 1:On (for Normal Mode)
+;ReduceEnable0 = 0 ;0:Off, 1:On (for Normal Mode)
+;MotionBEnable0 = 0 ;0:Off, 1:Black Fade, 2:, 3:Frame Blend (for Normal Mode)
+;Dark0 = 10 ;0~10 (for Normal Mode)
+;ReduceColorR0 = 0 ;0~31 (for Normal Mode)
+;ReduceColorG0 = 0 ;0~31 (for Normal Mode)
+;ReduceColorB0 = 0 ;0~31 (for Normal Mode)
+;MotionBlur0 = 31 ;0~31 (for Normal Mode)
+;DarkEnable1 = 0 ;0:Off, 1:On (for Green Mode)
+;ReduceEnable1 = 0 ;0:Off, 1:On (for Green Mode)
+;MotionBEnable1 = 0 ;0:Off, 1:Black Fade, 2:, 3:Frame Blend (for Green Mode)
+;Dark1 = 10 ;0~10 (for Green Mode)
+;ReduceColorR1 = 0 ;0~31 (for Green Mode)
+;ReduceColorG1 = 0 ;0~31 (for Green Mode)
+;ReduceColorB1 = 0 ;0~31 (for Green Mode)
+;MotionBlur1 = 31 ;0~31 (for Green Mode)
+;PaletteX = c31,31,31 ;X:0~15, cR,G,B (0~31)
+
+
+
+
+[send_send_buf2]
+Mode = 2
+Address = {HEX @ 4}
+Type = 29
+
+[send_send_buf2_ret]
+Mode = 2
+Address = {HEX @ 4}
+Type = 30
+
+[send_byt2]
+Mode = 2
+Address = {HEX @+5}
+Type = 31
+
+[send_byt2_ret]
+Mode = 2
+Address = {HEX @}
+Type = 32
+
+[send_byt2_wait]
+Mode = 1
+Address = {HEX @+1}
+Fixcode = {PATCH +1}
+
+[send_dummy]
+Mode = 2
+Address = {HEX @}
+Type = 33
+
+[send_dummy_wait]
+Mode = 1
+Address = {HEX @+1}
+Fixcode = {PATCH +1}
+
+[send_dummy_end]
+Mode = 2
+Address = {HEX @}
+Type = 34
+
+[Network10]
+Mode = 1
+Address = {HEX @+1 4}
+Fixcode = {PATCH +1}
+
+[Network11]
+Mode = 1
+Address = {HEX @+1 4}
+Fixcode = {PATCH +1}
+
+[NetworkDelay1]
+Mode = 1
+Address = {HEX @+1}
+Fixcode = {PATCH +1}
+
+[NetworkDelay2]
+Mode = 1
+Address = {HEX @}
+Fixcode = {PATCH}
+
+[NetworkDelay3]
+Mode = 1
+Address = {HEX @+1}
+Fixcode = {PATCH +1}
+
+[NetworkDelay4]
+Mode = 1
+Address = {HEX @+1}
+Fixcode = {PATCH +1}
+
+[NetworkDelay6]
+Mode = 1
+Address = {HEX @+1}
+Fixcode = {PATCH +1}
+
+[Network358]
+Mode = 2
+Address = {HEX @}
+Type = 4
+
+[Network359]
+Mode = 2
+Address = {HEX @}
+Type = 4
+
+[Network364]
+Mode = 2
+Address = {HEX @}
+Type = 26
+
+[Network360]
+Mode = 2
+Address = {HEX @}
+Type = 4
+
+[Network361]
+Mode = 2
+Address = {HEX @}
+Type = 4
+
+[Network362]
+Mode = 2
+Address = {HEX @}
+Type = 4
+
+[Network363]
+Mode = 2
+Address = {HEX @}
+Type = 4
+
+[Network_RECHECK]
+Mode = 2
+Address = {HEX @}
+Type = 7
+
+;no use[Network_STOP]
+;Mode = 2
+;Address = 0xF4D34
+;Type = 8
+
+;no use[Network_END]
+;Mode = 2
+;Address = 0xF4D3C
+;Type = 9
+
+[Network_RESET]
+Mode = 2
+Address = {HEX @ 5}
+Type = 10
+
+[E_YESNO]
+Mode = 2
+Address = {HEX @}
+Type = 15
+
+[linkCable fake begin]
+Mode = 2
+Address = {HEX @}
+Type = 16
+
+[linkCable fake end]
+Mode = 2
+Address = {HEX @}
+Type = 17
+
+;MURIYARI
+[linkCable block input]
+Mode = 2
+Address = {HEX @}
+Type = 18
+[linkCable block input2]
+Mode = 2
+Address = {HEX @}
+Type = 24
+[save game end]
+Mode = 2
+Address = {HEX @}
+Type = 20
+[term_exit]
+Mode = 2
+Address = {HEX @}
+Type = 25
+[room_check]
+Mode = 2
+Address = {HEX @}
+Type = 27
+[to_play2_mons1]
+Mode = 2
+Address = {HEX @}
+Type = 11
+[to_play2_trade]
+Mode = 2
+Address = {HEX @}
+Type = 12
+[to_play2_battle]
+Mode = 2
+Address = {HEX @}
+Type = 13
+[ret_heya]
+Mode = 2
+Address = {HEX @}
+Type = 14
+
+
+
+
+;
+;00023a9fh: C0 01 00 00 FF 00 FF 00 FF 00 FF 00 FF 10 00 00 ; ?.........
+;00023aafh: FF 01 00 00 0A 10 00 00 0A 01 00 00 FF 00 FF 00 ; .............
+;
+;change to below
+;
+;00023a9fh: FF 00 E0 01 00 00 FF 00 FF 10 00 00 FF 01 00 00 ; .?.........
+;00023aafh: 0A 10 00 00 0A 01 00 FF FF 00 FF 00 FF 00 FF 00 ; ...........
+;
+
+;[teaching movie]
+;Mode = 1
+;Address = 0x23a9f
+;Fixcode = a32: FF 00 E0 01 00 00 FF 00 FF 10 00 00 FF 01 00 00 0A 10 00 00 0A 01 00 FF FF 00 FF 00 FF 00 FF 00
+
+
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf7e value = 0x85
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf7f value = 0x88
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf80 value = 0x92
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf81 value = 0x92
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf82 value = 0x94
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf83 value = 0x91
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf84 value = 0x84
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf85 value = 0x50
+;000cc10fh: CB 7F 20 17 ; ? .
+[FPA 001 Begin@Reduce_move_anim_flashing]
+Mode = 3
+Type = 0
+Address = {hex @}
+DarkEnable0 = 1
+Dark0 = 4
+MotionBEnable0 = 3
+MotionBlur0 = 10
+ConditionType = 0
+ConditionValueA = {dws_ wStringBuffer2 wStringBuffer2+1 wStringBuffer2+2 wStringBuffer2+3 wStringBuffer2+4 wStringBuffer2+5}
+ConditionValueB = {dws_ == == == == == == }
+ConditionValueC = {dws_ "F" "I" "S" "S" "U" "R" }
+
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf7e value = 0x92
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf7f value = 0x84
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf80 value = 0x8b
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf81 value = 0x85
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf82 value = 0x83
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf83 value = 0x84
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf84 value = 0x92
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf85 value = 0x93
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf86 value = 0x91
+;selfexplore
+[FPA 002 Begin@Reduce_move_anim_flashing]
+Mode = 3
+Type = 0
+Address = {hex @}
+DarkEnable0 = 1
+Dark0 = 4
+MotionBEnable0 = 3
+MotionBlur0 = 10
+ConditionType = 0
+ConditionValueA = {dws_ wStringBuffer2 wStringBuffer2+1 wStringBuffer2+2 wStringBuffer2+3 wStringBuffer2+4 wStringBuffer2+5}
+ConditionValueB = {dws_ == == == == == == }
+ConditionValueC = {dws_ "S" "E" "L" "F" "D" "E" }
+
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf7e value = 0x93
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf7f value = 0x87
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf80 value = 0x94
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf81 value = 0x8d
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf82 value = 0x83
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf83 value = 0x84
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf84 value = 0x91
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf85 value = 0x50
+; t h u n d e r
+[FPA 003 Begin@Reduce_move_anim_flashing]
+Mode = 3
+Type = 0
+Address = {hex @}
+DarkEnable0 = 1
+Dark0 = 4
+MotionBEnable0 = 3
+MotionBlur0 = 10
+ConditionType = 0
+ConditionValueA = {dws_ wStringBuffer2 wStringBuffer2+1 wStringBuffer2+2 wStringBuffer2+3 wStringBuffer2+4 wStringBuffer2+5}
+ConditionValueB = {dws_ == == == == == == }
+ConditionValueC = {dws_ "T" "H" "U" "N" "D" "E" }
+
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf7e value = 0x87
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf7f value = 0x98
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf80 value = 0x8f
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf81 value = 0x84
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf82 value = 0x91
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf83 value = 0x7f
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf84 value = 0x81
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf85 value = 0x84
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf86 value = 0x80
+; h y p e r b e a m
+
+[FPA 004 Begin@Reduce_move_anim_flashing]
+Mode = 3
+Type = 0
+Address = {hex @}
+DarkEnable0 = 1
+Dark0 = 5
+MotionBEnable0 = 3
+MotionBlur0 = 16
+ConditionType = 0
+ConditionValueA = {dws_ wStringBuffer2 wStringBuffer2+1 wStringBuffer2+2 wStringBuffer2+3 wStringBuffer2+4 wStringBuffer2+5}
+ConditionValueB = {dws_ == == == == == == }
+ConditionValueC = {dws_ "H" "Y" "P" "E" "R" "<SPACE>" }
+
+
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf7e value = 0x87
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf7f value = 0x8e
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf80 value = 0x91
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf81 value = 0x8d
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf82 value = 0x7f
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf83 value = 0x83
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf84 value = 0x91
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf85 value = 0x88
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf86 value = 0x8b
+
+[FPA 005 Begin@Reduce_move_anim_flashing]
+Mode = 3
+Type = 0
+Address = {hex @}
+DarkEnable0 = 1
+Dark0 = 4
+MotionBEnable0 = 3
+MotionBlur0 = 11
+ConditionType = 0
+ConditionValueA = {dws_ wStringBuffer2 wStringBuffer2+1 wStringBuffer2+2 wStringBuffer2+3 wStringBuffer2+4 wStringBuffer2+5}
+ConditionValueB = {dws_ == == == == == == }
+ConditionValueC = {dws_ "H" "O" "R" "N" "<SPACE>" "D" }
+
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf7e value = 0x84
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf7f value = 0x97
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf80 value = 0x8f
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf81 value = 0x8b
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf82 value = 0x8e
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf83 value = 0x92
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf84 value = 0x88
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf85 value = 0x8e
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf86 value = 0x8d
+
+[FPA 006 Begin@Reduce_move_anim_flashing]
+Mode = 3
+Type = 0
+Address = {hex @}
+DarkEnable0 = 1
+Dark0 = 5
+MotionBEnable0 = 3
+MotionBlur0 = 11
+ConditionType = 0
+ConditionValueA = {dws_ wStringBuffer2 wStringBuffer2+1 wStringBuffer2+2 wStringBuffer2+3 wStringBuffer2+4 wStringBuffer2+5}
+ConditionValueB = {dws_ == == == == == == }
+ConditionValueC = {dws_ "E" "X" "P" "L" "O" "S" }
+
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf7e value = 0x85
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf7f value = 0x8b
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf80 value = 0x80
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf81 value = 0x92
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf82 value = 0x87
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf83 value = 0x50
+;
+[FPA 007 Begin@Reduce_move_anim_flashing]
+Mode = 3
+Type = 0
+Address = {hex @}
+DarkEnable0 = 1
+Dark0 = 4
+MotionBEnable0 = 3
+MotionBlur0 = 11
+ConditionType = 0
+ConditionValueA = {dws_ wStringBuffer2 wStringBuffer2+1 wStringBuffer2+2 wStringBuffer2+3 wStringBuffer2+4 wStringBuffer2+5}
+ConditionValueB = {dws_ == == == == == == }
+ConditionValueC = {dws_ "F" "L" "A" "S" "H" "@" }
+
+
+
+;-----111111111111111144444444444444----0xc902 no ..............Mem Write: pc32 = 0xcc46a addr = 0xc902 value = 0xd
+;
+;PC:51-4461=FA 000CC461 LY:006 AF:0080 BC:E401 DE:0001 HL:C900 SP:DFAB
+;PC:51-4464=FE 000CC464 LY:006 AF:0080 BC:E401 DE:0001 HL:C900 SP:DFAB
+;PC:51-4466=D0 000CC466 LY:006 AF:0070 BC:E401 DE:0001 HL:C900 SP:DFAB
+;PC:51-4467=CD 000CC467 LY:006 AF:0070 BC:E401 DE:0001 HL:C900 SP:DFAB ----- happend only once while the explosive animation begin.
+;000cc471h: FA 19 CA FE
+
+ ; ******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf7e value = 0x8f
+ ; ******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf7f value = 0x91
+ ; ******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf80 value = 0x84
+ ; ******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf81 value = 0x92
+ ; ******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf82 value = 0x84
+ ; ******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf83 value = 0x8d
+ ; ******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf84 value = 0x93
+ ; ******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf85 value = 0x50
+
+
+[FPA 042801 Begin]
+Mode = 3
+Type = 0
+Address = {HEX @}
+DarkEnable0 = 1
+Dark0 = 5
+MotionBEnable0 = 3
+MotionBlur0 = 11
+ConditionType = 0
+ConditionValueA = {dws_ wStringBuffer2 wStringBuffer2+1 wStringBuffer2+2 wStringBuffer2+3 wStringBuffer2+4 wStringBuffer2+5 wBattleAnimTileDict+2}
+ConditionValueB = {dws_ == == == == == == == }
+ConditionValueC = {dws_ "P" "R" "E" "S" "E" "N" ANIM_GFX_BUBBLE }
+
+
+
+
+;ROM:CC1A4 call unk_41CA
+;ROM:CC1A7 call unk_41CA
+;ROM:CC1AA call unk_41CA
+;ROM:CC1AD call unk_147E
+;ROM:CC1B0 ret
+
+;exit point
+;000cc1c0h: C9 F0 E8 A7 C8
+
+[FPA 001 End@Stop_reducing_move_anim_flashing]
+Mode = 3
+Type = 1
+Address = {hex @}
+
+
+
+
+;******ffa0***000000000000--------------- Mem Write: pc32 = 0x8c52d addr = 0xffa0 value = 0x1
+;-----ddddff0xff690xff69fffff----0xce57 no ....----5555555577777---------..........Mem Write: pc32 = 0x8c483 addr = 0xce57 value = 0x1a
+[FPA link fight begin]
+Mode = 3
+Type = 0
+Address = {hex @}
+DarkEnable0 = 1
+Dark0 = 5
+MotionBEnable0 = 3
+MotionBlur0 = 11
+
+;ROM:8C52D ld [hl], 1
+;ROM:8C52F ld a, [byte_CE63]
+;ROM:8C532 bit 7, a
+;
+
+;******ffa0***000000000000--------------- Mem Write: pc32 = 0x8c55d addr = 0xffa0 value = 0x0
+;0008c65dh: CE 34 C9 CD 5B 46 AF EA 64 CE E0 D6 C9 CD 72 46 ; ?赏[Fd梧稚蛂F
+;******cccceeee6333--------------- Mem Write: pc32 = 0x8c65e addr = 0xce63 value = 0x15
+;******cccceeee6333--------------- Mem Write: pc32 = 0x8c65e addr = 0xce63 value = 0x16
+;******cccceeee6333--------------- Mem Write: pc32 = 0x8c65e addr = 0xce63 value = 0x17
+
+;40 90 e4 01 3E at 3E
+[FPA link fight End0]
+Mode = 3
+Type = 1
+Address = {HEX @}
+
+;3D 20 EF C9 3E 01 at 3E
+[FPA link fight End1]
+Mode = 3
+Type = 1
+Address = {HEX @}
+
+;01 FF 3E 01 at 3E
+[FPA link fight End2]
+Mode = 3
+Type = 1
+Address = {HEX @}
+
+;32 00 19 00 3e 01 at 3e
+[FPA link fight End3]
+Mode = 3
+Type = 1
+Address = {HEX @}
+
+[FPA link fight End4]
+Mode = 3
+Type = 1
+Address = {hex @}
+
+;-----4a----0xffaaaa no ..............Mem Write: pc32 = 0x1a3 addr = 0xff4a value = 0x90
+;-----4bbbb----0xff4b no ..............Mem Write: pc32 = 0x1a7 addr = 0xff4b value = 0x7
+;-----4a----0xffaaaa no ..............Mem Write: pc32 = 0x1a3 addr = 0xff4a value = 0x90
+;-----4bbbb----0xff4b no ..............Mem Write: pc32 = 0x1a7 addr = 0xff4b value = 0x7
+;Patch 46 0x3f929
+;Patch 46 0x3f929 effecting
+;-----4a----0xffaaaa no ..............Mem Write: pc32 = 0x3f929 addr = 0xff4a value = 0x90
+;-----4a----0xffaaaa no ..............Mem Write: pc32 = 0x1a3 addr = 0xff4a value = 0x0
+;-----4bbbb----0xff4b no ..............Mem Write: pc32 = 0x1a7 addr = 0xff4b value = 0x7
+
+
+;ROM:3F929 ld [byte_FF4A], a
+;ROM:3F92B call unk_33AE
+;ROM:3F92E call unk_30C6
+;ROM:3F931 ld b, 1
+;ROM:3F933 call unk_34E5
+;ROM:3F936 call unk_34A8
+;ROM:3F939 ld a, $90 ; '?
+;ROM:3F93B ld [byte_FFD4], a
+;ROM:3F93D xor a
+
+;0003f8c6h: AF E0 D4 E0 4A ; 脏J
+
+[fight begin]
+Mode = 11
+Type = 0
+Index = 1
+Address = {HEx @}
+Fixcode={db SCREEN_HEIGHT_PX}
+
+
+
+
+; print forbid 1
+;ROM:1758D ld a, [byte_FFA9]
+;ROM:1758F and 2
+;ROM:17591 jr nz, unk_75B4
+;ROM:17593 ld a, [byte_FFA9]
+;ROM:17595 and 1 ;e6 01
+;ROM:17597 jr nz, unk_75A1
+;
+; change "and 1" to "and 0"
+;00016ecch: E6 01 20 08
+[print forbid 1]
+Mode = 1
+Address = {hex @}
+Fixcode={patch}
+
+;ROM:1A29 ld a, [byte_FFAB]
+;ROM:1A2B and $F0 ; '?
+;ROM:1A2D ld b, a
+;ROM:1A2E ld a, [byte_FFA9]
+;ROM:1A30 and $F
+;ROM:1A32 or b
+;
+;
+;
+;ROM:2419C call loc_1A27
+;ROM:2419F bit 0, a
+;ROM:241A1 jp nz, unk_4244
+;ROM:241A4 bit 1, a
+;ROM:241A6 jp nz, unk_4244
+;ROM:241A9 bit 2, a
+;ROM:241AB jp nz, unk_4244
+;ROM:241AE bit 3, a
+;ROM:241B0 jp nz, unk_4244
+;ROM:241B3 bit 4, a
+;ROM:241B5 jr nz, unk_4226
+;ROM:241B7 bit 5, a
+;ROM:241B9 jr nz, unk_4208
+;ROM:241BB bit 6, a
+;ROM:241BD jr nz, unk_41EA
+;ROM:241BF bit 7, a
+;ROM:241C1 jr nz, unk_41CC
+;ROM:241C3 and a
+;ROM:241C4 ret
+
+;0002419bh: C9 CD 7A 1A CB 47 C2 44 42 CB 4F C2 44 42 CB 57
+;000241abh: C2 44 42 CB
+;
+[print forbid 2]
+Mode = 6
+Type = 0
+Address = {hex @}
+MemAddress={hex hJoyPressed}
+Fixcode={db NO_INPUT}
+ConditionType = 0
+ConditionValueA = {dws_ wWindowStackPointer wWindowStackPointer+1 wMenuJoypad wMenuSelection wMenuSelection wMenuCursorY hJoyPressed hJoyPressed hJoyPressed hJoyPressed}
+ConditionValueB = {dws_ == == == >= <= == != != != != }
+ConditionValueC = {dws_ 0xb7 0xb9 A_BUTTON 0x00 0x0f 0x03 D_DOWN D_UP B_BUTTON NO_INPUT }
+
+; -----ddddfffffff99999ccccc77777----0xd9c7 no ..............Mem Write: pc32 = 0x230b addr = 0xd9c7 value = 0x8
+; 0xd9c7 is the room number.
+;
+
+[print forbid 3]
+Mode = 6
+Type = 0
+Address = {hex @}
+MemAddress={hex hJoyPressed}
+Fixcode={db NO_INPUT}
+ConditionType = 0
+ConditionValueA = {dws_ wWindowStackPointer wWindowStackPointer+1 wMenuJoypad wMenuSelection wMenuCursorY wWarpNumber wMapGroup wMapNumber hJoyPressed hJoyPressed hJoyPressed hJoyPressed}
+ConditionValueB = {dws_ == == == == == == == == != != != != }
+ConditionValueC = {dws_ 0xcd 0xbf NO_INPUT 0x00 0x01 0x01 MAPGROUP_CIANWOOD MAP_CIANWOOD_PHOTO_STUDIO D_DOWN D_UP B_BUTTON NO_INPUT }
+
+;ROM:BB29C call unk_934
+;ROM:BB29F ld a, [byte_FFA9]
+;ROM:BB2A1 and $B
+;ROM:BB2A3 jr z, unk_B29C
+;ROM:BB2A5 and 8
+;ROM:BB2A7 jr nz, unk_B2AA
+;ROM:BB2A9 ret
+; 000baf1ah: E6 08 20 01
+; change "and 1" to "and 0"
+[print forbid 4]
+Mode = 1
+Address = {hex @}
+Fixcode={patch}
+
+
+;ROM:401D6 call unk_50A5
+;ROM:401D9 ld hl, $FFA9
+;ROM:401DC ld a, [hl]
+;ROM:401DD and 2
+;ROM:401DF jr nz, unk_1F8
+;ROM:401E1 ld a, [hl]
+;ROM:401E2 and 1
+;ROM:401E4 jr nz, unk_1EE
+;ROM:401E6 call unk_4562
+;ROM:401E9 ret nc
+;ROM:401EA call unk_4114
+;ROM:401ED ret
+; -----6666666666ddddddddd88888----0xc6d8 no ..............Mem Write: pc32 = 0x4109b addr = 0xc6d8 value = 0x0
+
+; 00040266h: 7E E6 01 20 08
+[print forbid 5]
+Mode = 6
+Type = 0
+Address = {hex @}
+MemAddress={hex hJoyPressed}
+Fixcode={db NO_INPUT}
+ConditionType = 0
+ConditionValueA = {dws_ wWindowStackPointer wWindowStackPointer+1 wMenuJoypad wMenuSelection wDexArrowCursorPosIndex hJoyPressed hJoyPressed hJoyPressed hJoyPressed}
+ConditionValueB = {dws_ == == == == == != != != != }
+ConditionValueC = {dws_ 0xbd 0xbd A_BUTTON 0x00 0x03 D_DOWN D_UP B_BUTTON NO_INPUT }
+
+
+
+
+;0x29e97
+; call ir_main
+; ld d,a ; IR_STAT
+; xor a
+
+
+; _IRcomm_end 0x2a1b9
+; ld hl,ir_read_buf | 21 50 c7
+; ld de,ir_read_buf_stk | 11 00 c8
+; ld bc,15 |
+; call block_move |
+; |
+
+
+;0002a123h: FE 03 30 24
+;the code below is Set_send_data2
+;0002a127h: 3E 3F 21 6A 4F CF CD 29 65
+
+
+;3E 3F 21 6A 4F CF CD 29 65
+; ------->
+; BCALL G_BANK0b,set_send_data2
+; call read_buf_clr
+;
+
+;00029e23h: 3E 02 EA 01 C9
+[infrared fake 0]
+Mode = 1
+Address = {hex @}
+Fixcode={PATCH}
+
+
+
+;00029fc8h: 30 3E 3A 21 E9 4F CF CD 8C 61 CD C4 61 CD 0B 62
+;00029fd8h: F0 BE FE 10
+
+[infrared fake 1@infrared_fake]
+Mode = 1
+Address = {hex @}
+Fixcode={patch 0 21}
+
+[infrared fake 2@infrared_fake]
+Mode = 2
+Address = {hex @}
+Type = 101
+
+[infrared fake 5]
+Mode = 2
+Address = {hex @}
+Type = 100
+
+[infrared fake 3]
+Mode = 2
+Address = {hex @}
+Type = 102
+
+[infrared fake 4]
+Mode = 2
+Address = {hex @}
+Type = 103
+
+
+
+
+
+
+
+
+
+
+
diff --git a/vc/pokesilver.constants.asm b/vc/pokesilver.constants.asm
new file mode 100644
index 00000000..6de0ff48
--- /dev/null
+++ b/vc/pokesilver.constants.asm
@@ -0,0 +1,59 @@
+INCLUDE "constants.asm"
+
+; These are all the asm constants needed to make the silver_vc patch.
+
+vc_const: MACRO
+x = \1
+ println "00:{04x:x} \1" ; same format as rgblink's .sym file
+ENDM
+
+; [FPA 001 Begin]
+ vc_const "F"
+ vc_const "I"
+ vc_const "S"
+ vc_const "U"
+ vc_const "R"
+
+; [FPA 002 Begin]
+ vc_const "E"
+ vc_const "L"
+ vc_const "D"
+
+; [FPA 003 Begin]
+ vc_const "T"
+ vc_const "H"
+ vc_const "N"
+
+; [FPA 004 Begin]
+ vc_const "Y"
+ vc_const "P"
+ ; "<SPACE>" is necessary since spaces separate template command arguments
+ charmap "<SPACE>", " "
+ vc_const "<SPACE>"
+
+; [FPA 005 Begin]
+ vc_const "O"
+
+; [FPA 006 Begin]
+ vc_const "X"
+
+; [FPA 007 Begin]
+ vc_const "A"
+ vc_const "@"
+
+; [FPA 042801 Begin]
+ vc_const ANIM_GFX_BUBBLE
+
+; [fight begin]
+ vc_const SCREEN_HEIGHT_PX
+
+; [print forbid 2]
+ vc_const NO_INPUT
+ vc_const A_BUTTON
+ vc_const B_BUTTON
+ vc_const D_UP
+ vc_const D_DOWN
+
+; [print forbid 3]
+ vc_const MAPGROUP_CIANWOOD
+ vc_const MAP_CIANWOOD_PHOTO_STUDIO
diff --git a/vc/pokesilver.patch.template b/vc/pokesilver.patch.template
new file mode 100644
index 00000000..46936d0e
--- /dev/null
+++ b/vc/pokesilver.patch.template
@@ -0,0 +1,724 @@
+;Format Sample
+;[xxxx] ;User-defined Name (Max:31 chars)
+;Mode = 1 ;1:Fixcode; 2:Fixvalue; 3:Mask; 4:Palette; 5:Double Frame Buffer
+;Type = 0 ;0:Begin 1:End
+;Index = 0 ;Index
+;Address = x1F8000 ;ROM Address
+;MemAddress = x2000 ;RAM Address
+;Fixcode = 0 ;Mode1: Fixed Rom Code; Mode2: Fixed Value
+;DelayFrame = 0 ;Delay Frame
+;FadeFrame = 0 ;Fade Frame 0:Off
+;DarkEnable0 = 0 ;0:Off, 1:On (for Normal Mode)
+;ReduceEnable0 = 0 ;0:Off, 1:On (for Normal Mode)
+;MotionBEnable0 = 0 ;0:Off, 1:Black Fade, 2:, 3:Frame Blend (for Normal Mode)
+;Dark0 = 10 ;0~10 (for Normal Mode)
+;ReduceColorR0 = 0 ;0~31 (for Normal Mode)
+;ReduceColorG0 = 0 ;0~31 (for Normal Mode)
+;ReduceColorB0 = 0 ;0~31 (for Normal Mode)
+;MotionBlur0 = 31 ;0~31 (for Normal Mode)
+;DarkEnable1 = 0 ;0:Off, 1:On (for Green Mode)
+;ReduceEnable1 = 0 ;0:Off, 1:On (for Green Mode)
+;MotionBEnable1 = 0 ;0:Off, 1:Black Fade, 2:, 3:Frame Blend (for Green Mode)
+;Dark1 = 10 ;0~10 (for Green Mode)
+;ReduceColorR1 = 0 ;0~31 (for Green Mode)
+;ReduceColorG1 = 0 ;0~31 (for Green Mode)
+;ReduceColorB1 = 0 ;0~31 (for Green Mode)
+;MotionBlur1 = 31 ;0~31 (for Green Mode)
+;PaletteX = c31,31,31 ;X:0~15, cR,G,B (0~31)
+
+
+
+
+[send_send_buf2]
+Mode = 2
+Address = {HEX @ 4}
+Type = 29
+
+[send_send_buf2_ret]
+Mode = 2
+Address = {HEX @ 4}
+Type = 30
+
+[send_byt2]
+Mode = 2
+Address = {HEX @+5}
+Type = 31
+
+[send_byt2_ret]
+Mode = 2
+Address = {HEX @}
+Type = 32
+
+[send_byt2_wait]
+Mode = 1
+Address = {HEX @+1}
+Fixcode = {PATCH +1}
+
+[send_dummy]
+Mode = 2
+Address = {HEX @}
+Type = 33
+
+[send_dummy_wait]
+Mode = 1
+Address = {HEX @+1}
+Fixcode = {PATCH +1}
+
+[send_dummy_end]
+Mode = 2
+Address = {HEX @}
+Type = 34
+
+[Network10]
+Mode = 1
+Address = {HEX @+1 4}
+Fixcode = {PATCH +1}
+
+[Network11]
+Mode = 1
+Address = {HEX @+1 4}
+Fixcode = {PATCH +1}
+
+[NetworkDelay1]
+Mode = 1
+Address = {HEX @+1}
+Fixcode = {PATCH +1}
+
+[NetworkDelay2]
+Mode = 1
+Address = {HEX @}
+Fixcode = {PATCH}
+
+[NetworkDelay3]
+Mode = 1
+Address = {HEX @+1}
+Fixcode = {PATCH +1}
+
+[NetworkDelay4]
+Mode = 1
+Address = {HEX @+1}
+Fixcode = {PATCH +1}
+
+[NetworkDelay6]
+Mode = 1
+Address = {HEX @+1}
+Fixcode = {PATCH +1}
+
+[Network358]
+Mode = 2
+Address = {HEX @}
+Type = 4
+
+[Network359]
+Mode = 2
+Address = {HEX @}
+Type = 4
+
+[Network364]
+Mode = 2
+Address = {HEX @}
+Type = 26
+
+[Network360]
+Mode = 2
+Address = {HEX @}
+Type = 4
+
+[Network361]
+Mode = 2
+Address = {HEX @}
+Type = 4
+
+[Network362]
+Mode = 2
+Address = {HEX @}
+Type = 4
+
+[Network363]
+Mode = 2
+Address = {HEX @}
+Type = 4
+
+[Network_RECHECK]
+Mode = 2
+Address = {HEX @}
+Type = 7
+
+;no use[Network_STOP]
+;Mode = 2
+;Address = 0xF4D34
+;Type = 8
+
+;no use[Network_END]
+;Mode = 2
+;Address = 0xF4D3C
+;Type = 9
+
+[Network_RESET]
+Mode = 2
+Address = {HEX @ 5}
+Type = 10
+
+[E_YESNO]
+Mode = 2
+Address = {HEX @}
+Type = 15
+
+[linkCable fake begin]
+Mode = 2
+Address = {HEX @}
+Type = 16
+
+[linkCable fake end]
+Mode = 2
+Address = {HEX @}
+Type = 17
+
+;MURIYARI
+[linkCable block input]
+Mode = 2
+Address = {HEX @}
+Type = 18
+[linkCable block input2]
+Mode = 2
+Address = {HEX @}
+Type = 24
+[save game end]
+Mode = 2
+Address = {HEX @}
+Type = 20
+[term_exit]
+Mode = 2
+Address = {HEX @}
+Type = 25
+[room_check]
+Mode = 2
+Address = {HEX @}
+Type = 27
+[to_play2_mons1]
+Mode = 2
+Address = {HEX @}
+Type = 11
+[to_play2_trade]
+Mode = 2
+Address = {HEX @}
+Type = 12
+[to_play2_battle]
+Mode = 2
+Address = {HEX @}
+Type = 13
+[ret_heya]
+Mode = 2
+Address = {HEX @}
+Type = 14
+
+
+
+
+;
+;00023a9fh: C0 01 00 00 FF 00 FF 00 FF 00 FF 00 FF 10 00 00 ; ?.........
+;00023aafh: FF 01 00 00 0A 10 00 00 0A 01 00 00 FF 00 FF 00 ; .............
+;
+;change to below
+;
+;00023a9fh: FF 00 E0 01 00 00 FF 00 FF 10 00 00 FF 01 00 00 ; .?.........
+;00023aafh: 0A 10 00 00 0A 01 00 FF FF 00 FF 00 FF 00 FF 00 ; ...........
+;
+
+;[teaching movie]
+;Mode = 1
+;Address = 0x23a9f
+;Fixcode = a32: FF 00 E0 01 00 00 FF 00 FF 10 00 00 FF 01 00 00 0A 10 00 00 0A 01 00 FF FF 00 FF 00 FF 00 FF 00
+;
+
+
+
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf7e value = 0x85
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf7f value = 0x88
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf80 value = 0x92
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf81 value = 0x92
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf82 value = 0x94
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf83 value = 0x91
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf84 value = 0x84
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf85 value = 0x50
+;000cc10fh: CB 7F 20 17 ; ? .
+[FPA 001 Begin@Reduce_move_anim_flashing]
+Mode = 3
+Type = 0
+Address = {hex @}
+DarkEnable0 = 1
+Dark0 = 4
+MotionBEnable0 = 3
+MotionBlur0 = 10
+ConditionType = 0
+ConditionValueA = {dws_ wStringBuffer2 wStringBuffer2+1 wStringBuffer2+2 wStringBuffer2+3 wStringBuffer2+4 wStringBuffer2+5}
+ConditionValueB = {dws_ == == == == == == }
+ConditionValueC = {dws_ "F" "I" "S" "S" "U" "R" }
+
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf7e value = 0x92
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf7f value = 0x84
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf80 value = 0x8b
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf81 value = 0x85
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf82 value = 0x83
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf83 value = 0x84
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf84 value = 0x92
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf85 value = 0x93
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf86 value = 0x91
+;selfexplore
+[FPA 002 Begin@Reduce_move_anim_flashing]
+Mode = 3
+Type = 0
+Address = {hex @}
+DarkEnable0 = 1
+Dark0 = 4
+MotionBEnable0 = 3
+MotionBlur0 = 10
+ConditionType = 0
+ConditionValueA = {dws_ wStringBuffer2 wStringBuffer2+1 wStringBuffer2+2 wStringBuffer2+3 wStringBuffer2+4 wStringBuffer2+5}
+ConditionValueB = {dws_ == == == == == == }
+ConditionValueC = {dws_ "S" "E" "L" "F" "D" "E" }
+
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf7e value = 0x93
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf7f value = 0x87
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf80 value = 0x94
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf81 value = 0x8d
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf82 value = 0x83
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf83 value = 0x84
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf84 value = 0x91
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf85 value = 0x50
+; t h u n d e r
+[FPA 003 Begin@Reduce_move_anim_flashing]
+Mode = 3
+Type = 0
+Address = {hex @}
+DarkEnable0 = 1
+Dark0 = 4
+MotionBEnable0 = 3
+MotionBlur0 = 10
+ConditionType = 0
+ConditionValueA = {dws_ wStringBuffer2 wStringBuffer2+1 wStringBuffer2+2 wStringBuffer2+3 wStringBuffer2+4 wStringBuffer2+5}
+ConditionValueB = {dws_ == == == == == == }
+ConditionValueC = {dws_ "T" "H" "U" "N" "D" "E" }
+
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf7e value = 0x87
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf7f value = 0x98
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf80 value = 0x8f
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf81 value = 0x84
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf82 value = 0x91
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf83 value = 0x7f
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf84 value = 0x81
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf85 value = 0x84
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf86 value = 0x80
+; h y p e r b e a m
+
+[FPA 004 Begin@Reduce_move_anim_flashing]
+Mode = 3
+Type = 0
+Address = {hex @}
+DarkEnable0 = 1
+Dark0 = 5
+MotionBEnable0 = 3
+MotionBlur0 = 16
+ConditionType = 0
+ConditionValueA = {dws_ wStringBuffer2 wStringBuffer2+1 wStringBuffer2+2 wStringBuffer2+3 wStringBuffer2+4 wStringBuffer2+5}
+ConditionValueB = {dws_ == == == == == == }
+ConditionValueC = {dws_ "H" "Y" "P" "E" "R" "<SPACE>" }
+
+
+
+
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf7e value = 0x87
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf7f value = 0x8e
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf80 value = 0x91
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf81 value = 0x8d
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf82 value = 0x7f
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf83 value = 0x83
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf84 value = 0x91
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf85 value = 0x88
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf86 value = 0x8b
+
+[FPA 005 Begin@Reduce_move_anim_flashing]
+Mode = 3
+Type = 0
+Address = {hex @}
+DarkEnable0 = 1
+Dark0 = 4
+MotionBEnable0 = 3
+MotionBlur0 = 11
+ConditionType = 0
+ConditionValueA = {dws_ wStringBuffer2 wStringBuffer2+1 wStringBuffer2+2 wStringBuffer2+3 wStringBuffer2+4 wStringBuffer2+5}
+ConditionValueB = {dws_ == == == == == == }
+ConditionValueC = {dws_ "H" "O" "R" "N" "<SPACE>" "D" }
+
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf7e value = 0x84
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf7f value = 0x97
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf80 value = 0x8f
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf81 value = 0x8b
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf82 value = 0x8e
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf83 value = 0x92
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf84 value = 0x88
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf85 value = 0x8e
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf86 value = 0x8d
+
+[FPA 006 Begin@Reduce_move_anim_flashing]
+Mode = 3
+Type = 0
+Address = {hex @}
+DarkEnable0 = 1
+Dark0 = 5
+MotionBEnable0 = 3
+MotionBlur0 = 11
+ConditionType = 0
+ConditionValueA = {dws_ wStringBuffer2 wStringBuffer2+1 wStringBuffer2+2 wStringBuffer2+3 wStringBuffer2+4 wStringBuffer2+5}
+ConditionValueB = {dws_ == == == == == == }
+ConditionValueC = {dws_ "E" "X" "P" "L" "O" "S" }
+
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf7e value = 0x85
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf7f value = 0x8b
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf80 value = 0x80
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf81 value = 0x92
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf82 value = 0x87
+;******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf83 value = 0x50
+;
+[FPA 007 Begin@Reduce_move_anim_flashing]
+Mode = 3
+Type = 0
+Address = {hex @}
+DarkEnable0 = 1
+Dark0 = 4
+MotionBEnable0 = 3
+MotionBlur0 = 11
+ConditionType = 0
+ConditionValueA = {dws_ wStringBuffer2 wStringBuffer2+1 wStringBuffer2+2 wStringBuffer2+3 wStringBuffer2+4 wStringBuffer2+5}
+ConditionValueB = {dws_ == == == == == == }
+ConditionValueC = {dws_ "F" "L" "A" "S" "H" "@" }
+
+
+
+
+;-----111111111111111144444444444444----0xc902 no ..............Mem Write: pc32 = 0xcc46a addr = 0xc902 value = 0xd
+;
+;PC:51-4461=FA 000CC461 LY:006 AF:0080 BC:E401 DE:0001 HL:C900 SP:DFAB
+;PC:51-4464=FE 000CC464 LY:006 AF:0080 BC:E401 DE:0001 HL:C900 SP:DFAB
+;PC:51-4466=D0 000CC466 LY:006 AF:0070 BC:E401 DE:0001 HL:C900 SP:DFAB
+;PC:51-4467=CD 000CC467 LY:006 AF:0070 BC:E401 DE:0001 HL:C900 SP:DFAB ----- happend only once while the explosive animation begin.
+;000cc471h: FA 19 CA FE
+
+ ; ******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf7e value = 0x8f
+ ; ******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf7f value = 0x91
+ ; ******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf80 value = 0x84
+ ; ******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf81 value = 0x92
+ ; ******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf82 value = 0x84
+ ; ******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf83 value = 0x8d
+ ; ******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf84 value = 0x93
+ ; ******0xcccccccccffffffff8***********--------------- Mem Write: pc32 = 0x3180 addr = 0xcf85 value = 0x50
+
+
+[FPA 042801 Begin]
+Mode = 3
+Type = 0
+Address = {HEX @}
+DarkEnable0 = 1
+Dark0 = 5
+MotionBEnable0 = 3
+MotionBlur0 = 11
+ConditionType = 0
+ConditionValueA = {dws_ wStringBuffer2 wStringBuffer2+1 wStringBuffer2+2 wStringBuffer2+3 wStringBuffer2+4 wStringBuffer2+5 wBattleAnimTileDict+2}
+ConditionValueB = {dws_ == == == == == == == }
+ConditionValueC = {dws_ "P" "R" "E" "S" "E" "N" ANIM_GFX_BUBBLE }
+
+
+
+
+;ROM:CC1A4 call unk_41CA
+;ROM:CC1A7 call unk_41CA
+;ROM:CC1AA call unk_41CA
+;ROM:CC1AD call unk_147E
+;ROM:CC1B0 ret
+
+;exit point
+;000cc1c0h: C9 F0 E8 A7 C8
+
+[FPA 001 End@Stop_reducing_move_anim_flashing]
+Mode = 3
+Type = 1
+Address = {hex @}
+
+
+
+;******ffa0***000000000000--------------- Mem Write: pc32 = 0x8c52d addr = 0xffa0 value = 0x1
+;-----ddddff0xff690xff69fffff----0xce57 no ....----5555555577777---------..........Mem Write: pc32 = 0x8c483 addr = 0xce57 value = 0x1a
+[FPA link fight begin]
+Mode = 3
+Type = 0
+Address = {hex @}
+DarkEnable0 = 1
+Dark0 = 5
+MotionBEnable0 = 3
+MotionBlur0 = 11
+
+
+;ROM:8C52D ld [hl], 1
+;ROM:8C52F ld a, [byte_CE63]
+;ROM:8C532 bit 7, a
+;
+
+;******ffa0***000000000000--------------- Mem Write: pc32 = 0x8c55d addr = 0xffa0 value = 0x0
+;0008c65dh: CE 34 C9 CD 5B 46 AF EA 64 CE E0 D6 C9 CD 72 46 ; ?赏[Fd梧稚蛂F
+;******cccceeee6333--------------- Mem Write: pc32 = 0x8c65e addr = 0xce63 value = 0x15
+;******cccceeee6333--------------- Mem Write: pc32 = 0x8c65e addr = 0xce63 value = 0x16
+;******cccceeee6333--------------- Mem Write: pc32 = 0x8c65e addr = 0xce63 value = 0x17
+
+
+;40 90 e4 01 3E at 3E
+[FPA link fight End0]
+Mode = 3
+Type = 1
+Address = {HEX @}
+
+;3D 20 EF C9 3E 01 at 3E
+[FPA link fight End1]
+Mode = 3
+Type = 1
+Address = {HEX @}
+
+;01 FF 3E 01 at 3E
+[FPA link fight End2]
+Mode = 3
+Type = 1
+Address = {HEX @}
+
+;32 00 19 00 3e 01 at 3e
+[FPA link fight End3]
+Mode = 3
+Type = 1
+Address = {HEX @}
+
+[FPA link fight End4]
+Mode = 3
+Type = 1
+Address = {hex @}
+
+;-----4a----0xffaaaa no ..............Mem Write: pc32 = 0x1a3 addr = 0xff4a value = 0x90
+;-----4bbbb----0xff4b no ..............Mem Write: pc32 = 0x1a7 addr = 0xff4b value = 0x7
+;-----4a----0xffaaaa no ..............Mem Write: pc32 = 0x1a3 addr = 0xff4a value = 0x90
+;-----4bbbb----0xff4b no ..............Mem Write: pc32 = 0x1a7 addr = 0xff4b value = 0x7
+;Patch 46 0x3f929
+;Patch 46 0x3f929 effecting
+;-----4a----0xffaaaa no ..............Mem Write: pc32 = 0x3f929 addr = 0xff4a value = 0x90
+;-----4a----0xffaaaa no ..............Mem Write: pc32 = 0x1a3 addr = 0xff4a value = 0x0
+;-----4bbbb----0xff4b no ..............Mem Write: pc32 = 0x1a7 addr = 0xff4b value = 0x7
+
+
+;ROM:3F929 ld [byte_FF4A], a
+;ROM:3F92B call unk_33AE
+;ROM:3F92E call unk_30C6
+;ROM:3F931 ld b, 1
+;ROM:3F933 call unk_34E5
+;ROM:3F936 call unk_34A8
+;ROM:3F939 ld a, $90 ; '?
+;ROM:3F93B ld [byte_FFD4], a
+;ROM:3F93D xor a
+;0003f8c6h: AF E0 D4 E0 4A
+
+[fight begin]
+Mode = 11
+Type = 0
+Index = 1
+Address = {HEx @}
+Fixcode={db SCREEN_HEIGHT_PX}
+
+
+
+
+
+
+
+; print forbid 1
+;ROM:1758D ld a, [byte_FFA9]
+;ROM:1758F and 2
+;ROM:17591 jr nz, unk_75B4
+;ROM:17593 ld a, [byte_FFA9]
+;ROM:17595 and 1 ;e6 01
+;ROM:17597 jr nz, unk_75A1
+;
+; change "and 1" to "and 0"
+;00016ecch: E6 01 20 08
+[print forbid 1]
+Mode = 1
+Address = {hex @}
+Fixcode={patch}
+
+;ROM:1A29 ld a, [byte_FFAB]
+;ROM:1A2B and $F0 ; '?
+;ROM:1A2D ld b, a
+;ROM:1A2E ld a, [byte_FFA9]
+;ROM:1A30 and $F
+;ROM:1A32 or b
+;
+;
+;
+;ROM:2419C call loc_1A27
+;ROM:2419F bit 0, a
+;ROM:241A1 jp nz, unk_4244
+;ROM:241A4 bit 1, a
+;ROM:241A6 jp nz, unk_4244
+;ROM:241A9 bit 2, a
+;ROM:241AB jp nz, unk_4244
+;ROM:241AE bit 3, a
+;ROM:241B0 jp nz, unk_4244
+;ROM:241B3 bit 4, a
+;ROM:241B5 jr nz, unk_4226
+;ROM:241B7 bit 5, a
+;ROM:241B9 jr nz, unk_4208
+;ROM:241BB bit 6, a
+;ROM:241BD jr nz, unk_41EA
+;ROM:241BF bit 7, a
+;ROM:241C1 jr nz, unk_41CC
+;ROM:241C3 and a
+;ROM:241C4 ret
+
+;0002419bh: C9 CD 7A 1A CB 47 C2 44 42 CB 4F C2 44 42 CB 57
+;000241abh: C2 44 42 CB
+;
+[print forbid 2]
+Mode = 6
+Type = 0
+Address = {hex @}
+MemAddress={hex hJoyPressed}
+Fixcode={db NO_INPUT}
+ConditionType = 0
+ConditionValueA = {dws_ wWindowStackPointer wWindowStackPointer+1 wMenuJoypad wMenuSelection wMenuSelection wMenuCursorY hJoyPressed hJoyPressed hJoyPressed hJoyPressed}
+ConditionValueB = {dws_ == == == >= <= == != != != != }
+ConditionValueC = {dws_ 0xb7 0xb9 A_BUTTON 0x00 0x0f 0x03 D_DOWN D_UP B_BUTTON NO_INPUT }
+
+; -----ddddfffffff99999ccccc77777----0xd9c7 no ..............Mem Write: pc32 = 0x230b addr = 0xd9c7 value = 0x8
+; 0xd9c7 is the room number.
+;
+
+[print forbid 3]
+Mode = 6
+Type = 0
+Address = {hex @}
+MemAddress={hex hJoyPressed}
+Fixcode={db NO_INPUT}
+ConditionType = 0
+ConditionValueA = {dws_ wWindowStackPointer wWindowStackPointer+1 wMenuJoypad wMenuSelection wMenuCursorY hJoyPressed hJoyPressed hJoyPressed hJoyPressed wWarpNumber wMapGroup wMapNumber}
+ConditionValueB = {dws_ == == == == == != != != != == == == }
+ConditionValueC = {dws_ 0xcd 0xbf NO_INPUT 0x00 0x01 D_DOWN D_UP B_BUTTON NO_INPUT 0x01 MAPGROUP_CIANWOOD MAP_CIANWOOD_PHOTO_STUDIO}
+
+;ROM:BB29C call unk_934
+;ROM:BB29F ld a, [byte_FFA9]
+;ROM:BB2A1 and $B
+;ROM:BB2A3 jr z, unk_B29C
+;ROM:BB2A5 and 8
+;ROM:BB2A7 jr nz, unk_B2AA
+;ROM:BB2A9 ret
+; 000baf1ah: E6 08 20 01
+; change "and 1" to "and 0"
+[print forbid 4]
+Mode = 1
+Address = {hex @}
+Fixcode={patch}
+
+
+;ROM:401D6 call unk_50A5
+;ROM:401D9 ld hl, $FFA9
+;ROM:401DC ld a, [hl]
+;ROM:401DD and 2
+;ROM:401DF jr nz, unk_1F8
+;ROM:401E1 ld a, [hl]
+;ROM:401E2 and 1
+;ROM:401E4 jr nz, unk_1EE
+;ROM:401E6 call unk_4562
+;ROM:401E9 ret nc
+;ROM:401EA call unk_4114
+;ROM:401ED ret
+; -----6666666666ddddddddd88888----0xc6d8 no ..............Mem Write: pc32 = 0x4109b addr = 0xc6d8 value = 0x0
+
+; 00040266h: 7E E6 01 20 08
+[print forbid 5]
+Mode = 6
+Type = 0
+Address = {hex @}
+MemAddress={hex hJoyPressed}
+Fixcode={db NO_INPUT}
+ConditionType = 0
+ConditionValueA = {dws_ wWindowStackPointer wWindowStackPointer+1 wMenuJoypad wMenuSelection wDexArrowCursorPosIndex hJoyPressed hJoyPressed hJoyPressed hJoyPressed}
+ConditionValueB = {dws_ == == == == == != != != != }
+ConditionValueC = {dws_ 0xbd 0xbd A_BUTTON 0x00 0x03 D_DOWN D_UP B_BUTTON NO_INPUT }
+
+
+
+
+
+;0x29e97
+; call ir_main
+; ld d,a ; IR_STAT
+; xor a
+
+
+; _IRcomm_end 0x2a1b9
+; ld hl,ir_read_buf | 21 50 c7
+; ld de,ir_read_buf_stk | 11 00 c8
+; ld bc,15 |
+; call block_move |
+; |
+
+
+;0002a123h: FE 03 30 24
+;the code below is Set_send_data2
+;0002a127h: 3E 3F 21 6A 4F CF CD 29 65
+
+
+;3E 3F 21 6A 4F CF CD 29 65
+; ------->
+; BCALL G_BANK0b,set_send_data2
+; call read_buf_clr
+;
+
+;00029e23h: 3E 02 EA 01 C9
+[infrared fake 0]
+Mode = 1
+Address = {hex @}
+Fixcode={PATCH}
+
+
+
+;00029fc8h: 30 3E 3A 21 E9 4F CF CD 8C 61 CD C4 61 CD 0B 62
+;00029fd8h: F0 BE FE 10
+
+[infrared fake 1@infrared_fake]
+Mode = 1
+Address = {hex @}
+Fixcode={patch 0 21}
+
+[infrared fake 2@infrared_fake]
+Mode = 2
+Address = {hex @}
+Type = 101
+
+[infrared fake 5]
+Mode = 2
+Address = {hex @}
+Type = 100
+
+[infrared fake 3]
+Mode = 2
+Address = {hex @}
+Type = 102
+
+[infrared fake 4]
+Mode = 2
+Address = {hex @}
+Type = 103
+
+
+
+
+
+
+
+
+
+