Harmonize engine/{battle, battle_anims, events, games} with pokegold

This commit is contained in:
Rangi 2020-06-16 19:32:36 -04:00
parent c552390a15
commit f76dabedcc
13 changed files with 97 additions and 85 deletions

View File

@ -55,7 +55,7 @@ DoBattleTransition:
ldh [hLYOverrideEnd], a
ldh [hSCY], a
ld a, 1 ; unnecessary bankswitch?
ld a, $1 ; unnecessary bankswitch?
ldh [rSVBK], a
pop af
ldh [hVBlank], a
@ -313,7 +313,6 @@ StartTrainerBattle_SetUpForWavyOutro:
farcall Function5602
ld a, BANK(wLYOverrides)
ldh [rSVBK], a
call StartTrainerBattle_NextScene
ld a, LOW(rSCX)
@ -349,7 +348,7 @@ StartTrainerBattle_SineWave:
ld [hl], a
ld a, wLYOverridesEnd - wLYOverrides
ld bc, wLYOverrides
ld e, $0
ld e, 0
.loop
push af
@ -360,7 +359,7 @@ StartTrainerBattle_SineWave:
inc bc
pop de
ld a, e
add $2
add 2
ld e, a
pop af
dec a
@ -391,7 +390,7 @@ endr
jr z, .end
ld [wcf65], a
call .load
ld a, $1
ld a, 1
ldh [hBGMapMode], a
call DelayFrame
call DelayFrame
@ -400,7 +399,7 @@ endr
ret
.end
ld a, $1
ld a, 1
ldh [hBGMapMode], a
call DelayFrame
call DelayFrame
@ -516,7 +515,7 @@ StartTrainerBattle_SetUpForRandomScatterOutro:
call StartTrainerBattle_NextScene
ld a, $10
ld [wcf64], a
ld a, $1
ld a, 1
ldh [hBGMapMode], a
ret
@ -585,35 +584,36 @@ StartTrainerBattle_LoadPokeBallGraphics:
xor a
ldh [hBGMapMode], a
hlcoord 0, 0, wAttrmap
ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
inc b
inc c
jr .enter_loop_midway
.loop
.pal_loop
; set all pals to 7
ld a, [hl]
or %00000111
or PAL_BG_TEXT
ld [hli], a
.enter_loop_midway
dec c
jr nz, .loop
jr nz, .pal_loop
dec b
jr nz, .loop
jr nz, .pal_loop
call .loadpokeballgfx
hlcoord 2, 1
ld b, SCREEN_WIDTH - 4
.loop2
.tile_loop
push hl
ld c, 2
.loop3
.row_loop
push hl
ld a, [de]
inc de
.loop4
.col_loop
; Loading is done bit by bit
and a
jr z, .done
@ -622,7 +622,7 @@ StartTrainerBattle_LoadPokeBallGraphics:
ld [hl], BATTLETRANSITION_SQUARE
.no_load
inc hl
jr .loop4
jr .col_loop
.done
pop hl
@ -631,7 +631,7 @@ StartTrainerBattle_LoadPokeBallGraphics:
add hl, bc
pop bc
dec c
jr nz, .loop3
jr nz, .row_loop
pop hl
push bc
@ -639,12 +639,12 @@ StartTrainerBattle_LoadPokeBallGraphics:
add hl, bc
pop bc
dec b
jr nz, .loop2
jr nz, .tile_loop
ldh a, [hCGB]
and a
jr nz, .cgb
ld a, $1
ld a, 1
ldh [hBGMapMode], a
call DelayFrame
call DelayFrame
@ -673,7 +673,7 @@ StartTrainerBattle_LoadPokeBallGraphics:
call CopyBytes
pop af
ldh [rSVBK], a
ld a, $1
ld a, 1
ldh [hCGBPalUpdate], a
call DelayFrame
call BattleStart_CopyTilemapAtOnce
@ -827,7 +827,7 @@ ENDM
ret
Unreferenced_Function8c7c9:
ld a, $1
ld a, 1
ldh [hBGMapMode], a
call WaitBGMap
xor a

View File

@ -1963,14 +1963,14 @@ RestoreHP:
ld b, a
ld a, [hl]
sbc b
jr c, .asm_3cd2d
jr c, .overflow
ld a, b
ld [hli], a
ld [wBuffer6], a
ld a, c
ld [hl], a
ld [wBuffer5], a
.asm_3cd2d
.overflow
call SwitchTurnCore
call UpdateHPBarBattleHuds
@ -5958,7 +5958,7 @@ LoadEnemyMon:
jp nz, InitEnemyMon
; and also not in a BattleTower-Battle
ld a, [wInBattleTowerBattle] ; ????
ld a, [wInBattleTowerBattle]
bit 0, a
jp nz, InitEnemyMon
@ -7764,7 +7764,6 @@ GoodComeBackText:
text_end
Unreferenced_TextJump_ComeBack:
; this function doesn't seem to be used
ld hl, ComeBackText
ret
@ -8127,8 +8126,8 @@ InitEnemyTrainer:
jr nz, .ok
xor a
ld [wOTPartyMon1Item], a
.ok
.ok
ld de, vTiles2
callfar GetTrainerPic
xor a
@ -8374,21 +8373,21 @@ DisplayLinkBattleResult:
ld a, [wBattleResult]
and $f
cp LOSE
jr c, .victory ; WIN
jr z, .loss ; LOSE
jr c, .win ; WIN
jr z, .lose ; LOSE
; DRAW
farcall StubbedTrainerRankings_ColosseumDraws
ld de, .Draw
jr .store_result
.victory
.win
farcall StubbedTrainerRankings_ColosseumWins
ld de, .Win
ld de, .YouWin
jr .store_result
.loss
.lose
farcall StubbedTrainerRankings_ColosseumLosses
ld de, .Lose
ld de, .YouLose
jr .store_result
.store_result
@ -8418,23 +8417,23 @@ DisplayLinkBattleResult:
call ClearTilemap
ret
.Win:
.YouWin:
db "YOU WIN@"
.Lose:
.YouLose:
db "YOU LOSE@"
.Draw:
db " DRAW@"
.Mobile_InvalidBattle:
hlcoord 6, 8
ld de, .Invalid
ld de, .InvalidBattle
call PlaceString
ld c, 200
call DelayFrames
call ClearTilemap
ret
.Invalid:
.InvalidBattle:
db "INVALID BATTLE@"
IsMobileBattle2:
@ -9013,7 +9012,7 @@ CopyBackpic:
ld de, vTiles2 tile $31
ldh a, [hROMBank]
ld b, a
ld c, $31
ld c, 7 * 7
call Get2bpp
pop af
ldh [rSVBK], a

View File

@ -5079,7 +5079,7 @@ BattleCommand_ForceSwitch:
call UpdateBattleMonInParty
xor a
ld [wNumHits], a
inc a
inc a ; TRUE
ld [wForcedSwitch], a
call SetBattleDraw
ld a, [wPlayerMoveStructAnimation]
@ -5172,7 +5172,7 @@ BattleCommand_ForceSwitch:
call UpdateBattleMonInParty
xor a
ld [wNumHits], a
inc a
inc a ; TRUE
ld [wForcedSwitch], a
call SetBattleDraw
ld a, [wEnemyMoveStructAnimation]

View File

@ -380,8 +380,7 @@ CopyTrainerName:
pop de
ret
Function39990:
; This function is useless.
Unreferenced_Function39990:
ld de, wStringBuffer1
push de
ld bc, NAME_LENGTH

View File

@ -41,7 +41,7 @@ _PlayBattleAnim:
pop af
ldh [hVBlank], a
ld a, $1
ld a, 1
ldh [hBGMapMode], a
call BattleAnimDelayFrame
@ -155,9 +155,10 @@ BattleAnimRestoreHuds:
ld a, BANK(wCurBattleMon) ; aka BANK(wTempMon), BANK(wPartyMon1), and several others
ldh [rSVBK], a
; this block should just be "call UpdateBattleHuds"
ld hl, UpdateBattleHuds
ld a, BANK(UpdatePlayerHUD)
rst FarCall ; Why not "call UpdateBattleHuds"?
rst FarCall
pop af
ldh [rSVBK], a
@ -891,32 +892,34 @@ BattleAnimCmd_Transform:
push af
ld a, BANK(wCurPartySpecies)
ldh [rSVBK], a
ld a, [wCurPartySpecies] ; CurPartySpecies
ld a, [wCurPartySpecies]
push af
ldh a, [hBattleTurn]
and a
jr z, .player
ld a, [wTempBattleMonSpecies] ; TempBattleMonSpecies
ld [wCurPartySpecies], a ; CurPartySpecies
ld hl, wBattleMonDVs ; BattleMonDVs
ld a, [wTempBattleMonSpecies]
ld [wCurPartySpecies], a
ld hl, wBattleMonDVs
predef GetUnownLetter
ld de, vTiles0 tile $00
predef GetMonFrontpic
jr .done
.player
ld a, [wTempEnemyMonSpecies] ; TempEnemyMonSpecies
ld [wCurPartySpecies], a ; CurPartySpecies
ld hl, wEnemyMonDVs ; EnemyMonDVs
ld a, [wTempEnemyMonSpecies]
ld [wCurPartySpecies], a
ld hl, wEnemyMonDVs
predef GetUnownLetter
ld de, vTiles0 tile $00
predef GetMonBackpic
.done
pop af
ld [wCurPartySpecies], a ; CurPartySpecies
ld [wCurPartySpecies], a
pop af
ldh [rSVBK], a
ret
@ -945,11 +948,11 @@ BattleAnimCmd_RaiseSub:
push af
ld a, 1 ; unnecessary bankswitch?
ldh [rSVBK], a
xor a ; sScratch
xor a ; BANK(sScratch)
call GetSRAMBank
GetSubstitutePic: ; used only for BANK(GetSubstitutePic)
ld hl, sScratch
ld bc, (7 * 7) tiles
.loop
@ -1004,6 +1007,7 @@ GetSubstitutePic: ; used only for BANK(GetSubstitutePic)
.done
call CloseSRAM
pop af
ldh [rSVBK], a
ret
@ -1019,11 +1023,13 @@ BattleAnimCmd_MinimizeOpp:
push af
ld a, 1 ; unnecessary bankswitch?
ldh [rSVBK], a
xor a ; sScratch
xor a ; BANK(sScratch)
call GetSRAMBank
call GetMinimizePic
call Request2bpp
call CloseSRAM
pop af
ldh [rSVBK], a
ret
@ -1073,12 +1079,14 @@ BattleAnimCmd_Minimize:
push af
ld a, 1 ; unnecessary bankswitch?
ldh [rSVBK], a
xor a ; sScratch
xor a ; BANK(sScratch)
call GetSRAMBank
call GetMinimizePic
ld hl, vTiles0 tile $00
call Request2bpp
call CloseSRAM
pop af
ldh [rSVBK], a
ret
@ -1089,7 +1097,7 @@ BattleAnimCmd_DropSub:
ld a, BANK(wCurPartySpecies)
ldh [rSVBK], a
ld a, [wCurPartySpecies] ; CurPartySpecies
ld a, [wCurPartySpecies]
push af
ldh a, [hBattleTurn]
and a
@ -1103,7 +1111,8 @@ BattleAnimCmd_DropSub:
.done
pop af
ld [wCurPartySpecies], a ; CurPartySpecies
ld [wCurPartySpecies], a
pop af
ldh [rSVBK], a
ret
@ -1113,11 +1122,12 @@ BattleAnimCmd_BeatUp:
push af
ld a, BANK(wCurPartySpecies)
ldh [rSVBK], a
ld a, [wCurPartySpecies] ; CurPartySpecies
ld a, [wCurPartySpecies]
push af
ld a, [wBattleAnimParam]
ld [wCurPartySpecies], a ; CurPartySpecies
ld [wCurPartySpecies], a
ldh a, [hBattleTurn]
and a
@ -1137,9 +1147,10 @@ BattleAnimCmd_BeatUp:
.done
pop af
ld [wCurPartySpecies], a ; CurPartySpecies
ld [wCurPartySpecies], a
ld b, SCGB_BATTLE_COLORS
call GetSGBLayout
pop af
ldh [rSVBK], a
ret
@ -1176,7 +1187,7 @@ BattleAnimCmd_Sound:
ld [wSFXDuration], a
call .GetCryTrack
maskbits NUM_NOISE_CHANS
ld [wCryTracks], a ; CryTracks
ld [wCryTracks], a
ld e, a
ld d, 0
@ -1220,7 +1231,7 @@ endr
ldh a, [rSVBK]
push af
ld a, BANK(wEnemyMon) ; wBattleMon is in WRAM0, but EnemyMon is in WRAMX
ld a, BANK(wEnemyMon) ; wBattleMon is in WRAM0, but wEnemyMon is in WRAMX
ldh [rSVBK], a
ldh a, [hBattleTurn]
@ -1263,14 +1274,14 @@ endr
ld a, [hli]
ld c, a
ld b, [hl]
ld hl, wCryLength ; CryLength
ld hl, wCryLength
ld a, [hli]
ld h, [hl]
ld l, a
add hl, bc
ld a, l
ld [wCryLength], a ; CryLength
ld [wCryLength], a
ld a, h
ld [wCryLength + 1], a
ld a, 1
@ -1347,7 +1358,7 @@ ClearBattleAnims::
ld hl, wLYOverrides
ld bc, wBattleAnimEnd - wLYOverrides
.loop
ld [hl], $0
ld [hl], 0
inc hl
dec bc
ld a, c

View File

@ -2839,7 +2839,8 @@ BGEffect_FillLYOverridesBackup:
ret
BGEffect_DisplaceLYOverridesBackup:
; e = a; d = [hLYOverrideEnd] - [hLYOverrideStart] - a
; e = a
; d = [hLYOverrideEnd] - [hLYOverrideStart] - a
push af
ld e, a
ldh a, [hLYOverrideStart]

View File

@ -1,9 +1,9 @@
; PrintDayCareText.TextTable indexes
const_def
const DAYCARETEXT_MAN_INTRO
const DAYCARETEXT_MAN_EGG
const DAYCARETEXT_MAN_ODD_EGG
const DAYCARETEXT_LADY_INTRO
const DAYCARETEXT_LADY_EGG
const DAYCARETEXT_LADY_ODD_EGG
const DAYCARETEXT_WHICH_ONE
const DAYCARETEXT_DEPOSIT
const DAYCARETEXT_CANT_BREED_EGG

View File

@ -204,7 +204,7 @@ Cut_SpawnAnimateLeaves:
ret
Cut_StartWaiting:
ld a, $1
ld a, 1
ldh [hBGMapMode], a
; Cut_WaitAnimSFX
ld hl, wJumptableIndex
@ -445,8 +445,8 @@ FlyFunction_FrameTimer:
sla a
add 8 * 8 ; gives a number in [$40, $50, $60, $70]
ld d, a
ld e, $0
ld a, SPRITE_ANIM_INDEX_FLY_LEAF ; fly land
ld e, 0
ld a, SPRITE_ANIM_INDEX_FLY_LEAF
call InitSpriteAnimStruct
ld hl, SPRITEANIMSTRUCT_TILE_ID
add hl, bc

View File

@ -278,7 +278,7 @@ HOF_SlideBackpic:
ldh a, [hSCX]
cp $70
ret z
add $4
add 4
ldh [hSCX], a
call DelayFrame
jr .backpicloop

View File

@ -103,6 +103,7 @@ CheckForLuckyNumberWinners:
ld a, [wScriptVar]
and a
ret z ; found nothing
farcall StubbedTrainerRankings_LuckyNumberShow
ld a, [wTempByteValue]
and a

View File

@ -78,6 +78,7 @@ MagnetTrain:
ldh [hSCX], a
xor a
ldh [hBGMapMode], a
pop af
ldh [rSVBK], a
ret
@ -127,7 +128,7 @@ MagnetTrain_LoadGFX_PlayMusic:
ldh [hSCX], a
ldh [hSCY], a
; Load the player sprite
; Load the player sprite's standing frames
ldh a, [rSVBK]
push af
ld a, BANK(wPlayerGender)
@ -139,7 +140,7 @@ MagnetTrain_LoadGFX_PlayMusic:
ld c, 4
call Request2bpp
; Load the trainer walking frame
; Load the player sprite's walking frames
ld hl, 12 tiles
add hl, de
ld d, h

View File

@ -349,7 +349,7 @@ SurfFunction:
.TrySurf:
ld de, ENGINE_FOGBADGE
call CheckBadge
jr c, .asm_c956
jr c, .nofogbadge
ld hl, wBikeFlags
bit BIKEFLAGS_ALWAYS_ON_BIKE_F, [hl]
jr nz, .cannotsurf
@ -368,7 +368,7 @@ SurfFunction:
jr c, .cannotsurf
ld a, $1
ret
.asm_c956
.nofogbadge
ld a, $80
ret
.alreadyfail
@ -407,7 +407,7 @@ UsedSurfScript:
waitbutton
closetext
callasm .empty_fn ; empty function
callasm .stubbed_fn
readmem wBuffer2
writevar VAR_MOVEMENT
@ -419,7 +419,7 @@ UsedSurfScript:
applymovement PLAYER, wMovementBuffer
end
.empty_fn
.stubbed_fn
farcall StubbedTrainerRankings_Surf
ret
@ -1369,7 +1369,7 @@ RockSmashScript:
special WaitSFX
playsound SFX_STRENGTH
earthquake 84
applymovementlasttalked MovementData_0xcf55
applymovementlasttalked MovementData_RockSmash
disappear -2
callasm RockMonEncounter
@ -1381,7 +1381,7 @@ RockSmashScript:
.done
end
MovementData_0xcf55:
MovementData_RockSmash:
rock_smash 10
step_end
@ -1591,11 +1591,11 @@ Script_FishCastRod:
loademote EMOTE_ROD
callasm LoadFishingGFX
loademote EMOTE_SHOCK
applymovement PLAYER, MovementData_0xd093
applymovement PLAYER, MovementData_CastRod
pause 40
end
MovementData_0xd093:
MovementData_CastRod:
fish_cast_rod
step_end
@ -1787,10 +1787,10 @@ AskCutScript:
opentext
writetext AskCutText
yesorno
iffalse .script_d1b8
iffalse .declined
callasm .CheckMap
iftrue Script_Cut
.script_d1b8
.declined
closetext
end

View File

@ -11,7 +11,7 @@ _DummyGame:
ld b, SCGB_DIPLOMA
call GetSGBLayout
callfar ClearSpriteAnims
ld hl, LZ_e2221
ld hl, DummyGameLZ
ld de, vTiles2 tile $00
call Decompress
ld hl, Unknown_e00ed
@ -586,5 +586,5 @@ DummyGame_InterpretJoypad_AnimateCursor:
ld [hl], a
ret
LZ_e2221:
DummyGameLZ:
INCBIN "gfx/dummy_game/dummy_game.2bpp.lz"