Use labels instead of constants for HRAM

Use explicit ldh instruction to access HRAM locations, don't rely on optimizing ld
This commit is contained in:
Rangi
2018-08-25 14:28:22 -04:00
parent 376c64468b
commit eb1e3636bb
243 changed files with 4706 additions and 4661 deletions

View File

@@ -61,7 +61,7 @@ $(crystal11_obj): RGBASMFLAGS = -D _CRYSTAL -D _CRYSTAL11
# It doesn't look like $(shell) can be deferred so there might not be a better way. # It doesn't look like $(shell) can be deferred so there might not be a better way.
define DEP define DEP
$1: $2 $$(shell tools/scan_includes $2) $1: $2 $$(shell tools/scan_includes $2)
$$(RGBASM) $$(RGBASMFLAGS) -o $$@ $$< $$(RGBASM) $$(RGBASMFLAGS) -L -o $$@ $$<
endef endef
# Build tools when building the rom. # Build tools when building the rom.

View File

@@ -202,10 +202,10 @@ _UpdateSound::
call FadeMusic call FadeMusic
; write volume to hardware register ; write volume to hardware register
ld a, [wVolume] ld a, [wVolume]
ld [rNR50], a ldh [rNR50], a
; write SO on/off to hardware register ; write SO on/off to hardware register
ld a, [wSoundOutput] ld a, [wSoundOutput]
ld [rNR51], a ldh [rNR51], a
ret ret
UpdateChannels: UpdateChannels:
@@ -244,7 +244,7 @@ UpdateChannels:
jr z, .asm_e8159 jr z, .asm_e8159
; ;
ld a, [wSoundInput] ld a, [wSoundInput]
ld [rNR10], a ldh [rNR10], a
.asm_e8159 .asm_e8159
bit NOTE_REST, [hl] ; rest bit NOTE_REST, [hl] ; rest
jr nz, .ch1rest jr nz, .ch1rest
@@ -258,35 +258,35 @@ UpdateChannels:
.frequency_override .frequency_override
ld a, [wCurTrackFrequency] ld a, [wCurTrackFrequency]
ld [rNR13], a ldh [rNR13], a
ld a, [wCurTrackFrequency + 1] ld a, [wCurTrackFrequency + 1]
ld [rNR14], a ldh [rNR14], a
.check_duty_override .check_duty_override
bit NOTE_DUTY_OVERRIDE, [hl] bit NOTE_DUTY_OVERRIDE, [hl]
ret z ret z
ld a, [wCurTrackDuty] ld a, [wCurTrackDuty]
ld d, a ld d, a
ld a, [rNR11] ldh a, [rNR11]
and $3f ; sound length and $3f ; sound length
or d or d
ld [rNR11], a ldh [rNR11], a
ret ret
.asm_e8184 .asm_e8184
ld a, [wCurTrackDuty] ld a, [wCurTrackDuty]
ld d, a ld d, a
ld a, [rNR11] ldh a, [rNR11]
and $3f ; sound length and $3f ; sound length
or d or d
ld [rNR11], a ldh [rNR11], a
ld a, [wCurTrackFrequency] ld a, [wCurTrackFrequency]
ld [rNR13], a ldh [rNR13], a
ret ret
.ch1rest .ch1rest
ld a, [rNR52] ldh a, [rNR52]
and %10001110 ; ch1 off and %10001110 ; ch1 off
ld [rNR52], a ldh [rNR52], a
ld hl, rNR10 ld hl, rNR10
call ClearChannel call ClearChannel
ret ret
@@ -295,14 +295,14 @@ UpdateChannels:
ld hl, wCurTrackDuty ld hl, wCurTrackDuty
ld a, $3f ; sound length ld a, $3f ; sound length
or [hl] or [hl]
ld [rNR11], a ldh [rNR11], a
ld a, [wCurTrackIntensity] ld a, [wCurTrackIntensity]
ld [rNR12], a ldh [rNR12], a
ld a, [wCurTrackFrequency] ld a, [wCurTrackFrequency]
ld [rNR13], a ldh [rNR13], a
ld a, [wCurTrackFrequency + 1] ld a, [wCurTrackFrequency + 1]
or $80 or $80
ld [rNR14], a ldh [rNR14], a
ret ret
.Channel2: .Channel2:
@@ -319,34 +319,34 @@ UpdateChannels:
ret z ret z
ld a, [wCurTrackDuty] ld a, [wCurTrackDuty]
ld d, a ld d, a
ld a, [rNR21] ldh a, [rNR21]
and $3f ; sound length and $3f ; sound length
or d or d
ld [rNR21], a ldh [rNR21], a
ret ret
.asm_e81db ; unused .asm_e81db ; unused
ld a, [wCurTrackFrequency] ld a, [wCurTrackFrequency]
ld [rNR23], a ldh [rNR23], a
ld a, [wCurTrackFrequency + 1] ld a, [wCurTrackFrequency + 1]
ld [rNR24], a ldh [rNR24], a
ret ret
.asm_e81e6 .asm_e81e6
ld a, [wCurTrackDuty] ld a, [wCurTrackDuty]
ld d, a ld d, a
ld a, [rNR21] ldh a, [rNR21]
and $3f ; sound length and $3f ; sound length
or d or d
ld [rNR21], a ldh [rNR21], a
ld a, [wCurTrackFrequency] ld a, [wCurTrackFrequency]
ld [rNR23], a ldh [rNR23], a
ret ret
.ch2rest .ch2rest
ld a, [rNR52] ldh a, [rNR52]
and %10001101 ; ch2 off and %10001101 ; ch2 off
ld [rNR52], a ldh [rNR52], a
ld hl, rNR20 ld hl, rNR20
call ClearChannel call ClearChannel
ret ret
@@ -355,14 +355,14 @@ UpdateChannels:
ld hl, wCurTrackDuty ld hl, wCurTrackDuty
ld a, $3f ; sound length ld a, $3f ; sound length
or [hl] or [hl]
ld [rNR21], a ldh [rNR21], a
ld a, [wCurTrackIntensity] ld a, [wCurTrackIntensity]
ld [rNR22], a ldh [rNR22], a
ld a, [wCurTrackFrequency] ld a, [wCurTrackFrequency]
ld [rNR23], a ldh [rNR23], a
ld a, [wCurTrackFrequency + 1] ld a, [wCurTrackFrequency + 1]
or $80 ; initial (restart) or $80 ; initial (restart)
ld [rNR24], a ldh [rNR24], a
ret ret
.Channel3: .Channel3:
@@ -379,37 +379,37 @@ UpdateChannels:
.asm_e822f ; unused .asm_e822f ; unused
ld a, [wCurTrackFrequency] ld a, [wCurTrackFrequency]
ld [rNR33], a ldh [rNR33], a
ld a, [wCurTrackFrequency + 1] ld a, [wCurTrackFrequency + 1]
ld [rNR34], a ldh [rNR34], a
ret ret
.asm_e823a .asm_e823a
ld a, [wCurTrackFrequency] ld a, [wCurTrackFrequency]
ld [rNR33], a ldh [rNR33], a
ret ret
.ch3rest .ch3rest
ld a, [rNR52] ldh a, [rNR52]
and %10001011 ; ch3 off and %10001011 ; ch3 off
ld [rNR52], a ldh [rNR52], a
ld hl, rNR30 ld hl, rNR30
call ClearChannel call ClearChannel
ret ret
.asm_e824d .asm_e824d
ld a, $3f ; sound length ld a, $3f ; sound length
ld [rNR31], a ldh [rNR31], a
xor a xor a
ld [rNR30], a ldh [rNR30], a
call .asm_e8268 call .asm_e8268
ld a, $80 ld a, $80
ld [rNR30], a ldh [rNR30], a
ld a, [wCurTrackFrequency] ld a, [wCurTrackFrequency]
ld [rNR33], a ldh [rNR33], a
ld a, [wCurTrackFrequency + 1] ld a, [wCurTrackFrequency + 1]
or $80 or $80
ld [rNR34], a ldh [rNR34], a
ret ret
.asm_e8268 .asm_e8268
@@ -428,42 +428,42 @@ endr
add hl, de add hl, de
; load wavepattern into rWave_0-rWave_f ; load wavepattern into rWave_0-rWave_f
ld a, [hli] ld a, [hli]
ld [rWave_0], a ldh [rWave_0], a
ld a, [hli] ld a, [hli]
ld [rWave_1], a ldh [rWave_1], a
ld a, [hli] ld a, [hli]
ld [rWave_2], a ldh [rWave_2], a
ld a, [hli] ld a, [hli]
ld [rWave_3], a ldh [rWave_3], a
ld a, [hli] ld a, [hli]
ld [rWave_4], a ldh [rWave_4], a
ld a, [hli] ld a, [hli]
ld [rWave_5], a ldh [rWave_5], a
ld a, [hli] ld a, [hli]
ld [rWave_6], a ldh [rWave_6], a
ld a, [hli] ld a, [hli]
ld [rWave_7], a ldh [rWave_7], a
ld a, [hli] ld a, [hli]
ld [rWave_8], a ldh [rWave_8], a
ld a, [hli] ld a, [hli]
ld [rWave_9], a ldh [rWave_9], a
ld a, [hli] ld a, [hli]
ld [rWave_a], a ldh [rWave_a], a
ld a, [hli] ld a, [hli]
ld [rWave_b], a ldh [rWave_b], a
ld a, [hli] ld a, [hli]
ld [rWave_c], a ldh [rWave_c], a
ld a, [hli] ld a, [hli]
ld [rWave_d], a ldh [rWave_d], a
ld a, [hli] ld a, [hli]
ld [rWave_e], a ldh [rWave_e], a
ld a, [hli] ld a, [hli]
ld [rWave_f], a ldh [rWave_f], a
pop hl pop hl
ld a, [wCurTrackIntensity] ld a, [wCurTrackIntensity]
and $f0 and $f0
sla a sla a
ld [rNR32], a ldh [rNR32], a
ret ret
.Channel4: .Channel4:
@@ -478,26 +478,26 @@ endr
.asm_e82c1 ; unused .asm_e82c1 ; unused
ld a, [wCurTrackFrequency] ld a, [wCurTrackFrequency]
ld [rNR43], a ldh [rNR43], a
ret ret
.ch4rest .ch4rest
ld a, [rNR52] ldh a, [rNR52]
and %10000111 ; ch4 off and %10000111 ; ch4 off
ld [rNR52], a ldh [rNR52], a
ld hl, rNR40 ld hl, rNR40
call ClearChannel call ClearChannel
ret ret
.asm_e82d4 .asm_e82d4
ld a, $3f ; sound length ld a, $3f ; sound length
ld [rNR41], a ldh [rNR41], a
ld a, [wCurTrackIntensity] ld a, [wCurTrackIntensity]
ld [rNR42], a ldh [rNR42], a
ld a, [wCurTrackFrequency] ld a, [wCurTrackFrequency]
ld [rNR43], a ldh [rNR43], a
ld a, $80 ld a, $80
ld [rNR44], a ldh [rNR44], a
ret ret
_CheckSFX: _CheckSFX:
@@ -551,15 +551,15 @@ PlayDanger:
.applychannel .applychannel
xor a xor a
ld [rNR10], a ldh [rNR10], a
ld a, [hli] ld a, [hli]
ld [rNR11], a ldh [rNR11], a
ld a, [hli] ld a, [hli]
ld [rNR12], a ldh [rNR12], a
ld a, [hli] ld a, [hli]
ld [rNR13], a ldh [rNR13], a
ld a, [hli] ld a, [hli]
ld [rNR14], a ldh [rNR14], a
.increment .increment
ld a, d ld a, d
@@ -1221,7 +1221,7 @@ ParseMusic:
jr nz, .ok jr nz, .ok
; ???? ; ????
xor a xor a
ld [rNR10], a ; sweep = 0 ldh [rNR10], a ; sweep = 0
.ok .ok
; stop playing ; stop playing
; turn channel off ; turn channel off
@@ -2476,56 +2476,56 @@ _PlaySFX::
jr z, .ch6 jr z, .ch6
res SOUND_CHANNEL_ON, [hl] ; turn it off res SOUND_CHANNEL_ON, [hl] ; turn it off
xor a xor a
ld [rNR11], a ; length/wavepattern = 0 ldh [rNR11], a ; length/wavepattern = 0
ld a, $8 ld a, $8
ld [rNR12], a ; envelope = 0 ldh [rNR12], a ; envelope = 0
xor a xor a
ld [rNR13], a ; frequency lo = 0 ldh [rNR13], a ; frequency lo = 0
ld a, $80 ld a, $80
ld [rNR14], a ; restart sound (freq hi = 0) ldh [rNR14], a ; restart sound (freq hi = 0)
xor a xor a
ld [wSoundInput], a ; global sound off ld [wSoundInput], a ; global sound off
ld [rNR10], a ; sweep = 0 ldh [rNR10], a ; sweep = 0
.ch6 .ch6
ld hl, wChannel6Flags1 ld hl, wChannel6Flags1
bit SOUND_CHANNEL_ON, [hl] bit SOUND_CHANNEL_ON, [hl]
jr z, .ch7 jr z, .ch7
res SOUND_CHANNEL_ON, [hl] ; turn it off res SOUND_CHANNEL_ON, [hl] ; turn it off
xor a xor a
ld [rNR21], a ; length/wavepattern = 0 ldh [rNR21], a ; length/wavepattern = 0
ld a, $8 ld a, $8
ld [rNR22], a ; envelope = 0 ldh [rNR22], a ; envelope = 0
xor a xor a
ld [rNR23], a ; frequency lo = 0 ldh [rNR23], a ; frequency lo = 0
ld a, $80 ld a, $80
ld [rNR24], a ; restart sound (freq hi = 0) ldh [rNR24], a ; restart sound (freq hi = 0)
.ch7 .ch7
ld hl, wChannel7Flags1 ld hl, wChannel7Flags1
bit SOUND_CHANNEL_ON, [hl] bit SOUND_CHANNEL_ON, [hl]
jr z, .ch8 jr z, .ch8
res SOUND_CHANNEL_ON, [hl] ; turn it off res SOUND_CHANNEL_ON, [hl] ; turn it off
xor a xor a
ld [rNR30], a ; sound mode #3 off ldh [rNR30], a ; sound mode #3 off
ld [rNR31], a ; length/wavepattern = 0 ldh [rNR31], a ; length/wavepattern = 0
ld a, $8 ld a, $8
ld [rNR32], a ; envelope = 0 ldh [rNR32], a ; envelope = 0
xor a xor a
ld [rNR33], a ; frequency lo = 0 ldh [rNR33], a ; frequency lo = 0
ld a, $80 ld a, $80
ld [rNR34], a ; restart sound (freq hi = 0) ldh [rNR34], a ; restart sound (freq hi = 0)
.ch8 .ch8
ld hl, wChannel8Flags1 ld hl, wChannel8Flags1
bit SOUND_CHANNEL_ON, [hl] bit SOUND_CHANNEL_ON, [hl]
jr z, .chscleared jr z, .chscleared
res SOUND_CHANNEL_ON, [hl] ; turn it off res SOUND_CHANNEL_ON, [hl] ; turn it off
xor a xor a
ld [rNR41], a ; length/wavepattern = 0 ldh [rNR41], a ; length/wavepattern = 0
ld a, $8 ld a, $8
ld [rNR42], a ; envelope = 0 ldh [rNR42], a ; envelope = 0
xor a xor a
ld [rNR43], a ; frequency lo = 0 ldh [rNR43], a ; frequency lo = 0
ld a, $80 ld a, $80
ld [rNR44], a ; restart sound (freq hi = 0) ldh [rNR44], a ; restart sound (freq hi = 0)
xor a xor a
ld [wNoiseSampleAddress], a ld [wNoiseSampleAddress], a
ld [wNoiseSampleAddress + 1], a ld [wNoiseSampleAddress + 1], a

View File

@@ -2,8 +2,6 @@ INCLUDE "charmap.asm"
INCLUDE "macros.asm" INCLUDE "macros.asm"
INCLUDE "hram.asm"
INCLUDE "constants/hardware_constants.asm" INCLUDE "constants/hardware_constants.asm"
INCLUDE "constants/deco_constants.asm" INCLUDE "constants/deco_constants.asm"
INCLUDE "constants/wram_constants.asm" INCLUDE "constants/wram_constants.asm"

View File

@@ -485,7 +485,7 @@ In [engine/battle/effect_commands.asm](/engine/battle/effect_commands.asm).
```asm ```asm
BattleCheckTypeMatchup: BattleCheckTypeMatchup:
ld hl, wEnemyMonType1 ld hl, wEnemyMonType1
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, CheckTypeMatchup jr z, CheckTypeMatchup
ld hl, wBattleMonType1 ld hl, wBattleMonType1
@@ -962,7 +962,7 @@ Then edit [engine/battle/start_battle.asm](/engine/battle/start_battle.asm):
```diff ```diff
FindFirstAliveMonAndStartBattle: FindFirstAliveMonAndStartBattle:
xor a xor a
ld [hMapAnims], a ldh [hMapAnims], a
call DelayFrame call DelayFrame
- ld b, 6 - ld b, 6
- ld hl, wPartyMon1HP - ld hl, wPartyMon1HP
@@ -1520,7 +1520,7 @@ ScriptCall:
ld a, 1 ld a, 1
.bank_loop .bank_loop
push af push af
ld [rSVBK], a ldh [rSVBK], a
xor a xor a
ld hl, WRAM1_Begin ld hl, WRAM1_Begin
ld bc, WRAM1_End - WRAM1_Begin ld bc, WRAM1_End - WRAM1_Begin

View File

@@ -520,7 +520,7 @@ AIUpdateHUD:
call UpdateEnemyMonInParty call UpdateEnemyMonInParty
farcall UpdateEnemyHUD farcall UpdateEnemyHUD
ld a, $1 ld a, $1
ld [hBGMapMode], a ldh [hBGMapMode], a
ld hl, wEnemyItemState ld hl, wEnemyItemState
dec [hl] dec [hl]
scf scf
@@ -671,7 +671,7 @@ AI_Switch:
ld hl, wEnemySubStatus4 ld hl, wEnemySubStatus4
res SUBSTATUS_RAGE, [hl] res SUBSTATUS_RAGE, [hl]
xor a xor a
ld [hBattleTurn], a ldh [hBattleTurn], a
callfar PursuitSwitch callfar PursuitSwitch
push af push af
@@ -755,17 +755,17 @@ EnemyUsedDireHit:
jp PrintText_UsedItemOn_AND_AIUpdateHUD jp PrintText_UsedItemOn_AND_AIUpdateHUD
Function3851e: ; This appears to be unused Function3851e: ; This appears to be unused
ld [hDivisor], a ldh [hDivisor], a
ld hl, wEnemyMonMaxHP ld hl, wEnemyMonMaxHP
ld a, [hli] ld a, [hli]
ld [hDividend], a ldh [hDividend], a
ld a, [hl] ld a, [hl]
ld [hDividend + 1], a ldh [hDividend + 1], a
ld b, 2 ld b, 2
call Divide call Divide
ld a, [hQuotient + 2] ldh a, [hQuotient + 2]
ld c, a ld c, a
ld a, [hQuotient + 1] ldh a, [hQuotient + 1]
ld b, a ld b, a
ld hl, wEnemyMonHP + 1 ld hl, wEnemyMonHP + 1
ld a, [hld] ld a, [hld]

View File

@@ -165,7 +165,7 @@ AI_Types:
push bc push bc
push de push de
ld a, 1 ld a, 1
ld [hBattleTurn], a ldh [hBattleTurn], a
callfar BattleCheckTypeMatchup callfar BattleCheckTypeMatchup
pop de pop de
pop bc pop bc
@@ -410,7 +410,7 @@ AI_Smart_Sleep:
AI_Smart_LeechHit: AI_Smart_LeechHit:
push hl push hl
ld a, 1 ld a, 1
ld [hBattleTurn], a ldh [hBattleTurn], a
callfar BattleCheckTypeMatchup callfar BattleCheckTypeMatchup
pop hl pop hl
@@ -486,7 +486,7 @@ AI_Smart_LockOn:
jr nc, .asm_3884f jr nc, .asm_3884f
ld a, $1 ld a, $1
ld [hBattleTurn], a ldh [hBattleTurn], a
push hl push hl
push bc push bc
@@ -1289,7 +1289,7 @@ AI_Smart_Mimic:
call AIGetEnemyMove call AIGetEnemyMove
ld a, $1 ld a, $1
ld [hBattleTurn], a ldh [hBattleTurn], a
callfar BattleCheckTypeMatchup callfar BattleCheckTypeMatchup
ld a, [wTypeMatchup] ld a, [wTypeMatchup]
@@ -1631,7 +1631,7 @@ AI_Smart_PriorityHit:
; Greatly encourage this move if it will KO the player. ; Greatly encourage this move if it will KO the player.
ld a, $1 ld a, $1
ld [hBattleTurn], a ldh [hBattleTurn], a
push hl push hl
callfar EnemyAttackDamage callfar EnemyAttackDamage
callfar BattleCommand_DamageCalc callfar BattleCommand_DamageCalc
@@ -1675,7 +1675,7 @@ AI_Smart_Conversion2:
ld [wPlayerMoveStruct + MOVE_TYPE], a ld [wPlayerMoveStruct + MOVE_TYPE], a
xor a xor a
ld [hBattleTurn], a ldh [hBattleTurn], a
callfar BattleCheckTypeMatchup callfar BattleCheckTypeMatchup
@@ -2285,7 +2285,7 @@ AI_Smart_RapidSpin:
AI_Smart_HiddenPower: AI_Smart_HiddenPower:
push hl push hl
ld a, 1 ld a, 1
ld [hBattleTurn], a ldh [hBattleTurn], a
; Calculate Hidden Power's type and base power based on enemy's DVs. ; Calculate Hidden Power's type and base power based on enemy's DVs.
callfar HiddenPowerDamage callfar HiddenPowerDamage
@@ -3013,7 +3013,7 @@ INCLUDE "data/battle/ai/reckless_moves.asm"
AIDamageCalc: AIDamageCalc:
ld a, 1 ld a, 1
ld [hBattleTurn], a ldh [hBattleTurn], a
ld a, [wEnemyMoveStruct + MOVE_EFFECT] ld a, [wEnemyMoveStruct + MOVE_EFFECT]
ld de, 1 ld de, 1
ld hl, ConstantDamageEffects ld hl, ConstantDamageEffects
@@ -3119,7 +3119,7 @@ AI_Status:
push bc push bc
push de push de
ld a, 1 ld a, 1
ld [hBattleTurn], a ldh [hBattleTurn], a
callfar BattleCheckTypeMatchup callfar BattleCheckTypeMatchup
pop de pop de
pop bc pop bc

View File

@@ -277,7 +277,7 @@ HPBarAnim_UpdateHPRemaining:
ret ret
HPBarAnim_PaletteUpdate: HPBarAnim_PaletteUpdate:
ld a, [hCGB] ldh a, [hCGB]
and a and a
ret z ret z
ld hl, wCurHPAnimPal ld hl, wCurHPAnimPal
@@ -288,7 +288,7 @@ HPBarAnim_PaletteUpdate:
ret ret
HPBarAnim_BGMapUpdate: HPBarAnim_BGMapUpdate:
ld a, [hCGB] ldh a, [hCGB]
and a and a
jr nz, .cgb jr nz, .cgb
call DelayFrame call DelayFrame
@@ -316,15 +316,15 @@ HPBarAnim_BGMapUpdate:
cp $5 cp $5
jr z, .skip_delay jr z, .skip_delay
ld a, $2 ld a, $2
ld [hBGMapMode], a ldh [hBGMapMode], a
ld a, c ld a, c
ld [hBGMapThird], a ldh [hBGMapThird], a
call DelayFrame call DelayFrame
.skip_delay .skip_delay
ld a, $1 ld a, $1
ld [hBGMapMode], a ldh [hBGMapMode], a
ld a, c ld a, c
ld [hBGMapThird], a ldh [hBGMapThird], a
call DelayFrame call DelayFrame
pop af pop af
cp $2 cp $2
@@ -336,14 +336,14 @@ HPBarAnim_BGMapUpdate:
.two_frames .two_frames
inc c inc c
ld a, $2 ld a, $2
ld [hBGMapMode], a ldh [hBGMapMode], a
ld a, c ld a, c
ld [hBGMapThird], a ldh [hBGMapThird], a
call DelayFrame call DelayFrame
ld a, $1 ld a, $1
ld [hBGMapMode], a ldh [hBGMapMode], a
ld a, c ld a, c
ld [hBGMapThird], a ldh [hBGMapThird], a
call DelayFrame call DelayFrame
ret ret
@@ -356,7 +356,7 @@ HPBarAnim_BGMapUpdate:
.finish .finish
call DelayFrame call DelayFrame
ld a, c ld a, c
ld [hBGMapThird], a ldh [hBGMapThird], a
call DelayFrame call DelayFrame
ret ret

View File

@@ -10,11 +10,11 @@ BATTLETRANSITION_SQUARE EQUS "\"8\"" ; $fe
DoBattleTransition: DoBattleTransition:
call .InitGFX call .InitGFX
ld a, [rBGP] ldh a, [rBGP]
ld [wBGP], a ld [wBGP], a
ld a, [rOBP0] ldh a, [rOBP0]
ld [wOBP0], a ld [wOBP0], a
ld a, [rOBP1] ldh a, [rOBP1]
ld [wOBP1], a ld [wOBP1], a
call DelayFrame call DelayFrame
ld hl, hVBlank ld hl, hVBlank
@@ -31,10 +31,10 @@ DoBattleTransition:
jr .loop jr .loop
.done .done
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, BANK(wBGPals1) ld a, BANK(wBGPals1)
ld [rSVBK], a ldh [rSVBK], a
ld hl, wBGPals1 ld hl, wBGPals1
ld bc, 8 palettes ld bc, 8 palettes
@@ -42,22 +42,22 @@ DoBattleTransition:
call ByteFill call ByteFill
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ld a, %11111111 ld a, %11111111
ld [wBGP], a ld [wBGP], a
call DmgToCgbBGPals call DmgToCgbBGPals
call DelayFrame call DelayFrame
xor a xor a
ld [hLCDCPointer], a ldh [hLCDCPointer], a
ld [hLYOverrideStart], a ldh [hLYOverrideStart], a
ld [hLYOverrideEnd], a ldh [hLYOverrideEnd], a
ld [hSCY], a ldh [hSCY], a
ld a, 1 ; unnecessary bankswitch? ld a, 1 ; unnecessary bankswitch?
ld [rSVBK], a ldh [rSVBK], a
pop af pop af
ld [hVBlank], a ldh [hVBlank], a
call DelayFrame call DelayFrame
ret ret
@@ -77,10 +77,10 @@ DoBattleTransition:
.resume .resume
ld a, SCREEN_HEIGHT_PX ld a, SCREEN_HEIGHT_PX
ld [hWY], a ldh [hWY], a
call DelayFrame call DelayFrame
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
ld hl, wJumptableIndex ld hl, wJumptableIndex
xor a xor a
ld [hli], a ld [hli], a
@@ -104,10 +104,10 @@ LoadTrainerBattlePokeballTiles:
ld c, 2 ld c, 2
call Request2bpp call Request2bpp
ld a, [rVBK] ldh a, [rVBK]
push af push af
ld a, $1 ld a, $1
ld [rVBK], a ldh [rVBK], a
ld de, TrainerBattlePokeballTiles ld de, TrainerBattlePokeballTiles
ld hl, vTiles3 tile BATTLETRANSITION_SQUARE ld hl, vTiles3 tile BATTLETRANSITION_SQUARE
@@ -116,14 +116,14 @@ LoadTrainerBattlePokeballTiles:
call Request2bpp call Request2bpp
pop af pop af
ld [rVBK], a ldh [rVBK], a
ret ret
ConvertTrainerBattlePokeballTilesTo2bpp: ConvertTrainerBattlePokeballTilesTo2bpp:
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, BANK(wDecompressScratch) ld a, BANK(wDecompressScratch)
ld [rSVBK], a ldh [rSVBK], a
push hl push hl
ld hl, wDecompressScratch ld hl, wDecompressScratch
ld bc, $28 tiles ld bc, $28 tiles
@@ -142,7 +142,7 @@ ConvertTrainerBattlePokeballTilesTo2bpp:
ld c, $28 ld c, $28
call Request2bpp call Request2bpp
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ret ret
TrainerBattlePokeballTiles: TrainerBattlePokeballTiles:
@@ -258,7 +258,7 @@ StartTrainerBattle_SetUpBGMap:
call StartTrainerBattle_NextScene call StartTrainerBattle_NextScene
xor a xor a
ld [wcf64], a ld [wcf64], a
ld [hBGMapMode], a ldh [hBGMapMode], a
ret ret
StartTrainerBattle_Flash: StartTrainerBattle_Flash:
@@ -311,16 +311,16 @@ StartTrainerBattle_Flash:
StartTrainerBattle_SetUpForWavyOutro: StartTrainerBattle_SetUpForWavyOutro:
farcall Function5602 farcall Function5602
ld a, BANK(wLYOverrides) ld a, BANK(wLYOverrides)
ld [rSVBK], a ldh [rSVBK], a
call StartTrainerBattle_NextScene call StartTrainerBattle_NextScene
ld a, rSCX - $ff00 ld a, rSCX - $ff00
ld [hLCDCPointer], a ldh [hLCDCPointer], a
xor a xor a
ld [hLYOverrideStart], a ldh [hLYOverrideStart], a
ld a, $90 ld a, $90
ld [hLYOverrideEnd], a ldh [hLYOverrideEnd], a
xor a xor a
ld [wcf64], a ld [wcf64], a
ld [wcf65], a ld [wcf65], a
@@ -369,7 +369,7 @@ StartTrainerBattle_SineWave:
StartTrainerBattle_SetUpForSpinOutro: StartTrainerBattle_SetUpForSpinOutro:
farcall Function5602 farcall Function5602
ld a, BANK(wLYOverrides) ld a, BANK(wLYOverrides)
ld [rSVBK], a ldh [rSVBK], a
call StartTrainerBattle_NextScene call StartTrainerBattle_NextScene
xor a xor a
ld [wcf64], a ld [wcf64], a
@@ -377,7 +377,7 @@ StartTrainerBattle_SetUpForSpinOutro:
StartTrainerBattle_SpinToBlack: StartTrainerBattle_SpinToBlack:
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
ld a, [wcf64] ld a, [wcf64]
ld e, a ld e, a
ld d, 0 ld d, 0
@@ -391,7 +391,7 @@ endr
ld [wcf65], a ld [wcf65], a
call .load call .load
ld a, $1 ld a, $1
ld [hBGMapMode], a ldh [hBGMapMode], a
call DelayFrame call DelayFrame
call DelayFrame call DelayFrame
ld hl, wcf64 ld hl, wcf64
@@ -400,12 +400,12 @@ endr
.end .end
ld a, $1 ld a, $1
ld [hBGMapMode], a ldh [hBGMapMode], a
call DelayFrame call DelayFrame
call DelayFrame call DelayFrame
call DelayFrame call DelayFrame
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
ld a, BATTLETRANSITION_FINISH ld a, BATTLETRANSITION_FINISH
ld [wJumptableIndex], a ld [wJumptableIndex], a
ret ret
@@ -511,12 +511,12 @@ ENDM
StartTrainerBattle_SetUpForRandomScatterOutro: StartTrainerBattle_SetUpForRandomScatterOutro:
farcall Function5602 farcall Function5602
ld a, BANK(wLYOverrides) ld a, BANK(wLYOverrides)
ld [rSVBK], a ldh [rSVBK], a
call StartTrainerBattle_NextScene call StartTrainerBattle_NextScene
ld a, $10 ld a, $10
ld [wcf64], a ld [wcf64], a
ld a, $1 ld a, $1
ld [hBGMapMode], a ldh [hBGMapMode], a
ret ret
StartTrainerBattle_SpeckleToBlack: StartTrainerBattle_SpeckleToBlack:
@@ -536,12 +536,12 @@ StartTrainerBattle_SpeckleToBlack:
.done .done
ld a, $1 ld a, $1
ld [hBGMapMode], a ldh [hBGMapMode], a
call DelayFrame call DelayFrame
call DelayFrame call DelayFrame
call DelayFrame call DelayFrame
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
ld a, BATTLETRANSITION_FINISH ld a, BATTLETRANSITION_FINISH
ld [wJumptableIndex], a ld [wJumptableIndex], a
ret ret
@@ -583,7 +583,7 @@ StartTrainerBattle_LoadPokeBallGraphics:
jp z, .nextscene ; don't need to be here if wild jp z, .nextscene ; don't need to be here if wild
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
hlcoord 0, 0, wAttrMap hlcoord 0, 0, wAttrMap
ld bc, SCREEN_HEIGHT * SCREEN_WIDTH ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
inc b inc b
@@ -640,11 +640,11 @@ StartTrainerBattle_LoadPokeBallGraphics:
dec b dec b
jr nz, .loop2 jr nz, .loop2
ld a, [hCGB] ldh a, [hCGB]
and a and a
jr nz, .cgb jr nz, .cgb
ld a, $1 ld a, $1
ld [hBGMapMode], a ldh [hBGMapMode], a
call DelayFrame call DelayFrame
call DelayFrame call DelayFrame
jr .nextscene jr .nextscene
@@ -657,10 +657,10 @@ StartTrainerBattle_LoadPokeBallGraphics:
jr nz, .daytime jr nz, .daytime
ld hl, .nightpals ld hl, .nightpals
.daytime .daytime
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, BANK(wBGPals1) ld a, BANK(wBGPals1)
ld [rSVBK], a ldh [rSVBK], a
call .copypals call .copypals
push hl push hl
ld de, wBGPals1 palette PAL_BG_TEXT ld de, wBGPals1 palette PAL_BG_TEXT
@@ -671,9 +671,9 @@ StartTrainerBattle_LoadPokeBallGraphics:
ld bc, 1 palettes ld bc, 1 palettes
call CopyBytes call CopyBytes
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ld a, $1 ld a, $1
ld [hCGBPalUpdate], a ldh [hCGBPalUpdate], a
call DelayFrame call DelayFrame
call BattleStart_CopyTilemapAtOnce call BattleStart_CopyTilemapAtOnce
@@ -731,10 +731,10 @@ PokeBallTransition:
db %00000011, %11000000 db %00000011, %11000000
WipeLYOverrides: WipeLYOverrides:
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, BANK(wLYOverrides) ld a, BANK(wLYOverrides)
ld [rSVBK], a ldh [rSVBK], a
ld hl, wLYOverrides ld hl, wLYOverrides
call .wipe call .wipe
@@ -742,7 +742,7 @@ WipeLYOverrides:
call .wipe call .wipe
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ret ret
.wipe .wipe
@@ -777,7 +777,7 @@ StartTrainerBattle_ZoomToBlack:
inc de inc de
ld h, a ld h, a
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
call .Copy call .Copy
call WaitBGMap call WaitBGMap
jr .loop jr .loop
@@ -823,8 +823,8 @@ ENDM
Unreferenced_Function8c7c9: Unreferenced_Function8c7c9:
ld a, $1 ld a, $1
ld [hBGMapMode], a ldh [hBGMapMode], a
call WaitBGMap call WaitBGMap
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
ret ret

View File

@@ -2,7 +2,7 @@ ConsumeHeldItem:
push hl push hl
push de push de
push bc push bc
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
ld hl, wOTPartyMon1Item ld hl, wOTPartyMon1Item
ld de, wEnemyMonItem ld de, wEnemyMonItem
@@ -38,7 +38,7 @@ ConsumeHeldItem:
pop af pop af
pop hl pop hl
call GetPartyLocation call GetPartyLocation
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr nz, .ourturn jr nz, .ourturn
ld a, [wBattleMode] ld a, [wBattleMode]

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -2,7 +2,7 @@ HiddenPowerDamage:
; Override Hidden Power's type and power based on the user's DVs. ; Override Hidden Power's type and power based on the user's DVs.
ld hl, wBattleMonDVs ld hl, wBattleMonDVs
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .got_dvs jr z, .got_dvs
ld hl, wEnemyMonDVs ld hl, wEnemyMonDVs

View File

@@ -83,13 +83,13 @@ DetermineLinkBattleResult:
jr z, .next jr z, .next
dec hl dec hl
xor a xor a
ld [hDividend + 0], a ldh [hDividend + 0], a
ld a, [hli] ld a, [hli]
ld [hDividend + 1], a ldh [hDividend + 1], a
ld a, [hli] ld a, [hli]
ld [hDividend + 2], a ldh [hDividend + 2], a
xor a xor a
ld [hDividend + 3], a ldh [hDividend + 3], a
ld a, [hli] ld a, [hli]
ld b, a ld b, a
ld a, [hld] ld a, [hld]
@@ -97,13 +97,13 @@ DetermineLinkBattleResult:
rr a rr a
srl b srl b
rr a rr a
ld [hDivisor], a ldh [hDivisor], a
ld b, $4 ld b, $4
call Divide call Divide
ld a, [hQuotient + 2] ldh a, [hQuotient + 2]
add e add e
ld e, a ld e, a
ld a, [hQuotient + 1] ldh a, [hQuotient + 1]
adc d adc d
ld d, a ld d, a
dec hl dec hl

View File

@@ -1,7 +1,7 @@
_DisappearUser: _DisappearUser:
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .player jr z, .player
call GetEnemyFrontpicCoords call GetEnemyFrontpicCoords
@@ -21,8 +21,8 @@ _AppearUserLowerSub:
AppearUser: AppearUser:
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .player jr z, .player
call GetEnemyFrontpicCoords call GetEnemyFrontpicCoords
@@ -32,11 +32,11 @@ AppearUser:
call GetPlayerBackpicCoords call GetPlayerBackpicCoords
ld a, $31 ld a, $31
.okay .okay
ld [hGraphicStartTile], a ldh [hGraphicStartTile], a
predef PlaceGraphic predef PlaceGraphic
FinishAppearDisappearUser: FinishAppearDisappearUser:
ld a, $1 ld a, $1
ld [hBGMapMode], a ldh [hBGMapMode], a
ret ret
GetEnemyFrontpicCoords: GetEnemyFrontpicCoords:
@@ -101,32 +101,32 @@ DoWeatherModifiers:
.ApplyModifier: .ApplyModifier:
xor a xor a
ld [hMultiplicand + 0], a ldh [hMultiplicand + 0], a
ld hl, wCurDamage ld hl, wCurDamage
ld a, [hli] ld a, [hli]
ld [hMultiplicand + 1], a ldh [hMultiplicand + 1], a
ld a, [hl] ld a, [hl]
ld [hMultiplicand + 2], a ldh [hMultiplicand + 2], a
inc de inc de
ld a, [de] ld a, [de]
ld [hMultiplier], a ldh [hMultiplier], a
call Multiply call Multiply
ld a, 10 ld a, 10
ld [hDivisor], a ldh [hDivisor], a
ld b, 4 ld b, 4
call Divide call Divide
ld a, [hQuotient + 0] ldh a, [hQuotient + 0]
and a and a
ld bc, -1 ld bc, -1
jr nz, .Update jr nz, .Update
ld a, [hQuotient + 1] ldh a, [hQuotient + 1]
ld b, a ld b, a
ld a, [hQuotient + 2] ldh a, [hQuotient + 2]
ld c, a ld c, a
or b or b
jr nz, .Update jr nz, .Update
@@ -153,7 +153,7 @@ DoBadgeTypeBoosts:
and a and a
ret nz ret nz
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
ret nz ret nz

View File

@@ -1,7 +1,7 @@
BattleCommand_BatonPass: BattleCommand_BatonPass:
; batonpass ; batonpass
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jp nz, .Enemy jp nz, .Enemy

View File

@@ -2,7 +2,7 @@ BattleCommand_BeatUp:
; beatup ; beatup
call ResetDamage call ResetDamage
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jp nz, .enemy_beats_up jp nz, .enemy_beats_up
@@ -210,7 +210,7 @@ GetBeatupMonLocation:
push bc push bc
ld c, a ld c, a
ld b, 0 ld b, 0
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
ld hl, wPartyMon1Species ld hl, wPartyMon1Species
jr z, .got_species jr z, .got_species

View File

@@ -7,7 +7,7 @@ BattleCommand_StoreEnergy:
ret z ret z
ld hl, wPlayerRolloutCount ld hl, wPlayerRolloutCount
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .check_still_storing_energy jr z, .check_still_storing_energy
ld hl, wEnemyRolloutCount ld hl, wEnemyRolloutCount
@@ -28,7 +28,7 @@ BattleCommand_StoreEnergy:
ld [hl], a ld [hl], a
ld hl, wPlayerDamageTaken + 1 ld hl, wPlayerDamageTaken + 1
ld de, wPlayerCharging ; player ld de, wPlayerCharging ; player
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .player jr z, .player
ld hl, wEnemyDamageTaken + 1 ld hl, wEnemyDamageTaken + 1
@@ -74,7 +74,7 @@ BattleCommand_UnleashEnergy:
ld de, wPlayerDamageTaken ld de, wPlayerDamageTaken
ld bc, wPlayerRolloutCount ld bc, wPlayerRolloutCount
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .got_damage jr z, .got_damage
ld de, wEnemyDamageTaken ld de, wEnemyDamageTaken

View File

@@ -3,7 +3,7 @@ BattleCommand_Conversion:
ld hl, wBattleMonMoves ld hl, wBattleMonMoves
ld de, wBattleMonType1 ld de, wBattleMonType1
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .got_moves jr z, .got_moves
ld hl, wEnemyMonMoves ld hl, wEnemyMonMoves

View File

@@ -5,7 +5,7 @@ BattleCommand_Conversion2:
and a and a
jr nz, .failed jr nz, .failed
ld hl, wBattleMonType1 ld hl, wBattleMonType1
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .got_type jr z, .got_type
ld hl, wEnemyMonType1 ld hl, wEnemyMonType1

View File

@@ -3,7 +3,7 @@ BattleCommand_Curse:
ld de, wBattleMonType1 ld de, wBattleMonType1
ld bc, wPlayerStatLevels ld bc, wPlayerStatLevels
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .go jr z, .go
ld de, wEnemyMonType1 ld de, wEnemyMonType1

Some files were not shown because too many files have changed in this diff Show More