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

View File

@ -7,7 +7,7 @@ BattleCommand_Disable:
ld de, wEnemyDisableCount ld de, wEnemyDisableCount
ld hl, wEnemyMonMoves ld hl, wEnemyMonMoves
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .got_moves jr z, .got_moves
ld de, wPlayerDisableCount ld de, wPlayerDisableCount
@ -33,7 +33,7 @@ BattleCommand_Disable:
cp b cp b
jr nz, .loop jr nz, .loop
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
ld hl, wEnemyMonPP ld hl, wEnemyMonPP
jr z, .got_pp jr z, .got_pp
@ -55,7 +55,7 @@ BattleCommand_Disable:
ld [de], a ld [de], a
call AnimateCurrentMove call AnimateCurrentMove
ld hl, wDisabledMove ld hl, wDisabledMove
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr nz, .got_disabled_move_pointer jr nz, .got_disabled_move_pointer
inc hl inc hl

View File

@ -3,7 +3,7 @@ BattleCommand_Encore:
ld hl, wEnemyMonMoves ld hl, wEnemyMonMoves
ld de, wEnemyEncoreCount ld de, wEnemyEncoreCount
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .ok jr z, .ok
ld hl, wBattleMonMoves ld hl, wBattleMonMoves
@ -47,7 +47,7 @@ BattleCommand_Encore:
ld [de], a ld [de], a
call CheckOpponentWentFirst call CheckOpponentWentFirst
jr nz, .finish_move jr nz, .finish_move
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .force_last_enemy_move jr z, .force_last_enemy_move

View File

@ -4,7 +4,7 @@ BattleCommand_FalseSwipe:
; Makes sure wCurDamage < MonHP ; Makes sure wCurDamage < MonHP
ld hl, wEnemyMonHP ld hl, wEnemyMonHP
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .got_hp jr z, .got_hp
ld hl, wBattleMonHP ld hl, wBattleMonHP

View File

@ -3,25 +3,25 @@ BattleCommand_FrustrationPower:
push bc push bc
ld hl, wBattleMonHappiness ld hl, wBattleMonHappiness
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .got_happiness jr z, .got_happiness
ld hl, wEnemyMonHappiness ld hl, wEnemyMonHappiness
.got_happiness .got_happiness
ld a, $ff ld a, $ff
sub [hl] sub [hl]
ld [hMultiplicand + 2], a ldh [hMultiplicand + 2], a
xor a xor a
ld [hMultiplicand + 0], a ldh [hMultiplicand + 0], a
ld [hMultiplicand + 1], a ldh [hMultiplicand + 1], a
ld a, 10 ld a, 10
ld [hMultiplier], a ldh [hMultiplier], a
call Multiply call Multiply
ld a, 25 ld a, 25
ld [hDivisor], a ldh [hDivisor], a
ld b, 4 ld b, 4
call Divide call Divide
ld a, [hQuotient + 2] ldh a, [hQuotient + 2]
ld d, a ld d, a
pop bc pop bc
ret ret

View File

@ -2,7 +2,7 @@ BattleCommand_FuryCutter:
; furycutter ; furycutter
ld hl, wPlayerFuryCutterCount ld hl, wPlayerFuryCutterCount
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .go jr z, .go
ld hl, wEnemyFuryCutterCount ld hl, wEnemyFuryCutterCount
@ -42,7 +42,7 @@ ResetFuryCutterCount:
push hl push hl
ld hl, wPlayerFuryCutterCount ld hl, wPlayerFuryCutterCount
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .reset jr z, .reset
ld hl, wEnemyFuryCutterCount ld hl, wEnemyFuryCutterCount

View File

@ -3,7 +3,7 @@ BattleCommand_CheckFutureSight:
ld hl, wPlayerFutureSightCount ld hl, wPlayerFutureSightCount
ld de, wPlayerFutureSightDamage ld de, wPlayerFutureSightDamage
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .ok jr z, .ok
ld hl, wEnemyFutureSightCount ld hl, wEnemyFutureSightCount
@ -41,7 +41,7 @@ BattleCommand_FutureSight:
ld [hl], b ld [hl], b
.AlreadyChargingFutureSight: .AlreadyChargingFutureSight:
ld hl, wPlayerFutureSightCount ld hl, wPlayerFutureSightCount
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .GotFutureSightCount jr z, .GotFutureSightCount
ld hl, wEnemyFutureSightCount ld hl, wEnemyFutureSightCount
@ -57,7 +57,7 @@ BattleCommand_FutureSight:
call StdBattleTextBox call StdBattleTextBox
call BattleCommand_RaiseSub call BattleCommand_RaiseSub
ld de, wPlayerFutureSightDamage ld de, wPlayerFutureSightDamage
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .StoreDamage jr z, .StoreDamage
ld de, wEnemyFutureSightDamage ld de, wEnemyFutureSightDamage

View File

@ -5,7 +5,7 @@ BattleCommand_HealBell:
call GetBattleVarAddr call GetBattleVarAddr
res SUBSTATUS_NIGHTMARE, [hl] res SUBSTATUS_NIGHTMARE, [hl]
ld de, wPartyMon1Status ld de, wPartyMon1Status
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .got_status jr z, .got_status
ld de, wOTPartyMon1Status ld de, wOTPartyMon1Status
@ -28,7 +28,7 @@ BattleCommand_HealBell:
ld hl, BellChimedText ld hl, BellChimedText
call StdBattleTextBox call StdBattleTextBox
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jp z, CalcPlayerStats jp z, CalcPlayerStats
jp CalcEnemyStats jp CalcEnemyStats

View File

@ -7,7 +7,7 @@ BattleCommand_LeechSeed:
jr nz, .evaded jr nz, .evaded
ld de, wEnemyMonType1 ld de, wEnemyMonType1
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .ok jr z, .ok
ld de, wBattleMonType1 ld de, wBattleMonType1

View File

@ -7,7 +7,7 @@ BattleCommand_Mimic:
and a and a
jr nz, .fail jr nz, .fail
ld hl, wBattleMonMoves ld hl, wBattleMonMoves
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .player_turn jr z, .player_turn
ld hl, wEnemyMonMoves ld hl, wEnemyMonMoves

View File

@ -5,7 +5,7 @@ BattleCommand_PayDay:
ld hl, wStringBuffer1 ld hl, wStringBuffer1
ld [hli], a ld [hli], a
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
ld a, [wBattleMonLevel] ld a, [wBattleMonLevel]
jr z, .ok jr z, .ok

View File

@ -54,7 +54,7 @@ BattleCommand_Present:
call AnimateCurrentMove call AnimateCurrentMove
call BattleCommand_SwitchTurn call BattleCommand_SwitchTurn
ld hl, AICheckPlayerMaxHP ld hl, AICheckPlayerMaxHP
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .got_hp_fn_pointer jr z, .got_hp_fn_pointer
ld hl, AICheckEnemyMaxHP ld hl, AICheckEnemyMaxHP

View File

@ -14,7 +14,7 @@ BattleCommand_Protect:
ProtectChance: ProtectChance:
ld de, wPlayerProtectCount ld de, wPlayerProtectCount
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .asm_37637 jr z, .asm_37637
ld de, wEnemyProtectCount ld de, wEnemyProtectCount

View File

@ -3,7 +3,7 @@ BattleCommand_PsychUp:
ld hl, wEnemyStatLevels ld hl, wEnemyStatLevels
ld de, wPlayerStatLevels ld de, wPlayerStatLevels
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .pointers_correct jr z, .pointers_correct
; It's the enemy's turn, so swap the pointers. ; It's the enemy's turn, so swap the pointers.
@ -35,7 +35,7 @@ BattleCommand_PsychUp:
inc de inc de
dec b dec b
jr nz, .loop2 jr nz, .loop2
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr nz, .calc_enemy_stats jr nz, .calc_enemy_stats
call CalcPlayerStats call CalcPlayerStats

View File

@ -3,7 +3,7 @@ BattleCommand_Pursuit:
; Double damage if the opponent is switching. ; Double damage if the opponent is switching.
ld hl, wEnemyIsSwitching ld hl, wEnemyIsSwitching
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .ok jr z, .ok
ld hl, wPlayerIsSwitching ld hl, wPlayerIsSwitching

View File

@ -12,7 +12,7 @@ BattleCommand_ClearHazards:
ld hl, wPlayerScreens ld hl, wPlayerScreens
ld de, wPlayerWrapCount ld de, wPlayerWrapCount
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .got_screens_wrap jr z, .got_screens_wrap
ld hl, wEnemyScreens ld hl, wEnemyScreens

View File

@ -2,24 +2,24 @@ BattleCommand_HappinessPower:
; happinesspower ; happinesspower
push bc push bc
ld hl, wBattleMonHappiness ld hl, wBattleMonHappiness
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .ok jr z, .ok
ld hl, wEnemyMonHappiness ld hl, wEnemyMonHappiness
.ok .ok
xor a xor a
ld [hMultiplicand + 0], a ldh [hMultiplicand + 0], a
ld [hMultiplicand + 1], a ldh [hMultiplicand + 1], a
ld a, [hl] ld a, [hl]
ld [hMultiplicand + 2], a ldh [hMultiplicand + 2], a
ld a, 10 ld a, 10
ld [hMultiplier], a ldh [hMultiplier], a
call Multiply call Multiply
ld a, 25 ld a, 25
ld [hDivisor], a ldh [hDivisor], a
ld b, 4 ld b, 4
call Divide call Divide
ld a, [hQuotient + 2] ldh a, [hQuotient + 2]
ld d, a ld d, a
pop bc pop bc
ret ret

View File

@ -4,7 +4,7 @@ BattleCommand_CheckCurl:
; checkcurl ; checkcurl
ld de, wPlayerRolloutCount ld de, wPlayerRolloutCount
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .ok jr z, .ok
ld de, wEnemyRolloutCount ld de, wEnemyRolloutCount
@ -31,7 +31,7 @@ BattleCommand_RolloutPower:
ret nz ret nz
ld hl, wPlayerRolloutCount ld hl, wPlayerRolloutCount
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .got_rollout_count jr z, .got_rollout_count
ld hl, wEnemyRolloutCount ld hl, wEnemyRolloutCount

View File

@ -3,7 +3,7 @@ BattleCommand_Safeguard:
ld hl, wPlayerScreens ld hl, wPlayerScreens
ld de, wPlayerSafeguardCount ld de, wPlayerSafeguardCount
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .ok jr z, .ok
ld hl, wEnemyScreens ld hl, wEnemyScreens

View File

@ -27,7 +27,7 @@ BattleCommand_Sketch:
ld e, l ld e, l
; Get the battle move structs. ; Get the battle move structs.
ld hl, wBattleMonMoves ld hl, wBattleMonMoves
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .get_last_move jr z, .get_last_move
ld hl, wEnemyMonMoves ld hl, wEnemyMonMoves
@ -74,7 +74,7 @@ BattleCommand_Sketch:
ld [hl], a ld [hl], a
pop bc pop bc
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .user_trainer jr z, .user_trainer
ld a, [wBattleMode] ld a, [wBattleMode]

View File

@ -5,7 +5,7 @@ BattleCommand_SleepTalk:
ld a, [wAttackMissed] ld a, [wAttackMissed]
and a and a
jr nz, .fail jr nz, .fail
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
ld hl, wBattleMonMoves + 1 ld hl, wBattleMonMoves + 1
ld a, [wDisabledMove] ld a, [wDisabledMove]
@ -77,7 +77,7 @@ BattleCommand_SleepTalk:
ret ret
.check_has_usable_move .check_has_usable_move
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
ld a, [wDisabledMove] ld a, [wDisabledMove]
jr z, .got_move_2 jr z, .got_move_2

View File

@ -2,7 +2,7 @@ BattleCommand_Spikes:
; spikes ; spikes
ld hl, wEnemyScreens ld hl, wEnemyScreens
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .asm_3768e jr z, .asm_3768e
ld hl, wPlayerScreens ld hl, wPlayerScreens

View File

@ -6,7 +6,7 @@ BattleCommand_Spite:
jp nz, .failed jp nz, .failed
ld bc, PARTYMON_STRUCT_LENGTH ; ???? ld bc, PARTYMON_STRUCT_LENGTH ; ????
ld hl, wEnemyMonMoves ld hl, wEnemyMonMoves
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .got_moves jr z, .got_moves
ld hl, wBattleMonMoves ld hl, wBattleMonMoves
@ -63,7 +63,7 @@ BattleCommand_Spite:
call GetBattleVar call GetBattleVar
bit SUBSTATUS_TRANSFORMED, a bit SUBSTATUS_TRANSFORMED, a
jr nz, .transformed jr nz, .transformed
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr nz, .not_wildmon jr nz, .not_wildmon
ld a, [wBattleMode] ld a, [wBattleMode]

View File

@ -4,7 +4,7 @@ BattleCommand_Substitute:
call BattleCommand_MoveDelay call BattleCommand_MoveDelay
ld hl, wBattleMonMaxHP ld hl, wBattleMonMaxHP
ld de, wPlayerSubstituteHP ld de, wPlayerSubstituteHP
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .got_hp jr z, .got_hp
ld hl, wEnemyMonMaxHP ld hl, wEnemyMonMaxHP
@ -46,7 +46,7 @@ BattleCommand_Substitute:
ld hl, wPlayerWrapCount ld hl, wPlayerWrapCount
ld de, wPlayerTrappingMove ld de, wPlayerTrappingMove
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .player jr z, .player
ld hl, wEnemyWrapCount ld hl, wEnemyWrapCount

View File

@ -16,7 +16,7 @@ BattleCommand_Teleport:
bit SUBSTATUS_CANT_RUN, a bit SUBSTATUS_CANT_RUN, a
jr nz, .failed jr nz, .failed
; Only need to check these next things if it's your turn ; Only need to check these next things if it's your turn
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr nz, .enemy_turn jr nz, .enemy_turn
; Can't teleport from a trainer battle ; Can't teleport from a trainer battle

View File

@ -1,7 +1,7 @@
BattleCommand_Thief: BattleCommand_Thief:
; thief ; thief
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr nz, .enemy jr nz, .enemy

View File

@ -30,7 +30,7 @@ BattleCommand_Transform:
call ResetActorDisable call ResetActorDisable
ld hl, wBattleMonSpecies ld hl, wBattleMonSpecies
ld de, wEnemyMonSpecies ld de, wEnemyMonSpecies
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr nz, .got_mon_species jr nz, .got_mon_species
ld hl, wEnemyMonSpecies ld hl, wEnemyMonSpecies
@ -46,7 +46,7 @@ BattleCommand_Transform:
inc de inc de
ld bc, NUM_MOVES ld bc, NUM_MOVES
call CopyBytes call CopyBytes
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .mimic_enemy_backup jr z, .mimic_enemy_backup
ld a, [de] ld a, [de]
@ -112,7 +112,7 @@ BattleCommand_Transform:
call BattleSideCopy call BattleSideCopy
call _CheckBattleScene call _CheckBattleScene
jr c, .mimic_anims jr c, .mimic_anims
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
ld a, [wPlayerMinimized] ld a, [wPlayerMinimized]
jr z, .got_byte jr z, .got_byte

View File

@ -315,9 +315,9 @@ ComputeTrainerReward:
ld hl, wBattleReward ld hl, wBattleReward
xor a xor a
ld [hli], a ld [hli], a
ld a, [hProduct + 2] ldh a, [hProduct + 2]
ld [hli], a ld [hli], a
ld a, [hProduct + 3] ldh a, [hProduct + 3]
ld [hl], a ld [hl], a
ret ret

View File

@ -1,22 +1,22 @@
BattleIntroSlidingPics: BattleIntroSlidingPics:
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, BANK(wLYOverrides) ld a, BANK(wLYOverrides)
ld [rSVBK], a ldh [rSVBK], a
call .subfunction1 call .subfunction1
ld a, rSCX - $ff00 ld a, rSCX - $ff00
ld [hLCDCPointer], a ldh [hLCDCPointer], a
call .subfunction2 call .subfunction2
xor a xor a
ld [hLCDCPointer], a ldh [hLCDCPointer], a
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ret ret
.subfunction1 .subfunction1
call .subfunction4 call .subfunction4
ld a, $90 ld a, $90
ld [hSCX], a ldh [hSCX], a
ld a, %11100100 ld a, %11100100
call DmgToCgbBGPals call DmgToCgbBGPals
lb de, %11100100, %11100100 lb de, %11100100, %11100100
@ -31,11 +31,11 @@ BattleIntroSlidingPics:
.loop1 .loop1
push af push af
.loop2 .loop2
ld a, [rLY] ldh a, [rLY]
cp $60 cp $60
jr c, .loop2 jr c, .loop2
ld a, d ld a, d
ld [hSCX], a ldh [hSCX], a
call .subfunction5 call .subfunction5
inc e inc e
inc e inc e

View File

@ -14,7 +14,7 @@ ShowLinkBattleParticipants:
FindFirstAliveMonAndStartBattle: FindFirstAliveMonAndStartBattle:
xor a xor a
ld [hMapAnims], a ldh [hMapAnims], a
call DelayFrame call DelayFrame
ld b, PARTY_LENGTH ld b, PARTY_LENGTH
ld hl, wPartyMon1HP ld hl, wPartyMon1HP
@ -36,14 +36,14 @@ FindFirstAliveMonAndStartBattle:
predef DoBattleTransition predef DoBattleTransition
farcall _LoadBattleFontsHPBar farcall _LoadBattleFontsHPBar
ld a, 1 ld a, 1
ld [hBGMapMode], a ldh [hBGMapMode], a
call ClearSprites call ClearSprites
call ClearTileMap call ClearTileMap
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
ld [hWY], a ldh [hWY], a
ld [rWY], a ldh [rWY], a
ld [hMapAnims], a ldh [hMapAnims], a
ret ret
PlayBattleMusic: PlayBattleMusic:

View File

@ -1,6 +1,6 @@
BattleStart_TrainerHuds: BattleStart_TrainerHuds:
ld a, $e4 ld a, $e4
ld [rOBP0], a ldh [rOBP0], a
call LoadBallIconGFX call LoadBallIconGFX
call ShowPlayerMonsRemaining call ShowPlayerMonsRemaining
ld a, [wBattleMode] ld a, [wBattleMode]
@ -10,7 +10,7 @@ BattleStart_TrainerHuds:
EnemySwitch_TrainerHud: EnemySwitch_TrainerHud:
ld a, $e4 ld a, $e4
ld [rOBP0], a ldh [rOBP0], a
call LoadBallIconGFX call LoadBallIconGFX
jp ShowOTTrainerMonsRemaining jp ShowOTTrainerMonsRemaining
@ -253,5 +253,5 @@ _ShowLinkBattleParticipants:
call GetSGBLayout call GetSGBLayout
call SetPalettes call SetPalettes
ld a, $e4 ld a, $e4
ld [rOBP0], a ldh [rOBP0], a
ret ret

View File

@ -8,7 +8,7 @@ UsedMoveText:
; this is a stream of text and asm from 105db9 to 105ef6 ; this is a stream of text and asm from 105db9 to 105ef6
text_jump _ActorNameText text_jump _ActorNameText
start_asm start_asm
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr nz, .start jr nz, .start

View File

@ -1,16 +1,16 @@
; Battle animation command interpreter. ; Battle animation command interpreter.
PlayBattleAnim: PlayBattleAnim:
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, BANK(wActiveAnimObjects) ld a, BANK(wActiveAnimObjects)
ld [rSVBK], a ldh [rSVBK], a
call _PlayBattleAnim call _PlayBattleAnim
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ret ret
_PlayBattleAnim: _PlayBattleAnim:
@ -25,7 +25,7 @@ _PlayBattleAnim:
call BattleAnimDelayFrame call BattleAnimDelayFrame
ld c, 1 ld c, 1
ld a, [rKEY1] ldh a, [rKEY1]
bit 7, a bit 7, a
jr nz, .asm_cc0ff jr nz, .asm_cc0ff
ld c, 3 ld c, 3
@ -39,10 +39,10 @@ _PlayBattleAnim:
call BattleAnimRunScript call BattleAnimRunScript
pop af pop af
ld [hVBlank], a ldh [hVBlank], a
ld a, $1 ld a, $1
ld [hBGMapMode], a ldh [hBGMapMode], a
call BattleAnimDelayFrame call BattleAnimDelayFrame
call BattleAnimDelayFrame call BattleAnimDelayFrame
@ -65,8 +65,8 @@ BattleAnimRunScript:
call BattleAnimRequestPals call BattleAnimRequestPals
xor a xor a
ld [hSCX], a ldh [hSCX], a
ld [hSCY], a ldh [hSCY], a
call BattleAnimDelayFrame call BattleAnimDelayFrame
call BattleAnimRestoreHuds call BattleAnimRestoreHuds
@ -139,7 +139,7 @@ BattleAnimClearHud:
call WaitTop call WaitTop
call ClearActorHud call ClearActorHud
ld a, $1 ld a, $1
ld [hBGMapMode], a ldh [hBGMapMode], a
call BattleAnimDelayFrame call BattleAnimDelayFrame
call BattleAnimDelayFrame call BattleAnimDelayFrame
call BattleAnimDelayFrame call BattleAnimDelayFrame
@ -150,20 +150,20 @@ BattleAnimRestoreHuds:
call BattleAnimDelayFrame call BattleAnimDelayFrame
call WaitTop call WaitTop
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, BANK(wCurBattleMon) ; alternatively: BANK(wTempMon), BANK(wPartyMon1), several others ld a, BANK(wCurBattleMon) ; alternatively: BANK(wTempMon), BANK(wPartyMon1), several others
ld [rSVBK], a ldh [rSVBK], a
ld hl, UpdateBattleHuds ld hl, UpdateBattleHuds
ld a, BANK(UpdatePlayerHUD) ld a, BANK(UpdatePlayerHUD)
rst FarCall ; Why not "call UpdateBattleHuds"? rst FarCall ; Why not "call UpdateBattleHuds"?
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ld a, $1 ld a, $1
ld [hBGMapMode], a ldh [hBGMapMode], a
call BattleAnimDelayFrame call BattleAnimDelayFrame
call BattleAnimDelayFrame call BattleAnimDelayFrame
call BattleAnimDelayFrame call BattleAnimDelayFrame
@ -171,17 +171,17 @@ BattleAnimRestoreHuds:
ret ret
BattleAnimRequestPals: BattleAnimRequestPals:
ld a, [hCGB] ldh a, [hCGB]
and a and a
ret z ret z
ld a, [rBGP] ldh a, [rBGP]
ld b, a ld b, a
ld a, [wBGP] ld a, [wBGP]
cp b cp b
call nz, BattleAnim_SetBGPals call nz, BattleAnim_SetBGPals
ld a, [rOBP0] ldh a, [rOBP0]
ld b, a ld b, a
ld a, [wOBP0] ld a, [wOBP0]
cp b cp b
@ -200,7 +200,7 @@ BattleAnimDelayFrame:
ret ret
ClearActorHud: ClearActorHud:
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .player jr z, .player
@ -217,18 +217,18 @@ ClearActorHud:
Unreferenced_Functioncc220: Unreferenced_Functioncc220:
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
ld a, LOW(vBGMap0 tile $28) ld a, LOW(vBGMap0 tile $28)
ld [hBGMapAddress], a ldh [hBGMapAddress], a
ld a, HIGH(vBGMap0 tile $28) ld a, HIGH(vBGMap0 tile $28)
ld [hBGMapAddress + 1], a ldh [hBGMapAddress + 1], a
call WaitBGMap2 call WaitBGMap2
ld a, $60 ld a, $60
ld [hWY], a ldh [hWY], a
xor a ; LOW(vBGMap0) xor a ; LOW(vBGMap0)
ld [hBGMapAddress], a ldh [hBGMapAddress], a
ld a, HIGH(vBGMap0) ld a, HIGH(vBGMap0)
ld [hBGMapAddress + 1], a ldh [hBGMapAddress + 1], a
call BattleAnimDelayFrame call BattleAnimDelayFrame
ret ret
@ -633,7 +633,7 @@ BattleAnimCmd_OBP1:
ret ret
BattleAnimCmd_ResetObp0: BattleAnimCmd_ResetObp0:
ld a, [hSGB] ldh a, [hSGB]
and a and a
ld a, $e0 ld a, $e0
jr z, .not_sgb jr z, .not_sgb
@ -885,14 +885,14 @@ BattleAnimCmd_E7:
ret ret
BattleAnimCmd_Transform: BattleAnimCmd_Transform:
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, BANK(wCurPartySpecies) ld a, BANK(wCurPartySpecies)
ld [rSVBK], a ldh [rSVBK], a
ld a, [wCurPartySpecies] ; CurPartySpecies ld a, [wCurPartySpecies] ; CurPartySpecies
push af push af
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .player jr z, .player
@ -916,12 +916,12 @@ BattleAnimCmd_Transform:
pop af pop af
ld [wCurPartySpecies], a ; CurPartySpecies ld [wCurPartySpecies], a ; CurPartySpecies
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ret ret
BattleAnimCmd_UpdateActorPic: BattleAnimCmd_UpdateActorPic:
ld de, vTiles0 tile $00 ld de, vTiles0 tile $00
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .player jr z, .player
@ -939,10 +939,10 @@ BattleAnimCmd_UpdateActorPic:
ret ret
BattleAnimCmd_RaiseSub: BattleAnimCmd_RaiseSub:
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, 1 ; unnecessary bankswitch? ld a, 1 ; unnecessary bankswitch?
ld [rSVBK], a ldh [rSVBK], a
xor a ; sScratch xor a ; sScratch
call GetSRAMBank call GetSRAMBank
@ -958,7 +958,7 @@ GetSubstitutePic: ; used only for BANK(GetSubstitutePic)
or b or b
jr nz, .loop jr nz, .loop
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .player jr z, .player
@ -1003,7 +1003,7 @@ GetSubstitutePic: ; used only for BANK(GetSubstitutePic)
.done .done
call CloseSRAM call CloseSRAM
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ret ret
.CopyTile: .CopyTile:
@ -1013,17 +1013,17 @@ GetSubstitutePic: ; used only for BANK(GetSubstitutePic)
ret ret
BattleAnimCmd_MinimizeOpp: BattleAnimCmd_MinimizeOpp:
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, 1 ; unnecessary bankswitch? ld a, 1 ; unnecessary bankswitch?
ld [rSVBK], a ldh [rSVBK], a
xor a ; sScratch xor a ; sScratch
call GetSRAMBank call GetSRAMBank
call GetMinimizePic call GetMinimizePic
call Request2bpp call Request2bpp
call CloseSRAM call CloseSRAM
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ret ret
GetMinimizePic: GetMinimizePic:
@ -1037,7 +1037,7 @@ GetMinimizePic:
or b or b
jr nz, .loop jr nz, .loop
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .player jr z, .player
@ -1067,10 +1067,10 @@ MinimizePic:
INCBIN "gfx/battle/minimize.2bpp" INCBIN "gfx/battle/minimize.2bpp"
BattleAnimCmd_Minimize: BattleAnimCmd_Minimize:
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, 1 ; unnecessary bankswitch? ld a, 1 ; unnecessary bankswitch?
ld [rSVBK], a ldh [rSVBK], a
xor a ; sScratch xor a ; sScratch
call GetSRAMBank call GetSRAMBank
call GetMinimizePic call GetMinimizePic
@ -1078,18 +1078,18 @@ BattleAnimCmd_Minimize:
call Request2bpp call Request2bpp
call CloseSRAM call CloseSRAM
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ret ret
BattleAnimCmd_DropSub: BattleAnimCmd_DropSub:
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, BANK(wCurPartySpecies) ld a, BANK(wCurPartySpecies)
ld [rSVBK], a ldh [rSVBK], a
ld a, [wCurPartySpecies] ; CurPartySpecies ld a, [wCurPartySpecies] ; CurPartySpecies
push af push af
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .player jr z, .player
@ -1103,21 +1103,21 @@ BattleAnimCmd_DropSub:
pop af pop af
ld [wCurPartySpecies], a ; CurPartySpecies ld [wCurPartySpecies], a ; CurPartySpecies
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ret ret
BattleAnimCmd_BeatUp: BattleAnimCmd_BeatUp:
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, BANK(wCurPartySpecies) ld a, BANK(wCurPartySpecies)
ld [rSVBK], a ldh [rSVBK], a
ld a, [wCurPartySpecies] ; CurPartySpecies ld a, [wCurPartySpecies] ; CurPartySpecies
push af push af
ld a, [wBattleAnimParam] ld a, [wBattleAnimParam]
ld [wCurPartySpecies], a ; CurPartySpecies ld [wCurPartySpecies], a ; CurPartySpecies
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .player jr z, .player
@ -1139,17 +1139,17 @@ BattleAnimCmd_BeatUp:
ld b, SCGB_BATTLE_COLORS ld b, SCGB_BATTLE_COLORS
call GetSGBLayout call GetSGBLayout
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ret ret
BattleAnimCmd_OAMOn: BattleAnimCmd_OAMOn:
xor a xor a
ld [hOAMUpdate], a ldh [hOAMUpdate], a
ret ret
BattleAnimCmd_OAMOff: BattleAnimCmd_OAMOff:
ld a, $1 ld a, $1
ld [hOAMUpdate], a ldh [hOAMUpdate], a
ret ret
BattleAnimCmd_ClearSprites: BattleAnimCmd_ClearSprites:
@ -1194,7 +1194,7 @@ BattleAnimCmd_Sound:
db $f0, $0f, $f0, $0f db $f0, $0f, $f0, $0f
.GetCryTrack: .GetCryTrack:
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr nz, .enemy jr nz, .enemy
@ -1216,12 +1216,12 @@ rept 4
add hl, de add hl, de
endr endr
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, BANK(wEnemyMon) ; wBattleMon is in WRAM0, but EnemyMon is in WRAMX ld a, BANK(wEnemyMon) ; wBattleMon is in WRAM0, but EnemyMon is in WRAMX
ld [rSVBK], a ldh [rSVBK], a
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr nz, .enemy jr nz, .enemy
@ -1278,7 +1278,7 @@ endr
.done .done
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ret ret
.CryData: .CryData:
@ -1314,10 +1314,10 @@ PlayHitSound:
ret ret
BattleAnimAssignPals: BattleAnimAssignPals:
ld a, [hCGB] ldh a, [hCGB]
and a and a
jr nz, .cgb jr nz, .cgb
ld a, [hSGB] ldh a, [hSGB]
and a and a
ld a, %11100000 ld a, %11100000
jr z, .sgb jr z, .sgb
@ -1374,59 +1374,59 @@ BattleAnim_RevertPals:
lb de, %11100100, %11100100 lb de, %11100100, %11100100
call DmgToCgbObjPals call DmgToCgbObjPals
xor a xor a
ld [hSCX], a ldh [hSCX], a
ld [hSCY], a ldh [hSCY], a
call BattleAnimDelayFrame call BattleAnimDelayFrame
ld a, $1 ld a, $1
ld [hBGMapMode], a ldh [hBGMapMode], a
ret ret
BattleAnim_SetBGPals: BattleAnim_SetBGPals:
ld [rBGP], a ldh [rBGP], a
ld a, [hCGB] ldh a, [hCGB]
and a and a
ret z ret z
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, wBGPals2 ld hl, wBGPals2
ld de, wBGPals1 ld de, wBGPals1
ld a, [rBGP] ldh a, [rBGP]
ld b, a ld b, a
ld c, 7 ld c, 7
call CopyPals call CopyPals
ld hl, wOBPals2 ld hl, wOBPals2
ld de, wOBPals1 ld de, wOBPals1
ld a, [rBGP] ldh a, [rBGP]
ld b, a ld b, a
ld c, 2 ld c, 2
call CopyPals call CopyPals
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ld a, $1 ld a, $1
ld [hCGBPalUpdate], a ldh [hCGBPalUpdate], a
ret ret
BattleAnim_SetOBPals: BattleAnim_SetOBPals:
ld [rOBP0], a ldh [rOBP0], a
ld a, [hCGB] ldh a, [hCGB]
and a and a
ret z ret z
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, BANK(wOBPals1) ld a, BANK(wOBPals1)
ld [rSVBK], a ldh [rSVBK], a
ld hl, wOBPals2 palette PAL_BATTLE_OB_GRAY ld hl, wOBPals2 palette PAL_BATTLE_OB_GRAY
ld de, wOBPals1 palette PAL_BATTLE_OB_GRAY ld de, wOBPals1 palette PAL_BATTLE_OB_GRAY
ld a, [rOBP0] ldh a, [rOBP0]
ld b, a ld b, a
ld c, 2 ld c, 2
call CopyPals call CopyPals
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ld a, $1 ld a, $1
ld [hCGBPalUpdate], a ldh [hCGBPalUpdate], a
ret ret
BattleAnim_UpdateOAM_All: BattleAnim_UpdateOAM_All:

View File

@ -363,14 +363,14 @@ BattleBGEffect_HideMon:
call ClearBox call ClearBox
pop bc pop bc
xor a xor a
ld [hBGMapThird], a ldh [hBGMapThird], a
ld a, $1 ld a, $1
ld [hBGMapMode], a ldh [hBGMapMode], a
ret ret
.four .four
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
call EndBattleBGEffect call EndBattleBGEffect
ret ret
@ -460,13 +460,13 @@ BattleBGEffect_FeetFollow:
.okay2 .okay2
call ClearBox call ClearBox
ld a, $1 ld a, $1
ld [hBGMapMode], a ldh [hBGMapMode], a
pop bc pop bc
ret ret
.five .five
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
call EndBattleBGEffect call EndBattleBGEffect
ret ret
@ -527,13 +527,13 @@ BattleBGEffect_HeadFollow:
.okay2 .okay2
call ClearBox call ClearBox
ld a, $1 ld a, $1
ld [hBGMapMode], a ldh [hBGMapMode], a
pop bc pop bc
ret ret
.five .five
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
call EndBattleBGEffect call EndBattleBGEffect
ret ret
@ -615,9 +615,9 @@ BattleBGEffect_27:
jr nz, .row2 jr nz, .row2
.okay2 .okay2
xor a xor a
ld [hBGMapThird], a ldh [hBGMapThird], a
ld a, $1 ld a, $1
ld [hBGMapMode], a ldh [hBGMapMode], a
call BattleBGEffects_IncrementJumptable call BattleBGEffects_IncrementJumptable
ld hl, BG_EFFECT_STRUCT_03 ld hl, BG_EFFECT_STRUCT_03
add hl, bc add hl, bc
@ -626,7 +626,7 @@ BattleBGEffect_27:
.four .four
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
ld hl, BG_EFFECT_STRUCT_03 ld hl, BG_EFFECT_STRUCT_03
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
@ -736,7 +736,7 @@ BattleBGEffect_RunPicResizeScript:
.skip .skip
call BattleBGEffects_IncrementJumptable call BattleBGEffects_IncrementJumptable
ld a, $1 ld a, $1
ld [hBGMapMode], a ldh [hBGMapMode], a
ret ret
.clear .clear
@ -745,7 +745,7 @@ BattleBGEffect_RunPicResizeScript:
.restart .restart
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
ld hl, BG_EFFECT_STRUCT_JT_INDEX ld hl, BG_EFFECT_STRUCT_JT_INDEX
add hl, bc add hl, bc
ld [hl], $0 ld [hl], $0
@ -753,7 +753,7 @@ BattleBGEffect_RunPicResizeScript:
.end .end
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
call EndBattleBGEffect call EndBattleBGEffect
ret ret
@ -915,7 +915,7 @@ BattleBGEffect_Surf:
call InitSurfWaves call InitSurfWaves
.one .one
ld a, [hLCDCPointer] ldh a, [hLCDCPointer]
and a and a
ret z ret z
push bc push bc
@ -945,7 +945,7 @@ BattleBGEffect_Surf:
ld hl, wSurfWaveBGEffect ld hl, wSurfWaveBGEffect
ld bc, $0 ld bc, $0
.loop2 .loop2
ld a, [hLYOverrideStart] ldh a, [hLYOverrideStart]
cp e cp e
jr nc, .load_zero jr nc, .load_zero
push hl push hl
@ -979,11 +979,11 @@ BattleBGEffect_Whirlpool:
call BattleBGEffects_IncrementJumptable call BattleBGEffects_IncrementJumptable
call BattleBGEffects_ClearLYOverrides call BattleBGEffects_ClearLYOverrides
ld a, rSCY - $ff00 ld a, rSCY - $ff00
ld [hLCDCPointer], a ldh [hLCDCPointer], a
xor a xor a
ld [hLYOverrideStart], a ldh [hLYOverrideStart], a
ld a, $5e ld a, $5e
ld [hLYOverrideEnd], a ldh [hLYOverrideEnd], a
lb de, 2, 2 lb de, 2, 2
call Functionc8f2e call Functionc8f2e
ret ret
@ -1052,11 +1052,11 @@ BattleBGEffect_Psychic:
call BattleBGEffects_IncrementJumptable call BattleBGEffects_IncrementJumptable
call BattleBGEffects_ClearLYOverrides call BattleBGEffects_ClearLYOverrides
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, $5f ld a, $5f
ld [hLYOverrideEnd], a ldh [hLYOverrideEnd], a
lb de, 6, 5 lb de, 6, 5
call Functionc8f2e call Functionc8f2e
ld hl, BG_EFFECT_STRUCT_03 ld hl, BG_EFFECT_STRUCT_03
@ -1144,9 +1144,9 @@ BattleBGEffect_DoubleTeam:
call BattleBGEffects_ClearLYOverrides call BattleBGEffects_ClearLYOverrides
ld a, rSCX - $ff00 ld a, rSCX - $ff00
call BattleBGEffect_SetLCDStatCustoms1 call BattleBGEffect_SetLCDStatCustoms1
ld a, [hLYOverrideEnd] ldh a, [hLYOverrideEnd]
inc a inc a
ld [hLYOverrideEnd], a ldh [hLYOverrideEnd], a
ld hl, BG_EFFECT_STRUCT_BATTLE_TURN ld hl, BG_EFFECT_STRUCT_BATTLE_TURN
add hl, bc add hl, bc
ld [hl], $0 ld [hl], $0
@ -1201,9 +1201,9 @@ BattleBGEffect_DoubleTeam:
inc a inc a
ld d, a ld d, a
ld h, HIGH(wLYOverridesBackup) ld h, HIGH(wLYOverridesBackup)
ld a, [hLYOverrideStart] ldh a, [hLYOverrideStart]
ld l, a ld l, a
ld a, [hLYOverrideEnd] ldh a, [hLYOverrideEnd]
sub l sub l
srl a srl a
push af push af
@ -1241,7 +1241,7 @@ BattleBGEffect_AcidArmor:
ld d, 2 ld d, 2
call Functionc8f2e call Functionc8f2e
ld h, HIGH(wLYOverridesBackup) ld h, HIGH(wLYOverridesBackup)
ld a, [hLYOverrideEnd] ldh a, [hLYOverrideEnd]
ld l, a ld l, a
ld [hl], $0 ld [hl], $0
dec l dec l
@ -1249,7 +1249,7 @@ BattleBGEffect_AcidArmor:
ret ret
.one .one
ld a, [hLYOverrideEnd] ldh a, [hLYOverrideEnd]
ld l, a ld l, a
ld h, HIGH(wLYOverridesBackup) ld h, HIGH(wLYOverridesBackup)
ld e, l ld e, l
@ -1259,11 +1259,11 @@ BattleBGEffect_AcidArmor:
ld a, [de] ld a, [de]
dec de dec de
ld [hld], a ld [hld], a
ld a, [hLYOverrideStart] ldh a, [hLYOverrideStart]
cp l cp l
jr nz, .loop jr nz, .loop
ld [hl], $90 ld [hl], $90
ld a, [hLYOverrideEnd] ldh a, [hLYOverrideEnd]
ld l, a ld l, a
ld a, [hl] ld a, [hl]
cp $1 cp $1
@ -1297,9 +1297,9 @@ BattleBGEffect_Withdraw:
call BattleBGEffects_ClearLYOverrides call BattleBGEffects_ClearLYOverrides
ld a, rSCY - $ff00 ld a, rSCY - $ff00
call BattleBGEffect_SetLCDStatCustoms1 call BattleBGEffect_SetLCDStatCustoms1
ld a, [hLYOverrideEnd] ldh a, [hLYOverrideEnd]
inc a inc a
ld [hLYOverrideEnd], a ldh [hLYOverrideEnd], a
ld hl, BG_EFFECT_STRUCT_BATTLE_TURN ld hl, BG_EFFECT_STRUCT_BATTLE_TURN
add hl, bc add hl, bc
ld [hl], $1 ld [hl], $1
@ -1346,9 +1346,9 @@ BattleBGEffect_Dig:
call BattleBGEffects_ClearLYOverrides call BattleBGEffects_ClearLYOverrides
ld a, rSCY - $ff00 ld a, rSCY - $ff00
call BattleBGEffect_SetLCDStatCustoms1 call BattleBGEffect_SetLCDStatCustoms1
ld a, [hLYOverrideEnd] ldh a, [hLYOverrideEnd]
inc a inc a
ld [hLYOverrideEnd], a ldh [hLYOverrideEnd], a
ld hl, BG_EFFECT_STRUCT_BATTLE_TURN ld hl, BG_EFFECT_STRUCT_BATTLE_TURN
add hl, bc add hl, bc
ld [hl], $2 ld [hl], $2
@ -1370,9 +1370,9 @@ BattleBGEffect_Dig:
ld [hl], $10 ld [hl], $10
call BattleBGEffects_IncrementJumptable call BattleBGEffects_IncrementJumptable
.two .two
ld a, [hLYOverrideStart] ldh a, [hLYOverrideStart]
ld l, a ld l, a
ld a, [hLYOverrideEnd] ldh a, [hLYOverrideEnd]
sub l sub l
dec a dec a
ld hl, BG_EFFECT_STRUCT_BATTLE_TURN ld hl, BG_EFFECT_STRUCT_BATTLE_TURN
@ -1412,9 +1412,9 @@ BattleBGEffect_Tackle:
call BattleBGEffects_ClearLYOverrides call BattleBGEffects_ClearLYOverrides
ld a, rSCX - $ff00 ld a, rSCX - $ff00
call BattleBGEffect_SetLCDStatCustoms1 call BattleBGEffect_SetLCDStatCustoms1
ld a, [hLYOverrideEnd] ldh a, [hLYOverrideEnd]
inc a inc a
ld [hLYOverrideEnd], a ldh [hLYOverrideEnd], a
ld hl, BG_EFFECT_STRUCT_03 ld hl, BG_EFFECT_STRUCT_03
add hl, bc add hl, bc
ld [hl], $0 ld [hl], $0
@ -1446,9 +1446,9 @@ BattleBGEffect_25:
call BattleBGEffects_ClearLYOverrides call BattleBGEffects_ClearLYOverrides
ld a, rSCX - $ff00 ld a, rSCX - $ff00
call BattleBGEffect_SetLCDStatCustoms2 call BattleBGEffect_SetLCDStatCustoms2
ld a, [hLYOverrideEnd] ldh a, [hLYOverrideEnd]
inc a inc a
ld [hLYOverrideEnd], a ldh [hLYOverrideEnd], a
ld hl, BG_EFFECT_STRUCT_03 ld hl, BG_EFFECT_STRUCT_03
add hl, bc add hl, bc
ld [hl], $0 ld [hl], $0
@ -1521,16 +1521,16 @@ Functionc88a5:
jp BGEffect_FillLYOverridesBackup jp BGEffect_FillLYOverridesBackup
.rollout .rollout
ld a, [hLYOverrideStart] ldh a, [hLYOverrideStart]
ld d, a ld d, a
ld a, [hLYOverrideEnd] ldh a, [hLYOverrideEnd]
sub d sub d
ld d, a ld d, a
ld h, HIGH(wLYOverridesBackup) ld h, HIGH(wLYOverridesBackup)
ld a, [hSCY] ldh a, [hSCY]
or a or a
jr nz, .skip1 jr nz, .skip1
ld a, [hLYOverrideStart] ldh a, [hLYOverrideStart]
or a or a
jr z, .skip2 jr z, .skip2
dec a dec a
@ -1539,14 +1539,14 @@ Functionc88a5:
jr .skip2 jr .skip2
.skip1 .skip1
ld a, [hLYOverrideEnd] ldh a, [hLYOverrideEnd]
dec a dec a
ld l, a ld l, a
ld [hl], $0 ld [hl], $0
.skip2 .skip2
ld a, [hSCY] ldh a, [hSCY]
ld l, a ld l, a
ld a, [hLYOverrideStart] ldh a, [hLYOverrideStart]
sub l sub l
jr nc, .skip3 jr nc, .skip3
xor a xor a
@ -1577,9 +1577,9 @@ BGEffect2d_2f_zero:
call BattleBGEffects_ClearLYOverrides call BattleBGEffects_ClearLYOverrides
ld a, rSCX - $ff00 ld a, rSCX - $ff00
call BattleBGEffect_SetLCDStatCustoms1 call BattleBGEffect_SetLCDStatCustoms1
ld a, [hLYOverrideEnd] ldh a, [hLYOverrideEnd]
inc a inc a
ld [hLYOverrideEnd], a ldh [hLYOverrideEnd], a
ld hl, BG_EFFECT_STRUCT_03 ld hl, BG_EFFECT_STRUCT_03
add hl, bc add hl, bc
ld [hl], $0 ld [hl], $0
@ -1620,9 +1620,9 @@ BattleBGEffect_26:
call BattleBGEffects_ClearLYOverrides call BattleBGEffects_ClearLYOverrides
ld a, rSCX - $ff00 ld a, rSCX - $ff00
call BattleBGEffect_SetLCDStatCustoms1 call BattleBGEffect_SetLCDStatCustoms1
ld a, [hLYOverrideEnd] ldh a, [hLYOverrideEnd]
inc a inc a
ld [hLYOverrideEnd], a ldh [hLYOverrideEnd], a
ld hl, BG_EFFECT_STRUCT_03 ld hl, BG_EFFECT_STRUCT_03
add hl, bc add hl, bc
ld [hl], $0 ld [hl], $0
@ -1658,9 +1658,9 @@ BattleBGEffect_2c:
call BattleBGEffects_ClearLYOverrides call BattleBGEffects_ClearLYOverrides
ld a, rSCX - $ff00 ld a, rSCX - $ff00
call BattleBGEffect_SetLCDStatCustoms1 call BattleBGEffect_SetLCDStatCustoms1
ld a, [hLYOverrideEnd] ldh a, [hLYOverrideEnd]
inc a inc a
ld [hLYOverrideEnd], a ldh [hLYOverrideEnd], a
xor a xor a
ld hl, BG_EFFECT_STRUCT_BATTLE_TURN ld hl, BG_EFFECT_STRUCT_BATTLE_TURN
add hl, bc add hl, bc
@ -1754,9 +1754,9 @@ BattleBGEffect_BounceDown:
call BattleBGEffects_ClearLYOverrides call BattleBGEffects_ClearLYOverrides
ld a, rSCY - $ff00 ld a, rSCY - $ff00
call BattleBGEffect_SetLCDStatCustoms2 call BattleBGEffect_SetLCDStatCustoms2
ld a, [hLYOverrideEnd] ldh a, [hLYOverrideEnd]
inc a inc a
ld [hLYOverrideEnd], a ldh [hLYOverrideEnd], a
ld hl, BG_EFFECT_STRUCT_BATTLE_TURN ld hl, BG_EFFECT_STRUCT_BATTLE_TURN
add hl, bc add hl, bc
ld [hl], $1 ld [hl], $1
@ -1808,14 +1808,14 @@ BattleBGEffect_2a:
call BattleBGEffects_SetLYOverrides call BattleBGEffects_SetLYOverrides
ld a, $47 ld a, $47
call BattleBGEffect_SetLCDStatCustoms1 call BattleBGEffect_SetLCDStatCustoms1
ld a, [hLYOverrideEnd] ldh a, [hLYOverrideEnd]
inc a inc a
ld [hLYOverrideEnd], a ldh [hLYOverrideEnd], a
ld a, [hLYOverrideStart] ldh a, [hLYOverrideStart]
ld l, a ld l, a
ld h, HIGH(wLYOverridesBackup) ld h, HIGH(wLYOverridesBackup)
.loop .loop
ld a, [hLYOverrideEnd] ldh a, [hLYOverrideEnd]
cp l cp l
jr z, .done jr z, .done
xor a xor a
@ -1840,9 +1840,9 @@ BattleBGEffect_2a:
ld hl, BG_EFFECT_STRUCT_03 ld hl, BG_EFFECT_STRUCT_03
add hl, bc add hl, bc
ld [hl], $0 ld [hl], $0
ld a, [hLYOverrideStart] ldh a, [hLYOverrideStart]
inc a inc a
ld [hLYOverrideStart], a ldh [hLYOverrideStart], a
call BattleBGEffects_IncrementJumptable call BattleBGEffects_IncrementJumptable
ret ret
@ -1850,7 +1850,7 @@ BattleBGEffect_2a:
call .GetLYOverride call .GetLYOverride
jr nc, .finish jr nc, .finish
call .SetLYOverridesBackup call .SetLYOverridesBackup
ld a, [hLYOverrideEnd] ldh a, [hLYOverrideEnd]
dec a dec a
ld l, a ld l, a
ld [hl], e ld [hl], e
@ -1862,9 +1862,9 @@ BattleBGEffect_2a:
.SetLYOverridesBackup: .SetLYOverridesBackup:
ld e, a ld e, a
ld a, [hLYOverrideStart] ldh a, [hLYOverrideStart]
ld l, a ld l, a
ld a, [hLYOverrideEnd] ldh a, [hLYOverrideEnd]
sub l sub l
srl a srl a
ld h, HIGH(wLYOverridesBackup) ld h, HIGH(wLYOverridesBackup)
@ -1937,7 +1937,7 @@ BattleBGEffect_2b:
ret ret
BattleBGEffect_1c: BattleBGEffect_1c:
ld a, [hCGB] ldh a, [hCGB]
and a and a
jr nz, .cgb jr nz, .cgb
call BattleBGEffects_AnonJumptable call BattleBGEffects_AnonJumptable
@ -1951,11 +1951,11 @@ BattleBGEffect_1c:
ld a, $e4 ld a, $e4
call BattleBGEffects_SetLYOverrides call BattleBGEffects_SetLYOverrides
ld a, rBGP - $ff00 ld a, rBGP - $ff00
ld [hLCDCPointer], a ldh [hLCDCPointer], a
xor a xor a
ld [hLYOverrideStart], a ldh [hLYOverrideStart], a
ld a, $60 ld a, $60
ld [hLYOverrideEnd], a ldh [hLYOverrideEnd], a
ret ret
.one .one
@ -2177,9 +2177,9 @@ BattleBGEffect_VibrateMon:
call BattleBGEffects_ClearLYOverrides call BattleBGEffects_ClearLYOverrides
ld a, rSCX - $ff00 ld a, rSCX - $ff00
call BattleBGEffect_SetLCDStatCustoms1 call BattleBGEffect_SetLCDStatCustoms1
ld a, [hLYOverrideEnd] ldh a, [hLYOverrideEnd]
inc a inc a
ld [hLYOverrideEnd], a ldh [hLYOverrideEnd], a
ld hl, BG_EFFECT_STRUCT_BATTLE_TURN ld hl, BG_EFFECT_STRUCT_BATTLE_TURN
add hl, bc add hl, bc
ld [hl], $1 ld [hl], $1
@ -2221,11 +2221,11 @@ BattleBGEffect_WobbleMon:
call BattleBGEffects_IncrementJumptable call BattleBGEffects_IncrementJumptable
call BattleBGEffects_ClearLYOverrides call BattleBGEffects_ClearLYOverrides
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, $37 ld a, $37
ld [hLYOverrideEnd], a ldh [hLYOverrideEnd], a
ld hl, BG_EFFECT_STRUCT_03 ld hl, BG_EFFECT_STRUCT_03
add hl, bc add hl, bc
ld [hl], $0 ld [hl], $0
@ -2262,7 +2262,7 @@ BattleBGEffect_2e:
push af push af
call DelayFrame call DelayFrame
pop af pop af
ld [hSCY], a ldh [hSCY], a
xor $ff xor $ff
inc a inc a
ld [wAnimObject01YOffset], a ld [wAnimObject01YOffset], a
@ -2273,7 +2273,7 @@ BattleBGEffect_1f:
jr nc, .skip jr nc, .skip
xor a xor a
.skip .skip
ld [hSCX], a ldh [hSCX], a
ret ret
BattleBGEffect_20: BattleBGEffect_20:
@ -2281,7 +2281,7 @@ BattleBGEffect_20:
jr nc, .skip jr nc, .skip
xor a xor a
.skip .skip
ld [hSCY], a ldh [hSCY], a
ret ret
Functionc8d0b: Functionc8d0b:
@ -2330,7 +2330,7 @@ BattleBGEffect_35:
jr nc, .finish jr nc, .finish
ld d, $6 ld d, $6
call BattleBGEffects_Sine call BattleBGEffects_Sine
ld [hSCX], a ldh [hSCX], a
ld hl, BG_EFFECT_STRUCT_03 ld hl, BG_EFFECT_STRUCT_03
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
@ -2340,7 +2340,7 @@ BattleBGEffect_35:
.finish .finish
xor a xor a
ld [hSCX], a ldh [hSCX], a
ret ret
BattleBGEffect_GetNthDMGPal: BattleBGEffect_GetNthDMGPal:
@ -2367,7 +2367,7 @@ BattleBGEffect_GetNthDMGPal:
ret ret
BGEffect_RapidCyclePals: BGEffect_RapidCyclePals:
ld a, [hCGB] ldh a, [hCGB]
and a and a
jr nz, .cgb jr nz, .cgb
push de push de
@ -2387,9 +2387,9 @@ BGEffect_RapidCyclePals:
call BattleBGEffects_SetLYOverrides call BattleBGEffects_SetLYOverrides
ld a, $47 ld a, $47
call BattleBGEffect_SetLCDStatCustoms1 call BattleBGEffect_SetLCDStatCustoms1
ld a, [hLYOverrideEnd] ldh a, [hLYOverrideEnd]
inc a inc a
ld [hLYOverrideEnd], a ldh [hLYOverrideEnd], a
ld hl, BG_EFFECT_STRUCT_03 ld hl, BG_EFFECT_STRUCT_03
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
@ -2427,7 +2427,7 @@ BGEffect_RapidCyclePals:
.two_dmg .two_dmg
call BattleBGEffects_ResetVideoHRAM call BattleBGEffects_ResetVideoHRAM
ld a, %11100100 ld a, %11100100
ld [rBGP], a ldh [rBGP], a
call EndBattleBGEffect call EndBattleBGEffect
ret ret
@ -2525,10 +2525,10 @@ BGEffect_RapidCyclePals:
BGEffects_LoadBGPal0_OBPal1: BGEffects_LoadBGPal0_OBPal1:
ld h, a ld h, a
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 a, h ld a, h
push bc push bc
push af push af
@ -2545,17 +2545,17 @@ BGEffects_LoadBGPal0_OBPal1:
call CopyPals call CopyPals
pop bc pop bc
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ld a, $1 ld a, $1
ld [hCGBPalUpdate], a ldh [hCGBPalUpdate], a
ret ret
BGEffects_LoadBGPal1_OBPal0: BGEffects_LoadBGPal1_OBPal0:
ld h, a ld h, a
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 a, h ld a, h
push bc push bc
push af push af
@ -2572,9 +2572,9 @@ BGEffects_LoadBGPal1_OBPal0:
call CopyPals call CopyPals
pop bc pop bc
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ld a, $1 ld a, $1
ld [hCGBPalUpdate], a ldh [hCGBPalUpdate], a
ret ret
BattleBGEffect_GetFirstDMGPal: BattleBGEffect_GetFirstDMGPal:
@ -2621,7 +2621,7 @@ BattleBGEffects_SetLYOverrides:
ret ret
BattleBGEffect_SetLCDStatCustoms1: BattleBGEffect_SetLCDStatCustoms1:
ld [hLCDCPointer], a ldh [hLCDCPointer], a
call BGEffect_CheckBattleTurn call BGEffect_CheckBattleTurn
jr nz, .player_turn jr nz, .player_turn
lb de, $00, $36 lb de, $00, $36
@ -2631,13 +2631,13 @@ BattleBGEffect_SetLCDStatCustoms1:
lb de, $2f, $5e lb de, $2f, $5e
.okay .okay
ld a, d ld a, d
ld [hLYOverrideStart], a ldh [hLYOverrideStart], a
ld a, e ld a, e
ld [hLYOverrideEnd], a ldh [hLYOverrideEnd], a
ret ret
BattleBGEffect_SetLCDStatCustoms2: BattleBGEffect_SetLCDStatCustoms2:
ld [hLCDCPointer], a ldh [hLCDCPointer], a
call BGEffect_CheckBattleTurn call BGEffect_CheckBattleTurn
jr nz, .player_turn jr nz, .player_turn
lb de, $00, $36 lb de, $00, $36
@ -2647,30 +2647,30 @@ BattleBGEffect_SetLCDStatCustoms2:
lb de, $2d, $5e lb de, $2d, $5e
.okay .okay
ld a, d ld a, d
ld [hLYOverrideStart], a ldh [hLYOverrideStart], a
ld a, e ld a, e
ld [hLYOverrideEnd], a ldh [hLYOverrideEnd], a
ret ret
BattleAnim_ResetLCDStatCustom: BattleAnim_ResetLCDStatCustom:
xor a xor a
ld [hLYOverrideStart], a ldh [hLYOverrideStart], a
ld [hLYOverrideEnd], a ldh [hLYOverrideEnd], a
call BattleBGEffects_ClearLYOverrides call BattleBGEffects_ClearLYOverrides
xor a xor a
ld [hLCDCPointer], a ldh [hLCDCPointer], a
call EndBattleBGEffect call EndBattleBGEffect
ret ret
BattleBGEffects_ResetVideoHRAM: BattleBGEffects_ResetVideoHRAM:
xor a xor a
ld [hLCDCPointer], a ldh [hLCDCPointer], a
ld a, %11100100 ld a, %11100100
ld [rBGP], a ldh [rBGP], a
ld [wBGP], a ld [wBGP], a
ld [wOBP1], a ld [wOBP1], a
ld [hLYOverrideStart], a ldh [hLYOverrideStart], a
ld [hLYOverrideEnd], a ldh [hLYOverrideEnd], a
call BattleBGEffects_ClearLYOverrides call BattleBGEffects_ClearLYOverrides
ret ret
@ -2686,10 +2686,10 @@ Functionc8f2e:
ld [wBattleAnimTemp3], a ld [wBattleAnimTemp3], a
ld bc, wLYOverridesBackup ld bc, wLYOverridesBackup
.loop .loop
ld a, [hLYOverrideStart] ldh a, [hLYOverrideStart]
cp c cp c
jr nc, .next jr nc, .next
ld a, [hLYOverrideEnd] ldh a, [hLYOverrideEnd]
cp c cp c
jr c, .next jr c, .next
ld a, [wBattleAnimTemp2] ld a, [wBattleAnimTemp2]
@ -2763,14 +2763,14 @@ Functionc8f9a:
call BattleBGEffects_Sine call BattleBGEffects_Sine
ld e, a ld e, a
pop hl pop hl
ld a, [hLYOverrideEnd] ldh a, [hLYOverrideEnd]
cp c cp c
jr c, .skip1 jr c, .skip1
ld a, e ld a, e
ld [bc], a ld [bc], a
inc bc inc bc
.skip1 .skip1
ld a, [hLYOverrideStart] ldh a, [hLYOverrideStart]
cp l cp l
jr nc, .skip2 jr nc, .skip2
ld [hl], e ld [hl], e
@ -2788,7 +2788,7 @@ Functionc8f9a:
ret ret
.GetLYOverrideBackupAddrOffset: .GetLYOverrideBackupAddrOffset:
ld a, [hLYOverrideStart] ldh a, [hLYOverrideStart]
ld e, a ld e, a
ld a, [wBattleAnimTemp0] ld a, [wBattleAnimTemp0]
add e add e
@ -2798,13 +2798,13 @@ Functionc8f9a:
BattleBGEffect_WavyScreenFX: BattleBGEffect_WavyScreenFX:
push bc push bc
ld a, [hLYOverrideStart] ldh a, [hLYOverrideStart]
ld l, a ld l, a
inc a inc a
ld e, a ld e, a
ld h, HIGH(wLYOverridesBackup) ld h, HIGH(wLYOverridesBackup)
ld d, h ld d, h
ld a, [hLYOverrideEnd] ldh a, [hLYOverrideEnd]
sub l sub l
and a and a
jr z, .done jr z, .done
@ -2826,9 +2826,9 @@ BattleBGEffect_WavyScreenFX:
BGEffect_FillLYOverridesBackup: BGEffect_FillLYOverridesBackup:
push af push af
ld h, HIGH(wLYOverridesBackup) ld h, HIGH(wLYOverridesBackup)
ld a, [hLYOverrideStart] ldh a, [hLYOverrideStart]
ld l, a ld l, a
ld a, [hLYOverrideEnd] ldh a, [hLYOverrideEnd]
sub l sub l
ld d, a ld d, a
pop af pop af
@ -2842,14 +2842,14 @@ BGEffect_DisplaceLYOverridesBackup:
; e = a; d = [hLYOverrideEnd] - [hLYOverrideStart] - a ; e = a; d = [hLYOverrideEnd] - [hLYOverrideStart] - a
push af push af
ld e, a ld e, a
ld a, [hLYOverrideStart] ldh a, [hLYOverrideStart]
ld l, a ld l, a
ld a, [hLYOverrideEnd] ldh a, [hLYOverrideEnd]
sub l sub l
sub e sub e
ld d, a ld d, a
ld h, HIGH(wLYOverridesBackup) ld h, HIGH(wLYOverridesBackup)
ld a, [hLYOverrideStart] ldh a, [hLYOverrideStart]
ld l, a ld l, a
ld a, $90 ld a, $90
.loop .loop
@ -2867,7 +2867,7 @@ BGEffect_DisplaceLYOverridesBackup:
BGEffect_CheckBattleTurn: BGEffect_CheckBattleTurn:
ld hl, BG_EFFECT_STRUCT_BATTLE_TURN ld hl, BG_EFFECT_STRUCT_BATTLE_TURN
add hl, bc add hl, bc
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and $1 and $1
xor [hl] xor [hl]
ret ret
@ -2875,7 +2875,7 @@ BGEffect_CheckBattleTurn:
BGEffect_CheckFlyDigStatus: BGEffect_CheckFlyDigStatus:
ld hl, BG_EFFECT_STRUCT_BATTLE_TURN ld hl, BG_EFFECT_STRUCT_BATTLE_TURN
add hl, bc add hl, bc
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and $1 and $1
xor [hl] xor [hl]
jr nz, .player jr nz, .player
@ -2889,7 +2889,7 @@ BGEffect_CheckFlyDigStatus:
ret ret
BattleBGEffects_CheckSGB: BattleBGEffects_CheckSGB:
ld a, [hSGB] ldh a, [hSGB]
and a and a
ret ret

View File

@ -217,7 +217,7 @@ InitBattleAnimBuffer:
ld [wBattleAnimTempXOffset], a ld [wBattleAnimTempXOffset], a
ld a, [hli] ld a, [hli]
ld [wBattleAnimTempYOffset], a ld [wBattleAnimTempYOffset], a
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
ret z ret z
ld hl, BATTLEANIMSTRUCT_01 ld hl, BATTLEANIMSTRUCT_01

View File

@ -425,14 +425,14 @@ BattleAnimFunction_PokeBallBlocked:
GetBallAnimPal: GetBallAnimPal:
ld hl, BallColors ld hl, BallColors
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, BANK(wCurItem) ld a, BANK(wCurItem)
ld [rSVBK], a ldh [rSVBK], a
ld a, [wCurItem] ld a, [wCurItem]
ld e, a ld e, a
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
.IsInArray: .IsInArray:
ld a, [hli] ld a, [hli]
cp -1 cp -1
@ -1138,11 +1138,11 @@ BattleAnimFunction_0D:
.zero .zero
call BattleAnim_IncAnonJumptableIndex call BattleAnim_IncAnonJumptableIndex
ld a, rSCY - $ff00 ld a, rSCY - $ff00
ld [hLCDCPointer], a ldh [hLCDCPointer], a
ld a, $58 ld a, $58
ld [hLYOverrideStart], a ldh [hLYOverrideStart], a
ld a, $5e ld a, $5e
ld [hLYOverrideEnd], a ldh [hLYOverrideEnd], a
ret ret
.one .one
@ -1156,7 +1156,7 @@ BattleAnimFunction_0D:
jr nc, .asm_cd69b jr nc, .asm_cd69b
call BattleAnim_IncAnonJumptableIndex call BattleAnim_IncAnonJumptableIndex
xor a xor a
ld [hLYOverrideStart], a ldh [hLYOverrideStart], a
ret ret
.asm_cd69b .asm_cd69b
@ -1175,7 +1175,7 @@ BattleAnimFunction_0D:
add [hl] add [hl]
sub $10 sub $10
ret c ret c
ld [hLYOverrideStart], a ldh [hLYOverrideStart], a
ld hl, BATTLEANIMSTRUCT_XOFFSET ld hl, BATTLEANIMSTRUCT_XOFFSET
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
@ -1196,9 +1196,9 @@ BattleAnimFunction_0D:
cp $70 cp $70
jr c, asm_cd6da jr c, asm_cd6da
xor a xor a
ld [hLCDCPointer], a ldh [hLCDCPointer], a
ld [hLYOverrideStart], a ldh [hLYOverrideStart], a
ld [hLYOverrideEnd], a ldh [hLYOverrideEnd], a
.four .four
call DeinitBattleAnimation call DeinitBattleAnimation
ret ret
@ -1209,7 +1209,7 @@ asm_cd6da:
ld [hl], a ld [hl], a
sub $10 sub $10
ret c ret c
ld [hLYOverrideStart], a ldh [hLYOverrideStart], a
ret ret
BattleAnimFunction_0E: BattleAnimFunction_0E:
@ -2252,7 +2252,7 @@ BattleAnimFunction_21:
dw Functioncdced dw Functioncdced
Functioncdcca: Functioncdcca:
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr z, .asm_cdcd9 jr z, .asm_cdcd9
ld hl, BATTLEANIMSTRUCT_0B ld hl, BATTLEANIMSTRUCT_0B
@ -3227,7 +3227,7 @@ BattleAnimFunction_32:
Functionce260: Functionce260:
call BattleAnim_IncAnonJumptableIndex call BattleAnim_IncAnonJumptableIndex
ld a, [hBattleTurn] ldh a, [hBattleTurn]
and a and a
jr nz, .asm_ce26c jr nz, .asm_ce26c
ld a, $f0 ld a, $f0
@ -3280,7 +3280,7 @@ Functionce29f:
srl a srl a
ld e, a ld e, a
ld d, $0 ld d, $0
ld a, [hSGB] ldh a, [hSGB]
and a and a
jr nz, .asm_ce2b6 jr nz, .asm_ce2b6
ld hl, Unknown_ce2c4 ld hl, Unknown_ce2c4

View File

@ -4,12 +4,12 @@ GetPokeBallWobble:
push de push de
ld a, [rSVBK] ldh a, [rSVBK]
ld d, a ld d, a
push de push de
ld a, BANK(wBuffer2) ld a, BANK(wBuffer2)
ld [rSVBK], a ldh [rSVBK], a
ld a, [wBuffer2] ld a, [wBuffer2]
inc a inc a
@ -54,7 +54,7 @@ GetPokeBallWobble:
pop de pop de
ld e, a ld e, a
ld a, d ld a, d
ld [rSVBK], a ldh [rSVBK], a
ld a, e ld a, e
pop de pop de
ret ret

View File

@ -10,10 +10,10 @@ Function1700ba:
ret ret
Function1700c4: Function1700c4:
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, $3 ld a, $3
ld [rSVBK], a ldh [rSVBK], a
call Function17042c call Function17042c
@ -47,7 +47,7 @@ Function1700c4:
call CopyBytes call CopyBytes
call CloseSRAM call CloseSRAM
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ret ret
Function170114: Function170114:
@ -556,10 +556,10 @@ INCLUDE "data/battle_tower/unknown_levels.asm"
CopyBTTrainer_FromBT_OT_TowBT_OTTemp: CopyBTTrainer_FromBT_OT_TowBT_OTTemp:
; copy the BattleTower-Trainer data that lies at 'wBT_OTTrainer' to 'wBT_OTTemp' ; copy the BattleTower-Trainer data that lies at 'wBT_OTTrainer' to 'wBT_OTTemp'
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, BANK(wBT_OTTrainer) ld a, BANK(wBT_OTTrainer)
ld [rSVBK], a ldh [rSVBK], a
ld hl, wBT_OTTrainer ld hl, wBT_OTTrainer
ld de, wBT_OTTemp ld de, wBT_OTTemp
@ -567,7 +567,7 @@ CopyBTTrainer_FromBT_OT_TowBT_OTTemp:
call CopyBytes call CopyBytes
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ld a, BANK(sBattleTowerChallengeState) ld a, BANK(sBattleTowerChallengeState)
call GetSRAMBank call GetSRAMBank
@ -982,7 +982,7 @@ BattleTower_RandomlyChooseReward: ; BattleTowerAction $1e
; Generate a random stat boosting item. ; Generate a random stat boosting item.
.loop .loop
call Random call Random
ld a, [hRandomAdd] ldh a, [hRandomAdd]
and $7 and $7
cp 6 cp 6
jr c, .okay jr c, .okay
@ -1153,28 +1153,28 @@ Function17081d: ; BattleTowerAction $17
SaveBattleTowerLevelGroup: ; BattleTowerAction $07 SaveBattleTowerLevelGroup: ; BattleTowerAction $07
ld a, BANK(sBTChoiceOfLevelGroup) ld a, BANK(sBTChoiceOfLevelGroup)
call GetSRAMBank call GetSRAMBank
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, $3 ld a, $3
ld [rSVBK], a ldh [rSVBK], a
ld a, [wBTChoiceOfLvlGroup] ld a, [wBTChoiceOfLvlGroup]
ld [sBTChoiceOfLevelGroup], a ld [sBTChoiceOfLevelGroup], a
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
call CloseSRAM call CloseSRAM
ret ret
LoadBattleTowerLevelGroup: ; BattleTowerAction $08 ; Load level group choice LoadBattleTowerLevelGroup: ; BattleTowerAction $08 ; Load level group choice
ld a, BANK(sBTChoiceOfLevelGroup) ld a, BANK(sBTChoiceOfLevelGroup)
call GetSRAMBank call GetSRAMBank
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, $3 ld a, $3
ld [rSVBK], a ldh [rSVBK], a
ld a, [sBTChoiceOfLevelGroup] ld a, [sBTChoiceOfLevelGroup]
ld [wBTChoiceOfLvlGroup], a ld [wBTChoiceOfLvlGroup], a
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
call CloseSRAM call CloseSRAM
ret ret
@ -1336,14 +1336,14 @@ String_MysteryJP:
db "なぞナゾ@@" ; MYSTERY db "なぞナゾ@@" ; MYSTERY
Function1709aa: ; BattleTowerAction $0f Function1709aa: ; BattleTowerAction $0f
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, BANK(w3_d090) ld a, BANK(w3_d090)
ld [rSVBK], a ldh [rSVBK], a
ld a, [w3_d090] ld a, [w3_d090]
ld [wScriptVar], a ld [wScriptVar], a
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ret ret
Function1709bb: ; BattleTowerAction $10 Function1709bb: ; BattleTowerAction $10
@ -1557,17 +1557,17 @@ BattleTowerAction_UbersCheck: ; BattleTowerAction $19
LoadOpponentTrainerAndPokemonWithOTSprite: LoadOpponentTrainerAndPokemonWithOTSprite:
farcall Function_LoadOpponentTrainerAndPokemons farcall Function_LoadOpponentTrainerAndPokemons
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, $3 ld a, $3
ld [rSVBK], a ldh [rSVBK], a
ld hl, wBT_OTTrainerClass ld hl, wBT_OTTrainerClass
ld a, [hl] ld a, [hl]
dec a dec a
ld c, a ld c, a
ld b, $0 ld b, $0
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ld hl, BTTrainerClassSprites ld hl, BTTrainerClassSprites
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
@ -1593,9 +1593,9 @@ LoadOpponentTrainerAndPokemonWithOTSprite:
ld hl, wUsedSprites ld hl, wUsedSprites
add hl, de add hl, de
ld [hli], a ld [hli], a
ld [hUsedSpriteIndex], a ldh [hUsedSpriteIndex], a
ld a, [hl] ld a, [hl]
ld [hUsedSpriteTile], a ldh [hUsedSpriteTile], a
farcall GetUsedSprite farcall GetUsedSprite
ret ret

View File

@ -1,8 +1,8 @@
Function_LoadOpponentTrainerAndPokemons: Function_LoadOpponentTrainerAndPokemons:
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, BANK(wBT_OTTrainer) ld a, BANK(wBT_OTTrainer)
ld [rSVBK], a ldh [rSVBK], a
; Fill wBT_OTTrainer with zeros ; Fill wBT_OTTrainer with zeros
xor a xor a
@ -19,11 +19,11 @@ Function_LoadOpponentTrainerAndPokemons:
; Set wBT_OTTrainer as start address to write the following data to ; Set wBT_OTTrainer as start address to write the following data to
ld de, wBT_OTTrainer ld de, wBT_OTTrainer
ld a, [hRandomAdd] ldh a, [hRandomAdd]
ld b, a ld b, a
.resample ; loop to find a random trainer .resample ; loop to find a random trainer
call Random call Random
ld a, [hRandomAdd] ldh a, [hRandomAdd]
add b add b
ld b, a ; b contains the nr of the trainer ld b, a ; b contains the nr of the trainer
if DEF(_CRYSTAL11) if DEF(_CRYSTAL11)
@ -87,7 +87,7 @@ endc
jr nz, .copy_bt_trainer_data_loop jr nz, .copy_bt_trainer_data_loop
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ret ret
@ -107,11 +107,11 @@ Function_LoadRandomBattleTowerMon:
ld bc, BattleTowerMons2 - BattleTowerMons1 ; size of one level group ld bc, BattleTowerMons2 - BattleTowerMons1 ; size of one level group
call AddNTimes call AddNTimes
ld a, [hRandomAdd] ldh a, [hRandomAdd]
ld b, a ld b, a
.resample .resample
call Random call Random
ld a, [hRandomAdd] ldh a, [hRandomAdd]
add b add b
ld b, a ld b, a
maskbits BATTLETOWER_NUM_UNIQUE_MON maskbits BATTLETOWER_NUM_UNIQUE_MON

View File

@ -3,10 +3,10 @@ BattleTowerText::
; 1: Intro text ; 1: Intro text
; 2: Player lost ; 2: Player lost
; 3: Player won ; 3: Player won
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, BANK(wBT_OTTrainerClass) ld a, BANK(wBT_OTTrainerClass)
ld [rSVBK], a ldh [rSVBK], a
if DEF(_CRYSTAL11) if DEF(_CRYSTAL11)
ld hl, wBT_OTTrainerClass ld hl, wBT_OTTrainerClass
else else
@ -28,7 +28,7 @@ endc
and a and a
jr nz, .female jr nz, .female
; generate a random number between 0 and 24 ; generate a random number between 0 and 24
ld a, [hRandomAdd] ldh a, [hRandomAdd]
and $1f and $1f
cp 25 cp 25
jr c, .okay0 jr c, .okay0
@ -40,7 +40,7 @@ endc
.female .female
; generate a random number between 0 and 14 ; generate a random number between 0 and 14
ld a, [hRandomAdd] ldh a, [hRandomAdd]
and $f and $f
cp 15 cp 15
jr c, .okay1 jr c, .okay1
@ -80,7 +80,7 @@ endc
ld h, a ld h, a
bccoord 1, 14 bccoord 1, 14
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
call PlaceHLTextAtBC call PlaceHLTextAtBC
ret ret

View File

@ -188,7 +188,7 @@ PrintBlueCardBalance:
.DrawBox: .DrawBox:
push de push de
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
ld hl, BlueCardBalanceMenuHeader ld hl, BlueCardBalanceMenuHeader
call CopyMenuHeader call CopyMenuHeader
call MenuBox call MenuBox
@ -232,7 +232,7 @@ Buena_PrizeMenu:
ld [wMenuCursorBuffer], a ld [wMenuCursorBuffer], a
xor a xor a
ld [wWhichIndexSet], a ld [wWhichIndexSet], a
ld [hBGMapMode], a ldh [hBGMapMode], a
call InitScrollingMenu call InitScrollingMenu
call UpdateSprites call UpdateSprites
call ScrollingMenu call ScrollingMenu

View File

@ -43,16 +43,16 @@ AskRememberPassword:
ret ret
Buena_ExitMenu: Buena_ExitMenu:
ld a, [hOAMUpdate] ldh a, [hOAMUpdate]
push af push af
call ExitMenu call ExitMenu
call UpdateSprites call UpdateSprites
xor a xor a
ld [hOAMUpdate], a ldh [hOAMUpdate], a
call DelayFrame call DelayFrame
ld a, $1 ld a, $1
ld [hOAMUpdate], a ldh [hOAMUpdate], a
call ApplyTilemap call ApplyTilemap
pop af pop af
ld [hOAMUpdate], a ldh [hOAMUpdate], a
ret ret

View File

@ -150,9 +150,9 @@ BugContest_JudgeContestants:
ld [hli], a ld [hli], a
ld a, [wContestMon] ld a, [wContestMon]
ld [hli], a ld [hli], a
ld a, [hProduct] ldh a, [hProduct]
ld [hli], a ld [hli], a
ld a, [hProduct + 1] ldh a, [hProduct + 1]
ld [hl], a ld [hl], a
call DetermineContestWinners call DetermineContestWinners
ret ret
@ -287,8 +287,8 @@ ContestScore:
; Determine the player's score in the Bug Catching Contest. ; Determine the player's score in the Bug Catching Contest.
xor a xor a
ld [hProduct], a ldh [hProduct], a
ld [hMultiplicand], a ldh [hMultiplicand], a
ld a, [wContestMonSpecies] ; Species ld a, [wContestMonSpecies] ; Species
and a and a

View File

@ -31,8 +31,8 @@ CatchTutorial::
call .LoadDudeData call .LoadDudeData
xor a xor a
ld [hJoyDown], a ldh [hJoyDown], a
ld [hJoyPressed], a ldh [hJoyPressed], a
ld a, [wOptions] ld a, [wOptions]
push af push af
and $f8 and $f8

View File

@ -656,11 +656,11 @@ DayCare_InitBreeding:
ld d, a ld d, a
callfar CalcExpAtLevel callfar CalcExpAtLevel
ld hl, wEggMonExp ld hl, wEggMonExp
ld a, [hMultiplicand] ldh a, [hMultiplicand]
ld [hli], a ld [hli], a
ld a, [hMultiplicand + 1] ldh a, [hMultiplicand + 1]
ld [hli], a ld [hli], a
ld a, [hMultiplicand + 2] ldh a, [hMultiplicand + 2]
ld [hl], a ld [hl], a
xor a xor a
ld b, wEggMonDVs - wEggMonStatExp ld b, wEggMonDVs - wEggMonStatExp

View File

@ -62,7 +62,7 @@ ShakeHeadbuttTree:
call OverworldTextModeSwitch call OverworldTextModeSwitch
call WaitBGMap call WaitBGMap
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
farcall ClearSpriteAnims farcall ClearSpriteAnims
ld hl, wVirtualOAMSprite36 ld hl, wVirtualOAMSprite36
ld bc, wVirtualOAMEnd - wVirtualOAMSprite36 ld bc, wVirtualOAMEnd - wVirtualOAMSprite36
@ -80,7 +80,7 @@ INCBIN "gfx/overworld/headbutt_tree.2bpp"
HideHeadbuttTree: HideHeadbuttTree:
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
ld a, [wPlayerDirection] ld a, [wPlayerDirection]
and %00001100 and %00001100
srl a srl a
@ -101,7 +101,7 @@ HideHeadbuttTree:
ld [hld], a ld [hld], a
call WaitBGMap call WaitBGMap
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
ret ret
TreeRelativeLocationTable: TreeRelativeLocationTable:
@ -205,7 +205,7 @@ Cut_SpawnAnimateLeaves:
Cut_StartWaiting: Cut_StartWaiting:
ld a, $1 ld a, $1
ld [hBGMapMode], a ldh [hBGMapMode], a
; Cut_WaitAnimSFX ; Cut_WaitAnimSFX
ld hl, wJumptableIndex ld hl, wJumptableIndex
inc [hl] inc [hl]

View File

@ -1,8 +1,8 @@
LoadFishingGFX: LoadFishingGFX:
ld a, [rVBK] ldh a, [rVBK]
push af push af
ld a, $1 ld a, $1
ld [rVBK], a ldh [rVBK], a
ld de, FishingGFX ld de, FishingGFX
ld a, [wPlayerGender] ld a, [wPlayerGender]
@ -21,7 +21,7 @@ LoadFishingGFX:
call .LoadGFX call .LoadGFX
pop af pop af
ld [rVBK], a ldh [rVBK], a
ret ret
.LoadGFX: .LoadGFX:

View File

@ -44,7 +44,7 @@ RedCredits::
farcall FadeOutPalettes farcall FadeOutPalettes
xor a xor a
ld [wVramState], a ld [wVramState], a
ld [hMapAnims], a ldh [hMapAnims], a
farcall InitDisplayForRedCredits farcall InitDisplayForRedCredits
ld c, 8 ld c, 8
call DelayFrames call DelayFrames
@ -66,7 +66,7 @@ HallOfFame_FadeOutMusic:
farcall FadeOutPalettes farcall FadeOutPalettes
xor a xor a
ld [wVramState], a ld [wVramState], a
ld [hMapAnims], a ldh [hMapAnims], a
farcall InitDisplayForHallOfFame farcall InitDisplayForHallOfFame
ld c, 100 ld c, 100
jp DelayFrames jp DelayFrames
@ -243,17 +243,17 @@ AnimateHOFMonEntrance:
ld de, vTiles2 tile $31 ld de, vTiles2 tile $31
predef GetMonBackpic predef GetMonBackpic
ld a, $31 ld a, $31
ld [hGraphicStartTile], a ldh [hGraphicStartTile], a
hlcoord 6, 6 hlcoord 6, 6
lb bc, 6, 6 lb bc, 6, 6
predef PlaceGraphic predef PlaceGraphic
ld a, $d0 ld a, $d0
ld [hSCY], a ldh [hSCY], a
ld a, $90 ld a, $90
ld [hSCX], a ldh [hSCX], a
call WaitBGMap call WaitBGMap
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
ld b, SCGB_PLAYER_OR_MON_FRONTPIC_PALS ld b, SCGB_PLAYER_OR_MON_FRONTPIC_PALS
call GetSGBLayout call GetSGBLayout
call SetPalettes call SetPalettes
@ -268,29 +268,29 @@ AnimateHOFMonEntrance:
call _PrepMonFrontpic call _PrepMonFrontpic
call WaitBGMap call WaitBGMap
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
ld [hSCY], a ldh [hSCY], a
call HOF_SlideFrontpic call HOF_SlideFrontpic
ret ret
HOF_SlideBackpic: HOF_SlideBackpic:
.backpicloop .backpicloop
ld a, [hSCX] ldh a, [hSCX]
cp $70 cp $70
ret z ret z
add $4 add $4
ld [hSCX], a ldh [hSCX], a
call DelayFrame call DelayFrame
jr .backpicloop jr .backpicloop
HOF_SlideFrontpic: HOF_SlideFrontpic:
.frontpicloop .frontpicloop
ld a, [hSCX] ldh a, [hSCX]
and a and a
ret z ret z
dec a dec a
dec a dec a
ld [hSCX], a ldh [hSCX], a
call DelayFrame call DelayFrame
jr .frontpicloop jr .frontpicloop
@ -432,7 +432,7 @@ LoadHOFTeam:
DisplayHOFMon: DisplayHOFMon:
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
ld a, [hli] ld a, [hli]
ld [wTempMonSpecies], a ld [wTempMonSpecies], a
ld a, [hli] ld a, [hli]
@ -528,17 +528,17 @@ HOF_AnimatePlayerPic:
call ByteFill call ByteFill
farcall GetPlayerBackpic farcall GetPlayerBackpic
ld a, $31 ld a, $31
ld [hGraphicStartTile], a ldh [hGraphicStartTile], a
hlcoord 6, 6 hlcoord 6, 6
lb bc, 6, 6 lb bc, 6, 6
predef PlaceGraphic predef PlaceGraphic
ld a, $d0 ld a, $d0
ld [hSCY], a ldh [hSCY], a
ld a, $90 ld a, $90
ld [hSCX], a ldh [hSCX], a
call WaitBGMap call WaitBGMap
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
ld [wCurPartySpecies], a ld [wCurPartySpecies], a
ld b, SCGB_PLAYER_OR_MON_FRONTPIC_PALS ld b, SCGB_PLAYER_OR_MON_FRONTPIC_PALS
call GetSGBLayout call GetSGBLayout
@ -552,19 +552,19 @@ HOF_AnimatePlayerPic:
call ByteFill call ByteFill
farcall HOF_LoadTrainerFrontpic farcall HOF_LoadTrainerFrontpic
xor a xor a
ld [hGraphicStartTile], a ldh [hGraphicStartTile], a
hlcoord 12, 5 hlcoord 12, 5
lb bc, 7, 7 lb bc, 7, 7
predef PlaceGraphic predef PlaceGraphic
ld a, $c0 ld a, $c0
ld [hSCX], a ldh [hSCX], a
call WaitBGMap call WaitBGMap
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
ld [hSCY], a ldh [hSCY], a
call HOF_SlideFrontpic call HOF_SlideFrontpic
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
hlcoord 0, 2 hlcoord 0, 2
lb bc, 8, 9 lb bc, 8, 9
call TextBox call TextBox

View File

@ -18,7 +18,7 @@ HealMachineAnim:
; 2: Up (Hall of Fame) ; 2: Up (Hall of Fame)
ld a, [wScriptVar] ld a, [wScriptVar]
ld [wBuffer1], a ld [wBuffer1], a
ld a, [rOBP1] ldh a, [rOBP1]
ld [wBuffer2], a ld [wBuffer2], a
call .DoJumptableFunctions call .DoJumptableFunctions
ld a, [wBuffer2] ld a, [wBuffer2]
@ -158,7 +158,7 @@ INCBIN "gfx/overworld/heal_machine.2bpp"
call IsCGB call IsCGB
jr nz, .cgb jr nz, .cgb
ld a, %11100000 ld a, %11100000
ld [rOBP1], a ldh [rOBP1], a
ret ret
.cgb .cgb
@ -168,7 +168,7 @@ INCBIN "gfx/overworld/heal_machine.2bpp"
ld a, BANK(wOBPals2) ld a, BANK(wOBPals2)
call FarCopyWRAM call FarCopyWRAM
ld a, $1 ld a, $1
ld [hCGBPalUpdate], a ldh [hCGBPalUpdate], a
ret ret
.palettes .palettes
@ -189,16 +189,16 @@ INCLUDE "gfx/overworld/heal_machine.pal"
.FlashPalettes: .FlashPalettes:
call IsCGB call IsCGB
jr nz, .go jr nz, .go
ld a, [rOBP1] ldh a, [rOBP1]
xor %00101000 xor %00101000
ld [rOBP1], a ldh [rOBP1], a
ret ret
.go .go
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, BANK(wOBPals2) ld a, BANK(wOBPals2)
ld [rSVBK], a ldh [rSVBK], a
ld hl, wOBPals2 palette PAL_OW_TREE ld hl, wOBPals2 palette PAL_OW_TREE
ld a, [hli] ld a, [hli]
@ -230,9 +230,9 @@ INCLUDE "gfx/overworld/heal_machine.pal"
ld [hl], a ld [hl], a
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ld a, $1 ld a, $1
ld [hCGBPalUpdate], a ldh [hCGBPalUpdate], a
ret ret
.PlaceHealingMachineTile: .PlaceHealingMachineTile:

View File

@ -59,7 +59,7 @@ Kurt_SelectApricorn:
ld a, [wMenuSelection] ld a, [wMenuSelection]
ld [wMenuCursorBuffer], a ld [wMenuCursorBuffer], a
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
call InitScrollingMenu call InitScrollingMenu
call UpdateSprites call UpdateSprites
call ScrollingMenu call ScrollingMenu
@ -124,7 +124,7 @@ Kurt_SelectQuantity:
call LoadMenuHeader call LoadMenuHeader
.loop .loop
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
call MenuBox call MenuBox
call UpdateSprites call UpdateSprites
call .PlaceApricornName call .PlaceApricornName

View File

@ -198,30 +198,30 @@ CalcMagikarpLength:
; c = (bc - de) / [hl] ; c = (bc - de) / [hl]
call .BCMinusDE call .BCMinusDE
ld a, b ld a, b
ld [hDividend + 0], a ldh [hDividend + 0], a
ld a, c ld a, c
ld [hDividend + 1], a ldh [hDividend + 1], a
ld a, [hl] ld a, [hl]
ld [hDivisor], a ldh [hDivisor], 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
; de = c + 100 × (2 + i) ; de = c + 100 × (2 + i)
xor a xor a
ld [hMultiplicand + 0], a ldh [hMultiplicand + 0], a
ld [hMultiplicand + 1], a ldh [hMultiplicand + 1], a
ld a, 100 ld a, 100
ld [hMultiplicand + 2], a ldh [hMultiplicand + 2], a
ld a, [wTempByteValue] ld a, [wTempByteValue]
ld [hMultiplier], a ldh [hMultiplier], a
call Multiply call Multiply
ld b, 0 ld b, 0
ld a, [hProduct + 3] ldh a, [hProduct + 3]
add c add c
ld e, a ld e, a
ld a, [hProduct + 2] ldh a, [hProduct + 2]
adc b adc b
ld d, a ld d, a
jr .done jr .done

View File

@ -14,10 +14,10 @@ MagnetTrain:
.continue .continue
ld h, a ld h, a
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, BANK(wMagnetTrain) ld a, BANK(wMagnetTrain)
ld [rSVBK], a ldh [rSVBK], a
ld a, h ld a, h
ld [wMagnetTrainDirection], a ld [wMagnetTrainDirection], a
@ -30,9 +30,9 @@ MagnetTrain:
ld a, d ld a, d
ld [wMagnetTrainPlayerSpriteInitX], a ld [wMagnetTrainPlayerSpriteInitX], a
ld a, [hSCX] ldh a, [hSCX]
push af push af
ld a, [hSCY] ldh a, [hSCY]
push af push af
call MagntTrain_LoadGFX_PlayMusic call MagntTrain_LoadGFX_PlayMusic
ld hl, hVBlank ld hl, hVBlank
@ -58,13 +58,13 @@ MagnetTrain:
.done .done
pop af pop af
ld [hVBlank], a ldh [hVBlank], a
call ClearBGPalettes call ClearBGPalettes
xor a xor a
ld [hLCDCPointer], a ldh [hLCDCPointer], a
ld [hLYOverrideStart], a ldh [hLYOverrideStart], a
ld [hLYOverrideEnd], a ldh [hLYOverrideEnd], a
ld [hSCX], a ldh [hSCX], a
ld [wRequested2bppSource], a ld [wRequested2bppSource], a
ld [wRequested2bppSource + 1], a ld [wRequested2bppSource + 1], a
ld [wRequested2bppDest], a ld [wRequested2bppDest], a
@ -73,13 +73,13 @@ MagnetTrain:
call ClearTileMap call ClearTileMap
pop af pop af
ld [hSCY], a ldh [hSCY], a
pop af pop af
ld [hSCX], a ldh [hSCX], a
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ret ret
MagnetTrain_UpdateLYOverrides: MagnetTrain_UpdateLYOverrides:
@ -87,7 +87,7 @@ MagnetTrain_UpdateLYOverrides:
ld c, $2f ld c, $2f
ld a, [wMagnetTrainOffset] ld a, [wMagnetTrainOffset]
add a add a
ld [hSCX], a ldh [hSCX], a
call .loadloop call .loadloop
ld c, $30 ld c, $30
ld a, [wMagnetTrainPosition] ld a, [wMagnetTrainPosition]
@ -119,19 +119,19 @@ MagntTrain_LoadGFX_PlayMusic:
call SetMagnetTrainPals call SetMagnetTrainPals
call DrawMagnetTrain call DrawMagnetTrain
ld a, $90 ld a, $90
ld [hWY], a ldh [hWY], a
call EnableLCD call EnableLCD
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
ld [hSCX], a ldh [hSCX], a
ld [hSCY], a ldh [hSCY], a
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, BANK(wPlayerGender) ld a, BANK(wPlayerGender)
ld [rSVBK], a ldh [rSVBK], a
farcall GetPlayerIcon farcall GetPlayerIcon
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ld hl, vTiles0 ld hl, vTiles0
ld c, 4 ld c, 4
call Request2bpp call Request2bpp
@ -243,12 +243,12 @@ MagnetTrain_InitLYOverrides:
ld a, [wMagnetTrainInitPosition] ld a, [wMagnetTrainInitPosition]
call ByteFill call ByteFill
ld a, rSCX - $ff00 ld a, rSCX - $ff00
ld [hLCDCPointer], a ldh [hLCDCPointer], a
ret ret
SetMagnetTrainPals: SetMagnetTrainPals:
ld a, $1 ld a, $1
ld [rVBK], a ldh [rVBK], a
; bushes ; bushes
hlbgcoord 0, 0 hlbgcoord 0, 0
@ -275,7 +275,7 @@ SetMagnetTrainPals:
call ByteFill call ByteFill
ld a, $0 ld a, $0
ld [rVBK], a ldh [rVBK], a
ret ret
MagnetTrain_Jumptable: MagnetTrain_Jumptable:
@ -309,10 +309,10 @@ MagnetTrain_Jumptable:
ld a, [wMagnetTrainPlayerSpriteInitX] ld a, [wMagnetTrainPlayerSpriteInitX]
ld e, a ld e, a
ld b, SPRITE_ANIM_INDEX_MAGNET_TRAIN_RED ld b, SPRITE_ANIM_INDEX_MAGNET_TRAIN_RED
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, BANK(wPlayerGender) ld a, BANK(wPlayerGender)
ld [rSVBK], a ldh [rSVBK], a
ld a, [wPlayerGender] ld a, [wPlayerGender]
bit PLAYERGENDER_FEMALE_F, a bit PLAYERGENDER_FEMALE_F, a
jr z, .got_gender jr z, .got_gender
@ -320,7 +320,7 @@ MagnetTrain_Jumptable:
.got_gender .got_gender
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ld a, b ld a, b
call _InitSpriteAnimStruct call _InitSpriteAnimStruct
ld hl, SPRITEANIMSTRUCT_TILE_ID ld hl, SPRITEANIMSTRUCT_TILE_ID
@ -408,10 +408,10 @@ MagnetTrain_Jumptable_FirstRunThrough:
call MagnetTrain_UpdateLYOverrides call MagnetTrain_UpdateLYOverrides
call PushLYOverrides call PushLYOverrides
call DelayFrame call DelayFrame
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, BANK(wEnvironment) ld a, BANK(wEnvironment)
ld [rSVBK], a ldh [rSVBK], a
ld a, [wTimeOfDayPal] ld a, [wTimeOfDayPal]
push af push af
ld a, [wEnvironment] ld a, [wEnvironment]
@ -424,18 +424,18 @@ MagnetTrain_Jumptable_FirstRunThrough:
ld b, SCGB_MAPPALS ld b, SCGB_MAPPALS
call GetSGBLayout call GetSGBLayout
call UpdateTimePals call UpdateTimePals
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
pop af pop af
ld [wEnvironment], a ld [wEnvironment], a
pop af pop af
ld [wTimeOfDayPal], a ld [wTimeOfDayPal], a
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ret ret
MagnetTrainTilemap1: MagnetTrainTilemap1:

View File

@ -2,7 +2,7 @@ MAP_NAME_SIGN_START EQU $60
ReturnFromMapSetupScript:: ReturnFromMapSetupScript::
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
farcall .inefficient_farcall ; this is a waste of 6 ROM bytes and 6 stack bytes farcall .inefficient_farcall ; this is a waste of 6 ROM bytes and 6 stack bytes
ret ret
@ -51,10 +51,10 @@ ReturnFromMapSetupScript::
ld a, [wCurrentLandmark] ld a, [wCurrentLandmark]
ld [wPreviousLandmark], a ld [wPreviousLandmark], a
ld a, $90 ld a, $90
ld [rWY], a ldh [rWY], a
ld [hWY], a ldh [hWY], a
xor a xor a
ld [hLCDCPointer], a ldh [hLCDCPointer], a
ret ret
.CheckMovingWithinLandmark: .CheckMovingWithinLandmark:
@ -112,16 +112,16 @@ PlaceMapNameSign::
.skip2 .skip2
ld a, $80 ld a, $80
ld a, $70 ld a, $70
ld [rWY], a ldh [rWY], a
ld [hWY], a ldh [hWY], a
ret ret
.disappear .disappear
ld a, $90 ld a, $90
ld [rWY], a ldh [rWY], a
ld [hWY], a ldh [hWY], a
xor a xor a
ld [hLCDCPointer], a ldh [hLCDCPointer], a
ret ret
LoadMapNameSignGFX: LoadMapNameSignGFX:

View File

@ -1,8 +1,8 @@
BankOfMom: BankOfMom:
ld a, [hInMenu] ldh a, [hInMenu]
push af push af
ld a, $1 ld a, $1
ld [hInMenu], a ldh [hInMenu], a
xor a xor a
ld [wJumptableIndex], a ld [wJumptableIndex], a
.loop .loop
@ -14,7 +14,7 @@ BankOfMom:
.done .done
pop af pop af
ld [hInMenu], a ldh [hInMenu], a
ret ret
.RunJumptable: .RunJumptable:
@ -295,7 +295,7 @@ DSTChecks:
; check the time; avoid changing DST if doing so would change the current day ; check the time; avoid changing DST if doing so would change the current day
ld a, [wDST] ld a, [wDST]
bit 7, a bit 7, a
ld a, [hHours] ldh a, [hHours]
jr z, .NotDST jr z, .NotDST
and a ; within one hour of 00:00? and a ; within one hour of 00:00?
jr z, .LostBooklet jr z, .LostBooklet
@ -429,7 +429,7 @@ Mom_SetUpDepositMenu:
Mom_ContinueMenuSetup: Mom_ContinueMenuSetup:
push de push de
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
hlcoord 0, 0 hlcoord 0, 0
lb bc, 6, 18 lb bc, 6, 18
call TextBox call TextBox
@ -475,7 +475,7 @@ Mom_WithdrawDepositMenuJoypad:
jr nz, .pressedA jr nz, .pressedA
call .dpadaction call .dpadaction
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
hlcoord 12, 6 hlcoord 12, 6
ld bc, 7 ld bc, 7
ld a, " " ld a, " "
@ -484,7 +484,7 @@ Mom_WithdrawDepositMenuJoypad:
ld de, wStringBuffer2 ld de, wStringBuffer2
lb bc, PRINTNUM_MONEY | PRINTNUM_LEADINGZEROS | 3, 6 lb bc, PRINTNUM_MONEY | PRINTNUM_LEADINGZEROS | 3, 6
call PrintNum call PrintNum
ld a, [hVBlankCounter] ldh a, [hVBlankCounter]
and $10 and $10
jr nz, .skip jr nz, .skip
hlcoord 13, 6 hlcoord 13, 6

View File

@ -61,11 +61,11 @@ CheckBalance_MomItem2:
jr nc, .nope jr nc, .nope
call GetItemFromMom call GetItemFromMom
ld a, [hli] ld a, [hli]
ld [hMoneyTemp], a ldh [hMoneyTemp], a
ld a, [hli] ld a, [hli]
ld [hMoneyTemp + 1], a ldh [hMoneyTemp + 1], a
ld a, [hli] ld a, [hli]
ld [hMoneyTemp + 2], a ldh [hMoneyTemp + 2], a
ld de, wMomsMoney ld de, wMomsMoney
ld bc, hMoneyTemp ld bc, hMoneyTemp
farcall CompareMoney farcall CompareMoney
@ -118,11 +118,11 @@ MomBuysItem_DeductFunds:
ld de, 3 ; cost ld de, 3 ; cost
add hl, de add hl, de
ld a, [hli] ld a, [hli]
ld [hMoneyTemp], a ldh [hMoneyTemp], a
ld a, [hli] ld a, [hli]
ld [hMoneyTemp + 1], a ldh [hMoneyTemp + 1], a
ld a, [hli] ld a, [hli]
ld [hMoneyTemp + 2], a ldh [hMoneyTemp + 2], a
ld de, wMomsMoney ld de, wMomsMoney
ld bc, hMoneyTemp ld bc, hMoneyTemp
farcall TakeMoney farcall TakeMoney

View File

@ -23,13 +23,13 @@ _GiveOddEgg:
.not_done .not_done
; Break when [hRandom] <= de. ; Break when [hRandom] <= de.
ld a, [hRandom + 1] ldh a, [hRandom + 1]
cp d cp d
jr c, .done jr c, .done
jr z, .ok jr z, .ok
jr .next jr .next
.ok .ok
ld a, [hRandom + 0] ldh a, [hRandom + 0]
cp e cp e
jr c, .done jr c, .done
jr z, .done jr z, .done

View File

@ -226,7 +226,7 @@ CutDownTreeOrGrass:
ld a, [wBuffer5] ; ReplacementTile ld a, [wBuffer5] ; ReplacementTile
ld [hl], a ld [hl], a
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
call OverworldTextModeSwitch call OverworldTextModeSwitch
call UpdateSprites call UpdateSprites
call DelayFrame call DelayFrame
@ -575,7 +575,7 @@ FlyFunction:
.outdoors .outdoors
xor a xor a
ld [hMapAnims], a ldh [hMapAnims], a
call LoadStandardMenuHeader call LoadStandardMenuHeader
call ClearSprites call ClearSprites
farcall _FlyMap farcall _FlyMap
@ -1199,7 +1199,7 @@ DisappearWhirlpool:
ld a, [wBuffer5] ld a, [wBuffer5]
ld [hl], a ld [hl], a
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
call OverworldTextModeSwitch call OverworldTextModeSwitch
ld a, [wBuffer6] ld a, [wBuffer6]
ld e, a ld e, a
@ -1360,12 +1360,12 @@ GetFacingObject:
farcall CheckFacingObject farcall CheckFacingObject
jr nc, .fail jr nc, .fail
ld a, [hObjectStructIndexBuffer] ldh a, [hObjectStructIndexBuffer]
call GetObjectStruct call GetObjectStruct
ld hl, OBJECT_MAP_OBJECT_INDEX ld hl, OBJECT_MAP_OBJECT_INDEX
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
ld [hLastTalked], a ldh [hLastTalked], a
call GetMapObject call GetMapObject
ld hl, MAPOBJECT_MOVEMENT ld hl, MAPOBJECT_MOVEMENT
add hl, bc add hl, bc
@ -1623,7 +1623,7 @@ MovementData_0xd093:
PutTheRodAway: PutTheRodAway:
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
ld a, $1 ld a, $1
ld [wPlayerAction], a ld [wPlayerAction], a
call UpdateSprites call UpdateSprites

View File

@ -1,12 +1,12 @@
LoadPoisonBGPals: LoadPoisonBGPals:
call .LoadPals call .LoadPals
ld a, [hCGB] ldh a, [hCGB]
and a and a
ret nz ret nz
ret ; ???? ret ; ????
.LoadPals: .LoadPals:
ld a, [hCGB] ldh a, [hCGB]
and a and a
jr nz, .cgb jr nz, .cgb
ld a, [wTimeOfDayPal] ld a, [wTimeOfDayPal]
@ -24,10 +24,10 @@ LoadPoisonBGPals:
ret ret
.cgb .cgb
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, BANK(wBGPals2) ld a, BANK(wBGPals2)
ld [rSVBK], a ldh [rSVBK], a
ld hl, wBGPals2 ld hl, wBGPals2
ld c, 4 palettes ld c, 4 palettes
.loop .loop
@ -38,9 +38,9 @@ LoadPoisonBGPals:
dec c dec c
jr nz, .loop jr nz, .loop
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ld a, $1 ld a, $1
ld [hCGBPalUpdate], a ldh [hCGBPalUpdate], a
ld c, 4 ld c, 4
call DelayFrames call DelayFrames
farcall _UpdateTimePals farcall _UpdateTimePals

View File

@ -10,7 +10,7 @@ PokemonCenterPC:
call LoadMenuHeader call LoadMenuHeader
.loop .loop
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
call .ChooseWhichPCListToUse call .ChooseWhichPCListToUse
ld [wWhichIndexSet], a ld [wWhichIndexSet], a
call DoNthMenu call DoNthMenu
@ -360,7 +360,7 @@ PlayerWithdrawItemMenu:
ld hl, .WithdrewText ld hl, .WithdrewText
call MenuTextBox call MenuTextBox
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
call ExitMenu call ExitMenu
ret ret

View File

@ -7,7 +7,7 @@ Pokepic::
ld b, SCGB_POKEPIC ld b, SCGB_POKEPIC
call GetSGBLayout call GetSGBLayout
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
ld a, [wCurPartySpecies] ld a, [wCurPartySpecies]
ld [wCurSpecies], a ld [wCurSpecies], a
call GetBaseData call GetBaseData
@ -21,7 +21,7 @@ Pokepic::
ld c, a ld c, a
call Coord2Tile call Coord2Tile
ld a, $80 ld a, $80
ld [hGraphicStartTile], a ldh [hGraphicStartTile], a
lb bc, 7, 7 lb bc, 7, 7
predef PlaceGraphic predef PlaceGraphic
call WaitBGMap call WaitBGMap
@ -34,7 +34,7 @@ ClosePokepic::
call WaitBGMap call WaitBGMap
call GetMemSGBLayout call GetMemSGBLayout
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
call OverworldTextModeSwitch call OverworldTextModeSwitch
call ApplyTilemap call ApplyTilemap
call UpdateSprites call UpdateSprites

View File

@ -22,10 +22,10 @@ GivePokerusAndConvertBerries:
bit STATUSFLAGS2_REACHED_GOLDENROD_F, [hl] bit STATUSFLAGS2_REACHED_GOLDENROD_F, [hl]
ret z ret z
call Random call Random
ld a, [hRandomAdd] ldh a, [hRandomAdd]
and a and a
ret nz ret nz
ld a, [hRandomSub] ldh a, [hRandomSub]
cp $3 cp $3
ret nc ; 3/65536 chance (00 00, 00 01 or 00 02) ret nc ; 3/65536 chance (00 00, 00 01 or 00 02)
ld a, [wPartyCount] ld a, [wPartyCount]

View File

@ -12,7 +12,7 @@ PhotoStudio:
call DisableSpriteUpdates call DisableSpriteUpdates
farcall PrintPartymon farcall PrintPartymon
call ReturnToMapWithSpeechTextbox call ReturnToMapWithSpeechTextbox
ld a, [hPrinter] ldh a, [hPrinter]
and a and a
jr nz, .cancel jr nz, .cancel
ld hl, .Text_Presto ld hl, .Text_Presto

View File

@ -6,10 +6,10 @@ _UnownPrinter:
and a and a
ret z ret z
ld a, [hInMenu] ldh a, [hInMenu]
push af push af
ld a, $1 ld a, $1
ld [hInMenu], a ldh [hInMenu], a
ld a, [wOptions] ld a, [wOptions]
push af push af
set NO_TEXT_SCROLL, a set NO_TEXT_SCROLL, a
@ -69,11 +69,11 @@ _UnownPrinter:
.joy_loop .joy_loop
call JoyTextDelay call JoyTextDelay
ld a, [hJoyPressed] ldh a, [hJoyPressed]
and B_BUTTON and B_BUTTON
jr nz, .pressed_b jr nz, .pressed_b
ld a, [hJoyPressed] ldh a, [hJoyPressed]
and A_BUTTON and A_BUTTON
jr nz, .pressed_a jr nz, .pressed_a
@ -94,15 +94,15 @@ _UnownPrinter:
pop af pop af
ld [wOptions], a ld [wOptions], a
pop af pop af
ld [hInMenu], a ldh [hInMenu], a
call ReturnToMapFromSubmenu call ReturnToMapFromSubmenu
ret ret
.LeftRight: .LeftRight:
ld a, [hJoyLast] ldh a, [hJoyLast]
and D_RIGHT and D_RIGHT
jr nz, .press_right jr nz, .press_right
ld a, [hJoyLast] ldh a, [hJoyLast]
and D_LEFT and D_LEFT
jr nz, .press_left jr nz, .press_left
ret ret
@ -145,7 +145,7 @@ _UnownPrinter:
call .Load2bppToSRAM call .Load2bppToSRAM
hlcoord 1, 6 hlcoord 1, 6
xor a xor a
ld [hGraphicStartTile], a ldh [hGraphicStartTile], a
lb bc, 7, 7 lb bc, 7, 7
predef PlaceGraphic predef PlaceGraphic
ld de, vTiles2 tile $31 ld de, vTiles2 tile $31
@ -153,23 +153,23 @@ _UnownPrinter:
ret ret
.Load2bppToSRAM: .Load2bppToSRAM:
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, BANK(wDecompressScratch) ld a, BANK(wDecompressScratch)
ld [rSVBK], a ldh [rSVBK], a
ld a, BANK(sScratch) ld a, BANK(sScratch)
call GetSRAMBank call GetSRAMBank
ld de, wDecompressScratch ld de, wDecompressScratch
ld hl, sScratch ld hl, sScratch
ld a, [hROMBank] ldh a, [hROMBank]
ld b, a ld b, a
ld c, $31 ld c, $31
call Get2bpp call Get2bpp
call CloseSRAM call CloseSRAM
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ret ret
.vacant .vacant
@ -188,7 +188,7 @@ _UnownPrinter:
ld hl, vTiles2 tile $31 ld hl, vTiles2 tile $31
ld de, sScratch ld de, sScratch
ld c, $31 ld c, $31
ld a, [hROMBank] ldh a, [hROMBank]
ld b, a ld b, a
call Get2bpp call Get2bpp
call CloseSRAM call CloseSRAM
@ -224,7 +224,7 @@ PlaceUnownPrinterFrontpic:
call ByteFill call ByteFill
hlcoord 7, 11 hlcoord 7, 11
ld a, $31 ld a, $31
ld [hGraphicStartTile], a ldh [hGraphicStartTile], a
lb bc, 7, 7 lb bc, 7, 7
predef PlaceGraphic predef PlaceGraphic
ret ret

View File

@ -37,7 +37,7 @@ RotateUnownFrontpic:
pop hl pop hl
ld de, sScratch ld de, sScratch
ld c, 7 * 7 ld c, 7 * 7
ld a, [hROMBank] ldh a, [hROMBank]
ld b, a ld b, a
call Get2bpp call Get2bpp
call CloseSRAM call CloseSRAM

View File

@ -380,11 +380,11 @@ PlayCurMonCry:
jp PlayMonCry jp PlayMonCry
GameboyCheck: GameboyCheck:
ld a, [hCGB] ldh a, [hCGB]
and a and a
jr nz, .cgb jr nz, .cgb
ld a, [hSGB] ldh a, [hSGB]
and a and a
jr nz, .sgb jr nz, .sgb

View File

@ -242,34 +242,34 @@ GetTreeScore:
add hl, bc add hl, bc
ld a, h ld a, h
ld [hDividend], a ldh [hDividend], a
ld a, l ld a, l
ld [hDividend + 1], a ldh [hDividend + 1], a
ld a, 5 ld a, 5
ld [hDivisor], a ldh [hDivisor], a
ld b, 2 ld b, 2
call Divide call Divide
ld a, [hQuotient + 1] ldh a, [hQuotient + 1]
ld [hDividend], a ldh [hDividend], a
ld a, [hQuotient + 2] ldh a, [hQuotient + 2]
ld [hDividend + 1], a ldh [hDividend + 1], a
ld a, 10 ld a, 10
ld [hDivisor], a ldh [hDivisor], a
ld b, 2 ld b, 2
call Divide call Divide
ld a, [hQuotient + 3] ldh a, [hQuotient + 3]
ret ret
.OTIDScore: .OTIDScore:
ld a, [wPlayerID] ld a, [wPlayerID]
ld [hDividend], a ldh [hDividend], a
ld a, [wPlayerID + 1] ld a, [wPlayerID + 1]
ld [hDividend + 1], a ldh [hDividend + 1], a
ld a, 10 ld a, 10
ld [hDivisor], a ldh [hDivisor], a
ld b, 2 ld b, 2
call Divide call Divide
ld a, [hQuotient + 3] ldh a, [hQuotient + 3]
ret ret

View File

@ -115,7 +115,7 @@ DisplayUnownWords:
.load .load
call LoadMenuHeader call LoadMenuHeader
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
call MenuBox call MenuBox
call UpdateSprites call UpdateSprites
call ApplyTilemap call ApplyTilemap

View File

@ -147,10 +147,10 @@ _CardFlip:
ld de, SFX_TRANSACTION ld de, SFX_TRANSACTION
call PlaySFX call PlaySFX
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
call CardFlip_PrintCoinBalance call CardFlip_PrintCoinBalance
ld a, $1 ld a, $1
ld [hBGMapMode], a ldh [hBGMapMode], a
call WaitSFX call WaitSFX
call .Increment call .Increment
ret ret
@ -162,7 +162,7 @@ _CardFlip:
.ChooseACard: .ChooseACard:
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
hlcoord 0, 0 hlcoord 0, 0
lb bc, 12, 9 lb bc, 12, 9
call CardFlip_FillGreenBox call CardFlip_FillGreenBox
@ -172,13 +172,13 @@ _CardFlip:
call AddNTimes call AddNTimes
ld [hl], CARDFLIP_LIGHT_ON ld [hl], CARDFLIP_LIGHT_ON
ld a, $1 ld a, $1
ld [hBGMapMode], a ldh [hBGMapMode], a
ld c, 20 ld c, 20
call DelayFrames call DelayFrames
hlcoord 2, 0 hlcoord 2, 0
call PlaceCardFaceDown call PlaceCardFaceDown
ld a, $1 ld a, $1
ld [hBGMapMode], a ldh [hBGMapMode], a
ld c, 20 ld c, 20
call DelayFrames call DelayFrames
hlcoord 2, 6 hlcoord 2, 6
@ -190,7 +190,7 @@ _CardFlip:
ld [wCardFlipWhichCard], a ld [wCardFlipWhichCard], a
.loop .loop
call JoyTextDelay call JoyTextDelay
ld a, [hJoyLast] ldh a, [hJoyLast]
and A_BUTTON and A_BUTTON
jr nz, .next jr nz, .next
ld de, SFX_KINESIS ld de, SFX_KINESIS
@ -242,7 +242,7 @@ _CardFlip:
call CardFlip_UpdateCoinBalanceDisplay call CardFlip_UpdateCoinBalanceDisplay
.betloop .betloop
call JoyTextDelay call JoyTextDelay
ld a, [hJoyLast] ldh a, [hJoyLast]
and A_BUTTON and A_BUTTON
jr nz, .betdone jr nz, .betdone
call ChooseCard_HandleJoypad call ChooseCard_HandleJoypad
@ -261,7 +261,7 @@ _CardFlip:
.CheckTheCard: .CheckTheCard:
xor a xor a
ld [hVBlankCounter], a ldh [hVBlankCounter], a
call CardFlip_UpdateCursorOAM call CardFlip_UpdateCursorOAM
call WaitSFX call WaitSFX
ld de, SFX_CHOOSE_A_CARD ld de, SFX_CHOOSE_A_CARD
@ -311,7 +311,7 @@ _CardFlip:
jr c, .KeepTheCurrentDeck jr c, .KeepTheCurrentDeck
call CardFlip_InitTilemap call CardFlip_InitTilemap
ld a, $1 ld a, $1
ld [hBGMapMode], a ldh [hBGMapMode], a
call CardFlip_ShuffleDeck call CardFlip_ShuffleDeck
ld hl, .CardsShuffledText ld hl, .CardsShuffledText
call PrintText call PrintText
@ -396,7 +396,7 @@ GetCoordsOfChosenCard:
PlaceCardFaceDown: PlaceCardFaceDown:
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
ld de, .FaceDownCardTilemap ld de, .FaceDownCardTilemap
lb bc, 6, 5 lb bc, 6, 5
call CardFlip_CopyToBox call CardFlip_CopyToBox
@ -412,7 +412,7 @@ PlaceCardFaceDown:
CardFlip_DisplayCardFaceUp: CardFlip_DisplayCardFaceUp:
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
push hl push hl
push hl push hl
; Flip the card face up. ; Flip the card face up.
@ -458,7 +458,7 @@ CardFlip_DisplayCardFaceUp:
pop hl pop hl
; Pointless CGB check ; Pointless CGB check
ld a, [hCGB] ldh a, [hCGB]
and a and a
ret z ret z
@ -519,7 +519,7 @@ CardFlip_PrintCoinBalance:
CardFlip_InitTilemap: CardFlip_InitTilemap:
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
hlcoord 0, 0 hlcoord 0, 0
ld bc, SCREEN_HEIGHT * SCREEN_WIDTH ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
ld a, $29 ld a, $29
@ -607,7 +607,7 @@ CardFlip_ShiftDigitsLeftTwoPixels:
CardFlip_BlankDiscardedCardSlot: CardFlip_BlankDiscardedCardSlot:
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
ld a, [wCardFlipFaceUpCard] ld a, [wCardFlipFaceUpCard]
ld e, a ld e, a
ld d, 0 ld d, 0
@ -1327,10 +1327,10 @@ ChooseCard_HandleJoypad:
CardFlip_UpdateCursorOAM: CardFlip_UpdateCursorOAM:
call ClearSprites call ClearSprites
ld a, [hCGB] ldh a, [hCGB]
and a and a
jr nz, .skip jr nz, .skip
ld a, [hVBlankCounter] ldh a, [hVBlankCounter]
and $4 and $4
ret nz ret nz
@ -1560,7 +1560,7 @@ ENDM
dsprite 1, 0, 1, 0, $00, 0 | X_FLIP | Y_FLIP | PRIORITY dsprite 1, 0, 1, 0, $00, 0 | X_FLIP | Y_FLIP | PRIORITY
CardFlip_InitAttrPals: CardFlip_InitAttrPals:
ld a, [hCGB] ldh a, [hCGB]
and a and a
ret z ret z
@ -1594,16 +1594,16 @@ CardFlip_InitAttrPals:
ld a, $1 ld a, $1
call CardFlip_FillBox call CardFlip_FillBox
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, .palettes ld hl, .palettes
ld de, wBGPals1 ld de, wBGPals1
ld bc, 9 palettes ld bc, 9 palettes
call CopyBytes call CopyBytes
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ret ret
.palettes .palettes

View File

@ -28,14 +28,14 @@ _DummyGame:
xor a xor a
call ByteFill call ByteFill
xor a xor a
ld [hSCY], a ldh [hSCY], a
ld [hSCX], a ldh [hSCX], a
ld [rWY], a ldh [rWY], a
ld [wJumptableIndex], a ld [wJumptableIndex], a
ld a, $1 ld a, $1
ld [hBGMapMode], a ldh [hBGMapMode], a
ld a, LCDC_DEFAULT ld a, LCDC_DEFAULT
ld [rLCDC], a ldh [rLCDC], a
ld a, $e4 ld a, $e4
call DmgToCgbBGPals call DmgToCgbBGPals
ld a, $e0 ld a, $e0
@ -200,7 +200,7 @@ endr
ret ret
.RevealAll: .RevealAll:
ld a, [hJoypadPressed] ldh a, [hJoypadPressed]
and A_BUTTON and A_BUTTON
ret z ret z
xor a xor a

View File

@ -167,7 +167,7 @@ Slots_GetPals:
ld a, %11100100 ld a, %11100100
call DmgToCgbBGPals call DmgToCgbBGPals
lb de, %11100100, %11100100 lb de, %11100100, %11100100
ld a, [hCGB] ldh a, [hCGB]
and a and a
jr nz, .cgb jr nz, .cgb
lb de, %11000000, %11100100 lb de, %11000000, %11100100
@ -214,7 +214,7 @@ SlotsLoop:
ld a, [wTextDelayFrames] ld a, [wTextDelayFrames]
and $7 and $7
ret nz ret nz
ld a, [rBGP] ldh a, [rBGP]
xor %00001100 xor %00001100
call DmgToCgbBGPals call DmgToCgbBGPals
ret ret
@ -343,7 +343,7 @@ SlotsAction_WaitStart:
.proceed .proceed
call SlotsAction_Next call SlotsAction_Next
xor a xor a
ld [hJoypadSum], a ldh [hJoypadSum], a
ret ret
SlotsAction_WaitReel1: SlotsAction_WaitReel1:
@ -365,7 +365,7 @@ SlotsAction_WaitStopReel1:
call Slots_LoadReelState call Slots_LoadReelState
call SlotsAction_Next call SlotsAction_Next
xor a xor a
ld [hJoypadSum], a ldh [hJoypadSum], a
SlotsAction_WaitReel2: SlotsAction_WaitReel2:
ld hl, hJoypadSum ld hl, hJoypadSum
ld a, [hl] ld a, [hl]
@ -385,7 +385,7 @@ SlotsAction_WaitStopReel2:
call Slots_LoadReelState call Slots_LoadReelState
call SlotsAction_Next call SlotsAction_Next
xor a xor a
ld [hJoypadSum], a ldh [hJoypadSum], a
SlotsAction_WaitReel3: SlotsAction_WaitReel3:
ld hl, hJoypadSum ld hl, hJoypadSum
ld a, [hl] ld a, [hl]
@ -405,7 +405,7 @@ SlotsAction_WaitStopReel3:
call Slots_LoadReelState call Slots_LoadReelState
call SlotsAction_Next call SlotsAction_Next
xor a xor a
ld [hJoypadSum], a ldh [hJoypadSum], a
ret ret
SlotsAction_FlashIfWin: SlotsAction_FlashIfWin:
@ -429,7 +429,7 @@ SlotsAction_FlashScreen:
srl a srl a
ret z ret z
ld a, [rOBP0] ldh a, [rOBP0]
xor $ff xor $ff
ld e, a ld e, a
ld d, a ld d, a
@ -2042,7 +2042,7 @@ Slots_AnimateGolem:
xor $ff xor $ff
inc a inc a
ld [hl], a ld [hl], a
ld [hSCY], a ldh [hSCY], a
ret ret
.restart .restart
@ -2050,7 +2050,7 @@ Slots_AnimateGolem:
add hl, bc add hl, bc
xor a xor a
ld [hl], a ld [hl], a
ld [hSCY], a ldh [hSCY], a
ret ret
Slots_AnimateChansey: Slots_AnimateChansey:

View File

@ -4,15 +4,15 @@ PUZZLE_VOID EQU $ef
puzcoord EQUS "* 6 +" puzcoord EQUS "* 6 +"
_UnownPuzzle: _UnownPuzzle:
ld a, [hInMenu] ldh a, [hInMenu]
push af push af
ld a, $1 ld a, $1
ld [hInMenu], a ldh [hInMenu], a
call ClearBGPalettes call ClearBGPalettes
call ClearTileMap call ClearTileMap
call ClearSprites call ClearSprites
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
call DisableLCD call DisableLCD
ld hl, wc608 ; includes wPuzzlePieces ld hl, wc608 ; includes wPuzzlePieces
ld bc, wc7e8 - wc608 ld bc, wc7e8 - wc608
@ -38,15 +38,15 @@ _UnownPuzzle:
call UnownPuzzle_UpdateTilemap call UnownPuzzle_UpdateTilemap
call PlaceStartCancelBox call PlaceStartCancelBox
xor a xor a
ld [hSCY], a ldh [hSCY], a
ld [hSCX], a ldh [hSCX], a
ld [rWY], a ldh [rWY], a
ld [wJumptableIndex], a ld [wJumptableIndex], a
ld [wHoldingUnownPuzzlePiece], a ld [wHoldingUnownPuzzlePiece], a
ld [wUnownPuzzleCursorPosition], a ld [wUnownPuzzleCursorPosition], a
ld [wUnownPuzzleHeldPiece], a ld [wUnownPuzzleHeldPiece], a
ld a, %10010011 ld a, %10010011
ld [rLCDC], a ldh [rLCDC], a
call WaitBGMap call WaitBGMap
ld b, SCGB_UNOWN_PUZZLE ld b, SCGB_UNOWN_PUZZLE
call GetSGBLayout call GetSGBLayout
@ -66,7 +66,7 @@ _UnownPuzzle:
ld a, [wHoldingUnownPuzzlePiece] ld a, [wHoldingUnownPuzzlePiece]
and a and a
jr nz, .holding_piece jr nz, .holding_piece
ld a, [hVBlankCounter] ldh a, [hVBlankCounter]
and $10 and $10
jr z, .clear jr z, .clear
.holding_piece .holding_piece
@ -81,12 +81,12 @@ _UnownPuzzle:
.quit .quit
pop af pop af
ld [hInMenu], a ldh [hInMenu], a
call ClearBGPalettes call ClearBGPalettes
call ClearTileMap call ClearTileMap
call ClearSprites call ClearSprites
ld a, LCDC_DEFAULT ld a, LCDC_DEFAULT
ld [rLCDC], a ldh [rLCDC], a
ret ret
InitUnownPuzzlePiecePositions: InitUnownPuzzlePiecePositions:
@ -185,10 +185,10 @@ UnownPuzzleJumptable:
dw .Function dw .Function
.Function: .Function:
ld a, [hJoyPressed] ldh a, [hJoyPressed]
and START and START
jp nz, UnownPuzzle_Quit jp nz, UnownPuzzle_Quit
ld a, [hJoyPressed] ldh a, [hJoyPressed]
and A_BUTTON and A_BUTTON
jp nz, UnownPuzzle_A jp nz, UnownPuzzle_A
ld hl, hJoyLast ld hl, hJoyLast

View File

@ -1,7 +1,7 @@
; Replaces the functionality of sgb.asm to work with CGB hardware. ; Replaces the functionality of sgb.asm to work with CGB hardware.
CheckCGB: CheckCGB:
ld a, [hCGB] ldh a, [hCGB]
and a and a
ret ret
@ -190,7 +190,7 @@ _CGB_PokegearPals:
call FarCopyWRAM call FarCopyWRAM
call ApplyPals call ApplyPals
ld a, $1 ld a, $1
ld [hCGBPalUpdate], a ldh [hCGBPalUpdate], a
ret ret
_CGB_StatsScreenHPPals: _CGB_StatsScreenHPPals:
@ -244,7 +244,7 @@ _CGB_StatsScreenHPPals:
call ApplyAttrMap call ApplyAttrMap
call ApplyPals call ApplyPals
ld a, $1 ld a, $1
ld [hCGBPalUpdate], a ldh [hCGBPalUpdate], a
ret ret
StatsScreenPagePals: StatsScreenPagePals:
@ -283,7 +283,7 @@ _CGB_Pokedex:
call ApplyAttrMap call ApplyAttrMap
call ApplyPals call ApplyPals
ld a, $1 ld a, $1
ld [hCGBPalUpdate], a ldh [hCGBPalUpdate], a
ret ret
.PokedexQuestionMarkPalette: .PokedexQuestionMarkPalette:
@ -318,7 +318,7 @@ _CGB_BillsPC:
call ApplyAttrMap call ApplyAttrMap
call ApplyPals call ApplyPals
ld a, $1 ld a, $1
ld [hCGBPalUpdate], a ldh [hCGBPalUpdate], a
ret ret
.Function9009: .Function9009:
@ -340,7 +340,7 @@ _CGB_BillsPC:
call ApplyAttrMap call ApplyAttrMap
call ApplyPals call ApplyPals
ld a, $1 ld a, $1
ld [hCGBPalUpdate], a ldh [hCGBPalUpdate], a
ret ret
.BillsPCOrangePalette: .BillsPCOrangePalette:
@ -363,7 +363,7 @@ _CGB_PokedexUnownMode:
call ApplyAttrMap call ApplyAttrMap
call ApplyPals call ApplyPals
ld a, $1 ld a, $1
ld [hCGBPalUpdate], a ldh [hCGBPalUpdate], a
ret ret
_CGB_SlotMachine: _CGB_SlotMachine:
@ -416,7 +416,7 @@ _CGB_SlotMachine:
call ApplyAttrMap call ApplyAttrMap
call ApplyPals call ApplyPals
ld a, $1 ld a, $1
ld [hCGBPalUpdate], a ldh [hCGBPalUpdate], a
ret ret
_CGB06: _CGB06:
@ -434,7 +434,7 @@ _CGB06:
call ApplyAttrMap call ApplyAttrMap
call ApplyPals call ApplyPals
ld a, $1 ld a, $1
ld [hCGBPalUpdate], a ldh [hCGBPalUpdate], a
ret ret
_CGB_GSIntro: _CGB_GSIntro:
@ -574,7 +574,7 @@ _CGB_Evolution:
call ApplyAttrMap call ApplyAttrMap
call ApplyPals call ApplyPals
ld a, $1 ld a, $1
ld [hCGBPalUpdate], a ldh [hCGBPalUpdate], a
ret ret
_CGB_GSTitleScreen: _CGB_GSTitleScreen:
@ -592,7 +592,7 @@ _CGB_GSTitleScreen:
ld [wSGBPredef], a ld [wSGBPredef], a
call ApplyPals call ApplyPals
ld a, $1 ld a, $1
ld [hCGBPalUpdate], a ldh [hCGBPalUpdate], a
ret ret
_CGB0d: _CGB0d:
@ -609,17 +609,17 @@ _CGB_UnownPuzzle:
ld a, PREDEFPAL_UNOWN_PUZZLE ld a, PREDEFPAL_UNOWN_PUZZLE
call GetPredefPal call GetPredefPal
call LoadHLPaletteIntoDE call LoadHLPaletteIntoDE
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, BANK(wOBPals1) ld a, BANK(wOBPals1)
ld [rSVBK], a ldh [rSVBK], a
ld hl, wOBPals1 ld hl, wOBPals1
ld a, LOW(palred 31 + palgreen 0 + palblue 0) ld a, LOW(palred 31 + palgreen 0 + palblue 0)
ld [hli], a ld [hli], a
ld a, HIGH(palred 31 + palgreen 0 + palblue 0) ld a, HIGH(palred 31 + palgreen 0 + palblue 0)
ld [hl], a ld [hl], a
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
call WipeAttrMap call WipeAttrMap
call ApplyAttrMap call ApplyAttrMap
ret ret
@ -726,7 +726,7 @@ _CGB_TrainerCard:
call ApplyAttrMap call ApplyAttrMap
call ApplyPals call ApplyPals
ld a, $1 ld a, $1
ld [hCGBPalUpdate], a ldh [hCGBPalUpdate], a
ret ret
_CGB_MoveList: _CGB_MoveList:
@ -750,7 +750,7 @@ _CGB_MoveList:
call ApplyAttrMap call ApplyAttrMap
call ApplyPals call ApplyPals
ld a, $1 ld a, $1
ld [hCGBPalUpdate], a ldh [hCGBPalUpdate], a
ret ret
_CGB_BetaPikachuMinigame: _CGB_BetaPikachuMinigame:
@ -760,7 +760,7 @@ _CGB_BetaPikachuMinigame:
call ApplyAttrMap call ApplyAttrMap
call ApplyPals call ApplyPals
ld a, $1 ld a, $1
ld [hCGBPalUpdate], a ldh [hCGBPalUpdate], a
ret ret
_CGB_PokedexSearchOption: _CGB_PokedexSearchOption:
@ -772,7 +772,7 @@ _CGB_PokedexSearchOption:
call ApplyAttrMap call ApplyAttrMap
call ApplyPals call ApplyPals
ld a, $1 ld a, $1
ld [hCGBPalUpdate], a ldh [hCGBPalUpdate], a
ret ret
_CGB_PackPals: _CGB_PackPals:
@ -820,7 +820,7 @@ _CGB_PackPals:
call ApplyAttrMap call ApplyAttrMap
call ApplyPals call ApplyPals
ld a, $1 ld a, $1
ld [hCGBPalUpdate], a ldh [hCGBPalUpdate], a
ret ret
.ChrisPackPals: .ChrisPackPals:
@ -878,7 +878,7 @@ _CGB13:
call ApplyAttrMap call ApplyAttrMap
call ApplyPals call ApplyPals
ld a, $1 ld a, $1
ld [hCGBPalUpdate], a ldh [hCGBPalUpdate], a
ret ret
_CGB_GamefreakLogo: _CGB_GamefreakLogo:

View File

@ -151,7 +151,7 @@ Unreferenced_Function8b07:
call ApplyPals call ApplyPals
ld a, $1 ld a, $1
ld [hCGBPalUpdate], a ldh [hCGBPalUpdate], a
ret ret
.BGPal: .BGPal:
@ -169,7 +169,7 @@ Unreferenced_Function8b07:
Unreferenced_Function8b3f: Unreferenced_Function8b3f:
call CheckCGB call CheckCGB
ret nz ret nz
ld a, [hSGB] ldh a, [hSGB]
and a and a
ret z ret z
ld hl, BlkPacket_9a86 ld hl, BlkPacket_9a86
@ -178,7 +178,7 @@ Unreferenced_Function8b3f:
Unreferenced_Function8b4d: Unreferenced_Function8b4d:
call CheckCGB call CheckCGB
jr nz, .cgb jr nz, .cgb
ld a, [hSGB] ldh a, [hSGB]
and a and a
ret z ret z
ld hl, PalPacket_BetaIntroVenusaur ld hl, PalPacket_BetaIntroVenusaur
@ -193,7 +193,7 @@ Unreferenced_Function8b4d:
Unreferenced_Function8b67: Unreferenced_Function8b67:
call CheckCGB call CheckCGB
jr nz, .cgb jr nz, .cgb
ld a, [hSGB] ldh a, [hSGB]
and a and a
ret z ret z
ld hl, PalPacket_Pack ld hl, PalPacket_Pack
@ -208,7 +208,7 @@ Unreferenced_Function8b67:
Unreferenced_Function8b81: Unreferenced_Function8b81:
call CheckCGB call CheckCGB
jr nz, .cgb jr nz, .cgb
ld a, [hSGB] ldh a, [hSGB]
and a and a
ret z ret z
ld a, c ld a, c
@ -274,7 +274,7 @@ got_palette_pointer_8bd7
ret ret
Unreferenced_Function8bec: Unreferenced_Function8bec:
ld a, [hCGB] ldh a, [hCGB]
and a and a
jr nz, .cgb jr nz, .cgb
ld hl, wPlayerLightScreenCount ld hl, wPlayerLightScreenCount
@ -353,7 +353,7 @@ ApplyHPBarPals:
ld a, BANK(wBGPals2) ld a, BANK(wBGPals2)
call FarCopyWRAM call FarCopyWRAM
ld a, $1 ld a, $1
ld [hCGBPalUpdate], a ldh [hCGBPalUpdate], a
ret ret
.PartyMenu: .PartyMenu:
@ -383,10 +383,10 @@ LoadStatsScreenPals:
dec c dec c
add hl, bc add hl, bc
add hl, bc add hl, bc
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 a, [hli] ld a, [hli]
ld [wBGPals1 palette 0], a ld [wBGPals1 palette 0], a
ld [wBGPals1 palette 2], a ld [wBGPals1 palette 2], a
@ -394,7 +394,7 @@ LoadStatsScreenPals:
ld [wBGPals1 palette 0 + 1], a ld [wBGPals1 palette 0 + 1], a
ld [wBGPals1 palette 2 + 1], a ld [wBGPals1 palette 2 + 1], a
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
call ApplyPals call ApplyPals
ld a, $1 ld a, $1
ret ret
@ -492,10 +492,10 @@ GetPredefPal:
ret ret
LoadHLPaletteIntoDE: LoadHLPaletteIntoDE:
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, BANK(wOBPals1) ld a, BANK(wOBPals1)
ld [rSVBK], a ldh [rSVBK], a
ld c, 1 palettes ld c, 1 palettes
.loop .loop
ld a, [hli] ld a, [hli]
@ -504,14 +504,14 @@ LoadHLPaletteIntoDE:
dec c dec c
jr nz, .loop jr nz, .loop
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ret ret
LoadPalette_White_Col1_Col2_Black: LoadPalette_White_Col1_Col2_Black:
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 a, LOW(PALRGB_WHITE) ld a, LOW(PALRGB_WHITE)
ld [de], a ld [de], a
@ -535,7 +535,7 @@ LoadPalette_White_Col1_Col2_Black:
inc de inc de
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ret ret
FillBoxCGB: FillBoxCGB:
@ -560,10 +560,10 @@ ResetBGPals:
push de push de
push hl push hl
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 c, 1 palettes ld c, 1 palettes
@ -582,7 +582,7 @@ ResetBGPals:
jr nz, .loop jr nz, .loop
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
pop hl pop hl
pop de pop de
@ -606,19 +606,19 @@ ApplyPals:
ret ret
ApplyAttrMap: ApplyAttrMap:
ld a, [rLCDC] ldh a, [rLCDC]
bit rLCDC_ENABLE, a bit rLCDC_ENABLE, a
jr z, .UpdateVBank1 jr z, .UpdateVBank1
ld a, [hBGMapMode] ldh a, [hBGMapMode]
push af push af
ld a, $2 ld a, $2
ld [hBGMapMode], a ldh [hBGMapMode], a
call DelayFrame call DelayFrame
call DelayFrame call DelayFrame
call DelayFrame call DelayFrame
call DelayFrame call DelayFrame
pop af pop af
ld [hBGMapMode], a ldh [hBGMapMode], a
ret ret
.UpdateVBank1: .UpdateVBank1:
@ -626,7 +626,7 @@ ApplyAttrMap:
debgcoord 0, 0 debgcoord 0, 0
ld b, SCREEN_HEIGHT ld b, SCREEN_HEIGHT
ld a, $1 ld a, $1
ld [rVBK], a ldh [rVBK], a
.row .row
ld c, SCREEN_WIDTH ld c, SCREEN_WIDTH
.col .col
@ -644,7 +644,7 @@ ApplyAttrMap:
dec b dec b
jr nz, .row jr nz, .row
ld a, $0 ld a, $0
ld [rVBK], a ldh [rVBK], a
ret ret
; CGB layout for SCGB_PARTY_MENU_HP_PALS ; CGB layout for SCGB_PARTY_MENU_HP_PALS
@ -742,11 +742,11 @@ Unreferenced_Function9779:
ret z ret z
ld hl, BattleObjectPals ld hl, BattleObjectPals
ld a, $90 ld a, $90
ld [rOBPI], a ldh [rOBPI], a
ld c, 6 palettes ld c, 6 palettes
.loop .loop
ld a, [hli] ld a, [hli]
ld [rOBPD], a ldh [rOBPD], a
dec c dec c
jr nz, .loop jr nz, .loop
ld hl, BattleObjectPals ld hl, BattleObjectPals
@ -763,7 +763,7 @@ Unreferenced_Function97cc:
call CheckCGB call CheckCGB
ret z ret z
ld a, $90 ld a, $90
ld [rOBPI], a ldh [rOBPI], a
ld a, PREDEFPAL_TRADE_TUBE ld a, PREDEFPAL_TRADE_TUBE
call GetPredefPal call GetPredefPal
call .PushPalette call .PushPalette
@ -776,7 +776,7 @@ Unreferenced_Function97cc:
ld c, 1 palettes ld c, 1 palettes
.loop .loop
ld a, [hli] ld a, [hli]
ld [rOBPD], a ldh [rOBPD], a
dec c dec c
jr nz, .loop jr nz, .loop
ret ret
@ -822,9 +822,9 @@ _PushSGBPals:
.loop .loop
push bc push bc
xor a xor a
ld [rJOYP], a ldh [rJOYP], a
ld a, $30 ld a, $30
ld [rJOYP], a ldh [rJOYP], a
ld b, $10 ld b, $10
.loop2 .loop2
ld e, $8 ld e, $8
@ -836,18 +836,18 @@ _PushSGBPals:
jr nz, .okay jr nz, .okay
ld a, $20 ld a, $20
.okay .okay
ld [rJOYP], a ldh [rJOYP], a
ld a, $30 ld a, $30
ld [rJOYP], a ldh [rJOYP], a
rr d rr d
dec e dec e
jr nz, .loop3 jr nz, .loop3
dec b dec b
jr nz, .loop2 jr nz, .loop2
ld a, $20 ld a, $20
ld [rJOYP], a ldh [rJOYP], a
ld a, $30 ld a, $30
ld [rJOYP], a ldh [rJOYP], a
call SGBDelayCycles call SGBDelayCycles
pop bc pop bc
dec b dec b
@ -864,12 +864,12 @@ InitSGBBorder:
set 7, a set 7, a
ld [wcfbe], a ld [wcfbe], a
xor a xor a
ld [rJOYP], a ldh [rJOYP], a
ld [hSGB], a ldh [hSGB], a
call PushSGBBorderPalsAndWait call PushSGBBorderPalsAndWait
jr nc, .skip jr nc, .skip
ld a, $1 ld a, $1
ld [hSGB], a ldh [hSGB], a
call _InitSGBBorderPals call _InitSGBBorderPals
call SGBBorder_PushBGPals call SGBBorder_PushBGPals
call SGBDelayCycles call SGBDelayCycles
@ -891,43 +891,43 @@ InitCGBPals::
ret z ret z
; CGB only ; CGB only
ld a, BANK(vTiles3) ld a, BANK(vTiles3)
ld [rVBK], a ldh [rVBK], a
ld hl, vTiles3 ld hl, vTiles3
ld bc, $200 tiles ld bc, $200 tiles
xor a xor a
call ByteFill call ByteFill
ld a, BANK(vTiles0) ld a, BANK(vTiles0)
ld [rVBK], a ldh [rVBK], a
ld a, 1 << rBGPI_AUTO_INCREMENT ld a, 1 << rBGPI_AUTO_INCREMENT
ld [rBGPI], a ldh [rBGPI], a
ld c, 4 * 8 ld c, 4 * 8
.bgpals_loop .bgpals_loop
ld a, LOW(PALRGB_WHITE) ld a, LOW(PALRGB_WHITE)
ld [rBGPD], a ldh [rBGPD], a
ld a, HIGH(PALRGB_WHITE) ld a, HIGH(PALRGB_WHITE)
ld [rBGPD], a ldh [rBGPD], a
dec c dec c
jr nz, .bgpals_loop jr nz, .bgpals_loop
ld a, 1 << rOBPI_AUTO_INCREMENT ld a, 1 << rOBPI_AUTO_INCREMENT
ld [rOBPI], a ldh [rOBPI], a
ld c, 4 * 8 ld c, 4 * 8
.obpals_loop .obpals_loop
ld a, LOW(PALRGB_WHITE) ld a, LOW(PALRGB_WHITE)
ld [rOBPD], a ldh [rOBPD], a
ld a, HIGH(PALRGB_WHITE) ld a, HIGH(PALRGB_WHITE)
ld [rOBPD], a ldh [rOBPD], a
dec c dec c
jr nz, .obpals_loop jr nz, .obpals_loop
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
call .LoadWhitePals call .LoadWhitePals
ld hl, wBGPals2 ld hl, wBGPals2
call .LoadWhitePals call .LoadWhitePals
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ret ret
.LoadWhitePals: .LoadWhitePals:
@ -972,7 +972,7 @@ _InitSGBBorderPals:
Unreferenced_Function9911: Unreferenced_Function9911:
di di
xor a xor a
ld [rJOYP], a ldh [rJOYP], a
ld hl, MaskEnFreezePacket ld hl, MaskEnFreezePacket
call _PushSGBPals call _PushSGBPals
call PushSGBBorder call PushSGBBorder
@ -1007,35 +1007,35 @@ PushSGBBorderPalsAndWait:
ld hl, MltReq2Packet ld hl, MltReq2Packet
call _PushSGBPals call _PushSGBPals
call SGBDelayCycles call SGBDelayCycles
ld a, [rJOYP] ldh a, [rJOYP]
and $3 and $3
cp $3 cp $3
jr nz, .carry jr nz, .carry
ld a, $20 ld a, $20
ld [rJOYP], a ldh [rJOYP], a
ld a, [rJOYP] ldh a, [rJOYP]
ld a, [rJOYP] ldh a, [rJOYP]
call SGBDelayCycles call SGBDelayCycles
call SGBDelayCycles call SGBDelayCycles
ld a, $30 ld a, $30
ld [rJOYP], a ldh [rJOYP], a
call SGBDelayCycles call SGBDelayCycles
call SGBDelayCycles call SGBDelayCycles
ld a, $10 ld a, $10
ld [rJOYP], a ldh [rJOYP], a
rept 6 rept 6
ld a, [rJOYP] ldh a, [rJOYP]
endr endr
call SGBDelayCycles call SGBDelayCycles
call SGBDelayCycles call SGBDelayCycles
ld a, $30 ld a, $30
ld [rJOYP], a ldh [rJOYP], a
ld a, [rJOYP] ldh a, [rJOYP]
ld a, [rJOYP] ldh a, [rJOYP]
ld a, [rJOYP] ldh a, [rJOYP]
call SGBDelayCycles call SGBDelayCycles
call SGBDelayCycles call SGBDelayCycles
ld a, [rJOYP] ldh a, [rJOYP]
and $3 and $3
cp $3 cp $3
jr nz, .carry jr nz, .carry
@ -1056,24 +1056,24 @@ endr
SGBBorder_PushBGPals: SGBBorder_PushBGPals:
call DisableLCD call DisableLCD
ld a, %11100100 ld a, %11100100
ld [rBGP], a ldh [rBGP], a
ld hl, PredefPals ld hl, PredefPals
ld de, vTiles1 ld de, vTiles1
ld bc, $100 tiles ld bc, $100 tiles
call CopyData call CopyData
call DrawDefaultTiles call DrawDefaultTiles
ld a, LCDC_DEFAULT ld a, LCDC_DEFAULT
ld [rLCDC], a ldh [rLCDC], a
ld hl, PalTrnPacket ld hl, PalTrnPacket
call _PushSGBPals call _PushSGBPals
xor a xor a
ld [rBGP], a ldh [rBGP], a
ret ret
SGBBorder_MorePalPushing: SGBBorder_MorePalPushing:
call DisableLCD call DisableLCD
ld a, $e4 ld a, $e4
ld [rBGP], a ldh [rBGP], a
ld de, vTiles1 ld de, vTiles1
ld bc, 20 tiles ld bc, 20 tiles
call CopyData call CopyData
@ -1097,17 +1097,17 @@ SGBBorder_MorePalPushing:
call CopyData call CopyData
call DrawDefaultTiles call DrawDefaultTiles
ld a, LCDC_DEFAULT ld a, LCDC_DEFAULT
ld [rLCDC], a ldh [rLCDC], a
ld hl, PctTrnPacket ld hl, PctTrnPacket
call _PushSGBPals call _PushSGBPals
xor a xor a
ld [rBGP], a ldh [rBGP], a
ret ret
SGBBorder_YetMorePalPushing: SGBBorder_YetMorePalPushing:
call DisableLCD call DisableLCD
ld a, %11100100 ld a, %11100100
ld [rBGP], a ldh [rBGP], a
ld de, vTiles1 ld de, vTiles1
ld b, $80 ld b, $80
.loop .loop
@ -1121,11 +1121,11 @@ SGBBorder_YetMorePalPushing:
jr nz, .loop jr nz, .loop
call DrawDefaultTiles call DrawDefaultTiles
ld a, LCDC_DEFAULT ld a, LCDC_DEFAULT
ld [rLCDC], a ldh [rLCDC], a
ld hl, ChrTrnPacket ld hl, ChrTrnPacket
call _PushSGBPals call _PushSGBPals
xor a xor a
ld [rBGP], a ldh [rBGP], a
ret ret
CopyData: CopyData:
@ -1237,10 +1237,10 @@ LoadMapPals:
ld e, l ld e, l
ld d, h ld d, h
; Switch to palettes WRAM bank ; Switch to palettes WRAM bank
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 b, 8 ld b, 8
.outer_loop .outer_loop
@ -1269,7 +1269,7 @@ LoadMapPals:
dec b dec b
jr nz, .outer_loop jr nz, .outer_loop
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
.got_pals .got_pals
ld a, [wTimeOfDayPal] ld a, [wTimeOfDayPal]

View File

@ -158,7 +158,7 @@ MG_Mobile_Layout01:
farcall ApplyAttrMap farcall ApplyAttrMap
farcall ApplyPals farcall ApplyPals
ld a, $1 ld a, $1
ld [hCGBPalUpdate], a ldh [hCGBPalUpdate], a
ret ret
.Palette_49478: .Palette_49478:

View File

@ -10,11 +10,11 @@ HDMATransferAttrMapAndTileMapToWRAMBank3::
ld hl, wScratchTileMap ld hl, wScratchTileMap
call PadTilemapForHDMATransfer call PadTilemapForHDMATransfer
ld a, $0 ld a, $0
ld [rVBK], a ldh [rVBK], a
ld hl, wScratchTileMap ld hl, wScratchTileMap
call HDMATransferToWRAMBank3 call HDMATransferToWRAMBank3
ld a, $1 ld a, $1
ld [rVBK], a ldh [rVBK], a
ld hl, wScratchAttrMap ld hl, wScratchAttrMap
call HDMATransferToWRAMBank3 call HDMATransferToWRAMBank3
ret ret
@ -28,7 +28,7 @@ HDMATransferTileMapToWRAMBank3::
ld hl, wScratchTileMap ld hl, wScratchTileMap
call PadTilemapForHDMATransfer call PadTilemapForHDMATransfer
ld a, $0 ld a, $0
ld [rVBK], a ldh [rVBK], a
ld hl, wScratchTileMap ld hl, wScratchTileMap
call HDMATransferToWRAMBank3 call HDMATransferToWRAMBank3
ret ret
@ -42,7 +42,7 @@ HDMATransferAttrMapToWRAMBank3:
ld hl, wScratchAttrMap ld hl, wScratchAttrMap
call PadAttrMapForHDMATransfer call PadAttrMapForHDMATransfer
ld a, $1 ld a, $1
ld [rVBK], a ldh [rVBK], a
ld hl, wScratchAttrMap ld hl, wScratchAttrMap
call HDMATransferToWRAMBank3 call HDMATransferToWRAMBank3
ret ret
@ -61,18 +61,18 @@ ReloadMapPart::
call DelayFrame call DelayFrame
di di
ld a, [rVBK] ldh a, [rVBK]
push af push af
ld a, $1 ld a, $1
ld [rVBK], a ldh [rVBK], a
ld hl, wScratchAttrMap ld hl, wScratchAttrMap
call HDMATransfer_Wait127Scanlines_toBGMap call HDMATransfer_Wait127Scanlines_toBGMap
ld a, $0 ld a, $0
ld [rVBK], a ldh [rVBK], a
ld hl, wScratchTileMap ld hl, wScratchTileMap
call HDMATransfer_Wait127Scanlines_toBGMap call HDMATransfer_Wait127Scanlines_toBGMap
pop af pop af
ld [rVBK], a ldh [rVBK], a
ei ei
ret ret
@ -92,18 +92,18 @@ Mobile_ReloadMapPart:
call DelayFrame call DelayFrame
di di
ld a, [rVBK] ldh a, [rVBK]
push af push af
ld a, $1 ld a, $1
ld [rVBK], a ldh [rVBK], a
ld hl, wScratchAttrMap ld hl, wScratchAttrMap
call HDMATransfer_NoDI call HDMATransfer_NoDI
ld a, $0 ld a, $0
ld [rVBK], a ldh [rVBK], a
ld hl, wScratchTileMap ld hl, wScratchTileMap
call HDMATransfer_NoDI call HDMATransfer_NoDI
pop af pop af
ld [rVBK], a ldh [rVBK], a
ei ei
ret ret
@ -114,20 +114,20 @@ Mobile_ReloadMapPart:
.unreferenced_1040da .unreferenced_1040da
ld a, $1 ld a, $1
ld [rVBK], a ldh [rVBK], a
ld a, BANK(w3_d800) ld a, BANK(w3_d800)
ld [rSVBK], a ldh [rSVBK], a
ld de, w3_d800 ld de, w3_d800
ld a, [hBGMapAddress + 1] ldh a, [hBGMapAddress + 1]
ld [rHDMA1], a ldh [rHDMA1], a
ld a, [hBGMapAddress] ldh a, [hBGMapAddress]
ld [rHDMA2], a ldh [rHDMA2], a
ld a, d ld a, d
ld [rHDMA3], a ldh [rHDMA3], a
ld a, e ld a, e
ld [rHDMA4], a ldh [rHDMA4], a
ld a, $23 ld a, $23
ld [hDMATransfer], a ldh [hDMATransfer], a
call WaitDMATransfer call WaitDMATransfer
ret ret
@ -137,9 +137,9 @@ Mobile_ReloadMapPart:
.unreferenced_104101 .unreferenced_104101
ld a, $1 ld a, $1
ld [rVBK], a ldh [rVBK], a
ld a, BANK(w3_d800) ld a, BANK(w3_d800)
ld [rSVBK], a ldh [rSVBK], a
ld hl, w3_d800 ld hl, w3_d800
call HDMATransferToWRAMBank3 call HDMATransferToWRAMBank3
ret ret
@ -162,18 +162,18 @@ OpenAndCloseMenu_HDMATransferTileMapAndAttrMap::
call DelayFrame call DelayFrame
di di
ld a, [rVBK] ldh a, [rVBK]
push af push af
ld a, $1 ld a, $1
ld [rVBK], a ldh [rVBK], a
ld hl, wScratchAttrMap ld hl, wScratchAttrMap
call HDMATransfer_Wait123Scanlines_toBGMap call HDMATransfer_Wait123Scanlines_toBGMap
ld a, $0 ld a, $0
ld [rVBK], a ldh [rVBK], a
ld hl, wScratchTileMap ld hl, wScratchTileMap
call HDMATransfer_Wait123Scanlines_toBGMap call HDMATransfer_Wait123Scanlines_toBGMap
pop af pop af
ld [rVBK], a ldh [rVBK], a
ei ei
ret ret
@ -194,40 +194,40 @@ Mobile_OpenAndCloseMenu_HDMATransferTileMapAndAttrMap:
call PadMapForHDMATransfer call PadMapForHDMATransfer
ld a, $1 ld a, $1
ld [rVBK], a ldh [rVBK], a
ld hl, wScratchAttrMap ld hl, wScratchAttrMap
call HDMATransfer_Wait127Scanlines_toBGMap call HDMATransfer_Wait127Scanlines_toBGMap
ld a, $0 ld a, $0
ld [rVBK], a ldh [rVBK], a
ld hl, wScratchTileMap ld hl, wScratchTileMap
call HDMATransfer_Wait127Scanlines_toBGMap call HDMATransfer_Wait127Scanlines_toBGMap
ret ret
CallInSafeGFXMode: CallInSafeGFXMode:
ld a, [hBGMapMode] ldh a, [hBGMapMode]
push af push af
ld a, [hMapAnims] ldh a, [hMapAnims]
push af push af
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
ld [hMapAnims], a ldh [hMapAnims], a
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, BANK(wScratchTileMap) ld a, BANK(wScratchTileMap)
ld [rSVBK], a ldh [rSVBK], a
ld a, [rVBK] ldh a, [rVBK]
push af push af
call ._hl_ call ._hl_
pop af pop af
ld [rVBK], a ldh [rVBK], a
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
pop af pop af
ld [hMapAnims], a ldh [hMapAnims], a
pop af pop af
ld [hBGMapMode], a ldh [hBGMapMode], a
ret ret
._hl_ ._hl_
@ -236,12 +236,12 @@ CallInSafeGFXMode:
HDMATransferToWRAMBank3: HDMATransferToWRAMBank3:
call _LoadHDMAParameters call _LoadHDMAParameters
ld a, $23 ld a, $23
ld [hDMATransfer], a ldh [hDMATransfer], a
WaitDMATransfer: WaitDMATransfer:
.loop .loop
call DelayFrame call DelayFrame
ld a, [hDMATransfer] ldh a, [hDMATransfer]
and a and a
jr nz, .loop jr nz, .loop
ret ret
@ -250,9 +250,9 @@ HDMATransfer_Wait127Scanlines_toBGMap:
; HDMA transfer from hl to [hBGMapAddress] ; HDMA transfer from hl to [hBGMapAddress]
; hBGMapAddress -> de ; hBGMapAddress -> de
; 2 * SCREEN_HEIGHT -> c ; 2 * SCREEN_HEIGHT -> c
ld a, [hBGMapAddress + 1] ldh a, [hBGMapAddress + 1]
ld d, a ld d, a
ld a, [hBGMapAddress] ldh a, [hBGMapAddress]
ld e, a ld e, a
ld c, 2 * SCREEN_HEIGHT ld c, 2 * SCREEN_HEIGHT
jr HDMATransfer_Wait127Scanlines jr HDMATransfer_Wait127Scanlines
@ -262,9 +262,9 @@ HDMATransfer_Wait123Scanlines_toBGMap:
; hBGMapAddress -> de ; hBGMapAddress -> de
; 2 * SCREEN_HEIGHT -> c ; 2 * SCREEN_HEIGHT -> c
; $7b --> b ; $7b --> b
ld a, [hBGMapAddress + 1] ldh a, [hBGMapAddress + 1]
ld d, a ld d, a
ld a, [hBGMapAddress] ldh a, [hBGMapAddress]
ld e, a ld e, a
ld c, 2 * SCREEN_HEIGHT ld c, 2 * SCREEN_HEIGHT
jr HDMATransfer_Wait123Scanlines jr HDMATransfer_Wait123Scanlines
@ -273,25 +273,25 @@ HDMATransfer_NoDI:
; HDMA transfer from hl to [hBGMapAddress] ; HDMA transfer from hl to [hBGMapAddress]
; [hBGMapAddress] --> de ; [hBGMapAddress] --> de
; 2 * SCREEN_HEIGHT --> c ; 2 * SCREEN_HEIGHT --> c
ld a, [hBGMapAddress + 1] ldh a, [hBGMapAddress + 1]
ld d, a ld d, a
ld a, [hBGMapAddress] ldh a, [hBGMapAddress]
ld e, a ld e, a
ld c, 2 * SCREEN_HEIGHT ld c, 2 * SCREEN_HEIGHT
; [rHDMA1, rHDMA2] = hl & $fff0 ; [rHDMA1, rHDMA2] = hl & $fff0
ld a, h ld a, h
ld [rHDMA1], a ldh [rHDMA1], a
ld a, l ld a, l
and $f0 and $f0
ld [rHDMA2], a ldh [rHDMA2], a
; [rHDMA3, rHDMA4] = de & $1ff0 ; [rHDMA3, rHDMA4] = de & $1ff0
ld a, d ld a, d
and $1f and $1f
ld [rHDMA3], a ldh [rHDMA3], a
ld a, e ld a, e
and $f0 and $f0
ld [rHDMA4], a ldh [rHDMA4], a
; b = c | %10000000 ; b = c | %10000000
ld a, c ld a, c
dec c dec c
@ -303,19 +303,19 @@ HDMATransfer_NoDI:
ld d, a ld d, a
; while [rLY] >= d: pass ; while [rLY] >= d: pass
.loop1 .loop1
ld a, [rLY] ldh a, [rLY]
cp d cp d
jr nc, .loop1 jr nc, .loop1
; while not [rSTAT] & 3: pass ; while not [rSTAT] & 3: pass
.loop2 .loop2
ld a, [rSTAT] ldh a, [rSTAT]
and $3 and $3
jr z, .loop2 jr z, .loop2
; load the 5th byte of HDMA ; load the 5th byte of HDMA
ld a, b ld a, b
ld [rHDMA5], a ldh [rHDMA5], a
; wait until rLY advances (c + 1) times ; wait until rLY advances (c + 1) times
ld a, [rLY] ldh a, [rLY]
inc c inc c
ld hl, rLY ld hl, rLY
.loop3 .loop3
@ -338,17 +338,17 @@ _continue_HDMATransfer:
; a lot of waiting around for hardware registers ; a lot of waiting around for hardware registers
; [rHDMA1, rHDMA2] = hl & $fff0 ; [rHDMA1, rHDMA2] = hl & $fff0
ld a, h ld a, h
ld [rHDMA1], a ldh [rHDMA1], a
ld a, l ld a, l
and $f0 ; high nybble and $f0 ; high nybble
ld [rHDMA2], a ldh [rHDMA2], a
; [rHDMA3, rHDMA4] = de & $1ff0 ; [rHDMA3, rHDMA4] = de & $1ff0
ld a, d ld a, d
and $1f ; lower 5 bits and $1f ; lower 5 bits
ld [rHDMA3], a ldh [rHDMA3], a
ld a, e ld a, e
and $f0 ; high nybble and $f0 ; high nybble
ld [rHDMA4], a ldh [rHDMA4], a
; e = c | %10000000 ; e = c | %10000000
ld a, c ld a, c
dec c dec c
@ -360,26 +360,26 @@ _continue_HDMATransfer:
ld d, a ld d, a
; while [rLY] >= d: pass ; while [rLY] >= d: pass
.ly_loop .ly_loop
ld a, [rLY] ldh a, [rLY]
cp d cp d
jr nc, .ly_loop jr nc, .ly_loop
di di
; while [rSTAT] & 3: pass ; while [rSTAT] & 3: pass
.rstat_loop_1 .rstat_loop_1
ld a, [rSTAT] ldh a, [rSTAT]
and $3 and $3
jr nz, .rstat_loop_1 jr nz, .rstat_loop_1
; while not [rSTAT] & 3: pass ; while not [rSTAT] & 3: pass
.rstat_loop_2 .rstat_loop_2
ld a, [rSTAT] ldh a, [rSTAT]
and $3 and $3
jr z, .rstat_loop_2 jr z, .rstat_loop_2
; load the 5th byte of HDMA ; load the 5th byte of HDMA
ld a, e ld a, e
ld [rHDMA5], a ldh [rHDMA5], a
; wait until rLY advances (c + 1) times ; wait until rLY advances (c + 1) times
ld a, [rLY] ldh a, [rLY]
inc c inc c
ld hl, rLY ld hl, rLY
.final_ly_loop .final_ly_loop
@ -396,14 +396,14 @@ _continue_HDMATransfer:
_LoadHDMAParameters: _LoadHDMAParameters:
ld a, h ld a, h
ld [rHDMA1], a ldh [rHDMA1], a
ld a, l ld a, l
ld [rHDMA2], a ldh [rHDMA2], a
ld a, [hBGMapAddress + 1] ldh a, [hBGMapAddress + 1]
and $1f and $1f
ld [rHDMA3], a ldh [rHDMA3], a
ld a, [hBGMapAddress] ldh a, [hBGMapAddress]
ld [rHDMA4], a ldh [rHDMA4], a
ret ret
PadTilemapForHDMATransfer: PadTilemapForHDMATransfer:
@ -416,10 +416,10 @@ PadAttrMapForHDMATransfer:
PadMapForHDMATransfer: PadMapForHDMATransfer:
; pad a 20x18 map to 32x18 for HDMA transfer ; pad a 20x18 map to 32x18 for HDMA transfer
; back up the padding value in c to hMapObjectIndexBuffer ; back up the padding value in c to hMapObjectIndexBuffer
ld a, [hMapObjectIndexBuffer] ldh a, [hMapObjectIndexBuffer]
push af push af
ld a, c ld a, c
ld [hMapObjectIndexBuffer], a ldh [hMapObjectIndexBuffer], a
; for each row on the screen ; for each row on the screen
ld c, SCREEN_HEIGHT ld c, SCREEN_HEIGHT
@ -435,7 +435,7 @@ PadMapForHDMATransfer:
jr nz, .loop2 jr nz, .loop2
; load the original padding value of c into hl for 32 - 20 = 12 rows ; load the original padding value of c into hl for 32 - 20 = 12 rows
ld a, [hMapObjectIndexBuffer] ldh a, [hMapObjectIndexBuffer]
ld b, BG_MAP_WIDTH - SCREEN_WIDTH ld b, BG_MAP_WIDTH - SCREEN_WIDTH
.loop3 .loop3
ld [hli], a ld [hli], a
@ -447,16 +447,16 @@ PadMapForHDMATransfer:
; restore the original value of hMapObjectIndexBuffer ; restore the original value of hMapObjectIndexBuffer
pop af pop af
ld [hMapObjectIndexBuffer], a ldh [hMapObjectIndexBuffer], a
ret ret
_Get2bpp:: _Get2bpp::
; 2bpp when [rLCDC] & $80 ; 2bpp when [rLCDC] & $80
; switch to WRAM bank 6 ; switch to WRAM bank 6
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, BANK(wScratchTileMap) ld a, BANK(wScratchTileMap)
ld [rSVBK], a ldh [rSVBK], a
push bc push bc
push hl push hl
@ -491,7 +491,7 @@ _Get2bpp::
; restore the previous bank ; restore the previous bank
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ret ret
_Get1bpp:: _Get1bpp::
@ -521,10 +521,10 @@ _Get1bpp::
jr .loop jr .loop
.bankswitch .bankswitch
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, BANK(wScratchTileMap) ld a, BANK(wScratchTileMap)
ld [rSVBK], a ldh [rSVBK], a
push bc push bc
push hl push hl
@ -555,7 +555,7 @@ _Get1bpp::
call HDMATransfer_Wait127Scanlines call HDMATransfer_Wait127Scanlines
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ret ret
HDMATransfer_OnlyTopFourRows: HDMATransfer_OnlyTopFourRows:
@ -570,13 +570,13 @@ HDMATransfer_OnlyTopFourRows:
decoord 0, 0, wAttrMap decoord 0, 0, wAttrMap
call .Copy call .Copy
ld a, $1 ld a, $1
ld [rVBK], a ldh [rVBK], a
ld c, $8 ld c, $8
ld hl, wScratchTileMap + $80 ld hl, wScratchTileMap + $80
debgcoord 0, 0, vBGMap1 debgcoord 0, 0, vBGMap1
call HDMATransfer_Wait127Scanlines call HDMATransfer_Wait127Scanlines
ld a, $0 ld a, $0
ld [rVBK], a ldh [rVBK], a
ld c, $8 ld c, $8
ld hl, wScratchTileMap ld hl, wScratchTileMap
debgcoord 0, 0, vBGMap1 debgcoord 0, 0, vBGMap1

View File

@ -22,7 +22,7 @@ _LoadStandardFont::
ld de, Font ld de, Font
ld hl, vTiles1 ld hl, vTiles1
lb bc, BANK(Font), 128 ; "A" to "9" lb bc, BANK(Font), 128 ; "A" to "9"
ld a, [rLCDC] ldh a, [rLCDC]
bit rLCDC_ENABLE, a bit rLCDC_ENABLE, a
jp z, Copy1bpp jp z, Copy1bpp

View File

@ -32,18 +32,18 @@ GetUnownLetter:
or b or b
; Divide by 10 to get 0-25 ; Divide by 10 to get 0-25
ld [hDividend + 3], a ldh [hDividend + 3], a
xor a xor a
ld [hDividend], a ldh [hDividend], a
ld [hDividend + 1], a ldh [hDividend + 1], a
ld [hDividend + 2], a ldh [hDividend + 2], a
ld a, $ff / NUM_UNOWN + 1 ld a, $ff / NUM_UNOWN + 1
ld [hDivisor], a ldh [hDivisor], a
ld b, 4 ld b, 4
call Divide call Divide
; Increment to get 1-26 ; Increment to get 1-26
ld a, [hQuotient + 2] ldh a, [hQuotient + 2]
inc a inc a
ld [wUnownLetter], a ld [wUnownLetter], a
ret ret
@ -53,11 +53,11 @@ GetMonFrontpic:
ld [wCurSpecies], a ld [wCurSpecies], a
call IsAPokemon call IsAPokemon
ret c ret c
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
call _GetFrontpic call _GetFrontpic
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ret ret
GetAnimatedFrontpic: GetAnimatedFrontpic:
@ -65,14 +65,14 @@ GetAnimatedFrontpic:
ld [wCurSpecies], a ld [wCurSpecies], a
call IsAPokemon call IsAPokemon
ret c ret c
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
call _GetFrontpic call _GetFrontpic
call GetAnimatedEnemyFrontpic call GetAnimatedEnemyFrontpic
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ret ret
_GetFrontpic: _GetFrontpic:
@ -84,7 +84,7 @@ _GetFrontpic:
push bc push bc
call GetFrontpicPointer call GetFrontpicPointer
ld a, BANK(wDecompressEnemyFrontpic) ld a, BANK(wDecompressEnemyFrontpic)
ld [rSVBK], a ldh [rSVBK], a
ld a, b ld a, b
ld de, wDecompressEnemyFrontpic ld de, wDecompressEnemyFrontpic
call FarDecompress call FarDecompress
@ -96,7 +96,7 @@ _GetFrontpic:
push hl push hl
ld de, wDecompressScratch ld de, wDecompressScratch
ld c, 7 * 7 ld c, 7 * 7
ld a, [hROMBank] ldh a, [hROMBank]
ld b, a ld b, a
call Get2bpp call Get2bpp
pop hl pop hl
@ -131,11 +131,11 @@ GetFrontpicPointer:
GetAnimatedEnemyFrontpic: GetAnimatedEnemyFrontpic:
ld a, BANK(vTiles3) ld a, BANK(vTiles3)
ld [rVBK], a ldh [rVBK], a
push hl push hl
ld de, wDecompressScratch ld de, wDecompressScratch
ld c, 7 * 7 ld c, 7 * 7
ld a, [hROMBank] ldh a, [hROMBank]
ld b, a ld b, a
call Get2bpp call Get2bpp
pop hl pop hl
@ -164,11 +164,11 @@ GetAnimatedEnemyFrontpic:
pop bc pop bc
pop hl pop hl
ld de, wDecompressScratch ld de, wDecompressScratch
ld a, [hROMBank] ldh a, [hROMBank]
ld b, a ld b, a
call Get2bpp call Get2bpp
xor a xor a
ld [rVBK], a ldh [rVBK], a
ret ret
LoadFrontpicTiles: LoadFrontpicTiles:
@ -201,10 +201,10 @@ GetMonBackpic:
ld b, a ld b, a
ld a, [wUnownLetter] ld a, [wUnownLetter]
ld c, a ld c, a
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 de push de
; These are assumed to be at the same address in their respective banks. ; These are assumed to be at the same address in their respective banks.
@ -236,11 +236,11 @@ GetMonBackpic:
call FixBackpicAlignment call FixBackpicAlignment
pop hl pop hl
ld de, wDecompressScratch ld de, wDecompressScratch
ld a, [hROMBank] ldh a, [hROMBank]
ld b, a ld b, a
call Get2bpp call Get2bpp
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ret ret
FixPicBank: FixPicBank:
@ -314,16 +314,16 @@ GetTrainerPic:
ret nc ret nc
call WaitBGMap call WaitBGMap
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
ld hl, TrainerPicPointers ld hl, TrainerPicPointers
ld a, [wTrainerClass] ld a, [wTrainerClass]
dec a dec a
ld bc, 3 ld bc, 3
call AddNTimes call AddNTimes
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 de push de
ld a, BANK(TrainerPicPointers) ld a, BANK(TrainerPicPointers)
call GetFarByte call GetFarByte
@ -338,23 +338,23 @@ GetTrainerPic:
pop hl pop hl
ld de, wDecompressScratch ld de, wDecompressScratch
ld c, 7 * 7 ld c, 7 * 7
ld a, [hROMBank] ldh a, [hROMBank]
ld b, a ld b, a
call Get2bpp call Get2bpp
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
call WaitBGMap call WaitBGMap
ld a, $1 ld a, $1
ld [hBGMapMode], a ldh [hBGMapMode], a
ret ret
DecompressGet2bpp: DecompressGet2bpp:
; Decompress lz data from b:hl to scratch space at 6:d000, then copy it to address de. ; Decompress lz data from b:hl to scratch space at 6:d000, then copy it to address de.
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 de push de
push bc push bc
@ -364,12 +364,12 @@ DecompressGet2bpp:
pop bc pop bc
ld de, wDecompressScratch ld de, wDecompressScratch
pop hl pop hl
ld a, [hROMBank] ldh a, [hROMBank]
ld b, a ld b, a
call Get2bpp call Get2bpp
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ret ret
FixBackpicAlignment: FixBackpicAlignment:

View File

@ -12,7 +12,7 @@ WriteOAMDMACodeToHRAM::
.PushOAM: .PushOAM:
ld a, HIGH(wVirtualOAM) ld a, HIGH(wVirtualOAM)
ld [rDMA], a ldh [rDMA], a
ld a, NUM_SPRITE_OAM_STRUCTS ld a, NUM_SPRITE_OAM_STRUCTS
.pushoam_loop .pushoam_loop
dec a dec a

View File

@ -51,7 +51,7 @@ LoadMenuMonIcon:
.GetPartyMonItemGFX: .GetPartyMonItemGFX:
push bc push bc
ld a, [hObjectStructIndexBuffer] ldh a, [hObjectStructIndexBuffer]
ld hl, wPartyMon1Item ld hl, wPartyMon1Item
ld bc, PARTYMON_STRUCT_LENGTH ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes call AddNTimes
@ -125,7 +125,7 @@ PartyMenu_InitAnimatedMonIcon:
.SpawnItemIcon: .SpawnItemIcon:
push bc push bc
ld a, [hObjectStructIndexBuffer] ldh a, [hObjectStructIndexBuffer]
ld hl, wPartyMon1Item ld hl, wPartyMon1Item
ld bc, PARTYMON_STRUCT_LENGTH ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes call AddNTimes
@ -154,7 +154,7 @@ PartyMenu_InitAnimatedMonIcon:
InitPartyMenuIcon: InitPartyMenuIcon:
ld a, [wCurIconTile] ld a, [wCurIconTile]
push af push af
ld a, [hObjectStructIndexBuffer] ldh a, [hObjectStructIndexBuffer]
ld hl, wPartySpecies ld hl, wPartySpecies
ld e, a ld e, a
ld d, 0 ld d, 0
@ -163,7 +163,7 @@ InitPartyMenuIcon:
call ReadMonMenuIcon call ReadMonMenuIcon
ld [wCurIcon], a ld [wCurIcon], a
call GetMemIconGFX call GetMemIconGFX
ld a, [hObjectStructIndexBuffer] ldh a, [hObjectStructIndexBuffer]
; y coord ; y coord
add a add a
add a add a
@ -184,7 +184,7 @@ InitPartyMenuIcon:
SetPartyMonIconAnimSpeed: SetPartyMonIconAnimSpeed:
push bc push bc
ld a, [hObjectStructIndexBuffer] ldh a, [hObjectStructIndexBuffer]
ld b, a ld b, a
call .getspeed call .getspeed
ld a, b ld a, b

View File

@ -107,10 +107,10 @@ LoadMonAnimation:
ret ret
SetUpPokeAnim: SetUpPokeAnim:
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, BANK(wPokeAnimStruct) ld a, BANK(wPokeAnimStruct)
ld [rSVBK], a ldh [rSVBK], a
ld a, [wPokeAnimSceneIndex] ld a, [wPokeAnimSceneIndex]
ld c, a ld c, a
ld b, 0 ld b, 0
@ -125,7 +125,7 @@ SetUpPokeAnim:
ld a, [wPokeAnimSceneIndex] ld a, [wPokeAnimSceneIndex]
ld c, a ld c, a
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ld a, c ld a, c
and $80 and $80
ret z ret z
@ -256,16 +256,16 @@ PokeAnim_StereoCry:
ret ret
PokeAnim_DeinitFrames: PokeAnim_DeinitFrames:
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, BANK(wPokeAnimCoord) ld a, BANK(wPokeAnimCoord)
ld [rSVBK], a ldh [rSVBK], a
call PokeAnim_PlaceGraphic call PokeAnim_PlaceGraphic
farcall HDMATransferTileMapToWRAMBank3 farcall HDMATransferTileMapToWRAMBank3
call PokeAnim_SetVBank0 call PokeAnim_SetVBank0
farcall HDMATransferAttrMapToWRAMBank3 farcall HDMATransferAttrMapToWRAMBank3
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ret ret
AnimateMon_CheckIfPokemon: AnimateMon_CheckIfPokemon:
@ -282,10 +282,10 @@ AnimateMon_CheckIfPokemon:
ret ret
PokeAnim_InitPicAttributes: PokeAnim_InitPicAttributes:
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, BANK(wPokeAnimStruct) ld a, BANK(wPokeAnimStruct)
ld [rSVBK], a ldh [rSVBK], a
push bc push bc
push de push de
@ -330,14 +330,14 @@ PokeAnim_InitPicAttributes:
ld [wPokeAnimFrontpicHeight], a ld [wPokeAnimFrontpicHeight], a
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ret ret
PokeAnim_InitAnim: PokeAnim_InitAnim:
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, BANK(wPokeAnimIdleFlag) ld a, BANK(wPokeAnimIdleFlag)
ld [rSVBK], a ldh [rSVBK], a
push bc push bc
ld hl, wPokeAnimIdleFlag ld hl, wPokeAnimIdleFlag
ld bc, wPokeAnimStructEnd - wPokeAnimIdleFlag ld bc, wPokeAnimStructEnd - wPokeAnimIdleFlag
@ -352,12 +352,12 @@ PokeAnim_InitAnim:
call GetMonFramesPointer call GetMonFramesPointer
call GetMonBitmaskPointer call GetMonBitmaskPointer
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ret ret
PokeAnim_DoAnimScript: PokeAnim_DoAnimScript:
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
.loop .loop
ld a, [wPokeAnimJumptableIndex] ld a, [wPokeAnimJumptableIndex]
and $7f and $7f
@ -823,16 +823,16 @@ PokeAnim_PlaceGraphic:
ret ret
PokeAnim_SetVBank1: PokeAnim_SetVBank1:
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, BANK(wPokeAnimCoord) ld a, BANK(wPokeAnimCoord)
ld [rSVBK], a ldh [rSVBK], a
xor a xor a
ld [hBGMapMode], a ldh [hBGMapMode], a
call .SetFlag call .SetFlag
farcall HDMATransferAttrMapToWRAMBank3 farcall HDMATransferAttrMapToWRAMBank3
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ret ret
.SetFlag: .SetFlag:
@ -943,10 +943,10 @@ GetMonAnimPointer:
ret ret
PokeAnim_GetFrontpicDims: PokeAnim_GetFrontpicDims:
ld a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, BANK(wCurPartySpecies) ld a, BANK(wCurPartySpecies)
ld [rSVBK], a ldh [rSVBK], a
ld a, [wCurPartySpecies] ld a, [wCurPartySpecies]
ld [wCurSpecies], a ld [wCurSpecies], a
call GetBaseData call GetBaseData
@ -954,7 +954,7 @@ PokeAnim_GetFrontpicDims:
and $f and $f
ld c, a ld c, a
pop af pop af
ld [rSVBK], a ldh [rSVBK], a
ret ret
GetMonFramesPointer: GetMonFramesPointer:

View File

@ -8,7 +8,7 @@ PlaceGraphic:
and a and a
jr nz, .right jr nz, .right
ld a, [hGraphicStartTile] ldh a, [hGraphicStartTile]
.x1 .x1
push bc push bc
push hl push hl
@ -35,7 +35,7 @@ PlaceGraphic:
add hl, bc add hl, bc
pop bc pop bc
ld a, [hGraphicStartTile] ldh a, [hGraphicStartTile]
.x2 .x2
push bc push bc
push hl push hl

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