diff options
320 files changed, 6366 insertions, 6390 deletions
@@ -58,7 +58,7 @@ tools: $(MAKE) -C tools/ -RGBASMFLAGS = -h -Weverything +RGBASMFLAGS = -h -L -Weverything # Create a sym/map for debug purposes if `make` run with `DEBUG=1` ifeq ($(DEBUG),1) RGBASMFLAGS += -E diff --git a/audio/engine_1.asm b/audio/engine_1.asm index 20b992aa..8af8f707 100644 --- a/audio/engine_1.asm +++ b/audio/engine_1.asm @@ -20,10 +20,10 @@ Audio1_UpdateMusic:: set 7, a ld [wMuteAudioAndPauseMusic], a xor a ; disable all channels' output - ld [rNR51], a - ld [rNR30], a + ldh [rNR51], a + ldh [rNR30], a ld a, $80 - ld [rNR30], a + ldh [rNR30], a jr .nextChannel .applyAffects call Audio1_ApplyMusicAffects @@ -183,9 +183,9 @@ Audio1_sound_ret: jr nz, .skipSfxChannel3 ; restart hardware channel 3 (wave channel) output ld a, $0 - ld [rNR30], a + ldh [rNR30], a ld a, $80 - ld [rNR30], a + ldh [rNR30], a .skipSfxChannel3 jr nz, .dontDisable ld a, [wDisableChannelOutputWhenSfxEnds] @@ -219,9 +219,9 @@ Audio1_sound_ret: .disableChannelOutput ld hl, Audio1_HWChannelDisableMasks add hl, bc - ld a, [rNR51] + ldh a, [rNR51] and [hl] - ld [rNR51], a + ldh [rNR51], a .afterDisable ld a, [wChannelSoundIDs + Ch5] cp CRY_SFX_START @@ -241,7 +241,7 @@ Audio1_sound_ret: ret c .skipRewind ld a, [wSavedVolume] - ld [rNR50], a + ldh [rNR50], a xor a ld [wSavedVolume], a .skipCry @@ -548,7 +548,7 @@ Audio1_volume: cp $f0 ; is this command a volume? jr nz, Audio1_execute_music ; no call Audio1_GetNextMusicByte - ld [rNR50], a ; store volume + ldh [rNR50], a ; store volume jp Audio1_sound_ret Audio1_execute_music: @@ -638,7 +638,7 @@ Audio1_pitch_sweep: bit BIT_EXECUTE_MUSIC, [hl] jr nz, Audio1_note ; no call Audio1_GetNextMusicByte - ld [rNR10], a + ldh [rNR10], a jp Audio1_sound_ret Audio1_note: @@ -770,9 +770,9 @@ Audio1_note_pitch: ld b, 0 ld hl, Audio1_HWChannelDisableMasks add hl, bc - ld a, [rNR51] + ldh a, [rNR51] and [hl] - ld [rNR51], a ; disable hardware channel 3's output + ldh [rNR51], a ; disable hardware channel 3's output jr .done .notChannel3 ld b, REG_VOLUME_ENVELOPE @@ -844,7 +844,7 @@ Audio1_EnableChannelOutput: ld b, 0 ld hl, Audio1_HWChannelEnableMasks add hl, bc - ld a, [rNR51] + ldh a, [rNR51] or [hl] ; set this channel's bits ld d, a ld a, c @@ -866,7 +866,7 @@ Audio1_EnableChannelOutput: add hl, bc and [hl] ld d, a - ld a, [rNR51] + ldh a, [rNR51] ld hl, Audio1_HWChannelDisableMasks add hl, bc and [hl] ; reset this channel's output bits @@ -874,7 +874,7 @@ Audio1_EnableChannelOutput: ld d, a .skip ld a, d - ld [rNR51], a + ldh [rNR51], a ret Audio1_ApplyDutyCycleAndSoundLength: @@ -928,7 +928,7 @@ Audio1_ApplyWavePatternAndFrequency: ld hl, rWave_0 ld b, $f ld a, $0 ; stop hardware channel 3 - ld [rNR30], a + ldh [rNR30], a .loop ld a, [de] inc de @@ -938,7 +938,7 @@ Audio1_ApplyWavePatternAndFrequency: and a jr nz, .loop ld a, $80 ; start hardware channel 3 - ld [rNR30], a + ldh [rNR30], a pop de .notChannel3 ld a, d @@ -1399,17 +1399,17 @@ Audio1_PlaySound:: ld a, $ff ld [wStereoPanning], a xor a - ld [rNR50], a + ldh [rNR50], a ld a, $8 - ld [rNR10], a + ldh [rNR10], a ld a, 0 - ld [rNR51], a + ldh [rNR51], a xor a - ld [rNR30], a + ldh [rNR30], a ld a, $80 - ld [rNR30], a + ldh [rNR30], a ld a, $77 - ld [rNR50], a + ldh [rNR50], a jp .playSoundCommon .playSfx @@ -1555,7 +1555,7 @@ Audio1_PlaySound:: cp Ch5 jr nz, .skipSweepDisable ld a, $8 - ld [rNR10], a ; sweep off + ldh [rNR10], a ; sweep off .skipSweepDisable ld a, c and a @@ -1565,22 +1565,22 @@ Audio1_PlaySound:: .stopAllAudio ld a, $80 - ld [rNR52], a ; sound hardware on - ld [rNR30], a ; wave playback on + ldh [rNR52], a ; sound hardware on + ldh [rNR30], a ; wave playback on xor a - ld [rNR51], a ; no sound output - ld [rNR32], a ; mute channel 3 (wave channel) + ldh [rNR51], a ; no sound output + ldh [rNR32], a ; mute channel 3 (wave channel) ld a, $8 - ld [rNR10], a ; sweep off - ld [rNR12], a ; mute channel 1 (pulse channel 1) - ld [rNR22], a ; mute channel 2 (pulse channel 2) - ld [rNR42], a ; mute channel 4 (noise channel) + ldh [rNR10], a ; sweep off + ldh [rNR12], a ; mute channel 1 (pulse channel 1) + ldh [rNR22], a ; mute channel 2 (pulse channel 2) + ldh [rNR42], a ; mute channel 4 (noise channel) ld a, $40 - ld [rNR14], a ; counter mode - ld [rNR24], a - ld [rNR44], a + ldh [rNR14], a ; counter mode + ldh [rNR24], a + ldh [rNR44], a ld a, $77 - ld [rNR50], a ; full volume + ldh [rNR50], a ; full volume xor a ld [wUnusedC000], a ld [wDisableChannelOutputWhenSfxEnds], a @@ -1699,10 +1699,10 @@ Audio1_PlaySound:: ld a, [wSavedVolume] and a jr nz, .done - ld a, [rNR50] + ldh a, [rNR50] ld [wSavedVolume], a ld a, $77 - ld [rNR50], a ; full volume + ldh [rNR50], a ; full volume .done ret diff --git a/audio/engine_2.asm b/audio/engine_2.asm index 864a8c21..aa2c7227 100644 --- a/audio/engine_2.asm +++ b/audio/engine_2.asm @@ -22,10 +22,10 @@ Audio2_UpdateMusic:: set 7, a ld [wMuteAudioAndPauseMusic], a xor a ; disable all channels' output - ld [rNR51], a - ld [rNR30], a + ldh [rNR51], a + ldh [rNR30], a ld a, $80 - ld [rNR30], a + ldh [rNR30], a jr .nextChannel .applyAffects call Audio2_ApplyMusicAffects @@ -194,9 +194,9 @@ Audio2_sound_ret: jr nz, .skipSfxChannel3 ; restart hardware channel 3 (wave channel) output ld a, $0 - ld [rNR30], a + ldh [rNR30], a ld a, $80 - ld [rNR30], a + ldh [rNR30], a .skipSfxChannel3 jr nz, .dontDisable ld a, [wDisableChannelOutputWhenSfxEnds] @@ -230,9 +230,9 @@ Audio2_sound_ret: .disableChannelOutput ld hl, Audio2_HWChannelDisableMasks add hl, bc - ld a, [rNR51] + ldh a, [rNR51] and [hl] - ld [rNR51], a + ldh [rNR51], a .afterDisable ld a, [wChannelSoundIDs + Ch5] cp CRY_SFX_START @@ -252,7 +252,7 @@ Audio2_sound_ret: ret c .skipRewind ld a, [wSavedVolume] - ld [rNR50], a + ldh [rNR50], a xor a ld [wSavedVolume], a .skipCry @@ -559,7 +559,7 @@ Audio2_volume: cp $f0 ; is this command a volume? jr nz, Audio2_execute_music ; no call Audio2_GetNextMusicByte - ld [rNR50], a ; store volume + ldh [rNR50], a ; store volume jp Audio2_sound_ret Audio2_execute_music: @@ -649,7 +649,7 @@ Audio2_pitch_sweep: bit BIT_EXECUTE_MUSIC, [hl] jr nz, Audio2_note ; no call Audio2_GetNextMusicByte - ld [rNR10], a + ldh [rNR10], a jp Audio2_sound_ret Audio2_note: @@ -781,9 +781,9 @@ Audio2_note_pitch: ld b, 0 ld hl, Audio2_HWChannelDisableMasks add hl, bc - ld a, [rNR51] + ldh a, [rNR51] and [hl] - ld [rNR51], a ; disable hardware channel 3's output + ldh [rNR51], a ; disable hardware channel 3's output jr .done .notChannel3 ld b, REG_VOLUME_ENVELOPE @@ -855,7 +855,7 @@ Audio2_EnableChannelOutput: ld b, 0 ld hl, Audio2_HWChannelEnableMasks add hl, bc - ld a, [rNR51] + ldh a, [rNR51] or [hl] ; set this channel's bits ld d, a ld a, c @@ -877,7 +877,7 @@ Audio2_EnableChannelOutput: add hl, bc and [hl] ld d, a - ld a, [rNR51] + ldh a, [rNR51] ld hl, Audio2_HWChannelDisableMasks add hl, bc and [hl] ; reset this channel's output bits @@ -885,7 +885,7 @@ Audio2_EnableChannelOutput: ld d, a .skip ld a, d - ld [rNR51], a + ldh [rNR51], a ret Audio2_ApplyDutyCycleAndSoundLength: @@ -939,7 +939,7 @@ Audio2_ApplyWavePatternAndFrequency: ld hl, rWave_0 ld b, $f ld a, $0 ; stop hardware channel 3 - ld [rNR30], a + ldh [rNR30], a .loop ld a, [de] inc de @@ -949,7 +949,7 @@ Audio2_ApplyWavePatternAndFrequency: and a jr nz, .loop ld a, $80 ; start hardware channel 3 - ld [rNR30], a + ldh [rNR30], a pop de .notChannel3 ld a, d @@ -1462,17 +1462,17 @@ Audio2_PlaySound:: ld a, $ff ld [wStereoPanning], a xor a - ld [rNR50], a + ldh [rNR50], a ld a, $8 - ld [rNR10], a + ldh [rNR10], a ld a, 0 - ld [rNR51], a + ldh [rNR51], a xor a - ld [rNR30], a + ldh [rNR30], a ld a, $80 - ld [rNR30], a + ldh [rNR30], a ld a, $77 - ld [rNR50], a + ldh [rNR50], a jp .playSoundCommon .playSfx @@ -1618,7 +1618,7 @@ Audio2_PlaySound:: cp Ch5 jr nz, .skipSweepDisable ld a, $8 - ld [rNR10], a ; sweep off + ldh [rNR10], a ; sweep off .skipSweepDisable ld a, c and a @@ -1628,22 +1628,22 @@ Audio2_PlaySound:: .stopAllAudio ld a, $80 - ld [rNR52], a ; sound hardware on - ld [rNR30], a ; wave playback on + ldh [rNR52], a ; sound hardware on + ldh [rNR30], a ; wave playback on xor a - ld [rNR51], a ; no sound output - ld [rNR32], a ; mute channel 3 (wave channel) + ldh [rNR51], a ; no sound output + ldh [rNR32], a ; mute channel 3 (wave channel) ld a, $8 - ld [rNR10], a ; sweep off - ld [rNR12], a ; mute channel 1 (pulse channel 1) - ld [rNR22], a ; mute channel 2 (pulse channel 2) - ld [rNR42], a ; mute channel 4 (noise channel) + ldh [rNR10], a ; sweep off + ldh [rNR12], a ; mute channel 1 (pulse channel 1) + ldh [rNR22], a ; mute channel 2 (pulse channel 2) + ldh [rNR42], a ; mute channel 4 (noise channel) ld a, $40 - ld [rNR14], a ; counter mode - ld [rNR24], a - ld [rNR44], a + ldh [rNR14], a ; counter mode + ldh [rNR24], a + ldh [rNR44], a ld a, $77 - ld [rNR50], a ; full volume + ldh [rNR50], a ; full volume xor a ld [wUnusedC000], a ld [wDisableChannelOutputWhenSfxEnds], a @@ -1762,10 +1762,10 @@ Audio2_PlaySound:: ld a, [wSavedVolume] and a jr nz, .done - ld a, [rNR50] + ldh a, [rNR50] ld [wSavedVolume], a ld a, $77 - ld [rNR50], a ; full volume + ldh [rNR50], a ; full volume .done ret diff --git a/audio/engine_3.asm b/audio/engine_3.asm index c0aaeaf8..e8ee38c9 100644 --- a/audio/engine_3.asm +++ b/audio/engine_3.asm @@ -20,10 +20,10 @@ Audio3_UpdateMusic:: set 7, a ld [wMuteAudioAndPauseMusic], a xor a ; disable all channels' output - ld [rNR51], a - ld [rNR30], a + ldh [rNR51], a + ldh [rNR30], a ld a, $80 - ld [rNR30], a + ldh [rNR30], a jr .nextChannel .applyAffects call Audio3_ApplyMusicAffects @@ -183,9 +183,9 @@ Audio3_sound_ret: jr nz, .skipSfxChannel3 ; restart hardware channel 3 (wave channel) output ld a, $0 - ld [rNR30], a + ldh [rNR30], a ld a, $80 - ld [rNR30], a + ldh [rNR30], a .skipSfxChannel3 jr nz, .dontDisable ld a, [wDisableChannelOutputWhenSfxEnds] @@ -219,9 +219,9 @@ Audio3_sound_ret: .disableChannelOutput ld hl, Audio3_HWChannelDisableMasks add hl, bc - ld a, [rNR51] + ldh a, [rNR51] and [hl] - ld [rNR51], a + ldh [rNR51], a .afterDisable ld a, [wChannelSoundIDs + Ch5] cp CRY_SFX_START @@ -241,7 +241,7 @@ Audio3_sound_ret: ret c .skipRewind ld a, [wSavedVolume] - ld [rNR50], a + ldh [rNR50], a xor a ld [wSavedVolume], a .skipCry @@ -548,7 +548,7 @@ Audio3_volume: cp $f0 ; is this command a volume? jr nz, Audio3_execute_music ; no call Audio3_GetNextMusicByte - ld [rNR50], a ; store volume + ldh [rNR50], a ; store volume jp Audio3_sound_ret Audio3_execute_music: @@ -638,7 +638,7 @@ Audio3_pitch_sweep: bit BIT_EXECUTE_MUSIC, [hl] jr nz, Audio3_note ; no call Audio3_GetNextMusicByte - ld [rNR10], a + ldh [rNR10], a jp Audio3_sound_ret Audio3_note: @@ -770,9 +770,9 @@ Audio3_note_pitch: ld b, 0 ld hl, Audio3_HWChannelDisableMasks add hl, bc - ld a, [rNR51] + ldh a, [rNR51] and [hl] - ld [rNR51], a ; disable hardware channel 3's output + ldh [rNR51], a ; disable hardware channel 3's output jr .done .notChannel3 ld b, REG_VOLUME_ENVELOPE @@ -844,7 +844,7 @@ Audio3_EnableChannelOutput: ld b, 0 ld hl, Audio3_HWChannelEnableMasks add hl, bc - ld a, [rNR51] + ldh a, [rNR51] or [hl] ; set this channel's bits ld d, a ld a, c @@ -866,7 +866,7 @@ Audio3_EnableChannelOutput: add hl, bc and [hl] ld d, a - ld a, [rNR51] + ldh a, [rNR51] ld hl, Audio3_HWChannelDisableMasks add hl, bc and [hl] ; reset this channel's output bits @@ -874,7 +874,7 @@ Audio3_EnableChannelOutput: ld d, a .skip ld a, d - ld [rNR51], a + ldh [rNR51], a ret Audio3_ApplyDutyCycleAndSoundLength: @@ -928,7 +928,7 @@ Audio3_ApplyWavePatternAndFrequency: ld hl, rWave_0 ld b, $f ld a, $0 ; stop hardware channel 3 - ld [rNR30], a + ldh [rNR30], a .loop ld a, [de] inc de @@ -938,7 +938,7 @@ Audio3_ApplyWavePatternAndFrequency: and a jr nz, .loop ld a, $80 ; start hardware channel 3 - ld [rNR30], a + ldh [rNR30], a pop de .notChannel3 ld a, d @@ -1399,17 +1399,17 @@ Audio3_PlaySound:: ld a, $ff ld [wStereoPanning], a xor a - ld [rNR50], a + ldh [rNR50], a ld a, $8 - ld [rNR10], a + ldh [rNR10], a ld a, 0 - ld [rNR51], a + ldh [rNR51], a xor a - ld [rNR30], a + ldh [rNR30], a ld a, $80 - ld [rNR30], a + ldh [rNR30], a ld a, $77 - ld [rNR50], a + ldh [rNR50], a jp .playSoundCommon .playSfx @@ -1555,7 +1555,7 @@ Audio3_PlaySound:: cp Ch5 jr nz, .skipSweepDisable ld a, $8 - ld [rNR10], a ; sweep off + ldh [rNR10], a ; sweep off .skipSweepDisable ld a, c and a @@ -1565,22 +1565,22 @@ Audio3_PlaySound:: .stopAllAudio ld a, $80 - ld [rNR52], a ; sound hardware on - ld [rNR30], a ; wave playback on + ldh [rNR52], a ; sound hardware on + ldh [rNR30], a ; wave playback on xor a - ld [rNR51], a ; no sound output - ld [rNR32], a ; mute channel 3 (wave channel) + ldh [rNR51], a ; no sound output + ldh [rNR32], a ; mute channel 3 (wave channel) ld a, $8 - ld [rNR10], a ; sweep off - ld [rNR12], a ; mute channel 1 (pulse channel 1) - ld [rNR22], a ; mute channel 2 (pulse channel 2) - ld [rNR42], a ; mute channel 4 (noise channel) + ldh [rNR10], a ; sweep off + ldh [rNR12], a ; mute channel 1 (pulse channel 1) + ldh [rNR22], a ; mute channel 2 (pulse channel 2) + ldh [rNR42], a ; mute channel 4 (noise channel) ld a, $40 - ld [rNR14], a ; counter mode - ld [rNR24], a - ld [rNR44], a + ldh [rNR14], a ; counter mode + ldh [rNR24], a + ldh [rNR44], a ld a, $77 - ld [rNR50], a ; full volume + ldh [rNR50], a ; full volume xor a ld [wUnusedC000], a ld [wDisableChannelOutputWhenSfxEnds], a @@ -1699,10 +1699,10 @@ Audio3_PlaySound:: ld a, [wSavedVolume] and a jr nz, .done - ld a, [rNR50] + ldh a, [rNR50] ld [wSavedVolume], a ld a, $77 - ld [rNR50], a ; full volume + ldh [rNR50], a ; full volume .done ret diff --git a/audio/pokedex_rating_sfx.asm b/audio/pokedex_rating_sfx.asm index 1b5dc4f0..4a5647cb 100644 --- a/audio/pokedex_rating_sfx.asm +++ b/audio/pokedex_rating_sfx.asm @@ -1,5 +1,5 @@ PlayPokedexRatingSfx:: - ld a, [hDexRatingNumMonsOwned] + ldh a, [hDexRatingNumMonsOwned] ld c, $0 ld hl, OwnedMonValues .getSfxPointer diff --git a/constants.asm b/constants.asm index f52af60d..3d428283 100644 --- a/constants.asm +++ b/constants.asm @@ -2,9 +2,6 @@ INCLUDE "charmap.asm" INCLUDE "macros.asm" -INCLUDE "hram.asm" -INCLUDE "vram.asm" - INCLUDE "constants/hardware_constants.asm" INCLUDE "constants/oam_constants.asm" INCLUDE "constants/misc_constants.asm" diff --git a/constants/audio_constants.asm b/constants/audio_constants.asm index 38719f92..3a1a8f5b 100644 --- a/constants/audio_constants.asm +++ b/constants/audio_constants.asm @@ -25,10 +25,10 @@ const Ch8 ; 7 ; HW sound channel register base addresses -HW_CH1_BASE EQU (rNR10 % $100) -HW_CH2_BASE EQU ((rNR21 % $100) - 1) -HW_CH3_BASE EQU (rNR30 % $100) -HW_CH4_BASE EQU ((rNR41 % $100) - 1) +HW_CH1_BASE EQU LOW(rNR10) +HW_CH2_BASE EQU LOW(rNR21) - 1 +HW_CH3_BASE EQU LOW(rNR30) +HW_CH4_BASE EQU LOW(rNR41) - 1 ; HW sound channel enable bit masks HW_CH1_ENABLE_MASK EQU %00010001 diff --git a/constants/battle_constants.asm b/constants/battle_constants.asm index bdcd2b98..bdd03e8a 100644 --- a/constants/battle_constants.asm +++ b/constants/battle_constants.asm @@ -21,6 +21,13 @@ MAX_NEUTRAL_DAMAGE EQU 999 SONICBOOM_DAMAGE EQU 20 DRAGON_RAGE_DAMAGE EQU 40 +; type effectiveness factors, scaled by 10 +SUPER_EFFECTIVE EQU 20 +MORE_EFFECTIVE EQU 15 +EFFECTIVE EQU 10 +NOT_VERY_EFFECTIVE EQU 05 +NO_EFFECT EQU 00 + ; non-volatile statuses SLP EQU %111 ; sleep counter PSN EQU 3 @@ -28,6 +35,8 @@ BRN EQU 4 FRZ EQU 5 PAR EQU 6 +MAX_STAT_VALUE EQU 999 + ; volatile statuses 1 STORING_ENERGY EQU 0 ; Bide THRASHING_ABOUT EQU 1 ; e.g. Thrash diff --git a/constants/gfx_constants.asm b/constants/gfx_constants.asm index 0cc0d98d..6446a51f 100644 --- a/constants/gfx_constants.asm +++ b/constants/gfx_constants.asm @@ -20,3 +20,12 @@ SPRITEBUFFERSIZE EQU 7 * 7 * LEN_1BPP_TILE HP_BAR_GREEN EQU 0 HP_BAR_YELLOW EQU 1 HP_BAR_RED EQU 2 + +; hAutoBGTransferEnabled +TRANSFERTOP EQU 0 +TRANSFERMIDDLE EQU 1 +TRANSFERBOTTOM EQU 2 + +; hRedrawRowOrColumnMode +REDRAW_COL EQU 1 +REDRAW_ROW EQU 2 diff --git a/constants/map_object_constants.asm b/constants/map_object_constants.asm index f5fc952b..459fae4a 100644 --- a/constants/map_object_constants.asm +++ b/constants/map_object_constants.asm @@ -1,3 +1,43 @@ +; spritestatedata1 struct members (see macros/wram.asm) + const_def + const SPRITESTATEDATA1_PICTUREID ; 0 + const SPRITESTATEDATA1_MOVEMENTSTATUS ; 1 + const SPRITESTATEDATA1_IMAGEINDEX ; 2 + const SPRITESTATEDATA1_YSTEPVECTOR ; 3 + const SPRITESTATEDATA1_YPIXELS ; 4 + const SPRITESTATEDATA1_XSTEPVECTOR ; 5 + const SPRITESTATEDATA1_XPIXELS ; 6 + const SPRITESTATEDATA1_INTRAANIMFRAMECOUNTER ; 7 + const SPRITESTATEDATA1_ANIMFRAMECOUNTER ; 8 + const SPRITESTATEDATA1_FACINGDIRECTION ; 9 + const SPRITESTATEDATA1_YADJUSTED ; a + const SPRITESTATEDATA1_XADJUSTED ; b + const SPRITESTATEDATA1_COLLISIONDATA ; c + const SPRITESTATEDATA1_0D ; d + const SPRITESTATEDATA1_0E ; e + const SPRITESTATEDATA1_0F ; f +SPRITESTATEDATA1_LENGTH EQU const_value + +; spritestatedata2 struct members (see macros/wram.asm) + const_def + const SPRITESTATEDATA2_WALKANIMATIONCOUNTER ; 0 + const SPRITESTATEDATA2_01 ; 1 + const SPRITESTATEDATA2_YDISPLACEMENT ; 2 + const SPRITESTATEDATA2_XDISPLACEMENT ; 3 + const SPRITESTATEDATA2_MAPY ; 4 + const SPRITESTATEDATA2_MAPX ; 5 + const SPRITESTATEDATA2_MOVEMENTBYTE1 ; 6 + const SPRITESTATEDATA2_GRASSPRIORITY ; 7 + const SPRITESTATEDATA2_MOVEMENTDELAY ; 8 + const SPRITESTATEDATA2_ORIGFACINGDIRECTION ; 9 + const SPRITESTATEDATA2_0A ; a + const SPRITESTATEDATA2_0B ; b + const SPRITESTATEDATA2_0C ; c + const SPRITESTATEDATA2_PICTUREID ; d + const SPRITESTATEDATA2_IMAGEBASEOFFSET ; e + const SPRITESTATEDATA2_0F ; f +SPRITESTATEDATA2_LENGTH EQU const_value + ; different kinds of people events ITEM EQU $80 TRAINER EQU $40 diff --git a/constants/type_constants.asm b/constants/type_constants.asm index c94d5c39..d1a1a73e 100755 --- a/constants/type_constants.asm +++ b/constants/type_constants.asm @@ -1,23 +1,23 @@ const_def PHYSICAL EQU const_value - const NORMAL ; $00 - const FIGHTING ; $01 - const FLYING ; $02 - const POISON ; $03 - const GROUND ; $04 - const ROCK ; $05 - const BIRD ; $06 - const BUG ; $07 - const GHOST ; $08 + const NORMAL ; $00 + const FIGHTING ; $01 + const FLYING ; $02 + const POISON ; $03 + const GROUND ; $04 + const ROCK ; $05 + const BIRD ; $06 + const BUG ; $07 + const GHOST ; $08 const_value = $14 SPECIAL EQU const_value - const FIRE ; $14 - const WATER ; $15 - const GRASS ; $16 - const ELECTRIC ; $17 - const PSYCHIC ; $18 - const ICE ; $19 - const DRAGON ; $1A + const FIRE ; $14 + const WATER ; $15 + const GRASS ; $16 + const ELECTRIC ; $17 + const PSYCHIC_TYPE ; $18 + const ICE ; $19 + const DRAGON ; $1A diff --git a/data/icon_pointers.asm b/data/icon_pointers.asm index b615798e..585a0a29 100644 --- a/data/icon_pointers.asm +++ b/data/icon_pointers.asm @@ -1,140 +1,37 @@ -MonPartySpritePointers: - dw SlowbroSprite + $c0 - db $40 / $10 ; 40 bytes - db BANK(SlowbroSprite) - dw vSprites - - dw BallSprite - db $80 / $10 ; $80 bytes - db BANK(BallSprite) - dw vSprites + $40 - - dw ClefairySprite + $c0 - db $40 / $10 ; $40 bytes - db BANK(ClefairySprite) - dw vSprites + $c0 - - dw BirdSprite + $c0 - db $40 / $10 ; $40 bytes - db BANK(BirdSprite) - dw vSprites + $100 - - dw SeelSprite - db $40 / $10 ; $40 bytes - db BANK(SeelSprite) - dw vSprites + $140 - - dw BugIconFrame2 - db $10 / $10 ; $10 bytes - db BANK(BugIconFrame2) - dw vSprites + $180 - - dw BugIconFrame2 + $10 - db $10 / $10 ; $10 bytes - db BANK(BugIconFrame2) - dw vSprites + $1a0 - - dw PlantIconFrame2 - db $10 / $10 ; $10 bytes - db BANK(PlantIconFrame2) - dw vSprites + $1c0 - - dw PlantIconFrame2 + $10 - db $10 / $10 ; $10 bytes - db BANK(PlantIconFrame2) - dw vSprites + $1e0 - - dw SnakeIconFrame1 - db $10 / $10 ; $10 bytes - db BANK(SnakeIconFrame1) - dw vSprites + $200 - - dw SnakeIconFrame1 + $10 - db $10 / $10 ; $10 bytes - db BANK(SnakeIconFrame1) - dw vSprites + $220 - - dw QuadrupedIconFrame1 - db $10 / $10 ; $10 bytes - db BANK(QuadrupedIconFrame1) - dw vSprites + $240 - - dw QuadrupedIconFrame1 + $10 - db $10 / $10 ; $10 bytes - db BANK(QuadrupedIconFrame1) - dw vSprites + $260 - - dw TradeBubbleIconGFX - db $40 / $10 ; $40 bytes - db BANK(TradeBubbleIconGFX) - dw vSprites + $380 +mon_icon_header: MACRO + dw \1 tile \2 + db \3 + db BANK(\1) + dw vSprites tile \4 +ENDM - dw SlowbroSprite - db $40 / $10 ; $40 bytes - db BANK(SlowbroSprite) - dw vSprites + $400 - - dw BallSprite - db $80 / $10 ; $80 bytes - db BANK(BallSprite) - dw vSprites + $440 - - dw ClefairySprite - db $40 / $10 ; $40 bytes - db BANK(ClefairySprite) - dw vSprites + $4c0 - - dw BirdSprite - db $40 / $10 ; $40 bytes - db BANK(BirdSprite) - dw vSprites + $500 - - dw SeelSprite + $C0 - db $40 / $10 ; $40 bytes - db BANK(SeelSprite) - dw vSprites + $540 - - dw BugIconFrame1 - db $10 / $10 ; $10 bytes - db BANK(BugIconFrame1) - dw vSprites + $580 - - dw BugIconFrame1 + $10 - db $10 / $10 ; $10 bytes - db BANK(BugIconFrame1) - dw vSprites + $5a0 - - dw PlantIconFrame1 - db $10 / $10 ; $10 bytes - db BANK(PlantIconFrame1) - dw vSprites + $5c0 - - dw PlantIconFrame1 + $10 - db $10 / $10 ; $10 bytes - db BANK(PlantIconFrame1) - dw vSprites + $5E0 - - dw SnakeIconFrame2 - db $10 / $10 ; $10 bytes - db BANK(SnakeIconFrame2) - dw vSprites + $600 - - dw SnakeIconFrame2 + $10 - db $10 / $10 ; $10 bytes - db BANK(SnakeIconFrame2) - dw vSprites + $620 - - dw QuadrupedIconFrame2 - db $10 / $10 ; $10 bytes - db BANK(QuadrupedIconFrame2) - dw vSprites + $640 - - dw QuadrupedIconFrame2 + $10 - db $10 / $10 ; $10 bytes - db BANK(QuadrupedIconFrame2) - dw vSprites + $660 - - dw TradeBubbleIconGFX + $40 - db $40 / $10 ; $40 bytes - db BANK(TradeBubbleIconGFX) - dw vSprites + $780 +MonPartySpritePointers: +; gfx pointer, gfx tile offset, # tiles, vSprites tile offset + mon_icon_header SlowbroSprite, 12, 4, $00 + mon_icon_header BallSprite, 0, 8, $04 + mon_icon_header ClefairySprite, 12, 4, $0c + mon_icon_header BirdSprite, 12, 4, $10 + mon_icon_header SeelSprite, 0, 4, $14 + mon_icon_header BugIconFrame2, 0, 1, $18 + mon_icon_header BugIconFrame2, 1, 1, $1a + mon_icon_header PlantIconFrame2, 0, 1, $1c + mon_icon_header PlantIconFrame2, 1, 1, $1e + mon_icon_header SnakeIconFrame1, 0, 1, $20 + mon_icon_header SnakeIconFrame1, 1, 1, $22 + mon_icon_header QuadrupedIconFrame1, 0, 1, $24 + mon_icon_header QuadrupedIconFrame1, 1, 1, $26 + mon_icon_header TradeBubbleIconGFX, 0, 4, $38 + mon_icon_header SlowbroSprite, 0, 4, $40 + mon_icon_header BallSprite, 0, 8, $44 + mon_icon_header ClefairySprite, 0, 4, $4c + mon_icon_header BirdSprite, 0, 4, $50 + mon_icon_header SeelSprite, 12, 4, $54 + mon_icon_header BugIconFrame1, 0, 1, $58 + mon_icon_header BugIconFrame1, 1, 1, $5a + mon_icon_header PlantIconFrame1, 0, 1, $5c + mon_icon_header PlantIconFrame1, 1, 1, $5e + mon_icon_header SnakeIconFrame2, 0, 1, $60 + mon_icon_header SnakeIconFrame2, 1, 1, $62 + mon_icon_header QuadrupedIconFrame2, 0, 1, $64 + mon_icon_header QuadrupedIconFrame2, 1, 1, $66 + mon_icon_header TradeBubbleIconGFX, 4, 4, $78 diff --git a/data/moves/moves.asm b/data/moves/moves.asm index 183243e9..85b6dcfc 100755 --- a/data/moves/moves.asm +++ b/data/moves/moves.asm @@ -10,169 +10,169 @@ move: MACRO db \6 ; pp ENDM - move POUND, NO_ADDITIONAL_EFFECT, 40, NORMAL, 100, 35 + move POUND, NO_ADDITIONAL_EFFECT, 40, NORMAL, 100, 35 MoveEnd: - move KARATE_CHOP, NO_ADDITIONAL_EFFECT, 50, NORMAL, 100, 25 - move DOUBLESLAP, TWO_TO_FIVE_ATTACKS_EFFECT, 15, NORMAL, 85, 10 - move COMET_PUNCH, TWO_TO_FIVE_ATTACKS_EFFECT, 18, NORMAL, 85, 15 - move MEGA_PUNCH, NO_ADDITIONAL_EFFECT, 80, NORMAL, 85, 20 - move PAY_DAY, PAY_DAY_EFFECT, 40, NORMAL, 100, 20 - move FIRE_PUNCH, BURN_SIDE_EFFECT1, 75, FIRE, 100, 15 - move ICE_PUNCH, FREEZE_SIDE_EFFECT, 75, ICE, 100, 15 - move THUNDERPUNCH, PARALYZE_SIDE_EFFECT1, 75, ELECTRIC, 100, 15 - move SCRATCH, NO_ADDITIONAL_EFFECT, 40, NORMAL, 100, 35 - move VICEGRIP, NO_ADDITIONAL_EFFECT, 55, NORMAL, 100, 30 - move GUILLOTINE, OHKO_EFFECT, 1, NORMAL, 30, 5 - move RAZOR_WIND, CHARGE_EFFECT, 80, NORMAL, 75, 10 - move SWORDS_DANCE, ATTACK_UP2_EFFECT, 0, NORMAL, 100, 30 - move CUT, NO_ADDITIONAL_EFFECT, 50, NORMAL, 95, 30 - move GUST, NO_ADDITIONAL_EFFECT, 40, NORMAL, 100, 35 - move WING_ATTACK, NO_ADDITIONAL_EFFECT, 35, FLYING, 100, 35 - move WHIRLWIND, SWITCH_AND_TELEPORT_EFFECT, 0, NORMAL, 85, 20 - move FLY, FLY_EFFECT, 70, FLYING, 95, 15 - move BIND, TRAPPING_EFFECT, 15, NORMAL, 75, 20 - move SLAM, NO_ADDITIONAL_EFFECT, 80, NORMAL, 75, 20 - move VINE_WHIP, NO_ADDITIONAL_EFFECT, 35, GRASS, 100, 10 - move STOMP, FLINCH_SIDE_EFFECT2, 65, NORMAL, 100, 20 - move DOUBLE_KICK, ATTACK_TWICE_EFFECT, 30, FIGHTING, 100, 30 - move MEGA_KICK, NO_ADDITIONAL_EFFECT, 120, NORMAL, 75, 5 - move JUMP_KICK, JUMP_KICK_EFFECT, 70, FIGHTING, 95, 25 - move ROLLING_KICK, FLINCH_SIDE_EFFECT2, 60, FIGHTING, 85, 15 - move SAND_ATTACK, ACCURACY_DOWN1_EFFECT, 0, NORMAL, 100, 15 - move HEADBUTT, FLINCH_SIDE_EFFECT2, 70, NORMAL, 100, 15 - move HORN_ATTACK, NO_ADDITIONAL_EFFECT, 65, NORMAL, 100, 25 - move FURY_ATTACK, TWO_TO_FIVE_ATTACKS_EFFECT, 15, NORMAL, 85, 20 - move HORN_DRILL, OHKO_EFFECT, 1, NORMAL, 30, 5 - move TACKLE, NO_ADDITIONAL_EFFECT, 35, NORMAL, 95, 35 - move BODY_SLAM, PARALYZE_SIDE_EFFECT2, 85, NORMAL, 100, 15 - move WRAP, TRAPPING_EFFECT, 15, NORMAL, 85, 20 - move TAKE_DOWN, RECOIL_EFFECT, 90, NORMAL, 85, 20 - move THRASH, THRASH_PETAL_DANCE_EFFECT, 90, NORMAL, 100, 20 - move DOUBLE_EDGE, RECOIL_EFFECT, 100, NORMAL, 100, 15 - move TAIL_WHIP, DEFENSE_DOWN1_EFFECT, 0, NORMAL, 100, 30 - move POISON_STING, POISON_SIDE_EFFECT1, 15, POISON, 100, 35 - move TWINEEDLE, TWINEEDLE_EFFECT, 25, BUG, 100, 20 - move PIN_MISSILE, TWO_TO_FIVE_ATTACKS_EFFECT, 14, BUG, 85, 20 - move LEER, DEFENSE_DOWN1_EFFECT, 0, NORMAL, 100, 30 - move BITE, FLINCH_SIDE_EFFECT1, 60, NORMAL, 100, 25 - move GROWL, ATTACK_DOWN1_EFFECT, 0, NORMAL, 100, 40 - move ROAR, SWITCH_AND_TELEPORT_EFFECT, 0, NORMAL, 100, 20 - move SING, SLEEP_EFFECT, 0, NORMAL, 55, 15 - move SUPERSONIC, CONFUSION_EFFECT, 0, NORMAL, 55, 20 - move SONICBOOM, SPECIAL_DAMAGE_EFFECT, 1, NORMAL, 90, 20 - move DISABLE, DISABLE_EFFECT, 0, NORMAL, 55, 20 - move ACID, DEFENSE_DOWN_SIDE_EFFECT, 40, POISON, 100, 30 - move EMBER, BURN_SIDE_EFFECT1, 40, FIRE, 100, 25 - move FLAMETHROWER, BURN_SIDE_EFFECT1, 95, FIRE, 100, 15 - move MIST, MIST_EFFECT, 0, ICE, 100, 30 - move WATER_GUN, NO_ADDITIONAL_EFFECT, 40, WATER, 100, 25 - move HYDRO_PUMP, NO_ADDITIONAL_EFFECT, 120, WATER, 80, 5 - move SURF, NO_ADDITIONAL_EFFECT, 95, WATER, 100, 15 - move ICE_BEAM, FREEZE_SIDE_EFFECT, 95, ICE, 100, 10 - move BLIZZARD, FREEZE_SIDE_EFFECT, 120, ICE, 90, 5 - move PSYBEAM, CONFUSION_SIDE_EFFECT, 65, PSYCHIC, 100, 20 - move BUBBLEBEAM, SPEED_DOWN_SIDE_EFFECT, 65, WATER, 100, 20 - move AURORA_BEAM, ATTACK_DOWN_SIDE_EFFECT, 65, ICE, 100, 20 - move HYPER_BEAM, HYPER_BEAM_EFFECT, 150, NORMAL, 90, 5 - move PECK, NO_ADDITIONAL_EFFECT, 35, FLYING, 100, 35 - move DRILL_PECK, NO_ADDITIONAL_EFFECT, 80, FLYING, 100, 20 - move SUBMISSION, RECOIL_EFFECT, 80, FIGHTING, 80, 25 - move LOW_KICK, FLINCH_SIDE_EFFECT2, 50, FIGHTING, 90, 20 - move COUNTER, NO_ADDITIONAL_EFFECT, 1, FIGHTING, 100, 20 - move SEISMIC_TOSS, SPECIAL_DAMAGE_EFFECT, 1, FIGHTING, 100, 20 - move STRENGTH, NO_ADDITIONAL_EFFECT, 80, NORMAL, 100, 15 - move ABSORB, DRAIN_HP_EFFECT, 20, GRASS, 100, 20 - move MEGA_DRAIN, DRAIN_HP_EFFECT, 40, GRASS, 100, 10 - move LEECH_SEED, LEECH_SEED_EFFECT, 0, GRASS, 90, 10 - move GROWTH, SPECIAL_UP1_EFFECT, 0, NORMAL, 100, 40 - move RAZOR_LEAF, NO_ADDITIONAL_EFFECT, 55, GRASS, 95, 25 - move SOLARBEAM, CHARGE_EFFECT, 120, GRASS, 100, 10 - move POISONPOWDER, POISON_EFFECT, 0, POISON, 75, 35 - move STUN_SPORE, PARALYZE_EFFECT, 0, GRASS, 75, 30 - move SLEEP_POWDER, SLEEP_EFFECT, 0, GRASS, 75, 15 - move PETAL_DANCE, THRASH_PETAL_DANCE_EFFECT, 70, GRASS, 100, 20 - move STRING_SHOT, SPEED_DOWN1_EFFECT, 0, BUG, 95, 40 - move DRAGON_RAGE, SPECIAL_DAMAGE_EFFECT, 1, DRAGON, 100, 10 - move FIRE_SPIN, TRAPPING_EFFECT, 15, FIRE, 70, 15 - move THUNDERSHOCK, PARALYZE_SIDE_EFFECT1, 40, ELECTRIC, 100, 30 - move THUNDERBOLT, PARALYZE_SIDE_EFFECT1, 95, ELECTRIC, 100, 15 - move THUNDER_WAVE, PARALYZE_EFFECT, 0, ELECTRIC, 100, 20 - move THUNDER, PARALYZE_SIDE_EFFECT1, 120, ELECTRIC, 70, 10 - move ROCK_THROW, NO_ADDITIONAL_EFFECT, 50, ROCK, 65, 15 - move EARTHQUAKE, NO_ADDITIONAL_EFFECT, 100, GROUND, 100, 10 - move FISSURE, OHKO_EFFECT, 1, GROUND, 30, 5 - move DIG, CHARGE_EFFECT, 100, GROUND, 100, 10 - move TOXIC, POISON_EFFECT, 0, POISON, 85, 10 - move CONFUSION, CONFUSION_SIDE_EFFECT, 50, PSYCHIC, 100, 25 - move PSYCHIC_M, SPECIAL_DOWN_SIDE_EFFECT, 90, PSYCHIC, 100, 10 - move HYPNOSIS, SLEEP_EFFECT, 0, PSYCHIC, 60, 20 - move MEDITATE, ATTACK_UP1_EFFECT, 0, PSYCHIC, 100, 40 - move AGILITY, SPEED_UP2_EFFECT, 0, PSYCHIC, 100, 30 - move QUICK_ATTACK, NO_ADDITIONAL_EFFECT, 40, NORMAL, 100, 30 - move RAGE, RAGE_EFFECT, 20, NORMAL, 100, 20 - move TELEPORT, SWITCH_AND_TELEPORT_EFFECT, 0, PSYCHIC, 100, 20 - move NIGHT_SHADE, SPECIAL_DAMAGE_EFFECT, 0, GHOST, 100, 15 - move MIMIC, MIMIC_EFFECT, 0, NORMAL, 100, 10 - move SCREECH, DEFENSE_DOWN2_EFFECT, 0, NORMAL, 85, 40 - move DOUBLE_TEAM, EVASION_UP1_EFFECT, 0, NORMAL, 100, 15 - move RECOVER, HEAL_EFFECT, 0, NORMAL, 100, 20 - move HARDEN, DEFENSE_UP1_EFFECT, 0, NORMAL, 100, 30 - move MINIMIZE, EVASION_UP1_EFFECT, 0, NORMAL, 100, 20 - move SMOKESCREEN, ACCURACY_DOWN1_EFFECT, 0, NORMAL, 100, 20 - move CONFUSE_RAY, CONFUSION_EFFECT, 0, GHOST, 100, 10 - move WITHDRAW, DEFENSE_UP1_EFFECT, 0, WATER, 100, 40 - move DEFENSE_CURL, DEFENSE_UP1_EFFECT, 0, NORMAL, 100, 40 - move BARRIER, DEFENSE_UP2_EFFECT, 0, PSYCHIC, 100, 30 - move LIGHT_SCREEN, LIGHT_SCREEN_EFFECT, 0, PSYCHIC, 100, 30 - move HAZE, HAZE_EFFECT, 0, ICE, 100, 30 - move REFLECT, REFLECT_EFFECT, 0, PSYCHIC, 100, 20 - move FOCUS_ENERGY, FOCUS_ENERGY_EFFECT, 0, NORMAL, 100, 30 - move BIDE, BIDE_EFFECT, 0, NORMAL, 100, 10 - move METRONOME, METRONOME_EFFECT, 0, NORMAL, 100, 10 - move MIRROR_MOVE, MIRROR_MOVE_EFFECT, 0, FLYING, 100, 20 - move SELFDESTRUCT, EXPLODE_EFFECT, 130, NORMAL, 100, 5 - move EGG_BOMB, NO_ADDITIONAL_EFFECT, 100, NORMAL, 75, 10 - move LICK, PARALYZE_SIDE_EFFECT2, 20, GHOST, 100, 30 - move SMOG, POISON_SIDE_EFFECT2, 20, POISON, 70, 20 - move SLUDGE, POISON_SIDE_EFFECT2, 65, POISON, 100, 20 - move BONE_CLUB, FLINCH_SIDE_EFFECT1, 65, GROUND, 85, 20 - move FIRE_BLAST, BURN_SIDE_EFFECT2, 120, FIRE, 85, 5 - move WATERFALL, NO_ADDITIONAL_EFFECT, 80, WATER, 100, 15 - move CLAMP, TRAPPING_EFFECT, 35, WATER, 75, 10 - move SWIFT, SWIFT_EFFECT, 60, NORMAL, 100, 20 - move SKULL_BASH, CHARGE_EFFECT, 100, NORMAL, 100, 15 - move SPIKE_CANNON, TWO_TO_FIVE_ATTACKS_EFFECT, 20, NORMAL, 100, 15 - move CONSTRICT, SPEED_DOWN_SIDE_EFFECT, 10, NORMAL, 100, 35 - move AMNESIA, SPECIAL_UP2_EFFECT, 0, PSYCHIC, 100, 20 - move KINESIS, ACCURACY_DOWN1_EFFECT, 0, PSYCHIC, 80, 15 - move SOFTBOILED, HEAL_EFFECT, 0, NORMAL, 100, 10 - move HI_JUMP_KICK, JUMP_KICK_EFFECT, 85, FIGHTING, 90, 20 - move GLARE, PARALYZE_EFFECT, 0, NORMAL, 75, 30 - move DREAM_EATER, DREAM_EATER_EFFECT, 100, PSYCHIC, 100, 15 - move POISON_GAS, POISON_EFFECT, 0, POISON, 55, 40 - move BARRAGE, TWO_TO_FIVE_ATTACKS_EFFECT, 15, NORMAL, 85, 20 - move LEECH_LIFE, DRAIN_HP_EFFECT, 20, BUG, 100, 15 - move LOVELY_KISS, SLEEP_EFFECT, 0, NORMAL, 75, 10 - move SKY_ATTACK, CHARGE_EFFECT, 140, FLYING, 90, 5 - move TRANSFORM, TRANSFORM_EFFECT, 0, NORMAL, 100, 10 - move BUBBLE, SPEED_DOWN_SIDE_EFFECT, 20, WATER, 100, 30 - move DIZZY_PUNCH, NO_ADDITIONAL_EFFECT, 70, NORMAL, 100, 10 - move SPORE, SLEEP_EFFECT, 0, GRASS, 100, 15 - move FLASH, ACCURACY_DOWN1_EFFECT, 0, NORMAL, 70, 20 - move PSYWAVE, SPECIAL_DAMAGE_EFFECT, 1, PSYCHIC, 80, 15 - move SPLASH, SPLASH_EFFECT, 0, NORMAL, 100, 40 - move ACID_ARMOR, DEFENSE_UP2_EFFECT, 0, POISON, 100, 40 - move CRABHAMMER, NO_ADDITIONAL_EFFECT, 90, WATER, 85, 10 - move EXPLOSION, EXPLODE_EFFECT, 170, NORMAL, 100, 5 - move FURY_SWIPES, TWO_TO_FIVE_ATTACKS_EFFECT, 18, NORMAL, 80, 15 - move BONEMERANG, ATTACK_TWICE_EFFECT, 50, GROUND, 90, 10 - move REST, HEAL_EFFECT, 0, PSYCHIC, 100, 10 - move ROCK_SLIDE, NO_ADDITIONAL_EFFECT, 75, ROCK, 90, 10 - move HYPER_FANG, FLINCH_SIDE_EFFECT1, 80, NORMAL, 90, 15 - move SHARPEN, ATTACK_UP1_EFFECT, 0, NORMAL, 100, 30 - move CONVERSION, CONVERSION_EFFECT, 0, NORMAL, 100, 30 - move TRI_ATTACK, NO_ADDITIONAL_EFFECT, 80, NORMAL, 100, 10 - move SUPER_FANG, SUPER_FANG_EFFECT, 1, NORMAL, 90, 10 - move SLASH, NO_ADDITIONAL_EFFECT, 70, NORMAL, 100, 20 - move SUBSTITUTE, SUBSTITUTE_EFFECT, 0, NORMAL, 100, 10 - move STRUGGLE, RECOIL_EFFECT, 50, NORMAL, 100, 10 + move KARATE_CHOP, NO_ADDITIONAL_EFFECT, 50, NORMAL, 100, 25 + move DOUBLESLAP, TWO_TO_FIVE_ATTACKS_EFFECT, 15, NORMAL, 85, 10 + move COMET_PUNCH, TWO_TO_FIVE_ATTACKS_EFFECT, 18, NORMAL, 85, 15 + move MEGA_PUNCH, NO_ADDITIONAL_EFFECT, 80, NORMAL, 85, 20 + move PAY_DAY, PAY_DAY_EFFECT, 40, NORMAL, 100, 20 + move FIRE_PUNCH, BURN_SIDE_EFFECT1, 75, FIRE, 100, 15 + move ICE_PUNCH, FREEZE_SIDE_EFFECT, 75, ICE, 100, 15 + move THUNDERPUNCH, PARALYZE_SIDE_EFFECT1, 75, ELECTRIC, 100, 15 + move SCRATCH, NO_ADDITIONAL_EFFECT, 40, NORMAL, 100, 35 + move VICEGRIP, NO_ADDITIONAL_EFFECT, 55, NORMAL, 100, 30 + move GUILLOTINE, OHKO_EFFECT, 1, NORMAL, 30, 5 + move RAZOR_WIND, CHARGE_EFFECT, 80, NORMAL, 75, 10 + move SWORDS_DANCE, ATTACK_UP2_EFFECT, 0, NORMAL, 100, 30 + move CUT, NO_ADDITIONAL_EFFECT, 50, NORMAL, 95, 30 + move GUST, NO_ADDITIONAL_EFFECT, 40, NORMAL, 100, 35 + move WING_ATTACK, NO_ADDITIONAL_EFFECT, 35, FLYING, 100, 35 + move WHIRLWIND, SWITCH_AND_TELEPORT_EFFECT, 0, NORMAL, 85, 20 + move FLY, FLY_EFFECT, 70, FLYING, 95, 15 + move BIND, TRAPPING_EFFECT, 15, NORMAL, 75, 20 + move SLAM, NO_ADDITIONAL_EFFECT, 80, NORMAL, 75, 20 + move VINE_WHIP, NO_ADDITIONAL_EFFECT, 35, GRASS, 100, 10 + move STOMP, FLINCH_SIDE_EFFECT2, 65, NORMAL, 100, 20 + move DOUBLE_KICK, ATTACK_TWICE_EFFECT, 30, FIGHTING, 100, 30 + move MEGA_KICK, NO_ADDITIONAL_EFFECT, 120, NORMAL, 75, 5 + move JUMP_KICK, JUMP_KICK_EFFECT, 70, FIGHTING, 95, 25 + move ROLLING_KICK, FLINCH_SIDE_EFFECT2, 60, FIGHTING, 85, 15 + move SAND_ATTACK, ACCURACY_DOWN1_EFFECT, 0, NORMAL, 100, 15 + move HEADBUTT, FLINCH_SIDE_EFFECT2, 70, NORMAL, 100, 15 + move HORN_ATTACK, NO_ADDITIONAL_EFFECT, 65, NORMAL, 100, 25 + move FURY_ATTACK, TWO_TO_FIVE_ATTACKS_EFFECT, 15, NORMAL, 85, 20 + move HORN_DRILL, OHKO_EFFECT, 1, NORMAL, 30, 5 + move TACKLE, NO_ADDITIONAL_EFFECT, 35, NORMAL, 95, 35 + move BODY_SLAM, PARALYZE_SIDE_EFFECT2, 85, NORMAL, 100, 15 + move WRAP, TRAPPING_EFFECT, 15, NORMAL, 85, 20 + move TAKE_DOWN, RECOIL_EFFECT, 90, NORMAL, 85, 20 + move THRASH, THRASH_PETAL_DANCE_EFFECT, 90, NORMAL, 100, 20 + move DOUBLE_EDGE, RECOIL_EFFECT, 100, NORMAL, 100, 15 + move TAIL_WHIP, DEFENSE_DOWN1_EFFECT, 0, NORMAL, 100, 30 + move POISON_STING, POISON_SIDE_EFFECT1, 15, POISON, 100, 35 + move TWINEEDLE, TWINEEDLE_EFFECT, 25, BUG, 100, 20 + move PIN_MISSILE, TWO_TO_FIVE_ATTACKS_EFFECT, 14, BUG, 85, 20 + move LEER, DEFENSE_DOWN1_EFFECT, 0, NORMAL, 100, 30 + move BITE, FLINCH_SIDE_EFFECT1, 60, NORMAL, 100, 25 + move GROWL, ATTACK_DOWN1_EFFECT, 0, NORMAL, 100, 40 + move ROAR, SWITCH_AND_TELEPORT_EFFECT, 0, NORMAL, 100, 20 + move SING, SLEEP_EFFECT, 0, NORMAL, 55, 15 + move SUPERSONIC, CONFUSION_EFFECT, 0, NORMAL, 55, 20 + move SONICBOOM, SPECIAL_DAMAGE_EFFECT, 1, NORMAL, 90, 20 + move DISABLE, DISABLE_EFFECT, 0, NORMAL, 55, 20 + move ACID, DEFENSE_DOWN_SIDE_EFFECT, 40, POISON, 100, 30 + move EMBER, BURN_SIDE_EFFECT1, 40, FIRE, 100, 25 + move FLAMETHROWER, BURN_SIDE_EFFECT1, 95, FIRE, 100, 15 + move MIST, MIST_EFFECT, 0, ICE, 100, 30 + move WATER_GUN, NO_ADDITIONAL_EFFECT, 40, WATER, 100, 25 + move HYDRO_PUMP, NO_ADDITIONAL_EFFECT, 120, WATER, 80, 5 + move SURF, NO_ADDITIONAL_EFFECT, 95, WATER, 100, 15 + move ICE_BEAM, FREEZE_SIDE_EFFECT, 95, ICE, 100, 10 + move BLIZZARD, FREEZE_SIDE_EFFECT, 120, ICE, 90, 5 + move PSYBEAM, CONFUSION_SIDE_EFFECT, 65, PSYCHIC_TYPE, 100, 20 + move BUBBLEBEAM, SPEED_DOWN_SIDE_EFFECT, 65, WATER, 100, 20 + move AURORA_BEAM, ATTACK_DOWN_SIDE_EFFECT, 65, ICE, 100, 20 + move HYPER_BEAM, HYPER_BEAM_EFFECT, 150, NORMAL, 90, 5 + move PECK, NO_ADDITIONAL_EFFECT, 35, FLYING, 100, 35 + move DRILL_PECK, NO_ADDITIONAL_EFFECT, 80, FLYING, 100, 20 + move SUBMISSION, RECOIL_EFFECT, 80, FIGHTING, 80, 25 + move LOW_KICK, FLINCH_SIDE_EFFECT2, 50, FIGHTING, 90, 20 + move COUNTER, NO_ADDITIONAL_EFFECT, 1, FIGHTING, 100, 20 + move SEISMIC_TOSS, SPECIAL_DAMAGE_EFFECT, 1, FIGHTING, 100, 20 + move STRENGTH, NO_ADDITIONAL_EFFECT, 80, NORMAL, 100, 15 + move ABSORB, DRAIN_HP_EFFECT, 20, GRASS, 100, 20 + move MEGA_DRAIN, DRAIN_HP_EFFECT, 40, GRASS, 100, 10 + move LEECH_SEED, LEECH_SEED_EFFECT, 0, GRASS, 90, 10 + move GROWTH, SPECIAL_UP1_EFFECT, 0, NORMAL, 100, 40 + move RAZOR_LEAF, NO_ADDITIONAL_EFFECT, 55, GRASS, 95, 25 + move SOLARBEAM, CHARGE_EFFECT, 120, GRASS, 100, 10 + move POISONPOWDER, POISON_EFFECT, 0, POISON, 75, 35 + move STUN_SPORE, PARALYZE_EFFECT, 0, GRASS, 75, 30 + move SLEEP_POWDER, SLEEP_EFFECT, 0, GRASS, 75, 15 + move PETAL_DANCE, THRASH_PETAL_DANCE_EFFECT, 70, GRASS, 100, 20 + move STRING_SHOT, SPEED_DOWN1_EFFECT, 0, BUG, 95, 40 + move DRAGON_RAGE, SPECIAL_DAMAGE_EFFECT, 1, DRAGON, 100, 10 + move FIRE_SPIN, TRAPPING_EFFECT, 15, FIRE, 70, 15 + move THUNDERSHOCK, PARALYZE_SIDE_EFFECT1, 40, ELECTRIC, 100, 30 + move THUNDERBOLT, PARALYZE_SIDE_EFFECT1, 95, ELECTRIC, 100, 15 + move THUNDER_WAVE, PARALYZE_EFFECT, 0, ELECTRIC, 100, 20 + move THUNDER, PARALYZE_SIDE_EFFECT1, 120, ELECTRIC, 70, 10 + move ROCK_THROW, NO_ADDITIONAL_EFFECT, 50, ROCK, 65, 15 + move EARTHQUAKE, NO_ADDITIONAL_EFFECT, 100, GROUND, 100, 10 + move FISSURE, OHKO_EFFECT, 1, GROUND, 30, 5 + move DIG, CHARGE_EFFECT, 100, GROUND, 100, 10 + move TOXIC, POISON_EFFECT, 0, POISON, 85, 10 + move CONFUSION, CONFUSION_SIDE_EFFECT, 50, PSYCHIC_TYPE, 100, 25 + move PSYCHIC_M, SPECIAL_DOWN_SIDE_EFFECT, 90, PSYCHIC_TYPE, 100, 10 + move HYPNOSIS, SLEEP_EFFECT, 0, PSYCHIC_TYPE, 60, 20 + move MEDITATE, ATTACK_UP1_EFFECT, 0, PSYCHIC_TYPE, 100, 40 + move AGILITY, SPEED_UP2_EFFECT, 0, PSYCHIC_TYPE, 100, 30 + move QUICK_ATTACK, NO_ADDITIONAL_EFFECT, 40, NORMAL, 100, 30 + move RAGE, RAGE_EFFECT, 20, NORMAL, 100, 20 + move TELEPORT, SWITCH_AND_TELEPORT_EFFECT, 0, PSYCHIC_TYPE, 100, 20 + move NIGHT_SHADE, SPECIAL_DAMAGE_EFFECT, 0, GHOST, 100, 15 + move MIMIC, MIMIC_EFFECT, 0, NORMAL, 100, 10 + move SCREECH, DEFENSE_DOWN2_EFFECT, 0, NORMAL, 85, 40 + move DOUBLE_TEAM, EVASION_UP1_EFFECT, 0, NORMAL, 100, 15 + move RECOVER, HEAL_EFFECT, 0, NORMAL, 100, 20 + move HARDEN, DEFENSE_UP1_EFFECT, 0, NORMAL, 100, 30 + move MINIMIZE, EVASION_UP1_EFFECT, 0, NORMAL, 100, 20 + move SMOKESCREEN, ACCURACY_DOWN1_EFFECT, 0, NORMAL, 100, 20 + move CONFUSE_RAY, CONFUSION_EFFECT, 0, GHOST, 100, 10 + move WITHDRAW, DEFENSE_UP1_EFFECT, 0, WATER, 100, 40 + move DEFENSE_CURL, DEFENSE_UP1_EFFECT, 0, NORMAL, 100, 40 + move BARRIER, DEFENSE_UP2_EFFECT, 0, PSYCHIC_TYPE, 100, 30 + move LIGHT_SCREEN, LIGHT_SCREEN_EFFECT, 0, PSYCHIC_TYPE, 100, 30 + move HAZE, HAZE_EFFECT, 0, ICE, 100, 30 + move REFLECT, REFLECT_EFFECT, 0, PSYCHIC_TYPE, 100, 20 + move FOCUS_ENERGY, FOCUS_ENERGY_EFFECT, 0, NORMAL, 100, 30 + move BIDE, BIDE_EFFECT, 0, NORMAL, 100, 10 + move METRONOME, METRONOME_EFFECT, 0, NORMAL, 100, 10 + move MIRROR_MOVE, MIRROR_MOVE_EFFECT, 0, FLYING, 100, 20 + move SELFDESTRUCT, EXPLODE_EFFECT, 130, NORMAL, 100, 5 + move EGG_BOMB, NO_ADDITIONAL_EFFECT, 100, NORMAL, 75, 10 + move LICK, PARALYZE_SIDE_EFFECT2, 20, GHOST, 100, 30 + move SMOG, POISON_SIDE_EFFECT2, 20, POISON, 70, 20 + move SLUDGE, POISON_SIDE_EFFECT2, 65, POISON, 100, 20 + move BONE_CLUB, FLINCH_SIDE_EFFECT1, 65, GROUND, 85, 20 + move FIRE_BLAST, BURN_SIDE_EFFECT2, 120, FIRE, 85, 5 + move WATERFALL, NO_ADDITIONAL_EFFECT, 80, WATER, 100, 15 + move CLAMP, TRAPPING_EFFECT, 35, WATER, 75, 10 + move SWIFT, SWIFT_EFFECT, 60, NORMAL, 100, 20 + move SKULL_BASH, CHARGE_EFFECT, 100, NORMAL, 100, 15 + move SPIKE_CANNON, TWO_TO_FIVE_ATTACKS_EFFECT, 20, NORMAL, 100, 15 + move CONSTRICT, SPEED_DOWN_SIDE_EFFECT, 10, NORMAL, 100, 35 + move AMNESIA, SPECIAL_UP2_EFFECT, 0, PSYCHIC_TYPE, 100, 20 + move KINESIS, ACCURACY_DOWN1_EFFECT, 0, PSYCHIC_TYPE, 80, 15 + move SOFTBOILED, HEAL_EFFECT, 0, NORMAL, 100, 10 + move HI_JUMP_KICK, JUMP_KICK_EFFECT, 85, FIGHTING, 90, 20 + move GLARE, PARALYZE_EFFECT, 0, NORMAL, 75, 30 + move DREAM_EATER, DREAM_EATER_EFFECT, 100, PSYCHIC_TYPE, 100, 15 + move POISON_GAS, POISON_EFFECT, 0, POISON, 55, 40 + move BARRAGE, TWO_TO_FIVE_ATTACKS_EFFECT, 15, NORMAL, 85, 20 + move LEECH_LIFE, DRAIN_HP_EFFECT, 20, BUG, 100, 15 + move LOVELY_KISS, SLEEP_EFFECT, 0, NORMAL, 75, 10 + move SKY_ATTACK, CHARGE_EFFECT, 140, FLYING, 90, 5 + move TRANSFORM, TRANSFORM_EFFECT, 0, NORMAL, 100, 10 + move BUBBLE, SPEED_DOWN_SIDE_EFFECT, 20, WATER, 100, 30 + move DIZZY_PUNCH, NO_ADDITIONAL_EFFECT, 70, NORMAL, 100, 10 + move SPORE, SLEEP_EFFECT, 0, GRASS, 100, 15 + move FLASH, ACCURACY_DOWN1_EFFECT, 0, NORMAL, 70, 20 + move PSYWAVE, SPECIAL_DAMAGE_EFFECT, 1, PSYCHIC_TYPE, 80, 15 + move SPLASH, SPLASH_EFFECT, 0, NORMAL, 100, 40 + move ACID_ARMOR, DEFENSE_UP2_EFFECT, 0, POISON, 100, 40 + move CRABHAMMER, NO_ADDITIONAL_EFFECT, 90, WATER, 85, 10 + move EXPLOSION, EXPLODE_EFFECT, 170, NORMAL, 100, 5 + move FURY_SWIPES, TWO_TO_FIVE_ATTACKS_EFFECT, 18, NORMAL, 80, 15 + move BONEMERANG, ATTACK_TWICE_EFFECT, 50, GROUND, 90, 10 + move REST, HEAL_EFFECT, 0, PSYCHIC_TYPE, 100, 10 + move ROCK_SLIDE, NO_ADDITIONAL_EFFECT, 75, ROCK, 90, 10 + move HYPER_FANG, FLINCH_SIDE_EFFECT1, 80, NORMAL, 90, 15 + move SHARPEN, ATTACK_UP1_EFFECT, 0, NORMAL, 100, 30 + move CONVERSION, CONVERSION_EFFECT, 0, NORMAL, 100, 30 + move TRI_ATTACK, NO_ADDITIONAL_EFFECT, 80, NORMAL, 100, 10 + move SUPER_FANG, SUPER_FANG_EFFECT, 1, NORMAL, 90, 10 + move SLASH, NO_ADDITIONAL_EFFECT, 70, NORMAL, 100, 20 + move SUBSTITUTE, SUBSTITUTE_EFFECT, 0, NORMAL, 100, 10 + move STRUGGLE, RECOIL_EFFECT, 50, NORMAL, 100, 10 diff --git a/data/pokemon/base_stats/abra.asm b/data/pokemon/base_stats/abra.asm index 522bd0a5..97009888 100644 --- a/data/pokemon/base_stats/abra.asm +++ b/data/pokemon/base_stats/abra.asm @@ -3,7 +3,7 @@ db 25, 20, 15, 90, 105 ; hp atk def spd spc - db PSYCHIC, PSYCHIC ; type + db PSYCHIC_TYPE, PSYCHIC_TYPE ; type db 200 ; catch rate db 73 ; base exp diff --git a/data/pokemon/base_stats/alakazam.asm b/data/pokemon/base_stats/alakazam.asm index d4b8296a..dd1fe126 100644 --- a/data/pokemon/base_stats/alakazam.asm +++ b/data/pokemon/base_stats/alakazam.asm @@ -3,7 +3,7 @@ db 55, 50, 45, 120, 135 ; hp atk def spd spc - db PSYCHIC, PSYCHIC ; type + db PSYCHIC_TYPE, PSYCHIC_TYPE ; type db 50 ; catch rate db 186 ; base exp diff --git a/data/pokemon/base_stats/drowzee.asm b/data/pokemon/base_stats/drowzee.asm index 756c2bae..e1760ebe 100644 --- a/data/pokemon/base_stats/drowzee.asm +++ b/data/pokemon/base_stats/drowzee.asm @@ -3,7 +3,7 @@ db 60, 48, 45, 42, 90 ; hp atk def spd spc - db PSYCHIC, PSYCHIC ; type + db PSYCHIC_TYPE, PSYCHIC_TYPE ; type db 190 ; catch rate db 102 ; base exp diff --git a/data/pokemon/base_stats/exeggcute.asm b/data/pokemon/base_stats/exeggcute.asm index ee91449d..3e0cb826 100644 --- a/data/pokemon/base_stats/exeggcute.asm +++ b/data/pokemon/base_stats/exeggcute.asm @@ -3,7 +3,7 @@ db 60, 40, 80, 40, 60 ; hp atk def spd spc - db GRASS, PSYCHIC ; type + db GRASS, PSYCHIC_TYPE ; type db 90 ; catch rate db 98 ; base exp diff --git a/data/pokemon/base_stats/exeggutor.asm b/data/pokemon/base_stats/exeggutor.asm index 6d12f9cb..2c68c724 100644 --- a/data/pokemon/base_stats/exeggutor.asm +++ b/data/pokemon/base_stats/exeggutor.asm @@ -3,7 +3,7 @@ db 95, 95, 85, 55, 125 ; hp atk def spd spc - db GRASS, PSYCHIC ; type + db GRASS, PSYCHIC_TYPE ; type db 45 ; catch rate db 212 ; base exp diff --git a/data/pokemon/base_stats/hypno.asm b/data/pokemon/base_stats/hypno.asm index b03cb2a0..208c5bd2 100644 --- a/data/pokemon/base_stats/hypno.asm +++ b/data/pokemon/base_stats/hypno.asm @@ -3,7 +3,7 @@ db 85, 73, 70, 67, 115 ; hp atk def spd spc - db PSYCHIC, PSYCHIC ; type + db PSYCHIC_TYPE, PSYCHIC_TYPE ; type db 75 ; catch rate db 165 ; base exp diff --git a/data/pokemon/base_stats/jynx.asm b/data/pokemon/base_stats/jynx.asm index 0324d5f9..6cc52608 100644 --- a/data/pokemon/base_stats/jynx.asm +++ b/data/pokemon/base_stats/jynx.asm @@ -3,7 +3,7 @@ db 65, 50, 35, 95, 95 ; hp atk def spd spc - db ICE, PSYCHIC ; type + db ICE, PSYCHIC_TYPE ; type db 45 ; catch rate db 137 ; base exp diff --git a/data/pokemon/base_stats/kadabra.asm b/data/pokemon/base_stats/kadabra.asm index eba3878b..6ce061e8 100644 --- a/data/pokemon/base_stats/kadabra.asm +++ b/data/pokemon/base_stats/kadabra.asm @@ -3,7 +3,7 @@ db 40, 35, 30, 105, 120 ; hp atk def spd spc - db PSYCHIC, PSYCHIC ; type + db PSYCHIC_TYPE, PSYCHIC_TYPE ; type db 100 ; catch rate db 145 ; base exp diff --git a/data/pokemon/base_stats/mew.asm b/data/pokemon/base_stats/mew.asm index d601c7a0..e65e45ec 100644 --- a/data/pokemon/base_stats/mew.asm +++ b/data/pokemon/base_stats/mew.asm @@ -3,7 +3,7 @@ db 100, 100, 100, 100, 100 ; hp atk def spd spc - db PSYCHIC, PSYCHIC ; type + db PSYCHIC_TYPE, PSYCHIC_TYPE ; type db 45 ; catch rate db 64 ; base exp diff --git a/data/pokemon/base_stats/mewtwo.asm b/data/pokemon/base_stats/mewtwo.asm index fd77502d..4142479b 100644 --- a/data/pokemon/base_stats/mewtwo.asm +++ b/data/pokemon/base_stats/mewtwo.asm @@ -3,7 +3,7 @@ db 106, 110, 90, 130, 154 ; hp atk def spd spc - db PSYCHIC, PSYCHIC ; type + db PSYCHIC_TYPE, PSYCHIC_TYPE ; type db 3 ; catch rate db 220 ; base exp diff --git a/data/pokemon/base_stats/mrmime.asm b/data/pokemon/base_stats/mrmime.asm index 44b11ad1..c4d98f79 100644 --- a/data/pokemon/base_stats/mrmime.asm +++ b/data/pokemon/base_stats/mrmime.asm @@ -3,7 +3,7 @@ db 40, 45, 65, 90, 100 ; hp atk def spd spc - db PSYCHIC, PSYCHIC ; type + db PSYCHIC_TYPE, PSYCHIC_TYPE ; type db 45 ; catch rate db 136 ; base exp diff --git a/data/pokemon/base_stats/slowbro.asm b/data/pokemon/base_stats/slowbro.asm index 939229d6..a5e067d2 100644 --- a/data/pokemon/base_stats/slowbro.asm +++ b/data/pokemon/base_stats/slowbro.asm @@ -3,7 +3,7 @@ db 95, 75, 110, 30, 80 ; hp atk def spd spc - db WATER, PSYCHIC ; type + db WATER, PSYCHIC_TYPE ; type db 75 ; catch rate db 164 ; base exp diff --git a/data/pokemon/base_stats/slowpoke.asm b/data/pokemon/base_stats/slowpoke.asm index 77c48277..acb8d0ed 100644 --- a/data/pokemon/base_stats/slowpoke.asm +++ b/data/pokemon/base_stats/slowpoke.asm @@ -3,7 +3,7 @@ db 90, 65, 65, 15, 40 ; hp atk def spd spc - db WATER, PSYCHIC ; type + db WATER, PSYCHIC_TYPE ; type db 190 ; catch rate db 99 ; base exp diff --git a/data/pokemon/base_stats/starmie.asm b/data/pokemon/base_stats/starmie.asm index 5792c21f..dfbad82d 100644 --- a/data/pokemon/base_stats/starmie.asm +++ b/data/pokemon/base_stats/starmie.asm @@ -3,7 +3,7 @@ db 60, 75, 85, 115, 100 ; hp atk def spd spc - db WATER, PSYCHIC ; type + db WATER, PSYCHIC_TYPE ; type db 60 ; catch rate db 207 ; base exp diff --git a/data/pokemon/title_mons.asm b/data/pokemon/title_mons.asm index c5d94301..c0acd13a 100755 --- a/data/pokemon/title_mons.asm +++ b/data/pokemon/title_mons.asm @@ -1,9 +1,9 @@ TitleMons: ; mons on the title screen are randomly chosen from here IF DEF(_RED) - db CHARMANDER - db SQUIRTLE - db BULBASAUR + db STARTER1 + db STARTER2 + db STARTER3 db WEEDLE db NIDORAN_M db SCYTHER @@ -19,9 +19,9 @@ IF DEF(_RED) db MAGIKARP ENDC IF DEF(_GREEN) - db BULBASAUR - db CHARMANDER - db SQUIRTLE + db STARTER3 + db STARTER1 + db STARTER2 db CATERPIE db NIDORAN_F db PINSIR @@ -37,9 +37,9 @@ IF DEF(_GREEN) db MAGIKARP ENDC IF DEF(_BLUE) - db SQUIRTLE - db CHARMANDER - db BULBASAUR + db STARTER2 + db STARTER1 + db STARTER3 db MANKEY db HITMONLEE db VULPIX diff --git a/data/types/type_matchups.asm b/data/types/type_matchups.asm index 1321a3d9..52e3d956 100755 --- a/data/types/type_matchups.asm +++ b/data/types/type_matchups.asm @@ -1,89 +1,85 @@ TypeEffects: -; format: attacking type, defending type, damage multiplier -; the multiplier is a (decimal) fixed-point number: -; 20 is ×2.0 -; 05 is ×0.5 -; 00 is ×0 - db WATER,FIRE,20 - db FIRE,GRASS,20 - db FIRE,ICE,20 - db GRASS,WATER,20 - db ELECTRIC,WATER,20 - db WATER,ROCK,20 - db GROUND,FLYING,00 - db WATER,WATER,05 - db FIRE,FIRE,05 - db ELECTRIC,ELECTRIC,05 - db ICE,ICE,05 - db GRASS,GRASS,05 - db PSYCHIC,PSYCHIC,05 - db FIRE,WATER,05 - db GRASS,FIRE,05 - db WATER,GRASS,05 - db ELECTRIC,GRASS,05 - db NORMAL,ROCK,05 - db NORMAL,GHOST,00 - db GHOST,GHOST,20 - db FIRE,BUG,20 - db FIRE,ROCK,05 - db WATER,GROUND,20 - db ELECTRIC,GROUND,00 - db ELECTRIC,FLYING,20 - db GRASS,GROUND,20 - db GRASS,BUG,05 - db GRASS,POISON,05 - db GRASS,ROCK,20 - db GRASS,FLYING,05 - db ICE,WATER,05 - db ICE,GRASS,20 - db ICE,GROUND,20 - db ICE,FLYING,20 - db FIGHTING,NORMAL,20 - db FIGHTING,POISON,05 - db FIGHTING,FLYING,05 - db FIGHTING,PSYCHIC,05 - db FIGHTING,BUG,05 - db FIGHTING,ROCK,20 - db FIGHTING,ICE,20 - db FIGHTING,GHOST,00 - db POISON,GRASS,20 - db POISON,POISON,05 - db POISON,GROUND,05 - db POISON,BUG,20 - db POISON,ROCK,05 - db POISON,GHOST,05 - db GROUND,FIRE,20 - db GROUND,ELECTRIC,20 - db GROUND,GRASS,05 - db GROUND,BUG,05 - db GROUND,ROCK,20 - db GROUND,POISON,20 - db FLYING,ELECTRIC,05 - db FLYING,FIGHTING,20 - db FLYING,BUG,20 - db FLYING,GRASS,20 - db FLYING,ROCK,05 - db PSYCHIC,FIGHTING,20 - db PSYCHIC,POISON,20 - db BUG,FIRE,05 - db BUG,GRASS,20 - db BUG,FIGHTING,05 - db BUG,FLYING,05 - db BUG,PSYCHIC,20 - db BUG,GHOST,05 - db BUG,POISON,20 - db ROCK,FIRE,20 - db ROCK,FIGHTING,05 - db ROCK,GROUND,05 - db ROCK,FLYING,20 - db ROCK,BUG,20 - db ROCK,ICE,20 - db GHOST,NORMAL,00 - db GHOST,PSYCHIC,00 - db FIRE,DRAGON,05 - db WATER,DRAGON,05 - db ELECTRIC,DRAGON,05 - db GRASS,DRAGON,05 - db ICE,DRAGON,20 - db DRAGON,DRAGON,20 - db $FF + ; attacker, defender, *= + db WATER, FIRE, SUPER_EFFECTIVE + db FIRE, GRASS, SUPER_EFFECTIVE + db FIRE, ICE, SUPER_EFFECTIVE + db GRASS, WATER, SUPER_EFFECTIVE + db ELECTRIC, WATER, SUPER_EFFECTIVE + db WATER, ROCK, SUPER_EFFECTIVE + db GROUND, FLYING, NO_EFFECT + db WATER, WATER, NOT_VERY_EFFECTIVE + db FIRE, FIRE, NOT_VERY_EFFECTIVE + db ELECTRIC, ELECTRIC, NOT_VERY_EFFECTIVE + db ICE, ICE, NOT_VERY_EFFECTIVE + db GRASS, GRASS, NOT_VERY_EFFECTIVE + db PSYCHIC_TYPE, PSYCHIC_TYPE, NOT_VERY_EFFECTIVE + db FIRE, WATER, NOT_VERY_EFFECTIVE + db GRASS, FIRE, NOT_VERY_EFFECTIVE + db WATER, GRASS, NOT_VERY_EFFECTIVE + db ELECTRIC, GRASS, NOT_VERY_EFFECTIVE + db NORMAL, ROCK, NOT_VERY_EFFECTIVE + db NORMAL, GHOST, NO_EFFECT + db GHOST, GHOST, SUPER_EFFECTIVE + db FIRE, BUG, SUPER_EFFECTIVE + db FIRE, ROCK, NOT_VERY_EFFECTIVE + db WATER, GROUND, SUPER_EFFECTIVE + db ELECTRIC, GROUND, NO_EFFECT + db ELECTRIC, FLYING, SUPER_EFFECTIVE + db GRASS, GROUND, SUPER_EFFECTIVE + db GRASS, BUG, NOT_VERY_EFFECTIVE + db GRASS, POISON, NOT_VERY_EFFECTIVE + db GRASS, ROCK, SUPER_EFFECTIVE + db GRASS, FLYING, NOT_VERY_EFFECTIVE + db ICE, WATER, NOT_VERY_EFFECTIVE + db ICE, GRASS, SUPER_EFFECTIVE + db ICE, GROUND, SUPER_EFFECTIVE + db ICE, FLYING, SUPER_EFFECTIVE + db FIGHTING, NORMAL, SUPER_EFFECTIVE + db FIGHTING, POISON, NOT_VERY_EFFECTIVE + db FIGHTING, FLYING, NOT_VERY_EFFECTIVE + db FIGHTING, PSYCHIC_TYPE, NOT_VERY_EFFECTIVE + db FIGHTING, BUG, NOT_VERY_EFFECTIVE + db FIGHTING, ROCK, SUPER_EFFECTIVE + db FIGHTING, ICE, SUPER_EFFECTIVE + db FIGHTING, GHOST, NO_EFFECT + db POISON, GRASS, SUPER_EFFECTIVE + db POISON, POISON, NOT_VERY_EFFECTIVE + db POISON, GROUND, NOT_VERY_EFFECTIVE + db POISON, BUG, SUPER_EFFECTIVE + db POISON, ROCK, NOT_VERY_EFFECTIVE + db POISON, GHOST, NOT_VERY_EFFECTIVE + db GROUND, FIRE, SUPER_EFFECTIVE + db GROUND, ELECTRIC, SUPER_EFFECTIVE + db GROUND, GRASS, NOT_VERY_EFFECTIVE + db GROUND, BUG, NOT_VERY_EFFECTIVE + db GROUND, ROCK, SUPER_EFFECTIVE + db GROUND, POISON, SUPER_EFFECTIVE + db FLYING, ELECTRIC, NOT_VERY_EFFECTIVE + db FLYING, FIGHTING, SUPER_EFFECTIVE + db FLYING, BUG, SUPER_EFFECTIVE + db FLYING, GRASS, SUPER_EFFECTIVE + db FLYING, ROCK, NOT_VERY_EFFECTIVE + db PSYCHIC_TYPE, FIGHTING, SUPER_EFFECTIVE + db PSYCHIC_TYPE, POISON, SUPER_EFFECTIVE + db BUG, FIRE, NOT_VERY_EFFECTIVE + db BUG, GRASS, SUPER_EFFECTIVE + db BUG, FIGHTING, NOT_VERY_EFFECTIVE + db BUG, FLYING, NOT_VERY_EFFECTIVE + db BUG, PSYCHIC_TYPE, SUPER_EFFECTIVE + db BUG, GHOST, NOT_VERY_EFFECTIVE + db BUG, POISON, SUPER_EFFECTIVE + db ROCK, FIRE, SUPER_EFFECTIVE + db ROCK, FIGHTING, NOT_VERY_EFFECTIVE + db ROCK, GROUND, NOT_VERY_EFFECTIVE + db ROCK, FLYING, SUPER_EFFECTIVE + db ROCK, BUG, SUPER_EFFECTIVE + db ROCK, ICE, SUPER_EFFECTIVE + db GHOST, NORMAL, NO_EFFECT + db GHOST, PSYCHIC_TYPE, NO_EFFECT + db FIRE, DRAGON, NOT_VERY_EFFECTIVE + db WATER, DRAGON, NOT_VERY_EFFECTIVE + db ELECTRIC, DRAGON, NOT_VERY_EFFECTIVE + db GRASS, DRAGON, NOT_VERY_EFFECTIVE + db ICE, DRAGON, SUPER_EFFECTIVE + db DRAGON, DRAGON, SUPER_EFFECTIVE + db -1 ; end diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm index 78301b2e..4e836510 100755 --- a/engine/battle/animations.asm +++ b/engine/battle/animations.asm @@ -163,7 +163,7 @@ DrawFrameBlock: PlayAnimation: xor a - ld [hROMBankTemp], a ; it looks like nothing reads this + ldh [hROMBankTemp], a ; it looks like nothing reads this ld [wSubAnimTransform], a ld a, [wAnimationID] ; get animation number dec a @@ -241,15 +241,15 @@ PlayAnimation: ld l, c ld h, b push hl - ld a, [rOBP0] + ldh a, [rOBP0] push af ld a, [wAnimPalette] - ld [rOBP0], a + ldh [rOBP0], a call LoadAnimationTileset call LoadSubanimation call PlaySubanimation pop af - ld [rOBP0], a + ldh [rOBP0], a .nextAnimationCommand pop hl jr .animationLoop @@ -308,7 +308,7 @@ LoadSubanimation: ; sets the transform to the subanimation type if it's the enemy's turn GetSubanimationTransform1: ld b, a - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld a, b 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 0 (i.e. no transform) if it's the enemy's turn GetSubanimationTransform2: - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld a, 2 << 5 ret z @@ -341,7 +341,7 @@ LoadAnimationTileset: ld e, a ld a, [hl] ld d, a ; de = address of tileset - ld hl, vSprites + $310 + ld hl, vSprites tile $31 ld b, BANK(AnimationTileset1) ; ROM bank ld a, [wTempTilesetNumTiles] ld c, a ; number of tiles @@ -373,6 +373,7 @@ ENDC IF DEF(_BLUE) INCBIN "gfx/slots/blue_slots_2.2bpp" ENDC +SlotMachineTiles2End: MoveAnimation: push hl @@ -421,11 +422,11 @@ MoveAnimation: ShareMoveAnimations: ; some moves just reuse animations from status conditions - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ret z - ; opponent’s turn + ; opponent's turn ld a, [wAnimationID] @@ -497,18 +498,18 @@ AnimationShakeScreenHorizontallySlow: push bc push bc .loop1 - ld a, [rWX] + ldh a, [rWX] inc a - ld [rWX], a + ldh [rWX], a ld c, 2 call DelayFrames dec b jr nz, .loop1 pop bc .loop2 - ld a, [rWX] + ldh a, [rWX] dec a - ld [rWX], a + ldh [rWX], a ld c, 2 call DelayFrames dec b @@ -534,16 +535,16 @@ SetAnimationPalette: ld b, $f0 .next ld a, b - ld [rOBP0], a + ldh [rOBP0], a ld a, $6c - ld [rOBP1], a + ldh [rOBP1], a ret .notSGB ld a, $e4 ld [wAnimPalette], a - ld [rOBP0], a + ldh [rOBP0], a ld a, $6c - ld [rOBP1], a + ldh [rOBP1], a ret PlaySubanimation: @@ -656,9 +657,9 @@ DoBallTossSpecialEffects: cp 3 ; is it a Master Ball or Ultra Ball? jr nc, .skipFlashingEffect .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 - ld [rOBP0], a + ldh [rOBP0], a .skipFlashingEffect ld a, [wSubAnimCounter] cp 11 ; is it the beginning of the subanimation? @@ -682,7 +683,7 @@ DoBallTossSpecialEffects: cp 1 ret nz .moveGhostMarowakLeft - coord hl, 17, 0 + hlcoord 17, 0 ld de, 20 lb bc, 7, 7 .loop @@ -695,7 +696,7 @@ DoBallTossSpecialEffects: dec b jr nz, .loop ld a, %00001000 - ld [rNR10], a ; Channel 1 sweep register + ldh [rNR10], a ; Channel 1 sweep register ret .isTrainerBattle ; if it's a trainer battle, shorten the animation by one frame ld a, [wSubAnimCounter] @@ -781,7 +782,7 @@ DoExplodeSpecialEffects: cp 1 ; is it the end of the subanimation? jr nz, FlashScreenEveryFourFrameBlocks ; if it's the end of the subanimation, make the attacking pokemon disappear - coord hl, 1, 5 + hlcoord 1, 5 jp AnimationHideMonPic ; make pokemon disappear ; flashes the screen when subanimation counter is 1 modulo 4 @@ -882,9 +883,9 @@ TradeJumpPokeball: ld c, 5 call DelayFrames pop bc - ld a, [hSCX] ; background scroll X + ldh a, [hSCX] ; background scroll X sub 8 ; scroll to the left - ld [hSCX], a + ldh [hSCX], a pop de jr .loop @@ -920,16 +921,16 @@ AnimationDelay10: ; calls a function with the turn flipped from player to enemy or vice versa ; input - hl - address of function to call CallWithTurnFlipped: - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] push af xor 1 - ld [hWhoseTurn], a + ldh [hWhoseTurn], a ld de, .returnAddress push de jp hl .returnAddress pop af - ld [hWhoseTurn], a + ldh [hWhoseTurn], a ret ; flashes the screen for an extended period (48 frames) @@ -947,7 +948,7 @@ AnimationFlashScreenLong: ld a, [hli] cp $01 ; is it the end of the palettes? jr z, .endOfPalettes - ld [rBGP], a + ldh [rBGP], a call FlashScreenLongDelay jr .innerLoop .endOfPalettes @@ -1006,18 +1007,18 @@ FlashScreenLongDelay: jp DelayFrames AnimationFlashScreen: - ld a, [rBGP] + ldh a, [rBGP] push af ; save initial palette ld a, %00011011 ; 0, 1, 2, 3 (inverted colors) - ld [rBGP], a + ldh [rBGP], a ld c, 2 call DelayFrames xor a ; white out background - ld [rBGP], a + ldh [rBGP], a ld c, 2 call DelayFrames pop af - ld [rBGP], a ; restore initial palette + ldh [rBGP], a ; restore initial palette ret AnimationDarkScreenPalette: @@ -1062,7 +1063,7 @@ SetAnimationBGPalette: jr z, .next ld a, c .next - ld [rBGP], a + ldh [rBGP], a ret ld b, $5 @@ -1133,14 +1134,14 @@ _AnimationWaterDroplets: AnimationSlideMonUp: ; Slides the mon's sprite upwards. ld c, 7 - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a - coord hl, 1, 6 - coord de, 1, 5 + hlcoord 1, 6 + decoord 1, 5 ld a, $30 jr z, .next - coord hl, 12, 1 - coord de, 12, 0 + hlcoord 12, 1 + decoord 12, 0 ld a, $ff .next ld [wSlideMonUpBottomRowLeftTile], a @@ -1201,11 +1202,11 @@ _AnimationSlideMonUp: jr nz, .slideLoop ; Fill in the bottom row of the mon pic with the next row's tile IDs. - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a - coord hl, 1, 11 + hlcoord 1, 11 jr z, .next - coord hl, 12, 6 + hlcoord 12, 6 .next ld a, [wSlideMonUpBottomRowLeftTile] inc a @@ -1370,13 +1371,13 @@ AnimationShowEnemyMonPic: AnimationShakeBackAndForth: ; Shakes the mon's sprite back and forth rapidly. This is used in Double Team. ; The mon's sprite disappears after this animation. - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a - coord hl, 0, 5 - coord de, 2, 5 + hlcoord 0, 5 + decoord 2, 5 jr z, .next - coord hl, 11, 0 - coord de, 13, 0 + hlcoord 11, 0 + decoord 13, 0 .next xor a @@ -1418,11 +1419,11 @@ AnimationMoveMonHorizontally: ; Shifts the mon's sprite horizontally to a fixed location. Used by lots of ; animations like Tackle/Body Slam. call AnimationHideMonPic - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a - coord hl, 2, 5 + hlcoord 2, 5 jr z, .next - coord hl, 11, 0 + hlcoord 11, 0 .next xor a push hl @@ -1434,7 +1435,7 @@ AnimationMoveMonHorizontally: AnimationResetMonPosition: ; Resets the mon's sprites to be located at the normal coordinates. - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld a, 5 * SCREEN_WIDTH + 2 jr z, .next @@ -1446,7 +1447,7 @@ AnimationResetMonPosition: AnimationSpiralBallsInward: ; Creates an effect that looks like energy balls spiralling into the ; player mon's sprite. Used in Focus Energy, for example. - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .playerTurn ld a, -40 @@ -1530,15 +1531,15 @@ AnimationSquishMonPic: ld c, 4 .loop push bc - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .playerTurn - coord hl, 16, 0 - coord de, 14, 0 + hlcoord 16, 0 + decoord 14, 0 jr .next .playerTurn - coord hl, 5, 5 - coord de, 3, 5 + hlcoord 5, 5 + decoord 3, 5 .next push de xor a ; left @@ -1583,7 +1584,7 @@ _AnimationSquishMonPic: AnimationShootBallsUpward: ; Shoots one pillar of "energy" balls upwards. Used in Teleport/Sky Attack ; animations. - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .playerTurn lb bc, 0, 16 * 8 @@ -1651,7 +1652,7 @@ _AnimationShootBallsUpward: AnimationShootManyBallsUpward: ; Shoots several pillars of "energy" balls upward. - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld hl, UpwardBallsAnimXCoordinatesPlayerTurn ld a, $50 ; y coordinate for "energy" ball pillar @@ -1743,13 +1744,13 @@ AnimationSlideMonDownAndHide: _AnimationSlideMonOff: ; 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. - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .playerTurn - coord hl, 12, 0 + hlcoord 12, 0 jr .next .playerTurn - coord hl, 0, 5 + hlcoord 0, 5 .next ld d, 8 ; d's value is unused .slideLoop ; iterates once for each time the pic slides by one tile @@ -1758,7 +1759,7 @@ _AnimationSlideMonOff: .rowLoop ; iterates once for each row ld c, 8 .tileLoop ; iterates once for each tile in the row - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .playerTurn2 call .EnemyNextTile @@ -1821,7 +1822,7 @@ AnimationSlideMonHalfOff: jp Delay3 CopyTempPicToMonPic: - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld hl, vBackPic ; player turn jr z, .next @@ -1837,9 +1838,9 @@ AnimationWavyScreen: call BattleAnimCopyTileMapToVRAM call Delay3 xor a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ld a, SCREEN_HEIGHT_PX - ld [hWY], a + ldh [hWY], a ld d, $80 ; terminator ld e, SCREEN_HEIGHT_PX - 1 ld c, $ff @@ -1848,7 +1849,7 @@ AnimationWavyScreen: push hl .innerLoop call WavyScreen_SetSCX - ld a, [rLY] + ldh a, [rLY] cp e ; is it the last visible line in the frame? jr nz, .innerLoop ; keep going if not pop hl @@ -1861,11 +1862,11 @@ AnimationWavyScreen: dec c jr nz, .loop xor a - ld [hWY], a + ldh [hWY], a call SaveScreenTilesToBuffer2 call ClearScreen ld a, 1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a call Delay3 call LoadScreenTilesFromBuffer2 ld hl, vBGMap1 @@ -1873,11 +1874,11 @@ AnimationWavyScreen: ret WavyScreen_SetSCX: - ld a, [rSTAT] + ldh a, [rSTAT] and $3 ; is it H-blank? jr nz, WavyScreen_SetSCX ; wait until it's H-blank ld a, [hl] - ld [rSCX], a + ldh [rSCX], a inc hl ld a, [hl] cp d ; have we reached the end? @@ -1898,7 +1899,7 @@ AnimationSubstitute: xor a ld bc, $310 call FillMemory - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .playerTurn ld hl, SlowbroSprite ; facing down sprite @@ -1937,7 +1938,7 @@ CopySlowbroSpriteData: jp FarCopyData2 HideSubstituteShowMonAnim: - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld hl, wPlayerMonMinimized ld a, [wPlayerBattleStatus2] @@ -1987,7 +1988,7 @@ AnimationTransformMon: ld [wChangeMonPicEnemyTurnSpecies], a ChangeMonPic: - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .playerTurn ld a, [wChangeMonPicEnemyTurnSpecies] @@ -1996,7 +1997,7 @@ ChangeMonPic: xor a ld [wSpriteFlipped], a call GetMonHeader - coord hl, 12, 0 + hlcoord 12, 0 call LoadFrontSpriteByMonIndex jr .done .playerTurn @@ -2020,11 +2021,11 @@ ChangeMonPic: AnimationHideEnemyMonPic: ; Hides the enemy mon's sprite xor a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ld hl, AnimationHideMonPic call CallWithTurnFlipped ld a, $1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a jp Delay3 InitMultipleObjectsOAM: @@ -2050,7 +2051,7 @@ InitMultipleObjectsOAM: AnimationHideMonPic: ; Hides the mon's sprite. - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .playerTurn ld a, 12 @@ -2064,7 +2065,7 @@ ClearMonPicFromTileMap: push bc ld e, a ld d, 0 - coord hl, 0, 0 + hlcoord 0, 0 add hl, de lb bc, 7, 7 call ClearScreenArea @@ -2078,7 +2079,7 @@ ClearMonPicFromTileMap: ; in order to show only a portion of the mon sprite. GetMonSpriteTileMapPointerFromRowCount: push de - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr nz, .enemyTurn ld a, 20 * 5 + 1 @@ -2086,7 +2087,7 @@ GetMonSpriteTileMapPointerFromRowCount: .enemyTurn ld a, 12 .next - coord hl, 0, 0 + hlcoord 0, 0 ld e, a ld d, 0 add hl, de @@ -2166,7 +2167,7 @@ GetMoveSound: ld b, a call IsCryMove jr nc, .NotCryMove - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr nz, .next ld a, [wBattleMonSpecies] ; get number of current monster @@ -2211,14 +2212,14 @@ IsCryMove: INCLUDE "data/moves/sfx.asm" CopyPicTiles: - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld a, $31 ; base tile ID of player mon sprite jr z, .next ; enemy turn xor a ; base tile ID of enemy mon sprite .next - ld [hBaseTileID], a + ldh [hBaseTileID], a jr CopyTileIDs_NoBGTransfer ; copy the tiles used when a mon is being sent out of or into a pokeball @@ -2235,7 +2236,7 @@ CopyDownscaledMonTiles: CopyTileIDs_NoBGTransfer: xor a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ; fall through ; b = number of rows @@ -2245,7 +2246,7 @@ CopyTileIDs: .rowLoop push bc push hl - ld a, [hBaseTileID] + ldh a, [hBaseTileID] ld b, a .columnLoop ld a, [de] @@ -2261,7 +2262,7 @@ CopyTileIDs: dec b jr nz, .rowLoop ld a, $1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a pop hl ret @@ -2361,16 +2362,16 @@ Unknown_79c50: AnimationLeavesFalling: ; Makes leaves float down from the top of the screen. This is used ; in Razor Leaf's animation. - ld a, [rOBP0] + ldh a, [rOBP0] push af ld a, [wAnimPalette] - ld [rOBP0], a + ldh [rOBP0], a ld d, $37 ; leaf tile ld a, 3 ; number of leaves ld [wNumFallingObjects], a call AnimationFallingObjects pop af - ld [rOBP0], a + ldh [rOBP0], a ret AnimationPetalsFalling: @@ -2529,7 +2530,7 @@ AnimationShakeEnemyHUD: call CopyVideoData xor a - ld [hSCX], a + ldh [hSCX], a ; 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. @@ -2539,7 +2540,7 @@ AnimationShakeEnemyHUD: ; 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. 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 ; lined up with row 0 of the window. @@ -2551,7 +2552,7 @@ AnimationShakeEnemyHUD: ; covers everything below the enemy HD with a copy that looks just like what ; was there before. 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 ; function shows up on screen. We need this because the back pic's Y coordinates @@ -2576,11 +2577,11 @@ AnimationShakeEnemyHUD: call AnimationShowMonPic call ClearSprites ld a, SCREEN_HEIGHT_PX - ld [hWY], a + ldh [hWY], a ld hl, vBGMap1 call BattleAnimCopyTileMapToVRAM xor a - ld [hWY], a + ldh [hWY], a call SaveScreenTilesToBuffer1 ld hl, vBGMap0 call BattleAnimCopyTileMapToVRAM @@ -2595,7 +2596,7 @@ AnimationShakeEnemyHUD: CopyTileIDsFromList: call GetPredefRegisters ld a, c - ld [hBaseTileID], a + ldh [hBaseTileID], a ld a, b push hl call GetTileIDList @@ -2603,30 +2604,30 @@ CopyTileIDsFromList: jp CopyTileIDs ShakeEnemyHUD_ShakeBG: - ld a, [hSCX] + ldh a, [hSCX] ld [wTempSCX], a .loop ld a, [wTempSCX] add d - ld [hSCX], a + ldh [hSCX], a ld c, 2 call DelayFrames ld a, [wTempSCX] sub d - ld [hSCX], a + ldh [hSCX], a ld c, 2 call DelayFrames dec e jr nz, .loop ld a, [wTempSCX] - ld [hSCX], a + ldh [hSCX], a ret BattleAnimCopyTileMapToVRAM: ld a, h - ld [hAutoBGTransferDest + 1], a + ldh [hAutoBGTransferDest + 1], a ld a, l - ld [hAutoBGTransferDest], a + ldh [hAutoBGTransferDest], a jp Delay3 TossBallAnimation: diff --git a/engine/battle/battle_transitions.asm b/engine/battle/battle_transitions.asm index 548e85fb..34b3fbdb 100644 --- a/engine/battle/battle_transitions.asm +++ b/engine/battle/battle_transitions.asm @@ -1,9 +1,9 @@ BattleTransition: ld a, 1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a call Delay3 xor a - ld [hWY], a + ldh [hWY], a dec a ld [wUpdateSpritesEnabled], a call DelayFrame @@ -11,7 +11,7 @@ BattleTransition: ; Determine which OAM block is being used by the enemy trainer sprite (if there ; is one). 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 b, 0 ld de, $10 @@ -154,20 +154,18 @@ GetBattleTransitionID_IsDungeonMap: INCLUDE "data/maps/dungeon_maps.asm" LoadBattleTransitionTile: - ld hl, vChars1 + $7f0 + ld hl, vChars1 tile $7f ld de, BattleTransitionTile - lb bc, BANK(BattleTransitionTile), (BattleTransitionTileEnd - BattleTransitionTile) / $10 + lb bc, BANK(BattleTransitionTile), 1 jp CopyVideoData -BattleTransitionTile: - INCBIN "gfx/overworld/battle_transition.2bpp" -BattleTransitionTileEnd: +BattleTransitionTile: INCBIN "gfx/overworld/battle_transition.2bpp" BattleTransition_BlackScreen: ld a, $ff - ld [rBGP], a - ld [rOBP0], a - ld [rOBP1], a + ldh [rBGP], a + ldh [rOBP0], a + ldh [rOBP1], a ret ; for non-dungeon trainer battles @@ -181,7 +179,7 @@ BattleTransition_Spiral: call BattleTransition_InwardSpiral jr .done .outwardSpiral - coord hl, 10, 10 + hlcoord 10, 10 ld a, $3 ld [wOutwardSpiralCurrentDirection], a ld a, l @@ -210,7 +208,7 @@ BattleTransition_Spiral: BattleTransition_InwardSpiral: ld a, 7 ld [wInwardSpiralUpdateScreenCounter], a - coord hl, 0, 0 + hlcoord 0, 0 ld c, SCREEN_HEIGHT - 1 ld de, SCREEN_WIDTH call BattleTransition_InwardSpiral_ @@ -330,7 +328,7 @@ BattleTransition_FlashScreen_: ld a, [hli] cp $1 jr z, .done - ld [rBGP], a + ldh [rBGP], a ld c, 2 call DelayFrames jr .loop @@ -349,25 +347,25 @@ BattleTransition_Shrink: .loop push bc xor a - ld [hAutoBGTransferEnabled], a - coord hl, 0, 7 - coord de, 0, 8 + ldh [hAutoBGTransferEnabled], a + hlcoord 0, 7 + decoord 0, 8 ld bc, -SCREEN_WIDTH * 2 call BattleTransition_CopyTiles1 - coord hl, 0, 10 - coord de, 0, 9 + hlcoord 0, 10 + decoord 0, 9 ld bc, SCREEN_WIDTH * 2 call BattleTransition_CopyTiles1 - coord hl, 8, 0 - coord de, 9, 0 + hlcoord 8, 0 + decoord 9, 0 ld bc, -2 call BattleTransition_CopyTiles2 - coord hl, 11, 0 - coord de, 10, 0 + hlcoord 11, 0 + decoord 10, 0 ld bc, 2 call BattleTransition_CopyTiles2 ld a, $1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ld c, 6 call DelayFrames pop bc @@ -381,23 +379,23 @@ BattleTransition_Shrink: BattleTransition_Split: ld c, SCREEN_HEIGHT / 2 xor a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a .loop push bc - coord hl, 0, 16 - coord de, 0, 17 + hlcoord 0, 16 + decoord 0, 17 ld bc, -SCREEN_WIDTH * 2 call BattleTransition_CopyTiles1 - coord hl, 0, 1 - coord de, 0, 0 + hlcoord 0, 1 + decoord 0, 0 ld bc, SCREEN_WIDTH * 2 call BattleTransition_CopyTiles1 - coord hl, 18, 0 - coord de, 19, 0 + hlcoord 18, 0 + decoord 19, 0 ld bc, -2 call BattleTransition_CopyTiles2 - coord hl, 1, 0 - coord de, 0, 0 + hlcoord 1, 0 + decoord 0, 0 ld bc, 2 call BattleTransition_CopyTiles2 call BattleTransition_TransferDelay3 @@ -493,10 +491,10 @@ BattleTransition_CopyTiles2: ; used for high level wild dungeon battles BattleTransition_VerticalStripes: ld c, SCREEN_HEIGHT - coord hl, 0, 0 - coord de, 1, 17 + hlcoord 0, 0 + decoord 1, 17 xor a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a .loop push bc push hl @@ -532,10 +530,10 @@ BattleTransition_VerticalStripes_: ; used for low level wild dungeon battles BattleTransition_HorizontalStripes: ld c, SCREEN_WIDTH - coord hl, 0, 0 - coord de, 19, 1 + hlcoord 0, 0 + decoord 19, 1 xor a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a .loop push bc push hl @@ -582,7 +580,7 @@ BattleTransition_FlashScreen: ld b, $3 call BattleTransition_FlashScreen_ xor a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ret BattleTransition_Circle_Sub1: @@ -601,10 +599,10 @@ BattleTransition_Circle_Sub1: BattleTransition_TransferDelay3: ld a, 1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a call Delay3 xor a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ret ; used for low level wild non-dungeon battles @@ -654,84 +652,84 @@ BattleTransition_Circle_Sub2: BattleTransition_HalfCircle1: db $01 dw BattleTransition_CircleData1 - dwCoord 18, 6 + dwcoord 18, 6 db $01 dw BattleTransition_CircleData2 - dwCoord 19, 3 + dwcoord 19, 3 db $01 dw BattleTransition_CircleData3 - dwCoord 18, 0 + dwcoord 18, 0 db $01 dw BattleTransition_CircleData4 - dwCoord 14, 0 + dwcoord 14, 0 db $01 dw BattleTransition_CircleData5 - dwCoord 10, 0 + dwcoord 10, 0 db $00 dw BattleTransition_CircleData5 - dwCoord 9, 0 + dwcoord 9, 0 db $00 dw BattleTransition_CircleData4 - dwCoord 5, 0 + dwcoord 5, 0 db $00 dw BattleTransition_CircleData3 - dwCoord 1, 0 + dwcoord 1, 0 db $00 dw BattleTransition_CircleData2 - dwCoord 0, 3 + dwcoord 0, 3 db $00 dw BattleTransition_CircleData1 - dwCoord 1, 6 + dwcoord 1, 6 BattleTransition_HalfCircle2: db $00 dw BattleTransition_CircleData1 - dwCoord 1, 11 + dwcoord 1, 11 db $00 dw BattleTransition_CircleData2 - dwCoord 0, 14 + dwcoord 0, 14 db $00 dw BattleTransition_CircleData3 - dwCoord 1, 17 + dwcoord 1, 17 db $00 dw BattleTransition_CircleData4 - dwCoord 5, 17 + dwcoord 5, 17 db $00 dw BattleTransition_CircleData5 - dwCoord 9, 17 + dwcoord 9, 17 db $01 dw BattleTransition_CircleData5 - dwCoord 10, 17 + dwcoord 10, 17 db $01 dw BattleTransition_CircleData4 - dwCoord 14, 17 + dwcoord 14, 17 db $01 dw BattleTransition_CircleData3 - dwCoord 18, 17 + dwcoord 18, 17 db $01 dw BattleTransition_CircleData2 - dwCoord 19, 14 + dwcoord 19, 14 db $01 dw BattleTransition_CircleData1 - dwCoord 18, 11 + dwcoord 18, 11 BattleTransition_Circle_Sub3: push hl diff --git a/engine/battle/common_text.asm b/engine/battle/common_text.asm index 1cb455f3..9f6f90b6 100644 --- a/engine/battle/common_text.asm +++ b/engine/battle/common_text.asm @@ -24,7 +24,7 @@ PrintBeginningBattleText: ld hl, TrainerWantsToFightText .wildBattle push hl - callab DrawAllPokeballs + callfar DrawAllPokeballs pop hl call PrintText jr .done @@ -38,7 +38,7 @@ PrintBeginningBattleText: ld a, b and a jr z, .noSilphScope - callab LoadEnemyMonData + callfar LoadEnemyMonData jr .notPokemonTower .noSilphScope ld hl, EnemyAppearedText @@ -54,8 +54,8 @@ PrintBeginningBattleText: call PrintText ld hl, UnveiledGhostText call PrintText - callab LoadEnemyMonData - callab MarowakAnim + callfar LoadEnemyMonData + callfar MarowakAnim ld hl, WildMonAppearedText call PrintText @@ -101,16 +101,16 @@ PrintSendOutMonMessage: ld hl, GoText jr z, .printText xor a - ld [hMultiplicand], a + ldh [hMultiplicand], a ld hl, wEnemyMonHP ld a, [hli] ld [wLastSwitchInEnemyMonHP], a - ld [hMultiplicand + 1], a + ldh [hMultiplicand + 1], a ld a, [hl] ld [wLastSwitchInEnemyMonHP + 1], a - ld [hMultiplicand + 2], a + ldh [hMultiplicand + 2], a ld a, 25 - ld [hMultiplier], a + ldh [hMultiplier], a call Multiply ld hl, wEnemyMonMaxHP ld a, [hli] @@ -121,9 +121,9 @@ PrintSendOutMonMessage: rr b ld a, b 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 - 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 cp 70 jr nc, .printText @@ -179,14 +179,14 @@ PlayerMon2Text: dec hl ld a, [de] sub b - ld [hMultiplicand + 2], a + ldh [hMultiplicand + 2], a dec de ld b, [hl] ld a, [de] sbc b - ld [hMultiplicand + 1], a + ldh [hMultiplicand + 1], a ld a, 25 - ld [hMultiplier], a + ldh [hMultiplier], a call Multiply ld hl, wEnemyMonMaxHP ld a, [hli] @@ -197,11 +197,11 @@ PlayerMon2Text: rr b ld a, b ld b, 4 - ld [hDivisor], a + ldh [hDivisor], a call Divide pop bc 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, ; a approximates the percentage that the enemy mon's total HP has decreased ; since the last switch in. diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 935764aa..5cf8a45d 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -11,7 +11,7 @@ SlidePlayerAndEnemySilhouettesOnScreen: ld a, MESSAGE_BOX ; the usual text box at the bottom of the screen ld [wTextBoxID], a call DisplayTextBoxID - coord hl, 1, 5 + hlcoord 1, 5 lb bc, 3, 7 call ClearScreenArea call DisableLCD @@ -27,7 +27,7 @@ SlidePlayerAndEnemySilhouettesOnScreen: or c jr nz, .clearBackgroundLoop ; copy the work RAM tile map to VRAM - coord hl, 0, 0 + hlcoord 0, 0 ld de, vBGMap0 ld b, 18 ; number of rows .copyRowLoop @@ -48,25 +48,25 @@ SlidePlayerAndEnemySilhouettesOnScreen: jr nz, .copyRowLoop call EnableLCD ld a, $90 - ld [hWY], a - ld [rWY], a + ldh [hWY], a + ldh [rWY], a xor a - ld [hTilesetType], a - ld [hSCY], a + ldh [hTilesetType], a + ldh [hSCY], a dec a ld [wUpdateSpritesEnabled], a call Delay3 xor a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ld b, $70 ld c, $90 ld a, c - ld [hSCX], a + ldh [hSCX], a call DelayFrame ld a, %11100100 ; inverted palette for silhouette effect - ld [rBGP], a - ld [rOBP0], a - ld [rOBP1], a + ldh [rBGP], a + ldh [rOBP0], a + ldh [rOBP1], a .slideSilhouettesLoop ; slide silhouettes of the player's pic and the enemy's pic onto the screen ld h, b ld l, $40 @@ -78,26 +78,26 @@ SlidePlayerAndEnemySilhouettesOnScreen: call SetScrollXForSlidingPlayerBodyLeft ; end background scrolling on line $60 call SlidePlayerHeadLeft ld a, c - ld [hSCX], a + ldh [hSCX], a dec c dec c jr nz, .slideSilhouettesLoop ld a, $1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ld a, $31 - ld [hStartTileID], a - coord hl, 1, 5 + ldh [hStartTileID], a + hlcoord 1, 5 predef CopyUncompressedPicToTilemap xor a - ld [hWY], a - ld [rWY], a + ldh [hWY], a + ldh [rWY], a inc a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a call Delay3 ld b, SET_PAL_BATTLE call RunPaletteCommand call HideSprites - jpab PrintBeginningBattleText + jpfar PrintBeginningBattleText ; when a battle is starting, silhouettes of the player's pic and the enemy's pic are slid onto the screen ; the lower of the player's pic (his body) is part of the background, but his head is a sprite @@ -118,13 +118,13 @@ SlidePlayerHeadLeft: ret SetScrollXForSlidingPlayerBodyLeft: - ld a, [rLY] + ldh a, [rLY] cp l jr nz, SetScrollXForSlidingPlayerBodyLeft ld a, h - ld [rSCX], a + ldh [rSCX], a .loop - ld a, [rLY] + ldh a, [rLY] cp h jr z, .loop ret @@ -178,7 +178,7 @@ StartBattle: ld hl, .outOfSafariBallsText jp PrintText .notOutOfSafariBalls - callab PrintSafariZoneBattleText + callfar PrintSafariZoneBattleText ld a, [wEnemyMonSpeed + 1] add a ld b, a ; init b (which is later compared with random value) to (enemy speed % 256) * 2 @@ -232,7 +232,7 @@ StartBattle: ld [wcf91], a ld [wBattleMonSpecies2], a call LoadScreenTilesFromBuffer1 - coord hl, 1, 5 + hlcoord 1, 5 ld a, $9 call SlideTrainerPicOffScreen call SaveScreenTilesToBuffer1 @@ -266,8 +266,8 @@ EnemyRan: ld a, SFX_RUN call PlaySoundWaitForCurrent xor a - ld [hWhoseTurn], a - jpab AnimationSlideEnemyMonOff + ldh [hWhoseTurn], a + jpfar AnimationSlideEnemyMonOff WildRanText: text_far _WildRanText @@ -365,7 +365,7 @@ MainInBattleLoop: jr nz, .specialMoveNotUsed ld [wPlayerSelectedMove], a .specialMoveNotUsed - callab SwitchEnemyMon + callfar SwitchEnemyMon .noLinkBattle ld a, [wPlayerSelectedMove] cp QUICK_ATTACK @@ -398,7 +398,7 @@ MainInBattleLoop: jr nc, .playerMovesFirst ; if player is faster jr .enemyMovesFirst ; if enemy is faster .speedEqual ; 50/50 chance for both players - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] cp USING_INTERNAL_CLOCK jr z, .invertOutcome call BattleRandom @@ -412,8 +412,8 @@ MainInBattleLoop: jr .playerMovesFirst .enemyMovesFirst ld a, $1 - ld [hWhoseTurn], a - callab TrainerAI + ldh [hWhoseTurn], a + callfar TrainerAI jr c, .AIActionUsedEnemyFirst call ExecuteEnemyMove ld a, [wEscapedFromBattle] @@ -450,8 +450,8 @@ MainInBattleLoop: jp z, HandlePlayerMonFainted call DrawHUDsAndHPBars ld a, $1 - ld [hWhoseTurn], a - callab TrainerAI + ldh [hWhoseTurn], a + callfar TrainerAI jr c, .AIActionUsedPlayerFirst call ExecuteEnemyMove ld a, [wEscapedFromBattle] @@ -470,7 +470,7 @@ MainInBattleLoop: HandlePoisonBurnLeechSeed: ld hl, wBattleMonHP ld de, wBattleMonStatus - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .playersTurn ld hl, wEnemyMonHP @@ -495,7 +495,7 @@ HandlePoisonBurnLeechSeed: call HandlePoisonBurnLeechSeed_DecreaseOwnHP .notBurnedOrPoisoned ld de, wPlayerBattleStatus2 - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .playersTurn2 ld de, wEnemyBattleStatus2 @@ -504,16 +504,16 @@ HandlePoisonBurnLeechSeed: add a jr nc, .notLeechSeeded push hl - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] push af xor $1 - ld [hWhoseTurn], a + ldh [hWhoseTurn], a xor a ld [wAnimationType], a ld a, ABSORB call PlayMoveAnimation ; play leech seed animation (from opposing mon) pop af - ld [hWhoseTurn], a + ldh [hWhoseTurn], a pop hl call HandlePoisonBurnLeechSeed_DecreaseOwnHP call HandlePoisonBurnLeechSeed_IncreaseEnemyHP @@ -571,7 +571,7 @@ HandlePoisonBurnLeechSeed_DecreaseOwnHP: .nonZeroDamage ld hl, wPlayerBattleStatus3 ld de, wPlayerToxicCounter - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .playersTurn ld hl, wEnemyBattleStatus3 @@ -618,7 +618,7 @@ HandlePoisonBurnLeechSeed_DecreaseOwnHP: HandlePoisonBurnLeechSeed_IncreaseEnemyHP: push hl ld hl, wEnemyMonMaxHP - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .playersTurn ld hl, wBattleMonMaxHP @@ -655,23 +655,23 @@ HandlePoisonBurnLeechSeed_IncreaseEnemyHP: ld [hl], a ld [wHPBarNewHP], a .noOverfullHeal - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] xor $1 - ld [hWhoseTurn], a + ldh [hWhoseTurn], a call UpdateCurMonHPBar - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] xor $1 - ld [hWhoseTurn], a + ldh [hWhoseTurn], a pop hl ret UpdateCurMonHPBar: - coord hl, 10, 9 ; tile pointer to player HP bar - ld a, [hWhoseTurn] + hlcoord 10, 9 ; tile pointer to player HP bar + ldh a, [hWhoseTurn] and a ld a, $1 jr z, .playersTurn - coord hl, 2, 2 ; tile pointer to enemy HP bar + hlcoord 2, 2 ; tile pointer to enemy HP bar xor a .playersTurn push bc @@ -767,10 +767,10 @@ FaintEnemyPokemon: ld hl, wPlayerUsedMove ld [hli], a ld [hl], a - coord hl, 12, 5 - coord de, 12, 6 + hlcoord 12, 5 + decoord 12, 6 call SlideDownFaintedMonPic - coord hl, 0, 0 + hlcoord 0, 0 lb bc, 4, 11 call ClearScreenArea ld a, [wIsInBattle] @@ -837,7 +837,7 @@ FaintEnemyPokemon: .giveExpToMonsThatFought xor a ld [wBoostExpByExpAll], a - callab GainExperience + callfar GainExperience pop af ret z ; return if no exp all @@ -855,7 +855,7 @@ FaintEnemyPokemon: jr nz, .gainExpFlagsLoop ld a, b ld [wPartyGainExpFlags], a - jpab GainExperience + jpfar GainExperience EnemyMonFaintedText: text_far _EnemyMonFaintedText @@ -893,7 +893,7 @@ ReplaceFaintedEnemyMon: ld hl, wEnemyHPBarColor ld e, $30 call GetBattleHealthBarColor - callab DrawEnemyPokeballs + callfar DrawEnemyPokeballs ld a, [wLinkState] cp LINK_STATE_BATTLING jr nz, .notLinkBattle @@ -1021,11 +1021,11 @@ RemoveFaintedPlayerMon: ld [hl], a ld [wBattleMonStatus], a call ReadPlayerMonCurHPAndStatus - coord hl, 9, 7 + hlcoord 9, 7 lb bc, 5, 11 call ClearScreenArea - coord hl, 1, 10 - coord de, 1, 11 + hlcoord 1, 10 + decoord 1, 11 call SlideDownFaintedMonPic ld a, $1 ld [wBattleResult], a @@ -1059,7 +1059,7 @@ DoUseNextMonDialogue: ld hl, UseNextMonText call PrintText .displayYesNoBox - coord hl, 13, 9 + hlcoord 13, 9 lb bc, 10, 14 ld a, TWO_OPTION_MENU ld [wTextBoxID], a @@ -1136,7 +1136,7 @@ HandlePlayerBlackOut: ld a, [wCurOpponent] cp OPP_SONY1 jr nz, .notSony1Battle - coord hl, 0, 0 ; sony 1 battle + hlcoord 0, 0 ; sony 1 battle lb bc, 8, 21 call ClearScreenArea call ScrollTrainerPicAfterBattle @@ -1232,7 +1232,7 @@ SevenSpacesText: ; if a is 8, the slide is to the right, else it is to the left ; bug: when this is called, [hAutoBGTransferEnabled] is non-zero, so there is screen tearing SlideTrainerPicOffScreen: - ld [hSlideAmount], a + ldh [hSlideAmount], a ld c, a .slideStepLoop ; each iteration, the trainer pic is slid one tile left/right push bc @@ -1240,10 +1240,10 @@ SlideTrainerPicOffScreen: ld b, 7 ; number of rows .rowLoop push hl - ld a, [hSlideAmount] + ldh a, [hSlideAmount] ld c, a .columnLoop - ld a, [hSlideAmount] + ldh a, [hSlideAmount] cp 8 jr z, .slideRight .slideLeft ; slide player sprite off screen @@ -1306,7 +1306,7 @@ EnemySendOutFirstMon: ld [wAICount], a ld hl, wPlayerBattleStatus1 res 5, [hl] - coord hl, 18, 0 + hlcoord 18, 0 ld a, 8 call SlideTrainerPicOffScreen call PrintEmptyString @@ -1376,7 +1376,7 @@ EnemySendOutFirstMon: jr nz, .next4 ld hl, TrainerAboutToUseText call PrintText - coord hl, 0, 7 + hlcoord 0, 7 lb bc, 8, 1 ld a, TWO_OPTION_MENU ld [wTextBoxID], a @@ -1411,7 +1411,7 @@ EnemySendOutFirstMon: call LoadScreenTilesFromBuffer1 .next4 call ClearSprites - coord hl, 0, 0 + hlcoord 0, 0 lb bc, 4, 11 call ClearScreenArea ld b, SET_PAL_BATTLE @@ -1426,8 +1426,8 @@ EnemySendOutFirstMon: ld de, vFrontPic call LoadMonFrontSprite ld a, -$31 - ld [hStartTileID], a - coord hl, 15, 6 + ldh [hStartTileID], a + hlcoord 15, 6 predef AnimateSendingOutMon ld a, [wEnemyMonSpecies2] call PlayCry @@ -1508,14 +1508,14 @@ TryRunningFromBattle: inc a ld [wNumRunAttempts], a ld a, [hli] - ld [hMultiplicand + 1], a + ldh [hMultiplicand + 1], a ld a, [hl] - ld [hMultiplicand + 2], a + ldh [hMultiplicand + 2], a ld a, [de] - ld [hEnemySpeed], a + ldh [hEnemySpeed], a inc de ld a, [de] - ld [hEnemySpeed + 1], a + ldh [hEnemySpeed + 1], a call LoadScreenTilesFromBuffer1 ld de, hMultiplicand + 1 ld hl, hEnemySpeed @@ -1523,17 +1523,17 @@ TryRunningFromBattle: call StringCmp jr nc, .canEscape ; jump if player speed greater than enemy speed xor a - ld [hMultiplicand], a + ldh [hMultiplicand], a ld a, 32 - ld [hMultiplier], a + ldh [hMultiplier], a call Multiply ; multiply player speed by 32 - ld a, [hProduct + 2] - ld [hDividend], a - ld a, [hProduct + 3] - ld [hDividend + 1], a - ld a, [hEnemySpeed] + ldh a, [hProduct + 2] + ldh [hDividend], a + ldh a, [hProduct + 3] + ldh [hDividend + 1], a + ldh a, [hEnemySpeed] ld b, a - ld a, [hEnemySpeed + 1] + ldh a, [hEnemySpeed + 1] ; divide enemy speed by 4 srl b rr a @@ -1541,10 +1541,10 @@ TryRunningFromBattle: rr a and a jr z, .canEscape ; jump if enemy speed divided by 4, mod 256 is 0 - ld [hDivisor], a ; ((enemy speed / 4) % 256) + ldh [hDivisor], a ; ((enemy speed / 4) % 256) ld b, $2 call Divide ; divide (player speed * 32) by ((enemy speed / 4) % 256) - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] and a ; is the quotient greater than 256? jr nz, .canEscape ; if so, the player can escape ld a, [wNumRunAttempts] @@ -1554,15 +1554,15 @@ TryRunningFromBattle: dec c jr z, .compareWithRandomValue ld b, 30 - ld a, [hQuotient + 3] + ldh a, [hQuotient + 3] add b - ld [hQuotient + 3], a + ldh [hQuotient + 3], a jr c, .canEscape jr .loop .compareWithRandomValue call BattleRandom ld b, a - ld a, [hQuotient + 3] + ldh a, [hQuotient + 3] cp b jr nc, .canEscape ; if the random value was less than or equal to the quotient ; plus 30 times the number of attempts, the player can escape @@ -1720,7 +1720,7 @@ LoadEnemyMonFromParty: ret SendOutMon: - callab PrintSendOutMonMessage + callfar PrintSendOutMonMessage ld hl, wEnemyMonHP ld a, [hli] or [hl] ; is enemy mon HP zero? @@ -1730,7 +1730,7 @@ SendOutMon: call DrawPlayerHUDAndHPBar predef LoadMonBackPic xor a - ld [hStartTileID], a + ldh [hStartTileID], a ld hl, wBattleAndStartSavedMenuItem ld [hli], a ld [hl], a @@ -1754,10 +1754,10 @@ SendOutMon: ld hl, wEnemyBattleStatus1 res USING_TRAPPING_MOVE, [hl] ld a, $1 - ld [hWhoseTurn], a + ldh [hWhoseTurn], a ld a, POOF_ANIM call PlayMoveAnimation - coord hl, 4, 11 + hlcoord 4, 11 predef AnimateSendingOutMon ld a, [wcf91] call PlayCry @@ -1766,31 +1766,31 @@ SendOutMon: ; show 2 stages of the player mon getting smaller before disappearing AnimateRetreatingPlayerMon: - coord hl, 1, 5 + hlcoord 1, 5 lb bc, 7, 7 call ClearScreenArea - coord hl, 3, 7 + hlcoord 3, 7 lb bc, 5, 5 xor a ld [wDownscaledMonSize], a - ld [hBaseTileID], a + ldh [hBaseTileID], a predef CopyDownscaledMonTiles ld c, 4 call DelayFrames call .clearScreenArea - coord hl, 4, 9 + hlcoord 4, 9 lb bc, 3, 3 ld a, 1 ld [wDownscaledMonSize], a xor a - ld [hBaseTileID], a + ldh [hBaseTileID], a predef CopyDownscaledMonTiles call Delay3 call .clearScreenArea ld a, $4c - Coorda 5, 11 + ldcoord_a 5, 11 .clearScreenArea - coord hl, 1, 5 + hlcoord 1, 5 lb bc, 7, 7 jp ClearScreenArea @@ -1812,15 +1812,15 @@ DrawHUDsAndHPBars: DrawPlayerHUDAndHPBar: xor a - ld [hAutoBGTransferEnabled], a - coord hl, 9, 7 + ldh [hAutoBGTransferEnabled], a + hlcoord 9, 7 lb bc, 5, 11 call ClearScreenArea - callab PlacePlayerHUDTiles - coord hl, 18, 9 + callfar PlacePlayerHUDTiles + hlcoord 18, 9 ld [hl], $73 ld de, wBattleMonNick - coord hl, 10, 7 + hlcoord 10, 7 call CenterMonName call PlaceString ld hl, wBattleMonSpecies @@ -1831,7 +1831,7 @@ DrawPlayerHUDAndHPBar: ld de, wLoadedMonLevel ld bc, wBattleMonPP - wBattleMonLevel call CopyData - coord hl, 14, 8 + hlcoord 14, 8 push hl inc hl ld de, wLoadedMonStatus @@ -1842,10 +1842,10 @@ DrawPlayerHUDAndHPBar: .doNotPrintLevel ld a, [wLoadedMonSpecies] ld [wcf91], a - coord hl, 10, 9 + hlcoord 10, 9 predef DrawHP ld a, $1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ld hl, wPlayerHPBarColor call GetBattleHealthBarColor ld hl, wBattleMonHP @@ -1873,16 +1873,16 @@ DrawPlayerHUDAndHPBar: DrawEnemyHUDAndHPBar: xor a - ld [hAutoBGTransferEnabled], a - coord hl, 0, 0 + ldh [hAutoBGTransferEnabled], a + hlcoord 0, 0 lb bc, 4, 12 call ClearScreenArea - callab PlaceEnemyHUDTiles + callfar PlaceEnemyHUDTiles ld de, wEnemyMonNick - coord hl, 1, 0 + hlcoord 1, 0 call CenterMonName call PlaceString - coord hl, 4, 1 + hlcoord 4, 1 push hl inc hl ld de, wEnemyMonStatus @@ -1895,9 +1895,9 @@ DrawEnemyHUDAndHPBar: .skipPrintLevel ld hl, wEnemyMonHP ld a, [hli] - ld [hMultiplicand + 1], a + ldh [hMultiplicand + 1], a ld a, [hld] - ld [hMultiplicand + 2], a + ldh [hMultiplicand + 2], a or [hl] ; is current HP zero? jr nz, .hpNonzero ; current HP is 0 @@ -1908,45 +1908,45 @@ DrawEnemyHUDAndHPBar: jp .drawHPBar .hpNonzero xor a - ld [hMultiplicand], a + ldh [hMultiplicand], a ld a, 48 - ld [hMultiplier], a + ldh [hMultiplier], a call Multiply ; multiply current HP by 48 ld hl, wEnemyMonMaxHP ld a, [hli] ld b, a ld a, [hl] - ld [hDivisor], a + ldh [hDivisor], a ld a, b and a ; is max HP > 255? jr z, .doDivide ; if max HP > 255, scale both (current HP * 48) and max HP by dividing by 4 so that max HP fits in one byte ; (it needs to be one byte so it can be used as the divisor for the Divide function) - ld a, [hDivisor] + ldh a, [hDivisor] srl b rr a srl b rr a - ld [hDivisor], a - ld a, [hProduct + 2] + ldh [hDivisor], a + ldh a, [hProduct + 2] ld b, a srl b - ld a, [hProduct + 3] + ldh a, [hProduct + 3] rr a srl b rr a - ld [hProduct + 3], a + ldh [hProduct + 3], a ld a, b - ld [hProduct + 2], a + ldh [hProduct + 2], a .doDivide - ld a, [hProduct + 2] - ld [hDividend], a - ld a, [hProduct + 3] - ld [hDividend + 1], a + ldh a, [hProduct + 2] + ldh [hDividend], a + ldh a, [hProduct + 3] + ldh [hDividend + 1], a ld a, $2 ld b, a call Divide ; divide (current HP * 48) by max HP - ld a, [hQuotient + 3] + ldh a, [hQuotient + 3] ; set variables for DrawHPBar ld e, a ld a, $6 @@ -1955,10 +1955,10 @@ DrawEnemyHUDAndHPBar: .drawHPBar xor a ld [wHPBarType], a - coord hl, 2, 2 + hlcoord 2, 2 call DrawHPBar ld a, $1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ld hl, wEnemyHPBarColor GetBattleHealthBarColor: @@ -2030,12 +2030,12 @@ DisplayBattleMenu:: ld bc, NAME_LENGTH call CopyData ; the following simulates the keystrokes by drawing menus on screen - coord hl, 9, 14 + hlcoord 9, 14 ld [hl], "▶" ld c, 80 call DelayFrames ld [hl], " " - coord hl, 9, 16 + hlcoord 9, 16 ld [hl], "▶" ld c, 50 call DelayFrames @@ -2060,14 +2060,14 @@ DisplayBattleMenu:: ld a, " " jr z, .safariLeftColumn ; put cursor in left column for normal battle menu (i.e. when it's not a Safari battle) - Coorda 15, 14 ; clear upper cursor position in right column - Coorda 15, 16 ; clear lower cursor position in right column + ldcoord_a 15, 14 ; clear upper cursor position in right column + ldcoord_a 15, 16 ; clear lower cursor position in right column ld b, $9 ; top menu item X jr .leftColumn_WaitForInput .safariLeftColumn - Coorda 13, 14 - Coorda 13, 16 - coord hl, 7, 14 + ldcoord_a 13, 14 + ldcoord_a 13, 16 + hlcoord 7, 14 ld de, wNumSafariBalls lb bc, 1, 2 call PrintNumber @@ -2093,14 +2093,14 @@ DisplayBattleMenu:: ld a, " " jr z, .safariRightColumn ; put cursor in right column for normal battle menu (i.e. when it's not a Safari battle) - Coorda 9, 14 ; clear upper cursor position in left column - Coorda 9, 16 ; clear lower cursor position in left column + ldcoord_a 9, 14 ; clear upper cursor position in left column + ldcoord_a 9, 16 ; clear lower cursor position in left column ld b, $f ; top menu item X jr .rightColumn_WaitForInput .safariRightColumn - Coorda 1, 14 ; clear upper cursor position in left column - Coorda 1, 16 ; clear lower cursor position in left column - coord hl, 7, 14 + ldcoord_a 1, 14 ; clear upper cursor position in left column + ldcoord_a 1, 16 ; clear lower cursor position in left column + hlcoord 7, 14 ld de, wNumSafariBalls lb bc, 1, 2 call PrintNumber @@ -2321,7 +2321,7 @@ PartyMenuOrRockOrRun: call GBPalNormal jp DisplayBattleMenu .partyMonDeselected - coord hl, 11, 11 + hlcoord 11, 11 ld bc, 6 * SCREEN_WIDTH + 9 ld a, " " call FillMemory @@ -2411,7 +2411,7 @@ PartyMenuOrRockOrRun: ; fall through to SwitchPlayerMon SwitchPlayerMon: - callab RetreatMon + callfar RetreatMon ld c, 50 call DelayFrames call AnimateRetreatingPlayerMon @@ -2464,18 +2464,18 @@ MoveSelectionMenu: ld de, wMoves ld bc, NUM_MOVES call CopyData - callab FormatMovesString + callfar FormatMovesString ret .writemoves ld de, wMovesString - ld a, [hFlagsFFF6] + ldh a, [hFlagsFFF6] set 2, a - ld [hFlagsFFF6], a + ldh [hFlagsFFF6], a call PlaceString - ld a, [hFlagsFFF6] + ldh a, [hFlagsFFF6] res 2, a - ld [hFlagsFFF6], a + ldh [hFlagsFFF6], a ret .regularmenu @@ -2483,18 +2483,18 @@ MoveSelectionMenu: ret z ld hl, wBattleMonMoves call .loadmoves - coord hl, 4, 12 + hlcoord 4, 12 ld b, 4 ld c, 14 di ; out of pure coincidence, it is possible for vblank to occur between the di and ei ; so it is necessary to put the di ei block to not cause tearing call TextBoxBorder - coord hl, 4, 12 + hlcoord 4, 12 ld [hl], $7a - coord hl, 10, 12 + hlcoord 10, 12 ld [hl], $7e ei - coord hl, 6, 13 + hlcoord 6, 13 call .writemoves ld b, $5 ld a, $c @@ -2502,11 +2502,11 @@ MoveSelectionMenu: .mimicmenu ld hl, wEnemyMonMoves call .loadmoves - coord hl, 0, 7 + hlcoord 0, 7 ld b, 4 ld c, 14 call TextBoxBorder - coord hl, 2, 8 + hlcoord 2, 8 call .writemoves ld b, $1 ld a, $7 @@ -2517,11 +2517,11 @@ MoveSelectionMenu: ld bc, wPartyMon2 - wPartyMon1 call AddNTimes call .loadmoves - coord hl, 4, 7 + hlcoord 4, 7 ld b, 4 ld c, 14 call TextBoxBorder - coord hl, 6, 8 + hlcoord 6, 8 call .writemoves ld b, $5 ld a, $7 @@ -2577,7 +2577,7 @@ SelectMenuItem: jr z, .battleselect dec a jr nz, .select - coord hl, 1, 14 + hlcoord 1, 14 ld de, WhichTechniqueString call PlaceString jr .select @@ -2589,7 +2589,7 @@ SelectMenuItem: ld a, [wMenuItemToSwap] and a jr z, .select - coord hl, 5, 13 + hlcoord 5, 13 dec a ld bc, SCREEN_WIDTH call AddNTimes @@ -2825,8 +2825,8 @@ SwapMovesInMenu: PrintMenuItem: xor a - ld [hAutoBGTransferEnabled], a - coord hl, 0, 8 + ldh [hAutoBGTransferEnabled], a + hlcoord 0, 8 ld b, 3 ld c, 9 call TextBoxBorder @@ -2839,7 +2839,7 @@ PrintMenuItem: ld a, [wCurrentMenuItem] cp b jr nz, .notDisabled - coord hl, 1, 10 + hlcoord 1, 10 ld de, DisabledText call PlaceString jr .moveDisabled @@ -2847,7 +2847,7 @@ PrintMenuItem: ld hl, wCurrentMenuItem dec [hl] xor a - ld [hWhoseTurn], a + ldh [hWhoseTurn], a ld hl, wBattleMonMoves ld a, [wCurrentMenuItem] ld c, a @@ -2860,7 +2860,7 @@ PrintMenuItem: ld [wWhichPokemon], a ld a, BATTLE_MON_DATA ld [wMonDataLocation], a - callab GetMaxPP + callfar GetMaxPP ld hl, wCurrentMenuItem ld c, [hl] inc [hl] @@ -2871,27 +2871,27 @@ PrintMenuItem: and $3f ld [wcd6d], a ; print TYPE/<type> and <curPP>/<maxPP> - coord hl, 1, 9 + hlcoord 1, 9 ld de, TypeText call PlaceString - coord hl, 7, 11 + hlcoord 7, 11 ld [hl], "/" - coord hl, 5, 9 + hlcoord 5, 9 ld [hl], "/" - coord hl, 5, 11 + hlcoord 5, 11 ld de, wcd6d lb bc, 1, 2 call PrintNumber - coord hl, 8, 11 + hlcoord 8, 11 ld de, wMaxPP lb bc, 1, 2 call PrintNumber call GetCurrentMove - coord hl, 2, 10 + hlcoord 2, 10 predef PrintMoveType .moveDisabled ld a, $1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a jp Delay3 DisabledText: @@ -2955,7 +2955,7 @@ SelectEnemyMove: ld a, [wIsInBattle] dec a jr z, .chooseRandomMove ; wild encounter - callab AIEnemyTrainerChooseMoves + callfar AIEnemyTrainerChooseMoves .chooseRandomMove push hl call BattleRandom @@ -3020,7 +3020,7 @@ LinkBattleExchangeData: ld a, b .doExchange ld [wSerialExchangeNybbleSendData], a - callab PrintWaitingText + callfar PrintWaitingText .syncLoop1 call Serial_ExchangeNybble call DelayFrame @@ -3043,7 +3043,7 @@ LinkBattleExchangeData: ExecutePlayerMove: xor a - ld [hWhoseTurn], a ; set player's turn + ldh [hWhoseTurn], a ; set player's turn ld a, [wPlayerSelectedMove] inc a jp z, ExecutePlayerMoveDone ; for selected move = FF, skip most of player's turn @@ -3196,7 +3196,7 @@ MirrorMoveCheck: .moveDidNotMiss call ApplyAttackToEnemyPokemon call PrintCriticalOHKOText - callab DisplayEffectiveness + callfar DisplayEffectiveness ld a, 1 ld [wMoveDidntMiss], a .notDone @@ -3252,17 +3252,17 @@ PrintGhostText: ; print the ghost battle messages call IsGhostBattle ret nz - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr nz, .Ghost - ld a, [wBattleMonStatus] ; player’s turn + ld a, [wBattleMonStatus] ; player's turn and SLP | (1 << FRZ) ret nz ld hl, ScaredText call PrintText xor a ret -.Ghost ; ghost’s turn +.Ghost ; ghost's turn ld hl, GetOutText call PrintText xor a @@ -3619,7 +3619,7 @@ CantMoveText: PrintMoveIsDisabledText: ld hl, wPlayerSelectedMove ld de, wPlayerBattleStatus1 - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .removeChargingUp inc hl @@ -3675,11 +3675,11 @@ HandleSelfConfusionDamage: xor a ld [wAnimationType], a inc a - ld [hWhoseTurn], a + ldh [hWhoseTurn], a call PlayMoveAnimation call DrawPlayerHUDAndHPBar xor a - ld [hWhoseTurn], a + ldh [hWhoseTurn], a jp ApplyDamageToPlayerPokemon PrintMonName1Text: @@ -3694,7 +3694,7 @@ PrintMonName1Text: MonName1Text: text_far _MonName1Text text_asm - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld a, [wPlayerMoveNum] ld hl, wPlayerUsedMove @@ -3818,7 +3818,7 @@ INCLUDE "data/moves/grammar.asm" PrintMoveFailureText: ld de, wPlayerMoveEffect - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .playersTurn ld de, wEnemyMoveEffect @@ -3866,7 +3866,7 @@ PrintMoveFailureText: call PrintText ld b, $4 predef PredefShakeScreenHorizontally - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr nz, .enemyTurn jp ApplyDamageToPlayerPokemon @@ -4160,9 +4160,9 @@ GetDamageVarsForPlayerAttack: ; in the case of a critical hit, reset the player's attack and the enemy's defense to their base values ld c, 3 ; defense stat call GetEnemyMonStat - ld a, [hProduct + 2] + ldh a, [hProduct + 2] ld b, a - ld a, [hProduct + 3] + ldh a, [hProduct + 3] ld c, a push bc ld hl, wPartyMon1Attack @@ -4182,8 +4182,8 @@ GetDamageVarsForPlayerAttack: ; if the enemy has used Light Screen, double the enemy's special sla c rl b -; reflect and light screen boosts do not cap the stat at 999, so weird things will happen during stats scaling if -; a Pokemon with 512 or more Defense has used Reflect, or if a Pokemon with 512 or more Special has used Light Screen +; reflect and light screen boosts do not cap the stat at MAX_STAT_VALUE, so weird things will happen during stats scaling +; if a Pokemon with 512 or more Defense has used Reflect, or if a Pokemon with 512 or more Special has used Light Screen .specialAttackCritCheck ld hl, wBattleMonSpecial ld a, [wCriticalHitOrOHKO] @@ -4192,9 +4192,9 @@ GetDamageVarsForPlayerAttack: ; in the case of a critical hit, reset the player's and enemy's specials to their base values ld c, 5 ; special stat call GetEnemyMonStat - ld a, [hProduct + 2] + ldh a, [hProduct + 2] ld b, a - ld a, [hProduct + 3] + ldh a, [hProduct + 3] ld c, a push bc ld hl, wPartyMon1Special @@ -4295,8 +4295,8 @@ GetDamageVarsForEnemyAttack: ; if the player has used Light Screen, double the player's special sla c rl b -; reflect and light screen boosts do not cap the stat at 999, so weird things will happen during stats scaling if -; a Pokemon with 512 or more Defense has used Reflect, or if a Pokemon with 512 or more Special has used Light Screen +; reflect and light screen boosts do not cap the stat at MAX_STAT_VALUE, so weird things will happen during stats scaling +; if a Pokemon with 512 or more Defense has used Reflect, or if a Pokemon with 512 or more Special has used Light Screen .specialAttackCritCheck ld hl, wEnemyMonSpecial ld a, [wCriticalHitOrOHKO] @@ -4371,9 +4371,9 @@ GetEnemyMonStat: ld bc, wEnemyMon2 - wEnemyMon1 call AddNTimes ld a, [hli] - ld [hMultiplicand + 1], a + ldh [hMultiplicand + 1], a ld a, [hl] - ld [hMultiplicand + 2], a + ldh [hMultiplicand + 2], a pop bc pop de ret @@ -4404,7 +4404,7 @@ CalculateDamage: ; d: base power ; e: level - ld a, [hWhoseTurn] ; whose turn? + ldh a, [hWhoseTurn] ; whose turn? and a ld a, [wPlayerMoveEffect] jr z, .effect @@ -4489,65 +4489,65 @@ CalculateDamage: ; Capped at MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE: 999 - 2 = 997. ld hl, wDamage ld b, [hl] - ld a, [hQuotient + 3] + ldh a, [hQuotient + 3] add b - ld [hQuotient + 3], a + ldh [hQuotient + 3], a jr nc, .dont_cap_1 - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] inc a - ld [hQuotient + 2], a + ldh [hQuotient + 2], a and a jr z, .cap .dont_cap_1 - ld a, [hQuotient] + ldh a, [hQuotient] ld b, a - ld a, [hQuotient + 1] + ldh a, [hQuotient + 1] or a jr nz, .cap - ld a, [hQuotient + 2] - cp (MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) / $100 + ldh a, [hQuotient + 2] + cp HIGH(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) jr c, .dont_cap_2 - cp (MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) / $100 + 1 + cp HIGH(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) + 1 jr nc, .cap - ld a, [hQuotient + 3] - cp (MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) % $100 + ldh a, [hQuotient + 3] + cp LOW(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) jr nc, .cap .dont_cap_2 inc hl - ld a, [hQuotient + 3] + ldh a, [hQuotient + 3] ld b, [hl] add b ld [hld], a - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] ld b, [hl] adc b ld [hl], a jr c, .cap ld a, [hl] - cp (MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) / $100 + cp HIGH(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) jr c, .dont_cap_3 - cp (MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) / $100 + 1 + cp HIGH(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) + 1 jr nc, .cap inc hl ld a, [hld] - cp (MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) % $100 + cp LOW(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) jr c, .dont_cap_3 .cap - ld a, (MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE) / $100 + ld a, HIGH(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE) ld [hli], a - ld a, (MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE) % $100 + ld a, LOW(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE) ld [hld], a .dont_cap_3 @@ -4579,7 +4579,7 @@ INCLUDE "data/battle/unused_critical_hit_moves.asm" CriticalHitTest: xor a ld [wCriticalHitOrOHKO], a - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld a, [wEnemyMonSpecies] jr nz, .handleEnemy @@ -4590,7 +4590,7 @@ CriticalHitTest: ld a, [wMonHBaseSpeed] ld b, a srl b ; (effective (base speed/2)) - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld hl, wPlayerMovePower ld de, wPlayerBattleStatus2 @@ -4652,7 +4652,7 @@ HandleCounterMove: ; the outcome may be affected by the player's actions in the move selection menu prior to switching the Pokemon. ; This might also lead to desync glitches in link battles. - ld a, [hWhoseTurn] ; whose turn + ldh a, [hWhoseTurn] ; whose turn and a ; player's turn ld hl, wEnemySelectedMove @@ -4822,7 +4822,7 @@ ApplyDamageToEnemyPokemon: ld [wHPBarNewHP+1], a ld a, [hl] ld [wHPBarNewHP], a - coord hl, 2, 2 + hlcoord 2, 2 xor a ld [wHPBarType], a predef UpdateHPBar2 ; animate the HP bar shortening @@ -4940,7 +4940,7 @@ ApplyDamageToPlayerPokemon: ld [wHPBarMaxHP+1], a ld a, [hl] ld [wHPBarMaxHP], a - coord hl, 10, 9 + hlcoord 10, 9 ld a, $01 ld [wHPBarType], a predef UpdateHPBar2 ; animate the HP bar shortening @@ -4960,7 +4960,7 @@ AttackSubstitute: ; values for player turn ld de, wEnemySubstituteHP ld bc, wEnemyBattleStatus2 - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .applyDamageToSubstitute ; values for enemy turn @@ -4985,14 +4985,14 @@ AttackSubstitute: ld hl, SubstituteBrokeText call PrintText ; flip whose turn it is for the next function call - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] xor $01 - ld [hWhoseTurn], a - callab HideSubstituteShowMonAnim ; animate the substitute breaking + ldh [hWhoseTurn], a + callfar HideSubstituteShowMonAnim ; animate the substitute breaking ; flip the turn back to the way it was - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] xor $01 - ld [hWhoseTurn], a + ldh [hWhoseTurn], a ld hl, wPlayerMoveEffect ; value for player's turn and a jr z, .nullifyEffect @@ -5016,7 +5016,7 @@ HandleBuildingRage: ld hl, wEnemyBattleStatus2 ld de, wEnemyMonStatMods ld bc, wEnemyMoveNum - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .next ; values for the enemy turn @@ -5029,9 +5029,9 @@ HandleBuildingRage: ld a, [de] cp $0d ; maximum stat modifier value ret z ; return if attack modifier is already maxed - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] xor $01 ; flip turn for the stat modifier raising function - ld [hWhoseTurn], a + ldh [hWhoseTurn], a ; temporarily change the target pokemon's move to $00 and the effect to the one ; that causes the attack modifier to go up one stage ld h, b @@ -5048,9 +5048,9 @@ HandleBuildingRage: ldd [hl], a ; null move effect ld a, RAGE ld [hl], a ; restore the target pokemon's move number to Rage - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] xor $01 ; flip turn back to the way it was - ld [hWhoseTurn], a + ldh [hWhoseTurn], a ret BuildingRageText: @@ -5066,7 +5066,7 @@ MirrorMoveCopyMove: ; wPlayerUsedMove is also set to 0 whenever the player is fast asleep or frozen solid. ; wEnemyUsedMove is also set to 0 whenever the enemy is fast asleep or frozen solid. - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ; values for player turn ld a, [wEnemyUsedMove] @@ -5119,7 +5119,7 @@ MetronomePickMove: ; values for player turn ld de, wPlayerMoveNum ld hl, wPlayerSelectedMove - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .pickMoveLoop ; values for enemy turn @@ -5141,7 +5141,7 @@ MetronomePickMove: ; it's used to prevent moves that run another move within the same turn ; (like Mirror Move and Metronome) from losing 2 PP IncrementMovePP: - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ; values for player turn ld hl, wBattleMonPP @@ -5160,7 +5160,7 @@ IncrementMovePP: ld h, d ld l, e add hl, bc - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld a, [wPlayerMonNumber] ; value for player turn jr z, .updatePP @@ -5184,7 +5184,7 @@ AdjustDamageForMoveType: ld e, [hl] ; e = type 2 of defender ld a, [wPlayerMoveType] ld [wMoveType], a - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .next ; values for enemy turn @@ -5248,25 +5248,25 @@ AdjustDamageForMoveType: and $80 ld b, a ld a, [hl] ; a = damage multiplier - ld [hMultiplier], a + ldh [hMultiplier], a add b ld [wDamageMultipliers], a xor a - ld [hMultiplicand], a + ldh [hMultiplicand], a ld hl, wDamage ld a, [hli] - ld [hMultiplicand + 1], a + ldh [hMultiplicand + 1], a ld a, [hld] - ld [hMultiplicand + 2], a + ldh [hMultiplicand + 2], a call Multiply ld a, 10 - ld [hDivisor], a + ldh [hDivisor], a ld b, $04 call Divide - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] ld [hli], a ld b, a - ld a, [hQuotient + 3] + ldh a, [hQuotient + 3] ld [hl], a or b ; is damage 0? jr nz, .skipTypeImmunity @@ -5331,7 +5331,7 @@ MoveHitTest: ld hl, wEnemyBattleStatus1 ld de, wPlayerMoveEffect ld bc, wEnemyMonStatus - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .dreamEaterCheck ; enemy's turn @@ -5360,7 +5360,7 @@ MoveHitTest: .checkForDigOrFlyStatus bit INVULNERABLE, [hl] jp nz, .moveMissed - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr nz, .enemyTurn .playerTurn @@ -5414,7 +5414,7 @@ MoveHitTest: call CalcHitChance ; scale the move accuracy according to attacker's accuracy and target's evasion ld a, [wPlayerMoveAccuracy] ld b, a - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .doAccuracyCheck ld a, [wEnemyMoveAccuracy] @@ -5433,7 +5433,7 @@ MoveHitTest: ld [hl], a inc a ld [wMoveMissed], a - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .playerTurn2 .enemyTurn2 @@ -5448,7 +5448,7 @@ MoveHitTest: ; values for player turn CalcHitChance: ld hl, wPlayerMoveAccuracy - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld a, [wPlayerMonAccuracyMod] ld b, a @@ -5468,10 +5468,10 @@ CalcHitChance: ; decreases the hit chance instead of increasing the hit chance) ; zero the high bytes of the multiplicand xor a - ld [hMultiplicand], a - ld [hMultiplicand + 1], a + ldh [hMultiplicand], a + ldh [hMultiplicand + 1], a ld a, [hl] - ld [hMultiplicand + 2], a ; set multiplicand to move accuracy + ldh [hMultiplicand + 2], a ; set multiplicand to move accuracy push hl ld d, $02 ; loop has two iterations ; loop to do the calculations, the first iteration multiplies by the accuracy ratio and @@ -5486,29 +5486,29 @@ CalcHitChance: add hl, bc ; hl = address of stat modifier ratio pop bc ld a, [hli] - ld [hMultiplier], a ; set multiplier to the numerator of the ratio + ldh [hMultiplier], a ; set multiplier to the numerator of the ratio call Multiply ld a, [hl] - ld [hDivisor], a ; set divisor to the the denominator of the ratio + ldh [hDivisor], a ; set divisor to the the denominator of the ratio ; (the dividend is the product of the previous multiplication) ld b, $04 ; number of bytes in the dividend call Divide - ld a, [hQuotient + 3] + ldh a, [hQuotient + 3] ld b, a - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] or b jp nz, .nextCalculation ; make sure the result is always at least one - ld [hQuotient + 2], a + ldh [hQuotient + 2], a ld a, $01 - ld [hQuotient + 3], a + ldh [hQuotient + 3], a .nextCalculation ld b, c dec d jr nz, .loop - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] and a ; is the calculated hit chance over 0xFF? - ld a, [hQuotient + 3] + ldh a, [hQuotient + 3] jr z, .storeAccuracy ; if calculated hit chance over 0xFF ld a, $ff ; set the hit chance to 0xFF @@ -5528,29 +5528,29 @@ RandomizeDamage: ret c ; return if damage is equal to 0 or 1 .DamageGreaterThanOne xor a - ld [hMultiplicand], a + ldh [hMultiplicand], a dec hl ld a, [hli] - ld [hMultiplicand + 1], a + ldh [hMultiplicand + 1], a ld a, [hl] - ld [hMultiplicand + 2], a + ldh [hMultiplicand + 2], a ; loop until a random number greater than or equal to 217 is generated .loop call BattleRandom rrca cp 217 jr c, .loop - ld [hMultiplier], a + ldh [hMultiplier], a call Multiply ; multiply damage by the random number, which is in the range [217, 255] ld a, 255 - ld [hDivisor], a + ldh [hDivisor], a ld b, $4 call Divide ; divide the result by 255 ; store the modified damage - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] ld hl, wDamage ld [hli], a - ld a, [hQuotient + 3] + ldh a, [hQuotient + 3] ld [hl], a ret @@ -5726,7 +5726,7 @@ EnemyCheckIfMirrorMoveEffect: .moveDidNotMiss call ApplyAttackToPlayerPokemon call PrintCriticalOHKOText - callab DisplayEffectiveness + callfar DisplayEffectiveness ld a, 1 ld [wMoveDidntMiss], a .handleExplosionMiss @@ -5906,11 +5906,11 @@ CheckEnemyStatusConditions: ld [hl], a xor a ld [wAnimationType], a - ld [hWhoseTurn], a + ldh [hWhoseTurn], a ld a, POUND call PlayMoveAnimation ld a, $1 - ld [hWhoseTurn], a + ldh [hWhoseTurn], a call ApplyDamageToEnemyPokemon jr .monHurtItselfOrFullyParalysed .checkIfTriedToUseDisabledMove @@ -6057,7 +6057,7 @@ CheckEnemyStatusConditions: ret GetCurrentMove: - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jp z, .player ld de, wEnemyMoveNum @@ -6254,25 +6254,25 @@ DoBattleTransitionAndInitBattleVariables: ; link battle xor a ld [wMenuJoypadPollCount], a - callab DisplayLinkBattleVersusTextBox + callfar DisplayLinkBattleVersusTextBox ld a, $1 ld [wUpdateSpritesEnabled], a call ClearScreen .next call DelayFrame predef BattleTransition - callab LoadHudAndHpBarAndStatusTilePatterns + callfar LoadHudAndHpBarAndStatusTilePatterns ld a, $1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ld a, $ff ld [wUpdateSpritesEnabled], a call ClearSprites call ClearScreen xor a - ld [hAutoBGTransferEnabled], a - ld [hWY], a - ld [rWY], a - ld [hTilesetType], a + ldh [hAutoBGTransferEnabled], a + ldh [hWY], a + ldh [rWY], a + ldh [hTilesetType], a ld hl, wPlayerStatsToDouble ld [hli], a ld [hli], a @@ -6309,7 +6309,7 @@ LoadPlayerBackPic: predef ScaleSpriteByTwo ld hl, wOAMBuffer xor a - ld [hOAMTile], a ; initial tile number + ldh [hOAMTile], a ; initial tile number ld b, $7 ; 7 columns ld e, $a0 ; X for the left-most column .loop ; each loop iteration writes 3 OAM entries in a vertical column @@ -6323,16 +6323,16 @@ LoadPlayerBackPic: add d ; increase Y by height of tile ld d, a inc hl - ld a, [hOAMTile] + ldh a, [hOAMTile] ld [hli], a ; OAM tile number inc a ; increment tile number - ld [hOAMTile], a + ldh [hOAMTile], a inc hl dec c jr nz, .innerLoop - ld a, [hOAMTile] + ldh a, [hOAMTile] add $4 ; increase tile number by 4 - ld [hOAMTile], a + ldh [hOAMTile], a ld a, $8 ; width of tile add e ; increase X by width of tile ld e, a @@ -6346,24 +6346,24 @@ LoadPlayerBackPic: ld [MBC1SRamBank], a ld hl, vSprites ld de, sSpriteBuffer1 - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] ld b, a ld c, 7 * 7 call CopyVideoData xor a ld [MBC1SRamEnable], a ld a, $31 - ld [hStartTileID], a - coord hl, 1, 5 + ldh [hStartTileID], a + hlcoord 1, 5 predef_jump CopyUncompressedPicToTilemap ; does nothing since no stats are ever selected (barring glitches) DoubleOrHalveSelectedStats: - callab DoubleSelectedStats - jpab HalveSelectedStats + callfar DoubleSelectedStats + jpfar HalveSelectedStats ScrollTrainerPicAfterBattle: - jpab _ScrollTrainerPicAfterBattle + jpfar _ScrollTrainerPicAfterBattle ApplyBurnAndParalysisPenaltiesToPlayer: ld a, $1 @@ -6373,12 +6373,12 @@ ApplyBurnAndParalysisPenaltiesToEnemy: xor a ApplyBurnAndParalysisPenalties: - ld [hWhoseTurn], a + ldh [hWhoseTurn], a call QuarterSpeedDueToParalysis jp HalveAttackDueToBurn QuarterSpeedDueToParalysis: - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .playerTurn .enemyTurn ; quarter the player's speed @@ -6421,7 +6421,7 @@ QuarterSpeedDueToParalysis: ret HalveAttackDueToBurn: - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .playerTurn .enemyTurn ; halve the player's attack @@ -6511,35 +6511,35 @@ CalculateModifiedStat: ld b, 0 add hl, bc xor a - ld [hMultiplicand], a + ldh [hMultiplicand], a ld a, [de] - ld [hMultiplicand + 1], a + ldh [hMultiplicand + 1], a inc de ld a, [de] - ld [hMultiplicand + 2], a + ldh [hMultiplicand + 2], a ld a, [hli] - ld [hMultiplier], a + ldh [hMultiplier], a call Multiply ld a, [hl] - ld [hDivisor], a + ldh [hDivisor], a ld b, $4 call Divide pop hl - ld a, [hDividend + 3] - sub 999 % $100 - ld a, [hDividend + 2] - sbc 999 / $100 + ldh a, [hDividend + 3] + sub LOW(MAX_STAT_VALUE) + ldh a, [hDividend + 2] + sbc HIGH(MAX_STAT_VALUE) jp c, .storeNewStatValue -; cap the stat at 999 - ld a, 999 / $100 - ld [hDividend + 2], a - ld a, 999 % $100 - ld [hDividend + 3], a +; cap the stat at MAX_STAT_VALUE (999) + ld a, HIGH(MAX_STAT_VALUE) + ldh [hDividend + 2], a + ld a, LOW(MAX_STAT_VALUE) + ldh [hDividend + 3], a .storeNewStatValue - ld a, [hDividend + 2] + ldh a, [hDividend + 2] ld [hli], a ld b, a - ld a, [hDividend + 3] + ldh a, [hDividend + 3] ld [hl], a or b jr nz, .done @@ -6573,7 +6573,7 @@ ApplyBadgeStatBoosts: ret ; multiply stat at hl by 1.125 -; cap stat at 999 +; cap stat at MAX_STAT_VALUE .applyBoostToStat ld a, [hli] ld d, a @@ -6591,13 +6591,13 @@ ApplyBadgeStatBoosts: adc d ld [hli], a ld a, [hld] - sub 999 % $100 + sub LOW(MAX_STAT_VALUE) ld a, [hl] - sbc 999 / $100 + sbc HIGH(MAX_STAT_VALUE) ret c - ld a, 999 / $100 + ld a, HIGH(MAX_STAT_VALUE) ld [hli], a - ld a, 999 % $100 + ld a, LOW(MAX_STAT_VALUE) ld [hld], a ret @@ -6605,27 +6605,27 @@ LoadHudAndHpBarAndStatusTilePatterns: call LoadHpBarAndStatusTilePatterns LoadHudTilePatterns: - ld a, [rLCDC] + ldh a, [rLCDC] add a ; is LCD disabled? jr c, .lcdEnabled .lcdDisabled ld hl, BattleHudTiles1 - ld de, vChars2 + $6d0 + ld de, vChars2 tile $6d ld bc, BattleHudTiles1End - BattleHudTiles1 ld a, BANK(BattleHudTiles1) call FarCopyDataDouble ld hl, BattleHudTiles2 - ld de, vChars2 + $730 + ld de, vChars2 tile $73 ld bc, BattleHudTiles3End - BattleHudTiles2 ld a, BANK(BattleHudTiles2) jp FarCopyDataDouble .lcdEnabled ld de, BattleHudTiles1 - ld hl, vChars2 + $6d0 + ld hl, vChars2 tile $6d lb bc, BANK(BattleHudTiles1), (BattleHudTiles1End - BattleHudTiles1) / $8 call CopyVideoDataDouble ld de, BattleHudTiles2 - ld hl, vChars2 + $730 + ld hl, vChars2 tile $73 lb bc, BANK(BattleHudTiles2), (BattleHudTiles3End - BattleHudTiles2) / $8 jp CopyVideoDataDouble @@ -6690,7 +6690,7 @@ BattleRandom: HandleExplodingAnimation: - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld hl, wEnemyMonType1 ld de, wEnemyBattleStatus1 @@ -6740,14 +6740,14 @@ DetermineWildOpponent: ld a, [wd732] bit 1, a jr z, .asm_3ef2f - ld a, [hJoyHeld] + ldh a, [hJoyHeld] bit 1, a ; B button pressed? ret nz .asm_3ef2f ld a, [wNumberOfNoRandomBattleStepsLeft] and a ret nz - callab TryDoWildEncounter + callfar TryDoWildEncounter ret nz InitBattleCommon: ld a, [wMapPalOffset] @@ -6756,21 +6756,21 @@ InitBattleCommon: ld a, [hl] push af res 1, [hl] - callab InitBattleVariables + callfar InitBattleVariables ld a, [wEnemyMonSpecies2] sub OPP_ID_OFFSET jp c, InitWildBattle ld [wTrainerClass], a call GetTrainerInformation - callab ReadTrainer + callfar ReadTrainer call DoBattleTransitionAndInitBattleVariables call _LoadTrainerPic xor a ld [wEnemyMonSpecies2], a - ld [hStartTileID], a + ldh [hStartTileID], a dec a ld [wAICount], a - coord hl, 12, 0 + hlcoord 12, 0 predef CopyUncompressedPicToTilemap ld a, $ff ld [wEnemyMonPartyPos], a @@ -6823,8 +6823,8 @@ InitWildBattle: .spriteLoaded xor a ld [wTrainerClass], a - ld [hStartTileID], a - coord hl, 12, 0 + ldh [hStartTileID], a + hlcoord 12, 0 predef CopyUncompressedPicToTilemap ; common code that executes after init battle code specific to trainer or wild battles @@ -6833,23 +6833,23 @@ _InitBattleCommon: call RunPaletteCommand call SlidePlayerAndEnemySilhouettesOnScreen xor a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ld hl, .emptyString call PrintText call SaveScreenTilesToBuffer1 call ClearScreen ld a, $98 - ld [hAutoBGTransferDest + 1], a + ldh [hAutoBGTransferDest + 1], a ld a, $1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a call Delay3 ld a, $9c - ld [hAutoBGTransferDest + 1], a + ldh [hAutoBGTransferDest + 1], a call LoadScreenTilesFromBuffer1 - coord hl, 9, 7 + hlcoord 9, 7 lb bc, 5, 10 call ClearScreenArea - coord hl, 1, 0 + hlcoord 1, 0 lb bc, 4, 10 call ClearScreenArea call ClearSprites @@ -6857,13 +6857,13 @@ _InitBattleCommon: dec a ; is it a wild battle? call z, DrawEnemyHUDAndHPBar ; draw enemy HUD and HP bar if it's a wild battle call StartBattle - callab EndOfBattle + callfar EndOfBattle pop af ld [wLetterPrintingDelayFlags], a pop af ld [wMapPalOffset], a ld a, [wSavedTilesetType] - ld [hTilesetType], a + ldh [hTilesetType], a scf ret .emptyString @@ -6900,8 +6900,8 @@ AnimateSendingOutMon: ld h, a ld a, [wPredefRegisters + 1] ld l, a - ld a, [hStartTileID] - ld [hBaseTileID], a + ldh a, [hStartTileID] + ldh [hBaseTileID], a ld b, $4c ld a, [wIsInBattle] and a @@ -6931,7 +6931,7 @@ AnimateSendingOutMon: ld bc, -(SCREEN_WIDTH * 6 + 3) .next add hl, bc - ld a, [hBaseTileID] + ldh a, [hBaseTileID] add $31 jr CopyUncompressedPicToHL @@ -6940,7 +6940,7 @@ CopyUncompressedPicToTilemap: ld h, a ld a, [wPredefRegisters + 1] ld l, a - ld a, [hStartTileID] + ldh a, [hStartTileID] CopyUncompressedPicToHL:: lb bc, 7, 7 ld de, SCREEN_WIDTH @@ -6993,7 +6993,7 @@ LoadMonBackPic: ; been loaded with GetMonHeader. ld a, [wBattleMonSpecies2] ld [wcf91], a - coord hl, 1, 5 + hlcoord 1, 5 ld b, 7 ld c, 8 call ClearScreenArea @@ -7005,6 +7005,6 @@ LoadMonBackPic: ld hl, vSprites ld de, vBackPic ld c, (2*SPRITEBUFFERSIZE)/16 ; count of 16-byte chunks to be copied - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] ld b, a jp CopyVideoData diff --git a/engine/battle/draw_hud_pokeball_gfx.asm b/engine/battle/draw_hud_pokeball_gfx.asm index c0a91949..097a0fcc 100644 --- a/engine/battle/draw_hud_pokeball_gfx.asm +++ b/engine/battle/draw_hud_pokeball_gfx.asm @@ -12,7 +12,7 @@ DrawEnemyPokeballs: LoadPartyPokeballGfx: ld de, PokeballTileGraphics - ld hl, vSprites + $310 + ld hl, vSprites tile $31 lb bc, BANK(PokeballTileGraphics), (PokeballTileGraphicsEnd - PokeballTileGraphics) / $10 jp CopyVideoData @@ -121,7 +121,7 @@ PlacePlayerHUDTiles: ld de, wHUDGraphicsTiles ld bc, $3 call CopyData - coord hl, 18, 10 + hlcoord 18, 10 ld de, -1 jr PlaceHUDTiles @@ -136,7 +136,7 @@ PlaceEnemyHUDTiles: ld de, wHUDGraphicsTiles ld bc, $3 call CopyData - coord hl, 1, 2 + hlcoord 1, 2 ld de, $1 jr PlaceHUDTiles diff --git a/engine/battle/effects.asm b/engine/battle/effects.asm index 22fadb42..441d6c1c 100644 --- a/engine/battle/effects.asm +++ b/engine/battle/effects.asm @@ -4,7 +4,7 @@ JumpMoveEffect: ret _JumpMoveEffect: - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld a, [wPlayerMoveEffect] jr z, .next1 @@ -26,7 +26,7 @@ INCLUDE "data/moves/effects_pointers.asm" SleepEffect: ld de, wEnemyMonStatus ld bc, wEnemyBattleStatus2 - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jp z, .sleepEffect ld de, wBattleMonStatus @@ -78,7 +78,7 @@ AlreadyAsleepText: PoisonEffect: ld hl, wEnemyMonStatus ld de, wPlayerMoveEffect - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .poisonEffect ld hl, wBattleMonStatus @@ -121,7 +121,7 @@ PoisonEffect: set 3, [hl] ; mon is now poisoned push de dec de - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld b, ANIM_C7 ld hl, wPlayerBattleStatus3 @@ -170,12 +170,12 @@ BadlyPoisonedText: text_end DrainHPEffect: - jpab DrainHPEffect_ + jpfar DrainHPEffect_ ExplodeEffect: ld hl, wBattleMonHP ld de, wPlayerBattleStatus2 - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .faintUser ld hl, wEnemyMonHP @@ -196,7 +196,7 @@ FreezeBurnParalyzeEffect: ld [wAnimationType], a 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 - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jp nz, opponentAttacker 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 and 1 << FRZ ; are they frozen? ret z ; return if so - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr nz, .opponent ;player [attacker] @@ -346,7 +346,7 @@ FireDefrostedText: StatModifierUpEffect: ld hl, wPlayerMonStatMods ld de, wPlayerMoveEffect - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .statModifierUpEffect ld hl, wEnemyMonStatMods @@ -382,7 +382,7 @@ StatModifierUpEffect: push hl ld hl, wBattleMonAttack + 1 ld de, wPlayerMonUnmodifiedAttack - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .pointToStats ld hl, wEnemyMonAttack + 1 @@ -399,11 +399,12 @@ StatModifierUpEffect: inc d ; de = unmodified (original) stat .checkIf999 pop bc + ; check if stat is already 999 ld a, [hld] - sub 999 % $100 ; check if stat is already 999 + sub LOW(MAX_STAT_VALUE) jr nz, .recalculateStat ld a, [hl] - sbc 999 / $100 + sbc HIGH(MAX_STAT_VALUE) jp z, RestoreOriginalStatModifier .recalculateStat ; recalculate affected stat ; paralysis and burn penalties, as well as badge boosts are ignored @@ -417,35 +418,35 @@ StatModifierUpEffect: add hl, bc pop bc xor a - ld [hMultiplicand], a + ldh [hMultiplicand], a ld a, [de] - ld [hMultiplicand + 1], a + ldh [hMultiplicand + 1], a inc de ld a, [de] - ld [hMultiplicand + 2], a + ldh [hMultiplicand + 2], a ld a, [hli] - ld [hMultiplier], a + ldh [hMultiplier], a call Multiply ld a, [hl] - ld [hDivisor], a + ldh [hDivisor], a ld b, $4 call Divide pop hl -; cap at 999 - ld a, [hProduct + 3] - sub 999 % $100 - ld a, [hProduct + 2] - sbc 999 / $100 +; cap at MAX_STAT_VALUE (999) + ldh a, [hProduct + 3] + sub LOW(MAX_STAT_VALUE) + ldh a, [hProduct + 2] + sbc HIGH(MAX_STAT_VALUE) jp c, UpdateStat - ld a, 999 / $100 - ld [hMultiplicand + 1], a - ld a, 999 % $100 - ld [hMultiplicand + 2], a + ld a, HIGH(MAX_STAT_VALUE) + ldh [hMultiplicand + 1], a + ld a, LOW(MAX_STAT_VALUE) + ldh [hMultiplicand + 2], a UpdateStat: - ld a, [hProduct + 2] + ldh a, [hProduct + 2] ld [hli], a - ld a, [hProduct + 3] + ldh a, [hProduct + 3] ld [hl], a pop hl UpdateStatDone: @@ -455,7 +456,7 @@ UpdateStatDone: ld hl, wPlayerBattleStatus2 ld de, wPlayerMoveNum ld bc, wPlayerMonMinimized - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .asm_3f4e6 ld hl, wEnemyBattleStatus2 @@ -488,7 +489,7 @@ UpdateStatDone: pop af call nz, Bankswitch .applyBadgeBoostsAndStatusPenalties - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a 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) @@ -511,7 +512,7 @@ MonsStatsRoseText: text_far _MonsStatsRoseText text_asm ld hl, GreatlyRoseText - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld a, [wPlayerMoveEffect] jr z, .playerTurn @@ -534,7 +535,7 @@ StatModifierDownEffect: ld hl, wEnemyMonStatMods ld de, wPlayerMoveEffect ld bc, wEnemyBattleStatus1 - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .statModifierDownEffect ld hl, wPlayerMonStatMods @@ -601,7 +602,7 @@ StatModifierDownEffect: push de ld hl, wEnemyMonAttack + 1 ld de, wEnemyMonUnmodifiedAttack - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .pointToStat ld hl, wBattleMonAttack + 1 @@ -637,33 +638,33 @@ StatModifierDownEffect: add hl, bc pop bc xor a - ld [hMultiplicand], a + ldh [hMultiplicand], a ld a, [de] - ld [hMultiplicand + 1], a + ldh [hMultiplicand + 1], a inc de ld a, [de] - ld [hMultiplicand + 2], a + ldh [hMultiplicand + 2], a ld a, [hli] - ld [hMultiplier], a + ldh [hMultiplier], a call Multiply ld a, [hl] - ld [hDivisor], a + ldh [hDivisor], a ld b, $4 call Divide pop hl - ld a, [hProduct + 3] + ldh a, [hProduct + 3] ld b, a - ld a, [hProduct + 2] + ldh a, [hProduct + 2] or b jp nz, UpdateLoweredStat - ld [hMultiplicand + 1], a + ldh [hMultiplicand + 1], a ld a, $1 - ld [hMultiplicand + 2], a + ldh [hMultiplicand + 2], a UpdateLoweredStat: - ld a, [hProduct + 2] + ldh a, [hProduct + 2] ld [hli], a - ld a, [hProduct + 3] + ldh a, [hProduct + 3] ld [hl], a pop de pop hl @@ -678,7 +679,7 @@ UpdateLoweredStatDone: jr nc, .ApplyBadgeBoostsAndStatusPenalties call PlayCurrentMoveAnimation2 .ApplyBadgeBoostsAndStatusPenalties - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a 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) @@ -713,7 +714,7 @@ MonsStatsFellText: text_far _MonsStatsFellText text_asm ld hl, FellText - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld a, [wPlayerMoveEffect] jr z, .playerTurn @@ -759,7 +760,7 @@ BideEffect: ld hl, wPlayerBattleStatus1 ld de, wPlayerBideAccumulatedDamage ld bc, wPlayerNumAttacksLeft - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .bideEffect ld hl, wEnemyBattleStatus1 @@ -778,14 +779,14 @@ BideEffect: inc a inc a ld [bc], a ; set Bide counter to 2 or 3 at random - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] add XSTATITEM_ANIM jp PlayBattleAnimation2 ThrashPetalDanceEffect: ld hl, wPlayerBattleStatus1 ld de, wPlayerNumAttacksLeft - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .thrashPetalDanceEffect ld hl, wEnemyBattleStatus1 @@ -797,12 +798,12 @@ ThrashPetalDanceEffect: inc a inc a ld [de], a ; set thrash/petal dance counter to 2 or 3 at random - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] add ANIM_B0 jp PlayBattleAnimation2 SwitchAndTeleportEffect: - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr nz, .handleEnemy ld a, [wIsInBattle] @@ -920,7 +921,7 @@ TwoToFiveAttacksEffect: ld hl, wPlayerBattleStatus1 ld de, wPlayerNumAttacksLeft ld bc, wPlayerNumHits - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .twoToFiveAttacksEffect ld hl, wEnemyBattleStatus1 @@ -931,7 +932,7 @@ TwoToFiveAttacksEffect: ret nz set ATTACKING_MULTIPLE_TIMES, [hl] ; mon is now attacking multiple times ld hl, wPlayerMoveEffect - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .setNumberOfHits ld hl, wEnemyMoveEffect @@ -967,7 +968,7 @@ FlinchSideEffect: ret nz ld hl, wEnemyBattleStatus1 ld de, wPlayerMoveEffect - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .flinchSideEffect ld hl, wPlayerBattleStatus1 @@ -987,12 +988,12 @@ FlinchSideEffect: ret OneHitKOEffect: - jpab OneHitKOEffect_ + jpfar OneHitKOEffect_ ChargeEffect: ld hl, wPlayerBattleStatus1 ld de, wPlayerMoveEffect - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld b, XSTATITEM_ANIM jr z, .chargeEffect @@ -1074,7 +1075,7 @@ DugAHoleText: TrappingEffect: ld hl, wPlayerBattleStatus1 ld de, wPlayerNumAttacksLeft - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .trappingEffect ld hl, wEnemyBattleStatus1 @@ -1097,13 +1098,13 @@ TrappingEffect: ret MistEffect: - jpab MistEffect_ + jpfar MistEffect_ FocusEnergyEffect: - jpab FocusEnergyEffect_ + jpfar FocusEnergyEffect_ RecoilEffect: - jpab RecoilEffect_ + jpfar RecoilEffect_ ConfusionSideEffect: call BattleRandom @@ -1120,7 +1121,7 @@ ConfusionEffect: jr nz, ConfusionEffectFailed ConfusionSideEffectSuccess: - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld hl, wEnemyBattleStatus1 ld bc, wEnemyConfusedCounter @@ -1157,14 +1158,14 @@ ConfusionEffectFailed: jp ConditionalPrintButItFailed ParalyzeEffect: - jpab ParalyzeEffect_ + jpfar ParalyzeEffect_ SubstituteEffect: - jpab SubstituteEffect_ + jpfar SubstituteEffect_ HyperBeamEffect: ld hl, wPlayerBattleStatus2 - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .hyperBeamEffect ld hl, wEnemyBattleStatus2 @@ -1175,7 +1176,7 @@ HyperBeamEffect: ClearHyperBeam: push hl ld hl, wEnemyBattleStatus2 - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .playerTurn ld hl, wPlayerBattleStatus2 @@ -1186,7 +1187,7 @@ ClearHyperBeam: RageEffect: ld hl, wPlayerBattleStatus2 - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .player ld hl, wEnemyBattleStatus2 @@ -1201,7 +1202,7 @@ MimicEffect: ld a, [wMoveMissed] and a jr nz, .mimicMissed - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld hl, wBattleMonMoves ld a, [wPlayerBattleStatus1] @@ -1226,7 +1227,7 @@ MimicEffect: and a jr z, .getRandomMove ld d, a - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld hl, wBattleMonMoves ld a, [wPlayerMoveListIndex] @@ -1271,7 +1272,7 @@ MimicLearnedMoveText: text_end LeechSeedEffect: - jpab LeechSeedEffect_ + jpfar LeechSeedEffect_ SplashEffect: call PlayCurrentMoveAnimation @@ -1284,7 +1285,7 @@ DisableEffect: jr nz, .moveMissed ld de, wEnemyDisabledMove ld hl, wEnemyMonMoves - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .disableEffect ld de, wPlayerDisabledMove @@ -1307,7 +1308,7 @@ DisableEffect: jr z, .pickMoveToDisable ; loop until a non-00 move slot is found ld [wd11e], a ; store move number push hl - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld hl, wBattleMonPP jr nz, .enemyTurn @@ -1345,7 +1346,7 @@ DisableEffect: ld [de], a call PlayCurrentMoveAnimation2 ld hl, wPlayerDisabledMoveNumber - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr nz, .printDisableText inc hl ; wEnemyDisabledMoveNumber @@ -1365,22 +1366,22 @@ MoveWasDisabledText: text_end PayDayEffect: - jpab PayDayEffect_ + jpfar PayDayEffect_ ConversionEffect: - jpab ConversionEffect_ + jpfar ConversionEffect_ HazeEffect: - jpab HazeEffect_ + jpfar HazeEffect_ HealEffect: - jpab HealEffect_ + jpfar HealEffect_ TransformEffect: - jpab TransformEffect_ + jpfar TransformEffect_ ReflectLightScreenEffect: - jpab ReflectLightScreenEffect_ + jpfar ReflectLightScreenEffect_ NothingHappenedText: text_far _NothingHappenedText @@ -1430,7 +1431,7 @@ ParalyzedMayNotAttackText: CheckTargetSubstitute: push hl ld hl, wEnemyBattleStatus2 - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .next1 ld hl, wPlayerBattleStatus2 @@ -1442,7 +1443,7 @@ CheckTargetSubstitute: PlayCurrentMoveAnimation2: ; animation at MOVENUM will be played unless MOVENUM is 0 ; plays wAnimationType 3 or 6 - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld a, [wPlayerMoveNum] jr z, .notEnemyTurn @@ -1454,7 +1455,7 @@ PlayCurrentMoveAnimation2: PlayBattleAnimation2: ; play animation ID at a and animation type 6 or 3 ld [wAnimationID], a - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld a, $6 jr z, .storeAnimationType @@ -1468,7 +1469,7 @@ PlayCurrentMoveAnimation: ; resets wAnimationType xor a ld [wAnimationType], a - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld a, [wPlayerMoveNum] jr z, .notEnemyTurn diff --git a/engine/battle/end_of_battle.asm b/engine/battle/end_of_battle.asm index f490c34d..bd4a1901 100755 --- a/engine/battle/end_of_battle.asm +++ b/engine/battle/end_of_battle.asm @@ -10,7 +10,7 @@ EndOfBattle: ld a, [wEnemyMonStatus] ld [hl], a call ClearScreen - callab DisplayLinkBattleVersusTextBox + callfar DisplayLinkBattleVersusTextBox ld a, [wBattleResult] cp $1 ld de, YouWinText @@ -19,7 +19,7 @@ EndOfBattle: jr z, .placeWinOrLoseString ld de, DrawText .placeWinOrLoseString - coord hl, 6, 8 + hlcoord 6, 8 call PlaceString ld c, 200 call DelayFrames diff --git a/engine/battle/experience.asm b/engine/battle/experience.asm index 6bc0a019..0eab6e08 100644 --- a/engine/battle/experience.asm +++ b/engine/battle/experience.asm @@ -55,15 +55,15 @@ GainExperience: jr .gainStatExpLoop .statExpDone xor a - ld [hMultiplicand], a - ld [hMultiplicand + 1], a + ldh [hMultiplicand], a + ldh [hMultiplicand + 1], a ld a, [wEnemyMonBaseExp] - ld [hMultiplicand + 2], a + ldh [hMultiplicand + 2], a ld a, [wEnemyMonLevel] - ld [hMultiplier], a + ldh [hMultiplier], a call Multiply ld a, 7 - ld [hDivisor], a + ldh [hDivisor], a ld b, 4 call Divide ld hl, wPartyMon1OTID - (wPartyMon1DVs - 1) @@ -91,12 +91,12 @@ GainExperience: inc hl ; add the gained exp to the party mon's exp ld b, [hl] - ld a, [hQuotient + 3] + ldh a, [hQuotient + 3] ld [wExpAmountGained + 1], a add b ld [hld], a ld b, [hl] - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] ld [wExpAmountGained], a adc b ld [hl], a @@ -117,13 +117,13 @@ GainExperience: ld [wd0b5], a call GetMonHeader ld d, MAX_LEVEL - callab CalcExperience ; get max exp + callfar CalcExperience ; get max exp ; compare max exp with current exp - ld a, [hExperience] + ldh a, [hExperience] ld b, a - ld a, [hExperience + 1] + ldh a, [hExperience + 1] ld c, a - ld a, [hExperience + 2] + ldh a, [hExperience + 2] ld d, a pop hl ld a, [hld] @@ -155,7 +155,7 @@ GainExperience: ld bc, wPartyMon1Level - wPartyMon1Exp add hl, bc push hl - callba CalcLevelFromExperience + farcall CalcLevelFromExperience pop hl ld a, [hl] ; current level cp d @@ -233,11 +233,11 @@ GainExperience: .recalcStatChanges xor a ; battle mon ld [wCalculateWhoseStats], a - callab CalculateModifiedStats - callab ApplyBurnAndParalysisPenaltiesToPlayer - callab ApplyBadgeStatBoosts - callab DrawPlayerHUDAndHPBar - callab PrintEmptyString + callfar CalculateModifiedStats + callfar ApplyBurnAndParalysisPenaltiesToPlayer + callfar ApplyBadgeStatBoosts + callfar DrawPlayerHUDAndHPBar + callfar PrintEmptyString call SaveScreenTilesToBuffer1 .printGrewLevelText ld hl, GrewLevelText @@ -246,7 +246,7 @@ GainExperience: ld [wMonDataLocation], a call LoadMonData ld d, $1 - callab PrintStatsBox + callfar PrintStatsBox call WaitForTextScrollButtonPress call LoadScreenTilesFromBuffer1 xor a ; PLAYER_PARTY_DATA @@ -311,14 +311,14 @@ DivideExpDataByNumMonsGainingExp: ld c, wEnemyMonBaseExp + 1 - wEnemyMonBaseStats .divideLoop xor a - ld [hDividend], a + ldh [hDividend], a ld a, [hl] - ld [hDividend + 1], a + ldh [hDividend + 1], a ld a, [wd11e] - ld [hDivisor], a + ldh [hDivisor], a ld b, $2 call Divide ; divide value by number of mons gaining exp - ld a, [hQuotient + 3] + ldh a, [hQuotient + 3] ld [hli], a dec c jr nz, .divideLoop @@ -326,17 +326,17 @@ DivideExpDataByNumMonsGainingExp: ; multiplies exp by 1.5 BoostExp: - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] ld b, a - ld a, [hQuotient + 3] + ldh a, [hQuotient + 3] ld c, a srl b rr c add c - ld [hQuotient + 3], a - ld a, [hQuotient + 2] + ldh [hQuotient + 3], a + ldh a, [hQuotient + 2] adc b - ld [hQuotient + 2], a + ldh [hQuotient + 2], a ret GainedText: diff --git a/engine/battle/ghost_marowak_anim.asm b/engine/battle/ghost_marowak_anim.asm index 28f536ca..7405c40b 100644 --- a/engine/battle/ghost_marowak_anim.asm +++ b/engine/battle/ghost_marowak_anim.asm @@ -1,21 +1,21 @@ MarowakAnim: ; animate the ghost being unveiled as a Marowak 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 ; now that the ghost pic is being displayed using sprites, clear the ghost pic from the BG tilemap - coord hl, 12, 0 + hlcoord 12, 0 lb bc, 7, 7 call ClearScreenArea call Delay3 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 ld a, MAROWAK ld [wChangeMonPicEnemyTurnSpecies], a ld a, $1 - ld [hWhoseTurn], a - callab ChangeMonPic + ldh [hWhoseTurn], a + callfar ChangeMonPic ; alternate between black and light grey 8 times. ; this makes the ghost's body appear to flash ld d, $80 @@ -23,10 +23,10 @@ MarowakAnim: .fadeOutGhostLoop ld c, 10 call DelayFrames - ld a, [rOBP1] + ldh a, [rOBP1] sla a sla a - ld [rOBP1], a + ldh [rOBP1], a jr nz, .fadeOutGhostLoop call ClearSprites call CopyMonPicFromBGToSpriteVRAM ; copy Marowak pic from BG to sprite VRAM @@ -34,17 +34,17 @@ MarowakAnim: .fadeInMarowakLoop ld c, 10 call DelayFrames - ld a, [rOBP1] + ldh a, [rOBP1] srl b rra srl b rra - ld [rOBP1], a + ldh [rOBP1], a ld a, b and a jr nz, .fadeInMarowakLoop 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 jp ClearSprites diff --git a/engine/battle/init_battle_variables.asm b/engine/battle/init_battle_variables.asm index 7bc912d2..0d403b55 100644 --- a/engine/battle/init_battle_variables.asm +++ b/engine/battle/init_battle_variables.asm @@ -1,5 +1,5 @@ InitBattleVariables: - ld a, [hTilesetType] + ldh a, [hTilesetType] ld [wSavedTilesetType], a xor a ld [wActionResultOrTookBattleTurn], a @@ -35,4 +35,4 @@ InitBattleVariables: ld a, BATTLE_TYPE_SAFARI ld [wBattleType], a .notSafariBattle - jpab PlayBattleMusic + jpfar PlayBattleMusic diff --git a/engine/battle/link_battle_versus_text.asm b/engine/battle/link_battle_versus_text.asm index 76559117..29c11356 100644 --- a/engine/battle/link_battle_versus_text.asm +++ b/engine/battle/link_battle_versus_text.asm @@ -1,23 +1,23 @@ ; display "[player] VS [enemy]" text box with pokeballs representing their parties next to the names DisplayLinkBattleVersusTextBox: call LoadTextBoxTilePatterns - coord hl, 3, 4 + hlcoord 3, 4 ld b, 7 ld c, 12 call TextBoxBorder - coord hl, 4, 5 + hlcoord 4, 5 ld de, wPlayerName call PlaceString - coord hl, 4, 10 + hlcoord 4, 10 ld de, wLinkEnemyTrainerName call PlaceString ; place bold "VS" tiles between the names - coord hl, 9, 8 + hlcoord 9, 8 ld a, $69 ld [hli], a ld [hl], $6a xor a ld [wUpdateSpritesEnabled], a - callab SetupPlayerAndEnemyPokeballs + callfar SetupPlayerAndEnemyPokeballs ld c, 150 jp DelayFrames diff --git a/engine/battle/move_effects/conversion.asm b/engine/battle/move_effects/conversion.asm index 662f65e0..1f64ec5b 100644 --- a/engine/battle/move_effects/conversion.asm +++ b/engine/battle/move_effects/conversion.asm @@ -1,7 +1,7 @@ ConversionEffect_: ld hl, wEnemyMonType1 ld de, wBattleMonType1 - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld a, [wEnemyBattleStatus1] jr z, .conversionEffect diff --git a/engine/battle/move_effects/drain_hp.asm b/engine/battle/move_effects/drain_hp.asm index 452ccf0c..04a585cc 100644 --- a/engine/battle/move_effects/drain_hp.asm +++ b/engine/battle/move_effects/drain_hp.asm @@ -14,7 +14,7 @@ DrainHPEffect_: .getAttackerHP ld hl, wBattleMonHP ld de, wBattleMonMaxHP - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jp z, .addDamageToAttackerHP ld hl, wEnemyMonHP @@ -69,21 +69,21 @@ DrainHPEffect_: ld [wHPBarNewHP+1], a inc de .next - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a - coord hl, 10, 9 + hlcoord 10, 9 ld a, $1 jr z, .next2 - coord hl, 2, 2 + hlcoord 2, 2 xor a .next2 ld [wHPBarType], a predef UpdateHPBar2 predef DrawPlayerHUDAndHPBar predef DrawEnemyHUDAndHPBar - callab ReadPlayerMonCurHPAndStatus + callfar ReadPlayerMonCurHPAndStatus ld hl, SuckedHealthText - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld a, [wPlayerMoveEffect] jr z, .next3 diff --git a/engine/battle/move_effects/focus_energy.asm b/engine/battle/move_effects/focus_energy.asm index 7a426d2c..1fafe920 100644 --- a/engine/battle/move_effects/focus_energy.asm +++ b/engine/battle/move_effects/focus_energy.asm @@ -1,6 +1,6 @@ FocusEnergyEffect_: ld hl, wPlayerBattleStatus2 - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .notEnemy ld hl, wEnemyBattleStatus2 @@ -8,13 +8,13 @@ FocusEnergyEffect_: bit GETTING_PUMPED, [hl] ; is mon already using focus energy? jr nz, .alreadyUsing set GETTING_PUMPED, [hl] ; mon is now using focus energy - callab PlayCurrentMoveAnimation + callfar PlayCurrentMoveAnimation ld hl, GettingPumpedText jp PrintText .alreadyUsing ld c, 50 call DelayFrames - jpab PrintButItFailedText_ + jpfar PrintButItFailedText_ GettingPumpedText: text_pause diff --git a/engine/battle/move_effects/haze.asm b/engine/battle/move_effects/haze.asm index 521ff662..915eeed8 100644 --- a/engine/battle/move_effects/haze.asm +++ b/engine/battle/move_effects/haze.asm @@ -15,7 +15,7 @@ HazeEffect_: ; cure non-volatile status, but only for the target ld hl, wEnemyMonStatus ld de, wEnemySelectedMove - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .cureStatuses ld hl, wBattleMonStatus diff --git a/engine/battle/move_effects/heal.asm b/engine/battle/move_effects/heal.asm index 8cc9da93..e9fb62a7 100644 --- a/engine/battle/move_effects/heal.asm +++ b/engine/battle/move_effects/heal.asm @@ -1,5 +1,5 @@ HealEffect_: - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld de, wBattleMonHP ld hl, wBattleMonMaxHP @@ -27,7 +27,7 @@ HealEffect_: ld c, 50 call DelayFrames ld hl, wBattleMonStatus - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .restEffect ld hl, wEnemyMonStatus @@ -87,12 +87,12 @@ HealEffect_: .playAnim ld hl, PlayCurrentMoveAnimation call BankswitchEtoF - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a - coord hl, 10, 9 + hlcoord 10, 9 ld a, $1 jr z, .updateHPBar - coord hl, 2, 2 + hlcoord 2, 2 xor a .updateHPBar ld [wHPBarType], a diff --git a/engine/battle/move_effects/leech_seed.asm b/engine/battle/move_effects/leech_seed.asm index 74360233..61bd982a 100644 --- a/engine/battle/move_effects/leech_seed.asm +++ b/engine/battle/move_effects/leech_seed.asm @@ -1,11 +1,11 @@ LeechSeedEffect_: - callab MoveHitTest + callfar MoveHitTest ld a, [wMoveMissed] and a jr nz, .moveMissed ld hl, wEnemyBattleStatus2 ld de, wEnemyMonType1 - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .leechSeedEffect ld hl, wPlayerBattleStatus2 @@ -22,7 +22,7 @@ LeechSeedEffect_: bit SEEDED, [hl] jr nz, .moveMissed set SEEDED, [hl] - callab PlayCurrentMoveAnimation + callfar PlayCurrentMoveAnimation ld hl, WasSeededText jp PrintText .moveMissed diff --git a/engine/battle/move_effects/mist.asm b/engine/battle/move_effects/mist.asm index 67ee4921..163d386f 100644 --- a/engine/battle/move_effects/mist.asm +++ b/engine/battle/move_effects/mist.asm @@ -1,6 +1,6 @@ MistEffect_: ld hl, wPlayerBattleStatus2 - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .mistEffect ld hl, wEnemyBattleStatus2 @@ -8,11 +8,11 @@ MistEffect_: bit PROTECTED_BY_MIST, [hl] ; is mon protected by mist? jr nz, .mistAlreadyInUse set PROTECTED_BY_MIST, [hl] ; mon is now protected by mist - callab PlayCurrentMoveAnimation + callfar PlayCurrentMoveAnimation ld hl, ShroudedInMistText jp PrintText .mistAlreadyInUse - jpab PrintButItFailedText_ + jpfar PrintButItFailedText_ ShroudedInMistText: text_far _ShroudedInMistText diff --git a/engine/battle/move_effects/one_hit_ko.asm b/engine/battle/move_effects/one_hit_ko.asm index 347a4c7b..7e5db0f7 100644 --- a/engine/battle/move_effects/one_hit_ko.asm +++ b/engine/battle/move_effects/one_hit_ko.asm @@ -7,7 +7,7 @@ OneHitKOEffect_: ld [wCriticalHitOrOHKO], a ld hl, wBattleMonSpeed + 1 ld de, wEnemyMonSpeed + 1 - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .compareSpeed ld hl, wEnemyMonSpeed + 1 diff --git a/engine/battle/move_effects/paralyze.asm b/engine/battle/move_effects/paralyze.asm index b01aa5cf..dbaa0fb8 100644 --- a/engine/battle/move_effects/paralyze.asm +++ b/engine/battle/move_effects/paralyze.asm @@ -1,7 +1,7 @@ ParalyzeEffect_: ld hl, wEnemyMonStatus ld de, wPlayerMoveType - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jp z, .next ld hl, wBattleMonStatus @@ -26,22 +26,22 @@ ParalyzeEffect_: jr z, .doesntAffect .hitTest push hl - callab MoveHitTest + callfar MoveHitTest pop hl ld a, [wMoveMissed] and a jr nz, .didntAffect set PAR, [hl] - callab QuarterSpeedDueToParalysis + callfar QuarterSpeedDueToParalysis ld c, 30 call DelayFrames - callab PlayCurrentMoveAnimation - jpab PrintMayNotAttackText + callfar PlayCurrentMoveAnimation + jpfar PrintMayNotAttackText .didntAffect ld c, 50 call DelayFrames - jpab PrintDidntAffectText + jpfar PrintDidntAffectText .doesntAffect ld c, 50 call DelayFrames - jpab PrintDoesntAffectText + jpfar PrintDoesntAffectText diff --git a/engine/battle/move_effects/pay_day.asm b/engine/battle/move_effects/pay_day.asm index 11140ec2..fa373038 100644 --- a/engine/battle/move_effects/pay_day.asm +++ b/engine/battle/move_effects/pay_day.asm @@ -2,7 +2,7 @@ PayDayEffect_: xor a ld hl, wcd6d ld [hli], a - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld a, [wBattleMonLevel] jr z, .payDayEffect @@ -10,28 +10,28 @@ PayDayEffect_: .payDayEffect ; level * 2 add a - ld [hDividend + 3], a + ldh [hDividend + 3], a xor a - ld [hDividend], a - ld [hDividend + 1], a - ld [hDividend + 2], a + ldh [hDividend], a + ldh [hDividend + 1], a + ldh [hDividend + 2], a ; convert to BCD ld a, 100 - ld [hDivisor], a + ldh [hDivisor], a ld b, $4 call Divide - ld a, [hQuotient + 3] + ldh a, [hQuotient + 3] ld [hli], a - ld a, [hRemainder] - ld [hDividend + 3], a + ldh a, [hRemainder] + ldh [hDividend + 3], a ld a, 10 - ld [hDivisor], a + ldh [hDivisor], a ld b, $4 call Divide - ld a, [hQuotient + 3] + ldh a, [hQuotient + 3] swap a ld b, a - ld a, [hRemainder] + ldh a, [hRemainder] add b ld [hl], a ld de, wTotalPayDayMoney + 2 diff --git a/engine/battle/move_effects/recoil.asm b/engine/battle/move_effects/recoil.asm index 63aff429..85110d50 100644 --- a/engine/battle/move_effects/recoil.asm +++ b/engine/battle/move_effects/recoil.asm @@ -1,5 +1,5 @@ RecoilEffect_: - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld a, [wPlayerMoveNum] ld hl, wBattleMonMaxHP @@ -53,12 +53,12 @@ RecoilEffect_: ld [hli], a ld [hl], a .getHPBarCoords - coord hl, 10, 9 - ld a, [hWhoseTurn] + hlcoord 10, 9 + ldh a, [hWhoseTurn] and a ld a, $1 jr z, .updateHPBar - coord hl, 2, 2 + hlcoord 2, 2 xor a .updateHPBar ld [wHPBarType], a diff --git a/engine/battle/move_effects/reflect_light_screen.asm b/engine/battle/move_effects/reflect_light_screen.asm index 07338c9a..7bdc7be7 100644 --- a/engine/battle/move_effects/reflect_light_screen.asm +++ b/engine/battle/move_effects/reflect_light_screen.asm @@ -1,7 +1,7 @@ ReflectLightScreenEffect_: ld hl, wPlayerBattleStatus3 ld de, wPlayerMoveEffect - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .reflectLightScreenEffect ld hl, wEnemyBattleStatus3 diff --git a/engine/battle/move_effects/substitute.asm b/engine/battle/move_effects/substitute.asm index 95c43462..860b76b6 100644 --- a/engine/battle/move_effects/substitute.asm +++ b/engine/battle/move_effects/substitute.asm @@ -4,7 +4,7 @@ SubstituteEffect_: ld hl, wBattleMonMaxHP ld de, wPlayerSubstituteHP ld bc, wPlayerBattleStatus2 - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .notEnemy ld hl, wEnemyMonMaxHP @@ -55,7 +55,7 @@ SubstituteEffect_: call Bankswitch ; jump to routine depending on animation setting ld hl, SubstituteText call PrintText - jpab DrawHUDsAndHPBars + jpfar DrawHUDsAndHPBars .alreadyHasSubstitute ld hl, HasSubstituteText jr .printText diff --git a/engine/battle/move_effects/transform.asm b/engine/battle/move_effects/transform.asm index da26d031..46cea51c 100644 --- a/engine/battle/move_effects/transform.asm +++ b/engine/battle/move_effects/transform.asm @@ -3,7 +3,7 @@ TransformEffect_: ld de, wEnemyMonSpecies ld bc, wEnemyBattleStatus3 ld a, [wEnemyBattleStatus1] - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr nz, .hitTest ld hl, wEnemyMonSpecies @@ -18,7 +18,7 @@ TransformEffect_: push de push bc ld hl, wPlayerBattleStatus2 - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .transformEffect ld hl, wEnemyBattleStatus2 @@ -64,7 +64,7 @@ TransformEffect_: inc bc inc bc call CopyData - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .next ; save enemy mon DVs at wTransformedEnemyMonOriginalDVs @@ -128,7 +128,7 @@ TransformEffect_: jp PrintText .copyBasedOnTurn - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a jr z, .gotStatsOrModsToCopy push hl diff --git a/engine/battle/scale_sprites.asm b/engine/battle/scale_sprites.asm index 11967ba1..69979412 100644 --- a/engine/battle/scale_sprites.asm +++ b/engine/battle/scale_sprites.asm @@ -41,16 +41,16 @@ ScaleFirstThreeSpriteColumnsByTwo: ScaleLastSpriteColumnByTwo: ld a, 4*8 - 4 ; $1c, 4 tiles minus 4 unused rows - ld [hSpriteInterlaceCounter], a + ldh [hSpriteInterlaceCounter], a ld bc, -1 .columnInnerLoop ld a, [de] dec de swap a ; only high nybble contains information call ScalePixelsByTwo - ld a, [hSpriteInterlaceCounter] + ldh a, [hSpriteInterlaceCounter] dec a - ld [hSpriteInterlaceCounter], a + ldh [hSpriteInterlaceCounter], a jr nz, .columnInnerLoop dec de ; skip last 4 rows of new column dec de diff --git a/engine/battle/scroll_draw_trainer_pic.asm b/engine/battle/scroll_draw_trainer_pic.asm index 98893dcf..e19d681a 100644 --- a/engine/battle/scroll_draw_trainer_pic.asm +++ b/engine/battle/scroll_draw_trainer_pic.asm @@ -5,8 +5,8 @@ _ScrollTrainerPicAfterBattle: ld [wEnemyMonSpecies2], a ld b, SET_PAL_BATTLE call RunPaletteCommand - callab _LoadTrainerPic - coord hl, 19, 0 + callfar _LoadTrainerPic + hlcoord 19, 0 ld c, $0 .scrollLoop inc c diff --git a/engine/battle/trainer_ai.asm b/engine/battle/trainer_ai.asm index 8373ef4f..87bec842 100644 --- a/engine/battle/trainer_ai.asm +++ b/engine/battle/trainer_ai.asm @@ -204,7 +204,7 @@ AIMoveChoiceModification3: push hl push bc push de - callab AIGetTypeEffectiveness + callfar AIGetTypeEffectiveness pop de pop bc pop hl @@ -542,7 +542,7 @@ AIRecoverHP: AIPrintItemUseAndUpdateHPBar: call AIPrintItemUse_ - coord hl, 2, 2 + hlcoord 2, 2 xor a ld [wHPBarType], a predef UpdateHPBar2 @@ -599,7 +599,7 @@ SwitchEnemyMon: ; switching in a new mon in response to this switch. ld a, 1 ld [wFirstMonsNotOutYet], a - callab EnemySendOut + callfar EnemySendOut xor a ld [wFirstMonsNotOutYet], a @@ -655,17 +655,17 @@ AIUseDireHit: ; unused AICheckIfHPBelowFraction: ; 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 a, [hli] - ld [hDividend], a + ldh [hDividend], a ld a, [hl] - ld [hDividend + 1], a + ldh [hDividend + 1], a ld b, 2 call Divide - ld a, [hQuotient + 3] + ldh a, [hQuotient + 3] ld c, a - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] ld b, a ld hl, wEnemyMonHP + 1 ld a, [hld] @@ -713,7 +713,7 @@ AIIncreaseStat: ld a, ANIM_AF ld [hli], a ld [hl], b - callab StatModifierUpEffect + callfar StatModifierUpEffect pop hl pop af ld [hli], a diff --git a/engine/battle/unused_stats_functions.asm b/engine/battle/unused_stats_functions.asm index fb3422c7..5174adf5 100644 --- a/engine/battle/unused_stats_functions.asm +++ b/engine/battle/unused_stats_functions.asm @@ -1,6 +1,6 @@ ; does nothing since no stats are ever selected (barring glitches) DoubleSelectedStats: - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld a, [wPlayerStatsToDouble] ld hl, wBattleMonAttack + 1 @@ -30,7 +30,7 @@ DoubleSelectedStats: ; does nothing since no stats are ever selected (barring glitches) HalveSelectedStats: - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] and a ld a, [wPlayerStatsToHalve] ld hl, wBattleMonAttack diff --git a/engine/battle/wild_encounters.asm b/engine/battle/wild_encounters.asm index 9d6fcb8d..e24f9632 100644 --- a/engine/battle/wild_encounters.asm +++ b/engine/battle/wild_encounters.asm @@ -7,14 +7,14 @@ TryDoWildEncounter: ld a, [wd736] and a ret nz - callab IsPlayerStandingOnDoorTileOrWarpTile + callfar IsPlayerStandingOnDoorTileOrWarpTile jr nc, .notStandingOnDoorOrWarpTile .CantEncounter ld a, $1 and a ret .notStandingOnDoorOrWarpTile - callab IsPlayerJustOutsideMap + callfar IsPlayerJustOutsideMap jr z, .CantEncounter ld a, [wRepelRemainingSteps] and a @@ -25,7 +25,7 @@ TryDoWildEncounter: .next ; determine if wild pokemon can appear in the half-block we're standing in ; is the bottom right tile (9,9) of the half-block we're standing in a grass/water tile? - coord hl, 9, 9 + hlcoord 9, 9 ld c, [hl] ld a, [wGrassTile] cp c @@ -48,10 +48,10 @@ TryDoWildEncounter: .CanEncounter ; compare encounter chance with a random number to determine if there will be an encounter ld b, a - ld a, [hRandomAdd] + ldh a, [hRandomAdd] cp b jr nc, .CantEncounter2 - ld a, [hRandomSub] + ldh a, [hRandomSub] ld b, a ld hl, WildMonEncounterSlotChances .determineEncounterSlot @@ -64,7 +64,7 @@ TryDoWildEncounter: ; determine which wild pokemon (grass or water) can appear in the half-block we're standing in ld c, [hl] ld hl, wGrassMons - aCoord 8, 9 + lda_coord 8, 9 cp $14 ; is the bottom left tile (8,9) of the half-block we're standing in a water tile? jr nz, .gotWildEncounterType ; else, it's treated as a grass tile by default ld hl, wWaterMons @@ -90,7 +90,7 @@ TryDoWildEncounter: .lastRepelStep ld [wRepelRemainingSteps], a ld a, TEXT_REPEL_WORE_OFF - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call EnableAutoTextBoxDrawing call DisplayTextID .CantEncounter2 diff --git a/engine/debug/test_battle.asm b/engine/debug/test_battle.asm index 92d6e4a9..92f74576 100644 --- a/engine/debug/test_battle.asm +++ b/engine/debug/test_battle.asm @@ -41,5 +41,5 @@ TestBattle: ; do it all again. ld a, 1 ld [wUpdateSpritesEnabled], a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a jr .loop diff --git a/engine/events/black_out.asm b/engine/events/black_out.asm index 6c358ce3..16d2081f 100644 --- a/engine/events/black_out.asm +++ b/engine/events/black_out.asm @@ -6,34 +6,34 @@ ResetStatusAndHalveMoneyOnBlackout:: ld [wIsInBattle], a ld [wMapPalOffset], a ld [wNPCMovementScriptFunctionNum], a - ld [hJoyHeld], a + ldh [hJoyHeld], a ld [wNPCMovementScriptPointerTableNum], a ld [wFlags_0xcd60], a - ld [hMoney], a - ld [hMoney + 1], a - ld [hMoney + 2], a + ldh [hMoney], a + ldh [hMoney + 1], a + ldh [hMoney + 2], a call HasEnoughMoney jr c, .lostmoney ; never happens ; Halve the player's money. ld a, [wPlayerMoney] - ld [hMoney], a + ldh [hMoney], a ld a, [wPlayerMoney + 1] - ld [hMoney + 1], a + ldh [hMoney + 1], a ld a, [wPlayerMoney + 2] - ld [hMoney + 2], a + ldh [hMoney + 2], a xor a - ld [hDivideBCDDivisor], a - ld [hDivideBCDDivisor + 1], a + ldh [hDivideBCDDivisor], a + ldh [hDivideBCDDivisor + 1], a ld a, 2 - ld [hDivideBCDDivisor + 2], a + ldh [hDivideBCDDivisor + 2], a predef DivideBCDPredef3 - ld a, [hDivideBCDQuotient] + ldh a, [hDivideBCDQuotient] ld [wPlayerMoney], a - ld a, [hDivideBCDQuotient + 1] + ldh a, [hDivideBCDQuotient + 1] ld [wPlayerMoney + 1], a - ld a, [hDivideBCDQuotient + 2] + ldh a, [hDivideBCDQuotient + 2] ld [wPlayerMoney + 2], a .lostmoney diff --git a/engine/events/card_key.asm b/engine/events/card_key.asm index a37a1f27..7ac39a6f 100755 --- a/engine/events/card_key.asm +++ b/engine/events/card_key.asm @@ -28,7 +28,7 @@ PrintCardKeyText: call GetCoordsInFrontOfPlayer push de tx_pre_id CardKeySuccessText - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call PrintPredefTextID pop de srl d @@ -55,7 +55,7 @@ PrintCardKeyText: jp PlaySound .noCardKey tx_pre_id CardKeyFailText - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a jp PrintPredefTextID SilphCoMapList: diff --git a/engine/events/cinnabar_lab.asm b/engine/events/cinnabar_lab.asm index 7878780c..bccc95d1 100755 --- a/engine/events/cinnabar_lab.asm +++ b/engine/events/cinnabar_lab.asm @@ -20,7 +20,7 @@ GiveFossilToCinnabarLab:: dec l ld b, l ld c, $d - coord hl, 0, 0 + hlcoord 0, 0 call TextBoxBorder call UpdateSprites call PrintFossilsInBag @@ -35,7 +35,7 @@ GiveFossilToCinnabarLab:: ld e, a add hl, de ld a, [hl] - ld [hItemToRemoveID], a + ldh [hItemToRemoveID], a cp DOME_FOSSIL jr z, .choseDomeFossil cp HELIX_FOSSIL @@ -61,8 +61,8 @@ GiveFossilToCinnabarLab:: ld hl, LabFossil_610b3 call PrintText ld a, [wFossilItem] - ld [hItemToRemoveID], a - callba RemoveItemByID + ldh [hItemToRemoveID], a + farcall RemoveItemByID ld hl, LabFossil_610b8 call PrintText SetEvents EVENT_GAVE_FOSSIL_TO_LAB, EVENT_LAB_STILL_REVIVING_FOSSIL @@ -92,7 +92,7 @@ PrintFossilsInBag: ; Prints each fossil in the player's bag on a separate line in the menu. ld hl, wFilteredBagItems xor a - ld [hItemCounter], a + ldh [hItemCounter], a .loop ld a, [hli] cp $ff @@ -100,8 +100,8 @@ PrintFossilsInBag: push hl ld [wd11e], a call GetItemName - coord hl, 2, 2 - ld a, [hItemCounter] + hlcoord 2, 2 + ldh a, [hItemCounter] ld bc, SCREEN_WIDTH * 2 call AddNTimes ld de, wcd6d diff --git a/engine/events/diploma.asm b/engine/events/diploma.asm index 92196537..c282b49b 100755 --- a/engine/events/diploma.asm +++ b/engine/events/diploma.asm @@ -10,11 +10,11 @@ DisplayDiploma:: set 6, [hl] call DisableLCD ld hl, CircleTile - ld de, vChars2 + CIRCLE_TILE_ID * $10 + ld de, vChars2 tile CIRCLE_TILE_ID ld bc, $10 ld a, BANK(CircleTile) call FarCopyData2 - coord hl, 0, 0 + hlcoord 0, 0 lb bc, 16, 18 predef Diploma_TextBoxBorder ld hl, DiplomaTextPointersAndCoords @@ -35,10 +35,10 @@ DisplayDiploma:: pop bc dec c jr nz, .asm_56715 - coord hl, 10, 4 + hlcoord 10, 4 ld de, wPlayerName call PlaceString - callba DrawPlayerCharacter + farcall DrawPlayerCharacter ; Move the player 33 pixels right and set the priority bit so he appears ; behind the background layer. @@ -56,13 +56,13 @@ DisplayDiploma:: jr nz, .adjustPlayerGfxLoop call EnableLCD - callba LoadTrainerInfoTextBoxTiles + farcall LoadTrainerInfoTextBoxTiles ld b, SET_PAL_GENERIC call RunPaletteCommand call Delay3 call GBPalNormal ld a, $90 - ld [rOBP0], a + ldh [rOBP0], a call WaitForTextScrollButtonPress ld hl, wd730 res 6, [hl] @@ -85,15 +85,15 @@ UnusedPlayerNameLengthFunc: DiplomaTextPointersAndCoords: dw DiplomaText - dwCoord 5, 2 + dwcoord 5, 2 dw DiplomaPlayer - dwCoord 3, 4 + dwcoord 3, 4 dw DiplomaEmptyText - dwCoord 15, 4 + dwcoord 15, 4 dw DiplomaCongrats - dwCoord 2, 6 + dwcoord 2, 6 dw DiplomaGameFreak - dwCoord 9, 16 + dwcoord 9, 16 DiplomaText: db CIRCLE_TILE_ID, "Diploma", CIRCLE_TILE_ID, "@" diff --git a/engine/events/evolve_trade.asm b/engine/events/evolve_trade.asm index e17fc05c..56069fac 100755 --- a/engine/events/evolve_trade.asm +++ b/engine/events/evolve_trade.asm @@ -38,7 +38,7 @@ EvolveTradeMon: ld [wForceEvolution], a ld a, LINK_STATE_TRADING ld [wLinkState], a - callab TryEvolvingMon + callfar TryEvolvingMon xor a ; LINK_STATE_NONE ld [wLinkState], a jp PlayDefaultMusic diff --git a/engine/events/give_pokemon.asm b/engine/events/give_pokemon.asm index 041b9fb0..ef01ef99 100755 --- a/engine/events/give_pokemon.asm +++ b/engine/events/give_pokemon.asm @@ -15,9 +15,9 @@ _GivePokemon:: ld [wEnemyBattleStatus3], a ld a, [wcf91] ld [wEnemyMonSpecies2], a - callab LoadEnemyMonData + callfar LoadEnemyMonData call SetPokedexOwnedFlag - callab SendNewMonToBox + callfar SendNewMonToBox ld hl, wcf4b ld a, [wCurrentBoxNum] and $7f diff --git a/engine/events/hidden_items.asm b/engine/events/hidden_items.asm index 85ae7c93..6a5835cd 100755 --- a/engine/events/hidden_items.asm +++ b/engine/events/hidden_items.asm @@ -67,9 +67,9 @@ HiddenCoins: and a ret nz xor a - ld [hUnusedCoinsByte], a - ld [hCoins], a - ld [hCoins + 1], a + ldh [hUnusedCoinsByte], a + ldh [hCoins], a + ldh [hCoins + 1], a ld a, [wHiddenObjectFunctionArgument] sub COIN cp 10 @@ -81,19 +81,19 @@ HiddenCoins: jr .bcd100 .bcd10 ld a, $10 - ld [hCoins + 1], a + ldh [hCoins + 1], a jr .bcdDone .bcd20 ld a, $20 - ld [hCoins + 1], a + ldh [hCoins + 1], a jr .bcdDone .bcd40 ; due to a typo, this is never used ld a, $40 - ld [hCoins + 1], a + ldh [hCoins + 1], a jr .bcdDone .bcd100 ld a, $1 - ld [hCoins], a + ldh [hCoins], a .bcdDone ld de, wPlayerCoins + 1 ld hl, hCoins + 1 diff --git a/engine/events/hidden_objects/bills_house_pc.asm b/engine/events/hidden_objects/bills_house_pc.asm index 92679d66..a73596b4 100644 --- a/engine/events/hidden_objects/bills_house_pc.asm +++ b/engine/events/hidden_objects/bills_house_pc.asm @@ -84,11 +84,11 @@ BillsHousePokemonList:: .billsPokemonLoop ld hl, wd730 set 6, [hl] - coord hl, 0, 0 + hlcoord 0, 0 ld b, 10 ld c, 9 call TextBoxBorder - coord hl, 2, 2 + hlcoord 2, 2 ld de, BillsMonListText call PlaceString ld hl, BillsHousePokemonListText2 diff --git a/engine/events/hidden_objects/book_or_sculpture.asm b/engine/events/hidden_objects/book_or_sculpture.asm index 2f3334b8..e04f4047 100644 --- a/engine/events/hidden_objects/book_or_sculpture.asm +++ b/engine/events/hidden_objects/book_or_sculpture.asm @@ -4,7 +4,7 @@ BookOrSculptureText:: ld a, [wCurMapTileset] cp MANSION ; Celadon Mansion tileset jr nz, .ok - aCoord 8, 6 + lda_coord 8, 6 cp $38 jr nz, .ok ld hl, DiglettSculptureText diff --git a/engine/events/hidden_objects/bookshelves.asm b/engine/events/hidden_objects/bookshelves.asm index 9cdd037a..b58444af 100644 --- a/engine/events/hidden_objects/bookshelves.asm +++ b/engine/events/hidden_objects/bookshelves.asm @@ -6,7 +6,7 @@ PrintBookshelfText:: ; facing up ld a, [wCurMapTileset] ld b, a - aCoord 8, 7 + lda_coord 8, 7 ld c, a ld hl, BookshelfTileIDs .loop @@ -24,7 +24,7 @@ PrintBookshelfText:: pop af call PrintPredefTextID xor a - ld [hFFDB], a + ldh [hFFDB], a ret .nextBookshelfEntry1 inc hl @@ -33,7 +33,7 @@ PrintBookshelfText:: jr .loop .noMatch ld a, $ff - ld [hFFDB], a - jpba PrintCardKeyText + ldh [hFFDB], a + farjp PrintCardKeyText INCLUDE "data/tilesets/bookshelf_tile_ids.asm" diff --git a/engine/events/hidden_objects/cinnabar_gym_quiz.asm b/engine/events/hidden_objects/cinnabar_gym_quiz.asm index da309f87..2e4f48f3 100644 --- a/engine/events/hidden_objects/cinnabar_gym_quiz.asm +++ b/engine/events/hidden_objects/cinnabar_gym_quiz.asm @@ -12,14 +12,14 @@ CinnabarGymQuiz:: ld a, [wHiddenObjectFunctionArgument] push af and $f - ld [hGymGateIndex], a + ldh [hGymGateIndex], a pop af and $f0 swap a - ld [hGymGateAnswer], a + ldh [hGymGateAnswer], a ld hl, CinnabarGymQuizIntroText call PrintText - ld a, [hGymGateIndex] + ldh a, [hGymGateIndex] dec a add a ld d, 0 @@ -77,18 +77,18 @@ CinnabarGymGateFlagAction: CinnabarGymQuiz_1ea92: call YesNoChoice - ld a, [hGymGateAnswer] + ldh a, [hGymGateAnswer] ld c, a ld a, [wCurrentMenuItem] cp c jr nz, .wrongAnswer ld hl, wCurrentMapScriptFlags set 5, [hl] - ld a, [hGymGateIndex] - ld [hBackupGymGateIndex], a + ldh a, [hGymGateIndex] + ldh [hBackupGymGateIndex], a ld hl, CinnabarGymQuizCorrectText call PrintText - ld a, [hBackupGymGateIndex] + ldh a, [hBackupGymGateIndex] AdjustEventBit EVENT_CINNABAR_GYM_GATE0_UNLOCKED, 0 ld c, a ld b, FLAG_SET @@ -101,7 +101,7 @@ CinnabarGymQuiz_1ea92: call WaitForSoundToFinish ld hl, CinnabarGymQuizIncorrectText call PrintText - ld a, [hGymGateIndex] + ldh a, [hGymGateIndex] add $2 AdjustEventBit EVENT_BEAT_CINNABAR_GYM_TRAINER_0, 2 ld c, a @@ -111,7 +111,7 @@ CinnabarGymQuiz_1ea92: ld a, c and a ret nz - ld a, [hGymGateIndex] + ldh a, [hGymGateIndex] add $2 ld [wOpponentAfterWrongAnswer], a ret @@ -122,7 +122,7 @@ CinnabarGymQuizCorrectText: text_promptbutton text_asm - ld a, [hBackupGymGateIndex] + ldh a, [hBackupGymGateIndex] AdjustEventBit EVENT_CINNABAR_GYM_GATE0_UNLOCKED, 0 ld c, a ld b, FLAG_TEST @@ -144,9 +144,9 @@ UpdateCinnabarGymGateTileBlocks_:: ; Update the overworld map with open floor blocks or locked gate blocks ; depending on event flags. ld a, 6 - ld [hGymGateIndex], a + ldh [hGymGateIndex], a .loop - ld a, [hGymGateIndex] + ldh a, [hGymGateIndex] dec a add a add a @@ -161,8 +161,8 @@ UpdateCinnabarGymGateTileBlocks_:: ld a, [hl] ld [wGymGateTileBlock], a push bc - ld a, [hGymGateIndex] - ld [hBackupGymGateIndex], a + ldh a, [hGymGateIndex] + ldh [hBackupGymGateIndex], a AdjustEventBit EVENT_CINNABAR_GYM_GATE0_UNLOCKED, 0 ld c, a ld b, FLAG_TEST diff --git a/engine/events/hidden_objects/gym_statues.asm b/engine/events/hidden_objects/gym_statues.asm index 1f592f2f..97b01a3a 100644 --- a/engine/events/hidden_objects/gym_statues.asm +++ b/engine/events/hidden_objects/gym_statues.asm @@ -1,6 +1,6 @@ GymStatues: ; if in a gym and have the corresponding badge, a = GymStatueText2_id and jp PrintPredefTextID -; if in a gym and don’t have the corresponding badge, a = GymStatueText1_id and jp PrintPredefTextID +; if in a gym and don't have the corresponding badge, a = GymStatueText1_id and jp PrintPredefTextID ; else ret call EnableAutoTextBoxDrawing ld a, [wSpritePlayerStateData1FacingDirection] diff --git a/engine/events/hidden_objects/museum_fossils.asm b/engine/events/hidden_objects/museum_fossils.asm index 36fb2556..27714981 100644 --- a/engine/events/hidden_objects/museum_fossils.asm +++ b/engine/events/hidden_objects/museum_fossils.asm @@ -26,10 +26,10 @@ DisplayMonFrontSpriteInBox: ; Displays a pokemon's front sprite in a pop-up window. ; [wcf91] = pokemon internal id number ld a, 1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a call Delay3 xor a - ld [hWY], a + ldh [hWY], a call SaveScreenTilesToBuffer1 ld a, MON_SPRITE_POPUP ld [wTextBoxID], a @@ -38,15 +38,15 @@ DisplayMonFrontSpriteInBox: ld a, [wcf91] ld [wd0b5], a call GetMonHeader - ld de, vChars1 + $310 + ld de, vChars1 tile $31 call LoadMonFrontSprite ld a, $80 - ld [hStartTileID], a - coord hl, 10, 11 + ldh [hStartTileID], a + hlcoord 10, 11 predef AnimateSendingOutMon call WaitForTextScrollButtonPress call LoadScreenTilesFromBuffer1 call Delay3 ld a, $90 - ld [hWY], a + ldh [hWY], a ret diff --git a/engine/events/hidden_objects/safari_game.asm b/engine/events/hidden_objects/safari_game.asm index 656e872a..5996fc6f 100644 --- a/engine/events/hidden_objects/safari_game.asm +++ b/engine/events/hidden_objects/safari_game.asm @@ -37,12 +37,12 @@ SafariZoneGameOver: cp SFX_SAFARI_ZONE_PA jr nz, .waitForMusicToPlay ld a, TEXT_SAFARI_GAME_OVER - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID xor a ld [wPlayerMovingDirection], a ld a, SAFARI_ZONE_GATE - ld [hWarpDestinationMap], a + ldh [hWarpDestinationMap], a ld a, $3 ld [wDestinationWarpID], a ld a, $5 diff --git a/engine/events/hidden_objects/school_blackboard.asm b/engine/events/hidden_objects/school_blackboard.asm index 48b97d73..de4700d4 100644 --- a/engine/events/hidden_objects/school_blackboard.asm +++ b/engine/events/hidden_objects/school_blackboard.asm @@ -26,11 +26,11 @@ LinkCableHelp:: .linkHelpLoop ld hl, wd730 set 6, [hl] - coord hl, 0, 0 + hlcoord 0, 0 ld b, 8 ld c, 13 call TextBoxBorder - coord hl, 2, 2 + hlcoord 2, 2 ld de, HowToLinkText call PlaceString ld hl, LinkCableHelpText2 @@ -110,13 +110,13 @@ ViridianSchoolBlackboard:: .blackboardLoop ld hl, wd730 set 6, [hl] - coord hl, 0, 0 + hlcoord 0, 0 lb bc, 6, 10 call TextBoxBorder - coord hl, 1, 2 + hlcoord 1, 2 ld de, StatusAilmentText1 call PlaceString - coord hl, 6, 2 + hlcoord 6, 2 ld de, StatusAilmentText2 call PlaceString ld hl, ViridianSchoolBlackboardText2 diff --git a/engine/events/hidden_objects/town_map.asm b/engine/events/hidden_objects/town_map.asm index 9481b902..4284214f 100644 --- a/engine/events/hidden_objects/town_map.asm +++ b/engine/events/hidden_objects/town_map.asm @@ -8,15 +8,15 @@ TownMapText:: set 6, [hl] call GBPalWhiteOutWithDelay3 xor a - ld [hWY], a + ldh [hWY], a inc a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a call LoadFontTilePatterns - callba DisplayTownMap + farcall DisplayTownMap ld hl, wd730 res 6, [hl] ld de, TextScriptEnd push de - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] push af jp CloseTextDisplay diff --git a/engine/events/hidden_objects/vermilion_gym_trash.asm b/engine/events/hidden_objects/vermilion_gym_trash.asm index f46b53c2..c2bfed06 100644 --- a/engine/events/hidden_objects/vermilion_gym_trash.asm +++ b/engine/events/hidden_objects/vermilion_gym_trash.asm @@ -56,12 +56,12 @@ GymTrashScript: ; 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. - ld [hGymTrashCanRandNumMask], a + ldh [hGymTrashCanRandNumMask], a push hl call Random swap a ld b, a - ld a, [hGymTrashCanRandNumMask] + ldh a, [hGymTrashCanRandNumMask] and b dec a pop hl diff --git a/engine/events/in_game_trades.asm b/engine/events/in_game_trades.asm index a25abe0b..8a29d6a4 100755 --- a/engine/events/in_game_trades.asm +++ b/engine/events/in_game_trades.asm @@ -137,10 +137,10 @@ InGameTrade_DoTrade: ld [wMonDataLocation], a call AddPartyMon call InGameTrade_CopyDataToReceivedMon - callab EvolveTradeMon + callfar EvolveTradeMon call ClearScreen call InGameTrade_RestoreScreen - callba RedrawMapView + farcall RedrawMapView and a ld a, $3 jr .tradeSucceeded @@ -159,7 +159,7 @@ InGameTrade_RestoreScreen: call LoadGBPal ld c, 10 call DelayFrames - jpba LoadWildData + farjp LoadWildData InGameTrade_PrepareTradeData: ld hl, wTradedPlayerMonSpecies diff --git a/engine/events/oaks_aide.asm b/engine/events/oaks_aide.asm index 61304877..dd4e5fd7 100755 --- a/engine/events/oaks_aide.asm +++ b/engine/events/oaks_aide.asm @@ -9,16 +9,16 @@ OaksAideScript: ld b, wPokedexOwnedEnd - wPokedexOwned call CountSetBits ld a, [wNumSetBits] - ld [hOaksAideNumMonsOwned], a + ldh [hOaksAideNumMonsOwned], a ld b, a - ld a, [hOaksAideRequirement] + ldh a, [hOaksAideRequirement] cp b jr z, .giveItem jr nc, .notEnoughOwnedMons .giveItem ld hl, OaksAideHereYouGoText call PrintText - ld a, [hOaksAideRewardItem] + ldh a, [hOaksAideRewardItem] ld b, a ld c, 1 call GiveItem @@ -42,7 +42,7 @@ OaksAideScript: call PrintText ld a, $ff .done - ld [hOaksAideResult], a + ldh [hOaksAideResult], a ret OaksAideHiText: diff --git a/engine/events/pick_up_item.asm b/engine/events/pick_up_item.asm index ec50d9c4..548db5be 100644 --- a/engine/events/pick_up_item.asm +++ b/engine/events/pick_up_item.asm @@ -1,7 +1,7 @@ PickUpItem: call EnableAutoTextBoxDrawing - ld a, [hSpriteIndexOrTextID] + ldh a, [hSpriteIndexOrTextID] ld b, a ld hl, wMissableObjectList .missableObjectsListLoop @@ -15,10 +15,10 @@ PickUpItem: .isMissable ld a, [hl] - ld [hMissableObjectIndex], a + ldh [hMissableObjectIndex], a ld hl, wMapSpriteExtraData - ld a, [hSpriteIndexOrTextID] + ldh a, [hSpriteIndexOrTextID] dec a add a ld d, 0 @@ -30,7 +30,7 @@ PickUpItem: call GiveItem jr nc, .BagFull - ld a, [hMissableObjectIndex] + ldh a, [hMissableObjectIndex] ld [wMissableObjectIndex], a predef HideObject ld a, 1 diff --git a/engine/events/poison.asm b/engine/events/poison.asm index 5d8eb9fd..8bb756b5 100644 --- a/engine/events/poison.asm +++ b/engine/events/poison.asm @@ -52,7 +52,7 @@ ApplyOutOfBattlePoisonDamage: ld [wJoyIgnore], a call EnableAutoTextBoxDrawing ld a, TEXT_MON_FAINTED - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID pop de pop hl @@ -99,7 +99,7 @@ ApplyOutOfBattlePoisonDamage: jr nz, .noBlackOut call EnableAutoTextBoxDrawing ld a, TEXT_BLACKED_OUT - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID ld hl, wd72e set 5, [hl] diff --git a/engine/events/pokecenter.asm b/engine/events/pokecenter.asm index 030c333f..97dbcd53 100755 --- a/engine/events/pokecenter.asm +++ b/engine/events/pokecenter.asm @@ -22,7 +22,7 @@ DisplayPokemonCenterDialogue_:: ld [wSprite01StateData1ImageIndex], a ; make the nurse turn to face the machine call Delay3 predef HealParty - callba AnimateHealingMachine ; do the healing machine animation + farcall AnimateHealingMachine ; do the healing machine animation xor a ld [wAudioFadeOutControl], a ld a, [wAudioSavedROMBank] diff --git a/engine/events/pokedex_rating.asm b/engine/events/pokedex_rating.asm index 9dbe2138..490ae05a 100755 --- a/engine/events/pokedex_rating.asm +++ b/engine/events/pokedex_rating.asm @@ -3,17 +3,17 @@ DisplayDexRating: ld b, wPokedexSeenEnd - wPokedexSeen call CountSetBits ld a, [wNumSetBits] - ld [hDexRatingNumMonsSeen], a + ldh [hDexRatingNumMonsSeen], a ld hl, wPokedexOwned ld b, wPokedexOwnedEnd - wPokedexOwned call CountSetBits ld a, [wNumSetBits] - ld [hDexRatingNumMonsOwned], a + ldh [hDexRatingNumMonsOwned], a ld hl, DexRatingsTable .findRating ld a, [hli] ld b, a - ld a, [hDexRatingNumMonsOwned] + ldh a, [hDexRatingNumMonsOwned] cp b jr c, .foundRating inc hl @@ -30,14 +30,14 @@ DisplayDexRating: call PrintText pop hl call PrintText - callba PlayPokedexRatingSfx + farcall PlayPokedexRatingSfx jp WaitForTextScrollButtonPress .hallOfFame ld de, wDexRatingNumMonsSeen - ld a, [hDexRatingNumMonsSeen] + ldh a, [hDexRatingNumMonsSeen] ld [de], a inc de - ld a, [hDexRatingNumMonsOwned] + ldh a, [hDexRatingNumMonsOwned] ld [de], a inc de .copyRatingTextLoop diff --git a/engine/events/pokemart.asm b/engine/events/pokemart.asm index b05e4ed6..c7cb8115 100755 --- a/engine/events/pokemart.asm +++ b/engine/events/pokemart.asm @@ -42,7 +42,7 @@ DisplayPokemartDialogue_:: ld [wPrintItemPrices], a ld a, INIT_BAG_ITEM_LIST ld [wInitListType], a - callab InitList + callfar InitList ld a, [wNumBagItems] and a @@ -77,14 +77,14 @@ DisplayPokemartDialogue_:: jr c, .unsellableItem ld a, PRICEDITEMLISTMENU ld [wListMenuID], a - ld [hHalveItemPrices], a ; halve prices when selling + ldh [hHalveItemPrices], a ; halve prices when selling call DisplayChooseQuantityMenu inc a jr z, .sellMenuLoop ; if the player closed the choose quantity menu with the B button ld hl, PokemartTellSellPriceText lb bc, 14, 1 ; location that PrintText always prints to, this is useless call PrintText - coord hl, 14, 7 + hlcoord 14, 7 lb bc, 8, 15 ld a, TWO_OPTION_MENU ld [wTextBoxID], a @@ -126,7 +126,7 @@ DisplayPokemartDialogue_:: ld [wPrintItemPrices], a ld a, INIT_OTHER_ITEM_LIST ld [wInitListType], a - callab InitList + callfar InitList ld hl, PokemartBuyingGreetingText call PrintText @@ -152,7 +152,7 @@ DisplayPokemartDialogue_:: ld a, 99 ld [wMaxItemQuantity], 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 inc a jr z, .buyMenuLoop ; if the player closed the choose quantity menu with the B button @@ -162,7 +162,7 @@ DisplayPokemartDialogue_:: call CopyStringToCF4B ; copy name to wcf4b ld hl, PokemartTellBuyPriceText call PrintText - coord hl, 14, 7 + hlcoord 14, 7 lb bc, 8, 15 ld a, TWO_OPTION_MENU ld [wTextBoxID], a diff --git a/engine/events/prize_menu.asm b/engine/events/prize_menu.asm index 0030aafb..d9320fe7 100755 --- a/engine/events/prize_menu.asm +++ b/engine/events/prize_menu.asm @@ -22,7 +22,7 @@ CeladonPrizeMenu:: ld a, $01 ld [wTopMenuItemX], a call PrintPrizePrice - coord hl, 0, 2 + hlcoord 0, 2 ld b, 8 ld c, 16 call TextBoxBorder @@ -64,7 +64,7 @@ GetPrizeMenuId: ; display the three prizes' names ; (distinguishing between Pokemon names ; and Items (specifically TMs) names) - ld a, [hSpriteIndexOrTextID] + ldh a, [hSpriteIndexOrTextID] sub 3 ; prize-texts' id are 3, 4 and 5 ld [wWhichPrizeWindow], a ; prize-texts' id (relative, i.e. 0, 1 or 2) add a @@ -93,71 +93,71 @@ GetPrizeMenuId: ld a, [wPrize1] ld [wd11e], a call GetItemName - coord hl, 2, 4 + hlcoord 2, 4 call PlaceString ld a, [wPrize2] ld [wd11e], a call GetItemName - coord hl, 2, 6 + hlcoord 2, 6 call PlaceString ld a, [wPrize3] ld [wd11e], a call GetItemName - coord hl, 2, 8 + hlcoord 2, 8 call PlaceString jr .putNoThanksText .putMonName ld a, [wPrize1] ld [wd11e], a call GetMonName - coord hl, 2, 4 + hlcoord 2, 4 call PlaceString ld a, [wPrize2] ld [wd11e], a call GetMonName - coord hl, 2, 6 + hlcoord 2, 6 call PlaceString ld a, [wPrize3] ld [wd11e], a call GetMonName - coord hl, 2, 8 + hlcoord 2, 8 call PlaceString .putNoThanksText - coord hl, 2, 10 + hlcoord 2, 10 ld de, NoThanksText call PlaceString ; put prices on the right side of the textbox ld de, wPrize1Price - coord hl, 13, 5 + hlcoord 13, 5 ; reg. c: ; [low nybble] number of bytes ; [bits 765 = %100] space-padding (not zero-padding) ld c, (1 << 7 | 2) call PrintBCDNumber ld de, wPrize2Price - coord hl, 13, 7 + hlcoord 13, 7 ld c, (1 << 7 | 2) call PrintBCDNumber ld de, wPrize3Price - coord hl, 13, 9 + hlcoord 13, 9 ld c, (1 << 7 | 2) jp PrintBCDNumber INCLUDE "data/events/prizes.asm" PrintPrizePrice: - coord hl, 11, 0 + hlcoord 11, 0 ld b, 1 ld c, 7 call TextBoxBorder call UpdateSprites - coord hl, 12, 0 + hlcoord 12, 0 ld de, .CoinString call PlaceString - coord hl, 13, 1 + hlcoord 13, 1 ld de, .SixSpacesString call PlaceString - coord hl, 13, 1 + hlcoord 13, 1 ld de, wPlayerCoins ld c, %10000010 call PrintBCDNumber @@ -177,11 +177,11 @@ LoadCoinsToSubtract: ld hl, wPrize1Price add hl, de ; get selected prize's price xor a - ld [hUnusedCoinsByte], a + ldh [hUnusedCoinsByte], a ld a, [hli] - ld [hCoins], a + ldh [hCoins], a ld a, [hl] - ld [hCoins + 1], a + ldh [hCoins + 1], a ret HandlePrizeChoice: diff --git a/engine/events/saffron_guards.asm b/engine/events/saffron_guards.asm index 59c2725c..bf30b8c5 100755 --- a/engine/events/saffron_guards.asm +++ b/engine/events/saffron_guards.asm @@ -2,7 +2,7 @@ RemoveGuardDrink:: ld hl, GuardDrinksList .drinkLoop ld a, [hli] - ld [hItemToRemoveID], a + ldh [hItemToRemoveID], a and a ret z push hl @@ -10,6 +10,6 @@ RemoveGuardDrink:: call IsItemInBag pop hl jr z, .drinkLoop - jpba RemoveItemByID + farjp RemoveItemByID INCLUDE "data/items/guard_drink_items.asm" diff --git a/engine/events/starter_dex.asm b/engine/events/starter_dex.asm index 21289c6a..7cfe9af2 100755 --- a/engine/events/starter_dex.asm +++ b/engine/events/starter_dex.asm @@ -1,9 +1,9 @@ ; this function temporarily makes the starters (and Ivysaur) seen ; so that the full Pokedex information gets displayed in Oak's lab StarterDex: - ld a, %01001011 ; set starter flags + ld a, 1 << (DEX_BULBASAUR - 1) | 1 << (DEX_IVYSAUR - 1) | 1 << (DEX_CHARMANDER - 1) | 1 << (DEX_SQUIRTLE - 1) ld [wPokedexOwned], a predef ShowPokedexData - xor a ; unset starter flags + xor a ld [wPokedexOwned], a ret diff --git a/engine/events/vending_machine.asm b/engine/events/vending_machine.asm index acb8dce8..a67f1c07 100755 --- a/engine/events/vending_machine.asm +++ b/engine/events/vending_machine.asm @@ -17,15 +17,15 @@ VendingMachineMenu:: ld [wTopMenuItemX], a ld hl, wd730 set 6, [hl] - coord hl, 0, 3 + hlcoord 0, 3 ld b, 8 ld c, 12 call TextBoxBorder call UpdateSprites - coord hl, 2, 5 + hlcoord 2, 5 ld de, DrinkText call PlaceString - coord hl, 9, 6 + hlcoord 9, 6 ld de, DrinkPriceText call PlaceString ld hl, wd730 @@ -37,17 +37,17 @@ VendingMachineMenu:: cp 3 ; chose Cancel? jr z, .notThirsty xor a - ld [hMoney], a - ld [hMoney + 2], a + ldh [hMoney], a + ldh [hMoney + 2], a ld a, $2 - ld [hMoney + 1], a + ldh [hMoney + 1], a call HasEnoughMoney jr nc, .enoughMoney ld hl, VendingMachineText4 jp PrintText .enoughMoney call LoadVendingMachineItem - ld a, [hVendingMachineItem] + ldh a, [hVendingMachineItem] ld b, a ld c, 1 call GiveItem @@ -121,13 +121,13 @@ LoadVendingMachineItem: ld e, a add hl, de ld a, [hli] - ld [hVendingMachineItem], a + ldh [hVendingMachineItem], a ld a, [hli] - ld [hVendingMachinePrice], a + ldh [hVendingMachinePrice], a ld a, [hli] - ld [hVendingMachinePrice + 1], a + ldh [hVendingMachinePrice + 1], a ld a, [hl] - ld [hVendingMachinePrice + 2], a + ldh [hVendingMachinePrice + 2], a ret INCLUDE "data/items/vending_prices.asm" diff --git a/engine/gfx/hp_bar.asm b/engine/gfx/hp_bar.asm index 4b91da58..b7bd97f2 100755 --- a/engine/gfx/hp_bar.asm +++ b/engine/gfx/hp_bar.asm @@ -21,22 +21,22 @@ GetHPBarLength: rr e srl d rr e - ld a, [hMultiplicand+1] + ldh a, [hMultiplicand+1] ld b, a - ld a, [hMultiplicand+2] + ldh a, [hMultiplicand+2] srl b ; divide multiplication result as well rr a srl b rr a - ld [hMultiplicand+2], a + ldh [hMultiplicand+2], a ld a, b - ld [hMultiplicand+1], a + ldh [hMultiplicand+1], a .maxHPSmaller256 ld a, e - ld [hDivisor], a + ldh [hDivisor], a ld b, $4 call Divide - ld a, [hMultiplicand+2] + ldh a, [hMultiplicand+2] ld e, a ; e = bc * 48 / de (num of pixels of HP bar) pop hl and a @@ -213,7 +213,7 @@ UpdateHPBar_PrintHPNumber: ld a, [wHPBarOldHP + 1] ld [wHPBarTempHP], a push hl - ld a, [hFlagsFFF6] + ldh a, [hFlagsFFF6] bit 0, a jr z, .asm_fb15 ld de, $9 diff --git a/engine/gfx/load_pokedex_tiles.asm b/engine/gfx/load_pokedex_tiles.asm index 70bcf04d..a3f69171 100755 --- a/engine/gfx/load_pokedex_tiles.asm +++ b/engine/gfx/load_pokedex_tiles.asm @@ -2,10 +2,10 @@ LoadPokedexTilePatterns: call LoadHpBarAndStatusTilePatterns ld de, PokedexTileGraphics - ld hl, vChars2 + $600 + ld hl, vChars2 tile $60 lb bc, BANK(PokedexTileGraphics), (PokedexTileGraphicsEnd - PokedexTileGraphics) / $10 call CopyVideoData ld de, PokeballTileGraphics - ld hl, vChars2 + $720 - lb bc, BANK(PokeballTileGraphics), $01 + ld hl, vChars2 tile $72 + lb bc, BANK(PokeballTileGraphics), 1 jp CopyVideoData ; load pokeball tile for marking caught mons diff --git a/engine/gfx/mon_icons.asm b/engine/gfx/mon_icons.asm index 7a96b36c..8dd6fe75 100755 --- a/engine/gfx/mon_icons.asm +++ b/engine/gfx/mon_icons.asm @@ -169,7 +169,7 @@ WriteMonPartySpriteOAMByPartyIndex: push hl push de push bc - ld a, [hPartyMonIndex] + ldh a, [hPartyMonIndex] ld hl, wPartySpecies ld e, a ld d, 0 @@ -187,7 +187,7 @@ WriteMonPartySpriteOAMBySpecies: ; Write OAM blocks for the party sprite of the species in ; [wMonPartySpriteSpecies]. xor a - ld [hPartyMonIndex], a + ldh [hPartyMonIndex], a ld a, [wMonPartySpriteSpecies] call GetPartyMonSpriteID ld [wOAMBaseTile], a @@ -201,11 +201,11 @@ UnusedPartyMonSpriteFunction: ld a, [wcf91] call GetPartyMonSpriteID push af - ld hl, vSprites + ld hl, vSprites tile $00 call .LoadTilePatterns pop af add $54 - ld hl, vSprites + $40 + ld hl, vSprites tile $04 call .LoadTilePatterns xor a ld [wMonPartySpriteSpecies], a @@ -236,8 +236,8 @@ WriteMonPartySpriteOAM: ; make a copy at wMonPartySpritesSavedOAM. push af ld c, $10 - ld h, wOAMBuffer / $100 - ld a, [hPartyMonIndex] + ld h, HIGH(wOAMBuffer) + ldh a, [hPartyMonIndex] swap a ld l, a add $10 diff --git a/engine/gfx/oam_dma.asm b/engine/gfx/oam_dma.asm index aeea4c01..84bb4b5c 100644 --- a/engine/gfx/oam_dma.asm +++ b/engine/gfx/oam_dma.asm @@ -1,7 +1,7 @@ WriteDMACodeToHRAM:: ; Since no other memory is available during OAM DMA, ; DMARoutine is copied to HRAM and executed there. - ld c, hDMARoutine % $100 + ld c, LOW(hDMARoutine) ld b, DMARoutineEnd - DMARoutine ld hl, DMARoutine .copy @@ -14,8 +14,8 @@ WriteDMACodeToHRAM:: DMARoutine: ; initiate DMA - ld a, wOAMBuffer / $100 - ld [rDMA], a + ld a, HIGH(wOAMBuffer) + ldh [rDMA], a ; wait for DMA to finish ld a, $28 diff --git a/engine/gfx/palettes.asm b/engine/gfx/palettes.asm index 58e08e86..23203374 100755 --- a/engine/gfx/palettes.asm +++ b/engine/gfx/palettes.asm @@ -335,13 +335,13 @@ SendSGBPacket: push bc ; disable ReadJoypad to prevent it from interfering with sending the packet ld a, 1 - ld [hDisableJoypadPolling], a + ldh [hDisableJoypadPolling], a ; send RESET signal (P14=LOW, P15=LOW) xor a - ld [rJOYP], a + ldh [rJOYP], a ; set P14=HIGH, P15=HIGH ld a, $30 - ld [rJOYP], a + ldh [rJOYP], a ;load length of packets (16 bytes) ld b, $10 .nextByte @@ -358,10 +358,10 @@ SendSGBPacket: ; else (if 0th bit is zero) set P14=LOW,P15=HIGH (send bit 0) ld a, $20 .next0 - ld [rJOYP], a + ldh [rJOYP], a ; must set P14=HIGH,P15=HIGH between each "pulse" ld a, $30 - ld [rJOYP], a + ldh [rJOYP], a ; 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) rr d @@ -372,12 +372,12 @@ SendSGBPacket: jr nz, .nextByte ; send bit 1 as a "stop bit" (end of parameter data) ld a, $20 - ld [rJOYP], a + ldh [rJOYP], a ; set P14=HIGH,P15=HIGH ld a, $30 - ld [rJOYP], a + ldh [rJOYP], a xor a - ld [hDisableJoypadPolling], a + ldh [hDisableJoypadPolling], a ; wait for about 70000 cycles call Wait7000 ; restore (previously pushed) number of packets @@ -457,41 +457,41 @@ CheckSGB: di call SendSGBPacket ld a, 1 - ld [hDisableJoypadPolling], a + ldh [hDisableJoypadPolling], a ei call Wait7000 - ld a, [rJOYP] + ldh a, [rJOYP] and $3 cp $3 jr nz, .isSGB ld a, $20 - ld [rJOYP], a - ld a, [rJOYP] - ld a, [rJOYP] + ldh [rJOYP], a + ldh a, [rJOYP] + ldh a, [rJOYP] call Wait7000 call Wait7000 ld a, $30 - ld [rJOYP], a + ldh [rJOYP], a call Wait7000 call Wait7000 ld a, $10 - ld [rJOYP], a - ld a, [rJOYP] - ld a, [rJOYP] - ld a, [rJOYP] - ld a, [rJOYP] - ld a, [rJOYP] - ld a, [rJOYP] + ldh [rJOYP], a + ldh a, [rJOYP] + ldh a, [rJOYP] + ldh a, [rJOYP] + ldh a, [rJOYP] + ldh a, [rJOYP] + ldh a, [rJOYP] call Wait7000 call Wait7000 ld a, $30 - ld [rJOYP], a - ld a, [rJOYP] - ld a, [rJOYP] - ld a, [rJOYP] + ldh [rJOYP], a + ldh a, [rJOYP] + ldh a, [rJOYP] + ldh a, [rJOYP] call Wait7000 call Wait7000 - ld a, [rJOYP] + ldh a, [rJOYP] and $3 cp $3 jr nz, .isSGB @@ -513,7 +513,7 @@ CopyGfxToSuperNintendoVRAM: push de call DisableLCD ld a, $e4 - ld [rBGP], a + ldh [rBGP], a ld de, vChars1 ld a, [wCopyingSGBTileData] and a @@ -539,11 +539,11 @@ CopyGfxToSuperNintendoVRAM: dec c jr nz, .loop ld a, $e3 - ld [rLCDC], a + ldh [rLCDC], a pop hl call SendSGBPacket xor a - ld [rBGP], a + ldh [rBGP], a ei ret @@ -577,7 +577,7 @@ SendSGBPackets: InitGBCPalettes: ld a, $80 ; index 0 with auto-increment - ld [rBGPI], a + ldh [rBGPI], a inc hl ld c, $20 .loop @@ -592,7 +592,7 @@ InitGBCPalettes: inc d .noCarry ld a, [de] - ld [rBGPD], a + ldh [rBGPD], a dec c jr nz, .loop ret diff --git a/engine/gfx/screen_effects.asm b/engine/gfx/screen_effects.asm index 0d3806c1..e8648901 100755 --- a/engine/gfx/screen_effects.asm +++ b/engine/gfx/screen_effects.asm @@ -1,14 +1,14 @@ ; b = new colour for BG colour 0 (usually white) for 4 frames ChangeBGPalColor0_4Frames: call GetPredefRegisters - ld a, [rBGP] + ldh a, [rBGP] or b - ld [rBGP], a + ldh [rBGP], a ld c, 4 call DelayFrames - ld a, [rBGP] + ldh a, [rBGP] and %11111100 - ld [rBGP], a + ldh [rBGP], a ret PredefShakeScreenVertically: @@ -19,7 +19,7 @@ PredefShakeScreenVertically: ld [wDisableVBlankWYUpdate], a xor a .loop - ld [hMutateWY], a + ldh [hMutateWY], a call .MutateWY call .MutateWY dec b @@ -30,10 +30,10 @@ PredefShakeScreenVertically: ret .MutateWY - ld a, [hMutateWY] + ldh a, [hMutateWY] xor b - ld [hMutateWY], a - ld [rWY], a + ldh [hMutateWY], a + ldh [rWY], a ld c, 3 jp DelayFrames @@ -43,7 +43,7 @@ PredefShakeScreenHorizontally: call GetPredefRegisters xor a .loop - ld [hMutateWX], a + ldh [hMutateWX], a call .MutateWX ld c, 1 call DelayFrames @@ -54,18 +54,18 @@ PredefShakeScreenHorizontally: ; restore normal WX ld a, 7 - ld [rWX], a + ldh [rWX], a ret .MutateWX - ld a, [hMutateWX] + ldh a, [hMutateWX] xor b - ld [hMutateWX], a + ldh [hMutateWX], a bit 7, a jr z, .skipZeroing xor a ; zero a if it's negative .skipZeroing add 7 - ld [rWX], a + ldh [rWX], a ld c, 4 jp DelayFrames diff --git a/engine/gfx/sprite_oam.asm b/engine/gfx/sprite_oam.asm index 68128413..b3c07ecd 100644 --- a/engine/gfx/sprite_oam.asm +++ b/engine/gfx/sprite_oam.asm @@ -13,21 +13,21 @@ PrepareOAMData:: .updateEnabled xor a - ld [hOAMBufferOffset], a + ldh [hOAMBufferOffset], a .spriteLoop - ld [hSpriteOffset2], a + ldh [hSpriteOffset2], a - ld d, wSpriteStateData1 / $100 - ld a, [hSpriteOffset2] + ld d, HIGH(wSpriteStateData1) + ldh a, [hSpriteOffset2] ld e, a - ld a, [de] ; c1x0 + ld a, [de] ; [x#SPRITESTATEDATA1_PICTUREID] and a jp z, .nextSprite inc e inc e - ld a, [de] ; c1x2 (facing/anim) + ld a, [de] ; [x#SPRITESTATEDATA1_IMAGEINDEX] ld [wd5cd], a cp $ff ; off-screen (don't draw) jr nz, .visible @@ -56,9 +56,9 @@ PrepareOAMData:: ld a, e add $5 ld e, a - ld a, [de] ; c2x7 + ld a, [de] ; [x#SPRITESTATEDATA2_GRASSPRIORITY] and $80 - ld [hSpritePriority], a ; temp store sprite priority + ldh [hSpritePriority], a ; temp store sprite priority pop de ; read the entry from the table @@ -77,17 +77,17 @@ PrepareOAMData:: call GetSpriteScreenXY - ld a, [hOAMBufferOffset] + ldh a, [hOAMBufferOffset] ld e, a - ld d, wOAMBuffer / $100 + ld d, HIGH(wOAMBuffer) .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 [hl] ; add Y offset from table ld [de], a ; write new sprite OAM Y position 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 [hl] ; add X offset from table inc e @@ -98,7 +98,7 @@ PrepareOAMData:: push bc ld b, a - ld a, [wd5cd] ; temp copy of c1x2 + ld a, [wd5cd] ; temp copy of [x#SPRITESTATEDATA1_IMAGEINDEX] swap a ; high nybble determines sprite used (0 is always player sprite, next are some npcs) and $f @@ -126,7 +126,7 @@ PrepareOAMData:: ld a, [hl] bit 1, a ; is the tile allowed to set the sprite priority bit? jr z, .skipPriority - ld a, [hSpritePriority] + ldh a, [hSpritePriority] or [hl] .skipPriority inc hl @@ -136,18 +136,18 @@ PrepareOAMData:: jr z, .tileLoop ld a, e - ld [hOAMBufferOffset], a + ldh [hOAMBufferOffset], a .nextSprite - ld a, [hSpriteOffset2] + ldh a, [hSpriteOffset2] add $10 - cp $100 % $100 + cp LOW($100) jp nz, .spriteLoop ; Clear unused OAM. - ld a, [hOAMBufferOffset] + ldh a, [hOAMBufferOffset] ld l, a - ld h, wOAMBuffer / $100 + ld h, HIGH(wOAMBuffer) ld de, $4 ld b, $a0 ld a, [wd736] @@ -169,21 +169,21 @@ PrepareOAMData:: GetSpriteScreenXY: inc e inc e - ld a, [de] ; c1x4 - ld [hSpriteScreenY], a + ld a, [de] ; [x#SPRITESTATEDATA1_YPIXELS] + ldh [hSpriteScreenY], a inc e inc e - ld a, [de] ; c1x6 - ld [hSpriteScreenX], a + ld a, [de] ; [x#SPRITESTATEDATA1_XPIXELS] + ldh [hSpriteScreenX], a ld a, 4 add e ld e, a - ld a, [hSpriteScreenY] + ldh a, [hSpriteScreenY] add 4 and $f0 - ld [de], a ; c1xa (y) + ld [de], a ; [x#SPRITESTATEDATA1_YADJUSTED] inc e - ld a, [hSpriteScreenX] + ldh a, [hSpriteScreenX] and $f0 - ld [de], a ; c1xb (x) + ld [de], a ; [x#SPRITESTATEDATA1_XADJUSTED] ret diff --git a/engine/items/inventory.asm b/engine/items/inventory.asm index 7ce61cb9..bf433175 100644 --- a/engine/items/inventory.asm +++ b/engine/items/inventory.asm @@ -12,10 +12,10 @@ AddItemToInventory_:: push hl push hl ld d, PC_ITEM_CAPACITY ; how many items the PC can hold - ld a, wNumBagItems & $FF + ld a, LOW(wNumBagItems) cp l jr nz, .checkIfInventoryFull - ld a, wNumBagItems >> 8 + ld a, HIGH(wNumBagItems) cp h jr nz, .checkIfInventoryFull ; if the destination is the bag diff --git a/engine/items/item_effects.asm b/engine/items/item_effects.asm index 238c2ea9..b04f11fb 100755 --- a/engine/items/item_effects.asm +++ b/engine/items/item_effects.asm @@ -147,7 +147,7 @@ ItemUseBall: ; If the player is fighting an unidentified ghost, set the value that indicates ; the Pokémon can't be caught and skip the capture calculations. - callab IsGhostBattle + callfar IsGhostBattle ld b, $10 ; can't be caught value jp z, .setAnimData @@ -239,14 +239,14 @@ ItemUseBall: ; Calculate MaxHP * 255. xor a - ld [hMultiplicand], a + ldh [hMultiplicand], a ld hl, wEnemyMonMaxHP ld a, [hli] - ld [hMultiplicand + 1], a + ldh [hMultiplicand + 1], a ld a, [hl] - ld [hMultiplicand + 2], a + ldh [hMultiplicand + 2], a ld a, 255 - ld [hMultiplier], a + ldh [hMultiplier], a call Multiply ; 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. ; Calculate (MaxHP * 255) / BallFactor. - ld [hDivisor], a + ldh [hDivisor], a ld b, 4 ; number of bytes in dividend call Divide @@ -281,17 +281,17 @@ ItemUseBall: .skip2 ; Let W = ((MaxHP * 255) / BallFactor) / max(HP / 4, 1). Calculate W. - ld [hDivisor], a + ldh [hDivisor], a ld b, 4 call Divide ; If W > 255, store 255 in [hQuotient + 3]. ; Let X = min(W, 255) = [hQuotient + 3]. - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] and a jr z, .skip3 ld a, 255 - ld [hQuotient + 3], a + ldh [hQuotient + 3], a .skip3 pop bc ; b = Rand1 - Status @@ -302,7 +302,7 @@ ItemUseBall: jr c, .failedToCapture ; If W > 255, the ball captures the Pokémon. - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] and a jr nz, .captured @@ -310,7 +310,7 @@ ItemUseBall: ; If Rand2 > X, the ball fails to capture the Pokémon. ld b, a - ld a, [hQuotient + 3] + ldh a, [hQuotient + 3] cp b jr c, .failedToCapture @@ -318,17 +318,17 @@ ItemUseBall: jr .skipShakeCalculations .failedToCapture - ld a, [hQuotient + 3] + ldh a, [hQuotient + 3] ld [wPokeBallCaptureCalcTemp], a ; Save X. ; Calculate CatchRate * 100. xor a - ld [hMultiplicand], a - ld [hMultiplicand + 1], a + ldh [hMultiplicand], a + ldh [hMultiplicand + 1], a ld a, [wEnemyMonActualCatchRate] - ld [hMultiplicand + 2], a + ldh [hMultiplicand + 2], a ld a, 100 - ld [hMultiplier], a + ldh [hMultiplier], a call Multiply ; Determine BallFactor2. @@ -349,26 +349,26 @@ ItemUseBall: .skip4 ; Let Y = (CatchRate * 100) / BallFactor2. Calculate Y. ld a, b - ld [hDivisor], a + ldh [hDivisor], a ld b, 4 call Divide ; If Y > 255, there are 3 shakes. ; Note that this shouldn't be possible. ; The maximum value of Y is (255 * 100) / 150 = 170. - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] and a ld b, $63 ; 3 shakes jr nz, .setAnimData ; Calculate X * Y. ld a, [wPokeBallCaptureCalcTemp] - ld [hMultiplier], a + ldh [hMultiplier], a call Multiply ; Calculate (X * Y) / 255. ld a, 255 - ld [hDivisor], a + ldh [hDivisor], a ld b, 4 call Divide @@ -386,9 +386,9 @@ ItemUseBall: .addAilmentValue ; If the Pokémon has a status ailment, add Status2. - ld a, [hQuotient + 3] + ldh a, [hQuotient + 3] add b - ld [hQuotient + 3], a + ldh [hQuotient + 3], a .skip5 ; Finally determine the number of shakes. @@ -398,7 +398,7 @@ ItemUseBall: ; 10 ≤ Z < 30: 1 shake ; 30 ≤ Z < 70: 2 shakes ; 70 ≤ Z: 3 shakes - ld a, [hQuotient + 3] + ldh a, [hQuotient + 3] cp 10 ld b, $20 jr c, .setAnimData @@ -422,7 +422,7 @@ ItemUseBall: ld a, TOSS_ANIM ld [wAnimationID], a xor a - ld [hWhoseTurn], a + ldh [hWhoseTurn], a ld [wAnimationType], a ld [wDamageMultipliers], a ld a, [wWhichPokemon] @@ -495,7 +495,7 @@ ItemUseBall: ld [wcf91], a ld a, [wEnemyMonLevel] ld [wCurEnemyLVL], a - callab LoadEnemyMonData + callfar LoadEnemyMonData pop af ld [wcf91], a pop hl @@ -632,7 +632,7 @@ ItemUseTownMap: ld a, [wIsInBattle] and a jp nz, ItemUseNotTime - jpba DisplayTownMap + farjp DisplayTownMap ItemUseBicycle: ld a, [wIsInBattle] @@ -656,7 +656,7 @@ ItemUseBicycle: jp nc, NoCyclingAllowedHere call ItemUseReloadOverworldData xor a ; no keys pressed - ld [hJoyHeld], a ; current joypad state + ldh [hJoyHeld], a ; current joypad state inc a ld [wWalkBikeSurfState], a ; change player state to bicycling ld hl, GotOnBicycleText @@ -687,11 +687,11 @@ ItemUseSurfboard: jp PrintText .tryToStopSurfing xor a - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a ld d, 16 ; talking range in pixels (normal range) call IsSpriteInFrontOfPlayer2 res 7, [hl] - ld a, [hSpriteIndexOrTextID] + ldh a, [hSpriteIndexOrTextID] and a ; is there a sprite in the way? jr nz, .cannotStopSurfing ld hl, TilePairCollisionsWater @@ -778,7 +778,7 @@ ItemUseEvoStone: ld a, SFX_HEAL_AILMENT call PlaySoundWaitForCurrent call WaitForSoundToFinish - callab TryEvolvingMon ; try to evolve pokemon + callfar TryEvolvingMon ; try to evolve pokemon ld a, [wEvolutionOccurred] and a jr z, .noEffect @@ -1018,18 +1018,18 @@ ItemUseMedicine: call AddNTimes ld a, [hli] ld [wHPBarMaxHP + 1], a - ld [hDividend], a + ldh [hDividend], a ld a, [hl] ld [wHPBarMaxHP], a - ld [hDividend + 1], a + ldh [hDividend + 1], a ld a, 5 - ld [hDivisor], a + ldh [hDivisor], a ld b, 2 ; number of bytes call Divide ; get 1/5 of max HP of pokemon that used Softboiled ld bc, (wPartyMon1HP + 1) - (wPartyMon1MaxHP + 1) 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 - ld a, [hQuotient + 3] + ldh a, [hQuotient + 3] push af ld b, a ld a, [hl] @@ -1037,28 +1037,28 @@ ItemUseMedicine: sub b ld [hld], a ld [wHPBarNewHP], a - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] ld b, a ld a, [hl] ld [wHPBarOldHP+1], a sbc b ld [hl], a ld [wHPBarNewHP+1], a - coord hl, 4, 1 + hlcoord 4, 1 ld a, [wWhichPokemon] ld bc, 2 * SCREEN_WIDTH call AddNTimes ; calculate coordinates of HP bar of pokemon that used Softboiled ld a, SFX_HEAL_HP call PlaySoundWaitForCurrent - ld a, [hFlagsFFF6] + ldh a, [hFlagsFFF6] set 0, a - ld [hFlagsFFF6], a + ldh [hFlagsFFF6], a ld a, $02 ld [wHPBarType], a predef UpdateHPBar2 ; animate HP bar decrease of pokemon that used Softboiled - ld a, [hFlagsFFF6] + ldh a, [hFlagsFFF6] res 0, a - ld [hFlagsFFF6], a + ldh [hFlagsFFF6], a pop af ld b, a ; store heal amount (1/5 of max HP) ld hl, wHPBarOldHP + 1 @@ -1200,15 +1200,15 @@ ItemUseMedicine: jr z, .playStatusAilmentCuringSound ld a, SFX_HEAL_HP call PlaySoundWaitForCurrent - ld a, [hFlagsFFF6] + ldh a, [hFlagsFFF6] set 0, a - ld [hFlagsFFF6], a + ldh [hFlagsFFF6], a ld a, $02 ld [wHPBarType], a predef UpdateHPBar2 ; animate the HP bar lengthening - ld a, [hFlagsFFF6] + ldh a, [hFlagsFFF6] res 0, a - ld [hFlagsFFF6], a + ldh [hFlagsFFF6], a ld a, REVIVE_MSG ld [wPartyMenuTypeOrMessageID], a ld a, [wcf91] @@ -1224,13 +1224,13 @@ ItemUseMedicine: call PlaySoundWaitForCurrent .showHealingItemMessage xor a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a call ClearScreen dec a ld [wUpdateSpritesEnabled], a call RedrawPartyMenu ; redraws the party menu and displays the message ld a, 1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ld c, 50 call DelayFrames call WaitForTextScrollButtonPress @@ -1341,17 +1341,17 @@ ItemUseMedicine: push hl push de ld d, a - callab CalcExperience ; calculate experience for next level and store it at hExperience + callfar CalcExperience ; calculate experience for next level and store it at hExperience pop de pop hl ld bc, wPartyMon1Exp - wPartyMon1Level add hl, bc ; hl now points to MSB of experience ; update experience to minimum for new level - ld a, [hExperience] + ldh a, [hExperience] ld [hli], a - ld a, [hExperience + 1] + ldh a, [hExperience + 1] ld [hli], a - ld a, [hExperience + 2] + ldh a, [hExperience + 2] ld [hl], a pop hl ld a, [wWhichPokemon] @@ -1400,14 +1400,14 @@ ItemUseMedicine: ld [wMonDataLocation], a call LoadMonData ld d, $01 - callab PrintStatsBox ; display new stats text box + callfar PrintStatsBox ; display new stats text box call WaitForTextScrollButtonPress ; wait for button press xor a ; PLAYER_PARTY_DATA ld [wMonDataLocation], a predef LearnMoveFromLevelUp ; learn level up move, if any xor a ld [wForceEvolution], a - callab TryEvolvingMon ; evolve pokemon, if appropriate + callfar TryEvolvingMon ; evolve pokemon, if appropriate ld a, $01 ld [wUpdateSpritesEnabled], a pop af @@ -1459,7 +1459,7 @@ BaitRockCommon: ld [wAnimationID], a xor a ld [wAnimationType], a - ld [hWhoseTurn], a + ldh [hWhoseTurn], a ld [de], a ; zero escape factor (for bait), zero bait factor (for rock) .randomLoop ; loop until a random number less than 5 is generated call Random @@ -1698,8 +1698,8 @@ ItemUseXStat: call LoadScreenTilesFromBuffer1 ; restore saved screen call Delay3 xor a - ld [hWhoseTurn], a ; set turn to player's turn - callba StatModifierUpEffect ; do stat increase move + ldh [hWhoseTurn], a ; set turn to player's turn + farcall StatModifierUpEffect ; do stat increase move pop hl pop af ld [hld], a ; restore [wPlayerMoveEffect] @@ -1775,7 +1775,7 @@ ItemUsePokeflute: and $80 jr nz, .skipMusic call WaitForSoundToFinish ; wait for sound to end - callba Music_PokeFluteInBattle ; play in-battle pokeflute music + farcall Music_PokeFluteInBattle ; play in-battle pokeflute music .musicWaitLoop ; wait for music to finish playing ld a, [wChannelSoundIDs + Ch7] and a ; music off? @@ -1927,7 +1927,7 @@ RodResponse: push af push hl ld [hl], 0 - callba FishingAnim + farcall FishingAnim pop hl pop af ld [hl], a @@ -1968,7 +1968,7 @@ ItemUseItemfinder: and a jp nz, ItemUseNotTime call ItemUseReloadOverworldData - callba HiddenItemNear ; check for hidden items + farcall HiddenItemNear ; check for hidden items ld hl, ItemfinderFoundNothingText jr nc, .printText ; if no hidden items ld c, 4 @@ -2024,7 +2024,7 @@ ItemUsePPRestore: call PrintText xor a ld [wPlayerMoveListIndex], a - callab MoveSelectionMenu ; move selection menu + callfar MoveSelectionMenu ; move selection menu ld a, 0 ld [wPlayerMoveListIndex], a jr nz, .chooseMon @@ -2221,7 +2221,7 @@ ItemUseTMHM: call PrintText ld hl, TeachMachineMoveText call PrintText - coord hl, 14, 7 + hlcoord 14, 7 lb bc, 8, 15 ld a, TWO_OPTION_MENU ld [wTextBoxID], a @@ -2278,7 +2278,7 @@ ItemUseTMHM: call PrintText jr .chooseMon .checkIfAlreadyLearnedMove - callab CheckIfMoveIsKnown ; check if the pokemon already knows the move + callfar CheckIfMoveIsKnown ; check if the pokemon already knows the move jr c, .chooseMon predef LearnMove ; teach move pop af @@ -2463,13 +2463,13 @@ RestoreBonusPP: AddBonusPP: push bc ld a, [de] ; normal max PP of move - ld [hDividend + 3], a + ldh [hDividend + 3], a xor a - ld [hDividend], a - ld [hDividend + 1], a - ld [hDividend + 2], a + ldh [hDividend], a + ldh [hDividend + 1], a + ldh [hDividend + 2], a ld a, 5 - ld [hDivisor], a + ldh [hDivisor], a ld b, 4 call Divide ld a, [hl] ; move PP @@ -2480,7 +2480,7 @@ AddBonusPP: srl a ld c, a ; c = number of PP Ups used .loop - ld a, [hQuotient + 3] + ldh a, [hQuotient + 3] cp 8 ; is the amount greater than or equal to 8? jr c, .addAmount ld a, 7 ; cap the amount at 7 @@ -2607,7 +2607,7 @@ TossItem_:: call CopyStringToCF4B ; copy name to wcf4b ld hl, IsItOKToTossItemText call PrintText - coord hl, 14, 7 + hlcoord 14, 7 lb bc, 8, 15 ld a, TWO_OPTION_MENU ld [wTextBoxID], a @@ -2820,15 +2820,15 @@ SendNewMonToBox: push de ld a, [wCurEnemyLVL] ld d, a - callab CalcExperience + callfar CalcExperience pop de - ld a, [hExperience] + ldh a, [hExperience] ld [de], a inc de - ld a, [hExperience + 1] + ldh a, [hExperience + 1] ld [de], a inc de - ld a, [hExperience + 2] + ldh a, [hExperience + 2] ld [de], a inc de xor a diff --git a/engine/items/tm_prices.asm b/engine/items/tm_prices.asm index 502191d5..df9761bd 100755 --- a/engine/items/tm_prices.asm +++ b/engine/items/tm_prices.asm @@ -16,10 +16,10 @@ GetMachinePrice:: swap a .highNybbleIsPrice and $f0 - ld [hItemPrice + 1], a + ldh [hItemPrice + 1], a xor a - ld [hItemPrice], a - ld [hItemPrice + 2], a + ldh [hItemPrice], a + ldh [hItemPrice + 2], a ret INCLUDE "data/items/tm_prices.asm" diff --git a/engine/items/town_map.asm b/engine/items/town_map.asm index 285dbfa5..83ea81bf 100755 --- a/engine/items/town_map.asm +++ b/engine/items/town_map.asm @@ -6,19 +6,19 @@ DisplayTownMap: ld [hl], $ff push hl ld a, $1 - ld [hJoy7], a + ldh [hJoy7], a ld a, [wCurMap] push af ld b, $0 call DrawPlayerOrBirdSprite ; player sprite - coord hl, 1, 0 + hlcoord 1, 0 ld de, wcd6d call PlaceString ld hl, wOAMBuffer ld de, wTileMapBackup ld bc, $10 call CopyData - ld hl, vSprites + $40 + ld hl, vSprites tile $04 ld de, TownMapCursor lb bc, BANK(TownMapCursor), (TownMapCursorEnd - TownMapCursor) / $8 call CopyVideoDataDouble @@ -28,7 +28,7 @@ DisplayTownMap: jr .enterLoop .townMapLoop - coord hl, 0, 0 + hlcoord 0, 0 lb bc, 1, 20 call ClearScreenArea ld hl, TownMapOrder @@ -55,7 +55,7 @@ DisplayTownMap: inc de cp $50 jr nz, .copyMapName - coord hl, 1, 0 + hlcoord 1, 0 ld de, wcd6d call PlaceString ld hl, wOAMBuffer + $10 @@ -65,7 +65,7 @@ DisplayTownMap: .inputLoop call TownMapSpriteBlinkingAnimation call JoypadLowSensitivity - ld a, [hJoy5] + ldh a, [hJoy5] ld b, a and A_BUTTON | B_BUTTON | D_UP | D_DOWN jr z, .inputLoop @@ -77,7 +77,7 @@ DisplayTownMap: jr nz, .pressedDown xor a ld [wTownMapSpriteBlinkingEnabled], a - ld [hJoy7], a + ldh [hJoy7], a ld [wAnimCounter], a call ExitTownMap pop hl @@ -118,7 +118,7 @@ LoadTownMap_Nest: push hl call DisplayWildLocations call GetMonName - coord hl, 1, 0 + hlcoord 1, 0 call PlaceString ld h, b ld l, c @@ -140,11 +140,11 @@ LoadTownMap_Fly:: call LoadPlayerSpriteGraphics call LoadFontTilePatterns ld de, BirdSprite - ld hl, vSprites + $40 - lb bc, BANK(BirdSprite), $c + ld hl, vSprites tile $04 + lb bc, BANK(BirdSprite), 12 call CopyVideoData ld de, TownMapUpArrow - ld hl, vChars1 + $6d0 + ld hl, vChars1 tile $6d lb bc, BANK(TownMapUpArrow), (TownMapUpArrowEnd - TownMapUpArrow) / $8 call CopyVideoDataDouble call BuildFlyLocationsList @@ -153,41 +153,41 @@ LoadTownMap_Fly:: push af ld [hl], $ff push hl - coord hl, 0, 0 + hlcoord 0, 0 ld de, ToText call PlaceString ld a, [wCurMap] ld b, $0 call DrawPlayerOrBirdSprite ld hl, wFlyLocationsList - coord de, 18, 0 + decoord 18, 0 .townMapFlyLoop ld a, " " ld [de], a push hl push hl - coord hl, 3, 0 + hlcoord 3, 0 lb bc, 1, 15 call ClearScreenArea pop hl ld a, [hl] ld b, $4 call DrawPlayerOrBirdSprite ; draw bird sprite - coord hl, 3, 0 + hlcoord 3, 0 ld de, wcd6d call PlaceString ld c, 15 call DelayFrames - coord hl, 18, 0 + hlcoord 18, 0 ld [hl], "▲" - coord hl, 19, 0 + hlcoord 19, 0 ld [hl], "▼" pop hl .inputLoop push hl call DelayFrame call JoypadLowSensitivity - ld a, [hJoy5] + ldh a, [hJoy5] ld b, a pop hl and A_BUTTON | B_BUTTON | D_UP | D_DOWN @@ -219,7 +219,7 @@ LoadTownMap_Fly:: ld [hl], a ret .pressedUp - coord de, 18, 0 + decoord 18, 0 inc hl ld a, [hl] cp $ff @@ -231,7 +231,7 @@ LoadTownMap_Fly:: ld hl, wFlyLocationsList jp .townMapFlyLoop .pressedDown - coord de, 19, 0 + decoord 19, 0 dec hl ld a, [hl] cp $ff @@ -278,22 +278,22 @@ LoadTownMap: call GBPalWhiteOutWithDelay3 call ClearScreen call UpdateSprites - coord hl, 0, 0 + hlcoord 0, 0 ld b, $12 ld c, $12 call TextBoxBorder call DisableLCD ld hl, WorldMapTileGraphics - ld de, vChars2 + $600 + ld de, vChars2 tile $60 ld bc, WorldMapTileGraphicsEnd - WorldMapTileGraphics ld a, BANK(WorldMapTileGraphics) call FarCopyData2 ld hl, MonNestIcon - ld de, vSprites + $40 + ld de, vSprites tile $04 ld bc, MonNestIconEnd - MonNestIcon ld a, BANK(MonNestIcon) call FarCopyDataDouble - coord hl, 0, 0 + hlcoord 0, 0 ld de, CompressedMap .nextTile ld a, [de] @@ -366,7 +366,7 @@ DrawPlayerOrBirdSprite: jp CopyData DisplayWildLocations: - callba FindWildLocationsOfMon + farcall FindWildLocationsOfMon call ZeroOutDuplicatesInList ld hl, wOAMBuffer ld de, wTownMapCoords @@ -395,11 +395,11 @@ DisplayWildLocations: and a ; were any OAM entries written? jr nz, .drawPlayerSprite ; if no OAM entries were written, print area unknown text - coord hl, 1, 7 + hlcoord 1, 7 ld b, 2 ld c, 15 call TextBoxBorder - coord hl, 2, 9 + hlcoord 2, 9 ld de, AreaUnknownText call PlaceString jr .done diff --git a/engine/joypad.asm b/engine/joypad.asm index 31e197e2..87f92635 100644 --- a/engine/joypad.asm +++ b/engine/joypad.asm @@ -2,29 +2,29 @@ _Joypad:: ; hJoyReleased: (hJoyLast ^ hJoyInput) & hJoyLast ; hJoyPressed: (hJoyLast ^ hJoyInput) & hJoyInput - ld a, [hJoyInput] + ldh a, [hJoyInput] cp A_BUTTON + B_BUTTON + SELECT + START ; soft reset jp z, TrySoftReset ld b, a - ld a, [hJoyLast] + ldh a, [hJoyLast] ld e, a xor b ld d, a and e - ld [hJoyReleased], a + ldh [hJoyReleased], a ld a, d and b - ld [hJoyPressed], a + ldh [hJoyPressed], a ld a, b - ld [hJoyLast], a + ldh [hJoyLast], a ld a, [wd730] bit 5, a jr nz, DiscardButtonPresses - ld a, [hJoyLast] - ld [hJoyHeld], a + ldh a, [hJoyLast] + ldh [hJoyHeld], a ld a, [wJoyIgnore] and a @@ -32,19 +32,19 @@ _Joypad:: cpl ld b, a - ld a, [hJoyHeld] + ldh a, [hJoyHeld] and b - ld [hJoyHeld], a - ld a, [hJoyPressed] + ldh [hJoyHeld], a + ldh a, [hJoyPressed] and b - ld [hJoyPressed], a + ldh [hJoyPressed], a ret DiscardButtonPresses: xor a - ld [hJoyHeld], a - ld [hJoyPressed], a - ld [hJoyReleased], a + ldh [hJoyHeld], a + ldh [hJoyPressed], a + ldh [hJoyReleased], a ret TrySoftReset: @@ -52,7 +52,7 @@ TrySoftReset: ; deselect (redundant) ld a, $30 - ld [rJOYP], a + ldh [rJOYP], a ld hl, hSoftReset dec [hl] diff --git a/engine/link/cable_club.asm b/engine/link/cable_club.asm index ca43a895..67c0e471 100755 --- a/engine/link/cable_club.asm +++ b/engine/link/cable_club.asm @@ -9,11 +9,11 @@ CableClub_DoBattleOrTrade: call LoadFontTilePatterns call LoadHpBarAndStatusTilePatterns call LoadTrainerInfoTextBoxTiles - coord hl, 3, 8 + hlcoord 3, 8 ld b, 2 ld c, 12 call CableClub_TextBoxBorder - coord hl, 4, 10 + hlcoord 4, 10 ld de, PleaseWaitString call PlaceString ld hl, wPlayerNumHits @@ -102,25 +102,25 @@ CableClub_DoBattleOrTradeAgain: ld a, SERIAL_PATCH_LIST_PART_TERMINATOR ld [de], a ; end of part 2 call Serial_SyncAndExchangeNybble - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] cp USING_INTERNAL_CLOCK jr nz, .skipSendingTwoZeroBytes ; if using internal clock ; send two zero bytes for syncing purposes? call Delay3 xor a - ld [hSerialSendData], a + ldh [hSerialSendData], a ld a, START_TRANSFER_INTERNAL_CLOCK - ld [rSC], a + ldh [rSC], a call DelayFrame xor a - ld [hSerialSendData], a + ldh [hSerialSendData], a ld a, START_TRANSFER_INTERNAL_CLOCK - ld [rSC], a + ldh [rSC], a .skipSendingTwoZeroBytes call Delay3 ld a, (1 << SERIAL) - ld [rIE], a + ldh [rIE], a ld hl, wSerialRandomNumberListBlock ld de, wSerialOtherGameboyRandomNumberListBlock ld bc, $11 @@ -138,10 +138,10 @@ CableClub_DoBattleOrTradeAgain: ld bc, $c8 call Serial_ExchangeBytes ld a, (1 << SERIAL) | (1 << TIMER) | (1 << VBLANK) - ld [rIE], a + ldh [rIE], a ld a, SFX_STOP_ALL_MUSIC call PlaySound - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] cp USING_INTERNAL_CLOCK jr z, .skipCopyingRandomNumberList ; the list generated by the gameboy clocking the connection is used by both gameboys ld hl, wSerialOtherGameboyRandomNumberListBlock @@ -255,15 +255,15 @@ CableClub_DoBattleOrTradeAgain: ld hl, wEnemyMons + (SERIAL_PREAMBLE_BYTE - 1) dec c jr nz, .unpatchEnemyMonsLoop - ld a, wEnemyMonOT % $100 + ld a, LOW(wEnemyMonOT) ld [wUnusedCF8D], a - ld a, wEnemyMonOT / $100 + ld a, HIGH(wEnemyMonOT) ld [wUnusedCF8D + 1], a xor a ld [wTradeCenterPointerTableIndex], a ld a, SFX_STOP_ALL_MUSIC call PlaySound - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] cp USING_INTERNAL_CLOCK ld c, 66 call z, DelayFrames ; delay if using internal clock @@ -359,7 +359,7 @@ TradeCenter_SelectMon: .displayEnemyMonStats ld a, INIT_ENEMYOT_LIST ld [wInitListType], a - callab InitList ; the list isn't used + callfar InitList ; the list isn't used ld hl, wEnemyMons call TradeCenter_DisplayStats jp .getNewInput @@ -399,7 +399,7 @@ TradeCenter_SelectMon: ld [wTopMenuItemY], a ld a, 1 ld [wTopMenuItemX], a - coord hl, 1, 1 + hlcoord 1, 1 lb bc, 6, 1 call ClearScreenArea .playerMonMenu_HandleInput @@ -418,7 +418,7 @@ TradeCenter_SelectMon: ; unreachable code ld a, INIT_PLAYEROT_LIST ld [wInitListType], a - callab InitList ; the list isn't used + callfar InitList ; the list isn't used call TradeCenter_DisplayStats jp .getNewInput .playerMonMenu_ANotPressed @@ -464,11 +464,11 @@ TradeCenter_SelectMon: dec a .displayStatsTradeMenu push af - coord hl, 0, 14 + hlcoord 0, 14 ld b, 2 ld c, 18 call CableClub_TextBoxBorder - coord hl, 2, 16 + hlcoord 2, 16 ld de, .statsTrade call PlaceString xor a @@ -480,7 +480,7 @@ TradeCenter_SelectMon: ld [wTopMenuItemY], a .selectStatsMenuItem ld a, " " - Coorda 11, 16 + ldcoord_a 11, 16 ld a, D_RIGHT | B_BUTTON | A_BUTTON ld [wMenuWatchedKeys], a ld a, 1 @@ -497,7 +497,7 @@ TradeCenter_SelectMon: jp .playerMonMenu .selectTradeMenuItem ld a, " " - Coorda 1, 16 + ldcoord_a 1, 16 ld a, D_LEFT | B_BUTTON | A_BUTTON ld [wMenuWatchedKeys], a ld a, 11 @@ -513,7 +513,7 @@ TradeCenter_SelectMon: ld [wCurrentMenuItem], a ld a, INIT_PLAYEROT_LIST ld [wInitListType], a - callab InitList ; the list isn't used + callfar InitList ; the list isn't used call TradeCenter_DisplayStats call LoadScreenTilesFromBuffer1 jp .playerMonMenu @@ -548,10 +548,10 @@ TradeCenter_SelectMon: ld [hl], a .cancelMenuItem_Loop ld a, "▶" ; filled arrow cursor - Coorda 1, 16 + ldcoord_a 1, 16 .cancelMenuItem_JoypadLoop call JoypadLowSensitivity - ld a, [hJoy5] + ldh a, [hJoy5] and a ; pressed anything? jr z, .cancelMenuItem_JoypadLoop bit 0, a ; A button pressed? @@ -560,14 +560,14 @@ TradeCenter_SelectMon: jr z, .cancelMenuItem_JoypadLoop ; if Up pressed ld a, " " - Coorda 1, 16 + ldcoord_a 1, 16 ld a, [wPartyCount] dec a ld [wCurrentMenuItem], a jp .playerMonMenu .cancelMenuItem_APressed ld a, "▷" ; unfilled arrow cursor - Coorda 1, 16 + ldcoord_a 1, 16 ld a, $f ld [wSerialExchangeNybbleSendData], a call Serial_PrintWaitingTextAndSyncAndExchangeNybble @@ -588,7 +588,7 @@ ReturnToCableClubRoom: dec a ld [wDestinationWarpID], a call LoadMapData - callba ClearVariablesOnEnterMap + farcall ClearVariablesOnEnterMap pop hl pop af ld [hl], a @@ -596,15 +596,15 @@ ReturnToCableClubRoom: ret TradeCenter_DrawCancelBox: - coord hl, 11, 15 + hlcoord 11, 15 ld a, $7e ld bc, 2 * SCREEN_WIDTH + 9 call FillMemory - coord hl, 0, 15 + hlcoord 0, 15 ld b, 1 ld c, 9 call CableClub_TextBoxBorder - coord hl, 2, 16 + hlcoord 2, 16 ld de, CancelTextString jp PlaceString @@ -613,7 +613,7 @@ CancelTextString: TradeCenter_PlaceSelectedEnemyMonMenuCursor: ld a, [wSerialSyncAndExchangeNybbleReceiveData] - coord hl, 1, 9 + hlcoord 1, 9 ld bc, SCREEN_WIDTH call AddNTimes ld [hl], "▷" ; cursor @@ -630,24 +630,24 @@ TradeCenter_DisplayStats: jp TradeCenter_DrawCancelBox TradeCenter_DrawPartyLists: - coord hl, 0, 0 + hlcoord 0, 0 ld b, 6 ld c, 18 call CableClub_TextBoxBorder - coord hl, 0, 8 + hlcoord 0, 8 ld b, 6 ld c, 18 call CableClub_TextBoxBorder - coord hl, 5, 0 + hlcoord 5, 0 ld de, wPlayerName call PlaceString - coord hl, 5, 8 + hlcoord 5, 8 ld de, wLinkEnemyTrainerName call PlaceString - coord hl, 2, 1 + hlcoord 2, 1 ld de, wPartySpecies call TradeCenter_PrintPartyListNames - coord hl, 2, 9 + hlcoord 2, 9 ld de, wEnemyPartyMons ; fall through @@ -663,7 +663,7 @@ TradeCenter_PrintPartyListNames: push de push hl ld a, c - ld [hPastLeadingZeros], a + ldh [hPastLeadingZeros], a call GetMonName pop hl call PlaceString @@ -684,7 +684,7 @@ TradeCenter_Trade: ld [wSerialExchangeNybbleReceiveData], a ld [wMenuWatchMovingOutOfBounds], a ld [wMenuJoypadPollCount], a - coord hl, 0, 12 + hlcoord 0, 12 ld b, 4 ld c, 18 call CableClub_TextBoxBorder @@ -709,10 +709,10 @@ TradeCenter_Trade: ld [wd11e], a call GetMonName ld hl, WillBeTradedText - coord bc, 1, 14 + bccoord 1, 14 call TextCommandProcessor call SaveScreenTilesToBuffer1 - coord hl, 10, 7 + hlcoord 10, 7 lb bc, 8, 11 ld a, TRADE_CANCEL_MENU ld [wTwoOptionMenuID], a @@ -726,11 +726,11 @@ TradeCenter_Trade: ; if trade cancelled ld a, $1 ld [wSerialExchangeNybbleSendData], a - coord hl, 0, 12 + hlcoord 0, 12 ld b, 4 ld c, 18 call CableClub_TextBoxBorder - coord hl, 1, 14 + hlcoord 1, 14 ld de, TradeCanceled call PlaceString call Serial_PrintWaitingTextAndSyncAndExchangeNybble @@ -743,11 +743,11 @@ TradeCenter_Trade: dec a ; did the other person cancel? jr nz, .doTrade ; if the other person cancelled - coord hl, 0, 12 + hlcoord 0, 12 ld b, 4 ld c, 18 call CableClub_TextBoxBorder - coord hl, 1, 14 + hlcoord 1, 14 ld de, TradeCanceled call PlaceString jp .tradeCancelled @@ -837,7 +837,7 @@ TradeCenter_Trade: call LoadHpBarAndStatusTilePatterns xor a ld [wUnusedCC5B], a - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK jr z, .usingExternalClock predef InternalClockTradeAnim @@ -845,17 +845,17 @@ TradeCenter_Trade: .usingExternalClock predef ExternalClockTradeAnim .tradeCompleted - callab TryEvolvingMon + callfar TryEvolvingMon call ClearScreen call LoadTrainerInfoTextBoxTiles call Serial_PrintWaitingTextAndSyncAndExchangeNybble ld c, 40 call DelayFrames - coord hl, 0, 12 + hlcoord 0, 12 ld b, 4 ld c, 18 call CableClub_TextBoxBorder - coord hl, 1, 14 + hlcoord 1, 14 ld de, TradeCompleted call PlaceString predef SaveSAVtoSRAM2 @@ -914,7 +914,7 @@ CableClub_Run: ld [wGrassRate], a inc a ; LINK_STATE_IN_CABLE_CLUB ld [wLinkState], a - ld [hJoy5], a + ldh [hJoy5], a ld a, 10 ld [wAudioFadeOutControl], a ld a, BANK(Music_Celadon) @@ -972,6 +972,6 @@ CableClub_DrawHorizontalLine: LoadTrainerInfoTextBoxTiles: ld de, TrainerInfoTextBoxTileGraphics - ld hl, vChars2 + $760 + ld hl, vChars2 tile $76 lb bc, BANK(TrainerInfoTextBoxTileGraphics), (TrainerInfoTextBoxTileGraphicsEnd - TrainerInfoTextBoxTileGraphics) / $10 jp CopyVideoData diff --git a/engine/link/cable_club_npc.asm b/engine/link/cable_club_npc.asm index 6001c314..594adf08 100755 --- a/engine/link/cable_club_npc.asm +++ b/engine/link/cable_club_npc.asm @@ -15,27 +15,27 @@ CableClubNPC:: ld a, 90 ld [wLinkTimeoutCounter], a .establishConnectionLoop - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] cp USING_INTERNAL_CLOCK jr z, .establishedConnection cp USING_EXTERNAL_CLOCK jr z, .establishedConnection ld a, CONNECTION_NOT_ESTABLISHED - ld [hSerialConnectionStatus], a + ldh [hSerialConnectionStatus], a ld a, ESTABLISH_CONNECTION_WITH_EXTERNAL_CLOCK - ld [rSB], a + ldh [rSB], a xor a - ld [hSerialReceiveData], a + ldh [hSerialReceiveData], a ld a, START_TRANSFER_EXTERNAL_CLOCK - ld [rSC], a + ldh [rSC], a ld a, [wLinkTimeoutCounter] dec a ld [wLinkTimeoutCounter], a jr z, .failedToEstablishConnection ld a, ESTABLISH_CONNECTION_WITH_INTERNAL_CLOCK - ld [rSB], a + ldh [rSB], a ld a, START_TRANSFER_INTERNAL_CLOCK - ld [rSC], a + ldh [rSC], a call DelayFrame jr .establishConnectionLoop .establishedConnection @@ -54,7 +54,7 @@ CableClubNPC:: ld a, [wCurrentMenuItem] and a jr nz, .choseNo - callab SaveSAVtoSRAM + callfar SaveSAVtoSRAM call WaitForSoundToFinish ld a, SFX_SAVE call PlaySoundWaitForCurrent @@ -65,7 +65,7 @@ CableClubNPC:: ld [hli], a xor a ld [hl], a - ld [hSerialReceivedNewData], a + ldh [hSerialReceivedNewData], a ld [wSerialExchangeNybbleSendData], a call Serial_SyncAndExchangeNybble ld hl, wUnknownSerialCounter @@ -107,7 +107,7 @@ CableClubNPC:: xor a ld [hld], a ld [hl], a - jpab LinkMenu + jpfar LinkMenu CableClubNPCAreaReservedFor2FriendsLinkedByCableText: text_far _CableClubNPCAreaReservedFor2FriendsLinkedByCableText @@ -141,11 +141,11 @@ CableClubNPCMakingPreparationsText: CloseLinkConnection: call Delay3 ld a, CONNECTION_NOT_ESTABLISHED - ld [hSerialConnectionStatus], a + ldh [hSerialConnectionStatus], a ld a, ESTABLISH_CONNECTION_WITH_EXTERNAL_CLOCK - ld [rSB], a + ldh [rSB], a xor a - ld [hSerialReceiveData], a + ldh [hSerialReceiveData], a ld a, START_TRANSFER_EXTERNAL_CLOCK - ld [rSC], a + ldh [rSC], a ret diff --git a/engine/link/print_waiting_text.asm b/engine/link/print_waiting_text.asm index c48459d3..d74d635f 100644 --- a/engine/link/print_waiting_text.asm +++ b/engine/link/print_waiting_text.asm @@ -1,5 +1,5 @@ PrintWaitingText:: - coord hl, 3, 10 + hlcoord 3, 10 ld b, $1 ld c, $b ld a, [wIsInBattle] @@ -10,7 +10,7 @@ PrintWaitingText:: .asm_4c17 call CableClub_TextBoxBorder .asm_4c1a - coord hl, 4, 11 + hlcoord 4, 11 ld de, WaitingText call PlaceString ld c, 50 diff --git a/engine/math/bcd.asm b/engine/math/bcd.asm index 2d0b43df..1e5aedc9 100644 --- a/engine/math/bcd.asm +++ b/engine/math/bcd.asm @@ -6,39 +6,39 @@ DivideBCDPredef4:: DivideBCD:: xor a - ld [hDivideBCDBuffer], a - ld [hDivideBCDBuffer+1], a - ld [hDivideBCDBuffer+2], a + ldh [hDivideBCDBuffer], a + ldh [hDivideBCDBuffer+1], a + ldh [hDivideBCDBuffer+2], a ld d, $1 .mulBy10Loop ; multiply the divisor by 10 until the leading digit is nonzero ; to set up the standard long division algorithm - ld a, [hDivideBCDDivisor] + ldh a, [hDivideBCDDivisor] and $f0 jr nz, .next inc d - ld a, [hDivideBCDDivisor] + ldh a, [hDivideBCDDivisor] swap a and $f0 ld b, a - ld a, [hDivideBCDDivisor+1] + ldh a, [hDivideBCDDivisor+1] swap a - ld [hDivideBCDDivisor+1], a + ldh [hDivideBCDDivisor+1], a and $f or b - ld [hDivideBCDDivisor], a - ld a, [hDivideBCDDivisor+1] + ldh [hDivideBCDDivisor], a + ldh a, [hDivideBCDDivisor+1] and $f0 ld b, a - ld a, [hDivideBCDDivisor+2] + ldh a, [hDivideBCDDivisor+2] swap a - ld [hDivideBCDDivisor+2], a + ldh [hDivideBCDDivisor+2], a and $f or b - ld [hDivideBCDDivisor+1], a - ld a, [hDivideBCDDivisor+2] + ldh [hDivideBCDDivisor+1], a + ldh a, [hDivideBCDDivisor+2] and $f0 - ld [hDivideBCDDivisor+2], a + ldh [hDivideBCDDivisor+2], a jr .mulBy10Loop .next push de @@ -48,16 +48,16 @@ DivideBCD:: ld a, b swap a and $f0 - ld [hDivideBCDBuffer], a + ldh [hDivideBCDBuffer], a dec d jr z, .next2 push de call DivideBCD_divDivisorBy10 call DivideBCD_getNextDigit pop de - ld a, [hDivideBCDBuffer] + ldh a, [hDivideBCDBuffer] or b - ld [hDivideBCDBuffer], a + ldh [hDivideBCDBuffer], a dec d jr z, .next2 push de @@ -67,16 +67,16 @@ DivideBCD:: ld a, b swap a and $f0 - ld [hDivideBCDBuffer+1], a + ldh [hDivideBCDBuffer+1], a dec d jr z, .next2 push de call DivideBCD_divDivisorBy10 call DivideBCD_getNextDigit pop de - ld a, [hDivideBCDBuffer+1] + ldh a, [hDivideBCDBuffer+1] or b - ld [hDivideBCDBuffer+1], a + ldh [hDivideBCDBuffer+1], a dec d jr z, .next2 push de @@ -86,23 +86,23 @@ DivideBCD:: ld a, b swap a and $f0 - ld [hDivideBCDBuffer+2], a + ldh [hDivideBCDBuffer+2], a dec d jr z, .next2 push de call DivideBCD_divDivisorBy10 call DivideBCD_getNextDigit pop de - ld a, [hDivideBCDBuffer+2] + ldh a, [hDivideBCDBuffer+2] or b - ld [hDivideBCDBuffer+2], a + ldh [hDivideBCDBuffer+2], a .next2 - ld a, [hDivideBCDBuffer] - ld [hDivideBCDQuotient], a ; the same memory location as hDivideBCDDivisor - ld a, [hDivideBCDBuffer+1] - ld [hDivideBCDQuotient+1], a - ld a, [hDivideBCDBuffer+2] - ld [hDivideBCDQuotient+2], a + ldh a, [hDivideBCDBuffer] + ldh [hDivideBCDQuotient], a ; the same memory location as hDivideBCDDivisor + ldh a, [hDivideBCDBuffer+1] + ldh [hDivideBCDQuotient+1], a + ldh a, [hDivideBCDBuffer+2] + ldh [hDivideBCDQuotient+2], a pop de ld a, $6 sub d @@ -117,28 +117,28 @@ DivideBCD:: ret DivideBCD_divDivisorBy10: - ld a, [hDivideBCDDivisor+2] + ldh a, [hDivideBCDDivisor+2] swap a and $f ld b, a - ld a, [hDivideBCDDivisor+1] + ldh a, [hDivideBCDDivisor+1] swap a - ld [hDivideBCDDivisor+1], a + ldh [hDivideBCDDivisor+1], a and $f0 or b - ld [hDivideBCDDivisor+2], a - ld a, [hDivideBCDDivisor+1] + ldh [hDivideBCDDivisor+2], a + ldh a, [hDivideBCDDivisor+1] and $f ld b, a - ld a, [hDivideBCDDivisor] + ldh a, [hDivideBCDDivisor] swap a - ld [hDivideBCDDivisor], a + ldh [hDivideBCDDivisor], a and $f0 or b - ld [hDivideBCDDivisor+1], a - ld a, [hDivideBCDDivisor] + ldh [hDivideBCDDivisor+1], a + ldh a, [hDivideBCDDivisor] and $f - ld [hDivideBCDDivisor], a + ldh [hDivideBCDDivisor], a ret DivideBCD_getNextDigit: diff --git a/engine/math/multiply_divide.asm b/engine/math/multiply_divide.asm index 8bbc20a1..2fcda158 100755 --- a/engine/math/multiply_divide.asm +++ b/engine/math/multiply_divide.asm @@ -2,142 +2,142 @@ _Multiply:: ld a, $8 ld b, a xor a - ld [hProduct], a - ld [hMultiplyBuffer], a - ld [hMultiplyBuffer+1], a - ld [hMultiplyBuffer+2], a - ld [hMultiplyBuffer+3], a + ldh [hProduct], a + ldh [hMultiplyBuffer], a + ldh [hMultiplyBuffer+1], a + ldh [hMultiplyBuffer+2], a + ldh [hMultiplyBuffer+3], a .loop - ld a, [hMultiplier] + ldh a, [hMultiplier] srl a - ld [hMultiplier], a ; (aliases: hDivisor, hMultiplier, hPowerOf10) + ldh [hMultiplier], a ; (aliases: hDivisor, hMultiplier, hPowerOf10) jr nc, .smallMultiplier - ld a, [hMultiplyBuffer+3] + ldh a, [hMultiplyBuffer+3] ld c, a - ld a, [hMultiplicand+2] + ldh a, [hMultiplicand+2] add c - ld [hMultiplyBuffer+3], a - ld a, [hMultiplyBuffer+2] + ldh [hMultiplyBuffer+3], a + ldh a, [hMultiplyBuffer+2] ld c, a - ld a, [hMultiplicand+1] + ldh a, [hMultiplicand+1] adc c - ld [hMultiplyBuffer+2], a - ld a, [hMultiplyBuffer+1] + ldh [hMultiplyBuffer+2], a + ldh a, [hMultiplyBuffer+1] ld c, a - ld a, [hMultiplicand] ; (aliases: hMultiplicand) + ldh a, [hMultiplicand] ; (aliases: hMultiplicand) adc c - ld [hMultiplyBuffer+1], a - ld a, [hMultiplyBuffer] + ldh [hMultiplyBuffer+1], a + ldh a, [hMultiplyBuffer] ld c, a - ld a, [hProduct] ; (aliases: hProduct, hPastLeadingZeros, hQuotient) + ldh a, [hProduct] ; (aliases: hProduct, hPastLeadingZeros, hQuotient) adc c - ld [hMultiplyBuffer], a + ldh [hMultiplyBuffer], a .smallMultiplier dec b jr z, .done - ld a, [hMultiplicand+2] + ldh a, [hMultiplicand+2] sla a - ld [hMultiplicand+2], a - ld a, [hMultiplicand+1] + ldh [hMultiplicand+2], a + ldh a, [hMultiplicand+1] rl a - ld [hMultiplicand+1], a - ld a, [hMultiplicand] + ldh [hMultiplicand+1], a + ldh a, [hMultiplicand] rl a - ld [hMultiplicand], a - ld a, [hProduct] + ldh [hMultiplicand], a + ldh a, [hProduct] rl a - ld [hProduct], a + ldh [hProduct], a jr .loop .done - ld a, [hMultiplyBuffer+3] - ld [hProduct+3], a - ld a, [hMultiplyBuffer+2] - ld [hProduct+2], a - ld a, [hMultiplyBuffer+1] - ld [hProduct+1], a - ld a, [hMultiplyBuffer] - ld [hProduct], a + ldh a, [hMultiplyBuffer+3] + ldh [hProduct+3], a + ldh a, [hMultiplyBuffer+2] + ldh [hProduct+2], a + ldh a, [hMultiplyBuffer+1] + ldh [hProduct+1], a + ldh a, [hMultiplyBuffer] + ldh [hProduct], a ret _Divide:: xor a - ld [hDivideBuffer], a - ld [hDivideBuffer+1], a - ld [hDivideBuffer+2], a - ld [hDivideBuffer+3], a - ld [hDivideBuffer+4], a + ldh [hDivideBuffer], a + ldh [hDivideBuffer+1], a + ldh [hDivideBuffer+2], a + ldh [hDivideBuffer+3], a + ldh [hDivideBuffer+4], a ld a, $9 ld e, a .asm_37db3 - ld a, [hDivideBuffer] + ldh a, [hDivideBuffer] ld c, a - ld a, [hDividend+1] ; (aliases: hMultiplicand) + ldh a, [hDividend+1] ; (aliases: hMultiplicand) sub c ld d, a - ld a, [hDivisor] ; (aliases: hDivisor, hMultiplier, hPowerOf10) + ldh a, [hDivisor] ; (aliases: hDivisor, hMultiplier, hPowerOf10) ld c, a - ld a, [hDividend] ; (aliases: hProduct, hPastLeadingZeros, hQuotient) + ldh a, [hDividend] ; (aliases: hProduct, hPastLeadingZeros, hQuotient) sbc c jr c, .asm_37dce - ld [hDividend], a ; (aliases: hProduct, hPastLeadingZeros, hQuotient) + ldh [hDividend], a ; (aliases: hProduct, hPastLeadingZeros, hQuotient) ld a, d - ld [hDividend+1], a ; (aliases: hMultiplicand) - ld a, [hDivideBuffer+4] + ldh [hDividend+1], a ; (aliases: hMultiplicand) + ldh a, [hDivideBuffer+4] inc a - ld [hDivideBuffer+4], a + ldh [hDivideBuffer+4], a jr .asm_37db3 .asm_37dce ld a, b cp $1 jr z, .asm_37e18 - ld a, [hDivideBuffer+4] + ldh a, [hDivideBuffer+4] sla a - ld [hDivideBuffer+4], a - ld a, [hDivideBuffer+3] + ldh [hDivideBuffer+4], a + ldh a, [hDivideBuffer+3] rl a - ld [hDivideBuffer+3], a - ld a, [hDivideBuffer+2] + ldh [hDivideBuffer+3], a + ldh a, [hDivideBuffer+2] rl a - ld [hDivideBuffer+2], a - ld a, [hDivideBuffer+1] + ldh [hDivideBuffer+2], a + ldh a, [hDivideBuffer+1] rl a - ld [hDivideBuffer+1], a + ldh [hDivideBuffer+1], a dec e jr nz, .asm_37e04 ld a, $8 ld e, a - ld a, [hDivideBuffer] - ld [hDivisor], a ; (aliases: hDivisor, hMultiplier, hPowerOf10) + ldh a, [hDivideBuffer] + ldh [hDivisor], a ; (aliases: hDivisor, hMultiplier, hPowerOf10) xor a - ld [hDivideBuffer], a - ld a, [hDividend+1] ; (aliases: hMultiplicand) - ld [hDividend], a ; (aliases: hProduct, hPastLeadingZeros, hQuotient) - ld a, [hDividend+2] - ld [hDividend+1], a ; (aliases: hMultiplicand) - ld a, [hDividend+3] - ld [hDividend+2], a + ldh [hDivideBuffer], a + ldh a, [hDividend+1] ; (aliases: hMultiplicand) + ldh [hDividend], a ; (aliases: hProduct, hPastLeadingZeros, hQuotient) + ldh a, [hDividend+2] + ldh [hDividend+1], a ; (aliases: hMultiplicand) + ldh a, [hDividend+3] + ldh [hDividend+2], a .asm_37e04 ld a, e cp $1 jr nz, .asm_37e0a dec b .asm_37e0a - ld a, [hDivisor] ; (aliases: hDivisor, hMultiplier, hPowerOf10) + ldh a, [hDivisor] ; (aliases: hDivisor, hMultiplier, hPowerOf10) srl a - ld [hDivisor], a ; (aliases: hDivisor, hMultiplier, hPowerOf10) - ld a, [hDivideBuffer] + ldh [hDivisor], a ; (aliases: hDivisor, hMultiplier, hPowerOf10) + ldh a, [hDivideBuffer] rr a - ld [hDivideBuffer], a + ldh [hDivideBuffer], a jr .asm_37db3 .asm_37e18 - ld a, [hDividend+1] ; (aliases: hMultiplicand) - ld [hRemainder], a ; (aliases: hDivisor, hMultiplier, hPowerOf10) - ld a, [hDivideBuffer+4] - ld [hQuotient+3], a - ld a, [hDivideBuffer+3] - ld [hQuotient+2], a - ld a, [hDivideBuffer+2] - ld [hQuotient+1], a ; (aliases: hMultiplicand) - ld a, [hDivideBuffer+1] - ld [hDividend], a ; (aliases: hProduct, hPastLeadingZeros, hQuotient) + ldh a, [hDividend+1] ; (aliases: hMultiplicand) + ldh [hRemainder], a ; (aliases: hDivisor, hMultiplier, hPowerOf10) + ldh a, [hDivideBuffer+4] + ldh [hQuotient+3], a + ldh a, [hDivideBuffer+3] + ldh [hQuotient+2], a + ldh a, [hDivideBuffer+2] + ldh [hQuotient+1], a ; (aliases: hMultiplicand) + ldh a, [hDivideBuffer+1] + ldh [hDividend], a ; (aliases: hProduct, hPastLeadingZeros, hQuotient) ret diff --git a/engine/math/random.asm b/engine/math/random.asm index 2fc83f6f..c8760157 100755 --- a/engine/math/random.asm +++ b/engine/math/random.asm @@ -1,13 +1,13 @@ Random_:: ; Generate a random 16-bit value. - ld a, [rDIV] + ldh a, [rDIV] ld b, a - ld a, [hRandomAdd] + ldh a, [hRandomAdd] adc b - ld [hRandomAdd], a - ld a, [rDIV] + ldh [hRandomAdd], a + ldh a, [rDIV] ld b, a - ld a, [hRandomSub] + ldh a, [hRandomSub] sbc b - ld [hRandomSub], a + ldh [hRandomSub], a ret diff --git a/engine/menus/display_text_id_init.asm b/engine/menus/display_text_id_init.asm index c02e5bbc..6ce76e7f 100644 --- a/engine/menus/display_text_id_init.asm +++ b/engine/menus/display_text_id_init.asm @@ -5,7 +5,7 @@ DisplayTextIDInit:: ld a, [wAutoTextBoxDrawingControl] bit 0, a jr nz, .skipDrawingTextBoxBorder - ld a, [hSpriteIndexOrTextID] ; text ID (or sprite ID) + ldh a, [hSpriteIndexOrTextID] ; text ID (or sprite ID) and a jr nz, .notStartMenu ; if text ID is 0 (i.e. the start menu) @@ -13,18 +13,18 @@ DisplayTextIDInit:: ; below this, so this seems unnecessary. CheckEvent EVENT_GOT_POKEDEX ; start menu with pokedex - coord hl, 10, 0 + hlcoord 10, 0 ld b, $0e ld c, $08 jr nz, .drawTextBoxBorder ; start menu without pokedex - coord hl, 10, 0 + hlcoord 10, 0 ld b, $0c ld c, $08 jr .drawTextBoxBorder ; if text ID is not 0 (i.e. not the start menu) then do a standard dialogue text box .notStartMenu - coord hl, 0, 12 + hlcoord 0, 12 ld b, $04 ld c, $12 .drawTextBoxBorder @@ -38,16 +38,17 @@ DisplayTextIDInit:: jr nz, .skipMovingSprites call UpdateSprites .skipMovingSprites -; loop to copy C1X9 (direction the sprite is facing) to C2X9 for each sprite +; loop to copy [x#SPRITESTATEDATA1_FACINGDIRECTION] to +; [x#SPRITESTATEDATA2_ORIGFACINGDIRECTION] for each non-player sprite ; this is done because when you talk to an NPC, they turn to look your way ; the original direction they were facing must be restored after the dialogue is over ld hl, wSprite01StateData1FacingDirection ld c, $0f ld de, $10 .spriteFacingDirectionCopyLoop - ld a, [hl] + ld a, [hl] ; x#SPRITESTATEDATA1_FACINGDIRECTION inc h - ld [hl], a + ld [hl], a ; [x#SPRITESTATEDATA2_ORIGFACINGDIRECTION] dec h add hl, de dec c @@ -71,8 +72,8 @@ DisplayTextIDInit:: ld b, $9c ; window background address call CopyScreenTileBufferToVRAM ; transfer background in WRAM to VRAM xor a - ld [hWY], a ; put the window on the screen + ldh [hWY], a ; put the window on the screen call LoadFontTilePatterns 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 diff --git a/engine/menus/draw_badges.asm b/engine/menus/draw_badges.asm index 1888e32f..a74497c1 100644 --- a/engine/menus/draw_badges.asm +++ b/engine/menus/draw_badges.asm @@ -43,11 +43,11 @@ DrawBadges: ld [hli], a ld [hl], $60 ; First name - coord hl, 2, 11 + hlcoord 2, 11 ld de, wTempObtainedBadgesBooleans call .DrawBadgeRow - coord hl, 2, 14 + hlcoord 2, 14 ld de, wTempObtainedBadgesBooleans + 4 ; call .DrawBadgeRow ; ret diff --git a/engine/menus/draw_start_menu.asm b/engine/menus/draw_start_menu.asm index 21e444e9..00d385bc 100644 --- a/engine/menus/draw_start_menu.asm +++ b/engine/menus/draw_start_menu.asm @@ -2,12 +2,12 @@ DrawStartMenu:: CheckEvent EVENT_GOT_POKEDEX ; menu with pokedex - coord hl, 10, 0 + hlcoord 10, 0 ld b, $0e ld c, $08 jr nz, .drawTextBoxBorder ; shorter menu if the player doesn't have the pokedex - coord hl, 10, 0 + hlcoord 10, 0 ld b, $0c ld c, $08 .drawTextBoxBorder @@ -25,7 +25,7 @@ DrawStartMenu:: ld [wMenuWatchMovingOutOfBounds], a ld hl, wd730 set 6, [hl] ; no pauses between printing each letter - coord hl, 12, 2 + hlcoord 12, 2 CheckEvent EVENT_GOT_POKEDEX ; case for not having pokedex ld a, $06 diff --git a/engine/menus/league_pc.asm b/engine/menus/league_pc.asm index c07c6bc1..f2107c49 100755 --- a/engine/menus/league_pc.asm +++ b/engine/menus/league_pc.asm @@ -6,10 +6,10 @@ PKMNLeaguePC: push hl ld a, [wUpdateSpritesEnabled] push af - ld a, [hTilesetType] + ldh a, [hTilesetType] push af xor a - ld [hTilesetType], a + ldh [hTilesetType], a ld [wSpriteFlipped], a ld [wUpdateSpritesEnabled], a ld [wHoFTeamIndex2], a @@ -29,7 +29,7 @@ PKMNLeaguePC: push bc ld a, [wHoFTeamIndex2] ld [wHoFTeamIndex], a - callba LoadHallOfFameTeams + farcall LoadHallOfFameTeams call LeaguePCShowTeam pop bc jr c, .doneShowingTeams @@ -40,7 +40,7 @@ PKMNLeaguePC: jr nz, .loop .doneShowingTeams pop af - ld [hTilesetType], a + ldh [hTilesetType], a pop af ld [wUpdateSpritesEnabled], a pop hl @@ -56,7 +56,7 @@ LeaguePCShowTeam: push bc call LeaguePCShowMon call WaitForTextScrollButtonPress - ld a, [hJoyHeld] + ldh a, [hJoyHeld] bit 1, a jr nz, .exit ld hl, wHallOfFame + HOF_MON @@ -95,22 +95,22 @@ LeaguePCShowMon: ld b, SET_PAL_POKEMON_WHOLE_SCREEN ld c, 0 call RunPaletteCommand - coord hl, 12, 5 + hlcoord 12, 5 call GetMonHeader call LoadFrontSpriteByMonIndex call GBPalNormal - coord hl, 0, 13 + hlcoord 0, 13 ld b, 2 ld c, $12 call TextBoxBorder - coord hl, 1, 15 + hlcoord 1, 15 ld de, HallOfFameNoText call PlaceString - coord hl, 16, 15 + hlcoord 16, 15 ld de, wHoFTeamNo lb bc, 1, 3 call PrintNumber - jpba HoFDisplayMonInfo + farjp HoFDisplayMonInfo HallOfFameNoText: db "HALL OF FAME No @" diff --git a/engine/menus/main_menu.asm b/engine/menus/main_menu.asm index 43289ce8..d2776240 100755 --- a/engine/menus/main_menu.asm +++ b/engine/menus/main_menu.asm @@ -33,20 +33,20 @@ MainMenu: cp 1 jr z, .noSaveFile ; there's a save file - coord hl, 0, 0 + hlcoord 0, 0 ld b, 6 ld c, 13 call TextBoxBorder - coord hl, 2, 2 + hlcoord 2, 2 ld de, ContinueText call PlaceString jr .next2 .noSaveFile - coord hl, 0, 0 + hlcoord 0, 0 ld b, 4 ld c, 13 call TextBoxBorder - coord hl, 2, 2 + hlcoord 2, 2 ld de, NewGameText call PlaceString .next2 @@ -94,11 +94,11 @@ MainMenu: set 5, [hl] .inputLoop xor a - ld [hJoyPressed], a - ld [hJoyReleased], a - ld [hJoyHeld], a + ldh [hJoyPressed], a + ldh [hJoyReleased], a + ldh [hJoyHeld], a call Joypad - ld a, [hJoyHeld] + ldh a, [hJoyHeld] bit 0, a jr nz, .pressedA bit 1, a @@ -141,12 +141,12 @@ LinkMenu: call SaveScreenTilesToBuffer1 ld hl, WhereWouldYouLikeText call PrintText - coord hl, 5, 5 + hlcoord 5, 5 ld b, $6 ld c, $d call TextBoxBorder call UpdateSprites - coord hl, 7, 7 + hlcoord 7, 7 ld de, CableClubOptionsText call PlaceString xor 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 ; the enemy and the player both pressed A or B ; The gameboy that is clocking the connection wins. - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] cp USING_INTERNAL_CLOCK jr z, .doneChoosingMenuSelection .useEnemyMenuSelection @@ -214,13 +214,13 @@ LinkMenu: and $3 ld [wCurrentMenuItem], a .doneChoosingMenuSelection - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] cp USING_INTERNAL_CLOCK jr nz, .skipStartingTransfer call DelayFrame call DelayFrame ld a, START_TRANSFER_INTERNAL_CLOCK - ld [rSC], a + ldh [rSC], a .skipStartingTransfer ld b, $7f ld c, $7f @@ -240,11 +240,11 @@ LinkMenu: ld c, d .updateCursorPosition ld a, b - Coorda 6, 7 + ldcoord_a 6, 7 ld a, c - Coorda 6, 9 + ldcoord_a 6, 9 ld a, d - Coorda 6, 11 + ldcoord_a 6, 11 ld c, 40 call DelayFrames call LoadScreenTilesFromBuffer1 @@ -314,9 +314,9 @@ StartNewGame: ; enter map after using a special warp or loading the game from the main menu SpecialEnterMap:: xor a - ld [hJoyPressed], a - ld [hJoyHeld], a - ld [hJoy5], a + ldh [hJoyPressed], a + ldh [hJoyHeld], a + ldh [hJoy5], a ld [wd72d], a ld hl, wd732 set 0, [hl] ; count play time @@ -344,51 +344,51 @@ CableClubOptionsText: DisplayContinueGameInfo: xor a - ld [hAutoBGTransferEnabled], a - coord hl, 4, 7 + ldh [hAutoBGTransferEnabled], a + hlcoord 4, 7 ld b, 8 ld c, 14 call TextBoxBorder - coord hl, 5, 9 + hlcoord 5, 9 ld de, SaveScreenInfoText call PlaceString - coord hl, 12, 9 + hlcoord 12, 9 ld de, wPlayerName call PlaceString - coord hl, 17, 11 + hlcoord 17, 11 call PrintNumBadges - coord hl, 16, 13 + hlcoord 16, 13 call PrintNumOwnedMons - coord hl, 13, 15 + hlcoord 13, 15 call PrintPlayTime ld a, 1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ld c, 30 jp DelayFrames PrintSaveScreenText: xor a - ld [hAutoBGTransferEnabled], a - coord hl, 4, 0 + ldh [hAutoBGTransferEnabled], a + hlcoord 4, 0 ld b, $8 ld c, $e call TextBoxBorder call LoadTextBoxTilePatterns call UpdateSprites - coord hl, 5, 2 + hlcoord 5, 2 ld de, SaveScreenInfoText call PlaceString - coord hl, 12, 2 + hlcoord 12, 2 ld de, wPlayerName call PlaceString - coord hl, 17, 4 + hlcoord 17, 4 call PrintNumBadges - coord hl, 16, 6 + hlcoord 16, 6 call PrintNumOwnedMons - coord hl, 13, 8 + hlcoord 13, 8 call PrintPlayTime ld a, $1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ld c, 30 jp DelayFrames @@ -429,28 +429,28 @@ SaveScreenInfoText: next "TIME@" DisplayOptionMenu: - coord hl, 0, 0 + hlcoord 0, 0 ld b, 3 ld c, 18 call TextBoxBorder - coord hl, 0, 5 + hlcoord 0, 5 ld b, 3 ld c, 18 call TextBoxBorder - coord hl, 0, 10 + hlcoord 0, 10 ld b, 3 ld c, 18 call TextBoxBorder - coord hl, 1, 1 + hlcoord 1, 1 ld de, TextSpeedOptionText call PlaceString - coord hl, 1, 6 + hlcoord 1, 6 ld de, BattleAnimationOptionText call PlaceString - coord hl, 1, 11 + hlcoord 1, 11 ld de, BattleStyleOptionText call PlaceString - coord hl, 2, 16 + hlcoord 2, 16 ld de, OptionMenuCancelText call PlaceString xor a @@ -465,14 +465,14 @@ DisplayOptionMenu: ld a, [wOptionsTextSpeedCursorX] ; text speed cursor X coordinate ld [wTopMenuItemX], a ld a, $01 - ld [hAutoBGTransferEnabled], a ; enable auto background transfer + ldh [hAutoBGTransferEnabled], a ; enable auto background transfer call Delay3 .loop call PlaceMenuCursor call SetOptionsFromCursorPositions .getJoypadStateLoop call JoypadLowSensitivity - ld a, [hJoy5] + ldh a, [hJoy5] ld b, a and A_BUTTON | B_BUTTON | START | D_RIGHT | D_LEFT | D_UP | D_DOWN ; any key besides select pressed? jr z, .getJoypadStateLoop @@ -644,7 +644,7 @@ SetCursorPositionsFromOptions: dec hl ld a, [hl] ld [wOptionsTextSpeedCursorX], a ; text speed cursor X coordinate - coord hl, 0, 3 + hlcoord 0, 3 call .placeUnfilledRightArrow sla c ld a, 1 ; On @@ -652,7 +652,7 @@ SetCursorPositionsFromOptions: ld a, 10 ; Off .storeBattleAnimationCursorX ld [wOptionsBattleAnimCursorX], a ; battle animation cursor X coordinate - coord hl, 0, 8 + hlcoord 0, 8 call .placeUnfilledRightArrow sla c ld a, 1 @@ -660,10 +660,10 @@ SetCursorPositionsFromOptions: ld a, 10 .storeBattleStyleCursorX ld [wOptionsBattleStyleCursorX], a ; battle style cursor X coordinate - coord hl, 0, 13 + hlcoord 0, 13 call .placeUnfilledRightArrow ; cursor in front of Cancel - coord hl, 0, 16 + hlcoord 0, 16 ld a, 1 .placeUnfilledRightArrow ld e, a diff --git a/engine/menus/naming_screen.asm b/engine/menus/naming_screen.asm index a84609c9..8ca2ec9b 100755 --- a/engine/menus/naming_screen.asm +++ b/engine/menus/naming_screen.asm @@ -4,7 +4,7 @@ AskName: push hl ld a, [wIsInBattle] dec a - coord hl, 0, 0 + hlcoord 0, 0 ld b, 4 ld c, 11 call z, ClearScreenArea ; only if in wild battle @@ -13,7 +13,7 @@ AskName: call GetMonName ld hl, DoYouWantToNicknameText call PrintText - coord hl, 14, 7 + hlcoord 14, 7 lb bc, 8, 15 ld a, TWO_OPTION_MENU ld [wTextBoxID], a @@ -92,8 +92,8 @@ DisplayNamingScreen: call RunPaletteCommand call LoadHpBarAndStatusTilePatterns call LoadEDTile - callba LoadMonPartySpriteGfx - coord hl, 0, 4 + farcall LoadMonPartySpriteGfx + hlcoord 0, 4 ld b, 9 ld c, 18 call TextBoxBorder @@ -128,11 +128,11 @@ DisplayNamingScreen: .inputLoop ld a, [wCurrentMenuItem] push af - callba AnimatePartyMon_ForceSpeed1 + farcall AnimatePartyMon_ForceSpeed1 pop af ld [wCurrentMenuItem], a call JoypadLowSensitivity - ld a, [hJoyPressed] + ldh a, [hJoyPressed] and a jr z, .inputLoop ld hl, .namingScreenButtonFunctions @@ -172,7 +172,7 @@ DisplayNamingScreen: ld a, [wIsInBattle] and a jp z, LoadTextBoxTilePatterns - jpab LoadHudTilePatterns + jpfar LoadHudTilePatterns .namingScreenButtonFunctions dw .dPadReturnPoint @@ -325,7 +325,7 @@ DisplayNamingScreen: LoadEDTile: ld de, ED_Tile - ld hl, vFont + $700 + ld hl, vFont tile $70 ld bc, (ED_TileEnd - ED_Tile) / $8 ; to fix the graphical bug on poor emulators ;lb bc, BANK(ED_Tile), (ED_TileEnd - ED_Tile) / $8 @@ -337,14 +337,14 @@ ED_TileEnd: PrintAlphabet: xor a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ld a, [wAlphabetCase] and a ld de, LowerCaseAlphabet jr nz, .lowercase ld de, UpperCaseAlphabet .lowercase - coord hl, 2, 5 + hlcoord 2, 5 lb bc, 5, 9 ; 5 rows, 9 columns .outerLoop push bc @@ -362,7 +362,7 @@ PrintAlphabet: jr nz, .outerLoop call PlaceString ld a, $1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a jp Delay3 INCLUDE "data/text/alphabets.asm" @@ -371,13 +371,13 @@ PrintNicknameAndUnderscores: call CalcStringLength ld a, c ld [wNamingScreenNameLength], a - coord hl, 10, 2 + hlcoord 10, 2 lb bc, 1, 10 call ClearScreenArea - coord hl, 10, 2 + hlcoord 10, 2 ld de, wcf4b call PlaceString - coord hl, 10, 3 + hlcoord 10, 3 ld a, [wNamingScreenType] cp NAME_MON_SCREEN jr nc, .pokemon1 @@ -416,7 +416,7 @@ PrintNicknameAndUnderscores: .emptySpacesRemaining ld c, a ld b, $0 - coord hl, 10, 3 + hlcoord 10, 3 add hl, bc ld [hl], $77 ; raised underscore tile id ret @@ -450,7 +450,7 @@ CalcStringLength: jr .loop PrintNamingText: - coord hl, 0, 1 + hlcoord 0, 1 ld a, [wNamingScreenType] ld de, YourTextString and a @@ -461,16 +461,16 @@ PrintNamingText: ld a, [wcf91] ld [wMonPartySpriteSpecies], a push af - callba WriteMonPartySpriteOAMBySpecies + farcall WriteMonPartySpriteOAMBySpecies pop af ld [wd11e], a call GetMonName - coord hl, 4, 1 + hlcoord 4, 1 call PlaceString ld hl, $1 add hl, bc ld [hl], $c9 - coord hl, 1, 3 + hlcoord 1, 3 ld de, NicknameTextString jr .placeString .notNickname diff --git a/engine/menus/party_menu.asm b/engine/menus/party_menu.asm index f63a3cf0..14216b64 100755 --- a/engine/menus/party_menu.asm +++ b/engine/menus/party_menu.asm @@ -19,22 +19,22 @@ ; f8: leveled up DrawPartyMenu_:: xor a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a call ClearScreen call UpdateSprites - callba LoadMonPartySpriteGfxWithLCDDisabled ; load pokemon icon graphics + farcall LoadMonPartySpriteGfxWithLCDDisabled ; load pokemon icon graphics RedrawPartyMenu_:: ld a, [wPartyMenuTypeOrMessageID] cp SWAP_MONS_PARTY_MENU jp z, .printMessage call ErasePartyMenuCursors - callba InitPartyMenuBlkPacket - coord hl, 3, 0 + farcall InitPartyMenuBlkPacket + hlcoord 3, 0 ld de, wPartySpecies xor a ld c, a - ld [hPartyMonIndex], a + ldh [hPartyMonIndex], a ld [wWhichPartyMenuHPBar], a .loop ld a, [de] @@ -49,11 +49,11 @@ RedrawPartyMenu_:: call GetPartyMonName pop hl call PlaceString ; print the pokemon's name - callba WriteMonPartySpriteOAMByPartyIndex ; place the appropriate pokemon icon - ld a, [hPartyMonIndex] + farcall WriteMonPartySpriteOAMByPartyIndex ; place the appropriate pokemon icon + ldh a, [hPartyMonIndex] ld [wWhichPokemon], a inc a - ld [hPartyMonIndex], a + ldh [hPartyMonIndex], a call LoadMonData pop hl push hl @@ -88,14 +88,14 @@ RedrawPartyMenu_:: pop hl push hl ld bc, SCREEN_WIDTH + 1 ; down 1 row and right 1 column - ld a, [hFlagsFFF6] + ldh a, [hFlagsFFF6] set 0, a - ld [hFlagsFFF6], a + ldh [hFlagsFFF6], a add hl, bc predef DrawHP2 ; draw HP bar and prints current / max HP - ld a, [hFlagsFFF6] + ldh a, [hFlagsFFF6] res 0, a - ld [hFlagsFFF6], a + ldh [hFlagsFFF6], a call SetPartyMenuHPBarColor ; color the HP bar (on SGB) pop hl jr .printLevel @@ -213,7 +213,7 @@ RedrawPartyMenu_:: pop af ld [hl], a ld a, 1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a call Delay3 jp GBPalNormal .printItemUseMessage diff --git a/engine/menus/pc.asm b/engine/menus/pc.asm index f296ad61..4c340e7b 100755 --- a/engine/menus/pc.asm +++ b/engine/menus/pc.asm @@ -10,7 +10,7 @@ ActivatePC:: call LoadScreenTilesFromBuffer2 call Delay3 PCMainMenu: - callba DisplayPCMainMenu + farcall DisplayPCMainMenu ld hl, wFlags_0xcd60 set 5, [hl] call HandleMenuInput @@ -56,19 +56,19 @@ PCMainMenu: call WaitForSoundToFinish ld hl, AccessedMyPCText call PrintText - callba PlayerPC + farcall PlayerPC jr ReloadMainMenu OaksPC: ld a, SFX_ENTER_PC call PlaySound call WaitForSoundToFinish - callba OpenOaksPC + farcall OpenOaksPC jr ReloadMainMenu PKMNLeague: ld a, SFX_ENTER_PC call PlaySound call WaitForSoundToFinish - callba PKMNLeaguePC + farcall PKMNLeaguePC jr ReloadMainMenu BillsPC: ld a, SFX_ENTER_PC @@ -82,7 +82,7 @@ BillsPC: ld hl, AccessedBillsPCText .printText call PrintText - callba BillsPC_ + farcall BillsPC_ ReloadMainMenu: xor a ld [wDoNotWaitForButtonPressAfterDisplayingText], a @@ -117,10 +117,10 @@ AccessedMyPCText: ; removes one of the specified item ID [hItemToRemoveID] from bag (if existent) RemoveItemByID:: ld hl, wBagItems - ld a, [hItemToRemoveID] + ldh a, [hItemToRemoveID] ld b, a xor a - ld [hItemToRemoveIndex], a + ldh [hItemToRemoveIndex], a .loop ld a, [hli] cp -1 ; reached terminator? @@ -128,14 +128,14 @@ RemoveItemByID:: cp b jr z, .foundItem inc hl - ld a, [hItemToRemoveIndex] + ldh a, [hItemToRemoveIndex] inc a - ld [hItemToRemoveIndex], a + ldh [hItemToRemoveIndex], a jr .loop .foundItem ld a, $1 ld [wItemQuantity], a - ld a, [hItemToRemoveIndex] + ldh a, [hItemToRemoveIndex] ld [wWhichPokemon], a ld hl, wNumBagItems jp RemoveItemFromInventory diff --git a/engine/menus/players_pc.asm b/engine/menus/players_pc.asm index ebaacd52..5461be51 100755 --- a/engine/menus/players_pc.asm +++ b/engine/menus/players_pc.asm @@ -22,12 +22,12 @@ PlayerPCMenu: ld hl, wFlags_0xcd60 set 5, [hl] call LoadScreenTilesFromBuffer2 - coord hl, 0, 0 + hlcoord 0, 0 ld b, $8 ld c, $e call TextBoxBorder call UpdateSprites - coord hl, 2, 2 + hlcoord 2, 2 ld de, PlayersPCMenuEntries call PlaceString ld hl, wTopMenuItemY diff --git a/engine/menus/pokedex.asm b/engine/menus/pokedex.asm index 542ef873..53719712 100755 --- a/engine/menus/pokedex.asm +++ b/engine/menus/pokedex.asm @@ -10,11 +10,11 @@ ShowPokedexMenu: ld [wLastMenuItem], a inc a ld [wd11e], a - ld [hJoy7], a + ldh [hJoy7], a .setUpGraphics ld b, SET_PAL_GENERIC call RunPaletteCommand - callab LoadPokedexTilePatterns + callfar LoadPokedexTilePatterns .doPokemonListMenu ld hl, wTopMenuItemY ld a, 3 @@ -35,7 +35,7 @@ ShowPokedexMenu: ld [wMenuWatchMovingOutOfBounds], a ld [wCurrentMenuItem], a ld [wLastMenuItem], a - ld [hJoy7], a + ldh [hJoy7], a ld [wWastedByteCD3A], a ld [wOverrideSimulatedJoypadStatesMask], a pop af @@ -119,7 +119,7 @@ HandlePokedexSideMenu: pop af ld [wCurrentMenuItem], a push bc - coord hl, 0, 3 + hlcoord 0, 3 ld de, 20 lb bc, " ", 13 call DrawTileLine ; cover up the menu cursor in the pokemon list @@ -128,7 +128,7 @@ HandlePokedexSideMenu: .buttonBPressed push bc - coord hl, 15, 10 + hlcoord 15, 10 ld de, 20 lb bc, " ", 7 call DrawTileLine ; cover up the menu cursor in the side menu @@ -156,45 +156,45 @@ HandlePokedexSideMenu: ; sets carry flag if player presses A, unsets carry flag if player presses B HandlePokedexListMenu: xor a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ; draw the horizontal line separating the seen and owned amounts from the menu - coord hl, 15, 8 + hlcoord 15, 8 ld a, "─" ld [hli], a ld [hli], a ld [hli], a ld [hli], a ld [hli], a - coord hl, 14, 0 + hlcoord 14, 0 ld [hl], $71 ; vertical line tile - coord hl, 14, 1 + hlcoord 14, 1 call DrawPokedexVerticalLine - coord hl, 14, 9 + hlcoord 14, 9 call DrawPokedexVerticalLine ld hl, wPokedexSeen ld b, wPokedexSeenEnd - wPokedexSeen call CountSetBits ld de, wNumSetBits - coord hl, 16, 3 + hlcoord 16, 3 lb bc, 1, 3 call PrintNumber ; print number of seen pokemon ld hl, wPokedexOwned ld b, wPokedexOwnedEnd - wPokedexOwned call CountSetBits ld de, wNumSetBits - coord hl, 16, 6 + hlcoord 16, 6 lb bc, 1, 3 call PrintNumber ; print number of owned pokemon - coord hl, 16, 2 + hlcoord 16, 2 ld de, PokedexSeenText call PlaceString - coord hl, 16, 5 + hlcoord 16, 5 ld de, PokedexOwnText call PlaceString - coord hl, 1, 1 + hlcoord 1, 1 ld de, PokedexContentsText call PlaceString - coord hl, 16, 10 + hlcoord 16, 10 ld de, PokedexMenuItemsText call PlaceString ; find the highest pokedex number among the pokemon the player has seen @@ -216,11 +216,11 @@ HandlePokedexListMenu: ld [wDexMaxSeenMon], a .loop xor a - ld [hAutoBGTransferEnabled], a - coord hl, 4, 2 + ldh [hAutoBGTransferEnabled], a + hlcoord 4, 2 lb bc, 14, 10 call ClearScreenArea - coord hl, 1, 3 + hlcoord 1, 3 ld a, [wListScrollOffset] ld [wd11e], a ld d, 7 @@ -280,7 +280,7 @@ HandlePokedexListMenu: dec d jr nz, .printPokemonLoop ld a, 01 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a call Delay3 call GBPalNormal call HandleMenuInput @@ -393,14 +393,14 @@ ShowPokedexData: call GBPalWhiteOutWithDelay3 call ClearScreen call UpdateSprites - callab LoadPokedexTilePatterns ; load pokedex tiles + callfar LoadPokedexTilePatterns ; load pokedex tiles ; function to display pokedex data from inside the pokedex ShowPokedexDataInternal: ld hl, wd72c set 1, [hl] ld a, $33 ; 3/7 volume - ld [rNR50], a + ldh [rNR50], a call GBPalWhiteOut ; zero all palettes call ClearScreen ld a, [wd11e] ; pokemon ID @@ -410,48 +410,48 @@ ShowPokedexDataInternal: call RunPaletteCommand pop af ld [wd11e], a - ld a, [hTilesetType] + ldh a, [hTilesetType] push af xor a - ld [hTilesetType], a + ldh [hTilesetType], a - coord hl, 0, 0 + hlcoord 0, 0 ld de, 1 lb bc, $64, SCREEN_WIDTH call DrawTileLine ; draw top border - coord hl, 0, 17 + hlcoord 0, 17 ld b, $6f call DrawTileLine ; draw bottom border - coord hl, 0, 1 + hlcoord 0, 1 ld de, 20 lb bc, $66, $10 call DrawTileLine ; draw left border - coord hl, 19, 1 + hlcoord 19, 1 ld b, $67 call DrawTileLine ; draw right border ld a, $63 ; upper left corner tile - Coorda 0, 0 + ldcoord_a 0, 0 ld a, $65 ; upper right corner tile - Coorda 19, 0 + ldcoord_a 19, 0 ld a, $6c ; lower left corner tile - Coorda 0, 17 + ldcoord_a 0, 17 ld a, $6e ; lower right corner tile - Coorda 19, 17 + ldcoord_a 19, 17 - coord hl, 0, 9 + hlcoord 0, 9 ld de, PokedexDataDividerLine call PlaceString ; draw horizontal divider line - coord hl, 9, 6 + hlcoord 9, 6 ld de, HeightWeightText call PlaceString call GetMonName - coord hl, 9, 2 + hlcoord 9, 2 call PlaceString ld hl, PokedexEntryPointers @@ -465,7 +465,7 @@ ShowPokedexDataInternal: ld e, a ld d, [hl] ; de = address of pokedex entry - coord hl, 9, 4 + hlcoord 9, 4 call PlaceString ; print species name ld h, b @@ -475,7 +475,7 @@ ShowPokedexDataInternal: push af call IndexToPokedex - coord hl, 2, 8 + hlcoord 2, 8 ld a, "№" ld [hli], a ld a, "<DOT>" @@ -500,7 +500,7 @@ ShowPokedexDataInternal: call Delay3 call GBPalNormal call GetMonHeader ; load pokemon picture location - coord hl, 1, 1 + hlcoord 1, 1 call LoadFlippedFrontSpriteByMonIndex ; draw pokemon picture ld a, [wcf91] call PlayCry ; play pokemon cry @@ -515,14 +515,14 @@ ShowPokedexDataInternal: jp z, .waitForButtonPress ; if the pokemon has not been owned, don't print the height, weight, or description inc de ; de = address of feet (height) ld a, [de] ; reads feet, but a is overwritten without being used - coord hl, 12, 6 + hlcoord 12, 6 lb bc, 1, 2 call PrintNumber ; print feet (height) ld a, "′" ld [hl], a inc de inc de ; de = address of inches (height) - coord hl, 15, 6 + hlcoord 15, 6 lb bc, LEADING_ZEROES | 1, 2 call PrintNumber ; print inches (height) ld a, "″" @@ -544,13 +544,13 @@ ShowPokedexDataInternal: ld a, [de] ; a = lower byte of weight ld [hl], a ; store lower byte of weight in [hDexWeight + 1] ld de, hDexWeight - coord hl, 11, 8 + hlcoord 11, 8 lb bc, 2, 5 ; 2 bytes, 5 digits call PrintNumber ; print weight - coord hl, 14, 8 - ld a, [hDexWeight + 1] + hlcoord 14, 8 + ldh a, [hDexWeight + 1] sub 10 - ld a, [hDexWeight] + ldh a, [hDexWeight] sbc 0 jr nc, .next 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 [hl], "<DOT>" ; decimal point tile pop af - ld [hDexWeight + 1], a ; restore original value of [hDexWeight + 1] + ldh [hDexWeight + 1], a ; restore original value of [hDexWeight + 1] pop af - ld [hDexWeight], a ; restore original value of [hDexWeight] + ldh [hDexWeight], a ; restore original value of [hDexWeight] pop hl inc hl ; hl = address of pokedex description text - coord bc, 1, 11 + bccoord 1, 11 ld a, %10 - ld [hClearLetterPrintingDelayFlags], a + ldh [hClearLetterPrintingDelayFlags], a call TextCommandProcessor ; print pokedex description text xor a - ld [hClearLetterPrintingDelayFlags], a + ldh [hClearLetterPrintingDelayFlags], a .waitForButtonPress call JoypadLowSensitivity - ld a, [hJoy5] + ldh a, [hJoy5] and A_BUTTON | B_BUTTON jr z, .waitForButtonPress pop af - ld [hTilesetType], a + ldh [hTilesetType], a call GBPalWhiteOut call ClearScreen call RunDefaultPaletteCommand @@ -586,7 +586,7 @@ ShowPokedexDataInternal: ld hl, wd72c res 1, [hl] ld a, $77 ; max volume - ld [rNR50], a + ldh [rNR50], a ret HeightWeightText: diff --git a/engine/menus/save.asm b/engine/menus/save.asm index 462e0eea..45fed8a6 100755 --- a/engine/menus/save.asm +++ b/engine/menus/save.asm @@ -70,7 +70,7 @@ LoadSAV0: ld bc, wSpriteDataEnd - wSpriteDataStart call CopyData ld a, [sTilesetType] - ld [hTilesetType], a + ldh [hTilesetType], a ld hl, sCurBoxData ld de, wBoxDataStart ld bc, wBoxDataEnd - wBoxDataStart @@ -138,7 +138,7 @@ LoadSAVIgnoreBadCheckSum: jp LoadSAV2 SaveSAV: - callba PrintSaveScreenText + farcall PrintSaveScreenText ld hl, WouldYouLikeToSaveText call SaveSAVConfirm and a ;|0 = Yes|1 = No| @@ -154,10 +154,10 @@ SaveSAV: ret nz .save call SaveSAVtoSRAM - coord hl, 1, 13 + hlcoord 1, 13 lb bc, 4, 18 call ClearScreenArea - coord hl, 1, 14 + hlcoord 1, 14 ld de, NowSavingString call PlaceString ld c, 120 @@ -175,7 +175,7 @@ NowSavingString: SaveSAVConfirm: call PrintText - coord hl, 0, 7 + hlcoord 0, 7 lb bc, 8, 1 ld a, TWO_OPTION_MENU ld [wTextBoxID], a @@ -217,7 +217,7 @@ SaveSAVtoSRAM0: ld de, sCurBoxData ld bc, wBoxDataEnd - wBoxDataStart call CopyData - ld a, [hTilesetType] + ldh a, [hTilesetType] ld [sTilesetType], a ld hl, sPlayerName ld bc, sMainDataCheckSum - sPlayerName @@ -420,7 +420,7 @@ CopyBoxToOrFromSRAM: DisplayChangeBoxMenu: xor a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ld a, A_BUTTON | B_BUTTON ld [wMenuWatchedKeys], a ld a, 11 @@ -435,20 +435,20 @@ DisplayChangeBoxMenu: and $7f ld [wCurrentMenuItem], a ld [wLastMenuItem], a - coord hl, 0, 0 + hlcoord 0, 0 ld b, 2 ld c, 9 call TextBoxBorder ld hl, ChooseABoxText call PrintText - coord hl, 11, 0 + hlcoord 11, 0 ld b, 12 ld c, 7 call TextBoxBorder ld hl, hFlagsFFF6 set 2, [hl] ld de, BoxNames - coord hl, 13, 1 + hlcoord 13, 1 call PlaceString ld hl, hFlagsFFF6 res 2, [hl] @@ -457,19 +457,19 @@ DisplayChangeBoxMenu: cp 9 jr c, .singleDigitBoxNum sub 9 - coord hl, 8, 2 + hlcoord 8, 2 ld [hl], "1" add "0" jr .next .singleDigitBoxNum add "1" .next - Coorda 9, 2 - coord hl, 1, 2 + ldcoord_a 9, 2 + hlcoord 1, 2 ld de, BoxNoText call PlaceString call GetMonCountsForAllBoxes - coord hl, 18, 1 + hlcoord 18, 1 ld de, wBoxMonCounts ld bc, SCREEN_WIDTH ld a, $c @@ -486,7 +486,7 @@ DisplayChangeBoxMenu: dec a jr nz, .loop ld a, 1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ret ChooseABoxText: diff --git a/engine/menus/start_sub_menus.asm b/engine/menus/start_sub_menus.asm index 5182ae79..a845592f 100755 --- a/engine/menus/start_sub_menus.asm +++ b/engine/menus/start_sub_menus.asm @@ -50,7 +50,7 @@ StartMenu_Pokemon:: ld hl, wTopMenuItemY ld a, c ld [hli], a ; top menu item Y - ld a, [hFieldMoveMonMenuTopMenuItemX] + ldh a, [hFieldMoveMonMenuTopMenuItemX] ld [hli], a ; top menu item X xor a ld [hli], a ; current menu item ID @@ -160,7 +160,7 @@ StartMenu_Pokemon:: .surf bit 4, a ; does the player have the Soul Badge? jp z, .newBadgeRequired - callba IsSurfingAllowed + farcall IsSurfingAllowed ld hl, wd728 bit 1, [hl] res 1, [hl] @@ -239,21 +239,21 @@ StartMenu_Pokemon:: ld bc, wPartyMon2 - wPartyMon1 call AddNTimes ld a, [hli] - ld [hDividend], a + ldh [hDividend], a ld a, [hl] - ld [hDividend + 1], a + ldh [hDividend + 1], a ld a, 5 - ld [hDivisor], a + ldh [hDivisor], a ld b, 2 ; number of bytes call Divide ld bc, wPartyMon1HP - wPartyMon1MaxHP add hl, bc ld a, [hld] ld b, a - ld a, [hQuotient + 3] + ldh a, [hQuotient + 3] sub b ld b, [hl] - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] sbc b jp nc, .notHealthyEnough ld a, [wPartyAndBillsPCSavedMenuItem] @@ -285,7 +285,7 @@ StartMenu_Pokemon:: ; writes a blank tile to all possible menu cursor positions on the party menu ErasePartyMenuCursors:: - coord hl, 0, 1 + hlcoord 0, 1 ld bc, 2 * 20 ; menu cursor positions are 2 rows apart ld a, 6 ; 6 menu cursor positions .loop @@ -330,10 +330,10 @@ StartMenu_Item:: .choseItem ; erase menu cursor (blank each tile in front of an item name) ld a, " " - Coorda 5, 4 - Coorda 5, 6 - Coorda 5, 8 - Coorda 5, 10 + ldcoord_a 5, 4 + ldcoord_a 5, 6 + ldcoord_a 5, 8 + ldcoord_a 5, 10 call PlaceUnfilledArrowMenuCursor xor a ld [wMenuItemToSwap], a @@ -454,10 +454,10 @@ StartMenu_TrainerInfo:: call GBPalWhiteOut call ClearScreen call UpdateSprites - ld a, [hTilesetType] + ldh a, [hTilesetType] push af xor a - ld [hTilesetType], a + ldh [hTilesetType], a call DrawTrainerInfo predef DrawBadges ; draw badges ld b, SET_PAL_TRAINER_CARD @@ -471,7 +471,7 @@ StartMenu_TrainerInfo:: call ReloadMapData call LoadGBPal pop af - ld [hTilesetType], a + ldh [hTilesetType], a jp RedisplayStartMenu ; loads tile patterns and draws everything except for gym leader faces / badges @@ -480,44 +480,44 @@ DrawTrainerInfo: lb bc, BANK(RedPicFront), $01 predef DisplayPicCenteredOrUpperRight call DisableLCD - coord hl, 0, 2 + hlcoord 0, 2 ld a, " " call TrainerInfo_DrawVerticalLine - coord hl, 1, 2 + hlcoord 1, 2 call TrainerInfo_DrawVerticalLine - ld hl, vChars2 + $70 - ld de, vChars2 - ld bc, $70 * 4 + ld hl, vChars2 tile $07 + ld de, vChars2 tile $00 + ld bc, $1c tiles call CopyData ld hl, TrainerInfoTextBoxTileGraphics ; trainer info text box tile patterns - ld de, vChars2 + $770 - ld bc, $80 + ld de, vChars2 tile $77 + ld bc, 8 tiles push bc call TrainerInfo_FarCopyData ld hl, BlankLeaderNames - ld de, vChars2 + $600 - ld bc, $170 + ld de, vChars2 tile $60 + ld bc, $17 tiles call TrainerInfo_FarCopyData pop bc ld hl, BadgeNumbersTileGraphics ; badge number tile patterns - ld de, vChars1 + $580 + ld de, vChars1 tile $58 call TrainerInfo_FarCopyData ld hl, GymLeaderFaceAndBadgeTileGraphics ; gym leader face and badge tile patterns - ld de, vChars2 + $200 - ld bc, $400 - ld a, $03 + ld de, vChars2 tile $20 + ld bc, 8 * 8 tiles + ld a, BANK(GymLeaderFaceAndBadgeTileGraphics) call FarCopyData2 ld hl, TextBoxGraphics - ld de, $d0 + ld de, 13 tiles add hl, de ; hl = colon tile pattern - ld de, vChars1 + $560 - ld bc, $10 - ld a, $04 + ld de, vChars1 tile $56 + ld bc, 1 tiles + ld a, BANK(TextBoxGraphics) push bc call FarCopyData2 pop bc - ld hl, TrainerInfoTextBoxTileGraphics + $80 ; background tile pattern - ld de, vChars1 + $570 + ld hl, TrainerInfoTextBoxTileGraphics tile 8 ; background tile pattern + ld de, vChars1 tile $57 call TrainerInfo_FarCopyData call EnableLCD ld hl, wTrainerInfoTextBoxWidthPlus1 @@ -526,7 +526,7 @@ DrawTrainerInfo: dec a ld [hli], a ld [hl], 1 - coord hl, 0, 0 + hlcoord 0, 0 call TrainerInfo_DrawTextBox ld hl, wTrainerInfoTextBoxWidthPlus1 ld a, 16 + 1 @@ -534,27 +534,27 @@ DrawTrainerInfo: dec a ld [hli], a ld [hl], 3 - coord hl, 1, 10 + hlcoord 1, 10 call TrainerInfo_DrawTextBox - coord hl, 0, 10 + hlcoord 0, 10 ld a, $d7 call TrainerInfo_DrawVerticalLine - coord hl, 19, 10 + hlcoord 19, 10 call TrainerInfo_DrawVerticalLine - coord hl, 6, 9 + hlcoord 6, 9 ld de, TrainerInfo_BadgesText call PlaceString - coord hl, 2, 2 + hlcoord 2, 2 ld de, TrainerInfo_NameMoneyTimeText call PlaceString - coord hl, 7, 2 + hlcoord 7, 2 ld de, wPlayerName call PlaceString - coord hl, 8, 4 + hlcoord 8, 4 ld de, wPlayerMoney ld c, $e3 call PrintBCDNumber - coord hl, 9, 6 + hlcoord 9, 6 ld de, wPlayTimeHours ; hours lb bc, LEFT_ALIGN | 1, 3 call PrintNumber @@ -648,10 +648,10 @@ StartMenu_SaveReset:: StartMenu_Option:: xor a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a call ClearScreen call UpdateSprites - callab DisplayOptionMenu + callfar DisplayOptionMenu call LoadScreenTilesFromBuffer2 ; restore saved screen call LoadTextBoxTilePatterns call UpdateSprites @@ -667,7 +667,7 @@ SwitchPartyMon:: SwitchPartyMon_ClearGfx: push af - coord hl, 0, 0 + hlcoord 0, 0 ld bc, SCREEN_WIDTH * 2 call AddNTimes ld c, SCREEN_WIDTH * 2 @@ -737,10 +737,10 @@ SwitchPartyMon_InitVarOrSwapData: inc d .noCarry2 ld a, [hl] - ld [hSwapTemp], a + ldh [hSwapTemp], a ld a, [de] ld [hl], a - ld a, [hSwapTemp] + ldh a, [hSwapTemp] ld [de], a ld hl, wPartyMons ld bc, wPartyMon2 - wPartyMon1 diff --git a/engine/menus/swap_items.asm b/engine/menus/swap_items.asm index 8b793ea1..2d506ce2 100644 --- a/engine/menus/swap_items.asm +++ b/engine/menus/swap_items.asm @@ -77,18 +77,18 @@ HandleItemListSwapping:: cp b jr z, .swapSameItemType .swapDifferentItems - ld [hSwapItemID], a ; save second item ID + ldh [hSwapItemID], a ; save second item ID ld a, [hld] - ld [hSwapItemQuantity], a ; save second item quantity + ldh [hSwapItemQuantity], a ; save second item quantity ld a, [de] ld [hli], a ; put first item ID in second item slot inc de ld a, [de] 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 dec de - ld a, [hSwapItemID] + ldh a, [hSwapItemID] ld [de], a ; put second item ID in first item slot xor a ld [wMenuItemToSwap], a ; 0 means no item is currently being swapped diff --git a/engine/menus/text_box.asm b/engine/menus/text_box.asm index e3de41b4..2e69c5a4 100644 --- a/engine/menus/text_box.asm +++ b/engine/menus/text_box.asm @@ -111,7 +111,7 @@ GetTextBoxIDText: ; hl = address of upper left corner of text box GetAddressOfScreenCoords: push bc - coord hl, 0, 0 + hlcoord 0, 0 ld bc, 20 .loop ; loop to add d rows to the base address ld a, d @@ -274,11 +274,11 @@ DisplayMoneyBox: ld a, MONEY_BOX_TEMPLATE ld [wTextBoxID], a call DisplayTextBoxID - coord hl, 13, 1 + hlcoord 13, 1 ld b, 1 ld c, 6 call ClearScreenArea - coord hl, 12, 1 + hlcoord 12, 1 ld de, wPlayerMoney ld c, $a3 call PrintBCDNumber @@ -578,14 +578,14 @@ DisplayFieldMoveMonMenu: jr nz, .fieldMovesExist ; no field moves - coord hl, 11, 11 + hlcoord 11, 11 ld b, 5 ld c, 7 call TextBoxBorder call UpdateSprites ld a, 12 - ld [hFieldMoveMonMenuTopMenuItemX], a - coord hl, 13, 12 + ldh [hFieldMoveMonMenuTopMenuItemX], a + hlcoord 13, 12 ld de, PokemonMenuEntries jp PlaceString @@ -594,7 +594,7 @@ DisplayFieldMoveMonMenu: ; Calculate the text box position and dimensions based on the leftmost X coord ; of the field move names before adjusting for the number of field moves. - coord hl, 0, 11 + hlcoord 0, 11 ld a, [wFieldMovesLeftmostXCoord] dec a ld e, a @@ -625,7 +625,7 @@ DisplayFieldMoveMonMenu: call UpdateSprites ; Calculate the position of the first field move name to print. - coord hl, 0, 12 + hlcoord 0, 12 ld a, [wFieldMovesLeftmostXCoord] inc a ld e, a @@ -673,8 +673,8 @@ DisplayFieldMoveMonMenu: .donePrintingNames pop hl ld a, [wFieldMovesLeftmostXCoord] - ld [hFieldMoveMonMenuTopMenuItemX], a - coord hl, 0, 12 + ldh [hFieldMoveMonMenuTopMenuItemX], a + hlcoord 0, 12 ld a, [wFieldMovesLeftmostXCoord] inc a ld e, a diff --git a/engine/movie/credits.asm b/engine/movie/credits.asm index d8e593a5..6fb0598e 100755 --- a/engine/movie/credits.asm +++ b/engine/movie/credits.asm @@ -1,25 +1,25 @@ HallOfFamePC: - callba AnimateHallOfFame + farcall AnimateHallOfFame call ClearScreen ld c, 100 call DelayFrames call DisableLCD ld hl, vFont - ld bc, $800 / 2 + ld bc, ($80 tiles) / 2 call ZeroMemory - ld hl, vChars2 + $600 - ld bc, $200 / 2 + ld hl, vChars2 tile $60 + ld bc, ($20 tiles) / 2 call ZeroMemory - ld hl, vChars2 + $7e0 - ld bc, $10 - ld a, $ff + ld hl, vChars2 tile $7e + ld bc, 1 tiles + ld a, $ff ; solid black call FillMemory - coord hl, 0, 0 + hlcoord 0, 0 call FillFourRowsWithBlack - coord hl, 0, 14 + hlcoord 0, 14 call FillFourRowsWithBlack ld a, %11000000 - ld [rBGP], a + ldh [rBGP], a call EnableLCD ld a, SFX_STOP_ALL_MUSIC call PlaySoundWaitForCurrent @@ -38,7 +38,7 @@ FadeInCreditsText: ld b, 4 .loop ld a, [hli] - ld [rBGP], a + ldh [rBGP], a ld c, 5 call DelayFrames dec b @@ -47,7 +47,7 @@ FadeInCreditsText: DisplayCreditsMon: xor a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a call SaveScreenTilesToBuffer1 call FillMiddleOfScreenWithWhite @@ -61,23 +61,23 @@ DisplayCreditsMon: ld a, [hl] ld [wcf91], a ld [wd0b5], a - coord hl, 8, 6 + hlcoord 8, 6 call GetMonHeader call LoadFrontSpriteByMonIndex ld hl, vBGMap0 + $c call CreditsCopyTileMapToVRAM xor a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a call LoadScreenTilesFromBuffer1 ld hl, vBGMap0 call CreditsCopyTileMapToVRAM ld a, $A7 - ld [rWX], a + ldh [rWX], a ld hl, vBGMap1 call CreditsCopyTileMapToVRAM call FillMiddleOfScreenWithWhite ld a, %11111100 ; make the mon a black silhouette - ld [rBGP], a + ldh [rBGP], a ; scroll the mon left by one tile 7 times ld bc, 7 @@ -92,16 +92,16 @@ DisplayCreditsMon: ld c, 20 .scrollLoop2 call ScrollCreditsMonLeft - ld a, [rWX] + ldh a, [rWX] sub 8 - ld [rWX], a + ldh [rWX], a dec c jr nz, .scrollLoop2 xor a - ld [hWY], a + ldh [hWY], a ld a, %11000000 - ld [rBGP], a + ldh [rBGP], a ret INCLUDE "data/credits/credits_mons.asm" @@ -119,13 +119,13 @@ ScrollCreditsMonLeft: ret ScrollCreditsMonLeft_SetSCX: - ld a, [rLY] + ldh a, [rLY] cp l jr nz, ScrollCreditsMonLeft_SetSCX ld a, h - ld [rSCX], a + ldh [rSCX], a .loop - ld a, [rLY] + ldh a, [rLY] cp h jr z, .loop ret @@ -138,11 +138,11 @@ HoFGBPalettes: CreditsCopyTileMapToVRAM: ld a, l - ld [hAutoBGTransferDest], a + ldh [hAutoBGTransferDest], a ld a, h - ld [hAutoBGTransferDest + 1], a + ldh [hAutoBGTransferDest + 1], a ld a, 1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a jp Delay3 ZeroMemory: @@ -162,7 +162,7 @@ FillFourRowsWithBlack: jp FillMemory FillMiddleOfScreenWithWhite: - coord hl, 0, 4 + hlcoord 0, 4 ld bc, SCREEN_WIDTH * 10 ld a, " " jp FillMemory @@ -172,7 +172,7 @@ Credits: push de .nextCreditsScreen pop de - coord hl, 9, 6 + hlcoord 9, 6 push hl call FillMiddleOfScreenWithWhite pop hl @@ -235,7 +235,7 @@ Credits: jr .nextCreditsScreen .showCopyrightText push de - callba LoadCopyrightTiles + farcall LoadCopyrightTiles pop de pop de jr .nextCreditsCommand @@ -245,13 +245,13 @@ Credits: call FillMiddleOfScreenWithWhite pop de ld de, TheEndGfx - ld hl, vChars2 + $600 + ld hl, vChars2 tile $60 lb bc, BANK(TheEndGfx), (TheEndGfxEnd - TheEndGfx) / $10 call CopyVideoData - coord hl, 4, 8 + hlcoord 4, 8 ld de, TheEndTextString call PlaceString - coord hl, 4, 9 + hlcoord 4, 9 inc de call PlaceString jp FadeInCreditsText diff --git a/engine/movie/evolution.asm b/engine/movie/evolution.asm index 1e3aaad4..cabe7254 100755 --- a/engine/movie/evolution.asm +++ b/engine/movie/evolution.asm @@ -13,13 +13,13 @@ EvolveMon: ld [wNewSoundID], a call PlaySound ld a, $1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ld a, SFX_TINK call PlaySound call Delay3 xor a - ld [hAutoBGTransferEnabled], a - ld [hTilesetType], a + ldh [hAutoBGTransferEnabled], a + ldh [hTilesetType], a ld a, [wEvoOldSpecies] ld [wWholeScreenPaletteMonSpecies], a ld c, 0 @@ -37,7 +37,7 @@ EvolveMon: ld [wd0b5], a call Evolution_LoadPic ld a, $1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ld a, [wEvoOldSpecies] call PlayCry call WaitForSoundToFinish @@ -99,7 +99,7 @@ EvolutionSetWholeScreenPalette: Evolution_LoadPic: call GetMonHeader - coord hl, 7, 2 + hlcoord 7, 2 jp LoadFlippedFrontSpriteByMonIndex Evolution_BackAndForthAnim: @@ -117,8 +117,8 @@ Evolution_BackAndForthAnim: Evolution_ChangeMonPic: push bc xor a - ld [hAutoBGTransferEnabled], a - coord hl, 7, 2 + ldh [hAutoBGTransferEnabled], a + hlcoord 7, 2 lb bc, 7, 7 ld de, SCREEN_WIDTH - 7 .loop @@ -134,7 +134,7 @@ Evolution_ChangeMonPic: dec b jr nz, .loop ld a, 1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a call Delay3 pop bc ret @@ -143,7 +143,7 @@ Evolution_CheckForCancel: call DelayFrame push bc call JoypadLowSensitivity - ld a, [hJoy5] + ldh a, [hJoy5] pop bc and B_BUTTON jr nz, .pressedB diff --git a/engine/movie/gamefreak.asm b/engine/movie/gamefreak.asm index 78e48384..1463eb4f 100755 --- a/engine/movie/gamefreak.asm +++ b/engine/movie/gamefreak.asm @@ -1,18 +1,18 @@ LoadShootingStarGraphics: ld a, $f9 - ld [rOBP0], a + ldh [rOBP0], a ld a, $a4 - ld [rOBP1], a - ld de, AnimationTileset2 + $30 ; star tile (top left quadrant) - ld hl, vChars1 + $200 - lb bc, BANK(AnimationTileset2), $01 + ldh [rOBP1], a + ld de, AnimationTileset2 tile 3 ; star tile (top left quadrant) + ld hl, vChars1 tile $20 + lb bc, BANK(AnimationTileset2), 1 call CopyVideoData - ld de, AnimationTileset2 + $130 ; star tile (bottom left quadrant) - ld hl, vChars1 + $210 - lb bc, BANK(AnimationTileset2), $01 + ld de, AnimationTileset2 tile 19 ; star tile (bottom left quadrant) + ld hl, vChars1 tile $21 + lb bc, BANK(AnimationTileset2), 1 call CopyVideoData ld de, FallingStar - ld hl, vChars1 + $220 + ld hl, vChars1 tile $22 lb bc, BANK(FallingStar), (FallingStarEnd - FallingStar) / $10 call CopyVideoData ld hl, GameFreakLogoOAMData @@ -201,9 +201,9 @@ MoveDownSmallStars: jr nz, .innerLoop ; Toggle the palette so that the lower star in the small stars tile blinks in ; and out. - ld a, [rOBP1] + ldh a, [rOBP1] xor %10100000 - ld [rOBP1], a + ldh [rOBP1], a ld c, 3 call CheckForUserInterruption diff --git a/engine/movie/hall_of_fame.asm b/engine/movie/hall_of_fame.asm index f0553eb6..071e7ca1 100755 --- a/engine/movie/hall_of_fame.asm +++ b/engine/movie/hall_of_fame.asm @@ -19,12 +19,12 @@ AnimateHallOfFame: call FillMemory xor a ld [wUpdateSpritesEnabled], a - ld [hTilesetType], a + ldh [hTilesetType], a ld [wSpriteFlipped], a ld [wLetterPrintingDelayFlags], a ; no delay ld [wHoFMonOrPlayer], a ; mon inc a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ld hl, wNumHoFTeams ld a, [hl] inc a @@ -32,7 +32,7 @@ AnimateHallOfFame: inc [hl] .skipInc ld a, $90 - ld [hWY], a + ldh [hWY], a ld c, BANK(Music_HallOfFame) ld a, MUSIC_HALL_OF_FAME call PlayMusic @@ -57,11 +57,11 @@ AnimateHallOfFame: call HoFDisplayAndRecordMonInfo ld c, 80 call DelayFrames - coord hl, 2, 13 + hlcoord 2, 13 ld b, 3 ld c, 14 call TextBoxBorder - coord hl, 4, 15 + hlcoord 4, 15 ld de, HallOfFameText call PlaceString ld c, 180 @@ -86,7 +86,7 @@ AnimateHallOfFame: call HoFDisplayPlayerStats call HoFFadeOutScreenAndMusic xor a - ld [hWY], a + ldh [hWY], a ld hl, rLCDC res 3, [hl] ret @@ -97,9 +97,9 @@ HallOfFameText: HoFShowMonOrPlayer: call ClearScreen ld a, $d0 - ld [hSCY], a + ldh [hSCY], a ld a, $c0 - ld [hSCX], a + ldh [hSCX], a ld a, [wHoFMonSpecies] ld [wcf91], a ld [wd0b5], a @@ -112,7 +112,7 @@ HoFShowMonOrPlayer: call HoFLoadPlayerPics jr .next1 .showMon - coord hl, 12, 5 + hlcoord 12, 5 call GetMonHeader call LoadFrontSpriteByMonIndex predef LoadMonBackPic @@ -121,7 +121,7 @@ HoFShowMonOrPlayer: ld c, 0 call RunPaletteCommand ld a, %11100100 - ld [rBGP], a + ldh [rBGP], a ld c, $31 ; back pic call HoFLoadMonPlayerPicTileIDs ld d, $a0 @@ -133,7 +133,7 @@ HoFShowMonOrPlayer: .next2 call .ScrollPic ; scroll back pic left xor a - ld [hSCY], a + ldh [hSCY], a ld c, a ; front pic call HoFLoadMonPlayerPicTileIDs ld d, 0 @@ -142,9 +142,9 @@ HoFShowMonOrPlayer: .ScrollPic call DelayFrame - ld a, [hSCX] + ldh a, [hSCX] add e - ld [hSCX], a + ldh [hSCX], a cp d jr nz, .ScrollPic ret @@ -157,22 +157,22 @@ HoFDisplayAndRecordMonInfo: jp HoFRecordMonInfo HoFDisplayMonInfo: - coord hl, 0, 2 + hlcoord 0, 2 ld b, 9 ld c, 10 call TextBoxBorder - coord hl, 2, 6 + hlcoord 2, 6 ld de, HoFMonInfoText call PlaceString - coord hl, 1, 4 + hlcoord 1, 4 ld de, wcd6d call PlaceString ld a, [wHoFMonLevel] - coord hl, 8, 7 + hlcoord 8, 7 call PrintLevelCommon ld a, [wHoFMonSpecies] ld [wd0b5], a - coord hl, 3, 9 + hlcoord 3, 9 predef PrintMonType ld a, [wHoFMonSpecies] jp PlayCry @@ -203,27 +203,27 @@ HoFLoadPlayerPics: HoFLoadMonPlayerPicTileIDs: ; c = base tile ID ld b, 0 - coord hl, 12, 5 + hlcoord 12, 5 predef_jump CopyTileIDsFromList HoFDisplayPlayerStats: SetEvent EVENT_HALL_OF_FAME_DEX_RATING predef DisplayDexRating - coord hl, 0, 4 + hlcoord 0, 4 ld b, 6 ld c, 10 call TextBoxBorder - coord hl, 5, 0 + hlcoord 5, 0 ld b, 2 ld c, 9 call TextBoxBorder - coord hl, 7, 2 + hlcoord 7, 2 ld de, wPlayerName call PlaceString - coord hl, 1, 6 + hlcoord 1, 6 ld de, HoFPlayTimeText call PlaceString - coord hl, 5, 7 + hlcoord 5, 7 ld de, wPlayTimeHours lb bc, 1, 3 call PrintNumber @@ -232,10 +232,10 @@ HoFDisplayPlayerStats: ld de, wPlayTimeMinutes lb bc, LEADING_ZEROES | 1, 2 call PrintNumber - coord hl, 1, 9 + hlcoord 1, 9 ld de, HoFMoneyText call PlaceString - coord hl, 4, 10 + hlcoord 4, 10 ld de, wPlayerMoney ld c, $a3 call PrintBCDNumber diff --git a/engine/movie/intro.asm b/engine/movie/intro.asm index 21f1a885..fc404b82 100755 --- a/engine/movie/intro.asm +++ b/engine/movie/intro.asm @@ -12,15 +12,15 @@ const_value = 3 PlayIntro: xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a inc a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a call PlayShootingStar call PlayIntroScene call GBFadeOutToWhite xor a - ld [hSCX], a - ld [hAutoBGTransferEnabled], a + ldh [hSCX], a + ldh [hAutoBGTransferEnabled], a call ClearSprites call DelayFrame ret @@ -29,11 +29,11 @@ PlayIntroScene: ld b, SET_PAL_NIDORINO_INTRO call RunPaletteCommand ldPal a, BLACK, DARK_GRAY, LIGHT_GRAY, WHITE - ld [rBGP], a - ld [rOBP0], a - ld [rOBP1], a + ldh [rBGP], a + ldh [rOBP0], a + ldh [rOBP1], a xor a - ld [hSCX], a + ldh [hSCX], a ld b, GENGAR_INTRO_TILES1 call IntroCopyTiles ld a, 0 @@ -217,7 +217,7 @@ IntroClearScreen: IntroClearMiddleOfScreen: ; clear the area of the tile map between the black bars on the top and bottom - coord hl, 0, 4 + hlcoord 0, 4 ld bc, SCREEN_WIDTH * 10 IntroClearCommon: @@ -245,7 +245,7 @@ IntroMoveMon: cp MOVE_GENGAR_LEFT jr z, .moveGengarLeft ; move Gengar right - ld a, [hSCX] + ldh a, [hSCX] dec a dec a jr .next @@ -259,11 +259,11 @@ IntroMoveMon: call UpdateIntroNidorinoOAM pop de .moveGengarLeft - ld a, [hSCX] + ldh a, [hSCX] inc a inc a .next - ld [hSCX], a + ldh [hSCX], a push de ld c, 2 call CheckForUserInterruption @@ -274,7 +274,7 @@ IntroMoveMon: ret IntroCopyTiles: - coord hl, 13, 7 + hlcoord 13, 7 CopyTileIDsFromList_ZeroBaseTileID: ld c, 0 @@ -311,9 +311,9 @@ LoadIntroGraphics: PlayShootingStar: ld b, SET_PAL_GAME_FREAK_INTRO call RunPaletteCommand - callba LoadCopyrightAndTextBoxTiles + farcall LoadCopyrightAndTextBoxTiles ldPal a, BLACK, DARK_GRAY, LIGHT_GRAY, WHITE - ld [rBGP], a + ldh [rBGP], a ld c, 180 call DelayFrames call ClearScreen @@ -328,7 +328,7 @@ PlayShootingStar: set 3, [hl] ld c, 64 call DelayFrames - callba AnimateShootingStar + farcall AnimateShootingStar push af pop af jr c, .next ; skip the delay if the user interrupted the animation @@ -348,16 +348,16 @@ PlayShootingStar: IntroDrawBlackBars: ; clear the screen and draw black bars on the top and bottom call IntroClearScreen - coord hl, 0, 0 + hlcoord 0, 0 ld c, SCREEN_WIDTH * 4 call IntroPlaceBlackTiles - coord hl, 0, 14 + hlcoord 0, 14 ld c, SCREEN_WIDTH * 4 call IntroPlaceBlackTiles ld hl, vBGMap1 ld c, BG_MAP_WIDTH * 4 call IntroPlaceBlackTiles - ld hl, vBGMap1 + BG_MAP_WIDTH * 14 + hlbgcoord 0, 14, vBGMap1 ld c, BG_MAP_WIDTH * 4 jp IntroPlaceBlackTiles diff --git a/engine/movie/oak_speech/clear_save.asm b/engine/movie/oak_speech/clear_save.asm index b214ec32..d5c04e6e 100755 --- a/engine/movie/oak_speech/clear_save.asm +++ b/engine/movie/oak_speech/clear_save.asm @@ -5,7 +5,7 @@ DoClearSaveDialogue: call LoadTextBoxTilePatterns ld hl, ClearSaveDataText call PrintText - coord hl, 14, 7 + hlcoord 14, 7 lb bc, 8, 15 ld a, NO_YES_MENU ld [wTwoOptionMenuID], a @@ -15,7 +15,7 @@ DoClearSaveDialogue: ld a, [wCurrentMenuItem] and a jp z, Init - callba ClearSAV + farcall ClearSAV jp Init ClearSaveDataText: diff --git a/engine/movie/oak_speech/init_player_data.asm b/engine/movie/oak_speech/init_player_data.asm index c576e65a..53ca24f3 100644 --- a/engine/movie/oak_speech/init_player_data.asm +++ b/engine/movie/oak_speech/init_player_data.asm @@ -2,11 +2,11 @@ InitPlayerData: InitPlayerData2: call Random - ld a, [hRandomSub] + ldh a, [hRandomSub] ld [wPlayerID], a call Random - ld a, [hRandomAdd] + ldh a, [hRandomAdd] ld [wPlayerID + 1], a ld a, $ff @@ -23,9 +23,9 @@ InitPlayerData2: START_MONEY EQU $3000 ld hl, wPlayerMoney + 1 - ld a, START_MONEY / $100 + ld a, HIGH(START_MONEY) ld [hld], a - xor a + xor a ; LOW(START_MONEY) ld [hli], a inc hl ld [hl], a diff --git a/engine/movie/oak_speech/oak_speech.asm b/engine/movie/oak_speech/oak_speech.asm index 0dd0c2dc..4b64f20d 100755 --- a/engine/movie/oak_speech/oak_speech.asm +++ b/engine/movie/oak_speech/oak_speech.asm @@ -52,7 +52,7 @@ OakSpeech: ld [wDestinationMap], a call SpecialWarpIn xor a - ld [hTilesetType], a + ldh [hTilesetType], a ld a, [wd732] bit 1, a ; possibly a debug mode bit jp nz, .skipChoosingNames @@ -68,7 +68,7 @@ OakSpeech: ld [wd0b5], a ld [wcf91], a call GetMonHeader - coord hl, 6, 4 + hlcoord 6, 4 call LoadFlippedFrontSpriteByMonIndex call MovePicLeft ld hl, OakSpeechText2 @@ -104,12 +104,12 @@ OakSpeech: ld hl, OakSpeechText3 call PrintText .next - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] push af ld a, SFX_SHRINK call PlaySound pop af - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ld c, 4 call DelayFrames @@ -126,7 +126,7 @@ OakSpeech: lb bc, BANK(ShrinkPic2), $00 call IntroDisplayPicCenteredOrUpperRight call ResetPlayerSpriteData - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] push af ld a, BANK(Music_PalletTown) ld [wAudioROMBank], a @@ -137,11 +137,11 @@ OakSpeech: ld [wNewSoundID], a call PlaySound pop af - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ld c, 20 call DelayFrames - coord hl, 6, 5 + hlcoord 6, 5 ld b, 7 ld c, 7 call ClearScreenArea @@ -175,7 +175,7 @@ FadeInIntroPic: ld b, 6 .next ld a, [hli] - ld [rBGP], a + ldh [rBGP], a ld c, 10 call DelayFrames dec b @@ -192,18 +192,18 @@ IntroFadePalettes: MovePicLeft: ld a, 119 - ld [rWX], a + ldh [rWX], a call DelayFrame ld a, %11100100 - ld [rBGP], a + ldh [rBGP], a .next call DelayFrame - ld a, [rWX] + ldh a, [rWX] sub 8 cp $FF ret z - ld [rWX], a + ldh [rWX], a jr .next DisplayPicCenteredOrUpperRight: @@ -224,10 +224,10 @@ IntroDisplayPicCenteredOrUpperRight: pop bc ld a, c and a - coord hl, 15, 1 + hlcoord 15, 1 jr nz, .next - coord hl, 6, 4 + hlcoord 6, 4 .next xor a - ld [hStartTileID], a + ldh [hStartTileID], a predef_jump CopyUncompressedPicToTilemap diff --git a/engine/movie/oak_speech/oak_speech2.asm b/engine/movie/oak_speech/oak_speech2.asm index 743d0d13..28208ddc 100755 --- a/engine/movie/oak_speech/oak_speech2.asm +++ b/engine/movie/oak_speech/oak_speech2.asm @@ -66,7 +66,7 @@ HisNameIsText: OakSpeechSlidePicLeft: push de - coord hl, 0, 0 + hlcoord 0, 0 lb bc, 12, 11 call ClearScreenArea ; clear the name list text box ld c, 10 @@ -76,13 +76,13 @@ OakSpeechSlidePicLeft: ld bc, NAME_LENGTH call CopyData call Delay3 - coord hl, 12, 4 + hlcoord 12, 4 lb de, 6, 6 * SCREEN_WIDTH + 5 ld a, $ff jr OakSpeechSlidePicCommon OakSpeechSlidePicRight: - coord hl, 5, 4 + hlcoord 5, 4 lb de, 6, 6 * SCREEN_WIDTH + 5 xor a @@ -90,13 +90,13 @@ OakSpeechSlidePicCommon: push hl push de push bc - ld [hSlideDirection], a + ldh [hSlideDirection], a ld a, d - ld [hSlideAmount], a + ldh [hSlideAmount], a ld a, e - ld [hSlidingRegionSize], a + ldh [hSlidingRegionSize], a ld c, a - ld a, [hSlideDirection] + ldh a, [hSlideDirection] and a jr nz, .next ; If sliding right, point hl to the end of the pic's tiles. @@ -107,8 +107,8 @@ OakSpeechSlidePicCommon: ld e, l .loop xor a - ld [hAutoBGTransferEnabled], a - ld a, [hSlideDirection] + ldh [hAutoBGTransferEnabled], a + ldh a, [hSlideDirection] and a jr nz, .slideLeft ; sliding right @@ -123,7 +123,7 @@ OakSpeechSlidePicCommon: .next2 dec c jr nz, .loop - ld a, [hSlideDirection] + ldh a, [hSlideDirection] and a jr z, .next3 ; 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 .next3 ld a, 1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a call Delay3 - ld a, [hSlidingRegionSize] + ldh a, [hSlidingRegionSize] ld c, a ld h, d ld l, e - ld a, [hSlideDirection] + ldh a, [hSlideDirection] and a jr nz, .slideLeft2 inc hl @@ -150,9 +150,9 @@ OakSpeechSlidePicCommon: .next4 ld d, h ld e, l - ld a, [hSlideAmount] + ldh a, [hSlideAmount] dec a - ld [hSlideAmount], a + ldh [hSlideAmount], a jr nz, .loop pop bc pop de @@ -161,15 +161,15 @@ OakSpeechSlidePicCommon: DisplayIntroNameTextBox: push de - coord hl, 0, 0 + hlcoord 0, 0 ld b, $a ld c, $9 call TextBoxBorder - coord hl, 3, 0 + hlcoord 3, 0 ld de, .namestring call PlaceString pop de - coord hl, 2, 2 + hlcoord 2, 2 call PlaceString call UpdateSprites xor a diff --git a/engine/movie/title.asm b/engine/movie/title.asm index 5ee9b77f..bdb24d6a 100755 --- a/engine/movie/title.asm +++ b/engine/movie/title.asm @@ -11,7 +11,7 @@ SetDefaultNamesBeforeTitlescreen:: ld de, wRivalName call CopyFixedLengthText xor a - ld [hWY], a + ldh [hWY], a ld [wLetterPrintingDelayFlags], a ld hl, wd732 ld [hli], a @@ -24,46 +24,46 @@ SetDefaultNamesBeforeTitlescreen:: DisplayTitleScreen: call GBPalWhiteOut ld a, $1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a xor a - ld [hTilesetType], a - ld [hSCX], a + ldh [hTilesetType], a + ldh [hSCX], a ld a, $40 - ld [hSCY], a + ldh [hSCY], a ld a, $90 - ld [hWY], a + ldh [hWY], a call ClearScreen call DisableLCD call LoadFontTilePatterns ld hl, NintendoCopyrightLogoGraphics - ld de, vTitleLogo2 + $100 - ld bc, $50 + ld de, vTitleLogo2 tile 16 + ld bc, 5 tiles ld a, BANK(NintendoCopyrightLogoGraphics) call FarCopyData2 ld hl, GamefreakLogoGraphics - ld de, vTitleLogo2 + $100 + $50 - ld bc, $90 + ld de, vTitleLogo2 tile (16 + 5) + ld bc, 9 tiles ld a, BANK(GamefreakLogoGraphics) call FarCopyData2 ld hl, PokemonLogoGraphics ld de, vTitleLogo - ld bc, $600 + ld bc, $60 tiles ld a, BANK(PokemonLogoGraphics) call FarCopyData2 ; first chunk - ld hl, PokemonLogoGraphics+$600 + ld hl, PokemonLogoGraphics tile $60 ld de, vTitleLogo2 - ld bc, $100 + ld bc, $10 tiles ld a, BANK(PokemonLogoGraphics) call FarCopyData2 ; second chunk ld hl, Version_GFX - ld de, vChars2 + $600 - (Version_GFXEnd - Version_GFX - $50) + ld de, vChars2 tile $60 + (10 tiles - (Version_GFXEnd - Version_GFX) * 2) / 2 ld bc, Version_GFXEnd - Version_GFX ld a, BANK(Version_GFX) call FarCopyDataDouble call ClearBothBGMaps ; place tiles for pokemon logo (except for the last row) - coord hl, 2, 1 + hlcoord 2, 1 ld a, $80 ld de, SCREEN_WIDTH ld c, 6 @@ -81,7 +81,7 @@ DisplayTitleScreen: jr nz, .pokemonLogoTileLoop ; place tiles for the last row of the pokemon logo - coord hl, 2, 7 + hlcoord 2, 7 ld a, $31 ld b, $10 .pokemonLogoLastTileRowLoop @@ -98,7 +98,7 @@ DisplayTitleScreen: ld [hl], a ; place tiles for title screen copyright - coord hl, 2, 17 + hlcoord 2, 17 ld de, .tileScreenCopyrightTiles ld b, $10 .tileScreenCopyrightTilesLoop @@ -126,19 +126,19 @@ ENDC ld [wTitleMonSpecies], a call LoadTitleMonSprite - ld a, (vBGMap0 + $300) / $100 + ld a, HIGH(vBGMap0 + $300) call TitleScreenCopyTileMapToVRAM call SaveScreenTilesToBuffer1 ld a, $40 - ld [hWY], a + ldh [hWY], a call LoadScreenTilesFromBuffer2 - ld a, vBGMap0 / $100 + ld a, HIGH(vBGMap0) call TitleScreenCopyTileMapToVRAM ld b, SET_PAL_TITLE_SCREEN call RunPaletteCommand call GBPalNormal ld a, %11100100 - ld [rOBP0], a + ldh [rOBP0], a ; make pokemon logo bounce up and down ld bc, hSCY ; background scroll Y @@ -190,7 +190,7 @@ ENDC ; scroll game version in from the right call PrintGameVersionOnTitleScreen ld a, SCREEN_HEIGHT_PX - ld [hWY], a + ldh [hWY], a ld d, 144 .scrollTitleScreenGameVersionLoop ld h, d @@ -205,7 +205,7 @@ ENDC and a jr nz, .scrollTitleScreenGameVersionLoop - ld a, vBGMap1 / $100 + ld a, HIGH(vBGMap1) call TitleScreenCopyTileMapToVRAM call LoadScreenTilesFromBuffer2 call PrintGameVersionOnTitleScreen @@ -226,7 +226,7 @@ ENDC ld c, 1 call CheckForUserInterruption jr c, .finishedWaiting - callba TitleScreenAnimateBallIfStarterOut + farcall TitleScreenAnimateBallIfStarterOut call TitleScreenPickNewMon jr .awaitUserInterruptionLoop @@ -237,17 +237,17 @@ ENDC call GBPalWhiteOutWithDelay3 call ClearSprites xor a - ld [hWY], a + ldh [hWY], a inc a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a call ClearScreen - ld a, vBGMap0 / $100 + ld a, HIGH(vBGMap0) call TitleScreenCopyTileMapToVRAM - ld a, vBGMap1 / $100 + ld a, HIGH(vBGMap1) call TitleScreenCopyTileMapToVRAM call Delay3 call LoadGBPal - ld a, [hJoyHeld] + ldh a, [hJoyHeld] ld b, a and D_UP | SELECT | B_BUTTON cp D_UP | SELECT | B_BUTTON @@ -255,10 +255,10 @@ ENDC jp MainMenu .doClearSaveDialogue - jpba DoClearSaveDialogue + farjp DoClearSaveDialogue TitleScreenPickNewMon: - ld a, vBGMap0 / $100 + ld a, HIGH(vBGMap0) call TitleScreenCopyTileMapToVRAM .loop @@ -280,29 +280,29 @@ TitleScreenPickNewMon: call LoadTitleMonSprite ld a, $90 - ld [hWY], a + ldh [hWY], a ld d, 1 ; scroll out - callba TitleScroll + farcall TitleScroll ret TitleScreenScrollInMon: ld d, 0 ; scroll in - callba TitleScroll + farcall TitleScroll xor a - ld [hWY], a + ldh [hWY], a ret ScrollTitleScreenGameVersion: .wait - ld a, [rLY] + ldh a, [rLY] cp l jr nz, .wait ld a, h - ld [rSCX], a + ldh [rSCX], a .wait2 - ld a, [rLY] + ldh a, [rLY] cp h jr z, .wait2 ret @@ -353,26 +353,26 @@ ClearBothBGMaps: LoadTitleMonSprite: ld [wcf91], a ld [wd0b5], a - coord hl, 5, 10 + hlcoord 5, 10 call GetMonHeader jp LoadFrontSpriteByMonIndex TitleScreenCopyTileMapToVRAM: - ld [hAutoBGTransferDest + 1], a + ldh [hAutoBGTransferDest + 1], a jp Delay3 LoadCopyrightAndTextBoxTiles: xor a - ld [hWY], a + ldh [hWY], a call ClearScreen call LoadTextBoxTilePatterns LoadCopyrightTiles: ld de, NintendoCopyrightLogoGraphics - ld hl, vChars2 + $600 + ld hl, vChars2 tile $60 lb bc, BANK(NintendoCopyrightLogoGraphics), (GamefreakLogoGraphicsEnd - NintendoCopyrightLogoGraphics) / $10 call CopyVideoData - coord hl, 2, 7 + hlcoord 2, 7 ld de, CopyrightTextString jp PlaceString @@ -386,7 +386,7 @@ INCLUDE "data/pokemon/title_mons.asm" ; prints version text (red, blue) PrintGameVersionOnTitleScreen: - coord hl, 7, 8 + hlcoord 7, 8 ld de, VersionOnTitleScreenText jp PlaceString diff --git a/engine/movie/title2.asm b/engine/movie/title2.asm index 2346fcc5..315cf6b5 100755 --- a/engine/movie/title2.asm +++ b/engine/movie/title2.asm @@ -69,15 +69,15 @@ _TitleScroll: .ScrollBetween: .wait - ld a, [rLY] ; rLY + ldh a, [rLY] ; rLY cp l jr nz, .wait ld a, h - ld [rSCX], a + ldh [rSCX], a .wait2 - ld a, [rLY] ; rLY + ldh a, [rLY] ; rLY cp h jr z, .wait2 ret diff --git a/engine/movie/trade.asm b/engine/movie/trade.asm index 8b596e5e..fc2da9bd 100755 --- a/engine/movie/trade.asm +++ b/engine/movie/trade.asm @@ -20,14 +20,14 @@ ExternalClockTradeAnim: TradeAnimCommon: ld a, [wOptions] push af - ld a, [hSCY] + ldh a, [hSCY] push af - ld a, [hSCX] + ldh a, [hSCX] push af xor a ld [wOptions], a - ld [hSCY], a - ld [hSCX], a + ldh [hSCY], a + ldh [hSCX], a push de .loop pop de @@ -49,9 +49,9 @@ TradeAnimCommon: jp hl ; call trade func, which will return to the top of the loop .done pop af - ld [hSCX], a + ldh [hSCX], a pop af - ld [hSCY], a + ldh [hSCY], a pop af ld [wOptions], a ret @@ -137,10 +137,10 @@ Trade_Delay100: Trade_CopyTileMapToVRAM: ld a, $1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a call Delay3 xor a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ret Trade_Delay80: @@ -148,7 +148,7 @@ Trade_Delay80: jp DelayFrames Trade_ClearTileMap: - coord hl, 0, 0 + hlcoord 0, 0 ld bc, SCREEN_WIDTH * SCREEN_HEIGHT ld a, " " jp FillMemory @@ -157,12 +157,12 @@ LoadTradingGFXAndMonNames: call Trade_ClearTileMap call DisableLCD ld hl, TradingAnimationGraphics - ld de, vChars2 + $310 + ld de, vChars2 tile $31 ld bc, TradingAnimationGraphicsEnd - TradingAnimationGraphics ld a, BANK(TradingAnimationGraphics) call FarCopyData2 ld hl, TradingAnimationGraphics2 - ld de, vSprites + $7c0 + ld de, vSprites tile $7c ld bc, TradingAnimationGraphics2End - TradingAnimationGraphics2 ld a, BANK(TradingAnimationGraphics2) call FarCopyData2 @@ -181,10 +181,10 @@ LoadTradingGFXAndMonNames: jr z, .next ld a, $f0 ; SGB OBP0 .next - ld [rOBP0], a + ldh [rOBP0], a call EnableLCD xor a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ld a, [wTradedPlayerMonSpecies] ld [wd11e], a call GetMonName @@ -198,8 +198,8 @@ LoadTradingGFXAndMonNames: Trade_LoadMonPartySpriteGfx: ld a, %11010000 - ld [rOBP1], a - jpba LoadMonPartySpriteGfx + ldh [rOBP1], a + farjp LoadMonPartySpriteGfx Trade_SwapNames: ld hl, wPlayerName @@ -224,20 +224,20 @@ Trade_Cleanup: Trade_ShowPlayerMon: ld a, %10101011 - ld [rLCDC], a + ldh [rLCDC], a ld a, $50 - ld [hWY], a + ldh [hWY], a ld a, $86 - ld [rWX], a - ld [hSCX], a + ldh [rWX], a + ldh [hSCX], a xor a - ld [hAutoBGTransferEnabled], a - coord hl, 4, 0 + ldh [hAutoBGTransferEnabled], a + hlcoord 4, 0 ld b, 6 ld c, 10 call TextBoxBorder call Trade_PrintPlayerMonInfoText - ld b, vBGMap0 / $100 + ld b, HIGH(vBGMap0) call CopyScreenTileBufferToVRAM call ClearScreen ld a, [wTradedPlayerMonSpecies] @@ -247,8 +247,8 @@ Trade_ShowPlayerMon: push af call DelayFrame pop af - ld [rWX], a - ld [hSCX], a + ldh [rWX], a + ldh [hSCX], a dec a dec a and a @@ -261,12 +261,12 @@ Trade_ShowPlayerMon: ld a, [wTradedPlayerMonSpecies] call PlayCry xor a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ret Trade_DrawOpenEndOfLinkCable: call Trade_ClearTileMap - ld b, vBGMap0 / $100 + ld b, HIGH(vBGMap0) call CopyScreenTileBufferToVRAM ld b, SET_PAL_GENERIC call RunPaletteCommand @@ -277,11 +277,11 @@ Trade_DrawOpenEndOfLinkCable: call Trade_CopyCableTilesOffScreen ld a, $a0 - ld [hSCX], a + ldh [hSCX], a call DelayFrame ld a, %10001011 - ld [rLCDC], a - coord hl, 6, 2 + ldh [rLCDC], a + hlcoord 6, 2 ld b, $7 ; open end of link cable tile ID list index call CopyTileIDsFromList_ZeroBaseTileID call Trade_CopyTileMapToVRAM @@ -289,9 +289,9 @@ Trade_DrawOpenEndOfLinkCable: call PlaySound ld c, 20 .loop - ld a, [hSCX] + ldh a, [hSCX] add 4 - ld [hSCX], a + ldh [hSCX], a dec c jr nz, .loop ret @@ -302,7 +302,7 @@ Trade_AnimateBallEnteringLinkCable: ld c, 10 call DelayFrames ld a, %11100100 - ld [rOBP0], a + ldh [rOBP0], a xor a ld [wLinkCableAnimBulgeToggle], a lb bc, $20, $60 @@ -336,13 +336,13 @@ Trade_AnimateBallEnteringLinkCable: .ballSpriteReachedEdgeOfScreen call ClearSprites ld a, $1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a call ClearScreen ld b, $98 call CopyScreenTileBufferToVRAM call Delay3 xor a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ret Trade_BallInsideLinkCableOAM: @@ -353,24 +353,24 @@ Trade_ShowEnemyMon: ld a, TRADE_BALL_TILT_ANIM call Trade_ShowAnimation call Trade_ShowClearedWindow - coord hl, 4, 10 + hlcoord 4, 10 ld b, 6 ld c, 10 call TextBoxBorder call Trade_PrintEnemyMonInfoText call Trade_CopyTileMapToVRAM ld a, $1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ld a, [wTradedEnemyMonSpecies] call Trade_LoadMonSprite ld a, TRADE_BALL_POOF_ANIM call Trade_ShowAnimation ld a, $1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ld a, [wTradedEnemyMonSpecies] call PlayCry call Trade_Delay100 - coord hl, 4, 10 + hlcoord 4, 10 lb bc, 8, 12 call ClearScreenArea jp PrintTradeTakeCareText @@ -381,7 +381,7 @@ Trade_AnimLeftToRight: ld a, $1 ld [wTradedMonMovingRight], a ld a, %11100100 - ld [rOBP0], a + ldh [rOBP0], a ld a, $54 ld [wBaseCoordX], a ld a, $1c @@ -397,7 +397,7 @@ Trade_AnimLeftToRight: ld b, $6 call Trade_AnimMonMoveHorizontal ld a, $1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a call Trade_DrawCableAcrossScreen ld b, $4 call Trade_AnimMonMoveHorizontal @@ -405,7 +405,7 @@ Trade_AnimLeftToRight: ld b, $6 call Trade_AnimMonMoveHorizontal xor a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a call Trade_AnimMonMoveVertical jp ClearSprites @@ -430,7 +430,7 @@ Trade_AnimRightToLeft: ld b, $6 call Trade_AnimMonMoveHorizontal ld a, $1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a call Trade_DrawCableAcrossScreen ld b, $4 call Trade_AnimMonMoveHorizontal @@ -438,31 +438,31 @@ Trade_AnimRightToLeft: ld b, $6 call Trade_AnimMonMoveHorizontal xor a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a jp ClearSprites Trade_InitGameboyTransferGfx: ; Initialises the graphics for showing a mon moving between gameboys. ld a, $1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a call ClearScreen xor a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a call Trade_LoadMonPartySpriteGfx call DelayFrame ld a, %10101011 - ld [rLCDC], a + ldh [rLCDC], a xor a - ld [hSCX], a + ldh [hSCX], a ld a, $90 - ld [hWY], a + ldh [hWY], a ret Trade_DrawLeftGameboy: call Trade_ClearTileMap ; draw link cable - coord hl, 11, 4 + hlcoord 11, 4 ld a, $5d ld [hli], a ld a, $5e @@ -473,16 +473,16 @@ Trade_DrawLeftGameboy: jr nz, .loop ; draw gameboy pic - coord hl, 5, 3 + hlcoord 5, 3 ld b, $6 call CopyTileIDsFromList_ZeroBaseTileID ; draw text box with player name below gameboy pic - coord hl, 4, 12 + hlcoord 4, 12 ld b, 2 ld c, 7 call TextBoxBorder - coord hl, 5, 14 + hlcoord 5, 14 ld de, wPlayerName call PlaceString @@ -492,7 +492,7 @@ Trade_DrawRightGameboy: call Trade_ClearTileMap ; draw horizontal segment of link cable - coord hl, 0, 4 + hlcoord 0, 4 ld a, $5e ld c, $e .loop @@ -520,16 +520,16 @@ Trade_DrawRightGameboy: ld [hl], a ; draw gameboy pic - coord hl, 7, 8 + hlcoord 7, 8 ld b, $6 call CopyTileIDsFromList_ZeroBaseTileID ; draw text box with enemy name above link cable - coord hl, 6, 0 + hlcoord 6, 0 ld b, 2 ld c, 7 call TextBoxBorder - coord hl, 7, 2 + hlcoord 7, 2 ld de, wLinkEnemyTrainerName call PlaceString @@ -538,7 +538,7 @@ Trade_DrawRightGameboy: Trade_DrawCableAcrossScreen: ; Draws the link cable across the screen. call Trade_ClearTileMap - coord hl, 0, 4 + hlcoord 0, 4 ld a, $5e ld c, SCREEN_WIDTH .loop @@ -551,15 +551,15 @@ Trade_CopyCableTilesOffScreen: ; This is used to copy the link cable tiles off screen so that the cable ; continues when the screen is scrolled. push hl - coord hl, 0, 4 + hlcoord 0, 4 call CopyToRedrawRowOrColumnSrcTiles pop hl ld a, h - ld [hRedrawRowOrColumnDest + 1], a + ldh [hRedrawRowOrColumnDest + 1], a ld a, l - ld [hRedrawRowOrColumnDest], a + ldh [hRedrawRowOrColumnDest], a ld a, REDRAW_ROW - ld [hRedrawRowOrColumnMode], a + ldh [hRedrawRowOrColumnMode], a ld c, 10 jp DelayFrames @@ -574,14 +574,14 @@ Trade_AnimMonMoveHorizontal: dec a jr z, .movingRight ; moving left - ld a, [hSCX] + ldh a, [hSCX] sub $2 jr .next .movingRight - ld a, [hSCX] + ldh a, [hSCX] add $2 .next - ld [hSCX], a + ldh [hSCX], a call DelayFrame dec d jr nz, .scrollLoop @@ -596,9 +596,9 @@ Trade_AnimCircledMon: push de push bc push hl - ld a, [rBGP] + ldh a, [rBGP] xor $3c ; make link cable flash - ld [rBGP], a + ldh [rBGP], a ld hl, wOAMBuffer + $02 ld de, $4 ld c, $14 @@ -615,7 +615,7 @@ Trade_AnimCircledMon: ret Trade_WriteCircledMonOAM: - callba WriteMonPartySpriteOAMBySpecies + farcall WriteMonPartySpriteOAMBySpecies call Trade_WriteCircleOAM Trade_AddOffsetsToOAMCoords: @@ -731,11 +731,11 @@ Trade_LoadMonSprite: ld b, SET_PAL_POKEMON_WHOLE_SCREEN ld c, 0 call RunPaletteCommand - ld a, [hAutoBGTransferEnabled] + ldh a, [hAutoBGTransferEnabled] xor $1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a call GetMonHeader - coord hl, 7, 2 + hlcoord 7, 2 call LoadFlippedFrontSpriteByMonIndex ld c, 10 jp DelayFrames @@ -743,16 +743,16 @@ Trade_LoadMonSprite: Trade_ShowClearedWindow: ; clears the window and covers the BG entirely with the window ld a, $1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a call ClearScreen ld a, %11100011 - ld [rLCDC], a + ldh [rLCDC], a ld a, $7 - ld [rWX], a + ldh [rWX], a xor a - ld [hWY], a + ldh [hWY], a ld a, $90 - ld [hSCX], a + ldh [hSCX], a ret Trade_SlideTextBoxOffScreen: @@ -764,17 +764,17 @@ Trade_SlideTextBoxOffScreen: call DelayFrames .loop call DelayFrame - ld a, [rWX] + ldh a, [rWX] inc a inc a - ld [rWX], a + ldh [rWX], a cp $a1 jr nz, .loop call Trade_ClearTileMap ld c, 10 call DelayFrames ld a, $7 - ld [rWX], a + ldh [rWX], a ret PrintTradeWentToText: diff --git a/engine/movie/trade2.asm b/engine/movie/trade2.asm index 6b744fd8..f0d91846 100755 --- a/engine/movie/trade2.asm +++ b/engine/movie/trade2.asm @@ -1,43 +1,43 @@ Trade_PrintPlayerMonInfoText: - coord hl, 5, 0 + hlcoord 5, 0 ld de, Trade_MonInfoText call PlaceString ld a, [wTradedPlayerMonSpecies] ld [wd11e], a predef IndexToPokedex - coord hl, 9, 0 + hlcoord 9, 0 ld de, wd11e lb bc, LEADING_ZEROES | 1, 3 call PrintNumber - coord hl, 5, 2 + hlcoord 5, 2 ld de, wcf4b call PlaceString - coord hl, 8, 4 + hlcoord 8, 4 ld de, wTradedPlayerMonOT call PlaceString - coord hl, 8, 6 + hlcoord 8, 6 ld de, wTradedPlayerMonOTID lb bc, LEADING_ZEROES | 2, 5 jp PrintNumber Trade_PrintEnemyMonInfoText: - coord hl, 5, 10 + hlcoord 5, 10 ld de, Trade_MonInfoText call PlaceString ld a, [wTradedEnemyMonSpecies] ld [wd11e], a predef IndexToPokedex - coord hl, 9, 10 + hlcoord 9, 10 ld de, wd11e lb bc, LEADING_ZEROES | 1, 3 call PrintNumber - coord hl, 5, 12 + hlcoord 5, 12 ld de, wcd6d call PlaceString - coord hl, 8, 14 + hlcoord 8, 14 ld de, wTradedEnemyMonOT call PlaceString - coord hl, 8, 16 + hlcoord 8, 16 ld de, wTradedEnemyMonOTID lb bc, LEADING_ZEROES | 2, 5 jp PrintNumber diff --git a/engine/overworld/auto_movement.asm b/engine/overworld/auto_movement.asm index 5e70ab8c..9a717641 100755 --- a/engine/overworld/auto_movement.asm +++ b/engine/overworld/auto_movement.asm @@ -66,7 +66,7 @@ PalletMovementScript_OakMoveLeft: call FillMemory ld [hl], $ff ld a, [wSpriteIndex] - ld [hSpriteIndex], a + ldh [hSpriteIndex], a ld de, wNPCMovementDirections2 call MoveSprite ld a, $1 @@ -91,7 +91,7 @@ PalletMovementScript_PlayerMoveLeft: ret nz ; return if Oak is still moving ld a, [wNumStepsToTake] ld [wSimulatedJoypadStatesIndex], a - ld [hNPCMovementDirections2Index], a + ldh [hNPCMovementDirections2Index], a predef ConvertNPCMovementDirectionsToJoypadMasks call StartSimulatingJoypadStates ld a, $2 @@ -282,7 +282,7 @@ FreezeEnemyTrainerSprite:: jr .loop .notRival ld a, [wSpriteIndex] - ld [hSpriteIndex], a + ldh [hSpriteIndex], a jp SetSpriteMovementBytesToFF RivalIDs: diff --git a/engine/overworld/clear_variables.asm b/engine/overworld/clear_variables.asm index 9b735495..bbb7c986 100644 --- a/engine/overworld/clear_variables.asm +++ b/engine/overworld/clear_variables.asm @@ -1,14 +1,14 @@ ClearVariablesOnEnterMap:: ld a, SCREEN_HEIGHT_PX - ld [hWY], a - ld [rWY], a + ldh [hWY], a + ldh [rWY], a xor a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ld [wStepCounter], a ld [wLoneAttackNo], a - ld [hJoyPressed], a - ld [hJoyReleased], a - ld [hJoyHeld], a + ldh [hJoyPressed], a + ldh [hJoyReleased], a + ldh [hJoyHeld], a ld [wActionResultOrTookBattleTurn], a ld [wUnusedD5A3], a ld hl, wCardKeyDoorY diff --git a/engine/overworld/cut.asm b/engine/overworld/cut.asm index f99bf323..07039e03 100755 --- a/engine/overworld/cut.asm +++ b/engine/overworld/cut.asm @@ -38,14 +38,14 @@ UsedCut: call ClearSprites call RestoreScreenTilesAndReloadTilePatterns ld a, SCREEN_HEIGHT_PX - ld [hWY], a + ldh [hWY], a call Delay3 call LoadGBPal call LoadCurrentMapView call SaveScreenTilesToBuffer2 call Delay3 xor a - ld [hWY], a + ldh [hWY], a ld hl, UsedCutText call PrintText call LoadScreenTilesFromBuffer2 @@ -57,13 +57,13 @@ UsedCut: ld de, CutTreeBlockSwaps call ReplaceTreeTileBlock call RedrawMapView - callba AnimCut + farcall AnimCut ld a, $1 ld [wUpdateSpritesEnabled], a ld a, SFX_CUT call PlaySound ld a, $90 - ld [hWY], a + ldh [hWY], a call UpdateSprites jp RedrawMapView @@ -75,28 +75,28 @@ InitCutAnimOAM: xor a ld [wWhichAnimationOffsets], a ld a, %11100100 - ld [rOBP1], a + ldh [rOBP1], a ld a, [wCutTile] cp $52 jr z, .grass ; tree - ld de, Overworld_GFX + $2d0 ; cuttable tree sprite top row - ld hl, vChars1 + $7c0 - lb bc, BANK(Overworld_GFX), $02 + ld de, Overworld_GFX tile $2d ; cuttable tree sprite top row + ld hl, vChars1 tile $7c + lb bc, BANK(Overworld_GFX), 2 call CopyVideoData - ld de, Overworld_GFX + $3d0 ; cuttable tree sprite bottom row - ld hl, vChars1 + $7e0 - lb bc, BANK(Overworld_GFX), $02 + ld de, Overworld_GFX tile $3d ; cuttable tree sprite bottom row + ld hl, vChars1 tile $7e + lb bc, BANK(Overworld_GFX), 2 call CopyVideoData jr WriteCutOrBoulderDustAnimationOAMBlock .grass - ld hl, vChars1 + $7c0 + ld hl, vChars1 tile $7c call LoadCutGrassAnimationTilePattern - ld hl, vChars1 + $7d0 + ld hl, vChars1 tile $7d call LoadCutGrassAnimationTilePattern - ld hl, vChars1 + $7e0 + ld hl, vChars1 tile $7e call LoadCutGrassAnimationTilePattern - ld hl, vChars1 + $7f0 + ld hl, vChars1 tile $7f call LoadCutGrassAnimationTilePattern call WriteCutOrBoulderDustAnimationOAMBlock ld hl, wOAMBuffer + $93 @@ -112,8 +112,8 @@ InitCutAnimOAM: ret LoadCutGrassAnimationTilePattern: - ld de, AnimationTileset2 + $60 ; tile depicting a leaf - lb bc, BANK(AnimationTileset2), $01 + ld de, AnimationTileset2 tile 6 ; tile depicting a leaf + lb bc, BANK(AnimationTileset2), 1 jp CopyVideoData WriteCutOrBoulderDustAnimationOAMBlock: diff --git a/engine/overworld/cut2.asm b/engine/overworld/cut2.asm index f16fed66..3d4a5905 100755 --- a/engine/overworld/cut2.asm +++ b/engine/overworld/cut2.asm @@ -15,9 +15,9 @@ AnimCut: ld [wCoordAdjustmentAmount], a ld c, 2 call AdjustOAMBlockXPos2 - ld a, [rOBP1] + ldh a, [rOBP1] xor $64 - ld [rOBP1], a + ldh [rOBP1], a call DelayFrame pop bc dec c @@ -65,9 +65,9 @@ AnimCutGrass_UpdateOAMEntries: ld [wCoordAdjustmentAmount], a ld c, 1 call AdjustOAMBlockXPos2 - ld a, [rOBP1] + ldh a, [rOBP1] xor $64 - ld [rOBP1], a + ldh [rOBP1], a call DelayFrame pop bc dec c diff --git a/engine/overworld/doors.asm b/engine/overworld/doors.asm index ed893773..d38818fa 100755 --- a/engine/overworld/doors.asm +++ b/engine/overworld/doors.asm @@ -11,7 +11,7 @@ IsPlayerStandingOnDoorTile: ld a, [hli] ld h, [hl] ld l, a - aCoord 8, 9 ; a = lower left background tile under player's sprite + lda_coord 8, 9 ; a = lower left background tile under player's sprite ld b, a .loop ld a, [hli] diff --git a/engine/overworld/dust_smoke.asm b/engine/overworld/dust_smoke.asm index 2dc6882e..a20a0591 100755 --- a/engine/overworld/dust_smoke.asm +++ b/engine/overworld/dust_smoke.asm @@ -6,9 +6,9 @@ AnimateBoulderDust: ld a, $ff ld [wUpdateSpritesEnabled], a ld a, %11100100 - ld [rOBP1], a + ldh [rOBP1], a call LoadSmokeTileFourTimes - callba WriteCutOrBoulderDustAnimationOAMBlock + farcall WriteCutOrBoulderDustAnimationOAMBlock ld c, 8 ; number of steps in animation .loop push bc @@ -18,9 +18,9 @@ AnimateBoulderDust: ld c, 4 jp hl .returnAddress - ld a, [rOBP1] + ldh a, [rOBP1] xor %01100100 - ld [rOBP1], a + ldh [rOBP1], a call Delay3 pop bc dec c @@ -69,14 +69,14 @@ MoveBoulderDustFunctionPointerTable: dw AdjustOAMBlockXPos LoadSmokeTileFourTimes:: - ld hl, vChars1 + $7c0 - ld c, $4 + ld hl, vChars1 tile $7c + ld c, 4 .loop push bc push hl call LoadSmokeTile pop hl - ld bc, $10 + ld bc, 1 tiles add hl, bc pop bc dec c diff --git a/engine/overworld/elevator.asm b/engine/overworld/elevator.asm index 05ca08c9..fa404602 100755 --- a/engine/overworld/elevator.asm +++ b/engine/overworld/elevator.asm @@ -6,7 +6,7 @@ ShakeElevator:: call Delay3 ld a, SFX_STOP_ALL_MUSIC call PlaySound - ld a, [hSCY] + ldh a, [hSCY] ld d, a ld e, $1 ld b, 100 @@ -15,7 +15,7 @@ ShakeElevator:: xor $fe ld e, a add d - ld [hSCY], a + ldh [hSCY], a push bc ld c, BANK(SFX_Collision_1) ld a, SFX_COLLISION @@ -26,7 +26,7 @@ ShakeElevator:: dec b jr nz, .shakeLoop ld a, d - ld [hSCY], a + ldh [hSCY], a ld a, SFX_STOP_ALL_MUSIC call PlaySound ld c, BANK(SFX_Safari_Zone_PA) @@ -56,7 +56,7 @@ ShakeElevatorRedrawRow: add hl, de ld a, h and $3 - or vBGMap0 / $100 + or HIGH(vBGMap0) ld d, a ld a, l pop hl diff --git a/engine/overworld/emotion_bubbles.asm b/engine/overworld/emotion_bubbles.asm index 1ac07b80..298858a2 100755 --- a/engine/overworld/emotion_bubbles.asm +++ b/engine/overworld/emotion_bubbles.asm @@ -8,8 +8,8 @@ EmotionBubble: ld e, [hl] inc hl ld d, [hl] - ld hl, vChars1 + $780 - lb bc, BANK(EmotionBubbles), $04 + ld hl, vChars1 tile $78 + lb bc, BANK(EmotionBubbles), 4 call CopyVideoData ld a, [wUpdateSpritesEnabled] push af diff --git a/engine/overworld/healing_machine.asm b/engine/overworld/healing_machine.asm index a09a7590..eaa396d0 100755 --- a/engine/overworld/healing_machine.asm +++ b/engine/overworld/healing_machine.asm @@ -1,17 +1,17 @@ AnimateHealingMachine: ld de, PokeCenterFlashingMonitorAndHealBall - ld hl, vChars0 + $7c0 - lb bc, BANK(PokeCenterFlashingMonitorAndHealBall), $03 ; loads one too many tiles + ld hl, vChars0 tile $7c + lb bc, BANK(PokeCenterFlashingMonitorAndHealBall), 3 ; should be 2 call CopyVideoData ld hl, wUpdateSpritesEnabled ld a, [hl] push af ld [hl], $ff push hl - ld a, [rOBP1] + ldh a, [rOBP1] push af ld a, $e0 - ld [rOBP1], a + ldh [rOBP1], a ld hl, wOAMBuffer + $84 ld de, PokeCenterOAMData call CopyHealingMachineOAM @@ -56,7 +56,7 @@ AnimateHealingMachine: ld c, 32 call DelayFrames pop af - ld [rOBP1], a + ldh [rOBP1], a pop hl pop af ld [hl], a @@ -78,9 +78,9 @@ PokeCenterOAMData: FlashSprite8Times: ld b, 8 .loop - ld a, [rOBP1] + ldh a, [rOBP1] xor d - ld [rOBP1], a + ldh [rOBP1], a ld c, 10 call DelayFrames dec b diff --git a/engine/overworld/hidden_objects.asm b/engine/overworld/hidden_objects.asm index 5ce7f3cb..855328e7 100755 --- a/engine/overworld/hidden_objects.asm +++ b/engine/overworld/hidden_objects.asm @@ -58,7 +58,7 @@ CheckForHiddenObject:: ld [wHiddenObjectX], a ld c, a call CheckIfCoordsInFrontOfPlayerMatch - ld a, [hCoordsInFrontOfPlayerMatch] + ldh a, [hCoordsInFrontOfPlayerMatch] and a jr z, .foundMatchingObject inc hl @@ -81,7 +81,7 @@ CheckForHiddenObject:: ret .noMatch ld a, $ff - ld [hDidntFindAnyHiddenObject], a + ldh [hDidntFindAnyHiddenObject], a ret ; 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 ld a, $ff .done - ld [hCoordsInFrontOfPlayerMatch], a + ldh [hCoordsInFrontOfPlayerMatch], a ret INCLUDE "data/events/hidden_objects.asm" diff --git a/engine/overworld/ledges.asm b/engine/overworld/ledges.asm index 0f135fb6..0e006c5e 100755 --- a/engine/overworld/ledges.asm +++ b/engine/overworld/ledges.asm @@ -8,7 +8,7 @@ HandleLedges:: predef GetTileAndCoordsInFrontOfPlayer ld a, [wSpritePlayerStateData1FacingDirection] ld b, a - aCoord 8, 9 + lda_coord 8, 9 ld c, a ld a, [wTileInFrontOfPlayer] ld d, a @@ -36,7 +36,7 @@ HandleLedges:: inc hl jr .loop .foundMatch - ld a, [hJoyHeld] + ldh a, [hJoyHeld] and e ret z ld a, $ff @@ -57,7 +57,7 @@ HandleLedges:: INCLUDE "data/tilesets/ledge_tiles.asm" LoadHoppingShadowOAM: - ld hl, vChars1 + $7f0 + ld hl, vChars1 tile $7f ld de, LedgeHoppingShadow lb bc, BANK(LedgeHoppingShadow), (LedgeHoppingShadowEnd - LedgeHoppingShadow) / $8 call CopyVideoDataDouble diff --git a/engine/overworld/map_sprites.asm b/engine/overworld/map_sprites.asm index 0de1befd..8f1f3931 100755 --- a/engine/overworld/map_sprites.asm +++ b/engine/overworld/map_sprites.asm @@ -4,20 +4,21 @@ ; This is also called after displaying text because loading ; text tile patterns overwrites half of the sprite tile pattern data. ; Note on notation: -; $C1X* and $C2X* are used to denote wSpriteStateData1-wSpriteStateData1 + $ff and wSpriteStateData2 + $00-wSpriteStateData2 + $ff sprite slot -; fields, respectively, within loops. The X is the loop index. -; If there is an inner loop, Y is the inner loop index, i.e. $C1Y* and $C2Y* -; denote fields of the sprite slots iterated over in the inner loop. +; x#SPRITESTATEDATA1_* and x#SPRITESTATEDATA2_* are used to denote wSpriteStateData1 and +; wSpriteStateData2 sprite slot, respectively, within loops. The X is the loop index. +; If there is an inner loop, Y is the inner loop index, i.e. y#SPRITESTATEDATA1_* and +; y#SPRITESTATEDATA2_* denote fields of the sprite slots iterated over in the inner loop. InitMapSprites:: call InitOutsideMapSprites ret c ; return if the map is an outside map (already handled by above call) ; if the map is an inside map (i.e. mapID >= $25) ld hl, wSpritePlayerStateData1PictureID ld de, wSpritePlayerStateData2PictureID -; Loop to copy picture ID's from $C1X0 to $C2XD for LoadMapSpriteTilePatterns. +; Loop to copy picture IDs from [x#SPRITESTATEDATA1_PICTUREID] +; to [x#SPRITESTATEDATA2_PICTUREID] for LoadMapSpriteTilePatterns. .copyPictureIDLoop - ld a, [hl] ; $C1X0 (picture ID) - ld [de], a ; $C2XD + ld a, [hl] ; a = [x#SPRITESTATEDATA1_PICTUREID] + ld [de], a ; [x#SPRITESTATEDATA2_PICTUREID] = a ld a, $10 add e ld e, a @@ -39,10 +40,12 @@ LoadMapSpriteTilePatterns: ld b, $10 ; number of sprite slots ld hl, wSpritePlayerStateData2PictureID xor a - ld [hFourTileSpriteCount], a -.copyPictureIDLoop ; loop to copy picture ID from $C2XD to $C2XE - ld a, [hli] ; $C2XD (sprite picture ID) - ld [hld], a ; $C2XE + ldh [hFourTileSpriteCount], a +; Loop to copy picture IDs from [x#SPRITESTATEDATA2_PICTUREID] +; to [x#SPRITESTATEDATA2_IMAGEBASEOFFSET]. +.copyPictureIDLoop + ld a, [hli] ; a = [x#SPRITESTATEDATA2_PICTUREID] + ld [hld], a ; [x#SPRITESTATEDATA2_IMAGEBASEOFFSET] = a ld a, l add $10 ld l, a @@ -81,7 +84,7 @@ LoadMapSpriteTilePatterns: ld a, l cp e ; reached current slot? jr z, .foundNextVRAMSlot - ld a, [de] ; $C2YE (VRAM slot) + ld a, [de] ; y#SPRITESTATEDATA2_IMAGEBASEOFFSET cp 11 ; is it one of the first 10 slots? jr nc, .findNextVRAMSlotLoop cp b ; compare the slot being checked to the current max @@ -93,19 +96,19 @@ LoadMapSpriteTilePatterns: inc b ; increment previous max value to get next VRAM tile pattern slot ld a, b ; a = next VRAM tile pattern slot push af - ld a, [hl] ; $C2XE (sprite picture ID) + ld a, [hl] ; [x#SPRITESTATEDATA2_IMAGEBASEOFFSET] ld b, a ; b = current sprite picture ID cp SPRITE_BALL ; is it a 4-tile sprite? jr c, .notFourTileSprite pop af - ld a, [hFourTileSpriteCount] + ldh a, [hFourTileSpriteCount] add 11 jr .storeVRAMSlot .notFourTileSprite pop af .storeVRAMSlot - ld [hl], a ; store VRAM slot at $C2XE - ld [hVRAMSlot], a ; used to determine if it's 4-tile sprite later + ld [hl], a ; store VRAM slot at [x#SPRITESTATEDATA2_IMAGEBASEOFFSET] + ldh [hVRAMSlot], a ; used to determine if it's 4-tile sprite later ld a, b ; a = current sprite picture ID dec a add a @@ -127,27 +130,27 @@ LoadMapSpriteTilePatterns: push de push bc ld hl, vNPCSprites ; VRAM base address - ld bc, $c0 ; number of bytes per VRAM slot - ld a, [hVRAMSlot] + ld bc, 12 tiles ; number of bytes per VRAM slot + ldh a, [hVRAMSlot] cp 11 ; is it a 4-tile sprite? jr nc, .fourTileSpriteVRAMAddr ld d, a dec d -; hl = vSprites + [hVRAMSlot] * $C0 (the number of bytes in 12 tiles) +; hl = vSprites + [hVRAMSlot] * 12 tiles .calculateVRAMAddrLoop add hl, bc dec d jr nz, .calculateVRAMAddrLoop jr .loadStillTilePattern .fourTileSpriteVRAMAddr - ld hl, vSprites + $7c0 ; address for second 4-tile sprite - ld a, [hFourTileSpriteCount] + ld hl, vSprites tile $7c ; address for second 4-tile sprite + ldh a, [hFourTileSpriteCount] and a jr nz, .loadStillTilePattern ; if it's the first 4-tile sprite - ld hl, vSprites + $780 ; address for first 4-tile sprite + ld hl, vSprites tile $78 ; address for first 4-tile sprite inc a - ld [hFourTileSpriteCount], a + ldh [hFourTileSpriteCount], a .loadStillTilePattern pop bc pop de @@ -167,7 +170,7 @@ LoadMapSpriteTilePatterns: .skipFirstLoad pop de pop hl - ld a, [hVRAMSlot] + ldh a, [hVRAMSlot] cp 11 ; is it a 4-tile sprite? jr nc, .skipSecondLoad ; if so, there is no second block push de @@ -207,8 +210,8 @@ LoadMapSpriteTilePatterns: jr .nextSpriteSlot .alreadyLoaded ; if the current picture ID has already had its tile patterns loaded inc de - ld a, [de] ; a = VRAM slot for the current picture ID (from $C2YE) - ld [hl], a ; store VRAM slot in current wSpriteStateData2 sprite slot (at $C2XE) + ld a, [de] ; a = [y#SPRITESTATEDATA2_IMAGEBASEOFFSET] + ld [hl], a ; [x#SPRITESTATEDATA2_IMAGEBASEOFFSET] = a .nextSpriteSlot ld a, l add $10 @@ -217,10 +220,11 @@ LoadMapSpriteTilePatterns: jp nz, .loadTilePatternLoop ld hl, wSpritePlayerStateData2PictureID ld b, $10 -; the pictures ID's stored at $C2XD are no longer needed, so zero them +; the pictures IDs stored at [x#SPRITESTATEDATA2_PICTUREID] are no longer needed, +; so zero them .zeroStoredPictureIDLoop xor a - ld [hl], a ; $C2XD + ld [hl], a ; [x#SPRITESTATEDATA2_PICTUREID] ld a, $10 add l ld l, a @@ -292,15 +296,15 @@ InitOutsideMapSprites: ld [hl], a ld bc, wSpriteSet ; Load the sprite set into RAM. -; This loop also fills $C2XD (sprite picture ID) where X is from $0 to $A -; with picture ID's. This is done so that LoadMapSpriteTilePatterns will +; This loop also fills [x#SPRITESTATEDATA2_PICTUREID] where X is from $0 to $A +; with picture IDs. This is done so that LoadMapSpriteTilePatterns will ; load tile patterns for all sprite pictures in the sprite set. .loadSpriteSetLoop ld a, $10 add l ld l, a ld a, [de] ; sprite picture ID from sprite set - ld [hl], a ; $C2XD (sprite picture ID) + ld [hl], a ; [x#SPRITESTATEDATA2_PICTUREID] ld [bc], a inc de inc bc @@ -313,7 +317,7 @@ InitOutsideMapSprites: add l ld l, a xor a - ld [hl], a ; $C2XD (sprite picture ID) + ld [hl], a ; [x#SPRITESTATEDATA2_PICTUREID] dec b jr nz, .zeroRemainingSlotsLoop ld a, [wNumSprites] @@ -330,7 +334,7 @@ InitOutsideMapSprites: ; for the current map. So, they are not needed and are zeroed by this loop. .zeroVRAMSlotsLoop xor a - ld [hl], a ; $C2XE (VRAM slot) + ld [hl], a ; [x#SPRITESTATEDATA2_IMAGEBASEOFFSET] ld a, $10 add l ld l, a @@ -347,7 +351,7 @@ InitOutsideMapSprites: ; VRAM tile pattern slot. .storeVRAMSlotsLoop ld c, 0 - ld a, [hl] ; $C1X0 (picture ID) (zero if sprite slot is not used) + ld a, [hl] ; [x#SPRITESTATEDATA1_PICTUREID] (zero if sprite slot is not used) and a ; is the sprite slot used? jr z, .skipGettingPictureIndex ; if the sprite slot is not used ld b, a ; b = picture ID @@ -367,7 +371,7 @@ InitOutsideMapSprites: add l ld l, a ld a, c ; a = VRAM slot (zero if sprite slot is not used) - ld [hl], a ; $C2XE (VRAM slot) + ld [hl], a ; [x#SPRITESTATEDATA2_IMAGEBASEOFFSET] pop hl ld a, $10 add l diff --git a/engine/overworld/missable_objects.asm b/engine/overworld/missable_objects.asm index 1ebe8064..fd2fe578 100644 --- a/engine/overworld/missable_objects.asm +++ b/engine/overworld/missable_objects.asm @@ -31,19 +31,19 @@ LoadMissableObjects: sub d ld h, a ld a, h - ld [hDividend], a + ldh [hDividend], a ld a, l - ld [hDividend+1], a + ldh [hDividend+1], a xor a - ld [hDividend+2], a - ld [hDividend+3], a + ldh [hDividend+2], a + ldh [hDividend+3], a ld a, $3 - ld [hDivisor], a + ldh [hDivisor], a ld b, $2 call Divide ; divide difference by 3, resulting in the global offset (number of missable items before ours) ld a, [wCurMap] ld b, a - ld a, [hDividend+3] + ldh a, [hDividend+3] ld c, a ; store global offset in c ld de, wMissableObjectList pop hl @@ -99,7 +99,7 @@ InitializeMissableObjectsFlags: ; tests if current sprite is a missable object that is hidden/has been removed IsObjectHidden: - ld a, [hCurrentSpriteOffset] + ldh a, [hCurrentSpriteOffset] swap a ld b, a ld hl, wMissableObjectList @@ -120,7 +120,7 @@ IsObjectHidden: .notHidden xor a .hidden - ld [hIsHiddenMissableObject], a + ldh [hIsHiddenMissableObject], a ret ; adds missable object (items, leg. pokemon, etc.) to the map diff --git a/engine/overworld/movement.asm b/engine/overworld/movement.asm index d27ccb4b..58481613 100644 --- a/engine/overworld/movement.asm +++ b/engine/overworld/movement.asm @@ -13,8 +13,8 @@ UpdatePlayerSprite: ; background tile the sprite is standing on is greater than $5F, which is ; the maximum number for map tiles .checkIfTextBoxInFrontOfSprite - aCoord 8, 9 - ld [hTilePlayerStandingOn], a + lda_coord 8, 9 + ldh [hTilePlayerStandingOn], a cp MAP_TILESET_SIZE jr c, .lowerLeftTileIsMapTile .disableSprite @@ -23,7 +23,7 @@ UpdatePlayerSprite: ret .lowerLeftTileIsMapTile call DetectCollisionBetweenSprites - ld h, wSpriteStateData1 / $100 + ld h, HIGH(wSpriteStateData1) ld a, [wWalkCounter] and a jr nz, .moving @@ -63,7 +63,7 @@ UpdatePlayerSprite: ld a, [wd736] bit 7, a ; is the player sprite spinning due to a spin tile? jr nz, .skipSpriteAnim - ld a, [hCurrentSpriteOffset] + ldh a, [hCurrentSpriteOffset] add $7 ld l, a ld a, [hl] @@ -89,7 +89,7 @@ UpdatePlayerSprite: ; 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 ; bit set by later logic. - ld a, [hTilePlayerStandingOn] + ldh a, [hTilePlayerStandingOn] ld c, a ld a, [wGrassTile] cp c @@ -103,7 +103,7 @@ UpdatePlayerSprite: UnusedReadSpriteDataFunction: push bc push af - ld a, [hCurrentSpriteOffset] + ldh a, [hCurrentSpriteOffset] ld c, a pop af add c @@ -112,7 +112,7 @@ UnusedReadSpriteDataFunction: ret UpdateNPCSprite: - ld a, [hCurrentSpriteOffset] + ldh a, [hCurrentSpriteOffset] swap a dec a add a @@ -121,20 +121,20 @@ UpdateNPCSprite: ld l, a ld a, [hl] ; read movement byte 2 ld [wCurSpriteMovement2], a - ld h, $c1 - ld a, [hCurrentSpriteOffset] + ld h, HIGH(wSpriteStateData1) + ldh a, [hCurrentSpriteOffset] ld l, a inc l - ld a, [hl] ; c1x1 + ld a, [hl] ; x#SPRITESTATEDATA1_MOVEMENTSTATUS and a jp z, InitializeSpriteStatus call CheckSpriteAvailability ret c ; if sprite is invisible, on tile >=MAP_TILESET_SIZE, in grass or player is currently walking - ld h, $c1 - ld a, [hCurrentSpriteOffset] + ld h, HIGH(wSpriteStateData1) + ldh a, [hCurrentSpriteOffset] ld l, a inc l - ld a, [hl] ; c1x1 + ld a, [hl] ; x#SPRITESTATEDATA1_MOVEMENTSTATUS bit 7, a ; is the face player flag set? jp nz, MakeNPCFacePlayer ld b, a @@ -143,18 +143,18 @@ UpdateNPCSprite: jp nz, notYetMoving ld a, b cp $2 - jp z, UpdateSpriteMovementDelay ; c1x1 == 2 + jp z, UpdateSpriteMovementDelay ; [x#SPRITESTATEDATA1_MOVEMENTSTATUS] == 2 cp $3 - jp z, UpdateSpriteInWalkingAnimation ; c1x1 == 3 + jp z, UpdateSpriteInWalkingAnimation ; [x#SPRITESTATEDATA1_MOVEMENTSTATUS] == 3 ld a, [wWalkCounter] and a ret nz ; don't do anything yet if player is currently moving (redundant, already tested in CheckSpriteAvailability) call InitializeSpriteScreenPosition ld h, $c2 - ld a, [hCurrentSpriteOffset] + ldh a, [hCurrentSpriteOffset] add $6 ld l, a - ld a, [hl] ; c2x6: movement byte 1 + ld a, [hl] ; x#SPRITESTATEDATA2_MOVEMENTBYTE1 inc a jr z, .randomMovement ; value $FF inc a @@ -263,18 +263,18 @@ ChangeFacingDirection: ; set carry on failure, clears carry on success TryWalking: push hl - ld h, $c1 - ld a, [hCurrentSpriteOffset] + ld h, HIGH(wSpriteStateData1) + ldh a, [hCurrentSpriteOffset] add $9 ld l, a - ld [hl], c ; c1x9 (update facing direction) - ld a, [hCurrentSpriteOffset] + ld [hl], c ; x#SPRITESTATEDATA1_FACINGDIRECTION + ldh a, [hCurrentSpriteOffset] add $3 ld l, a - ld [hl], d ; c1x3 (update Y movement delta) + ld [hl], d ; x#SPRITESTATEDATA1_YSTEPVECTOR inc l inc l - ld [hl], e ; c1x5 (update X movement delta) + ld [hl], e ; x#SPRITESTATEDATA1_XSTEPVECTOR pop hl push de ld c, [hl] ; read tile to walk onto @@ -282,103 +282,105 @@ TryWalking: pop de ret c ; cannot walk there (reinitialization of delay values already done) ld h, $c2 - ld a, [hCurrentSpriteOffset] + ldh a, [hCurrentSpriteOffset] add $4 ld l, a - ld a, [hl] ; c2x4: Y position + ld a, [hl] ; x#SPRITESTATEDATA2_MAPY add d ld [hli], a ; update Y position - ld a, [hl] ; c2x5: X position + ld a, [hl] ; x#SPRITESTATEDATA2_MAPX add e ld [hl], a ; update X position - ld a, [hCurrentSpriteOffset] + ldh a, [hCurrentSpriteOffset] ld l, a - ld [hl], $10 ; c2x0=16: walk animation counter + ld [hl], $10 ; [x#SPRITESTATEDATA2_WALKANIMATIONCOUNTER] = 16 dec h inc l - ld [hl], $3 ; c1x1: set movement status to walking + ld [hl], $3 ; x#SPRITESTATEDATA1_MOVEMENTSTATUS jp UpdateSpriteImage ; update the walking animation parameters for a sprite that is currently walking UpdateSpriteInWalkingAnimation: - ld a, [hCurrentSpriteOffset] + ldh a, [hCurrentSpriteOffset] add $7 ld l, a - ld a, [hl] ; c1x7 (counter until next walk animation frame) + ld a, [hl] ; x#SPRITESTATEDATA1_INTRAANIMFRAMECOUNTER inc a - ld [hl], a ; c1x7 += 1 + ld [hl], a ; [x#SPRITESTATEDATA1_INTRAANIMFRAMECOUNTER]++ cp $4 jr nz, .noNextAnimationFrame xor a - ld [hl], a ; c1x7 = 0 + ld [hl], a ; [x#SPRITESTATEDATA1_INTRAANIMFRAMECOUNTER] = 0 inc l - ld a, [hl] ; c1x8 (walk animation frame) + ld a, [hl] ; x#SPRITESTATEDATA1_ANIMFRAMECOUNTER inc a and $3 ld [hl], a ; advance to next animation frame every 4 ticks (16 ticks total for one step) .noNextAnimationFrame - ld a, [hCurrentSpriteOffset] + ldh a, [hCurrentSpriteOffset] add $3 ld l, a - ld a, [hli] ; c1x3 (movement Y delta) + ld a, [hli] ; x#SPRITESTATEDATA1_YSTEPVECTOR ld b, a - ld a, [hl] ; c1x4 (screen Y position) + ld a, [hl] ; x#SPRITESTATEDATA1_YPIXELS add b - ld [hli], a ; update screen Y position - ld a, [hli] ; c1x5 (movement X delta) + ld [hli], a ; update [x#SPRITESTATEDATA1_YPIXELS] + ld a, [hli] ; x#SPRITESTATEDATA1_XSTEPVECTOR ld b, a - ld a, [hl] ; c1x6 (screen X position) + ld a, [hl] ; x#SPRITESTATEDATA1_XPIXELS add b - ld [hl], a ; update screen X position - ld a, [hCurrentSpriteOffset] + ld [hl], a ; update [x#SPRITESTATEDATA1_XPIXELS] + ldh a, [hCurrentSpriteOffset] ld l, a inc h - ld a, [hl] ; c2x0 (walk animation counter) + ld a, [hl] ; x#SPRITESTATEDATA2_WALKANIMATIONCOUNTER dec a ld [hl], a ; update walk animation counter ret nz ld a, $6 ; walking finished, update state add l ld l, a - ld a, [hl] ; c2x6 (movement byte 1) + ld a, [hl] ; x#SPRITESTATEDATA2_MOVEMENTBYTE1 cp $fe jr nc, .initNextMovementCounter ; values $fe and $ff - ld a, [hCurrentSpriteOffset] + ldh a, [hCurrentSpriteOffset] inc a ld l, a dec h - ld [hl], $1 ; c1x1 = 1 (movement status ready) + ld [hl], $1 ; [x#SPRITESTATEDATA1_MOVEMENTSTATUS] = 1 (movement status ready) ret .initNextMovementCounter call Random - ld a, [hCurrentSpriteOffset] + ldh a, [hCurrentSpriteOffset] add $8 ld l, a - ld a, [hRandomAdd] + ldh a, [hRandomAdd] and $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?) - ld a, [hCurrentSpriteOffset] + ld [hl], a ; x#SPRITESTATEDATA2_MOVEMENTDELAY: + ; set next movement delay to a random value in [0,$7f] + ; note that value 0 actually makes the delay $100 (bug?) + dec h ; HIGH(wSpriteStateData1) + ldh a, [hCurrentSpriteOffset] inc a ld l, a - ld [hl], $2 ; c1x1 = 2 (movement status) + ld [hl], $2 ; [x#SPRITESTATEDATA1_MOVEMENTSTATUS] = 2 (movement status) inc l inc l xor a - ld b, [hl] ; c1x3 (movement Y delta) - ld [hli], a ; reset movement Y delta + ld b, [hl] ; x#SPRITESTATEDATA1_YSTEPVECTOR + ld [hli], a ; [x#SPRITESTATEDATA1_YSTEPVECTOR] = 0 inc l - ld c, [hl] ; c1x5 (movement X delta) - ld [hl], a ; reset movement X delta + ld c, [hl] ; x#SPRITESTATEDATA1_XSTEPVECTOR + ld [hl], a ; [x#SPRITESTATEDATA1_XSTEPVECTOR] = 0 ret -; update delay value (c2x8) for sprites in the delayed state (c1x1) +; update [x#SPRITESTATEDATA2_MOVEMENTDELAY] for sprites in the delayed state (x#SPRITESTATEDATA1_MOVEMENTSTATUS) UpdateSpriteMovementDelay: - ld h, $c2 - ld a, [hCurrentSpriteOffset] + ld h, HIGH(wSpriteStateData2) + ldh a, [hCurrentSpriteOffset] add $6 ld l, a - ld a, [hl] ; c2x6: movement byte 1 + ld a, [hl] ; x#SPRITESTATEDATA2_MOVEMENTBYTE1 inc l inc l cp $fe @@ -386,20 +388,20 @@ UpdateSpriteMovementDelay: ld [hl], $0 jr .moving .tickMoveCounter - dec [hl] ; c2x8: frame counter until next movement + dec [hl] ; x#SPRITESTATEDATA2_MOVEMENTDELAY jr nz, notYetMoving .moving dec h - ld a, [hCurrentSpriteOffset] + ldh a, [hCurrentSpriteOffset] inc a ld l, a - ld [hl], $1 ; c1x1 = 1 (mark as ready to move) + ld [hl], $1 ; [x#SPRITESTATEDATA1_MOVEMENTSTATUS] = 1 (mark as ready to move) notYetMoving: - ld h, wSpriteStateData1 / $100 - ld a, [hCurrentSpriteOffset] - add wSpritePlayerStateData1AnimFrameCounter - wSpritePlayerStateData1 + ld h, HIGH(wSpriteStateData1) + ldh a, [hCurrentSpriteOffset] + add SPRITESTATEDATA1_ANIMFRAMECOUNTER ld l, a - ld [hl], $0 ; c1x8 = 0 (walk animation frame) + ld [hl], $0 ; [x#SPRITESTATEDATA1_ANIMFRAMECOUNTER] = 0 (walk animation frame) jp UpdateSpriteImage MakeNPCFacePlayer: @@ -429,66 +431,66 @@ MakeNPCFacePlayer: .notFacingRight ld c, SPRITE_FACING_LEFT .facingDirectionDetermined - ld a, [hCurrentSpriteOffset] + ldh a, [hCurrentSpriteOffset] add $9 ld l, a - ld [hl], c ; c1x9: set facing direction + ld [hl], c ; [x#SPRITESTATEDATA1_FACINGDIRECTION]: set facing direction jr notYetMoving InitializeSpriteStatus: - ld [hl], $1 ; $c1x1: set movement status to ready + ld [hl], $1 ; [x#SPRITESTATEDATA1_MOVEMENTSTATUS] = ready inc l - ld [hl], $ff ; $c1x2: set sprite image to $ff (invisible/off screen) - inc h - ld a, [hCurrentSpriteOffset] + ld [hl], $ff ; [x#SPRITESTATEDATA1_IMAGEINDEX] = invisible/off screen + inc h ; HIGH(wSpriteStateData2) + ldh a, [hCurrentSpriteOffset] add $2 ld l, a ld a, $8 - ld [hli], a ; $c2x2: set Y displacement to 8 - ld [hl], a ; $c2x3: set X displacement to 8 + ld [hli], a ; [x#SPRITESTATEDATA2_YDISPLACEMENT] = 8 + ld [hl], a ; [x#SPRITESTATEDATA2_XDISPLACEMENT] = 8 ret -; calculates the sprite's screen position form its map position and the player position +; calculates the sprite's screen position from its map position and the player position InitializeSpriteScreenPosition: - ld h, wSpriteStateData2 / $100 - ld a, [hCurrentSpriteOffset] - add wSpritePlayerStateData2MapY - wSpritePlayerStateData2 + ld h, HIGH(wSpriteStateData2) + ldh a, [hCurrentSpriteOffset] + add SPRITESTATEDATA2_MAPY ld l, a ld a, [wYCoord] ld b, a - ld a, [hl] ; c2x4 (Y position + 4) + ld a, [hl] ; x#SPRITESTATEDATA2_MAPY sub b ; relative to player position swap a ; * 16 sub $4 ; - 4 dec h - ld [hli], a ; c1x4 (screen Y position) + ld [hli], a ; [x#SPRITESTATEDATA1_YPIXELS] inc h ld a, [wXCoord] ld b, a - ld a, [hli] ; c2x6 (X position + 4) + ld a, [hli] ; x#SPRITESTATEDATA2_MAPX sub b ; relative to player position swap a ; * 16 dec h - ld [hl], a ; c1x6 (screen X position) + ld [hl], a ; [x#SPRITESTATEDATA1_XPIXELS] ret ; tests if sprite is off screen or otherwise unable to do anything CheckSpriteAvailability: predef IsObjectHidden - ld a, [hIsHiddenMissableObject] + ldh a, [hIsHiddenMissableObject] and a jp nz, .spriteInvisible - ld h, wSpriteStateData2 / $100 - ld a, [hCurrentSpriteOffset] - add wSpritePlayerStateData2MovementByte1 - wSpritePlayerStateData2 + ld h, HIGH(wSpriteStateData2) + ldh a, [hCurrentSpriteOffset] + add SPRITESTATEDATA2_MOVEMENTBYTE1 ld l, a - ld a, [hl] ; c2x6: movement byte 1 + ld a, [hl] ; x#SPRITESTATEDATA2_MOVEMENTBYTE1 cp $fe jr c, .skipXVisibilityTest ; movement byte 1 < $fe (i.e. the sprite's movement is scripted) - ld a, [hCurrentSpriteOffset] - add wSpritePlayerStateData2MapY - wSpritePlayerStateData2 + ldh a, [hCurrentSpriteOffset] + add SPRITESTATEDATA2_MAPY ld l, a - ld b, [hl] ; c2x4: Y pos (+4) + ld b, [hl] ; x#SPRITESTATEDATA2_MAPY ld a, [wYCoord] cp b jr z, .skipYVisibilityTest @@ -498,7 +500,7 @@ CheckSpriteAvailability: jr c, .spriteInvisible ; below screen region .skipYVisibilityTest inc l - ld b, [hl] ; c2x5: X pos (+4) + ld b, [hl] ; x#SPRITESTATEDATA2_MAPX ld a, [wXCoord] cp b jr z, .skipXVisibilityTest @@ -526,11 +528,11 @@ CheckSpriteAvailability: cp d jr c, .spriteVisible ; standing on tile with ID >=MAP_TILESET_SIZE (top right tile) .spriteInvisible - ld h, wSpriteStateData1 / $100 - ld a, [hCurrentSpriteOffset] - add wSpritePlayerStateData1ImageIndex - wSpritePlayerStateData1 + ld h, HIGH(wSpriteStateData1) + ldh a, [hCurrentSpriteOffset] + add SPRITESTATEDATA1_IMAGEINDEX ld l, a - ld [hl], $ff ; c1x2 + ld [hl], $ff ; x#SPRITESTATEDATA1_IMAGEINDEX scf jr .done .spriteVisible @@ -540,7 +542,7 @@ CheckSpriteAvailability: jr nz, .done ; if player is currently walking, we're done call UpdateSpriteImage inc h - ld a, [hCurrentSpriteOffset] + ldh a, [hCurrentSpriteOffset] add $7 ld l, a ld a, [wGrassTile] @@ -549,28 +551,28 @@ CheckSpriteAvailability: jr nz, .notInGrass ld a, $80 .notInGrass - ld [hl], a ; c2x7 + ld [hl], a ; x#SPRITESTATEDATA2_GRASSPRIORITY and a .done ret UpdateSpriteImage: - ld h, $c1 - ld a, [hCurrentSpriteOffset] + ld h, HIGH(wSpriteStateData1) + ldh a, [hCurrentSpriteOffset] add $8 ld l, a - ld a, [hli] ; c1x8: walk animation frame + ld a, [hli] ; x#SPRITESTATEDATA1_ANIMFRAMECOUNTER ld b, a - ld a, [hl] ; c1x9: facing direction + ld a, [hl] ; x#SPRITESTATEDATA1_FACINGDIRECTION add b ld b, a - ld a, [hTilePlayerStandingOn] + ldh a, [hTilePlayerStandingOn] add b ld b, a - ld a, [hCurrentSpriteOffset] + ldh a, [hCurrentSpriteOffset] add $2 ld l, a - ld [hl], b ; c1x2: sprite to display + ld [hl], b ; x#SPRITESTATEDATA1_IMAGEINDEX ret ; tests if sprite can walk the specified direction @@ -580,11 +582,11 @@ UpdateSpriteImage: ; e: X movement delta (-1, 0 or 1) ; set carry on failure, clears carry on success CanWalkOntoTile: - ld h, wSpriteStateData2 / $100 - ld a, [hCurrentSpriteOffset] - add wSpritePlayerStateData2MovementByte1 - wSpritePlayerStateData2 + ld h, HIGH(wSpriteStateData2) + ldh a, [hCurrentSpriteOffset] + add SPRITESTATEDATA2_MOVEMENTBYTE1 ld l, a - ld a, [hl] ; c2x6 (movement byte 1) + ld a, [hl] ; x#SPRITESTATEDATA2_MOVEMENTBYTE1 cp $fe jr nc, .notScripted ; values $fe and $ff ; always allow walking if the movement is scripted @@ -602,23 +604,23 @@ CanWalkOntoTile: cp c jr nz, .tilePassableLoop ld h, $c2 - ld a, [hCurrentSpriteOffset] + ldh a, [hCurrentSpriteOffset] add $6 ld l, a - ld a, [hl] ; $c2x6 (movement byte 1) + ld a, [hl] ; x#SPRITESTATEDATA2_MOVEMENTBYTE1 inc a jr z, .impassable ; if $ff, no movement allowed (however, changing direction is) - ld h, wSpriteStateData1 / $100 - ld a, [hCurrentSpriteOffset] - add wSpritePlayerStateData1YPixels - wSpritePlayerStateData1 + ld h, HIGH(wSpriteStateData1) + ldh a, [hCurrentSpriteOffset] + add SPRITESTATEDATA1_YPIXELS ld l, a - ld a, [hli] ; c1x4 (screen Y pos) + ld a, [hli] ; x#SPRITESTATEDATA1_YPIXELS add $4 ; align to blocks (Y pos is always 4 pixels off) add d ; add Y delta cp $80 ; if value is >$80, the destination is off screen (either $81 or $FF underflow) jr nc, .impassable ; don't walk off screen inc l - ld a, [hl] ; c1x6 (screen X pos) + ld a, [hl] ; x#SPRITESTATEDATA1_XPIXELS add e ; add X delta cp $90 ; if value is >$90, the destination is off screen (either $91 or $FF underflow) jr nc, .impassable ; don't walk off screen @@ -627,30 +629,35 @@ CanWalkOntoTile: call DetectCollisionBetweenSprites pop bc pop de - ld h, wSpriteStateData1 / $100 - ld a, [hCurrentSpriteOffset] + ld h, HIGH(wSpriteStateData1) + ldh a, [hCurrentSpriteOffset] add $c ld l, a - ld a, [hl] ; c1xc (directions in which sprite collision would occur) + ld a, [hl] ; x#SPRITESTATEDATA1_COLLISIONDATA (directions in which sprite collision would occur) and b ; check against chosen direction (1,2,4 or 8) jr nz, .impassable ; collision between sprites, don't go there - ld h, wSpriteStateData2 / $100 - ld a, [hCurrentSpriteOffset] - add wSpritePlayerStateData2YDisplacement - wSpritePlayerStateData2 + ld h, HIGH(wSpriteStateData2) + ldh a, [hCurrentSpriteOffset] + add SPRITESTATEDATA2_YDISPLACEMENT ld l, a - ld a, [hli] ; c2x2 (sprite Y displacement, initialized at $8, keep track of where a sprite did go) + ld a, [hli] ; x#SPRITESTATEDATA2_YDISPLACEMENT (initialized at $8, keep track of where a sprite did go) bit 7, d ; check if going upwards (d=$ff) jr nz, .upwards add d + ; bug: these tests against $5 probably were supposed to prevent + ; sprites from walking out too far, but this line makes sprites get + ; stuck whenever they walked upwards 5 steps + ; on the other hand, the amount a sprite can walk out to the + ; right of bottom is not limited (until the counter overflows) cp $5 - jr c, .impassable ; if c2x2+d < 5, don't go ;bug: this tests probably were supposed to prevent sprites - jr .checkHorizontal ; from walking out too far, but this line makes sprites get stuck -.upwards ; whenever they walked upwards 5 steps - sub $1 ; on the other hand, the amount a sprite can walk out to the - jr c, .impassable ; if d2x2 == 0, don't go ; right of bottom is not limited (until the counter overflows) + jr c, .impassable ; if [x#SPRITESTATEDATA2_YDISPLACEMENT]+d < 5, don't go + jr .checkHorizontal +.upwards + sub $1 + jr c, .impassable ; if [x#SPRITESTATEDATA2_YDISPLACEMENT] == 0, don't go .checkHorizontal ld d, a - ld a, [hl] ; c2x3 (sprite X displacement, initialized at $8, keep track of where a sprite did go) + ld a, [hl] ; x#SPRITESTATEDATA2_XDISPLACEMENT (initialized at $8, keep track of where a sprite did go) bit 7, e ; check if going left (e=$ff) jr nz, .left add e @@ -658,32 +665,32 @@ CanWalkOntoTile: jr .passable .left sub $1 - jr c, .impassable ; if d2x3 == 0, don't go + jr c, .impassable ; if [x#SPRITESTATEDATA2_XDISPLACEMENT] == 0, don't go .passable - ld [hld], a ; update c2x3 - ld [hl], d ; update c2x2 + ld [hld], a ; update x#SPRITESTATEDATA2_XDISPLACEMENT + ld [hl], d ; update x#SPRITESTATEDATA2_YDISPLACEMENT and a ; clear carry (marking success) ret .impassable - ld h, wSpriteStateData1 / $100 - ld a, [hCurrentSpriteOffset] + ld h, HIGH(wSpriteStateData1) + ldh a, [hCurrentSpriteOffset] inc a ld l, a - ld [hl], $2 ; c1x1 = 2 (set movement status to delayed) + ld [hl], $2 ; [x#SPRITESTATEDATA1_MOVEMENTSTATUS] = 2 (delayed) inc l inc l xor a - ld [hli], a ; c1x3 = 0 (clear Y movement delta) + ld [hli], a ; [x#SPRITESTATEDATA1_YSTEPVECTOR] = 0 inc l - ld [hl], a ; c1x5 = 0 (clear X movement delta) + ld [hl], a ; [x#SPRITESTATEDATA1_XSTEPVECTOR] = 0 inc h - ld a, [hCurrentSpriteOffset] + ldh a, [hCurrentSpriteOffset] add $8 ld l, a call Random - ld a, [hRandomAdd] + ldh a, [hRandomAdd] 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 ; x#SPRITESTATEDATA2_MOVEMENTDELAY: set to a random value in [0,$7f] (again with delay $100 if value is 0) scf ; set carry (marking failure to walk) ret @@ -691,25 +698,25 @@ CanWalkOntoTile: ; this is always the lower left tile of the 2x2 tile blocks all sprites are snapped to ; hl: output pointer GetTileSpriteStandsOn: - ld h, wSpriteStateData1 / $100 - ld a, [hCurrentSpriteOffset] - add wSpritePlayerStateData1YPixels - wSpritePlayerStateData1 + ld h, HIGH(wSpriteStateData1) + ldh a, [hCurrentSpriteOffset] + add SPRITESTATEDATA1_YPIXELS ld l, a - ld a, [hli] ; c1x4: screen Y position + ld a, [hli] ; x#SPRITESTATEDATA1_YPIXELS add $4 ; align to 2*2 tile blocks (Y position is always off 4 pixels to the top) and $f0 ; in case object is currently moving srl a ; screen Y tile * 4 ld c, a ld b, $0 inc l - ld a, [hl] ; c1x6: screen X position + ld a, [hl] ; x#SPRITESTATEDATA1_XPIXELS srl a srl a srl a ; screen X tile add SCREEN_WIDTH ; screen X tile + 20 ld d, $0 ld e, a - coord hl, 0, 0 + hlcoord 0, 0 add hl, bc add hl, bc add hl, bc @@ -784,7 +791,7 @@ DoScriptedNPCMovement: ld a, [hl] add b ld [hl], a - ld a, [hCurrentSpriteOffset] + ldh a, [hCurrentSpriteOffset] add $9 ld l, a ld a, c @@ -807,17 +814,17 @@ InitScriptedNPCMovement: jp AnimScriptedNPCMovement GetSpriteScreenYPointer: - ld a, wSpritePlayerStateData1YPixels - wSpritePlayerStateData1 + ld a, SPRITESTATEDATA1_YPIXELS ld b, a jr GetSpriteScreenXYPointerCommon GetSpriteScreenXPointer: - ld a, wSpritePlayerStateData1XPixels - wSpritePlayerStateData1 + ld a, SPRITESTATEDATA1_XPIXELS ld b, a GetSpriteScreenXYPointerCommon: ld hl, wSpriteStateData1 - ld a, [hCurrentSpriteOffset] + ldh a, [hCurrentSpriteOffset] add l add b ld l, a @@ -825,16 +832,16 @@ GetSpriteScreenXYPointerCommon: AnimScriptedNPCMovement: ld hl, wSpriteStateData2 - ld a, [hCurrentSpriteOffset] - add wSpritePlayerStateData2ImageBaseOffset - wSpritePlayerStateData2 + ldh a, [hCurrentSpriteOffset] + add SPRITESTATEDATA2_IMAGEBASEOFFSET ld l, a ld a, [hl] ; VRAM slot dec a swap a ld b, a ld hl, wSpriteStateData1 - ld a, [hCurrentSpriteOffset] - add wSpritePlayerStateData1FacingDirection - wSpritePlayerStateData1 + ldh a, [hCurrentSpriteOffset] + add SPRITESTATEDATA1_FACINGDIRECTION ld l, a ld a, [hl] ; facing direction cp SPRITE_FACING_DOWN @@ -849,21 +856,21 @@ AnimScriptedNPCMovement: .anim add b ld b, a - ld [hSpriteVRAMSlotAndFacing], a + ldh [hSpriteVRAMSlotAndFacing], a call AdvanceScriptedNPCAnimFrameCounter ld hl, wSpriteStateData1 - ld a, [hCurrentSpriteOffset] - add wSpritePlayerStateData1ImageIndex - wSpritePlayerStateData1 + ldh a, [hCurrentSpriteOffset] + add SPRITESTATEDATA1_IMAGEINDEX ld l, a - ld a, [hSpriteVRAMSlotAndFacing] + ldh a, [hSpriteVRAMSlotAndFacing] ld b, a - ld a, [hSpriteAnimFrameCounter] + ldh a, [hSpriteAnimFrameCounter] add b ld [hl], a ret AdvanceScriptedNPCAnimFrameCounter: - ld a, [hCurrentSpriteOffset] + ldh a, [hCurrentSpriteOffset] add $7 ld l, a ld a, [hl] ; intra-animation frame counter @@ -878,5 +885,5 @@ AdvanceScriptedNPCAnimFrameCounter: inc a and $3 ld [hl], a - ld [hSpriteAnimFrameCounter], a + ldh [hSpriteAnimFrameCounter], a ret diff --git a/engine/overworld/pathfinding.asm b/engine/overworld/pathfinding.asm index 7251759c..1925dbbc 100644 --- a/engine/overworld/pathfinding.asm +++ b/engine/overworld/pathfinding.asm @@ -8,29 +8,29 @@ FindPathToPlayer: ld hl, wNPCMovementDirections2 ld de, $0 .loop - ld a, [hFindPathYProgress] + ldh a, [hFindPathYProgress] ld b, a - ld a, [hNPCPlayerYDistance] ; Y distance in steps + ldh a, [hNPCPlayerYDistance] ; Y distance in steps call CalcDifference ld d, a and a jr nz, .asm_f8da - ld a, [hFindPathFlags] + ldh a, [hFindPathFlags] set 0, a ; current end of path matches the player's Y coordinate - ld [hFindPathFlags], a + ldh [hFindPathFlags], a .asm_f8da - ld a, [hFindPathXProgress] + ldh a, [hFindPathXProgress] ld b, a - ld a, [hNPCPlayerXDistance] ; X distance in steps + ldh a, [hNPCPlayerXDistance] ; X distance in steps call CalcDifference ld e, a and a jr nz, .asm_f8ec - ld a, [hFindPathFlags] + ldh a, [hFindPathFlags] set 1, a ; current end of path matches the player's X coordinate - ld [hFindPathFlags], a + ldh [hFindPathFlags], a .asm_f8ec - ld a, [hFindPathFlags] + ldh a, [hFindPathFlags] cp $3 ; has the end of the path reached the player's position? jr z, .done ; Compare whether the X distance between the player and the current of the path @@ -39,7 +39,7 @@ FindPathToPlayer: cp d jr c, .yDistanceGreater ; x distance is greater - ld a, [hNPCPlayerRelativePosFlags] + ldh a, [hNPCPlayerRelativePosFlags] bit 1, a jr nz, .playerIsLeftOfNPC ld d, NPC_MOVEMENT_RIGHT @@ -47,12 +47,12 @@ FindPathToPlayer: .playerIsLeftOfNPC ld d, NPC_MOVEMENT_LEFT .next1 - ld a, [hFindPathXProgress] + ldh a, [hFindPathXProgress] add 1 - ld [hFindPathXProgress], a + ldh [hFindPathXProgress], a jr .storeDirection .yDistanceGreater - ld a, [hNPCPlayerRelativePosFlags] + ldh a, [hNPCPlayerRelativePosFlags] bit 0, a jr nz, .playerIsAboveNPC ld d, NPC_MOVEMENT_DOWN @@ -60,15 +60,15 @@ FindPathToPlayer: .playerIsAboveNPC ld d, NPC_MOVEMENT_UP .next2 - ld a, [hFindPathYProgress] + ldh a, [hFindPathYProgress] add 1 - ld [hFindPathYProgress], a + ldh [hFindPathYProgress], a .storeDirection ld a, d ld [hli], a - ld a, [hFindPathNumSteps] + ldh a, [hFindPathNumSteps] inc a - ld [hFindPathNumSteps], a + ldh [hFindPathNumSteps], a jp .loop .done ld [hl], $ff @@ -76,15 +76,15 @@ FindPathToPlayer: CalcPositionOfPlayerRelativeToNPC: xor a - ld [hNPCPlayerRelativePosFlags], a + ldh [hNPCPlayerRelativePosFlags], a ld a, [wSpritePlayerStateData1YPixels] ld d, a ld a, [wSpritePlayerStateData1XPixels] ld e, a ld hl, wSpriteStateData1 - ld a, [hNPCSpriteOffset] + ldh a, [hNPCSpriteOffset] add l - add wSpritePlayerStateData1YPixels - wSpritePlayerStateData1 + add SPRITESTATEDATA1_YPIXELS ld l, a jr nc, .noCarry inc h @@ -115,7 +115,7 @@ CalcPositionOfPlayerRelativeToNPC: ld [hli], a call DivideBytes ; divide Y absolute distance by 16 ld a, [hl] ; quotient - ld [hNPCPlayerYDistance], a + ldh [hNPCPlayerYDistance], a pop hl inc hl ld b, e @@ -136,23 +136,23 @@ CalcPositionOfPlayerRelativeToNPC: res 1, [hl] pop hl .divideXDistance - ld [hDividend2], a + ldh [hDividend2], a ld a, 16 - ld [hDivisor2], a + ldh [hDivisor2], a call DivideBytes ; divide X absolute distance by 16 - ld a, [hQuotient2] - ld [hNPCPlayerXDistance], a - ld a, [hNPCPlayerRelativePosPerspective] + ldh a, [hQuotient2] + ldh [hNPCPlayerXDistance], a + ldh a, [hNPCPlayerRelativePosPerspective] and a ret z - ld a, [hNPCPlayerRelativePosFlags] + ldh a, [hNPCPlayerRelativePosFlags] cpl and $3 - ld [hNPCPlayerRelativePosFlags], a + ldh [hNPCPlayerRelativePosFlags], a ret ConvertNPCMovementDirectionsToJoypadMasks: - ld a, [hNPCMovementDirections2Index] + ldh a, [hNPCMovementDirections2Index] ld [wNPCMovementDirections2Index], a dec a ld de, wSimulatedJoypadStatesEnd @@ -166,9 +166,9 @@ ConvertNPCMovementDirectionsToJoypadMasks: call ConvertNPCMovementDirectionToJoypadMask ld [de], a inc de - ld a, [hNPCMovementDirections2Index] + ldh a, [hNPCMovementDirections2Index] dec a - ld [hNPCMovementDirections2Index], a + ldh [hNPCMovementDirections2Index], a jr nz, .loop ret diff --git a/engine/overworld/player_animations.asm b/engine/overworld/player_animations.asm index cfd6cc8d..9e9b4073 100755 --- a/engine/overworld/player_animations.asm +++ b/engine/overworld/player_animations.asm @@ -250,11 +250,11 @@ DoFlyAnimation: LoadBirdSpriteGraphics: ld de, BirdSprite ld hl, vNPCSprites - lb bc, BANK(BirdSprite), $0c + lb bc, BANK(BirdSprite), 12 call CopyVideoData - ld de, BirdSprite + $c0 ; moving animation sprite + ld de, BirdSprite tile 12 ; moving animation sprite ld hl, vNPCSprites2 - lb bc, BANK(BirdSprite), $0c + lb bc, BANK(BirdSprite), 12 jp CopyVideoData InitFacingDirectionList: @@ -358,7 +358,7 @@ IsPlayerStandingOnWarpPadOrHole:: jr z, .done cp c jr nz, .nextEntry - aCoord 8, 9 + lda_coord 8, 9 cp [hl] jr z, .foundMatch .nextEntry @@ -381,8 +381,8 @@ FishingAnim: ld hl, wd736 set 6, [hl] ; reserve the last 4 OAM entries ld de, RedSprite - ld hl, vNPCSprites - lb bc, BANK(RedSprite), $c + ld hl, vNPCSprites tile $00 + lb bc, BANK(RedSprite), 12 call CopyVideoData ld a, $4 ld hl, RedFishingTiles @@ -479,22 +479,18 @@ FishingRodOAM: db $50, $40, $FE, $00 ; player facing left db $50, $58, $FE, $20 ; player facing right ($20 means "horizontally flip the tile") -RedFishingTiles: - dw RedFishingTilesFront - db 2, BANK(RedFishingTilesFront) - dw vNPCSprites + $20 +fishing_gfx: MACRO + dw \1 + db \2 + db BANK(\1) + dw vNPCSprites tile \3 +ENDM - dw RedFishingTilesBack - db 2, BANK(RedFishingTilesBack) - dw vNPCSprites + $60 - - dw RedFishingTilesSide - db 2, BANK(RedFishingTilesSide) - dw vNPCSprites + $a0 - - dw RedFishingRodTiles - db 3, BANK(RedFishingRodTiles) - dw vNPCSprites2 + $7d0 +RedFishingTiles: + fishing_gfx RedFishingTilesFront, 2, $02 + fishing_gfx RedFishingTilesBack, 2, $06 + fishing_gfx RedFishingTilesSide, 2, $0a + fishing_gfx RedFishingRodTiles, 3, $fd _HandleMidJump:: ld a, [wPlayerJumpingYScreenCoordsIndex] @@ -516,9 +512,9 @@ _HandleMidJump:: call UpdateSprites call Delay3 xor a - ld [hJoyHeld], a - ld [hJoyPressed], a - ld [hJoyReleased], a + ldh [hJoyHeld], a + ldh [hJoyPressed], a + ldh [hJoyReleased], a ld [wPlayerJumpingYScreenCoordsIndex], a ld hl, wd736 res 6, [hl] ; not jumping down a ledge any more diff --git a/engine/overworld/player_state.asm b/engine/overworld/player_state.asm index 9ff67df8..70326754 100644 --- a/engine/overworld/player_state.asm +++ b/engine/overworld/player_state.asm @@ -17,7 +17,7 @@ IsPlayerStandingOnWarp:: ld a, [hli] ; target warp ld [wDestinationWarpID], a ld a, [hl] ; target map - ld [hWarpDestinationMap], a + ldh [hWarpDestinationMap], a ld hl, wd736 set 2, [hl] ; standing on warp flag ret @@ -192,7 +192,7 @@ IsPlayerStandingOnDoorTileOrWarpTile:: push hl push de push bc - callba IsPlayerStandingOnDoorTile + farcall IsPlayerStandingOnDoorTile jr c, .done ld a, [wCurMapTileset] add a @@ -204,7 +204,7 @@ IsPlayerStandingOnDoorTileOrWarpTile:: ld h, [hl] ld l, a ld de, $1 - aCoord 8, 9 + lda_coord 8, 9 call IsInArray jr nc, .done ld hl, wd736 @@ -223,28 +223,28 @@ PrintSafariZoneSteps:: ret c cp CERULEAN_CAVE_2F ret nc - coord hl, 0, 0 + hlcoord 0, 0 ld b, 3 ld c, 7 call TextBoxBorder - coord hl, 1, 1 + hlcoord 1, 1 ld de, wSafariSteps lb bc, 2, 3 call PrintNumber - coord hl, 4, 1 + hlcoord 4, 1 ld de, SafariSteps call PlaceString - coord hl, 1, 3 + hlcoord 1, 3 ld de, SafariBallText call PlaceString ld a, [wNumSafariBalls] cp 10 jr nc, .asm_c56d - coord hl, 5, 3 + hlcoord 5, 3 ld a, " " ld [hl], a .asm_c56d - coord hl, 6, 3 + hlcoord 6, 3 ld de, wNumSafariBalls lb bc, 1, 2 jp PrintNumber @@ -267,28 +267,28 @@ _GetTileAndCoordsInFrontOfPlayer: and a ; cp SPRITE_FACING_DOWN jr nz, .notFacingDown ; facing down - aCoord 8, 11 + lda_coord 8, 11 inc d jr .storeTile .notFacingDown cp SPRITE_FACING_UP jr nz, .notFacingUp ; facing up - aCoord 8, 7 + lda_coord 8, 7 dec d jr .storeTile .notFacingUp cp SPRITE_FACING_LEFT jr nz, .notFacingLeft ; facing left - aCoord 6, 9 + lda_coord 6, 9 dec e jr .storeTile .notFacingLeft cp SPRITE_FACING_RIGHT jr nz, .storeTile ; facing right - aCoord 10, 9 + lda_coord 10, 9 inc e .storeTile ld c, a @@ -297,7 +297,7 @@ _GetTileAndCoordsInFrontOfPlayer: GetTileTwoStepsInFrontOfPlayer: xor a - ld [hPlayerFacing], a + ldh [hPlayerFacing], a ld hl, wYCoord ld a, [hli] ld d, a @@ -308,7 +308,7 @@ GetTileTwoStepsInFrontOfPlayer: ; facing down ld hl, hPlayerFacing set 0, [hl] - aCoord 8, 13 + lda_coord 8, 13 inc d jr .storeTile .notFacingDown @@ -317,7 +317,7 @@ GetTileTwoStepsInFrontOfPlayer: ; facing up ld hl, hPlayerFacing set 1, [hl] - aCoord 8, 5 + lda_coord 8, 5 dec d jr .storeTile .notFacingUp @@ -326,7 +326,7 @@ GetTileTwoStepsInFrontOfPlayer: ; facing left ld hl, hPlayerFacing set 2, [hl] - aCoord 4, 9 + lda_coord 4, 9 dec e jr .storeTile .notFacingLeft @@ -335,7 +335,7 @@ GetTileTwoStepsInFrontOfPlayer: ; facing right ld hl, hPlayerFacing set 3, [hl] - aCoord 12, 9 + lda_coord 12, 9 inc e .storeTile ld c, a @@ -378,33 +378,33 @@ CheckForBoulderCollisionWithSprites: ld hl, wSprite01StateData2MapY add hl, de ld a, [hli] ; map Y position - ld [hPlayerYCoord], a + ldh [hPlayerYCoord], a ld a, [hl] ; map X position - ld [hPlayerXCoord], a + ldh [hPlayerXCoord], a ld a, [wNumSprites] ld c, a ld de, $f ld hl, wSprite01StateData2MapY - ld a, [hPlayerFacing] + ldh a, [hPlayerFacing] and $3 ; facing up or down? jr z, .pushingHorizontallyLoop .pushingVerticallyLoop inc hl - ld a, [hPlayerXCoord] + ldh a, [hPlayerXCoord] cp [hl] jr nz, .nextSprite1 ; if X coordinates don't match dec hl ld a, [hli] ld b, a - ld a, [hPlayerFacing] + ldh a, [hPlayerFacing] rrca jr c, .pushingDown ; pushing up - ld a, [hPlayerYCoord] + ldh a, [hPlayerYCoord] dec a jr .compareYCoords .pushingDown - ld a, [hPlayerYCoord] + ldh a, [hPlayerYCoord] inc a .compareYCoords cp b @@ -417,19 +417,19 @@ CheckForBoulderCollisionWithSprites: .pushingHorizontallyLoop ld a, [hli] ld b, a - ld a, [hPlayerYCoord] + ldh a, [hPlayerYCoord] cp b jr nz, .nextSprite2 ld b, [hl] - ld a, [hPlayerFacing] + ldh a, [hPlayerFacing] bit 2, a jr nz, .pushingLeft ; pushing right - ld a, [hPlayerXCoord] + ldh a, [hPlayerXCoord] inc a jr .compareXCoords .pushingLeft - ld a, [hPlayerXCoord] + ldh a, [hPlayerXCoord] dec a .compareXCoords cp b diff --git a/engine/overworld/push_boulder.asm b/engine/overworld/push_boulder.asm index da1c6dee..4cef8b64 100644 --- a/engine/overworld/push_boulder.asm +++ b/engine/overworld/push_boulder.asm @@ -6,15 +6,15 @@ TryPushingBoulder:: bit 1, a ; has boulder dust animation from previous push played yet? ret nz xor a - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call IsSpriteInFrontOfPlayer - ld a, [hSpriteIndexOrTextID] + ldh a, [hSpriteIndexOrTextID] ld [wBoulderSpriteIndex], a and a jp z, ResetBoulderPushFlags ld hl, wSpritePlayerStateData1MovementStatus ld d, $0 - ld a, [hSpriteIndexOrTextID] + ldh a, [hSpriteIndexOrTextID] swap a ld e, a add hl, de @@ -27,14 +27,14 @@ TryPushingBoulder:: bit 6, [hl] set 6, [hl] ; indicate that the player has tried pushing ret z ; the player must try pushing twice before the boulder will move - ld a, [hJoyHeld] + ldh a, [hJoyHeld] and D_RIGHT | D_LEFT | D_UP | D_DOWN ret z predef CheckForCollisionWhenPushingBoulder ld a, [wTileInFrontOfBoulderAndBoulderCollisionResult] and a ; was there a collision? jp nz, ResetBoulderPushFlags - ld a, [hJoyHeld] + ldh a, [hJoyHeld] ld b, a ld a, [wSpritePlayerStateData1FacingDirection] cp SPRITE_FACING_UP @@ -86,13 +86,13 @@ DoBoulderDustAnimation:: ld a, [wd730] bit 0, a ret nz - callab AnimateBoulderDust + callfar AnimateBoulderDust call DiscardButtonPresses ld [wJoyIgnore], a call ResetBoulderPushFlags set 7, [hl] ld a, [wBoulderSpriteIndex] - ld [hSpriteIndex], a + ldh [hSpriteIndex], a call GetSpriteMovementByte2Pointer ld [hl], $10 ld a, SFX_CUT diff --git a/engine/overworld/special_warps.asm b/engine/overworld/special_warps.asm index 042146f9..54471ee0 100644 --- a/engine/overworld/special_warps.asm +++ b/engine/overworld/special_warps.asm @@ -34,7 +34,7 @@ LoadSpecialWarpData: cp TRADE_CENTER jr nz, .notTradeCenter ld hl, TradeCenterSpec1 - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] cp USING_INTERNAL_CLOCK ; which gameboy is clocking determines who is on the left and who is on the right jr z, .copyWarpData ld hl, TradeCenterSpec2 @@ -43,7 +43,7 @@ LoadSpecialWarpData: cp COLOSSEUM jr nz, .notColosseum ld hl, ColosseumSpec1 - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] cp USING_INTERNAL_CLOCK jr z, .copyWarpData ld hl, ColosseumSpec2 diff --git a/engine/overworld/sprite_collisions.asm b/engine/overworld/sprite_collisions.asm index 48cd95b9..dc57d5b9 100644 --- a/engine/overworld/sprite_collisions.asm +++ b/engine/overworld/sprite_collisions.asm @@ -1,15 +1,15 @@ _UpdateSprites:: ld h, $c1 inc h - ld a, wSpritePlayerStateData2ImageBaseOffset - wSpritePlayerStateData2 + ld a, SPRITESTATEDATA2_IMAGEBASEOFFSET .spriteLoop ld l, a - sub wSpritePlayerStateData2ImageBaseOffset - wSpritePlayerStateData2 + sub SPRITESTATEDATA2_IMAGEBASEOFFSET ld c, a - ld [hCurrentSpriteOffset], a + ldh [hCurrentSpriteOffset], a ld a, [hl] and a - jr z, .skipSprite ; tests $c2Xe + jr z, .skipSprite ; tests SPRITESTATEDATA2_IMAGEBASEOFFSET push hl push de push bc @@ -20,7 +20,7 @@ _UpdateSprites:: .skipSprite ld a, l add $10 ; move to next sprite - cp wSpritePlayerStateData2ImageBaseOffset - wSpritePlayerStateData2 ; test for overflow (back at beginning) + cp SPRITESTATEDATA2_IMAGEBASEOFFSET ; test for overflow (back at beginning) jr nz, .spriteLoop ret .updateCurrentSprite @@ -31,10 +31,10 @@ _UpdateSprites:: UpdateNonPlayerSprite: dec a swap a - ld [hTilePlayerStandingOn], a ; $10 * sprite# + ldh [hTilePlayerStandingOn], a ; $10 * sprite# ld a, [wNPCMovementScriptSpriteOffset] ; some sprite offset? ld b, a - ld a, [hCurrentSpriteOffset] + ldh a, [hCurrentSpriteOffset] cp b jr nz, .unequal jp DoScriptedNPCMovement @@ -43,22 +43,23 @@ UpdateNonPlayerSprite: ; This detects if the current sprite (whose offset is at hCurrentSpriteOffset) ; is going to collide with another sprite by looping over the other sprites. -; The current sprite's offset will be labelled with i (e.g. $c1i0). -; The loop sprite's offset will labelled with j (e.g. $c1j0). +; The current sprite's offset will be labelled with i (e.g. i#SPRITESTATEDATA1_PICTUREID). +; The loop sprite's offset will labelled with j (e.g. j#SPRITESTATEDATA1_PICTUREID). ; -; Note that the Y coordinate of the sprite (in [$c1k4]) is one of the following -; 9 values when the sprite is aligned with the grid: $fc, $0c, $1c, $2c, ..., $7c. +; Note that the Y coordinate of the sprite (in [k#SPRITESTATEDATA1_YPIXELS]) +; is one of the following 9 values when the sprite is aligned with the grid: +; $fc, $0c, $1c, $2c, ..., $7c. ; The reason that 4 is added below to the coordinate is to make it align with a ; multiple of $10 to make comparisons easier. DetectCollisionBetweenSprites: nop - ld h, wSpriteStateData1 / $100 - ld a, [hCurrentSpriteOffset] - add wSpriteStateData1 % $100 + ld h, HIGH(wSpriteStateData1) + ldh a, [hCurrentSpriteOffset] + add LOW(wSpriteStateData1) ld l, a - ld a, [hl] ; a = [$c1i0] (picture) (0 if slot is unused) + ld a, [hl] ; a = [i#SPRITESTATEDATA1_PICTUREID] (0 if slot is unused) and a ; is this sprite slot slot used? ret z ; return if not used @@ -66,10 +67,10 @@ DetectCollisionBetweenSprites: add 3 ld l, a - ld a, [hli] ; a = [$c1i3] (delta Y) (-1, 0, or 1) + ld a, [hli] ; a = [i#SPRITESTATEDATA1_YSTEPVECTOR] (-1, 0, or 1) call SetSpriteCollisionValues - ld a, [hli] ; a = [$C1i4] (Y screen coordinate) + ld a, [hli] ; a = [i#SPRITESTATEDATA1_YPIXELS] add 4 ; align with multiple of $10 ; The effect of the following 3 lines is to @@ -79,11 +80,11 @@ DetectCollisionBetweenSprites: and $f0 or c - ld [hFF90], a ; store Y coordinate adjusted for direction of movement + ldh [hFF90], a ; store Y coordinate adjusted for direction of movement - ld a, [hli] ; a = [$c1i5] (delta X) (-1, 0, or 1) + ld a, [hli] ; a = [i#SPRITESTATEDATA1_XSTEPVECTOR] (-1, 0, or 1) call SetSpriteCollisionValues - ld a, [hl] ; a = [$C1i6] (X screen coordinate) + ld a, [hl] ; a = [i#SPRITESTATEDATA1_XPIXELS] ; The effect of the following 3 lines is to ; add 7 to a if moving east or @@ -92,52 +93,52 @@ DetectCollisionBetweenSprites: and $f0 or c - ld [hFF91], a ; store X coordinate adjusted for direction of movement + ldh [hFF91], a ; store X coordinate adjusted for direction of movement ld a, l add 7 ld l, a xor a - ld [hld], a ; zero [$c1id] XXX what's [$c1id] for? - ld [hld], a ; zero [$c1ic] (directions in which collisions occurred) + ld [hld], a ; zero [i#SPRITESTATEDATA1_0D] XXX what's this for? + ld [hld], a ; zero [i#SPRITESTATEDATA1_COLLISIONDATA] - ld a, [hFF91] - ld [hld], a ; [$c1ib] = adjusted X coordinate - ld a, [hFF90] - ld [hl], a ; [$c1ia] = adjusted Y coordinate + ldh a, [hFF91] + ld [hld], a ; [i#SPRITESTATEDATA1_XADJUSTED] + ldh a, [hFF90] + ld [hl], a ; [i#SPRITESTATEDATA1_YADJUSTED] xor a ; zero the loop counter .loop - ld [hFF8F], a ; store loop counter + ldh [hFF8F], a ; store loop counter swap a ld e, a - ld a, [hCurrentSpriteOffset] + ldh a, [hCurrentSpriteOffset] cp e ; does the loop sprite match the current sprite? jp z, .next ; go to the next sprite if they match ld d, h - ld a, [de] ; a = [$c1j0] (picture) (0 if slot is unused) + ld a, [de] ; a = [j#SPRITESTATEDATA1_PICTUREID] (0 if slot is unused) and a ; is this sprite slot slot used? jp z, .next ; go the next sprite if not used inc e inc e - ld a, [de] ; a = [$c1j2] ($ff means the sprite is offscreen) + ld a, [de] ; a = [j#SPRITESTATEDATA1_IMAGEINDEX] ($ff means the sprite is offscreen) inc a jp z, .next ; go the next sprite if offscreen - ld a, [hCurrentSpriteOffset] + ldh a, [hCurrentSpriteOffset] add 10 ld l, a inc e - ld a, [de] ; a = [$c1j3] (delta Y) + ld a, [de] ; a = [j#SPRITESTATEDATA1_YSTEPVECTOR] call SetSpriteCollisionValues inc e - ld a, [de] ; a = [$C1j4] (Y screen coordinate) + ld a, [de] ; a = [j#SPRITESTATEDATA1_YPIXELS] add 4 ; align with multiple of $10 ; The effect of the following 3 lines is to @@ -147,18 +148,18 @@ DetectCollisionBetweenSprites: and $f0 or c - sub [hl] ; subtract the adjusted Y coordinate of sprite i ([$c1ia]) from that of sprite j + sub [hl] ; subtract [i#SPRITESTATEDATA1_YADJUSTED] from [j#SPRITESTATEDATA1_YADJUSTED] ; calculate the absolute value of the difference to get the distance jr nc, .noCarry1 cpl inc a .noCarry1 - ld [hFF90], a ; store the distance between the two sprites' adjusted Y values + ldh [hFF90], a ; store the distance between the two sprites' adjusted Y values ; Use the carry flag set by the above subtraction to determine which sprite's -; Y coordinate is larger. This information is used later to set [$c1ic], -; which stores which direction the collision occurred in. +; Y coordinate is larger. This information is used later to set +; [i#SPRITESTATEDATA1_COLLISIONDATA]. ; The following 5 lines set the lowest 2 bits of c, which are later shifted left by 2. ; If sprite i's Y is larger, set lowest 2 bits of c to 10. ; If sprite j's Y is larger or both are equal, set lowest 2 bits of c to 01. @@ -170,30 +171,30 @@ DetectCollisionBetweenSprites: ; If sprite i's delta Y is 0, then b = 7, else b = 9. ld b, 7 - ld a, [hl] ; a = [$c1ia] (adjusted Y coordinate) + ld a, [hl] ; a = [i#SPRITESTATEDATA1_YADJUSTED] and $f jr z, .next1 ld b, 9 .next1 - ld a, [hFF90] ; a = distance between adjusted Y coordinates + ldh a, [hFF90] ; a = distance between adjusted Y coordinates sub b - ld [hFF92], a ; store distance adjusted using sprite i's direction + ldh [hFF92], a ; store distance adjusted using sprite i's direction ld a, b - ld [hFF90], a ; store 7 or 9 depending on sprite i's delta Y + ldh [hFF90], a ; store 7 or 9 depending on sprite i's delta Y jr c, .checkXDistance ; If sprite j's delta Y is 0, then b = 7, else b = 9. ld b, 7 dec e - ld a, [de] ; a = [$c1j3] (delta Y) + ld a, [de] ; a = [j#SPRITESTATEDATA1_YSTEPVECTOR] inc e and a jr z, .next2 ld b, 9 .next2 - ld a, [hFF92] ; a = distance adjusted using sprite i's direction + ldh a, [hFF92] ; a = distance adjusted using sprite i's direction sub b ; adjust distance using sprite j's direction jr z, .checkXDistance jr nc, .next ; go to next sprite if distance is still positive after both adjustments @@ -201,13 +202,13 @@ DetectCollisionBetweenSprites: .checkXDistance inc e inc l - ld a, [de] ; a = [$c1j5] (delta X) + ld a, [de] ; a = [j#SPRITESTATEDATA1_XSTEPVECTOR] push bc call SetSpriteCollisionValues inc e - ld a, [de] ; a = [$c1j6] (X screen coordinate) + ld a, [de] ; a = [j#SPRITESTATEDATA1_XPIXELS] ; The effect of the following 3 lines is to ; add 7 to a if moving east or @@ -218,18 +219,18 @@ DetectCollisionBetweenSprites: pop bc - sub [hl] ; subtract the adjusted X coordinate of sprite i ([$c1ib]) from that of sprite j + sub [hl] ; subtract [i#SPRITESTATEDATA1_XADJUSTED] from [j#SPRITESTATEDATA1_XADJUSTED] ; calculate the absolute value of the difference to get the distance jr nc, .noCarry2 cpl inc a .noCarry2 - ld [hFF91], a ; store the distance between the two sprites' adjusted X values + ldh [hFF91], a ; store the distance between the two sprites' adjusted X values ; Use the carry flag set by the above subtraction to determine which sprite's -; X coordinate is larger. This information is used later to set [$c1ic], -; which stores which direction the collision occurred in. +; X coordinate is larger. This information is used later to set +; [i#SPRITESTATEDATA1_COLLISIONDATA]. ; The following 5 lines set the lowest 2 bits of c. ; If sprite i's X is larger, set lowest 2 bits of c to 10. ; If sprite j's X is larger or both are equal, set lowest 2 bits of c to 01. @@ -241,38 +242,38 @@ DetectCollisionBetweenSprites: ; If sprite i's delta X is 0, then b = 7, else b = 9. ld b, 7 - ld a, [hl] ; a = [$c1ib] (adjusted X coordinate) + ld a, [hl] ; a = [i#SPRITESTATEDATA1_XADJUSTED] and $f jr z, .next3 ld b, 9 .next3 - ld a, [hFF91] ; a = distance between adjusted X coordinates + ldh a, [hFF91] ; a = distance between adjusted X coordinates sub b - ld [hFF92], a ; store distance adjusted using sprite i's direction + ldh [hFF92], a ; store distance adjusted using sprite i's direction ld a, b - ld [hFF91], a ; store 7 or 9 depending on sprite i's delta X + ldh [hFF91], a ; store 7 or 9 depending on sprite i's delta X jr c, .collision ; If sprite j's delta X is 0, then b = 7, else b = 9. ld b, 7 dec e - ld a, [de] ; a = [$c1j5] (delta X) + ld a, [de] ; a = [j#SPRITESTATEDATA1_XSTEPVECTOR] inc e and a jr z, .next4 ld b, 9 .next4 - ld a, [hFF92] ; a = distance adjusted using sprite i's direction + ldh a, [hFF92] ; a = distance adjusted using sprite i's direction sub b ; adjust distance using sprite j's direction jr z, .collision jr nc, .next ; go to next sprite if distance is still positive after both adjustments .collision - ld a, [hFF91] ; a = 7 or 9 depending on sprite i's delta X + ldh a, [hFF91] ; a = 7 or 9 depending on sprite i's delta X ld b, a - ld a, [hFF90] ; a = 7 or 9 depending on sprite i's delta Y + ldh a, [hFF90] ; a = 7 or 9 depending on sprite i's delta Y inc l ; If delta X isn't 0 and delta Y is 0, then b = %0011, else b = %1100. @@ -287,14 +288,15 @@ DetectCollisionBetweenSprites: .next6 ld a, c ; c has 2 bits set (one of bits 0-1 is set for the X axis and one of bits 2-3 for the Y axis) and b ; we select either the bit in bits 0-1 or bits 2-3 based on the calculation immediately above - or [hl] ; or with existing collision direction bits in [$c1ic] + or [hl] ; or with existing collision direction bits in [i#SPRITESTATEDATA1_COLLISIONDATA] ld [hl], a ; store new value ld a, c ; useless code because a is overwritten before being used again -; set bit in [$c1ie] or [$c1if] to indicate which sprite the collision occurred with +; set bit in [i#SPRITESTATEDATA1_0E] or [i#SPRITESTATEDATA1_0F] +; to indicate which sprite the collision occurred with inc l inc l - ld a, [hFF8F] ; a = loop counter + ldh a, [hFF8F] ; a = loop counter ld de, SpriteCollisionBitTable add a add e @@ -311,7 +313,7 @@ DetectCollisionBetweenSprites: ld [hl], a .next - ld a, [hFF8F] ; a = loop counter + ldh a, [hFF8F] ; a = loop counter inc a cp $10 jp nz, .loop diff --git a/engine/overworld/tilesets.asm b/engine/overworld/tilesets.asm index 88147233..f40cbbc2 100644 --- a/engine/overworld/tilesets.asm +++ b/engine/overworld/tilesets.asm @@ -23,9 +23,9 @@ LoadTilesetHeader: dec c jr nz, .copyTilesetHeaderLoop ld a, [hl] - ld [hTilesetType], a + ldh [hTilesetType], a xor a - ld [hMovingBGTilesCounter1], a + ldh [hMovingBGTilesCounter1], a pop hl ld a, [wCurMapTileset] push hl @@ -38,7 +38,7 @@ LoadTilesetHeader: jr c, .asm_c797 ld a, [wCurMapTileset] ld b, a - ld a, [hPreviousTileset] + ldh a, [hPreviousTileset] cp b jr z, .done .asm_c797 diff --git a/engine/overworld/trainer_sight.asm b/engine/overworld/trainer_sight.asm index c12c064b..816dea7f 100755 --- a/engine/overworld/trainer_sight.asm +++ b/engine/overworld/trainer_sight.asm @@ -1,77 +1,77 @@ _GetSpritePosition1:: ld hl, wSpriteStateData1 - ld de, wSpritePlayerStateData1YPixels - wSpritePlayerStateData1 + ld de, SPRITESTATEDATA1_YPIXELS ld a, [wSpriteIndex] - ld [hSpriteIndex], a + ldh [hSpriteIndex], a call GetSpriteDataPointer - ld a, [hli] ; c1x4 (screen Y pos) - ld [hSpriteScreenYCoord], a + ld a, [hli] ; x#SPRITESTATEDATA1_YPIXELS + ldh [hSpriteScreenYCoord], a inc hl - ld a, [hl] ; c1x6 (screen X pos) - ld [hSpriteScreenXCoord], a + ld a, [hl] ; x#SPRITESTATEDATA1_XPIXELS + ldh [hSpriteScreenXCoord], a ld de, wSpritePlayerStateData2MapY - wSpritePlayerStateData1XPixels add hl, de - ld a, [hli] ; c2x4 (map Y pos) - ld [hSpriteMapYCoord], a - ld a, [hl] ; c2x5 (map X pos) - ld [hSpriteMapXCoord], a + ld a, [hli] ; x#SPRITESTATEDATA2_MAPY + ldh [hSpriteMapYCoord], a + ld a, [hl] ; x#SPRITESTATEDATA2_MAPX + ldh [hSpriteMapXCoord], a ret _GetSpritePosition2:: ld hl, wSpriteStateData1 - ld de, wSpritePlayerStateData1YPixels - wSpritePlayerStateData1 + ld de, SPRITESTATEDATA1_YPIXELS ld a, [wSpriteIndex] - ld [hSpriteIndex], a + ldh [hSpriteIndex], a call GetSpriteDataPointer - ld a, [hli] ; c1x4 (screen Y pos) + ld a, [hli] ; x#SPRITESTATEDATA1_YPIXELS ld [wSavedSpriteScreenY], a inc hl - ld a, [hl] ; c1x6 (screen X pos) + ld a, [hl] ; x#SPRITESTATEDATA1_XPIXELS ld [wSavedSpriteScreenX], a ld de, wSpritePlayerStateData2MapY - wSpritePlayerStateData1XPixels add hl, de - ld a, [hli] ; c2x4 (map Y pos) + ld a, [hli] ; x#SPRITESTATEDATA2_MAPY ld [wSavedSpriteMapY], a - ld a, [hl] ; c2x5 (map X pos) + ld a, [hl] ; x#SPRITESTATEDATA2_MAPX ld [wSavedSpriteMapX], a ret _SetSpritePosition1:: ld hl, wSpriteStateData1 - ld de, wSpritePlayerStateData1YPixels - wSpritePlayerStateData1 + ld de, SPRITESTATEDATA1_YPIXELS ld a, [wSpriteIndex] - ld [hSpriteIndex], a + ldh [hSpriteIndex], a call GetSpriteDataPointer - ld a, [hSpriteScreenYCoord] ; c1x4 (screen Y pos) + ldh a, [hSpriteScreenYCoord] ; x#SPRITESTATEDATA1_YPIXELS ld [hli], a inc hl - ld a, [hSpriteScreenXCoord] ; c1x6 (screen X pos) + ldh a, [hSpriteScreenXCoord] ; x#SPRITESTATEDATA1_XPIXELS ld [hl], a ld de, wSpritePlayerStateData2MapY - wSpritePlayerStateData1XPixels add hl, de - ld a, [hSpriteMapYCoord] ; c2x4 (map Y pos) + ldh a, [hSpriteMapYCoord] ; x#SPRITESTATEDATA2_MAPY ld [hli], a - ld a, [hSpriteMapXCoord] ; c2x5 (map X pos) + ldh a, [hSpriteMapXCoord] ; x#SPRITESTATEDATA2_MAPX ld [hl], a ret _SetSpritePosition2:: ld hl, wSpriteStateData1 - ld de, wSpritePlayerStateData1YPixels - wSpritePlayerStateData1 + ld de, SPRITESTATEDATA1_YPIXELS ld a, [wSpriteIndex] - ld [hSpriteIndex], a + ldh [hSpriteIndex], a call GetSpriteDataPointer ld a, [wSavedSpriteScreenY] - ld [hli], a ; c1x4 (screen Y pos) + ld [hli], a ; x#SPRITESTATEDATA1_YPIXELS inc hl ld a, [wSavedSpriteScreenX] - ld [hl], a ; c1x6 (screen X pos) + ld [hl], a ; x#SPRITESTATEDATA1_XPIXELS ld de, wSpritePlayerStateData2MapY - wSpritePlayerStateData1XPixels add hl, de ld a, [wSavedSpriteMapY] - ld [hli], a ; c2x4 (map Y pos) + ld [hli], a ; x#SPRITESTATEDATA2_MAPY ld a, [wSavedSpriteMapX] - ld [hl], a ; c2x5 (map X pos) + ld [hl], a ; x#SPRITESTATEDATA2_MAPX ret TrainerWalkUpToPlayer:: @@ -144,7 +144,7 @@ TrainerWalkUpToPlayer:: call FillMemory ; write the necessary steps to reach player ld [hl], $ff ; write end of list sentinel ld a, [wSpriteIndex] - ld [hSpriteIndex], a + ldh [hSpriteIndex], a jp MoveSprite_ ; input: de = offset within sprite entry @@ -152,7 +152,7 @@ TrainerWalkUpToPlayer:: GetSpriteDataPointer: push de add hl, de - ld a, [hSpriteIndex] + ldh a, [hSpriteIndex] swap a ld d, $0 ld e, a @@ -165,23 +165,23 @@ TrainerEngage: push hl push de ld a, [wTrainerSpriteOffset] - add wSpritePlayerStateData1ImageIndex - wSpritePlayerStateData1 + add SPRITESTATEDATA1_IMAGEINDEX ld d, $0 ld e, a ld hl, wSpriteStateData1 add hl, de - ld a, [hl] ; c1x2: sprite image index + ld a, [hl] ; x#SPRITESTATEDATA1_IMAGEINDEX sub $ff jr nz, .spriteOnScreen ; test if sprite is on screen jp .noEngage .spriteOnScreen ld a, [wTrainerSpriteOffset] - add wSpritePlayerStateData1FacingDirection - wSpritePlayerStateData1 + add SPRITESTATEDATA1_FACINGDIRECTION ld d, $0 ld e, a ld hl, wSpriteStateData1 add hl, de - ld a, [hl] ; c1x9: facing direction + ld a, [hl] ; x#SPRITESTATEDATA1_FACINGDIRECTION ld [wTrainerFacingDirection], a call ReadTrainerScreenPosition ld a, [wTrainerScreenY] ; sprite screen Y pos @@ -234,20 +234,20 @@ TrainerEngage: ; reads trainer's Y position to wTrainerScreenY and X position to wTrainerScreenX ReadTrainerScreenPosition: ld a, [wTrainerSpriteOffset] - add wSpritePlayerStateData1YPixels - wSpritePlayerStateData1 + add SPRITESTATEDATA1_YPIXELS ld d, $0 ld e, a ld hl, wSpriteStateData1 add hl, de - ld a, [hl] ; c1x4 (sprite Y pos) + ld a, [hl] ; x#SPRITESTATEDATA1_YPIXELS ld [wTrainerScreenY], a ld a, [wTrainerSpriteOffset] - add wSpritePlayerStateData1XPixels - wSpritePlayerStateData1 + add SPRITESTATEDATA1_XPIXELS ld d, $0 ld e, a ld hl, wSpriteStateData1 add hl, de - ld a, [hl] ; c1x6 (sprite X pos) + ld a, [hl] ; x#SPRITESTATEDATA1_XPIXELS ld [wTrainerScreenX], a ret @@ -295,24 +295,24 @@ CheckPlayerIsInFrontOfSprite: cp POWER_PLANT jp z, .engage ; bypass this for power plant to get voltorb fake items to work ld a, [wTrainerSpriteOffset] - add wSpritePlayerStateData1YPixels - wSpritePlayerStateData1 + add SPRITESTATEDATA1_YPIXELS ld d, $0 ld e, a ld hl, wSpriteStateData1 add hl, de - ld a, [hl] ; c1x4 (sprite screen Y pos) + ld a, [hl] ; x#SPRITESTATEDATA1_YPIXELS cp $fc jr nz, .notOnTopmostTile ; special case if sprite is on topmost tile (Y = $fc (-4)), make it come down a block ld a, $c .notOnTopmostTile ld [wTrainerScreenY], a ld a, [wTrainerSpriteOffset] - add wSpritePlayerStateData1XPixels - wSpritePlayerStateData1 + add SPRITESTATEDATA1_XPIXELS ld d, $0 ld e, a ld hl, wSpriteStateData1 add hl, de - ld a, [hl] ; c1x6 (sprite screen X pos) + ld a, [hl] ; x#SPRITESTATEDATA1_XPIXELS ld [wTrainerScreenX], a ld a, [wTrainerFacingDirection] ; facing direction cp SPRITE_FACING_DOWN diff --git a/engine/overworld/turn_sprite.asm b/engine/overworld/turn_sprite.asm index bef26537..7b34a03a 100755 --- a/engine/overworld/turn_sprite.asm +++ b/engine/overworld/turn_sprite.asm @@ -1,25 +1,25 @@ UpdateSpriteFacingOffsetAndDelayMovement:: - ld h, $c2 - ld a, [hCurrentSpriteOffset] + ld h, HIGH(wSpriteStateData2) + ldh a, [hCurrentSpriteOffset] add $8 ld l, a ld a, $7f ; maximum movement delay - ld [hl], a ; c2x8 (movement delay) - dec h - ld a, [hCurrentSpriteOffset] + ld [hl], a ; x#SPRITESTATEDATA2_MOVEMENTDELAY + dec h ; HIGH(wSpriteStateData1) + ldh a, [hCurrentSpriteOffset] add $9 ld l, a - ld a, [hld] ; c1x9 (facing direction) + ld a, [hld] ; x#SPRITESTATEDATA1_FACINGDIRECTION ld b, a xor a ld [hld], a - ld [hl], a ; c1x8 (walk animation frame) - ld a, [hCurrentSpriteOffset] - add $2 + ld [hl], a ; x#SPRITESTATEDATA1_ANIMFRAMECOUNTER + ldh a, [hCurrentSpriteOffset] + add SPRITESTATEDATA1_IMAGEINDEX ld l, a - ld a, [hl] ; c1x2 (facing and animation table offset) + ld a, [hl] ; x#SPRITESTATEDATA1_IMAGEINDEX or b ; or in the facing direction ld [hld], a ld a, $2 ; delayed movement status - ld [hl], a ; c1x1 (movement status) + ld [hl], a ; x#SPRITESTATEDATA1_MOVEMENTSTATUS ret diff --git a/engine/overworld/update_map.asm b/engine/overworld/update_map.asm index 92ae2b10..53a5592d 100644 --- a/engine/overworld/update_map.asm +++ b/engine/overworld/update_map.asm @@ -50,13 +50,13 @@ RedrawMapView: ld a, [wIsInBattle] inc a ret z - ld a, [hAutoBGTransferEnabled] + ldh a, [hAutoBGTransferEnabled] push af - ld a, [hTilesetType] + ldh a, [hTilesetType] push af xor a - ld [hAutoBGTransferEnabled], a - ld [hTilesetType], a ; no flower/water BG tile animations + ldh [hAutoBGTransferEnabled], a + ldh [hTilesetType], a ; no flower/water BG tile animations call LoadCurrentMapView call RunDefaultPaletteCommand ld hl, wMapViewVRAMPointer @@ -73,7 +73,7 @@ RedrawMapView: ld a, h ld [wBuffer + 1], a ; this copy of the address is not used ld a, 2 - ld [hRedrawMapViewRowOffset], a + ldh [hRedrawMapViewRowOffset], a ld c, SCREEN_HEIGHT / 2 ; number of rows of 2x2 tiles (this covers the whole screen) .redrawRowLoop push bc @@ -81,7 +81,7 @@ RedrawMapView: push hl ld hl, wTileMap - 2 * SCREEN_WIDTH ld de, SCREEN_WIDTH - ld a, [hRedrawMapViewRowOffset] + ldh a, [hRedrawMapViewRowOffset] .calcWRAMAddrLoop add hl, de dec a @@ -89,7 +89,7 @@ RedrawMapView: call CopyToRedrawRowOrColumnSrcTiles pop hl ld de, BG_MAP_WIDTH - ld a, [hRedrawMapViewRowOffset] + ldh a, [hRedrawMapViewRowOffset] ld c, a .calcVRAMAddrLoop add hl, de @@ -98,11 +98,11 @@ RedrawMapView: or $98 dec c jr nz, .calcVRAMAddrLoop - ld [hRedrawRowOrColumnDest + 1], a + ldh [hRedrawRowOrColumnDest + 1], a ld a, l - ld [hRedrawRowOrColumnDest], a + ldh [hRedrawRowOrColumnDest], a ld a, REDRAW_ROW - ld [hRedrawRowOrColumnMode], a + ldh [hRedrawRowOrColumnMode], a call DelayFrame ld hl, hRedrawMapViewRowOffset inc [hl] @@ -112,9 +112,9 @@ RedrawMapView: dec c jr nz, .redrawRowLoop pop af - ld [hTilesetType], a + ldh [hTilesetType], a pop af - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ret CompareHLWithBC: diff --git a/engine/play_time.asm b/engine/play_time.asm index 504830cb..29897242 100755 --- a/engine/play_time.asm +++ b/engine/play_time.asm @@ -56,6 +56,6 @@ CountDownIgnoreInputBitReset: ld [wd730], a ret z xor a - ld [hJoyPressed], a - ld [hJoyHeld], a + ldh [hJoyPressed], a + ldh [hJoyHeld], a ret diff --git a/engine/pokemon/add_mon.asm b/engine/pokemon/add_mon.asm index 8d0a6495..0c72ff5b 100644 --- a/engine/pokemon/add_mon.asm +++ b/engine/pokemon/add_mon.asm @@ -15,7 +15,7 @@ _AddPartyMon:: ret nc ; return if the party is already full ld [de], a ld a, [de] - ld [hNewPartyLength], a + ldh [hNewPartyLength], a add e ld e, a jr nc, .noCarry @@ -32,7 +32,7 @@ _AddPartyMon:: jr z, .next2 ld hl, wEnemyMonOT .next2 - ld a, [hNewPartyLength] + ldh a, [hNewPartyLength] dec a call SkipFixedLengthTextEntries ld d, h @@ -44,7 +44,7 @@ _AddPartyMon:: and a jr nz, .skipNaming ld hl, wPartyMonNicks - ld a, [hNewPartyLength] + ldh a, [hNewPartyLength] dec a call SkipFixedLengthTextEntries ld a, NAME_MON_SCREEN @@ -57,7 +57,7 @@ _AddPartyMon:: jr z, .next3 ld hl, wEnemyMons .next3 - ld a, [hNewPartyLength] + ldh a, [hNewPartyLength] dec a ld bc, wPartyMon2 - wPartyMon1 call AddNTimes @@ -129,10 +129,10 @@ _AddPartyMon:: xor a ld b, a call CalcStat ; calc HP stat (set cur Hp to max HP) - ld a, [hMultiplicand+1] + ldh a, [hMultiplicand+1] ld [de], a inc de - ld a, [hMultiplicand+2] + ldh a, [hMultiplicand+2] ld [de], a inc de xor a @@ -201,16 +201,16 @@ _AddPartyMon:: push de ld a, [wCurEnemyLVL] ld d, a - callab CalcExperience + callfar CalcExperience pop de inc de - ld a, [hExperience] ; write experience + ldh a, [hExperience] ; write experience ld [de], a inc de - ld a, [hExperience + 1] + ldh a, [hExperience + 1] ld [de], a inc de - ld a, [hExperience + 2] + ldh a, [hExperience + 2] ld [de], a xor a ld b, NUM_STATS * 2 @@ -498,7 +498,7 @@ _MoveMon:: add $2 ld [wMonDataLocation], a call LoadMonData - callba CalcLevelFromExperience + farcall CalcLevelFromExperience ld a, d ld [wCurEnemyLVL], a pop hl diff --git a/engine/pokemon/bills_pc.asm b/engine/pokemon/bills_pc.asm index 7877ada1..df02a496 100644 --- a/engine/pokemon/bills_pc.asm +++ b/engine/pokemon/bills_pc.asm @@ -1,6 +1,6 @@ DisplayPCMainMenu:: xor a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a call SaveScreenTilesToBuffer2 ld a, [wNumHoFTeams] and a @@ -10,17 +10,17 @@ DisplayPCMainMenu:: ld a, [wNumHoFTeams] and a jr nz, .leaguePCAvailable - coord hl, 0, 0 + hlcoord 0, 0 ld b, 8 ld c, 14 jr .next .noOaksPC - coord hl, 0, 0 + hlcoord 0, 0 ld b, 6 ld c, 14 jr .next .leaguePCAvailable - coord hl, 0, 0 + hlcoord 0, 0 ld b, 10 ld c, 14 .next @@ -30,15 +30,15 @@ DisplayPCMainMenu:: ld [wMaxMenuItem], a CheckEvent EVENT_MET_BILL jr nz, .metBill - coord hl, 2, 2 + hlcoord 2, 2 ld de, SomeonesPCText jr .next2 .metBill - coord hl, 2, 2 + hlcoord 2, 2 ld de, BillsPCText .next2 call PlaceString - coord hl, 2, 4 + hlcoord 2, 4 ld de, wPlayerName call PlaceString ld l, c @@ -47,7 +47,7 @@ DisplayPCMainMenu:: call PlaceString CheckEvent EVENT_GOT_POKEDEX jr z, .noOaksPC2 - coord hl, 2, 6 + hlcoord 2, 6 ld de, OaksPCText call PlaceString ld a, [wNumHoFTeams] @@ -55,20 +55,20 @@ DisplayPCMainMenu:: jr z, .noLeaguePC ld a, 4 ld [wMaxMenuItem], a - coord hl, 2, 8 + hlcoord 2, 8 ld de, PKMNLeaguePCText call PlaceString - coord hl, 2, 10 + hlcoord 2, 10 ld de, LogOffPCText jr .next3 .noLeaguePC - coord hl, 2, 8 + hlcoord 2, 8 ld de, LogOffPCText jr .next3 .noOaksPC2 ld a, $2 ld [wMaxMenuItem], a - coord hl, 2, 6 + hlcoord 2, 6 ld de, LogOffPCText .next3 call PlaceString @@ -82,7 +82,7 @@ DisplayPCMainMenu:: ld [wCurrentMenuItem], a ld [wLastMenuItem], a ld a, 1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ret SomeonesPCText: db "SOMEONE's PC@" @@ -114,16 +114,16 @@ BillsPC_:: BillsPCMenu: ld a, [wParentMenuItem] ld [wCurrentMenuItem], a - ld hl, vChars2 + $780 + ld hl, vChars2 tile $78 ld de, PokeballTileGraphics - lb bc, BANK(PokeballTileGraphics), $01 + lb bc, BANK(PokeballTileGraphics), 1 call CopyVideoData call LoadScreenTilesFromBuffer2DisableBGTransfer - coord hl, 0, 0 + hlcoord 0, 0 ld b, 10 ld c, 12 call TextBoxBorder - coord hl, 2, 2 + hlcoord 2, 2 ld de, BillsPCMenuText call PlaceString ld hl, wTopMenuItemY @@ -146,7 +146,7 @@ BillsPCMenu: ld [wPlayerMonNumber], a ld hl, WhatText call PrintText - coord hl, 9, 14 + hlcoord 9, 14 ld b, 2 ld c, 9 call TextBoxBorder @@ -156,19 +156,19 @@ BillsPCMenu: jr c, .singleDigitBoxNum ; two digit box num sub 9 - coord hl, 17, 16 + hlcoord 17, 16 ld [hl], "1" add "0" jr .next .singleDigitBoxNum add "1" .next - Coorda 18, 16 - coord hl, 10, 16 + ldcoord_a 18, 16 + hlcoord 10, 16 ld de, BoxNoPCText call PlaceString ld a, 1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a call Delay3 call HandleMenuInput bit 1, a @@ -318,7 +318,7 @@ BillsPCRelease: jp BillsPCMenu BillsPCChangeBox: - callba ChangeBox + farcall ChangeBox jp BillsPCMenu DisplayMonListMenu: @@ -380,7 +380,7 @@ HMMoveArray: INCLUDE "data/moves/hm_moves.asm" DisplayDepositWithdrawMenu: - coord hl, 9, 10 + hlcoord 9, 10 ld b, 6 ld c, 9 call TextBoxBorder @@ -390,9 +390,9 @@ DisplayDepositWithdrawMenu: jr nz, .next ld de, WithdrawPCText .next - coord hl, 11, 12 + hlcoord 11, 12 call PlaceString - coord hl, 11, 14 + hlcoord 11, 14 ld de, StatsCancelPCText call PlaceString ld hl, wTopMenuItemY @@ -501,7 +501,7 @@ MonWasReleasedText: text_end CableClubLeftGameboy:: - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK ret z ld a, [wSpritePlayerStateData1FacingDirection] @@ -518,7 +518,7 @@ CableClubLeftGameboy:: tx_pre_jump JustAMomentText CableClubRightGameboy:: - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] cp USING_INTERNAL_CLOCK ret z ld a, [wSpritePlayerStateData1FacingDirection] diff --git a/engine/pokemon/evos_moves.asm b/engine/pokemon/evos_moves.asm index 469d689a..ed44f9a6 100755 --- a/engine/pokemon/evos_moves.asm +++ b/engine/pokemon/evos_moves.asm @@ -11,7 +11,7 @@ TryEvolvingMon: ; this is only called after battle ; it is supposed to do level up evolutions, though there is a bug that allows item evolutions to occur EvolutionAfterBattle: - ld a, [hTilesetType] + ldh a, [hTilesetType] push af xor a ld [wEvolutionOccurred], a @@ -120,16 +120,16 @@ Evolution_PartyMonLoop: ; loop over party mons ld c, 50 call DelayFrames xor a - ld [hAutoBGTransferEnabled], a - coord hl, 0, 0 + ldh [hAutoBGTransferEnabled], a + hlcoord 0, 0 lb bc, 12, 20 call ClearScreenArea ld a, $1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ld a, $ff ld [wUpdateSpritesEnabled], a call ClearSprites - callab EvolveMon + callfar EvolveMon jp c, CancelledEvolution ld hl, EvolvedText call PrintText @@ -245,7 +245,7 @@ Evolution_PartyMonLoop: ; loop over party mons pop bc pop hl pop af - ld [hTilesetType], a + ldh [hTilesetType], a ld a, [wLinkState] cp LINK_STATE_TRADING ret z diff --git a/engine/pokemon/experience.asm b/engine/pokemon/experience.asm index 76e6b88b..427d2a7f 100755 --- a/engine/pokemon/experience.asm +++ b/engine/pokemon/experience.asm @@ -10,15 +10,15 @@ CalcLevelFromExperience:: push hl ld hl, wLoadedMonExp + 2 ; current exp ; compare exp needed for level d with current exp - ld a, [hExperience + 2] + ldh a, [hExperience + 2] ld c, a ld a, [hld] sub c - ld a, [hExperience + 1] + ldh a, [hExperience + 1] ld c, a ld a, [hld] sbc c - ld a, [hExperience] + ldh a, [hExperience] ld c, a ld a, [hl] sbc c @@ -38,56 +38,56 @@ CalcExperience:: add hl, bc call CalcDSquared ld a, d - ld [hMultiplier], a + ldh [hMultiplier], a call Multiply ld a, [hl] and $f0 swap a - ld [hMultiplier], a + ldh [hMultiplier], a call Multiply ld a, [hli] and $f - ld [hDivisor], a + ldh [hDivisor], a ld b, $4 call Divide - ld a, [hQuotient + 1] + ldh a, [hQuotient + 1] push af - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] push af - ld a, [hQuotient + 3] + ldh a, [hQuotient + 3] push af call CalcDSquared ld a, [hl] and $7f - ld [hMultiplier], a + ldh [hMultiplier], a call Multiply - ld a, [hProduct + 1] + ldh a, [hProduct + 1] push af - ld a, [hProduct + 2] + ldh a, [hProduct + 2] push af - ld a, [hProduct + 3] + ldh a, [hProduct + 3] push af ld a, [hli] push af xor a - ld [hMultiplicand], a - ld [hMultiplicand + 1], a + ldh [hMultiplicand], a + ldh [hMultiplicand + 1], a ld a, d - ld [hMultiplicand + 2], a + ldh [hMultiplicand + 2], a ld a, [hli] - ld [hMultiplier], a + ldh [hMultiplier], a call Multiply ld b, [hl] - ld a, [hProduct + 3] + ldh a, [hProduct + 3] sub b - ld [hProduct + 3], a + ldh [hProduct + 3], a ld b, $0 - ld a, [hProduct + 2] + ldh a, [hProduct + 2] sbc b - ld [hProduct + 2], a - ld a, [hProduct + 1] + ldh [hProduct + 2], a + ldh a, [hProduct + 1] sbc b - ld [hProduct + 1], a + ldh [hProduct + 1], a ; The difference of the linear term and the constant term consists of 3 bytes ; starting at hProduct + 1. Below, hExperience (an alias of that address) will ; be used instead for the further work of adding or subtracting the squared @@ -96,54 +96,54 @@ CalcExperience:: and $80 jr nz, .subtractSquaredTerm ; check sign pop bc - ld a, [hExperience + 2] + ldh a, [hExperience + 2] add b - ld [hExperience + 2], a + ldh [hExperience + 2], a pop bc - ld a, [hExperience + 1] + ldh a, [hExperience + 1] adc b - ld [hExperience + 1], a + ldh [hExperience + 1], a pop bc - ld a, [hExperience] + ldh a, [hExperience] adc b - ld [hExperience], a + ldh [hExperience], a jr .addCubedTerm .subtractSquaredTerm pop bc - ld a, [hExperience + 2] + ldh a, [hExperience + 2] sub b - ld [hExperience + 2], a + ldh [hExperience + 2], a pop bc - ld a, [hExperience + 1] + ldh a, [hExperience + 1] sbc b - ld [hExperience + 1], a + ldh [hExperience + 1], a pop bc - ld a, [hExperience] + ldh a, [hExperience] sbc b - ld [hExperience], a + ldh [hExperience], a .addCubedTerm pop bc - ld a, [hExperience + 2] + ldh a, [hExperience + 2] add b - ld [hExperience + 2], a + ldh [hExperience + 2], a pop bc - ld a, [hExperience + 1] + ldh a, [hExperience + 1] adc b - ld [hExperience + 1], a + ldh [hExperience + 1], a pop bc - ld a, [hExperience] + ldh a, [hExperience] adc b - ld [hExperience], a + ldh [hExperience], a ret ; calculates d*d CalcDSquared: xor a - ld [hMultiplicand], a - ld [hMultiplicand + 1], a + ldh [hMultiplicand], a + ldh [hMultiplicand + 1], a ld a, d - ld [hMultiplicand + 2], a - ld [hMultiplier], a + ldh [hMultiplicand + 2], a + ldh [hMultiplier], a jp Multiply INCLUDE "data/growth_rates.asm" diff --git a/engine/pokemon/learn_move.asm b/engine/pokemon/learn_move.asm index e1b1a4c7..8e852fd4 100755 --- a/engine/pokemon/learn_move.asm +++ b/engine/pokemon/learn_move.asm @@ -76,7 +76,7 @@ DontAbandonLearning: AbandonLearning: ld hl, AbandonLearningText call PrintText - coord hl, 14, 7 + hlcoord 14, 7 lb bc, 8, 15 ld a, TWO_OPTION_MENU ld [wTextBoxID], a @@ -99,7 +99,7 @@ TryingToLearn: push hl ld hl, TryingToLearnText call PrintText - coord hl, 14, 7 + hlcoord 14, 7 lb bc, 8, 15 ld a, TWO_OPTION_MENU ld [wTextBoxID], a @@ -114,25 +114,25 @@ TryingToLearn: ld de, wMoves ld bc, NUM_MOVES call CopyData - callab FormatMovesString + callfar FormatMovesString pop hl .loop push hl ld hl, WhichMoveToForgetText call PrintText - coord hl, 4, 7 + hlcoord 4, 7 ld b, 4 ld c, 14 call TextBoxBorder - coord hl, 6, 8 + hlcoord 6, 8 ld de, wMovesString - ld a, [hFlagsFFF6] + ldh a, [hFlagsFFF6] set 2, a - ld [hFlagsFFF6], a + ldh [hFlagsFFF6], a call PlaceString - ld a, [hFlagsFFF6] + ldh a, [hFlagsFFF6] res 2, a - ld [hFlagsFFF6], a + ldh [hFlagsFFF6], a ld hl, wTopMenuItemY ld a, 8 ld [hli], a ; wTopMenuItemY diff --git a/engine/pokemon/load_mon_data.asm b/engine/pokemon/load_mon_data.asm index 480ab1ca..c5e2041a 100644 --- a/engine/pokemon/load_mon_data.asm +++ b/engine/pokemon/load_mon_data.asm @@ -15,7 +15,7 @@ LoadMonData_:: ld a, [wWhichPokemon] ld e, a - callab GetMonSpecies + callfar GetMonSpecies .GetMonHeader ld a, [wcf91] diff --git a/engine/pokemon/status_screen.asm b/engine/pokemon/status_screen.asm index 35cc9502..d4a4e59a 100755 --- a/engine/pokemon/status_screen.asm +++ b/engine/pokemon/status_screen.asm @@ -40,7 +40,7 @@ DrawHP_: push hl call DrawHPBar pop hl - ld a, [hFlagsFFF6] + ldh a, [hFlagsFFF6] bit 0, a jr z, .printFractionBelowBar ld bc, $9 ; right of bar @@ -80,32 +80,32 @@ StatusScreen: ld hl, wd72c set 1, [hl] ld a, $33 - ld [rNR50], a ; Reduce the volume + ldh [rNR50], a ; Reduce the volume call GBPalWhiteOutWithDelay3 call ClearScreen call UpdateSprites call LoadHpBarAndStatusTilePatterns ld de, BattleHudTiles1 ; source - ld hl, vChars2 + $6d0 ; dest - lb bc, BANK(BattleHudTiles1), $03 + ld hl, vChars2 tile $6d ; dest + lb bc, BANK(BattleHudTiles1), 3 call CopyVideoDataDouble ; ·│ :L and halfarrow line end ld de, BattleHudTiles2 - ld hl, vChars2 + $780 - lb bc, BANK(BattleHudTiles2), $01 + ld hl, vChars2 tile $78 + lb bc, BANK(BattleHudTiles2), 1 call CopyVideoDataDouble ; │ ld de, BattleHudTiles3 - ld hl, vChars2 + $760 - lb bc, BANK(BattleHudTiles3), $02 - call CopyVideoDataDouble ; ─┘ + ld hl, vChars2 tile $76 + lb bc, BANK(BattleHudTiles3), 2 + call CopyVideoDataDouble ; ─ ┘ ld de, PTile - ld hl, vChars2 + $720 - lb bc, BANK(PTile), (PTileEnd - PTile) / $8 - call CopyVideoDataDouble ; P (for PP), inline - ld a, [hTilesetType] + ld hl, vChars2 tile $72 + lb bc, BANK(PTile), 1 + call CopyVideoDataDouble ; bold P (for PP) + ldh a, [hTilesetType] push af xor a - ld [hTilesetType], a - coord hl, 19, 1 + ldh [hTilesetType], a + hlcoord 19, 1 lb bc, 6, 10 call DrawLineBox ; Draws the box around name, HP and status ld de, -6 @@ -113,54 +113,54 @@ StatusScreen: ld [hl], "<DOT>" dec hl ld [hl], "№" - coord hl, 19, 9 + hlcoord 19, 9 lb bc, 8, 6 call DrawLineBox ; Draws the box around types, ID No. and OT - coord hl, 10, 9 + hlcoord 10, 9 ld de, Type1Text call PlaceString ; "TYPE1/" - coord hl, 11, 3 + hlcoord 11, 3 predef DrawHP ld hl, wStatusScreenHPBarColor call GetHealthBarColor ld b, SET_PAL_STATUS_SCREEN call RunPaletteCommand - coord hl, 16, 6 + hlcoord 16, 6 ld de, wLoadedMonStatus call PrintStatusCondition jr nz, .StatusWritten - coord hl, 16, 6 + hlcoord 16, 6 ld de, OKText call PlaceString ; "OK" .StatusWritten - coord hl, 9, 6 + hlcoord 9, 6 ld de, StatusText call PlaceString ; "STATUS/" - coord hl, 14, 2 + hlcoord 14, 2 call PrintLevel ; Pokémon level ld a, [wMonHIndex] ld [wd11e], a ld [wd0b5], a predef IndexToPokedex - coord hl, 3, 7 + hlcoord 3, 7 ld de, wd11e lb bc, LEADING_ZEROES | 1, 3 call PrintNumber ; Pokémon no. - coord hl, 11, 10 + hlcoord 11, 10 predef PrintMonType ld hl, NamePointers2 call .GetStringPointer ld d, h ld e, l - coord hl, 9, 1 + hlcoord 9, 1 call PlaceString ; Pokémon name ld hl, OTPointers call .GetStringPointer ld d, h ld e, l - coord hl, 12, 16 + hlcoord 12, 16 call PlaceString ; OT - coord hl, 12, 14 + hlcoord 12, 14 ld de, wLoadedMonOTID lb bc, LEADING_ZEROES | 2, 5 call PrintNumber ; ID Number @@ -168,13 +168,13 @@ StatusScreen: call PrintStatsBox call Delay3 call GBPalNormal - coord hl, 1, 0 + hlcoord 1, 0 call LoadFlippedFrontSpriteByMonIndex ; draw Pokémon picture ld a, [wcf91] call PlayCry ; play Pokémon cry call WaitForTextScrollButtonPress ; wait for button pop af - ld [hTilesetType], a + ldh [hTilesetType], a ret .GetStringPointer @@ -244,27 +244,25 @@ DrawLineBox: ld [hl], $6f ; ← (halfarrow ending) ret -PTile: - INCBIN "gfx/font/P.1bpp" -PTileEnd: +PTile: INCBIN "gfx/font/P.1bpp" PrintStatsBox: ld a, d and a ; a is 0 from the status screen jr nz, .DifferentBox - coord hl, 0, 8 + hlcoord 0, 8 ld b, 8 ld c, 8 call TextBoxBorder ; Draws the box - coord hl, 1, 9 ; Start printing stats from here + hlcoord 1, 9 ; Start printing stats from here ld bc, $19 ; Number offset jr .PrintStats .DifferentBox - coord hl, 9, 2 + hlcoord 9, 2 ld b, 8 ld c, 9 call TextBoxBorder - coord hl, 11, 3 + hlcoord 11, 3 ld bc, $18 .PrintStats push bc @@ -298,11 +296,11 @@ StatsText: next "SPECIAL@" StatusScreen2: - ld a, [hTilesetType] + ldh a, [hTilesetType] push af xor a - ld [hTilesetType], a - ld [hAutoBGTransferEnabled], a + ldh [hTilesetType], a + ldh [hAutoBGTransferEnabled], a ld bc, NUM_MOVES + 1 ld hl, wMoves call FillMemory @@ -310,17 +308,17 @@ StatusScreen2: ld de, wMoves ld bc, NUM_MOVES call CopyData - callab FormatMovesString - coord hl, 9, 2 + callfar FormatMovesString + hlcoord 9, 2 lb bc, 5, 10 call ClearScreenArea ; Clear under name - coord hl, 19, 3 + hlcoord 19, 3 ld [hl], $78 - coord hl, 0, 8 + hlcoord 0, 8 ld b, 8 ld c, 18 call TextBoxBorder ; Draw move container - coord hl, 2, 9 + hlcoord 2, 9 ld de, wMovesString call PlaceString ; Print moves ld a, [wNumMovesMinusOne] @@ -329,7 +327,7 @@ StatusScreen2: ld a, $4 sub c ld b, a ; Number of moves ? - coord hl, 11, 10 + hlcoord 11, 10 ld de, SCREEN_WIDTH * 2 ld a, "<BOLD_P>" call StatusScreen_PrintPP ; Print "PP" @@ -341,7 +339,7 @@ StatusScreen2: call StatusScreen_PrintPP ; Fill the rest with -- .InitPP ld hl, wLoadedMonMoves - coord de, 14, 10 + decoord 14, 10 ld b, 0 .PrintPP ld a, [hli] @@ -356,7 +354,7 @@ StatusScreen2: ld a, b ld [hl], a push hl - callab GetMaxPP + callfar GetMaxPP pop hl pop af ld [hl], a @@ -391,7 +389,7 @@ StatusScreen2: cp $4 jr nz, .PrintPP .PPDone - coord hl, 9, 3 + hlcoord 9, 3 ld de, StatusScreenExpText call PlaceString ld a, [wLoadedMonLevel] @@ -401,7 +399,7 @@ StatusScreen2: inc a ld [wLoadedMonLevel], a ; Increase temporarily if not 100 .Level100 - coord hl, 14, 6 + hlcoord 14, 6 ld [hl], "<to>" inc hl inc hl @@ -409,33 +407,33 @@ StatusScreen2: pop af ld [wLoadedMonLevel], a ld de, wLoadedMonExp - coord hl, 12, 4 + hlcoord 12, 4 lb bc, 3, 7 call PrintNumber ; exp call CalcExpToLevelUp ld de, wLoadedMonExp - coord hl, 7, 6 + hlcoord 7, 6 lb bc, 3, 7 call PrintNumber ; exp needed to level up - coord hl, 9, 0 + hlcoord 9, 0 call StatusScreen_ClearName - coord hl, 9, 1 + hlcoord 9, 1 call StatusScreen_ClearName ld a, [wMonHIndex] ld [wd11e], a call GetMonName - coord hl, 9, 1 + hlcoord 9, 1 call PlaceString ld a, $1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a call Delay3 call WaitForTextScrollButtonPress ; wait for button pop af - ld [hTilesetType], a + ldh [hTilesetType], a ld hl, wd72c res 1, [hl] ld a, $77 - ld [rNR50], a + ldh [rNR50], a call GBPalWhiteOut jp ClearScreen @@ -445,15 +443,15 @@ CalcExpToLevelUp: jr z, .atMaxLevel inc a ld d, a - callab CalcExperience + callfar CalcExperience ld hl, wLoadedMonExp + 2 - ld a, [hExperience + 2] + ldh a, [hExperience + 2] sub [hl] ld [hld], a - ld a, [hExperience + 1] + ldh a, [hExperience + 1] sbc [hl] ld [hld], a - ld a, [hExperience] + ldh a, [hExperience] sbc [hl] ld [hld], a ret diff --git a/engine/slots/game_corner_slots.asm b/engine/slots/game_corner_slots.asm index 84f3efdc..c233b0e6 100755 --- a/engine/slots/game_corner_slots.asm +++ b/engine/slots/game_corner_slots.asm @@ -6,7 +6,7 @@ StartSlotMachine: jr z, .printOutToLunch cp $ff jr z, .printSomeonesKeys - callba AbleToPlaySlotsCheck + farcall AbleToPlaySlotsCheck ld a, [wCanPlaySlots] and a ret z @@ -22,7 +22,7 @@ StartSlotMachine: ld a, 250 .next ld [wSlotMachineSevenAndBarModeChance], a - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] ld [wSlotMachineSavedROMBank], a call PromptUserToPlaySlots ret diff --git a/engine/slots/slot_machine.asm b/engine/slots/slot_machine.asm index 3802cdd5..9af17a81 100755 --- a/engine/slots/slot_machine.asm +++ b/engine/slots/slot_machine.asm @@ -25,7 +25,7 @@ PromptUserToPlaySlots: call RunPaletteCommand call GBPalNormal ld a, $e4 - ld [rOBP0], a + ldh [rOBP0], a ld hl, wd730 set 6, [hl] xor a @@ -79,11 +79,11 @@ MainSlotMachineLoop: ld [wCurrentMenuItem], a ld [wLastMenuItem], a ld [wMenuWatchMovingOutOfBounds], a - coord hl, 14, 11 + hlcoord 14, 11 ld b, 5 ld c, 4 call TextBoxBorder - coord hl, 16, 12 + hlcoord 16, 12 ld de, CoinMultiplierSlotMachineText call PlaceString call HandleMenuInput @@ -133,7 +133,7 @@ MainSlotMachineLoop: .skip2 ld hl, OneMoreGoSlotMachineText call PrintText - coord hl, 14, 12 + hlcoord 14, 12 lb bc, 13, 15 xor a ; YES_NO_MENU ld [wTwoOptionMenuID], a @@ -294,7 +294,7 @@ SlotMachine_StopWheel1Early: ; Stop early if the middle symbol is not a cherry. inc hl ld a, [hl] - cp SLOTSCHERRY >> 8 + cp HIGH(SLOTSCHERRY) jr nz, .stopWheel ret ; It looks like this was intended to make the wheel stop when a 7 symbol was @@ -303,7 +303,7 @@ SlotMachine_StopWheel1Early: ld c, $3 .loop ld a, [hli] - cp SLOTS7 >> 8 + cp HIGH(SLOTS7) jr c, .stopWheel ; condition never true dec c jr nz, .loop @@ -330,7 +330,7 @@ SlotMachine_StopWheel2Early: .sevenAndBarMode call SlotMachine_FindWheel1Wheel2Matches ld a, [de] - cp (SLOTSBAR >> 8) + 1 + cp HIGH(SLOTSBAR) + 1 ret nc .stopWheel xor a @@ -427,7 +427,7 @@ SlotMachine_CheckForMatches: jr nz, .acceptMatch ; if 7/bar matches aren't enabled and the match was a 7/bar symbol, roll wheel ld a, [hl] - cp (SLOTSBAR >> 8) + 1 + cp HIGH(SLOTSBAR) + 1 jr c, .rollWheel3DownByOneSymbol .acceptMatch ld a, [hl] @@ -454,9 +454,9 @@ SlotMachine_CheckForMatches: jp hl .flashScreenLoop - ld a, [rBGP] + ldh a, [rBGP] xor $40 - ld [rBGP], a + ldh [rBGP], a ld c, 5 call DelayFrames dec b @@ -472,7 +472,7 @@ SlotMachine_CheckForMatches: call SlotMachine_PayCoinsToPlayer call SlotMachine_PrintPayoutCoins ld a, $e4 - ld [rOBP0], a + ldh [rOBP0], a jp .done SymbolLinedUpSlotMachineText: @@ -615,7 +615,7 @@ YeahText: SlotMachine_PrintWinningSymbol: ; prints winning symbol and down arrow in text box - coord hl, 2, 14 + hlcoord 2, 14 ld a, [wSlotMachineWinningSymbol] add $25 ld [hli], a @@ -627,7 +627,7 @@ SlotMachine_PrintWinningSymbol: ld [hli], a inc a ld [hl], a - coord hl, 18, 16 + hlcoord 18, 16 ld [hl], "▼" ret @@ -642,13 +642,13 @@ SlotMachine_SubtractBetFromPlayerCoins: predef SubBCDPredef SlotMachine_PrintCreditCoins: - coord hl, 5, 1 + hlcoord 5, 1 ld de, wPlayerCoins ld c, $2 jp PrintBCDNumber SlotMachine_PrintPayoutCoins: - coord hl, 11, 1 + hlcoord 11, 1 ld de, wPayoutCoins lb bc, LEADING_ZEROES | 2, 4 ; 2 bytes, 4 digits jp PrintNumber @@ -695,14 +695,14 @@ SlotMachine_PayCoinsToPlayer: ld a, [wAnimCounter] dec a jr nz, .skip1 - ld a, [rOBP0] + ldh a, [rOBP0] xor $40 ; make the slot wheel symbols flash - ld [rOBP0], a + ldh [rOBP0], a ld a, 5 .skip1 ld [wAnimCounter], a ld a, [wSlotMachineWinningSymbol] - cp (SLOTSBAR >> 8) + 1 + cp HIGH(SLOTSBAR) + 1 ld c, 8 jr nc, .skip2 srl c ; c = 4 (make the the coins transfer faster if the symbol was 7 or bar) @@ -725,19 +725,19 @@ SlotMachine_LightBalls: jr z, SlotMachine_UpdateTwoCoinBallTiles SlotMachine_UpdateThreeCoinBallTiles: - coord hl, 3, 2 + hlcoord 3, 2 call SlotMachine_UpdateBallTiles - coord hl, 3, 10 + hlcoord 3, 10 call SlotMachine_UpdateBallTiles SlotMachine_UpdateTwoCoinBallTiles: - coord hl, 3, 4 + hlcoord 3, 4 call SlotMachine_UpdateBallTiles - coord hl, 3, 8 + hlcoord 3, 8 call SlotMachine_UpdateBallTiles SlotMachine_UpdateOneCoinBallTiles: - coord hl, 3, 6 + hlcoord 3, 6 SlotMachine_UpdateBallTiles: ld a, [wNewSlotMachineBallTile] @@ -825,7 +825,7 @@ SlotMachine_AnimWheel: SlotMachine_HandleInputWhileWheelsSpin: call DelayFrame call JoypadLowSensitivity - ld a, [hJoy5] + ldh a, [hJoy5] and A_BUTTON ret z ld hl, wStoppingWhichSlotMachineWheel @@ -850,21 +850,21 @@ LoadSlotMachineTiles: call DisableLCD ld hl, SlotMachineTiles2 ld de, vChars0 - ld bc, $1c0 + ld bc, $1c tiles ; should be SlotMachineTiles2End - SlotMachineTiles2, or $18 tiles ld a, BANK(SlotMachineTiles2) call FarCopyData2 ld hl, SlotMachineTiles1 ld de, vChars2 - ld bc, $250 + ld bc, SlotMachineTiles1End - SlotMachineTiles1 ld a, BANK(SlotMachineTiles1) call FarCopyData2 ld hl, SlotMachineTiles2 - ld de, vChars2 + $250 - ld bc, $1c0 + ld de, vChars2 tile $25 + ld bc, $1c tiles ; should be SlotMachineTiles2End - SlotMachineTiles2, or $18 tiles ld a, BANK(SlotMachineTiles2) call FarCopyData2 ld hl, SlotMachineMap - coord de, 0, 0 + decoord 0, 0 ld bc, SlotMachineMapEnd - SlotMachineMap call CopyData call EnableLCD @@ -890,3 +890,4 @@ ENDC IF DEF(_BLUE) INCBIN "gfx/slots/blue_slots_1.2bpp" ENDC +SlotMachineTiles1End: @@ -18,64 +18,16 @@ SECTION "Home", ROM0 INCLUDE "home/start.asm" INCLUDE "home/joypad.asm" -INCLUDE "data/maps/map_header_pointers.asm" -INCLUDE "home/overworld.asm" - -CheckForUserInterruption:: -; Return carry if Up+Select+B, Start or A are pressed in c frames. -; Used only in the intro and title screen. - call DelayFrame - - push bc - call JoypadLowSensitivity - pop bc - - ld a, [hJoyHeld] - cp D_UP + SELECT + B_BUTTON - jr z, .input - - ld a, [hJoy5] - and START | A_BUTTON - jr nz, .input - - dec c - jr nz, CheckForUserInterruption - - and a - ret - -.input - scf - ret -; function to load position data for destination warp when switching maps -; INPUT: -; a = ID of destination warp within destination map -LoadDestinationWarpPosition:: - ld b, a - ld a, [hLoadedROMBank] - push af - ld a, [wPredefParentBank] - ld [hLoadedROMBank], a - ld [MBC1RomBank], a - ld a, b - add a - add a - ld c, a - ld b, 0 - add hl, bc - ld bc, 4 - ld de, wCurrentTileBlockMapViewPointer - call CopyData - pop af - ld [hLoadedROMBank], a - ld [MBC1RomBank], a - ret +INCLUDE "data/maps/map_header_pointers.asm" +INCLUDE "home/overworld.asm" INCLUDE "home/pokemon.asm" INCLUDE "home/print_bcd.asm" INCLUDE "home/pics.asm" + INCLUDE "data/tilesets/collision_tile_ids.asm" + INCLUDE "home/copy2.asm" INCLUDE "home/text.asm" INCLUDE "home/vcopy.asm" @@ -85,1724 +37,51 @@ INCLUDE "home/fade.asm" INCLUDE "home/serial.asm" INCLUDE "home/timer.asm" INCLUDE "home/audio.asm" - -UpdateSprites:: - ld a, [wUpdateSpritesEnabled] - dec a - ret nz - ld a, [hLoadedROMBank] - push af - ld a, BANK(_UpdateSprites) - ld [hLoadedROMBank], a - ld [MBC1RomBank], a - call _UpdateSprites - pop af - ld [hLoadedROMBank], a - ld [MBC1RomBank], a - ret +INCLUDE "home/update_sprites.asm" INCLUDE "data/items/marts.asm" + INCLUDE "home/overworld_text.asm" INCLUDE "home/uncompress.asm" - -ResetPlayerSpriteData:: - ld hl, wSpriteStateData1 - call ResetPlayerSpriteData_ClearSpriteData - ld hl, wSpriteStateData2 - call ResetPlayerSpriteData_ClearSpriteData - ld a, $1 - ld [wSpritePlayerStateData1PictureID], a - ld [wSpritePlayerStateData2ImageBaseOffset], a - ld hl, wSpritePlayerStateData1YPixels - ld [hl], $3c ; set Y screen pos - inc hl - inc hl - ld [hl], $40 ; set X screen pos - ret - -; overwrites sprite data with zeroes -ResetPlayerSpriteData_ClearSpriteData:: - ld bc, $10 - xor a - jp FillMemory - -FadeOutAudio:: - ld a, [wAudioFadeOutControl] - and a ; currently fading out audio? - jr nz, .fadingOut - ld a, [wd72c] - bit 1, a - ret nz - ld a, $77 - ld [rNR50], a - ret -.fadingOut - ld a, [wAudioFadeOutCounter] - and a - jr z, .counterReachedZero - dec a - ld [wAudioFadeOutCounter], a - ret -.counterReachedZero - ld a, [wAudioFadeOutCounterReloadValue] - ld [wAudioFadeOutCounter], a - ld a, [rNR50] - and a ; has the volume reached 0? - jr z, .fadeOutComplete - ld b, a - and $f - dec a - ld c, a - ld a, b - and $f0 - swap a - dec a - swap a - or c - ld [rNR50], a - ret -.fadeOutComplete - ld a, [wAudioFadeOutControl] - ld b, a - xor a - ld [wAudioFadeOutControl], a - ld a, SFX_STOP_ALL_MUSIC - ld [wNewSoundID], a - call PlaySound - ld a, [wAudioSavedROMBank] - ld [wAudioROMBank], a - ld a, b - ld [wNewSoundID], a - jp PlaySound - +INCLUDE "home/reset_player_sprite.asm" +INCLUDE "home/fade_audio.asm" INCLUDE "home/text_script.asm" INCLUDE "home/start_menu.asm" - -; function to count how many bits are set in a string of bytes -; INPUT: -; hl = address of string of bytes -; b = length of string of bytes -; OUTPUT: -; [wNumSetBits] = number of set bits -CountSetBits:: - ld c, 0 -.loop - ld a, [hli] - ld e, a - ld d, 8 -.innerLoop ; count how many bits are set in the current byte - srl e - ld a, 0 - adc c - ld c, a - dec d - jr nz, .innerLoop - dec b - jr nz, .loop - ld a, c - ld [wNumSetBits], a - ret - -; subtracts the amount the player paid from their money -; OUTPUT: carry = 0(success) or 1(fail because there is not enough money) -SubtractAmountPaidFromMoney:: - jpba SubtractAmountPaidFromMoney_ - -; adds the amount the player sold to their money -AddAmountSoldToMoney:: - ld de, wPlayerMoney + 2 - ld hl, hMoney + 2 ; total price of items - ld c, 3 ; length of money in bytes - predef AddBCDPredef ; add total price to money - ld a, MONEY_BOX - ld [wTextBoxID], a - call DisplayTextBoxID ; redraw money text box - ld a, SFX_PURCHASE - call PlaySoundWaitForCurrent - jp WaitForSoundToFinish - -; function to remove an item (in varying quantities) from the player's bag or PC box -; INPUT: -; HL = address of inventory (either wNumBagItems or wNumBoxItems) -; [wWhichPokemon] = index (within the inventory) of the item to remove -; [wItemQuantity] = quantity to remove -RemoveItemFromInventory:: - ld a, [hLoadedROMBank] - push af - ld a, BANK(RemoveItemFromInventory_) - ld [hLoadedROMBank], a - ld [MBC1RomBank], a - call RemoveItemFromInventory_ - pop af - ld [hLoadedROMBank], a - ld [MBC1RomBank], a - ret - -; function to add an item (in varying quantities) to the player's bag or PC box -; INPUT: -; HL = address of inventory (either wNumBagItems or wNumBoxItems) -; [wcf91] = item ID -; [wItemQuantity] = item quantity -; sets carry flag if successful, unsets carry flag if unsuccessful -AddItemToInventory:: - push bc - ld a, [hLoadedROMBank] - push af - ld a, BANK(AddItemToInventory_) - ld [hLoadedROMBank], a - ld [MBC1RomBank], a - call AddItemToInventory_ - pop bc - ld a, b - ld [hLoadedROMBank], a - ld [MBC1RomBank], a - pop bc - ret - +INCLUDE "home/count_set_bits.asm" +INCLUDE "home/inventory.asm" INCLUDE "home/list_menu.asm" INCLUDE "home/names.asm" - -; reloads text box tile patterns, current map view, and tileset tile patterns -ReloadMapData:: - ld a, [hLoadedROMBank] - push af - ld a, [wCurMap] - call SwitchToMapRomBank - call DisableLCD - call LoadTextBoxTilePatterns - call LoadCurrentMapView - call LoadTilesetTilePatternData - call EnableLCD - pop af - ld [hLoadedROMBank], a - ld [MBC1RomBank], a - ret - -; reloads tileset tile patterns -ReloadTilesetTilePatterns:: - ld a, [hLoadedROMBank] - push af - ld a, [wCurMap] - call SwitchToMapRomBank - call DisableLCD - call LoadTilesetTilePatternData - call EnableLCD - pop af - ld [hLoadedROMBank], a - ld [MBC1RomBank], a - ret - -; shows the town map and lets the player choose a destination to fly to -ChooseFlyDestination:: - ld hl, wd72e - res 4, [hl] - jpba LoadTownMap_Fly - -; causes the text box to close without waiting for a button press after displaying text -DisableWaitingAfterTextDisplay:: - ld a, $01 - ld [wDoNotWaitForButtonPressAfterDisplayingText], a - ret - -; uses an item -; UseItem is used with dummy items to perform certain other functions as well -; INPUT: -; [wcf91] = item ID -; OUTPUT: -; [wActionResultOrTookBattleTurn] = success -; 00: unsuccessful -; 01: successful -; 02: not able to be used right now, no extra menu displayed (only certain items use this) -UseItem:: - jpba UseItem_ - -; confirms the item toss and then tosses the item -; INPUT: -; hl = address of inventory (either wNumBagItems or wNumBoxItems) -; [wcf91] = item ID -; [wWhichPokemon] = index of item within inventory -; [wItemQuantity] = quantity to toss -; OUTPUT: -; clears carry flag if the item is tossed, sets carry flag if not -TossItem:: - ld a, [hLoadedROMBank] - push af - ld a, BANK(TossItem_) - ld [hLoadedROMBank], a - ld [MBC1RomBank], a - call TossItem_ - pop de - ld a, d - ld [hLoadedROMBank], a - ld [MBC1RomBank], a - ret - -; checks if an item is a key item -; INPUT: -; [wcf91] = item ID -; OUTPUT: -; [wIsKeyItem] = result -; 00: item is not key item -; 01: item is key item -IsKeyItem:: - push hl - push de - push bc - callba IsKeyItem_ - pop bc - pop de - pop hl - ret - -; function to draw various text boxes -; INPUT: -; [wTextBoxID] = text box ID -; b, c = y, x cursor position (TWO_OPTION_MENU only) -DisplayTextBoxID:: - ld a, [hLoadedROMBank] - push af - ld a, BANK(DisplayTextBoxID_) - ld [hLoadedROMBank], a - ld [MBC1RomBank], a - call DisplayTextBoxID_ - pop bc - ld a, b - ld [hLoadedROMBank], a - ld [MBC1RomBank], a - ret - -; not zero if an NPC movement script is running, the player character is -; automatically stepping down from a door, or joypad states are being simulated -IsPlayerCharacterBeingControlledByGame:: - ld a, [wNPCMovementScriptPointerTableNum] - and a - ret nz - ld a, [wd736] - bit 1, a ; currently stepping down from door bit - ret nz - ld a, [wd730] - and $80 - ret - -RunNPCMovementScript:: - ld hl, wd736 - bit 0, [hl] - res 0, [hl] - jr nz, .playerStepOutFromDoor - ld a, [wNPCMovementScriptPointerTableNum] - and a - ret z - dec a - add a - ld d, 0 - ld e, a - ld hl, .NPCMovementScriptPointerTables - add hl, de - ld a, [hli] - ld h, [hl] - ld l, a - ld a, [hLoadedROMBank] - push af - ld a, [wNPCMovementScriptBank] - ld [hLoadedROMBank], a - ld [MBC1RomBank], a - ld a, [wNPCMovementScriptFunctionNum] - call CallFunctionInTable - pop af - ld [hLoadedROMBank], a - ld [MBC1RomBank], a - ret - -.NPCMovementScriptPointerTables - dw PalletMovementScriptPointerTable - dw PewterMuseumGuyMovementScriptPointerTable - dw PewterGymGuyMovementScriptPointerTable -.playerStepOutFromDoor - jpba PlayerStepOutFromDoor - -EndNPCMovementScript:: - jpba _EndNPCMovementScript - -EmptyFunc2:: - ret - +INCLUDE "home/reload_tiles.asm" +INCLUDE "home/item.asm" +INCLUDE "home/textbox.asm" +INCLUDE "home/npc_movement.asm" INCLUDE "home/trainers.asm" - -; checks if the player's coordinates match an arrow movement tile's coordinates -; and if so, decodes the RLE movement data -; b = player Y -; c = player X -DecodeArrowMovementRLE:: - ld a, [hli] - cp $ff - ret z ; no match in the list - cp b - jr nz, .nextArrowMovementTileEntry1 - ld a, [hli] - cp c - jr nz, .nextArrowMovementTileEntry2 - ld a, [hli] - ld d, [hl] - ld e, a - ld hl, wSimulatedJoypadStatesEnd - call DecodeRLEList - dec a - ld [wSimulatedJoypadStatesIndex], a - ret -.nextArrowMovementTileEntry1 - inc hl -.nextArrowMovementTileEntry2 - inc hl - inc hl - jr DecodeArrowMovementRLE - -TextScript_ItemStoragePC:: - call SaveScreenTilesToBuffer2 - ld b, BANK(PlayerPC) - ld hl, PlayerPC - jr bankswitchAndContinue - -TextScript_BillsPC:: - call SaveScreenTilesToBuffer2 - ld b, BANK(BillsPC_) - ld hl, BillsPC_ - jr bankswitchAndContinue - -TextScript_GameCornerPrizeMenu:: -; XXX find a better name for this function -; special_F7 - ld b, BANK(CeladonPrizeMenu) - ld hl, CeladonPrizeMenu -bankswitchAndContinue:: - call Bankswitch - jp HoldTextDisplayOpen ; continue to main text-engine function - -TextScript_PokemonCenterPC:: - ld b, BANK(ActivatePC) - ld hl, ActivatePC - jr bankswitchAndContinue - -StartSimulatingJoypadStates:: - xor a - ld [wOverrideSimulatedJoypadStatesMask], a - ld [wSpritePlayerStateData2MovementByte1], a - ld hl, wd730 - set 7, [hl] - ret - -IsItemInBag:: -; given an item_id in b -; set zero flag if item isn't in player's bag -; else reset zero flag -; related to Pokémon Tower and ghosts - predef GetQuantityOfItemInBag - ld a, b - and a - ret - -DisplayPokedex:: - ld [wd11e], a - jpba _DisplayPokedex - -SetSpriteFacingDirectionAndDelay:: - call SetSpriteFacingDirection - ld c, 6 - jp DelayFrames - -SetSpriteFacingDirection:: - ld a, $9 - ld [hSpriteDataOffset], a - call GetPointerWithinSpriteStateData1 - ld a, [hSpriteFacingDirection] - ld [hl], a - ret - -SetSpriteImageIndexAfterSettingFacingDirection:: - ld de, -7 - add hl, de - ld [hl], a - ret - -; tests if the player's coordinates are in a specified array -; INPUT: -; hl = address of array -; OUTPUT: -; [wCoordIndex] = if there is match, the matching array index -; sets carry if the coordinates are in the array, clears carry if not -ArePlayerCoordsInArray:: - ld a, [wYCoord] - ld b, a - ld a, [wXCoord] - ld c, a - ; fallthrough - -CheckCoords:: - xor a - ld [wCoordIndex], a -.loop - ld a, [hli] - cp $ff ; reached terminator? - jr z, .notInArray - push hl - ld hl, wCoordIndex - inc [hl] - pop hl -.compareYCoord - cp b - jr z, .compareXCoord - inc hl - jr .loop -.compareXCoord - ld a, [hli] - cp c - jr nz, .loop -.inArray - scf - ret -.notInArray - and a - ret - -; tests if a boulder's coordinates are in a specified array -; INPUT: -; hl = address of array -; [hSpriteIndex] = index of boulder sprite -; OUTPUT: -; [wCoordIndex] = if there is match, the matching array index -; sets carry if the coordinates are in the array, clears carry if not -CheckBoulderCoords:: - push hl - ld hl, wSpritePlayerStateData2MapY - ld a, [hSpriteIndex] - swap a - ld d, $0 - ld e, a - add hl, de - ld a, [hli] - sub $4 ; because sprite coordinates are offset by 4 - ld b, a - ld a, [hl] - sub $4 ; because sprite coordinates are offset by 4 - ld c, a - pop hl - jp CheckCoords - -GetPointerWithinSpriteStateData1:: - ld h, $c1 - jr _GetPointerWithinSpriteStateData - -GetPointerWithinSpriteStateData2:: - ld h, $c2 - -_GetPointerWithinSpriteStateData: - ld a, [hSpriteDataOffset] - ld b, a - ld a, [hSpriteIndex] - swap a - add b - ld l, a - ret - -; decodes a $ff-terminated RLEncoded list -; each entry is a pair of bytes <byte value> <repetitions> -; the final $ff will be replicated in the output list and a contains the number of bytes written -; de: input list -; hl: output list -DecodeRLEList:: - xor a - ld [wRLEByteCount], a ; count written bytes here -.listLoop - ld a, [de] - cp $ff - jr z, .endOfList - ld [hRLEByteValue], a ; store byte value to be written - inc de - ld a, [de] - ld b, $0 - ld c, a ; number of bytes to be written - ld a, [wRLEByteCount] - add c - ld [wRLEByteCount], a ; update total number of written bytes - ld a, [hRLEByteValue] - call FillMemory ; write a c-times to output - inc de - jr .listLoop -.endOfList - ld a, $ff - ld [hl], a ; write final $ff - ld a, [wRLEByteCount] - inc a ; include sentinel in counting - ret - -; sets movement byte 1 for sprite [hSpriteIndex] to $FE and byte 2 to [hSpriteMovementByte2] -SetSpriteMovementBytesToFE:: - push hl - call GetSpriteMovementByte1Pointer - ld [hl], $fe - call GetSpriteMovementByte2Pointer - ld a, [hSpriteMovementByte2] - ld [hl], a - pop hl - ret - -; sets both movement bytes for sprite [hSpriteIndex] to $FF -SetSpriteMovementBytesToFF:: - push hl - call GetSpriteMovementByte1Pointer - ld [hl], $FF - call GetSpriteMovementByte2Pointer - ld [hl], $FF ; prevent person from walking? - pop hl - ret - -; returns the sprite movement byte 1 pointer for sprite [hSpriteIndex] in hl -GetSpriteMovementByte1Pointer:: - ld h, $C2 - ld a, [hSpriteIndex] - swap a - add 6 - ld l, a - ret - -; returns the sprite movement byte 2 pointer for sprite [hSpriteIndex] in hl -GetSpriteMovementByte2Pointer:: - push de - ld hl, wMapSpriteData - ld a, [hSpriteIndex] - dec a - add a - ld d, 0 - ld e, a - add hl, de - pop de - ret - -GetTrainerInformation:: - call GetTrainerName - ld a, [wLinkState] - and a - jr nz, .linkBattle - ld a, BANK(TrainerPicAndMoneyPointers) - call BankswitchHome - ld a, [wTrainerClass] - dec a - ld hl, TrainerPicAndMoneyPointers - ld bc, $5 - call AddNTimes - ld de, wTrainerPicPointer - ld a, [hli] - ld [de], a - inc de - ld a, [hli] - ld [de], a - ld de, wTrainerBaseMoney - ld a, [hli] - ld [de], a - inc de - ld a, [hli] - ld [de], a - jp BankswitchBack -.linkBattle - ld hl, wTrainerPicPointer - ld de, RedPicFront - ld [hl], e - inc hl - ld [hl], d - ret - -GetTrainerName:: - jpba GetTrainerName_ - -HasEnoughMoney:: -; Check if the player has at least as much -; money as the 3-byte BCD value at hMoney. - ld de, wPlayerMoney - ld hl, hMoney - ld c, 3 - jp StringCmp - -HasEnoughCoins:: -; Check if the player has at least as many -; coins as the 2-byte BCD value at hCoins. - ld de, wPlayerCoins - ld hl, hCoins - ld c, 2 - jp StringCmp - +INCLUDE "home/map_objects.asm" +INCLUDE "home/trainers2.asm" +INCLUDE "home/money.asm" INCLUDE "home/bankswitch.asm" INCLUDE "home/yes_no.asm" - -; calculates the difference |a-b|, setting carry flag if a<b -CalcDifference:: - sub b - ret nc - cpl - add $1 - scf - ret - -MoveSprite:: -; move the sprite [hSpriteIndex] with the movement pointed to by de -; actually only copies the movement data to wNPCMovementDirections for later - call SetSpriteMovementBytesToFF -MoveSprite_:: - push hl - push bc - call GetSpriteMovementByte1Pointer - xor a - ld [hl], a - ld hl, wNPCMovementDirections - ld c, 0 - -.loop - ld a, [de] - ld [hli], a - inc de - inc c - cp $FF ; have we reached the end of the movement data? - jr nz, .loop - - ld a, c - ld [wNPCNumScriptedSteps], a ; number of steps taken - - pop bc - ld hl, wd730 - set 0, [hl] - pop hl - xor a - ld [wOverrideSimulatedJoypadStatesMask], a - ld [wSimulatedJoypadStatesEnd], a - dec a - ld [wJoyIgnore], a - ld [wWastedByteCD3A], a - ret - -; divides [hDividend2] by [hDivisor2] and stores the quotient in [hQuotient2] -DivideBytes:: - push hl - ld hl, hQuotient2 - xor a - ld [hld], a - ld a, [hld] - and a - jr z, .done - ld a, [hli] -.loop - sub [hl] - jr c, .done - inc hl - inc [hl] - dec hl - jr .loop -.done - pop hl - ret - -LoadFontTilePatterns:: - ld a, [rLCDC] - bit 7, a ; is the LCD enabled? - jr nz, .on -.off - ld hl, FontGraphics - ld de, vFont - ld bc, FontGraphicsEnd - FontGraphics - ld a, BANK(FontGraphics) - jp FarCopyDataDouble ; if LCD is off, transfer all at once -.on - ld de, FontGraphics - ld hl, vFont - lb bc, BANK(FontGraphics), (FontGraphicsEnd - FontGraphics) / $8 - jp CopyVideoDataDouble ; if LCD is on, transfer during V-blank - -LoadTextBoxTilePatterns:: - ld a, [rLCDC] - bit 7, a ; is the LCD enabled? - jr nz, .on -.off - ld hl, TextBoxGraphics - ld de, vChars2 + $600 - ld bc, TextBoxGraphicsEnd - TextBoxGraphics - ld a, BANK(TextBoxGraphics) - jp FarCopyData2 ; if LCD is off, transfer all at once -.on - ld de, TextBoxGraphics - ld hl, vChars2 + $600 - lb bc, BANK(TextBoxGraphics), (TextBoxGraphicsEnd - TextBoxGraphics) / $10 - jp CopyVideoData ; if LCD is on, transfer during V-blank - -LoadHpBarAndStatusTilePatterns:: - ld a, [rLCDC] - bit 7, a ; is the LCD enabled? - jr nz, .on -.off - ld hl, HpBarAndStatusGraphics - ld de, vChars2 + $620 - ld bc, HpBarAndStatusGraphicsEnd - HpBarAndStatusGraphics - ld a, BANK(HpBarAndStatusGraphics) - jp FarCopyData2 ; if LCD is off, transfer all at once -.on - ld de, HpBarAndStatusGraphics - ld hl, vChars2 + $620 - lb bc, BANK(HpBarAndStatusGraphics), (HpBarAndStatusGraphicsEnd - HpBarAndStatusGraphics) / $10 - jp CopyVideoData ; if LCD is on, transfer during V-blank - -FillMemory:: -; Fill bc bytes at hl with a. - push de - ld d, a -.loop - ld a, d - ld [hli], a - dec bc - ld a, b - or c - jr nz, .loop - pop de - ret - -UncompressSpriteFromDE:: -; Decompress pic at a:de. - ld hl, wSpriteInputPtr - ld [hl], e - inc hl - ld [hl], d - jp UncompressSpriteData - -SaveScreenTilesToBuffer2:: - coord hl, 0, 0 - ld de, wTileMapBackup2 - ld bc, SCREEN_WIDTH * SCREEN_HEIGHT - call CopyData - ret - -LoadScreenTilesFromBuffer2:: - call LoadScreenTilesFromBuffer2DisableBGTransfer - ld a, 1 - ld [hAutoBGTransferEnabled], a - ret - -; loads screen tiles stored in wTileMapBackup2 but leaves hAutoBGTransferEnabled disabled -LoadScreenTilesFromBuffer2DisableBGTransfer:: - xor a - ld [hAutoBGTransferEnabled], a - ld hl, wTileMapBackup2 - coord de, 0, 0 - ld bc, SCREEN_WIDTH * SCREEN_HEIGHT - call CopyData - ret - -SaveScreenTilesToBuffer1:: - coord hl, 0, 0 - ld de, wTileMapBackup - ld bc, SCREEN_WIDTH * SCREEN_HEIGHT - jp CopyData - -LoadScreenTilesFromBuffer1:: - xor a - ld [hAutoBGTransferEnabled], a - ld hl, wTileMapBackup - coord de, 0, 0 - ld bc, SCREEN_WIDTH * SCREEN_HEIGHT - call CopyData - ld a, 1 - ld [hAutoBGTransferEnabled], a - ret - -DelayFrames:: -; wait c frames - call DelayFrame - dec c - jr nz, DelayFrames - ret - -PlaySoundWaitForCurrent:: - push af - call WaitForSoundToFinish - pop af - jp PlaySound - -; Wait for sound to finish playing -WaitForSoundToFinish:: - ld a, [wLowHealthAlarm] - and $80 - ret nz - push hl -.waitLoop - ld hl, wChannelSoundIDs + Ch5 - xor a - or [hl] - inc hl - or [hl] - inc hl - inc hl - or [hl] - jr nz, .waitLoop - pop hl - ret - +INCLUDE "home/pathfinding.asm" +INCLUDE "home/load_font.asm" +INCLUDE "home/tilemap.asm" +INCLUDE "home/delay.asm" INCLUDE "home/names2.asm" - -GetItemPrice:: -; Stores item's price as BCD at hItemPrice (3 bytes) -; Input: [wcf91] = item id - ld a, [hLoadedROMBank] - push af - ld a, [wListMenuID] - cp MOVESLISTMENU - ld a, BANK(ItemPrices) - jr nz, .ok - ld a, $f ; hardcoded Bank -.ok - ld [hLoadedROMBank], a - ld [MBC1RomBank], a - ld hl, wItemPrices - ld a, [hli] - ld h, [hl] - ld l, a - ld a, [wcf91] ; a contains item id - cp HM01 - jr nc, .getTMPrice - ld bc, $3 -.loop - add hl, bc - dec a - jr nz, .loop - dec hl - ld a, [hld] - ld [hItemPrice + 2], a - ld a, [hld] - ld [hItemPrice + 1], a - ld a, [hl] - ld [hItemPrice], a - jr .done -.getTMPrice - ld a, BANK(GetMachinePrice) - ld [hLoadedROMBank], a - ld [MBC1RomBank], a - call GetMachinePrice -.done - ld de, hItemPrice - pop af - ld [hLoadedROMBank], a - ld [MBC1RomBank], a - ret - -; copies a string from [de] to [wcf4b] -CopyStringToCF4B:: - ld hl, wcf4b - ; fall through - -; copies a string from [de] to [hl] -CopyString:: - ld a, [de] - inc de - ld [hli], a - cp "@" - jr nz, CopyString - ret - -; this function is used when lower button sensitivity is wanted (e.g. menus) -; OUTPUT: [hJoy5] = pressed buttons in usual format -; there are two flags that control its functionality, [hJoy6] and [hJoy7] -; there are essentially three modes of operation -; 1. Get newly pressed buttons only -; ([hJoy7] == 0, [hJoy6] == any) -; Just copies [hJoyPressed] to [hJoy5]. -; 2. Get currently pressed buttons at low sample rate with delay -; ([hJoy7] == 1, [hJoy6] != 0) -; If the user holds down buttons for more than half a second, -; report buttons as being pressed up to 12 times per second thereafter. -; If the user holds down buttons for less than half a second, -; report only one button press. -; 3. Same as 2, but report no buttons as pressed if A or B is held down. -; ([hJoy7] == 1, [hJoy6] == 0) -JoypadLowSensitivity:: - call Joypad - ld a, [hJoy7] ; flag - and a ; get all currently pressed buttons or only newly pressed buttons? - ld a, [hJoyPressed] ; newly pressed buttons - jr z, .storeButtonState - ld a, [hJoyHeld] ; all currently pressed buttons -.storeButtonState - ld [hJoy5], a - ld a, [hJoyPressed] ; newly pressed buttons - and a ; have any buttons been newly pressed since last check? - jr z, .noNewlyPressedButtons -.newlyPressedButtons - ld a, 30 ; half a second delay - ld [hFrameCounter], a - ret -.noNewlyPressedButtons - ld a, [hFrameCounter] - and a ; is the delay over? - jr z, .delayOver -.delayNotOver - xor a - ld [hJoy5], a ; report no buttons as pressed - ret -.delayOver -; if [hJoy6] = 0 and A or B is pressed, report no buttons as pressed - ld a, [hJoyHeld] - and A_BUTTON | B_BUTTON - jr z, .setShortDelay - ld a, [hJoy6] ; flag - and a - jr nz, .setShortDelay - xor a - ld [hJoy5], a -.setShortDelay - ld a, 5 ; 1/12 of a second delay - ld [hFrameCounter], a - ret - -WaitForTextScrollButtonPress:: - ld a, [hDownArrowBlinkCount1] - push af - ld a, [hDownArrowBlinkCount2] - push af - xor a - ld [hDownArrowBlinkCount1], a - ld a, $6 - ld [hDownArrowBlinkCount2], a -.loop - push hl - ld a, [wTownMapSpriteBlinkingEnabled] - and a - jr z, .skipAnimation - call TownMapSpriteBlinkingAnimation -.skipAnimation - coord hl, 18, 16 - call HandleDownArrowBlinkTiming - pop hl - call JoypadLowSensitivity - predef CableClub_Run - ld a, [hJoy5] - and A_BUTTON | B_BUTTON - jr z, .loop - pop af - ld [hDownArrowBlinkCount2], a - pop af - ld [hDownArrowBlinkCount1], a - ret - -; (unless in link battle) waits for A or B being pressed and outputs the scrolling sound effect -ManualTextScroll:: - ld a, [wLinkState] - cp LINK_STATE_BATTLING - jr z, .inLinkBattle - call WaitForTextScrollButtonPress - ld a, SFX_PRESS_AB - jp PlaySound -.inLinkBattle - ld c, 65 - jp DelayFrames - -; function to do multiplication -; all values are big endian -; INPUT -; FF96-FF98 = multiplicand -; FF99 = multiplier -; OUTPUT -; FF95-FF98 = product -Multiply:: - push hl - push bc - callab _Multiply - pop bc - pop hl - ret - -; function to do division -; all values are big endian -; INPUT -; FF95-FF98 = dividend -; FF99 = divisor -; b = number of bytes in the dividend (starting from FF95) -; OUTPUT -; FF95-FF98 = quotient -; FF99 = remainder -Divide:: - push hl - push de - push bc - ld a, [hLoadedROMBank] - push af - ld a, BANK(_Divide) - ld [hLoadedROMBank], a - ld [MBC1RomBank], a - call _Divide - pop af - ld [hLoadedROMBank], a - ld [MBC1RomBank], a - pop bc - pop de - pop hl - ret - -; This function is used to wait a short period after printing a letter to the -; screen unless the player presses the A/B button or the delay is turned off -; through the [wd730] or [wLetterPrintingDelayFlags] flags. -PrintLetterDelay:: - ld a, [wd730] - bit 6, a - ret nz - ld a, [wLetterPrintingDelayFlags] - bit 1, a - ret z - push hl - push de - push bc - ld a, [wLetterPrintingDelayFlags] - bit 0, a - jr z, .waitOneFrame - ld a, [wOptions] - and $f - ld [hFrameCounter], a - jr .checkButtons -.waitOneFrame - ld a, 1 - ld [hFrameCounter], a -.checkButtons - call Joypad - ld a, [hJoyHeld] -.checkAButton - bit 0, a ; is the A button pressed? - jr z, .checkBButton - jr .endWait -.checkBButton - bit 1, a ; is the B button pressed? - jr z, .buttonsNotPressed -.endWait - call DelayFrame - jr .done -.buttonsNotPressed ; if neither A nor B is pressed - ld a, [hFrameCounter] - and a - jr nz, .checkButtons -.done - pop bc - pop de - pop hl - ret - -; Copies [hl, bc) to [de, de + bc - hl). -; In other words, the source data is from hl up to but not including bc, -; and the destination is de. -CopyDataUntil:: - ld a, [hli] - ld [de], a - inc de - ld a, h - cp b - jr nz, CopyDataUntil - ld a, l - cp c - jr nz, CopyDataUntil - ret - +INCLUDE "home/item_price.asm" +INCLUDE "home/copy_string.asm" +INCLUDE "home/joypad2.asm" +INCLUDE "home/math.asm" +INCLUDE "home/print_text.asm" INCLUDE "home/move_mon.asm" - -; skips a text entries, each of size NAME_LENGTH (like trainer name, OT name, rival name, ...) -; hl: base pointer, will be incremented by NAME_LENGTH * a -SkipFixedLengthTextEntries:: - and a - ret z - ld bc, NAME_LENGTH -.skipLoop - add hl, bc - dec a - jr nz, .skipLoop - ret - -AddNTimes:: -; add bc to hl a times - and a - ret z -.loop - add hl, bc - dec a - jr nz, .loop - ret - -; Compare strings, c bytes in length, at de and hl. -; Often used to compare big endian numbers in battle calculations. -StringCmp:: - ld a, [de] - cp [hl] - ret nz - inc de - inc hl - dec c - jr nz, StringCmp - ret - -; INPUT: -; a = oam block index (each block is 4 oam entries) -; b = Y coordinate of upper left corner of sprite -; c = X coordinate of upper left corner of sprite -; de = base address of 4 tile number and attribute pairs -WriteOAMBlock:: - ld h, wOAMBuffer / $100 - swap a ; multiply by 16 - ld l, a - call .writeOneEntry ; upper left - push bc - ld a, 8 - add c - ld c, a - call .writeOneEntry ; upper right - pop bc - ld a, 8 - add b - ld b, a - call .writeOneEntry ; lower left - ld a, 8 - add c - ld c, a - ; lower right -.writeOneEntry - ld [hl], b ; Y coordinate - inc hl - ld [hl], c ; X coordinate - inc hl - ld a, [de] ; tile number - inc de - ld [hli], a - ld a, [de] ; attribute - inc de - ld [hli], a - ret - -HandleMenuInput:: - xor a - ld [wPartyMenuAnimMonEnabled], a - -HandleMenuInput_:: - ld a, [hDownArrowBlinkCount1] - push af - ld a, [hDownArrowBlinkCount2] - push af ; save existing values on stack - xor a - ld [hDownArrowBlinkCount1], a ; blinking down arrow timing value 1 - ld a, 6 - ld [hDownArrowBlinkCount2], a ; blinking down arrow timing value 2 -.loop1 - xor a - ld [wAnimCounter], a ; counter for pokemon shaking animation - call PlaceMenuCursor - call Delay3 -.loop2 - push hl - ld a, [wPartyMenuAnimMonEnabled] - and a ; is it a pokemon selection menu? - jr z, .getJoypadState - callba AnimatePartyMon ; shake mini sprite of selected pokemon -.getJoypadState - pop hl - call JoypadLowSensitivity - ld a, [hJoy5] - and a ; was a key pressed? - jr nz, .keyPressed - push hl - coord hl, 18, 11 ; coordinates of blinking down arrow in some menus - call HandleDownArrowBlinkTiming ; blink down arrow (if any) - pop hl - ld a, [wMenuJoypadPollCount] - dec a - jr z, .giveUpWaiting - jr .loop2 -.giveUpWaiting -; if a key wasn't pressed within the specified number of checks - pop af - ld [hDownArrowBlinkCount2], a - pop af - ld [hDownArrowBlinkCount1], a ; restore previous values - xor a - ld [wMenuWrappingEnabled], a ; disable menu wrapping - ret -.keyPressed - xor a - ld [wCheckFor180DegreeTurn], a - ld a, [hJoy5] - ld b, a - bit 6, a ; pressed Up key? - jr z, .checkIfDownPressed -.upPressed - ld a, [wCurrentMenuItem] ; selected menu item - and a ; already at the top of the menu? - jr z, .alreadyAtTop -.notAtTop - dec a - ld [wCurrentMenuItem], a ; move selected menu item up one space - jr .checkOtherKeys -.alreadyAtTop - ld a, [wMenuWrappingEnabled] - and a ; is wrapping around enabled? - jr z, .noWrappingAround - ld a, [wMaxMenuItem] - ld [wCurrentMenuItem], a ; wrap to the bottom of the menu - jr .checkOtherKeys -.checkIfDownPressed - bit 7, a - jr z, .checkOtherKeys -.downPressed - ld a, [wCurrentMenuItem] - inc a - ld c, a - ld a, [wMaxMenuItem] - cp c - jr nc, .notAtBottom -.alreadyAtBottom - ld a, [wMenuWrappingEnabled] - and a ; is wrapping around enabled? - jr z, .noWrappingAround - ld c, $00 ; wrap from bottom to top -.notAtBottom - ld a, c - ld [wCurrentMenuItem], a -.checkOtherKeys - ld a, [wMenuWatchedKeys] - and b ; does the menu care about any of the pressed keys? - jp z, .loop1 -.checkIfAButtonOrBButtonPressed - ld a, [hJoy5] - and A_BUTTON | B_BUTTON - jr z, .skipPlayingSound -.AButtonOrBButtonPressed - push hl - ld hl, wFlags_0xcd60 - bit 5, [hl] - pop hl - jr nz, .skipPlayingSound - ld a, SFX_PRESS_AB - call PlaySound -.skipPlayingSound - pop af - ld [hDownArrowBlinkCount2], a - pop af - ld [hDownArrowBlinkCount1], a ; restore previous values - xor a - ld [wMenuWrappingEnabled], a ; disable menu wrapping - ld a, [hJoy5] - ret -.noWrappingAround - ld a, [wMenuWatchMovingOutOfBounds] - and a ; should we return if the user tried to go past the top or bottom? - jr z, .checkOtherKeys - jr .checkIfAButtonOrBButtonPressed - -PlaceMenuCursor:: - ld a, [wTopMenuItemY] - and a ; is the y coordinate 0? - jr z, .adjustForXCoord - coord hl, 0, 0 - ld bc, SCREEN_WIDTH -.topMenuItemLoop - add hl, bc - dec a - jr nz, .topMenuItemLoop -.adjustForXCoord - ld a, [wTopMenuItemX] - ld b, 0 - ld c, a - add hl, bc - push hl - ld a, [wLastMenuItem] - and a ; was the previous menu id 0? - jr z, .checkForArrow1 - push af - ld a, [hFlagsFFF6] - bit 1, a ; is the menu double spaced? - jr z, .doubleSpaced1 - ld bc, 20 - jr .getOldMenuItemScreenPosition -.doubleSpaced1 - ld bc, 40 -.getOldMenuItemScreenPosition - pop af -.oldMenuItemLoop - add hl, bc - dec a - jr nz, .oldMenuItemLoop -.checkForArrow1 - ld a, [hl] - cp "▶" ; was an arrow next to the previously selected menu item? - jr nz, .skipClearingArrow -.clearArrow - ld a, [wTileBehindCursor] - ld [hl], a -.skipClearingArrow - pop hl - ld a, [wCurrentMenuItem] - and a - jr z, .checkForArrow2 - push af - ld a, [hFlagsFFF6] - bit 1, a ; is the menu double spaced? - jr z, .doubleSpaced2 - ld bc, 20 - jr .getCurrentMenuItemScreenPosition -.doubleSpaced2 - ld bc, 40 -.getCurrentMenuItemScreenPosition - pop af -.currentMenuItemLoop - add hl, bc - dec a - jr nz, .currentMenuItemLoop -.checkForArrow2 - ld a, [hl] - cp "▶" ; has the right arrow already been placed? - jr z, .skipSavingTile ; if so, don't lose the saved tile - ld [wTileBehindCursor], a ; save tile before overwriting with right arrow -.skipSavingTile - ld a, "▶" ; place right arrow - ld [hl], a - ld a, l - ld [wMenuCursorLocation], a - ld a, h - ld [wMenuCursorLocation + 1], a - ld a, [wCurrentMenuItem] - ld [wLastMenuItem], a - ret - -; This is used to mark a menu cursor other than the one currently being -; manipulated. In the case of submenus, this is used to show the location of -; the menu cursor in the parent menu. In the case of swapping items in list, -; this is used to mark the item that was first chosen to be swapped. -PlaceUnfilledArrowMenuCursor:: - ld b, a - ld a, [wMenuCursorLocation] - ld l, a - ld a, [wMenuCursorLocation + 1] - ld h, a - ld [hl], $ec ; outline of right arrow - ld a, b - ret - -; Replaces the menu cursor with a blank space. -EraseMenuCursor:: - ld a, [wMenuCursorLocation] - ld l, a - ld a, [wMenuCursorLocation + 1] - ld h, a - ld [hl], " " - ret - -; This toggles a blinking down arrow at hl on and off after a delay has passed. -; This is often called even when no blinking is occurring. -; The reason is that most functions that call this initialize hDownArrowBlinkCount1 to 0. -; The effect is that if the tile at hl is initialized with a down arrow, -; this function will toggle that down arrow on and off, but if the tile isn't -; initialized with a down arrow, this function does nothing. -; That allows this to be called without worrying about if a down arrow should -; be blinking. -HandleDownArrowBlinkTiming:: - ld a, [hl] - ld b, a - ld a, "▼" - cp b - jr nz, .downArrowOff -.downArrowOn - ld a, [hDownArrowBlinkCount1] - dec a - ld [hDownArrowBlinkCount1], a - ret nz - ld a, [hDownArrowBlinkCount2] - dec a - ld [hDownArrowBlinkCount2], a - ret nz - ld a, " " - ld [hl], a - ld a, $ff - ld [hDownArrowBlinkCount1], a - ld a, $06 - ld [hDownArrowBlinkCount2], a - ret -.downArrowOff - ld a, [hDownArrowBlinkCount1] - and a - ret z - dec a - ld [hDownArrowBlinkCount1], a - ret nz - dec a - ld [hDownArrowBlinkCount1], a - ld a, [hDownArrowBlinkCount2] - dec a - ld [hDownArrowBlinkCount2], a - ret nz - ld a, $06 - ld [hDownArrowBlinkCount2], a - ld a, "▼" - ld [hl], a - ret - -; The following code either enables or disables the automatic drawing of -; text boxes by DisplayTextID. Both functions cause DisplayTextID to wait -; for a button press after displaying text (unless [wEnteringCableClub] is set). - -EnableAutoTextBoxDrawing:: - xor a - jr AutoTextBoxDrawingCommon - -DisableAutoTextBoxDrawing:: - ld a, $01 - -AutoTextBoxDrawingCommon:: - ld [wAutoTextBoxDrawingControl], a - xor a - ld [wDoNotWaitForButtonPressAfterDisplayingText], a ; make DisplayTextID wait for button press - ret - -PrintText:: -; Print text hl at (1, 14). - push hl - ld a, MESSAGE_BOX - ld [wTextBoxID], a - call DisplayTextBoxID - call UpdateSprites - call Delay3 - pop hl -PrintText_NoCreatingTextBox:: - coord bc, 1, 14 - jp TextCommandProcessor - +INCLUDE "home/array.asm" +INCLUDE "home/compare.asm" +INCLUDE "home/oam.asm" +INCLUDE "home/window.asm" INCLUDE "home/print_num.asm" - -CallFunctionInTable:: -; Call function a in jumptable hl. -; de is not preserved. - push hl - push de - push bc - add a - ld d, 0 - ld e, a - add hl, de - ld a, [hli] - ld h, [hl] - ld l, a - ld de, .returnAddress - push de - jp hl -.returnAddress - pop bc - pop de - pop hl - ret - -IsInArray:: -; Search an array at hl for the value in a. -; Entry size is de bytes. -; Return count b and carry if found. - ld b, 0 - -IsInRestOfArray:: - ld c, a -.loop - ld a, [hl] - cp -1 - jr z, .notfound - cp c - jr z, .found - inc b - add hl, de - jr .loop - -.notfound - and a - ret - -.found - scf - ret - -RestoreScreenTilesAndReloadTilePatterns:: - call ClearSprites - ld a, $1 - ld [wUpdateSpritesEnabled], a - call ReloadMapSpriteTilePatterns - call LoadScreenTilesFromBuffer2 - call LoadTextBoxTilePatterns - call RunDefaultPaletteCommand - jr Delay3 - -GBPalWhiteOutWithDelay3:: - call GBPalWhiteOut - -Delay3:: -; The bg map is updated each frame in thirds. -; Wait three frames to let the bg map fully update. - ld c, 3 - jp DelayFrames - -GBPalNormal:: -; Reset BGP and OBP0. - ld a, %11100100 ; 3210 - ld [rBGP], a - ld a, %11010000 ; 3100 - ld [rOBP0], a - ret - -GBPalWhiteOut:: -; White out all palettes. - xor a - ld [rBGP], a - ld [rOBP0], a - ld [rOBP1], a - ret - -RunDefaultPaletteCommand:: - ld b, SET_PAL_DEFAULT -RunPaletteCommand:: - ld a, [wOnSGB] - and a - ret z - predef_jump _RunPaletteCommand - -GetHealthBarColor:: -; Return at hl the palette of -; an HP bar e pixels long. - ld a, e - cp 27 - ld d, 0 ; green - jr nc, .gotColor - cp 10 - inc d ; yellow - jr nc, .gotColor - inc d ; red -.gotColor - ld [hl], d - ret - -; Copy the current map's sprites' tile patterns to VRAM again after they have -; been overwritten by other tile patterns. -ReloadMapSpriteTilePatterns:: - ld hl, wFontLoaded - ld a, [hl] - push af - res 0, [hl] - push hl - xor a - ld [wSpriteSetID], a - call DisableLCD - callba InitMapSprites - call EnableLCD - pop hl - pop af - ld [hl], a - call LoadPlayerSpriteGraphics - call LoadFontTilePatterns - jp UpdateSprites - -GiveItem:: -; Give player quantity c of item b, -; and copy the item's name to wcf4b. -; Return carry on success. - ld a, b - ld [wd11e], a - ld [wcf91], a - ld a, c - ld [wItemQuantity], a - ld hl, wNumBagItems - call AddItemToInventory - ret nc - call GetItemName - call CopyStringToCF4B - scf - ret - -GivePokemon:: -; Give the player monster b at level c. - ld a, b - ld [wcf91], a - ld a, c - ld [wCurEnemyLVL], a - xor a ; PLAYER_PARTY_DATA - ld [wMonDataLocation], a - jpba _GivePokemon - -Random:: -; Return a random number in a. -; For battles, use BattleRandom. - push hl - push de - push bc - callba Random_ - ld a, [hRandomAdd] - pop bc - pop de - pop hl - ret - +INCLUDE "home/array2.asm" +INCLUDE "home/palettes.asm" +INCLUDE "home/reload_sprites.asm" +INCLUDE "home/give.asm" +INCLUDE "home/random.asm" INCLUDE "home/predef.asm" - -UpdateCinnabarGymGateTileBlocks:: - jpba UpdateCinnabarGymGateTileBlocks_ - -CheckForHiddenObjectOrBookshelfOrCardKeyDoor:: - ld a, [hLoadedROMBank] - push af - ld a, [hJoyHeld] - bit 0, a ; A button - jr z, .nothingFound -; A button is pressed - ld a, BANK(CheckForHiddenObject) - ld [MBC1RomBank], a - ld [hLoadedROMBank], a - call CheckForHiddenObject - ld a, [hDidntFindAnyHiddenObject] - and a - jr nz, .hiddenObjectNotFound - ld a, [wHiddenObjectFunctionRomBank] - ld [MBC1RomBank], a - ld [hLoadedROMBank], a - ld de, .returnAddress - push de - jp hl -.returnAddress - xor a - jr .done -.hiddenObjectNotFound - callba PrintBookshelfText - ld a, [hFFDB] - and a - jr z, .done -.nothingFound - ld a, $ff -.done - ld [hItemAlreadyFound], a - pop af - ld [MBC1RomBank], a - ld [hLoadedROMBank], a - ret - -PrintPredefTextID:: - ld [hSpriteIndexOrTextID], a - ld hl, TextPredefs - call SetMapTextPointer - ld hl, wTextPredefFlag - set 0, [hl] - call DisplayTextID - -RestoreMapTextPointer:: - ld hl, wMapTextPtr - ld a, [hSavedMapTextPtr] - ld [hli], a - ld a, [hSavedMapTextPtr + 1] - ld [hl], a - ret - -SetMapTextPointer:: - ld a, [wMapTextPtr] - ld [hSavedMapTextPtr], a - ld a, [wMapTextPtr + 1] - ld [hSavedMapTextPtr + 1], a - ld a, l - ld [wMapTextPtr], a - ld a, h - ld [wMapTextPtr + 1], a - ret - -INCLUDE "data/text_predef_pointers.asm" +INCLUDE "home/hidden_objects.asm" +INCLUDE "home/predef_text.asm" diff --git a/home/array.asm b/home/array.asm new file mode 100644 index 00000000..256c58e1 --- /dev/null +++ b/home/array.asm @@ -0,0 +1,21 @@ +; skips a text entries, each of size NAME_LENGTH (like trainer name, OT name, rival name, ...) +; hl: base pointer, will be incremented by NAME_LENGTH * a +SkipFixedLengthTextEntries:: + and a + ret z + ld bc, NAME_LENGTH +.skipLoop + add hl, bc + dec a + jr nz, .skipLoop + ret + +AddNTimes:: +; add bc to hl a times + and a + ret z +.loop + add hl, bc + dec a + jr nz, .loop + ret diff --git a/home/array2.asm b/home/array2.asm new file mode 100644 index 00000000..f4ed8389 --- /dev/null +++ b/home/array2.asm @@ -0,0 +1,47 @@ +CallFunctionInTable:: +; Call function a in jumptable hl. +; de is not preserved. + push hl + push de + push bc + add a + ld d, 0 + ld e, a + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + ld de, .returnAddress + push de + jp hl +.returnAddress + pop bc + pop de + pop hl + ret + +IsInArray:: +; Search an array at hl for the value in a. +; Entry size is de bytes. +; Return count b and carry if found. + ld b, 0 + +IsInRestOfArray:: + ld c, a +.loop + ld a, [hl] + cp -1 + jr z, .notfound + cp c + jr z, .found + inc b + add hl, de + jr .loop + +.notfound + and a + ret + +.found + scf + ret diff --git a/home/audio.asm b/home/audio.asm index 04f0276d..426506bf 100644 --- a/home/audio.asm +++ b/home/audio.asm @@ -170,10 +170,10 @@ PlaySound:: .noFadeOut xor a ld [wNewSoundID], a - ld a, [hLoadedROMBank] - ld [hSavedROMBank], a + ldh a, [hLoadedROMBank] + ldh [hSavedROMBank], a ld a, [wAudioROMBank] - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a cp BANK(Audio1_PlaySound) jr nz, .checkForAudio2 @@ -197,8 +197,8 @@ PlaySound:: call Audio3_PlaySound .next2 - ld a, [hSavedROMBank] - ld [hLoadedROMBank], a + ldh a, [hSavedROMBank] + ldh [hLoadedROMBank], a ld [MBC1RomBank], a jr .done diff --git a/home/bankswitch.asm b/home/bankswitch.asm index 086ca2f3..52c8a45c 100644 --- a/home/bankswitch.asm +++ b/home/bankswitch.asm @@ -2,27 +2,27 @@ BankswitchHome:: ; switches to bank # in a ; Only use this when in the home bank! ld [wBankswitchHomeTemp], a - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] ld [wBankswitchHomeSavedROMBank], a ld a, [wBankswitchHomeTemp] - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ret BankswitchBack:: ; returns from BankswitchHome ld a, [wBankswitchHomeSavedROMBank] - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ret Bankswitch:: ; self-contained bankswitch, use this when not in the home bank ; switches to the bank in b - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] push af ld a, b - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ld bc, .Return push bc @@ -30,6 +30,6 @@ Bankswitch:: .Return pop bc ld a, b - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ret diff --git a/home/compare.asm b/home/compare.asm new file mode 100644 index 00000000..e2da7857 --- /dev/null +++ b/home/compare.asm @@ -0,0 +1,11 @@ +; Compare strings, c bytes in length, at de and hl. +; Often used to compare big endian numbers in battle calculations. +StringCmp:: + ld a, [de] + cp [hl] + ret nz + inc de + inc hl + dec c + jr nz, StringCmp + ret diff --git a/home/copy.asm b/home/copy.asm index 910f508b..880d1fb7 100644 --- a/home/copy.asm +++ b/home/copy.asm @@ -1,14 +1,14 @@ FarCopyData:: ; Copy bc bytes from a:hl to de. ld [wBuffer], a - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] push af ld a, [wBuffer] - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a call CopyData pop af - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ret diff --git a/home/copy2.asm b/home/copy2.asm index 521223b6..1c9a56f3 100644 --- a/home/copy2.asm +++ b/home/copy2.asm @@ -1,25 +1,25 @@ FarCopyData2:: ; Identical to FarCopyData, but uses hROMBankTemp ; as temp space instead of wBuffer. - ld [hROMBankTemp], a - ld a, [hLoadedROMBank] + ldh [hROMBankTemp], a + ldh a, [hLoadedROMBank] push af - ld a, [hROMBankTemp] - ld [hLoadedROMBank], a + ldh a, [hROMBankTemp] + ldh [hLoadedROMBank], a ld [MBC1RomBank], a call CopyData pop af - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ret FarCopyData3:: ; Copy bc bytes from a:de to hl. - ld [hROMBankTemp], a - ld a, [hLoadedROMBank] + ldh [hROMBankTemp], a + ldh a, [hLoadedROMBank] push af - ld a, [hROMBankTemp] - ld [hLoadedROMBank], a + ldh a, [hROMBankTemp] + ldh [hLoadedROMBank], a ld [MBC1RomBank], a push hl push de @@ -31,18 +31,18 @@ FarCopyData3:: pop de pop hl pop af - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ret FarCopyDataDouble:: ; Expand bc bytes of 1bpp image data ; from a:hl to 2bpp data at de. - ld [hROMBankTemp], a - ld a, [hLoadedROMBank] + ldh [hROMBankTemp], a + ldh a, [hLoadedROMBank] push af - ld a, [hROMBankTemp] - ld [hLoadedROMBank], a + ldh a, [hROMBankTemp] + ldh [hLoadedROMBank], a ld [MBC1RomBank], a .loop ld a, [hli] @@ -55,7 +55,7 @@ FarCopyDataDouble:: or b jr nz, .loop pop af - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ret @@ -64,27 +64,27 @@ CopyVideoData:: ; tiles from b:de to hl, 8 tiles at a time. ; This takes c/8 frames. - ld a, [hAutoBGTransferEnabled] + ldh a, [hAutoBGTransferEnabled] push af xor a ; disable auto-transfer while copying - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a - ld a, [hLoadedROMBank] - ld [hROMBankTemp], a + ldh a, [hLoadedROMBank] + ldh [hROMBankTemp], a ld a, b - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ld a, e - ld [hVBlankCopySource], a + ldh [hVBlankCopySource], a ld a, d - ld [hVBlankCopySource + 1], a + ldh [hVBlankCopySource + 1], a ld a, l - ld [hVBlankCopyDest], a + ldh [hVBlankCopyDest], a ld a, h - ld [hVBlankCopyDest + 1], a + ldh [hVBlankCopyDest + 1], a .loop ld a, c @@ -92,18 +92,18 @@ CopyVideoData:: jr nc, .keepgoing .done - ld [hVBlankCopySize], a + ldh [hVBlankCopySize], a call DelayFrame - ld a, [hROMBankTemp] - ld [hLoadedROMBank], a + ldh a, [hROMBankTemp] + ldh [hLoadedROMBank], a ld [MBC1RomBank], a pop af - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ret .keepgoing ld a, 8 - ld [hVBlankCopySize], a + ldh [hVBlankCopySize], a call DelayFrame ld a, c sub 8 @@ -114,26 +114,26 @@ CopyVideoDataDouble:: ; Wait for the next VBlank, then copy c 1bpp ; tiles from b:de to hl, 8 tiles at a time. ; This takes c/8 frames. - ld a, [hAutoBGTransferEnabled] + ldh a, [hAutoBGTransferEnabled] push af xor a ; disable auto-transfer while copying - ld [hAutoBGTransferEnabled], a - ld a, [hLoadedROMBank] - ld [hROMBankTemp], a + ldh [hAutoBGTransferEnabled], a + ldh a, [hLoadedROMBank] + ldh [hROMBankTemp], a ld a, b - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ld a, e - ld [hVBlankCopyDoubleSource], a + ldh [hVBlankCopyDoubleSource], a ld a, d - ld [hVBlankCopyDoubleSource + 1], a + ldh [hVBlankCopyDoubleSource + 1], a ld a, l - ld [hVBlankCopyDoubleDest], a + ldh [hVBlankCopyDoubleDest], a ld a, h - ld [hVBlankCopyDoubleDest + 1], a + ldh [hVBlankCopyDoubleDest + 1], a .loop ld a, c @@ -141,18 +141,18 @@ CopyVideoDataDouble:: jr nc, .keepgoing .done - ld [hVBlankCopyDoubleSize], a + ldh [hVBlankCopyDoubleSize], a call DelayFrame - ld a, [hROMBankTemp] - ld [hLoadedROMBank], a + ldh a, [hROMBankTemp] + ldh [hLoadedROMBank], a ld [MBC1RomBank], a pop af - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ret .keepgoing ld a, 8 - ld [hVBlankCopyDoubleSize], a + ldh [hVBlankCopyDoubleSize], a call DelayFrame ld a, c sub 8 @@ -184,32 +184,32 @@ CopyScreenTileBufferToVRAM:: ld c, 6 ld hl, $600 * 0 - coord de, 0, 6 * 0 + decoord 0, 6 * 0 call .setup call DelayFrame ld hl, $600 * 1 - coord de, 0, 6 * 1 + decoord 0, 6 * 1 call .setup call DelayFrame ld hl, $600 * 2 - coord de, 0, 6 * 2 + decoord 0, 6 * 2 call .setup jp DelayFrame .setup ld a, d - ld [hVBlankCopyBGSource+1], a + ldh [hVBlankCopyBGSource+1], a call GetRowColAddressBgMap ld a, l - ld [hVBlankCopyBGDest], a + ldh [hVBlankCopyBGDest], a ld a, h - ld [hVBlankCopyBGDest+1], a + ldh [hVBlankCopyBGDest+1], a ld a, c - ld [hVBlankCopyBGNumRows], a + ldh [hVBlankCopyBGNumRows], a ld a, e - ld [hVBlankCopyBGSource], a + ldh [hVBlankCopyBGSource], a ret ClearScreen:: @@ -217,7 +217,7 @@ ClearScreen:: ; for the bg map to update. ld bc, 20 * 18 inc b - coord hl, 0, 0 + hlcoord 0, 0 ld a, " " .loop ld [hli], a diff --git a/home/copy_string.asm b/home/copy_string.asm new file mode 100644 index 00000000..7f86e501 --- /dev/null +++ b/home/copy_string.asm @@ -0,0 +1,13 @@ +; copies a string from [de] to [wcf4b] +CopyStringToCF4B:: + ld hl, wcf4b + ; fall through + +; copies a string from [de] to [hl] +CopyString:: + ld a, [de] + inc de + ld [hli], a + cp "@" + jr nz, CopyString + ret diff --git a/home/count_set_bits.asm b/home/count_set_bits.asm new file mode 100644 index 00000000..73f7fa9c --- /dev/null +++ b/home/count_set_bits.asm @@ -0,0 +1,24 @@ +; function to count how many bits are set in a string of bytes +; INPUT: +; hl = address of string of bytes +; b = length of string of bytes +; OUTPUT: +; [wNumSetBits] = number of set bits +CountSetBits:: + ld c, 0 +.loop + ld a, [hli] + ld e, a + ld d, 8 +.innerLoop ; count how many bits are set in the current byte + srl e + ld a, 0 + adc c + ld c, a + dec d + jr nz, .innerLoop + dec b + jr nz, .loop + ld a, c + ld [wNumSetBits], a + ret diff --git a/home/delay.asm b/home/delay.asm new file mode 100644 index 00000000..850b23e9 --- /dev/null +++ b/home/delay.asm @@ -0,0 +1,31 @@ +DelayFrames:: +; wait c frames + call DelayFrame + dec c + jr nz, DelayFrames + ret + +PlaySoundWaitForCurrent:: + push af + call WaitForSoundToFinish + pop af + jp PlaySound + +; Wait for sound to finish playing +WaitForSoundToFinish:: + ld a, [wLowHealthAlarm] + and $80 + ret nz + push hl +.waitLoop + ld hl, wChannelSoundIDs + Ch5 + xor a + or [hl] + inc hl + or [hl] + inc hl + inc hl + or [hl] + jr nz, .waitLoop + pop hl + ret diff --git a/home/fade.asm b/home/fade.asm index 9482fcb0..32175e16 100644 --- a/home/fade.asm +++ b/home/fade.asm @@ -11,11 +11,11 @@ LoadGBPal:: dec h .ok ld a, [hli] - ld [rBGP], a + ldh [rBGP], a ld a, [hli] - ld [rOBP0], a + ldh [rOBP0], a ld a, [hli] - ld [rOBP1], a + ldh [rOBP1], a ret GBFadeInFromBlack:: @@ -29,11 +29,11 @@ GBFadeOutToWhite:: GBFadeIncCommon: ld a, [hli] - ld [rBGP], a + ldh [rBGP], a ld a, [hli] - ld [rOBP0], a + ldh [rOBP0], a ld a, [hli] - ld [rOBP1], a + ldh [rOBP1], a ld c, 8 call DelayFrames dec b @@ -51,11 +51,11 @@ GBFadeInFromWhite:: GBFadeDecCommon: ld a, [hld] - ld [rOBP1], a + ldh [rOBP1], a ld a, [hld] - ld [rOBP0], a + ldh [rOBP0], a ld a, [hld] - ld [rBGP], a + ldh [rBGP], a ld c, 8 call DelayFrames dec b diff --git a/home/fade_audio.asm b/home/fade_audio.asm new file mode 100644 index 00000000..4ad2607d --- /dev/null +++ b/home/fade_audio.asm @@ -0,0 +1,48 @@ +FadeOutAudio:: + ld a, [wAudioFadeOutControl] + and a ; currently fading out audio? + jr nz, .fadingOut + ld a, [wd72c] + bit 1, a + ret nz + ld a, $77 + ldh [rNR50], a + ret +.fadingOut + ld a, [wAudioFadeOutCounter] + and a + jr z, .counterReachedZero + dec a + ld [wAudioFadeOutCounter], a + ret +.counterReachedZero + ld a, [wAudioFadeOutCounterReloadValue] + ld [wAudioFadeOutCounter], a + ldh a, [rNR50] + and a ; has the volume reached 0? + jr z, .fadeOutComplete + ld b, a + and $f + dec a + ld c, a + ld a, b + and $f0 + swap a + dec a + swap a + or c + ldh [rNR50], a + ret +.fadeOutComplete + ld a, [wAudioFadeOutControl] + ld b, a + xor a + ld [wAudioFadeOutControl], a + ld a, SFX_STOP_ALL_MUSIC + ld [wNewSoundID], a + call PlaySound + ld a, [wAudioSavedROMBank] + ld [wAudioROMBank], a + ld a, b + ld [wNewSoundID], a + jp PlaySound diff --git a/home/give.asm b/home/give.asm new file mode 100644 index 00000000..cbfd0310 --- /dev/null +++ b/home/give.asm @@ -0,0 +1,26 @@ +GiveItem:: +; Give player quantity c of item b, +; and copy the item's name to wcf4b. +; Return carry on success. + ld a, b + ld [wd11e], a + ld [wcf91], a + ld a, c + ld [wItemQuantity], a + ld hl, wNumBagItems + call AddItemToInventory + ret nc + call GetItemName + call CopyStringToCF4B + scf + ret + +GivePokemon:: +; Give the player monster b at level c. + ld a, b + ld [wcf91], a + ld a, c + ld [wCurEnemyLVL], a + xor a ; PLAYER_PARTY_DATA + ld [wMonDataLocation], a + farjp _GivePokemon diff --git a/home/hidden_objects.asm b/home/hidden_objects.asm new file mode 100644 index 00000000..eccf1c8f --- /dev/null +++ b/home/hidden_objects.asm @@ -0,0 +1,39 @@ +UpdateCinnabarGymGateTileBlocks:: + farjp UpdateCinnabarGymGateTileBlocks_ + +CheckForHiddenObjectOrBookshelfOrCardKeyDoor:: + ldh a, [hLoadedROMBank] + push af + ldh a, [hJoyHeld] + bit 0, a ; A button + jr z, .nothingFound +; A button is pressed + ld a, BANK(CheckForHiddenObject) + ld [MBC1RomBank], a + ldh [hLoadedROMBank], a + call CheckForHiddenObject + ldh a, [hDidntFindAnyHiddenObject] + and a + jr nz, .hiddenObjectNotFound + ld a, [wHiddenObjectFunctionRomBank] + ld [MBC1RomBank], a + ldh [hLoadedROMBank], a + ld de, .returnAddress + push de + jp hl +.returnAddress + xor a + jr .done +.hiddenObjectNotFound + farcall PrintBookshelfText + ldh a, [hFFDB] + and a + jr z, .done +.nothingFound + ld a, $ff +.done + ldh [hItemAlreadyFound], a + pop af + ld [MBC1RomBank], a + ldh [hLoadedROMBank], a + ret diff --git a/home/init.asm b/home/init.asm index 83238bad..e3f5fdd4 100644 --- a/home/init.asm +++ b/home/init.asm @@ -21,22 +21,22 @@ rLCDC_DEFAULT EQU %11100011 di xor a - ld [rIF], a - ld [rIE], a - ld [rSCX], a - ld [rSCY], a - ld [rSB], a - ld [rSC], a - ld [rWX], a - ld [rWY], a - ld [rTMA], a - ld [rTAC], a - ld [rBGP], a - ld [rOBP0], a - ld [rOBP1], a + ldh [rIF], a + ldh [rIE], a + ldh [rSCX], a + ldh [rSCY], a + ldh [rSB], a + ldh [rSC], a + ldh [rWX], a + ldh [rWY], a + ldh [rTMA], a + ldh [rTAC], a + ldh [rBGP], a + ldh [rOBP0], a + ldh [rOBP1], a ld a, rLCDC_ENABLE_MASK - ld [rLCDC], a + ldh [rLCDC], a call DisableLCD ld sp, wStack @@ -60,37 +60,37 @@ rLCDC_DEFAULT EQU %11100011 call ClearSprites ld a, BANK(WriteDMACodeToHRAM) - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a call WriteDMACodeToHRAM xor a - ld [hTilesetType], a - ld [rSTAT], a - ld [hSCX], a - ld [hSCY], a - ld [rIF], a + ldh [hTilesetType], a + ldh [rSTAT], a + ldh [hSCX], a + ldh [hSCY], a + ldh [rIF], a ld a, 1 << VBLANK + 1 << TIMER + 1 << SERIAL - ld [rIE], a + ldh [rIE], a ld a, 144 ; move the window off-screen - ld [hWY], a - ld [rWY], a + ldh [hWY], a + ldh [rWY], a ld a, 7 - ld [rWX], a + ldh [rWX], a ld a, CONNECTION_NOT_ESTABLISHED - ld [hSerialConnectionStatus], a + ldh [hSerialConnectionStatus], a - ld h, vBGMap0 / $100 + ld h, HIGH(vBGMap0) call ClearBgMap - ld h, vBGMap1 / $100 + ld h, HIGH(vBGMap1) call ClearBgMap ld a, rLCDC_DEFAULT - ld [rLCDC], a + ldh [rLCDC], a ld a, 16 - ld [hSoftReset], a + ldh [hSoftReset], a call StopAllSounds ei @@ -101,9 +101,9 @@ rLCDC_DEFAULT EQU %11100011 ld [wAudioROMBank], a ld [wAudioSavedROMBank], a ld a, $9c - ld [hAutoBGTransferDest + 1], a + ldh [hAutoBGTransferDest + 1], a xor a - ld [hAutoBGTransferDest], a + ldh [hAutoBGTransferDest], a dec a ld [wUpdateSpritesEnabled], a @@ -114,7 +114,7 @@ rLCDC_DEFAULT EQU %11100011 call GBPalNormal call ClearSprites ld a, rLCDC_DEFAULT - ld [rLCDC], a + ldh [rLCDC], a jp SetDefaultNamesBeforeTitlescreen diff --git a/home/inventory.asm b/home/inventory.asm new file mode 100644 index 00000000..ebaa4047 --- /dev/null +++ b/home/inventory.asm @@ -0,0 +1,55 @@ +; subtracts the amount the player paid from their money +; OUTPUT: carry = 0(success) or 1(fail because there is not enough money) +SubtractAmountPaidFromMoney:: + farjp SubtractAmountPaidFromMoney_ + +; adds the amount the player sold to their money +AddAmountSoldToMoney:: + ld de, wPlayerMoney + 2 + ld hl, hMoney + 2 ; total price of items + ld c, 3 ; length of money in bytes + predef AddBCDPredef ; add total price to money + ld a, MONEY_BOX + ld [wTextBoxID], a + call DisplayTextBoxID ; redraw money text box + ld a, SFX_PURCHASE + call PlaySoundWaitForCurrent + jp WaitForSoundToFinish + +; function to remove an item (in varying quantities) from the player's bag or PC box +; INPUT: +; HL = address of inventory (either wNumBagItems or wNumBoxItems) +; [wWhichPokemon] = index (within the inventory) of the item to remove +; [wItemQuantity] = quantity to remove +RemoveItemFromInventory:: + ldh a, [hLoadedROMBank] + push af + ld a, BANK(RemoveItemFromInventory_) + ldh [hLoadedROMBank], a + ld [MBC1RomBank], a + call RemoveItemFromInventory_ + pop af + ldh [hLoadedROMBank], a + ld [MBC1RomBank], a + ret + +; function to add an item (in varying quantities) to the player's bag or PC box +; INPUT: +; HL = address of inventory (either wNumBagItems or wNumBoxItems) +; [wcf91] = item ID +; [wItemQuantity] = item quantity +; sets carry flag if successful, unsets carry flag if unsuccessful +AddItemToInventory:: + push bc + ldh a, [hLoadedROMBank] + push af + ld a, BANK(AddItemToInventory_) + ldh [hLoadedROMBank], a + ld [MBC1RomBank], a + call AddItemToInventory_ + pop bc + ld a, b + ldh [hLoadedROMBank], a + ld [MBC1RomBank], a + pop bc + ret diff --git a/home/item.asm b/home/item.asm new file mode 100644 index 00000000..f27d46f4 --- /dev/null +++ b/home/item.asm @@ -0,0 +1,49 @@ +; uses an item +; UseItem is used with dummy items to perform certain other functions as well +; INPUT: +; [wcf91] = item ID +; OUTPUT: +; [wActionResultOrTookBattleTurn] = success +; 00: unsuccessful +; 01: successful +; 02: not able to be used right now, no extra menu displayed (only certain items use this) +UseItem:: + farjp UseItem_ + +; confirms the item toss and then tosses the item +; INPUT: +; hl = address of inventory (either wNumBagItems or wNumBoxItems) +; [wcf91] = item ID +; [wWhichPokemon] = index of item within inventory +; [wItemQuantity] = quantity to toss +; OUTPUT: +; clears carry flag if the item is tossed, sets carry flag if not +TossItem:: + ldh a, [hLoadedROMBank] + push af + ld a, BANK(TossItem_) + ldh [hLoadedROMBank], a + ld [MBC1RomBank], a + call TossItem_ + pop de + ld a, d + ldh [hLoadedROMBank], a + ld [MBC1RomBank], a + ret + +; checks if an item is a key item +; INPUT: +; [wcf91] = item ID +; OUTPUT: +; [wIsKeyItem] = result +; 00: item is not key item +; 01: item is key item +IsKeyItem:: + push hl + push de + push bc + farcall IsKeyItem_ + pop bc + pop de + pop hl + ret diff --git a/home/item_price.asm b/home/item_price.asm new file mode 100644 index 00000000..98eb31b1 --- /dev/null +++ b/home/item_price.asm @@ -0,0 +1,44 @@ +GetItemPrice:: +; Stores item's price as BCD at hItemPrice (3 bytes) +; Input: [wcf91] = item id + ldh a, [hLoadedROMBank] + push af + ld a, [wListMenuID] + cp MOVESLISTMENU + ld a, BANK(ItemPrices) + jr nz, .ok + ld a, $f ; hardcoded Bank +.ok + ldh [hLoadedROMBank], a + ld [MBC1RomBank], a + ld hl, wItemPrices + ld a, [hli] + ld h, [hl] + ld l, a + ld a, [wcf91] ; a contains item id + cp HM01 + jr nc, .getTMPrice + ld bc, $3 +.loop + add hl, bc + dec a + jr nz, .loop + dec hl + ld a, [hld] + ldh [hItemPrice + 2], a + ld a, [hld] + ldh [hItemPrice + 1], a + ld a, [hl] + ldh [hItemPrice], a + jr .done +.getTMPrice + ld a, BANK(GetMachinePrice) + ldh [hLoadedROMBank], a + ld [MBC1RomBank], a + call GetMachinePrice +.done + ld de, hItemPrice + pop af + ldh [hLoadedROMBank], a + ld [MBC1RomBank], a + ret diff --git a/home/joypad.asm b/home/joypad.asm index 9948b6e7..51a77fcc 100644 --- a/home/joypad.asm +++ b/home/joypad.asm @@ -6,9 +6,9 @@ ReadJoypad:: ld a, 1 << 5 ; select direction keys ld c, 0 - ld [rJOYP], a + ldh [rJOYP], a REPT 6 - ld a, [rJOYP] + ldh a, [rJOYP] ENDR cpl and %1111 @@ -16,18 +16,18 @@ ReadJoypad:: ld b, a ld a, 1 << 4 ; select button keys - ld [rJOYP], a + ldh [rJOYP], a REPT 10 - ld a, [rJOYP] + ldh a, [rJOYP] ENDR cpl and %1111 or b - ld [hJoyInput], a + ldh [hJoyInput], a ld a, 1 << 4 + 1 << 5 ; deselect keys - ld [rJOYP], a + ldh [rJOYP], a ret Joypad:: diff --git a/home/joypad2.asm b/home/joypad2.asm new file mode 100644 index 00000000..139dd3f5 --- /dev/null +++ b/home/joypad2.asm @@ -0,0 +1,95 @@ +; this function is used when lower button sensitivity is wanted (e.g. menus) +; OUTPUT: [hJoy5] = pressed buttons in usual format +; there are two flags that control its functionality, [hJoy6] and [hJoy7] +; there are essentially three modes of operation +; 1. Get newly pressed buttons only +; ([hJoy7] == 0, [hJoy6] == any) +; Just copies [hJoyPressed] to [hJoy5]. +; 2. Get currently pressed buttons at low sample rate with delay +; ([hJoy7] == 1, [hJoy6] != 0) +; If the user holds down buttons for more than half a second, +; report buttons as being pressed up to 12 times per second thereafter. +; If the user holds down buttons for less than half a second, +; report only one button press. +; 3. Same as 2, but report no buttons as pressed if A or B is held down. +; ([hJoy7] == 1, [hJoy6] == 0) +JoypadLowSensitivity:: + call Joypad + ldh a, [hJoy7] ; flag + and a ; get all currently pressed buttons or only newly pressed buttons? + ldh a, [hJoyPressed] ; newly pressed buttons + jr z, .storeButtonState + ldh a, [hJoyHeld] ; all currently pressed buttons +.storeButtonState + ldh [hJoy5], a + ldh a, [hJoyPressed] ; newly pressed buttons + and a ; have any buttons been newly pressed since last check? + jr z, .noNewlyPressedButtons +.newlyPressedButtons + ld a, 30 ; half a second delay + ldh [hFrameCounter], a + ret +.noNewlyPressedButtons + ldh a, [hFrameCounter] + and a ; is the delay over? + jr z, .delayOver +.delayNotOver + xor a + ldh [hJoy5], a ; report no buttons as pressed + ret +.delayOver +; if [hJoy6] = 0 and A or B is pressed, report no buttons as pressed + ldh a, [hJoyHeld] + and A_BUTTON | B_BUTTON + jr z, .setShortDelay + ldh a, [hJoy6] ; flag + and a + jr nz, .setShortDelay + xor a + ldh [hJoy5], a +.setShortDelay + ld a, 5 ; 1/12 of a second delay + ldh [hFrameCounter], a + ret + +WaitForTextScrollButtonPress:: + ldh a, [hDownArrowBlinkCount1] + push af + ldh a, [hDownArrowBlinkCount2] + push af + xor a + ldh [hDownArrowBlinkCount1], a + ld a, $6 + ldh [hDownArrowBlinkCount2], a +.loop + push hl + ld a, [wTownMapSpriteBlinkingEnabled] + and a + jr z, .skipAnimation + call TownMapSpriteBlinkingAnimation +.skipAnimation + hlcoord 18, 16 + call HandleDownArrowBlinkTiming + pop hl + call JoypadLowSensitivity + predef CableClub_Run + ldh a, [hJoy5] + and A_BUTTON | B_BUTTON + jr z, .loop + pop af + ldh [hDownArrowBlinkCount2], a + pop af + ldh [hDownArrowBlinkCount1], a + ret + +; (unless in link battle) waits for A or B being pressed and outputs the scrolling sound effect +ManualTextScroll:: + ld a, [wLinkState] + cp LINK_STATE_BATTLING + jr z, .inLinkBattle + call WaitForTextScrollButtonPress + ld a, SFX_PRESS_AB + jp PlaySound +.inLinkBattle + ld c, 65 + jp DelayFrames diff --git a/home/lcd.asm b/home/lcd.asm index e88a42b3..72fc70ed 100644 --- a/home/lcd.asm +++ b/home/lcd.asm @@ -1,25 +1,25 @@ DisableLCD:: xor a - ld [rIF], a - ld a, [rIE] + ldh [rIF], a + ldh a, [rIE] ld b, a res 0, a - ld [rIE], a + ldh [rIE], a .wait - ld a, [rLY] + ldh a, [rLY] cp LY_VBLANK jr nz, .wait - ld a, [rLCDC] + ldh a, [rLCDC] and $ff ^ rLCDC_ENABLE_MASK - ld [rLCDC], a + ldh [rLCDC], a ld a, b - ld [rIE], a + ldh [rIE], a ret EnableLCD:: - ld a, [rLCDC] + ldh a, [rLCDC] set rLCDC_ENABLE, a - ld [rLCDC], a + ldh [rLCDC], a ret diff --git a/home/list_menu.asm b/home/list_menu.asm index 4ce973b2..ec775331 100644 --- a/home/list_menu.asm +++ b/home/list_menu.asm @@ -3,9 +3,9 @@ ; [wListPointer] = address of the list (2 bytes) DisplayListMenuID:: xor a - ld [hAutoBGTransferEnabled], a ; disable auto-transfer + ldh [hAutoBGTransferEnabled], a ; disable auto-transfer ld a, 1 - ld [hJoy7], a ; joypad state update flag + ldh [hJoy7], a ; joypad state update flag ld a, [wBattleType] and a ; is it the Old Man battle? jr nz, .specialBattleType @@ -31,7 +31,7 @@ DisplayListMenuID:: call DisplayTextBoxID ; draw the menu text box call UpdateSprites ; disable sprites behind the text box ; the code up to .skipMovingSprites appears to be useless - coord hl, 4, 2 ; coordinates of upper left corner of menu text box + hlcoord 4, 2 ; coordinates of upper left corner of menu text box lb de, 9, 14 ; height and width of menu text box ld a, [wListMenuID] and a ; is it a PC pokemon list? @@ -57,22 +57,22 @@ DisplayListMenuID:: DisplayListMenuIDLoop:: xor a - ld [hAutoBGTransferEnabled], a ; disable transfer + ldh [hAutoBGTransferEnabled], a ; disable transfer call PrintListMenuEntries ld a, 1 - ld [hAutoBGTransferEnabled], a ; enable transfer + ldh [hAutoBGTransferEnabled], a ; enable transfer call Delay3 ld a, [wBattleType] and a ; is it the Old Man battle? jr z, .notOldManBattle .oldManBattle ld a, "▶" - Coorda 5, 4 ; place menu cursor in front of first menu entry + ldcoord_a 5, 4 ; place menu cursor in front of first menu entry ld c, 80 call DelayFrames xor a ld [wCurrentMenuItem], a - coord hl, 5, 4 + hlcoord 5, 4 ld a, l ld [wMenuCursorLocation], a ld a, h @@ -163,7 +163,7 @@ DisplayListMenuIDLoop:: ld a, [wCurrentMenuItem] ld [wChosenMenuItem], a xor a - ld [hJoy7], a ; joypad state update flag + ldh [hJoy7], a ; joypad state update flag ld hl, wd730 res 6, [hl] ; turn on letter printing delay jp BankswitchBack @@ -194,23 +194,23 @@ DisplayListMenuIDLoop:: DisplayChooseQuantityMenu:: ; text box dimensions/coordinates for just quantity - coord hl, 15, 9 + hlcoord 15, 9 ld b, 1 ; height ld c, 3 ; width ld a, [wListMenuID] cp PRICEDITEMLISTMENU jr nz, .drawTextBox ; text box dimensions/coordinates for quantity and price - coord hl, 7, 9 + hlcoord 7, 9 ld b, 1 ; height ld c, 11 ; width .drawTextBox call TextBoxBorder - coord hl, 16, 10 + hlcoord 16, 10 ld a, [wListMenuID] cp PRICEDITEMLISTMENU jr nz, .printInitialQuantity - coord hl, 8, 10 + hlcoord 8, 10 .printInitialQuantity ld de, InitialQuantityText call PlaceString @@ -219,7 +219,7 @@ DisplayChooseQuantityMenu:: jp .incrementQuantity .waitForKeyPressLoop call JoypadLowSensitivity - ld a, [hJoyPressed] ; newly pressed buttons + ldh a, [hJoyPressed] ; newly pressed buttons bit 0, a ; was the A button pressed? jp nz, .buttonAPressed bit 1, a ; was the B button pressed? @@ -250,7 +250,7 @@ DisplayChooseQuantityMenu:: ld a, [wMaxItemQuantity] ld [hl], a .handleNewQuantity - coord hl, 17, 10 + hlcoord 17, 10 ld a, [wListMenuID] cp PRICEDITEMLISTMENU jr nz, .printQuantity @@ -272,30 +272,30 @@ DisplayChooseQuantityMenu:: pop bc dec b jr nz, .addLoop - ld a, [hHalveItemPrices] + ldh a, [hHalveItemPrices] and a ; should the price be halved (for selling items)? jr z, .skipHalvingPrice xor a - ld [hDivideBCDDivisor], a - ld [hDivideBCDDivisor + 1], a + ldh [hDivideBCDDivisor], a + ldh [hDivideBCDDivisor + 1], a ld a, $02 - ld [hDivideBCDDivisor + 2], a + ldh [hDivideBCDDivisor + 2], a predef DivideBCDPredef3 ; halves the price ; store the halved price - ld a, [hDivideBCDQuotient] - ld [hMoney], a - ld a, [hDivideBCDQuotient + 1] - ld [hMoney + 1], a - ld a, [hDivideBCDQuotient + 2] - ld [hMoney + 2], a + ldh a, [hDivideBCDQuotient] + ldh [hMoney], a + ldh a, [hDivideBCDQuotient + 1] + ldh [hMoney + 1], a + ldh a, [hDivideBCDQuotient + 2] + ldh [hMoney + 2], a .skipHalvingPrice - coord hl, 12, 10 + hlcoord 12, 10 ld de, SpacesBetweenQuantityAndPriceText call PlaceString ld de, hMoney ; total price ld c, $a3 call PrintBCDNumber - coord hl, 9, 10 + hlcoord 9, 10 .printQuantity ld de, wItemQuantity ; current quantity lb bc, LEADING_ZEROES | 1, 2 ; 1 byte, 2 digits @@ -324,7 +324,7 @@ ExitListMenu:: ld [wMenuExitMethod], a ld [wMenuWatchMovingOutOfBounds], a xor a - ld [hJoy7], a + ldh [hJoy7], a ld hl, wd730 res 6, [hl] call BankswitchBack @@ -334,7 +334,7 @@ ExitListMenu:: ret PrintListMenuEntries:: - coord hl, 5, 3 + hlcoord 5, 3 ld b, 9 ld c, 14 call ClearScreenArea @@ -359,7 +359,7 @@ PrintListMenuEntries:: jr nc, .noCarry inc d .noCarry - coord hl, 6, 4 ; coordinates of first list entry name + hlcoord 6, 4 ; coordinates of first list entry name ld b, 4 ; print 4 names .loop ld a, b diff --git a/home/load_font.asm b/home/load_font.asm new file mode 100644 index 00000000..3b56d3a8 --- /dev/null +++ b/home/load_font.asm @@ -0,0 +1,47 @@ +LoadFontTilePatterns:: + ldh a, [rLCDC] + bit 7, a ; is the LCD enabled? + jr nz, .on +.off + ld hl, FontGraphics + ld de, vFont + ld bc, FontGraphicsEnd - FontGraphics + ld a, BANK(FontGraphics) + jp FarCopyDataDouble ; if LCD is off, transfer all at once +.on + ld de, FontGraphics + ld hl, vFont + lb bc, BANK(FontGraphics), (FontGraphicsEnd - FontGraphics) / $8 + jp CopyVideoDataDouble ; if LCD is on, transfer during V-blank + +LoadTextBoxTilePatterns:: + ldh a, [rLCDC] + bit 7, a ; is the LCD enabled? + jr nz, .on +.off + ld hl, TextBoxGraphics + ld de, vChars2 tile $60 + ld bc, TextBoxGraphicsEnd - TextBoxGraphics + ld a, BANK(TextBoxGraphics) + jp FarCopyData2 ; if LCD is off, transfer all at once +.on + ld de, TextBoxGraphics + ld hl, vChars2 tile $60 + lb bc, BANK(TextBoxGraphics), (TextBoxGraphicsEnd - TextBoxGraphics) / $10 + jp CopyVideoData ; if LCD is on, transfer during V-blank + +LoadHpBarAndStatusTilePatterns:: + ldh a, [rLCDC] + bit 7, a ; is the LCD enabled? + jr nz, .on +.off + ld hl, HpBarAndStatusGraphics + ld de, vChars2 tile $62 + ld bc, HpBarAndStatusGraphicsEnd - HpBarAndStatusGraphics + ld a, BANK(HpBarAndStatusGraphics) + jp FarCopyData2 ; if LCD is off, transfer all at once +.on + ld de, HpBarAndStatusGraphics + ld hl, vChars2 tile $62 + lb bc, BANK(HpBarAndStatusGraphics), (HpBarAndStatusGraphicsEnd - HpBarAndStatusGraphics) / $10 + jp CopyVideoData ; if LCD is on, transfer during V-blank diff --git a/home/map_objects.asm b/home/map_objects.asm new file mode 100644 index 00000000..02555e35 --- /dev/null +++ b/home/map_objects.asm @@ -0,0 +1,248 @@ +; checks if the player's coordinates match an arrow movement tile's coordinates +; and if so, decodes the RLE movement data +; b = player Y +; c = player X +DecodeArrowMovementRLE:: + ld a, [hli] + cp $ff + ret z ; no match in the list + cp b + jr nz, .nextArrowMovementTileEntry1 + ld a, [hli] + cp c + jr nz, .nextArrowMovementTileEntry2 + ld a, [hli] + ld d, [hl] + ld e, a + ld hl, wSimulatedJoypadStatesEnd + call DecodeRLEList + dec a + ld [wSimulatedJoypadStatesIndex], a + ret +.nextArrowMovementTileEntry1 + inc hl +.nextArrowMovementTileEntry2 + inc hl + inc hl + jr DecodeArrowMovementRLE + +TextScript_ItemStoragePC:: + call SaveScreenTilesToBuffer2 + ld b, BANK(PlayerPC) + ld hl, PlayerPC + jr bankswitchAndContinue + +TextScript_BillsPC:: + call SaveScreenTilesToBuffer2 + ld b, BANK(BillsPC_) + ld hl, BillsPC_ + jr bankswitchAndContinue + +TextScript_GameCornerPrizeMenu:: +; XXX find a better name for this function +; special_F7 + ld b, BANK(CeladonPrizeMenu) + ld hl, CeladonPrizeMenu +bankswitchAndContinue:: + call Bankswitch + jp HoldTextDisplayOpen ; continue to main text-engine function + +TextScript_PokemonCenterPC:: + ld b, BANK(ActivatePC) + ld hl, ActivatePC + jr bankswitchAndContinue + +StartSimulatingJoypadStates:: + xor a + ld [wOverrideSimulatedJoypadStatesMask], a + ld [wSpritePlayerStateData2MovementByte1], a + ld hl, wd730 + set 7, [hl] + ret + +IsItemInBag:: +; given an item_id in b +; set zero flag if item isn't in player's bag +; else reset zero flag +; related to Pokémon Tower and ghosts + predef GetQuantityOfItemInBag + ld a, b + and a + ret + +DisplayPokedex:: + ld [wd11e], a + farjp _DisplayPokedex + +SetSpriteFacingDirectionAndDelay:: + call SetSpriteFacingDirection + ld c, 6 + jp DelayFrames + +SetSpriteFacingDirection:: + ld a, $9 + ldh [hSpriteDataOffset], a + call GetPointerWithinSpriteStateData1 + ldh a, [hSpriteFacingDirection] + ld [hl], a + ret + +SetSpriteImageIndexAfterSettingFacingDirection:: + ld de, -7 + add hl, de + ld [hl], a + ret + +; tests if the player's coordinates are in a specified array +; INPUT: +; hl = address of array +; OUTPUT: +; [wCoordIndex] = if there is match, the matching array index +; sets carry if the coordinates are in the array, clears carry if not +ArePlayerCoordsInArray:: + ld a, [wYCoord] + ld b, a + ld a, [wXCoord] + ld c, a + ; fallthrough + +CheckCoords:: + xor a + ld [wCoordIndex], a +.loop + ld a, [hli] + cp $ff ; reached terminator? + jr z, .notInArray + push hl + ld hl, wCoordIndex + inc [hl] + pop hl +.compareYCoord + cp b + jr z, .compareXCoord + inc hl + jr .loop +.compareXCoord + ld a, [hli] + cp c + jr nz, .loop +.inArray + scf + ret +.notInArray + and a + ret + +; tests if a boulder's coordinates are in a specified array +; INPUT: +; hl = address of array +; [hSpriteIndex] = index of boulder sprite +; OUTPUT: +; [wCoordIndex] = if there is match, the matching array index +; sets carry if the coordinates are in the array, clears carry if not +CheckBoulderCoords:: + push hl + ld hl, wSpritePlayerStateData2MapY + ldh a, [hSpriteIndex] + swap a + ld d, $0 + ld e, a + add hl, de + ld a, [hli] + sub $4 ; because sprite coordinates are offset by 4 + ld b, a + ld a, [hl] + sub $4 ; because sprite coordinates are offset by 4 + ld c, a + pop hl + jp CheckCoords + +GetPointerWithinSpriteStateData1:: + ld h, $c1 + jr _GetPointerWithinSpriteStateData + +GetPointerWithinSpriteStateData2:: + ld h, $c2 + +_GetPointerWithinSpriteStateData: + ldh a, [hSpriteDataOffset] + ld b, a + ldh a, [hSpriteIndex] + swap a + add b + ld l, a + ret + +; decodes a $ff-terminated RLEncoded list +; each entry is a pair of bytes <byte value> <repetitions> +; the final $ff will be replicated in the output list and a contains the number of bytes written +; de: input list +; hl: output list +DecodeRLEList:: + xor a + ld [wRLEByteCount], a ; count written bytes here +.listLoop + ld a, [de] + cp $ff + jr z, .endOfList + ldh [hRLEByteValue], a ; store byte value to be written + inc de + ld a, [de] + ld b, $0 + ld c, a ; number of bytes to be written + ld a, [wRLEByteCount] + add c + ld [wRLEByteCount], a ; update total number of written bytes + ldh a, [hRLEByteValue] + call FillMemory ; write a c-times to output + inc de + jr .listLoop +.endOfList + ld a, $ff + ld [hl], a ; write final $ff + ld a, [wRLEByteCount] + inc a ; include sentinel in counting + ret + +; sets movement byte 1 for sprite [hSpriteIndex] to $FE and byte 2 to [hSpriteMovementByte2] +SetSpriteMovementBytesToFE:: + push hl + call GetSpriteMovementByte1Pointer + ld [hl], $fe + call GetSpriteMovementByte2Pointer + ldh a, [hSpriteMovementByte2] + ld [hl], a + pop hl + ret + +; sets both movement bytes for sprite [hSpriteIndex] to $FF +SetSpriteMovementBytesToFF:: + push hl + call GetSpriteMovementByte1Pointer + ld [hl], $FF + call GetSpriteMovementByte2Pointer + ld [hl], $FF ; prevent person from walking? + pop hl + ret + +; returns the sprite movement byte 1 pointer for sprite [hSpriteIndex] in hl +GetSpriteMovementByte1Pointer:: + ld h, $C2 + ldh a, [hSpriteIndex] + swap a + add 6 + ld l, a + ret + +; returns the sprite movement byte 2 pointer for sprite [hSpriteIndex] in hl +GetSpriteMovementByte2Pointer:: + push de + ld hl, wMapSpriteData + ldh a, [hSpriteIndex] + dec a + add a + ld d, 0 + ld e, a + add hl, de + pop de + ret diff --git a/home/math.asm b/home/math.asm new file mode 100644 index 00000000..b081b540 --- /dev/null +++ b/home/math.asm @@ -0,0 +1,41 @@ +; function to do multiplication +; all values are big endian +; INPUT +; FF96-FF98 = multiplicand +; FF99 = multiplier +; OUTPUT +; FF95-FF98 = product +Multiply:: + push hl + push bc + callfar _Multiply + pop bc + pop hl + ret + +; function to do division +; all values are big endian +; INPUT +; FF95-FF98 = dividend +; FF99 = divisor +; b = number of bytes in the dividend (starting from FF95) +; OUTPUT +; FF95-FF98 = quotient +; FF99 = remainder +Divide:: + push hl + push de + push bc + ldh a, [hLoadedROMBank] + push af + ld a, BANK(_Divide) + ldh [hLoadedROMBank], a + ld [MBC1RomBank], a + call _Divide + pop af + ldh [hLoadedROMBank], a + ld [MBC1RomBank], a + pop bc + pop de + pop hl + ret diff --git a/home/money.asm b/home/money.asm new file mode 100644 index 00000000..a62835ea --- /dev/null +++ b/home/money.asm @@ -0,0 +1,15 @@ +HasEnoughMoney:: +; Check if the player has at least as much +; money as the 3-byte BCD value at hMoney. + ld de, wPlayerMoney + ld hl, hMoney + ld c, 3 + jp StringCmp + +HasEnoughCoins:: +; Check if the player has at least as many +; coins as the 2-byte BCD value at hCoins. + ld de, wPlayerCoins + ld hl, hCoins + ld c, 2 + jp StringCmp diff --git a/home/move_mon.asm b/home/move_mon.asm index e13ebf4e..3e69e6d0 100644 --- a/home/move_mon.asm +++ b/home/move_mon.asm @@ -1,15 +1,30 @@ +; Copies [hl, bc) to [de, de + bc - hl). +; In other words, the source data is from hl up to but not including bc, +; and the destination is de. +CopyDataUntil:: + ld a, [hli] + ld [de], a + inc de + ld a, h + cp b + jr nz, CopyDataUntil + ld a, l + cp c + jr nz, CopyDataUntil + ret + ; Function to remove a pokemon from the party or the current box. ; wWhichPokemon determines the pokemon. ; [wRemoveMonFromBox] == 0 specifies the party. ; [wRemoveMonFromBox] != 0 specifies the current box. RemovePokemon:: - jpab _RemovePokemon + jpfar _RemovePokemon AddPartyMon:: push hl push de push bc - callba _AddPartyMon + farcall _AddPartyMon pop bc pop de pop hl @@ -21,10 +36,10 @@ CalcStats:: .statsLoop inc c call CalcStat - ld a, [hMultiplicand+1] + ldh a, [hMultiplicand+1] ld [de], a inc de - ld a, [hMultiplicand+2] + ldh a, [hMultiplicand+2] ld [de], a inc de ld a, c @@ -57,22 +72,22 @@ CalcStat:: add hl, bc ; skip to corresponding stat exp value .statExpLoop ; calculates ceil(Sqrt(stat exp)) in b xor a - ld [hMultiplicand], a - ld [hMultiplicand+1], a + ldh [hMultiplicand], a + ldh [hMultiplicand+1], a inc b ; increment current stat exp bonus ld a, b cp $ff jr z, .statExpDone - ld [hMultiplicand+2], a - ld [hMultiplier], a + ldh [hMultiplicand+2], a + ldh [hMultiplier], a call Multiply ld a, [hld] ld d, a - ld a, [hProduct + 3] + ldh a, [hProduct + 3] sub d ld a, [hli] ld d, a - ld a, [hProduct + 2] + ldh a, [hProduct + 2] sbc d ; test if (current stat exp bonus)^2 < stat exp jr c, .statExpLoop .statExpDone @@ -152,22 +167,22 @@ CalcStat:: jr nc, .noCarry2 inc d ; de = (Base + IV) * 2 + ceil(Sqrt(stat exp)) / 4 .noCarry2 - ld [hMultiplicand+2], a + ldh [hMultiplicand+2], a ld a, d - ld [hMultiplicand+1], a + ldh [hMultiplicand+1], a xor a - ld [hMultiplicand], a + ldh [hMultiplicand], a ld a, [wCurEnemyLVL] - ld [hMultiplier], a + ldh [hMultiplier], a call Multiply ; ((Base + IV) * 2 + ceil(Sqrt(stat exp)) / 4) * Level - ld a, [hMultiplicand] - ld [hDividend], a - ld a, [hMultiplicand+1] - ld [hDividend+1], a - ld a, [hMultiplicand+2] - ld [hDividend+2], a + ldh a, [hMultiplicand] + ldh [hDividend], a + ldh a, [hMultiplicand+1] + ldh [hDividend+1], a + ldh a, [hMultiplicand+2] + ldh [hDividend+2], a ld a, $64 - ld [hDivisor], a + ldh [hDivisor], a ld a, $3 ld b, a call Divide ; (((Base + IV) * 2 + ceil(Sqrt(stat exp)) / 4) * Level) / 100 @@ -177,38 +192,38 @@ CalcStat:: jr nz, .notHPStat ld a, [wCurEnemyLVL] ld b, a - ld a, [hMultiplicand+2] + ldh a, [hMultiplicand+2] add b - ld [hMultiplicand+2], a + ldh [hMultiplicand+2], a jr nc, .noCarry3 - ld a, [hMultiplicand+1] + ldh a, [hMultiplicand+1] inc a - ld [hMultiplicand+1], a ; HP: (((Base + IV) * 2 + ceil(Sqrt(stat exp)) / 4) * Level) / 100 + Level + ldh [hMultiplicand+1], a ; HP: (((Base + IV) * 2 + ceil(Sqrt(stat exp)) / 4) * Level) / 100 + Level .noCarry3 ld a, 10 ; +10 for HP stat .notHPStat ld b, a - ld a, [hMultiplicand+2] + ldh a, [hMultiplicand+2] add b - ld [hMultiplicand+2], a + ldh [hMultiplicand+2], a jr nc, .noCarry4 - ld a, [hMultiplicand+1] + ldh a, [hMultiplicand+1] inc a ; non-HP: (((Base + IV) * 2 + ceil(Sqrt(stat exp)) / 4) * Level) / 100 + 5 - ld [hMultiplicand+1], a ; HP: (((Base + IV) * 2 + ceil(Sqrt(stat exp)) / 4) * Level) / 100 + Level + 10 + ldh [hMultiplicand+1], a ; HP: (((Base + IV) * 2 + ceil(Sqrt(stat exp)) / 4) * Level) / 100 + Level + 10 .noCarry4 - ld a, [hMultiplicand+1] ; check for overflow (>999) - cp 999 / $100 + 1 + ldh a, [hMultiplicand+1] ; check for overflow (>999) + cp HIGH(MAX_STAT_VALUE) + 1 jr nc, .overflow - cp 999 / $100 + cp HIGH(MAX_STAT_VALUE) jr c, .noOverflow - ld a, [hMultiplicand+2] - cp 999 % $100 + 1 + ldh a, [hMultiplicand+2] + cp LOW(MAX_STAT_VALUE) + 1 jr c, .noOverflow .overflow - ld a, 999 / $100 ; overflow: cap at 999 - ld [hMultiplicand+1], a - ld a, 999 % $100 - ld [hMultiplicand+2], a + ld a, HIGH(MAX_STAT_VALUE) ; overflow: cap at 999 + ldh [hMultiplicand+1], a + ld a, LOW(MAX_STAT_VALUE) + ldh [hMultiplicand+2], a .noOverflow pop bc pop de @@ -216,27 +231,27 @@ CalcStat:: ret AddEnemyMonToPlayerParty:: - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] push af ld a, BANK(_AddEnemyMonToPlayerParty) - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a call _AddEnemyMonToPlayerParty pop bc ld a, b - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ret MoveMon:: - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] push af ld a, BANK(_MoveMon) - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a call _MoveMon pop bc ld a, b - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ret diff --git a/home/names.asm b/home/names.asm index 489bd040..f7751fa0 100644 --- a/home/names.asm +++ b/home/names.asm @@ -1,9 +1,9 @@ GetMonName:: push hl - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] push af ld a, BANK(MonsterNames) - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ld a, [wd11e] dec a @@ -19,7 +19,7 @@ GetMonName:: ld [hl], "@" pop de pop af - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a pop hl ret diff --git a/home/names2.asm b/home/names2.asm index ecf6ae63..8f539c31 100644 --- a/home/names2.asm +++ b/home/names2.asm @@ -22,7 +22,7 @@ GetName:: cp HM01 jp nc, GetMachineName - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] push af push hl push bc @@ -40,7 +40,7 @@ GetName:: .otherEntries ;2-7 = OTHER ENTRIES ld a, [wPredefBank] - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ld a, [wNameListType] ;VariousNames' entryID dec a @@ -53,12 +53,12 @@ GetName:: ld hl, NamePointers add hl, de ld a, [hli] - ld [hSwapTemp + 1], a + ldh [hSwapTemp + 1], a ld a, [hl] - ld [hSwapTemp], a - ld a, [hSwapTemp] + ldh [hSwapTemp], a + ldh a, [hSwapTemp] ld h, a - ld a, [hSwapTemp + 1] + ldh a, [hSwapTemp + 1] ld l, a ld a, [wd0b5] ld b, a @@ -88,6 +88,6 @@ GetName:: pop bc pop hl pop af - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ret diff --git a/home/npc_movement.asm b/home/npc_movement.asm new file mode 100644 index 00000000..4914d3df --- /dev/null +++ b/home/npc_movement.asm @@ -0,0 +1,54 @@ +; not zero if an NPC movement script is running, the player character is +; automatically stepping down from a door, or joypad states are being simulated +IsPlayerCharacterBeingControlledByGame:: + ld a, [wNPCMovementScriptPointerTableNum] + and a + ret nz + ld a, [wd736] + bit 1, a ; currently stepping down from door bit + ret nz + ld a, [wd730] + and $80 + ret + +RunNPCMovementScript:: + ld hl, wd736 + bit 0, [hl] + res 0, [hl] + jr nz, .playerStepOutFromDoor + ld a, [wNPCMovementScriptPointerTableNum] + and a + ret z + dec a + add a + ld d, 0 + ld e, a + ld hl, .NPCMovementScriptPointerTables + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + ldh a, [hLoadedROMBank] + push af + ld a, [wNPCMovementScriptBank] + ldh [hLoadedROMBank], a + ld [MBC1RomBank], a + ld a, [wNPCMovementScriptFunctionNum] + call CallFunctionInTable + pop af + ldh [hLoadedROMBank], a + ld [MBC1RomBank], a + ret + +.NPCMovementScriptPointerTables + dw PalletMovementScriptPointerTable + dw PewterMuseumGuyMovementScriptPointerTable + dw PewterGymGuyMovementScriptPointerTable +.playerStepOutFromDoor + farjp PlayerStepOutFromDoor + +EndNPCMovementScript:: + farjp _EndNPCMovementScript + +EmptyFunc2:: + ret diff --git a/home/oam.asm b/home/oam.asm new file mode 100644 index 00000000..8a940d97 --- /dev/null +++ b/home/oam.asm @@ -0,0 +1,36 @@ +; INPUT: +; a = oam block index (each block is 4 oam entries) +; b = Y coordinate of upper left corner of sprite +; c = X coordinate of upper left corner of sprite +; de = base address of 4 tile number and attribute pairs +WriteOAMBlock:: + ld h, HIGH(wOAMBuffer) + swap a ; multiply by 16 + ld l, a + call .writeOneEntry ; upper left + push bc + ld a, 8 + add c + ld c, a + call .writeOneEntry ; upper right + pop bc + ld a, 8 + add b + ld b, a + call .writeOneEntry ; lower left + ld a, 8 + add c + ld c, a + ; lower right +.writeOneEntry + ld [hl], b ; Y coordinate + inc hl + ld [hl], c ; X coordinate + inc hl + ld a, [de] ; tile number + inc de + ld [hli], a + ld a, [de] ; attribute + inc de + ld [hli], a + ret diff --git a/home/overworld.asm b/home/overworld.asm index be4af6ee..0408bf32 100644 --- a/home/overworld.asm +++ b/home/overworld.asm @@ -1,14 +1,14 @@ HandleMidJump:: ; Handle the player jumping down ; a ledge in the overworld. - jpba _HandleMidJump + farjp _HandleMidJump EnterMap:: ; Load a new map. ld a, $ff ld [wJoyIgnore], a call LoadMapData - callba ClearVariablesOnEnterMap + farcall ClearVariablesOnEnterMap ld hl, wd72c bit 0, [hl] ; has the player already made 3 steps since the last battle? jr z, .skipGivingThreeStepsOfNoRandomBattles @@ -25,10 +25,10 @@ EnterMap:: and 1 << 4 | 1 << 3 ; fly warp or dungeon warp jr z, .didNotEnterUsingFlyWarpOrDungeonWarp res 3, [hl] - callba EnterMapAnim + farcall EnterMapAnim call UpdateSprites .didNotEnterUsingFlyWarpOrDungeonWarp - callba CheckForceBikeOrSurf ; handle currents in SF islands and forced bike riding in cycling road + farcall CheckForceBikeOrSurf ; handle currents in SF islands and forced bike riding in cycling road ld hl, wd72d res 5, [hl] call UpdateSprites @@ -50,7 +50,7 @@ OverworldLoopLessDelay:: and a jp nz, .moveAhead ; if the player sprite has not yet completed the walking animation call JoypadOverworld ; get joypad state (which is possibly simulated) - callba SafariZoneCheck + farcall SafariZoneCheck ld a, [wSafariZoneGameOver] and a jp nz, WarpFound2 @@ -67,16 +67,16 @@ OverworldLoopLessDelay:: ld a, [wd730] bit 7, a ; are we simulating button presses? jr z, .notSimulating - ld a, [hJoyHeld] + ldh a, [hJoyHeld] jr .checkIfStartIsPressed .notSimulating - ld a, [hJoyPressed] + ldh a, [hJoyPressed] .checkIfStartIsPressed bit 3, a ; start button jr z, .startButtonNotPressed ; if START is pressed xor a ; TEXT_START_MENU - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a jp .displayDialogue .startButtonNotPressed bit 0, a ; A button @@ -88,11 +88,11 @@ OverworldLoopLessDelay:: call IsPlayerCharacterBeingControlledByGame jr nz, .checkForOpponent call CheckForHiddenObjectOrBookshelfOrCardKeyDoor - ld a, [hItemAlreadyFound] + ldh a, [hItemAlreadyFound] and a jp z, OverworldLoop ; jump if a hidden object or bookshelf was found, but not if a card key door was found call IsSpriteOrSignInFrontOfPlayer - ld a, [hSpriteIndexOrTextID] + ldh a, [hSpriteIndexOrTextID] and a jp z, OverworldLoop .displayDialogue @@ -103,7 +103,7 @@ OverworldLoopLessDelay:: jr nz, .checkForOpponent bit 0, a jr nz, .checkForOpponent - aCoord 8, 9 + lda_coord 8, 9 ld [wTilePlayerStandingOn], a ; unused? call DisplayTextID ; display either the start menu or the NPC/sign text ld a, [wEnteringCableClub] @@ -145,7 +145,7 @@ OverworldLoopLessDelay:: jp OverworldLoop .checkIfDownButtonIsPressed - ld a, [hJoyHeld] ; current joypad state + ldh a, [hJoyHeld] ; current joypad state bit 7, a ; down button jr z, .checkIfUpButtonIsPressed ld a, 1 @@ -269,7 +269,7 @@ OverworldLoopLessDelay:: ld a, [wd736] bit 7, a jr z, .noSpinning - callba LoadSpinnerArrowTiles + farcall LoadSpinnerArrowTiles .noSpinning call UpdateSprites @@ -306,7 +306,7 @@ OverworldLoopLessDelay:: .doneStepCounting CheckEvent EVENT_IN_SAFARI_ZONE jr z, .notSafariZone - callba SafariZoneCheckSteps + farcall SafariZoneCheckSteps ld a, [wSafariZoneGameOver] and a jp nz, WarpFound2 @@ -332,7 +332,7 @@ OverworldLoopLessDelay:: set 5, [hl] set 6, [hl] xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a ld a, [wCurMap] cp CINNABAR_GYM jr nz, .notCinnabarGym @@ -343,7 +343,7 @@ OverworldLoopLessDelay:: ld a, [wCurMap] cp OAKS_LAB jp z, .noFaintCheck ; no blacking out if the player lost to the rival in Oak's lab - callab AnyPartyAlive + callfar AnyPartyAlive ld a, d and a jr z, .allPokemonFainted @@ -368,7 +368,7 @@ NewBattle:: ld a, [wd72e] bit 4, a jr nz, .noBattle - jpba InitBattle + farjp InitBattle .noBattle and a ret @@ -381,7 +381,7 @@ DoBikeSpeedup:: ld a, [wCurMap] cp ROUTE_17 ; Cycling Road jr nz, .goFaster - ld a, [hJoyHeld] + ldh a, [hJoyHeld] and D_UP | D_LEFT | D_RIGHT ret nz .goFaster @@ -412,7 +412,7 @@ CheckWarpsNoCollisionLoop:: push bc ld hl, wd736 set 2, [hl] ; standing on warp flag - callba IsPlayerStandingOnDoorTileOrWarpTile + farcall IsPlayerStandingOnDoorTileOrWarpTile pop bc pop hl jr c, WarpFound1 ; jump if standing on door or warp @@ -431,7 +431,7 @@ CheckWarpsNoCollisionLoop:: call Joypad pop bc pop de - ld a, [hJoyHeld] + ldh a, [hJoyHeld] and D_DOWN | D_UP | D_LEFT | D_RIGHT jr z, CheckWarpsNoCollisionRetry2 ; if directional buttons aren't being pressed, do not pass through the warp jr WarpFound1 @@ -455,7 +455,7 @@ CheckWarpsCollision:: ld a, [hli] ld [wDestinationWarpID], a ld a, [hl] - ld [hWarpDestinationMap], a + ldh [hWarpDestinationMap], a jr WarpFound2 .retry1 inc hl @@ -477,7 +477,7 @@ WarpFound1:: ld a, [hli] ld [wDestinationWarpID], a ld a, [hli] - ld [hWarpDestinationMap], a + ldh [hWarpDestinationMap], a WarpFound2:: ld a, [wNumberOfWarps] @@ -492,7 +492,7 @@ WarpFound2:: ld [wLastMap], a ld a, [wCurMapWidth] ld [wUnusedD366], a ; not read - ld a, [hWarpDestinationMap] + ldh a, [hWarpDestinationMap] ld [wCurMap], a cp ROCK_TUNNEL_1F jr nz, .notRockTunnel @@ -506,12 +506,12 @@ WarpFound2:: ; for maps that can have the 0xFF destination map, which means to return to the outside map ; not all these maps are necessarily indoors, though .indoorMaps - ld a, [hWarpDestinationMap] ; destination map + ldh a, [hWarpDestinationMap] ; destination map cp $ff jr z, .goBackOutside ; if not going back to the previous map ld [wCurMap], a - callba IsPlayerStandingOnWarpPadOrHole + farcall IsPlayerStandingOnWarpPadOrHole ld a, [wStandingOnWarpPadOrHole] dec a ; is the player on a warp pad? jr nz, .notWarpPad @@ -678,8 +678,8 @@ CheckMapConnections:: ld b, SET_PAL_OVERWORLD call RunPaletteCommand ; Since the sprite set shouldn't change, this will just update VRAM slots at -; $C2XE without loading any tile patterns. - callba InitMapSprites +; x#SPRITESTATEDATA2_IMAGEBASEOFFSET without loading any tile patterns. + farcall InitMapSprites call LoadTileBlockMap jp OverworldLoopLessDelay @@ -688,7 +688,7 @@ CheckMapConnections:: ; function to play a sound when changing maps PlayMapChangeSound:: - aCoord 8, 8 ; upper left tile of the 4x4 square the player's sprite is standing on + lda_coord 8, 8 ; upper left tile of the 4x4 square the player's sprite is standing on cp $0b ; door tile in tileset 0 jr nz, .didNotGoThroughDoor ld a, SFX_GO_INSIDE @@ -747,7 +747,7 @@ ExtraWarpCheck:: jp Bankswitch MapEntryAfterBattle:: - callba IsPlayerStandingOnWarp ; for enabling warp testing after collisions + farcall IsPlayerStandingOnWarp ; for enabling warp testing after collisions ld a, [wMapPalOffset] and a jp z, GBFadeInFromWhite @@ -763,7 +763,7 @@ HandleBlackOut:: ld hl, wd72e res 5, [hl] ld a, BANK(ResetStatusAndHalveMoneyOnBlackout) ; also BANK(SpecialWarpIn) and BANK(SpecialEnterMap) - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a call ResetStatusAndHalveMoneyOnBlackout call SpecialWarpIn @@ -794,13 +794,13 @@ HandleFlyWarpOrDungeonWarp:: res 5, [hl] ; forced to ride bike call LeaveMapAnim ld a, BANK(SpecialWarpIn) - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a call SpecialWarpIn jp SpecialEnterMap LeaveMapAnim:: - jpba _LeaveMapAnim + farjp _LeaveMapAnim LoadPlayerSpriteGraphics:: ; Load sprite graphics based on whether the player is standing, biking, or surfing. @@ -813,7 +813,7 @@ LoadPlayerSpriteGraphics:: dec a jr z, .ridingBike - ld a, [hTilesetType] + ldh a, [hTilesetType] and a jr nz, .determineGraphics jr .startWalking @@ -899,9 +899,9 @@ LoadTileBlockMap:: ; a 3-byte border at the edges of the map is kept so that there is space for map connections ld hl, wOverworldMap ld a, [wCurMapWidth] - ld [hMapWidth], a + ldh [hMapWidth], a add MAP_BORDER * 2 ; east and west - ld [hMapStride], a ; map width + border + ldh [hMapStride], a ; map width + border ld b, 0 ld c, a ; make space for north border (next 3 lines) @@ -918,7 +918,7 @@ LoadTileBlockMap:: ld b, a .rowLoop ; copy one row each iteration push hl - ld a, [hMapWidth] ; map width (without border) + ldh a, [hMapWidth] ; map width (without border) ld c, a .rowInnerLoop ld a, [de] @@ -928,7 +928,7 @@ LoadTileBlockMap:: jr nz, .rowInnerLoop ; add the map width plus the border to the base address of the current row to get the next row's address pop hl - ld a, [hMapStride] ; map width + border + ldh a, [hMapStride] ; map width + border add l ld l, a jr nc, .noCarry @@ -950,9 +950,9 @@ LoadTileBlockMap:: ld a, [wNorthConnectionStripDest + 1] ld d, a ld a, [wNorthConnectionStripWidth] - ld [hNorthSouthConnectionStripWidth], a + ldh [hNorthSouthConnectionStripWidth], a ld a, [wNorthConnectedMapWidth] - ld [hNorthSouthConnectedMapWidth], a + ldh [hNorthSouthConnectedMapWidth], a call LoadNorthSouthConnectionsTileMap .southConnection ld a, [wMapConn2Ptr] @@ -968,9 +968,9 @@ LoadTileBlockMap:: ld a, [wSouthConnectionStripDest + 1] ld d, a ld a, [wSouthConnectionStripWidth] - ld [hNorthSouthConnectionStripWidth], a + ldh [hNorthSouthConnectionStripWidth], a ld a, [wSouthConnectedMapWidth] - ld [hNorthSouthConnectedMapWidth], a + ldh [hNorthSouthConnectedMapWidth], a call LoadNorthSouthConnectionsTileMap .westConnection ld a, [wMapConn3Ptr] @@ -988,7 +988,7 @@ LoadTileBlockMap:: ld a, [wWestConnectionStripHeight] ld b, a ld a, [wWestConnectedMapWidth] - ld [hEastWestConnectedMapWidth], a + ldh [hEastWestConnectedMapWidth], a call LoadEastWestConnectionsTileMap .eastConnection ld a, [wMapConn4Ptr] @@ -1006,7 +1006,7 @@ LoadTileBlockMap:: ld a, [wEastConnectionStripHeight] ld b, a ld a, [wEastConnectedMapWidth] - ld [hEastWestConnectedMapWidth], a + ldh [hEastWestConnectedMapWidth], a call LoadEastWestConnectionsTileMap .done ret @@ -1016,7 +1016,7 @@ LoadNorthSouthConnectionsTileMap:: .loop push de push hl - ld a, [hNorthSouthConnectionStripWidth] + ldh a, [hNorthSouthConnectionStripWidth] ld b, a .innerLoop ld a, [hli] @@ -1026,7 +1026,7 @@ LoadNorthSouthConnectionsTileMap:: jr nz, .innerLoop pop hl pop de - ld a, [hNorthSouthConnectedMapWidth] + ldh a, [hNorthSouthConnectedMapWidth] add l ld l, a jr nc, .noCarry1 @@ -1055,7 +1055,7 @@ LoadEastWestConnectionsTileMap:: jr nz, .innerLoop pop de pop hl - ld a, [hEastWestConnectedMapWidth] + ldh a, [hEastWestConnectedMapWidth] add l ld l, a jr nc, .noCarry1 @@ -1077,7 +1077,7 @@ LoadEastWestConnectionsTileMap:: ; if not, [hSpriteIndexOrTextID] is set to 0 IsSpriteOrSignInFrontOfPlayer:: xor a - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a ld a, [wNumSigns] and a jr z, .extendRangeOverCounter @@ -1107,7 +1107,7 @@ IsSpriteOrSignInFrontOfPlayer:: dec c add hl, bc ld a, [hl] - ld [hSpriteIndexOrTextID], a ; store sign text ID + ldh [hSpriteIndexOrTextID], a ; store sign text ID pop bc pop hl ret @@ -1210,10 +1210,10 @@ IsSpriteInFrontOfPlayer2:: ld a, l and $f0 inc a - ld l, a ; hl = $c1x1 + ld l, a ; hl = x#SPRITESTATEDATA1_MOVEMENTSTATUS set 7, [hl] ; set flag to make the sprite face the player ld a, e - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a ret ; function to check if the player will jump down a ledge and check if the tile ahead is passable (when not surfing) @@ -1232,9 +1232,9 @@ CollisionCheckOnLand:: and d ; check if a sprite is in the direction the player is trying to go jr nz, .collision xor a - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call IsSpriteInFrontOfPlayer ; check for sprite collisions again? when does the above check fail to detect a sprite collision? - ld a, [hSpriteIndexOrTextID] + ldh a, [hSpriteIndexOrTextID] and a ; was there a sprite collision? jr nz, .collision ; if no sprite collision @@ -1286,7 +1286,7 @@ CheckForJumpingAndTilePairCollisions:: predef GetTileAndCoordsInFrontOfPlayer ; get the tile in front of the player push de push bc - callba HandleLedges ; check if the player is trying to jump a ledge + farcall HandleLedges ; check if the player is trying to jump a ledge pop bc pop de pop hl @@ -1297,7 +1297,7 @@ CheckForJumpingAndTilePairCollisions:: ; if not jumping CheckForTilePairCollisions2:: - aCoord 8, 9 ; tile the player is on + lda_coord 8, 9 ; tile the player is on ld [wTilePlayerStandingOn], a CheckForTilePairCollisions:: @@ -1372,10 +1372,10 @@ TilePairCollisionsWater:: ; this builds a tile map from the tile block map based on the current X/Y coordinates of the player's character LoadCurrentMapView:: - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] push af ld a, [wTilesetBank] ; tile data ROM bank - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ; switch to ROM bank that contains tile data ld a, [wCurrentTileBlockMapViewPointer] ; address of upper left corner of current map view ld e, a @@ -1438,7 +1438,7 @@ LoadCurrentMapView:: ld bc, $2 add hl, bc .copyToVisibleAreaBuffer - coord de, 0, 0 ; base address for the tiles that are directly transferred to VRAM during V-blank + decoord 0, 0 ; base address for the tiles that are directly transferred to VRAM during V-blank ld b, SCREEN_HEIGHT .rowLoop2 ld c, SCREEN_WIDTH @@ -1457,7 +1457,7 @@ LoadCurrentMapView:: dec b jr nz, .rowLoop2 pop af - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ; restore previous ROM bank ret @@ -1627,12 +1627,12 @@ AdvancePlayerSprite:: ld c, a sla b sla c - ld a, [hSCY] + ldh a, [hSCY] add b - ld [hSCY], a ; update background scroll Y - ld a, [hSCX] + ldh [hSCY], a ; update background scroll Y + ldh a, [hSCX] add c - ld [hSCX], a ; update background scroll X + ldh [hSCX], a ; update background scroll X ; shift all the sprites in the direction opposite of the player's motion ; so that the player appears to move relative to them ld hl, wSprite01StateData1YPixels @@ -1711,14 +1711,14 @@ MoveTileBlockMapPointerNorth:: ; the portion of the map that was newly exposed due to the player's movement ScheduleNorthRowRedraw:: - coord hl, 0, 0 + hlcoord 0, 0 call CopyToRedrawRowOrColumnSrcTiles ld a, [wMapViewVRAMPointer] - ld [hRedrawRowOrColumnDest], a + ldh [hRedrawRowOrColumnDest], a ld a, [wMapViewVRAMPointer + 1] - ld [hRedrawRowOrColumnDest + 1], a + ldh [hRedrawRowOrColumnDest + 1], a ld a, REDRAW_ROW - ld [hRedrawRowOrColumnMode], a + ldh [hRedrawRowOrColumnMode], a ret CopyToRedrawRowOrColumnSrcTiles:: @@ -1733,7 +1733,7 @@ CopyToRedrawRowOrColumnSrcTiles:: ret ScheduleSouthRowRedraw:: - coord hl, 0, 16 + hlcoord 0, 16 call CopyToRedrawRowOrColumnSrcTiles ld a, [wMapViewVRAMPointer] ld l, a @@ -1744,15 +1744,15 @@ ScheduleSouthRowRedraw:: ld a, h and $03 or $98 - ld [hRedrawRowOrColumnDest + 1], a + ldh [hRedrawRowOrColumnDest + 1], a ld a, l - ld [hRedrawRowOrColumnDest], a + ldh [hRedrawRowOrColumnDest], a ld a, REDRAW_ROW - ld [hRedrawRowOrColumnMode], a + ldh [hRedrawRowOrColumnMode], a ret ScheduleEastColumnRedraw:: - coord hl, 18, 0 + hlcoord 18, 0 call ScheduleColumnRedrawHelper ld a, [wMapViewVRAMPointer] ld c, a @@ -1762,11 +1762,11 @@ ScheduleEastColumnRedraw:: add 18 and $1f or b - ld [hRedrawRowOrColumnDest], a + ldh [hRedrawRowOrColumnDest], a ld a, [wMapViewVRAMPointer + 1] - ld [hRedrawRowOrColumnDest + 1], a + ldh [hRedrawRowOrColumnDest + 1], a ld a, REDRAW_COL - ld [hRedrawRowOrColumnMode], a + ldh [hRedrawRowOrColumnMode], a ret ScheduleColumnRedrawHelper:: @@ -1790,14 +1790,14 @@ ScheduleColumnRedrawHelper:: ret ScheduleWestColumnRedraw:: - coord hl, 0, 0 + hlcoord 0, 0 call ScheduleColumnRedrawHelper ld a, [wMapViewVRAMPointer] - ld [hRedrawRowOrColumnDest], a + ldh [hRedrawRowOrColumnDest], a ld a, [wMapViewVRAMPointer + 1] - ld [hRedrawRowOrColumnDest + 1], a + ldh [hRedrawRowOrColumnDest + 1], a ld a, REDRAW_COL - ld [hRedrawRowOrColumnMode], a + ldh [hRedrawRowOrColumnMode], a ret ; function to write the tiles that make up a tile block to memory @@ -1855,17 +1855,17 @@ JoypadOverworld:: ld a, [wCurMap] cp ROUTE_17 ; Cycling Road jr nz, .notForcedDownwards - ld a, [hJoyHeld] + ldh a, [hJoyHeld] and D_DOWN | D_UP | D_LEFT | D_RIGHT | B_BUTTON | A_BUTTON jr nz, .notForcedDownwards ld a, D_DOWN - ld [hJoyHeld], a ; on the cycling road, if there isn't a trainer and the player isn't pressing buttons, simulate a down press + ldh [hJoyHeld], a ; on the cycling road, if there isn't a trainer and the player isn't pressing buttons, simulate a down press .notForcedDownwards ld a, [wd730] bit 7, a ret z ; if simulating button presses - ld a, [hJoyHeld] + ldh a, [hJoyHeld] ld b, a ld a, [wOverrideSimulatedJoypadStatesMask] ; bit mask for button presses that override simulated ones and b @@ -1882,11 +1882,11 @@ JoypadOverworld:: inc h .noCarry ld a, [hl] - ld [hJoyHeld], a ; store simulated button press in joypad state + ldh [hJoyHeld], a ; store simulated button press in joypad state and a ret nz - ld [hJoyPressed], a - ld [hJoyReleased], a + ldh [hJoyPressed], a + ldh [hJoyReleased], a ret ; if done simulating button presses @@ -1896,7 +1896,7 @@ JoypadOverworld:: ld [wSimulatedJoypadStatesIndex], a ld [wSimulatedJoypadStatesEnd], a ld [wJoyIgnore], a - ld [hJoyHeld], a + ldh [hJoyHeld], a ld hl, wd736 ld a, [hl] and $f8 @@ -1977,11 +1977,11 @@ RunMapScript:: push hl push de push bc - callba TryPushingBoulder + farcall TryPushingBoulder ld a, [wFlags_0xcd60] bit 1, a ; play boulder dust animation jr z, .afterBoulderEffect - callba DoBoulderDustAnimation + farcall DoBoulderDustAnimation .afterBoulderEffect pop bc pop de @@ -2032,7 +2032,7 @@ LoadPlayerSpriteGraphicsCommon:: ; function to load data from the map header LoadMapHeader:: - callba MarkTownVisitedAndLoadMissableObjects + farcall MarkTownVisitedAndLoadMissableObjects ld a, [wCurMapTileset] ld [wUnusedD119], a ld a, [wCurMap] @@ -2041,7 +2041,7 @@ LoadMapHeader:: ld b, a res 7, a ld [wCurMapTileset], a - ld [hPreviousTileset], a + ldh [hPreviousTileset], a bit 7, b ret nz ld hl, MapHeaderPointers @@ -2134,9 +2134,9 @@ LoadMapHeader:: ld c, a ld de, wSignTextIDs ld a, d - ld [hSignCoordPointer], a + ldh [hSignCoordPointer], a ld a, e - ld [hSignCoordPointer + 1], a + ldh [hSignCoordPointer + 1], a ld de, wSignCoords .signLoop ld a, [hli] @@ -2146,17 +2146,17 @@ LoadMapHeader:: ld [de], a inc de push de - ld a, [hSignCoordPointer] + ldh a, [hSignCoordPointer] ld d, a - ld a, [hSignCoordPointer + 1] + ldh a, [hSignCoordPointer + 1] ld e, a ld a, [hli] ld [de], a inc de ld a, d - ld [hSignCoordPointer], a + ldh [hSignCoordPointer], a ld a, e - ld [hSignCoordPointer + 1], a + ldh [hSignCoordPointer + 1], a pop de dec c jr nz, .signLoop @@ -2167,7 +2167,7 @@ LoadMapHeader:: ld a, [hli] ld [wNumSprites], a ; save the number of sprites push hl -; zero C110-C1FF and C210-C2FF +; zero out sprite state data for sprites 01-15 ld hl, wSprite01StateData1 ld de, wSprite01StateData2 xor a @@ -2178,7 +2178,7 @@ LoadMapHeader:: inc e dec b jr nz, .zeroSpriteDataLoop -; initialize all C100-C1FF sprite entries to disabled (other than player's) +; disable SPRITESTATEDATA1_IMAGEINDEX (set to $ff) for sprites 01-15 ld hl, wSprite01StateData1ImageIndex ld de, $10 ld c, $0f @@ -2196,38 +2196,38 @@ LoadMapHeader:: ld c, $00 .loadSpriteLoop ld a, [hli] - ld [de], a ; store picture ID at C1X0 + ld [de], a ; x#SPRITESTATEDATA1_PICTUREID inc d ld a, $04 add e ld e, a ld a, [hli] - ld [de], a ; store Y position at C2X4 + ld [de], a ; x#SPRITESTATEDATA2_MAPY inc e ld a, [hli] - ld [de], a ; store X position at C2X5 + ld [de], a ; x#SPRITESTATEDATA2_MAPX inc e ld a, [hli] - ld [de], a ; store movement byte 1 at C2X6 + ld [de], a ; x#SPRITESTATEDATA2_MOVEMENTBYTE1 ld a, [hli] - ld [hLoadSpriteTemp1], a ; save movement byte 2 + ldh [hLoadSpriteTemp1], a ; save movement byte 2 ld a, [hli] - ld [hLoadSpriteTemp2], a ; save text ID and flags byte + ldh [hLoadSpriteTemp2], a ; save text ID and flags byte push bc push hl ld b, $00 ld hl, wMapSpriteData add hl, bc - ld a, [hLoadSpriteTemp1] + ldh a, [hLoadSpriteTemp1] ld [hli], a ; store movement byte 2 in byte 0 of sprite entry - ld a, [hLoadSpriteTemp2] + ldh a, [hLoadSpriteTemp2] ld [hl], a ; this appears pointless, since the value is overwritten immediately after - ld a, [hLoadSpriteTemp2] - ld [hLoadSpriteTemp1], a + ldh a, [hLoadSpriteTemp2] + ldh [hLoadSpriteTemp1], a and $3f ld [hl], a ; store text ID in byte 1 of sprite entry pop hl - ld a, [hLoadSpriteTemp1] + ldh a, [hLoadSpriteTemp1] bit 6, a jr nz, .trainerSprite bit 7, a @@ -2235,25 +2235,25 @@ LoadMapHeader:: jr .regularSprite .trainerSprite ld a, [hli] - ld [hLoadSpriteTemp1], a ; save trainer class + ldh [hLoadSpriteTemp1], a ; save trainer class ld a, [hli] - ld [hLoadSpriteTemp2], a ; save trainer number (within class) + ldh [hLoadSpriteTemp2], a ; save trainer number (within class) push hl ld hl, wMapSpriteExtraData add hl, bc - ld a, [hLoadSpriteTemp1] + ldh a, [hLoadSpriteTemp1] ld [hli], a ; store trainer class in byte 0 of the entry - ld a, [hLoadSpriteTemp2] + ldh a, [hLoadSpriteTemp2] ld [hl], a ; store trainer number in byte 1 of the entry pop hl jr .nextSprite .itemBallSprite ld a, [hli] - ld [hLoadSpriteTemp1], a ; save item number + ldh [hLoadSpriteTemp1], a ; save item number push hl ld hl, wMapSpriteExtraData add hl, bc - ld a, [hLoadSpriteTemp1] + ldh a, [hLoadSpriteTemp1] ld [hli], a ; store item number in byte 0 of the entry xor a ld [hl], a ; zero byte 1, since it is not used @@ -2280,7 +2280,7 @@ LoadMapHeader:: jp nz, .loadSpriteLoop .finishUp predef LoadTilesetHeader - callab LoadWildData + callfar LoadWildData pop hl ; restore hl from before going to the warp/sign/sprite data (this value was saved for seemingly no purpose) ld a, [wCurMapHeight] ; map height in 4x4 tile blocks add a ; double it @@ -2291,10 +2291,10 @@ LoadMapHeader:: ld a, [wCurMap] ld c, a ld b, $00 - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] push af ld a, BANK(MapSongBanks) - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ld hl, MapSongBanks add hl, bc @@ -2304,7 +2304,7 @@ LoadMapHeader:: ld a, [hl] ld [wMapMusicROMBank], a ; music 2 pop af - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ret @@ -2322,27 +2322,27 @@ CopyMapConnectionHeader:: ; function to load map data LoadMapData:: - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] push af call DisableLCD ld a, $98 ld [wMapViewVRAMPointer + 1], a xor a ld [wMapViewVRAMPointer], a - ld [hSCY], a - ld [hSCX], a + ldh [hSCY], a + ldh [hSCX], a ld [wWalkCounter], a ld [wUnusedD119], a ld [wWalkBikeSurfStateCopy], a ld [wSpriteSetID], a call LoadTextBoxTilePatterns call LoadMapHeader - callba InitMapSprites ; load tile pattern data for sprites + farcall InitMapSprites ; load tile pattern data for sprites call LoadTileBlockMap call LoadTilesetTilePatternData call LoadCurrentMapView ; copy current map view to VRAM - coord hl, 0, 0 + hlcoord 0, 0 ld de, vBGMap0 ld b, 18 .vramCopyLoop @@ -2377,7 +2377,7 @@ LoadMapData:: call PlayDefaultMusicFadeOutCurrent .restoreRomBank pop af - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ret @@ -2393,10 +2393,10 @@ SwitchToMapRomBank:: ld hl, MapHeaderBanks add hl, bc ld a, [hl] - ld [hMapROMBank], a ; save map ROM bank + ldh [hMapROMBank], a ; save map ROM bank call BankswitchBack - ld a, [hMapROMBank] - ld [hLoadedROMBank], a + ldh a, [hMapROMBank] + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ; switch to map ROM bank pop bc pop hl @@ -2421,3 +2421,54 @@ ForceBikeOrSurf:: ld hl, LoadPlayerSpriteGraphics call Bankswitch jp PlayDefaultMusic ; update map/player state? + +CheckForUserInterruption:: +; Return carry if Up+Select+B, Start or A are pressed in c frames. +; Used only in the intro and title screen. + call DelayFrame + + push bc + call JoypadLowSensitivity + pop bc + + ldh a, [hJoyHeld] + cp D_UP + SELECT + B_BUTTON + jr z, .input + + ldh a, [hJoy5] + and START | A_BUTTON + jr nz, .input + + dec c + jr nz, CheckForUserInterruption + + and a + ret + +.input + scf + ret + +; function to load position data for destination warp when switching maps +; INPUT: +; a = ID of destination warp within destination map +LoadDestinationWarpPosition:: + ld b, a + ldh a, [hLoadedROMBank] + push af + ld a, [wPredefParentBank] + ldh [hLoadedROMBank], a + ld [MBC1RomBank], a + ld a, b + add a + add a + ld c, a + ld b, 0 + add hl, bc + ld bc, 4 + ld de, wCurrentTileBlockMapViewPointer + call CopyData + pop af + ldh [hLoadedROMBank], a + ld [MBC1RomBank], a + ret diff --git a/home/palettes.asm b/home/palettes.asm new file mode 100644 index 00000000..08dcdc85 --- /dev/null +++ b/home/palettes.asm @@ -0,0 +1,57 @@ +RestoreScreenTilesAndReloadTilePatterns:: + call ClearSprites + ld a, $1 + ld [wUpdateSpritesEnabled], a + call ReloadMapSpriteTilePatterns + call LoadScreenTilesFromBuffer2 + call LoadTextBoxTilePatterns + call RunDefaultPaletteCommand + jr Delay3 + +GBPalWhiteOutWithDelay3:: + call GBPalWhiteOut + +Delay3:: +; The bg map is updated each frame in thirds. +; Wait three frames to let the bg map fully update. + ld c, 3 + jp DelayFrames + +GBPalNormal:: +; Reset BGP and OBP0. + ld a, %11100100 ; 3210 + ldh [rBGP], a + ld a, %11010000 ; 3100 + ldh [rOBP0], a + ret + +GBPalWhiteOut:: +; White out all palettes. + xor a + ldh [rBGP], a + ldh [rOBP0], a + ldh [rOBP1], a + ret + +RunDefaultPaletteCommand:: + ld b, SET_PAL_DEFAULT +RunPaletteCommand:: + ld a, [wOnSGB] + and a + ret z + predef_jump _RunPaletteCommand + +GetHealthBarColor:: +; Return at hl the palette of +; an HP bar e pixels long. + ld a, e + cp 27 + ld d, 0 ; green + jr nc, .gotColor + cp 10 + inc d ; yellow + jr nc, .gotColor + inc d ; red +.gotColor + ld [hl], d + ret diff --git a/home/pathfinding.asm b/home/pathfinding.asm new file mode 100644 index 00000000..aca5a763 --- /dev/null +++ b/home/pathfinding.asm @@ -0,0 +1,65 @@ +; calculates the difference |a-b|, setting carry flag if a<b +CalcDifference:: + sub b + ret nc + cpl + add $1 + scf + ret + +MoveSprite:: +; move the sprite [hSpriteIndex] with the movement pointed to by de +; actually only copies the movement data to wNPCMovementDirections for later + call SetSpriteMovementBytesToFF +MoveSprite_:: + push hl + push bc + call GetSpriteMovementByte1Pointer + xor a + ld [hl], a + ld hl, wNPCMovementDirections + ld c, 0 + +.loop + ld a, [de] + ld [hli], a + inc de + inc c + cp $FF ; have we reached the end of the movement data? + jr nz, .loop + + ld a, c + ld [wNPCNumScriptedSteps], a ; number of steps taken + + pop bc + ld hl, wd730 + set 0, [hl] + pop hl + xor a + ld [wOverrideSimulatedJoypadStatesMask], a + ld [wSimulatedJoypadStatesEnd], a + dec a + ld [wJoyIgnore], a + ld [wWastedByteCD3A], a + ret + +; divides [hDividend2] by [hDivisor2] and stores the quotient in [hQuotient2] +DivideBytes:: + push hl + ld hl, hQuotient2 + xor a + ld [hld], a + ld a, [hld] + and a + jr z, .done + ld a, [hli] +.loop + sub [hl] + jr c, .done + inc hl + inc [hl] + dec hl + jr .loop +.done + pop hl + ret diff --git a/home/pics.asm b/home/pics.asm index c6d99cbb..ef668620 100644 --- a/home/pics.asm +++ b/home/pics.asm @@ -63,7 +63,7 @@ LoadMonFrontSprite:: LoadUncompressedSpriteData:: push de and $f - ld [hSpriteWidth], a ; each byte contains 8 pixels (in 1bpp), so tiles=bytes for width + ldh [hSpriteWidth], a ; each byte contains 8 pixels (in 1bpp), so tiles=bytes for width ld b, a ld a, $7 sub b ; 7-w @@ -74,7 +74,7 @@ LoadUncompressedSpriteData:: add a add a sub b ; 7*((8-w)/2) ; skip for horizontal center (in tiles) - ld [hSpriteOffset], a + ldh [hSpriteOffset], a ld a, c swap a and $f @@ -82,16 +82,16 @@ LoadUncompressedSpriteData:: add a add a add a ; 8*tiles is height in bytes - ld [hSpriteHeight], a + ldh [hSpriteHeight], a ld a, $7 sub b ; 7-h ; skip for vertical center (in tiles, relative to current column) ld b, a - ld a, [hSpriteOffset] + ldh a, [hSpriteOffset] add b ; 7*((8-w)/2) + 7-h ; combined overall offset (in tiles) add a add a add a ; 8*(7*((8-w)/2) + 7-h) ; combined overall offset (in bytes) - ld [hSpriteOffset], a + ldh [hSpriteOffset], a xor a ld [MBC1SRamBank], a ld hl, sSpriteBuffer0 @@ -110,15 +110,15 @@ LoadUncompressedSpriteData:: ; copies and aligns the sprite data properly inside the sprite buffer ; sprite buffers are 7*7 tiles in size, the loaded sprite is centered within this area AlignSpriteDataCentered:: - ld a, [hSpriteOffset] + ldh a, [hSpriteOffset] ld b, $0 ld c, a add hl, bc - ld a, [hSpriteWidth] + ldh a, [hSpriteWidth] .columnLoop push af push hl - ld a, [hSpriteHeight] + ldh a, [hSpriteHeight] ld c, a .columnInnerLoop ld a, [de] @@ -157,7 +157,7 @@ InterlaceMergeSpriteBuffers:: ld de, sSpriteBuffer1 + (SPRITEBUFFERSIZE - 1) ; source 2: end of buffer 1 ld bc, sSpriteBuffer0 + (SPRITEBUFFERSIZE - 1) ; source 1: end of buffer 0 ld a, SPRITEBUFFERSIZE/2 ; $c4 - ld [hSpriteInterlaceCounter], a + ldh [hSpriteInterlaceCounter], a .interlaceLoop ld a, [de] dec de @@ -171,9 +171,9 @@ InterlaceMergeSpriteBuffers:: ld a, [bc] dec bc ld [hld], a ; write byte of source 1 - ld a, [hSpriteInterlaceCounter] + ldh a, [hSpriteInterlaceCounter] dec a - ld [hSpriteInterlaceCounter], a + ldh [hSpriteInterlaceCounter], a jr nz, .interlaceLoop ld a, [wSpriteFlipped] and a @@ -191,6 +191,6 @@ InterlaceMergeSpriteBuffers:: pop hl ld de, sSpriteBuffer1 ld c, (2*SPRITEBUFFERSIZE)/16 ; $31, number of 16 byte chunks to be copied - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] ld b, a jp CopyVideoData diff --git a/home/pokemon.asm b/home/pokemon.asm index 539632d4..d018843e 100644 --- a/home/pokemon.asm +++ b/home/pokemon.asm @@ -81,7 +81,7 @@ DrawHPBar:: ; wLoadedMon = base address of pokemon data ; wMonHeader = base address of base stats LoadMonData:: - jpab LoadMonData_ + jpfar LoadMonData_ OverwritewMoves:: ; Write c to [wMoves + b]. Unused. @@ -122,18 +122,18 @@ LoadFrontSpriteByMonIndex:: ld de, vFrontPic call LoadMonFrontSprite pop hl - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] push af ld a, BANK(CopyUncompressedPicToHL) - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a xor a - ld [hStartTileID], a + ldh [hStartTileID], a call CopyUncompressedPicToHL xor a ld [wSpriteFlipped], a pop af - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ret @@ -175,10 +175,10 @@ GetCryData:: ret DisplayPartyMenu:: - ld a, [hTilesetType] + ldh a, [hTilesetType] push af xor a - ld [hTilesetType], a + ldh [hTilesetType], a call GBPalWhiteOutWithDelay3 call ClearSprites call PartyMenuInit @@ -186,10 +186,10 @@ DisplayPartyMenu:: jp HandlePartyMenuInput GoBackToPartyMenu:: - ld a, [hTilesetType] + ldh a, [hTilesetType] push af xor a - ld [hTilesetType], a + ldh [hTilesetType], a call PartyMenuInit call RedrawPartyMenu jp HandlePartyMenuInput @@ -251,7 +251,7 @@ HandlePartyMenuInput:: and a jp nz, .swappingPokemon pop af - ld [hTilesetType], a + ldh [hTilesetType], a bit 1, b jr nz, .noPokemonChosen ld a, [wPartyCount] @@ -277,7 +277,7 @@ HandlePartyMenuInput:: bit 1, b ; was the B button pressed? jr z, .handleSwap ; if not, handle swapping the pokemon .cancelSwap ; if the B button was pressed - callba ErasePartyMenuCursors + farcall ErasePartyMenuCursors xor a ld [wMenuItemToSwap], a ld [wPartyMenuTypeOrMessageID], a @@ -286,7 +286,7 @@ HandlePartyMenuInput:: .handleSwap ld a, [wCurrentMenuItem] ld [wWhichPokemon], a - callba SwitchPartyMon + farcall SwitchPartyMon jr HandlePartyMenuInput DrawPartyMenu:: @@ -325,15 +325,15 @@ PrintStatusCondition:: ret PrintStatusConditionNotFainted:: - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] push af ld a, BANK(PrintStatusAilment) - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a call PrintStatusAilment ; print status condition pop bc ld a, b - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ret @@ -382,10 +382,10 @@ GetwMoves:: ; INPUT: ; [wd0b5] = pokemon ID GetMonHeader:: - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] push af ld a, BANK(BaseStats) - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a push bc push de @@ -440,7 +440,7 @@ GetMonHeader:: pop de pop bc pop af - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ret diff --git a/home/predef.asm b/home/predef.asm index 4f0c37d9..69aa7347 100644 --- a/home/predef.asm +++ b/home/predef.asm @@ -8,18 +8,18 @@ Predef:: ; A hack for LoadDestinationWarpPosition. ; See LoadTilesetHeader (predef $19). - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] ld [wPredefParentBank], a push af ld a, BANK(GetPredefPointer) - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a call GetPredefPointer ld a, [wPredefBank] - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ld de, .done @@ -28,7 +28,7 @@ Predef:: .done pop af - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ret diff --git a/home/predef_text.asm b/home/predef_text.asm new file mode 100644 index 00000000..b494a2c8 --- /dev/null +++ b/home/predef_text.asm @@ -0,0 +1,28 @@ +PrintPredefTextID:: + ldh [hSpriteIndexOrTextID], a + ld hl, TextPredefs + call SetMapTextPointer + ld hl, wTextPredefFlag + set 0, [hl] + call DisplayTextID + +RestoreMapTextPointer:: + ld hl, wMapTextPtr + ldh a, [hSavedMapTextPtr] + ld [hli], a + ldh a, [hSavedMapTextPtr + 1] + ld [hl], a + ret + +SetMapTextPointer:: + ld a, [wMapTextPtr] + ldh [hSavedMapTextPtr], a + ld a, [wMapTextPtr + 1] + ldh [hSavedMapTextPtr + 1], a + ld a, l + ld [wMapTextPtr], a + ld a, h + ld [wMapTextPtr + 1], a + ret + +INCLUDE "data/text_predef_pointers.asm" diff --git a/home/print_num.asm b/home/print_num.asm index f7ea2174..e2628b1f 100644 --- a/home/print_num.asm +++ b/home/print_num.asm @@ -6,9 +6,9 @@ PrintNumber:: ; in bits 7 and 6 of b respectively. push bc xor a - ld [hPastLeadingZeros], a - ld [hNumToPrint], a - ld [hNumToPrint + 1], a + ldh [hPastLeadingZeros], a + ldh [hNumToPrint], a + ldh [hNumToPrint + 1], a ld a, b and $f cp 1 @@ -17,26 +17,26 @@ PrintNumber:: jr z, .word .long ld a, [de] - ld [hNumToPrint], a + ldh [hNumToPrint], a inc de ld a, [de] - ld [hNumToPrint + 1], a + ldh [hNumToPrint + 1], a inc de ld a, [de] - ld [hNumToPrint + 2], a + ldh [hNumToPrint + 2], a jr .start .word ld a, [de] - ld [hNumToPrint + 1], a + ldh [hNumToPrint + 1], a inc de ld a, [de] - ld [hNumToPrint + 2], a + ldh [hNumToPrint + 2], a jr .start .byte ld a, [de] - ld [hNumToPrint + 2], a + ldh [hNumToPrint + 2], a .start push de @@ -66,17 +66,17 @@ IF (\1) / $10000 ELSE xor a ENDC - ld [hPowerOf10 + 0], a + ldh [hPowerOf10 + 0], a IF (\1) / $100 ld a, \1 / $100 % $100 ELSE xor a ENDC - ld [hPowerOf10 + 1], a + ldh [hPowerOf10 + 1], a ld a, \1 / $1 % $100 - ld [hPowerOf10 + 2], a + ldh [hPowerOf10 + 2], a call .PrintDigit call .NextDigit @@ -90,7 +90,7 @@ ENDM .tens ld c, 0 - ld a, [hNumToPrint + 2] + ldh a, [hNumToPrint + 2] .mod cp 10 jr c, .ok @@ -100,9 +100,9 @@ ENDM .ok ld b, a - ld a, [hPastLeadingZeros] + ldh a, [hPastLeadingZeros] or c - ld [hPastLeadingZeros], a + ldh [hPastLeadingZeros], a jr nz, .past call .PrintLeadingZero jr .next @@ -127,74 +127,74 @@ ENDM ; Print the quotient, and keep the modulus. ld c, 0 .loop - ld a, [hPowerOf10] + ldh a, [hPowerOf10] ld b, a - ld a, [hNumToPrint] - ld [hSavedNumToPrint], a + ldh a, [hNumToPrint] + ldh [hSavedNumToPrint], a cp b jr c, .underflow0 sub b - ld [hNumToPrint], a - ld a, [hPowerOf10 + 1] + ldh [hNumToPrint], a + ldh a, [hPowerOf10 + 1] ld b, a - ld a, [hNumToPrint + 1] - ld [hSavedNumToPrint + 1], a + ldh a, [hNumToPrint + 1] + ldh [hSavedNumToPrint + 1], a cp b jr nc, .noborrow1 - ld a, [hNumToPrint] + ldh a, [hNumToPrint] or 0 jr z, .underflow1 dec a - ld [hNumToPrint], a - ld a, [hNumToPrint + 1] + ldh [hNumToPrint], a + ldh a, [hNumToPrint + 1] .noborrow1 sub b - ld [hNumToPrint + 1], a - ld a, [hPowerOf10 + 2] + ldh [hNumToPrint + 1], a + ldh a, [hPowerOf10 + 2] ld b, a - ld a, [hNumToPrint + 2] - ld [hSavedNumToPrint + 2], a + ldh a, [hNumToPrint + 2] + ldh [hSavedNumToPrint + 2], a cp b jr nc, .noborrow2 - ld a, [hNumToPrint + 1] + ldh a, [hNumToPrint + 1] and a jr nz, .borrowed - ld a, [hNumToPrint] + ldh a, [hNumToPrint] and a jr z, .underflow2 dec a - ld [hNumToPrint], a + ldh [hNumToPrint], a xor a .borrowed dec a - ld [hNumToPrint + 1], a - ld a, [hNumToPrint + 2] + ldh [hNumToPrint + 1], a + ldh a, [hNumToPrint + 2] .noborrow2 sub b - ld [hNumToPrint + 2], a + ldh [hNumToPrint + 2], a inc c jr .loop .underflow2 - ld a, [hSavedNumToPrint + 1] - ld [hNumToPrint + 1], a + ldh a, [hSavedNumToPrint + 1] + ldh [hNumToPrint + 1], a .underflow1 - ld a, [hSavedNumToPrint] - ld [hNumToPrint], a + ldh a, [hSavedNumToPrint] + ldh [hNumToPrint], a .underflow0 - ld a, [hPastLeadingZeros] + ldh a, [hPastLeadingZeros] or c jr z, .PrintLeadingZero ld a, "0" add c ld [hl], a - ld [hPastLeadingZeros], a + ldh [hPastLeadingZeros], a ret .PrintLeadingZero: @@ -211,7 +211,7 @@ ENDM jr nz, .inc bit BIT_LEFT_ALIGN, d jr z, .inc - ld a, [hPastLeadingZeros] + ldh a, [hPastLeadingZeros] and a ret z .inc diff --git a/home/print_text.asm b/home/print_text.asm new file mode 100644 index 00000000..049ddfb4 --- /dev/null +++ b/home/print_text.asm @@ -0,0 +1,45 @@ +; This function is used to wait a short period after printing a letter to the +; screen unless the player presses the A/B button or the delay is turned off +; through the [wd730] or [wLetterPrintingDelayFlags] flags. +PrintLetterDelay:: + ld a, [wd730] + bit 6, a + ret nz + ld a, [wLetterPrintingDelayFlags] + bit 1, a + ret z + push hl + push de + push bc + ld a, [wLetterPrintingDelayFlags] + bit 0, a + jr z, .waitOneFrame + ld a, [wOptions] + and $f + ldh [hFrameCounter], a + jr .checkButtons +.waitOneFrame + ld a, 1 + ldh [hFrameCounter], a +.checkButtons + call Joypad + ldh a, [hJoyHeld] +.checkAButton + bit 0, a ; is the A button pressed? + jr z, .checkBButton + jr .endWait +.checkBButton + bit 1, a ; is the B button pressed? + jr z, .buttonsNotPressed +.endWait + call DelayFrame + jr .done +.buttonsNotPressed ; if neither A nor B is pressed + ldh a, [hFrameCounter] + and a + jr nz, .checkButtons +.done + pop bc + pop de + pop hl + ret diff --git a/home/random.asm b/home/random.asm new file mode 100644 index 00000000..33a24425 --- /dev/null +++ b/home/random.asm @@ -0,0 +1,12 @@ +Random:: +; Return a random number in a. +; For battles, use BattleRandom. + push hl + push de + push bc + farcall Random_ + ldh a, [hRandomAdd] + pop bc + pop de + pop hl + ret diff --git a/home/reload_sprites.asm b/home/reload_sprites.asm new file mode 100644 index 00000000..8a08d64d --- /dev/null +++ b/home/reload_sprites.asm @@ -0,0 +1,19 @@ +; Copy the current map's sprites' tile patterns to VRAM again after they have +; been overwritten by other tile patterns. +ReloadMapSpriteTilePatterns:: + ld hl, wFontLoaded + ld a, [hl] + push af + res 0, [hl] + push hl + xor a + ld [wSpriteSetID], a + call DisableLCD + farcall InitMapSprites + call EnableLCD + pop hl + pop af + ld [hl], a + call LoadPlayerSpriteGraphics + call LoadFontTilePatterns + jp UpdateSprites diff --git a/home/reload_tiles.asm b/home/reload_tiles.asm new file mode 100644 index 00000000..6228395c --- /dev/null +++ b/home/reload_tiles.asm @@ -0,0 +1,41 @@ +; reloads text box tile patterns, current map view, and tileset tile patterns +ReloadMapData:: + ldh a, [hLoadedROMBank] + push af + ld a, [wCurMap] + call SwitchToMapRomBank + call DisableLCD + call LoadTextBoxTilePatterns + call LoadCurrentMapView + call LoadTilesetTilePatternData + call EnableLCD + pop af + ldh [hLoadedROMBank], a + ld [MBC1RomBank], a + ret + +; reloads tileset tile patterns +ReloadTilesetTilePatterns:: + ldh a, [hLoadedROMBank] + push af + ld a, [wCurMap] + call SwitchToMapRomBank + call DisableLCD + call LoadTilesetTilePatternData + call EnableLCD + pop af + ldh [hLoadedROMBank], a + ld [MBC1RomBank], a + ret + +; shows the town map and lets the player choose a destination to fly to +ChooseFlyDestination:: + ld hl, wd72e + res 4, [hl] + farjp LoadTownMap_Fly + +; causes the text box to close without waiting for a button press after displaying text +DisableWaitingAfterTextDisplay:: + ld a, $01 + ld [wDoNotWaitForButtonPressAfterDisplayingText], a + ret diff --git a/home/reset_player_sprite.asm b/home/reset_player_sprite.asm new file mode 100644 index 00000000..72df31a1 --- /dev/null +++ b/home/reset_player_sprite.asm @@ -0,0 +1,20 @@ +ResetPlayerSpriteData:: + ld hl, wSpriteStateData1 + call ResetPlayerSpriteData_ClearSpriteData + ld hl, wSpriteStateData2 + call ResetPlayerSpriteData_ClearSpriteData + ld a, $1 + ld [wSpritePlayerStateData1PictureID], a + ld [wSpritePlayerStateData2ImageBaseOffset], a + ld hl, wSpritePlayerStateData1YPixels + ld [hl], $3c ; set Y screen pos + inc hl + inc hl + ld [hl], $40 ; set X screen pos + ret + +; overwrites sprite data with zeroes +ResetPlayerSpriteData_ClearSpriteData:: + ld bc, $10 + xor a + jp FillMemory diff --git a/home/serial.asm b/home/serial.asm index 6c412239..bd984d4f 100644 --- a/home/serial.asm +++ b/home/serial.asm @@ -3,46 +3,46 @@ Serial:: push bc push de push hl - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] inc a jr z, .connectionNotYetEstablished - ld a, [rSB] - ld [hSerialReceiveData], a - ld a, [hSerialSendData] - ld [rSB], a - ld a, [hSerialConnectionStatus] + ldh a, [rSB] + ldh [hSerialReceiveData], a + ldh a, [hSerialSendData] + ldh [rSB], a + ldh a, [hSerialConnectionStatus] cp USING_INTERNAL_CLOCK jr z, .done ; using external clock ld a, START_TRANSFER_EXTERNAL_CLOCK - ld [rSC], a + ldh [rSC], a jr .done .connectionNotYetEstablished - ld a, [rSB] - ld [hSerialReceiveData], a - ld [hSerialConnectionStatus], a + ldh a, [rSB] + ldh [hSerialReceiveData], a + ldh [hSerialConnectionStatus], a cp USING_INTERNAL_CLOCK jr z, .usingInternalClock ; using external clock xor a - ld [rSB], a + ldh [rSB], a ld a, $3 - ld [rDIV], a + ldh [rDIV], a .waitLoop - ld a, [rDIV] + ldh a, [rDIV] bit 7, a jr nz, .waitLoop ld a, START_TRANSFER_EXTERNAL_CLOCK - ld [rSC], a + ldh [rSC], a jr .done .usingInternalClock xor a - ld [rSB], a + ldh [rSB], a .done ld a, $1 - ld [hSerialReceivedNewData], a + ldh [hSerialReceivedNewData], a ld a, SERIAL_NO_DATA_BYTE - ld [hSerialSendData], a + ldh [hSerialSendData], a pop hl pop de pop bc @@ -54,10 +54,10 @@ Serial:: ; bc = length of data Serial_ExchangeBytes:: ld a, 1 - ld [hSerialIgnoringInitialData], a + ldh [hSerialIgnoringInitialData], a .loop ld a, [hl] - ld [hSerialSendData], a + ldh [hSerialSendData], a call Serial_ExchangeByte push bc ld b, a @@ -66,7 +66,7 @@ Serial_ExchangeBytes:: .waitLoop dec a jr nz, .waitLoop - ld a, [hSerialIgnoringInitialData] + ldh a, [hSerialIgnoringInitialData] and a ld a, b pop bc @@ -75,7 +75,7 @@ Serial_ExchangeBytes:: cp SERIAL_PREAMBLE_BYTE jr nz, .loop xor a - ld [hSerialIgnoringInitialData], a + ldh [hSerialIgnoringInitialData], a jr .loop .storeReceivedByte ld [de], a @@ -88,17 +88,17 @@ Serial_ExchangeBytes:: Serial_ExchangeByte:: xor a - ld [hSerialReceivedNewData], a - ld a, [hSerialConnectionStatus] + ldh [hSerialReceivedNewData], a + ldh a, [hSerialConnectionStatus] cp USING_INTERNAL_CLOCK jr nz, .loop ld a, START_TRANSFER_INTERNAL_CLOCK - ld [rSC], a + ldh [rSC], a .loop - ld a, [hSerialReceivedNewData] + ldh a, [hSerialReceivedNewData] and a jr nz, .ok - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK jr nz, .doNotIncrementUnknownCounter call IsUnknownCounterZero @@ -116,7 +116,7 @@ Serial_ExchangeByte:: jr nz, .loop jp SetUnknownCounterToFFFF .doNotIncrementUnknownCounter - ld a, [rIE] + ldh a, [rIE] and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK) cp (1 << SERIAL) jr nz, .loop @@ -128,7 +128,7 @@ Serial_ExchangeByte:: dec a ld [wUnknownSerialCounter2 + 1], a jr nz, .loop - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK jr z, .ok ld a, 255 @@ -137,8 +137,8 @@ Serial_ExchangeByte:: jr nz, .waitLoop .ok xor a - ld [hSerialReceivedNewData], a - ld a, [rIE] + ldh [hSerialReceivedNewData], a + ldh a, [rIE] and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK) sub (1 << SERIAL) jr nz, .skipReloadingUnknownCounter2 @@ -146,7 +146,7 @@ Serial_ExchangeByte:: ld a, $50 ld [wUnknownSerialCounter2 + 1], a .skipReloadingUnknownCounter2 - ld a, [hSerialReceiveData] + ldh a, [hSerialReceiveData] cp SERIAL_NO_DATA_BYTE ret nz call IsUnknownCounterZero @@ -164,13 +164,13 @@ Serial_ExchangeByte:: call IsUnknownCounterZero jr z, SetUnknownCounterToFFFF .done - ld a, [rIE] + ldh a, [rIE] and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK) cp (1 << SERIAL) ld a, SERIAL_NO_DATA_BYTE ret z ld a, [hl] - ld [hSerialSendData], a + ldh [hSerialSendData], a call DelayFrame jp Serial_ExchangeByte @@ -203,18 +203,18 @@ Serial_ExchangeLinkMenuSelection:: ld de, wLinkMenuSelectionReceiveBuffer ld c, 2 ; number of bytes to save ld a, 1 - ld [hSerialIgnoringInitialData], a + ldh [hSerialIgnoringInitialData], a .loop call DelayFrame ld a, [hl] - ld [hSerialSendData], a + ldh [hSerialSendData], a call Serial_ExchangeByte ld b, a inc hl - ld a, [hSerialIgnoringInitialData] + ldh a, [hSerialIgnoringInitialData] and a ld a, 0 - ld [hSerialIgnoringInitialData], a + ldh [hSerialIgnoringInitialData], a jr nz, .loop ld a, b ld [de], a @@ -225,7 +225,7 @@ Serial_ExchangeLinkMenuSelection:: Serial_PrintWaitingTextAndSyncAndExchangeNybble:: call SaveScreenTilesToBuffer1 - callab PrintWaitingText + callfar PrintWaitingText call Serial_SyncAndExchangeNybble jp LoadScreenTilesFromBuffer1 @@ -273,20 +273,20 @@ Serial_ExchangeNybble:: call .doExchange ld a, [wSerialExchangeNybbleSendData] add $60 - ld [hSerialSendData], a - ld a, [hSerialConnectionStatus] + ldh [hSerialSendData], a + ldh a, [hSerialConnectionStatus] cp USING_INTERNAL_CLOCK jr nz, .doExchange ld a, START_TRANSFER_INTERNAL_CLOCK - ld [rSC], a + ldh [rSC], a .doExchange - ld a, [hSerialReceiveData] + ldh a, [hSerialReceiveData] ld [wSerialExchangeNybbleTempReceiveData], a and $f0 cp $60 ret nz xor a - ld [hSerialReceiveData], a + ldh [hSerialReceiveData], a ld a, [wSerialExchangeNybbleTempReceiveData] and $f ld [wSerialExchangeNybbleReceiveData], a @@ -294,19 +294,19 @@ Serial_ExchangeNybble:: Serial_SendZeroByte:: xor a - ld [hSerialSendData], a - ld a, [hSerialConnectionStatus] + ldh [hSerialSendData], a + ldh a, [hSerialConnectionStatus] cp USING_INTERNAL_CLOCK ret nz ld a, START_TRANSFER_INTERNAL_CLOCK - ld [rSC], a + ldh [rSC], a ret Serial_TryEstablishingExternallyClockedConnection:: ld a, ESTABLISH_CONNECTION_WITH_EXTERNAL_CLOCK - ld [rSB], a + ldh [rSB], a xor a - ld [hSerialReceiveData], a + ldh [hSerialReceiveData], a ld a, START_TRANSFER_EXTERNAL_CLOCK - ld [rSC], a + ldh [rSC], a ret diff --git a/home/start_menu.asm b/home/start_menu.asm index 38333644..5b29f67a 100755 --- a/home/start_menu.asm +++ b/home/start_menu.asm @@ -1,6 +1,6 @@ DisplayStartMenu:: ld a, BANK(StartMenu_Pokedex) - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ld a, [wWalkBikeSurfState] ; walking/biking/surfing ld [wWalkBikeSurfStateCopy], a @@ -8,8 +8,8 @@ DisplayStartMenu:: call PlaySound RedisplayStartMenu:: - callba DrawStartMenu - callba PrintSafariZoneSteps ; print Safari Zone info, if in Safari Zone + farcall DrawStartMenu + farcall PrintSafariZoneSteps ; print Safari Zone info, if in Safari Zone call UpdateSprites .loop call HandleMenuInput @@ -78,7 +78,7 @@ RedisplayStartMenu:: ; EXIT falls through to here CloseStartMenu:: call Joypad - ld a, [hJoyPressed] + ldh a, [hJoyPressed] bit 0, a ; was A button newly pressed? jr nz, CloseStartMenu call LoadTextBoxTilePatterns diff --git a/home/text.asm b/home/text.asm index 2047eaaa..bdd871cb 100644 --- a/home/text.asm +++ b/home/text.asm @@ -62,7 +62,7 @@ PlaceNextChar:: cp "<NEXT>" jr nz, .NotNext ld bc, 2 * SCREEN_WIDTH - ld a, [hFlagsFFF6] + ldh a, [hFlagsFFF6] bit 2, a jr z, .ok ld bc, SCREEN_WIDTH @@ -76,7 +76,7 @@ PlaceNextChar:: cp "<LINE>" jr nz, .NotLine pop hl - coord hl, 1, 16 + hlcoord 1, 16 push hl jp NextChar @@ -141,12 +141,12 @@ SixDotsChar:: print_name SixDotsCharText PlacePKMN:: print_name PlacePKMNText PlaceMoveTargetsName:: - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] xor 1 jr PlaceMoveUsersName.place PlaceMoveUsersName:: - ld a, [hWhoseTurn] + ldh a, [hWhoseTurn] .place: push de @@ -207,12 +207,12 @@ PromptText:: cp LINK_STATE_BATTLING jp z, .ok ld a, "▼" - Coorda 18, 16 + ldcoord_a 18, 16 .ok call ProtectedDelay3 call ManualTextScroll ld a, " " - Coorda 18, 16 + ldcoord_a 18, 16 DoneText:: pop hl @@ -226,49 +226,49 @@ DoneText:: Paragraph:: push de ld a, "▼" - Coorda 18, 16 + ldcoord_a 18, 16 call ProtectedDelay3 call ManualTextScroll - coord hl, 1, 13 + hlcoord 1, 13 lb bc, 4, 18 call ClearScreenArea ld c, 20 call DelayFrames pop de - coord hl, 1, 14 + hlcoord 1, 14 jp NextChar PageChar:: push de ld a, "▼" - Coorda 18, 16 + ldcoord_a 18, 16 call ProtectedDelay3 call ManualTextScroll - coord hl, 1, 10 + hlcoord 1, 10 lb bc, 7, 18 call ClearScreenArea ld c, 20 call DelayFrames pop de pop hl - coord hl, 1, 11 + hlcoord 1, 11 push hl jp NextChar _ContText:: ld a, "▼" - Coorda 18, 16 + ldcoord_a 18, 16 call ProtectedDelay3 push de call ManualTextScroll pop de ld a, " " - Coorda 18, 16 + ldcoord_a 18, 16 _ContTextNoPause:: push de call ScrollTextUpOneLine call ScrollTextUpOneLine - coord hl, 1, 16 + hlcoord 1, 16 pop de jp NextChar @@ -277,8 +277,8 @@ _ContTextNoPause:: ; first time, copy the two rows of text to the "in between" rows that are usually emtpy ; second time, copy the bottom row of text into the top row of text ScrollTextUpOneLine:: - coord hl, 0, 14 ; top row of text - coord de, 0, 13 ; empty line above text + hlcoord 0, 14 ; top row of text + decoord 0, 13 ; empty line above text ld b, SCREEN_WIDTH * 3 .copyText ld a, [hli] @@ -286,7 +286,7 @@ ScrollTextUpOneLine:: inc de dec b jr nz, .copyText - coord hl, 1, 16 + hlcoord 1, 16 ld a, " " ld b, SCREEN_WIDTH - 2 .clearText @@ -313,7 +313,7 @@ TextCommandProcessor:: push af set 1, a ld e, a - ld a, [hClearLetterPrintingDelayFlags] + ldh a, [hClearLetterPrintingDelayFlags] xor e ld [wLetterPrintingDelayFlags], a ld a, c @@ -424,7 +424,7 @@ TextCommand_MOVE:: TextCommand_LOW:: ; write text at (1,16) pop hl - coord bc, 1, 16 ; second line of dialogue text box + bccoord 1, 16 ; second line of dialogue text box jp NextTextCommand TextCommand_PROMPT_BUTTON:: @@ -433,12 +433,12 @@ TextCommand_PROMPT_BUTTON:: cp LINK_STATE_BATTLING jp z, TextCommand_WAIT_BUTTON ld a, "▼" - Coorda 18, 16 ; place down arrow in lower right corner of dialogue text box + ldcoord_a 18, 16 ; place down arrow in lower right corner of dialogue text box push bc call ManualTextScroll ; blink arrow and wait for A or B to be pressed pop bc ld a, " " - Coorda 18, 16 ; overwrite down arrow with blank space + ldcoord_a 18, 16 ; overwrite down arrow with blank space pop hl jp NextTextCommand @@ -446,11 +446,11 @@ TextCommand_SCROLL:: ; pushes text up two lines and sets the BC cursor to the border tile ; below the first character column of the text box. ld a, " " - Coorda 18, 16 ; place blank space in lower right corner of dialogue text box + ldcoord_a 18, 16 ; place blank space in lower right corner of dialogue text box call ScrollTextUpOneLine call ScrollTextUpOneLine pop hl - coord bc, 1, 16 ; second line of dialogue text box + bccoord 1, 16 ; second line of dialogue text box jp NextTextCommand TextCommand_START_ASM:: @@ -489,7 +489,7 @@ TextCommand_PAUSE:: ; wait for button press or 30 frames push bc call Joypad - ld a, [hJoyHeld] + ldh a, [hJoyHeld] and A_BUTTON | B_BUTTON jr nz, .done ld c, 30 ; half a second @@ -565,7 +565,7 @@ TextCommand_DOTS:: push de call Joypad pop de - ld a, [hJoyHeld] ; joypad state + ldh a, [hJoyHeld] ; joypad state and A_BUTTON | B_BUTTON jr nz, .next ; if so, skip the delay ld c, 10 @@ -590,7 +590,7 @@ TextCommand_WAIT_BUTTON:: TextCommand_FAR:: ; write text from a different bank (little endian) pop hl - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] push af ld a, [hli] @@ -599,7 +599,7 @@ TextCommand_FAR:: ld d, a ld a, [hli] - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a push hl @@ -609,7 +609,7 @@ TextCommand_FAR:: pop hl pop af - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a jp NextTextCommand diff --git a/home/text_script.asm b/home/text_script.asm index 2dd2dbde..b9c3c8e4 100644 --- a/home/text_script.asm +++ b/home/text_script.asm @@ -1,9 +1,9 @@ ; this function is used to display sign messages, sprite dialog, etc. ; INPUT: [hSpriteIndexOrTextID] = sprite ID or text ID DisplayTextID:: - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] push af - callba DisplayTextIDInit ; initialization + farcall DisplayTextIDInit ; initialization ld hl, wTextPredefFlag bit 0, [hl] res 0, [hl] @@ -12,13 +12,13 @@ DisplayTextID:: call SwitchToMapRomBank .skipSwitchToMapBank ld a, 30 ; half a second - ld [hFrameCounter], a ; used as joypad poll timer + ldh [hFrameCounter], a ; used as joypad poll timer ld hl, wMapTextPtr ld a, [hli] ld h, [hl] ld l, a ; hl = map text pointer ld d, $00 - ld a, [hSpriteIndexOrTextID] ; text ID + ldh a, [hSpriteIndexOrTextID] ; text ID ld [wSpriteIndex], a dict TEXT_START_MENU, DisplayStartMenu @@ -29,7 +29,7 @@ DisplayTextID:: ld a, [wNumSprites] ld e, a - ld a, [hSpriteIndexOrTextID] ; sprite ID + ldh a, [hSpriteIndexOrTextID] ; sprite ID cp e jr z, .spriteHandling jr nc, .skipSpriteHandling @@ -38,11 +38,11 @@ DisplayTextID:: push hl push de push bc - callba UpdateSpriteFacingOffsetAndDelayMovement ; update the graphics of the sprite the player is talking to (to face the right direction) + farcall UpdateSpriteFacingOffsetAndDelayMovement ; update the graphics of the sprite the player is talking to (to face the right direction) pop bc pop de ld hl, wMapSpriteData ; NPC text entries - ld a, [hSpriteIndexOrTextID] + ldh a, [hSpriteIndexOrTextID] dec a add a add l @@ -79,9 +79,9 @@ ENDM dict TX_SCRIPT_PLAYERS_PC, TextScript_ItemStoragePC dict TX_SCRIPT_BILLS_PC, TextScript_BillsPC dict TX_SCRIPT_POKECENTER_PC, TextScript_PokemonCenterPC - dict2 TX_SCRIPT_VENDING_MACHINE, callba VendingMachineMenu + dict2 TX_SCRIPT_VENDING_MACHINE, farcall VendingMachineMenu dict TX_SCRIPT_PRIZE_VENDOR, TextScript_GameCornerPrizeMenu - dict2 TX_SCRIPT_CABLE_CLUB_RECEPTIONIST, callab CableClubNPC + dict2 TX_SCRIPT_CABLE_CLUB_RECEPTIONIST, callfar CableClubNPC call PrintText_NoCreatingTextBox ; display the text ld a, [wDoNotWaitForButtonPressAfterDisplayingText] @@ -97,7 +97,7 @@ AfterDisplayingTextID:: ; loop to hold the dialogue box open as long as the player keeps holding down the A button HoldTextDisplayOpen:: call Joypad - ld a, [hJoyHeld] + ldh a, [hJoyHeld] bit 0, a ; is the A button being pressed? jr nz, HoldTextDisplayOpen @@ -105,25 +105,25 @@ CloseTextDisplay:: ld a, [wCurMap] call SwitchToMapRomBank ld a, $90 - ld [hWY], a ; move the window off the screen + ldh [hWY], a ; move the window off the screen call DelayFrame call LoadGBPal xor a - ld [hAutoBGTransferEnabled], a ; disable continuous WRAM to VRAM transfer each V-blank + ldh [hAutoBGTransferEnabled], a ; disable continuous WRAM to VRAM transfer each V-blank ; loop to make sprites face the directions they originally faced before the dialogue - ld hl, wSprite01StateData2 + 9 ; should be wSprite01StateData1FacingDirection? + ld hl, wSprite01StateData2OrigFacingDirection ld c, $0f ld de, $10 .restoreSpriteFacingDirectionLoop - ld a, [hl] + ld a, [hl] ; x#SPRITESTATEDATA2_ORIGFACINGDIRECTION dec h - ld [hl], a + ld [hl], a ; [x#SPRITESTATEDATA1_FACINGDIRECTION] inc h add hl, de dec c jr nz, .restoreSpriteFacingDirectionLoop ld a, BANK(InitMapSprites) - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a call InitMapSprites ; reload sprite tile pattern data (since it was partially overwritten by text tile patterns) ld hl, wFontLoaded @@ -133,7 +133,7 @@ CloseTextDisplay:: call z, LoadPlayerSpriteGraphics call LoadCurrentMapView pop af - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a jp UpdateSprites @@ -146,14 +146,14 @@ DisplayPokemartDialogue:: call LoadItemList ld a, PRICEDITEMLISTMENU ld [wListMenuID], a - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] push af ld a, BANK(DisplayPokemartDialogue_) - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a call DisplayPokemartDialogue_ pop af - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a jp AfterDisplayingTextID @@ -180,24 +180,24 @@ LoadItemList:: DisplayPokemonCenterDialogue:: ; zeroing these doesn't appear to serve any purpose xor a - ld [hItemPrice], a - ld [hItemPrice + 1], a - ld [hItemPrice + 2], a + ldh [hItemPrice], a + ldh [hItemPrice + 1], a + ldh [hItemPrice + 2], a inc hl - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] push af ld a, BANK(DisplayPokemonCenterDialogue_) - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a call DisplayPokemonCenterDialogue_ pop af - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a jp AfterDisplayingTextID DisplaySafariGameOverText:: - callab PrintSafariGameOverText + callfar PrintSafariGameOverText jp AfterDisplayingTextID DisplayPokemonFaintedText:: diff --git a/home/textbox.asm b/home/textbox.asm new file mode 100644 index 00000000..5067b044 --- /dev/null +++ b/home/textbox.asm @@ -0,0 +1,16 @@ +; function to draw various text boxes +; INPUT: +; [wTextBoxID] = text box ID +; b, c = y, x cursor position (TWO_OPTION_MENU only) +DisplayTextBoxID:: + ldh a, [hLoadedROMBank] + push af + ld a, BANK(DisplayTextBoxID_) + ldh [hLoadedROMBank], a + ld [MBC1RomBank], a + call DisplayTextBoxID_ + pop bc + ld a, b + ldh [hLoadedROMBank], a + ld [MBC1RomBank], a + ret diff --git a/home/tilemap.asm b/home/tilemap.asm new file mode 100644 index 00000000..afee7097 --- /dev/null +++ b/home/tilemap.asm @@ -0,0 +1,61 @@ +FillMemory:: +; Fill bc bytes at hl with a. + push de + ld d, a +.loop + ld a, d + ld [hli], a + dec bc + ld a, b + or c + jr nz, .loop + pop de + ret + +UncompressSpriteFromDE:: +; Decompress pic at a:de. + ld hl, wSpriteInputPtr + ld [hl], e + inc hl + ld [hl], d + jp UncompressSpriteData + +SaveScreenTilesToBuffer2:: + hlcoord 0, 0 + ld de, wTileMapBackup2 + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT + call CopyData + ret + +LoadScreenTilesFromBuffer2:: + call LoadScreenTilesFromBuffer2DisableBGTransfer + ld a, 1 + ldh [hAutoBGTransferEnabled], a + ret + +; loads screen tiles stored in wTileMapBackup2 but leaves hAutoBGTransferEnabled disabled +LoadScreenTilesFromBuffer2DisableBGTransfer:: + xor a + ldh [hAutoBGTransferEnabled], a + ld hl, wTileMapBackup2 + decoord 0, 0 + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT + call CopyData + ret + +SaveScreenTilesToBuffer1:: + hlcoord 0, 0 + ld de, wTileMapBackup + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT + jp CopyData + +LoadScreenTilesFromBuffer1:: + xor a + ldh [hAutoBGTransferEnabled], a + ld hl, wTileMapBackup + decoord 0, 0 + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT + call CopyData + ld a, 1 + ldh [hAutoBGTransferEnabled], a + ret diff --git a/home/trainers.asm b/home/trainers.asm index 22601db8..039c4ec8 100644 --- a/home/trainers.asm +++ b/home/trainers.asm @@ -144,7 +144,7 @@ CheckFightingMapTrainers:: ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN ld [wJoyIgnore], a xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a call TrainerWalkUpToPlayer_Bank0 ld hl, wCurMapScript inc [hl] ; increment map script index (next script function is usually DisplayEnemyTrainerTextAndStartBattle) @@ -157,7 +157,7 @@ DisplayEnemyTrainerTextAndStartBattle:: ret nz ; return if the enemy trainer hasn't finished walking to the player's sprite ld [wJoyIgnore], a ld a, [wSpriteIndex] - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID ; fall through @@ -211,15 +211,15 @@ EndTrainerBattle:: ResetButtonPressedAndMapScript:: xor a ld [wJoyIgnore], a - ld [hJoyHeld], a - ld [hJoyPressed], a - ld [hJoyReleased], a + ldh [hJoyHeld], a + ldh [hJoyPressed], a + ldh [hJoyReleased], a ld [wCurMapScript], a ; reset battle status ret ; calls TrainerWalkUpToPlayer TrainerWalkUpToPlayer_Bank0:: - jpba TrainerWalkUpToPlayer + farjp TrainerWalkUpToPlayer ; sets opponent type and mon set/lvl based on the engaging trainer data InitBattleEnemyParameters:: @@ -302,7 +302,7 @@ CheckForEngagingTrainers:: ; hl = text if the player wins ; de = text if the player loses SaveEndBattleTextPointers:: - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] ld [wEndBattleTextRomBank], a ld a, h ld [wEndBattleWinTextPointer], a @@ -337,20 +337,20 @@ PrintEndBattleText:: res 7, [hl] pop hl ret z - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] push af ld a, [wEndBattleTextRomBank] - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a push hl - callba SaveTrainerName + farcall SaveTrainerName ld hl, TrainerEndBattleText call PrintText pop hl pop af - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a - callba FreezeEnemyTrainerSprite + farcall FreezeEnemyTrainerSprite jp WaitForSoundToFinish GetSavedEndBattleTextPointer:: diff --git a/home/trainers2.asm b/home/trainers2.asm new file mode 100644 index 00000000..950eabb2 --- /dev/null +++ b/home/trainers2.asm @@ -0,0 +1,35 @@ +GetTrainerInformation:: + call GetTrainerName + ld a, [wLinkState] + and a + jr nz, .linkBattle + ld a, BANK(TrainerPicAndMoneyPointers) + call BankswitchHome + ld a, [wTrainerClass] + dec a + ld hl, TrainerPicAndMoneyPointers + ld bc, $5 + call AddNTimes + ld de, wTrainerPicPointer + ld a, [hli] + ld [de], a + inc de + ld a, [hli] + ld [de], a + ld de, wTrainerBaseMoney + ld a, [hli] + ld [de], a + inc de + ld a, [hli] + ld [de], a + jp BankswitchBack +.linkBattle + ld hl, wTrainerPicPointer + ld de, RedPicFront + ld [hl], e + inc hl + ld [hl], d + ret + +GetTrainerName:: + farjp GetTrainerName_ diff --git a/home/uncompress.asm b/home/uncompress.asm index cfc39f0f..9d08aa60 100644 --- a/home/uncompress.asm +++ b/home/uncompress.asm @@ -2,10 +2,10 @@ ; bank is given in a, sprite input stream is pointed to in wSpriteInputPtr UncompressSpriteData:: ld b, a - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] push af ld a, b - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ld a, SRAM_ENABLE ld [MBC1SRamEnable], a @@ -13,15 +13,15 @@ UncompressSpriteData:: ld [MBC1SRamBank], a call _UncompressSpriteData pop af - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ret ; initializes necessary data to load a sprite and runs UncompressSpriteDataLoop _UncompressSpriteData:: ld hl, sSpriteBuffer1 - ld c, (2*SPRITEBUFFERSIZE) % $100 - ld b, (2*SPRITEBUFFERSIZE) / $100 + ld c, LOW(2 * SPRITEBUFFERSIZE) + ld b, HIGH(2 * SPRITEBUFFERSIZE) xor a call FillMemory ; clear sprite buffer 1 and 2 ld a, $1 diff --git a/home/update_sprites.asm b/home/update_sprites.asm new file mode 100644 index 00000000..80ea14d3 --- /dev/null +++ b/home/update_sprites.asm @@ -0,0 +1,14 @@ +UpdateSprites:: + ld a, [wUpdateSpritesEnabled] + dec a + ret nz + ldh a, [hLoadedROMBank] + push af + ld a, BANK(_UpdateSprites) + ldh [hLoadedROMBank], a + ld [MBC1RomBank], a + call _UpdateSprites + pop af + ldh [hLoadedROMBank], a + ld [MBC1RomBank], a + ret diff --git a/home/vblank.asm b/home/vblank.asm index 78f5f69d..4c7abc20 100644 --- a/home/vblank.asm +++ b/home/vblank.asm @@ -5,19 +5,19 @@ VBlank:: push de push hl - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] ld [wVBlankSavedROMBank], a - ld a, [hSCX] - ld [rSCX], a - ld a, [hSCY] - ld [rSCY], a + ldh a, [hSCX] + ldh [rSCX], a + ldh a, [hSCY] + ldh [rSCY], a ld a, [wDisableVBlankWYUpdate] and a jr nz, .ok - ld a, [hWY] - ld [rWY], a + ldh a, [hWY] + ldh [rWY], a .ok call AutoBgMapTransfer @@ -28,7 +28,7 @@ VBlank:: call UpdateMovingBgTiles call hDMARoutine ld a, BANK(PrepareOAMData) - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a call PrepareOAMData @@ -36,24 +36,24 @@ VBlank:: call Random - ld a, [hVBlankOccurred] + ldh a, [hVBlankOccurred] and a jr z, .skipZeroing xor a - ld [hVBlankOccurred], a + ldh [hVBlankOccurred], a .skipZeroing - ld a, [hFrameCounter] + ldh a, [hFrameCounter] and a jr z, .skipDec dec a - ld [hFrameCounter], a + ldh [hFrameCounter], a .skipDec call FadeOutAudio ld a, [wAudioROMBank] ; music ROM bank - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a cp BANK(Audio1_UpdateMusic) @@ -72,14 +72,14 @@ VBlank:: call Audio3_UpdateMusic .afterMusic - callba TrackPlayTime ; keep track of time played + farcall TrackPlayTime ; keep track of time played - ld a, [hDisableJoypadPolling] + ldh a, [hDisableJoypadPolling] and a call z, ReadJoypad ld a, [wVBlankSavedROMBank] - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a pop hl @@ -96,10 +96,10 @@ DelayFrame:: NOT_VBLANKED EQU 1 ld a, NOT_VBLANKED - ld [hVBlankOccurred], a + ldh [hVBlankOccurred], a .halt halt - ld a, [hVBlankOccurred] + ldh a, [hVBlankOccurred] and a jr nz, .halt ret diff --git a/home/vcopy.asm b/home/vcopy.asm index e2325d5c..458fa610 100644 --- a/home/vcopy.asm +++ b/home/vcopy.asm @@ -40,19 +40,19 @@ ClearBgMap:: ; However, this function is also called repeatedly to redraw the whole screen ; when necessary. It is also used in trade animation and elevator code. RedrawRowOrColumn:: - ld a, [hRedrawRowOrColumnMode] + ldh a, [hRedrawRowOrColumnMode] and a ret z ld b, a xor a - ld [hRedrawRowOrColumnMode], a + ldh [hRedrawRowOrColumnMode], a dec b jr nz, .redrawRow .redrawColumn ld hl, wRedrawRowOrColumnSrcTiles - ld a, [hRedrawRowOrColumnDest] + ldh a, [hRedrawRowOrColumnDest] ld e, a - ld a, [hRedrawRowOrColumnDest + 1] + ldh a, [hRedrawRowOrColumnDest + 1] ld d, a ld c, SCREEN_HEIGHT .loop1 @@ -75,13 +75,13 @@ RedrawRowOrColumn:: dec c jr nz, .loop1 xor a - ld [hRedrawRowOrColumnMode], a + ldh [hRedrawRowOrColumnMode], a ret .redrawRow ld hl, wRedrawRowOrColumnSrcTiles - ld a, [hRedrawRowOrColumnDest] + ldh a, [hRedrawRowOrColumnDest] ld e, a - ld a, [hRedrawRowOrColumnDest + 1] + ldh a, [hRedrawRowOrColumnDest + 1] ld d, a push de call .DrawHalf ; draw upper half @@ -120,51 +120,51 @@ RedrawRowOrColumn:: ; the above function, RedrawRowOrColumn, is used when walking to ; improve efficiency. AutoBgMapTransfer:: - ld a, [hAutoBGTransferEnabled] + ldh a, [hAutoBGTransferEnabled] and a ret z ld hl, sp + 0 ld a, h - ld [hSPTemp], a + ldh [hSPTemp], a ld a, l - ld [hSPTemp + 1], a ; save stack pinter - ld a, [hAutoBGTransferPortion] + ldh [hSPTemp + 1], a ; save stack pinter + ldh a, [hAutoBGTransferPortion] and a jr z, .transferTopThird dec a jr z, .transferMiddleThird .transferBottomThird - coord hl, 0, 12 + hlcoord 0, 12 ld sp, hl - ld a, [hAutoBGTransferDest + 1] + ldh a, [hAutoBGTransferDest + 1] ld h, a - ld a, [hAutoBGTransferDest] + ldh a, [hAutoBGTransferDest] ld l, a ld de, (12 * 32) add hl, de xor a ; TRANSFERTOP jr .doTransfer .transferTopThird - coord hl, 0, 0 + hlcoord 0, 0 ld sp, hl - ld a, [hAutoBGTransferDest + 1] + ldh a, [hAutoBGTransferDest + 1] ld h, a - ld a, [hAutoBGTransferDest] + ldh a, [hAutoBGTransferDest] ld l, a ld a, TRANSFERMIDDLE jr .doTransfer .transferMiddleThird - coord hl, 0, 6 + hlcoord 0, 6 ld sp, hl - ld a, [hAutoBGTransferDest + 1] + ldh a, [hAutoBGTransferDest + 1] ld h, a - ld a, [hAutoBGTransferDest] + ldh a, [hAutoBGTransferDest] ld l, a ld de, (6 * 32) add hl, de ld a, TRANSFERBOTTOM .doTransfer - ld [hAutoBGTransferPortion], a ; store next portion + ldh [hAutoBGTransferPortion], a ; store next portion ld b, 6 TransferBgRows:: @@ -192,9 +192,9 @@ TransferBgRows:: dec b jr nz, TransferBgRows - ld a, [hSPTemp] + ldh a, [hSPTemp] ld h, a - ld a, [hSPTemp + 1] + ldh a, [hSPTemp + 1] ld l, a ld sp, hl ret @@ -202,27 +202,27 @@ TransferBgRows:: ; Copies [hVBlankCopyBGNumRows] rows from hVBlankCopyBGSource to hVBlankCopyBGDest. ; If hVBlankCopyBGSource is XX00, the transfer is disabled. VBlankCopyBgMap:: - ld a, [hVBlankCopyBGSource] ; doubles as enabling byte + ldh a, [hVBlankCopyBGSource] ; doubles as enabling byte and a ret z ld hl, sp + 0 ld a, h - ld [hSPTemp], a + ldh [hSPTemp], a ld a, l - ld [hSPTemp + 1], a ; save stack pointer - ld a, [hVBlankCopyBGSource] + ldh [hSPTemp + 1], a ; save stack pointer + ldh a, [hVBlankCopyBGSource] ld l, a - ld a, [hVBlankCopyBGSource + 1] + ldh a, [hVBlankCopyBGSource + 1] ld h, a ld sp, hl - ld a, [hVBlankCopyBGDest] + ldh a, [hVBlankCopyBGDest] ld l, a - ld a, [hVBlankCopyBGDest + 1] + ldh a, [hVBlankCopyBGDest + 1] ld h, a - ld a, [hVBlankCopyBGNumRows] + ldh a, [hVBlankCopyBGNumRows] ld b, a xor a - ld [hVBlankCopyBGSource], a ; disable transfer so it doesn't continue next V-blank + ldh [hVBlankCopyBGSource], a ; disable transfer so it doesn't continue next V-blank jr TransferBgRows @@ -234,31 +234,31 @@ VBlankCopyDouble:: ; The process is straightforward: ; copy each byte twice. - ld a, [hVBlankCopyDoubleSize] + ldh a, [hVBlankCopyDoubleSize] and a ret z ld hl, sp + 0 ld a, h - ld [hSPTemp], a + ldh [hSPTemp], a ld a, l - ld [hSPTemp + 1], a + ldh [hSPTemp + 1], a - ld a, [hVBlankCopyDoubleSource] + ldh a, [hVBlankCopyDoubleSource] ld l, a - ld a, [hVBlankCopyDoubleSource + 1] + ldh a, [hVBlankCopyDoubleSource + 1] ld h, a ld sp, hl - ld a, [hVBlankCopyDoubleDest] + ldh a, [hVBlankCopyDoubleDest] ld l, a - ld a, [hVBlankCopyDoubleDest + 1] + ldh a, [hVBlankCopyDoubleDest + 1] ld h, a - ld a, [hVBlankCopyDoubleSize] + ldh a, [hVBlankCopyDoubleSize] ld b, a xor a ; transferred - ld [hVBlankCopyDoubleSize], a + ldh [hVBlankCopyDoubleSize], a .loop REPT 3 @@ -286,19 +286,19 @@ VBlankCopyDouble:: jr nz, .loop ld a, l - ld [hVBlankCopyDoubleDest], a + ldh [hVBlankCopyDoubleDest], a ld a, h - ld [hVBlankCopyDoubleDest + 1], a + ldh [hVBlankCopyDoubleDest + 1], a ld hl, sp + 0 ld a, l - ld [hVBlankCopyDoubleSource], a + ldh [hVBlankCopyDoubleSource], a ld a, h - ld [hVBlankCopyDoubleSource + 1], a + ldh [hVBlankCopyDoubleSource + 1], a - ld a, [hSPTemp] + ldh a, [hSPTemp] ld h, a - ld a, [hSPTemp + 1] + ldh a, [hSPTemp + 1] ld l, a ld sp, hl @@ -312,31 +312,31 @@ VBlankCopy:: ; Source and destination addresses are updated, ; so transfer can continue in subsequent calls. - ld a, [hVBlankCopySize] + ldh a, [hVBlankCopySize] and a ret z ld hl, sp + 0 ld a, h - ld [hSPTemp], a + ldh [hSPTemp], a ld a, l - ld [hSPTemp + 1], a + ldh [hSPTemp + 1], a - ld a, [hVBlankCopySource] + ldh a, [hVBlankCopySource] ld l, a - ld a, [hVBlankCopySource + 1] + ldh a, [hVBlankCopySource + 1] ld h, a ld sp, hl - ld a, [hVBlankCopyDest] + ldh a, [hVBlankCopyDest] ld l, a - ld a, [hVBlankCopyDest + 1] + ldh a, [hVBlankCopyDest + 1] ld h, a - ld a, [hVBlankCopySize] + ldh a, [hVBlankCopySize] ld b, a xor a ; transferred - ld [hVBlankCopySize], a + ldh [hVBlankCopySize], a .loop REPT 7 @@ -356,19 +356,19 @@ VBlankCopy:: jr nz, .loop ld a, l - ld [hVBlankCopyDest], a + ldh [hVBlankCopyDest], a ld a, h - ld [hVBlankCopyDest + 1], a + ldh [hVBlankCopyDest + 1], a ld hl, sp + 0 ld a, l - ld [hVBlankCopySource], a + ldh [hVBlankCopySource], a ld a, h - ld [hVBlankCopySource + 1], a + ldh [hVBlankCopySource + 1], a - ld a, [hSPTemp] + ldh a, [hSPTemp] ld h, a - ld a, [hSPTemp + 1] + ldh a, [hSPTemp + 1] ld l, a ld sp, hl @@ -379,13 +379,13 @@ UpdateMovingBgTiles:: ; Animate water and flower ; tiles in the overworld. - ld a, [hTilesetType] + ldh a, [hTilesetType] and a ret z ; no animations if indoors (or if a menu set this to 0) - ld a, [hMovingBGTilesCounter1] + ldh a, [hMovingBGTilesCounter1] inc a - ld [hMovingBGTilesCounter1], a + ldh [hMovingBGTilesCounter1], a cp 20 ret c cp 21 @@ -393,7 +393,7 @@ UpdateMovingBgTiles:: ; water - ld hl, vTileset + $14 * $10 + ld hl, vTileset tile $14 ld c, $10 ld a, [wMovingBGTilesCounter2] @@ -417,17 +417,17 @@ UpdateMovingBgTiles:: dec c jr nz, .left .done - ld a, [hTilesetType] + ldh a, [hTilesetType] rrca ret nc ; if in a cave, no flower animations xor a - ld [hMovingBGTilesCounter1], a + ldh [hMovingBGTilesCounter1], a ret .flower xor a - ld [hMovingBGTilesCounter1], a + ldh [hMovingBGTilesCounter1], a ld a, [wMovingBGTilesCounter2] and 3 @@ -438,7 +438,7 @@ UpdateMovingBgTiles:: jr z, .copy ld hl, FlowerTile3 .copy - ld de, vTileset + $3 * $10 + ld de, vTileset tile $03 ld c, $10 .loop ld a, [hli] diff --git a/home/window.asm b/home/window.asm new file mode 100644 index 00000000..e83f9585 --- /dev/null +++ b/home/window.asm @@ -0,0 +1,294 @@ +HandleMenuInput:: + xor a + ld [wPartyMenuAnimMonEnabled], a + +HandleMenuInput_:: + ldh a, [hDownArrowBlinkCount1] + push af + ldh a, [hDownArrowBlinkCount2] + push af ; save existing values on stack + xor a + ldh [hDownArrowBlinkCount1], a ; blinking down arrow timing value 1 + ld a, 6 + ldh [hDownArrowBlinkCount2], a ; blinking down arrow timing value 2 +.loop1 + xor a + ld [wAnimCounter], a ; counter for pokemon shaking animation + call PlaceMenuCursor + call Delay3 +.loop2 + push hl + ld a, [wPartyMenuAnimMonEnabled] + and a ; is it a pokemon selection menu? + jr z, .getJoypadState + farcall AnimatePartyMon ; shake mini sprite of selected pokemon +.getJoypadState + pop hl + call JoypadLowSensitivity + ldh a, [hJoy5] + and a ; was a key pressed? + jr nz, .keyPressed + push hl + hlcoord 18, 11 ; coordinates of blinking down arrow in some menus + call HandleDownArrowBlinkTiming ; blink down arrow (if any) + pop hl + ld a, [wMenuJoypadPollCount] + dec a + jr z, .giveUpWaiting + jr .loop2 +.giveUpWaiting +; if a key wasn't pressed within the specified number of checks + pop af + ldh [hDownArrowBlinkCount2], a + pop af + ldh [hDownArrowBlinkCount1], a ; restore previous values + xor a + ld [wMenuWrappingEnabled], a ; disable menu wrapping + ret +.keyPressed + xor a + ld [wCheckFor180DegreeTurn], a + ldh a, [hJoy5] + ld b, a + bit 6, a ; pressed Up key? + jr z, .checkIfDownPressed +.upPressed + ld a, [wCurrentMenuItem] ; selected menu item + and a ; already at the top of the menu? + jr z, .alreadyAtTop +.notAtTop + dec a + ld [wCurrentMenuItem], a ; move selected menu item up one space + jr .checkOtherKeys +.alreadyAtTop + ld a, [wMenuWrappingEnabled] + and a ; is wrapping around enabled? + jr z, .noWrappingAround + ld a, [wMaxMenuItem] + ld [wCurrentMenuItem], a ; wrap to the bottom of the menu + jr .checkOtherKeys +.checkIfDownPressed + bit 7, a + jr z, .checkOtherKeys +.downPressed + ld a, [wCurrentMenuItem] + inc a + ld c, a + ld a, [wMaxMenuItem] + cp c + jr nc, .notAtBottom +.alreadyAtBottom + ld a, [wMenuWrappingEnabled] + and a ; is wrapping around enabled? + jr z, .noWrappingAround + ld c, $00 ; wrap from bottom to top +.notAtBottom + ld a, c + ld [wCurrentMenuItem], a +.checkOtherKeys + ld a, [wMenuWatchedKeys] + and b ; does the menu care about any of the pressed keys? + jp z, .loop1 +.checkIfAButtonOrBButtonPressed + ldh a, [hJoy5] + and A_BUTTON | B_BUTTON + jr z, .skipPlayingSound +.AButtonOrBButtonPressed + push hl + ld hl, wFlags_0xcd60 + bit 5, [hl] + pop hl + jr nz, .skipPlayingSound + ld a, SFX_PRESS_AB + call PlaySound +.skipPlayingSound + pop af + ldh [hDownArrowBlinkCount2], a + pop af + ldh [hDownArrowBlinkCount1], a ; restore previous values + xor a + ld [wMenuWrappingEnabled], a ; disable menu wrapping + ldh a, [hJoy5] + ret +.noWrappingAround + ld a, [wMenuWatchMovingOutOfBounds] + and a ; should we return if the user tried to go past the top or bottom? + jr z, .checkOtherKeys + jr .checkIfAButtonOrBButtonPressed + +PlaceMenuCursor:: + ld a, [wTopMenuItemY] + and a ; is the y coordinate 0? + jr z, .adjustForXCoord + hlcoord 0, 0 + ld bc, SCREEN_WIDTH +.topMenuItemLoop + add hl, bc + dec a + jr nz, .topMenuItemLoop +.adjustForXCoord + ld a, [wTopMenuItemX] + ld b, 0 + ld c, a + add hl, bc + push hl + ld a, [wLastMenuItem] + and a ; was the previous menu id 0? + jr z, .checkForArrow1 + push af + ldh a, [hFlagsFFF6] + bit 1, a ; is the menu double spaced? + jr z, .doubleSpaced1 + ld bc, 20 + jr .getOldMenuItemScreenPosition +.doubleSpaced1 + ld bc, 40 +.getOldMenuItemScreenPosition + pop af +.oldMenuItemLoop + add hl, bc + dec a + jr nz, .oldMenuItemLoop +.checkForArrow1 + ld a, [hl] + cp "▶" ; was an arrow next to the previously selected menu item? + jr nz, .skipClearingArrow +.clearArrow + ld a, [wTileBehindCursor] + ld [hl], a +.skipClearingArrow + pop hl + ld a, [wCurrentMenuItem] + and a + jr z, .checkForArrow2 + push af + ldh a, [hFlagsFFF6] + bit 1, a ; is the menu double spaced? + jr z, .doubleSpaced2 + ld bc, 20 + jr .getCurrentMenuItemScreenPosition +.doubleSpaced2 + ld bc, 40 +.getCurrentMenuItemScreenPosition + pop af +.currentMenuItemLoop + add hl, bc + dec a + jr nz, .currentMenuItemLoop +.checkForArrow2 + ld a, [hl] + cp "▶" ; has the right arrow already been placed? + jr z, .skipSavingTile ; if so, don't lose the saved tile + ld [wTileBehindCursor], a ; save tile before overwriting with right arrow +.skipSavingTile + ld a, "▶" ; place right arrow + ld [hl], a + ld a, l + ld [wMenuCursorLocation], a + ld a, h + ld [wMenuCursorLocation + 1], a + ld a, [wCurrentMenuItem] + ld [wLastMenuItem], a + ret + +; This is used to mark a menu cursor other than the one currently being +; manipulated. In the case of submenus, this is used to show the location of +; the menu cursor in the parent menu. In the case of swapping items in list, +; this is used to mark the item that was first chosen to be swapped. +PlaceUnfilledArrowMenuCursor:: + ld b, a + ld a, [wMenuCursorLocation] + ld l, a + ld a, [wMenuCursorLocation + 1] + ld h, a + ld [hl], $ec ; outline of right arrow + ld a, b + ret + +; Replaces the menu cursor with a blank space. +EraseMenuCursor:: + ld a, [wMenuCursorLocation] + ld l, a + ld a, [wMenuCursorLocation + 1] + ld h, a + ld [hl], " " + ret + +; This toggles a blinking down arrow at hl on and off after a delay has passed. +; This is often called even when no blinking is occurring. +; The reason is that most functions that call this initialize hDownArrowBlinkCount1 to 0. +; The effect is that if the tile at hl is initialized with a down arrow, +; this function will toggle that down arrow on and off, but if the tile isn't +; initialized with a down arrow, this function does nothing. +; That allows this to be called without worrying about if a down arrow should +; be blinking. +HandleDownArrowBlinkTiming:: + ld a, [hl] + ld b, a + ld a, "▼" + cp b + jr nz, .downArrowOff +.downArrowOn + ldh a, [hDownArrowBlinkCount1] + dec a + ldh [hDownArrowBlinkCount1], a + ret nz + ldh a, [hDownArrowBlinkCount2] + dec a + ldh [hDownArrowBlinkCount2], a + ret nz + ld a, " " + ld [hl], a + ld a, $ff + ldh [hDownArrowBlinkCount1], a + ld a, $06 + ldh [hDownArrowBlinkCount2], a + ret +.downArrowOff + ldh a, [hDownArrowBlinkCount1] + and a + ret z + dec a + ldh [hDownArrowBlinkCount1], a + ret nz + dec a + ldh [hDownArrowBlinkCount1], a + ldh a, [hDownArrowBlinkCount2] + dec a + ldh [hDownArrowBlinkCount2], a + ret nz + ld a, $06 + ldh [hDownArrowBlinkCount2], a + ld a, "▼" + ld [hl], a + ret + +; The following code either enables or disables the automatic drawing of +; text boxes by DisplayTextID. Both functions cause DisplayTextID to wait +; for a button press after displaying text (unless [wEnteringCableClub] is set). + +EnableAutoTextBoxDrawing:: + xor a + jr AutoTextBoxDrawingCommon + +DisableAutoTextBoxDrawing:: + ld a, $01 + +AutoTextBoxDrawingCommon:: + ld [wAutoTextBoxDrawingControl], a + xor a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ; make DisplayTextID wait for button press + ret + +PrintText:: +; Print text hl at (1, 14). + push hl + ld a, MESSAGE_BOX + ld [wTextBoxID], a + call DisplayTextBoxID + call UpdateSprites + call Delay3 + pop hl +PrintText_NoCreatingTextBox:: + bccoord 1, 14 + jp TextCommandProcessor diff --git a/home/yes_no.asm b/home/yes_no.asm index 61aa1390..aae27f86 100644 --- a/home/yes_no.asm +++ b/home/yes_no.asm @@ -14,7 +14,7 @@ Func_35f4:: InitYesNoTextBoxParameters:: xor a ; YES_NO_MENU ld [wTwoOptionMenuID], a - coord hl, 14, 7 + hlcoord 14, 7 ld bc, $80f ret @@ -22,7 +22,7 @@ YesNoChoicePokeCenter:: call SaveScreenTilesToBuffer1 ld a, HEAL_CANCEL_MENU ld [wTwoOptionMenuID], a - coord hl, 11, 6 + hlcoord 11, 6 lb bc, 8, 12 jr DisplayYesNoChoice @@ -30,7 +30,7 @@ WideYesNoChoice:: ; unused call SaveScreenTilesToBuffer1 ld a, WIDE_YES_NO_MENU ld [wTwoOptionMenuID], a - coord hl, 12, 7 + hlcoord 12, 7 lb bc, 8, 13 DisplayYesNoChoice:: @@ -1,370 +1,404 @@ -hDMARoutine EQU $FF80 +SECTION "HRAM", HRAM + +hDMARoutine:: ds 10 -hSoftReset EQU $FF8A ; Initialized to 16. ; Decremented each input iteration if the player ; presses the reset sequence (A+B+SEL+START). ; Soft reset when 0 is reached. +hSoftReset:: db -; base tile ID to which offsets are added -hBaseTileID EQU $FF8B - -; 3-byte BCD number -hItemPrice EQU $FF8B - -hDexWeight EQU $FF8B - -hWarpDestinationMap EQU $FF8B - -hOAMTile EQU $FF8B - -hROMBankTemp EQU $FF8B - -hPreviousTileset EQU $FF8B - -hEastWestConnectedMapWidth EQU $FF8B - -hSlideAmount EQU $FF8B +UNION +hBaseTileID:: ; base tile ID to which offsets are added +hDexWeight:: +hWarpDestinationMap:: +hOAMTile:: +hROMBankTemp:: +hPreviousTileset:: +hRLEByteValue:: + db -hRLEByteValue EQU $FF8B +hSpriteIndexOrTextID:: ; DisplayTextID's argument +hPartyMonIndex:: + db -hSpriteWidth EQU $FF8B ; in tiles -hSpriteInterlaceCounter EQU $FF8B -hSpriteHeight EQU $FF8C ; in tiles -hSpriteOffset EQU $FF8D +hVRAMSlot:: + db -; counters for blinking down arrow -hDownArrowBlinkCount1 EQU $FF8B -hDownArrowBlinkCount2 EQU $FF8C - -hSpriteDataOffset EQU $FF8B -hSpriteIndex EQU $FF8C - -hMapStride EQU $FF8B -hMapWidth EQU $FF8C +hFourTileSpriteCount:: +hHalveItemPrices:: + db -hNorthSouthConnectionStripWidth EQU $FF8B -hNorthSouthConnectedMapWidth EQU $FF8C +NEXTU +hItemPrice:: ds 3 ; BCD number -; DisplayTextID's argument -hSpriteIndexOrTextID EQU $FF8C - -hPartyMonIndex EQU $FF8C +NEXTU +hSlideAmount:: db ; the total number of tiles being shifted each time the pic slides by one tile -hSlidingRegionSize EQU $FF8C - -; 2 bytes -hEnemySpeed EQU $FF8D - -hVRAMSlot EQU $FF8D - -hFourTileSpriteCount EQU $FF8E +hSlidingRegionSize:: db ; -1 = left ; 0 = right -hSlideDirection EQU $FF8D - -hSpriteFacingDirection EQU $FF8D - -hSpriteMovementByte2 EQU $FF8D - -hSpriteImageIndex EQU $FF8D - -hLoadSpriteTemp1 EQU $FF8D -hLoadSpriteTemp2 EQU $FF8E - -hHalveItemPrices EQU $FF8E - -hSpriteOffset2 EQU $FF8F - -hOAMBufferOffset EQU $FF90 - -hSpriteScreenX EQU $FF91 -hSpriteScreenY EQU $FF92 - -hFF8F EQU $FF8F -hFF90 EQU $FF90 -hFF91 EQU $FF91 -hFF92 EQU $FF92 - -hTilePlayerStandingOn EQU $FF93 - -hSpritePriority EQU $FF94 - -; 2 bytes -hSignCoordPointer EQU $FF95 - -hNPCMovementDirections2Index EQU $FF95 - -hSwapItemID EQU $FF95 -hSwapItemQuantity EQU $FF96 - -; CalcPositionOfPlayerRelativeToNPC -hNPCSpriteOffset EQU $FF95 - -; temp value used when swapping bytes or words -hSwapTemp EQU $FF95 - -hExperience EQU $FF96 ; 3 bytes, big endian - -hMutateWY EQU $FF96 -hMutateWX EQU $FF97 - -; Multiplication and division variables are meant -; to overlap for back-to-back usage. Big endian. +hSlideDirection:: db -hMultiplicand EQU $FF96 ; 3 bytes -hMultiplier EQU $FF99 ; 1 byte -hProduct EQU $FF95 ; 4 bytes - -hDividend EQU $FF95 ; 4 bytes -hDivisor EQU $FF99 ; 1 byte -hQuotient EQU $FF95 ; 4 bytes -hRemainder EQU $FF99 ; 1 byte - -hDivideBuffer EQU $FF9A - -hMultiplyBuffer EQU $FF9B +NEXTU +hSpriteInterlaceCounter:: +hSpriteWidth:: db ; in tiles +hSpriteHeight:: db ; in tiles +hSpriteOffset:: db +NEXTU +; counters for blinking down arrow +hDownArrowBlinkCount1:: db +hDownArrowBlinkCount2:: db + +NEXTU +hMapStride:: +hEastWestConnectedMapWidth:: +hNorthSouthConnectionStripWidth:: + db +hMapWidth:: +hNorthSouthConnectedMapWidth:: + db + +NEXTU +hSpriteDataOffset:: db +hSpriteIndex:: db +hSpriteImageIndex:: +hSpriteFacingDirection:: +hSpriteMovementByte2:: + db + +NEXTU + ds 2 +hLoadSpriteTemp1:: db +hLoadSpriteTemp2:: db + +NEXTU + ds 2 +hEnemySpeed:: dw +ENDU + +UNION +hSpriteOffset2:: db +hOAMBufferOffset:: db +hSpriteScreenX:: db +hSpriteScreenY:: db + +NEXTU +hFF8F:: db +hFF90:: db +hFF91:: db +hFF92:: db +ENDU + +hTilePlayerStandingOn:: db + +hSpritePriority:: db + +UNION +;; Multiplication and division variables are meant +;; to overlap for back-to-back usage. Big endian. +UNION + ds 1 +hMultiplicand:: ds 3 +hMultiplier:: db + ds 1 +hMultiplyBuffer:: ds 4 +NEXTU +hProduct:: ds 4 +NEXTU +hDividend:: ds 4 +hDivisor:: db +hDivideBuffer:: ds 5 +NEXTU +hQuotient:: ds 4 +hRemainder:: db +ENDU + +NEXTU ; PrintNumber (big endian). -hPastLeadingZeros EQU $FF95 ; last char printed -hNumToPrint EQU $FF96 ; 3 bytes -hPowerOf10 EQU $FF99 ; 3 bytes -hSavedNumToPrint EQU $FF9C ; 3 bytes - +hPastLeadingZeros:: db ; last char printed +hNumToPrint:: ds 3 +hPowerOf10:: ds 3 +hSavedNumToPrint:: ds 3 + +NEXTU +hNPCMovementDirections2Index:: +hNPCSpriteOffset:: ; distance in steps between NPC and player -hNPCPlayerYDistance EQU $FF95 -hNPCPlayerXDistance EQU $FF96 - -hFindPathNumSteps EQU $FF97 - +hNPCPlayerYDistance:: + db +hNPCPlayerXDistance:: + db +hFindPathNumSteps:: db ; bit 0: set when the end of the path's Y coordinate matches the target's ; bit 1: set when the end of the path's X coordinate matches the target's ; When both bits are set, the end of the path is at the target's position ; (i.e. the path has been found). -hFindPathFlags EQU $FF98 - -hFindPathYProgress EQU $FF99 -hFindPathXProgress EQU $FF9A - +hFindPathFlags:: db +hFindPathYProgress:: db +hFindPathXProgress:: db ; 0 = from player to NPC ; 1 = from NPC to player -hNPCPlayerRelativePosPerspective EQU $FF9B - +hNPCPlayerRelativePosPerspective:: db + ds 1 ; bit 0: ; 0 = target is to the south or aligned ; 1 = target is to the north ; bit 1: ; 0 = target is to the east or aligned ; 1 = target is to the west -hNPCPlayerRelativePosFlags EQU $FF9D - -; some code zeroes this for no reason when writing a coin amount -hUnusedCoinsByte EQU $FF9F - -hMoney EQU $FF9F ; 3-byte BCD number -hCoins EQU $FFA0 ; 2-byte BCD number - -hDivideBCDDivisor EQU $FFA2 ; 3-byte BCD number -hDivideBCDQuotient EQU $FFA2 ; 3-byte BCD number -hDivideBCDBuffer EQU $FFA5 ; 3-byte BCD number +hNPCPlayerRelativePosFlags:: db -hSerialReceivedNewData EQU $FFA9 - -; $01 = using external clock -; $02 = using internal clock -; $ff = establishing connection -hSerialConnectionStatus EQU $FFAA +NEXTU +hSwapItemID:: db +hSwapItemQuantity:: db -hSerialIgnoringInitialData EQU $FFAB +NEXTU +hSignCoordPointer:: dw -hSerialSendData EQU $FFAC +NEXTU + ds 1 +hMutateWY:: db +hMutateWX:: db -hSerialReceiveData EQU $FFAD +NEXTU +; temp value used when swapping bytes or words +hSwapTemp:: db +hExperience:: ds 3 ; big endian +ENDU -; these values are copied to SCX, SCY, and WY during V-blank -hSCX EQU $FFAE -hSCY EQU $FFAF -hWY EQU $FFB0 +UNION +hMoney:: ds 3 ; BCD number +NEXTU +; some code zeroes this for no reason when writing a coin amount +hUnusedCoinsByte:: db +hCoins:: ds 2 ; BCD number +ENDU -hJoyLast EQU $FFB1 -hJoyReleased EQU $FFB2 -hJoyPressed EQU $FFB3 -hJoyHeld EQU $FFB4 -hJoy5 EQU $FFB5 -hJoy6 EQU $FFB6 -hJoy7 EQU $FFB7 +hDivideBCDDivisor:: +hDivideBCDQuotient:: + ds 3 ; BCD number +hDivideBCDBuffer:: + ds 3 ; BCD number -hLoadedROMBank EQU $FFB8 + ds 1 -hSavedROMBank EQU $FFB9 +hSerialReceivedNewData:: db +; $01 = using external clock +; $02 = using internal clock +; $ff = establishing connection +hSerialConnectionStatus:: db +hSerialIgnoringInitialData:: db +hSerialSendData:: db +hSerialReceiveData:: db + +; these values are copied to rSCX, rSCY, and rWY during V-blank +hSCX:: db +hSCY:: db +hWY:: db + +hJoyLast:: db +hJoyReleased:: db +hJoyPressed:: db +hJoyHeld:: db +hJoy5:: db +hJoy6:: db +hJoy7:: db + +hLoadedROMBank:: db +hSavedROMBank:: db ; is automatic background transfer during V-blank enabled? ; if nonzero, yes ; if zero, no -hAutoBGTransferEnabled EQU $FFBA - -TRANSFERTOP EQU 0 -TRANSFERMIDDLE EQU 1 -TRANSFERBOTTOM EQU 2 +hAutoBGTransferEnabled:: db ; 00 = top third of background ; 01 = middle third of background ; 02 = bottom third of background -hAutoBGTransferPortion EQU $FFBB +hAutoBGTransferPortion:: db ; the destination address of the automatic background transfer -hAutoBGTransferDest EQU $FFBC ; 2 bytes +hAutoBGTransferDest:: dw -hRedrawMapViewRowOffset EQU $FFBE +hRedrawMapViewRowOffset:: db ; temporary storage for stack pointer during memory transfers that use pop ; to increase speed -hSPTemp EQU $FFBF ; 2 bytes +hSPTemp:: dw ; source address for VBlankCopyBgMap function ; the first byte doubles as the byte that enabled the transfer. ; if it is 0, the transfer is disabled ; if it is not 0, the transfer is enabled ; this means that XX00 is not a valid source address -hVBlankCopyBGSource EQU $FFC1 ; 2 bytes +hVBlankCopyBGSource:: dw ; destination address for VBlankCopyBgMap function -hVBlankCopyBGDest EQU $FFC3 ; 2 bytes +hVBlankCopyBGDest:: dw ; number of rows for VBlankCopyBgMap to copy -hVBlankCopyBGNumRows EQU $FFC5 +hVBlankCopyBGNumRows:: db ; size of VBlankCopy transfer in 16-byte units -hVBlankCopySize EQU $FFC6 +hVBlankCopySize:: db ; source address for VBlankCopy function -hVBlankCopySource EQU $FFC7 +hVBlankCopySource:: dw ; destination address for VBlankCopy function -hVBlankCopyDest EQU $FFC9 +hVBlankCopyDest:: dw ; size of source data for VBlankCopyDouble in 8-byte units -hVBlankCopyDoubleSize EQU $FFCB +hVBlankCopyDoubleSize:: db ; source address for VBlankCopyDouble function -hVBlankCopyDoubleSource EQU $FFCC +hVBlankCopyDoubleSource:: dw ; destination address for VBlankCopyDouble function -hVBlankCopyDoubleDest EQU $FFCE +hVBlankCopyDoubleDest:: dw ; controls whether a row or column of 2x2 tile blocks is redrawn in V-blank ; 00 = no redraw ; 01 = redraw column ; 02 = redraw row -hRedrawRowOrColumnMode EQU $FFD0 - -REDRAW_COL EQU 1 -REDRAW_ROW EQU 2 +hRedrawRowOrColumnMode:: db -hRedrawRowOrColumnDest EQU $FFD1 +hRedrawRowOrColumnDest:: dw -hRandomAdd EQU $FFD3 -hRandomSub EQU $FFD4 +hRandomAdd:: db +hRandomSub:: db -hFrameCounter EQU $FFD5 ; decremented every V-blank (used for delays) +hFrameCounter:: db ; decremented every V-blank (used for delays) ; V-blank sets this to 0 each time it runs. ; So, by setting it to a nonzero value and waiting for it to become 0 again, ; you can detect that the V-blank handler has run since then. -hVBlankOccurred EQU $FFD6 +hVBlankOccurred:: db ; 00 = indoor ; 01 = cave ; 02 = outdoor ; this is often set to 00 in order to turn off water and flower BG tile animations -hTilesetType EQU $FFD7 +hTilesetType:: db -hMovingBGTilesCounter1 EQU $FFD8 +hMovingBGTilesCounter1:: db -hCurrentSpriteOffset EQU $FFDA ; multiple of $10 + ds 1 -hItemCounter EQU $FFDB +hCurrentSpriteOffset:: db ; multiple of $10 -hGymGateIndex EQU $FFDB -hGymGateAnswer EQU $FFDC +UNION +hPlayerFacing:: db +hPlayerYCoord:: db +hPlayerXCoord:: db -hGymTrashCanRandNumMask EQU $FFDB - -hDexRatingNumMonsSeen EQU $FFDB -hDexRatingNumMonsOwned EQU $FFDC +NEXTU ; $00 = bag full ; $01 = got item ; $80 = didn't meet required number of owned mons ; $FF = player cancelled -hOaksAideResult EQU $FFDB - -hSavedCoordIndex EQU $FFDB +hOaksAideResult:: +hOaksAideRequirement:: ; required number of owned mons + db +hOaksAideRewardItem:: db +hOaksAideNumMonsOwned:: db + +NEXTU +hVendingMachineItem:: db +hVendingMachinePrice:: ds 3 ; BCD number + +NEXTU +hGymGateIndex:: db +hGymGateAnswer:: db + +NEXTU +hDexRatingNumMonsSeen:: db +hDexRatingNumMonsOwned:: db + +NEXTU +hItemToRemoveID:: db +hItemToRemoveIndex:: db + +NEXTU +hItemCounter:: +hSavedCoordIndex:: +hMissableObjectIndex:: +hGymTrashCanRandNumMask:: + db + +NEXTU +hFFDB:: db +hFFDC:: db +ENDU + + ds 1 + +hBackupGymGateIndex:: +hUnlockedSilphCoDoors:: + db -hOaksAideRequirement EQU $FFDB ; required number of owned mons -hOaksAideRewardItem EQU $FFDC -hOaksAideNumMonsOwned EQU $FFDD - -hPlayerFacing EQU $FFDB -hPlayerYCoord EQU $FFDC -hPlayerXCoord EQU $FFDD - -hMissableObjectIndex EQU $FFDB - -hItemToRemoveID EQU $FFDB -hItemToRemoveIndex EQU $FFDC - -hVendingMachineItem EQU $FFDB -hVendingMachinePrice EQU $FFDC ; 3-byte BCD number - -hFFDB EQU $FFDB -hFFDC EQU $FFDC - -hBackupGymGateIndex EQU $FFE0 +; the first tile ID in a sequence of tile IDs that increase by 1 each step +hStartTileID:: db -hUnlockedSilphCoDoors EQU $FFE0 + ds 2 -; the first tile ID in a sequence of tile IDs that increase by 1 each step -hStartTileID EQU $FFE1 +hNewPartyLength:: db -hNewPartyLength EQU $FFE4 +UNION +hDividend2:: db +hDivisor2:: db +hQuotient2:: db -hIsHiddenMissableObject EQU $FFE5 +NEXTU +hIsHiddenMissableObject:: db +ENDU -hDividend2 EQU $FFE5 -hDivisor2 EQU $FFE6 -hQuotient2 EQU $FFE7 +hMapROMBank:: db -hMapROMBank EQU $FFE8 +hSpriteVRAMSlotAndFacing:: db -hSpriteVRAMSlotAndFacing EQU $FFE9 +hCoordsInFrontOfPlayerMatch:: +hSpriteAnimFrameCounter:: + db -hCoordsInFrontOfPlayerMatch EQU $FFEA +UNION +hSpriteScreenYCoord:: db +hSpriteScreenXCoord:: db +hSpriteMapYCoord:: db +hSpriteMapXCoord:: db -hSpriteAnimFrameCounter EQU $FFEA +NEXTU +hItemAlreadyFound:: db + ds 2 +hDidntFindAnyHiddenObject:: db -hSpriteScreenYCoord EQU $FFEB -hSpriteScreenXCoord EQU $FFEC -hSpriteMapYCoord EQU $FFED -hSpriteMapXCoord EQU $FFEE +NEXTU + ds 1 +hSavedMapTextPtr:: dw + ds 1 +ENDU -hItemAlreadyFound EQU $FFEB -hDidntFindAnyHiddenObject EQU $FFEE + ds 4 -hSavedMapTextPtr EQU $FFEC +hWhoseTurn:: db ; 0 on player's turn, 1 on enemy's turn -hWhoseTurn EQU $FFF3 ; 0 on player’s turn, 1 on enemy’s turn +hClearLetterPrintingDelayFlags:: db -hClearLetterPrintingDelayFlags EQU $FFF4 + ds 1 ; bit 0: draw HP fraction to the right of bar instead of below (for party menu) ; bit 1: menu is double spaced -hFlagsFFF6 EQU $FFF6 +hFlagsFFF6:: db + +hFieldMoveMonMenuTopMenuItemX:: db -hFieldMoveMonMenuTopMenuItemX EQU $FFF7 +hJoyInput:: db -hDisableJoypadPolling EQU $FFF9 +hDisableJoypadPolling:: db -hJoyInput EQU $FFF8 + ds 5 diff --git a/layout.link b/layout.link index d4473435..5ea3558f 100644 --- a/layout.link +++ b/layout.link @@ -33,41 +33,33 @@ ROM0 "Header" org $150 "Home" - ROMX $1 "bank1" - ROMX $2 "Sound Effect Headers 1" "Music Headers 1" "Sound Effects 1" "Audio Engine 1" "Music 1" - ROMX $3 "bank3" - ROMX $4 "NPC Sprites 1" - "Graphics (BANK 4)" - "Battle (BANK 4)" - + "Font Graphics" + "Battle Engine 1" ROMX $5 "NPC Sprites 2" - "Battle (BANK 5)" - + "Battle Engine 2" ROMX $6 "Maps 1" - "bank6_1" + "Play Time" "Maps 2" - "bank6_2" - + "Doors and Ledges" ROMX $7 "Maps 3" - "bank7_1" + "Pokémon Names" "Maps 4" - "bank7_2" - + "Hidden Objects 1" ROMX $8 "Sound Effect Headers 2" "Music Headers 2" @@ -76,166 +68,131 @@ ROMX $8 "Bill's PC" "Audio Engine 2" "Music 2" - ROMX $9 "Pics 1" - "Battle (BANK 9)" - + "Battle Engine 3" ROMX $A "Pics 2" - "Battle (BANK A)" - + "Battle Engine 4" ROMX $B "Pics 3" - "Battle (BANK B)" - + "Battle Engine 5" ROMX $C "Pics 4" - "Battle (BANK C)" - + "Battle Engine 6" ROMX $D "Pics 5" - "Battle (BANK D)" - + "Slot Machines" ROMX $E - "bankE" - + "Battle Engine 7" ROMX $F - "bankF" - + "Battle Core" ROMX $10 "bank10" - ROMX $11 "Maps 5" - "bank11_1" + "Pokédex Rating" "Maps 6" - "bank11_2" - + "Hidden Objects Core" ROMX $12 "Maps 7" - "bank12" + "Screen Effects" "Maps 8" - ROMX $13 "Pics 6" "Maps 9" - "bank13" - + "Predefs" ROMX $14 "Maps 10" - "bank14" - + "Battle Engine 8" + "Hidden Objects 2" ROMX $15 "Maps 11" - "bank15_1" + "Battle Engine 9" "Maps 12" - "bank15_2" - + "Diploma" + "Trainer Sight" ROMX $16 "Maps 13" - "bank16_1" + "Battle Engine 10" "Maps 14" - "bank16_2" - + "Saffron Guards" ROMX $17 "Maps 15" - "bank17_1" + "Starter Dex" "Maps 16" - "bank17_2" - + "Hidden Objects 3" ROMX $18 "Maps 17" - "bank18_1" + "Cinnabar Lab Fossils" "Maps 18" - "bank18_2" - + "Hidden Objects 4" ROMX $19 "Tilesets 1" - ROMX $1A - "bank1A" + "Battle Engine 11" "Tilesets 2" - ROMX $1B "Tilesets 3" - ROMX $1C "bank1C" - ROMX $1D "Maps 19" - "bank1D_1" + "Itemfinder 1" "Maps 20" - "bank1D_2" + "Vending Machine" "Maps 21" - "bank1D_3" - + "Itemfinder 2" ROMX $1E "bank1E" - ROMX $1F "Sound Effect Headers 3" "Music Headers 3" "Sound Effects 3" "Audio Engine 3" "Music 3" - ROMX $20 "Text 1" - ROMX $21 "Text 2" - ROMX $22 "Text 3" - ROMX $23 "Text 4" - ROMX $24 "Text 5" - ROMX $25 "Text 6" - ROMX $26 "Text 7" - ROMX $27 "Text 8" - ROMX $28 "Text 9" - ROMX $29 "Text 10" - ROMX $2A "Text 11" - ROMX $2B - "Pokedex Text" - + "Pokédex Text" ROMX $2C "Move Names" - WRAM0 - "WRAM Bank 0" + "WRAM" org $c100 "Sprite State Data" "OAM Buffer" org $dfff "Stack" - +VRAM + "VRAM" SRAM $0 "Sprite Buffers" - SRAM $1 "Save Data" - SRAM $2 "Saved Boxes 1" - SRAM $3 "Saved Boxes 2" +HRAM + "HRAM" diff --git a/macros/coords.asm b/macros/coords.asm index 302260d7..94808ba5 100644 --- a/macros/coords.asm +++ b/macros/coords.asm @@ -1,65 +1,79 @@ -validateCoords: MACRO - IF \1 >= SCREEN_WIDTH - fail "x coord out of range" - ENDC - IF \2 >= SCREEN_HEIGHT - fail "y coord out of range" +validate_coords: MACRO + IF _NARG >= 4 + IF \1 >= \3 + fail "x coord out of range" + ENDC + IF \2 >= \4 + fail "y coord out of range" + ENDC + ELSE + validate_coords \1, \2, SCREEN_WIDTH, SCREEN_HEIGHT ENDC ENDM -;\1 = r -;\2 = X -;\3 = Y -;\4 = which tilemap (optional) +hlcoord EQUS "coord hl," +bccoord EQUS "coord bc," +decoord EQUS "coord de," + coord: MACRO - validateCoords \2, \3 +; register, x, y[, origin] + validate_coords \2, \3 IF _NARG >= 4 - ld \1, \4 + SCREEN_WIDTH * \3 + \2 + ld \1, (\3) * SCREEN_WIDTH + (\2) + \4 ELSE - ld \1, wTileMap + SCREEN_WIDTH * \3 + \2 + ld \1, (\3) * SCREEN_WIDTH + (\2) + wTileMap ENDC ENDM -;\1 = X -;\2 = Y -;\3 = which tilemap (optional) -aCoord: MACRO - validateCoords \1, \2 - IF _NARG >= 3 - ld a, [\3 + SCREEN_WIDTH * \2 + \1] +hlbgcoord EQUS "bgcoord hl," +bcbgcoord EQUS "bgcoord bc," +debgcoord EQUS "bgcoord de," + +bgcoord: MACRO +; register, x, y[, origin] + validate_coords \2, \3, BG_MAP_WIDTH, BG_MAP_HEIGHT + IF _NARG >= 4 + ld \1, (\3) * BG_MAP_WIDTH + (\2) + \4 ELSE - ld a, [wTileMap + SCREEN_WIDTH * \2 + \1] + ld \1, (\3) * BG_MAP_WIDTH + (\2) + vBGMap0 ENDC ENDM -;\1 = X -;\2 = Y -;\3 = which tilemap (optional) -Coorda: MACRO - validateCoords \1, \2 +hlowcoord EQUS "owcoord hl," +bcowcoord EQUS "owcoord bc," +deowcoord EQUS "owcoord de," + +owcoord: MACRO +; register, x, y, map width + ld \1, wOverworldMap + ((\2) + 3) + (((\3) + 3) * ((\4) + (3 * 2))) +ENDM + +dwcoord: MACRO +; x, y + validate_coords \1, \2 IF _NARG >= 3 - ld [\3 + SCREEN_WIDTH * \2 + \1], a + dw (\2) * SCREEN_WIDTH + (\1) + \3 ELSE - ld [wTileMap + SCREEN_WIDTH * \2 + \1], a + dw (\2) * SCREEN_WIDTH + (\1) + wTileMap ENDC ENDM -;\1 = X -;\2 = Y -;\3 = which tilemap (optional) -dwCoord: MACRO - validateCoords \1, \2 +ldcoord_a: MACRO +; x, y[, origin] + validate_coords \1, \2 IF _NARG >= 3 - dw \3 + SCREEN_WIDTH * \2 + \1 + ld [(\2) * SCREEN_WIDTH + (\1) + \3], a ELSE - dw wTileMap + SCREEN_WIDTH * \2 + \1 + ld [(\2) * SCREEN_WIDTH + (\1) + wTileMap], a ENDC ENDM -;\1 = r -;\2 = X -;\3 = Y -;\4 = map width -overworldMapCoord: MACRO - ld \1, wOverworldMap + ((\2) + 3) + (((\3) + 3) * ((\4) + (3 * 2))) +lda_coord: MACRO +; x, y[, origin] + validate_coords \1, \2 + IF _NARG >= 3 + ld a, [(\2) * SCREEN_WIDTH + (\1) + \3] + ELSE + ld a, [(\2) * SCREEN_WIDTH + (\1) + wTileMap] + ENDC ENDM diff --git a/macros/data.asm b/macros/data.asm index 7a813529..16742d53 100755 --- a/macros/data.asm +++ b/macros/data.asm @@ -33,7 +33,7 @@ _tms3 = _tms3 | (1 << ((\1_TMNUM) - 1 - 48)) else fail "\1 is not a TM or HM move" ENDC - shift + SHIFT ENDR REPT 3 ; TM01-TM24 (24/24) db _tms1 & $ff diff --git a/macros/farcall.asm b/macros/farcall.asm index 885f8c66..122e5207 100644 --- a/macros/farcall.asm +++ b/macros/farcall.asm @@ -1,37 +1,35 @@ -farcall EQUS "callba" - -callba: MACRO +farcall: MACRO ld b, BANK(\1) ld hl, \1 call Bankswitch ENDM -callab: MACRO +callfar: MACRO ld hl, \1 ld b, BANK(\1) call Bankswitch ENDM -jpba: MACRO +farjp: MACRO ld b, BANK(\1) ld hl, \1 jp Bankswitch ENDM -jpab: MACRO +jpfar: MACRO ld hl, \1 ld b, BANK(\1) jp Bankswitch ENDM homecall: MACRO - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] push af ld a, BANK(\1) - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a call \1 pop af - ld [hLoadedROMBank], a + ldh [hLoadedROMBank], a ld [MBC1RomBank], a ENDM diff --git a/macros/gfx.asm b/macros/gfx.asm index 950daee1..8803dad2 100644 --- a/macros/gfx.asm +++ b/macros/gfx.asm @@ -1,7 +1,7 @@ RGB: MACRO REPT _NARG / 3 dw palred (\1) + palgreen (\2) + palblue (\3) - shift 3 + SHIFT 3 ENDR ENDM diff --git a/macros/scripts/audio.asm b/macros/scripts/audio.asm index 8a250c63..4f4d084c 100755 --- a/macros/scripts/audio.asm +++ b/macros/scripts/audio.asm @@ -141,8 +141,7 @@ ENDM ; stored in big endian tempo: MACRO db $ED - db \1 / $100 - db \1 % $100 + db HIGH(\1), LOW(\1) ENDM ; arguments: left output enable mask, right output enable mask diff --git a/macros/scripts/events.asm b/macros/scripts/events.asm index 9e84ec62..8087c5c2 100755 --- a/macros/scripts/events.asm +++ b/macros/scripts/events.asm @@ -185,7 +185,7 @@ SetEvents: MACRO SetEvent \1 REPT _NARG - 1 SetEventReuseHL \2 - shift + SHIFT ENDR ENDM @@ -237,7 +237,7 @@ ResetEvents: MACRO ResetEvent \1 REPT _NARG - 1 ResetEventReuseHL \2 - shift + SHIFT ENDR ENDM diff --git a/macros/scripts/text.asm b/macros/scripts/text.asm index efecdd1c..261ab5f4 100755 --- a/macros/scripts/text.asm +++ b/macros/scripts/text.asm @@ -200,7 +200,7 @@ script_mart: MACRO db _NARG ; number of items REPT _NARG db \1 ; item id - shift + SHIFT ENDR db -1 ; end ENDM diff --git a/macros/wram.asm b/macros/wram.asm index 62464543..41fd1dad 100644 --- a/macros/wram.asm +++ b/macros/wram.asm @@ -71,7 +71,8 @@ spritestatedata1: MACRO \1IntraAnimFrameCounter:: db \1AnimFrameCounter:: db \1FacingDirection:: db - ds 2 +\1YAdjusted:: db +\1XAdjusted:: db \1CollisionData:: db ds 3 \1End:: @@ -87,7 +88,8 @@ spritestatedata2: MACRO \1MovementByte1:: db \1GrassPriority:: db \1MovementDelay:: db - ds 4 +\1OrigFacingDirection:: db + ds 3 \1PictureID:: db \1ImageBaseOffset:: db ds 1 @@ -78,12 +78,12 @@ INCLUDE "engine/events/hidden_objects/town_map.asm" INCLUDE "engine/events/hidden_objects/pokemon_stuff.asm" -SECTION "Graphics (BANK 4)", ROMX +SECTION "Font Graphics", ROMX INCLUDE "gfx/font.asm" -SECTION "Battle (BANK 4)", ROMX +SECTION "Battle Engine 1", ROMX INCLUDE "engine/overworld/is_player_just_outside_map.asm" INCLUDE "engine/pokemon/status_screen.asm" @@ -101,7 +101,7 @@ INCLUDE "engine/battle/get_trainer_name.asm" INCLUDE "engine/math/random.asm" -SECTION "Battle (BANK 5)", ROMX +SECTION "Battle Engine 2", ROMX INCLUDE "engine/gfx/load_pokedex_tiles.asm" INCLUDE "engine/overworld/map_sprites.asm" @@ -111,26 +111,26 @@ INCLUDE "engine/battle/move_effects/substitute.asm" INCLUDE "engine/menus/pc.asm" -SECTION "bank6_1", ROMX +SECTION "Play Time", ROMX INCLUDE "engine/play_time.asm" -SECTION "bank6_2", ROMX +SECTION "Doors and Ledges", ROMX INCLUDE "engine/overworld/auto_movement.asm" INCLUDE "engine/overworld/doors.asm" INCLUDE "engine/overworld/ledges.asm" -SECTION "bank7_1", ROMX +SECTION "Pokémon Names", ROMX INCLUDE "data/pokemon/names.asm" INCLUDE "engine/movie/oak_speech/clear_save.asm" INCLUDE "engine/events/elevator.asm" -SECTION "bank7_2", ROMX +SECTION "Hidden Objects 1", ROMX INCLUDE "engine/menus/oaks_pc.asm" INCLUDE "engine/events/hidden_objects/new_bike.asm" @@ -147,19 +147,19 @@ SECTION "Bill's PC", ROMX INCLUDE "engine/pokemon/bills_pc.asm" -SECTION "Battle (BANK 9)", ROMX +SECTION "Battle Engine 3", ROMX INCLUDE "engine/battle/print_type.asm" INCLUDE "engine/battle/save_trainer_name.asm" INCLUDE "engine/battle/move_effects/focus_energy.asm" -SECTION "Battle (BANK A)", ROMX +SECTION "Battle Engine 4", ROMX INCLUDE "engine/battle/move_effects/leech_seed.asm" -SECTION "Battle (BANK B)", ROMX +SECTION "Battle Engine 5", ROMX INCLUDE "engine/battle/display_effectiveness.asm" INCLUDE "gfx/trainer_card.asm" @@ -169,13 +169,13 @@ INCLUDE "engine/battle/move_effects/pay_day.asm" INCLUDE "engine/slots/game_corner_slots2.asm" -SECTION "Battle (BANK C)", ROMX +SECTION "Battle Engine 6", ROMX INCLUDE "engine/battle/move_effects/mist.asm" INCLUDE "engine/battle/move_effects/one_hit_ko.asm" -SECTION "Battle (BANK D)", ROMX +SECTION "Slot Machines", ROMX INCLUDE "engine/movie/title2.asm" INCLUDE "engine/battle/link_battle_versus_text.asm" @@ -185,7 +185,7 @@ INCLUDE "engine/math/multiply_divide.asm" INCLUDE "engine/slots/game_corner_slots.asm" -SECTION "bankE", ROMX +SECTION "Battle Engine 7", ROMX INCLUDE "data/moves/moves.asm" INCLUDE "data/pokemon/base_stats.asm" @@ -201,7 +201,7 @@ INCLUDE "engine/battle/move_effects/transform.asm" INCLUDE "engine/battle/move_effects/reflect_light_screen.asm" -SECTION "bankF", ROMX +SECTION "Battle Core", ROMX INCLUDE "engine/battle/core.asm" INCLUDE "engine/battle/effects.asm" @@ -215,31 +215,35 @@ INCLUDE "engine/movie/intro.asm" INCLUDE "engine/movie/trade2.asm" -SECTION "bank11_1", ROMX +SECTION "Pokédex Rating", ROMX INCLUDE "engine/events/pokedex_rating.asm" -SECTION "bank11_2", ROMX +SECTION "Hidden Objects Core", ROMX INCLUDE "engine/overworld/hidden_objects.asm" -SECTION "bank12", ROMX +SECTION "Screen Effects", ROMX INCLUDE "engine/gfx/screen_effects.asm" -SECTION "bank13", ROMX +SECTION "Predefs", ROMX INCLUDE "engine/events/give_pokemon.asm" INCLUDE "engine/predefs.asm" -SECTION "bank14", ROMX +SECTION "Battle Engine 8", ROMX INCLUDE "engine/battle/init_battle_variables.asm" INCLUDE "engine/battle/move_effects/paralyze.asm" + + +SECTION "Hidden Objects 2", ROMX + INCLUDE "engine/events/card_key.asm" INCLUDE "engine/events/prize_menu.asm" INCLUDE "engine/events/hidden_objects/school_notebooks.asm" @@ -247,35 +251,39 @@ INCLUDE "engine/events/hidden_objects/fighting_dojo.asm" INCLUDE "engine/events/hidden_objects/indigo_plateau_hq.asm" -SECTION "bank15_1", ROMX +SECTION "Battle Engine 9", ROMX INCLUDE "engine/battle/experience.asm" -SECTION "bank15_2", ROMX +SECTION "Diploma", ROMX INCLUDE "engine/events/diploma.asm" + + +SECTION "Trainer Sight", ROMX + INCLUDE "engine/overworld/trainer_sight.asm" -SECTION "bank16_1", ROMX +SECTION "Battle Engine 10", ROMX INCLUDE "engine/battle/common_text.asm" INCLUDE "engine/pokemon/experience.asm" INCLUDE "engine/events/oaks_aide.asm" -SECTION "bank16_2", ROMX +SECTION "Saffron Guards", ROMX INCLUDE "engine/events/saffron_guards.asm" -SECTION "bank17_1", ROMX +SECTION "Starter Dex", ROMX INCLUDE "engine/events/starter_dex.asm" -SECTION "bank17_2", ROMX +SECTION "Hidden Objects 3", ROMX INCLUDE "engine/pokemon/set_types.asm" INCLUDE "engine/events/hidden_objects/reds_room.asm" @@ -285,12 +293,12 @@ INCLUDE "engine/events/hidden_objects/school_blackboard.asm" INCLUDE "engine/events/hidden_objects/vermilion_gym_trash.asm" -SECTION "bank18_1", ROMX +SECTION "Cinnabar Lab Fossils", ROMX INCLUDE "engine/events/cinnabar_lab.asm" -SECTION "bank18_2", ROMX +SECTION "Hidden Objects 4", ROMX INCLUDE "engine/events/hidden_objects/gym_statues.asm" INCLUDE "engine/events/hidden_objects/bench_guys.asm" @@ -298,7 +306,7 @@ INCLUDE "engine/events/hidden_objects/blues_room.asm" INCLUDE "engine/events/hidden_objects/pokecenter_pc.asm" -SECTION "bank1A", ROMX +SECTION "Battle Engine 11", ROMX INCLUDE "engine/battle/decrement_pp.asm" INCLUDE "gfx/version.asm" @@ -319,19 +327,19 @@ INCLUDE "engine/gfx/palettes.asm" INCLUDE "engine/menus/save.asm" -SECTION "bank1D_1", ROMX +SECTION "Itemfinder 1", ROMX INCLUDE "engine/movie/credits.asm" INCLUDE "engine/pokemon/status_ailments.asm" INCLUDE "engine/items/itemfinder.asm" -SECTION "bank1D_2", ROMX +SECTION "Vending Machine", ROMX INCLUDE "engine/events/vending_machine.asm" -SECTION "bank1D_3", ROMX +SECTION "Itemfinder 2", ROMX INCLUDE "engine/menus/league_pc.asm" INCLUDE "engine/events/hidden_items.asm" diff --git a/scripts/AgathasRoom.asm b/scripts/AgathasRoom.asm index 6d304de8..b49b2a2b 100755 --- a/scripts/AgathasRoom.asm +++ b/scripts/AgathasRoom.asm @@ -63,8 +63,8 @@ AgathaScript0: call ArePlayerCoordsInArray jp nc, CheckFightingMapTrainers xor a - ld [hJoyPressed], a - ld [hJoyHeld], a + ldh [hJoyPressed], a + ldh [hJoyHeld], a ld [wSimulatedJoypadStatesEnd], a ld [wSimulatedJoypadStatesIndex], a ld a, [wCoordIndex] @@ -74,7 +74,7 @@ AgathaScript0: jr z, AgathaScriptWalkIntoRoom .stopPlayerFromLeaving ld a, $2 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID ; "Don't run away!" ld a, D_UP ld [wSimulatedJoypadStatesEnd], a @@ -110,7 +110,7 @@ AgathaScript2: cp $ff jp z, ResetAgathaScript ld a, $1 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID ld a, $1 ld [wChampionsRoomCurScript], a diff --git a/scripts/BikeShop.asm b/scripts/BikeShop.asm index 07e96c1b..7b290f31 100755 --- a/scripts/BikeShop.asm +++ b/scripts/BikeShop.asm @@ -23,8 +23,8 @@ BikeShopText1: call GiveItem jr nc, .BagFull ld a, BIKE_VOUCHER - ld [hItemToRemoveID], a - callba RemoveItemByID + ldh [hItemToRemoveID], a + farcall RemoveItemByID SetEvent EVENT_GOT_BICYCLE ld hl, BikeShopText_1d824 call PrintText @@ -49,15 +49,15 @@ BikeShopText1: ld [wTopMenuItemX], a ld hl, wd730 set 6, [hl] - coord hl, 0, 0 + hlcoord 0, 0 ld b, $4 ld c, $f call TextBoxBorder call UpdateSprites - coord hl, 2, 2 + hlcoord 2, 2 ld de, BikeShopMenuText call PlaceString - coord hl, 8, 3 + hlcoord 8, 3 ld de, BikeShopMenuPrice call PlaceString ld hl, BikeShopText_1d815 diff --git a/scripts/BillsHouse.asm b/scripts/BillsHouse.asm index 3601c0b6..3edfdf5b 100755 --- a/scripts/BillsHouse.asm +++ b/scripts/BillsHouse.asm @@ -23,7 +23,7 @@ BillsHouseScript1: ld de, MovementData_1e7a0 .notDown ld a, $1 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a call MoveSprite ld a, $2 ld [wBillsHouseCurScript], a @@ -66,13 +66,13 @@ BillsHouseScript3: ld a, $2 ld [wSpriteIndex], a ld a, $c - ld [hSpriteScreenYCoord], a + ldh [hSpriteScreenYCoord], a ld a, $40 - ld [hSpriteScreenXCoord], a + ldh [hSpriteScreenXCoord], a ld a, $6 - ld [hSpriteMapYCoord], a + ldh [hSpriteMapYCoord], a ld a, $5 - ld [hSpriteMapXCoord], a + ldh [hSpriteMapXCoord], a call SetSpritePosition1 ld a, HS_BILL_1 ld [wMissableObjectIndex], a @@ -80,7 +80,7 @@ BillsHouseScript3: ld c, 8 call DelayFrames ld a, $2 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a ld de, MovementData_1e807 call MoveSprite ld a, $4 @@ -109,7 +109,7 @@ BillsHouseScript4: BillsHouseScript5: ld a, $4 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID ld a, $0 ld [wBillsHouseCurScript], a diff --git a/scripts/BrunosRoom.asm b/scripts/BrunosRoom.asm index 85cd86af..d7254c97 100755 --- a/scripts/BrunosRoom.asm +++ b/scripts/BrunosRoom.asm @@ -63,8 +63,8 @@ BrunoScript0: call ArePlayerCoordsInArray jp nc, CheckFightingMapTrainers xor a - ld [hJoyPressed], a - ld [hJoyHeld], a + ldh [hJoyPressed], a + ldh [hJoyHeld], a ld [wSimulatedJoypadStatesEnd], a ld [wSimulatedJoypadStatesIndex], a ld a, [wCoordIndex] @@ -74,7 +74,7 @@ BrunoScript0: jr z, BrunoScriptWalkIntoRoom .stopPlayerFromLeaving ld a, $2 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID ; "Don't run away!" ld a, D_UP ld [wSimulatedJoypadStatesEnd], a @@ -110,7 +110,7 @@ BrunoScript2: cp $ff jp z, ResetBrunoScript ld a, $1 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a jp DisplayTextID BrunosRoom_TextPointers: diff --git a/scripts/CeladonGym.asm b/scripts/CeladonGym.asm index 4af9d146..21ba65d9 100755 --- a/scripts/CeladonGym.asm +++ b/scripts/CeladonGym.asm @@ -44,20 +44,20 @@ CeladonGymScript3: CeladonGymText_48963: ld a, $9 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID SetEvent EVENT_BEAT_ERIKA lb bc, TM_MEGA_DRAIN, 1 call GiveItem jr nc, .BagFull ld a, $a - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID SetEvent EVENT_GOT_TM21 jr .gymVictory .BagFull ld a, $b - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID .gymVictory ld hl, wObtainedBadges @@ -170,7 +170,7 @@ CeladonGymText1: ld hl, CeladonGymText_48a63 ld de, CeladonGymText_48a63 call SaveEndBattleTextPointers - ld a, [hSpriteIndex] + ldh a, [hSpriteIndex] ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters diff --git a/scripts/CeladonMansion3F.asm b/scripts/CeladonMansion3F.asm index c9085b32..b2d40b44 100755 --- a/scripts/CeladonMansion3F.asm +++ b/scripts/CeladonMansion3F.asm @@ -49,7 +49,7 @@ DirectorText: text_far _CompletedDexText text_promptbutton text_asm - callab DisplayDiploma + callfar DisplayDiploma ld a, $1 ld [wDoNotWaitForButtonPressAfterDisplayingText], a jp TextScriptEnd diff --git a/scripts/CeladonMartElevator.asm b/scripts/CeladonMartElevator.asm index bcac0d14..e58c88f0 100755 --- a/scripts/CeladonMartElevator.asm +++ b/scripts/CeladonMartElevator.asm @@ -60,7 +60,7 @@ CeladonMartElevatorWarpMaps: CeladonMartElevatorWarpMapsEnd: CeladonMartElevatorScript_48654: - jpba ShakeElevator + farjp ShakeElevator CeladonMartElevator_TextPointers: dw CeladonMartElevatorText1 diff --git a/scripts/CeladonMartRoof.asm b/scripts/CeladonMartRoof.asm index f38bb984..b1f6a8a3 100755 --- a/scripts/CeladonMartRoof.asm +++ b/scripts/CeladonMartRoof.asm @@ -64,7 +64,7 @@ CeladonMartRoofScript_GiveDrinkToGirl: dec l ld b, l ld c, 12 - coord hl, 0, 0 + hlcoord 0, 0 call TextBoxBorder call UpdateSprites call CeladonMartRoofScript_PrintDrinksInBag @@ -79,7 +79,7 @@ CeladonMartRoofScript_GiveDrinkToGirl: ld e, a add hl, de ld a, [hl] - ld [hItemToRemoveID], a + ldh [hItemToRemoveID], a cp FRESH_WATER jr z, .gaveFreshWater cp SODA_POP @@ -131,7 +131,7 @@ CeladonMartRoofScript_GiveDrinkToGirl: jp PrintText RemoveItemByIDBank12: - jpba RemoveItemByID + farjp RemoveItemByID CeladonMartRoofText_484ee: text_far _CeladonMartRoofText_484ee @@ -186,7 +186,7 @@ CeladonMartRoofText_4852c: CeladonMartRoofScript_PrintDrinksInBag: ld hl, wFilteredBagItems xor a - ld [hItemCounter], a + ldh [hItemCounter], a .loop ld a, [hli] cp $ff @@ -194,8 +194,8 @@ CeladonMartRoofScript_PrintDrinksInBag: push hl ld [wd11e], a call GetItemName - coord hl, 2, 2 - ld a, [hItemCounter] + hlcoord 2, 2 + ldh a, [hItemCounter] ld bc, SCREEN_WIDTH * 2 call AddNTimes ld de, wcd6d diff --git a/scripts/CeruleanCity.asm b/scripts/CeruleanCity.asm index bda53667..070120b7 100755 --- a/scripts/CeruleanCity.asm +++ b/scripts/CeruleanCity.asm @@ -27,7 +27,7 @@ CeruleanCityScript4: ld [wJoyIgnore], a SetEvent EVENT_BEAT_CERULEAN_ROCKET_THIEF ld a, $2 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID xor a ld [wJoyIgnore], a @@ -53,7 +53,7 @@ CeruleanCityScript0: ld [wSprite02StateData1FacingDirection], a call Delay3 ld a, $2 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a jp DisplayTextID .asm_194f7 CheckEvent EVENT_BEAT_CERULEAN_RIVAL @@ -72,16 +72,16 @@ CeruleanCityScript0: ld a, MUSIC_MEET_RIVAL call PlayMusic xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a ld a, $f0 ld [wJoyIgnore], a ld a, [wXCoord] cp $14 jr z, .asm_19535 ld a, $1 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a ld a, $5 - ld [hSpriteDataOffset], a + ldh [hSpriteDataOffset], a call GetPointerWithinSpriteStateData2 ld [hl], $19 .asm_19535 @@ -90,7 +90,7 @@ CeruleanCityScript0: predef ShowObject ld de, CeruleanCityMovement1 ld a, $1 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a call MoveSprite ld a, $1 ld [wCeruleanCityCurScript], a @@ -114,9 +114,9 @@ CeruleanCityMovement1: CeruleanCityScript_1955d: ld a, 1 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a xor a ; SPRITE_FACING_DOWN - ld [hSpriteFacingDirection], a + ldh [hSpriteFacingDirection], a jp SetSpriteFacingDirectionAndDelay ; face object CeruleanCityScript1: @@ -126,7 +126,7 @@ CeruleanCityScript1: xor a ld [wJoyIgnore], a ld a, $1 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID ld hl, wd72d set 6, [hl] @@ -154,7 +154,7 @@ CeruleanCityScript1: ld [wTrainerNo], a xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a call CeruleanCityScript_1955d ld a, $2 ld [wCeruleanCityCurScript], a @@ -169,14 +169,14 @@ CeruleanCityScript2: ld [wJoyIgnore], a SetEvent EVENT_BEAT_CERULEAN_RIVAL ld a, $1 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID ld a, SFX_STOP_ALL_MUSIC ld [wNewSoundID], a call PlaySound - callba Music_RivalAlternateStart + farcall Music_RivalAlternateStart ld a, $1 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a call SetSpriteMovementBytesToFF ld a, [wXCoord] cp $14 @@ -187,7 +187,7 @@ CeruleanCityScript2: ld de, CeruleanCityMovement3 .asm_195f3 ld a, $1 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a call MoveSprite ld a, $3 ld [wCeruleanCityCurScript], a @@ -289,7 +289,7 @@ CeruleanCityText2: ld hl, CeruleanCityText_196ee ld de, CeruleanCityText_196ee call SaveEndBattleTextPointers - ld a, [hSpriteIndexOrTextID] + ldh a, [hSpriteIndexOrTextID] ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters @@ -310,7 +310,7 @@ CeruleanCityText2: ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld hl, ReceivedTM28Text call PrintText - callba CeruleanHideRocket + farcall CeruleanHideRocket .Done jp TextScriptEnd @@ -356,7 +356,7 @@ CeruleanCityText6: CeruleanCityText7: text_asm - ld a, [hRandomAdd] + ldh a, [hRandomAdd] cp 180 jr c, .asm_e9fc9 ld hl, CeruleanCityText_19730 @@ -388,7 +388,7 @@ CeruleanCityText_1973a: CeruleanCityText8: text_asm - ld a, [hRandomAdd] + ldh a, [hRandomAdd] cp 180 jr c, .asm_e28da ld hl, CeruleanCityText_1976f diff --git a/scripts/CeruleanGym.asm b/scripts/CeruleanGym.asm index 14363066..ef3c96f5 100755 --- a/scripts/CeruleanGym.asm +++ b/scripts/CeruleanGym.asm @@ -44,20 +44,20 @@ CeruleanGymScript3: CeruleanGymScript_5c70d: ld a, $5 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID SetEvent EVENT_BEAT_MISTY lb bc, TM_BUBBLEBEAM, 1 call GiveItem jr nc, .BagFull ld a, $6 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID SetEvent EVENT_GOT_TM11 jr .gymVictory .BagFull ld a, $7 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID .gymVictory ld hl, wObtainedBadges @@ -121,14 +121,14 @@ CeruleanGymText1: ld hl, CeruleanGymText_5c7d8 ld de, CeruleanGymText_5c7d8 call SaveEndBattleTextPointers - ld a, [hSpriteIndex] + ldh a, [hSpriteIndex] ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters ld a, $2 ld [wGymLeaderNo], a xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a ld a, $3 ld [wCeruleanGymCurScript], a .done diff --git a/scripts/ChampionsRoom.asm b/scripts/ChampionsRoom.asm index ef6ff8fb..e57048c5 100755 --- a/scripts/ChampionsRoom.asm +++ b/scripts/ChampionsRoom.asm @@ -55,7 +55,7 @@ GaryScript2: ld hl, wOptions res 7, [hl] ; Turn on battle animations to make the battle feel more epic. ld a, $1 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID call Delay3 ld hl, wd72d @@ -84,7 +84,7 @@ GaryScript2: ld [wTrainerNo], a xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a ld a, $3 ld [wChampionsRoomCurScript], a ret @@ -98,26 +98,26 @@ GaryScript3: ld a, $f0 ld [wJoyIgnore], a ld a, $1 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call GaryScript_760c8 ld a, $1 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a call SetSpriteMovementBytesToFF ld a, $4 ld [wChampionsRoomCurScript], a ret GaryScript4: - callba Music_Cities1AlternateTempo + farcall Music_Cities1AlternateTempo ld a, $2 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call GaryScript_760c8 ld a, $2 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a call SetSpriteMovementBytesToFF ld de, OakEntranceAfterVictoryMovement ld a, $2 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a call MoveSprite ld a, HS_CHAMPIONS_ROOM_OAK ld [wMissableObjectIndex], a @@ -141,17 +141,17 @@ GaryScript5: ld a, PLAYER_DIR_LEFT ld [wPlayerMovingDirection], a ld a, $1 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a ld a, SPRITE_FACING_LEFT - ld [hSpriteFacingDirection], a + ldh [hSpriteFacingDirection], a call SetSpriteFacingDirectionAndDelay ld a, $2 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a xor a ; SPRITE_FACING_DOWN - ld [hSpriteFacingDirection], a + ldh [hSpriteFacingDirection], a call SetSpriteFacingDirectionAndDelay ld a, $3 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call GaryScript_760c8 ld a, $6 ld [wChampionsRoomCurScript], a @@ -159,12 +159,12 @@ GaryScript5: GaryScript6: ld a, $2 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a ld a, SPRITE_FACING_RIGHT - ld [hSpriteFacingDirection], a + ldh [hSpriteFacingDirection], a call SetSpriteFacingDirectionAndDelay ld a, $4 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call GaryScript_760c8 ld a, $7 ld [wChampionsRoomCurScript], a @@ -172,16 +172,16 @@ GaryScript6: GaryScript7: ld a, $2 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a xor a ; SPRITE_FACING_DOWN - ld [hSpriteFacingDirection], a + ldh [hSpriteFacingDirection], a call SetSpriteFacingDirectionAndDelay ld a, $5 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call GaryScript_760c8 ld de, OakExitGaryRoomMovement ld a, $2 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a call MoveSprite ld a, $8 ld [wChampionsRoomCurScript], a diff --git a/scripts/CinnabarGym.asm b/scripts/CinnabarGym.asm index 2aa61135..9318c775 100755 --- a/scripts/CinnabarGym.asm +++ b/scripts/CinnabarGym.asm @@ -36,7 +36,7 @@ CinnabarGymScript_75792: ret CinnabarGymScript_757a0: - ld a, [hSpriteIndexOrTextID] + ldh a, [hSpriteIndexOrTextID] ld [wTrainerHeaderFlagBit], a ret @@ -50,7 +50,7 @@ CinnabarGymScript0: ld a, [wOpponentAfterWrongAnswer] and a ret z - ld [hSpriteIndex], a + ldh [hSpriteIndex], a cp $4 jr nz, .asm_757c3 ld a, PLAYER_DIR_DOWN @@ -85,7 +85,7 @@ CinnabarGymScript1: ld [wJoyIgnore], a ld a, [wOpponentAfterWrongAnswer] ld [wTrainerHeaderFlagBit], a - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a jp DisplayTextID CinnabarGymFlagAction: @@ -96,7 +96,7 @@ CinnabarGymScript2: cp $ff jp z, CinnabarGymScript_75792 ld a, [wTrainerHeaderFlagBit] - ld [hGymGateIndex], a + ldh [hGymGateIndex], a AdjustEventBit EVENT_BEAT_CINNABAR_GYM_TRAINER_0, 2 ld c, a ld b, FLAG_TEST @@ -111,7 +111,7 @@ CinnabarGymScript2: call WaitForSoundToFinish .asm_7581b ld a, [wTrainerHeaderFlagBit] - ld [hGymGateIndex], a + ldh [hGymGateIndex], a AdjustEventBit EVENT_BEAT_CINNABAR_GYM_TRAINER_0, 2 ld c, a ld b, FLAG_SET @@ -141,20 +141,20 @@ CinnabarGymScript3: ld [wJoyIgnore], a CinnabarGymScript3_75857: ld a, $a - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID SetEvent EVENT_BEAT_BLAINE lb bc, TM_FIRE_BLAST, 1 call GiveItem jr nc, .BagFull ld a, $b - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID SetEvent EVENT_GOT_TM38 jr .gymVictory .BagFull ld a, $c - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID .gymVictory ld hl, wObtainedBadges @@ -185,7 +185,7 @@ CinnabarGym_TextPointers: dw TM38NoRoomText CinnabarGymScript_758b7: - ld a, [hSpriteIndexOrTextID] + ldh a, [hSpriteIndexOrTextID] ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters diff --git a/scripts/CinnabarIsland.asm b/scripts/CinnabarIsland.asm index 54bbe1d8..f74890e8 100755 --- a/scripts/CinnabarIsland.asm +++ b/scripts/CinnabarIsland.asm @@ -25,10 +25,10 @@ CinnabarIslandScript0: ld a, PLAYER_DIR_UP ld [wPlayerMovingDirection], a ld a, $8 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a ld a, $1 ld [wSimulatedJoypadStatesIndex], a ld a, D_DOWN diff --git a/scripts/CinnabarLabFossilRoom.asm b/scripts/CinnabarLabFossilRoom.asm index ac33e6ee..4bdb8a36 100755 --- a/scripts/CinnabarLabFossilRoom.asm +++ b/scripts/CinnabarLabFossilRoom.asm @@ -56,7 +56,7 @@ Lab4Text1: ld a, [wFilteredBagItemsCount] and a jr z, .asm_75d8d - callba GiveFossilToCinnabarLab + farcall GiveFossilToCinnabarLab jr .asm_75d93 .asm_75d8d ld hl, Lab4Text_75dcb @@ -106,4 +106,4 @@ Lab4Text2: jp TextScriptEnd LoadFossilItemAndMonNameBank1D: - jpba LoadFossilItemAndMonName + farjp LoadFossilItemAndMonName diff --git a/scripts/CopycatsHouse2F.asm b/scripts/CopycatsHouse2F.asm index 580d9b11..c27043e6 100755 --- a/scripts/CopycatsHouse2F.asm +++ b/scripts/CopycatsHouse2F.asm @@ -29,8 +29,8 @@ CopycatsHouse2FText1: ld hl, ReceivedTM31Text call PrintText ld a, POKE_DOLL - ld [hItemToRemoveID], a - callba RemoveItemByID + ldh [hItemToRemoveID], a + farcall RemoveItemByID SetEvent EVENT_GOT_TM31 jr .asm_62ecd .BagFull diff --git a/scripts/Daycare.asm b/scripts/Daycare.asm index 4c9e2a85..481d7e14 100755 --- a/scripts/Daycare.asm +++ b/scripts/Daycare.asm @@ -35,7 +35,7 @@ DayCareMText1: pop af ld hl, DayCareAllRightThenText jp c, .done - callab KnowsHMMove + callfar KnowsHMMove ld hl, DayCareCantAcceptMonWithHMText jp c, .done xor a @@ -65,19 +65,19 @@ DayCareMText1: ld a, DAYCARE_DATA ld [wMonDataLocation], a call LoadMonData - callab CalcLevelFromExperience + callfar CalcLevelFromExperience ld a, d cp MAX_LEVEL jr c, .skipCalcExp ld d, MAX_LEVEL - callab CalcExperience + callfar CalcExperience ld hl, wDayCareMonExp - ld a, [hExperience] + ldh a, [hExperience] ld [hli], a - ld a, [hExperience + 1] + ldh a, [hExperience + 1] ld [hli], a - ld a, [hExperience + 2] + ldh a, [hExperience + 2] ld [hl], a ld d, MAX_LEVEL @@ -138,11 +138,11 @@ DayCareMText1: and a jp nz, .leaveMonInDayCare ld hl, wDayCareTotalCost - ld [hMoney], a + ldh [hMoney], a ld a, [hli] - ld [hMoney + 1], a + ldh [hMoney + 1], a ld a, [hl] - ld [hMoney + 2], a + ldh [hMoney + 2], a call HasEnoughMoney jr nc, .enoughMoney ld hl, DayCareNotEnoughMoneyText diff --git a/scripts/FightingDojo.asm b/scripts/FightingDojo.asm index eb1e3d55..a5844c14 100755 --- a/scripts/FightingDojo.asm +++ b/scripts/FightingDojo.asm @@ -30,7 +30,7 @@ FightingDojoScript1: CheckEvent EVENT_BEAT_KARATE_MASTER ret nz xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a ld [wcf0d], a ld a, [wYCoord] cp $3 @@ -43,12 +43,12 @@ FightingDojoScript1: ld a, PLAYER_DIR_RIGHT ld [wPlayerMovingDirection], a ld a, $1 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a ld a, SPRITE_FACING_LEFT - ld [hSpriteFacingDirection], a + ldh [hSpriteFacingDirection], a call SetSpriteFacingDirectionAndDelay ld a, $1 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID ret @@ -62,9 +62,9 @@ FightingDojoScript3: ld a, PLAYER_DIR_RIGHT ld [wPlayerMovingDirection], a ld a, $1 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a ld a, SPRITE_FACING_LEFT - ld [hSpriteFacingDirection], a + ldh [hSpriteFacingDirection], a call SetSpriteFacingDirectionAndDelay .asm_5cde4 @@ -72,7 +72,7 @@ FightingDojoScript3: ld [wJoyIgnore], a SetEventRange EVENT_BEAT_KARATE_MASTER, EVENT_BEAT_FIGHTING_DOJO_TRAINER_3 ld a, $8 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID xor a ld [wJoyIgnore], a @@ -142,7 +142,7 @@ FightingDojoText1: ld hl, FightingDojoText_5ce93 ld de, FightingDojoText_5ce93 call SaveEndBattleTextPointers - ld a, [hSpriteIndexOrTextID] + ldh a, [hSpriteIndexOrTextID] ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters diff --git a/scripts/FuchsiaGym.asm b/scripts/FuchsiaGym.asm index 6fa569a0..ccde6106 100755 --- a/scripts/FuchsiaGym.asm +++ b/scripts/FuchsiaGym.asm @@ -44,20 +44,20 @@ FuchsiaGymScript3: ld [wJoyIgnore], a FuchsiaGymScript3_75497: ld a, $9 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID SetEvent EVENT_BEAT_KOGA lb bc, TM_TOXIC, 1 call GiveItem jr nc, .BagFull ld a, $a - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID SetEvent EVENT_GOT_TM06 jr .gymVictory .BagFull ld a, $b - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID .gymVictory ld hl, wObtainedBadges @@ -161,14 +161,14 @@ FuchsiaGymText1: ld hl, KogaAfterBattleText ld de, KogaAfterBattleText call SaveEndBattleTextPointers - ld a, [hSpriteIndex] + ldh a, [hSpriteIndex] ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters ld a, $5 ld [wGymLeaderNo], a xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a ld a, $3 ld [wFuchsiaGymCurScript], a .done diff --git a/scripts/GameCorner.asm b/scripts/GameCorner.asm index 551caa78..ded5854f 100755 --- a/scripts/GameCorner.asm +++ b/scripts/GameCorner.asm @@ -12,7 +12,7 @@ CeladonGameCornerScript_48bcf: res 6, [hl] ret z call Random - ld a, [hRandomAdd] + ldh a, [hRandomAdd] cp $7 jr nc, .asm_48be2 ld a, $8 @@ -57,10 +57,10 @@ CeladonGameCornerScript1: ld a, $f0 ld [wJoyIgnore], a ld a, $d - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID ld a, $b - ld [hSpriteIndex], a + ldh [hSpriteIndex], a call SetSpriteMovementBytesToFF ld de, MovementData_48c5a ld a, [wYCoord] @@ -75,7 +75,7 @@ CeladonGameCornerScript1: ld de, MovementData_48c63 .asm_48c4d ld a, $b - ld [hSpriteIndex], a + ldh [hSpriteIndex], a call MoveSprite ld a, $2 ld [wGameCornerCurScript], a @@ -150,29 +150,29 @@ CeladonGameCornerText2: call Has9990Coins jr nc, .asm_48d14 xor a - ld [hMoney], a - ld [hMoney + 2], a + ldh [hMoney], a + ldh [hMoney + 2], a ld a, $10 - ld [hMoney + 1], a + ldh [hMoney + 1], a call HasEnoughMoney jr nc, .asm_48cdb ld hl, CeladonGameCornerText_48d31 jr .asm_48d1c .asm_48cdb xor a - ld [hMoney], a - ld [hMoney + 2], a + ldh [hMoney], a + ldh [hMoney + 2], a ld a, $10 - ld [hMoney + 1], a + ldh [hMoney + 1], a ld hl, hMoney + 2 ld de, wPlayerMoney + 2 ld c, $3 predef SubBCDPredef xor a - ld [hUnusedCoinsByte], a - ld [hCoins], a + ldh [hUnusedCoinsByte], a + ldh [hCoins], a ld a, $50 - ld [hCoins + 1], a + ldh [hCoins + 1], a ld de, wPlayerCoins + 1 ld hl, hCoins + 1 ld c, $2 @@ -236,10 +236,10 @@ CeladonGameCornerText5: call Has9990Coins jr nc, .asm_48d8e xor a - ld [hUnusedCoinsByte], a - ld [hCoins], a + ldh [hUnusedCoinsByte], a + ldh [hCoins], a ld a, $10 - ld [hCoins + 1], a + ldh [hCoins + 1], a ld de, wPlayerCoins + 1 ld hl, hCoins + 1 ld c, $2 @@ -316,10 +316,10 @@ CeladonGameCornerText9: call Has9990Coins jr nc, .asm_48e18 xor a - ld [hUnusedCoinsByte], a - ld [hCoins], a + ldh [hUnusedCoinsByte], a + ldh [hCoins], a ld a, $20 - ld [hCoins + 1], a + ldh [hCoins + 1], a ld de, wPlayerCoins + 1 ld hl, hCoins + 1 ld c, $2 @@ -368,10 +368,10 @@ CeladonGameCornerText10: call Has9990Coins jr z, .asm_48e7a xor a - ld [hUnusedCoinsByte], a - ld [hCoins], a + ldh [hUnusedCoinsByte], a + ldh [hCoins], a ld a, $20 - ld [hCoins + 1], a + ldh [hCoins + 1], a ld de, wPlayerCoins + 1 ld hl, hCoins + 1 ld c, $2 @@ -418,14 +418,14 @@ CeladonGameCornerText11: ld hl, CeladonGameCornerText_48ed3 ld de, CeladonGameCornerText_48ed3 call SaveEndBattleTextPointers - ld a, [hSpriteIndex] + ldh a, [hSpriteIndex] ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters xor a - ld [hJoyHeld], a - ld [hJoyPressed], a - ld [hJoyReleased], a + ldh [hJoyHeld], a + ldh [hJoyPressed], a + ldh [hJoyReleased], a ld a, $1 ld [wGameCornerCurScript], a jp TextScriptEnd @@ -474,32 +474,32 @@ CeladonGameCornerText_48f19: CeladonGameCornerScript_48f1e: ld hl, wd730 set 6, [hl] - coord hl, 11, 0 + hlcoord 11, 0 ld b, $5 ld c, $7 call TextBoxBorder call UpdateSprites - coord hl, 12, 1 + hlcoord 12, 1 ld b, 4 ld c, 7 call ClearScreenArea - coord hl, 12, 2 + hlcoord 12, 2 ld de, GameCornerMoneyText call PlaceString - coord hl, 12, 3 + hlcoord 12, 3 ld de, GameCornerBlankText1 call PlaceString - coord hl, 12, 3 + hlcoord 12, 3 ld de, wPlayerMoney ld c, $a3 call PrintBCDNumber - coord hl, 12, 4 + hlcoord 12, 4 ld de, GameCornerCoinText call PlaceString - coord hl, 12, 5 + hlcoord 12, 5 ld de, GameCornerBlankText2 call PlaceString - coord hl, 15, 5 + hlcoord 15, 5 ld de, wPlayerCoins ld c, $82 call PrintBCDNumber @@ -521,7 +521,7 @@ GameCornerBlankText2: Has9990Coins: ld a, $99 - ld [hCoins], a + ldh [hCoins], a ld a, $90 - ld [hCoins + 1], a + ldh [hCoins + 1], a jp HasEnoughCoins diff --git a/scripts/HallOfFame.asm b/scripts/HallOfFame.asm index ef3ed128..35ad9fd8 100755 --- a/scripts/HallOfFame.asm +++ b/scripts/HallOfFame.asm @@ -45,7 +45,7 @@ HallofFameRoomScript2: ld [wHallOfFameCurScript], a ld a, PALLET_TOWN ld [wLastBlackoutMap], a - callba SaveSAVtoSRAM + farcall SaveSAVtoSRAM ld b, 5 .delayLoop ld c, 600 / 5 @@ -79,10 +79,10 @@ HallofFameRoomScript1: ld a, PLAYER_DIR_RIGHT ld [wPlayerMovingDirection], a ld a, $1 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a call SetSpriteMovementBytesToFF ld a, SPRITE_FACING_LEFT - ld [hSpriteFacingDirection], a + ldh [hSpriteFacingDirection], a call SetSpriteFacingDirectionAndDelay call Delay3 xor a @@ -90,7 +90,7 @@ HallofFameRoomScript1: inc a ; PLAYER_DIR_RIGHT ld [wPlayerMovingDirection], a ld a, $1 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID ld a, $ff ld [wJoyIgnore], a diff --git a/scripts/LancesRoom.asm b/scripts/LancesRoom.asm index 712972e8..5087dda8 100755 --- a/scripts/LancesRoom.asm +++ b/scripts/LancesRoom.asm @@ -59,12 +59,12 @@ LanceScript0: call ArePlayerCoordsInArray jp nc, CheckFightingMapTrainers xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a ld a, [wCoordIndex] cp $3 ; Is player standing next to Lance's sprite? jr nc, .notStandingNextToLance ld a, $1 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a jp DisplayTextID .notStandingNextToLance cp $5 ; Is player standing on the entrance staircase? @@ -91,7 +91,7 @@ LanceScript2: cp $ff jp z, ResetLanceScript ld a, $1 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a jp DisplayTextID WalkToLance: diff --git a/scripts/LoreleisRoom.asm b/scripts/LoreleisRoom.asm index c03d1161..f2cdfb45 100755 --- a/scripts/LoreleisRoom.asm +++ b/scripts/LoreleisRoom.asm @@ -65,8 +65,8 @@ LoreleiScript0: call ArePlayerCoordsInArray jp nc, CheckFightingMapTrainers xor a - ld [hJoyPressed], a - ld [hJoyHeld], a + ldh [hJoyPressed], a + ldh [hJoyHeld], a ld [wSimulatedJoypadStatesEnd], a ld [wSimulatedJoypadStatesIndex], a ld a, [wCoordIndex] @@ -76,7 +76,7 @@ LoreleiScript0: jr z, LoreleiScriptWalkIntoRoom .stopPlayerFromLeaving ld a, $2 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID ; "Don't run away!" ld a, D_UP ld [wSimulatedJoypadStatesEnd], a @@ -112,7 +112,7 @@ LoreleiScript2: cp $ff jp z, ResetLoreleiScript ld a, $1 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a jp DisplayTextID LoreleisRoom_TextPointers: diff --git a/scripts/MtMoonB2F.asm b/scripts/MtMoonB2F.asm index 50620f23..a70967e4 100755 --- a/scripts/MtMoonB2F.asm +++ b/scripts/MtMoonB2F.asm @@ -62,9 +62,9 @@ MtMoon3Script0: cp $d jp nz, MtMoon3Script_49d91 xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a ld a, $1 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a jp DisplayTextID MtMoon3Script_49d91: @@ -88,7 +88,7 @@ MtMoon3Script3: MtMoon3Script4: ld a, $1 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a call SetSpriteMovementBytesToFF ld hl, CoordsData_49dea call ArePlayerCoordsInArray @@ -102,7 +102,7 @@ MtMoon3Script4: ld de, MovementData_49df8 .asm_49dda ld a, $1 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a call MoveSprite ld a, $5 ld [wMtMoonB2FCurScript], a @@ -136,7 +136,7 @@ MtMoon3Script5: ld a, $1 ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld a, $a - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID CheckEvent EVENT_GOT_DOME_FOSSIL jr z, .asm_49e1d @@ -222,7 +222,7 @@ MtMoon3Text1: ld hl, MtMoon3Text_49f8a ld de, MtMoon3Text_49f8a call SaveEndBattleTextPointers - ld a, [hSpriteIndex] + ldh a, [hSpriteIndex] ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters diff --git a/scripts/MtMoonPokecenter.asm b/scripts/MtMoonPokecenter.asm index bcc540a3..3dafd780 100755 --- a/scripts/MtMoonPokecenter.asm +++ b/scripts/MtMoonPokecenter.asm @@ -34,10 +34,10 @@ MagikarpSalesmanText: ld a, [wCurrentMenuItem] and a jp nz, .choseNo - ld [hMoney], a - ld [hMoney + 2], a + ldh [hMoney], a + ldh [hMoney + 2], a ld a, $5 - ld [hMoney + 1], a + ldh [hMoney + 1], a call HasEnoughMoney jr nc, .enoughMoney ld hl, .NoMoneyText diff --git a/scripts/Museum1F.asm b/scripts/Museum1F.asm index a8a609ff..caec03be 100755 --- a/scripts/Museum1F.asm +++ b/scripts/Museum1F.asm @@ -23,9 +23,9 @@ Museum1FScript0: ret nz .asm_5c120 xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a ld a, $1 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a jp DisplayTextID Museum1FScript1: @@ -71,7 +71,7 @@ Museum1FText1: ld [wTextBoxID], a call DisplayTextBoxID xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a ld hl, Museum1FText_5c21f call PrintText call YesNoChoice @@ -79,10 +79,10 @@ Museum1FText1: and a jr nz, .asm_de133 xor a - ld [hMoney], a - ld [hMoney + 1], a + ldh [hMoney], a + ldh [hMoney + 1], a ld a, $50 - ld [hMoney + 2], a + ldh [hMoney + 2], a call HasEnoughMoney jr nc, .asm_0f3e3 ld hl, Museum1FText_5c229 diff --git a/scripts/NameRatersHouse.asm b/scripts/NameRatersHouse.asm index 7694e92b..cecf97e7 100755 --- a/scripts/NameRatersHouse.asm +++ b/scripts/NameRatersHouse.asm @@ -68,7 +68,7 @@ NameRaterText1: jr nz, .asm_1daae ld hl, NameRaterText_1dac2 call PrintText - callba DisplayNameRaterScreen + farcall DisplayNameRaterScreen jr c, .asm_1daae ld hl, NameRaterText_1dac7 .asm_1daa8 diff --git a/scripts/OaksLab.asm b/scripts/OaksLab.asm index 01196d7c..a2e0bfe8 100755 --- a/scripts/OaksLab.asm +++ b/scripts/OaksLab.asm @@ -48,7 +48,7 @@ OaksLabScript0: OaksLabScript1: ld a, $8 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a ld de, OakEntryMovement call MoveSprite @@ -86,14 +86,14 @@ OaksLabScript3: ld [wSimulatedJoypadStatesIndex], a call StartSimulatingJoypadStates ld a, $1 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a xor a - ld [hSpriteFacingDirection], a + ldh [hSpriteFacingDirection], a call SetSpriteFacingDirectionAndDelay ld a, $5 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a xor a - ld [hSpriteFacingDirection], a + ldh [hSpriteFacingDirection], a call SetSpriteFacingDirectionAndDelay ld a, $4 @@ -111,9 +111,9 @@ OaksLabScript4: SetEvent EVENT_FOLLOWED_OAK_INTO_LAB SetEvent EVENT_FOLLOWED_OAK_INTO_LAB_2 ld a, $1 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a ld a, SPRITE_FACING_UP - ld [hSpriteFacingDirection], a + ldh [hSpriteFacingDirection], a call SetSpriteFacingDirectionAndDelay call UpdateSprites ld hl, wFlags_D733 @@ -128,19 +128,19 @@ OaksLabScript5: ld a, $fc ld [wJoyIgnore], a ld a, $11 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID call Delay3 ld a, $12 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID call Delay3 ld a, $13 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID call Delay3 ld a, $14 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID SetEvent EVENT_OAK_ASKED_TO_CHOOSE_MON xor a @@ -155,18 +155,18 @@ OaksLabScript6: cp $6 ret nz ld a, $5 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a xor a ; SPRITE_FACING_DOWN - ld [hSpriteFacingDirection], a + ldh [hSpriteFacingDirection], a call SetSpriteFacingDirectionAndDelay ld a, $1 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a xor a - ld [hSpriteFacingDirection], a + ldh [hSpriteFacingDirection], a call SetSpriteFacingDirectionAndDelay call UpdateSprites ld a, $c - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID ld a, $1 ld [wSimulatedJoypadStatesIndex], a @@ -254,9 +254,9 @@ OaksLabScript8: jr nz, .moveBlue push hl ld a, $1 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a ld a, $4 - ld [hSpriteDataOffset], a + ldh [hSpriteDataOffset], a call GetPointerWithinSpriteStateData1 push hl ld [hl], $4c @@ -281,7 +281,7 @@ OaksLabScript8: .moveBlue ld a, $1 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a call MoveSprite ld a, $9 @@ -295,12 +295,12 @@ OaksLabScript9: ld a, $fc ld [wJoyIgnore], a ld a, $1 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a ld a, SPRITE_FACING_UP - ld [hSpriteFacingDirection], a + ldh [hSpriteFacingDirection], a call SetSpriteFacingDirectionAndDelay ld a, $d - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID ld a, [wRivalStarterBallSpriteIndex] cp $2 @@ -324,12 +324,12 @@ OaksLabScript9: ld [wd11e], a call GetMonName ld a, $1 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a ld a, SPRITE_FACING_UP - ld [hSpriteFacingDirection], a + ldh [hSpriteFacingDirection], a call SetSpriteFacingDirectionAndDelay ld a, $e - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID SetEvent EVENT_GOT_STARTER xor a @@ -344,9 +344,9 @@ OaksLabScript10: cp $6 ret nz ld a, $1 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a xor a ; SPRITE_FACING_DOWN - ld [hSpriteFacingDirection], a + ldh [hSpriteFacingDirection], a call SetSpriteFacingDirectionAndDelay ld a, PLAYER_DIR_UP ld [wPlayerMovingDirection], a @@ -354,21 +354,21 @@ OaksLabScript10: ld a, MUSIC_MEET_RIVAL call PlayMusic ld a, $f - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID ld a, $1 - ld [hNPCPlayerRelativePosPerspective], a + ldh [hNPCPlayerRelativePosPerspective], a ld a, $1 swap a - ld [hNPCSpriteOffset], a + ldh [hNPCSpriteOffset], a predef CalcPositionOfPlayerRelativeToNPC - ld a, [hNPCPlayerYDistance] + ldh a, [hNPCPlayerYDistance] dec a - ld [hNPCPlayerYDistance], a + ldh [hNPCPlayerYDistance], a predef FindPathToPlayer ld de, wNPCMovementDirections2 ld a, $1 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a call MoveSprite ld a, $b @@ -424,9 +424,9 @@ OaksLabScript12: ld [wSpriteIndex], a call SetSpritePosition1 ld a, $1 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a xor a ; SPRITE_FACING_DOWN - ld [hSpriteFacingDirection], a + ldh [hSpriteFacingDirection], a call SetSpriteFacingDirectionAndDelay predef HealParty SetEvent EVENT_BATTLED_RIVAL_IN_OAKS_LAB @@ -439,11 +439,11 @@ OaksLabScript13: ld c, 20 call DelayFrames ld a, $10 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID - callba Music_RivalAlternateStart + farcall Music_RivalAlternateStart ld a, $1 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a ld de, .RivalExitMovement call MoveSprite ld a, [wXCoord] @@ -508,14 +508,14 @@ OaksLabScript14: OaksLabScript15: xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a call EnableAutoTextBoxDrawing ld a, SFX_STOP_ALL_MUSIC ld [wNewSoundID], a call PlaySound - callba Music_RivalAlternateStart + farcall Music_RivalAlternateStart ld a, $15 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID call OaksLabScript_1d02b ld a, HS_OAKS_LAB_RIVAL @@ -530,7 +530,7 @@ OaksLabScript15: call FillMemory ld [hl], $ff ld a, $1 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a ld de, wNPCMovementDirections2 call MoveSprite @@ -540,14 +540,14 @@ OaksLabScript15: OaksLabScript_1cefd: ld a, $1 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a ld a, SPRITE_FACING_UP - ld [hSpriteFacingDirection], a + ldh [hSpriteFacingDirection], a call SetSpriteFacingDirectionAndDelay ld a, $8 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a xor a ; SPRITE_FACING_DOWN - ld [hSpriteFacingDirection], a + ldh [hSpriteFacingDirection], a jp SetSpriteFacingDirectionAndDelay OaksLabScript16: @@ -560,21 +560,21 @@ OaksLabScript16: ld [wJoyIgnore], a call OaksLabScript_1cefd ld a, $16 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID call DelayFrame call OaksLabScript_1cefd ld a, $17 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID call DelayFrame call OaksLabScript_1cefd ld a, $18 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID call DelayFrame ld a, $19 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID call Delay3 ld a, HS_POKEDEX_1 @@ -585,16 +585,16 @@ OaksLabScript16: predef HideObject call OaksLabScript_1cefd ld a, $1a - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID ld a, $1 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a ld a, SPRITE_FACING_RIGHT - ld [hSpriteFacingDirection], a + ldh [hSpriteFacingDirection], a call SetSpriteFacingDirectionAndDelay call Delay3 ld a, $1b - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID SetEvent EVENT_GOT_POKEDEX SetEvent EVENT_OAK_GOT_PARCEL @@ -614,9 +614,9 @@ OaksLabScript16: ld a, SFX_STOP_ALL_MUSIC ld [wNewSoundID], a call PlaySound - callba Music_RivalAlternateStart + farcall Music_RivalAlternateStart ld a, $1 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a ld de, wNPCMovementDirections2 call MoveSprite @@ -672,9 +672,9 @@ OaksLabScript_RemoveParcel: OaksLabScript_1d02b: ld a, $7c - ld [hSpriteScreenYCoord], a + ldh [hSpriteScreenYCoord], a ld a, $8 - ld [hSpriteMapXCoord], a + ldh [hSpriteMapXCoord], a ld a, [wYCoord] cp $3 jr nz, .asm_1d045 @@ -703,9 +703,9 @@ OaksLabScript_1d02b: .asm_1d066 ld a, $20 .asm_1d068 - ld [hSpriteScreenXCoord], a + ldh [hSpriteScreenXCoord], a ld a, b - ld [hSpriteMapYCoord], a + ldh [hSpriteMapYCoord], a ld a, $1 ld [wSpriteIndex], a call SetSpritePosition1 @@ -840,15 +840,15 @@ OaksLabText39: OaksLabScript_1d157: ld a, $5 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a ld a, $9 - ld [hSpriteDataOffset], a + ldh [hSpriteDataOffset], a call GetPointerWithinSpriteStateData1 ld [hl], SPRITE_FACING_DOWN ld a, $1 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a ld a, $9 - ld [hSpriteDataOffset], a + ldh [hSpriteDataOffset], a call GetPointerWithinSpriteStateData1 ld [hl], SPRITE_FACING_RIGHT ld hl, wd730 @@ -947,9 +947,9 @@ OaksLabReceivedMonText: OaksLabScript_1d22d: ld a, $5 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a ld a, $9 - ld [hSpriteDataOffset], a + ldh [hSpriteDataOffset], a call GetPointerWithinSpriteStateData1 ld [hl], $0 ld hl, OaksLabLastMonText diff --git a/scripts/PalletTown.asm b/scripts/PalletTown.asm index e063e0c8..5c26fc55 100755 --- a/scripts/PalletTown.asm +++ b/scripts/PalletTown.asm @@ -24,14 +24,14 @@ PalletTownScript0: cp 1 ; is player near north exit? ret nz xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a ld a, PLAYER_DIR_DOWN ld [wPlayerMovingDirection], a ld a, SFX_STOP_ALL_MUSIC call PlaySound ld a, BANK(Music_MeetProfOak) ld c, a - ld a, MUSIC_MEET_PROF_OAK ; “oak appears” music + ld a, MUSIC_MEET_PROF_OAK ; "oak appears" music call PlayMusic ld a, $FC ld [wJoyIgnore], a @@ -46,7 +46,7 @@ PalletTownScript1: xor a ld [wcf0d], a ld a, 1 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID ld a, $FF ld [wJoyIgnore], a @@ -61,25 +61,25 @@ PalletTownScript1: PalletTownScript2: ld a, 1 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a ld a, SPRITE_FACING_UP - ld [hSpriteFacingDirection], a + ldh [hSpriteFacingDirection], a call SetSpriteFacingDirectionAndDelay call Delay3 ld a, 1 ld [wYCoord], a ld a, 1 - ld [hNPCPlayerRelativePosPerspective], a + ldh [hNPCPlayerRelativePosPerspective], a ld a, 1 swap a - ld [hNPCSpriteOffset], a + ldh [hNPCSpriteOffset], a predef CalcPositionOfPlayerRelativeToNPC ld hl, hNPCPlayerYDistance dec [hl] - predef FindPathToPlayer ; load Oak’s movement into wNPCMovementDirections2 + predef FindPathToPlayer ; load Oak's movement into wNPCMovementDirections2 ld de, wNPCMovementDirections2 ld a, 1 ; oak - ld [hSpriteIndex], a + ldh [hSpriteIndex], a call MoveSprite ld a, $FF ld [wJoyIgnore], a @@ -100,7 +100,7 @@ PalletTownScript3: ld a, $FC ld [wJoyIgnore], a ld a, 1 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID ; set up movement script that causes the player to follow Oak to his lab ld a, $FF @@ -111,7 +111,7 @@ PalletTownScript3: ld [wNPCMovementScriptFunctionNum], a ld a, 1 ld [wNPCMovementScriptPointerTableNum], a - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] ld [wNPCMovementScriptBank], a ; trigger the next script @@ -205,10 +205,10 @@ PalletTownText5: ; sign by fence text_far _PalletTownText5 text_end -PalletTownText6: ; sign by Red’s house +PalletTownText6: ; sign by Red's house text_far _PalletTownText6 text_end -PalletTownText7: ; sign by Blue’s house +PalletTownText7: ; sign by Blue's house text_far _PalletTownText7 text_end diff --git a/scripts/PewterCity.asm b/scripts/PewterCity.asm index a082d5eb..e3d39dae 100755 --- a/scripts/PewterCity.asm +++ b/scripts/PewterCity.asm @@ -29,7 +29,7 @@ PewterCityScript_1925e: ld a, $f0 ld [wJoyIgnore], a ld a, $5 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a jp DisplayTextID CoordsData_19277: @@ -44,32 +44,32 @@ PewterCityScript1: and a ret nz ld a, $3 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a ld a, SPRITE_FACING_UP - ld [hSpriteFacingDirection], a + ldh [hSpriteFacingDirection], a call SetSpriteFacingDirectionAndDelay ld a, ($3 << 4) | SPRITE_FACING_UP - ld [hSpriteImageIndex], a + ldh [hSpriteImageIndex], a call SetSpriteImageIndexAfterSettingFacingDirection call PlayDefaultMusic ld hl, wFlags_0xcd60 set 4, [hl] ld a, $d - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID ld a, $3c - ld [hSpriteScreenYCoord], a + ldh [hSpriteScreenYCoord], a ld a, $30 - ld [hSpriteScreenXCoord], a + ldh [hSpriteScreenXCoord], a ld a, $c - ld [hSpriteMapYCoord], a + ldh [hSpriteMapYCoord], a ld a, $11 - ld [hSpriteMapXCoord], a + ldh [hSpriteMapXCoord], a ld a, $3 ld [wSpriteIndex], a call SetSpritePosition1 ld a, $3 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a ld de, MovementData_PewterMuseumGuyExit call MoveSprite ld a, $2 @@ -112,32 +112,32 @@ PewterCityScript4: and a ret nz ld a, $5 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a ld a, SPRITE_FACING_LEFT - ld [hSpriteFacingDirection], a + ldh [hSpriteFacingDirection], a call SetSpriteFacingDirectionAndDelay ld a, ($1 << 4) | SPRITE_FACING_LEFT - ld [hSpriteImageIndex], a + ldh [hSpriteImageIndex], a call SetSpriteImageIndexAfterSettingFacingDirection call PlayDefaultMusic ld hl, wFlags_0xcd60 set 4, [hl] ld a, $e - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID ld a, $3c - ld [hSpriteScreenYCoord], a + ldh [hSpriteScreenYCoord], a ld a, $40 - ld [hSpriteScreenXCoord], a + ldh [hSpriteScreenXCoord], a ld a, $16 - ld [hSpriteMapYCoord], a + ldh [hSpriteMapYCoord], a ld a, $10 - ld [hSpriteMapXCoord], a + ldh [hSpriteMapXCoord], a ld a, $5 ld [wSpriteIndex], a call SetSpritePosition1 ld a, $5 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a ld de, MovementData_PewterGymGuyExit call MoveSprite ld a, $5 @@ -215,12 +215,12 @@ PewterCityText3: ld hl, PewterCityText_193fb call PrintText xor a - ld [hJoyPressed], a - ld [hJoyHeld], a + ldh [hJoyPressed], a + ldh [hJoyHeld], a ld [wNPCMovementScriptFunctionNum], a ld a, $2 ld [wNPCMovementScriptPointerTableNum], a - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] ld [wNPCMovementScriptBank], a ld a, $3 ld [wSpriteIndex], a @@ -280,11 +280,11 @@ PewterCityText5: ld hl, PewterCityText_1945d call PrintText xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a ld [wNPCMovementScriptFunctionNum], a ld a, $3 ld [wNPCMovementScriptPointerTableNum], a - ld a, [hLoadedROMBank] + ldh a, [hLoadedROMBank] ld [wNPCMovementScriptBank], a ld a, $5 ld [wSpriteIndex], a diff --git a/scripts/PewterGym.asm b/scripts/PewterGym.asm index 7215e095..94364043 100755 --- a/scripts/PewterGym.asm +++ b/scripts/PewterGym.asm @@ -44,20 +44,20 @@ PewterGymScript3: PewterGymScript_5c3df: ld a, $4 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID SetEvent EVENT_BEAT_BROCK lb bc, TM_BIDE, 1 call GiveItem jr nc, .BagFull ld a, $5 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID SetEvent EVENT_GOT_TM34 jr .gymVictory .BagFull ld a, $6 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID .gymVictory ld hl, wObtainedBadges @@ -120,14 +120,14 @@ PewterGymText1: ld hl, PewterGymText_5c4bc ld de, PewterGymText_5c4bc call SaveEndBattleTextPointers - ld a, [hSpriteIndex] + ldh a, [hSpriteIndex] ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters ld a, $1 ld [wGymLeaderNo], a xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a ld a, $3 ld [wPewterGymCurScript], a ld [wCurMapScript], a diff --git a/scripts/PokemonMansion1F.asm b/scripts/PokemonMansion1F.asm index d8f3728c..a68b8928 100755 --- a/scripts/PokemonMansion1F.asm +++ b/scripts/PokemonMansion1F.asm @@ -50,9 +50,9 @@ Mansion1Script_Switches:: cp SPRITE_FACING_UP ret nz xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a ld a, $4 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a jp DisplayTextID PokemonMansion1F_ScriptPointers: diff --git a/scripts/PokemonMansion2F.asm b/scripts/PokemonMansion2F.asm index e560d6bd..16f0dff5 100755 --- a/scripts/PokemonMansion2F.asm +++ b/scripts/PokemonMansion2F.asm @@ -46,9 +46,9 @@ Mansion2Script_Switches:: cp SPRITE_FACING_UP ret nz xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a ld a, $5 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a jp DisplayTextID PokemonMansion2F_ScriptPointers: diff --git a/scripts/PokemonMansion3F.asm b/scripts/PokemonMansion3F.asm index ad346702..f4612b0d 100755 --- a/scripts/PokemonMansion3F.asm +++ b/scripts/PokemonMansion3F.asm @@ -77,9 +77,9 @@ Mansion3Script_Switches:: cp SPRITE_FACING_UP ret nz xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a ld a, $6 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a jp DisplayTextID PokemonMansion3F_TextPointers: diff --git a/scripts/PokemonMansionB1F.asm b/scripts/PokemonMansionB1F.asm index aa7123f0..7b295f7e 100755 --- a/scripts/PokemonMansionB1F.asm +++ b/scripts/PokemonMansionB1F.asm @@ -48,9 +48,9 @@ Mansion4Script_Switches:: cp SPRITE_FACING_UP ret nz xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a ld a, $9 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a jp DisplayTextID PokemonMansionB1F_ScriptPointers: diff --git a/scripts/PokemonTower2F.asm b/scripts/PokemonTower2F.asm index 4cf308b5..cddebfa8 100755 --- a/scripts/PokemonTower2F.asm +++ b/scripts/PokemonTower2F.asm @@ -41,16 +41,16 @@ PokemonTower2Script0: .asm_60544 ld [wPlayerMovingDirection], a ld a, $1 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a ld a, b - ld [hSpriteFacingDirection], a + ldh [hSpriteFacingDirection], a call SetSpriteFacingDirectionAndDelay ld a, $1 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID xor a - ld [hJoyHeld], a - ld [hJoyPressed], a + ldh [hJoyHeld], a + ldh [hJoyPressed], a ret CoordsData_6055e: @@ -66,7 +66,7 @@ PokemonTower2Script1: ld [wJoyIgnore], a SetEvent EVENT_BEAT_POKEMON_TOWER_RIVAL ld a, $1 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID ld de, MovementData_605b2 CheckEvent EVENT_POKEMON_TOWER_RIVAL_ON_LEFT @@ -74,12 +74,12 @@ PokemonTower2Script1: ld de, MovementData_605a9 .asm_60589 ld a, $1 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a call MoveSprite ld a, SFX_STOP_ALL_MUSIC ld [wNewSoundID], a call PlaySound - callba Music_RivalAlternateStart + farcall Music_RivalAlternateStart ld a, $2 ld [wPokemonTower2FCurScript], a ld [wCurMapScript], a diff --git a/scripts/PokemonTower5F.asm b/scripts/PokemonTower5F.asm index de09ec49..8cd9f5d1 100755 --- a/scripts/PokemonTower5F.asm +++ b/scripts/PokemonTower5F.asm @@ -24,7 +24,7 @@ PokemonTower5Script0: CheckAndSetEvent EVENT_IN_PURIFIED_ZONE ret nz xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a ld a, $f0 ld [wJoyIgnore], a ld hl, wd72e @@ -35,7 +35,7 @@ PokemonTower5Script0: call Delay3 call GBFadeInFromWhite ld a, $7 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID xor a ld [wJoyIgnore], a diff --git a/scripts/PokemonTower6F.asm b/scripts/PokemonTower6F.asm index a6ae22ec..9ed36a7b 100755 --- a/scripts/PokemonTower6F.asm +++ b/scripts/PokemonTower6F.asm @@ -28,9 +28,9 @@ PokemonTower6Script0: call ArePlayerCoordsInArray jp nc, CheckFightingMapTrainers xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a ld a, $6 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID ld a, MAROWAK ld [wCurOpponent], a @@ -61,7 +61,7 @@ PokemonTower6Script4: jr nz, .asm_60b82 SetEvent EVENT_BEAT_GHOST_MAROWAK ld a, $7 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID xor a ld [wJoyIgnore], a diff --git a/scripts/PokemonTower7F.asm b/scripts/PokemonTower7F.asm index 3f16ca92..f32e1a7c 100755 --- a/scripts/PokemonTower7F.asm +++ b/scripts/PokemonTower7F.asm @@ -31,7 +31,7 @@ PokemonTower7Script2: ld a, $f0 ld [wJoyIgnore], a ld a, [wSpriteIndex] - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID call PokemonTower7Script_60db6 ld a, $3 @@ -72,7 +72,7 @@ PokemonTower7Script4: ld a, SPRITE_FACING_UP ld [wSpritePlayerStateData1FacingDirection], a ld a, MR_FUJIS_HOUSE - ld [hWarpDestinationMap], a + ldh [hWarpDestinationMap], a ld a, $1 ld [wDestinationWarpID], a ld a, LAVENDER_TOWN @@ -107,7 +107,7 @@ PokemonTower7Script_60db6: ld d, [hl] ld e, a ld a, [wSpriteIndex] - ld [hSpriteIndex], a + ldh [hSpriteIndex], a jp MoveSprite .asm_60dde inc hl diff --git a/scripts/RedsHouse2F.asm b/scripts/RedsHouse2F.asm index 69a62f81..2e3463ee 100755 --- a/scripts/RedsHouse2F.asm +++ b/scripts/RedsHouse2F.asm @@ -10,7 +10,7 @@ RedsHouse2F_ScriptPointers: RedsHouse2FScript0: xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a ld a, PLAYER_DIR_UP ld [wPlayerMovingDirection], a ld a, 1 diff --git a/scripts/RocketHideoutB2F.asm b/scripts/RocketHideoutB2F.asm index 7a43e90e..47c0581c 100755 --- a/scripts/RocketHideoutB2F.asm +++ b/scripts/RocketHideoutB2F.asm @@ -367,38 +367,32 @@ LoadSpinnerArrowTiles:: spinner: MACRO ; \1: source ; \2: offset (BANK() chokes on literals) -; \3: length -; \4: dest - dw \1 + \2 - db \3, BANK(\1) - dw \4 +; \3: dest + dw \1 tile \2 + db 1 + db BANK(\1) + dw vTileset tile \3 ENDM FacilitySpinnerArrows: -FACILITY_SPINNER EQU $20 * $10 -vFacilitySpinner EQU vTileset + FACILITY_SPINNER - - spinner SpinnerArrowAnimTiles, $00, 1, vFacilitySpinner - spinner SpinnerArrowAnimTiles, $10, 1, vFacilitySpinner + $10 - spinner SpinnerArrowAnimTiles, $20, 1, vFacilitySpinner + $100 - spinner SpinnerArrowAnimTiles, $30, 1, vFacilitySpinner + $110 - spinner Facility_GFX, FACILITY_SPINNER + $000, 1, vFacilitySpinner - spinner Facility_GFX, FACILITY_SPINNER + $010, 1, vFacilitySpinner + $10 - spinner Facility_GFX, FACILITY_SPINNER + $100, 1, vFacilitySpinner + $100 - spinner Facility_GFX, FACILITY_SPINNER + $110, 1, vFacilitySpinner + $110 + spinner SpinnerArrowAnimTiles, 0, $20 + spinner SpinnerArrowAnimTiles, 1, $21 + spinner SpinnerArrowAnimTiles, 2, $30 + spinner SpinnerArrowAnimTiles, 3, $31 + spinner Facility_GFX, $20, $20 + spinner Facility_GFX, $21, $21 + spinner Facility_GFX, $30, $30 + spinner Facility_GFX, $31, $31 GymSpinnerArrows: -GYM_SPINNER EQU $3c * $10 -vGymSpinner EQU vTileset + GYM_SPINNER - - spinner SpinnerArrowAnimTiles, $10, 1, vGymSpinner - spinner SpinnerArrowAnimTiles, $30, 1, vGymSpinner + $10 - spinner SpinnerArrowAnimTiles, $00, 1, vGymSpinner + $100 - spinner SpinnerArrowAnimTiles, $20, 1, vGymSpinner + $110 - spinner Gym_GFX, GYM_SPINNER + $000, 1, vGymSpinner - spinner Gym_GFX, GYM_SPINNER + $010, 1, vGymSpinner + $10 - spinner Gym_GFX, GYM_SPINNER + $100, 1, vGymSpinner + $100 - spinner Gym_GFX, GYM_SPINNER + $110, 1, vGymSpinner + $110 + spinner SpinnerArrowAnimTiles, 1, $3c + spinner SpinnerArrowAnimTiles, 3, $3d + spinner SpinnerArrowAnimTiles, 0, $4c + spinner SpinnerArrowAnimTiles, 2, $4d + spinner Gym_GFX, $3c, $3c + spinner Gym_GFX, $3d, $3d + spinner Gym_GFX, $4c, $4c + spinner Gym_GFX, $4d, $4d SpinnerPlayerFacingDirections: ; This isn't the order of the facing directions. Rather, it's a list of diff --git a/scripts/RocketHideoutB4F.asm b/scripts/RocketHideoutB4F.asm index 81762a8f..f33ef6e2 100755 --- a/scripts/RocketHideoutB4F.asm +++ b/scripts/RocketHideoutB4F.asm @@ -52,7 +52,7 @@ RocketHideout4Script3: ld [wJoyIgnore], a SetEvent EVENT_BEAT_ROCKET_HIDEOUT_GIOVANNI ld a, $a - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID call GBFadeOutToBlack ld a, HS_ROCKET_HIDEOUT_B4F_GIOVANNI @@ -125,12 +125,12 @@ RocketHideout4Text1: ld hl, RocketHideout4Text_4557f ld de, RocketHideout4Text_4557f call SaveEndBattleTextPointers - ld a, [hSpriteIndex] + ldh a, [hSpriteIndex] ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a ld a, $3 ld [wRocketHideoutB4FCurScript], a ld [wCurMapScript], a diff --git a/scripts/RocketHideoutElevator.asm b/scripts/RocketHideoutElevator.asm index 6b1294b3..45b27e3b 100755 --- a/scripts/RocketHideoutElevator.asm +++ b/scripts/RocketHideoutElevator.asm @@ -58,7 +58,7 @@ RocketHideoutElevatorWarpMapsEnd: RocketHideoutElevatorScript_4575f: call Delay3 - callba ShakeElevator + farcall ShakeElevator ret RocketHideoutElevator_TextPointers: diff --git a/scripts/Route11Gate2F.asm b/scripts/Route11Gate2F.asm index 1fefc824..1797c540 100755 --- a/scripts/Route11Gate2F.asm +++ b/scripts/Route11Gate2F.asm @@ -20,9 +20,9 @@ Route11GateUpstairsText2: CheckEvent EVENT_GOT_ITEMFINDER, 1 jr c, .asm_4949b ld a, 30 ; pokemon needed - ld [hOaksAideRequirement], a + ldh [hOaksAideRequirement], a ld a, ITEMFINDER ; oak's aide reward - ld [hOaksAideRewardItem], a + ldh [hOaksAideRewardItem], a ld [wd11e], a call GetItemName ld h, d @@ -31,7 +31,7 @@ Route11GateUpstairsText2: ld bc, ITEM_NAME_LENGTH call CopyData predef OaksAideScript - ld a, [hOaksAideResult] + ldh a, [hOaksAideResult] dec a jr nz, .asm_494a1 SetEvent EVENT_GOT_ITEMFINDER diff --git a/scripts/Route12.asm b/scripts/Route12.asm index 1033e495..87052fd6 100755 --- a/scripts/Route12.asm +++ b/scripts/Route12.asm @@ -27,7 +27,7 @@ Route12Script0: ResetEventReuseHL EVENT_FIGHT_ROUTE12_SNORLAX jp z, CheckFightingMapTrainers ld a, $d - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID ld a, SNORLAX ld [wCurOpponent], a @@ -50,7 +50,7 @@ Route12Script3: cp $2 jr z, .asm_59664 ld a, $e - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID .asm_59664 SetEvent EVENT_BEAT_ROUTE12_SNORLAX diff --git a/scripts/Route15Gate2F.asm b/scripts/Route15Gate2F.asm index a0535949..9887fbc1 100755 --- a/scripts/Route15Gate2F.asm +++ b/scripts/Route15Gate2F.asm @@ -10,9 +10,9 @@ Route15GateUpstairsText1: CheckEvent EVENT_GOT_EXP_ALL jr nz, .asm_49683 ld a, 50 ; pokemon needed - ld [hOaksAideRequirement], a + ldh [hOaksAideRequirement], a ld a, EXP_ALL ; oak's aide reward - ld [hOaksAideRewardItem], a + ldh [hOaksAideRewardItem], a ld [wd11e], a call GetItemName ld hl, wcd6d @@ -20,7 +20,7 @@ Route15GateUpstairsText1: ld bc, ITEM_NAME_LENGTH call CopyData predef OaksAideScript - ld a, [hOaksAideResult] + ldh a, [hOaksAideResult] cp $1 jr nz, .asm_49689 SetEvent EVENT_GOT_EXP_ALL diff --git a/scripts/Route16.asm b/scripts/Route16.asm index f813b4e5..bd80a918 100755 --- a/scripts/Route16.asm +++ b/scripts/Route16.asm @@ -27,7 +27,7 @@ Route16Script0: ResetEventReuseHL EVENT_FIGHT_ROUTE16_SNORLAX jp z, CheckFightingMapTrainers ld a, $a - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID ld a, SNORLAX ld [wCurOpponent], a @@ -51,7 +51,7 @@ Route16Script3: cp $2 jr z, .asm_599a8 ld a, $b - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID .asm_599a8 SetEvent EVENT_BEAT_ROUTE16_SNORLAX diff --git a/scripts/Route16Gate1F.asm b/scripts/Route16Gate1F.asm index af84bab0..5bb77075 100755 --- a/scripts/Route16Gate1F.asm +++ b/scripts/Route16Gate1F.asm @@ -19,10 +19,10 @@ Route16GateScript0: call ArePlayerCoordsInArray ret nc ld a, $3 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a ld a, [wCoordIndex] cp $1 jr z, .asm_4970e @@ -59,7 +59,7 @@ Route16GateScript1: Route16GateScript2: ld a, $1 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID ld a, $1 ld [wSimulatedJoypadStatesIndex], a diff --git a/scripts/Route18Gate1F.asm b/scripts/Route18Gate1F.asm index ad876e15..ea8783df 100755 --- a/scripts/Route18Gate1F.asm +++ b/scripts/Route18Gate1F.asm @@ -19,10 +19,10 @@ Route18GateScript0: call ArePlayerCoordsInArray ret nc ld a, $2 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a ld a, [wCoordIndex] cp $1 jr z, .asm_498c6 @@ -59,7 +59,7 @@ Route18GateScript1: Route18GateScript2: ld a, $1 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID ld a, $1 ld [wSimulatedJoypadStatesIndex], a diff --git a/scripts/Route22.asm b/scripts/Route22.asm index b6970ef0..57dc934e 100755 --- a/scripts/Route22.asm +++ b/scripts/Route22.asm @@ -44,7 +44,7 @@ Route22MoveRivalSprite: .asm_50ef1 call MoveSprite ld a, SPRITE_FACING_RIGHT - ld [hSpriteFacingDirection], a + ldh [hSpriteFacingDirection], a jp SetSpriteFacingDirectionAndDelay Route22RivalMovementData: @@ -63,7 +63,7 @@ Route22Script0: ld a, [wCoordIndex] ld [wcf0d], a xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a ld a, $f0 ld [wJoyIgnore], a ld a, PLAYER_DIR_LEFT @@ -96,7 +96,7 @@ Route22Script0: ld a, MUSIC_MEET_RIVAL call PlayMusic ld a, $1 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a call Route22MoveRivalSprite ld a, $1 ld [wRoute22CurScript], a @@ -116,14 +116,14 @@ Route22Script1: .asm_50f78 ld a, SPRITE_FACING_RIGHT .asm_50f7a - ld [hSpriteFacingDirection], a + ldh [hSpriteFacingDirection], a ld a, $1 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a call SetSpriteFacingDirectionAndDelay xor a ld [wJoyIgnore], a ld a, $1 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID ld hl, wd72d set 6, [hl] @@ -157,20 +157,20 @@ Route22Script2: .notDown ld a, SPRITE_FACING_RIGHT .done - ld [hSpriteFacingDirection], a + ldh [hSpriteFacingDirection], a ld a, $1 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a call SetSpriteFacingDirectionAndDelay ld a, $f0 ld [wJoyIgnore], a SetEvent EVENT_BEAT_ROUTE22_RIVAL_1ST_BATTLE ld a, $1 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID ld a, SFX_STOP_ALL_MUSIC ld [wNewSoundID], a call PlaySound - callba Music_RivalAlternateStart + farcall Music_RivalAlternateStart ld a, [wcf0d] cp $1 jr nz, .asm_50fff @@ -191,7 +191,7 @@ Route22Script_5100d: ld de, Route22RivalExitMovementData2 Route22MoveRival1: ld a, $1 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a jp MoveSprite Route22RivalExitMovementData1: @@ -248,9 +248,9 @@ Route22Script_5104e: ld a, SFX_STOP_ALL_MUSIC ld [wNewSoundID], a call PlaySound - callba Music_RivalAlternateTempo + farcall Music_RivalAlternateTempo ld a, $2 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a call Route22MoveRivalSprite ld a, $4 ld [wRoute22CurScript], a @@ -261,7 +261,7 @@ Route22Script4: bit 0, a ret nz ld a, $2 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a ld a, [wcf0d] cp $1 jr nz, .asm_510a1 @@ -274,12 +274,12 @@ Route22Script4: ld [wPlayerMovingDirection], a ld a, SPRITE_FACING_RIGHT .asm_510a8 - ld [hSpriteFacingDirection], a + ldh [hSpriteFacingDirection], a call SetSpriteFacingDirectionAndDelay xor a ld [wJoyIgnore], a ld a, $2 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID ld hl, wd72d set 6, [hl] @@ -305,7 +305,7 @@ Route22Script5: cp $ff jp z, Route22Script_50ece ld a, $2 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a ld a, [wcf0d] cp $1 jr nz, .asm_510fb @@ -318,18 +318,18 @@ Route22Script5: ld [wPlayerMovingDirection], a ld a, SPRITE_FACING_RIGHT .asm_51102 - ld [hSpriteFacingDirection], a + ldh [hSpriteFacingDirection], a call SetSpriteFacingDirectionAndDelay ld a, $f0 ld [wJoyIgnore], a SetEvent EVENT_BEAT_ROUTE22_RIVAL_2ND_BATTLE ld a, $2 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID ld a, SFX_STOP_ALL_MUSIC ld [wNewSoundID], a call PlaySound - callba Music_RivalAlternateStartAndTempo + farcall Music_RivalAlternateStartAndTempo ld a, [wcf0d] cp $1 jr nz, .asm_51134 @@ -350,7 +350,7 @@ Route22Script_51142: ld de, MovementData_5114d Route22MoveRival2: ld a, $2 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a jp MoveSprite MovementData_5114c: diff --git a/scripts/Route22Gate.asm b/scripts/Route22Gate.asm index e2311b95..59b7d7a2 100755 --- a/scripts/Route22Gate.asm +++ b/scripts/Route22Gate.asm @@ -22,9 +22,9 @@ Route22GateScript0: call ArePlayerCoordsInArray ret nc xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a ld a, $1 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a jp DisplayTextID Route22GateScriptCoords: diff --git a/scripts/Route23.asm b/scripts/Route23.asm index b617992b..f4d65266 100755 --- a/scripts/Route23.asm +++ b/scripts/Route23.asm @@ -45,7 +45,7 @@ Route23Script0: ret nc .asm_51237 ld a, e - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a ld a, c ld [wWhichBadge], a ld b, FLAG_TEST @@ -57,7 +57,7 @@ Route23Script0: call Route23Script_5125d call DisplayTextID xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a ret YCoordsData_51255: diff --git a/scripts/Route24.asm b/scripts/Route24.asm index f04a43cf..22ef9aab 100755 --- a/scripts/Route24.asm +++ b/scripts/Route24.asm @@ -28,9 +28,9 @@ Route24Script0: call ArePlayerCoordsInArray jp nc, CheckFightingMapTrainers xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a ld a, $1 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID CheckAndResetEvent EVENT_NUGGET_REWARD_AVAILABLE ret z @@ -66,7 +66,7 @@ Route24Script3: ld [wJoyIgnore], a SetEvent EVENT_BEAT_ROUTE24_ROCKET ld a, $1 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID xor a ld [wJoyIgnore], a @@ -162,12 +162,12 @@ Route24Text1: ld hl, Route24Text_5152b ld de, Route24Text_5152b call SaveEndBattleTextPointers - ld a, [hSpriteIndexOrTextID] + ldh a, [hSpriteIndexOrTextID] ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a ld a, $3 ld [wRoute24CurScript], a ld [wCurMapScript], a diff --git a/scripts/Route2Gate.asm b/scripts/Route2Gate.asm index 27da0909..d9d30218 100755 --- a/scripts/Route2Gate.asm +++ b/scripts/Route2Gate.asm @@ -10,9 +10,9 @@ Route2GateText1: CheckEvent EVENT_GOT_HM05 jr nz, .asm_5d60d ld a, 10 ; pokemon needed - ld [hOaksAideRequirement], a + ldh [hOaksAideRequirement], a ld a, HM_FLASH ; oak's aide reward - ld [hOaksAideRewardItem], a + ldh [hOaksAideRewardItem], a ld [wd11e], a call GetItemName ld hl, wcd6d @@ -20,7 +20,7 @@ Route2GateText1: ld bc, ITEM_NAME_LENGTH call CopyData predef OaksAideScript - ld a, [hOaksAideResult] + ldh a, [hOaksAideResult] cp $1 jr nz, .asm_5d613 SetEvent EVENT_GOT_HM05 diff --git a/scripts/Route5Gate.asm b/scripts/Route5Gate.asm index 0bd896f1..f2d45112 100755 --- a/scripts/Route5Gate.asm +++ b/scripts/Route5Gate.asm @@ -25,13 +25,13 @@ Route5GateScript0: ld a, PLAYER_DIR_LEFT ld [wPlayerMovingDirection], a xor a - ld [hJoyHeld], a - callba RemoveGuardDrink - ld a, [hItemToRemoveID] + ldh [hJoyHeld], a + farcall RemoveGuardDrink + ldh a, [hItemToRemoveID] and a jr nz, .asm_1df82 ld a, $2 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID call Route5GateScript_1df43 ld a, $1 @@ -39,7 +39,7 @@ Route5GateScript0: ret .asm_1df82 ld a, $3 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID ld hl, wd728 set 6, [hl] @@ -73,8 +73,8 @@ Route5GateText1: ld a, [wd728] bit 6, a jr nz, .asm_88856 - callba RemoveGuardDrink - ld a, [hItemToRemoveID] + farcall RemoveGuardDrink + ldh a, [hItemToRemoveID] and a jr nz, .asm_768a2 ld hl, Route5GateText2 diff --git a/scripts/Route6Gate.asm b/scripts/Route6Gate.asm index 6e9dd4b3..22d40fd3 100755 --- a/scripts/Route6Gate.asm +++ b/scripts/Route6Gate.asm @@ -19,13 +19,13 @@ Route6GateScript0: ld a, PLAYER_DIR_RIGHT ld [wPlayerMovingDirection], a xor a - ld [hJoyHeld], a - callba RemoveGuardDrink - ld a, [hItemToRemoveID] + ldh [hJoyHeld], a + farcall RemoveGuardDrink + ldh a, [hItemToRemoveID] and a jr nz, .asm_1e080 ld a, $2 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID call Route6GateScript_1e0a1 ld a, $1 @@ -35,7 +35,7 @@ Route6GateScript0: ld hl, wd728 set 6, [hl] ld a, $3 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a jp DisplayTextID CoordsData_1e08c: diff --git a/scripts/Route7Gate.asm b/scripts/Route7Gate.asm index 00d7472f..182dedab 100755 --- a/scripts/Route7Gate.asm +++ b/scripts/Route7Gate.asm @@ -31,13 +31,13 @@ Route7GateScript0: ld a, PLAYER_DIR_UP ld [wPlayerMovingDirection], a xor a - ld [hJoyHeld], a - callba RemoveGuardDrink - ld a, [hItemToRemoveID] + ldh [hJoyHeld], a + farcall RemoveGuardDrink + ldh a, [hItemToRemoveID] and a jr nz, .asm_1e15a ld a, $2 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID call Route7GateScript_1e111 ld a, $1 @@ -45,7 +45,7 @@ Route7GateScript0: ret .asm_1e15a ld a, $3 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID ld hl, wd728 set 6, [hl] diff --git a/scripts/Route8Gate.asm b/scripts/Route8Gate.asm index d3003c4d..9ddaf601 100755 --- a/scripts/Route8Gate.asm +++ b/scripts/Route8Gate.asm @@ -30,13 +30,13 @@ Route8GateScript0: ld a, PLAYER_DIR_LEFT ld [wPlayerMovingDirection], a xor a - ld [hJoyHeld], a - callba RemoveGuardDrink - ld a, [hItemToRemoveID] + ldh [hJoyHeld], a + farcall RemoveGuardDrink + ldh a, [hItemToRemoveID] and a jr nz, .asm_1e220 ld a, $2 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID call Route8GateScript_1e1d7 ld a, $1 @@ -46,7 +46,7 @@ Route8GateScript0: ld hl, wd728 set 6, [hl] ld a, $3 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a jp DisplayTextID CoordsData_1e22c: diff --git a/scripts/SSAnne2F.asm b/scripts/SSAnne2F.asm index 98d4f197..5060f1e1 100755 --- a/scripts/SSAnne2F.asm +++ b/scripts/SSAnne2F.asm @@ -31,19 +31,19 @@ SSAnne2Script0: ld a, MUSIC_MEET_RIVAL call PlayMusic ld a, [wCoordIndex] - ld [hSavedCoordIndex], a + ldh [hSavedCoordIndex], a ld a, HS_SS_ANNE_2F_RIVAL ld [wMissableObjectIndex], a predef ShowObject call Delay3 ld a, $2 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a call SetSpriteMovementBytesToFF xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a ld a, $f0 ld [wJoyIgnore], a - ld a, [hSavedCoordIndex] + ldh a, [hSavedCoordIndex] cp $2 jr nz, .asm_61400 ld de, MovementData_6140c @@ -81,9 +81,9 @@ SSAnne2Script_61416: .asm_61426 xor a ; SPRITE_FACING_DOWN .asm_61427 - ld [hSpriteFacingDirection], a + ldh [hSpriteFacingDirection], a ld a, $2 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a jp SetSpriteFacingDirectionAndDelay SSAnne2Script1: @@ -94,7 +94,7 @@ SSAnne2Script1: xor a ld [wJoyIgnore], a ld a, $2 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID call Delay3 ld a, OPP_SONY2 @@ -129,10 +129,10 @@ SSAnne2Script2: ld a, $f0 ld [wJoyIgnore], a ld a, $3 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID ld a, $2 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a call SetSpriteMovementBytesToFF ld a, [wXCoord] cp $25 @@ -143,12 +143,12 @@ SSAnne2Script2: ld de, MovementData_614b7 .asm_6149a ld a, $2 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a call MoveSprite ld a, SFX_STOP_ALL_MUSIC ld [wNewSoundID], a call PlaySound - callba Music_RivalAlternateStart + farcall Music_RivalAlternateStart ld a, $3 ld [wSSAnne2FCurScript], a ret diff --git a/scripts/SSAnneKitchen.asm b/scripts/SSAnneKitchen.asm index 7334cc69..969c6b7f 100755 --- a/scripts/SSAnneKitchen.asm +++ b/scripts/SSAnneKitchen.asm @@ -39,7 +39,7 @@ SSAnne6Text7: text_asm ld hl, SSAnne6Text_61807 call PrintText - ld a, [hRandomAdd] + ldh a, [hRandomAdd] bit 7, a jr z, .asm_93eb1 ld hl, SSAnne6Text_6180c diff --git a/scripts/SafariZoneGate.asm b/scripts/SafariZoneGate.asm index 76f4faa6..a15a5630 100755 --- a/scripts/SafariZoneGate.asm +++ b/scripts/SafariZoneGate.asm @@ -18,12 +18,12 @@ SafariZoneGate_ScriptPointers: call ArePlayerCoordsInArray ret nc ld a, $3 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID ld a, $ff ld [wJoyIgnore], a xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a ld a, SPRITE_FACING_RIGHT ld [wSpritePlayerStateData1FacingDirection], a ld a, [wCoordIndex] @@ -52,11 +52,11 @@ SafariZoneGate_ScriptPointers: ret nz .SafariZoneEntranceScript2 xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a ld [wJoyIgnore], a call UpdateSprites ld a, $4 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID ld a, $ff ld [wJoyIgnore], a @@ -81,7 +81,7 @@ SafariZoneGate_ScriptPointers: ld a, $f0 ld [wJoyIgnore], a ld a, $6 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID xor a ld [wNumSafariBalls], a @@ -93,7 +93,7 @@ SafariZoneGate_ScriptPointers: jr .asm_75286 .asm_7527f ld a, $5 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID .asm_75286 ret @@ -153,11 +153,11 @@ SafariZoneGate_TextPointers: and a jp nz, .PleaseComeAgain xor a - ld [hMoney], a + ldh [hMoney], a ld a, $05 - ld [hMoney + 1], a + ldh [hMoney + 1], a ld a, $00 - ld [hMoney + 2], a + ldh [hMoney + 2], a call HasEnoughMoney jr nc, .success ld hl, .NotEnoughMoneyText @@ -182,9 +182,9 @@ SafariZoneGate_TextPointers: call PrintText ld a, 30 ld [wNumSafariBalls], a - ld a, 502 / $100 + ld a, HIGH(502) ld [wSafariSteps], a - ld a, 502 % $100 + ld a, LOW(502) ld [wSafariSteps + 1], a ld a, D_UP ld c, 3 diff --git a/scripts/SaffronGym.asm b/scripts/SaffronGym.asm index 88a76253..5f4045ac 100755 --- a/scripts/SaffronGym.asm +++ b/scripts/SaffronGym.asm @@ -44,20 +44,20 @@ SaffronGymScript3: SaffronGymText_5d068: ld a, $a - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID SetEvent EVENT_BEAT_SABRINA lb bc, TM_PSYWAVE, 1 call GiveItem jr nc, .BagFull ld a, $b - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID SetEvent EVENT_GOT_TM46 jr .gymVictory .BagFull ld a, $c - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID .gymVictory ld hl, wObtainedBadges @@ -171,7 +171,7 @@ SaffronGymText1: ld hl, SaffronGymText_5d167 ld de, SaffronGymText_5d167 call SaveEndBattleTextPointers - ld a, [hSpriteIndex] + ldh a, [hSpriteIndex] ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters diff --git a/scripts/SilphCo10F.asm b/scripts/SilphCo10F.asm index 140584f1..8fa53319 100755 --- a/scripts/SilphCo10F.asm +++ b/scripts/SilphCo10F.asm @@ -28,7 +28,7 @@ SilphCo10GateCoords: db $FF SilphCo10Text_5a176: - ld a, [hUnlockedSilphCoDoors] + ldh a, [hUnlockedSilphCoDoors] and a ret z SetEvent EVENT_SILPH_CO_10_UNLOCKED_DOOR diff --git a/scripts/SilphCo11F.asm b/scripts/SilphCo11F.asm index a2c540fe..4b54bf48 100755 --- a/scripts/SilphCo11F.asm +++ b/scripts/SilphCo11F.asm @@ -35,7 +35,7 @@ SilphCo11Script_62137: ld a, [hl] ld c, a xor a - ld [hUnlockedSilphCoDoors], a + ldh [hUnlockedSilphCoDoors], a pop hl .asm_62143 ld a, [hli] @@ -60,11 +60,11 @@ SilphCo11Script_62137: ret .asm_6215f xor a - ld [hUnlockedSilphCoDoors], a + ldh [hUnlockedSilphCoDoors], a ret SilphCo11Script_62163: - ld a, [hUnlockedSilphCoDoors] + ldh a, [hUnlockedSilphCoDoors] and a ret z SetEvent EVENT_SILPH_CO_11_UNLOCKED_DOOR @@ -171,14 +171,14 @@ SilphCo11Script0: ld a, [wCoordIndex] ld [wcf0d], a xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a ld a, $f0 ld [wJoyIgnore], a ld a, $3 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID ld a, $3 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a call SetSpriteMovementBytesToFF ld de, MovementData_62216 call MoveSprite @@ -199,9 +199,9 @@ MovementData_62216: SilphCo11Script_6221a: ld [wPlayerMovingDirection], a ld a, $3 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a ld a, b - ld [hSpriteFacingDirection], a + ldh [hSpriteFacingDirection], a jp SetSpriteFacingDirectionAndDelay SilphCo11Script5: @@ -222,7 +222,7 @@ SilphCo11Script5: ld a, $f0 ld [wJoyIgnore], a ld a, $6 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID call GBFadeOutToBlack call SilphCo11Script_6216d @@ -239,7 +239,7 @@ SilphCo11Script3: bit 0, a ret nz ld a, $3 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a call SetSpriteMovementBytesToFF ld a, [wcf0d] cp $1 @@ -263,7 +263,7 @@ SilphCo11Script4: ld hl, SilphCo10Text_62330 ld de, SilphCo10Text_62330 call SaveEndBattleTextPointers - ld a, [hSpriteIndex] + ldh a, [hSpriteIndex] ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters diff --git a/scripts/SilphCo2F.asm b/scripts/SilphCo2F.asm index 212d0b90..42e5a7e6 100755 --- a/scripts/SilphCo2F.asm +++ b/scripts/SilphCo2F.asm @@ -45,7 +45,7 @@ SilphCo2Script_59d43: ld a, [hl] ld c, a xor a - ld [hUnlockedSilphCoDoors], a + ldh [hUnlockedSilphCoDoors], a pop hl .asm_59d4f ld a, [hli] @@ -70,12 +70,12 @@ SilphCo2Script_59d43: ret .asm_59d6b xor a - ld [hUnlockedSilphCoDoors], a + ldh [hUnlockedSilphCoDoors], a ret SilphCo2Script_59d6f: EventFlagAddress hl, EVENT_SILPH_CO_2_UNLOCKED_DOOR1 - ld a, [hUnlockedSilphCoDoors] + ldh a, [hUnlockedSilphCoDoors] and a ret z cp $1 diff --git a/scripts/SilphCo3F.asm b/scripts/SilphCo3F.asm index ddd40048..2a086708 100755 --- a/scripts/SilphCo3F.asm +++ b/scripts/SilphCo3F.asm @@ -39,7 +39,7 @@ SilphCo3GateCoords: SilphCo3Script_59fad: EventFlagAddress hl, EVENT_SILPH_CO_3_UNLOCKED_DOOR1 - ld a, [hUnlockedSilphCoDoors] + ldh a, [hUnlockedSilphCoDoors] and a ret z cp $1 diff --git a/scripts/SilphCo4F.asm b/scripts/SilphCo4F.asm index 523336c0..e148447b 100755 --- a/scripts/SilphCo4F.asm +++ b/scripts/SilphCo4F.asm @@ -45,7 +45,7 @@ SilphCo4Script_19d5d: ld a, [hl] ld c, a xor a - ld [hUnlockedSilphCoDoors], a + ldh [hUnlockedSilphCoDoors], a pop hl .asm_19d69 ld a, [hli] @@ -70,12 +70,12 @@ SilphCo4Script_19d5d: ret .asm_19d85 xor a - ld [hUnlockedSilphCoDoors], a + ldh [hUnlockedSilphCoDoors], a ret SilphCo4Script_19d89: EventFlagAddress hl, EVENT_SILPH_CO_4_UNLOCKED_DOOR1 - ld a, [hUnlockedSilphCoDoors] + ldh a, [hUnlockedSilphCoDoors] and a ret z cp $1 diff --git a/scripts/SilphCo5F.asm b/scripts/SilphCo5F.asm index 653390c7..4d4f6ab6 100755 --- a/scripts/SilphCo5F.asm +++ b/scripts/SilphCo5F.asm @@ -49,7 +49,7 @@ SilphCo5GateCoords: SilphCo5Script_19f9e: EventFlagAddress hl, EVENT_SILPH_CO_5_UNLOCKED_DOOR1 - ld a, [hUnlockedSilphCoDoors] + ldh a, [hUnlockedSilphCoDoors] and a ret z cp $1 diff --git a/scripts/SilphCo6F.asm b/scripts/SilphCo6F.asm index 0d393b6e..30a0d83e 100755 --- a/scripts/SilphCo6F.asm +++ b/scripts/SilphCo6F.asm @@ -28,7 +28,7 @@ SilphCo6GateCoords: db $FF SilphCo6Script_1a1e6: - ld a, [hUnlockedSilphCoDoors] + ldh a, [hUnlockedSilphCoDoors] and a ret z SetEvent EVENT_SILPH_CO_6_UNLOCKED_DOOR diff --git a/scripts/SilphCo7F.asm b/scripts/SilphCo7F.asm index 966a18d9..dae0f96b 100755 --- a/scripts/SilphCo7F.asm +++ b/scripts/SilphCo7F.asm @@ -55,7 +55,7 @@ SilphCo7Text_51bc8: ld a, [hl] ld c, a xor a - ld [hUnlockedSilphCoDoors], a + ldh [hUnlockedSilphCoDoors], a pop hl .asm_51bd4 ld a, [hli] @@ -80,12 +80,12 @@ SilphCo7Text_51bc8: ret .asm_51bf0 xor a - ld [hUnlockedSilphCoDoors], a + ldh [hUnlockedSilphCoDoors], a ret SilphCo7Text_51bf4: EventFlagAddress hl, EVENT_SILPH_CO_7_UNLOCKED_DOOR1 - ld a, [hUnlockedSilphCoDoors] + ldh a, [hUnlockedSilphCoDoors] and a ret z cp $1 @@ -125,7 +125,7 @@ SilphCo7Script0: call ArePlayerCoordsInArray jp nc, CheckFightingMapTrainers xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a ld a, $f0 ld [wJoyIgnore], a ld a, PLAYER_DIR_DOWN @@ -137,10 +137,10 @@ SilphCo7Script0: ld a, MUSIC_MEET_RIVAL call PlayMusic ld a, $9 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID ld a, $9 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a call SetSpriteMovementBytesToFF ld de, MovementData_51c7d ld a, [wCoordIndex] @@ -150,7 +150,7 @@ SilphCo7Script0: inc de .asm_51c6c ld a, $9 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a call MoveSprite ld a, $3 jp SilphCo7Text_51c10 @@ -174,7 +174,7 @@ SilphCo7Script3: xor a ld [wJoyIgnore], a ld a, $d - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID call Delay3 ld hl, wd72d @@ -212,17 +212,17 @@ SilphCo7Script4: ld a, PLAYER_DIR_DOWN ld [wPlayerMovingDirection], a ld a, $9 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a ld a, SPRITE_FACING_UP - ld [hSpriteFacingDirection], a + ldh [hSpriteFacingDirection], a call SetSpriteFacingDirectionAndDelay ld a, $f - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID ld a, SFX_STOP_ALL_MUSIC ld [wNewSoundID], a call PlaySound - callba Music_RivalAlternateStart + farcall Music_RivalAlternateStart ld de, MovementData_51d1d ld a, [wcf0d] cp $1 @@ -230,7 +230,7 @@ SilphCo7Script4: ld de, MovementData_51d1a .asm_51d0e ld a, $9 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a call MoveSprite ld a, $5 jp SilphCo7Text_51c10 diff --git a/scripts/SilphCo8F.asm b/scripts/SilphCo8F.asm index 71e529a6..0a10781e 100755 --- a/scripts/SilphCo8F.asm +++ b/scripts/SilphCo8F.asm @@ -35,7 +35,7 @@ SilphCo8Script_56541: ld a, [hl] ld c, a xor a - ld [hUnlockedSilphCoDoors], a + ldh [hUnlockedSilphCoDoors], a pop hl .asm_5654d ld a, [hli] @@ -60,11 +60,11 @@ SilphCo8Script_56541: ret .asm_56569 xor a - ld [hUnlockedSilphCoDoors], a + ldh [hUnlockedSilphCoDoors], a ret SilphCo8Script_5656d: - ld a, [hUnlockedSilphCoDoors] + ldh a, [hUnlockedSilphCoDoors] and a ret z SetEvent EVENT_SILPH_CO_8_UNLOCKED_DOOR diff --git a/scripts/SilphCo9F.asm b/scripts/SilphCo9F.asm index e1676bf2..7889e8f7 100755 --- a/scripts/SilphCo9F.asm +++ b/scripts/SilphCo9F.asm @@ -65,7 +65,7 @@ SilphCo9Script_5d837: ld a, [hl] ld c, a xor a - ld [hUnlockedSilphCoDoors], a + ldh [hUnlockedSilphCoDoors], a pop hl .asm_5d843 ld a, [hli] @@ -90,12 +90,12 @@ SilphCo9Script_5d837: ret .asm_5d85f xor a - ld [hUnlockedSilphCoDoors], a + ldh [hUnlockedSilphCoDoors], a ret SilphCo9Script_5d863: EventFlagAddress hl, EVENT_SILPH_CO_9_UNLOCKED_DOOR1 - ld a, [hUnlockedSilphCoDoors] + ldh a, [hUnlockedSilphCoDoors] and a ret z cp $1 diff --git a/scripts/SilphCoElevator.asm b/scripts/SilphCoElevator.asm index 3ff507c7..e660cd0f 100755 --- a/scripts/SilphCoElevator.asm +++ b/scripts/SilphCoElevator.asm @@ -74,7 +74,7 @@ SilphCoElevatorWarpMapsEnd: SilphCoElevatorScript_45827: call Delay3 - callba ShakeElevator + farcall ShakeElevator ret SilphCoElevator_TextPointers: diff --git a/scripts/TradeCenter.asm b/scripts/TradeCenter.asm index e7fa8ac8..b91996e0 100755 --- a/scripts/TradeCenter.asm +++ b/scripts/TradeCenter.asm @@ -1,14 +1,14 @@ TradeCenter_Script: call EnableAutoTextBoxDrawing - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] cp USING_INTERNAL_CLOCK ld a, SPRITE_FACING_LEFT jr z, .next ld a, SPRITE_FACING_RIGHT .next - ld [hSpriteFacingDirection], a + ldh [hSpriteFacingDirection], a ld a, $1 - ld [hSpriteIndex], a + ldh [hSpriteIndex], a call SetSpriteFacingDirection ld hl, wd72d bit 0, [hl] @@ -21,7 +21,7 @@ TradeCenter_Script: ld [hl], a ld a, SPRITE_FACING_LEFT ld [wSprite01StateData1FacingDirection], a - ld a, [hSerialConnectionStatus] + ldh a, [hSerialConnectionStatus] cp USING_INTERNAL_CLOCK ret z ld a, $7 diff --git a/scripts/VermilionCity.asm b/scripts/VermilionCity.asm index 127ee16a..9178cd65 100755 --- a/scripts/VermilionCity.asm +++ b/scripts/VermilionCity.asm @@ -15,7 +15,7 @@ VermilionCity_Script: .setFirstLockTrashCanIndex call Random - ld a, [hRandomSub] + ldh a, [hRandomSub] and $e ld [wFirstLockTrashCanIndex], a ret @@ -45,10 +45,10 @@ VermilionCityScript0: call ArePlayerCoordsInArray ret nc xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a ld [wcf0d], a ld a, $3 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID CheckEvent EVENT_SS_ANNE_LEFT jr nz, .shipHasDeparted @@ -98,7 +98,7 @@ VermilionCityScript3: ret nz xor a ld [wJoyIgnore], a - ld [hJoyHeld], a + ldh [hJoyHeld], a ld a, $0 ld [wVermilionCityCurScript], a ret diff --git a/scripts/VermilionDock.asm b/scripts/VermilionDock.asm index 2c39bdb8..9dc4b2b9 100755 --- a/scripts/VermilionDock.asm +++ b/scripts/VermilionDock.asm @@ -45,24 +45,24 @@ VermilionDock_1db9b: ld c, BANK(Music_Surfing) ld a, MUSIC_SURFING call PlayMusic - callba LoadSmokeTileFourTimes + farcall LoadSmokeTileFourTimes xor a ld [wSpritePlayerStateData1ImageIndex], a ld c, 120 call DelayFrames ld b, $9c call CopyScreenTileBufferToVRAM - coord hl, 0, 10 + hlcoord 0, 10 ld bc, SCREEN_WIDTH * 6 ld a, $14 ; water tile call FillMemory ld a, 1 - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a call Delay3 xor a - ld [hAutoBGTransferEnabled], a + ldh [hAutoBGTransferEnabled], a ld [wSSAnneSmokeDriftAmount], a - ld [rOBP1], a + ldh [rOBP1], a ld a, 88 ld [wSSAnneSmokeX], a ld hl, wMapViewVRAMPointer @@ -104,11 +104,11 @@ VermilionDock_1db9b: dec e jr nz, .asm_1dbfa xor a - ld [rWY], a - ld [hWY], a + ldh [rWY], a + ldh [hWY], a call VermilionDock_EraseSSAnne ld a, $90 - ld [hWY], a + ldh [hWY], a ld a, $1 ld [wUpdateSpritesEnabled], a pop hl @@ -167,13 +167,13 @@ VermilionDock_1dc7c: ld h, $0 ld l, $80 .asm_1dc86 - ld a, [rLY] + ldh a, [rLY] cp l jr nz, .asm_1dc86 ld a, h - ld [rSCX], a + ldh [rSCX], a .asm_1dc8e - ld a, [rLY] + ldh a, [rLY] cp h jr z, .asm_1dc8e ret @@ -184,7 +184,7 @@ VermilionDock_EraseSSAnne: ld bc, (5 * BG_MAP_WIDTH) + SCREEN_WIDTH ld a, $14 ; water tile call FillMemory - ld hl, vBGMap0 + 10 * BG_MAP_WIDTH + hlbgcoord 0, 10 ld de, wVermilionDockTileMapBuffer ld bc, (6 * BG_MAP_WIDTH) / 16 call CopyVideoData @@ -194,7 +194,7 @@ VermilionDock_EraseSSAnne: ; the blocks is unnecessary because the blocks the ship occupies are south of ; the player and won't be redrawn when the player automatically walks north and ; exits the map. This code could be removed without affecting anything. - overworldMapCoord hl, 5, 2, VERMILION_DOCK_WIDTH + hlowcoord 5, 2, VERMILION_DOCK_WIDTH ld a, $d ; water block ld [hli], a ld [hli], a diff --git a/scripts/VermilionGym.asm b/scripts/VermilionGym.asm index 10967cbe..45b200e2 100755 --- a/scripts/VermilionGym.asm +++ b/scripts/VermilionGym.asm @@ -63,20 +63,20 @@ VermilionGymLTSurgePostBattle: VermilionGymReceiveTM24: ld a, $6 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID SetEvent EVENT_BEAT_LT_SURGE lb bc, TM_THUNDERBOLT, 1 call GiveItem jr nc, .BagFull ld a, $7 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID SetEvent EVENT_GOT_TM24 jr .gymVictory .BagFull ld a, $8 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID .gymVictory ld hl, wObtainedBadges @@ -150,14 +150,14 @@ LTSurgeText: ld hl, ReceivedThunderbadgeText ld de, ReceivedThunderbadgeText call SaveEndBattleTextPointers - ld a, [hSpriteIndex] + ldh a, [hSpriteIndex] ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters ld a, $3 ld [wGymLeaderNo], a xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a ld a, $3 ; set script index to LT Surge post-battle script ld [wVermilionGymCurScript], a ld [wCurMapScript], a diff --git a/scripts/ViridianCity.asm b/scripts/ViridianCity.asm index 2a86374e..62d98c4c 100755 --- a/scripts/ViridianCity.asm +++ b/scripts/ViridianCity.asm @@ -30,10 +30,10 @@ ViridianCityScript_1900b: cp $20 ret nz ld a, $e - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a call ViridianCityScript_190cf ld a, $3 ld [wViridianCityCurScript], a @@ -49,10 +49,10 @@ ViridianCityScript_1903d: cp $13 ret nz ld a, $5 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID xor a - ld [hJoyHeld], a + ldh [hJoyHeld], a call ViridianCityScript_190cf ld a, $3 ld [wViridianCityCurScript], a @@ -60,13 +60,13 @@ ViridianCityScript_1903d: ViridianCityScript1: ld a, [wSprite03StateData1YPixels] - ld [hSpriteScreenYCoord], a + ldh [hSpriteScreenYCoord], a ld a, [wSprite03StateData1XPixels] - ld [hSpriteScreenXCoord], a + ldh [hSpriteScreenXCoord], a ld a, [wSprite03StateData2MapY] - ld [hSpriteMapYCoord], a + ldh [hSpriteMapYCoord], a ld a, [wSprite03StateData2MapX] - ld [hSpriteMapXCoord], a + ldh [hSpriteMapXCoord], a xor a ld [wListScrollOffset], a @@ -82,20 +82,20 @@ ViridianCityScript1: ret ViridianCityScript2: - ld a, [hSpriteScreenYCoord] + ldh a, [hSpriteScreenYCoord] ld [wSprite03StateData1YPixels], a - ld a, [hSpriteScreenXCoord] + ldh a, [hSpriteScreenXCoord] ld [wSprite03StateData1XPixels], a - ld a, [hSpriteMapYCoord] + ldh a, [hSpriteMapYCoord] ld [wSprite03StateData2MapY], a - ld a, [hSpriteMapXCoord] + ldh a, [hSpriteMapXCoord] ld [wSprite03StateData2MapX], a call UpdateSprites call Delay3 xor a ld [wJoyIgnore], a ld a, $f - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID xor a ld [wBattleType], a diff --git a/scripts/ViridianGym.asm b/scripts/ViridianGym.asm index 05430332..80f19f3a 100755 --- a/scripts/ViridianGym.asm +++ b/scripts/ViridianGym.asm @@ -128,7 +128,7 @@ ViridianGymScript4: ld [wCurMapScript], a ret .asm_74980 - jpba LoadSpinnerArrowTiles + farjp LoadSpinnerArrowTiles ViridianGymScript3: ld a, [wIsInBattle] @@ -138,20 +138,20 @@ ViridianGymScript3: ld [wJoyIgnore], a ViridianGymScript3_74995: ld a, $c - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID SetEvent EVENT_BEAT_VIRIDIAN_GYM_GIOVANNI lb bc, TM_FISSURE, 1 call GiveItem jr nc, .BagFull ld a, $d - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID SetEvent EVENT_GOT_TM27 jr .gymVictory .BagFull ld a, $e - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID .gymVictory ld hl, wObtainedBadges @@ -289,7 +289,7 @@ ViridianGymText1: ld hl, ViridianGymText_74ad3 ld de, ViridianGymText_74ad3 call SaveEndBattleTextPointers - ld a, [hSpriteIndex] + ldh a, [hSpriteIndex] ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters diff --git a/scripts/ViridianMart.asm b/scripts/ViridianMart.asm index 09ddfda9..ea1c373f 100755 --- a/scripts/ViridianMart.asm +++ b/scripts/ViridianMart.asm @@ -27,7 +27,7 @@ ViridianMart_ScriptPointers: ViridianMartScript0: call UpdateSprites ld a, $4 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID ld hl, wSimulatedJoypadStatesEnd ld de, RLEMovement1d4bb @@ -50,7 +50,7 @@ ViridianMartScript1: ret nz call Delay3 ld a, $5 - ld [hSpriteIndexOrTextID], a + ldh [hSpriteIndexOrTextID], a call DisplayTextID lb bc, OAKS_PARCEL, 1 call GiveItem diff --git a/scripts/WardensHouse.asm b/scripts/WardensHouse.asm index 474ba320..6705a450 100755 --- a/scripts/WardensHouse.asm +++ b/scripts/WardensHouse.asm @@ -32,8 +32,8 @@ FuchsiaHouse2Text1: ld hl, WardenTeethText1 call PrintText ld a, GOLD_TEETH - ld [hItemToRemoveID], a - callba RemoveItemByID + ldh [hItemToRemoveID], a + farcall RemoveItemByID SetEvent EVENT_GAVE_GOLD_TEETH .asm_60cba ld hl, WardenThankYouText @@ -95,7 +95,7 @@ HM04NoRoomText: FuchsiaHouse2Text5: FuchsiaHouse2Text4: text_asm - ld a, [hSpriteIndex] + ldh a, [hSpriteIndex] cp $4 ld hl, FuchsiaHouse2Text_7517b jr nz, .asm_4c9a2 @@ -270,7 +270,7 @@ SECTION "Text 11", ROMX INCLUDE "data/text/text_7.asm" -SECTION "Pokedex Text", ROMX +SECTION "Pokédex Text", ROMX INCLUDE "data/pokemon/dex_text.asm" @@ -1,21 +1,31 @@ -vChars0 EQU $8000 -vChars1 EQU $8800 -vChars2 EQU $9000 -vBGMap0 EQU $9800 -vBGMap1 EQU $9c00 +SECTION "VRAM", VRAM -; Battle/Menu -vSprites EQU vChars0 -vFont EQU vChars1 -vFrontPic EQU vChars2 -vBackPic EQU vFrontPic + 7 * 7 * $10 +UNION +; generic +vChars0:: ds $800 +vChars1:: ds $800 +vChars2:: ds $800 +vBGMap0:: ds $400 +vBGMap1:: ds $400 -; Overworld -vNPCSprites EQU vChars0 -vNPCSprites2 EQU vChars1 -vTileset EQU vChars2 +NEXTU +; battle/menu +vSprites:: ds $800 +vFont:: ds $800 +vFrontPic:: ds 7 * 7 * $10 +vBackPic:: ds 7 * 7 * $10 -; Title -vTitleLogo EQU vChars1 -vTitleLogo2 EQU vFrontPic + 7 * 7 * $10 +NEXTU +; overworld +vNPCSprites:: ds $800 +vNPCSprites2:: ds $800 +vTileset:: ds $800 +NEXTU +; title + ds $800 +vTitleLogo:: ds $800 + ds 7 * 7 * $10 +vTitleLogo2:: ds $1e0 + +ENDU @@ -3,7 +3,10 @@ INCLUDE "constants.asm" INCLUDE "macros/wram.asm" -SECTION "WRAM Bank 0", WRAM0 +INCLUDE "vram.asm" + + +SECTION "WRAM", WRAM0 wUnusedC000:: ds 1 @@ -155,22 +158,23 @@ wSpriteStateData1:: ; data for all sprites on the current map ; holds info for 16 sprites with $10 bytes each ; player sprite is always sprite 0 -; C1x0: picture ID (fixed, loaded at map init) -; C1x1: movement status (0: uninitialized, 1: ready, 2: delayed, 3: moving) -; C1x2: sprite image index (changed on update, $ff if off screen, includes facing direction, progress in walking animation and a sprite-specific offset) -; C1x3: Y screen position delta (-1,0 or 1; added to c1x4 on each walking animation update) -; C1x4: Y screen position (in pixels, always 4 pixels above grid which makes sprites appear to be in the center of a tile) -; C1x5: X screen position delta (-1,0 or 1; added to c1x6 on each walking animation update) -; C1x6: X screen position (in pixels, snaps to grid if not currently walking) -; C1x7: intra-animation-frame counter (counting upwards to 4 until c1x8 is incremented) -; C1x8: animation frame counter (increased every 4 updates, hold four states (totalling to 16 walking frames) -; C1x9: facing direction (0: down, 4: up, 8: left, $c: right) -; C1xA -; C1xB -; C1xC -; C1xD -; C1xE -; C1xF +; struct fields: +; - 0: picture ID (fixed, loaded at map init) +; - 1: movement status (0: uninitialized, 1: ready, 2: delayed, 3: moving) +; - 2: sprite image index (changed on update, $ff if off screen, includes facing direction, progress in walking animation and a sprite-specific offset) +; - 3: Y screen position delta (-1,0 or 1; added to Y pixels on each walking animation update) +; - 4: Y screen position (in pixels, always 4 pixels above grid which makes sprites appear to be in the center of a tile) +; - 5: X screen position delta (-1,0 or 1; added to field X pixels on each walking animation update) +; - 6: X screen position (in pixels, snaps to grid if not currently walking) +; - 7: intra-animation-frame counter (counting upwards to 4 until animation frame counter is incremented) +; - 8: animation frame counter (increased every 4 updates, hold four states (totalling to 16 walking frames) +; - 9: facing direction ($0: down, $4: up, $8: left, $c: right) +; - A: adjusted Y coordinate +; - B: adjusted X coordinate +; - C: direction of collision +; - D +; - E +; - F wSpritePlayerStateData1:: spritestatedata1 wSpritePlayerStateData1 wSprite01StateData1:: spritestatedata1 wSprite01StateData1 wSprite02StateData1:: spritestatedata1 wSprite02StateData1 @@ -192,22 +196,23 @@ wSpriteStateData2:: ; more data for all sprites on the current map ; holds info for 16 sprites with $10 bytes each ; player sprite is always sprite 0 -; C2x0: walk animation counter (counting from $10 backwards when moving) -; C2x1: -; C2x2: Y displacement (initialized at 8, supposed to keep moving sprites from moving too far, but bugged) -; C2x3: X displacement (initialized at 8, supposed to keep moving sprites from moving too far, but bugged) -; C2x4: Y position (in 2x2 tile grid steps, topmost 2x2 tile has value 4) -; C2x5: X position (in 2x2 tile grid steps, leftmost 2x2 tile has value 4) -; C2x6: movement byte 1 (determines whether a sprite can move, $ff:not moving, $fe:random movements, others unknown) -; C2x7: (?) (set to $80 when in grass, else $0; may be used to draw grass above the sprite) -; C2x8: delay until next movement (counted downwards, status (c1x1) is set to ready if reached 0) -; C2x9 -; C2xA -; C2xB -; C2xC -; C2xD -; C2xE: sprite image base offset (in video ram, player always has value 1, used to compute c1x2) -; C2xF +; struct fields: +; - 0: walk animation counter (counting from $10 backwards when moving) +; - 1: +; - 2: Y displacement (initialized at 8, supposed to keep moving sprites from moving too far, but bugged) +; - 3: X displacement (initialized at 8, supposed to keep moving sprites from moving too far, but bugged) +; - 4: Y position (in 2x2 tile grid steps, topmost 2x2 tile has value 4) +; - 5: X position (in 2x2 tile grid steps, leftmost 2x2 tile has value 4) +; - 6: movement byte 1 (determines whether a sprite can move, $ff:not moving, $fe:random movements, others unknown) +; - 7: (?) (set to $80 when in grass, else $0; may be used to draw grass above the sprite) +; - 8: delay until next movement (counted downwards, movement status is set to ready if reached 0) +; - 9: original facing direction (backed up by DisplayTextIDInit, restored by CloseTextDisplay) +; - A +; - B +; - C +; - D: picture ID +; - E: sprite image base offset (in video ram, player always has value 1, used to compute sprite image index) +; - F wSpritePlayerStateData2:: spritestatedata2 wSpritePlayerStateData2 wSprite01StateData2:: spritestatedata2 wSprite01StateData2 wSprite02StateData2:: spritestatedata2 wSprite02StateData2 @@ -2292,7 +2297,7 @@ wCurrentTileBlockMapViewPointer:: ds 2 wYCoord:: -; player’s position on the current map +; player's position on the current map ds 1 wXCoord:: @@ -2574,7 +2579,7 @@ wMissableObjectFlagsEnd:: ds 7 -wd5cd:: ds 1 ; temp copy of c1x2 (sprite facing/anim) +wd5cd:: ds 1 ; temp copy of SPRITESTATEDATA1_IMAGEINDEX (used for sprite facing/anim) wMissableObjectList:: ; each entry consists of 2 bytes @@ -3112,3 +3117,5 @@ wStack:: INCLUDE "sram.asm" + +INCLUDE "hram.asm" |