summaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorvulcandth <vulcandth@gmail.com>2022-03-12 17:34:04 -0600
committerGitHub <noreply@github.com>2022-03-12 18:34:04 -0500
commit31c3c94d64e1ac1e40c95acfda7de8b99b4f302b (patch)
tree274ec3a4fb4cacaa3d0f88c713085cfb5a3c85d1 /engine
parent775b5d046c7f42a3bd8034b92da92e25969bdbf7 (diff)
Build the Virtual Console patch with `make crystal11_vc` (#882)
Fixes #813
Diffstat (limited to 'engine')
-rw-r--r--engine/battle/battle_transition.asm6
-rw-r--r--engine/battle/core.asm1
-rw-r--r--engine/battle_anims/anim_commands.asm9
-rw-r--r--engine/events/print_unown.asm6
-rw-r--r--engine/gfx/color.asm1
-rw-r--r--engine/link/link.asm49
-rw-r--r--engine/link/mystery_gift.asm31
-rw-r--r--engine/menus/menu.asm2
-rw-r--r--engine/menus/save.asm9
-rw-r--r--engine/overworld/scripting.asm1
-rw-r--r--engine/pokedex/pokedex.asm1
-rw-r--r--engine/pokemon/mail_2.asm6
12 files changed, 122 insertions, 0 deletions
diff --git a/engine/battle/battle_transition.asm b/engine/battle/battle_transition.asm
index 12932ede5..1cbe881ef 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
@@ -58,6 +59,7 @@ DoBattleTransition:
ld a, $1 ; unnecessary bankswitch?
ldh [rSVBK], a
pop af
+ vc_hook FPA_link_fight_End4
ldh [hVBlank], a
call DelayFrame
ret
@@ -310,6 +312,7 @@ StartTrainerBattle_Flash:
dc 0, 0, 0, 1
StartTrainerBattle_SetUpForWavyOutro:
+ vc_hook FPA_link_fight_End0
farcall RespawnPlayerAndOpponent
ld a, BANK(wLYOverrides)
ldh [rSVBK], a
@@ -367,6 +370,7 @@ StartTrainerBattle_SineWave:
ret
StartTrainerBattle_SetUpForSpinOutro:
+ vc_hook FPA_link_fight_End1
farcall RespawnPlayerAndOpponent
ld a, BANK(wLYOverrides)
ldh [rSVBK], a
@@ -509,6 +513,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
ld a, BANK(wLYOverrides)
ldh [rSVBK], a
@@ -763,6 +768,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 5a6f20ce9..a8c54b77f 100644
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -8940,6 +8940,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 e7ae07087..d6d874240 100644
--- a/engine/battle_anims/anim_commands.asm
+++ b/engine/battle_anims/anim_commands.asm
@@ -58,12 +58,20 @@ BattleAnimRunScript:
farcall CheckBattleScene
jr c, .disabled
+ vc_hook FPA_001_Begin
+ vc_hook FPA_002_Begin
+ vc_hook FPA_003_Begin
+ vc_hook FPA_004_Begin
+ vc_hook FPA_005_Begin
+ vc_hook FPA_006_Begin
+ vc_hook FPA_007_Begin
call BattleAnimClearHud
call RunBattleAnimScript
call BattleAnimAssignPals
call BattleAnimRequestPals
+ vc_hook FPA_001_End
xor a
ldh [hSCX], a
ldh [hSCY], a
@@ -673,6 +681,7 @@ BattleAnimCmd_5GFX:
.loop
ld a, [wBattleAnimGFXTempTileID]
cp (vTiles1 - vTiles0) / LEN_2BPP_TILE - BATTLEANIM_BASE_TILE
+ vc_hook FPA_042801_Begin
ret nc
call GetBattleAnimByte
ld [hli], a
diff --git a/engine/events/print_unown.asm b/engine/events/print_unown.asm
index dac7d4b97..f969b3449 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(_CRYSTAL11_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 af7b7cd3d..092980a0e 100644
--- a/engine/gfx/color.asm
+++ b/engine/gfx/color.asm
@@ -1033,6 +1033,7 @@ endr
.FinalPush:
ld hl, MltReq1Packet
call _PushSGBPals
+ vc_hook Network_RESET
jp SGBDelayCycles
SGBBorder_PushBGPals:
diff --git a/engine/link/link.asm b/engine/link/link.asm
index 7de939430..72bc6f368 100644
--- a/engine/link/link.asm
+++ b/engine/link/link.asm
@@ -67,7 +67,13 @@ Gen2ToGen1LinkComms:
.player_1
ld de, MUSIC_NONE
call PlayMusic
+ vc_patch NetworkDelay1
+if DEF(_CRYSTAL11_VC)
+ ld c, 26
+else
ld c, 3
+endc
+ vc_patch_end
call DelayFrames
xor a
ldh [rIF], a
@@ -77,6 +83,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
@@ -84,6 +91,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
@@ -91,6 +99,7 @@ Gen2ToGen1LinkComms:
ld hl, wPlayerPatchLists
ld de, wOTPatchLists
ld bc, 200
+ vc_hook Network364
call Serial_ExchangeBytes
xor a
@@ -224,7 +233,13 @@ Gen2ToGen2LinkComms:
.player_1
ld de, MUSIC_NONE
call PlayMusic
+ vc_patch NetworkDelay4
+if DEF(_CRYSTAL11_VC)
+ ld c, 26
+else
ld c, 3
+endc
+ vc_patch_end
call DelayFrames
xor a
ldh [rIF], a
@@ -234,6 +249,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
@@ -241,6 +257,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
@@ -248,6 +265,7 @@ Gen2ToGen2LinkComms:
ld hl, wPlayerPatchLists
ld de, wOTPatchLists
ld bc, 200
+ vc_hook Network362
call Serial_ExchangeBytes
ld a, [wLinkMode]
@@ -256,6 +274,7 @@ Gen2ToGen2LinkComms:
ld hl, wLinkPlayerMail
ld de, wLinkOTMail
ld bc, wLinkPlayerMailEnd - wLinkPlayerMail
+ vc_hook Network363
call ExchangeBytes
.not_trading
@@ -1608,6 +1627,7 @@ ExitLinkCommunications:
ldh [rSC], a
ld a, (1 << rSC_ON) | (1 << rSC_CLOCK)
ldh [rSC], a
+ vc_hook ret_heya
ret
GSPlaceTradeScreenFooter: ; unreferenced
@@ -2009,6 +2029,7 @@ LinkTrade:
ld de, String_TradeCompleted
call PlaceString
farcall Link_WaitBGMap
+ vc_hook save_game_end
ld c, 50
call DelayFrames
ld a, [wLinkMode]
@@ -2161,7 +2182,13 @@ GetIncompatibleMonName:
ret
EnterTimeCapsule:
+ vc_patch NetworkDelay2
+if DEF(_CRYSTAL11_VC)
+ ld c, 26
+else
ld c, 10
+endc
+ vc_patch_end
call DelayFrames
ld a, $4
call Link_EnsureSync
@@ -2218,6 +2245,7 @@ WaitForOtherPlayerToExit:
ld [hl], a
ldh [hVBlank], a
ld [wLinkMode], a
+ vc_hook term_exit
ret
SetBitsForLinkTradeRequest:
@@ -2282,6 +2310,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
@@ -2374,7 +2403,13 @@ CheckLinkTimeout_Gen2:
ld a, $6
ld [wPlayerLinkAction], a
ld hl, wLinkTimeoutFrames
+ vc_patch NetworkDelay6
+if DEF(_CRYSTAL11_VC)
+ ld a, $3
+else
ld a, 1
+endc
+ vc_patch_end
ld [hli], a
ld [hl], 50
call Link_CheckCommunicationError
@@ -2395,6 +2430,7 @@ CheckLinkTimeout_Gen2:
Link_CheckCommunicationError:
xor a
ldh [hSerialReceivedNewData], a
+ vc_hook linkCable_fake_end
ld a, [wLinkTimeoutFrames]
ld h, a
ld a, [wLinkTimeoutFrames + 1]
@@ -2425,6 +2461,7 @@ Link_CheckCommunicationError:
.CheckConnected:
call WaitLinkTransfer
ld hl, wLinkTimeoutFrames
+ vc_hook Network_RECHECK
ld a, [hli]
inc a
ret nz
@@ -2433,7 +2470,13 @@ Link_CheckCommunicationError:
ret
.AcknowledgeSerial:
+ vc_patch NetworkDelay3
+if DEF(_CRYSTAL11_VC)
+ ld b, 26
+else
ld b, 10
+endc
+ vc_patch_end
.loop
call DelayFrame
call LinkDataReceived
@@ -2460,8 +2503,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
@@ -2498,6 +2543,7 @@ CheckBothSelectedSameRoom:
ret
TimeCapsule:
+ vc_hook to_play2_mons1
ld a, LINK_TIMECAPSULE
ld [wLinkMode], a
call DisableSpriteUpdates
@@ -2508,6 +2554,7 @@ TimeCapsule:
ret
TradeCenter:
+ vc_hook to_play2_trade
ld a, LINK_TRADECENTER
ld [wLinkMode], a
call DisableSpriteUpdates
@@ -2518,6 +2565,7 @@ TradeCenter:
ret
Colosseum:
+ vc_hook to_play2_battle
ld a, LINK_COLOSSEUM
ld [wLinkMode], a
call DisableSpriteUpdates
@@ -2532,6 +2580,7 @@ CloseLink:
ld [wLinkMode], a
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 1bc26f6a4..f3cb4e790 100644
--- a/engine/link/mystery_gift.asm
+++ b/engine/link/mystery_gift.asm
@@ -37,14 +37,23 @@ DoMysteryGift:
; Prepare the first of two messages for wMysteryGiftPartnerData
farcall StageDataForMysteryGift
call ClearMysteryGiftTrainer
+ vc_patch infrared_fake_0
+if DEF(_CRYSTAL11_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
@@ -260,6 +269,26 @@ DoMysteryGift:
jp CloseSRAM
ExchangeMysteryGiftData:
+ vc_hook infrared_fake_2
+ vc_patch infrared_fake_1
+if DEF(_CRYSTAL11_VC)
+ ld d, $ef
+.loop
+ dec d
+ ld a, d
+ or a
+ jr nz, .loop
+ vc_hook infrared_fake_3
+ nop
+ cp MG_CANCELED
+.restart ; same location as unpatched .restart
+ ret z
+ nop
+ nop
+ cp MG_OKAY
+ jr nz, ExchangeMysteryGiftData
+ ret
+else
di
farcall ClearChannels
call InitializeIRCommunicationInterrupts
@@ -268,6 +297,8 @@ ExchangeMysteryGiftData:
call BeginIRCommunication
call InitializeIRCommunicationRoles
ldh a, [hMGStatusFlags]
+endc
+ vc_patch_end
cp MG_CANCELED
jp z, EndOrContinueMysteryGiftIRCommunication
cp MG_OKAY
diff --git a/engine/menus/menu.asm b/engine/menus/menu.asm
index f20a6dceb..edae1c982 100644
--- a/engine/menus/menu.asm
+++ b/engine/menus/menu.asm
@@ -362,7 +362,9 @@ Menu_WasButtonPressed:
call GetMenuJoypad
and a
ret z
+ vc_hook print_forbid_3
scf
+ vc_hook print_forbid_2
ret
_2DMenuInterpretJoypad:
diff --git a/engine/menus/save.asm b/engine/menus/save.asm
index 82dab1046..381e3cc7c 100644
--- a/engine/menus/save.asm
+++ b/engine/menus/save.asm
@@ -161,6 +161,15 @@ AddHallOfFameEntry:
ld bc, wHallOfFamePokemonListEnd - wHallOfFamePokemonList + 1
call CopyBytes
call CloseSRAM
+; This vc_hook causes the Virtual Console to set [sMobileEventIndex] and [sMobileEventIndexBackup]
+; to MOBILE_EVENT_OBJECT_GS_BALL ($b), which enables you to get the GS Ball, take it to Kurt, and
+; encounter Celebi. It assumes that sMobileEventIndex and sMobileEventIndexBackup are at their
+; original addresses.
+ vc_hook BiographySave_ret
+ vc_assert BANK(sMobileEventIndex) == $1 && sMobileEventIndex == $be3c, \
+ "sMobileEventIndex is no longer located at 01:be3c."
+ vc_assert BANK(sMobileEventIndexBackup) == $1 && sMobileEventIndexBackup == $be44, \
+ "sMobileEventIndexBackup is no longer located at 01:be44."
ret
SaveGameData:
diff --git a/engine/overworld/scripting.asm b/engine/overworld/scripting.asm
index b53ba3911..824f626c4 100644
--- a/engine/overworld/scripting.asm
+++ b/engine/overworld/scripting.asm
@@ -389,6 +389,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 1a52d750f..5b356c29e 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 e0eb014b8..47b662412 100644
--- a/engine/pokemon/mail_2.asm
+++ b/engine/pokemon/mail_2.asm
@@ -67,7 +67,13 @@ ReadAnyMail:
ldh a, [hJoyPressed]
and A_BUTTON | B_BUTTON | START
jr z, .loop
+ vc_patch print_forbid_4
+if DEF(_CRYSTAL11_VC)
+ and 0
+else
and START
+endc
+ vc_patch_end
jr nz, .pressed_start
ret