diff options
-rw-r--r-- | .travis.yml | 25 | ||||
-rw-r--r-- | Makefile | 87 | ||||
-rw-r--r-- | README.md | 45 | ||||
-rw-r--r-- | constants.asm | 1 | ||||
-rw-r--r-- | constants/icon_constants.asm | 35 | ||||
-rwxr-xr-x | constants/music_constants.asm | 2 | ||||
-rw-r--r-- | constants/pokedex_constants.asm | 6 | ||||
-rw-r--r-- | data/items/names.asm | 4 | ||||
-rw-r--r-- | data/pokemon/base_stats/kirinriki.inc | 4 | ||||
-rw-r--r-- | data/pokemon/menu_icons.asm | 256 | ||||
-rw-r--r-- | data/tileset_headers.asm | 5 | ||||
-rwxr-xr-x | engine/dumps/bank03.asm | 6 | ||||
-rw-r--r-- | engine/intro.asm (renamed from engine/Intro.asm) | 24 | ||||
-rw-r--r-- | engine/predef.asm | 4 | ||||
-rw-r--r-- | engine/title.asm | 9 | ||||
-rw-r--r-- | gfx.asm | 18 | ||||
-rw-r--r-- | gfx.py | 2 | ||||
-rw-r--r-- | home/audio.asm | 68 | ||||
-rw-r--r-- | home/bankswitch.asm | 12 | ||||
-rw-r--r-- | home/clear_sprites.asm | 10 | ||||
-rw-r--r-- | home/copy.asm | 20 | ||||
-rw-r--r-- | home/copy2.asm | 39 | ||||
-rw-r--r-- | home/cry.asm | 26 | ||||
-rw-r--r-- | home/delay.asm | 2 | ||||
-rw-r--r-- | home/fade.asm | 84 | ||||
-rw-r--r-- | home/farcall.asm | 10 | ||||
-rw-r--r-- | home/init.asm | 45 | ||||
-rw-r--r-- | home/interrupts.asm | 7 | ||||
-rwxr-xr-x | home/items.asm | 16 | ||||
-rw-r--r-- | home/joypad.asm | 22 | ||||
-rw-r--r-- | home/jumptable.asm | 18 | ||||
-rw-r--r-- | home/lcd.asm | 11 | ||||
-rw-r--r-- | home/map.asm | 2 | ||||
-rw-r--r-- | home/map_objects.asm | 2 | ||||
-rw-r--r-- | home/math.asm | 6 | ||||
-rw-r--r-- | home/menu.asm | 80 | ||||
-rw-r--r-- | home/menu_window.asm | 108 | ||||
-rw-r--r-- | home/misc_32c8.asm | 24 | ||||
-rw-r--r-- | home/misc_3c43.asm | 16 | ||||
-rw-r--r-- | home/mon_stats.asm | 18 | ||||
-rw-r--r-- | home/movement.asm | 22 | ||||
-rw-r--r-- | home/names.asm | 30 | ||||
-rw-r--r-- | home/oam_dma.asm | 8 | ||||
-rw-r--r-- | home/overworld.asm | 36 | ||||
-rw-r--r-- | home/pokemon.asm | 33 | ||||
-rw-r--r-- | home/predef.asm | 10 | ||||
-rw-r--r-- | home/print_bcd.asm | 9 | ||||
-rw-r--r-- | home/print_hex.asm | 15 | ||||
-rw-r--r-- | home/print_num.asm | 12 | ||||
-rw-r--r-- | home/print_text.asm | 17 | ||||
-rw-r--r-- | home/random.asm | 6 | ||||
-rw-r--r-- | home/rst.asm | 8 | ||||
-rw-r--r-- | home/rtc.asm | 16 | ||||
-rw-r--r-- | home/scrolling_menu.asm | 18 | ||||
-rw-r--r-- | home/serial.asm | 20 | ||||
-rw-r--r-- | home/sram.asm | 10 | ||||
-rwxr-xr-x | home/tables.asm | 4 | ||||
-rw-r--r-- | home/talk_to_npc.asm | 114 | ||||
-rw-r--r-- | home/text.asm | 2 | ||||
-rw-r--r-- | home/tilemap.asm | 24 | ||||
-rw-r--r-- | home/tileset.asm | 43 | ||||
-rw-r--r-- | home/time.asm | 12 | ||||
-rw-r--r-- | home/toolgear.asm | 27 | ||||
-rw-r--r-- | home/unknown.asm | 15 | ||||
-rw-r--r-- | home/unknown_388f.asm | 7 | ||||
-rw-r--r-- | home/util.asm | 20 | ||||
-rw-r--r-- | home/vblank.asm | 11 | ||||
-rw-r--r-- | home/vcopy.asm | 1 | ||||
-rw-r--r-- | home/window.asm | 2 | ||||
-rw-r--r-- | layout.link (renamed from pokegold-spaceworld.link) | 137 | ||||
-rw-r--r-- | maps/Route1P2.asm | 2 | ||||
-rwxr-xr-x | shim.sym | 4 | ||||
-rw-r--r-- | tools/fix_sections.py | 137 | ||||
-rw-r--r-- | tools/fix_sections_directory.py | 1 | ||||
-rw-r--r-- | tools/make_shim.py | 3 | ||||
-rw-r--r-- | tools/scan_includes.py | 2 | ||||
-rw-r--r-- | tools/sort_sym.py | 68 | ||||
-rwxr-xr-x | tools/sort_symfile.sh | 12 | ||||
-rw-r--r-- | utils/__init__.py (renamed from tools/__init__.py) | 0 | ||||
-rw-r--r-- | utils/compare.sh (renamed from compare.sh) | 2 | ||||
-rw-r--r-- | utils/disasm_coverage.py (renamed from tools/disasm_coverage.py) | 10 | ||||
-rw-r--r-- | utils/dump_names.py (renamed from tools/dump_names.py) | 3 | ||||
-rw-r--r-- | utils/dump_text.py (renamed from tools/dump_text.py) | 3 | ||||
-rw-r--r-- | utils/gfx.py (renamed from tools/gfx.py) | 1 | ||||
-rw-r--r-- | utils/lz.py (renamed from tools/lz.py) | 0 | ||||
-rw-r--r-- | utils/map2link.py (renamed from tools/map2link.py) | 3 | ||||
-rw-r--r-- | utils/mapreader.py (renamed from tools/mapreader.py) | 72 | ||||
-rw-r--r-- | utils/png.py (renamed from tools/png.py) | 0 | ||||
-rw-r--r-- | utils/read_charmap.py (renamed from tools/read_charmap.py) | 3 | ||||
-rw-r--r-- | utils/tests/README.txt (renamed from tools/tests/README.txt) | 0 | ||||
-rw-r--r-- | utils/tests/charmap.asm (renamed from tools/tests/charmap.asm) | 0 | ||||
-rw-r--r-- | utils/tests/dump_test.cc.txt (renamed from tools/tests/dump_test.cc.txt) | 0 | ||||
-rw-r--r-- | utils/tests/dump_test.cc_endless.txt (renamed from tools/tests/dump_test.cc_endless.txt) | 0 | ||||
-rw-r--r-- | utils/tests/dump_test.cc_tc.txt (renamed from tools/tests/dump_test.cc_tc.txt) | 0 | ||||
-rw-r--r-- | utils/tests/dump_test.cc_tc_endless.txt (renamed from tools/tests/dump_test.cc_tc_endless.txt) | 0 | ||||
-rw-r--r-- | utils/tests/dump_test.endless.txt (renamed from tools/tests/dump_test.endless.txt) | 0 | ||||
-rw-r--r-- | utils/tests/dump_test.tc.txt (renamed from tools/tests/dump_test.tc.txt) | 0 | ||||
-rw-r--r-- | utils/tests/dump_test.tc_endless.txt (renamed from tools/tests/dump_test.tc_endless.txt) | 0 | ||||
-rw-r--r-- | utils/tests/dump_test.txt (renamed from tools/tests/dump_test.txt) | 0 | ||||
-rw-r--r-- | utils/tests/dump_text_test.bin (renamed from tools/tests/dump_text_test.bin) | bin | 69 -> 69 bytes | |||
-rw-r--r-- | wram.asm | 3 | ||||
-rw-r--r-- | zero_checksum.asm | 6 |
102 files changed, 1078 insertions, 1125 deletions
diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..c7f6a26 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,25 @@ +language: c +os: linux +install: + - |- + ( cd + git clone -b v0.4.1 --depth=1 https://github.com/rednex/rgbds + sudo make -C rgbds install + rm -rf rgbds + sudo apt-get install wget p7zip-full + ) +before_script: + - |- + function check_status() { + if ! git diff-index --quiet --ignore-submodules=all HEAD --; then + echo 'Uncommitted changes detected:'; + git diff-index HEAD --; + return 1; + fi; + } + - wget -O roms.7z 'https://tcrf.net/images/3/33/Pok%C3%A9mon_Gold_-_Spaceworld_1997_Demo_%28Debug%29.7z' + - 7z e roms.7z + - mv P*\(Debug\).sgb baserom.gb + - rm -f roms.7z P*\(Header\ Fixed\).sgb +script: + - make -j2 compare @@ -1,29 +1,35 @@ +ROM := pokegold-spaceworld.gb +CORRECTEDROM := $(ROM:%.gb=%-correctheader.gb) +BASEROM := baserom.gb + +DIRS := home engine data audio maps +FILES := bin.asm gfx.asm vram.asm sram.asm wram.asm hram.asm + BUILD := build +rwildcard = $(foreach d, $(wildcard $1*), $(filter $(subst *, %, $2), $d) $(call rwildcard, $d/, $2)) +ASMFILES := $(call rwildcard, $(DIRS), *.asm) $(FILES) +OBJS := $(patsubst %.asm, $(BUILD)/%.o, $(ASMFILES)) +OBJS += $(BUILD)/shim.o + + +### Build tools + MD5 := md5sum -c -PYTHON := python -PYTHON3 := python3 +PYTHON := python3 + +RGBDS ?= +RGBASM ?= $(RGBDS)rgbasm +RGBFIX ?= $(RGBDS)rgbfix +RGBGFX ?= $(RGBDS)rgbgfx +RGBLINK ?= $(RGBDS)rgblink -RGBASM := rgbasm -RGBGFX := rgbgfx -RGBLINK := rgblink -RGBFIX := rgbfix -sort_sym := tools/sort_symfile.sh +RGBASMFLAGS := -h -E -i $(BUILD)/ -DGOLD -RGBASMFLAGS := -h -E -i $(BUILD)/ -DGOLD -DDEBUG=1 tools/gfx := -ROM := pokegold-spaceworld.gb -LINKERSCRIPT := pokegold-spaceworld-gen.link -BASEROM := baserom.gb -SHIM := shim.sym -CORRECTEDROM := $(ROM:%.gb=%-correctheader.gb) -rwildcard = $(foreach d, $(wildcard $1*), $(filter $(subst *, %, $2), $d) $(call rwildcard, $d/, $2)) -DIRS := home engine data audio maps -ASMFILES := $(call rwildcard, $(DIRS), *.asm) bin.asm gfx.asm vram.asm sram.asm wram.asm hram.asm -OBJS := $(patsubst %.asm, $(BUILD)/%.o, $(ASMFILES)) -OBJS += $(BUILD)/shim.o +### Build targets .SECONDEXPANSION: @@ -44,48 +50,44 @@ clean: rm -rf $(ROM) $(CORRECTEDROM) $(BUILD) $(ROMS:.gb=.sym) $(ROMS:.gb=.map) *.d "$(MAKE)" -C tools clean -# Remove files except for graphics. -.PHONY: mostlyclean -mostlyclean: +# Remove generated files except for graphics. +.PHONY: tidy +tidy: rm -rf $(ROM) $(CORRECTEDROM) $(OBJS) $(ROMS:.gb=.sym) $(ROMS:.gb=.map) *.d -# Utilities +# Visualize disassembly progress. .PHONY: coverage -coverage: $(ROM:.gb=.map) tools/disasm_coverage.py - $(PYTHON) tools/disasm_coverage.py -m $< -b 0x40 - -.PHONY: linkerscript -linkerscript: $(ROM:.gb=-gen.link) +coverage: $(ROM:.gb=.map) utils/disasm_coverage.py + $(PYTHON) utils/disasm_coverage.py -m $< -b 0x40 -# TODO FIX HARDCODE -%.link: pokegold-spaceworld.map tools/map2link.py - $(PYTHON3) tools/map2link.py $< $@ %.map: %.gb $(CORRECTEDROM): %-correctheader.gb: %.gb - $(RGBASM) $(RGBASMFLAGS) -o $(BUILD)/zero_checksum.o zero_checksum.asm - $(RGBLINK) -O $< -o $@ $(BUILD)/zero_checksum.o - $(RGBFIX) -f hg -m 0x10 $@ + cp $< $@ cp $(<:.gb=.sym) $(@:.gb=.sym) + $(RGBFIX) -f hg -m 0x10 $@ $(ROM): poke%-spaceworld.gb: $(OBJS) | $(BASEROM) - $(RGBLINK) -d -n $(@:.gb=.sym) -m $(@:.gb=.map) -l $(@:.gb=.link) -O $(BASEROM) -o $@ $^ + $(RGBLINK) -d -n $(@:.gb=.sym) -m $(@:.gb=.map) -l layout.link -O $(BASEROM) -o $@ $^ $(RGBFIX) -f lh -k 01 -l 0x33 -m 0x03 -p 0 -r 3 -t "POKEMON2$(shell echo $* | cut -d _ -f 1 | tr '[:lower:]' '[:upper:]')" $@ - $(sort_sym) $(@:.gb=.sym) $(BASEROM): @echo "Please obtain a copy of Gold_debug.sgb and put it in this directory as $@" @exit 1 -$(BUILD)/shim.asm: tools/make_shim.py $(SHIM) | $$(dir $$@) - $(PYTHON3) tools/make_shim.py -w $(filter-out $<, $^) > $@ +$(BUILD)/shim.asm: tools/make_shim.py shim.sym | $$(dir $$@) + $(PYTHON) tools/make_shim.py -w $(filter-out $<, $^) > $@ $(BUILD)/%.o: $(BUILD)/%.asm | $$(dir $$@) $(RGBASM) $(RGBASMFLAGS) $(OUTPUT_OPTION) $< + $(BUILD)/%.o: %.asm | $$(dir $$@) $(RGBASM) $(RGBASMFLAGS) $(OUTPUT_OPTION) $< + +### Misc file-specific graphics rules + $(BUILD)/gfx/sgb/sgb_border_alt.2bpp: tools/gfx += --trim-whitespace $(BUILD)/gfx/sgb/sgb_border_gold.2bpp: tools/gfx += --trim-whitespace $(BUILD)/gfx/sgb/sgb_border_gold_corrupted.2bpp: tools/gfx += --trim-whitespace @@ -94,14 +96,20 @@ $(BUILD)/gfx/sgb/corrupted_9e1c.2bpp: tools/gfx += --trim-whitespace $(BUILD)/gfx/sgb/corrupted_a66c.2bpp: tools/gfx += --trim-whitespace $(BUILD)/gfx/sgb/corrupted_b1e3.2bpp: tools/gfx += --trim-whitespace $(BUILD)/gfx/sgb/sgb_border_silver.2bpp: tools/gfx += --trim-whitespace + $(BUILD)/gfx/trainer_card/leaders.2bpp: tools/gfx += --trim-whitespace $(BUILD)/gfx/trainer_gear/town_map.2bpp: tools/gfx += --trim-trailing $(BUILD)/gfx/minigames/slots.2bpp: tools/gfx += --trim-whitespace $(BUILD)/gfx/minigames/poker.2bpp: tools/gfx += --trim-whitespace + $(BUILD)/gfx/intro/purin_pikachu.2bpp: tools/gfx += --trim-whitespace + $(BUILD)/gfx/battle_anims/attack_animations_1.2bpp: tools/gfx += --trim-whitespace $(BUILD)/gfx/battle_anims/attack_animations_2.2bpp: tools/gfx += --trim-whitespace + +### Catch-all graphics rules + .PRECIOUS: $(BUILD)/%.pic $(BUILD)/%.pic: $(BUILD)/%.2bpp tools/pkmncompress | $$(dir $$@) tools/pkmncompress $< $@ @@ -124,7 +132,10 @@ $(BUILD)/%.tilemap: %.png | $$(dir $$@) %/: mkdir -p $@ -DEPENDENCY_SCAN_EXIT_STATUS := $(shell $(PYTHON3) tools/scan_includes.py $(BUILD:%=-b %) $(ASMFILES) > dependencies.d; echo $$?) + +### Scan .asm files for INCLUDE dependencies + +DEPENDENCY_SCAN_EXIT_STATUS := $(shell $(PYTHON) tools/scan_includes.py $(BUILD:%=-b %) $(ASMFILES) > dependencies.d; echo $$?) ifneq ($(DEPENDENCY_SCAN_EXIT_STATUS), 0) $(error Dependency scan failed) endif @@ -1,15 +1,42 @@ -WIP disassembly of the Space World 1997 Gold proto +# Pokémon Gold and Silver: Space World 1997 Demo [![Build Status][travis-badge]][travis] -It attempts to build the following ROMs: +This is a work-in-progress disassembly of the Pokémon Gold and Pokémon Silver prototypes demoed at Space World 1997. -pokegold_spaceworld.gb (MD5: 3c407114de28d17b7113a2c0cee9a37c) -pokegold_debug_spaceworld.gb (MD5: 2eadbed83b775c097ff79e5128d1184f) -pokesilver_spaceworld.gb (MD5: c52a677c35f15320d5b495e14809f00d) -pokesilver_debug_spaceworld.gb (MD5: fa65d3759bb17c489de171a598ba4913) +It builds the following ROMs: + +- Gold_debug.sgb `md5: 2eadbed83b775c097ff79e5128d1184f` +- Gold_debug.sgb (correct header) `md5: 8e509301f6db1f89fee85aead8ebf8d4` + +You will need to provide a copy of Gold_debug.sgb renamed **baserom.gb** to build the ROMs. -Requires [RGBDS](https://github.com/rednex/rgbds) version 0.3.8 or newer to build! ## See also -* Discord: [**pret**][Discord] -[Discord]: https://discord.gg/vdTW48Q +- **Discord:** [pret][discord] +- **IRC:** [freenode#pret][irc] + +Other disassembly projects: + +- [**Pokémon Red/Blue**][pokered] +- [**Pokémon Yellow**][pokeyellow] +- [**Pokémon Gold**][pokegold] +- [**Pokémon Crystal**][pokecrystal] +- [**Pokémon Pinball**][pokepinball] +- [**Pokémon TCG**][poketcg] +- [**Pokémon Ruby**][pokeruby] +- [**Pokémon FireRed**][pokefirered] +- [**Pokémon Emerald**][pokeemerald] + +[pokered]: https://github.com/pret/pokered +[pokeyellow]: https://github.com/pret/pokeyellow +[pokegold]: https://github.com/pret/pokegold +[pokecrystal]: https://github.com/pret/pokecrystal +[pokepinball]: https://github.com/pret/pokepinball +[poketcg]: https://github.com/pret/poketcg +[pokeruby]: https://github.com/pret/pokeruby +[pokefirered]: https://github.com/pret/pokefirered +[pokeemerald]: https://github.com/pret/pokeemerald +[discord]: https://discord.gg/d5dubZ3 +[irc]: https://kiwiirc.com/client/irc.freenode.net/?#pret +[travis]: https://travis-ci.org/pret/pokegold-spaceworld +[travis-badge]: https://travis-ci.org/pret/pokegold-spaceworld.svg?branch=master diff --git a/constants.asm b/constants.asm index abf943a..0d1fdec 100644 --- a/constants.asm +++ b/constants.asm @@ -12,6 +12,7 @@ INCLUDE "constants/pokedex_constants.asm" INCLUDE "constants/pokemon_constants.asm" INCLUDE "constants/pokemon_data_constants.asm" INCLUDE "constants/move_constants.asm" +INCLUDE "constants/icon_constants.asm" INCLUDE "constants/item_constants.asm" INCLUDE "constants/item_data_constants.asm" INCLUDE "constants/trainer_constants.asm" diff --git a/constants/icon_constants.asm b/constants/icon_constants.asm new file mode 100644 index 0000000..6490b51 --- /dev/null +++ b/constants/icon_constants.asm @@ -0,0 +1,35 @@ +; Icon IDs + const_def + const ICON_NONE ; 00 + const ICON_NYOROMO ; 01 + const ICON_PURIN ; 02 + const ICON_DIGDA ; 03 + const ICON_PIKACHU ; 04 + const ICON_HITODEMAN ; 05 + const ICON_KOIKING ; 06 + const ICON_POPPO ; 07 + const ICON_SIDON ; 08 + const ICON_PIPPI ; 09 + const ICON_NAZONOKUSA ; 0a + const ICON_MUSHI ; 0b + const ICON_GANGAR ; 0c + const ICON_LAPLACE ; 0d + const ICON_BARRIERD ; 0e + const ICON_LOKON ; 0f + const ICON_KENTAUROS ; 10 + const ICON_SHELLDER ; 11 + const ICON_METAMON ; 12 + const ICON_IWARK ; 13 + const ICON_BIRIRIDAMA ; 14 + const ICON_ZENIGAME ; 15 + const ICON_FUSHIGIDANE ; 16 + const ICON_HITOKAGE ; 17 + const ICON_BEEDLE ; 18 + const ICON_ANNON ; 19 + const ICON_ISITSUBUTE ; 1a + const ICON_WANRIKY ; 1b + const ICON_EGG ; 1c + const ICON_MENOKURAGE ; 1d + const ICON_BUTTERFREE ; 1e + const ICON_ZUBAT ; 1f + const ICON_KABIGON ; 20 diff --git a/constants/music_constants.asm b/constants/music_constants.asm index c304fbb..acb47eb 100755 --- a/constants/music_constants.asm +++ b/constants/music_constants.asm @@ -15,5 +15,5 @@ const MUSIC_EVOLUTION ; 0C MUSIC_SURF EQU $62 - + SE_SELECT EQU 5 diff --git a/constants/pokedex_constants.asm b/constants/pokedex_constants.asm index 66da19b..b3c5e00 100644 --- a/constants/pokedex_constants.asm +++ b/constants/pokedex_constants.asm @@ -252,9 +252,9 @@ const DEX_BULU ; f9 SNUBBULL const DEX_TAIL ; fa AIPOM const DEX_LEAFY ; fb LEAFEON (evolved EEVEE) -NUM_POKEMON EQU const_value + -1 +NUM_POKEMON EQU const_value - 1 const DEX_FC ; fc - const DEX_FD ; fd + const DEX_EGG ; fd EGG const DEX_FE ; fe ; Annon forms @@ -285,4 +285,4 @@ NUM_POKEMON EQU const_value + -1 const ANNON_X ; 24 const ANNON_Y ; 25 const ANNON_Z ; 26 -NUM_ANNON EQU const_value + -1 ; 26 +NUM_ANNON EQU const_value - 1 ; 26 diff --git a/data/items/names.asm b/data/items/names.asm index 3ae826d..b8d6d75 100644 --- a/data/items/names.asm +++ b/data/items/names.asm @@ -1,10 +1,6 @@ INCLUDE "constants.asm" -; if DEBUG SECTION "data/items/names.asm", ROMX -; else -; SECTION "ItemNames", ROMX[$6FE9], BANK[$01] -; endc ItemNames:: db "マスターボール@" ; MASTER_BALL diff --git a/data/pokemon/base_stats/kirinriki.inc b/data/pokemon/base_stats/kirinriki.inc index 30b2312..400a807 100644 --- a/data/pokemon/base_stats/kirinriki.inc +++ b/data/pokemon/base_stats/kirinriki.inc @@ -6,11 +6,7 @@ db TYPE_DARK, TYPE_NORMAL ; type db 255 ; catch rate db 100 ; base exp -if DEBUG || def(SILVER) db ITEM_BERRY, ITEM_TAG ; items -else - db ITEM_APPLE, ITEM_TAG ; item -endc db GENDER_50_50 ; gender ratio db 100, 4, 70 ; unknown dn 7, 7 ; sprite dimensions diff --git a/data/pokemon/menu_icons.asm b/data/pokemon/menu_icons.asm new file mode 100644 index 0000000..5ef9b63 --- /dev/null +++ b/data/pokemon/menu_icons.asm @@ -0,0 +1,256 @@ +INCLUDE "constants.asm" + +SECTION "data/pokemon/menu_icons.asm", ROMX + +MonMenuIcons:: ; 8F22A + db ICON_FUSHIGIDANE ; 01 FUSHIGIDANE + db ICON_FUSHIGIDANE ; 02 FUSHIGISOU + db ICON_FUSHIGIDANE ; 03 FUSHIGIBANA + db ICON_HITOKAGE ; 04 HITOKAGE + db ICON_HITOKAGE ; 05 LIZARDO + db ICON_HITOKAGE ; 06 LIZARDON + db ICON_ZENIGAME ; 07 ZENIGAME + db ICON_ZENIGAME ; 08 KAMEIL + db ICON_ZENIGAME ; 09 KAMEX + db ICON_BEEDLE ; 0a CATERPIE + db ICON_BEEDLE ; 0b TRANSEL + db ICON_BUTTERFREE ; 0c BUTTERFREE + db ICON_BEEDLE ; 0d BEEDLE + db ICON_BEEDLE ; 0e COCOON + db ICON_MUSHI ; 0f SPEAR + db ICON_POPPO ; 10 POPPO + db ICON_POPPO ; 11 PIGEON + db ICON_POPPO ; 12 PIGEOT + db ICON_LOKON ; 13 KORATTA + db ICON_LOKON ; 14 RATTA + db ICON_POPPO ; 15 ONISUZUME + db ICON_POPPO ; 16 ONIDRILL + db ICON_IWARK ; 17 ARBO + db ICON_IWARK ; 18 ARBOK + db ICON_PIKACHU ; 19 PIKACHU + db ICON_PIKACHU ; 1a RAICHU + db ICON_SIDON ; 1b SAND + db ICON_SIDON ; 1c SANDPAN + db ICON_LOKON ; 1d NIDORAN_F + db ICON_LOKON ; 1e NIDORINA + db ICON_SIDON ; 1f NIDOQUEEN + db ICON_LOKON ; 20 NIDORAN_M + db ICON_LOKON ; 21 NIDORINO + db ICON_SIDON ; 22 NIDOKING + db ICON_PIPPI ; 23 PIPPI + db ICON_PIPPI ; 24 PIXY + db ICON_LOKON ; 25 ROKON + db ICON_LOKON ; 26 KYUKON + db ICON_PURIN ; 27 PURIN + db ICON_PURIN ; 28 PUKURIN + db ICON_ZUBAT ; 29 ZUBAT + db ICON_ZUBAT ; 2a GOLBAT + db ICON_NAZONOKUSA ; 2b NAZONOKUSA + db ICON_NAZONOKUSA ; 2c KUSAIHANA + db ICON_NAZONOKUSA ; 2d RUFFRESIA + db ICON_MUSHI ; 2e PARAS + db ICON_MUSHI ; 2f PARASECT + db ICON_MUSHI ; 30 KONGPANG + db ICON_BUTTERFREE ; 31 MORPHON + db ICON_DIGDA ; 32 DIGDA + db ICON_DIGDA ; 33 DUGTRIO + db ICON_LOKON ; 34 NYARTH + db ICON_LOKON ; 35 PERSIAN + db ICON_SIDON ; 36 KODUCK + db ICON_SIDON ; 37 GOLDUCK + db ICON_WANRIKY ; 38 MANKEY + db ICON_WANRIKY ; 39 OKORIZARU + db ICON_LOKON ; 3a GARDIE + db ICON_LOKON ; 3b WINDIE + db ICON_NYOROMO ; 3c NYOROMO + db ICON_NYOROMO ; 3d NYOROZO + db ICON_NYOROMO ; 3e NYOROBON + db ICON_BARRIERD ; 3f CASEY + db ICON_BARRIERD ; 40 YUNGERER + db ICON_BARRIERD ; 41 FOODIN + db ICON_WANRIKY ; 42 WANRIKY + db ICON_WANRIKY ; 43 GORIKY + db ICON_WANRIKY ; 44 KAIRIKY + db ICON_NAZONOKUSA ; 45 MADATSUBOMI + db ICON_NAZONOKUSA ; 46 UTSUDON + db ICON_NAZONOKUSA ; 47 UTSUBOT + db ICON_MENOKURAGE ; 48 MENOKURAGE + db ICON_MENOKURAGE ; 49 DOKUKURAGE + db ICON_ISITSUBUTE ; 4a ISITSUBUTE + db ICON_ISITSUBUTE ; 4b GOLONE + db ICON_ISITSUBUTE ; 4c GOLONYA + db ICON_KENTAUROS ; 4d PONYTA + db ICON_KENTAUROS ; 4e GALLOP + db ICON_SIDON ; 4f YADON + db ICON_SIDON ; 50 YADORAN + db ICON_BIRIRIDAMA ; 51 COIL + db ICON_BIRIRIDAMA ; 52 RARECOIL + db ICON_POPPO ; 53 KAMONEGI + db ICON_POPPO ; 54 DODO + db ICON_POPPO ; 55 DODORIO + db ICON_LAPLACE ; 56 PAWOU + db ICON_LAPLACE ; 57 JUGON + db ICON_METAMON ; 58 BETBETER + db ICON_METAMON ; 59 BETBETON + db ICON_SHELLDER ; 5a SHELLDER + db ICON_SHELLDER ; 5b PARSHEN + db ICON_GANGAR ; 5c GHOS + db ICON_GANGAR ; 5d GHOST + db ICON_GANGAR ; 5e GANGAR + db ICON_ISITSUBUTE ; 5f IWARK + db ICON_BARRIERD ; 60 SLEEPE + db ICON_BARRIERD ; 61 SLEEPER + db ICON_SHELLDER ; 62 CRAB + db ICON_SHELLDER ; 63 KINGLER + db ICON_BIRIRIDAMA ; 64 BIRIRIDAMA + db ICON_BIRIRIDAMA ; 65 MARUMINE + db ICON_NAZONOKUSA ; 66 TAMATAMA + db ICON_NAZONOKUSA ; 67 NASSY + db ICON_SIDON ; 68 KARAKARA + db ICON_SIDON ; 69 GARAGARA + db ICON_WANRIKY ; 6a SAWAMULAR + db ICON_WANRIKY ; 6b EBIWALAR + db ICON_SIDON ; 6c BERORINGA + db ICON_METAMON ; 6d DOGARS + db ICON_METAMON ; 6e MATADOGAS + db ICON_KENTAUROS ; 6f SIHORN + db ICON_SIDON ; 70 SIDON + db ICON_SIDON ; 71 LUCKY + db ICON_NAZONOKUSA ; 72 MONJARA + db ICON_SIDON ; 73 GARURA + db ICON_KOIKING ; 74 TATTU + db ICON_KOIKING ; 75 SEADRA + db ICON_KOIKING ; 76 TOSAKINTO + db ICON_KOIKING ; 77 AZUMAO + db ICON_HITODEMAN ; 78 HITODEMAN + db ICON_HITODEMAN ; 79 STARMIE + db ICON_BARRIERD ; 7a BARRIERD + db ICON_MUSHI ; 7b STRIKE + db ICON_BARRIERD ; 7c ROUGELA + db ICON_BARRIERD ; 7d ELEBOO + db ICON_BARRIERD ; 7e BOOBER + db ICON_MUSHI ; 7f KAILIOS + db ICON_KENTAUROS ; 80 KENTAUROS + db ICON_KOIKING ; 81 KOIKING + db ICON_IWARK ; 82 GYARADOS + db ICON_LAPLACE ; 83 LAPLACE + db ICON_METAMON ; 84 METAMON + db ICON_LOKON ; 85 EIEVUI + db ICON_LOKON ; 86 SHOWERS + db ICON_LOKON ; 87 THUNDERS + db ICON_LOKON ; 88 BOOSTER + db ICON_BIRIRIDAMA ; 89 PORYGON + db ICON_SHELLDER ; 8a OMNITE + db ICON_SHELLDER ; 8b OMSTAR + db ICON_SIDON ; 8c KABUTO + db ICON_SIDON ; 8d KABUTOPS + db ICON_POPPO ; 8e PTERA + db ICON_KABIGON ; 8f KABIGON + db ICON_POPPO ; 90 FREEZER + db ICON_POPPO ; 91 THUNDER + db ICON_POPPO ; 92 FIRE + db ICON_IWARK ; 93 MINIRYU + db ICON_IWARK ; 94 HAKURYU + db ICON_LAPLACE ; 95 KAIRYU + db ICON_BARRIERD ; 96 MEWTWO + db ICON_BARRIERD ; 97 MEW + db ICON_NAZONOKUSA ; 98 HAPPA + db ICON_NAZONOKUSA ; 99 HANAMOGURA + db ICON_NAZONOKUSA ; 9a HANARYU + db ICON_SIDON ; 9b HONOGUMA + db ICON_SIDON ; 9c VOLBEAR + db ICON_SIDON ; 9d DYNABEAR + db ICON_LAPLACE ; 9e KURUSU + db ICON_LAPLACE ; 9f AQUA + db ICON_LAPLACE ; a0 AQUARIA + db ICON_POPPO ; a1 HOHO + db ICON_POPPO ; a2 BOBO + db ICON_LOKON ; a3 PACHIMEE + db ICON_LOKON ; a4 MOKOKO + db ICON_SIDON ; a5 DENRYU + db ICON_LOKON ; a6 MIKON + db ICON_NAZONOKUSA ; a7 MONJA + db ICON_NAZONOKUSA ; a8 JARANRA + db ICON_KOIKING ; a9 HANEEI + db ICON_KOIKING ; aa PUKU + db ICON_KOIKING ; ab SHIBIREFUGU + db ICON_PIKACHU ; ac PICHU + db ICON_PIPPI ; ad PY + db ICON_PURIN ; ae PUPURIN + db ICON_SIDON ; af MIZUUO + db ICON_POPPO ; b0 NATY + db ICON_POPPO ; b1 NATIO + db ICON_KOIKING ; b2 GYOPIN + db ICON_PURIN ; b3 MARIL + db ICON_KOIKING ; b4 MANBO1 + db ICON_KOIKING ; b5 IKARI + db ICON_KOIKING ; b6 GROTESS + db ICON_ZUBAT ; b7 EKSING + db ICON_MUSHI ; b8 PARA + db ICON_MUSHI ; b9 KOKUMO + db ICON_MUSHI ; ba TWOHEAD + db ICON_POPPO ; bb YOROIDORI + db ICON_METAMON ; bc ANIMON + db ICON_POPPO ; bd HINAZU + db ICON_NAZONOKUSA ; be SUNNY + db ICON_KENTAUROS ; bf PAON + db ICON_KENTAUROS ; c0 DONPHAN + db ICON_GANGAR ; c1 TWINZ + db ICON_LOKON ; c2 KIRINRIKI + db ICON_BARRIERD ; c3 PAINTER + db ICON_LOKON ; c4 KOUNYA + db ICON_LOKON ; c5 RINRIN + db ICON_LOKON ; c6 BERURUN + db ICON_NYOROMO ; c7 NYOROTONO + db ICON_SIDON ; c8 YADOKING + db ICON_ANNON ; c9 ANNON + db ICON_MUSHI ; ca REDIBA + db ICON_MUSHI ; cb MITSUBOSHI + db ICON_KENTAUROS ; cc PUCHICORN + db ICON_LOKON ; cd EIFIE + db ICON_LOKON ; ce BLACKY + db ICON_LOKON ; cf TURBAN + db ICON_METAMON ; d0 BETBABY + db ICON_KOIKING ; d1 TEPPOUO + db ICON_KOIKING ; d2 OKUTANK + db ICON_WANRIKY ; d3 GONGU + db ICON_WANRIKY ; d4 KAPOERER + db ICON_LOKON ; d5 PUDIE + db ICON_NAZONOKUSA ; d6 HANEKO + db ICON_NAZONOKUSA ; d7 POPONEKO + db ICON_NAZONOKUSA ; d8 WATANEKO + db ICON_BARRIERD ; d9 BARIRINA + db ICON_BARRIERD ; da LIP + db ICON_BARRIERD ; db ELEBABY + db ICON_BARRIERD ; dc BOOBY + db ICON_NAZONOKUSA ; dd KIREIHANA + db ICON_NAZONOKUSA ; de TSUBOMITTO + db ICON_KENTAUROS ; df MILTANK + db ICON_LAPLACE ; e0 BOMBSEEKER + db ICON_PIPPI ; e1 GIFT + db ICON_LOKON ; e2 KOTORA + db ICON_LOKON ; e3 RAITORA + db ICON_POPPO ; e4 MADAME + db ICON_GANGAR ; e5 NOROWARA + db ICON_GANGAR ; e6 KYONPAN + db ICON_POPPO ; e7 YAMIKARASU + db ICON_SIDON ; e8 HAPPI + db ICON_MUSHI ; e9 SCISSORS + db ICON_MUSHI ; ea PURAKKUSU + db ICON_LOKON ; eb DEVIL + db ICON_LOKON ; ec HELGAA + db ICON_SIDON ; ed WOLFMAN + db ICON_SIDON ; ee WARWOLF + db ICON_BIRIRIDAMA ; ef PORYGON2 + db ICON_SIDON ; f0 NAMEIL + db ICON_IWARK ; f1 HAGANEIL + db ICON_LAPLACE ; f2 KINGDRA + db ICON_LOKON ; f3 RAI + db ICON_LOKON ; f4 EN + db ICON_LOKON ; f5 SUI + db ICON_LOKON ; f6 NYULA + db ICON_POPPO ; f7 HOUOU + db ICON_PIPPI ; f8 TOGEPY + db ICON_PIPPI ; f9 BULU + db ICON_LOKON ; fa TAIL + db ICON_LOKON ; fb LEAFY diff --git a/data/tileset_headers.asm b/data/tileset_headers.asm index f739d1b..2c00ffe 100644 --- a/data/tileset_headers.asm +++ b/data/tileset_headers.asm @@ -1,10 +1,7 @@ INCLUDE "constants.asm" -; if DEBUG SECTION "data/tileset_headers.asm", ROMX -; else -; SECTION "Tileset Headers", ROMX[$4875], BANK[$03] -; endc + Tilesets:: Tileset_00: ; 0xc88d diff --git a/engine/dumps/bank03.asm b/engine/dumps/bank03.asm index 39d1f78..2c2a21c 100755 --- a/engine/dumps/bank03.asm +++ b/engine/dumps/bank03.asm @@ -2196,7 +2196,7 @@ Function60a0: ; 03:60a0 call LoadMapPart call GetMemSGBLayout call WaitBGMap - call RotateThreePalettesLeft + call GBFadeInFromWhite .sub_e155 pop bc ld a, b @@ -3342,7 +3342,7 @@ Functione8f9: ; 03:68f9 ld hl, NamingScreen push de call FarCall_hl - call RotateThreePalettesRight + call GBFadeOutToWhite pop de ld a, [de] cp $50 @@ -3364,7 +3364,7 @@ Functione8f9: ; 03:68f9 ld a, BANK(NamingScreen) ld hl, NamingScreen call FarCall_hl - call RotateThreePalettesRight + call GBFadeOutToWhite ld de, wdf17 ld a, [de] cp $50 diff --git a/engine/Intro.asm b/engine/intro.asm index 55f8c3f..ad8fb3e 100644 --- a/engine/Intro.asm +++ b/engine/intro.asm @@ -9,7 +9,7 @@ DemoStart:: ; 558D call FadeInIntroPic ld hl, OakSpeechDemo call PrintText - call RotateThreePalettesRight + call GBFadeOutToWhite call ClearTileMap ld de, ProtagonistPic lb bc, BANK(ProtagonistPic), $00 @@ -27,7 +27,7 @@ GameStart:: ; 55BB call FadeInIntroPic ld hl, OakSpeech1 call PrintText - call RotateThreePalettesRight + call GBFadeOutToWhite call ClearTileMap ld a, DEX_YADOKING ld [wCurSpecies], a @@ -43,7 +43,7 @@ GameStart:: ; 55BB call PlayCry ld hl, OakSpeech3 call PrintText - call RotateThreePalettesRight + call GBFadeOutToWhite call ClearTileMap ld de, ProtagonistPic lb bc, BANK(ProtagonistPic), $00 @@ -52,7 +52,7 @@ GameStart:: ; 55BB ld hl, OakSpeech4 call PrintText call ChoosePlayerName - call RotateThreePalettesRight + call GBFadeOutToWhite call ClearTileMap ld de, RivalPic lb bc, BANK(RivalPic), $00 @@ -61,7 +61,7 @@ GameStart:: ; 55BB ld hl, OakSpeech5 call PrintText call ChooseRivalName - call RotateThreePalettesRight + call GBFadeOutToWhite call ClearTileMap ld de, OakPic lb bc, BANK(OakPic), $00 @@ -71,12 +71,12 @@ GameStart:: ; 55BB call PrintText callba SetClockDialog call Function04ac - call RotateThreePalettesRight + call GBFadeOutToWhite call ClearTileMap ld de, ProtagonistPic lb bc, BANK(ProtagonistPic), $00 call IntroDisplayPicCenteredOrUpperRight - call RotateThreePalettesLeft + call GBFadeInFromWhite ld hl, OakSpeech7 call PrintText ldh a, [hROMBank] @@ -116,7 +116,7 @@ IntroCleanup:: ; 568E call LoadFontExtra ld c, $32 call DelayFrames - call RotateThreePalettesRight + call GBFadeOutToWhite call ClearTileMap call Function0502 ld a, $00 @@ -499,14 +499,14 @@ ChoosePlayerName:: ; 5B25 cp "@" jr z, .loop - call RotateThreePalettesRight + call GBFadeOutToWhite call ClearTileMap call LoadFontExtra call WaitBGMap ld de, $4D10 ld bc, $1200 call IntroDisplayPicCenteredOrUpperRight - call RotateThreePalettesLeft + call GBFadeInFromWhite .farjump ld hl, ChoosePlayerNameEndText call PrintText @@ -552,14 +552,14 @@ ChooseRivalName:: ; 5BA9 cp "@" jr z, .loop - call RotateThreePalettesRight + call GBFadeOutToWhite call ClearTileMap call LoadFontExtra call WaitBGMap ld de, $4BD4 ld bc, $1200 call IntroDisplayPicCenteredOrUpperRight - call RotateThreePalettesLeft + call GBFadeInFromWhite .farjump ld hl, ChooseRivalNameEndText call PrintText diff --git a/engine/predef.asm b/engine/predef.asm index c9293b4..92fed51 100644 --- a/engine/predef.asm +++ b/engine/predef.asm @@ -1,10 +1,6 @@ INCLUDE "constants.asm" -; if DEBUG SECTION "engine/predef.asm", ROMX -; else -; SECTION "Predef pointers", ROMX[$62AD], BANK[$01] -; endc GetPredefPointer:: ; 1:62b0 ld a, h diff --git a/engine/title.asm b/engine/title.asm index c39abdd..5abeade 100644 --- a/engine/title.asm +++ b/engine/title.asm @@ -420,12 +420,8 @@ TitleSeq_TitleScreenInputAndTimeout:: jr .psbtn_nextseq .psbtn_gotodebug -if DEBUG ld a, $01 ; DebugMenu jr .psbtn_nextseq -else - ret -endc .psbtn_sramclear ld a, $02 @@ -629,12 +625,7 @@ SetTitleGfxNext:: jr nz, .loop ret -; if DEBUG SECTION "engine/title.asm@Title screen TEMPORARY", ROMX -; else -; SECTION "Title screen TEMPORARY", ROMX[$62A2], BANK[$01] ; TODO: merge this with the main section above -; endc - GameInit:: call ClearWindowData @@ -93,22 +93,14 @@ MailIconGFX:: INCBIN "gfx/icons/mail.2bpp" SECTION "gfx.asm@Trainer Card GFX", ROMX -TrainerCardBorderGFX:: INCBIN "gfx/trainer_card/border.2bpp" -TrainerCardGFX:: INCBIN "gfx/trainer_card/trainer_card.2bpp" ; 0x013171--0x013381 -TrainerCardColonGFX:: INCBIN "gfx/trainer_card/colon.2bpp" ; 0x013381--0x013391 -TrainerCardIDNoGFX:: INCBIN "gfx/trainer_card/id_no.2bpp" ; 0x013391--0x0133B1 +TrainerCardBorderGFX:: INCBIN "gfx/trainer_card/border.2bpp" +TrainerCardGFX:: INCBIN "gfx/trainer_card/trainer_card.2bpp" ; 0x013171--0x013381 +TrainerCardColonGFX:: INCBIN "gfx/trainer_card/colon.2bpp" ; 0x013381--0x013391 +TrainerCardIDNoGFX:: INCBIN "gfx/trainer_card/id_no.2bpp" ; 0x013391--0x0133B1 TrainerCardIDNoGFXEnd:: -TrainerCardLeadersGFX:: INCBIN "gfx/trainer_card/leaders.2bpp" ; 0x0133B1--0x133BA1 -if DEBUG || def(GOLD) +TrainerCardLeadersGFX:: INCBIN "gfx/trainer_card/leaders.2bpp" ; 0x0133B1--0x133BA1 db $18, $00 ; leftover of previous graphics -else - db $b2, $aa ; leftover of previous graphics? -endc - -if DEBUG -; Not sure how to parse this from the non-debug ROM, so I'll leave this be for now Unreferenced_UnusedLeaderNameGFX:: INCBIN "gfx/trainer_card/unused_leader_name.2bpp" ; 0x13ba3 -endc SECTION "gfx.asm@Bank 6 Tilesets 00", ROMX Tileset_00_GFX: @@ -5,7 +5,7 @@ import os import argparse -from tools import gfx, lz +from utils import gfx, lz # Graphics with inverted tilemaps that aren't covered by filepath_rules. diff --git a/home/audio.asm b/home/audio.asm index c157bed..b2d07c5 100644 --- a/home/audio.asm +++ b/home/audio.asm @@ -1,12 +1,9 @@ INCLUDE "constants.asm" -; if DEBUG + SECTION "home/audio.asm", ROM0 -; else -; SECTION "Audio interface", ROM0[$3C83] -; endc -DisableAudio:: ; 3cbf +DisableAudio:: push hl push de push bc @@ -26,7 +23,7 @@ DisableAudio:: ; 3cbf pop hl ret -UpdateSound:: ; 3cdb +UpdateSound:: push hl push de push bc @@ -46,7 +43,7 @@ UpdateSound:: ; 3cdb pop hl ret -_LoadMusicByte:: ; 3cf7 +_LoadMusicByte:: ld [MBC3RomBank], a ; Unsafe ldh [hROMBank], a ld a, [de] @@ -57,7 +54,7 @@ _LoadMusicByte:: ; 3cf7 pop af ret -PlayMusic:: ; 3d07 +PlayMusic:: push hl push de push bc @@ -77,7 +74,7 @@ PlayMusic:: ; 3d07 pop hl ret -PlayCryHeader:: ; 3d23 +PlayCryHeader:: push hl push de push bc @@ -119,7 +116,7 @@ endr pop hl ret -PlaySFX:: ; 3d63 +PlaySFX:: push hl push de push bc @@ -139,12 +136,12 @@ PlaySFX:: ; 3d63 pop hl ret -WaitPlaySFX:: ; 3d7f +WaitPlaySFX:: call WaitSFX call PlaySFX ret -WaitSFX:: ; 3d86 +WaitSFX:: push hl .loop ld hl, wChannel5Flags1 @@ -161,23 +158,23 @@ WaitSFX:: ; 3d86 jr nz, .loop pop hl ret - -MaxVolume:: ; 3DA5 + +MaxVolume:: ld a, $77 ld [wVolume], a ret -LowVolume:: ; 3DAB +LowVolume:: ld a, $33 ld [wVolume], a ret -VolumeOff:: ; 3DB1 +VolumeOff:: xor a ld [wVolume], a ret -UpdateSoundNTimes:: ; 3DB6 +UpdateSoundNTimes:: .loop and a ret z @@ -185,7 +182,7 @@ UpdateSoundNTimes:: ; 3DB6 call UpdateSound jr .loop -FadeToMapMusic:: ; 3DBE +FadeToMapMusic:: push hl push de push bc @@ -194,7 +191,7 @@ FadeToMapMusic:: ; 3DBE ld a, [wMapMusic] cp e jr z, .jump - ld a, $08 + ld a, 8 ld [wMusicFade], a ld a, e ld [wMusicFadeID], a @@ -209,7 +206,7 @@ FadeToMapMusic:: ; 3DBE pop hl ret -PlayMapMusic:: ; 3DE1 +PlayMapMusic:: push hl push de push bc @@ -219,7 +216,7 @@ PlayMapMusic:: ; 3DE1 cp e jr z, .jump push de - ld de, $0000 + ld de, MUSIC_NONE call PlayMusic call DelayFrame pop de @@ -233,37 +230,36 @@ PlayMapMusic:: ; 3DE1 pop hl ret -SpecialMapMusic:: ; 3E05 +SpecialMapMusic:: ld a, [wPlayerState] and a jr z, .normal cp $02 jr z, .state2 - ld de, $0009 + ld de, MUSIC_BICYCLE scf ret -.state2 ; 3E14 - ld de, $0000 +.state2 ; 3e14 + ld de, MUSIC_NONE scf ret -.normal ; 3E19 +.normal ; 3e19 and a ret -GetMapMusic:: ; 3E1B +GetMapMusic:: call SpecialMapMusic ret c ld a, [wMapPermissions] - cp $01 - jr z, .jump - cp $03 - jr z, .jump - ld de, $0002 - ret -.jump ; 3E2E - ld de, $0007 + cp TOWN + jr z, .not_route + cp INDOOR + jr z, .not_route + ld de, MUSIC_ROUTE_1 ret -; 3E32, this is likely not a function.
\ No newline at end of file +.not_route + ld de, MUSIC_VIRIDIAN_CITY + ret diff --git a/home/bankswitch.asm b/home/bankswitch.asm index a0e0d9d..c28d72b 100644 --- a/home/bankswitch.asm +++ b/home/bankswitch.asm @@ -1,14 +1,10 @@ INCLUDE "constants.asm" -; if DEBUG SECTION "home/bankswitch.asm", ROM0 -; else -; SECTION "Bankswitch", ROM0[$3286] -; endc -; Moved to a rst vector in final US releases (not sure about JP) -; All rst vectors are unused at this point in development -Bankswitch:: ; 32c2 +; Moved to a rst vector in final US releases (not sure about JP). +; All rst vectors are unused at this point in development. +Bankswitch:: ldh [hROMBank], a ld [MBC3RomBank], a - ret
\ No newline at end of file + ret diff --git a/home/clear_sprites.asm b/home/clear_sprites.asm index dca5479..c25d251 100644 --- a/home/clear_sprites.asm +++ b/home/clear_sprites.asm @@ -1,12 +1,8 @@ INCLUDE "constants.asm" -; if DEBUG SECTION "home/clear_sprites.asm", ROM0 -; else -; SECTION "Sprite clearing", ROM0[$32A0] -; endc -ClearSprites:: ; 32dc +ClearSprites:: ld hl, wVirtualOAM ld b, wVirtualOAMEnd - wVirtualOAM xor a @@ -16,7 +12,7 @@ ClearSprites:: ; 32dc jr nz, .loop ret -HideSprites:: ; 32e7 +HideSprites:: ld hl, wVirtualOAM ld de, SPRITEOAMSTRUCT_LENGTH ld b, NUM_SPRITE_OAM_STRUCTS @@ -26,4 +22,4 @@ HideSprites:: ; 32e7 add hl, de dec b jr nz, .loop - ret
\ No newline at end of file + ret diff --git a/home/copy.asm b/home/copy.asm index 6efabc4..ebce4f3 100644 --- a/home/copy.asm +++ b/home/copy.asm @@ -1,12 +1,8 @@ INCLUDE "constants.asm" -; if DEBUG SECTION "home/copy.asm", ROM0 -; else -; SECTION "Copy functions", ROM0[$32BB] -; endc -FarCopyBytes:: ; 32f7 +FarCopyBytes:: ; Copy bc bytes from a:hl to de. ld [wBuffer], a ldh a, [hROMBank] @@ -17,7 +13,7 @@ FarCopyBytes:: ; 32f7 pop af jp Bankswitch -CopyBytes:: ; 330a +CopyBytes:: ; Copy bc bytes from hl to de ld a, b and a @@ -32,7 +28,7 @@ CopyBytes:: ; 330a jr nz, .next ret -CopyBytesSmall:: ; 331a +CopyBytesSmall:: ; Copy c bytes from hl to de ld a, [hli] ld [de], a @@ -41,7 +37,7 @@ CopyBytesSmall:: ; 331a jr nz, CopyBytesSmall ret -GetFarByte:: ; 3321 +GetFarByte:: ld [wBuffer], a ldh a, [hROMBank] push af @@ -54,7 +50,7 @@ GetFarByte:: ; 3321 ld a, [wBuffer] ret -ByteFill:: ; 3339 +ByteFill:: push af ld a, b and a @@ -82,13 +78,13 @@ UncompressSpriteFromDE:: ld [hl], d jp UncompressSpriteData -BackUpTilesToBuffer:: ; 3355 +BackUpTilesToBuffer:: hlcoord 0, 0 decoord 0, 0, wTileMapBackup ld bc, SCREEN_HEIGHT * SCREEN_WIDTH jp CopyBytes -ReloadTilesFromBuffer:: ; 3361 +ReloadTilesFromBuffer:: xor a ldh [hBGMapMode], a hlcoord 0, 0, wTileMapBackup @@ -111,4 +107,4 @@ CopyString:: ld [hli], a cp "@" jr nz, CopyString - ret
\ No newline at end of file + ret diff --git a/home/copy2.asm b/home/copy2.asm index 1a30e63..a55ecb8 100644 --- a/home/copy2.asm +++ b/home/copy2.asm @@ -5,20 +5,20 @@ SECTION "home/copy2.asm", ROM0 RedrawPlayerSprite:: jpab _RedrawPlayerSprite -LoadFont:: ; 00:0d0a +LoadFont:: jpab LoadFontGraphics LoadFontsBattleExtra:: jpab LoadPokemonMenuGraphics -LoadFontExtra:: ; 00:0d1a +LoadFontExtra:: jpab LoadFontExtraGraphicsWithCursor LoadToolgearGraphics:: jpab LoadToolgearGraphicsDebug -FarCopyData: ; d2a (0:d2a) -; Identical to FarCopyBytes except for tail call optimization +FarCopyData: +; Identical to FarCopyBytes except for tail call optimization. ; Copy bc 2bpp bytes from a:hl to de. ld [wBuffer], a ldh a, [hROMBank] @@ -30,7 +30,7 @@ FarCopyData: ; d2a (0:d2a) call Bankswitch ret -FarCopyDataDouble: ; d3e (0:d3e) +FarCopyDataDouble: ; Copy and expand bc 1bpp bytes from a:hl to de. ld [wBuffer], a ldh a, [hROMBank] @@ -64,7 +64,7 @@ FarCopyDataDouble: ; d3e (0:d3e) call Bankswitch ret -Request2bpp:: ; d68 (0:d68) +Request2bpp:: ; Wait for the next VBlank, then copy c 2bpp ; tiles from b:de to hl, 8 tiles at a time. ; This takes c/8 frames. @@ -104,7 +104,7 @@ Request2bpp:: ; d68 (0:d68) ld c, a jr .loop -Request1bpp:: ; da6 (0:da6) +Request1bpp:: ; Wait for the next VBlank, then copy c 1bpp ; tiles from b:de to hl, 8 tiles at a time. ; This takes c/8 frames. @@ -144,15 +144,16 @@ Request1bpp:: ; da6 (0:da6) ld c, a jr .loop -Get2bpp:: ; de4 (0:de4) -; Copy c 2bpp tiles from b:de to hl in VRAM -; using VBlank service or direct copy in -; case LCD is off +Get2bpp:: +; Copy c 2bpp tiles from b:de to hl in VRAM using +; VBlank service or direct copy in case LCD is off. ldh a, [rLCDC] bit rLCDC_ENABLE, a jp nz, Request2bpp ; copy video data during vblank while screen is on -Copy2bpp:: ; 0deb - push hl ; convert to FarCopyData call + ; fallthrough + +Copy2bpp:: + push hl ld h, d ld l, e pop de @@ -168,14 +169,15 @@ Copy2bpp:: ; 0deb pop af jp FarCopyData -Get1bpp: ; dff (0:dff) -; Copy c 1bpp tiles from b:de to hl in VRAM -; using VBlank service or direct copy in -; case LCD is off +Get1bpp: +; Copy c 1bpp tiles from b:de to hl in VRAM using +; VBlank service or direct copy in case LCD is off. ldh a, [rLCDC] bit rLCDC_ENABLE, a jp nz, Request1bpp -Copy1bpp:: ; 0e06 + ; fallthrough + +Copy1bpp:: push de ld d, h ld e, l @@ -191,4 +193,3 @@ Copy1bpp:: ; 0e06 pop af pop hl jp FarCopyDataDouble -; 0xe18
\ No newline at end of file diff --git a/home/cry.asm b/home/cry.asm index 02a281b..075386a 100644 --- a/home/cry.asm +++ b/home/cry.asm @@ -7,15 +7,15 @@ PlayStereoCry:: ld a, $1 ld [wc1b9], a pop af - jr asm_39c3 + jr _PlayCry -PlayCry:: ; 00:39ba +PlayCry:: push af xor a ld [wc1b9], a ld [wc1ba], a pop af -asm_39c3: ; 00:39c3 +_PlayCry: push hl push de push bc @@ -58,7 +58,7 @@ LoadCryHeader:: call Bankswitch ret -GetCryIndex:: ; 00:3a02 +GetCryIndex:: ld d, a ld a, [wce37] push af @@ -74,22 +74,22 @@ GetCryIndex:: ; 00:3a02 ret PrintLevel:: - ld a, $6e + ld a, $6e ; ":L" ld [hli], a ld c, 2 - ld a, [wcd9e] + ld a, [wLoadedMonLevel] cp 100 - jr c, asm_3a37 + jr c, _PrintLevelCommon dec hl inc c - jr asm_3a37 + jr _PrintLevelCommon PrintLevelFullWidth:: - ld a, $6e + ld a, $6e ; ":L" ld [hli], a ld c, 3 - ld a, [wcd9e] -asm_3a37: ; 00:3a37 + ld a, [wLoadedMonLevel] +_PrintLevelCommon: ld [wce37], a ld de, wce37 ld b, PRINTNUM_RIGHTALIGN | 1 @@ -98,7 +98,7 @@ asm_3a37: ; 00:3a37 Function3a42:: ld hl, wce2e ld c, a - ld b, $0 + ld b, 0 add hl, bc ld a, [hl] - ret
\ No newline at end of file + ret diff --git a/home/delay.asm b/home/delay.asm index 2f8ec13..48b855c 100644 --- a/home/delay.asm +++ b/home/delay.asm @@ -19,4 +19,4 @@ DelayFrames:: call DelayFrame dec c jr nz, DelayFrames - ret
\ No newline at end of file + ret diff --git a/home/fade.asm b/home/fade.asm index 4da54a0..21a5a7b 100644 --- a/home/fade.asm +++ b/home/fade.asm @@ -1,15 +1,11 @@ include "constants.asm" -; if DEBUG SECTION "home/fade.asm", ROM0 -; else -; SECTION "DMG Palette Fade Effect", ROM0 [$0307] -; endc -Function0343:: ; 0343 - ld a, [wTimeOfDayPal] +Function0343:: + ld a, [wTimeOfDayPal] ; tells if current map is dark ld b, a - ld hl, IncGradGBPalTable_11 ; $39f + ld hl, FadePal4 ld a, l sub b ld l, a @@ -24,17 +20,17 @@ Function0343:: ; 0343 ld [rOBP1], a ret -RotateFourPalettesRight:: - ld hl, IncGradGBPalTable_08 ; $396 - ld b, $4 - jr RotatePalettesRight +GBFadeInFromBlack:: + ld hl, FadePal1 + ld b, 4 + jr _GBFadeIncCommon -RotateThreePalettesRight:: - ld hl, IncGradGBPalTable_13 ; $3a5 - ld b, $3 -RotatePalettesRight:: ; 0366 -; Rotate palettes to the right and fill with loaded colors from the left -; If we're already at the leftmost color, fill with the leftmost color +GBFadeOutToWhite:: + ld hl, FadePal6 + ld b, 3 +_GBFadeIncCommon: +; Rotate palettes to the right and fill with loaded colors from the left. +; If we're already at the leftmost color, fill with the leftmost color. .loop ld a, [hli] ld [rBGP], a @@ -42,23 +38,23 @@ RotatePalettesRight:: ; 0366 ld [rOBP0], a ld a, [hli] ld [rOBP1], a - ld c, $8 + ld c, 8 call DelayFrames dec b jr nz, .loop ret -RotateFourPalettesLeft:: - ld hl, IncGradGBPalTable_12 - 1 ; $3a1 - ld b, $4 - jr RotatePalettesLeft +GBFadeOutToBlack:: + ld hl, FadePal5 - 1 + ld b, 4 + jr _GBFadeDecCommon -RotateThreePalettesLeft:: - ld hl, IncGradGBPalTable_15 - 1 ; $3aa - ld b, $3 -RotatePalettesLeft:: ; 0384 -; Rotate palettes to the left and fill with loaded colors from the right -; If we're already at the rightmost color, fill with the rightmost color +GBFadeInFromWhite:: + ld hl, FadePal8 - 1 + ld b, 3 +_GBFadeDecCommon: +; Rotate palettes to the left and fill with loaded colors from the right. +; If we're already at the rightmost color, fill with the rightmost color. .loop ld a, [hld] ld [rOBP1], a @@ -66,30 +62,18 @@ RotatePalettesLeft:: ; 0384 ld [rOBP0], a ld a, [hld] ld [rBGP], a - ld c, $8 + ld c, 8 call DelayFrames dec b jr nz, .loop ret -; IncGradGBPalTable_00:: db %11111111, %11111111, %11111111 -; IncGradGBPalTable_01:: db %11111110, %11111110, %11111110 -; IncGradGBPalTable_02:: db %11111001, %11111001, %11111001 -; IncGradGBPalTable_03:: db %11100100, %11100100, %11100100 - -; IncGradGBPalTable_04:: db %11100100, %11100100, %11100100 -; IncGradGBPalTable_05:: db %10010000, %10010000, %10010000 -; IncGradGBPalTable_06:: db %01000000, %01000000, %01000000 - -; IncGradGBPalTable_07:: db %00000000, %00000000, %00000000 -; bgp obp1 obp2 -IncGradGBPalTable_08:: db %11111111, %11111111, %11111111 -IncGradGBPalTable_09:: db %11111110, %11111110, %11111000 -IncGradGBPalTable_10:: db %11111001, %11100100, %11100100 -IncGradGBPalTable_11:: db %11100100, %11010000, %11100000 - -IncGradGBPalTable_12:: db %11100100, %11010000, %11100000 -IncGradGBPalTable_13:: db %10010000, %10000000, %10010000 -IncGradGBPalTable_14:: db %01000000, %01000000, %01000000 - -IncGradGBPalTable_15:: db %00000000, %00000000, %00000000
\ No newline at end of file +FadePal1:: db %11111111, %11111111, %11111111 +FadePal2:: db %11111110, %11111110, %11111000 +FadePal3:: db %11111001, %11100100, %11100100 +FadePal4:: db %11100100, %11010000, %11100000 +; rBGP rOBP0 rOBP1 +FadePal5:: db %11100100, %11010000, %11100000 +FadePal6:: db %10010000, %10000000, %10010000 +FadePal7:: db %01000000, %01000000, %01000000 +FadePal8:: db %00000000, %00000000, %00000000 diff --git a/home/farcall.asm b/home/farcall.asm index 7f4d759..ccc6bca 100644 --- a/home/farcall.asm +++ b/home/farcall.asm @@ -1,12 +1,8 @@ INCLUDE "constants.asm" -; if DEBUG SECTION "home/farcall.asm", ROM0 -; else -; SECTION "FarCall", ROM0[$2F6C] -; endc -FarCall_hl:: ; 2fa8 +FarCall_hl:: push af ld a, b ld [wFarCallBCBuffer], a @@ -27,7 +23,7 @@ FarCall_hl:: ; 2fa8 ld c, a ret -.return +.return: ld a, b ld [wFarCallBCBuffer], a ld a, c @@ -39,4 +35,4 @@ FarCall_hl:: ; 2fa8 ld b, a ld a, [wFarCallBCBuffer + 1] ld c, a - ret
\ No newline at end of file + ret diff --git a/home/init.asm b/home/init.asm index 7407f63..4c06359 100644 --- a/home/init.asm +++ b/home/init.asm @@ -1,29 +1,24 @@ INCLUDE "constants.asm" + +SECTION "NULL", ROM0 +NULL:: + + SECTION "home/init.asm@Entry point", ROM0 nop jp Init + SECTION "home/init.asm@Global check value", ROM0 -; The ROM has an incorrect global check, so set it here -; It is not corrected by RGBFIX -if def(GOLD) -if DEBUG - db $21, $C6 -else - db $7e, $49 -endc -else -if DEBUG - db $c9, $2f -else - db $b1, $7a -endc -endc +; The ROM has an incorrect global check, so set it here. +; It is not corrected by RGBFIX. + dw $C621 + SECTION "home/init.asm@Init", ROM0 -Reset: ; 51c (0:051c) +Reset: call DisableAudio call ClearPalettes ei @@ -34,9 +29,9 @@ Reset: ; 51c (0:051c) ld c, 32 call DelayFrames - jr Init + jr Init ; pointless -Init: ; 052f +Init: di xor a ld [rIF], a @@ -61,15 +56,17 @@ Init: ; 052f ld sp, wStackBottom call ClearVRAM + ld hl, WRAM0_Begin ld bc, WRAM1_End - WRAM0_Begin -.ByteFill ; 0565 +.clear_loop ld [hl], 0 inc hl dec bc ld a, b or c - jr nz, .ByteFill + jr nz, .clear_loop + ld hl, HRAM_Begin ld bc, HRAM_End - HRAM_Begin call ByteFill @@ -129,7 +126,7 @@ Init: ; 052f ld [MBC3SRamEnable], a jp GameInit -ClearVRAM: ; 05e6 +ClearVRAM: ld hl, VRAM_Begin ld bc, VRAM_End - VRAM_Begin xor a @@ -137,13 +134,11 @@ ClearVRAM: ; 05e6 ret BlankBGMap: - ld a, $7f + ld a, " " jr _FillBGMap FillBGMap: ld a, l - ; fallthrough - _FillBGMap: ld de, BG_MAP_WIDTH * BG_MAP_HEIGHT ld l, e @@ -153,4 +148,4 @@ _FillBGMap: jr nz, .loop dec d jr nz, .loop - ret
\ No newline at end of file + ret diff --git a/home/interrupts.asm b/home/interrupts.asm index 949b351..50a99fb 100644 --- a/home/interrupts.asm +++ b/home/interrupts.asm @@ -1,5 +1,6 @@ INCLUDE "constants.asm" + SECTION "home/interrupts.asm@VBlank interrupt vector", ROM0 jp VBlank @@ -18,11 +19,11 @@ SECTION "home/interrupts.asm@Joypad interrupt vector", ROM0 SECTION "home/interrupts.asm@Timer dummy interrupt", ROM0 -TimerDummy: ; 042a +TimerDummy: reti SECTION "home/interrupts.asm@Joypad dummy interrupt", ROM0 -JoypadDummy: ; 07f7 - reti
\ No newline at end of file +JoypadDummy: + reti diff --git a/home/items.asm b/home/items.asm index f37a4df..c31d3b0 100755 --- a/home/items.asm +++ b/home/items.asm @@ -1,12 +1,9 @@ INCLUDE "constants.asm" -; if DEBUG + SECTION "home/items.asm@TossItem", ROM0 -; else -; SECTION "TossItem", ROM0[$3207] -; endc -TossItem: ; 00:3243 +TossItem: ldh a, [hROMBank] push af ld a, BANK(_TossItem) @@ -22,7 +19,7 @@ TossItem: ; 00:3243 call Bankswitch ret -ReceiveItem:: ; 3259 +ReceiveItem:: ; function to add an item (in varying quantities) to the player's bag or PC box ; INPUT: ; HL = address of inventory (either wNumBagItems or wNumBoxItems) @@ -45,11 +42,8 @@ ReceiveItem:: ; 3259 pop bc ret -; if DEBUG + SECTION "home/items.asm@GiveItem", ROM0 -; else -; SECTION "GiveItem", ROM0[$3630] -; endc GiveItem:: ; Give player quantity c of item b, @@ -66,4 +60,4 @@ GiveItem:: call GetItemName call CopyStringToStringBuffer2 scf - ret
\ No newline at end of file + ret diff --git a/home/joypad.asm b/home/joypad.asm index 6581413..b68cb32 100644 --- a/home/joypad.asm +++ b/home/joypad.asm @@ -1,5 +1,6 @@ INCLUDE "constants.asm" + SECTION "home/joypad.asm", ROM0 ClearJoypad:: @@ -10,7 +11,8 @@ ClearJoypad:: ldh [hJoyState], a ret -Joypad:: ; 7fe (0:7fe) + +Joypad:: ; Read the joypad register and translate it to something more ; workable for use in-game. There are 8 buttons, so we can use ; one byte to contain all player input. @@ -68,7 +70,7 @@ Joypad:: ; 7fe (0:7fe) jp z, Reset ret -GetJoypad:: ; 84a (0:84a) +GetJoypad:: ; Update mirror joypad input from hJoypadState (real input) ; hJoyReleased, hJoyDown and hJoyState are synchronized @@ -104,7 +106,7 @@ GetJoypad:: ; 84a (0:84a) pop af ret -JoyTitleScreenInput:: ; 869 (0:869) +JoyTitleScreenInput:: ; Check if any of the following conditions ; is met for c frames ; - B, Select and Up keys are pressed in same frame @@ -132,7 +134,7 @@ JoyTitleScreenInput:: ; 869 (0:869) scf ret -GetJoypadDebounced:: ; 884 (0:884) +GetJoypadDebounced:: ; Update hJoySum joypad input from either hJoyDown or ; hJoyState depending on hJoyDebounceSrc. ; hJoyState is only updated every 5 frames and @@ -166,7 +168,7 @@ GetJoypadDebounced:: ; 884 (0:884) ret ; 0x8ad -TextboxWaitPressAorB_BlinkCursor: ; 8ad (0:8ad) +TextboxWaitPressAorB_BlinkCursor: ; Show a blinking cursor in the lower right-hand ; corner of a textbox and wait until A or B is ; pressed. @@ -197,7 +199,7 @@ TextboxWaitPressAorB_BlinkCursor: ; 8ad (0:8ad) ldh [hSpriteWidth], a ret -ButtonSound:: ; 8d2 (0:8d2) +ButtonSound:: ld a, [wLinkMode] cp $03 jr z, .link @@ -211,7 +213,7 @@ ButtonSound:: ; 8d2 (0:8d2) ld c, $41 jp DelayFrames -WaitAorB_BlinkCursor:: ; 8ea (0:8ea) +WaitAorB_BlinkCursor:: .loop call BlinkCursor call GetJoypadDebounced @@ -225,7 +227,7 @@ WaitAorB_BlinkCursor:: ; 8ea (0:8ea) call DelayFrame jr .loop -BlinkCursor: ; 904 (0:904) +BlinkCursor: ; Show a blinking cursor in the lower right-hand ; corner of the screen ; Will toggle between cursor and blank every @@ -241,7 +243,7 @@ BlinkCursor: ; 904 (0:904) ldcoord_a (SCREEN_WIDTH - 2), (SCREEN_HEIGHT - 1) ret -TextboxBlinkCursor:: ; 914 (0:914) +TextboxBlinkCursor:: ; Show a blinking cursor at the specified position ; that toggles between down arrow and horizontal textbox ; frame tile. @@ -290,4 +292,4 @@ TextboxBlinkCursor:: ; 914 (0:914) ldh [hTextBoxCursorBlinkInterval + 1], a ; reset to 0x6FF iterations ld a, "▼" ld [hl], a - ret
\ No newline at end of file + ret diff --git a/home/jumptable.asm b/home/jumptable.asm index 4f9294f..03947bf 100644 --- a/home/jumptable.asm +++ b/home/jumptable.asm @@ -1,22 +1,17 @@ INCLUDE "constants.asm" -; if DEBUG SECTION "home/jumptable.asm", ROM0 -; else -; SECTION "Jumptable functions", ROM0[$3591] -; endc -CallJumptable:: ; 35cd (0:35cd) +CallJumptable:: ; CallJumptable ; Call function whose pointer is ; at index a in 2-byte pointer table ; pointed to by hl. ; Clobbers: a, hl ; -; This ultimately wound up at rst $28 in -; GSC +; This became rst $28 in final GSC. push de - ld d, $00 + ld d, 0 ld e, a add hl, de add hl, de @@ -38,10 +33,11 @@ CallFar_atHL:: ld a, [hli] ld h, [hl] ld l, a - call .jump + call ._hl_ pop hl ld a, h call Bankswitch ret -.jump: ; 35eb (0:35eb) - jp hl
\ No newline at end of file + +._hl_: + jp hl diff --git a/home/lcd.asm b/home/lcd.asm index 4553f09..5565786 100644 --- a/home/lcd.asm +++ b/home/lcd.asm @@ -2,7 +2,7 @@ INCLUDE "constants.asm" SECTION "home/lcd.asm", ROM0 -LCD:: ; 03ae +LCD:: push af ldh a, [hLCDCPointer] and a @@ -44,13 +44,10 @@ LCD:: ; 03ae pop af reti - -; 0:3e1 ; TODO: can this be done using `sine_table`? db 0, 1, 2, 2, 3, 3, 4, 4, 4, 4, 4, 3, 3, 2, 2, 1, 0, -1, -2, -2, -3, -3, -4, -4, -4, -4, -4, -3, -3, -2, -2, -1 - -DisableLCD:: ; 0401 +DisableLCD:: ld a, [rLCDC] bit 7, a ret z @@ -73,8 +70,8 @@ DisableLCD:: ; 0401 ld [rIE], a ret -EnableLCD:: ; 0423 +EnableLCD:: ld a, [rLCDC] set 7, a ld [rLCDC], a - ret
\ No newline at end of file + ret diff --git a/home/map.asm b/home/map.asm index 58c568d..9e6da75 100644 --- a/home/map.asm +++ b/home/map.asm @@ -1731,4 +1731,4 @@ Function2be5:: ; 00:2be5 ; TODO jp hl .Return: ; 00:2c04 - ret
\ No newline at end of file + ret diff --git a/home/map_objects.asm b/home/map_objects.asm index 69bd60b..1362c84 100644 --- a/home/map_objects.asm +++ b/home/map_objects.asm @@ -685,4 +685,4 @@ SetObjectFacing:: ; 19C0 ld hl, OBJECT_DIRECTION_WALKING add hl, bc ld [hl], a - ret
\ No newline at end of file + ret diff --git a/home/math.asm b/home/math.asm index dd7718d..c9d9f5c 100644 --- a/home/math.asm +++ b/home/math.asm @@ -1,10 +1,6 @@ include "constants.asm" -; if DEBUG SECTION "home/math.asm", ROM0 -; else -; SECTION "Math utility functions", ROM0 [$3344] -; endc Multiply:: push hl @@ -22,4 +18,4 @@ Divide:: pop bc pop de pop hl - ret
\ No newline at end of file + ret diff --git a/home/menu.asm b/home/menu.asm index 3199400..e9d41bb 100644 --- a/home/menu.asm +++ b/home/menu.asm @@ -2,17 +2,17 @@ include "constants.asm" SECTION "home/menu.asm", ROM0 -LoadMenuHeader:: ; 00:1d49 +LoadMenuHeader:: call CopyMenuHeader call PushWindow ret -CopyMenuHeader:: ; 00:1d50 +CopyMenuHeader:: ld de, wMenuDataHeader - ld bc, $10 + ld bc, wMenuDataHeaderEnd - wMenuDataHeader jp CopyBytes -MenuTextBox:: ; 00:1d59 +MenuTextBox:: push hl ld hl, .Data call LoadMenuHeader @@ -38,17 +38,17 @@ LoadStandardMenuHeader:: call LoadMenuHeader ret -.Data: ; 00:1d7b +.Data: db MENU_BACKUP_TILES ; flags menu_coords 0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1 - dw 0 + dw NULL db 1 ; default option Call_ExitMenu:: call ExitMenu ret -VerticalMenu:: ; 00:1d87 +VerticalMenu:: xor a ldh [hBGMapMode], a call MenuBox @@ -105,7 +105,7 @@ PlaceGenericTwoOptionBox:: call LoadMenuHeader jr asm_1df9 -asm_1ddc: ; 00:1ddc +asm_1ddc: push bc ld hl, YesNoMenuHeader call CopyMenuHeader @@ -119,7 +119,7 @@ asm_1ddc: ; 00:1ddc add 4 ld [wMenuBorderBottomCoord], a call PushWindow -asm_1df9: ; 00:1df9 +asm_1df9: call VerticalMenu push af ld c, 15 @@ -133,13 +133,13 @@ asm_1df9: ; 00:1df9 and a ret -.asm_1e11: ; 00:1e11 - ld a, $2 +.asm_1e11: + ld a, 2 ld [wMenuCursorY], a scf ret -YesNoMenuHeader:: ; 00:1e18 +YesNoMenuHeader:: db MENU_BACKUP_TILES ; flags menu_coords 10, 5, 15, 9 dw .MenuData @@ -156,7 +156,7 @@ OffsetMenuHeader:: call PushWindow ret -_OffsetMenuHeader:: ; 00:1e30 +_OffsetMenuHeader:: push de call CopyMenuHeader pop de @@ -164,7 +164,7 @@ _OffsetMenuHeader:: ; 00:1e30 ld h, a ld a, [wMenuBorderRightCoord] sub h -.asm_1e3d: ; 00:1e3d +.asm_1e3d: ld h, a ld a, d ld [wMenuBorderLeftCoord], a @@ -181,7 +181,7 @@ _OffsetMenuHeader:: ; 00:1e30 ld [wMenuBorderBottomCoord], a ret -OpenMenu:: ; 00:1e58 +OpenMenu:: call CopyMenuData call GetMenuIndexSet push de @@ -205,7 +205,7 @@ OpenMenu:: ; 00:1e58 call Function1f27 ret -Function1e8a:: ; 00:1e8a +Function1e8a:: xor a ldh [hBGMapMode], a xor a @@ -224,7 +224,7 @@ Function1e8a:: ; 00:1e8a dec [hl] ret -AutomaticGetMenuBottomCoord:: ; 00:1eac +AutomaticGetMenuBottomCoord:: ld a, [wMenuBorderLeftCoord] ld c, a ld a, [wMenuBorderRightCoord] @@ -239,7 +239,7 @@ AutomaticGetMenuBottomCoord:: ; 00:1eac ld [wMenuBorderBottomCoord], a ret -GetMenuIndexSet:: ; 00:1ec3 +GetMenuIndexSet:: ld hl, wMenuDataIndicesPointer ld a, [hli] ld h, [hl] @@ -249,18 +249,18 @@ GetMenuIndexSet:: ; 00:1ec3 jr z, .asm_1ed9 ld b, a ld c, -1 -.asm_1ed2: ; 00:1ed2 +.asm_1ed2: ld a, [hli] cp c jr nz, .asm_1ed2 dec b jr nz, .asm_1ed2 -.asm_1ed9: ; 00:1ed9 +.asm_1ed9: ld d, h ld e, l inc hl ld c, $ff -.asm_1ede: ; 00:1ede +.asm_1ede: inc c ld a, [hli] cp $ff @@ -269,7 +269,7 @@ GetMenuIndexSet:: ; 00:1ec3 ld [wMenuDataItems], a ret -Function1ee9:: ; 1ee9 +Function1ee9:: call MenuBoxCoord2Tile call GetMenuBoxDims ld a, [wMenuDataItems] @@ -280,7 +280,7 @@ Function1ee9:: ; 1ee9 dec c ret -.asm_1ef9: ; 00:1ef9 +.asm_1ef9: ld a, b srl a dec a @@ -288,7 +288,7 @@ Function1ee9:: ; 1ee9 dec c ret -RunMenuItemPrintingFunction:: ; 00:1f02 +RunMenuItemPrintingFunction:: call MenuBoxCoord2Tile ld bc, 2 * SCREEN_WIDTH + 2 add hl, bc @@ -316,7 +316,7 @@ RunMenuItemPrintingFunction:: ; 00:1f02 ld l, a jp hl -Function1f27:: ; 00:1f27 +Function1f27:: ; Combines Crystal functions "InitMenuCursorAndButtonPermissions" and "GetStaticMenuJoypad" push de call InitVerticalMenuCursor @@ -325,13 +325,13 @@ Function1f27:: ; 00:1f27 bit 3, a jr z, .asm_1f37 set 3, [hl] -.asm_1f37: ; 00:1f37 +.asm_1f37: bit 2, a jr z, .asm_1f3f ld a, [hl] or D_LEFT | D_RIGHT ld [hl], a -.asm_1f3f: ; 00:1f3f +.asm_1f3f: call Get2DMenuJoypad pop de bit 0, a @@ -346,20 +346,20 @@ Function1f27:: ; 00:1f27 jr nz, .asm_1f5f ret -.asm_1f58: ; 00:1f58 +.asm_1f58: ld a, D_RIGHT ld [wMenuJoypad], a jr .asm_1f6b -.asm_1f5f: ; 00:1f5f +.asm_1f5f: ld a, D_LEFT ld [wMenuJoypad], a jr .asm_1f6b -.asm_1f66: ; 00:1f66 +.asm_1f66: ld a, A_BUTTON ld [wMenuJoypad], a -.asm_1f6b: ; 00:1f6b +.asm_1f6b: ld a, [wMenuCursorY] ld l, a ld h, $0 @@ -371,7 +371,7 @@ Function1f27:: ; 00:1f27 and a ret -.asm_1f7e: ; 00:1f7e +.asm_1f7e: ld a, B_BUTTON ld [wMenuJoypad], a ld a, -1 @@ -393,15 +393,15 @@ PlaceMenuStrings:: call PlaceString ret -ClearWindowData:: ; 00:1f9e +ClearWindowData:: ld hl, wWindowStackPointer - call .bytefill + call .clear ld hl, wMenuDataHeader - call .bytefill + call .clear ld hl, wMenuData2 - call .bytefill + call .clear ld hl, wMenuData3 - call .bytefill + call .clear xor a call OpenSRAM @@ -418,8 +418,8 @@ ClearWindowData:: ; 00:1f9e call CloseSRAM ret -.bytefill: ; 00:1fcc - ld bc, 16 +.clear: + ld bc, wMenuDataHeaderEnd - wMenuDataHeader xor a call ByteFill - ret
\ No newline at end of file + ret diff --git a/home/menu_window.asm b/home/menu_window.asm index 4911863..5f8465e 100644 --- a/home/menu_window.asm +++ b/home/menu_window.asm @@ -7,7 +7,7 @@ SetMenuAttributes:: push bc ld hl, wMenuData3 ld b, $8 -.asm_1a6b: ; 00:1a6b +.asm_1a6b: ld a, [de] inc de ld [hli], a @@ -24,14 +24,14 @@ SetMenuAttributes:: pop hl ret -Get2DMenuJoypad:: ; 00:1a7c +Get2DMenuJoypad:: call Place2DMenuCursor ld hl, w2DMenuFlags + 1 res 7, [hl] -.loop: ; 00:1a84 +.loop: call Move2DMenuCursor call WaitBGMap -.asm_1a8a: ; 00:1a8a +.asm_1a8a: call UpdateTime call UpdateTimeOfDayPalettes call Menu_WasButtonPressed @@ -41,7 +41,7 @@ Get2DMenuJoypad:: ; 00:1a7c jp nz, .done jr .asm_1a8a -.asm_1a9f: ; 00:1a9f +.asm_1a9f: call _2DMenuInterpretJoypad jp c, .done ld a, [w2DMenuFlags] @@ -52,7 +52,7 @@ Get2DMenuJoypad:: ; 00:1a7c ld a, [wMenuJoypadFilter] and b jp z, .loop -.done: ; 00:1ab6 +.done: ldh a, [hJoyDown] and A_BUTTON | B_BUTTON jr z, .asm_1ac4 @@ -60,16 +60,16 @@ Get2DMenuJoypad:: ; 00:1a7c ld de, SE_SELECT call PlaySFX pop de -.asm_1ac4: ; 00:1ac4 +.asm_1ac4: ldh a, [hJoySum] ret -Menu_WasButtonPressed:: ; 00:1ac7 +Menu_WasButtonPressed:: ld a, [w2DMenuFlags] bit 6, a jr z, .asm_1ad6 callba PlaySpriteAnimationsAndDelayFrame -.asm_1ad6: ; 00:1ad6 +.asm_1ad6: call GetJoypadDebounced ldh a, [hJoySum] and a @@ -77,7 +77,7 @@ Menu_WasButtonPressed:: ; 00:1ac7 scf ret -_2DMenuInterpretJoypad:: ; 00:1adf +_2DMenuInterpretJoypad:: ldh a, [hJoySum] bit A_BUTTON_F, a jp nz, .PressedABStartOrSelect @@ -98,13 +98,13 @@ _2DMenuInterpretJoypad:: ; 00:1adf and a ret -.SetFlag15AndCarry: ; 00:1b07 +.SetFlag15AndCarry: ld hl, w2DMenuFlags + 1 set 7, [hl] scf ret -.PressedDown: ; 00:1b0e +.PressedDown: ld hl, wMenuCursorY ld a, [w2DMenuNumRows] cp [hl] @@ -113,7 +113,7 @@ _2DMenuInterpretJoypad:: ; 00:1adf xor a ret -.asm_1b1a: ; 00:1b1a +.asm_1b1a: ld a, [w2DMenuFlags] bit 5, a jr nz, .asm_1b28 @@ -122,12 +122,12 @@ _2DMenuInterpretJoypad:: ; 00:1adf xor a ret -.asm_1b28: ; 00:1b28 +.asm_1b28: ld [hl], $1 xor a ret -.PressedUp: ; 00:1b2c +.PressedUp: ld hl, wMenuCursorY ld a, [hl] dec a @@ -136,7 +136,7 @@ _2DMenuInterpretJoypad:: ; 00:1adf xor a ret -.asm_1b36: ; 00:1b36 +.asm_1b36: ld a, [w2DMenuFlags] bit 5, a jr nz, .asm_1b44 @@ -145,13 +145,13 @@ _2DMenuInterpretJoypad:: ; 00:1adf xor a ret -.asm_1b44: ; 00:1b44 +.asm_1b44: ld a, [w2DMenuNumRows] ld [hl], a xor a ret -.PressedLeft: ; 00:1b4a +.PressedLeft: ld hl, wMenuCursorX ld a, [hl] dec a @@ -160,7 +160,7 @@ _2DMenuInterpretJoypad:: ; 00:1adf xor a ret -.asm_1b54: ; 00:1b54 +.asm_1b54: ld a, [w2DMenuFlags] bit 4, a jr nz, .asm_1b62 @@ -169,13 +169,13 @@ _2DMenuInterpretJoypad:: ; 00:1adf xor a ret -.asm_1b62: ; 00:1b62 +.asm_1b62: ld a, [w2DMenuNumCols] ld [hl], a xor a ret -.PressedRight: ; 00:1b68 +.PressedRight: ld hl, wMenuCursorX ld a, [w2DMenuNumCols] cp [hl] @@ -184,7 +184,7 @@ _2DMenuInterpretJoypad:: ; 00:1adf xor a ret -.asm_1b74: ; 00:1b74 +.asm_1b74: ld a, [w2DMenuFlags] bit 4, a jr nz, .asm_1b82 @@ -193,16 +193,16 @@ _2DMenuInterpretJoypad:: ; 00:1adf xor a ret -.asm_1b82: ; 00:1b82 +.asm_1b82: ld [hl], $1 xor a ret -.PressedABStartOrSelect: ; 00:1b86 +.PressedABStartOrSelect: xor a ret -Move2DMenuCursor:: ; 00:1b88 +Move2DMenuCursor:: ld hl, wCursorCurrentTile ld a, [hli] ld h, [hl] @@ -212,7 +212,7 @@ Move2DMenuCursor:: ; 00:1b88 jr nz, Place2DMenuCursor ld a, [wCursorOffCharacter] ld [hl], a -Place2DMenuCursor:: ; 00:1b97 +Place2DMenuCursor:: ld a, [w2DMenuCursorInitY] ld b, a ld a, [w2DMenuCursorInitX] @@ -227,11 +227,11 @@ Place2DMenuCursor:: ; 00:1b97 xor a dec b jr z, .asm_1bb6 -.asm_1bb2: ; 00:1bb2 +.asm_1bb2: add c dec b jr nz, .asm_1bb2 -.asm_1bb6: ; 00:1bb6 +.asm_1bb6: ld c, SCREEN_WIDTH call AddNTimes ld a, [w2DMenuCursorOffsets] @@ -242,11 +242,11 @@ Place2DMenuCursor:: ; 00:1b97 xor a dec b jr z, .asm_1bcd -.asm_1bc9: ; 00:1bc9 +.asm_1bc9: add c dec b jr nz, .asm_1bc9 -.asm_1bcd: ; 00:1bcd +.asm_1bcd: ld c, a add hl, bc ld a, [hl] @@ -254,7 +254,7 @@ Place2DMenuCursor:: ; 00:1b97 jr z, .asm_1bd9 ld [wCursorOffCharacter], a ld [hl], $ed -.asm_1bd9: ; 00:1bd9 +.asm_1bd9: ld a, l ld [wCursorCurrentTile], a ld a, h @@ -277,19 +277,19 @@ HideCursor:: ld [hl], $7f ret -PushWindow:: ; 00:1bf4 +PushWindow:: ld hl, PlaceWaitingText ld a, $9 jp FarCall_hl -ExitMenu:: ; 00:1bfc +ExitMenu:: push af callab _ExitMenu call Function1c0a pop af ret -Function1c0a:: ; 00:1c0a +Function1c0a:: ld a, [wVramState] bit 0, a ret z @@ -325,10 +325,10 @@ Function1c0a:: ; 00:1c0a ret -InitVerticalMenuCursor:: ; 00:1c44 +InitVerticalMenuCursor:: jpab _InitVerticalMenuCursor -CloseWindow:: ; 00:1c4c +CloseWindow:: push af call ExitMenu call WaitBGMap @@ -339,15 +339,15 @@ CloseWindow:: ; 00:1c4c Function1c58:: jpab Function24185 -RestoreTileBackup:: ; 00:1c60 +RestoreTileBackup:: call MenuBoxCoord2Tile call GetMenuBoxDims inc b inc c -.asm_1c68: ; 00:1c68 +.asm_1c68: push bc push hl -.asm_1c6a: ; 00:1c6a +.asm_1c6a: ld a, [de] ld [hli], a dec de @@ -361,10 +361,10 @@ RestoreTileBackup:: ; 00:1c60 jr nz, .asm_1c68 ret -PopWindow:: ; 00:1c7a +PopWindow:: ld b, $10 ld de, wMenuDataHeader -.asm_1c7f: ; 00:1c7f +.asm_1c7f: ld a, [hld] ld [de], a inc de @@ -372,7 +372,7 @@ PopWindow:: ; 00:1c7a jr nz, .asm_1c7f ret -GetMenuBoxDims:: ; 00:1c86 +GetMenuBoxDims:: push hl ld hl, wMenuBorderTopCoord ld a, [hli] @@ -388,7 +388,7 @@ GetMenuBoxDims:: ; 00:1c86 pop hl ret -CopyMenuData:: ; 00:1c96 +CopyMenuData:: push hl push de push bc @@ -406,7 +406,7 @@ CopyMenuData:: ; 00:1c96 pop hl ret -GetWindowStackTop:: ; 00:1cae +GetWindowStackTop:: ld hl, wWindowStackPointer ld a, [hli] ld h, [hl] @@ -417,7 +417,7 @@ GetWindowStackTop:: ; 00:1cae ld l, a ret -PlaceVerticalMenuItems:: ; 00:1cb9 +PlaceVerticalMenuItems:: call CopyMenuData ld hl, wMenuDataPointer ld e, [hl] @@ -429,7 +429,7 @@ PlaceVerticalMenuItems:: ; 00:1cb9 ld a, [de] inc de ld b, a -.asm_1ccc: ; 00:1ccc +.asm_1ccc: push bc call PlaceString inc de @@ -451,14 +451,14 @@ PlaceVerticalMenuItems:: ; 00:1cb9 add hl, bc jp PlaceString -MenuBox:: ; 00:1ceb +MenuBox:: call MenuBoxCoord2Tile call GetMenuBoxDims dec b dec c jp DrawTextBox -GetMenuTextStartCoord:: ; 00:1cf6 +GetMenuTextStartCoord:: ld a, [wMenuBorderTopCoord] ld b, a inc b @@ -469,12 +469,12 @@ GetMenuTextStartCoord:: ; 00:1cf6 bit 6, a jr nz, .asm_1d08 inc b -.asm_1d08: ; 00:1d08 +.asm_1d08 ld a, [wMenuDataFlags] bit 7, a - jr z, .asm_1d10 + jr z, .done inc c -.asm_1d10: ; 00:1d10 +.done ret ClearMenuBoxInterior:: @@ -495,12 +495,12 @@ ClearWholeMenuBox:: call ClearBox ret -MenuBoxCoord2Tile:: ; 00:1d2d +MenuBoxCoord2Tile:: ld a, [wMenuBorderLeftCoord] ld c, a ld a, [wMenuBorderTopCoord] ld b, a -Coord2Tile:: ; 00:1d35 +Coord2Tile:: xor a ld h, a ld l, b @@ -518,4 +518,4 @@ Coord2Tile:: ; 00:1d35 add hl, bc bccoord 0, 0 add hl, bc - ret
\ No newline at end of file + ret diff --git a/home/misc_32c8.asm b/home/misc_32c8.asm index ae12d23..3fafade 100644 --- a/home/misc_32c8.asm +++ b/home/misc_32c8.asm @@ -1,10 +1,6 @@ include "constants.asm" -; if DEBUG SECTION "home/misc_32c8.asm@Unknown 32c8", ROM0 -; else -; SECTION "Unknown 32c8", ROM0[$328c] -; endc Function32c8:: predef GetItemAmount @@ -13,10 +9,10 @@ Function32c8:: ret Function32d0:: - ld hl, .Data + ld hl, .EmptyString ret -.Data: ; 00:32d4 +.EmptyString: db "@" SubtractSigned:: @@ -27,13 +23,9 @@ SubtractSigned:: scf ret -; if DEBUG SECTION "home/misc_32c8.asm@Unknown 3686", ROM0 -; else -; SECTION "Unknown 3686", ROM0[$364a] -; endc -GiveMonToPlayer:: ; 3686 +GiveMonToPlayer:: ; Give to the player Pokemon of species b at level c. ld a, b ld [wMonDexIndex], a @@ -43,7 +35,7 @@ GiveMonToPlayer:: ; 3686 ld [wMonType], a jpba Function1130a -WaitPressedAny:: ; 369a +WaitPressedAny:: ; Waits for one of the buttons in d to be pressed. ; If bc is negative, waits forever. ; Otherwise, times out after bc frames then returns z. @@ -76,15 +68,15 @@ WaitPressedAny:: ; 369a ; Return z, signifying that the request timed out. ret -CountSetBits:: ; 36b1 +CountSetBits:: ; Count the number of bits set in b bytes at hl. ; Return to a, c, and wCountSetBitsResult. ld c, $0 -.asm_36b3: ; 00:36b3 +.asm_36b3: ld a, [hli] ld e, a ld d, $8 -.asm_36b7: ; 00:36b7 +.asm_36b7: srl e ld a, $0 adc c @@ -95,4 +87,4 @@ CountSetBits:: ; 36b1 jr nz, .asm_36b3 ld a, c ld [wCountSetBitsResult], a - ret
\ No newline at end of file + ret diff --git a/home/misc_3c43.asm b/home/misc_3c43.asm index 0abbd79..315856f 100644 --- a/home/misc_3c43.asm +++ b/home/misc_3c43.asm @@ -2,7 +2,7 @@ INCLUDE "constants.asm" SECTION "home/misc_3c43.asm", ROM0 -GetPartyParamLocation:: ; 3c43 (00:3c43) +GetPartyParamLocation:: ; Get the location of parameter a from wCurPartyMon in hl push bc ld hl, wPartyMons @@ -15,10 +15,10 @@ GetPartyParamLocation:: ; 3c43 (00:3c43) pop bc ret -UseItem:: ; 3c56 (00:3c56) +UseItem:: jpba _UseItem -CheckTossableItem:: ; 3c5e (00:3c5e) +CheckTossableItem:: push hl push de push bc @@ -28,7 +28,7 @@ CheckTossableItem:: ; 3c5e (00:3c5e) pop hl ret -GetBattleAnimPointer:: ; 3c6d (00:3c6d) +GetBattleAnimPointer:: ld a, BANK(BattleAnimationsBankRef) ld [MBC3RomBank], a ldh [hROMBank], a @@ -44,7 +44,7 @@ GetBattleAnimPointer:: ; 3c6d (00:3c6d) ret -GetBattleAnimByte:: ; 3c84 (00:3c84) +GetBattleAnimByte:: push hl push de @@ -75,7 +75,7 @@ GetBattleAnimByte:: ; 3c84 (00:3c84) ld a, [wBattleAnimByte] ret -InitSpriteAnimStruct:: ; 3ca8 (00:3ca8) +InitSpriteAnimStruct:: ld [wSpriteAnimIDBuffer], a ldh a, [hROMBank] push af @@ -87,5 +87,5 @@ InitSpriteAnimStruct:: ; 3ca8 (00:3ca8) call Bankswitch ret -EmptyFunction3cbe:: ; 3cbe (00:3cbe) - ret
\ No newline at end of file +EmptyFunction3cbe:: + ret diff --git a/home/mon_stats.asm b/home/mon_stats.asm index e5b16db..ed4f6a8 100644 --- a/home/mon_stats.asm +++ b/home/mon_stats.asm @@ -1,10 +1,6 @@ include "constants.asm" -; if DEBUG SECTION "home/mon_stats.asm", ROM0 -; else -; SECTION "Mon Stats", ROM0 [$390f] -; endc DrawBattleHPBar:: push hl @@ -16,7 +12,7 @@ DrawBattleHPBar:: ld [hli], a push hl ld a, $62 -.asm_3957: ; 00:3957 +.asm_3957: ld [hli], a dec d jr nz, .asm_3957 @@ -31,7 +27,7 @@ DrawBattleHPBar:: and a jr z, .asm_397d ld e, $1 -.asm_396a: ; 00:396a +.asm_396a: ld a, e sub $8 jr c, .asm_3979 @@ -43,11 +39,11 @@ DrawBattleHPBar:: jr z, .asm_397d jr .asm_396a -.asm_3979: ; 00:3979 +.asm_3979: ld a, $62 add e ld [hl], a -.asm_397d: ; 00:397d +.asm_397d: pop bc pop de pop hl @@ -60,7 +56,7 @@ _PrepMonFrontpic:: ld a, [wMonDexIndex] and a jr z, .asm_39a8 - cp 252 + cp NUM_POKEMON + 1 jr nc, .asm_39a8 push hl ld de, vFrontPic @@ -74,9 +70,9 @@ _PrepMonFrontpic:: ld [wSpriteFlipped], a ret -.asm_39a8: ; 00:39a8 +.asm_39a8: xor a ld [wSpriteFlipped], a inc a ld [wMonDexIndex], a - ret
\ No newline at end of file + ret diff --git a/home/movement.asm b/home/movement.asm index b1dd6c0..db27b1e 100644 --- a/home/movement.asm +++ b/home/movement.asm @@ -22,7 +22,7 @@ DecrementMovementBufferCount:: ld [wMovementBufferCount], a ret -AppendToMovementBuffer:: ; 00:19f2 +AppendToMovementBuffer:: push hl push de ld hl, wMovementBufferCount @@ -36,7 +36,7 @@ AppendToMovementBuffer:: ; 00:19f2 pop hl ret -AppendToMovementBufferNTimes:: ; 00:1a03 +AppendToMovementBufferNTimes:: push af ld a, c and a @@ -44,9 +44,9 @@ AppendToMovementBufferNTimes:: ; 00:1a03 pop af ret -.asm_1a0a: ; 00:1a0a +.asm_1a0a: pop af -.asm_1a0b: ; 00:1a0b +.asm_1a0b: call AppendToMovementBuffer dec c jr nz, .asm_1a0b @@ -61,7 +61,7 @@ ComputePathToWalkToPlayer:: dec a cpl ld h, RIGHT -.asm_1a1d: ; 00:1a1d +.asm_1a1d: ld d, a ld a, c sub e @@ -70,7 +70,7 @@ ComputePathToWalkToPlayer:: dec a cpl ld l, DOWN -.asm_1a28: ; 00:1a28 +.asm_1a28: ld e, a cp d jr nc, .asm_1a32 @@ -80,7 +80,7 @@ ComputePathToWalkToPlayer:: ld a, d ld d, e ld e, a -.asm_1a32: ; 00:1a32 +.asm_1a32: pop af ld b, a ld a, h @@ -93,7 +93,7 @@ ComputePathToWalkToPlayer:: call AppendToMovementBufferNTimes ret -.GetMovementData: ; 00:1a45 +.GetMovementData: push de push hl ld l, b @@ -110,11 +110,11 @@ ComputePathToWalkToPlayer:: pop de ret -.Data: ; 00:1a58 +.Data: db $04, $05, $06, $07 db $08, $09, $0a, $0b db $0c, $0d, $0e, $0f - + ; slow_step DOWN ; slow_step UP ; slow_step LEFT @@ -126,4 +126,4 @@ ComputePathToWalkToPlayer:: ; big_step DOWN ; big_step UP ; big_step LEFT -; big_step RIGHT
\ No newline at end of file +; big_step RIGHT diff --git a/home/names.asm b/home/names.asm index 7b5b995..656835a 100644 --- a/home/names.asm +++ b/home/names.asm @@ -1,12 +1,9 @@ INCLUDE "constants.asm" -; if DEBUG + SECTION "home/names.asm@Names", ROM0 -; else -; SECTION "Names", ROM0[$368c] ; Unsure -; endc -NamesPointers:: ; 00:36c8 +NamesPointers:: ; entries correspond to GetName constants (see constants/text_constants.asm) dba PokemonNames ; MON_NAME (not used; jumps to GetPokemonName) dba MoveNames ; MOVE_NAME @@ -17,7 +14,7 @@ NamesPointers:: ; 00:36c8 dba TrainerClassNames ; TRAINER_NAME dbw $04, $5677 ; MOVE_DESC_NAME_BROKEN (wrong bank..?) -GetName:: ; 00:36e0 +GetName:: ; Return name wCurSpecies from name list wNamedObjectTypeBuffer in wStringBuffer1. ldh a, [hROMBank] @@ -91,7 +88,7 @@ GetNthString:: pop bc ret -GetPokemonName: ; 00:3741 +GetPokemonName: ; Get Pokemon name wNamedObjectIndexBuffer. ldh a, [hROMBank] @@ -123,7 +120,7 @@ endr call Bankswitch ret -GetItemName:: ; 376F +GetItemName:: ; given an item ID at [wNamedObjectIndexBuffer], store the name of the item into a string ; starting at wStringBuffer1 push hl @@ -210,17 +207,17 @@ GetMachineName:: .HMTextEnd: db "@" -IsHM:: ; 00:37e4 - cp ITEM_TM01 ; ??? +IsHM:: + cp ITEM_HM01_RED jr c, .false - cp ITEM_TM05 ; ??? + cp ITEM_TM01_RED ret .false and a ret -IsHMMove:: ; 00:37ed +IsHMMove:: ld hl, .HMMoves ld de, 1 jp FindItemInTable @@ -233,7 +230,7 @@ IsHMMove:: ; 00:37ed db MOVE_FLASH db -1 -Unreferenced_GetMoveName:: ; 00:37fc +Unreferenced_GetMoveName:: push hl ld a, MOVE_NAME ld [wNamedObjectTypeBuffer], a @@ -244,13 +241,14 @@ Unreferenced_GetMoveName:: ; 00:37fc pop hl ret + SECTION "home/names.asm@GetNick", ROM0 -GetCurNick:: ; 3a91 (00:3a91) +GetCurNick:: ld a, [wWhichPokemon] ld hl, wPartyMonNicknames -GetNick: ; 00:3a97 +GetNick: ; Get nickname a from list hl. push hl push bc @@ -263,4 +261,4 @@ GetNick: ; 00:3a97 callab CorrectNickErrors pop bc pop hl - ret
\ No newline at end of file + ret diff --git a/home/oam_dma.asm b/home/oam_dma.asm index db08f0e..d48f98e 100644 --- a/home/oam_dma.asm +++ b/home/oam_dma.asm @@ -2,19 +2,19 @@ INCLUDE "constants.asm" SECTION "home/oam_dma.asm", ROMX -WriteOAMDMACodeToHRAM:: ; 4153 +WriteOAMDMACodeToHRAM:: ld c, LOW(hOAMDMA) ld b, .OAMDMAEnd - .OAMDMA ld hl, .OAMDMA .loop ld a, [hli] - ld [$ff00+c], a + ldh [c], a inc c dec b jr nz, .loop ret -.OAMDMA ; 4161 +.OAMDMA ld a, HIGH(wVirtualOAM) ldh [rDMA], a ld a, $28 @@ -22,4 +22,4 @@ WriteOAMDMACodeToHRAM:: ; 4153 dec a jr nz, .wait ret -.OAMDMAEnd ; 416b
\ No newline at end of file +.OAMDMAEnd diff --git a/home/overworld.asm b/home/overworld.asm index f276ea1..d8bf242 100644 --- a/home/overworld.asm +++ b/home/overworld.asm @@ -1,16 +1,12 @@ INCLUDE "constants.asm" -; if DEBUG + SECTION "home/overworld.asm@Startmenu and Select Button Check", ROM0 -; else -; SECTION "Startmenu and Select Button Check", ROM0[$2BDF] -; endc -OverworldStartButtonCheck:: ; 2c05 (0:2c05) +OverworldStartButtonCheck:: ldh a, [hJoyState] bit START_F, a ret z -if DEBUG and (START | B_BUTTON) cp (START | B_BUTTON) jr nz, .regularMenu @@ -20,10 +16,9 @@ if DEBUG callba InGameDebugMenu jr CheckStartmenuSelectHook .regularMenu -endc callba DisplayStartMenu jr CheckStartmenuSelectHook -SelectButtonFunction:: ; 2c2a (0:2c2a) +SelectButtonFunction:: callab CheckRegisteredItem CheckStartmenuSelectHook: ldh a, [hStartmenuCloseAndSelectHookEnable] @@ -42,7 +37,7 @@ CheckStartmenuSelectHook: dec a ret -Function2c4a: ; 2c4a (0:2c4a) +Function2c4a: ; copy of Function2ba8 ; calling Functiond4e6 instead of Functiond6e4 .loop @@ -56,7 +51,7 @@ Function2c4a: ; 2c4a (0:2c4a) scf ret -Function2c5a: ; 2c5a (0:2c5a) +Function2c5a: ldh a, [hROMBank] push af ld a, BANK(Function50b9) @@ -78,7 +73,7 @@ Function2c5a: ; 2c5a (0:2c5a) call Bankswitch ret -UpdateAndTransferToolgear: ; 2c8b (0:2c8b) +UpdateAndTransferToolgear: call DelayFrame call UpdateToolgear ld hl, wToolgearFlags @@ -86,7 +81,7 @@ UpdateAndTransferToolgear: ; 2c8b (0:2c8b) call DelayFrame ret -ScheduleNorthRowRedraw: ; 2c9a (0:2c9a) +ScheduleNorthRowRedraw: coord hl, 0, 0 call CopyToRedrawRowOrColumnSrcTiles ld a, [wBGMapAnchor] @@ -97,7 +92,7 @@ ScheduleNorthRowRedraw: ; 2c9a (0:2c9a) ldh [hRedrawRowOrColumnMode], a ret -ScheduleSouthRowRedraw: ; 2caf (0:2caf) +ScheduleSouthRowRedraw: coord hl, 0, SCREEN_HEIGHT - 2 call CopyToRedrawRowOrColumnSrcTiles ld a, [wBGMapAnchor] @@ -117,7 +112,7 @@ ScheduleSouthRowRedraw: ; 2caf (0:2caf) ldh [hRedrawRowOrColumnMode], a ret -ScheduleEastColumnRedraw: ; 2cd0 (0:2cd0) +ScheduleEastColumnRedraw: coord hl, SCREEN_WIDTH - 2, 0 call ScheduleColumnRedrawHelper ld a, [wBGMapAnchor] @@ -135,7 +130,7 @@ ScheduleEastColumnRedraw: ; 2cd0 (0:2cd0) ldh [hRedrawRowOrColumnMode], a ret -ScheduleWestColumnRedraw: ; 2cef (0:2cef) +ScheduleWestColumnRedraw: coord hl, 0, 0 call ScheduleColumnRedrawHelper ld a, [wBGMapAnchor] @@ -146,7 +141,7 @@ ScheduleWestColumnRedraw: ; 2cef (0:2cef) ldh [hRedrawRowOrColumnMode], a ret -CopyToRedrawRowOrColumnSrcTiles: ; 2d04 (0:2d04) +CopyToRedrawRowOrColumnSrcTiles: ld de, wRedrawRowOrColumnSrcTiles ld c, 2 * SCREEN_WIDTH .loop @@ -157,7 +152,7 @@ CopyToRedrawRowOrColumnSrcTiles: ; 2d04 (0:2d04) jr nz, .loop ret -ScheduleColumnRedrawHelper: ; 2d10 (0:2d10) +ScheduleColumnRedrawHelper: ld de, wRedrawRowOrColumnSrcTiles ld c, SCREEN_HEIGHT .loop @@ -177,11 +172,8 @@ ScheduleColumnRedrawHelper: ; 2d10 (0:2d10) jr nz, .loop ret -; if DEBUG + SECTION "home/overworld.asm@QueueScript", ROM0 -; else -; SECTION "QueueScript", ROM0[$35B0] -; endc QueueScript:: ; Install a function that is called as soon as @@ -192,4 +184,4 @@ QueueScript:: ld [wQueuedScriptAddr], a ld a, h ld [wQueuedScriptAddr + 1], a - ret
\ No newline at end of file + ret diff --git a/home/pokemon.asm b/home/pokemon.asm index a98122c..ee0c1f9 100644 --- a/home/pokemon.asm +++ b/home/pokemon.asm @@ -1,11 +1,9 @@ INCLUDE "constants.asm" -; if DEBUG + SECTION "home/pokemon.asm@3A4B", ROM0 -; else -; SECTION "3A4B", ROM0[$3A0F] -; endc -GetMonHeader:: ; 3a4b (0:3a4b) + +GetMonHeader:: ; copies the base stat data of a pokemon to wMonHeader ; INPUT: ; [wCurSpecies] = pokemon ID in dex order @@ -17,7 +15,7 @@ GetMonHeader:: ; 3a4b (0:3a4b) ld a, BANK(MonBaseStats) call Bankswitch ld a, [wCurSpecies] - cp DEX_FD + cp DEX_EGG jr z, .egg dec a ld bc, MonBaseStatsEnd - MonBaseStats @@ -36,7 +34,7 @@ GetMonHeader:: ; 3a4b (0:3a4b) ld [hl], e inc hl ld [hl], d - jr .done + jr .done ; useless .done ld a, [wCurSpecies] ld [wMonHIndex], a @@ -47,13 +45,10 @@ GetMonHeader:: ; 3a4b (0:3a4b) pop bc ret -; if DEBUG + SECTION "home/pokemon.asm@3AED", ROM0 -; else -; SECTION "3AED", ROM0[$3AB1] -; endc -UncompressMonSprite:: ; 3aed (0:3aed) +UncompressMonSprite:: ; Uncompresses the front or back sprite of the specified mon ; assumes the corresponding mon header is already loaded ; hl contains offset to sprite pointer ($b for front or $d for back) @@ -104,7 +99,7 @@ UncompressMonSprite:: ; 3aed (0:3aed) ld a, BANK(AnnonPics) jp UncompressSpriteData -LoadMonFrontSprite:: ; 3b3f +LoadMonFrontSprite:: ; Uncompress Pokémon Front Sprite for ; mon currently loaded in wMonHeader ; to 0x9000 @@ -119,7 +114,7 @@ LoadMonFrontSprite:: ; 3b3f pop de ; fallthrough -LoadUncompressedSpriteData:: ; 3b4c (0:3b4c) +LoadUncompressedSpriteData:: ; postprocesses uncompressed sprite chunks to a 2bpp sprite and loads it into video ram ; calculates alignment parameters to place both sprite chunks in the center of the 7*7 tile sprite buffers ; de: destination location @@ -172,13 +167,13 @@ LoadUncompressedSpriteData:: ; 3b4c (0:3b4c) call InterlaceMergeSpriteBuffers ret -ZeroSpriteBuffer:: ; 3ba1 (0:3ba1) +ZeroSpriteBuffer:: ; fills the sprite buffer (pointed to in hl) with zeros ld bc, SPRITEBUFFERSIZE xor a jp ByteFill -AlignSpriteDataCentered:: ; 3ba8 (0:3ba8) +AlignSpriteDataCentered:: ; copies and aligns the sprite data properly inside the sprite buffer ; sprite buffers are 7*7 tiles in size, the loaded sprite is centered within this area ldh a, [hSpriteOffset] @@ -206,7 +201,7 @@ AlignSpriteDataCentered:: ; 3ba8 (0:3ba8) jr nz, .columnLoop ret -InterlaceMergeSpriteBuffers:: ; 3bc6 (0:3bc6) +InterlaceMergeSpriteBuffers:: ; combines the (7*7 tiles, 1bpp) sprite chunks in buffer 0 and 1 into a 2bpp sprite located in buffer 1 through 2 ; in the resulting sprite, the rows of the two source sprites are interlaced ; de: output address @@ -223,7 +218,7 @@ InterlaceMergeSpriteBuffers:: ; 3bc6 (0:3bc6) call CloseSRAM ret -_InterlaceMergeSpriteBuffers:: ; 3bdf (0:3bdf) +_InterlaceMergeSpriteBuffers:: ; actual implementation of InterlaceMergeSpriteBuffers ; sprite flipping is now done during interlace merge loop ; and not as second loop after regular interlace merge @@ -294,4 +289,4 @@ _InterlaceMergeSpriteBuffers:: ; 3bdf (0:3bdf) dec a ldh [hSpriteInterlaceCounter], a jr nz, .interlaceLoopFlipped - ret
\ No newline at end of file + ret diff --git a/home/predef.asm b/home/predef.asm index c9457a8..f9f195a 100644 --- a/home/predef.asm +++ b/home/predef.asm @@ -1,12 +1,8 @@ INCLUDE "constants.asm" -; if DEBUG SECTION "home/predef.asm", ROM0 -; else -; SECTION "Predef", ROM0[$2FA2] -; endc -Predef:: ; 2fde +Predef:: ld [wPredefID], a ldh a, [hROMBank] push af @@ -25,7 +21,7 @@ Predef:: ; 2fde ld a, l ld [wPredefHL + 1], a pop hl - ld a, h ; Could have used `pop af` instead + ld a, h call Bankswitch ld a, [wPredefHL] ld h, a @@ -46,4 +42,4 @@ Predef:: ; 2fde ld b, a ld a, [wPredefBC + 1] ld c, a - ret
\ No newline at end of file + ret diff --git a/home/print_bcd.asm b/home/print_bcd.asm index 8b96d4b..87851ae 100644 --- a/home/print_bcd.asm +++ b/home/print_bcd.asm @@ -1,10 +1,6 @@ INCLUDE "constants.asm" -; if DEBUG SECTION "home/print_bcd.asm", ROM0 -; else -; SECTION "BCD Functions", ROM0[$3A76] -; endc ; function to print a BCD (Binary-coded decimal) number ; de = address of BCD number @@ -17,7 +13,7 @@ SECTION "home/print_bcd.asm", ROM0 ; bits 0-5: length of BCD number in bytes ; Note that bits 5 and 7 are modified during execution. The above reflects ; their meaning at the beginning of the functions's execution. -PrintBCDNumber:: ; 3ab2 (0:3ab2) +PrintBCDNumber:: ld b, c ; save flags in b res 7, c res 6, c ; c now holds the length @@ -43,7 +39,7 @@ PrintBCDNumber:: ; 3ab2 (0:3ab2) .done ret -PrintBCDDigit:: ; 3ad5 (0:3ad5) +PrintBCDDigit:: and $0f and a jr z, .zeroDigit @@ -60,4 +56,3 @@ PrintBCDDigit:: ; 3ad5 (0:3ad5) ld a, " " ld [hli], a ret -; 0x3aed
\ No newline at end of file diff --git a/home/print_hex.asm b/home/print_hex.asm index 2a68c2b..07d3736 100644 --- a/home/print_hex.asm +++ b/home/print_hex.asm @@ -1,12 +1,8 @@ INCLUDE "constants.asm" -; if DEBUG SECTION "home/print_hex.asm", ROM0 -; else -; SECTION "Print Hexadecimal functions", ROM0[$355B] -; endc -PrintHexBytes: ; 3597 (0:3597) +PrintHexBytes: ; Print c hex bytes located at de to hl .loop push bc @@ -16,7 +12,7 @@ PrintHexBytes: ; 3597 (0:3597) jr nz, .loop ret -PrintHexByte:: ; 35a0 (0:35a0) +PrintHexByte:: ; Print one hex byte located at de to hl ld a, [de] swap a @@ -30,9 +26,8 @@ PrintHexByte:: ; 35a0 (0:35a0) inc de ret -GetHexDigit: ; 35b2 (0:35b2) -; Get a hex digit tile number -; in a. +GetHexDigit: +; Get a hex digit tile number in a ld bc, .hexDigitTable add c ld c, a @@ -43,4 +38,4 @@ GetHexDigit: ; 35b2 (0:35b2) ret .hexDigitTable: - db "0123456789ABCDEF"
\ No newline at end of file + db "0123456789ABCDEF" diff --git a/home/print_num.asm b/home/print_num.asm index 2a0f36f..c40f826 100644 --- a/home/print_num.asm +++ b/home/print_num.asm @@ -1,12 +1,8 @@ INCLUDE "constants.asm" -; if DEBUG SECTION "home/print_num.asm", ROM0 -; else -; SECTION "Number Printing Functions", ROM0[$3424] -; endc -PrintNumber:: ; 3460 (0:3460) +PrintNumber:: ; function to print a number ; de = address of number in little-endian format ; hl = destination address @@ -164,7 +160,7 @@ PrintNumber:: ; 3460 (0:3460) pop bc ret -.PrintDigit: ; 3525 (0:3525) +.PrintDigit: ld c, $00 .loop ldh a, [hPrintNumDivisor] @@ -237,7 +233,7 @@ PrintNumber:: ; 3460 (0:3460) ld [hl], "0" ret -.AdvancePointer: ; 3589 (0:3589) +.AdvancePointer: ; increments the pointer unless leading zeroes are not being printed, ; the number is left-aligned, and no nonzero digits have been printed yet bit 7, d ; print leading zeroes? @@ -249,4 +245,4 @@ PrintNumber:: ; 3460 (0:3460) ret z ; don't advance if leading digit is zero .inc inc hl - ret
\ No newline at end of file + ret diff --git a/home/print_text.asm b/home/print_text.asm index 61cc9e1..52f2489 100644 --- a/home/print_text.asm +++ b/home/print_text.asm @@ -1,12 +1,8 @@ include "constants.asm" -; if DEBUG SECTION "home/print_text.asm", ROM0 -; else -; SECTION "Print Letter Delay", ROM0[$3367] -; endc -PrintLetterDelay:: ; 33a3 (0:33a3) +PrintLetterDelay:: ld a, [wce5f] bit 4, a ret nz @@ -48,23 +44,22 @@ PrintLetterDelay:: ; 33a3 (0:33a3) pop de pop hl ret -; 0x33e3 -CopyDataUntil:: ; 33e3 +CopyDataUntil:: ; Copy [hl .. bc) to de. ; In other words, the source data is ; from hl up to but not including bc, ; and the destination is de. -.asm_33e3: ; 00:33e3 +.loop: ld a, [hli] ld [de], a inc de ld a, h cp b - jr nz, .asm_33e3 + jr nz, .loop ld a, l cp c - jr nz, .asm_33e3 - ret
\ No newline at end of file + jr nz, .loop + ret diff --git a/home/random.asm b/home/random.asm index 7c833b5..a342976 100644 --- a/home/random.asm +++ b/home/random.asm @@ -1,10 +1,6 @@ include "constants.asm" -; if DEBUG SECTION "home/random.asm", ROM0 -; else -; SECTION "Random Number Generation", ROM0 [$3234] -; endc Random:: ; A simple hardware-based random number generator (RNG). @@ -66,4 +62,4 @@ BattleRandom:: pop af call Bankswitch ld a, [wPredefHL + 1] - ret
\ No newline at end of file + ret diff --git a/home/rst.asm b/home/rst.asm index 7d087aa..a3c5a59 100644 --- a/home/rst.asm +++ b/home/rst.asm @@ -22,8 +22,6 @@ SECTION "home/rst.asm@rst30", ROM0 rst $38 SECTION "home/rst.asm@rst38", ROM0 -if DEBUG && def(SILVER) - rst $38 -else - jp $F080 ; Jumps in the middle of unmapped memory. Probably used to trigger a breakpoint of sorts. -endc + ; Jumps in the middle of unmapped echo RAM. + ; Probably used to trigger a breakpoint. + jp $F080 diff --git a/home/rtc.asm b/home/rtc.asm index 651a7b6..bc81e80 100644 --- a/home/rtc.asm +++ b/home/rtc.asm @@ -1,19 +1,17 @@ include "constants.asm" -; if DEBUG SECTION "home/rtc.asm", ROM0 -; else -; SECTION "Time Of Day Palettes", ROM0 [$02EF] -; endc -UpdateTimeOfDayPalettes: ; 32b (0:032b) +UpdateTimeOfDayPalettes: ld a, [wVramState] bit 0, a ret z + ; fallthrough + TimeOfDayPals:: - callab _TimeOfDayPals ; Func_8c2e3 + callab _TimeOfDayPals ret -UpdateTimePals:: ; 33a - callab _UpdateTimePals ; Func_8c335 - ret
\ No newline at end of file +UpdateTimePals:: + callab _UpdateTimePals + ret diff --git a/home/scrolling_menu.asm b/home/scrolling_menu.asm index 0c86363..5a73bba 100644 --- a/home/scrolling_menu.asm +++ b/home/scrolling_menu.asm @@ -1,10 +1,6 @@ include "constants.asm" -; if DEBUG SECTION "home/scrolling_menu.asm", ROM0 -; else -; SECTION "Scrolling Menu", ROM0 [$37D4] -; endc Function3810:: ld e, [hl] @@ -40,7 +36,7 @@ Function3810:: ld a, [wMenuJoypad] ret -ScrollingMenu:: ; 00:383e +ScrollingMenu:: call CopyMenuData ldh a, [hROMBank] push af @@ -64,7 +60,7 @@ Function385a:: Function385d:: callab Function_8f1cb -asm_3865: ; 00:3865 +asm_3865: pop hl call MenuTextBox ld c, $0 @@ -72,22 +68,22 @@ asm_3865: ; 00:3865 call CloseWindow ret -Function3872:: ; 00:3872 +Function3872:: push bc jr asm_387d Function3875:: callab PlaySpriteAnimationsAndDelayFrame -asm_387d: ; 00:387d +asm_387d: pop bc call GetJoypad ldh a, [hJoyDown] and A_BUTTON | B_BUTTON - jr nz, .asm_388e + jr nz, .done ld a, c and a jr z, Function3872 dec c jr z, Function3872 -.asm_388e: ; 00:388e - ret
\ No newline at end of file +.done: + ret diff --git a/home/serial.asm b/home/serial.asm index 6d4568b..a0f9dd8 100644 --- a/home/serial.asm +++ b/home/serial.asm @@ -53,7 +53,7 @@ Serial:: pop af reti -Serial_ExchangeBytes:: ; 64c +Serial_ExchangeBytes:: ld a, $1 ldh [hSerialIgnoringInitialData], a .loop @@ -88,7 +88,7 @@ Serial_ExchangeBytes:: ; 64c jr nz, .loop ret -Serial_ExchangeByte:: ; 677 (0:0677) +Serial_ExchangeByte:: .loop xor a ldh [hSerialReceived], a @@ -187,14 +187,14 @@ Serial_ExchangeByte:: ; 677 (0:0677) call DelayFrame jp .loop -.delay_15_cycles: ; 70e (0:070e) +.delay_15_cycles: ld a, 15 .delay_cycles dec a jr nz, .delay_cycles ret -CheckwLinkTimeoutFramesNonzero: ; 714 (0:0714) +CheckwLinkTimeoutFramesNonzero: push hl ld hl, wLinkTimeoutFrames ld a, [hli] @@ -202,7 +202,7 @@ CheckwLinkTimeoutFramesNonzero: ; 714 (0:0714) pop hl ret -SerialDisconnected: ; 71c (0:071c) +SerialDisconnected: dec a ld [wLinkTimeoutFrames], a ld [wLinkTimeoutFrames + 1], a @@ -241,7 +241,7 @@ Serial_PrintWaitingTextAndSyncAndExchangeNybble:: call WaitLinkTransfer jp ReloadTilesFromBuffer -WaitLinkTransfer:: ; 75c (0:075c) +WaitLinkTransfer:: ld a, $ff ld [wOtherPlayerLinkAction], a .loop @@ -286,7 +286,7 @@ WaitLinkTransfer:: ; 75c (0:075c) ld [wOtherPlayerLinkMode], a ret -LinkTransfer:: ; 7a0 (0:07a0) +LinkTransfer:: push bc ld b, $60 ld a, [wLinkMode] @@ -310,7 +310,7 @@ LinkTransfer:: ; 7a0 (0:07a0) pop bc ret -.Receive: ; 7c4 (0:07c4) +.Receive: ldh a, [hSerialReceive] ld [wOtherPlayerLinkMode], a and $f0 @@ -323,7 +323,7 @@ LinkTransfer:: ; 7a0 (0:07a0) ld [wOtherPlayerLinkAction], a ret -LinkDataReceived:: ; 7d9 (0:07d9) +LinkDataReceived:: ; Let the other system know that the data has been received. xor a ldh [hSerialSend], a @@ -344,4 +344,4 @@ Unreferenced_Function7e6:: ldh [hSerialReceive], a ld a, (1 << rSC_ON) ldh [rSC], a - ret
\ No newline at end of file + ret diff --git a/home/sram.asm b/home/sram.asm index da27c81..53798cd 100644 --- a/home/sram.asm +++ b/home/sram.asm @@ -1,12 +1,8 @@ INCLUDE "constants.asm" -; if DEBUG SECTION "home/sram.asm", ROM0 -; else -; SECTION "SRAM functions", ROM0[$326B] -; endc -OpenSRAM:: ; 32a7 +OpenSRAM:: push af ld a, 1 ld [MBC3LatchClock], a @@ -16,10 +12,10 @@ OpenSRAM:: ; 32a7 ld [MBC3SRamBank], a ret -CloseSRAM:: ; 32b7 +CloseSRAM:: push af ld a, SRAM_DISABLE ld [MBC3LatchClock], a ld [MBC3SRamEnable], a pop af - ret
\ No newline at end of file + ret diff --git a/home/tables.asm b/home/tables.asm index e5d9c1e..c005ffc 100755 --- a/home/tables.asm +++ b/home/tables.asm @@ -4,7 +4,7 @@ SECTION "home/tables.asm", ROM0 ; find value a from table hl with row length de ; returns carry and row index b if successful -FindItemInTable: ; 00:35F8 +FindItemInTable: ld b, 0 ld c, a @@ -24,4 +24,4 @@ FindItemInTable: ; 00:35F8 .success scf - ret
\ No newline at end of file + ret diff --git a/home/talk_to_npc.asm b/home/talk_to_npc.asm index ddc2fcd..0be8e8e 100644 --- a/home/talk_to_npc.asm +++ b/home/talk_to_npc.asm @@ -1,28 +1,24 @@ include "constants.asm" -; if DEBUG SECTION "home/talk_to_npc.asm", ROM0 -; else -; SECTION "Unknown 3025", ROM0 [$2fe9] -; endc MapDefaultText:: ld hl, GameplayText call OpenTextbox ret -GameplayText:: ; 00:302c +GameplayText:: text "ゲームフりーク!" done -Function3036:: ; 3036 +Function3036:: ld hl, EmptyText ret -EmptyText:: ; 00:303a +EmptyText:: db "@" -CallMapTextSubroutine:: ; 00:303b +CallMapTextSubroutine:: ld a, [wTalkingTargetType] bit 0, a jr z, asm_3062 @@ -36,14 +32,14 @@ CallMapTextSubroutine:: ; 00:303b push de jp hl -.Return: ; 00:3051 +.Return: call Function307a ret -Function3055:: ; 00:3055 +Function3055:: ldh a, [hFFEA] ld b, a -.Loop: ; 00:3058 +.Loop: ld a, [hli] cp $ff ret z @@ -51,7 +47,7 @@ Function3055:: ; 00:3055 jp z, SetFFInAccumulator jr .Loop -asm_3062: ; 00:3062 +asm_3062: ld a, [wTalkingTargetType] bit 1, a ret z @@ -70,14 +66,14 @@ asm_3062: ; 00:3062 push de jp hl -Function307a:: ; 00:307a +Function307a:: ld hl, wTalkingTargetType res 0, [hl] res 1, [hl] call SetFFInAccumulator ret -PrintTextboxDebugNumbers:: ; 00:3085 +PrintTextboxDebugNumbers:: push hl push de push bc @@ -88,12 +84,12 @@ PrintTextboxDebugNumbers:: ; 00:3085 ld de, hFFEA jr .PrintNum -.CheckSign: ; 00:3097 +.CheckSign: bit 1, a jr z, .PrintNum ld de, hFFEE -.PrintNum: ; 00:309e +.PrintNum: hlcoord 4, 12 lb bc, PRINTNUM_LEADINGZEROS | 1, 2 call PrintNumber @@ -106,7 +102,7 @@ PrintTextboxDebugNumbers:: ; 00:3085 pop hl ret -QueueMapTextSubroutine:: ; 00:30b7 +QueueMapTextSubroutine:: ldh a, [hJoyState] bit A_BUTTON_F, a jp z, ClearAccumulator ; if we didn't press a @@ -134,7 +130,7 @@ QueueMapTextSubroutine:: ; 00:30b7 call SetFFInAccumulator ret -Function30e8:: ; 00:30e8 +Function30e8:: call GetFacingSignpost jp nc, ClearAccumulator ; if not facing person or sign ld a, e @@ -150,14 +146,14 @@ Function30e8:: ; 00:30e8 call SetFFInAccumulator ret -GetFacingPersonText:: ; 00:3103 +GetFacingPersonText:: callba Function776e ret nc call TurnNPCTalkingTo scf ret -OpenTextbox:: ; 00:3111 +OpenTextbox:: ; Opens a textbox and waits for input push hl call PrepareTextbox @@ -165,28 +161,28 @@ OpenTextbox:: ; 00:3111 bit DEBUG_FIELD_F, a call nz, PrintTextboxDebugNumbers pop hl - call TextboxIdle + call TextboxIdle ret -OpenTextboxNoInput:: ; 00:3122 - push hl - call PrepareTextbox +OpenTextboxNoInput:: + push hl + call PrepareTextbox pop hl -TextboxIdle:: ; 00:3127 +TextboxIdle:: ; Prints text, then waits for A or B to be pressed, unless bit 5 of JoypadFlags is set. call PrintTextBoxText .Loop ld a, [wJoypadFlags] bit 5, a - res 5, a - ld [wJoypadFlags], a + res 5, a + ld [wJoypadFlags], a jr nz, .Escape call GetJoypad ldh a, [hJoyDown] and A_BUTTON | B_BUTTON - jr nz, .Escape - call UpdateTime + jr nz, .Escape + call UpdateTime call UpdateTimeOfDayPalettes call DelayFrame jr .Loop @@ -194,16 +190,16 @@ TextboxIdle:: ; 00:3127 call TextboxCleanup ret -PrepareTextbox:: ; 00:314E +PrepareTextbox:: call ClearWindowData ldh a, [hROMBank] - push af - ld a, 01 + push af + ld a, 01 call Bankswitch call ReanchorBGMap_NoOAMUpdate hlcoord 0, 12 ;in the tilemap in WRAM - ld b, 04 - ld c, $12 + ld b, 04 + ld c, $12 call DrawTextBox call WaitBGMap call LoadFonts_NoOAMUpdate @@ -211,27 +207,27 @@ PrepareTextbox:: ; 00:314E call Bankswitch ret -TextboxCleanup: ; 00:3171 +TextboxCleanup: callab ReanchorBGMap_NoOAMUpdate call UpdateSprites xor a ldh [hBGMapMode], a ld a, $90 ldh [hWY], a - call Function318f + call Function318f ld hl, wToolgearFlags res 7, [hl] call InitToolgearBuffer ret -Function318f: ; 00:318f +Function318f: callab Function140ea call RedrawPlayerSprite ret - -TurnNPCTalkingTo:: ; 00:319b + +TurnNPCTalkingTo:: ; If an NPC is allowed to turn when talked to, turn it. - ldh a, [hObjectStructIndexBuffer] + ldh a, [hObjectStructIndexBuffer] call GetObjectStruct ld hl, OBJECT_SPRITE add hl, bc @@ -254,17 +250,17 @@ TurnNPCTalkingTo:: ; 00:319b ldh [hFFEA], a ret -Function31C3:: ; 00:31C3 +Function31C3:: ret -CheckInlineTrainer:: ; 00:31C4 +CheckInlineTrainer:: ; Passed de is the pointer to a map_object struct. If it's an inline trainer, write to relevant wram region. ld hl, MAPOBJECT_OBJECT_STRUCT_ID add hl, de ld a, [hl] call GetObjectStruct call GetInlineMapObject - jr nc, .Escape + jr nc, .Escape ld hl, MAPOBJECT_POINTER_HI add hl, de ld a, [hl] @@ -274,7 +270,7 @@ CheckInlineTrainer:: ; 00:31C4 add hl, de ld a, [hl] add a, a - ld hl, wCurrMapInlineTrainers + ld hl, wCurrMapInlineTrainers add a, l ld l, a jr nc, .NoCarry @@ -286,7 +282,7 @@ CheckInlineTrainer:: ; 00:31C4 .Escape ret -GetInlineMapObject:: ; 00:31EB +GetInlineMapObject:: ;bc is start of object struct. if c flag set, returns distance in B and direction in C ld hl, OBJECT_NEXT_MAP_X add hl, bc @@ -298,27 +294,27 @@ GetInlineMapObject:: ; 00:31EB ld a, [wPlayerNextMapY] cp [hl] jr z, .EqualY - and a + and a ret -.EqualX +.EqualX ld hl, OBJECT_NEXT_MAP_Y add hl, bc ld a, [wPlayerNextMapY] sub [hl] - jr z, .Reset - jr nc, .SetDown + jr z, .Reset + jr nc, .SetDown cpl inc a ld b, a ld c, UP scf ret -.SetDown ; 3214 +.SetDown ld b, a ld c, DOWN scf ret -.EqualY ; 3219 +.EqualY ld hl, OBJECT_NEXT_MAP_X add hl, bc ld a, [wPlayerNextMapX] @@ -331,16 +327,16 @@ GetInlineMapObject:: ; 00:31EB ld c, LEFT scf ret -.SetRight ; 322C +.SetRight ld b, a ld c, RIGHT scf ret -.Reset ; 3231 +.Reset and a ret - -CheckBPressedDebug: ; 3233 + +CheckBPressedDebug: ; If in debug mode, returns a check on the B button. ld a, [wDebugFlags] bit DEBUG_FIELD_F, a @@ -349,13 +345,11 @@ CheckBPressedDebug: ; 3233 bit B_BUTTON_F, a ret -ClearAccumulator:: ; 323E +ClearAccumulator:: xor a ret - -SetFFInAccumulator:: ; 3240 + +SetFFInAccumulator:: xor a dec a ret - -; 3243
\ No newline at end of file diff --git a/home/text.asm b/home/text.asm index abca7ab..fbf2ce5 100644 --- a/home/text.asm +++ b/home/text.asm @@ -729,4 +729,4 @@ TextCommands:: ; 120c dw Text_PlaySound dw Text_PlaySound dw Text_PlaySound - dw Text_PlaySound
\ No newline at end of file + dw Text_PlaySound diff --git a/home/tilemap.asm b/home/tilemap.asm index 6348671..659974a 100644 --- a/home/tilemap.asm +++ b/home/tilemap.asm @@ -1,10 +1,6 @@ include "constants.asm" -; if DEBUG SECTION "home/tilemap.asm", ROM0 -; else -; SECTION "Tilemap Functions", ROM0 [$35CF] -; endc Function360b:: call ClearSprites @@ -15,9 +11,9 @@ Function360b:: call GetMemSGBLayout jr WaitBGMap -ClearBGPalettes:: ; 361e +ClearBGPalettes:: call ClearPalettes -WaitBGMap:: ; 00:3621 +WaitBGMap:: ; Tell VBlank to update BG Map ld a, $1 ldh [hBGMapMode], a @@ -26,29 +22,29 @@ WaitBGMap:: ; 00:3621 call DelayFrames ret -SetPalettes:: ; 00:362b +SetPalettes:: ld a, %11100100 ldh [rBGP], a ld a, %11010000 ldh [rOBP0], a ret -ClearPalettes:: ; 00:3634 +ClearPalettes:: xor a ldh [rBGP], a ldh [rOBP0], a ldh [rOBP1], a ret -GetMemSGBLayout:: ; 00:363c +GetMemSGBLayout:: ld b, SGB_RAM -GetSGBLayout:: ; 00:363e +GetSGBLayout:: ld a, [wSGB] and a ret z predef_jump Function928b -SetHPPal:: ; 00:3648 +SetHPPal:: ld a, e cp 27 ; 56.25% ld d, $0 @@ -57,14 +53,14 @@ SetHPPal:: ; 00:3648 inc d jr nc, .done inc d -.done: ; 00:3655 +.done: ld [hl], d ret -Function3657:: ; 00:3657 +Function3657:: call DisableLCD callab Function140d9 call LoadFont call UpdateSprites call EnableLCD - ret
\ No newline at end of file + ret diff --git a/home/tileset.asm b/home/tileset.asm index d96018f..ddde57b 100644 --- a/home/tileset.asm +++ b/home/tileset.asm @@ -3,7 +3,7 @@ include "constants.asm" SECTION "home/tileset.asm", ROM0 -LoadTilesetGFX:: ; 2d26 +LoadTilesetGFX:: call GetMapEnvironment cp TOWN jr z, .exterior @@ -27,7 +27,7 @@ LoadTilesetGFX:: ; 2d26 ret .exterior - ld de, CommonExteriorTilesGFX ; TODO: maybe find a better name + ld de, CommonExteriorTilesGFX ld hl, vTileset lb bc, BANK(CommonExteriorTilesGFX), $20 call Get2bpp @@ -46,7 +46,7 @@ LoadTilesetGFX:: ; 2d26 ret -RefreshPlayerCoords:: ; 2d74 +RefreshPlayerCoords:: ld a, [wXCoord] add a, 4 ld d, a @@ -103,8 +103,7 @@ RefreshPlayerCoords:: ; 2d74 ld [hl], a ret - -BufferScreen:: ; 2dcd +BufferScreen:: ld hl, wOverworldMapAnchor ld a, [hli] ld h, [hl] @@ -132,7 +131,7 @@ BufferScreen:: ; 2dcd jr nz, .row ret -SaveScreen:: ; 2df1 +SaveScreen:: ld hl, wOverworldMapAnchor ld a, [hli] ld h, [hl] @@ -178,7 +177,7 @@ SaveScreen:: ; 2df1 ld b, 5 ld c, 5 -.load_neighbor ; 2e35 +.load_neighbor .row push bc push hl @@ -208,7 +207,7 @@ SaveScreen:: ; 2df1 ret -RefreshTiles:: ; 2e52 +RefreshTiles:: call .left_right call .up_down ld a, [wPlayerNextMapX] @@ -219,7 +218,7 @@ RefreshTiles:: ; 2e52 ld [wPlayerStandingTile], a ret -.up_down ; 2e67 +.up_down ld a, [wPlayerNextMapX] ld d, a ld a, [wPlayerNextMapY] @@ -234,7 +233,7 @@ RefreshTiles:: ; 2e52 ld [wTileUp], a ret -.left_right ; 2e80 +.left_right ld a, [wPlayerNextMapX] ld d, a ld a, [wPlayerNextMapY] @@ -250,7 +249,7 @@ RefreshTiles:: ; 2e52 ret -GetFacingTileCoord:: ; 2e99 +GetFacingTileCoord:: ld a, [wPlayerWalking] ; TODO: wPlayerDirection in Crystal. Not here? and %1100 srl a @@ -292,7 +291,7 @@ GetFacingTileCoord:: ; 2e99 db 1, 0 dw wTileRight -GetCoordTile:: ; 2ece +GetCoordTile:: ; Get the collision byte for tile d, e call GetBlockLocation ld a, [hl] @@ -326,7 +325,7 @@ GetCoordTile:: ; 2ece ld a, -1 ret -GetBlockLocation:: ; 2ef8 +GetBlockLocation:: ld a, [wMapWidth] add a, 6 ld c, a @@ -355,7 +354,7 @@ GetBlockLocation:: ; 2ef8 add hl, bc ret -GetFacingSignpost:: ; 00:2f1d +GetFacingSignpost:: call GetFacingTileCoord ld b, a ld a, d @@ -369,7 +368,7 @@ GetFacingSignpost:: ; 00:2f1d ret z ld c, a ld hl, wCurrMapSigns -.asm_2f32: ; 00:2f32 +.asm_2f32: ld a, [hli] cp e jr nz, .asm_2f3e @@ -380,9 +379,9 @@ GetFacingSignpost:: ; 00:2f1d cp b ; useless comparison jr .asm_2f46 -.asm_2f3e: ; 00:2f3e +.asm_2f3e: inc hl -.asm_2f3f: ; 00:2f3f +.asm_2f3f: inc hl inc hl dec c @@ -390,11 +389,11 @@ GetFacingSignpost:: ; 00:2f1d xor a ret -.asm_2f46: ; 00:2f46 +.asm_2f46: scf ret -LoadTileset:: ; 2f48 +LoadTileset:: push hl push bc @@ -418,7 +417,7 @@ LoadTileset:: ; 2f48 pop hl ret -ReloadFontAndTileset:: ; 2f6b (00:2f6b) +ReloadFontAndTileset:: call DisableLCD ldh a, [hROMBank] push af @@ -436,8 +435,8 @@ ReloadFontAndTileset:: ; 2f6b (00:2f6b) call EnableLCD ret -LoadTilesetGFX_LCDOff:: ; 2f8d (00:2f8d) +LoadTilesetGFX_LCDOff:: call DisableLCD call LoadTilesetGFX call EnableLCD - ret
\ No newline at end of file + ret diff --git a/home/time.asm b/home/time.asm index 98f3827..ccd6f33 100644 --- a/home/time.asm +++ b/home/time.asm @@ -2,14 +2,14 @@ include "constants.asm" SECTION "home/time.asm", ROM0 -LatchClock: ; 42b (0:042b) +LatchClock: ld a, 0 ld [MBC3LatchClock], a ld a, 1 ld [MBC3LatchClock], a ret -UpdateTime:: ; 436 (0:0436) +UpdateTime:: ldh a, [hRTCStatusFlags] bit 0, a ret nz @@ -81,7 +81,7 @@ UpdateTime:: ; 436 (0:0436) db $23, $01 db $32, $02 db $3b, $03 - + Function04ac:: ld hl, hRTCStatusFlags set 0, [hl] @@ -113,7 +113,7 @@ Function04ac:: res 0, [hl] ret -Function04ea:: ; 4ea (0:04ea) +Function04ea:: ld a, SRAM_ENABLE ld [MBC3SRamEnable], a call LatchClock @@ -125,7 +125,7 @@ Function04ea:: ; 4ea (0:04ea) call CloseSRAM ret -Function0502:: ; 0502 +Function0502:: ld a, SRAM_ENABLE ld [MBC3SRamEnable], a call LatchClock @@ -135,4 +135,4 @@ Function0502:: ; 0502 res 6, a ld [MBC3RTC], a call CloseSRAM - ret
\ No newline at end of file + ret diff --git a/home/toolgear.asm b/home/toolgear.asm index dc79b5b..0b21454 100644 --- a/home/toolgear.asm +++ b/home/toolgear.asm @@ -4,6 +4,7 @@ SECTION "home/toolgear.asm", ROM0 ; local charmap, global charmap won't apply ; see https://github.com/rednex/rgbds/issues/265#issuecomment-395229694 +newcharmap local charmap "0", $66 charmap "1", $67 charmap "2", $68 @@ -22,7 +23,7 @@ SECTION "home/toolgear.asm", ROM0 charmap "E", $74 charmap "F", $75 ; small kana aren't actively loaded - + ; if clock shown charmap ":", $70 charmap "日", $71 @@ -34,7 +35,7 @@ SECTION "home/toolgear.asm", ROM0 charmap "土", $77 charmap "⚡", $78 ; power charmap "☎", $79 ; mobile - + ; active frame charmap "┌", $79 ; only if debug coords shown charmap "─", $7a @@ -44,21 +45,21 @@ SECTION "home/toolgear.asm", ROM0 charmap "┘", $7e charmap " ", $7f -EnableToolgear:: ; 00:2018 +EnableToolgear:: ld hl, wd153 res 0, [hl] ld hl, wToolgearFlags set 0, [hl] ret -DisableToolgear:: ; 00:2023 +DisableToolgear:: ld hl, wToolgearFlags res 0, [hl] xor a ldh [hLCDCPointer], a ret -InitToolgearBuffer:: ; 00:202c +InitToolgearBuffer:: xor a ldh [hBGMapMode], a ld hl, wToolgearFlags @@ -92,7 +93,7 @@ InitToolgearBuffer:: ; 00:202c ldh [hWY], a ret -.hide_window: ; 00:206b +.hide_window: xor a ldh [hLCDCPointer], a ld a, $90 @@ -100,7 +101,7 @@ InitToolgearBuffer:: ; 00:202c ldh [hWY], a ret -UpdateToolgear:: ; 2075 +UpdateToolgear:: ; Prepares a buffer for the clock display, which in the Debug ROM is displayed on the bottom of the screen. ; This function is called every frame, and loads special tiles into the $66-$7a space. bgcoord hl, 0, 1, wToolgearBuffer @@ -108,7 +109,6 @@ UpdateToolgear:: ; 2075 ld a, " " call ByteFill -if DEBUG ld hl, wd153 bit 0, [hl] jr z, .debug_show_time @@ -121,8 +121,7 @@ if DEBUG ld c, $01 call .printHex ret -.debug_show_time: -endc +.debug_show_time ld hl, hRTCHours bgcoord de, 0, 1, wToolgearBuffer @@ -145,7 +144,7 @@ endc ldbgcoord_a 2, 1, wToolgearBuffer ret -.printHex:: ; 20cd +.printHex:: ; .printHex ; print c hexadecimal digits from hl to de ; clobbers: a, b @@ -159,7 +158,7 @@ endc jr nz, .printHex ret -.printDec:: ; 20dc +.printDec:: ; .printDec ; print c decimal digits from hl to de ; clobbers: a, b @@ -178,11 +177,11 @@ endc call .printDigit ret -.printDigit:: ; 20f1 +.printDigit:: ; .printDigit ; print a hexadecimal digit for value in a to de and $0f add "0" ld [de], a inc de - ret
\ No newline at end of file + ret diff --git a/home/unknown.asm b/home/unknown.asm index 6e540f8..f06101b 100644 --- a/home/unknown.asm +++ b/home/unknown.asm @@ -1,12 +1,9 @@ INCLUDE "constants.asm" -; if DEBUG + SECTION "home/unknown.asm@Empty function", ROM0 -; else -; SECTION "Empty function", ROM0[$2F5B] -; endc -InexplicablyEmptyFunction:: ; 2f97 +InexplicablyEmptyFunction:: rept 16 nop endr @@ -20,7 +17,7 @@ endr SECTION "home/unknown.asm@Unknown functions", ROM0 -_1FF4:: ; 1ff4 +_1FF4:: ld a, BANK(s0_a600) call OpenSRAM ld hl, s0_a600 ; TODO: label this. @@ -30,7 +27,7 @@ _1FF4:: ; 1ff4 call CloseSRAM ret -_2007:: ; 2007 +_2007:: ld a, BANK(s0_a600) call OpenSRAM ld a, [s0_a600] @@ -39,6 +36,7 @@ _2007:: ; 2007 call CloseSRAM ret + SECTION "home/unknown.asm@Unknown_20f8", ROM0 Function20f8:: @@ -46,6 +44,7 @@ Function20f8:: call Function18cc ret + SECTION "home/unknown.asm@Unknown_094c", ROM0 Function094c:: @@ -57,4 +56,4 @@ Function094c:: pop af call Bankswitch - jp DebugMenu
\ No newline at end of file + jp DebugMenu diff --git a/home/unknown_388f.asm b/home/unknown_388f.asm index 85aa781..b230dc8 100644 --- a/home/unknown_388f.asm +++ b/home/unknown_388f.asm @@ -1,11 +1,6 @@ include "constants.asm" -; if DEBUG SECTION "home/unknown_388f.asm", ROM0 -; else -; SECTION "Unknown 388F", ROM0 [$3853] -; endc - Function388f:: ret @@ -93,7 +88,7 @@ Function3920:: res 4, [hl] ld hl, .text call OpenTextbox - call RotateFourPalettesLeft + call GBFadeOutToBlack jp Init .text: diff --git a/home/util.asm b/home/util.asm index f7ddc1f..81435c2 100644 --- a/home/util.asm +++ b/home/util.asm @@ -1,10 +1,6 @@ INCLUDE "constants.asm" -; if DEBUG SECTION "home/util.asm", ROM0 -; else -; SECTION "Misc Utility Functions", ROM0[$33B3] -; endc Function33ef:: ; hl = src @@ -18,7 +14,7 @@ Function33ef:: dec a dec a ld b, $0 -.asm_33f7: ; 00:33f7 +.asm_33f7: add hl, bc dec a jr nz, .asm_33f7 @@ -30,7 +26,7 @@ Function33ef:: ld d, h ld e, l pop hl -.asm_3403: ; 00:3403 +.asm_3403: push af push bc call CopyBytes @@ -53,7 +49,7 @@ Function33ef:: pop de jp CopyBytes -SkipNames:: ; 341f +SkipNames:: ; Returns hl + a * 6 and a ret z @@ -64,7 +60,7 @@ SkipNames:: ; 341f jr nz, .loop ret -AddNTimes:: ; 3429 (0:3429) +AddNTimes:: ; Adds bc to hl, a times and a ret z @@ -75,7 +71,7 @@ AddNTimes:: ; 3429 (0:3429) ret ; 0x3430 -memcmp:: ; 3430 +memcmp:: ; TODO: rename ; Compare c bytes at hl and de ; Returns z if all equal, nz otherwise. .loop: @@ -88,7 +84,7 @@ memcmp:: ; 3430 jr nz, .loop ret -Function3439:: ; 3439 +Function3439:: ; Place 2x2 sprite from *de into OAM at slot a ld h, HIGH(wVirtualOAM) swap a @@ -107,7 +103,7 @@ Function3439:: ; 3439 ld a, $8 add c ld c, a -.Load: ; 00:3455 +.Load: ld [hl], b inc hl ld [hl], c @@ -118,4 +114,4 @@ Function3439:: ; 3439 ld a, [de] inc de ld [hli], a - ret
\ No newline at end of file + ret diff --git a/home/vblank.asm b/home/vblank.asm index ea567ea..4313390 100644 --- a/home/vblank.asm +++ b/home/vblank.asm @@ -2,7 +2,7 @@ INCLUDE "constants.asm" SECTION "home/vblank.asm", ROM0 -VBlank:: ; 0150 +VBlank:: push af push bc push de @@ -33,7 +33,7 @@ VBlank:: ; 0150 dw VBlank2 dw VBlank3 -VBlank0:: ; 175 (0:175) +VBlank0:: ; rng ; scx, scy, wy, wx ; bg map @@ -115,7 +115,7 @@ VBlank0:: ; 175 (0:175) ldh [rIE], a ret -VBlank1:: ; 1f6 (0:1f6) +VBlank1:: ; Simple VBlank ; ; scx, scy @@ -162,7 +162,7 @@ VBlank1:: ; 1f6 (0:1f6) ldh [rIE], a ret -VBlank2:: ; 241 (0:241) +VBlank2:: ; rng ; scx, scy, wy, wx ; joypad @@ -223,7 +223,7 @@ VBlank2:: ; 241 (0:241) call Bankswitch ret -VBlank3:: ; 2a0 (0:2a0) +VBlank3:: ; rng ; joypad ; scx, scy, wy, wx @@ -297,4 +297,3 @@ VBlank3:: ; 2a0 (0:2a0) ld a, (1 << JOYPAD | 1 << SERIAL | 1 << TIMER | 1 << LCD_STAT | 1 << VBLANK) ldh [rIE], a ret -; 0x317
\ No newline at end of file diff --git a/home/vcopy.asm b/home/vcopy.asm index b0ad6eb..aae4a2f 100644 --- a/home/vcopy.asm +++ b/home/vcopy.asm @@ -614,4 +614,3 @@ VBlankCopyFar:: ; 1558 (0:1558) ld h, a ld sp, hl ret -; 0x15b5
\ No newline at end of file diff --git a/home/window.asm b/home/window.asm index 178ad9b..90a6116 100644 --- a/home/window.asm +++ b/home/window.asm @@ -20,4 +20,4 @@ Function1fea:: call TextboxCleanup call ClearWindowData call InitToolgearBuffer - ret
\ No newline at end of file + ret diff --git a/pokegold-spaceworld.link b/layout.link index 6fd26a3..ea55c98 100644 --- a/pokegold-spaceworld.link +++ b/layout.link @@ -1,46 +1,34 @@ -; Automatically generated by map2link.py ROM0 + org $0000 + "NULL" + org $0000 "home/rst.asm@rst00" - ; $0001 org $0008 "home/rst.asm@rst08" - ; $0009 org $0010 "home/rst.asm@rst10" - ; $0011 org $0018 "home/rst.asm@rst18" - ; $0019 org $0020 "home/rst.asm@rst20" - ; $0021 org $0028 "home/rst.asm@rst28" - ; $0029 org $0030 "home/rst.asm@rst30" - ; $0031 org $0038 "home/rst.asm@rst38" - ; $003b org $0040 "home/interrupts.asm@VBlank interrupt vector" - ; $0043 org $0048 "home/interrupts.asm@LCD interrupt vector" - ; $004b org $0050 "home/interrupts.asm@Timer interrupt vector" - ; $0053 org $0058 "home/interrupts.asm@Serial interrupt vector" - ; $005b org $0060 "home/interrupts.asm@Joypad interrupt vector" - ; $0063 org $0100 "home/init.asm@Entry point" - ; $0104 org $014e "home/init.asm@Global check value" "home/vblank.asm" @@ -103,6 +91,7 @@ ROM0 "home/pokemon.asm@3AED" "home/misc_3c43.asm" "home/audio.asm" + ROMX $01 org $4000 "engine/link/place_waiting_text.asm" @@ -128,6 +117,7 @@ ROMX $01 "engine/dumps/bank01.asm@Function782c" "engine/overworld/object_collision.asm@_CheckPlayerObjectCollision" "engine/dumps/bank01.asm@SettingsScreen" + ROMX $02 "engine/dumps/bank02.asm@Function8000" "gfx.asm@Bank 2 Misc GFX" @@ -142,6 +132,7 @@ ROMX $02 "bin.asm@Unknownaebc" "gfx.asm@Corrupted SGB GFX" "bin.asm@Unknownbb43" + ROMX $03 org $4000 "engine/overworld/player_movement.asm@Player Movement" @@ -163,10 +154,10 @@ ROMX $03 "engine/dumps/bank03.asm@Functiond41d" "engine/items/item_effects.asm" "engine/dumps/bank03.asm@Functionf960" + ROMX $04 org $4000 "data/maps/maps.asm" - ; $4743 org $47cf "gfx.asm@Title Screen GFX" "engine/items/tmhm.asm" @@ -181,208 +172,202 @@ ROMX $04 "engine/unknown11d32.asm" "engine/menu/start_menu.asm" "gfx.asm@Trainer Card GFX" - ; $7be3 + ROMX $05 org $4000 "engine/overworld/player_movement.asm@_RedrawPlayerSprite" org $4150 "engine/sprites/sprites.asm@LoadOverworldSprite" - ; $4193 org $423b "engine/sprites/sprites.asm@OverworldSprites" - ; $43a7 + ROMX $06 org $4000 "gfx.asm@Bank 6 Tilesets 00" - ; $4400 org $5800 "gfx.asm@Bank 6 Tilesets 01" - ; $5c00 org $6600 "gfx.asm@Bank 6 Tilesets 02" - ; $6a00 org $7400 "gfx.asm@Bank 6 Tilesets 09" + ROMX $07 org $4000 "gfx.asm@Bank 7 Tilesets 13" - ; $4600 org $4b00 "gfx.asm@Bank 7 Tilesets 0e" - ; $5100 org $5600 "gfx.asm@Bank 7 Tilesets 06" - ; $5a00 org $6400 "gfx.asm@Bank 7 Tilesets 05" - ; $6800 org $7200 "gfx.asm@Bank 7 Tilesets 03" + ROMX $08 org $4000 "gfx.asm@Bank 8 Tilesets 04" - ; $4400 org $4e00 "gfx.asm@Bank 8 Tilesets 07" - ; $5200 org $5c00 "gfx.asm@Bank 8 Tilesets 08" - ; $6000 org $6a00 "gfx.asm@Bank 8 Tilesets 0f" - ; $7000 org $7500 "gfx.asm@Bank 8 Tilesets 11" + ROMX $09 org $4000 - ; $4000 + ROMX $0a org $4000 - ; $4000 org $5641 "gfx.asm@Gameboy GFX" + ROMX $0b org $4000 - ; $4000 + ROMX $0c org $4000 "gfx.asm@Bank C Tilesets 12" - ; $4600 org $4b00 "gfx.asm@Bank C Tilesets 0b" - ; $5100 org $5600 "gfx.asm@Bank C Tilesets 0d" - ; $5c00 org $6100 "gfx.asm@Bank C Tilesets 14" - ; $6700 org $7100 "gfx.asm@Bank C Tilesets 0c" - ; $7700 org $7c00 "gfx.asm@Bank C Tilesets Common" - ; $7e00 + ROMX $0d org $4000 - ; $4000 org $506d "data/types/type_matchups.asm" + ROMX $0e org $4000 - ; $4000 org $4494 "gfx.asm@PokeBalls GFX" - ; $44d4 org $4d90 "data/trainers/class_names.asm" - ; $4f45 org $5110 "data/trainers/parties.asm@Trainer Parties" + ROMX $0f org $4000 - ; $4000 org $63da "engine/battle/core.asm" - ; $6411 org $6a3c "data/wild.asm" + ROMX $10 org $4000 org $4943 "data/pokemon/dex_order_alpha.asm" - ; $4a3e org $4ecc "data/types/search_strings.asm" - ; $4f17 org $5068 "data/types/search_types.asm" - ; $5077 org $52a1 "data/moves/names.asm" - ; $58b6 org $6493 "data/pokemon/evos_attacks.asm" + ROMX $11 org $4000 - ; $4000 org $40d5 "gfx.asm@Pokedex GFX" + ROMX $12 org $4000 "gfx.asm@Trainer Battle Sprites" + ROMX $13 org $4000 "gfx.asm@Bank 13 Tilesets 0a" - ; $4600 org $4b00 "gfx.asm@Bank 13 Tilesets 16" - ; $5100 org $5b00 "gfx.asm@Bank 13 Tilesets 19" - ; $5f00 org $6900 "gfx.asm@Bank 13 Tilesets 1a" + ROMX $14 org $4000 org $40dd "data/types/names.asm" - ; $4162 org $4f10 "data/pokemon/base_stats.asm" "data/pokemon/names.asm" "gfx.asm@PKMN Sprite Bank List" + ROMX $15 org $4000 "gfx/pokemon/pkmn_pics.asm@PKMN Pics 1" + ROMX $16 org $4000 "gfx/pokemon/pkmn_pics.asm@PKMN Pics 2" + ROMX $17 org $4000 "gfx/pokemon/pkmn_pics.asm@PKMN Pics 3" + ROMX $18 org $4000 "gfx/pokemon/pkmn_pics.asm@PKMN Pics 4" + ROMX $19 org $4000 "gfx/pokemon/pkmn_pics.asm@PKMN Pics 5" + ROMX $1a org $4000 "gfx/pokemon/pkmn_pics.asm@PKMN Pics 6" + ROMX $1b org $4000 "gfx/pokemon/pkmn_pics.asm@PKMN Pics 7" + ROMX $1c org $4000 "gfx/pokemon/pkmn_pics.asm@PKMN Pics 8" + ROMX $1d org $4000 "gfx/pokemon/pkmn_pics.asm@PKMN Pics 9" + ROMX $1e org $4000 "gfx/pokemon/pkmn_pics.asm@PKMN Pics 10" + ROMX $1f org $4000 "gfx/pokemon/pkmn_pics.asm@PKMN Pics 11" "gfx.asm@Annon Pic Ptrs and Pics" "gfx/pokemon/egg.asm" + ROMX $21 org $4000 "gfx.asm@Attack Animation GFX" + ROMX $23 org $4000 org $433e "engine/palettes.asm@Overworld fade" org $43d1 "engine/palettes.asm@Palette fading, part 2?" - ; $446d org $60cc "gfx.asm@Pokemon Party Sprites" + org $722a + "data/pokemon/menu_icons.asm" + ROMX $24 org $4000 org $4fdb "gfx.asm@Slot Machine GFX" + ROMX $25 org $4000 "data/maps/attributes/placeholder/Route2Gate1F.asm" @@ -425,6 +410,7 @@ ROMX $25 "maps/placeholder/OldCityKurtsHouse.asm" "data/maps/attributes/placeholder/OldCitySchool.asm" "maps/placeholder/OldCitySchool.asm" + ROMX $26 org $4000 "data/maps/attributes/Route1Gate1F.asm" @@ -467,6 +453,7 @@ ROMX $26 "maps/placeholder/WestHouse1.asm" "data/maps/attributes/placeholder/WestHouse2.asm" "maps/placeholder/WestHouse2.asm" + ROMX $27 org $4000 "data/maps/attributes/placeholder/HaitekuWestRouteGate.asm" @@ -709,6 +696,7 @@ ROMX $27 "maps/placeholder/NorthPokecenter1F.asm" "data/maps/attributes/placeholder/NorthPokecenter2F.asm" "maps/placeholder/NorthPokecenter2F.asm" + ROMX $2f org $4000 "data/maps/attributes/placeholder/PowerPlant1.asm" @@ -749,18 +737,22 @@ ROMX $2f "maps/placeholder/SlowpokeWellMain.asm" "data/maps/attributes/ShizukanaOka.asm" "maps/ShizukanaOka.asm" + ROMX $30 org $4000 "gfx.asm@Bank 30 Sprites 1" + ROMX $31 org $4000 "gfx.asm@Bank 31 Sprites 2" + ROMX $32 org $4000 "engine/battle_anims/bg_effects.asm" - ; $4cfe + ROMX $33 org $4000 + ROMX $34 org $4000 "data/maps/attributes/placeholder/RouteSilentEastGate.asm" @@ -779,6 +771,7 @@ ROMX $34 "maps/SilentHillLabBack.asm" "data/maps/attributes/UnusedMap13.asm" "maps/UnusedMap13.asm" + ROMX $36 org $4000 "maps/placeholder/dummy_text_pointers.asm" @@ -865,57 +858,52 @@ ROMX $36 "engine/menu/set_time.asm" "maps/Route1P1.asm" "maps/Route1P2.asm" + ROMX $37 org $4000 "gfx.asm@Bank 37 Tilesets 10" - ; $4600 org $4b00 "gfx.asm@Bank 37 Tilesets 15" - ; $5100 org $5b00 "gfx.asm@Bank 37 Tilesets 17" - ; $6100 org $6b00 "gfx.asm@Bank 37 Tilesets 18" + ROMX $38 org $4000 org $5403 "gfx.asm@Poker GFX" - ; $5ae3 org $5f93 "gfx.asm@15 Puzzle GFX" - ; $6213 org $6606 "gfx.asm@Matches GFX" - ; $6886 org $75b7 "gfx.asm@Picross GFX" + ROMX $39 org $4000 org $41ff "gfx.asm@Gamefreak Logo GFX" org $4adf "gfx.asm@Intro Underwater GFX" - ; $52df org $55ef "gfx.asm@Intro Water Mon and Forest GFX" - ; $60ef org $626f "gfx.asm@Intro Mon" + ROMX $3a org $4000 "audio/engine.asm@Audio" - ; $410b org $42bd "audio/engine.asm@IsChannelSFXOn" "audio/engine.asm@Functione82f0" org $4cee "audio/engine.asm@Audio engine, part 2" - ; $4d8d org $52c7 "audio/engine.asm@Song Header Pointers" org $52ee "audio/songs/none.asm" + ROMX $3b org $4000 "audio/songs/nidorinointro.asm" @@ -929,51 +917,48 @@ ROMX $3b "audio/songs/spottedrocket.asm" "audio/songs/victorytrainer.asm" "audio/songs/evolution.asm" + ROMX $3c org $4000 - ; $4000 org $51cb "audio/cries.asm" - ; $51cb org $62fe "audio/songs/title.asm" + ROMX $3e org $4000 "engine/gfx.asm" "gfx.asm@Misc GFX" + ROMX $3f org $4000 - ; $4000 org $4362 "engine/menu/reset_dialog.asm" - ; $4381 org $4aa5 "engine/landmarks.asm" "data/maps/landmarks.asm" - ; $4bc6 org $506f "gfx.asm@Town Map Cursor" - ; $50af + WRAM0 org $c000 "Music engine RAM" - ; $c1bc org $c200 "OAM Buffer" - ; $c570 org $c5e8 "Map Buffer" org $dfff "Stack Bottom" + VRAM 0 "VRAM" + HRAM "HRAM" + SRAM 0 "Sprite Buffers" - ; $a498 org $a600 "Unknown, bank 0" - ; $a607 org $bffe "Window Stack Top" diff --git a/maps/Route1P2.asm b/maps/Route1P2.asm index ae7e399..29b74f1 100644 --- a/maps/Route1P2.asm +++ b/maps/Route1P2.asm @@ -48,7 +48,7 @@ Route1P2Script:: ; 7C7F Route1P2Text1: ; 7CA7 ld hl, Route1P2TextString4 call OpenTextbox - call RotateFourPalettesLeft + call GBFadeOutToBlack jp Init Route1P2Text2: ; 7CB3 @@ -61,7 +61,7 @@ 0B:5663 Function2d663 0E:4B78 LoadTrainerClassName -0E:4BA0 LoadTrainerClassName.got_name +;0E:4BA0 LoadTrainerClassName.got_name 0E:4BA9 LoadTrainerClass 0D:7E3D Function37e3d @@ -179,5 +179,5 @@ 3F:64CE MonsterTest 3F:654E PicTest 3F:6750 PicTestMenu -3F:6755 PicTestMenu.loop +;3F:6755 PicTestMenu.loop 3F:67A1 CallSubGameMenu diff --git a/tools/fix_sections.py b/tools/fix_sections.py deleted file mode 100644 index dc23f52..0000000 --- a/tools/fix_sections.py +++ /dev/null @@ -1,137 +0,0 @@ -import os, errno -import re -import fix_sections_directory - -os.chdir("..") -cwd = os.getcwd() - -debug_lines_startswith = [ - "SECTION ", - "else", - "SECTION ", - "endc" -] - -with open("pokegold-spaceworld-gen.link", "r") as f: - linkerscript = f.read() - -def clean_section(line, file, multiple): - global linkerscript - lines = line.lstrip().split("\"") - if "@" in lines[1] or file == lines[1] or file == "hram.asm" or file == "vram.asm" or file == "sram.asm": - file = lines[1] - else: - file += ("@" + lines[1]) if multiple else "" - - linkerscript = linkerscript.replace("\"" + lines[1] + "\"", "\"" + file + "\"") - if "ROMX" in lines[2]: - return "SECTION \"%s\", ROMX" % file - elif "HRAM" in lines[2]: - return "SECTION \"%s\", HRAM" % file - elif "VRAM" in lines[2]: - return "SECTION \"%s\", VRAM" % file - elif "ROM0" in lines[2]: - return "SECTION \"%s\", ROM0" % file - elif "SRAM" in lines[2]: - return "SECTION \"%s\", SRAM" % file - else: - raise - -TEMP_PATH = fix_sections_directory.TEMP_DIRECTORY - -for root, dirs, files in os.walk(cwd): - for file in files: - rel_root = os.path.relpath(root, cwd) - if not rel_root.startswith("build") and not rel_root.startswith("temp") and file.endswith(".asm") and file != "rst.asm" and file != "wram.asm" and file != "zero_checksum.asm": - canonical_path = os.path.join(root, file) - rel_path = os.path.relpath(canonical_path, cwd) - with open(canonical_path, "r") as f: - contents = f.read() - content_lines = contents.splitlines() - - if "SECTION" in contents: - print(canonical_path) - modify_flag = False - skip_next_line = False - for i, line in enumerate(content_lines): - if not skip_next_line: - if line.lstrip().startswith("SECTION"): - modify_flag = True - content_lines[i] = clean_section(content_lines[i], rel_path, contents.count("SECTION") > 1) - elif "if DEBUG" in line: - debug_content_lines = content_lines[i+1:i+5] - debug_code = False - for debug_content_line, debug_line_startswith in zip(debug_content_lines, debug_lines_startswith): - if not debug_content_line.lstrip().startswith(debug_line_startswith): - break - else: - modify_flag = True - content_lines[i] = "; " + content_lines[i] - content_lines[i+1] = clean_section(content_lines[i+1], rel_path, contents.count("SECTION") > 2) - content_lines[i+2] = "; " + content_lines[i+2] - content_lines[i+3] = "; " + content_lines[i+3] - content_lines[i+4] = "; " + content_lines[i+4] - skip_next_line = True - else: - skip_next_line = False - - if modify_flag: - output = "\n".join(content_lines) - print("rel root: " + rel_root) - try: - os.makedirs(TEMP_PATH + rel_root) - except OSError as e: - if e.errno != errno.EEXIST: - raise - - with open(TEMP_PATH + rel_path, "w+") as f: - f.write(output) - -linkerscript_lines = linkerscript.splitlines() - -i = 0 -clean_wram = False - -while i < len(linkerscript_lines): - line = linkerscript_lines[i] - if clean_wram: - if "org $dfff" not in line: - print(linkerscript_lines.pop(i)) - else: - clean_wram = False - i += 1 - elif "\"Shim for " in line: - no_pop_count = 0 - shim_addr = line.replace(", ", " ; ").split(" ; ")[1] - if linkerscript_lines[i-1] == "\torg " + shim_addr and linkerscript_lines[i-1] != "\torg $4000": - print(linkerscript_lines.pop(i-1)) - else: - no_pop_count += 1 - print(linkerscript_lines.pop(i-1 + no_pop_count)) - - if linkerscript_lines[i-1 + no_pop_count] == "\t; " + shim_addr: - print(linkerscript_lines.pop(i-1 + no_pop_count)) - else: - no_pop_count += 1 - - i -= 3 - no_pop_count - print("") - elif "ROMX" in line and "org $4000" not in linkerscript_lines[i+1]: - linkerscript_lines.insert(i+1, "\torg $4000") - i += 1 - elif line.startswith("WRAM0"): - linkerscript_lines.insert(i+1, "\torg $c000") - i += 1 - elif "\"Map Buffer\"" in line: - clean_wram = True - i += 1 - else: - i += 1 - -for i in range(len(linkerscript_lines)): - linkerscript_lines[i] = linkerscript_lines[i].split(" ; ")[0] - -linkerscript = "\n".join(linkerscript_lines) + "\n" - -with open(TEMP_PATH + "pokegold-spaceworld.link", "w+") as f: - f.write(linkerscript)
\ No newline at end of file diff --git a/tools/fix_sections_directory.py b/tools/fix_sections_directory.py deleted file mode 100644 index d359c8c..0000000 --- a/tools/fix_sections_directory.py +++ /dev/null @@ -1 +0,0 @@ -TEMP_DIRECTORY = ""
\ No newline at end of file diff --git a/tools/make_shim.py b/tools/make_shim.py index e2e4bf2..e88e3fc 100644 --- a/tools/make_shim.py +++ b/tools/make_shim.py @@ -1,4 +1,5 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- from __future__ import print_function import argparse diff --git a/tools/scan_includes.py b/tools/scan_includes.py index 34e1f09..c30adc0 100644 --- a/tools/scan_includes.py +++ b/tools/scan_includes.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Get all the dependencies of RGBDS assembly files recursively, diff --git a/tools/sort_sym.py b/tools/sort_sym.py deleted file mode 100644 index f4674e8..0000000 --- a/tools/sort_sym.py +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/python3.6 - -import argparse -from functools import total_ordering - - -@total_ordering -class GBSection: - ROM0 = 0 - ROMX = 1 - VRAM = 2 - SRAM = 3 - WRAM0 = 4 - WRAMX = 5 - - __thresholds__ = (0x4000, 0x8000, 0xa000, 0xc000, 0xd000, 0xe000) - - def __init__(self, addr): - self.ident = sum(x <= addr for x in self.__thresholds__) - - @property - def start(self): - if self.ident == self.ROM0: - return 0 - return self.__thresholds__[self.ident - 1] - - @property - def end(self): - return self.__thresholds__[self.ident] - - def __eq__(self, other): - return self.ident == other.ident - - def __lt__(self, other): - return self.ident < other.ident - - -def read_sym(filename): - with open(filename) as fp: - for line in fp: - try: - line, *rest = line.split(';') - pointer, name = line.split() - bank, addr = (int(part, 16) for part in pointer.split(':')) - yield bank, addr, name - except ValueError: - continue - - -def sort_key(args): - bank, addr, name = args - return GBSection(addr), bank, addr, name - - -def main(): - parser = argparse.ArgumentParser() - parser.add_argument('symfile') - args = parser.parse_args() - - symbols = list(read_sym(args.symfile)) - symbols.sort(key=sort_key) - with open(args.symfile, 'w') as fp: - for bank, addr, name in symbols: - print(f'{bank:02X}:{addr:04X}', name, file=fp) - - -if __name__ == '__main__': - main() diff --git a/tools/sort_symfile.sh b/tools/sort_symfile.sh deleted file mode 100755 index 82fced5..0000000 --- a/tools/sort_symfile.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -sed \ - -e "s/^..:[0-3]/0_ROM0@&/g" \ - -e "s/^..:[4-7]/1_ROMX@&/g" \ - -e "s/^..:[8-9]/2_VRAM@&/g" \ - -e "s/^..:[A-B]/3_SRAM@&/g" \ - -e "s/^00:[C-D]/4_WRAM0@&/g" \ - -e "s/^..:[D-D]/5_WRAMX@&/g" \ - $1 \ -| sort -o $1 -TEMP_FILE=$(mktemp) -sed -e "s/^.*@//g" $1 > $TEMP_FILE && mv $TEMP_FILE $1 diff --git a/tools/__init__.py b/utils/__init__.py index b64ec3b..b64ec3b 100644 --- a/tools/__init__.py +++ b/utils/__init__.py diff --git a/compare.sh b/utils/compare.sh index b52696d..44e0771 100644 --- a/compare.sh +++ b/utils/compare.sh @@ -8,4 +8,4 @@ fi hexdump -C pokegold-spaceworld.gb > pokegold-spaceworld.txt -diff -u baserom.txt pokegold-spaceworld.txt | less
\ No newline at end of file +diff -u baserom.txt pokegold-spaceworld.txt | less diff --git a/tools/disasm_coverage.py b/utils/disasm_coverage.py index 9fcd61e..6a68730 100644 --- a/tools/disasm_coverage.py +++ b/utils/disasm_coverage.py @@ -1,5 +1,5 @@ -# #!/usr/bin/env python3 -# coding: utf-8 +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- from __future__ import division @@ -45,7 +45,8 @@ if __name__ == '__main__': if (romname is not None): with open(romname, 'rb') as f: for rb in range(0, args.num_banks): - data = r.bank_data['ROM Bank'].get(rb, default_bank_data) + bank_data = r.bank_data['ROM0 bank' if rb == 0 else 'ROMX bank'] + data = bank_data.get(rb, default_bank_data) bank = f.read(bank_size) if (bank[bank_size - 1] in filler): fill = bank[bank_size - 1] @@ -59,7 +60,8 @@ if __name__ == '__main__': hit_data = [[0] * width for _ in range(height)] for bank in range(args.num_banks): - data = r.bank_data['ROM Bank'].get(bank, default_bank_data) + bank_data = r.bank_data['ROM0 bank' if bank == 0 else 'ROMX bank'] + data = bank_data.get(bank, default_bank_data) for s in data['sections']: beg = (s['beg'] & bank_mask) + bank * bank_size end = ((s['end'] -1) & bank_mask) + bank * bank_size # end is exclusive diff --git a/tools/dump_names.py b/utils/dump_names.py index 81f357a..12eafb5 100644 --- a/tools/dump_names.py +++ b/utils/dump_names.py @@ -1,4 +1,5 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 +# -*- coding: utf-8 -*- import sys, os, io from read_charmap import read_charmap diff --git a/tools/dump_text.py b/utils/dump_text.py index 808f674..c36298e 100644 --- a/tools/dump_text.py +++ b/utils/dump_text.py @@ -1,4 +1,5 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- import argparse import sys diff --git a/tools/gfx.py b/utils/gfx.py index 3ccafe0..80c84d3 100644 --- a/tools/gfx.py +++ b/utils/gfx.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python2 # -*- coding: utf-8 -*- import os diff --git a/tools/lz.py b/utils/lz.py index aef5c64..aef5c64 100644 --- a/tools/lz.py +++ b/utils/lz.py diff --git a/tools/map2link.py b/utils/map2link.py index f1cd3a3..2c7d40c 100644 --- a/tools/map2link.py +++ b/utils/map2link.py @@ -1,4 +1,5 @@ -#!/bin/python3.6 +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- import argparse import re diff --git a/tools/mapreader.py b/utils/mapreader.py index 41ad935..1164cc4 100644 --- a/tools/mapreader.py +++ b/utils/mapreader.py @@ -1,5 +1,6 @@ -# #!/usr/bin/env python3 -# coding: utf-8 +# -*- coding: utf-8 -*- + +# A library for parsing the pokegold-spaceworld.map file output by rgbds. import re @@ -37,30 +38,31 @@ class MapReader: bank_types = { 'HRAM' : { 'size': 0x80, 'banked': False, }, 'OAM' : { 'size': 0xA0, 'banked': False, }, - 'ROM Bank' : { 'size': 0x4000, 'banked': True, }, - 'SRAM Bank': { 'size': 0x2000, 'banked': True, }, - 'VRAM Bank': { 'size': 0x1000, 'banked': True, }, - 'WRAM Bank': { 'size': 0x2000, 'banked': True, }, + 'ROM0 bank': { 'size': 0x4000, 'banked': True, }, + 'ROMX bank': { 'size': 0x4000, 'banked': True, }, + 'SRAM bank': { 'size': 0x2000, 'banked': True, }, + 'VRAM bank': { 'size': 0x1000, 'banked': True, }, + 'WRAM bank': { 'size': 0x2000, 'banked': True, }, } - + # FSM states INIT, BANK, SECTION = range(3) - + # $506D-$519A ($012E bytes) ["Type Matchups"] section_header_regex = re.compile('\$([0-9A-Fa-f]{4})-\$([0-9A-Fa-f]{4}) \(.*\) \["(.*)"\]') # $506D = TypeMatchups section_data_regex = re.compile('\$([0-9A-Fa-f]{4}) = (.*)') # $3ED2 bytes - slack_regex = re.compile('\$([0-9A-Fa-f]{4}) bytes') + slack_regex = re.compile('\$([0-9A-Fa-f]{4}) bytes?') def __init__(self, *args, **kwargs): self.__dict__.update(kwargs) - + def _parse_init(self, line): - + line = line.split(':', 1)[0] parts = line.split(' #', 1) - + if (parts[0] in self.bank_types): self._cur_bank_name = parts[0] self._cur_bank_type = self.bank_types[self._cur_bank_name] @@ -76,17 +78,17 @@ class MapReader: self._cur_data = self.bank_data[self._cur_bank_name][self._cur_bank] else: self._cur_data = self.bank_data[self._cur_bank_name] - + if ({} == self._cur_data): self._cur_data['sections'] = [] self._cur_data['used'] = 0 self._cur_data['slack'] = self._cur_bank_type['size'] return True - + return False - + def _parse_section_header(self, header): - + section_data = self.section_header_regex.match(header) if section_data is not None: beg = int(section_data.group(1), 16) @@ -96,48 +98,48 @@ class MapReader: self._cur_data['sections'].append(self._cur_section) return True return False - + def _parse_slack(self, data): - + slack_data = self.slack_regex.match(data) slack_bytes = int(slack_data.group(1), 16) self._cur_data['slack'] = slack_bytes - + used_bytes = 0 - + for s in self._cur_data['sections']: used_bytes += s['end'] - s['beg'] + 1 - + self._cur_data['used'] = used_bytes - + def read_map_data(self, map): - + if type(map) is str: map = map.split('\n') - + self._state = MapReader.INIT self._cur_bank_name = '' self._cur_bank_type = {} self._cur_bank = 0 self._cur_data = {} - + for line in map: - + line = line.rstrip() if (MapReader.INIT == self._state): - + if (self._parse_init(line)): self._state = MapReader.BANK - + elif (MapReader.BANK == self._state or MapReader.SECTION == self._state): - + if ('' == line): self._state = MapReader.INIT else: - + line = line.lstrip() parts = line.split(': ', 1) - + if (MapReader.SECTION == self._state): section_data = self.section_data_regex.match(parts[0]) if section_data is not None: @@ -145,7 +147,7 @@ class MapReader: name = section_data.group(2) self._cur_section['symbols'].append({'name': name, 'address': address}) continue - + if ('SECTION' == parts[0]): if (self._parse_section_header(parts[1])): self._state = MapReader.SECTION @@ -155,10 +157,10 @@ class MapReader: elif ('EMPTY' == parts[0]): self._cur_data = {'sections': [], 'used': 0, 'slack': self._cur_bank_type['size']} self._state = MapReader.INIT - + else: pass - + for k, v in self.bank_data.items(): if (self.bank_types[k]['banked']): for _, vv in v.items(): @@ -168,4 +170,4 @@ class MapReader: else: v['sections'].sort(key=lambda x: x['beg']) for vv in v['sections']: - vv['symbols'].sort(key=lambda x: x['address'])
\ No newline at end of file + vv['symbols'].sort(key=lambda x: x['address']) diff --git a/tools/png.py b/utils/png.py index db6da12..db6da12 100644 --- a/tools/png.py +++ b/utils/png.py diff --git a/tools/read_charmap.py b/utils/read_charmap.py index af290c3..77036f6 100644 --- a/tools/read_charmap.py +++ b/utils/read_charmap.py @@ -1,3 +1,6 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + import os, io from re import compile from sys import stderr diff --git a/tools/tests/README.txt b/utils/tests/README.txt index 750482e..750482e 100644 --- a/tools/tests/README.txt +++ b/utils/tests/README.txt diff --git a/tools/tests/charmap.asm b/utils/tests/charmap.asm index 70e228c..70e228c 100644 --- a/tools/tests/charmap.asm +++ b/utils/tests/charmap.asm diff --git a/tools/tests/dump_test.cc.txt b/utils/tests/dump_test.cc.txt index 4dfd14a..4dfd14a 100644 --- a/tools/tests/dump_test.cc.txt +++ b/utils/tests/dump_test.cc.txt diff --git a/tools/tests/dump_test.cc_endless.txt b/utils/tests/dump_test.cc_endless.txt index 5c59830..5c59830 100644 --- a/tools/tests/dump_test.cc_endless.txt +++ b/utils/tests/dump_test.cc_endless.txt diff --git a/tools/tests/dump_test.cc_tc.txt b/utils/tests/dump_test.cc_tc.txt index e49a010..e49a010 100644 --- a/tools/tests/dump_test.cc_tc.txt +++ b/utils/tests/dump_test.cc_tc.txt diff --git a/tools/tests/dump_test.cc_tc_endless.txt b/utils/tests/dump_test.cc_tc_endless.txt index dbf8e8b..dbf8e8b 100644 --- a/tools/tests/dump_test.cc_tc_endless.txt +++ b/utils/tests/dump_test.cc_tc_endless.txt diff --git a/tools/tests/dump_test.endless.txt b/utils/tests/dump_test.endless.txt index fbbdeef..fbbdeef 100644 --- a/tools/tests/dump_test.endless.txt +++ b/utils/tests/dump_test.endless.txt diff --git a/tools/tests/dump_test.tc.txt b/utils/tests/dump_test.tc.txt index 82c276d..82c276d 100644 --- a/tools/tests/dump_test.tc.txt +++ b/utils/tests/dump_test.tc.txt diff --git a/tools/tests/dump_test.tc_endless.txt b/utils/tests/dump_test.tc_endless.txt index 37bdda0..37bdda0 100644 --- a/tools/tests/dump_test.tc_endless.txt +++ b/utils/tests/dump_test.tc_endless.txt diff --git a/tools/tests/dump_test.txt b/utils/tests/dump_test.txt index a181744..a181744 100644 --- a/tools/tests/dump_test.txt +++ b/utils/tests/dump_test.txt diff --git a/tools/tests/dump_text_test.bin b/utils/tests/dump_text_test.bin Binary files differindex 778a446..778a446 100644 --- a/tools/tests/dump_text_test.bin +++ b/utils/tests/dump_text_test.bin @@ -401,6 +401,7 @@ wMenuDataPointer:: dw ; cc07 wMenuCursorBuffer:: db ; cc09 ; cc0a ds 8 ; TODO +wMenuDataHeaderEnd:: wMenuData2:: wMenuDataFlags:: db ; cc12 @@ -619,7 +620,7 @@ wcd80:: db ; cd80 wcd81:: db ; cd81 SECTION "CD9E", WRAM0 [$CD9E] -wcd9e:: db ; cd9e +wLoadedMonLevel:: db ; cd9e SECTION "CDAF", WRAM0 [$CDAF] wcdaf:: db ; cdaf diff --git a/zero_checksum.asm b/zero_checksum.asm deleted file mode 100644 index c35e834..0000000 --- a/zero_checksum.asm +++ /dev/null @@ -1,6 +0,0 @@ - -; This is part of a workaround to RGBFIX 0.3.7, which does not compute the global checksum correctly -; if it's not 0 in the pre-fix ROM. See https://github.com/rednex/rgbds/issues/280 - -SECTION "RGBFIX 0.3.7 workaround", ROM0[$14E] - dw 0
\ No newline at end of file |