Specify the ldh instruction, don't turn ld into ldh

This commit is contained in:
Rangi 2020-07-06 19:03:05 -04:00
parent c480632d54
commit 772fcc7588
219 changed files with 2556 additions and 2556 deletions

View file

@ -58,7 +58,7 @@ tools:
$(MAKE) -C tools/ $(MAKE) -C tools/
RGBASMFLAGS = -h -Weverything RGBASMFLAGS = -h -L -Weverything
# Create a sym/map for debug purposes if `make` run with `DEBUG=1` # Create a sym/map for debug purposes if `make` run with `DEBUG=1`
ifeq ($(DEBUG),1) ifeq ($(DEBUG),1)
RGBASMFLAGS += -E RGBASMFLAGS += -E

View file

@ -20,10 +20,10 @@ Audio1_UpdateMusic::
set 7, a set 7, a
ld [wMuteAudioAndPauseMusic], a ld [wMuteAudioAndPauseMusic], a
xor a ; disable all channels' output xor a ; disable all channels' output
ld [rNR51], a ldh [rNR51], a
ld [rNR30], a ldh [rNR30], a
ld a, $80 ld a, $80
ld [rNR30], a ldh [rNR30], a
jr .nextChannel jr .nextChannel
.applyAffects .applyAffects
call Audio1_ApplyMusicAffects call Audio1_ApplyMusicAffects
@ -183,9 +183,9 @@ Audio1_sound_ret:
jr nz, .skipSfxChannel3 jr nz, .skipSfxChannel3
; restart hardware channel 3 (wave channel) output ; restart hardware channel 3 (wave channel) output
ld a, $0 ld a, $0
ld [rNR30], a ldh [rNR30], a
ld a, $80 ld a, $80
ld [rNR30], a ldh [rNR30], a
.skipSfxChannel3 .skipSfxChannel3
jr nz, .dontDisable jr nz, .dontDisable
ld a, [wDisableChannelOutputWhenSfxEnds] ld a, [wDisableChannelOutputWhenSfxEnds]
@ -219,9 +219,9 @@ Audio1_sound_ret:
.disableChannelOutput .disableChannelOutput
ld hl, Audio1_HWChannelDisableMasks ld hl, Audio1_HWChannelDisableMasks
add hl, bc add hl, bc
ld a, [rNR51] ldh a, [rNR51]
and [hl] and [hl]
ld [rNR51], a ldh [rNR51], a
.afterDisable .afterDisable
ld a, [wChannelSoundIDs + Ch5] ld a, [wChannelSoundIDs + Ch5]
cp CRY_SFX_START cp CRY_SFX_START
@ -241,7 +241,7 @@ Audio1_sound_ret:
ret c ret c
.skipRewind .skipRewind
ld a, [wSavedVolume] ld a, [wSavedVolume]
ld [rNR50], a ldh [rNR50], a
xor a xor a
ld [wSavedVolume], a ld [wSavedVolume], a
.skipCry .skipCry
@ -548,7 +548,7 @@ Audio1_volume:
cp $f0 ; is this command a volume? cp $f0 ; is this command a volume?
jr nz, Audio1_execute_music ; no jr nz, Audio1_execute_music ; no
call Audio1_GetNextMusicByte call Audio1_GetNextMusicByte
ld [rNR50], a ; store volume ldh [rNR50], a ; store volume
jp Audio1_sound_ret jp Audio1_sound_ret
Audio1_execute_music: Audio1_execute_music:
@ -638,7 +638,7 @@ Audio1_pitch_sweep:
bit BIT_EXECUTE_MUSIC, [hl] bit BIT_EXECUTE_MUSIC, [hl]
jr nz, Audio1_note ; no jr nz, Audio1_note ; no
call Audio1_GetNextMusicByte call Audio1_GetNextMusicByte
ld [rNR10], a ldh [rNR10], a
jp Audio1_sound_ret jp Audio1_sound_ret
Audio1_note: Audio1_note:
@ -770,9 +770,9 @@ Audio1_note_pitch:
ld b, 0 ld b, 0
ld hl, Audio1_HWChannelDisableMasks ld hl, Audio1_HWChannelDisableMasks
add hl, bc add hl, bc
ld a, [rNR51] ldh a, [rNR51]
and [hl] and [hl]
ld [rNR51], a ; disable hardware channel 3's output ldh [rNR51], a ; disable hardware channel 3's output
jr .done jr .done
.notChannel3 .notChannel3
ld b, REG_VOLUME_ENVELOPE ld b, REG_VOLUME_ENVELOPE
@ -844,7 +844,7 @@ Audio1_EnableChannelOutput:
ld b, 0 ld b, 0
ld hl, Audio1_HWChannelEnableMasks ld hl, Audio1_HWChannelEnableMasks
add hl, bc add hl, bc
ld a, [rNR51] ldh a, [rNR51]
or [hl] ; set this channel's bits or [hl] ; set this channel's bits
ld d, a ld d, a
ld a, c ld a, c
@ -866,7 +866,7 @@ Audio1_EnableChannelOutput:
add hl, bc add hl, bc
and [hl] and [hl]
ld d, a ld d, a
ld a, [rNR51] ldh a, [rNR51]
ld hl, Audio1_HWChannelDisableMasks ld hl, Audio1_HWChannelDisableMasks
add hl, bc add hl, bc
and [hl] ; reset this channel's output bits and [hl] ; reset this channel's output bits
@ -874,7 +874,7 @@ Audio1_EnableChannelOutput:
ld d, a ld d, a
.skip .skip
ld a, d ld a, d
ld [rNR51], a ldh [rNR51], a
ret ret
Audio1_ApplyDutyCycleAndSoundLength: Audio1_ApplyDutyCycleAndSoundLength:
@ -928,7 +928,7 @@ Audio1_ApplyWavePatternAndFrequency:
ld hl, rWave_0 ld hl, rWave_0
ld b, $f ld b, $f
ld a, $0 ; stop hardware channel 3 ld a, $0 ; stop hardware channel 3
ld [rNR30], a ldh [rNR30], a
.loop .loop
ld a, [de] ld a, [de]
inc de inc de
@ -938,7 +938,7 @@ Audio1_ApplyWavePatternAndFrequency:
and a and a
jr nz, .loop jr nz, .loop
ld a, $80 ; start hardware channel 3 ld a, $80 ; start hardware channel 3
ld [rNR30], a ldh [rNR30], a
pop de pop de
.notChannel3 .notChannel3
ld a, d ld a, d
@ -1399,17 +1399,17 @@ Audio1_PlaySound::
ld a, $ff ld a, $ff
ld [wStereoPanning], a ld [wStereoPanning], a
xor a xor a
ld [rNR50], a ldh [rNR50], a
ld a, $8 ld a, $8
ld [rNR10], a ldh [rNR10], a
ld a, 0 ld a, 0
ld [rNR51], a ldh [rNR51], a
xor a xor a
ld [rNR30], a ldh [rNR30], a
ld a, $80 ld a, $80
ld [rNR30], a ldh [rNR30], a
ld a, $77 ld a, $77
ld [rNR50], a ldh [rNR50], a
jp .playSoundCommon jp .playSoundCommon
.playSfx .playSfx
@ -1555,7 +1555,7 @@ Audio1_PlaySound::
cp Ch5 cp Ch5
jr nz, .skipSweepDisable jr nz, .skipSweepDisable
ld a, $8 ld a, $8
ld [rNR10], a ; sweep off ldh [rNR10], a ; sweep off
.skipSweepDisable .skipSweepDisable
ld a, c ld a, c
and a and a
@ -1565,22 +1565,22 @@ Audio1_PlaySound::
.stopAllAudio .stopAllAudio
ld a, $80 ld a, $80
ld [rNR52], a ; sound hardware on ldh [rNR52], a ; sound hardware on
ld [rNR30], a ; wave playback on ldh [rNR30], a ; wave playback on
xor a xor a
ld [rNR51], a ; no sound output ldh [rNR51], a ; no sound output
ld [rNR32], a ; mute channel 3 (wave channel) ldh [rNR32], a ; mute channel 3 (wave channel)
ld a, $8 ld a, $8
ld [rNR10], a ; sweep off ldh [rNR10], a ; sweep off
ld [rNR12], a ; mute channel 1 (pulse channel 1) ldh [rNR12], a ; mute channel 1 (pulse channel 1)
ld [rNR22], a ; mute channel 2 (pulse channel 2) ldh [rNR22], a ; mute channel 2 (pulse channel 2)
ld [rNR42], a ; mute channel 4 (noise channel) ldh [rNR42], a ; mute channel 4 (noise channel)
ld a, $40 ld a, $40
ld [rNR14], a ; counter mode ldh [rNR14], a ; counter mode
ld [rNR24], a ldh [rNR24], a
ld [rNR44], a ldh [rNR44], a
ld a, $77 ld a, $77
ld [rNR50], a ; full volume ldh [rNR50], a ; full volume
xor a xor a
ld [wUnusedC000], a ld [wUnusedC000], a
ld [wDisableChannelOutputWhenSfxEnds], a ld [wDisableChannelOutputWhenSfxEnds], a
@ -1699,10 +1699,10 @@ Audio1_PlaySound::
ld a, [wSavedVolume] ld a, [wSavedVolume]
and a and a
jr nz, .done jr nz, .done
ld a, [rNR50] ldh a, [rNR50]
ld [wSavedVolume], a ld [wSavedVolume], a
ld a, $77 ld a, $77
ld [rNR50], a ; full volume ldh [rNR50], a ; full volume
.done .done
ret ret

View file

@ -22,10 +22,10 @@ Audio2_UpdateMusic::
set 7, a set 7, a
ld [wMuteAudioAndPauseMusic], a ld [wMuteAudioAndPauseMusic], a
xor a ; disable all channels' output xor a ; disable all channels' output
ld [rNR51], a ldh [rNR51], a
ld [rNR30], a ldh [rNR30], a
ld a, $80 ld a, $80
ld [rNR30], a ldh [rNR30], a
jr .nextChannel jr .nextChannel
.applyAffects .applyAffects
call Audio2_ApplyMusicAffects call Audio2_ApplyMusicAffects
@ -194,9 +194,9 @@ Audio2_sound_ret:
jr nz, .skipSfxChannel3 jr nz, .skipSfxChannel3
; restart hardware channel 3 (wave channel) output ; restart hardware channel 3 (wave channel) output
ld a, $0 ld a, $0
ld [rNR30], a ldh [rNR30], a
ld a, $80 ld a, $80
ld [rNR30], a ldh [rNR30], a
.skipSfxChannel3 .skipSfxChannel3
jr nz, .dontDisable jr nz, .dontDisable
ld a, [wDisableChannelOutputWhenSfxEnds] ld a, [wDisableChannelOutputWhenSfxEnds]
@ -230,9 +230,9 @@ Audio2_sound_ret:
.disableChannelOutput .disableChannelOutput
ld hl, Audio2_HWChannelDisableMasks ld hl, Audio2_HWChannelDisableMasks
add hl, bc add hl, bc
ld a, [rNR51] ldh a, [rNR51]
and [hl] and [hl]
ld [rNR51], a ldh [rNR51], a
.afterDisable .afterDisable
ld a, [wChannelSoundIDs + Ch5] ld a, [wChannelSoundIDs + Ch5]
cp CRY_SFX_START cp CRY_SFX_START
@ -252,7 +252,7 @@ Audio2_sound_ret:
ret c ret c
.skipRewind .skipRewind
ld a, [wSavedVolume] ld a, [wSavedVolume]
ld [rNR50], a ldh [rNR50], a
xor a xor a
ld [wSavedVolume], a ld [wSavedVolume], a
.skipCry .skipCry
@ -559,7 +559,7 @@ Audio2_volume:
cp $f0 ; is this command a volume? cp $f0 ; is this command a volume?
jr nz, Audio2_execute_music ; no jr nz, Audio2_execute_music ; no
call Audio2_GetNextMusicByte call Audio2_GetNextMusicByte
ld [rNR50], a ; store volume ldh [rNR50], a ; store volume
jp Audio2_sound_ret jp Audio2_sound_ret
Audio2_execute_music: Audio2_execute_music:
@ -649,7 +649,7 @@ Audio2_pitch_sweep:
bit BIT_EXECUTE_MUSIC, [hl] bit BIT_EXECUTE_MUSIC, [hl]
jr nz, Audio2_note ; no jr nz, Audio2_note ; no
call Audio2_GetNextMusicByte call Audio2_GetNextMusicByte
ld [rNR10], a ldh [rNR10], a
jp Audio2_sound_ret jp Audio2_sound_ret
Audio2_note: Audio2_note:
@ -781,9 +781,9 @@ Audio2_note_pitch:
ld b, 0 ld b, 0
ld hl, Audio2_HWChannelDisableMasks ld hl, Audio2_HWChannelDisableMasks
add hl, bc add hl, bc
ld a, [rNR51] ldh a, [rNR51]
and [hl] and [hl]
ld [rNR51], a ; disable hardware channel 3's output ldh [rNR51], a ; disable hardware channel 3's output
jr .done jr .done
.notChannel3 .notChannel3
ld b, REG_VOLUME_ENVELOPE ld b, REG_VOLUME_ENVELOPE
@ -855,7 +855,7 @@ Audio2_EnableChannelOutput:
ld b, 0 ld b, 0
ld hl, Audio2_HWChannelEnableMasks ld hl, Audio2_HWChannelEnableMasks
add hl, bc add hl, bc
ld a, [rNR51] ldh a, [rNR51]
or [hl] ; set this channel's bits or [hl] ; set this channel's bits
ld d, a ld d, a
ld a, c ld a, c
@ -877,7 +877,7 @@ Audio2_EnableChannelOutput:
add hl, bc add hl, bc
and [hl] and [hl]
ld d, a ld d, a
ld a, [rNR51] ldh a, [rNR51]
ld hl, Audio2_HWChannelDisableMasks ld hl, Audio2_HWChannelDisableMasks
add hl, bc add hl, bc
and [hl] ; reset this channel's output bits and [hl] ; reset this channel's output bits
@ -885,7 +885,7 @@ Audio2_EnableChannelOutput:
ld d, a ld d, a
.skip .skip
ld a, d ld a, d
ld [rNR51], a ldh [rNR51], a
ret ret
Audio2_ApplyDutyCycleAndSoundLength: Audio2_ApplyDutyCycleAndSoundLength:
@ -939,7 +939,7 @@ Audio2_ApplyWavePatternAndFrequency:
ld hl, rWave_0 ld hl, rWave_0
ld b, $f ld b, $f
ld a, $0 ; stop hardware channel 3 ld a, $0 ; stop hardware channel 3
ld [rNR30], a ldh [rNR30], a
.loop .loop
ld a, [de] ld a, [de]
inc de inc de
@ -949,7 +949,7 @@ Audio2_ApplyWavePatternAndFrequency:
and a and a
jr nz, .loop jr nz, .loop
ld a, $80 ; start hardware channel 3 ld a, $80 ; start hardware channel 3
ld [rNR30], a ldh [rNR30], a
pop de pop de
.notChannel3 .notChannel3
ld a, d ld a, d
@ -1462,17 +1462,17 @@ Audio2_PlaySound::
ld a, $ff ld a, $ff
ld [wStereoPanning], a ld [wStereoPanning], a
xor a xor a
ld [rNR50], a ldh [rNR50], a
ld a, $8 ld a, $8
ld [rNR10], a ldh [rNR10], a
ld a, 0 ld a, 0
ld [rNR51], a ldh [rNR51], a
xor a xor a
ld [rNR30], a ldh [rNR30], a
ld a, $80 ld a, $80
ld [rNR30], a ldh [rNR30], a
ld a, $77 ld a, $77
ld [rNR50], a ldh [rNR50], a
jp .playSoundCommon jp .playSoundCommon
.playSfx .playSfx
@ -1618,7 +1618,7 @@ Audio2_PlaySound::
cp Ch5 cp Ch5
jr nz, .skipSweepDisable jr nz, .skipSweepDisable
ld a, $8 ld a, $8
ld [rNR10], a ; sweep off ldh [rNR10], a ; sweep off
.skipSweepDisable .skipSweepDisable
ld a, c ld a, c
and a and a
@ -1628,22 +1628,22 @@ Audio2_PlaySound::
.stopAllAudio .stopAllAudio
ld a, $80 ld a, $80
ld [rNR52], a ; sound hardware on ldh [rNR52], a ; sound hardware on
ld [rNR30], a ; wave playback on ldh [rNR30], a ; wave playback on
xor a xor a
ld [rNR51], a ; no sound output ldh [rNR51], a ; no sound output
ld [rNR32], a ; mute channel 3 (wave channel) ldh [rNR32], a ; mute channel 3 (wave channel)
ld a, $8 ld a, $8
ld [rNR10], a ; sweep off ldh [rNR10], a ; sweep off
ld [rNR12], a ; mute channel 1 (pulse channel 1) ldh [rNR12], a ; mute channel 1 (pulse channel 1)
ld [rNR22], a ; mute channel 2 (pulse channel 2) ldh [rNR22], a ; mute channel 2 (pulse channel 2)
ld [rNR42], a ; mute channel 4 (noise channel) ldh [rNR42], a ; mute channel 4 (noise channel)
ld a, $40 ld a, $40
ld [rNR14], a ; counter mode ldh [rNR14], a ; counter mode
ld [rNR24], a ldh [rNR24], a
ld [rNR44], a ldh [rNR44], a
ld a, $77 ld a, $77
ld [rNR50], a ; full volume ldh [rNR50], a ; full volume
xor a xor a
ld [wUnusedC000], a ld [wUnusedC000], a
ld [wDisableChannelOutputWhenSfxEnds], a ld [wDisableChannelOutputWhenSfxEnds], a
@ -1762,10 +1762,10 @@ Audio2_PlaySound::
ld a, [wSavedVolume] ld a, [wSavedVolume]
and a and a
jr nz, .done jr nz, .done
ld a, [rNR50] ldh a, [rNR50]
ld [wSavedVolume], a ld [wSavedVolume], a
ld a, $77 ld a, $77
ld [rNR50], a ; full volume ldh [rNR50], a ; full volume
.done .done
ret ret

View file

@ -20,10 +20,10 @@ Audio3_UpdateMusic::
set 7, a set 7, a
ld [wMuteAudioAndPauseMusic], a ld [wMuteAudioAndPauseMusic], a
xor a ; disable all channels' output xor a ; disable all channels' output
ld [rNR51], a ldh [rNR51], a
ld [rNR30], a ldh [rNR30], a
ld a, $80 ld a, $80
ld [rNR30], a ldh [rNR30], a
jr .nextChannel jr .nextChannel
.applyAffects .applyAffects
call Audio3_ApplyMusicAffects call Audio3_ApplyMusicAffects
@ -183,9 +183,9 @@ Audio3_sound_ret:
jr nz, .skipSfxChannel3 jr nz, .skipSfxChannel3
; restart hardware channel 3 (wave channel) output ; restart hardware channel 3 (wave channel) output
ld a, $0 ld a, $0
ld [rNR30], a ldh [rNR30], a
ld a, $80 ld a, $80
ld [rNR30], a ldh [rNR30], a
.skipSfxChannel3 .skipSfxChannel3
jr nz, .dontDisable jr nz, .dontDisable
ld a, [wDisableChannelOutputWhenSfxEnds] ld a, [wDisableChannelOutputWhenSfxEnds]
@ -219,9 +219,9 @@ Audio3_sound_ret:
.disableChannelOutput .disableChannelOutput
ld hl, Audio3_HWChannelDisableMasks ld hl, Audio3_HWChannelDisableMasks
add hl, bc add hl, bc
ld a, [rNR51] ldh a, [rNR51]
and [hl] and [hl]
ld [rNR51], a ldh [rNR51], a
.afterDisable .afterDisable
ld a, [wChannelSoundIDs + Ch5] ld a, [wChannelSoundIDs + Ch5]
cp CRY_SFX_START cp CRY_SFX_START
@ -241,7 +241,7 @@ Audio3_sound_ret:
ret c ret c
.skipRewind .skipRewind
ld a, [wSavedVolume] ld a, [wSavedVolume]
ld [rNR50], a ldh [rNR50], a
xor a xor a
ld [wSavedVolume], a ld [wSavedVolume], a
.skipCry .skipCry
@ -548,7 +548,7 @@ Audio3_volume:
cp $f0 ; is this command a volume? cp $f0 ; is this command a volume?
jr nz, Audio3_execute_music ; no jr nz, Audio3_execute_music ; no
call Audio3_GetNextMusicByte call Audio3_GetNextMusicByte
ld [rNR50], a ; store volume ldh [rNR50], a ; store volume
jp Audio3_sound_ret jp Audio3_sound_ret
Audio3_execute_music: Audio3_execute_music:
@ -638,7 +638,7 @@ Audio3_pitch_sweep:
bit BIT_EXECUTE_MUSIC, [hl] bit BIT_EXECUTE_MUSIC, [hl]
jr nz, Audio3_note ; no jr nz, Audio3_note ; no
call Audio3_GetNextMusicByte call Audio3_GetNextMusicByte
ld [rNR10], a ldh [rNR10], a
jp Audio3_sound_ret jp Audio3_sound_ret
Audio3_note: Audio3_note:
@ -770,9 +770,9 @@ Audio3_note_pitch:
ld b, 0 ld b, 0
ld hl, Audio3_HWChannelDisableMasks ld hl, Audio3_HWChannelDisableMasks
add hl, bc add hl, bc
ld a, [rNR51] ldh a, [rNR51]
and [hl] and [hl]
ld [rNR51], a ; disable hardware channel 3's output ldh [rNR51], a ; disable hardware channel 3's output
jr .done jr .done
.notChannel3 .notChannel3
ld b, REG_VOLUME_ENVELOPE ld b, REG_VOLUME_ENVELOPE
@ -844,7 +844,7 @@ Audio3_EnableChannelOutput:
ld b, 0 ld b, 0
ld hl, Audio3_HWChannelEnableMasks ld hl, Audio3_HWChannelEnableMasks
add hl, bc add hl, bc
ld a, [rNR51] ldh a, [rNR51]
or [hl] ; set this channel's bits or [hl] ; set this channel's bits
ld d, a ld d, a
ld a, c ld a, c
@ -866,7 +866,7 @@ Audio3_EnableChannelOutput:
add hl, bc add hl, bc
and [hl] and [hl]
ld d, a ld d, a
ld a, [rNR51] ldh a, [rNR51]
ld hl, Audio3_HWChannelDisableMasks ld hl, Audio3_HWChannelDisableMasks
add hl, bc add hl, bc
and [hl] ; reset this channel's output bits and [hl] ; reset this channel's output bits
@ -874,7 +874,7 @@ Audio3_EnableChannelOutput:
ld d, a ld d, a
.skip .skip
ld a, d ld a, d
ld [rNR51], a ldh [rNR51], a
ret ret
Audio3_ApplyDutyCycleAndSoundLength: Audio3_ApplyDutyCycleAndSoundLength:
@ -928,7 +928,7 @@ Audio3_ApplyWavePatternAndFrequency:
ld hl, rWave_0 ld hl, rWave_0
ld b, $f ld b, $f
ld a, $0 ; stop hardware channel 3 ld a, $0 ; stop hardware channel 3
ld [rNR30], a ldh [rNR30], a
.loop .loop
ld a, [de] ld a, [de]
inc de inc de
@ -938,7 +938,7 @@ Audio3_ApplyWavePatternAndFrequency:
and a and a
jr nz, .loop jr nz, .loop
ld a, $80 ; start hardware channel 3 ld a, $80 ; start hardware channel 3
ld [rNR30], a ldh [rNR30], a
pop de pop de
.notChannel3 .notChannel3
ld a, d ld a, d
@ -1399,17 +1399,17 @@ Audio3_PlaySound::
ld a, $ff ld a, $ff
ld [wStereoPanning], a ld [wStereoPanning], a
xor a xor a
ld [rNR50], a ldh [rNR50], a
ld a, $8 ld a, $8
ld [rNR10], a ldh [rNR10], a
ld a, 0 ld a, 0
ld [rNR51], a ldh [rNR51], a
xor a xor a
ld [rNR30], a ldh [rNR30], a
ld a, $80 ld a, $80
ld [rNR30], a ldh [rNR30], a
ld a, $77 ld a, $77
ld [rNR50], a ldh [rNR50], a
jp .playSoundCommon jp .playSoundCommon
.playSfx .playSfx
@ -1555,7 +1555,7 @@ Audio3_PlaySound::
cp Ch5 cp Ch5
jr nz, .skipSweepDisable jr nz, .skipSweepDisable
ld a, $8 ld a, $8
ld [rNR10], a ; sweep off ldh [rNR10], a ; sweep off
.skipSweepDisable .skipSweepDisable
ld a, c ld a, c
and a and a
@ -1565,22 +1565,22 @@ Audio3_PlaySound::
.stopAllAudio .stopAllAudio
ld a, $80 ld a, $80
ld [rNR52], a ; sound hardware on ldh [rNR52], a ; sound hardware on
ld [rNR30], a ; wave playback on ldh [rNR30], a ; wave playback on
xor a xor a
ld [rNR51], a ; no sound output ldh [rNR51], a ; no sound output
ld [rNR32], a ; mute channel 3 (wave channel) ldh [rNR32], a ; mute channel 3 (wave channel)
ld a, $8 ld a, $8
ld [rNR10], a ; sweep off ldh [rNR10], a ; sweep off
ld [rNR12], a ; mute channel 1 (pulse channel 1) ldh [rNR12], a ; mute channel 1 (pulse channel 1)
ld [rNR22], a ; mute channel 2 (pulse channel 2) ldh [rNR22], a ; mute channel 2 (pulse channel 2)
ld [rNR42], a ; mute channel 4 (noise channel) ldh [rNR42], a ; mute channel 4 (noise channel)
ld a, $40 ld a, $40
ld [rNR14], a ; counter mode ldh [rNR14], a ; counter mode
ld [rNR24], a ldh [rNR24], a
ld [rNR44], a ldh [rNR44], a
ld a, $77 ld a, $77
ld [rNR50], a ; full volume ldh [rNR50], a ; full volume
xor a xor a
ld [wUnusedC000], a ld [wUnusedC000], a
ld [wDisableChannelOutputWhenSfxEnds], a ld [wDisableChannelOutputWhenSfxEnds], a
@ -1699,10 +1699,10 @@ Audio3_PlaySound::
ld a, [wSavedVolume] ld a, [wSavedVolume]
and a and a
jr nz, .done jr nz, .done
ld a, [rNR50] ldh a, [rNR50]
ld [wSavedVolume], a ld [wSavedVolume], a
ld a, $77 ld a, $77
ld [rNR50], a ; full volume ldh [rNR50], a ; full volume
.done .done
ret ret

View file

@ -1,5 +1,5 @@
PlayPokedexRatingSfx:: PlayPokedexRatingSfx::
ld a, [hDexRatingNumMonsOwned] ldh a, [hDexRatingNumMonsOwned]
ld c, $0 ld c, $0
ld hl, OwnedMonValues ld hl, OwnedMonValues
.getSfxPointer .getSfxPointer

View file

@ -163,7 +163,7 @@ DrawFrameBlock:
PlayAnimation: PlayAnimation:
xor a xor a
ld [hROMBankTemp], a ; it looks like nothing reads this ldh [hROMBankTemp], a ; it looks like nothing reads this
ld [wSubAnimTransform], a ld [wSubAnimTransform], a
ld a, [wAnimationID] ; get animation number ld a, [wAnimationID] ; get animation number
dec a dec a
@ -241,15 +241,15 @@ PlayAnimation:
ld l, c ld l, c
ld h, b ld h, b
push hl push hl
ld a, [rOBP0] ldh a, [rOBP0]
push af push af
ld a, [wAnimPalette] ld a, [wAnimPalette]
ld [rOBP0], a ldh [rOBP0], a
call LoadAnimationTileset call LoadAnimationTileset
call LoadSubanimation call LoadSubanimation
call PlaySubanimation call PlaySubanimation
pop af pop af
ld [rOBP0], a ldh [rOBP0], a
.nextAnimationCommand .nextAnimationCommand
pop hl pop hl
jr .animationLoop jr .animationLoop
@ -308,7 +308,7 @@ LoadSubanimation:
; sets the transform to the subanimation type if it's the enemy's turn ; sets the transform to the subanimation type if it's the enemy's turn
GetSubanimationTransform1: GetSubanimationTransform1:
ld b, a ld b, a
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
ld a, b ld a, b
ret nz ret nz
@ -319,7 +319,7 @@ GetSubanimationTransform1:
; sets the transform to 2 (i.e. horizontal and vertical flip) if it's the player's turn ; sets the transform to 2 (i.e. horizontal and vertical flip) if it's the player's turn
; sets the transform to 0 (i.e. no transform) if it's the enemy's turn ; sets the transform to 0 (i.e. no transform) if it's the enemy's turn
GetSubanimationTransform2: GetSubanimationTransform2:
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
ld a, 2 << 5 ld a, 2 << 5
ret z ret z
@ -421,7 +421,7 @@ MoveAnimation:
ShareMoveAnimations: ShareMoveAnimations:
; some moves just reuse animations from status conditions ; some moves just reuse animations from status conditions
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
ret z ret z
@ -497,18 +497,18 @@ AnimationShakeScreenHorizontallySlow:
push bc push bc
push bc push bc
.loop1 .loop1
ld a, [rWX] ldh a, [rWX]
inc a inc a
ld [rWX], a ldh [rWX], a
ld c, 2 ld c, 2
call DelayFrames call DelayFrames
dec b dec b
jr nz, .loop1 jr nz, .loop1
pop bc pop bc
.loop2 .loop2
ld a, [rWX] ldh a, [rWX]
dec a dec a
ld [rWX], a ldh [rWX], a
ld c, 2 ld c, 2
call DelayFrames call DelayFrames
dec b dec b
@ -534,16 +534,16 @@ SetAnimationPalette:
ld b, $f0 ld b, $f0
.next .next
ld a, b ld a, b
ld [rOBP0], a ldh [rOBP0], a
ld a, $6c ld a, $6c
ld [rOBP1], a ldh [rOBP1], a
ret ret
.notSGB .notSGB
ld a, $e4 ld a, $e4
ld [wAnimPalette], a ld [wAnimPalette], a
ld [rOBP0], a ldh [rOBP0], a
ld a, $6c ld a, $6c
ld [rOBP1], a ldh [rOBP1], a
ret ret
PlaySubanimation: PlaySubanimation:
@ -656,9 +656,9 @@ DoBallTossSpecialEffects:
cp 3 ; is it a Master Ball or Ultra Ball? cp 3 ; is it a Master Ball or Ultra Ball?
jr nc, .skipFlashingEffect jr nc, .skipFlashingEffect
.flashingEffect ; do a flashing effect if it's Master Ball or Ultra Ball .flashingEffect ; do a flashing effect if it's Master Ball or Ultra Ball
ld a, [rOBP0] ldh a, [rOBP0]
xor %00111100 ; complement colors 1 and 2 xor %00111100 ; complement colors 1 and 2
ld [rOBP0], a ldh [rOBP0], a
.skipFlashingEffect .skipFlashingEffect
ld a, [wSubAnimCounter] ld a, [wSubAnimCounter]
cp 11 ; is it the beginning of the subanimation? cp 11 ; is it the beginning of the subanimation?
@ -695,7 +695,7 @@ DoBallTossSpecialEffects:
dec b dec b
jr nz, .loop jr nz, .loop
ld a, %00001000 ld a, %00001000
ld [rNR10], a ; Channel 1 sweep register ldh [rNR10], a ; Channel 1 sweep register
ret ret
.isTrainerBattle ; if it's a trainer battle, shorten the animation by one frame .isTrainerBattle ; if it's a trainer battle, shorten the animation by one frame
ld a, [wSubAnimCounter] ld a, [wSubAnimCounter]
@ -882,9 +882,9 @@ TradeJumpPokeball:
ld c, 5 ld c, 5
call DelayFrames call DelayFrames
pop bc pop bc
ld a, [hSCX] ; background scroll X ldh a, [hSCX] ; background scroll X
sub 8 ; scroll to the left sub 8 ; scroll to the left
ld [hSCX], a ldh [hSCX], a
pop de pop de
jr .loop jr .loop
@ -920,16 +920,16 @@ AnimationDelay10:
; calls a function with the turn flipped from player to enemy or vice versa ; calls a function with the turn flipped from player to enemy or vice versa
; input - hl - address of function to call ; input - hl - address of function to call
CallWithTurnFlipped: CallWithTurnFlipped:
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
push af push af
xor 1 xor 1
ld [hWhoseTurn], a ldh [hWhoseTurn], a
ld de, .returnAddress ld de, .returnAddress
push de push de
jp hl jp hl
.returnAddress .returnAddress
pop af pop af
ld [hWhoseTurn], a ldh [hWhoseTurn], a
ret ret
; flashes the screen for an extended period (48 frames) ; flashes the screen for an extended period (48 frames)
@ -947,7 +947,7 @@ AnimationFlashScreenLong:
ld a, [hli] ld a, [hli]
cp $01 ; is it the end of the palettes? cp $01 ; is it the end of the palettes?
jr z, .endOfPalettes jr z, .endOfPalettes
ld [rBGP], a ldh [rBGP], a
call FlashScreenLongDelay call FlashScreenLongDelay
jr .innerLoop jr .innerLoop
.endOfPalettes .endOfPalettes
@ -1006,18 +1006,18 @@ FlashScreenLongDelay:
jp DelayFrames jp DelayFrames
AnimationFlashScreen: AnimationFlashScreen:
ld a, [rBGP] ldh a, [rBGP]
push af ; save initial palette push af ; save initial palette
ld a, %00011011 ; 0, 1, 2, 3 (inverted colors) ld a, %00011011 ; 0, 1, 2, 3 (inverted colors)
ld [rBGP], a ldh [rBGP], a
ld c, 2 ld c, 2
call DelayFrames call DelayFrames
xor a ; white out background xor a ; white out background
ld [rBGP], a ldh [rBGP], a
ld c, 2 ld c, 2
call DelayFrames call DelayFrames
pop af pop af
ld [rBGP], a ; restore initial palette ldh [rBGP], a ; restore initial palette
ret ret
AnimationDarkScreenPalette: AnimationDarkScreenPalette:
@ -1062,7 +1062,7 @@ SetAnimationBGPalette:
jr z, .next jr z, .next
ld a, c ld a, c
.next .next
ld [rBGP], a ldh [rBGP], a
ret ret
ld b, $5 ld b, $5
@ -1133,7 +1133,7 @@ _AnimationWaterDroplets:
AnimationSlideMonUp: AnimationSlideMonUp:
; Slides the mon's sprite upwards. ; Slides the mon's sprite upwards.
ld c, 7 ld c, 7
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
coord hl, 1, 6 coord hl, 1, 6
coord de, 1, 5 coord de, 1, 5
@ -1201,7 +1201,7 @@ _AnimationSlideMonUp:
jr nz, .slideLoop jr nz, .slideLoop
; Fill in the bottom row of the mon pic with the next row's tile IDs. ; Fill in the bottom row of the mon pic with the next row's tile IDs.
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
coord hl, 1, 11 coord hl, 1, 11
jr z, .next jr z, .next
@ -1370,7 +1370,7 @@ AnimationShowEnemyMonPic:
AnimationShakeBackAndForth: AnimationShakeBackAndForth:
; Shakes the mon's sprite back and forth rapidly. This is used in Double Team. ; Shakes the mon's sprite back and forth rapidly. This is used in Double Team.
; The mon's sprite disappears after this animation. ; The mon's sprite disappears after this animation.
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
coord hl, 0, 5 coord hl, 0, 5
coord de, 2, 5 coord de, 2, 5
@ -1418,7 +1418,7 @@ AnimationMoveMonHorizontally:
; Shifts the mon's sprite horizontally to a fixed location. Used by lots of ; Shifts the mon's sprite horizontally to a fixed location. Used by lots of
; animations like Tackle/Body Slam. ; animations like Tackle/Body Slam.
call AnimationHideMonPic call AnimationHideMonPic
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
coord hl, 2, 5 coord hl, 2, 5
jr z, .next jr z, .next
@ -1434,7 +1434,7 @@ AnimationMoveMonHorizontally:
AnimationResetMonPosition: AnimationResetMonPosition:
; Resets the mon's sprites to be located at the normal coordinates. ; Resets the mon's sprites to be located at the normal coordinates.
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
ld a, 5 * SCREEN_WIDTH + 2 ld a, 5 * SCREEN_WIDTH + 2
jr z, .next jr z, .next
@ -1446,7 +1446,7 @@ AnimationResetMonPosition:
AnimationSpiralBallsInward: AnimationSpiralBallsInward:
; Creates an effect that looks like energy balls spiralling into the ; Creates an effect that looks like energy balls spiralling into the
; player mon's sprite. Used in Focus Energy, for example. ; player mon's sprite. Used in Focus Energy, for example.
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr z, .playerTurn jr z, .playerTurn
ld a, -40 ld a, -40
@ -1530,7 +1530,7 @@ AnimationSquishMonPic:
ld c, 4 ld c, 4
.loop .loop
push bc push bc
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr z, .playerTurn jr z, .playerTurn
coord hl, 16, 0 coord hl, 16, 0
@ -1583,7 +1583,7 @@ _AnimationSquishMonPic:
AnimationShootBallsUpward: AnimationShootBallsUpward:
; Shoots one pillar of "energy" balls upwards. Used in Teleport/Sky Attack ; Shoots one pillar of "energy" balls upwards. Used in Teleport/Sky Attack
; animations. ; animations.
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr z, .playerTurn jr z, .playerTurn
lb bc, 0, 16 * 8 lb bc, 0, 16 * 8
@ -1651,7 +1651,7 @@ _AnimationShootBallsUpward:
AnimationShootManyBallsUpward: AnimationShootManyBallsUpward:
; Shoots several pillars of "energy" balls upward. ; Shoots several pillars of "energy" balls upward.
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
ld hl, UpwardBallsAnimXCoordinatesPlayerTurn ld hl, UpwardBallsAnimXCoordinatesPlayerTurn
ld a, $50 ; y coordinate for "energy" ball pillar ld a, $50 ; y coordinate for "energy" ball pillar
@ -1743,7 +1743,7 @@ AnimationSlideMonDownAndHide:
_AnimationSlideMonOff: _AnimationSlideMonOff:
; Slides the mon's sprite off the screen horizontally by e tiles and waits ; Slides the mon's sprite off the screen horizontally by e tiles and waits
; [wSlideMonDelay] V-blanks each time the pic is slid by one tile. ; [wSlideMonDelay] V-blanks each time the pic is slid by one tile.
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr z, .playerTurn jr z, .playerTurn
coord hl, 12, 0 coord hl, 12, 0
@ -1758,7 +1758,7 @@ _AnimationSlideMonOff:
.rowLoop ; iterates once for each row .rowLoop ; iterates once for each row
ld c, 8 ld c, 8
.tileLoop ; iterates once for each tile in the row .tileLoop ; iterates once for each tile in the row
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr z, .playerTurn2 jr z, .playerTurn2
call .EnemyNextTile call .EnemyNextTile
@ -1821,7 +1821,7 @@ AnimationSlideMonHalfOff:
jp Delay3 jp Delay3
CopyTempPicToMonPic: CopyTempPicToMonPic:
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
ld hl, vBackPic ; player turn ld hl, vBackPic ; player turn
jr z, .next jr z, .next
@ -1837,9 +1837,9 @@ AnimationWavyScreen:
call BattleAnimCopyTileMapToVRAM call BattleAnimCopyTileMapToVRAM
call Delay3 call Delay3
xor a xor a
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
ld a, SCREEN_HEIGHT_PX ld a, SCREEN_HEIGHT_PX
ld [hWY], a ldh [hWY], a
ld d, $80 ; terminator ld d, $80 ; terminator
ld e, SCREEN_HEIGHT_PX - 1 ld e, SCREEN_HEIGHT_PX - 1
ld c, $ff ld c, $ff
@ -1848,7 +1848,7 @@ AnimationWavyScreen:
push hl push hl
.innerLoop .innerLoop
call WavyScreen_SetSCX call WavyScreen_SetSCX
ld a, [rLY] ldh a, [rLY]
cp e ; is it the last visible line in the frame? cp e ; is it the last visible line in the frame?
jr nz, .innerLoop ; keep going if not jr nz, .innerLoop ; keep going if not
pop hl pop hl
@ -1861,11 +1861,11 @@ AnimationWavyScreen:
dec c dec c
jr nz, .loop jr nz, .loop
xor a xor a
ld [hWY], a ldh [hWY], a
call SaveScreenTilesToBuffer2 call SaveScreenTilesToBuffer2
call ClearScreen call ClearScreen
ld a, 1 ld a, 1
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
call Delay3 call Delay3
call LoadScreenTilesFromBuffer2 call LoadScreenTilesFromBuffer2
ld hl, vBGMap1 ld hl, vBGMap1
@ -1873,11 +1873,11 @@ AnimationWavyScreen:
ret ret
WavyScreen_SetSCX: WavyScreen_SetSCX:
ld a, [rSTAT] ldh a, [rSTAT]
and $3 ; is it H-blank? and $3 ; is it H-blank?
jr nz, WavyScreen_SetSCX ; wait until it's H-blank jr nz, WavyScreen_SetSCX ; wait until it's H-blank
ld a, [hl] ld a, [hl]
ld [rSCX], a ldh [rSCX], a
inc hl inc hl
ld a, [hl] ld a, [hl]
cp d ; have we reached the end? cp d ; have we reached the end?
@ -1898,7 +1898,7 @@ AnimationSubstitute:
xor a xor a
ld bc, $310 ld bc, $310
call FillMemory call FillMemory
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr z, .playerTurn jr z, .playerTurn
ld hl, SlowbroSprite ; facing down sprite ld hl, SlowbroSprite ; facing down sprite
@ -1937,7 +1937,7 @@ CopySlowbroSpriteData:
jp FarCopyData2 jp FarCopyData2
HideSubstituteShowMonAnim: HideSubstituteShowMonAnim:
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
ld hl, wPlayerMonMinimized ld hl, wPlayerMonMinimized
ld a, [wPlayerBattleStatus2] ld a, [wPlayerBattleStatus2]
@ -1987,7 +1987,7 @@ AnimationTransformMon:
ld [wChangeMonPicEnemyTurnSpecies], a ld [wChangeMonPicEnemyTurnSpecies], a
ChangeMonPic: ChangeMonPic:
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr z, .playerTurn jr z, .playerTurn
ld a, [wChangeMonPicEnemyTurnSpecies] ld a, [wChangeMonPicEnemyTurnSpecies]
@ -2020,11 +2020,11 @@ ChangeMonPic:
AnimationHideEnemyMonPic: AnimationHideEnemyMonPic:
; Hides the enemy mon's sprite ; Hides the enemy mon's sprite
xor a xor a
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
ld hl, AnimationHideMonPic ld hl, AnimationHideMonPic
call CallWithTurnFlipped call CallWithTurnFlipped
ld a, $1 ld a, $1
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
jp Delay3 jp Delay3
InitMultipleObjectsOAM: InitMultipleObjectsOAM:
@ -2050,7 +2050,7 @@ InitMultipleObjectsOAM:
AnimationHideMonPic: AnimationHideMonPic:
; Hides the mon's sprite. ; Hides the mon's sprite.
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr z, .playerTurn jr z, .playerTurn
ld a, 12 ld a, 12
@ -2078,7 +2078,7 @@ ClearMonPicFromTileMap:
; in order to show only a portion of the mon sprite. ; in order to show only a portion of the mon sprite.
GetMonSpriteTileMapPointerFromRowCount: GetMonSpriteTileMapPointerFromRowCount:
push de push de
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr nz, .enemyTurn jr nz, .enemyTurn
ld a, 20 * 5 + 1 ld a, 20 * 5 + 1
@ -2166,7 +2166,7 @@ GetMoveSound:
ld b, a ld b, a
call IsCryMove call IsCryMove
jr nc, .NotCryMove jr nc, .NotCryMove
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr nz, .next jr nz, .next
ld a, [wBattleMonSpecies] ; get number of current monster ld a, [wBattleMonSpecies] ; get number of current monster
@ -2211,14 +2211,14 @@ IsCryMove:
INCLUDE "data/moves/sfx.asm" INCLUDE "data/moves/sfx.asm"
CopyPicTiles: CopyPicTiles:
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
ld a, $31 ; base tile ID of player mon sprite ld a, $31 ; base tile ID of player mon sprite
jr z, .next jr z, .next
; enemy turn ; enemy turn
xor a ; base tile ID of enemy mon sprite xor a ; base tile ID of enemy mon sprite
.next .next
ld [hBaseTileID], a ldh [hBaseTileID], a
jr CopyTileIDs_NoBGTransfer jr CopyTileIDs_NoBGTransfer
; copy the tiles used when a mon is being sent out of or into a pokeball ; copy the tiles used when a mon is being sent out of or into a pokeball
@ -2235,7 +2235,7 @@ CopyDownscaledMonTiles:
CopyTileIDs_NoBGTransfer: CopyTileIDs_NoBGTransfer:
xor a xor a
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
; fall through ; fall through
; b = number of rows ; b = number of rows
@ -2245,7 +2245,7 @@ CopyTileIDs:
.rowLoop .rowLoop
push bc push bc
push hl push hl
ld a, [hBaseTileID] ldh a, [hBaseTileID]
ld b, a ld b, a
.columnLoop .columnLoop
ld a, [de] ld a, [de]
@ -2261,7 +2261,7 @@ CopyTileIDs:
dec b dec b
jr nz, .rowLoop jr nz, .rowLoop
ld a, $1 ld a, $1
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
pop hl pop hl
ret ret
@ -2361,16 +2361,16 @@ Unknown_79c50:
AnimationLeavesFalling: AnimationLeavesFalling:
; Makes leaves float down from the top of the screen. This is used ; Makes leaves float down from the top of the screen. This is used
; in Razor Leaf's animation. ; in Razor Leaf's animation.
ld a, [rOBP0] ldh a, [rOBP0]
push af push af
ld a, [wAnimPalette] ld a, [wAnimPalette]
ld [rOBP0], a ldh [rOBP0], a
ld d, $37 ; leaf tile ld d, $37 ; leaf tile
ld a, 3 ; number of leaves ld a, 3 ; number of leaves
ld [wNumFallingObjects], a ld [wNumFallingObjects], a
call AnimationFallingObjects call AnimationFallingObjects
pop af pop af
ld [rOBP0], a ldh [rOBP0], a
ret ret
AnimationPetalsFalling: AnimationPetalsFalling:
@ -2529,7 +2529,7 @@ AnimationShakeEnemyHUD:
call CopyVideoData call CopyVideoData
xor a xor a
ld [hSCX], a ldh [hSCX], a
; Copy wTileMap to BG map 0. The regular BG (not the window) is set to use ; Copy wTileMap to BG map 0. The regular BG (not the window) is set to use
; map 0 and can be scrolled with SCX, which allows a shaking effect. ; map 0 and can be scrolled with SCX, which allows a shaking effect.
@ -2539,7 +2539,7 @@ AnimationShakeEnemyHUD:
; Now that the regular BG is showing the same thing the window was, move the ; Now that the regular BG is showing the same thing the window was, move the
; window off the screen so that we can modify its contents below. ; window off the screen so that we can modify its contents below.
ld a, SCREEN_HEIGHT_PX ld a, SCREEN_HEIGHT_PX
ld [hWY], a ldh [hWY], a
; Copy wTileMap to VRAM such that the row below the enemy HUD (in wTileMap) is ; Copy wTileMap to VRAM such that the row below the enemy HUD (in wTileMap) is
; lined up with row 0 of the window. ; lined up with row 0 of the window.
@ -2551,7 +2551,7 @@ AnimationShakeEnemyHUD:
; covers everything below the enemy HD with a copy that looks just like what ; covers everything below the enemy HD with a copy that looks just like what
; was there before. ; was there before.
ld a, 7 * 8 ld a, 7 * 8
ld [hWY], a ldh [hWY], a
; Write OAM entries so that the copy of the back pic from the top of this ; Write OAM entries so that the copy of the back pic from the top of this
; function shows up on screen. We need this because the back pic's Y coordinates ; function shows up on screen. We need this because the back pic's Y coordinates
@ -2576,11 +2576,11 @@ AnimationShakeEnemyHUD:
call AnimationShowMonPic call AnimationShowMonPic
call ClearSprites call ClearSprites
ld a, SCREEN_HEIGHT_PX ld a, SCREEN_HEIGHT_PX
ld [hWY], a ldh [hWY], a
ld hl, vBGMap1 ld hl, vBGMap1
call BattleAnimCopyTileMapToVRAM call BattleAnimCopyTileMapToVRAM
xor a xor a
ld [hWY], a ldh [hWY], a
call SaveScreenTilesToBuffer1 call SaveScreenTilesToBuffer1
ld hl, vBGMap0 ld hl, vBGMap0
call BattleAnimCopyTileMapToVRAM call BattleAnimCopyTileMapToVRAM
@ -2595,7 +2595,7 @@ AnimationShakeEnemyHUD:
CopyTileIDsFromList: CopyTileIDsFromList:
call GetPredefRegisters call GetPredefRegisters
ld a, c ld a, c
ld [hBaseTileID], a ldh [hBaseTileID], a
ld a, b ld a, b
push hl push hl
call GetTileIDList call GetTileIDList
@ -2603,30 +2603,30 @@ CopyTileIDsFromList:
jp CopyTileIDs jp CopyTileIDs
ShakeEnemyHUD_ShakeBG: ShakeEnemyHUD_ShakeBG:
ld a, [hSCX] ldh a, [hSCX]
ld [wTempSCX], a ld [wTempSCX], a
.loop .loop
ld a, [wTempSCX] ld a, [wTempSCX]
add d add d
ld [hSCX], a ldh [hSCX], a
ld c, 2 ld c, 2
call DelayFrames call DelayFrames
ld a, [wTempSCX] ld a, [wTempSCX]
sub d sub d
ld [hSCX], a ldh [hSCX], a
ld c, 2 ld c, 2
call DelayFrames call DelayFrames
dec e dec e
jr nz, .loop jr nz, .loop
ld a, [wTempSCX] ld a, [wTempSCX]
ld [hSCX], a ldh [hSCX], a
ret ret
BattleAnimCopyTileMapToVRAM: BattleAnimCopyTileMapToVRAM:
ld a, h ld a, h
ld [hAutoBGTransferDest + 1], a ldh [hAutoBGTransferDest + 1], a
ld a, l ld a, l
ld [hAutoBGTransferDest], a ldh [hAutoBGTransferDest], a
jp Delay3 jp Delay3
TossBallAnimation: TossBallAnimation:

View file

@ -1,9 +1,9 @@
BattleTransition: BattleTransition:
ld a, 1 ld a, 1
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
call Delay3 call Delay3
xor a xor a
ld [hWY], a ldh [hWY], a
dec a dec a
ld [wUpdateSpritesEnabled], a ld [wUpdateSpritesEnabled], a
call DelayFrame call DelayFrame
@ -11,7 +11,7 @@ BattleTransition:
; Determine which OAM block is being used by the enemy trainer sprite (if there ; Determine which OAM block is being used by the enemy trainer sprite (if there
; is one). ; is one).
ld hl, wSpritePlayerStateData1ImageIndex ld hl, wSpritePlayerStateData1ImageIndex
ld a, [hSpriteIndexOrTextID] ; enemy trainer sprite index (0 if wild battle) ldh a, [hSpriteIndexOrTextID] ; enemy trainer sprite index (0 if wild battle)
ld c, a ld c, a
ld b, 0 ld b, 0
ld de, $10 ld de, $10
@ -165,9 +165,9 @@ BattleTransitionTileEnd:
BattleTransition_BlackScreen: BattleTransition_BlackScreen:
ld a, $ff ld a, $ff
ld [rBGP], a ldh [rBGP], a
ld [rOBP0], a ldh [rOBP0], a
ld [rOBP1], a ldh [rOBP1], a
ret ret
; for non-dungeon trainer battles ; for non-dungeon trainer battles
@ -330,7 +330,7 @@ BattleTransition_FlashScreen_:
ld a, [hli] ld a, [hli]
cp $1 cp $1
jr z, .done jr z, .done
ld [rBGP], a ldh [rBGP], a
ld c, 2 ld c, 2
call DelayFrames call DelayFrames
jr .loop jr .loop
@ -349,7 +349,7 @@ BattleTransition_Shrink:
.loop .loop
push bc push bc
xor a xor a
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
coord hl, 0, 7 coord hl, 0, 7
coord de, 0, 8 coord de, 0, 8
ld bc, -SCREEN_WIDTH * 2 ld bc, -SCREEN_WIDTH * 2
@ -367,7 +367,7 @@ BattleTransition_Shrink:
ld bc, 2 ld bc, 2
call BattleTransition_CopyTiles2 call BattleTransition_CopyTiles2
ld a, $1 ld a, $1
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
ld c, 6 ld c, 6
call DelayFrames call DelayFrames
pop bc pop bc
@ -381,7 +381,7 @@ BattleTransition_Shrink:
BattleTransition_Split: BattleTransition_Split:
ld c, SCREEN_HEIGHT / 2 ld c, SCREEN_HEIGHT / 2
xor a xor a
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
.loop .loop
push bc push bc
coord hl, 0, 16 coord hl, 0, 16
@ -496,7 +496,7 @@ BattleTransition_VerticalStripes:
coord hl, 0, 0 coord hl, 0, 0
coord de, 1, 17 coord de, 1, 17
xor a xor a
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
.loop .loop
push bc push bc
push hl push hl
@ -535,7 +535,7 @@ BattleTransition_HorizontalStripes:
coord hl, 0, 0 coord hl, 0, 0
coord de, 19, 1 coord de, 19, 1
xor a xor a
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
.loop .loop
push bc push bc
push hl push hl
@ -582,7 +582,7 @@ BattleTransition_FlashScreen:
ld b, $3 ld b, $3
call BattleTransition_FlashScreen_ call BattleTransition_FlashScreen_
xor a xor a
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
ret ret
BattleTransition_Circle_Sub1: BattleTransition_Circle_Sub1:
@ -601,10 +601,10 @@ BattleTransition_Circle_Sub1:
BattleTransition_TransferDelay3: BattleTransition_TransferDelay3:
ld a, 1 ld a, 1
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
call Delay3 call Delay3
xor a xor a
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
ret ret
; used for low level wild non-dungeon battles ; used for low level wild non-dungeon battles

View file

@ -101,16 +101,16 @@ PrintSendOutMonMessage:
ld hl, GoText ld hl, GoText
jr z, .printText jr z, .printText
xor a xor a
ld [hMultiplicand], a ldh [hMultiplicand], a
ld hl, wEnemyMonHP ld hl, wEnemyMonHP
ld a, [hli] ld a, [hli]
ld [wLastSwitchInEnemyMonHP], a ld [wLastSwitchInEnemyMonHP], a
ld [hMultiplicand + 1], a ldh [hMultiplicand + 1], a
ld a, [hl] ld a, [hl]
ld [wLastSwitchInEnemyMonHP + 1], a ld [wLastSwitchInEnemyMonHP + 1], a
ld [hMultiplicand + 2], a ldh [hMultiplicand + 2], a
ld a, 25 ld a, 25
ld [hMultiplier], a ldh [hMultiplier], a
call Multiply call Multiply
ld hl, wEnemyMonMaxHP ld hl, wEnemyMonMaxHP
ld a, [hli] ld a, [hli]
@ -121,9 +121,9 @@ PrintSendOutMonMessage:
rr b rr b
ld a, b ld a, b
ld b, 4 ld b, 4
ld [hDivisor], a ; enemy mon max HP divided by 4 ldh [hDivisor], a ; enemy mon max HP divided by 4
call Divide call Divide
ld a, [hQuotient + 3] ; a = (enemy mon current HP * 25) / (enemy max HP / 4); this approximates the current percentage of max HP ldh a, [hQuotient + 3] ; a = (enemy mon current HP * 25) / (enemy max HP / 4); this approximates the current percentage of max HP
ld hl, GoText ; 70% or greater ld hl, GoText ; 70% or greater
cp 70 cp 70
jr nc, .printText jr nc, .printText
@ -179,14 +179,14 @@ PlayerMon2Text:
dec hl dec hl
ld a, [de] ld a, [de]
sub b sub b
ld [hMultiplicand + 2], a ldh [hMultiplicand + 2], a
dec de dec de
ld b, [hl] ld b, [hl]
ld a, [de] ld a, [de]
sbc b sbc b
ld [hMultiplicand + 1], a ldh [hMultiplicand + 1], a
ld a, 25 ld a, 25
ld [hMultiplier], a ldh [hMultiplier], a
call Multiply call Multiply
ld hl, wEnemyMonMaxHP ld hl, wEnemyMonMaxHP
ld a, [hli] ld a, [hli]
@ -197,11 +197,11 @@ PlayerMon2Text:
rr b rr b
ld a, b ld a, b
ld b, 4 ld b, 4
ld [hDivisor], a ldh [hDivisor], a
call Divide call Divide
pop bc pop bc
pop de pop de
ld a, [hQuotient + 3] ; a = ((LastSwitchInEnemyMonHP - CurrentEnemyMonHP) / 25) / (EnemyMonMaxHP / 4) ldh a, [hQuotient + 3] ; a = ((LastSwitchInEnemyMonHP - CurrentEnemyMonHP) / 25) / (EnemyMonMaxHP / 4)
; Assuming that the enemy mon hasn't gained HP since the last switch in, ; Assuming that the enemy mon hasn't gained HP since the last switch in,
; a approximates the percentage that the enemy mon's total HP has decreased ; a approximates the percentage that the enemy mon's total HP has decreased
; since the last switch in. ; since the last switch in.

File diff suppressed because it is too large Load diff

View file

@ -4,7 +4,7 @@ JumpMoveEffect:
ret ret
_JumpMoveEffect: _JumpMoveEffect:
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
ld a, [wPlayerMoveEffect] ld a, [wPlayerMoveEffect]
jr z, .next1 jr z, .next1
@ -26,7 +26,7 @@ INCLUDE "data/moves/effects_pointers.asm"
SleepEffect: SleepEffect:
ld de, wEnemyMonStatus ld de, wEnemyMonStatus
ld bc, wEnemyBattleStatus2 ld bc, wEnemyBattleStatus2
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jp z, .sleepEffect jp z, .sleepEffect
ld de, wBattleMonStatus ld de, wBattleMonStatus
@ -78,7 +78,7 @@ AlreadyAsleepText:
PoisonEffect: PoisonEffect:
ld hl, wEnemyMonStatus ld hl, wEnemyMonStatus
ld de, wPlayerMoveEffect ld de, wPlayerMoveEffect
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr z, .poisonEffect jr z, .poisonEffect
ld hl, wBattleMonStatus ld hl, wBattleMonStatus
@ -121,7 +121,7 @@ PoisonEffect:
set 3, [hl] ; mon is now poisoned set 3, [hl] ; mon is now poisoned
push de push de
dec de dec de
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
ld b, ANIM_C7 ld b, ANIM_C7
ld hl, wPlayerBattleStatus3 ld hl, wPlayerBattleStatus3
@ -175,7 +175,7 @@ DrainHPEffect:
ExplodeEffect: ExplodeEffect:
ld hl, wBattleMonHP ld hl, wBattleMonHP
ld de, wPlayerBattleStatus2 ld de, wPlayerBattleStatus2
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr z, .faintUser jr z, .faintUser
ld hl, wEnemyMonHP ld hl, wEnemyMonHP
@ -196,7 +196,7 @@ FreezeBurnParalyzeEffect:
ld [wAnimationType], a ld [wAnimationType], a
call CheckTargetSubstitute ; test bit 4 of d063/d068 flags [target has substitute flag] call CheckTargetSubstitute ; test bit 4 of d063/d068 flags [target has substitute flag]
ret nz ; return if they have a substitute, can't effect them ret nz ; return if they have a substitute, can't effect them
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jp nz, opponentAttacker jp nz, opponentAttacker
ld a, [wEnemyMonStatus] ld a, [wEnemyMonStatus]
@ -308,7 +308,7 @@ CheckDefrost:
; any fire-type move that has a chance inflict burn (all but Fire Spin) will defrost a frozen target ; any fire-type move that has a chance inflict burn (all but Fire Spin) will defrost a frozen target
and 1 << FRZ ; are they frozen? and 1 << FRZ ; are they frozen?
ret z ; return if so ret z ; return if so
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr nz, .opponent jr nz, .opponent
;player [attacker] ;player [attacker]
@ -346,7 +346,7 @@ FireDefrostedText:
StatModifierUpEffect: StatModifierUpEffect:
ld hl, wPlayerMonStatMods ld hl, wPlayerMonStatMods
ld de, wPlayerMoveEffect ld de, wPlayerMoveEffect
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr z, .statModifierUpEffect jr z, .statModifierUpEffect
ld hl, wEnemyMonStatMods ld hl, wEnemyMonStatMods
@ -382,7 +382,7 @@ StatModifierUpEffect:
push hl push hl
ld hl, wBattleMonAttack + 1 ld hl, wBattleMonAttack + 1
ld de, wPlayerMonUnmodifiedAttack ld de, wPlayerMonUnmodifiedAttack
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr z, .pointToStats jr z, .pointToStats
ld hl, wEnemyMonAttack + 1 ld hl, wEnemyMonAttack + 1
@ -417,35 +417,35 @@ StatModifierUpEffect:
add hl, bc add hl, bc
pop bc pop bc
xor a xor a
ld [hMultiplicand], a ldh [hMultiplicand], a
ld a, [de] ld a, [de]
ld [hMultiplicand + 1], a ldh [hMultiplicand + 1], a
inc de inc de
ld a, [de] ld a, [de]
ld [hMultiplicand + 2], a ldh [hMultiplicand + 2], a
ld a, [hli] ld a, [hli]
ld [hMultiplier], a ldh [hMultiplier], a
call Multiply call Multiply
ld a, [hl] ld a, [hl]
ld [hDivisor], a ldh [hDivisor], a
ld b, $4 ld b, $4
call Divide call Divide
pop hl pop hl
; cap at 999 ; cap at 999
ld a, [hProduct + 3] ldh a, [hProduct + 3]
sub 999 % $100 sub 999 % $100
ld a, [hProduct + 2] ldh a, [hProduct + 2]
sbc 999 / $100 sbc 999 / $100
jp c, UpdateStat jp c, UpdateStat
ld a, 999 / $100 ld a, 999 / $100
ld [hMultiplicand + 1], a ldh [hMultiplicand + 1], a
ld a, 999 % $100 ld a, 999 % $100
ld [hMultiplicand + 2], a ldh [hMultiplicand + 2], a
UpdateStat: UpdateStat:
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
pop hl pop hl
UpdateStatDone: UpdateStatDone:
@ -455,7 +455,7 @@ UpdateStatDone:
ld hl, wPlayerBattleStatus2 ld hl, wPlayerBattleStatus2
ld de, wPlayerMoveNum ld de, wPlayerMoveNum
ld bc, wPlayerMonMinimized ld bc, wPlayerMonMinimized
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr z, .asm_3f4e6 jr z, .asm_3f4e6
ld hl, wEnemyBattleStatus2 ld hl, wEnemyBattleStatus2
@ -488,7 +488,7 @@ UpdateStatDone:
pop af pop af
call nz, Bankswitch call nz, Bankswitch
.applyBadgeBoostsAndStatusPenalties .applyBadgeBoostsAndStatusPenalties
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
call z, ApplyBadgeStatBoosts ; whenever the player uses a stat-up move, badge boosts get reapplied again to every stat, call z, ApplyBadgeStatBoosts ; whenever the player uses a stat-up move, badge boosts get reapplied again to every stat,
; even to those not affected by the stat-up move (will be boosted further) ; even to those not affected by the stat-up move (will be boosted further)
@ -511,7 +511,7 @@ MonsStatsRoseText:
text_far _MonsStatsRoseText text_far _MonsStatsRoseText
text_asm text_asm
ld hl, GreatlyRoseText ld hl, GreatlyRoseText
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
ld a, [wPlayerMoveEffect] ld a, [wPlayerMoveEffect]
jr z, .playerTurn jr z, .playerTurn
@ -534,7 +534,7 @@ StatModifierDownEffect:
ld hl, wEnemyMonStatMods ld hl, wEnemyMonStatMods
ld de, wPlayerMoveEffect ld de, wPlayerMoveEffect
ld bc, wEnemyBattleStatus1 ld bc, wEnemyBattleStatus1
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr z, .statModifierDownEffect jr z, .statModifierDownEffect
ld hl, wPlayerMonStatMods ld hl, wPlayerMonStatMods
@ -601,7 +601,7 @@ StatModifierDownEffect:
push de push de
ld hl, wEnemyMonAttack + 1 ld hl, wEnemyMonAttack + 1
ld de, wEnemyMonUnmodifiedAttack ld de, wEnemyMonUnmodifiedAttack
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr z, .pointToStat jr z, .pointToStat
ld hl, wBattleMonAttack + 1 ld hl, wBattleMonAttack + 1
@ -637,33 +637,33 @@ StatModifierDownEffect:
add hl, bc add hl, bc
pop bc pop bc
xor a xor a
ld [hMultiplicand], a ldh [hMultiplicand], a
ld a, [de] ld a, [de]
ld [hMultiplicand + 1], a ldh [hMultiplicand + 1], a
inc de inc de
ld a, [de] ld a, [de]
ld [hMultiplicand + 2], a ldh [hMultiplicand + 2], a
ld a, [hli] ld a, [hli]
ld [hMultiplier], a ldh [hMultiplier], a
call Multiply call Multiply
ld a, [hl] ld a, [hl]
ld [hDivisor], a ldh [hDivisor], a
ld b, $4 ld b, $4
call Divide call Divide
pop hl pop hl
ld a, [hProduct + 3] ldh a, [hProduct + 3]
ld b, a ld b, a
ld a, [hProduct + 2] ldh a, [hProduct + 2]
or b or b
jp nz, UpdateLoweredStat jp nz, UpdateLoweredStat
ld [hMultiplicand + 1], a ldh [hMultiplicand + 1], a
ld a, $1 ld a, $1
ld [hMultiplicand + 2], a ldh [hMultiplicand + 2], a
UpdateLoweredStat: UpdateLoweredStat:
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
pop de pop de
pop hl pop hl
@ -678,7 +678,7 @@ UpdateLoweredStatDone:
jr nc, .ApplyBadgeBoostsAndStatusPenalties jr nc, .ApplyBadgeBoostsAndStatusPenalties
call PlayCurrentMoveAnimation2 call PlayCurrentMoveAnimation2
.ApplyBadgeBoostsAndStatusPenalties .ApplyBadgeBoostsAndStatusPenalties
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
call nz, ApplyBadgeStatBoosts ; whenever the player uses a stat-down move, badge boosts get reapplied again to every stat, call nz, ApplyBadgeStatBoosts ; whenever the player uses a stat-down move, badge boosts get reapplied again to every stat,
; even to those not affected by the stat-up move (will be boosted further) ; even to those not affected by the stat-up move (will be boosted further)
@ -713,7 +713,7 @@ MonsStatsFellText:
text_far _MonsStatsFellText text_far _MonsStatsFellText
text_asm text_asm
ld hl, FellText ld hl, FellText
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
ld a, [wPlayerMoveEffect] ld a, [wPlayerMoveEffect]
jr z, .playerTurn jr z, .playerTurn
@ -759,7 +759,7 @@ BideEffect:
ld hl, wPlayerBattleStatus1 ld hl, wPlayerBattleStatus1
ld de, wPlayerBideAccumulatedDamage ld de, wPlayerBideAccumulatedDamage
ld bc, wPlayerNumAttacksLeft ld bc, wPlayerNumAttacksLeft
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr z, .bideEffect jr z, .bideEffect
ld hl, wEnemyBattleStatus1 ld hl, wEnemyBattleStatus1
@ -778,14 +778,14 @@ BideEffect:
inc a inc a
inc a inc a
ld [bc], a ; set Bide counter to 2 or 3 at random ld [bc], a ; set Bide counter to 2 or 3 at random
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
add XSTATITEM_ANIM add XSTATITEM_ANIM
jp PlayBattleAnimation2 jp PlayBattleAnimation2
ThrashPetalDanceEffect: ThrashPetalDanceEffect:
ld hl, wPlayerBattleStatus1 ld hl, wPlayerBattleStatus1
ld de, wPlayerNumAttacksLeft ld de, wPlayerNumAttacksLeft
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr z, .thrashPetalDanceEffect jr z, .thrashPetalDanceEffect
ld hl, wEnemyBattleStatus1 ld hl, wEnemyBattleStatus1
@ -797,12 +797,12 @@ ThrashPetalDanceEffect:
inc a inc a
inc a inc a
ld [de], a ; set thrash/petal dance counter to 2 or 3 at random ld [de], a ; set thrash/petal dance counter to 2 or 3 at random
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
add ANIM_B0 add ANIM_B0
jp PlayBattleAnimation2 jp PlayBattleAnimation2
SwitchAndTeleportEffect: SwitchAndTeleportEffect:
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr nz, .handleEnemy jr nz, .handleEnemy
ld a, [wIsInBattle] ld a, [wIsInBattle]
@ -920,7 +920,7 @@ TwoToFiveAttacksEffect:
ld hl, wPlayerBattleStatus1 ld hl, wPlayerBattleStatus1
ld de, wPlayerNumAttacksLeft ld de, wPlayerNumAttacksLeft
ld bc, wPlayerNumHits ld bc, wPlayerNumHits
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr z, .twoToFiveAttacksEffect jr z, .twoToFiveAttacksEffect
ld hl, wEnemyBattleStatus1 ld hl, wEnemyBattleStatus1
@ -931,7 +931,7 @@ TwoToFiveAttacksEffect:
ret nz ret nz
set ATTACKING_MULTIPLE_TIMES, [hl] ; mon is now attacking multiple times set ATTACKING_MULTIPLE_TIMES, [hl] ; mon is now attacking multiple times
ld hl, wPlayerMoveEffect ld hl, wPlayerMoveEffect
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr z, .setNumberOfHits jr z, .setNumberOfHits
ld hl, wEnemyMoveEffect ld hl, wEnemyMoveEffect
@ -967,7 +967,7 @@ FlinchSideEffect:
ret nz ret nz
ld hl, wEnemyBattleStatus1 ld hl, wEnemyBattleStatus1
ld de, wPlayerMoveEffect ld de, wPlayerMoveEffect
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr z, .flinchSideEffect jr z, .flinchSideEffect
ld hl, wPlayerBattleStatus1 ld hl, wPlayerBattleStatus1
@ -992,7 +992,7 @@ OneHitKOEffect:
ChargeEffect: ChargeEffect:
ld hl, wPlayerBattleStatus1 ld hl, wPlayerBattleStatus1
ld de, wPlayerMoveEffect ld de, wPlayerMoveEffect
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
ld b, XSTATITEM_ANIM ld b, XSTATITEM_ANIM
jr z, .chargeEffect jr z, .chargeEffect
@ -1074,7 +1074,7 @@ DugAHoleText:
TrappingEffect: TrappingEffect:
ld hl, wPlayerBattleStatus1 ld hl, wPlayerBattleStatus1
ld de, wPlayerNumAttacksLeft ld de, wPlayerNumAttacksLeft
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr z, .trappingEffect jr z, .trappingEffect
ld hl, wEnemyBattleStatus1 ld hl, wEnemyBattleStatus1
@ -1120,7 +1120,7 @@ ConfusionEffect:
jr nz, ConfusionEffectFailed jr nz, ConfusionEffectFailed
ConfusionSideEffectSuccess: ConfusionSideEffectSuccess:
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
ld hl, wEnemyBattleStatus1 ld hl, wEnemyBattleStatus1
ld bc, wEnemyConfusedCounter ld bc, wEnemyConfusedCounter
@ -1164,7 +1164,7 @@ SubstituteEffect:
HyperBeamEffect: HyperBeamEffect:
ld hl, wPlayerBattleStatus2 ld hl, wPlayerBattleStatus2
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr z, .hyperBeamEffect jr z, .hyperBeamEffect
ld hl, wEnemyBattleStatus2 ld hl, wEnemyBattleStatus2
@ -1175,7 +1175,7 @@ HyperBeamEffect:
ClearHyperBeam: ClearHyperBeam:
push hl push hl
ld hl, wEnemyBattleStatus2 ld hl, wEnemyBattleStatus2
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr z, .playerTurn jr z, .playerTurn
ld hl, wPlayerBattleStatus2 ld hl, wPlayerBattleStatus2
@ -1186,7 +1186,7 @@ ClearHyperBeam:
RageEffect: RageEffect:
ld hl, wPlayerBattleStatus2 ld hl, wPlayerBattleStatus2
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr z, .player jr z, .player
ld hl, wEnemyBattleStatus2 ld hl, wEnemyBattleStatus2
@ -1201,7 +1201,7 @@ MimicEffect:
ld a, [wMoveMissed] ld a, [wMoveMissed]
and a and a
jr nz, .mimicMissed jr nz, .mimicMissed
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
ld hl, wBattleMonMoves ld hl, wBattleMonMoves
ld a, [wPlayerBattleStatus1] ld a, [wPlayerBattleStatus1]
@ -1226,7 +1226,7 @@ MimicEffect:
and a and a
jr z, .getRandomMove jr z, .getRandomMove
ld d, a ld d, a
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
ld hl, wBattleMonMoves ld hl, wBattleMonMoves
ld a, [wPlayerMoveListIndex] ld a, [wPlayerMoveListIndex]
@ -1284,7 +1284,7 @@ DisableEffect:
jr nz, .moveMissed jr nz, .moveMissed
ld de, wEnemyDisabledMove ld de, wEnemyDisabledMove
ld hl, wEnemyMonMoves ld hl, wEnemyMonMoves
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr z, .disableEffect jr z, .disableEffect
ld de, wPlayerDisabledMove ld de, wPlayerDisabledMove
@ -1307,7 +1307,7 @@ DisableEffect:
jr z, .pickMoveToDisable ; loop until a non-00 move slot is found jr z, .pickMoveToDisable ; loop until a non-00 move slot is found
ld [wd11e], a ; store move number ld [wd11e], a ; store move number
push hl push hl
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
ld hl, wBattleMonPP ld hl, wBattleMonPP
jr nz, .enemyTurn jr nz, .enemyTurn
@ -1345,7 +1345,7 @@ DisableEffect:
ld [de], a ld [de], a
call PlayCurrentMoveAnimation2 call PlayCurrentMoveAnimation2
ld hl, wPlayerDisabledMoveNumber ld hl, wPlayerDisabledMoveNumber
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr nz, .printDisableText jr nz, .printDisableText
inc hl ; wEnemyDisabledMoveNumber inc hl ; wEnemyDisabledMoveNumber
@ -1430,7 +1430,7 @@ ParalyzedMayNotAttackText:
CheckTargetSubstitute: CheckTargetSubstitute:
push hl push hl
ld hl, wEnemyBattleStatus2 ld hl, wEnemyBattleStatus2
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr z, .next1 jr z, .next1
ld hl, wPlayerBattleStatus2 ld hl, wPlayerBattleStatus2
@ -1442,7 +1442,7 @@ CheckTargetSubstitute:
PlayCurrentMoveAnimation2: PlayCurrentMoveAnimation2:
; animation at MOVENUM will be played unless MOVENUM is 0 ; animation at MOVENUM will be played unless MOVENUM is 0
; plays wAnimationType 3 or 6 ; plays wAnimationType 3 or 6
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
ld a, [wPlayerMoveNum] ld a, [wPlayerMoveNum]
jr z, .notEnemyTurn jr z, .notEnemyTurn
@ -1454,7 +1454,7 @@ PlayCurrentMoveAnimation2:
PlayBattleAnimation2: PlayBattleAnimation2:
; play animation ID at a and animation type 6 or 3 ; play animation ID at a and animation type 6 or 3
ld [wAnimationID], a ld [wAnimationID], a
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
ld a, $6 ld a, $6
jr z, .storeAnimationType jr z, .storeAnimationType
@ -1468,7 +1468,7 @@ PlayCurrentMoveAnimation:
; resets wAnimationType ; resets wAnimationType
xor a xor a
ld [wAnimationType], a ld [wAnimationType], a
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
ld a, [wPlayerMoveNum] ld a, [wPlayerMoveNum]
jr z, .notEnemyTurn jr z, .notEnemyTurn

View file

@ -55,15 +55,15 @@ GainExperience:
jr .gainStatExpLoop jr .gainStatExpLoop
.statExpDone .statExpDone
xor a xor a
ld [hMultiplicand], a ldh [hMultiplicand], a
ld [hMultiplicand + 1], a ldh [hMultiplicand + 1], a
ld a, [wEnemyMonBaseExp] ld a, [wEnemyMonBaseExp]
ld [hMultiplicand + 2], a ldh [hMultiplicand + 2], a
ld a, [wEnemyMonLevel] ld a, [wEnemyMonLevel]
ld [hMultiplier], a ldh [hMultiplier], a
call Multiply call Multiply
ld a, 7 ld a, 7
ld [hDivisor], a ldh [hDivisor], a
ld b, 4 ld b, 4
call Divide call Divide
ld hl, wPartyMon1OTID - (wPartyMon1DVs - 1) ld hl, wPartyMon1OTID - (wPartyMon1DVs - 1)
@ -91,12 +91,12 @@ GainExperience:
inc hl inc hl
; add the gained exp to the party mon's exp ; add the gained exp to the party mon's exp
ld b, [hl] ld b, [hl]
ld a, [hQuotient + 3] ldh a, [hQuotient + 3]
ld [wExpAmountGained + 1], a ld [wExpAmountGained + 1], a
add b add b
ld [hld], a ld [hld], a
ld b, [hl] ld b, [hl]
ld a, [hQuotient + 2] ldh a, [hQuotient + 2]
ld [wExpAmountGained], a ld [wExpAmountGained], a
adc b adc b
ld [hl], a ld [hl], a
@ -119,11 +119,11 @@ GainExperience:
ld d, MAX_LEVEL ld d, MAX_LEVEL
callab CalcExperience ; get max exp callab CalcExperience ; get max exp
; compare max exp with current exp ; compare max exp with current exp
ld a, [hExperience] ldh a, [hExperience]
ld b, a ld b, a
ld a, [hExperience + 1] ldh a, [hExperience + 1]
ld c, a ld c, a
ld a, [hExperience + 2] ldh a, [hExperience + 2]
ld d, a ld d, a
pop hl pop hl
ld a, [hld] ld a, [hld]
@ -311,14 +311,14 @@ DivideExpDataByNumMonsGainingExp:
ld c, wEnemyMonBaseExp + 1 - wEnemyMonBaseStats ld c, wEnemyMonBaseExp + 1 - wEnemyMonBaseStats
.divideLoop .divideLoop
xor a xor a
ld [hDividend], a ldh [hDividend], a
ld a, [hl] ld a, [hl]
ld [hDividend + 1], a ldh [hDividend + 1], a
ld a, [wd11e] ld a, [wd11e]
ld [hDivisor], a ldh [hDivisor], a
ld b, $2 ld b, $2
call Divide ; divide value by number of mons gaining exp call Divide ; divide value by number of mons gaining exp
ld a, [hQuotient + 3] ldh a, [hQuotient + 3]
ld [hli], a ld [hli], a
dec c dec c
jr nz, .divideLoop jr nz, .divideLoop
@ -326,17 +326,17 @@ DivideExpDataByNumMonsGainingExp:
; multiplies exp by 1.5 ; multiplies exp by 1.5
BoostExp: BoostExp:
ld a, [hQuotient + 2] ldh a, [hQuotient + 2]
ld b, a ld b, a
ld a, [hQuotient + 3] ldh a, [hQuotient + 3]
ld c, a ld c, a
srl b srl b
rr c rr c
add c add c
ld [hQuotient + 3], a ldh [hQuotient + 3], a
ld a, [hQuotient + 2] ldh a, [hQuotient + 2]
adc b adc b
ld [hQuotient + 2], a ldh [hQuotient + 2], a
ret ret
GainedText: GainedText:

View file

@ -1,7 +1,7 @@
MarowakAnim: MarowakAnim:
; animate the ghost being unveiled as a Marowak ; animate the ghost being unveiled as a Marowak
ld a, $e4 ld a, $e4
ld [rOBP1], a ldh [rOBP1], a
call CopyMonPicFromBGToSpriteVRAM ; cover the BG ghost pic with a sprite ghost pic that looks the same call CopyMonPicFromBGToSpriteVRAM ; cover the BG ghost pic with a sprite ghost pic that looks the same
; now that the ghost pic is being displayed using sprites, clear the ghost pic from the BG tilemap ; now that the ghost pic is being displayed using sprites, clear the ghost pic from the BG tilemap
coord hl, 12, 0 coord hl, 12, 0
@ -9,12 +9,12 @@ MarowakAnim:
call ClearScreenArea call ClearScreenArea
call Delay3 call Delay3
xor a xor a
ld [hAutoBGTransferEnabled], a ; disable BG transfer so we don't see the Marowak too soon ldh [hAutoBGTransferEnabled], a ; disable BG transfer so we don't see the Marowak too soon
; replace ghost pic with Marowak in BG ; replace ghost pic with Marowak in BG
ld a, MAROWAK ld a, MAROWAK
ld [wChangeMonPicEnemyTurnSpecies], a ld [wChangeMonPicEnemyTurnSpecies], a
ld a, $1 ld a, $1
ld [hWhoseTurn], a ldh [hWhoseTurn], a
callab ChangeMonPic callab ChangeMonPic
; alternate between black and light grey 8 times. ; alternate between black and light grey 8 times.
; this makes the ghost's body appear to flash ; this makes the ghost's body appear to flash
@ -23,10 +23,10 @@ MarowakAnim:
.fadeOutGhostLoop .fadeOutGhostLoop
ld c, 10 ld c, 10
call DelayFrames call DelayFrames
ld a, [rOBP1] ldh a, [rOBP1]
sla a sla a
sla a sla a
ld [rOBP1], a ldh [rOBP1], a
jr nz, .fadeOutGhostLoop jr nz, .fadeOutGhostLoop
call ClearSprites call ClearSprites
call CopyMonPicFromBGToSpriteVRAM ; copy Marowak pic from BG to sprite VRAM call CopyMonPicFromBGToSpriteVRAM ; copy Marowak pic from BG to sprite VRAM
@ -34,17 +34,17 @@ MarowakAnim:
.fadeInMarowakLoop .fadeInMarowakLoop
ld c, 10 ld c, 10
call DelayFrames call DelayFrames
ld a, [rOBP1] ldh a, [rOBP1]
srl b srl b
rra rra
srl b srl b
rra rra
ld [rOBP1], a ldh [rOBP1], a
ld a, b ld a, b
and a and a
jr nz, .fadeInMarowakLoop jr nz, .fadeInMarowakLoop
ld a, $1 ld a, $1
ld [hAutoBGTransferEnabled], a ; enable BG transfer so the BG Marowak pic will be visible after the sprite one is cleared ldh [hAutoBGTransferEnabled], a ; enable BG transfer so the BG Marowak pic will be visible after the sprite one is cleared
call Delay3 call Delay3
jp ClearSprites jp ClearSprites

View file

@ -1,5 +1,5 @@
InitBattleVariables: InitBattleVariables:
ld a, [hTilesetType] ldh a, [hTilesetType]
ld [wSavedTilesetType], a ld [wSavedTilesetType], a
xor a xor a
ld [wActionResultOrTookBattleTurn], a ld [wActionResultOrTookBattleTurn], a

View file

@ -1,7 +1,7 @@
ConversionEffect_: ConversionEffect_:
ld hl, wEnemyMonType1 ld hl, wEnemyMonType1
ld de, wBattleMonType1 ld de, wBattleMonType1
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
ld a, [wEnemyBattleStatus1] ld a, [wEnemyBattleStatus1]
jr z, .conversionEffect jr z, .conversionEffect

View file

@ -14,7 +14,7 @@ DrainHPEffect_:
.getAttackerHP .getAttackerHP
ld hl, wBattleMonHP ld hl, wBattleMonHP
ld de, wBattleMonMaxHP ld de, wBattleMonMaxHP
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jp z, .addDamageToAttackerHP jp z, .addDamageToAttackerHP
ld hl, wEnemyMonHP ld hl, wEnemyMonHP
@ -69,7 +69,7 @@ DrainHPEffect_:
ld [wHPBarNewHP+1], a ld [wHPBarNewHP+1], a
inc de inc de
.next .next
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
coord hl, 10, 9 coord hl, 10, 9
ld a, $1 ld a, $1
@ -83,7 +83,7 @@ DrainHPEffect_:
predef DrawEnemyHUDAndHPBar predef DrawEnemyHUDAndHPBar
callab ReadPlayerMonCurHPAndStatus callab ReadPlayerMonCurHPAndStatus
ld hl, SuckedHealthText ld hl, SuckedHealthText
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
ld a, [wPlayerMoveEffect] ld a, [wPlayerMoveEffect]
jr z, .next3 jr z, .next3

View file

@ -1,6 +1,6 @@
FocusEnergyEffect_: FocusEnergyEffect_:
ld hl, wPlayerBattleStatus2 ld hl, wPlayerBattleStatus2
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr z, .notEnemy jr z, .notEnemy
ld hl, wEnemyBattleStatus2 ld hl, wEnemyBattleStatus2

View file

@ -15,7 +15,7 @@ HazeEffect_:
; cure non-volatile status, but only for the target ; cure non-volatile status, but only for the target
ld hl, wEnemyMonStatus ld hl, wEnemyMonStatus
ld de, wEnemySelectedMove ld de, wEnemySelectedMove
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr z, .cureStatuses jr z, .cureStatuses
ld hl, wBattleMonStatus ld hl, wBattleMonStatus

View file

@ -1,5 +1,5 @@
HealEffect_: HealEffect_:
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
ld de, wBattleMonHP ld de, wBattleMonHP
ld hl, wBattleMonMaxHP ld hl, wBattleMonMaxHP
@ -27,7 +27,7 @@ HealEffect_:
ld c, 50 ld c, 50
call DelayFrames call DelayFrames
ld hl, wBattleMonStatus ld hl, wBattleMonStatus
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr z, .restEffect jr z, .restEffect
ld hl, wEnemyMonStatus ld hl, wEnemyMonStatus
@ -87,7 +87,7 @@ HealEffect_:
.playAnim .playAnim
ld hl, PlayCurrentMoveAnimation ld hl, PlayCurrentMoveAnimation
call BankswitchEtoF call BankswitchEtoF
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
coord hl, 10, 9 coord hl, 10, 9
ld a, $1 ld a, $1

View file

@ -5,7 +5,7 @@ LeechSeedEffect_:
jr nz, .moveMissed jr nz, .moveMissed
ld hl, wEnemyBattleStatus2 ld hl, wEnemyBattleStatus2
ld de, wEnemyMonType1 ld de, wEnemyMonType1
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr z, .leechSeedEffect jr z, .leechSeedEffect
ld hl, wPlayerBattleStatus2 ld hl, wPlayerBattleStatus2

View file

@ -1,6 +1,6 @@
MistEffect_: MistEffect_:
ld hl, wPlayerBattleStatus2 ld hl, wPlayerBattleStatus2
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr z, .mistEffect jr z, .mistEffect
ld hl, wEnemyBattleStatus2 ld hl, wEnemyBattleStatus2

View file

@ -7,7 +7,7 @@ OneHitKOEffect_:
ld [wCriticalHitOrOHKO], a ld [wCriticalHitOrOHKO], a
ld hl, wBattleMonSpeed + 1 ld hl, wBattleMonSpeed + 1
ld de, wEnemyMonSpeed + 1 ld de, wEnemyMonSpeed + 1
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr z, .compareSpeed jr z, .compareSpeed
ld hl, wEnemyMonSpeed + 1 ld hl, wEnemyMonSpeed + 1

View file

@ -1,7 +1,7 @@
ParalyzeEffect_: ParalyzeEffect_:
ld hl, wEnemyMonStatus ld hl, wEnemyMonStatus
ld de, wPlayerMoveType ld de, wPlayerMoveType
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jp z, .next jp z, .next
ld hl, wBattleMonStatus ld hl, wBattleMonStatus

View file

@ -2,7 +2,7 @@ PayDayEffect_:
xor a xor a
ld hl, wcd6d ld hl, wcd6d
ld [hli], a ld [hli], a
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
ld a, [wBattleMonLevel] ld a, [wBattleMonLevel]
jr z, .payDayEffect jr z, .payDayEffect
@ -10,28 +10,28 @@ PayDayEffect_:
.payDayEffect .payDayEffect
; level * 2 ; level * 2
add a add a
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
; convert to BCD ; convert to BCD
ld a, 100 ld a, 100
ld [hDivisor], a ldh [hDivisor], a
ld b, $4 ld b, $4
call Divide call Divide
ld a, [hQuotient + 3] ldh a, [hQuotient + 3]
ld [hli], a ld [hli], a
ld a, [hRemainder] ldh a, [hRemainder]
ld [hDividend + 3], a ldh [hDividend + 3], a
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 + 3] ldh a, [hQuotient + 3]
swap a swap a
ld b, a ld b, a
ld a, [hRemainder] ldh a, [hRemainder]
add b add b
ld [hl], a ld [hl], a
ld de, wTotalPayDayMoney + 2 ld de, wTotalPayDayMoney + 2

View file

@ -1,5 +1,5 @@
RecoilEffect_: RecoilEffect_:
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
ld a, [wPlayerMoveNum] ld a, [wPlayerMoveNum]
ld hl, wBattleMonMaxHP ld hl, wBattleMonMaxHP
@ -54,7 +54,7 @@ RecoilEffect_:
ld [hl], a ld [hl], a
.getHPBarCoords .getHPBarCoords
coord hl, 10, 9 coord hl, 10, 9
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
ld a, $1 ld a, $1
jr z, .updateHPBar jr z, .updateHPBar

View file

@ -1,7 +1,7 @@
ReflectLightScreenEffect_: ReflectLightScreenEffect_:
ld hl, wPlayerBattleStatus3 ld hl, wPlayerBattleStatus3
ld de, wPlayerMoveEffect ld de, wPlayerMoveEffect
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr z, .reflectLightScreenEffect jr z, .reflectLightScreenEffect
ld hl, wEnemyBattleStatus3 ld hl, wEnemyBattleStatus3

View file

@ -4,7 +4,7 @@ SubstituteEffect_:
ld hl, wBattleMonMaxHP ld hl, wBattleMonMaxHP
ld de, wPlayerSubstituteHP ld de, wPlayerSubstituteHP
ld bc, wPlayerBattleStatus2 ld bc, wPlayerBattleStatus2
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr z, .notEnemy jr z, .notEnemy
ld hl, wEnemyMonMaxHP ld hl, wEnemyMonMaxHP

View file

@ -3,7 +3,7 @@ TransformEffect_:
ld de, wEnemyMonSpecies ld de, wEnemyMonSpecies
ld bc, wEnemyBattleStatus3 ld bc, wEnemyBattleStatus3
ld a, [wEnemyBattleStatus1] ld a, [wEnemyBattleStatus1]
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr nz, .hitTest jr nz, .hitTest
ld hl, wEnemyMonSpecies ld hl, wEnemyMonSpecies
@ -18,7 +18,7 @@ TransformEffect_:
push de push de
push bc push bc
ld hl, wPlayerBattleStatus2 ld hl, wPlayerBattleStatus2
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr z, .transformEffect jr z, .transformEffect
ld hl, wEnemyBattleStatus2 ld hl, wEnemyBattleStatus2
@ -64,7 +64,7 @@ TransformEffect_:
inc bc inc bc
inc bc inc bc
call CopyData call CopyData
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr z, .next jr z, .next
; save enemy mon DVs at wTransformedEnemyMonOriginalDVs ; save enemy mon DVs at wTransformedEnemyMonOriginalDVs
@ -128,7 +128,7 @@ TransformEffect_:
jp PrintText jp PrintText
.copyBasedOnTurn .copyBasedOnTurn
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
jr z, .gotStatsOrModsToCopy jr z, .gotStatsOrModsToCopy
push hl push hl

View file

@ -41,16 +41,16 @@ ScaleFirstThreeSpriteColumnsByTwo:
ScaleLastSpriteColumnByTwo: ScaleLastSpriteColumnByTwo:
ld a, 4*8 - 4 ; $1c, 4 tiles minus 4 unused rows ld a, 4*8 - 4 ; $1c, 4 tiles minus 4 unused rows
ld [hSpriteInterlaceCounter], a ldh [hSpriteInterlaceCounter], a
ld bc, -1 ld bc, -1
.columnInnerLoop .columnInnerLoop
ld a, [de] ld a, [de]
dec de dec de
swap a ; only high nybble contains information swap a ; only high nybble contains information
call ScalePixelsByTwo call ScalePixelsByTwo
ld a, [hSpriteInterlaceCounter] ldh a, [hSpriteInterlaceCounter]
dec a dec a
ld [hSpriteInterlaceCounter], a ldh [hSpriteInterlaceCounter], a
jr nz, .columnInnerLoop jr nz, .columnInnerLoop
dec de ; skip last 4 rows of new column dec de ; skip last 4 rows of new column
dec de dec de

View file

@ -655,17 +655,17 @@ AIUseDireHit: ; unused
AICheckIfHPBelowFraction: AICheckIfHPBelowFraction:
; return carry if enemy trainer's current HP is below 1 / a of the maximum ; return carry if enemy trainer's current HP is below 1 / a of the maximum
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 + 3] ldh a, [hQuotient + 3]
ld c, a ld c, a
ld a, [hQuotient + 2] ldh a, [hQuotient + 2]
ld b, a ld b, a
ld hl, wEnemyMonHP + 1 ld hl, wEnemyMonHP + 1
ld a, [hld] ld a, [hld]

View file

@ -1,6 +1,6 @@
; does nothing since no stats are ever selected (barring glitches) ; does nothing since no stats are ever selected (barring glitches)
DoubleSelectedStats: DoubleSelectedStats:
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
ld a, [wPlayerStatsToDouble] ld a, [wPlayerStatsToDouble]
ld hl, wBattleMonAttack + 1 ld hl, wBattleMonAttack + 1
@ -30,7 +30,7 @@ DoubleSelectedStats:
; does nothing since no stats are ever selected (barring glitches) ; does nothing since no stats are ever selected (barring glitches)
HalveSelectedStats: HalveSelectedStats:
ld a, [hWhoseTurn] ldh a, [hWhoseTurn]
and a and a
ld a, [wPlayerStatsToHalve] ld a, [wPlayerStatsToHalve]
ld hl, wBattleMonAttack ld hl, wBattleMonAttack

View file

@ -48,10 +48,10 @@ TryDoWildEncounter:
.CanEncounter .CanEncounter
; compare encounter chance with a random number to determine if there will be an encounter ; compare encounter chance with a random number to determine if there will be an encounter
ld b, a ld b, a
ld a, [hRandomAdd] ldh a, [hRandomAdd]
cp b cp b
jr nc, .CantEncounter2 jr nc, .CantEncounter2
ld a, [hRandomSub] ldh a, [hRandomSub]
ld b, a ld b, a
ld hl, WildMonEncounterSlotChances ld hl, WildMonEncounterSlotChances
.determineEncounterSlot .determineEncounterSlot
@ -90,7 +90,7 @@ TryDoWildEncounter:
.lastRepelStep .lastRepelStep
ld [wRepelRemainingSteps], a ld [wRepelRemainingSteps], a
ld a, TEXT_REPEL_WORE_OFF ld a, TEXT_REPEL_WORE_OFF
ld [hSpriteIndexOrTextID], a ldh [hSpriteIndexOrTextID], a
call EnableAutoTextBoxDrawing call EnableAutoTextBoxDrawing
call DisplayTextID call DisplayTextID
.CantEncounter2 .CantEncounter2

View file

@ -41,5 +41,5 @@ TestBattle:
; do it all again. ; do it all again.
ld a, 1 ld a, 1
ld [wUpdateSpritesEnabled], a ld [wUpdateSpritesEnabled], a
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
jr .loop jr .loop

View file

@ -6,34 +6,34 @@ ResetStatusAndHalveMoneyOnBlackout::
ld [wIsInBattle], a ld [wIsInBattle], a
ld [wMapPalOffset], a ld [wMapPalOffset], a
ld [wNPCMovementScriptFunctionNum], a ld [wNPCMovementScriptFunctionNum], a
ld [hJoyHeld], a ldh [hJoyHeld], a
ld [wNPCMovementScriptPointerTableNum], a ld [wNPCMovementScriptPointerTableNum], a
ld [wFlags_0xcd60], a ld [wFlags_0xcd60], a
ld [hMoney], a ldh [hMoney], a
ld [hMoney + 1], a ldh [hMoney + 1], a
ld [hMoney + 2], a ldh [hMoney + 2], a
call HasEnoughMoney call HasEnoughMoney
jr c, .lostmoney ; never happens jr c, .lostmoney ; never happens
; Halve the player's money. ; Halve the player's money.
ld a, [wPlayerMoney] ld a, [wPlayerMoney]
ld [hMoney], a ldh [hMoney], a
ld a, [wPlayerMoney + 1] ld a, [wPlayerMoney + 1]
ld [hMoney + 1], a ldh [hMoney + 1], a
ld a, [wPlayerMoney + 2] ld a, [wPlayerMoney + 2]
ld [hMoney + 2], a ldh [hMoney + 2], a
xor a xor a
ld [hDivideBCDDivisor], a ldh [hDivideBCDDivisor], a
ld [hDivideBCDDivisor + 1], a ldh [hDivideBCDDivisor + 1], a
ld a, 2 ld a, 2
ld [hDivideBCDDivisor + 2], a ldh [hDivideBCDDivisor + 2], a
predef DivideBCDPredef3 predef DivideBCDPredef3
ld a, [hDivideBCDQuotient] ldh a, [hDivideBCDQuotient]
ld [wPlayerMoney], a ld [wPlayerMoney], a
ld a, [hDivideBCDQuotient + 1] ldh a, [hDivideBCDQuotient + 1]
ld [wPlayerMoney + 1], a ld [wPlayerMoney + 1], a
ld a, [hDivideBCDQuotient + 2] ldh a, [hDivideBCDQuotient + 2]
ld [wPlayerMoney + 2], a ld [wPlayerMoney + 2], a
.lostmoney .lostmoney

View file

@ -28,7 +28,7 @@ PrintCardKeyText:
call GetCoordsInFrontOfPlayer call GetCoordsInFrontOfPlayer
push de push de
tx_pre_id CardKeySuccessText tx_pre_id CardKeySuccessText
ld [hSpriteIndexOrTextID], a ldh [hSpriteIndexOrTextID], a
call PrintPredefTextID call PrintPredefTextID
pop de pop de
srl d srl d
@ -55,7 +55,7 @@ PrintCardKeyText:
jp PlaySound jp PlaySound
.noCardKey .noCardKey
tx_pre_id CardKeyFailText tx_pre_id CardKeyFailText
ld [hSpriteIndexOrTextID], a ldh [hSpriteIndexOrTextID], a
jp PrintPredefTextID jp PrintPredefTextID
SilphCoMapList: SilphCoMapList:

View file

@ -35,7 +35,7 @@ GiveFossilToCinnabarLab::
ld e, a ld e, a
add hl, de add hl, de
ld a, [hl] ld a, [hl]
ld [hItemToRemoveID], a ldh [hItemToRemoveID], a
cp DOME_FOSSIL cp DOME_FOSSIL
jr z, .choseDomeFossil jr z, .choseDomeFossil
cp HELIX_FOSSIL cp HELIX_FOSSIL
@ -61,7 +61,7 @@ GiveFossilToCinnabarLab::
ld hl, LabFossil_610b3 ld hl, LabFossil_610b3
call PrintText call PrintText
ld a, [wFossilItem] ld a, [wFossilItem]
ld [hItemToRemoveID], a ldh [hItemToRemoveID], a
callba RemoveItemByID callba RemoveItemByID
ld hl, LabFossil_610b8 ld hl, LabFossil_610b8
call PrintText call PrintText
@ -92,7 +92,7 @@ PrintFossilsInBag:
; Prints each fossil in the player's bag on a separate line in the menu. ; Prints each fossil in the player's bag on a separate line in the menu.
ld hl, wFilteredBagItems ld hl, wFilteredBagItems
xor a xor a
ld [hItemCounter], a ldh [hItemCounter], a
.loop .loop
ld a, [hli] ld a, [hli]
cp $ff cp $ff
@ -101,7 +101,7 @@ PrintFossilsInBag:
ld [wd11e], a ld [wd11e], a
call GetItemName call GetItemName
coord hl, 2, 2 coord hl, 2, 2
ld a, [hItemCounter] ldh a, [hItemCounter]
ld bc, SCREEN_WIDTH * 2 ld bc, SCREEN_WIDTH * 2
call AddNTimes call AddNTimes
ld de, wcd6d ld de, wcd6d

View file

@ -62,7 +62,7 @@ DisplayDiploma::
call Delay3 call Delay3
call GBPalNormal call GBPalNormal
ld a, $90 ld a, $90
ld [rOBP0], a ldh [rOBP0], a
call WaitForTextScrollButtonPress call WaitForTextScrollButtonPress
ld hl, wd730 ld hl, wd730
res 6, [hl] res 6, [hl]

View file

@ -67,9 +67,9 @@ HiddenCoins:
and a and a
ret nz ret nz
xor a xor a
ld [hUnusedCoinsByte], a ldh [hUnusedCoinsByte], a
ld [hCoins], a ldh [hCoins], a
ld [hCoins + 1], a ldh [hCoins + 1], a
ld a, [wHiddenObjectFunctionArgument] ld a, [wHiddenObjectFunctionArgument]
sub COIN sub COIN
cp 10 cp 10
@ -81,19 +81,19 @@ HiddenCoins:
jr .bcd100 jr .bcd100
.bcd10 .bcd10
ld a, $10 ld a, $10
ld [hCoins + 1], a ldh [hCoins + 1], a
jr .bcdDone jr .bcdDone
.bcd20 .bcd20
ld a, $20 ld a, $20
ld [hCoins + 1], a ldh [hCoins + 1], a
jr .bcdDone jr .bcdDone
.bcd40 ; due to a typo, this is never used .bcd40 ; due to a typo, this is never used
ld a, $40 ld a, $40
ld [hCoins + 1], a ldh [hCoins + 1], a
jr .bcdDone jr .bcdDone
.bcd100 .bcd100
ld a, $1 ld a, $1
ld [hCoins], a ldh [hCoins], a
.bcdDone .bcdDone
ld de, wPlayerCoins + 1 ld de, wPlayerCoins + 1
ld hl, hCoins + 1 ld hl, hCoins + 1

View file

@ -24,7 +24,7 @@ PrintBookshelfText::
pop af pop af
call PrintPredefTextID call PrintPredefTextID
xor a xor a
ld [hFFDB], a ldh [hFFDB], a
ret ret
.nextBookshelfEntry1 .nextBookshelfEntry1
inc hl inc hl
@ -33,7 +33,7 @@ PrintBookshelfText::
jr .loop jr .loop
.noMatch .noMatch
ld a, $ff ld a, $ff
ld [hFFDB], a ldh [hFFDB], a
jpba PrintCardKeyText jpba PrintCardKeyText
INCLUDE "data/tilesets/bookshelf_tile_ids.asm" INCLUDE "data/tilesets/bookshelf_tile_ids.asm"

View file

@ -12,14 +12,14 @@ CinnabarGymQuiz::
ld a, [wHiddenObjectFunctionArgument] ld a, [wHiddenObjectFunctionArgument]
push af push af
and $f and $f
ld [hGymGateIndex], a ldh [hGymGateIndex], a
pop af pop af
and $f0 and $f0
swap a swap a
ld [hGymGateAnswer], a ldh [hGymGateAnswer], a
ld hl, CinnabarGymQuizIntroText ld hl, CinnabarGymQuizIntroText
call PrintText call PrintText
ld a, [hGymGateIndex] ldh a, [hGymGateIndex]
dec a dec a
add a add a
ld d, 0 ld d, 0
@ -77,18 +77,18 @@ CinnabarGymGateFlagAction:
CinnabarGymQuiz_1ea92: CinnabarGymQuiz_1ea92:
call YesNoChoice call YesNoChoice
ld a, [hGymGateAnswer] ldh a, [hGymGateAnswer]
ld c, a ld c, a
ld a, [wCurrentMenuItem] ld a, [wCurrentMenuItem]
cp c cp c
jr nz, .wrongAnswer jr nz, .wrongAnswer
ld hl, wCurrentMapScriptFlags ld hl, wCurrentMapScriptFlags
set 5, [hl] set 5, [hl]
ld a, [hGymGateIndex] ldh a, [hGymGateIndex]
ld [hBackupGymGateIndex], a ldh [hBackupGymGateIndex], a
ld hl, CinnabarGymQuizCorrectText ld hl, CinnabarGymQuizCorrectText
call PrintText call PrintText
ld a, [hBackupGymGateIndex] ldh a, [hBackupGymGateIndex]
AdjustEventBit EVENT_CINNABAR_GYM_GATE0_UNLOCKED, 0 AdjustEventBit EVENT_CINNABAR_GYM_GATE0_UNLOCKED, 0
ld c, a ld c, a
ld b, FLAG_SET ld b, FLAG_SET
@ -101,7 +101,7 @@ CinnabarGymQuiz_1ea92:
call WaitForSoundToFinish call WaitForSoundToFinish
ld hl, CinnabarGymQuizIncorrectText ld hl, CinnabarGymQuizIncorrectText
call PrintText call PrintText
ld a, [hGymGateIndex] ldh a, [hGymGateIndex]
add $2 add $2
AdjustEventBit EVENT_BEAT_CINNABAR_GYM_TRAINER_0, 2 AdjustEventBit EVENT_BEAT_CINNABAR_GYM_TRAINER_0, 2
ld c, a ld c, a
@ -111,7 +111,7 @@ CinnabarGymQuiz_1ea92:
ld a, c ld a, c
and a and a
ret nz ret nz
ld a, [hGymGateIndex] ldh a, [hGymGateIndex]
add $2 add $2
ld [wOpponentAfterWrongAnswer], a ld [wOpponentAfterWrongAnswer], a
ret ret
@ -122,7 +122,7 @@ CinnabarGymQuizCorrectText:
text_promptbutton text_promptbutton
text_asm text_asm
ld a, [hBackupGymGateIndex] ldh a, [hBackupGymGateIndex]
AdjustEventBit EVENT_CINNABAR_GYM_GATE0_UNLOCKED, 0 AdjustEventBit EVENT_CINNABAR_GYM_GATE0_UNLOCKED, 0
ld c, a ld c, a
ld b, FLAG_TEST ld b, FLAG_TEST
@ -144,9 +144,9 @@ UpdateCinnabarGymGateTileBlocks_::
; Update the overworld map with open floor blocks or locked gate blocks ; Update the overworld map with open floor blocks or locked gate blocks
; depending on event flags. ; depending on event flags.
ld a, 6 ld a, 6
ld [hGymGateIndex], a ldh [hGymGateIndex], a
.loop .loop
ld a, [hGymGateIndex] ldh a, [hGymGateIndex]
dec a dec a
add a add a
add a add a
@ -161,8 +161,8 @@ UpdateCinnabarGymGateTileBlocks_::
ld a, [hl] ld a, [hl]
ld [wGymGateTileBlock], a ld [wGymGateTileBlock], a
push bc push bc
ld a, [hGymGateIndex] ldh a, [hGymGateIndex]
ld [hBackupGymGateIndex], a ldh [hBackupGymGateIndex], a
AdjustEventBit EVENT_CINNABAR_GYM_GATE0_UNLOCKED, 0 AdjustEventBit EVENT_CINNABAR_GYM_GATE0_UNLOCKED, 0
ld c, a ld c, a
ld b, FLAG_TEST ld b, FLAG_TEST

View file

@ -26,10 +26,10 @@ DisplayMonFrontSpriteInBox:
; Displays a pokemon's front sprite in a pop-up window. ; Displays a pokemon's front sprite in a pop-up window.
; [wcf91] = pokemon internal id number ; [wcf91] = pokemon internal id number
ld a, 1 ld a, 1
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
call Delay3 call Delay3
xor a xor a
ld [hWY], a ldh [hWY], a
call SaveScreenTilesToBuffer1 call SaveScreenTilesToBuffer1
ld a, MON_SPRITE_POPUP ld a, MON_SPRITE_POPUP
ld [wTextBoxID], a ld [wTextBoxID], a
@ -41,12 +41,12 @@ DisplayMonFrontSpriteInBox:
ld de, vChars1 + $310 ld de, vChars1 + $310
call LoadMonFrontSprite call LoadMonFrontSprite
ld a, $80 ld a, $80
ld [hStartTileID], a ldh [hStartTileID], a
coord hl, 10, 11 coord hl, 10, 11
predef AnimateSendingOutMon predef AnimateSendingOutMon
call WaitForTextScrollButtonPress call WaitForTextScrollButtonPress
call LoadScreenTilesFromBuffer1 call LoadScreenTilesFromBuffer1
call Delay3 call Delay3
ld a, $90 ld a, $90
ld [hWY], a ldh [hWY], a
ret ret

View file

@ -37,12 +37,12 @@ SafariZoneGameOver:
cp SFX_SAFARI_ZONE_PA cp SFX_SAFARI_ZONE_PA
jr nz, .waitForMusicToPlay jr nz, .waitForMusicToPlay
ld a, TEXT_SAFARI_GAME_OVER ld a, TEXT_SAFARI_GAME_OVER
ld [hSpriteIndexOrTextID], a ldh [hSpriteIndexOrTextID], a
call DisplayTextID call DisplayTextID
xor a xor a
ld [wPlayerMovingDirection], a ld [wPlayerMovingDirection], a
ld a, SAFARI_ZONE_GATE ld a, SAFARI_ZONE_GATE
ld [hWarpDestinationMap], a ldh [hWarpDestinationMap], a
ld a, $3 ld a, $3
ld [wDestinationWarpID], a ld [wDestinationWarpID], a
ld a, $5 ld a, $5

View file

@ -8,15 +8,15 @@ TownMapText::
set 6, [hl] set 6, [hl]
call GBPalWhiteOutWithDelay3 call GBPalWhiteOutWithDelay3
xor a xor a
ld [hWY], a ldh [hWY], a
inc a inc a
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
call LoadFontTilePatterns call LoadFontTilePatterns
callba DisplayTownMap callba DisplayTownMap
ld hl, wd730 ld hl, wd730
res 6, [hl] res 6, [hl]
ld de, TextScriptEnd ld de, TextScriptEnd
push de push de
ld a, [hLoadedROMBank] ldh a, [hLoadedROMBank]
push af push af
jp CloseTextDisplay jp CloseTextDisplay

View file

@ -56,12 +56,12 @@ GymTrashScript:
; first lock was in trash can 1 or 3. However, due to this bug, trash can 0 can ; first lock was in trash can 1 or 3. However, due to this bug, trash can 0 can
; have the second lock regardless of which trash can had the first lock. ; have the second lock regardless of which trash can had the first lock.
ld [hGymTrashCanRandNumMask], a ldh [hGymTrashCanRandNumMask], a
push hl push hl
call Random call Random
swap a swap a
ld b, a ld b, a
ld a, [hGymTrashCanRandNumMask] ldh a, [hGymTrashCanRandNumMask]
and b and b
dec a dec a
pop hl pop hl

View file

@ -9,16 +9,16 @@ OaksAideScript:
ld b, wPokedexOwnedEnd - wPokedexOwned ld b, wPokedexOwnedEnd - wPokedexOwned
call CountSetBits call CountSetBits
ld a, [wNumSetBits] ld a, [wNumSetBits]
ld [hOaksAideNumMonsOwned], a ldh [hOaksAideNumMonsOwned], a
ld b, a ld b, a
ld a, [hOaksAideRequirement] ldh a, [hOaksAideRequirement]
cp b cp b
jr z, .giveItem jr z, .giveItem
jr nc, .notEnoughOwnedMons jr nc, .notEnoughOwnedMons
.giveItem .giveItem
ld hl, OaksAideHereYouGoText ld hl, OaksAideHereYouGoText
call PrintText call PrintText
ld a, [hOaksAideRewardItem] ldh a, [hOaksAideRewardItem]
ld b, a ld b, a
ld c, 1 ld c, 1
call GiveItem call GiveItem
@ -42,7 +42,7 @@ OaksAideScript:
call PrintText call PrintText
ld a, $ff ld a, $ff
.done .done
ld [hOaksAideResult], a ldh [hOaksAideResult], a
ret ret
OaksAideHiText: OaksAideHiText:

View file

@ -1,7 +1,7 @@
PickUpItem: PickUpItem:
call EnableAutoTextBoxDrawing call EnableAutoTextBoxDrawing
ld a, [hSpriteIndexOrTextID] ldh a, [hSpriteIndexOrTextID]
ld b, a ld b, a
ld hl, wMissableObjectList ld hl, wMissableObjectList
.missableObjectsListLoop .missableObjectsListLoop
@ -15,10 +15,10 @@ PickUpItem:
.isMissable .isMissable
ld a, [hl] ld a, [hl]
ld [hMissableObjectIndex], a ldh [hMissableObjectIndex], a
ld hl, wMapSpriteExtraData ld hl, wMapSpriteExtraData
ld a, [hSpriteIndexOrTextID] ldh a, [hSpriteIndexOrTextID]
dec a dec a
add a add a
ld d, 0 ld d, 0
@ -30,7 +30,7 @@ PickUpItem:
call GiveItem call GiveItem
jr nc, .BagFull jr nc, .BagFull
ld a, [hMissableObjectIndex] ldh a, [hMissableObjectIndex]
ld [wMissableObjectIndex], a ld [wMissableObjectIndex], a
predef HideObject predef HideObject
ld a, 1 ld a, 1

View file

@ -52,7 +52,7 @@ ApplyOutOfBattlePoisonDamage:
ld [wJoyIgnore], a ld [wJoyIgnore], a
call EnableAutoTextBoxDrawing call EnableAutoTextBoxDrawing
ld a, TEXT_MON_FAINTED ld a, TEXT_MON_FAINTED
ld [hSpriteIndexOrTextID], a ldh [hSpriteIndexOrTextID], a
call DisplayTextID call DisplayTextID
pop de pop de
pop hl pop hl
@ -99,7 +99,7 @@ ApplyOutOfBattlePoisonDamage:
jr nz, .noBlackOut jr nz, .noBlackOut
call EnableAutoTextBoxDrawing call EnableAutoTextBoxDrawing
ld a, TEXT_BLACKED_OUT ld a, TEXT_BLACKED_OUT
ld [hSpriteIndexOrTextID], a ldh [hSpriteIndexOrTextID], a
call DisplayTextID call DisplayTextID
ld hl, wd72e ld hl, wd72e
set 5, [hl] set 5, [hl]

View file

@ -3,17 +3,17 @@ DisplayDexRating:
ld b, wPokedexSeenEnd - wPokedexSeen ld b, wPokedexSeenEnd - wPokedexSeen
call CountSetBits call CountSetBits
ld a, [wNumSetBits] ld a, [wNumSetBits]
ld [hDexRatingNumMonsSeen], a ldh [hDexRatingNumMonsSeen], a
ld hl, wPokedexOwned ld hl, wPokedexOwned
ld b, wPokedexOwnedEnd - wPokedexOwned ld b, wPokedexOwnedEnd - wPokedexOwned
call CountSetBits call CountSetBits
ld a, [wNumSetBits] ld a, [wNumSetBits]
ld [hDexRatingNumMonsOwned], a ldh [hDexRatingNumMonsOwned], a
ld hl, DexRatingsTable ld hl, DexRatingsTable
.findRating .findRating
ld a, [hli] ld a, [hli]
ld b, a ld b, a
ld a, [hDexRatingNumMonsOwned] ldh a, [hDexRatingNumMonsOwned]
cp b cp b
jr c, .foundRating jr c, .foundRating
inc hl inc hl
@ -34,10 +34,10 @@ DisplayDexRating:
jp WaitForTextScrollButtonPress jp WaitForTextScrollButtonPress
.hallOfFame .hallOfFame
ld de, wDexRatingNumMonsSeen ld de, wDexRatingNumMonsSeen
ld a, [hDexRatingNumMonsSeen] ldh a, [hDexRatingNumMonsSeen]
ld [de], a ld [de], a
inc de inc de
ld a, [hDexRatingNumMonsOwned] ldh a, [hDexRatingNumMonsOwned]
ld [de], a ld [de], a
inc de inc de
.copyRatingTextLoop .copyRatingTextLoop

View file

@ -77,7 +77,7 @@ DisplayPokemartDialogue_::
jr c, .unsellableItem jr c, .unsellableItem
ld a, PRICEDITEMLISTMENU ld a, PRICEDITEMLISTMENU
ld [wListMenuID], a ld [wListMenuID], a
ld [hHalveItemPrices], a ; halve prices when selling ldh [hHalveItemPrices], a ; halve prices when selling
call DisplayChooseQuantityMenu call DisplayChooseQuantityMenu
inc a inc a
jr z, .sellMenuLoop ; if the player closed the choose quantity menu with the B button jr z, .sellMenuLoop ; if the player closed the choose quantity menu with the B button
@ -152,7 +152,7 @@ DisplayPokemartDialogue_::
ld a, 99 ld a, 99
ld [wMaxItemQuantity], a ld [wMaxItemQuantity], a
xor a xor a
ld [hHalveItemPrices], a ; don't halve item prices when buying ldh [hHalveItemPrices], a ; don't halve item prices when buying
call DisplayChooseQuantityMenu call DisplayChooseQuantityMenu
inc a inc a
jr z, .buyMenuLoop ; if the player closed the choose quantity menu with the B button jr z, .buyMenuLoop ; if the player closed the choose quantity menu with the B button

View file

@ -64,7 +64,7 @@ GetPrizeMenuId:
; display the three prizes' names ; display the three prizes' names
; (distinguishing between Pokemon names ; (distinguishing between Pokemon names
; and Items (specifically TMs) names) ; and Items (specifically TMs) names)
ld a, [hSpriteIndexOrTextID] ldh a, [hSpriteIndexOrTextID]
sub 3 ; prize-texts' id are 3, 4 and 5 sub 3 ; prize-texts' id are 3, 4 and 5
ld [wWhichPrizeWindow], a ; prize-texts' id (relative, i.e. 0, 1 or 2) ld [wWhichPrizeWindow], a ; prize-texts' id (relative, i.e. 0, 1 or 2)
add a add a
@ -177,11 +177,11 @@ LoadCoinsToSubtract:
ld hl, wPrize1Price ld hl, wPrize1Price
add hl, de ; get selected prize's price add hl, de ; get selected prize's price
xor a xor a
ld [hUnusedCoinsByte], a ldh [hUnusedCoinsByte], a
ld a, [hli] ld a, [hli]
ld [hCoins], a ldh [hCoins], a
ld a, [hl] ld a, [hl]
ld [hCoins + 1], a ldh [hCoins + 1], a
ret ret
HandlePrizeChoice: HandlePrizeChoice:

View file

@ -2,7 +2,7 @@ RemoveGuardDrink::
ld hl, GuardDrinksList ld hl, GuardDrinksList
.drinkLoop .drinkLoop
ld a, [hli] ld a, [hli]
ld [hItemToRemoveID], a ldh [hItemToRemoveID], a
and a and a
ret z ret z
push hl push hl

View file

@ -37,17 +37,17 @@ VendingMachineMenu::
cp 3 ; chose Cancel? cp 3 ; chose Cancel?
jr z, .notThirsty jr z, .notThirsty
xor a xor a
ld [hMoney], a ldh [hMoney], a
ld [hMoney + 2], a ldh [hMoney + 2], a
ld a, $2 ld a, $2
ld [hMoney + 1], a ldh [hMoney + 1], a
call HasEnoughMoney call HasEnoughMoney
jr nc, .enoughMoney jr nc, .enoughMoney
ld hl, VendingMachineText4 ld hl, VendingMachineText4
jp PrintText jp PrintText
.enoughMoney .enoughMoney
call LoadVendingMachineItem call LoadVendingMachineItem
ld a, [hVendingMachineItem] ldh a, [hVendingMachineItem]
ld b, a ld b, a
ld c, 1 ld c, 1
call GiveItem call GiveItem
@ -121,13 +121,13 @@ LoadVendingMachineItem:
ld e, a ld e, a
add hl, de add hl, de
ld a, [hli] ld a, [hli]
ld [hVendingMachineItem], a ldh [hVendingMachineItem], a
ld a, [hli] ld a, [hli]
ld [hVendingMachinePrice], a ldh [hVendingMachinePrice], a
ld a, [hli] ld a, [hli]
ld [hVendingMachinePrice + 1], a ldh [hVendingMachinePrice + 1], a
ld a, [hl] ld a, [hl]
ld [hVendingMachinePrice + 2], a ldh [hVendingMachinePrice + 2], a
ret ret
INCLUDE "data/items/vending_prices.asm" INCLUDE "data/items/vending_prices.asm"

View file

@ -21,22 +21,22 @@ GetHPBarLength:
rr e rr e
srl d srl d
rr e rr e
ld a, [hMultiplicand+1] ldh a, [hMultiplicand+1]
ld b, a ld b, a
ld a, [hMultiplicand+2] ldh a, [hMultiplicand+2]
srl b ; divide multiplication result as well srl b ; divide multiplication result as well
rr a rr a
srl b srl b
rr a rr a
ld [hMultiplicand+2], a ldh [hMultiplicand+2], a
ld a, b ld a, b
ld [hMultiplicand+1], a ldh [hMultiplicand+1], a
.maxHPSmaller256 .maxHPSmaller256
ld a, e ld a, e
ld [hDivisor], a ldh [hDivisor], a
ld b, $4 ld b, $4
call Divide call Divide
ld a, [hMultiplicand+2] ldh a, [hMultiplicand+2]
ld e, a ; e = bc * 48 / de (num of pixels of HP bar) ld e, a ; e = bc * 48 / de (num of pixels of HP bar)
pop hl pop hl
and a and a
@ -213,7 +213,7 @@ UpdateHPBar_PrintHPNumber:
ld a, [wHPBarOldHP + 1] ld a, [wHPBarOldHP + 1]
ld [wHPBarTempHP], a ld [wHPBarTempHP], a
push hl push hl
ld a, [hFlagsFFF6] ldh a, [hFlagsFFF6]
bit 0, a bit 0, a
jr z, .asm_fb15 jr z, .asm_fb15
ld de, $9 ld de, $9

View file

@ -169,7 +169,7 @@ WriteMonPartySpriteOAMByPartyIndex:
push hl push hl
push de push de
push bc push bc
ld a, [hPartyMonIndex] ldh a, [hPartyMonIndex]
ld hl, wPartySpecies ld hl, wPartySpecies
ld e, a ld e, a
ld d, 0 ld d, 0
@ -187,7 +187,7 @@ WriteMonPartySpriteOAMBySpecies:
; Write OAM blocks for the party sprite of the species in ; Write OAM blocks for the party sprite of the species in
; [wMonPartySpriteSpecies]. ; [wMonPartySpriteSpecies].
xor a xor a
ld [hPartyMonIndex], a ldh [hPartyMonIndex], a
ld a, [wMonPartySpriteSpecies] ld a, [wMonPartySpriteSpecies]
call GetPartyMonSpriteID call GetPartyMonSpriteID
ld [wOAMBaseTile], a ld [wOAMBaseTile], a
@ -237,7 +237,7 @@ WriteMonPartySpriteOAM:
push af push af
ld c, $10 ld c, $10
ld h, wOAMBuffer / $100 ld h, wOAMBuffer / $100
ld a, [hPartyMonIndex] ldh a, [hPartyMonIndex]
swap a swap a
ld l, a ld l, a
add $10 add $10

View file

@ -15,7 +15,7 @@ WriteDMACodeToHRAM::
DMARoutine: DMARoutine:
; initiate DMA ; initiate DMA
ld a, wOAMBuffer / $100 ld a, wOAMBuffer / $100
ld [rDMA], a ldh [rDMA], a
; wait for DMA to finish ; wait for DMA to finish
ld a, $28 ld a, $28

View file

@ -335,13 +335,13 @@ SendSGBPacket:
push bc push bc
; disable ReadJoypad to prevent it from interfering with sending the packet ; disable ReadJoypad to prevent it from interfering with sending the packet
ld a, 1 ld a, 1
ld [hDisableJoypadPolling], a ldh [hDisableJoypadPolling], a
; send RESET signal (P14=LOW, P15=LOW) ; send RESET signal (P14=LOW, P15=LOW)
xor a xor a
ld [rJOYP], a ldh [rJOYP], a
; set P14=HIGH, P15=HIGH ; set P14=HIGH, P15=HIGH
ld a, $30 ld a, $30
ld [rJOYP], a ldh [rJOYP], a
;load length of packets (16 bytes) ;load length of packets (16 bytes)
ld b, $10 ld b, $10
.nextByte .nextByte
@ -358,10 +358,10 @@ SendSGBPacket:
; else (if 0th bit is zero) set P14=LOW,P15=HIGH (send bit 0) ; else (if 0th bit is zero) set P14=LOW,P15=HIGH (send bit 0)
ld a, $20 ld a, $20
.next0 .next0
ld [rJOYP], a ldh [rJOYP], a
; must set P14=HIGH,P15=HIGH between each "pulse" ; must set P14=HIGH,P15=HIGH between each "pulse"
ld a, $30 ld a, $30
ld [rJOYP], a ldh [rJOYP], a
; rotation will put next bit in 0th position (so we can always use command ; rotation will put next bit in 0th position (so we can always use command
; "bit 0,d" to fetch the bit that has to be sent) ; "bit 0,d" to fetch the bit that has to be sent)
rr d rr d
@ -372,12 +372,12 @@ SendSGBPacket:
jr nz, .nextByte jr nz, .nextByte
; send bit 1 as a "stop bit" (end of parameter data) ; send bit 1 as a "stop bit" (end of parameter data)
ld a, $20 ld a, $20
ld [rJOYP], a ldh [rJOYP], a
; set P14=HIGH,P15=HIGH ; set P14=HIGH,P15=HIGH
ld a, $30 ld a, $30
ld [rJOYP], a ldh [rJOYP], a
xor a xor a
ld [hDisableJoypadPolling], a ldh [hDisableJoypadPolling], a
; wait for about 70000 cycles ; wait for about 70000 cycles
call Wait7000 call Wait7000
; restore (previously pushed) number of packets ; restore (previously pushed) number of packets
@ -457,41 +457,41 @@ CheckSGB:
di di
call SendSGBPacket call SendSGBPacket
ld a, 1 ld a, 1
ld [hDisableJoypadPolling], a ldh [hDisableJoypadPolling], a
ei ei
call Wait7000 call Wait7000
ld a, [rJOYP] ldh a, [rJOYP]
and $3 and $3
cp $3 cp $3
jr nz, .isSGB jr nz, .isSGB
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 Wait7000 call Wait7000
call Wait7000 call Wait7000
ld a, $30 ld a, $30
ld [rJOYP], a ldh [rJOYP], a
call Wait7000 call Wait7000
call Wait7000 call Wait7000
ld a, $10 ld a, $10
ld [rJOYP], a ldh [rJOYP], a
ld a, [rJOYP] ldh a, [rJOYP]
ld a, [rJOYP] ldh a, [rJOYP]
ld a, [rJOYP] ldh a, [rJOYP]
ld a, [rJOYP] ldh a, [rJOYP]
ld a, [rJOYP] ldh a, [rJOYP]
ld a, [rJOYP] ldh a, [rJOYP]
call Wait7000 call Wait7000
call Wait7000 call Wait7000
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 Wait7000 call Wait7000
call Wait7000 call Wait7000
ld a, [rJOYP] ldh a, [rJOYP]
and $3 and $3
cp $3 cp $3
jr nz, .isSGB jr nz, .isSGB
@ -513,7 +513,7 @@ CopyGfxToSuperNintendoVRAM:
push de push de
call DisableLCD call DisableLCD
ld a, $e4 ld a, $e4
ld [rBGP], a ldh [rBGP], a
ld de, vChars1 ld de, vChars1
ld a, [wCopyingSGBTileData] ld a, [wCopyingSGBTileData]
and a and a
@ -539,11 +539,11 @@ CopyGfxToSuperNintendoVRAM:
dec c dec c
jr nz, .loop jr nz, .loop
ld a, $e3 ld a, $e3
ld [rLCDC], a ldh [rLCDC], a
pop hl pop hl
call SendSGBPacket call SendSGBPacket
xor a xor a
ld [rBGP], a ldh [rBGP], a
ei ei
ret ret
@ -577,7 +577,7 @@ SendSGBPackets:
InitGBCPalettes: InitGBCPalettes:
ld a, $80 ; index 0 with auto-increment ld a, $80 ; index 0 with auto-increment
ld [rBGPI], a ldh [rBGPI], a
inc hl inc hl
ld c, $20 ld c, $20
.loop .loop
@ -592,7 +592,7 @@ InitGBCPalettes:
inc d inc d
.noCarry .noCarry
ld a, [de] ld a, [de]
ld [rBGPD], a ldh [rBGPD], a
dec c dec c
jr nz, .loop jr nz, .loop
ret ret

View file

@ -1,14 +1,14 @@
; b = new colour for BG colour 0 (usually white) for 4 frames ; b = new colour for BG colour 0 (usually white) for 4 frames
ChangeBGPalColor0_4Frames: ChangeBGPalColor0_4Frames:
call GetPredefRegisters call GetPredefRegisters
ld a, [rBGP] ldh a, [rBGP]
or b or b
ld [rBGP], a ldh [rBGP], a
ld c, 4 ld c, 4
call DelayFrames call DelayFrames
ld a, [rBGP] ldh a, [rBGP]
and %11111100 and %11111100
ld [rBGP], a ldh [rBGP], a
ret ret
PredefShakeScreenVertically: PredefShakeScreenVertically:
@ -19,7 +19,7 @@ PredefShakeScreenVertically:
ld [wDisableVBlankWYUpdate], a ld [wDisableVBlankWYUpdate], a
xor a xor a
.loop .loop
ld [hMutateWY], a ldh [hMutateWY], a
call .MutateWY call .MutateWY
call .MutateWY call .MutateWY
dec b dec b
@ -30,10 +30,10 @@ PredefShakeScreenVertically:
ret ret
.MutateWY .MutateWY
ld a, [hMutateWY] ldh a, [hMutateWY]
xor b xor b
ld [hMutateWY], a ldh [hMutateWY], a
ld [rWY], a ldh [rWY], a
ld c, 3 ld c, 3
jp DelayFrames jp DelayFrames
@ -43,7 +43,7 @@ PredefShakeScreenHorizontally:
call GetPredefRegisters call GetPredefRegisters
xor a xor a
.loop .loop
ld [hMutateWX], a ldh [hMutateWX], a
call .MutateWX call .MutateWX
ld c, 1 ld c, 1
call DelayFrames call DelayFrames
@ -54,18 +54,18 @@ PredefShakeScreenHorizontally:
; restore normal WX ; restore normal WX
ld a, 7 ld a, 7
ld [rWX], a ldh [rWX], a
ret ret
.MutateWX .MutateWX
ld a, [hMutateWX] ldh a, [hMutateWX]
xor b xor b
ld [hMutateWX], a ldh [hMutateWX], a
bit 7, a bit 7, a
jr z, .skipZeroing jr z, .skipZeroing
xor a ; zero a if it's negative xor a ; zero a if it's negative
.skipZeroing .skipZeroing
add 7 add 7
ld [rWX], a ldh [rWX], a
ld c, 4 ld c, 4
jp DelayFrames jp DelayFrames

View file

@ -13,13 +13,13 @@ PrepareOAMData::
.updateEnabled .updateEnabled
xor a xor a
ld [hOAMBufferOffset], a ldh [hOAMBufferOffset], a
.spriteLoop .spriteLoop
ld [hSpriteOffset2], a ldh [hSpriteOffset2], a
ld d, wSpriteStateData1 / $100 ld d, wSpriteStateData1 / $100
ld a, [hSpriteOffset2] ldh a, [hSpriteOffset2]
ld e, a ld e, a
ld a, [de] ; c1x0 ld a, [de] ; c1x0
and a and a
@ -58,7 +58,7 @@ PrepareOAMData::
ld e, a ld e, a
ld a, [de] ; c2x7 ld a, [de] ; c2x7
and $80 and $80
ld [hSpritePriority], a ; temp store sprite priority ldh [hSpritePriority], a ; temp store sprite priority
pop de pop de
; read the entry from the table ; read the entry from the table
@ -77,17 +77,17 @@ PrepareOAMData::
call GetSpriteScreenXY call GetSpriteScreenXY
ld a, [hOAMBufferOffset] ldh a, [hOAMBufferOffset]
ld e, a ld e, a
ld d, wOAMBuffer / $100 ld d, wOAMBuffer / $100
.tileLoop .tileLoop
ld a, [hSpriteScreenY] ; temp for sprite Y position ldh a, [hSpriteScreenY] ; temp for sprite Y position
add $10 ; Y=16 is top of screen (Y=0 is invisible) add $10 ; Y=16 is top of screen (Y=0 is invisible)
add [hl] ; add Y offset from table add [hl] ; add Y offset from table
ld [de], a ; write new sprite OAM Y position ld [de], a ; write new sprite OAM Y position
inc hl inc hl
ld a, [hSpriteScreenX] ; temp for sprite X position ldh a, [hSpriteScreenX] ; temp for sprite X position
add $8 ; X=8 is left of screen (X=0 is invisible) add $8 ; X=8 is left of screen (X=0 is invisible)
add [hl] ; add X offset from table add [hl] ; add X offset from table
inc e inc e
@ -126,7 +126,7 @@ PrepareOAMData::
ld a, [hl] ld a, [hl]
bit 1, a ; is the tile allowed to set the sprite priority bit? bit 1, a ; is the tile allowed to set the sprite priority bit?
jr z, .skipPriority jr z, .skipPriority
ld a, [hSpritePriority] ldh a, [hSpritePriority]
or [hl] or [hl]
.skipPriority .skipPriority
inc hl inc hl
@ -136,16 +136,16 @@ PrepareOAMData::
jr z, .tileLoop jr z, .tileLoop
ld a, e ld a, e
ld [hOAMBufferOffset], a ldh [hOAMBufferOffset], a
.nextSprite .nextSprite
ld a, [hSpriteOffset2] ldh a, [hSpriteOffset2]
add $10 add $10
cp $100 % $100 cp $100 % $100
jp nz, .spriteLoop jp nz, .spriteLoop
; Clear unused OAM. ; Clear unused OAM.
ld a, [hOAMBufferOffset] ldh a, [hOAMBufferOffset]
ld l, a ld l, a
ld h, wOAMBuffer / $100 ld h, wOAMBuffer / $100
ld de, $4 ld de, $4
@ -170,20 +170,20 @@ GetSpriteScreenXY:
inc e inc e
inc e inc e
ld a, [de] ; c1x4 ld a, [de] ; c1x4
ld [hSpriteScreenY], a ldh [hSpriteScreenY], a
inc e inc e
inc e inc e
ld a, [de] ; c1x6 ld a, [de] ; c1x6
ld [hSpriteScreenX], a ldh [hSpriteScreenX], a
ld a, 4 ld a, 4
add e add e
ld e, a ld e, a
ld a, [hSpriteScreenY] ldh a, [hSpriteScreenY]
add 4 add 4
and $f0 and $f0
ld [de], a ; c1xa (y) ld [de], a ; c1xa (y)
inc e inc e
ld a, [hSpriteScreenX] ldh a, [hSpriteScreenX]
and $f0 and $f0
ld [de], a ; c1xb (x) ld [de], a ; c1xb (x)
ret ret

View file

@ -239,14 +239,14 @@ ItemUseBall:
; Calculate MaxHP * 255. ; Calculate MaxHP * 255.
xor a xor a
ld [hMultiplicand], a ldh [hMultiplicand], a
ld hl, wEnemyMonMaxHP ld hl, wEnemyMonMaxHP
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
ld a, 255 ld a, 255
ld [hMultiplier], a ldh [hMultiplier], a
call Multiply call Multiply
; Determine BallFactor. It's 8 for Great Balls and 12 for the others. ; Determine BallFactor. It's 8 for Great Balls and 12 for the others.
@ -260,7 +260,7 @@ ItemUseBall:
; Note that the results of all division operations are floored. ; Note that the results of all division operations are floored.
; Calculate (MaxHP * 255) / BallFactor. ; Calculate (MaxHP * 255) / BallFactor.
ld [hDivisor], a ldh [hDivisor], a
ld b, 4 ; number of bytes in dividend ld b, 4 ; number of bytes in dividend
call Divide call Divide
@ -281,17 +281,17 @@ ItemUseBall:
.skip2 .skip2
; Let W = ((MaxHP * 255) / BallFactor) / max(HP / 4, 1). Calculate W. ; Let W = ((MaxHP * 255) / BallFactor) / max(HP / 4, 1). Calculate W.
ld [hDivisor], a ldh [hDivisor], a
ld b, 4 ld b, 4
call Divide call Divide
; If W > 255, store 255 in [hQuotient + 3]. ; If W > 255, store 255 in [hQuotient + 3].
; Let X = min(W, 255) = [hQuotient + 3]. ; Let X = min(W, 255) = [hQuotient + 3].
ld a, [hQuotient + 2] ldh a, [hQuotient + 2]
and a and a
jr z, .skip3 jr z, .skip3
ld a, 255 ld a, 255
ld [hQuotient + 3], a ldh [hQuotient + 3], a
.skip3 .skip3
pop bc ; b = Rand1 - Status pop bc ; b = Rand1 - Status
@ -302,7 +302,7 @@ ItemUseBall:
jr c, .failedToCapture jr c, .failedToCapture
; If W > 255, the ball captures the Pokémon. ; If W > 255, the ball captures the Pokémon.
ld a, [hQuotient + 2] ldh a, [hQuotient + 2]
and a and a
jr nz, .captured jr nz, .captured
@ -310,7 +310,7 @@ ItemUseBall:
; If Rand2 > X, the ball fails to capture the Pokémon. ; If Rand2 > X, the ball fails to capture the Pokémon.
ld b, a ld b, a
ld a, [hQuotient + 3] ldh a, [hQuotient + 3]
cp b cp b
jr c, .failedToCapture jr c, .failedToCapture
@ -318,17 +318,17 @@ ItemUseBall:
jr .skipShakeCalculations jr .skipShakeCalculations
.failedToCapture .failedToCapture
ld a, [hQuotient + 3] ldh a, [hQuotient + 3]
ld [wPokeBallCaptureCalcTemp], a ; Save X. ld [wPokeBallCaptureCalcTemp], a ; Save X.
; Calculate CatchRate * 100. ; Calculate CatchRate * 100.
xor a xor a
ld [hMultiplicand], a ldh [hMultiplicand], a
ld [hMultiplicand + 1], a ldh [hMultiplicand + 1], a
ld a, [wEnemyMonActualCatchRate] ld a, [wEnemyMonActualCatchRate]
ld [hMultiplicand + 2], a ldh [hMultiplicand + 2], a
ld a, 100 ld a, 100
ld [hMultiplier], a ldh [hMultiplier], a
call Multiply call Multiply
; Determine BallFactor2. ; Determine BallFactor2.
@ -349,26 +349,26 @@ ItemUseBall:
.skip4 .skip4
; Let Y = (CatchRate * 100) / BallFactor2. Calculate Y. ; Let Y = (CatchRate * 100) / BallFactor2. Calculate Y.
ld a, b ld a, b
ld [hDivisor], a ldh [hDivisor], a
ld b, 4 ld b, 4
call Divide call Divide
; If Y > 255, there are 3 shakes. ; If Y > 255, there are 3 shakes.
; Note that this shouldn't be possible. ; Note that this shouldn't be possible.
; The maximum value of Y is (255 * 100) / 150 = 170. ; The maximum value of Y is (255 * 100) / 150 = 170.
ld a, [hQuotient + 2] ldh a, [hQuotient + 2]
and a and a
ld b, $63 ; 3 shakes ld b, $63 ; 3 shakes
jr nz, .setAnimData jr nz, .setAnimData
; Calculate X * Y. ; Calculate X * Y.
ld a, [wPokeBallCaptureCalcTemp] ld a, [wPokeBallCaptureCalcTemp]
ld [hMultiplier], a ldh [hMultiplier], a
call Multiply call Multiply
; Calculate (X * Y) / 255. ; Calculate (X * Y) / 255.
ld a, 255 ld a, 255
ld [hDivisor], a ldh [hDivisor], a
ld b, 4 ld b, 4
call Divide call Divide
@ -386,9 +386,9 @@ ItemUseBall:
.addAilmentValue .addAilmentValue
; If the Pokémon has a status ailment, add Status2. ; If the Pokémon has a status ailment, add Status2.
ld a, [hQuotient + 3] ldh a, [hQuotient + 3]
add b add b
ld [hQuotient + 3], a ldh [hQuotient + 3], a
.skip5 .skip5
; Finally determine the number of shakes. ; Finally determine the number of shakes.
@ -398,7 +398,7 @@ ItemUseBall:
; 10 ≤ Z < 30: 1 shake ; 10 ≤ Z < 30: 1 shake
; 30 ≤ Z < 70: 2 shakes ; 30 ≤ Z < 70: 2 shakes
; 70 ≤ Z: 3 shakes ; 70 ≤ Z: 3 shakes
ld a, [hQuotient + 3] ldh a, [hQuotient + 3]
cp 10 cp 10
ld b, $20 ld b, $20
jr c, .setAnimData jr c, .setAnimData
@ -422,7 +422,7 @@ ItemUseBall:
ld a, TOSS_ANIM ld a, TOSS_ANIM
ld [wAnimationID], a ld [wAnimationID], a
xor a xor a
ld [hWhoseTurn], a ldh [hWhoseTurn], a
ld [wAnimationType], a ld [wAnimationType], a
ld [wDamageMultipliers], a ld [wDamageMultipliers], a
ld a, [wWhichPokemon] ld a, [wWhichPokemon]
@ -656,7 +656,7 @@ ItemUseBicycle:
jp nc, NoCyclingAllowedHere jp nc, NoCyclingAllowedHere
call ItemUseReloadOverworldData call ItemUseReloadOverworldData
xor a ; no keys pressed xor a ; no keys pressed
ld [hJoyHeld], a ; current joypad state ldh [hJoyHeld], a ; current joypad state
inc a inc a
ld [wWalkBikeSurfState], a ; change player state to bicycling ld [wWalkBikeSurfState], a ; change player state to bicycling
ld hl, GotOnBicycleText ld hl, GotOnBicycleText
@ -687,11 +687,11 @@ ItemUseSurfboard:
jp PrintText jp PrintText
.tryToStopSurfing .tryToStopSurfing
xor a xor a
ld [hSpriteIndexOrTextID], a ldh [hSpriteIndexOrTextID], a
ld d, 16 ; talking range in pixels (normal range) ld d, 16 ; talking range in pixels (normal range)
call IsSpriteInFrontOfPlayer2 call IsSpriteInFrontOfPlayer2
res 7, [hl] res 7, [hl]
ld a, [hSpriteIndexOrTextID] ldh a, [hSpriteIndexOrTextID]
and a ; is there a sprite in the way? and a ; is there a sprite in the way?
jr nz, .cannotStopSurfing jr nz, .cannotStopSurfing
ld hl, TilePairCollisionsWater ld hl, TilePairCollisionsWater
@ -1018,18 +1018,18 @@ ItemUseMedicine:
call AddNTimes call AddNTimes
ld a, [hli] ld a, [hli]
ld [wHPBarMaxHP + 1], a ld [wHPBarMaxHP + 1], a
ld [hDividend], a ldh [hDividend], a
ld a, [hl] ld a, [hl]
ld [wHPBarMaxHP], a ld [wHPBarMaxHP], a
ld [hDividend + 1], a ldh [hDividend + 1], a
ld a, 5 ld a, 5
ld [hDivisor], a ldh [hDivisor], a
ld b, 2 ; number of bytes ld b, 2 ; number of bytes
call Divide ; get 1/5 of max HP of pokemon that used Softboiled call Divide ; get 1/5 of max HP of pokemon that used Softboiled
ld bc, (wPartyMon1HP + 1) - (wPartyMon1MaxHP + 1) ld bc, (wPartyMon1HP + 1) - (wPartyMon1MaxHP + 1)
add hl, bc ; hl now points to LSB of current HP of pokemon that used Softboiled add hl, bc ; hl now points to LSB of current HP of pokemon that used Softboiled
; subtract 1/5 of max HP from current HP of pokemon that used Softboiled ; subtract 1/5 of max HP from current HP of pokemon that used Softboiled
ld a, [hQuotient + 3] ldh a, [hQuotient + 3]
push af push af
ld b, a ld b, a
ld a, [hl] ld a, [hl]
@ -1037,7 +1037,7 @@ ItemUseMedicine:
sub b sub b
ld [hld], a ld [hld], a
ld [wHPBarNewHP], a ld [wHPBarNewHP], a
ld a, [hQuotient + 2] ldh a, [hQuotient + 2]
ld b, a ld b, a
ld a, [hl] ld a, [hl]
ld [wHPBarOldHP+1], a ld [wHPBarOldHP+1], a
@ -1050,15 +1050,15 @@ ItemUseMedicine:
call AddNTimes ; calculate coordinates of HP bar of pokemon that used Softboiled call AddNTimes ; calculate coordinates of HP bar of pokemon that used Softboiled
ld a, SFX_HEAL_HP ld a, SFX_HEAL_HP
call PlaySoundWaitForCurrent call PlaySoundWaitForCurrent
ld a, [hFlagsFFF6] ldh a, [hFlagsFFF6]
set 0, a set 0, a
ld [hFlagsFFF6], a ldh [hFlagsFFF6], a
ld a, $02 ld a, $02
ld [wHPBarType], a ld [wHPBarType], a
predef UpdateHPBar2 ; animate HP bar decrease of pokemon that used Softboiled predef UpdateHPBar2 ; animate HP bar decrease of pokemon that used Softboiled
ld a, [hFlagsFFF6] ldh a, [hFlagsFFF6]
res 0, a res 0, a
ld [hFlagsFFF6], a ldh [hFlagsFFF6], a
pop af pop af
ld b, a ; store heal amount (1/5 of max HP) ld b, a ; store heal amount (1/5 of max HP)
ld hl, wHPBarOldHP + 1 ld hl, wHPBarOldHP + 1
@ -1200,15 +1200,15 @@ ItemUseMedicine:
jr z, .playStatusAilmentCuringSound jr z, .playStatusAilmentCuringSound
ld a, SFX_HEAL_HP ld a, SFX_HEAL_HP
call PlaySoundWaitForCurrent call PlaySoundWaitForCurrent
ld a, [hFlagsFFF6] ldh a, [hFlagsFFF6]
set 0, a set 0, a
ld [hFlagsFFF6], a ldh [hFlagsFFF6], a
ld a, $02 ld a, $02
ld [wHPBarType], a ld [wHPBarType], a
predef UpdateHPBar2 ; animate the HP bar lengthening predef UpdateHPBar2 ; animate the HP bar lengthening
ld a, [hFlagsFFF6] ldh a, [hFlagsFFF6]
res 0, a res 0, a
ld [hFlagsFFF6], a ldh [hFlagsFFF6], a
ld a, REVIVE_MSG ld a, REVIVE_MSG
ld [wPartyMenuTypeOrMessageID], a ld [wPartyMenuTypeOrMessageID], a
ld a, [wcf91] ld a, [wcf91]
@ -1224,13 +1224,13 @@ ItemUseMedicine:
call PlaySoundWaitForCurrent call PlaySoundWaitForCurrent
.showHealingItemMessage .showHealingItemMessage
xor a xor a
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
call ClearScreen call ClearScreen
dec a dec a
ld [wUpdateSpritesEnabled], a ld [wUpdateSpritesEnabled], a
call RedrawPartyMenu ; redraws the party menu and displays the message call RedrawPartyMenu ; redraws the party menu and displays the message
ld a, 1 ld a, 1
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
ld c, 50 ld c, 50
call DelayFrames call DelayFrames
call WaitForTextScrollButtonPress call WaitForTextScrollButtonPress
@ -1347,11 +1347,11 @@ ItemUseMedicine:
ld bc, wPartyMon1Exp - wPartyMon1Level ld bc, wPartyMon1Exp - wPartyMon1Level
add hl, bc ; hl now points to MSB of experience add hl, bc ; hl now points to MSB of experience
; update experience to minimum for new level ; update experience to minimum for new level
ld a, [hExperience] ldh a, [hExperience]
ld [hli], a ld [hli], a
ld a, [hExperience + 1] ldh a, [hExperience + 1]
ld [hli], a ld [hli], a
ld a, [hExperience + 2] ldh a, [hExperience + 2]
ld [hl], a ld [hl], a
pop hl pop hl
ld a, [wWhichPokemon] ld a, [wWhichPokemon]
@ -1459,7 +1459,7 @@ BaitRockCommon:
ld [wAnimationID], a ld [wAnimationID], a
xor a xor a
ld [wAnimationType], a ld [wAnimationType], a
ld [hWhoseTurn], a ldh [hWhoseTurn], a
ld [de], a ; zero escape factor (for bait), zero bait factor (for rock) ld [de], a ; zero escape factor (for bait), zero bait factor (for rock)
.randomLoop ; loop until a random number less than 5 is generated .randomLoop ; loop until a random number less than 5 is generated
call Random call Random
@ -1698,7 +1698,7 @@ ItemUseXStat:
call LoadScreenTilesFromBuffer1 ; restore saved screen call LoadScreenTilesFromBuffer1 ; restore saved screen
call Delay3 call Delay3
xor a xor a
ld [hWhoseTurn], a ; set turn to player's turn ldh [hWhoseTurn], a ; set turn to player's turn
callba StatModifierUpEffect ; do stat increase move callba StatModifierUpEffect ; do stat increase move
pop hl pop hl
pop af pop af
@ -2463,13 +2463,13 @@ RestoreBonusPP:
AddBonusPP: AddBonusPP:
push bc push bc
ld a, [de] ; normal max PP of move ld a, [de] ; normal max PP of move
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, 5 ld a, 5
ld [hDivisor], a ldh [hDivisor], a
ld b, 4 ld b, 4
call Divide call Divide
ld a, [hl] ; move PP ld a, [hl] ; move PP
@ -2480,7 +2480,7 @@ AddBonusPP:
srl a srl a
ld c, a ; c = number of PP Ups used ld c, a ; c = number of PP Ups used
.loop .loop
ld a, [hQuotient + 3] ldh a, [hQuotient + 3]
cp 8 ; is the amount greater than or equal to 8? cp 8 ; is the amount greater than or equal to 8?
jr c, .addAmount jr c, .addAmount
ld a, 7 ; cap the amount at 7 ld a, 7 ; cap the amount at 7
@ -2822,13 +2822,13 @@ SendNewMonToBox:
ld d, a ld d, a
callab CalcExperience callab CalcExperience
pop de pop de
ld a, [hExperience] ldh a, [hExperience]
ld [de], a ld [de], a
inc de inc de
ld a, [hExperience + 1] ldh a, [hExperience + 1]
ld [de], a ld [de], a
inc de inc de
ld a, [hExperience + 2] ldh a, [hExperience + 2]
ld [de], a ld [de], a
inc de inc de
xor a xor a

View file

@ -16,10 +16,10 @@ GetMachinePrice::
swap a swap a
.highNybbleIsPrice .highNybbleIsPrice
and $f0 and $f0
ld [hItemPrice + 1], a ldh [hItemPrice + 1], a
xor a xor a
ld [hItemPrice], a ldh [hItemPrice], a
ld [hItemPrice + 2], a ldh [hItemPrice + 2], a
ret ret
INCLUDE "data/items/tm_prices.asm" INCLUDE "data/items/tm_prices.asm"

View file

@ -6,7 +6,7 @@ DisplayTownMap:
ld [hl], $ff ld [hl], $ff
push hl push hl
ld a, $1 ld a, $1
ld [hJoy7], a ldh [hJoy7], a
ld a, [wCurMap] ld a, [wCurMap]
push af push af
ld b, $0 ld b, $0
@ -65,7 +65,7 @@ DisplayTownMap:
.inputLoop .inputLoop
call TownMapSpriteBlinkingAnimation call TownMapSpriteBlinkingAnimation
call JoypadLowSensitivity call JoypadLowSensitivity
ld a, [hJoy5] ldh a, [hJoy5]
ld b, a ld b, a
and A_BUTTON | B_BUTTON | D_UP | D_DOWN and A_BUTTON | B_BUTTON | D_UP | D_DOWN
jr z, .inputLoop jr z, .inputLoop
@ -77,7 +77,7 @@ DisplayTownMap:
jr nz, .pressedDown jr nz, .pressedDown
xor a xor a
ld [wTownMapSpriteBlinkingEnabled], a ld [wTownMapSpriteBlinkingEnabled], a
ld [hJoy7], a ldh [hJoy7], a
ld [wAnimCounter], a ld [wAnimCounter], a
call ExitTownMap call ExitTownMap
pop hl pop hl
@ -187,7 +187,7 @@ LoadTownMap_Fly::
push hl push hl
call DelayFrame call DelayFrame
call JoypadLowSensitivity call JoypadLowSensitivity
ld a, [hJoy5] ldh a, [hJoy5]
ld b, a ld b, a
pop hl pop hl
and A_BUTTON | B_BUTTON | D_UP | D_DOWN and A_BUTTON | B_BUTTON | D_UP | D_DOWN

View file

@ -2,29 +2,29 @@ _Joypad::
; hJoyReleased: (hJoyLast ^ hJoyInput) & hJoyLast ; hJoyReleased: (hJoyLast ^ hJoyInput) & hJoyLast
; hJoyPressed: (hJoyLast ^ hJoyInput) & hJoyInput ; hJoyPressed: (hJoyLast ^ hJoyInput) & hJoyInput
ld a, [hJoyInput] ldh a, [hJoyInput]
cp A_BUTTON + B_BUTTON + SELECT + START ; soft reset cp A_BUTTON + B_BUTTON + SELECT + START ; soft reset
jp z, TrySoftReset jp z, TrySoftReset
ld b, a ld b, a
ld a, [hJoyLast] ldh a, [hJoyLast]
ld e, a ld e, a
xor b xor b
ld d, a ld d, a
and e and e
ld [hJoyReleased], a ldh [hJoyReleased], a
ld a, d ld a, d
and b and b
ld [hJoyPressed], a ldh [hJoyPressed], a
ld a, b ld a, b
ld [hJoyLast], a ldh [hJoyLast], a
ld a, [wd730] ld a, [wd730]
bit 5, a bit 5, a
jr nz, DiscardButtonPresses jr nz, DiscardButtonPresses
ld a, [hJoyLast] ldh a, [hJoyLast]
ld [hJoyHeld], a ldh [hJoyHeld], a
ld a, [wJoyIgnore] ld a, [wJoyIgnore]
and a and a
@ -32,19 +32,19 @@ _Joypad::
cpl cpl
ld b, a ld b, a
ld a, [hJoyHeld] ldh a, [hJoyHeld]
and b and b
ld [hJoyHeld], a ldh [hJoyHeld], a
ld a, [hJoyPressed] ldh a, [hJoyPressed]
and b and b
ld [hJoyPressed], a ldh [hJoyPressed], a
ret ret
DiscardButtonPresses: DiscardButtonPresses:
xor a xor a
ld [hJoyHeld], a ldh [hJoyHeld], a
ld [hJoyPressed], a ldh [hJoyPressed], a
ld [hJoyReleased], a ldh [hJoyReleased], a
ret ret
TrySoftReset: TrySoftReset:
@ -52,7 +52,7 @@ TrySoftReset:
; deselect (redundant) ; deselect (redundant)
ld a, $30 ld a, $30
ld [rJOYP], a ldh [rJOYP], a
ld hl, hSoftReset ld hl, hSoftReset
dec [hl] dec [hl]

View file

@ -102,25 +102,25 @@ CableClub_DoBattleOrTradeAgain:
ld a, SERIAL_PATCH_LIST_PART_TERMINATOR ld a, SERIAL_PATCH_LIST_PART_TERMINATOR
ld [de], a ; end of part 2 ld [de], a ; end of part 2
call Serial_SyncAndExchangeNybble call Serial_SyncAndExchangeNybble
ld a, [hSerialConnectionStatus] ldh a, [hSerialConnectionStatus]
cp USING_INTERNAL_CLOCK cp USING_INTERNAL_CLOCK
jr nz, .skipSendingTwoZeroBytes jr nz, .skipSendingTwoZeroBytes
; if using internal clock ; if using internal clock
; send two zero bytes for syncing purposes? ; send two zero bytes for syncing purposes?
call Delay3 call Delay3
xor a xor a
ld [hSerialSendData], a ldh [hSerialSendData], a
ld a, START_TRANSFER_INTERNAL_CLOCK ld a, START_TRANSFER_INTERNAL_CLOCK
ld [rSC], a ldh [rSC], a
call DelayFrame call DelayFrame
xor a xor a
ld [hSerialSendData], a ldh [hSerialSendData], a
ld a, START_TRANSFER_INTERNAL_CLOCK ld a, START_TRANSFER_INTERNAL_CLOCK
ld [rSC], a ldh [rSC], a
.skipSendingTwoZeroBytes .skipSendingTwoZeroBytes
call Delay3 call Delay3
ld a, (1 << SERIAL) ld a, (1 << SERIAL)
ld [rIE], a ldh [rIE], a
ld hl, wSerialRandomNumberListBlock ld hl, wSerialRandomNumberListBlock
ld de, wSerialOtherGameboyRandomNumberListBlock ld de, wSerialOtherGameboyRandomNumberListBlock
ld bc, $11 ld bc, $11
@ -138,10 +138,10 @@ CableClub_DoBattleOrTradeAgain:
ld bc, $c8 ld bc, $c8
call Serial_ExchangeBytes call Serial_ExchangeBytes
ld a, (1 << SERIAL) | (1 << TIMER) | (1 << VBLANK) ld a, (1 << SERIAL) | (1 << TIMER) | (1 << VBLANK)
ld [rIE], a ldh [rIE], a
ld a, SFX_STOP_ALL_MUSIC ld a, SFX_STOP_ALL_MUSIC
call PlaySound call PlaySound
ld a, [hSerialConnectionStatus] ldh a, [hSerialConnectionStatus]
cp USING_INTERNAL_CLOCK cp USING_INTERNAL_CLOCK
jr z, .skipCopyingRandomNumberList ; the list generated by the gameboy clocking the connection is used by both gameboys jr z, .skipCopyingRandomNumberList ; the list generated by the gameboy clocking the connection is used by both gameboys
ld hl, wSerialOtherGameboyRandomNumberListBlock ld hl, wSerialOtherGameboyRandomNumberListBlock
@ -263,7 +263,7 @@ CableClub_DoBattleOrTradeAgain:
ld [wTradeCenterPointerTableIndex], a ld [wTradeCenterPointerTableIndex], a
ld a, SFX_STOP_ALL_MUSIC ld a, SFX_STOP_ALL_MUSIC
call PlaySound call PlaySound
ld a, [hSerialConnectionStatus] ldh a, [hSerialConnectionStatus]
cp USING_INTERNAL_CLOCK cp USING_INTERNAL_CLOCK
ld c, 66 ld c, 66
call z, DelayFrames ; delay if using internal clock call z, DelayFrames ; delay if using internal clock
@ -551,7 +551,7 @@ TradeCenter_SelectMon:
Coorda 1, 16 Coorda 1, 16
.cancelMenuItem_JoypadLoop .cancelMenuItem_JoypadLoop
call JoypadLowSensitivity call JoypadLowSensitivity
ld a, [hJoy5] ldh a, [hJoy5]
and a ; pressed anything? and a ; pressed anything?
jr z, .cancelMenuItem_JoypadLoop jr z, .cancelMenuItem_JoypadLoop
bit 0, a ; A button pressed? bit 0, a ; A button pressed?
@ -663,7 +663,7 @@ TradeCenter_PrintPartyListNames:
push de push de
push hl push hl
ld a, c ld a, c
ld [hPastLeadingZeros], a ldh [hPastLeadingZeros], a
call GetMonName call GetMonName
pop hl pop hl
call PlaceString call PlaceString
@ -837,7 +837,7 @@ TradeCenter_Trade:
call LoadHpBarAndStatusTilePatterns call LoadHpBarAndStatusTilePatterns
xor a xor a
ld [wUnusedCC5B], a ld [wUnusedCC5B], a
ld a, [hSerialConnectionStatus] ldh a, [hSerialConnectionStatus]
cp USING_EXTERNAL_CLOCK cp USING_EXTERNAL_CLOCK
jr z, .usingExternalClock jr z, .usingExternalClock
predef InternalClockTradeAnim predef InternalClockTradeAnim
@ -914,7 +914,7 @@ CableClub_Run:
ld [wGrassRate], a ld [wGrassRate], a
inc a ; LINK_STATE_IN_CABLE_CLUB inc a ; LINK_STATE_IN_CABLE_CLUB
ld [wLinkState], a ld [wLinkState], a
ld [hJoy5], a ldh [hJoy5], a
ld a, 10 ld a, 10
ld [wAudioFadeOutControl], a ld [wAudioFadeOutControl], a
ld a, BANK(Music_Celadon) ld a, BANK(Music_Celadon)

View file

@ -15,27 +15,27 @@ CableClubNPC::
ld a, 90 ld a, 90
ld [wLinkTimeoutCounter], a ld [wLinkTimeoutCounter], a
.establishConnectionLoop .establishConnectionLoop
ld a, [hSerialConnectionStatus] ldh a, [hSerialConnectionStatus]
cp USING_INTERNAL_CLOCK cp USING_INTERNAL_CLOCK
jr z, .establishedConnection jr z, .establishedConnection
cp USING_EXTERNAL_CLOCK cp USING_EXTERNAL_CLOCK
jr z, .establishedConnection jr z, .establishedConnection
ld a, CONNECTION_NOT_ESTABLISHED ld a, CONNECTION_NOT_ESTABLISHED
ld [hSerialConnectionStatus], a ldh [hSerialConnectionStatus], a
ld a, ESTABLISH_CONNECTION_WITH_EXTERNAL_CLOCK ld a, ESTABLISH_CONNECTION_WITH_EXTERNAL_CLOCK
ld [rSB], a ldh [rSB], a
xor a xor a
ld [hSerialReceiveData], a ldh [hSerialReceiveData], a
ld a, START_TRANSFER_EXTERNAL_CLOCK ld a, START_TRANSFER_EXTERNAL_CLOCK
ld [rSC], a ldh [rSC], a
ld a, [wLinkTimeoutCounter] ld a, [wLinkTimeoutCounter]
dec a dec a
ld [wLinkTimeoutCounter], a ld [wLinkTimeoutCounter], a
jr z, .failedToEstablishConnection jr z, .failedToEstablishConnection
ld a, ESTABLISH_CONNECTION_WITH_INTERNAL_CLOCK ld a, ESTABLISH_CONNECTION_WITH_INTERNAL_CLOCK
ld [rSB], a ldh [rSB], a
ld a, START_TRANSFER_INTERNAL_CLOCK ld a, START_TRANSFER_INTERNAL_CLOCK
ld [rSC], a ldh [rSC], a
call DelayFrame call DelayFrame
jr .establishConnectionLoop jr .establishConnectionLoop
.establishedConnection .establishedConnection
@ -65,7 +65,7 @@ CableClubNPC::
ld [hli], a ld [hli], a
xor a xor a
ld [hl], a ld [hl], a
ld [hSerialReceivedNewData], a ldh [hSerialReceivedNewData], a
ld [wSerialExchangeNybbleSendData], a ld [wSerialExchangeNybbleSendData], a
call Serial_SyncAndExchangeNybble call Serial_SyncAndExchangeNybble
ld hl, wUnknownSerialCounter ld hl, wUnknownSerialCounter
@ -141,11 +141,11 @@ CableClubNPCMakingPreparationsText:
CloseLinkConnection: CloseLinkConnection:
call Delay3 call Delay3
ld a, CONNECTION_NOT_ESTABLISHED ld a, CONNECTION_NOT_ESTABLISHED
ld [hSerialConnectionStatus], a ldh [hSerialConnectionStatus], a
ld a, ESTABLISH_CONNECTION_WITH_EXTERNAL_CLOCK ld a, ESTABLISH_CONNECTION_WITH_EXTERNAL_CLOCK
ld [rSB], a ldh [rSB], a
xor a xor a
ld [hSerialReceiveData], a ldh [hSerialReceiveData], a
ld a, START_TRANSFER_EXTERNAL_CLOCK ld a, START_TRANSFER_EXTERNAL_CLOCK
ld [rSC], a ldh [rSC], a
ret ret

View file

@ -6,39 +6,39 @@ DivideBCDPredef4::
DivideBCD:: DivideBCD::
xor a xor a
ld [hDivideBCDBuffer], a ldh [hDivideBCDBuffer], a
ld [hDivideBCDBuffer+1], a ldh [hDivideBCDBuffer+1], a
ld [hDivideBCDBuffer+2], a ldh [hDivideBCDBuffer+2], a
ld d, $1 ld d, $1
.mulBy10Loop .mulBy10Loop
; multiply the divisor by 10 until the leading digit is nonzero ; multiply the divisor by 10 until the leading digit is nonzero
; to set up the standard long division algorithm ; to set up the standard long division algorithm
ld a, [hDivideBCDDivisor] ldh a, [hDivideBCDDivisor]
and $f0 and $f0
jr nz, .next jr nz, .next
inc d inc d
ld a, [hDivideBCDDivisor] ldh a, [hDivideBCDDivisor]
swap a swap a
and $f0 and $f0
ld b, a ld b, a
ld a, [hDivideBCDDivisor+1] ldh a, [hDivideBCDDivisor+1]
swap a swap a
ld [hDivideBCDDivisor+1], a ldh [hDivideBCDDivisor+1], a
and $f and $f
or b or b
ld [hDivideBCDDivisor], a ldh [hDivideBCDDivisor], a
ld a, [hDivideBCDDivisor+1] ldh a, [hDivideBCDDivisor+1]
and $f0 and $f0
ld b, a ld b, a
ld a, [hDivideBCDDivisor+2] ldh a, [hDivideBCDDivisor+2]
swap a swap a
ld [hDivideBCDDivisor+2], a ldh [hDivideBCDDivisor+2], a
and $f and $f
or b or b
ld [hDivideBCDDivisor+1], a ldh [hDivideBCDDivisor+1], a
ld a, [hDivideBCDDivisor+2] ldh a, [hDivideBCDDivisor+2]
and $f0 and $f0
ld [hDivideBCDDivisor+2], a ldh [hDivideBCDDivisor+2], a
jr .mulBy10Loop jr .mulBy10Loop
.next .next
push de push de
@ -48,16 +48,16 @@ DivideBCD::
ld a, b ld a, b
swap a swap a
and $f0 and $f0
ld [hDivideBCDBuffer], a ldh [hDivideBCDBuffer], a
dec d dec d
jr z, .next2 jr z, .next2
push de push de
call DivideBCD_divDivisorBy10 call DivideBCD_divDivisorBy10
call DivideBCD_getNextDigit call DivideBCD_getNextDigit
pop de pop de
ld a, [hDivideBCDBuffer] ldh a, [hDivideBCDBuffer]
or b or b
ld [hDivideBCDBuffer], a ldh [hDivideBCDBuffer], a
dec d dec d
jr z, .next2 jr z, .next2
push de push de
@ -67,16 +67,16 @@ DivideBCD::
ld a, b ld a, b
swap a swap a
and $f0 and $f0
ld [hDivideBCDBuffer+1], a ldh [hDivideBCDBuffer+1], a
dec d dec d
jr z, .next2 jr z, .next2
push de push de
call DivideBCD_divDivisorBy10 call DivideBCD_divDivisorBy10
call DivideBCD_getNextDigit call DivideBCD_getNextDigit
pop de pop de
ld a, [hDivideBCDBuffer+1] ldh a, [hDivideBCDBuffer+1]
or b or b
ld [hDivideBCDBuffer+1], a ldh [hDivideBCDBuffer+1], a
dec d dec d
jr z, .next2 jr z, .next2
push de push de
@ -86,23 +86,23 @@ DivideBCD::
ld a, b ld a, b
swap a swap a
and $f0 and $f0
ld [hDivideBCDBuffer+2], a ldh [hDivideBCDBuffer+2], a
dec d dec d
jr z, .next2 jr z, .next2
push de push de
call DivideBCD_divDivisorBy10 call DivideBCD_divDivisorBy10
call DivideBCD_getNextDigit call DivideBCD_getNextDigit
pop de pop de
ld a, [hDivideBCDBuffer+2] ldh a, [hDivideBCDBuffer+2]
or b or b
ld [hDivideBCDBuffer+2], a ldh [hDivideBCDBuffer+2], a
.next2 .next2
ld a, [hDivideBCDBuffer] ldh a, [hDivideBCDBuffer]
ld [hDivideBCDQuotient], a ; the same memory location as hDivideBCDDivisor ldh [hDivideBCDQuotient], a ; the same memory location as hDivideBCDDivisor
ld a, [hDivideBCDBuffer+1] ldh a, [hDivideBCDBuffer+1]
ld [hDivideBCDQuotient+1], a ldh [hDivideBCDQuotient+1], a
ld a, [hDivideBCDBuffer+2] ldh a, [hDivideBCDBuffer+2]
ld [hDivideBCDQuotient+2], a ldh [hDivideBCDQuotient+2], a
pop de pop de
ld a, $6 ld a, $6
sub d sub d
@ -117,28 +117,28 @@ DivideBCD::
ret ret
DivideBCD_divDivisorBy10: DivideBCD_divDivisorBy10:
ld a, [hDivideBCDDivisor+2] ldh a, [hDivideBCDDivisor+2]
swap a swap a
and $f and $f
ld b, a ld b, a
ld a, [hDivideBCDDivisor+1] ldh a, [hDivideBCDDivisor+1]
swap a swap a
ld [hDivideBCDDivisor+1], a ldh [hDivideBCDDivisor+1], a
and $f0 and $f0
or b or b
ld [hDivideBCDDivisor+2], a ldh [hDivideBCDDivisor+2], a
ld a, [hDivideBCDDivisor+1] ldh a, [hDivideBCDDivisor+1]
and $f and $f
ld b, a ld b, a
ld a, [hDivideBCDDivisor] ldh a, [hDivideBCDDivisor]
swap a swap a
ld [hDivideBCDDivisor], a ldh [hDivideBCDDivisor], a
and $f0 and $f0
or b or b
ld [hDivideBCDDivisor+1], a ldh [hDivideBCDDivisor+1], a
ld a, [hDivideBCDDivisor] ldh a, [hDivideBCDDivisor]
and $f and $f
ld [hDivideBCDDivisor], a ldh [hDivideBCDDivisor], a
ret ret
DivideBCD_getNextDigit: DivideBCD_getNextDigit:

View file

@ -2,142 +2,142 @@ _Multiply::
ld a, $8 ld a, $8
ld b, a ld b, a
xor a xor a
ld [hProduct], a ldh [hProduct], a
ld [hMultiplyBuffer], a ldh [hMultiplyBuffer], a
ld [hMultiplyBuffer+1], a ldh [hMultiplyBuffer+1], a
ld [hMultiplyBuffer+2], a ldh [hMultiplyBuffer+2], a
ld [hMultiplyBuffer+3], a ldh [hMultiplyBuffer+3], a
.loop .loop
ld a, [hMultiplier] ldh a, [hMultiplier]
srl a srl a
ld [hMultiplier], a ; (aliases: hDivisor, hMultiplier, hPowerOf10) ldh [hMultiplier], a ; (aliases: hDivisor, hMultiplier, hPowerOf10)
jr nc, .smallMultiplier jr nc, .smallMultiplier
ld a, [hMultiplyBuffer+3] ldh a, [hMultiplyBuffer+3]
ld c, a ld c, a
ld a, [hMultiplicand+2] ldh a, [hMultiplicand+2]
add c add c
ld [hMultiplyBuffer+3], a ldh [hMultiplyBuffer+3], a
ld a, [hMultiplyBuffer+2] ldh a, [hMultiplyBuffer+2]
ld c, a ld c, a
ld a, [hMultiplicand+1] ldh a, [hMultiplicand+1]
adc c adc c
ld [hMultiplyBuffer+2], a ldh [hMultiplyBuffer+2], a
ld a, [hMultiplyBuffer+1] ldh a, [hMultiplyBuffer+1]
ld c, a ld c, a
ld a, [hMultiplicand] ; (aliases: hMultiplicand) ldh a, [hMultiplicand] ; (aliases: hMultiplicand)
adc c adc c
ld [hMultiplyBuffer+1], a ldh [hMultiplyBuffer+1], a
ld a, [hMultiplyBuffer] ldh a, [hMultiplyBuffer]
ld c, a ld c, a
ld a, [hProduct] ; (aliases: hProduct, hPastLeadingZeros, hQuotient) ldh a, [hProduct] ; (aliases: hProduct, hPastLeadingZeros, hQuotient)
adc c adc c
ld [hMultiplyBuffer], a ldh [hMultiplyBuffer], a
.smallMultiplier .smallMultiplier
dec b dec b
jr z, .done jr z, .done
ld a, [hMultiplicand+2] ldh a, [hMultiplicand+2]
sla a sla a
ld [hMultiplicand+2], a ldh [hMultiplicand+2], a
ld a, [hMultiplicand+1] ldh a, [hMultiplicand+1]
rl a rl a
ld [hMultiplicand+1], a ldh [hMultiplicand+1], a
ld a, [hMultiplicand] ldh a, [hMultiplicand]
rl a rl a
ld [hMultiplicand], a ldh [hMultiplicand], a
ld a, [hProduct] ldh a, [hProduct]
rl a rl a
ld [hProduct], a ldh [hProduct], a
jr .loop jr .loop
.done .done
ld a, [hMultiplyBuffer+3] ldh a, [hMultiplyBuffer+3]
ld [hProduct+3], a ldh [hProduct+3], a
ld a, [hMultiplyBuffer+2] ldh a, [hMultiplyBuffer+2]
ld [hProduct+2], a ldh [hProduct+2], a
ld a, [hMultiplyBuffer+1] ldh a, [hMultiplyBuffer+1]
ld [hProduct+1], a ldh [hProduct+1], a
ld a, [hMultiplyBuffer] ldh a, [hMultiplyBuffer]
ld [hProduct], a ldh [hProduct], a
ret ret
_Divide:: _Divide::
xor a xor a
ld [hDivideBuffer], a ldh [hDivideBuffer], a
ld [hDivideBuffer+1], a ldh [hDivideBuffer+1], a
ld [hDivideBuffer+2], a ldh [hDivideBuffer+2], a
ld [hDivideBuffer+3], a ldh [hDivideBuffer+3], a
ld [hDivideBuffer+4], a ldh [hDivideBuffer+4], a
ld a, $9 ld a, $9
ld e, a ld e, a
.asm_37db3 .asm_37db3
ld a, [hDivideBuffer] ldh a, [hDivideBuffer]
ld c, a ld c, a
ld a, [hDividend+1] ; (aliases: hMultiplicand) ldh a, [hDividend+1] ; (aliases: hMultiplicand)
sub c sub c
ld d, a ld d, a
ld a, [hDivisor] ; (aliases: hDivisor, hMultiplier, hPowerOf10) ldh a, [hDivisor] ; (aliases: hDivisor, hMultiplier, hPowerOf10)
ld c, a ld c, a
ld a, [hDividend] ; (aliases: hProduct, hPastLeadingZeros, hQuotient) ldh a, [hDividend] ; (aliases: hProduct, hPastLeadingZeros, hQuotient)
sbc c sbc c
jr c, .asm_37dce jr c, .asm_37dce
ld [hDividend], a ; (aliases: hProduct, hPastLeadingZeros, hQuotient) ldh [hDividend], a ; (aliases: hProduct, hPastLeadingZeros, hQuotient)
ld a, d ld a, d
ld [hDividend+1], a ; (aliases: hMultiplicand) ldh [hDividend+1], a ; (aliases: hMultiplicand)
ld a, [hDivideBuffer+4] ldh a, [hDivideBuffer+4]
inc a inc a
ld [hDivideBuffer+4], a ldh [hDivideBuffer+4], a
jr .asm_37db3 jr .asm_37db3
.asm_37dce .asm_37dce
ld a, b ld a, b
cp $1 cp $1
jr z, .asm_37e18 jr z, .asm_37e18
ld a, [hDivideBuffer+4] ldh a, [hDivideBuffer+4]
sla a sla a
ld [hDivideBuffer+4], a ldh [hDivideBuffer+4], a
ld a, [hDivideBuffer+3] ldh a, [hDivideBuffer+3]
rl a rl a
ld [hDivideBuffer+3], a ldh [hDivideBuffer+3], a
ld a, [hDivideBuffer+2] ldh a, [hDivideBuffer+2]
rl a rl a
ld [hDivideBuffer+2], a ldh [hDivideBuffer+2], a
ld a, [hDivideBuffer+1] ldh a, [hDivideBuffer+1]
rl a rl a
ld [hDivideBuffer+1], a ldh [hDivideBuffer+1], a
dec e dec e
jr nz, .asm_37e04 jr nz, .asm_37e04
ld a, $8 ld a, $8
ld e, a ld e, a
ld a, [hDivideBuffer] ldh a, [hDivideBuffer]
ld [hDivisor], a ; (aliases: hDivisor, hMultiplier, hPowerOf10) ldh [hDivisor], a ; (aliases: hDivisor, hMultiplier, hPowerOf10)
xor a xor a
ld [hDivideBuffer], a ldh [hDivideBuffer], a
ld a, [hDividend+1] ; (aliases: hMultiplicand) ldh a, [hDividend+1] ; (aliases: hMultiplicand)
ld [hDividend], a ; (aliases: hProduct, hPastLeadingZeros, hQuotient) ldh [hDividend], a ; (aliases: hProduct, hPastLeadingZeros, hQuotient)
ld a, [hDividend+2] ldh a, [hDividend+2]
ld [hDividend+1], a ; (aliases: hMultiplicand) ldh [hDividend+1], a ; (aliases: hMultiplicand)
ld a, [hDividend+3] ldh a, [hDividend+3]
ld [hDividend+2], a ldh [hDividend+2], a
.asm_37e04 .asm_37e04
ld a, e ld a, e
cp $1 cp $1
jr nz, .asm_37e0a jr nz, .asm_37e0a
dec b dec b
.asm_37e0a .asm_37e0a
ld a, [hDivisor] ; (aliases: hDivisor, hMultiplier, hPowerOf10) ldh a, [hDivisor] ; (aliases: hDivisor, hMultiplier, hPowerOf10)
srl a srl a
ld [hDivisor], a ; (aliases: hDivisor, hMultiplier, hPowerOf10) ldh [hDivisor], a ; (aliases: hDivisor, hMultiplier, hPowerOf10)
ld a, [hDivideBuffer] ldh a, [hDivideBuffer]
rr a rr a
ld [hDivideBuffer], a ldh [hDivideBuffer], a
jr .asm_37db3 jr .asm_37db3
.asm_37e18 .asm_37e18
ld a, [hDividend+1] ; (aliases: hMultiplicand) ldh a, [hDividend+1] ; (aliases: hMultiplicand)
ld [hRemainder], a ; (aliases: hDivisor, hMultiplier, hPowerOf10) ldh [hRemainder], a ; (aliases: hDivisor, hMultiplier, hPowerOf10)
ld a, [hDivideBuffer+4] ldh a, [hDivideBuffer+4]
ld [hQuotient+3], a ldh [hQuotient+3], a
ld a, [hDivideBuffer+3] ldh a, [hDivideBuffer+3]
ld [hQuotient+2], a ldh [hQuotient+2], a
ld a, [hDivideBuffer+2] ldh a, [hDivideBuffer+2]
ld [hQuotient+1], a ; (aliases: hMultiplicand) ldh [hQuotient+1], a ; (aliases: hMultiplicand)
ld a, [hDivideBuffer+1] ldh a, [hDivideBuffer+1]
ld [hDividend], a ; (aliases: hProduct, hPastLeadingZeros, hQuotient) ldh [hDividend], a ; (aliases: hProduct, hPastLeadingZeros, hQuotient)
ret ret

View file

@ -1,13 +1,13 @@
Random_:: Random_::
; Generate a random 16-bit value. ; Generate a random 16-bit value.
ld a, [rDIV] ldh a, [rDIV]
ld b, a ld b, a
ld a, [hRandomAdd] ldh a, [hRandomAdd]
adc b adc b
ld [hRandomAdd], a ldh [hRandomAdd], a
ld a, [rDIV] ldh a, [rDIV]
ld b, a ld b, a
ld a, [hRandomSub] ldh a, [hRandomSub]
sbc b sbc b
ld [hRandomSub], a ldh [hRandomSub], a
ret ret

View file

@ -5,7 +5,7 @@ DisplayTextIDInit::
ld a, [wAutoTextBoxDrawingControl] ld a, [wAutoTextBoxDrawingControl]
bit 0, a bit 0, a
jr nz, .skipDrawingTextBoxBorder jr nz, .skipDrawingTextBoxBorder
ld a, [hSpriteIndexOrTextID] ; text ID (or sprite ID) ldh a, [hSpriteIndexOrTextID] ; text ID (or sprite ID)
and a and a
jr nz, .notStartMenu jr nz, .notStartMenu
; if text ID is 0 (i.e. the start menu) ; if text ID is 0 (i.e. the start menu)
@ -71,8 +71,8 @@ DisplayTextIDInit::
ld b, $9c ; window background address ld b, $9c ; window background address
call CopyScreenTileBufferToVRAM ; transfer background in WRAM to VRAM call CopyScreenTileBufferToVRAM ; transfer background in WRAM to VRAM
xor a xor a
ld [hWY], a ; put the window on the screen ldh [hWY], a ; put the window on the screen
call LoadFontTilePatterns call LoadFontTilePatterns
ld a, $01 ld a, $01
ld [hAutoBGTransferEnabled], a ; enable continuous WRAM to VRAM transfer each V-blank ldh [hAutoBGTransferEnabled], a ; enable continuous WRAM to VRAM transfer each V-blank
ret ret

View file

@ -6,10 +6,10 @@ PKMNLeaguePC:
push hl push hl
ld a, [wUpdateSpritesEnabled] ld a, [wUpdateSpritesEnabled]
push af push af
ld a, [hTilesetType] ldh a, [hTilesetType]
push af push af
xor a xor a
ld [hTilesetType], a ldh [hTilesetType], a
ld [wSpriteFlipped], a ld [wSpriteFlipped], a
ld [wUpdateSpritesEnabled], a ld [wUpdateSpritesEnabled], a
ld [wHoFTeamIndex2], a ld [wHoFTeamIndex2], a
@ -40,7 +40,7 @@ PKMNLeaguePC:
jr nz, .loop jr nz, .loop
.doneShowingTeams .doneShowingTeams
pop af pop af
ld [hTilesetType], a ldh [hTilesetType], a
pop af pop af
ld [wUpdateSpritesEnabled], a ld [wUpdateSpritesEnabled], a
pop hl pop hl
@ -56,7 +56,7 @@ LeaguePCShowTeam:
push bc push bc
call LeaguePCShowMon call LeaguePCShowMon
call WaitForTextScrollButtonPress call WaitForTextScrollButtonPress
ld a, [hJoyHeld] ldh a, [hJoyHeld]
bit 1, a bit 1, a
jr nz, .exit jr nz, .exit
ld hl, wHallOfFame + HOF_MON ld hl, wHallOfFame + HOF_MON

View file

@ -94,11 +94,11 @@ MainMenu:
set 5, [hl] set 5, [hl]
.inputLoop .inputLoop
xor a xor a
ld [hJoyPressed], a ldh [hJoyPressed], a
ld [hJoyReleased], a ldh [hJoyReleased], a
ld [hJoyHeld], a ldh [hJoyHeld], a
call Joypad call Joypad
ld a, [hJoyHeld] ldh a, [hJoyHeld]
bit 0, a bit 0, a
jr nz, .pressedA jr nz, .pressedA
bit 1, a bit 1, a
@ -205,7 +205,7 @@ LinkMenu:
jr z, .useEnemyMenuSelection ; if the enemy pressed A or B but the player didn't, use the enemy's selection jr z, .useEnemyMenuSelection ; if the enemy pressed A or B but the player didn't, use the enemy's selection
; the enemy and the player both pressed A or B ; the enemy and the player both pressed A or B
; The gameboy that is clocking the connection wins. ; The gameboy that is clocking the connection wins.
ld a, [hSerialConnectionStatus] ldh a, [hSerialConnectionStatus]
cp USING_INTERNAL_CLOCK cp USING_INTERNAL_CLOCK
jr z, .doneChoosingMenuSelection jr z, .doneChoosingMenuSelection
.useEnemyMenuSelection .useEnemyMenuSelection
@ -214,13 +214,13 @@ LinkMenu:
and $3 and $3
ld [wCurrentMenuItem], a ld [wCurrentMenuItem], a
.doneChoosingMenuSelection .doneChoosingMenuSelection
ld a, [hSerialConnectionStatus] ldh a, [hSerialConnectionStatus]
cp USING_INTERNAL_CLOCK cp USING_INTERNAL_CLOCK
jr nz, .skipStartingTransfer jr nz, .skipStartingTransfer
call DelayFrame call DelayFrame
call DelayFrame call DelayFrame
ld a, START_TRANSFER_INTERNAL_CLOCK ld a, START_TRANSFER_INTERNAL_CLOCK
ld [rSC], a ldh [rSC], a
.skipStartingTransfer .skipStartingTransfer
ld b, $7f ld b, $7f
ld c, $7f ld c, $7f
@ -314,9 +314,9 @@ StartNewGame:
; enter map after using a special warp or loading the game from the main menu ; enter map after using a special warp or loading the game from the main menu
SpecialEnterMap:: SpecialEnterMap::
xor a xor a
ld [hJoyPressed], a ldh [hJoyPressed], a
ld [hJoyHeld], a ldh [hJoyHeld], a
ld [hJoy5], a ldh [hJoy5], a
ld [wd72d], a ld [wd72d], a
ld hl, wd732 ld hl, wd732
set 0, [hl] ; count play time set 0, [hl] ; count play time
@ -344,7 +344,7 @@ CableClubOptionsText:
DisplayContinueGameInfo: DisplayContinueGameInfo:
xor a xor a
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
coord hl, 4, 7 coord hl, 4, 7
ld b, 8 ld b, 8
ld c, 14 ld c, 14
@ -362,13 +362,13 @@ DisplayContinueGameInfo:
coord hl, 13, 15 coord hl, 13, 15
call PrintPlayTime call PrintPlayTime
ld a, 1 ld a, 1
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
ld c, 30 ld c, 30
jp DelayFrames jp DelayFrames
PrintSaveScreenText: PrintSaveScreenText:
xor a xor a
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
coord hl, 4, 0 coord hl, 4, 0
ld b, $8 ld b, $8
ld c, $e ld c, $e
@ -388,7 +388,7 @@ PrintSaveScreenText:
coord hl, 13, 8 coord hl, 13, 8
call PrintPlayTime call PrintPlayTime
ld a, $1 ld a, $1
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
ld c, 30 ld c, 30
jp DelayFrames jp DelayFrames
@ -465,14 +465,14 @@ DisplayOptionMenu:
ld a, [wOptionsTextSpeedCursorX] ; text speed cursor X coordinate ld a, [wOptionsTextSpeedCursorX] ; text speed cursor X coordinate
ld [wTopMenuItemX], a ld [wTopMenuItemX], a
ld a, $01 ld a, $01
ld [hAutoBGTransferEnabled], a ; enable auto background transfer ldh [hAutoBGTransferEnabled], a ; enable auto background transfer
call Delay3 call Delay3
.loop .loop
call PlaceMenuCursor call PlaceMenuCursor
call SetOptionsFromCursorPositions call SetOptionsFromCursorPositions
.getJoypadStateLoop .getJoypadStateLoop
call JoypadLowSensitivity call JoypadLowSensitivity
ld a, [hJoy5] ldh a, [hJoy5]
ld b, a ld b, a
and A_BUTTON | B_BUTTON | START | D_RIGHT | D_LEFT | D_UP | D_DOWN ; any key besides select pressed? and A_BUTTON | B_BUTTON | START | D_RIGHT | D_LEFT | D_UP | D_DOWN ; any key besides select pressed?
jr z, .getJoypadStateLoop jr z, .getJoypadStateLoop

View file

@ -132,7 +132,7 @@ DisplayNamingScreen:
pop af pop af
ld [wCurrentMenuItem], a ld [wCurrentMenuItem], a
call JoypadLowSensitivity call JoypadLowSensitivity
ld a, [hJoyPressed] ldh a, [hJoyPressed]
and a and a
jr z, .inputLoop jr z, .inputLoop
ld hl, .namingScreenButtonFunctions ld hl, .namingScreenButtonFunctions
@ -337,7 +337,7 @@ ED_TileEnd:
PrintAlphabet: PrintAlphabet:
xor a xor a
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
ld a, [wAlphabetCase] ld a, [wAlphabetCase]
and a and a
ld de, LowerCaseAlphabet ld de, LowerCaseAlphabet
@ -362,7 +362,7 @@ PrintAlphabet:
jr nz, .outerLoop jr nz, .outerLoop
call PlaceString call PlaceString
ld a, $1 ld a, $1
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
jp Delay3 jp Delay3
INCLUDE "data/text/alphabets.asm" INCLUDE "data/text/alphabets.asm"

View file

@ -19,7 +19,7 @@
; f8: leveled up ; f8: leveled up
DrawPartyMenu_:: DrawPartyMenu_::
xor a xor a
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
call ClearScreen call ClearScreen
call UpdateSprites call UpdateSprites
callba LoadMonPartySpriteGfxWithLCDDisabled ; load pokemon icon graphics callba LoadMonPartySpriteGfxWithLCDDisabled ; load pokemon icon graphics
@ -34,7 +34,7 @@ RedrawPartyMenu_::
ld de, wPartySpecies ld de, wPartySpecies
xor a xor a
ld c, a ld c, a
ld [hPartyMonIndex], a ldh [hPartyMonIndex], a
ld [wWhichPartyMenuHPBar], a ld [wWhichPartyMenuHPBar], a
.loop .loop
ld a, [de] ld a, [de]
@ -50,10 +50,10 @@ RedrawPartyMenu_::
pop hl pop hl
call PlaceString ; print the pokemon's name call PlaceString ; print the pokemon's name
callba WriteMonPartySpriteOAMByPartyIndex ; place the appropriate pokemon icon callba WriteMonPartySpriteOAMByPartyIndex ; place the appropriate pokemon icon
ld a, [hPartyMonIndex] ldh a, [hPartyMonIndex]
ld [wWhichPokemon], a ld [wWhichPokemon], a
inc a inc a
ld [hPartyMonIndex], a ldh [hPartyMonIndex], a
call LoadMonData call LoadMonData
pop hl pop hl
push hl push hl
@ -88,14 +88,14 @@ RedrawPartyMenu_::
pop hl pop hl
push hl push hl
ld bc, SCREEN_WIDTH + 1 ; down 1 row and right 1 column ld bc, SCREEN_WIDTH + 1 ; down 1 row and right 1 column
ld a, [hFlagsFFF6] ldh a, [hFlagsFFF6]
set 0, a set 0, a
ld [hFlagsFFF6], a ldh [hFlagsFFF6], a
add hl, bc add hl, bc
predef DrawHP2 ; draw HP bar and prints current / max HP predef DrawHP2 ; draw HP bar and prints current / max HP
ld a, [hFlagsFFF6] ldh a, [hFlagsFFF6]
res 0, a res 0, a
ld [hFlagsFFF6], a ldh [hFlagsFFF6], a
call SetPartyMenuHPBarColor ; color the HP bar (on SGB) call SetPartyMenuHPBarColor ; color the HP bar (on SGB)
pop hl pop hl
jr .printLevel jr .printLevel
@ -213,7 +213,7 @@ RedrawPartyMenu_::
pop af pop af
ld [hl], a ld [hl], a
ld a, 1 ld a, 1
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
call Delay3 call Delay3
jp GBPalNormal jp GBPalNormal
.printItemUseMessage .printItemUseMessage

View file

@ -117,10 +117,10 @@ AccessedMyPCText:
; removes one of the specified item ID [hItemToRemoveID] from bag (if existent) ; removes one of the specified item ID [hItemToRemoveID] from bag (if existent)
RemoveItemByID:: RemoveItemByID::
ld hl, wBagItems ld hl, wBagItems
ld a, [hItemToRemoveID] ldh a, [hItemToRemoveID]
ld b, a ld b, a
xor a xor a
ld [hItemToRemoveIndex], a ldh [hItemToRemoveIndex], a
.loop .loop
ld a, [hli] ld a, [hli]
cp -1 ; reached terminator? cp -1 ; reached terminator?
@ -128,14 +128,14 @@ RemoveItemByID::
cp b cp b
jr z, .foundItem jr z, .foundItem
inc hl inc hl
ld a, [hItemToRemoveIndex] ldh a, [hItemToRemoveIndex]
inc a inc a
ld [hItemToRemoveIndex], a ldh [hItemToRemoveIndex], a
jr .loop jr .loop
.foundItem .foundItem
ld a, $1 ld a, $1
ld [wItemQuantity], a ld [wItemQuantity], a
ld a, [hItemToRemoveIndex] ldh a, [hItemToRemoveIndex]
ld [wWhichPokemon], a ld [wWhichPokemon], a
ld hl, wNumBagItems ld hl, wNumBagItems
jp RemoveItemFromInventory jp RemoveItemFromInventory

View file

@ -10,7 +10,7 @@ ShowPokedexMenu:
ld [wLastMenuItem], a ld [wLastMenuItem], a
inc a inc a
ld [wd11e], a ld [wd11e], a
ld [hJoy7], a ldh [hJoy7], a
.setUpGraphics .setUpGraphics
ld b, SET_PAL_GENERIC ld b, SET_PAL_GENERIC
call RunPaletteCommand call RunPaletteCommand
@ -35,7 +35,7 @@ ShowPokedexMenu:
ld [wMenuWatchMovingOutOfBounds], a ld [wMenuWatchMovingOutOfBounds], a
ld [wCurrentMenuItem], a ld [wCurrentMenuItem], a
ld [wLastMenuItem], a ld [wLastMenuItem], a
ld [hJoy7], a ldh [hJoy7], a
ld [wWastedByteCD3A], a ld [wWastedByteCD3A], a
ld [wOverrideSimulatedJoypadStatesMask], a ld [wOverrideSimulatedJoypadStatesMask], a
pop af pop af
@ -156,7 +156,7 @@ HandlePokedexSideMenu:
; sets carry flag if player presses A, unsets carry flag if player presses B ; sets carry flag if player presses A, unsets carry flag if player presses B
HandlePokedexListMenu: HandlePokedexListMenu:
xor a xor a
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
; draw the horizontal line separating the seen and owned amounts from the menu ; draw the horizontal line separating the seen and owned amounts from the menu
coord hl, 15, 8 coord hl, 15, 8
ld a, "─" ld a, "─"
@ -216,7 +216,7 @@ HandlePokedexListMenu:
ld [wDexMaxSeenMon], a ld [wDexMaxSeenMon], a
.loop .loop
xor a xor a
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
coord hl, 4, 2 coord hl, 4, 2
lb bc, 14, 10 lb bc, 14, 10
call ClearScreenArea call ClearScreenArea
@ -280,7 +280,7 @@ HandlePokedexListMenu:
dec d dec d
jr nz, .printPokemonLoop jr nz, .printPokemonLoop
ld a, 01 ld a, 01
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
call Delay3 call Delay3
call GBPalNormal call GBPalNormal
call HandleMenuInput call HandleMenuInput
@ -400,7 +400,7 @@ ShowPokedexDataInternal:
ld hl, wd72c ld hl, wd72c
set 1, [hl] set 1, [hl]
ld a, $33 ; 3/7 volume ld a, $33 ; 3/7 volume
ld [rNR50], a ldh [rNR50], a
call GBPalWhiteOut ; zero all palettes call GBPalWhiteOut ; zero all palettes
call ClearScreen call ClearScreen
ld a, [wd11e] ; pokemon ID ld a, [wd11e] ; pokemon ID
@ -410,10 +410,10 @@ ShowPokedexDataInternal:
call RunPaletteCommand call RunPaletteCommand
pop af pop af
ld [wd11e], a ld [wd11e], a
ld a, [hTilesetType] ldh a, [hTilesetType]
push af push af
xor a xor a
ld [hTilesetType], a ldh [hTilesetType], a
coord hl, 0, 0 coord hl, 0, 0
ld de, 1 ld de, 1
@ -548,9 +548,9 @@ ShowPokedexDataInternal:
lb bc, 2, 5 ; 2 bytes, 5 digits lb bc, 2, 5 ; 2 bytes, 5 digits
call PrintNumber ; print weight call PrintNumber ; print weight
coord hl, 14, 8 coord hl, 14, 8
ld a, [hDexWeight + 1] ldh a, [hDexWeight + 1]
sub 10 sub 10
ld a, [hDexWeight] ldh a, [hDexWeight]
sbc 0 sbc 0
jr nc, .next jr nc, .next
ld [hl], "0" ; if the weight is less than 10, put a 0 before the decimal point ld [hl], "0" ; if the weight is less than 10, put a 0 before the decimal point
@ -560,24 +560,24 @@ ShowPokedexDataInternal:
ld [hld], a ; make space for the decimal point by moving the last digit forward one tile ld [hld], a ; make space for the decimal point by moving the last digit forward one tile
ld [hl], "<DOT>" ; decimal point tile ld [hl], "<DOT>" ; decimal point tile
pop af pop af
ld [hDexWeight + 1], a ; restore original value of [hDexWeight + 1] ldh [hDexWeight + 1], a ; restore original value of [hDexWeight + 1]
pop af pop af
ld [hDexWeight], a ; restore original value of [hDexWeight] ldh [hDexWeight], a ; restore original value of [hDexWeight]
pop hl pop hl
inc hl ; hl = address of pokedex description text inc hl ; hl = address of pokedex description text
coord bc, 1, 11 coord bc, 1, 11
ld a, %10 ld a, %10
ld [hClearLetterPrintingDelayFlags], a ldh [hClearLetterPrintingDelayFlags], a
call TextCommandProcessor ; print pokedex description text call TextCommandProcessor ; print pokedex description text
xor a xor a
ld [hClearLetterPrintingDelayFlags], a ldh [hClearLetterPrintingDelayFlags], a
.waitForButtonPress .waitForButtonPress
call JoypadLowSensitivity call JoypadLowSensitivity
ld a, [hJoy5] ldh a, [hJoy5]
and A_BUTTON | B_BUTTON and A_BUTTON | B_BUTTON
jr z, .waitForButtonPress jr z, .waitForButtonPress
pop af pop af
ld [hTilesetType], a ldh [hTilesetType], a
call GBPalWhiteOut call GBPalWhiteOut
call ClearScreen call ClearScreen
call RunDefaultPaletteCommand call RunDefaultPaletteCommand
@ -586,7 +586,7 @@ ShowPokedexDataInternal:
ld hl, wd72c ld hl, wd72c
res 1, [hl] res 1, [hl]
ld a, $77 ; max volume ld a, $77 ; max volume
ld [rNR50], a ldh [rNR50], a
ret ret
HeightWeightText: HeightWeightText:

View file

@ -70,7 +70,7 @@ LoadSAV0:
ld bc, wSpriteDataEnd - wSpriteDataStart ld bc, wSpriteDataEnd - wSpriteDataStart
call CopyData call CopyData
ld a, [sTilesetType] ld a, [sTilesetType]
ld [hTilesetType], a ldh [hTilesetType], a
ld hl, sCurBoxData ld hl, sCurBoxData
ld de, wBoxDataStart ld de, wBoxDataStart
ld bc, wBoxDataEnd - wBoxDataStart ld bc, wBoxDataEnd - wBoxDataStart
@ -217,7 +217,7 @@ SaveSAVtoSRAM0:
ld de, sCurBoxData ld de, sCurBoxData
ld bc, wBoxDataEnd - wBoxDataStart ld bc, wBoxDataEnd - wBoxDataStart
call CopyData call CopyData
ld a, [hTilesetType] ldh a, [hTilesetType]
ld [sTilesetType], a ld [sTilesetType], a
ld hl, sPlayerName ld hl, sPlayerName
ld bc, sMainDataCheckSum - sPlayerName ld bc, sMainDataCheckSum - sPlayerName
@ -420,7 +420,7 @@ CopyBoxToOrFromSRAM:
DisplayChangeBoxMenu: DisplayChangeBoxMenu:
xor a xor a
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
ld a, A_BUTTON | B_BUTTON ld a, A_BUTTON | B_BUTTON
ld [wMenuWatchedKeys], a ld [wMenuWatchedKeys], a
ld a, 11 ld a, 11
@ -486,7 +486,7 @@ DisplayChangeBoxMenu:
dec a dec a
jr nz, .loop jr nz, .loop
ld a, 1 ld a, 1
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
ret ret
ChooseABoxText: ChooseABoxText:

View file

@ -50,7 +50,7 @@ StartMenu_Pokemon::
ld hl, wTopMenuItemY ld hl, wTopMenuItemY
ld a, c ld a, c
ld [hli], a ; top menu item Y ld [hli], a ; top menu item Y
ld a, [hFieldMoveMonMenuTopMenuItemX] ldh a, [hFieldMoveMonMenuTopMenuItemX]
ld [hli], a ; top menu item X ld [hli], a ; top menu item X
xor a xor a
ld [hli], a ; current menu item ID ld [hli], a ; current menu item ID
@ -239,21 +239,21 @@ StartMenu_Pokemon::
ld bc, wPartyMon2 - wPartyMon1 ld bc, wPartyMon2 - wPartyMon1
call AddNTimes call AddNTimes
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 a, 5 ld a, 5
ld [hDivisor], a ldh [hDivisor], a
ld b, 2 ; number of bytes ld b, 2 ; number of bytes
call Divide call Divide
ld bc, wPartyMon1HP - wPartyMon1MaxHP ld bc, wPartyMon1HP - wPartyMon1MaxHP
add hl, bc add hl, bc
ld a, [hld] ld a, [hld]
ld b, a ld b, a
ld a, [hQuotient + 3] ldh a, [hQuotient + 3]
sub b sub b
ld b, [hl] ld b, [hl]
ld a, [hQuotient + 2] ldh a, [hQuotient + 2]
sbc b sbc b
jp nc, .notHealthyEnough jp nc, .notHealthyEnough
ld a, [wPartyAndBillsPCSavedMenuItem] ld a, [wPartyAndBillsPCSavedMenuItem]
@ -454,10 +454,10 @@ StartMenu_TrainerInfo::
call GBPalWhiteOut call GBPalWhiteOut
call ClearScreen call ClearScreen
call UpdateSprites call UpdateSprites
ld a, [hTilesetType] ldh a, [hTilesetType]
push af push af
xor a xor a
ld [hTilesetType], a ldh [hTilesetType], a
call DrawTrainerInfo call DrawTrainerInfo
predef DrawBadges ; draw badges predef DrawBadges ; draw badges
ld b, SET_PAL_TRAINER_CARD ld b, SET_PAL_TRAINER_CARD
@ -471,7 +471,7 @@ StartMenu_TrainerInfo::
call ReloadMapData call ReloadMapData
call LoadGBPal call LoadGBPal
pop af pop af
ld [hTilesetType], a ldh [hTilesetType], a
jp RedisplayStartMenu jp RedisplayStartMenu
; loads tile patterns and draws everything except for gym leader faces / badges ; loads tile patterns and draws everything except for gym leader faces / badges
@ -648,7 +648,7 @@ StartMenu_SaveReset::
StartMenu_Option:: StartMenu_Option::
xor a xor a
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
call ClearScreen call ClearScreen
call UpdateSprites call UpdateSprites
callab DisplayOptionMenu callab DisplayOptionMenu
@ -737,10 +737,10 @@ SwitchPartyMon_InitVarOrSwapData:
inc d inc d
.noCarry2 .noCarry2
ld a, [hl] ld a, [hl]
ld [hSwapTemp], a ldh [hSwapTemp], a
ld a, [de] ld a, [de]
ld [hl], a ld [hl], a
ld a, [hSwapTemp] ldh a, [hSwapTemp]
ld [de], a ld [de], a
ld hl, wPartyMons ld hl, wPartyMons
ld bc, wPartyMon2 - wPartyMon1 ld bc, wPartyMon2 - wPartyMon1

View file

@ -77,18 +77,18 @@ HandleItemListSwapping::
cp b cp b
jr z, .swapSameItemType jr z, .swapSameItemType
.swapDifferentItems .swapDifferentItems
ld [hSwapItemID], a ; save second item ID ldh [hSwapItemID], a ; save second item ID
ld a, [hld] ld a, [hld]
ld [hSwapItemQuantity], a ; save second item quantity ldh [hSwapItemQuantity], a ; save second item quantity
ld a, [de] ld a, [de]
ld [hli], a ; put first item ID in second item slot ld [hli], a ; put first item ID in second item slot
inc de inc de
ld a, [de] ld a, [de]
ld [hl], a ; put first item quantity in second item slot ld [hl], a ; put first item quantity in second item slot
ld a, [hSwapItemQuantity] ldh a, [hSwapItemQuantity]
ld [de], a ; put second item quantity in first item slot ld [de], a ; put second item quantity in first item slot
dec de dec de
ld a, [hSwapItemID] ldh a, [hSwapItemID]
ld [de], a ; put second item ID in first item slot ld [de], a ; put second item ID in first item slot
xor a xor a
ld [wMenuItemToSwap], a ; 0 means no item is currently being swapped ld [wMenuItemToSwap], a ; 0 means no item is currently being swapped

View file

@ -584,7 +584,7 @@ DisplayFieldMoveMonMenu:
call TextBoxBorder call TextBoxBorder
call UpdateSprites call UpdateSprites
ld a, 12 ld a, 12
ld [hFieldMoveMonMenuTopMenuItemX], a ldh [hFieldMoveMonMenuTopMenuItemX], a
coord hl, 13, 12 coord hl, 13, 12
ld de, PokemonMenuEntries ld de, PokemonMenuEntries
jp PlaceString jp PlaceString
@ -673,7 +673,7 @@ DisplayFieldMoveMonMenu:
.donePrintingNames .donePrintingNames
pop hl pop hl
ld a, [wFieldMovesLeftmostXCoord] ld a, [wFieldMovesLeftmostXCoord]
ld [hFieldMoveMonMenuTopMenuItemX], a ldh [hFieldMoveMonMenuTopMenuItemX], a
coord hl, 0, 12 coord hl, 0, 12
ld a, [wFieldMovesLeftmostXCoord] ld a, [wFieldMovesLeftmostXCoord]
inc a inc a

View file

@ -19,7 +19,7 @@ HallOfFamePC:
coord hl, 0, 14 coord hl, 0, 14
call FillFourRowsWithBlack call FillFourRowsWithBlack
ld a, %11000000 ld a, %11000000
ld [rBGP], a ldh [rBGP], a
call EnableLCD call EnableLCD
ld a, SFX_STOP_ALL_MUSIC ld a, SFX_STOP_ALL_MUSIC
call PlaySoundWaitForCurrent call PlaySoundWaitForCurrent
@ -38,7 +38,7 @@ FadeInCreditsText:
ld b, 4 ld b, 4
.loop .loop
ld a, [hli] ld a, [hli]
ld [rBGP], a ldh [rBGP], a
ld c, 5 ld c, 5
call DelayFrames call DelayFrames
dec b dec b
@ -47,7 +47,7 @@ FadeInCreditsText:
DisplayCreditsMon: DisplayCreditsMon:
xor a xor a
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
call SaveScreenTilesToBuffer1 call SaveScreenTilesToBuffer1
call FillMiddleOfScreenWithWhite call FillMiddleOfScreenWithWhite
@ -67,17 +67,17 @@ DisplayCreditsMon:
ld hl, vBGMap0 + $c ld hl, vBGMap0 + $c
call CreditsCopyTileMapToVRAM call CreditsCopyTileMapToVRAM
xor a xor a
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
call LoadScreenTilesFromBuffer1 call LoadScreenTilesFromBuffer1
ld hl, vBGMap0 ld hl, vBGMap0
call CreditsCopyTileMapToVRAM call CreditsCopyTileMapToVRAM
ld a, $A7 ld a, $A7
ld [rWX], a ldh [rWX], a
ld hl, vBGMap1 ld hl, vBGMap1
call CreditsCopyTileMapToVRAM call CreditsCopyTileMapToVRAM
call FillMiddleOfScreenWithWhite call FillMiddleOfScreenWithWhite
ld a, %11111100 ; make the mon a black silhouette ld a, %11111100 ; make the mon a black silhouette
ld [rBGP], a ldh [rBGP], a
; scroll the mon left by one tile 7 times ; scroll the mon left by one tile 7 times
ld bc, 7 ld bc, 7
@ -92,16 +92,16 @@ DisplayCreditsMon:
ld c, 20 ld c, 20
.scrollLoop2 .scrollLoop2
call ScrollCreditsMonLeft call ScrollCreditsMonLeft
ld a, [rWX] ldh a, [rWX]
sub 8 sub 8
ld [rWX], a ldh [rWX], a
dec c dec c
jr nz, .scrollLoop2 jr nz, .scrollLoop2
xor a xor a
ld [hWY], a ldh [hWY], a
ld a, %11000000 ld a, %11000000
ld [rBGP], a ldh [rBGP], a
ret ret
INCLUDE "data/credits/credits_mons.asm" INCLUDE "data/credits/credits_mons.asm"
@ -119,13 +119,13 @@ ScrollCreditsMonLeft:
ret ret
ScrollCreditsMonLeft_SetSCX: ScrollCreditsMonLeft_SetSCX:
ld a, [rLY] ldh a, [rLY]
cp l cp l
jr nz, ScrollCreditsMonLeft_SetSCX jr nz, ScrollCreditsMonLeft_SetSCX
ld a, h ld a, h
ld [rSCX], a ldh [rSCX], a
.loop .loop
ld a, [rLY] ldh a, [rLY]
cp h cp h
jr z, .loop jr z, .loop
ret ret
@ -138,11 +138,11 @@ HoFGBPalettes:
CreditsCopyTileMapToVRAM: CreditsCopyTileMapToVRAM:
ld a, l ld a, l
ld [hAutoBGTransferDest], a ldh [hAutoBGTransferDest], a
ld a, h ld a, h
ld [hAutoBGTransferDest + 1], a ldh [hAutoBGTransferDest + 1], a
ld a, 1 ld a, 1
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
jp Delay3 jp Delay3
ZeroMemory: ZeroMemory:

View file

@ -13,13 +13,13 @@ EvolveMon:
ld [wNewSoundID], a ld [wNewSoundID], a
call PlaySound call PlaySound
ld a, $1 ld a, $1
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
ld a, SFX_TINK ld a, SFX_TINK
call PlaySound call PlaySound
call Delay3 call Delay3
xor a xor a
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
ld [hTilesetType], a ldh [hTilesetType], a
ld a, [wEvoOldSpecies] ld a, [wEvoOldSpecies]
ld [wWholeScreenPaletteMonSpecies], a ld [wWholeScreenPaletteMonSpecies], a
ld c, 0 ld c, 0
@ -37,7 +37,7 @@ EvolveMon:
ld [wd0b5], a ld [wd0b5], a
call Evolution_LoadPic call Evolution_LoadPic
ld a, $1 ld a, $1
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
ld a, [wEvoOldSpecies] ld a, [wEvoOldSpecies]
call PlayCry call PlayCry
call WaitForSoundToFinish call WaitForSoundToFinish
@ -117,7 +117,7 @@ Evolution_BackAndForthAnim:
Evolution_ChangeMonPic: Evolution_ChangeMonPic:
push bc push bc
xor a xor a
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
coord hl, 7, 2 coord hl, 7, 2
lb bc, 7, 7 lb bc, 7, 7
ld de, SCREEN_WIDTH - 7 ld de, SCREEN_WIDTH - 7
@ -134,7 +134,7 @@ Evolution_ChangeMonPic:
dec b dec b
jr nz, .loop jr nz, .loop
ld a, 1 ld a, 1
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
call Delay3 call Delay3
pop bc pop bc
ret ret
@ -143,7 +143,7 @@ Evolution_CheckForCancel:
call DelayFrame call DelayFrame
push bc push bc
call JoypadLowSensitivity call JoypadLowSensitivity
ld a, [hJoy5] ldh a, [hJoy5]
pop bc pop bc
and B_BUTTON and B_BUTTON
jr nz, .pressedB jr nz, .pressedB

View file

@ -1,8 +1,8 @@
LoadShootingStarGraphics: LoadShootingStarGraphics:
ld a, $f9 ld a, $f9
ld [rOBP0], a ldh [rOBP0], a
ld a, $a4 ld a, $a4
ld [rOBP1], a ldh [rOBP1], a
ld de, AnimationTileset2 + $30 ; star tile (top left quadrant) ld de, AnimationTileset2 + $30 ; star tile (top left quadrant)
ld hl, vChars1 + $200 ld hl, vChars1 + $200
lb bc, BANK(AnimationTileset2), $01 lb bc, BANK(AnimationTileset2), $01
@ -201,9 +201,9 @@ MoveDownSmallStars:
jr nz, .innerLoop jr nz, .innerLoop
; Toggle the palette so that the lower star in the small stars tile blinks in ; Toggle the palette so that the lower star in the small stars tile blinks in
; and out. ; and out.
ld a, [rOBP1] ldh a, [rOBP1]
xor %10100000 xor %10100000
ld [rOBP1], a ldh [rOBP1], a
ld c, 3 ld c, 3
call CheckForUserInterruption call CheckForUserInterruption

View file

@ -19,12 +19,12 @@ AnimateHallOfFame:
call FillMemory call FillMemory
xor a xor a
ld [wUpdateSpritesEnabled], a ld [wUpdateSpritesEnabled], a
ld [hTilesetType], a ldh [hTilesetType], a
ld [wSpriteFlipped], a ld [wSpriteFlipped], a
ld [wLetterPrintingDelayFlags], a ; no delay ld [wLetterPrintingDelayFlags], a ; no delay
ld [wHoFMonOrPlayer], a ; mon ld [wHoFMonOrPlayer], a ; mon
inc a inc a
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
ld hl, wNumHoFTeams ld hl, wNumHoFTeams
ld a, [hl] ld a, [hl]
inc a inc a
@ -32,7 +32,7 @@ AnimateHallOfFame:
inc [hl] inc [hl]
.skipInc .skipInc
ld a, $90 ld a, $90
ld [hWY], a ldh [hWY], a
ld c, BANK(Music_HallOfFame) ld c, BANK(Music_HallOfFame)
ld a, MUSIC_HALL_OF_FAME ld a, MUSIC_HALL_OF_FAME
call PlayMusic call PlayMusic
@ -86,7 +86,7 @@ AnimateHallOfFame:
call HoFDisplayPlayerStats call HoFDisplayPlayerStats
call HoFFadeOutScreenAndMusic call HoFFadeOutScreenAndMusic
xor a xor a
ld [hWY], a ldh [hWY], a
ld hl, rLCDC ld hl, rLCDC
res 3, [hl] res 3, [hl]
ret ret
@ -97,9 +97,9 @@ HallOfFameText:
HoFShowMonOrPlayer: HoFShowMonOrPlayer:
call ClearScreen call ClearScreen
ld a, $d0 ld a, $d0
ld [hSCY], a ldh [hSCY], a
ld a, $c0 ld a, $c0
ld [hSCX], a ldh [hSCX], a
ld a, [wHoFMonSpecies] ld a, [wHoFMonSpecies]
ld [wcf91], a ld [wcf91], a
ld [wd0b5], a ld [wd0b5], a
@ -121,7 +121,7 @@ HoFShowMonOrPlayer:
ld c, 0 ld c, 0
call RunPaletteCommand call RunPaletteCommand
ld a, %11100100 ld a, %11100100
ld [rBGP], a ldh [rBGP], a
ld c, $31 ; back pic ld c, $31 ; back pic
call HoFLoadMonPlayerPicTileIDs call HoFLoadMonPlayerPicTileIDs
ld d, $a0 ld d, $a0
@ -133,7 +133,7 @@ HoFShowMonOrPlayer:
.next2 .next2
call .ScrollPic ; scroll back pic left call .ScrollPic ; scroll back pic left
xor a xor a
ld [hSCY], a ldh [hSCY], a
ld c, a ; front pic ld c, a ; front pic
call HoFLoadMonPlayerPicTileIDs call HoFLoadMonPlayerPicTileIDs
ld d, 0 ld d, 0
@ -142,9 +142,9 @@ HoFShowMonOrPlayer:
.ScrollPic .ScrollPic
call DelayFrame call DelayFrame
ld a, [hSCX] ldh a, [hSCX]
add e add e
ld [hSCX], a ldh [hSCX], a
cp d cp d
jr nz, .ScrollPic jr nz, .ScrollPic
ret ret

View file

@ -12,15 +12,15 @@ const_value = 3
PlayIntro: PlayIntro:
xor a xor a
ld [hJoyHeld], a ldh [hJoyHeld], a
inc a inc a
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
call PlayShootingStar call PlayShootingStar
call PlayIntroScene call PlayIntroScene
call GBFadeOutToWhite call GBFadeOutToWhite
xor a xor a
ld [hSCX], a ldh [hSCX], a
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
call ClearSprites call ClearSprites
call DelayFrame call DelayFrame
ret ret
@ -29,11 +29,11 @@ PlayIntroScene:
ld b, SET_PAL_NIDORINO_INTRO ld b, SET_PAL_NIDORINO_INTRO
call RunPaletteCommand call RunPaletteCommand
ldPal a, BLACK, DARK_GRAY, LIGHT_GRAY, WHITE ldPal a, BLACK, DARK_GRAY, LIGHT_GRAY, WHITE
ld [rBGP], a ldh [rBGP], a
ld [rOBP0], a ldh [rOBP0], a
ld [rOBP1], a ldh [rOBP1], a
xor a xor a
ld [hSCX], a ldh [hSCX], a
ld b, GENGAR_INTRO_TILES1 ld b, GENGAR_INTRO_TILES1
call IntroCopyTiles call IntroCopyTiles
ld a, 0 ld a, 0
@ -245,7 +245,7 @@ IntroMoveMon:
cp MOVE_GENGAR_LEFT cp MOVE_GENGAR_LEFT
jr z, .moveGengarLeft jr z, .moveGengarLeft
; move Gengar right ; move Gengar right
ld a, [hSCX] ldh a, [hSCX]
dec a dec a
dec a dec a
jr .next jr .next
@ -259,11 +259,11 @@ IntroMoveMon:
call UpdateIntroNidorinoOAM call UpdateIntroNidorinoOAM
pop de pop de
.moveGengarLeft .moveGengarLeft
ld a, [hSCX] ldh a, [hSCX]
inc a inc a
inc a inc a
.next .next
ld [hSCX], a ldh [hSCX], a
push de push de
ld c, 2 ld c, 2
call CheckForUserInterruption call CheckForUserInterruption
@ -313,7 +313,7 @@ PlayShootingStar:
call RunPaletteCommand call RunPaletteCommand
callba LoadCopyrightAndTextBoxTiles callba LoadCopyrightAndTextBoxTiles
ldPal a, BLACK, DARK_GRAY, LIGHT_GRAY, WHITE ldPal a, BLACK, DARK_GRAY, LIGHT_GRAY, WHITE
ld [rBGP], a ldh [rBGP], a
ld c, 180 ld c, 180
call DelayFrames call DelayFrames
call ClearScreen call ClearScreen

View file

@ -2,11 +2,11 @@ InitPlayerData:
InitPlayerData2: InitPlayerData2:
call Random call Random
ld a, [hRandomSub] ldh a, [hRandomSub]
ld [wPlayerID], a ld [wPlayerID], a
call Random call Random
ld a, [hRandomAdd] ldh a, [hRandomAdd]
ld [wPlayerID + 1], a ld [wPlayerID + 1], a
ld a, $ff ld a, $ff

View file

@ -52,7 +52,7 @@ OakSpeech:
ld [wDestinationMap], a ld [wDestinationMap], a
call SpecialWarpIn call SpecialWarpIn
xor a xor a
ld [hTilesetType], a ldh [hTilesetType], a
ld a, [wd732] ld a, [wd732]
bit 1, a ; possibly a debug mode bit bit 1, a ; possibly a debug mode bit
jp nz, .skipChoosingNames jp nz, .skipChoosingNames
@ -104,12 +104,12 @@ OakSpeech:
ld hl, OakSpeechText3 ld hl, OakSpeechText3
call PrintText call PrintText
.next .next
ld a, [hLoadedROMBank] ldh a, [hLoadedROMBank]
push af push af
ld a, SFX_SHRINK ld a, SFX_SHRINK
call PlaySound call PlaySound
pop af pop af
ld [hLoadedROMBank], a ldh [hLoadedROMBank], a
ld [MBC1RomBank], a ld [MBC1RomBank], a
ld c, 4 ld c, 4
call DelayFrames call DelayFrames
@ -126,7 +126,7 @@ OakSpeech:
lb bc, BANK(ShrinkPic2), $00 lb bc, BANK(ShrinkPic2), $00
call IntroDisplayPicCenteredOrUpperRight call IntroDisplayPicCenteredOrUpperRight
call ResetPlayerSpriteData call ResetPlayerSpriteData
ld a, [hLoadedROMBank] ldh a, [hLoadedROMBank]
push af push af
ld a, BANK(Music_PalletTown) ld a, BANK(Music_PalletTown)
ld [wAudioROMBank], a ld [wAudioROMBank], a
@ -137,7 +137,7 @@ OakSpeech:
ld [wNewSoundID], a ld [wNewSoundID], a
call PlaySound call PlaySound
pop af pop af
ld [hLoadedROMBank], a ldh [hLoadedROMBank], a
ld [MBC1RomBank], a ld [MBC1RomBank], a
ld c, 20 ld c, 20
call DelayFrames call DelayFrames
@ -175,7 +175,7 @@ FadeInIntroPic:
ld b, 6 ld b, 6
.next .next
ld a, [hli] ld a, [hli]
ld [rBGP], a ldh [rBGP], a
ld c, 10 ld c, 10
call DelayFrames call DelayFrames
dec b dec b
@ -192,18 +192,18 @@ IntroFadePalettes:
MovePicLeft: MovePicLeft:
ld a, 119 ld a, 119
ld [rWX], a ldh [rWX], a
call DelayFrame call DelayFrame
ld a, %11100100 ld a, %11100100
ld [rBGP], a ldh [rBGP], a
.next .next
call DelayFrame call DelayFrame
ld a, [rWX] ldh a, [rWX]
sub 8 sub 8
cp $FF cp $FF
ret z ret z
ld [rWX], a ldh [rWX], a
jr .next jr .next
DisplayPicCenteredOrUpperRight: DisplayPicCenteredOrUpperRight:
@ -229,5 +229,5 @@ IntroDisplayPicCenteredOrUpperRight:
coord hl, 6, 4 coord hl, 6, 4
.next .next
xor a xor a
ld [hStartTileID], a ldh [hStartTileID], a
predef_jump CopyUncompressedPicToTilemap predef_jump CopyUncompressedPicToTilemap

View file

@ -90,13 +90,13 @@ OakSpeechSlidePicCommon:
push hl push hl
push de push de
push bc push bc
ld [hSlideDirection], a ldh [hSlideDirection], a
ld a, d ld a, d
ld [hSlideAmount], a ldh [hSlideAmount], a
ld a, e ld a, e
ld [hSlidingRegionSize], a ldh [hSlidingRegionSize], a
ld c, a ld c, a
ld a, [hSlideDirection] ldh a, [hSlideDirection]
and a and a
jr nz, .next jr nz, .next
; If sliding right, point hl to the end of the pic's tiles. ; If sliding right, point hl to the end of the pic's tiles.
@ -107,8 +107,8 @@ OakSpeechSlidePicCommon:
ld e, l ld e, l
.loop .loop
xor a xor a
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
ld a, [hSlideDirection] ldh a, [hSlideDirection]
and a and a
jr nz, .slideLeft jr nz, .slideLeft
; sliding right ; sliding right
@ -123,7 +123,7 @@ OakSpeechSlidePicCommon:
.next2 .next2
dec c dec c
jr nz, .loop jr nz, .loop
ld a, [hSlideDirection] ldh a, [hSlideDirection]
and a and a
jr z, .next3 jr z, .next3
; If sliding left, we need to zero the last tile in the pic (there is no need ; If sliding left, we need to zero the last tile in the pic (there is no need
@ -134,13 +134,13 @@ OakSpeechSlidePicCommon:
ld [hl], a ld [hl], a
.next3 .next3
ld a, 1 ld a, 1
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
call Delay3 call Delay3
ld a, [hSlidingRegionSize] ldh a, [hSlidingRegionSize]
ld c, a ld c, a
ld h, d ld h, d
ld l, e ld l, e
ld a, [hSlideDirection] ldh a, [hSlideDirection]
and a and a
jr nz, .slideLeft2 jr nz, .slideLeft2
inc hl inc hl
@ -150,9 +150,9 @@ OakSpeechSlidePicCommon:
.next4 .next4
ld d, h ld d, h
ld e, l ld e, l
ld a, [hSlideAmount] ldh a, [hSlideAmount]
dec a dec a
ld [hSlideAmount], a ldh [hSlideAmount], a
jr nz, .loop jr nz, .loop
pop bc pop bc
pop de pop de

View file

@ -11,7 +11,7 @@ SetDefaultNamesBeforeTitlescreen::
ld de, wRivalName ld de, wRivalName
call CopyFixedLengthText call CopyFixedLengthText
xor a xor a
ld [hWY], a ldh [hWY], a
ld [wLetterPrintingDelayFlags], a ld [wLetterPrintingDelayFlags], a
ld hl, wd732 ld hl, wd732
ld [hli], a ld [hli], a
@ -24,14 +24,14 @@ SetDefaultNamesBeforeTitlescreen::
DisplayTitleScreen: DisplayTitleScreen:
call GBPalWhiteOut call GBPalWhiteOut
ld a, $1 ld a, $1
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
xor a xor a
ld [hTilesetType], a ldh [hTilesetType], a
ld [hSCX], a ldh [hSCX], a
ld a, $40 ld a, $40
ld [hSCY], a ldh [hSCY], a
ld a, $90 ld a, $90
ld [hWY], a ldh [hWY], a
call ClearScreen call ClearScreen
call DisableLCD call DisableLCD
call LoadFontTilePatterns call LoadFontTilePatterns
@ -130,7 +130,7 @@ ENDC
call TitleScreenCopyTileMapToVRAM call TitleScreenCopyTileMapToVRAM
call SaveScreenTilesToBuffer1 call SaveScreenTilesToBuffer1
ld a, $40 ld a, $40
ld [hWY], a ldh [hWY], a
call LoadScreenTilesFromBuffer2 call LoadScreenTilesFromBuffer2
ld a, vBGMap0 / $100 ld a, vBGMap0 / $100
call TitleScreenCopyTileMapToVRAM call TitleScreenCopyTileMapToVRAM
@ -138,7 +138,7 @@ ENDC
call RunPaletteCommand call RunPaletteCommand
call GBPalNormal call GBPalNormal
ld a, %11100100 ld a, %11100100
ld [rOBP0], a ldh [rOBP0], a
; make pokemon logo bounce up and down ; make pokemon logo bounce up and down
ld bc, hSCY ; background scroll Y ld bc, hSCY ; background scroll Y
@ -190,7 +190,7 @@ ENDC
; scroll game version in from the right ; scroll game version in from the right
call PrintGameVersionOnTitleScreen call PrintGameVersionOnTitleScreen
ld a, SCREEN_HEIGHT_PX ld a, SCREEN_HEIGHT_PX
ld [hWY], a ldh [hWY], a
ld d, 144 ld d, 144
.scrollTitleScreenGameVersionLoop .scrollTitleScreenGameVersionLoop
ld h, d ld h, d
@ -237,9 +237,9 @@ ENDC
call GBPalWhiteOutWithDelay3 call GBPalWhiteOutWithDelay3
call ClearSprites call ClearSprites
xor a xor a
ld [hWY], a ldh [hWY], a
inc a inc a
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
call ClearScreen call ClearScreen
ld a, vBGMap0 / $100 ld a, vBGMap0 / $100
call TitleScreenCopyTileMapToVRAM call TitleScreenCopyTileMapToVRAM
@ -247,7 +247,7 @@ ENDC
call TitleScreenCopyTileMapToVRAM call TitleScreenCopyTileMapToVRAM
call Delay3 call Delay3
call LoadGBPal call LoadGBPal
ld a, [hJoyHeld] ldh a, [hJoyHeld]
ld b, a ld b, a
and D_UP | SELECT | B_BUTTON and D_UP | SELECT | B_BUTTON
cp D_UP | SELECT | B_BUTTON cp D_UP | SELECT | B_BUTTON
@ -280,7 +280,7 @@ TitleScreenPickNewMon:
call LoadTitleMonSprite call LoadTitleMonSprite
ld a, $90 ld a, $90
ld [hWY], a ldh [hWY], a
ld d, 1 ; scroll out ld d, 1 ; scroll out
callba TitleScroll callba TitleScroll
ret ret
@ -289,20 +289,20 @@ TitleScreenScrollInMon:
ld d, 0 ; scroll in ld d, 0 ; scroll in
callba TitleScroll callba TitleScroll
xor a xor a
ld [hWY], a ldh [hWY], a
ret ret
ScrollTitleScreenGameVersion: ScrollTitleScreenGameVersion:
.wait .wait
ld a, [rLY] ldh a, [rLY]
cp l cp l
jr nz, .wait jr nz, .wait
ld a, h ld a, h
ld [rSCX], a ldh [rSCX], a
.wait2 .wait2
ld a, [rLY] ldh a, [rLY]
cp h cp h
jr z, .wait2 jr z, .wait2
ret ret
@ -358,12 +358,12 @@ LoadTitleMonSprite:
jp LoadFrontSpriteByMonIndex jp LoadFrontSpriteByMonIndex
TitleScreenCopyTileMapToVRAM: TitleScreenCopyTileMapToVRAM:
ld [hAutoBGTransferDest + 1], a ldh [hAutoBGTransferDest + 1], a
jp Delay3 jp Delay3
LoadCopyrightAndTextBoxTiles: LoadCopyrightAndTextBoxTiles:
xor a xor a
ld [hWY], a ldh [hWY], a
call ClearScreen call ClearScreen
call LoadTextBoxTilePatterns call LoadTextBoxTilePatterns

View file

@ -69,15 +69,15 @@ _TitleScroll:
.ScrollBetween: .ScrollBetween:
.wait .wait
ld a, [rLY] ; rLY ldh a, [rLY] ; rLY
cp l cp l
jr nz, .wait jr nz, .wait
ld a, h ld a, h
ld [rSCX], a ldh [rSCX], a
.wait2 .wait2
ld a, [rLY] ; rLY ldh a, [rLY] ; rLY
cp h cp h
jr z, .wait2 jr z, .wait2
ret ret

View file

@ -20,14 +20,14 @@ ExternalClockTradeAnim:
TradeAnimCommon: TradeAnimCommon:
ld a, [wOptions] ld a, [wOptions]
push af push af
ld a, [hSCY] ldh a, [hSCY]
push af push af
ld a, [hSCX] ldh a, [hSCX]
push af push af
xor a xor a
ld [wOptions], a ld [wOptions], a
ld [hSCY], a ldh [hSCY], a
ld [hSCX], a ldh [hSCX], a
push de push de
.loop .loop
pop de pop de
@ -49,9 +49,9 @@ TradeAnimCommon:
jp hl ; call trade func, which will return to the top of the loop jp hl ; call trade func, which will return to the top of the loop
.done .done
pop af pop af
ld [hSCX], a ldh [hSCX], a
pop af pop af
ld [hSCY], a ldh [hSCY], a
pop af pop af
ld [wOptions], a ld [wOptions], a
ret ret
@ -137,10 +137,10 @@ Trade_Delay100:
Trade_CopyTileMapToVRAM: Trade_CopyTileMapToVRAM:
ld a, $1 ld a, $1
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
call Delay3 call Delay3
xor a xor a
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
ret ret
Trade_Delay80: Trade_Delay80:
@ -181,10 +181,10 @@ LoadTradingGFXAndMonNames:
jr z, .next jr z, .next
ld a, $f0 ; SGB OBP0 ld a, $f0 ; SGB OBP0
.next .next
ld [rOBP0], a ldh [rOBP0], a
call EnableLCD call EnableLCD
xor a xor a
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
ld a, [wTradedPlayerMonSpecies] ld a, [wTradedPlayerMonSpecies]
ld [wd11e], a ld [wd11e], a
call GetMonName call GetMonName
@ -198,7 +198,7 @@ LoadTradingGFXAndMonNames:
Trade_LoadMonPartySpriteGfx: Trade_LoadMonPartySpriteGfx:
ld a, %11010000 ld a, %11010000
ld [rOBP1], a ldh [rOBP1], a
jpba LoadMonPartySpriteGfx jpba LoadMonPartySpriteGfx
Trade_SwapNames: Trade_SwapNames:
@ -224,14 +224,14 @@ Trade_Cleanup:
Trade_ShowPlayerMon: Trade_ShowPlayerMon:
ld a, %10101011 ld a, %10101011
ld [rLCDC], a ldh [rLCDC], a
ld a, $50 ld a, $50
ld [hWY], a ldh [hWY], a
ld a, $86 ld a, $86
ld [rWX], a ldh [rWX], a
ld [hSCX], a ldh [hSCX], a
xor a xor a
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
coord hl, 4, 0 coord hl, 4, 0
ld b, 6 ld b, 6
ld c, 10 ld c, 10
@ -247,8 +247,8 @@ Trade_ShowPlayerMon:
push af push af
call DelayFrame call DelayFrame
pop af pop af
ld [rWX], a ldh [rWX], a
ld [hSCX], a ldh [hSCX], a
dec a dec a
dec a dec a
and a and a
@ -261,7 +261,7 @@ Trade_ShowPlayerMon:
ld a, [wTradedPlayerMonSpecies] ld a, [wTradedPlayerMonSpecies]
call PlayCry call PlayCry
xor a xor a
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
ret ret
Trade_DrawOpenEndOfLinkCable: Trade_DrawOpenEndOfLinkCable:
@ -277,10 +277,10 @@ Trade_DrawOpenEndOfLinkCable:
call Trade_CopyCableTilesOffScreen call Trade_CopyCableTilesOffScreen
ld a, $a0 ld a, $a0
ld [hSCX], a ldh [hSCX], a
call DelayFrame call DelayFrame
ld a, %10001011 ld a, %10001011
ld [rLCDC], a ldh [rLCDC], a
coord hl, 6, 2 coord hl, 6, 2
ld b, $7 ; open end of link cable tile ID list index ld b, $7 ; open end of link cable tile ID list index
call CopyTileIDsFromList_ZeroBaseTileID call CopyTileIDsFromList_ZeroBaseTileID
@ -289,9 +289,9 @@ Trade_DrawOpenEndOfLinkCable:
call PlaySound call PlaySound
ld c, 20 ld c, 20
.loop .loop
ld a, [hSCX] ldh a, [hSCX]
add 4 add 4
ld [hSCX], a ldh [hSCX], a
dec c dec c
jr nz, .loop jr nz, .loop
ret ret
@ -302,7 +302,7 @@ Trade_AnimateBallEnteringLinkCable:
ld c, 10 ld c, 10
call DelayFrames call DelayFrames
ld a, %11100100 ld a, %11100100
ld [rOBP0], a ldh [rOBP0], a
xor a xor a
ld [wLinkCableAnimBulgeToggle], a ld [wLinkCableAnimBulgeToggle], a
lb bc, $20, $60 lb bc, $20, $60
@ -336,13 +336,13 @@ Trade_AnimateBallEnteringLinkCable:
.ballSpriteReachedEdgeOfScreen .ballSpriteReachedEdgeOfScreen
call ClearSprites call ClearSprites
ld a, $1 ld a, $1
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
call ClearScreen call ClearScreen
ld b, $98 ld b, $98
call CopyScreenTileBufferToVRAM call CopyScreenTileBufferToVRAM
call Delay3 call Delay3
xor a xor a
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
ret ret
Trade_BallInsideLinkCableOAM: Trade_BallInsideLinkCableOAM:
@ -360,13 +360,13 @@ Trade_ShowEnemyMon:
call Trade_PrintEnemyMonInfoText call Trade_PrintEnemyMonInfoText
call Trade_CopyTileMapToVRAM call Trade_CopyTileMapToVRAM
ld a, $1 ld a, $1
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
ld a, [wTradedEnemyMonSpecies] ld a, [wTradedEnemyMonSpecies]
call Trade_LoadMonSprite call Trade_LoadMonSprite
ld a, TRADE_BALL_POOF_ANIM ld a, TRADE_BALL_POOF_ANIM
call Trade_ShowAnimation call Trade_ShowAnimation
ld a, $1 ld a, $1
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
ld a, [wTradedEnemyMonSpecies] ld a, [wTradedEnemyMonSpecies]
call PlayCry call PlayCry
call Trade_Delay100 call Trade_Delay100
@ -381,7 +381,7 @@ Trade_AnimLeftToRight:
ld a, $1 ld a, $1
ld [wTradedMonMovingRight], a ld [wTradedMonMovingRight], a
ld a, %11100100 ld a, %11100100
ld [rOBP0], a ldh [rOBP0], a
ld a, $54 ld a, $54
ld [wBaseCoordX], a ld [wBaseCoordX], a
ld a, $1c ld a, $1c
@ -397,7 +397,7 @@ Trade_AnimLeftToRight:
ld b, $6 ld b, $6
call Trade_AnimMonMoveHorizontal call Trade_AnimMonMoveHorizontal
ld a, $1 ld a, $1
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
call Trade_DrawCableAcrossScreen call Trade_DrawCableAcrossScreen
ld b, $4 ld b, $4
call Trade_AnimMonMoveHorizontal call Trade_AnimMonMoveHorizontal
@ -405,7 +405,7 @@ Trade_AnimLeftToRight:
ld b, $6 ld b, $6
call Trade_AnimMonMoveHorizontal call Trade_AnimMonMoveHorizontal
xor a xor a
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
call Trade_AnimMonMoveVertical call Trade_AnimMonMoveVertical
jp ClearSprites jp ClearSprites
@ -430,7 +430,7 @@ Trade_AnimRightToLeft:
ld b, $6 ld b, $6
call Trade_AnimMonMoveHorizontal call Trade_AnimMonMoveHorizontal
ld a, $1 ld a, $1
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
call Trade_DrawCableAcrossScreen call Trade_DrawCableAcrossScreen
ld b, $4 ld b, $4
call Trade_AnimMonMoveHorizontal call Trade_AnimMonMoveHorizontal
@ -438,24 +438,24 @@ Trade_AnimRightToLeft:
ld b, $6 ld b, $6
call Trade_AnimMonMoveHorizontal call Trade_AnimMonMoveHorizontal
xor a xor a
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
jp ClearSprites jp ClearSprites
Trade_InitGameboyTransferGfx: Trade_InitGameboyTransferGfx:
; Initialises the graphics for showing a mon moving between gameboys. ; Initialises the graphics for showing a mon moving between gameboys.
ld a, $1 ld a, $1
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
call ClearScreen call ClearScreen
xor a xor a
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
call Trade_LoadMonPartySpriteGfx call Trade_LoadMonPartySpriteGfx
call DelayFrame call DelayFrame
ld a, %10101011 ld a, %10101011
ld [rLCDC], a ldh [rLCDC], a
xor a xor a
ld [hSCX], a ldh [hSCX], a
ld a, $90 ld a, $90
ld [hWY], a ldh [hWY], a
ret ret
Trade_DrawLeftGameboy: Trade_DrawLeftGameboy:
@ -555,11 +555,11 @@ Trade_CopyCableTilesOffScreen:
call CopyToRedrawRowOrColumnSrcTiles call CopyToRedrawRowOrColumnSrcTiles
pop hl pop hl
ld a, h ld a, h
ld [hRedrawRowOrColumnDest + 1], a ldh [hRedrawRowOrColumnDest + 1], a
ld a, l ld a, l
ld [hRedrawRowOrColumnDest], a ldh [hRedrawRowOrColumnDest], a
ld a, REDRAW_ROW ld a, REDRAW_ROW
ld [hRedrawRowOrColumnMode], a ldh [hRedrawRowOrColumnMode], a
ld c, 10 ld c, 10
jp DelayFrames jp DelayFrames
@ -574,14 +574,14 @@ Trade_AnimMonMoveHorizontal:
dec a dec a
jr z, .movingRight jr z, .movingRight
; moving left ; moving left
ld a, [hSCX] ldh a, [hSCX]
sub $2 sub $2
jr .next jr .next
.movingRight .movingRight
ld a, [hSCX] ldh a, [hSCX]
add $2 add $2
.next .next
ld [hSCX], a ldh [hSCX], a
call DelayFrame call DelayFrame
dec d dec d
jr nz, .scrollLoop jr nz, .scrollLoop
@ -596,9 +596,9 @@ Trade_AnimCircledMon:
push de push de
push bc push bc
push hl push hl
ld a, [rBGP] ldh a, [rBGP]
xor $3c ; make link cable flash xor $3c ; make link cable flash
ld [rBGP], a ldh [rBGP], a
ld hl, wOAMBuffer + $02 ld hl, wOAMBuffer + $02
ld de, $4 ld de, $4
ld c, $14 ld c, $14
@ -731,9 +731,9 @@ Trade_LoadMonSprite:
ld b, SET_PAL_POKEMON_WHOLE_SCREEN ld b, SET_PAL_POKEMON_WHOLE_SCREEN
ld c, 0 ld c, 0
call RunPaletteCommand call RunPaletteCommand
ld a, [hAutoBGTransferEnabled] ldh a, [hAutoBGTransferEnabled]
xor $1 xor $1
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
call GetMonHeader call GetMonHeader
coord hl, 7, 2 coord hl, 7, 2
call LoadFlippedFrontSpriteByMonIndex call LoadFlippedFrontSpriteByMonIndex
@ -743,16 +743,16 @@ Trade_LoadMonSprite:
Trade_ShowClearedWindow: Trade_ShowClearedWindow:
; clears the window and covers the BG entirely with the window ; clears the window and covers the BG entirely with the window
ld a, $1 ld a, $1
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
call ClearScreen call ClearScreen
ld a, %11100011 ld a, %11100011
ld [rLCDC], a ldh [rLCDC], a
ld a, $7 ld a, $7
ld [rWX], a ldh [rWX], a
xor a xor a
ld [hWY], a ldh [hWY], a
ld a, $90 ld a, $90
ld [hSCX], a ldh [hSCX], a
ret ret
Trade_SlideTextBoxOffScreen: Trade_SlideTextBoxOffScreen:
@ -764,17 +764,17 @@ Trade_SlideTextBoxOffScreen:
call DelayFrames call DelayFrames
.loop .loop
call DelayFrame call DelayFrame
ld a, [rWX] ldh a, [rWX]
inc a inc a
inc a inc a
ld [rWX], a ldh [rWX], a
cp $a1 cp $a1
jr nz, .loop jr nz, .loop
call Trade_ClearTileMap call Trade_ClearTileMap
ld c, 10 ld c, 10
call DelayFrames call DelayFrames
ld a, $7 ld a, $7
ld [rWX], a ldh [rWX], a
ret ret
PrintTradeWentToText: PrintTradeWentToText:

View file

@ -66,7 +66,7 @@ PalletMovementScript_OakMoveLeft:
call FillMemory call FillMemory
ld [hl], $ff ld [hl], $ff
ld a, [wSpriteIndex] ld a, [wSpriteIndex]
ld [hSpriteIndex], a ldh [hSpriteIndex], a
ld de, wNPCMovementDirections2 ld de, wNPCMovementDirections2
call MoveSprite call MoveSprite
ld a, $1 ld a, $1
@ -91,7 +91,7 @@ PalletMovementScript_PlayerMoveLeft:
ret nz ; return if Oak is still moving ret nz ; return if Oak is still moving
ld a, [wNumStepsToTake] ld a, [wNumStepsToTake]
ld [wSimulatedJoypadStatesIndex], a ld [wSimulatedJoypadStatesIndex], a
ld [hNPCMovementDirections2Index], a ldh [hNPCMovementDirections2Index], a
predef ConvertNPCMovementDirectionsToJoypadMasks predef ConvertNPCMovementDirectionsToJoypadMasks
call StartSimulatingJoypadStates call StartSimulatingJoypadStates
ld a, $2 ld a, $2
@ -282,7 +282,7 @@ FreezeEnemyTrainerSprite::
jr .loop jr .loop
.notRival .notRival
ld a, [wSpriteIndex] ld a, [wSpriteIndex]
ld [hSpriteIndex], a ldh [hSpriteIndex], a
jp SetSpriteMovementBytesToFF jp SetSpriteMovementBytesToFF
RivalIDs: RivalIDs:

View file

@ -1,14 +1,14 @@
ClearVariablesOnEnterMap:: ClearVariablesOnEnterMap::
ld a, SCREEN_HEIGHT_PX ld a, SCREEN_HEIGHT_PX
ld [hWY], a ldh [hWY], a
ld [rWY], a ldh [rWY], a
xor a xor a
ld [hAutoBGTransferEnabled], a ldh [hAutoBGTransferEnabled], a
ld [wStepCounter], a ld [wStepCounter], a
ld [wLoneAttackNo], a ld [wLoneAttackNo], a
ld [hJoyPressed], a ldh [hJoyPressed], a
ld [hJoyReleased], a ldh [hJoyReleased], a
ld [hJoyHeld], a ldh [hJoyHeld], a
ld [wActionResultOrTookBattleTurn], a ld [wActionResultOrTookBattleTurn], a
ld [wUnusedD5A3], a ld [wUnusedD5A3], a
ld hl, wCardKeyDoorY ld hl, wCardKeyDoorY

View file

@ -38,14 +38,14 @@ UsedCut:
call ClearSprites call ClearSprites
call RestoreScreenTilesAndReloadTilePatterns call RestoreScreenTilesAndReloadTilePatterns
ld a, SCREEN_HEIGHT_PX ld a, SCREEN_HEIGHT_PX
ld [hWY], a ldh [hWY], a
call Delay3 call Delay3
call LoadGBPal call LoadGBPal
call LoadCurrentMapView call LoadCurrentMapView
call SaveScreenTilesToBuffer2 call SaveScreenTilesToBuffer2
call Delay3 call Delay3
xor a xor a
ld [hWY], a ldh [hWY], a
ld hl, UsedCutText ld hl, UsedCutText
call PrintText call PrintText
call LoadScreenTilesFromBuffer2 call LoadScreenTilesFromBuffer2
@ -63,7 +63,7 @@ UsedCut:
ld a, SFX_CUT ld a, SFX_CUT
call PlaySound call PlaySound
ld a, $90 ld a, $90
ld [hWY], a ldh [hWY], a
call UpdateSprites call UpdateSprites
jp RedrawMapView jp RedrawMapView
@ -75,7 +75,7 @@ InitCutAnimOAM:
xor a xor a
ld [wWhichAnimationOffsets], a ld [wWhichAnimationOffsets], a
ld a, %11100100 ld a, %11100100
ld [rOBP1], a ldh [rOBP1], a
ld a, [wCutTile] ld a, [wCutTile]
cp $52 cp $52
jr z, .grass jr z, .grass

View file

@ -15,9 +15,9 @@ AnimCut:
ld [wCoordAdjustmentAmount], a ld [wCoordAdjustmentAmount], a
ld c, 2 ld c, 2
call AdjustOAMBlockXPos2 call AdjustOAMBlockXPos2
ld a, [rOBP1] ldh a, [rOBP1]
xor $64 xor $64
ld [rOBP1], a ldh [rOBP1], a
call DelayFrame call DelayFrame
pop bc pop bc
dec c dec c
@ -65,9 +65,9 @@ AnimCutGrass_UpdateOAMEntries:
ld [wCoordAdjustmentAmount], a ld [wCoordAdjustmentAmount], a
ld c, 1 ld c, 1
call AdjustOAMBlockXPos2 call AdjustOAMBlockXPos2
ld a, [rOBP1] ldh a, [rOBP1]
xor $64 xor $64
ld [rOBP1], a ldh [rOBP1], a
call DelayFrame call DelayFrame
pop bc pop bc
dec c dec c

View file

@ -6,7 +6,7 @@ AnimateBoulderDust:
ld a, $ff ld a, $ff
ld [wUpdateSpritesEnabled], a ld [wUpdateSpritesEnabled], a
ld a, %11100100 ld a, %11100100
ld [rOBP1], a ldh [rOBP1], a
call LoadSmokeTileFourTimes call LoadSmokeTileFourTimes
callba WriteCutOrBoulderDustAnimationOAMBlock callba WriteCutOrBoulderDustAnimationOAMBlock
ld c, 8 ; number of steps in animation ld c, 8 ; number of steps in animation
@ -18,9 +18,9 @@ AnimateBoulderDust:
ld c, 4 ld c, 4
jp hl jp hl
.returnAddress .returnAddress
ld a, [rOBP1] ldh a, [rOBP1]
xor %01100100 xor %01100100
ld [rOBP1], a ldh [rOBP1], a
call Delay3 call Delay3
pop bc pop bc
dec c dec c

View file

@ -6,7 +6,7 @@ ShakeElevator::
call Delay3 call Delay3
ld a, SFX_STOP_ALL_MUSIC ld a, SFX_STOP_ALL_MUSIC
call PlaySound call PlaySound
ld a, [hSCY] ldh a, [hSCY]
ld d, a ld d, a
ld e, $1 ld e, $1
ld b, 100 ld b, 100
@ -15,7 +15,7 @@ ShakeElevator::
xor $fe xor $fe
ld e, a ld e, a
add d add d
ld [hSCY], a ldh [hSCY], a
push bc push bc
ld c, BANK(SFX_Collision_1) ld c, BANK(SFX_Collision_1)
ld a, SFX_COLLISION ld a, SFX_COLLISION
@ -26,7 +26,7 @@ ShakeElevator::
dec b dec b
jr nz, .shakeLoop jr nz, .shakeLoop
ld a, d ld a, d
ld [hSCY], a ldh [hSCY], a
ld a, SFX_STOP_ALL_MUSIC ld a, SFX_STOP_ALL_MUSIC
call PlaySound call PlaySound
ld c, BANK(SFX_Safari_Zone_PA) ld c, BANK(SFX_Safari_Zone_PA)

View file

@ -8,10 +8,10 @@ AnimateHealingMachine:
push af push af
ld [hl], $ff ld [hl], $ff
push hl push hl
ld a, [rOBP1] ldh a, [rOBP1]
push af push af
ld a, $e0 ld a, $e0
ld [rOBP1], a ldh [rOBP1], a
ld hl, wOAMBuffer + $84 ld hl, wOAMBuffer + $84
ld de, PokeCenterOAMData ld de, PokeCenterOAMData
call CopyHealingMachineOAM call CopyHealingMachineOAM
@ -56,7 +56,7 @@ AnimateHealingMachine:
ld c, 32 ld c, 32
call DelayFrames call DelayFrames
pop af pop af
ld [rOBP1], a ldh [rOBP1], a
pop hl pop hl
pop af pop af
ld [hl], a ld [hl], a
@ -78,9 +78,9 @@ PokeCenterOAMData:
FlashSprite8Times: FlashSprite8Times:
ld b, 8 ld b, 8
.loop .loop
ld a, [rOBP1] ldh a, [rOBP1]
xor d xor d
ld [rOBP1], a ldh [rOBP1], a
ld c, 10 ld c, 10
call DelayFrames call DelayFrames
dec b dec b

View file

@ -58,7 +58,7 @@ CheckForHiddenObject::
ld [wHiddenObjectX], a ld [wHiddenObjectX], a
ld c, a ld c, a
call CheckIfCoordsInFrontOfPlayerMatch call CheckIfCoordsInFrontOfPlayerMatch
ld a, [hCoordsInFrontOfPlayerMatch] ldh a, [hCoordsInFrontOfPlayerMatch]
and a and a
jr z, .foundMatchingObject jr z, .foundMatchingObject
inc hl inc hl
@ -81,7 +81,7 @@ CheckForHiddenObject::
ret ret
.noMatch .noMatch
ld a, $ff ld a, $ff
ld [hDidntFindAnyHiddenObject], a ldh [hDidntFindAnyHiddenObject], a
ret ret
; checks if the coordinates in front of the player's sprite match Y in b and X in c ; checks if the coordinates in front of the player's sprite match Y in b and X in c
@ -127,7 +127,7 @@ CheckIfCoordsInFrontOfPlayerMatch:
.didNotMatch .didNotMatch
ld a, $ff ld a, $ff
.done .done
ld [hCoordsInFrontOfPlayerMatch], a ldh [hCoordsInFrontOfPlayerMatch], a
ret ret
INCLUDE "data/events/hidden_objects.asm" INCLUDE "data/events/hidden_objects.asm"

View file

@ -36,7 +36,7 @@ HandleLedges::
inc hl inc hl
jr .loop jr .loop
.foundMatch .foundMatch
ld a, [hJoyHeld] ldh a, [hJoyHeld]
and e and e
ret z ret z
ld a, $ff ld a, $ff

View file

@ -39,7 +39,7 @@ LoadMapSpriteTilePatterns:
ld b, $10 ; number of sprite slots ld b, $10 ; number of sprite slots
ld hl, wSpritePlayerStateData2PictureID ld hl, wSpritePlayerStateData2PictureID
xor a xor a
ld [hFourTileSpriteCount], a ldh [hFourTileSpriteCount], a
.copyPictureIDLoop ; loop to copy picture ID from $C2XD to $C2XE .copyPictureIDLoop ; loop to copy picture ID from $C2XD to $C2XE
ld a, [hli] ; $C2XD (sprite picture ID) ld a, [hli] ; $C2XD (sprite picture ID)
ld [hld], a ; $C2XE ld [hld], a ; $C2XE
@ -98,14 +98,14 @@ LoadMapSpriteTilePatterns:
cp SPRITE_BALL ; is it a 4-tile sprite? cp SPRITE_BALL ; is it a 4-tile sprite?
jr c, .notFourTileSprite jr c, .notFourTileSprite
pop af pop af
ld a, [hFourTileSpriteCount] ldh a, [hFourTileSpriteCount]
add 11 add 11
jr .storeVRAMSlot jr .storeVRAMSlot
.notFourTileSprite .notFourTileSprite
pop af pop af
.storeVRAMSlot .storeVRAMSlot
ld [hl], a ; store VRAM slot at $C2XE ld [hl], a ; store VRAM slot at $C2XE
ld [hVRAMSlot], a ; used to determine if it's 4-tile sprite later ldh [hVRAMSlot], a ; used to determine if it's 4-tile sprite later
ld a, b ; a = current sprite picture ID ld a, b ; a = current sprite picture ID
dec a dec a
add a add a
@ -128,7 +128,7 @@ LoadMapSpriteTilePatterns:
push bc push bc
ld hl, vNPCSprites ; VRAM base address ld hl, vNPCSprites ; VRAM base address
ld bc, $c0 ; number of bytes per VRAM slot ld bc, $c0 ; number of bytes per VRAM slot
ld a, [hVRAMSlot] ldh a, [hVRAMSlot]
cp 11 ; is it a 4-tile sprite? cp 11 ; is it a 4-tile sprite?
jr nc, .fourTileSpriteVRAMAddr jr nc, .fourTileSpriteVRAMAddr
ld d, a ld d, a
@ -141,13 +141,13 @@ LoadMapSpriteTilePatterns:
jr .loadStillTilePattern jr .loadStillTilePattern
.fourTileSpriteVRAMAddr .fourTileSpriteVRAMAddr
ld hl, vSprites + $7c0 ; address for second 4-tile sprite ld hl, vSprites + $7c0 ; address for second 4-tile sprite
ld a, [hFourTileSpriteCount] ldh a, [hFourTileSpriteCount]
and a and a
jr nz, .loadStillTilePattern jr nz, .loadStillTilePattern
; if it's the first 4-tile sprite ; if it's the first 4-tile sprite
ld hl, vSprites + $780 ; address for first 4-tile sprite ld hl, vSprites + $780 ; address for first 4-tile sprite
inc a inc a
ld [hFourTileSpriteCount], a ldh [hFourTileSpriteCount], a
.loadStillTilePattern .loadStillTilePattern
pop bc pop bc
pop de pop de
@ -167,7 +167,7 @@ LoadMapSpriteTilePatterns:
.skipFirstLoad .skipFirstLoad
pop de pop de
pop hl pop hl
ld a, [hVRAMSlot] ldh a, [hVRAMSlot]
cp 11 ; is it a 4-tile sprite? cp 11 ; is it a 4-tile sprite?
jr nc, .skipSecondLoad ; if so, there is no second block jr nc, .skipSecondLoad ; if so, there is no second block
push de push de

View file

@ -31,19 +31,19 @@ LoadMissableObjects:
sub d sub d
ld h, a ld h, a
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
xor a xor a
ld [hDividend+2], a ldh [hDividend+2], a
ld [hDividend+3], a ldh [hDividend+3], a
ld a, $3 ld a, $3
ld [hDivisor], a ldh [hDivisor], a
ld b, $2 ld b, $2
call Divide ; divide difference by 3, resulting in the global offset (number of missable items before ours) call Divide ; divide difference by 3, resulting in the global offset (number of missable items before ours)
ld a, [wCurMap] ld a, [wCurMap]
ld b, a ld b, a
ld a, [hDividend+3] ldh a, [hDividend+3]
ld c, a ; store global offset in c ld c, a ; store global offset in c
ld de, wMissableObjectList ld de, wMissableObjectList
pop hl pop hl
@ -99,7 +99,7 @@ InitializeMissableObjectsFlags:
; tests if current sprite is a missable object that is hidden/has been removed ; tests if current sprite is a missable object that is hidden/has been removed
IsObjectHidden: IsObjectHidden:
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
swap a swap a
ld b, a ld b, a
ld hl, wMissableObjectList ld hl, wMissableObjectList
@ -120,7 +120,7 @@ IsObjectHidden:
.notHidden .notHidden
xor a xor a
.hidden .hidden
ld [hIsHiddenMissableObject], a ldh [hIsHiddenMissableObject], a
ret ret
; adds missable object (items, leg. pokemon, etc.) to the map ; adds missable object (items, leg. pokemon, etc.) to the map

View file

@ -14,7 +14,7 @@ UpdatePlayerSprite:
; the maximum number for map tiles ; the maximum number for map tiles
.checkIfTextBoxInFrontOfSprite .checkIfTextBoxInFrontOfSprite
aCoord 8, 9 aCoord 8, 9
ld [hTilePlayerStandingOn], a ldh [hTilePlayerStandingOn], a
cp MAP_TILESET_SIZE cp MAP_TILESET_SIZE
jr c, .lowerLeftTileIsMapTile jr c, .lowerLeftTileIsMapTile
.disableSprite .disableSprite
@ -63,7 +63,7 @@ UpdatePlayerSprite:
ld a, [wd736] ld a, [wd736]
bit 7, a ; is the player sprite spinning due to a spin tile? bit 7, a ; is the player sprite spinning due to a spin tile?
jr nz, .skipSpriteAnim jr nz, .skipSpriteAnim
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
add $7 add $7
ld l, a ld l, a
ld a, [hl] ld a, [hl]
@ -89,7 +89,7 @@ UpdatePlayerSprite:
; lower priority than the background so that it's partially obscured by the ; lower priority than the background so that it's partially obscured by the
; grass. Only the lower half of the sprite is permitted to have the priority ; grass. Only the lower half of the sprite is permitted to have the priority
; bit set by later logic. ; bit set by later logic.
ld a, [hTilePlayerStandingOn] ldh a, [hTilePlayerStandingOn]
ld c, a ld c, a
ld a, [wGrassTile] ld a, [wGrassTile]
cp c cp c
@ -103,7 +103,7 @@ UpdatePlayerSprite:
UnusedReadSpriteDataFunction: UnusedReadSpriteDataFunction:
push bc push bc
push af push af
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
ld c, a ld c, a
pop af pop af
add c add c
@ -112,7 +112,7 @@ UnusedReadSpriteDataFunction:
ret ret
UpdateNPCSprite: UpdateNPCSprite:
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
swap a swap a
dec a dec a
add a add a
@ -122,7 +122,7 @@ UpdateNPCSprite:
ld a, [hl] ; read movement byte 2 ld a, [hl] ; read movement byte 2
ld [wCurSpriteMovement2], a ld [wCurSpriteMovement2], a
ld h, $c1 ld h, $c1
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
ld l, a ld l, a
inc l inc l
ld a, [hl] ; c1x1 ld a, [hl] ; c1x1
@ -131,7 +131,7 @@ UpdateNPCSprite:
call CheckSpriteAvailability call CheckSpriteAvailability
ret c ; if sprite is invisible, on tile >=MAP_TILESET_SIZE, in grass or player is currently walking ret c ; if sprite is invisible, on tile >=MAP_TILESET_SIZE, in grass or player is currently walking
ld h, $c1 ld h, $c1
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
ld l, a ld l, a
inc l inc l
ld a, [hl] ; c1x1 ld a, [hl] ; c1x1
@ -151,7 +151,7 @@ UpdateNPCSprite:
ret nz ; don't do anything yet if player is currently moving (redundant, already tested in CheckSpriteAvailability) ret nz ; don't do anything yet if player is currently moving (redundant, already tested in CheckSpriteAvailability)
call InitializeSpriteScreenPosition call InitializeSpriteScreenPosition
ld h, $c2 ld h, $c2
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
add $6 add $6
ld l, a ld l, a
ld a, [hl] ; c2x6: movement byte 1 ld a, [hl] ; c2x6: movement byte 1
@ -264,11 +264,11 @@ ChangeFacingDirection:
TryWalking: TryWalking:
push hl push hl
ld h, $c1 ld h, $c1
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
add $9 add $9
ld l, a ld l, a
ld [hl], c ; c1x9 (update facing direction) ld [hl], c ; c1x9 (update facing direction)
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
add $3 add $3
ld l, a ld l, a
ld [hl], d ; c1x3 (update Y movement delta) ld [hl], d ; c1x3 (update Y movement delta)
@ -282,7 +282,7 @@ TryWalking:
pop de pop de
ret c ; cannot walk there (reinitialization of delay values already done) ret c ; cannot walk there (reinitialization of delay values already done)
ld h, $c2 ld h, $c2
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
add $4 add $4
ld l, a ld l, a
ld a, [hl] ; c2x4: Y position ld a, [hl] ; c2x4: Y position
@ -291,7 +291,7 @@ TryWalking:
ld a, [hl] ; c2x5: X position ld a, [hl] ; c2x5: X position
add e add e
ld [hl], a ; update X position ld [hl], a ; update X position
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
ld l, a ld l, a
ld [hl], $10 ; c2x0=16: walk animation counter ld [hl], $10 ; c2x0=16: walk animation counter
dec h dec h
@ -301,7 +301,7 @@ TryWalking:
; update the walking animation parameters for a sprite that is currently walking ; update the walking animation parameters for a sprite that is currently walking
UpdateSpriteInWalkingAnimation: UpdateSpriteInWalkingAnimation:
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
add $7 add $7
ld l, a ld l, a
ld a, [hl] ; c1x7 (counter until next walk animation frame) ld a, [hl] ; c1x7 (counter until next walk animation frame)
@ -317,7 +317,7 @@ UpdateSpriteInWalkingAnimation:
and $3 and $3
ld [hl], a ; advance to next animation frame every 4 ticks (16 ticks total for one step) ld [hl], a ; advance to next animation frame every 4 ticks (16 ticks total for one step)
.noNextAnimationFrame .noNextAnimationFrame
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
add $3 add $3
ld l, a ld l, a
ld a, [hli] ; c1x3 (movement Y delta) ld a, [hli] ; c1x3 (movement Y delta)
@ -330,7 +330,7 @@ UpdateSpriteInWalkingAnimation:
ld a, [hl] ; c1x6 (screen X position) ld a, [hl] ; c1x6 (screen X position)
add b add b
ld [hl], a ; update screen X position ld [hl], a ; update screen X position
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
ld l, a ld l, a
inc h inc h
ld a, [hl] ; c2x0 (walk animation counter) ld a, [hl] ; c2x0 (walk animation counter)
@ -343,7 +343,7 @@ UpdateSpriteInWalkingAnimation:
ld a, [hl] ; c2x6 (movement byte 1) ld a, [hl] ; c2x6 (movement byte 1)
cp $fe cp $fe
jr nc, .initNextMovementCounter ; values $fe and $ff jr nc, .initNextMovementCounter ; values $fe and $ff
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
inc a inc a
ld l, a ld l, a
dec h dec h
@ -351,14 +351,14 @@ UpdateSpriteInWalkingAnimation:
ret ret
.initNextMovementCounter .initNextMovementCounter
call Random call Random
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
add $8 add $8
ld l, a ld l, a
ld a, [hRandomAdd] ldh a, [hRandomAdd]
and $7f and $7f
ld [hl], a ; c2x8: set next movement delay to a random value in [0,$7f] ld [hl], a ; c2x8: set next movement delay to a random value in [0,$7f]
dec h ; note that value 0 actually makes the delay $100 (bug?) dec h ; note that value 0 actually makes the delay $100 (bug?)
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
inc a inc a
ld l, a ld l, a
ld [hl], $2 ; c1x1 = 2 (movement status) ld [hl], $2 ; c1x1 = 2 (movement status)
@ -375,7 +375,7 @@ UpdateSpriteInWalkingAnimation:
; update delay value (c2x8) for sprites in the delayed state (c1x1) ; update delay value (c2x8) for sprites in the delayed state (c1x1)
UpdateSpriteMovementDelay: UpdateSpriteMovementDelay:
ld h, $c2 ld h, $c2
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
add $6 add $6
ld l, a ld l, a
ld a, [hl] ; c2x6: movement byte 1 ld a, [hl] ; c2x6: movement byte 1
@ -390,13 +390,13 @@ UpdateSpriteMovementDelay:
jr nz, notYetMoving jr nz, notYetMoving
.moving .moving
dec h dec h
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
inc a inc a
ld l, a ld l, a
ld [hl], $1 ; c1x1 = 1 (mark as ready to move) ld [hl], $1 ; c1x1 = 1 (mark as ready to move)
notYetMoving: notYetMoving:
ld h, wSpriteStateData1 / $100 ld h, wSpriteStateData1 / $100
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
add wSpritePlayerStateData1AnimFrameCounter - wSpritePlayerStateData1 add wSpritePlayerStateData1AnimFrameCounter - wSpritePlayerStateData1
ld l, a ld l, a
ld [hl], $0 ; c1x8 = 0 (walk animation frame) ld [hl], $0 ; c1x8 = 0 (walk animation frame)
@ -429,7 +429,7 @@ MakeNPCFacePlayer:
.notFacingRight .notFacingRight
ld c, SPRITE_FACING_LEFT ld c, SPRITE_FACING_LEFT
.facingDirectionDetermined .facingDirectionDetermined
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
add $9 add $9
ld l, a ld l, a
ld [hl], c ; c1x9: set facing direction ld [hl], c ; c1x9: set facing direction
@ -440,7 +440,7 @@ InitializeSpriteStatus:
inc l inc l
ld [hl], $ff ; $c1x2: set sprite image to $ff (invisible/off screen) ld [hl], $ff ; $c1x2: set sprite image to $ff (invisible/off screen)
inc h inc h
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
add $2 add $2
ld l, a ld l, a
ld a, $8 ld a, $8
@ -451,7 +451,7 @@ InitializeSpriteStatus:
; calculates the sprite's screen position form its map position and the player position ; calculates the sprite's screen position form its map position and the player position
InitializeSpriteScreenPosition: InitializeSpriteScreenPosition:
ld h, wSpriteStateData2 / $100 ld h, wSpriteStateData2 / $100
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
add wSpritePlayerStateData2MapY - wSpritePlayerStateData2 add wSpritePlayerStateData2MapY - wSpritePlayerStateData2
ld l, a ld l, a
ld a, [wYCoord] ld a, [wYCoord]
@ -475,17 +475,17 @@ InitializeSpriteScreenPosition:
; tests if sprite is off screen or otherwise unable to do anything ; tests if sprite is off screen or otherwise unable to do anything
CheckSpriteAvailability: CheckSpriteAvailability:
predef IsObjectHidden predef IsObjectHidden
ld a, [hIsHiddenMissableObject] ldh a, [hIsHiddenMissableObject]
and a and a
jp nz, .spriteInvisible jp nz, .spriteInvisible
ld h, wSpriteStateData2 / $100 ld h, wSpriteStateData2 / $100
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
add wSpritePlayerStateData2MovementByte1 - wSpritePlayerStateData2 add wSpritePlayerStateData2MovementByte1 - wSpritePlayerStateData2
ld l, a ld l, a
ld a, [hl] ; c2x6: movement byte 1 ld a, [hl] ; c2x6: movement byte 1
cp $fe cp $fe
jr c, .skipXVisibilityTest ; movement byte 1 < $fe (i.e. the sprite's movement is scripted) jr c, .skipXVisibilityTest ; movement byte 1 < $fe (i.e. the sprite's movement is scripted)
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
add wSpritePlayerStateData2MapY - wSpritePlayerStateData2 add wSpritePlayerStateData2MapY - wSpritePlayerStateData2
ld l, a ld l, a
ld b, [hl] ; c2x4: Y pos (+4) ld b, [hl] ; c2x4: Y pos (+4)
@ -527,7 +527,7 @@ CheckSpriteAvailability:
jr c, .spriteVisible ; standing on tile with ID >=MAP_TILESET_SIZE (top right tile) jr c, .spriteVisible ; standing on tile with ID >=MAP_TILESET_SIZE (top right tile)
.spriteInvisible .spriteInvisible
ld h, wSpriteStateData1 / $100 ld h, wSpriteStateData1 / $100
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
add wSpritePlayerStateData1ImageIndex - wSpritePlayerStateData1 add wSpritePlayerStateData1ImageIndex - wSpritePlayerStateData1
ld l, a ld l, a
ld [hl], $ff ; c1x2 ld [hl], $ff ; c1x2
@ -540,7 +540,7 @@ CheckSpriteAvailability:
jr nz, .done ; if player is currently walking, we're done jr nz, .done ; if player is currently walking, we're done
call UpdateSpriteImage call UpdateSpriteImage
inc h inc h
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
add $7 add $7
ld l, a ld l, a
ld a, [wGrassTile] ld a, [wGrassTile]
@ -556,7 +556,7 @@ CheckSpriteAvailability:
UpdateSpriteImage: UpdateSpriteImage:
ld h, $c1 ld h, $c1
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
add $8 add $8
ld l, a ld l, a
ld a, [hli] ; c1x8: walk animation frame ld a, [hli] ; c1x8: walk animation frame
@ -564,10 +564,10 @@ UpdateSpriteImage:
ld a, [hl] ; c1x9: facing direction ld a, [hl] ; c1x9: facing direction
add b add b
ld b, a ld b, a
ld a, [hTilePlayerStandingOn] ldh a, [hTilePlayerStandingOn]
add b add b
ld b, a ld b, a
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
add $2 add $2
ld l, a ld l, a
ld [hl], b ; c1x2: sprite to display ld [hl], b ; c1x2: sprite to display
@ -581,7 +581,7 @@ UpdateSpriteImage:
; set carry on failure, clears carry on success ; set carry on failure, clears carry on success
CanWalkOntoTile: CanWalkOntoTile:
ld h, wSpriteStateData2 / $100 ld h, wSpriteStateData2 / $100
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
add wSpritePlayerStateData2MovementByte1 - wSpritePlayerStateData2 add wSpritePlayerStateData2MovementByte1 - wSpritePlayerStateData2
ld l, a ld l, a
ld a, [hl] ; c2x6 (movement byte 1) ld a, [hl] ; c2x6 (movement byte 1)
@ -602,14 +602,14 @@ CanWalkOntoTile:
cp c cp c
jr nz, .tilePassableLoop jr nz, .tilePassableLoop
ld h, $c2 ld h, $c2
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
add $6 add $6
ld l, a ld l, a
ld a, [hl] ; $c2x6 (movement byte 1) ld a, [hl] ; $c2x6 (movement byte 1)
inc a inc a
jr z, .impassable ; if $ff, no movement allowed (however, changing direction is) jr z, .impassable ; if $ff, no movement allowed (however, changing direction is)
ld h, wSpriteStateData1 / $100 ld h, wSpriteStateData1 / $100
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
add wSpritePlayerStateData1YPixels - wSpritePlayerStateData1 add wSpritePlayerStateData1YPixels - wSpritePlayerStateData1
ld l, a ld l, a
ld a, [hli] ; c1x4 (screen Y pos) ld a, [hli] ; c1x4 (screen Y pos)
@ -628,14 +628,14 @@ CanWalkOntoTile:
pop bc pop bc
pop de pop de
ld h, wSpriteStateData1 / $100 ld h, wSpriteStateData1 / $100
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
add $c add $c
ld l, a ld l, a
ld a, [hl] ; c1xc (directions in which sprite collision would occur) ld a, [hl] ; c1xc (directions in which sprite collision would occur)
and b ; check against chosen direction (1,2,4 or 8) and b ; check against chosen direction (1,2,4 or 8)
jr nz, .impassable ; collision between sprites, don't go there jr nz, .impassable ; collision between sprites, don't go there
ld h, wSpriteStateData2 / $100 ld h, wSpriteStateData2 / $100
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
add wSpritePlayerStateData2YDisplacement - wSpritePlayerStateData2 add wSpritePlayerStateData2YDisplacement - wSpritePlayerStateData2
ld l, a ld l, a
ld a, [hli] ; c2x2 (sprite Y displacement, initialized at $8, keep track of where a sprite did go) ld a, [hli] ; c2x2 (sprite Y displacement, initialized at $8, keep track of where a sprite did go)
@ -666,7 +666,7 @@ CanWalkOntoTile:
ret ret
.impassable .impassable
ld h, wSpriteStateData1 / $100 ld h, wSpriteStateData1 / $100
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
inc a inc a
ld l, a ld l, a
ld [hl], $2 ; c1x1 = 2 (set movement status to delayed) ld [hl], $2 ; c1x1 = 2 (set movement status to delayed)
@ -677,11 +677,11 @@ CanWalkOntoTile:
inc l inc l
ld [hl], a ; c1x5 = 0 (clear X movement delta) ld [hl], a ; c1x5 = 0 (clear X movement delta)
inc h inc h
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
add $8 add $8
ld l, a ld l, a
call Random call Random
ld a, [hRandomAdd] ldh a, [hRandomAdd]
and $7f and $7f
ld [hl], a ; c2x8: set next movement delay to a random value in [0,$7f] (again with delay $100 if value is 0) ld [hl], a ; c2x8: set next movement delay to a random value in [0,$7f] (again with delay $100 if value is 0)
scf ; set carry (marking failure to walk) scf ; set carry (marking failure to walk)
@ -692,7 +692,7 @@ CanWalkOntoTile:
; hl: output pointer ; hl: output pointer
GetTileSpriteStandsOn: GetTileSpriteStandsOn:
ld h, wSpriteStateData1 / $100 ld h, wSpriteStateData1 / $100
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
add wSpritePlayerStateData1YPixels - wSpritePlayerStateData1 add wSpritePlayerStateData1YPixels - wSpritePlayerStateData1
ld l, a ld l, a
ld a, [hli] ; c1x4: screen Y position ld a, [hli] ; c1x4: screen Y position
@ -784,7 +784,7 @@ DoScriptedNPCMovement:
ld a, [hl] ld a, [hl]
add b add b
ld [hl], a ld [hl], a
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
add $9 add $9
ld l, a ld l, a
ld a, c ld a, c
@ -817,7 +817,7 @@ GetSpriteScreenXPointer:
GetSpriteScreenXYPointerCommon: GetSpriteScreenXYPointerCommon:
ld hl, wSpriteStateData1 ld hl, wSpriteStateData1
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
add l add l
add b add b
ld l, a ld l, a
@ -825,7 +825,7 @@ GetSpriteScreenXYPointerCommon:
AnimScriptedNPCMovement: AnimScriptedNPCMovement:
ld hl, wSpriteStateData2 ld hl, wSpriteStateData2
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
add wSpritePlayerStateData2ImageBaseOffset - wSpritePlayerStateData2 add wSpritePlayerStateData2ImageBaseOffset - wSpritePlayerStateData2
ld l, a ld l, a
ld a, [hl] ; VRAM slot ld a, [hl] ; VRAM slot
@ -833,7 +833,7 @@ AnimScriptedNPCMovement:
swap a swap a
ld b, a ld b, a
ld hl, wSpriteStateData1 ld hl, wSpriteStateData1
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
add wSpritePlayerStateData1FacingDirection - wSpritePlayerStateData1 add wSpritePlayerStateData1FacingDirection - wSpritePlayerStateData1
ld l, a ld l, a
ld a, [hl] ; facing direction ld a, [hl] ; facing direction
@ -849,21 +849,21 @@ AnimScriptedNPCMovement:
.anim .anim
add b add b
ld b, a ld b, a
ld [hSpriteVRAMSlotAndFacing], a ldh [hSpriteVRAMSlotAndFacing], a
call AdvanceScriptedNPCAnimFrameCounter call AdvanceScriptedNPCAnimFrameCounter
ld hl, wSpriteStateData1 ld hl, wSpriteStateData1
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
add wSpritePlayerStateData1ImageIndex - wSpritePlayerStateData1 add wSpritePlayerStateData1ImageIndex - wSpritePlayerStateData1
ld l, a ld l, a
ld a, [hSpriteVRAMSlotAndFacing] ldh a, [hSpriteVRAMSlotAndFacing]
ld b, a ld b, a
ld a, [hSpriteAnimFrameCounter] ldh a, [hSpriteAnimFrameCounter]
add b add b
ld [hl], a ld [hl], a
ret ret
AdvanceScriptedNPCAnimFrameCounter: AdvanceScriptedNPCAnimFrameCounter:
ld a, [hCurrentSpriteOffset] ldh a, [hCurrentSpriteOffset]
add $7 add $7
ld l, a ld l, a
ld a, [hl] ; intra-animation frame counter ld a, [hl] ; intra-animation frame counter
@ -878,5 +878,5 @@ AdvanceScriptedNPCAnimFrameCounter:
inc a inc a
and $3 and $3
ld [hl], a ld [hl], a
ld [hSpriteAnimFrameCounter], a ldh [hSpriteAnimFrameCounter], a
ret ret

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