diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4f1e352f36..968b5026b4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,7 +16,7 @@ jobs: uses: actions/checkout@master with: path: rgbds - ref: v0.9.2 + ref: v1.0.0 repository: gbdev/rgbds - name: Install rgbds diff --git a/.rgbds-version b/.rgbds-version new file mode 100644 index 0000000000..3eefcb9dd5 --- /dev/null +++ b/.rgbds-version @@ -0,0 +1 @@ +1.0.0 diff --git a/INSTALL.md b/INSTALL.md index b4179a7f10..47cca55660 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -44,9 +44,9 @@ Run setup and leave the default settings. At the "**Select Packages**" step, cho Double click on the text that says "**Skip**" next to each package to select the most recent version to install. -Then follow the [**rgbds** install instructions](https://rgbds.gbdev.io/install#pre-built) for Windows with Cygwin to install **rgbds 0.9.2**. +Then follow the [**rgbds** install instructions](https://rgbds.gbdev.io/install#pre-built) for Windows with Cygwin to install **rgbds 1.0.0**. -**Note:** If you already have an installed rgbds older than 0.9.2, you will need to update to 0.9.2. Ignore this if you have never installed rgbds before. If a version newer than 0.9.2 does not work, try downloading 0.9.2. +**Note:** If you already have an installed rgbds older than 1.0.0, you will need to update to 1.0.0. Ignore this if you have never installed rgbds before. If a version newer than 1.0.0 does not work, try downloading 1.0.0. Now open the **Cygwin terminal** and enter the following commands. @@ -69,7 +69,7 @@ Install [**Homebrew**](https://brew.sh/). Follow the official instructions. Open **Terminal** and prepare to enter commands. -Then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install#pre-built) for macOS to install **rgbds 0.9.2**. +Then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install#pre-built) for macOS to install **rgbds 1.0.0**. Now you're ready to [build **pokered**](#build-pokered). @@ -86,7 +86,7 @@ To install the software required for **pokered**: sudo apt-get install make gcc git ``` -Then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install#building-from-source) to build **rgbds 0.9.2** from source. +Then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install#building-from-source) to build **rgbds 1.0.0** from source. ### OpenSUSE @@ -96,7 +96,7 @@ To install the software required for **pokered**: sudo zypper install make gcc git ``` -Then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install#building-from-source) to build **rgbds 0.9.2** from source. +Then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install#building-from-source) to build **rgbds 1.0.0** from source. ### Arch Linux @@ -106,7 +106,7 @@ To install the software required for **pokered**: sudo pacman -S make gcc git rgbds ``` -If you want to compile and install **rgbds** yourself instead, then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install#building-from-source) to build **rgbds 0.9.2** from source. +If you want to compile and install **rgbds** yourself instead, then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install#building-from-source) to build **rgbds 1.0.0** from source. ### Termux @@ -122,7 +122,7 @@ To install **rgbds**: pkg install rgbds ``` -If you want to compile and install **rgbds** yourself instead, then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install#building-from-source) to build **rgbds 0.9.2** from source. +If you want to compile and install **rgbds** yourself instead, then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install#building-from-source) to build **rgbds 1.0.0** from source. ### Other distros @@ -133,7 +133,7 @@ If your distro is not listed here, try to find the required software in its repo - `git` - `rgbds` -If `rgbds` is not available, you'll need to follow the [**rgbds** instructions](https://rgbds.gbdev.io/install#building-from-source) to build **rgbds 0.9.2** from source. +If `rgbds` is not available, you'll need to follow the [**rgbds** instructions](https://rgbds.gbdev.io/install#building-from-source) to build **rgbds 1.0.0** from source. Now you're ready to [build **pokered**](#build-pokered). @@ -155,8 +155,8 @@ make ### Build with a local rgbds version -If you have different projects that require different versions of `rgbds`, it might not be convenient to install rgbds 0.9.2 globally. Instead, you can put its files in a directory within pokered, such as `pokered/rgbds-0.9.2/`. Then specify it when you run `make`: +If you have different projects that require different versions of `rgbds`, it might not be convenient to install rgbds 1.0.0 globally. Instead, you can put its files in a directory within pokered, such as `pokered/rgbds-1.0.0/`. Then specify it when you run `make`: ```bash -make RGBDS=rgbds-0.9.2/ +make RGBDS=rgbds-1.0.0/ ``` diff --git a/Makefile b/Makefile index 7a3979253d..27bc2ef3c4 100644 --- a/Makefile +++ b/Makefile @@ -40,6 +40,11 @@ RGBFIX ?= $(RGBDS)rgbfix RGBGFX ?= $(RGBDS)rgbgfx RGBLINK ?= $(RGBDS)rgblink +RGBASMFLAGS ?= -Weverything -Wtruncation=1 +RGBLINKFLAGS ?= -Weverything -Wtruncation=1 +RGBFIXFLAGS ?= -Weverything +RGBGFXFLAGS ?= -Weverything + ### Build targets @@ -47,7 +52,18 @@ RGBLINK ?= $(RGBDS)rgblink .SECONDEXPANSION: .PRECIOUS: .SECONDARY: -.PHONY: all red blue green blue_debug clean tidy compare tools +.PHONY: \ + all \ + red \ + blue \ + green \ + blue_debug \ + red_vc \ + blue_vc \ + clean \ + tidy \ + compare \ + tools all: $(roms) red: pokered.gbc @@ -89,7 +105,7 @@ tools: $(MAKE) -C tools/ -RGBASMFLAGS = -Q8 -P includes.asm -Weverything -Wtruncation=1 +RGBASMFLAGS += -Q8 -P includes.asm # Create a sym/map for debug purposes if `make` run with `DEBUG=1` ifeq ($(DEBUG),1) RGBASMFLAGS += -E @@ -134,26 +150,24 @@ $(foreach obj, $(pokeblue_vc_obj), $(eval $(call DEP,$(obj),$(obj:_blue_vc.o=.as endif -%.asm: ; - - -pokered_pad = 0x00 -pokeblue_pad = 0x00 -pokegreen_pad = 0x00 -pokered_vc_pad = 0x00 -pokeblue_vc_pad = 0x00 -pokeblue_debug_pad = 0xff +pokered.gbc: RGBLINKFLAGS += -p 0x00 +pokeblue.gbc: RGBLINKFLAGS += -p 0x00 +pokeblue_debug.gbc: RGBLINKFLAGS += -p 0xff +pokered_vc.gbc: RGBLINKFLAGS += -p 0x00 +pokeblue_vc.gbc: RGBLINKFLAGS += -p 0x00 -pokered_opt = -cjsv -n 0 -k 01 -l 0x33 -m MBC3+RAM+BATTERY -r 03 -t "POKEMON RED" -pokeblue_opt = -cjsv -n 0 -k 01 -l 0x33 -m MBC3+RAM+BATTERY -r 03 -t "POKEMON BLUE" -pokegreen_opt = -cjsv -n 0 -k 01 -l 0x33 -m MBC3+RAM+BATTERY -r 03 -t "POKEMON GREEN" -pokeblue_debug_opt = -cjsv -n 0 -k 01 -l 0x33 -m MBC3+RAM+BATTERY -r 03 -t "POKEMON BLUE" -pokered_vc_opt = -cjsv -n 0 -k 01 -l 0x33 -m MBC3+RAM+BATTERY -r 03 -t "POKEMON RED" -pokeblue_vc_opt = -cjsv -n 0 -k 01 -l 0x33 -m MBC3+RAM+BATTERY -r 03 -t "POKEMON BLUE" +RGBFIXFLAGS += -cjsv -n 0 -k 01 -l 0x33 -m MBC3+RAM+BATTERY -r 03 +pokered.gbc: RGBFIXFLAGS += -p 0x00 -t "POKEMON RED" +pokeblue.gbc: RGBFIXFLAGS += -p 0x00 -t "POKEMON BLUE" +pokegreen.gbc: RGBFIXFLAGS += -p 0x00 -t "POKEMON GREEN" +pokeblue_debug.gbc: RGBFIXFLAGS += -p 0xff -t "POKEMON BLUE" + RGBLINKFLAGS+= -p 0xff +pokered_vc.gbc: RGBFIXFLAGS += -p 0x00 -t "POKEMON RED" +pokeblue_vc.gbc: RGBFIXFLAGS += -p 0x00 -t "POKEMON BLUE" %.gbc: $$(%_obj) layout.link - $(RGBLINK) -p $($*_pad) -m $*.map -n $*.sym -l layout.link -o $@ $(filter %.o,$^) - $(RGBFIX) -p $($*_pad) $($*_opt) $@ + $(RGBLINK) $(RGBLINKFLAGS) -l layout.link -m $*.map -n $*.sym -o $@ $(filter %.o,$^) + $(RGBFIX) $(RGBFIXFLAGS) $@ ### Misc file-specific graphics rules @@ -161,13 +175,13 @@ pokeblue_vc_opt = -cjsv -n 0 -k 01 -l 0x33 -m MBC3+RAM+BATTERY -r 03 -t "POKE gfx/battle/move_anim_0.2bpp: tools/gfx += --trim-whitespace gfx/battle/move_anim_1.2bpp: tools/gfx += --trim-whitespace -gfx/intro/blue_jigglypuff_1.2bpp: rgbgfx += --columns -gfx/intro/blue_jigglypuff_2.2bpp: rgbgfx += --columns -gfx/intro/blue_jigglypuff_3.2bpp: rgbgfx += --columns -gfx/intro/red_nidorino_1.2bpp: rgbgfx += --columns -gfx/intro/red_nidorino_2.2bpp: rgbgfx += --columns -gfx/intro/red_nidorino_3.2bpp: rgbgfx += --columns -gfx/intro/gengar.2bpp: rgbgfx += --columns +gfx/intro/blue_jigglypuff_1.2bpp: RGBGFXFLAGS += --columns +gfx/intro/blue_jigglypuff_2.2bpp: RGBGFXFLAGS += --columns +gfx/intro/blue_jigglypuff_3.2bpp: RGBGFXFLAGS += --columns +gfx/intro/red_nidorino_1.2bpp: RGBGFXFLAGS += --columns +gfx/intro/red_nidorino_2.2bpp: RGBGFXFLAGS += --columns +gfx/intro/red_nidorino_3.2bpp: RGBGFXFLAGS += --columns +gfx/intro/gengar.2bpp: RGBGFXFLAGS += --columns gfx/intro/gengar.2bpp: tools/gfx += --remove-duplicates --preserve=0x19,0x76 gfx/credits/the_end.2bpp: tools/gfx += --interleave --png=$< @@ -184,17 +198,27 @@ gfx/trade/game_boy.2bpp: tools/gfx += --remove-duplicates ### Catch-all graphics rules -%.png: ; - %.2bpp: %.png - $(RGBGFX) $(rgbgfx) -o $@ $< + $(RGBGFX) --colors dmg $(RGBGFXFLAGS) -o $@ $< $(if $(tools/gfx),\ - tools/gfx $(tools/gfx) -o $@ $@) + tools/gfx $(tools/gfx) -o $@ $@ || $$($(RM) $@ && false)) %.1bpp: %.png - $(RGBGFX) $(rgbgfx) --depth 1 -o $@ $< + $(RGBGFX) --colors dmg $(RGBGFXFLAGS) --depth 1 -o $@ $< $(if $(tools/gfx),\ - tools/gfx $(tools/gfx) --depth 1 -o $@ $@) + tools/gfx $(tools/gfx) --depth 1 -o $@ $@ || $$($(RM) $@ && false)) %.pic: %.2bpp tools/pkmncompress $< $@ + + +### File extensions that are never generated and should be manually created + +%.asm: ; +%.inc: ; +%.png: ; +%.pal: ; +%.bin: ; +%.blk: ; +%.bst: ; +%.rle: ; diff --git a/audio/engine_1.asm b/audio/engine_1.asm index 06b02de012..1f244e4b06 100644 --- a/audio/engine_1.asm +++ b/audio/engine_1.asm @@ -21,10 +21,10 @@ Audio1_UpdateMusic:: set BIT_MUTE_AUDIO, a ld [wMuteAudioAndPauseMusic], a xor a ; disable all channels' output - ldh [rNR51], a - ldh [rNR30], a - ld a, $80 - ldh [rNR30], a + ldh [rAUDTERM], a + ldh [rAUD3ENA], a + ld a, AUD3ENA_ON + ldh [rAUD3ENA], a jr .nextChannel .applyAffects call Audio1_ApplyMusicAffects @@ -184,9 +184,9 @@ Audio1_sound_ret: jr nz, .skipSfxChannel3 ; restart hardware channel 3 (wave channel) output xor a - ldh [rNR30], a + ldh [rAUD3ENA], a ld a, $80 - ldh [rNR30], a + ldh [rAUD3ENA], a .skipSfxChannel3 jr nz, .afterDisable ld a, [wDisableChannelOutputWhenSfxEnds] @@ -218,9 +218,9 @@ Audio1_sound_ret: .disableChannelOutput ld hl, Audio1_HWChannelDisableMasks add hl, bc - ldh a, [rNR51] + ldh a, [rAUDTERM] and [hl] - ldh [rNR51], a + ldh [rAUDTERM], a .afterDisable ld a, [wChannelSoundIDs + CHAN5] cp CRY_SFX_START @@ -236,7 +236,7 @@ Audio1_sound_ret: ret c .skipRewind ld a, [wSavedVolume] - ldh [rNR50], a + ldh [rAUDVOL], a xor a ld [wSavedVolume], a .skipCry @@ -543,7 +543,7 @@ Audio1_volume: cp volume_cmd jr nz, Audio1_execute_music call Audio1_GetNextMusicByte - ldh [rNR50], a ; store volume + ldh [rAUDVOL], a ; store volume jp Audio1_sound_ret Audio1_execute_music: @@ -632,7 +632,7 @@ Audio1_pitch_sweep: bit BIT_EXECUTE_MUSIC, [hl] jp nz, Audio1_note ; no call Audio1_GetNextMusicByte - ldh [rNR10], a + ldh [rAUD1SWEEP], a jp Audio1_sound_ret ;;;;;;;;;; PureRGBnote: ADDED: new audio commands that can be used in songs, needed for tcg/tcg2/pinball songs to work properly @@ -876,9 +876,9 @@ Audio1_note_pitch: ld b, 0 ld hl, Audio1_HWChannelDisableMasks add hl, bc - ldh a, [rNR51] + ldh a, [rAUDTERM] and [hl] - ldh [rNR51], a ; disable hardware channel 3's output + ldh [rAUDTERM], a ; disable hardware channel 3's output ret .notChannel3 ld b, REG_VOLUME_ENVELOPE @@ -944,7 +944,7 @@ Audio1_EnableChannelOutput: ld b, 0 call Audio1_9972 add hl, bc - ldh a, [rNR51] + ldh a, [rAUDTERM] or [hl] ; set this channel's bits ld d, a ld a, c @@ -966,7 +966,7 @@ Audio1_EnableChannelOutput: add hl, bc and [hl] ld d, a - ldh a, [rNR51] + ldh a, [rAUDTERM] ld hl, Audio1_HWChannelDisableMasks add hl, bc and [hl] ; reset this channel's output bits @@ -974,7 +974,7 @@ Audio1_EnableChannelOutput: ld d, a .skip ld a, d - ldh [rNR51], a + ldh [rAUDTERM], a ret Audio1_ApplyDutyCycleAndSoundLength: @@ -1025,10 +1025,10 @@ Audio1_ApplyWavePatternAndFrequency: ld a, [hli] ld e, a ld d, [hl] - ld hl, rWave_0 + ld hl, rAUD3WAVE_0 ld b, $f xor a ; stop hardware channel 3 - ldh [rNR30], a + ldh [rAUD3ENA], a .loop ld a, [de] inc de @@ -1037,8 +1037,8 @@ Audio1_ApplyWavePatternAndFrequency: dec b and a jr nz, .loop - ld a, $80 ; start hardware channel 3 - ldh [rNR30], a + ld a, AUD3ENA_ON ; start hardware channel 3 + ldh [rAUD3ENA], a pop de .notChannel3 ld a, d @@ -1633,10 +1633,10 @@ Audio1_PlaySound:: ld a, [wSavedVolume] and a ret nz - ldh a, [rNR50] + ldh a, [rAUDVOL] ld [wSavedVolume], a ld a, $77 - ldh [rNR50], a ; full volume + ldh [rAUDVOL], a ; full volume ret Audio1_CryRet: diff --git a/audio/engine_3.asm b/audio/engine_3.asm index de2916156b..5c7937f37f 100644 --- a/audio/engine_3.asm +++ b/audio/engine_3.asm @@ -174,10 +174,10 @@ PlaySoundCommon_3: ld a, [wSavedVolume] and a ret nz - ldh a, [rNR50] + ldh a, [rAUDVOL] ld [wSavedVolume], a ld a, $77 - ldh [rNR50], a + ldh [rAUDVOL], a ; full volume ret Noise3_endchannel: diff --git a/audio/low_health_alarm.asm b/audio/low_health_alarm.asm index c2a35c6fc4..851a085611 100644 --- a/audio/low_health_alarm.asm +++ b/audio/low_health_alarm.asm @@ -94,7 +94,7 @@ Music_DoLowHealthAlarm:: ;update sound channel 1 to play the alarm, overriding all other sounds. .playTone - ld hl, rNR10 ;channel 1 sound register + ld hl, rAUD1SWEEP ;channel 1 sound register ld c, $5 xor a diff --git a/audio/wave_samples.asm b/audio/wave_samples.asm index 7f9aa01db7..f2cd77a767 100644 --- a/audio/wave_samples.asm +++ b/audio/wave_samples.asm @@ -19,7 +19,7 @@ ; these are the definitions for the channel 3 instruments ; each instrument definition is made up of 32 points (nibbles) that form ; the graph of the wave -; the current instrument is copied to rWave_0--rWave_f +; the current instrument is copied to _AUD3WAVERAM .wave0 dn 0, 2, 4, 6, 8, 10, 12, 14, 15, 15, 15, 14, 14, 13, 13, 12, 12, 11, 10, 9, 8, 7, 6, 5, 4, 4, 3, 3, 2, 2, 1, 1 diff --git a/constants/audio_constants.asm b/constants/audio_constants.asm index 99b899d1e9..36c3500618 100644 --- a/constants/audio_constants.asm +++ b/constants/audio_constants.asm @@ -32,10 +32,10 @@ DEF NUM_NOISE_CHANS EQU const_value - NUM_MUSIC_CHANS DEF NUM_CHANNELS EQU const_value ; HW sound channel register base addresses -DEF HW_CH1_BASE EQU LOW(rNR10) -DEF HW_CH2_BASE EQU LOW(rNR21) - 1 -DEF HW_CH3_BASE EQU LOW(rNR30) -DEF HW_CH4_BASE EQU LOW(rNR41) - 1 +DEF HW_CH1_BASE EQU LOW(rAUD1SWEEP) +DEF HW_CH2_BASE EQU LOW(rAUD2LEN) - 1 +DEF HW_CH3_BASE EQU LOW(rAUD3ENA) +DEF HW_CH4_BASE EQU LOW(rAUD4LEN) - 1 ; HW sound channel enable bit masks DEF HW_CH1_ENABLE_MASK EQU %00010001 diff --git a/constants/gfx_constants.asm b/constants/gfx_constants.asm index 08cf8dc73e..c3f29ca558 100644 --- a/constants/gfx_constants.asm +++ b/constants/gfx_constants.asm @@ -1,14 +1,4 @@ -DEF TILE_WIDTH EQU 8 ; pixels -DEF LEN_1BPP_TILE EQU 1 * TILE_WIDTH ; bytes -DEF LEN_2BPP_TILE EQU 2 * TILE_WIDTH ; bytes - -DEF SCREEN_WIDTH EQU 20 -DEF SCREEN_HEIGHT EQU 18 -DEF SCREEN_WIDTH_PX EQU SCREEN_WIDTH * TILE_WIDTH ; pixels -DEF SCREEN_HEIGHT_PX EQU SCREEN_HEIGHT * TILE_WIDTH ; pixels - -DEF BG_MAP_WIDTH EQU 32 ; tiles -DEF BG_MAP_HEIGHT EQU 32 ; tiles +DEF TILE_1BPP_SIZE EQU TILE_SIZE / 2 ; bytes DEF BLOCK_WIDTH EQU 4 ; tiles DEF BLOCK_HEIGHT EQU BLOCK_WIDTH ; tiles @@ -17,16 +7,17 @@ DEF SCREEN_BLOCK_HEIGHT EQU 5 ; blocks DEF SURROUNDING_WIDTH EQU SCREEN_BLOCK_WIDTH * BLOCK_WIDTH ; tiles DEF SURROUNDING_HEIGHT EQU SCREEN_BLOCK_HEIGHT * BLOCK_HEIGHT ; tiles -DEF SPRITEBUFFERSIZE EQU 7 * 7 * LEN_1BPP_TILE +DEF PIC_WIDTH EQU 7 ; tiles +DEF PIC_HEIGHT EQU PIC_WIDTH ; tiles +DEF PIC_SIZE EQU PIC_WIDTH * PIC_HEIGHT ; tiles + +DEF SPRITEBUFFERSIZE EQU PIC_WIDTH * PIC_HEIGHT * TILE_1BPP_SIZE ; HP bar DEF HP_BAR_GREEN EQU 0 DEF HP_BAR_YELLOW EQU 1 DEF HP_BAR_RED EQU 2 -; wShadowOAM -DEF NUM_SPRITE_OAM_STRUCTS EQU 40 - ; hAutoBGTransferEnabled DEF TRANSFERTOP EQU 0 DEF TRANSFERMIDDLE EQU 1 diff --git a/constants/hardware.inc b/constants/hardware.inc new file mode 100644 index 0000000000..e1e3b2ccd0 --- /dev/null +++ b/constants/hardware.inc @@ -0,0 +1,1110 @@ +;****************************************************************************** +; Game Boy hardware constant definitions +; https://github.com/gbdev/hardware.inc +;****************************************************************************** + +; To the extent possible under law, the authors of this work have +; waived all copyright and related or neighboring rights to the work. +; See https://creativecommons.org/publicdomain/zero/1.0/ for details. +; SPDX-License-Identifier: CC0-1.0 + +; If this file was already included, don't do it again +if !def(HARDWARE_INC) + +; Check for the minimum supported RGBDS version +if !def(__RGBDS_MAJOR__) || !def(__RGBDS_MINOR__) || !def(__RGBDS_PATCH__) + fail "This version of 'hardware.inc' requires RGBDS version 0.5.0 or later" +endc +if __RGBDS_MAJOR__ == 0 && __RGBDS_MINOR__ < 5 + fail "This version of 'hardware.inc' requires RGBDS version 0.5.0 or later." +endc + +; Define the include guard and the current hardware.inc version +; (do this after the RGBDS version check since the `def` syntax depends on it) +def HARDWARE_INC equ 1 +def HARDWARE_INC_VERSION equs "5.3.0" + +; Usage: rev_Check_hardware_inc +; Examples: +; rev_Check_hardware_inc 1.2.3 +; rev_Check_hardware_inc 1.2 (equivalent to 1.2.0) +; rev_Check_hardware_inc 1 (equivalent to 1.0.0) +MACRO rev_Check_hardware_inc + if _NARG == 1 ; Actual invocation by the user + def hw_inc_cur_ver\@ equs strrpl("{HARDWARE_INC_VERSION}", ".", ",") + def hw_inc_min_ver\@ equs strrpl("\1", ".", ",") + rev_Check_hardware_inc {hw_inc_cur_ver\@}, {hw_inc_min_ver\@}, 0, 0 + purge hw_inc_cur_ver\@, hw_inc_min_ver\@ + else ; Recursive invocation + if \1 != \4 || (\2 < \5 || (\2 == \5 && \3 < \6)) + fail "Version \1.\2.\3 of 'hardware.inc' is incompatible with requested version \4.\5.\6" + endc + endc +ENDM + + +;****************************************************************************** +; Memory-mapped registers ($FFxx range) +;****************************************************************************** + +; -- JOYP / P1 ($FF00) -------------------------------------------------------- +; Joypad face buttons +def rJOYP equ $FF00 + +def B_JOYP_GET_BUTTONS equ 5 ; 0 = reading buttons [r/w] +def B_JOYP_GET_CTRL_PAD equ 4 ; 0 = reading Control Pad [r/w] + def JOYP_GET equ %00_11_0000 ; select which inputs to read from the lower nybble + def JOYP_GET_BUTTONS equ %00_01_0000 ; reading A/B/Select/Start buttons + def JOYP_GET_CTRL_PAD equ %00_10_0000 ; reading Control Pad directions + def JOYP_GET_NONE equ %00_11_0000 ; reading nothing + +def B_JOYP_START equ 3 ; 0 = Start is pressed (if reading buttons) [ro] +def B_JOYP_SELECT equ 2 ; 0 = Select is pressed (if reading buttons) [ro] +def B_JOYP_B equ 1 ; 0 = B is pressed (if reading buttons) [ro] +def B_JOYP_A equ 0 ; 0 = A is pressed (if reading buttons) [ro] +def B_JOYP_DOWN equ 3 ; 0 = Down is pressed (if reading Control Pad) [ro] +def B_JOYP_UP equ 2 ; 0 = Up is pressed (if reading Control Pad) [ro] +def B_JOYP_LEFT equ 1 ; 0 = Left is pressed (if reading Control Pad) [ro] +def B_JOYP_RIGHT equ 0 ; 0 = Right is pressed (if reading Control Pad) [ro] + def JOYP_INPUTS equ %0000_1111 ; bits equal to 0 indicate pressed (when reading inputs) + def JOYP_START equ 1 << B_JOYP_START + def JOYP_SELECT equ 1 << B_JOYP_SELECT + def JOYP_B equ 1 << B_JOYP_B + def JOYP_A equ 1 << B_JOYP_A + def JOYP_DOWN equ 1 << B_JOYP_DOWN + def JOYP_UP equ 1 << B_JOYP_UP + def JOYP_LEFT equ 1 << B_JOYP_LEFT + def JOYP_RIGHT equ 1 << B_JOYP_RIGHT + +; SGB command packet transfer uses for JOYP bits +def B_JOYP_SGB_ONE equ 5 ; 0 = sending 1 bit +def B_JOYP_SGB_ZERO equ 4 ; 0 = sending 0 bit + def JOYP_SGB_START equ %00_00_0000 ; start SGB packet transfer + def JOYP_SGB_ONE equ %00_01_0000 ; send 1 bit + def JOYP_SGB_ZERO equ %00_10_0000 ; send 0 bit + def JOYP_SGB_FINISH equ %00_11_0000 ; finish SGB packet transfer + +; Combined input byte, with Control Pad in high nybble (conventional order) +def B_PAD_DOWN equ 7 +def B_PAD_UP equ 6 +def B_PAD_LEFT equ 5 +def B_PAD_RIGHT equ 4 +def B_PAD_START equ 3 +def B_PAD_SELECT equ 2 +def B_PAD_B equ 1 +def B_PAD_A equ 0 + def PAD_CTRL_PAD equ %1111_0000 + def PAD_BUTTONS equ %0000_1111 + def PAD_DOWN equ 1 << B_PAD_DOWN + def PAD_UP equ 1 << B_PAD_UP + def PAD_LEFT equ 1 << B_PAD_LEFT + def PAD_RIGHT equ 1 << B_PAD_RIGHT + def PAD_START equ 1 << B_PAD_START + def PAD_SELECT equ 1 << B_PAD_SELECT + def PAD_B equ 1 << B_PAD_B + def PAD_A equ 1 << B_PAD_A + +; Combined input byte, with Control Pad in low nybble (swapped order) +def B_PAD_SWAP_START equ 7 +def B_PAD_SWAP_SELECT equ 6 +def B_PAD_SWAP_B equ 5 +def B_PAD_SWAP_A equ 4 +def B_PAD_SWAP_DOWN equ 3 +def B_PAD_SWAP_UP equ 2 +def B_PAD_SWAP_LEFT equ 1 +def B_PAD_SWAP_RIGHT equ 0 + def PAD_SWAP_CTRL_PAD equ %0000_1111 + def PAD_SWAP_BUTTONS equ %1111_0000 + def PAD_SWAP_START equ 1 << B_PAD_SWAP_START + def PAD_SWAP_SELECT equ 1 << B_PAD_SWAP_SELECT + def PAD_SWAP_B equ 1 << B_PAD_SWAP_B + def PAD_SWAP_A equ 1 << B_PAD_SWAP_A + def PAD_SWAP_DOWN equ 1 << B_PAD_SWAP_DOWN + def PAD_SWAP_UP equ 1 << B_PAD_SWAP_UP + def PAD_SWAP_LEFT equ 1 << B_PAD_SWAP_LEFT + def PAD_SWAP_RIGHT equ 1 << B_PAD_SWAP_RIGHT + +; -- SB ($FF01) --------------------------------------------------------------- +; Serial transfer data [r/w] +def rSB equ $FF01 + +; -- SC ($FF02) --------------------------------------------------------------- +; Serial transfer control +def rSC equ $FF02 + +def B_SC_START equ 7 ; reading 1 = transfer in progress, writing 1 = start transfer [r/w] +def B_SC_SPEED equ 1 ; (CGB only) 1 = use faster internal clock [r/w] +def B_SC_SOURCE equ 0 ; 0 = use external clock ("slave"), 1 = use internal clock ("master") [r/w] + def SC_START equ 1 << B_SC_START + def SC_SPEED equ 1 << B_SC_SPEED + def SC_SLOW equ 0 << B_SC_SPEED + def SC_FAST equ 1 << B_SC_SPEED + def SC_SOURCE equ 1 << B_SC_SOURCE + def SC_EXTERNAL equ 0 << B_SC_SOURCE + def SC_INTERNAL equ 1 << B_SC_SOURCE + +; -- $FF03 is unused ---------------------------------------------------------- + +; -- DIV ($FF04) -------------------------------------------------------------- +; Divider register [r/w] +def rDIV equ $FF04 + +; -- TIMA ($FF05) ------------------------------------------------------------- +; Timer counter [r/w] +def rTIMA equ $FF05 + +; -- TMA ($FF06) -------------------------------------------------------------- +; Timer modulo [r/w] +def rTMA equ $FF06 + +; -- TAC ($FF07) -------------------------------------------------------------- +; Timer control +def rTAC equ $FF07 + +def B_TAC_START equ 2 ; enable incrementing TIMA [r/w] + def TAC_STOP equ 0 << B_TAC_START + def TAC_START equ 1 << B_TAC_START + +def TAC_CLOCK equ %000000_11 ; the frequency at which TIMA increments [r/w] + def TAC_4KHZ equ %000000_00 ; every 256 M-cycles = ~4 KHz on DMG + def TAC_262KHZ equ %000000_01 ; every 4 M-cycles = ~262 KHz on DMG + def TAC_65KHZ equ %000000_10 ; every 16 M-cycles = ~65 KHz on DMG + def TAC_16KHZ equ %000000_11 ; every 64 M-cycles = ~16 KHz on DMG + +; -- $FF08-$FF0E are unused --------------------------------------------------- + +; -- IF ($FF0F) --------------------------------------------------------------- +; Pending interrupts +def rIF equ $FF0F + +def B_IF_JOYPAD equ 4 ; 1 = joypad interrupt is pending [r/w] +def B_IF_SERIAL equ 3 ; 1 = serial interrupt is pending [r/w] +def B_IF_TIMER equ 2 ; 1 = timer interrupt is pending [r/w] +def B_IF_STAT equ 1 ; 1 = STAT interrupt is pending [r/w] +def B_IF_VBLANK equ 0 ; 1 = VBlank interrupt is pending [r/w] + def IF_JOYPAD equ 1 << B_IF_JOYPAD + def IF_SERIAL equ 1 << B_IF_SERIAL + def IF_TIMER equ 1 << B_IF_TIMER + def IF_STAT equ 1 << B_IF_STAT + def IF_VBLANK equ 1 << B_IF_VBLANK + +; -- AUD1SWEEP / NR10 ($FF10) ------------------------------------------------- +; Audio channel 1 sweep +def rAUD1SWEEP equ $FF10 + +def AUD1SWEEP_TIME equ %0_111_0000 ; how long between sweep iterations + ; (in 128 Hz ticks, ~7.8 ms apart) [r/w] + +def B_AUD1SWEEP_DIR equ 3 ; sweep direction [r/w] + def AUD1SWEEP_DIR equ 1 << B_AUD1SWEEP_DIR + def AUD1SWEEP_UP equ 0 << B_AUD1SWEEP_DIR + def AUD1SWEEP_DOWN equ 1 << B_AUD1SWEEP_DIR + +def AUD1SWEEP_SHIFT equ %00000_111 ; how much the period increases/decreases per iteration [r/w] + +; -- AUD1LEN / NR11 ($FF11) --------------------------------------------------- +; Audio channel 1 length timer and duty cycle +def rAUD1LEN equ $FF11 + +def AUD1LEN_DUTY equ %11_000000 ; ratio of time spent high vs. time spent low [r/w] + def AUD1LEN_DUTY_12_5 equ %00_000000 ; 12.5% + def AUD1LEN_DUTY_25 equ %01_000000 ; 25% + def AUD1LEN_DUTY_50 equ %10_000000 ; 50% + def AUD1LEN_DUTY_75 equ %11_000000 ; 75% + +def AUD1LEN_TIMER equ %00_111111 ; initial length timer (0-63) [wo] + +; -- AUD1ENV / NR12 ($FF12) --------------------------------------------------- +; Audio channel 1 volume and envelope +def rAUD1ENV equ $FF12 + +def AUD1ENV_INIT_VOLUME equ %1111_0000 ; initial volume [r/w] + +def B_AUD1ENV_DIR equ 3 ; direction of volume envelope [r/w] + def AUD1ENV_DIR equ 1 << B_AUD1ENV_DIR + def AUD1ENV_DOWN equ 0 << B_AUD1ENV_DIR + def AUD1ENV_UP equ 1 << B_AUD1ENV_DIR + +def AUD1ENV_PACE equ %00000_111 ; how long between envelope iterations + ; (in 64 Hz ticks, ~15.6 ms apart) [r/w] + +; -- AUD1LOW / NR13 ($FF13) --------------------------------------------------- +; Audio channel 1 period (low 8 bits) [wo] +def rAUD1LOW equ $FF13 + +; -- AUD1HIGH / NR14 ($FF14) -------------------------------------------------- +; Audio channel 1 period (high 3 bits) and control +def rAUD1HIGH equ $FF14 + +def B_AUD1HIGH_RESTART equ 7 ; 1 = restart the channel [wo] +def B_AUD1HIGH_LEN_ENABLE equ 6 ; 1 = reset the channel after the length timer expires [r/w] + def AUD1HIGH_RESTART equ 1 << B_AUD1HIGH_RESTART + def AUD1HIGH_LENGTH_OFF equ 0 << B_AUD1HIGH_LEN_ENABLE + def AUD1HIGH_LENGTH_ON equ 1 << B_AUD1HIGH_LEN_ENABLE + +def AUD1HIGH_PERIOD_HIGH equ %00000_111 ; upper 3 bits of the channel's period [r/w] + +; -- $FF15 is unused ---------------------------------------------------------- + +; -- AUD2LEN / NR21 ($FF16) --------------------------------------------------- +; Audio channel 2 length timer and duty cycle +def rAUD2LEN equ $FF16 + +def AUD2LEN_DUTY equ %11_000000 ; ratio of time spent high vs. time spent low [r/w] + def AUD2LEN_DUTY_12_5 equ %00_000000 ; 12.5% + def AUD2LEN_DUTY_25 equ %01_000000 ; 25% + def AUD2LEN_DUTY_50 equ %10_000000 ; 50% + def AUD2LEN_DUTY_75 equ %11_000000 ; 75% + +def AUD2LEN_TIMER equ %00_111111 ; initial length timer (0-63) [wo] + +; -- AUD2ENV / NR22 ($FF17) --------------------------------------------------- +; Audio channel 2 volume and envelope +def rAUD2ENV equ $FF17 + +def AUD2ENV_INIT_VOLUME equ %1111_0000 ; initial volume [r/w] + +def B_AUD2ENV_DIR equ 3 ; direction of volume envelope [r/w] + def AUD2ENV_DIR equ 1 << B_AUD2ENV_DIR + def AUD2ENV_DOWN equ 0 << B_AUD2ENV_DIR + def AUD2ENV_UP equ 1 << B_AUD2ENV_DIR + +def AUD2ENV_PACE equ %00000_111 ; how long between envelope iterations + ; (in 64 Hz ticks, ~15.6 ms apart) [r/w] + +; -- AUD2LOW / NR23 ($FF18) --------------------------------------------------- +; Audio channel 2 period (low 8 bits) [wo] +def rAUD2LOW equ $FF18 + +; -- AUD2HIGH / NR24 ($FF19) -------------------------------------------------- +; Audio channel 2 period (high 3 bits) and control +def rAUD2HIGH equ $FF19 + +def B_AUD2HIGH_RESTART equ 7 ; 1 = restart the channel [wo] +def B_AUD2HIGH_LEN_ENABLE equ 6 ; 1 = reset the channel after the length timer expires [r/w] + def AUD2HIGH_RESTART equ 1 << B_AUD2HIGH_RESTART + def AUD2HIGH_LENGTH_OFF equ 0 << B_AUD2HIGH_LEN_ENABLE + def AUD2HIGH_LENGTH_ON equ 1 << B_AUD2HIGH_LEN_ENABLE + +def AUD2HIGH_PERIOD_HIGH equ %00000_111 ; upper 3 bits of the channel's period [r/w] + +; -- AUD3ENA / NR30 ($FF1A) --------------------------------------------------- +; Audio channel 3 enable +def rAUD3ENA equ $FF1A + +def B_AUD3ENA_ENABLE equ 7 ; 1 = channel is active [r/w] + def AUD3ENA_OFF equ 0 << B_AUD3ENA_ENABLE + def AUD3ENA_ON equ 1 << B_AUD3ENA_ENABLE + +; -- AUD3LEN / NR31 ($FF1B) --------------------------------------------------- +; Audio channel 3 length timer [wo] +def rAUD3LEN equ $FF1B + +; -- AUD3LEVEL / NR32 ($FF1C) ------------------------------------------------- +; Audio channel 3 volume +def rAUD3LEVEL equ $FF1C + +def AUD3LEVEL_VOLUME equ %0_11_00000 ; volume level [r/w] + def AUD3LEVEL_MUTE equ %0_00_00000 ; 0% (muted) + def AUD3LEVEL_100 equ %0_01_00000 ; 100% + def AUD3LEVEL_50 equ %0_10_00000 ; 50% + def AUD3LEVEL_25 equ %0_11_00000 ; 25% + +; -- AUD3LOW / NR33 ($FF1D) --------------------------------------------------- +; Audio channel 3 period (low 8 bits) [wo] +def rAUD3LOW equ $FF1D + +; -- AUD3HIGH / NR34 ($FF1E) -------------------------------------------------- +; Audio channel 3 period (high 3 bits) and control +def rAUD3HIGH equ $FF1E + +def B_AUD3HIGH_RESTART equ 7 ; 1 = restart the channel [wo] +def B_AUD3HIGH_LEN_ENABLE equ 6 ; 1 = reset the channel after the length timer expires [r/w] + def AUD3HIGH_RESTART equ 1 << B_AUD3HIGH_RESTART + def AUD3HIGH_LENGTH_OFF equ 0 << B_AUD3HIGH_LEN_ENABLE + def AUD3HIGH_LENGTH_ON equ 1 << B_AUD3HIGH_LEN_ENABLE + +def AUD3HIGH_PERIOD_HIGH equ %00000_111 ; upper 3 bits of the channel's period [r/w] + +; -- $FF1F is unused ---------------------------------------------------------- + +; -- AUD4LEN / NR41 ($FF20) --------------------------------------------------- +; Audio channel 4 length timer +def rAUD4LEN equ $FF20 + +def AUD4LEN_TIMER equ %00_111111 ; initial length timer (0-63) [wo] + +; -- AUD4ENV / NR42 ($FF21) --------------------------------------------------- +; Audio channel 4 volume and envelope +def rAUD4ENV equ $FF21 + +def AUD4ENV_INIT_VOLUME equ %1111_0000 ; initial volume [r/w] + +def B_AUD4ENV_DIR equ 3 ; direction of volume envelope [r/w] + def AUD4ENV_DIR equ 1 << B_AUD4ENV_DIR + def AUD4ENV_DOWN equ 0 << B_AUD4ENV_DIR + def AUD4ENV_UP equ 1 << B_AUD4ENV_DIR + +def AUD4ENV_PACE equ %00000_111 ; how long between envelope iterations + ; (in 64 Hz ticks, ~15.6 ms apart) [r/w] + +; -- AUD4POLY / NR43 ($FF22) -------------------------------------------------- +; Audio channel 4 period and randomness +def rAUD4POLY equ $FF22 + +def AUD4POLY_SHIFT equ %1111_0000 ; coarse control of the channel's period [r/w] + +def B_AUD4POLY_WIDTH equ 3 ; controls the noise generator (LFSR)'s step width [r/w] + def AUD4POLY_15STEP equ 0 << B_AUD4POLY_WIDTH + def AUD4POLY_7STEP equ 1 << B_AUD4POLY_WIDTH + +def AUD4POLY_DIV equ %00000_111 ; fine control of the channel's period [r/w] + +; -- AUD4GO / NR44 ($FF23) ---------------------------------------------------- +; Audio channel 4 control +def rAUD4GO equ $FF23 + +def B_AUD4GO_RESTART equ 7 ; 1 = restart the channel [wo] +def B_AUD4GO_LEN_ENABLE equ 6 ; 1 = reset the channel after the length timer expires [r/w] + def AUD4GO_RESTART equ 1 << B_AUD4GO_RESTART + def AUD4GO_LENGTH_OFF equ 0 << B_AUD4GO_LEN_ENABLE + def AUD4GO_LENGTH_ON equ 1 << B_AUD4GO_LEN_ENABLE + +; -- AUDVOL / NR50 ($FF24) ---------------------------------------------------- +; Audio master volume and VIN mixer +def rAUDVOL equ $FF24 + +def B_AUDVOL_VIN_LEFT equ 7 ; 1 = output VIN to left ear (SO2, speaker 2) [r/w] + def AUDVOL_VIN_LEFT equ 1 << B_AUDVOL_VIN_LEFT + +def AUDVOL_LEFT equ %0_111_0000 ; 0 = barely audible, 7 = full volume [r/w] + +def B_AUDVOL_VIN_RIGHT equ 3 ; 1 = output VIN to right ear (SO1, speaker 1) [r/w] + def AUDVOL_VIN_RIGHT equ 1 << B_AUDVOL_VIN_RIGHT + +def AUDVOL_RIGHT equ %00000_111 ; 0 = barely audible, 7 = full volume [r/w] + +; -- AUDTERM / NR51 ($FF25) --------------------------------------------------- +; Audio channel mixer +def rAUDTERM equ $FF25 + +def B_AUDTERM_4_LEFT equ 7 ; 1 = output channel 4 to left ear [r/w] +def B_AUDTERM_3_LEFT equ 6 ; 1 = output channel 3 to left ear [r/w] +def B_AUDTERM_2_LEFT equ 5 ; 1 = output channel 2 to left ear [r/w] +def B_AUDTERM_1_LEFT equ 4 ; 1 = output channel 1 to left ear [r/w] +def B_AUDTERM_4_RIGHT equ 3 ; 1 = output channel 4 to right ear [r/w] +def B_AUDTERM_3_RIGHT equ 2 ; 1 = output channel 3 to right ear [r/w] +def B_AUDTERM_2_RIGHT equ 1 ; 1 = output channel 2 to right ear [r/w] +def B_AUDTERM_1_RIGHT equ 0 ; 1 = output channel 1 to right ear [r/w] + def AUDTERM_4_LEFT equ 1 << B_AUDTERM_4_LEFT + def AUDTERM_3_LEFT equ 1 << B_AUDTERM_3_LEFT + def AUDTERM_2_LEFT equ 1 << B_AUDTERM_2_LEFT + def AUDTERM_1_LEFT equ 1 << B_AUDTERM_1_LEFT + def AUDTERM_4_RIGHT equ 1 << B_AUDTERM_4_RIGHT + def AUDTERM_3_RIGHT equ 1 << B_AUDTERM_3_RIGHT + def AUDTERM_2_RIGHT equ 1 << B_AUDTERM_2_RIGHT + def AUDTERM_1_RIGHT equ 1 << B_AUDTERM_1_RIGHT + +; -- AUDENA / NR52 ($FF26) ---------------------------------------------------- +; Audio master enable +def rAUDENA equ $FF26 + +def B_AUDENA_ENABLE equ 7 ; 0 = disable the APU (resets all audio registers to 0!) [r/w] +def B_AUDENA_ENABLE_CH4 equ 3 ; 1 = channel 4 is running [ro] +def B_AUDENA_ENABLE_CH3 equ 2 ; 1 = channel 3 is running [ro] +def B_AUDENA_ENABLE_CH2 equ 1 ; 1 = channel 2 is running [ro] +def B_AUDENA_ENABLE_CH1 equ 0 ; 1 = channel 1 is running [ro] + def AUDENA_OFF equ 0 << B_AUDENA_ENABLE + def AUDENA_ON equ 1 << B_AUDENA_ENABLE + def AUDENA_CH4_OFF equ 0 << B_AUDENA_ENABLE_CH4 + def AUDENA_CH4_ON equ 1 << B_AUDENA_ENABLE_CH4 + def AUDENA_CH3_OFF equ 0 << B_AUDENA_ENABLE_CH3 + def AUDENA_CH3_ON equ 1 << B_AUDENA_ENABLE_CH3 + def AUDENA_CH2_OFF equ 0 << B_AUDENA_ENABLE_CH2 + def AUDENA_CH2_ON equ 1 << B_AUDENA_ENABLE_CH2 + def AUDENA_CH1_OFF equ 0 << B_AUDENA_ENABLE_CH1 + def AUDENA_CH1_ON equ 1 << B_AUDENA_ENABLE_CH1 + +; -- $FF27-$FF2F are unused --------------------------------------------------- + +; -- AUD3WAVE ($FF30-$FF3F) --------------------------------------------------- +; Audio channel 3 wave pattern RAM [r/w] +def rAUD3WAVE_0 equ $FF30 +def rAUD3WAVE_1 equ $FF31 +def rAUD3WAVE_2 equ $FF32 +def rAUD3WAVE_3 equ $FF33 +def rAUD3WAVE_4 equ $FF34 +def rAUD3WAVE_5 equ $FF35 +def rAUD3WAVE_6 equ $FF36 +def rAUD3WAVE_7 equ $FF37 +def rAUD3WAVE_8 equ $FF38 +def rAUD3WAVE_9 equ $FF39 +def rAUD3WAVE_A equ $FF3A +def rAUD3WAVE_B equ $FF3B +def rAUD3WAVE_C equ $FF3C +def rAUD3WAVE_D equ $FF3D +def rAUD3WAVE_E equ $FF3E +def rAUD3WAVE_F equ $FF3F + +; -- LCDC ($FF40) ------------------------------------------------------------- +; PPU graphics control +def rLCDC equ $FF40 + +def B_LCDC_ENABLE equ 7 ; whether the PPU (and LCD) are turned on [r/w] +def B_LCDC_WIN_MAP equ 6 ; which tilemap the Window reads from [r/w] +def B_LCDC_WINDOW equ 5 ; whether the Window is enabled [r/w] +def B_LCDC_BLOCKS equ 4 ; which "tile blocks" the BG and Window use [r/w] +def B_LCDC_BG_MAP equ 3 ; which tilemap the BG reads from [r/w] +def B_LCDC_OBJ_SIZE equ 2 ; how many pixels tall each OBJ is [r/w] +def B_LCDC_OBJS equ 1 ; whether OBJs are enabled [r/w] +def B_LCDC_BG equ 0 ; (DMG only) whether the BG is enabled [r/w] +def B_LCDC_PRIO equ 0 ; (CGB only) whether OBJ priority bits are enabled [r/w] + def LCDC_ENABLE equ 1 << B_LCDC_ENABLE + def LCDC_OFF equ 0 << B_LCDC_ENABLE + def LCDC_ON equ 1 << B_LCDC_ENABLE + def LCDC_WIN_MAP equ 1 << B_LCDC_WIN_MAP + def LCDC_WIN_9800 equ 0 << B_LCDC_WIN_MAP + def LCDC_WIN_9C00 equ 1 << B_LCDC_WIN_MAP + def LCDC_WINDOW equ 1 << B_LCDC_WINDOW + def LCDC_WIN_OFF equ 0 << B_LCDC_WINDOW + def LCDC_WIN_ON equ 1 << B_LCDC_WINDOW + def LCDC_BLOCKS equ 1 << B_LCDC_BLOCKS + def LCDC_BLOCK21 equ 0 << B_LCDC_BLOCKS + def LCDC_BLOCK01 equ 1 << B_LCDC_BLOCKS + def LCDC_BG_MAP equ 1 << B_LCDC_BG_MAP + def LCDC_BG_9800 equ 0 << B_LCDC_BG_MAP + def LCDC_BG_9C00 equ 1 << B_LCDC_BG_MAP + def LCDC_OBJ_SIZE equ 1 << B_LCDC_OBJ_SIZE + def LCDC_OBJ_8 equ 0 << B_LCDC_OBJ_SIZE + def LCDC_OBJ_16 equ 1 << B_LCDC_OBJ_SIZE + def LCDC_OBJS equ 1 << B_LCDC_OBJS + def LCDC_OBJ_OFF equ 0 << B_LCDC_OBJS + def LCDC_OBJ_ON equ 1 << B_LCDC_OBJS + def LCDC_BG equ 1 << B_LCDC_BG + def LCDC_BG_OFF equ 0 << B_LCDC_BG + def LCDC_BG_ON equ 1 << B_LCDC_BG + def LCDC_PRIO equ 1 << B_LCDC_PRIO + def LCDC_PRIO_OFF equ 0 << B_LCDC_PRIO + def LCDC_PRIO_ON equ 1 << B_LCDC_PRIO + +; -- STAT ($FF41) ------------------------------------------------------------- +; Graphics status and interrupt control +def rSTAT equ $FF41 + +def B_STAT_LYC equ 6 ; 1 = LY match triggers the STAT interrupt [r/w] +def B_STAT_MODE_2 equ 5 ; 1 = OAM Scan triggers the PPU interrupt [r/w] +def B_STAT_MODE_1 equ 4 ; 1 = VBlank triggers the PPU interrupt [r/w] +def B_STAT_MODE_0 equ 3 ; 1 = HBlank triggers the PPU interrupt [r/w] +def B_STAT_LYCF equ 2 ; 1 = LY is currently equal to LYC [ro] +def B_STAT_BUSY equ 1 ; 1 = the PPU is currently accessing VRAM [ro] + def STAT_LYC equ 1 << B_STAT_LYC + def STAT_MODE_2 equ 1 << B_STAT_MODE_2 + def STAT_MODE_1 equ 1 << B_STAT_MODE_1 + def STAT_MODE_0 equ 1 << B_STAT_MODE_0 + def STAT_LYCF equ 1 << B_STAT_LYCF + def STAT_BUSY equ 1 << B_STAT_BUSY + +def STAT_MODE equ %000000_11 ; PPU's current status [ro] + def STAT_HBLANK equ %000000_00 ; waiting after a line's rendering (HBlank) + def STAT_VBLANK equ %000000_01 ; waiting between frames (VBlank) + def STAT_OAM equ %000000_10 ; checking which OBJs will be rendered on this line (OAM scan) + def STAT_LCD equ %000000_11 ; pushing pixels to the LCD + +; -- SCY ($FF42) -------------------------------------------------------------- +; Background Y scroll offset (in pixels) [r/w] +def rSCY equ $FF42 + +; -- SCX ($FF43) -------------------------------------------------------------- +; Background X scroll offset (in pixels) [r/w] +def rSCX equ $FF43 + +; -- LY ($FF44) --------------------------------------------------------------- +; Y coordinate of the line currently processed by the PPU (0-153) [ro] +def rLY equ $FF44 + +def LY_VBLANK equ 144 ; 144-153 is the VBlank period + +; -- LYC ($FF45) -------------------------------------------------------------- +; Value that LY is constantly compared to [r/w] +def rLYC equ $FF45 + +; -- DMA ($FF46) -------------------------------------------------------------- +; OAM DMA start address (high 8 bits) and start [wo] +def rDMA equ $FF46 + +; -- BGP ($FF47) -------------------------------------------------------------- +; (DMG only) Background color mapping [r/w] +def rBGP equ $FF47 + +def BGP_SGB_TRANSFER equ %11_10_01_00 ; set BGP to this value before SGB VRAM transfer + +; -- OBP0 ($FF48) ------------------------------------------------------------- +; (DMG only) OBJ color mapping #0 [r/w] +def rOBP0 equ $FF48 + +; -- OBP1 ($FF49) ------------------------------------------------------------- +; (DMG only) OBJ color mapping #1 [r/w] +def rOBP1 equ $FF49 + +; -- WY ($FF4A) --------------------------------------------------------------- +; Y coordinate of the Window's top-left pixel (0-143) [r/w] +def rWY equ $FF4A + +; -- WX ($FF4B) --------------------------------------------------------------- +; X coordinate of the Window's top-left pixel, plus 7 (7-166) [r/w] +def rWX equ $FF4B + +def WX_OFS equ 7 ; subtract this to get the actual Window X coordinate + +; -- SYS / KEY0 ($FF4C) ------------------------------------------------------- +; (CGB boot ROM only) CPU mode select +def rSYS equ $FF4C + +; This is known as the "CPU mode register" in Fig. 11 of this patent: +; https://patents.google.com/patent/US6322447B1/en?oq=US6322447bi +; "OBJ priority mode designating register" in the same patent +; Credit to @mattcurrie for this finding! + +def SYS_MODE equ %0000_11_00 ; current system mode [r/w] + def SYS_CGB equ %0000_00_00 ; CGB mode + def SYS_DMG equ %0000_01_00 ; DMG compatibility mode + def SYS_PGB1 equ %0000_10_00 ; LCD is driven externally, CPU is stopped + def SYS_PGB2 equ %0000_11_00 ; LCD is driven externally, CPU is running + +; -- SPD / KEY1 ($FF4D) ------------------------------------------------------- +; (CGB only) Double-speed mode control +def rSPD equ $FF4D + +def B_SPD_DOUBLE equ 7 ; current clock speed [ro] +def B_SPD_PREPARE equ 0 ; 1 = next `stop` instruction will switch clock speeds [r/w] + def SPD_SINGLE equ 0 << B_SPD_DOUBLE + def SPD_DOUBLE equ 1 << B_SPD_DOUBLE + def SPD_PREPARE equ 1 << B_SPD_PREPARE + +; -- $FF4E is unused ---------------------------------------------------------- + +; -- VBK ($FF4F) -------------------------------------------------------------- +; (CGB only) VRAM bank number (0 or 1) +def rVBK equ $FF4F + +def VBK_BANK equ %0000000_1 ; mapped VRAM bank [r/w] + +; -- BANK ($FF50) ------------------------------------------------------------- +; (boot ROM only) Boot ROM mapping control +def rBANK equ $FF50 + +def B_BANK_ON equ 0 ; whether the boot ROM is mapped [wo] + def BANK_ON equ 0 << B_BANK_ON + def BANK_OFF equ 1 << B_BANK_ON + +; -- VDMA_SRC_HIGH / HDMA1 ($FF51) -------------------------------------------- +; (CGB only) VRAM DMA source address (high 8 bits) [wo] +def rVDMA_SRC_HIGH equ $FF51 + +; -- VDMA_SRC_LOW / HDMA2 ($FF52) --------------------------------------------- +; (CGB only) VRAM DMA source address (low 8 bits) [wo] +def rVDMA_SRC_LOW equ $FF52 + +; -- VDMA_DEST_HIGH / HDMA3 ($FF53) ------------------------------------------- +; (CGB only) VRAM DMA destination address (high 8 bits) [wo] +def rVDMA_DEST_HIGH equ $FF53 + +; -- VDMA_DEST_LOW / HDMA4 ($FF54) -------------------------------------------- +; (CGB only) VRAM DMA destination address (low 8 bits) [wo] +def rVDMA_DEST_LOW equ $FF54 + +; -- VDMA_LEN / HDMA5 ($FF55) ------------------------------------------------- +; (CGB only) VRAM DMA length, mode, and start +def rVDMA_LEN equ $FF55 + +def B_VDMA_LEN_MODE equ 7 ; on write: VRAM DMA mode [wo] + def VDMA_LEN_MODE equ 1 << B_VDMA_LEN_MODE + def VDMA_LEN_MODE_GENERAL equ 0 << B_VDMA_LEN_MODE ; GDMA (general-purpose) + def VDMA_LEN_MODE_HBLANK equ 1 << B_VDMA_LEN_MODE ; HDMA (HBlank) + +def B_VDMA_LEN_BUSY equ 7 ; on read: is a VRAM DMA active? + def VDMA_LEN_BUSY equ 1 << B_VDMA_LEN_BUSY + def VDMA_LEN_NO equ 0 << B_VDMA_LEN_BUSY + def VDMA_LEN_YES equ 1 << B_VDMA_LEN_BUSY + +def VDMA_LEN_SIZE equ %0_1111111 ; how many 16-byte blocks (minus 1) to transfer [r/w] + +; -- RP ($FF56) --------------------------------------------------------------- +; (CGB only) Infrared communications port +def rRP equ $FF56 + +def RP_READ equ %11_000000 ; whether the IR read is enabled [r/w] + def RP_DISABLE equ %00_000000 + def RP_ENABLE equ %11_000000 + +def B_RP_DATA_IN equ 1 ; 0 = IR light is being received [ro] +def B_RP_LED_ON equ 0 ; 1 = IR light is being sent [r/w] + def RP_DATA_IN equ 1 << B_RP_DATA_IN + def RP_LED_ON equ 1 << B_RP_LED_ON + def RP_WRITE_LOW equ 0 << B_RP_LED_ON + def RP_WRITE_HIGH equ 1 << B_RP_LED_ON + +; -- $FF57-$FF67 are unused --------------------------------------------------- + +; -- BGPI / BCPS ($FF68) ------------------------------------------------------ +; (CGB only) Background palette I/O index +def rBGPI equ $FF68 + +def B_BGPI_AUTOINC equ 7 ; whether the index field is incremented after each write to BCPD [r/w] + def BGPI_AUTOINC equ 1 << B_BGPI_AUTOINC + +def BGPI_INDEX equ %00_111111 ; the index within Palette RAM accessed via BCPD [r/w] + +; -- BGPD / BCPD ($FF69) ------------------------------------------------------ +; (CGB only) Background palette I/O access [r/w] +def rBGPD equ $FF69 + +; -- OBPI / OCPS ($FF6A) ------------------------------------------------------ +; (CGB only) OBJ palette I/O index +def rOBPI equ $FF6A + +def B_OBPI_AUTOINC equ 7 ; whether the index field is incremented after each write to OBPD [r/w] + def OBPI_AUTOINC equ 1 << B_OBPI_AUTOINC + +def OBPI_INDEX equ %00_111111 ; the index within Palette RAM accessed via OBPD [r/w] + +; -- OBPD / OCPD ($FF6B) ------------------------------------------------------ +; (CGB only) OBJ palette I/O access [r/w] +def rOBPD equ $FF6B + +; -- OPRI ($FF6C) ------------------------------------------------------------- +; (CGB boot ROM only) OBJ draw priority mode +def rOPRI equ $FF6C + +def B_OPRI_PRIORITY equ 0 ; which drawing priority is used for OBJs [r/w] + def OPRI_PRIORITY equ 1 << B_OPRI_PRIORITY + def OPRI_OAM equ 0 << B_OPRI_PRIORITY ; CGB mode default: earliest OBJ in OAM wins + def OPRI_COORD equ 1 << B_OPRI_PRIORITY ; DMG mode default: leftmost OBJ wins + +; -- $FF6D-$FF6F are unused --------------------------------------------------- + +; -- WBK / SVBK ($FF70) ------------------------------------------------------- +; (CGB only) WRAM bank number +def rWBK equ $FF70 + +def WBK_BANK equ %00000_111 ; mapped WRAM bank (0-7) [r/w] + +; -- $FF71-$FF75 are unused --------------------------------------------------- + +; -- PCM12 ($FF76) ------------------------------------------------------------ +; Audio channels 1 and 2 output +def rPCM12 equ $FF76 + +def PCM12_CH2 equ %1111_0000 ; audio channel 2 output [ro] +def PCM12_CH1 equ %0000_1111 ; audio channel 1 output [ro] + +; -- PCM34 ($FF77) ------------------------------------------------------------ +; Audio channels 3 and 4 output +def rPCM34 equ $FF77 + +def PCM34_CH4 equ %1111_0000 ; audio channel 4 output [ro] +def PCM34_CH3 equ %0000_1111 ; audio channel 3 output [ro] + +; -- $FF78-$FF7F are unused --------------------------------------------------- + +; -- IE ($FFFF) --------------------------------------------------------------- +; Interrupt enable +def rIE equ $FFFF + +def B_IE_JOYPAD equ 4 ; 1 = joypad interrupt is enabled [r/w] +def B_IE_SERIAL equ 3 ; 1 = serial interrupt is enabled [r/w] +def B_IE_TIMER equ 2 ; 1 = timer interrupt is enabled [r/w] +def B_IE_STAT equ 1 ; 1 = STAT interrupt is enabled [r/w] +def B_IE_VBLANK equ 0 ; 1 = VBlank interrupt is enabled [r/w] + def IE_JOYPAD equ 1 << B_IE_JOYPAD + def IE_SERIAL equ 1 << B_IE_SERIAL + def IE_TIMER equ 1 << B_IE_TIMER + def IE_STAT equ 1 << B_IE_STAT + def IE_VBLANK equ 1 << B_IE_VBLANK + + +;****************************************************************************** +; Cartridge registers (MBC) +;****************************************************************************** + +; Note that these "registers" are each actually accessible at an entire address range; +; however, one address for each of these ranges is considered the "canonical" one, and +; these addresses are what's provided here. + + +; ** Common to most MBCs ****************************************************** + +; -- RAMG ($0000-$1FFF) ------------------------------------------------------- +; Whether SRAM can be accessed [wo] +def rRAMG equ $0000 + +; Common values (not for HuC1 or HuC-3) +def RAMG_SRAM_DISABLE equ $00 +def RAMG_SRAM_ENABLE equ $0A ; some MBCs accept any value whose low nybble is $A + +; (HuC-3 only) switch SRAM to map cartridge RAM, RTC, or IR +def RAMG_CART_RAM_RO equ $00 ; select cartridge RAM [ro] +def RAMG_CART_RAM equ $0A ; select cartridge RAM [r/w] +def RAMG_RTC_IN equ $0B ; select RTC command/argument [wo] + def RAMG_RTC_IN_CMD equ %0_111_0000 ; command + def RAMG_RTC_IN_ARG equ %0_000_1111 ; argument +def RAMG_RTC_OUT equ $0C ; select RTC command/response [ro] + def RAMG_RTC_OUT_CMD equ %0_111_0000 ; command + def RAMG_RTC_OUT_RESULT equ %0_000_1111 ; result +def RAMG_RTC_SEMAPHORE equ $0D ; select RTC semaphore [r/w] +def RAMG_IR equ $0E ; (HuC1 and HuC-3 only) select IR [r/w] + +; -- ROMB ($2000-$3FFF) ------------------------------------------------------- +; ROM bank number (not for MBC5 or MBC6) [wo] +def rROMB equ $2000 + +; -- RAMB ($4000-$5FFF) ------------------------------------------------------- +; SRAM bank number (not for MBC2, MBC6, or MBC7) [wo] +def rRAMB equ $4000 + +; (MBC3 only) Special RAM bank numbers that actually map values into RTCREG +def RAMB_RTC_S equ $08 ; seconds counter (0-59) +def RAMB_RTC_M equ $09 ; minutes counter (0-59) +def RAMB_RTC_H equ $0A ; hours counter (0-23) +def RAMB_RTC_DL equ $0B ; days counter, low byte (0-255) +def RAMB_RTC_DH equ $0C ; days counter, high bit and other flags + def B_RAMB_RTC_DH_CARRY equ 7 ; 1 = days counter overflowed [wo] + def B_RAMB_RTC_DH_HALT equ 6 ; 0 = run timer, 1 = stop timer [wo] + def B_RAMB_RTC_DH_HIGH equ 0 ; days counter, high bit (bit 8) [wo] + def RAMB_RTC_DH_CARRY equ 1 << B_RAMB_RTC_DH_CARRY + def RAMB_RTC_DH_HALT equ 1 << B_RAMB_RTC_DH_HALT + def RAMB_RTC_DH_HIGH equ 1 << B_RAMB_RTC_DH_HIGH + +def B_RAMB_RUMBLE equ 3 ; (MBC5 and MBC7 only) enable the rumble motor (if any) + def RAMB_RUMBLE equ 1 << B_RAMB_RUMBLE + def RAMB_RUMBLE_OFF equ 0 << B_RAMB_RUMBLE + def RAMB_RUMBLE_ON equ 1 << B_RAMB_RUMBLE + + +; ** MBC1 and MMM01 only ****************************************************** + +; -- BMODE ($6000-$7FFF) ------------------------------------------------------ +; Banking mode select [wo] +def rBMODE equ $6000 + +def BMODE_SIMPLE equ $00 ; locks ROMB and RAMB to bank 0 +def BMODE_ADVANCED equ $01 ; allows bank-switching with RAMB + + +; ** MBC2 only **************************************************************** + +; -- ROM2B ($0000-$3FFF with bit 8 set) --------------------------------------- +; ROM bank number [wo] +def rROM2B equ $2100 + + +; ** MBC3 only **************************************************************** + +; -- RTCLATCH ($6000-$7FFF) --------------------------------------------------- +; RTC latch clock data [wo] +def rRTCLATCH equ $6000 + +; Write $00 then $01 to latch the current time into RTCREG +def RTCLATCH_START equ $00 +def RTCLATCH_FINISH equ $01 + +; -- RTCREG ($A000-$BFFF) ----------------------------------------------------- +; RTC register [r/w] +def rRTCREG equ $A000 + + +; ** MBC5 only **************************************************************** + +; -- ROMB0 ($2000-$2FFF) ------------------------------------------------------ +; ROM bank number low byte (bits 0-7) [wo] +def rROMB0 equ $2000 + +; -- ROMB1 ($3000-$3FFF) ------------------------------------------------------ +; ROM bank number high bit (bit 8) [wo] +def rROMB1 equ $3000 + + +; ** MBC6 only **************************************************************** + +; -- RAMBA ($0400-$07FF) ------------------------------------------------------ +; RAM bank A number [wo] +def rRAMBA equ $0400 + +; -- RAMBB ($0800-$0BFF) ------------------------------------------------------ +; RAM bank B number [wo] +def rRAMBB equ $0800 + +; -- FLASH ($0C00-$0FFF) ------------------------------------------------------ +; Whether the flash chip can be accessed [wo] +def rFLASH equ $0C00 + +; -- FMODE ($1000) ------------------------------------------------------------ +; Write mode select for the flash chip +def rFMODE equ $1000 + +; -- ROMBA ($2000-$27FF) ------------------------------------------------------ +; ROM/Flash bank A number [wo] +def rROMBA equ $2000 + +; -- FLASHA ($2800-$2FFF) ----------------------------------------------------- +; ROM/Flash bank A select [wo] +def rFLASHA equ $2800 + +; -- ROMBB ($3000-$37FF) ------------------------------------------------------ +; ROM/Flash bank B number [wo] +def rROMBB equ $3000 + +; -- FLASHB ($3800-$3FFF) ----------------------------------------------------- +; ROM/Flash bank B select [wo] +def rFLASHB equ $3800 + + +; ** MBC7 only **************************************************************** + +; -- RAMREG ($4000-$5FFF) ----------------------------------------------------- +; Enable RAM register access [wo] +def rRAMREG equ $4000 + +def RAMREG_ENABLE equ $40 + +; -- ACCLATCH0 ($Ax0x) -------------------------------------------------------- +; Latch accelerometer start [wo] +def rACCLATCH0 equ $A000 + +; Write $55 to ACCLATCH0 to erase the latched data +def ACCLATCH0_START equ $55 + +; -- ACCLATCH1 ($Ax1x) -------------------------------------------------------- +; Latch accelerometer finish [wo] +def rACCLATCH1 equ $A010 + +; Write $AA to ACCLATCH1 to latch the accelerometer and update ACCEL* +def ACCLATCH1_FINISH equ $AA + +; -- ACCELX0 ($Ax2x) ---------------------------------------------------------- +; Accelerometer X value low byte [ro] +def rACCELX0 equ $A020 + +; -- ACCELX1 ($Ax3x) ---------------------------------------------------------- +; Accelerometer X value high byte [ro] +def rACCELX1 equ $A030 + +; -- ACCELY0 ($Ax4x) ---------------------------------------------------------- +; Accelerometer Y value low byte [ro] +def rACCELY0 equ $A040 + +; -- ACCELY1 ($Ax5x) ---------------------------------------------------------- +; Accelerometer Y value high byte [ro] +def rACCELY1 equ $A050 + +; -- EEPROM ($Ax8x) ----------------------------------------------------------- +; EEPROM access [r/w] +def rEEPROM equ $A080 + + +; ** HuC1 only **************************************************************** + +; -- IRREG ($A000-$BFFF) ------------------------------------------------------ +; IR register [r/w] +def rIRREG equ $A000 + +; whether the IR transmitter sees light +def IR_LED_OFF equ $C0 +def IR_LED_ON equ $C1 + + +;****************************************************************************** +; Screen-related constants +;****************************************************************************** + +def SCREEN_WIDTH_PX equ 160 ; width of screen in pixels +def SCREEN_HEIGHT_PX equ 144 ; height of screen in pixels +def SCREEN_WIDTH equ 20 ; width of screen in bytes +def SCREEN_HEIGHT equ 18 ; height of screen in bytes +def SCREEN_AREA equ SCREEN_WIDTH * SCREEN_HEIGHT ; size of screen in bytes + +def TILEMAP_WIDTH_PX equ 256 ; width of tilemap in pixels +def TILEMAP_HEIGHT_PX equ 256 ; height of tilemap in pixels +def TILEMAP_WIDTH equ 32 ; width of tilemap in bytes +def TILEMAP_HEIGHT equ 32 ; height of tilemap in bytes +def TILEMAP_AREA equ TILEMAP_WIDTH * TILEMAP_HEIGHT ; size of tilemap in bytes + +def TILE_WIDTH equ 8 ; width of tile in pixels +def TILE_HEIGHT equ 8 ; height of tile in pixels +def TILE_SIZE equ 16 ; size of tile in bytes (2 bits/pixel) + +def COLOR_SIZE equ 2 ; size of color in bytes (little-endian BGR555) +def PAL_COLORS equ 4 ; colors per palette +def PAL_SIZE equ COLOR_SIZE * PAL_COLORS ; size of palette in bytes + +def COLOR_CH_WIDTH equ 5 ; bits per RGB color channel +def COLOR_CH_MAX equ (1 << COLOR_CH_WIDTH) - 1 + def B_COLOR_RED equ COLOR_CH_WIDTH * 0 ; bits 4-0 + def B_COLOR_GREEN equ COLOR_CH_WIDTH * 1 ; bits 9-5 + def B_COLOR_BLUE equ COLOR_CH_WIDTH * 2 ; bits 14-10 + def COLOR_RED equ %000_11111 ; for the low byte + def COLOR_GREEN_LOW equ %111_00000 ; for the low byte + def COLOR_GREEN_HIGH equ %0_00000_11 ; for the high byte + def COLOR_BLUE equ %0_11111_00 ; for the high byte + +; (DMG only) grayscale shade indexes for BGP, OBP0, and OBP1 +def SHADE_WHITE equ %00 +def SHADE_LIGHT equ %01 +def SHADE_DARK equ %10 +def SHADE_BLACK equ %11 + +; Tilemaps the BG or Window can read from (controlled by LCDC) +def TILEMAP0 equ $9800 ; $9800-$9BFF +def TILEMAP1 equ $9C00 ; $9C00-$9FFF + +; (CGB only) BG tile attribute fields +def B_BG_PRIO equ 7 ; whether the BG tile colors 1-3 are drawn above OBJs +def B_BG_YFLIP equ 6 ; whether the whole BG tile is flipped vertically +def B_BG_XFLIP equ 5 ; whether the whole BG tile is flipped horizontally +def B_BG_BANK1 equ 3 ; which VRAM bank the BG tile is taken from +def BG_PALETTE equ %00000_111 ; which palette the BG tile uses + def BG_PRIO equ 1 << B_BG_PRIO + def BG_YFLIP equ 1 << B_BG_YFLIP + def BG_XFLIP equ 1 << B_BG_XFLIP + def BG_BANK0 equ 0 << B_BG_BANK1 + def BG_BANK1 equ 1 << B_BG_BANK1 + + +;****************************************************************************** +; OBJ-related constants +;****************************************************************************** + +; OAM attribute field offsets +rsreset +def OAMA_Y rb ; 0 + def OAM_Y_OFS equ 16 ; subtract 16 from what's written to OAM to get the real Y position +def OAMA_X rb ; 1 + def OAM_X_OFS equ 8 ; subtract 8 from what's written to OAM to get the real X position +def OAMA_TILEID rb ; 2 +def OAMA_FLAGS rb ; 3 + def B_OAM_PRIO equ 7 ; whether the OBJ is drawn below BG colors 1-3 + def B_OAM_YFLIP equ 6 ; whether the whole OBJ is flipped vertically + def B_OAM_XFLIP equ 5 ; whether the whole OBJ is flipped horizontally + def B_OAM_PAL1 equ 4 ; (DMG only) which of the two palettes the OBJ uses + def B_OAM_BANK1 equ 3 ; (CGB only) which VRAM bank the OBJ takes its tile(s) from + def OAM_PALETTE equ %00000_111 ; (CGB only) which palette the OBJ uses + def OAM_PRIO equ 1 << B_OAM_PRIO + def OAM_YFLIP equ 1 << B_OAM_YFLIP + def OAM_XFLIP equ 1 << B_OAM_XFLIP + def OAM_PAL0 equ 0 << B_OAM_PAL1 + def OAM_PAL1 equ 1 << B_OAM_PAL1 + def OAM_BANK0 equ 0 << B_OAM_BANK1 + def OAM_BANK1 equ 1 << B_OAM_BANK1 +def OBJ_SIZE rb 0 ; size of OBJ in bytes = 4 + +def OAM_COUNT equ 40 ; how many OBJs there are room for in OAM +def OAM_SIZE equ OBJ_SIZE * OAM_COUNT + + +;****************************************************************************** +; Audio channel RAM addresses +;****************************************************************************** + +def AUD1RAM equ $FF10 ; $FF10-$FF14 +def AUD2RAM equ $FF15 ; $FF15-$FF19 +def AUD3RAM equ $FF1A ; $FF1A-$FF1E +def AUD4RAM equ $FF1F ; $FF1F-$FF23 +def AUDRAM_SIZE equ 5 ; size of each audio channel RAM in bytes + +def _AUD3WAVERAM equ $FF30 ; $FF30-$FF3F +def AUD3WAVE_SIZE equ 16 ; size of wave pattern RAM in bytes + + +;****************************************************************************** +; Interrupt vector addresses +;****************************************************************************** + +def INT_HANDLER_VBLANK equ $0040 ; VBlank interrupt handler address +def INT_HANDLER_STAT equ $0048 ; STAT interrupt handler address +def INT_HANDLER_TIMER equ $0050 ; timer interrupt handler address +def INT_HANDLER_SERIAL equ $0058 ; serial interrupt handler address +def INT_HANDLER_JOYPAD equ $0060 ; joypad interrupt handler address + + +;****************************************************************************** +; Boot-up register values +;****************************************************************************** + +; Register A = CPU type +def BOOTUP_A_DMG equ $01 +def BOOTUP_A_CGB equ $11 ; CGB or AGB +def BOOTUP_A_MGB equ $FF + def BOOTUP_A_SGB equ BOOTUP_A_DMG + def BOOTUP_A_SGB2 equ BOOTUP_A_MGB + +; Register B = CPU qualifier (if A is BOOTUP_A_CGB) +def B_BOOTUP_B_AGB equ 0 + def BOOTUP_B_CGB equ 0 << B_BOOTUP_B_AGB + def BOOTUP_B_AGB equ 1 << B_BOOTUP_B_AGB + +; Register C = CPU qualifier +def BOOTUP_C_DMG equ $13 +def BOOTUP_C_SGB equ $14 +def BOOTUP_C_CGB equ $00 ; CGB or AGB + +; Register D = color qualifier +def BOOTUP_D_MONO equ $00 ; DMG, MGB, SGB, or CGB or AGB in DMG mode +def BOOTUP_D_COLOR equ $FF ; CGB or AGB + +; Register E = CPU qualifier (distinguishes DMG variants) +def BOOTUP_E_DMG0 equ $C1 +def BOOTUP_E_DMG equ $C8 +def BOOTUP_E_SGB equ $00 +def BOOTUP_E_CGB_DMGMODE equ $08 ; CGB or AGB in DMG mode +def BOOTUP_E_CGB equ $56 ; CGB or AGB + + +;****************************************************************************** +; Aliases +;****************************************************************************** + +; Prefer the standard names to these aliases, which may be official but are +; less directly meaningful or human-readable. + +def rP1 equ rJOYP + +def rNR10 equ rAUD1SWEEP +def rNR11 equ rAUD1LEN +def rNR12 equ rAUD1ENV +def rNR13 equ rAUD1LOW +def rNR14 equ rAUD1HIGH +def rNR21 equ rAUD2LEN +def rNR22 equ rAUD2ENV +def rNR23 equ rAUD2LOW +def rNR24 equ rAUD2HIGH +def rNR30 equ rAUD3ENA +def rNR31 equ rAUD3LEN +def rNR32 equ rAUD3LEVEL +def rNR33 equ rAUD3LOW +def rNR34 equ rAUD3HIGH +def rNR41 equ rAUD4LEN +def rNR42 equ rAUD4ENV +def rNR43 equ rAUD4POLY +def rNR44 equ rAUD4GO +def rNR50 equ rAUDVOL +def rNR51 equ rAUDTERM +def rNR52 equ rAUDENA + +def rKEY0 equ rSYS +def rKEY1 equ rSPD + +def rHDMA1 equ rVDMA_SRC_HIGH +def rHDMA2 equ rVDMA_SRC_LOW +def rHDMA3 equ rVDMA_DEST_HIGH +def rHDMA4 equ rVDMA_DEST_LOW +def rHDMA5 equ rVDMA_LEN + +def rBCPS equ rBGPI +def rBCPD equ rBGPD + +def rOCPS equ rOBPI +def rOCPD equ rOBPD + +def rSVBK equ rWBK + +endc ; HARDWARE_INC diff --git a/constants/hardware_constants.asm b/constants/hardware_constants.asm deleted file mode 100644 index 6c5d43c169..0000000000 --- a/constants/hardware_constants.asm +++ /dev/null @@ -1,126 +0,0 @@ -; Reference documents: -; https://gbdev.io/pandocs/ -; https://github.com/gbdev/hardware.inc - -DEF CGB EQU $11 - -; MBC1 -DEF MBC1SRamEnable EQU $0000 -DEF MBC1RomBank EQU $2000 -DEF MBC1SRamBank EQU $4000 -DEF MBC1SRamBankingMode EQU $6000 - -DEF SRAM_DISABLE EQU $00 -DEF SRAM_ENABLE EQU $0a - -DEF NUM_SRAM_BANKS EQU 4 - -; interrupt flags -DEF VBLANK EQU 0 -DEF LCD_STAT EQU 1 -DEF TIMER EQU 2 -DEF SERIAL EQU 3 -DEF JOYPAD EQU 4 - -DEF LY_VBLANK EQU 145 - -; serial -DEF START_TRANSFER_EXTERNAL_CLOCK EQU $80 -DEF START_TRANSFER_INTERNAL_CLOCK EQU $81 - -; Hardware registers -DEF rJOYP EQU $ff00 ; Joypad (R/W) -DEF rSB EQU $ff01 ; Serial transfer data (R/W) -DEF rSC EQU $ff02 ; Serial Transfer Control (R/W) -DEF rSC_ON EQU 7 -DEF rSC_CGB EQU 1 -DEF rSC_CLOCK EQU 0 -DEF rDIV EQU $ff04 ; Divider Register (R/W) -DEF rTIMA EQU $ff05 ; Timer counter (R/W) -DEF rTMA EQU $ff06 ; Timer Modulo (R/W) -DEF rTAC EQU $ff07 ; Timer Control (R/W) -DEF rTAC_ON EQU 2 -DEF rTAC_4096_HZ EQU 0 -DEF rTAC_262144_HZ EQU 1 -DEF rTAC_65536_HZ EQU 2 -DEF rTAC_16384_HZ EQU 3 -DEF rIF EQU $ff0f ; Interrupt Flag (R/W) -DEF rNR10 EQU $ff10 ; Channel 1 Sweep register (R/W) -DEF rNR11 EQU $ff11 ; Channel 1 Sound length/Wave pattern duty (R/W) -DEF rNR12 EQU $ff12 ; Channel 1 Volume Envelope (R/W) -DEF rNR13 EQU $ff13 ; Channel 1 Frequency lo (Write Only) -DEF rNR14 EQU $ff14 ; Channel 1 Frequency hi (R/W) -DEF rNR21 EQU $ff16 ; Channel 2 Sound Length/Wave Pattern Duty (R/W) -DEF rNR22 EQU $ff17 ; Channel 2 Volume Envelope (R/W) -DEF rNR23 EQU $ff18 ; Channel 2 Frequency lo data (W) -DEF rNR24 EQU $ff19 ; Channel 2 Frequency hi data (R/W) -DEF rNR30 EQU $ff1a ; Channel 3 Sound on/off (R/W) -DEF rNR31 EQU $ff1b ; Channel 3 Sound Length -DEF rNR32 EQU $ff1c ; Channel 3 Select output level (R/W) -DEF rNR33 EQU $ff1d ; Channel 3 Frequency's lower data (W) -DEF rNR34 EQU $ff1e ; Channel 3 Frequency's higher data (R/W) -DEF rNR41 EQU $ff20 ; Channel 4 Sound Length (R/W) -DEF rNR42 EQU $ff21 ; Channel 4 Volume Envelope (R/W) -DEF rNR43 EQU $ff22 ; Channel 4 Polynomial Counter (R/W) -DEF rNR44 EQU $ff23 ; Channel 4 Counter/consecutive; Initial (R/W) -DEF rNR50 EQU $ff24 ; Channel control / ON-OFF / Volume (R/W) -DEF rNR51 EQU $ff25 ; Selection of Sound output terminal (R/W) -DEF rNR52 EQU $ff26 ; Sound on/off -DEF rWave_0 EQU $ff30 -DEF rWave_1 EQU $ff31 -DEF rWave_2 EQU $ff32 -DEF rWave_3 EQU $ff33 -DEF rWave_4 EQU $ff34 -DEF rWave_5 EQU $ff35 -DEF rWave_6 EQU $ff36 -DEF rWave_7 EQU $ff37 -DEF rWave_8 EQU $ff38 -DEF rWave_9 EQU $ff39 -DEF rWave_a EQU $ff3a -DEF rWave_b EQU $ff3b -DEF rWave_c EQU $ff3c -DEF rWave_d EQU $ff3d -DEF rWave_e EQU $ff3e -DEF rWave_f EQU $ff3f -DEF rLCDC EQU $ff40 ; LCD Control (R/W) -DEF rLCDC_BG_PRIORITY EQU 0 -DEF rLCDC_SPRITES_ENABLE EQU 1 -DEF rLCDC_SPRITE_SIZE EQU 2 -DEF rLCDC_BG_TILEMAP EQU 3 -DEF rLCDC_TILE_DATA EQU 4 -DEF rLCDC_WINDOW_ENABLE EQU 5 -DEF rLCDC_WINDOW_TILEMAP EQU 6 -DEF rLCDC_ENABLE EQU 7 -DEF rSTAT EQU $ff41 ; LCDC Status (R/W) -DEF rSCY EQU $ff42 ; Scroll Y (R/W) -DEF rSCX EQU $ff43 ; Scroll X (R/W) -DEF rLY EQU $ff44 ; LCDC Y-Coordinate (R) -DEF rLYC EQU $ff45 ; LY Compare (R/W) -DEF rDMA EQU $ff46 ; DMA Transfer and Start Address (W) -DEF rBGP EQU $ff47 ; BG Palette Data (R/W) - Non CGB Mode Only -DEF rOBP0 EQU $ff48 ; Object Palette 0 Data (R/W) - Non CGB Mode Only -DEF rOBP1 EQU $ff49 ; Object Palette 1 Data (R/W) - Non CGB Mode Only -DEF rWY EQU $ff4a ; Window Y Position (R/W) -DEF rWX EQU $ff4b ; Window X Position minus 7 (R/W) -DEF rKEY1 EQU $ff4d ; CGB Mode Only - Prepare Speed Switch -DEF rVBK EQU $ff4f ; CGB Mode Only - VRAM Bank -DEF rHDMA1 EQU $ff51 ; CGB Mode Only - New DMA Source, High -DEF rHDMA2 EQU $ff52 ; CGB Mode Only - New DMA Source, Low -DEF rHDMA3 EQU $ff53 ; CGB Mode Only - New DMA Destination, High -DEF rHDMA4 EQU $ff54 ; CGB Mode Only - New DMA Destination, Low -DEF rHDMA5 EQU $ff55 ; CGB Mode Only - New DMA Length/Mode/Start -DEF rRP EQU $ff56 ; CGB Mode Only - Infrared Communications Port -DEF rBGPI EQU $ff68 ; CGB Mode Only - Background Palette Index -DEF rBGPD EQU $ff69 ; CGB Mode Only - Background Palette Data -DEF rOBPI EQU $ff6a ; CGB Mode Only - Sprite Palette Index -DEF rOBPD EQU $ff6b ; CGB Mode Only - Sprite Palette Data -DEF rOPRI EQU $ff6c ; CGB Mode Only - Object Priority Mode -DEF rSVBK EQU $ff70 ; CGB Mode Only - WRAM Bank -DEF rPCM12 EQU $ff76 ; Channels 1 & 2 Amplitude (R) -DEF rPCM34 EQU $ff77 ; Channels 3 & 4 Amplitude (R) -DEF rIE EQU $ffff ; Interrupt Enable (R/W) -DEF rIE_VBLANK EQU 0 -DEF rIE_LCD EQU 1 -DEF rIE_TIMER EQU 2 -DEF rIE_SERIAL EQU 3 -DEF rIE_JOYPAD EQU 4 diff --git a/constants/input_constants.asm b/constants/input_constants.asm deleted file mode 100644 index 68233dea2a..0000000000 --- a/constants/input_constants.asm +++ /dev/null @@ -1,20 +0,0 @@ -; joypad buttons - const_def - const BIT_A_BUTTON ; 0 - const BIT_B_BUTTON ; 1 - const BIT_SELECT ; 2 - const BIT_START ; 3 - const BIT_D_RIGHT ; 4 - const BIT_D_LEFT ; 5 - const BIT_D_UP ; 6 - const BIT_D_DOWN ; 7 - -DEF NO_INPUT EQU 0 -DEF A_BUTTON EQU 1 << BIT_A_BUTTON -DEF B_BUTTON EQU 1 << BIT_B_BUTTON -DEF SELECT EQU 1 << BIT_SELECT -DEF START EQU 1 << BIT_START -DEF D_RIGHT EQU 1 << BIT_D_RIGHT -DEF D_LEFT EQU 1 << BIT_D_LEFT -DEF D_UP EQU 1 << BIT_D_UP -DEF D_DOWN EQU 1 << BIT_D_DOWN diff --git a/constants/item_constants.asm b/constants/item_constants.asm index 2137131224..9f8aa51699 100644 --- a/constants/item_constants.asm +++ b/constants/item_constants.asm @@ -92,7 +92,7 @@ const MAX_ELIXER ; $53 DEF NUM_ITEMS EQU const_value - 1 -; elevator floors use item IDs +; elevator floors use item IDs (see scripts/CeladonMartElevator.asm and scripts/SilphCoElevator.asm) const FLOOR_B2F ; $54 const FLOOR_B1F ; $55 const FLOOR_1F ; $56 diff --git a/constants/map_constants.asm b/constants/map_constants.asm index de74884629..642d6095b4 100644 --- a/constants/map_constants.asm +++ b/constants/map_constants.asm @@ -4,6 +4,13 @@ MACRO map_const DEF \1_HEIGHT EQU \3 ENDM +; "Indoor" maps are grouped sequentially (see data/maps/town_map_entries.asm) +DEF NUM_INDOOR_MAP_GROUPS EQU 0 +MACRO end_indoor_group + DEF INDOORGROUP_\1 EQU const_value + REDEF NUM_INDOOR_MAP_GROUPS EQU NUM_INDOOR_MAP_GROUPS + 1 +ENDM + ; map ids ; indexes for: ; - MapHeaderBanks (see data/maps/map_header_banks.asm) @@ -28,7 +35,9 @@ ENDM map_const CINNABAR_ISLAND, 10, 9 ; $09 map_const INDIGO_PLATEAU, 10, 9 ; $0A DEF NUM_CITY_MAPS EQU const_value + map_const UNUSED_MAP_0B, 0, 0 ; $0B ; unused map + DEF FIRST_ROUTE_MAP EQU const_value map_const ROUTE_1, 10, 18 ; $0C map_const ROUTE_2, 10, 36 ; $0D @@ -55,22 +64,31 @@ DEF FIRST_ROUTE_MAP EQU const_value map_const ROUTE_23, 10, 72 ; $22 map_const ROUTE_24, 10, 18 ; $23 map_const ROUTE_25, 30, 10 ; $24 + DEF FIRST_INDOOR_MAP EQU const_value map_const REDS_HOUSE_1F, 4, 4 ; $25 map_const REDS_HOUSE_2F, 4, 4 ; $26 map_const BLUES_HOUSE, 4, 4 ; $27 map_const OAKS_LAB, 5, 6 ; $28 + end_indoor_group PALLET_TOWN + map_const VIRIDIAN_POKECENTER, 7, 4 ; $29 map_const VIRIDIAN_MART, 4, 4 ; $2A map_const VIRIDIAN_SCHOOL_HOUSE, 4, 4 ; $2B map_const VIRIDIAN_NICKNAME_HOUSE, 4, 4 ; $2C map_const VIRIDIAN_GYM, 10, 9 ; $2D + end_indoor_group VIRIDIAN_CITY + map_const DIGLETTS_CAVE_ROUTE_2, 4, 4 ; $2E map_const VIRIDIAN_FOREST_NORTH_GATE, 5, 4 ; $2F map_const ROUTE_2_TRADE_HOUSE, 4, 4 ; $30 map_const ROUTE_2_GATE, 5, 4 ; $31 map_const VIRIDIAN_FOREST_SOUTH_GATE, 5, 4 ; $32 + end_indoor_group ROUTE_2 + map_const VIRIDIAN_FOREST, 17, 24 ; $33 + end_indoor_group VIRIDIAN_FOREST + map_const MUSEUM_1F, 10, 4 ; $34 map_const MUSEUM_2F, 7, 4 ; $35 map_const PEWTER_GYM, 5, 7 ; $36 @@ -78,42 +96,72 @@ DEF FIRST_INDOOR_MAP EQU const_value map_const PEWTER_MART, 4, 4 ; $38 map_const PEWTER_SPEECH_HOUSE, 4, 4 ; $39 map_const PEWTER_POKECENTER, 7, 4 ; $3A + end_indoor_group PEWTER_CITY + map_const MT_MOON_1F, 20, 18 ; $3B map_const MT_MOON_B1F, 14, 14 ; $3C map_const MT_MOON_B2F, 20, 18 ; $3D + end_indoor_group MT_MOON + map_const CERULEAN_TRASHED_HOUSE, 4, 4 ; $3E map_const CERULEAN_TRADE_HOUSE, 4, 4 ; $3F map_const CERULEAN_POKECENTER, 7, 4 ; $40 map_const CERULEAN_GYM, 5, 7 ; $41 map_const BIKE_SHOP, 6, 4 ; $42 map_const CERULEAN_MART, 4, 4 ; $43 + end_indoor_group CERULEAN_CITY + map_const MT_MOON_POKECENTER, 7, 4 ; $44 + end_indoor_group ROUTE_4 + map_const POWER_PLANT_ROOF, 15, 8 ; $45 + end_indoor_group CERULEAN_CITY_2 + map_const ROUTE_5_GATE, 4, 3 ; $46 map_const UNDERGROUND_PATH_ROUTE_5, 4, 4 ; $47 map_const DAYCARE, 4, 4 ; $48 + end_indoor_group ROUTE_5 + map_const ROUTE_6_GATE, 4, 3 ; $49 map_const UNDERGROUND_PATH_ROUTE_6, 4, 4 ; $4A map_const UNDERGROUND_PATH_ROUTE_6_COPY, 4, 4 ; $4B ; pointless map + end_indoor_group ROUTE_6 + map_const ROUTE_7_GATE, 3, 4 ; $4C map_const UNDERGROUND_PATH_ROUTE_7, 4, 4 ; $4D map_const UNDERGROUND_PATH_ROUTE_7_COPY, 4, 4 ; $4E ; pointless map + end_indoor_group ROUTE_7 + map_const ROUTE_8_GATE, 3, 4 ; $4F map_const UNDERGROUND_PATH_ROUTE_8, 4, 4 ; $50 + end_indoor_group ROUTE_8 + map_const ROCK_TUNNEL_POKECENTER, 7, 4 ; $51 map_const ROCK_TUNNEL_1F, 20, 18 ; $52 + end_indoor_group ROCK_TUNNEL + map_const POWER_PLANT, 29, 18 ; $53 + end_indoor_group POWER_PLANT + map_const ROUTE_11_GATE_1F, 4, 5 ; $54 map_const DIGLETTS_CAVE_ROUTE_11, 4, 4 ; $55 map_const ROUTE_11_GATE_2F, 4, 4 ; $56 + end_indoor_group ROUTE_11 + map_const ROUTE_12_GATE_1F, 5, 4 ; $57 + end_indoor_group ROUTE_12 + map_const BILLS_HOUSE, 4, 4 ; $58 + end_indoor_group SEA_COTTAGE + map_const VERMILION_POKECENTER, 7, 4 ; $59 map_const POKEMON_FAN_CLUB, 4, 4 ; $5A map_const VERMILION_MART, 4, 4 ; $5B map_const VERMILION_GYM, 5, 9 ; $5C map_const VERMILION_PIDGEY_HOUSE, 4, 4 ; $5D map_const VERMILION_DOCK, 14, 6 ; $5E + end_indoor_group VERMILION_CITY + map_const SS_ANNE_1F, 20, 9 ; $5F map_const SS_ANNE_2F, 20, 9 ; $60 map_const SS_ANNE_3F, 10, 3 ; $61 @@ -124,10 +172,14 @@ DEF FIRST_INDOOR_MAP EQU const_value map_const SS_ANNE_1F_ROOMS, 12, 8 ; $66 map_const SS_ANNE_2F_ROOMS, 12, 8 ; $67 map_const SS_ANNE_B1F_ROOMS, 12, 8 ; $68 + end_indoor_group SS_ANNE + map_const CERULEAN_OLD_ROD_HOUSE, 4, 5 ; $69 ; PureRGBnote: ADDED: New map map_const CERULEAN_ROCKET_HOUSE_1F, 3, 3 ; $6A ; PureRGBnote: ADDED: New map map_const CERULEAN_ROCKET_HOUSE_B1F, 8, 8 ; $6B ; PureRGBnote: ADDED: New map map_const VICTORY_ROAD_1F, 10, 9 ; $6C + end_indoor_group VICTORY_ROAD + map_const VIRIDIAN_SCHOOL_HOUSE_B1F, 9, 6 ; $6D ; PureRGBnote: ADDED: New map map_const BILLS_GARDEN, 11, 10 ; $6E ; PureRGBnote: ADDED: New map map_const SECRET_LAB, 5, 22 ; $6F ; PureRGBnote: ADDED: New map @@ -138,9 +190,17 @@ DEF FIRST_INDOOR_MAP EQU const_value map_const CINNABAR_VOLCANO, 26, 34 ; $74 ; PureRGBnote: ADDED: New map map_const CINNABAR_VOLCANO_WEST, 15, 10 ; $75 ; PureRGBnote: ADDED: New map map_const HALL_OF_FAME, 5, 4 ; $76 + end_indoor_group POKEMON_LEAGUE + map_const UNDERGROUND_PATH_NORTH_SOUTH, 4, 23 ; $77 ; ERROR: UndergroundPathNorthSouth.blk is actually 4x23 PureRGBnote: FIXED + end_indoor_group UNDERGROUND_PATH + map_const CHAMPIONS_ROOM, 4, 4 ; $78 + end_indoor_group POKEMON_LEAGUE_2 + map_const UNDERGROUND_PATH_WEST_EAST, 25, 4 ; $79 + end_indoor_group UNDERGROUND_PATH_2 + map_const CELADON_MART_1F, 10, 4 ; $7A map_const CELADON_MART_2F, 10, 4 ; $7B map_const CELADON_MART_3F, 10, 4 ; $7C @@ -160,7 +220,11 @@ DEF FIRST_INDOOR_MAP EQU const_value map_const CELADON_DINER, 5, 4 ; $8A map_const CELADON_CHIEF_HOUSE, 4, 4 ; $8B map_const CELADON_HOTEL, 7, 4 ; $8C + end_indoor_group CELADON_CITY + map_const LAVENDER_POKECENTER, 7, 4 ; $8D + end_indoor_group LAVENDER_TOWN + map_const POKEMON_TOWER_1F, 10, 9 ; $8E map_const POKEMON_TOWER_2F, 10, 9 ; $8F map_const POKEMON_TOWER_3F, 10, 9 ; $90 @@ -168,23 +232,41 @@ DEF FIRST_INDOOR_MAP EQU const_value map_const POKEMON_TOWER_5F, 10, 9 ; $92 map_const POKEMON_TOWER_6F, 10, 9 ; $93 map_const POKEMON_TOWER_7F, 10, 9 ; $94 + end_indoor_group POKEMON_TOWER + map_const MR_FUJIS_HOUSE, 4, 4 ; $95 map_const LAVENDER_MART, 4, 4 ; $96 map_const LAVENDER_CUBONE_HOUSE, 4, 4 ; $97 + end_indoor_group LAVENDER_TOWN_2 + map_const FUCHSIA_MART, 4, 4 ; $98 map_const FUCHSIA_BILLS_GRANDPAS_HOUSE, 4, 4 ; $99 map_const FUCHSIA_POKECENTER, 7, 4 ; $9A map_const WARDENS_HOUSE, 5, 4 ; $9B + end_indoor_group FUCHSIA_CITY + map_const SAFARI_ZONE_GATE, 4, 3 ; $9C + end_indoor_group SAFARI_ZONE + map_const FUCHSIA_GYM, 5, 9 ; $9D map_const FUCHSIA_MEETING_ROOM, 7, 4 ; $9E + end_indoor_group FUCHSIA_CITY_2 + map_const SEAFOAM_ISLANDS_B1F, 15, 9 ; $9F map_const SEAFOAM_ISLANDS_B2F, 15, 9 ; $A0 map_const SEAFOAM_ISLANDS_B3F, 15, 9 ; $A1 map_const SEAFOAM_ISLANDS_B4F, 15, 9 ; $A2 + end_indoor_group SEAFOAM_ISLANDS + map_const VERMILION_OLD_ROD_HOUSE, 4, 4 ; $A3 + end_indoor_group VERMILION_CITY_2 + map_const FUCHSIA_GOOD_ROD_HOUSE, 12, 6 ; $A4 + end_indoor_group FUCHSIA_CITY_3 + map_const POKEMON_MANSION_1F, 15, 14 ; $A5 + end_indoor_group POKEMON_MANSION + map_const CINNABAR_GYM, 10, 9 ; $A6 map_const CINNABAR_LAB, 9, 4 ; $A7 map_const CINNABAR_LAB_TRADE_ROOM, 4, 4 ; $A8 @@ -193,7 +275,11 @@ DEF FIRST_INDOOR_MAP EQU const_value map_const CINNABAR_POKECENTER, 7, 4 ; $AB map_const CINNABAR_MART, 4, 4 ; $AC map_const TYPE_GUYS_HOUSE, 7, 4 ; $AD + end_indoor_group CINNABAR_ISLAND + map_const INDIGO_PLATEAU_LOBBY, 8, 6 ; $AE + end_indoor_group INDIGO_PLATEAU + map_const COPYCATS_HOUSE_1F, 4, 4 ; $AF map_const COPYCATS_HOUSE_2F, 4, 4 ; $B0 map_const FIGHTING_DOJO, 5, 6 ; $B1 @@ -203,21 +289,45 @@ DEF FIRST_INDOOR_MAP EQU const_value map_const SILPH_CO_1F, 29, 9 ; $B5 map_const SAFFRON_POKECENTER, 7, 4 ; $B6 map_const MR_PSYCHICS_HOUSE, 4, 4 ; $B7 + end_indoor_group SAFFRON_CITY + map_const ROUTE_15_GATE_1F, 4, 5 ; $B8 map_const ROUTE_15_GATE_2F, 4, 4 ; $B9 + end_indoor_group ROUTE_15 + map_const ROUTE_16_GATE_1F, 4, 7 ; $BA map_const ROUTE_16_GATE_2F, 4, 4 ; $BB map_const ROUTE_16_FLY_HOUSE, 4, 4 ; $BC + end_indoor_group ROUTE_16 + map_const ROUTE_12_SUPER_ROD_HOUSE, 4, 4 ; $BD + end_indoor_group ROUTE_12_2 + map_const ROUTE_18_GATE_1F, 4, 5 ; $BE map_const ROUTE_18_GATE_2F, 4, 4 ; $BF + end_indoor_group ROUTE_18 + map_const SEAFOAM_ISLANDS_1F, 21, 9 ; $C0 + end_indoor_group SEAFOAM_ISLANDS_2 + map_const ROUTE_22_GATE, 5, 4 ; $C1 + end_indoor_group ROUTE_22 + map_const VICTORY_ROAD_2F, 15, 9 ; $C2 + end_indoor_group VICTORY_ROAD_2 + map_const ROUTE_12_GATE_2F, 4, 4 ; $C3 + end_indoor_group ROUTE_12_3 + map_const VERMILION_TRADE_HOUSE, 4, 4 ; $C4 + end_indoor_group VERMILION_CITY_3 + map_const DIGLETTS_CAVE, 20, 18 ; $C5 + end_indoor_group DIGLETTS_CAVE + map_const VICTORY_ROAD_3F, 15, 9 ; $C6 + end_indoor_group VICTORY_ROAD_3 + map_const ROCKET_HIDEOUT_B1F, 15, 14 ; $C7 map_const ROCKET_HIDEOUT_B2F, 15, 14 ; $C8 map_const ROCKET_HIDEOUT_B3F, 15, 14 ; $C9 @@ -226,6 +336,8 @@ DEF FIRST_INDOOR_MAP EQU const_value map_const FUCHSIA_TREE_DELETER_HOUSE, 4, 4 ; $CC ; PureRGBnote: ADDED: New map map_const FOSSIL_GUYS_HOUSE, 11, 4 ; $CD ; PureRGBnote: ADDED: New map map_const UNUSED_MAP_CE, 0, 0 ; $CE ; unused map + end_indoor_group ROCKET_HQ + map_const SILPH_CO_2F, 15, 9 ; $CF map_const SILPH_CO_3F, 15, 9 ; $D0 map_const SILPH_CO_4F, 15, 9 ; $D1 @@ -233,9 +345,13 @@ DEF FIRST_INDOOR_MAP EQU const_value map_const SILPH_CO_6F, 13, 9 ; $D3 map_const SILPH_CO_7F, 13, 9 ; $D4 map_const SILPH_CO_8F, 13, 9 ; $D5 + end_indoor_group SILPH_CO + map_const POKEMON_MANSION_2F, 15, 14 ; $D6 map_const POKEMON_MANSION_3F, 15, 9 ; $D7 map_const POKEMON_MANSION_B1F, 15, 14 ; $D8 + end_indoor_group POKEMON_MANSION_2 + map_const SAFARI_ZONE_EAST, 15, 13 ; $D9 map_const SAFARI_ZONE_NORTH, 20, 18 ; $DA map_const SAFARI_ZONE_WEST, 15, 13 ; $DB @@ -245,17 +361,29 @@ DEF FIRST_INDOOR_MAP EQU const_value map_const SAFARI_ZONE_WEST_REST_HOUSE, 4, 4 ; $DF map_const SAFARI_ZONE_EAST_REST_HOUSE, 4, 4 ; $E0 map_const SAFARI_ZONE_NORTH_REST_HOUSE, 4, 4 ; $E1 + end_indoor_group SAFARI_ZONE_2 + map_const CERULEAN_CAVE_2F, 15, 9 ; $E2 map_const CERULEAN_CAVE_B1F, 15, 9 ; $E3 map_const CERULEAN_CAVE_1F, 15, 9 ; $E4 + end_indoor_group CERULEAN_CAVE + map_const NAME_RATERS_HOUSE, 4, 4 ; $E5 + end_indoor_group LAVENDER_TOWN_3 + map_const CERULEAN_BADGE_HOUSE, 4, 4 ; $E6 + end_indoor_group CERULEAN_CITY_3 + map_const UNUSED_MAP_E7, 0, 0 ; $E7 ; unused map map_const ROCK_TUNNEL_B1F, 20, 18 ; $E8 + end_indoor_group ROCK_TUNNEL_2 + map_const SILPH_CO_9F, 13, 9 ; $E9 map_const SILPH_CO_10F, 8, 9 ; $EA map_const SILPH_CO_11F, 9, 9 ; $EB map_const SILPH_CO_ELEVATOR, 2, 2 ; $EC + end_indoor_group SILPH_CO_2 + map_const UNUSED_MAP_ED, 0, 0 ; $ED ; unused map map_const UNUSED_MAP_EE, 0, 0 ; $EE ; unused map map_const TRADE_CENTER, 5, 4 ; $EF @@ -267,6 +395,7 @@ DEF FIRST_INDOOR_MAP EQU const_value map_const LORELEIS_ROOM, 5, 6 ; $F5 map_const BRUNOS_ROOM, 5, 6 ; $F6 map_const AGATHAS_ROOM, 5, 6 ; $F7 + end_indoor_group POKEMON_LEAGUE_3 ;map_const UNUSED_MAP_F8, 0, 0 ; $F8 ; unused map ;map_const UNUSED_MAP_F9, 0, 0 ; $F9 ; unused map ;map_const UNUSED_MAP_FA, 0, 0 ; $FA ; unused map @@ -278,4 +407,6 @@ DEF NUM_MAPS EQU const_value ; Indoor maps, such as houses, use this as the Map ID in their exit warps ; This map ID takes the player back to the last outdoor map they were on, stored in wLastMap -DEF LAST_MAP EQU -1 +DEF LAST_MAP EQU $ff + +ASSERT NUM_MAPS <= LAST_MAP, "map IDs overlap LAST_MAP" diff --git a/constants/map_data_constants.asm b/constants/map_data_constants.asm index fca9cffb18..ea7d09677d 100644 --- a/constants/map_data_constants.asm +++ b/constants/map_data_constants.asm @@ -24,6 +24,15 @@ DEF SPECIAL_ANIMATION_MAP EQU %1000000 shift_const SOUTH ; 4 %100 shift_const NORTH ; 8 %1000 +; wWarpEntries +DEF MAX_WARP_EVENTS EQU 32 + +; wNumSigns +DEF MAX_BG_EVENTS EQU 16 + +; wMapSpriteData +DEF MAX_OBJECT_EVENTS EQU 16 + ; flower and water tile animations const_def const TILEANIM_NONE ; 0 diff --git a/constants/menu_constants.asm b/constants/menu_constants.asm index 8008525b3a..fa63d5b1f6 100644 --- a/constants/menu_constants.asm +++ b/constants/menu_constants.asm @@ -92,3 +92,8 @@ DEF FIRST_PARTY_MENU_TEXT_ID EQU const_value const NAME_PLAYER_SCREEN ; 0 const NAME_RIVAL_SCREEN ; 1 const NAME_MON_SCREEN ; 2 + +; Stats box layout (see engine/pokemon/status_screen.asm) + const_def + const STATUS_SCREEN_STATS_BOX ; 0 + const LEVEL_UP_STATS_BOX ; 1 diff --git a/constants/misc_constants.asm b/constants/misc_constants.asm index 5c5bac4e79..d1f5e56ea1 100644 --- a/constants/misc_constants.asm +++ b/constants/misc_constants.asm @@ -20,8 +20,6 @@ DEF CONVERT_BGP EQU 0 DEF CONVERT_OBP0 EQU 1 DEF CONVERT_OBP1 EQU 2 -DEF NUM_COLORS EQU 4 -DEF PAL_SIZE EQU NUM_COLORS * 2 DEF NUM_ACTIVE_PALS EQU 4 ;;;;;;;;;; @@ -52,4 +50,9 @@ DEF NUM_ACTIVE_PALS EQU 4 DEF LEARN_BY_ITEM EQU 1 -DEF BIT_ALT_PALETTE_TRAINER_MON EQU 7 \ No newline at end of file +DEF BIT_ALT_PALETTE_TRAINER_MON EQU 7 +; input +DEF NO_INPUT EQU 0 + +; SGB command MLT_REQ can be used to detect SGB hardware +DEF JOYP_SGB_MLT_REQ EQU %00000011 diff --git a/constants/move_constants.asm b/constants/move_constants.asm index 5ca6aa4560..ccd45d45fe 100644 --- a/constants/move_constants.asm +++ b/constants/move_constants.asm @@ -173,6 +173,8 @@ const STRUGGLE ; a5 DEF NUM_ATTACKS EQU const_value - 1 +DEF CANNOT_MOVE EQU $ff + ; Moves do double duty as animation identifiers. const SHOWPIC_ANIM diff --git a/constants/oam_constants.asm b/constants/oam_constants.asm index e87e54a00b..93d5b87710 100644 --- a/constants/oam_constants.asm +++ b/constants/oam_constants.asm @@ -6,18 +6,3 @@ ; Used in SpriteFacingAndAnimationTable (see data/sprites/facings.asm) DEF FACING_END EQU 1 << BIT_END_OF_OAM_DATA DEF UNDER_GRASS EQU 1 << BIT_SPRITE_UNDER_GRASS - -; OAM attribute flags -DEF OAM_PALETTE EQU %111 - const_def 3 - const OAM_TILE_BANK ; 3 - const OAM_OBP_NUM ; 4 ; Non CGB Mode Only - const OAM_X_FLIP ; 5 - const OAM_Y_FLIP ; 6 - const OAM_PRIORITY ; 7 ; 0: OBJ above BG, 1: OBJ behind BG (colors 1-3) - -; OAM attribute masks -DEF OAM_OBP1 EQU 1 << OAM_OBP_NUM ; OBJ palette 1 -DEF OAM_HFLIP EQU 1 << OAM_X_FLIP ; horizontal flip -DEF OAM_VFLIP EQU 1 << OAM_Y_FLIP ; vertical flip -DEF OAM_BEHIND_BG EQU 1 << OAM_PRIORITY ; behind bg (except color 0) diff --git a/constants/palette_constants.asm b/constants/palette_constants.asm index c978737abb..3900ce5f15 100644 --- a/constants/palette_constants.asm +++ b/constants/palette_constants.asm @@ -1,14 +1,3 @@ -; monochrome palette color ids - const_def - const SHADE_WHITE ; %00 - const SHADE_LIGHT ; %01 - const SHADE_DARK ; %10 - const SHADE_BLACK ; %11 -DEF NUM_PAL_COLORS EQU const_value - -DEF PAL_COLOR_SIZE EQU 2 -DEF PALETTE_SIZE EQU NUM_PAL_COLORS * PAL_COLOR_SIZE - ; pal/blk packets ; SetPalFunctions indexes (see engine/gfx/palettes.asm) const_def diff --git a/constants/player_constants.asm b/constants/player_constants.asm new file mode 100644 index 0000000000..4fe50b53f8 --- /dev/null +++ b/constants/player_constants.asm @@ -0,0 +1,31 @@ +DEF NUM_PLAYER_NAMES EQU 3 + +IF DEF(_RED) +DEF PLAYERNAME1 EQUS "RED" +DEF PLAYERNAME2 EQUS "ASH" +DEF PLAYERNAME3 EQUS "JACK" + +DEF RIVALNAME1 EQUS "BLUE" +DEF RIVALNAME2 EQUS "GARY" +DEF RIVALNAME3 EQUS "JOHN" +ENDC + +IF DEF(_BLUE) +DEF PLAYERNAME1 EQUS "BLUE" +DEF PLAYERNAME2 EQUS "GARY" +DEF PLAYERNAME3 EQUS "JOHN" + +DEF RIVALNAME1 EQUS "RED" +DEF RIVALNAME2 EQUS "ASH" +DEF RIVALNAME3 EQUS "JACK" +ENDC + +IF DEF(_GREEN) ; PureRGBnote: GREENBUILD: default names specific to pokemon green +DEF PLAYERNAME1 EQUS "GREEN" +DEF PLAYERNAME2 EQUS "ASH" +DEF PLAYERNAME3 EQUS "MIKE" + +DEF RIVALNAME1 EQUS "BLUE" +DEF RIVALNAME2 EQUS "GARY" +DEF RIVALNAME3 EQUS "GABE" +ENDC diff --git a/constants/pokemon_data_constants.asm b/constants/pokemon_data_constants.asm index 378cf388e3..38286608a4 100644 --- a/constants/pokemon_data_constants.asm +++ b/constants/pokemon_data_constants.asm @@ -50,7 +50,7 @@ DEF MON_SPD_EXP rw DEF MON_SPC_EXP rw DEF MON_DVS rw DEF MON_PP rb NUM_MOVES -DEF BOXMON_STRUCT_LENGTH EQU _RS +DEF BOXMON_STRUCT_LENGTH EQU _RS ; $21 DEF MON_LEVEL rb DEF MON_STATS rw NUM_STATS rsset MON_STATS @@ -59,7 +59,7 @@ DEF MON_ATK rw DEF MON_DEF rw DEF MON_SPD rw DEF MON_SPC rw -DEF PARTYMON_STRUCT_LENGTH EQU _RS +DEF PARTYMON_STRUCT_LENGTH EQU _RS ; $2c DEF PARTY_LENGTH EQU 6 @@ -70,7 +70,6 @@ DEF HOF_MON EQU $10 DEF HOF_TEAM EQU PARTY_LENGTH * HOF_MON DEF HOF_TEAM_CAPACITY EQU 50 - ; mon data locations ; Note that some values are not supported by all functions that use these values. const_def @@ -80,15 +79,14 @@ DEF HOF_TEAM_CAPACITY EQU 50 const DAYCARE_DATA ; 3 const BATTLE_MON_DATA ; 4 - -; See data/pokemon/evos_moves.asm - ; Evolution types const_def 1 const EVOLVE_LEVEL ; 1 const EVOLVE_ITEM ; 2 const EVOLVE_TRADE ; 3 +; evolution data (see data/pokemon/evos_moves.asm) +DEF NUM_EVOS_IN_BUFFER EQU 3 ; wMonHGrowthRate values ; GrowthRateTable indexes (see data/growth_rates.asm) diff --git a/constants/ram_constants.asm b/constants/ram_constants.asm index a85fcd9531..1eef9b7b6f 100644 --- a/constants/ram_constants.asm +++ b/constants/ram_constants.asm @@ -59,6 +59,7 @@ DEF BIT_NO_PREVIOUS_MAP EQU 7 ; wCurrentBoxNum DEF BIT_HAS_CHANGED_BOXES EQU 7 +DEF BOX_NUM_MASK EQU %01111111 ; wObtainedBadges, wBeatGymFlags const_def @@ -244,4 +245,7 @@ DEF PALETTES_YELLOW2 EQU %01000011 const IN_GAME const IN_POKEMART_MENU -;;;;;;;;;; \ No newline at end of file +;;;;;;;;;; + +; rLCDC +DEF LCDC_DEFAULT EQU LCDC_ON | LCDC_WIN_9C00 | LCDC_WIN_ON | LCDC_BLOCK21 | LCDC_BG_9800 | LCDC_OBJ_8 | LCDC_OBJ_ON | LCDC_BG_ON diff --git a/constants/text_constants.asm b/constants/text_constants.asm index fa5565f9f3..214f6aeb87 100644 --- a/constants/text_constants.asm +++ b/constants/text_constants.asm @@ -1,6 +1,11 @@ -DEF NAME_LENGTH EQU 11 -DEF ITEM_NAME_LENGTH EQU 13 -DEF NAME_BUFFER_LENGTH EQU 20 +DEF PLAYER_NAME_LENGTH EQU 8 +DEF STAT_NAME_LENGTH EQU 10 +DEF NAME_LENGTH EQU 11 +DEF ITEM_NAME_LENGTH EQU 13 +DEF TRAINER_NAME_LENGTH EQU 13 +DEF MOVE_NAME_LENGTH EQU 14 +DEF GYM_CITY_LENGTH EQU 17 +DEF NAME_BUFFER_LENGTH EQU 20 ; PrintNumber, PrintBCDNumber const_def 5 @@ -8,9 +13,9 @@ DEF NAME_BUFFER_LENGTH EQU 20 const BIT_LEFT_ALIGN ; 6 const BIT_LEADING_ZEROES ; 7 -DEF MONEY_SIGN EQU (1 << BIT_MONEY_SIGN) -DEF LEFT_ALIGN EQU (1 << BIT_LEFT_ALIGN) -DEF LEADING_ZEROES EQU (1 << BIT_LEADING_ZEROES) +DEF MONEY_SIGN EQU 1 << BIT_MONEY_SIGN +DEF LEFT_ALIGN EQU 1 << BIT_LEFT_ALIGN +DEF LEADING_ZEROES EQU 1 << BIT_LEADING_ZEROES ; special text IDs (see home/text_script.asm) const_def $d0 diff --git a/data/battle/stat_mod_names.asm b/data/battle/stat_mod_names.asm index 63c956d73a..6c68db4ea1 100644 --- a/data/battle/stat_mod_names.asm +++ b/data/battle/stat_mod_names.asm @@ -2,7 +2,7 @@ ; The relevant move effect IDs correspond to the stats StatModTextStrings: - list_start + list_start STAT_NAME_LENGTH - 1 li "ATTACK" li "DEFENSE" li "SPEED" diff --git a/data/battle/stat_names.asm b/data/battle/stat_names.asm index 30401a99bc..08685e837e 100644 --- a/data/battle/stat_names.asm +++ b/data/battle/stat_names.asm @@ -1,7 +1,7 @@ ; Stats that vitamins can raise or lower VitaminStats: - list_start + list_start STAT_NAME_LENGTH - 1 li "HEALTH" li "ATTACK" li "DEFENSE" diff --git a/data/battle_anims/frame_blocks.asm b/data/battle_anims/frame_blocks.asm index a8b36ef78e..11e0007ace 100644 --- a/data/battle_anims/frame_blocks.asm +++ b/data/battle_anims/frame_blocks.asm @@ -134,39 +134,39 @@ FrameBlock01: db 9 ; # dbsprite 0, 0, 0, 0, $2c, 0 dbsprite 1, 0, 0, 0, $2d, 0 - dbsprite 2, 0, 0, 0, $2c, OAM_HFLIP + dbsprite 2, 0, 0, 0, $2c, OAM_XFLIP dbsprite 0, 1, 0, 0, $3c, 0 dbsprite 1, 1, 0, 0, $3d, 0 - dbsprite 2, 1, 0, 0, $3c, OAM_HFLIP - dbsprite 0, 2, 0, 0, $2c, OAM_VFLIP - dbsprite 1, 2, 0, 0, $2d, OAM_VFLIP - dbsprite 2, 2, 0, 0, $2c, OAM_HFLIP | OAM_VFLIP + dbsprite 2, 1, 0, 0, $3c, OAM_XFLIP + dbsprite 0, 2, 0, 0, $2c, OAM_YFLIP + dbsprite 1, 2, 0, 0, $2d, OAM_YFLIP + dbsprite 2, 2, 0, 0, $2c, OAM_XFLIP | OAM_YFLIP FrameBlock02: db 16 ; # dbsprite 0, 0, 0, 0, $20, 0 dbsprite 1, 0, 0, 0, $21, 0 - dbsprite 2, 0, 0, 0, $21, OAM_HFLIP - dbsprite 3, 0, 0, 0, $20, OAM_HFLIP + dbsprite 2, 0, 0, 0, $21, OAM_XFLIP + dbsprite 3, 0, 0, 0, $20, OAM_XFLIP dbsprite 0, 1, 0, 0, $30, 0 dbsprite 1, 1, 0, 0, $31, 0 - dbsprite 2, 1, 0, 0, $31, OAM_HFLIP - dbsprite 3, 1, 0, 0, $30, OAM_HFLIP - dbsprite 0, 2, 0, 0, $30, OAM_VFLIP - dbsprite 1, 2, 0, 0, $31, OAM_VFLIP - dbsprite 2, 2, 0, 0, $31, OAM_HFLIP | OAM_VFLIP - dbsprite 3, 2, 0, 0, $30, OAM_HFLIP | OAM_VFLIP - dbsprite 0, 3, 0, 0, $20, OAM_VFLIP - dbsprite 1, 3, 0, 0, $21, OAM_VFLIP - dbsprite 2, 3, 0, 0, $21, OAM_HFLIP | OAM_VFLIP - dbsprite 3, 3, 0, 0, $20, OAM_HFLIP | OAM_VFLIP + dbsprite 2, 1, 0, 0, $31, OAM_XFLIP + dbsprite 3, 1, 0, 0, $30, OAM_XFLIP + dbsprite 0, 2, 0, 0, $30, OAM_YFLIP + dbsprite 1, 2, 0, 0, $31, OAM_YFLIP + dbsprite 2, 2, 0, 0, $31, OAM_XFLIP | OAM_YFLIP + dbsprite 3, 2, 0, 0, $30, OAM_XFLIP | OAM_YFLIP + dbsprite 0, 3, 0, 0, $20, OAM_YFLIP + dbsprite 1, 3, 0, 0, $21, OAM_YFLIP + dbsprite 2, 3, 0, 0, $21, OAM_XFLIP | OAM_YFLIP + dbsprite 3, 3, 0, 0, $20, OAM_XFLIP | OAM_YFLIP FrameBlock03: db 4 ; # dbsprite 0, 0, 0, 0, $02, 0 - dbsprite 1, 0, 0, 0, $02, OAM_HFLIP + dbsprite 1, 0, 0, 0, $02, OAM_XFLIP dbsprite 0, 1, 0, 0, $12, 0 - dbsprite 1, 1, 0, 0, $12, OAM_HFLIP + dbsprite 1, 1, 0, 0, $12, OAM_XFLIP FrameBlock04: db 4 ; # @@ -177,25 +177,25 @@ FrameBlock04: FrameBlock05: db 4 ; # - dbsprite 0, 0, 0, 0, $07, OAM_HFLIP - dbsprite 1, 0, 0, 0, $06, OAM_HFLIP - dbsprite 0, 1, 0, 0, $17, OAM_HFLIP - dbsprite 1, 1, 0, 0, $16, OAM_HFLIP + dbsprite 0, 0, 0, 0, $07, OAM_XFLIP + dbsprite 1, 0, 0, 0, $06, OAM_XFLIP + dbsprite 0, 1, 0, 0, $17, OAM_XFLIP + dbsprite 1, 1, 0, 0, $16, OAM_XFLIP FrameBlock06: db 12 ; # dbsprite 1, 0, 0, 0, $23, 0 dbsprite 0, 1, 0, 0, $32, 0 dbsprite 1, 1, 0, 0, $33, 0 - dbsprite 2, 0, 0, 0, $23, OAM_HFLIP - dbsprite 2, 1, 0, 0, $33, OAM_HFLIP - dbsprite 3, 1, 0, 0, $32, OAM_HFLIP - dbsprite 0, 2, 0, 0, $32, OAM_VFLIP - dbsprite 1, 2, 0, 0, $33, OAM_VFLIP - dbsprite 1, 3, 0, 0, $23, OAM_VFLIP - dbsprite 2, 2, 0, 0, $33, OAM_HFLIP | OAM_VFLIP - dbsprite 3, 2, 0, 0, $32, OAM_HFLIP | OAM_VFLIP - dbsprite 2, 3, 0, 0, $23, OAM_HFLIP | OAM_VFLIP + dbsprite 2, 0, 0, 0, $23, OAM_XFLIP + dbsprite 2, 1, 0, 0, $33, OAM_XFLIP + dbsprite 3, 1, 0, 0, $32, OAM_XFLIP + dbsprite 0, 2, 0, 0, $32, OAM_YFLIP + dbsprite 1, 2, 0, 0, $33, OAM_YFLIP + dbsprite 1, 3, 0, 0, $23, OAM_YFLIP + dbsprite 2, 2, 0, 0, $33, OAM_XFLIP | OAM_YFLIP + dbsprite 3, 2, 0, 0, $32, OAM_XFLIP | OAM_YFLIP + dbsprite 2, 3, 0, 0, $23, OAM_XFLIP | OAM_YFLIP FrameBlock07: db 16 ; # @@ -203,18 +203,18 @@ FrameBlock07: dbsprite 1, 0, 0, 0, $21, 0 dbsprite 0, 1, 0, 0, $30, 0 dbsprite 1, 1, 0, 0, $31, 0 - dbsprite 2, 0, 0, 0, $21, OAM_HFLIP - dbsprite 3, 0, 0, 0, $20, OAM_HFLIP - dbsprite 2, 1, 0, 0, $31, OAM_HFLIP - dbsprite 3, 1, 0, 0, $30, OAM_HFLIP - dbsprite 0, 2, 0, 0, $30, OAM_VFLIP - dbsprite 1, 2, 0, 0, $31, OAM_VFLIP - dbsprite 0, 3, 0, 0, $20, OAM_VFLIP - dbsprite 1, 3, 0, 0, $21, OAM_VFLIP - dbsprite 2, 2, 0, 0, $31, OAM_HFLIP | OAM_VFLIP - dbsprite 3, 2, 0, 0, $30, OAM_HFLIP | OAM_VFLIP - dbsprite 2, 3, 0, 0, $21, OAM_HFLIP | OAM_VFLIP - dbsprite 3, 3, 0, 0, $20, OAM_HFLIP | OAM_VFLIP + dbsprite 2, 0, 0, 0, $21, OAM_XFLIP + dbsprite 3, 0, 0, 0, $20, OAM_XFLIP + dbsprite 2, 1, 0, 0, $31, OAM_XFLIP + dbsprite 3, 1, 0, 0, $30, OAM_XFLIP + dbsprite 0, 2, 0, 0, $30, OAM_YFLIP + dbsprite 1, 2, 0, 0, $31, OAM_YFLIP + dbsprite 0, 3, 0, 0, $20, OAM_YFLIP + dbsprite 1, 3, 0, 0, $21, OAM_YFLIP + dbsprite 2, 2, 0, 0, $31, OAM_XFLIP | OAM_YFLIP + dbsprite 3, 2, 0, 0, $30, OAM_XFLIP | OAM_YFLIP + dbsprite 2, 3, 0, 0, $21, OAM_XFLIP | OAM_YFLIP + dbsprite 3, 3, 0, 0, $20, OAM_XFLIP | OAM_YFLIP FrameBlock08: db 16 ; # @@ -222,62 +222,62 @@ FrameBlock08: dbsprite 1, 0, 0, 0, $21, 0 dbsprite 0, 1, 0, 0, $30, 0 dbsprite 1, 1, 0, 0, $31, 0 - dbsprite 3, 0, 0, 0, $21, OAM_HFLIP - dbsprite 4, 0, 0, 0, $20, OAM_HFLIP - dbsprite 3, 1, 0, 0, $31, OAM_HFLIP - dbsprite 4, 1, 0, 0, $30, OAM_HFLIP - dbsprite 0, 3, 0, 0, $30, OAM_VFLIP - dbsprite 1, 3, 0, 0, $31, OAM_VFLIP - dbsprite 0, 4, 0, 0, $20, OAM_VFLIP - dbsprite 1, 4, 0, 0, $21, OAM_VFLIP - dbsprite 3, 3, 0, 0, $31, OAM_HFLIP | OAM_VFLIP - dbsprite 4, 3, 0, 0, $30, OAM_HFLIP | OAM_VFLIP - dbsprite 3, 4, 0, 0, $21, OAM_HFLIP | OAM_VFLIP - dbsprite 4, 4, 0, 0, $20, OAM_HFLIP | OAM_VFLIP + dbsprite 3, 0, 0, 0, $21, OAM_XFLIP + dbsprite 4, 0, 0, 0, $20, OAM_XFLIP + dbsprite 3, 1, 0, 0, $31, OAM_XFLIP + dbsprite 4, 1, 0, 0, $30, OAM_XFLIP + dbsprite 0, 3, 0, 0, $30, OAM_YFLIP + dbsprite 1, 3, 0, 0, $31, OAM_YFLIP + dbsprite 0, 4, 0, 0, $20, OAM_YFLIP + dbsprite 1, 4, 0, 0, $21, OAM_YFLIP + dbsprite 3, 3, 0, 0, $31, OAM_XFLIP | OAM_YFLIP + dbsprite 4, 3, 0, 0, $30, OAM_XFLIP | OAM_YFLIP + dbsprite 3, 4, 0, 0, $21, OAM_XFLIP | OAM_YFLIP + dbsprite 4, 4, 0, 0, $20, OAM_XFLIP | OAM_YFLIP FrameBlock09: db 12 ; # dbsprite 0, 0, 0, 0, $24, 0 dbsprite 1, 0, 0, 0, $25, 0 dbsprite 0, 1, 0, 0, $34, 0 - dbsprite 3, 0, 0, 0, $25, OAM_HFLIP - dbsprite 4, 0, 0, 0, $24, OAM_HFLIP - dbsprite 4, 1, 0, 0, $34, OAM_HFLIP - dbsprite 0, 3, 0, 0, $34, OAM_VFLIP - dbsprite 0, 4, 0, 0, $24, OAM_VFLIP - dbsprite 1, 4, 0, 0, $25, OAM_VFLIP - dbsprite 4, 3, 0, 0, $34, OAM_HFLIP | OAM_VFLIP - dbsprite 3, 4, 0, 0, $25, OAM_HFLIP | OAM_VFLIP - dbsprite 4, 4, 0, 0, $24, OAM_HFLIP | OAM_VFLIP + dbsprite 3, 0, 0, 0, $25, OAM_XFLIP + dbsprite 4, 0, 0, 0, $24, OAM_XFLIP + dbsprite 4, 1, 0, 0, $34, OAM_XFLIP + dbsprite 0, 3, 0, 0, $34, OAM_YFLIP + dbsprite 0, 4, 0, 0, $24, OAM_YFLIP + dbsprite 1, 4, 0, 0, $25, OAM_YFLIP + dbsprite 4, 3, 0, 0, $34, OAM_XFLIP | OAM_YFLIP + dbsprite 3, 4, 0, 0, $25, OAM_XFLIP | OAM_YFLIP + dbsprite 4, 4, 0, 0, $24, OAM_XFLIP | OAM_YFLIP FrameBlock0a: db 12 ; # dbsprite 0, 0, 0, 0, $24, 0 dbsprite 1, 0, 0, 0, $25, 0 dbsprite 0, 1, 0, 0, $34, 0 - dbsprite 4, 0, 0, 0, $25, OAM_HFLIP - dbsprite 5, 0, 0, 0, $24, OAM_HFLIP - dbsprite 5, 1, 0, 0, $34, OAM_HFLIP - dbsprite 0, 4, 0, 0, $34, OAM_VFLIP - dbsprite 0, 5, 0, 0, $24, OAM_VFLIP - dbsprite 1, 5, 0, 0, $25, OAM_VFLIP - dbsprite 5, 4, 0, 0, $34, OAM_HFLIP | OAM_VFLIP - dbsprite 4, 5, 0, 0, $25, OAM_HFLIP | OAM_VFLIP - dbsprite 5, 5, 0, 0, $24, OAM_HFLIP | OAM_VFLIP + dbsprite 4, 0, 0, 0, $25, OAM_XFLIP + dbsprite 5, 0, 0, 0, $24, OAM_XFLIP + dbsprite 5, 1, 0, 0, $34, OAM_XFLIP + dbsprite 0, 4, 0, 0, $34, OAM_YFLIP + dbsprite 0, 5, 0, 0, $24, OAM_YFLIP + dbsprite 1, 5, 0, 0, $25, OAM_YFLIP + dbsprite 5, 4, 0, 0, $34, OAM_XFLIP | OAM_YFLIP + dbsprite 4, 5, 0, 0, $25, OAM_XFLIP | OAM_YFLIP + dbsprite 5, 5, 0, 0, $24, OAM_XFLIP | OAM_YFLIP FrameBlock0b: db 4 ; # dbsprite 0, 0, 0, 0, $05, 0 - dbsprite 1, 0, 0, 0, $05, OAM_HFLIP + dbsprite 1, 0, 0, 0, $05, OAM_XFLIP dbsprite 0, 1, 0, 0, $15, 0 - dbsprite 1, 1, 0, 0, $15, OAM_HFLIP + dbsprite 1, 1, 0, 0, $15, OAM_XFLIP FrameBlock0c: db 4 ; # dbsprite 0, 0, 0, 0, $04, 0 - dbsprite 1, 0, 0, 0, $04, OAM_HFLIP + dbsprite 1, 0, 0, 0, $04, OAM_XFLIP dbsprite 0, 1, 0, 0, $14, 0 - dbsprite 1, 1, 0, 0, $14, OAM_HFLIP + dbsprite 1, 1, 0, 0, $14, OAM_XFLIP FrameBlock0d: db 8 ; # @@ -285,10 +285,10 @@ FrameBlock0d: dbsprite 1, 0, 0, 0, $0d, 0 dbsprite 0, 1, 0, 0, $1c, 0 dbsprite 1, 1, 0, 0, $1d, 0 - dbsprite 0, 2, 0, 0, $1d, OAM_HFLIP | OAM_VFLIP - dbsprite 1, 2, 0, 0, $1c, OAM_HFLIP | OAM_VFLIP - dbsprite 0, 3, 0, 0, $0d, OAM_HFLIP | OAM_VFLIP - dbsprite 1, 3, 0, 0, $0c, OAM_HFLIP | OAM_VFLIP + dbsprite 0, 2, 0, 0, $1d, OAM_XFLIP | OAM_YFLIP + dbsprite 1, 2, 0, 0, $1c, OAM_XFLIP | OAM_YFLIP + dbsprite 0, 3, 0, 0, $0d, OAM_XFLIP | OAM_YFLIP + dbsprite 1, 3, 0, 0, $0c, OAM_XFLIP | OAM_YFLIP FrameBlock0e: db 4 ; # @@ -299,10 +299,10 @@ FrameBlock0e: FrameBlock0f: db 4 ; # - dbsprite 0, 6, 0, 0, $1d, OAM_HFLIP | OAM_VFLIP - dbsprite 1, 6, 0, 0, $1c, OAM_HFLIP | OAM_VFLIP - dbsprite 0, 7, 0, 0, $0d, OAM_HFLIP | OAM_VFLIP - dbsprite 1, 7, 0, 0, $0c, OAM_HFLIP | OAM_VFLIP + dbsprite 0, 6, 0, 0, $1d, OAM_XFLIP | OAM_YFLIP + dbsprite 1, 6, 0, 0, $1c, OAM_XFLIP | OAM_YFLIP + dbsprite 0, 7, 0, 0, $0d, OAM_XFLIP | OAM_YFLIP + dbsprite 1, 7, 0, 0, $0c, OAM_XFLIP | OAM_YFLIP FrameBlock10: db 8 ; # @@ -310,10 +310,10 @@ FrameBlock10: dbsprite 1, 0, 0, 0, $0f, 0 dbsprite 0, 1, 0, 0, $1e, 0 dbsprite 1, 1, 0, 0, $1f, 0 - dbsprite 2, 0, 0, 0, $0f, OAM_HFLIP - dbsprite 3, 0, 0, 0, $0e, OAM_HFLIP - dbsprite 2, 1, 0, 0, $1f, OAM_HFLIP - dbsprite 3, 1, 0, 0, $1e, OAM_HFLIP + dbsprite 2, 0, 0, 0, $0f, OAM_XFLIP + dbsprite 3, 0, 0, 0, $0e, OAM_XFLIP + dbsprite 2, 1, 0, 0, $1f, OAM_XFLIP + dbsprite 3, 1, 0, 0, $1e, OAM_XFLIP FrameBlock11: db 8 ; # @@ -321,10 +321,10 @@ FrameBlock11: dbsprite 1, 0, 0, 0, $0f, 0 dbsprite 0, 1, 0, 0, $1e, 0 dbsprite 1, 1, 0, 0, $1f, 0 - dbsprite 4, 0, 0, 0, $0f, OAM_HFLIP - dbsprite 5, 0, 0, 0, $0e, OAM_HFLIP - dbsprite 4, 1, 0, 0, $1f, OAM_HFLIP - dbsprite 5, 1, 0, 0, $1e, OAM_HFLIP + dbsprite 4, 0, 0, 0, $0f, OAM_XFLIP + dbsprite 5, 0, 0, 0, $0e, OAM_XFLIP + dbsprite 4, 1, 0, 0, $1f, OAM_XFLIP + dbsprite 5, 1, 0, 0, $1e, OAM_XFLIP FrameBlock12: db 3 ; # @@ -335,46 +335,46 @@ FrameBlock12: FrameBlock13: db 4 ; # dbsprite 0, 0, 0, 0, $36, 0 - dbsprite 1, 0, 0, 0, $36, OAM_HFLIP - dbsprite 0, 1, 0, 0, $36, OAM_VFLIP - dbsprite 1, 1, 0, 0, $36, OAM_HFLIP | OAM_VFLIP + dbsprite 1, 0, 0, 0, $36, OAM_XFLIP + dbsprite 0, 1, 0, 0, $36, OAM_YFLIP + dbsprite 1, 1, 0, 0, $36, OAM_XFLIP | OAM_YFLIP FrameBlock14: db 8 ; # dbsprite 2, 0, 0, 0, $28, 0 - dbsprite 3, 0, 0, 0, $28, OAM_HFLIP + dbsprite 3, 0, 0, 0, $28, OAM_XFLIP dbsprite 2, 1, 0, 0, $38, 0 - dbsprite 3, 1, 0, 0, $38, OAM_HFLIP + dbsprite 3, 1, 0, 0, $38, OAM_XFLIP dbsprite 4, 0, 0, 0, $36, 0 - dbsprite 5, 0, 0, 0, $36, OAM_HFLIP - dbsprite 4, 1, 0, 0, $36, OAM_VFLIP - dbsprite 5, 1, 0, 0, $36, OAM_HFLIP | OAM_VFLIP + dbsprite 5, 0, 0, 0, $36, OAM_XFLIP + dbsprite 4, 1, 0, 0, $36, OAM_YFLIP + dbsprite 5, 1, 0, 0, $36, OAM_XFLIP | OAM_YFLIP FrameBlock15: db 12 ; # dbsprite 0, 0, 0, 0, $28, 0 - dbsprite 1, 0, 0, 0, $28, OAM_HFLIP + dbsprite 1, 0, 0, 0, $28, OAM_XFLIP dbsprite 0, 1, 0, 0, $38, 0 - dbsprite 1, 1, 0, 0, $38, OAM_HFLIP + dbsprite 1, 1, 0, 0, $38, OAM_XFLIP dbsprite 2, 0, 0, 0, $29, 0 - dbsprite 3, 0, 0, 0, $29, OAM_HFLIP + dbsprite 3, 0, 0, 0, $29, OAM_XFLIP dbsprite 2, 1, 0, 0, $39, 0 - dbsprite 3, 1, 0, 0, $39, OAM_HFLIP + dbsprite 3, 1, 0, 0, $39, OAM_XFLIP dbsprite 4, 0, 0, 0, $28, 0 - dbsprite 5, 0, 0, 0, $28, OAM_HFLIP + dbsprite 5, 0, 0, 0, $28, OAM_XFLIP dbsprite 4, 1, 0, 0, $38, 0 - dbsprite 5, 1, 0, 0, $38, OAM_HFLIP + dbsprite 5, 1, 0, 0, $38, OAM_XFLIP FrameBlock16: db 8 ; # dbsprite 0, 0, 0, 0, $29, 0 - dbsprite 1, 0, 0, 0, $29, OAM_HFLIP + dbsprite 1, 0, 0, 0, $29, OAM_XFLIP dbsprite 0, 1, 0, 0, $39, 0 - dbsprite 1, 1, 0, 0, $39, OAM_HFLIP + dbsprite 1, 1, 0, 0, $39, OAM_XFLIP dbsprite 4, 0, 0, 0, $29, 0 - dbsprite 5, 0, 0, 0, $29, OAM_HFLIP + dbsprite 5, 0, 0, 0, $29, OAM_XFLIP dbsprite 4, 1, 0, 0, $39, 0 - dbsprite 5, 1, 0, 0, $39, OAM_HFLIP + dbsprite 5, 1, 0, 0, $39, OAM_XFLIP FrameBlock17: db 4 ; # @@ -385,73 +385,73 @@ FrameBlock17: FrameBlock18: db 1 ; # - dbsprite 0, 3, 0, 0, $45, OAM_HFLIP | OAM_VFLIP + dbsprite 0, 3, 0, 0, $45, OAM_XFLIP | OAM_YFLIP FrameBlock19: db 2 ; # dbsprite 1, 3, 0, 0, $45, 0 - dbsprite 1, 2, 0, 0, $46, OAM_HFLIP | OAM_VFLIP + dbsprite 1, 2, 0, 0, $46, OAM_XFLIP | OAM_YFLIP FrameBlock1a: db 2 ; # - dbsprite 2, 2, 0, 0, $45, OAM_HFLIP | OAM_VFLIP + dbsprite 2, 2, 0, 0, $45, OAM_XFLIP | OAM_YFLIP dbsprite 2, 3, 0, 0, $46, 0 FrameBlock1b: db 2 ; # dbsprite 3, 2, 0, 0, $45, 0 - dbsprite 3, 1, 0, 0, $46, OAM_HFLIP | OAM_VFLIP + dbsprite 3, 1, 0, 0, $46, OAM_XFLIP | OAM_YFLIP FrameBlock1c: db 2 ; # - dbsprite 4, 1, 0, 0, $45, OAM_HFLIP | OAM_VFLIP + dbsprite 4, 1, 0, 0, $45, OAM_XFLIP | OAM_YFLIP dbsprite 4, 2, 0, 0, $46, 0 FrameBlock1d: db 2 ; # dbsprite 5, 1, 0, 0, $45, 0 - dbsprite 5, 0, 0, 0, $46, OAM_HFLIP | OAM_VFLIP + dbsprite 5, 0, 0, 0, $46, OAM_XFLIP | OAM_YFLIP FrameBlock1e: db 2 ; # - dbsprite 6, 0, 0, 0, $45, OAM_HFLIP | OAM_VFLIP + dbsprite 6, 0, 0, 0, $45, OAM_XFLIP | OAM_YFLIP dbsprite 6, 1, 0, 0, $46, 0 FrameBlock75: db 4 ; # dbsprite 0, 0, 0, 0, $43, 0 - dbsprite 1, 0, 0, 0, $43, OAM_HFLIP + dbsprite 1, 0, 0, 0, $43, OAM_XFLIP dbsprite 0, 1, 0, 0, $22, 0 - dbsprite 1, 1, 0, 0, $43, OAM_HFLIP | OAM_VFLIP + dbsprite 1, 1, 0, 0, $43, OAM_XFLIP | OAM_YFLIP FrameBlock1f: db 2 ; # dbsprite 0, 0, 0, 0, $03, 0 - dbsprite 6, 0, 0, 0, $03, OAM_HFLIP + dbsprite 6, 0, 0, 0, $03, OAM_XFLIP FrameBlock20: db 6 ; # dbsprite 0, 0, 0, 0, $03, 0 - dbsprite 6, 0, 0, 0, $03, OAM_HFLIP + dbsprite 6, 0, 0, 0, $03, OAM_XFLIP dbsprite 1, 1, 0, 0, $03, 0 - dbsprite 5, 1, 0, 0, $03, OAM_HFLIP + dbsprite 5, 1, 0, 0, $03, OAM_XFLIP dbsprite 0, 1, 0, 0, $13, 0 - dbsprite 6, 1, 0, 0, $13, OAM_HFLIP + dbsprite 6, 1, 0, 0, $13, OAM_XFLIP FrameBlock21: db 12 ; # dbsprite 0, 0, 0, 0, $03, 0 - dbsprite 6, 0, 0, 0, $03, OAM_HFLIP + dbsprite 6, 0, 0, 0, $03, OAM_XFLIP dbsprite 1, 1, 0, 0, $03, 0 - dbsprite 5, 1, 0, 0, $03, OAM_HFLIP + dbsprite 5, 1, 0, 0, $03, OAM_XFLIP dbsprite 0, 1, 0, 0, $13, 0 - dbsprite 6, 1, 0, 0, $13, OAM_HFLIP + dbsprite 6, 1, 0, 0, $13, OAM_XFLIP dbsprite 2, 2, 0, 0, $03, 0 - dbsprite 4, 2, 0, 0, $03, OAM_HFLIP + dbsprite 4, 2, 0, 0, $03, OAM_XFLIP dbsprite 1, 2, 0, 0, $13, 0 - dbsprite 5, 2, 0, 0, $13, OAM_HFLIP + dbsprite 5, 2, 0, 0, $13, OAM_XFLIP dbsprite 0, 2, 0, 0, $03, 0 - dbsprite 6, 2, 0, 0, $03, OAM_HFLIP + dbsprite 6, 2, 0, 0, $03, OAM_XFLIP FrameBlock22: db 19 ; # @@ -465,15 +465,15 @@ FrameBlock22: dbsprite 2, 2, 0, 0, $03, 0 dbsprite 2, 3, 0, 0, $13, 0 dbsprite 3, 3, 0, 0, $03, 0 - dbsprite 4, 2, 0, 0, $03, OAM_HFLIP - dbsprite 4, 3, 0, 0, $13, OAM_HFLIP - dbsprite 5, 1, 0, 0, $03, OAM_HFLIP - dbsprite 5, 2, 0, 0, $13, OAM_HFLIP - dbsprite 5, 3, 0, 0, $03, OAM_HFLIP - dbsprite 6, 0, 0, 0, $03, OAM_HFLIP - dbsprite 6, 1, 0, 0, $13, OAM_HFLIP - dbsprite 6, 2, 0, 0, $03, OAM_HFLIP - dbsprite 6, 3, 0, 0, $13, OAM_HFLIP + dbsprite 4, 2, 0, 0, $03, OAM_XFLIP + dbsprite 4, 3, 0, 0, $13, OAM_XFLIP + dbsprite 5, 1, 0, 0, $03, OAM_XFLIP + dbsprite 5, 2, 0, 0, $13, OAM_XFLIP + dbsprite 5, 3, 0, 0, $03, OAM_XFLIP + dbsprite 6, 0, 0, 0, $03, OAM_XFLIP + dbsprite 6, 1, 0, 0, $13, OAM_XFLIP + dbsprite 6, 2, 0, 0, $03, OAM_XFLIP + dbsprite 6, 3, 0, 0, $13, OAM_XFLIP FrameBlock23: db 4 ; # @@ -505,24 +505,24 @@ FrameBlock25: FrameBlock26: db 4 ; # dbsprite 2, 0, 0, 0, $44, 0 - dbsprite 3, 0, 0, 0, $44, OAM_HFLIP - dbsprite 2, 1, 0, 0, $44, OAM_VFLIP - dbsprite 3, 1, 0, 0, $44, OAM_HFLIP | OAM_VFLIP + dbsprite 3, 0, 0, 0, $44, OAM_XFLIP + dbsprite 2, 1, 0, 0, $44, OAM_YFLIP + dbsprite 3, 1, 0, 0, $44, OAM_XFLIP | OAM_YFLIP FrameBlock27: db 5 ; # dbsprite 1, 1, 0, 0, $44, 0 - dbsprite 2, 1, 0, 0, $44, OAM_HFLIP - dbsprite 1, 2, 0, 0, $44, OAM_VFLIP - dbsprite 2, 2, 0, 0, $44, OAM_HFLIP | OAM_VFLIP + dbsprite 2, 1, 0, 0, $44, OAM_XFLIP + dbsprite 1, 2, 0, 0, $44, OAM_YFLIP + dbsprite 2, 2, 0, 0, $44, OAM_XFLIP | OAM_YFLIP dbsprite 3, 0, 0, 0, $47, 0 FrameBlock28: db 6 ; # dbsprite 0, 2, 0, 0, $44, 0 - dbsprite 1, 2, 0, 0, $44, OAM_HFLIP - dbsprite 0, 3, 0, 0, $44, OAM_VFLIP - dbsprite 1, 3, 0, 0, $44, OAM_HFLIP | OAM_VFLIP + dbsprite 1, 2, 0, 0, $44, OAM_XFLIP + dbsprite 0, 3, 0, 0, $44, OAM_YFLIP + dbsprite 1, 3, 0, 0, $44, OAM_XFLIP | OAM_YFLIP dbsprite 2, 1, 0, 0, $47, 0 dbsprite 2, 0, 6, 2, $47, 0 @@ -536,9 +536,9 @@ FrameBlock29: FrameBlock2a: db 4 ; # dbsprite 0, 0, 0, 0, $44, 0 - dbsprite 1, 0, 0, 0, $44, OAM_HFLIP - dbsprite 0, 1, 0, 0, $44, OAM_VFLIP - dbsprite 1, 1, 0, 0, $44, OAM_HFLIP | OAM_VFLIP + dbsprite 1, 0, 0, 0, $44, OAM_XFLIP + dbsprite 0, 1, 0, 0, $44, OAM_YFLIP + dbsprite 1, 1, 0, 0, $44, OAM_XFLIP | OAM_YFLIP FrameBlock2b: db 2 ; # @@ -562,28 +562,28 @@ FrameBlock2d: FrameBlock2e: db 8 ; # - dbsprite 0, 0, 0, 0, $27, OAM_HFLIP - dbsprite 1, 0, 0, 0, $26, OAM_HFLIP - dbsprite 0, 1, 0, 0, $37, OAM_HFLIP - dbsprite 1, 1, 0, 0, $36, OAM_HFLIP - dbsprite 0, 2, 0, 0, $29, OAM_HFLIP - dbsprite 1, 2, 0, 0, $28, OAM_HFLIP - dbsprite 0, 3, 0, 0, $39, OAM_HFLIP - dbsprite 1, 3, 0, 0, $38, OAM_HFLIP + dbsprite 0, 0, 0, 0, $27, OAM_XFLIP + dbsprite 1, 0, 0, 0, $26, OAM_XFLIP + dbsprite 0, 1, 0, 0, $37, OAM_XFLIP + dbsprite 1, 1, 0, 0, $36, OAM_XFLIP + dbsprite 0, 2, 0, 0, $29, OAM_XFLIP + dbsprite 1, 2, 0, 0, $28, OAM_XFLIP + dbsprite 0, 3, 0, 0, $39, OAM_XFLIP + dbsprite 1, 3, 0, 0, $38, OAM_XFLIP FrameBlock2f: db 4 ; # dbsprite 0, 0, 0, 0, $0c, 0 dbsprite 1, 0, 0, 0, $0d, 0 - dbsprite 0, 1, 0, 0, $0c, OAM_VFLIP - dbsprite 1, 1, 0, 0, $0d, OAM_VFLIP + dbsprite 0, 1, 0, 0, $0c, OAM_YFLIP + dbsprite 1, 1, 0, 0, $0d, OAM_YFLIP FrameBlock30: db 4 ; # dbsprite 0, 0, 0, 0, $44, 0 - dbsprite 1, 0, 0, 0, $44, OAM_HFLIP - dbsprite 0, 1, 0, 0, $44, OAM_VFLIP - dbsprite 1, 1, 0, 0, $44, OAM_HFLIP | OAM_VFLIP + dbsprite 1, 0, 0, 0, $44, OAM_XFLIP + dbsprite 0, 1, 0, 0, $44, OAM_YFLIP + dbsprite 1, 1, 0, 0, $44, OAM_XFLIP | OAM_YFLIP FrameBlock31: db 1 ; # @@ -593,34 +593,34 @@ FrameBlock32: db 7 ; # dbsprite 0, 0, 0, 0, $4d, 0 dbsprite 1, 0, 0, 0, $2f, 0 - dbsprite 2, 0, 0, 0, $4d, OAM_HFLIP + dbsprite 2, 0, 0, 0, $4d, OAM_XFLIP dbsprite 0, 1, 0, 0, $4e, 0 dbsprite 1, 1, 0, 0, $07, 0 - dbsprite 2, 1, 0, 0, $4e, OAM_HFLIP + dbsprite 2, 1, 0, 0, $4e, OAM_XFLIP dbsprite 1, 2, 0, 0, $3f, 0 FrameBlock33: db 7 ; # - dbsprite 1, 0, 0, 0, $3f, OAM_VFLIP - dbsprite 0, 1, 0, 0, $4e, OAM_VFLIP - dbsprite 1, 1, 0, 0, $07, OAM_VFLIP - dbsprite 2, 1, 0, 0, $4e, OAM_HFLIP | OAM_VFLIP - dbsprite 0, 2, 0, 0, $4d, OAM_VFLIP - dbsprite 1, 2, 0, 0, $2f, OAM_VFLIP - dbsprite 2, 2, 0, 0, $4d, OAM_HFLIP | OAM_VFLIP + dbsprite 1, 0, 0, 0, $3f, OAM_YFLIP + dbsprite 0, 1, 0, 0, $4e, OAM_YFLIP + dbsprite 1, 1, 0, 0, $07, OAM_YFLIP + dbsprite 2, 1, 0, 0, $4e, OAM_XFLIP | OAM_YFLIP + dbsprite 0, 2, 0, 0, $4d, OAM_YFLIP + dbsprite 1, 2, 0, 0, $2f, OAM_YFLIP + dbsprite 2, 2, 0, 0, $4d, OAM_XFLIP | OAM_YFLIP FrameBlock34: db 1 ; # - dbsprite 0, 20, 0, 0, $00, OAM_OBP1 + dbsprite 0, 20, 0, 0, $00, OAM_PAL1 FrameBlock35: db 6 ; # dbsprite 0, 0, 0, 0, $2a, 0 dbsprite 1, 0, 0, 0, $2b, 0 dbsprite 0, 1, 0, 0, $3a, 0 - dbsprite 0, 2, 0, 0, $3a, OAM_VFLIP - dbsprite 0, 3, 0, 0, $2a, OAM_VFLIP - dbsprite 1, 3, 0, 0, $2b, OAM_VFLIP + dbsprite 0, 2, 0, 0, $3a, OAM_YFLIP + dbsprite 0, 3, 0, 0, $2a, OAM_YFLIP + dbsprite 1, 3, 0, 0, $2b, OAM_YFLIP FrameBlock36: db 4 ; # @@ -631,10 +631,10 @@ FrameBlock36: FrameBlock37: db 4 ; # - dbsprite 0, 0, 0, 0, $01, OAM_BEHIND_BG | OAM_HFLIP - dbsprite 1, 0, 0, 0, $00, OAM_BEHIND_BG | OAM_HFLIP - dbsprite 0, 1, 0, 0, $11, OAM_BEHIND_BG | OAM_HFLIP - dbsprite 1, 1, 0, 0, $10, OAM_BEHIND_BG | OAM_HFLIP + dbsprite 0, 0, 0, 0, $01, OAM_PRIO | OAM_XFLIP + dbsprite 1, 0, 0, 0, $00, OAM_PRIO | OAM_XFLIP + dbsprite 0, 1, 0, 0, $11, OAM_PRIO | OAM_XFLIP + dbsprite 1, 1, 0, 0, $10, OAM_PRIO | OAM_XFLIP FrameBlock38: db 4 ; # @@ -645,41 +645,41 @@ FrameBlock38: FrameBlock39: db 4 ; # - dbsprite 0, 0, 0, 0, $0b, OAM_HFLIP - dbsprite 1, 0, 0, 0, $0a, OAM_HFLIP - dbsprite 0, 1, 0, 0, $1b, OAM_HFLIP - dbsprite 1, 1, 0, 0, $1a, OAM_HFLIP + dbsprite 0, 0, 0, 0, $0b, OAM_XFLIP + dbsprite 1, 0, 0, 0, $0a, OAM_XFLIP + dbsprite 0, 1, 0, 0, $1b, OAM_XFLIP + dbsprite 1, 1, 0, 0, $1a, OAM_XFLIP FrameBlock3a: db 4 ; # dbsprite 0, 4, 0, 0, $05, 0 - dbsprite 1, 4, 0, 0, $05, OAM_HFLIP + dbsprite 1, 4, 0, 0, $05, OAM_XFLIP dbsprite 0, 5, 0, 0, $15, 0 - dbsprite 1, 5, 0, 0, $15, OAM_HFLIP + dbsprite 1, 5, 0, 0, $15, OAM_XFLIP FrameBlock3b: db 5 ; # dbsprite 0, 3, 0, 0, $04, 0 - dbsprite 1, 3, 0, 0, $04, OAM_HFLIP + dbsprite 1, 3, 0, 0, $04, OAM_XFLIP dbsprite 0, 4, 0, 0, $14, 0 - dbsprite 1, 4, 0, 0, $14, OAM_HFLIP + dbsprite 1, 4, 0, 0, $14, OAM_XFLIP dbsprite 0, 5, 4, 0, $41, 0 FrameBlock3c: db 6 ; # dbsprite 0, 2, 0, 0, $05, 0 - dbsprite 1, 2, 0, 0, $05, OAM_HFLIP + dbsprite 1, 2, 0, 0, $05, OAM_XFLIP dbsprite 0, 3, 0, 0, $15, 0 - dbsprite 1, 3, 0, 0, $15, OAM_HFLIP + dbsprite 1, 3, 0, 0, $15, OAM_XFLIP dbsprite 0, 4, 4, 0, $42, 0 dbsprite 0, 5, 4, 0, $42, 0 FrameBlock3d: db 7 ; # dbsprite 0, 1, 0, 0, $04, 0 - dbsprite 1, 1, 0, 0, $04, OAM_HFLIP + dbsprite 1, 1, 0, 0, $04, OAM_XFLIP dbsprite 0, 2, 0, 0, $14, 0 - dbsprite 1, 2, 0, 0, $14, OAM_HFLIP + dbsprite 1, 2, 0, 0, $14, OAM_XFLIP dbsprite 0, 3, 4, 0, $41, 0 dbsprite 0, 4, 4, 0, $41, 0 dbsprite 0, 5, 4, 0, $41, 0 @@ -687,9 +687,9 @@ FrameBlock3d: FrameBlock3e: db 8 ; # dbsprite 0, 0, 0, 0, $05, 0 - dbsprite 1, 0, 0, 0, $05, OAM_HFLIP + dbsprite 1, 0, 0, 0, $05, OAM_XFLIP dbsprite 0, 1, 0, 0, $15, 0 - dbsprite 1, 1, 0, 0, $15, OAM_HFLIP + dbsprite 1, 1, 0, 0, $15, OAM_XFLIP dbsprite 0, 2, 4, 0, $42, 0 dbsprite 0, 3, 4, 0, $42, 0 dbsprite 0, 4, 4, 0, $42, 0 @@ -698,9 +698,9 @@ FrameBlock3e: FrameBlock3f: db 8 ; # dbsprite 0, 0, 0, 0, $04, 0 - dbsprite 1, 0, 0, 0, $04, OAM_HFLIP + dbsprite 1, 0, 0, 0, $04, OAM_XFLIP dbsprite 0, 1, 0, 0, $14, 0 - dbsprite 1, 1, 0, 0, $14, OAM_HFLIP + dbsprite 1, 1, 0, 0, $14, OAM_XFLIP dbsprite 0, 2, 4, 0, $41, 0 dbsprite 0, 3, 4, 0, $41, 0 dbsprite 0, 4, 4, 0, $41, 0 @@ -715,7 +715,7 @@ FrameBlock40: FrameBlock41: db 4 ; # dbsprite 0, 0, 0, 0, $06, 0 - dbsprite 1, 0, 0, 0, $06, OAM_HFLIP + dbsprite 1, 0, 0, 0, $06, OAM_XFLIP dbsprite 0, 1, 0, 0, $16, 0 dbsprite 1, 1, 0, 0, $17, 0 @@ -771,139 +771,139 @@ FrameBlock46: FrameBlock47: db 4 ; # dbsprite 0, 0, 0, 0, $43, 0 - dbsprite 1, 0, 0, 0, $43, OAM_HFLIP - dbsprite 0, 1, 0, 0, $43, OAM_VFLIP - dbsprite 1, 1, 0, 0, $43, OAM_HFLIP | OAM_VFLIP + dbsprite 1, 0, 0, 0, $43, OAM_XFLIP + dbsprite 0, 1, 0, 0, $43, OAM_YFLIP + dbsprite 1, 1, 0, 0, $43, OAM_XFLIP | OAM_YFLIP SmallBlackCircleFrameBlock: db 4 ; # dbsprite 1, 1, 0, 0, $33, 0 - dbsprite 2, 1, 0, 0, $33, OAM_HFLIP - dbsprite 1, 2, 0, 0, $33, OAM_VFLIP - dbsprite 2, 2, 0, 0, $33, OAM_HFLIP | OAM_VFLIP + dbsprite 2, 1, 0, 0, $33, OAM_XFLIP + dbsprite 1, 2, 0, 0, $33, OAM_YFLIP + dbsprite 2, 2, 0, 0, $33, OAM_XFLIP | OAM_YFLIP LargeBlackCircleFrameBlock: db 16 ; # dbsprite 0, 0, 0, 0, $22, 0 dbsprite 1, 0, 0, 0, $23, 0 - dbsprite 2, 0, 0, 0, $23, OAM_HFLIP - dbsprite 3, 0, 0, 0, $22, OAM_HFLIP + dbsprite 2, 0, 0, 0, $23, OAM_XFLIP + dbsprite 3, 0, 0, 0, $22, OAM_XFLIP dbsprite 0, 1, 0, 0, $32, 0 dbsprite 1, 1, 0, 0, $43, 0 - dbsprite 2, 1, 0, 0, $43, OAM_HFLIP - dbsprite 3, 1, 0, 0, $32, OAM_HFLIP - dbsprite 0, 2, 0, 0, $32, OAM_VFLIP - dbsprite 1, 2, 0, 0, $43, OAM_VFLIP - dbsprite 2, 2, 0, 0, $43, OAM_HFLIP | OAM_VFLIP - dbsprite 3, 2, 0, 0, $32, OAM_HFLIP | OAM_VFLIP - dbsprite 0, 3, 0, 0, $22, OAM_VFLIP - dbsprite 1, 3, 0, 0, $23, OAM_VFLIP - dbsprite 2, 3, 0, 0, $23, OAM_HFLIP | OAM_VFLIP - dbsprite 3, 3, 0, 0, $22, OAM_HFLIP | OAM_VFLIP + dbsprite 2, 1, 0, 0, $43, OAM_XFLIP + dbsprite 3, 1, 0, 0, $32, OAM_XFLIP + dbsprite 0, 2, 0, 0, $32, OAM_YFLIP + dbsprite 1, 2, 0, 0, $43, OAM_YFLIP + dbsprite 2, 2, 0, 0, $43, OAM_XFLIP | OAM_YFLIP + dbsprite 3, 2, 0, 0, $32, OAM_XFLIP | OAM_YFLIP + dbsprite 0, 3, 0, 0, $22, OAM_YFLIP + dbsprite 1, 3, 0, 0, $23, OAM_YFLIP + dbsprite 2, 3, 0, 0, $23, OAM_XFLIP | OAM_YFLIP + dbsprite 3, 3, 0, 0, $22, OAM_XFLIP | OAM_YFLIP FrameBlock71: db 16 ; # dbsprite 0, 0, 0, 0, $22, 0 dbsprite 1, 0, 0, 0, $3b, 0 - dbsprite 2, 0, 0, 0, $23, OAM_HFLIP - dbsprite 3, 0, 0, 0, $22, OAM_HFLIP + dbsprite 2, 0, 0, 0, $23, OAM_XFLIP + dbsprite 3, 0, 0, 0, $22, OAM_XFLIP dbsprite 0, 1, 0, 0, $32, 0 dbsprite 1, 1, 0, 0, $43, 0 - dbsprite 2, 1, 0, 0, $43, OAM_HFLIP - dbsprite 3, 1, 0, 0, $32, OAM_HFLIP - dbsprite 0, 2, 0, 0, $32, OAM_VFLIP - dbsprite 1, 2, 0, 0, $43, OAM_VFLIP - dbsprite 2, 2, 0, 0, $43, OAM_HFLIP | OAM_VFLIP - dbsprite 3, 2, 0, 0, $32, OAM_HFLIP | OAM_VFLIP - dbsprite 0, 3, 0, 0, $22, OAM_VFLIP - dbsprite 1, 3, 0, 0, $23, OAM_VFLIP - dbsprite 2, 3, 0, 0, $23, OAM_HFLIP | OAM_VFLIP - dbsprite 3, 3, 0, 0, $22, OAM_HFLIP | OAM_VFLIP + dbsprite 2, 1, 0, 0, $43, OAM_XFLIP + dbsprite 3, 1, 0, 0, $32, OAM_XFLIP + dbsprite 0, 2, 0, 0, $32, OAM_YFLIP + dbsprite 1, 2, 0, 0, $43, OAM_YFLIP + dbsprite 2, 2, 0, 0, $43, OAM_XFLIP | OAM_YFLIP + dbsprite 3, 2, 0, 0, $32, OAM_XFLIP | OAM_YFLIP + dbsprite 0, 3, 0, 0, $22, OAM_YFLIP + dbsprite 1, 3, 0, 0, $23, OAM_YFLIP + dbsprite 2, 3, 0, 0, $23, OAM_XFLIP | OAM_YFLIP + dbsprite 3, 3, 0, 0, $22, OAM_XFLIP | OAM_YFLIP FrameBlock72: db 12 ; # dbsprite 0, 0, 0, 0, $32, 0 dbsprite 1, 0, 0, 0, $43, 0 - dbsprite 2, 0, 0, 0, $43, OAM_HFLIP - dbsprite 3, 0, 0, 0, $32, OAM_HFLIP - dbsprite 0, 1, 0, 0, $32, OAM_VFLIP - dbsprite 1, 1, 0, 0, $43, OAM_VFLIP - dbsprite 2, 1, 0, 0, $43, OAM_HFLIP | OAM_VFLIP - dbsprite 3, 1, 0, 0, $32, OAM_HFLIP | OAM_VFLIP - dbsprite 0, 2, 0, 0, $22, OAM_VFLIP - dbsprite 1, 2, 0, 0, $23, OAM_VFLIP - dbsprite 2, 2, 0, 0, $23, OAM_HFLIP | OAM_VFLIP - dbsprite 3, 2, 0, 0, $22, OAM_HFLIP | OAM_VFLIP + dbsprite 2, 0, 0, 0, $43, OAM_XFLIP + dbsprite 3, 0, 0, 0, $32, OAM_XFLIP + dbsprite 0, 1, 0, 0, $32, OAM_YFLIP + dbsprite 1, 1, 0, 0, $43, OAM_YFLIP + dbsprite 2, 1, 0, 0, $43, OAM_XFLIP | OAM_YFLIP + dbsprite 3, 1, 0, 0, $32, OAM_XFLIP | OAM_YFLIP + dbsprite 0, 2, 0, 0, $22, OAM_YFLIP + dbsprite 1, 2, 0, 0, $23, OAM_YFLIP + dbsprite 2, 2, 0, 0, $23, OAM_XFLIP | OAM_YFLIP + dbsprite 3, 2, 0, 0, $22, OAM_XFLIP | OAM_YFLIP FrameBlock73: db 8 ; # - dbsprite 0, 0, 0, 0, $32, OAM_VFLIP - dbsprite 1, 0, 0, 0, $43, OAM_VFLIP - dbsprite 2, 0, 0, 0, $43, OAM_HFLIP | OAM_VFLIP - dbsprite 3, 0, 0, 0, $32, OAM_HFLIP | OAM_VFLIP - dbsprite 0, 1, 0, 0, $22, OAM_VFLIP - dbsprite 1, 1, 0, 0, $23, OAM_VFLIP - dbsprite 2, 1, 0, 0, $23, OAM_HFLIP | OAM_VFLIP - dbsprite 3, 1, 0, 0, $22, OAM_HFLIP | OAM_VFLIP + dbsprite 0, 0, 0, 0, $32, OAM_YFLIP + dbsprite 1, 0, 0, 0, $43, OAM_YFLIP + dbsprite 2, 0, 0, 0, $43, OAM_XFLIP | OAM_YFLIP + dbsprite 3, 0, 0, 0, $32, OAM_XFLIP | OAM_YFLIP + dbsprite 0, 1, 0, 0, $22, OAM_YFLIP + dbsprite 1, 1, 0, 0, $23, OAM_YFLIP + dbsprite 2, 1, 0, 0, $23, OAM_XFLIP | OAM_YFLIP + dbsprite 3, 1, 0, 0, $22, OAM_XFLIP | OAM_YFLIP FrameBlock74: db 4 ; # - dbsprite 0, 0, 0, 0, $22, OAM_VFLIP - dbsprite 1, 0, 0, 0, $23, OAM_VFLIP - dbsprite 2, 0, 0, 0, $23, OAM_HFLIP | OAM_VFLIP - dbsprite 3, 0, 0, 0, $22, OAM_HFLIP | OAM_VFLIP + dbsprite 0, 0, 0, 0, $22, OAM_YFLIP + dbsprite 1, 0, 0, 0, $23, OAM_YFLIP + dbsprite 2, 0, 0, 0, $23, OAM_XFLIP | OAM_YFLIP + dbsprite 3, 0, 0, 0, $22, OAM_XFLIP | OAM_YFLIP FrameBlock4a: db 4 ; # - dbsprite 3, 1, 0, 0, $4c, OAM_HFLIP + dbsprite 3, 1, 0, 0, $4c, OAM_XFLIP dbsprite 1, 4, 0, 0, $4b, 0 dbsprite 4, 6, 0, 0, $4c, 0 - dbsprite 6, 3, 0, 0, $4b, OAM_VFLIP + dbsprite 6, 3, 0, 0, $4b, OAM_YFLIP FrameBlock4b: db 4 ; # dbsprite 3, 0, 0, 0, $4c, 0 - dbsprite 0, 4, 0, 0, $4b, OAM_VFLIP - dbsprite 4, 7, 0, 0, $4c, OAM_HFLIP + dbsprite 0, 4, 0, 0, $4b, OAM_YFLIP + dbsprite 4, 7, 0, 0, $4c, OAM_XFLIP dbsprite 7, 3, 0, 0, $4b, 0 FrameBlock4c: db 4 ; # - dbsprite 1, 2, 0, 0, $4a, OAM_VFLIP + dbsprite 1, 2, 0, 0, $4a, OAM_YFLIP dbsprite 2, 6, 0, 0, $4a, 0 - dbsprite 6, 5, 0, 0, $4a, OAM_HFLIP - dbsprite 5, 1, 0, 0, $4a, OAM_HFLIP | OAM_VFLIP + dbsprite 6, 5, 0, 0, $4a, OAM_XFLIP + dbsprite 5, 1, 0, 0, $4a, OAM_XFLIP | OAM_YFLIP FrameBlock4d: db 4 ; # - dbsprite 0, 1, 0, 0, $4a, OAM_HFLIP - dbsprite 1, 7, 0, 0, $4a, OAM_HFLIP | OAM_VFLIP - dbsprite 7, 6, 0, 0, $4a, OAM_VFLIP + dbsprite 0, 1, 0, 0, $4a, OAM_XFLIP + dbsprite 1, 7, 0, 0, $4a, OAM_XFLIP | OAM_YFLIP + dbsprite 7, 6, 0, 0, $4a, OAM_YFLIP dbsprite 6, 0, 0, 0, $4a, 0 FrameBlock4e: db 8 ; # dbsprite 6, 0, 0, 0, $44, 0 - dbsprite 7, 0, 0, 0, $44, OAM_HFLIP - dbsprite 6, 1, 0, 0, $44, OAM_VFLIP - dbsprite 7, 1, 0, 0, $44, OAM_HFLIP | OAM_VFLIP + dbsprite 7, 0, 0, 0, $44, OAM_XFLIP + dbsprite 6, 1, 0, 0, $44, OAM_YFLIP + dbsprite 7, 1, 0, 0, $44, OAM_XFLIP | OAM_YFLIP dbsprite 1, 4, 2, 6, $44, 0 - dbsprite 2, 4, 2, 6, $44, OAM_HFLIP - dbsprite 1, 5, 2, 6, $44, OAM_VFLIP - dbsprite 2, 5, 2, 6, $44, OAM_HFLIP | OAM_VFLIP + dbsprite 2, 4, 2, 6, $44, OAM_XFLIP + dbsprite 1, 5, 2, 6, $44, OAM_YFLIP + dbsprite 2, 5, 2, 6, $44, OAM_XFLIP | OAM_YFLIP FrameBlock4f: db 12 ; # dbsprite 4, 1, 2, 6, $44, 0 - dbsprite 5, 1, 2, 6, $44, OAM_HFLIP - dbsprite 4, 2, 2, 6, $44, OAM_VFLIP - dbsprite 5, 2, 2, 6, $44, OAM_HFLIP | OAM_VFLIP + dbsprite 5, 1, 2, 6, $44, OAM_XFLIP + dbsprite 4, 2, 2, 6, $44, OAM_YFLIP + dbsprite 5, 2, 2, 6, $44, OAM_XFLIP | OAM_YFLIP dbsprite 6, 0, 2, 6, $47, 0 dbsprite 7, 0, 0, 0, $47, 0 dbsprite 2, 3, 6, 2, $44, 0 - dbsprite 3, 3, 6, 2, $44, OAM_HFLIP - dbsprite 2, 4, 6, 2, $44, OAM_VFLIP - dbsprite 3, 4, 6, 2, $44, OAM_HFLIP | OAM_VFLIP + dbsprite 3, 3, 6, 2, $44, OAM_XFLIP + dbsprite 2, 4, 6, 2, $44, OAM_YFLIP + dbsprite 3, 4, 6, 2, $44, OAM_XFLIP | OAM_YFLIP dbsprite 1, 6, 0, 0, $47, 0 dbsprite 1, 5, 6, 2, $47, 0 @@ -920,14 +920,14 @@ FrameBlock50: FrameBlock51: db 8 ; # - dbsprite 0, 0, 0, 0, $35, OAM_HFLIP - dbsprite 0, 1, 0, 0, $35, OAM_VFLIP + dbsprite 0, 0, 0, 0, $35, OAM_XFLIP + dbsprite 0, 1, 0, 0, $35, OAM_YFLIP dbsprite 0, 2, 0, 0, $35, 0 - dbsprite 0, 3, 0, 0, $35, OAM_HFLIP | OAM_VFLIP + dbsprite 0, 3, 0, 0, $35, OAM_XFLIP | OAM_YFLIP dbsprite 8, 0, 0, 0, $35, 0 - dbsprite 8, 1, 0, 0, $35, OAM_HFLIP | OAM_VFLIP - dbsprite 8, 2, 0, 0, $35, OAM_HFLIP - dbsprite 8, 3, 0, 0, $35, OAM_VFLIP + dbsprite 8, 1, 0, 0, $35, OAM_XFLIP | OAM_YFLIP + dbsprite 8, 2, 0, 0, $35, OAM_XFLIP + dbsprite 8, 3, 0, 0, $35, OAM_YFLIP FrameBlock52: db 4 ; # @@ -945,9 +945,9 @@ FrameBlock53: FrameBlock54: db 4 ; # dbsprite 0, 0, 0, 0, $0e, 0 - dbsprite 1, 0, 0, 0, $0e, OAM_HFLIP + dbsprite 1, 0, 0, 0, $0e, OAM_XFLIP dbsprite 0, 1, 0, 0, $0f, 0 - dbsprite 1, 1, 0, 0, $0f, OAM_HFLIP + dbsprite 1, 1, 0, 0, $0f, OAM_XFLIP FrameBlock55: db 3 ; # @@ -995,22 +995,22 @@ FrameBlock5a: dbsprite 0, 0, 0, 0, $24, 0 dbsprite 1, 0, 0, 0, $25, 0 dbsprite 0, 1, 0, 0, $34, 0 - dbsprite 2, 0, 0, 0, $25, OAM_HFLIP - dbsprite 3, 0, 0, 0, $24, OAM_HFLIP - dbsprite 3, 1, 0, 0, $34, OAM_HFLIP - dbsprite 0, 2, 0, 0, $34, OAM_VFLIP - dbsprite 0, 3, 0, 0, $24, OAM_VFLIP - dbsprite 1, 3, 0, 0, $25, OAM_VFLIP - dbsprite 3, 2, 0, 0, $34, OAM_HFLIP | OAM_VFLIP - dbsprite 2, 3, 0, 0, $25, OAM_HFLIP | OAM_VFLIP - dbsprite 3, 3, 0, 0, $24, OAM_HFLIP | OAM_VFLIP + dbsprite 2, 0, 0, 0, $25, OAM_XFLIP + dbsprite 3, 0, 0, 0, $24, OAM_XFLIP + dbsprite 3, 1, 0, 0, $34, OAM_XFLIP + dbsprite 0, 2, 0, 0, $34, OAM_YFLIP + dbsprite 0, 3, 0, 0, $24, OAM_YFLIP + dbsprite 1, 3, 0, 0, $25, OAM_YFLIP + dbsprite 3, 2, 0, 0, $34, OAM_XFLIP | OAM_YFLIP + dbsprite 2, 3, 0, 0, $25, OAM_XFLIP | OAM_YFLIP + dbsprite 3, 3, 0, 0, $24, OAM_XFLIP | OAM_YFLIP FrameBlock5b: db 4 ; # dbsprite 0, 0, 0, 0, $43, 0 - dbsprite 1, 0, 0, 0, $43, OAM_HFLIP - dbsprite 0, 1, 0, 0, $43, OAM_VFLIP - dbsprite 1, 1, 0, 0, $43, OAM_HFLIP | OAM_VFLIP + dbsprite 1, 0, 0, 0, $43, OAM_XFLIP + dbsprite 0, 1, 0, 0, $43, OAM_YFLIP + dbsprite 1, 1, 0, 0, $43, OAM_XFLIP | OAM_YFLIP FrameBlock5c: db 8 ; # @@ -1019,9 +1019,9 @@ FrameBlock5c: dbsprite 0, 3, 0, 0, $49, 0 dbsprite 2, 2, 0, 0, $49, 0 dbsprite 0, 1, 0, 0, $43, 0 - dbsprite 1, 1, 0, 0, $43, OAM_HFLIP - dbsprite 0, 2, 0, 0, $43, OAM_VFLIP - dbsprite 1, 2, 0, 0, $43, OAM_HFLIP | OAM_VFLIP + dbsprite 1, 1, 0, 0, $43, OAM_XFLIP + dbsprite 0, 2, 0, 0, $43, OAM_YFLIP + dbsprite 1, 2, 0, 0, $43, OAM_XFLIP | OAM_YFLIP FrameBlock5d: db 11 ; # @@ -1029,13 +1029,13 @@ FrameBlock5d: dbsprite 0, 3, 2, 0, $49, 0 dbsprite 2, 2, 0, 4, $49, 0 dbsprite 0, 1, 0, 0, $43, 0 - dbsprite 1, 0, 0, 0, $43, OAM_HFLIP - dbsprite 0, 2, 0, 0, $43, OAM_VFLIP - dbsprite 1, 2, 0, 0, $43, OAM_HFLIP | OAM_VFLIP + dbsprite 1, 0, 0, 0, $43, OAM_XFLIP + dbsprite 0, 2, 0, 0, $43, OAM_YFLIP + dbsprite 1, 2, 0, 0, $43, OAM_XFLIP | OAM_YFLIP dbsprite 1, 0, 0, 4, $43, 0 - dbsprite 2, 0, 0, 4, $43, OAM_HFLIP - dbsprite 1, 1, 0, 4, $43, OAM_VFLIP - dbsprite 2, 1, 0, 4, $43, OAM_HFLIP | OAM_VFLIP + dbsprite 2, 0, 0, 4, $43, OAM_XFLIP + dbsprite 1, 1, 0, 4, $43, OAM_YFLIP + dbsprite 2, 1, 0, 4, $43, OAM_XFLIP | OAM_YFLIP FrameBlock5e: db 15 ; # @@ -1043,17 +1043,17 @@ FrameBlock5e: dbsprite 2, 1, 0, 0, $49, 0 dbsprite 0, 4, 0, 0, $49, 0 dbsprite 0, 1, 0, 0, $43, 0 - dbsprite 1, 1, 0, 0, $43, OAM_HFLIP - dbsprite 0, 2, 0, 0, $43, OAM_VFLIP - dbsprite 1, 2, 0, 0, $43, OAM_HFLIP | OAM_VFLIP + dbsprite 1, 1, 0, 0, $43, OAM_XFLIP + dbsprite 0, 2, 0, 0, $43, OAM_YFLIP + dbsprite 1, 2, 0, 0, $43, OAM_XFLIP | OAM_YFLIP dbsprite 2, 2, 0, 0, $43, 0 - dbsprite 3, 2, 0, 0, $43, OAM_HFLIP - dbsprite 2, 3, 0, 0, $43, OAM_VFLIP - dbsprite 3, 3, 0, 0, $43, OAM_HFLIP | OAM_VFLIP + dbsprite 3, 2, 0, 0, $43, OAM_XFLIP + dbsprite 2, 3, 0, 0, $43, OAM_YFLIP + dbsprite 3, 3, 0, 0, $43, OAM_XFLIP | OAM_YFLIP dbsprite 1, 4, 0, 0, $43, 0 - dbsprite 2, 4, 0, 0, $43, OAM_HFLIP - dbsprite 1, 5, 0, 0, $43, OAM_VFLIP - dbsprite 2, 5, 0, 0, $43, OAM_HFLIP | OAM_VFLIP + dbsprite 2, 4, 0, 0, $43, OAM_XFLIP + dbsprite 1, 5, 0, 0, $43, OAM_YFLIP + dbsprite 2, 5, 0, 0, $43, OAM_XFLIP | OAM_YFLIP FrameBlock5f: db 4 ; # @@ -1146,9 +1146,9 @@ FrameBlock67: FrameBlock68: db 4 ; # dbsprite 0, 0, 0, 0, $03, 0 - dbsprite 1, 0, 0, 0, $03, OAM_HFLIP + dbsprite 1, 0, 0, 0, $03, OAM_XFLIP dbsprite 0, 1, 0, 0, $13, 0 - dbsprite 1, 1, 0, 0, $13, OAM_HFLIP + dbsprite 1, 1, 0, 0, $13, OAM_XFLIP FrameBlock69: db 1 ; # @@ -1157,35 +1157,35 @@ FrameBlock69: FrameBlock6a: db 8 ; # dbsprite 0, 0, 0, 0, $2e, 0 - dbsprite 6, 0, 0, 0, $2e, OAM_HFLIP - dbsprite 0, 6, 0, 0, $2e, OAM_VFLIP - dbsprite 6, 6, 0, 0, $2e, OAM_HFLIP | OAM_VFLIP + dbsprite 6, 0, 0, 0, $2e, OAM_XFLIP + dbsprite 0, 6, 0, 0, $2e, OAM_YFLIP + dbsprite 6, 6, 0, 0, $2e, OAM_XFLIP | OAM_YFLIP dbsprite 3, 0, 0, 0, $2f, 0 - dbsprite 3, 6, 0, 0, $2f, OAM_VFLIP + dbsprite 3, 6, 0, 0, $2f, OAM_YFLIP dbsprite 0, 3, 0, 0, $3e, 0 - dbsprite 6, 3, 0, 0, $3e, OAM_HFLIP + dbsprite 6, 3, 0, 0, $3e, OAM_XFLIP FrameBlock6b: db 8 ; # dbsprite 0, 0, 0, 0, $2e, 0 - dbsprite 4, 0, 0, 0, $2e, OAM_HFLIP - dbsprite 0, 4, 0, 0, $2e, OAM_VFLIP - dbsprite 4, 4, 0, 0, $2e, OAM_HFLIP | OAM_VFLIP + dbsprite 4, 0, 0, 0, $2e, OAM_XFLIP + dbsprite 0, 4, 0, 0, $2e, OAM_YFLIP + dbsprite 4, 4, 0, 0, $2e, OAM_XFLIP | OAM_YFLIP dbsprite 2, 0, 0, 0, $2f, 0 - dbsprite 2, 4, 0, 0, $2f, OAM_VFLIP + dbsprite 2, 4, 0, 0, $2f, OAM_YFLIP dbsprite 0, 2, 0, 0, $3e, 0 - dbsprite 4, 2, 0, 0, $3e, OAM_HFLIP + dbsprite 4, 2, 0, 0, $3e, OAM_XFLIP FrameBlock6c: db 8 ; # dbsprite 0, 0, 0, 0, $2e, 0 - dbsprite 2, 0, 0, 0, $2e, OAM_HFLIP - dbsprite 0, 2, 0, 0, $2e, OAM_VFLIP - dbsprite 2, 2, 0, 0, $2e, OAM_HFLIP | OAM_VFLIP + dbsprite 2, 0, 0, 0, $2e, OAM_XFLIP + dbsprite 0, 2, 0, 0, $2e, OAM_YFLIP + dbsprite 2, 2, 0, 0, $2e, OAM_XFLIP | OAM_YFLIP dbsprite 1, 0, 0, 0, $2f, 0 - dbsprite 1, 2, 0, 0, $2f, OAM_VFLIP + dbsprite 1, 2, 0, 0, $2f, OAM_YFLIP dbsprite 0, 1, 0, 0, $3e, 0 - dbsprite 2, 1, 0, 0, $3e, OAM_HFLIP + dbsprite 2, 1, 0, 0, $3e, OAM_XFLIP FrameBlock6d: db 2 ; # @@ -1195,9 +1195,9 @@ FrameBlock6d: FrameBlock6e: db 4 ; # dbsprite 0, 0, 0, 0, $48, 0 - dbsprite 1, 0, 0, 0, $48, OAM_HFLIP + dbsprite 1, 0, 0, 0, $48, OAM_XFLIP dbsprite 0, 1, 0, 0, $12, 0 - dbsprite 1, 1, 0, 0, $12, OAM_HFLIP + dbsprite 1, 1, 0, 0, $12, OAM_XFLIP FrameBlock6f: db 4 ; # @@ -1208,10 +1208,10 @@ FrameBlock6f: FrameBlock70: db 4 ; # - dbsprite 0, 0, 0, 0, $07, OAM_HFLIP - dbsprite 1, 0, 0, 0, $4a, OAM_HFLIP - dbsprite 0, 1, 0, 0, $17, OAM_HFLIP - dbsprite 1, 1, 0, 0, $16, OAM_HFLIP + dbsprite 0, 0, 0, 0, $07, OAM_XFLIP + dbsprite 1, 0, 0, 0, $4a, OAM_XFLIP + dbsprite 0, 1, 0, 0, $17, OAM_XFLIP + dbsprite 1, 1, 0, 0, $16, OAM_XFLIP FrameBlock76: db 7 ; # @@ -1219,16 +1219,16 @@ FrameBlock76: dbsprite 1, 0, 0, 1, $2f, 0 dbsprite 3, 0, 0, 1, $2f, 0 dbsprite 0, 0, 0, 2, $2e, 0 - dbsprite 4, 0, 0, 2, $2e, OAM_HFLIP + dbsprite 4, 0, 0, 2, $2e, OAM_XFLIP dbsprite 0, 1, 0, 2, $3e, 0 - dbsprite 4, 1, 0, 2, $3e, OAM_HFLIP + dbsprite 4, 1, 0, 2, $3e, OAM_XFLIP FrameBlock77: db 4 ; # dbsprite 0, 0, 2, 0, $4b, 0 dbsprite 1, 0, 2, 0, $4c, 0 - dbsprite 0, 1, 0, 0, $4c, OAM_HFLIP | OAM_VFLIP - dbsprite 1, 1, 0, 0, $4b, OAM_HFLIP | OAM_VFLIP + dbsprite 0, 1, 0, 0, $4c, OAM_XFLIP | OAM_YFLIP + dbsprite 1, 1, 0, 0, $4b, OAM_XFLIP | OAM_YFLIP FrameBlock78: db 1 ; # @@ -1276,14 +1276,14 @@ FrameBlock7d: FrameBlock7e: db 4 ; # - dbsprite 0, 0, 0, 0, $01, OAM_HFLIP - dbsprite 1, 0, 0, 0, $00, OAM_HFLIP - dbsprite 0, 1, 0, 0, $04, OAM_HFLIP - dbsprite 1, 1, 0, 0, $03, OAM_HFLIP + dbsprite 0, 0, 0, 0, $01, OAM_XFLIP + dbsprite 1, 0, 0, 0, $00, OAM_XFLIP + dbsprite 0, 1, 0, 0, $04, OAM_XFLIP + dbsprite 1, 1, 0, 0, $03, OAM_XFLIP FrameBlock7f: db 4 ; # dbsprite 0, 0, 0, 0, $02, 0 - dbsprite 1, 0, 0, 0, $02, OAM_HFLIP - dbsprite 0, 1, 0, 0, $02, OAM_VFLIP - dbsprite 1, 1, 0, 0, $02, OAM_HFLIP | OAM_VFLIP + dbsprite 1, 0, 0, 0, $02, OAM_XFLIP + dbsprite 0, 1, 0, 0, $02, OAM_YFLIP + dbsprite 1, 1, 0, 0, $02, OAM_XFLIP | OAM_YFLIP diff --git a/data/events/trades.asm b/data/events/trades.asm index 40f528b09d..9b67f3d77d 100644 --- a/data/events/trades.asm +++ b/data/events/trades.asm @@ -1,26 +1,31 @@ ; PureRGBnote: CHANGED: different in-game trades +MACRO npctrade +; give mon, get mon, dialog id, nickname + db \1, \2, \3 + dname \4, NAME_LENGTH +ENDM TradeMons: ; entries correspond to TRADE_FOR_* constants table_width 3 + NAME_LENGTH - ; give mon, get mon, dialog id, nickname ; The two instances of TRADE_DIALOGSET_EVOLUTION are a leftover ; from the Japanese Blue trades, which used species that evolve. ; TRADE_DIALOGSET_EVOLUTION did not refer to evolution in Japanese ; Red/Green. Japanese Blue changed _AfterTrade2Text to say your Pokémon ; "went and evolved" and also changed the trades to match. English ; Red/Blue uses the original JP Red/Green trades but with the JP Blue - ; post-trade text. - db ODDISH, PONYTA, TRADE_DIALOGSET_CASUAL, "Seabiscuit@" ; route 11 - db DROWZEE, GRIMER, TRADE_DIALOGSET_CASUAL, "Goopinator@" ; route 2 - db ALAKAZAM, MAGNETON, TRADE_DIALOGSET_SPROCKET, "SPROCKET@@@" ; cerulean city rocket house basement - db PONYTA, MACHOP, TRADE_DIALOGSET_CASUAL_COLOR, "HulkSmash@@" ; cinnabar lab - db ONIX, GASTLY, TRADE_DIALOGSET_HAPPY, "Nebula@@@@@" ; vermilion city - db TAUROS, LICKITUNG, TRADE_DIALOGSET_CASUAL_COLOR, "Saliva@@@@@" ; route 18 - db PIDGEOTTO, SEEL, TRADE_DIALOGSET_EVOLUTION, "Slappy@@@@@" ; cerulean city - db DITTO, ZUBAT, TRADE_DIALOGSET_EVOLUTION_COLOR, "EmeraldSDB@" ; cinnabar lab - db LAPRAS, SNORLAX, TRADE_DIALOGSET_HAPPY_COLOR, "Fatso@@@@@@" ; cinnabar lab - db VOLTORB, TANGELA, TRADE_DIALOGSET_HAPPY, "Discombob@@" ; route 5 + ; post-trade text. English Yellow changed _AfterTrade2Text to + ; not mention evolution. + npctrade ODDISH, PONYTA, TRADE_DIALOGSET_CASUAL, "Seabiscuit" ; route 11 + npctrade DROWZEE, GRIMER, TRADE_DIALOGSET_CASUAL, "Goopinator" ; route 2 + npctrade ALAKAZAM, MAGNETON, TRADE_DIALOGSET_SPROCKET, "SPROCKET" ; cerulean city rocket house basement + npctrade PONYTA, MACHOP, TRADE_DIALOGSET_CASUAL_COLOR, "HulkSmash" ; cinnabar lab + npctrade ONIX, GASTLY, TRADE_DIALOGSET_HAPPY, "Nebula" ; vermilion city + npctrade TAUROS, LICKITUNG, TRADE_DIALOGSET_CASUAL_COLOR, "Saliva" ; route 18 + npctrade PIDGEOTTO, SEEL, TRADE_DIALOGSET_EVOLUTION, "Slappy" ; cerulean city + npctrade DITTO, ZUBAT, TRADE_DIALOGSET_EVOLUTION_COLOR, "EmeraldSDB" ; cinnabar lab + npctrade LAPRAS, SNORLAX, TRADE_DIALOGSET_HAPPY_COLOR, "Fatso" ; cinnabar lab + npctrade VOLTORB, TANGELA, TRADE_DIALOGSET_HAPPY, "Discombob" ; route 5 assert_table_length NUM_NPC_TRADES ; PureRGBnote: ADDED: some received pokemon use alternate color palettes if the feature is enabled diff --git a/data/items/names.asm b/data/items/names.asm index e3e6135e0a..a5966323c8 100644 --- a/data/items/names.asm +++ b/data/items/names.asm @@ -1,5 +1,5 @@ ItemNames:: - list_start + list_start ITEM_NAME_LENGTH - 1 li "MASTER BALL" li "ULTRA BALL" li "GREAT BALL" diff --git a/data/maps/hide_show_data.asm b/data/maps/hide_show_data.asm index fdad57c082..4a150d5b20 100644 --- a/data/maps/hide_show_data.asm +++ b/data/maps/hide_show_data.asm @@ -256,7 +256,7 @@ MapHSPointers: dw -1 ; end NoHS: - db $FF, $FF, $FF + db -1, -1, -1 ; end MissableObjects: ; entries correspond to HS_* constants (see constants/hide_show_constants) @@ -590,8 +590,8 @@ CeruleanRocketHouse1FHS: db CERULEAN_ROCKET_HOUSE_1F, CERULEANROCKETHOUSE1F_ROCKET, SHOW CeladonHotelHS: db CELADON_HOTEL, CELADONHOTEL_LAPRAS_GUY, SHOW - db $FF, $01, SHOW ; end - assert_table_length NUM_HS_OBJECTS + 1 + assert_table_length NUM_HS_OBJECTS + db -1, 1, SHOW ; end ExtraMissableObjects: ; entries correspond to HS_* constants (see constants/hide_show_constants) diff --git a/data/maps/objects/Route2Gate.asm b/data/maps/objects/Route2Gate.asm index 6c46736dd8..44e4aa6790 100644 --- a/data/maps/objects/Route2Gate.asm +++ b/data/maps/objects/Route2Gate.asm @@ -1,6 +1,6 @@ object_const_def - const_export ROUTE2_OAKS_AIDE - const_export ROUTE2_YOUNGSTER + const_export ROUTE2GATE_OAKS_AIDE + const_export ROUTE2GATE_YOUNGSTER Route2Gate_Object: db $a ; border block diff --git a/data/maps/town_map_entries.asm b/data/maps/town_map_entries.asm index ca1cdecf4d..d8dd7e7be9 100644 --- a/data/maps/town_map_entries.asm +++ b/data/maps/town_map_entries.asm @@ -1,4 +1,4 @@ -MACRO external_map +MACRO outdoor_map dn \2, \1 dw \3 ENDM @@ -8,47 +8,47 @@ ENDM ExternalMapEntries: table_width 3 ; x, y, name - external_map 2, 11, PalletTownName - external_map 2, 8, ViridianCityName - external_map 2, 3, PewterCityName - external_map 10, 2, CeruleanCityName - external_map 14, 5, LavenderTownName - external_map 10, 9, VermilionCityName - external_map 7, 5, CeladonCityName - external_map 10, 5, SaffronCityName - external_map 8, 13, FuchsiaCityName - external_map 2, 15, CinnabarIslandName - external_map 0, 2, IndigoPlateauName - external_map 0, 0, PalletTownName ; unused - external_map 2, 10, Route1Name - external_map 2, 6, Route2Name - external_map 4, 3, Route3Name - external_map 8, 2, Route4Name - external_map 10, 3, Route5Name - external_map 10, 7, Route6Name - external_map 8, 5, Route7Name - external_map 12, 5, Route8Name - external_map 13, 2, Route9Name - external_map 14, 4, Route10Name - external_map 12, 9, Route11Name - external_map 14, 8, Route12Name - external_map 13, 11, Route13Name - external_map 11, 12, Route14Name - external_map 10, 13, Route15Name - external_map 5, 5, Route16Name - external_map 4, 8, Route17Name - external_map 6, 13, Route18Name - external_map 6, 15, Route19Name - external_map 4, 15, Route20Name - external_map 2, 13, Route21Name - external_map 0, 8, Route22Name - external_map 0, 6, Route23Name - external_map 10, 1, Route24Name - external_map 11, 0, Route25Name + outdoor_map 2, 11, PalletTownName + outdoor_map 2, 8, ViridianCityName + outdoor_map 2, 3, PewterCityName + outdoor_map 10, 2, CeruleanCityName + outdoor_map 14, 5, LavenderTownName + outdoor_map 10, 9, VermilionCityName + outdoor_map 7, 5, CeladonCityName + outdoor_map 10, 5, SaffronCityName + outdoor_map 8, 13, FuchsiaCityName + outdoor_map 2, 15, CinnabarIslandName + outdoor_map 0, 2, IndigoPlateauName + outdoor_map 0, 0, PalletTownName ; unused + outdoor_map 2, 10, Route1Name + outdoor_map 2, 6, Route2Name + outdoor_map 4, 3, Route3Name + outdoor_map 8, 2, Route4Name + outdoor_map 10, 3, Route5Name + outdoor_map 10, 7, Route6Name + outdoor_map 8, 5, Route7Name + outdoor_map 12, 5, Route8Name + outdoor_map 13, 2, Route9Name + outdoor_map 14, 4, Route10Name + outdoor_map 12, 9, Route11Name + outdoor_map 14, 8, Route12Name + outdoor_map 13, 11, Route13Name + outdoor_map 11, 12, Route14Name + outdoor_map 10, 13, Route15Name + outdoor_map 5, 5, Route16Name + outdoor_map 4, 8, Route17Name + outdoor_map 6, 13, Route18Name + outdoor_map 6, 15, Route19Name + outdoor_map 4, 15, Route20Name + outdoor_map 2, 13, Route21Name + outdoor_map 0, 8, Route22Name + outdoor_map 0, 6, Route23Name + outdoor_map 10, 1, Route24Name + outdoor_map 11, 0, Route25Name assert_table_length FIRST_INDOOR_MAP -MACRO internal_map +MACRO indoor_map db \1 + 1 dn \3, \2 dw \4 @@ -57,80 +57,81 @@ ENDM ; PureRGBnote: CHANGED: some coordinates were changed for better positioning here ; the appearance of buildings and dungeons in the town map InternalMapEntries: - ; maximum map id subject to this rule, x, y, name - internal_map OAKS_LAB, 2, 11, PalletTownName - internal_map VIRIDIAN_GYM, 2, 8, ViridianCityName - internal_map DIGLETTS_CAVE_ROUTE_2, 3, 4, DiglettsCaveName - internal_map VIRIDIAN_FOREST_NORTH_GATE, 2, 4, Route2Name - internal_map VIRIDIAN_FOREST_SOUTH_GATE, 2, 5, Route2Name - internal_map VIRIDIAN_FOREST, 2, 4, ViridianForestName - internal_map PEWTER_POKECENTER, 2, 3, PewterCityName - internal_map MT_MOON_B2F, 6, 2, MountMoonName - internal_map CERULEAN_MART, 10, 2, CeruleanCityName - internal_map MT_MOON_POKECENTER, 5, 2, Route4Name - internal_map POWER_PLANT_ROOF, 15, 3, PowerPlantName - internal_map DAYCARE, 10, 4, Route5Name - internal_map UNDERGROUND_PATH_ROUTE_6_COPY, 10, 6, Route6Name - internal_map UNDERGROUND_PATH_ROUTE_7_COPY, 9, 5, Route7Name - internal_map UNDERGROUND_PATH_ROUTE_8, 11, 5, Route8Name - internal_map ROCK_TUNNEL_POKECENTER, 14, 3, Route10Name - internal_map ROCK_TUNNEL_1F, 14, 3, RockTunnelName - internal_map POWER_PLANT, 15, 3, PowerPlantName - internal_map ROUTE_11_GATE_1F, 13, 9, Route11Name - internal_map DIGLETTS_CAVE_ROUTE_11, 11, 8, DiglettsCaveName - internal_map ROUTE_11_GATE_2F, 13, 9, Route11Name - internal_map ROUTE_12_GATE_1F, 14, 7, Route12Name - internal_map BILLS_HOUSE, 12, 0, SeaCottageName - internal_map VERMILION_DOCK, 10, 9, VermilionCityName - internal_map SS_ANNE_B1F_ROOMS, 9, 10, SSAnneName - internal_map CERULEAN_ROCKET_HOUSE_B1F, 10, 2, CeruleanCityName - internal_map VICTORY_ROAD_1F, 0, 4, VictoryRoadName - internal_map VIRIDIAN_SCHOOL_HOUSE_B1F, 2, 8, ViridianCityName - internal_map BILLS_GARDEN, 13, 0, BillsGardenName - internal_map SECRET_LAB, 2, 15, PokemonMansionName - internal_map CHAMP_ARENA, 0, 2, PokemonLeagueName - internal_map DIAMOND_MINE, 12, 4, DiamondMineName - internal_map CINNABAR_VOLCANO_WEST, 1, 13, CinnabarVolcanoName - internal_map HALL_OF_FAME, 0, 2, PokemonLeagueName - internal_map UNDERGROUND_PATH_NORTH_SOUTH, 10, 5, UndergroundPathName - internal_map CHAMPIONS_ROOM, 0, 2, PokemonLeagueName - internal_map UNDERGROUND_PATH_WEST_EAST, 10, 5, UndergroundPathName - internal_map CELADON_HOTEL, 7, 5, CeladonCityName - internal_map LAVENDER_POKECENTER, 14, 5, LavenderTownName - internal_map POKEMON_TOWER_7F, 15, 4, PokemonTowerName - internal_map LAVENDER_CUBONE_HOUSE, 14, 5, LavenderTownName - internal_map WARDENS_HOUSE, 8, 13, FuchsiaCityName - internal_map SAFARI_ZONE_GATE, 8, 12, SafariZoneName - internal_map FUCHSIA_MEETING_ROOM, 8, 13, FuchsiaCityName - internal_map SEAFOAM_ISLANDS_B4F, 5, 15, SeafoamIslandsName - internal_map VERMILION_OLD_ROD_HOUSE, 10, 9, VermilionCityName - internal_map FUCHSIA_GOOD_ROD_HOUSE, 8, 13, FuchsiaCityName - internal_map POKEMON_MANSION_1F, 2, 15, PokemonMansionName - internal_map CINNABAR_MART, 2, 15, CinnabarIslandName - internal_map TYPE_GUYS_HOUSE, 0, 6, Route23Name - internal_map INDIGO_PLATEAU_LOBBY, 0, 2, IndigoPlateauName - internal_map MR_PSYCHICS_HOUSE, 10, 5, SaffronCityName - internal_map ROUTE_15_GATE_2F, 9, 13, Route15Name - internal_map ROUTE_16_FLY_HOUSE, 4, 5, Route16Name - internal_map ROUTE_12_SUPER_ROD_HOUSE, 14, 10, Route12Name - internal_map ROUTE_18_GATE_2F, 7, 13, Route18Name - internal_map SEAFOAM_ISLANDS_1F, 5, 15, SeafoamIslandsName - internal_map ROUTE_22_GATE, 0, 7, Route22Name - internal_map VICTORY_ROAD_2F, 0, 4, VictoryRoadName - internal_map ROUTE_12_GATE_2F, 14, 7, Route12Name - internal_map VERMILION_TRADE_HOUSE, 10, 9, VermilionCityName - internal_map DIGLETTS_CAVE, 11, 8, DiglettsCaveName - internal_map VICTORY_ROAD_3F, 0, 4, VictoryRoadName - internal_map ROCKET_HIDEOUT_ELEVATOR, 7, 5, RocketHQName - internal_map FUCHSIA_TREE_DELETER_HOUSE, 8, 13, FuchsiaCityName - internal_map FOSSIL_GUYS_HOUSE, 10, 5, SaffronCityName - internal_map SILPH_CO_8F, 10, 5, SilphCoName - internal_map POKEMON_MANSION_B1F, 2, 15, PokemonMansionName - internal_map SAFARI_ZONE_NORTH_REST_HOUSE, 8, 12, SafariZoneName - internal_map CERULEAN_CAVE_1F, 9, 1, CeruleanCaveName - internal_map NAME_RATERS_HOUSE, 14, 5, LavenderTownName - internal_map CERULEAN_BADGE_HOUSE, 10, 2, CeruleanCityName - internal_map ROCK_TUNNEL_B1F, 14, 3, RockTunnelName - internal_map SILPH_CO_ELEVATOR, 10, 5, SilphCoName - internal_map AGATHAS_ROOM, 0, 2, PokemonLeagueName + table_width 4 + ; indoor map group, x, y, name + indoor_map OAKS_LAB, 2, 11, PalletTownName + indoor_map VIRIDIAN_GYM, 2, 8, ViridianCityName + indoor_map DIGLETTS_CAVE_ROUTE_2, 3, 4, DiglettsCaveName + indoor_map VIRIDIAN_FOREST_NORTH_GATE, 2, 4, Route2Name + indoor_map VIRIDIAN_FOREST_SOUTH_GATE, 2, 5, Route2Name + indoor_map VIRIDIAN_FOREST, 2, 4, ViridianForestName + indoor_map PEWTER_POKECENTER, 2, 3, PewterCityName + indoor_map MT_MOON_B2F, 6, 2, MountMoonName + indoor_map CERULEAN_MART, 10, 2, CeruleanCityName + indoor_map MT_MOON_POKECENTER, 5, 2, Route4Name + indoor_map POWER_PLANT_ROOF, 15, 3, PowerPlantName + indoor_map DAYCARE, 10, 4, Route5Name + indoor_map UNDERGROUND_PATH_ROUTE_6_COPY, 10, 6, Route6Name + indoor_map UNDERGROUND_PATH_ROUTE_7_COPY, 9, 5, Route7Name + indoor_map UNDERGROUND_PATH_ROUTE_8, 11, 5, Route8Name + indoor_map ROCK_TUNNEL_POKECENTER, 14, 3, Route10Name + indoor_map ROCK_TUNNEL_1F, 14, 3, RockTunnelName + indoor_map POWER_PLANT, 15, 3, PowerPlantName + indoor_map ROUTE_11_GATE_1F, 13, 9, Route11Name + indoor_map DIGLETTS_CAVE_ROUTE_11, 11, 8, DiglettsCaveName + indoor_map ROUTE_11_GATE_2F, 13, 9, Route11Name + indoor_map ROUTE_12_GATE_1F, 14, 7, Route12Name + indoor_map BILLS_HOUSE, 12, 0, SeaCottageName + indoor_map VERMILION_DOCK, 10, 9, VermilionCityName + indoor_map SS_ANNE_B1F_ROOMS, 9, 10, SSAnneName + indoor_map CERULEAN_ROCKET_HOUSE_B1F, 10, 2, CeruleanCityName + indoor_map VICTORY_ROAD_1F, 0, 4, VictoryRoadName + indoor_map VIRIDIAN_SCHOOL_HOUSE_B1F, 2, 8, ViridianCityName + indoor_map BILLS_GARDEN, 13, 0, BillsGardenName + indoor_map SECRET_LAB, 2, 15, PokemonMansionName + indoor_map CHAMP_ARENA, 0, 2, PokemonLeagueName + indoor_map DIAMOND_MINE, 12, 4, DiamondMineName + indoor_map CINNABAR_VOLCANO_WEST, 1, 13, CinnabarVolcanoName + indoor_map HALL_OF_FAME, 0, 2, PokemonLeagueName + indoor_map UNDERGROUND_PATH_NORTH_SOUTH, 10, 5, UndergroundPathName + indoor_map CHAMPIONS_ROOM, 0, 2, PokemonLeagueName + indoor_map UNDERGROUND_PATH_WEST_EAST, 10, 5, UndergroundPathName + indoor_map CELADON_HOTEL, 7, 5, CeladonCityName + indoor_map LAVENDER_POKECENTER, 14, 5, LavenderTownName + indoor_map POKEMON_TOWER_7F, 15, 4, PokemonTowerName + indoor_map LAVENDER_CUBONE_HOUSE, 14, 5, LavenderTownName + indoor_map WARDENS_HOUSE, 8, 13, FuchsiaCityName + indoor_map SAFARI_ZONE_GATE, 8, 12, SafariZoneName + indoor_map FUCHSIA_MEETING_ROOM, 8, 13, FuchsiaCityName + indoor_map SEAFOAM_ISLANDS_B4F, 5, 15, SeafoamIslandsName + indoor_map VERMILION_OLD_ROD_HOUSE, 10, 9, VermilionCityName + indoor_map FUCHSIA_GOOD_ROD_HOUSE, 8, 13, FuchsiaCityName + indoor_map POKEMON_MANSION_1F, 2, 15, PokemonMansionName + indoor_map CINNABAR_MART, 2, 15, CinnabarIslandName + indoor_map TYPE_GUYS_HOUSE, 0, 6, Route23Name + indoor_map INDIGO_PLATEAU_LOBBY, 0, 2, IndigoPlateauName + indoor_map MR_PSYCHICS_HOUSE, 10, 5, SaffronCityName + indoor_map ROUTE_15_GATE_2F, 9, 13, Route15Name + indoor_map ROUTE_16_FLY_HOUSE, 4, 5, Route16Name + indoor_map ROUTE_12_SUPER_ROD_HOUSE, 14, 10, Route12Name + indoor_map ROUTE_18_GATE_2F, 7, 13, Route18Name + indoor_map SEAFOAM_ISLANDS_1F, 5, 15, SeafoamIslandsName + indoor_map ROUTE_22_GATE, 0, 7, Route22Name + indoor_map VICTORY_ROAD_2F, 0, 4, VictoryRoadName + indoor_map ROUTE_12_GATE_2F, 14, 7, Route12Name + indoor_map VERMILION_TRADE_HOUSE, 10, 9, VermilionCityName + indoor_map DIGLETTS_CAVE, 11, 8, DiglettsCaveName + indoor_map VICTORY_ROAD_3F, 0, 4, VictoryRoadName + indoor_map ROCKET_HIDEOUT_ELEVATOR, 7, 5, RocketHQName + indoor_map FUCHSIA_TREE_DELETER_HOUSE, 8, 13, FuchsiaCityName + indoor_map FOSSIL_GUYS_HOUSE, 10, 5, SaffronCityName + indoor_map SILPH_CO_8F, 10, 5, SilphCoName + indoor_map POKEMON_MANSION_B1F, 2, 15, PokemonMansionName + indoor_map SAFARI_ZONE_NORTH_REST_HOUSE, 8, 12, SafariZoneName + indoor_map CERULEAN_CAVE_1F, 9, 1, CeruleanCaveName + indoor_map NAME_RATERS_HOUSE, 14, 5, LavenderTownName + indoor_map CERULEAN_BADGE_HOUSE, 10, 2, CeruleanCityName + indoor_map ROCK_TUNNEL_B1F, 14, 3, RockTunnelName + indoor_map SILPH_CO_ELEVATOR, 10, 5, SilphCoName + indoor_map AGATHAS_ROOM, 0, 2, PokemonLeagueName db -1 ; end diff --git a/data/moves/names.asm b/data/moves/names.asm index 8bb25fc35d..b2107fb8e6 100644 --- a/data/moves/names.asm +++ b/data/moves/names.asm @@ -1,5 +1,6 @@ MoveNames:: - list_start + ; in-battle "used !" text can only fit 12 (MOVE_NAME_LENGTH - 2) characters + list_start MOVE_NAME_LENGTH - 2 li "POUND" li "KARATE CHOP" li "DOUBLESLAP" diff --git a/data/player/names.asm b/data/player/names.asm new file mode 100644 index 0000000000..67f2df36eb --- /dev/null +++ b/data/player/names.asm @@ -0,0 +1,15 @@ +; see constants/player_constants.asm + +DefaultNamesPlayer: + db "NEW NAME" +FOR n, 1, NUM_PLAYER_NAMES + 1 + next #PLAYERNAME{d:n} +ENDR + db "@" + +DefaultNamesRival: + db "NEW NAME" +FOR n, 1, NUM_PLAYER_NAMES + 1 + next #RIVALNAME{d:n} +ENDR + db "@" diff --git a/data/player/names_list.asm b/data/player/names_list.asm new file mode 100644 index 0000000000..44f3c7f158 --- /dev/null +++ b/data/player/names_list.asm @@ -0,0 +1,17 @@ +; see constants/player_constants.asm + +DefaultNamesPlayerList: + db "NEW NAME@" + list_start PLAYER_NAME_LENGTH - 1 +FOR n, 1, NUM_PLAYER_NAMES + 1 + li #PLAYERNAME{d:n} +ENDR + assert_list_length NUM_PLAYER_NAMES + +DefaultNamesRivalList: + db "NEW NAME@" + list_start PLAYER_NAME_LENGTH - 1 +FOR n, 1, NUM_PLAYER_NAMES + 1 + li #RIVALNAME{d:n} +ENDR + assert_list_length NUM_PLAYER_NAMES diff --git a/data/player_names.asm b/data/player_names.asm deleted file mode 100644 index dfea78b30d..0000000000 --- a/data/player_names.asm +++ /dev/null @@ -1,47 +0,0 @@ -IF DEF(_RED) -DefaultNamesPlayer: - db "NEW NAME" - next "RED" - next "ASH" - next "JACK" - db "@" - -DefaultNamesRival: - db "NEW NAME" - next "BLUE" - next "GARY" - next "JOHN" - db "@" -ENDC - -IF DEF(_BLUE) -DefaultNamesPlayer: - db "NEW NAME" - next "BLUE" - next "GARY" - next "JOHN" - db "@" - -DefaultNamesRival: - db "NEW NAME" - next "RED" - next "ASH" - next "JACK" - db "@" -ENDC - -IF DEF(_GREEN) ; PureRGBnote: GREENBUILD: default names specific to pokemon green -DefaultNamesPlayer: - db "NEW NAME" - next "GREEN" - next "ASH" - next "MIKE" - db "@" - -DefaultNamesRival: - db "NEW NAME" - next "BLUE" - next "GARY" - next "GABE" - db "@" -ENDC \ No newline at end of file diff --git a/data/player_names_list.asm b/data/player_names_list.asm deleted file mode 100644 index 7eacb27c27..0000000000 --- a/data/player_names_list.asm +++ /dev/null @@ -1,42 +0,0 @@ -IF DEF(_RED) -DefaultNamesPlayerList: - db "NEW NAME@" - db "RED@" - db "ASH@" - db "JACK@" - -DefaultNamesRivalList: - db "NEW NAME@" - db "BLUE@" - db "GARY@" - db "JOHN@" -ENDC - -IF DEF(_BLUE) -DefaultNamesPlayerList: - db "NEW NAME@" - db "BLUE@" - db "GARY@" - db "JOHN@" - -DefaultNamesRivalList: - db "NEW NAME@" - db "RED@" - db "ASH@" - db "JACK@" -ENDC - -IF DEF(_GREEN) ; PureRGBnote: GREENBUILD: default names specific to pokemon green -DefaultNamesPlayerList: - db "NEW NAME@" - db "GREEN@" - db "ASH@" - db "MIKE@" - -DefaultNamesRivalList: - db "NEW NAME@" - db "BLUE@" - db "GARY@" - db "GABE@" -ENDC - diff --git a/data/pokemon/names.asm b/data/pokemon/names.asm index 3f465c1c1c..ab3ca94ab9 100644 --- a/data/pokemon/names.asm +++ b/data/pokemon/names.asm @@ -1,193 +1,193 @@ MonsterNames:: table_width NAME_LENGTH - 1 - db "RHYDON@@@@" - db "KANGASKHAN" - db "NIDORAN♂@@" - db "CLEFAIRY@@" - db "SPEAROW@@@" - db "VOLTORB@@@" - db "NIDOKING@@" - db "SLOWBRO@@@" - db "IVYSAUR@@@" - db "EXEGGUTOR@" - db "LICKITUNG@" - db "EXEGGCUTE@" - db "GRIMER@@@@" - db "GENGAR@@@@" - db "NIDORAN♀@@" - db "NIDOQUEEN@" - db "CUBONE@@@@" - db "RHYHORN@@@" - db "LAPRAS@@@@" - db "ARCANINE@@" - db "MEW@@@@@@@" - db "GYARADOS@@" - db "SHELLDER@@" - db "TENTACOOL@" - db "GASTLY@@@@" - db "SCYTHER@@@" - db "STARYU@@@@" - db "BLASTOISE@" - db "PINSIR@@@@" - db "TANGELA@@@" - db "TORCHED@@@" - db "MISSINGNO." - db "GROWLITHE@" - db "ONIX@@@@@@" - db "FEAROW@@@@" - db "PIDGEY@@@@" - db "SLOWPOKE@@" - db "KADABRA@@@" - db "GRAVELER@@" - db "CHANSEY@@@" - db "MACHOKE@@@" - db "MR.MIME@@@" - db "HITMONLEE@" - db "HITMONCHAN" - db "ARBOK@@@@@" - db "PARASECT@@" - db "PSYDUCK@@@" - db "DROWZEE@@@" - db "GOLEM@@@@@" - db "IRRADIATED" - db "MAGMAR@@@@" - db "MAGMAR@@@@" - db "ELECTABUZZ" - db "MAGNETON@@" - db "KOFFING@@@" - db "MAGNETON@@" - db "MANKEY@@@@" - db "SEEL@@@@@@" - db "DIGLETT@@@" - db "TAUROS@@@@" - db "MISSINGNO." - db "MISSINGNO." - db "MISSINGNO." - db "FARFETCH'D" - db "VENONAT@@@" - db "DRAGONITE@" - db "MISSINGNO." - db "MISSINGNO." - db "MISSINGNO." - db "DODUO@@@@@" - db "POLIWAG@@@" - db "JYNX@@@@@@" - db "MOLTRES@@@" - db "ARTICUNO@@" - db "ZAPDOS@@@@" - db "DITTO@@@@@" - db "MEOWTH@@@@" - db "KRABBY@@@@" - db "MISSINGNO." - db "MISSINGNO." - db "MISSINGNO." - db "VULPIX@@@@" - db "NINETALES@" - db "PIKACHU@@@" - db "RAICHU@@@@" - db "CHUNKY@@@@" - db "MISSINGNO." - db "DRATINI@@@" - db "DRAGONAIR@" - db "KABUTO@@@@" - db "KABUTOPS@@" - db "HORSEA@@@@" - db "SEADRA@@@@" - db "DRAGONAIR@" - db "MISSINGNO." - db "SANDSHREW@" - db "SANDSLASH@" - db "OMANYTE@@@" - db "OMASTAR@@@" - db "JIGGLYPUFF" - db "WIGGLYTUFF" - db "EEVEE@@@@@" - db "FLAREON@@@" - db "JOLTEON@@@" - db "VAPOREON@@" - db "MACHOP@@@@" - db "ZUBAT@@@@@" - db "EKANS@@@@@" - db "PARAS@@@@@" - db "POLIWHIRL@" - db "POLIWRATH@" - db "WEEDLE@@@@" - db "KAKUNA@@@@" - db "BEEDRILL@@" - db "PAINLESS@@" - db "DODRIO@@@@" - db "PRIMEAPE@@" - db "DUGTRIO@@@" - db "VENOMOTH@@" - db "DEWGONG@@@" - db "MISSINGNO." - db "MISSINGNO." - db "CATERPIE@@" - db "METAPOD@@@" - db "BUTTERFREE" - db "MACHAMP@@@" - db "MISSINGNO." - db "GOLDUCK@@@" - db "HYPNO@@@@@" - db "GOLBAT@@@@" - db "MEWTWO@@@@" - db "SNORLAX@@@" - db "MAGIKARP@@" - db "THE MAW@@@" - db "MISSINGNO." - db "MUK@@@@@@@" - db "MISSINGNO." - db "KINGLER@@@" - db "CLOYSTER@@" - db "MISSINGNO." - db "ELECTRODE@" - db "CLEFABLE@@" - db "WEEZING@@@" - db "PERSIAN@@@" - db "MAROWAK@@@" - db "WEEZING@@@" - db "HAUNTER@@@" - db "ABRA@@@@@@" - db "ALAKAZAM@@" - db "PIDGEOTTO@" - db "PIDGEOT@@@" - db "STARMIE@@@" - db "BULBASAUR@" - db "VENUSAUR@@" - db "TENTACRUEL" - db "MISSINGNO." - db "GOLDEEN@@@" - db "SEAKING@@@" - db "MISSINGNO." - db "MISSINGNO." - db "MISSINGNO." - db "MISSINGNO." - db "PONYTA@@@@" - db "RAPIDASH@@" - db "RATTATA@@@" - db "RATICATE@@" - db "NIDORINO@@" - db "NIDORINA@@" - db "GEODUDE@@@" - db "PORYGON@@@" - db "AERODACTYL" - db "ONIX@@@@@@" - db "MAGNEMITE@" - db "MEWTWO@@@@" - db "HAUNTER@@@" - db "CHARMANDER" - db "SQUIRTLE@@" - db "CHARMELEON" - db "WARTORTLE@" - db "CHARIZARD@" - db "MISSINGNO." - db "MISSINGNO." - db "MISSINGNO." - db "GHOST@@@@@" - db "ODDISH@@@@" - db "GLOOM@@@@@" - db "VILEPLUME@" - db "BELLSPROUT" - db "WEEPINBELL" - db "VICTREEBEL" + dname "RHYDON" + dname "KANGASKHAN" + dname "NIDORAN♂" + dname "CLEFAIRY" + dname "SPEAROW" + dname "VOLTORB" + dname "NIDOKING" + dname "SLOWBRO" + dname "IVYSAUR" + dname "EXEGGUTOR" + dname "LICKITUNG" + dname "EXEGGCUTE" + dname "GRIMER" + dname "GENGAR" + dname "NIDORAN♀" + dname "NIDOQUEEN" + dname "CUBONE" + dname "RHYHORN" + dname "LAPRAS" + dname "ARCANINE" + dname "MEW" + dname "GYARADOS" + dname "SHELLDER" + dname "TENTACOOL" + dname "GASTLY" + dname "SCYTHER" + dname "STARYU" + dname "BLASTOISE" + dname "PINSIR" + dname "TANGELA" + dname "TORCHED" + dname "MISSINGNO." + dname "GROWLITHE" + dname "ONIX" + dname "FEAROW" + dname "PIDGEY" + dname "SLOWPOKE" + dname "KADABRA" + dname "GRAVELER" + dname "CHANSEY" + dname "MACHOKE" + dname "MR.MIME" + dname "HITMONLEE" + dname "HITMONCHAN" + dname "ARBOK" + dname "PARASECT" + dname "PSYDUCK" + dname "DROWZEE" + dname "GOLEM" + dname "IRRADIATED" + dname "MAGMAR" + dname "MAGMAR" + dname "ELECTABUZZ" + dname "MAGNETON" + dname "KOFFING" + dname "MAGNETON" + dname "MANKEY" + dname "SEEL" + dname "DIGLETT" + dname "TAUROS" + dname "MISSINGNO." + dname "MISSINGNO." + dname "MISSINGNO." + dname "FARFETCH'D" + dname "VENONAT" + dname "DRAGONITE" + dname "MISSINGNO." + dname "MISSINGNO." + dname "MISSINGNO." + dname "DODUO" + dname "POLIWAG" + dname "JYNX" + dname "MOLTRES" + dname "ARTICUNO" + dname "ZAPDOS" + dname "DITTO" + dname "MEOWTH" + dname "KRABBY" + dname "MISSINGNO." + dname "MISSINGNO." + dname "MISSINGNO." + dname "VULPIX" + dname "NINETALES" + dname "PIKACHU" + dname "RAICHU" + dname "CHUNKY" + dname "MISSINGNO." + dname "DRATINI" + dname "DRAGONAIR" + dname "KABUTO" + dname "KABUTOPS" + dname "HORSEA" + dname "SEADRA" + dname "DRAGONAIR" + dname "MISSINGNO." + dname "SANDSHREW" + dname "SANDSLASH" + dname "OMANYTE" + dname "OMASTAR" + dname "JIGGLYPUFF" + dname "WIGGLYTUFF" + dname "EEVEE" + dname "FLAREON" + dname "JOLTEON" + dname "VAPOREON" + dname "MACHOP" + dname "ZUBAT" + dname "EKANS" + dname "PARAS" + dname "POLIWHIRL" + dname "POLIWRATH" + dname "WEEDLE" + dname "KAKUNA" + dname "BEEDRILL" + dname "PAINLESS" + dname "DODRIO" + dname "PRIMEAPE" + dname "DUGTRIO" + dname "VENOMOTH" + dname "DEWGONG" + dname "MISSINGNO." + dname "MISSINGNO." + dname "CATERPIE" + dname "METAPOD" + dname "BUTTERFREE" + dname "MACHAMP" + dname "MISSINGNO." + dname "GOLDUCK" + dname "HYPNO" + dname "GOLBAT" + dname "MEWTWO" + dname "SNORLAX" + dname "MAGIKARP" + dname "THE MAW" + dname "MISSINGNO." + dname "MUK" + dname "MISSINGNO." + dname "KINGLER" + dname "CLOYSTER" + dname "MISSINGNO." + dname "ELECTRODE" + dname "CLEFABLE" + dname "WEEZING" + dname "PERSIAN" + dname "MAROWAK" + dname "WEEZING" + dname "HAUNTER" + dname "ABRA" + dname "ALAKAZAM" + dname "PIDGEOTTO" + dname "PIDGEOT" + dname "STARMIE" + dname "BULBASAUR" + dname "VENUSAUR" + dname "TENTACRUEL" + dname "MISSINGNO." + dname "GOLDEEN" + dname "SEAKING" + dname "MISSINGNO." + dname "MISSINGNO." + dname "MISSINGNO." + dname "MISSINGNO." + dname "PONYTA" + dname "RAPIDASH" + dname "RATTATA" + dname "RATICATE" + dname "NIDORINO" + dname "NIDORINA" + dname "GEODUDE" + dname "PORYGON" + dname "AERODACTYL" + dname "ONIX" + dname "MAGNEMITE" + dname "MEWTWO" + dname "HAUNTER" + dname "CHARMANDER" + dname "SQUIRTLE" + dname "CHARMELEON" + dname "WARTORTLE" + dname "CHARIZARD" + dname "MISSINGNO." + dname "MISSINGNO." + dname "MISSINGNO." + dname "GHOST" + dname "ODDISH" + dname "GLOOM" + dname "VILEPLUME" + dname "BELLSPROUT" + dname "WEEPINBELL" + dname "VICTREEBEL" assert_table_length NUM_POKEMON_INDEXES diff --git a/data/predef_pointers.asm b/data/predef_pointers.asm index 0094b00166..2ee34c2ba6 100644 --- a/data/predef_pointers.asm +++ b/data/predef_pointers.asm @@ -53,7 +53,7 @@ PredefPointers:: add_predef UndoBurnParStats add_predef ShowPokedexMenu add_predef EvolutionAfterBattle - add_predef SaveSAVtoSRAM0 + add_predef SaveMainData add_predef InitOpponent add_predef CableClub_Run add_predef DrawBadges @@ -73,7 +73,7 @@ PredefPointers:: add_predef UsedCut add_predef ShowPokedexData add_predef WriteMonMoves - add_predef SaveSAV + add_predef SaveMenu add_predef LoadSGB add_predef MarkTownVisitedAndLoadMissableObjects add_predef SetPartyMonTypes @@ -90,10 +90,10 @@ PredefPointers:: add_predef SetAttackAnimPal add_predef AskName add_predef PewterGuys - add_predef SaveSAVtoSRAM2 - add_predef LoadSAV2 - add_predef LoadSAV - add_predef SaveSAVtoSRAM1 + add_predef SavePartyAndDexData + add_predef LoadPartyAndDexData + add_predef TryLoadSaveFile + add_predef SaveCurrentBoxData add_predef DoInGameTradeDialogue add_predef HallOfFamePC add_predef DisplayDexRating diff --git a/data/sprites/facings.asm b/data/sprites/facings.asm index 54fd7ed08e..1741f25957 100644 --- a/data/sprites/facings.asm +++ b/data/sprites/facings.asm @@ -53,7 +53,7 @@ SpriteFacingAndAnimationTable: .FlippedOAM: ; y, x, attributes - db 0, 8, OAM_HFLIP ; top left - db 0, 0, OAM_HFLIP ; top right - db 8, 8, OAM_HFLIP | UNDER_GRASS ; bottom left - db 8, 0, OAM_HFLIP | UNDER_GRASS | FACING_END ; bottom right + db 0, 8, OAM_XFLIP ; top left + db 0, 0, OAM_XFLIP ; top right + db 8, 8, OAM_XFLIP | UNDER_GRASS ; bottom left + db 8, 0, OAM_XFLIP | UNDER_GRASS | FACING_END ; bottom right diff --git a/data/tilesets/ledge_tiles.asm b/data/tilesets/ledge_tiles.asm index c853d485c6..9a7a1033d4 100644 --- a/data/tilesets/ledge_tiles.asm +++ b/data/tilesets/ledge_tiles.asm @@ -1,19 +1,19 @@ LedgeTiles: ; player direction, tile player standing on, ledge tile, input required - db SPRITE_FACING_DOWN, $2C, $37, D_DOWN - db SPRITE_FACING_DOWN, $39, $36, D_DOWN - db SPRITE_FACING_DOWN, $39, $37, D_DOWN - db SPRITE_FACING_LEFT, $2C, $27, D_LEFT - db SPRITE_FACING_LEFT, $39, $27, D_LEFT - db SPRITE_FACING_RIGHT, $2C, $0D, D_RIGHT - db SPRITE_FACING_RIGHT, $2C, $1D, D_RIGHT - db SPRITE_FACING_RIGHT, $39, $0D, D_RIGHT + db SPRITE_FACING_DOWN, $2C, $37, PAD_DOWN + db SPRITE_FACING_DOWN, $39, $36, PAD_DOWN + db SPRITE_FACING_DOWN, $39, $37, PAD_DOWN + db SPRITE_FACING_LEFT, $2C, $27, PAD_LEFT + db SPRITE_FACING_LEFT, $39, $27, PAD_LEFT + db SPRITE_FACING_RIGHT, $2C, $0D, PAD_RIGHT + db SPRITE_FACING_RIGHT, $2C, $1D, PAD_RIGHT + db SPRITE_FACING_RIGHT, $39, $0D, PAD_RIGHT db -1 ; end ; PureRGBnote: ADDED: in the volcano you can jump over specific new tiles like ledges. VolcanoLedgeTiles: ; player direction, ledge tile, input required - db SPRITE_FACING_DOWN, $41, D_DOWN - db SPRITE_FACING_RIGHT, $40, D_RIGHT - db SPRITE_FACING_LEFT, $30, D_LEFT + db SPRITE_FACING_DOWN, $41, PAD_DOWN + db SPRITE_FACING_RIGHT, $40, PAD_RIGHT + db SPRITE_FACING_LEFT, $30, PAD_LEFT db -1 diff --git a/data/trainers/move_choices.asm b/data/trainers/move_choices.asm index 27e85bad02..bfcd7d82bc 100644 --- a/data/trainers/move_choices.asm +++ b/data/trainers/move_choices.asm @@ -1,16 +1,16 @@ ; PureRGBnote: CHANGED: some trainers have added AI types. Mainly AI type 3 is more widely used. +DEF __move_choices__ = 0 MACRO move_choices IF _NARG db \# ; all args ENDC db 0 ; end - DEF list_index += 1 + DEF __move_choices__ += 1 ENDM ; move choice modification methods that are applied for each trainer class TrainerClassMoveChoiceModifications: - list_start move_choices ; YOUNGSTER move_choices 1 ; BUG CATCHER move_choices 1 ; LASS @@ -64,7 +64,8 @@ TrainerClassMoveChoiceModifications: move_choices 1, 3 ; SOLDIER move_choices 1, 3, 4 ; CHIEF move_choices 1, 3, 4 ; GYM_GUIDE - assert_list_length NUM_TRAINERS + assert __move_choices__ == NUM_TRAINERS, \ + "TrainerClassMoveChoiceModifications: expected {d:NUM_TRAINERS} entries, got {d:__move_choices__}" ChampArenaGenericMoveChoices: - move_choices 1, 2, 3, 4 ; PureRGBnote: ADDED: used to make all the champ arena challengers have strong AI without changing their initial encounter ones. \ No newline at end of file + move_choices 1, 2, 3, 4 ; PureRGBnote: ADDED: used to make all the champ arena challengers have strong AI without changing their initial encounter ones. diff --git a/data/trainers/names.asm b/data/trainers/names.asm index 095302e0da..ba030c8068 100644 --- a/data/trainers/names.asm +++ b/data/trainers/names.asm @@ -1,5 +1,5 @@ TrainerNames:: - list_start + list_start TRAINER_NAME_LENGTH - 1 li "YOUNGSTER" li "BUG CATCHER" li "LASS" diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm index 2bf977f0b7..566e8c5bcb 100644 --- a/engine/battle/animations.asm +++ b/engine/battle/animations.asm @@ -27,7 +27,7 @@ DrawFrameBlock: jp z, .flipHorizontalTranslateDown ; SUBANIMTYPE_HFLIP dec a jr z, .flipBaseCoords ; SUBANIMTYPE_COORDFLIP -.noTransformation +; no transformation ld a, [wBaseCoordY] add [hl] ld [de], a ; store Y @@ -98,13 +98,13 @@ DrawFrameBlock: ; toggle horizontal and vertical flip ld a, [hli] ; flags and a - ld b, OAM_VFLIP | OAM_HFLIP + ld b, OAM_YFLIP | OAM_XFLIP jr z, .storeFlags1 - cp OAM_HFLIP - ld b, OAM_VFLIP + cp OAM_XFLIP + ld b, OAM_YFLIP jr z, .storeFlags1 - cp OAM_VFLIP - ld b, OAM_HFLIP + cp OAM_YFLIP + ld b, OAM_XFLIP jr z, .storeFlags1 ld b, 0 .storeFlags1 @@ -141,13 +141,13 @@ DrawFrameBlock: ld [de], a ; store tile ID inc de ld a, [hli] - bit OAM_X_FLIP, a + bit B_OAM_XFLIP, a jr nz, .disableHorizontalFlip .enableHorizontalFlip - set OAM_X_FLIP, a + set B_OAM_XFLIP, a jr .storeFlags2 .disableHorizontalFlip - res OAM_X_FLIP, a + res B_OAM_XFLIP, a .storeFlags2 ;;;;;;;;;; shinpokerednote: gbcnote: oam updates from yellow version ld b, a @@ -162,7 +162,7 @@ DrawFrameBlock: ld a, [wNumFBTiles] cp c jp nz, .loop ; go back up if there are more tiles to draw -.afterDrawingTiles +; after drawing tiles ld a, [wFBMode] cp FRAMEBLOCKMODE_02 jr z, .advanceFrameBlockDestAddr ; skip delay and don't clean OAM buffer @@ -216,7 +216,7 @@ PlayAnimation: ret z cp FIRST_SE_ID ; is this subanimation or a special effect? jr c, .playSubanimation -.doSpecialEffect +; do Special Effect ld c, a ld de, SpecialEffectPointers .searchSpecialEffectTableLoop @@ -331,11 +331,11 @@ LoadSubanimation: and %11100000 cp SUBANIMTYPE_ENEMY << 5 vc_hook_blue Reduce_move_anim_flashing_Blizzard - jr nz, .isNotType5 -.isType5 + jr nz, .isNotTypeEnemy +; subanim type enemy call GetSubanimationTransform2 jr .saveTransformation -.isNotType5 +.isNotTypeEnemy vc_hook Reduce_move_anim_flashing_Hyper_Beam call GetSubanimationTransform1 .saveTransformation @@ -477,11 +477,11 @@ MoveAnimationContent: call PlayAnimation vc_hook_red Stop_reducing_move_anim_flashing_Bubblebeam_Mega_Kick vc_hook_blue Stop_reducing_move_anim_flashing_Spore - jr .next4 + jr .next .animationsDisabled ld c, 30 rst _DelayFrames -.next4 +.next vc_hook_red Stop_reducing_move_anim_flashing vc_hook_blue Stop_reducing_move_anim_flashing_Rock_Slide_Dream_Eater call PlayApplyingAttackAnimation ; shake the screen or flash the pic in and out (to show damage) @@ -809,7 +809,7 @@ DoBallTossSpecialEffects: dec b jr nz, .loop ld a, %00001000 - ldh [rNR10], a ; Channel 1 sweep register + ldh [rAUD1SWEEP], a ; Channel 1 sweep register ret .isTrainerBattle ; if it's a trainer battle, shorten the animation by one frame ld a, [wSubAnimCounter] @@ -1133,7 +1133,7 @@ BallMoveDistances2: DoGrowlSpecialEffects: ld hl, wShadowOAM ld de, wShadowOAMSprite04 - ld bc, $10 + ld bc, OBJ_SIZE * 4 rst _CopyData ; copy the musical note graphic ld a, [wSubAnimCounter] dec a @@ -1336,7 +1336,9 @@ SetAnimationBGPalette: ldh [rBGP], a jp UpdateGBCPal_BGP ; shinpokerednote: gbcnote: gbc color facilitation - ;ld b, $5 ; unused label? +AnimationUnusedShakeScreen: ; unreferenced +; Shakes the screen for a while. + ;ld b, $5 AnimationShakeScreenVertically: predef_jump PredefShakeScreenVertically @@ -1519,12 +1521,12 @@ _AnimationSlideMonUp: push bc ; In each iteration, slide up all rows but the top one (which is overwritten). - ld b, 6 + ld b, PIC_HEIGHT - 1 .slideLoop push bc push de push hl - ld bc, 7 + ld bc, PIC_WIDTH rst _CopyData ; Note that de and hl are popped in the same order they are pushed, swapping ; their values. When CopyData is called, hl points to a tile 1 row below @@ -1548,10 +1550,10 @@ _AnimationSlideMonUp: ld a, [wSlideMonUpBottomRowLeftTile] inc a ld [wSlideMonUpBottomRowLeftTile], a - ld c, 7 + ld c, PIC_WIDTH .fillBottomRowLoop ld [hli], a - add 7 + add PIC_WIDTH dec c jr nz, .fillBottomRowLoop @@ -1653,7 +1655,7 @@ AdjustOAMBlockXPos: ld h, d AdjustOAMBlockXPos2: - ld de, 4 + ld de, OBJ_SIZE .loop ld a, [wCoordAdjustmentAmount] ld b, a @@ -1663,7 +1665,7 @@ AdjustOAMBlockXPos2: jr c, .skipPuttingEntryOffScreen ; put off-screen if X >= 168 dec hl - ld a, 160 + ld a, SCREEN_HEIGHT_PX + OAM_Y_OFS ld [hli], a .skipPuttingEntryOffScreen ld [hl], a @@ -1677,7 +1679,7 @@ AdjustOAMBlockYPos: ld h, d AdjustOAMBlockYPos2: - ld de, 4 + ld de, OBJ_SIZE .loop ld a, [wCoordAdjustmentAmount] ld b, a @@ -2064,7 +2066,7 @@ _AnimationSquishMonPic: call AnimCopyRowRight inc hl .next - ld [hl], " " + ld [hl], ' ' pop hl ld de, SCREEN_WIDTH add hl, de @@ -2132,7 +2134,7 @@ _AnimationShootBallsUpward: dec a ld [wNumShootingBalls], a .next - ld de, 4 + ld de, OBJ_SIZE add hl, de ; next OAM entry dec b jr nz, .innerLoop @@ -2194,10 +2196,10 @@ AnimationMinimizeMon: ld hl, wTempPic push hl xor a - ld bc, 7 * 7 * $10 + ld bc, PIC_SIZE tiles call FillMemory pop hl - ld de, 7 * 3 * $10 + 4 * $10 + 4 + ld de, (PIC_WIDTH * 3 + 4) tiles + TILE_SIZE / 4 add hl, de ld de, MinimizedMonSprite ld c, MinimizedMonSpriteEnd - MinimizedMonSprite @@ -2314,7 +2316,7 @@ _AnimationSlideMonOff: ; plus one instead. cp $62 ; PureRGBnote: CHANGED: now it's plus one as the above comment indicates ret c - ld a, " " + ld a, ' ' ret .EnemyNextTile @@ -2324,7 +2326,7 @@ _AnimationSlideMonOff: ; the lower right tile is in the first column to slide off the screen. cp $30 ret c - ld a, " " + ld a, ' ' ret ;;;;;;;;;; PureRGBnote: ADDED: new animation used in some moves like Filthy Slam. @@ -2350,7 +2352,7 @@ CopyTempPicToMonPic: ld hl, vFrontPic ; enemy turn .next ld de, wTempPic - ld bc, 7 * 7 + ld bc, PIC_SIZE jp CopyVideoData AnimationWavyScreen:: @@ -2428,7 +2430,7 @@ AnimationSubstitute: ; Changes the pokemon's sprite to the mini sprite ld hl, wTempPic xor a - ld bc, 7 * 7 tiles + ld bc, PIC_SIZE tiles call FillMemory ldh a, [hWhoseTurn] and a @@ -2464,7 +2466,7 @@ AnimationSubstitute: jp AnimationShowMonPic CopyMonsterSpriteData: - ld bc, 1 tiles + ld bc, TILE_SIZE ld a, BANK(MonsterSprite) jp FarCopyData2 @@ -2876,7 +2878,7 @@ FallingObjects_UpdateOAMEntry: inc a cp 112 jr c, .next - ld a, 160 ; if Y >= 112, put it off-screen + ld a, SCREEN_HEIGHT_PX + OAM_Y_OFS ; if Y >= 112, put it off-screen .next ld [hli], a ; Y ;;;;;;;;;; shinpokerednote: gbcnote: oam updates from pokemon yellow @@ -2931,7 +2933,7 @@ FallingObjects_UpdateOAMEntry: .asm_79e5c ;;;;;;;;;; inc hl - ld a, 1 << OAM_X_FLIP + ld a, OAM_XFLIP .next2 ;;;;;;;;;; shinpokerednote: gbcnote: oam updates from pokemon yellow ld b, a @@ -3001,7 +3003,7 @@ AnimationShakeEnemyHUD: ; Make a copy of the back pic's tile patterns in sprite tile pattern VRAM. ld de, vBackPic ld hl, vSprites - ld bc, 7 * 7 + ld bc, PIC_SIZE call CopyVideoData xor a diff --git a/engine/battle/battle_transitions.asm b/engine/battle/battle_transitions.asm index 58da69b402..7bad094ebb 100644 --- a/engine/battle/battle_transitions.asm +++ b/engine/battle/battle_transitions.asm @@ -14,7 +14,7 @@ BattleTransition: ldh a, [hSpriteIndex] ; enemy trainer sprite index (0 if wild battle) ld c, a ld b, 0 - ld de, $10 + ld de, SPRITESTATEDATA1_LENGTH .loop1 ld a, [hl] cp $ff @@ -35,13 +35,13 @@ BattleTransition: jr z, .skip2 ; skip clearing the block if the enemy trainer is using it push hl push bc - ld bc, $10 + ld bc, OBJ_SIZE * 4 xor a call FillMemory pop bc pop hl .skip2 - ld de, $10 + ld de, OBJ_SIZE * 4 add hl, de dec c jr nz, .loop2 @@ -104,11 +104,11 @@ GetBattleTransitionID_CompareLevels: ld a, [hli] or [hl] jr nz, .notFainted - ld de, wPartyMon2 - (wPartyMon1 + 1) + ld de, PARTYMON_STRUCT_LENGTH - 1 add hl, de jr .faintedLoop .notFainted - ld de, wPartyMon1Level - (wPartyMon1HP + 1) + ld de, MON_LEVEL - (MON_HP + 1) add hl, de ld a, [hl] add $3 diff --git a/engine/battle/core.asm b/engine/battle/core.asm index b615ea2719..a5a17923e0 100644 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -19,9 +19,9 @@ SlidePlayerAndEnemySilhouettesOnScreen: call LoadFontTilePatterns call LoadHudAndHpBarAndStatusTilePatterns ld hl, vBGMap0 - ld bc, BG_MAP_WIDTH * BG_MAP_HEIGHT + ld bc, TILEMAP_AREA .clearBackgroundLoop - ld a, " " + ld a, ' ' ld [hli], a dec bc ld a, b @@ -140,8 +140,8 @@ SlidePlayerAndEnemySilhouettesOnScreen: SlidePlayerHeadLeft: push bc ld hl, wShadowOAMSprite00XCoord - ld c, $15 ; number of OAM entries - ld de, $4 ; size of OAM entry + ld c, 7 * 3 ; number of OAM entries + ld de, OBJ_SIZE .loop dec [hl] ; decrement X dec [hl] ; decrement X @@ -168,7 +168,7 @@ StartBattle: inc a ld [wFirstMonsNotOutYet], a ld hl, wEnemyMon1HP - ld bc, wEnemyMon2 - wEnemyMon1 - 1 + ld bc, PARTYMON_STRUCT_LENGTH - 1 ld d, $3 .findFirstAliveEnemyMonLoop inc d @@ -358,7 +358,7 @@ MainInBattleLoop: bit USING_TRAPPING_MOVE, a ; check if enemy is using a multi-turn attack like wrap jr z, .selectPlayerMove ; if not, jump ; enemy is using a multi-turn attack like wrap, so player is trapped and cannot execute a move - ld a, $ff + ld a, CANNOT_MOVE ld [wPlayerSelectedMove], a jr .selectEnemyMove .selectPlayerMove @@ -796,7 +796,7 @@ FaintEnemyPokemon: jr z, .wild ld a, [wEnemyMonPartyPos] ld hl, wEnemyMon1HP - ld bc, wEnemyMon2 - wEnemyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes xor a ld [hli], a @@ -942,7 +942,7 @@ AnyEnemyPokemonAliveCheck: ld b, a xor a ld hl, wEnemyMon1HP - ld de, wEnemyMon2 - wEnemyMon1 + ld de, PARTYMON_STRUCT_LENGTH .nextPokemon or [hl] inc hl @@ -1326,17 +1326,17 @@ SlideDownFaintedMonPic: push af set BIT_NO_TEXT_DELAY, a ld [wStatusFlags5], a - ld b, 7 ; number of times to slide + ld b, PIC_HEIGHT ; number of times to slide .slideStepLoop ; each iteration, the mon is slid down one row push bc push de push hl - ld b, 6 ; number of rows + ld b, PIC_HEIGHT - 1 ; number of rows .rowLoop push bc push hl push de - ld bc, $7 + ld bc, PIC_WIDTH rst _CopyData pop de pop hl @@ -1368,7 +1368,8 @@ SlideDownFaintedMonPic: ret SevenSpacesText: - db " @" + ds PIC_WIDTH, ' ' + db "@" ; slides the player or enemy trainer off screen ; a is the number of tiles to slide it horizontally (always 9 for the player trainer or 8 for the enemy trainer) @@ -1380,7 +1381,7 @@ SlideTrainerPicOffScreen: .slideStepLoop ; each iteration, the trainer pic is slid one tile left/right push bc push hl - ld b, 7 ; number of rows + ld b, PIC_HEIGHT ; number of rows .rowLoop push hl ldh a, [hSlideAmount] @@ -1389,7 +1390,7 @@ SlideTrainerPicOffScreen: ldh a, [hSlideAmount] cp 8 jr z, .slideRight -.slideLeft ; slide player sprite off screen +; slide player sprite left off screen ld a, [hld] ld [hli], a inc hl @@ -1472,7 +1473,7 @@ EnemySendOutFirstMon: ld a, b ld [wWhichPokemon], a push bc - ld bc, wEnemyMon2 - wEnemyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes pop bc inc hl @@ -1484,7 +1485,7 @@ EnemySendOutFirstMon: .next3 ld a, [wWhichPokemon] ld hl, wEnemyMon1Level - ld bc, wEnemyMon2 - wEnemyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld a, [hl] ld [wCurEnemyLevel], a @@ -1603,7 +1604,7 @@ AnyPartyAlive:: ld e, a xor a ld hl, wPartyMon1HP - ld bc, wPartyMon2 - wPartyMon1 - 1 + ld bc, PARTYMON_STRUCT_LENGTH - 1 .partyMonsLoop or [hl] inc hl @@ -1619,7 +1620,7 @@ AnyPartyAlive:: HasMonFainted: ld a, [wWhichPokemon] ld hl, wPartyMon1HP - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld a, [hli] or [hl] @@ -1785,16 +1786,16 @@ GotAwayText: ; copies from party data to battle mon data when sending out a new player mon LoadBattleMonFromParty: ld a, [wWhichPokemon] - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH ld hl, wPartyMon1Species call AddNTimes ld de, wBattleMonSpecies ld bc, wBattleMonDVs - wBattleMonSpecies rst _CopyData - ld bc, wPartyMon1DVs - wPartyMon1OTID + ld bc, MON_DVS - MON_OTID add hl, bc ld de, wBattleMonDVs - ld bc, wPartyMon1PP - wPartyMon1DVs + ld bc, MON_PP - MON_DVS rst _CopyData ld de, wBattleMonPP ld bc, NUM_MOVES @@ -1834,16 +1835,16 @@ LoadBattleMonFromParty: ; copies from enemy party data to current enemy mon data when sending out a new enemy mon LoadEnemyMonFromParty: ld a, [wWhichPokemon] - ld bc, wEnemyMon2 - wEnemyMon1 + ld bc, PARTYMON_STRUCT_LENGTH ld hl, wEnemyMons call AddNTimes ld de, wEnemyMonSpecies ld bc, wEnemyMonDVs - wEnemyMonSpecies rst _CopyData - ld bc, wEnemyMon1DVs - wEnemyMon1OTID + ld bc, MON_DVS - MON_OTID add hl, bc ld de, wEnemyMonDVs - ld bc, wEnemyMon1PP - wEnemyMon1DVs + ld bc, MON_PP - MON_DVS rst _CopyData ld de, wEnemyMonPP ld bc, NUM_MOVES @@ -1964,12 +1965,12 @@ AnimateRetreatingPlayerMon: ReadPlayerMonCurHPAndStatus: ld a, [wPlayerMonNumber] ld hl, wPartyMon1HP - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld d, h ld e, l ld hl, wBattleMonHP - ld bc, $4 ; 2 bytes HP, 1 byte unknown (unused?), 1 byte status + ld bc, MON_STATUS + 1 - MON_HP ; also copies party pos in-between HP and status rst _CopyData ret @@ -2155,11 +2156,11 @@ CenterMonName: .loop inc de ld a, [de] - cp "@" + cp '@' jr z, .done inc de ld a, [de] - cp "@" + cp '@' jr z, .done dec hl dec b @@ -2207,15 +2208,15 @@ DisplayBattleMenu:: rst _CopyData ; the following simulates the keystrokes by drawing menus on screen hlcoord 9, 14 - ld [hl], "▶" + ld [hl], '▶' ld c, 80 rst _DelayFrames - ld [hl], " " + ld [hl], ' ' hlcoord 9, 16 - ld [hl], "▶" + ld [hl], '▶' ld c, 50 rst _DelayFrames - ld [hl], "▷" + ld [hl], '▷' ld a, $2 ; select the "ITEM" menu jp .upperLeftMenuItemWasNotSelected .oldManName @@ -2233,7 +2234,7 @@ DisplayBattleMenu:: .leftColumn ; put cursor in left column of menu ld a, [wBattleType] cp BATTLE_TYPE_SAFARI - ld a, " " + ld a, ' ' jr z, .safariLeftColumn ; put cursor in left column for normal battle menu (i.e. when it's not a Safari battle) ldcoord_a 15, 14 ; clear upper cursor position in right column @@ -2258,14 +2259,14 @@ DisplayBattleMenu:: inc hl ld a, $1 ld [hli], a ; wMaxMenuItem - ld [hl], D_RIGHT | A_BUTTON ; wMenuWatchedKeys + ld [hl], PAD_RIGHT | PAD_A ; wMenuWatchedKeys call HandleMenuInput - bit BIT_D_RIGHT, a + bit B_PAD_RIGHT, a jr z, .AButtonPressed ; the A button was pressed .rightColumn ; put cursor in right column of menu ld a, [wBattleType] cp BATTLE_TYPE_SAFARI - ld a, " " + ld a, ' ' jr z, .safariRightColumn ; put cursor in right column for normal battle menu (i.e. when it's not a Safari battle) ldcoord_a 9, 14 ; clear upper cursor position in left column @@ -2290,10 +2291,10 @@ DisplayBattleMenu:: inc hl ld a, $1 ld [hli], a ; wMaxMenuItem - ld a, D_LEFT | A_BUTTON + ld a, PAD_LEFT | PAD_A ld [hli], a ; wMenuWatchedKeys call HandleMenuInput - bit BIT_D_LEFT, a + bit B_PAD_LEFT, a jr nz, .leftColumn ; if left was pressed, jump ld a, [wCurrentMenuItem] add $2 ; if we're in the right column, the actual id is +2 @@ -2510,7 +2511,7 @@ PartyMenuOrRockOrRun: .partyMonDeselected hlcoord 11, 11 ld bc, 6 * SCREEN_WIDTH + 9 - ld a, " " + ld a, ' ' call FillMemory xor a ; NORMAL_PARTY_MENU ld [wPartyMenuTypeOrMessageID], a @@ -2529,12 +2530,12 @@ PartyMenuOrRockOrRun: inc hl ld a, $2 ld [hli], a ; wMaxMenuItem - ld a, B_BUTTON | A_BUTTON + ld a, PAD_B | PAD_A ld [hli], a ; wMenuWatchedKeys xor a ld [hl], a ; wLastMenuItem call HandleMenuInput - bit BIT_B_BUTTON, a + bit B_PAD_B, a jr nz, .partyMonDeselected ; if B was pressed, jump ; A was pressed call PlaceUnfilledArrowMenuCursor @@ -2672,9 +2673,9 @@ MoveSelectionMenu: ; so it is necessary to put the di ei block to not cause tearing call TextBoxBorder hlcoord 4, 12 - ld [hl], "─" + ld [hl], '─' hlcoord 10, 12 - ld [hl], "┘" + ld [hl], '┘' ei hlcoord 6, 13 call .writemoves @@ -2695,7 +2696,7 @@ MoveSelectionMenu: .relearnmenu ld a, [wWhichPokemon] ld hl, wPartyMon1Moves - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes call .loadmoves hlcoord 4, 7 @@ -2726,10 +2727,10 @@ MoveSelectionMenu: ld [hli], a ; wMaxMenuItem ld a, [wMoveMenuType] dec a - ld b, D_UP | D_DOWN | A_BUTTON + ld b, PAD_UP | PAD_DOWN | PAD_A jr z, .matchedkeyspicked dec a - ld b, D_UP | D_DOWN | A_BUTTON | B_BUTTON + ld b, PAD_UP | PAD_DOWN | PAD_A | PAD_B jr z, .matchedkeyspicked ld a, [wLinkState] cp LINK_STATE_BATTLING @@ -2737,9 +2738,9 @@ MoveSelectionMenu: ; Disable left, right, and START buttons in regular battles. ld a, [wStatusFlags7] bit BIT_TEST_BATTLE, a - ld b, D_UP | D_DOWN | A_BUTTON | B_BUTTON | SELECT + ld b, ~(PAD_LEFT | PAD_RIGHT | PAD_START) jr z, .matchedkeyspicked - ld b, D_UP | D_DOWN | D_LEFT | D_RIGHT | A_BUTTON | B_BUTTON | SELECT | START + ld b, PAD_CTRL_PAD | PAD_BUTTONS .matchedkeyspicked ld a, b ld [hli], a ; wMenuWatchedKeys @@ -2784,20 +2785,20 @@ SelectMenuItem: dec a ld bc, SCREEN_WIDTH call AddNTimes - ld [hl], "▷" + ld [hl], '▷' .select ld hl, hUILayoutFlags set BIT_DOUBLE_SPACED_MENU, [hl] call HandleMenuInput ld hl, hUILayoutFlags res BIT_DOUBLE_SPACED_MENU, [hl] - bit BIT_D_UP, a + bit B_PAD_UP, a jp nz, SelectMenuItem_CursorUp - bit BIT_D_DOWN, a + bit B_PAD_DOWN, a jp nz, SelectMenuItem_CursorDown - bit BIT_SELECT, a + bit B_PAD_SELECT, a jp nz, SwapMovesInMenu - bit BIT_B_BUTTON, a + bit B_PAD_B, a push af xor a ld [wMenuItemToSwap], a @@ -2995,12 +2996,12 @@ SwapMovesInMenu: .swapMovesInPartyMon ld hl, wPartyMon1Moves ld a, [wPlayerMonNumber] - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes push hl call .swapBytes ; swap moves pop hl - ld bc, wPartyMon1PP - wPartyMon1Moves + ld bc, MON_PP - MON_MOVES add hl, bc call .swapBytes ; swap move PP xor a @@ -3083,9 +3084,9 @@ PrintMenuItem: ld de, TypeText call PlaceString hlcoord 7, 11 - ld [hl], "/" + ld [hl], '/' hlcoord 5, 9 - ld [hl], "/" + ld [hl], '/' hlcoord 5, 11 ld de, wBattleMenuCurrentPP lb bc, 1, 2 @@ -3215,7 +3216,7 @@ SelectEnemyMove: pop hl ;jr z, .chooseRandomMove ; move disabled, try again ;and a - ;jr z, .chooseRandomMove ; move non-existant, try again + ;jr z, .chooseRandomMove ; move non-existent, try again jr z, .chooseRandomMoveAgain ; move not available, try again pop de .done @@ -3241,7 +3242,8 @@ LinkBattleExchangeData: ld b, LINKBATTLE_STRUGGLE jr z, .next dec b ; LINKBATTLE_NO_ACTION - inc a ; does move equal -1 (i.e. no action)? + ASSERT CANNOT_MOVE == $ff + inc a jr z, .next ld a, [wPlayerMoveListIndex] jr .doExchange @@ -3294,8 +3296,9 @@ ExecutePlayerMove: xor a ldh [hWhoseTurn], a ; set player's turn ld a, [wPlayerSelectedMove] + ASSERT CANNOT_MOVE == $ff inc a - jp z, ExecutePlayerMoveDone ; for selected move = FF, skip most of player's turn + jp z, ExecutePlayerMoveDone ; if the player cannot move, skip most of their turn xor a ld [wMoveMissed], a ld [wMonIsDisobedient], a @@ -3368,35 +3371,35 @@ PlayerCalcMoveDamage: jp c, .moveHitTest ; SetDamageEffects moves (e.g. Seismic Toss and Super Fang) skip damage calculation call CriticalHitTest ;call HandleCounterMove ; PureRGBnote: CHANGED: Counter changed to have an effect similar to drain punch, so dont need this code - ;jr z, handleIfPlayerMoveMissed + ;jr z, HandleIfPlayerMoveMissed call GetDamageVarsForPlayerAttack call CalculateDamage - jp z, playerCheckIfFlyOrChargeEffect ; for moves with 0 BP, skip any further damage calculation and, for now, skip MoveHitTest + jp z, PlayerCheckIfFlyOrChargeEffect ; for moves with 0 BP, skip any further damage calculation and, for now, skip MoveHitTest ; for these moves, accuracy tests will only occur if they are called as part of the effect itself call AdjustDamageForMoveType call RandomizeDamage .moveHitTest call MoveHitTest -handleIfPlayerMoveMissed: +HandleIfPlayerMoveMissed: ld a, [wMoveMissed] and a - jr z, getPlayerAnimationType + jr z, GetPlayerAnimationType ld a, [wPlayerMoveEffect] cp EXPLODE_EFFECT ; don't play any animation if the move missed, unless it was EXPLODE_EFFECT jr z, .explodeAnimation cp EXPLODE_RECOIL_EFFECT ; PureRGBnote: ADDED: when using explosion at higher health, this effect is now used. (Makes sure it plays even if you miss.) jr z, .explodeAnimation - jr playerCheckIfFlyOrChargeEffect + jr PlayerCheckIfFlyOrChargeEffect .explodeAnimation xor a - jr playPlayerMoveAnimation -getPlayerAnimationType: + jr PlayPlayerMoveAnimation +GetPlayerAnimationType: ld a, [wPlayerMoveEffect] and a ld a, ANIMATIONTYPE_BLINK_ENEMY_MON_SPRITE ; move has no effect other than dealing damage - jr z, playPlayerMoveAnimation + jr z, PlayPlayerMoveAnimation ld a, ANIMATIONTYPE_SHAKE_SCREEN_HORIZONTALLY_LIGHT ; move has effect -playPlayerMoveAnimation: +PlayPlayerMoveAnimation: push af ld a, [wPlayerBattleStatus2] bit HAS_SUBSTITUTE_UP, a @@ -3419,7 +3422,7 @@ playPlayerMoveAnimation: ld b, BANK(ReshowSubstituteAnim) call nz, Bankswitch jr MirrorMoveCheck -playerCheckIfFlyOrChargeEffect: +PlayerCheckIfFlyOrChargeEffect: ld c, 30 rst _DelayFrames ld a, [wPlayerMoveEffect] @@ -3491,7 +3494,7 @@ MirrorMoveCheck: ld a, [wPlayerNumAttacksLeft] dec a ld [wPlayerNumAttacksLeft], a - jp nz, getPlayerAnimationType ; for multi-hit moves, apply attack until PlayerNumAttacksLeft hits 0 or the enemy faints. + jp nz, GetPlayerAnimationType ; for multi-hit moves, apply attack until PlayerNumAttacksLeft hits 0 or the enemy faints. ; damage calculation and accuracy tests only happen for the first hit res ATTACKING_MULTIPLE_TIMES, [hl] ; clear attacking multiple times status when all attacks are over ld hl, MultiHitText @@ -3694,7 +3697,7 @@ CheckPlayerStatusConditions: bit PAR, [hl] jr z, .BideCheck call BattleRandom - cp $3F ; 25% to be fully paralyzed + cp 25 percent ; chance to be fully paralyzed jr nc, .BideCheck ld hl, FullyParalyzedText rst _PrintText @@ -3729,7 +3732,8 @@ CheckPlayerStatusConditions: .BideCheck ld hl, wPlayerBattleStatus1 - ; jr .ThrashingAboutCheck ; PureRGBnote: CHANGED: bide effect was changed so this whole block isn't needed now + ; PureRGBnote: CHANGED: bide effect was changed so this whole block isn't needed now + ;jr .ThrashingAboutCheck ;bit STORING_ENERGY, [hl] ; is mon using bide? ;jr z, .ThrashingAboutCheck ;xor a @@ -3775,7 +3779,7 @@ CheckPlayerStatusConditions: ; ld [hl], a ; ld a, BIDE ; ld [wPlayerMoveNum], a -; ld hl, handleIfPlayerMoveMissed ; skip damage calculation, DecrementPP and MoveHitTest +; ld hl, HandleIfPlayerMoveMissed ; skip damage calculation, DecrementPP and MoveHitTest ; jp .returnToHL .ThrashingAboutCheck @@ -3808,7 +3812,7 @@ CheckPlayerStatusConditions: rst _PrintText ld hl, wPlayerNumAttacksLeft dec [hl] ; did multi-turn move end? - ld hl, getPlayerAnimationType ; if it didn't, skip damage calculation (deal damage equal to last hit), + ld hl, GetPlayerAnimationType ; if it didn't, skip damage calculation (deal damage equal to last hit), ; DecrementPP and MoveHitTest ; jp nz, .returnToHL ; PureRGBnote: Rage effect was changed, don't need this code ; jp .returnToHL @@ -3875,7 +3879,7 @@ ConfusedNoMoreText: text_far _ConfusedNoMoreText text_end -SavingEnergyText: +SavingEnergyText: ; unreferenced text_far _SavingEnergyText text_end @@ -4117,7 +4121,7 @@ CheckForDisobedience: ; compare the mon's original trainer ID with the player's ID to see if it was traded .checkIfMonIsTraded ld hl, wPartyMon1OTID - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH ld a, [wPlayerMonNumber] call AddNTimes ld a, [wPlayerID] @@ -4368,7 +4372,7 @@ GetDamageVarsForPlayerAttack: push bc ld hl, wPartyMon1Attack ld a, [wPlayerMonNumber] - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes pop bc jr .scaleStats @@ -4401,7 +4405,7 @@ GetDamageVarsForPlayerAttack: push bc ld hl, wPartyMon1Special ld a, [wPlayerMonNumber] - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes pop bc ; if either the offensive or defensive stat is too large to store in a byte, scale both stats by dividing them by 4 @@ -4488,7 +4492,7 @@ GetDamageVarsForEnemyAttack: ; in the case of a critical hit, reset the player's defense and the enemy's attack to their base values ld hl, wPartyMon1Defense ld a, [wPlayerMonNumber] - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld a, [hli] ld b, a @@ -4521,7 +4525,7 @@ GetDamageVarsForEnemyAttack: ; in the case of a critical hit, reset the player's and enemy's specials to their base values ld hl, wPartyMon1Special ld a, [wPlayerMonNumber] - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld a, [hli] ld b, a @@ -4583,7 +4587,7 @@ GetEnemyMonStat: ld b, $0 add hl, bc ld a, [wEnemyMonPartyPos] - ld bc, wEnemyMon2 - wEnemyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld a, [hli] ldh [hMultiplicand + 1], a @@ -4682,7 +4686,7 @@ CalculateDamage: ; Divide by 5 ld a, 5 - ldd [hl], a + ld [hld], a push bc ld b, 4 call Divide @@ -4923,7 +4927,7 @@ INCLUDE "data/battle/critical_hit_moves.asm" ; if it did damage, double it ; ld a, [hl] ; add a -; ldd [hl], a +; ld [hld], a ; ld a, [hl] ; adc a ; ld [hl], a @@ -5247,7 +5251,7 @@ SubstituteBrokeText: ; call StatModifierUpEffect ; stat modifier raising function ; pop hl ; xor a -; ldd [hl], a ; null move effect +; ld [hld], a ; null move effect ; ld a, RAGE ; ld [hl], a ; restore the target pokemon's move number to Rage ; ldh a, [hWhoseTurn] @@ -5404,7 +5408,7 @@ IncrementMovePP: jr z, .updatePP ld a, [wEnemyMonPartyPos] ; value for enemy turn .updatePP - ld bc, wEnemyMon2 - wEnemyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes inc [hl] ; increment PP in the party memory location ret @@ -5795,7 +5799,7 @@ MoveHitTest: ldh a, [hWhoseTurn] and a jr nz, .enemyTurn -.playerTurn +; player's turn ; this checks if the move effect is disallowed by mist ld a, [wEnemyBattleStatus2] bit STAT_DOWN_IMMUNITY, a ; is mon protected by mist? @@ -5853,12 +5857,12 @@ MoveHitTest: ld [wMoveMissed], a ldh a, [hWhoseTurn] and a - jr z, .playerTurn2 -.enemyTurn2 + jr z, .playerTurn +; enemy's turn ld hl, wEnemyBattleStatus1 res USING_TRAPPING_MOVE, [hl] ; end multi-turn attack e.g. wrap ret -.playerTurn2 +.playerTurn ld hl, wPlayerBattleStatus1 res USING_TRAPPING_MOVE, [hl] ; end multi-turn attack e.g. wrap ret @@ -5961,7 +5965,7 @@ RandomizeDamage: .loop call BattleRandom rrca - cp 217 + cp 85 percent + 1 jr c, .loop ldh [hMultiplier], a call Multiply ; multiply damage by the random number, which is in the range [217, 255] @@ -5980,6 +5984,7 @@ RandomizeDamage: ; for more detailed commentary, see equivalent function for player side (ExecutePlayerMove) ExecuteEnemyMove: ld a, [wEnemySelectedMove] + ASSERT CANNOT_MOVE == $ff inc a jp z, ExecuteEnemyMoveDone call PrintGhostText @@ -6060,7 +6065,7 @@ EnemyCalcMoveDamage: jp c, EnemyMoveHitTest call CriticalHitTest ;call HandleCounterMove ; PureRGBnote: CHANGED: counter changed to have an effect similar to drain punch - ;jr z, handleIfEnemyMoveMissed + ;jr z, HandleIfEnemyMoveMissed call SwapPlayerAndEnemyLevels call GetDamageVarsForEnemyAttack call SwapPlayerAndEnemyLevels @@ -6071,15 +6076,15 @@ EnemyCalcMoveDamage: EnemyMoveHitTest: call MoveHitTest -handleIfEnemyMoveMissed: +HandleIfEnemyMoveMissed: ld a, [wMoveMissed] and a jr z, .moveDidNotMiss ld a, [wEnemyMoveEffect] cp EXPLODE_EFFECT - jr z, handleExplosionMiss + jr z, HandleExplosionMiss cp EXPLODE_RECOIL_EFFECT - jr z, handleExplosionMiss + jr z, HandleExplosionMiss jr EnemyCheckIfFlyOrChargeEffect .moveDidNotMiss call SwapPlayerAndEnemyLevels @@ -6088,13 +6093,13 @@ GetEnemyAnimationType: ld a, [wEnemyMoveEffect] and a ld a, ANIMATIONTYPE_SHAKE_SCREEN_VERTICALLY - jr z, playEnemyMoveAnimation + jr z, PlayEnemyMoveAnimation ld a, ANIMATIONTYPE_SHAKE_SCREEN_HORIZONTALLY_HEAVY - jr playEnemyMoveAnimation -handleExplosionMiss: + jr PlayEnemyMoveAnimation +HandleExplosionMiss: call SwapPlayerAndEnemyLevels xor a -playEnemyMoveAnimation: +PlayEnemyMoveAnimation: push af ld a, [wEnemyBattleStatus2] bit HAS_SUBSTITUTE_UP, a ; does mon have a substitute? @@ -6444,7 +6449,7 @@ CheckEnemyStatusConditions: ; ld a, BIDE ; ld [wEnemyMoveNum], a ; call SwapPlayerAndEnemyLevels -; ld hl, handleIfEnemyMoveMissed ; skip damage calculation, DecrementPP and MoveHitTest +; ld hl, HandleIfEnemyMoveMissed ; skip damage calculation, DecrementPP and MoveHitTest ; jp .enemyReturnToHL .checkIfThrashingAbout bit THRASHING_ABOUT, [hl] ; is mon using thrash or petal dance? @@ -6474,10 +6479,12 @@ CheckEnemyStatusConditions: ld hl, AttackContinuesText rst _PrintText ld hl, wEnemyNumAttacksLeft - dec [hl] ; did multi-turn move end? - ld hl, GetEnemyAnimationType ; if it didn't, skip damage calculation (deal damage equal to last hit), + dec [hl] + ld hl, GetEnemyAnimationType ; skip damage calculation (deal damage equal to last hit), ; DecrementPP and MoveHitTest -; jp nz, .enemyReturnToHL ; PureRGBnote: Rage effect was changed, don't need this code +; PureRGBnote: Rage effect was changed, don't need this code +; jp nz, .enemyReturnToHL ; redundant leftover code, the case wEnemyNumAttacksLeft == 0 +; ; is handled within CheckNumAttacksLeft ; jp .enemyReturnToHL ;.checkIfUsingRage ; ld a, [wEnemyBattleStatus2] @@ -6711,7 +6718,7 @@ LoadEnemyMonData: ; if it's a trainer battle, copy moves from enemy party data ld hl, wEnemyMon1Moves ld a, [wWhichPokemon] - ld bc, wEnemyMon2 - wEnemyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld bc, NUM_MOVES rst _CopyData @@ -7140,7 +7147,7 @@ LoadHudTilePatterns: ldh a, [rLCDC] add a ; is LCD disabled? jr c, .lcdEnabled -.lcdDisabled +; LCD disabled ld hl, BattleHudTiles1 ld de, vChars2 tile $6d ld bc, BattleHudTiles1End - BattleHudTiles1 @@ -7154,11 +7161,11 @@ LoadHudTilePatterns: .lcdEnabled ld de, BattleHudTiles1 ld hl, vChars2 tile $6d - lb bc, BANK(BattleHudTiles1), (BattleHudTiles1End - BattleHudTiles1) / $8 + lb bc, BANK(BattleHudTiles1), (BattleHudTiles1End - BattleHudTiles1) / TILE_1BPP_SIZE call CopyVideoDataDouble ld de, BattleHudTiles2 ld hl, vChars2 tile $73 - lb bc, BANK(BattleHudTiles2), (BattleHudTiles3End - BattleHudTiles2) / $8 + lb bc, BANK(BattleHudTiles2), (BattleHudTiles3End - BattleHudTiles2) / TILE_1BPP_SIZE jp CopyVideoDataDouble PrintEmptyString: @@ -7287,7 +7294,7 @@ DetermineWildOpponent: bit BIT_DEBUG_MODE, a jr z, .notDebugMode ldh a, [hJoyHeld] - bit BIT_B_BUTTON, a ; disable wild encounters + bit B_PAD_B, a ; disable wild encounters ret nz .notDebugMode ld a, [wNumberOfNoRandomBattleStepsLeft] @@ -7372,12 +7379,12 @@ _InitBattleCommon: rst _PrintText call SaveScreenTilesToBuffer1 call ClearScreen - ld a, $98 + ld a, HIGH(vBGMap0) ldh [hAutoBGTransferDest + 1], a ld a, $1 ldh [hAutoBGTransferEnabled], a call Delay3 - ld a, $9c + ld a, HIGH(vBGMap1) ldh [hAutoBGTransferDest + 1], a call LoadScreenTilesFromBuffer1 hlcoord 9, 7 @@ -7557,7 +7564,7 @@ LoadMonBackPicCommon: call GetBackSpriteTarget ret nz ; don't copy anything to vSprites when we loaded to vFrontPic ld hl, vSprites - ld c, (2 * SPRITEBUFFERSIZE)/16 ; count of 16-byte chunks to be copied + ld c, (2 * SPRITEBUFFERSIZE)/ TILE_SIZE ; count of 16-byte chunks to be copied ldh a, [hLoadedROMBank] ld b, a jp CopyVideoData @@ -7725,7 +7732,7 @@ CheckHazeMistImmunity: ; PureRGBnote: MOVED: moved from list_menu.asm to free up space in home bank OldManListMenuInit:: - ld a, "▶" + ld a, '▶' ldcoord_a 5, 4 ; place menu cursor in front of first menu entry ld c, 80 rst _DelayFrames diff --git a/engine/battle/decrement_pp.asm b/engine/battle/decrement_pp.asm index 6d4167d049..d7ed59289f 100644 --- a/engine/battle/decrement_pp.asm +++ b/engine/battle/decrement_pp.asm @@ -29,7 +29,7 @@ DecrementPP: ld hl, wPartyMon1PP ; PP of first move (in party) ld a, [wPlayerMonNumber] ; which mon in party is active - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ; calculate address of the mon to modify .DecrementPP: ld a, [wPlayerMoveListIndex] ; which move (0, 1, 2, 3) did we use? diff --git a/engine/battle/draw_hud_pokeball_gfx.asm b/engine/battle/draw_hud_pokeball_gfx.asm index 00fd2cd679..f1e9959c4e 100644 --- a/engine/battle/draw_hud_pokeball_gfx.asm +++ b/engine/battle/draw_hud_pokeball_gfx.asm @@ -13,12 +13,12 @@ DrawEnemyPokeballs: LoadPartyPokeballGfx: ld de, PokeballTileGraphics ld hl, vSprites tile $31 - lb bc, BANK(PokeballTileGraphics), (PokeballTileGraphicsEnd - PokeballTileGraphics) / $10 + lb bc, BANK(PokeballTileGraphics), (PokeballTileGraphicsEnd - PokeballTileGraphics) / TILE_SIZE jp CopyVideoData SetupOwnPartyPokeballs: call PlacePlayerHUDTiles - ld hl, wPartyMon1 + ld hl, wPartyMons ld de, wPartyCount call SetupPokeballs ld a, $60 @@ -98,7 +98,7 @@ PickPokeball: .done ld a, b ld [de], a - ld bc, wPartyMon2 - wPartyMon1Status + ld bc, PARTYMON_STRUCT_LENGTH - MON_STATUS add hl, bc ; next mon struct ret @@ -129,7 +129,7 @@ WritePokeballOAMData: PlacePlayerHUDTiles: ld hl, PlayerBattleHUDGraphicsTiles ld de, wHUDGraphicsTiles - ld bc, $3 + ld bc, wHUDGraphicsTilesEnd - wHUDGraphicsTiles rst _CopyData hlcoord 18, 10 ld de, -1 @@ -144,7 +144,7 @@ PlayerBattleHUDGraphicsTiles: PlaceEnemyHUDTiles: ld hl, EnemyBattleHUDGraphicsTiles ld de, wHUDGraphicsTiles - ld bc, $3 + ld bc, wHUDGraphicsTilesEnd - wHUDGraphicsTiles rst _CopyData hlcoord 1, 2 ld de, $1 @@ -160,7 +160,7 @@ PlaceHUDTiles: ld [hl], $73 ld bc, SCREEN_WIDTH add hl, bc - ld a, [wHUDGraphicsTiles + 1] ; leftmost tile + ld a, [wHUDCornerTile] ; leftmost tile ld [hl], a ld a, 8 .loop @@ -169,7 +169,7 @@ PlaceHUDTiles: dec a jr nz, .loop add hl, de - ld a, [wHUDGraphicsTiles + 2] ; rightmost tile + ld a, [wHUDTriangleTile] ; rightmost tile ld [hl], a ret diff --git a/engine/battle/effects.asm b/engine/battle/effects.asm index 6192660884..d4a8ced91d 100644 --- a/engine/battle/effects.asm +++ b/engine/battle/effects.asm @@ -7,9 +7,9 @@ _JumpMoveEffect: ldh a, [hWhoseTurn] and a ld a, [wPlayerMoveEffect] - jr z, .next1 + jr z, .next ld a, [wEnemyMoveEffect] -.next1 +.next dec a ; subtract 1, there is no special effect for 00 add a ; x2, 16bit pointers ld hl, MoveEffectPointerTable @@ -41,7 +41,7 @@ SleepEffect: ; including the event where the target already has another status ld a, [de] ld b, a - and $7 + and SLP_MASK jr z, .notAlreadySleeping ; can't affect a mon that is already asleep ld hl, AlreadyAsleepText rst _PrintText @@ -59,7 +59,7 @@ SleepEffect: .setSleepCounter ; set target's sleep counter to a random number between 1 and 7 call BattleRandom - and $7 + and SLP_MASK jr z, .setSleepCounter ld [de], a call PlayCurrentMoveAnimation2 @@ -232,7 +232,7 @@ FreezeBurnParalyzeEffect: jr z, .burn1 cp FREEZE_SIDE_EFFECT1 jr z, .freeze1 -; .paralyze1 +; paralyze1 ld a, 1 << PAR ld [wEnemyMonStatus], a call QuarterSpeedDueToParalysis ; quarter speed of affected mon @@ -297,7 +297,7 @@ FreezeBurnParalyzeEffect: jr z, .burn2 cp FREEZE_SIDE_EFFECT1 jr z, .freeze2 -; .paralyze2 +; paralyze2 ld a, 1 << PAR ld [wBattleMonStatus], a call QuarterSpeedDueToParalysis @@ -345,7 +345,7 @@ CheckDefrost: ld [wEnemyMonStatus], a ; set opponent status to 00 ["defrost" a frozen monster] ld hl, wEnemyMon1Status ld a, [wEnemyMonPartyPos] - ld bc, wEnemyMon2 - wEnemyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes xor a ld [hl], a ; clear status in roster @@ -358,7 +358,7 @@ CheckDefrost: ld [wBattleMonStatus], a ld hl, wPartyMon1Status ld a, [wPlayerMonNumber] - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes xor a ld [hl], a @@ -855,7 +855,7 @@ StatModifierDownEffect: ld a, [de] cp ATTACK_DOWN2_EFFECT - $16 ; $24 jr c, .ok - cp EVASION_DOWN2_EFFECT + $5 ; $44 + cp ATTACK_DOWN_SIDE_EFFECT ; move side effects, stat mod decrease is always 1 jr nc, .ok dec b ; stat down 2 effects only (dec mod again) jr nz, .ok @@ -944,7 +944,7 @@ UpdateLoweredStatDone: CheckFlag FLAG_SKIP_STAT_ANIMATION jr nz, .ApplyBadgeBoostsAndStatusPenalties ld a, [de] - cp $44 + cp ATTACK_DOWN_SIDE_EFFECT call c, PlayCurrentMoveAnimation2 .ApplyBadgeBoostsAndStatusPenalties ldh a, [hWhoseTurn] @@ -986,7 +986,7 @@ CantLowerAnymore: MoveMissed: ld a, [de] - cp $44 + cp ATTACK_DOWN_SIDE_EFFECT ret nc jp ConditionalPrintButItFailed @@ -1018,7 +1018,7 @@ FellText: PrintStatText: ld hl, StatModTextStrings - ld c, "@" + ld c, '@' .findStatName_outer dec b jr z, .foundStatName @@ -1029,7 +1029,7 @@ PrintStatText: jr .findStatName_inner .foundStatName ld de, wStringBuffer - ld bc, $a + ld bc, STAT_NAME_LENGTH jp CopyData INCLUDE "data/battle/stat_mod_names.asm" @@ -1621,7 +1621,7 @@ DisableEffect: cp LINK_STATE_BATTLING pop hl ; wEnemyMonMoves jr nz, .playerTurnNotLinkBattle -; .playerTurnLinkBattle +; player's turn, Link Battle push hl ld hl, wEnemyMonPP .enemyTurn @@ -1809,9 +1809,9 @@ CheckTargetSubstitute: ld hl, wEnemyBattleStatus2 ldh a, [hWhoseTurn] and a - jr z, .next1 + jr z, .next ld hl, wPlayerBattleStatus2 -.next1 +.next bit HAS_SUBSTITUTE_UP, [hl] pop hl ret @@ -1833,6 +1833,7 @@ PlayCurrentMoveAnimation2: set 0, [hl] pop hl ;;;;;;;;;; +; fallthrough PlayBattleAnimation2: ; play animation ID at a and animation type 6 or 3 @@ -1865,6 +1866,7 @@ PlayCurrentMoveAnimation: set 0, [hl] pop hl ;;;;;;;;;; +; fallthrough PlayBattleAnimation: ; play animation ID at a and predefined animation type diff --git a/engine/battle/end_of_battle.asm b/engine/battle/end_of_battle.asm index f69489fb11..e3a464055f 100644 --- a/engine/battle/end_of_battle.asm +++ b/engine/battle/end_of_battle.asm @@ -5,7 +5,7 @@ EndOfBattle: ; link battle ld a, [wEnemyMonPartyPos] ld hl, wEnemyMon1Status - ld bc, wEnemyMon2 - wEnemyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld a, [wEnemyMonStatus] ld [hl], a @@ -59,8 +59,8 @@ EndOfBattle: ld [hli], a ld [hl], a ld [wListScrollOffset], a - ld hl, wPlayerStatsToDouble - ld b, $18 + ld hl, wBattleStatusData + ld b, wBattleStatusDataEnd - wBattleStatusData .loop ld [hli], a dec b diff --git a/engine/battle/experience.asm b/engine/battle/experience.asm index a5a82f4eee..a00551a1ca 100644 --- a/engine/battle/experience.asm +++ b/engine/battle/experience.asm @@ -21,7 +21,7 @@ GainExperience: and a ; is mon's gain exp flag set? pop hl jp z, .nextMon ; if mon's gain exp flag not set, go to next mon - ld de, (wPartyMon1HPExp + 1) - (wPartyMon1HP + 1) + ld de, (MON_HP_EXP + 1) - (MON_HP + 1) add hl, de ld d, h ld e, l @@ -66,10 +66,10 @@ GainExperience: ldh [hDivisor], a ld b, 4 call Divide - ld hl, wPartyMon1OTID - (wPartyMon1DVs - 1) + ld hl, MON_OTID - (MON_DVS - 1) add hl, de ld a, [hli] - ld b, a ; party mon OTID + ld b, a ; wPartyMon*OTID ;;;;;;;;;; PureRGBnote: ADDED: new item that causes all pokemon to gain EXP as if they were received from a trade. CheckEvent EVENT_BOOSTER_CHIP_ACTIVE ; always get traded pokemon boost if BOOSTER CHIP was used. jr nz, .tradedMon @@ -168,7 +168,7 @@ GainExperience: ;;;;;;;;;; call LoadMonData pop hl - ld bc, wPartyMon1Level - wPartyMon1Exp + ld bc, MON_LEVEL - MON_EXP add hl, bc push hl farcall CalcLevelFromExperience @@ -191,13 +191,13 @@ GainExperience: ld a, d ld [wCurEnemyLevel], a ld [hl], a - ld bc, wPartyMon1Species - wPartyMon1Level + ld bc, MON_SPECIES - MON_LEVEL add hl, bc ld a, [hl] ld [wCurSpecies], a ld [wPokedexNum], a call GetMonHeader - ld bc, (wPartyMon1MaxHP + 1) - wPartyMon1Species + ld bc, (MON_MAXHP + 1) - MON_SPECIES add hl, bc push hl ld a, [hld] @@ -206,7 +206,7 @@ GainExperience: push bc ; push max HP (from before levelling up) ld d, h ld e, l - ld bc, (wPartyMon1HPExp - 1) - wPartyMon1MaxHP + ld bc, (MON_HP_EXP - 1) - MON_MAXHP add hl, bc ld b, $1 ; consider stat exp when calculating stats call CalcStats @@ -218,15 +218,15 @@ GainExperience: ld a, [hl] sbc b ld b, a ; bc = difference between old max HP and new max HP after levelling - ld de, (wPartyMon1HP + 1) - wPartyMon1MaxHP + ld de, (MON_HP + 1) - MON_MAXHP add hl, de ; add to the current HP the amount of max HP gained when levelling - ld a, [hl] ; wPartyMon1HP + 1 + ld a, [hl] ; wPartyMon*HP + 1 add c ld [hld], a - ld a, [hl] ; wPartyMon1HP + 1 + ld a, [hl] ; wPartyMon*HP + 1 adc b - ld [hl], a ; wPartyMon1HP + ld [hl], a ; wPartyMon*HP ld a, [wPlayerMonNumber] ld b, a ld a, [wWhichPokemon] @@ -241,7 +241,7 @@ GainExperience: ld a, [hl] ld [de], a ; copy other stats from party mon to battle mon - ld bc, wPartyMon1Level - (wPartyMon1HP + 1) + ld bc, MON_LEVEL - (MON_HP + 1) add hl, bc push hl ld de, wBattleMonLevel @@ -276,7 +276,7 @@ GainExperience: .noExpBar3 ;;;;;;;;;; call LoadMonData - ld d, $1 + ld d, LEVEL_UP_STATS_BOX callfar PrintStatsBox call WaitForTextScrollButtonPress call LoadScreenTilesFromBuffer1 @@ -339,7 +339,7 @@ GainExperience: cp b jr z, .done ld [wWhichPokemon], a - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH ld hl, wPartyMon1 call AddNTimes jp .partyMonLoop diff --git a/engine/battle/get_trainer_name.asm b/engine/battle/get_trainer_name.asm index a0e869fce8..1983b08a3a 100644 --- a/engine/battle/get_trainer_name.asm +++ b/engine/battle/get_trainer_name.asm @@ -20,5 +20,5 @@ GetTrainerName_:: ld hl, wNameBuffer .foundName ld de, wTrainerName - ld bc, ITEM_NAME_LENGTH + ld bc, TRAINER_NAME_LENGTH jp CopyData diff --git a/engine/battle/ghost_marowak_anim.asm b/engine/battle/ghost_marowak_anim.asm index 4c2de3f266..ae1abe7a9c 100644 --- a/engine/battle/ghost_marowak_anim.asm +++ b/engine/battle/ghost_marowak_anim.asm @@ -51,11 +51,11 @@ MarowakAnim: call Delay3 jp ClearSprites -; copies a mon pic's from background VRAM to sprite VRAM and sets up OAM +; copies a mon pic's from background VRAM to sprite VRAM and sets up OAM CopyMonPicFromBGToSpriteVRAM: ld de, vFrontPic ld hl, vSprites - ld bc, 7 * 7 + ld bc, PIC_SIZE call CopyVideoData ld a, $10 ld [wBaseCoordY], a @@ -77,7 +77,7 @@ CopyMonPicFromBGToSpriteVRAM: ld [hli], a ld a, d ld [hli], a - ld a, $14 ; use OBP1 ;shinpokerednote: gbcnote - updated oam setting for GBC + ld a, OAM_PAL1 | $04 ; use OBP1 ;shinpokerednote: gbcnote - updated oam setting for GBC ld [hli], a inc d dec c diff --git a/engine/battle/link_battle_versus_text.asm b/engine/battle/link_battle_versus_text.asm index 555eafa757..3a8c31dd17 100644 --- a/engine/battle/link_battle_versus_text.asm +++ b/engine/battle/link_battle_versus_text.asm @@ -12,9 +12,7 @@ DisplayLinkBattleVersusTextBox: call PlaceString ; place bold "VS" tiles between the names hlcoord 9, 8 - ld a, "" - ld [hli], a - ld [hl], "" + ld_hli_a_string "" xor a ld [wUpdateSpritesEnabled], a call SetupPlayerAndEnemyPokeballs diff --git a/engine/battle/misc.asm b/engine/battle/misc.asm index cb1b7e6745..083b7a0dd6 100644 --- a/engine/battle/misc.asm +++ b/engine/battle/misc.asm @@ -17,7 +17,7 @@ FormatMovesString: ld hl, wNameBuffer .copyNameLoop ld a, [hli] - cp "@" + cp '@' jr z, .doneCopyingName ld [de], a inc de @@ -26,7 +26,7 @@ FormatMovesString: ld a, b ld [wNumMovesMinusOne], a inc b - ld a, "" + ld a, '' ld [de], a inc de pop hl @@ -35,19 +35,19 @@ FormatMovesString: jr z, .done jr .printMoveNameLoop .printDashLoop - ld a, "-" + ld a, '-' ld [de], a inc de inc b ld a, b cp NUM_MOVES jr z, .done - ld a, "" + ld a, '' ld [de], a inc de jr .printDashLoop .done - ld a, "@" + ld a, '@' ld [de], a ret diff --git a/engine/battle/move_effects/conversion.asm b/engine/battle/move_effects/conversion.asm index d2fe2aef69..678b3c37f0 100644 --- a/engine/battle/move_effects/conversion.asm +++ b/engine/battle/move_effects/conversion.asm @@ -9,7 +9,7 @@ ShowConversionMenu:: ld hl, .chooseConversionMode rst _PrintText ld hl, ConversionMenu - ld b, A_BUTTON | B_BUTTON + ld b, PAD_A | PAD_B call DisplayMultiChoiceTextBox jr nz, .back call LoadScreenTilesFromBuffer1 diff --git a/engine/battle/move_effects/transform.asm b/engine/battle/move_effects/transform.asm index 2570d850b6..18fad99eb5 100644 --- a/engine/battle/move_effects/transform.asm +++ b/engine/battle/move_effects/transform.asm @@ -2,17 +2,22 @@ TransformEffect_: ld hl, wBattleMonSpecies ld de, wEnemyMonSpecies ld bc, wEnemyBattleStatus3 + ; bug: on enemy's turn, a is overloaded with hWhoseTurn, + ; before the check for INVULNERABLE ld a, [wEnemyBattleStatus1] ldh a, [hWhoseTurn] and a jr nz, .hitTest +; player's turn ld hl, wEnemyMonSpecies ld de, wBattleMonSpecies ld bc, wPlayerBattleStatus3 ld [wPlayerMoveListIndex], a + ; bug: this should be target's BattleStatus1 (i.e. wEnemyBattleStatus1) ld a, [wPlayerBattleStatus1] .hitTest bit INVULNERABLE, a ; is mon invulnerable to typical attacks? (fly/dig) + ; this check doesn't work due to above bugs jp nz, .failed push hl push de @@ -101,7 +106,7 @@ TransformEffect_: inc de inc de inc de - ld bc, $8 + ld bc, (NUM_STATS - 1) * 2 rst _CopyData ld bc, wBattleMonMoves - wBattleMonPP add hl, bc ; ld hl, wBattleMonMoves @@ -111,7 +116,7 @@ TransformEffect_: ld a, [hli] and a jr z, .lessThanFourMoves - ld a, $5 + ld a, 5 ld [de], a inc de dec b diff --git a/engine/battle/moved_battle_code.asm b/engine/battle/moved_battle_code.asm index a7ac1ced0b..a486102352 100644 --- a/engine/battle/moved_battle_code.asm +++ b/engine/battle/moved_battle_code.asm @@ -244,10 +244,10 @@ LoadPlayerBackPic:: ld de, vBackPic call InterlaceMergeSpriteBuffers .nextFinish - ld a, $a - ld [MBC1SRamEnable], a + ld a, RAMG_SRAM_ENABLE + ld [rRAMG], a xor a - ld [MBC1SRamBank], a + ld [rRAMB], a ld hl, vSprites ld de, sSpriteBuffer1 ldh a, [hLoadedROMBank] @@ -255,7 +255,7 @@ LoadPlayerBackPic:: ld c, 7 * 7 call CopyVideoData xor a - ld [MBC1SRamEnable], a + ld [rRAMG], a ld a, $31 ldh [hStartTileID], a hlcoord 1, 5 diff --git a/engine/battle/print_type.asm b/engine/battle/print_type.asm index 191205934a..8eff4043f9 100644 --- a/engine/battle/print_type.asm +++ b/engine/battle/print_type.asm @@ -31,7 +31,7 @@ PrintType: ; erase "TYPE2/" if the mon only has 1 type EraseType2Text: - ld a, " " + ld a, ' ' ld bc, $13 add hl, bc ld bc, $6 diff --git a/engine/battle/read_trainer_party.asm b/engine/battle/read_trainer_party.asm index 26753e4a15..95307db71b 100644 --- a/engine/battle/read_trainer_party.asm +++ b/engine/battle/read_trainer_party.asm @@ -32,14 +32,14 @@ ReadTrainer: ; and hl points to the trainer class. ; Our next task is to iterate through the trainers, ; decrementing b each time, until we get to the right one. -.outer +.CheckNextTrainer dec b jr z, .IterateTrainer -.inner +.SkipTrainer ld a, [hli] and a - jr nz, .inner - jr .outer + jr nz, .SkipTrainer + jr .CheckNextTrainer ; if the first byte of trainer data is FF, ; - each pokemon has a specific level @@ -132,7 +132,7 @@ ReadTrainer: ld d, [hl] ; move to be given ld hl, wEnemyMon1Moves add hl, bc ; select which move will be replaced based on c - ld bc, wEnemyMon2 - wEnemyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ; select the correct pokemon to modify ld [hl], d ; modify the move at the given slot to be the given move ;;;;;;;;;; diff --git a/engine/battle/save_trainer_name.asm b/engine/battle/save_trainer_name.asm index 29b2304bfa..e6d0575afa 100644 --- a/engine/battle/save_trainer_name.asm +++ b/engine/battle/save_trainer_name.asm @@ -6,7 +6,7 @@ SaveTrainerName:: ld a, [hli] ld [de], a inc de - cp "@" + cp '@' jr nz, .CopyCharacter ret diff --git a/engine/battle/trainer_ai.asm b/engine/battle/trainer_ai.asm index 61497deb9b..be9ccf3b0a 100644 --- a/engine/battle/trainer_ai.asm +++ b/engine/battle/trainer_ai.asm @@ -1421,7 +1421,7 @@ AISwitchIfEnoughMons: inc d .Fainted push bc - ld bc, wEnemyMon2 - wEnemyMon1 + ld bc, PARTYMON_STRUCT_LENGTH add hl, bc pop bc dec c @@ -1460,16 +1460,16 @@ SwitchEnemyMonCommon: .preparewithdraw ;;;;; -; prepare to withdraw the active monster: copy hp, number, and status to roster +; prepare to withdraw the active monster: copy HP, party pos, and status to roster ld a, [wEnemyMonPartyPos] ld hl, wEnemyMon1HP - ld bc, wEnemyMon2 - wEnemyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld d, h ld e, l ld hl, wEnemyMonHP - ld bc, 4 + ld bc, MON_STATUS + 1 - MON_HP ; also copies party pos in-between HP and status rst _CopyData ;shinpokerednote: ADDED: don't copy PP information if transformed @@ -1527,7 +1527,7 @@ AICureStatus: ;shinpokerednote: CHANGED: modified to be more robust and also und ; cures the status of enemy's active pokemon ld a, [wEnemyMonPartyPos] ld hl, wEnemyMon1Status - ld bc, wEnemyMon2 - wEnemyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes xor a ld [hl], a ; clear status in enemy team roster @@ -1624,22 +1624,22 @@ CheckIfHPBelowFractionCommon: ret AIUseXAttack: - ld b, $A + ld b, ATTACK_UP1_EFFECT ld a, X_ATTACK jr AIIncreaseStat AIUseXDefend: - ld b, $B + ld b, DEFENSE_UP1_EFFECT ld a, X_DEFEND jr AIIncreaseStat AIUseXSpeed: - ld b, $C + ld b, SPEED_UP1_EFFECT ld a, X_SPEED jr AIIncreaseStat AIUseXSpecial: - ld b, $D + ld b, SPECIAL_UP1_EFFECT ld a, X_SPECIAL ; fallthrough diff --git a/engine/debug/debug_menu.asm b/engine/debug/debug_menu.asm index e894fe804f..6b8c90d17f 100644 --- a/engine/debug/debug_menu.asm +++ b/engine/debug/debug_menu.asm @@ -33,7 +33,7 @@ IF DEF(_DEBUG) ld a, TEXT_DELAY_MEDIUM ld [wOptions], a - ld a, A_BUTTON | B_BUTTON | START + ld a, PAD_A | PAD_B | PAD_START ld [wMenuWatchedKeys], a xor a ld [wMenuJoypadPollCount], a @@ -49,7 +49,7 @@ IF DEF(_DEBUG) ld [wMenuWatchMovingOutOfBounds], a ;call HandleMenuInput - ;bit BIT_B_BUTTON, a + ;bit B_PAD_B, a ;jp nz, DisplayTitleScreen ;ld a, [wCurrentMenuItem] diff --git a/engine/events/black_out.asm b/engine/events/black_out.asm index 41e30cf0df..bd7ceb6be3 100644 --- a/engine/events/black_out.asm +++ b/engine/events/black_out.asm @@ -48,6 +48,6 @@ ResetStatusAndHalveMoneyOnBlackout:: set BIT_FLY_OR_DUNGEON_WARP, [hl] res BIT_FLY_WARP, [hl] set BIT_ESCAPE_WARP, [hl] - ld a, A_BUTTON | B_BUTTON | SELECT | START | D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_BUTTONS | PAD_CTRL_PAD ld [wJoyIgnore], a predef_jump HealParty diff --git a/engine/events/cinnabar_lab.asm b/engine/events/cinnabar_lab.asm index d547512bf6..25d3f6205a 100644 --- a/engine/events/cinnabar_lab.asm +++ b/engine/events/cinnabar_lab.asm @@ -3,7 +3,7 @@ GiveFossilToCinnabarLab:: set BIT_NO_TEXT_DELAY, [hl] xor a ld [wCurrentMenuItem], a - ld a, A_BUTTON | B_BUTTON + ld a, PAD_A | PAD_B ld [wMenuWatchedKeys], a ld a, [wFilteredBagItemsCount] dec a @@ -27,7 +27,7 @@ GiveFossilToCinnabarLab:: ld hl, wStatusFlags5 res BIT_NO_TEXT_DELAY, [hl] call HandleMenuInput - bit BIT_B_BUTTON, a + bit B_PAD_B, a jr nz, .cancelledGivingFossil ld hl, wFilteredBagItems ld a, [wCurrentMenuItem] diff --git a/engine/events/diploma.asm b/engine/events/diploma.asm index 2eb4c47fbc..c70b49a38c 100644 --- a/engine/events/diploma.asm +++ b/engine/events/diploma.asm @@ -12,7 +12,7 @@ DisplayDiploma:: rst _DelayFrame ; shinpokerednote: FIXED: the overworld sprite wobble fix makes the player sprites hidden unless a delay is added ld hl, CircleTile ld de, vChars2 tile CIRCLE_TILE_ID - ld bc, $10 + ld bc, TILE_SIZE ld a, BANK(CircleTile) call FarCopyData2 hlcoord 0, 0 @@ -75,13 +75,13 @@ DisplayDiploma:: jp GBPalNormal ;UnusedPlayerNameLengthFunc: -; Unused function that does a calculation involving the length of the player's -; name. +;; Unused function that performs bc = -(player name's length) +;; leftover from the JPN versions ; ld hl, wPlayerName ; lb bc, $ff, $00 ;.loop ; ld a, [hli] -; cp "@" +; cp '@' ; ret z ; dec c ; jr .loop diff --git a/engine/events/evolve_trade.asm b/engine/events/evolve_trade.asm index 8ec7ad5cf6..7dfc2433cc 100644 --- a/engine/events/evolve_trade.asm +++ b/engine/events/evolve_trade.asm @@ -6,13 +6,13 @@ InGameTrade_CheckForTradeEvo: ; Graveler's English name and Haunter's early English name "Spectre". ; The final release replaced Graveler and Haunter in TradeMons. ld a, [wInGameTradeReceiveMonName] - cp "G" ; GRAVELER + cp 'G' ; GRAVELER jr z, .nameMatched ; "SPECTRE" (HAUNTER) - cp "S" + cp 'S' ret nz ld a, [wInGameTradeReceiveMonName + 1] - cp "P" + cp 'P' ret nz .nameMatched ld a, [wPartyCount] diff --git a/engine/events/give_pokemon.asm b/engine/events/give_pokemon.asm index 39cc83e815..7f1aeb1bbe 100644 --- a/engine/events/give_pokemon.asm +++ b/engine/events/give_pokemon.asm @@ -20,19 +20,19 @@ _GivePokemon:: callfar SendNewMonToBox ld hl, wStringBuffer ld a, [wCurrentBoxNum] - and $7f + and BOX_NUM_MASK cp 9 jr c, .singleDigitBoxNum sub 9 - ld [hl], "1" + ld [hl], '1' inc hl - add "0" + add '0' jr .next .singleDigitBoxNum - add "1" + add '1' .next ld [hli], a - ld [hl], "@" + ld [hl], '@' ld hl, SentToBoxText rst _PrintText callfar PrintRemainingBoxSpace ; PureRGBnote: ADDED: diff --git a/engine/events/heal_party.asm b/engine/events/heal_party.asm index e6551bcddd..5532fd920f 100644 --- a/engine/events/heal_party.asm +++ b/engine/events/heal_party.asm @@ -11,7 +11,7 @@ HealParty: push hl push de - ld hl, wPartyMon1Status - wPartyMon1HP + ld hl, MON_STATUS - MON_HP add hl, de xor a ld [hl], a @@ -19,7 +19,7 @@ HealParty: push de ld b, NUM_MOVES ; A Pokémon has 4 moves .pp - ld hl, wPartyMon1Moves - wPartyMon1HP + ld hl, MON_MOVES - MON_HP add hl, de ld a, [hl] @@ -27,7 +27,7 @@ HealParty: jr z, .nextmove dec a - ld hl, wPartyMon1PP - wPartyMon1HP + ld hl, MON_PP - MON_HP add hl, de push hl @@ -60,7 +60,7 @@ HealParty: jr nz, .pp pop de - ld hl, wPartyMon1MaxHP - wPartyMon1HP + ld hl, MON_MAXHP - MON_HP add hl, de ld a, [hli] ld [de], a @@ -72,7 +72,7 @@ HealParty: pop hl push hl - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH ld h, d ld l, e add hl, bc diff --git a/engine/events/hidden_items.asm b/engine/events/hidden_items.asm index 3d0fd18168..28b301b707 100644 --- a/engine/events/hidden_items.asm +++ b/engine/events/hidden_items.asm @@ -47,7 +47,7 @@ HiddenItemsInit: HiddenItemsFinish: ld [wTempStore1], a - ld a, "@" + ld a, '@' ld [wTempStore2], a tx_pre_jump FoundHiddenItemText diff --git a/engine/events/hidden_objects/bench_guys.asm b/engine/events/hidden_objects/bench_guys.asm index 502b89dc85..56524cc87c 100644 --- a/engine/events/hidden_objects/bench_guys.asm +++ b/engine/events/hidden_objects/bench_guys.asm @@ -17,6 +17,16 @@ PrintBenchGuyText: ld b, a ld a, [wSpritePlayerStateData1FacingDirection] cp b + + ; bug: an 'inc hl' instruction is needed before looping back. When trying to + ; talk to a bench guy from above, this Sprite Facing test will fail, and the + ; next loop iteration will be misaligned within BenchGuyTextPointers table. + ; As a result, the routine will miss the terminator byte, and continue to + ; process data beyond the table boundary. + ; It seems that it will only return after starting to read data from VRAM + ; (According to Pan Docs, during PPU mode 3, reads return garbage value, + ; usually $FF). + inc hl jr nz, .loop ; player isn't facing the bench guy ld a, [hl] jp PrintPredefTextID diff --git a/engine/events/hidden_objects/bills_house_pc.asm b/engine/events/hidden_objects/bills_house_pc.asm index 477a65ed91..62651e6cb4 100644 --- a/engine/events/hidden_objects/bills_house_pc.asm +++ b/engine/events/hidden_objects/bills_house_pc.asm @@ -81,7 +81,7 @@ BillsHousePokemonList:: ld [wTopMenuItemX], a .billsPokemonLoop ;;;;;;;;;; PureRGBnote: MOVED: moved here because opening a pokedex entry changes wMenuWatchedKeys now and this needs to be repeated every menu loop. - ld a, A_BUTTON | B_BUTTON + ld a, PAD_A | PAD_B ld [wMenuWatchedKeys], a ;;;;;;;;;; ld hl, wStatusFlags5 @@ -96,7 +96,7 @@ BillsHousePokemonList:: rst _PrintText call SaveScreenTilesToBuffer2 call HandleMenuInput - bit BIT_B_BUTTON, a + bit B_PAD_B, a jr nz, .cancel ld a, [wCurrentMenuItem] add EEVEE diff --git a/engine/events/hidden_objects/school_blackboard.asm b/engine/events/hidden_objects/school_blackboard.asm index 7d90037a3b..f7e195244c 100644 --- a/engine/events/hidden_objects/school_blackboard.asm +++ b/engine/events/hidden_objects/school_blackboard.asm @@ -14,7 +14,7 @@ LinkCableHelp:: ld [wMenuItemOffset], a ; not used ld [wCurrentMenuItem], a ld [wLastMenuItem], a - ld a, A_BUTTON | B_BUTTON + ld a, PAD_A | PAD_B ld [wMenuWatchedKeys], a ld a, 3 ld [wMaxMenuItem], a @@ -34,7 +34,7 @@ LinkCableHelp:: ld hl, LinkCableHelpText2 rst _PrintText call HandleMenuInput - bit BIT_B_BUTTON, a + bit B_PAD_B, a jr nz, .exit ld a, [wCurrentMenuItem] cp 3 ; pressed a on "STOP READING" @@ -97,7 +97,7 @@ ViridianSchoolBlackboard:: ld [wMenuItemOffset], a ld [wCurrentMenuItem], a ld [wLastMenuItem], a - ld a, D_LEFT | D_RIGHT | A_BUTTON | B_BUTTON + ld a, PAD_LEFT | PAD_RIGHT | PAD_A | PAD_B ld [wMenuWatchedKeys], a ld a, 2 ld [wMaxMenuItem], a @@ -120,9 +120,9 @@ ViridianSchoolBlackboard:: ld hl, ViridianSchoolBlackboardText2 rst _PrintText call HandleMenuInput ; pressing up and down is handled in here - bit BIT_B_BUTTON, a ; pressed b + bit B_PAD_B, a ; pressed b jr nz, .exitBlackboard - bit BIT_D_RIGHT, a + bit B_PAD_RIGHT, a jr z, .didNotPressRight ; move cursor to right column ld a, 2 @@ -135,7 +135,7 @@ ViridianSchoolBlackboard:: ld [wMenuItemOffset], a jr .blackboardLoop .didNotPressRight - bit BIT_D_LEFT, a + bit B_PAD_LEFT, a jr z, .didNotPressLeftOrRight ; move cursor to left column ld a, 2 diff --git a/engine/events/hidden_objects/vermilion_gym_trash.asm b/engine/events/hidden_objects/vermilion_gym_trash.asm index 6838c82d05..300c93cf01 100644 --- a/engine/events/hidden_objects/vermilion_gym_trash.asm +++ b/engine/events/hidden_objects/vermilion_gym_trash.asm @@ -145,7 +145,7 @@ VermilionGymTrashSuccessText2:: text_end ; unused -VermilionGymTrashSuccesPlaySfx: +VermilionGymTrashSuccessPlaySfx: text_asm call WaitForSoundToFinish ld a, SFX_SWITCH diff --git a/engine/events/in_game_trades.asm b/engine/events/in_game_trades.asm index 38bfb40370..f18f82fffd 100644 --- a/engine/events/in_game_trades.asm +++ b/engine/events/in_game_trades.asm @@ -116,7 +116,7 @@ InGameTrade_DoTrade: ld a, [wWhichPokemon] ;;;;;;;;;; PureRGBnote: ADDED: check if we need to store whether the player's pokemon uses alternate palette to make the trade animation correct ld hl, wPartyMon1Flags - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld a, [hl] and 1 @@ -221,7 +221,7 @@ InGameTrade_PrepareTradeData: ld de, wLinkEnemyTrainerName call InGameTrade_CopyData ld hl, wPartyMon1OTID - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH ld a, [wWhichPokemon] call AddNTimes ld de, wTradedPlayerMonOTID @@ -254,10 +254,10 @@ InGameTrade_CopyDataToReceivedMon: ld bc, NAME_LENGTH rst _CopyData ld hl, wPartyMon1OTID - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call InGameTrade_GetReceivedMonPointer ld hl, wTradedEnemyMonOTID - ld bc, $2 + ld bc, 2 jp CopyData ; the received mon's index is (partyCount - 1), @@ -271,7 +271,7 @@ InGameTrade_GetReceivedMonPointer: ret InGameTrade_TrainerString: - db "@@@@@@@@@@" + dname "", NAME_LENGTH InGameTradeTextPointers: ; entries correspond to TRADE_DIALOGSET_* constants diff --git a/engine/events/pewter_guys.asm b/engine/events/pewter_guys.asm index 0742cba55b..2a6af9c270 100644 --- a/engine/events/pewter_guys.asm +++ b/engine/events/pewter_guys.asm @@ -76,13 +76,13 @@ PewterMuseumGuyCoords: dw .right .down - db D_UP, D_UP, $ff + db PAD_UP, PAD_UP, $ff .up - db D_RIGHT, D_LEFT, $ff + db PAD_RIGHT, PAD_LEFT, $ff .left - db D_UP, D_RIGHT, $ff + db PAD_UP, PAD_RIGHT, $ff .right - db D_UP, D_LEFT, $ff + db PAD_UP, PAD_LEFT, $ff ; these are the five coordinates which trigger the gym guy and pointers to ; different movements for the player to make to get positioned before the @@ -101,12 +101,12 @@ PewterGymGuyCoords: dw .five .one - db D_LEFT, D_DOWN, D_DOWN, D_RIGHT, $ff + db PAD_LEFT, PAD_DOWN, PAD_DOWN, PAD_RIGHT, $ff .two - db D_LEFT, D_DOWN, D_RIGHT, D_LEFT, $ff + db PAD_LEFT, PAD_DOWN, PAD_RIGHT, PAD_LEFT, $ff .three - db D_LEFT, D_LEFT, D_LEFT, $00, $00, $00, $00, $00, $00, $00, $00, $ff + db PAD_LEFT, PAD_LEFT, PAD_LEFT, $00, $00, $00, $00, $00, $00, $00, $00, $ff .four - db D_LEFT, D_LEFT, D_UP, D_LEFT, $ff + db PAD_LEFT, PAD_LEFT, PAD_UP, PAD_LEFT, $ff .five - db D_LEFT, D_DOWN, D_LEFT, $00, $00, $00, $00, $00, $00, $00, $00, $ff + db PAD_LEFT, PAD_DOWN, PAD_LEFT, $00, $00, $00, $00, $00, $00, $00, $00, $ff diff --git a/engine/events/pick_up_item.asm b/engine/events/pick_up_item.asm index 6ccb0a9edc..63e139451d 100644 --- a/engine/events/pick_up_item.asm +++ b/engine/events/pick_up_item.asm @@ -61,7 +61,7 @@ PickUpItemCommon: .multiItemPickup add NUMBER_CHAR_OFFSET ; index of first number character in charmap (assumes c must be 0-9) ld [wTempStore1], a - ld a, "@" + ld a, '@' ld [wTempStore2], a ld hl, FoundMultipleItemText jr .print diff --git a/engine/events/poison.asm b/engine/events/poison.asm index 705a4a44cf..f360640e10 100644 --- a/engine/events/poison.asm +++ b/engine/events/poison.asm @@ -65,7 +65,7 @@ ApplyOutOfBattlePoisonDamage: ld a, [de] inc a jr z, .applyDamageLoopDone - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH add hl, bc push hl ld hl, wWhichPokemon @@ -82,7 +82,7 @@ ApplyOutOfBattlePoisonDamage: and 1 << PSN or e ld e, a - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH add hl, bc dec d jr nz, .countPoisonedLoop diff --git a/engine/events/pokecenter.asm b/engine/events/pokecenter.asm index 59c4a95b5e..8d3f5fab44 100644 --- a/engine/events/pokecenter.asm +++ b/engine/events/pokecenter.asm @@ -8,7 +8,7 @@ DisplayPokemonCenterDialogue_:: set BIT_UNKNOWN_4_1, [hl] set BIT_USED_POKECENTER, [hl] ldh a, [hJoyHeld] - bit BIT_B_BUTTON, a + bit B_PAD_B, a jr z, .normalWelcome ; NEW: if you're holding b when you start talking to the nurse, it'll skip right to healing. .fastWelcome CheckEventHL EVENT_DONATED_TO_POKECENTER_CHARITY ; must donate to pokecenter charity at rock tunnel pokecenter to be able to do this diff --git a/engine/events/pokedex_rating.asm b/engine/events/pokedex_rating.asm index 21376f274f..4d82ec47c9 100644 --- a/engine/events/pokedex_rating.asm +++ b/engine/events/pokedex_rating.asm @@ -40,7 +40,7 @@ DisplayDexRating: inc de .copyRatingTextLoop ld a, [hli] - cp "@" + cp '@' jr z, .doneCopying ld [de], a inc de diff --git a/engine/events/pokemart.asm b/engine/events/pokemart.asm index 8348d340d8..8d050997a0 100644 --- a/engine/events/pokemart.asm +++ b/engine/events/pokemart.asm @@ -105,7 +105,7 @@ DisplayPokemartDialogue_:: ;dec a ;jr z, .restoreItemIndexSellMenuLoop -.sellItem +; sell item ld a, [wBoughtOrSoldItemInMart] and a jr nz, .skipSettingFlag1 @@ -177,7 +177,7 @@ DisplayPokemartDialogue_:: ld a, [wMenuExitMethod] cp CHOSE_SECOND_ITEM jp z, .restoreItemIndexBuyMenuLoop ; if the player chose No or pressed the B button -.buyItem +; buy item call .isThereEnoughMoney jr c, .notEnoughMoney ld hl, wNumBagItems diff --git a/engine/events/prize_menu.asm b/engine/events/prize_menu.asm index 3c6fb889ae..907f35e434 100644 --- a/engine/events/prize_menu.asm +++ b/engine/events/prize_menu.asm @@ -1,18 +1,18 @@ CeladonPrizeMenu:: CheckEvent EVENT_GOT_COIN_CASE ; PureRGBnote: CHANGED: coin case was made into an event rather than an item in your bag. jr nz, .havingCoinCase - ld hl, RequireCoinCaseTextPtr + ld hl, RequireCoinCaseText jp PrintText .havingCoinCase ld hl, wStatusFlags5 set BIT_NO_TEXT_DELAY, [hl] - ld hl, ExchangeCoinsForPrizesTextPtr + ld hl, ExchangeCoinsForPrizesText rst _PrintText ; the following are the menu settings xor a ld [wCurrentMenuItem], a ld [wLastMenuItem], a - ld a, A_BUTTON | B_BUTTON + ld a, PAD_A | PAD_B ld [wMenuWatchedKeys], a ld a, $03 ld [wMaxMenuItem], a @@ -26,10 +26,10 @@ CeladonPrizeMenu:: call TextBoxBorder call GetPrizeMenuId call UpdateSprites - ld hl, WhichPrizeTextPtr + ld hl, WhichPrizeText rst _PrintText call HandleMenuInput ; menu choice handler - bit BIT_B_BUTTON, a + bit B_PAD_B, a jr nz, .noChoice ld a, [wCurrentMenuItem] cp 3 ; "NO,THANKS" choice @@ -39,16 +39,16 @@ CeladonPrizeMenu:: res BIT_NO_TEXT_DELAY, [hl] ret -RequireCoinCaseTextPtr: +RequireCoinCaseText: text_far _RequireCoinCaseText text_waitbutton text_end -ExchangeCoinsForPrizesTextPtr: +ExchangeCoinsForPrizesText: text_far _ExchangeCoinsForPrizesText text_end -WhichPrizeTextPtr: +WhichPrizeText: text_far _WhichPrizeText text_end @@ -190,7 +190,7 @@ HandlePrizeChoice: .getMonName call GetMonName .givePrize - ld hl, SoYouWantPrizeTextPtr + ld hl, SoYouWantPrizeText rst _PrintText call YesNoChoice ld a, [wCurrentMenuItem] ; yes/no answer (Y=0, N=1) @@ -238,25 +238,25 @@ HandlePrizeChoice: predef SubBCDPredef jp PrintPrizePrice .bagFull - ld hl, PrizeRoomBagIsFullTextPtr + ld hl, PrizeRoomBagIsFullText jp PrintText .notEnoughCoins ld hl, SorryNeedMoreCoinsText jp PrintText .printOhFineThen - ld hl, OhFineThenTextPtr + ld hl, OhFineThenText jp PrintText UnknownPrizeData: ; XXX what's this? db $00,$01,$00,$01,$00,$01,$00,$00,$01 -HereYouGoTextPtr: +HereYouGoText: ; unreferenced text_far _HereYouGoText text_waitbutton text_end -SoYouWantPrizeTextPtr: +SoYouWantPrizeText: text_far _SoYouWantPrizeText text_end @@ -265,12 +265,12 @@ SorryNeedMoreCoinsText: text_waitbutton text_end -PrizeRoomBagIsFullTextPtr: +PrizeRoomBagIsFullText: text_far _OopsYouDontHaveEnoughRoomText text_waitbutton text_end -OhFineThenTextPtr: +OhFineThenText: text_far _OhFineThenText text_waitbutton text_end diff --git a/engine/events/vending_machine.asm b/engine/events/vending_machine.asm index 51b8298098..2522034f88 100644 --- a/engine/events/vending_machine.asm +++ b/engine/events/vending_machine.asm @@ -11,7 +11,7 @@ VendingMachineMenu:: ld a, MONEY_BOX ld [wTextBoxID], a call DisplayTextBoxID - ld a, A_BUTTON | B_BUTTON + ld a, PAD_A | PAD_B ld [wMenuWatchedKeys], a ld a, 3 ld [wMaxMenuItem], a @@ -46,7 +46,7 @@ VendingMachineMenu:: ld hl, wStatusFlags5 res BIT_NO_TEXT_DELAY, [hl] call HandleMenuInput - bit BIT_B_BUTTON, a + bit B_PAD_B, a jp nz, .notThirsty ld a, [wCurrentMenuItem] cp 3 ; chose Cancel? diff --git a/engine/flag_action.asm b/engine/flag_action.asm index 802f3a2c92..b891156e2b 100644 --- a/engine/flag_action.asm +++ b/engine/flag_action.asm @@ -41,10 +41,10 @@ FlagAction: ld a, b and a jr z, .reset - cp 2 + cp FLAG_TEST jr z, .read -.set +; set ld b, [hl] ld a, d or b diff --git a/engine/gbc/bg_map_attributes.asm b/engine/gbc/bg_map_attributes.asm index 36ff560437..43ced5c49a 100644 --- a/engine/gbc/bg_map_attributes.asm +++ b/engine/gbc/bg_map_attributes.asm @@ -37,7 +37,7 @@ LoadBGMapAttributes:: ldh [rHDMA4], a ldh a, [rLCDC] - and 1 << rLCDC_ENABLE ; is LCD off? + and LCDC_ENABLE ; is LCD off? jr z, .lcdOff ; if off, transfer immediately ; wait for VBlank if LCD is on .waitForVBlankLoop1 @@ -71,7 +71,7 @@ LoadBGMapAttributes:: ldh [rHDMA4], a ; LCD check again ldh a, [rLCDC] - and 1 << rLCDC_ENABLE ; is LCD off? + and LCDC_ENABLE ; is LCD off? jr z, .lcdOff2 ; if off, transfer immediately ; wait for VBlank if LCD is on .waitForVBlankLoop2 @@ -99,7 +99,7 @@ LoadBGMapAttributes:: .done call Func_3082 ldh a, [rIF] - res VBLANK, a + res IF_VBLANK, a ldh [rIF], a xor a ldh [rVBK], a diff --git a/engine/gfx/hp_bar.asm b/engine/gfx/hp_bar.asm index a9995e2189..4d0932776d 100644 --- a/engine/gfx/hp_bar.asm +++ b/engine/gfx/hp_bar.asm @@ -230,7 +230,7 @@ UpdateHPBar_PrintHPNumber: .next add hl, de push hl - ld a, " " + ld a, ' ' ld [hli], a ld [hli], a ld [hl], a diff --git a/engine/gfx/load_pokedex_tiles.asm b/engine/gfx/load_pokedex_tiles.asm index a3f691714d..b0857137f9 100644 --- a/engine/gfx/load_pokedex_tiles.asm +++ b/engine/gfx/load_pokedex_tiles.asm @@ -3,7 +3,7 @@ LoadPokedexTilePatterns: call LoadHpBarAndStatusTilePatterns ld de, PokedexTileGraphics ld hl, vChars2 tile $60 - lb bc, BANK(PokedexTileGraphics), (PokedexTileGraphicsEnd - PokedexTileGraphics) / $10 + lb bc, BANK(PokedexTileGraphics), (PokedexTileGraphicsEnd - PokedexTileGraphics) / TILE_SIZE call CopyVideoData ld de, PokeballTileGraphics ld hl, vChars2 tile $72 diff --git a/engine/gfx/mon_icons.asm b/engine/gfx/mon_icons.asm index d8ecf60b47..efee716ce7 100644 --- a/engine/gfx/mon_icons.asm +++ b/engine/gfx/mon_icons.asm @@ -90,7 +90,7 @@ GetAnimationSpeed: .animateSprite push bc ld hl, wShadowOAMSprite00TileID - ld bc, $10 + ld bc, OBJ_SIZE * 4 ld a, [wCurrentMenuItem] call AddNTimes ; mechanicalpennote: ADDED: don't use hardcoded icon sprite indices @@ -246,7 +246,7 @@ WriteMonPartySpriteOAM: .makeCopy ld hl, wShadowOAM ld de, wMonPartySpritesSavedOAM - ld bc, $60 + ld bc, OBJ_SIZE * 4 * PARTY_LENGTH jp CopyData TradeBubbleIconGFX: INCBIN "gfx/trade/bubble.2bpp" diff --git a/engine/gfx/palettes.asm b/engine/gfx/palettes.asm index 3cbe975015..661543e4d2 100644 --- a/engine/gfx/palettes.asm +++ b/engine/gfx/palettes.asm @@ -402,7 +402,7 @@ SetPal_TrainerCard: srl a push af jr c, .haveBadge -; The player doens't have the badge, so zero the badge's blk data. +; The player doesn't have the badge, so zero the badge's blk data. push bc ld a, [de] ld c, a @@ -595,30 +595,30 @@ _SendSGBPacket: ; save B for later use push bc ; send RESET signal (P14=LOW, P15=LOW) - xor a + xor a ; JOYP_SGB_START ldh [rJOYP], a ; set P14=HIGH, P15=HIGH - ld a, $30 + ld a, JOYP_SGB_FINISH ldh [rJOYP], a ;load length of packets (16 bytes) - ld b, $10 + ld b, 16 .nextByte ;set bit counter (8 bits per byte) - ld e, $08 + ld e, 8 ; get next byte in the packet ld a, [hli] ld d, a .nextBit0 bit 0, d ; if 0th bit is not zero set P14=HIGH, P15=LOW (send bit 1) - ld a, $10 + ld a, JOYP_SGB_ONE jr nz, .next0 ; else (if 0th bit is zero) set P14=LOW, P15=HIGH (send bit 0) - ld a, $20 + ld a, JOYP_SGB_ZERO .next0 ldh [rJOYP], a ; must set P14=HIGH,P15=HIGH between each "pulse" - ld a, $30 + ld a, JOYP_SGB_FINISH 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) @@ -628,11 +628,11 @@ _SendSGBPacket: jr nz, .nextBit0 dec b jr nz, .nextByte -; send bit 1 as a "stop bit" (end of parameter data) - ld a, $20 +; send bit 0 as a "stop bit" (end of parameter data) + ld a, JOYP_SGB_ZERO ldh [rJOYP], a ; set P14=HIGH,P15=HIGH - ld a, $30 + ld a, JOYP_SGB_FINISH ldh [rJOYP], a ; wait for about 70000 cycles call Wait7000 @@ -725,20 +725,20 @@ CheckSGB: ei call Wait7000 ldh a, [rJOYP] - and $3 - cp $3 + and JOYP_SGB_MLT_REQ + cp JOYP_SGB_MLT_REQ jr nz, .isSGB - ld a, $20 + ld a, JOYP_SGB_ZERO ldh [rJOYP], a ldh a, [rJOYP] ldh a, [rJOYP] call Wait7000 call Wait7000 - ld a, $30 + ld a, JOYP_SGB_FINISH ldh [rJOYP], a call Wait7000 call Wait7000 - ld a, $10 + ld a, JOYP_SGB_ONE ldh [rJOYP], a ldh a, [rJOYP] ldh a, [rJOYP] @@ -749,7 +749,7 @@ CheckSGB: call Wait7000 vc_hook Unknown_network_reset call Wait7000 - ld a, $30 + ld a, JOYP_SGB_FINISH ldh [rJOYP], a ldh a, [rJOYP] ldh a, [rJOYP] @@ -757,8 +757,8 @@ CheckSGB: call Wait7000 call Wait7000 ldh a, [rJOYP] - and $3 - cp $3 + and JOYP_SGB_MLT_REQ + cp JOYP_SGB_MLT_REQ jr nz, .isSGB call SendMltReq1Packet and a @@ -787,15 +787,15 @@ CopyGfxToSuperNintendoVRAM: call CopySGBBorderTiles jr .next .notCopyingTileData - ld bc, $1000 + ld bc, 256 tiles rst _CopyData .next ld hl, vBGMap0 - ld de, $c + ld de, TILEMAP_WIDTH - SCREEN_WIDTH ld a, $80 - ld c, $d + ld c, (256 + SCREEN_WIDTH - 1) / SCREEN_WIDTH ; enough rows to fit 256 tiles .loop - ld b, $14 + ld b, SCREEN_WIDTH .innerLoop ld [hli], a inc a @@ -804,7 +804,7 @@ CopyGfxToSuperNintendoVRAM: add hl, de dec c jr nz, .loop - ld a, $e3 + ld a, LCDC_DEFAULT ldh [rLCDC], a pop hl call SendSGBPacket @@ -837,7 +837,7 @@ SendSGBPackets: ;shinpokerednote: gbcnote: initialize the second pal packet in de (now in hl) then enable the lcd call InitGBCPalettesNew ldh a, [rLCDC] - and 1 << rLCDC_ENABLE + and LCDC_ENABLE ret z jp Delay3 .notGBC @@ -980,7 +980,7 @@ DMGPalToGBCPal:: ;shinpokerednote: gbcnote: new function .convert ;"A" now holds the palette data DEF color_index = 0 - REPT NUM_COLORS + REPT PAL_COLORS ld b, a ;"B" now holds the palette data and %11 ;"A" now has just the value for the shade of palette color 0 call .GetColorAddress @@ -997,7 +997,7 @@ DEF color_index = 0 ld [wGBCPal + color_index * 2 + 1], a pop de - IF color_index < (NUM_COLORS + -1) + IF color_index < (PAL_COLORS + -1) ld a, b ;restore the palette data back into "A" ;rotate the palette data bits twice to the right so the next color in line becomes color 0 rrca @@ -1026,14 +1026,14 @@ TransferCurBGPData:: ;shinpokerednote: gbcnote: code from pokemon yellow ld de, rBGPD ld hl, wGBCPal ldh a, [rLCDC] - and 1 << rLCDC_ENABLE + and LCDC_ENABLE jr nz, .lcdEnabled - rept NUM_COLORS + rept PAL_COLORS call TransferPalColorLCDDisabled endr jr .done .lcdEnabled - rept NUM_COLORS + rept PAL_COLORS call TransferPalColorLCDEnabled endr .done @@ -1067,7 +1067,7 @@ BufferBGPPal:: ;shinpokerednote: gbcnote: code from pokemon yellow TransferBGPPals:: ;shinpokerednote: gbcnote: code from pokemon yellow ; Transfer the buffered BG palettes. ldh a, [rLCDC] - and 1 << rLCDC_ENABLE + and LCDC_ENABLE jr z, .lcdDisabled ; have to wait until LCDC is disabled ; LCD should only ever be disabled during the V-blank period to prevent hardware damage @@ -1105,14 +1105,14 @@ TransferCurOBPData: ;shinpokerednote: gbcnote: code from pokemon yellow ld de, rOBPD ld hl, wGBCPal ldh a, [rLCDC] - and 1 << rLCDC_ENABLE + and LCDC_ENABLE jr nz, .lcdEnabled - rept NUM_COLORS + rept PAL_COLORS call TransferPalColorLCDDisabled endr jr .done .lcdEnabled - rept NUM_COLORS + rept PAL_COLORS call TransferPalColorLCDEnabled endr .done @@ -1256,7 +1256,7 @@ CopySGBBorderTiles: ld b, 128 .tileLoop ; Copy bit planes 1 and 2 of the tile data. - ld c, 16 + ld c, TILE_SIZE .copyLoop ld a, [hli] ld [de], a diff --git a/engine/gfx/set_attack_animation_palette.asm b/engine/gfx/set_attack_animation_palette.asm index 1160ea4569..39cb2bc567 100644 --- a/engine/gfx/set_attack_animation_palette.asm +++ b/engine/gfx/set_attack_animation_palette.asm @@ -213,7 +213,7 @@ SetAttackAnimPal_resetPalettes: ld b, 4 .loop2 ldh a, [rLCDC] - and 1 << rLCDC_ENABLE + and LCDC_ENABLE jr z, .lcd_dis ;lcd in enabled otherwise .wait1 diff --git a/engine/gfx/sprite_oam.asm b/engine/gfx/sprite_oam.asm index b595666796..f38ba408c9 100644 --- a/engine/gfx/sprite_oam.asm +++ b/engine/gfx/sprite_oam.asm @@ -172,16 +172,16 @@ PrepareOAMData:: ldh a, [hOAMBufferOffset] ld l, a ld h, HIGH(wShadowOAM) - ld de, $4 - ld b, $a0 + ld de, OBJ_SIZE + ld b, SCREEN_HEIGHT_PX + OAM_Y_OFS ld a, [wMovementFlags] bit BIT_LEDGE_OR_FISHING, a - ld a, $a0 + ld a, LOW(wShadowOAMEnd) jr z, .clear ; Don't clear the last 4 entries because they are used for the shadow in the ; jumping down ledge animation and the rod in the fishing animation. - ld a, $90 + ld a, LOW(wShadowOAMSprite36) .clear cp l diff --git a/engine/items/inventory.asm b/engine/items/inventory.asm index f62abe65e1..7a713e2d7c 100644 --- a/engine/items/inventory.asm +++ b/engine/items/inventory.asm @@ -118,7 +118,6 @@ RemoveItemFromInventory_:: jr nz, .skipMovingUpSlots ; if the remaining quantity is 0, ; remove the emptied item slot and move up all the following item slots -.moveSlotsUp ld e, l ld d, h inc de diff --git a/engine/items/item_effects.asm b/engine/items/item_effects.asm index abc56b843e..d8b7ce7703 100644 --- a/engine/items/item_effects.asm +++ b/engine/items/item_effects.asm @@ -164,7 +164,7 @@ ItemUseBall: dec a jr nz, .notOldManBattle -.oldManBattle +; Old Man battle ld hl, wGrassRate ld de, wPlayerName ld bc, NAME_LENGTH @@ -760,7 +760,7 @@ ItemUseBicycle: jp z, ItemUseNotTime dec a ; is player already bicycling? jr nz, .tryToGetOnBike -.getOffBike +; get off bike call ItemUseReloadOverworldData xor a ld [wWalkBikeSurfState], a ; change player state to walking @@ -850,13 +850,13 @@ ItemUseSurfboard: cp SURFING ; is the player already surfing? jr z, .alreadySurfing ; don't do anything if so ; PureRGBnote: CHANGED: can't use surf to "get back on land", this feature is bugged anyway ;jr z, .tryToStopSurfing -.tryToSurf +; try to Surf call IsNextTileShoreOrWater jp c, SurfingAttemptFailed ld hl, TilePairCollisionsWater call CheckForTilePairCollisions jp c, SurfingAttemptFailed -.surf +; surfing ;;;;; PureRGBnote: ADDED: only certain pokemon can surf on lava. ld a, [wCurMapTileset] cp VOLCANO @@ -892,15 +892,15 @@ ItemUseSurfboard: .makePlayerMoveForward ld a, [wPlayerDirection] ; direction the player is going bit PLAYER_DIR_BIT_UP, a - ld b, D_UP + ld b, PAD_UP jr nz, .storeSimulatedButtonPress bit PLAYER_DIR_BIT_DOWN, a - ld b, D_DOWN + ld b, PAD_DOWN jr nz, .storeSimulatedButtonPress bit PLAYER_DIR_BIT_LEFT, a - ld b, D_LEFT + ld b, PAD_LEFT jr nz, .storeSimulatedButtonPress - ld b, D_RIGHT + ld b, PAD_RIGHT .storeSimulatedButtonPress ld a, b ld [wSimulatedJoypadStatesEnd], a @@ -1007,7 +1007,7 @@ ItemUseMedicine: .getPartyMonDataAddress jp c, .canceledItemUse ld hl, wPartyMons - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH ld a, [wWhichPokemon] call AddNTimes ld a, [wWhichPokemon] @@ -1039,7 +1039,7 @@ ItemUseMedicine: jr nc, .healHP ; if it's a Full Restore or one of the potions ; fall through if it's one of the status-specific healing items .cureStatusAilment - ld bc, wPartyMon1Status - wPartyMon1 + ld bc, MON_STATUS add hl, bc ; hl now points to status ld a, [wCurItem] lb bc, ANTIDOTE_MSG, 1 << PSN @@ -1081,7 +1081,7 @@ ItemUseMedicine: ld [wHPBarOldHP], a ; current HP stored at wHPBarOldHP (2 bytes, big-endian) or b jr nz, .notFainted -.fainted +; fainted ld a, [wCurItem] cp REVIVE jr z, .updateInBattleFaintedData @@ -1121,7 +1121,7 @@ ItemUseMedicine: .compareCurrentHPToMaxHP push hl push bc - ld bc, wPartyMon1MaxHP - (wPartyMon1HP + 1) + ld bc, MON_MAXHP - (MON_HP + 1) add hl, bc ; hl now points to max HP pop bc ld a, [hli] @@ -1132,7 +1132,7 @@ ItemUseMedicine: .skipComparingLSB pop hl jr nz, .notFullHP -.fullHP ; if the pokemon's current HP equals its max HP +; if the pokemon's current HP equals its max HP ld a, [wCurItem] cp FULL_RESTORE jp nz, .healingItemNoEffect @@ -1153,7 +1153,7 @@ ItemUseMedicine: ld [wChannelSoundIDs + CHAN5], a push hl push de - ld bc, wPartyMon1MaxHP - (wPartyMon1HP + 1) + ld bc, MON_MAXHP - (MON_HP + 1) add hl, bc ; hl now points to max HP ld a, [hli] ld [wHPBarMaxHP+1], a @@ -1174,7 +1174,7 @@ ItemUseMedicine: push af ld hl, wPartyMon1MaxHP ld a, [wWhichPokemon] - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld a, [hli] ld [wHPBarMaxHP + 1], a @@ -1186,7 +1186,7 @@ ItemUseMedicine: 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) + ld bc, (MON_HP + 1) - (MON_MAXHP + 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 ldh a, [hQuotient + 3] @@ -1265,7 +1265,7 @@ ItemUseMedicine: inc hl ld d, h ld e, l ; de now points to current HP - ld hl, (wPartyMon1MaxHP + 1) - (wPartyMon1HP + 1) + ld hl, (MON_MAXHP + 1) - (MON_HP + 1) add hl, de ; hl now points to max HP ld a, [wCurItem] cp REVIVE @@ -1312,7 +1312,7 @@ ItemUseMedicine: ld a, [wCurItem] cp FULL_RESTORE jr nz, .updateInBattleData - ld bc, wPartyMon1Status - (wPartyMon1MaxHP + 1) + ld bc, MON_STATUS - (MON_MAXHP + 1) add hl, bc xor a ld [hl], a ; remove the status ailment in the party data @@ -1423,7 +1423,7 @@ ItemUseMedicine: ld a, [hl] ld [wCurSpecies], a ld [wPokedexNum], a - ld bc, wPartyMon1Level - wPartyMon1 + ld bc, MON_LEVEL add hl, bc ; hl now points to level ld a, [hl] ; a = level ld [wCurEnemyLevel], a ; store level @@ -1442,7 +1442,7 @@ ItemUseMedicine: push hl sub HP_UP add a - ld bc, wPartyMon1HPExp - wPartyMon1 + ld bc, MON_HP_EXP add hl, bc add l ld l, a @@ -1471,13 +1471,13 @@ ItemUseMedicine: .statNameInnerLoop ld a, [hli] ld b, a - ld a, $50 + ld a, '@' cp b jr nz, .statNameInnerLoop jr .statNameLoop .gotStatName ld de, wStringBuffer - ld bc, 10 + ld bc, STAT_NAME_LENGTH rst _CopyData ; copy the stat's name to wStringBuffer ld a, SFX_HEAL_AILMENT rst _PlaySound @@ -1497,17 +1497,17 @@ ItemUseMedicine: rst _PrintText jp GBPalWhiteOut .recalculateStats - ld bc, wPartyMon1Stats - wPartyMon1 + ld bc, MON_STATS add hl, bc ld d, h ld e, l ; de now points to stats - ld bc, (wPartyMon1Exp + 2) - wPartyMon1Stats + ld bc, (MON_EXP + 2) - MON_STATS add hl, bc ; hl now points to LSB of experience ld b, 1 jp CalcStats ; recalculate stats .useRareCandy push hl - ld bc, wPartyMon1Level - wPartyMon1 + ld bc, MON_LEVEL add hl, bc ; hl now points to level ld a, [hl] ; a = level cp MAX_LEVEL @@ -1521,7 +1521,7 @@ ItemUseMedicine: callfar CalcExperience ; calculate experience for next level and store it at hExperience pop de pop hl - ld bc, wPartyMon1Exp - wPartyMon1Level + ld bc, MON_EXP - MON_LEVEL add hl, bc ; hl now points to MSB of experience ; update experience to minimum for new level ldh a, [hExperience] @@ -1537,7 +1537,7 @@ ItemUseMedicine: push af push de push hl - ld bc, wPartyMon1MaxHP - wPartyMon1 + ld bc, MON_MAXHP add hl, bc ; hl now points to MSB of max HP ld a, [hli] ld b, a @@ -1547,7 +1547,7 @@ ItemUseMedicine: push hl call .recalculateStats pop hl - ld bc, (wPartyMon1MaxHP + 1) - wPartyMon1 + ld bc, (MON_MAXHP + 1) add hl, bc ; hl now points to LSB of max HP pop bc ld a, [hld] @@ -1557,7 +1557,7 @@ ItemUseMedicine: sbc b ld b, a ; bc = the amount of max HP gained from leveling up ; add the amount gained to the current HP - ld de, (wPartyMon1HP + 1) - wPartyMon1MaxHP + ld de, (MON_HP + 1) - MON_MAXHP add hl, de ; hl now points to LSB of current HP ld a, [hl] add c @@ -1576,15 +1576,15 @@ ItemUseMedicine: xor a ; PLAYER_PARTY_DATA ld [wMonDataLocation], a call LoadMonData - ld d, $01 - callfar PrintStatsBox ; display new stats text box - call WaitForTextScrollButtonPress ; wait for button press + ld d, LEVEL_UP_STATS_BOX + callfar PrintStatsBox + call WaitForTextScrollButtonPress xor a ; PLAYER_PARTY_DATA ld [wMonDataLocation], a - predef LearnMoveFromLevelUp ; learn level up move, if any + predef LearnMoveFromLevelUp xor a ld [wForceEvolution], a - callfar TryEvolvingMon ; evolve pokemon, if appropriate + callfar TryEvolvingMon ld a, $01 ld [wUpdateSpritesEnabled], a pop af @@ -1670,11 +1670,11 @@ INCLUDE "data/battle/stat_names.asm" ItemUseBait: ld hl, ThrewBaitText rst _PrintText - ld hl, wEnemyMonActualCatchRate ; catch rate + ld hl, wEnemyMonActualCatchRate srl [hl] ; halve catch rate ld a, BAIT_ANIM - ld hl, wSafariBaitFactor ; bait factor - ld de, wSafariEscapeFactor ; escape factor + ld hl, wSafariBaitFactor + ld de, wSafariEscapeFactor jr BaitRockCommon ; for CASCADEBADGE when used from the @@ -1683,7 +1683,7 @@ ItemUseBait: ItemUseRock: ld hl, ThrewRockText rst _PrintText - ld hl, wEnemyMonActualCatchRate ; catch rate + ld hl, wEnemyMonActualCatchRate ld a, [hl] add a ; double catch rate jr nc, .noCarry @@ -1691,8 +1691,8 @@ ItemUseRock: .noCarry ld [hl], a ld a, ROCK_ANIM - ld hl, wSafariEscapeFactor ; escape factor - ld de, wSafariBaitFactor ; bait factor + ld hl, wSafariEscapeFactor + ld de, wSafariBaitFactor BaitRockCommon: ld [wAnimationID], a @@ -2088,8 +2088,8 @@ ItemUsePokeFlute: ; OUTPUT: ; [wWereAnyMonsAsleep]: set to 1 if any pokemon were asleep WakeUpEntireParty: - ld de, 44 - ld c, 6 + ld de, PARTYMON_STRUCT_LENGTH + ld c, PARTY_LENGTH .loop ld a, [hl] push af @@ -2385,7 +2385,7 @@ ItemUsePPRestore: ld [wPlayerMoveListIndex], a jr nz, .chooseMon ld hl, wPartyMon1Moves - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call GetSelectedMoveOffset push hl ld a, [hl] @@ -2396,8 +2396,8 @@ ItemUsePPRestore: ld a, [wPPRestoreItem] cp ETHER jr nc, .useEther ; if Ether or Max Ether -.usePPUp - ld bc, wPartyMon1PP - wPartyMon1Moves +; use PP Up + ld bc, MON_PP - MON_MOVES add hl, bc ld a, [hl] ; move PP cp 3 << 6 ; have 3 PP Ups already been used? @@ -2427,10 +2427,10 @@ ItemUsePPRestore: cp b ; is the pokemon whose PP was restored active in battle? jr nz, .skipUpdatingInBattleData ld hl, wPartyMon1PP - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld de, wBattleMonPP - ld bc, 4 + ld bc, NUM_MOVES rst _CopyData ; copy party data to in-battle data .skipUpdatingInBattleData ld a, SFX_HEAL_AILMENT @@ -2449,9 +2449,9 @@ ItemUsePPRestore: ld [wMonDataLocation], a call GetMaxPP ld hl, wPartyMon1Moves - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call GetSelectedMoveOffset - ld bc, wPartyMon1PP - wPartyMon1Moves + ld bc, MON_PP - MON_MOVES add hl, bc ; hl now points to move's PP ld a, [wMaxPP] ld b, a @@ -2499,7 +2499,7 @@ ItemUsePPRestore: .elixirLoop push bc ld hl, wPartyMon1Moves - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call GetSelectedMoveOffset ld a, [hl] and a ; does the current slot have a move? @@ -2624,7 +2624,7 @@ ItemUseTMHM: .chooseMon ld hl, wStringBuffer ld de, wTempMoveNameBuffer - ld bc, 14 + ld bc, MOVE_NAME_LENGTH rst _CopyData ; save the move name because DisplayPartyMenu will overwrite it ld a, $ff ld [wUpdateSpritesEnabled], a @@ -2634,7 +2634,7 @@ ItemUseTMHM: push af ld hl, wTempMoveNameBuffer ld de, wStringBuffer - ld bc, 14 + ld bc, MOVE_NAME_LENGTH rst _CopyData pop af jr nc, .checkIfAbleToLearnMove @@ -2839,14 +2839,14 @@ GotOffBicycleText: ; [wCurrentMenuItem] = index of move (when using a PP Up) RestoreBonusPP: ld hl, wPartyMon1Moves - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH ld a, [wWhichPokemon] call AddNTimes push hl ld de, wNormalMaxPPList - 1 predef LoadMovePPs ; loads the normal max PP of each of the pokemon's moves to wNormalMaxPPList pop hl - lb bc, 0, wPartyMon1PP - wPartyMon1Moves + lb bc, 0, MON_PP - MON_MOVES add hl, bc ; hl now points to move 1 PP ld de, wNormalMaxPPList ld b, 0 ; initialize move counter to zero @@ -2931,13 +2931,13 @@ GetMaxPP: ld a, [wMonDataLocation] and a ld hl, wPartyMon1Moves - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH jr z, .sourceWithMultipleMon ld hl, wEnemyMon1Moves dec a jr z, .sourceWithMultipleMon ld hl, wBoxMon1Moves - ld bc, wBoxMon2 - wBoxMon1 + ld bc, BOXMON_STRUCT_LENGTH dec a jr z, .sourceWithMultipleMon ld hl, wDayCareMonMoves @@ -2964,7 +2964,7 @@ GetMaxPP: ld b, a ; b = normal max PP pop hl push bc - ld bc, wPartyMon1PP - wPartyMon1Moves ; PP offset if not player's in-battle pokemon data + ld bc, MON_PP - MON_MOVES ; PP offset if not player's in-battle pokemon data ld a, [wMonDataLocation] cp 4 ; player's in-battle pokemon? jr nz, .addPPOffset @@ -3112,29 +3112,33 @@ IsKeyItem_:: INCLUDE "data/items/key_items.asm" +; store the new mon in the first slot, shifting all existing box data down SendNewMonToBox: ld de, wBoxCount ld a, [de] inc a ld [de], a + ld a, [wCurPartySpecies] ld [wCurSpecies], a ld c, a -.loop +.shiftSpeciesLoop inc de ld a, [de] ld b, a ld a, c ld c, b ld [de], a - cp $ff - jr nz, .loop + cp -1 + jr nz, .shiftSpeciesLoop + call GetMonHeader ld hl, wBoxMonOT ld bc, NAME_LENGTH ld a, [wBoxCount] dec a - jr z, .skip + jr z, .skipOTshift ; if the box was empty, there is nothing to shift + dec a call AddNTimes push hl @@ -3146,7 +3150,7 @@ SendNewMonToBox: ld a, [wBoxCount] dec a ld b, a -.loop2 +.shiftMonOTLoop push bc push hl ld bc, NAME_LENGTH @@ -3158,15 +3162,18 @@ SendNewMonToBox: add hl, bc pop bc dec b - jr nz, .loop2 -.skip + jr nz, .shiftMonOTLoop + +.skipOTshift ld hl, wPlayerName - ld de, wBoxMonOT + ld de, wBoxMon1OT ld bc, NAME_LENGTH rst _CopyData + ld a, [wBoxCount] dec a - jr z, .skip2 + jr z, .skipNickShift + ld hl, wBoxMonNicks ld bc, NAME_LENGTH dec a @@ -3180,7 +3187,7 @@ SendNewMonToBox: ld a, [wBoxCount] dec a ld b, a -.loop3 +.shiftNickLoop push bc push hl ld bc, NAME_LENGTH @@ -3192,8 +3199,8 @@ SendNewMonToBox: add hl, bc pop bc dec b - jr nz, .loop3 -.skip2 + jr nz, .shiftNickLoop +.skipNickShift ;;;;;;;;;; PureRGBnote: ADDED: when in bills garden, if a pikachu is caught, skip nicknaming automatically. ld a, [wCurMap] cp BILLS_GARDEN @@ -3214,13 +3221,14 @@ SendNewMonToBox: .skipAskName ld a, [wBoxCount] dec a - jr z, .skip3 + jr z, .skipMonDataShift + ld hl, wBoxMons - ld bc, wBoxMon2 - wBoxMon1 + ld bc, BOXMON_STRUCT_LENGTH dec a call AddNTimes push hl - ld bc, wBoxMon2 - wBoxMon1 + ld bc, BOXMON_STRUCT_LENGTH add hl, bc ld d, h ld e, l @@ -3228,20 +3236,21 @@ SendNewMonToBox: ld a, [wBoxCount] dec a ld b, a -.loop4 +.shiftMonDataLoop push bc push hl - ld bc, wBoxMon2 - wBoxMon1 + ld bc, BOXMON_STRUCT_LENGTH rst _CopyData pop hl ld d, h ld e, l - ld bc, wBoxMon1 - wBoxMon2 + ld bc, -BOXMON_STRUCT_LENGTH add hl, bc pop bc dec b - jr nz, .loop4 -.skip3 + jr nz, .shiftMonDataLoop + +.skipMonDataShift ;;;;;;;;;; PureRGBnote: Reset the enemy pokemon's types in case they were remapped during battle ld a, [wMonHType1] ld [wEnemyMonType1], a @@ -3277,11 +3286,12 @@ SendNewMonToBox: inc de xor a ld b, NUM_STATS * 2 -.loop5 +.statLoop ld [de], a inc de dec b - jr nz, .loop5 + jr nz, .statLoop + ld hl, wEnemyMonDVs ld a, [hli] ld [de], a @@ -3290,12 +3300,12 @@ SendNewMonToBox: ld [de], a ld hl, wEnemyMonPP ld b, NUM_MOVES -.loop6 +.movePPLoop ld a, [hli] inc de ld [de], a dec b - jr nz, .loop6 + jr nz, .movePPLoop ret ; checks if the tile in front of the player is a shore or water tile @@ -3483,12 +3493,12 @@ Load2DigitNumberBelow20: cp 10 jr c, .singleDigit sub 10 - ld [hl], "1" + ld [hl], '1' inc hl .singleDigit add NUMBER_CHAR_OFFSET ld [hli], a - ld [hl], "@" + ld [hl], '@' ret ;;;;;;;;;; diff --git a/engine/items/tmhm.asm b/engine/items/tmhm.asm index 626e6f6546..82ebb67a97 100644 --- a/engine/items/tmhm.asm +++ b/engine/items/tmhm.asm @@ -2,7 +2,7 @@ CheckIfMoveIsKnown: ld a, [wWhichPokemon] ld hl, wPartyMon1Moves - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld a, [wMoveNum] ld b, a diff --git a/engine/items/town_map.asm b/engine/items/town_map.asm index 2c25ac812d..8978df0fe0 100644 --- a/engine/items/town_map.asm +++ b/engine/items/town_map.asm @@ -21,11 +21,11 @@ DisplayTownMap: call PlaceString ld hl, wShadowOAM ld de, wTownMapSavedOAM - ld bc, 4 * 4 + ld bc, OBJ_SIZE * 4 rst _CopyData ld hl, vSprites tile BIRD_BASE_TILE ld de, TownMapCursor - lb bc, BANK(TownMapCursor), (TownMapCursorEnd - TownMapCursor) / $8 + lb bc, BANK(TownMapCursor), (TownMapCursorEnd - TownMapCursor) / TILE_1BPP_SIZE call CopyVideoDataDouble xor a ld [wWhichTownMapLocation], a @@ -58,27 +58,27 @@ DisplayTownMap: ld a, [hli] ld [de], a inc de - cp "@" + cp '@' jr nz, .copyMapName hlcoord 1, 0 ld de, wNameBuffer call PlaceString ld hl, wShadowOAMSprite04 ld de, wTownMapSavedOAM + 16 - ld bc, 4 * 4 + ld bc, OBJ_SIZE * 4 rst _CopyData .inputLoop call TownMapSpriteBlinkingAnimation call JoypadLowSensitivity ldh a, [hJoy5] ld b, a - and A_BUTTON | B_BUTTON | D_UP | D_DOWN + and PAD_A | PAD_B | PAD_UP | PAD_DOWN jr z, .inputLoop ld a, SFX_TINK rst _PlaySound - bit BIT_D_UP, b + bit B_PAD_UP, b jr nz, .pressedUp - bit BIT_D_DOWN, b + bit B_PAD_DOWN, b jr nz, .pressedDown xor a ld [wTownMapSpriteBlinkingEnabled], a @@ -185,7 +185,7 @@ LoadTownMap_Fly_Common: ;;;;;;;;;; ld de, TownMapUpArrow ld hl, vChars1 tile $6d - lb bc, BANK(TownMapUpArrow), (TownMapUpArrowEnd - TownMapUpArrow) / $8 + lb bc, BANK(TownMapUpArrow), (TownMapUpArrowEnd - TownMapUpArrow) / TILE_1BPP_SIZE call CopyVideoDataDouble call BuildFlyLocationsList ld hl, wUpdateSpritesEnabled @@ -202,7 +202,7 @@ LoadTownMap_Fly_Common: ld hl, wFlyLocationsList decoord 18, 0 .townMapFlyLoop - ld a, " " + ld a, ' ' ld [de], a push hl push hl @@ -219,9 +219,9 @@ LoadTownMap_Fly_Common: ld c, 5 ; PureRGBnote: CHANGED: cut the artificial delay between fly selections to 1/3 of what it was in the vanilla game rst _DelayFrames hlcoord 18, 0 - ld [hl], "▲" + ld [hl], '▲' hlcoord 19, 0 - ld [hl], "▼" + ld [hl], '▼' pop hl .inputLoop push hl @@ -230,15 +230,15 @@ LoadTownMap_Fly_Common: ldh a, [hJoy5] ld b, a pop hl - and A_BUTTON | B_BUTTON | D_UP | D_DOWN + and PAD_A | PAD_B | PAD_UP | PAD_DOWN jr z, .inputLoop - bit BIT_A_BUTTON, b + bit B_PAD_A, b jr nz, .pressedA ld a, SFX_TINK rst _PlaySound - bit BIT_D_UP, b + bit B_PAD_UP, b jr nz, .pressedUp - bit BIT_D_DOWN, b + bit B_PAD_DOWN, b jr nz, .pressedDown jr .pressedB .pressedA @@ -410,11 +410,11 @@ DrawPlayerOrBirdSprite: ld a, [hli] ld [de], a inc de - cp "@" + cp '@' jr nz, .loop ld hl, wShadowOAM ld de, wTownMapSavedOAM - ld bc, NUM_SPRITE_OAM_STRUCTS * 4 + ld bc, OAM_COUNT * 4 jp CopyData TownMapCoordsToOAMCoords: @@ -507,7 +507,7 @@ WriteSymmetricMonPartySpriteOAM: ld [hli], a ; tile ld a, [wSymmetricSpriteOAMAttributes] ld [hli], a ; attributes - xor 1 << OAM_X_FLIP + xor OAM_XFLIP ld [wSymmetricSpriteOAMAttributes], a inc d ld a, 8 @@ -581,16 +581,16 @@ TownMapSpriteBlinkingAnimation:: ; show sprites when the counter reaches 50 ld hl, wTownMapSavedOAM ld de, wShadowOAM - ld bc, (NUM_SPRITE_OAM_STRUCTS - 4) * 4 + ld bc, (OAM_COUNT - 4) * 4 rst _CopyData xor a jr .done .hideSprites - ld hl, wShadowOAM - ld b, NUM_SPRITE_OAM_STRUCTS - 4 - ld de, $4 + ld hl, wShadowOAMSprite00YCoord + ld b, OAM_COUNT - 4 + ld de, OBJ_SIZE .hideSpritesLoop - ld [hl], $a0 + ld [hl], SCREEN_HEIGHT_PX + OAM_Y_OFS add hl, de dec b jr nz, .hideSpritesLoop diff --git a/engine/joypad.asm b/engine/joypad.asm index c124361777..0eaacdfe94 100644 --- a/engine/joypad.asm +++ b/engine/joypad.asm @@ -3,7 +3,7 @@ _Joypad:: ; hJoyPressed: (hJoyLast ^ hJoyInput) & hJoyInput ldh a, [hJoyInput] - cp A_BUTTON + B_BUTTON + SELECT + START ; soft reset + cp PAD_BUTTONS ; soft reset jp z, TrySoftReset ld b, a diff --git a/engine/link/cable_club.asm b/engine/link/cable_club.asm index dfbb659f79..9180f9af60 100644 --- a/engine/link/cable_club.asm +++ b/engine/link/cable_club.asm @@ -109,16 +109,16 @@ CableClub_DoBattleOrTradeAgain: call Delay3 xor a ldh [hSerialSendData], a - ld a, START_TRANSFER_INTERNAL_CLOCK + ld a, SC_START | SC_INTERNAL ldh [rSC], a rst _DelayFrame xor a ldh [hSerialSendData], a - ld a, START_TRANSFER_INTERNAL_CLOCK + ld a, SC_START | SC_INTERNAL ldh [rSC], a .skipSendingTwoZeroBytes call Delay3 - ld a, 1 << SERIAL + ld a, IE_SERIAL ldh [rIE], a ld hl, wSerialRandomNumberListBlock ld de, wSerialOtherGameboyRandomNumberListBlock @@ -139,7 +139,7 @@ CableClub_DoBattleOrTradeAgain: ld bc, 200 vc_hook Wireless_ExchangeBytes_patch_lists call Serial_ExchangeBytes - ld a, (1 << SERIAL) | (1 << TIMER) | (1 << VBLANK) + ld a, IE_SERIAL | IE_TIMER | IE_VBLANK ldh [rIE], a ld a, SFX_STOP_ALL_MUSIC rst _PlaySound @@ -330,7 +330,7 @@ TradeCenter_SelectMon: ld [wMenuWatchMovingOutOfBounds], a inc a ld [wWhichTradeMonSelectionMenu], a - ld a, D_DOWN | D_LEFT | A_BUTTON + ld a, PAD_DOWN | PAD_LEFT | PAD_A ld [wMenuWatchedKeys], a ld a, [wEnemyPartyCount] ld [wMaxMenuItem], a @@ -346,7 +346,7 @@ TradeCenter_SelectMon: res BIT_DOUBLE_SPACED_MENU, [hl] and a jp z, .getNewInput - bit BIT_A_BUTTON, a + bit B_PAD_A, a jr z, .enemyMonMenu_ANotPressed ; if A button pressed ld a, [wMaxMenuItem] @@ -363,7 +363,7 @@ TradeCenter_SelectMon: call TradeCenter_DisplayStats jp .getNewInput .enemyMonMenu_ANotPressed - bit BIT_D_LEFT, a + bit B_PAD_LEFT, a jr z, .enemyMonMenu_LeftNotPressed ; if Left pressed, switch back to the player mon menu xor a ; player mon menu @@ -380,14 +380,14 @@ TradeCenter_SelectMon: ld [wCurrentMenuItem], a jr .playerMonMenu .enemyMonMenu_LeftNotPressed - bit BIT_D_DOWN, a + bit B_PAD_DOWN, a jp z, .getNewInput jp .selectedCancelMenuItem ; jump if Down pressed .playerMonMenu xor a ; player mon menu ld [wWhichTradeMonSelectionMenu], a ld [wMenuWatchMovingOutOfBounds], a - ld a, D_DOWN | D_RIGHT | A_BUTTON + ld a, PAD_DOWN | PAD_RIGHT | PAD_A ld [wMenuWatchedKeys], a ld a, [wPartyCount] ld [wMaxMenuItem], a @@ -407,7 +407,7 @@ TradeCenter_SelectMon: and a ; was anything pressed? jp z, .getNewInput .playerMonMenu_SomethingPressed - bit BIT_A_BUTTON, a + bit B_PAD_A, a jr z, .playerMonMenu_ANotPressed jp .chosePlayerMon ; jump if A button pressed ; unreachable code @@ -415,7 +415,7 @@ TradeCenter_SelectMon: call TradeCenter_DisplayStats jp .getNewInput .playerMonMenu_ANotPressed - bit BIT_D_RIGHT, a + bit B_PAD_RIGHT, a jr z, .playerMonMenu_RightNotPressed ; if Right pressed, switch to the enemy mon menu ld a, $1 ; enemy mon menu @@ -434,7 +434,7 @@ TradeCenter_SelectMon: .notPastLastEnemyMon jp .enemyMonMenu .playerMonMenu_RightNotPressed - bit BIT_D_DOWN, a + bit B_PAD_DOWN, a jp nz, .selectedCancelMenuItem ; jump if Down pressed .getNewInput ld a, [wWhichTradeMonSelectionMenu] @@ -467,16 +467,16 @@ TradeCenter_SelectMon: ld a, 16 ld [wTopMenuItemY], a .selectStatsMenuItem - ld a, " " + ld a, ' ' ldcoord_a 11, 16 - ld a, D_RIGHT | B_BUTTON | A_BUTTON + ld a, PAD_RIGHT | PAD_B | PAD_A ld [wMenuWatchedKeys], a ld a, 1 ld [wTopMenuItemX], a call HandleMenuInput - bit BIT_D_RIGHT, a + bit B_PAD_RIGHT, a jr nz, .selectTradeMenuItem - bit BIT_B_BUTTON, a + bit B_PAD_B, a jr z, .displayPlayerMonStats .cancelPlayerMonChoice pop af @@ -484,16 +484,16 @@ TradeCenter_SelectMon: call LoadScreenTilesFromBuffer1 jp .playerMonMenu .selectTradeMenuItem - ld a, " " + ld a, ' ' ldcoord_a 1, 16 - ld a, D_LEFT | B_BUTTON | A_BUTTON + ld a, PAD_LEFT | PAD_B | PAD_A ld [wMenuWatchedKeys], a ld a, 11 ld [wTopMenuItemX], a call HandleMenuInput - bit BIT_D_LEFT, a + bit B_PAD_LEFT, a jr nz, .selectStatsMenuItem - bit BIT_B_BUTTON, a + bit B_PAD_B, a jr nz, .cancelPlayerMonChoice jr .choseTrade .displayPlayerMonStats @@ -527,28 +527,28 @@ TradeCenter_SelectMon: cp b jp nz, .getNewInput hl_deref wMenuCursorLocation - ld [hl], " " + ld [hl], ' ' .cancelMenuItem_Loop - ld a, "▶" ; filled arrow cursor + ld a, '▶' ; filled arrow cursor ldcoord_a 1, 16 .cancelMenuItem_JoypadLoop call JoypadLowSensitivity ldh a, [hJoy5] and a ; pressed anything? jr z, .cancelMenuItem_JoypadLoop - bit BIT_A_BUTTON, a + bit B_PAD_A, a jr nz, .cancelMenuItem_APressed - bit BIT_D_UP, a + bit B_PAD_UP, a jr z, .cancelMenuItem_JoypadLoop ; if Up pressed - ld a, " " + ld a, ' ' ldcoord_a 1, 16 ld a, [wPartyCount] dec a ld [wCurrentMenuItem], a jp .playerMonMenu .cancelMenuItem_APressed - ld a, "▷" ; unfilled arrow cursor + ld a, '▷' ; unfilled arrow cursor ldcoord_a 1, 16 ld a, $f ld [wSerialExchangeNybbleSendData], a @@ -596,7 +596,7 @@ TradeCenter_PlaceSelectedEnemyMonMenuCursor: hlcoord 1, 9 ld bc, SCREEN_WIDTH call AddNTimes - ld [hl], "▷" ; cursor + ld [hl], '▷' ; cursor ret TradeCenter_DisplayStats: @@ -650,7 +650,7 @@ TradeCenter_PrintPartyListNames: pop de inc de pop hl - ld bc, 20 + ld bc, SCREEN_WIDTH add hl, bc pop bc inc c @@ -737,7 +737,7 @@ TradeCenter_Trade: rst _CopyData ld hl, wPartyMon1Species ld a, [wTradingWhichPlayerMon] - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ;;;;;;;;;; PureRGBnote: ADDED: need to show alternate palette pokemon for the player's pokemon if the flag is set ld bc, wPartyMon1Flags - wPartyMon1 @@ -745,7 +745,7 @@ TradeCenter_Trade: ld a, [hl] and 1 ld [wIsAltPalettePkmn], a ; should the player's pokemon be shown as having an alt palette - ld bc, wPartyMon1OTID - wPartyMon1Flags + ld bc, MON_OTID ;;;;;;;;;; add hl, bc ld a, [hli] @@ -760,7 +760,7 @@ TradeCenter_Trade: rst _CopyData ld hl, wEnemyMons ld a, [wTradingWhichEnemyMon] - ld bc, wEnemyMon2 - wEnemyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ;;;;;;;;;; PureRGBnote: ADDED: need to show alternate palette pokemon for the received pokemon if the flag is set ld bc, wEnemyMon1Flags - wEnemyMon1 @@ -768,7 +768,7 @@ TradeCenter_Trade: ld a, [hl] and 1 ld [wIsAltPalettePkmnData], a ; should the received pokemon be shown as having an alt palette - ld bc, wEnemyMon1OTID - wEnemyMon1Flags + ld bc, MON_OTID ;;;;;;;;;; add hl, bc ld a, [hli] @@ -797,10 +797,10 @@ TradeCenter_Trade: ld [wCurPartySpecies], a ld hl, wEnemyMons ld a, c - ld bc, wEnemyMon2 - wEnemyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld de, wLoadedMon - ld bc, wEnemyMon2 - wEnemyMon1 + ld bc, PARTYMON_STRUCT_LENGTH rst _CopyData call AddEnemyMonToPlayerParty ld a, [wPartyCount] @@ -852,7 +852,7 @@ TradeCenter_Trade: hlcoord 1, 14 ld de, TradeCompleted call PlaceString - predef SaveSAVtoSRAM2 + predef SavePartyAndDexData ; this allows reset into Pokecenter vc_hook Trade_save_game_end ld c, 50 rst _DelayFrames @@ -942,7 +942,7 @@ CableClub_TextBoxBorder: push hl ld a, $7b ; border left vertical line tile ld [hli], a - ld a, " " + ld a, ' ' call CableClub_DrawHorizontalLine ld [hl], $77 ; border right vertical line tile pop hl @@ -969,5 +969,5 @@ CableClub_DrawHorizontalLine: LoadTrainerInfoTextBoxTiles: ld de, TrainerInfoTextBoxTileGraphics ld hl, vChars2 tile $76 - lb bc, BANK(TrainerInfoTextBoxTileGraphics), (TrainerInfoTextBoxTileGraphicsEnd - TrainerInfoTextBoxTileGraphics) / $10 + lb bc, BANK(TrainerInfoTextBoxTileGraphics), (TrainerInfoTextBoxTileGraphicsEnd - TrainerInfoTextBoxTileGraphics) / TILE_SIZE jp CopyVideoData diff --git a/engine/link/cable_club_npc.asm b/engine/link/cable_club_npc.asm index 3ed606e357..bcd647f4d0 100644 --- a/engine/link/cable_club_npc.asm +++ b/engine/link/cable_club_npc.asm @@ -26,7 +26,7 @@ CableClubNPC:: ldh [rSB], a xor a ldh [hSerialReceiveData], a - ld a, START_TRANSFER_EXTERNAL_CLOCK + ld a, SC_START | SC_EXTERNAL ; This vc_hook causes the Virtual Console to set [hSerialConnectionStatus] to ; USING_INTERNAL_CLOCK, which allows the player to proceed past the link ; receptionist's "Please wait." It assumes that hSerialConnectionStatus is at @@ -46,7 +46,7 @@ CableClubNPC:: jr z, .failedToEstablishConnection ld a, ESTABLISH_CONNECTION_WITH_INTERNAL_CLOCK ldh [rSB], a - ld a, START_TRANSFER_INTERNAL_CLOCK + ld a, SC_START | SC_INTERNAL ldh [rSC], a rst _DelayFrame jr .establishConnectionLoop @@ -67,7 +67,7 @@ CableClubNPC:: and a jr nz, .choseNo vc_hook Wireless_TryQuickSave_block_input - callfar SaveSAVtoSRAM + callfar SaveGameData call WaitForSoundToFinish ld a, SFX_SAVE call PlaySoundWaitForCurrent @@ -161,6 +161,6 @@ CloseLinkConnection: ldh [rSB], a xor a ldh [hSerialReceiveData], a - ld a, START_TRANSFER_EXTERNAL_CLOCK + ld a, SC_START | SC_EXTERNAL ldh [rSC], a ret diff --git a/engine/menus/change_box_menu.asm b/engine/menus/change_box_menu.asm index f074a3633a..ef7b36a7e9 100644 --- a/engine/menus/change_box_menu.asm +++ b/engine/menus/change_box_menu.asm @@ -25,7 +25,7 @@ LoadBillsPCExtraTiles:: DisplayChangeBoxMenu: xor a ldh [hAutoBGTransferEnabled], a - ld a, A_BUTTON | B_BUTTON + ld a, PAD_A | PAD_B ld [wMenuWatchedKeys], a ld a, 11 ld [wMaxMenuItem], a @@ -147,14 +147,14 @@ DrawCurrentBoxPrompt:: push hl ld a, $76 ; "No" tile ld [hli], a - ld a, "." + ld a, '.' ld [hli], a ld a, [wCurrentBoxNum] and $7f cp 9 jr c, .singleDigitBoxNum sub 9 - ld [hl], "1" + ld [hl], '1' inc hl add NUMBER_CHAR_OFFSET jr .next diff --git a/engine/menus/custom_list_menu.asm b/engine/menus/custom_list_menu.asm index ce5656058f..9eb0cb6b8a 100644 --- a/engine/menus/custom_list_menu.asm +++ b/engine/menus/custom_list_menu.asm @@ -106,7 +106,7 @@ CheckLoadTypes: predef PrintMonType hlcoord 11, 16 ld a, [hl] - cp " " + cp ' ' ret z ; if no type printed for the second type at this point, don't print "Type2:" on that line hlcoord 5, 16 ld de, MenuType2Text diff --git a/engine/menus/display_text_id_init.asm b/engine/menus/display_text_id_init.asm index 7356b52705..18a2e949f3 100644 --- a/engine/menus/display_text_id_init.asm +++ b/engine/menus/display_text_id_init.asm @@ -38,8 +38,8 @@ DisplayTextIDInit:: ; 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 + ld c, NUM_SPRITESTATEDATA_STRUCTS - 1 + ld de, SPRITESTATEDATA1_LENGTH .spriteFacingDirectionCopyLoop ld a, [hl] ; x#SPRITESTATEDATA1_FACINGDIRECTION inc h @@ -51,7 +51,8 @@ DisplayTextIDInit:: ; loop to force all the sprites in the middle of animation to stand still ; (so that they don't like they're frozen mid-step during the dialogue) ld hl, wSpritePlayerStateData1ImageIndex - ld de, $10 + ld de, SPRITESTATEDATA1_LENGTH + ASSERT NUM_SPRITESTATEDATA_STRUCTS == SPRITESTATEDATA1_LENGTH ld c, e .spriteStandStillLoop ld a, [hl] @@ -64,7 +65,7 @@ DisplayTextIDInit:: add hl, de dec c jr nz, .spriteStandStillLoop - ld b, $9c ; window background address + ld b, HIGH(vBGMap1) call CopyScreenTileBufferToVRAM ; transfer background in WRAM to VRAM xor a ldh [hWY], a ; put the window on the screen diff --git a/engine/menus/draw_start_menu.asm b/engine/menus/draw_start_menu.asm index fdb47b024e..ec6b52d8d1 100644 --- a/engine/menus/draw_start_menu.asm +++ b/engine/menus/draw_start_menu.asm @@ -10,7 +10,7 @@ DrawStartMenu:: .drawTextBoxBorder call TextBoxBorder ; PureRGBnote: CHANGED: now SELECT button is tracked on this menu. Used in the new box-switching anywhere functionality. - ld a, D_DOWN | D_UP | START | B_BUTTON | A_BUTTON | SELECT + ld a, PAD_DOWN | PAD_UP | PAD_START | PAD_B | PAD_A | PAD_SELECT ld [wMenuWatchedKeys], a ld a, $02 ld [wTopMenuItemY], a ; Y position of first menu choice diff --git a/engine/menus/front_sprite_options.asm b/engine/menus/front_sprite_options.asm index 33a05ebb9e..b89389bb8d 100644 --- a/engine/menus/front_sprite_options.asm +++ b/engine/menus/front_sprite_options.asm @@ -38,7 +38,7 @@ DisplayFrontSpriteOptions: FrontSpriteSelectButtonDefault: ld a, [hJoy5] - bit BIT_SELECT, a + bit B_PAD_SELECT, a ret z ld a, [wTopMenuItemY] cp PAGE_CONTROLS_Y_COORD ; is cursor on NEXT/PREV row? @@ -89,7 +89,7 @@ DrawChildMenuDigit: add NUMBER_CHAR_OFFSET hlcoord 14, PAGE_CONTROLS_Y_COORD ld [hli], a - ld [hl], "→" + ld [hl], '→' ret DrawFrontSpriteOptionsMenu: diff --git a/engine/menus/league_pc.asm b/engine/menus/league_pc.asm index 96b9012a3e..e526e3e138 100644 --- a/engine/menus/league_pc.asm +++ b/engine/menus/league_pc.asm @@ -58,7 +58,7 @@ LeaguePCShowTeam: call LeaguePCShowMon call WaitForTextScrollButtonPress ldh a, [hJoyHeld] - bit BIT_B_BUTTON, a + bit B_PAD_B, a jr nz, .exit ld hl, wHallOfFame + HOF_MON ld de, wHallOfFame diff --git a/engine/menus/main_menu.asm b/engine/menus/main_menu.asm index 3eb2ea2f4d..69154b8ee3 100644 --- a/engine/menus/main_menu.asm +++ b/engine/menus/main_menu.asm @@ -8,7 +8,7 @@ MainMenu: call CheckForPlayerNameInSRAM jr nc, .mainMenuLoop - predef LoadSAV + predef TryLoadSaveFile .mainMenuLoop ld c, 20 @@ -64,12 +64,12 @@ MainMenu: ld [wTopMenuItemX], a inc a ld [wTopMenuItemY], a - ld a, A_BUTTON | B_BUTTON | START + ld a, PAD_A | PAD_B | PAD_START ld [wMenuWatchedKeys], a ld a, [wSaveFileStatus] ld [wMaxMenuItem], a call HandleMenuInput - bit BIT_B_BUTTON, a + bit B_PAD_B, a jp nz, DisplayTitleScreen ; if so, go back to the title screen ld c, 20 rst _DelayFrames @@ -106,9 +106,9 @@ MainMenu: ldh [hJoyHeld], a call Joypad ldh a, [hJoyHeld] - bit BIT_A_BUTTON, a + bit B_PAD_A, a jr nz, .pressedA - bit BIT_B_BUTTON, a + bit B_PAD_B, a jp nz, .mainMenuLoop jr .inputLoop .pressedA @@ -182,7 +182,7 @@ LinkMenu: ld a, 2 ld [hli], a ASSERT wMaxMenuItem + 1 == wMenuWatchedKeys - ASSERT 2 + 1 == A_BUTTON | B_BUTTON + ASSERT 2 + 1 == PAD_A | PAD_B inc a ld [hli], a ASSERT wMenuWatchedKeys + 1 == wLastMenuItem @@ -190,7 +190,7 @@ LinkMenu: ld [hl], a .waitForInputLoop call HandleMenuInput - and A_BUTTON | B_BUTTON + and PAD_A | PAD_B add a add a ld b, a @@ -240,13 +240,13 @@ LinkMenu: jr nz, .skipStartingTransfer rst _DelayFrame rst _DelayFrame - ld a, START_TRANSFER_INTERNAL_CLOCK + ld a, SC_START | SC_INTERNAL ldh [rSC], a .skipStartingTransfer - lb bc, " ", " " - ld d, "▷" + lb bc, ' ', ' ' + ld d, '▷' ld a, [wLinkMenuSelectionSendBuffer] - and B_BUTTON << 2 ; was B button pressed? + and PAD_B << 2 ; was B button pressed? jr nz, .updateCursorPosition ; A button was pressed ld a, [wCurrentMenuItem] @@ -269,7 +269,7 @@ LinkMenu: rst _DelayFrames call LoadScreenTilesFromBuffer1 ld a, [wLinkMenuSelectionSendBuffer] - and B_BUTTON << 2 ; was B button pressed? + and PAD_B << 2 ; was B button pressed? jr nz, .choseCancel ; cancel if B pressed ld a, [wCurrentMenuItem] cp $2 @@ -488,15 +488,17 @@ CheckForPlayerNameInSRAM: ; Check if the player name data in SRAM has a string terminator character ; (indicating that a name may have been saved there) and return whether it does ; in carry. - ld a, SRAM_ENABLE - ld [MBC1SRamEnable], a - ld a, 1 - ld [MBC1SRamBankingMode], a - ld [MBC1SRamBank], a + ld a, RAMG_SRAM_ENABLE + ld [rRAMG], a + ld a, BMODE_ADVANCED + ld [rBMODE], a + ASSERT BANK(sPlayerName) == BMODE_ADVANCED + ld [rRAMB], a call CheckSaveFileExists ; PureRGBnote: MOVED: this code was moved to home since it is used on booting the game to load options early. - ld a, 0 - ld [MBC1SRamEnable], a - ld [MBC1SRamBankingMode], a + ld a, RAMG_SRAM_DISABLE + ld [rRAMG], a + ld [rBMODE], a + ASSERT RAMG_SRAM_DISABLE == BMODE_SIMPLE jr c, .found ; not found and a @@ -511,10 +513,11 @@ CheckSaveFileExists:: ld hl, sPlayerName .loop ld a, [hli] - cp "@" + cp '@' jr z, .found dec b jr nz, .loop +; not found and a ret .found diff --git a/engine/menus/map_pokemon_areas.asm b/engine/menus/map_pokemon_areas.asm index 4435cb2d6a..7af78d80a9 100644 --- a/engine/menus/map_pokemon_areas.asm +++ b/engine/menus/map_pokemon_areas.asm @@ -254,13 +254,13 @@ DisplayWildLocations: call FillMemory pop af ldh a, [hJoy5] - bit BIT_A_BUTTON, a + bit B_PAD_A, a jr nz, .exit - bit BIT_B_BUTTON, a + bit B_PAD_B, a jr nz, .exit - bit BIT_D_LEFT, a + bit B_PAD_LEFT, a jr nz, .getPrevState - bit BIT_D_RIGHT, a + bit B_PAD_RIGHT, a jr nz, .getNextState .exit xor a @@ -281,7 +281,7 @@ DisplayWildLocations: jp .goToNextState GetMonAreaInputButtons: - ld a, B_BUTTON + ld a, PAD_B ld [wMenuWatchedKeys], a call FindNextMonAreaState call nz, .hasRight @@ -290,12 +290,12 @@ GetMonAreaInputButtons: ret .hasRight ld a, [wMenuWatchedKeys] - or D_RIGHT + or PAD_RIGHT ld [wMenuWatchedKeys], a ret .hasLeft ld a, [wMenuWatchedKeys] - or D_LEFT + or PAD_LEFT ld [wMenuWatchedKeys], a ret diff --git a/engine/menus/movedex.asm b/engine/menus/movedex.asm index 2ea16e1d61..44bd7a6666 100644 --- a/engine/menus/movedex.asm +++ b/engine/menus/movedex.asm @@ -49,7 +49,7 @@ ShowMovedexMenu: inc hl ld a, 6 ld [hli], a ; max menu item ID - ld [hl], D_LEFT | D_RIGHT | B_BUTTON | A_BUTTON | SELECT | START + ld [hl], PAD_LEFT | PAD_RIGHT | PAD_B | PAD_A | PAD_SELECT | PAD_START call HandleMovedexListMenu jr c, .goToMoveData ; if the player chose a move from the list cp 1 @@ -203,16 +203,16 @@ HandleMovedexListMenu: call Delay3 call GBPalNormal call HandleMenuInput - bit BIT_START, a + bit B_PAD_START, a jp nz, .startPressed - bit BIT_SELECT, a + bit B_PAD_SELECT, a jp nz, .selectPressed - bit BIT_B_BUTTON, a + bit B_PAD_B, a jp nz, .buttonBPressed - bit BIT_A_BUTTON, a + bit B_PAD_A, a jp nz, .buttonAPressed .checkIfUpPressed - bit BIT_D_UP, a + bit B_PAD_UP, a jr z, .checkIfDownPressed .upPressed ; scroll up one row ld a, [wListScrollOffset] @@ -222,7 +222,7 @@ HandleMovedexListMenu: ld [wListScrollOffset], a jp .loop .checkIfDownPressed - bit BIT_D_DOWN, a + bit B_PAD_DOWN, a jr z, .checkIfRightPressed .downPressed ; scroll down one row ld a, [wDexMaxSeenMove] @@ -237,7 +237,7 @@ HandleMovedexListMenu: ld [wListScrollOffset], a jp .loop .checkIfRightPressed - bit BIT_D_RIGHT, a + bit B_PAD_RIGHT, a jr z, .checkIfLeftPressed .rightPressed ; scroll down 7 rows ld a, [wDexMaxSeenMove] @@ -255,7 +255,7 @@ HandleMovedexListMenu: ld [wListScrollOffset], a jp .loop .checkIfLeftPressed ; scroll up 7 rows - bit BIT_D_LEFT, a + bit B_PAD_LEFT, a jr z, .buttonAPressed .leftPressed ld a, [wListScrollOffset] @@ -433,9 +433,9 @@ ShowNextMoveData: call PlaceString hlcoord 14, 1 - ld a, "№" + ld a, '№' ld [hli], a - ld a, "" + ld a, '' ld [hli], a ld de, wMovedexMoveID lb bc, LEADING_ZEROES | 1, 3 @@ -514,21 +514,21 @@ ShowNextMoveData: .printDescription ; start by storing the buttons we will track while displaying the description - ld a, B_BUTTON + ld a, PAD_B ld b, a ld a, [wStoredMovedexListIndex] ld c, a ld a, [wDexMaxSeenMove] cp c jr z, .noRight - ld a, D_RIGHT + ld a, PAD_RIGHT or b ld b, a .noRight ld a, [wDexMinSeenMove] cp c jr z, .noLeft - ld a, D_LEFT + ld a, PAD_LEFT or b ld b, a .noLeft @@ -569,11 +569,11 @@ ShowNextMoveData: and c jr z, .waitForButtonPress .dontLoop - bit BIT_B_BUTTON, b + bit B_PAD_B, b jr nz, .closeMenu - bit BIT_D_LEFT, b + bit B_PAD_LEFT, b jr nz, .prevMove - bit BIT_D_RIGHT, b + bit B_PAD_RIGHT, b jr nz, .nextMove jr .waitForButtonPress .closeMenu diff --git a/engine/menus/multi_choice_menu.asm b/engine/menus/multi_choice_menu.asm index d16d332499..974144ac5f 100644 --- a/engine/menus/multi_choice_menu.asm +++ b/engine/menus/multi_choice_menu.asm @@ -434,7 +434,7 @@ GetChampArenaMusicNameIntoWRAM: .loop ld a, [hli] ld [de], a - cp "@" + cp '@' jr z, .done inc de jr .loop @@ -449,7 +449,7 @@ GetChampArenaMusicName: ld b, a ; b = which name in the list it is .loop ld a, [hli] - cp "@" + cp '@' jr nz, .loop dec b ret z diff --git a/engine/menus/naming_screen.asm b/engine/menus/naming_screen.asm index 059439bbfa..ed42d43143 100644 --- a/engine/menus/naming_screen.asm +++ b/engine/menus/naming_screen.asm @@ -38,7 +38,7 @@ AskName: pop af ld [wUpdateSpritesEnabled], a ld a, [wStringBuffer] - cp "@" + cp '@' ret nz .declinedNickname ld d, h @@ -63,7 +63,7 @@ DisplayNameRaterScreen:: call RestoreScreenTilesAndReloadTilePatterns call LoadGBPal ld a, [wStringBuffer] - cp "@" + cp '@' jr z, .playerCancelled ld hl, wPartyMonNicks ld bc, NAME_LENGTH @@ -125,7 +125,7 @@ DisplayNamingScreenWrap: ld [wMenuWatchedKeys], a ld a, 7 ld [wMaxMenuItem], a - ld a, "@" + ld a, '@' ld [wStringBuffer], a xor a ld hl, wNamingScreenSubmitName @@ -234,11 +234,11 @@ DisplayNamingScreenWrap: .didNotPressED ld a, [wCurrentMenuItem] cp $6 ; case switch row - jr nz, .didNotPressCaseSwtich + jr nz, .didNotPressCaseSwitch ld a, [wTopMenuItemX] cp $1 ; case switch column jr z, .pressedA_changedCase -.didNotPressCaseSwtich +.didNotPressCaseSwitch ld hl, wMenuCursorLocation ld a, [hli] ld h, [hl] @@ -248,21 +248,21 @@ DisplayNamingScreenWrap: ld [wNamingScreenLetter], a call CalcStringLength ld a, [wNamingScreenLetter] - cp "゙" + cp '゙' ld de, Dakutens jr z, .dakutensAndHandakutens - cp "゚" + cp '゚' ld de, Handakutens jr z, .dakutensAndHandakutens ld a, [wNamingScreenType] cp NAME_MON_SCREEN jr nc, .checkMonNameLength ld a, [wNamingScreenNameLength] - cp $7 ; max length of player/rival names + cp PLAYER_NAME_LENGTH - 1 jr .checkNameLength .checkMonNameLength ld a, [wNamingScreenNameLength] - cp $a ; max length of pokemon nicknames + cp NAME_LENGTH - 1 .checkNameLength jr c, .addLetter ret @@ -276,7 +276,7 @@ DisplayNamingScreenWrap: .addLetter ld a, [wNamingScreenLetter] ld [hli], a - ld [hl], "@" + ld [hl], '@' ld a, SFX_PRESS_AB rst _PlaySound ret @@ -286,7 +286,7 @@ DisplayNamingScreenWrap: ret z call CalcStringLength dec hl - ld [hl], "@" + ld [hl], '@' ret .pressedRight ld a, [wCurrentMenuItem] @@ -343,7 +343,7 @@ DisplayNamingScreenWrap: LoadEDTile: ld de, ED_Tile ld hl, vFont tile $70 - lb bc, BANK(ED_Tile), (ED_TileEnd - ED_Tile) / $8 + lb bc, BANK(ED_Tile), (ED_TileEnd - ED_Tile) / TILE_1BPP_SIZE jp CopyVideoDataDouble ED_Tile: @@ -395,9 +395,9 @@ PrintNicknameAndUnderscores: hlcoord 10, 3 ld a, [wNamingScreenType] cp NAME_MON_SCREEN - ld b, 10 ; pokemon max name length + ld b, PLAYER_NAME_LENGTH - 1 jr nc, .playerOrRival1 - ld b, 7 ; player or rival max name length + ld b, NAME_LENGTH - 1 .playerOrRival1 ld a, $76 ; underscore tile id .placeUnderscoreLoop @@ -408,10 +408,10 @@ PrintNicknameAndUnderscores: cp NAME_MON_SCREEN ld a, [wNamingScreenNameLength] jr nc, .pokemon2 - cp 7 ; player or rival max name length + cp PLAYER_NAME_LENGTH - 1 jr .playerOrRival2 .pokemon2 - cp 10 ; pokemon max name length + cp NAME_LENGTH - 1 .playerOrRival2 jr nz, .emptySpacesRemaining ; when all spaces are filled, force the cursor onto the ED tile @@ -422,9 +422,9 @@ PrintNicknameAndUnderscores: ld [wCurrentMenuItem], a ld a, [wNamingScreenType] cp NAME_MON_SCREEN - ld a, 9 ; keep the last underscore raised + ld a, NAME_LENGTH - 2 jr nc, .pokemon3 - ld a, 6 ; keep the last underscore raised + ld a, PLAYER_NAME_LENGTH - 2 .pokemon3 .emptySpacesRemaining ld c, a @@ -456,7 +456,7 @@ CalcStringLength: ld c, $0 .loop ld a, [hl] - cp "@" + cp '@' ret z inc hl inc c @@ -483,7 +483,7 @@ PrintNamingText: ; PureRGBnote: OPTIMIZED: don't need this blank character anymore in english ;ld hl, $1 ;add hl, bc - ;ld [hl], "の" ; leftover from Japanese version; blank tile $c9 in English + ;ld [hl], 'の' ; leftover from Japanese version; blank tile $c9 in English hlcoord 1, 3 ld de, NicknameTextString jr .placeString diff --git a/engine/menus/options_menu.asm b/engine/menus/options_menu.asm index 70388d4437..158154f593 100644 --- a/engine/menus/options_menu.asm +++ b/engine/menus/options_menu.asm @@ -23,7 +23,7 @@ OptionsDoNothing: OptionsPageAorSelectButtonDefault: ; by default the A button does nothing but the select button displays info on each option ldh a, [hJoy5] - bit BIT_SELECT, a + bit B_PAD_SELECT, a ret z ; if select wasn't pressed do nothing ld a, [wTopMenuItemY] cp PAGE_CONTROLS_Y_COORD ; is cursor on NEXT/PREV row? @@ -82,20 +82,20 @@ DrawOptionsPageInfo: add NUMBER_CHAR_OFFSET ld [hl], a hlcoord 17, PAGE_CONTROLS_Y_COORD - ld [hl], "/" + ld [hl], '/' hlcoord 18, PAGE_CONTROLS_Y_COORD pop bc inc bc ld a, [bc] ; number of pages in total add NUMBER_CHAR_OFFSET ld [hli], a - ld [hl], " " + ld [hl], ' ' hlcoord 14, PAGE_CONTROLS_Y_COORD ld a, [hl] cp $7a ; check if info text has just displayed and trashed the coords beside page number with a menu border jr nz, .skip ;if so, clear the menu border tiles out - ld a, " " + ld a, ' ' ld [hli], a ld [hl], a .skip @@ -104,7 +104,7 @@ DrawOptionsPageInfo: call PlaceString ; add cursor in front of NEXT hlcoord 1, PAGE_CONTROLS_Y_COORD - ld [hl], "▷" + ld [hl], '▷' ; add SELECT:INFO prompt to top of menu push bc hlcoord 14, 0 @@ -229,7 +229,7 @@ DisplayOptionMenuCommon: jr nz, .doneLoad push hl hlcoord NEXT_BUTTON_X_COORD, PAGE_CONTROLS_Y_COORD - ld [hl], " " + ld [hl], ' ' pop hl .doneLoad ld a, 1 @@ -249,15 +249,15 @@ OptionsMenuLoop: call JoypadLowSensitivity ldh a, [hJoy5] ld b, a - and A_BUTTON | B_BUTTON | START | SELECT | D_RIGHT | D_LEFT | D_UP | D_DOWN + and PAD_A | PAD_B | PAD_START | PAD_SELECT | PAD_RIGHT | PAD_LEFT | PAD_UP | PAD_DOWN jr z, .getJoypadStateLoop - bit BIT_B_BUTTON, b + bit B_PAD_B, b jr nz, .exitMenu - bit BIT_START, b + bit B_PAD_START, b jr nz, .exitMenu - bit BIT_SELECT, b + bit B_PAD_SELECT, b jr nz, .selectPressed - bit BIT_A_BUTTON, b + bit B_PAD_A, b jr z, .checkDirectionKeys .AbuttonPressed ld b, PAGE_CONTROLS_Y_COORD @@ -301,9 +301,9 @@ OptionsMenuLoop: ret .checkDirectionKeys ld hl, wCurrentOptionIndex - bit BIT_D_DOWN, b + bit B_PAD_DOWN, b jr nz, .downPressed - bit BIT_D_UP, b + bit B_PAD_UP, b jr nz, .upPressed ld e, [hl] pop hl @@ -348,7 +348,7 @@ OptionsMenuLoop: jp OptionsMenuLoop CursorInTextSpeed: - bit BIT_D_LEFT, b + bit B_PAD_LEFT, b jp z, .pressedRightInTextSpeed ;;;;;;;;;; PureRGBnote: CHANGED: Instant text speed replaced medium speed, so we need to adjust the X positions of the cursors a bit. ld a, [wOptions1CursorX] ; text speed cursor X coordinate @@ -528,7 +528,7 @@ PlaceUnfilledRightArrow: ld e, a ld d, 0 add hl, de - ld [hl], "▷" + ld [hl], '▷' ret SetTextSpeedCursorPosition: @@ -578,11 +578,12 @@ TextSpeedOptionData: ; this menu was changed a bit to have a NEXT and BACK button to navigate pages more easily. CopyOptionsFromSRAM:: - ld a, SRAM_ENABLE - ld [MBC1SRamEnable], a - ld a, 1 - ld [MBC1SRamBankingMode], a - ld [MBC1SRamBank], a + ld a, RAMG_SRAM_ENABLE + ld [rRAMG], a + ld a, BMODE_ADVANCED + ld [rBMODE], a + ASSERT BANK("Save Data") == BMODE_ADVANCED + ld [rRAMB], a ; by checking if a name has been saved we can know if a save file was created callfar CheckSaveFileExists jr nc, .doneLoad @@ -594,8 +595,9 @@ CopyOptionsFromSRAM:: ld [wSpriteOptions3], a .doneLoad xor a - ld [MBC1SRamBankingMode], a - ld [MBC1SRamEnable], a + ld [rBMODE], a + ASSERT RAMG_SRAM_DISABLE == BMODE_SIMPLE + ld [rRAMG], a ret OptionsMenu1InfoTextJumpTable: diff --git a/engine/menus/options_menu2.asm b/engine/menus/options_menu2.asm index aea09cbb10..3e93fb219e 100644 --- a/engine/menus/options_menu2.asm +++ b/engine/menus/options_menu2.asm @@ -95,7 +95,7 @@ Options2Text: OptionsPage2AorSelectButton: ld a, [hJoy5] - bit BIT_A_BUTTON, a + bit B_PAD_A, a jp z, OptionsPageAorSelectButtonDefault ; fall through OptionsPage2AButton: @@ -153,7 +153,7 @@ CursorInGBCFade: GetTwoBitXPosition: ld a, b - bit BIT_D_LEFT, b ; did the player press the left button + bit B_PAD_LEFT, b ; did the player press the left button ld a, [wOptions1CursorX] ; battle animation cursor X coordinate jr nz, .left ld b, OPTION_COLORS_LEFT_XPOS @@ -338,15 +338,15 @@ ToggleAltSGBYellowColors: PrintSGBYellowOptionNumbers: hlcoord 15, 3 cp %01000001 - ld [hl], "2" + ld [hl], '2' jr z, .next - ld [hl], "1" + ld [hl], '1' .next hlcoord 18, 3 cp %01000011 - ld [hl], "2" + ld [hl], '2' ret z - ld [hl], "1" + ld [hl], '1' ret diff --git a/engine/menus/party_menu.asm b/engine/menus/party_menu.asm index a46021fbe4..b40c614f34 100644 --- a/engine/menus/party_menu.asm +++ b/engine/menus/party_menu.asm @@ -52,7 +52,7 @@ RedrawPartyMenu_:: dec hl dec hl dec hl - ld a, "▷" ; unfilled right arrow menu cursor + ld a, '▷' ; unfilled right arrow menu cursor ld [hli], a ; place the cursor inc hl inc hl @@ -91,7 +91,7 @@ RedrawPartyMenu_:: jr nz, .placeMoveLearnabilityString ld de, .notAbleToLearnMoveText .placeMoveLearnabilityString - ld bc, 20 + 9 ; down 1 row and right 9 columns + ld bc, SCREEN_WIDTH + 9 ; 1 row down and 9 columns right push hl add hl, bc call PlaceString @@ -103,7 +103,7 @@ RedrawPartyMenu_:: pop hl pop de inc de - ld bc, 2 * 20 + ld bc, 2 * SCREEN_WIDTH add hl, bc pop bc inc c @@ -132,7 +132,7 @@ RedrawPartyMenu_:: ld l, a ld de, wEvoDataBuffer ld a, BANK(EvosMovesPointerTable) - ld bc, 4 * 3 + 1 ; enough for Eevee's three 4-byte evolutions and 0 terminator + ld bc, wEvoDataBufferEnd - wEvoDataBuffer call FarCopyData ld hl, wEvoDataBuffer ld de, .notAbleToEvolveText diff --git a/engine/menus/pc.asm b/engine/menus/pc.asm index 4483687bb8..f549e1c604 100644 --- a/engine/menus/pc.asm +++ b/engine/menus/pc.asm @@ -14,7 +14,7 @@ PCMainMenu: ld hl, wMiscFlags set BIT_NO_MENU_BUTTON_SOUND, [hl] call HandleMenuInput - bit BIT_B_BUTTON, a + bit B_PAD_B, a jp nz, LogOff ld a, [wMaxMenuItem] ; minimum of 2 for 3 options dec a diff --git a/engine/menus/players_pc.asm b/engine/menus/players_pc.asm index 61eb2a4021..04730fc606 100644 --- a/engine/menus/players_pc.asm +++ b/engine/menus/players_pc.asm @@ -42,7 +42,7 @@ PlayerPCMenu: inc hl ld a, 4 ; PureRGBnote: CHANGED: increased menu length for WORLD OPTIONS to be added ld [hli], a ; wMaxMenuItem - ld a, A_BUTTON | B_BUTTON + ld a, PAD_A | PAD_B ld [hli], a ; wMenuWatchedKeys xor a ld [hl], a @@ -55,7 +55,7 @@ PlayerPCMenu: ld hl, WhatDoYouWantText rst _PrintText call HandleMenuInput - bit BIT_B_BUTTON, a + bit B_PAD_B, a jp nz, ExitPlayerPC call PlaceUnfilledArrowMenuCursor ld a, [wCurrentMenuItem] @@ -279,7 +279,7 @@ PlayerPCToss: ; PureRGBnote: ADDED: happens when pressing start in a list menu - used for facilitating depositing items from the start item menu CheckButtonStartPressed:: - bit BIT_START, a + bit B_PAD_START, a jr z, .continue push af ld a, [wListMenuID] diff --git a/engine/menus/pokedex.asm b/engine/menus/pokedex.asm index 0c2ec40ea7..ab2932e6b9 100644 --- a/engine/menus/pokedex.asm +++ b/engine/menus/pokedex.asm @@ -36,7 +36,7 @@ ShowPokedexMenu: inc hl ld a, 6 ld [hli], a ; max menu item ID - ld [hl], D_LEFT | D_RIGHT | B_BUTTON | A_BUTTON | SELECT | START ; PureRGBnote: ADDED: track the SELECT and START buttons in order to trigger new functions + ld [hl], PAD_LEFT | PAD_RIGHT | PAD_B | PAD_A | PAD_SELECT | PAD_START ; PureRGBnote: ADDED: track the SELECT and START buttons in order to trigger new functions call HandlePokedexListMenu jr c, .goToSideMenu ; if the player chose a pokemon from the list cp 1 @@ -109,14 +109,14 @@ HandlePokedexSideMenu: inc hl ld a, 3 ld [hli], a ; max menu item ID - ;ld a, A_BUTTON | B_BUTTON not needed since A_BUTTON | B_BUTTON = 3 and 3 is already in the 'a' register + ;ld a, PAD_A | PAD_B not needed since PAD_A | PAD_B = 3 and 3 is already in the 'a' register ld [hli], a ; menu watched keys (A button and B button) xor a ld [hli], a ; old menu item ID ld [wMenuWatchMovingOutOfBounds], a .handleMenuInput call HandleMenuInput - bit BIT_B_BUTTON, a + bit B_PAD_B, a ld b, 2 jr nz, .buttonBPressed ld a, [wCurrentMenuItem] @@ -126,7 +126,7 @@ HandlePokedexSideMenu: jr z, .choseCry dec a jr z, .choseArea -.choseQuit +; chose Quit ld b, 1 .exitSideMenu pop af @@ -142,7 +142,7 @@ HandlePokedexSideMenu: push bc hlcoord 0, 3 ld de, 20 - lb bc, " ", 13 + lb bc, ' ', 13 call DrawTileLine ; cover up the menu cursor in the pokemon list pop bc ret @@ -151,7 +151,7 @@ HandlePokedexSideMenu: push bc hlcoord 15, 10 ld de, 20 - lb bc, " ", 7 + lb bc, ' ', 7 call DrawTileLine ; cover up the menu cursor in the side menu pop bc jr .exitSideMenu @@ -183,7 +183,7 @@ HandlePokedexSideMenu: .exitedData hlcoord 0, 3 ld de, 20 - lb bc, " ", 13 + lb bc, ' ', 13 call DrawTileLine ; cover up the menu cursor in the pokemon list pop bc ret @@ -229,7 +229,7 @@ HandlePokedexListMenu: ;;;;;;;;;;; ; draw the horizontal line separating the seen and owned amounts from the menu hlcoord 15, 8 - ld a, "─" + ld a, '─' ld [hli], a ld [hli], a ld [hli], a @@ -343,7 +343,7 @@ HandlePokedexListMenu: ld hl, wPokedexOwned call IsPokemonBitSet pop hl - ld a, " " + ld a, ' ' jr z, .writeTile ld a, $72 ; pokeball tile .writeTile @@ -377,22 +377,22 @@ HandlePokedexListMenu: call GBPalNormal call HandleMenuInput ;;;;;;;;;; PureRGBnote: ADDED: track the SELECT button in order to trigger town map when able - bit BIT_START, a + bit B_PAD_START, a jp nz, .startPressed ;;;;;;;;;; ;;;;;;;;;; PureRGBnote: ADDED: track the SELECT button in order to trigger town map when able - bit BIT_SELECT, a + bit B_PAD_SELECT, a jp nz, .selectPressed ;;;;;;;;;; - bit BIT_B_BUTTON, a + bit B_PAD_B, a jp nz, .buttonBPressed ;;;;;;;;;; PureRGBnote: FIXED: code from yellow, avoids a bug where pressing down/up and then ;;;;;;;;;; immediately A scrolls up/down twice instead of selecting the next pokemon - bit BIT_A_BUTTON, a + bit B_PAD_A, a jp nz, .buttonAPressed ;;;;;;;;;; -.checkIfUpPressed - bit BIT_D_UP, a +; check if Up pressed + bit B_PAD_UP, a jr z, .checkIfDownPressed .upPressed ; scroll up one row ld a, [wListScrollOffset] @@ -402,9 +402,9 @@ HandlePokedexListMenu: ld [wListScrollOffset], a jp .loop .checkIfDownPressed - bit BIT_D_DOWN, a + bit B_PAD_DOWN, a jr z, .checkIfRightPressed -.downPressed ; scroll down one row +; Down pressed, scroll down one row ld a, [wDexMaxSeenMon] cp 7 jp c, .loop ; can't if the list is shorter than 7 @@ -417,9 +417,9 @@ HandlePokedexListMenu: ld [wListScrollOffset], a jp .loop .checkIfRightPressed - bit BIT_D_RIGHT, a + bit B_PAD_RIGHT, a jr z, .checkIfLeftPressed -.rightPressed ; scroll down 7 rows +; Right pressed, scroll down 7 rows ld a, [wDexMaxSeenMon] cp 7 jp c, .loop ; can't if the list is shorter than 7 @@ -435,9 +435,9 @@ HandlePokedexListMenu: ld [wListScrollOffset], a jp .loop .checkIfLeftPressed ; scroll up 7 rows - bit BIT_D_LEFT, a + bit B_PAD_LEFT, a jr z, .buttonAPressed -.leftPressed +; Left pressed ld a, [wListScrollOffset] sub 7 ld [wListScrollOffset], a @@ -529,7 +529,7 @@ ShowPokedexDataInternal: ld hl, vChars1 tile $4C call CopyVideoDataDouble - ld a, B_BUTTON + ld a, PAD_B ld [wMenuWatchedKeys], a ; buttons this menu will track when displaying text (A Button used to proceed the text) jr ShowPokedexDataCommon @@ -539,7 +539,7 @@ ShowPokedexData: ld hl, wPokedexDataFlags set BIT_POKEDEX_DATA_DISPLAY_TYPE, [hl] CheckEvent EVENT_GOT_POKEDEX - ld a, B_BUTTON + ld a, PAD_B jr nz, .loadButtons xor a .loadButtons @@ -560,7 +560,7 @@ ShowPokedexDataCommon: ld hl, wStatusFlags2 set BIT_NO_AUDIO_FADE_OUT, [hl] ld a, $33 ; 3/7 volume - ldh [rNR50], a + ldh [rAUDVOL], a call GBPalWhiteOut ; zero all palettes call ClearScreen ld hl, wPokedexDataFlags @@ -594,9 +594,9 @@ ShowPokedexDataCommon: ldcoord_a 19, 17 hlcoord 2, 8 - ld a, "№" + ld a, '№' ld [hli], a - ld a, "" + ld a, '' ld [hli], a hlcoord 0, 9 @@ -691,7 +691,7 @@ ShowNextPokemonData: ld a, [wPokedexDataFlags] bit BIT_POKEDEX_DATA_DISPLAY_TYPE, a jr nz, .noLeftRight ; no left or right tracking when we are displaying an external pokedex entry - ; we will add D_RIGHT and D_LEFT to the tracked buttons if going left or right to other pokedex entries is allowed + ; we will add PAD_RIGHT and PAD_LEFT to the tracked buttons if going left or right to other pokedex entries is allowed ld a, [wMenuWatchedKeys] ld b, a ld a, [wPokedexNum] @@ -699,14 +699,14 @@ ShowNextPokemonData: ld a, [wDexMaxSeenMon] cp c jr z, .noRight - ld a, D_RIGHT + ld a, PAD_RIGHT or b ld b, a .noRight ld a, [wDexMinSeenMon] cp c jr z, .noLeft - ld a, D_LEFT + ld a, PAD_LEFT or b ld b, a .noLeft @@ -749,7 +749,7 @@ ShowNextPokemonData: jr z, .printHeightWeight ; don't track the select button if we're showing the starter dex entries before getting the pokedex ld a, [wMenuWatchedKeys] - ld b, SELECT + ld b, PAD_SELECT or b ld [wMenuWatchedKeys], a ; watch the select button too if the pokemon is owned (allows the player to see the back sprite on pressing select) @@ -760,13 +760,13 @@ ShowNextPokemonData: hlcoord 12, 6 lb bc, 1, 2 call PrintNumber ; print feet (height) - ld [hl], "′" + ld [hl], '′' inc de inc de ; de = address of inches (height) hlcoord 15, 6 lb bc, LEADING_ZEROES | 1, 2 call PrintNumber ; print inches (height) - ld [hl], "″" + ld [hl], '″' ; now print the weight (note that weight is stored in tenths of pounds internally) inc de inc de @@ -793,12 +793,12 @@ ShowNextPokemonData: 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 + ld [hl], '0' ; if the weight is less than 10, put a 0 before the decimal point .next inc hl ld a, [hli] ld [hld], a ; make space for the decimal point by moving the last digit forward one tile - ld [hl], "" ; decimal point tile + ld [hl], '' ; decimal point tile pop af ldh [hDexWeight + 1], a ; restore original value of [hDexWeight + 1] pop af @@ -824,15 +824,15 @@ ShowNextPokemonData: ldh a, [hJoy5] ld b, a .buttonTracking1 - bit BIT_A_BUTTON, b + bit B_PAD_A, b jr nz, .printBaseStats - bit BIT_B_BUTTON, b + bit B_PAD_B, b jp nz, .exitDataPage - bit BIT_D_LEFT, b + bit B_PAD_LEFT, b jp nz, .prevMon - bit BIT_D_RIGHT, b + bit B_PAD_RIGHT, b jp nz, .nextMon - bit BIT_SELECT, b + bit B_PAD_SELECT, b jp nz, .switchMonSprite ;;;;;;;;;; PureRGBnote: ADDED: pokedex will display the pokemon's types and their base stats on a new third page. .printBaseStats @@ -920,7 +920,7 @@ ShowNextPokemonData: predef PrintMonType hlcoord 2, 14 ld a, [hl] - cp " " + cp ' ' jr z, .waitForButtonPress2 ; don't print TYPE2/ if the pokemon has 1 type only. hlcoord 1, 13 ld de, DexType2Text @@ -928,7 +928,7 @@ ShowNextPokemonData: jr .waitForButtonPress2 .starterDisplay ld a, [wMenuWatchedKeys] - or A_BUTTON + or PAD_A ld [wMenuWatchedKeys], a .waitForButtonPress2 ;;;;;;;;;; @@ -940,15 +940,15 @@ ShowNextPokemonData: and c jr z, .waitForButtonPress2 .buttonTracking2 - bit BIT_B_BUTTON, b + bit B_PAD_B, b jp nz, .exitDataPage - bit BIT_D_LEFT, b + bit B_PAD_LEFT, b jp nz, .prevMon - bit BIT_D_RIGHT, b + bit B_PAD_RIGHT, b jr nz, .nextMon - bit BIT_SELECT, b + bit B_PAD_SELECT, b jr nz, .switchMonSprite - bit BIT_A_BUTTON, b + bit B_PAD_A, b jp nz, .exitDataPage ; only an option if in the starter pokedex display at the beginning of the game .exitDataPage xor a @@ -965,7 +965,7 @@ ShowNextPokemonData: ld hl, wStatusFlags2 res BIT_NO_AUDIO_FADE_OUT, [hl] ld a, $77 ; max volume - ldh [rNR50], a + ldh [rAUDVOL], a ret .switchMonSprite ld a, [wPokedexNum] @@ -1042,7 +1042,7 @@ ShowNextPokemonData: lb bc, 3, 10 call ClearScreenArea - ld a, B_BUTTON + ld a, PAD_B ld [wMenuWatchedKeys], a ; reset the default watched buttons for internal entries call Delay3 @@ -1055,7 +1055,8 @@ HeightWeightText: next "WT ???lb@" ; XXX does anything point to this? ; PureRGBnote: CHANGED: no, so comment out -;PokeText: +; leftover from JPN Pokedex, where species have the suffix "Pokemon" +;PokeText: ; unreferenced ; db "#@" ; horizontal line that divides the pokedex text description from the rest of the data diff --git a/engine/menus/save.asm b/engine/menus/save.asm index 4e239b0659..3aceaffe51 100644 --- a/engine/menus/save.asm +++ b/engine/menus/save.asm @@ -1,16 +1,15 @@ -LoadSAV: -; if carry, write "the file data is destroyed" +TryLoadSaveFile: call ClearScreen call LoadFontTilePatterns call LoadTextBoxTilePatterns - call LoadSAV0 + call LoadMainData jr c, .badsum - call LoadSAV1 + call LoadCurrentBoxData jr c, .badsum - call LoadSAV2 + call LoadPartyAndDexData jr c, .badsum ld a, $2 ; good checksum - jr .goodsum + jr .done .badsum ld hl, wStatusFlags5 push hl @@ -22,7 +21,7 @@ LoadSAV: pop hl res BIT_NO_TEXT_DELAY, [hl] ld a, $1 ; bad checksum -.goodsum +.done ld [wSaveFileStatus], a ret @@ -30,33 +29,34 @@ FileDataDestroyedText: text_far _FileDataDestroyedText text_end -LoadSAV0: - ld a, SRAM_ENABLE - ld [MBC1SRamEnable], a - ld a, $1 - ld [MBC1SRamBankingMode], a - ld [MBC1SRamBank], a +LoadMainData: + ld a, RAMG_SRAM_ENABLE + ld [rRAMG], a + ld a, BMODE_ADVANCED + ld [rBMODE], a + ASSERT BANK("Save Data") == BMODE_ADVANCED + ld [rRAMB], a ; This vc_hook does not have to be in any particular location. ; It is defined here because it refers to the same labels as the two lines below. vc_hook Unknown_save_limit ld hl, sGameData ld bc, sGameDataEnd - sGameData - call SAVCheckSum + call CalcCheckSum ld c, a ld a, [sMainDataCheckSum] cp c - jp z, .checkSumsMatched + jp z, .checkSumMatched ; If the computed checksum didn't match the saved on, try again. ld hl, sGameData ld bc, sGameDataEnd - sGameData - call SAVCheckSum + call CalcCheckSum ld c, a ld a, [sMainDataCheckSum] cp c - jp nz, SAVBadCheckSum + jp nz, CheckSumFailed -.checkSumsMatched +.checkSumMatched ld hl, sPlayerName ld de, wPlayerName ld bc, NAME_LENGTH @@ -78,41 +78,42 @@ LoadSAV0: ld bc, wBoxDataEnd - wBoxDataStart rst _CopyData and a - jp SAVGoodChecksum - -LoadSAV1: - ld a, SRAM_ENABLE - ld [MBC1SRamEnable], a - ld a, $1 - ld [MBC1SRamBankingMode], a - ld [MBC1SRamBank], a + jp GoodCheckSum + +LoadPartyAndDexData: + ld a, RAMG_SRAM_ENABLE + ld [rRAMG], a + ld a, BMODE_ADVANCED + ld [rBMODE], a + ASSERT BANK("Save Data") == BMODE_ADVANCED + ld [rRAMB], a ld hl, sGameData ld bc, sGameDataEnd - sGameData - call SAVCheckSum + call CalcCheckSum ld c, a ld a, [sMainDataCheckSum] cp c - jr nz, SAVBadCheckSum + jr nz, CheckSumFailed ld hl, sCurBoxData ld de, wBoxDataStart ld bc, wBoxDataEnd - wBoxDataStart rst _CopyData and a - jp SAVGoodChecksum - -LoadSAV2: - ld a, SRAM_ENABLE - ld [MBC1SRamEnable], a - ld a, $1 - ld [MBC1SRamBankingMode], a - ld [MBC1SRamBank], a + jp GoodCheckSum + +LoadCurrentBoxData: + ld a, RAMG_SRAM_ENABLE + ld [rRAMG], a + ld a, BMODE_ADVANCED + ld [rBMODE], a + ld [rRAMB], a ld hl, sGameData ld bc, sGameDataEnd - sGameData - call SAVCheckSum + call SaveMenu ld c, a ld a, [sMainDataCheckSum] cp c - jp nz, SAVBadCheckSum + jp nz, CheckSumFailed ld hl, sPartyData ld de, wPartyDataStart ld bc, wPartyDataEnd - wPartyDataStart @@ -122,41 +123,44 @@ LoadSAV2: ld bc, wPokedexSeenEnd - wPokedexOwned rst _CopyData and a - jp SAVGoodChecksum + jp GoodCheckSum -SAVBadCheckSum: +CheckSumFailed: scf + ; fallthrough -SAVGoodChecksum: +GoodCheckSum: ld a, 0 - ld [MBC1SRamBankingMode], a - ld [MBC1SRamEnable], a + ld [rBMODE], a + ASSERT RAMG_SRAM_DISABLE == BMODE_SIMPLE + ld [rRAMG], a ret -LoadSAVIgnoreBadCheckSum: -; unused function that loads save data and ignores bad checksums - call LoadSAV0 - call LoadSAV1 - jp LoadSAV2 +TryLoadSaveFileIgnoreChecksum: ; unreferenced +; don't update wSaveFileStatus upon success or failure +; don't display warning in case of failed checksum + call LoadMainData + call LoadCurrentBoxData + jp LoadPartyAndDexData ; PureRGBnote: CHANGED: remove "now saving" text because saving is near-instant now. -SaveSAV: +SaveMenu: farcall PrintSaveScreenText ld hl, WouldYouLikeToSaveText - call SaveSAVConfirm + call SaveTheGame_YesOrNo and a ;|0 = Yes|1 = No| ret nz ld a, [wSaveFileStatus] dec a jr z, .save - call SAVCheckRandomID + call CheckPreviousSaveFile jr z, .save ld hl, OlderFileWillBeErasedText - call SaveSAVConfirm + call SaveTheGame_YesOrNo and a ret nz .save - call SaveSAVtoSRAM + call SaveGameData hlcoord 1, 13 lb bc, 4, 18 call ClearScreenArea @@ -169,13 +173,13 @@ SaveSAV: ld c, 10 ; PureRGBnote: CHANGED: reduce artificial save delay to 1/3 of original. jp DelayFrames -SaveSAVConfirm: +SaveTheGame_YesOrNo: rst _PrintText hlcoord 0, 7 lb bc, 8, 1 ld a, TWO_OPTION_MENU ld [wTextBoxID], a - call DisplayTextBoxID ; yes/no menu + call DisplayTextBoxID ld a, [wCurrentMenuItem] ret @@ -191,12 +195,12 @@ OlderFileWillBeErasedText: text_far _OlderFileWillBeErasedText text_end -SaveSAVtoSRAM0: - ld a, SRAM_ENABLE - ld [MBC1SRamEnable], a - ld a, $1 - ld [MBC1SRamBankingMode], a - ld [MBC1SRamBank], a +SaveMainData: + ld a, RAMG_SRAM_ENABLE + ld [rRAMG], a + ld a, BMODE_ADVANCED + ASSERT BANK("Save Data") == BMODE_ADVANCED + ld [rRAMB], a ;;;;;;;;;; PureRGBnote: ADDED: duplicates of options variables in SRAM. These are loaded on boot of the game for instant options-efficacy. ld a, [wOptions2] ld [sOptions2], a @@ -217,47 +221,51 @@ SaveSAVtoSRAM0: ld de, sSpriteData ld bc, wSpriteDataEnd - wSpriteDataStart rst _CopyData + +; this part is redundant, SaveCurrentBoxData is always called next ld hl, wBoxDataStart ld de, sCurBoxData ld bc, wBoxDataEnd - wBoxDataStart rst _CopyData + ldh a, [hTileAnimations] ld [sTileAnimations], a ld hl, sGameData ld bc, sGameDataEnd - sGameData - call SAVCheckSum + call CalcCheckSum ld [sMainDataCheckSum], a xor a - ld [MBC1SRamBankingMode], a - ld [MBC1SRamEnable], a + ld [rBMODE], a + ld [rRAMG], a ret -SaveSAVtoSRAM1: -; stored pokémon - ld a, SRAM_ENABLE - ld [MBC1SRamEnable], a - ld a, $1 - ld [MBC1SRamBankingMode], a - ld [MBC1SRamBank], a +SaveCurrentBoxData: + ld a, RAMG_SRAM_ENABLE + ld [rRAMG], a + ld a, BMODE_ADVANCED + ld [rBMODE], a + ASSERT BANK("Save Data") == BMODE_ADVANCED + ld [rRAMB], a ld hl, wBoxDataStart ld de, sCurBoxData ld bc, wBoxDataEnd - wBoxDataStart rst _CopyData ld hl, sGameData ld bc, sGameDataEnd - sGameData - call SAVCheckSum + call CalcCheckSum ld [sMainDataCheckSum], a xor a - ld [MBC1SRamBankingMode], a - ld [MBC1SRamEnable], a + ld [rBMODE], a + ld [rRAMG], a ret -SaveSAVtoSRAM2: - ld a, SRAM_ENABLE - ld [MBC1SRamEnable], a - ld a, $1 - ld [MBC1SRamBankingMode], a - ld [MBC1SRamBank], a +SavePartyAndDexData: + ld a, RAMG_SRAM_ENABLE + ld [rRAMG], a + ld a, BMODE_ADVANCED + ld [rBMODE], a + ASSERT BANK("Save Data") == BMODE_ADVANCED + ld [rRAMB], a ld hl, wPartyDataStart ld de, sPartyData ld bc, wPartyDataEnd - wPartyDataStart @@ -268,21 +276,21 @@ SaveSAVtoSRAM2: rst _CopyData ld hl, sGameData ld bc, sGameDataEnd - sGameData - call SAVCheckSum + call CalcCheckSum ld [sMainDataCheckSum], a xor a - ld [MBC1SRamBankingMode], a - ld [MBC1SRamEnable], a + ld [rBMODE], a + ld [rRAMG], a ret -SaveSAVtoSRAM:: +SaveGameData:: ld a, $2 ld [wSaveFileStatus], a - call SaveSAVtoSRAM0 - call SaveSAVtoSRAM1 - jp SaveSAVtoSRAM2 + call SaveMainData + call SaveCurrentBoxData + jp SavePartyAndDexData -SAVCheckSum: +CalcCheckSum: ;Check Sum (result[1 byte] is complemented) ld d, 0 .loop @@ -305,7 +313,7 @@ CalcIndividualBoxCheckSums: push bc push de ld bc, wBoxDataEnd - wBoxDataStart - call SAVCheckSum + call CalcCheckSum pop de ld [de], a inc de @@ -319,7 +327,7 @@ GetBoxSRAMLocation: ; out: b = box SRAM bank, hl = pointer to start of box ld hl, BoxSRAMPointerTable ld a, [wCurrentBoxNum] - and $7f + and BOX_NUM_MASK cp NUM_BOXES / 2 ld b, 2 jr c, .next @@ -362,11 +370,11 @@ ChangeBox:: ld [wListPointer + 1], a xor a ld [wCurrentMenuItem], a - ld a, A_BUTTON | B_BUTTON + ld a, PAD_A | PAD_B ld [wMenuWatchedKeys], a callfar DisplayMultiChoiceMenu ldh a, [hJoy5] - bit BIT_B_BUTTON, a + bit B_PAD_B, a jr nz, .done ld a, [wCurrentMenuItem] and a @@ -391,7 +399,7 @@ ChangeBox:: call HandleMenuInput ld hl, hUILayoutFlags res BIT_DOUBLE_SPACED_MENU, [hl] - bit BIT_B_BUTTON, a + bit B_PAD_B, a jr nz, .done call GetBoxSRAMLocation ld e, l @@ -412,7 +420,7 @@ ChangeBox:: ld a, [hl] ld [de], a call RestoreMapTextPointer - call SaveSAVtoSRAM + call SaveGameData ld hl, wChangeBoxSavedMapTextPointer call SetMapTextPointer ld a, SFX_SAVE @@ -434,17 +442,17 @@ SkippedForeverText: CopyBoxToOrFromSRAM: ; copy an entire box from hl to de with b as the SRAM bank push hl - ld a, SRAM_ENABLE - ld [MBC1SRamEnable], a - ld a, $1 - ld [MBC1SRamBankingMode], a + ld a, RAMG_SRAM_ENABLE + ld [rRAMG], a + ld a, BMODE_ADVANCED + ld [rBMODE], a ld a, b - ld [MBC1SRamBank], a + ld [rRAMB], a ld bc, wBoxDataEnd - wBoxDataStart rst _CopyData pop hl -; mark the memory that the box was copied from as am empty box +; mark the source box as an empty box xor a ld [hli], a dec a @@ -452,30 +460,30 @@ CopyBoxToOrFromSRAM: ld hl, sBox1 ; sBox7 ld bc, sBank2AllBoxesChecksum - sBox1 - call SAVCheckSum + call CalcCheckSum ld [sBank2AllBoxesChecksum], a ; sBank3AllBoxesChecksum call CalcIndividualBoxCheckSums xor a - ld [MBC1SRamBankingMode], a - ld [MBC1SRamEnable], a + ld [rBMODE], a + ld [rRAMG], a ret EmptyAllSRAMBoxes: ; marks all boxes in SRAM as empty (initialisation for the first time the ; player changes the box) - ld a, SRAM_ENABLE - ld [MBC1SRamEnable], a - ld a, $1 - ld [MBC1SRamBankingMode], a - ld a, 2 - ld [MBC1SRamBank], a + ld a, RAMG_SRAM_ENABLE + ld [rRAMG], a + ld a, BMODE_ADVANCED + ld [rBMODE], a + ld a, BANK("Saved Boxes 1") + ld [rRAMB], a call EmptySRAMBoxesInBank - ld a, 3 - ld [MBC1SRamBank], a + ld a, BANK("Saved Boxes 2") + ld [rRAMB], a call EmptySRAMBoxesInBank xor a - ld [MBC1SRamBankingMode], a - ld [MBC1SRamEnable], a + ld [rBMODE], a + ld [rRAMG], a ret EmptySRAMBoxesInBank: @@ -494,7 +502,7 @@ EmptySRAMBoxesInBank: call EmptySRAMBox ld hl, sBox1 ; sBox7 ld bc, sBank2AllBoxesChecksum - sBox1 - call SAVCheckSum + call CalcCheckSum ld [sBank2AllBoxesChecksum], a ; sBank3AllBoxesChecksum jp CalcIndividualBoxCheckSums @@ -508,24 +516,24 @@ EmptySRAMBox: GetMonCountsForAllBoxes: ld hl, wBoxMonCounts push hl - ld a, SRAM_ENABLE - ld [MBC1SRamEnable], a - ld a, $1 - ld [MBC1SRamBankingMode], a - ld a, $2 - ld [MBC1SRamBank], a + ld a, RAMG_SRAM_ENABLE + ld [rRAMG], a + ld a, BMODE_ADVANCED + ld [rBMODE], a + ld a, BANK("Saved Boxes 1") + ld [rRAMB], a call GetMonCountsForBoxesInBank - ld a, $3 - ld [MBC1SRamBank], a + ld a, BANK("Saved Boxes 2") + ld [rRAMB], a call GetMonCountsForBoxesInBank xor a - ld [MBC1SRamBankingMode], a - ld [MBC1SRamEnable], a + ld [rBMODE], a + ld [rRAMG], a pop hl ; copy the count for the current box from WRAM ld a, [wCurrentBoxNum] - and $7f + and BOX_NUM_MASK ld c, a ld b, 0 add hl, bc @@ -549,25 +557,26 @@ GetMonCountsForBoxesInBank: ld [hli], a ret -SAVCheckRandomID: -; checks if Sav file is the same by checking player's name 1st letter -; and the two random numbers generated at game beginning -; (which are stored at wPlayerID)s - ld a, $0a - ld [MBC1SRamEnable], a - ld a, $01 - ld [MBC1SRamBankingMode], a - ld [MBC1SRamBank], a +; check if we're trying to save over a different playthrough +; return result in zero flag +; z set: a valid save file was found, and saved PlayerID is different from wPlayerID +CheckPreviousSaveFile: + ld a, RAMG_SRAM_ENABLE + ld [rRAMG], a + ld a, BMODE_ADVANCED + ld [rBMODE], a + ASSERT BANK("Save Data") == BMODE_ADVANCED + ld [rRAMB], a ld a, [sPlayerName] and a jr z, .next ld hl, sGameData ld bc, sGameDataEnd - sGameData - call SAVCheckSum + call CalcCheckSum ld c, a ld a, [sMainDataCheckSum] cp c - jr nz, .next + jr nz, .next ; return z set if save data is corrupted ld hl, sMainData + (wPlayerID - wMainDataStart) ; player ID ld a, [hli] ld h, [hl] @@ -578,7 +587,7 @@ SAVCheckRandomID: ld a, [wPlayerID + 1] cp h .next - jp SAVGoodChecksum + jp GoodCheckSum SaveHallOfFameTeams: ld a, [wNumHoFTeams] @@ -645,38 +654,39 @@ LoadHallOfFameTeams: ; fallthrough HallOfFame_Copy: - ld a, SRAM_ENABLE - ld [MBC1SRamEnable], a - ld a, $1 - ld [MBC1SRamBankingMode], a + ld a, RAMG_SRAM_ENABLE + ld [rRAMG], a + ld a, BMODE_ADVANCED + ld [rBMODE], a xor a - ld [MBC1SRamBank], a + ld [rRAMB], a rst _CopyData xor a - ld [MBC1SRamBankingMode], a - ld [MBC1SRamEnable], a + ld [rBMODE], a + ld [rRAMG], a ret -ClearSAV: - ld a, SRAM_ENABLE - ld [MBC1SRamEnable], a - ld a, $1 - ld [MBC1SRamBankingMode], a +; Fill SRAM with $ff, erasing save data. Used by DoClearSaveDialogue +ClearAllSRAMBanks: + ld a, RAMG_SRAM_ENABLE + ld [rRAMG], a + ld a, BMODE_ADVANCED + ld [rBMODE], a xor a - call PadSRAM_FF - ld a, $1 - call PadSRAM_FF - ld a, $2 - call PadSRAM_FF - ld a, $3 - call PadSRAM_FF + call .PadSRAM_FF + ld a, 1 + call .PadSRAM_FF + ld a, 2 + call .PadSRAM_FF + ld a, 3 + call .PadSRAM_FF xor a - ld [MBC1SRamBankingMode], a - ld [MBC1SRamEnable], a + ld [rBMODE], a + ld [rRAMG], a ret -PadSRAM_FF: - ld [MBC1SRamBank], a +.PadSRAM_FF + ld [rRAMB], a ld hl, STARTOF(SRAM) ld bc, SIZEOF(SRAM) ld a, $ff diff --git a/engine/menus/save_file_updater.asm b/engine/menus/save_file_updater.asm index 89237dad96..53871f9d3c 100644 --- a/engine/menus/save_file_updater.asm +++ b/engine/menus/save_file_updater.asm @@ -43,11 +43,11 @@ SaveFileUpdateCheck:: ld [wCurrentMenuItem], a .reload ld hl, SaveFileUpdaterMenu - ld b, A_BUTTON | START | B_BUTTON + ld b, PAD_A | PAD_START | PAD_B call DisplayMultiChoiceTextBoxNoMenuReset jr nz, .exitSaveUpdater ldh a, [hJoy5] - bit BIT_A_BUTTON, a + bit B_PAD_A, a jr z, .startPressed ld hl, PressStartToContinueText rst _PrintText diff --git a/engine/menus/sprite_options_menu.asm b/engine/menus/sprite_options_menu.asm index 9374f2feac..c92a734d28 100644 --- a/engine/menus/sprite_options_menu.asm +++ b/engine/menus/sprite_options_menu.asm @@ -68,7 +68,7 @@ DrawSpriteOptionsMenu: SpriteOptionsAorSelectButton: ld a, [hJoy5] - bit BIT_A_BUTTON, a + bit B_PAD_A, a jp z, OptionsPageAorSelectButtonDefault ; fall through SpriteOptionsAButton: @@ -88,7 +88,7 @@ SpriteOptionsAButton: rst _PlaySound call DisplayFrontSpriteOptions hlcoord 14, PAGE_CONTROLS_Y_COORD - ld a, " " + ld a, ' ' ld [hli], a ld [hl], a pop af diff --git a/engine/menus/start_sub_menus.asm b/engine/menus/start_sub_menus.asm index 305e3a8f32..a910208e4f 100644 --- a/engine/menus/start_sub_menus.asm +++ b/engine/menus/start_sub_menus.asm @@ -1,6 +1,6 @@ StartMenu_Pokedex:: predef ShowPokedexMenu - call LoadScreenTilesFromBuffer2 ; restore saved screen + call LoadScreenTilesFromBuffer2 call Delay3 ;call LoadGBPal ; shinpokerednote: gbcnote: moved to redisplaystartmenu for better visual effect call UpdateSprites @@ -57,15 +57,15 @@ StartMenu_Pokemon:: inc hl ld a, b ld [hli], a ; max menu item ID - ld a, A_BUTTON | B_BUTTON + ld a, PAD_A | PAD_B ld [hli], a ; menu watched keys xor a ld [hl], a call HandleMenuInput push af - call LoadScreenTilesFromBuffer1 ; restore saved screen + call LoadScreenTilesFromBuffer1 pop af - bit BIT_B_BUTTON, a + bit B_PAD_B, a jp nz, .loop ; if the B button wasn't pressed ld a, [wMaxMenuItem] @@ -116,7 +116,7 @@ StartMenu_Pokemon:: ld a, [hli] ld h, [hl] ld l, a - ld a, [wObtainedBadges] ; badges obtained + ld a, [wObtainedBadges] jp hl .outOfBattleMovePointers dw .cut @@ -243,7 +243,7 @@ StartMenu_Pokemon:: .softboiled ld hl, wPartyMon1MaxHP ld a, [wWhichPokemon] - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld a, [hli] ldh [hDividend], a @@ -253,7 +253,7 @@ StartMenu_Pokemon:: ldh [hDivisor], a ld b, 2 ; number of bytes call Divide - ld bc, wPartyMon1HP - wPartyMon1MaxHP + ld bc, MON_HP - MON_MAXHP add hl, bc ld a, [hld] ld b, a @@ -297,17 +297,17 @@ StartMenu_Pokemon:: ; writes a blank tile to all possible menu cursor positions on the party menu ErasePartyMenuCursors:: hlcoord 0, 1 - ld bc, 2 * 20 ; menu cursor positions are 2 rows apart + ld bc, 2 * SCREEN_WIDTH ; menu cursor positions are 2 rows apart ld a, 6 ; 6 menu cursor positions .loop - ld [hl], " " + ld [hl], ' ' add hl, bc dec a jr nz, .loop ret ItemMenuLoop: - call LoadScreenTilesFromBuffer2DisableBGTransfer ; restore saved screen + call LoadScreenTilesFromBuffer2DisableBGTransfer call RunDefaultPaletteCommand StartMenu_Item:: @@ -353,8 +353,8 @@ StartMenu_Item:: jp ItemMenuLoop .noStartButton ;;;;;;;;;; -; erase menu cursor (blank each tile in front of an item name) - ld a, " " +; erase menu cursor (blank each tile in front of an item name) + ld a, ' ' ldcoord_a 5, 4 ldcoord_a 5, 6 ldcoord_a 5, 8 @@ -367,7 +367,7 @@ StartMenu_Item:: jp z, .useOrTossItem cp POCKET_ABRA jp z, .useOrTossItem ; PureRGBnote: ADDED: Pocket Abra doesn't bring up Use/toss dialog before usage -.notBicycle1 +; not Bicycle xor a ld [wListMenuHoverTextType], a ; PureRGBnote: ADDED: done with the item list interaction, so no TM names need to be printed anymore ld a, USE_TOSS_MENU_TEMPLATE @@ -383,15 +383,15 @@ StartMenu_Item:: inc hl inc a ; a = 1 ld [hli], a ; max menu item ID - ld a, A_BUTTON | B_BUTTON + ld a, PAD_A | PAD_B ld [hli], a ; menu watched keys xor a ld [hl], a ; old menu item id call HandleMenuInput call PlaceUnfilledArrowMenuCursor - bit BIT_B_BUTTON, a + bit B_PAD_B, a jp nz, ItemMenuLoop -.useOrTossItem ; if the player made the choice to use or toss the item +.useOrTossItem ld a, [wCurItem] ld [wNamedObjectIndex], a call GetItemName @@ -401,7 +401,7 @@ StartMenu_Item:: ;;;;;;;;;; PureRGBnote: ADDED: pocket abra closes the item menu after usage. jr z, .yesBicycle cp POCKET_ABRA - jr nz, .notBicycle2 + jr nz, .notBicycle jr .useItem_closeMenu .yesBicycle ;;;;;;;;;; @@ -411,7 +411,7 @@ StartMenu_Item:: ld hl, CannotGetOffHereText rst _PrintText jp ItemMenuLoop -.notBicycle2 +.notBicycle ld a, [wCurrentMenuItem] and a jr nz, .tossItem @@ -521,14 +521,14 @@ StartMenu_TrainerInfo:: xor a ldh [hTileAnimations], a call DrawTrainerInfo - predef DrawBadges ; draw badges + predef DrawBadges ld b, SET_PAL_TRAINER_CARD call RunPaletteCommand call GBPalNormal - call WaitForTextScrollButtonPress ; wait for button press + call WaitForTextScrollButtonPress call GBPalWhiteOut call LoadFontTilePatterns - call LoadScreenTilesFromBuffer2 ; restore saved screen + call LoadScreenTilesFromBuffer2 call RunDefaultPaletteCommand call ReloadMapData ;call LoadGBPal ; shinpokerednote: gbcnote: moved to redisplaystartmenu for better visual effect @@ -543,7 +543,7 @@ DrawTrainerInfo: predef DisplayPicCenteredOrUpperRight call DisableLCD hlcoord 0, 2 - ld a, " " + ld a, ' ' call TrainerInfo_DrawVerticalLine hlcoord 1, 2 call TrainerInfo_DrawVerticalLine @@ -551,7 +551,7 @@ DrawTrainerInfo: ld de, vChars2 tile $00 ld bc, $1c tiles rst _CopyData - ld hl, TrainerInfoTextBoxTileGraphics ; trainer info text box tile patterns + ld hl, TrainerInfoTextBoxTileGraphics ld de, vChars2 tile $77 ld bc, 8 tiles push bc @@ -561,10 +561,10 @@ DrawTrainerInfo: ld bc, $17 tiles call TrainerInfo_FarCopyData pop bc - ld hl, BadgeNumbersTileGraphics ; badge number tile patterns + ld hl, BadgeNumbersTileGraphics ld de, vChars1 tile $58 call TrainerInfo_FarCopyData - ld hl, GymLeaderFaceAndBadgeTileGraphics ; gym leader face and badge tile patterns + ld hl, GymLeaderFaceAndBadgeTileGraphics ld de, vChars2 tile $20 ld bc, 8 * 8 tiles ld a, BANK(GymLeaderFaceAndBadgeTileGraphics) @@ -573,7 +573,7 @@ DrawTrainerInfo: ld de, 13 tiles add hl, de ; hl = colon tile pattern ld de, vChars1 tile $56 - ld bc, 1 tiles + ld bc, TILE_SIZE ld a, BANK(TextBoxGraphics) push bc call FarCopyData2 @@ -617,12 +617,12 @@ DrawTrainerInfo: ld c, 3 | LEADING_ZEROES | LEFT_ALIGN | MONEY_SIGN call PrintBCDNumber hlcoord 9, 6 - ld de, wPlayTimeHours ; hours + ld de, wPlayTimeHours lb bc, LEFT_ALIGN | 1, 3 call PrintNumber ld a, $d6 ; colon tile ID ld [hli], a - ld de, wPlayTimeMinutes ; minutes + ld de, wPlayTimeMinutes lb bc, LEADING_ZEROES | 1, 2 jp PrintNumber @@ -704,8 +704,8 @@ StartMenu_SaveReset:: ld a, [wStatusFlags4] bit BIT_LINK_CONNECTED, a jp nz, Init - predef SaveSAV ; save the game - call LoadScreenTilesFromBuffer2 ; restore saved screen + predef SaveMenu + call LoadScreenTilesFromBuffer2 jp HoldTextDisplayOpen StartMenu_Option:: @@ -716,7 +716,7 @@ StartMenu_Option:: call ClearScreen call UpdateSprites callfar DisplayOptionMenu - call LoadScreenTilesFromBuffer2 ; restore saved screen + call LoadScreenTilesFromBuffer2 call LoadTextBoxTilePatterns call UpdateSprites jp RedisplayStartMenu @@ -776,19 +776,19 @@ SwitchPartyMon_ClearGfx: ld bc, SCREEN_WIDTH * 2 call AddNTimes ld c, SCREEN_WIDTH * 2 - ld a, " " + ld a, ' ' .clearMonBGLoop ; clear the mon's row in the party menu ld [hli], a dec c jr nz, .clearMonBGLoop pop af - ld hl, wShadowOAM - ld bc, $10 + ld hl, wShadowOAMSprite00YCoord + ld bc, OBJ_SIZE * 4 call AddNTimes - ld de, $4 + ld de, OBJ_SIZE ld c, e .clearMonOAMLoop - ld [hl], $a0 + ld [hl], SCREEN_HEIGHT_PX + OAM_Y_OFS add hl, de dec c jr nz, .clearMonOAMLoop @@ -848,24 +848,24 @@ SwitchPartyMon_InitVarOrSwapData:: ldh a, [hSwapTemp] ld [de], a ld hl, wPartyMons - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH ld a, [wCurrentMenuItem] call AddNTimes push hl ld de, wSwitchPartyMonTempBuffer - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH rst _CopyData ld hl, wPartyMons - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH ld a, [wMenuItemToSwap] call AddNTimes pop de push hl - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH rst _CopyData pop de ld hl, wSwitchPartyMonTempBuffer - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH rst _CopyData ld hl, wPartyMonOT ld a, [wCurrentMenuItem] diff --git a/engine/menus/swap_items.asm b/engine/menus/swap_items.asm index 8b1794c8cb..8d0fd2bcd1 100644 --- a/engine/menus/swap_items.asm +++ b/engine/menus/swap_items.asm @@ -76,7 +76,7 @@ HandleItemListSwapping:: ld a, [hli] cp b jr z, .swapSameItemType -.swapDifferentItems +; swap different items ldh [hSwapItemID], a ; save second item ID ld a, [hld] ldh [hSwapItemQuantity], a ; save second item quantity diff --git a/engine/menus/text_box.asm b/engine/menus/text_box.asm index e850b29e66..b95e745473 100644 --- a/engine/menus/text_box.asm +++ b/engine/menus/text_box.asm @@ -174,7 +174,7 @@ DoBuySellQuitMenu: ld a, BUY_SELL_QUIT_MENU_TEMPLATE ld [wTextBoxID], a call DisplayTextBoxID - ld a, A_BUTTON | B_BUTTON + ld a, PAD_A | PAD_B ld [wMenuWatchedKeys], a ld a, $2 ld [wMaxMenuItem], a @@ -191,9 +191,9 @@ DoBuySellQuitMenu: ld [wStatusFlags5], a call HandleMenuInput call PlaceUnfilledArrowMenuCursor - bit BIT_A_BUTTON, a + bit B_PAD_A, a jr nz, .pressedA - bit BIT_B_BUTTON, a ; always true since only A/B are watched + bit B_PAD_B, a ; always true since only A/B are watched jr z, .pressedA ld a, CANCELLED_MENU ld [wMenuExitMethod], a @@ -230,7 +230,7 @@ DisplayTwoOptionMenu: ld [wChosenMenuItem], a ld [wMenuExitMethod], a - ld a, A_BUTTON | B_BUTTON + ld a, PAD_A | PAD_B ld [wMenuWatchedKeys], a ld a, $1 ld [wMaxMenuItem], a @@ -312,7 +312,7 @@ DisplayTwoOptionMenu: pop hl .noYesMenuInputLoop call HandleMenuInput - bit BIT_B_BUTTON, a + bit B_PAD_B, a jr nz, .noYesMenuInputLoop ; try again if B was not pressed pop af pop hl @@ -325,7 +325,7 @@ DisplayTwoOptionMenu: ld [wTwoOptionMenuID], a call HandleMenuInput pop hl - bit BIT_B_BUTTON, a + bit B_PAD_B, a jr nz, .choseSecondMenuItem ; automatically choose the second option if B is pressed .pressedAButton ld a, [wCurrentMenuItem] @@ -484,7 +484,7 @@ DisplayFieldMoveMonMenu: jr z, .reachedName .skipNameLoop ; skip past current name ld a, [hli] - cp "@" + cp '@' jr nz, .skipNameLoop jr .skipNamesLoop .reachedName @@ -523,7 +523,7 @@ PokemonMenuEntries: GetMonFieldMoves: ld a, [wWhichPokemon] ld hl, wPartyMon1Moves - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld d, h ld e, l diff --git a/engine/menus/text_multi_button_prompt.asm b/engine/menus/text_multi_button_prompt.asm index 17208c13ba..5baac92bee 100644 --- a/engine/menus/text_multi_button_prompt.asm +++ b/engine/menus/text_multi_button_prompt.asm @@ -1,16 +1,16 @@ ; PureRGBnote: ADDED: ; A new "next page" function for text scripts that has more functionality ; inputs: (required) -; wMenuWatchedKeys - which buttons will jump out of the text script. A_BUTTON is an invalid option, it always proceeds the text script. +; wMenuWatchedKeys - which buttons will jump out of the text script. PAD_A is an invalid option, it always proceeds the text script. ; wMenuCursorLocation - the tilemap coordinate where the down arrow cursor should flash at. TextCommandPromptMultiButton:: call LoadDownArrowCoord - ld [hl], "▼" + ld [hl], '▼' call Delay3 call ManualTextScrollMultiButton call LoadDownArrowCoord - ld [hl], " " + ld [hl], ' ' ld a, d and a jr nz, .interrupted ; exit if they pressed one of the specified watched buttons @@ -32,7 +32,7 @@ TextCommandPromptMultiButton:: ManualTextScrollMultiButton:: call WaitForTextScrollSpecificButtonsPress ld a, d - bit BIT_A_BUTTON, a + bit B_PAD_A, a jr nz, .continueText ld d, 1 ret @@ -66,7 +66,7 @@ WaitForTextScrollSpecificButtonsPress:: ldh a, [hJoy5] ld d, a ld a, [wMenuWatchedKeys] - or A_BUTTON + or PAD_A and d jr z, .loop pop af diff --git a/engine/movie/credits.asm b/engine/movie/credits.asm index 68aaf80fd7..092152b833 100644 --- a/engine/movie/credits.asm +++ b/engine/movie/credits.asm @@ -6,12 +6,12 @@ HallOfFamePC: call DisableLCD ld hl, vFont ld bc, ($80 tiles) / 2 - call ZeroMemory + call ShiftFontColorIndex ld hl, vChars2 tile $60 ld bc, ($20 tiles) / 2 - call ZeroMemory + call ShiftFontColorIndex ld hl, vChars2 tile $7e - ld bc, 1 tiles + ld bc, TILE_SIZE ld a, $ff ; solid black call FillMemory hlcoord 0, 0 @@ -33,7 +33,7 @@ HallOfFamePC: ld [wNumCreditsMonsDisplayed], a jp Credits -FadeInCreditsText: +FadeInCredits: ld hl, HoFGBPalettes ld b, 4 .loop @@ -142,15 +142,18 @@ CreditsCopyTileMapToVRAM: ldh [hAutoBGTransferEnabled], a jp Delay3 -ZeroMemory: -; zero bc bytes at hl +ShiftFontColorIndex: +; Zero every second byte at hl, writing a total of bc bytes. +; When used on VRAM font characters that contain only black and white shades, +; it shifts the color index: black -> light gray, allowing palette-controlled +; text fade-in during the Credits roll, while the black bars remain solid. xor a ld [hli], a inc hl dec bc ld a, b or c - jr nz, ZeroMemory + jr nz, ShiftFontColorIndex ret FillFourRowsWithBlack: @@ -161,7 +164,7 @@ FillFourRowsWithBlack: FillMiddleOfScreenWithWhite: hlcoord 0, 4 ld bc, SCREEN_WIDTH * 10 - ld a, " " + ld a, ' ' jp FillMemory Credits: @@ -212,7 +215,7 @@ Credits: pop de jr .nextCreditsCommand .fadeInTextAndShowMon - call FadeInCreditsText + call FadeInCredits ld c, 90 jr .next1 .showTextAndShowMon @@ -222,7 +225,7 @@ Credits: call DisplayCreditsMon jr .nextCreditsScreen .fadeInText - call FadeInCreditsText + call FadeInCredits ld c, 120 jr .next2 .showText @@ -243,7 +246,7 @@ Credits: pop de ld de, TheEndGfx ld hl, vChars2 tile $60 - lb bc, BANK(TheEndGfx), (TheEndGfxEnd - TheEndGfx) / $10 + lb bc, BANK(TheEndGfx), (TheEndGfxEnd - TheEndGfx) / TILE_SIZE call CopyVideoData hlcoord 4, 8 ld de, TheEndTextString @@ -251,7 +254,7 @@ Credits: hlcoord 4, 9 inc de call PlaceString - jp FadeInCreditsText + jp FadeInCredits TheEndTextString: ; "T H E E N D" diff --git a/engine/movie/evolution.asm b/engine/movie/evolution.asm index b8445c9596..91318f50a1 100644 --- a/engine/movie/evolution.asm +++ b/engine/movie/evolution.asm @@ -30,7 +30,7 @@ EvolveMon: call Evolution_LoadPic ld de, vFrontPic ld hl, vBackPic - ld bc, 7 * 7 + ld bc, PIC_SIZE call CopyVideoData ld a, [wEvoOldSpecies] ld [wCurPartySpecies], a @@ -145,7 +145,7 @@ Evolution_CheckForCancel: call JoypadLowSensitivity ldh a, [hJoy5] pop bc - and B_BUTTON + and PAD_B jr nz, .pressedB .notAllowedToCancel dec c diff --git a/engine/movie/hall_of_fame.asm b/engine/movie/hall_of_fame.asm index 5c4214ec17..0c9012cf37 100644 --- a/engine/movie/hall_of_fame.asm +++ b/engine/movie/hall_of_fame.asm @@ -7,12 +7,12 @@ AnimateHallOfFame: call LoadTextBoxTilePatterns call DisableLCD ld hl, vBGMap0 - ld bc, $800 - ld a, " " + ld bc, 2 * TILEMAP_AREA + ld a, ' ' call FillMemory call EnableLCD ld hl, rLCDC - set rLCDC_BG_TILEMAP, [hl] + set B_LCDC_BG_MAP, [hl] xor a ld hl, wHallOfFame ld bc, HOF_TEAM @@ -51,7 +51,7 @@ AnimateHallOfFame: ld [wHoFPartyMonIndex], a call StoreHoFAltPaletteFlag ; PureRGBnote: ADDED: we will set a flag to indicate whether the pokemon uses alt palette or not ld hl, wPartyMon1Level - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld a, [hl] ld [wHoFMonLevel], a @@ -90,7 +90,7 @@ AnimateHallOfFame: xor a ldh [hWY], a ld hl, rLCDC - res rLCDC_BG_TILEMAP, [hl] + res B_LCDC_BG_MAP, [hl] ret ; PureRGBnote: ADDED: sets a flag in wHallofFamePalettes if the pokemon uses an alt palette. @@ -209,7 +209,7 @@ HoFLoadPlayerPics: call UncompressSpriteFromDE ld hl, sSpriteBuffer1 ld de, sSpriteBuffer0 - ld bc, $310 + ld bc, 2 * SPRITEBUFFERSIZE rst _CopyData ld de, vFrontPic call InterlaceMergeSpriteBuffers diff --git a/engine/movie/intro.asm b/engine/movie/intro.asm index e70b35b8fe..29ca2cbdf4 100644 --- a/engine/movie/intro.asm +++ b/engine/movie/intro.asm @@ -97,7 +97,7 @@ PlayIntroScene: ; hip ld a, SFX_INTRO_HIP rst _PlaySound - ld a, (FightIntroFrontMon2 - FightIntroFrontMon) / LEN_2BPP_TILE + ld a, (FightIntroFrontMon2 - FightIntroFrontMon) / TILE_SIZE ld [wIntroNidorinoBaseTile], a ld de, IntroNidorinoAnimation3 call AnimateIntroNidorino @@ -129,7 +129,7 @@ PlayIntroScene: call CheckForUserInterruption ret c - ld a, (FightIntroFrontMon2 - FightIntroFrontMon) / LEN_2BPP_TILE + ld a, (FightIntroFrontMon2 - FightIntroFrontMon) / TILE_SIZE ld [wIntroNidorinoBaseTile], a ld de, IntroNidorinoAnimation6 call AnimateIntroNidorino @@ -140,7 +140,7 @@ PlayIntroScene: ; lunge ld a, SFX_INTRO_LUNGE rst _PlaySound - ld a, (FightIntroFrontMon3 - FightIntroFrontMon) / LEN_2BPP_TILE + ld a, (FightIntroFrontMon3 - FightIntroFrontMon) / TILE_SIZE ld [wIntroNidorinoBaseTile], a ld de, IntroNidorinoAnimation7 ; fall through @@ -197,7 +197,7 @@ InitIntroNidorinoOAM: ld [hli], a ; X ld a, d ld [hli], a ; tile - ld a, OAM_BEHIND_BG + ld a, OAM_PRIO ld [hli], a ; attributes inc d dec c @@ -212,7 +212,7 @@ InitIntroNidorinoOAM: IntroClearScreen: ld hl, vBGMap1 - ld bc, BG_MAP_WIDTH * SCREEN_HEIGHT + ld bc, TILEMAP_WIDTH * SCREEN_HEIGHT jr IntroClearCommon IntroClearMiddleOfScreen: @@ -324,8 +324,8 @@ PlayShootingStar: call LoadIntroGraphics call EnableLCD ld hl, rLCDC - res rLCDC_WINDOW_ENABLE, [hl] - set rLCDC_BG_TILEMAP, [hl] + res B_LCDC_WINDOW, [hl] + set B_LCDC_BG_MAP, [hl] ld c, 64 rst _DelayFrames farcall AnimateShootingStar @@ -356,10 +356,10 @@ IntroDrawBlackBars: ld c, SCREEN_WIDTH * 4 call IntroPlaceBlackTiles ld hl, vBGMap1 - ld c, BG_MAP_WIDTH * 4 + ld c, TILEMAP_WIDTH * 4 call IntroPlaceBlackTiles hlbgcoord 0, 14, vBGMap1 - ld c, BG_MAP_WIDTH * 4 + ld c, TILEMAP_WIDTH * 4 jp IntroPlaceBlackTiles IntroNidorinoAnimation0: @@ -438,12 +438,12 @@ IntroNidorinoAnimation7: GameFreakIntro: INCBIN "gfx/splash/gamefreak_presents.2bpp" INCBIN "gfx/splash/gamefreak_logo.2bpp" - ds 16, $00 ; blank tile + ds TILE_SIZE, $00 ; blank tile GameFreakIntroEnd: FightIntroBackMon: INCBIN "gfx/intro/gengar.2bpp" - ds 16, $00 ; blank tile + ds TILE_SIZE, $00 ; blank tile FightIntroBackMonEnd: IF (DEF(_RED) || DEF(_GREEN)) ; PureRGBnote: GREENBUILD: pokemon green displays the nidorino intro diff --git a/engine/movie/oak_speech/clear_save.asm b/engine/movie/oak_speech/clear_save.asm index 13b2b05ea9..9534952a1a 100644 --- a/engine/movie/oak_speech/clear_save.asm +++ b/engine/movie/oak_speech/clear_save.asm @@ -15,7 +15,7 @@ DoClearSaveDialogue: ld a, [wCurrentMenuItem] and a jp z, Init - farcall ClearSAV + farcall ClearAllSRAMBanks jp Init ClearSaveDataText: diff --git a/engine/movie/oak_speech/oak_speech.asm b/engine/movie/oak_speech/oak_speech.asm index 1e52cb099e..e7676f7a70 100644 --- a/engine/movie/oak_speech/oak_speech.asm +++ b/engine/movie/oak_speech/oak_speech.asm @@ -157,6 +157,9 @@ ENDC ld a, SFX_SHRINK rst _PlaySound pop af +; bug: switching ROM Bank should not happen outside of Home Bank +; This code does nothing, as PlaySound does all necessary Bank switch +; It looks like a leftover from an early development stage call SetCurBank ld c, 4 rst _DelayFrames @@ -185,6 +188,7 @@ ENDC ld [wNewSoundID], a rst _PlaySound pop af +; bug: switching ROM Bank should not happen outside of Home Bank call SetCurBank IF DEF(_DEBUG) ld a, [wStatusFlags6] @@ -204,9 +208,11 @@ ENDC call GBFadeOutToWhite .skipDelay jp ClearScreen + OakSpeechText1: text_far _OakSpeechText1 text_end + OakSpeechText2: text_far _OakSpeechText2A ; BUG: The cry played does not match the sprite displayed. PureRGBnote: FIXED: Plays nidorino's cry now. @@ -220,12 +226,15 @@ OakSpeechText2: .2b text_far _OakSpeechText2B text_end + IntroducePlayerText: text_far _IntroducePlayerText text_end + IntroduceRivalText: text_far _IntroduceRivalText text_end + OakSpeechText3: text_far _OakSpeechText3 text_end @@ -279,7 +288,7 @@ IntroDisplayPicCenteredOrUpperRight: call UncompressSpriteFromDE ld hl, sSpriteBuffer1 ld de, sSpriteBuffer0 - ld bc, $310 + ld bc, 2 * SPRITEBUFFERSIZE rst _CopyData ld de, vFrontPic call InterlaceMergeSpriteBuffers diff --git a/engine/movie/oak_speech/oak_speech2.asm b/engine/movie/oak_speech/oak_speech2.asm index 7f61360555..8a6340d838 100644 --- a/engine/movie/oak_speech/oak_speech2.asm +++ b/engine/movie/oak_speech/oak_speech2.asm @@ -16,7 +16,7 @@ ChoosePlayerName: ld [wNamingScreenType], a call DisplayNamingScreen ld a, [wStringBuffer] - cp "@" + cp '@' jr z, .customName call ClearScreen call Delay3 @@ -49,7 +49,7 @@ ChooseRivalName: ld [wNamingScreenType], a call DisplayNamingScreen ld a, [wStringBuffer] - cp "@" + cp '@' jr z, .customName call ClearScreen call Delay3 @@ -176,7 +176,7 @@ DisplayIntroNameTextBox: ld [wLastMenuItem], a inc a ld [wTopMenuItemX], a - ld [wMenuWatchedKeys], a ; A_BUTTON + ld [wMenuWatchedKeys], a ; PAD_A inc a ld [wTopMenuItemY], a inc a @@ -186,7 +186,7 @@ DisplayIntroNameTextBox: .namestring db "NAME@" -INCLUDE "data/player_names.asm" +INCLUDE "data/player/names.asm" GetDefaultName: ; a = name index @@ -198,7 +198,7 @@ GetDefaultName: ld e, l .innerLoop ld a, [hli] - cp "@" + cp '@' jr nz, .innerLoop ld a, b cp c @@ -212,7 +212,7 @@ GetDefaultName: ld bc, NAME_BUFFER_LENGTH jp CopyData -INCLUDE "data/player_names_list.asm" +INCLUDE "data/player/names_list.asm" LinkMenuEmptyText: text_end diff --git a/engine/movie/splash.asm b/engine/movie/splash.asm index 7d5aba03ca..71ba148be4 100644 --- a/engine/movie/splash.asm +++ b/engine/movie/splash.asm @@ -15,7 +15,7 @@ LoadShootingStarGraphics: call CopyVideoData ld de, FallingStar ld hl, vChars1 tile $22 - lb bc, BANK(FallingStar), (FallingStarEnd - FallingStar) / $10 + lb bc, BANK(FallingStar), (FallingStarEnd - FallingStar) / TILE_SIZE call CopyVideoData ld hl, GameFreakLogoOAMData ld de, wShadowOAMSprite24 @@ -61,11 +61,11 @@ AnimateShootingStar: jr nz, .bigStarLoop ; Clear big star OAM. - ld hl, wShadowOAM + ld hl, wShadowOAMSprite00YCoord ld c, 4 - ld de, 4 + ld de, OBJ_SIZE .clearOAMLoop - ld [hl], 160 + ld [hl], SCREEN_HEIGHT_PX + OAM_Y_OFS add hl, de dec c jr nz, .clearOAMLoop @@ -148,7 +148,7 @@ AnimateShootingStar: ; shift the existing OAM entries down to make room for the next wave ld hl, wShadowOAMSprite04 ld de, wShadowOAM - ld bc, $50 + ld bc, OBJ_SIZE * 20 rst _CopyData pop af @@ -161,7 +161,7 @@ AnimateShootingStar: ret SmallStarsOAM: - dbsprite 0, 0, 0, 0, $A2, OAM_BEHIND_BG | OAM_OBP1 + dbsprite 0, 0, 0, 0, $A2, OAM_PRIO | OAM_PAL1 SmallStarsOAMEnd: SmallStarsWaveCoordsPointerTable: @@ -259,10 +259,10 @@ GameFreakLogoOAMDataEnd: GameFreakShootingStarOAMData: ;shinpokerednote: gbcnote: changing the attribute to use palette 4 via GBC bits ;last column is byte 3 of OAM data; the attribute byte - db $00,$A0,$A0,$14 - db $00,$A8,$A0,$34 - db $08,$A0,$A1,$14 - db $08,$A8,$A1,$34 + dbsprite 20, 0, 0, 0, $a0, $04 + dbsprite 21, 0, 0, 0, $a0, $04 | OAM_XFLIP + dbsprite 20, 1, 0, 0, $a1, $04 + dbsprite 21, 1, 0, 0, $a1, $04 | OAM_XFLIP GameFreakShootingStarOAMDataEnd: FallingStar:: INCBIN "gfx/splash/falling_star.2bpp" diff --git a/engine/movie/title.asm b/engine/movie/title.asm index 70732ceed9..151199e2da 100644 --- a/engine/movie/title.asm +++ b/engine/movie/title.asm @@ -103,7 +103,7 @@ DisplayTitleScreen: ; place tiles for title screen copyright hlcoord 2, 17 ld de, .tileScreenCopyrightTiles - ld b, $10 + ld b, .tileScreenCopyrightTilesEnd - .tileScreenCopyrightTiles .tileScreenCopyrightTilesLoop ld a, [de] ld [hli], a @@ -115,6 +115,7 @@ DisplayTitleScreen: .tileScreenCopyrightTiles db $41,$42,$43,$42,$44,$42,$45,$46,$47,$48,$49,$4A,$4B,$4C,$4D,$4E ; ©'95.'96.'98 GAME FREAK inc. +.tileScreenCopyrightTilesEnd .next call SaveScreenTilesToBuffer2 @@ -274,12 +275,12 @@ ENDC ;;;;;;; ldh a, [hJoyHeld] ld b, a - and D_UP | SELECT | B_BUTTON - cp D_UP | SELECT | B_BUTTON + and PAD_UP | PAD_SELECT | PAD_B + cp PAD_UP | PAD_SELECT | PAD_B jp z, .doClearSaveDialogue IF DEF(_DEBUG) ld a, b - bit BIT_SELECT, a + bit B_PAD_SELECT, a jp nz, DebugMenu ENDC jp MainMenu @@ -392,8 +393,8 @@ DrawPlayerCharacter: ClearBothBGMaps: ld hl, vBGMap0 - ld bc, $400 * 2 - ld a, " " + ld bc, 2 * TILEMAP_AREA + ld a, ' ' jp FillMemory LoadTitleMonSprite: @@ -416,7 +417,7 @@ LoadCopyrightAndTextBoxTiles: LoadCopyrightTiles: ld de, NintendoCopyrightLogoGraphics ld hl, vChars2 tile $60 - lb bc, BANK(NintendoCopyrightLogoGraphics), (GameFreakLogoGraphicsEnd - NintendoCopyrightLogoGraphics) / $10 + lb bc, BANK(NintendoCopyrightLogoGraphics), (GameFreakLogoGraphicsEnd - NintendoCopyrightLogoGraphics) / TILE_SIZE call CopyVideoData hlcoord 2, 7 ld de, CopyrightTextString diff --git a/engine/movie/trade.asm b/engine/movie/trade.asm index 376f004a56..55b8b19250 100644 --- a/engine/movie/trade.asm +++ b/engine/movie/trade.asm @@ -149,8 +149,8 @@ Trade_Delay80: Trade_ClearTileMap: hlcoord 0, 0 - ld bc, SCREEN_WIDTH * SCREEN_HEIGHT - ld a, " " + ld bc, SCREEN_AREA + ld a, ' ' jp FillMemory LoadTradingGFXAndMonNames: @@ -167,8 +167,8 @@ LoadTradingGFXAndMonNames: ld a, BANK(TradingAnimationGraphics2) call FarCopyData2 ld hl, vBGMap0 - ld bc, $800 - ld a, " " + ld bc, 2 * TILEMAP_AREA + ld a, ' ' call FillMemory call ClearSprites ld a, $ff @@ -225,7 +225,7 @@ Trade_Cleanup: ret Trade_ShowPlayerMon: - ld a, %10101011 + ld a, LCDC_ON | LCDC_WIN_9800 | LCDC_WIN_ON | LCDC_BLOCK21 | LCDC_BG_9C00 | LCDC_OBJ_8 | LCDC_OBJ_ON | LCDC_BG_ON ldh [rLCDC], a ld a, $50 ldh [hWY], a @@ -280,7 +280,7 @@ Trade_DrawOpenEndOfLinkCable: ld a, $a0 ldh [hSCX], a rst _DelayFrame - ld a, %10001011 + ld a, LCDC_ON | LCDC_WIN_9800 | LCDC_WIN_OFF | LCDC_BLOCK21 | LCDC_BG_9C00 | LCDC_OBJ_8 | LCDC_OBJ_ON | LCDC_BG_ON ldh [rLCDC], a hlcoord 6, 2 ld b, TILEMAP_LINK_CABLE @@ -318,7 +318,7 @@ Trade_AnimateBallEnteringLinkCable: ld [wLinkCableAnimBulgeToggle], a add $7e ld hl, wShadowOAMSprite00TileID - ld de, 4 + ld de, OBJ_SIZE ld c, e .cycleLinkCableBulgeTile ld [hl], a @@ -340,7 +340,7 @@ Trade_AnimateBallEnteringLinkCable: ld a, $1 ldh [hAutoBGTransferEnabled], a call ClearScreen - ld b, $98 + ld b, HIGH(vBGMap0) call CopyScreenTileBufferToVRAM call Delay3 xor a @@ -349,9 +349,9 @@ Trade_AnimateBallEnteringLinkCable: Trade_BallInsideLinkCableOAMBlock: db $7e, 0 - db $7e, OAM_HFLIP - db $7e, OAM_VFLIP - db $7e, OAM_HFLIP | OAM_VFLIP + db $7e, OAM_XFLIP + db $7e, OAM_YFLIP + db $7e, OAM_XFLIP | OAM_YFLIP Trade_ShowEnemyMon: ld a, TRADE_BALL_TILT_ANIM @@ -459,7 +459,7 @@ Trade_InitGameboyTransferGfx: ldh [hAutoBGTransferEnabled], a call Trade_LoadMonPartySpriteGfx rst _DelayFrame - ld a, %10101011 + ld a, LCDC_ON | LCDC_WIN_9800 | LCDC_WIN_ON | LCDC_BLOCK21 | LCDC_BG_9C00 | LCDC_OBJ_8 | LCDC_OBJ_ON | LCDC_BG_ON ldh [rLCDC], a xor a ldh [hSCX], a @@ -624,7 +624,7 @@ Trade_AnimCircledMon: dec c jr nz, .loopMon ld hl, wShadowOAM + $04 + $04 + $04 + $04 + $02 ; OAM tile id and skip the mon. - ld de, $4 + ld de, OBJ_SIZE ld c, $10 .loopCable ;;;;;;;;;; @@ -742,28 +742,28 @@ Trade_CircleOAMBlocks: trade_circle_oam_block .OAMBlock3, 24, 24 .OAMBlock0: - db ICON_TRADEBUBBLE << 2 + 0, OAM_OBP1 - db ICON_TRADEBUBBLE << 2 + 1, OAM_OBP1 - db ICON_TRADEBUBBLE << 2 + 2, OAM_OBP1 - db ICON_TRADEBUBBLE << 2 + 3, OAM_OBP1 + db ICON_TRADEBUBBLE << 2 + 0, OAM_PAL1 + db ICON_TRADEBUBBLE << 2 + 1, OAM_PAL1 + db ICON_TRADEBUBBLE << 2 + 2, OAM_PAL1 + db ICON_TRADEBUBBLE << 2 + 3, OAM_PAL1 .OAMBlock1: - db ICON_TRADEBUBBLE << 2 + 1, OAM_OBP1 | OAM_HFLIP - db ICON_TRADEBUBBLE << 2 + 0, OAM_OBP1 | OAM_HFLIP - db ICON_TRADEBUBBLE << 2 + 3, OAM_OBP1 | OAM_HFLIP - db ICON_TRADEBUBBLE << 2 + 2, OAM_OBP1 | OAM_HFLIP + db ICON_TRADEBUBBLE << 2 + 1, OAM_PAL1 | OAM_XFLIP + db ICON_TRADEBUBBLE << 2 + 0, OAM_PAL1 | OAM_XFLIP + db ICON_TRADEBUBBLE << 2 + 3, OAM_PAL1 | OAM_XFLIP + db ICON_TRADEBUBBLE << 2 + 2, OAM_PAL1 | OAM_XFLIP .OAMBlock2: - db ICON_TRADEBUBBLE << 2 + 2, OAM_OBP1 | OAM_VFLIP - db ICON_TRADEBUBBLE << 2 + 3, OAM_OBP1 | OAM_VFLIP - db ICON_TRADEBUBBLE << 2 + 0, OAM_OBP1 | OAM_VFLIP - db ICON_TRADEBUBBLE << 2 + 1, OAM_OBP1 | OAM_VFLIP + db ICON_TRADEBUBBLE << 2 + 2, OAM_PAL1 | OAM_YFLIP + db ICON_TRADEBUBBLE << 2 + 3, OAM_PAL1 | OAM_YFLIP + db ICON_TRADEBUBBLE << 2 + 0, OAM_PAL1 | OAM_YFLIP + db ICON_TRADEBUBBLE << 2 + 1, OAM_PAL1 | OAM_YFLIP .OAMBlock3: - db ICON_TRADEBUBBLE << 2 + 3, OAM_OBP1 | OAM_HFLIP | OAM_VFLIP - db ICON_TRADEBUBBLE << 2 + 2, OAM_OBP1 | OAM_HFLIP | OAM_VFLIP - db ICON_TRADEBUBBLE << 2 + 1, OAM_OBP1 | OAM_HFLIP | OAM_VFLIP - db ICON_TRADEBUBBLE << 2 + 0, OAM_OBP1 | OAM_HFLIP | OAM_VFLIP + db ICON_TRADEBUBBLE << 2 + 3, OAM_PAL1 | OAM_XFLIP | OAM_YFLIP + db ICON_TRADEBUBBLE << 2 + 2, OAM_PAL1 | OAM_XFLIP | OAM_YFLIP + db ICON_TRADEBUBBLE << 2 + 1, OAM_PAL1 | OAM_XFLIP | OAM_YFLIP + db ICON_TRADEBUBBLE << 2 + 0, OAM_PAL1 | OAM_XFLIP | OAM_YFLIP ; a = species Trade_LoadMonSprite: @@ -786,7 +786,7 @@ Trade_ShowClearedWindow: ld a, $1 ldh [hAutoBGTransferEnabled], a call ClearScreen - ld a, %11100011 + ld a, LCDC_DEFAULT ldh [rLCDC], a ld a, $7 ldh [rWX], a diff --git a/engine/overworld/auto_movement.asm b/engine/overworld/auto_movement.asm index 00492aa8cc..49097de07e 100644 --- a/engine/overworld/auto_movement.asm +++ b/engine/overworld/auto_movement.asm @@ -1,15 +1,15 @@ PlayerStepOutFromDoor:: - ld hl, wStatusFlags5 ; should this be wMovementFlags? - res BIT_EXITING_DOOR, [hl] + ld hl, wStatusFlags5 + res BIT_UNKNOWN_5_1, [hl] call IsPlayerStandingOnDoorTile ;;;;;;;;;; PureRGBnote: CHANGED: this code was slightly updated to allow calling from arbitrary places jr nc, ForceStepFromDoor.notStandingOnDoor ForceStepOutFromDoor:: - ld d, D_DOWN + ld d, PAD_DOWN ForceStepFromDoor:: ld a, d push af - ld a, SELECT | START | D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_SELECT | PAD_START | PAD_RIGHT | PAD_LEFT | PAD_UP | PAD_DOWN ld [wJoyIgnore], a ld hl, wMovementFlags set BIT_EXITING_DOOR, [hl] @@ -85,7 +85,7 @@ PalletMovementScript_OakMoveLeft: .done ld hl, wStatusFlags7 set BIT_NO_MAP_MUSIC, [hl] - ld a, SELECT | START | D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_SELECT | PAD_START | PAD_CTRL_PAD ld [wJoyIgnore], a ret @@ -141,11 +141,11 @@ RLEList_ProfOakWalkToLab: db -1 ; end RLEList_PlayerWalkToLab: - db D_UP, 2 - db D_RIGHT, 3 - db D_DOWN, 5 - db D_LEFT, 1 - db D_DOWN, 6 + db PAD_UP, 2 + db PAD_RIGHT, 3 + db PAD_DOWN, 5 + db PAD_LEFT, 1 + db PAD_DOWN, 6 db -1 ; end PalletMovementScript_Done: @@ -196,9 +196,9 @@ PewterMovementScript_WalkToMuseum: RLEList_PewterMuseumPlayer: db NO_INPUT, 1 - db D_UP, 3 - db D_LEFT, 13 - db D_UP, 6 + db PAD_UP, 3 + db PAD_LEFT, 13 + db PAD_UP, 6 db -1 ; end RLEList_PewterMuseumGuy: @@ -256,11 +256,11 @@ PewterMovementScript_WalkToGym: RLEList_PewterGymPlayer: db NO_INPUT, 1 - db D_RIGHT, 2 - db D_DOWN, 5 - db D_LEFT, 11 - db D_UP, 5 - db D_LEFT, 15 + db PAD_RIGHT, 2 + db PAD_DOWN, 5 + db PAD_LEFT, 11 + db PAD_UP, 5 + db PAD_LEFT, 15 db -1 ; end RLEList_PewterGymGuy: diff --git a/engine/overworld/cut.asm b/engine/overworld/cut.asm index 838ac57cbe..e34d516396 100644 --- a/engine/overworld/cut.asm +++ b/engine/overworld/cut.asm @@ -105,13 +105,13 @@ InitCutAnimOAM: call LoadCutGrassAnimationTilePattern call WriteCutOrBoulderDustAnimationOAMBlock ld hl, wShadowOAMSprite36Attributes - ld de, 4 - ld a, $30 + ld de, OBJ_SIZE + ld a, OAM_XFLIP | OAM_PAL1 ld c, e .loop ld [hl], a add hl, de - xor $60 + xor OAM_YFLIP | OAM_XFLIP dec c jr nz, .loop ret @@ -131,10 +131,10 @@ WriteCutOrBoulderDustAnimationOAMBlock: ; tile ID, attributes ; TODO: update second byte with constants like OAM_OBP1 ; shinpokerednote: gbcnote: updated attributes for GBC - db $FC,%00010100 - db $FD,%00010100 - db $FE,%00010100 - db $FF,%00010100 + db $fc, OAM_PAL1 | %00000100 + db $fd, OAM_PAL1 | %00000100 + db $fe, OAM_PAL1 | %00000100 + db $ff, OAM_PAL1 | %00000100 GetCutOrBoulderDustAnimationOffsets: ld hl, wSpritePlayerStateData1YPixels diff --git a/engine/overworld/cut2.asm b/engine/overworld/cut2.asm index b62bdc04d5..35d63a768f 100644 --- a/engine/overworld/cut2.asm +++ b/engine/overworld/cut2.asm @@ -82,15 +82,15 @@ AnimCutGrass_UpdateOAMEntries: AnimCutGrass_SwapOAMEntries: ld hl, wShadowOAMSprite36 ld de, wBuffer - ld bc, $8 + ld bc, 2 * OBJ_SIZE rst _CopyData ld hl, wShadowOAMSprite38 ld de, wShadowOAMSprite36 - ld bc, $8 + ld bc, 2 * OBJ_SIZE rst _CopyData ld hl, wBuffer ld de, wShadowOAMSprite38 - ld bc, $8 + ld bc, 2 * OBJ_SIZE jp CopyData AdjustOAMBlockXPos3start: diff --git a/engine/overworld/dust_smoke.asm b/engine/overworld/dust_smoke.asm index bdc9551b46..0a2e1565e0 100644 --- a/engine/overworld/dust_smoke.asm +++ b/engine/overworld/dust_smoke.asm @@ -82,7 +82,7 @@ LoadSmokeTileFourTimesCommon:: push hl call LoadSmokeTile pop hl - ld bc, 1 tiles + ld bc, TILE_SIZE add hl, bc pop bc dec c @@ -91,7 +91,7 @@ LoadSmokeTileFourTimesCommon:: LoadSmokeTile: ld de, SSAnneSmokePuffTile - lb bc, BANK(SSAnneSmokePuffTile), (SSAnneSmokePuffTileEnd - SSAnneSmokePuffTile) / $10 + lb bc, BANK(SSAnneSmokePuffTile), (SSAnneSmokePuffTileEnd - SSAnneSmokePuffTile) / TILE_SIZE jp CopyVideoData SSAnneSmokePuffTile: diff --git a/engine/overworld/ledges.asm b/engine/overworld/ledges.asm index 77e9943f9f..99eea881f2 100644 --- a/engine/overworld/ledges.asm +++ b/engine/overworld/ledges.asm @@ -49,7 +49,7 @@ HandleLedges:: ldh a, [hJoyHeld] and e ret z - ld a, A_BUTTON | B_BUTTON | SELECT | START | D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_BUTTONS | PAD_CTRL_PAD ld [wJoyIgnore], a ld hl, wMovementFlags set BIT_LEDGE_OR_FISHING, [hl] @@ -84,19 +84,19 @@ HandleLedges:: lda_coord 8, 10 cp $41 ; down ledge ret nz - ld e, D_DOWN + ld e, PAD_DOWN jr .noCutTile .left lda_coord 7, 9 cp $30 ; left ledge ret nz - ld e, D_LEFT + ld e, PAD_LEFT jr .noCutTile .right lda_coord 10, 9 cp $40 ; right ledge ret nz - ld e, D_RIGHT + ld e, PAD_RIGHT jr .noCutTile ;;;;;;;; @@ -107,7 +107,7 @@ INCLUDE "data/tilesets/ledge_tiles.asm" LoadHoppingShadowOAM: ld hl, vChars1 tile $7f ld de, LedgeHoppingShadow - lb bc, BANK(LedgeHoppingShadow), (LedgeHoppingShadowEnd - LedgeHoppingShadow) / $8 + lb bc, BANK(LedgeHoppingShadow), (LedgeHoppingShadowEnd - LedgeHoppingShadow) / TILE_1BPP_SIZE call CopyVideoDataDouble ld a, $9 lb bc, $54, $48 ; b, c = y, x coordinates of shadow @@ -120,7 +120,7 @@ LedgeHoppingShadowEnd: LedgeHoppingShadowOAMBlock: ; tile ID, attributes - db $ff, OAM_OBP1 - db $ff, OAM_HFLIP - db $ff, OAM_VFLIP - db $ff, OAM_HFLIP | OAM_VFLIP + db $ff, OAM_PAL1 + db $ff, OAM_XFLIP + db $ff, OAM_YFLIP + db $ff, OAM_XFLIP | OAM_YFLIP diff --git a/engine/overworld/missable_objects.asm b/engine/overworld/missable_objects.asm index 3d71ed3395..6381d2ab04 100644 --- a/engine/overworld/missable_objects.asm +++ b/engine/overworld/missable_objects.asm @@ -15,9 +15,6 @@ MarkTownVisitedAndLoadMissableObjects:: add hl, bc ld a, [hli] ; load missable objects pointer in hl ld h, [hl] - ; fall through - -LoadMissableObjects: ld l, a push hl @@ -249,10 +246,10 @@ MissableObjectFlagAction: ld a, b and a jr z, .reset - cp 2 + cp FLAG_TEST jr z, .read -.set +; set ld a, [hl] ld b, a ld a, d diff --git a/engine/overworld/movement.asm b/engine/overworld/movement.asm index 6e2867f973..9b7752d263 100644 --- a/engine/overworld/movement.asm +++ b/engine/overworld/movement.asm @@ -83,7 +83,7 @@ UpdatePlayerSprite: and a jr nz, .doneSpeed ldh a, [hJoyHeld] - and B_BUTTON + and PAD_B jr z, .doneSpeed ld c, 2 .doneSpeed @@ -115,7 +115,7 @@ UpdatePlayerSprite: call TestGrassTile2 ld a, 0 jr nz, .next2 - ld a, OAM_BEHIND_BG + ld a, OAM_PRIO .next2 ld [wSpritePlayerStateData2GrassPriority], a ret @@ -177,7 +177,7 @@ UpdateNPCSprite: ld b, a ld a, [wFontLoaded] bit BIT_FONT_LOADED, a - jp nz, notYetMoving + jp nz, NotYetMoving ld a, b cp $2 jp z, UpdateSpriteMovementDelay ; [x#SPRITESTATEDATA1_MOVEMENTSTATUS] == 2 @@ -466,14 +466,15 @@ UpdateSpriteMovementDelay: ld [hl], a ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; dec [hl] ; x#SPRITESTATEDATA2_MOVEMENTDELAY - jr nz, notYetMoving + jr nz, NotYetMoving .moving dec h ldh a, [hCurrentSpriteOffset] inc a ld l, a ld [hl], $1 ; [x#SPRITESTATEDATA1_MOVEMENTSTATUS] = 1 (mark as ready to move) -notYetMoving: + ; fallthrough +NotYetMoving: ld h, HIGH(wSpriteStateData1) ldh a, [hCurrentSpriteOffset] add SPRITESTATEDATA1_ANIMFRAMECOUNTER @@ -488,7 +489,7 @@ MakeNPCFacePlayer: ; disabled. This is only done when rubbing the S.S. Anne captain's back. ld a, [wStatusFlags3] bit BIT_NO_NPC_FACE_PLAYER, a - jr nz, notYetMoving + jr nz, NotYetMoving res BIT_FACE_PLAYER, [hl] ld a, [wPlayerDirection] bit PLAYER_DIR_BIT_UP, a @@ -510,7 +511,7 @@ MakeNPCFacePlayer: add $9 ld l, a ld [hl], c ; [x#SPRITESTATEDATA1_FACINGDIRECTION]: set facing direction - jr notYetMoving + jr NotYetMoving InitializeSpriteStatus: ld [hl], $1 ; [x#SPRITESTATEDATA1_MOVEMENTSTATUS] = ready @@ -623,7 +624,7 @@ CheckSpriteAvailability: call TestGrassTile2 ld a, 0 jr nz, .notInGrass - ld a, OAM_BEHIND_BG + ld a, OAM_PRIO .notInGrass ld [hl], a ; x#SPRITESTATEDATA2_GRASSPRIORITY and a diff --git a/engine/overworld/pathfinding.asm b/engine/overworld/pathfinding.asm index 5eece65e48..50c3b222b0 100644 --- a/engine/overworld/pathfinding.asm +++ b/engine/overworld/pathfinding.asm @@ -90,7 +90,7 @@ CalcPositionOfPlayerRelativeToNPC: ld a, [hli] ; NPC sprite screen Y position in pixels call CalcDifference jr nc, .NPCSouthOfOrAlignedWithPlayer -.NPCNorthOfPlayer +; NPC north of player push hl ld hl, hNPCPlayerRelativePosFlags bit BIT_PLAYER_LOWER_Y, [hl] @@ -118,7 +118,7 @@ CalcPositionOfPlayerRelativeToNPC: ld a, [hl] ; NPC sprite screen X position in pixels call CalcDifference jr nc, .NPCEastOfOrAlignedWithPlayer -.NPCWestOfPlayer +; NPC west of player push hl ld hl, hNPCPlayerRelativePosFlags bit BIT_PLAYER_LOWER_X, [hl] @@ -187,8 +187,8 @@ ConvertNPCMovementDirectionToJoypadMask: ret NPCMovementDirectionsToJoypadMasksTable: - db NPC_MOVEMENT_UP, D_UP - db NPC_MOVEMENT_DOWN, D_DOWN - db NPC_MOVEMENT_LEFT, D_LEFT - db NPC_MOVEMENT_RIGHT, D_RIGHT + db NPC_MOVEMENT_UP, PAD_UP + db NPC_MOVEMENT_DOWN, PAD_DOWN + db NPC_MOVEMENT_LEFT, PAD_LEFT + db NPC_MOVEMENT_RIGHT, PAD_RIGHT db $ff diff --git a/engine/overworld/player_animations.asm b/engine/overworld/player_animations.asm index c1d5d52e2d..1936a04d13 100644 --- a/engine/overworld/player_animations.asm +++ b/engine/overworld/player_animations.asm @@ -203,7 +203,7 @@ LeaveMapThroughHoleAnim: ld [wShadowOAMSprite02TileID], a ld a, [wShadowOAMSprite01TileID] ld [wShadowOAMSprite03TileID], a - ld a, $a0 + ld a, SCREEN_HEIGHT_PX + OAM_Y_OFS ld [wShadowOAMSprite00YCoord], a ld [wShadowOAMSprite01YCoord], a ld c, 2 @@ -214,7 +214,7 @@ LeaveMapThroughHoleAnim: call PlayNewSoundChannel5 ;;;;;;;;;; ; hide upper half of player's sprite - ld a, $a0 + ld a, SCREEN_HEIGHT_PX + OAM_Y_OFS ld [wShadowOAMSprite02YCoord], a ld [wShadowOAMSprite03YCoord], a call GBFadeOutToWhite @@ -239,7 +239,7 @@ InitFacingDirectionList: ld [wSavedPlayerScreenY], a ld hl, PlayerSpinningFacingOrder ld de, wFacingDirectionList - ld bc, 4 + ld bc, OBJ_SIZE rst _CopyData ld a, [wSpritePlayerStateData1ImageIndex] ; (image index is locked to standing images) ld hl, wFacingDirectionList @@ -263,7 +263,7 @@ SpinPlayerSprite: push hl ld hl, wFacingDirectionList ld de, wFacingDirectionList - 1 - ld bc, 4 + ld bc, OBJ_SIZE rst _CopyData ld a, [wFacingDirectionList - 1] ld [wFacingDirectionList + 3], a @@ -368,7 +368,7 @@ FishingAnim: ld hl, FishingRodOAM add hl, bc ld de, wShadowOAMSprite39 - ld bc, $4 + ld bc, OBJ_SIZE rst _CopyData ;;;;;;;;;; PureRGBnote: CHANGED: fishing animation wait time is randomized instead of hardcoded 100 frames. call Random @@ -403,7 +403,7 @@ FishingAnim: ld a, [wSpritePlayerStateData1ImageIndex] ; (image index is locked to standing images) cp SPRITE_FACING_UP jr nz, .skipHidingFishingRod - ld a, $a0 + ld a, SCREEN_HEIGHT_PX + OAM_Y_OFS ld [wShadowOAMSprite39YCoord], a .skipHidingFishingRod @@ -452,7 +452,7 @@ FishingRodOAM: dbsprite 9, 11, 4, 3, $c0, 0 ; down dbsprite 9, 8, 4, 4, $c0, 0 ; up dbsprite 8, 10, 0, 0, $c1, 0 ; left - dbsprite 11, 10, 0, 0, $c1, OAM_HFLIP ; right + dbsprite 11, 10, 0, 0, $c1, OAM_XFLIP ; right MACRO fishing_gfx dw \1 diff --git a/engine/overworld/player_state.asm b/engine/overworld/player_state.asm index f32bd5f394..d32f0729fc 100644 --- a/engine/overworld/player_state.asm +++ b/engine/overworld/player_state.asm @@ -252,7 +252,7 @@ PrintSafariZoneSteps:: cp 10 jr nc, .tenOrMore hlcoord 5, 3 - ld [hl], " " + ld [hl], ' ' .tenOrMore hlcoord 6, 3 ld de, wNumSafariBalls diff --git a/engine/overworld/push_boulder.asm b/engine/overworld/push_boulder.asm index 561a49fec5..f96a0a0229 100644 --- a/engine/overworld/push_boulder.asm +++ b/engine/overworld/push_boulder.asm @@ -37,7 +37,7 @@ TryPushingBoulder:: set BIT_TRIED_PUSH_BOULDER, [hl] ret z ; the player must try pushing twice before the boulder will move ldh a, [hJoyHeld] - and D_RIGHT | D_LEFT | D_UP | D_DOWN + and PAD_CTRL_PAD ret z predef CheckForCollisionWhenPushingBoulder ld a, [wTileInFrontOfBoulderAndBoulderCollisionResult] @@ -52,23 +52,23 @@ TryPushingBoulder:: jr z, .pushBoulderLeft cp SPRITE_FACING_RIGHT jr z, .pushBoulderRight -.pushBoulderDown - bit BIT_D_DOWN, b +; push boulder down + bit B_PAD_DOWN, b ret z ld de, PushBoulderDownMovementData jr .done .pushBoulderUp - bit BIT_D_UP, b + bit B_PAD_UP, b ret z ld de, PushBoulderUpMovementData jr .done .pushBoulderLeft - bit BIT_D_LEFT, b + bit B_PAD_LEFT, b ret z ld de, PushBoulderLeftMovementData jr .done .pushBoulderRight - bit BIT_D_RIGHT, b + bit B_PAD_RIGHT, b ret z ld de, PushBoulderRightMovementData .done diff --git a/engine/overworld/spinners.asm b/engine/overworld/spinners.asm index cef1b6f7c0..5da72c3a06 100644 --- a/engine/overworld/spinners.asm +++ b/engine/overworld/spinners.asm @@ -181,7 +181,7 @@ CheckStartStopSpinning:: ret nz ; if we're already spinning don't replay the sound or reload joyignore ld a, SFX_ARROW_TILES rst _PlaySound - ld a, A_BUTTON | B_BUTTON | SELECT | START | D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_A | PAD_B | PAD_SELECT | PAD_START | PAD_RIGHT | PAD_LEFT | PAD_UP | PAD_DOWN ld [wJoyIgnore], a ret .next @@ -205,16 +205,16 @@ CheckStartStopSpinning:: ; 2nd byte: bottom right tile player must be standing on ; 3rd byte: direction it should move player SpinnerTilesFacilityTileset: - db $30, $30, D_RIGHT - db $20, $20, D_LEFT - db $21, $31, D_UP - db $20, $30, D_DOWN + db $30, $30, PAD_RIGHT + db $20, $20, PAD_LEFT + db $21, $31, PAD_UP + db $20, $30, PAD_DOWN db -1 SpinnerTilesGymTileset: - db $4D, $4D, D_RIGHT - db $4C, $4C, D_LEFT - db $3C, $3D, D_UP - db $4C, $4D, D_DOWN + db $4D, $4D, PAD_RIGHT + db $4C, $4C, PAD_LEFT + db $3C, $3D, PAD_UP + db $4C, $4D, PAD_DOWN db -1 ;;;;; \ No newline at end of file diff --git a/engine/overworld/update_map.asm b/engine/overworld/update_map.asm index 72982e0e1c..dc006aaa07 100644 --- a/engine/overworld/update_map.asm +++ b/engine/overworld/update_map.asm @@ -210,7 +210,7 @@ RedrawMapView:: ld a, [hli] ld h, [hl] ld l, a - ld de, -2 * BG_MAP_WIDTH + ld de, -2 * TILEMAP_WIDTH add hl, de ld a, h and $3 @@ -235,7 +235,7 @@ RedrawMapView:: jr nz, .calcWRAMAddrLoop call CopyToRedrawRowOrColumnSrcTiles pop hl - ld de, BG_MAP_WIDTH + ld de, TILEMAP_WIDTH ldh a, [hRedrawMapViewRowOffset] ld c, a .calcVRAMAddrLoop diff --git a/engine/overworld/wild_mons.asm b/engine/overworld/wild_mons.asm index 8fb95af5ed..fea035ed82 100644 --- a/engine/overworld/wild_mons.asm +++ b/engine/overworld/wild_mons.asm @@ -16,10 +16,10 @@ LoadWildData:: jr z, .NoGrassData ; if no grass data, skip to surfing data push hl ld de, wGrassMons ; otherwise, load grass data - ld bc, $14 + ld bc, WILDDATA_LENGTH - 1 rst _CopyData pop hl - ld bc, $14 + ld bc, WILDDATA_LENGTH - 1 add hl, bc .NoGrassData ld a, [hli] @@ -27,7 +27,7 @@ LoadWildData:: and a jr z, .loadPaletteData ; if no water data, no need to load it ld de, wWaterMons ; otherwise, load surfing data - ld bc, $14 + ld bc, WILDDATA_LENGTH - 1 rst _CopyData .loadPaletteData jp GetWildPokemonPalettes ; PureRGBnote: ADDED: we always need to load the palette flags for wild pokemon on loading a map. diff --git a/engine/pokemon/add_mon.asm b/engine/pokemon/add_mon.asm index dc1564438c..04da66d662 100644 --- a/engine/pokemon/add_mon.asm +++ b/engine/pokemon/add_mon.asm @@ -78,7 +78,7 @@ ENDC .next3 ldh a, [hNewPartyLength] dec a - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld e, l ld d, h @@ -138,12 +138,12 @@ ENDC .next4 push bc - ld bc, wPartyMon1DVs - wPartyMon1 + ld bc, MON_DVS add hl, bc pop bc ld [hli], a ld [hl], b ; write IVs - ld bc, (wPartyMon1HPExp - 1) - (wPartyMon1DVs + 1) + ld bc, (MON_HP_EXP - 1) - (MON_DVS + 1) add hl, bc ld a, 1 ld c, a @@ -163,7 +163,7 @@ ENDC inc de jr .copyMonTypesAndMoves .copyEnemyMonData - ld bc, wEnemyMon1DVs - wEnemyMon1 + ld bc, MON_DVS add hl, bc ld a, [wEnemyMonDVs] ; copy IVs from cur enemy mon ld [hli], a @@ -283,13 +283,13 @@ ENDC dec a jr nz, .calcFreshStats ld hl, wEnemyMonMaxHP - ld bc, $a + ld bc, NUM_STATS * 2 rst _CopyData ; copy stats of cur enemy mon pop hl jr .done .calcFreshStats pop hl - ld bc, wPartyMon1HPExp - 1 - wPartyMon1 + ld bc, MON_HP_EXP - 1 add hl, bc ld b, $0 call CalcStats ; calculate fresh set of stats @@ -352,7 +352,7 @@ _AddEnemyMonToPlayerParty:: ld hl, wPartyMons ld a, [wPartyCount] dec a - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld e, l ld d, h @@ -433,16 +433,16 @@ _MoveMon:: .copySpecies ld [hli], a ; write new mon ID to wPartySpecies on the last byte where party ends (eg 5 if 5 pokemon now in party) ld [hl], $ff ; write new sentinel -.findMonDataDest +; find mon data dest ld a, [wMoveMonType] dec a ld hl, wPartyMons - ld bc, wPartyMon2 - wPartyMon1 ; $2c + ld bc, PARTYMON_STRUCT_LENGTH ld a, [wPartyCount] jr nz, .addMonOffset ; if it's PARTY_TO_BOX ld hl, wBoxMons - ld bc, wBoxMon2 - wBoxMon1 ; $21 + ld bc, BOXMON_STRUCT_LENGTH ld a, [wBoxCount] .addMonOffset dec a @@ -454,20 +454,20 @@ _MoveMon:: ld a, [wMoveMonType] and a ld hl, wBoxMons - ld bc, wBoxMon2 - wBoxMon1 ; $21 + ld bc, BOXMON_STRUCT_LENGTH jr z, .addMonOffset2 cp DAYCARE_TO_PARTY ld hl, wDayCareMon jr z, .copyMonData ld hl, wPartyMons - ld bc, wPartyMon2 - wPartyMon1 ; $2c + ld bc, PARTYMON_STRUCT_LENGTH .addMonOffset2 ld a, [wWhichPokemon] call AddNTimes .copyMonData push hl push de - ld bc, wBoxMon2 - wBoxMon1 + ld bc, BOXMON_STRUCT_LENGTH rst _CopyData pop de pop hl @@ -476,7 +476,7 @@ _MoveMon:: jr z, .findOTdest cp DAYCARE_TO_PARTY jr z, .findOTdest - ld bc, wBoxMon2 - wBoxMon1 + ld bc, BOXMON_STRUCT_LENGTH add hl, bc ld a, [hl] ; hl = Level inc de @@ -515,7 +515,7 @@ _MoveMon:: ld bc, NAME_LENGTH rst _CopyData ld a, [wMoveMonType] -.findNickDest +; find nick dest cp PARTY_TO_DAYCARE ld de, wDayCareMonName jr z, .findNickSrc @@ -551,6 +551,7 @@ _MoveMon:: jr z, .done cp PARTY_TO_DAYCARE jr z, .done + ; returning mon to party, compute level and stats push hl srl a add $2 @@ -560,13 +561,13 @@ _MoveMon:: ld a, d ld [wCurEnemyLevel], a pop hl - ld bc, wBoxMon2 - wBoxMon1 - add hl, bc + ld bc, BOXMON_STRUCT_LENGTH + add hl, bc ; hl = wPartyMon*Level ld [hli], a ld d, h ld e, l - ld bc, -18 - add hl, bc + ld bc, (MON_HP_EXP - 1) - MON_STATS + add hl, bc ; hl = wPartyMon*HPExp - 1 ld b, $1 call CalcStats .done diff --git a/engine/pokemon/bills_pc.asm b/engine/pokemon/bills_pc.asm index cbed084818..c51789162c 100644 --- a/engine/pokemon/bills_pc.asm +++ b/engine/pokemon/bills_pc.asm @@ -72,7 +72,7 @@ DisplayPCMainMenu:: ld de, LogOffPCText .next3 call PlaceString - ld a, A_BUTTON | B_BUTTON + ld a, PAD_A | PAD_B ld [wMenuWatchedKeys], a ld a, 2 ld [wTopMenuItemY], a @@ -132,7 +132,7 @@ BillsPCMenu: inc hl ld a, 4 ld [hli], a ; wMaxMenuItem - ld a, A_BUTTON | B_BUTTON | SELECT + ld a, PAD_A | PAD_B | PAD_SELECT ld [hli], a ; wMenuWatchedKeys xor a ld [hli], a ; wLastMenuItem @@ -150,7 +150,7 @@ BillsPCMenu: call Delay3 .handleMenuInput call HandleMenuInput - bit BIT_SELECT, a + bit B_PAD_SELECT, a jr z, .notSelect ld a, [wCurrentMenuItem] and a @@ -159,7 +159,7 @@ BillsPCMenu: SetFlag FLAG_VIEW_PC_PKMN jp BillsPCWithdraw .notSelect - bit BIT_B_BUTTON, a + bit B_PAD_B, a jp nz, ExitBillsPC call PlaceUnfilledArrowMenuCursor ld a, [wCurrentMenuItem] @@ -229,19 +229,19 @@ BillsPCDeposit: call WaitForSoundToFinish ld hl, wBoxNumString ld a, [wCurrentBoxNum] - and $7f + and BOX_NUM_MASK cp 9 jr c, .singleDigitBoxNum sub 9 - ld [hl], "1" + ld [hl], '1' inc hl - add "0" + add '0' jr .next .singleDigitBoxNum - add "1" + add '1' .next ld [hli], a - ld [hl], "@" + ld [hl], '@' ld hl, MonWasStoredText rst _PrintText ;jp BillsPCMenu @@ -359,7 +359,7 @@ BillsPCRelease: rst _PrintText xor a ld [wCurrentMenuItem], a - ld a, A_BUTTON | B_BUTTON + ld a, PAD_A | PAD_B ld [wMenuWatchedKeys], a .loopYesNo ld hl, YesNoSmall @@ -369,18 +369,18 @@ BillsPCRelease: ld [wListPointer + 1], a callfar DisplayMultiChoiceMenu ldh a, [hJoy5] - bit BIT_B_BUTTON, a + bit B_PAD_B, a jr nz, .doneReleaseDialogBox - bit BIT_START, a + bit B_PAD_START, a ld a, [wCurrentMenuItem] jr nz, .continue and a jr nz, .doneReleaseDialogBox - ; a button was pressed, tell the player to press START + ; a button was pressed, tell the player to press PAD_START ld hl, PressStartToReleaseText rst _PrintText ld a, [wMenuWatchedKeys] - or START + or PAD_START ld [wMenuWatchedKeys], a jr .loopYesNo .continue @@ -434,11 +434,11 @@ BillsPCMenuText: ;KnowsHMMove:: ; returns whether mon with party index [wWhichPokemon] knows an HM move ; ld hl, wPartyMon1Moves -; ld bc, wPartyMon2 - wPartyMon1 +; ld bc, PARTYMON_STRUCT_LENGTH ; jr .next ; unreachable ;ld hl, wBoxMon1Moves - ;ld bc, wBoxMon2 - wBoxMon1 + ;ld bc, BOXMON_STRUCT_LENGTH ;.next ; ld a, [wWhichPokemon] ; call AddNTimes @@ -486,7 +486,7 @@ DisplayDepositWithdrawMenu: inc hl ld a, 2 ld [hli], a ; wMaxMenuItem - ld a, A_BUTTON | B_BUTTON + ld a, PAD_A | PAD_B ld [hli], a ; wMenuWatchedKeys xor a ld [hl], a ; wLastMenuItem @@ -496,7 +496,7 @@ DisplayDepositWithdrawMenu: ld [wPlayerMonNumber], a .loop call HandleMenuInput - bit BIT_B_BUTTON, a + bit B_PAD_B, a jr nz, .exit ld a, [wCurrentMenuItem] and a @@ -627,6 +627,7 @@ JustAMomentText:: text_far _JustAMomentText text_end +UnusedOpenBillsPC: ; unreferenced ld a, [wSpritePlayerStateData1FacingDirection] cp SPRITE_FACING_UP ret nz diff --git a/engine/pokemon/change_mon_species.asm b/engine/pokemon/change_mon_species.asm index c142745247..7af7ff4581 100644 --- a/engine/pokemon/change_mon_species.asm +++ b/engine/pokemon/change_mon_species.asm @@ -88,7 +88,7 @@ CheckMonNickNameDefault:: inc de cp b jr nz, .noMatch - cp "@" + cp '@' jr nz, .loop ; they're the same, so rename .rename @@ -100,7 +100,7 @@ CheckMonNickNameDefault:: .loop2 ld a, [de] ld [hli], a - cp "@" + cp '@' ret z inc de jr .loop2 diff --git a/engine/pokemon/evos_moves.asm b/engine/pokemon/evos_moves.asm index 8b0d47a8ab..accfd8c61b 100644 --- a/engine/pokemon/evos_moves.asm +++ b/engine/pokemon/evos_moves.asm @@ -205,13 +205,13 @@ Evolution_PartyMonLoop: ; loop over party mons call CalcStats ld a, [wWhichPokemon] ld hl, wPartyMon1 - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld e, l ld d, h push hl push bc - ld bc, wPartyMon1MaxHP - wPartyMon1 + ld bc, MON_MAXHP add hl, bc ld a, [hli] ld b, a @@ -334,7 +334,7 @@ RenameEvolvedMon: cp [hl] inc hl ret nz - cp "@" + cp '@' jr nz, .compareNamesLoop ld a, [wWhichPokemon] ld bc, NAME_LENGTH @@ -418,7 +418,7 @@ LearnMoveFromLevelUp: ; If it is not 0, this function will not work properly. ld hl, wPartyMon1Moves ld a, [wWhichPokemon] - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes .next ld b, NUM_MOVES @@ -556,7 +556,7 @@ WriteMonMoves: ; shift PP as well if learning moves from day care push de - ld bc, wPartyMon1PP - (wPartyMon1Moves + 3) + ld bc, MON_PP - (MON_MOVES + 3) add hl, bc ld d, h ld e, l @@ -575,7 +575,7 @@ WriteMonMoves: ; write move PP value if learning moves from day care push hl ld a, [hl] - ld hl, wPartyMon1PP - wPartyMon1Moves + ld hl, MON_PP - MON_MOVES add hl, de push hl dec a diff --git a/engine/pokemon/learn_move.asm b/engine/pokemon/learn_move.asm index 0df7b8b026..5c33e95105 100644 --- a/engine/pokemon/learn_move.asm +++ b/engine/pokemon/learn_move.asm @@ -10,7 +10,7 @@ LearnMove: DontAbandonLearning: ld hl, wPartyMon1Moves - ld bc, wPartyMon2Moves - wPartyMon1Moves + ld bc, PARTYMON_STRUCT_LENGTH ld a, [wWhichPokemon] call AddNTimes ld d, h @@ -38,7 +38,7 @@ DontAbandonLearning: .next ld a, [wMoveNum] ld [hl], a - ld bc, wPartyMon1PP - wPartyMon1Moves + ld bc, MON_PP - MON_MOVES add hl, bc push hl push de @@ -66,7 +66,7 @@ DontAbandonLearning: ld de, wBattleMonMoves ld bc, NUM_MOVES rst _CopyData - ld bc, wPartyMon1PP - wPartyMon1OTID + ld bc, MON_PP - MON_OTID add hl, bc ld de, wBattleMonPP ld bc, NUM_MOVES @@ -119,7 +119,7 @@ TryingToLearn: rst _PrintText SetEvent FLAG_SKIP_MULTI_CHOICE_LOADGBPAL ld hl, YesNoHideTM - ld b, A_BUTTON | B_BUTTON + ld b, PAD_A | PAD_B call DisplayMultiChoiceTextBox jr nz, .no ; if B button was pressed assume "no" ld a, [wCurrentMenuItem] @@ -173,14 +173,14 @@ TryingToLearn: inc hl ld a, [wNumMovesMinusOne] ld [hli], a ; wMaxMenuItem - ld a, A_BUTTON | START | B_BUTTON ; PureRGBnote: ADDED: START button is tracked in this menu + ld a, PAD_A | PAD_START | PAD_B ; PureRGBnote: ADDED: START button is tracked in this menu ld [hli], a ; wMenuWatchedKeys ld [hl], 0 ; wLastMenuItem ld hl, hUILayoutFlags set BIT_DOUBLE_SPACED_MENU, [hl] .menuLoop call HandleMenuInput - bit BIT_A_BUTTON, a ; PureRGBnote: FIXED: Press START to learn a move instead of A to prevent accidental mashing A move-forget woes + bit B_PAD_A, a ; PureRGBnote: FIXED: Press START to learn a move instead of A to prevent accidental mashing A move-forget woes jr nz, .pressStart ld hl, hUILayoutFlags res BIT_DOUBLE_SPACED_MENU, [hl] @@ -188,7 +188,7 @@ TryingToLearn: call LoadScreenTilesFromBuffer1 pop af pop hl - bit BIT_B_BUTTON, a + bit B_PAD_B, a jr nz, .cancel push hl ld a, [wCurrentMenuItem] diff --git a/engine/pokemon/load_mon_data.asm b/engine/pokemon/load_mon_data.asm index 7a39f08374..87a2be8be1 100644 --- a/engine/pokemon/load_mon_data.asm +++ b/engine/pokemon/load_mon_data.asm @@ -23,7 +23,7 @@ LoadMonData_:: call GetMonHeader ld hl, wPartyMons - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH ld a, [wMonDataLocation] cp ENEMY_PARTY_DATA jr c, .getMonEntry @@ -31,9 +31,9 @@ LoadMonData_:: ld hl, wEnemyMons jr z, .getMonEntry - cp 2 + cp BOX_DATA ld hl, wBoxMons - ld bc, wBoxMon2 - wBoxMon1 + ld bc, BOXMON_STRUCT_LENGTH jr z, .getMonEntry ld hl, wDayCareMon @@ -45,5 +45,5 @@ LoadMonData_:: .copyMonData ld de, wLoadedMon - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH jp CopyData diff --git a/engine/pokemon/pikablu.asm b/engine/pokemon/pikablu.asm index 5100e1f4bc..40e7861e4d 100644 --- a/engine/pokemon/pikablu.asm +++ b/engine/pokemon/pikablu.asm @@ -21,7 +21,7 @@ CopyName: inc de ld [hli], a ld a, [de] - cp "@" + cp '@' jr nz, .loopName ld [hl], a ; load string terminator ret diff --git a/engine/pokemon/remove_mon.asm b/engine/pokemon/remove_mon.asm index 60ec8c27e6..ee47f0c8d4 100644 --- a/engine/pokemon/remove_mon.asm +++ b/engine/pokemon/remove_mon.asm @@ -2,15 +2,16 @@ _RemovePokemon:: ld hl, wPartyCount ld a, [wRemoveMonFromBox] and a - jr z, .usePartyCount + jr z, .gotCount ld hl, wBoxCount -.usePartyCount +.gotCount ld a, [hl] dec a ld [hli], a + ld a, [wWhichPokemon] ld c, a - ld b, $0 + ld b, 0 add hl, bc ld e, l ld d, h @@ -21,21 +22,27 @@ _RemovePokemon:: ld [hli], a inc a ; reached terminator? jr nz, .shiftMonSpeciesLoop ; if not, continue shifting species + ld hl, wPartyMonOT ld d, PARTY_LENGTH - 1 ; max number of pokemon to shift ld a, [wRemoveMonFromBox] and a - jr z, .usePartyMonOTs + jr z, .gotOTsPointer ld hl, wBoxMonOT ld d, MONS_PER_BOX - 1 -.usePartyMonOTs +.gotOTsPointer ld a, [wWhichPokemon] call SkipFixedLengthTextEntries ld a, [wWhichPokemon] cp d ; are we removing the last pokemon? jr nz, .notRemovingLastMon ; if not, shift the pokemon below - ld [hl], $ff ; else, write the terminator and return + + ; bug: to erase a string, this should be ld [hl], '@' + ; This is not needed, as wBoxSpecies/wPartySpecies determine if a slot is used. + ; Besides, existing mon nick is left untouched + ld [hl], $ff ret + .notRemovingLastMon ld d, h ld e, l @@ -44,44 +51,49 @@ _RemovePokemon:: ld bc, wPartyMonNicks ld a, [wRemoveMonFromBox] and a - jr z, .usePartyMonNicks + jr z, .gotNicksPointer ld bc, wBoxMonNicks -.usePartyMonNicks +.gotNicksPointer call CopyDataUntil + ld hl, wPartyMons - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH ld a, [wRemoveMonFromBox] and a - jr z, .usePartyMonStructs + jr z, .gotMonStructs ld hl, wBoxMons - ld bc, wBoxMon2 - wBoxMon1 -.usePartyMonStructs + ld bc, BOXMON_STRUCT_LENGTH +.gotMonStructs ld a, [wWhichPokemon] call AddNTimes ; get address of the pokemon removed - ld d, h ; store in de for CopyDataUntil + + ld d, h ; de = start address for CopyDataUntil ld e, l ld a, [wRemoveMonFromBox] and a - jr z, .copyUntilPartyMonOTs - ld bc, wBoxMon2 - wBoxMon1 - add hl, bc ; get address of pokemon after the pokemon removed - ld bc, wBoxMonOT ; address of when to stop copying - jr .continue -.copyUntilPartyMonOTs - ld bc, wPartyMon2 - wPartyMon1 - add hl, bc ; get address of pokemon after the pokemon removed - ld bc, wPartyMonOT ; address of when to stop copying -.continue - call CopyDataUntil ; shift all pokemon data after the removed mon to the removed mon's location + jr z, .copyUntilPartyMonOT +; copy until wBoxMonOT + ld bc, BOXMON_STRUCT_LENGTH + add hl, bc ; get address of next slot + ld bc, wBoxMonOT + jr .shiftOTs +.copyUntilPartyMonOT + ld bc, PARTYMON_STRUCT_LENGTH + add hl, bc ; get address of next slot + ld bc, wPartyMonOT +.shiftOTs + call CopyDataUntil ; shift all pokemon data up one slot + ld hl, wPartyMonNicks ld a, [wRemoveMonFromBox] and a - jr z, .usePartyMonNicks2 + jr z, .gotNicksPointer2 ld hl, wBoxMonNicks -.usePartyMonNicks2 +.gotNicksPointer2 ld bc, NAME_LENGTH ld a, [wWhichPokemon] call AddNTimes + ld d, h ld e, l ld bc, NAME_LENGTH @@ -89,7 +101,7 @@ _RemovePokemon:: ld bc, wPartyMonNicksEnd ld a, [wRemoveMonFromBox] and a - jr z, .copyUntilPartyMonNicksEnd + jr z, .shiftMonNicks ld bc, wBoxMonNicksEnd -.copyUntilPartyMonNicksEnd - jp CopyDataUntil +.shiftMonNicks + jp CopyDataUntil ; shift all pokemon nicknames up one slot diff --git a/engine/pokemon/set_types.asm b/engine/pokemon/set_types.asm index 2cf8f14c7f..d42c3cf307 100644 --- a/engine/pokemon/set_types.asm +++ b/engine/pokemon/set_types.asm @@ -1,7 +1,7 @@ ; updates the types of a party mon (pointed to in hl) to the ones of the mon specified in [wPokedexNum] SetPartyMonTypes: call GetPredefRegisters - ld bc, wPartyMon1Type - wPartyMon1 ; $5 + ld bc, MON_TYPE add hl, bc ld a, [wPokedexNum] ld [wCurSpecies], a diff --git a/engine/pokemon/status_ailments.asm b/engine/pokemon/status_ailments.asm index 05205a3481..3cc2d4903f 100644 --- a/engine/pokemon/status_ailments.asm +++ b/engine/pokemon/status_ailments.asm @@ -10,37 +10,17 @@ PrintStatusAilment:: jr nz, .par and SLP_MASK ret z - ld a, "S" - ld [hli], a - ld a, "L" - ld [hli], a - ld [hl], "P" + ld_hli_a_string "SLP" ret .psn - ld a, "P" - ld [hli], a - ld a, "S" - ld [hli], a - ld [hl], "N" + ld_hli_a_string "PSN" ret .brn - ld a, "B" - ld [hli], a - ld a, "R" - ld [hli], a - ld [hl], "N" + ld_hli_a_string "BRN" ret .frz - ld a, "F" - ld [hli], a - ld a, "R" - ld [hli], a - ld [hl], "Z" + ld_hli_a_string "FRZ" ret .par - ld a, "P" - ld [hli], a - ld a, "A" - ld [hli], a - ld [hl], "R" + ld_hli_a_string "PAR" ret diff --git a/engine/pokemon/status_screen.asm b/engine/pokemon/status_screen.asm index 919c65c0f9..711ae42a5b 100644 --- a/engine/pokemon/status_screen.asm +++ b/engine/pokemon/status_screen.asm @@ -52,7 +52,7 @@ DrawHP_: ld de, wLoadedMonHP lb bc, 2, 3 call PrintNumber - ld a, "/" + ld a, '/' ld [hli], a ld de, wLoadedMonMaxHP lb bc, 2, 3 @@ -61,8 +61,6 @@ DrawHP_: pop de ret - -; Predef 0x37 StatusScreen: call LoadMonData ld a, [wMonDataLocation] @@ -75,12 +73,12 @@ StatusScreen: ld hl, wLoadedMonHPExp - 1 ld de, wLoadedMonStats ld b, $1 - call CalcStats ; Recalculate stats + call CalcStats .DontRecalculate ld hl, wStatusFlags2 set BIT_NO_AUDIO_FADE_OUT, [hl] ld a, $33 - ldh [rNR50], a ; Reduce the volume + ldh [rAUDVOL], a ; Reduce the volume call GBPalWhiteOutWithDelay3 call ClearScreen call UpdateSprites @@ -119,15 +117,15 @@ StatusScreen: call DrawLineBox ; Draws the box around name, HP and status ld de, -6 add hl, de - ld a, "" + ld a, '' ld [hld], a - ld [hl], "№" + ld [hl], '№' hlcoord 19, 9 lb bc, 8, 6 call DrawLineBox ; Draws the box around types, ID No. and OT hlcoord 10, 9 - ld de, Type1Text - call PlaceString ; "TYPE1/" + ld de, TypesIDNoOTText + call PlaceString hlcoord 11, 3 predef DrawHP ld hl, wStatusScreenHPBarColor @@ -146,7 +144,7 @@ StatusScreen: ld de, StatusText call PlaceString ; "STATUS/" hlcoord 14, 2 - call PrintLevel ; Pokémon level + call PrintLevel ld a, [wMonHIndex] ld [wPokedexNum], a ld [wCurSpecies], a @@ -173,7 +171,7 @@ StatusScreen: ld de, wLoadedMonOTID lb bc, LEADING_ZEROES | 2, 5 call PrintNumber ; ID Number - ld d, $0 + ld d, STATUS_SCREEN_STATS_BOX call PrintStatsBox ;;;;; PureRGBnote: ADDED: If the pokemon has max DVs, display the APEX prompt on their status screen. call DoesLoadedMonHaveMaxDVs @@ -221,20 +219,11 @@ NamePointers2: dw wBoxMonNicks dw wDayCareMonName -Type1Text: +TypesIDNoOTText: db "TYPE1/" - next "" - ; fallthrough -Type2Text: - db "TYPE2/" - next "" - ; fallthrough -IDNoText: - db "№/" - next "" - ; fallthrough -OTText: - db "OT/" + next "TYPE2/" + next "№/" + next "OT/" next "@" StatusText: @@ -265,38 +254,40 @@ PTile: INCBIN "gfx/font/P.1bpp" PrintStatsBox: ld a, d - and a ; a is 0 from the status screen - jr nz, .DifferentBox + ASSERT STATUS_SCREEN_STATS_BOX == 0 + and a + jr nz, .LevelUpStatsBox ; battle or Rare Candy hlcoord 0, 8 lb bc, 8, 8 - call TextBoxBorder ; Draws the box - hlcoord 1, 9 ; Start printing stats from here - ld bc, $19 ; Number offset + call TextBoxBorder + hlcoord 1, 9 + ld bc, SCREEN_WIDTH + 5 ; one row down and 5 columns right jr .PrintStats -.DifferentBox +.LevelUpStatsBox hlcoord 9, 2 lb bc, 8, 9 call TextBoxBorder hlcoord 11, 3 - ld bc, $18 + ld bc, SCREEN_WIDTH + 4 ; one row down and 4 columns right .PrintStats push bc push hl - ld de, StatsText + ld de, .StatsText call PlaceString pop hl pop bc add hl, bc ld de, wLoadedMonAttack lb bc, 2, 3 - call PrintStat + call .PrintStat ld de, wLoadedMonDefense - call PrintStat + call .PrintStat ld de, wLoadedMonSpeed - call PrintStat + call .PrintStat ld de, wLoadedMonSpecial jp PrintNumber -PrintStat: + +.PrintStat: push hl call PrintNumber pop hl @@ -304,7 +295,7 @@ PrintStat: add hl, de ret -StatsText: +.StatsText: db "ATTACK" next "DEFENSE" next "SPEED" @@ -337,18 +328,18 @@ StatusScreen2: call PlaceString ; Print moves ld a, [wNumMovesMinusOne] inc a - ld c, a - n_sub_a 4 - ld b, a ; Number of moves ? + ld c, a ; number of known moves + n_sub_a NUM_MOVES + ld b, a ; number of blank moves hlcoord 11, 10 ld de, SCREEN_WIDTH * 2 - ld a, "" + ld a, '' call StatusScreen_PrintPP ; Print "PP" ld a, b and a jr z, .InitPP ld c, a - ld a, "-" + ld a, '-' call StatusScreen_PrintPP ; Fill the rest with -- .InitPP ld hl, wLoadedMonMoves @@ -374,7 +365,7 @@ StatusScreen2: pop de pop hl push hl - ld bc, wPartyMon1PP - wPartyMon1Moves - 1 + ld bc, MON_PP - MON_MOVES - 1 add hl, bc ld a, [hl] and PP_MASK @@ -385,7 +376,7 @@ StatusScreen2: ld de, wStatusScreenCurrentPP lb bc, 1, 2 call PrintNumber - ld a, "/" + ld a, '/' ld [hli], a ld de, wMaxPP lb bc, 1, 2 @@ -399,7 +390,7 @@ StatusScreen2: pop bc inc b ld a, b - cp $4 + cp NUM_MOVES jr nz, .PrintPP .PPDone hlcoord 9, 3 @@ -413,7 +404,7 @@ StatusScreen2: ld [wLoadedMonLevel], a ; Increase temporarily if not 100 .Level100 hlcoord 14, 6 - ld a, "" + ld a, '' ld [hli], a inc hl call PrintLevel @@ -428,8 +419,11 @@ StatusScreen2: hlcoord 7, 6 lb bc, 3, 7 call PrintNumber ; exp needed to level up + + ; unneeded, this clears the diacritic characters in JPN versions hlcoord 9, 0 call StatusScreen_ClearName + hlcoord 9, 1 call StatusScreen_ClearName ld a, [wMonHIndex] @@ -474,8 +468,8 @@ StatusScreenExpText: next "LEVEL UP@" StatusScreen_ClearName: - ld bc, 10 - ld a, " " + ld bc, NAME_LENGTH - 1 + ld a, ' ' jp FillMemory StatusScreen_PrintPP: @@ -493,12 +487,12 @@ StatusScreenOriginal: ldh a, [hTileAnimations] push af call StatusScreen - ld b, A_BUTTON | B_BUTTON + ld b, PAD_A | PAD_B call PokedexStatusWaitForButtonPressLoop - bit BIT_B_BUTTON, a + bit B_PAD_B, a jr nz, ExitStatusScreen call StatusScreen2 - ld b, A_BUTTON | B_BUTTON + ld b, PAD_A | PAD_B call PokedexStatusWaitForButtonPressLoop ExitStatusScreen: pop af @@ -521,17 +515,17 @@ StatusScreenLoop: .displayNextMon call StatusScreen call PokemonStatusWaitForButtonPress - bit BIT_D_UP, a + bit B_PAD_UP, a jr nz, .prevMon - bit BIT_D_DOWN, a + bit B_PAD_DOWN, a jr nz, .nextMon - bit BIT_B_BUTTON, a + bit B_PAD_B, a jr nz, .exitStatus call StatusScreen2 call PokemonStatusWaitForButtonPress - bit BIT_D_UP, a + bit B_PAD_UP, a jr nz, .prevMon - bit BIT_D_DOWN, a + bit B_PAD_DOWN, a jr nz, .nextMon .exitStatus jp ExitStatusScreen @@ -550,13 +544,13 @@ StatusScreenLoop: PokemonStatusWaitForButtonPress: .decideButtons - ld a, A_BUTTON | B_BUTTON + ld a, PAD_A | PAD_B ld b, a ld a, [wWhichPokemon] and a jr z, .checkRight ld a, b - or D_UP + or PAD_UP ld b, a .checkRight ld a, [wPartyCount] @@ -566,7 +560,7 @@ PokemonStatusWaitForButtonPress: cp c jr z, PokedexStatusWaitForButtonPressLoop ld a, b - or D_DOWN + or PAD_DOWN ld b, a PokedexStatusWaitForButtonPressLoop: .waitForButtonPress diff --git a/engine/slots/slot_machine.asm b/engine/slots/slot_machine.asm index 1f401bd299..7d7cc3ff55 100644 --- a/engine/slots/slot_machine.asm +++ b/engine/slots/slot_machine.asm @@ -69,7 +69,7 @@ MainSlotMachineLoop: rst _PrintText call SaveScreenTilesToBuffer1 .loop - ld a, A_BUTTON | B_BUTTON + ld a, PAD_A | PAD_B ld [wMenuWatchedKeys], a ld a, 2 ld [wMaxMenuItem], a @@ -88,7 +88,7 @@ MainSlotMachineLoop: ld de, CoinMultiplierSlotMachineText call PlaceString call HandleMenuInput - and B_BUTTON + and PAD_B jp nz, LoadScreenTilesFromBuffer1 ld a, [wCurrentMenuItem] n_sub_a 3 @@ -445,7 +445,7 @@ SlotMachine_CheckForMatches: ld h, [hl] ld l, a ld de, wStringBuffer - ld bc, 4 + ld bc, 4 ; every SlotReward*Text is at most 4 bytes rst _CopyData pop hl call hl_caller @@ -634,7 +634,7 @@ SlotMachine_PrintWinningSymbol: inc a ld [hl], a hlcoord 18, 16 - ld [hl], "▼" + ld [hl], '▼' ret SlotMachine_SubtractBetFromPlayerCoins: @@ -847,7 +847,7 @@ SlotMachine_HandleInputWhileWheelsSpin: rst _DelayFrame call JoypadLowSensitivity ldh a, [hJoy5] - and A_BUTTON + and PAD_A ret z ld hl, wStoppingWhichSlotMachineWheel ld a, [hl] diff --git a/gfx/battle/move_anim_2.png b/gfx/battle/move_anim_2.png index 2f4122e341..79c8d416ff 100644 Binary files a/gfx/battle/move_anim_2.png and b/gfx/battle/move_anim_2.png differ diff --git a/gfx/overworld/power_plant_roof_extra_tiles.png b/gfx/overworld/power_plant_roof_extra_tiles.png index a57923f38b..002fd63cdd 100644 Binary files a/gfx/overworld/power_plant_roof_extra_tiles.png and b/gfx/overworld/power_plant_roof_extra_tiles.png differ diff --git a/gfx/overworld/red_fish_back.png b/gfx/overworld/red_fish_back.png index 0972377cb0..fd29ddab88 100644 Binary files a/gfx/overworld/red_fish_back.png and b/gfx/overworld/red_fish_back.png differ diff --git a/gfx/overworld/red_fish_front.png b/gfx/overworld/red_fish_front.png index e18a27d811..0d76b4284d 100644 Binary files a/gfx/overworld/red_fish_front.png and b/gfx/overworld/red_fish_front.png differ diff --git a/gfx/overworld/red_fish_side.png b/gfx/overworld/red_fish_side.png index 11f25c2a66..faab54742e 100644 Binary files a/gfx/overworld/red_fish_side.png and b/gfx/overworld/red_fish_side.png differ diff --git a/gfx/pokemon/front_alt/articuno.png b/gfx/pokemon/front_alt/articuno.png index 38c8916ddc..56a1e90687 100644 Binary files a/gfx/pokemon/front_alt/articuno.png and b/gfx/pokemon/front_alt/articuno.png differ diff --git a/gfx/pokemon/front_alt/jynx.png b/gfx/pokemon/front_alt/jynx.png index 250250e984..edb7a3efe2 100644 Binary files a/gfx/pokemon/front_alt/jynx.png and b/gfx/pokemon/front_alt/jynx.png differ diff --git a/gfx/sprites/ghost.png b/gfx/sprites/ghost.png index b4a80b32c5..ba7ee0ad0e 100644 Binary files a/gfx/sprites/ghost.png and b/gfx/sprites/ghost.png differ diff --git a/gfx/tilesets/electricity/electricity.png b/gfx/tilesets/electricity/electricity.png index cfc9021ca1..9cf686da9c 100644 Binary files a/gfx/tilesets/electricity/electricity.png and b/gfx/tilesets/electricity/electricity.png differ diff --git a/gfx/tilesets/volcano.png b/gfx/tilesets/volcano.png index 5bc5a05f3c..31b7c74fc5 100644 Binary files a/gfx/tilesets/volcano.png and b/gfx/tilesets/volcano.png differ diff --git a/home/bankswitch.asm b/home/bankswitch.asm index 3327b7db63..7882f4f61a 100644 --- a/home/bankswitch.asm +++ b/home/bankswitch.asm @@ -25,7 +25,7 @@ Bankswitch:: BankswitchCommon:: ; shinpokerednote: audionote: gbcnote: new function jump address from yellow SetCurBank:: ; PureRGBnote: CHANGED: a lot of functions in home bank ran the next 2 lines of code, we can save a lot of space in home by simply calling this subroutine instead. ldh [hLoadedROMBank], a - ld [MBC1RomBank], a + ld [rROMB], a ret hl_caller:: diff --git a/home/clear_sprites.asm b/home/clear_sprites.asm index 6d1066fae7..c18b1ff3f2 100644 --- a/home/clear_sprites.asm +++ b/home/clear_sprites.asm @@ -9,10 +9,10 @@ ClearSprites:: ret HideSprites:: - ld a, 160 - ld hl, wShadowOAM - ld de, 4 - ld b, 40 + ld a, SCREEN_HEIGHT_PX + OAM_Y_OFS + ld hl, wShadowOAMSprite00YCoord + ld de, OBJ_SIZE + ld b, OAM_COUNT .loop ld [hl], a add hl, de diff --git a/home/copy2.asm b/home/copy2.asm index 1ed15a8e23..0ea6857115 100644 --- a/home/copy2.asm +++ b/home/copy2.asm @@ -190,39 +190,39 @@ CopyVideoDataDouble:: ClearScreenArea:: ; Clear tilemap area cxb at hl. - ld a, " " ; blank tile - ld de, 20 ; screen width -.y + ld a, ' ' + ld de, SCREEN_WIDTH +.loopRows push hl push bc -.x +.loopTiles ld [hli], a dec c - jr nz, .x + jr nz, .loopTiles pop bc pop hl add hl, de dec b - jr nz, .y + jr nz, .loopRows ret CopyScreenTileBufferToVRAM:: ; Copy wTileMap to the BG Map starting at b * $100. ; This is done in thirds of 6 rows, so it takes 3 frames. - ld c, 6 + ld c, SCREEN_HEIGHT / 3 - ld hl, $600 * 0 + lb hl, 0, 0 decoord 0, 6 * 0 call .setup rst _DelayFrame - ld hl, $600 * 1 + lb hl, SCREEN_HEIGHT / 3, 0 decoord 0, 6 * 1 call .setup rst _DelayFrame - ld hl, $600 * 2 + lb hl, 2 * SCREEN_HEIGHT / 3, 0 decoord 0, 6 * 2 call .setup rst _DelayFrame @@ -245,10 +245,10 @@ CopyScreenTileBufferToVRAM:: ClearScreen:: ; Clear wTileMap, then wait ; for the bg map to update. - ld bc, 20 * 18 + ld bc, SCREEN_AREA inc b hlcoord 0, 0 - ld a, " " + ld a, ' ' .loop ld [hli], a dec c diff --git a/home/copy_string.asm b/home/copy_string.asm index 05f9ba80c5..3531aaf827 100644 --- a/home/copy_string.asm +++ b/home/copy_string.asm @@ -8,6 +8,6 @@ CopyString:: ld a, [de] inc de ld [hli], a - cp "@" + cp '@' jr nz, CopyString ret diff --git a/home/fade_audio.asm b/home/fade_audio.asm new file mode 100644 index 0000000000..a78ee2107b --- /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, [wStatusFlags2] + bit BIT_NO_AUDIO_FADE_OUT, a + ret nz + ld a, $77 + ldh [rAUDVOL], 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, [rAUDVOL] + 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 [rAUDVOL], 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/hidden_objects.asm b/home/hidden_objects.asm index f60c78e093..7f67e39f2d 100644 --- a/home/hidden_objects.asm +++ b/home/hidden_objects.asm @@ -5,7 +5,7 @@ CheckForHiddenObjectOrBookshelfOrCardKeyDoor:: ldh a, [hLoadedROMBank] push af ldh a, [hJoyHeld] - bit BIT_A_BUTTON, a + bit B_PAD_A, a jr z, .nothingFound ; A button is pressed ld a, BANK(CheckForHiddenObject) diff --git a/home/init.asm b/home/init.asm index e3dbd991a0..5a241ee293 100644 --- a/home/init.asm +++ b/home/init.asm @@ -7,17 +7,6 @@ SoftReset:: Init:: ; Program init. - -; * LCD enabled -; * Window tile map at $9C00 -; * Window display enabled -; * BG and window tile data at $8800 -; * BG tile map at $9800 -; * 8x8 OBJ size -; * OBJ display enabled -; * BG display enabled -DEF rLCDC_DEFAULT EQU (1 << rLCDC_ENABLE) | (1 << rLCDC_WINDOW_TILEMAP) | (1 << rLCDC_WINDOW_ENABLE) | (1 << rLCDC_SPRITES_ENABLE) | (1 << rLCDC_BG_PRIORITY) - di xor a @@ -35,7 +24,7 @@ DEF rLCDC_DEFAULT EQU (1 << rLCDC_ENABLE) | (1 << rLCDC_WINDOW_TILEMAP) | (1 << ldh [rOBP0], a ldh [rOBP1], a - ld a, 1 << rLCDC_ENABLE + ld a, LCDC_ON ldh [rLCDC], a call DisableLCD @@ -74,7 +63,7 @@ DEF rLCDC_DEFAULT EQU (1 << rLCDC_ENABLE) | (1 << rLCDC_WINDOW_TILEMAP) | (1 << ldh [hSCX], a ldh [hSCY], a ldh [rIF], a - ld a, 1 << VBLANK + 1 << TIMER + 1 << SERIAL + ld a, IE_VBLANK | IE_TIMER | IE_SERIAL ldh [rIE], a ld a, 144 ; move the window off-screen @@ -91,7 +80,7 @@ DEF rLCDC_DEFAULT EQU (1 << rLCDC_ENABLE) | (1 << rLCDC_WINDOW_TILEMAP) | (1 << ld h, HIGH(vBGMap1) call ClearBgMap - ld a, rLCDC_DEFAULT + ld a, LCDC_DEFAULT ldh [rLCDC], a ld a, 16 ldh [hSoftReset], a @@ -108,7 +97,7 @@ DEF rLCDC_DEFAULT EQU (1 << rLCDC_ENABLE) | (1 << rLCDC_WINDOW_TILEMAP) | (1 << ld a, BANK(SFX_Shooting_Star) ld [wAudioROMBank], a ld [wAudioSavedROMBank], a - ld a, $9c + ld a, HIGH(vBGMap1) ldh [hAutoBGTransferDest + 1], a xor a ldh [hAutoBGTransferDest], a @@ -124,7 +113,7 @@ ENDC call ClearVram call GBPalNormal call ClearSprites - ld a, rLCDC_DEFAULT + ld a, LCDC_DEFAULT ldh [rLCDC], a jp PrepareTitleScreen diff --git a/home/joypad2.asm b/home/joypad2.asm index 5e724fb9c8..c11165ca81 100644 --- a/home/joypad2.asm +++ b/home/joypad2.asm @@ -25,7 +25,7 @@ JoypadLowSensitivity:: ldh a, [hJoyPressed] ; newly pressed buttons and a ; have any buttons been newly pressed since last check? jr z, .noNewlyPressedButtons -.newlyPressedButtons +; newly pressed buttons ldh [hJoy5], a ; shinpokerednote: FIXED: helps prevent holding the A button from messing up list scrolling (without this fix holding A makes down/up select a menu item) ld a, 30 ; half a second delay ldh [hFrameCounter], a @@ -34,14 +34,14 @@ JoypadLowSensitivity:: ldh a, [hFrameCounter] and a ; is the delay over? jr z, .delayOver -.delayNotOver +; delay not over 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 + and PAD_A | PAD_B jr z, .setShortDelay ldh a, [hJoy6] ; flag and a @@ -73,7 +73,7 @@ WaitForTextScrollButtonPress:: call JoypadLowSensitivity predef CableClub_Run ldh a, [hJoy5] - and A_BUTTON | B_BUTTON + and PAD_A | PAD_B jr z, .loop pop af ldh [hDownArrowBlinkCount2], a diff --git a/home/lcd.asm b/home/lcd.asm index aef6d43fd8..1e9e8888ba 100644 --- a/home/lcd.asm +++ b/home/lcd.asm @@ -3,16 +3,16 @@ DisableLCD:: ldh [rIF], a ldh a, [rIE] ld b, a - res rIE_VBLANK, a + res B_IE_VBLANK, a ldh [rIE], a .wait ldh a, [rLY] - cp LY_VBLANK + cp LY_VBLANK + 1 jr nz, .wait ldh a, [rLCDC] - and ~(1 << rLCDC_ENABLE) + and ~LCDC_ON ldh [rLCDC], a ld a, b ldh [rIE], a @@ -20,6 +20,6 @@ DisableLCD:: EnableLCD:: ldh a, [rLCDC] - set rLCDC_ENABLE, a + set B_LCDC_ENABLE, a ldh [rLCDC], a ret diff --git a/home/list_menu.asm b/home/list_menu.asm index 49313c7eee..ca48749df9 100644 --- a/home/list_menu.asm +++ b/home/list_menu.asm @@ -52,7 +52,7 @@ DisplayListMenuID:: ld [wTopMenuItemY], a ld a, 5 ld [wTopMenuItemX], a - ld a, A_BUTTON | B_BUTTON | SELECT | START | D_LEFT ; PureRGBnote: ADDED: tracking START and Dpad Left for new functions + ld a, PAD_A | PAD_B | PAD_SELECT | PAD_START | PAD_LEFT ; PureRGBnote: ADDED: tracking START and Dpad Left for new functions ld [wMenuWatchedKeys], a ;;;;;;;;;; PureRGBnote: ADDED: code that checks if we need to adjust the offset after changing the size of the list (depositing items/pokemon) ld a, [wBattleType] @@ -84,7 +84,7 @@ DisplayListMenuIDLoop:: pop af call CheckButtonStartPressed ; PureRGBnote: ADDED: start button can trigger depositing items when in the item menu jr nc, DisplayListMenuIDLoop - bit BIT_A_BUTTON, a + bit B_PAD_A, a jp z, .checkOtherKeys .buttonAPressed ld a, [wCurrentMenuItem] @@ -164,17 +164,17 @@ DisplayListMenuIDLoop:: res BIT_NO_TEXT_DELAY, [hl] ; turn on letter printing delay jp BankswitchBack .checkOtherKeys ; check B, SELECT, Up, and Down keys - bit BIT_B_BUTTON, a + bit B_PAD_B, a jp nz, ExitListMenu ; if so, exit the menu - bit BIT_SELECT, a + bit B_PAD_SELECT, a jp nz, HandleItemListSwapping ; if so, allow the player to swap menu entries ld b, a - bit BIT_D_LEFT, b + bit B_PAD_LEFT, b jr nz, .handleListSkip ; PureRGBnote: ADDED: when pressing left we will check to skip to the top or bottom of the list - bit BIT_D_DOWN, b + bit B_PAD_DOWN, b ld hl, wListScrollOffset jr z, .upPressed -.downPressed +; Down pressed ld a, [hl] add 3 ld b, a @@ -223,18 +223,18 @@ DisplayChooseQuantityMenu:: .waitForKeyPressLoop call JoypadLowSensitivity ldh a, [hJoyPressed] ; newly pressed buttons - bit BIT_A_BUTTON, a + bit B_PAD_A, a jp nz, .buttonAPressed - bit BIT_B_BUTTON, a + bit B_PAD_B, a jp nz, .buttonBPressed - bit BIT_D_UP, a + bit B_PAD_UP, a jr nz, .incrementQuantity - bit BIT_D_DOWN, a + bit B_PAD_DOWN, a jr nz, .decrementQuantity ;;;;;;;;;; PureRGBnote: ADDED: functionality to decrement or increment amounts by 10 when pressing right or left - bit BIT_D_RIGHT, a + bit B_PAD_RIGHT, a jr nz, .incrementQuantity10 - bit BIT_D_LEFT, a + bit B_PAD_LEFT, a jr nz, .decrementQuantity10 ;;;;;;;;;; jr .waitForKeyPressLoop @@ -416,7 +416,7 @@ PrintListMenuEntries:: cp CUSTOMLISTMENU jr z, .customListMenu ;;;; code for printing item names -.itemMenu +; item menu call GetItemName jr .placeNameString ;;;; @@ -454,7 +454,7 @@ PrintListMenuEntries:: and a ; should prices be printed? jr z, .skipPrintingItemPrice ;;;; code for printing prices (specific to buy/sell menus) -.printItemPrice +; print item price push hl ld a, [de] ld de, ItemPrices @@ -471,7 +471,7 @@ PrintListMenuEntries:: and a ; PCPOKEMONLISTMENU? jr nz, .skipPrintingPokemonLevel ;;;; code for printing levels (specific to box menus) -.printPokemonLevel +; print Pokemon level ld a, [wNamedObjectIndex] push af push hl @@ -494,12 +494,12 @@ PrintListMenuEntries:: ld a, [wMonDataLocation] and a ; is it a list of party pokemon or box pokemon? jr z, .skipCopyingLevel -.copyLevel +; copy level ld a, [wLoadedMonBoxLevel] ld [wLoadedMonLevel], a .skipCopyingLevel pop hl - ld bc, $1c + ld bc, SCREEN_WIDTH + 8 ; 1 row down and 8 columns right add hl, bc call PrintLevel pop af @@ -513,7 +513,7 @@ PrintListMenuEntries:: cp ITEMLISTMENU jr nz, .nextListEntry ;;;; code for printing item quantities (specific to item menus) -.printItemQuantity +; print item quantity ld a, [wNamedObjectIndex] ld [wCurItem], a call IsKeyItem ; check if item is unsellable @@ -523,7 +523,7 @@ PrintListMenuEntries:: push hl ld bc, SCREEN_WIDTH + 8 ; 1 row down and 8 columns right add hl, bc - ld a, "×" + ld a, '×' ld [hli], a ld a, [wNamedObjectIndex] push af @@ -552,7 +552,7 @@ PrintListMenuEntries:: cp c ; is it this item? jr nz, .nextListEntry dec hl - ld a, "▷" + ld a, '▷' ld [hli], a .nextListEntry ld bc, 2 * SCREEN_WIDTH ; 2 rows @@ -563,7 +563,7 @@ PrintListMenuEntries:: jp nz, .loop ld bc, -8 add hl, bc - ld [hl], "▼" + ld [hl], '▼' ret .printCancelMenuItem ld de, ListMenuCancelText diff --git a/home/load_font.asm b/home/load_font.asm index 119bbeff89..199be27caa 100644 --- a/home/load_font.asm +++ b/home/load_font.asm @@ -1,8 +1,8 @@ LoadFontTilePatterns:: ldh a, [rLCDC] - bit rLCDC_ENABLE, a + bit B_LCDC_ENABLE, a jr nz, .on -.off +; off ld hl, FontGraphics ld de, vFont ld bc, FontGraphicsEnd - FontGraphics @@ -11,14 +11,14 @@ LoadFontTilePatterns:: .on ld de, FontGraphics ld hl, vFont - lb bc, BANK(FontGraphics), (FontGraphicsEnd - FontGraphics) / $8 + lb bc, BANK(FontGraphics), (FontGraphicsEnd - FontGraphics) / TILE_1BPP_SIZE jp CopyVideoDataDouble ; if LCD is on, transfer during V-blank LoadTextBoxTilePatterns:: ldh a, [rLCDC] - bit rLCDC_ENABLE, a + bit B_LCDC_ENABLE, a jr nz, .on -.off +; off ld hl, TextBoxGraphics ld de, vChars2 tile $60 ld bc, TextBoxGraphicsEnd - TextBoxGraphics @@ -27,14 +27,14 @@ LoadTextBoxTilePatterns:: .on ld de, TextBoxGraphics ld hl, vChars2 tile $60 - lb bc, BANK(TextBoxGraphics), (TextBoxGraphicsEnd - TextBoxGraphics) / $10 + lb bc, BANK(TextBoxGraphics), (TextBoxGraphicsEnd - TextBoxGraphics) / TILE_SIZE jp CopyVideoData ; if LCD is on, transfer during V-blank LoadHpBarAndStatusTilePatterns:: ldh a, [rLCDC] - bit rLCDC_ENABLE, a + bit B_LCDC_ENABLE, a jr nz, .on -.off +; off ld hl, HpBarAndStatusGraphics ld de, vChars2 tile $62 ld bc, HpBarAndStatusGraphicsEnd - HpBarAndStatusGraphics @@ -49,12 +49,12 @@ LoadHpBarAndStatusTilePatterns:: jp FarCopyData2 .on ld de, HpBarAndStatusGraphics - ld hl, vChars2 + $620 - lb bc, BANK(HpBarAndStatusGraphics), (HpBarAndStatusGraphicsEnd - HpBarAndStatusGraphics) / $10 + ld hl, vChars2 tile $62 + lb bc, BANK(HpBarAndStatusGraphics), (HpBarAndStatusGraphicsEnd - HpBarAndStatusGraphics) / TILE_SIZE ;shinpokerednote: ADDED: load exp bar ;jp CopyVideoData ; if LCD is on, transfer during V-blank call CopyVideoData ld de,EXPBarGraphics - ld hl, vChars1 + $400 - lb bc, BANK(EXPBarGraphics), (EXPBarGraphicsEnd - EXPBarGraphics) / $10 + ld hl, vChars1 tile $40 + lb bc, BANK(EXPBarGraphics), (EXPBarGraphicsEnd - EXPBarGraphics) / TILE_SIZE jp CopyVideoData diff --git a/home/map_objects.asm b/home/map_objects.asm index 84ece11bf6..c25a8c1711 100644 --- a/home/map_objects.asm +++ b/home/map_objects.asm @@ -2,27 +2,25 @@ TextScript_ItemStoragePC:: call SaveScreenTilesToBuffer2 ld b, BANK(PlayerPC) ld hl, PlayerPC - jr bankswitchAndContinue + jr BankswitchAndContinue TextScript_BillsPC:: call SaveScreenTilesToBuffer2 ld b, BANK(BillsPC_) ld hl, BillsPC_ - jr bankswitchAndContinue + jr BankswitchAndContinue TextScript_GameCornerPrizeMenu:: -; XXX find a better name for this function -; special_F7 ld b, BANK(CeladonPrizeMenu) ld hl, CeladonPrizeMenu -bankswitchAndContinue:: +BankswitchAndContinue:: rst _Bankswitch jp HoldTextDisplayOpen ; continue to main text-engine function TextScript_PokemonCenterPC:: ld b, BANK(ActivatePC) ld hl, ActivatePC - jr bankswitchAndContinue + jr BankswitchAndContinue StartSimulatingJoypadStates:: xor a @@ -90,7 +88,7 @@ CheckCoords:: ld hl, wCoordIndex inc [hl] pop hl -.compareYCoord +; compare Y coord cp b jr z, .compareXCoord inc hl @@ -99,7 +97,7 @@ CheckCoords:: ld a, [hli] cp c jr nz, .loop -.inArray +; in array scf ret .notInArray diff --git a/home/move_mon.asm b/home/move_mon.asm index e93c8b1b1f..8e329f33bc 100644 --- a/home/move_mon.asm +++ b/home/move_mon.asm @@ -94,7 +94,7 @@ CalcStat:: srl c pop hl push bc - ld bc, wPartyMon1DVs - (wPartyMon1HPExp - 1) ; also wEnemyMonDVs - wEnemyMonHP + ld bc, MON_DVS - (MON_HP_EXP - 1) add hl, bc pop bc ld a, c @@ -106,7 +106,7 @@ CalcStat:: jr z, .getSpeedIV cp $5 jr z, .getSpecialIV -.getHpIV +; get HP IV push bc ld a, [hl] ; Atk IV swap a diff --git a/home/names.asm b/home/names.asm index 6423dd9be7..a4386bc207 100644 --- a/home/names.asm +++ b/home/names.asm @@ -14,7 +14,7 @@ GetMonName:: ld bc, NAME_LENGTH - 1 rst _CopyData ld hl, wNameBuffer + NAME_LENGTH - 1 - ld [hl], "@" + ld [hl], '@' pop de pop af call SetCurBank @@ -71,7 +71,7 @@ GetMachineName:: ; now get the machine number and convert it to text ld a, [wNamedObjectIndex] sub TM01 - 1 - ld b, "0" + ld b, '0' .FirstDigit sub 10 jr c, .SecondDigit @@ -84,11 +84,11 @@ GetMachineName:: ld [de], a inc de pop af - ld b, "0" + ld b, '0' add b ld [de], a inc de - ld a, "@" + ld a, '@' ld [de], a pop af ld [wNamedObjectIndex], a diff --git a/home/names2.asm b/home/names2.asm index 1c847e06eb..e62393cea4 100644 --- a/home/names2.asm +++ b/home/names2.asm @@ -74,7 +74,7 @@ GetName:: ld e, l .nextChar ld a, [hli] - cp "@" + cp '@' jr nz, .nextChar inc c ld a, b diff --git a/home/npc_movement.asm b/home/npc_movement.asm index 9f4966d071..bd3ceaf3ee 100644 --- a/home/npc_movement.asm +++ b/home/npc_movement.asm @@ -55,9 +55,9 @@ IF DEF(_DEBUG) bit BIT_DEBUG_MODE, a ret z ldh a, [hJoyHeld] - bit BIT_B_BUTTON, a + bit B_PAD_B, a ret nz ldh a, [hJoyPressed] - bit BIT_B_BUTTON, a + bit B_PAD_B, a ENDC ret diff --git a/home/overworld.asm b/home/overworld.asm index f9f3f18c65..b348789712 100644 --- a/home/overworld.asm +++ b/home/overworld.asm @@ -1,6 +1,6 @@ EnterMap:: ; Load a new map. - ld a, A_BUTTON | B_BUTTON | SELECT | START | D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_BUTTONS | PAD_CTRL_PAD ld [wJoyIgnore], a call LoadMapData farcall ClearVariablesOnEnterMap @@ -84,16 +84,16 @@ OverworldLoopLessDelay:: ;.notSimulating ; ldh a, [hJoyPressed] .checkIfStartIsPressed - bit BIT_START, a + bit B_PAD_START, a jr z, .startButtonNotPressed ; if START is pressed xor a ; TEXT_START_MENU ldh [hTextID], a jp .displayDialogue .startButtonNotPressed - bit BIT_A_BUTTON, a + bit B_PAD_A, a jr nz, .aorSelectPressed ; PureRGBnote: ADDED: functionality that happens when pressing SELECT in overworld (bicycle) - bit BIT_SELECT, a + bit B_PAD_SELECT, a jp z, .checkIfDownButtonIsPressed .aorSelectPressed ; if A is pressed @@ -105,7 +105,7 @@ OverworldLoopLessDelay:: ;;;;;;;;;; PureRGBnote: ADDED: functionality that happens when pressing SELECT in overworld (bicycle) .trySelectingBikeRod ldh a, [hJoyPressed] - bit BIT_SELECT, a ;is Select being pressed? + bit B_PAD_SELECT, a ;is Select being pressed? jr z, .notSelect callfar CheckForRodBike jp OverworldLoop @@ -137,12 +137,12 @@ OverworldLoopLessDelay:: ld [wEnteringCableClub], a ; XXX can this code be reached? ; jr z, .changeMap -; predef LoadSAV +; predef TryLoadSaveFile ; ld a, [wCurMap] ; ld [wDestinationMap], a ; call PrepareForSpecialWarp ; ld a, [wCurMap] -; call SwitchToMapRomBank ; switch to the ROM bank of the current map +; call SwitchToMapRomBank ; ld hl, wCurMapTileset ; set BIT_NO_PREVIOUS_MAP, [hl] .changeMap @@ -158,8 +158,8 @@ OverworldLoopLessDelay:: call UpdateSprites ;;;;;;;;;;; PureRGBnote: ADDED: code for changing direction without moving by pressing A+B and a direction when standing still. ldh a, [hJoyHeld] - and B_BUTTON | A_BUTTON - cp B_BUTTON | A_BUTTON + and PAD_B | PAD_A + cp PAD_B | PAD_A jr nz, .resetDirectionChangeState ; hold both B and A button to go into "change direction without moving" mode. ld a, [wDirectionChangeModeCounter] and %01111111 ; prevents wrapping to 0 by incrementing past 255 @@ -182,7 +182,7 @@ OverworldLoopLessDelay:: .checkIfDownButtonIsPressed ldh a, [hJoyHeld] ; current joypad state - bit BIT_D_DOWN, a + bit B_PAD_DOWN, a jr z, .checkIfUpButtonIsPressed ld a, 1 ld [wSpritePlayerStateData1YStepVector], a @@ -190,7 +190,7 @@ OverworldLoopLessDelay:: jr .handleDirectionButtonPress .checkIfUpButtonIsPressed - bit BIT_D_UP, a + bit B_PAD_UP, a jr z, .checkIfLeftButtonIsPressed ld a, -1 ld [wSpritePlayerStateData1YStepVector], a @@ -198,7 +198,7 @@ OverworldLoopLessDelay:: jr .handleDirectionButtonPress .checkIfLeftButtonIsPressed - bit BIT_D_LEFT, a + bit B_PAD_LEFT, a jr z, .checkIfRightButtonIsPressed ld a, -1 ld [wSpritePlayerStateData1XStepVector], a @@ -206,7 +206,7 @@ OverworldLoopLessDelay:: jr .handleDirectionButtonPress .checkIfRightButtonIsPressed - bit BIT_D_RIGHT, a + bit B_PAD_RIGHT, a jr z, .noDirectionButtonsPressed ld a, 1 ld [wSpritePlayerStateData1XStepVector], a @@ -337,7 +337,7 @@ OverworldLoopLessDelay:: .normalPlayerSpriteAdvancement ; PureRGBnote: ADDED: Holding B makes you run at 2x walking speed ldh a, [hJoyHeld] - and B_BUTTON + and PAD_B call nz, DoBikeSpeedup .notRunning call AdvancePlayerSprite @@ -441,7 +441,7 @@ GetBikeSpeed:: cp ROUTE_17 ; Cycling Road jr z, .cyclingRoad ldh a, [hJoyHeld] - and B_BUTTON + and PAD_B jr z, DoBikeSpeedup ; B button held call DoBikeSpeedup @@ -450,14 +450,14 @@ GetBikeSpeed:: .cyclingRoad ; uphill we can only go a bit faster, downhill we can go full speed ldh a, [hJoyHeld] - and D_UP | D_LEFT | D_RIGHT + and PAD_UP | PAD_LEFT | PAD_RIGHT call z, DoBikeSpeedup ldh a, [hJoyHeld] - and B_BUTTON + and PAD_B ret z call DoBikeSpeedup ldh a, [hJoyHeld] - and D_UP | D_LEFT | D_RIGHT + and PAD_UP | PAD_LEFT | PAD_RIGHT ret nz ; fall through @@ -513,7 +513,7 @@ CheckWarpsNoCollisionLoop:: pop bc pop de ldh a, [hJoyHeld] - and D_DOWN | D_UP | D_LEFT | D_RIGHT + and PAD_CTRL_PAD jr z, CheckWarpsNoCollisionRetry2 ; if directional buttons aren't being pressed, do not pass through the warp jr WarpFound1 @@ -585,7 +585,7 @@ 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 - ldh a, [hWarpDestinationMap] ; destination map + ldh a, [hWarpDestinationMap] cp LAST_MAP jr z, .goBackOutside ; if not going back to the previous map @@ -1067,8 +1067,7 @@ IsSpriteOrSignInFrontOfPlayer:: ld a, [hli] ; sign X cp e jr nz, .retry -.xCoordMatched -; found sign +; X coord matched: found sign push hl push bc ld hl, wSignTextIDs @@ -1141,7 +1140,7 @@ IsSpriteInFrontOfPlayer2:: ld a, PLAYER_DIR_LEFT .doneCheckingDirection ld [wPlayerDirection], a - ld a, [wNumSprites] ; number of sprites + ld a, [wNumSprites] and a ret z ; if there are sprites @@ -1168,7 +1167,7 @@ IsSpriteInFrontOfPlayer2:: .nextSprite pop hl ld a, l - add $10 + add SPRITESTATEDATA1_LENGTH ld l, a inc e dec d @@ -1230,15 +1229,15 @@ CollisionCheckOnLand:: ; function that checks if the tile in front of the player is passable ; clears carry if it is, sets carry if not CheckTilePassable:: - predef GetTileAndCoordsInFrontOfPlayer ; get tile in front of player - ld a, [wTileInFrontOfPlayer] ; tile in front of player + predef GetTileAndCoordsInFrontOfPlayer + ld a, [wTileInFrontOfPlayer] ;;;;;;;;;; PureRGBnote: CHANGED: unified code for checking if a tile is passable ld d, a callfar _CheckTilePassable - jr c, .notPassable + jr c, .tileNotPassable and a ret -.notPassable +.tileNotPassable ;;;;;;;;;; scf ret @@ -1249,7 +1248,7 @@ CheckTilePassable:: ; sets carry if there is a collision and unsets carry if not CheckForJumpingAndTilePairCollisions:: push hl - predef GetTileAndCoordsInFrontOfPlayer ; get the tile in front of the player + predef GetTileAndCoordsInFrontOfPlayer push de push bc farcall HandleLedges ; check if the player is trying to jump a ledge @@ -1282,7 +1281,7 @@ CheckForTilePairCollisions:: inc hl jr .tilePairCollisionLoop .tilesetMatches - ld a, [wTilePlayerStandingOn] ; tile the player is on + ld a, [wTilePlayerStandingOn] ld b, a ld a, [hl] cp b @@ -1317,7 +1316,7 @@ INCLUDE "data/tilesets/pair_collision_tile_ids.asm" LoadCurrentMapView:: ldh a, [hLoadedROMBank] push af - ld a, [wTilesetBank] ; tile data ROM bank + ld a, [wTilesetBank] call SetCurBank ; switch to ROM bank that contains tile data ld a, [wCurrentTileBlockMapViewPointer] ; address of upper left corner of current map view ld e, a @@ -1406,7 +1405,7 @@ AdvancePlayerSprite:: ld b, a ld a, [wSpritePlayerStateData1XStepVector] ld c, a - ld hl, wWalkCounter ; walking animation counter + ld hl, wWalkCounter dec [hl] jr nz, .afterUpdateMapCoords ; if it's the end of the animation, update the player's map coordinates @@ -1417,7 +1416,7 @@ AdvancePlayerSprite:: add c ld [wXCoord], a .afterUpdateMapCoords - ld a, [wWalkCounter] ; walking animation counter + ld a, [wWalkCounter] ;;;;;;;;;; shinpokerednote: 60fps push bc ld b, $0F @@ -1578,7 +1577,7 @@ AdvancePlayerSprite:: ; 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 - ld a, [wNumSprites] ; number of sprites + ld a, [wNumSprites] and a ; are there any sprites? ret z ;jr z, .done ; PureRGBnote: OPTIMIZED ld e, a @@ -1788,9 +1787,9 @@ JoypadOverworld:: cp ROUTE_17 ; Cycling Road jr nz, .notForcedDownwards ldh a, [hJoyHeld] - and D_DOWN | D_UP | D_LEFT | D_RIGHT | B_BUTTON | A_BUTTON + and PAD_CTRL_PAD | PAD_B | PAD_A jr nz, .notForcedDownwards - ld a, D_DOWN + ld a, PAD_DOWN 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, [wStatusFlags5] @@ -2031,7 +2030,7 @@ LoadMapHeader:: ; copy connection data (if any) to WRAM ld a, [wCurMapConnections] ld b, a -.checkNorth +; check north bit NORTH_F, b jr z, .checkSouth ld de, wNorthConnectionHeader @@ -2061,7 +2060,7 @@ LoadMapHeader:: ld de, wMapBackgroundTile ld a, [hli] ld [de], a -.loadWarpData +; load warp data ld a, [hli] ld [wNumberOfWarps], a and a @@ -2132,8 +2131,8 @@ LoadMapHeader:: jr nz, .zeroSpriteDataLoop ; disable SPRITESTATEDATA1_IMAGEINDEX (set to $ff) for sprites 01-15 ld hl, wSprite01StateData1ImageIndex - ld de, $10 - ld c, $0f + ld de, SPRITESTATEDATA1_LENGTH + ld c, NUM_SPRITESTATEDATA_STRUCTS - 1 .disableSpriteEntriesLoop ld [hl], $ff add hl, de @@ -2291,7 +2290,7 @@ CopyMapConnectionHeader:: LoadMapData:: ldh a, [hLoadedROMBank] push af - ld a, $98 + ld a, HIGH(vBGMap0) ld [wMapViewVRAMPointer + 1], a xor a ld [wMapViewVRAMPointer], a @@ -2322,7 +2321,7 @@ LoadMapData:: call SpecialCopyData pop bc - ld a, BG_MAP_WIDTH - SCREEN_WIDTH + ld a, TILEMAP_WIDTH - SCREEN_WIDTH add e ld e, a jr nc, .noCarry @@ -2402,14 +2401,14 @@ CheckForUserInterruption:: pop bc ldh a, [hJoyHeld] - cp D_UP + SELECT + B_BUTTON + cp PAD_UP + PAD_SELECT + PAD_B jr z, .input ldh a, [hJoy5] IF DEF(_DEBUG) - and START | SELECT | A_BUTTON + and PAD_START | PAD_SELECT | PAD_A ELSE - and START | A_BUTTON + and PAD_START | PAD_A ENDC jr nz, .input diff --git a/home/pics.asm b/home/pics.asm index 136dfccbb8..a1522ca205 100644 --- a/home/pics.asm +++ b/home/pics.asm @@ -65,7 +65,7 @@ LoadUncompressedSpriteData:: add a ; 8*(7*((8-w)/2) + 7-h) ; combined overall offset (in bytes) ldh [hSpriteOffset], a xor a - ld [MBC1SRamBank], a + ld [rRAMB], a ld hl, sSpriteBuffer0 call ZeroSpriteBuffer ; zero buffer 0 ld de, sSpriteBuffer1 @@ -99,8 +99,8 @@ AlignSpriteDataCentered:: dec c jr nz, .columnInnerLoop pop hl - ld bc, 7*8 ; 7 tiles - add hl, bc ; advance one full column + ld bc, 7 * TILE_1BPP_SIZE + add hl, bc ; advance one full column pop af dec a jr nz, .columnLoop @@ -123,12 +123,12 @@ ZeroSpriteBuffer:: ; de: output address InterlaceMergeSpriteBuffers:: xor a - ld [MBC1SRamBank], a + ld [rRAMB], a push de ld hl, sSpriteBuffer2 + (SPRITEBUFFERSIZE - 1) ; destination: end of buffer 2 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 a, SPRITEBUFFERSIZE / 2 ldh [hSpriteInterlaceCounter], a .interlaceLoop ld a, [de] @@ -150,7 +150,7 @@ InterlaceMergeSpriteBuffers:: ld a, [wSpriteFlipped] and a jr z, .notFlipped - ld bc, 2*SPRITEBUFFERSIZE + ld bc, 2 * SPRITEBUFFERSIZE ld hl, sSpriteBuffer1 .swapLoop swap [hl] ; if flipped swap nybbles in all bytes @@ -160,9 +160,9 @@ InterlaceMergeSpriteBuffers:: or c jr nz, .swapLoop .notFlipped - pop hl + pop hl ; hl = output address ld de, sSpriteBuffer1 - ld c, (2*SPRITEBUFFERSIZE)/16 ; $31, number of 16 byte chunks to be copied + ld c, PIC_SIZE ; tiles ldh a, [hLoadedROMBank] ld b, a jp CopyVideoData diff --git a/home/pokemon.asm b/home/pokemon.asm index 28d74e3aab..97ba60a111 100644 --- a/home/pokemon.asm +++ b/home/pokemon.asm @@ -209,11 +209,11 @@ PartyMenuInit:: ld [hli], a ; max menu item ID ld a, [wForcePlayerToChooseMon] and a - ld a, A_BUTTON | B_BUTTON + ld a, PAD_A | PAD_B jr z, .next xor a ld [wForcePlayerToChooseMon], a - inc a ; a = A_BUTTON + inc a ; a = PAD_A .next ld [hli], a ; menu watched keys pop af @@ -239,7 +239,7 @@ HandlePartyMenuInput:: jp nz, .swappingPokemon pop af ldh [hTileAnimations], a - bit BIT_B_BUTTON, b + bit B_PAD_B, b jr nz, .noPokemonChosen ld a, [wPartyCount] and a @@ -261,7 +261,7 @@ HandlePartyMenuInput:: scf ret .swappingPokemon - bit BIT_B_BUTTON, b + bit B_PAD_B, b jr z, .handleSwap ; if not, handle swapping the pokemon .cancelSwap ; if the B button was pressed farcall ErasePartyMenuCursors @@ -305,11 +305,7 @@ PrintStatusCondition:: pop de jr nz, PrintStatusConditionNotFainted ; if the pokemon's HP is 0, print "FNT" - ld a, "F" - ld [hli], a - ld a, "N" - ld [hli], a - ld [hl], "T" + ld_hli_a_string "FNT" and a ret @@ -322,7 +318,7 @@ PrintStatusConditionNotFainted:: ; hl = destination address ; [wLoadedMonLevel] = level PrintLevel:: - ld a, "" ; ":L" tile ID + ld a, '' ; ":L" tile ID ld [hli], a ld c, 2 ; number of digits ld a, [wLoadedMonLevel] ; level @@ -338,7 +334,7 @@ PrintLevel:: ; hl = destination address ; [wLoadedMonLevel] = level PrintLevelFull:: - ld a, "" ; ":L" tile ID + ld a, '' ; ":L" tile ID ld [hli], a ld c, 3 ; number of digits ld a, [wLoadedMonLevel] ; level diff --git a/home/print_bcd.asm b/home/print_bcd.asm index d5c4c650d6..a81c789f86 100644 --- a/home/print_bcd.asm +++ b/home/print_bcd.asm @@ -21,9 +21,9 @@ PrintBCDNumber:: bit BIT_LEADING_ZEROES, b jr nz, .loop ; PureRGBnote; OPTIMIZED - ld a, "¥" + ld a, '¥' ld [hli], a - ;ld [hl], "¥" + ;ld [hl], '¥' ;inc hl .loop ld a, [de] @@ -38,19 +38,19 @@ PrintBCDNumber:: ; PureRGBnote: OPTIMIZED ret z ;jr z, .done ; if so, we are done -.numberEqualsZero ; if every digit of the BCD number is zero +; if every digit of the BCD number is zero, print the last 0 bit BIT_LEFT_ALIGN, b jr nz, .skipRightAlignmentAdjustment dec hl ; if the string is right-aligned, it needs to be moved back one space .skipRightAlignmentAdjustment bit BIT_MONEY_SIGN, b jr z, .skipCurrencySymbol - ld a, "¥" + ld a, '¥' ld [hli], a - ;ld [hl], "¥" + ;ld [hl], '¥' ;inc hl .skipCurrencySymbol - ld [hl], "0" + ld [hl], '0' call PrintLetterDelay inc hl ;.done @@ -66,13 +66,13 @@ PrintBCDDigit:: ; if bit 7 is set, then no numbers have been printed yet bit BIT_MONEY_SIGN, b jr z, .skipCurrencySymbol - ld [hl], "¥" + ld [hl], '¥' inc hl res BIT_MONEY_SIGN, b .skipCurrencySymbol res BIT_LEADING_ZEROES, b .outputDigit - add "0" + add '0' ld [hli], a jp PrintLetterDelay .zeroDigit diff --git a/home/print_num.asm b/home/print_num.asm index dcebf0a42f..c8c941bc9a 100644 --- a/home/print_num.asm +++ b/home/print_num.asm @@ -67,11 +67,16 @@ MACRO print_digit call .NextDigit ENDM -.millions print_digit 1000000 -.hundred_thousands print_digit 100000 -.ten_thousands print_digit 10000 -.thousands print_digit 1000 -.hundreds print_digit 100 +; millions + print_digit 1000000 +.hundred_thousands + print_digit 100000 +.ten_thousands + print_digit 10000 +.thousands + print_digit 1000 +.hundreds + print_digit 100 .tens ld c, 0 @@ -92,14 +97,14 @@ ENDM call .PrintLeadingZero jr .next .past - ld a, "0" + ld a, '0' add c ld [hl], a .next call .NextDigit -.ones - ld a, "0" +; ones + ld a, '0' add b ld [hli], a pop de @@ -176,7 +181,7 @@ ENDM or c jr z, .PrintLeadingZero - ld a, "0" + ld a, '0' add c ld [hl], a ldh [hPastLeadingZeros], a @@ -185,7 +190,7 @@ ENDM .PrintLeadingZero: bit BIT_LEADING_ZEROES, d ret z - ld [hl], "0" + ld [hl], '0' ret .NextDigit: diff --git a/home/print_text.asm b/home/print_text.asm index 04839d0011..0a5bb6fd19 100644 --- a/home/print_text.asm +++ b/home/print_text.asm @@ -25,10 +25,10 @@ PrintLetterDelay:: call Joypad ldh a, [hJoyHeld] .checkAButton - bit BIT_A_BUTTON, a + bit B_PAD_A, a jr nz, .endWait .checkBButton - bit BIT_B_BUTTON, a + bit B_PAD_B, a jr z, .buttonsNotPressed .endWait rst _DelayFrame diff --git a/home/reset_player_sprite.asm b/home/reset_player_sprite.asm index a23a9a5008..b8fc615173 100644 --- a/home/reset_player_sprite.asm +++ b/home/reset_player_sprite.asm @@ -18,6 +18,7 @@ ResetPlayerSpriteData:: ; overwrites sprite data with zeroes ResetPlayerSpriteData_ClearSpriteData:: - ld bc, $10 + ld bc, SPRITESTATEDATA1_LENGTH + ASSERT SPRITESTATEDATA2_LENGTH == SPRITESTATEDATA1_LENGTH xor a jp FillMemory diff --git a/home/serial.asm b/home/serial.asm index 0aa55533f1..20c109a629 100644 --- a/home/serial.asm +++ b/home/serial.asm @@ -14,7 +14,7 @@ Serial:: cp USING_INTERNAL_CLOCK jr z, .done ; using external clock - ld a, START_TRANSFER_EXTERNAL_CLOCK + ld a, SC_START | SC_EXTERNAL ldh [rSC], a jr .done .connectionNotYetEstablished @@ -32,7 +32,7 @@ Serial:: ldh a, [rDIV] bit 7, a ; wait until rDIV has incremented from $3 to $80 or more jr nz, .waitLoop - ld a, START_TRANSFER_EXTERNAL_CLOCK + ld a, SC_START | SC_EXTERNAL ldh [rSC], a jr .done .usingInternalClock @@ -92,7 +92,7 @@ Serial_ExchangeByte:: ldh a, [hSerialConnectionStatus] cp USING_INTERNAL_CLOCK jr nz, .loop - ld a, START_TRANSFER_INTERNAL_CLOCK + ld a, SC_START | SC_INTERNAL ldh [rSC], a .loop ldh a, [hSerialReceivedNewData] @@ -117,8 +117,8 @@ Serial_ExchangeByte:: jp SetUnknownCounterToFFFF .doNotIncrementUnknownCounter ldh a, [rIE] - and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK) - cp 1 << SERIAL + and IE_SERIAL | IE_TIMER | IE_STAT | IE_VBLANK + cp IE_SERIAL jr nz, .loop ld a, [wUnknownSerialCounter2] dec a @@ -139,8 +139,8 @@ Serial_ExchangeByte:: xor a ldh [hSerialReceivedNewData], a ldh a, [rIE] - and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK) - sub 1 << SERIAL + and IE_SERIAL | IE_TIMER | IE_STAT | IE_VBLANK + sub IE_SERIAL jr nz, .skipReloadingUnknownCounter2 ld [wUnknownSerialCounter2], a ld a, $50 @@ -165,8 +165,8 @@ Serial_ExchangeByte:: jr z, SetUnknownCounterToFFFF .done ldh a, [rIE] - and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK) - cp 1 << SERIAL + and IE_SERIAL | IE_TIMER | IE_STAT | IE_VBLANK + cp IE_SERIAL ld a, SERIAL_NO_DATA_BYTE ret z ld a, [hl] @@ -291,7 +291,7 @@ Serial_ExchangeNybble:: ldh a, [hSerialConnectionStatus] cp USING_INTERNAL_CLOCK jr nz, .doExchange - ld a, START_TRANSFER_INTERNAL_CLOCK + ld a, SC_START | SC_INTERNAL ldh [rSC], a .doExchange ldh a, [hSerialReceiveData] @@ -312,7 +312,7 @@ Serial_SendZeroByte:: ldh a, [hSerialConnectionStatus] cp USING_INTERNAL_CLOCK ret nz - ld a, START_TRANSFER_INTERNAL_CLOCK + ld a, SC_START | SC_INTERNAL ldh [rSC], a ret @@ -321,6 +321,6 @@ Serial_TryEstablishingExternallyClockedConnection:: ldh [rSB], a xor a ldh [hSerialReceiveData], a - ld a, START_TRANSFER_EXTERNAL_CLOCK + ld a, SC_START | SC_EXTERNAL ldh [rSC], a ret diff --git a/home/start.asm b/home/start.asm index 8c5ded478f..3f0428dca3 100644 --- a/home/start.asm +++ b/home/start.asm @@ -1,5 +1,5 @@ _Start:: - cp CGB + cp BOOTUP_A_CGB jr z, .gbc xor a jr .ok diff --git a/home/start_menu.asm b/home/start_menu.asm index f29100358b..446fafd0fb 100644 --- a/home/start_menu.asm +++ b/home/start_menu.asm @@ -15,9 +15,9 @@ RedisplayStartMenu:: call HandleMenuInput ld b, a .checkIfUpPressed - bit BIT_SELECT, a + bit B_PAD_SELECT, a jp nz, .selectPressed ; PureRGBnote: ADDED: if pressing SELECT while the cursor is over the SAVE option - we can change PC boxes. - bit BIT_D_UP, a + bit B_PAD_UP, a jr z, .checkIfDownPressed ld a, [wCurrentMenuItem] ; menu selection and a @@ -35,7 +35,7 @@ RedisplayStartMenu:: call EraseMenuCursor jr .loop .checkIfDownPressed - bit BIT_D_DOWN, a + bit B_PAD_DOWN, a jr z, .buttonPressed ; if the player pressed tried to go past the bottom item, wrap around to the top CheckEvent EVENT_GOT_POKEDEX @@ -56,7 +56,7 @@ RedisplayStartMenu:: ld a, [wCurrentMenuItem] ld [wBattleAndStartSavedMenuItem], a ; save current menu selection ld a, b - and B_BUTTON | START ; was the Start button or B button pressed? + and PAD_B | PAD_START ; was the Start button or B button pressed? jp nz, CloseStartMenu call SaveScreenTilesToBuffer2 ; copy background from wTileMap to wTileMapBackup2 CheckEvent EVENT_GOT_POKEDEX @@ -90,7 +90,7 @@ RedisplayStartMenu:: CloseStartMenu:: call Joypad ldh a, [hJoyPressed] - bit BIT_A_BUTTON, a + bit B_PAD_A, a jr nz, CloseStartMenu call LoadTextBoxTilePatterns jp CloseTextDisplay diff --git a/home/text.asm b/home/text.asm index f466328ef7..41c9c6516b 100644 --- a/home/text.asm +++ b/home/text.asm @@ -3,11 +3,11 @@ TextBoxBorder:: ; top row push hl - ld a, "┌" + ld a, '┌' ld [hli], a - inc a ; "─" + inc a ; '─' call .PlaceChars - inc a ; "┐" + inc a ; '┐' ld [hl], a pop hl @@ -17,11 +17,11 @@ TextBoxBorder:: ; middle rows .next push hl - ld a, "│" + ld a, '│' ld [hli], a - ld a, " " + ld a, ' ' call .PlaceChars - ld [hl], "│" + ld [hl], '│' pop hl ld de, SCREEN_WIDTH @@ -30,11 +30,11 @@ TextBoxBorder:: jr nz, .next ; bottom row - ld a, "└" + ld a, '└' ld [hli], a - ld a, "─" + ld a, '─' call .PlaceChars - ld [hl], "┘" + ld [hl], '┘' ret .PlaceChars:: @@ -51,7 +51,7 @@ PlaceString:: PlaceNextChar:: ld a, [de] - cp "@" + cp '@' jr nz, .NotTerminator ld b, h ld c, l @@ -86,7 +86,7 @@ NullChar:: ld b, h ld c, l pop hl - ; A "" character in a printed string + ; A '' character in a printed string ; displays an error message with the current value ; of hTextID in decimal format. ; This is a debugging leftover. @@ -97,36 +97,36 @@ NullChar:: ; PureRGBnote: CHANGED: many shortcut commands were added here ; because it greatly reduces text data size if certain commonly used phrases are parameterized. TextShortcutCommandJumpTable: - dbw "", NextCharCmd - dbw "", LineChar - dbw "", NullChar - dbw "", MultiButtonPageChar - dbw "", _ContTextNoPause - dbw "<_CONT>", _ContText - dbw "", Paragraph - dbw "", PageChar - dbw "", PrintPlayerName - dbw "", PrintRivalName - dbw "#", PlacePOKe - dbw "", PCChar - dbw "", TeamChar - dbw "", RocketChar - dbw "", TMChar - dbw "", TrainerChar - dbw "", ContText - dbw "<...>", ThreeDotsChar - dbw "", DoneText - dbw "", PromptText - dbw "", PlacePKMN - dbw "", PlaceDexEnd - dbw "", PlaceMoveTargetsName - dbw "", PlaceMoveUsersName - dbw "", TrainerTipsChar - dbw "#MON", PokemonChar - dbw "",OpponentChar - dbw "", UserChar - dbw "the", TheChar - dbw "you", YouChar + dbw '', NextCharCmd + dbw '', LineChar + dbw '', NullChar + dbw '', MultiButtonPageChar + dbw '', _ContTextNoPause + dbw '<_CONT>', _ContText + dbw '', Paragraph + dbw '', PageChar + dbw '', PrintPlayerName + dbw '', PrintRivalName + dbw '#', PlacePOKe + dbw '', PCChar + dbw '', TeamChar + dbw '', RocketChar + dbw '', TMChar + dbw '', TrainerChar + dbw '', ContText + dbw '<...>', ThreeDotsChar + dbw '', DoneText + dbw '', PromptText + dbw '', PlacePKMN + dbw '', PlaceDexEnd + dbw '', PlaceMoveTargetsName + dbw '', PlaceMoveUsersName + dbw '', TrainerTipsChar + dbw '#MON', PokemonChar + dbw '',OpponentChar + dbw '', UserChar + dbw 'the', TheChar + dbw 'you', YouChar db -1 LineChar:: @@ -230,7 +230,7 @@ ContText:: jp PlaceNextChar PlaceDexEnd:: - ld [hl], "." + ld [hl], '.' pop hl ret @@ -238,12 +238,12 @@ PromptText:: ld a, [wLinkState] cp LINK_STATE_BATTLING jp z, .ok - ld a, "▼" + ld a, '▼' ldcoord_a 18, 16 .ok call ProtectedDelay3 call ManualTextScroll - ld a, " " + ld a, ' ' ldcoord_a 18, 16 DoneText:: @@ -259,7 +259,7 @@ TextScriptEndingText:: Paragraph:: push de - ld a, "▼" + ld a, '▼' ldcoord_a 18, 16 call ProtectedDelay3 call ManualTextScroll @@ -274,7 +274,7 @@ Paragraph:: PageChar:: push de - ld a, "▼" + ld a, '▼' ldcoord_a 18, 16 call ProtectedDelay3 call ManualTextScroll @@ -309,13 +309,13 @@ MultiButtonPageChar:: _ContText:: - ld a, "▼" + ld a, '▼' ldcoord_a 18, 16 call ProtectedDelay3 push de call ManualTextScroll pop de - ld a, " " + ld a, ' ' ldcoord_a 18, 16 _ContTextNoPause:: push de @@ -327,7 +327,7 @@ _ContTextNoPause:: ; move both rows of text in the normal text box up one row ; always called twice in a row -; first time, copy the two rows of text to the "in between" rows that are usually emtpy +; first time, copy the two rows of text to the "in between" rows that are usually empty ; second time, copy the bottom row of text into the top row of text ScrollTextUpOneLine:: hlcoord 0, 14 ; top row of text @@ -340,7 +340,7 @@ ScrollTextUpOneLine:: dec b jr nz, .copyText hlcoord 1, 16 - ld a, " " + ld a, ' ' ld b, SCREEN_WIDTH - 2 .clearText ld [hli], a @@ -425,7 +425,7 @@ TextCommand_START_storeFlags: jr TextCommand_START_noPop TextCommand_START:: -; write text until "@" +; write text until '@' pop hl TextCommand_START_noPop:: ld d, h @@ -516,12 +516,12 @@ TextCommand_PROMPT_BUTTON:: ld a, [wLinkState] cp LINK_STATE_BATTLING jp z, TextCommand_WAIT_BUTTON - ld a, "▼" + ld a, '▼' 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, " " + ld a, ' ' ldcoord_a 18, 16 ; overwrite down arrow with blank space pop hl jp NextTextCommand @@ -529,7 +529,7 @@ TextCommand_PROMPT_BUTTON:: 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, " " + ld a, ' ' ldcoord_a 18, 16 ; place blank space in lower right corner of dialogue text box call ScrollTextUpOneLine call ScrollTextUpOneLine @@ -574,7 +574,7 @@ TextCommand_PAUSE:: push bc call Joypad ldh a, [hJoyHeld] - and A_BUTTON | B_BUTTON + and PAD_A | PAD_B jr nz, .done ld c, 30 ; half a second rst _DelayFrames @@ -621,7 +621,7 @@ TextCommandSounds:: db TX_SOUND_DEX_PAGE_ADDED, SFX_DEX_PAGE_ADDED TextCommand_DOTS:: -; wait for button press or 30 frames while printing "…"s +; wait for button press or 30 frames while printing '…'s pop hl ld a, [hli] ld d, a @@ -630,13 +630,13 @@ TextCommand_DOTS:: ld l, c .loop - ld a, "…" + ld a, '…' ld [hli], a push de call Joypad pop de ldh a, [hJoyHeld] ; joypad state - and A_BUTTON | B_BUTTON + and PAD_A | PAD_B jr nz, .next ; if so, skip the delay ld c, 10 rst _DelayFrames diff --git a/home/text_script.asm b/home/text_script.asm index 2820e53211..c65b88926b 100644 --- a/home/text_script.asm +++ b/home/text_script.asm @@ -90,7 +90,7 @@ ENDM dict TX_SCRIPT_PRIZE_VENDOR, TextScript_GameCornerPrizeMenu dict2 TX_SCRIPT_CABLE_CLUB_RECEPTIONIST, callfar CableClubNPC - call PrintText_NoCreatingTextBox ; display the text + call PrintText_NoCreatingTextBox ld a, [wDoNotWaitForButtonPressAfterDisplayingText] and a jr nz, HoldTextDisplayOpen @@ -105,7 +105,7 @@ AfterDisplayingTextID:: HoldTextDisplayOpen:: call Joypad ldh a, [hJoyHeld] - bit BIT_A_BUTTON, a + bit B_PAD_A, a jr nz, HoldTextDisplayOpen ; FIXME: this unintentionally gets run after HoldTextDisplayOpen...but that may be a good thing since resetting sprite facings seems pointless. @@ -132,8 +132,8 @@ CloseTextDisplayPart1: CloseTextDisplaySpriteUpdateLoop: ; loop to make sprites face the directions they originally faced before the dialogue ld hl, wSprite01StateData2OrigFacingDirection - ld c, $0f - ld de, $10 + ld c, NUM_SPRITESTATEDATA_STRUCTS - 1 + ld de, SPRITESTATEDATA1_LENGTH .restoreSpriteFacingDirectionLoop ld a, [hl] ; x#SPRITESTATEDATA2_ORIGFACINGDIRECTION dec h diff --git a/home/tilemap.asm b/home/tilemap.asm index e8d916268a..904f7681c8 100644 --- a/home/tilemap.asm +++ b/home/tilemap.asm @@ -60,7 +60,7 @@ SaveScreenTilesToBuffer1:: ; fall through SaveScreenTilesCommon: hlcoord 0, 0 - ld bc, SCREEN_WIDTH * SCREEN_HEIGHT + ld bc, SCREEN_AREA rst _CopyData ret diff --git a/home/trainers.asm b/home/trainers.asm index 1259fbbbc7..6f22782a1e 100644 --- a/home/trainers.asm +++ b/home/trainers.asm @@ -21,7 +21,7 @@ ExecuteCurMapScriptInTable:: ld hl, wStatusFlags7 bit BIT_USE_CUR_MAP_SCRIPT, [hl] res BIT_USE_CUR_MAP_SCRIPT, [hl] - jr z, .useProvidedIndex ; test if map script index was overridden manually + jr z, .useProvidedIndex ; test if map script index was overridden manually ld a, [wCurMapScript] .useProvidedIndex pop hl @@ -34,13 +34,12 @@ ExecuteCurMapScriptInTable:: ;LoadGymLeaderAndCityName:: ; push de ; ld de, wGymCityName -; ld bc, $11 -; rst _CopyData ; load city name +; ld bc, GYM_CITY_LENGTH +; call CopyData ; load city name ; pop hl ; ld de, wGymLeaderName ; ld bc, NAME_LENGTH -; rst _CopyData ; load gym leader name -; ret +; jp CopyData ; load gym leader name ; reads specific information from trainer header (pointed to at wTrainerHeaderPtr) ; a: offset in header data @@ -146,13 +145,13 @@ ENDC xor a ; EXCLAMATION_BUBBLE ld [wWhichEmotionBubble], a predef EmotionBubble - ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_CTRL_PAD ld [wJoyIgnore], a xor a ldh [hJoyHeld], a call TrainerWalkUpToPlayer_Bank0 ld hl, wCurMapScript - inc [hl] ; increment map script index (next script function is usually DisplayEnemyTrainerTextAndStartBattle) + inc [hl] ; increment map script index (next script function is usually DisplayEnemyTrainerTextAndStartBattle) ret ; display the before battle text after the enemy trainer has walked up to the player's sprite @@ -176,7 +175,7 @@ StartTrainerBattle:: ld hl, wStatusFlags4 set BIT_UNKNOWN_4_1, [hl] ld hl, wCurMapScript - inc [hl] ; increment map script index (next script function is usually EndTrainerBattle) + inc [hl] ; increment map script index (next script function is usually EndTrainerBattle) ret EndTrainerBattle:: @@ -194,16 +193,16 @@ EndTrainerBattle:: call TrainerFlagAction ; flag trainer as fought ld a, [wEnemyMonOrTrainerClass] cp OPP_ID_OFFSET - jr nc, .skipRemoveSprite ; test if trainer was fought (in that case skip removing the corresponding sprite) + jr nc, .skipRemoveSprite ; test if trainer was fought (in that case skip removing the corresponding sprite) ; code that removes overworld pokemon like articuno, mewtwo, snorlax, etc. when defeated ; TODO: hide extra object if in extra map??? ld hl, wMissableObjectList ld de, FLAG_TEST ld a, [wSpriteIndex] - call IsInArray ; search for sprite ID + call IsInArray ; search for sprite ID inc hl ld a, [hl] - ld [wMissableObjectIndex], a ; load corresponding missable object index and remove it + ld [wMissableObjectIndex], a ; load corresponding missable object index and remove it predef HideObject .skipRemoveSprite ld hl, wStatusFlags5 @@ -265,7 +264,7 @@ CheckForEngagingTrainers:: .trainerLoop call StoreTrainerHeaderPointer ; set trainer header pointer to current trainer ld a, [de] - ld [wSpriteIndex], a ; store trainer flag's bit + ld [wSpriteIndex], a ; store trainer flag's bit ld [wTrainerHeaderFlagBit], a cp -1 ret z @@ -290,7 +289,7 @@ CheckForEngagingTrainers:: pop hl ld a, [wTrainerSpriteOffset] and a - ret nz ; break if the trainer is engaging + ret nz ; break if the trainer is engaging .continue ld hl, $c add hl, de @@ -353,8 +352,8 @@ PrintEndBattleText:: GetSavedEndBattleTextPointer:: ld a, [wBattleResult] and a -; won battle jr nz, .lostBattle +; won battle hl_deref_reverse wEndBattleWinTextPointer ret .lostBattle diff --git a/home/uncompress.asm b/home/uncompress.asm index 959e3283e4..3078d09e6d 100644 --- a/home/uncompress.asm +++ b/home/uncompress.asm @@ -11,10 +11,10 @@ UncompressSpriteData:: push af ld a, b call SetCurBank - ld a, SRAM_ENABLE - ld [MBC1SRamEnable], a + ld a, RAMG_SRAM_ENABLE + ld [rRAMG], a xor a - ld [MBC1SRamBank], a + ld [rRAMB], a call _UncompressSpriteData pop af jp SetCurBank @@ -458,7 +458,7 @@ DecodeNybble1TableFlipped:: dn $e, $6 dn $2, $a -; combines the two loaded chunks with xor (the chunk loaded second is the destination). The source chunk is differeintial decoded beforehand. +; combines the two loaded chunks with xor (the chunk loaded second is the destination). The source chunk is differential decoded beforehand. XorSpriteChunks:: xor a ld [wSpriteCurPosX], a @@ -556,7 +556,7 @@ ResetSpriteBufferPointers:: NybbleReverseTable:: db $0, $8, $4, $c, $2, $a, $6, $e, $1, $9, $5, $d, $3, $b, $7, $f -; combines the two loaded chunks with xor (the chunk loaded second is the destination). Both chunks are differeintial decoded beforehand. +; combines the two loaded chunks with xor (the chunk loaded second is the destination). Both chunks are differential decoded beforehand. UnpackSpriteMode2:: call ResetSpriteBufferPointers ld a, [wSpriteFlipped] diff --git a/home/vblank.asm b/home/vblank.asm index cdb32798bd..54f11152a9 100644 --- a/home/vblank.asm +++ b/home/vblank.asm @@ -43,7 +43,7 @@ VBlank:: ;shinpokerednote: FIXED: doing this in DelayFrame instead - helps avoid sprites wobbling ;ld a, BANK(PrepareOAMData) ;ldh [hLoadedROMBank], a - ;ld [MBC1RomBank], a + ;ld [rROMB], a ;call PrepareOAMData ; VBlank-sensitive operations end. diff --git a/home/vcopy.asm b/home/vcopy.asm index f658c8aef1..ff3863a812 100644 --- a/home/vcopy.asm +++ b/home/vcopy.asm @@ -19,11 +19,16 @@ GetRowColAddressBgMap:: ; clears a VRAM background map with blank space tiles ; INPUT: h - high byte of background tile map address in VRAM ClearBgMap:: - ld a, " " - jr .next + ld a, ' ' + jr FillBgMapCommon + +; fills a VRAM background map with tile index in register l +; INPUT: h - high byte of background tile map address in VRAM +FillBgMap:: ; unreferenced ld a, l -.next - ld de, BG_MAP_WIDTH * BG_MAP_HEIGHT + +FillBgMapCommon: + ld de, TILEMAP_AREA ld l, e .loop ld [hli], a @@ -61,7 +66,7 @@ RedrawRowOrColumn:: inc de ld a, [hli] ld [de], a - ld a, BG_MAP_WIDTH - 1 + ld a, TILEMAP_WIDTH - 1 add e ld e, a jr nc, .noCarry @@ -69,8 +74,8 @@ RedrawRowOrColumn:: .noCarry ; the following 4 lines wrap us from bottom to top if necessary ld a, d - and $3 - or $98 + and HIGH(TILEMAP_AREA - 1) + or HIGH(vBGMap0) ld d, a dec c jr nz, .loop1 @@ -86,7 +91,7 @@ RedrawRowOrColumn:: push de call .DrawHalf ; draw upper half pop de - ld a, BG_MAP_WIDTH ; width of VRAM background map + ld a, TILEMAP_WIDTH add e ld e, a ; fall through and draw lower half @@ -106,10 +111,10 @@ RedrawRowOrColumn:: xor e and $1f xor e - ;and $1f + ;and %11111 ;ld b, a ;ld a, e - ;and $e0 + ;and %11100000 ;or b ld e, a dec c @@ -146,8 +151,8 @@ AutoBgMapTransfer:: dec a jr z, .transferMiddleThird .transferBottomThird - coord sp, 0, 12 - ld de, (12 * 32) + coord sp, 0, 2 * SCREEN_HEIGHT / 3 + ld de, (2 * SCREEN_HEIGHT / 3) * TILEMAP_WIDTH add hl, de xor a ; TRANSFERTOP jr .doTransfer @@ -156,14 +161,14 @@ AutoBgMapTransfer:: ld a, TRANSFERMIDDLE jr .doTransfer .transferMiddleThird - coord sp, 0, 6 - ld de, (6 * 32) + coord sp, 0, SCREEN_HEIGHT / 3 + ld de, (SCREEN_HEIGHT / 3) * TILEMAP_WIDTH add hl, de ld a, TRANSFERBOTTOM ;;;;;;;; .doTransfer ldh [hAutoBGTransferPortion], a ; store next portion - ld b, 6 + ld b, SCREEN_HEIGHT / 3 TransferBgRows:: ; unrolled loop and using pop for speed @@ -179,7 +184,7 @@ ENDR inc l ld [hl], d - ld a, BG_MAP_WIDTH - (SCREEN_WIDTH - 1) + ld a, TILEMAP_WIDTH - (SCREEN_WIDTH - 1) add l ld l, a jr nc, .ok @@ -278,7 +283,7 @@ VBlankCopyDouble:: .loop ;;;;;;;; PureRGBnote: OPTIMIZED ;;;; More cycles -;REPT LEN_2BPP_TILE / 4 - 1 +;REPT TILE_SIZE / 4 - 1 ; pop de ; ld [hl], e ; inc l @@ -299,7 +304,7 @@ VBlankCopyDouble:: ; ld a, d ; ld [hli], a ;;;; Less cycles -REPT LEN_2BPP_TILE / 4 +REPT TILE_SIZE / 4 pop de ld a, e ld [hli], a @@ -386,7 +391,7 @@ VBlankCopy:: .loop ;;;;;;;; PureRGBnote: OPTIMIZED -REPT LEN_2BPP_TILE / 2 +REPT TILE_SIZE / 2 pop de ld a, e ld [hli], a diff --git a/home/window.asm b/home/window.asm index dc0aa951f5..20a4de184b 100644 --- a/home/window.asm +++ b/home/window.asm @@ -48,16 +48,16 @@ HandleMenuInput_:: ldh a, [hJoy5] ld b, a ;shinpokerednote: FIXED: fix from pokeyellow to prioritize the A button over the directional buttons - bit BIT_A_BUTTON, a ; pressed A key? + bit B_PAD_A, a ; pressed A key? jr nz, .checkOtherKeys - bit BIT_D_UP, a ; pressed Up key? + bit B_PAD_UP, a ; pressed Up key? jr z, .checkIfDownPressed -.upPressed +; Up pressed ld a, [wCurrentMenuItem] ; selected menu item and a ; already at the top of the menu? jr z, .alreadyAtTop -.notAtTop +; not at top dec a ld [wCurrentMenuItem], a ; move selected menu item up one space call CheckForHoverText ; PureRGBnote: ADDED: when moving up and down (but not scrolling) specific list menus, we need to display TM text @@ -70,16 +70,16 @@ HandleMenuInput_:: ld [wCurrentMenuItem], a ; wrap to the bottom of the menu jr .checkOtherKeys .checkIfDownPressed - bit BIT_D_DOWN, a + bit B_PAD_DOWN, a jr z, .checkOtherKeys -.downPressed +; Down pressed ld a, [wCurrentMenuItem] inc a ld c, a ld a, [wMaxMenuItem] cp c jr nc, .notAtBottom -.alreadyAtBottom +; already at bottom ld a, [wMenuWrappingEnabled] and a ; is wrapping around enabled? jr z, .noWrappingAround @@ -94,7 +94,7 @@ HandleMenuInput_:: jp z, .loop1 .checkIfAButtonOrBButtonPressed ld a, b ; shinpokerednote: CHANGED: load from b, which contains [hJoy5], to save 1 byte - and A_BUTTON | B_BUTTON + and PAD_A | PAD_B jr z, .skipPlayingSound .AButtonOrBButtonPressed ld a, [wMiscFlags] ;shinpokerednote: CHANGED: remove push/pop with hl to save 2 bytes @@ -152,9 +152,9 @@ PlaceMenuCursor:: jr nz, .oldMenuItemLoop .checkForArrow1 ld a, [hl] - cp "▶" ; was an arrow next to the previously selected menu item? + cp '▶' ; was an arrow next to the previously selected menu item? jr nz, .skipClearingArrow -.clearArrow +; clear arrow ld a, [wTileBehindCursor] ld [hl], a .skipClearingArrow @@ -178,11 +178,11 @@ PlaceMenuCursor:: jr nz, .currentMenuItemLoop .checkForArrow2 ld a, [hl] - cp "▶" ; has the right arrow already been placed? + 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 [hl], "▶" + ld [hl], '▶' ld a, l ld [wMenuCursorLocation], a ld a, h @@ -207,14 +207,14 @@ CheckForHoverText:: PlaceUnfilledArrowMenuCursor:: ld b, a hl_deref wMenuCursorLocation - ld [hl], "▷" + ld [hl], '▷' ld a, b ret ; Replaces the menu cursor with a blank space. EraseMenuCursor:: hl_deref wMenuCursorLocation - ld [hl], " " + ld [hl], ' ' ret ; This toggles a blinking down arrow at hl on and off after a delay has passed. @@ -228,7 +228,7 @@ EraseMenuCursor:: HandleDownArrowBlinkTiming:: ld a, [hl] ld b, a - ld a, "▼" + ld a, '▼' cp b jr nz, .downArrowOff .downArrowOn @@ -240,7 +240,7 @@ HandleDownArrowBlinkTiming:: dec a ldh [hDownArrowBlinkCount2], a ret nz - ld [hl], " " + ld [hl], ' ' ld a, $ff ldh [hDownArrowBlinkCount1], a ld a, $06 @@ -261,7 +261,7 @@ HandleDownArrowBlinkTiming:: ret nz ld a, $06 ldh [hDownArrowBlinkCount2], a - ld [hl], "▼" + ld [hl], '▼' ret ; The following code either enables or disables the automatic drawing of diff --git a/home/yes_no.asm b/home/yes_no.asm index a3fc52a62e..aa4e881a26 100644 --- a/home/yes_no.asm +++ b/home/yes_no.asm @@ -49,7 +49,7 @@ DisplayMultiChoiceTextBoxNoMenuReset:: ld [wMenuWatchedKeys], a callfar DisplayMultiChoiceMenu ldh a, [hJoy5] - bit BIT_B_BUTTON, a + bit B_PAD_B, a ret ;WideYesNoChoice:: ; unused diff --git a/includes.asm b/includes.asm index 66b2243d0a..5e591e6b48 100644 --- a/includes.asm +++ b/includes.asm @@ -14,12 +14,11 @@ INCLUDE "macros/scripts/events.asm" INCLUDE "macros/scripts/text.asm" INCLUDE "constants/charmap.asm" -INCLUDE "constants/hardware_constants.asm" +INCLUDE "constants/hardware.inc" INCLUDE "constants/oam_constants.asm" INCLUDE "constants/ram_constants.asm" INCLUDE "constants/misc_constants.asm" INCLUDE "constants/gfx_constants.asm" -INCLUDE "constants/input_constants.asm" INCLUDE "constants/serial_constants.asm" INCLUDE "constants/script_constants.asm" INCLUDE "constants/type_constants.asm" @@ -32,6 +31,7 @@ INCLUDE "constants/item_constants.asm" INCLUDE "constants/pokemon_constants.asm" INCLUDE "constants/pokedex_constants.asm" INCLUDE "constants/pokemon_data_constants.asm" +INCLUDE "constants/player_constants.asm" INCLUDE "constants/trainer_constants.asm" INCLUDE "constants/icon_constants.asm" INCLUDE "constants/sprite_constants.asm" diff --git a/macros/asserts.asm b/macros/asserts.asm index 402d97dda5..11e0ee992e 100644 --- a/macros/asserts.asm +++ b/macros/asserts.asm @@ -1,18 +1,14 @@ ; Macros to verify assumptions about the data or code -MACRO _redef_current_label +MACRO? _redef_current_label IF DEF(\1) PURGE \1 ENDC - IF _NARG == 3 + (\3) - DEF \1 EQUS "\<_NARG>" - ELIF DEF(..) - IF .. - @ == 0 - DEF \1 EQUS "{..}" - ENDC - ELIF DEF(.) - if . - @ == 0 - DEF \1 EQUS "{.}" + IF _NARG > 2 + DEF \1 EQUS "\3" + ELIF STRLEN(#__SCOPE__) + IF {{__SCOPE__}} - @ == 0 + DEF \1 EQUS #{__SCOPE__} ENDC ENDC if !DEF(\1) @@ -21,41 +17,55 @@ MACRO _redef_current_label ENDC ENDM -MACRO table_width +MACRO? table_width DEF CURRENT_TABLE_WIDTH = \1 - _redef_current_label CURRENT_TABLE_START, "._table_width\@", 2, \# + SHIFT + _redef_current_label CURRENT_TABLE_START, "._table_width\@", \# ENDM -MACRO assert_table_length - DEF x = \1 - ASSERT x * CURRENT_TABLE_WIDTH == @ - {CURRENT_TABLE_START}, \ - "{CURRENT_TABLE_START}: expected {d:x} entries, each {d:CURRENT_TABLE_WIDTH} bytes" +MACRO? assert_table_length + DEF w = \1 + DEF x = w * CURRENT_TABLE_WIDTH + DEF y = @ - {CURRENT_TABLE_START} + ASSERT x == y, "{CURRENT_TABLE_START}: expected {d:w} entries, each {d:CURRENT_TABLE_WIDTH} " ++ \ + "bytes, for {d:x} total; but got {d:y} bytes" ENDM -MACRO assert_max_table_length - DEF x = \1 - ASSERT x * CURRENT_TABLE_WIDTH >= @ - {CURRENT_TABLE_START}, \ - "{CURRENT_TABLE_START}: expected a maximum of {d:x} entries, each {d:CURRENT_TABLE_WIDTH} bytes" +MACRO? assert_max_table_length + DEF w = \1 + DEF x = w * CURRENT_TABLE_WIDTH + DEF y = @ - {CURRENT_TABLE_START} + ASSERT x >= y, "{CURRENT_TABLE_START}: expected a maximum of {d:w} entries, each " ++ \ + "{d:CURRENT_TABLE_WIDTH} bytes, for maximum {d:x} total; but got {d:y} bytes" ENDM -MACRO list_start +MACRO? list_start DEF list_index = 0 - _redef_current_label CURRENT_LIST_START, "._list_start\@", 1, \# + DEF list_item_length = 0 + IF _NARG > 0 + DEF list_item_length = \1 + SHIFT + ENDC + _redef_current_label CURRENT_LIST_START, "._list_start\@", \# ENDM -MACRO li - ASSERT STRFIND(\1, "@") == -1, STRCAT("String terminator \"@\" in list entry: ", \1) +MACRO? li + ASSERT STRFIND(\1, "@") == -1, "String terminator \"@\" in list entry: \1" + IF list_item_length + ASSERT CHARLEN(\1) <= list_item_length, \ + "List entry longer than {d:list_item_length} characters: \1" + ENDC db \1, "@" DEF list_index += 1 ENDM -MACRO assert_list_length +MACRO? assert_list_length DEF x = \1 ASSERT x == list_index, \ "{CURRENT_LIST_START}: expected {d:x} entries, got {d:list_index}" ENDM -MACRO nybble_array +MACRO? nybble_array DEF CURRENT_NYBBLE_ARRAY_VALUE = 0 DEF CURRENT_NYBBLE_ARRAY_LENGTH = 0 IF _NARG == 1 @@ -66,7 +76,7 @@ MACRO nybble_array ENDC ENDM -MACRO nybble +MACRO? nybble ASSERT 0 <= (\1) && (\1) < $10, "nybbles must be 0-15" DEF CURRENT_NYBBLE_ARRAY_VALUE = (\1) | (CURRENT_NYBBLE_ARRAY_VALUE << 4) DEF CURRENT_NYBBLE_ARRAY_LENGTH += 1 @@ -76,7 +86,7 @@ MACRO nybble ENDC ENDM -MACRO end_nybble_array +MACRO? end_nybble_array IF CURRENT_NYBBLE_ARRAY_LENGTH % 2 db CURRENT_NYBBLE_ARRAY_VALUE << 4 ENDC @@ -90,7 +100,7 @@ MACRO end_nybble_array ENDC ENDM -MACRO bit_array +MACRO? bit_array DEF CURRENT_BIT_ARRAY_VALUE = 0 DEF CURRENT_BIT_ARRAY_LENGTH = 0 IF _NARG == 1 @@ -101,7 +111,7 @@ MACRO bit_array ENDC ENDM -MACRO dbit +MACRO? dbit ASSERT (\1) == 0 || (\1) == 1, "bits must be 0 or 1" DEF CURRENT_BIT_ARRAY_VALUE |= (\1) << (CURRENT_BIT_ARRAY_LENGTH % 8) DEF CURRENT_BIT_ARRAY_LENGTH += 1 @@ -111,7 +121,7 @@ MACRO dbit ENDC ENDM -MACRO end_bit_array +MACRO? end_bit_array IF CURRENT_BIT_ARRAY_LENGTH % 8 db CURRENT_BIT_ARRAY_VALUE ENDC @@ -125,7 +135,7 @@ MACRO end_bit_array ENDC ENDM -MACRO def_grass_wildmons +MACRO? def_grass_wildmons ;\1: encounter rate DEF CURRENT_GRASS_WILDMONS_RATE = \1 REDEF CURRENT_GRASS_WILDMONS_LABEL EQUS "._def_grass_wildmons_\1" @@ -133,17 +143,18 @@ MACRO def_grass_wildmons db \1 ENDM -MACRO end_grass_wildmons +MACRO? end_grass_wildmons + DEF x = @ - {CURRENT_GRASS_WILDMONS_LABEL} IF CURRENT_GRASS_WILDMONS_RATE == 0 - ASSERT 1 == @ - {CURRENT_GRASS_WILDMONS_LABEL}, \ - "def_grass_wildmons {d:CURRENT_GRASS_WILDMONS_RATE}: expected 1 byte" + ASSERT 1 == x, \ + "def_grass_wildmons {d:CURRENT_GRASS_WILDMONS_RATE}: expected 1 byte, got {d:x}" ELSE - ASSERT WILDDATA_LENGTH == @ - {CURRENT_GRASS_WILDMONS_LABEL}, \ - "def_grass_wildmons {d:CURRENT_GRASS_WILDMONS_RATE}: expected {d:WILDDATA_LENGTH} bytes" + ASSERT WILDDATA_LENGTH == x, \ + "def_grass_wildmons {d:CURRENT_GRASS_WILDMONS_RATE}: expected {d:WILDDATA_LENGTH} bytes, got {d:x}" ENDC ENDM -MACRO def_water_wildmons +MACRO? def_water_wildmons ;\1: encounter rate DEF CURRENT_WATER_WILDMONS_RATE = \1 REDEF CURRENT_WATER_WILDMONS_LABEL EQUS "._def_water_wildmons_\1" @@ -151,12 +162,13 @@ MACRO def_water_wildmons db \1 ENDM -MACRO end_water_wildmons +MACRO? end_water_wildmons + DEF x = @ - {CURRENT_WATER_WILDMONS_LABEL} IF CURRENT_WATER_WILDMONS_RATE == 0 - ASSERT 1 == @ - {CURRENT_WATER_WILDMONS_LABEL}, \ - "def_water_wildmons {d:CURRENT_WATER_WILDMONS_RATE}: expected 1 byte" + ASSERT 1 == x, \ + "def_water_wildmons {d:CURRENT_WATER_WILDMONS_RATE}: expected 1 byte, got {d:x}" ELSE - ASSERT WILDDATA_LENGTH == @ - {CURRENT_WATER_WILDMONS_LABEL}, \ - "def_water_wildmons {d:CURRENT_WATER_WILDMONS_RATE}: expected {d:WILDDATA_LENGTH} bytes" + ASSERT WILDDATA_LENGTH == x, \ + "def_water_wildmons {d:CURRENT_WATER_WILDMONS_RATE}: expected {d:WILDDATA_LENGTH} bytes, got {d:x}" ENDC ENDM diff --git a/macros/code.asm b/macros/code.asm index ef92ca035b..f5d6f24aff 100644 --- a/macros/code.asm +++ b/macros/code.asm @@ -1,15 +1,23 @@ ; Syntactic sugar macros -MACRO lb ; r, hi, lo +MACRO? lb ; r, hi, lo ld \1, ((\2) & $ff) << 8 + ((\3) & $ff) ENDM -MACRO ldpal +MACRO? ldpal ld \1, \2 << 6 | \3 << 4 | \4 << 2 | \5 ENDM ; Design patterns +MACRO ld_hli_a_string + FOR n, CHARLEN(\1) - 1 + ld a, CHARVAL(STRCHAR(\1, n)) + ld [hli], a + ENDR + ld [hl], CHARVAL(STRCHAR(\1, CHARLEN(\1) - 1)) +ENDM + MACRO dict IF \1 == 0 and a diff --git a/macros/const.asm b/macros/const.asm index fa2f07532b..d6a34672a1 100644 --- a/macros/const.asm +++ b/macros/const.asm @@ -1,6 +1,6 @@ ; Enumerate constants -MACRO const_def +MACRO? const_def IF _NARG >= 1 DEF const_value = \1 ELSE @@ -13,22 +13,22 @@ MACRO const_def ENDC ENDM -MACRO const +MACRO? const DEF \1 EQU const_value DEF const_value += const_inc ENDM -MACRO const_export +MACRO? const_export const \1 EXPORT \1 ENDM -MACRO shift_const +MACRO? shift_const DEF \1 EQU 1 << const_value DEF const_value += const_inc ENDM -MACRO const_skip +MACRO? const_skip if _NARG >= 1 DEF const_value += const_inc * (\1) else @@ -36,7 +36,7 @@ MACRO const_skip endc ENDM -MACRO const_next +MACRO? const_next if (const_value > 0 && \1 < const_value) || (const_value < 0 && \1 > const_value) fail "const_next cannot go backwards from {const_value} to \1" else @@ -44,12 +44,12 @@ MACRO const_next endc ENDM -MACRO dw_const +MACRO? dw_const dw \1 const \2 ENDM -MACRO rb_skip +MACRO? rb_skip IF _NARG == 1 rsset _RS + \1 ELSE diff --git a/macros/coords.asm b/macros/coords.asm index 6e122804f5..847585c894 100644 --- a/macros/coords.asm +++ b/macros/coords.asm @@ -1,4 +1,4 @@ -MACRO validate_coords +MACRO? validate_coords IF _NARG >= 4 IF \1 >= \3 fail "x coord out of range" @@ -11,19 +11,19 @@ MACRO validate_coords ENDC ENDM -MACRO hlcoord +MACRO? hlcoord coord hl, \# ENDM -MACRO bccoord +MACRO? bccoord coord bc, \# ENDM -MACRO decoord +MACRO? decoord coord de, \# ENDM -MACRO coord +MACRO? coord ; register, x, y[, origin] validate_coords \2, \3 IF _NARG >= 4 @@ -33,52 +33,52 @@ MACRO coord ENDC ENDM -MACRO hlbgcoord +MACRO? hlbgcoord bgcoord hl, \# ENDM -MACRO bcbgcoord +MACRO? bcbgcoord bgcoord bc, \# ENDM -MACRO debgcoord +MACRO? debgcoord bgcoord de, \# ENDM -MACRO bgcoord +MACRO? bgcoord ; register, x, y[, origin] - validate_coords \2, \3, BG_MAP_WIDTH, BG_MAP_HEIGHT + validate_coords \2, \3, TILEMAP_WIDTH, TILEMAP_HEIGHT IF _NARG >= 4 - ld \1, (\3) * BG_MAP_WIDTH + (\2) + \4 + ld \1, (\3) * TILEMAP_WIDTH + (\2) + \4 ELSE - ld \1, (\3) * BG_MAP_WIDTH + (\2) + vBGMap0 + ld \1, (\3) * TILEMAP_WIDTH + (\2) + vBGMap0 ENDC ENDM -MACRO hlowcoord +MACRO? hlowcoord owcoord hl, \# ENDM -MACRO bcowcoord +MACRO? bcowcoord owcoord bc, \# ENDM -MACRO deowcoord +MACRO? deowcoord owcoord de, \# ENDM -MACRO owcoord +MACRO? owcoord ; register, x, y, map width ld \1, wOverworldMap + ((\2) + 3) + (((\3) + 3) * ((\4) + (3 * 2))) ENDM -MACRO event_displacement +MACRO? event_displacement ; map width, x blocks, y blocks dw (wOverworldMap + 7 + (\1) + ((\1) + 6) * ((\3) >> 1) + ((\2) >> 1)) db \3, \2 ENDM -MACRO dwcoord +MACRO? dwcoord ; x, y validate_coords \1, \2 IF _NARG >= 3 @@ -88,7 +88,7 @@ MACRO dwcoord ENDC ENDM -MACRO ldcoord_a +MACRO? ldcoord_a ; x, y[, origin] validate_coords \1, \2 IF _NARG >= 3 @@ -98,7 +98,7 @@ MACRO ldcoord_a ENDC ENDM -MACRO lda_coord +MACRO? lda_coord ; x, y[, origin] validate_coords \1, \2 IF _NARG >= 3 @@ -108,7 +108,7 @@ MACRO lda_coord ENDC ENDM -MACRO dbmapcoord +MACRO? dbmapcoord ; x, y db \2, \1 ENDM diff --git a/macros/data.asm b/macros/data.asm index c3c9cb8d73..feb8f1b86e 100644 --- a/macros/data.asm +++ b/macros/data.asm @@ -2,25 +2,26 @@ DEF percent EQUS "* $ff / 100" -MACRO bcd2 +MACRO? bcd2 dn ((\1) / 1000) % 10, ((\1) / 100) % 10 dn ((\1) / 10) % 10, (\1) % 10 ENDM -MACRO bcd3 +MACRO? bcd3 dn ((\1) / 100000) % 10, ((\1) / 10000) % 10 dn ((\1) / 1000) % 10, ((\1) / 100) % 10 dn ((\1) / 10) % 10, (\1) % 10 ENDM ; used in data/pokemon/base_stats/*.asm -MACRO tmhm +MACRO? tmhm ; initialize bytes to 0 FOR n, (NUM_TM_HM + 7) / 8 DEF _tm{d:n} = 0 ENDR ; set bits of bytes REPT _NARG + ASSERT FATAL, STRFIND("\1", " ") == -1, "Invalid move: \1" IF DEF(\1_TMNUM) DEF n = (\1_TMNUM - 1) / 8 DEF i = (\1_TMNUM - 1) % 8 @@ -39,44 +40,56 @@ ENDM ; Constant data (db, dw, dl) macros -MACRO dbw +MACRO? dbw db \1 dw \2 ENDM -MACRO dwb +MACRO? dwb dw \1 db \2 ENDM -MACRO dn ; nybbles +MACRO? dn ; nybbles REPT _NARG / 2 db ((\1) << 4) | (\2) SHIFT 2 ENDR ENDM -MACRO dc ; "crumbs" +MACRO? dc ; "crumbs" REPT _NARG / 4 db ((\1) << 6) | ((\2) << 4) | ((\3) << 2) | (\4) SHIFT 4 ENDR ENDM -MACRO bigdw ; big-endian word +MACRO? bigdw ; big-endian word db HIGH(\1), LOW(\1) ENDM -MACRO dba ; dbw bank, address +MACRO? dba ; dbw bank, address REPT _NARG dbw BANK(\1), \1 SHIFT ENDR ENDM -MACRO dab ; dwb address, bank +MACRO? dab ; dwb address, bank REPT _NARG dwb \1, BANK(\1) SHIFT ENDR ENDM + +MACRO? dname + IF _NARG == 2 + DEF n = \2 + ELSE + DEF n = NAME_LENGTH - 1 + ENDC + ASSERT STRFIND(\1, "@") == -1, "String terminator \"@\" in name: \1" + ASSERT CHARLEN(\1) <= n, "Name longer than {d:n} characters: \1" + db \1 + ds n - CHARLEN(\1), '@' +ENDM diff --git a/macros/farcall.asm b/macros/farcall.asm index ebf8e87275..1ffc898df8 100644 --- a/macros/farcall.asm +++ b/macros/farcall.asm @@ -1,3 +1,10 @@ +; Far calls to another bank + +; There is no difference between `farcall` and `callfar`, except the arbitrary +; order in which they set `b` and `hl` before calling `FarCall`. +; We use the more natural name "farcall" for the more common order. +; The same goes for `farjp` and `jpfar`. + MACRO farcall ld b, BANK(\1) ld hl, \1 diff --git a/macros/gfx.asm b/macros/gfx.asm index 944e6dd591..817f8787ef 100644 --- a/macros/gfx.asm +++ b/macros/gfx.asm @@ -1,22 +1,22 @@ -MACRO RGB +MACRO? RGB REPT _NARG / 3 dw palred (\1) + palgreen (\2) + palblue (\3) SHIFT 3 ENDR ENDM -DEF palred EQUS "(1 << 0) *" -DEF palgreen EQUS "(1 << 5) *" -DEF palblue EQUS "(1 << 10) *" +DEF palred EQUS "(1 << B_COLOR_RED) *" +DEF palgreen EQUS "(1 << B_COLOR_GREEN) *" +DEF palblue EQUS "(1 << B_COLOR_BLUE) *" -DEF palettes EQUS "* PALETTE_SIZE" -DEF palette EQUS "+ PALETTE_SIZE *" -DEF color EQUS "+ PAL_COLOR_SIZE *" +DEF palettes EQUS "* PAL_SIZE" +DEF palette EQUS "+ PAL_SIZE *" +DEF color EQUS "+ PAL_COLORS *" -DEF tiles EQUS "* LEN_2BPP_TILE" -DEF tile EQUS "+ LEN_2BPP_TILE *" +DEF tiles EQUS "* TILE_SIZE" +DEF tile EQUS "+ TILE_SIZE *" -MACRO dbsprite +MACRO? dbsprite ; x tile, y tile, x pixel, y pixel, vtile offset, attributes db (\2 * TILE_WIDTH) % $100 + \4, (\1 * TILE_WIDTH) % $100 + \3, \5, \6 ENDM diff --git a/macros/predef.asm b/macros/predef.asm index dd38f7fff7..b1e0c9dc8c 100644 --- a/macros/predef.asm +++ b/macros/predef.asm @@ -1,33 +1,33 @@ -MACRO predef_id +MACRO? predef_id ld a, (\1Predef - PredefPointers) / 3 ENDM -MACRO predef +MACRO? predef predef_id \1 rst _Predef ENDM -MACRO predef_jump +MACRO? predef_jump predef_id \1 rst _Predef ret ENDM -MACRO tx_pre_id +MACRO? tx_pre_id ld a, (\1_id - TextPredefs) / 2 + 1 ENDM -MACRO tx_pre +MACRO? tx_pre tx_pre_id \1 call PrintPredefTextID ENDM -MACRO tx_pre_jump +MACRO? tx_pre_jump tx_pre_id \1 jp PrintPredefTextID ENDM -MACRO db_tx_pre +MACRO? db_tx_pre db (\1_id - TextPredefs) / 2 + 1 ENDM diff --git a/macros/ram.asm b/macros/ram.asm index c80d9178b8..f6a95511af 100644 --- a/macros/ram.asm +++ b/macros/ram.asm @@ -1,11 +1,9 @@ ; Used in wram.asm -MACRO flag_array +MACRO? flag_array ds ((\1) + 7) / 8 ENDM -DEF BOX_STRUCT_LENGTH EQU 25 + NUM_MOVES * 2 - MACRO box_struct \1Species:: db \1HP:: dw diff --git a/macros/scripts/events.asm b/macros/scripts/events.asm index 3d4e488102..e36a8ebf14 100644 --- a/macros/scripts/events.asm +++ b/macros/scripts/events.asm @@ -425,7 +425,7 @@ MACRO ResetEventRange IF event_fill_count > 1 ld hl, wEventFlags + event_fill_start - ; force xor a if we just to wrote to it above + ; force xor a if we just wrote to it above IF (_NARG < 3) || (((\1) % 8) != 0) xor a ENDC diff --git a/macros/scripts/maps.asm b/macros/scripts/maps.asm index 2837d0c0ad..127a13adcf 100644 --- a/macros/scripts/maps.asm +++ b/macros/scripts/maps.asm @@ -72,6 +72,12 @@ ENDM ;\1 source map MACRO def_warps_to + ASSERT {_NUM_WARP_EVENTS} <= MAX_WARP_EVENTS, \ + "Too many warp_events (above {d:MAX_WARP_EVENTS})!" + ASSERT {_NUM_BG_EVENTS} <= MAX_BG_EVENTS, \ + "Too many bg_events (above {d:MAX_BG_EVENTS})!" + ASSERT {_NUM_OBJECT_EVENTS} <= MAX_OBJECT_EVENTS, \ + "Too many object_events (above {d:MAX_OBJECT_EVENTS})!" ; text ID values are significant (see DisplayTextID in home/text_scripts.asm) FOR n, {_NUM_BG_EVENTS} ASSERT {_BG_EVENT_{d:n}_TEXT_ID} > {_NUM_OBJECT_EVENTS}, \ @@ -168,7 +174,7 @@ MACRO connection DEF _tgt = 0 ENDC - IF !STRCMP("\1", "north") + IF "\1" === "north" DEF _blk = \3_WIDTH * (\3_HEIGHT - 3) + _src DEF _map = _tgt DEF _win = (\3_WIDTH + 6) * \3_HEIGHT + 1 @@ -179,7 +185,7 @@ MACRO connection DEF _len = \3_WIDTH ENDC - ELIF !STRCMP("\1", "south") + ELIF "\1" === "south" DEF _blk = _src DEF _map = (CURRENT_MAP_WIDTH + 6) * (CURRENT_MAP_HEIGHT + 3) + _tgt DEF _win = \3_WIDTH + 7 @@ -190,7 +196,7 @@ MACRO connection DEF _len = \3_WIDTH ENDC - ELIF !STRCMP("\1", "west") + ELIF "\1" === "west" DEF _blk = (\3_WIDTH * _src) + \3_WIDTH - 3 DEF _map = (CURRENT_MAP_WIDTH + 6) * _tgt DEF _win = (\3_WIDTH + 6) * 2 - 6 @@ -201,7 +207,7 @@ MACRO connection DEF _len = \3_HEIGHT ENDC - ELIF !STRCMP("\1", "east") + ELIF "\1" === "east" DEF _blk = (\3_WIDTH * _src) DEF _map = (CURRENT_MAP_WIDTH + 6) * _tgt + CURRENT_MAP_WIDTH + 3 DEF _win = \3_WIDTH + 7 diff --git a/macros/vc.asm b/macros/vc.asm index 0990e988f5..bc0734aaab 100644 --- a/macros/vc.asm +++ b/macros/vc.asm @@ -1,22 +1,22 @@ -MACRO vc_hook +MACRO? vc_hook IF DEF(_RED_VC) || DEF(_BLUE_VC) .VC_\1:: ENDC ENDM -MACRO vc_hook_red +MACRO? vc_hook_red IF DEF(_RED_VC) .VC_\1:: ENDC ENDM -MACRO vc_hook_blue +MACRO? vc_hook_blue IF DEF(_BLUE_VC) .VC_\1:: ENDC ENDM -MACRO vc_patch +MACRO? vc_patch IF DEF(_RED_VC) || DEF(_BLUE_VC) ASSERT !DEF(CURRENT_VC_PATCH), "Already started a vc_patch" DEF CURRENT_VC_PATCH EQUS "\1" @@ -24,7 +24,7 @@ MACRO vc_patch ENDC ENDM -MACRO vc_patch_end +MACRO? vc_patch_end IF DEF(_RED_VC) || DEF(_BLUE_VC) ASSERT DEF(CURRENT_VC_PATCH), "No vc_patch started" .VC_{CURRENT_VC_PATCH}_End:: @@ -32,7 +32,7 @@ MACRO vc_patch_end ENDC ENDM -MACRO vc_assert +MACRO? vc_assert IF DEF(_RED_VC) || DEF(_BLUE_VC) ASSERT \# ENDC diff --git a/ram/vram.asm b/ram/vram.asm index 04556410cb..0819fe0a5a 100644 --- a/ram/vram.asm +++ b/ram/vram.asm @@ -5,15 +5,15 @@ UNION vChars0:: ds $80 tiles vChars1:: ds $80 tiles vChars2:: ds $80 tiles -vBGMap0:: ds BG_MAP_WIDTH * BG_MAP_HEIGHT -vBGMap1:: ds BG_MAP_WIDTH * BG_MAP_HEIGHT +vBGMap0:: ds TILEMAP_AREA +vBGMap1:: ds TILEMAP_AREA NEXTU ; battle/menu vSprites:: ds $80 tiles vFont:: ds $80 tiles -vFrontPic:: ds 7 * 7 tiles -vBackPic:: ds 7 * 7 tiles +vFrontPic:: ds PIC_SIZE tiles +vBackPic:: ds PIC_SIZE tiles NEXTU ; overworld @@ -25,7 +25,7 @@ NEXTU ; title ds $80 tiles vTitleLogo:: ds $80 tiles - ds 7 * 7 tiles + ds PIC_SIZE tiles vTitleLogo2:: ds 30 tiles ENDU diff --git a/ram/wram.asm b/ram/wram.asm index 18c91cfa5f..5f1f5411ad 100644 --- a/ram/wram.asm +++ b/ram/wram.asm @@ -164,7 +164,7 @@ SECTION "OAM Buffer", WRAM0 ; buffer for OAM data. Copied to OAM by DMA wShadowOAM:: ; wShadowOAMSprite00 - wShadowOAMSprite39 -FOR n, NUM_SPRITE_OAM_STRUCTS +FOR n, OAM_COUNT wShadowOAMSprite{02d:n}:: sprite_oam_struct wShadowOAMSprite{02d:n} ENDR wShadowOAMEnd:: @@ -173,13 +173,13 @@ wShadowOAMEnd:: SECTION "Tilemap", WRAM0 ; buffer for tiles that are visible on screen (20 columns by 18 rows) -wTileMap:: ds SCREEN_WIDTH * SCREEN_HEIGHT +wTileMap:: ds SCREEN_AREA ; This union spans 480 bytes. UNION ; buffer for temporarily saving and restoring current screen's tiles ; (e.g. if menus are drawn on top) -wTileMapBackup:: ds SCREEN_WIDTH * SCREEN_HEIGHT ; 360 +wTileMapBackup:: ds SCREEN_AREA ; 360 NEXTU ; buffer for the blocks surrounding the player (6 columns by 5 rows of 4x4-tile blocks) @@ -189,7 +189,7 @@ NEXTU ; buffer for temporarily saving and restoring shadow OAM wShadowOAMBackup:: ; wShadowOAMBackupSprite00 - wShadowOAMBackupSprite39 -FOR n, NUM_SPRITE_OAM_STRUCTS +FOR n, OAM_COUNT wShadowOAMBackupSprite{02d:n}:: sprite_oam_struct wShadowOAMBackupSprite{02d:n} ENDR wShadowOAMBackupEnd:: @@ -210,7 +210,7 @@ wOverworldMap:: ds 1300 wOverworldMapEnd:: NEXTU -wTempPic:: ds 7 * 7 tiles +wTempPic:: ds PIC_SIZE tiles ENDU @@ -374,7 +374,7 @@ wOverworldAnimationCooldown:: db ; used to make sure occasional animations don't ; This union spans 180 bytes. UNION -wVermilionDockTileMapBuffer:: ds 5 * BG_MAP_WIDTH + SCREEN_WIDTH +wVermilionDockTileMapBuffer:: ds 5 * TILEMAP_WIDTH + SCREEN_WIDTH wVermilionDockTileMapBufferEnd:: NEXTU @@ -405,7 +405,7 @@ wFilteredBagItems:: ds 4 NEXTU ; Saved copy of OAM for the first frame of the animation to make it easy to ; flip back from the second frame. -wMonPartySpritesSavedOAM:: ds $60 +wMonPartySpritesSavedOAM:: ds OBJ_SIZE * 4 * PARTY_LENGTH NEXTU wTrainerCardBlkPacket:: ds $40 @@ -454,7 +454,7 @@ wAnimPalette:: db NEXTU ds 60 ; temporary buffer when swapping party mon data -wSwitchPartyMonTempBuffer:: ds 44 ; party_struct size +wSwitchPartyMonTempBuffer:: ds PARTYMON_STRUCT_LENGTH NEXTU ds 120 @@ -747,7 +747,11 @@ NEXTU ds 1 ; difference in X between the next ball and the current one wHUDPokeballGfxOffsetX:: db -wHUDGraphicsTiles:: ds 3 +wHUDGraphicsTiles:: +wHUDUnusedTopTile:: db +wHUDCornerTile:: db +wHUDTriangleTile:: db +wHUDGraphicsTilesEnd:: NEXTU ; the level of the mon at the time it entered day care @@ -991,6 +995,7 @@ wDownscaledMonSize:: ; FormatMovesString stores the number of moves minus one here wNumMovesMinusOne:: db +; This union spans 20 bytes. UNION ; storage buffer for various name strings wNameBuffer:: ds NAME_BUFFER_LENGTH @@ -1006,7 +1011,8 @@ wPayDayMoney:: ds 3 NEXTU ; evolution data for one mon -wEvoDataBuffer:: ds 4 * 3 + 1 ; enough for Eevee's three 4-byte evolutions and 0 terminator +wEvoDataBuffer:: ds NUM_EVOS_IN_BUFFER * 4 + 1 ; enough for Eevee's three 4-byte evolutions and 0 terminator +wEvoDataBufferEnd:: NEXTU wBattleMenuCurrentPP:: db @@ -1022,7 +1028,7 @@ UNION wSerialOtherGameboyRandomNumberListBlock:: ds $11 NEXTU ; second buffer for temporarily saving and restoring current screen's tiles (e.g. if menus are drawn on top) -wTileMapBackup2:: ds SCREEN_WIDTH * SCREEN_HEIGHT +wTileMapBackup2:: ds SCREEN_AREA ENDU ; This union spans 30 bytes. @@ -1178,7 +1184,7 @@ wPartyHPBarAttributes:: NEXTU ds 29 ; storage buffer for various strings -wStringBuffer:: ds 20 +wStringBuffer:: ds NAME_BUFFER_LENGTH NEXTU ds 29 @@ -1376,7 +1382,7 @@ wTrainerPicPointer:: dw ds 1 ; unused lone byte UNION -wTempMoveNameBuffer:: ds 14 +wTempMoveNameBuffer:: ds MOVE_NAME_LENGTH NEXTU ; The name of the mon that is learning a move. @@ -1439,6 +1445,7 @@ wCriticalHitOrOHKO:: db wMoveMissed:: db +wBattleStatusData:: ; always 0 wPlayerStatsToDouble:: db ; always 0 @@ -1519,6 +1526,7 @@ wPlayerNumHits:: db ENDU ds 2 ; unused 2 bytes +wBattleStatusDataEnd:: ; non-zero when an item or move that allows escape from battle was used wEscapedFromBattle:: db @@ -1762,7 +1770,7 @@ wMoveNum:: db ; PureRGBnote: MOVED: itemlist is a temp list for indicating what items appear in a mart, the size was expanded to allow for bigger mart stocks. ; we reuse wMovesString for this expanded list since wMovesString is only used in battle. wItemList:: -wMovesString:: ds 56 +wMovesString:: ds NUM_MOVES * MOVE_NAME_LENGTH wUnusedCurMapTilesetCopy:: db @@ -2080,7 +2088,7 @@ wWestConnectionHeader:: map_connection_struct wWest wEastConnectionHeader:: map_connection_struct wEast ; sprite set for the current map (11 sprite picture ID's) -wSpriteSet:: ds 11 +wSpriteSet:: ds SPRITE_SET_LENGTH ; sprite set ID for the current map wSpriteSetID:: db @@ -2091,11 +2099,11 @@ wObjectDataPointerTemp:: dw ; the tile shown outside the boundaries of the map wMapBackgroundTile:: db -; number of warps in current map (up to 32) +; number of warps in current map (up to MAX_WARP_EVENTS) wNumberOfWarps:: db ; current map warp entries -wWarpEntries:: ds 32 * 4 ; Y, X, warp ID, map ID +wWarpEntries:: ds MAX_WARP_EVENTS * 4 ; Y, X, warp ID, map ID ; if $ff, the player's coordinates are not updated when entering the map wDestinationWarpID:: db @@ -2131,13 +2139,13 @@ wBoxItems:: ds PC_ITEM_CAPACITY * 2 + 1 ; now holds 60 items ENDU ;;;;;;;;;; -; number of signs in the current map (up to 16) +; number of signs in the current map (up to MAX_BG_EVENTS) wNumSigns:: db -wSignCoords:: ds 16 * 2 ; Y, X -wSignTextIDs:: ds 16 +wSignCoords:: ds MAX_BG_EVENTS * 2 ; Y, X +wSignTextIDs:: ds MAX_BG_EVENTS -; number of sprites on the current map (up to 16) +; number of sprites on the current map (up to MAX_OBJECT_EVENTS) wNumSprites:: db ; these two variables track the X and Y offset in blocks from the last special warp used @@ -2145,8 +2153,8 @@ wNumSprites:: db wYOffsetSinceLastSpecialWarp:: db wXOffsetSinceLastSpecialWarp:: db -wMapSpriteData:: ds 16 * 2 ; movement byte 2, text ID -wMapSpriteExtraData:: ds 16 * 2 ; trainer class/item ID, trainer set ID +wMapSpriteData:: ds MAX_OBJECT_EVENTS * 2 ; movement byte 2, text ID +wMapSpriteExtraData:: ds MAX_OBJECT_EVENTS * 2 ; trainer class/item ID, trainer set ID ; map height in 2x2 meta-tiles wCurrentMapHeight2:: db @@ -2544,12 +2552,12 @@ wEventFlags:: flag_array NUM_EVENTS UNION wGrassRate:: db -wGrassMons:: ds 10 * 2 +wGrassMons:: ds WILDDATA_LENGTH - 1 ds 8 wWaterRate:: db -wWaterMons:: ds 10 * 2 +wWaterMons:: ds WILDDATA_LENGTH - 1 NEXTU ; linked game's trainer name diff --git a/rgbdscheck.asm b/rgbdscheck.asm index 9b215d5d9f..0ba32a2982 100644 --- a/rgbdscheck.asm +++ b/rgbdscheck.asm @@ -1,6 +1,6 @@ -IF !DEF(__RGBDS_MAJOR__) || !DEF(__RGBDS_MINOR__) || !DEF(__RGBDS_PATCH__) - fail "pokered requires rgbds v0.9.2 or newer." +IF !DEF(__RGBDS_MAJOR__) + fail "pokered requires rgbds v1.0.0 or newer." ENDC -IF __RGBDS_MAJOR__ == 0 && (__RGBDS_MINOR__ < 9 || (__RGBDS_MINOR__ == 9 && __RGBDS_PATCH__ < 2)) - fail "pokered requires rgbds v0.9.2 or newer." +IF __RGBDS_MAJOR__ < 1 + fail "pokered requires rgbds v1.0.0 or newer." ENDC diff --git a/scripts/AgathasRoom.asm b/scripts/AgathasRoom.asm index d7f599991c..558b3a6233 100644 --- a/scripts/AgathasRoom.asm +++ b/scripts/AgathasRoom.asm @@ -39,7 +39,7 @@ AgathasRoom_ScriptPointers: AgathaScriptWalkIntoRoom: ; Walk six steps upward. ld hl, wSimulatedJoypadStatesEnd - ld a, D_UP + ld a, PAD_UP ld [hli], a ld [hli], a ld [hli], a @@ -72,7 +72,7 @@ AgathasRoomDefaultScript: ld a, TEXT_AGATHASROOM_AGATHA_DONT_RUN_AWAY ldh [hTextID], a call DisplayTextID - ld a, D_UP + ld a, PAD_UP ld [wSimulatedJoypadStatesEnd], a ld a, $1 ld [wSimulatedJoypadStatesIndex], a diff --git a/scripts/BikeShop.asm b/scripts/BikeShop.asm index e537a6fbf2..bc182fd206 100644 --- a/scripts/BikeShop.asm +++ b/scripts/BikeShop.asm @@ -52,7 +52,7 @@ BikeShopClerkText: xor a ld [wCurrentMenuItem], a ld [wLastMenuItem], a - ld a, A_BUTTON | B_BUTTON + ld a, PAD_A | PAD_B ld [wMenuWatchedKeys], a ld a, $1 ld [wMaxMenuItem], a @@ -75,7 +75,7 @@ BikeShopClerkText: ld hl, BikeShopClerkDoYouLikeItText rst _PrintText call HandleMenuInput - bit BIT_B_BUTTON, a + bit B_PAD_B, a jr nz, .cancel ld hl, wStatusFlags5 res BIT_NO_TEXT_DELAY, [hl] diff --git a/scripts/BillsGarden.asm b/scripts/BillsGarden.asm index 875fdb86f3..a23ea330df 100644 --- a/scripts/BillsGarden.asm +++ b/scripts/BillsGarden.asm @@ -357,7 +357,7 @@ BillsGardenBlueText: call SaveScreenTilesToBuffer1 ld hl, BillsGardenBlueThanks - ld b, A_BUTTON + ld b, PAD_A call DisplayMultiChoiceTextBox call LoadScreenTilesFromBuffer1 ld a, [wCurrentMenuItem] diff --git a/scripts/BillsHouse.asm b/scripts/BillsHouse.asm index 2b3ece76bb..4cd604bc03 100644 --- a/scripts/BillsHouse.asm +++ b/scripts/BillsHouse.asm @@ -80,7 +80,7 @@ BillsHousePokemonEntersMachineScript: BillsHouseBillExitsMachineScript: CheckEvent EVENT_USED_CELL_SEPARATOR_ON_BILL ret z - ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_CTRL_PAD ld [wJoyIgnore], a ld a, BILLSHOUSE_BILL_SS_TICKET ld [wSpriteIndex], a @@ -100,13 +100,13 @@ BillsHouseBillExitsMachineScript: rst _DelayFrames ld a, BILLSHOUSE_BILL_SS_TICKET ldh [hSpriteIndex], a - ld de, BillExitMachineMovement + ld de, .BillExitMachineMovement call MoveSprite ld a, SCRIPT_BILLSHOUSE_CLEANUP ld [wBillsHouseCurScript], a ret -BillExitMachineMovement: +.BillExitMachineMovement: db NPC_MOVEMENT_DOWN db NPC_MOVEMENT_RIGHT db NPC_MOVEMENT_RIGHT diff --git a/scripts/BrunosRoom.asm b/scripts/BrunosRoom.asm index 81994e0961..49dafadc16 100644 --- a/scripts/BrunosRoom.asm +++ b/scripts/BrunosRoom.asm @@ -39,7 +39,7 @@ BrunosRoom_ScriptPointers: BrunoScriptWalkIntoRoom: ; Walk six steps upward. ld hl, wSimulatedJoypadStatesEnd - ld a, D_UP + ld a, PAD_UP ld [hli], a ld [hli], a ld [hli], a @@ -72,7 +72,7 @@ BrunosRoomDefaultScript: ld a, TEXT_BRUNOSROOM_BRUNO_DONT_RUN_AWAY ldh [hTextID], a call DisplayTextID ; "Don't run away!" - ld a, D_UP + ld a, PAD_UP ld [wSimulatedJoypadStatesEnd], a ld a, $1 ld [wSimulatedJoypadStatesIndex], a diff --git a/scripts/CeladonGym.asm b/scripts/CeladonGym.asm index f530e4cd54..c74018fb42 100644 --- a/scripts/CeladonGym.asm +++ b/scripts/CeladonGym.asm @@ -70,7 +70,7 @@ CeladonGymErikaPostBattleScript: ld a, [wIsInBattle] cp $ff jp z, CeladonGymResetScripts - ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_CTRL_PAD ld [wJoyIgnore], a CeladonGymReceiveTM21: diff --git a/scripts/CeladonMart1F.asm b/scripts/CeladonMart1F.asm index d38dc3d583..ec90d18b25 100644 --- a/scripts/CeladonMart1F.asm +++ b/scripts/CeladonMart1F.asm @@ -81,7 +81,7 @@ CeladonMart1PhoneRight: ld hl, CeladonMart1CallWhoQuestion rst _PrintText ld hl, CeladonMartPhoneList - ld b, A_BUTTON | B_BUTTON + ld b, PAD_A | PAD_B call DisplayMultiChoiceTextBox jr nz, .no @@ -248,7 +248,7 @@ CallHome: ld hl, CeladonMartCallMomText rst _PrintText ld hl, CeladonMartCallMomQuestion1 - ld b, A_BUTTON + ld b, PAD_A call DisplayMultiChoiceTextBox call LoadScreenTilesFromBuffer2 ld a, [wCurrentMenuItem] @@ -262,7 +262,7 @@ CallHome: ld hl, CeladonMartCallMomHomesickText rst _PrintText ld hl, CeladonMartCallMomQuestion3 - ld b, A_BUTTON + ld b, PAD_A call DisplayMultiChoiceTextBox call LoadScreenTilesFromBuffer2 ld a, [wCurrentMenuItem] @@ -281,7 +281,7 @@ CallHome: ld hl, CeladonMartCallMomBoredText rst _PrintText ld hl, CeladonMartCallMomQuestion2 - ld b, A_BUTTON + ld b, PAD_A call DisplayMultiChoiceTextBox call LoadScreenTilesFromBuffer2 ld a, [wCurrentMenuItem] @@ -294,7 +294,7 @@ CallHome: ld hl, CeladonMartCallMomGoodbyeText rst _PrintText ld hl, CeladonMartCallMomQuestion4 - ld b, A_BUTTON + ld b, PAD_A call DisplayMultiChoiceTextBox call LoadScreenTilesFromBuffer2 ld a, [wCurrentMenuItem] @@ -325,7 +325,7 @@ CallHome: ld a, [wNumSetBits] add NUMBER_CHAR_OFFSET ld [w2CharStringBuffer], a - ld a, "@" + ld a, '@' ld [w2CharStringBuffer + 1], a SetEvent EVENT_CALLED_DAD_WAITING ld hl, CeladonMartCallDadText2 @@ -449,7 +449,7 @@ CallOak: rst _PrintText ld hl, CeladonMartCallOakQuestion1 - ld b, A_BUTTON + ld b, PAD_A call DisplayMultiChoiceTextBox call LoadScreenTilesFromBuffer2 ld a, [wCurrentMenuItem] @@ -460,7 +460,7 @@ CallOak: .question2 rst _PrintText ld hl, CeladonMartCallOakQuestion2 - ld b, A_BUTTON + ld b, PAD_A call DisplayMultiChoiceTextBox call LoadScreenTilesFromBuffer2 ld a, [wCurrentMenuItem] diff --git a/scripts/CeladonMartRoof.asm b/scripts/CeladonMartRoof.asm index 38e1e6fff0..f96ffed2e4 100644 --- a/scripts/CeladonMartRoof.asm +++ b/scripts/CeladonMartRoof.asm @@ -50,7 +50,7 @@ CeladonMartRoofScript_GiveDrinkToGirl: rst _PrintText xor a ld [wCurrentMenuItem], a - ld a, A_BUTTON | B_BUTTON + ld a, PAD_A | PAD_B ld [wMenuWatchedKeys], a ld a, [wFilteredBagItemsCount] dec a @@ -74,7 +74,7 @@ CeladonMartRoofScript_GiveDrinkToGirl: ld hl, wStatusFlags5 res BIT_NO_TEXT_DELAY, [hl] call HandleMenuInput - bit BIT_B_BUTTON, a + bit B_PAD_B, a ret nz ld hl, wFilteredBagItems ld a, [wCurrentMenuItem] diff --git a/scripts/CeruleanBadgeHouse.asm b/scripts/CeruleanBadgeHouse.asm index 0a2246bc88..6688009b81 100644 --- a/scripts/CeruleanBadgeHouse.asm +++ b/scripts/CeruleanBadgeHouse.asm @@ -52,8 +52,8 @@ CeruleanBadgeHouseMiddleAgedManText: rst TextScriptEnd .BadgeItemList: - table_width 1 db NUM_BADGES ; # + table_width 1 db BOULDERBADGE db CASCADEBADGE db THUNDERBADGE @@ -62,8 +62,8 @@ CeruleanBadgeHouseMiddleAgedManText: db MARSHBADGE db VOLCANOBADGE db EARTHBADGE + assert_table_length NUM_BADGES db -1 ; end - assert_table_length NUM_BADGES + 2 .Text: text_far _CeruleanBadgeHouseMiddleAgedManText diff --git a/scripts/CeruleanCity.asm b/scripts/CeruleanCity.asm index f1b101dfc4..15dff7be5a 100644 --- a/scripts/CeruleanCity.asm +++ b/scripts/CeruleanCity.asm @@ -55,7 +55,7 @@ CeruleanCityRocketDefeatedScript: ld a, [wIsInBattle] cp $ff jp z, CeruleanCityClearScripts - ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_CTRL_PAD ld [wJoyIgnore], a SetEvent EVENT_BEAT_CERULEAN_ROCKET_THIEF ld a, TEXT_CERULEANCITY_ROCKET @@ -109,7 +109,7 @@ ENDC call PlayMusic xor a ldh [hJoyHeld], a - ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_CTRL_PAD ld [wJoyIgnore], a ld a, [wXCoord] cp 20 ; is the player standing on the right side of the bridge? @@ -197,7 +197,7 @@ CeruleanCityRivalDefeatedScript: cp $ff jp z, CeruleanCityClearScripts call CeruleanCityFaceRivalScript - ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_CTRL_PAD ld [wJoyIgnore], a SetEvent EVENT_BEAT_CERULEAN_RIVAL ld a, TEXT_CERULEANCITY_RIVAL diff --git a/scripts/CeruleanGym.asm b/scripts/CeruleanGym.asm index d815e6a497..98f0054088 100644 --- a/scripts/CeruleanGym.asm +++ b/scripts/CeruleanGym.asm @@ -25,7 +25,7 @@ CeruleanGymMistyPostBattleScript: ld a, [wIsInBattle] cp $ff jp z, CeruleanGymResetScripts - ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_CTRL_PAD ld [wJoyIgnore], a CeruleanGymReceiveTM11: diff --git a/scripts/ChampArena.asm b/scripts/ChampArena.asm index 0dd8f8a108..dcd46589a3 100644 --- a/scripts/ChampArena.asm +++ b/scripts/ChampArena.asm @@ -331,12 +331,12 @@ ChampArenaGetRemainingOpponentCount: cp 10 jr c, .lowerThan10 sub 10 - ld [hl], "1" + ld [hl], '1' inc hl .lowerThan10 add NUMBER_CHAR_OFFSET ld [hli], a - ld [hl], "@" + ld [hl], '@' ret ChampArenaAssistantText: @@ -441,13 +441,13 @@ ChampArenaAssistantText: text_end PlayerCenterFieldDirectionsLeft: - db D_DOWN + db PAD_DOWN PlayerCenterFieldDirectionsRight: - db D_DOWN - db D_DOWN - db D_LEFT - db D_LEFT - db D_DOWN + db PAD_DOWN + db PAD_DOWN + db PAD_LEFT + db PAD_LEFT + db PAD_DOWN db -1 ChampArenaIntroText: @@ -577,7 +577,7 @@ ReloadChallengerSprite: call CopyVideoData pop bc pop de - ld hl, LEN_2BPP_TILE * 12 ; 12 tiles + ld hl, 12 tiles add hl, de ; make hl now pointing to the walking tile data of the sprite that will replace's data ld d, h ld e, l @@ -707,7 +707,7 @@ ChampArenaStartBattleText: call SaveScreenTilesToBuffer2 pop hl ; hl will have which music option menu to use - ld b, A_BUTTON + ld b, PAD_A call DisplayMultiChoiceTextBox ld a, [wCurrentMenuItem] and a diff --git a/scripts/ChampionsRoom.asm b/scripts/ChampionsRoom.asm index d0bc1f9e4c..962aa1b3e1 100644 --- a/scripts/ChampionsRoom.asm +++ b/scripts/ChampionsRoom.asm @@ -25,7 +25,7 @@ ChampionsRoom_ScriptPointers: dw_const ChampionsRoomCleanupScript, SCRIPT_CHAMPIONSROOM_CLEANUP_SCRIPT ChampionsRoomPlayerEntersScript: - ld a, A_BUTTON | B_BUTTON | SELECT | START | D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_BUTTONS | PAD_CTRL_PAD ld [wJoyIgnore], a ld hl, wSimulatedJoypadStatesEnd ld de, RivalEntrance_RLEMovement @@ -38,9 +38,9 @@ ChampionsRoomPlayerEntersScript: ret RivalEntrance_RLEMovement: - db D_UP, 1 - db D_RIGHT, 1 - db D_UP, 3 + db PAD_UP, 1 + db PAD_RIGHT, 1 + db PAD_UP, 3 db -1 ; end ChampionsRoomRivalReadyToBattleScript: @@ -82,7 +82,7 @@ ChampionsRoomRivalDefeatedScript: jp z, ResetRivalScript call UpdateSprites SetEvent EVENT_BEAT_CHAMPION_RIVAL - ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_CTRL_PAD ld [wJoyIgnore], a ld a, TEXT_CHAMPIONSROOM_RIVAL ldh [hTextID], a @@ -191,7 +191,7 @@ ChampionsRoomOakExitsScript: ret ChampionsRoomPlayerFollowsOakScript: - ld a, A_BUTTON | B_BUTTON | SELECT | START | D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_BUTTONS | PAD_CTRL_PAD ld [wJoyIgnore], a ld hl, wSimulatedJoypadStatesEnd ld de, WalkToHallOfFame_RLEMovement @@ -204,8 +204,8 @@ ChampionsRoomPlayerFollowsOakScript: ret WalkToHallOfFame_RLEMovement: - db D_UP, 4 - db D_LEFT, 1 + db PAD_UP, 4 + db PAD_LEFT, 1 db -1 ; end ChampionsRoomCleanupScript: @@ -218,10 +218,10 @@ ChampionsRoomCleanupScript: ret ChampionsRoom_DisplayTextID_AllowABSelectStart: - ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_CTRL_PAD ld [wJoyIgnore], a call DisplayTextID - ld a, A_BUTTON | B_BUTTON | SELECT | START | D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_BUTTONS | PAD_CTRL_PAD ld [wJoyIgnore], a ret diff --git a/scripts/CinnabarGym.asm b/scripts/CinnabarGym.asm index e47e18bb8b..3b6c0401e0 100644 --- a/scripts/CinnabarGym.asm +++ b/scripts/CinnabarGym.asm @@ -129,7 +129,7 @@ CinnabarGymBlainePostBattleScript: ld a, [wIsInBattle] cp $ff jp z, CinnabarGymResetScripts - ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_CTRL_PAD ld [wJoyIgnore], a ; fallthrough CinnabarGymReceiveTM38: diff --git a/scripts/CinnabarIsland.asm b/scripts/CinnabarIsland.asm index 75e447f29f..64890354c7 100644 --- a/scripts/CinnabarIsland.asm +++ b/scripts/CinnabarIsland.asm @@ -31,7 +31,7 @@ CinnabarIslandDefaultScript: ldh [hJoyHeld], a ld a, $1 ld [wSimulatedJoypadStatesIndex], a - ld a, D_DOWN + ld a, PAD_DOWN ld [wSimulatedJoypadStatesEnd], a call StartSimulatingJoypadStates xor a diff --git a/scripts/CinnabarLabFossilRoom.asm b/scripts/CinnabarLabFossilRoom.asm index 1a49d156df..129b583f0d 100644 --- a/scripts/CinnabarLabFossilRoom.asm +++ b/scripts/CinnabarLabFossilRoom.asm @@ -271,7 +271,7 @@ ShowBeforeAfterImages: .waitForButtonPress call JoypadLowSensitivity ldh a, [hJoy5] - and A_BUTTON | B_BUTTON + and PAD_A | PAD_B jr z, .waitForButtonPress ld hl, wStatusFlags2 diff --git a/scripts/CinnabarVolcano.asm b/scripts/CinnabarVolcano.asm index 4c85c98ff1..a6a2c9df76 100644 --- a/scripts/CinnabarVolcano.asm +++ b/scripts/CinnabarVolcano.asm @@ -65,7 +65,7 @@ CinnabarVolcanoOnMapLoad: .next jp CheckIfVolcanoBattleOccurred .forceWalkUp - ld d, D_UP + ld d, PAD_UP callfar ForceStepFromDoor jr .doneForcedWalk .forceWalkDown @@ -362,20 +362,20 @@ CheckForceSurfDirection:: ret nz lda_coord 8, 9 ; tile below player cp $24 ; down flowing lava - ld b, D_DOWN + ld b, PAD_DOWN jr z, .forceInput ld a, [wYCoord] cp 53 ret c ; prevents other direction lava currents from functioning when not on bottom floor lda_coord 8, 9 ; tile below player cp $23 ; right flowing lava - ld b, D_RIGHT + ld b, PAD_RIGHT jr z, .forceInput cp $25 ; left flowing lava - ld b, D_LEFT + ld b, PAD_LEFT jr z, .forceInput cp $26 ; up flowing lava - ld b, D_UP + ld b, PAD_UP ret nz .forceInput ld a, b @@ -450,7 +450,7 @@ ReplaceLadderAndWalkUp: SetEvent EVENT_HOLE_DRILL_FINISHED ld a, 1 ld [wOverworldAnimationCooldown], a - ld d, D_UP + ld d, PAD_UP jpfar ForceStepFromDoor DrilledFloor2Ladder: @@ -1268,7 +1268,7 @@ CinnabarVolcanoBombRockDoneText: ; wall breaks open, the whole side ld hl, .uhoh rst _PrintText - ld a, D_UP + ld a, PAD_UP ld b, 4 ld hl, wSimulatedJoypadStatesIndex ld [hl], b @@ -1941,7 +1941,7 @@ CheckForceTalkToProspector:: ld a, [wYCoord] cp 16 ret nz - ld a, D_UP + ld a, PAD_UP ld b, 4 ld hl, wSimulatedJoypadStatesIndex ld [hl], b @@ -1953,7 +1953,7 @@ CheckForceTalkToProspector:: ld a, [wXCoord] cp 22 jr nz, .movePlayer - ld a, D_RIGHT + ld a, PAD_RIGHT ld [hl], a ld hl, wSimulatedJoypadStatesIndex inc [hl] @@ -1990,7 +1990,7 @@ CheckForceTalkToProspector:: ret nz ; force player to avoid west area until finishing volcano ld hl, wSimulatedJoypadStatesEnd - ld [hl], D_DOWN + ld [hl], PAD_DOWN inc hl ld [hl], -1 ld a, 1 @@ -2368,8 +2368,8 @@ PlayerQuickSpinFacings: MoveSpriteButAllowAOrBPress: call MoveSprite ld hl, wJoyIgnore - res BIT_B_BUTTON, [hl] - res BIT_A_BUTTON, [hl] + res B_PAD_B, [hl] + res B_PAD_A, [hl] ret ; bc = picture id backup in wMapSpriteOriginalPictureIDs diff --git a/scripts/CinnabarVolcanoWest.asm b/scripts/CinnabarVolcanoWest.asm index b072c525ef..0594f87b4d 100644 --- a/scripts/CinnabarVolcanoWest.asm +++ b/scripts/CinnabarVolcanoWest.asm @@ -44,7 +44,7 @@ CinnabarVolcanoWestMagmar1Text: cp MAGMAR ld hl, .wrongMon jr nz, .printDone - ld d, D_RIGHT + ld d, PAD_RIGHT callfar ForceStepFromDoor SetEvent EVENT_MAGMAR_TRANSFORMATION ld hl, .lavaBath diff --git a/scripts/Colosseum.asm b/scripts/Colosseum.asm index 4aaa42367f..1489fd2c79 100644 --- a/scripts/Colosseum.asm +++ b/scripts/Colosseum.asm @@ -1,4 +1,5 @@ Colosseum_Script: + ASSERT TRADECENTER_OPPONENT == COLOSSEUM_OPPONENT jp TradeCenter_Script Colosseum_TextPointers: diff --git a/scripts/Daycare.asm b/scripts/Daycare.asm index f2de537e78..c0956874ac 100644 --- a/scripts/Daycare.asm +++ b/scripts/Daycare.asm @@ -173,7 +173,7 @@ DaycareGentlemanText: ld a, [wPartyCount] dec a push af - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH push bc ld hl, wPartyMon1Moves call AddNTimes @@ -190,7 +190,7 @@ DaycareGentlemanText: call AddNTimes ld d, h ld e, l - ld bc, wPartyMon1MaxHP - wPartyMon1HP + ld bc, MON_MAXHP - MON_HP add hl, bc ld a, [hli] ld [de], a diff --git a/scripts/DiamondMine.asm b/scripts/DiamondMine.asm index d8076f79c8..aa85c208b4 100644 --- a/scripts/DiamondMine.asm +++ b/scripts/DiamondMine.asm @@ -543,11 +543,11 @@ DiamondMineLoadPlayerDirections: jr .loop PlayerWalkDownHoleDirectionsBelow: - db D_UP + db PAD_UP PlayerWalkDownHoleDirectionsRight: - db D_UP - db D_UP - db D_LEFT + db PAD_UP + db PAD_UP + db PAD_LEFT db -1 DiamondMineBoombox: diff --git a/scripts/DiglettsCave.asm b/scripts/DiglettsCave.asm index 28ccf0635a..2e6a1a1f91 100644 --- a/scripts/DiglettsCave.asm +++ b/scripts/DiglettsCave.asm @@ -26,7 +26,7 @@ DiglettsCaveCheckStandingOnWarp: call .standingOnBottomWarp jr nz, .loadDigletts SetEvent EVENT_FOUND_SECRET_DIG_TUNNEL - ld d, D_UP + ld d, PAD_UP jpfar ForceStepFromDoor .checkStandingOnWarp call .standingOnBottomWarp diff --git a/scripts/FightingDojo.asm b/scripts/FightingDojo.asm index 9c81c410c7..519eb9083c 100644 --- a/scripts/FightingDojo.asm +++ b/scripts/FightingDojo.asm @@ -67,7 +67,7 @@ FightingDojoKarateMasterPostBattleScript: ldh [hSpriteFacingDirection], a call SetSpriteFacingDirectionAndDelay .already_facing - ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_CTRL_PAD ld [wJoyIgnore], a SetEventRange EVENT_BEAT_KARATE_MASTER, EVENT_BEAT_FIGHTING_DOJO_TRAINER_3 ld a, TEXT_FIGHTINGDOJO_KARATE_MASTER_I_WILL_GIVE_YOU_A_POKEMON diff --git a/scripts/FuchsiaGym.asm b/scripts/FuchsiaGym.asm index fd0b11495f..1c541ef125 100644 --- a/scripts/FuchsiaGym.asm +++ b/scripts/FuchsiaGym.asm @@ -25,7 +25,7 @@ FuchsiaGymKogaPostBattleScript: ld a, [wIsInBattle] cp $ff jp z, FuchsiaGymResetScripts - ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_CTRL_PAD ld [wJoyIgnore], a ; fallthrough FuchsiaGymReceiveTM06: diff --git a/scripts/FuchsiaTreeDeleterHouse.asm b/scripts/FuchsiaTreeDeleterHouse.asm index f557a3408c..3d4574ea35 100644 --- a/scripts/FuchsiaTreeDeleterHouse.asm +++ b/scripts/FuchsiaTreeDeleterHouse.asm @@ -52,7 +52,7 @@ TreeDeleterText: ld [wTextBoxID], a call DisplayTextBoxID ld hl, TreeDeleterOptions - ld b, A_BUTTON | B_BUTTON + ld b, PAD_A | PAD_B call DisplayMultiChoiceTextBoxNoMenuReset jr nz, .goodbye ld hl, TextPointers_TreeDelete diff --git a/scripts/GameCorner.asm b/scripts/GameCorner.asm index 52da860351..1e0a197b8d 100644 --- a/scripts/GameCorner.asm +++ b/scripts/GameCorner.asm @@ -55,7 +55,7 @@ GameCornerRocketBattleScript: ld a, [wIsInBattle] cp $ff jp z, GameCornerReenterMapAfterPlayerLoss - ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_CTRL_PAD ld [wJoyIgnore], a ld a, TEXT_GAMECORNER_ROCKET_AFTER_BATTLE ldh [hTextID], a diff --git a/scripts/HallOfFame.asm b/scripts/HallOfFame.asm index cbed58245f..6c1abe4708 100644 --- a/scripts/HallOfFame.asm +++ b/scripts/HallOfFame.asm @@ -46,7 +46,7 @@ HallOfFameResetEventsAndSaveScript: ld [wHallOfFameCurScript], a ld a, PALLET_TOWN ld [wLastBlackoutMap], a - farcall SaveSAVtoSRAM + farcall SaveGameData ld b, 5 .delayLoop ld c, 600 / 5 @@ -57,7 +57,7 @@ HallOfFameResetEventsAndSaveScript: jp Init HallOfFameDefaultScript: - ld a, A_BUTTON | B_BUTTON | SELECT | START | D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_BUTTONS | PAD_CTRL_PAD ld [wJoyIgnore], a ld hl, wSimulatedJoypadStatesEnd ld de, HallOfFameEntryMovement @@ -70,7 +70,7 @@ HallOfFameDefaultScript: ret HallOfFameEntryMovement: - db D_UP, 5 + db PAD_UP, 5 db -1 ; end HallOfFameOakCongratulationsScript: @@ -93,7 +93,7 @@ HallOfFameOakCongratulationsScript: ld a, TEXT_HALLOFFAME_OAK ldh [hTextID], a call DisplayTextID - ld a, A_BUTTON | B_BUTTON | SELECT | START | D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_BUTTONS | PAD_CTRL_PAD ld [wJoyIgnore], a ;;;;;;;;;; PureRGBnote: ADDED: hide the third pokeball in oak's lab because he's using it in battle now ld a, [wPlayerStarter] diff --git a/scripts/LancesRoom.asm b/scripts/LancesRoom.asm index f3a3aa02a5..c6de41d9d0 100644 --- a/scripts/LancesRoom.asm +++ b/scripts/LancesRoom.asm @@ -100,7 +100,7 @@ LancesRoomLanceEndBattleScript: WalkToLance: ; Moves the player down the hallway to Lance's room. - ld a, A_BUTTON | B_BUTTON | SELECT | START | D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_BUTTONS | PAD_CTRL_PAD ld [wJoyIgnore], a ld hl, wSimulatedJoypadStatesEnd ld de, WalkToLance_RLEList @@ -114,10 +114,10 @@ WalkToLance: ret WalkToLance_RLEList: - db D_UP, 12 - db D_LEFT, 12 - db D_DOWN, 7 - db D_LEFT, 6 + db PAD_UP, 12 + db PAD_LEFT, 12 + db PAD_DOWN, 7 + db PAD_LEFT, 6 db -1 ; end LancesRoomPlayerIsMovingScript: diff --git a/scripts/LoreleisRoom.asm b/scripts/LoreleisRoom.asm index 30bb553c1e..afd19ea85a 100644 --- a/scripts/LoreleisRoom.asm +++ b/scripts/LoreleisRoom.asm @@ -41,7 +41,7 @@ LoreleisRoom_ScriptPointers: LoreleiScriptWalkIntoRoom: ; Walk six steps upward. ld hl, wSimulatedJoypadStatesEnd - ld a, D_UP + ld a, PAD_UP ld [hli], a ld [hli], a ld [hli], a @@ -74,7 +74,7 @@ LoreleisRoomDefaultScript: ld a, TEXT_LORELEISROOM_DONT_RUN_AWAY ldh [hTextID], a call DisplayTextID ; "Don't run away!" - ld a, D_UP + ld a, PAD_UP ld [wSimulatedJoypadStatesEnd], a ld a, $1 ld [wSimulatedJoypadStatesIndex], a diff --git a/scripts/MtMoonB2F.asm b/scripts/MtMoonB2F.asm index 63d995152e..1c5ac332b6 100644 --- a/scripts/MtMoonB2F.asm +++ b/scripts/MtMoonB2F.asm @@ -133,7 +133,7 @@ MtMoonB2FSuperNerdTakesOtherFossilScript: ld a, [wStatusFlags5] bit BIT_SCRIPTED_NPC_MOVEMENT, a ret nz - ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_CTRL_PAD ld [wJoyIgnore], a ld a, $1 ld [wDoNotWaitForButtonPressAfterDisplayingText], a diff --git a/scripts/Museum1F.asm b/scripts/Museum1F.asm index 6aaaaa9b6d..e0458282fe 100644 --- a/scripts/Museum1F.asm +++ b/scripts/Museum1F.asm @@ -112,7 +112,7 @@ Museum1FScientist1Text: rst _PrintText ld a, $1 ld [wSimulatedJoypadStatesIndex], a - ld a, D_DOWN + ld a, PAD_DOWN ld [wSimulatedJoypadStatesEnd], a call StartSimulatingJoypadStates call UpdateSprites diff --git a/scripts/NameRatersHouse.asm b/scripts/NameRatersHouse.asm index 14513bc1a3..020ed14e7a 100644 --- a/scripts/NameRatersHouse.asm +++ b/scripts/NameRatersHouse.asm @@ -19,7 +19,7 @@ NameRatersHouseYesNoScript: ; call .check_match_loop ; jr c, .no_match ; ld hl, wPartyMon1OTID -; ld bc, wPartyMon2 - wPartyMon1 +; ld bc, PARTYMON_STRUCT_LENGTH ; ld a, [wWhichPokemon] ; call AddNTimes ; ld de, wPlayerID diff --git a/scripts/OaksLab.asm b/scripts/OaksLab.asm index dfd22c03d3..f9cd4d6562 100644 --- a/scripts/OaksLab.asm +++ b/scripts/OaksLab.asm @@ -102,7 +102,7 @@ OaksLabPlayerEntersLabScript: ret PlayerEntryMovementRLE: - db D_UP, 8 + db PAD_UP, 8 db -1 ; end OaksLabFollowedOakScript: @@ -126,7 +126,7 @@ OaksLabFollowedOakScript: ret OaksLabOakChooseMonSpeechScript: - ld a, SELECT | START | D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_SELECT | PAD_START | PAD_CTRL_PAD ld [wJoyIgnore], a ld a, TEXT_OAKSLAB_RIVAL_FED_UP_WITH_WAITING ldh [hTextID], a @@ -171,7 +171,7 @@ OaksLabPlayerDontGoAwayScript: call DisplayTextID ld a, $1 ld [wSimulatedJoypadStatesIndex], a - ld a, D_UP + ld a, PAD_UP ld [wSimulatedJoypadStatesEnd], a call StartSimulatingJoypadStates ld a, PLAYER_DIR_UP @@ -293,7 +293,7 @@ OaksLabRivalChoosesStarterScript: ld a, [wStatusFlags5] bit BIT_SCRIPTED_NPC_MOVEMENT, a ret nz - ld a, SELECT | START | D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_SELECT | PAD_START | PAD_CTRL_PAD ld [wJoyIgnore], a ld a, OAKSLAB_RIVAL ldh [hSpriteIndex], a @@ -404,7 +404,7 @@ OaksLabRivalStartBattleScript: ret OaksLabRivalEndBattleScript: - ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_CTRL_PAD ld [wJoyIgnore], a ld a, PLAYER_DIR_UP ld [wPlayerMovingDirection], a @@ -542,7 +542,7 @@ OaksLabOakGivesPokedexScript: ret nz call EnableAutoTextBoxDrawing call PlayDefaultMusic - ld a, SELECT | START | D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_SELECT | PAD_START | PAD_CTRL_PAD ld [wJoyIgnore], a call OaksLabRivalFaceUpOakFaceDownScript ld a, TEXT_OAKSLAB_RIVAL_WHAT_DID_YOU_CALL_ME_FOR @@ -910,7 +910,7 @@ OaksLabMonChoiceMenu: call AddPartyMon ld hl, wStatusFlags4 set BIT_GOT_STARTER, [hl] - ld a, SELECT | START | D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_SELECT | PAD_START | PAD_CTRL_PAD ld [wJoyIgnore], a ld a, SCRIPT_OAKSLAB_CHOSE_STARTER_SCRIPT ld [wOaksLabCurScript], a diff --git a/scripts/PalletTown.asm b/scripts/PalletTown.asm index ff1a054282..17a2ab0a61 100644 --- a/scripts/PalletTown.asm +++ b/scripts/PalletTown.asm @@ -38,7 +38,7 @@ ENDC ld c, a ld a, MUSIC_MEET_PROF_OAK ; "oak appears" music call PlayMusic - ld a, SELECT | START | D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_SELECT | PAD_START | PAD_CTRL_PAD ld [wJoyIgnore], a SetEvent EVENT_OAK_APPEARED_IN_PALLET @@ -53,7 +53,7 @@ PalletTownOakHeyWaitScript: ld a, TEXT_PALLETTOWN_OAK ldh [hTextID], a call DisplayTextID - ld a, A_BUTTON | B_BUTTON | SELECT | START | D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_BUTTONS | PAD_CTRL_PAD ld [wJoyIgnore], a ld a, HS_PALLET_TOWN_OAK ld [wMissableObjectIndex], a @@ -86,7 +86,7 @@ PalletTownOakWalksToPlayerScript: ld a, PALLETTOWN_OAK ldh [hSpriteIndex], a call MoveSprite - ld a, A_BUTTON | B_BUTTON | SELECT | START | D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_BUTTONS | PAD_CTRL_PAD ld [wJoyIgnore], a ; trigger the next script @@ -102,13 +102,13 @@ PalletTownOakNotSafeComeWithMeScript: ld [wSpritePlayerStateData1FacingDirection], a ld a, TRUE ld [wOakWalkedToPlayer], a - ld a, SELECT | START | D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_SELECT | PAD_START | PAD_CTRL_PAD ld [wJoyIgnore], a ld a, TEXT_PALLETTOWN_OAK ldh [hTextID], a call DisplayTextID ; set up movement script that causes the player to follow Oak to his lab - ld a, A_BUTTON | B_BUTTON | SELECT | START | D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_BUTTONS | PAD_CTRL_PAD ld [wJoyIgnore], a ld a, PALLETTOWN_OAK ld [wSpriteIndex], a diff --git a/scripts/PewterCity.asm b/scripts/PewterCity.asm index 9d37439ed8..1aeb2a2124 100644 --- a/scripts/PewterCity.asm +++ b/scripts/PewterCity.asm @@ -29,7 +29,7 @@ ENDC ld hl, PewterCityPlayerLeavingEastCoords call ArePlayerCoordsInArray ret nc - ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_CTRL_PAD ld [wJoyIgnore], a ld a, TEXT_PEWTERCITY_YOUNGSTER ldh [hTextID], a diff --git a/scripts/PewterGym.asm b/scripts/PewterGym.asm index c7ff7f0a38..c8b1127c94 100644 --- a/scripts/PewterGym.asm +++ b/scripts/PewterGym.asm @@ -25,7 +25,7 @@ PewterGymBrockPostBattle: ld a, [wIsInBattle] cp $ff jp z, PewterGymResetScripts - ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_CTRL_PAD ld [wJoyIgnore], a ; fallthrough PewterGymScriptReceiveTM34: diff --git a/scripts/PokemonMansionB1F.asm b/scripts/PokemonMansionB1F.asm index 287745c938..442d2eca8b 100644 --- a/scripts/PokemonMansionB1F.asm +++ b/scripts/PokemonMansionB1F.asm @@ -21,29 +21,29 @@ MansionB1FCheckReplaceSwitchDoorBlocks: CheckEvent EVENT_MANSION_SWITCH_ON jr nz, .switchTurnedOn ld a, $e - ld bc, $80d + lb bc, 8, 13 call Mansion2ReplaceBlock ld a, $e - ld bc, $b06 + lb bc, 11, 6 call Mansion2ReplaceBlock ld a, $5f - ld bc, $304 + lb bc, 3, 4 call Mansion2ReplaceBlock ld a, $54 - ld bc, $808 + lb bc, 8, 8 jp Mansion2ReplaceBlock .switchTurnedOn ld a, $2d - ld bc, $80d + lb bc, 8, 13 call Mansion2ReplaceBlock ld a, $5f - ld bc, $b06 + lb bc, 11, 6 call Mansion2ReplaceBlock ld a, $e - ld bc, $304 + lb bc, 3, 4 call Mansion2ReplaceBlock ld a, $e - ld bc, $808 + lb bc, 8, 8 jp Mansion2ReplaceBlock UnlockLab:: diff --git a/scripts/PokemonTower2F.asm b/scripts/PokemonTower2F.asm index c350f721bb..9bcded7b46 100644 --- a/scripts/PokemonTower2F.asm +++ b/scripts/PokemonTower2F.asm @@ -111,7 +111,7 @@ PokemonTower2FPlayerMovingScript: cp 5 jr nz, .doneMoving .startMoving - ld d, D_LEFT + ld d, PAD_LEFT jpfar ForceStepFromDoor .doneMoving ld a, PLAYER_DIR_LEFT @@ -132,7 +132,7 @@ PokemonTower2FDefeatedRivalScript: ld a, [wIsInBattle] cp $ff jp z, PokemonTower2FResetRivalEncounter - ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_CTRL_PAD ld [wJoyIgnore], a SetEvent EVENT_BEAT_POKEMON_TOWER_RIVAL ld a, TEXT_POKEMONTOWER2F_RIVAL diff --git a/scripts/PokemonTower5F.asm b/scripts/PokemonTower5F.asm index 05d368891e..34e174e2fd 100644 --- a/scripts/PokemonTower5F.asm +++ b/scripts/PokemonTower5F.asm @@ -26,7 +26,7 @@ PokemonTower5FDefaultScript: ret nz xor a ldh [hJoyHeld], a - ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_CTRL_PAD ld [wJoyIgnore], a ld hl, wStatusFlags4 set BIT_NO_BATTLES, [hl] diff --git a/scripts/PokemonTower6F.asm b/scripts/PokemonTower6F.asm index 54d9c5590a..f96b6681cc 100644 --- a/scripts/PokemonTower6F.asm +++ b/scripts/PokemonTower6F.asm @@ -54,13 +54,13 @@ PokemonTower6FMarowakBattleScript: ld a, [wIsInBattle] cp $ff jp z, PokemonTower6FSetDefaultScript - ld a, A_BUTTON | B_BUTTON | SELECT | START | D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_BUTTONS | PAD_CTRL_PAD ld [wJoyIgnore], a ld a, [wStatusFlags3] bit BIT_TALKED_TO_TRAINER, a ret nz call UpdateSprites - ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_CTRL_PAD ld [wJoyIgnore], a ;;;;;;;;;; PureRGBnote: ADDED: ghost marowak can be caught and the event will complete if you do so ld hl, wBattleFunctionalFlags @@ -91,7 +91,7 @@ PokemonTower6FMarowakBattleScript: .did_not_defeat ld a, $1 ld [wSimulatedJoypadStatesIndex], a - ld a, D_RIGHT + ld a, PAD_RIGHT ld [wSimulatedJoypadStatesEnd], a xor a ld [wSpritePlayerStateData2MovementByte1], a diff --git a/scripts/PokemonTower7F.asm b/scripts/PokemonTower7F.asm index c6883634cc..afead464c7 100644 --- a/scripts/PokemonTower7F.asm +++ b/scripts/PokemonTower7F.asm @@ -29,7 +29,7 @@ PokemonTower7FEndBattleScript: cp $ff jp z, PokemonTower7FSetDefaultScript call EndTrainerBattle - ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_CTRL_PAD ld [wJoyIgnore], a ld a, [wSpriteIndex] ldh [hSpriteIndex], a @@ -65,7 +65,7 @@ PokemonTower7FHideNPCScript: ret PokemonTower7FWarpToMrFujiHouseScript: - ld a, A_BUTTON | B_BUTTON | SELECT | START | D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_BUTTONS | PAD_CTRL_PAD ld [wJoyIgnore], a ld a, SPRITE_FACING_UP ld [wSpritePlayerStateData1FacingDirection], a diff --git a/scripts/PokemonTowerB1F.asm b/scripts/PokemonTowerB1F.asm index ee47ab3d56..bb60239d1e 100644 --- a/scripts/PokemonTowerB1F.asm +++ b/scripts/PokemonTowerB1F.asm @@ -166,13 +166,13 @@ PokemonTowerB1FOnMapLoad: ld a, DOWN ld [wMapSpriteData + ((POKEMONTOWERB1F_GHOST_MAROWAK - 1) * 2)], a SetEvent EVENT_CATACOMBS_SPRITE_WALKING - ld a, D_LEFT + ld a, PAD_LEFT ld hl, wSimulatedJoypadStatesEnd - ld [hl], D_UP + ld [hl], PAD_UP inc hl ld [hli], a ld [hli], a - ld [hl], D_DOWN + ld [hl], PAD_DOWN inc hl ld [hl], -1 ld a, 4 @@ -995,7 +995,7 @@ PokemonTowerB1FWaitForNPCWalk: ld a, TEXT_POKEMONTOWERB1F_CUBONE ldh [hTextID], a call DisplayTextID - ld a, D_RIGHT + ld a, PAD_RIGHT ld hl, wSimulatedJoypadStatesEnd ld [hli], a ld [hl], -1 @@ -1013,7 +1013,7 @@ PokemonTowerB1FWaitForNPCWalk: cp 5 ret nz SetEvent EVENT_CATACOMBS_SPRITE_WALKING - ld a, D_UP + ld a, PAD_UP ld hl, wSimulatedJoypadStatesEnd ld [hli], a ld [hli], a diff --git a/scripts/PowerPlant.asm b/scripts/PowerPlant.asm index 91abf4c135..96931147c4 100644 --- a/scripts/PowerPlant.asm +++ b/scripts/PowerPlant.asm @@ -210,7 +210,7 @@ CopyMenuSpritesVideoData: call CopyVideoData pop bc pop hl - ld a, LEN_2BPP_TILE * 4 + ld a, 4 tiles ld d, 0 ld e, a add hl, de @@ -218,7 +218,7 @@ CopyMenuSpritesVideoData: ld e, l pop hl push de - ld a, LEN_2BPP_TILE * 2 + ld a, 2 tiles ld d, 0 ld e, a add hl, de @@ -586,7 +586,7 @@ PowerPlantMagnet:: cp SCRIPT_MAGNETON_SUPERCHARGE ret nz ; make player walk down one step - ld a, D_DOWN + ld a, PAD_DOWN ld hl, wSimulatedJoypadStatesEnd ld [hli], a ld [hl], -1 diff --git a/scripts/PowerPlantRoof.asm b/scripts/PowerPlantRoof.asm index 6d7e3819e7..b4959ed2fd 100644 --- a/scripts/PowerPlantRoof.asm +++ b/scripts/PowerPlantRoof.asm @@ -342,7 +342,7 @@ PowerPlantDrawLightning: cp c ld a, $C1 jr z, .load - ld a, " " ; empty + ld a, ' ' ; empty .load ld [hli], a dec b diff --git a/scripts/RocketHideoutB4F.asm b/scripts/RocketHideoutB4F.asm index 3fb4d0d48a..6d80da46a5 100644 --- a/scripts/RocketHideoutB4F.asm +++ b/scripts/RocketHideoutB4F.asm @@ -79,7 +79,7 @@ RocketHideoutB4FBeatGiovanniScript: jp z, RocketHideoutB4FSetDefaultScript call PlayGiovanniMusic call UpdateSprites - ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_CTRL_PAD ld [wJoyIgnore], a SetEvent EVENT_BEAT_ROCKET_HIDEOUT_GIOVANNI ld a, TEXT_ROCKETHIDEOUTB4F_GIOVANNI_HOPE_WE_MEET_AGAIN diff --git a/scripts/Route16Gate1F.asm b/scripts/Route16Gate1F.asm index a42ddab6a0..7741ffa432 100644 --- a/scripts/Route16Gate1F.asm +++ b/scripts/Route16Gate1F.asm @@ -32,7 +32,7 @@ Route16Gate1FDefaultScript: ld [wSimulatedJoypadStatesIndex], a ld b, $0 ld c, a - ld a, D_UP + ld a, PAD_UP ld hl, wSimulatedJoypadStatesEnd call FillMemory call StartSimulatingJoypadStates @@ -55,7 +55,7 @@ Route16Gate1FPlayerMovingUpScript: ld a, [wSimulatedJoypadStatesIndex] and a ret nz - ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_CTRL_PAD ld [wJoyIgnore], a Route16Gate1FGuardScript: @@ -64,7 +64,7 @@ Route16Gate1FGuardScript: call DisplayTextID ld a, $1 ld [wSimulatedJoypadStatesIndex], a - ld a, D_RIGHT + ld a, PAD_RIGHT ld [wSimulatedJoypadStatesEnd], a call StartSimulatingJoypadStates ld a, SCRIPT_ROUTE16GATE1F_PLAYER_MOVING_RIGHT diff --git a/scripts/Route18Gate1F.asm b/scripts/Route18Gate1F.asm index 70694ea77e..ed2c5accf8 100644 --- a/scripts/Route18Gate1F.asm +++ b/scripts/Route18Gate1F.asm @@ -32,7 +32,7 @@ Route18Gate1FDefaultScript: ld [wSimulatedJoypadStatesIndex], a ld b, 0 ld c, a - ld a, D_UP + ld a, PAD_UP ld hl, wSimulatedJoypadStatesEnd call FillMemory call StartSimulatingJoypadStates @@ -55,7 +55,7 @@ Route18Gate1FPlayerMovingUpScript: ld a, [wSimulatedJoypadStatesIndex] and a ret nz - ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_CTRL_PAD ld [wJoyIgnore], a Route18Gate1FGuardScript: @@ -64,7 +64,7 @@ Route18Gate1FGuardScript: call DisplayTextID ld a, $1 ld [wSimulatedJoypadStatesIndex], a - ld a, D_RIGHT + ld a, PAD_RIGHT ld [wSimulatedJoypadStatesEnd], a call StartSimulatingJoypadStates ld a, SCRIPT_ROUTE18GATE1F_PLAYER_MOVING_RIGHT diff --git a/scripts/Route22.asm b/scripts/Route22.asm index d9a8314d2f..f19ba778e3 100644 --- a/scripts/Route22.asm +++ b/scripts/Route22.asm @@ -50,7 +50,7 @@ Route22DefaultScript: ld [wSavedCoordIndex], a xor a ldh [hJoyHeld], a - ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_CTRL_PAD ld [wJoyIgnore], a ld a, PLAYER_DIR_LEFT ld [wPlayerMovingDirection], a @@ -150,7 +150,7 @@ Route22Rival1AfterBattleScript: ld a, ROUTE22_RIVAL1 ldh [hSpriteIndex], a call SetSpriteFacingDirectionAndDelay - ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_CTRL_PAD ld [wJoyIgnore], a SetEvent EVENT_BEAT_ROUTE22_RIVAL_1ST_BATTLE ld a, TEXT_ROUTE22_RIVAL1 @@ -315,7 +315,7 @@ Route22Rival2AfterBattleScript: .set_rival_facing_direction ldh [hSpriteFacingDirection], a call SetSpriteFacingDirectionAndDelay - ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_CTRL_PAD ld [wJoyIgnore], a SetEvent EVENT_BEAT_ROUTE22_RIVAL_2ND_BATTLE ld a, TEXT_ROUTE22_RIVAL2 diff --git a/scripts/Route22Gate.asm b/scripts/Route22Gate.asm index a66b6cf849..e906562fe2 100644 --- a/scripts/Route22Gate.asm +++ b/scripts/Route22Gate.asm @@ -36,7 +36,7 @@ Route22GateScriptCoords: Route22GateMovePlayerDownScript: ld a, $1 ld [wSimulatedJoypadStatesIndex], a - ld a, D_DOWN + ld a, PAD_DOWN ld [wSimulatedJoypadStatesEnd], a ld [wSpritePlayerStateData1FacingDirection], a ld [wJoyIgnore], a diff --git a/scripts/Route23.asm b/scripts/Route23.asm index 4798576fe3..9dc965c495 100644 --- a/scripts/Route23.asm +++ b/scripts/Route23.asm @@ -86,7 +86,7 @@ Route23CopyBadgeTextScript: ld a, [hli] ld [de], a inc de - cp "@" + cp '@' jr nz, .copyTextLoop ret @@ -123,7 +123,7 @@ CascadeBadgeText: Route23MovePlayerDownScript: ld a, $1 ld [wSimulatedJoypadStatesIndex], a - ld a, D_DOWN + ld a, PAD_DOWN ld [wSimulatedJoypadStatesEnd], a xor a ld [wSpritePlayerStateData1FacingDirection], a diff --git a/scripts/Route24.asm b/scripts/Route24.asm index 6b8db55fd9..16eb471b9d 100644 --- a/scripts/Route24.asm +++ b/scripts/Route24.asm @@ -39,7 +39,7 @@ ENDC call DisplayTextID CheckAndResetEvent EVENT_NUGGET_REWARD_AVAILABLE ret z - ld a, D_DOWN + ld a, PAD_DOWN ld [wSimulatedJoypadStatesEnd], a ld a, $1 ld [wSimulatedJoypadStatesIndex], a @@ -68,7 +68,7 @@ Route24AfterRocketBattleScript: cp $ff jp z, Route24SetDefaultScript call UpdateSprites - ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_CTRL_PAD ld [wJoyIgnore], a SetEvent EVENT_BEAT_ROUTE24_ROCKET ld a, TEXT_ROUTE24_COOLTRAINER_M1 diff --git a/scripts/Route5Gate.asm b/scripts/Route5Gate.asm index 6060b5cb7e..a9c5b34913 100644 --- a/scripts/Route5Gate.asm +++ b/scripts/Route5Gate.asm @@ -10,7 +10,7 @@ Route5Gate_ScriptPointers: dw_const Route5GatePlayerMovingScript, SCRIPT_ROUTE5GATE_PLAYER_MOVING Route5GateMovePlayerUpScript: - ld a, D_UP + ld a, PAD_UP ld [wSimulatedJoypadStatesEnd], a ld a, $1 ld [wSimulatedJoypadStatesIndex], a diff --git a/scripts/Route6Gate.asm b/scripts/Route6Gate.asm index 7d481371c5..36448938ce 100644 --- a/scripts/Route6Gate.asm +++ b/scripts/Route6Gate.asm @@ -56,7 +56,7 @@ Route6GatePlayerMovingScript: Route6GateMovePlayerDownScript: ld hl, wStatusFlags5 set BIT_SCRIPTED_MOVEMENT_STATE, [hl] - ld a, D_DOWN + ld a, PAD_DOWN ld [wSimulatedJoypadStatesEnd], a ld a, $1 ld [wSimulatedJoypadStatesIndex], a diff --git a/scripts/Route7Gate.asm b/scripts/Route7Gate.asm index 77a8b002d0..b512b373ce 100644 --- a/scripts/Route7Gate.asm +++ b/scripts/Route7Gate.asm @@ -12,7 +12,7 @@ Route7Gate_ScriptPointers: Route7GateMovePlayerLeftScript: ld hl, wStatusFlags5 set BIT_SCRIPTED_MOVEMENT_STATE, [hl] - ld a, D_LEFT + ld a, PAD_LEFT ld [wSimulatedJoypadStatesEnd], a ld a, $1 ld [wSimulatedJoypadStatesIndex], a diff --git a/scripts/Route8Gate.asm b/scripts/Route8Gate.asm index 44e94a0c8d..533e45f62b 100644 --- a/scripts/Route8Gate.asm +++ b/scripts/Route8Gate.asm @@ -12,7 +12,7 @@ Route8Gate_ScriptPointers: Route8GateMovePlayerRightScript: ld hl, wStatusFlags5 set BIT_SCRIPTED_MOVEMENT_STATE, [hl] - ld a, D_RIGHT + ld a, PAD_RIGHT ld [wSimulatedJoypadStatesEnd], a ld a, $1 ld [wSimulatedJoypadStatesIndex], a diff --git a/scripts/SSAnne2F.asm b/scripts/SSAnne2F.asm index f7f751b6f6..7d1858a4e4 100644 --- a/scripts/SSAnne2F.asm +++ b/scripts/SSAnne2F.asm @@ -43,7 +43,7 @@ ENDC call SetSpriteMovementBytesToFF xor a ldh [hJoyHeld], a - ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_CTRL_PAD ld [wJoyIgnore], a ldh a, [hSavedCoordIndex] cp $2 @@ -116,7 +116,7 @@ SSAnne2FRivalAfterBattleScript: cp $ff jp z, SSAnne2FResetScripts call SSAnne2FSetFacingDirectionScript - ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_CTRL_PAD ld [wJoyIgnore], a ld a, TEXT_SSANNE2F_RIVAL_CUT_MASTER ldh [hTextID], a diff --git a/scripts/SSAnneKitchen.asm b/scripts/SSAnneKitchen.asm index 92587fa1a9..fc4a3ddb8f 100644 --- a/scripts/SSAnneKitchen.asm +++ b/scripts/SSAnneKitchen.asm @@ -144,7 +144,7 @@ SSAnneKitchenWaiterText: rst _PrintText call SaveScreenTilesToBuffer2 ld hl, SSAnneFoodMenu - ld b, A_BUTTON | B_BUTTON + ld b, PAD_A | PAD_B call DisplayMultiChoiceTextBox call LoadScreenTilesFromBuffer2 call Delay3 diff --git a/scripts/SafariZoneGate.asm b/scripts/SafariZoneGate.asm index ecd0040862..d798d39d94 100644 --- a/scripts/SafariZoneGate.asm +++ b/scripts/SafariZoneGate.asm @@ -25,7 +25,7 @@ SafariZoneGateDefaultScript: ld a, TEXT_SAFARIZONEGATE_SAFARI_ZONE_WORKER1_1 ldh [hTextID], a call DisplayTextID - ld a, A_BUTTON | B_BUTTON | SELECT | START | D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_BUTTONS | PAD_CTRL_PAD ld [wJoyIgnore], a xor a ldh [hJoyHeld], a @@ -38,10 +38,10 @@ SafariZoneGateDefaultScript: ld [wSafariZoneGateCurScript], a ret .player_not_next_to_worker - ld a, D_RIGHT + ld a, PAD_RIGHT ld c, 1 call SafariZoneEntranceAutoWalk - ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_CTRL_PAD ld [wJoyIgnore], a ld a, SCRIPT_SAFARIZONEGATE_PLAYER_MOVING_RIGHT ld [wSafariZoneGateCurScript], a @@ -63,7 +63,7 @@ SafariZoneGateWouldYouLikeToJoinScript: ld a, TEXT_SAFARIZONEGATE_SAFARI_ZONE_WORKER1_WOULD_YOU_LIKE_TO_JOIN ldh [hTextID], a call DisplayTextID - ld a, A_BUTTON | B_BUTTON | SELECT | START | D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_BUTTONS | PAD_CTRL_PAD ld [wJoyIgnore], a ret @@ -83,7 +83,7 @@ SafariZoneGateLeavingSafariScript: jr z, .leaving_early ResetEventReuseHL EVENT_IN_SAFARI_ZONE call UpdateSprites - ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_CTRL_PAD ld [wJoyIgnore], a ld a, [wSafariType] and a @@ -102,7 +102,7 @@ SafariZoneGateLeavingSafariScript: call DisplayTextID xor a ld [wNumRangersLeft], a - ld a, D_DOWN + ld a, PAD_DOWN ld c, $2 call SafariZoneEntranceAutoWalk ld a, SCRIPT_SAFARIZONEGATE_7 @@ -113,7 +113,7 @@ SafariZoneGateLeavingSafariScript: call DisplayTextID xor a ld [wNumSafariBalls], a - ld a, D_DOWN + ld a, PAD_DOWN ld c, 3 call SafariZoneEntranceAutoWalk ld a, SCRIPT_SAFARIZONEGATE_PLAYER_MOVING_DOWN @@ -149,7 +149,7 @@ SafariZoneGateScript7: ld a, $9 ldh [hTextID], a call DisplayTextID - ld a, D_DOWN + ld a, PAD_DOWN ld c, $1 call SafariZoneEntranceAutoWalk ld a, SCRIPT_SAFARIZONEGATE_PLAYER_MOVING_DOWN @@ -252,7 +252,7 @@ SafariZoneGateSafariZoneWorker1WouldYouLikeToJoinText: rst _PrintText call AskGameType jr c, .PleaseComeAgain ; if we cancelled, don't continue - ld a, D_UP + ld a, PAD_UP ld c, 3 call SafariZoneEntranceAutoWalk SetEvent EVENT_IN_SAFARI_ZONE @@ -265,7 +265,7 @@ SafariZoneGateSafariZoneWorker1WouldYouLikeToJoinText: ld hl, PleaseComeAgainText rst _PrintText .CantPayWalkDown - ld a, D_DOWN + ld a, PAD_DOWN ld c, 1 call SafariZoneEntranceAutoWalk ld a, SCRIPT_SAFARIZONEGATE_PLAYER_MOVING_DOWN @@ -292,7 +292,7 @@ SafariZoneGateSafariZoneWorker1LeavingEarlyText: rst _PrintText xor a ld [wSpritePlayerStateData1FacingDirection], a - ld a, D_DOWN + ld a, PAD_DOWN ld c, 3 call SafariZoneEntranceAutoWalk ResetEvents EVENT_SAFARI_GAME_OVER, EVENT_IN_SAFARI_ZONE @@ -304,7 +304,7 @@ SafariZoneGateSafariZoneWorker1LeavingEarlyText: rst _PrintText ld a, SPRITE_FACING_UP ld [wSpritePlayerStateData1FacingDirection], a - ld a, D_UP + ld a, PAD_UP ld c, 1 call SafariZoneEntranceAutoWalk ld a, SCRIPT_SAFARIZONEGATE_LEAVING_SAFARI @@ -376,7 +376,7 @@ AskGameType: ld hl, SafariZoneEntranceWhatGame rst _PrintText ld hl, SafariTypeOptions - ld b, A_BUTTON | B_BUTTON + ld b, PAD_A | PAD_B call DisplayMultiChoiceTextBox jr nz, .goodbye ld hl, TextPointers_SafariGames @@ -576,7 +576,7 @@ AskGameTypeExplanation: ld hl, SafariZoneHelp rst _PrintText ld hl, SafariTypeOptions - ld b, A_BUTTON | B_BUTTON + ld b, PAD_A | PAD_B call DisplayMultiChoiceTextBox jr nz, .goodbye ld hl, TextPointers_SafariExplanations diff --git a/scripts/SaffronGym.asm b/scripts/SaffronGym.asm index 4b204cb6f6..156e8b685e 100644 --- a/scripts/SaffronGym.asm +++ b/scripts/SaffronGym.asm @@ -25,7 +25,7 @@ SaffronGymSabrinaPostBattle: ld a, [wIsInBattle] cp $ff jp z, SaffronGymResetScripts - ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_CTRL_PAD ld [wJoyIgnore], a SaffronGymSabrinaReceiveTM46Script: diff --git a/scripts/SeafoamIslands1F.asm b/scripts/SeafoamIslands1F.asm index dc0a881810..43f9cd5be4 100644 --- a/scripts/SeafoamIslands1F.asm +++ b/scripts/SeafoamIslands1F.asm @@ -162,7 +162,7 @@ DragonairUnderWaterEventAreaScript: cp 36 jr z, .upOne ld hl, wSimulatedJoypadStatesEnd - ld a, D_UP + ld a, PAD_UP ld [hli], a ld [hli], a ld a, [wBattleResult] @@ -170,14 +170,14 @@ DragonairUnderWaterEventAreaScript: ld b, 2 jr z, .caught inc b - ld [hl], D_LEFT + ld [hl], PAD_LEFT inc hl .caught ld a, b ld [wSimulatedJoypadStatesIndex], a jp StartSimulatingJoypadStates .upOne - ld d, D_UP + ld d, PAD_UP jpfar ForceStepFromDoor .forceWalkDown SetEvent EVENT_DRAGONAIR_EVENT_FOUGHT_CLOYSTER_ONCE diff --git a/scripts/SeafoamIslandsB3F.asm b/scripts/SeafoamIslandsB3F.asm index e5aecff3c4..e6a509cb7d 100644 --- a/scripts/SeafoamIslandsB3F.asm +++ b/scripts/SeafoamIslandsB3F.asm @@ -94,13 +94,13 @@ SeafoamIslandsB3FDefaultScript: SeafoamIslandsCurrents: lda_coord 8, 9 ; tile below player cp $30 - ld b, D_UP + ld b, PAD_UP jr z, .forceInput cp $3B - ld b, D_RIGHT + ld b, PAD_RIGHT jr z, .forceInput cp $42 - ld b, D_DOWN + ld b, PAD_DOWN jr z, .forceInput and a ret diff --git a/scripts/SeafoamIslandsB4F.asm b/scripts/SeafoamIslandsB4F.asm index ac66fa4486..ab69b40614 100644 --- a/scripts/SeafoamIslandsB4F.asm +++ b/scripts/SeafoamIslandsB4F.asm @@ -369,7 +369,7 @@ SeafoamIslandsB4FDragonairEventStartScript: ldh [hTextID], a call DisplayTextID ; add more "downs" to the surf auto movement - ld a, D_DOWN + ld a, PAD_DOWN ld hl, wSimulatedJoypadStatesEnd + 1 ld [hli], a ld [hli], a diff --git a/scripts/SecretLab.asm b/scripts/SecretLab.asm index 285f1a9ba4..4731c1ee89 100644 --- a/scripts/SecretLab.asm +++ b/scripts/SecretLab.asm @@ -77,7 +77,7 @@ ReplaceDoor: .upDoorCheck cp 16 ret nz - ld d, D_UP + ld d, PAD_UP jpfar ForceStepFromDoor .clearPassword xor a @@ -136,7 +136,7 @@ CheckOpponentWalkIn: set BIT_SCRIPTED_MOVEMENT_STATE, [hl] ld a, 3 ld [wSimulatedJoypadStatesIndex], a - ld a, D_UP + ld a, PAD_UP ld b, 3 ld hl, wSimulatedJoypadStatesEnd .loop @@ -146,10 +146,10 @@ CheckOpponentWalkIn: ld a, [wXCoord] cp 4 jr z, .done - ld c, D_RIGHT + ld c, PAD_RIGHT ld d, a jr c, .right - ld c, D_LEFT + ld c, PAD_LEFT sub 4 jr .loop2 .right @@ -447,10 +447,10 @@ CheckPasswordCorrect: ret PlayerMoveToDoor:: ; these happen in reverse order - db D_LEFT - db D_LEFT - db D_LEFT - db D_DOWN + db PAD_LEFT + db PAD_LEFT + db PAD_LEFT + db PAD_DOWN StoreNoteToPassword: pop af @@ -831,7 +831,7 @@ SecretLabMewtwoMachineText: jr nz, .startTransform ld a, 6 ld [wSimulatedJoypadStatesIndex], a - ld a, D_LEFT + ld a, PAD_LEFT ld de, wSimulatedJoypadStatesEnd + 5 ld [de], a .startTransform @@ -842,11 +842,11 @@ SecretLabMewtwoMachineText: rst TextScriptEnd PlayerMewtwoTransformMoveScript:: ; these happen in reverse order - db D_LEFT - db D_DOWN - db D_DOWN - db D_UP - db D_LEFT + db PAD_LEFT + db PAD_DOWN + db PAD_DOWN + db PAD_UP + db PAD_LEFT SecretLabMewtwoMachineText1: text_far _SecretLabMewtwoMachineText diff --git a/scripts/SilphCo11F.asm b/scripts/SilphCo11F.asm index e43e485277..5567611075 100644 --- a/scripts/SilphCo11F.asm +++ b/scripts/SilphCo11F.asm @@ -196,7 +196,7 @@ SilphCo11FDefaultScript: ld [wSavedCoordIndex], a xor a ldh [hJoyHeld], a - ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_CTRL_PAD ld [wJoyIgnore], a ld a, TEXT_SILPHCO11F_GIOVANNI ldh [hTextID], a @@ -251,7 +251,7 @@ SilphCo11FGiovanniAfterBattleScript: res BIT_MAP_LOADED_AFTER_BATTLE, [hl] call GBFadeInFromWhite ; PureRGBnote: ADDED: since trainer instantly talks to us after battle we need to fade back in here callfar PlayGiovanniMusic - ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_RIGHT | PAD_LEFT | PAD_UP | PAD_DOWN ld [wJoyIgnore], a ld a, TEXT_SILPHCO11F_GIOVANNI_YOU_RUINED_OUR_PLANS ldh [hTextID], a diff --git a/scripts/SilphCo1F.asm b/scripts/SilphCo1F.asm index bc6dbeddb2..83c3cd87db 100644 --- a/scripts/SilphCo1F.asm +++ b/scripts/SilphCo1F.asm @@ -190,7 +190,7 @@ SaffronAbandonedBuildingRocket1Text: ld hl, .password rst _PrintText ld hl, RocketPasswordMenu - ld b, A_BUTTON | B_BUTTON + ld b, PAD_A | PAD_B call DisplayMultiChoiceTextBox push af call LoadScreenTilesFromBuffer2 @@ -209,7 +209,7 @@ SaffronAbandonedBuildingRocket1Text: .failedPrint rst _PrintText .failed - ld a, D_RIGHT + ld a, PAD_RIGHT ld hl, wSimulatedJoypadStatesEnd ld [hli], a ld [hli], a @@ -270,7 +270,7 @@ SaffronAbandonedBuildingHeliumPipe:: CheckEvent EVENT_FLOATING_WEEZING_ANIMATION ret z ; make player walk down one step - ld a, D_DOWN + ld a, PAD_DOWN ld hl, wSimulatedJoypadStatesEnd ld [hli], a ld [hl], -1 diff --git a/scripts/SilphCo7F.asm b/scripts/SilphCo7F.asm index 6440c97d86..4da0789761 100644 --- a/scripts/SilphCo7F.asm +++ b/scripts/SilphCo7F.asm @@ -150,7 +150,7 @@ SilphCo7FDefaultScript: jp nc, CheckFightingMapTrainers xor a ldh [hJoyHeld], a - ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_CTRL_PAD ld [wJoyIgnore], a ld a, PLAYER_DIR_DOWN ld [wPlayerMovingDirection], a @@ -223,7 +223,7 @@ SilphCo7FRivalAfterBattleScript: ld a, [wIsInBattle] cp $ff jp z, SilphCo7FSetDefaultScript - ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_CTRL_PAD ld [wJoyIgnore], a SetEvent EVENT_BEAT_SILPH_CO_RIVAL ld a, PLAYER_DIR_DOWN diff --git a/scripts/VermilionCity.asm b/scripts/VermilionCity.asm index 30fae0cd2c..05571e98ff 100644 --- a/scripts/VermilionCity.asm +++ b/scripts/VermilionCity.asm @@ -74,7 +74,7 @@ VermilionCityDefaultScript: and a ret nz .ship_departed - ld a, D_UP + ld a, PAD_UP ld [wSimulatedJoypadStatesEnd], a ld a, $1 ld [wSimulatedJoypadStatesIndex], a @@ -96,9 +96,9 @@ VermilionCityPlayerAllowedToPassScript: ret VermilionCityPlayerExitShipScript: - ld a, A_BUTTON | B_BUTTON | SELECT | START | D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_BUTTONS | PAD_CTRL_PAD ld [wJoyIgnore], a - ld a, D_UP + ld a, PAD_UP ld [wSimulatedJoypadStatesEnd], a ld [wSimulatedJoypadStatesEnd + 1], a ld a, 2 diff --git a/scripts/VermilionDock.asm b/scripts/VermilionDock.asm index ff7287f792..f15b13fe52 100644 --- a/scripts/VermilionDock.asm +++ b/scripts/VermilionDock.asm @@ -20,7 +20,7 @@ VermilionDock_Script: ld hl, wStatusFlags5 set BIT_SCRIPTED_MOVEMENT_STATE, [hl] ld hl, wSimulatedJoypadStatesEnd - ld a, D_UP + ld a, PAD_UP ld [hli], a ld [hli], a ld [hl], a @@ -72,7 +72,7 @@ VermilionDockSSAnneLeavesScript: ld [wSpritePlayerStateData1ImageIndex], a ld c, 120 rst _DelayFrames - ld b, $9c + ld b, HIGH(vBGMap1) call CopyScreenTileBufferToVRAM hlcoord 0, 10 ld bc, SCREEN_WIDTH * 6 @@ -151,7 +151,7 @@ VermilionDock_AnimSmokePuffDriftRight: ld a, [wSSAnneSmokeDriftAmount] swap a ld c, a - ld de, 4 + ld de, OBJ_SIZE .drift_loop inc [hl] inc [hl] @@ -178,10 +178,10 @@ VermilionDock_EmitSmokePuff: VermilionDockOAMBlock: ; tile ID, attributes - db $fc, $10 - db $fd, $10 - db $fe, $10 - db $ff, $10 + db $fc, OAM_PAL1 + db $fd, OAM_PAL1 + db $fe, OAM_PAL1 + db $ff, OAM_PAL1 VermilionDock_SyncScrollWithLY: ld h, d @@ -305,7 +305,7 @@ TruckCheck: set BIT_CUR_MAP_USED_ELEVATOR, [hl] ; wait until the next time the player presses left ret z ldh a, [hJoyHeld] - bit BIT_D_LEFT, a ; is player pressing left + bit B_PAD_LEFT, a ; is player pressing left ret z res BIT_CUR_MAP_USED_ELEVATOR, [hl] ld a, $ff diff --git a/scripts/VermilionGym.asm b/scripts/VermilionGym.asm index 0071953904..2296e0a9ec 100644 --- a/scripts/VermilionGym.asm +++ b/scripts/VermilionGym.asm @@ -49,7 +49,7 @@ VermilionGymLTSurgeAfterBattleScript: ld a, [wIsInBattle] cp $ff ; did we lose? jp z, VermilionGymResetScripts - ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_CTRL_PAD ld [wJoyIgnore], a VermilionGymLTSurgeReceiveTM24Script: diff --git a/scripts/ViridianCity.asm b/scripts/ViridianCity.asm index 963a215a5f..947196d427 100644 --- a/scripts/ViridianCity.asm +++ b/scripts/ViridianCity.asm @@ -123,7 +123,7 @@ ViridianCityMovePlayerDownScript: call StartSimulatingJoypadStates ld a, $1 ld [wSimulatedJoypadStatesIndex], a - ld a, D_DOWN + ld a, PAD_DOWN ld [wSimulatedJoypadStatesEnd], a xor a ld [wSpritePlayerStateData1FacingDirection], a diff --git a/scripts/ViridianGym.asm b/scripts/ViridianGym.asm index 49776a76a8..0d722bdf79 100644 --- a/scripts/ViridianGym.asm +++ b/scripts/ViridianGym.asm @@ -36,7 +36,7 @@ ViridianGymGiovanniPostBattle: ld a, [wIsInBattle] cp $ff jp z, ViridianGymResetScripts - ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN + ld a, PAD_CTRL_PAD ld [wJoyIgnore], a ; fallthrough ViridianGymReceiveTM27: diff --git a/scripts/ViridianMart.asm b/scripts/ViridianMart.asm index 4f9394bd2f..709d64ea0f 100644 --- a/scripts/ViridianMart.asm +++ b/scripts/ViridianMart.asm @@ -39,8 +39,8 @@ ViridianMartDefaultScript: ret .PlayerMovement: - db D_LEFT, 1 - db D_UP, 2 + db PAD_LEFT, 1 + db PAD_UP, 2 db -1 ; end ViridianMartOaksParcelScript: diff --git a/scripts/ViridianSchoolHouseB1F.asm b/scripts/ViridianSchoolHouseB1F.asm index a813cbdb6c..b0fa252a69 100644 --- a/scripts/ViridianSchoolHouseB1F.asm +++ b/scripts/ViridianSchoolHouseB1F.asm @@ -500,11 +500,11 @@ SchoolB1FNerdNotebook: ld [wListPointer], a ld a, h ld [wListPointer + 1], a - ld a, A_BUTTON | B_BUTTON + ld a, PAD_A | PAD_B ld [wMenuWatchedKeys], a callfar DisplayMultiChoiceMenu ldh a, [hJoy5] - bit BIT_B_BUTTON, a + bit B_PAD_B, a jr nz, .done ld hl, SchoolB1FNerdNotebookTextPointers ld a, [wCurrentMenuItem] @@ -646,7 +646,7 @@ SchoolB1FMovedexTest: DoMoveDexTestQuestion: inc hl inc hl - ld a, A_BUTTON + ld a, PAD_A ld [wMenuWatchedKeys], a push hl ld a, [hli] diff --git a/tools/make_patch.c b/tools/make_patch.c index 82b018fd83..0d874fdcbe 100644 --- a/tools/make_patch.c +++ b/tools/make_patch.c @@ -1,5 +1,5 @@ #define PROGRAM_NAME "make_patch" -#define USAGE_OPTS "values.sym patched.gbc original.gbc vc.patch.template vc.patch" +#define USAGE_OPTS "[--ignore addr:size] values.sym patched.gbc original.gbc vc.patch.template vc.patch" #include "common.h" @@ -127,7 +127,7 @@ struct Symbol *parse_symbols(const char *filename) { if (c == EOF || c == '\n' || c == '\r' || c == ';' || (state == SYM_NAME && (c == ' ' || c == '\t'))) { if (state == SYM_NAME) { // The symbol name has ended; append the buffered symbol - buffer_append(buffer, &(char []){'\0'}); + buffer_append(buffer, &(char){'\0'}); symbol_append(&symbols, buffer->data, bank, address); } // Skip to the next line, ignoring anything after the symbol value and name @@ -143,7 +143,7 @@ struct Symbol *parse_symbols(const char *filename) { // The symbol value or name has started; buffer its contents if (++state == SYM_NAME) { // The symbol name has started; parse the buffered value - buffer_append(buffer, &(char []){'\0'}); + buffer_append(buffer, &(char){'\0'}); parse_symbol_value(buffer->data, &bank, &address); } buffer->size = 0; @@ -349,7 +349,15 @@ void skip_to_next_line(FILE *restrict input, FILE *restrict output) { } } -struct Buffer *process_template(const char *template_filename, const char *patch_filename, FILE *restrict new_rom, FILE *restrict orig_rom, const struct Symbol *symbols) { +struct Buffer *process_template( + const char *template_filename, + const char *patch_filename, + FILE *restrict new_rom, + FILE *restrict orig_rom, + const struct Symbol *symbols, + unsigned int ignore_addr, + unsigned int ignore_size +) { FILE *input = xfopen(template_filename, 'r'); FILE *output = xfopen(patch_filename, 'w'); @@ -358,6 +366,11 @@ struct Buffer *process_template(const char *template_filename, const char *patch // The ROM checksum will always differ buffer_append(patches, &(struct Patch){0x14e, 2}); + // The ignored data will always differ + unsigned int rom_size = (unsigned int)xfsize("", orig_rom); + if (ignore_size > 0 && ignore_size <= rom_size && ignore_addr <= rom_size - ignore_size) { + buffer_append(patches, &(struct Patch){ignore_addr, ignore_size}); + } // Fill in the template const struct Symbol *current_hook = NULL; @@ -375,7 +388,7 @@ struct Buffer *process_template(const char *template_filename, const char *patch for (c = getc(input); c != EOF && c != '}'; c = getc(input)) { buffer_append(buffer, &c); } - buffer_append(buffer, &(char []){'\0'}); + buffer_append(buffer, &(char){'\0'}); // Interpret the command in the context of the current patch interpret_command(buffer->data, current_hook, symbols, patches, new_rom, orig_rom, output); break; @@ -404,7 +417,7 @@ struct Buffer *process_template(const char *template_filename, const char *patch buffer_append(buffer, &c); } } - buffer_append(buffer, &(char []){'\0'}); + buffer_append(buffer, &(char){'\0'}); // The current patch should have a corresponding ".VC_" label current_hook = symbol_find_cat(symbols, ".VC_", buffer->data); skip_to_next_line(input, output); @@ -458,19 +471,53 @@ bool verify_completeness(FILE *restrict orig_rom, FILE *restrict new_rom, struct } } +void parse_args(int argc, char *argv[], unsigned int *ignore_addr, unsigned int *ignore_size) { + struct option long_options[] = { + {"ignore", required_argument, 0, 'i'}, + {"help", no_argument, 0, 'h'}, + {0} + }; + for (int opt; (opt = getopt_long(argc, argv, "h", long_options)) != -1;) { + switch (opt) { + case 'i': { + char *colon = strchr(optarg, ':'); + if (colon) { + *colon++ = '\0'; + *ignore_addr = strtoul(optarg, NULL, 0); + *ignore_size = strtoul(colon, NULL, 0); + } else { + error_exit("Error: Invalid argument for '--ignore': \"%s\"\n", optarg); + } + break; + } + case 'h': + usage_exit(0); + break; + default: + usage_exit(1); + } + } +} + int main(int argc, char *argv[]) { - if (argc != 6) { + unsigned int ignore_addr = 0, ignore_size = 0; + + parse_args(argc, argv, &ignore_addr, &ignore_size); + + argc -= optind; + argv += optind; + if (argc != 5) { usage_exit(1); } - struct Symbol *symbols = parse_symbols(argv[1]); + struct Symbol *symbols = parse_symbols(argv[0]); - FILE *new_rom = xfopen(argv[2], 'r'); - FILE *orig_rom = xfopen(argv[3], 'r'); - struct Buffer *patches = process_template(argv[4], argv[5], new_rom, orig_rom, symbols); + FILE *new_rom = xfopen(argv[1], 'r'); + FILE *orig_rom = xfopen(argv[2], 'r'); + struct Buffer *patches = process_template(argv[3], argv[4], new_rom, orig_rom, symbols, ignore_addr, ignore_size); if (!verify_completeness(orig_rom, new_rom, patches)) { - fprintf(stderr, PROGRAM_NAME ": Warning: Not all ROM differences are defined by \"%s\"\n", argv[5]); + fprintf(stderr, PROGRAM_NAME ": Warning: Not all ROM differences are defined by \"%s\"\n", argv[4]); } symbol_free(symbols); diff --git a/vc/pokeblue.constants.asm b/vc/pokeblue.constants.asm index e55bcca0e9..1622a41d75 100644 --- a/vc/pokeblue.constants.asm +++ b/vc/pokeblue.constants.asm @@ -1,32 +1,32 @@ ; These are all the asm constants needed to make the blue_vc patch. ; [FPA 001 Begin] -EXPORT DEF M_CHAR EQU "M" -EXPORT DEF E_CHAR EQU "E" -EXPORT DEF G_CHAR EQU "G" -EXPORT DEF A_CHAR EQU "A" -EXPORT DEF P_CHAR EQU "P" -EXPORT DEF S_CHAR EQU "S" -EXPORT DEF L_CHAR EQU "L" -EXPORT DEF F_CHAR EQU "F" -EXPORT DEF X_CHAR EQU "X" +EXPORT DEF M_CHAR EQU 'M' +EXPORT DEF E_CHAR EQU 'E' +EXPORT DEF G_CHAR EQU 'G' +EXPORT DEF A_CHAR EQU 'A' +EXPORT DEF P_CHAR EQU 'P' +EXPORT DEF S_CHAR EQU 'S' +EXPORT DEF L_CHAR EQU 'L' +EXPORT DEF F_CHAR EQU 'F' +EXPORT DEF X_CHAR EQU 'X' EXPORT MEGA_PUNCH ; [FPA 001 End] EXPORT EXPLOSION ; [FPA 002 Begin] -EXPORT DEF U_CHAR EQU "U" -EXPORT DEF I_CHAR EQU "I" +EXPORT DEF U_CHAR EQU 'U' +EXPORT DEF I_CHAR EQU 'I' EXPORT GUILLOTINE ; [FPA 002 End] -EXPORT DEF K_CHAR EQU "K" +EXPORT DEF K_CHAR EQU 'K' EXPORT MEGA_KICK ; [FPA 004 Begin] -EXPORT DEF B_CHAR EQU "B" -EXPORT DEF Z_CHAR EQU "Z" +EXPORT DEF B_CHAR EQU 'B' +EXPORT DEF Z_CHAR EQU 'Z' EXPORT BLIZZARD ; [FPA 005 Begin] @@ -36,29 +36,29 @@ EXPORT BUBBLEBEAM EXPORT HYPER_BEAM ; [FPA 006 Begin] -EXPORT DEF H_CHAR EQU "H" -EXPORT DEF Y_CHAR EQU "Y" +EXPORT DEF H_CHAR EQU 'H' +EXPORT DEF Y_CHAR EQU 'Y' ; [FPA 007 Begin] -EXPORT DEF T_CHAR EQU "T" -EXPORT DEF N_CHAR EQU "N" +EXPORT DEF T_CHAR EQU 'T' +EXPORT DEF N_CHAR EQU 'N' EXPORT THUNDERBOLT ; [FPA 008 Begin] -EXPORT DEF R_CHAR EQU "R" +EXPORT DEF R_CHAR EQU 'R' EXPORT REFLECT ; [FPA 009 Begin] EXPORT SELFDESTRUCT ; [FPA 010 Begin] -EXPORT DEF D_CHAR EQU "D" +EXPORT DEF D_CHAR EQU 'D' EXPORT DREAM_EATER ; [FPA 011 Begin] -EXPORT DEF O_CHAR EQU "O" +EXPORT DEF O_CHAR EQU 'O' EXPORT SPORE ; [FPA 012 Begin] -EXPORT DEF C_CHAR EQU "C" +EXPORT DEF C_CHAR EQU 'C' EXPORT ROCK_SLIDE diff --git a/vc/pokered.constants.asm b/vc/pokered.constants.asm index aec40f11b0..a4b8ca2411 100644 --- a/vc/pokered.constants.asm +++ b/vc/pokered.constants.asm @@ -1,58 +1,58 @@ ; These are all the asm constants needed to make the red_vc patch. ; [FPA 001 Begin] -EXPORT DEF M_CHAR EQU "M" -EXPORT DEF E_CHAR EQU "E" -EXPORT DEF G_CHAR EQU "G" -EXPORT DEF A_CHAR EQU "A" -EXPORT DEF P_CHAR EQU "P" -EXPORT DEF S_CHAR EQU "S" -EXPORT DEF L_CHAR EQU "L" -EXPORT DEF F_CHAR EQU "F" -EXPORT DEF D_CHAR EQU "D" -EXPORT DEF X_CHAR EQU "X" +EXPORT DEF M_CHAR EQU 'M' +EXPORT DEF E_CHAR EQU 'E' +EXPORT DEF G_CHAR EQU 'G' +EXPORT DEF A_CHAR EQU 'A' +EXPORT DEF P_CHAR EQU 'P' +EXPORT DEF S_CHAR EQU 'S' +EXPORT DEF L_CHAR EQU 'L' +EXPORT DEF F_CHAR EQU 'F' +EXPORT DEF D_CHAR EQU 'D' +EXPORT DEF X_CHAR EQU 'X' EXPORT MEGA_PUNCH ; [FPA 002 Begin] -EXPORT DEF U_CHAR EQU "U" -EXPORT DEF I_CHAR EQU "I" +EXPORT DEF U_CHAR EQU 'U' +EXPORT DEF I_CHAR EQU 'I' EXPORT GUILLOTINE ; [FPA 003 Begin] -EXPORT DEF K_CHAR EQU "K" +EXPORT DEF K_CHAR EQU 'K' EXPORT MEGA_KICK ; [FPA 004 Begin] -EXPORT DEF B_CHAR EQU "B" +EXPORT DEF B_CHAR EQU 'B' EXPORT BUBBLEBEAM ; [FPA 005 Begin] -EXPORT DEF H_CHAR EQU "H" -EXPORT DEF Y_CHAR EQU "Y" +EXPORT DEF H_CHAR EQU 'H' +EXPORT DEF Y_CHAR EQU 'Y' EXPORT HYPER_BEAM ; [FPA 006 Begin] -EXPORT DEF T_CHAR EQU "T" -EXPORT DEF N_CHAR EQU "N" +EXPORT DEF T_CHAR EQU 'T' +EXPORT DEF N_CHAR EQU 'N' EXPORT THUNDERBOLT ; [FPA 007 Begin] -EXPORT DEF R_CHAR EQU "R" +EXPORT DEF R_CHAR EQU 'R' EXPORT REFLECT ; [FPA 008 Begin] EXPORT DREAM_EATER ; [FPA 008 End] -EXPORT DEF Z_CHAR EQU "Z" +EXPORT DEF Z_CHAR EQU 'Z' EXPORT BLIZZARD ; [FPA 009 Begin] -EXPORT DEF O_CHAR EQU "O" +EXPORT DEF O_CHAR EQU 'O' EXPORT SPORE ; [FPA 010 Begin] -EXPORT DEF C_CHAR EQU "C" +EXPORT DEF C_CHAR EQU 'C' EXPORT ROCK_SLIDE ; [FPA 010 End]