Remove unnecessary DMG and SGB checking (#7)

This commit is contained in:
xCrystal
2023-07-26 14:29:16 +02:00
parent 15f452ff26
commit acd022d765
30 changed files with 10 additions and 713 deletions

View File

@@ -176,10 +176,6 @@ BattleAnimRestoreHuds:
ret
BattleAnimRequestPals:
ldh a, [hCGB]
and a
ret z
ldh a, [rBGP]
ld b, a
ld a, [wBGP]
@@ -643,12 +639,7 @@ BattleAnimCmd_OBP1:
ret
BattleAnimCmd_ResetObp0:
ldh a, [hSGB]
and a
ld a, $e0
jr z, .not_sgb
ld a, $f0
.not_sgb
ld [wOBP0], a
ret
@@ -1336,23 +1327,6 @@ PlayHitSound:
ret
BattleAnimAssignPals:
ldh a, [hCGB]
and a
jr nz, .cgb
ldh a, [hSGB]
and a
ld a, %11100000
jr z, .sgb
ld a, %11110000
.sgb
ld [wOBP0], a
ld a, %11100100
ld [wBGP], a
ld [wOBP1], a
ret
.cgb
ld a, %11100100
ld [wBGP], a
ld [wOBP0], a
@@ -1405,9 +1379,6 @@ BattleAnim_RevertPals:
BattleAnim_SetBGPals:
ldh [rBGP], a
ldh a, [hCGB]
and a
ret z
ldh a, [rSVBK]
push af
ld a, BANK(wBGPals1)
@@ -1432,9 +1403,6 @@ BattleAnim_SetBGPals:
BattleAnim_SetOBPals:
ldh [rOBP0], a
ldh a, [hCGB]
and a
ret z
ldh a, [rSVBK]
push af
ld a, BANK(wOBPals1)

View File

@@ -281,14 +281,7 @@ BattleBGEffect_AlternateHues:
db -2
BattleBGEffect_CycleOBPalsGrayAndYellow:
call BattleBGEffects_CheckSGB
jr nz, .sgb
ld de, .PalsCGB
jr .okay
.sgb
ld de, .PalsSGB
.okay
call BattleBGEffect_GetNthDMGPal
ld [wOBP0], a
ret
@@ -304,14 +297,7 @@ BattleBGEffect_CycleOBPalsGrayAndYellow:
db -2
BattleBGEffect_CycleMidOBPalsGrayAndYellow:
call BattleBGEffects_CheckSGB
jr nz, .sgb
ld de, .PalsCGB
jr .okay
.sgb
ld de, .PalsSGB
.okay
call BattleBGEffect_GetNthDMGPal
ld [wOBP0], a
ret
@@ -1955,90 +1941,6 @@ BattleBGEffect_BetaSendOutMon2: ; unused
ret
BattleBGEffect_FadeMonsToBlackRepeating:
ldh a, [hCGB]
and a
jr nz, .cgb
call BattleBGEffects_AnonJumptable
.anon_dw
dw .zero
dw .one
dw .two
.zero
call BattleBGEffects_IncAnonJumptableIndex
ld a, $e4
call BattleBGEffects_SetLYOverrides
ld a, LOW(rBGP)
ldh [hLCDCPointer], a
xor a
ldh [hLYOverrideStart], a
ld a, $60
ldh [hLYOverrideEnd], a
ret
.one
ld hl, BG_EFFECT_STRUCT_PARAM
add hl, bc
ld a, [hl]
inc [hl]
ld e, a
and $7
ret nz
ld a, e
and $18
sla a
swap a
sla a
ld e, a
ld d, 0
push bc
call BGEffect_CheckBattleTurn
jr nz, .player
ld hl, .CGB_DMGEnemyData
add hl, de
ld a, [hli]
ld [wOBP1], a
ld d, a
ld e, [hl]
lb bc, $2f, $30
jr .okay
.player
ld hl, .DMG_PlayerData
add hl, de
ld d, [hl]
inc hl
ld a, [hl]
ld [wOBP1], a
ld e, a
lb bc, $37, $28
.okay
call .DMG_LYOverrideLoads
pop bc
ret
.two
call BattleBGEffects_ResetVideoHRAM
ld a, $e4
ld [wBGP], a
ld [wOBP1], a
ret
.DMG_LYOverrideLoads:
ld hl, wLYOverridesBackup
.loop1
ld [hl], d
inc hl
dec b
jr nz, .loop1
.loop2
ld [hl], e
inc hl
dec c
jr nz, .loop2
ret
.cgb
ld de, .Jumptable
call BatttleBGEffects_GetNamedJumptablePointer
jp hl
@@ -2397,71 +2299,6 @@ BattleBGEffect_GetNthDMGPal:
BGEffect_RapidCyclePals:
; Last index in DE: $fe signals a loop, $ff signals end
ldh a, [hCGB]
and a
jr nz, .cgb
push de
ld de, .Jumptable_DMG
call BatttleBGEffects_GetNamedJumptablePointer
pop de
jp hl
.Jumptable_DMG:
dw .zero_dmg
dw .one_dmg
dw .two_dmg
.zero_dmg
call BattleBGEffects_IncAnonJumptableIndex
ld a, $e4
call BattleBGEffects_SetLYOverrides
ld a, $47
call BattleBGEffect_SetLCDStatCustoms1
ldh a, [hLYOverrideEnd]
inc a
ldh [hLYOverrideEnd], a
ld hl, BG_EFFECT_STRUCT_PARAM
add hl, bc
ld a, [hl]
ld [hl], $0
ld hl, BG_EFFECT_STRUCT_BATTLE_TURN
add hl, bc
ld [hl], a
ret
.one_dmg
ld hl, BG_EFFECT_STRUCT_BATTLE_TURN
add hl, bc
ld a, [hl]
and $f
jr z, .okay_1_dmg
dec [hl]
ret
.okay_1_dmg
ld a, [hl]
swap a
or [hl]
ld [hl], a
call BattleBGEffect_GetFirstDMGPal
jr c, .okay_2_dmg
call BGEffect_FillLYOverridesBackup
ret
.okay_2_dmg
ld hl, BG_EFFECT_STRUCT_PARAM
add hl, bc
dec [hl]
ret
.two_dmg
call BattleBGEffects_ResetVideoHRAM
ld a, %11100100
ldh [rBGP], a
call EndBattleBGEffect
ret
.cgb
push de
ld de, .Jumptable_CGB
call BatttleBGEffects_GetNamedJumptablePointer
@@ -2919,11 +2756,6 @@ BGEffect_CheckFlyDigStatus:
and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND
ret
BattleBGEffects_CheckSGB:
ldh a, [hSGB]
and a
ret
BattleBGEffects_Sine:
ld e, a
callfar BattleAnim_Sine_e

View File

@@ -3399,15 +3399,7 @@ BattleAnimFunction_SkyAttack:
srl a
ld e, a
ld d, 0
ldh a, [hSGB]
and a
jr nz, .sgb
ld hl, .GBCPals
jr .got_pals
.sgb
ld hl, .SGBPals
.got_pals
add hl, de
ld a, [hl]
ld hl, BATTLEANIMSTRUCT_VAR1