mirror of
https://github.com/thornAvery/kep-hack.git
synced 2026-02-06 15:45:24 +13:00
Build the Virtual Console patches with make red_vc and make blue_vc (#351)
This commit is contained in:
parent
07df4a5f88
commit
fe8d3c51a4
24 changed files with 1752 additions and 34 deletions
|
|
@ -176,8 +176,12 @@ PlayAnimation:
|
|||
ld h, [hl]
|
||||
ld l, a
|
||||
.animationLoop
|
||||
vc_hook FPA_Thunderbolt_End
|
||||
ld a, [hli]
|
||||
vc_hook_red FPA_007_End
|
||||
vc_hook_blue FPA_009_End
|
||||
cp -1
|
||||
vc_hook_blue FPA_008_End
|
||||
jr z, .AnimationOver
|
||||
cp FIRST_SE_ID ; is this subanimation or a special effect?
|
||||
jr c, .playSubanimation
|
||||
|
|
@ -246,37 +250,55 @@ PlayAnimation:
|
|||
ld a, [wAnimPalette]
|
||||
ldh [rOBP0], a
|
||||
call LoadAnimationTileset
|
||||
vc_hook FPA_001_Begin
|
||||
call LoadSubanimation
|
||||
call PlaySubanimation
|
||||
vc_hook FPA_001_End
|
||||
pop af
|
||||
vc_hook_red FPA_008_End
|
||||
ldh [rOBP0], a
|
||||
.nextAnimationCommand
|
||||
vc_hook FPA_005_End
|
||||
pop hl
|
||||
vc_hook FPA_002_End
|
||||
jr .animationLoop
|
||||
.AnimationOver
|
||||
ret
|
||||
|
||||
LoadSubanimation:
|
||||
vc_hook FPA_002_Begin
|
||||
ld a, [wSubAnimAddrPtr + 1]
|
||||
vc_hook FPA_003_Begin
|
||||
ld h, a
|
||||
vc_hook_red FPA_131_Begin
|
||||
ld a, [wSubAnimAddrPtr]
|
||||
vc_hook_red FPA_56_Begin
|
||||
ld l, a
|
||||
ld a, [hli]
|
||||
ld e, a
|
||||
vc_hook FPA_76_Begin
|
||||
ld a, [hl]
|
||||
vc_hook FPA_Thunderbolt_Begin
|
||||
ld d, a ; de = address of subanimation
|
||||
ld a, [de]
|
||||
vc_hook_blue FPA_012_Begin
|
||||
ld b, a
|
||||
vc_hook FPA_Spore_Begin
|
||||
and %00011111
|
||||
vc_hook FPA_Bubblebeam_Begin
|
||||
ld [wSubAnimCounter], a ; number of frame blocks
|
||||
vc_hook_red FPA_010_Begin
|
||||
vc_hook_blue FPA_009_Begin
|
||||
ld a, b
|
||||
and %11100000
|
||||
cp SUBANIMTYPE_ENEMY << 5
|
||||
vc_hook_blue FPA_004_Begin
|
||||
jr nz, .isNotType5
|
||||
.isType5
|
||||
call GetSubanimationTransform2
|
||||
jr .saveTransformation
|
||||
.isNotType5
|
||||
vc_hook FPA_Hyper_Beam_Begin
|
||||
call GetSubanimationTransform1
|
||||
.saveTransformation
|
||||
; place the upper 3 bits of a into bits 0-2 of a before storing
|
||||
|
|
@ -307,6 +329,7 @@ LoadSubanimation:
|
|||
; sets the transform to SUBANIMTYPE_NORMAL if it's the player's turn
|
||||
; sets the transform to the subanimation type if it's the enemy's turn
|
||||
GetSubanimationTransform1:
|
||||
vc_hook FPA_Reflect_Begin
|
||||
ld b, a
|
||||
ldh a, [hWhoseTurn]
|
||||
and a
|
||||
|
|
@ -399,11 +422,15 @@ MoveAnimation:
|
|||
jr nz, .animationsDisabled
|
||||
call ShareMoveAnimations
|
||||
call PlayAnimation
|
||||
vc_hook_red FPA_004_End
|
||||
vc_hook_blue FPA_011_End
|
||||
jr .next4
|
||||
.animationsDisabled
|
||||
ld c, 30
|
||||
call DelayFrames
|
||||
.next4
|
||||
vc_hook_red FPA_010_End
|
||||
vc_hook_blue FPA_012_End
|
||||
call PlayApplyingAttackAnimation ; shake the screen or flash the pic in and out (to show damage)
|
||||
.animationFinished
|
||||
call WaitForSoundToFinish
|
||||
|
|
@ -541,6 +568,7 @@ SetAnimationPalette:
|
|||
.notSGB
|
||||
ld a, $e4
|
||||
ld [wAnimPalette], a
|
||||
vc_hook FPA_Dream_Eater_Begin
|
||||
ldh [rOBP0], a
|
||||
ld a, $6c
|
||||
ldh [rOBP1], a
|
||||
|
|
@ -956,6 +984,7 @@ AnimationFlashScreenLong:
|
|||
ld [wFlashScreenLongCounter], a
|
||||
pop hl
|
||||
jr nz, .loop
|
||||
vc_hook_red FPA_phy_End
|
||||
ret
|
||||
|
||||
; BG palettes
|
||||
|
|
|
|||
|
|
@ -3023,6 +3023,7 @@ LinkBattleExchangeData:
|
|||
ld a, b
|
||||
.doExchange
|
||||
ld [wSerialExchangeNybbleSendData], a
|
||||
vc_hook send_byt2
|
||||
callfar PrintWaitingText
|
||||
.syncLoop1
|
||||
call Serial_ExchangeNybble
|
||||
|
|
@ -3030,18 +3031,33 @@ LinkBattleExchangeData:
|
|||
ld a, [wSerialExchangeNybbleReceiveData]
|
||||
inc a
|
||||
jr z, .syncLoop1
|
||||
vc_hook send_byt2_ret
|
||||
vc_patch FIGHT
|
||||
IF DEF(_RED_VC) || DEF(_BLUE_VC)
|
||||
ld b, 26
|
||||
ELSE
|
||||
ld b, 10
|
||||
ENDC
|
||||
vc_patch_end
|
||||
.syncLoop2
|
||||
call DelayFrame
|
||||
call Serial_ExchangeNybble
|
||||
dec b
|
||||
jr nz, .syncLoop2
|
||||
vc_hook send_dummy
|
||||
vc_patch FIGHT2
|
||||
IF DEF(_RED_VC) || DEF(_BLUE_VC)
|
||||
ld b, 26
|
||||
ELSE
|
||||
ld b, 10
|
||||
ENDC
|
||||
vc_patch_end
|
||||
.syncLoop3
|
||||
call DelayFrame
|
||||
call Serial_SendZeroByte
|
||||
dec b
|
||||
jr nz, .syncLoop3
|
||||
vc_hook send_dummy_end
|
||||
ret
|
||||
|
||||
ExecutePlayerMove:
|
||||
|
|
@ -6661,7 +6677,14 @@ BattleRandom:
|
|||
ld a, [hl]
|
||||
pop bc
|
||||
pop hl
|
||||
vc_hook fight_ret_c
|
||||
vc_patch fight_ret
|
||||
IF DEF(_RED_VC) || DEF(_BLUE_VC)
|
||||
ret
|
||||
ELSE
|
||||
ret c
|
||||
ENDC
|
||||
vc_patch_end
|
||||
|
||||
; if we picked the last seed, we need to recalculate the nine seeds
|
||||
push hl
|
||||
|
|
@ -6726,7 +6749,9 @@ HandleExplodingAnimation:
|
|||
|
||||
PlayMoveAnimation:
|
||||
ld [wAnimationID], a
|
||||
vc_hook_red FPA_conf_Begin
|
||||
call Delay3
|
||||
vc_hook_red FPA_phy_Begin
|
||||
predef_jump MoveAnimation
|
||||
|
||||
InitBattle::
|
||||
|
|
|
|||
|
|
@ -484,6 +484,7 @@ CheckSGB:
|
|||
ldh a, [rJOYP]
|
||||
ldh a, [rJOYP]
|
||||
call Wait7000
|
||||
vc_hook Network_RESET
|
||||
call Wait7000
|
||||
ld a, $30
|
||||
ldh [rJOYP], a
|
||||
|
|
|
|||
|
|
@ -124,18 +124,21 @@ CableClub_DoBattleOrTradeAgain:
|
|||
ld hl, wSerialRandomNumberListBlock
|
||||
ld de, wSerialOtherGameboyRandomNumberListBlock
|
||||
ld bc, $11
|
||||
vc_hook Network17
|
||||
call Serial_ExchangeBytes
|
||||
ld a, SERIAL_NO_DATA_BYTE
|
||||
ld [de], a
|
||||
ld hl, wSerialPlayerDataBlock
|
||||
ld de, wSerialEnemyDataBlock
|
||||
ld bc, $1a8
|
||||
vc_hook Network424
|
||||
call Serial_ExchangeBytes
|
||||
ld a, SERIAL_NO_DATA_BYTE
|
||||
ld [de], a
|
||||
ld hl, wSerialPartyMonsPatchList
|
||||
ld de, wSerialEnemyMonsPatchList
|
||||
ld bc, $c8
|
||||
vc_hook Network200
|
||||
call Serial_ExchangeBytes
|
||||
ld a, (1 << SERIAL) | (1 << TIMER) | (1 << VBLANK)
|
||||
ldh [rIE], a
|
||||
|
|
@ -859,6 +862,7 @@ TradeCenter_Trade:
|
|||
ld de, TradeCompleted
|
||||
call PlaceString
|
||||
predef SaveSAVtoSRAM2
|
||||
vc_hook save_game_end
|
||||
ld c, 50
|
||||
call DelayFrames
|
||||
xor a
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ CableClubNPC::
|
|||
xor a
|
||||
ldh [hSerialReceiveData], a
|
||||
ld a, START_TRANSFER_EXTERNAL_CLOCK
|
||||
vc_hook linkCable_fake_begin
|
||||
ldh [rSC], a
|
||||
ld a, [wLinkTimeoutCounter]
|
||||
dec a
|
||||
|
|
@ -54,6 +55,7 @@ CableClubNPC::
|
|||
ld a, [wCurrentMenuItem]
|
||||
and a
|
||||
jr nz, .choseNo
|
||||
vc_hook linkCable_block_input
|
||||
callfar SaveSAVtoSRAM
|
||||
call WaitForSoundToFinish
|
||||
ld a, SFX_SAVE
|
||||
|
|
@ -66,8 +68,10 @@ CableClubNPC::
|
|||
xor a
|
||||
ld [hl], a
|
||||
ldh [hSerialReceivedNewData], a
|
||||
vc_hook linkCable_fake_end
|
||||
ld [wSerialExchangeNybbleSendData], a
|
||||
call Serial_SyncAndExchangeNybble
|
||||
vc_hook Network_RECHECK
|
||||
ld hl, wUnknownSerialCounter
|
||||
ld a, [hli]
|
||||
inc a
|
||||
|
|
|
|||
|
|
@ -284,9 +284,11 @@ LinkMenu:
|
|||
.choseCancel
|
||||
xor a
|
||||
ld [wMenuJoypadPollCount], a
|
||||
vc_hook Network_STOP
|
||||
call Delay3
|
||||
call CloseLinkConnection
|
||||
ld hl, LinkCanceledText
|
||||
vc_hook Network_END
|
||||
call PrintText
|
||||
ld hl, wd72e
|
||||
res 6, [hl]
|
||||
|
|
|
|||
|
|
@ -37,20 +37,23 @@ LoadSAV0:
|
|||
ld a, $1
|
||||
ld [MBC1SRamBankingMode], a
|
||||
ld [MBC1SRamBank], a
|
||||
ld hl, sPlayerName ; hero name located in SRAM
|
||||
ld bc, sMainDataCheckSum - sPlayerName ; but here checks the full SAV
|
||||
; This vc_hook does not have to be in any particular location.
|
||||
; It is defined here because it refers to the same labels as the two lines below.
|
||||
vc_hook SaveLimit
|
||||
ld hl, sGameData
|
||||
ld bc, sGameDataEnd - sGameData
|
||||
call SAVCheckSum
|
||||
ld c, a
|
||||
ld a, [sMainDataCheckSum] ; SAV's checksum
|
||||
ld a, [sMainDataCheckSum]
|
||||
cp c
|
||||
jp z, .checkSumsMatched
|
||||
|
||||
; If the computed checksum didn't match the saved on, try again.
|
||||
ld hl, sPlayerName
|
||||
ld bc, sMainDataCheckSum - sPlayerName
|
||||
ld hl, sGameData
|
||||
ld bc, sGameDataEnd - sGameData
|
||||
call SAVCheckSum
|
||||
ld c, a
|
||||
ld a, [sMainDataCheckSum] ; SAV's checksum
|
||||
ld a, [sMainDataCheckSum]
|
||||
cp c
|
||||
jp nz, SAVBadCheckSum
|
||||
|
||||
|
|
@ -84,11 +87,11 @@ LoadSAV1:
|
|||
ld a, $1
|
||||
ld [MBC1SRamBankingMode], a
|
||||
ld [MBC1SRamBank], a
|
||||
ld hl, sPlayerName ; hero name located in SRAM
|
||||
ld bc, sMainDataCheckSum - sPlayerName ; but here checks the full SAV
|
||||
ld hl, sGameData
|
||||
ld bc, sGameDataEnd - sGameData
|
||||
call SAVCheckSum
|
||||
ld c, a
|
||||
ld a, [sMainDataCheckSum] ; SAV's checksum
|
||||
ld a, [sMainDataCheckSum]
|
||||
cp c
|
||||
jr nz, SAVBadCheckSum
|
||||
ld hl, sCurBoxData
|
||||
|
|
@ -104,11 +107,11 @@ LoadSAV2:
|
|||
ld a, $1
|
||||
ld [MBC1SRamBankingMode], a
|
||||
ld [MBC1SRamBank], a
|
||||
ld hl, sPlayerName ; hero name located in SRAM
|
||||
ld bc, sMainDataCheckSum - sPlayerName ; but here checks the full SAV
|
||||
ld hl, sGameData
|
||||
ld bc, sGameDataEnd - sGameData
|
||||
call SAVCheckSum
|
||||
ld c, a
|
||||
ld a, [sMainDataCheckSum] ; SAV's checksum
|
||||
ld a, [sMainDataCheckSum]
|
||||
cp c
|
||||
jp nz, SAVBadCheckSum
|
||||
ld hl, sPartyData
|
||||
|
|
@ -219,8 +222,8 @@ SaveSAVtoSRAM0:
|
|||
call CopyData
|
||||
ldh a, [hTileAnimations]
|
||||
ld [sTileAnimations], a
|
||||
ld hl, sPlayerName
|
||||
ld bc, sMainDataCheckSum - sPlayerName
|
||||
ld hl, sGameData
|
||||
ld bc, sGameDataEnd - sGameData
|
||||
call SAVCheckSum
|
||||
ld [sMainDataCheckSum], a
|
||||
xor a
|
||||
|
|
@ -239,8 +242,8 @@ SaveSAVtoSRAM1:
|
|||
ld de, sCurBoxData
|
||||
ld bc, wBoxDataEnd - wBoxDataStart
|
||||
call CopyData
|
||||
ld hl, sPlayerName
|
||||
ld bc, sMainDataCheckSum - sPlayerName
|
||||
ld hl, sGameData
|
||||
ld bc, sGameDataEnd - sGameData
|
||||
call SAVCheckSum
|
||||
ld [sMainDataCheckSum], a
|
||||
xor a
|
||||
|
|
@ -262,8 +265,8 @@ SaveSAVtoSRAM2:
|
|||
ld de, sMainData
|
||||
ld bc, wPokedexSeenEnd - wPokedexOwned
|
||||
call CopyData
|
||||
ld hl, sPlayerName
|
||||
ld bc, sMainDataCheckSum - sPlayerName
|
||||
ld hl, sGameData
|
||||
ld bc, sGameDataEnd - sGameData
|
||||
call SAVCheckSum
|
||||
ld [sMainDataCheckSum], a
|
||||
xor a
|
||||
|
|
@ -612,8 +615,8 @@ SAVCheckRandomID:
|
|||
ld a, [sPlayerName]
|
||||
and a
|
||||
jr z, .next
|
||||
ld hl, sPlayerName
|
||||
ld bc, sMainDataCheckSum - sPlayerName
|
||||
ld hl, sGameData
|
||||
ld bc, sGameDataEnd - sGameData
|
||||
call SAVCheckSum
|
||||
ld c, a
|
||||
ld a, [sMainDataCheckSum]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue