From 8396935a07863484d1ce8a620511fbe645980fde Mon Sep 17 00:00:00 2001 From: yenatch Date: Fri, 11 Jul 2014 11:02:04 -0700 Subject: [PATCH 001/100] Comment the makefile. --- Makefile | 48 +++++++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index ec1ca45511..7b2970591a 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,22 @@ +# If your default python is 3, you may want to change this to python27. PYTHON := python + +# md5sum -c is used to compare rom hashes. The options may vary across platforms. MD5 := md5sum -c --quiet +# Clear the default suffixes. .SUFFIXES: .SUFFIXES: .asm .tx .o .gbc + .PHONY: all clean red blue yellow compare -.PRECIOUS: %.2bpp + +# Secondary expansion is required for dependency variables in object rules. .SECONDEXPANSION: +# Suppress annoying intermediate file deletion messages. +.PRECIOUS: %.2bpp + +# Filepath shortcuts to avoid overly long recipes. poketools := extras/pokemontools gfx := $(PYTHON) $(poketools)/gfx.py pic := $(PYTHON) $(poketools)/pic.py @@ -16,6 +26,8 @@ pre := $(PYTHON) prequeue.py versions := red blue yellow +# Collect file dependencies for objects in red/, blue/ and yellow/. +# These aren't provided by rgbds by default, so we have to look for file includes ourselves. $(foreach ver, $(versions), \ $(eval $(ver)_asm := $(shell find $(ver) -iname '*.asm')) \ $(eval $(ver)_obj := $($(ver)_asm:.asm=.o)) \ @@ -26,6 +38,7 @@ $(foreach obj, $(all_obj), \ ) +# Build Red/Blue. Yellow is WIP. roms := pokered.gbc pokeblue.gbc all: $(roms) @@ -40,22 +53,34 @@ clean: find . \( -iname '*.tx' -o -iname '*.1bpp' -o -iname '*.2bpp' -o -iname '*.pic' \) -exec rm {} + +# Image files are added to a queue to reduce build time. They're converted when building parent objects. +%.2bpp: %.png ; $(eval 2bppq += $<) @rm -f $@ +%.1bpp: %.png ; $(eval 1bppq += $<) @rm -f $@ +%.pic: %.2bpp ; $(eval picq += $<) @rm -f $@ + +# Source files are not fed directly into rgbasm. +# A python preprocessor runs over them first, replacing ascii strings with correct character codes. +# It spits out the new file with extension .tx. +# The text preprocessor also uses a queue. %.asm: ; -%.tx: %.asm - $(eval txq += $<) - @rm -f $@ +%.tx: %.asm ; $(eval txq += $<) @rm -f $@ $(all_obj): $$*.tx $$(patsubst %.asm, %.tx, $$($$*_dep)) + @# The queue payloads are here. + @# These are made silent since there may be hundreds of targets. @$(pre) $(txq); $(eval txq :=) @$(gfx) 2bpp $(2bppq); $(eval 2bppq :=) @$(gfx) 1bpp $(1bppq); $(eval 1bppq :=) @$(pic) compress $(picq); $(eval picq :=) + @# rgbasm -h for manual halt-nops. rgbasm -h -o $@ $*.tx +# Link objects together to build a rom. +# Make a symfile for debugging. rgblink will segfault if a mapfile isn't made too. link = rgblink -n $*.sym -m $*.map -dmg_opt := -jsv -k 01 -l 0x33 -m 0x13 -p 0 -r 03 -cgb_opt := -cjsv -k 01 -l 0x33 -m 0x1b -p 0 -r 03 +dmg_opt = -jsv -k 01 -l 0x33 -m 0x13 -p 0 -r 03 +cgb_opt = -cjsv -k 01 -l 0x33 -m 0x1b -p 0 -r 03 pokered.gbc: $(red_obj) $(link) -o $@ $^ @@ -68,14 +93,3 @@ pokeblue.gbc: $(blue_obj) pokeyellow.gbc: $(yellow_obj) $(link) -o $@ $^ rgbfix $(cgb_opt) -t "POKEMON YELLOW" $@ - - -%.2bpp: %.png - $(eval 2bppq += $<) - @rm -f $@ -%.1bpp: %.png - $(eval 1bppq += $<) - @rm -f $@ -%.pic: %.2bpp - $(eval picq += $<) - @rm -f $@ From 8f7135aa693f8606aa90aa1d4f099ee965c5fe84 Mon Sep 17 00:00:00 2001 From: yenatch Date: Fri, 11 Jul 2014 11:50:02 -0700 Subject: [PATCH 002/100] Reorganize makefile targets for clarity. --- Makefile | 62 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 25 deletions(-) diff --git a/Makefile b/Makefile index 7b2970591a..12e232976d 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,39 @@ +# Build Red/Blue. Yellow is WIP. +roms := pokered.gbc pokeblue.gbc + + +.PHONY: all clean red blue yellow compare + +all: $(roms) +red: pokered.gbc +blue: pokeblue.gbc +yellow: pokeyellow.gbc + +versions := red blue yellow + + +# Header options for rgbfix. +dmg_opt = -jsv -k 01 -l 0x33 -m 0x13 -p 0 -r 03 +cgb_opt = -cjsv -k 01 -l 0x33 -m 0x1b -p 0 -r 03 + +red_opt = $(dmg_opt) -t "POKEMON RED" +blue_opt = $(dmg_opt) -t "POKEMON BLUE" +yellow_opt = $(cgb_opt) -t "POKEMON YELLOW" + + + # If your default python is 3, you may want to change this to python27. PYTHON := python # md5sum -c is used to compare rom hashes. The options may vary across platforms. -MD5 := md5sum -c --quiet +MD5 := md5sum -c --quiet +compare: + @$(MD5) roms.md5 # Clear the default suffixes. .SUFFIXES: .SUFFIXES: .asm .tx .o .gbc -.PHONY: all clean red blue yellow compare - # Secondary expansion is required for dependency variables in object rules. .SECONDEXPANSION: @@ -24,7 +48,6 @@ includes := $(PYTHON) $(poketools)/scan_includes.py pre := $(PYTHON) prequeue.py -versions := red blue yellow # Collect file dependencies for objects in red/, blue/ and yellow/. # These aren't provided by rgbds by default, so we have to look for file includes ourselves. @@ -38,21 +61,6 @@ $(foreach obj, $(all_obj), \ ) -# Build Red/Blue. Yellow is WIP. -roms := pokered.gbc pokeblue.gbc - -all: $(roms) -red: pokered.gbc -blue: pokeblue.gbc -yellow: pokeyellow.gbc - -compare: - @$(MD5) roms.md5 -clean: - rm -f $(roms) $(all_obj) - find . \( -iname '*.tx' -o -iname '*.1bpp' -o -iname '*.2bpp' -o -iname '*.pic' \) -exec rm {} + - - # Image files are added to a queue to reduce build time. They're converted when building parent objects. %.2bpp: %.png ; $(eval 2bppq += $<) @rm -f $@ %.1bpp: %.png ; $(eval 1bppq += $<) @rm -f $@ @@ -77,19 +85,23 @@ $(all_obj): $$*.tx $$(patsubst %.asm, %.tx, $$($$*_dep)) # Link objects together to build a rom. + # Make a symfile for debugging. rgblink will segfault if a mapfile isn't made too. -link = rgblink -n $*.sym -m $*.map -dmg_opt = -jsv -k 01 -l 0x33 -m 0x13 -p 0 -r 03 -cgb_opt = -cjsv -k 01 -l 0x33 -m 0x1b -p 0 -r 03 +link = rgblink -n $*.sym -m $*.map pokered.gbc: $(red_obj) $(link) -o $@ $^ - rgbfix $(dmg_opt) -t "POKEMON RED" $@ + rgbfix $(red_opt) $@ pokeblue.gbc: $(blue_obj) $(link) -o $@ $^ - rgbfix $(dmg_opt) -t "POKEMON BLUE" $@ + rgbfix $(blue_opt) $@ pokeyellow.gbc: $(yellow_obj) $(link) -o $@ $^ - rgbfix $(cgb_opt) -t "POKEMON YELLOW" $@ + rgbfix $(yellow_opt) $@ + + +clean: + rm -f $(roms) $(all_obj) + find . \( -iname '*.tx' -o -iname '*.1bpp' -o -iname '*.2bpp' -o -iname '*.pic' \) -exec rm {} + From 9ab6327361190b04b27a2ada2a83210e1cb963b5 Mon Sep 17 00:00:00 2001 From: yenatch Date: Fri, 11 Jul 2014 12:01:05 -0700 Subject: [PATCH 003/100] Remove inline comments in an object recipe. --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 12e232976d..0d8db6bdb0 100644 --- a/Makefile +++ b/Makefile @@ -73,14 +73,14 @@ $(foreach obj, $(all_obj), \ %.asm: ; %.tx: %.asm ; $(eval txq += $<) @rm -f $@ +# Assemble source files into objects. +# Queue payloads are here. These are made silent since there may be hundreds of targets. +# Use rgbasm -h to use halts without nops. $(all_obj): $$*.tx $$(patsubst %.asm, %.tx, $$($$*_dep)) - @# The queue payloads are here. - @# These are made silent since there may be hundreds of targets. @$(pre) $(txq); $(eval txq :=) @$(gfx) 2bpp $(2bppq); $(eval 2bppq :=) @$(gfx) 1bpp $(1bppq); $(eval 1bppq :=) @$(pic) compress $(picq); $(eval picq :=) - @# rgbasm -h for manual halt-nops. rgbasm -h -o $@ $*.tx From dbef0efa6c44245907bea443fdee58c937ee54c7 Mon Sep 17 00:00:00 2001 From: yenatch Date: Fri, 11 Jul 2014 12:14:39 -0700 Subject: [PATCH 004/100] Add image suffixes to the makefile. Explicitly define png dependencies (none). This keeps make from looking for nonexistent dependencies with extensions like ".png.o". This doesn't make it go any faster, but it at least makes debug easier. --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 0d8db6bdb0..b61c050285 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ compare: # Clear the default suffixes. .SUFFIXES: -.SUFFIXES: .asm .tx .o .gbc +.SUFFIXES: .asm .tx .o .gbc .png .2bpp .1bpp .pic # Secondary expansion is required for dependency variables in object rules. .SECONDEXPANSION: @@ -62,6 +62,7 @@ $(foreach obj, $(all_obj), \ # Image files are added to a queue to reduce build time. They're converted when building parent objects. +%.png: ; %.2bpp: %.png ; $(eval 2bppq += $<) @rm -f $@ %.1bpp: %.png ; $(eval 1bppq += $<) @rm -f $@ %.pic: %.2bpp ; $(eval picq += $<) @rm -f $@ From 4ad367ba98b15a8b03d25963cd7b9a8125d2285f Mon Sep 17 00:00:00 2001 From: yenatch Date: Sun, 13 Jul 2014 20:42:46 -0700 Subject: [PATCH 005/100] Combine poke%.gbc build targets into a generalized one. Now only one target is needed for all versions. $$* also works instead of %, but in a pattern rule % is probably clearer. --- Makefile | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index b61c050285..37a9ea76f4 100644 --- a/Makefile +++ b/Makefile @@ -90,17 +90,9 @@ $(all_obj): $$*.tx $$(patsubst %.asm, %.tx, $$($$*_dep)) # Make a symfile for debugging. rgblink will segfault if a mapfile isn't made too. link = rgblink -n $*.sym -m $*.map -pokered.gbc: $(red_obj) +poke%.gbc: $$(%_obj) $(link) -o $@ $^ - rgbfix $(red_opt) $@ - -pokeblue.gbc: $(blue_obj) - $(link) -o $@ $^ - rgbfix $(blue_opt) $@ - -pokeyellow.gbc: $(yellow_obj) - $(link) -o $@ $^ - rgbfix $(yellow_opt) $@ + rgbfix $($*_opt) $@ clean: From 57113a7651ba8a7f88e119ca3de7acb45a77db69 Mon Sep 17 00:00:00 2001 From: "U-Daniel-PC\\Daniel" Date: Tue, 15 Jul 2014 09:31:30 -0500 Subject: [PATCH 006/100] Don't redundantly define sprite dimensions dimensions are defined in the .pic files --- data/baseStats/abra.asm | 2 +- data/baseStats/aerodactyl.asm | 2 +- data/baseStats/alakazam.asm | 2 +- data/baseStats/arbok.asm | 2 +- data/baseStats/arcanine.asm | 2 +- data/baseStats/articuno.asm | 2 +- data/baseStats/beedrill.asm | 2 +- data/baseStats/bellsprout.asm | 2 +- data/baseStats/blastoise.asm | 2 +- data/baseStats/bulbasaur.asm | 2 +- data/baseStats/butterfree.asm | 2 +- data/baseStats/caterpie.asm | 2 +- data/baseStats/chansey.asm | 2 +- data/baseStats/charizard.asm | 2 +- data/baseStats/charmander.asm | 2 +- data/baseStats/charmeleon.asm | 2 +- data/baseStats/clefable.asm | 2 +- data/baseStats/clefairy.asm | 2 +- data/baseStats/cloyster.asm | 2 +- data/baseStats/cubone.asm | 2 +- data/baseStats/dewgong.asm | 2 +- data/baseStats/diglett.asm | 2 +- data/baseStats/ditto.asm | 2 +- data/baseStats/dodrio.asm | 2 +- data/baseStats/doduo.asm | 2 +- data/baseStats/dragonair.asm | 2 +- data/baseStats/dragonite.asm | 2 +- data/baseStats/dratini.asm | 2 +- data/baseStats/drowzee.asm | 2 +- data/baseStats/dugtrio.asm | 2 +- data/baseStats/eevee.asm | 2 +- data/baseStats/ekans.asm | 2 +- data/baseStats/electabuzz.asm | 2 +- data/baseStats/electrode.asm | 2 +- data/baseStats/exeggcute.asm | 2 +- data/baseStats/exeggutor.asm | 2 +- data/baseStats/farfetchd.asm | 2 +- data/baseStats/fearow.asm | 2 +- data/baseStats/flareon.asm | 2 +- data/baseStats/gastly.asm | 2 +- data/baseStats/gengar.asm | 2 +- data/baseStats/geodude.asm | 2 +- data/baseStats/gloom.asm | 2 +- data/baseStats/golbat.asm | 2 +- data/baseStats/goldeen.asm | 2 +- data/baseStats/golduck.asm | 2 +- data/baseStats/golem.asm | 2 +- data/baseStats/graveler.asm | 2 +- data/baseStats/grimer.asm | 2 +- data/baseStats/growlithe.asm | 2 +- data/baseStats/gyarados.asm | 2 +- data/baseStats/haunter.asm | 2 +- data/baseStats/hitmonchan.asm | 2 +- data/baseStats/hitmonlee.asm | 2 +- data/baseStats/horsea.asm | 2 +- data/baseStats/hypno.asm | 2 +- data/baseStats/ivysaur.asm | 2 +- data/baseStats/jigglypuff.asm | 2 +- data/baseStats/jolteon.asm | 2 +- data/baseStats/jynx.asm | 2 +- data/baseStats/kabuto.asm | 2 +- data/baseStats/kabutops.asm | 2 +- data/baseStats/kadabra.asm | 2 +- data/baseStats/kakuna.asm | 2 +- data/baseStats/kangaskhan.asm | 2 +- data/baseStats/kingler.asm | 2 +- data/baseStats/koffing.asm | 2 +- data/baseStats/krabby.asm | 2 +- data/baseStats/lapras.asm | 2 +- data/baseStats/lickitung.asm | 2 +- data/baseStats/machamp.asm | 2 +- data/baseStats/machoke.asm | 2 +- data/baseStats/machop.asm | 2 +- data/baseStats/magikarp.asm | 2 +- data/baseStats/magmar.asm | 2 +- data/baseStats/magnemite.asm | 2 +- data/baseStats/magneton.asm | 2 +- data/baseStats/mankey.asm | 2 +- data/baseStats/marowak.asm | 2 +- data/baseStats/meowth.asm | 2 +- data/baseStats/metapod.asm | 2 +- data/baseStats/mew.asm | 2 +- data/baseStats/mewtwo.asm | 2 +- data/baseStats/moltres.asm | 2 +- data/baseStats/mrmime.asm | 2 +- data/baseStats/muk.asm | 2 +- data/baseStats/nidoking.asm | 2 +- data/baseStats/nidoqueen.asm | 2 +- data/baseStats/nidoranf.asm | 2 +- data/baseStats/nidoranm.asm | 2 +- data/baseStats/nidorina.asm | 2 +- data/baseStats/nidorino.asm | 2 +- data/baseStats/ninetails.asm | 2 +- data/baseStats/oddish.asm | 2 +- data/baseStats/omanyte.asm | 2 +- data/baseStats/omastar.asm | 2 +- data/baseStats/onix.asm | 2 +- data/baseStats/paras.asm | 2 +- data/baseStats/parasect.asm | 2 +- data/baseStats/persian.asm | 2 +- data/baseStats/pidgeot.asm | 2 +- data/baseStats/pidgeotto.asm | 2 +- data/baseStats/pidgey.asm | 2 +- data/baseStats/pikachu.asm | 2 +- data/baseStats/pinsir.asm | 2 +- data/baseStats/poliwag.asm | 2 +- data/baseStats/poliwhirl.asm | 2 +- data/baseStats/poliwrath.asm | 2 +- data/baseStats/ponyta.asm | 2 +- data/baseStats/porygon.asm | 2 +- data/baseStats/primeape.asm | 2 +- data/baseStats/psyduck.asm | 2 +- data/baseStats/raichu.asm | 2 +- data/baseStats/rapidash.asm | 2 +- data/baseStats/raticate.asm | 2 +- data/baseStats/rattata.asm | 2 +- data/baseStats/rhydon.asm | 2 +- data/baseStats/rhyhorn.asm | 2 +- data/baseStats/sandshrew.asm | 2 +- data/baseStats/sandslash.asm | 2 +- data/baseStats/scyther.asm | 2 +- data/baseStats/seadra.asm | 2 +- data/baseStats/seaking.asm | 2 +- data/baseStats/seel.asm | 2 +- data/baseStats/shellder.asm | 2 +- data/baseStats/slowbro.asm | 2 +- data/baseStats/slowpoke.asm | 2 +- data/baseStats/snorlax.asm | 2 +- data/baseStats/spearow.asm | 2 +- data/baseStats/squirtle.asm | 2 +- data/baseStats/starmie.asm | 2 +- data/baseStats/staryu.asm | 2 +- data/baseStats/tangela.asm | 2 +- data/baseStats/tauros.asm | 2 +- data/baseStats/tentacool.asm | 2 +- data/baseStats/tentacruel.asm | 2 +- data/baseStats/vaporeon.asm | 2 +- data/baseStats/venomoth.asm | 2 +- data/baseStats/venonat.asm | 2 +- data/baseStats/venusaur.asm | 2 +- data/baseStats/victreebel.asm | 2 +- data/baseStats/vileplume.asm | 2 +- data/baseStats/voltorb.asm | 2 +- data/baseStats/vulpix.asm | 2 +- data/baseStats/wartortle.asm | 2 +- data/baseStats/weedle.asm | 2 +- data/baseStats/weepinbell.asm | 2 +- data/baseStats/weezing.asm | 2 +- data/baseStats/wigglytuff.asm | 2 +- data/baseStats/zapdos.asm | 2 +- data/baseStats/zubat.asm | 2 +- 151 files changed, 151 insertions(+), 151 deletions(-) diff --git a/data/baseStats/abra.asm b/data/baseStats/abra.asm index a5acd0bf1d..80ee9e06bf 100755 --- a/data/baseStats/abra.asm +++ b/data/baseStats/abra.asm @@ -9,7 +9,7 @@ db PSYCHIC ; species type 1 db PSYCHIC ; species type 2 db 200 ; catch rate db 73 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/abra.pic",0,1 ; 55, sprite dimensions dw AbraPicFront dw AbraPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/aerodactyl.asm b/data/baseStats/aerodactyl.asm index 9c11ed3e8a..75067ad3f5 100755 --- a/data/baseStats/aerodactyl.asm +++ b/data/baseStats/aerodactyl.asm @@ -9,7 +9,7 @@ db ROCK ; species type 1 db FLYING ; species type 2 db 45 ; catch rate db 202 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/aerodactyl.pic",0,1 ; 77, sprite dimensions dw AerodactylPicFront dw AerodactylPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/alakazam.asm b/data/baseStats/alakazam.asm index 55a5e82112..dfea0c683c 100755 --- a/data/baseStats/alakazam.asm +++ b/data/baseStats/alakazam.asm @@ -9,7 +9,7 @@ db PSYCHIC ; species type 1 db PSYCHIC ; species type 2 db 50 ; catch rate db 186 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/alakazam.pic",0,1 ; 77, sprite dimensions dw AlakazamPicFront dw AlakazamPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/arbok.asm b/data/baseStats/arbok.asm index 682d9f5e97..bddcab5be1 100755 --- a/data/baseStats/arbok.asm +++ b/data/baseStats/arbok.asm @@ -9,7 +9,7 @@ db POISON ; species type 1 db POISON ; species type 2 db 90 ; catch rate db 147 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/arbok.pic",0,1 ; 77, sprite dimensions dw ArbokPicFront dw ArbokPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/arcanine.asm b/data/baseStats/arcanine.asm index f963277897..065edb6d36 100755 --- a/data/baseStats/arcanine.asm +++ b/data/baseStats/arcanine.asm @@ -9,7 +9,7 @@ db FIRE ; species type 1 db FIRE ; species type 2 db 75 ; catch rate db 213 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/arcanine.pic",0,1 ; 77, sprite dimensions dw ArcaninePicFront dw ArcaninePicBack ; attacks known at lvl 0 diff --git a/data/baseStats/articuno.asm b/data/baseStats/articuno.asm index e9d7318b8a..811bb884e3 100755 --- a/data/baseStats/articuno.asm +++ b/data/baseStats/articuno.asm @@ -9,7 +9,7 @@ db ICE ; species type 1 db FLYING ; species type 2 db 3 ; catch rate db 215 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/articuno.pic",0,1 ; 77, sprite dimensions dw ArticunoPicFront dw ArticunoPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/beedrill.asm b/data/baseStats/beedrill.asm index ba7d9f9670..9381a63a76 100755 --- a/data/baseStats/beedrill.asm +++ b/data/baseStats/beedrill.asm @@ -9,7 +9,7 @@ db BUG ; species type 1 db POISON ; species type 2 db 45 ; catch rate db 159 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/beedrill.pic",0,1 ; 77, sprite dimensions dw BeedrillPicFront dw BeedrillPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/bellsprout.asm b/data/baseStats/bellsprout.asm index 335c9ff134..e8b7d97a90 100755 --- a/data/baseStats/bellsprout.asm +++ b/data/baseStats/bellsprout.asm @@ -9,7 +9,7 @@ db GRASS ; species type 1 db POISON ; species type 2 db 255 ; catch rate db 84 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/bellsprout.pic",0,1 ; 55, sprite dimensions dw BellsproutPicFront dw BellsproutPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/blastoise.asm b/data/baseStats/blastoise.asm index 088ac25774..1ab81327d5 100755 --- a/data/baseStats/blastoise.asm +++ b/data/baseStats/blastoise.asm @@ -9,7 +9,7 @@ db WATER ; species type 1 db WATER ; species type 2 db 45 ; catch rate db 210 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/blastoise.pic",0,1 ; 77, sprite dimensions dw BlastoisePicFront dw BlastoisePicBack ; attacks known at lvl 0 diff --git a/data/baseStats/bulbasaur.asm b/data/baseStats/bulbasaur.asm index cc9db19fd5..5bf8a18431 100755 --- a/data/baseStats/bulbasaur.asm +++ b/data/baseStats/bulbasaur.asm @@ -9,7 +9,7 @@ db GRASS ; species type 1 db POISON ; species type 2 db 45 ; catch rate db 64 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/bulbasaur.pic",0,1 ; 55, sprite dimensions dw BulbasaurPicFront dw BulbasaurPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/butterfree.asm b/data/baseStats/butterfree.asm index 0573f878c8..1c9231f024 100755 --- a/data/baseStats/butterfree.asm +++ b/data/baseStats/butterfree.asm @@ -9,7 +9,7 @@ db BUG ; species type 1 db FLYING ; species type 2 db 45 ; catch rate db 160 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/butterfree.pic",0,1 ; 77, sprite dimensions dw ButterfreePicFront dw ButterfreePicBack ; attacks known at lvl 0 diff --git a/data/baseStats/caterpie.asm b/data/baseStats/caterpie.asm index fce4778033..0dab990b3f 100755 --- a/data/baseStats/caterpie.asm +++ b/data/baseStats/caterpie.asm @@ -9,7 +9,7 @@ db BUG ; species type 1 db BUG ; species type 2 db 255 ; catch rate db 53 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/caterpie.pic",0,1 ; 55, sprite dimensions dw CaterpiePicFront dw CaterpiePicBack ; attacks known at lvl 0 diff --git a/data/baseStats/chansey.asm b/data/baseStats/chansey.asm index 93cb1b4aec..351de4cf54 100755 --- a/data/baseStats/chansey.asm +++ b/data/baseStats/chansey.asm @@ -9,7 +9,7 @@ db NORMAL ; species type 1 db NORMAL ; species type 2 db 30 ; catch rate db 255 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/chansey.pic",0,1 ; 66, sprite dimensions dw ChanseyPicFront dw ChanseyPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/charizard.asm b/data/baseStats/charizard.asm index 280ce4ab5e..b6f651755d 100755 --- a/data/baseStats/charizard.asm +++ b/data/baseStats/charizard.asm @@ -9,7 +9,7 @@ db FIRE ; species type 1 db FLYING ; species type 2 db 45 ; catch rate db 209 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/charizard.pic",0,1 ; 77, sprite dimensions dw CharizardPicFront dw CharizardPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/charmander.asm b/data/baseStats/charmander.asm index 1cb1a62311..c9deed08b8 100755 --- a/data/baseStats/charmander.asm +++ b/data/baseStats/charmander.asm @@ -9,7 +9,7 @@ db FIRE ; species type 1 db FIRE ; species type 2 db 45 ; catch rate db 65 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/charmander.pic",0,1 ; 55, sprite dimensions dw CharmanderPicFront dw CharmanderPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/charmeleon.asm b/data/baseStats/charmeleon.asm index e4b1ee3f3c..6b2b9ba92b 100755 --- a/data/baseStats/charmeleon.asm +++ b/data/baseStats/charmeleon.asm @@ -9,7 +9,7 @@ db FIRE ; species type 1 db FIRE ; species type 2 db 45 ; catch rate db 142 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/charmeleon.pic",0,1 ; 66, sprite dimensions dw CharmeleonPicFront dw CharmeleonPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/clefable.asm b/data/baseStats/clefable.asm index 76267cc922..8fee3ec631 100755 --- a/data/baseStats/clefable.asm +++ b/data/baseStats/clefable.asm @@ -9,7 +9,7 @@ db NORMAL ; species type 1 db NORMAL ; species type 2 db 25 ; catch rate db 129 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/clefable.pic",0,1 ; 66, sprite dimensions dw ClefablePicFront dw ClefablePicBack ; attacks known at lvl 0 diff --git a/data/baseStats/clefairy.asm b/data/baseStats/clefairy.asm index 6585357e09..bea2ffecc2 100755 --- a/data/baseStats/clefairy.asm +++ b/data/baseStats/clefairy.asm @@ -9,7 +9,7 @@ db NORMAL ; species type 1 db NORMAL ; species type 2 db 150 ; catch rate db 68 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/clefairy.pic",0,1 ; 55, sprite dimensions dw ClefairyPicFront dw ClefairyPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/cloyster.asm b/data/baseStats/cloyster.asm index 0b70c8de38..d57b651a4d 100755 --- a/data/baseStats/cloyster.asm +++ b/data/baseStats/cloyster.asm @@ -9,7 +9,7 @@ db WATER ; species type 1 db ICE ; species type 2 db 60 ; catch rate db 203 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/cloyster.pic",0,1 ; 77, sprite dimensions dw CloysterPicFront dw CloysterPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/cubone.asm b/data/baseStats/cubone.asm index 3ae28ee247..42bb717c92 100755 --- a/data/baseStats/cubone.asm +++ b/data/baseStats/cubone.asm @@ -9,7 +9,7 @@ db GROUND ; species type 1 db GROUND ; species type 2 db 190 ; catch rate db 87 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/cubone.pic",0,1 ; 55, sprite dimensions dw CubonePicFront dw CubonePicBack ; attacks known at lvl 0 diff --git a/data/baseStats/dewgong.asm b/data/baseStats/dewgong.asm index 7dd2adbf00..5246189ee4 100755 --- a/data/baseStats/dewgong.asm +++ b/data/baseStats/dewgong.asm @@ -9,7 +9,7 @@ db WATER ; species type 1 db ICE ; species type 2 db 75 ; catch rate db 176 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/dewgong.pic",0,1 ; 66, sprite dimensions dw DewgongPicFront dw DewgongPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/diglett.asm b/data/baseStats/diglett.asm index f227463e2f..7e8a3bbb4f 100755 --- a/data/baseStats/diglett.asm +++ b/data/baseStats/diglett.asm @@ -9,7 +9,7 @@ db GROUND ; species type 1 db GROUND ; species type 2 db 255 ; catch rate db 81 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/diglett.pic",0,1 ; 55, sprite dimensions dw DiglettPicFront dw DiglettPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/ditto.asm b/data/baseStats/ditto.asm index c607cdc7e1..0a35bf5536 100755 --- a/data/baseStats/ditto.asm +++ b/data/baseStats/ditto.asm @@ -9,7 +9,7 @@ db NORMAL ; species type 1 db NORMAL ; species type 2 db 35 ; catch rate db 61 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/ditto.pic",0,1 ; 55, sprite dimensions dw DittoPicFront dw DittoPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/dodrio.asm b/data/baseStats/dodrio.asm index 53e3868250..b872ba4784 100755 --- a/data/baseStats/dodrio.asm +++ b/data/baseStats/dodrio.asm @@ -9,7 +9,7 @@ db NORMAL ; species type 1 db FLYING ; species type 2 db 45 ; catch rate db 158 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/dodrio.pic",0,1 ; 77, sprite dimensions dw DodrioPicFront dw DodrioPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/doduo.asm b/data/baseStats/doduo.asm index 430b4162cb..8070ba338c 100755 --- a/data/baseStats/doduo.asm +++ b/data/baseStats/doduo.asm @@ -9,7 +9,7 @@ db NORMAL ; species type 1 db FLYING ; species type 2 db 190 ; catch rate db 96 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/doduo.pic",0,1 ; 55, sprite dimensions dw DoduoPicFront dw DoduoPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/dragonair.asm b/data/baseStats/dragonair.asm index 7d9ad63000..89ff2eef77 100755 --- a/data/baseStats/dragonair.asm +++ b/data/baseStats/dragonair.asm @@ -9,7 +9,7 @@ db DRAGON ; species type 1 db DRAGON ; species type 2 db 45 ; catch rate db 144 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/dragonair.pic",0,1 ; 66, sprite dimensions dw DragonairPicFront dw DragonairPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/dragonite.asm b/data/baseStats/dragonite.asm index 769f9ab40f..3699955be8 100755 --- a/data/baseStats/dragonite.asm +++ b/data/baseStats/dragonite.asm @@ -9,7 +9,7 @@ db DRAGON ; species type 1 db FLYING ; species type 2 db 45 ; catch rate db 218 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/dragonite.pic",0,1 ; 77, sprite dimensions dw DragonitePicFront dw DragonitePicBack ; attacks known at lvl 0 diff --git a/data/baseStats/dratini.asm b/data/baseStats/dratini.asm index 0c890b2cd6..4837e4a568 100755 --- a/data/baseStats/dratini.asm +++ b/data/baseStats/dratini.asm @@ -9,7 +9,7 @@ db DRAGON ; species type 1 db DRAGON ; species type 2 db 45 ; catch rate db 67 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/dratini.pic",0,1 ; 55, sprite dimensions dw DratiniPicFront dw DratiniPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/drowzee.asm b/data/baseStats/drowzee.asm index 10c3283b20..dfa591bdd8 100755 --- a/data/baseStats/drowzee.asm +++ b/data/baseStats/drowzee.asm @@ -9,7 +9,7 @@ db PSYCHIC ; species type 1 db PSYCHIC ; species type 2 db 190 ; catch rate db 102 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/drowzee.pic",0,1 ; 66, sprite dimensions dw DrowzeePicFront dw DrowzeePicBack ; attacks known at lvl 0 diff --git a/data/baseStats/dugtrio.asm b/data/baseStats/dugtrio.asm index dbea18dfde..dfdd0eb9a1 100755 --- a/data/baseStats/dugtrio.asm +++ b/data/baseStats/dugtrio.asm @@ -9,7 +9,7 @@ db GROUND ; species type 1 db GROUND ; species type 2 db 50 ; catch rate db 153 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/dugtrio.pic",0,1 ; 66, sprite dimensions dw DugtrioPicFront dw DugtrioPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/eevee.asm b/data/baseStats/eevee.asm index 60fb6e5838..3632eef13c 100755 --- a/data/baseStats/eevee.asm +++ b/data/baseStats/eevee.asm @@ -9,7 +9,7 @@ db NORMAL ; species type 1 db NORMAL ; species type 2 db 45 ; catch rate db 92 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/eevee.pic",0,1 ; 55, sprite dimensions dw EeveePicFront dw EeveePicBack ; attacks known at lvl 0 diff --git a/data/baseStats/ekans.asm b/data/baseStats/ekans.asm index 45eae0d06c..79dbcbf5e4 100755 --- a/data/baseStats/ekans.asm +++ b/data/baseStats/ekans.asm @@ -9,7 +9,7 @@ db POISON ; species type 1 db POISON ; species type 2 db 255 ; catch rate db 62 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/ekans.pic",0,1 ; 55, sprite dimensions dw EkansPicFront dw EkansPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/electabuzz.asm b/data/baseStats/electabuzz.asm index 32fa0316d4..ac69243643 100755 --- a/data/baseStats/electabuzz.asm +++ b/data/baseStats/electabuzz.asm @@ -9,7 +9,7 @@ db ELECTRIC ; species type 1 db ELECTRIC ; species type 2 db 45 ; catch rate db 156 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/electabuzz.pic",0,1 ; 66, sprite dimensions dw ElectabuzzPicFront dw ElectabuzzPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/electrode.asm b/data/baseStats/electrode.asm index 3d2842c157..7ce93e8d39 100755 --- a/data/baseStats/electrode.asm +++ b/data/baseStats/electrode.asm @@ -9,7 +9,7 @@ db ELECTRIC ; species type 1 db ELECTRIC ; species type 2 db 60 ; catch rate db 150 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/electrode.pic",0,1 ; 55, sprite dimensions dw ElectrodePicFront dw ElectrodePicBack ; attacks known at lvl 0 diff --git a/data/baseStats/exeggcute.asm b/data/baseStats/exeggcute.asm index 6d73157125..ded057892a 100755 --- a/data/baseStats/exeggcute.asm +++ b/data/baseStats/exeggcute.asm @@ -9,7 +9,7 @@ db GRASS ; species type 1 db PSYCHIC ; species type 2 db 90 ; catch rate db 98 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/exeggcute.pic",0,1 ; 77, sprite dimensions dw ExeggcutePicFront dw ExeggcutePicBack ; attacks known at lvl 0 diff --git a/data/baseStats/exeggutor.asm b/data/baseStats/exeggutor.asm index 98c629cd51..e28fb8c819 100755 --- a/data/baseStats/exeggutor.asm +++ b/data/baseStats/exeggutor.asm @@ -9,7 +9,7 @@ db GRASS ; species type 1 db PSYCHIC ; species type 2 db 45 ; catch rate db 212 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/exeggutor.pic",0,1 ; 77, sprite dimensions dw ExeggutorPicFront dw ExeggutorPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/farfetchd.asm b/data/baseStats/farfetchd.asm index 22eeab6b99..51648c4638 100755 --- a/data/baseStats/farfetchd.asm +++ b/data/baseStats/farfetchd.asm @@ -9,7 +9,7 @@ db NORMAL ; species type 1 db FLYING ; species type 2 db 45 ; catch rate db 94 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/farfetchd.pic",0,1 ; 66, sprite dimensions dw FarfetchdPicFront dw FarfetchdPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/fearow.asm b/data/baseStats/fearow.asm index 398c32fbab..0a5d0c4889 100755 --- a/data/baseStats/fearow.asm +++ b/data/baseStats/fearow.asm @@ -9,7 +9,7 @@ db NORMAL ; species type 1 db FLYING ; species type 2 db 90 ; catch rate db 162 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/fearow.pic",0,1 ; 77, sprite dimensions dw FearowPicFront dw FearowPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/flareon.asm b/data/baseStats/flareon.asm index cedc0ac378..219c7e7c53 100755 --- a/data/baseStats/flareon.asm +++ b/data/baseStats/flareon.asm @@ -9,7 +9,7 @@ db FIRE ; species type 1 db FIRE ; species type 2 db 45 ; catch rate db 198 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/flareon.pic",0,1 ; 66, sprite dimensions dw FlareonPicFront dw FlareonPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/gastly.asm b/data/baseStats/gastly.asm index fddd51506e..ca6c2285e2 100755 --- a/data/baseStats/gastly.asm +++ b/data/baseStats/gastly.asm @@ -9,7 +9,7 @@ db GHOST ; species type 1 db POISON ; species type 2 db 190 ; catch rate db 95 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/gastly.pic",0,1 ; 77, sprite dimensions dw GastlyPicFront dw GastlyPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/gengar.asm b/data/baseStats/gengar.asm index 9ab1eb9dfa..a58814766b 100755 --- a/data/baseStats/gengar.asm +++ b/data/baseStats/gengar.asm @@ -9,7 +9,7 @@ db GHOST ; species type 1 db POISON ; species type 2 db 45 ; catch rate db 190 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/gengar.pic",0,1 ; 66, sprite dimensions dw GengarPicFront dw GengarPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/geodude.asm b/data/baseStats/geodude.asm index fff0b4df94..52d3553d99 100755 --- a/data/baseStats/geodude.asm +++ b/data/baseStats/geodude.asm @@ -9,7 +9,7 @@ db ROCK ; species type 1 db GROUND ; species type 2 db 255 ; catch rate db 86 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/geodude.pic",0,1 ; 55, sprite dimensions dw GeodudePicFront dw GeodudePicBack ; attacks known at lvl 0 diff --git a/data/baseStats/gloom.asm b/data/baseStats/gloom.asm index 388b5bdc9f..e2c854d465 100755 --- a/data/baseStats/gloom.asm +++ b/data/baseStats/gloom.asm @@ -9,7 +9,7 @@ db GRASS ; species type 1 db POISON ; species type 2 db 120 ; catch rate db 132 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/gloom.pic",0,1 ; 66, sprite dimensions dw GloomPicFront dw GloomPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/golbat.asm b/data/baseStats/golbat.asm index d4b0d6c0f2..d89dcb1e90 100755 --- a/data/baseStats/golbat.asm +++ b/data/baseStats/golbat.asm @@ -9,7 +9,7 @@ db POISON ; species type 1 db FLYING ; species type 2 db 90 ; catch rate db 171 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/golbat.pic",0,1 ; 77, sprite dimensions dw GolbatPicFront dw GolbatPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/goldeen.asm b/data/baseStats/goldeen.asm index f005506885..17afd3c2bd 100755 --- a/data/baseStats/goldeen.asm +++ b/data/baseStats/goldeen.asm @@ -9,7 +9,7 @@ db WATER ; species type 1 db WATER ; species type 2 db 225 ; catch rate db 111 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/goldeen.pic",0,1 ; 66, sprite dimensions dw GoldeenPicFront dw GoldeenPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/golduck.asm b/data/baseStats/golduck.asm index 52f544c5ed..f3797f73fe 100755 --- a/data/baseStats/golduck.asm +++ b/data/baseStats/golduck.asm @@ -9,7 +9,7 @@ db WATER ; species type 1 db WATER ; species type 2 db 75 ; catch rate db 174 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/golduck.pic",0,1 ; 77, sprite dimensions dw GolduckPicFront dw GolduckPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/golem.asm b/data/baseStats/golem.asm index 3a23f63f49..deebb1d189 100755 --- a/data/baseStats/golem.asm +++ b/data/baseStats/golem.asm @@ -9,7 +9,7 @@ db ROCK ; species type 1 db GROUND ; species type 2 db 45 ; catch rate db 177 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/golem.pic",0,1 ; 66, sprite dimensions dw GolemPicFront dw GolemPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/graveler.asm b/data/baseStats/graveler.asm index f4eab92696..586afc2c1e 100755 --- a/data/baseStats/graveler.asm +++ b/data/baseStats/graveler.asm @@ -9,7 +9,7 @@ db ROCK ; species type 1 db GROUND ; species type 2 db 120 ; catch rate db 134 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/graveler.pic",0,1 ; 66, sprite dimensions dw GravelerPicFront dw GravelerPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/grimer.asm b/data/baseStats/grimer.asm index 4c7871a83e..dd17fb056b 100755 --- a/data/baseStats/grimer.asm +++ b/data/baseStats/grimer.asm @@ -9,7 +9,7 @@ db POISON ; species type 1 db POISON ; species type 2 db 190 ; catch rate db 90 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/grimer.pic",0,1 ; 55, sprite dimensions dw GrimerPicFront dw GrimerPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/growlithe.asm b/data/baseStats/growlithe.asm index ddfd86feff..ec48b605dc 100755 --- a/data/baseStats/growlithe.asm +++ b/data/baseStats/growlithe.asm @@ -9,7 +9,7 @@ db FIRE ; species type 1 db FIRE ; species type 2 db 190 ; catch rate db 91 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/growlithe.pic",0,1 ; 55, sprite dimensions dw GrowlithePicFront dw GrowlithePicBack ; attacks known at lvl 0 diff --git a/data/baseStats/gyarados.asm b/data/baseStats/gyarados.asm index 5223b32a98..0d23564f1d 100755 --- a/data/baseStats/gyarados.asm +++ b/data/baseStats/gyarados.asm @@ -9,7 +9,7 @@ db WATER ; species type 1 db FLYING ; species type 2 db 45 ; catch rate db 214 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/gyarados.pic",0,1 ; 77, sprite dimensions dw GyaradosPicFront dw GyaradosPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/haunter.asm b/data/baseStats/haunter.asm index a35e1134b2..6ac7db99f9 100755 --- a/data/baseStats/haunter.asm +++ b/data/baseStats/haunter.asm @@ -9,7 +9,7 @@ db GHOST ; species type 1 db POISON ; species type 2 db 90 ; catch rate db 126 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/haunter.pic",0,1 ; 66, sprite dimensions dw HaunterPicFront dw HaunterPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/hitmonchan.asm b/data/baseStats/hitmonchan.asm index 1acce4fe62..9cb0d5669e 100755 --- a/data/baseStats/hitmonchan.asm +++ b/data/baseStats/hitmonchan.asm @@ -9,7 +9,7 @@ db FIGHTING ; species type 1 db FIGHTING ; species type 2 db 45 ; catch rate db 140 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/hitmonchan.pic",0,1 ; 66, sprite dimensions dw HitmonchanPicFront dw HitmonchanPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/hitmonlee.asm b/data/baseStats/hitmonlee.asm index 3f96dadde1..126f528bff 100755 --- a/data/baseStats/hitmonlee.asm +++ b/data/baseStats/hitmonlee.asm @@ -9,7 +9,7 @@ db FIGHTING ; species type 1 db FIGHTING ; species type 2 db 45 ; catch rate db 139 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/hitmonlee.pic",0,1 ; 77, sprite dimensions dw HitmonleePicFront dw HitmonleePicBack ; attacks known at lvl 0 diff --git a/data/baseStats/horsea.asm b/data/baseStats/horsea.asm index b53b92c146..f59bee0ca7 100755 --- a/data/baseStats/horsea.asm +++ b/data/baseStats/horsea.asm @@ -9,7 +9,7 @@ db WATER ; species type 1 db WATER ; species type 2 db 225 ; catch rate db 83 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/horsea.pic",0,1 ; 55, sprite dimensions dw HorseaPicFront dw HorseaPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/hypno.asm b/data/baseStats/hypno.asm index 0e4ff33f2e..022e31348a 100755 --- a/data/baseStats/hypno.asm +++ b/data/baseStats/hypno.asm @@ -9,7 +9,7 @@ db PSYCHIC ; species type 1 db PSYCHIC ; species type 2 db 75 ; catch rate db 165 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/hypno.pic",0,1 ; 77, sprite dimensions dw HypnoPicFront dw HypnoPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/ivysaur.asm b/data/baseStats/ivysaur.asm index 16d7520717..78aec210fb 100755 --- a/data/baseStats/ivysaur.asm +++ b/data/baseStats/ivysaur.asm @@ -9,7 +9,7 @@ db GRASS ; species type 1 db POISON ; species type 2 db 45 ; catch rate db 141 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/ivysaur.pic",0,1 ; 66, sprite dimensions dw IvysaurPicFront dw IvysaurPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/jigglypuff.asm b/data/baseStats/jigglypuff.asm index 444e195c9c..0252880fc2 100755 --- a/data/baseStats/jigglypuff.asm +++ b/data/baseStats/jigglypuff.asm @@ -9,7 +9,7 @@ db NORMAL ; species type 1 db NORMAL ; species type 2 db 170 ; catch rate db 76 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/jigglypuff.pic",0,1 ; 55, sprite dimensions dw JigglypuffPicFront dw JigglypuffPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/jolteon.asm b/data/baseStats/jolteon.asm index fd077d137c..d9ef0440ba 100755 --- a/data/baseStats/jolteon.asm +++ b/data/baseStats/jolteon.asm @@ -9,7 +9,7 @@ db ELECTRIC ; species type 1 db ELECTRIC ; species type 2 db 45 ; catch rate db 197 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/jolteon.pic",0,1 ; 66, sprite dimensions dw JolteonPicFront dw JolteonPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/jynx.asm b/data/baseStats/jynx.asm index 1b31bfa690..6299f545b3 100755 --- a/data/baseStats/jynx.asm +++ b/data/baseStats/jynx.asm @@ -9,7 +9,7 @@ db ICE ; species type 1 db PSYCHIC ; species type 2 db 45 ; catch rate db 137 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/jynx.pic",0,1 ; 66, sprite dimensions dw JynxPicFront dw JynxPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/kabuto.asm b/data/baseStats/kabuto.asm index 380c3f8b62..8a9899c78c 100755 --- a/data/baseStats/kabuto.asm +++ b/data/baseStats/kabuto.asm @@ -9,7 +9,7 @@ db ROCK ; species type 1 db WATER ; species type 2 db 45 ; catch rate db 119 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/kabuto.pic",0,1 ; 55, sprite dimensions dw KabutoPicFront dw KabutoPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/kabutops.asm b/data/baseStats/kabutops.asm index a0ec27cc48..7c80a8c028 100755 --- a/data/baseStats/kabutops.asm +++ b/data/baseStats/kabutops.asm @@ -9,7 +9,7 @@ db ROCK ; species type 1 db WATER ; species type 2 db 45 ; catch rate db 201 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/kabutops.pic",0,1 ; 66, sprite dimensions dw KabutopsPicFront dw KabutopsPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/kadabra.asm b/data/baseStats/kadabra.asm index 9ae3e47af6..1f1fe61a64 100755 --- a/data/baseStats/kadabra.asm +++ b/data/baseStats/kadabra.asm @@ -9,7 +9,7 @@ db PSYCHIC ; species type 1 db PSYCHIC ; species type 2 db 100 ; catch rate db 145 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/kadabra.pic",0,1 ; 66, sprite dimensions dw KadabraPicFront dw KadabraPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/kakuna.asm b/data/baseStats/kakuna.asm index b503a8a9c8..62e9c22560 100755 --- a/data/baseStats/kakuna.asm +++ b/data/baseStats/kakuna.asm @@ -9,7 +9,7 @@ db BUG ; species type 1 db POISON ; species type 2 db 120 ; catch rate db 71 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/kakuna.pic",0,1 ; 55, sprite dimensions dw KakunaPicFront dw KakunaPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/kangaskhan.asm b/data/baseStats/kangaskhan.asm index 4424107d72..3d30b78a06 100755 --- a/data/baseStats/kangaskhan.asm +++ b/data/baseStats/kangaskhan.asm @@ -9,7 +9,7 @@ db NORMAL ; species type 1 db NORMAL ; species type 2 db 45 ; catch rate db 175 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/kangaskhan.pic",0,1 ; 77, sprite dimensions dw KangaskhanPicFront dw KangaskhanPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/kingler.asm b/data/baseStats/kingler.asm index a3ce6f5b35..8a5b0f9828 100755 --- a/data/baseStats/kingler.asm +++ b/data/baseStats/kingler.asm @@ -9,7 +9,7 @@ db WATER ; species type 1 db WATER ; species type 2 db 60 ; catch rate db 206 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/kingler.pic",0,1 ; 77, sprite dimensions dw KinglerPicFront dw KinglerPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/koffing.asm b/data/baseStats/koffing.asm index 0976b55a50..d50e5bcf74 100755 --- a/data/baseStats/koffing.asm +++ b/data/baseStats/koffing.asm @@ -9,7 +9,7 @@ db POISON ; species type 1 db POISON ; species type 2 db 190 ; catch rate db 114 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/koffing.pic",0,1 ; 66, sprite dimensions dw KoffingPicFront dw KoffingPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/krabby.asm b/data/baseStats/krabby.asm index a6090a1506..37bbaa0b57 100755 --- a/data/baseStats/krabby.asm +++ b/data/baseStats/krabby.asm @@ -9,7 +9,7 @@ db WATER ; species type 1 db WATER ; species type 2 db 225 ; catch rate db 115 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/krabby.pic",0,1 ; 55, sprite dimensions dw KrabbyPicFront dw KrabbyPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/lapras.asm b/data/baseStats/lapras.asm index 28d1302ce7..cd4ea5b157 100755 --- a/data/baseStats/lapras.asm +++ b/data/baseStats/lapras.asm @@ -9,7 +9,7 @@ db WATER ; species type 1 db ICE ; species type 2 db 45 ; catch rate db 219 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/lapras.pic",0,1 ; 77, sprite dimensions dw LaprasPicFront dw LaprasPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/lickitung.asm b/data/baseStats/lickitung.asm index abfb94a626..8ada934e56 100755 --- a/data/baseStats/lickitung.asm +++ b/data/baseStats/lickitung.asm @@ -9,7 +9,7 @@ db NORMAL ; species type 1 db NORMAL ; species type 2 db 45 ; catch rate db 127 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/lickitung.pic",0,1 ; 77, sprite dimensions dw LickitungPicFront dw LickitungPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/machamp.asm b/data/baseStats/machamp.asm index 0ccb8615e8..1c10c96e02 100755 --- a/data/baseStats/machamp.asm +++ b/data/baseStats/machamp.asm @@ -9,7 +9,7 @@ db FIGHTING ; species type 1 db FIGHTING ; species type 2 db 45 ; catch rate db 193 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/machamp.pic",0,1 ; 77, sprite dimensions dw MachampPicFront dw MachampPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/machoke.asm b/data/baseStats/machoke.asm index b631bdf656..7b49164123 100755 --- a/data/baseStats/machoke.asm +++ b/data/baseStats/machoke.asm @@ -9,7 +9,7 @@ db FIGHTING ; species type 1 db FIGHTING ; species type 2 db 90 ; catch rate db 146 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/machoke.pic",0,1 ; 77, sprite dimensions dw MachokePicFront dw MachokePicBack ; attacks known at lvl 0 diff --git a/data/baseStats/machop.asm b/data/baseStats/machop.asm index ef0bdbe2aa..c951163fcb 100755 --- a/data/baseStats/machop.asm +++ b/data/baseStats/machop.asm @@ -9,7 +9,7 @@ db FIGHTING ; species type 1 db FIGHTING ; species type 2 db 180 ; catch rate db 88 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/machop.pic",0,1 ; 55, sprite dimensions dw MachopPicFront dw MachopPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/magikarp.asm b/data/baseStats/magikarp.asm index 9c1221d6a2..606bf755d4 100755 --- a/data/baseStats/magikarp.asm +++ b/data/baseStats/magikarp.asm @@ -9,7 +9,7 @@ db WATER ; species type 1 db WATER ; species type 2 db 255 ; catch rate db 20 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/magikarp.pic",0,1 ; 66, sprite dimensions dw MagikarpPicFront dw MagikarpPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/magmar.asm b/data/baseStats/magmar.asm index fcaf24692a..a360fe9d42 100755 --- a/data/baseStats/magmar.asm +++ b/data/baseStats/magmar.asm @@ -9,7 +9,7 @@ db FIRE ; species type 1 db FIRE ; species type 2 db 45 ; catch rate db 167 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/magmar.pic",0,1 ; 66, sprite dimensions dw MagmarPicFront dw MagmarPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/magnemite.asm b/data/baseStats/magnemite.asm index 2bd8817b6b..166e2fb0e5 100755 --- a/data/baseStats/magnemite.asm +++ b/data/baseStats/magnemite.asm @@ -9,7 +9,7 @@ db ELECTRIC ; species type 1 db ELECTRIC ; species type 2 db 190 ; catch rate db 89 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/magnemite.pic",0,1 ; 55, sprite dimensions dw MagnemitePicFront dw MagnemitePicBack ; attacks known at lvl 0 diff --git a/data/baseStats/magneton.asm b/data/baseStats/magneton.asm index ed8f93fddc..92ae9760c0 100755 --- a/data/baseStats/magneton.asm +++ b/data/baseStats/magneton.asm @@ -9,7 +9,7 @@ db ELECTRIC ; species type 1 db ELECTRIC ; species type 2 db 60 ; catch rate db 161 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/magneton.pic",0,1 ; 66, sprite dimensions dw MagnetonPicFront dw MagnetonPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/mankey.asm b/data/baseStats/mankey.asm index c93f3c398b..13e77c5ce9 100755 --- a/data/baseStats/mankey.asm +++ b/data/baseStats/mankey.asm @@ -9,7 +9,7 @@ db FIGHTING ; species type 1 db FIGHTING ; species type 2 db 190 ; catch rate db 74 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/mankey.pic",0,1 ; 55, sprite dimensions dw MankeyPicFront dw MankeyPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/marowak.asm b/data/baseStats/marowak.asm index be8930ae80..3b101fde44 100755 --- a/data/baseStats/marowak.asm +++ b/data/baseStats/marowak.asm @@ -9,7 +9,7 @@ db GROUND ; species type 1 db GROUND ; species type 2 db 75 ; catch rate db 124 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/marowak.pic",0,1 ; 66, sprite dimensions dw MarowakPicFront dw MarowakPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/meowth.asm b/data/baseStats/meowth.asm index 98b890a3a9..dc404d20d0 100755 --- a/data/baseStats/meowth.asm +++ b/data/baseStats/meowth.asm @@ -9,7 +9,7 @@ db NORMAL ; species type 1 db NORMAL ; species type 2 db 255 ; catch rate db 69 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/meowth.pic",0,1 ; 55, sprite dimensions dw MeowthPicFront dw MeowthPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/metapod.asm b/data/baseStats/metapod.asm index 2a75ff55a1..71a2be284f 100755 --- a/data/baseStats/metapod.asm +++ b/data/baseStats/metapod.asm @@ -9,7 +9,7 @@ db BUG ; species type 1 db BUG ; species type 2 db 120 ; catch rate db 72 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/metapod.pic",0,1 ; 55, sprite dimensions dw MetapodPicFront dw MetapodPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/mew.asm b/data/baseStats/mew.asm index 3a6d33275b..16634430fe 100755 --- a/data/baseStats/mew.asm +++ b/data/baseStats/mew.asm @@ -9,7 +9,7 @@ db PSYCHIC ; species type 1 db PSYCHIC ; species type 2 db 45 ; catch rate db 64 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/mew.pic",0,1 ; 55, sprite dimensions dw MewPicFront dw MewPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/mewtwo.asm b/data/baseStats/mewtwo.asm index 04d06e3d34..29b0b61b01 100755 --- a/data/baseStats/mewtwo.asm +++ b/data/baseStats/mewtwo.asm @@ -9,7 +9,7 @@ db PSYCHIC ; species type 1 db PSYCHIC ; species type 2 db 3 ; catch rate db 220 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/mewtwo.pic",0,1 ; 77, sprite dimensions dw MewtwoPicFront dw MewtwoPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/moltres.asm b/data/baseStats/moltres.asm index 38beec71f0..eeeb53676a 100755 --- a/data/baseStats/moltres.asm +++ b/data/baseStats/moltres.asm @@ -9,7 +9,7 @@ db FIRE ; species type 1 db FLYING ; species type 2 db 3 ; catch rate db 217 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/moltres.pic",0,1 ; 77, sprite dimensions dw MoltresPicFront dw MoltresPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/mrmime.asm b/data/baseStats/mrmime.asm index d86fc002fb..93a6fcf728 100755 --- a/data/baseStats/mrmime.asm +++ b/data/baseStats/mrmime.asm @@ -9,7 +9,7 @@ db PSYCHIC ; species type 1 db PSYCHIC ; species type 2 db 45 ; catch rate db 136 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/mr.mime.pic",0,1 ; 66, sprite dimensions dw MrMimePicFront dw MrMimePicBack ; attacks known at lvl 0 diff --git a/data/baseStats/muk.asm b/data/baseStats/muk.asm index 1b2843381c..465c601240 100755 --- a/data/baseStats/muk.asm +++ b/data/baseStats/muk.asm @@ -9,7 +9,7 @@ db POISON ; species type 1 db POISON ; species type 2 db 75 ; catch rate db 157 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/muk.pic",0,1 ; 77, sprite dimensions dw MukPicFront dw MukPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/nidoking.asm b/data/baseStats/nidoking.asm index 55cd235dce..c283821b87 100755 --- a/data/baseStats/nidoking.asm +++ b/data/baseStats/nidoking.asm @@ -9,7 +9,7 @@ db POISON ; species type 1 db GROUND ; species type 2 db 45 ; catch rate db 195 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/nidoking.pic",0,1 ; 77, sprite dimensions dw NidokingPicFront dw NidokingPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/nidoqueen.asm b/data/baseStats/nidoqueen.asm index 12054109ac..5f3f91a33f 100755 --- a/data/baseStats/nidoqueen.asm +++ b/data/baseStats/nidoqueen.asm @@ -9,7 +9,7 @@ db POISON ; species type 1 db GROUND ; species type 2 db 45 ; catch rate db 194 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/nidoqueen.pic",0,1 ; 77, sprite dimensions dw NidoqueenPicFront dw NidoqueenPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/nidoranf.asm b/data/baseStats/nidoranf.asm index 9a399a156f..7d3b194091 100755 --- a/data/baseStats/nidoranf.asm +++ b/data/baseStats/nidoranf.asm @@ -9,7 +9,7 @@ db POISON ; species type 1 db POISON ; species type 2 db 235 ; catch rate db 59 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/nidoranF.pic",0,1 ; 55, sprite dimensions dw NidoranFPicFront dw NidoranFPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/nidoranm.asm b/data/baseStats/nidoranm.asm index 646c94d3d7..1cf36df000 100755 --- a/data/baseStats/nidoranm.asm +++ b/data/baseStats/nidoranm.asm @@ -9,7 +9,7 @@ db POISON ; species type 1 db POISON ; species type 2 db 235 ; catch rate db 60 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/nidoranM.pic",0,1 ; 55, sprite dimensions dw NidoranMPicFront dw NidoranMPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/nidorina.asm b/data/baseStats/nidorina.asm index 6787022da7..b2ab3ce81e 100755 --- a/data/baseStats/nidorina.asm +++ b/data/baseStats/nidorina.asm @@ -9,7 +9,7 @@ db POISON ; species type 1 db POISON ; species type 2 db 120 ; catch rate db 117 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/nidorina.pic",0,1 ; 66, sprite dimensions dw NidorinaPicFront dw NidorinaPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/nidorino.asm b/data/baseStats/nidorino.asm index ee64fdafca..06957afdd6 100755 --- a/data/baseStats/nidorino.asm +++ b/data/baseStats/nidorino.asm @@ -9,7 +9,7 @@ db POISON ; species type 1 db POISON ; species type 2 db 120 ; catch rate db 118 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/nidorino.pic",0,1 ; 66, sprite dimensions dw NidorinoPicFront dw NidorinoPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/ninetails.asm b/data/baseStats/ninetails.asm index a79adb0304..8141b627e0 100755 --- a/data/baseStats/ninetails.asm +++ b/data/baseStats/ninetails.asm @@ -9,7 +9,7 @@ db FIRE ; species type 1 db FIRE ; species type 2 db 75 ; catch rate db 178 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/ninetales.pic",0,1 ; 77, sprite dimensions dw NinetalesPicFront dw NinetalesPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/oddish.asm b/data/baseStats/oddish.asm index fa4b42ae42..31e376a6af 100755 --- a/data/baseStats/oddish.asm +++ b/data/baseStats/oddish.asm @@ -9,7 +9,7 @@ db GRASS ; species type 1 db POISON ; species type 2 db 255 ; catch rate db 78 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/oddish.pic",0,1 ; 55, sprite dimensions dw OddishPicFront dw OddishPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/omanyte.asm b/data/baseStats/omanyte.asm index a95ba1b7f0..d4b5f534eb 100755 --- a/data/baseStats/omanyte.asm +++ b/data/baseStats/omanyte.asm @@ -9,7 +9,7 @@ db ROCK ; species type 1 db WATER ; species type 2 db 45 ; catch rate db 120 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/omanyte.pic",0,1 ; 55, sprite dimensions dw OmanytePicFront dw OmanytePicBack ; attacks known at lvl 0 diff --git a/data/baseStats/omastar.asm b/data/baseStats/omastar.asm index 0dc00a5905..f39c8f2dfa 100755 --- a/data/baseStats/omastar.asm +++ b/data/baseStats/omastar.asm @@ -9,7 +9,7 @@ db ROCK ; species type 1 db WATER ; species type 2 db 45 ; catch rate db 199 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/omastar.pic",0,1 ; 66, sprite dimensions dw OmastarPicFront dw OmastarPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/onix.asm b/data/baseStats/onix.asm index 984fc53b12..ce4375f786 100755 --- a/data/baseStats/onix.asm +++ b/data/baseStats/onix.asm @@ -9,7 +9,7 @@ db ROCK ; species type 1 db GROUND ; species type 2 db 45 ; catch rate db 108 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/onix.pic",0,1 ; 77, sprite dimensions dw OnixPicFront dw OnixPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/paras.asm b/data/baseStats/paras.asm index 8fbb729c2d..c1f9dbdd19 100755 --- a/data/baseStats/paras.asm +++ b/data/baseStats/paras.asm @@ -9,7 +9,7 @@ db BUG ; species type 1 db GRASS ; species type 2 db 190 ; catch rate db 70 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/paras.pic",0,1 ; 55, sprite dimensions dw ParasPicFront dw ParasPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/parasect.asm b/data/baseStats/parasect.asm index 81231c0f25..e53fec0ed9 100755 --- a/data/baseStats/parasect.asm +++ b/data/baseStats/parasect.asm @@ -9,7 +9,7 @@ db BUG ; species type 1 db GRASS ; species type 2 db 75 ; catch rate db 128 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/parasect.pic",0,1 ; 77, sprite dimensions dw ParasectPicFront dw ParasectPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/persian.asm b/data/baseStats/persian.asm index ddf889b9c1..c72ac802d5 100755 --- a/data/baseStats/persian.asm +++ b/data/baseStats/persian.asm @@ -9,7 +9,7 @@ db NORMAL ; species type 1 db NORMAL ; species type 2 db 90 ; catch rate db 148 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/persian.pic",0,1 ; 77, sprite dimensions dw PersianPicFront dw PersianPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/pidgeot.asm b/data/baseStats/pidgeot.asm index 6367cd24fd..47fafc3ea8 100755 --- a/data/baseStats/pidgeot.asm +++ b/data/baseStats/pidgeot.asm @@ -9,7 +9,7 @@ db NORMAL ; species type 1 db FLYING ; species type 2 db 45 ; catch rate db 172 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/pidgeot.pic",0,1 ; 77, sprite dimensions dw PidgeotPicFront dw PidgeotPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/pidgeotto.asm b/data/baseStats/pidgeotto.asm index 65a39130fd..c996b671b8 100755 --- a/data/baseStats/pidgeotto.asm +++ b/data/baseStats/pidgeotto.asm @@ -9,7 +9,7 @@ db NORMAL ; species type 1 db FLYING ; species type 2 db 120 ; catch rate db 113 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/pidgeotto.pic",0,1 ; 66, sprite dimensions dw PidgeottoPicFront dw PidgeottoPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/pidgey.asm b/data/baseStats/pidgey.asm index 81bbb12afa..212595827e 100755 --- a/data/baseStats/pidgey.asm +++ b/data/baseStats/pidgey.asm @@ -9,7 +9,7 @@ db NORMAL ; species type 1 db FLYING ; species type 2 db 255 ; catch rate db 55 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/pidgey.pic",0,1 ; 55, sprite dimensions dw PidgeyPicFront dw PidgeyPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/pikachu.asm b/data/baseStats/pikachu.asm index 21e4d32dd2..f3b224c8f4 100755 --- a/data/baseStats/pikachu.asm +++ b/data/baseStats/pikachu.asm @@ -9,7 +9,7 @@ db ELECTRIC ; species type 1 db ELECTRIC ; species type 2 db 190 ; catch rate db 82 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/pikachu.pic",0,1 ; 55, sprite dimensions dw PikachuPicFront dw PikachuPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/pinsir.asm b/data/baseStats/pinsir.asm index 3eec991671..d9c73ea07a 100755 --- a/data/baseStats/pinsir.asm +++ b/data/baseStats/pinsir.asm @@ -9,7 +9,7 @@ db BUG ; species type 1 db BUG ; species type 2 db 45 ; catch rate db 200 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/pinsir.pic",0,1 ; 77, sprite dimensions dw PinsirPicFront dw PinsirPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/poliwag.asm b/data/baseStats/poliwag.asm index 307e20091e..6be8587df7 100755 --- a/data/baseStats/poliwag.asm +++ b/data/baseStats/poliwag.asm @@ -9,7 +9,7 @@ db WATER ; species type 1 db WATER ; species type 2 db 255 ; catch rate db 77 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/poliwag.pic",0,1 ; 55, sprite dimensions dw PoliwagPicFront dw PoliwagPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/poliwhirl.asm b/data/baseStats/poliwhirl.asm index 953eea655d..b59d64158a 100755 --- a/data/baseStats/poliwhirl.asm +++ b/data/baseStats/poliwhirl.asm @@ -9,7 +9,7 @@ db WATER ; species type 1 db WATER ; species type 2 db 120 ; catch rate db 131 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/poliwhirl.pic",0,1 ; 66, sprite dimensions dw PoliwhirlPicFront dw PoliwhirlPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/poliwrath.asm b/data/baseStats/poliwrath.asm index 3691912510..d326a90919 100755 --- a/data/baseStats/poliwrath.asm +++ b/data/baseStats/poliwrath.asm @@ -9,7 +9,7 @@ db WATER ; species type 1 db FIGHTING ; species type 2 db 45 ; catch rate db 185 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/poliwrath.pic",0,1 ; 77, sprite dimensions dw PoliwrathPicFront dw PoliwrathPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/ponyta.asm b/data/baseStats/ponyta.asm index b791a349f8..3f22d6dd1a 100755 --- a/data/baseStats/ponyta.asm +++ b/data/baseStats/ponyta.asm @@ -9,7 +9,7 @@ db FIRE ; species type 1 db FIRE ; species type 2 db 190 ; catch rate db 152 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/ponyta.pic",0,1 ; 66, sprite dimensions dw PonytaPicFront dw PonytaPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/porygon.asm b/data/baseStats/porygon.asm index 14a1c44630..0c8a6b3333 100755 --- a/data/baseStats/porygon.asm +++ b/data/baseStats/porygon.asm @@ -9,7 +9,7 @@ db NORMAL ; species type 1 db NORMAL ; species type 2 db 45 ; catch rate db 130 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/porygon.pic",0,1 ; 66, sprite dimensions dw PorygonPicFront dw PorygonPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/primeape.asm b/data/baseStats/primeape.asm index 492fe8cadc..f88511df0d 100755 --- a/data/baseStats/primeape.asm +++ b/data/baseStats/primeape.asm @@ -9,7 +9,7 @@ db FIGHTING ; species type 1 db FIGHTING ; species type 2 db 75 ; catch rate db 149 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/primeape.pic",0,1 ; 77, sprite dimensions dw PrimeapePicFront dw PrimeapePicBack ; attacks known at lvl 0 diff --git a/data/baseStats/psyduck.asm b/data/baseStats/psyduck.asm index 6ec1bd9f16..bc435c5769 100755 --- a/data/baseStats/psyduck.asm +++ b/data/baseStats/psyduck.asm @@ -9,7 +9,7 @@ db WATER ; species type 1 db WATER ; species type 2 db 190 ; catch rate db 80 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/psyduck.pic",0,1 ; 55, sprite dimensions dw PsyduckPicFront dw PsyduckPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/raichu.asm b/data/baseStats/raichu.asm index 6bd2f940b9..6324d57d70 100755 --- a/data/baseStats/raichu.asm +++ b/data/baseStats/raichu.asm @@ -9,7 +9,7 @@ db ELECTRIC ; species type 1 db ELECTRIC ; species type 2 db 75 ; catch rate db 122 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/raichu.pic",0,1 ; 77, sprite dimensions dw RaichuPicFront dw RaichuPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/rapidash.asm b/data/baseStats/rapidash.asm index c3fb4168e2..f5088b6e69 100755 --- a/data/baseStats/rapidash.asm +++ b/data/baseStats/rapidash.asm @@ -9,7 +9,7 @@ db FIRE ; species type 1 db FIRE ; species type 2 db 60 ; catch rate db 192 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/rapidash.pic",0,1 ; 77, sprite dimensions dw RapidashPicFront dw RapidashPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/raticate.asm b/data/baseStats/raticate.asm index 301b7b2128..1bc9209005 100755 --- a/data/baseStats/raticate.asm +++ b/data/baseStats/raticate.asm @@ -9,7 +9,7 @@ db NORMAL ; species type 1 db NORMAL ; species type 2 db 90 ; catch rate db 116 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/raticate.pic",0,1 ; 66, sprite dimensions dw RaticatePicFront dw RaticatePicBack ; attacks known at lvl 0 diff --git a/data/baseStats/rattata.asm b/data/baseStats/rattata.asm index 72dbd8efe6..192f8f2620 100755 --- a/data/baseStats/rattata.asm +++ b/data/baseStats/rattata.asm @@ -9,7 +9,7 @@ db NORMAL ; species type 1 db NORMAL ; species type 2 db 255 ; catch rate db 57 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/rattata.pic",0,1 ; 55, sprite dimensions dw RattataPicFront dw RattataPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/rhydon.asm b/data/baseStats/rhydon.asm index dd0e938340..9f005b84d2 100755 --- a/data/baseStats/rhydon.asm +++ b/data/baseStats/rhydon.asm @@ -9,7 +9,7 @@ db GROUND ; species type 1 db ROCK ; species type 2 db 60 ; catch rate db 204 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/rhydon.pic",0,1 ; 77, sprite dimensions dw RhydonPicFront dw RhydonPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/rhyhorn.asm b/data/baseStats/rhyhorn.asm index 8939e8521e..5521f37a93 100755 --- a/data/baseStats/rhyhorn.asm +++ b/data/baseStats/rhyhorn.asm @@ -9,7 +9,7 @@ db GROUND ; species type 1 db ROCK ; species type 2 db 120 ; catch rate db 135 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/rhyhorn.pic",0,1 ; 77, sprite dimensions dw RhyhornPicFront dw RhyhornPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/sandshrew.asm b/data/baseStats/sandshrew.asm index 07df1cf2d4..28016ab9a1 100755 --- a/data/baseStats/sandshrew.asm +++ b/data/baseStats/sandshrew.asm @@ -9,7 +9,7 @@ db GROUND ; species type 1 db GROUND ; species type 2 db 255 ; catch rate db 93 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/sandshrew.pic",0,1 ; 55, sprite dimensions dw SandshrewPicFront dw SandshrewPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/sandslash.asm b/data/baseStats/sandslash.asm index 25e1e200fb..f613a51713 100755 --- a/data/baseStats/sandslash.asm +++ b/data/baseStats/sandslash.asm @@ -9,7 +9,7 @@ db GROUND ; species type 1 db GROUND ; species type 2 db 90 ; catch rate db 163 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/sandslash.pic",0,1 ; 66, sprite dimensions dw SandslashPicFront dw SandslashPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/scyther.asm b/data/baseStats/scyther.asm index ff7e9d29cf..6e20cddc87 100755 --- a/data/baseStats/scyther.asm +++ b/data/baseStats/scyther.asm @@ -9,7 +9,7 @@ db BUG ; species type 1 db FLYING ; species type 2 db 45 ; catch rate db 187 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/scyther.pic",0,1 ; 77, sprite dimensions dw ScytherPicFront dw ScytherPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/seadra.asm b/data/baseStats/seadra.asm index 1ba762c220..67cc26e15d 100755 --- a/data/baseStats/seadra.asm +++ b/data/baseStats/seadra.asm @@ -9,7 +9,7 @@ db WATER ; species type 1 db WATER ; species type 2 db 75 ; catch rate db 155 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/seadra.pic",0,1 ; 66, sprite dimensions dw SeadraPicFront dw SeadraPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/seaking.asm b/data/baseStats/seaking.asm index 385ed0883a..c122d946a7 100755 --- a/data/baseStats/seaking.asm +++ b/data/baseStats/seaking.asm @@ -9,7 +9,7 @@ db WATER ; species type 1 db WATER ; species type 2 db 60 ; catch rate db 170 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/seaking.pic",0,1 ; 77, sprite dimensions dw SeakingPicFront dw SeakingPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/seel.asm b/data/baseStats/seel.asm index d448eaca49..63a57b988f 100755 --- a/data/baseStats/seel.asm +++ b/data/baseStats/seel.asm @@ -9,7 +9,7 @@ db WATER ; species type 1 db WATER ; species type 2 db 190 ; catch rate db 100 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/seel.pic",0,1 ; 66, sprite dimensions dw SeelPicFront dw SeelPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/shellder.asm b/data/baseStats/shellder.asm index 6a53479ed3..06525091cc 100755 --- a/data/baseStats/shellder.asm +++ b/data/baseStats/shellder.asm @@ -9,7 +9,7 @@ db WATER ; species type 1 db WATER ; species type 2 db 190 ; catch rate db 97 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/shellder.pic",0,1 ; 55, sprite dimensions dw ShellderPicFront dw ShellderPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/slowbro.asm b/data/baseStats/slowbro.asm index c8687d7ead..dd27148522 100755 --- a/data/baseStats/slowbro.asm +++ b/data/baseStats/slowbro.asm @@ -9,7 +9,7 @@ db WATER ; species type 1 db PSYCHIC ; species type 2 db 75 ; catch rate db 164 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/slowbro.pic",0,1 ; 77, sprite dimensions dw SlowbroPicFront dw SlowbroPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/slowpoke.asm b/data/baseStats/slowpoke.asm index 29eccdf3cf..41e0a586e8 100755 --- a/data/baseStats/slowpoke.asm +++ b/data/baseStats/slowpoke.asm @@ -9,7 +9,7 @@ db WATER ; species type 1 db PSYCHIC ; species type 2 db 190 ; catch rate db 99 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/slowpoke.pic",0,1 ; 55, sprite dimensions dw SlowpokePicFront dw SlowpokePicBack ; attacks known at lvl 0 diff --git a/data/baseStats/snorlax.asm b/data/baseStats/snorlax.asm index 427ba99da4..0ada7fa3a0 100755 --- a/data/baseStats/snorlax.asm +++ b/data/baseStats/snorlax.asm @@ -9,7 +9,7 @@ db NORMAL ; species type 1 db NORMAL ; species type 2 db 25 ; catch rate db 154 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/snorlax.pic",0,1 ; 77, sprite dimensions dw SnorlaxPicFront dw SnorlaxPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/spearow.asm b/data/baseStats/spearow.asm index 351a9c35f6..818ec039cf 100755 --- a/data/baseStats/spearow.asm +++ b/data/baseStats/spearow.asm @@ -9,7 +9,7 @@ db NORMAL ; species type 1 db FLYING ; species type 2 db 255 ; catch rate db 58 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/spearow.pic",0,1 ; 55, sprite dimensions dw SpearowPicFront dw SpearowPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/squirtle.asm b/data/baseStats/squirtle.asm index aa7406a6db..d79a79e3a6 100755 --- a/data/baseStats/squirtle.asm +++ b/data/baseStats/squirtle.asm @@ -9,7 +9,7 @@ db WATER ; species type 1 db WATER ; species type 2 db 45 ; catch rate db 66 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/squirtle.pic",0,1 ; 55, sprite dimensions dw SquirtlePicFront dw SquirtlePicBack ; attacks known at lvl 0 diff --git a/data/baseStats/starmie.asm b/data/baseStats/starmie.asm index dbe27ac080..671666ccfb 100755 --- a/data/baseStats/starmie.asm +++ b/data/baseStats/starmie.asm @@ -9,7 +9,7 @@ db WATER ; species type 1 db PSYCHIC ; species type 2 db 60 ; catch rate db 207 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/starmie.pic",0,1 ; 66, sprite dimensions dw StarmiePicFront dw StarmiePicBack ; attacks known at lvl 0 diff --git a/data/baseStats/staryu.asm b/data/baseStats/staryu.asm index 043a86ad2e..031fe9f5eb 100755 --- a/data/baseStats/staryu.asm +++ b/data/baseStats/staryu.asm @@ -9,7 +9,7 @@ db WATER ; species type 1 db WATER ; species type 2 db 225 ; catch rate db 106 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/staryu.pic",0,1 ; 66, sprite dimensions dw StaryuPicFront dw StaryuPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/tangela.asm b/data/baseStats/tangela.asm index 41af97aa50..3e899c053b 100755 --- a/data/baseStats/tangela.asm +++ b/data/baseStats/tangela.asm @@ -9,7 +9,7 @@ db GRASS ; species type 1 db GRASS ; species type 2 db 45 ; catch rate db 166 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/tangela.pic",0,1 ; 66, sprite dimensions dw TangelaPicFront dw TangelaPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/tauros.asm b/data/baseStats/tauros.asm index 47a70dab8c..16020b09d2 100755 --- a/data/baseStats/tauros.asm +++ b/data/baseStats/tauros.asm @@ -9,7 +9,7 @@ db NORMAL ; species type 1 db NORMAL ; species type 2 db 45 ; catch rate db 211 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/tauros.pic",0,1 ; 77, sprite dimensions dw TaurosPicFront dw TaurosPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/tentacool.asm b/data/baseStats/tentacool.asm index 6d81f5ad7d..f7569d65da 100755 --- a/data/baseStats/tentacool.asm +++ b/data/baseStats/tentacool.asm @@ -9,7 +9,7 @@ db WATER ; species type 1 db POISON ; species type 2 db 190 ; catch rate db 105 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/tentacool.pic",0,1 ; 55, sprite dimensions dw TentacoolPicFront dw TentacoolPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/tentacruel.asm b/data/baseStats/tentacruel.asm index 13f49a8b22..d7115059bf 100755 --- a/data/baseStats/tentacruel.asm +++ b/data/baseStats/tentacruel.asm @@ -9,7 +9,7 @@ db WATER ; species type 1 db POISON ; species type 2 db 60 ; catch rate db 205 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/tentacruel.pic",0,1 ; 66, sprite dimensions dw TentacruelPicFront dw TentacruelPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/vaporeon.asm b/data/baseStats/vaporeon.asm index eca2309be6..33ccc5174f 100755 --- a/data/baseStats/vaporeon.asm +++ b/data/baseStats/vaporeon.asm @@ -9,7 +9,7 @@ db WATER ; species type 1 db WATER ; species type 2 db 45 ; catch rate db 196 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/vaporeon.pic",0,1 ; 66, sprite dimensions dw VaporeonPicFront dw VaporeonPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/venomoth.asm b/data/baseStats/venomoth.asm index c975ee6e37..0a4d446159 100755 --- a/data/baseStats/venomoth.asm +++ b/data/baseStats/venomoth.asm @@ -9,7 +9,7 @@ db BUG ; species type 1 db POISON ; species type 2 db 75 ; catch rate db 138 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/venomoth.pic",0,1 ; 77, sprite dimensions dw VenomothPicFront dw VenomothPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/venonat.asm b/data/baseStats/venonat.asm index cc4a6cb230..4543a7303a 100755 --- a/data/baseStats/venonat.asm +++ b/data/baseStats/venonat.asm @@ -9,7 +9,7 @@ db BUG ; species type 1 db POISON ; species type 2 db 190 ; catch rate db 75 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/venonat.pic",0,1 ; 55, sprite dimensions dw VenonatPicFront dw VenonatPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/venusaur.asm b/data/baseStats/venusaur.asm index 7b861914e0..426d18ac8e 100755 --- a/data/baseStats/venusaur.asm +++ b/data/baseStats/venusaur.asm @@ -9,7 +9,7 @@ db GRASS ; species type 1 db POISON ; species type 2 db 45 ; catch rate db 208 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/venusaur.pic",0,1 ; 77, sprite dimensions dw VenusaurPicFront dw VenusaurPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/victreebel.asm b/data/baseStats/victreebel.asm index 807dde1cf3..4f544b8d68 100755 --- a/data/baseStats/victreebel.asm +++ b/data/baseStats/victreebel.asm @@ -9,7 +9,7 @@ db GRASS ; species type 1 db POISON ; species type 2 db 45 ; catch rate db 191 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/victreebel.pic",0,1 ; 77, sprite dimensions dw VictreebelPicFront dw VictreebelPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/vileplume.asm b/data/baseStats/vileplume.asm index 60b580983d..df44be3531 100755 --- a/data/baseStats/vileplume.asm +++ b/data/baseStats/vileplume.asm @@ -9,7 +9,7 @@ db GRASS ; species type 1 db POISON ; species type 2 db 45 ; catch rate db 184 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/vileplume.pic",0,1 ; 77, sprite dimensions dw VileplumePicFront dw VileplumePicBack ; attacks known at lvl 0 diff --git a/data/baseStats/voltorb.asm b/data/baseStats/voltorb.asm index fed28364b6..f85fc1656a 100755 --- a/data/baseStats/voltorb.asm +++ b/data/baseStats/voltorb.asm @@ -9,7 +9,7 @@ db ELECTRIC ; species type 1 db ELECTRIC ; species type 2 db 190 ; catch rate db 103 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/voltorb.pic",0,1 ; 55, sprite dimensions dw VoltorbPicFront dw VoltorbPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/vulpix.asm b/data/baseStats/vulpix.asm index c01a64fcbe..5b9bc47ce7 100755 --- a/data/baseStats/vulpix.asm +++ b/data/baseStats/vulpix.asm @@ -9,7 +9,7 @@ db FIRE ; species type 1 db FIRE ; species type 2 db 190 ; catch rate db 63 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/vulpix.pic",0,1 ; 66, sprite dimensions dw VulpixPicFront dw VulpixPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/wartortle.asm b/data/baseStats/wartortle.asm index 9b2253a441..4d77ea7bc4 100755 --- a/data/baseStats/wartortle.asm +++ b/data/baseStats/wartortle.asm @@ -9,7 +9,7 @@ db WATER ; species type 1 db WATER ; species type 2 db 45 ; catch rate db 143 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/wartortle.pic",0,1 ; 66, sprite dimensions dw WartortlePicFront dw WartortlePicBack ; attacks known at lvl 0 diff --git a/data/baseStats/weedle.asm b/data/baseStats/weedle.asm index 683fa06dd7..8e501f0b38 100755 --- a/data/baseStats/weedle.asm +++ b/data/baseStats/weedle.asm @@ -9,7 +9,7 @@ db BUG ; species type 1 db POISON ; species type 2 db 255 ; catch rate db 52 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/weedle.pic",0,1 ; 55, sprite dimensions dw WeedlePicFront dw WeedlePicBack ; attacks known at lvl 0 diff --git a/data/baseStats/weepinbell.asm b/data/baseStats/weepinbell.asm index e3e6bab13e..1a974e203e 100755 --- a/data/baseStats/weepinbell.asm +++ b/data/baseStats/weepinbell.asm @@ -9,7 +9,7 @@ db GRASS ; species type 1 db POISON ; species type 2 db 120 ; catch rate db 151 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/weepinbell.pic",0,1 ; 66, sprite dimensions dw WeepinbellPicFront dw WeepinbellPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/weezing.asm b/data/baseStats/weezing.asm index cc7f18d15e..bd526ecb8b 100755 --- a/data/baseStats/weezing.asm +++ b/data/baseStats/weezing.asm @@ -9,7 +9,7 @@ db POISON ; species type 1 db POISON ; species type 2 db 60 ; catch rate db 173 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/weezing.pic",0,1 ; 77, sprite dimensions dw WeezingPicFront dw WeezingPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/wigglytuff.asm b/data/baseStats/wigglytuff.asm index f9c50c6929..1a403c3e82 100755 --- a/data/baseStats/wigglytuff.asm +++ b/data/baseStats/wigglytuff.asm @@ -9,7 +9,7 @@ db NORMAL ; species type 1 db NORMAL ; species type 2 db 50 ; catch rate db 109 ; base exp yield -db $66 ; sprite dimensions +INCBIN "pic/bmon/wigglytuff.pic",0,1 ; 66, sprite dimensions dw WigglytuffPicFront dw WigglytuffPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/zapdos.asm b/data/baseStats/zapdos.asm index 26e3f14c91..257bb859e2 100755 --- a/data/baseStats/zapdos.asm +++ b/data/baseStats/zapdos.asm @@ -9,7 +9,7 @@ db ELECTRIC ; species type 1 db FLYING ; species type 2 db 3 ; catch rate db 216 ; base exp yield -db $77 ; sprite dimensions +INCBIN "pic/bmon/zapdos.pic",0,1 ; 77, sprite dimensions dw ZapdosPicFront dw ZapdosPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/zubat.asm b/data/baseStats/zubat.asm index f80ff41910..b2197c1385 100755 --- a/data/baseStats/zubat.asm +++ b/data/baseStats/zubat.asm @@ -9,7 +9,7 @@ db POISON ; species type 1 db FLYING ; species type 2 db 255 ; catch rate db 54 ; base exp yield -db $55 ; sprite dimensions +INCBIN "pic/bmon/zubat.pic",0,1 ; 55, sprite dimensions dw ZubatPicFront dw ZubatPicBack ; attacks known at lvl 0 From 8dd46620bc7e17c4c582a391fb95c9e29ef58576 Mon Sep 17 00:00:00 2001 From: yenatch Date: Wed, 16 Jul 2014 15:28:46 -0700 Subject: [PATCH 007/100] Add a comment to the "compare" target. --- Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makefile b/Makefile index 37a9ea76f4..e361636149 100644 --- a/Makefile +++ b/Makefile @@ -27,9 +27,15 @@ PYTHON := python # md5sum -c is used to compare rom hashes. The options may vary across platforms. MD5 := md5sum -c --quiet + + +# The compare target is a shortcut to check that the build matches the original roms exactly. +# This is for contributors to make sure a change didn't affect the contents of the rom. +# More thorough comparison can be made by diffing the output of hexdump -C against both roms. compare: @$(MD5) roms.md5 + # Clear the default suffixes. .SUFFIXES: .SUFFIXES: .asm .tx .o .gbc .png .2bpp .1bpp .pic From c9946975d4cd806c92c1aa1efef94eb41d8b9d36 Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Mon, 28 Jul 2014 02:09:14 -0700 Subject: [PATCH 008/100] Commented function - Named and commented Func_4c70. - Removed gfx/diagonal_lines.png, which is not actually graphics. --- engine/overworld/movement.asm | 8 +- gfx/diagonal_lines.png | Bin 100 -> 0 bytes main.asm | 273 ++++++++++++++++++++++------------ 3 files changed, 182 insertions(+), 99 deletions(-) delete mode 100644 gfx/diagonal_lines.png diff --git a/engine/overworld/movement.asm b/engine/overworld/movement.asm index f08a20cb8f..dbec2e4fa9 100644 --- a/engine/overworld/movement.asm +++ b/engine/overworld/movement.asm @@ -17,7 +17,7 @@ UpdatePlayerSprite: ; 4e31 (1:4e31) ld [wSpriteStateData1 + 2], a ret .asm_4e50 - call Func_4c70 + call DetectCollisionBetweenSprites ld h, $c1 ld a, [wWalkCounter] ; wcfc5 and a @@ -604,16 +604,16 @@ CanWalkOntoTile: ; 516e (1:516e) jr nc, .impassable ; don't walk off screen push de push bc - call Func_4c70 + call DetectCollisionBetweenSprites pop bc pop de ld h, $c1 ld a, [H_CURRENTSPRITEOFFSET] add $c ld l, a - ld a, [hl] ; c1xc (forbidden directions flags(?)) + ld a, [hl] ; c1xc (directions in which sprite collision would occur) and b ; check against chosen direction (1,2,4 or 8) - jr nz, .impassable ; direction forbidden, don't go there + jr nz, .impassable ; collision between sprites, don't go there ld h, $c2 ld a, [H_CURRENTSPRITEOFFSET] add $2 diff --git a/gfx/diagonal_lines.png b/gfx/diagonal_lines.png deleted file mode 100644 index 400c04b5aa63a6a36a60a5b7730ab60a7741b0a3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 100 zcmeAS@N?(olHy`uVBq!ia0vp^96&6<1SA+-0xLn3wx^3@NX0GIgNA|(1{@3<%lo!? wIWj3Tv)^YCmlkfGI&F#oKRdU)y0Yqd{xj2MAKS_oxPtU~y85}Sb4q9e0JR_%b^rhX diff --git a/main.asm b/main.asm index 32a3db2c08..8c100de8d3 100755 --- a/main.asm +++ b/main.asm @@ -222,8 +222,16 @@ UpdateNonPlayerSprite: .unequal jp Func_4ed1 - -Func_4c70: +; This detects if the current sprite (whose offset is at H_CURRENTSPRITEOFFSET) +; is going to collide with another sprite by looping over the other sprites. +; The current sprite's offset will be labelled with i (e.g. $c1i0). +; The loop sprite's offset will labelled with j (e.g. $c1j0). +; +; Note that the Y coordinate of the sprite (in [$c1k4]) is one of the following +; 9 values when the sprite is aligned with the grid: $fc, $0c, $1c, $2c, ..., $7c. +; The reason that 4 is added below to the coordinate is to make it align with a +; multiple of $10 to make comparisons easier. +DetectCollisionBetweenSprites: nop ld h, wSpriteStateData1 / $100 @@ -231,195 +239,250 @@ Func_4c70: add wSpriteStateData1 % $100 ld l, a - ld a, [hl] - and a - ret z + ld a, [hl] ; a = [$c1i0] (picture) (0 if slot is unused) + and a ; is this sprite slot slot used? + ret z ; return if not used ld a, l add 3 ld l, a - ld a, [hli] - call Func_4d72 + ld a, [hli] ; a = [$c1i3] (delta Y) (-1, 0, or 1) + call SetSpriteCollisionValues - ld a, [hli] - add 4 + ld a, [hli] ; a = [$C1i4] (Y screen coordinate) + add 4 ; align with multiple of $10 + +; The effect of the following 3 lines is to +; add 7 to a if moving south or +; subtract 7 from a if moving north. add b and $f0 or c - ld [$ff90], a - ld a, [hli] - call Func_4d72 + ld [$ff90], a ; store Y coordinate adjusted for direction of movement - ld a, [hl] + ld a, [hli] ; a = [$c1i5] (delta X) (-1, 0, or 1) + call SetSpriteCollisionValues + ld a, [hl] ; a = [$C1i6] (X screen coordinate) + +; The effect of the following 3 lines is to +; add 7 to a if moving east or +; subtract 7 from a if moving west. add b and $f0 or c - ld [$ff91], a + + ld [$ff91], a ; store X coordinate adjusted for direction of movement ld a, l add 7 ld l, a xor a - ld [hld], a - ld [hld], a + ld [hld], a ; zero [$c1id] XXX what's [$c1id] for? + ld [hld], a ; zero [$c1ic] (directions in which collisions occurred) + ld a, [$ff91] - ld [hld], a + ld [hld], a ; [$c1ib] = adjusted X coordiate ld a, [$ff90] - ld [hl], a - xor a + ld [hl], a ; [$c1ia] = adjusted Y coordinate + + xor a ; zero the loop counter .loop - ld [$ff8f], a + ld [$ff8f], a ; store loop counter swap a ld e, a ld a, [H_CURRENTSPRITEOFFSET] - cp e - jp z, .next + cp e ; does the loop sprite match the current sprite? + jp z, .next ; go to the next sprite if they match ld d, h - ld a, [de] - and a - jp z, .next + ld a, [de] ; a = [$c1j0] (picture) (0 if slot is unused) + and a ; is this sprite slot slot used? + jp z, .next ; go the next sprite if not used inc e inc e - ld a, [de] + ld a, [de] ; a = [$c1j2] ($ff means the sprite is offscreen) inc a - jp z, .next + jp z, .next ; go the next sprite if offscreen ld a, [H_CURRENTSPRITEOFFSET] add 10 ld l, a + inc e + ld a, [de] ; a = [$c1j3] (delta Y) + call SetSpriteCollisionValues - ld a, [de] - call Func_4d72 inc e + ld a, [de] ; a = [$C1j4] (Y screen coordinate) + add 4 ; align with multiple of $10 - ld a, [de] - add 4 +; The effect of the following 3 lines is to +; add 7 to a if moving south or +; subtract 7 from a if moving north. add b and $f0 or c - sub [hl] - jr nc, .asm_4cd4 + + sub [hl] ; subtract the adjusted Y coordinate of sprite i ([$c1ia]) from that of sprite j + +; calculate the absolute value of the difference to get the distance + jr nc, .noCarry1 cpl inc a -.asm_4cd4 - ld [$ff90], a - +.noCarry1 + ld [$ff90], a ; store the distance between the two sprites' adjusted Y values + +; Use the carry flag set by the above subtraction to determine which sprite's +; Y coordinate is larger. This information is used later to set [$c1ic], +; which stores which direction the collision occurred in. +; The following 5 lines set the lowest 2 bits of c, which are later shifted left by 2. +; If sprite i's Y is larger, set lowest 2 bits of c to 10. +; If sprite j's Y is larger or both are equal, set lowest 2 bits of c to 01. push af rl c pop af ccf rl c + +; If sprite i's delta Y is 0, then b = 7, else b = 9. ld b, 7 - ld a, [hl] + ld a, [hl] ; a = [$c1ia] (adjusted Y coordinate) and $f - jr z, .asm_4ce6 + jr z, .next1 ld b, 9 -.asm_4ce6 - ld a, [$ff90] + +.next1 + ld a, [$ff90] ; a = distance between adjusted Y coordinates sub b - ld [$ff92], a + ld [$ff92], a ; store distance adjusted using sprite i's direction ld a, b - ld [$ff90], a - jr c, .asm_4d01 + ld [$ff90], a ; store 7 or 9 depending on sprite i's delta Y + jr c, .checkXDistance +; If sprite j's delta Y is 0, then b = 7, else b = 9. ld b, 7 dec e - ld a, [de] + ld a, [de] ; a = [$c1j3] (delta Y) inc e and a - jr z, .asm_4cfa + jr z, .next2 ld b, 9 -.asm_4cfa - ld a, [$ff92] - sub b - jr z, .asm_4d01 - jr nc, .next -.asm_4d01 +.next2 + ld a, [$ff92] ; a = distance adjusted using sprite i's direction + sub b ; adjust distance using sprite j's direction + jr z, .checkXDistance + jr nc, .next ; go to next sprite if distance is still positive after both adjustments + +.checkXDistance inc e inc l - ld a, [de] + ld a, [de] ; a = [$c1j5] (delta X) push bc - call Func_4d72 + + call SetSpriteCollisionValues inc e - ld a, [de] + ld a, [de] ; a = [$c1j6] (X screen coordinate) + +; The effect of the following 3 lines is to +; add 7 to a if moving east or +; subtract 7 from a if moving west. add b and $f0 or c + pop bc - sub [hl] - jr nc, .asm_4d14 + sub [hl] ; subtract the adjusted X coordinate of sprite i ([$c1ib]) from that of sprite j + +; calculate the absolute value of the difference to get the distance + jr nc, .noCarry2 cpl inc a -.asm_4d14 - ld [$ff91], a - +.noCarry2 + ld [$ff91], a ; store the distance between the two sprites' adjusted X values + +; Use the carry flag set by the above subtraction to determine which sprite's +; X coordinate is larger. This information is used later to set [$c1ic], +; which stores which direction the collision occurred in. +; The following 5 lines set the lowest 2 bits of c. +; If sprite i's X is larger, set lowest 2 bits of c to 10. +; If sprite j's X is larger or both are equal, set lowest 2 bits of c to 01. push af rl c pop af ccf rl c + +; If sprite i's delta X is 0, then b = 7, else b = 9. ld b, 7 - ld a, [hl] + ld a, [hl] ; a = [$c1ib] (adjusted X coordinate) and $f - jr z, .asm_4d26 + jr z, .next3 ld b, 9 -.asm_4d26 - ld a, [$ff91] + +.next3 + ld a, [$ff91] ; a = distance between adjusted X coordinates sub b - ld [$ff92], a + ld [$ff92], a ; store distance adjusted using sprite i's direction ld a, b - ld [$ff91], a - jr c, .asm_4d41 + ld [$ff91], a ; store 7 or 9 depending on sprite i's delta X + jr c, .collision + +; If sprite j's delta X is 0, then b = 7, else b = 9. ld b, 7 dec e - ld a, [de] + ld a, [de] ; a = [$c1j5] (delta X) inc e and a - jr z, .asm_4d3a + jr z, .next4 ld b, 9 -.asm_4d3a - ld a, [$ff92] - sub b - jr z, .asm_4d41 - jr nc, .next -.asm_4d41 - ld a, [$ff91] +.next4 + ld a, [$ff92] ; a = distance adjusted using sprite i's direction + sub b ; adjust distance using sprite j's direction + jr z, .collision + jr nc, .next ; go to next sprite if distance is still positive after both adjustments + +.collision + ld a, [$ff91] ; a = 7 or 9 depending on sprite i's delta X ld b, a - ld a, [$ff90] + ld a, [$ff90] ; a = 7 or 9 depending on sprite i's delta Y inc l + +; If delta X isn't 0 and delta Y is 0, then b = %0011, else b = %1100. +; (note that normally if delta X isn't 0, then delta Y must be 0 and vice versa) cp b - jr c, .asm_4d4e - ld b, 12 - jr .asm_4d50 -.asm_4d4e - ld b, 3 -.asm_4d50 - ld a, c - and b - or [hl] - ld [hl], a - ld a, c + jr c, .next5 + ld b, %1100 + jr .next6 +.next5 + ld b, %0011 + +.next6 + ld a, c ; c has 2 bits set (one of bits 0-1 is set for the X axis and one of bits 2-3 for the Y axis) + and b ; we select either the bit in bits 0-1 or bits 2-3 based on the calculation immediately above + or [hl] ; or with existing collision direction bits in [$c1ic] + ld [hl], a ; store new value + ld a, c ; useless code because a is overwritten before being used again + +; set bit in [$c1ie] or [$c1if] to indicate which sprite the collision occurred with inc l inc l - ld a, [$ff8f] - ld de, DiagonalLines + ld a, [$ff8f] ; a = loop counter + ld de, SpriteCollisionBitTable add a add e ld e, a - jr nc, .asm_4d62 + jr nc, .noCarry3 inc d -.asm_4d62 +.noCarry3 ld a, [de] or [hl] ld [hli], a @@ -429,13 +492,18 @@ Func_4c70: ld [hl], a .next - ld a, [$ff8f] + ld a, [$ff8f] ; a = loop counter inc a cp $10 jp nz, .loop ret -Func_4d72: +; takes delta X or delta Y in a +; b = delta X/Y +; c = 0 if delta X/Y is 0 +; c = 7 if delta X/Y is 1 +; c = 9 if delta X/Y is -1 +SetSpriteCollisionValues: and a ld b, 0 ld c, 0 @@ -450,8 +518,23 @@ Func_4d72: .done ret -DiagonalLines: INCBIN "gfx/diagonal_lines.2bpp" - +SpriteCollisionBitTable: + db %00000000,%00000001 + db %00000000,%00000010 + db %00000000,%00000100 + db %00000000,%00001000 + db %00000000,%00010000 + db %00000000,%00100000 + db %00000000,%01000000 + db %00000000,%10000000 + db %00000001,%00000000 + db %00000010,%00000000 + db %00000100,%00000000 + db %00001000,%00000000 + db %00010000,%00000000 + db %00100000,%00000000 + db %01000000,%00000000 + db %10000000,%00000000 TestBattle: ret From 1cf79b6f15761ec95ba1b0f9d6d83781c4240612 Mon Sep 17 00:00:00 2001 From: yenatch Date: Thu, 7 Aug 2014 21:17:44 -0700 Subject: [PATCH 009/100] Fix static banks passed into GetName. This appears to be the only other use of wPredefBank. Chances are there are more uncaught banks. Known cases are marked as "hardcoded" or similar. --- engine/battle/4_2.asm | 2 +- engine/battle/core.asm | 13 ++++++++----- engine/battle/e.asm | 2 +- engine/evos_moves.asm | 2 +- home.asm | 8 ++++---- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/engine/battle/4_2.asm b/engine/battle/4_2.asm index c5c6279654..b53ea6e48b 100755 --- a/engine/battle/4_2.asm +++ b/engine/battle/4_2.asm @@ -391,7 +391,7 @@ GetTrainerName_: ; 13a58 (4:7a58) ld [wd0b5], a ld a, TRAINER_NAME ld [W_LISTTYPE], a - ld a, $e + ld a, BANK(TrainerNames) ld [wPredefBank], a call GetName ld hl, wcd6d diff --git a/engine/battle/core.asm b/engine/battle/core.asm index b3495a293d..399a8ee758 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -2184,7 +2184,9 @@ asm_3d00e: ; 3d00e (f:500e) jr Func_3d03c OldManItemList: ; 3d02d (f:502d) - db $01, POKE_BALL, 50, $ff + db 1 ; # items + db POKE_BALL, 50 + db -1 Func_3d031 ld hl, wNumBagItems ; wNumBagItems @@ -5471,7 +5473,7 @@ asm_3e70b: ; 3e70b (f:670b) res 6, [hl] ; no longer invulnerable to typcial attacks ld a, [W_ENEMYMOVENUM] ; W_ENEMYMOVENUM ld [wd0b5], a - ld a, $2c + ld a, BANK(MoveNames) ld [wPredefBank], a ld a, MOVE_NAME ld [W_LISTTYPE], a @@ -5950,10 +5952,11 @@ GetCurrentMove: ; 3eabe (f:6abe) call AddNTimes ld a, BANK(Moves) call FarCopyData - ld a, $2c + + ld a, BANK(MoveNames) ld [wPredefBank], a - ld a, $2 - ld [W_LISTTYPE], a ; list type 2 = move name + ld a, MOVE_NAME + ld [W_LISTTYPE], a call GetName ld de, wcd6d jp CopyStringToCF4B diff --git a/engine/battle/e.asm b/engine/battle/e.asm index 8b0476ca98..a0d9d80c02 100755 --- a/engine/battle/e.asm +++ b/engine/battle/e.asm @@ -587,7 +587,7 @@ Func_39b87: ; 39b87 (e:5b87) jr z, .asm_39bc1 push hl ld [wd0b5], a - ld a, $2c + ld a, BANK(MoveNames) ld [wPredefBank], a ld a, MOVE_NAME ld [W_LISTTYPE], a diff --git a/engine/evos_moves.asm b/engine/evos_moves.asm index fd93fa1459..9869153e11 100755 --- a/engine/evos_moves.asm +++ b/engine/evos_moves.asm @@ -135,7 +135,7 @@ Func_3ad71: ; 3ad71 (e:6d71) ld [wHPBarMaxHP + 1], a ld a, MONSTER_NAME ld [W_LISTTYPE], a - ld a, $e + ld a, BANK(TrainerNames) ; bank is not used for monster names ld [wPredefBank], a call GetName push hl diff --git a/home.asm b/home.asm index dc0b0889cb..8c8f5c35f9 100644 --- a/home.asm +++ b/home.asm @@ -2044,7 +2044,7 @@ DisplayListMenuIDLoop:: ; 2c53 (0:2c53) .skipGettingQuantity ld a,[wcf91] ld [wd0b5],a - ld a,$01 + ld a,BANK(ItemNames) ld [wPredefBank],a call GetName jr .storeChosenEntry @@ -3782,7 +3782,7 @@ GetName:: ; 376b (0:376b) ; returns pointer to name in de ld a,[wd0b5] ld [wd11e],a - cp a,$C4 ;it's TM/HM + cp HM_01 jp nc,GetMachineName ld a,[H_LOADEDROMBANK] push af @@ -3858,8 +3858,8 @@ GetItemPrice:: ; 37df (0:37df) ld a, [H_LOADEDROMBANK] push af ld a, [wListMenuID] ; wListMenuID - cp $1 - ld a, $1 ; hardcoded Bank + cp MOVESLISTMENU + ld a, BANK(ItemPrices) jr nz, .asm_37ed ld a, $f ; hardcoded Bank .asm_37ed From 59f0507e4cd0693eb89f5ab3e44cb3c442666140 Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Fri, 8 Aug 2014 22:39:13 -0700 Subject: [PATCH 010/100] Labelled many functions/variables --- engine/HoF_room_pc.asm | 2 +- engine/battle/1.asm | 4 +- engine/battle/14.asm | 10 +- engine/battle/15.asm | 233 +- engine/battle/16.asm | 40 +- engine/battle/1c.asm | 2 +- engine/battle/4_2.asm | 59 +- engine/battle/5.asm | 4 +- engine/battle/animations.asm | 12 +- engine/battle/b_2.asm | 8 +- engine/battle/c.asm | 4 +- engine/battle/core.asm | 3732 +++++++++++++------------- engine/battle/d.asm | 10 +- engine/battle/e.asm | 4 +- engine/battle/e_2.asm | 6 +- engine/battle/safari_zone.asm | 4 +- engine/cable_club.asm | 2 +- engine/evolve_trade.asm | 2 +- engine/evos_moves.asm | 222 +- engine/experience.asm | 22 +- engine/give_pokemon.asm | 2 +- engine/hall_of_fame.asm | 4 +- engine/hidden_object_functions17.asm | 4 +- engine/hidden_object_functions3.asm | 2 +- engine/items/items.asm | 32 +- engine/menu/bills_pc.asm | 4 +- engine/menu/naming_screen.asm | 4 +- engine/menu/party_menu.asm | 2 +- engine/menu/start_sub_menus.asm | 28 +- engine/overworld/cable_club_npc.asm | 6 +- engine/overworld/cut.asm | 6 +- engine/predefs.asm | 8 +- engine/titlescreen.asm | 16 +- engine/trade.asm | 6 +- home.asm | 34 +- home/init.asm | 4 +- home/overworld.asm | 2 +- home/vblank.asm | 6 +- hram.asm | 5 + main.asm | 22 +- scripts/ceruleanhouse2.asm | 2 +- scripts/daycarem.asm | 4 +- scripts/namerater.asm | 2 +- scripts/pokemontower6.asm | 2 +- scripts/route12.asm | 2 +- scripts/route16.asm | 2 +- scripts/vermiliondock.asm | 4 +- text.asm | 2 +- wram.asm | 117 +- 49 files changed, 2479 insertions(+), 2237 deletions(-) diff --git a/engine/HoF_room_pc.asm b/engine/HoF_room_pc.asm index 16a3c3f92e..4eec737702 100755 --- a/engine/HoF_room_pc.asm +++ b/engine/HoF_room_pc.asm @@ -92,7 +92,7 @@ DisplayCreditsMon: ; 740cb (1d:40cb) dec c jr nz,.next2 xor a - ld [$FFB0],a + ld [hVBlankWY],a ld a,$C0 ld [$FF47],a ret diff --git a/engine/battle/1.asm b/engine/battle/1.asm index 045463134f..fdf2841dcc 100755 --- a/engine/battle/1.asm +++ b/engine/battle/1.asm @@ -75,8 +75,8 @@ Func_7861: ; 7861 (1:7861) .asm_78aa ld [wListMenuID], a ; wListMenuID predef UpdateHPBar2 - predef Func_3cd60 - predef Func_3cdec + predef DrawPlayerHUDAndHPBar + predef DrawEnemyHUDAndHPBar callab ReadPlayerMonCurHPAndStatus ld hl, SuckedHealthText ; $78dc ld a, [H_WHOSETURN] ; $fff3 diff --git a/engine/battle/14.asm b/engine/battle/14.asm index 01d115a6f5..01a8f48a2f 100755 --- a/engine/battle/14.asm +++ b/engine/battle/14.asm @@ -3,18 +3,18 @@ Func_525af: ; 525af (14:65af) ld [wd0d4], a xor a ld [wcd6a], a - ld [wcf0b], a + ld [wBattleResult], a ld hl, wcc2b ld [hli], a ld [hli], a ld [hli], a ld [hl], a ld [wListScrollOffset], a ; wcc36 - ld [wd05e], a + ld [wCriticalHitOrOHKO], a ld [wBattleMonSpecies], a - ld [wPartyAliveFlags], a + ld [wPartyGainExpFlags], a ld [wPlayerMonNumber], a ; wPlayerMonNumber - ld [wd078], a + ld [wEscapedFromBattle], a ld [wd35d], a ld hl, wcf1d ld [hli], a @@ -73,7 +73,7 @@ ParalyzeEffect_: ; 52601 (14:6601) and a jr nz, .asm_52659 set 6, [hl] - callab Func_3ed27 + callab QuarterSpeedDueToParalysis ld c, $1e call DelayFrames callab Func_3fba8 diff --git a/engine/battle/15.asm b/engine/battle/15.asm index 69d8ff3f4b..2fb3b108cd 100755 --- a/engine/battle/15.asm +++ b/engine/battle/15.asm @@ -1,63 +1,63 @@ GainExperience: ; 5524f (15:524f) ld a, [W_ISLINKBATTLE] cp $4 - ret z - call Func_5546c - ld hl, wPartyMons + ret z ; return if link battle + call DivideExpDataByNumMonsGainingExp + ld hl, wPartyMon1 xor a ld [wWhichPokemon], a - -Func_5525f: ; 5525f (15:525f) +.partyMonLoop ; loop over each mon and add gained exp inc hl ld a, [hli] - or [hl] - jp z, Func_55436 + or [hl] ; is mon's HP 0? + jp z, .nextMon ; if so, go to next mon push hl - ld hl, wPartyAliveFlags + ld hl, wPartyGainExpFlags ld a, [wWhichPokemon] ld c, a ld b, $2 predef FlagActionPredef ld a, c - and a + and a ; is mon's gain exp flag set? pop hl - jp z, Func_55436 - ld de, $10 + jp z, .nextMon ; if mon's gain exp flag not set, go to next mon + ld de, (wPartyMon1HPExp + 1) - (wPartyMon1HP + 1) add hl, de ld d, h ld e, l - ld hl, wd002 + ld hl, wEnemyMonBaseStats ld c, $5 -.asm_55285 +.gainStatExpLoop ld a, [hli] - ld b, a - ld a, [de] - add b + ld b, a ; enemy mon base stat + ld a, [de] ; stat exp + add b ; add enemy mon base state to stat exp ld [de], a - jr nc, .asm_5529a + jr nc, .nextBaseStat +; if there was a carry, increment the upper byte dec de ld a, [de] inc a - jr z, .asm_55295 + jr z, .maxStatExp ; jump if the value overflowed ld [de], a inc de - jr .asm_5529a -.asm_55295 + jr .nextBaseStat +.maxStatExp ; if the upper byte also overflowed, then we have hit the max stat exp ld a, $ff ld [de], a inc de ld [de], a -.asm_5529a +.nextBaseStat dec c jr z, .asm_552a1 inc de inc de - jr .asm_55285 + jr .gainStatExpLoop .asm_552a1 xor a ld [H_MULTIPLICAND], a ld [H_MULTIPLICAND + 1], a - ld a, [wd008] + ld a, [wEnemyMonBaseExp] ld [H_MULTIPLICAND + 2], a ld a, [wEnemyMonLevel] ld [H_MULTIPLIER], a @@ -66,44 +66,46 @@ Func_5525f: ; 5525f (15:525f) ld [H_DIVISOR], a ld b, 4 call Divide - ld hl, $fff2 + ld hl, -((wPartyMon1HPExp + 1) - wPartyMon1OTID + 4 * 2) add hl, de - ld b, [hl] + ld b, [hl] ; party mon OTID inc hl ld a, [wPlayerID] cp b - jr nz, .asm_552d1 + jr nz, .tradedMon ld b, [hl] ld a, [wPlayerID + 1] cp b ld a, $0 - jr z, .asm_552d6 -.asm_552d1 - call Func_5549f + jr z, .next +.tradedMon + call BoostExp ; traded mon exp boost ld a, $1 -.asm_552d6 +.next ld [wcf4d], a ld a, [W_ISINBATTLE] - dec a - call nz, Func_5549f + dec a ; is it a trainer battle? + call nz, BoostExp ; if so, boost exp inc hl inc hl inc hl +; add the gained exp to the party mon's exp ld b, [hl] - ld a, [$ff98] + ld a, [H_QUOTIENT + 3] ld [wcf4c], a add b ld [hld], a ld b, [hl] - ld a, [$ff97] + ld a, [H_QUOTIENT + 2] ld [wcf4b], a adc b ld [hl], a - jr nc, .asm_552f8 + jr nc, .noCarry dec hl inc [hl] inc hl -.asm_552f8 +.noCarry +; calculate exp for the mon at max level, and cap the exp at that value inc hl push hl ld a, [wWhichPokemon] @@ -111,11 +113,12 @@ Func_5525f: ; 5525f (15:525f) ld b, 0 ld hl, wPartySpecies add hl, bc - ld a, [hl] + ld a, [hl] ; species ld [wd0b5], a call GetMonHeader ld d, MAX_LEVEL - callab CalcExperience + callab CalcExperience ; get max exp +; compare max exp with current exp ld a, [$ff96] ld b, a ld a, [$ff97] @@ -129,7 +132,8 @@ Func_5525f: ; 5525f (15:525f) sbc c ld a, [hl] sbc b - jr c, .asm_5532e + jr c, .next2 +; the mon's exp is greater than the max exp, so overwrite it with the max exp ld a, b ld [hli], a ld a, c @@ -137,103 +141,108 @@ Func_5525f: ; 5525f (15:525f) ld a, d ld [hld], a dec hl -.asm_5532e +.next2 push hl ld a, [wWhichPokemon] ld hl, wPartyMonNicks call GetPartyMonName ld hl, GainedText call PrintText - xor a + xor a ; party mon data ld [wcc49], a call LoadMonData pop hl - ld bc, $13 + ld bc, wPartyMon1Level - wPartyMon1Exp add hl, bc push hl - callba Func_58f43 + callba CalcLevelFromExperience pop hl - ld a, [hl] + ld a, [hl] ; current level cp d - jp z, Func_55436 + jp z, .nextMon ; if level didn't change, go to next mon ld a, [W_CURENEMYLVL] push af push hl ld a, d ld [W_CURENEMYLVL], a ld [hl], a - ld bc, $ffdf + ld bc, wPartyMon1Species - wPartyMon1Level add hl, bc - ld a, [hl] + ld a, [hl] ; species ld [wd0b5], a ld [wd11e], a call GetMonHeader - ld bc, $23 + ld bc, (wPartyMon1MaxHP + 1) - wPartyMon1Species add hl, bc push hl ld a, [hld] ld c, a ld b, [hl] - push bc + push bc ; push max HP (from before levelling up) ld d, h ld e, l - ld bc, $ffee + ld bc, (wPartyMon1HPExp - 1) - wPartyMon1MaxHP add hl, bc - ld b, $1 + ld b, $1 ; consider stat exp when calculating stats call CalcStats - pop bc + pop bc ; pop max HP (from before levelling up) pop hl ld a, [hld] sub c ld c, a ld a, [hl] sbc b - ld b, a - ld de, $ffe0 + ld b, a ; bc = difference between old max HP and new max HP after levelling + ld de, (wPartyMon1HP + 1) - wPartyMon1MaxHP add hl, de - ld a, [hl] +; add to the current HP the amount of max HP gained when levelling + ld a, [hl] ; wPartyMon1HP + 1 add c ld [hld], a - ld a, [hl] + ld a, [hl] ; wPartyMon1HP + 1 adc b - ld [hl], a + ld [hl], a ; wPartyMon1HP ld a, [wPlayerMonNumber] ld b, a ld a, [wWhichPokemon] - cp b - jr nz, .asm_553f7 + cp b ; is the current mon in battle? + jr nz, .printGrewLevelText +; current mon is in battle ld de, wBattleMonHP +; copy party mon HP to battle mon HP ld a, [hli] ld [de], a inc de ld a, [hl] ld [de], a - ld bc, $1f +; copy other stats from party mon to battle mon + ld bc, wPartyMon1Level - (wPartyMon1HP + 1) add hl, bc push hl - ld de, wBattleMonLevel ; wBattleMonLevel - ld bc, $b + ld de, wBattleMonLevel + ld bc, $b ; size of stats call CopyData pop hl - ld a, [W_PLAYERBATTSTATUS3] ; W_PLAYERBATTSTATUS3 - bit 3, a - jr nz, .asm_553c8 + ld a, [W_PLAYERBATTSTATUS3] + bit 3, a ; is the mon transformed? + jr nz, .recalcStatChanges +; the mon is transformed, so copy transformed data ld de, wcd0f ld bc, $b call CopyData -.asm_553c8 +.recalcStatChanges xor a ld [wd11e], a - callab Func_3ed99 - callab Func_3ed1a - callab Func_3ee19 - callab Func_3cd60 - callab Func_3ee94 + callab CalculateModifiedStats + callab ApplyBurnAndParalysisPenaltiesToPlayer + callab ApplyBadgeStatBoosts + callab DrawPlayerHUDAndHPBar + callab PrintEmptyString call SaveScreenTilesToBuffer1 -.asm_553f7 +.printGrewLevelText ld hl, GrewLevelText call PrintText - xor a + xor a ; party mon data ld [wcc49], a call LoadMonData ld d, $1 @@ -244,88 +253,90 @@ Func_5525f: ; 5525f (15:525f) ld [wcc49], a ld a, [wd0b5] ld [wd11e], a - predef Func_3af5b + predef LearnMoveFromLevelUp ld hl, wccd3 - ld a, [wWhichPokemon] ; wWhichPokemon + ld a, [wWhichPokemon] ld c, a ld b, $1 predef FlagActionPredef pop hl pop af - ld [W_CURENEMYLVL], a ; W_CURENEMYLVL + ld [W_CURENEMYLVL], a -Func_55436: ; 55436 (15:5436) - ld a, [wPartyCount] ; wPartyCount +.nextMon + ld a, [wPartyCount] ld b, a - ld a, [wWhichPokemon] ; wWhichPokemon + ld a, [wWhichPokemon] inc a cp b - jr z, .asm_55450 - ld [wWhichPokemon], a ; wWhichPokemon - ld bc, $2c - ld hl, wPartyMon1Species ; wPartyMon1Species (aliases: wPartyMon1) + jr z, .done + ld [wWhichPokemon], a + ld bc, wPartyMon2 - wPartyMon1 + ld hl, wPartyMon1 call AddNTimes - jp Func_5525f -.asm_55450 - ld hl, wPartyAliveFlags + jp .partyMonLoop +.done + ld hl, wPartyGainExpFlags xor a - ld [hl], a - ld a, [wPlayerMonNumber] ; wPlayerMonNumber + ld [hl], a ; clear gain exp flags + ld a, [wPlayerMonNumber] ld c, a ld b, $1 push bc - predef FlagActionPredef - ld hl, wccf5 + predef FlagActionPredef ; set the gain exp flag for the mon that is currently out + ld hl, wPartyFoughtCurrentEnemyFlags xor a ld [hl], a pop bc - predef_jump FlagActionPredef + predef_jump FlagActionPredef ; set the fought current enemy flag for the mon that is currently out -Func_5546c: ; 5546c (15:546c) - ld a, [wPartyAliveFlags] +; divide enemy base stats, catch rate, and base exp by the number of mons gaining exp +DivideExpDataByNumMonsGainingExp: ; 5546c (15:546c) + ld a, [wPartyGainExpFlags] ld b, a xor a ld c, $8 ld d, $0 -.asm_55475 +.countSetBitsLoop ; loop to count set bits in wPartyGainExpFlags xor a srl b adc d ld d, a dec c - jr nz, .asm_55475 + jr nz, .countSetBitsLoop cp $2 - ret c - ld [wd11e], a - ld hl, wd002 + ret c ; return if only one mon is gaining exp + ld [wd11e], a ; store number of mons gaining exp + ld hl, wEnemyMonBaseStats ld c, $7 -.asm_55488 +.divideLoop xor a - ld [H_DIVIDEND], a ; $ff95 (aliases: H_PRODUCT, H_PASTLEADINGZEROES, H_QUOTIENT) + ld [H_DIVIDEND], a ld a, [hl] - ld [H_NUMTOPRINT], a ; $ff96 (aliases: H_MULTIPLICAND) + ld [H_DIVIDEND + 1], a ld a, [wd11e] - ld [H_REMAINDER], a ; $ff99 (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) + ld [H_DIVISOR], a ld b, $2 - call Divide - ld a, [$ff98] + call Divide ; divide value by number of mons gaining exp + ld a, [H_QUOTIENT + 3] ld [hli], a dec c - jr nz, .asm_55488 + jr nz, .divideLoop ret -Func_5549f: ; 5549f (15:549f) - ld a, [$ff97] +; multiplies exp by 1.5 +BoostExp: ; 5549f (15:549f) + ld a, [H_QUOTIENT + 2] ld b, a - ld a, [$ff98] + ld a, [H_QUOTIENT + 3] ld c, a srl b rr c add c - ld [$ff98], a - ld a, [$ff97] + ld [H_QUOTIENT + 3], a + ld a, [H_QUOTIENT + 2] adc b - ld [$ff97], a + ld [H_QUOTIENT + 2], a ret GainedText: ; 554b2 (15:54b2) diff --git a/engine/battle/16.asm b/engine/battle/16.asm index 1500d00365..d1cecbbe5b 100755 --- a/engine/battle/16.asm +++ b/engine/battle/16.asm @@ -38,7 +38,7 @@ PrintBeginningBattleText: ; 58d99 (16:4d99) ld a, b and a jr z, .noSilphScope - callab Func_3eb01 + callab LoadEnemyMonData jr .notPokemonTower .noSilphScope ld hl, EnemyAppearedText @@ -54,7 +54,7 @@ PrintBeginningBattleText: ; 58d99 (16:4d99) call PrintText ld hl, UnveiledGhostText call PrintText - callab Func_3eb01 + callab LoadEnemyMonData callab Func_708ca ld hl, WildMonAppearedText call PrintText @@ -94,25 +94,25 @@ GhostCantBeIDdText: ; 58e54 (16:4e54) TX_FAR _GhostCantBeIDdText db "@" -SendOutMon: ; 58e59 (16:4e59) - ld hl, wEnemyMonHP ; wEnemyMonHP +PrintSendOutMonMessage: ; 58e59 (16:4e59) + ld hl, wEnemyMonHP ld a, [hli] or [hl] ld hl, GoText jr z, .printText xor a - ld [H_NUMTOPRINT], a ; $ff96 (aliases: H_MULTIPLICAND) - ld hl, wEnemyMonHP ; wEnemyMonHP + ld [H_MULTIPLICAND], a + ld hl, wEnemyMonHP ld a, [hli] ld [wcce3], a - ld [$ff97], a + ld [H_MULTIPLICAND + 1], a ld a, [hl] ld [wcce4], a - ld [$ff98], a - ld a, $19 - ld [H_REMAINDER], a ; $ff99 (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) + ld [H_MULTIPLICAND + 2], a + ld a, 25 + ld [H_MULTIPLIER], a call Multiply - ld hl, wEnemyMonMaxHP ; wEnemyMonMaxHP + ld hl, wEnemyMonMaxHP ld a, [hli] ld b, [hl] srl a @@ -121,19 +121,19 @@ SendOutMon: ; 58e59 (16:4e59) rr b ld a, b ld b, $4 - ld [H_REMAINDER], a ; $ff99 (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) + ld [H_DIVISOR], a ; enemy mon max HP divided by 4 call Divide - ld a, [$ff98] - ld hl, GoText - cp $46 + ld a, [H_QUOTIENT + 3] ; a = (enemy mon current HP * 25) / (enemy max HP / 4); this approximates the current percentage of max HP + ld hl, GoText ; 70% or greater + cp 70 jr nc, .printText - ld hl, DoItText - cp $28 + ld hl, DoItText ; 40% - 69% + cp 40 jr nc, .printText - ld hl, GetmText - cp $a + ld hl, GetmText ; 10% - 39% + cp 10 jr nc, .printText - ld hl, EnemysWeakText + ld hl, EnemysWeakText ; 0% - 9% .printText jp PrintText diff --git a/engine/battle/1c.asm b/engine/battle/1c.asm index b3b2400711..3f23a27ca2 100755 --- a/engine/battle/1c.asm +++ b/engine/battle/1c.asm @@ -87,7 +87,7 @@ BattleTransition: ; 7096d (1c:496d) ld [H_AUTOBGTRANSFERENABLED], a call Delay3 xor a - ld [$ffb0], a + ld [hVBlankWY], a dec a ld [wcfcb], a call DelayFrame diff --git a/engine/battle/4_2.asm b/engine/battle/4_2.asm index c5c6279654..bdbf70c5f8 100755 --- a/engine/battle/4_2.asm +++ b/engine/battle/4_2.asm @@ -1,70 +1,71 @@ -Func_137aa: ; 137aa (4:77aa) - ld a, [W_ISLINKBATTLE] ; W_ISLINKBATTLE +EndOfBattle: ; 137aa (4:77aa) + ld a, [W_ISLINKBATTLE] cp $4 - jr nz, .asm_137eb + jr nz, .notLinkBattle +; link battle ld a, [wEnemyMonPartyPos] ld hl, wEnemyMon1Status ld bc, wEnemyMon2 - wEnemyMon1 call AddNTimes - ld a, [wEnemyMonStatus] ; wcfe9 + ld a, [wEnemyMonStatus] ld [hl], a call ClearScreen - callab Func_372d6 - ld a, [wcf0b] + callab DisplayLinkBattleVersusTextBox + ld a, [wBattleResult] cp $1 ld de, YouWinText - jr c, .asm_137de + jr c, .placeWinOrLoseString ld de, YouLoseText - jr z, .asm_137de + jr z, .placeWinOrLoseString ld de, DrawText -.asm_137de +.placeWinOrLoseString hlCoord 6, 8 call PlaceString ld c, $c8 call DelayFrames - jr .asm_1380a -.asm_137eb - ld a, [wcf0b] + jr .evolution +.notLinkBattle + ld a, [wBattleResult] and a - jr nz, .asm_13813 - ld hl, wcce5 + jr nz, .resetVariables + ld hl, wTotalPayDayMoney ld a, [hli] or [hl] inc hl or [hl] - jr z, .asm_1380a - ld de, wPlayerMoney + 2 ; wd349 + jr z, .evolution ; if pay day money is 0, jump + ld de, wPlayerMoney + 2 ld c, $3 predef AddBCDPredef ld hl, PickUpPayDayMoneyText call PrintText -.asm_1380a +.evolution xor a ld [wccd4], a - predef Func_3ad1c -.asm_13813 + predef EvolutionAfterBattle +.resetVariables xor a ld [wd083], a ld [wc02a], a - ld [W_ISINBATTLE], a ; W_ISINBATTLE - ld [W_BATTLETYPE], a ; wd05a - ld [W_MOVEMISSED], a ; W_MOVEMISSED - ld [W_CUROPPONENT], a ; wd059 + ld [W_ISINBATTLE], a + ld [W_BATTLETYPE], a + ld [W_MOVEMISSED], a + ld [W_CUROPPONENT], a ld [wd11f], a - ld [wd120], a - ld [wd078], a + ld [wNumRunAttempts], a + ld [wEscapedFromBattle], a ld hl, wcc2b ld [hli], a ld [hli], a ld [hli], a ld [hl], a - ld [wListScrollOffset], a ; wcc36 + ld [wListScrollOffset], a ld hl, wd060 ld b, $18 -.asm_1383e +.loop ld [hli], a dec b - jr nz, .asm_1383e + jr nz, .loop ld hl, wd72c set 0, [hl] call WaitForSoundToFinish @@ -307,7 +308,7 @@ HazeEffect_: ; 139da (4:79da) ld hl, wcd12 ld de, wBattleMonAttack call Func_13a4a - ld hl, wcd26 + ld hl, wEnemyMonUnmodifiedAttack ld de, wEnemyMonAttack call Func_13a4a ld hl, wEnemyMonStatus diff --git a/engine/battle/5.asm b/engine/battle/5.asm index 6c7a642e3f..82518052a9 100755 --- a/engine/battle/5.asm +++ b/engine/battle/5.asm @@ -53,8 +53,8 @@ SubstituteEffectHandler: ; 17dad (5:7dad) call Bankswitch ;jump to routine depending on animation setting ld hl, SubstituteText call PrintText - ld hl, Func_3cd5a - ld b, BANK(Func_3cd5a) + ld hl, DrawHUDsAndHPBars + ld b, BANK(DrawHUDsAndHPBars) jp Bankswitch .alreadyHasSubstitute ld hl, HasSubstituteText diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm index cc598de4c8..6df682a0ee 100755 --- a/engine/battle/animations.asm +++ b/engine/battle/animations.asm @@ -1962,7 +1962,7 @@ AnimationWavyScreen: ; 79666 (1e:5666) xor a ld [H_AUTOBGTRANSFERENABLED], a ld a, $90 - ld [$ffb0], a + ld [hVBlankWY], a ld d, $80 ld e, $8f ld c, $ff @@ -1984,7 +1984,7 @@ AnimationWavyScreen: ; 79666 (1e:5666) dec c jr nz, .asm_7967f xor a - ld [$ffb0], a + ld [hVBlankWY], a call SaveScreenTilesToBuffer2 call ClearScreen ld a, $1 @@ -2744,11 +2744,11 @@ AnimationShakeEnemyHUD: ; 79d77 (1e:5d77) ld hl, vBGMap0 call Func_79e0d ld a, $90 - ld [$ffb0], a + ld [hVBlankWY], a ld hl, vBGMap0 + $320 call Func_79e0d ld a, $38 - ld [$ffb0], a + ld [hVBlankWY], a call Func_792fd ld hl, vBGMap0 call Func_79e0d @@ -2759,11 +2759,11 @@ AnimationShakeEnemyHUD: ; 79d77 (1e:5d77) call AnimationShowMonPic call ClearSprites ld a, $90 - ld [$ffb0], a + ld [hVBlankWY], a ld hl, vBGMap1 call Func_79e0d xor a - ld [$ffb0], a + ld [hVBlankWY], a call SaveScreenTilesToBuffer1 ld hl, vBGMap0 call Func_79e0d diff --git a/engine/battle/b_2.asm b/engine/battle/b_2.asm index e343f1aafd..4ff8b66b46 100755 --- a/engine/battle/b_2.asm +++ b/engine/battle/b_2.asm @@ -88,10 +88,10 @@ PayDayEffect_ ; 2feb8 (b:7eb8) xor a ld hl, wcd6d ld [hli], a - ld a, [$fff3] + ld a, [H_WHOSETURN] and a ld a, [wBattleMonLevel] - jr z, .asm_2fec8 ; 0x2fec3 $3 + jr z, .asm_2fec8 ld a, [wEnemyMonLevel] .asm_2fec8 add a @@ -118,10 +118,10 @@ PayDayEffect_ ; 2feb8 (b:7eb8) ld a, [$ff99] add b ld [hl], a - ld de, wcce7 + ld de, wTotalPayDayMoney + 2 ld c, $3 predef AddBCDPredef - ld hl, CoinsScatteredText ; $7f04 + ld hl, CoinsScatteredText jp PrintText CoinsScatteredText: ; 2ff04 (b:7f04) diff --git a/engine/battle/c.asm b/engine/battle/c.asm index c1347d24ab..e31b1fce98 100755 --- a/engine/battle/c.asm +++ b/engine/battle/c.asm @@ -26,7 +26,7 @@ OneHitKOEffect_: ; 33f57 (c:7f57) ld [hli], a ld [hl], a ; set the damage output to zero dec a - ld [wd05e], a + ld [wCriticalHitOrOHKO], a ld hl, wBattleMonSpeed + 1 ld de, wEnemyMonSpeed + 1 ld a, [H_WHOSETURN] ; $fff3 @@ -50,7 +50,7 @@ OneHitKOEffect_: ; 33f57 (c:7f57) ld [hli], a ld [hl], a ld a, $2 - ld [wd05e], a + ld [wCriticalHitOrOHKO], a ret .asm_33f8a ld a, $1 diff --git a/engine/battle/core.asm b/engine/battle/core.asm index b3495a293d..4b1ceedd10 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -91,9 +91,9 @@ EffectsArray5B: ; 3c049 (f:4049) db TRAPPING_EFFECT db -1 -Func_3c04c: ; 3c04c (f:404c) - call Func_3ec92 - ld a, $1 +SlidePlayerAndEnemySilhouettesOnScreen: ; 3c04c (f:404c) + call LoadPlayerBackPic + ld a, $1 ; the usual text box at the bottom of the screen ld [wd125], a call DisplayTextBoxID hlCoord 1, 5 @@ -101,82 +101,83 @@ Func_3c04c: ; 3c04c (f:404c) call ClearScreenArea call DisableLCD call LoadFontTilePatterns - call Func_3ee58 + call LoadHudAndHpBarAndStatusTilePatterns ld hl, vBGMap0 ld bc, $400 -.asm_3c06f +.clearBackgroundLoop ld a, $7f ld [hli], a dec bc ld a, b or c - jr nz, .asm_3c06f + jr nz, .clearBackgroundLoop +; copy the work RAM tile map to VRAM ld hl, wTileMap ld de, vBGMap0 - ld b, $12 -.asm_3c07f - ld c, $14 -.asm_3c081 + ld b, 18 ; number of rows +.copyRowLoop + ld c, 20 ; number of columns +.copyColumnLoop ld a, [hli] ld [de], a inc e dec c - jr nz, .asm_3c081 - ld a, $c - add e + jr nz, .copyColumnLoop + ld a, 12 ; number of off screen tiles to the right of screen in VRAM + add e ; skip the off screen tiles ld e, a - jr nc, .asm_3c08e + jr nc, .noCarry inc d -.asm_3c08e +.noCarry dec b - jr nz, .asm_3c07f + jr nz, .copyRowLoop call EnableLCD ld a, $90 - ld [$ffb0], a - ld [rWY], a ; $ff4a + ld [hVBlankWY], a + ld [rWY], a xor a ld [$ffd7], a - ld [$ffaf], a + ld [hVBlankSCY], a dec a ld [wcfcb], a call Delay3 xor a - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba + ld [H_AUTOBGTRANSFERENABLED], a ld b, $70 ld c, $90 ld a, c - ld [$ffae], a + ld [hVBlankSCX], a call DelayFrame - ld a, $e4 - ld [rBGP], a ; $ff47 - ld [rOBP0], a ; $ff48 - ld [rOBP1], a ; $ff49 -.asm_3c0bb + ld a, %11100100 ; inverted palette for silhouette effect + ld [rBGP], a + ld [rOBP0], a + ld [rOBP1], a +.slideSilhouettesLoop ; slide silhouettes of the player's pic and the enemy's pic onto the screen ld h, b ld l, $40 - call Func_3c110 + call SetScrollXForSlidingPlayerBodyLeft ; begin background scrolling on line $40 inc b inc b ld h, $0 ld l, $60 - call Func_3c110 - call Func_3c0ff + call SetScrollXForSlidingPlayerBodyLeft ; end background scrolling on line $60 + call SlidePlayerHeadLeft ld a, c - ld [$ffae], a + ld [hVBlankSCX], a dec c dec c - jr nz, .asm_3c0bb + jr nz, .slideSilhouettesLoop ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba + ld [H_AUTOBGTRANSFERENABLED], a ld a, $31 ld [$ffe1], a hlCoord 1, 5 predef Func_3f0c6 xor a - ld [$ffb0], a - ld [rWY], a ; $ff4a + ld [hVBlankWY], a + ld [rWY], a inc a - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba + ld [H_AUTOBGTRANSFERENABLED], a call Delay3 ld b, $1 call GoPAL_SET @@ -185,160 +186,174 @@ Func_3c04c: ; 3c04c (f:404c) ld b, BANK(PrintBeginningBattleText) jp Bankswitch -Func_3c0ff: ; 3c0ff (f:40ff) +; when a battle is starting, silhouettes of the player's pic and the enemy's pic are slid onto the screen +; the lower of the player's pic (his body) is part of the background, but his head is a sprite +; the reason for this is that it shares Y coordinates with the lower part of the enemy pic, so background scrolling wouldn't work for both pics +; instead, the enemy pic is part of the background and uses the scroll register, while the player's head is a sprite and is slid by changing its X coordinates in a loop +SlidePlayerHeadLeft: ; 3c0ff (f:40ff) push bc ld hl, wOAMBuffer + $01 - ld c, $15 - ld de, $4 -.asm_3c108 - dec [hl] - dec [hl] - add hl, de + ld c, $15 ; number of OAM entries + ld de, $4 ; size of OAM entry +.loop + dec [hl] ; decrement X + dec [hl] ; decrement X + add hl, de ; next OAM entry dec c - jr nz, .asm_3c108 + jr nz, .loop pop bc ret -Func_3c110: ; 3c110 (f:4110) - ld a, [$ff44] +SetScrollXForSlidingPlayerBodyLeft: ; 3c110 (f:4110) + ld a, [rLY] cp l - jr nz, Func_3c110 + jr nz, SetScrollXForSlidingPlayerBodyLeft ld a, h - ld [rSCX], a ; $ff43 -.asm_3c118 - ld a, [$ff44] + ld [rSCX], a +.loop + ld a, [rLY] cp h - jr z, .asm_3c118 + jr z, .loop ret -Func_3c11e: ; 3c11e (f:411e) +StartBattle: ; 3c11e (f:411e) xor a - ld [wPartyAliveFlags], a - ld [wccf5], a + ld [wPartyGainExpFlags], a + ld [wPartyFoughtCurrentEnemyFlags], a ld [wcd6a], a inc a ld [wd11d], a - ld hl, wEnemyMon1HP ; wd8a5 - ld bc, $2b + ld hl, wEnemyMon1HP + ld bc, wEnemyMon2 - wEnemyMon1 - 1 ld d, $3 -.asm_3c134 +.findFirstAliveEnemyMonLoop inc d ld a, [hli] or [hl] - jr nz, .asm_3c13c + jr nz, .foundFirstAliveEnemyMon add hl, bc - jr .asm_3c134 -.asm_3c13c + jr .findFirstAliveEnemyMonLoop +.foundFirstAliveEnemyMon ld a, d ld [wcc3e], a - ld a, [W_ISINBATTLE] ; W_ISINBATTLE - dec a - call nz, Func_3c92a - ld c, $28 + ld a, [W_ISINBATTLE] + dec a ; is it a trainer battle? + call nz, EnemySendOutFirstMon ; if it is a trainer battle, send out enemy mon + ld c, 40 call DelayFrames call SaveScreenTilesToBuffer1 -.asm_3c14f +.checkAnyPartyAlive call AnyPartyAlive ld a, d and a - jp z, HandlePlayerBlackOut + jp z, HandlePlayerBlackOut ; jump if no mon is alive call LoadScreenTilesFromBuffer1 - ld a, [W_BATTLETYPE] ; wd05a - and a - jp z, Func_3c1ad -.asm_3c161 - call InitBattleMenu - ret c + ld a, [W_BATTLETYPE] + and a ; is it a normal battle? + jp z, .playerSendOutFirstMon ; if so, send out player mon +; safari zone battle +.displaySafariZoneBattleMenu + call DisplayBattleMenu + ret c ; return if the player ran from battle ld a, [wcd6a] + and a ; was the item used successfully? + jr z, .displaySafariZoneBattleMenu ; if not, display the menu again; XXX does this ever jump? + ld a, [W_NUMSAFARIBALLS] and a - jr z, .asm_3c161 - ld a, [W_NUMSAFARIBALLS] ; W_NUMSAFARIBALLS - and a - jr nz, .asm_3c17a + jr nz, .notOutOfSafariBalls call LoadScreenTilesFromBuffer1 - ld hl, OutOfSafariBallsText + ld hl, .outOfSafariBallsText jp PrintText -.asm_3c17a +.notOutOfSafariBalls callab PrintSafariZoneBattleText ld a, [wEnemyMonSpeed + 1] add a - ld b, a - jp c, asm_3c202 - ld a, [wcce9] - and a - jr z, .asm_3c194 + ld b, a ; init b (which is later compared with random value) to (enemy speed % 256) * 2 + jp c, EnemyRan ; if (enemy speed % 256) > 127, the enemy runs + ld a, [wSafariBaitFactor] + and a ; is bait factor 0? + jr z, .checkEscapeFactor +; bait factor is not 0 +; divide b by 4 (making the mon less likely to run) srl b srl b -.asm_3c194 - ld a, [wcce8] - and a - jr z, .asm_3c1a0 +.checkEscapeFactor + ld a, [wSafariEscapeFactor] + and a ; is escape factor 0? + jr z, .compareWithRandomValue +; escape factor is not 0 +; multiply b by 2 (making the mon more likely to run) sla b - jr nc, .asm_3c1a0 + jr nc, .compareWithRandomValue +; cap b at 255 ld b, $ff -.asm_3c1a0 +.compareWithRandomValue call Random cp b - jr nc, .asm_3c14f - jr asm_3c202 + jr nc, .checkAnyPartyAlive + jr EnemyRan ; if b was greater than the random value, the enemy runs -OutOfSafariBallsText: ; 3c1a8 (f:41a8) +.outOfSafariBallsText TX_FAR _OutOfSafariBallsText db "@" -Func_3c1ad: ; 3c1ad (f:41ad) +.playerSendOutFirstMon xor a - ld [wWhichPokemon], a ; wWhichPokemon -.asm_3c1b1 - call Func_3ca97 - jr nz, .asm_3c1bc - ld hl, wWhichPokemon ; wWhichPokemon + ld [wWhichPokemon], a +.findFirstAliveMonLoop + call HasMonFainted + jr nz, .foundFirstAliveMon +; fainted, go to the next one + ld hl, wWhichPokemon inc [hl] - jr .asm_3c1b1 -.asm_3c1bc - ld a, [wWhichPokemon] ; wWhichPokemon - ld [wPlayerMonNumber], a ; wPlayerMonNumber + jr .findFirstAliveMonLoop +.foundFirstAliveMon + ld a, [wWhichPokemon] + ld [wPlayerMonNumber], a inc a - ld hl, wPartyCount ; wPartyCount + ld hl, wPartySpecies - 1 ld c, a - ld b, $0 + ld b, 0 add hl, bc - ld a, [hl] + ld a, [hl] ; species ld [wcf91], a ld [wBattleMonSpecies2], a call LoadScreenTilesFromBuffer1 hlCoord 1, 5 ld a, $9 - call Func_3c8df + call SlideTrainerPicOffScreen call SaveScreenTilesToBuffer1 - ld a, [wWhichPokemon] ; wWhichPokemon + ld a, [wWhichPokemon] ld c, a ld b, $1 push bc - ld hl, wPartyAliveFlags + ld hl, wPartyGainExpFlags predef FlagActionPredef - ld hl, wccf5 + ld hl, wPartyFoughtCurrentEnemyFlags pop bc predef FlagActionPredef - call Func_3cba6 + call LoadBattleMonFromParty call LoadScreenTilesFromBuffer1 - call Func_3cc91 + call SendOutMon jr MainInBattleLoop -asm_3c202: ; 3c202 (f:4202) + +; wild mon or link battle enemy ran from battle +EnemyRan: ; 3c202 (f:4202) call LoadScreenTilesFromBuffer1 - ld a, [W_ISLINKBATTLE] ; W_ISLINKBATTLE + ld a, [W_ISLINKBATTLE] cp $4 ld hl, WildRanText - jr nz, .asm_3c216 + jr nz, .printText +; link battle xor a - ld [wcf0b], a + ld [wBattleResult], a ld hl, EnemyRanText -.asm_3c216 +.printText call PrintText ld a, (SFX_08_44 - SFX_Headers_08) / 3 call PlaySoundWaitForCurrent xor a - ld [H_WHOSETURN], a ; $fff3 + ld [H_WHOSETURN], a ld hl, AnimationSlideEnemyMonOut ld b, BANK(AnimationSlideEnemyMonOut) jp Bankswitch @@ -355,116 +370,121 @@ MainInBattleLoop: ; 3c233 (f:4233) call ReadPlayerMonCurHPAndStatus ld hl, wBattleMonHP ld a, [hli] - or [hl] - jp z, HandlePlayerMonFainted ; test if current player mon is fainted + or [hl] ; is battle mon HP 0? + jp z, HandlePlayerMonFainted ; if battle mon HP is 0, jump ld hl, wEnemyMonHP ld a, [hli] - or [hl] - jp z, HandleEnemyMonFainted + or [hl] ; is enemy mon HP 0? + jp z, HandleEnemyMonFainted ; if enemy mon HP is 0, jump call SaveScreenTilesToBuffer1 xor a ld [wd11d], a ld a, [W_PLAYERBATTSTATUS2] - and $60 - jr nz, .asm_3c2a6 ; 0x3c252 $52 + and %01100000 ; check if the player is using Rage or needs to recharge + jr nz, .selectEnemyMove +; the player is not using Rage and doesn't need to recharge ld hl, W_ENEMYBATTSTATUS1 - res 3, [hl] + res 3, [hl] ; reset flinch bit ld hl, W_PLAYERBATTSTATUS1 - res 3, [hl] + res 3, [hl] ; reset flinch bit ld a, [hl] - and $12 - jr nz, .asm_3c2a6 ; 0x3c261 $43 - call InitBattleMenu ; show battle menu - ret c - ld a, [wd078] - and a - ret nz + and %00010010 ; check if the player is thrashing about or charging for an attack + jr nz, .selectEnemyMove ; if so, jump +; the player is neither thrashing about nor charging for an attack + call DisplayBattleMenu ; show battle menu + ret c ; return if player ran from battle + ld a, [wEscapedFromBattle] + and a + ret nz ; return if pokedoll was used to escape from battle ld a, [wBattleMonStatus] - and $27 - jr nz, .asm_3c2a6 ; 0x3c271 $33 + and (1 << FRZ) | SLP ; is mon frozen or asleep? + jr nz, .selectEnemyMove ; if so, jump ld a, [W_PLAYERBATTSTATUS1] - and $21 - jr nz, .asm_3c2a6 ; 0x3c278 $2c + and %00100001 ; check player is using Bide or using a multi-turn attack like wrap + jr nz, .selectEnemyMove ; if so, jump ld a, [W_ENEMYBATTSTATUS1] - bit 5, a - jr z, .asm_3c288 ; 0x3c27f $7 + bit 5, a ; check if enemy is using a multi-turn attack like wrap + jr z, .selectPlayerMove ; if not, jump +; enemy is using a mult-turn attack like wrap, so player is trapped and cannot select a move ld a, $ff ld [wPlayerSelectedMove], a - jr .asm_3c2a6 ; 0x3c286 $1e -.asm_3c288 + jr .selectEnemyMove +.selectPlayerMove ld a, [wcd6a] and a - jr nz, .asm_3c2a6 ; 0x3c28c $18 + jr nz, .selectEnemyMove ld [wMoveMenuType], a inc a ld [W_ANIMATIONID], a xor a - ld [wcc35], a + ld [wMenuItemToSwap], a call MoveSelectionMenu push af call LoadScreenTilesFromBuffer1 - call Func_3cd5a + call DrawHUDsAndHPBars pop af - jr nz, MainInBattleLoop -.asm_3c2a6 + jr nz, MainInBattleLoop ; if the player didn't select a move, jump +.selectEnemyMove call SelectEnemyMove ld a, [W_ISLINKBATTLE] cp $4 jr nz, .noLinkBattle +; link battle ld a, [wcc3e] cp $f - jp z, asm_3c202 + jp z, EnemyRan cp $e jr z, .noLinkBattle cp $d jr z, .noLinkBattle sub $4 jr c, .noLinkBattle +; the link battle enemy has switched mons ld a, [W_PLAYERBATTSTATUS1] - bit 5, a - jr z, .asm_3c2dd ; 0x3c2c9 $12 + bit 5, a ; check if using multi-turn move like Wrap + jr z, .asm_3c2dd ld a, [wPlayerMoveListIndex] ld hl, wBattleMonMoves ld c, a - ld b, $0 + ld b, 0 add hl, bc ld a, [hl] - cp $76 - jr nz, .asm_3c2dd ; 0x3c2d8 $3 + cp METRONOME + jr nz, .asm_3c2dd ld [wPlayerSelectedMove], a .asm_3c2dd - callab Func_3a74b + callab SwitchEnemyMon .noLinkBattle ld a, [wPlayerSelectedMove] cp QUICK_ATTACK jr nz, .playerDidNotUseQuickAttack ld a, [wEnemySelectedMove] cp QUICK_ATTACK - jr z, .compareSpeed ; both used Quick Attack - jp .playerMovesFirst ; player used Quick Attack + jr z, .compareSpeed ; if both used Quick Attack + jp .playerMovesFirst ; if player used Quick Attack and enemy didn't .playerDidNotUseQuickAttack ld a, [wEnemySelectedMove] cp QUICK_ATTACK - jr z, .enemyMovesFirst + jr z, .enemyMovesFirst ; if enemy used Quick Attack and player didn't ld a, [wPlayerSelectedMove] cp COUNTER jr nz, .playerDidNotUseCounter ld a, [wEnemySelectedMove] cp COUNTER - jr z, .compareSpeed ; both used Counter - jr .enemyMovesFirst ; player used Counter + jr z, .compareSpeed ; if both used Counter + jr .enemyMovesFirst ; if player used Counter and enemy didn't .playerDidNotUseCounter ld a, [wEnemySelectedMove] cp COUNTER - jr z, .playerMovesFirst + jr z, .playerMovesFirst ; if enemy used Counter and player didn't .compareSpeed ld de, wBattleMonSpeed ; player speed value ld hl, wEnemyMonSpeed ; enemy speed value ld c, $2 call StringCmp ; compare speed values jr z, .speedEqual - jr nc, .playerMovesFirst - jr .enemyMovesFirst + jr nc, .playerMovesFirst ; if player is faster + jr .enemyMovesFirst ; if enemy is faster .speedEqual ld a, [$ffaa] cp $2 @@ -483,66 +503,66 @@ MainInBattleLoop: ; 3c233 (f:4233) ld [H_WHOSETURN], a callab TrainerAI jr c, .AIActionUsedEnemyFirst - call Func_3e6bc ; execute enemy move - ld a, [wd078] - and a - ret nz + call ExecuteEnemyMove + ld a, [wEscapedFromBattle] + and a ; was Teleport, Road, or Whirlwind used to escape from battle? + ret nz ; if so, return ld a, b and a jp z, HandlePlayerMonFainted .AIActionUsedEnemyFirst call HandlePoisonBurnLeechSeed jp z, HandleEnemyMonFainted - call Func_3cd5a - call Func_3d65e ; execute player move - ld a, [wd078] - and a - ret nz + call DrawHUDsAndHPBars + call ExecutePlayerMove + ld a, [wEscapedFromBattle] + and a ; was Teleport, Road, or Whirlwind used to escape from battle? + ret nz ; if so, return ld a, b and a jp z, HandleEnemyMonFainted call HandlePoisonBurnLeechSeed jp z, HandlePlayerMonFainted - call Func_3cd5a - call Func_3c50f + call DrawHUDsAndHPBars + call CheckNumAttacksLeft jp MainInBattleLoop .playerMovesFirst - call Func_3d65e ; execute player move - ld a, [wd078] - and a - ret nz + call ExecutePlayerMove + ld a, [wEscapedFromBattle] + and a ; was Teleport, Road, or Whirlwind used to escape from battle? + ret nz ; if so, return ld a, b and a jp z, HandleEnemyMonFainted call HandlePoisonBurnLeechSeed jp z, HandlePlayerMonFainted - call Func_3cd5a + call DrawHUDsAndHPBars ld a, $1 ld [H_WHOSETURN], a callab TrainerAI jr c, .AIActionUsedPlayerFirst - call Func_3e6bc ; execute enemy move - ld a, [wd078] - and a - ret nz + call ExecuteEnemyMove + ld a, [wEscapedFromBattle] + and a ; was Teleport, Road, or Whirlwind used to escape from battle? + ret nz ; if so, return ld a, b and a jp z, HandlePlayerMonFainted .AIActionUsedPlayerFirst call HandlePoisonBurnLeechSeed jp z, HandleEnemyMonFainted - call Func_3cd5a - call Func_3c50f + call DrawHUDsAndHPBars + call CheckNumAttacksLeft jp MainInBattleLoop HandlePoisonBurnLeechSeed: ; 3c3bd (f:43bd) - ld hl, wBattleMonHP ; wd015 - ld de, wBattleMonStatus ; wBattleMonStatus - ld a, [H_WHOSETURN] ; $fff3 + ld hl, wBattleMonHP + ld de, wBattleMonStatus + ld a, [H_WHOSETURN] and a jr z, .playersTurn - ld hl, wEnemyMonHP ; wEnemyMonHP - ld de, wEnemyMonStatus ; wcfe9 + ld hl, wEnemyMonHP + ld de, wEnemyMonStatus .playersTurn ld a, [de] and (1 << BRN) | (1 << PSN) @@ -562,26 +582,26 @@ HandlePoisonBurnLeechSeed: ; 3c3bd (f:43bd) pop hl call HandlePoisonBurnLeechSeed_DecreaseOwnHP .notBurnedOrPoisoned - ld de, W_PLAYERBATTSTATUS2 ; W_PLAYERBATTSTATUS2 - ld a, [H_WHOSETURN] ; $fff3 + ld de, W_PLAYERBATTSTATUS2 + ld a, [H_WHOSETURN] and a jr z, .playersTurn2 - ld de, W_ENEMYBATTSTATUS2 ; W_ENEMYBATTSTATUS2 + ld de, W_ENEMYBATTSTATUS2 .playersTurn2 ld a, [de] add a jr nc, .notLeechSeeded push hl - ld a, [H_WHOSETURN] ; $fff3 + ld a, [H_WHOSETURN] push af xor $1 - ld [H_WHOSETURN], a ; $fff3 + ld [H_WHOSETURN], a xor a ld [wcc5b], a ld a,ABSORB call PlayMoveAnimation ; play leech seed animation (from opposing mon) pop af - ld [H_WHOSETURN], a ; $fff3 + ld [H_WHOSETURN], a pop hl call HandlePoisonBurnLeechSeed_DecreaseOwnHP call HandlePoisonBurnLeechSeed_IncreaseEnemyHP @@ -593,7 +613,7 @@ HandlePoisonBurnLeechSeed: ; 3c3bd (f:43bd) ld a, [hli] or [hl] ret nz ; test if fainted - call Func_3cd5a + call DrawHUDsAndHPBars ld c, $14 call DelayFrames xor a @@ -637,13 +657,13 @@ HandlePoisonBurnLeechSeed_DecreaseOwnHP: ; 3c43d (f:443d) jr nz, .nonZeroDamage inc c ; damage is at least 1 .nonZeroDamage - ld hl, W_PLAYERBATTSTATUS3 ; W_PLAYERBATTSTATUS3 - ld de, W_PLAYERTOXICCOUNTER ; wd06c - ld a, [H_WHOSETURN] ; $fff3 + ld hl, W_PLAYERBATTSTATUS3 + ld de, W_PLAYERTOXICCOUNTER + ld a, [H_WHOSETURN] and a jr z, .playersTurn - ld hl, W_ENEMYBATTSTATUS3 ; W_ENEMYBATTSTATUS3 - ld de, W_ENEMYTOXICCOUNTER ; wd071 + ld hl, W_ENEMYBATTSTATUS3 + ld de, W_ENEMYTOXICCOUNTER .playersTurn bit 0, [hl] jr z, .noToxic @@ -684,11 +704,11 @@ HandlePoisonBurnLeechSeed_DecreaseOwnHP: ; 3c43d (f:443d) ; adds bc to enemy HP HandlePoisonBurnLeechSeed_IncreaseEnemyHP: ; 3c4a3 (f:44a3) push hl - ld hl, wEnemyMonMaxHP ; wEnemyMonMaxHP - ld a, [H_WHOSETURN] ; $fff3 + ld hl, wEnemyMonMaxHP + ld a, [H_WHOSETURN] and a jr z, .playersTurn - ld hl, wBattleMonMaxHP ; wd023 + ld hl, wBattleMonMaxHP .playersTurn ld a, [hli] ld [wHPBarMaxHP+1], a @@ -722,19 +742,19 @@ HandlePoisonBurnLeechSeed_IncreaseEnemyHP: ; 3c4a3 (f:44a3) ld [hl], a ld [wHPBarNewHP], a .noOverfullHeal - ld a, [H_WHOSETURN] ; $fff3 + ld a, [H_WHOSETURN] xor $1 - ld [H_WHOSETURN], a ; $fff3 + ld [H_WHOSETURN], a call UpdateCurMonHPBar - ld a, [H_WHOSETURN] ; $fff3 + ld a, [H_WHOSETURN] xor $1 - ld [H_WHOSETURN], a ; $fff3 + ld [H_WHOSETURN], a pop hl ret UpdateCurMonHPBar: ; 3c4f6 (f:44f6) hlCoord 10, 9 ; tile pointer to player HP bar - ld a, [H_WHOSETURN] ; $fff3 + ld a, [H_WHOSETURN] and a ld a, $1 jr z, .playersTurn @@ -742,23 +762,25 @@ UpdateCurMonHPBar: ; 3c4f6 (f:44f6) xor a .playersTurn push bc - ld [wListMenuID], a ; wListMenuID + ld [wListMenuID], a predef UpdateHPBar2 pop bc ret -Func_3c50f: ; 3c50f (f:450f) - ld a, [wd06a] +CheckNumAttacksLeft: ; 3c50f (f:450f) + ld a, [wPlayerNumAttacksLeft] and a - jr nz, .asm_3c51a - ld hl, W_PLAYERBATTSTATUS1 ; W_PLAYERBATTSTATUS1 - res 5, [hl] -.asm_3c51a - ld a, [wd06f] + jr nz, .checkEnemy +; player has 0 attacks left + ld hl, W_PLAYERBATTSTATUS1 + res 5, [hl] ; player not using multi-turn attack like wrap any more +.checkEnemy + ld a, [wEnemyNumAttacksLeft] and a ret nz - ld hl, W_ENEMYBATTSTATUS1 ; W_ENEMYBATTSTATUS1 - res 5, [hl] +; enemy has 0 attacks left + ld hl, W_ENEMYBATTSTATUS1 + res 5, [hl] ; enemy not using multi-turn attack like wrap any more ret HandleEnemyMonFainted: ; 3c525 (f:4525) @@ -768,56 +790,56 @@ HandleEnemyMonFainted: ; 3c525 (f:4525) call AnyPartyAlive ld a, d and a - jp z, HandlePlayerBlackOut - ld hl, wBattleMonHP ; wd015 + jp z, HandlePlayerBlackOut ; if no party mons are alive, the player blacks out + ld hl, wBattleMonHP ld a, [hli] - or [hl] - call nz, Func_3cd60 - ld a, [W_ISINBATTLE] ; W_ISINBATTLE + or [hl] ; is battle mon HP zero? + call nz, DrawPlayerHUDAndHPBar ; if battle mon HP is not zero, draw player HD and HP bar + ld a, [W_ISINBATTLE] dec a - ret z + ret z ; return if it's a wild battle call AnyEnemyPokemonAliveCheck jp z, TrainerBattleVictory - ld hl, wBattleMonHP ; wd015 + ld hl, wBattleMonHP ld a, [hli] - or [hl] - jr nz, .asm_3c555 - call Func_3c79b + or [hl] ; does battle mon have 0 HP? + jr nz, .skipReplacingBattleMon ; if not, skip replacing battle mon + call DoUseNextMonDialogue ; this call is useless in a trainer battle. it shouldn't be here ret c - call Func_3c7d8 -.asm_3c555 + call ChooseNextMon +.skipReplacingBattleMon ld a, $1 ld [wcd6a], a - call Func_3c664 - jp z, asm_3c202 + call ReplaceFaintedEnemyMon + jp z, EnemyRan xor a ld [wcd6a], a jp MainInBattleLoop FaintEnemyPokemon ; 0x3c567 call ReadPlayerMonCurHPAndStatus - ld a, [W_ISINBATTLE] ; W_ISINBATTLE + ld a, [W_ISINBATTLE] dec a jr z, .wild ld a, [wEnemyMonPartyPos] ld hl, wEnemyMon1HP - ld bc, $2c ; mon struct len + ld bc, wEnemyMon2 - wEnemyMon1 call AddNTimes xor a ld [hli], a ld [hl], a .wild - ld hl, W_PLAYERBATTSTATUS1 ; W_PLAYERBATTSTATUS1 + ld hl, W_PLAYERBATTSTATUS1 res 2, [hl] xor a - ld [W_NUMHITS], a ; wd074 + ld [W_NUMHITS], a ld hl, wd065 ; enemy statuses ld [hli], a ld [hli], a ld [hli], a ld [hli], a ld [hl], a - ld [W_ENEMYDISABLEDMOVE], a ; W_ENEMYDISABLEDMOVE + ld [W_ENEMYDISABLEDMOVE], a ld [wccef], a ld [wccf3], a ld hl, wccf1 @@ -825,11 +847,11 @@ FaintEnemyPokemon ; 0x3c567 ld [hl], a hlCoord 12, 5 deCoord 12, 6 - call Func_3c893 + call SlideDownFaintedMonPic ld hl, wTileMap ld bc, $40b call ClearScreenArea - ld a, [W_ISINBATTLE] ; W_ISINBATTLE + ld a, [W_ISINBATTLE] dec a jr z, .wild_win xor a @@ -850,14 +872,14 @@ FaintEnemyPokemon ; 0x3c567 ld a, MUSIC_DEFEATED_WILD_MON call PlayBattleVictoryMusic .sfxplayed - ld hl, wBattleMonHP ; wd015 + ld hl, wBattleMonHP ld a, [hli] or [hl] jr nz, .playermonnotfaint ld a, [wccf0] and a jr nz, .playermonnotfaint - call Func_3c741 + call RemoveFaintedPlayerMon .playermonnotfaint call AnyPartyAlive ld a, d @@ -865,38 +887,50 @@ FaintEnemyPokemon ; 0x3c567 ret z ld hl, EnemyMonFaintedText call PrintText - call Func_3ee94 + call PrintEmptyString call SaveScreenTilesToBuffer1 xor a - ld [wcf0b], a + ld [wBattleResult], a ld b, EXP__ALL call IsItemInBag push af - jr z, .no_exp_all - ld hl, wd002 + jr z, .giveExpToMonsThatFought ; if no exp all, then jump + +; the player has exp all +; first, we halve the values that determine exp gain +; the enemy mon base stats are added to stat exp, so they are halved +; the base exp (which determines normal exp) is also halved + ld hl, wEnemyMonBaseStats ld b, $7 -.exp_all_loop +.halveExpDataLoop srl [hl] inc hl dec b - jr nz, .exp_all_loop -.no_exp_all + jr nz, .halveExpDataLoop + +; give exp (divided evenly) to the mons that actually fought in battle against the enemy mon that has fainted +; if exp all is in the bag, this will be only be half of the stat exp and normal exp, due to the above loop +.giveExpToMonsThatFought xor a ld [wcc5b], a callab GainExperience pop af - ret z + ret z ; return if no exp all + +; the player has exp all +; now, set the gain exp flag for every party member +; half of the total stat exp and normal exp will divided evenly amongst every party member ld a, $1 ld [wcc5b], a - ld a, [wPartyCount] ; wPartyCount - ld b, $0 -.asm_3c62c + ld a, [wPartyCount] + ld b, 0 +.gainExpFlagsLoop scf rl b dec a - jr nz, .asm_3c62c + jr nz, .gainExpFlagsLoop ld a, b - ld [wPartyAliveFlags], a + ld [wPartyGainExpFlags], a ld hl, GainExperience ld b, BANK(GainExperience) jp Bankswitch @@ -914,10 +948,10 @@ Func_3c643: ; 3c643 (f:4643) ret AnyEnemyPokemonAliveCheck: ; 3c64f (f:464f) - ld a, [wEnemyPartyCount] ; wEnemyPartyCount + ld a, [wEnemyPartyCount] ld b, a xor a - ld hl, wEnemyMon1HP ; wd8a5 + ld hl, wEnemyMon1HP ld de, $2c .asm_3c65a or [hl] @@ -930,15 +964,17 @@ AnyEnemyPokemonAliveCheck: ; 3c64f (f:464f) and a ret -Func_3c664: ; 3c664 (f:4664) +; stores whether enemy ran in Z flag +ReplaceFaintedEnemyMon: ; 3c664 (f:4664) ld hl, wcf1e ld e, $30 call GetBattleHealthBarColor callab DrawEnemyPokeballs - ld a, [W_ISLINKBATTLE] ; W_ISLINKBATTLE + ld a, [W_ISLINKBATTLE] cp $4 jr nz, .asm_3c687 - call Func_3d605 +; link battle + call LinkBattleExchangeData ld a, [wcc3e] cp $f ret z @@ -946,34 +982,34 @@ Func_3c664: ; 3c664 (f:4664) .asm_3c687 call EnemySendOut xor a - ld [W_ENEMYMOVENUM], a ; W_ENEMYMOVENUM + ld [W_ENEMYMOVENUM], a ld [wcd6a], a ld [wccd5], a - inc a + inc a ; reset Z flag ret TrainerBattleVictory: ; 3c696 (f:4696) call Func_3c643 ld b, MUSIC_DEFEATED_GYM_LEADER - ld a, [W_GYMLEADERNO] ; W_GYMLEADERNO + ld a, [W_GYMLEADERNO] and a jr nz, .gymleader ld b, MUSIC_DEFEATED_TRAINER .gymleader - ld a, [W_TRAINERCLASS] ; wd031 + ld a, [W_TRAINERCLASS] cp SONY3 ; final battle against rival jr nz, .notrival ld b, MUSIC_DEFEATED_GYM_LEADER ld hl, W_FLAGS_D733 set 1, [hl] .notrival - ld a, [W_ISLINKBATTLE] ; W_ISLINKBATTLE + ld a, [W_ISLINKBATTLE] cp $4 ld a, b call nz, PlayBattleVictoryMusic ld hl, TrainerDefeatedText call PrintText - ld a, [W_ISLINKBATTLE] ; W_ISLINKBATTLE + ld a, [W_ISLINKBATTLE] cp $4 ret z call ScrollTrainerPicAfterBattle @@ -982,7 +1018,7 @@ TrainerBattleVictory: ; 3c696 (f:4696) call Func_3381 ld hl, MoneyForWinningText call PrintText - ld de, wPlayerMoney + 2 ; wd349 + ld de, wPlayerMoney + 2 ld hl, wd07b ld c, $3 predef_jump AddBCDPredef @@ -1008,41 +1044,44 @@ PlayBattleVictoryMusic: ; 3c6ee (f:46ee) HandlePlayerMonFainted: ; 3c700 (f:4700) ld a, $1 ld [wccf0], a - call Func_3c741 + call RemoveFaintedPlayerMon call AnyPartyAlive ; test if any more mons are alive ld a, d and a jp z, HandlePlayerBlackOut - ld hl, wEnemyMonHP ; wEnemyMonHP + ld hl, wEnemyMonHP ld a, [hli] - or [hl] - jr nz, .enemyMonNotFainted + or [hl] ; is enemy mon's HP 0? + jr nz, .doUseNextMonDialogue ; if not, jump +; the enemy mon has 0 HP call FaintEnemyPokemon - ld a, [W_ISINBATTLE] ; W_ISINBATTLE + ld a, [W_ISINBATTLE] dec a ret z ; if wild encounter, battle is over call AnyEnemyPokemonAliveCheck jp z, TrainerBattleVictory -.enemyMonNotFainted - call Func_3c79b - ret c - call Func_3c7d8 - jp nz, MainInBattleLoop +.doUseNextMonDialogue + call DoUseNextMonDialogue + ret c ; return if the player ran from battle + call ChooseNextMon + jp nz, MainInBattleLoop ; if the enemy mon has more than 0 HP, go back to battle loop +; the enemy mon has 0 HP ld a, $1 ld [wcd6a], a - call Func_3c664 - jp z, asm_3c202 + call ReplaceFaintedEnemyMon + jp z, EnemyRan ; if enemy ran from battle rather than sending out another mon, jump xor a ld [wcd6a], a jp MainInBattleLoop -Func_3c741: ; 3c741 (f:4741) - ld a, [wPlayerMonNumber] ; wPlayerMonNumber +; resets flags, slides mon's pic down, plays cry, and prints fainted message +RemoveFaintedPlayerMon: ; 3c741 (f:4741) + ld a, [wPlayerMonNumber] ld c, a - ld hl, wPartyAliveFlags ; clear fainted mon's alive flag + ld hl, wPartyGainExpFlags ld b, $0 - predef FlagActionPredef - ld hl, W_ENEMYBATTSTATUS1 ; W_ENEMYBATTSTATUS1 + predef FlagActionPredef ; clear gain exp flag for fainted mon + ld hl, W_ENEMYBATTSTATUS1 res 2, [hl] ; reset "attacking multiple times" flag ld a, [wd083] bit 7, a ; skip sound flag (red bar (?)) @@ -1054,16 +1093,16 @@ Func_3c741: ; 3c741 (f:4741) ld hl, wcd05 ld [hli], a ld [hl], a - ld [wBattleMonStatus], a ; wBattleMonStatus + ld [wBattleMonStatus], a call ReadPlayerMonCurHPAndStatus hlCoord 9, 7 ld bc, $50b call ClearScreenArea hlCoord 1, 10 deCoord 1, 11 - call Func_3c893 + call SlideDownFaintedMonPic ld a, $1 - ld [wcf0b], a + ld [wBattleResult], a ld a, [wccf0] and a ret z @@ -1076,78 +1115,82 @@ PlayerMonFaintedText: ; 3c796 (f:4796) TX_FAR _PlayerMonFaintedText db "@" -Func_3c79b: ; 3c79b (f:479b) - call Func_3ee94 +; asks if you want to use next mon +; stores whether you ran in C flag +DoUseNextMonDialogue: ; 3c79b (f:479b) + call PrintEmptyString call SaveScreenTilesToBuffer1 - ld a, [W_ISINBATTLE] ; W_ISINBATTLE + ld a, [W_ISINBATTLE] and a dec a - ret nz + ret nz ; return if it's a trainer battle ld hl, UseNextMonText call PrintText -.asm_3c7ad +.displayYesNoBox hlCoord 13, 9 ld bc, $a0e - ld a, $14 + ld a, $14 ; yes/no text box ld [wd125], a call DisplayTextBoxID ld a, [wd12e] - cp $2 - jr z, .asm_3c7c4 - and a + cp $2 ; did the player choose NO? + jr z, .tryRunning ; if the player chose NO, try running + and a ; reset carry ret -.asm_3c7c4 - ld a, [wCurrentMenuItem] ; wCurrentMenuItem +.tryRunning + ld a, [wCurrentMenuItem] and a - jr z, .asm_3c7ad + jr z, .displayYesNoBox ; xxx when does this happen? ld hl, wPartyMon1Speed ld de, wEnemyMonSpeed - jp Func_3cab9 + jp TryRunningFromBattle UseNextMonText: ; 3c7d3 (f:47d3) TX_FAR _UseNextMonText db "@" -Func_3c7d8: ; 3c7d8 (f:47d8) +; choose next player mon to send out +; stores whether enemy mon has no HP left in Z flag +ChooseNextMon: ; 3c7d8 (f:47d8) ld a, $2 ld [wd07d], a call DisplayPartyMenu -.asm_3c7e0 - jr nc, .asm_3c7e7 -.asm_3c7e2 +.checkIfMonChosen + jr nc, .monChosen +.goBackToPartyMenu call GoBackToPartyMenu - jr .asm_3c7e0 -.asm_3c7e7 - call Func_3ca97 - jr z, .asm_3c7e2 - ld a, [W_ISLINKBATTLE] ; W_ISLINKBATTLE + jr .checkIfMonChosen +.monChosen + call HasMonFainted + jr z, .goBackToPartyMenu ; if mon fainted, you have to choose another + ld a, [W_ISLINKBATTLE] cp $4 jr nz, .asm_3c7fa inc a ld [wcd6a], a - call Func_3d605 + call LinkBattleExchangeData .asm_3c7fa xor a ld [wcd6a], a call ClearSprites - ld a, [wWhichPokemon] ; wWhichPokemon - ld [wPlayerMonNumber], a ; wPlayerMonNumber + ld a, [wWhichPokemon] + ld [wPlayerMonNumber], a ld c, a - ld hl, wPartyAliveFlags + ld hl, wPartyGainExpFlags ld b, $1 push bc predef FlagActionPredef pop bc - ld hl, wccf5 + ld hl, wPartyFoughtCurrentEnemyFlags predef FlagActionPredef - call Func_3cba6 + call LoadBattleMonFromParty call GBPalWhiteOut - call Func_3ee5b + call LoadHudTilePatterns call LoadScreenTilesFromBuffer1 call GoPAL_SET_CF1C call GBPalNormal - call Func_3cc91 - ld hl, wEnemyMonHP ; wEnemyMonHP + call SendOutMon + ld hl, wEnemyMonHP ld a, [hli] or [hl] ret @@ -1155,10 +1198,10 @@ Func_3c7d8: ; 3c7d8 (f:47d8) ; called when player is out of usable mons. ; prints approriate lose message, sets carry flag if player blacked out (special case for initial rival fight) HandlePlayerBlackOut: ; 3c837 (f:4837) - ld a, [W_ISLINKBATTLE] ; W_ISLINKBATTLE + ld a, [W_ISLINKBATTLE] cp $4 jr z, .notSony1Battle - ld a, [W_CUROPPONENT] ; wd059 + ld a, [W_CUROPPONENT] cp $c8 + SONY1 jr nz, .notSony1Battle ld hl, wTileMap ; sony 1 battle @@ -1176,7 +1219,7 @@ HandlePlayerBlackOut: ; 3c837 (f:4837) ld b, $0 call GoPAL_SET ld hl, PlayerBlackedOutText2 - ld a, [W_ISLINKBATTLE] ; W_ISLINKBATTLE + ld a, [W_ISLINKBATTLE] cp $4 jr nz, .noLinkBattle ld hl, LinkBattleLostText @@ -1201,18 +1244,20 @@ LinkBattleLostText: ; 3c88e (f:488e) TX_FAR _LinkBattleLostText db "@" -Func_3c893: ; 3c893 (f:4893) +; slides pic of fainted mon downwards until it disappears +; bug: when this is called, [H_AUTOBGTRANSFERENABLED] is non-zero, so there is screen tearing +SlideDownFaintedMonPic: ; 3c893 (f:4893) ld a, [wd730] push af set 6, a ld [wd730], a - ld b, $7 -.asm_3c89e + ld b, 7 ; number of times to slide +.slideStepLoop ; each iteration, the mon is slid down one row push bc push de push hl - ld b, $6 -.asm_3c8a3 + ld b, 6 ; number of rows +.rowLoop push bc push hl push de @@ -1220,7 +1265,7 @@ Func_3c893: ; 3c893 (f:4893) call CopyData pop de pop hl - ld bc, $ffec + ld bc, -20 add hl, bc push hl ld h, d @@ -1231,18 +1276,18 @@ Func_3c893: ; 3c893 (f:4893) pop hl pop bc dec b - jr nz, .asm_3c8a3 - ld bc, $14 + jr nz, .rowLoop + ld bc, 20 add hl, bc ld de, SevenSpacesText call PlaceString - ld c, $2 + ld c, 2 call DelayFrames pop hl pop de pop bc dec b - jr nz, .asm_3c89e + jr nz, .slideStepLoop pop af ld [wd730], a ret @@ -1250,48 +1295,53 @@ Func_3c893: ; 3c893 (f:4893) SevenSpacesText: ; 3c8d7 (f:48d7) db " @" -Func_3c8df: ; 3c8df (f:48df) - ld [H_DOWNARROWBLINKCNT1], a ; $ff8b +; slides the player or enemy trainer off screen +; a is the number of tiles to slide it horizontally (always 9 for the player trainer or 8 for the enemy trainer) +; if a is 8, the slide is to the right, else it is to the left +; bug: when this is called, [H_AUTOBGTRANSFERENABLED] is non-zero, so there is screen tearing +SlideTrainerPicOffScreen: ; 3c8df (f:48df) + ld [$FF8B], a ld c, a -.asm_3c8e2 +.slideStepLoop ; each iteration, the trainer pic is slid one tile left/right push bc push hl - ld b, $7 -.asm_3c8e6 + ld b, 7 ; number of rows +.rowLoop push hl - ld a, [H_DOWNARROWBLINKCNT1] ; $ff8b + ld a, [$FF8B] ld c, a -.asm_3c8ea - ld a, [H_DOWNARROWBLINKCNT1] ; $ff8b - cp $8 - jr z, .asm_3c8f5 +.columnLoop + ld a, [$FF8B] + cp 8 + jr z, .slideRight +.slideLeft ; slide player sprite off screen ld a, [hld] ld [hli], a inc hl - jr .asm_3c8f8 -.asm_3c8f5 + jr .nextColumn +.slideRight ; slide enemy trainer sprite off screen ld a, [hli] ld [hld], a dec hl -.asm_3c8f8 +.nextColumn dec c - jr nz, .asm_3c8ea + jr nz, .columnLoop pop hl - ld de, $14 + ld de, 20 add hl, de dec b - jr nz, .asm_3c8e6 - ld c, $2 + jr nz, .rowLoop + ld c, 2 call DelayFrames pop hl pop bc dec c - jr nz, .asm_3c8e2 + jr nz, .slideStepLoop ret -; XXX this needs cleaning up. it's what runs when a juggler switches pokemon +; send out a trainer's mon EnemySendOut: ; 3c90e (f:490e) - ld hl,wPartyAliveFlags + ld hl,wPartyGainExpFlags xor a ld [hl],a ld a,[wPlayerMonNumber] @@ -1299,12 +1349,14 @@ EnemySendOut: ; 3c90e (f:490e) ld b,1 push bc predef FlagActionPredef - ld hl,wccf5 + ld hl,wPartyFoughtCurrentEnemyFlags xor a ld [hl],a pop bc predef FlagActionPredef -Func_3c92a: ; 3c92a (f:492a) + +; don't change wPartyGainExpFlags or wPartyFoughtCurrentEnemyFlags +EnemySendOutFirstMon: ; 3c92a (f:492a) xor a ld hl,wd065 ld [hli],a @@ -1324,8 +1376,8 @@ Func_3c92a: ; 3c92a (f:492a) res 5,[hl] hlCoord 18, 0 ld a,8 - call Func_3c8df - call Func_3ee94 + call SlideTrainerPicOffScreen + call PrintEmptyString call SaveScreenTilesToBuffer1 ld a,[W_ISLINKBATTLE] cp 4 @@ -1370,7 +1422,7 @@ Func_3c92a: ; 3c92a (f:492a) ld a,[hl] ld [wEnemyMonSpecies2],a ld [wcf91],a - call Func_3eb01 + call LoadEnemyMonData ld hl,wEnemyMonHP ld a,[hli] ld [wcce3],a @@ -1417,13 +1469,13 @@ Func_3c92a: ; 3c92a (f:492a) call GoBackToPartyMenu jr .next9 .next6 - call Func_3ca97 + call HasMonFainted jr z,.next8 xor a ld [wCurrentMenuItem],a .next7 call GBPalWhiteOut - call Func_3ee5b + call LoadHudTilePatterns call LoadScreenTilesFromBuffer1 .next4 call ClearSprites @@ -1447,15 +1499,15 @@ Func_3c92a: ; 3c92a (f:492a) predef Func_3f073 ld a,[wEnemyMonSpecies2] call PlayCry - call Func_3cdec + call DrawEnemyHUDAndHPBar ld a,[wCurrentMenuItem] and a ret nz xor a - ld [wPartyAliveFlags],a - ld [wccf5],a + ld [wPartyGainExpFlags],a + ld [wPartyFoughtCurrentEnemyFlags],a call SaveScreenTilesToBuffer1 - jp Func_3d1ba + jp SwitchPlayerMon TrainerAboutToUseText: ; 3ca79 (f:4a79) TX_FAR _TrainerAboutToUseText @@ -1468,10 +1520,10 @@ TrainerSentOutText: ; 3ca7e (f:4a7e) ; tests if the player has any pokemon that are not fainted ; sets d = 0 if all fainted, d != 0 if some mons are still alive AnyPartyAlive: ; 3ca83 (f:4a83) - ld a, [wPartyCount] ; wPartyCount + ld a, [wPartyCount] ld e, a xor a - ld hl, wPartyMon1HP ; wd16c + ld hl, wPartyMon1HP ld bc, wPartyMon2 - wPartyMon1 - 1 .partyMonsLoop or [hl] @@ -1483,20 +1535,22 @@ AnyPartyAlive: ; 3ca83 (f:4a83) ld d, a ret -Func_3ca97: ; 3ca97 (f:4a97) - ld a, [wWhichPokemon] ; wWhichPokemon - ld hl, wPartyMon1HP ; wd16c - ld bc, $2c +; tests if player mon has fainted +; stores whether mon has fainted in Z flag +HasMonFainted: ; 3ca97 (f:4a97) + ld a, [wWhichPokemon] + ld hl, wPartyMon1HP + ld bc, wPartyMon2 - wPartyMon1 call AddNTimes ld a, [hli] or [hl] ret nz ld a, [wd11d] and a - jr nz, .asm_3cab2 + jr nz, .done ld hl, NoWillText call PrintText -.asm_3cab2 +.done xor a ret @@ -1504,116 +1558,122 @@ NoWillText: ; 3cab4 (f:4ab4) TX_FAR _NoWillText db "@" -Func_3cab9: ; 3cab9 (f:4ab9) +; try to run from battle (hl = player speed, de = enemy speed) +; stores whether the attempt was successful in carry flag +TryRunningFromBattle: ; 3cab9 (f:4ab9) call IsGhostBattle - jp z, .asm_3cb5c - ld a, [W_BATTLETYPE] ; wd05a + jp z, .canEscape ; jump if it's a ghost battle + ld a, [W_BATTLETYPE] cp $2 - jp z, .asm_3cb5c - ld a, [W_ISLINKBATTLE] ; W_ISLINKBATTLE + jp z, .canEscape ; jump if it's a safari battle + ld a, [W_ISLINKBATTLE] cp $4 - jp z, .asm_3cb5c - ld a, [W_ISINBATTLE] ; W_ISINBATTLE + jp z, .canEscape + ld a, [W_ISINBATTLE] dec a - jr nz, .asm_3cb4c - ld a, [wd120] + jr nz, .trainerBattle ; jump if it's a trainer battle + ld a, [wNumRunAttempts] inc a - ld [wd120], a + ld [wNumRunAttempts], a ld a, [hli] - ld [$ff97], a + ld [H_MULTIPLICAND + 1], a ld a, [hl] - ld [$ff98], a + ld [H_MULTIPLICAND + 2], a ld a, [de] ld [$ff8d], a inc de ld a, [de] ld [$ff8e], a call LoadScreenTilesFromBuffer1 - ld de, $ff97 + ld de, H_MULTIPLICAND + 1 ld hl, $ff8d ld c, $2 call StringCmp - jr nc, .asm_3cb5c - xor a - ld [H_NUMTOPRINT], a ; $ff96 (aliases: H_MULTIPLICAND) - ld a, $20 - ld [H_REMAINDER], a ; $ff99 (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) - call Multiply - ld a, [$ff97] - ld [H_DIVIDEND], a ; $ff95 (aliases: H_PRODUCT, H_PASTLEADINGZEROES, H_QUOTIENT) - ld a, [$ff98] - ld [H_NUMTOPRINT], a ; $ff96 (aliases: H_MULTIPLICAND) + jr nc, .canEscape ; jump if player speed greater than enemy speed + xor a + ld [H_MULTIPLICAND], a + ld a, 32 + ld [H_MULTIPLIER], a + call Multiply ; multiply player speed by 32 + ld a, [H_PRODUCT + 2] + ld [H_DIVIDEND], a + ld a, [H_PRODUCT + 3] + ld [H_DIVIDEND + 1], a ld a, [$ff8d] ld b, a ld a, [$ff8e] +; divide enemy speed by 4 srl b rr a srl b rr a and a - jr z, .asm_3cb5c - ld [H_REMAINDER], a ; $ff99 (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) + jr z, .canEscape ; jump if enemy speed divided by 4, mod 256 is 0 + ld [H_DIVISOR], a ; ((enemy speed / 4) % 256) ld b, $2 - call Divide - ld a, [$ff97] - and a - jr nz, .asm_3cb5c - ld a, [wd120] + call Divide ; divide (player speed * 32) by ((enemy speed / 4) % 256) + ld a, [H_QUOTIENT + 2] + and a ; is the quotient greater than 256? + jr nz, .canEscape ; if so, the player can escape + ld a, [wNumRunAttempts] ld c, a -.asm_3cb2b +; add 30 to the quotient for each run attempt +.loop dec c - jr z, .asm_3cb39 - ld b, $1e - ld a, [$ff98] + jr z, .compareWithRandomValue + ld b, 30 + ld a, [H_QUOTIENT + 3] add b - ld [$ff98], a - jr c, .asm_3cb5c - jr .asm_3cb2b -.asm_3cb39 + ld [H_QUOTIENT + 3], a + jr c, .canEscape + jr .loop +.compareWithRandomValue call BattleRandom ld b, a - ld a, [$ff98] + ld a, [H_QUOTIENT + 3] cp b - jr nc, .asm_3cb5c + jr nc, .canEscape ; if the random value was less than or equal to the quotient plus 30 times the number of attempts, the player can escape +; can't escape ld a, $1 ld [wcd6a], a ld hl, CantEscapeText - jr .asm_3cb4f -.asm_3cb4c + jr .printCantEscapeOrNoRunningText +.trainerBattle ld hl, NoRunningText -.asm_3cb4f +.printCantEscapeOrNoRunningText call PrintText ld a, $1 ld [wd11f], a call SaveScreenTilesToBuffer1 - and a + and a ; reset carry ret -.asm_3cb5c - ld a, [W_ISLINKBATTLE] ; W_ISLINKBATTLE +.canEscape + ld a, [W_ISLINKBATTLE] cp $4 ld a, $2 - jr nz, .asm_3cb81 + jr nz, .playSound +; link battle call SaveScreenTilesToBuffer1 xor a ld [wcd6a], a ld a, $f - ld [wPlayerMoveListIndex], a ; wPlayerMoveListIndex - call Func_3d605 + ld [wPlayerMoveListIndex], a + call LinkBattleExchangeData call LoadScreenTilesFromBuffer1 ld a, [wcc3e] cp $f ld a, $2 - jr z, .asm_3cb81 + jr z, .playSound dec a -.asm_3cb81 - ld [wcf0b], a +.playSound + ld [wBattleResult], a ld a, (SFX_08_44 - SFX_Headers_08) / 3 call PlaySoundWaitForCurrent ld hl, GotAwayText call PrintText call WaitForSoundToFinish call SaveScreenTilesToBuffer1 - scf + scf ; set carry ret CantEscapeText: ; 3cb97 (f:4b97) @@ -1628,10 +1688,11 @@ GotAwayText: ; 3cba1 (f:4ba1) TX_FAR _GotAwayText db "@" -Func_3cba6: ; 3cba6 (f:4ba6) - ld a, [wWhichPokemon] ; wWhichPokemon +; copies from party data to battle mon data when sending out a new player mon +LoadBattleMonFromParty: ; 3cba6 (f:4ba6) + ld a, [wWhichPokemon] ld bc, $2c - ld hl, wPartyMon1Species ; wPartyMon1Species (aliases: wPartyMon1) + ld hl, wPartyMon1Species call AddNTimes ld de, wBattleMonSpecies ld bc, $c @@ -1641,40 +1702,41 @@ Func_3cba6: ; 3cba6 (f:4ba6) ld de, wBattleMonDVs ld bc, $2 call CopyData - ld de, wBattleMonPP ; wBattleMonPP + ld de, wBattleMonPP ld bc, $4 call CopyData - ld de, wBattleMonLevel ; wBattleMonLevel + ld de, wBattleMonLevel ld bc, $b call CopyData ld a, [wBattleMonSpecies2] ld [wd0b5], a call GetMonHeader - ld hl, wPartyMonNicks ; wPartyMonNicks - ld a, [wPlayerMonNumber] ; wPlayerMonNumber + ld hl, wPartyMonNicks + ld a, [wPlayerMonNumber] call SkipFixedLengthTextEntries ld de, wBattleMonNick ld bc, $b call CopyData - ld hl, wBattleMonLevel ; wBattleMonLevel - ld de, wcd0f + ld hl, wBattleMonLevel + ld de, wPlayerMonUnmodifiedLevel ; block of memory used for unmodified stats ld bc, $b call CopyData - call Func_3ed1a - call Func_3ee19 - ld a, $7 + call ApplyBurnAndParalysisPenaltiesToPlayer + call ApplyBadgeStatBoosts + ld a, $7 ; default stat modifier ld b, $8 - ld hl, wPlayerMonAttackMod ; wcd1a -.asm_3cc0e + ld hl, wPlayerMonAttackMod +.statModLoop ld [hli], a dec b - jr nz, .asm_3cc0e + jr nz, .statModLoop ret -Func_3cc13: ; 3cc13 (f:4c13) - ld a, [wWhichPokemon] ; wWhichPokemon +; copies from enemy party data to current enemy mon data when sending out a new enemy mon +LoadEnemyMonFromParty: ; 3cc13 (f:4c13) + ld a, [wWhichPokemon] ld bc, $2c - ld hl, wEnemyMons ; wEnemyMon1Species + ld hl, wEnemyMons call AddNTimes ld de, wEnemyMonSpecies ld bc, $c @@ -1684,56 +1746,55 @@ Func_3cc13: ; 3cc13 (f:4c13) ld de, wEnemyMonDVs ld bc, $2 call CopyData - ld de, wEnemyMonPP ; wcffe + ld de, wEnemyMonPP ld bc, $4 call CopyData - ld de, wEnemyMonLevel ; wEnemyMonLevel + ld de, wEnemyMonLevel ld bc, $b call CopyData ld a, [wEnemyMonSpecies] ld [wd0b5], a call GetMonHeader ld hl, wEnemyMonNicks - ld a, [wWhichPokemon] ; wWhichPokemon + ld a, [wWhichPokemon] call SkipFixedLengthTextEntries ld de, wEnemyMonNick ld bc, $b call CopyData - ld hl, wEnemyMonLevel ; wEnemyMonLevel - ld de, wcd23 + ld hl, wEnemyMonLevel + ld de, wEnemyMonUnmodifiedLevel ; block of memory used for unmodified stats ld bc, $b call CopyData - call Func_3ed1e + call ApplyBurnAndParalysisPenaltiesToEnemy ld hl, W_MONHBASESTATS - ld de, wd002 + ld de, wEnemyMonBaseStats ld b, $5 -.asm_3cc79 +.copyBaseStatsLoop ld a, [hli] ld [de], a inc de dec b - jr nz, .asm_3cc79 - ld a, $7 + jr nz, .copyBaseStatsLoop + ld a, $7 ; default stat modifier ld b, $8 - ld hl, wEnemyMonStatMods ; wcd2e -.asm_3cc86 + ld hl, wEnemyMonStatMods +.statModLoop ld [hli], a dec b - jr nz, .asm_3cc86 - ld a, [wWhichPokemon] ; wWhichPokemon + jr nz, .statModLoop + ld a, [wWhichPokemon] ld [wEnemyMonPartyPos], a ret -Func_3cc91: ; 3cc91 (f:4c91) - callab SendOutMon - ld hl, wEnemyMonHP ; wEnemyMonHP +SendOutMon: ; 3cc91 (f:4c91) + callab PrintSendOutMonMessage + ld hl, wEnemyMonHP ld a, [hli] - or [hl] - jp z, Func_3cca4 - call Func_3cdec - -Func_3cca4: ; 3cca4 (f:4ca4) - call Func_3cd60 + or [hl] ; is enemy mon HP zero? + jp z, .skipDrawingEnemyHUDAndHPBar; if HP is zero, skip drawing the HUD and HP bar + call DrawEnemyHUDAndHPBar +.skipDrawingEnemyHUDAndHPBar + call DrawPlayerHUDAndHPBar predef LoadMonBackPic xor a ld [$ffe1], a @@ -1742,7 +1803,7 @@ Func_3cca4: ; 3cca4 (f:4ca4) ld [hl], a ld [wcc5b], a ld [wd05b], a - ld [W_PLAYERMOVENUM], a ; wcfd2 + ld [W_PLAYERMOVENUM], a ld hl, wccf1 ld [hli], a ld [hl], a @@ -1752,25 +1813,26 @@ Func_3cca4: ; 3cca4 (f:4ca4) ld [hli], a ld [hli], a ld [hl], a - ld [W_PLAYERDISABLEDMOVE], a ; W_PLAYERDISABLEDMOVE + ld [W_PLAYERDISABLEDMOVE], a ld [wccee], a ld [wccf7], a ld b, $1 call GoPAL_SET - ld hl, W_ENEMYBATTSTATUS1 ; W_ENEMYBATTSTATUS1 + ld hl, W_ENEMYBATTSTATUS1 res 5, [hl] ld a, $1 - ld [H_WHOSETURN], a ; $fff3 + ld [H_WHOSETURN], a ld a, POOF_ANIM call PlayMoveAnimation hlCoord 4, 11 predef Func_3f073 ld a, [wcf91] call PlayCry - call Func_3ee94 + call PrintEmptyString jp SaveScreenTilesToBuffer1 -Func_3ccfa: ; 3ccfa (f:4cfa) +; show 2 stages of the player getting smaller before disappearing +AnimateRetreatingPlayerMon: ; 3ccfa (f:4cfa) hlCoord 1, 5 ld bc, $707 call ClearScreenArea @@ -1778,47 +1840,46 @@ Func_3ccfa: ; 3ccfa (f:4cfa) ld bc, $505 xor a ld [wcd6c], a - ld [H_DOWNARROWBLINKCNT1], a ; $ff8b + ld [H_DOWNARROWBLINKCNT1], a predef Func_79aba ld c, $4 call DelayFrames - call Func_3cd3a + call .clearScreenArea hlCoord 4, 9 ld bc, $303 ld a, $1 ld [wcd6c], a xor a - ld [H_DOWNARROWBLINKCNT1], a ; $ff8b + ld [H_DOWNARROWBLINKCNT1], a predef Func_79aba call Delay3 - call Func_3cd3a + call .clearScreenArea ld a, $4c Coorda 5, 11 - -Func_3cd3a: ; 3cd3a (f:4d3a) +.clearScreenArea hlCoord 1, 5 ld bc, $707 jp ClearScreenArea ; reads player's current mon's HP into wBattleMonHP ReadPlayerMonCurHPAndStatus: ; 3cd43 (f:4d43) - ld a, [wPlayerMonNumber] ; wPlayerMonNumber - ld hl, wPartyMon1HP ; wd16c + ld a, [wPlayerMonNumber] + ld hl, wPartyMon1HP ld bc, wPartyMon2 - wPartyMon1 call AddNTimes ld d, h ld e, l - ld hl, wBattleMonHP ; wd015 + ld hl, wBattleMonHP ld bc, $4 ; 2 bytes HP, 1 byte unknown (unused?), 1 byte status jp CopyData -Func_3cd5a: ; 3cd5a (f:4d5a) - call Func_3cd60 - jp Func_3cdec +DrawHUDsAndHPBars: ; 3cd5a (f:4d5a) + call DrawPlayerHUDAndHPBar + jp DrawEnemyHUDAndHPBar -Func_3cd60: ; 3cd60 (f:4d60) +DrawPlayerHUDAndHPBar: ; 3cd60 (f:4d60) xor a - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba + ld [H_AUTOBGTRANSFERENABLED], a hlCoord 9, 7 ld bc, $50b call ClearScreenArea @@ -1827,13 +1888,13 @@ Func_3cd60: ; 3cd60 (f:4d60) ld [hl], $73 ld de, wBattleMonNick hlCoord 10, 7 - call Func_3ce9c + call CenterMonName call PlaceString ld hl, wBattleMonSpecies ld de, wcf98 ld bc, $c call CopyData - ld hl, wBattleMonLevel ; wBattleMonLevel + ld hl, wBattleMonLevel ld de, wcfb9 ld bc, $b call CopyData @@ -1851,10 +1912,10 @@ Func_3cd60: ; 3cd60 (f:4d60) hlCoord 10, 9 predef DrawHP ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba + ld [H_AUTOBGTRANSFERENABLED], a ld hl, wcf1d call GetBattleHealthBarColor - ld hl, wBattleMonHP ; wd015 + ld hl, wBattleMonHP ld a, [hli] or [hl] jr z, .asm_3cdd9 @@ -1877,90 +1938,94 @@ Func_3cd60: ; 3cd60 (f:4d60) set 7, [hl] ret -Func_3cdec: ; 3cdec (f:4dec) +DrawEnemyHUDAndHPBar: ; 3cdec (f:4dec) xor a - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba + ld [H_AUTOBGTRANSFERENABLED], a ld hl, wTileMap ld bc, $40c call ClearScreenArea callab PlaceEnemyHUDTiles ld de, wEnemyMonNick hlCoord 1, 0 - call Func_3ce9c + call CenterMonName call PlaceString hlCoord 4, 1 push hl inc hl - ld de, wEnemyMonStatus ; wcfe9 + ld de, wEnemyMonStatus call PrintStatusConditionNotFainted pop hl - jr nz, .asm_3ce23 - ld a, [wEnemyMonLevel] ; wEnemyMonLevel + jr nz, .skipPrintLevel ; if the mon has a status condition, skip printing the level + ld a, [wEnemyMonLevel] ld [wcfb9], a call PrintLevel -.asm_3ce23 - ld hl, wEnemyMonHP ; wEnemyMonHP +.skipPrintLevel + ld hl, wEnemyMonHP ld a, [hli] - ld [$ff97], a + ld [H_MULTIPLICAND + 1], a ld a, [hld] - ld [$ff98], a - or [hl] - jr nz, .asm_3ce36 + ld [H_MULTIPLICAND + 2], a + or [hl] ; is current HP zero? + jr nz, .hpNonzero +; current HP is 0 +; set variables for DrawHPBar ld c, a ld e, a ld d, $6 - jp Func_3ce7f -.asm_3ce36 - xor a - ld [H_NUMTOPRINT], a ; $ff96 (aliases: H_MULTIPLICAND) - ld a, $30 - ld [H_REMAINDER], a ; $ff99 (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) - call Multiply - ld hl, wEnemyMonMaxHP ; wEnemyMonMaxHP + jp .drawHPBar +.hpNonzero + xor a + ld [H_MULTIPLICAND], a + ld a, 48 + ld [H_MULTIPLIER], a + call Multiply ; multiply current HP by 48 + ld hl, wEnemyMonMaxHP ld a, [hli] ld b, a ld a, [hl] - ld [H_REMAINDER], a ; $ff99 (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) + ld [H_DIVISOR], a ld a, b - and a - jr z, .asm_3ce6a - ld a, [H_REMAINDER] ; $ff99 (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) + and a ; is max HP > 255? + jr z, .doDivide +; if max HP > 255, scale both (current HP * 48) and max HP by dividing by 4 so that max HP fits in one byte +; (it needs to be one byte so it can be used as the divisor for the Divide function) + ld a, [H_DIVISOR] srl b rr a srl b rr a - ld [H_REMAINDER], a ; $ff99 (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) - ld a, [$ff97] + ld [H_DIVISOR], a + ld a, [H_PRODUCT + 2] ld b, a srl b - ld a, [$ff98] + ld a, [H_PRODUCT + 3] rr a srl b rr a - ld [$ff98], a + ld [H_PRODUCT + 3], a ld a, b - ld [$ff97], a -.asm_3ce6a - ld a, [$ff97] - ld [H_DIVIDEND], a ; $ff95 (aliases: H_PRODUCT, H_PASTLEADINGZEROES, H_QUOTIENT) - ld a, [$ff98] - ld [H_NUMTOPRINT], a ; $ff96 (aliases: H_MULTIPLICAND) + ld [H_PRODUCT + 2], a +.doDivide + ld a, [H_PRODUCT + 2] + ld [H_DIVIDEND], a + ld a, [H_PRODUCT + 3] + ld [H_DIVIDEND + 1], a ld a, $2 ld b, a - call Divide - ld a, [$ff98] + call Divide ; divide (current HP * 48) by max HP + ld a, [H_QUOTIENT + 3] +; set variables for DrawHPBar ld e, a ld a, $6 ld d, a ld c, a - -Func_3ce7f: ; 3ce7f (f:4e7f) +.drawHPBar xor a - ld [wListMenuID], a ; wListMenuID + ld [wListMenuID], a hlCoord 2, 2 call DrawHPBar ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba + ld [H_AUTOBGTRANSFERENABLED], a ld hl, wcf1e GetBattleHealthBarColor: ; 3ce90 (f:4e90) @@ -1972,37 +2037,40 @@ GetBattleHealthBarColor: ; 3ce90 (f:4e90) ld b, $1 jp GoPAL_SET -Func_3ce9c: ; 3ce9c (f:4e9c) +; center's mon's name on the battle screen +; if the name is 1 or 2 letters long, it is printed 2 spaces more to the right than usual (i.e. for names longer than 4 letters) +; if the name is 3 or 4 letters long, it is printed 1 space more to the right than usual (i.e. for names longer than 4 letters) +CenterMonName: ; 3ce9c (f:4e9c) push de inc hl inc hl ld b, $2 -.asm_3cea1 +.loop inc de ld a, [de] cp $50 - jr z, .asm_3ceb1 + jr z, .done inc de ld a, [de] cp $50 - jr z, .asm_3ceb1 + jr z, .done dec hl dec b - jr nz, .asm_3cea1 -.asm_3ceb1 + jr nz, .loop +.done pop de ret -InitBattleMenu: ; 3ceb3 (f:4eb3) +DisplayBattleMenu: ; 3ceb3 (f:4eb3) call LoadScreenTilesFromBuffer1 ; restore saved screen - ld a, [W_BATTLETYPE] ; wd05a + ld a, [W_BATTLETYPE] and a jr nz, .nonstandardbattle - call Func_3cd5a ; redraw names and HP bars? - call Func_3ee94 + call DrawHUDsAndHPBars + call PrintEmptyString call SaveScreenTilesToBuffer1 .nonstandardbattle - ld a, [W_BATTLETYPE] ; wd05a + ld a, [W_BATTLETYPE] cp $2 ; safari ld a, $b ; safari menu id jr nz, .menuselected @@ -2010,20 +2078,20 @@ InitBattleMenu: ; 3ceb3 (f:4eb3) .menuselected ld [wd125], a call DisplayTextBoxID - ld a, [W_BATTLETYPE] ; wd05a + ld a, [W_BATTLETYPE] dec a - jp nz, RegularBattleMenu ; regular battle - ; the following happens for the old man tutorial - ld hl, wPlayerName ; wd158 - ld de, W_GRASSRATE ; W_GRASSRATE + jp nz, .handleBattleMenuInput ; handle menu input if it's not the old man tutorial +; the following happens for the old man tutorial + ld hl, wPlayerName + ld de, W_GRASSRATE ld bc, $b call CopyData ; temporarily save the player name in unused space, ; which is supposed to get overwritten when entering a ; map with wild pokémon. due to an oversight, the data ; may not get overwritten (cinnabar) and the infamous ; missingno. glitch can show up. - ld hl, OldManName ; $4f12 - ld de, wPlayerName ; wd158 + ld hl, .oldManName + ld de, wPlayerName ld bc, $b call CopyData ; the following simulates the keystrokes by drawing menus on screen @@ -2037,176 +2105,183 @@ InitBattleMenu: ; 3ceb3 (f:4eb3) ld c, $32 call DelayFrames ld [hl], $ec - ld a, $2 - jp Func_3cfe8 - -OldManName: ; 3cf12 (f:4f12) + ld a, $2 ; select the "ITEM" menu + jp .upperLeftMenuItemWasNotSelected +.oldManName db "OLD MAN@" - -RegularBattleMenu: ; 3cf1a (f:4f1a) +.handleBattleMenuInput ld a, [wcc2d] - ld [wCurrentMenuItem], a ; wCurrentMenuItem - ld [wLastMenuItem], a ; wLastMenuItem - sub $2 - jr c, .leftcolumn - ld [wCurrentMenuItem], a ; wCurrentMenuItem - ld [wLastMenuItem], a ; wLastMenuItem - jr .rightcolumn -.leftcolumn - ld a, [W_BATTLETYPE] ; wd05a + ld [wCurrentMenuItem], a + ld [wLastMenuItem], a + sub 2 ; check if the cursor is in the left column + jr c, .leftColumn +; cursor is in the right column + ld [wCurrentMenuItem], a + ld [wLastMenuItem], a + jr .rightColumn +.leftColumn ; put cursor in left column of menu + ld a, [W_BATTLETYPE] cp $2 ld a, " " - jr z, .safaribattle - Coorda 15, 14 - Coorda 15, 16 - ld b, $9 - jr .notsafari -.safaribattle + jr z, .safariLeftColumn +; put cursor in left column for normal battle menu (i.e. when it's not a Safari battle) + Coorda 15, 14 ; clear upper cursor position in right column + Coorda 15, 16 ; clear lower cursor position in right column + ld b, $9 ; top menu item X + jr .leftColumn_WaitForInput +.safariLeftColumn Coorda 13, 14 Coorda 13, 16 hlCoord 7, 14 - ld de, W_NUMSAFARIBALLS ; W_NUMSAFARIBALLS + ld de, W_NUMSAFARIBALLS ld bc, $102 call PrintNumber - ld b, $1 -.notsafari - ld hl, wTopMenuItemY ; wTopMenuItemY + ld b, $1 ; top menu item X +.leftColumn_WaitForInput + ld hl, wTopMenuItemY ld a, $e - ld [hli], a + ld [hli], a ; wTopMenuItemY ld a, b - ld [hli], a + ld [hli], a ; wTopMenuItemX inc hl inc hl ld a, $1 - ld [hli], a - ld [hl], $11 + ld [hli], a ; wMaxMenuItem + ld [hl], D_RIGHT | A_BUTTON ; wMenuWatchedKeys call HandleMenuInput - bit 4, a - jr nz, .rightcolumn - jr .selection -.rightcolumn - ld a, [W_BATTLETYPE] ; wd05a + bit 4, a ; check if right was pressed + jr nz, .rightColumn + jr .AButtonPressed ; the A button was pressed +.rightColumn ; put cursor in right column of menu + ld a, [W_BATTLETYPE] cp $2 ld a, " " - jr z, .safarirightcolumn - Coorda 9, 14 - Coorda 9, 16 - ld b, $f - jr .notsafarirightcolumn -.safarirightcolumn - Coorda 1, 14 - Coorda 1, 16 + jr z, .safariRightColumn +; put cursor in right column for normal battle menu (i.e. when it's not a Safari battle) + Coorda 9, 14 ; clear upper cursor position in left column + Coorda 9, 16 ; clear lower cursor position in left column + ld b, $f ; top menu item X + jr .rightColumn_WaitForInput +.safariRightColumn + Coorda 1, 14 ; clear upper cursor position in left column + Coorda 1, 16 ; clear lower cursor position in left column hlCoord 7, 14 - ld de, W_NUMSAFARIBALLS ; W_NUMSAFARIBALLS + ld de, W_NUMSAFARIBALLS ld bc, $102 call PrintNumber - ld b, $d -.notsafarirightcolumn - ld hl, wTopMenuItemY ; wTopMenuItemY + ld b, $d ; top menu item X +.rightColumn_WaitForInput + ld hl, wTopMenuItemY ld a, $e - ld [hli], a + ld [hli], a ; wTopMenuItemY ld a, b - ld [hli], a + ld [hli], a ; wTopMenuItemX inc hl inc hl ld a, $1 - ld [hli], a - ld a, $21 - ld [hli], a + ld [hli], a ; wMaxMenuItem + ld a, D_LEFT | A_BUTTON + ld [hli], a ; wMenuWatchedKeys call HandleMenuInput - bit 5, a - jr nz, .leftcolumn - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + bit 5, a ; check if left was pressed + jr nz, .leftColumn ; if left was pressed, jump + ld a, [wCurrentMenuItem] add $2 ; if we're in the right column, the actual id is +2 - ld [wCurrentMenuItem], a ; wCurrentMenuItem -.selection + ld [wCurrentMenuItem], a +.AButtonPressed call PlaceUnfilledArrowMenuCursor - ld a, [W_BATTLETYPE] ; wd05a - cp $2 - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + ld a, [W_BATTLETYPE] + cp $2 ; is it a Safari battle? + ld a, [wCurrentMenuItem] ld [wcc2d], a - jr z, .asm_3cfd0 - cp $1 - jr nz, .asm_3cfcb - inc a - jr .asm_3cfd0 -.asm_3cfcb - cp $2 ; what - jr nz, .asm_3cfd0 - dec a -.asm_3cfd0 - and a - jr nz, Func_3cfe8 - ; first option was selected... - ld a, [W_BATTLETYPE] ; wd05a + jr z, .handleMenuSelection +; not Safari battle +; swap the IDs of the item menu and party menu (this is probably because they swapped the positions of these menu items in first generation English versions) + cp $1 ; was the item menu selected? + jr nz, .notItemMenu +; item menu was selected + inc a ; increment a to 2 + jr .handleMenuSelection +.notItemMenu + cp $2 ; was the party menu selected? + jr nz, .handleMenuSelection +; party menu selected + dec a ; decrement a to 1 +.handleMenuSelection + and a + jr nz, .upperLeftMenuItemWasNotSelected +; the upper left menu item was selected + ld a, [W_BATTLETYPE] cp $2 - jr z, .safari1 + jr z, .throwSafariBallWasSelected +; the "FIGHT" menu was selected xor a - ld [wd120], a - jp LoadScreenTilesFromBuffer1 ; restore saved screen and return?? -.safari1 ; safari first option?? + ld [wNumRunAttempts], a + jp LoadScreenTilesFromBuffer1 ; restore saved screen and return +.throwSafariBallWasSelected ld a, SAFARI_BALL ld [wcf91], a - jr asm_3d05f - -Func_3cfe8: ; 3cfe8 (f:4fe8) + jr .useItem +.upperLeftMenuItemWasNotSelected ; a menu item other than the upper left item was selected cp $2 - jp nz, Func_3d0ca - ld a, [W_ISLINKBATTLE] ; W_ISLINKBATTLE + jp nz, .partyMenuOrRockOrRunWasSelected +; either the bag (normal battle) or bait (safari battle) was selected + ld a, [W_ISLINKBATTLE] cp $4 - jr nz, .asm_3cffd - ld hl, ItemsCantBeUsedHereText + jr nz, .notLinkBattle +; can't use items in link battles + ld hl, .itemsCantBeUsedHereText call PrintText - jp InitBattleMenu -.asm_3cffd ; bag? - call SaveScreenTilesToBuffer2 ; copy bg? - ld a, [W_BATTLETYPE] ; wd05a - cp $2 - jr nz, asm_3d00e + jp DisplayBattleMenu +.notLinkBattle + call SaveScreenTilesToBuffer2 + ld a, [W_BATTLETYPE] + cp $2 ; is it a safari battle? + jr nz, .bagWasSelected +; bait was selected ld a, SAFARI_BAIT ld [wcf91], a - jr asm_3d05f -asm_3d00e: ; 3d00e (f:500e) + jr .useItem +.bagWasSelected call LoadScreenTilesFromBuffer1 - ld a, [W_BATTLETYPE] ; wd05a - and a - jr nz, .asm_3d01a - call Func_3cd5a -.asm_3d01a - ld a, [W_BATTLETYPE] ; wd05a - dec a - jr nz, Func_3d031 - ld hl, OldManItemList + ld a, [W_BATTLETYPE] + and a ; is it a normal battle? + jr nz, .next +; normal battle + call DrawHUDsAndHPBars +.next + ld a, [W_BATTLETYPE] + dec a ; is it the old man tutorial? + jr nz, .getPlayerBagPointer ; no, it is a normal battle + ld hl, .oldManItemList ld a, l ld [wcf8b], a ld a, h ld [wcf8c], a - jr Func_3d03c - -OldManItemList: ; 3d02d (f:502d) + jr .displayBagMenu +.oldManItemList db $01, POKE_BALL, 50, $ff - -Func_3d031 - ld hl, wNumBagItems ; wNumBagItems +.getPlayerBagPointer ; get the pointer to player's bag when in a normal battle + ld hl, wNumBagItems ld a, l ld [wcf8b], a ld a, h ld [wcf8c], a -Func_3d03c +.displayBagMenu xor a ld [wcf93], a - ld a, $3 - ld [wListMenuID], a ; wListMenuID + ld a, ITEMLISTMENU + ld [wListMenuID], a ld a, [wcc2c] - ld [wCurrentMenuItem], a ; wCurrentMenuItem + ld [wCurrentMenuItem], a call DisplayListMenuID - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + ld a, [wCurrentMenuItem] ld [wcc2c], a ld a, $0 ld [wcc37], a - ld [wcc35], a - jp c, InitBattleMenu -asm_3d05f: ; 3d05f (f:505f) + ld [wMenuItemToSwap], a + jp c, DisplayBattleMenu ; go back to battle menu if an item was not selected +.useItem ; either use an item from the bag or use a safari zone item ld a, [wcf91] ld [wd11e], a call GetItemName @@ -2214,80 +2289,81 @@ asm_3d05f: ; 3d05f (f:505f) xor a ld [wd152], a call UseItem - call Func_3ee5b + call LoadHudTilePatterns call ClearSprites xor a - ld [wCurrentMenuItem], a ; wCurrentMenuItem - ld a, [W_BATTLETYPE] ; wd05a - cp $2 - jr z, .asm_3d09c + ld [wCurrentMenuItem], a + ld a, [W_BATTLETYPE] + cp $2 ; is it a safari battle? + jr z, .checkIfMonCaptured ld a, [wcd6a] - and a - jp z, asm_3d00e - ld a, [W_PLAYERBATTSTATUS1] ; W_PLAYERBATTSTATUS1 - bit 5, a - jr z, .asm_3d09c - ld hl, wd06a + and a ; was the item used successfully? + jp z, .bagWasSelected ; if not, go back to the bag menu + ld a, [W_PLAYERBATTSTATUS1] + bit 5, a ; is the player using a multi-turn move like wrap? + jr z, .checkIfMonCaptured + ld hl, wPlayerNumAttacksLeft dec [hl] - jr nz, .asm_3d09c - ld hl, W_PLAYERBATTSTATUS1 ; W_PLAYERBATTSTATUS1 - res 5, [hl] -.asm_3d09c + jr nz, .checkIfMonCaptured + ld hl, W_PLAYERBATTSTATUS1 + res 5, [hl] ; not using multi-turn move any more +.checkIfMonCaptured ld a, [wd11c] - and a - jr nz, .asm_3d0b7 - ld a, [W_BATTLETYPE] ; wd05a - cp $2 - jr z, .asm_3d0b2 + and a ; was the enemy mon captured with a ball? + jr nz, .returnAfterCapturingMon + ld a, [W_BATTLETYPE] + cp $2 ; is it a safari battle? + jr z, .returnAfterUsingItem_NoCapture +; not a safari battle call LoadScreenTilesFromBuffer1 - call Func_3cd5a ; redraw name and hp bar? + call DrawHUDsAndHPBars call Delay3 -.asm_3d0b2 +.returnAfterUsingItem_NoCapture call GBPalNormal - and a + and a ; reset carry ret -.asm_3d0b7 +.returnAfterCapturingMon call GBPalNormal xor a ld [wd11c], a ld a, $2 - ld [wcf0b], a - scf + ld [wBattleResult], a + scf ; set carry ret -ItemsCantBeUsedHereText: ; 3d0c5 (f:50c5) +.itemsCantBeUsedHereText TX_FAR _ItemsCantBeUsedHereText db "@" -Func_3d0ca: ; 3d0ca (f:50ca) - dec a - jp nz, Func_3d1fa +.partyMenuOrRockOrRunWasSelected + dec a ; was Run selected? + jp nz, BattleMenu_RunWasSelected +; party menu or rock was selected call SaveScreenTilesToBuffer2 - ld a, [W_BATTLETYPE] ; wd05a - cp $2 - jr nz, Func_3d0e0 + ld a, [W_BATTLETYPE] + cp $2 ; is it a safari battle? + jr nz, .partyMenuWasSelected +; safari battle ld a, SAFARI_ROCK ld [wcf91], a - jp asm_3d05f - -Func_3d0e0: ; 3d0e0 (f:50e0) + jp .useItem +.partyMenuWasSelected call LoadScreenTilesFromBuffer1 xor a ld [wd07d], a - ld [wcc35], a + ld [wMenuItemToSwap], a call DisplayPartyMenu -asm_3d0ed: ; 3d0ed (f:50ed) - jp nc, Func_3d119 -asm_3d0f0: ; 3d0f0 (f:50f0) +.checkIfPartyMonWasSelected + jp nc, .partyMonWasSelected ; if a party mon was selected, jump, else we quit the party menu +.quitPartyMenu call ClearSprites call GBPalWhiteOut - call Func_3ee5b + call LoadHudTilePatterns call LoadScreenTilesFromBuffer2 call GoPAL_SET_CF1C call GBPalNormal - jp InitBattleMenu - -Func_3d105: ; 3d105 (f:5105) + jp DisplayBattleMenu +.partyMonDeselected hlCoord 11, 11 ld bc, $81 ld a, $7f @@ -2295,101 +2371,108 @@ Func_3d105: ; 3d105 (f:5105) xor a ld [wd07d], a call GoBackToPartyMenu - jr asm_3d0ed - -Func_3d119: ; 3d119 (f:5119) - ld a, $c + jr .checkIfPartyMonWasSelected +.partyMonWasSelected + ld a, $c ; switch/stats/cancel menu ld [wd125], a call DisplayTextBoxID - ld hl, wTopMenuItemY ; wTopMenuItemY + ld hl, wTopMenuItemY ld a, $c - ld [hli], a - ld [hli], a + ld [hli], a ; wTopMenuItemY + ld [hli], a ; wTopMenuItemX xor a - ld [hli], a + ld [hli], a ; wCurrentMenuItem inc hl ld a, $2 - ld [hli], a - ld a, $3 - ld [hli], a + ld [hli], a ; wMaxMenuItem + ld a, B_BUTTON | A_BUTTON + ld [hli], a ; wMenuWatchedKeys xor a - ld [hl], a + ld [hl], a ; wLastMenuItem call HandleMenuInput - bit 1, a - jr nz, Func_3d105 + bit 1, a ; was A pressed? + jr nz, .partyMonDeselected ; if B was pressed, jump +; A was pressed call PlaceUnfilledArrowMenuCursor - ld a, [wCurrentMenuItem] ; wCurrentMenuItem - cp $2 - jr z, asm_3d0f0 - and a - jr z, .asm_3d18a + ld a, [wCurrentMenuItem] + cp $2 ; was Cancel selected? + jr z, .quitPartyMenu ; if so, quit the party menu entirely + and a ; was Switch selected? + jr z, .switchMon ; if so, jump +; Stats was selected xor a ld [wcc49], a - ld hl, wPartyMon1Species ; wPartyMon1Species (aliases: wPartyMon1) + ld hl, wPartyMon1 call ClearSprites +; display the two status screens predef StatusScreen predef StatusScreen2 - ld a, [W_ENEMYBATTSTATUS2] ; W_ENEMYBATTSTATUS2 - bit 4, a +; now we need to reload the enemy mon pic + ld a, [W_ENEMYBATTSTATUS2] + bit 4, a ; does the enemy mon have a substitute? ld hl, AnimationSubstitute - jr nz, .asm_3d182 + jr nz, .doEnemyMonAnimation +; enemy mon doesn't have substitute ld a, [wccf3] - and a + and a ; has the enemy mon used Minimise? ld hl, AnimationMinimizeMon - jr nz, .asm_3d182 + jr nz, .doEnemyMonAnimation +; enemy mon is not minimised ld a, [wEnemyMonSpecies] ld [wcf91], a ld [wd0b5], a call GetMonHeader ld de, vFrontPic call LoadMonFrontSprite - jr .asm_3d187 -.asm_3d182 + jr .enemyMonPicReloaded +.doEnemyMonAnimation ld b, BANK(AnimationSubstitute) ; BANK(AnimationMinimizeMon) call Bankswitch -.asm_3d187 - jp Func_3d0e0 -.asm_3d18a - ld a, [wPlayerMonNumber] ; wPlayerMonNumber +.enemyMonPicReloaded ; enemy mon pic has been reloaded, so return to the party menu + jp .partyMenuWasSelected +.switchMon + ld a, [wPlayerMonNumber] ld d, a - ld a, [wWhichPokemon] ; wWhichPokemon - cp d - jr nz, .asm_3d19d + ld a, [wWhichPokemon] + cp d ; check if the mon to switch to is already out + jr nz, .notAlreadyOut +; mon is already out ld hl, AlreadyOutText call PrintText - jp Func_3d105 -.asm_3d19d - call Func_3ca97 - jp z, Func_3d105 + jp .partyMonDeselected +.notAlreadyOut + call HasMonFainted + jp z, .partyMonDeselected ; can't switch to fainted mon ld a, $1 ld [wcd6a], a call GBPalWhiteOut call ClearSprites - call Func_3ee5b + call LoadHudTilePatterns call LoadScreenTilesFromBuffer1 call GoPAL_SET_CF1C call GBPalNormal +; fall through to SwitchPlayerMon -Func_3d1ba: ; 3d1ba (f:51ba) +SwitchPlayerMon: ; 3d1ba (f:51ba) callab RetreatMon ld c, $32 call DelayFrames - call Func_3ccfa - ld a, [wWhichPokemon] ; wWhichPokemon - ld [wPlayerMonNumber], a ; wPlayerMonNumber + call AnimateRetreatingPlayerMon + ld a, [wWhichPokemon] + ld [wPlayerMonNumber], a ld c, a ld b, $1 push bc - ld hl, wPartyAliveFlags + ld hl, wPartyGainExpFlags predef FlagActionPredef pop bc - ld hl, wccf5 + ld hl, wPartyFoughtCurrentEnemyFlags predef FlagActionPredef - call Func_3cba6 - call Func_3cc91 + call LoadBattleMonFromParty + call SendOutMon call SaveScreenTilesToBuffer1 ld a, $2 - ld [wCurrentMenuItem], a ; wCurrentMenuItem + ld [wCurrentMenuItem], a and a ret @@ -2397,20 +2480,20 @@ AlreadyOutText: ; 3d1f5 (f:51f5) TX_FAR _AlreadyOutText db "@" -Func_3d1fa: ; 3d1fa (f:51fa) +BattleMenu_RunWasSelected: ; 3d1fa (f:51fa) call LoadScreenTilesFromBuffer1 ld a, $3 - ld [wCurrentMenuItem], a ; wCurrentMenuItem + ld [wCurrentMenuItem], a ld hl, wBattleMonSpeed ld de, wEnemyMonSpeed - call Func_3cab9 + call TryRunningFromBattle ld a, $0 ld [wd11f], a ret c ld a, [wcd6a] and a ret nz - jp InitBattleMenu + jp DisplayBattleMenu MoveSelectionMenu: ; 3d219 (f:5219) ld a, [wMoveMenuType] @@ -2471,8 +2554,8 @@ MoveSelectionMenu: ; 3d219 (f:5219) ld a, $7 jr .menuset .relearnmenu - ld a, [wWhichPokemon] ; wWhichPokemon - ld hl, wPartyMon1Moves ; wPartyMon1Moves + ld a, [wWhichPokemon] + ld hl, wPartyMon1Moves ld bc, $2c call AddNTimes call .loadmoves @@ -2485,24 +2568,24 @@ MoveSelectionMenu: ; 3d219 (f:5219) ld b, $5 ld a, $7 .menuset - ld hl, wTopMenuItemY ; wTopMenuItemY + ld hl, wTopMenuItemY ld [hli], a ld a, b - ld [hli], a ; wTopMenuItemX + ld [hli], a ld a, [wMoveMenuType] cp $1 jr z, .selectedmoveknown ld a, $1 jr nc, .selectedmoveknown - ld a, [wPlayerMoveListIndex] ; wPlayerMoveListIndex + ld a, [wPlayerMoveListIndex] inc a .selectedmoveknown - ld [hli], a ; wCurrentMenuItem + ld [hli], a inc hl ; wTileBehindCursor untouched ld a, [wcd6c] inc a inc a - ld [hli], a ; wMaxMenuItem + ld [hli], a ld a, [wMoveMenuType] dec a ld b, $c1 ; can't use B @@ -2510,7 +2593,7 @@ MoveSelectionMenu: ; 3d219 (f:5219) dec a ld b, $c3 jr z, .matchedkeyspicked - ld a, [W_ISLINKBATTLE] ; W_ISLINKBATTLE + ld a, [W_ISLINKBATTLE] cp $4 jr z, .matchedkeyspicked ld a, [W_FLAGS_D733] @@ -2520,14 +2603,14 @@ MoveSelectionMenu: ; 3d219 (f:5219) ld b, $ff .matchedkeyspicked ld a, b - ld [hli], a ; wMenuWatchedKeys + ld [hli], a ld a, [wMoveMenuType] cp $1 jr z, .movelistindex1 - ld a, [wPlayerMoveListIndex] ; wPlayerMoveListIndex + ld a, [wPlayerMoveListIndex] inc a .movelistindex1 - ld [hl], a ; wLastMenuItem + ld [hl], a Func_3d2fe: ; 3d2fe (f:52fe) ld a, [wMoveMenuType] @@ -2536,7 +2619,7 @@ Func_3d2fe: ; 3d2fe (f:52fe) dec a jr nz, .select hlCoord 1, 14 - ld de, WhichTechniqueString ; $53b8 + ld de, WhichTechniqueString call PlaceString jr .select .battleselect @@ -2544,7 +2627,7 @@ Func_3d2fe: ; 3d2fe (f:52fe) bit 0, a jr nz, .select call Func_3d4b6 - ld a, [wcc35] + ld a, [wMenuItemToSwap] and a jr z, .select hlCoord 5, 13 @@ -2563,14 +2646,14 @@ Func_3d2fe: ; 3d2fe (f:52fe) bit 7, a jp nz, Func_3d3dd ; down bit 2, a - jp nz, Func_3d435 ; select + jp nz, SwapMovesInMenu ; select bit 1, a ; B, but was it reset above? push af xor a - ld [wcc35], a - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + ld [wMenuItemToSwap], a + ld a, [wCurrentMenuItem] dec a - ld [wCurrentMenuItem], a ; wCurrentMenuItem + ld [wCurrentMenuItem], a ld b, a ld a, [wMoveMenuType] dec a ; if not mimic @@ -2580,38 +2663,38 @@ Func_3d2fe: ; 3d2fe (f:52fe) .nob dec a ld a, b - ld [wPlayerMoveListIndex], a ; wPlayerMoveListIndex + ld [wPlayerMoveListIndex], a jr nz, .moveselected pop af ret .moveselected pop af ret nz - ld hl, wBattleMonPP ; wBattleMonPP - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + ld hl, wBattleMonPP + ld a, [wCurrentMenuItem] ld c, a ld b, $0 add hl, bc ld a, [hl] and $3f jr z, .nopp - ld a, [W_PLAYERDISABLEDMOVE] ; W_PLAYERDISABLEDMOVE + ld a, [W_PLAYERDISABLEDMOVE] swap a and $f dec a cp c jr z, .disabled - ld a, [W_PLAYERBATTSTATUS3] ; W_PLAYERBATTSTATUS3 + ld a, [W_PLAYERBATTSTATUS3] bit 3, a ; transformed jr nz, .dummy ; game freak derp .dummy - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + ld a, [wCurrentMenuItem] ld hl, wBattleMonMoves ld c, a ld b, $0 add hl, bc ld a, [hl] - ld [wPlayerSelectedMove], a ; wPlayerSelectedMove + ld [wPlayerSelectedMove], a xor a ret .disabled @@ -2636,17 +2719,17 @@ WhichTechniqueString: ; 3d3b8 (f:53b8) db "WHICH TECHNIQUE?@" Func_3d3c9: ; 3d3c9 (f:53c9) - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + ld a, [wCurrentMenuItem] and a jp nz, Func_3d2fe call EraseMenuCursor ld a, [wcd6c] inc a - ld [wCurrentMenuItem], a ; wCurrentMenuItem + ld [wCurrentMenuItem], a jp Func_3d2fe Func_3d3dd: ; 3d3dd (f:53dd) - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + ld a, [wCurrentMenuItem] ld b, a ld a, [wcd6c] inc a @@ -2655,15 +2738,15 @@ Func_3d3dd: ; 3d3dd (f:53dd) jp nz, Func_3d2fe call EraseMenuCursor ld a, $1 - ld [wCurrentMenuItem], a ; wCurrentMenuItem + ld [wCurrentMenuItem], a jp Func_3d2fe Func_3d3f5: ; 3d3f5 (f:53f5) - ld a, $a5 - ld [wPlayerSelectedMove], a ; wPlayerSelectedMove - ld a, [W_PLAYERDISABLEDMOVE] ; W_PLAYERDISABLEDMOVE + ld a, STRUGGLE + ld [wPlayerSelectedMove], a + ld a, [W_PLAYERDISABLEDMOVE] and a - ld hl, wBattleMonPP ; wBattleMonPP + ld hl, wBattleMonPP jr nz, .asm_3d40e ld a, [hli] or [hl] @@ -2704,70 +2787,70 @@ NoMovesLeftText: ; 3d430 (f:5430) TX_FAR _NoMovesLeftText db "@" -Func_3d435: ; 3d435 (f:5435) - ld a, [wcc35] +SwapMovesInMenu: ; 3d435 (f:5435) + ld a, [wMenuItemToSwap] and a - jr z, asm_3d4ad + jr z, .noMenuItemSelected ld hl, wBattleMonMoves - call Func_3d493 - ld hl, wBattleMonPP ; wBattleMonPP - call Func_3d493 - ld hl, W_PLAYERDISABLEDMOVE ; W_PLAYERDISABLEDMOVE + call .swapBytes ; swap moves + ld hl, wBattleMonPP + call .swapBytes ; swap move PP +; update the index of the disabled move if necessary + ld hl, W_PLAYERDISABLEDMOVE ld a, [hl] swap a and $f ld b, a - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + ld a, [wCurrentMenuItem] cp b - jr nz, .asm_3d463 + jr nz, .next ld a, [hl] and $f ld b, a - ld a, [wcc35] + ld a, [wMenuItemToSwap] swap a add b ld [hl], a - jr .asm_3d474 -.asm_3d463 - ld a, [wcc35] + jr .swapMovesInPartyMon +.next + ld a, [wMenuItemToSwap] cp b - jr nz, .asm_3d474 + jr nz, .swapMovesInPartyMon ld a, [hl] and $f ld b, a - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + ld a, [wCurrentMenuItem] swap a add b ld [hl], a -.asm_3d474 - ld hl, wPartyMon1Moves ; wPartyMon1Moves - ld a, [wPlayerMonNumber] ; wPlayerMonNumber - ld bc, $2c +.swapMovesInPartyMon + ld hl, wPartyMon1Moves + ld a, [wPlayerMonNumber] + ld bc, wPartyMon2 - wPartyMon1 call AddNTimes push hl - call Func_3d493 + call .swapBytes ; swap moves pop hl ld bc, $15 add hl, bc - call Func_3d493 + call .swapBytes ; swap move PP xor a - ld [wcc35], a + ld [wMenuItemToSwap], a ; deselect the item jp MoveSelectionMenu - -Func_3d493: ; 3d493 (f:5493) +.swapBytes push hl - ld a, [wcc35] + ld a, [wMenuItemToSwap] dec a ld c, a - ld b, $0 + ld b, 0 add hl, bc ld d, h ld e, l pop hl - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + ld a, [wCurrentMenuItem] dec a ld c, a - ld b, $0 + ld b, 0 add hl, bc ld a, [de] ld b, [hl] @@ -2775,25 +2858,25 @@ Func_3d493: ; 3d493 (f:5493) ld a, b ld [de], a ret -asm_3d4ad: ; 3d4ad (f:54ad) - ld a, [wCurrentMenuItem] ; wCurrentMenuItem - ld [wcc35], a +.noMenuItemSelected + ld a, [wCurrentMenuItem] + ld [wMenuItemToSwap], a ; select the current menu item for swapping jp MoveSelectionMenu Func_3d4b6: ; 3d4b6 (f:54b6) xor a - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba + ld [H_AUTOBGTRANSFERENABLED], a hlCoord 0, 8 ld b, $3 ld c, $9 call TextBoxBorder - ld a, [W_PLAYERDISABLEDMOVE] ; W_PLAYERDISABLEDMOVE + ld a, [W_PLAYERDISABLEDMOVE] and a jr z, .asm_3d4df swap a and $f ld b, a - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + ld a, [wCurrentMenuItem] cp b jr nz, .asm_3d4df hlCoord 1, 10 @@ -2801,27 +2884,27 @@ Func_3d4b6: ; 3d4b6 (f:54b6) call PlaceString jr .asm_3d54e .asm_3d4df - ld hl, wCurrentMenuItem ; wCurrentMenuItem + ld hl, wCurrentMenuItem dec [hl] xor a - ld [H_WHOSETURN], a ; $fff3 + ld [H_WHOSETURN], a ld hl, wBattleMonMoves - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + ld a, [wCurrentMenuItem] ld c, a ld b, $0 add hl, bc ld a, [hl] - ld [wPlayerSelectedMove], a ; wPlayerSelectedMove - ld a, [wPlayerMonNumber] ; wPlayerMonNumber - ld [wWhichPokemon], a ; wWhichPokemon + ld [wPlayerSelectedMove], a + ld a, [wPlayerMonNumber] + ld [wWhichPokemon], a ld a, $4 ld [wcc49], a callab GetMaxPP - ld hl, wCurrentMenuItem ; wCurrentMenuItem + ld hl, wCurrentMenuItem ld c, [hl] inc [hl] ld b, $0 - ld hl, wBattleMonPP ; wBattleMonPP + ld hl, wBattleMonPP add hl, bc ld a, [hl] and $3f @@ -2846,7 +2929,7 @@ Func_3d4b6: ; 3d4b6 (f:54b6) predef Func_27d98 .asm_3d54e ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba + ld [H_AUTOBGTRANSFERENABLED], a jp Delay3 DisabledText: ; 3d555 (f:5555) @@ -2859,8 +2942,9 @@ SelectEnemyMove: ; 3d564 (f:5564) ld a, [W_ISLINKBATTLE] sub $4 jr nz, .noLinkBattle +; link battle call SaveScreenTilesToBuffer1 - call Func_3d605 + call LinkBattleExchangeData call LoadScreenTilesFromBuffer1 ld a, [wcc3e] cp $e @@ -2943,29 +3027,30 @@ SelectEnemyMove: ; 3d564 (f:5564) ld [wEnemySelectedMove], a ret .asm_3d601 - ld a, $a5 + ld a, STRUGGLE jr .done -Func_3d605: ; 3d605 (f:5605) +; this appears to exchange data with the other gameboy during link battles +LinkBattleExchangeData: ; 3d605 (f:5605) ld a, $ff ld [wcc3e], a - ld a, [wPlayerMoveListIndex] ; wPlayerMoveListIndex - cp $f + ld a, [wPlayerMoveListIndex] + cp $f ; is the player running from battle? jr z, .asm_3d630 ld a, [wcd6a] and a jr nz, .asm_3d629 - ld a, [wPlayerSelectedMove] ; wPlayerSelectedMove - cp $a5 + ld a, [wPlayerSelectedMove] + cp STRUGGLE ld b, $e jr z, .asm_3d62f dec b inc a jr z, .asm_3d62f - ld a, [wPlayerMoveListIndex] ; wPlayerMoveListIndex + ld a, [wPlayerMoveListIndex] jr .asm_3d630 .asm_3d629 - ld a, [wWhichPokemon] ; wWhichPokemon + ld a, [wWhichPokemon] add $4 ld b, a .asm_3d62f @@ -2993,14 +3078,14 @@ Func_3d605: ; 3d605 (f:5605) jr nz, .asm_3d654 ret -Func_3d65e: ; 3d65e (f:565e) +ExecutePlayerMove: ; 3d65e (f:565e) xor a - ld [H_WHOSETURN], a ; $fff3 - ld a, [wPlayerSelectedMove] ; wPlayerSelectedMove + ld [H_WHOSETURN], a + ld a, [wPlayerSelectedMove] inc a jp z, Func_3d80a xor a - ld [W_MOVEMISSED], a ; W_MOVEMISSED + ld [W_MOVEMISSED], a ld [wcced], a ld [wccf4], a ld a, $a @@ -3010,23 +3095,23 @@ Func_3d65e: ; 3d65e (f:565e) jp nz, Func_3d80a call PrintGhostText jp z, Func_3d80a - call Func_3d854 + call CheckPlayerStatusConditions jr nz, .asm_3d68a jp [hl] .asm_3d68a call GetCurrentMove - ld hl, W_PLAYERBATTSTATUS1 ; W_PLAYERBATTSTATUS1 + ld hl, W_PLAYERBATTSTATUS1 bit 4, [hl] jr nz, asm_3d6a9 - call Func_3dc88 + call CheckForDisobedience jp z, Func_3d80a Func_3d69a: ; 3d69a (f:569a) - ld a, [W_PLAYERMOVEEFFECT] ; wcfd3 + ld a, [W_PLAYERMOVEEFFECT] cp CHARGE_EFFECT - jp z, Func_3f132 + jp z, JumpMoveEffect cp FLY_EFFECT - jp z, Func_3f132 + jp z, JumpMoveEffect jr asm_3d6b0 ; in-battle stuff @@ -3044,12 +3129,12 @@ asm_3d6b0: ; 3d6b0 (f:56b0) ld hl,EffectsArray1 ld de,1 call IsInArray - jp c,Func_3f132 + jp c,JumpMoveEffect ld a,[W_PLAYERMOVEEFFECT] ld hl,EffectsArray5B ld de,1 call IsInArray - call c,Func_3f132 + call c,JumpMoveEffect asm_3d6dc: ; 3d6dc (f:56dc) ld a,[W_PLAYERMOVEEFFECT] ld hl,EffectsArray2 @@ -3059,11 +3144,11 @@ asm_3d6dc: ; 3d6dc (f:56dc) call CriticalHitTest call HandleCounterMove jr z,asm_3d705 + call GetDamageVarsForPlayerAttack call CalculateDamage - call MoreCalculateDamage jp z,asm_3d74b call AdjustDamageForMoveType - call Func_3e687 + call RandomizeDamage .asm_3d702 call MoveHitTest asm_3d705 @@ -3073,7 +3158,7 @@ asm_3d705 ld a,[W_PLAYERMOVEEFFECT] sub a,7 jr z,asm_3d71e - jr asm_3d74b ; 574B + jr asm_3d74b asm_3d714 ld a,[W_PLAYERMOVEEFFECT] and a @@ -3092,7 +3177,7 @@ asm_3d71e ld a,[W_PLAYERMOVENUM] call PlayMoveAnimation call Func_3eed3 - call Func_3cd60 + call DrawPlayerHUDAndHPBar ld a,[W_PLAYERBATTSTATUS2] bit 4,a ld hl,Func_79771 @@ -3116,7 +3201,7 @@ asm_3d74b asm_3d766 ld a,[W_PLAYERMOVEEFFECT] cp a,MIRROR_MOVE_EFFECT - jr nz,.next6 ; 577A + jr nz,.next6 call MirrorMoveCopyMove jp z,Func_3d80a xor a @@ -3124,7 +3209,7 @@ asm_3d766 jp Func_3d69a .next6 cp a,METRONOME_EFFECT - jr nz,.next7 ; 5784 + jr nz,.next7 call MetronomePickMove jp Func_3d69a .next7 @@ -3132,18 +3217,18 @@ asm_3d766 ld hl,EffectsArray3 ld de,1 call IsInArray - jp c,Func_3f132 + jp c,JumpMoveEffect ld a,[W_MOVEMISSED] and a - jr z,.next8 ; 57A6 + jr z,.next8 call PrintMoveFailureText ld a,[W_PLAYERMOVEEFFECT] cp a,EXPLODE_EFFECT - jr z,.next9 ; 57B9 + jr z,.next9 jp Func_3d80a .next8 call ApplyAttackToEnemyPokemon - call Func_3dc5c + call PrintCriticalOHKOText callab DisplayEffectiveness ld a,1 ld [wccf4],a @@ -3152,7 +3237,7 @@ asm_3d766 ld hl,EffectsArray4 ld de,1 call IsInArray - call c,Func_3f132 + call c,JumpMoveEffect ld hl,wEnemyMonHP ld a,[hli] ld b,[hl] @@ -3162,10 +3247,10 @@ asm_3d766 ld hl,W_PLAYERBATTSTATUS1 bit 2,[hl] - jr z,.next10 ; 57EF - ld a,[wd06a] + jr z,.next10 + ld a,[wPlayerNumAttacksLeft] dec a - ld [wd06a],a + ld [wPlayerNumAttacksLeft],a jp nz,asm_3d714 res 2,[hl] @@ -3180,7 +3265,7 @@ asm_3d766 ld hl,EffectsArray5 ld de,1 call IsInArray - call nc,Func_3f132 + call nc,JumpMoveEffect jp Func_3d80a MultiHitText: ; 3d805 (f:5805) @@ -3231,24 +3316,27 @@ IsGhostBattle: ; 3d83a (f:583a) cp a,LAVENDER_HOUSE_1 jr nc,.next ld b,SILPH_SCOPE - call IsItemInBag ; $3493 + call IsItemInBag ret z .next ld a,1 and a ret -Func_3d854: ; 3d854 (f:5854) +; checks for various status conditions affecting the player mon +; stores whether the mon cannot use a move this turn in Z flag +CheckPlayerStatusConditions: ; 3d854 (f:5854) ld hl,wBattleMonStatus ld a,[hl] - and a,SLP - jr z,.FrozenCheck ; to 5884 + and a,SLP ; sleep mask + jr z,.FrozenCheck +; sleeping dec a - ld [wBattleMonStatus],a ; decrement sleep count + ld [wBattleMonStatus],a ; decrement number of turns left and a - jr z,.WakeUp ; to 5874 - + jr z,.WakeUp ; if the number of turns hit 0, wake up +; fast asleep xor a ld [wcc5b],a ld a,SLP_ANIM - 1 @@ -3263,72 +3351,74 @@ Func_3d854: ; 3d854 (f:5854) xor a ld [wccf1],a ld hl,Func_3d80a - jp Func_3da37 + jp .CannotUseMove .FrozenCheck bit FRZ,[hl] ; frozen? - jr z,.HeldInPlaceCheck ; to 5898 + jr z,.HeldInPlaceCheck ld hl,IsFrozenText call PrintText xor a ld [wccf1],a ld hl,Func_3d80a - jp Func_3da37 + jp .CannotUseMove .HeldInPlaceCheck ld a,[W_ENEMYBATTSTATUS1] bit 5,a - jp z,FlinchedCheck + jp z,.FlinchedCheck ld hl,CantMoveText call PrintText ld hl,Func_3d80a - jp Func_3da37 + jp .CannotUseMove -FlinchedCheck: ; 3d8ac (f:58ac) +.FlinchedCheck ld hl,W_PLAYERBATTSTATUS1 bit 3,[hl] - jp z,HyperBeamCheck + jp z,.HyperBeamCheck res 3,[hl] ld hl,FlinchedText call PrintText ld hl,Func_3d80a - jp Func_3da37 + jp .CannotUseMove -HyperBeamCheck: ; 3d8c2 (f:58c2) +.HyperBeamCheck ld hl,W_PLAYERBATTSTATUS2 bit 5,[hl] - jr z,.next ; 58D7 + jr z,.AnyMoveDisabledCheck res 5,[hl] ld hl,MustRechargeText call PrintText - ld hl,Func_3d80a ; $580a - jp Func_3da37 -.next + ld hl,Func_3d80a + jp .CannotUseMove + +.AnyMoveDisabledCheck ld hl,W_PLAYERDISABLEDMOVE ld a,[hl] and a - jr z,.next2 ; 58EE + jr z,.ConfusedCheck dec a ld [hl],a and a,$F - jr nz,.next2 + jr nz,.ConfusedCheck ld [hl],a ld [wccee],a ld hl,DisabledNoMoreText call PrintText -.next2 + +.ConfusedCheck ld a,[W_PLAYERBATTSTATUS1] add a - jr nc,.next3 ; 5929 + jr nc,.TriedToUseDisabledMoveCheck ld hl,wd06b dec [hl] - jr nz,.next4 ; 5907 + jr nz,.IsConfused ld hl,W_PLAYERBATTSTATUS1 res 7,[hl] ld hl,ConfusedNoMoreText call PrintText - jr .next3 -.next4 + jr .TriedToUseDisabledMoveCheck +.IsConfused ld hl,IsConfusedText call PrintText xor a @@ -3337,55 +3427,60 @@ HyperBeamCheck: ; 3d8c2 (f:58c2) call PlayMoveAnimation call BattleRandom cp a,$80 - jr c,.next3 + jr c,.TriedToUseDisabledMoveCheck ld hl,W_PLAYERBATTSTATUS1 ld a,[hl] and a,$80 ; confused ld [hl],a call PrintHurtItselfText - jr .next5 ; 5952 -.next3 + jr .MonHurtItselfOrFullyParalysed + +.TriedToUseDisabledMoveCheck ld a,[wccee] and a - jr z,.ParalysisCheck ; 593E + jr z,.ParalysisCheck ld hl,wPlayerSelectedMove cp [hl] jr nz,.ParalysisCheck call PrintMoveIsDisabledText - ld hl,Func_3d80a ; $580a - jp Func_3da37 + ld hl,Func_3d80a + jp .CannotUseMove + .ParalysisCheck ld hl,wBattleMonStatus bit PAR,[hl] - jr z,.next7 ; 5975 + jr z,.BideCheck call BattleRandom cp a,$3F - jr nc,.next7 + jr nc,.BideCheck ld hl,FullyParalyzedText call PrintText -.next5 + +.MonHurtItselfOrFullyParalysed ld hl,W_PLAYERBATTSTATUS1 ld a,[hl] - and a,$CC + and a,$CC ; clear bide, thrashing, charging up, and multi-turn moves such as warp ld [hl],a ld a,[W_PLAYERMOVEEFFECT] cp a,FLY_EFFECT - jr z,.next8 ; 5966 + jr z,.FlyOrChargeEffect cp a,CHARGE_EFFECT - jr z,.next8 - jr .next9 ; 596F -.next8 + jr z,.FlyOrChargeEffect + jr .NotFlyOrChargeEffect + +.FlyOrChargeEffect xor a ld [wcc5b],a ld a,STATUS_AFFECTED_ANIM call PlayMoveAnimation -.next9 - ld hl,Func_3d80a ; $580a - jp Func_3da37 -.next7 +.NotFlyOrChargeEffect + ld hl,Func_3d80a + jp .CannotUseMove + +.BideCheck ld hl,W_PLAYERBATTSTATUS1 - bit 0,[hl] - jr z,.next10 ; 59D0 + bit 0,[hl] ; is mon using bide? + jr z,.ThrashingAboutCheck xor a ld [W_PLAYERMOVENUM],a ld hl,W_DAMAGE @@ -3399,14 +3494,14 @@ HyperBeamCheck: ; 3d8c2 (f:58c2) ld a,[hl] adc b ld [hl],a - ld hl,wd06a + ld hl,wPlayerNumAttacksLeft dec [hl] - jr z,.next11 ; 599B - ld hl,Func_3d80a ; $580a - jp Func_3da37 -.next11 + jr z,.UnleashEnergy + ld hl,Func_3d80a + jp .CannotUseMove +.UnleashEnergy ld hl,W_PLAYERBATTSTATUS1 - res 0,[hl] + res 0,[hl] ; not using bide any more ld hl,UnleashedEnergyText call PrintText ld a,1 @@ -3420,28 +3515,29 @@ HyperBeamCheck: ; 3d8c2 (f:58c2) rl a ld [W_DAMAGE],a or b - jr nz,.next12 ; 59C2 + jr nz,.next ld a,1 ld [W_MOVEMISSED],a -.next12 +.next xor a ld [hli],a ld [hl],a ld a,BIDE ld [W_PLAYERMOVENUM],a - ld hl,asm_3d705 ; $5705 - jp Func_3da37 -.next10 - bit 1,[hl] - jr z,.next13 ; 59FF + ld hl,asm_3d705 + jp .CannotUseMove + +.ThrashingAboutCheck + bit 1,[hl] ; is mon using thrash or petal dance? + jr z,.MultiturnMoveCheck ld a,THRASH ld [W_PLAYERMOVENUM],a ld hl,ThrashingAboutText call PrintText - ld hl,wd06a + ld hl,wPlayerNumAttacksLeft dec [hl] - ld hl,asm_3d6dc ; $56dc - jp nz,Func_3da37 + ld hl,asm_3d6dc + jp nz,.CannotUseMove push hl ld hl,W_PLAYERBATTSTATUS1 res 1,[hl] @@ -3452,37 +3548,38 @@ HyperBeamCheck: ; 3d8c2 (f:58c2) inc a ld [wd06b],a pop hl - jp Func_3da37 -.next13 - bit 5,[hl] - jp z,Func_3da1a + jp .CannotUseMove + +.MultiturnMoveCheck + bit 5,[hl] ; is mon using multi-turn move? + jp z,.RageCheck ld hl,AttackContinuesText call PrintText - ld a,[wd06a] + ld a,[wPlayerNumAttacksLeft] dec a - ld [wd06a],a - ld hl,asm_3d714 ; $5714 - jp nz,Func_3da37 - jp Func_3da37 + ld [wPlayerNumAttacksLeft],a + ld hl,asm_3d714 + jp nz,.CannotUseMove + jp .CannotUseMove -Func_3da1a: ; 3da1a (f:5a1a) - ld a, [W_PLAYERBATTSTATUS2] ; W_PLAYERBATTSTATUS2 - bit 6, a - jp z, Func_3da39 +.RageCheck + ld a, [W_PLAYERBATTSTATUS2] + bit 6, a ; is mon using rage? + jp z, .CanUseMove ld a, RAGE ld [wd11e], a call GetMoveName call CopyStringToCF4B xor a - ld [W_PLAYERMOVEEFFECT], a ; wcfd3 - ld hl, asm_3d6b0 ; $56b0 - jp Func_3da37 + ld [W_PLAYERMOVEEFFECT], a + ld hl, asm_3d6b0 + jp .CannotUseMove -Func_3da37: ; 3da37 (f:5a37) +.CannotUseMove xor a ret -Func_3da39: ; 3da39 (f:5a39) +.CanUseMove ld a, $1 and a ret @@ -3548,13 +3645,13 @@ CantMoveText: ; 3da83 (f:5a83) db "@" PrintMoveIsDisabledText: ; 3da88 (f:5a88) - ld hl, wPlayerSelectedMove ; wPlayerSelectedMove - ld de, W_PLAYERBATTSTATUS1 ; W_PLAYERBATTSTATUS1 - ld a, [H_WHOSETURN] ; $fff3 + ld hl, wPlayerSelectedMove + ld de, W_PLAYERBATTSTATUS1 + ld a, [H_WHOSETURN] and a jr z, .asm_3da97 inc hl - ld de, W_ENEMYBATTSTATUS1 ; W_ENEMYBATTSTATUS1 + ld de, W_ENEMYBATTSTATUS1 .asm_3da97 ld a, [de] res 4, a @@ -3572,7 +3669,7 @@ MoveIsDisabledText: ; 3daa8 (f:5aa8) PrintHurtItselfText: ; 3daad (f:5aad) ld hl, HurtItselfText call PrintText - ld hl, wEnemyMonDefense ; wcff8 + ld hl, wEnemyMonDefense ld a, [hli] push af ld a, [hld] @@ -3581,19 +3678,19 @@ PrintHurtItselfText: ; 3daad (f:5aad) ld [hli], a ld a, [wBattleMonDefense + 1] ld [hl], a - ld hl, W_PLAYERMOVEEFFECT ; wcfd3 + ld hl, W_PLAYERMOVEEFFECT push hl ld a, [hl] push af xor a ld [hli], a - ld [wd05e], a + ld [wCriticalHitOrOHKO], a ld a, $28 ld [hli], a xor a ld [hl], a + call GetDamageVarsForPlayerAttack call CalculateDamage - call MoreCalculateDamage pop af pop hl ld [hl], a @@ -3605,11 +3702,11 @@ PrintHurtItselfText: ; 3daad (f:5aad) xor a ld [wcc5b], a inc a - ld [H_WHOSETURN], a ; $fff3 + ld [H_WHOSETURN], a call PlayMoveAnimation - call Func_3cd60 + call DrawPlayerHUDAndHPBar xor a - ld [H_WHOSETURN], a ; $fff3 + ld [H_WHOSETURN], a jp ApplyDamageToPlayerPokemon PrintMonName1Text: ; 3daf5 (f:5af5) @@ -3619,12 +3716,12 @@ PrintMonName1Text: ; 3daf5 (f:5af5) MonName1Text: ; 3dafb (f:5afb) TX_FAR _MonName1Text db $08 ; asm - ld a, [H_WHOSETURN] ; $fff3 + ld a, [H_WHOSETURN] and a - ld a, [W_PLAYERMOVENUM] ; wcfd2 + ld a, [W_PLAYERMOVENUM] ld hl, wccf1 jr z, .asm_3db11 - ld a, [W_ENEMYMOVENUM] ; W_ENEMYMOVENUM + ld a, [W_ENEMYMOVENUM] ld hl, wccf2 .asm_3db11 ld [hl], a @@ -3713,7 +3810,7 @@ Func_3db85: ; 3db85 (f:5b85) ld a, [wd11e] ; move number ld c, a ld b, $0 - ld hl, UnknownMovesList_3dba3 ; $5ba3 + ld hl, UnknownMovesList_3dba3 .asm_3db8f ld a, [hli] cp $ff @@ -3746,33 +3843,33 @@ UnknownMovesList_3dba3: ; 3dba3 (f:5ba3) db $FF ; terminator PrintMoveFailureText: ; 3dbe2 (f:5be2) - ld de, W_PLAYERMOVEEFFECT ; wcfd3 - ld a, [H_WHOSETURN] ; $fff3 + ld de, W_PLAYERMOVEEFFECT + ld a, [H_WHOSETURN] and a - jr z, .asm_3dbed - ld de, W_ENEMYMOVEEFFECT ; W_ENEMYMOVEEFFECT -.asm_3dbed - ld hl, DoesntAffectMonText ; $5c57 + jr z, .playersTurn + ld de, W_ENEMYMOVEEFFECT +.playersTurn + ld hl, DoesntAffectMonText ld a, [wd05b] and $7f jr z, .asm_3dc04 - ld hl, AttackMissedText ; $5c42 - ld a, [wd05e] + ld hl, AttackMissedText + ld a, [wCriticalHitOrOHKO] cp $ff jr nz, .asm_3dc04 - ld hl, UnaffectedText ; $5c4c + ld hl, UnaffectedText .asm_3dc04 push de call PrintText xor a - ld [wd05e], a + ld [wCriticalHitOrOHKO], a pop de ld a, [de] cp JUMP_KICK_EFFECT ret nz ; if you get here, the mon used hi jump kick and missed - ld hl, W_DAMAGE ; W_DAMAGE + ld hl, W_DAMAGE ld a, [hli] ld b, [hl] srl a @@ -3789,11 +3886,11 @@ PrintMoveFailureText: ; 3dbe2 (f:5be2) inc a ld [hl], a .asm_3dc2a - ld hl, KeptGoingAndCrashedText ; $5c47 + ld hl, KeptGoingAndCrashedText call PrintText ld b, $4 predef Func_48125 - ld a, [H_WHOSETURN] ; $fff3 + ld a, [H_WHOSETURN] and a jr nz, .asm_3dc3f jp ApplyDamageToPlayerPokemon @@ -3813,20 +3910,21 @@ UnaffectedText: ; 3dc4c (f:5c4c) db "@" PrintDoesntAffectText: ; 3dc51 (f:5c51) - ld hl, DoesntAffectMonText ; $5c57 + ld hl, DoesntAffectMonText jp PrintText DoesntAffectMonText: ; 3dc57 (f:5c57) TX_FAR _DoesntAffectMonText db "@" -Func_3dc5c: ; 3dc5c (f:5c5c) - ld a, [wd05e] +; if there was a critical hit or an OHKO was successful, print the corresponding text +PrintCriticalOHKOText: ; 3dc5c (f:5c5c) + ld a, [wCriticalHitOrOHKO] and a - jr z, .asm_3dc75 + jr z, .done ; do nothing if there was no critical hit or successful OHKO dec a add a - ld hl, CriticalOHKOTextPointers ; $5c7a + ld hl, CriticalOHKOTextPointers ld b, $0 ld c, a add hl, bc @@ -3835,8 +3933,8 @@ Func_3dc5c: ; 3dc5c (f:5c5c) ld l, a call PrintText xor a - ld [wd05e], a -.asm_3dc75 + ld [wCriticalHitOrOHKO], a +.done ld c, $14 jp DelayFrames @@ -3852,118 +3950,123 @@ OHKOText: ; 3dc83 (f:5c83) TX_FAR _OHKOText db "@" -Func_3dc88: ; 3dc88 (f:5c88) +; checks if a traded mon will disobey due to lack of badges +; stores whether the mon will use a move in Z flag +CheckForDisobedience: ; 3dc88 (f:5c88) xor a ld [wcced], a - ld a, [W_ISLINKBATTLE] ; W_ISLINKBATTLE + ld a, [W_ISLINKBATTLE] cp $4 - jr nz, .asm_3dc97 + jr nz, .checkIfMonIsTraded ld a, $1 and a ret -.asm_3dc97 - ld hl, wPartyMon1OTID ; wPartyMon1OTID - ld bc, $2c - ld a, [wPlayerMonNumber] ; wPlayerMonNumber +; compare the mon's original trainer ID with the player's ID to see if it was traded +.checkIfMonIsTraded + ld hl, wPartyMon1OTID + ld bc, wPartyMon2 - wPartyMon1 + ld a, [wPlayerMonNumber] call AddNTimes - ld a, [wPlayerID] ; wPlayerID + ld a, [wPlayerID] cp [hl] - jr nz, .asm_3dcb1 + jr nz, .monIsTraded inc hl - ld a, [wPlayerID + 1] ; wd35a + ld a, [wPlayerID + 1] cp [hl] - jp z, Func_3ddb0 -.asm_3dcb1 + jp z, .canUseMove +; it was traded +.monIsTraded ; what level might disobey? ld hl, W_OBTAINEDBADGES bit 7, [hl] ld a, 101 - jr nz, .asm_3dcce + jr nz, .next bit 5, [hl] ld a, 70 - jr nz, .asm_3dcce + jr nz, .next bit 3, [hl] ld a, 50 - jr nz, .asm_3dcce + jr nz, .next bit 1, [hl] ld a, 30 - jr nz, .asm_3dcce + jr nz, .next ld a, 10 -.asm_3dcce +.next ld b, a ld c, a - ld a, [wBattleMonLevel] ; wBattleMonLevel + ld a, [wBattleMonLevel] ld d, a add b ld b, a - jr nc, .asm_3dcda - ld b, $ff -.asm_3dcda + jr nc, .noCarry + ld b, $ff ; cap b at $ff +.noCarry ld a, c cp d - jp nc, Func_3ddb0 -.asm_3dcdf + jp nc, .canUseMove +.loop1 call BattleRandom swap a cp b - jr nc, .asm_3dcdf + jr nc, .loop1 cp c - jp c, Func_3ddb0 -.asm_3dceb + jp c, .canUseMove +.loop2 call BattleRandom cp b - jr nc, .asm_3dceb + jr nc, .loop2 cp c - jr c, .asm_3dd3f + jr c, .useRandomMove ld a, d sub c ld b, a call BattleRandom swap a sub b - jr c, .asm_3dd0e + jr c, .monNaps cp b - jr nc, .asm_3dd20 + jr nc, .monDoesNothing ld hl, WontObeyText call PrintText call PrintHurtItselfText - jp Func_3ddb4 -.asm_3dd0e + jp .cannotUseMove +.monNaps call BattleRandom add a swap a - and $7 - jr z, .asm_3dd0e - ld [wBattleMonStatus], a ; wBattleMonStatus + and SLP ; sleep mask + jr z, .monNaps ; keep trying until we get at least 1 turn of sleep + ld [wBattleMonStatus], a ld hl, BeganToNapText - jr .asm_3dd3a -.asm_3dd20 + jr .printText +.monDoesNothing call BattleRandom and $3 ld hl, LoafingAroundText and a - jr z, .asm_3dd3a + jr z, .printText ld hl, WontObeyText dec a - jr z, .asm_3dd3a + jr z, .printText ld hl, TurnedAwayText dec a - jr z, .asm_3dd3a + jr z, .printText ld hl, IgnoredOrdersText -.asm_3dd3a +.printText call PrintText - jr Func_3ddb4 -.asm_3dd3f + jr .cannotUseMove +.useRandomMove ld a, [wBattleMonMoves + 1] - and a - jr z, .asm_3dd20 + and a ; is the second move slot empty? + jr z, .monDoesNothing ; mon will not use move if it only knows one move ld a, [wccee] and a - jr nz, .asm_3dd20 - ld a, [wPlayerSelectedMove] ; wPlayerSelectedMove - cp $a5 - jr z, .asm_3dd20 - ld hl, wBattleMonPP ; wBattleMonPP + jr nz, .monDoesNothing + ld a, [wPlayerSelectedMove] + cp STRUGGLE + jr z, .monDoesNothing ; mon will not use move if struggling +; check if only one move has remaining PP + ld hl, wBattleMonPP push hl ld a, [hli] and $3f @@ -3981,7 +4084,7 @@ Func_3dc88: ; 3dc88 (f:5c88) add b pop hl push af - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + ld a, [wCurrentMenuItem] ld c, a ld b, $0 add hl, bc @@ -3990,44 +4093,42 @@ Func_3dc88: ; 3dc88 (f:5c88) ld b, a pop af cp b - jr z, .asm_3dd20 + jr z, .monDoesNothing ; mon will not use move if only one move has remaining PP ld a, $1 ld [wcced], a - ld a, [wMaxMenuItem] ; wMaxMenuItem + ld a, [wMaxMenuItem] ld b, a - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + ld a, [wCurrentMenuItem] ld c, a -.asm_3dd86 +.chooseMove call BattleRandom and $3 cp b - jr nc, .asm_3dd86 + jr nc, .chooseMove ; if the random number is greater than the move count, choose another cp c - jr z, .asm_3dd86 - ld [wCurrentMenuItem], a ; wCurrentMenuItem - ld hl, wBattleMonPP ; wBattleMonPP + jr z, .chooseMove ; if the random number matches the move the player selected, choose another + ld [wCurrentMenuItem], a + ld hl, wBattleMonPP ld e, a ld d, $0 add hl, de ld a, [hl] - and a - jr z, .asm_3dd86 - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + and a ; does the move have any PP left? + jr z, .chooseMove ; if the move has no PP left, choose another + ld a, [wCurrentMenuItem] ld c, a ld b, $0 ld hl, wBattleMonMoves add hl, bc ld a, [hl] - ld [wPlayerSelectedMove], a ; wPlayerSelectedMove + ld [wPlayerSelectedMove], a call GetCurrentMove - -Func_3ddb0: ; 3ddb0 (f:5db0) +.canUseMove ld a, $1 - and a + and a; clear Z flag ret - -Func_3ddb4: ; 3ddb4 (f:5db4) - xor a +.cannotUseMove + xor a ; set Z flag ret LoafingAroundText: ; 3ddb6 (f:5db6) @@ -4050,37 +4151,39 @@ IgnoredOrdersText: ; 3ddca (f:5dca) TX_FAR _IgnoredOrdersText db "@" -CalculateDamage: ; 3ddcf (f:5dcf) +; sets b, c, d, and e for the CalculateDamage routine in the case of an attack by the player mon +GetDamageVarsForPlayerAttack: ; 3ddcf (f:5dcf) xor a - ld hl, W_DAMAGE ;damage to eventually inflict, intitialise to zero + ld hl, W_DAMAGE ; damage to eventually inflict, initialise to zero ldi [hl], a ld [hl], a ld hl, W_PLAYERMOVEPOWER - ld a, [hli] ;*read attack base power + ld a, [hli] and a - ld d, a ;*D = attack base, used later - ret z ;return if attack is zero - ld a, [hl] ;*test attacking type - cp a, $14 ;types >= $14 are all special + ld d, a ; d = move power + ret z ; return if move power is zero + ld a, [hl] ; a = [W_PLAYERMOVETYPE] + cp FIRE ; types >= FIRE are all special jr nc, .specialAttack .physicalAttack - ld hl, wEnemyMonDefense ;opponent defense - ld a, [hli] ;*BC = opponent defense used later + ld hl, wEnemyMonDefense + ld a, [hli] ld b, a - ld c, [hl] - ld a, [W_ENEMYBATTSTATUS3] ;test for reflect - bit 2, a - jr z, .next -.doubleDefense - sla c ;x2 defense if bit2 of D069 is set + ld c, [hl] ; bc = enemy defense + ld a, [W_ENEMYBATTSTATUS3] + bit 2, a ; check for Reflect + jr z, .physicalAttackCritCheck +; if the enemy has used Reflect, double the enemy's defense + sla c rl b -.next - ld hl, wBattleMonAttack ;attack pointer - ld a, [wd05e] - and a - jr z, .next3 - ld c, 3 - call Func_3df1c +.physicalAttackCritCheck + ld hl, wBattleMonAttack + ld a, [wCriticalHitOrOHKO] + and a ; check for critical hit + jr z, .scaleStats +; in the case of a critical hit, reset the player's attack and the enemy's defense to their base values + ld c, 3 ; defense stat + call GetEnemyMonStat ld a, [$ff97] ld b, a ld a, [$ff98] @@ -4091,26 +4194,26 @@ CalculateDamage: ; 3ddcf (f:5dcf) ld bc, wPartyMon2 - wPartyMon1 call AddNTimes pop bc - jr .next3 + jr .scaleStats .specialAttack - ld hl, wEnemyMonSpecial ;opponent special - ld a, [hli] ;*BC = opponent special defense used later + ld hl, wEnemyMonSpecial + ld a, [hli] ld b, a - ld c, [hl] - ld a, [W_ENEMYBATTSTATUS3] ;test for lightscreen - bit 1, a - jr z, .next2 -.doubleSpecialDefense - sla c ;x2 special defense if bit1 of D069 set + ld c, [hl] ; bc = enemy special + ld a, [W_ENEMYBATTSTATUS3] + bit 1, a ; check for Light Screen + jr z, .specialAttackCritCheck +; if the enemy has used Light Screen, double the enemy's special + sla c rl b -.next2 +.specialAttackCritCheck ld hl, wBattleMonSpecial - ld a, [wd05e] ;XXX - and a - jr z, .next3 ;skip portion of code that pulls up inactive pokemon -.loadOtherPoke - ld c, 5 - call Func_3df1c + ld a, [wCriticalHitOrOHKO] + and a ; check for critical hit + jr z, .scaleStats +; in the case of a critical hit, reset the player's and enemy's specials to their base values + ld c, 5 ; special stat + call GetEnemyMonStat ld a, [$ff97] ld b, a ld a, [$ff98] @@ -4121,140 +4224,158 @@ CalculateDamage: ; 3ddcf (f:5dcf) ld bc, wPartyMon2 - wPartyMon1 call AddNTimes pop bc -.next3 - ld a, [hli] ;HL: when this was taken +; if either the offensive or defensive stat is too large to store in a byte, scale both stats by dividing them by 4 +; this allows values with up to 10 bits (values up to 1023) to be handled +; anything larger will wrap around +.scaleStats + ld a, [hli] ld l, [hl] - ld h, a ;*HL = attacker attack - or b ;is either attack or defense high byte nonzero? - jr z, .next4 - srl b ;[defense] BC /= 4 [this is just so it fits into a single byte, 10bits max] + ld h, a ; hl = player's offensive stat + or b ; is either high byte nonzero? + jr z, .next ; if not, we don't need to scale + ; bc /= 4 (scale enemy's defensive stat) + srl b rr c srl b rr c - srl h ;[attack] HL /= 4 [to apply equal scaling] + ; hl /= 4 (scale player's offensive stat) + srl h rr l srl h rr l ld a, l - or h - jr nz, .next4 ;is HL result zero? - inc l ;minimum HL = 1 -.next4 - ld b, l ;*B = attack [possibly scaled] [C contains defense] - ld a, [wBattleMonLevel] ;*E = level - ld e, a - ld a, [wd05e] ;critical hit? - and a - jr z, .next5 - sla e ;double level if it was a critical hit -.next5 - ld a, 1 ;return Z = 0 + or h ; is the player's offensive stat 0? + jr nz, .next + inc l ; if the player's offensive stat is 0, bump it up to 1 +.next + ld b, l ; b = player's offensive stat (possibly scaled) (c already contains enemy's defensive stat (possibly scaled)) + ld a, [wBattleMonLevel] + ld e, a ; e = level + ld a, [wCriticalHitOrOHKO] + and a ; check for critical hit + jr z, .done + sla e ; double level if it was a critical hit +.done + ld a, 1 and a ret -Func_3de75: ; 3de75 (f:5e75) - ld hl, W_DAMAGE ; W_DAMAGE +; sets b, c, d, and e for the CalculateDamage routine in the case of an attack by the enemy mon +GetDamageVarsForEnemyAttack: ; 3de75 (f:5e75) + ld hl, W_DAMAGE ; damage to eventually inflict, initialise to zero xor a ld [hli], a ld [hl], a - ld hl, W_ENEMYMOVEPOWER ; wcfce + ld hl, W_ENEMYMOVEPOWER ld a, [hli] - ld d, a + ld d, a ; d = move power and a - ret z - ld a, [hl] - cp $14 - jr nc, .asm_3debc + ret z ; return if move power is zero + ld a, [hl] ; a = [W_ENEMYMOVETYPE] + cp FIRE ; types >= FIRE are all special + jr nc, .specialAttack +.physicalAttack ld hl, wBattleMonDefense ld a, [hli] ld b, a - ld c, [hl] - ld a, [W_PLAYERBATTSTATUS3] ; W_PLAYERBATTSTATUS3 - bit 2, a - jr z, .asm_3de98 + ld c, [hl] ; bc = player defense + ld a, [W_PLAYERBATTSTATUS3] + bit 2, a ; check for Reflect + jr z, .physicalAttackCritCheck +; if the player has used Reflect, double the player's defense sla c rl b -.asm_3de98 +.physicalAttackCritCheck ld hl, wEnemyMonAttack - ld a, [wd05e] - and a - jr z, .asm_3deef + ld a, [wCriticalHitOrOHKO] + and a ; check for critical hit + jr z, .scaleStats +; in the case of a critical hit, reset the player's defense and the enemy's attack to their base values ld hl, wPartyMon1Defense - ld a, [wPlayerMonNumber] ; wPlayerMonNumber - ld bc, $2c + ld a, [wPlayerMonNumber] + ld bc, wPartyMon2 - wPartyMon1 call AddNTimes ld a, [hli] ld b, a ld c, [hl] push bc - ld c, $2 - call Func_3df1c + ld c, 2 ; attack stat + call GetEnemyMonStat ld hl, $ff97 pop bc - jr .asm_3deef -.asm_3debc + jr .scaleStats +.specialAttack ld hl, wBattleMonSpecial ld a, [hli] ld b, a ld c, [hl] - ld a, [W_PLAYERBATTSTATUS3] ; W_PLAYERBATTSTATUS3 - bit 1, a - jr z, .asm_3decd + ld a, [W_PLAYERBATTSTATUS3] + bit 1, a ; check for Light Screen + jr z, .specialAttackCritCheck +; if the player has used Light Screen, double the player's special sla c - rl b -.asm_3decd - ld hl, wEnemyMonSpecial ; wcffc - ld a, [wd05e] - and a - jr z, .asm_3deef - ld hl, wPartyMon1Special ; wPartyMon1Special - ld a, [wPlayerMonNumber] ; wPlayerMonNumber - ld bc, $2c + rl b +.specialAttackCritCheck + ld hl, wEnemyMonSpecial + ld a, [wCriticalHitOrOHKO] + and a ; check for critical hit + jr z, .scaleStats +; in the case of a critical hit, reset the player's and enemy's specials to their base values + ld hl, wPartyMon1Special + ld a, [wPlayerMonNumber] + ld bc, wPartyMon2 - wPartyMon1 call AddNTimes ld a, [hli] ld b, a ld c, [hl] push bc - ld c, $5 - call Func_3df1c + ld c, 5 ; special stat + call GetEnemyMonStat ld hl, $ff97 pop bc -.asm_3deef +; if either the offensive or defensive stat is too large to store in a byte, scale both stats by dividing them by 4 +; this allows values with up to 10 bits (values up to 1023) to be handled +; anything larger will wrap around +.scaleStats ld a, [hli] ld l, [hl] - ld h, a - or b - jr z, .asm_3df0a + ld h, a ; hl = enemy's offensive stat + or b ; is either high byte nonzero? + jr z, .next ; if not, we don't need to scale +; bc /= 4 (scale player's defensive stat) srl b rr c srl b rr c +; hl /= 4 (scale enemy's offensive stat) srl h rr l srl h rr l ld a, l - or h - jr nz, .asm_3df0a - inc l -.asm_3df0a - ld b, l - ld a, [wEnemyMonLevel] ; wEnemyMonLevel + or h ; is the enemy's offensive stat 0? + jr nz, .next + inc l ; if the enemy's offensive stat is 0, bump it up to 1 +.next + ld b, l ; b = enemy's offensive stat (possibly scaled) (c already contains player's defensive stat (possibly scaled)) + ld a, [wEnemyMonLevel] ld e, a - ld a, [wd05e] - and a - jr z, .asm_3df17 - sla e -.asm_3df17 + ld a, [wCriticalHitOrOHKO] + and a ; check for critical hit + jr z, .done + sla e ; double level if it was a critical hit +.done ld a, $1 and a and a ret -Func_3df1c: ; 3df1c (f:5f1c) +; get stat c of enemy mon +; c: stat to get (HP=1,Attack=2,Defense=3,Speed=4,Special=5) +GetEnemyMonStat: ; 3df1c (f:5f1c) push de push bc - ld a, [W_ISLINKBATTLE] ; W_ISLINKBATTLE + ld a, [W_ISLINKBATTLE] cp $4 jr nz, .asm_3df40 ld hl, wEnemyMon1Stats @@ -4273,8 +4394,8 @@ Func_3df1c: ; 3df1c (f:5f1c) pop de ret .asm_3df40 - ld a, [wEnemyMonLevel] ; wEnemyMonLevel - ld [W_CURENEMYLVL], a ; W_CURENEMYLVL + ld a, [wEnemyMonLevel] + ld [W_CURENEMYLVL], a ld a, [wEnemyMonSpecies] ld [wd0b5], a call GetMonHeader @@ -4292,7 +4413,7 @@ Func_3df1c: ; 3df1c (f:5f1c) pop de ret -MoreCalculateDamage: ; 3df65 (f:5f65) +CalculateDamage: ; 3df65 (f:5f65) ; input: ; b: attack ; c: opponent defense @@ -4452,8 +4573,8 @@ MoreCalculateDamage: ; 3df65 (f:5f65) ret Func_3e016: ; 3e016 (f:6016) - call Func_3f132 - ld a, [W_MOVEMISSED] ; W_MOVEMISSED + call JumpMoveEffect + ld a, [W_MOVEMISSED] dec a ret @@ -4471,8 +4592,8 @@ UnusedHighCriticalMoves: ; 3e01e (f:601e) ; among the most popular) tend to CH about 20 to 25% of the time." CriticalHitTest: ; 3e023 (f:6023) xor a - ld [wd05e], a - ld a, [H_WHOSETURN] ; $fff3 + ld [wCriticalHitOrOHKO], a + ld a, [H_WHOSETURN] and a ld a, [wEnemyMonSpecies] jr nz, .asm_3e032 @@ -4483,13 +4604,13 @@ CriticalHitTest: ; 3e023 (f:6023) ld a, [W_MONHBASESPEED] ld b, a srl b ; (effective (base speed/2)) - ld a, [H_WHOSETURN] ; $fff3 + ld a, [H_WHOSETURN] and a - ld hl, W_PLAYERMOVEPOWER ; W_PLAYERMOVEPOWER - ld de, W_PLAYERBATTSTATUS2 ; W_PLAYERBATTSTATUS2 + ld hl, W_PLAYERMOVEPOWER + ld de, W_PLAYERBATTSTATUS2 jr z, .calcCriticalHitProbability - ld hl, W_ENEMYMOVEPOWER ; wcfce - ld de, W_ENEMYBATTSTATUS2 ; W_ENEMYBATTSTATUS2 + ld hl, W_ENEMYMOVEPOWER + ld de, W_ENEMYBATTSTATUS2 .calcCriticalHitProbability ; 0x3e04f ld a, [hld] ; read base power from RAM and a @@ -4532,7 +4653,7 @@ CriticalHitTest: ; 3e023 (f:6023) cp b ; check a against calculated crit rate ret nc ; no critical hit if no borrow ld a, $1 - ld [wd05e], a ; set critical hit flag + ld [wCriticalHitOrOHKO], a ; set critical hit flag ret ; high critical hit moves @@ -4719,7 +4840,7 @@ ApplyDamageToEnemyPokemon: ; 3e142 (f:6142) ld [wListMenuID],a predef UpdateHPBar2 ; animate the HP bar shortening ApplyAttackToEnemyPokemonDone: ; 3e19d (f:619d) - jp Func_3cd5a ; redraw pokemon names and HP bars + jp DrawHUDsAndHPBars ApplyAttackToPlayerPokemon: ; 3e1a0 (f:61a0) ld a,[W_ENEMYMOVEEFFECT] @@ -4837,7 +4958,7 @@ ApplyDamageToPlayerPokemon: ; 3e200 (f:6200) ld [wListMenuID],a predef UpdateHPBar2 ; animate the HP bar shortening ApplyAttackToPlayerPokemonDone - jp Func_3cd5a ; redraw pokemon names and HP bars + jp DrawHUDsAndHPBars AttackSubstitute: ; 3e25e (f:625e) ld hl,SubstituteTookDamageText @@ -4883,7 +5004,7 @@ AttackSubstitute: ; 3e25e (f:625e) .nullifyEffect xor a ld [hl],a ; zero the effect of the attacker's move - jp Func_3cd5a ; redraw pokemon names and HP bars + jp DrawHUDsAndHPBars SubstituteTookDamageText: ; 3e2ac (f:62ac) TX_FAR _SubstituteTookDamageText @@ -5230,9 +5351,9 @@ MoveHitTest: ; 3e56b (f:656b) jr z,.checkForDigOrFlyStatus ; this code is buggy. it's supposed to prevent HP draining moves from working on substitutes. ; since $7b79 overwrites a with either $00 or $01, it never works. - cp a,DRAIN_HP_EFFECT ; $03 + cp a,DRAIN_HP_EFFECT jp z,.moveMissed - cp a,DREAM_EATER_EFFECT ; $08 + cp a,DREAM_EATER_EFFECT jp z,.moveMissed .checkForDigOrFlyStatus bit 6,[hl] @@ -5392,47 +5513,50 @@ CalcHitChance: ; 3e624 (f:6624) ld [hl],a ; store the hit chance in the move accuracy variable ret -Func_3e687: ; 3e687 (f:6687) - ld hl, W_DAMAGE ; W_DAMAGE +; multiplies damage by a random percentage from ~85% to 100% +RandomizeDamage: ; 3e687 (f:6687) + ld hl, W_DAMAGE ld a, [hli] and a - jr nz, .asm_3e692 + jr nz, .DamageGreaterThanOne ld a, [hl] - cp $2 + cp 2 ret c -.asm_3e692 +.DamageGreaterThanOne xor a - ld [H_NUMTOPRINT], a ; $ff96 (aliases: H_MULTIPLICAND) + ld [H_MULTIPLICAND], a dec hl ld a, [hli] - ld [$ff97], a + ld [H_MULTIPLICAND + 1], a ld a, [hl] - ld [$ff98], a -.asm_3e69c + ld [H_MULTIPLICAND + 2], a +; loop until a random number greater than or equal to 217 is generated +.loop call BattleRandom rrca - cp $d9 - jr c, .asm_3e69c - ld [H_REMAINDER], a ; $ff99 (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) - call Multiply - ld a, $ff - ld [H_REMAINDER], a ; $ff99 (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) + cp 217 + jr c, .loop + ld [H_MULTIPLIER], a + call Multiply ; multiply damage by the random number, which is in the range [217, 255] + ld a, 255 + ld [H_DIVISOR], a ld b, $4 - call Divide - ld a, [$ff97] - ld hl, W_DAMAGE ; W_DAMAGE + call Divide ; divide the result by 255 +; store the modified damage + ld a, [H_QUOTIENT + 2] + ld hl, W_DAMAGE ld [hli], a - ld a, [$ff98] + ld a, [H_QUOTIENT + 3] ld [hl], a ret -Func_3e6bc: ; 3e6bc (f:66bc) - ld a, [wEnemySelectedMove] ; wccdd +ExecuteEnemyMove: ; 3e6bc (f:66bc) + ld a, [wEnemySelectedMove] inc a jp z, Func_3e88c call PrintGhostText jp z, Func_3e88c - ld a, [W_ISLINKBATTLE] ; W_ISLINKBATTLE + ld a, [W_ISLINKBATTLE] cp $4 jr nz, .asm_3e6dc ld b, $1 @@ -5445,31 +5569,31 @@ Func_3e6bc: ; 3e6bc (f:66bc) ld hl, wccd5 inc [hl] xor a - ld [W_MOVEMISSED], a ; W_MOVEMISSED + ld [W_MOVEMISSED], a ld [wccf4], a ld a, $a ld [wd05b], a - call Func_3e88f - jr nz, .asm_3e6f2 + call CheckEnemyStatusConditions + jr nz, .canUseMove jp [hl] -.asm_3e6f2 - ld hl, W_ENEMYBATTSTATUS1 ; W_ENEMYBATTSTATUS1 - bit 4, [hl] - jr nz, asm_3e70b +.canUseMove + ld hl, W_ENEMYBATTSTATUS1 + bit 4, [hl] ; is the enemy charging up for attack? + jr nz, asm_3e70b ; if so, jump call GetCurrentMove Func_3e6fc: ; 3e6fc (f:66fc) - ld a, [W_ENEMYMOVEEFFECT] ; W_ENEMYMOVEEFFECT + ld a, [W_ENEMYMOVEEFFECT] cp CHARGE_EFFECT - jp z, Func_3f132 + jp z, JumpMoveEffect cp FLY_EFFECT - jp z, Func_3f132 + jp z, JumpMoveEffect jr asm_3e72b asm_3e70b: ; 3e70b (f:670b) - ld hl, W_ENEMYBATTSTATUS1 ; W_ENEMYBATTSTATUS1 + ld hl, W_ENEMYBATTSTATUS1 res 4, [hl] ; no longer charging up for attack - res 6, [hl] ; no longer invulnerable to typcial attacks - ld a, [W_ENEMYMOVENUM] ; W_ENEMYMOVENUM + res 6, [hl] ; no longer invulnerable to typical attacks + ld a, [W_ENEMYMOVENUM] ld [wd0b5], a ld a, $2c ld [wPredefBank], a @@ -5482,71 +5606,71 @@ asm_3e72b: ; 3e72b (f:672b) xor a ld [wcced], a call PrintMonName1Text - ld a, [W_ENEMYMOVEEFFECT] ; W_ENEMYMOVEEFFECT - ld hl, EffectsArray1 ; $4000 + ld a, [W_ENEMYMOVEEFFECT] + ld hl, EffectsArray1 ld de, $1 call IsInArray - jp c, Func_3f132 - ld a, [W_ENEMYMOVEEFFECT] ; W_ENEMYMOVEEFFECT - ld hl, EffectsArray5B ; $4049 + jp c, JumpMoveEffect + ld a, [W_ENEMYMOVEEFFECT] + ld hl, EffectsArray5B ld de, $1 call IsInArray - call c, Func_3f132 + call c, JumpMoveEffect asm_3e750: ; 3e750 (f:6750) - call Func_3ec81 - ld a, [W_ENEMYMOVEEFFECT] ; W_ENEMYMOVEEFFECT - ld hl, EffectsArray2 ; $4011 + call SwapPlayerAndEnemyLevels + ld a, [W_ENEMYMOVEEFFECT] + ld hl, EffectsArray2 ld de, $1 call IsInArray jp c, Func_3e77f call CriticalHitTest call HandleCounterMove jr z, asm_3e782 - call Func_3ec81 - call Func_3de75 - call Func_3ec81 - call MoreCalculateDamage + call SwapPlayerAndEnemyLevels + call GetDamageVarsForEnemyAttack + call SwapPlayerAndEnemyLevels + call CalculateDamage jp z, Func_3e7d1 call AdjustDamageForMoveType - call Func_3e687 + call RandomizeDamage Func_3e77f: ; 3e77f (f:677f) call MoveHitTest asm_3e782: ; 3e782 (f:6782) - ld a, [W_MOVEMISSED] ; W_MOVEMISSED + ld a, [W_MOVEMISSED] and a jr z, .asm_3e791 - ld a, [W_ENEMYMOVEEFFECT] ; W_ENEMYMOVEEFFECT + ld a, [W_ENEMYMOVEEFFECT] cp EXPLODE_EFFECT jr z, asm_3e7a0 jr Func_3e7d1 .asm_3e791 - call Func_3ec81 + call SwapPlayerAndEnemyLevels Func_3e794: ; 3e794 (f:6794) - ld a, [W_ENEMYMOVEEFFECT] ; W_ENEMYMOVEEFFECT + ld a, [W_ENEMYMOVEEFFECT] and a ld a, $1 jr z, asm_3e7a4 ld a, $2 jr asm_3e7a4 asm_3e7a0: ; 3e7a0 (f:67a0) - call Func_3ec81 + call SwapPlayerAndEnemyLevels xor a asm_3e7a4: ; 3e7a4 (f:67a4) push af - ld a, [W_ENEMYBATTSTATUS2] ; W_ENEMYBATTSTATUS2 + ld a, [W_ENEMYBATTSTATUS2] bit 4, a ; does mon have a substitute? ld hl, Func_79747 ld b, BANK(Func_79747) call nz, Bankswitch pop af ld [wcc5b], a - ld a, [W_ENEMYMOVENUM] ; W_ENEMYMOVENUM + ld a, [W_ENEMYMOVENUM] call PlayMoveAnimation call Func_3eed3 - call Func_3cdec - ld a, [W_ENEMYBATTSTATUS2] ; W_ENEMYBATTSTATUS2 + call DrawEnemyHUDAndHPBar + ld a, [W_ENEMYBATTSTATUS2] bit 4, a ; does mon have a substitute? ld hl, Func_79771 ld b, BANK(Func_79771) @@ -5554,10 +5678,10 @@ asm_3e7a4: ; 3e7a4 (f:67a4) jr asm_3e7ef Func_3e7d1: ; 3e7d1 (f:67d1) - call Func_3ec81 + call SwapPlayerAndEnemyLevels ld c, $1e call DelayFrames - ld a, [W_ENEMYMOVEEFFECT] ; W_ENEMYMOVEEFFECT + ld a, [W_ENEMYMOVEEFFECT] cp FLY_EFFECT jr z, .asm_3e7e6 cp CHARGE_EFFECT @@ -5569,7 +5693,7 @@ Func_3e7d1: ; 3e7d1 (f:67d1) ld a,STATUS_AFFECTED_ANIM call PlayMoveAnimation asm_3e7ef: ; 3e7ef (f:67ef) - ld a, [W_ENEMYMOVEEFFECT] ; W_ENEMYMOVEEFFECT + ld a, [W_ENEMYMOVEEFFECT] cp MIRROR_MOVE_EFFECT jr nz, .notMirrorMoveEffect call MirrorMoveCopyMove @@ -5581,58 +5705,58 @@ asm_3e7ef: ; 3e7ef (f:67ef) call MetronomePickMove jp Func_3e6fc .notMetronomeEffect - ld a, [W_ENEMYMOVEEFFECT] ; W_ENEMYMOVEEFFECT - ld hl, EffectsArray3 ; $4014 + ld a, [W_ENEMYMOVEEFFECT] + ld hl, EffectsArray3 ld de, $1 call IsInArray - jp c, Func_3f132 - ld a, [W_MOVEMISSED] ; W_MOVEMISSED + jp c, JumpMoveEffect + ld a, [W_MOVEMISSED] and a jr z, .asm_3e82b call PrintMoveFailureText - ld a, [W_ENEMYMOVEEFFECT] ; W_ENEMYMOVEEFFECT + ld a, [W_ENEMYMOVEEFFECT] cp EXPLODE_EFFECT jr z, .asm_3e83e jp Func_3e88c .asm_3e82b call ApplyAttackToPlayerPokemon - call Func_3dc5c + call PrintCriticalOHKOText callab DisplayEffectiveness - ld a, $1 + ld a, 1 ld [wccf4], a .asm_3e83e - ld a, [W_ENEMYMOVEEFFECT] ; W_ENEMYMOVEEFFECT - ld hl, EffectsArray4 ; $4030 + ld a, [W_ENEMYMOVEEFFECT] + ld hl, EffectsArray4 ld de, $1 call IsInArray - call c, Func_3f132 - ld hl, wBattleMonHP ; wd015 + call c, JumpMoveEffect + ld hl, wBattleMonHP ld a, [hli] ld b, [hl] or b ret z call HandleBuildingRage - ld hl, W_ENEMYBATTSTATUS1 ; W_ENEMYBATTSTATUS1 + ld hl, W_ENEMYBATTSTATUS1 bit 2, [hl] ; is mon hitting multiple times? (example: double kick) jr z, .asm_3e873 push hl - ld hl, wd06f + ld hl, wEnemyNumAttacksLeft dec [hl] pop hl jp nz, Func_3e794 res 2, [hl] ; mon is no longer hitting multiple times - ld hl, HitXTimesText ; $6887 + ld hl, HitXTimesText call PrintText xor a ld [wcd05], a .asm_3e873 - ld a, [W_ENEMYMOVEEFFECT] ; W_ENEMYMOVEEFFECT + ld a, [W_ENEMYMOVEEFFECT] and a jr z, Func_3e88c - ld hl, EffectsArray5 ; $403b + ld hl, EffectsArray5 ld de, $1 call IsInArray - call nc, Func_3f132 + call nc, JumpMoveEffect jr Func_3e88c HitXTimesText: ; 3e887 (f:6887) @@ -5643,93 +5767,93 @@ Func_3e88c: ; 3e88c (f:688c) ld b, $1 ret -Func_3e88f: ; 3e88f (f:688f) - ld hl, wEnemyMonStatus ; wcfe9 +; checks for various status conditions affecting the enemy mon +; stores whether the mon cannot use a move this turn in Z flag +CheckEnemyStatusConditions: ; 3e88f (f:688f) + ld hl, wEnemyMonStatus ld a, [hl] - and $7 - jr z, .asm_3e8bf - dec a - ld [wEnemyMonStatus], a ; wcfe9 + and SLP ; sleep mask + jr z, .checkIfFrozen + dec a ; decrement number of turns left + ld [wEnemyMonStatus], a and a - jr z, .asm_3e8af + jr z, .wokeUp ; if the number of turns hit 0, wake up ld hl, FastAsleepText call PrintText xor a ld [wcc5b], a ld a,SLP_ANIM call PlayMoveAnimation - jr .asm_3e8b5 -.asm_3e8af + jr .next1 +.wokeUp ld hl, WokeUpText call PrintText -.asm_3e8b5 +.next1 xor a ld [wccf2], a - ld hl, Func_3e88c ; $688c - jp Func_3eab8 -.asm_3e8bf - bit 5, [hl] - jr z, .asm_3e8d3 + ld hl, Func_3e88c + jp .cannotUseMove +.checkIfFrozen + bit FRZ, [hl] + jr z, .checkIfTrapped ld hl, IsFrozenText call PrintText xor a ld [wccf2], a - ld hl, Func_3e88c ; $688c - jp Func_3eab8 -.asm_3e8d3 - ld a, [W_PLAYERBATTSTATUS1] ; W_PLAYERBATTSTATUS1 - bit 5, a - jp z, Func_3e8e7 + ld hl, Func_3e88c + jp .cannotUseMove +.checkIfTrapped + ld a, [W_PLAYERBATTSTATUS1] + bit 5, a ; is the player using a multi-turn attack like warp + jp z, .checkIfFlinched ld hl, CantMoveText call PrintText - ld hl, Func_3e88c ; $688c - jp Func_3eab8 - -Func_3e8e7: ; 3e8e7 (f:68e7) - ld hl, W_ENEMYBATTSTATUS1 ; W_ENEMYBATTSTATUS1 - bit 3, [hl] - jp z, Func_3e8fd + ld hl, Func_3e88c + jp .cannotUseMove +.checkIfFlinched + ld hl, W_ENEMYBATTSTATUS1 + bit 3, [hl] ; check if enemy mon flinched + jp z, .checkIfMustRecharge res 3, [hl] ld hl, FlinchedText call PrintText - ld hl, Func_3e88c ; $688c - jp Func_3eab8 - -Func_3e8fd: ; 3e8fd (f:68fd) - ld hl, W_ENEMYBATTSTATUS2 ; W_ENEMYBATTSTATUS2 - bit 5, [hl] - jr z, .asm_3e912 + ld hl, Func_3e88c + jp .cannotUseMove +.checkIfMustRecharge + ld hl, W_ENEMYBATTSTATUS2 + bit 5, [hl] ; check if enemy mon has to recharge after using a move + jr z, .checkIfAnyMoveDisabled res 5, [hl] ld hl, MustRechargeText call PrintText - ld hl, Func_3e88c ; $688c - jp Func_3eab8 -.asm_3e912 - ld hl, W_ENEMYDISABLEDMOVE ; W_ENEMYDISABLEDMOVE + ld hl, Func_3e88c + jp .cannotUseMove +.checkIfAnyMoveDisabled + ld hl, W_ENEMYDISABLEDMOVE ld a, [hl] and a - jr z, .asm_3e929 + jr z, .checkIfConfused dec a ld [hl], a and $f - jr nz, .asm_3e929 + jr nz, .checkIfConfused ld [hl], a ld [wccef], a ld hl, DisabledNoMoreText call PrintText -.asm_3e929 - ld a, [W_ENEMYBATTSTATUS1] ; W_ENEMYBATTSTATUS1 - add a - jp nc, Func_3e9aa +.checkIfConfused + ld a, [W_ENEMYBATTSTATUS1] + add a ; check if enemy mon is confused + jp nc, .checkIfTriedToUseDisabledMove ld hl, wd070 dec [hl] - jr nz, .asm_3e944 - ld hl, W_ENEMYBATTSTATUS1 ; W_ENEMYBATTSTATUS1 + jr nz, .isConfused + ld hl, W_ENEMYBATTSTATUS1 res 7, [hl] ld hl, ConfusedNoMoreText call PrintText - jp Func_3e9aa -.asm_3e944 + jp .checkIfTriedToUseDisabledMove +.isConfused ld hl, IsConfusedText call PrintText xor a @@ -5738,8 +5862,8 @@ Func_3e8fd: ; 3e8fd (f:68fd) call PlayMoveAnimation call BattleRandom cp $80 - jr c, Func_3e9aa - ld hl, W_ENEMYBATTSTATUS1 ; W_ENEMYBATTSTATUS1 + jr c, .checkIfTriedToUseDisabledMove + ld hl, W_ENEMYBATTSTATUS1 ld a, [hl] and $80 ld [hl], a @@ -5750,23 +5874,23 @@ Func_3e8fd: ; 3e8fd (f:68fd) push af ld a, [hld] push af - ld a, [wEnemyMonDefense] ; wcff8 + ld a, [wEnemyMonDefense] ld [hli], a ld a, [wEnemyMonDefense + 1] ld [hl], a - ld hl, W_ENEMYMOVEEFFECT ; W_ENEMYMOVEEFFECT + ld hl, W_ENEMYMOVEEFFECT push hl ld a, [hl] push af xor a ld [hli], a - ld [wd05e], a + ld [wCriticalHitOrOHKO], a ld a, $28 ld [hli], a xor a ld [hl], a - call Func_3de75 - call MoreCalculateDamage + call GetDamageVarsForEnemyAttack + call CalculateDamage pop af pop hl ld [hl], a @@ -5777,59 +5901,58 @@ Func_3e8fd: ; 3e8fd (f:68fd) ld [hl], a xor a ld [wcc5b], a - ld [H_WHOSETURN], a ; $fff3 + ld [H_WHOSETURN], a ld a, POUND call PlayMoveAnimation ld a, $1 - ld [H_WHOSETURN], a ; $fff3 + ld [H_WHOSETURN], a call ApplyDamageToEnemyPokemon - jr asm_3e9d3 - -Func_3e9aa: ; 3e9aa (f:69aa) + jr .monHurtItselfOrFullyParalysed +.checkIfTriedToUseDisabledMove ld a, [wccef] and a - jr z, .asm_3e9bf - ld hl, wEnemySelectedMove ; wccdd + jr z, .checkIfParalysed + ld hl, wEnemySelectedMove cp [hl] - jr nz, .asm_3e9bf + jr nz, .checkIfParalysed call PrintMoveIsDisabledText - ld hl, Func_3e88c ; $688c - jp Func_3eab8 -.asm_3e9bf - ld hl, wEnemyMonStatus ; wcfe9 - bit 6, [hl] - jr z, asm_3e9f6 + ld hl, Func_3e88c + jp .cannotUseMove +.checkIfParalysed + ld hl, wEnemyMonStatus + bit PAR, [hl] + jr z, .checkIfUsingBide call BattleRandom cp $3f - jr nc, asm_3e9f6 + jr nc, .checkIfUsingBide ld hl, FullyParalyzedText call PrintText -asm_3e9d3: ; 3e9d3 (f:69d3) - ld hl, W_ENEMYBATTSTATUS1 ; W_ENEMYBATTSTATUS1 +.monHurtItselfOrFullyParalysed + ld hl, W_ENEMYBATTSTATUS1 ld a, [hl] - and $cc + and $cc ; clear bide, thrashing, charging up, and multi-turn moves such as warp ld [hl], a - ld a, [W_ENEMYMOVEEFFECT] ; W_ENEMYMOVEEFFECT + ld a, [W_ENEMYMOVEEFFECT] cp FLY_EFFECT - jr z, .asm_3e9e7 + jr z, .flyOrChargeEffect cp CHARGE_EFFECT - jr z, .asm_3e9e7 - jr .asm_3e9f0 -.asm_3e9e7 + jr z, .flyOrChargeEffect + jr .notFlyOrChargeEffect +.flyOrChargeEffect xor a ld [wcc5b], a ld a, STATUS_AFFECTED_ANIM call PlayMoveAnimation -.asm_3e9f0 - ld hl, Func_3e88c ; $688c - jp Func_3eab8 -asm_3e9f6: ; 3e9f6 (f:69f6) - ld hl, W_ENEMYBATTSTATUS1 ; W_ENEMYBATTSTATUS1 +.notFlyOrChargeEffect + ld hl, Func_3e88c + jp .cannotUseMove +.checkIfUsingBide + ld hl, W_ENEMYBATTSTATUS1 bit 0, [hl] ; is mon using bide? - jr z, .asm_3ea54 + jr z, .checkIfThrashingAbout xor a - ld [W_ENEMYMOVENUM], a ; W_ENEMYMOVENUM - ld hl, W_DAMAGE ; W_DAMAGE + ld [W_ENEMYMOVENUM], a + ld hl, W_DAMAGE ld a, [hli] ld b, a ld c, [hl] @@ -5840,18 +5963,18 @@ asm_3e9f6: ; 3e9f6 (f:69f6) ld a, [hl] adc b ld [hl], a - ld hl, wd06f + ld hl, wEnemyNumAttacksLeft dec [hl] - jr z, .asm_3ea1c - ld hl, Func_3e88c ; $688c - jp Func_3eab8 -.asm_3ea1c - ld hl, W_ENEMYBATTSTATUS1 ; W_ENEMYBATTSTATUS1 - res 0, [hl] + jr z, .unleashEnergy + ld hl, Func_3e88c + jp .cannotUseMove +.unleashEnergy + ld hl, W_ENEMYBATTSTATUS1 + res 0, [hl] ; not using bide any more ld hl, UnleashedEnergyText call PrintText ld a, $1 - ld [W_ENEMYMOVEPOWER], a ; wcfce + ld [W_ENEMYMOVEPOWER], a ld hl, wcd06 ld a, [hld] add a @@ -5859,33 +5982,33 @@ asm_3e9f6: ; 3e9f6 (f:69f6) ld [wd0d8], a ld a, [hl] rl a - ld [W_DAMAGE], a ; W_DAMAGE + ld [W_DAMAGE], a or b - jr nz, .asm_3ea43 + jr nz, .next2 ld a, $1 - ld [W_MOVEMISSED], a ; W_MOVEMISSED -.asm_3ea43 + ld [W_MOVEMISSED], a +.next2 xor a ld [hli], a ld [hl], a ld a, BIDE - ld [W_ENEMYMOVENUM], a ; W_ENEMYMOVENUM - call Func_3ec81 - ld hl, asm_3e782 ; $6782 - jp Func_3eab8 -.asm_3ea54 + ld [W_ENEMYMOVENUM], a + call SwapPlayerAndEnemyLevels + ld hl, asm_3e782 + jp .cannotUseMove +.checkIfThrashingAbout bit 1, [hl] ; is mon using thrash or petal dance? - jr z, .asm_3ea83 + jr z, .checkIfUsingMultiturnMove ld a, THRASH - ld [W_ENEMYMOVENUM], a ; W_ENEMYMOVENUM + ld [W_ENEMYMOVENUM], a ld hl, ThrashingAboutText call PrintText - ld hl, wd06f + ld hl, wEnemyNumAttacksLeft dec [hl] - ld hl, asm_3e750 ; $6750 - jp nz, Func_3eab8 + ld hl, asm_3e750 + jp nz, .cannotUseMove push hl - ld hl, W_ENEMYBATTSTATUS1 ; W_ENEMYBATTSTATUS1 + ld hl, W_ENEMYBATTSTATUS1 res 1, [hl] ; mon is no longer using thrash or petal dance set 7, [hl] ; mon is now confused call BattleRandom @@ -5894,58 +6017,55 @@ asm_3e9f6: ; 3e9f6 (f:69f6) inc a ld [wd070], a pop hl - jp Func_3eab8 -.asm_3ea83 + jp .cannotUseMove +.checkIfUsingMultiturnMove bit 5, [hl] ; is mon using multi-turn move? - jp z, Func_3ea9b + jp z, .checkIfUsingRage ld hl, AttackContinuesText call PrintText - ld hl, wd06f + ld hl, wEnemyNumAttacksLeft dec [hl] - ld hl, Func_3e794 ; $6794 - jp nz, Func_3eab8 - jp Func_3eab8 - -Func_3ea9b: ; 3ea9b (f:6a9b) - ld a, [W_ENEMYBATTSTATUS2] ; W_ENEMYBATTSTATUS2 + ld hl, Func_3e794 + jp nz, .cannotUseMove + jp .cannotUseMove +.checkIfUsingRage + ld a, [W_ENEMYBATTSTATUS2] bit 6, a ; is mon using rage? - jp z, Func_3eaba + jp z, .canUseMove ld a, RAGE ld [wd11e], a call GetMoveName call CopyStringToCF4B xor a - ld [W_ENEMYMOVEEFFECT], a ; W_ENEMYMOVEEFFECT - ld hl, asm_3e72b ; $672b - jp Func_3eab8 - -Func_3eab8: ; 3eab8 (f:6ab8) - xor a + ld [W_ENEMYMOVEEFFECT], a + ld hl, asm_3e72b + jp .cannotUseMove +.cannotUseMove + xor a ; set Z flag ret - -Func_3eaba: ; 3eaba (f:6aba) +.canUseMove ld a, $1 - and a + and a ; clear Z flag ret GetCurrentMove: ; 3eabe (f:6abe) - ld a, [H_WHOSETURN] ; $fff3 + ld a, [H_WHOSETURN] and a jp z, .player - ld de, W_ENEMYMOVENUM ; W_ENEMYMOVENUM - ld a, [wEnemySelectedMove] ; wccdd + ld de, W_ENEMYMOVENUM + ld a, [wEnemySelectedMove] jr .selected .player - ld de, W_PLAYERMOVENUM ; wcfd2 + ld de, W_PLAYERMOVENUM ld a, [W_FLAGS_D733] bit 0, a ld a, [wccd9] jr nz, .selected - ld a, [wPlayerSelectedMove] ; wPlayerSelectedMove + ld a, [wPlayerSelectedMove] .selected ld [wd0b5], a dec a - ld hl, Moves ; $4000 + ld hl, Moves ld bc, $6 call AddNTimes ld a, BANK(Moves) @@ -5958,73 +6078,77 @@ GetCurrentMove: ; 3eabe (f:6abe) ld de, wcd6d jp CopyStringToCF4B -Func_3eb01: ; 3eb01 (f:6b01) - ld a, [W_ISLINKBATTLE] ; W_ISLINKBATTLE +LoadEnemyMonData: ; 3eb01 (f:6b01) + ld a, [W_ISLINKBATTLE] cp $4 - jp z, Func_3cc13 + jp z, LoadEnemyMonFromParty ld a, [wEnemyMonSpecies2] ld [wEnemyMonSpecies], a ld [wd0b5], a call GetMonHeader - ld a, [W_ENEMYBATTSTATUS3] ; W_ENEMYBATTSTATUS3 - bit 3, a - ld hl, wcceb + ld a, [W_ENEMYBATTSTATUS3] + bit 3, a ; is enemy mon transformed? + ld hl, wcceb ; copied DVs from when it used Transform ld a, [hli] ld b, [hl] - jr nz, .asm_3eb33 - ld a, [W_ISINBATTLE] ; W_ISINBATTLE - cp $2 + jr nz, .storeDVs + ld a, [W_ISINBATTLE] + cp $2 ; is it a trainer battle? +; fixed DVs for trainer mon ld a, $98 ld b, $88 - jr z, .asm_3eb33 + jr z, .storeDVs +; random DVs for wild mon call BattleRandom ld b, a call BattleRandom -.asm_3eb33 +.storeDVs ld hl, wEnemyMonDVs ld [hli], a ld [hl], b - ld de, wEnemyMonLevel ; wEnemyMonLevel - ld a, [W_CURENEMYLVL] ; W_CURENEMYLVL + ld de, wEnemyMonLevel + ld a, [W_CURENEMYLVL] ld [de], a inc de ld b, $0 - ld hl, wEnemyMonHP ; wEnemyMonHP + ld hl, wEnemyMonHP push hl call CalcStats pop hl - ld a, [W_ISINBATTLE] ; W_ISINBATTLE - cp $2 - jr z, .asm_3eb65 - ld a, [W_ENEMYBATTSTATUS3] ; W_ENEMYBATTSTATUS3 - bit 3, a - jr nz, .asm_3eb86 - ld a, [wEnemyMonMaxHP] ; wEnemyMonMaxHP + ld a, [W_ISINBATTLE] + cp $2 ; is it a trainer battle? + jr z, .copyHPAndStatusFromPartyData + ld a, [W_ENEMYBATTSTATUS3] + bit 3, a ; is enemy mon transformed? + jr nz, .copyTypes ; if transformed, jump +; if it's a wild mon and not transformed, init the current HP to max HP and the status to 0 + ld a, [wEnemyMonMaxHP] ld [hli], a ld a, [wEnemyMonMaxHP+1] ld [hli], a xor a inc hl - ld [hl], a - jr .asm_3eb86 -.asm_3eb65 - ld hl, wEnemyMon1HP ; wd8a5 (aliases: W_WATERMONS) - ld a, [wWhichPokemon] ; wWhichPokemon + ld [hl], a ; init status to 0 + jr .copyTypes +; if it's a trainer mon, copy the HP and status from the enemy party data +.copyHPAndStatusFromPartyData + ld hl, wEnemyMon1HP + ld a, [wWhichPokemon] ld bc, wEnemyMon2 - wEnemyMon1 call AddNTimes ld a, [hli] - ld [wEnemyMonHP], a ; wEnemyMonHP + ld [wEnemyMonHP], a ld a, [hli] ld [wEnemyMonHP + 1], a - ld a, [wWhichPokemon] ; wWhichPokemon + ld a, [wWhichPokemon] ld [wEnemyMonPartyPos], a inc hl ld a, [hl] - ld [wEnemyMonStatus], a ; wcfe9 - jr .asm_3eb86 -.asm_3eb86 + ld [wEnemyMonStatus], a + jr .copyTypes +.copyTypes ld hl, W_MONHTYPES - ld de, wEnemyMonType ; wcfea + ld de, wEnemyMonType ld a, [hli] ; copy type 1 ld [de], a inc de @@ -6034,17 +6158,19 @@ Func_3eb01: ; 3eb01 (f:6b01) ld a, [hli] ; copy catch rate ld [de], a inc de - ld a, [W_ISINBATTLE] ; W_ISINBATTLE - cp $2 - jr nz, .asm_3ebb0 + ld a, [W_ISINBATTLE] + cp $2 ; is it a trainer battle? + jr nz, .copyStandardMoves +; if it's a trainer battle, copy moves from enemy party data ld hl, wEnemyMon1Moves - ld a, [wWhichPokemon] ; wWhichPokemon + ld a, [wWhichPokemon] ld bc, wEnemyMon2 - wEnemyMon1 call AddNTimes ld bc, NUM_MOVES call CopyData - jr .asm_3ebca -.asm_3ebb0 + jr .loadMovePPs +.copyStandardMoves +; for a wild mon, first copy default moves from the mon header ld hl, W_MONHMOVES ld a, [hli] ld [de], a @@ -6062,20 +6188,20 @@ Func_3eb01: ; 3eb01 (f:6b01) dec de xor a ld [wHPBarMaxHP], a - predef WriteMonMoves -.asm_3ebca + predef WriteMonMoves ; get moves based on current level +.loadMovePPs ld hl, wEnemyMonMoves ld de, wEnemyMonSpecial + 1 predef LoadMovePPs ld hl, W_MONHBASESTATS - ld de, wd002 + ld de, wEnemyMonBaseStats ld b, $5 -.asm_3ebdd +.copyBaseStatsLoop ld a, [hli] ld [de], a inc de dec b - jr nz, .asm_3ebdd + jr nz, .copyBaseStatsLoop ld hl, W_MONHCATCHRATE ld a, [hli] ld [de], a @@ -6096,45 +6222,47 @@ Func_3eb01: ; 3eb01 (f:6b01) dec a ld c, a ld b, $1 - ld hl, wPokedexSeen ; wd30a - predef FlagActionPredef - ld hl, wEnemyMonLevel ; wEnemyMonLevel - ld de, wcd23 + ld hl, wPokedexSeen + predef FlagActionPredef ; mark this mon as seen in the pokedex + ld hl, wEnemyMonLevel + ld de, wEnemyMonUnmodifiedLevel ld bc, $b call CopyData - ld a, $7 - ld b, $8 - ld hl, wEnemyMonStatMods ; wcd2e -.asm_3ec2d + ld a, $7 ; default stat mod + ld b, $8 ; number of stat mods + ld hl, wEnemyMonStatMods +.statModLoop ld [hli], a dec b - jr nz, .asm_3ec2d + jr nz, .statModLoop ret -Func_3ec32: ; 3ec32 (f:6c32) - ld a, [W_ISLINKBATTLE] ; W_ISLINKBATTLE +; calls BattleTransition to show the battle transition animation and initializes some battle variables +DoBattleTransitionAndInitBattleVariables: ; 3ec32 (f:6c32) + ld a, [W_ISLINKBATTLE] cp $4 - jr nz, .asm_3ec4d + jr nz, .next +; link battle xor a - ld [wMenuJoypadPollCount], a ; wMenuJoypadPollCount - callab Func_372d6 + ld [wMenuJoypadPollCount], a + callab DisplayLinkBattleVersusTextBox ld a, $1 ld [wcfcb], a call ClearScreen -.asm_3ec4d +.next call DelayFrame predef BattleTransition - callab Func_3ee58 + callab LoadHudAndHpBarAndStatusTilePatterns ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba + ld [H_AUTOBGTRANSFERENABLED], a ld a, $ff ld [wcfcb], a call ClearSprites call ClearScreen xor a - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba - ld [$ffb0], a - ld [rWY], a ; $ff4a + ld [H_AUTOBGTRANSFERENABLED], a + ld [hVBlankWY], a + ld [rWY], a ld [$ffd7], a ld hl, wd060 ld [hli], a @@ -6142,61 +6270,65 @@ Func_3ec32: ; 3ec32 (f:6c32) ld [hli], a ld [hli], a ld [hl], a - ld [W_PLAYERDISABLEDMOVE], a ; W_PLAYERDISABLEDMOVE + ld [W_PLAYERDISABLEDMOVE], a ret -Func_3ec81: ; 3ec81 (f:6c81) +; swaps the level values of the BattleMon and EnemyMon structs +SwapPlayerAndEnemyLevels: ; 3ec81 (f:6c81) push bc - ld a, [wBattleMonLevel] ; wBattleMonLevel + ld a, [wBattleMonLevel] ld b, a - ld a, [wEnemyMonLevel] ; wEnemyMonLevel - ld [wBattleMonLevel], a ; wBattleMonLevel + ld a, [wEnemyMonLevel] + ld [wBattleMonLevel], a ld a, b - ld [wEnemyMonLevel], a ; wEnemyMonLevel + ld [wEnemyMonLevel], a pop bc ret -Func_3ec92: ; 3ec92 (f:6c92) - ld a, [W_BATTLETYPE] ; wd05a - dec a - ld de, RedPicBack ; $7e0a - jr nz, .asm_3ec9e - ld de, OldManPic ; $7e9a -.asm_3ec9e +; loads either red back pic or old man back pic +; also writes OAM data and loads tile patterns for the Red or Old Man back sprite's head +; (for use when scrolling the player sprite and enemy's silhouettes on screen) +LoadPlayerBackPic: ; 3ec92 (f:6c92) + ld a, [W_BATTLETYPE] + dec a ; is it the old man tutorial? + ld de, RedPicBack + jr nz, .next + ld de, OldManPic +.next ld a, BANK(RedPicBack) call UncompressSpriteFromDE predef ScaleSpriteByTwo ld hl, wOAMBuffer xor a - ld [H_DOWNARROWBLINKCNT1], a ; $ff8b - ld b, $7 - ld e, $a0 -.asm_3ecb2 - ld c, $3 - ld d, $38 -.asm_3ecb6 - ld [hl], d + ld [$FF8B], a ; initial tile number + ld b, $7 ; 7 columns + ld e, $a0 ; X for the left-most column +.loop ; each loop iteration writes 3 OAM entries in a vertical column + ld c, $3 ; 3 tiles per column + ld d, $38 ; Y for the top of each column +.innerLoop ; each loop iteration writes 1 OAM entry in the column + ld [hl], d ; OAM Y inc hl - ld [hl], e - ld a, $8 - add d + ld [hl], e ; OAM X + ld a, $8 ; height of tile + add d ; increase Y by height of tile ld d, a inc hl - ld a, [H_DOWNARROWBLINKCNT1] ; $ff8b - ld [hli], a - inc a - ld [H_DOWNARROWBLINKCNT1], a ; $ff8b + ld a, [$FF8B] + ld [hli], a ; OAM tile number + inc a ; increment tile number + ld [$FF8B], a inc hl dec c - jr nz, .asm_3ecb6 - ld a, [H_DOWNARROWBLINKCNT1] ; $ff8b - add $4 - ld [H_DOWNARROWBLINKCNT1], a ; $ff8b - ld a, $8 - add e + jr nz, .innerLoop + ld a, [$FF8B] + add $4 ; increase tile number by 4 + ld [$FF8B], a + ld a, $8 ; width of tile + add e ; increase X by width of tile ld e, a dec b - jr nz, .asm_3ecb2 + jr nz, .loop ld de, vBackPic call InterlaceMergeSpriteBuffers ld a, $a @@ -6227,24 +6359,26 @@ ScrollTrainerPicAfterBattle: ; 3ed12 (f:6d12) ld b, BANK(_ScrollTrainerPicAfterBattle) jp Bankswitch -Func_3ed1a: ; 3ed1a (f:6d1a) +ApplyBurnAndParalysisPenaltiesToPlayer: ; 3ed1a (f:6d1a) ld a, $1 - jr asm_3ed1f + jr ApplyBurnAndParalysisPenalties -Func_3ed1e: ; 3ed1e (f:6d1e) +ApplyBurnAndParalysisPenaltiesToEnemy: ; 3ed1e (f:6d1e) xor a -asm_3ed1f: ; 3ed1f (f:6d1f) - ld [H_WHOSETURN], a ; $fff3 - call Func_3ed27 - jp Func_3ed64 -Func_3ed27: ; 3ed27 (f:6d27) - ld a, [H_WHOSETURN] ; $fff3 +ApplyBurnAndParalysisPenalties: ; 3ed1f (f:6d1f) + ld [H_WHOSETURN], a + call QuarterSpeedDueToParalysis + jp HalveAttackDueToBurn + +QuarterSpeedDueToParalysis: ; 3ed27 (f:6d27) + ld a, [H_WHOSETURN] and a - jr z, .asm_3ed48 - ld a, [wBattleMonStatus] ; wBattleMonStatus - and $40 - ret z + jr z, .playerTurn +.enemyTurn ; quarter the player's speed + ld a, [wBattleMonStatus] + and 1 << PAR + ret z ; return if player not paralysed ld hl, wBattleMonSpeed + 1 ld a, [hld] ld b, a @@ -6255,15 +6389,15 @@ Func_3ed27: ; 3ed27 (f:6d27) rr b ld [hli], a or b - jr nz, .asm_3ed46 - ld b, $1 -.asm_3ed46 + jr nz, .storePlayerSpeed + ld b, 1 ; give the player a minimum of at least one speed point +.storePlayerSpeed ld [hl], b ret -.asm_3ed48 - ld a, [wEnemyMonStatus] ; wcfe9 - and $40 - ret z +.playerTurn ; quarter the enemy's speed + ld a, [wEnemyMonStatus] + and 1 << PAR + ret z ; return if enemy not paralysed ld hl, wEnemyMonSpeed + 1 ld a, [hld] ld b, a @@ -6274,19 +6408,20 @@ Func_3ed27: ; 3ed27 (f:6d27) rr b ld [hli], a or b - jr nz, .asm_3ed62 - ld b, $1 -.asm_3ed62 + jr nz, .storeEnemySpeed + ld b, 1 ; give the enemy a minimum of at least one speed point +.storeEnemySpeed ld [hl], b ret -Func_3ed64: ; 3ed64 (f:6d64) - ld a, [H_WHOSETURN] ; $fff3 +HalveAttackDueToBurn: ; 3ed64 (f:6d64) + ld a, [H_WHOSETURN] and a - jr z, .asm_3ed81 - ld a, [wBattleMonStatus] ; wBattleMonStatus - and $10 - ret z + jr z, .playerTurn +.enemyTurn ; halve the player's attack + ld a, [wBattleMonStatus] + and 1 << BRN + ret z ; return if player not burnt ld hl, wBattleMonAttack + 1 ld a, [hld] ld b, a @@ -6295,15 +6430,15 @@ Func_3ed64: ; 3ed64 (f:6d64) rr b ld [hli], a or b - jr nz, .asm_3ed7f - ld b, $1 -.asm_3ed7f + jr nz, .storePlayerAttack + ld b, 1 ; give the player a minimum of at least one attack point +.storePlayerAttack ld [hl], b ret -.asm_3ed81 - ld a, [wEnemyMonStatus] ; wcfe9 - and $10 - ret z +.playerTurn ; halve the enemy's attack + ld a, [wEnemyMonStatus] + and 1 << BRN + ret z ; return if enemy not burnt ld hl, wEnemyMonAttack + 1 ld a, [hld] ld b, a @@ -6312,119 +6447,128 @@ Func_3ed64: ; 3ed64 (f:6d64) rr b ld [hli], a or b - jr nz, .asm_3ed97 - ld b, $1 -.asm_3ed97 + jr nz, .storeEnemyAttack + ld b, 1 ; give the enemy a minimum of at least one attack point +.storeEnemyAttack ld [hl], b ret -Func_3ed99: ; 3ed99 (f:6d99) - ld c, $0 -.asm_3ed9b - call Func_3eda5 +CalculateModifiedStats: ; 3ed99 (f:6d99) + ld c, 0 +.loop + call CalculateModifiedStat inc c ld a, c - cp $4 - jr nz, .asm_3ed9b + cp 4 + jr nz, .loop ret -Func_3eda5: ; 3eda5 (f:6da5) +; calculate modified stat for stat c (0 = attack, 1 = defense, 2 = speed, 3 = special) +CalculateModifiedStat: ; 3eda5 (f:6da5) push bc push bc ld a, [wd11e] and a ld a, c ld hl, wBattleMonAttack - ld de, wcd12 - ld bc, wPlayerMonAttackMod ; wcd1a - jr z, .asm_3edc0 + ld de, wPlayerMonUnmodifiedAttack + ld bc, wPlayerMonAttackMod + jr z, .next ld hl, wEnemyMonAttack - ld de, wcd26 - ld bc, wEnemyMonStatMods ; wcd2e -.asm_3edc0 + ld de, wEnemyMonUnmodifiedAttack + ld bc, wEnemyMonStatMods +.next add c ld c, a - jr nc, .asm_3edc5 + jr nc, .noCarry1 inc b -.asm_3edc5 +.noCarry1 ld a, [bc] pop bc ld b, a push bc sla c - ld b, $0 + ld b, 0 add hl, bc ld a, c add e ld e, a - jr nc, .asm_3edd4 + jr nc, .noCarry2 inc d -.asm_3edd4 +.noCarry2 pop bc push hl - ld hl, StatModifierRatios ; $76cb + ld hl, StatModifierRatios dec b sla b ld c, b - ld b, $0 + ld b, 0 add hl, bc xor a - ld [H_NUMTOPRINT], a ; $ff96 (aliases: H_MULTIPLICAND) + ld [H_MULTIPLICAND], a ld a, [de] - ld [$ff97], a + ld [H_MULTIPLICAND + 1], a inc de ld a, [de] - ld [$ff98], a + ld [H_MULTIPLICAND + 2], a ld a, [hli] - ld [H_REMAINDER], a ; $ff99 (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) + ld [H_MULTIPLIER], a call Multiply ld a, [hl] - ld [H_REMAINDER], a ; $ff99 (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) + ld [H_DIVISOR], a ld b, $4 call Divide pop hl - ld a, [$ff98] - sub $e7 - ld a, [$ff97] - sbc $3 - jp c, Func_3ee0c - ld a, $3 - ld [$ff97], a - ld a, $e7 - ld [$ff98], a - -Func_3ee0c: ; 3ee0c (f:6e0c) - ld a, [$ff97] + ld a, [H_DIVIDEND + 3] + sub 999 % $100 + ld a, [H_DIVIDEND + 2] + sbc 999 / $100 + jp c, .storeNewStatValue +; cap the stat at 999 + ld a, 999 / $100 + ld [H_DIVIDEND + 2], a + ld a, 999 % $100 + ld [H_DIVIDEND + 3], a +.storeNewStatValue + ld a, [H_DIVIDEND + 2] ld [hli], a ld b, a - ld a, [$ff98] + ld a, [H_DIVIDEND + 3] ld [hl], a or b - jr nz, .asm_3ee17 - inc [hl] -.asm_3ee17 + jr nz, .done + inc [hl] ; if the stat is 0, bump it up to 1 +.done pop bc ret -Func_3ee19: ; 3ee19 (f:6e19) +ApplyBadgeStatBoosts: ; 3ee19 (f:6e19) ld a, [W_ISLINKBATTLE] cp $4 - ret z + ret z ; return if link battle ld a, [W_OBTAINEDBADGES] ld b, a ld hl, wBattleMonAttack ld c, $4 -.asm_3ee28 +; the boost is applied for badges whose bit position is even +; the order of boosts matches the order they are laid out in RAM +; Boulder (bit 0) - attack +; Thunder (bit 2) - defense +; Soul (bit 4) - speed +; Volcano (bit 6) - special +.loop srl b - call c, Func_3ee35 + call c, .applyBoostToStat inc hl inc hl srl b dec c - jr nz, .asm_3ee28 + jr nz, .loop ret -Func_3ee35: ; 3ee35 (f:6e35) +; multiply stat at hl by 1.125 +; cap stat at 999 +.applyBoostToStat ld a, [hli] ld d, a ld e, [hl] @@ -6441,48 +6585,48 @@ Func_3ee35: ; 3ee35 (f:6e35) adc d ld [hli], a ld a, [hld] - sub $e7 + sub 999 % $100 ld a, [hl] - sbc $3 + sbc 999 / $100 ret c - ld a, $3 + ld a, 999 / $100 ld [hli], a - ld a, $e7 + ld a, 999 % $100 ld [hld], a ret -Func_3ee58: ; 3ee58 (f:6e58) +LoadHudAndHpBarAndStatusTilePatterns: ; 3ee58 (f:6e58) call LoadHpBarAndStatusTilePatterns -Func_3ee5b: ; 3ee5b (f:6e5b) - ld a, [rLCDC] ; $ff40 - add a - jr c, .asm_3ee7c - ld hl, BattleHudTiles1 ; $6080 +LoadHudTilePatterns: ; 3ee5b (f:6e5b) + ld a, [rLCDC] + add a ; is LCD disabled? + jr c, .lcdEnabled +.lcdDisabled + ld hl, BattleHudTiles1 ld de, vChars2 + $6d0 ld bc, $18 ld a, BANK(BattleHudTiles1) call FarCopyDataDouble - ld hl, BattleHudTiles2 ; $6098 + ld hl, BattleHudTiles2 ld de, vChars2 + $730 ld bc, $30 ld a, BANK(BattleHudTiles2) jp FarCopyDataDouble -.asm_3ee7c - ld de, BattleHudTiles1 ; $6080 +.lcdEnabled + ld de, BattleHudTiles1 ld hl, vChars2 + $6d0 ld bc, (BANK(BattleHudTiles1) << 8) + $03 call CopyVideoDataDouble - ld de, BattleHudTiles2 ; $6098 + ld de, BattleHudTiles2 ld hl, vChars2 + $730 ld bc, (BANK(BattleHudTiles2) << 8) + $06 jp CopyVideoDataDouble -Func_3ee94: ; 3ee94 (f:6e94) - ld hl, TerminatorText_3ee9a ; $6e9a +PrintEmptyString: ; 3ee94 (f:6e94) + ld hl, .emptyString jp PrintText - -TerminatorText_3ee9a: ; 3ee9a (f:6e9a) +.emptyString db "@" @@ -6535,15 +6679,15 @@ BattleRandom: Func_3eed3: ; 3eed3 (f:6ed3) - ld a, [H_WHOSETURN] ; $fff3 + ld a, [H_WHOSETURN] and a ld hl, wEnemyMonType1 ; wcfea (aliases: wEnemyMonType) - ld de, W_ENEMYBATTSTATUS1 ; W_ENEMYBATTSTATUS1 - ld a, [W_PLAYERMOVENUM] ; wcfd2 + ld de, W_ENEMYBATTSTATUS1 + ld a, [W_PLAYERMOVENUM] jr z, .asm_3eeea ld hl, wBattleMonType1 ; wd019 (aliases: wBattleMonType) - ld de, W_ENEMYBATTSTATUS1 ; W_ENEMYBATTSTATUS1 - ld a, [W_ENEMYMOVENUM] ; W_ENEMYMOVENUM + ld de, W_ENEMYBATTSTATUS1 + ld a, [W_ENEMYMOVENUM] .asm_3eeea cp SELFDESTRUCT jr z, .asm_3eef1 @@ -6559,7 +6703,7 @@ Func_3eed3: ; 3eed3 (f:6ed3) ld a, [hl] cp GHOST ret z - ld a, [W_MOVEMISSED] ; W_MOVEMISSED + ld a, [W_MOVEMISSED] and a ret nz ld a, MEGA_PUNCH @@ -6571,12 +6715,12 @@ PlayMoveAnimation: ; 3ef07 (f:6f07) predef_jump MoveAnimation InitBattle: ; 3ef12 (f:6f12) - ld a, [W_CUROPPONENT] ; wd059 + ld a, [W_CUROPPONENT] and a jr z, asm_3ef23 InitOpponent: ; 3ef18 (f:6f18) - ld a, [W_CUROPPONENT] ; wd059 + ld a, [W_CUROPPONENT] ld [wcf91], a ld [wEnemyMonSpecies2], a jr asm_3ef3d @@ -6604,30 +6748,30 @@ asm_3ef3d: ; 3ef3d (f:6f3d) ld a, [wEnemyMonSpecies2] sub $c8 jp c, InitWildBattle - ld [W_TRAINERCLASS], a ; wd031 + ld [W_TRAINERCLASS], a call GetTrainerInformation callab ReadTrainer - call Func_3ec32 + call DoBattleTransitionAndInitBattleVariables call _LoadTrainerPic xor a ld [wEnemyMonSpecies2], a ld [$ffe1], a dec a - ld [wAICount], a ; wccdf + ld [wAICount], a hlCoord 12, 0 predef Func_3f0c6 ld a, $ff ld [wEnemyMonPartyPos], a ld a, $2 - ld [W_ISINBATTLE], a ; W_ISINBATTLE - jp Func_3efeb + ld [W_ISINBATTLE], a + jp InitBattle_Common InitWildBattle: ; 3ef8b (f:6f8b) ld a, $1 - ld [W_ISINBATTLE], a ; W_ISINBATTLE - call Func_3eb01 - call Func_3ec32 - ld a, [W_CUROPPONENT] ; wd059 + ld [W_ISINBATTLE], a + call LoadEnemyMonData + call DoBattleTransitionAndInitBattleVariables + ld a, [W_CUROPPONENT] cp MAROWAK jr z, .isGhost call IsGhostBattle @@ -6636,7 +6780,7 @@ InitWildBattle: ; 3ef8b (f:6f8b) ld hl, W_MONHSPRITEDIM ld a, $66 ld [hli], a ; write sprite dimensions - ld bc, GhostPic ; $66b5 + ld bc, GhostPic ld a, c ld [hli], a ; write front sprite pointer ld [hl], b @@ -6666,25 +6810,26 @@ InitWildBattle: ; 3ef8b (f:6f8b) call LoadMonFrontSprite ; load mon sprite .spriteLoaded xor a - ld [W_TRAINERCLASS], a ; wd031 + ld [W_TRAINERCLASS], a ld [$ffe1], a hlCoord 12, 0 predef Func_3f0c6 -Func_3efeb: ; 3efeb (f:6feb) +; common code that executes after init battle code specific to trainer or wild battles +InitBattle_Common: ; 3efeb (f:6feb) ld b, $0 call GoPAL_SET - call Func_3c04c + call SlidePlayerAndEnemySilhouettesOnScreen xor a - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba - ld hl, TerminatorText_3f04a + ld [H_AUTOBGTRANSFERENABLED], a + ld hl, .emptyString call PrintText call SaveScreenTilesToBuffer1 call ClearScreen ld a, $98 ld [$ffbd], a ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba + ld [H_AUTOBGTRANSFERENABLED], a call Delay3 ld a, $9c ld [$ffbd], a @@ -6696,11 +6841,11 @@ Func_3efeb: ; 3efeb (f:6feb) ld bc, $40a call ClearScreenArea call ClearSprites - ld a, [W_ISINBATTLE] ; W_ISINBATTLE - dec a - call z, Func_3cdec - call Func_3c11e - callab Func_137aa + ld a, [W_ISINBATTLE] + dec a ; is it a wild battle? + call z, DrawEnemyHUDAndHPBar ; draw enemy HUD and HP bar if it's a wild battle + call StartBattle + callab EndOfBattle pop af ld [wd358], a pop af @@ -6709,8 +6854,7 @@ Func_3efeb: ; 3efeb (f:6feb) ld [$ffd7], a scf ret - -TerminatorText_3f04a: ; 3f04a (f:704a) +.emptyString db "@" _LoadTrainerPic: ; 3f04b (f:704b) @@ -6719,7 +6863,7 @@ _LoadTrainerPic: ; 3f04b (f:704b) ld e, a ld a, [wd034] ld d, a ; de contains pointer to trainer pic - ld a, [W_ISLINKBATTLE] ; W_ISLINKBATTLE + ld a, [W_ISLINKBATTLE] and a ld a, Bank(TrainerPics) ; this is where all the trainer pics are (not counting Red's) jr z, .loadSprite @@ -6743,15 +6887,15 @@ Func_3f073: ; 3f073 (f:7073) ld a, [wPredefRegisters + 1] ld l, a ld a, [$ffe1] - ld [H_DOWNARROWBLINKCNT1], a ; $ff8b + ld [H_DOWNARROWBLINKCNT1], a ld b, $4c - ld a, [W_ISINBATTLE] ; W_ISINBATTLE + ld a, [W_ISINBATTLE] and a jr z, .asm_3f0bc add b ld [hl], a call Delay3 - ld bc, $ffd7 + ld bc, -41 add hl, bc ld a, $1 ld [wcd6c], a @@ -6759,7 +6903,7 @@ Func_3f073: ; 3f073 (f:7073) predef Func_79aba ld c, $4 call DelayFrames - ld bc, $ffd7 + ld bc, -41 add hl, bc xor a ld [wcd6c], a @@ -6767,13 +6911,13 @@ Func_3f073: ; 3f073 (f:7073) predef Func_79aba ld c, $5 call DelayFrames - ld bc, $ffd7 + ld bc, -41 jr .asm_3f0bf .asm_3f0bc - ld bc, $ff85 + ld bc, -123 .asm_3f0bf add hl, bc - ld a, [H_DOWNARROWBLINKCNT1] ; $ff8b + ld a, [H_DOWNARROWBLINKCNT1] add $31 jr asm_3f0d0 @@ -6850,12 +6994,12 @@ LoadMonBackPic: ld b, a jp CopyVideoData -Func_3f132: ; 3f132 (f:7132) - call JumpMoveEffect +JumpMoveEffect: ; 3f132 (f:7132) + call _JumpMoveEffect ld b, $1 ret -JumpMoveEffect: ; 3f138 (f:7138) +_JumpMoveEffect: ; 3f138 (f:7138) ld a, [$fff3] ;whose turn? and a ld a, [W_PLAYERMOVEEFFECT] @@ -6962,13 +7106,13 @@ MoveEffectPointerTable: ; 3f150 (f:7150) dw DisableEffect ; DISABLE_EFFECT SleepEffect: ; 3f1fc (f:71fc) - ld de, wEnemyMonStatus ; wcfe9 - ld bc, W_ENEMYBATTSTATUS2 ; W_ENEMYBATTSTATUS2 - ld a, [H_WHOSETURN] ; $fff3 + ld de, wEnemyMonStatus + ld bc, W_ENEMYBATTSTATUS2 + ld a, [H_WHOSETURN] and a jp z, .asm_3f20e - ld de, wBattleMonStatus ; wBattleMonStatus - ld bc, W_PLAYERBATTSTATUS2 ; W_PLAYERBATTSTATUS2 + ld de, wBattleMonStatus + ld bc, W_PLAYERBATTSTATUS2 .asm_3f20e ld a, [bc] @@ -6989,7 +7133,7 @@ SleepEffect: ; 3f1fc (f:71fc) push de call MoveHitTest pop de - ld a, [W_MOVEMISSED] ; W_MOVEMISSED + ld a, [W_MOVEMISSED] and a jr nz, .asm_3f242 .asm_3f231 @@ -7012,13 +7156,13 @@ AlreadyAsleepText: ; 3f24a (f:724a) db "@" PoisonEffect: ; 3f24f (f:724f) - ld hl, wEnemyMonStatus ; wcfe9 - ld de, W_PLAYERMOVEEFFECT ; wcfd3 - ld a, [H_WHOSETURN] ; $fff3 + ld hl, wEnemyMonStatus + ld de, W_PLAYERMOVEEFFECT + ld a, [H_WHOSETURN] and a jr z, .asm_3f260 - ld hl, wBattleMonStatus ; wBattleMonStatus - ld de, W_ENEMYMOVEEFFECT ; W_ENEMYMOVEEFFECT + ld hl, wBattleMonStatus + ld de, W_ENEMYMOVEEFFECT .asm_3f260 call CheckTargetSubstitute jr nz, .asm_3f2d3 @@ -7044,7 +7188,7 @@ PoisonEffect: ; 3f24f (f:724f) call MoveHitTest pop de pop hl - ld a, [W_MOVEMISSED] ; W_MOVEMISSED + ld a, [W_MOVEMISSED] and a jr nz, .asm_3f2d7 jr .asm_3f295 @@ -7057,16 +7201,16 @@ PoisonEffect: ; 3f24f (f:724f) set 3, [hl] push de dec de - ld a, [H_WHOSETURN] ; $fff3 + ld a, [H_WHOSETURN] and a ld b, $c7 - ld hl, W_PLAYERBATTSTATUS3 ; W_PLAYERBATTSTATUS3 + ld hl, W_PLAYERBATTSTATUS3 ld a, [de] - ld de, W_PLAYERTOXICCOUNTER ; wd06c + ld de, W_PLAYERTOXICCOUNTER jr nz, .asm_3f2b0 ld b, $a9 - ld hl, W_ENEMYBATTSTATUS3 ; W_ENEMYBATTSTATUS3 - ld de, W_ENEMYTOXICCOUNTER ; wd071 + ld hl, W_ENEMYBATTSTATUS3 + ld de, W_ENEMYTOXICCOUNTER .asm_3f2b0 cp $5c jr nz, .asm_3f2bd @@ -7111,13 +7255,13 @@ DrainHPEffect: ; 3f2e9 (f:72e9) jp Bankswitch ExplodeEffect: ; 3f2f1 (f:72f1) - ld hl, wBattleMonHP ; wd015 - ld de, W_PLAYERBATTSTATUS2 ; W_PLAYERBATTSTATUS2 - ld a, [H_WHOSETURN] ; $fff3 + ld hl, wBattleMonHP + ld de, W_PLAYERBATTSTATUS2 + ld a, [H_WHOSETURN] and a jr z, .asm_3f302 - ld hl, wEnemyMonHP ; wEnemyMonHP - ld de, W_ENEMYBATTSTATUS2 ; W_ENEMYBATTSTATUS2 + ld hl, wEnemyMonHP + ld de, W_ENEMYBATTSTATUS2 .asm_3f302 xor a ld [hli], a ; set the mon's HP to 0 @@ -7169,14 +7313,14 @@ FreezeBurnParalyzeEffect: ; 3f30c (f:730c) jr z, .freeze ld a, 1 << PAR ld [wEnemyMonStatus], a - call Func_3ed27 ;quarter speed of affected monster + call QuarterSpeedDueToParalysis ;quarter speed of affected monster ld a, $a9 call Func_3fbb9 ;animation jp PrintMayNotAttackText ;print paralysis text .burn ld a, 1 << BRN ld [wEnemyMonStatus], a - call Func_3ed64 + call HalveAttackDueToBurn ld a, $a9 call Func_3fbb9 ;animation ld hl, BurnedText @@ -7220,12 +7364,12 @@ opponentAttacker: ; 3f382 (f:7382) jr z, .freeze ld a, 1 << PAR ld [wBattleMonStatus], a - call Func_3ed27 + call QuarterSpeedDueToParalysis jp PrintMayNotAttackText .burn ld a, 1 << BRN ld [wBattleMonStatus], a - call Func_3ed64 + call HalveAttackDueToBurn ld hl, BurnedText jp PrintText .freeze @@ -7283,13 +7427,13 @@ FireDefrostedText: ; 3f423 (f:7423) db "@" StatModifierUpEffect: ; 3f428 (f:7428) - ld hl, wPlayerMonStatMods ; wcd1a - ld de, W_PLAYERMOVEEFFECT ; wcfd3 - ld a, [H_WHOSETURN] ; $fff3 + ld hl, wPlayerMonStatMods + ld de, W_PLAYERMOVEEFFECT + ld a, [H_WHOSETURN] and a jr z, .asm_3f439 - ld hl, wEnemyMonStatMods ; wcd2e - ld de, W_ENEMYMOVEEFFECT ; W_ENEMYMOVEEFFECT + ld hl, wEnemyMonStatMods + ld de, W_ENEMYMOVEEFFECT .asm_3f439 ld a, [de] sub $a @@ -7321,11 +7465,11 @@ StatModifierUpEffect: ; 3f428 (f:7428) push hl ld hl, wBattleMonAttack + 1 ld de, wcd12 - ld a, [H_WHOSETURN] ; $fff3 + ld a, [H_WHOSETURN] and a jr z, .asm_3f472 ld hl, wEnemyMonAttack + 1 - ld de, wcd26 + ld de, wEnemyMonUnmodifiedAttack .asm_3f472 push bc sla c @@ -7347,7 +7491,7 @@ StatModifierUpEffect: ; 3f428 (f:7428) .asm_3f48a push hl push bc - ld hl, StatModifierRatios ; $76cb + ld hl, StatModifierRatios dec b sla b ld c, b @@ -7389,14 +7533,14 @@ asm_3f4ca: ; 3f4ca (f:74ca) ld b, c inc b call Func_3f688 - ld hl, W_PLAYERBATTSTATUS2 ; W_PLAYERBATTSTATUS2 - ld de, W_PLAYERMOVENUM ; wcfd2 + ld hl, W_PLAYERBATTSTATUS2 + ld de, W_PLAYERMOVENUM ld bc, wccf7 - ld a, [H_WHOSETURN] ; $fff3 + ld a, [H_WHOSETURN] and a jr z, .asm_3f4e6 - ld hl, W_ENEMYBATTSTATUS2 ; W_ENEMYBATTSTATUS2 - ld de, W_ENEMYMOVENUM ; W_ENEMYMOVENUM + ld hl, W_ENEMYBATTSTATUS2 + ld de, W_ENEMYMOVENUM ld bc, wccf3 .asm_3f4e6 ld a, [de] @@ -7423,13 +7567,13 @@ asm_3f4ca: ; 3f4ca (f:74ca) pop af call nz, Bankswitch .asm_3f50e - ld a, [H_WHOSETURN] ; $fff3 + ld a, [H_WHOSETURN] and a - call z, Func_3ee19 + call z, ApplyBadgeStatBoosts ld hl, MonsStatsRoseText call PrintText - call Func_3ed27 - jp Func_3ed64 + call QuarterSpeedDueToParalysis + jp HalveAttackDueToBurn Func_3f520: ; 3f520 (f:7520) pop hl @@ -7443,11 +7587,11 @@ MonsStatsRoseText: ; 3f528 (f:7528) TX_FAR _MonsStatsRoseText db $08 ; asm ld hl, GreatlyRoseText - ld a, [H_WHOSETURN] ; $fff3 + ld a, [H_WHOSETURN] and a - ld a, [W_PLAYERMOVEEFFECT] ; wcfd3 + ld a, [W_PLAYERMOVEEFFECT] jr z, .asm_3f53b - ld a, [W_ENEMYMOVEEFFECT] ; W_ENEMYMOVEEFFECT + ld a, [W_ENEMYMOVEEFFECT] .asm_3f53b cp ATTACK_DOWN1_EFFECT ret nc @@ -7463,16 +7607,16 @@ RoseText: ; 3f547 (f:7547) db "@" StatModifierDownEffect: ; 3f54c (f:754c) - ld hl, wEnemyMonStatMods ; wcd2e - ld de, W_PLAYERMOVEEFFECT ; wcfd3 - ld bc, W_ENEMYBATTSTATUS1 ; W_ENEMYBATTSTATUS1 - ld a, [H_WHOSETURN] ; $fff3 + ld hl, wEnemyMonStatMods + ld de, W_PLAYERMOVEEFFECT + ld bc, W_ENEMYBATTSTATUS1 + ld a, [H_WHOSETURN] and a jr z, .asm_3f572 - ld hl, wPlayerMonStatMods ; wcd1a - ld de, W_ENEMYMOVEEFFECT ; W_ENEMYMOVEEFFECT - ld bc, W_PLAYERBATTSTATUS1 ; W_PLAYERBATTSTATUS1 - ld a, [W_ISLINKBATTLE] ; W_ISLINKBATTLE + ld hl, wPlayerMonStatMods + ld de, W_ENEMYMOVEEFFECT + ld bc, W_PLAYERBATTSTATUS1 + ld a, [W_ISLINKBATTLE] cp $4 jr z, .asm_3f572 call BattleRandom @@ -7498,7 +7642,7 @@ StatModifierDownEffect: ; 3f54c (f:754c) pop bc pop de pop hl - ld a, [W_MOVEMISSED] ; W_MOVEMISSED + ld a, [W_MOVEMISSED] and a jp nz, Func_3f65a ld a, [bc] @@ -7532,8 +7676,8 @@ StatModifierDownEffect: ; 3f54c (f:754c) push hl push de ld hl, wEnemyMonAttack + 1 - ld de, wcd26 - ld a, [H_WHOSETURN] ; $fff3 + ld de, wEnemyMonUnmodifiedAttack + ld a, [H_WHOSETURN] and a jr z, .asm_3f5d8 ld hl, wBattleMonAttack + 1 @@ -7559,7 +7703,7 @@ StatModifierDownEffect: ; 3f54c (f:754c) .asm_3f5ef push hl push bc - ld hl, StatModifierRatios ; $76cb + ld hl, StatModifierRatios dec b sla b ld c, b @@ -7608,13 +7752,13 @@ asm_3f62c: ; 3f62c (f:762c) jr nc, .asm_3f63b call Func_3fb89 .asm_3f63b - ld a, [H_WHOSETURN] ; $fff3 + ld a, [H_WHOSETURN] and a - call nz, Func_3ee19 + call nz, ApplyBadgeStatBoosts ld hl, MonsStatsFellText call PrintText - call Func_3ed27 - jp Func_3ed64 + call QuarterSpeedDueToParalysis + jp HalveAttackDueToBurn Func_3f64d: ; 3f64d (f:764d) pop de @@ -7638,11 +7782,11 @@ MonsStatsFellText: ; 3f661 (f:7661) TX_FAR _MonsStatsFellText db $08 ; asm ld hl, FellText - ld a, [H_WHOSETURN] ; $fff3 + ld a, [H_WHOSETURN] and a - ld a, [W_PLAYERMOVEEFFECT] ; wcfd3 + ld a, [W_PLAYERMOVEEFFECT] jr z, .asm_3f674 - ld a, [W_ENEMYMOVEEFFECT] ; W_ENEMYMOVEEFFECT + ld a, [W_ENEMYMOVEEFFECT] .asm_3f674 cp $1a ret c @@ -7702,13 +7846,13 @@ StatModifierRatios: ; 3f6cb (f:76cb) BideEffect: ; 3f6e5 (f:76e5) ld hl, W_PLAYERBATTSTATUS1 ld de, W_NUMHITS - ld bc, wd06a + ld bc, wPlayerNumAttacksLeft ld a, [H_WHOSETURN] and a jr z, .asm_3f6fc ld hl, W_ENEMYBATTSTATUS1 ld de, wcd05 - ld bc, wd06f + ld bc, wEnemyNumAttacksLeft .asm_3f6fc set 0, [hl] ; mon is now using bide xor a @@ -7727,13 +7871,13 @@ BideEffect: ; 3f6e5 (f:76e5) jp Func_3fb96 ThrashPetalDanceEffect: ; 3f717 (f:7717) - ld hl, W_PLAYERBATTSTATUS1 ; W_PLAYERBATTSTATUS1 - ld de, wd06a - ld a, [H_WHOSETURN] ; $fff3 + ld hl, W_PLAYERBATTSTATUS1 + ld de, wPlayerNumAttacksLeft + ld a, [H_WHOSETURN] and a jr z, .asm_3f728 - ld hl, W_ENEMYBATTSTATUS1 ; W_ENEMYBATTSTATUS1 - ld de, wd06f + ld hl, W_ENEMYBATTSTATUS1 + ld de, wEnemyNumAttacksLeft .asm_3f728 set 1, [hl] ; mon is now using thrash/petal dance call BattleRandom @@ -7741,20 +7885,20 @@ ThrashPetalDanceEffect: ; 3f717 (f:7717) inc a inc a ld [de], a - ld a, [H_WHOSETURN] ; $fff3 + ld a, [H_WHOSETURN] add $b0 jp Func_3fb96 SwitchAndTeleportEffect: ; 3f739 (f:7739) - ld a, [H_WHOSETURN] ; $fff3 + ld a, [H_WHOSETURN] and a jr nz, .asm_3f791 - ld a, [W_ISINBATTLE] ; W_ISINBATTLE + ld a, [W_ISINBATTLE] dec a jr nz, .asm_3f77e - ld a, [W_CURENEMYLVL] ; W_CURENEMYLVL + ld a, [W_CURENEMYLVL] ld b, a - ld a, [wBattleMonLevel] ; wBattleMonLevel + ld a, [wBattleMonLevel] cp b jr nc, .asm_3f76e add b @@ -7770,7 +7914,7 @@ SwitchAndTeleportEffect: ; 3f739 (f:7739) jr nc, .asm_3f76e ld c, $32 call DelayFrames - ld a, [W_PLAYERMOVENUM] ; wcfd2 + ld a, [W_PLAYERMOVENUM] cp TELEPORT jp nz, PrintDidntAffectText jp PrintButItFailedText_ @@ -7779,24 +7923,24 @@ SwitchAndTeleportEffect: ; 3f739 (f:7739) xor a ld [wcc5b], a inc a - ld [wd078], a - ld a, [W_PLAYERMOVENUM] ; wcfd2 + ld [wEscapedFromBattle], a + ld a, [W_PLAYERMOVENUM] jr .asm_3f7e4 .asm_3f77e ld c, $32 call DelayFrames ld hl, IsUnaffectedText - ld a, [W_PLAYERMOVENUM] ; wcfd2 + ld a, [W_PLAYERMOVENUM] cp TELEPORT jp nz, PrintText jp PrintButItFailedText_ .asm_3f791 - ld a, [W_ISINBATTLE] ; W_ISINBATTLE + ld a, [W_ISINBATTLE] dec a jr nz, .asm_3f7d1 - ld a, [wBattleMonLevel] ; wBattleMonLevel + ld a, [wBattleMonLevel] ld b, a - ld a, [W_CURENEMYLVL] ; W_CURENEMYLVL + ld a, [W_CURENEMYLVL] cp b jr nc, .asm_3f7c1 add b @@ -7812,7 +7956,7 @@ SwitchAndTeleportEffect: ; 3f739 (f:7739) jr nc, .asm_3f7c1 ld c, $32 call DelayFrames - ld a, [W_ENEMYMOVENUM] ; W_ENEMYMOVENUM + ld a, [W_ENEMYMOVENUM] cp TELEPORT jp nz, PrintDidntAffectText jp PrintButItFailedText_ @@ -7821,14 +7965,14 @@ SwitchAndTeleportEffect: ; 3f739 (f:7739) xor a ld [wcc5b], a inc a - ld [wd078], a - ld a, [W_ENEMYMOVENUM] ; W_ENEMYMOVENUM + ld [wEscapedFromBattle], a + ld a, [W_ENEMYMOVENUM] jr .asm_3f7e4 .asm_3f7d1 ld c, $32 call DelayFrames ld hl, IsUnaffectedText - ld a, [W_ENEMYMOVENUM] ; W_ENEMYMOVENUM + ld a, [W_ENEMYMOVENUM] cp TELEPORT jp nz, PrintText jp Func_3fb4e @@ -7838,13 +7982,13 @@ SwitchAndTeleportEffect: ; 3f739 (f:7739) ld c, $14 call DelayFrames pop af - ld hl, RanFromBattleText ; $7802 + ld hl, RanFromBattleText cp TELEPORT jr z, .asm_3f7ff - ld hl, RanAwayScaredText ; $7807 + ld hl, RanAwayScaredText cp ROAR jr z, .asm_3f7ff - ld hl, WasBlownAwayText ; $780c + ld hl, WasBlownAwayText .asm_3f7ff jp PrintText @@ -7861,24 +8005,24 @@ WasBlownAwayText: ; 3f80c (f:780c) db "@" TwoToFiveAttacksEffect: ; 3f811 (f:7811) - ld hl, W_PLAYERBATTSTATUS1 ; W_PLAYERBATTSTATUS1 - ld de, wd06a - ld bc, W_NUMHITS ; wd074 - ld a, [H_WHOSETURN] ; $fff3 + ld hl, W_PLAYERBATTSTATUS1 + ld de, wPlayerNumAttacksLeft + ld bc, W_NUMHITS + ld a, [H_WHOSETURN] and a jr z, .asm_3f828 - ld hl, W_ENEMYBATTSTATUS1 ; W_ENEMYBATTSTATUS1 - ld de, wd06f + ld hl, W_ENEMYBATTSTATUS1 + ld de, wEnemyNumAttacksLeft ld bc, wcd05 .asm_3f828 bit 2, [hl] ; is mon attacking multiple times? ret nz set 2, [hl] ; mon is now attacking multiple times - ld hl, W_PLAYERMOVEEFFECT ; wcfd3 - ld a, [H_WHOSETURN] ; $fff3 + ld hl, W_PLAYERMOVEEFFECT + ld a, [H_WHOSETURN] and a jr z, .asm_3f838 - ld hl, W_ENEMYMOVEEFFECT ; W_ENEMYMOVEEFFECT + ld hl, W_ENEMYMOVEEFFECT .asm_3f838 ld a, [hl] cp TWINEEDLE_EFFECT @@ -7907,13 +8051,13 @@ TwoToFiveAttacksEffect: ; 3f811 (f:7811) FlichSideEffect: ; 3f85b (f:785b) call CheckTargetSubstitute ret nz - ld hl, W_ENEMYBATTSTATUS1 ; W_ENEMYBATTSTATUS1 - ld de, W_PLAYERMOVEEFFECT ; wcfd3 - ld a, [H_WHOSETURN] ; $fff3 + ld hl, W_ENEMYBATTSTATUS1 + ld de, W_PLAYERMOVEEFFECT + ld a, [H_WHOSETURN] and a jr z, .asm_3f870 - ld hl, W_PLAYERBATTSTATUS1 ; W_PLAYERBATTSTATUS1 - ld de, W_ENEMYMOVEEFFECT ; W_ENEMYMOVEEFFECT + ld hl, W_PLAYERBATTSTATUS1 + ld de, W_ENEMYMOVEEFFECT .asm_3f870 ld a, [de] cp FLINCH_SIDE_EFFECT1 @@ -7934,14 +8078,14 @@ OneHitKOEffect: ; 3f884 (f:7884) jp Bankswitch ChargeEffect: ; 3f88c (f:788c) - ld hl, W_PLAYERBATTSTATUS1 ; W_PLAYERBATTSTATUS1 - ld de, W_PLAYERMOVEEFFECT ; wcfd3 - ld a, [H_WHOSETURN] ; $fff3 + ld hl, W_PLAYERBATTSTATUS1 + ld de, W_PLAYERMOVEEFFECT + ld a, [H_WHOSETURN] and a ld b, $ae jr z, .asm_3f8a1 - ld hl, W_ENEMYBATTSTATUS1 ; W_ENEMYBATTSTATUS1 - ld de, W_ENEMYMOVEEFFECT ; W_ENEMYMOVEEFFECT + ld hl, W_ENEMYBATTSTATUS1 + ld de, W_ENEMYMOVEEFFECT ld b, $af .asm_3f8a1 set 4, [hl] @@ -7963,31 +8107,31 @@ ChargeEffect: ; 3f88c (f:788c) ld a, b call Func_3fbb9 ld a, [de] - ld [wWhichTrade], a ; wWhichTrade - ld hl, ChargeMoveEffectText ; $78c8 + ld [wWhichTrade], a + ld hl, ChargeMoveEffectText jp PrintText ChargeMoveEffectText: ; 3f8c8 (f:78c8) TX_FAR _ChargeMoveEffectText db $08 ; asm - ld a, [wWhichTrade] ; wWhichTrade + ld a, [wWhichTrade] cp RAZOR_WIND - ld hl, MadeWhirlwindText ; $78f9 + ld hl, MadeWhirlwindText jr z, .asm_3f8f8 cp SOLARBEAM - ld hl, TookInSunlightText ; $78fe + ld hl, TookInSunlightText jr z, .asm_3f8f8 cp SKULL_BASH - ld hl, LoweredItsHeadText ; $7903 + ld hl, LoweredItsHeadText jr z, .asm_3f8f8 cp SKY_ATTACK - ld hl, SkyAttackGlowingText ; $7908 + ld hl, SkyAttackGlowingText jr z, .asm_3f8f8 cp FLY - ld hl, FlewUpHighText ; $790d + ld hl, FlewUpHighText jr z, .asm_3f8f8 cp DIG - ld hl, DugAHoleText ; $7912 + ld hl, DugAHoleText .asm_3f8f8 ret @@ -8016,13 +8160,13 @@ DugAHoleText: ; 3f912 (f:7912) db "@" TrappingEffect: ; 3f917 (f:7917) - ld hl, W_PLAYERBATTSTATUS1 ; W_PLAYERBATTSTATUS1 - ld de, wd06a - ld a, [H_WHOSETURN] ; $fff3 + ld hl, W_PLAYERBATTSTATUS1 + ld de, wPlayerNumAttacksLeft + ld a, [H_WHOSETURN] and a jr z, .asm_3f928 - ld hl, W_ENEMYBATTSTATUS1 ; W_ENEMYBATTSTATUS1 - ld de, wd06f + ld hl, W_ENEMYBATTSTATUS1 + ld de, wEnemyNumAttacksLeft .asm_3f928 bit 5, [hl] ret nz @@ -8064,20 +8208,20 @@ ConfusionEffect: ; 3f961 (f:7961) call CheckTargetSubstitute jr nz, Func_3f9a6 call MoveHitTest - ld a, [W_MOVEMISSED] ; W_MOVEMISSED + ld a, [W_MOVEMISSED] and a jr nz, Func_3f9a6 Func_3f96f: ; 3f96f (f:796f) - ld a, [H_WHOSETURN] ; $fff3 + ld a, [H_WHOSETURN] and a - ld hl, W_ENEMYBATTSTATUS1 ; W_ENEMYBATTSTATUS1 + ld hl, W_ENEMYBATTSTATUS1 ld bc, wd070 - ld a, [W_PLAYERMOVEEFFECT] ; wcfd3 + ld a, [W_PLAYERMOVEEFFECT] jr z, .asm_3f986 - ld hl, W_PLAYERBATTSTATUS1 ; W_PLAYERBATTSTATUS1 + ld hl, W_PLAYERBATTSTATUS1 ld bc, wd06b - ld a, [W_ENEMYMOVEEFFECT] ; W_ENEMYMOVEEFFECT + ld a, [W_ENEMYMOVEEFFECT] .asm_3f986 bit 7, [hl] ; is mon confused? jr nz, Func_3f9a6 @@ -8091,7 +8235,7 @@ Func_3f96f: ; 3f96f (f:796f) pop af cp CONFUSION_SIDE_EFFECT call nz, Func_3fb89 - ld hl, BecameConfusedText ; $79a1 + ld hl, BecameConfusedText jp PrintText BecameConfusedText: ; 3f9a1 (f:79a1) @@ -8116,22 +8260,22 @@ SubstituteEffect: ; 3f9b9 (f:79b9) jp Bankswitch HyperBeamEffect: ; 3f9c1 (f:79c1) - ld hl, W_PLAYERBATTSTATUS2 ; W_PLAYERBATTSTATUS2 - ld a, [H_WHOSETURN] ; $fff3 + ld hl, W_PLAYERBATTSTATUS2 + ld a, [H_WHOSETURN] and a jr z, .asm_3f9cc - ld hl, W_ENEMYBATTSTATUS2 ; W_ENEMYBATTSTATUS2 + ld hl, W_ENEMYBATTSTATUS2 .asm_3f9cc set 5, [hl] ; mon now needs to recharge ret Func_3f9cf: ; 3f9cf (f:79cf) push hl - ld hl, W_ENEMYBATTSTATUS2 ; W_ENEMYBATTSTATUS2 - ld a, [H_WHOSETURN] ; $fff3 + ld hl, W_ENEMYBATTSTATUS2 + ld a, [H_WHOSETURN] and a jr z, .asm_3f9db - ld hl, W_PLAYERBATTSTATUS2 ; W_PLAYERBATTSTATUS2 + ld hl, W_PLAYERBATTSTATUS2 .asm_3f9db res 5, [hl] ; mon no longer needs to recharge pop hl @@ -8234,15 +8378,15 @@ SplashEffect: ; 3fa84 (f:7a84) DisableEffect: ; 3fa8a (f:7a8a) call MoveHitTest - ld a, [W_MOVEMISSED] ; W_MOVEMISSED + ld a, [W_MOVEMISSED] and a jr nz, .asm_3fb06 - ld de, W_ENEMYDISABLEDMOVE ; W_ENEMYDISABLEDMOVE + ld de, W_ENEMYDISABLEDMOVE ld hl, wEnemyMonMoves - ld a, [H_WHOSETURN] ; $fff3 + ld a, [H_WHOSETURN] and a jr z, .asm_3faa4 - ld de, W_PLAYERDISABLEDMOVE ; W_PLAYERDISABLEDMOVE + ld de, W_PLAYERDISABLEDMOVE ld hl, wBattleMonMoves .asm_3faa4 ld a, [de] @@ -8261,16 +8405,16 @@ DisableEffect: ; 3fa8a (f:7a8a) jr z, .asm_3faa8 ld [wd11e], a push hl - ld a, [H_WHOSETURN] ; $fff3 + ld a, [H_WHOSETURN] and a - ld hl, wBattleMonPP ; wBattleMonPP + ld hl, wBattleMonPP jr nz, .asm_3facf - ld a, [W_ISLINKBATTLE] ; W_ISLINKBATTLE + ld a, [W_ISLINKBATTLE] cp $4 pop hl jr nz, .asm_3fae1 push hl - ld hl, wEnemyMonPP ; wcffe + ld hl, wEnemyMonPP .asm_3facf push hl ld a, [hli] @@ -8297,7 +8441,7 @@ DisableEffect: ; 3fa8a (f:7a8a) ld [de], a call Func_3fb89 ld hl, wccee - ld a, [H_WHOSETURN] ; $fff3 + ld a, [H_WHOSETURN] and a jr nz, .asm_3faf8 inc hl @@ -8305,7 +8449,7 @@ DisableEffect: ; 3fa8a (f:7a8a) ld a, [wd11e] ld [hl], a call GetMoveName - ld hl, MoveWasDisabledText ; $7b09 + ld hl, MoveWasDisabledText jp PrintText .asm_3fb05 pop hl @@ -8384,7 +8528,7 @@ IsUnaffectedText: ; 3fb69 (f:7b69) db "@" PrintMayNotAttackText: ; 3fb6e (f:7b6e) - ld hl, ParalyzedMayNotAttackText ; $7b74 + ld hl, ParalyzedMayNotAttackText jp PrintText ParalyzedMayNotAttackText: ; 3fb74 (f:7b74) @@ -8404,18 +8548,18 @@ CheckTargetSubstitute: ; 3fb79 (f:7b79) ret Func_3fb89: ; 3fb89 (f:7b89) - ld a, [H_WHOSETURN] ; $fff3 + ld a, [H_WHOSETURN] and a - ld a, [W_PLAYERMOVENUM] ; wcfd2 + ld a, [W_PLAYERMOVENUM] jr z, .asm_3fb94 - ld a, [W_ENEMYMOVENUM] ; W_ENEMYMOVENUM + ld a, [W_ENEMYMOVENUM] .asm_3fb94 and a ret z Func_3fb96: ; 3fb96 (f:7b96) - ld [W_ANIMATIONID], a ; W_ANIMATIONID - ld a, [H_WHOSETURN] ; $fff3 + ld [W_ANIMATIONID], a + ld a, [H_WHOSETURN] and a ld a, $6 jr z, .asm_3fba2 @@ -8427,17 +8571,17 @@ Func_3fb96: ; 3fb96 (f:7b96) Func_3fba8: ; 3fba8 (f:7ba8) xor a ld [wcc5b], a - ld a, [H_WHOSETURN] ; $fff3 + ld a, [H_WHOSETURN] and a - ld a, [W_PLAYERMOVENUM] ; wcfd2 + ld a, [W_PLAYERMOVENUM] jr z, .asm_3fbb7 - ld a, [W_ENEMYMOVENUM] ; W_ENEMYMOVENUM + ld a, [W_ENEMYMOVENUM] .asm_3fbb7 and a ret z Func_3fbb9: ; 3fbb9 (f:7bb9) - ld [W_ANIMATIONID], a ; W_ANIMATIONID + ld [W_ANIMATIONID], a Func_3fbbc: ; 3fbbc (f:7bbc) push hl diff --git a/engine/battle/d.asm b/engine/battle/d.asm index d23c911471..dcd58ec4e7 100755 --- a/engine/battle/d.asm +++ b/engine/battle/d.asm @@ -1,15 +1,17 @@ -Func_372d6: ; 372d6 (d:72d6) +; display "[player] VS [enemy]" text box with pokeballs representing their parties next to the names +DisplayLinkBattleVersusTextBox: ; 372d6 (d:72d6) call LoadTextBoxTilePatterns hlCoord 3, 4 ld b, $7 ld c, $c call TextBoxBorder hlCoord 4, 5 - ld de, wPlayerName ; wd158 + ld de, wPlayerName call PlaceString hlCoord 4, 10 - ld de, W_GRASSRATE ; W_GRASSRATE + ld de, W_GRASSRATE ; enemy name call PlaceString +; place bold "VS" tiles between the names hlCoord 9, 8 ld a, $69 ld [hli], a @@ -17,5 +19,5 @@ Func_372d6: ; 372d6 (d:72d6) xor a ld [wcfcb], a callab SetupPlayerAndEnemyPokeballs - ld c, $96 + ld c, 150 jp DelayFrames diff --git a/engine/battle/e.asm b/engine/battle/e.asm index 8b0476ca98..1112f39b0b 100755 --- a/engine/battle/e.asm +++ b/engine/battle/e.asm @@ -1203,11 +1203,11 @@ Func_3a72a: ; 3a72a (e:672a) ld a,d ; how many available monsters are there? cp 2 ; don't bother if only 1 or 2 - jp nc,Func_3a74b + jp nc,SwitchEnemyMon and a ret -Func_3a74b: ; 3a74b (e:674b) +SwitchEnemyMon: ; 3a74b (e:674b) ; prepare to withdraw the active monster: copy hp, number, and status to roster diff --git a/engine/battle/e_2.asm b/engine/battle/e_2.asm index 665807feef..b0e08982b4 100755 --- a/engine/battle/e_2.asm +++ b/engine/battle/e_2.asm @@ -93,7 +93,7 @@ HealEffect_: ; 3b9ec (e:79ec) .asm_3ba83 ld [wListMenuID], a ; wListMenuID predef UpdateHPBar2 - ld hl, Func_3cd5a ; $4d5a + ld hl, DrawHUDsAndHPBars ; $4d5a call BankswitchEtoF ld hl, RegainedHealthText ; $7aac jp PrintText @@ -226,8 +226,8 @@ TransformEffect_: ; 3bab1 (e:7ab1) ld a, [hl] ld [wd11e], a call GetMonName - ld hl, wcd26 - ld de, wcd12 + ld hl, wEnemyMonUnmodifiedAttack + ld de, wPlayerMonUnmodifiedAttack call Func_3bb7d ld hl, wEnemyMonStatMods ; wcd2e ld de, wPlayerMonStatMods ; wcd1a diff --git a/engine/battle/safari_zone.asm b/engine/battle/safari_zone.asm index 99e1492da5..6b0e222057 100755 --- a/engine/battle/safari_zone.asm +++ b/engine/battle/safari_zone.asm @@ -1,5 +1,5 @@ PrintSafariZoneBattleText: ; 4277 (1:4277) - ld hl, wcce9 + ld hl, wSafariBaitFactor ld a, [hl] and a jr z, .asm_4284 @@ -19,7 +19,7 @@ PrintSafariZoneBattleText: ; 4277 (1:4277) ld [wd0b5], a call GetMonHeader ld a, [W_MONHCATCHRATE] - ld [wd007], a + ld [wEnemyMonCatchRate], a pop hl .asm_429f push hl diff --git a/engine/cable_club.asm b/engine/cable_club.asm index fc049ceb7e..8cb70cbf6e 100755 --- a/engine/cable_club.asm +++ b/engine/cable_club.asm @@ -826,7 +826,7 @@ TradeCenter_Trade: .asm_59d9 predef Func_410f3 .asm_59de - callab Func_3ad0e + callab TryEvolvingMon call ClearScreen call LoadTrainerInfoTextBoxTiles call Func_226e diff --git a/engine/evolve_trade.asm b/engine/evolve_trade.asm index ffb8a7789d..97c261d0c3 100755 --- a/engine/evolve_trade.asm +++ b/engine/evolve_trade.asm @@ -38,7 +38,7 @@ EvolveTradeMon: ; 17d7d (5:7d7d) ld [wccd4], a ld a, $32 ld [W_ISLINKBATTLE], a ; W_ISLINKBATTLE - callab Func_3ad0e + callab TryEvolvingMon xor a ld [W_ISLINKBATTLE], a ; W_ISLINKBATTLE jp Func_2307 diff --git a/engine/evos_moves.asm b/engine/evos_moves.asm index fd93fa1459..90f89bce35 100755 --- a/engine/evos_moves.asm +++ b/engine/evos_moves.asm @@ -1,45 +1,49 @@ -Func_3ad0e: ; 3ad0e (e:6d0e) +; try to evolve the mon in [wWhichPokemon] +TryEvolvingMon: ; 3ad0e (e:6d0e) ld hl, wccd3 xor a ld [hl], a - ld a, [wWhichPokemon] ; wWhichPokemon + ld a, [wWhichPokemon] ld c, a ld b, $1 - call Func_3b057 + call Evolution_FlagAction -Func_3ad1c: ; 3ad1c (e:6d1c) +; this is only called after battle +; it is supposed to do level up evolutions, though there is a bug that allows item evolutions to occur +EvolutionAfterBattle: ; 3ad1c (e:6d1c) ld a, [$ffd7] push af xor a ld [wd121], a dec a - ld [wWhichPokemon], a ; wWhichPokemon + ld [wWhichPokemon], a push hl push bc push de - ld hl, wPartyCount ; wPartyCount + ld hl, wPartyCount push hl -asm_3ad2e: ; 3ad2e (e:6d2e) - ld hl, wWhichPokemon ; wWhichPokemon + +Evolution_PartyMonLoop: ; loop over party mons + ld hl, wWhichPokemon inc [hl] pop hl inc hl ld a, [hl] - cp $ff - jp z, Func_3aede + cp $ff ; have we reached the end of the party? + jp z, .done ld [wHPBarMaxHP], a push hl - ld a, [wWhichPokemon] ; wWhichPokemon + ld a, [wWhichPokemon] ld c, a ld hl, wccd3 ld b, $2 - call Func_3b057 + call Evolution_FlagAction ld a, c - and a - jp z, asm_3ad2e + and a ; is the mon's bit set? + jp z, Evolution_PartyMonLoop ; if not, go to the next mon ld a, [wHPBarMaxHP] dec a - ld b, $0 + ld b, 0 ld hl, EvosMovesPointerTable add a rl b @@ -58,56 +62,57 @@ asm_3ad2e: ; 3ad2e (e:6d2e) ld [wcf91], a pop hl -Func_3ad71: ; 3ad71 (e:6d71) +.evoEntryLoop ; loop over evolution entries ld a, [hli] - and a - jr z, asm_3ad2e - ld b, a - cp $3 - jr z, .asm_3ad91 - ld a, [W_ISLINKBATTLE] ; W_ISLINKBATTLE - cp $32 - jr z, asm_3ad2e + and a ; have we reached the end of the evolution data? + jr z, Evolution_PartyMonLoop + ld b, a ; evolution type + cp EV_TRADE + jr z, .checkTradeEvo +; not trade evolution + ld a, [W_ISLINKBATTLE] + cp $32 ; in a trade? + jr z, Evolution_PartyMonLoop ; if so, go the next mon ld a, b - cp $2 - jr z, .asm_3ada4 + cp EV_ITEM + jr z, .checkItemEvo ld a, [wccd4] and a - jr nz, asm_3ad2e + jr nz, Evolution_PartyMonLoop ld a, b - cp $1 - jr z, .asm_3adad -.asm_3ad91 - ld a, [W_ISLINKBATTLE] ; W_ISLINKBATTLE - cp $32 - jp nz, Func_3aed9 - ld a, [hli] + cp EV_LEVEL + jr z, .checkLevel +.checkTradeEvo + ld a, [W_ISLINKBATTLE] + cp $32 ; in a trade? + jp nz, .nextEvoEntry1 ; if not, go to the next evolution entry + ld a, [hli] ; level requirement ld b, a ld a, [wcfb9] - cp b - jp c, asm_3ad2e + cp b ; is the mon's level greater than the evolution requirement? + jp c, Evolution_PartyMonLoop ; if so, go the next mon jr .asm_3adb6 -.asm_3ada4 - ld a, [hli] - ld b, a - ld a, [wcf91] - cp b - jp nz, Func_3aed9 -.asm_3adad +.checkItemEvo ld a, [hli] + ld b, a ; evolution item + ld a, [wcf91] ; this is supposed to be the last item used, but it is also used to hold species numbers + cp b ; was the evolution item in this entry used? + jp nz, .nextEvoEntry1 ; if not, go to the next evolution entry +.checkLevel + ld a, [hli] ; level requirement ld b, a ld a, [wcfb9] - cp b - jp c, Func_3aeda + cp b ; is the mon's level greater than the evolution requirement? + jp c, .nextEvoEntry2 ; if so, go the next evolution entry .asm_3adb6 - ld [W_CURENEMYLVL], a ; W_CURENEMYLVL + ld [W_CURENEMYLVL], a ld a, $1 ld [wd121], a push hl ld a, [hl] ld [wHPBarMaxHP + 1], a - ld a, [wWhichPokemon] ; wWhichPokemon - ld hl, wPartyMonNicks ; wPartyMonNicks + ld a, [wWhichPokemon] + ld hl, wPartyMonNicks call GetPartyMonName call CopyStringToCF4B ld hl, IsEvolvingText @@ -115,17 +120,17 @@ Func_3ad71: ; 3ad71 (e:6d71) ld c, $32 call DelayFrames xor a - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba + ld [H_AUTOBGTRANSFERENABLED], a ld hl, wTileMap ld bc, $c14 call ClearScreenArea ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba + ld [H_AUTOBGTRANSFERENABLED], a ld a, $ff ld [wcfcb], a call ClearSprites callab Func_7bde9 - jp c, Func_3af2e + jp c, CancelledEvolution ld hl, EvolvedText call PrintText pop hl @@ -147,7 +152,7 @@ Func_3ad71: ; 3ad71 (e:6d71) ld c, $28 call DelayFrames call ClearScreen - call Func_3aef7 + call RenameEvolvedMon ld a, [wd11e] push af ld a, [wd0b5] @@ -168,15 +173,15 @@ Func_3ad71: ; 3ad71 (e:6d71) ld de, wcfba ld b, $1 call CalcStats - ld a, [wWhichPokemon] ; wWhichPokemon - ld hl, wPartyMon1Species ; wPartyMon1Species (aliases: wPartyMon1) - ld bc, $2c + ld a, [wWhichPokemon] + ld hl, wPartyMon1 + ld bc, wPartyMon2 - wPartyMon1 call AddNTimes ld e, l ld d, h push hl push bc - ld bc, $22 + ld bc, wPartyMon1MaxHP - wPartyMon1 add hl, bc ld a, [hli] ld b, a @@ -202,23 +207,23 @@ Func_3ad71: ; 3ad71 (e:6d71) ld [wd11e], a xor a ld [wcc49], a - call Func_3af5b + call LearnMoveFromLevelUp pop hl predef SetPartyMonTypes - ld a, [W_ISINBATTLE] ; W_ISINBATTLE + ld a, [W_ISINBATTLE] and a - call z, Func_3af52 + call z, Evolution_ReloadTilesetTilePatterns predef IndexToPokedex ld a, [wd11e] dec a ld c, a ld b, $1 - ld hl, wPokedexOwned ; wPokedexOwned + ld hl, wPokedexOwned push bc - call Func_3b057 + call Evolution_FlagAction pop bc - ld hl, wPokedexSeen ; wd30a - call Func_3b057 + ld hl, wPokedexSeen + call Evolution_FlagAction pop de pop hl ld a, [wcf98] @@ -226,25 +231,25 @@ Func_3ad71: ; 3ad71 (e:6d71) push hl ld l, e ld h, d - jr Func_3aeda + jr .nextEvoEntry2 -Func_3aed9: ; 3aed9 (e:6ed9) +.nextEvoEntry1 inc hl -Func_3aeda: ; 3aeda (e:6eda) +.nextEvoEntry2 inc hl - jp Func_3ad71 + jp .evoEntryLoop -Func_3aede: ; 3aede (e:6ede) +.done pop de pop bc pop hl pop af ld [$ffd7], a - ld a, [W_ISLINKBATTLE] ; W_ISLINKBATTLE + ld a, [W_ISLINKBATTLE] cp $32 ret z - ld a, [W_ISINBATTLE] ; W_ISINBATTLE + ld a, [W_ISINBATTLE] and a ret nz ld a, [wd121] @@ -252,7 +257,9 @@ Func_3aede: ; 3aede (e:6ede) call nz, Func_2307 ret -Func_3aef7: ; 3aef7 (e:6ef7) +; checks if the evolved mon's name is different from the standard name (i.e. it has a nickname) +; if so, rename it to is evolved form's standard name +RenameEvolvedMon: ; 3aef7 (e:6ef7) ld a, [wd0b5] push af ld a, [W_MONHDEXNUM] @@ -262,17 +269,17 @@ Func_3aef7: ; 3aef7 (e:6ef7) ld [wd0b5], a ld hl, wcd6d ld de, wcf4b -.asm_3af0e +.compareNamesLoop ld a, [de] inc de cp [hl] inc hl ret nz cp $50 - jr nz, .asm_3af0e - ld a, [wWhichPokemon] ; wWhichPokemon + jr nz, .compareNamesLoop + ld a, [wWhichPokemon] ld bc, $b - ld hl, wPartyMonNicks ; wPartyMonNicks + ld hl, wPartyMonNicks call AddNTimes push hl call GetName @@ -280,13 +287,13 @@ Func_3aef7: ; 3aef7 (e:6ef7) pop de jp CopyData -Func_3af2e: ; 3af2e (e:6f2e) +CancelledEvolution: ; 3af2e (e:6f2e) ld hl, StoppedEvolvingText call PrintText call ClearScreen pop hl - call Func_3af52 - jp asm_3ad2e + call Evolution_ReloadTilesetTilePatterns + jp Evolution_PartyMonLoop EvolvedText: ; 3af3e (e:6f3e) TX_FAR _EvolvedText @@ -304,18 +311,18 @@ IsEvolvingText: ; 3af4d (e:6f4d) TX_FAR _IsEvolvingText db "@" -Func_3af52: ; 3af52 (e:6f52) +Evolution_ReloadTilesetTilePatterns: ; 3af52 (e:6f52) ld a, [W_ISLINKBATTLE] ; W_ISLINKBATTLE - cp $32 - ret z + cp $32 ; in a trade? + ret z ; if so, return jp ReloadTilesetTilePatterns -Func_3af5b: ; 3af5b (e:6f5b) +LearnMoveFromLevelUp: ; 3af5b (e:6f5b) ld hl, EvosMovesPointerTable - ld a, [wd11e] + ld a, [wd11e] ; species ld [wcf91], a dec a - ld bc, $0 + ld bc, 0 ld hl, EvosMovesPointerTable add a rl b @@ -324,42 +331,45 @@ Func_3af5b: ; 3af5b (e:6f5b) ld a, [hli] ld h, [hl] ld l, a -.asm_3af73 +.skipEvolutionDataLoop ; loop to skip past the evolution data, which comes before the move data ld a, [hli] - and a - jr nz, .asm_3af73 -.asm_3af77 + and a ; have we reached the end of the evolution data? + jr nz, .skipEvolutionDataLoop ; if not, jump back up +.learnSetLoop ; loop over the learn set until we reach a move that is learnt at the current level or the end of the list ld a, [hli] - and a - jr z, .asm_3afb1 - ld b, a - ld a, [W_CURENEMYLVL] ; W_CURENEMYLVL - cp b - ld a, [hli] - jr nz, .asm_3af77 - ld d, a + and a ; have we reached the end of the learn set? + jr z, .done ; if we've reached the end of the learn set, jump + ld b, a ; level the move is learnt at + ld a, [W_CURENEMYLVL] + cp b ; is the move learnt at the mon's current level? + ld a, [hli] ; move ID + jr nz, .learnSetLoop + ld d, a ; ID of move to learn ld a, [wcc49] and a - jr nz, .asm_3af96 - ld hl, wPartyMon1Moves ; wPartyMon1Moves - ld a, [wWhichPokemon] ; wWhichPokemon - ld bc, $2c + jr nz, .next +; if [wcc49] is 0, get the address of the mon's current moves +; there is no reason to make this conditional because the code wouldn't work properly without doing this +; every call to this function sets [wcc49] to 0 + ld hl, wPartyMon1Moves + ld a, [wWhichPokemon] + ld bc, wPartyMon2 - wPartyMon1 call AddNTimes -.asm_3af96 +.next ld b, $4 -.asm_3af98 +.checkCurrentMovesLoop ; check if the move to learn is already known ld a, [hli] cp d - jr z, .asm_3afb1 + jr z, .done ; if already known, jump dec b - jr nz, .asm_3af98 + jr nz, .checkCurrentMovesLoop ld a, d ld [wd0e0], a ld [wd11e], a call GetMoveName call CopyStringToCF4B predef LearnMove -.asm_3afb1 +.done ld a, [wcf91] ld [wd11e], a ret @@ -484,7 +494,7 @@ WriteMonMoves_ShiftMoveData: ; 3b04e (e:704e) jr nz, .asm_3b050 ret -Func_3b057: ; 3b057 (e:7057) +Evolution_FlagAction: ; 3b057 (e:7057) predef_jump FlagActionPredef INCLUDE "data/evos_moves.asm" diff --git a/engine/experience.asm b/engine/experience.asm index 07726821b8..91f1dd5d7b 100755 --- a/engine/experience.asm +++ b/engine/experience.asm @@ -1,28 +1,30 @@ -Func_58f43: ; 58f43 (16:4f43) +; calculates the level a mon should be based on its current exp +CalcLevelFromExperience: ; 58f43 (16:4f43) ld a, [wcf98] ld [wd0b5], a call GetMonHeader - ld d, $1 -.asm_58f4e - inc d + ld d, $1 ; init level to 1 +.loop + inc d ; increment level call CalcExperience push hl - ld hl, wcfa8 - ld a, [$ff98] + ld hl, wcfa8 ; current exp +; compare exp needed for level d with current exp + ld a, [H_MULTIPLICAND + 2] ld c, a ld a, [hld] sub c - ld a, [$ff97] + ld a, [H_MULTIPLICAND + 1] ld c, a ld a, [hld] sbc c - ld a, [H_NUMTOPRINT] ; $ff96 (aliases: H_MULTIPLICAND) + ld a, [H_MULTIPLICAND] ld c, a ld a, [hl] sbc c pop hl - jr nc, .asm_58f4e - dec d + jr nc, .loop ; if exp needed for level d is not greater than exp, try the next level + dec d ; since the exp was too high on the last loop iteration, go back to the previous value and return ret ; calculates the amount of experience needed for level d diff --git a/engine/give_pokemon.asm b/engine/give_pokemon.asm index 9399fb050d..dd5e92647d 100755 --- a/engine/give_pokemon.asm +++ b/engine/give_pokemon.asm @@ -12,7 +12,7 @@ _GivePokemon: ; 4fda5 (13:7da5) ld [W_ENEMYBATTSTATUS3], a ; W_ENEMYBATTSTATUS3 ld a, [wcf91] ld [wEnemyMonSpecies2], a - callab Func_3eb01 + callab LoadEnemyMonData call SetPokedexOwnedFlag callab Func_e7a4 ld hl, wcf4b diff --git a/engine/hall_of_fame.asm b/engine/hall_of_fame.asm index f4384b9157..dd988cf193 100755 --- a/engine/hall_of_fame.asm +++ b/engine/hall_of_fame.asm @@ -32,7 +32,7 @@ AnimateHallOfFame: ; 701a0 (1c:41a0) inc [hl] .asm_701eb ld a, $90 - ld [$ffb0], a + ld [hVBlankWY], a ld c, BANK(Music_HallOfFame) ld a, MUSIC_HALL_OF_FAME call PlayMusic @@ -86,7 +86,7 @@ AnimateHallOfFame: ; 701a0 (1c:41a0) call Func_70377 call Func_70423 xor a - ld [$ffb0], a + ld [hVBlankWY], a ld hl, rLCDC ; $ff40 res 3, [hl] ret diff --git a/engine/hidden_object_functions17.asm b/engine/hidden_object_functions17.asm index f0126b6509..fccd426798 100755 --- a/engine/hidden_object_functions17.asm +++ b/engine/hidden_object_functions17.asm @@ -64,7 +64,7 @@ DisplayMonFrontSpriteInBox: ; 5dbd9 (17:5bd9) ld [H_AUTOBGTRANSFERENABLED], a ; $ffba call Delay3 xor a - ld [$ffb0], a + ld [hVBlankWY], a call SaveScreenTilesToBuffer1 ld a, $11 ld [wd125], a @@ -83,7 +83,7 @@ DisplayMonFrontSpriteInBox: ; 5dbd9 (17:5bd9) call LoadScreenTilesFromBuffer1 call Delay3 ld a, $90 - ld [$ffb0], a + ld [hVBlankWY], a ret PrintBlackboardLinkCableText: ; 5dc1a (17:5c1a) diff --git a/engine/hidden_object_functions3.asm b/engine/hidden_object_functions3.asm index e613df2ed3..11b91cd344 100755 --- a/engine/hidden_object_functions3.asm +++ b/engine/hidden_object_functions3.asm @@ -119,7 +119,7 @@ TownMapText: ; fc12 (3:7c12) set 6, [hl] call GBPalWhiteOutWithDelay3 xor a - ld [$ffb0], a + ld [hVBlankWY], a inc a ld [H_AUTOBGTRANSFERENABLED], a call LoadFontTilePatterns diff --git a/engine/items/items.asm b/engine/items/items.asm index 830f0dfc3b..b45c20da8c 100755 --- a/engine/items/items.asm +++ b/engine/items/items.asm @@ -237,7 +237,7 @@ ItemUseBall: ; d687 (3:5687) ld [H_QUOTIENT + 3],a .next9 ;$5776 pop bc - ld a,[wd007] ;enemy: Catch Rate + ld a,[wEnemyMonCatchRate] ;enemy: Catch Rate cp b jr c,.next10 ld a,[H_QUOTIENT + 2] @@ -256,7 +256,7 @@ ItemUseBall: ; d687 (3:5687) xor a ld [H_MULTIPLICAND],a ld [H_MULTIPLICAND + 1],a - ld a,[wd007] ;enemy: Catch Rate + ld a,[wEnemyMonCatchRate] ;enemy: Catch Rate ld [H_MULTIPLICAND + 2],a ld a,100 ld [H_MULTIPLIER],a @@ -376,7 +376,7 @@ ItemUseBall: ; d687 (3:5687) ld [wcf91],a ld a,[wEnemyMonLevel] ld [W_CURENEMYLVL],a - callab Func_3eb01 + callab LoadEnemyMonData pop af ld [wcf91],a pop hl @@ -647,7 +647,7 @@ ItemUseEvoStone: ; da5b (3:5a5b) ld a,(SFX_02_3e - SFX_Headers_02) / 3 call PlaySoundWaitForCurrent ; play sound call WaitForSoundToFinish ; wait for sound to end - callab Func_3ad0e ; try to evolve pokemon + callab TryEvolvingMon ; try to evolve pokemon ld a,[wd121] and a jr z,.noEffect @@ -805,7 +805,7 @@ ItemUseMedicine: ; dabb (3:5abb) push bc ld a,[wcf06] ld c,a - ld hl,wccf5 + ld hl,wPartyFoughtCurrentEnemyFlags ld b,$02 predef FlagActionPredef ld a,c @@ -813,7 +813,7 @@ ItemUseMedicine: ; dabb (3:5abb) jr z,.next ld a,[wcf06] ld c,a - ld hl,wPartyAliveFlags + ld hl,wPartyGainExpFlags ld b,$01 predef FlagActionPredef .next @@ -1273,10 +1273,10 @@ ItemUseMedicine: ; dabb (3:5abb) call WaitForTextScrollButtonPress ; wait for button press xor a ld [wcc49],a - predef Func_3af5b ; learn level up move, if any + predef LearnMoveFromLevelUp ; learn level up move, if any xor a ld [wccd4],a - callab Func_3ad0e ; evolve pokemon, if appropriate + callab TryEvolvingMon ; evolve pokemon, if appropriate ld a,$01 ld [wcfcb],a pop af @@ -1303,17 +1303,17 @@ VitaminText: ; df2e (3:5f2e) ItemUseBait: ; df52 (3:5f52) ld hl,ThrewBaitText call PrintText - ld hl,wd007 ; catch rate + ld hl,wEnemyMonCatchRate ; catch rate srl [hl] ; halve catch rate ld a,BAIT_ANIM - ld hl,wcce9 ; bait factor - ld de,wcce8 ; escape factor + ld hl,wSafariBaitFactor ; bait factor + ld de,wSafariEscapeFactor ; escape factor jr BaitRockCommon ItemUseRock: ; df67 (3:5f67) ld hl,ThrewRockText call PrintText - ld hl,wd007 ; catch rate + ld hl,wEnemyMonCatchRate ; catch rate ld a,[hl] add a ; double catch rate jr nc,.noCarry @@ -1321,8 +1321,8 @@ ItemUseRock: ; df67 (3:5f67) .noCarry ld [hl],a ld a,ROCK_ANIM - ld hl,wcce8 ; escape factor - ld de,wcce9 ; bait factor + ld hl,wSafariEscapeFactor ; escape factor + ld de,wSafariBaitFactor ; bait factor BaitRockCommon: ; df7f (3:5f7f) ld [W_ANIMATIONID],a @@ -1383,7 +1383,7 @@ ItemUseEscapeRope: ; dfaf (3:5faf) ld [W_NUMSAFARIBALLS],a ld [W_SAFARIZONEENTRANCECURSCRIPT],a inc a - ld [wd078],a + ld [wEscapedFromBattle],a ld [wcd6a],a ; item used ld a,[wd152] and a ; using Dig? @@ -1517,7 +1517,7 @@ ItemUsePokedoll: ; e0cd (3:60cd) dec a jp nz,ItemUseNotTime ld a,$01 - ld [wd078],a + ld [wEscapedFromBattle],a jp PrintItemUseTextAndRemoveItem ItemUseGuardSpec: ; e0dc (3:60dc) diff --git a/engine/menu/bills_pc.asm b/engine/menu/bills_pc.asm index 3edaadd890..b5ee9b94e4 100644 --- a/engine/menu/bills_pc.asm +++ b/engine/menu/bills_pc.asm @@ -523,7 +523,7 @@ PrintJustAMomentText1:: ; 5824 (8:5825) cp $c ret nz ld a, [W_CURMAP] - cp $ef + cp BATTLE_CENTER ld a, $2 jr z, .asm_2183a inc a @@ -541,7 +541,7 @@ PrintJustAMomentText2:: ; 5845 (8:5845) cp $8 ret nz ld a, [W_CURMAP] - cp $ef + cp BATTLE_CENTER ld a, $2 jr z, .asm_2185a inc a diff --git a/engine/menu/naming_screen.asm b/engine/menu/naming_screen.asm index 17aa96e671..7a0e7691b0 100755 --- a/engine/menu/naming_screen.asm +++ b/engine/menu/naming_screen.asm @@ -171,8 +171,8 @@ DisplayNamingScreen: ; 6596 (1:6596) ld a, [W_ISINBATTLE] ; W_ISINBATTLE and a jp z, LoadTextBoxTilePatterns - ld hl, Func_3ee5b - ld b, BANK(Func_3ee5b) + ld hl, LoadHudTilePatterns + ld b, BANK(LoadHudTilePatterns) jp Bankswitch .unknownPointerTable_665e: ; 665e (1:665e) diff --git a/engine/menu/party_menu.asm b/engine/menu/party_menu.asm index 4e47361bbe..10fc4182ec 100755 --- a/engine/menu/party_menu.asm +++ b/engine/menu/party_menu.asm @@ -57,7 +57,7 @@ RedrawPartyMenu_: ; 12ce3 (4:6ce3) call LoadMonData pop hl push hl - ld a,[wcc35] + ld a,[wMenuItemToSwap] and a ; is the player swapping pokemon positions? jr z,.skipUnfilledRightArrow ; if the player is swapping pokemon positions diff --git a/engine/menu/start_sub_menus.asm b/engine/menu/start_sub_menus.asm index 7c6fe4d6f2..6a64567586 100755 --- a/engine/menu/start_sub_menus.asm +++ b/engine/menu/start_sub_menus.asm @@ -11,14 +11,14 @@ StartMenu_Pokemon: ; 130a9 (4:70a9) and a jp z,RedisplayStartMenu xor a - ld [wcc35],a + ld [wMenuItemToSwap],a ld [wd07d],a ld [wcfcb],a call DisplayPartyMenu jr .checkIfPokemonChosen .loop xor a - ld [wcc35],a + ld [wMenuItemToSwap],a ld [wd07d],a call GoBackToPartyMenu .checkIfPokemonChosen @@ -336,7 +336,7 @@ StartMenu_Item: ; 13302 (4:7302) Coorda 5, 10 call PlaceUnfilledArrowMenuCursor xor a - ld [wcc35],a + ld [wMenuItemToSwap],a ld a,[wcf91] cp a,BICYCLE jp z,.useOrTossItem @@ -738,17 +738,17 @@ SwitchPartyMon_OAM: ; 13625 (4:7625) jp PlaySound SwitchPartyMon_Stats: ; 13653 (4:7653) - ld a, [wcc35] + ld a, [wMenuItemToSwap] and a jr nz, .asm_13661 ld a, [wWhichPokemon] ; wWhichPokemon inc a - ld [wcc35], a + ld [wMenuItemToSwap], a ret .asm_13661 xor a ld [wd07d], a - ld a, [wcc35] + ld a, [wMenuItemToSwap] dec a ld b, a ld a, [wCurrentMenuItem] ; wCurrentMenuItem @@ -756,12 +756,12 @@ SwitchPartyMon_Stats: ; 13653 (4:7653) cp b jr nz, .asm_1367b xor a - ld [wcc35], a + ld [wMenuItemToSwap], a ld [wd07d], a ret .asm_1367b ld a, b - ld [wcc35], a + ld [wMenuItemToSwap], a push hl push de ld hl, wPartySpecies @@ -773,7 +773,7 @@ SwitchPartyMon_Stats: ; 13653 (4:7653) jr nc, .asm_1368e inc h .asm_1368e - ld a, [wcc35] + ld a, [wMenuItemToSwap] add e ld e, a jr nc, .asm_13696 @@ -795,7 +795,7 @@ SwitchPartyMon_Stats: ; 13653 (4:7653) call CopyData ld hl, wPartyMons ld bc, $2c - ld a, [wcc35] + ld a, [wMenuItemToSwap] call AddNTimes pop de push hl @@ -813,7 +813,7 @@ SwitchPartyMon_Stats: ; 13653 (4:7653) ld bc, $b call CopyData ld hl, wPartyMonOT ; wd273 - ld a, [wcc35] + ld a, [wMenuItemToSwap] call SkipFixedLengthTextEntries pop de push hl @@ -831,7 +831,7 @@ SwitchPartyMon_Stats: ; 13653 (4:7653) ld bc, $b call CopyData ld hl, wPartyMonNicks ; wPartyMonNicks - ld a, [wcc35] + ld a, [wMenuItemToSwap] call SkipFixedLengthTextEntries pop de push hl @@ -841,10 +841,10 @@ SwitchPartyMon_Stats: ; 13653 (4:7653) ld hl, wcc97 ld bc, $b call CopyData - ld a, [wcc35] + ld a, [wMenuItemToSwap] ld [wWhichTrade], a ; wWhichTrade xor a - ld [wcc35], a + ld [wMenuItemToSwap], a ld [wd07d], a pop de pop hl diff --git a/engine/overworld/cable_club_npc.asm b/engine/overworld/cable_club_npc.asm index 9ae5b5083b..d071eee5b4 100755 --- a/engine/overworld/cable_club_npc.asm +++ b/engine/overworld/cable_club_npc.asm @@ -24,7 +24,7 @@ Func_71e1: ; 71e1 (1:71e1) ld a, $ff ld [$ffaa], a ld a, $2 - ld [$ff01], a + ld [rSB], a xor a ld [$ffad], a ld a, $80 @@ -34,7 +34,7 @@ Func_71e1: ; 71e1 (1:71e1) ld [wcc47], a jr z, .asm_7287 ; 0x720b $7a ld a, $1 - ld [$ff01], a + ld [rSB], a ld a, $81 ld [$ff02], a call DelayFrame @@ -148,7 +148,7 @@ Func_72d7: ; 72d7 (1:72d7) ld a, $ff ld [$ffaa], a ld a, $2 - ld [$ff01], a + ld [rSB], a xor a ld [$ffad], a ld a, $80 diff --git a/engine/overworld/cut.asm b/engine/overworld/cut.asm index 29b52eb9e1..d4d327e7bc 100755 --- a/engine/overworld/cut.asm +++ b/engine/overworld/cut.asm @@ -38,14 +38,14 @@ asm_ef82: ; ef82 (3:6f82) call ClearSprites call Func_3dbe ld a, $90 - ld [$ffb0], a + ld [hVBlankWY], a call Delay3 call LoadGBPal call LoadCurrentMapView call SaveScreenTilesToBuffer2 call Delay3 xor a - ld [$ffb0], a + ld [hVBlankWY], a ld hl, UsedCutText call PrintText call LoadScreenTilesFromBuffer2 @@ -63,7 +63,7 @@ asm_ef82: ; ef82 (3:6f82) ld a, (SFX_02_56 - SFX_Headers_02) / 3 call PlaySound ld a, $90 - ld [$ffb0], a + ld [hVBlankWY], a call UpdateSprites jp Func_eedc diff --git a/engine/predefs.asm b/engine/predefs.asm index 3ac9958527..669d77f42d 100755 --- a/engine/predefs.asm +++ b/engine/predefs.asm @@ -52,7 +52,7 @@ GetPredefPointer: PredefPointers:: ; 4fe79 (13:7e79) ; these are pointers to ASM routines. ; they appear to be used in overworld map scripts. - add_predef Func_3cd60 + add_predef DrawPlayerHUDAndHPBar add_predef Func_3f0c6 add_predef Func_3f073 add_predef ScaleSpriteByTwo @@ -78,7 +78,7 @@ PredefPointers:: ; 4fe79 (13:7e79) add_predef Func_ee9e add_predef InitPlayerData2 add_predef Func_c754 - add_predef Func_3af5b + add_predef LearnMoveFromLevelUp add_predef LearnMove add_predef IsItemInBag_ ; 1C, used in Pokémon Tower dbw $03,Func_3eb5 ; for these two, the bank number is actually 0 @@ -94,7 +94,7 @@ PredefPointers:: ; 4fe79 (13:7e79) add_predef Func_5ab0 add_predef Func_3ed02 add_predef ShowPokedexMenu - add_predef Func_3ad1c + add_predef EvolutionAfterBattle add_predef SaveSAVtoSRAM0 add_predef InitOpponent add_predef Func_5a5f @@ -125,7 +125,7 @@ PredefPointers:: ; 4fe79 (13:7e79) add_predef StarterDex ; 46 add_predef _AddPartyMon add_predef UpdateHPBar2 - add_predef Func_3cdec + add_predef DrawEnemyHUDAndHPBar add_predef LoadTownMap_Nest add_predef Func_27d6b add_predef EmotionBubble; 4C player exclamation diff --git a/engine/titlescreen.asm b/engine/titlescreen.asm index 10c5fad4a1..3f9cc61375 100755 --- a/engine/titlescreen.asm +++ b/engine/titlescreen.asm @@ -11,7 +11,7 @@ SetDefaultNamesBeforeTitlescreen: ; 42b7 (1:42b7) ld de, W_RIVALNAME ; wd34a call CopyFixedLengthText xor a - ld [$ffb0], a + ld [hVBlankWY], a ld [wd358], a ld hl, wd732 ld [hli], a @@ -31,7 +31,7 @@ LoadTitlescreenGraphics: ; 42dd (1:42dd) ld a, $40 ld [$ffaf], a ld a, $90 - ld [$ffb0], a + ld [hVBlankWY], a call ClearScreen call DisableLCD call LoadFontTilePatterns @@ -127,7 +127,7 @@ ENDC call Func_4533 call SaveScreenTilesToBuffer1 ld a, $40 - ld [$ffb0], a + ld [hVBlankWY], a call LoadScreenTilesFromBuffer2 ld a, $98 call Func_4533 @@ -182,7 +182,7 @@ ENDC call PlaySound call PrintGameVersionOnTitleScreen ld a, $90 - ld [$ffb0], a + ld [hVBlankWY], a ld d, $90 .asm_440a ld h, d @@ -225,7 +225,7 @@ ENDC call GBPalWhiteOutWithDelay3 call ClearSprites xor a - ld [$ffb0], a + ld [hVBlankWY], a inc a ld [H_AUTOBGTRANSFERENABLED], a ; $ffba call ClearScreen @@ -270,7 +270,7 @@ Func_4496: ; 4496 (1:4496) call Func_4524 ld a, $90 - ld [$ffb0], a + ld [hVBlankWY], a ld d, 1 ; scroll out callba TitleScroll ret @@ -279,7 +279,7 @@ Func_44c1: ; 44c1 (1:44c1) ld d, 0 ; scroll in callba TitleScroll xor a - ld [$ffb0], a + ld [hVBlankWY], a ret Func_44cf: ; 44cf (1:44cf) @@ -353,7 +353,7 @@ Func_4533: ; 4533 (1:4533) LoadCopyrightAndTextBoxTiles: ; 4538 (1:4538) xor a - ld [$ffb0], a + ld [hVBlankWY], a call ClearScreen call LoadTextBoxTilePatterns diff --git a/engine/trade.asm b/engine/trade.asm index 54abdab6ec..0f245fc5dc 100755 --- a/engine/trade.asm +++ b/engine/trade.asm @@ -175,7 +175,7 @@ Func_41245: ; 41245 (10:5245) ld a, $ab ld [rLCDC], a ; $ff40 ld a, $50 - ld [$ffb0], a + ld [hVBlankWY], a ld a, $86 ld [rWX], a ; $ff4b ld [$ffae], a @@ -397,7 +397,7 @@ Func_41411: ; 41411 (10:5411) xor a ld [$ffae], a ld a, $90 - ld [$ffb0], a + ld [hVBlankWY], a ret Func_4142d: ; 4142d (10:542d) @@ -655,7 +655,7 @@ Func_415c8: ; 415c8 (10:55c8) ld a, $7 ld [rWX], a ; $ff4b xor a - ld [$ffb0], a + ld [hVBlankWY], a ld a, $90 ld [$ffae], a ret diff --git a/home.asm b/home.asm index dc0b0889cb..2eea88eae5 100644 --- a/home.asm +++ b/home.asm @@ -417,7 +417,7 @@ HandlePartyMenuInput:: ; 145a (0:145a) ld [wcc2b],a ld hl,wd730 res 6,[hl] ; turn on letter printing delay - ld a,[wcc35] + ld a,[wMenuItemToSwap] and a jp nz,.swappingPokemon pop af @@ -449,7 +449,7 @@ HandlePartyMenuInput:: ; 145a (0:145a) .cancelSwap ; if the B button was pressed callba ErasePartyMenuCursors xor a - ld [wcc35],a + ld [wMenuItemToSwap],a ld [wd07d],a call RedrawPartyMenu jr HandlePartyMenuInput @@ -1155,10 +1155,10 @@ Serial:: ; 2125 (0:2125) ld a, [$ffaa] inc a jr z, .asm_2142 - ld a, [$ff01] + ld a, [rSB] ld [$ffad], a ld a, [$ffac] - ld [$ff01], a + ld [rSB], a ld a, [$ffaa] cp $2 jr z, .asm_2162 @@ -1166,13 +1166,13 @@ Serial:: ; 2125 (0:2125) ld [$ff02], a jr .asm_2162 .asm_2142 - ld a, [$ff01] + ld a, [rSB] ld [$ffad], a ld [$ffaa], a cp $2 jr z, .asm_215f xor a - ld [$ff01], a + ld [rSB], a ld a, $3 ld [rDIV], a ; $ff04 .asm_2153 @@ -1184,7 +1184,7 @@ Serial:: ; 2125 (0:2125) jr .asm_2162 .asm_215f xor a - ld [$ff01], a + ld [rSB], a .asm_2162 ld a, $1 ld [$ffa9], a @@ -1445,7 +1445,7 @@ Func_22ed:: ; 22ed (0:22ed) Func_22fa:: ; 22fa (0:22fa) ld a, $2 - ld [$ff01], a + ld [rSB], a xor a ld [$ffad], a ld a, $80 @@ -1697,7 +1697,7 @@ CloseTextDisplay:: ; 29e8 (0:29e8) ld a,[W_CURMAP] call SwitchToMapRomBank ld a,$90 - ld [$ffb0],a ; move the window off the screen + ld [hVBlankWY],a ; move the window off the screen call DelayFrame call LoadGBPal xor a @@ -1919,13 +1919,13 @@ DisplayListMenuID:: ; 2be6 (0:2be6) ld a,$01 ; hardcoded bank jr .bankswitch .specialBattleType ; Old Man battle - ld a, Bank(OldManItemList) + ld a, Bank(DisplayBattleMenu) .bankswitch call BankswitchHome ld hl,wd730 set 6,[hl] ; turn off letter printing delay xor a - ld [wcc35],a ; 0 means no item is currently being swapped + ld [wMenuItemToSwap],a ; 0 means no item is currently being swapped ld [wd12a],a ld a,[wcf8b] ld l,a @@ -2206,11 +2206,11 @@ DisplayChooseQuantityMenu:: ; 2d57 (0:2d57) jp .waitForKeyPressLoop .buttonAPressed ; the player chose to make the transaction xor a - ld [wcc35],a ; 0 means no item is currently being swapped + ld [wMenuItemToSwap],a ; 0 means no item is currently being swapped ret .buttonBPressed ; the player chose to cancel the transaction xor a - ld [wcc35],a ; 0 means no item is currently being swapped + ld [wMenuItemToSwap],a ; 0 means no item is currently being swapped ld a,$ff ret @@ -2232,7 +2232,7 @@ ExitListMenu:: ; 2e3b (0:2e3b) res 6,[hl] call BankswitchBack xor a - ld [wcc35],a ; 0 means no item is currently being swapped + ld [wMenuItemToSwap],a ; 0 means no item is currently being swapped scf ret @@ -2400,7 +2400,7 @@ PrintListMenuEntries:: ; 2e5a (0:2e5a) inc c push bc inc c - ld a,[wcc35] ; ID of item chosen for swapping (counts from 1) + ld a,[wMenuItemToSwap] ; ID of item chosen for swapping (counts from 1) and a ; is an item being swapped? jr z,.nextListEntry sla a @@ -2610,7 +2610,7 @@ ChooseFlyDestination:: ; 30a9 (0:30a9) ld hl, LoadTownMap_Fly jp Bankswitch -; causes the text box to close waithout waiting for a button press after displaying text +; causes the text box to close without waiting for a button press after displaying text DisableWaitingAfterTextDisplay:: ; 30b6 (0:30b6) ld a,$01 ld [wcc3c],a @@ -3095,7 +3095,7 @@ Func_3381:: ; 3381 (0:3381) jp WaitForSoundToFinish Func_33b7:: ; 33b7 (0:33b7) - ld a, [wcf0b] + ld a, [wBattleResult] and a jr nz, .asm_33c6 ld a, [W_PBSTOREDREGISTERH] diff --git a/home/init.asm b/home/init.asm index b79b19d9e5..cf8f448ec7 100644 --- a/home/init.asm +++ b/home/init.asm @@ -25,7 +25,7 @@ rLCDC_DEFAULT EQU %11100011 ld [rIE], a ld [$ff43], a ld [$ff42], a - ld [$ff01], a + ld [rSB], a ld [$ff02], a ld [$ff4b], a ld [$ff4a], a @@ -74,7 +74,7 @@ rLCDC_DEFAULT EQU %11100011 ld [rIE], a ld a, 144 ; move the window off-screen - ld [$ffb0], a + ld [hVBlankWY], a ld [rWY], a ld a, 7 ld [rWX], a diff --git a/home/overworld.asm b/home/overworld.asm index cf36aba84b..91f46dc0b0 100644 --- a/home/overworld.asm +++ b/home/overworld.asm @@ -766,7 +766,7 @@ HandleFlyOrTeleportAway:: call UpdateSprites call Delay3 xor a - ld [wcf0b], a + ld [wBattleResult], a ld [wd700], a ld [W_ISINBATTLE], a ld [wd35d], a diff --git a/home/vblank.asm b/home/vblank.asm index 15f9143789..b4daaa8be0 100644 --- a/home/vblank.asm +++ b/home/vblank.asm @@ -8,15 +8,15 @@ VBlank:: ld a, [H_LOADEDROMBANK] ld [wd122], a - ld a, [$ffae] + ld a, [hVBlankSCX] ld [rSCX], a - ld a, [$ffaf] + ld a, [hVBlankSCY] ld [rSCY], a ld a, [wd0a0] and a jr nz, .ok - ld a, [$ffb0] + ld a, [hVBlankWY] ld [rWY], a .ok diff --git a/hram.asm b/hram.asm index b88c248b90..1297480aee 100644 --- a/hram.asm +++ b/hram.asm @@ -32,6 +32,11 @@ H_NUMTOPRINT EQU $FF96 ; 3 bytes, big endian order H_POWEROFTEN EQU $FF99 ; 3 bytes, big endian order H_SAVEDNUMTOPRINT EQU $FF9C ; 3 bytes, big endian order (to back out of a subtraction) +; these values are copied to SCX, SCY, and WY during V-blank +hVBlankSCX EQU $FFAE +hVBlankSCY EQU $FFAF +hVBlankWY EQU $FFB0 + hJoyHeldLast EQU $FFB1 hJoyReleased EQU $FFB2 hJoyPressed EQU $FFB3 diff --git a/main.asm b/main.asm index 8c100de8d3..d9ed7bf7a2 100755 --- a/main.asm +++ b/main.asm @@ -22,7 +22,7 @@ INCLUDE "data/facing.asm" Func_40b0:: ; Reset player status on blackout. xor a - ld [wcf0b], a + ld [wBattleResult], a ld [wd700], a ld [W_ISINBATTLE], a ld [wd35d], a @@ -821,7 +821,7 @@ HandleItemListSwapping: ; 6b44 (1:6b44) pop hl inc a jp z,DisplayListMenuIDLoop ; ignore attempts to swap the Cancel menu item - ld a,[wcc35] ; ID of item chosen for swapping (counts from 1) + ld a,[wMenuItemToSwap] ; ID of item chosen for swapping (counts from 1) and a ; has the first item to swap already been chosen? jr nz,.swapItems ; if not, set the currently selected item as the first item @@ -830,7 +830,7 @@ HandleItemListSwapping: ; 6b44 (1:6b44) ld b,a ld a,[wListScrollOffset] ; index of top (visible) menu item within the list add b - ld [wcc35],a ; ID of item chosen for swapping (counts from 1) + ld [wMenuItemToSwap],a ; ID of item chosen for swapping (counts from 1) ld c,20 call DelayFrames jp DisplayListMenuIDLoop @@ -841,11 +841,11 @@ HandleItemListSwapping: ; 6b44 (1:6b44) ld a,[wListScrollOffset] add b ld b,a - ld a,[wcc35] ; ID of item chosen for swapping (counts from 1) + ld a,[wMenuItemToSwap] ; ID of item chosen for swapping (counts from 1) cp b ; is the currently selected item the same as the first item to swap? jp z,DisplayListMenuIDLoop ; ignore attempts to swap an item with itself dec a - ld [wcc35],a ; ID of item chosen for swapping (counts from 1) + ld [wMenuItemToSwap],a ; ID of item chosen for swapping (counts from 1) ld c,20 call DelayFrames push hl @@ -865,7 +865,7 @@ HandleItemListSwapping: ; 6b44 (1:6b44) ld c,a ld b,0 add hl,bc ; hl = address of currently selected item entry - ld a,[wcc35] ; ID of item chosen for swapping (counts from 1) + ld a,[wMenuItemToSwap] ; ID of item chosen for swapping (counts from 1) add a add e ld e,a @@ -892,7 +892,7 @@ HandleItemListSwapping: ; 6b44 (1:6b44) ld a,[$ff95] ld [de],a ; put second item ID in first item slot xor a - ld [wcc35],a ; 0 means no item is currently being swapped + ld [wMenuItemToSwap],a ; 0 means no item is currently being swapped pop de pop hl jp DisplayListMenuIDLoop @@ -944,7 +944,7 @@ HandleItemListSwapping: ; 6b44 (1:6b44) ld [wCurrentMenuItem],a .done xor a - ld [wcc35],a ; 0 means no item is currently being swapped + ld [wMenuItemToSwap],a ; 0 means no item is currently being swapped pop de pop hl jp DisplayListMenuIDLoop @@ -1059,7 +1059,7 @@ DisplayTextIDInit: ; 7096 (1:7096) ld b,$9c ; window background address call CopyScreenTileBufferToVRAM ; transfer background in WRAM to VRAM xor a - ld [$ffb0],a ; put the window on the screen + ld [hVBlankWY],a ; put the window on the screen call LoadFontTilePatterns ld a,$01 ld [H_AUTOBGTRANSFERENABLED],a ; enable continuous WRAM to VRAM transfer each V-blank @@ -2019,7 +2019,7 @@ INCLUDE "data/map_header_banks.asm" Func_c335: ; c335 (3:4335) ld a, $90 - ld [$ffb0], a + ld [hVBlankWY], a ld [rWY], a ; $ff4a xor a ld [H_AUTOBGTRANSFERENABLED], a ; $ffba @@ -3978,7 +3978,7 @@ Func_f51e: ; f51e (3:751e) add $2 ld [wcc49], a call LoadMonData - callba Func_58f43 + callba CalcLevelFromExperience ld a, d ld [W_CURENEMYLVL], a ; W_CURENEMYLVL pop hl diff --git a/scripts/ceruleanhouse2.asm b/scripts/ceruleanhouse2.asm index a45c0fdab7..7cc1aa74ee 100755 --- a/scripts/ceruleanhouse2.asm +++ b/scripts/ceruleanhouse2.asm @@ -27,7 +27,7 @@ CeruleanHouse2Text1: ; 74e15 (1d:4e15) ld [wcf8c], a xor a ld [wcf93], a - ld [wcc35], a + ld [wMenuItemToSwap], a ld a, SPECIALLISTMENU ld [wListMenuID], a call DisplayListMenuID diff --git a/scripts/daycarem.asm b/scripts/daycarem.asm index e463d38003..73ae66364d 100755 --- a/scripts/daycarem.asm +++ b/scripts/daycarem.asm @@ -26,7 +26,7 @@ DayCareMText1: ; 56254 (15:6254) xor a ld [wcfcb], a ld [wd07d], a - ld [wcc35], a + ld [wMenuItemToSwap], a call DisplayPartyMenu push af call GBPalWhiteOutWithDelay3 @@ -65,7 +65,7 @@ DayCareMScript_562e1: ; 562e1 (15:62e1) ld a, $3 ld [wcc49], a call LoadMonData - callab Func_58f43 + callab CalcLevelFromExperience ld a, d cp $64 jr c, .asm_56315 diff --git a/scripts/namerater.asm b/scripts/namerater.asm index ca357ad14a..28d53b1e62 100755 --- a/scripts/namerater.asm +++ b/scripts/namerater.asm @@ -51,7 +51,7 @@ NameRaterText1: ; 1da56 (7:5a56) xor a ld [wd07d], a ld [wcfcb], a - ld [wcc35], a + ld [wMenuItemToSwap], a call DisplayPartyMenu push af call GBPalWhiteOutWithDelay3 diff --git a/scripts/pokemontower6.asm b/scripts/pokemontower6.asm index fe33ce2957..646c956a51 100755 --- a/scripts/pokemontower6.asm +++ b/scripts/pokemontower6.asm @@ -57,7 +57,7 @@ PokemonTower6Script4: ; 60b48 (18:4b48) call UpdateSprites ld a, $f0 ld [wJoyIgnore], a - ld a, [wcf0b] + ld a, [wBattleResult] and a jr nz, .asm_60b82 ld hl, wd768 diff --git a/scripts/route12.asm b/scripts/route12.asm index b7ec451a9d..04b8620718 100755 --- a/scripts/route12.asm +++ b/scripts/route12.asm @@ -47,7 +47,7 @@ Route12Script3: ; 5964c (16:564c) cp $ff jr z, Route12Script_59606 call UpdateSprites - ld a, [wcf0b] + ld a, [wBattleResult] cp $2 jr z, .asm_59664 ld a, $e diff --git a/scripts/route16.asm b/scripts/route16.asm index 01bd35ad83..2e60d77ba3 100755 --- a/scripts/route16.asm +++ b/scripts/route16.asm @@ -48,7 +48,7 @@ Route16Script3: ; 5998f (16:598f) cp $ff jp z, Route16Script_59946 call UpdateSprites - ld a, [wcf0b] + ld a, [wBattleResult] cp $2 jr z, .asm_599a8 ld a, $b diff --git a/scripts/vermiliondock.asm b/scripts/vermiliondock.asm index 03dc4377d7..77216739ac 100755 --- a/scripts/vermiliondock.asm +++ b/scripts/vermiliondock.asm @@ -106,10 +106,10 @@ VermilionDock_1db9b: ; 1db9b (7:5b9b) jr nz, .asm_1dbfa ; 0x1dc22 $d6 xor a ld [$ff4a], a - ld [$ffb0], a + ld [hVBlankWY], a call VermilionDock_1dc94 ld a, $90 - ld [$ffb0], a + ld [hVBlankWY], a ld a, $1 ld [wcfcb], a pop hl diff --git a/text.asm b/text.asm index 57793c4238..c6cd43e389 100644 --- a/text.asm +++ b/text.asm @@ -1551,7 +1551,7 @@ _SafariZoneAngryText:: ; 89d6a (22:5d6a) _PickUpPayDayMoneyText:: ; 89d80 (22:5d80) text $52, " picked up" line "¥@" - TX_BCD wcce5, $c3 + TX_BCD wTotalPayDayMoney, $c3 text "!" prompt diff --git a/wram.asm b/wram.asm index 7e22f1249f..468e776e6f 100755 --- a/wram.asm +++ b/wram.asm @@ -247,7 +247,9 @@ wMenuJoypadPollCount:: ; cc34 ; how many times should HandleMenuInput poll the joypad state before it returns? ds 1 -wcc35:: ds 1 +wMenuItemToSwap:: ; cc35 +; id of menu item selected for swapping (counts from 1) (0 means that no menu item has been selected for swapping) + ds 1 wListScrollOffset:: ; cc36 ; offset of the current top menu item from the beginning of the list @@ -336,10 +338,18 @@ wEnemyMoveListIndex:: ; cce2 wcce3:: ds 1 wcce4:: ds 1 -wcce5:: ds 2 -wcce7:: ds 1 -wcce8:: ds 1 -wcce9:: ds 2 + +wTotalPayDayMoney:: ; cce5 +; total amount of money made using Pay Day during the current battle + ds 3 + +wSafariEscapeFactor:: ; cce8 + ds 1 +wSafariBaitFactor:: ; cce9 + ds 1; + + ds 1 + wcceb:: ds 1 wccec:: ds 1 wcced:: ds 1 @@ -350,16 +360,38 @@ wccf1:: ds 1 wccf2:: ds 1 wccf3:: ds 1 wccf4:: ds 1 -wccf5:: ds 1 + +wPartyFoughtCurrentEnemyFlags:: +; flags that indicate which party members have fought the current enemy mon + flag_array 6 + wccf6:: ds 1 wccf7:: ds 14 wcd05:: ds 1 wcd06:: ds 9 -wcd0f:: ds 1 -wcd10:: ds 1 -wcd11:: ds 1 -wcd12:: ds 1 -wcd13:: ds 7 + +wPlayerMonUnmodifiedLevel:: ; cd0f + ds 0 +wcd0f:: ; overload, used in in-game trade code + ds 1 +wPlayerMonUnmodifiedMaxHP:: ; cd10 + ds 0 +wcd10:: ; overload, used in in-game trade code + ds 1 +wcd11:: ; overload, used in in-game trade code + ds 1 +wPlayerMonUnmodifiedAttack:: ; cd12 + ds 0 +wcd12:: ; overload, used in in-game trade code + ds 1 +wcd13:: ; overload, used in in-game trade code (to store name string) + ds 1 +wPlayerMonUnmodifiedDefense:: ; cd14 + ds 2 +wPlayerMonUnmodifiedSpeed:: ; cd16 + ds 2 +wPlayerMonUnmodifiedSpecial:: ; cd18 + ds 2 ; stat modifiers for the player's current pokemon ; value can range from 1 - 13 ($1 to $D) @@ -381,9 +413,20 @@ wPlayerMonEvasionMod:: ; cd1f ds 3 -wcd23:: ds 3 -wcd26:: ds 3 -wcd29:: ds 4 +wEnemyMonUnmodifiedLevel:: ; cd23 + ds 1 +wEnemyMonUnmodifiedMaxHP:: ; cd24 + ds 2 +wEnemyMonUnmodifiedAttack:: ; cd26 + ds 2 +wEnemyMonUnmodifiedDefense:: ; cd28 + ds 1 +wcd29:: ; overload, used in in-game trade code + ds 1 +wEnemyMonUnmodifiedSpeed:: ; cd2a + ds 2 +wEnemyMonUnmodifiedSpecial:: ; cd2c + ds 1 wEngagedTrainerClass:: ; cd2d ds 1 @@ -505,7 +548,11 @@ wAnimSoundID:: ; cf07 wcf08:: ds 1 wcf09:: ds 1 wcf0a:: ds 1 -wcf0b:: ds 1 +wBattleResult:: ; cf0b +; $00 - win +; $01 - lose +; $02 - draw + ds 1 wcf0c:: ds 1 wcf0d:: ds 1 wcf0e:: ds 1 @@ -660,7 +707,7 @@ wEnemyMonStatus:: db wEnemyMonType:: wEnemyMonType1:: db wEnemyMonType2:: db -wEnemyMonCatchRate:: db +wEnemyMonCatchRate_NotReferenced:: db wEnemyMonMoves:: ds NUM_MOVES wEnemyMonDVs:: ds 2 wEnemyMonLevel:: db @@ -673,9 +720,9 @@ wEnemyMonPP:: ds 2 ; NUM_MOVES - 2 SECTION "WRAM Bank 1", WRAMX, BANK[1] ds 2 ; NUM_MOVES - 2 -wd002:: ds 5 -wd007:: ds 1 -wd008:: ds 1 +wEnemyMonBaseStats:: ds 5 +wEnemyMonCatchRate:: ds 1 +wEnemyMonBaseExp:: ds 1 wBattleMonNick:: ds 11 ; d009 wBattleMon:: battle_struct wBattleMon ; d014 @@ -705,7 +752,8 @@ W_ISINBATTLE:: ; d057 ; trainer battle, this is 2 ds 1 -wPartyAliveFlags:: ; d058 +wPartyGainExpFlags:: ; d058 +; flags that indicate which party members should be be given exp when GainExperience is called flag_array 6 W_CUROPPONENT:: ; d059 @@ -730,7 +778,12 @@ W_TRAINERNO:: ; d05d ; which instance of [youngster, lass, etc] is this? ds 1 -wd05e:: ds 1 +wCriticalHitOrOHKO:: ; d05e +; $00 = normal attack +; $01 = critical hit +; $02 = successful OHKO +; $ff = failed OHKO + ds 1 W_MOVEMISSED:: ; d05f ds 1 @@ -776,7 +829,10 @@ W_ENEMYBATTSTATUS2:: ; d068 W_ENEMYBATTSTATUS3:: ; d069 ds 1 -wd06a:: ds 1 +wPlayerNumAttacksLeft:: +; when the player is attacking multiple times, the number of attacks left + ds 1 + wd06b:: ds 1 W_PLAYERTOXICCOUNTER:: ; d06c @@ -786,7 +842,10 @@ W_PLAYERDISABLEDMOVE:: ; d06d ds 1 -wd06f:: ds 1 +wEnemyNumAttacksLeft:: +; when the player is attacking multiple times, the number of attacks left + ds 1 + wd070:: ds 1 W_ENEMYTOXICCOUNTER:: ; d071 @@ -801,7 +860,11 @@ W_NUMHITS:: ; d074 ds 1 wd075:: ds 3 -wd078:: ds 1 + +wEscapedFromBattle:: +; non-zero when an item or move that allows escape from battle was used + ds 1 + wd079:: ds 1 wd07a:: ds 1 wd07b:: ds 1 @@ -1016,7 +1079,11 @@ wd11c:: ds 1 wd11d:: ds 1 wd11e:: ds 1 wd11f:: ds 1 -wd120:: ds 1 + +wNumRunAttempts:: +; number of times the player has tried to run from battle + ds 1 + wd121:: ds 1 wd122:: ds 2 wd124:: ds 1 From cf399a8c86a7340a8c3162400657dca1c5d3ba0a Mon Sep 17 00:00:00 2001 From: yenatch Date: Tue, 12 Aug 2014 00:01:04 -0700 Subject: [PATCH 011/100] Split copy and serial functions out of home.asm. --- home.asm | 573 +----------------------------------------------- home/copy.asm | 24 ++ home/copy2.asm | 228 +++++++++++++++++++ home/serial.asm | 304 +++++++++++++++++++++++++ home/timer.asm | 3 + 5 files changed, 563 insertions(+), 569 deletions(-) create mode 100644 home/copy.asm create mode 100644 home/copy2.asm create mode 100644 home/serial.asm create mode 100644 home/timer.asm diff --git a/home.asm b/home.asm index 8c8f5c35f9..ad010cde5f 100644 --- a/home.asm +++ b/home.asm @@ -79,30 +79,7 @@ HideSprites:: jr nz, .loop ret -FarCopyData:: -; Copy bc bytes from a:hl to de. - ld [wBuffer], a - ld a, [H_LOADEDROMBANK] - push af - ld a, [wBuffer] - ld [H_LOADEDROMBANK], a - ld [MBC3RomBank], a - call CopyData - pop af - ld [H_LOADEDROMBANK], a - ld [MBC3RomBank], a - ret - -CopyData:: -; Copy bc bytes from hl to de. - ld a, [hli] - ld [de], a - inc de - dec bc - ld a, c - or b - jr nz, CopyData - ret +INCLUDE "home/copy.asm" SECTION "Entry", ROM0[$100] @@ -908,556 +885,14 @@ InterlaceMergeSpriteBuffers:: ; 16ea (0:16ea) INCLUDE "data/collision.asm" - - -FarCopyData2:: -; Identical to FarCopyData, but uses $ff8b -; as temp space instead of wBuffer. - ld [$ff8b],a - ld a,[H_LOADEDROMBANK] - push af - ld a,[$ff8b] - ld [H_LOADEDROMBANK],a - ld [MBC3RomBank],a - call CopyData - pop af - ld [H_LOADEDROMBANK],a - ld [MBC3RomBank],a - ret - -FarCopyData3:: -; Copy bc bytes from a:de to hl. - ld [$ff8b],a - ld a,[H_LOADEDROMBANK] - push af - ld a,[$ff8b] - ld [H_LOADEDROMBANK],a - ld [MBC3RomBank],a - push hl - push de - push de - ld d,h - ld e,l - pop hl - call CopyData - pop de - pop hl - pop af - ld [H_LOADEDROMBANK],a - ld [MBC3RomBank],a - ret - -FarCopyDataDouble:: -; Expand bc bytes of 1bpp image data -; from a:hl to 2bpp data at de. - ld [$ff8b],a - ld a,[H_LOADEDROMBANK] - push af - ld a,[$ff8b] - ld [H_LOADEDROMBANK],a - ld [MBC3RomBank],a -.loop - ld a,[hli] - ld [de],a - inc de - ld [de],a - inc de - dec bc - ld a,c - or b - jr nz,.loop - pop af - ld [H_LOADEDROMBANK],a - ld [MBC3RomBank],a - ret - -CopyVideoData:: -; 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. - - ld a, [H_AUTOBGTRANSFERENABLED] - push af - xor a ; disable auto-transfer while copying - ld [H_AUTOBGTRANSFERENABLED], a - - ld a, [H_LOADEDROMBANK] - ld [$ff8b], a - - ld a, b - ld [H_LOADEDROMBANK], a - ld [MBC3RomBank], a - - ld a, e - ld [H_VBCOPYSRC], a - ld a, d - ld [H_VBCOPYSRC + 1], a - - ld a, l - ld [H_VBCOPYDEST], a - ld a, h - ld [H_VBCOPYDEST + 1], a - -.loop - ld a, c - cp 8 - jr nc, .keepgoing - -.done - ld [H_VBCOPYSIZE], a - call DelayFrame - ld a, [$ff8b] - ld [H_LOADEDROMBANK], a - ld [MBC3RomBank], a - pop af - ld [H_AUTOBGTRANSFERENABLED], a - ret - -.keepgoing - ld a, 8 - ld [H_VBCOPYSIZE], a - call DelayFrame - ld a, c - sub 8 - ld c, a - jr .loop - -CopyVideoDataDouble:: -; Wait for the next VBlank, then copy c 1bpp -; tiles from b:de to hl, 8 tiles at a time. -; This takes c/8 frames. - ld a, [H_AUTOBGTRANSFERENABLED] - push af - xor a ; disable auto-transfer while copying - ld [H_AUTOBGTRANSFERENABLED], a - ld a, [H_LOADEDROMBANK] - ld [$ff8b], a - - ld a, b - ld [H_LOADEDROMBANK], a - ld [MBC3RomBank], a - - ld a, e - ld [H_VBCOPYDOUBLESRC], a - ld a, d - ld [H_VBCOPYDOUBLESRC + 1], a - - ld a, l - ld [H_VBCOPYDOUBLEDEST], a - ld a, h - ld [H_VBCOPYDOUBLEDEST + 1], a - -.loop - ld a, c - cp 8 - jr nc, .keepgoing - -.done - ld [H_VBCOPYDOUBLESIZE], a - call DelayFrame - ld a, [$ff8b] - ld [H_LOADEDROMBANK], a - ld [MBC3RomBank], a - pop af - ld [H_AUTOBGTRANSFERENABLED], a - ret - -.keepgoing - ld a, 8 - ld [H_VBCOPYDOUBLESIZE], a - call DelayFrame - ld a, c - sub 8 - ld c, a - jr .loop - -ClearScreenArea:: -; Clear tilemap area cxb at hl. - ld a, $7f ; blank tile - ld de, 20 ; screen width -.y - push hl - push bc -.x - ld [hli], a - dec c - jr nz, .x - pop bc - pop hl - add hl, de - dec b - jr nz, .y - ret - -CopyScreenTileBufferToVRAM:: -; Copy wTileMap to the BG Map starting at b * $100. -; This is done in thirds of 6 rows, so it takes 3 frames. - - ld c, 6 - - ld hl, $600 * 0 - ld de, wTileMap + 20 * 6 * 0 - call .setup - call DelayFrame - - ld hl, $600 * 1 - ld de, wTileMap + 20 * 6 * 1 - call .setup - call DelayFrame - - ld hl, $600 * 2 - ld de, wTileMap + 20 * 6 * 2 - call .setup - jp DelayFrame - -.setup - ld a, d - ld [H_VBCOPYBGSRC+1], a - call GetRowColAddressBgMap - ld a, l - ld [H_VBCOPYBGDEST], a - ld a, h - ld [H_VBCOPYBGDEST+1], a - ld a, c - ld [H_VBCOPYBGNUMROWS], a - ld a, e - ld [H_VBCOPYBGSRC], a - ret - -ClearScreen:: -; Clear wTileMap, then wait -; for the bg map to update. - ld bc, 20 * 18 - inc b - ld hl, wTileMap - ld a, $7f -.loop - ld [hli], a - dec c - jr nz, .loop - dec b - jr nz, .loop - jp Delay3 - - +INCLUDE "home/copy2.asm" INCLUDE "home/text.asm" INCLUDE "home/vcopy.asm" INCLUDE "home/init.asm" INCLUDE "home/vblank.asm" INCLUDE "home/fade.asm" - - -Serial:: ; 2125 (0:2125) - push af - push bc - push de - push hl - ld a, [$ffaa] - inc a - jr z, .asm_2142 - ld a, [$ff01] - ld [$ffad], a - ld a, [$ffac] - ld [$ff01], a - ld a, [$ffaa] - cp $2 - jr z, .asm_2162 - ld a, $80 - ld [$ff02], a - jr .asm_2162 -.asm_2142 - ld a, [$ff01] - ld [$ffad], a - ld [$ffaa], a - cp $2 - jr z, .asm_215f - xor a - ld [$ff01], a - ld a, $3 - ld [rDIV], a ; $ff04 -.asm_2153 - ld a, [rDIV] ; $ff04 - bit 7, a - jr nz, .asm_2153 - ld a, $80 - ld [$ff02], a - jr .asm_2162 -.asm_215f - xor a - ld [$ff01], a -.asm_2162 - ld a, $1 - ld [$ffa9], a - ld a, $fe - ld [$ffac], a - pop hl - pop de - pop bc - pop af - reti - -Func_216f:: ; 216f (0:216f) - ld a, $1 - ld [$ffab], a -.asm_2173 - ld a, [hl] - ld [$ffac], a - call Func_219a - push bc - ld b, a - inc hl - ld a, $30 -.asm_217e - dec a - jr nz, .asm_217e - ld a, [$ffab] - and a - ld a, b - pop bc - jr z, .asm_2192 - dec hl - cp $fd - jr nz, .asm_2173 - xor a - ld [$ffab], a - jr .asm_2173 -.asm_2192 - ld [de], a - inc de - dec bc - ld a, b - or c - jr nz, .asm_2173 - ret - -Func_219a:: ; 219a (0:219a) - xor a - ld [$ffa9], a - ld a, [$ffaa] - cp $2 - jr nz, .asm_21a7 - ld a, $81 - ld [$ff02], a -.asm_21a7 - ld a, [$ffa9] - and a - jr nz, .asm_21f1 - ld a, [$ffaa] - cp $1 - jr nz, .asm_21cc - call Func_2237 - jr z, .asm_21cc - call Func_2231 - push hl - ld hl, wcc48 - inc [hl] - jr nz, .asm_21c3 - dec hl - inc [hl] -.asm_21c3 - pop hl - call Func_2237 - jr nz, .asm_21a7 - jp Func_223f -.asm_21cc - ld a, [rIE] ; $ffff - and $f - cp $8 - jr nz, .asm_21a7 - ld a, [W_NUMHITS] ; wd074 - dec a - ld [W_NUMHITS], a ; wd074 - jr nz, .asm_21a7 - ld a, [wd075] - dec a - ld [wd075], a - jr nz, .asm_21a7 - ld a, [$ffaa] - cp $1 - jr z, .asm_21f1 - ld a, $ff -.asm_21ee - dec a - jr nz, .asm_21ee -.asm_21f1 - xor a - ld [$ffa9], a - ld a, [rIE] ; $ffff - and $f - sub $8 - jr nz, .asm_2204 - ld [W_NUMHITS], a ; wd074 - ld a, $50 - ld [wd075], a -.asm_2204 - ld a, [$ffad] - cp $fe - ret nz - call Func_2237 - jr z, .asm_221f - push hl - ld hl, wcc48 - ld a, [hl] - dec a - ld [hld], a - inc a - jr nz, .asm_2219 - dec [hl] -.asm_2219 - pop hl - call Func_2237 - jr z, Func_223f -.asm_221f - ld a, [rIE] ; $ffff - and $f - cp $8 - ld a, $fe - ret z - ld a, [hl] - ld [$ffac], a - call DelayFrame - jp Func_219a - -Func_2231:: ; 2231 (0:2231) - ld a, $f -.asm_2233 - dec a - jr nz, .asm_2233 - ret - -Func_2237:: ; 2237 (0:2237) - push hl - ld hl, wcc47 - ld a, [hli] - or [hl] - pop hl - ret - -Func_223f:: ; 223f (0:223f) - dec a - ld [wcc47], a - ld [wcc48], a - ret - -Func_2247:: ; 2247 (0:2247) - ld hl, wcc42 - ld de, wcc3d - ld c, $2 - ld a, $1 - ld [$ffab], a -.asm_2253 - call DelayFrame - ld a, [hl] - ld [$ffac], a - call Func_219a - ld b, a - inc hl - ld a, [$ffab] - and a - ld a, $0 - ld [$ffab], a - jr nz, .asm_2253 - ld a, b - ld [de], a - inc de - dec c - jr nz, .asm_2253 - ret - -Func_226e:: ; 226e (0:226e) - call SaveScreenTilesToBuffer1 - callab PrintWaitingText - call Func_227f - jp LoadScreenTilesFromBuffer1 - -Func_227f:: ; 227f (0:227f) - ld a, $ff - ld [wcc3e], a -.asm_2284 - call Func_22c3 - call DelayFrame - call Func_2237 - jr z, .asm_22a0 - push hl - ld hl, wcc48 - dec [hl] - jr nz, .asm_229f - dec hl - dec [hl] - jr nz, .asm_229f - pop hl - xor a - jp Func_223f -.asm_229f - pop hl -.asm_22a0 - ld a, [wcc3e] - inc a - jr z, .asm_2284 - ld b, $a -.asm_22a8 - call DelayFrame - call Func_22c3 - dec b - jr nz, .asm_22a8 - ld b, $a -.asm_22b3 - call DelayFrame - call Func_22ed - dec b - jr nz, .asm_22b3 - ld a, [wcc3e] - ld [wcc3d], a - ret - -Func_22c3:: ; 22c3 (0:22c3) - call asm_22d7 - ld a, [wcc42] - add $60 - ld [$ffac], a - ld a, [$ffaa] - cp $2 - jr nz, asm_22d7 - ld a, $81 - ld [$ff02], a -asm_22d7:: ; 22d7 (0:22d7) - ld a, [$ffad] - ld [wcc3d], a - and $f0 - cp $60 - ret nz - xor a - ld [$ffad], a - ld a, [wcc3d] - and $f - ld [wcc3e], a - ret - -Func_22ed:: ; 22ed (0:22ed) - xor a - ld [$ffac], a - ld a, [$ffaa] - cp $2 - ret nz - ld a, $81 - ld [$ff02], a - ret - -Func_22fa:: ; 22fa (0:22fa) - ld a, $2 - ld [$ff01], a - xor a - ld [$ffad], a - ld a, $80 - ld [$ff02], a - ret - - -; timer interrupt is apparently not invoked anyway -Timer:: ; 2306 (0:2306) - reti - - +INCLUDE "home/serial.asm" +INCLUDE "home/timer.asm" INCLUDE "home/audio.asm" diff --git a/home/copy.asm b/home/copy.asm new file mode 100644 index 0000000000..a6c298e4f4 --- /dev/null +++ b/home/copy.asm @@ -0,0 +1,24 @@ +FarCopyData:: +; Copy bc bytes from a:hl to de. + ld [wBuffer], a + ld a, [H_LOADEDROMBANK] + push af + ld a, [wBuffer] + ld [H_LOADEDROMBANK], a + ld [MBC3RomBank], a + call CopyData + pop af + ld [H_LOADEDROMBANK], a + ld [MBC3RomBank], a + ret + +CopyData:: +; Copy bc bytes from hl to de. + ld a, [hli] + ld [de], a + inc de + dec bc + ld a, c + or b + jr nz, CopyData + ret diff --git a/home/copy2.asm b/home/copy2.asm new file mode 100644 index 0000000000..f7e0a9da55 --- /dev/null +++ b/home/copy2.asm @@ -0,0 +1,228 @@ +FarCopyData2:: +; Identical to FarCopyData, but uses $ff8b +; as temp space instead of wBuffer. + ld [$ff8b],a + ld a,[H_LOADEDROMBANK] + push af + ld a,[$ff8b] + ld [H_LOADEDROMBANK],a + ld [MBC3RomBank],a + call CopyData + pop af + ld [H_LOADEDROMBANK],a + ld [MBC3RomBank],a + ret + +FarCopyData3:: +; Copy bc bytes from a:de to hl. + ld [$ff8b],a + ld a,[H_LOADEDROMBANK] + push af + ld a,[$ff8b] + ld [H_LOADEDROMBANK],a + ld [MBC3RomBank],a + push hl + push de + push de + ld d,h + ld e,l + pop hl + call CopyData + pop de + pop hl + pop af + ld [H_LOADEDROMBANK],a + ld [MBC3RomBank],a + ret + +FarCopyDataDouble:: +; Expand bc bytes of 1bpp image data +; from a:hl to 2bpp data at de. + ld [$ff8b],a + ld a,[H_LOADEDROMBANK] + push af + ld a,[$ff8b] + ld [H_LOADEDROMBANK],a + ld [MBC3RomBank],a +.loop + ld a,[hli] + ld [de],a + inc de + ld [de],a + inc de + dec bc + ld a,c + or b + jr nz,.loop + pop af + ld [H_LOADEDROMBANK],a + ld [MBC3RomBank],a + ret + +CopyVideoData:: +; 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. + + ld a, [H_AUTOBGTRANSFERENABLED] + push af + xor a ; disable auto-transfer while copying + ld [H_AUTOBGTRANSFERENABLED], a + + ld a, [H_LOADEDROMBANK] + ld [$ff8b], a + + ld a, b + ld [H_LOADEDROMBANK], a + ld [MBC3RomBank], a + + ld a, e + ld [H_VBCOPYSRC], a + ld a, d + ld [H_VBCOPYSRC + 1], a + + ld a, l + ld [H_VBCOPYDEST], a + ld a, h + ld [H_VBCOPYDEST + 1], a + +.loop + ld a, c + cp 8 + jr nc, .keepgoing + +.done + ld [H_VBCOPYSIZE], a + call DelayFrame + ld a, [$ff8b] + ld [H_LOADEDROMBANK], a + ld [MBC3RomBank], a + pop af + ld [H_AUTOBGTRANSFERENABLED], a + ret + +.keepgoing + ld a, 8 + ld [H_VBCOPYSIZE], a + call DelayFrame + ld a, c + sub 8 + ld c, a + jr .loop + +CopyVideoDataDouble:: +; Wait for the next VBlank, then copy c 1bpp +; tiles from b:de to hl, 8 tiles at a time. +; This takes c/8 frames. + ld a, [H_AUTOBGTRANSFERENABLED] + push af + xor a ; disable auto-transfer while copying + ld [H_AUTOBGTRANSFERENABLED], a + ld a, [H_LOADEDROMBANK] + ld [$ff8b], a + + ld a, b + ld [H_LOADEDROMBANK], a + ld [MBC3RomBank], a + + ld a, e + ld [H_VBCOPYDOUBLESRC], a + ld a, d + ld [H_VBCOPYDOUBLESRC + 1], a + + ld a, l + ld [H_VBCOPYDOUBLEDEST], a + ld a, h + ld [H_VBCOPYDOUBLEDEST + 1], a + +.loop + ld a, c + cp 8 + jr nc, .keepgoing + +.done + ld [H_VBCOPYDOUBLESIZE], a + call DelayFrame + ld a, [$ff8b] + ld [H_LOADEDROMBANK], a + ld [MBC3RomBank], a + pop af + ld [H_AUTOBGTRANSFERENABLED], a + ret + +.keepgoing + ld a, 8 + ld [H_VBCOPYDOUBLESIZE], a + call DelayFrame + ld a, c + sub 8 + ld c, a + jr .loop + +ClearScreenArea:: +; Clear tilemap area cxb at hl. + ld a, $7f ; blank tile + ld de, 20 ; screen width +.y + push hl + push bc +.x + ld [hli], a + dec c + jr nz, .x + pop bc + pop hl + add hl, de + dec b + jr nz, .y + ret + +CopyScreenTileBufferToVRAM:: +; Copy wTileMap to the BG Map starting at b * $100. +; This is done in thirds of 6 rows, so it takes 3 frames. + + ld c, 6 + + ld hl, $600 * 0 + ld de, wTileMap + 20 * 6 * 0 + call .setup + call DelayFrame + + ld hl, $600 * 1 + ld de, wTileMap + 20 * 6 * 1 + call .setup + call DelayFrame + + ld hl, $600 * 2 + ld de, wTileMap + 20 * 6 * 2 + call .setup + jp DelayFrame + +.setup + ld a, d + ld [H_VBCOPYBGSRC+1], a + call GetRowColAddressBgMap + ld a, l + ld [H_VBCOPYBGDEST], a + ld a, h + ld [H_VBCOPYBGDEST+1], a + ld a, c + ld [H_VBCOPYBGNUMROWS], a + ld a, e + ld [H_VBCOPYBGSRC], a + ret + +ClearScreen:: +; Clear wTileMap, then wait +; for the bg map to update. + ld bc, 20 * 18 + inc b + ld hl, wTileMap + ld a, $7f +.loop + ld [hli], a + dec c + jr nz, .loop + dec b + jr nz, .loop + jp Delay3 diff --git a/home/serial.asm b/home/serial.asm new file mode 100644 index 0000000000..02eb35347e --- /dev/null +++ b/home/serial.asm @@ -0,0 +1,304 @@ +Serial:: ; 2125 (0:2125) + push af + push bc + push de + push hl + ld a, [$ffaa] + inc a + jr z, .asm_2142 + ld a, [$ff01] + ld [$ffad], a + ld a, [$ffac] + ld [$ff01], a + ld a, [$ffaa] + cp $2 + jr z, .asm_2162 + ld a, $80 + ld [$ff02], a + jr .asm_2162 +.asm_2142 + ld a, [$ff01] + ld [$ffad], a + ld [$ffaa], a + cp $2 + jr z, .asm_215f + xor a + ld [$ff01], a + ld a, $3 + ld [rDIV], a ; $ff04 +.asm_2153 + ld a, [rDIV] ; $ff04 + bit 7, a + jr nz, .asm_2153 + ld a, $80 + ld [$ff02], a + jr .asm_2162 +.asm_215f + xor a + ld [$ff01], a +.asm_2162 + ld a, $1 + ld [$ffa9], a + ld a, $fe + ld [$ffac], a + pop hl + pop de + pop bc + pop af + reti + +Func_216f:: ; 216f (0:216f) + ld a, $1 + ld [$ffab], a +.asm_2173 + ld a, [hl] + ld [$ffac], a + call Func_219a + push bc + ld b, a + inc hl + ld a, $30 +.asm_217e + dec a + jr nz, .asm_217e + ld a, [$ffab] + and a + ld a, b + pop bc + jr z, .asm_2192 + dec hl + cp $fd + jr nz, .asm_2173 + xor a + ld [$ffab], a + jr .asm_2173 +.asm_2192 + ld [de], a + inc de + dec bc + ld a, b + or c + jr nz, .asm_2173 + ret + +Func_219a:: ; 219a (0:219a) + xor a + ld [$ffa9], a + ld a, [$ffaa] + cp $2 + jr nz, .asm_21a7 + ld a, $81 + ld [$ff02], a +.asm_21a7 + ld a, [$ffa9] + and a + jr nz, .asm_21f1 + ld a, [$ffaa] + cp $1 + jr nz, .asm_21cc + call Func_2237 + jr z, .asm_21cc + call Func_2231 + push hl + ld hl, wcc48 + inc [hl] + jr nz, .asm_21c3 + dec hl + inc [hl] +.asm_21c3 + pop hl + call Func_2237 + jr nz, .asm_21a7 + jp Func_223f +.asm_21cc + ld a, [rIE] ; $ffff + and $f + cp $8 + jr nz, .asm_21a7 + ld a, [W_NUMHITS] ; wd074 + dec a + ld [W_NUMHITS], a ; wd074 + jr nz, .asm_21a7 + ld a, [wd075] + dec a + ld [wd075], a + jr nz, .asm_21a7 + ld a, [$ffaa] + cp $1 + jr z, .asm_21f1 + ld a, $ff +.asm_21ee + dec a + jr nz, .asm_21ee +.asm_21f1 + xor a + ld [$ffa9], a + ld a, [rIE] ; $ffff + and $f + sub $8 + jr nz, .asm_2204 + ld [W_NUMHITS], a ; wd074 + ld a, $50 + ld [wd075], a +.asm_2204 + ld a, [$ffad] + cp $fe + ret nz + call Func_2237 + jr z, .asm_221f + push hl + ld hl, wcc48 + ld a, [hl] + dec a + ld [hld], a + inc a + jr nz, .asm_2219 + dec [hl] +.asm_2219 + pop hl + call Func_2237 + jr z, Func_223f +.asm_221f + ld a, [rIE] ; $ffff + and $f + cp $8 + ld a, $fe + ret z + ld a, [hl] + ld [$ffac], a + call DelayFrame + jp Func_219a + +Func_2231:: ; 2231 (0:2231) + ld a, $f +.asm_2233 + dec a + jr nz, .asm_2233 + ret + +Func_2237:: ; 2237 (0:2237) + push hl + ld hl, wcc47 + ld a, [hli] + or [hl] + pop hl + ret + +Func_223f:: ; 223f (0:223f) + dec a + ld [wcc47], a + ld [wcc48], a + ret + +Func_2247:: ; 2247 (0:2247) + ld hl, wcc42 + ld de, wcc3d + ld c, $2 + ld a, $1 + ld [$ffab], a +.asm_2253 + call DelayFrame + ld a, [hl] + ld [$ffac], a + call Func_219a + ld b, a + inc hl + ld a, [$ffab] + and a + ld a, $0 + ld [$ffab], a + jr nz, .asm_2253 + ld a, b + ld [de], a + inc de + dec c + jr nz, .asm_2253 + ret + +Func_226e:: ; 226e (0:226e) + call SaveScreenTilesToBuffer1 + callab PrintWaitingText + call Func_227f + jp LoadScreenTilesFromBuffer1 + +Func_227f:: ; 227f (0:227f) + ld a, $ff + ld [wcc3e], a +.asm_2284 + call Func_22c3 + call DelayFrame + call Func_2237 + jr z, .asm_22a0 + push hl + ld hl, wcc48 + dec [hl] + jr nz, .asm_229f + dec hl + dec [hl] + jr nz, .asm_229f + pop hl + xor a + jp Func_223f +.asm_229f + pop hl +.asm_22a0 + ld a, [wcc3e] + inc a + jr z, .asm_2284 + ld b, $a +.asm_22a8 + call DelayFrame + call Func_22c3 + dec b + jr nz, .asm_22a8 + ld b, $a +.asm_22b3 + call DelayFrame + call Func_22ed + dec b + jr nz, .asm_22b3 + ld a, [wcc3e] + ld [wcc3d], a + ret + +Func_22c3:: ; 22c3 (0:22c3) + call asm_22d7 + ld a, [wcc42] + add $60 + ld [$ffac], a + ld a, [$ffaa] + cp $2 + jr nz, asm_22d7 + ld a, $81 + ld [$ff02], a +asm_22d7:: ; 22d7 (0:22d7) + ld a, [$ffad] + ld [wcc3d], a + and $f0 + cp $60 + ret nz + xor a + ld [$ffad], a + ld a, [wcc3d] + and $f + ld [wcc3e], a + ret + +Func_22ed:: ; 22ed (0:22ed) + xor a + ld [$ffac], a + ld a, [$ffaa] + cp $2 + ret nz + ld a, $81 + ld [$ff02], a + ret + +Func_22fa:: ; 22fa (0:22fa) + ld a, $2 + ld [$ff01], a + xor a + ld [$ffad], a + ld a, $80 + ld [$ff02], a + ret diff --git a/home/timer.asm b/home/timer.asm new file mode 100644 index 0000000000..8578df1a0b --- /dev/null +++ b/home/timer.asm @@ -0,0 +1,3 @@ +; timer interrupt is apparently not invoked anyway +Timer:: ; 2306 (0:2306) + reti From 365ae68d80683deab0e2e721b8ff79dda4047513 Mon Sep 17 00:00:00 2001 From: yenatch Date: Fri, 22 Aug 2014 23:17:47 -0700 Subject: [PATCH 012/100] Use PARTY_LENGTH and related constants in menu and hud code. This should allow reducing PARTY_LENGTH to work as intended. Increasing it also works provided space is provided in wram, but breaks pc/saving. --- engine/battle/e.asm | 6 ++-- engine/give_pokemon.asm | 16 ++++----- engine/items/items.asm | 6 ++-- engine/menu/bills_pc.asm | 74 +++++++++++++++++----------------------- engine/save.asm | 10 +++--- main.asm | 10 +++--- scripts/daycarem.asm | 8 ++--- scripts/route5gate.asm | 8 ++--- 8 files changed, 64 insertions(+), 74 deletions(-) diff --git a/engine/battle/e.asm b/engine/battle/e.asm index a0d9d80c02..9abeeec8fc 100755 --- a/engine/battle/e.asm +++ b/engine/battle/e.asm @@ -1407,14 +1407,14 @@ SetupEnemyPartyPokeballs: ; 3a887 (e:6887) ld [hl], $20 ld a, $f8 ld [wTrainerEngageDistance], a - ld hl, wOAMBuffer + $18 + ld hl, wOAMBuffer + PARTY_LENGTH * 4 jp Func_3a8e1 SetupPokeballs: ; 0x3a8a6 ld a, [de] push af ld de, wBuffer - ld c, $6 ; max num of partymons + ld c, PARTY_LENGTH ld a, $34 ; empty pokeball .emptyloop ld [de], a @@ -1462,7 +1462,7 @@ PickPokeball: ; 3a8c2 (e:68c2) Func_3a8e1: ; 3a8e1 (e:68e1) ld de, wHPBarMaxHP - ld c, $6 + ld c, PARTY_LENGTH .asm_3a8e6 ld a, [W_BASECOORDY] ; wd082 ld [hli], a diff --git a/engine/give_pokemon.asm b/engine/give_pokemon.asm index 9399fb050d..f3bd7f785e 100755 --- a/engine/give_pokemon.asm +++ b/engine/give_pokemon.asm @@ -3,10 +3,10 @@ _GivePokemon: ; 4fda5 (13:7da5) xor a ld [wccd3], a ld a, [wPartyCount] ; wPartyCount - cp $6 + cp PARTY_LENGTH jr c, .asm_4fe01 ld a, [W_NUMINBOX] ; wda80 - cp $14 + cp MONS_PER_BOX jr nc, .asm_4fdf9 xor a ld [W_ENEMYBATTSTATUS3], a ; W_ENEMYBATTSTATUS3 @@ -18,18 +18,18 @@ _GivePokemon: ; 4fda5 (13:7da5) ld hl, wcf4b ld a, [wd5a0] and $7f - cp $9 + cp 9 jr c, .asm_4fdec - sub $9 - ld [hl], $f7 + sub 9 + ld [hl], "1" inc hl - add $f6 + add "0" jr .asm_4fdee .asm_4fdec - add $f7 + add "1" .asm_4fdee ld [hli], a - ld [hl], $50 + ld [hl], "@" ld hl, SetToBoxText call PrintText scf diff --git a/engine/items/items.asm b/engine/items/items.asm index 830f0dfc3b..0609e68526 100755 --- a/engine/items/items.asm +++ b/engine/items/items.asm @@ -110,10 +110,10 @@ ItemUseBall: ; d687 (3:5687) dec a jr z,.UseBall ld a,[wPartyCount] ;is Party full? - cp a,6 + cp a,PARTY_LENGTH jr nz,.UseBall ld a,[W_NUMINBOX] ;is Box full? - cp a,20 + cp a,MONS_PER_BOX jp z,BoxFullCannotThrowBall .UseBall ;$56a7 ;ok, you can use a ball @@ -421,7 +421,7 @@ ItemUseBall: ; d687 (3:5687) predef ShowPokedexData .checkParty ;$58f4 ld a,[wPartyCount] - cp a,6 ;is party full? + cp a,PARTY_LENGTH ;is party full? jr z,.sendToBox xor a ld [wcc49],a diff --git a/engine/menu/bills_pc.asm b/engine/menu/bills_pc.asm index 3edaadd890..b06927d88f 100644 --- a/engine/menu/bills_pc.asm +++ b/engine/menu/bills_pc.asm @@ -88,25 +88,13 @@ Func_213c8:: ; 213c8 (8:53c8) ld [H_AUTOBGTRANSFERENABLED], a ; $ffba ret -SomeonesPCText: ; 2148b (8:548b) - db "SOMEONE's PC@" +SomeonesPCText: db "SOMEONE's PC@" +BillsPCText: db "BILL's PC@" +PlayersPCText: db "'s PC@" +OaksPCText: db "PROF.OAK's PC@" +PKMNLeaguePCText: db $4a, "LEAGUE@" +LogOffPCText: db "LOG OFF@" -BillsPCText: ; 21497 (8:5497) - db "BILL's PC@" - -PlayersPCText: ; 214a0 (8:54a0) - db "'s PC@" - -OaksPCText: ; 214a5 (8:54a5) - db "PROF.OAK's PC@" - -PKMNLeaguePCText: ; 214b2 (8:54b2) - db $4a,"LEAGUE@" - -LogOffPCText: ; 214ba (8:54ba) - db "LOG OFF@" - -Func_214c2:: ; 214c2 (8:54c2) BillsPC_:: ; 0x214c2 ld hl, wd730 set 6, [hl] @@ -167,15 +155,15 @@ BillsPCMenu: call TextBoxBorder ld a, [wd5a0] and $7f - cp $9 + cp 9 jr c, .asm_2154f - sub $9 + sub 9 hlCoord 17, 16 - ld [hl], $f7 - add $f6 + ld [hl], "1" + add "0" jr .asm_21551 .asm_2154f - add $f7 + add "1" .asm_21551 Coorda 18, 16 hlCoord 10, 16 @@ -227,7 +215,7 @@ BillsPCDeposit: jp BillsPCMenu .asm_215bb ld a, [W_NUMINBOX] ; wda80 - cp $14 + cp MONS_PER_BOX jr nz, .asm_215cb ld hl, BoxFullText ; $5802 call PrintText @@ -251,15 +239,15 @@ BillsPCDeposit: ld hl, wWhichTrade ; wWhichTrade ld a, [wd5a0] and $7f - cp $9 + cp 9 jr c, .asm_2160a - sub $9 - ld [hl], $f7 + sub 9 + ld [hl], "1" inc hl - add $f6 + add "0" jr .asm_2160c .asm_2160a - add $f7 + add "1" .asm_2160c ld [hli], a ld [hl], $50 @@ -276,7 +264,7 @@ Func_21618: ; 21618 (8:5618) jp Func_214e8 .asm_21627 ld a, [wPartyCount] ; wPartyCount - cp $6 + cp PARTY_LENGTH jr nz, .asm_21637 ld hl, CantTakeMonText ; $5811 call PrintText @@ -353,7 +341,12 @@ Func_216be: ; 216be (8:56be) ret BillsPCMenuText: ; 216e1 (8:56e1) - db "WITHDRAW ",$4a,$4e,"DEPOSIT ",$4a,$4e,"RELEASE ",$4a,$4e,"CHANGE BOX",$4e,"SEE YA!@" + db "WITHDRAW ", $4a + next "DEPOSIT ", $4a + next "RELEASE ", $4a + next "CHANGE BOX" + next "SEE YA!" + db "@" BoxNoPCText: ; 21713 (8:5713) db "BOX No.@" @@ -389,7 +382,7 @@ HMMoveArray: ; 21745 (8:5745) db SURF db STRENGTH db FLASH - db $ff + db -1 Func_2174b: ; 2174b (8:574b) hlCoord 9, 10 @@ -458,14 +451,11 @@ Func_2174b: ; 2174b (8:574b) call LoadGBPal jr .asm_2178f -DepositPCText: ; 217cb (8:57cb) - db "DEPOSIT@" - -WithdrawPCText: ; 217d3 (8:57d3) - db "WITHDRAW@" - -StatsCancelPCText: ; 217dc (8:57dc) - db "STATS",$4e,"CANCEL@" +DepositPCText: db "DEPOSIT@" +WithdrawPCText: db "WITHDRAW@" +StatsCancelPCText: + db "STATS" + next "CANCEL@" SwitchOnText: ; 0x217e9 TX_FAR _SwitchOnText @@ -523,7 +513,7 @@ PrintJustAMomentText1:: ; 5824 (8:5825) cp $c ret nz ld a, [W_CURMAP] - cp $ef + cp BATTLE_CENTER ld a, $2 jr z, .asm_2183a inc a @@ -541,7 +531,7 @@ PrintJustAMomentText2:: ; 5845 (8:5845) cp $8 ret nz ld a, [W_CURMAP] - cp $ef + cp BATTLE_CENTER ld a, $2 jr z, .asm_2185a inc a diff --git a/engine/save.asm b/engine/save.asm index fcfbd13364..b473f1cdc7 100755 --- a/engine/save.asm +++ b/engine/save.asm @@ -445,15 +445,15 @@ Func_7393f: ; 7393f (1c:793f) res 2, [hl] ld a, [wd5a0] and $7f - cp $9 + cp 9 jr c, .asm_739a6 - sub $9 + sub 9 hlCoord 8, 2 - ld [hl], $f7 - add $f6 + ld [hl], "1" + add "0" jr .asm_739a8 .asm_739a6 - add $f7 + add "1" .asm_739a8 Coorda 9, 2 hlCoord 1, 2 diff --git a/main.asm b/main.asm index 32a3db2c08..96a1df8eff 100755 --- a/main.asm +++ b/main.asm @@ -3419,7 +3419,7 @@ _AddPartyMon: ; f2e5 (3:72e5) .asm_f2f2 ld a, [de] inc a - cp $7 + cp PARTY_LENGTH + 1 ret nc ld [de], a ld a, [de] @@ -3681,7 +3681,7 @@ AddPartyMon_WriteMovePP: ; f476 (3:7476) _AddEnemyMonToPlayerParty: ; f49d (3:749d) ld hl, wPartyCount ld a, [hl] - cp $6 + cp PARTY_LENGTH scf ret z ; party full, return failure inc a @@ -3750,13 +3750,13 @@ Func_f51e: ; f51e (3:751e) jr z, .asm_f575 ld hl, W_NUMINBOX ; wda80 ld a, [hl] - cp $14 + cp MONS_PER_BOX jr nz, .partyOrBoxNotFull jr .boxFull .checkPartyMonSlots ld hl, wPartyCount ; wPartyCount ld a, [hl] - cp $6 + cp PARTY_LENGTH jr nz, .partyOrBoxNotFull .boxFull scf @@ -3899,7 +3899,7 @@ Func_f51e: ; f51e (3:751e) ld a, d ld [W_CURENEMYLVL], a ; W_CURENEMYLVL pop hl - ld bc, $21 + ld bc, wBoxMon2 - wBoxMon1 add hl, bc ld [hli], a ld d, h diff --git a/scripts/daycarem.asm b/scripts/daycarem.asm index e463d38003..373a934906 100755 --- a/scripts/daycarem.asm +++ b/scripts/daycarem.asm @@ -67,9 +67,9 @@ DayCareMScript_562e1: ; 562e1 (15:62e1) call LoadMonData callab Func_58f43 ld a, d - cp $64 + cp MAX_LEVEL jr c, .asm_56315 - ld d, $64 + ld d, MAX_LEVEL callab CalcExperience ld hl, wDayCareMonExp ld a, [H_NUMTOPRINT] @@ -78,7 +78,7 @@ DayCareMScript_562e1: ; 562e1 (15:62e1) ld [hli], a ld a, [$ff98] ld [hl], a - ld d, $64 + ld d, MAX_LEVEL .asm_56315 xor a @@ -100,7 +100,7 @@ DayCareMScript_562e1: ; 562e1 (15:62e1) .asm_56333 call PrintText ld a, [wPartyCount] - cp $6 + cp PARTY_LENGTH ld hl, DayCareMText_56440 jp z, .asm_56403 ld de, wTrainerFacingDirection diff --git a/scripts/route5gate.asm b/scripts/route5gate.asm index d7abeff5ab..0e8d0d1c92 100755 --- a/scripts/route5gate.asm +++ b/scripts/route5gate.asm @@ -27,11 +27,11 @@ Route5GateScript0: ; 1df50 (7:5f50) xor a ld [hJoyHeld], a callba RemoveGuardDrink - ld a, [$ff00+$db] + ld a, [$ffdb] and a jr nz, .asm_1df82 ; 0x1df70 $10 ld a, $2 - ld [$ff00+$8c], a + ld [$ff8c], a call DisplayTextID call Route5GateScript_1df43 ld a, $1 @@ -39,7 +39,7 @@ Route5GateScript0: ; 1df50 (7:5f50) ret .asm_1df82 ld a, $3 - ld [$ff00+$8c], a + ld [$ff8c], a call DisplayTextID ld hl, wd728 set 6, [hl] @@ -74,7 +74,7 @@ Route5GateText1: ; 1dfaa (7:5faa) bit 6, a jr nz, .asm_88856 ; 0x1dfb0 $2c callba RemoveGuardDrink - ld a, [$ff00+$db] + ld a, [$ffdb] and a jr nz, .asm_768a2 ; 0x1dfbd $11 ld hl, Route5GateText2 From 8f49e37b82a90bbef8c7133c4adea8f82abf00e7 Mon Sep 17 00:00:00 2001 From: yenatch Date: Sat, 30 Aug 2014 19:48:49 -0700 Subject: [PATCH 013/100] Use hram constants for remaining joypad variables. --- engine/cable_club.asm | 4 +-- engine/evolution.asm | 2 +- engine/menu/main_menu.asm | 4 +-- engine/menu/pokedex.asm | 6 ++-- engine/slot_machine.asm | 2 +- engine/town_map.asm | 8 ++--- home.asm | 74 +++++++++++++++++++-------------------- hram.asm | 41 ++++++++++++---------- 8 files changed, 72 insertions(+), 69 deletions(-) diff --git a/engine/cable_club.asm b/engine/cable_club.asm index fc049ceb7e..06f69a73f4 100755 --- a/engine/cable_club.asm +++ b/engine/cable_club.asm @@ -537,7 +537,7 @@ TradeCenter_SelectMon: ld [wTileMap + $141], a .asm_574a call JoypadLowSensitivity - ld a, [$ffb5] + ld a, [hJoy5] and a jr z, .asm_574a ; 0x5750 $f8 bit 0, a @@ -896,7 +896,7 @@ Func_5a5f: ; 5a5f (1:5a5f) ld [W_GRASSRATE], a ; W_GRASSRATE inc a ld [W_ISLINKBATTLE], a ; W_ISLINKBATTLE - ld [$ffb5], a + ld [hJoy5], a ld a, $a ld [wMusicHeaderPointer], a ld a, BANK(Music_Celadon) diff --git a/engine/evolution.asm b/engine/evolution.asm index 07ccdbda97..a52e0071f0 100755 --- a/engine/evolution.asm +++ b/engine/evolution.asm @@ -140,7 +140,7 @@ asm_7befa: ; 7befa (1e:7efa) call DelayFrame push bc call JoypadLowSensitivity - ld a, [$ffb5] + ld a, [hJoy5] pop bc and $2 jr nz, .asm_7bf0d diff --git a/engine/menu/main_menu.asm b/engine/menu/main_menu.asm index 4044da43b6..5f8f0c1d4e 100755 --- a/engine/menu/main_menu.asm +++ b/engine/menu/main_menu.asm @@ -307,7 +307,7 @@ Func_5d5f: ; 5d5f (1:5d5f) xor a ld [hJoyPressed], a ld [hJoyHeld], a - ld [$ffb5], a + ld [hJoy5], a ld [wd72d], a ld hl, wd732 set 0, [hl] @@ -461,7 +461,7 @@ DisplayOptionMenu: ; 5e8a (1:5e8a) call SetOptionsFromCursorPositions .getJoypadStateLoop call JoypadLowSensitivity - ld a,[$ffb5] + ld a,[hJoy5] ld b,a and a,%11111011 ; any key besides select pressed? jr z,.getJoypadStateLoop diff --git a/engine/menu/pokedex.asm b/engine/menu/pokedex.asm index 63e440f840..f35b93e095 100755 --- a/engine/menu/pokedex.asm +++ b/engine/menu/pokedex.asm @@ -10,7 +10,7 @@ ShowPokedexMenu: ; 40000 (10:4000) ld [wLastMenuItem],a inc a ld [wd11e],a - ld [$ffb7],a + ld [hJoy7],a .setUpGraphics ld b,$08 call GoPAL_SET @@ -35,7 +35,7 @@ ShowPokedexMenu: ; 40000 (10:4000) ld [wcc37],a ld [wCurrentMenuItem],a ld [wLastMenuItem],a - ld [$ffb7],a + ld [hJoy7],a ld [wcd3a],a ld [wcd3b],a pop af @@ -550,7 +550,7 @@ ShowPokedexDataInternal: ; 402e2 (10:42e2) ld [$fff4],a .waitForButtonPress call JoypadLowSensitivity - ld a,[$ffb5] + ld a,[hJoy5] and a,%00000011 ; A button and B button jr z,.waitForButtonPress pop af diff --git a/engine/slot_machine.asm b/engine/slot_machine.asm index e43cc9ab24..9ded4f3609 100755 --- a/engine/slot_machine.asm +++ b/engine/slot_machine.asm @@ -797,7 +797,7 @@ SlotMachine_3784e: ; 3784e (d:784e) SlotMachine_37882: ; 37882 (d:7882) call DelayFrame call JoypadLowSensitivity - ld a, [$ffb5] + ld a, [hJoy5] and $1 ret z ld hl, wTrainerSpriteOffset diff --git a/engine/town_map.asm b/engine/town_map.asm index 2cd3728439..5e8b77de76 100755 --- a/engine/town_map.asm +++ b/engine/town_map.asm @@ -6,7 +6,7 @@ DisplayTownMap: ; 70e3e (1c:4e3e) ld [hl], $ff push hl ld a, $1 - ld [$ffb7], a + ld [hJoy7], a ld a, [W_CURMAP] ; W_CURMAP push af ld b, $0 @@ -66,7 +66,7 @@ Func_70e92: ; 70e92 (1c:4e92) .asm_70ec8 call Func_716c6 call JoypadLowSensitivity - ld a, [$ffb5] + ld a, [hJoy5] ld b, a and $c3 jr z, .asm_70ec8 @@ -78,7 +78,7 @@ Func_70e92: ; 70e92 (1c:4e92) jr nz, .asm_70f01 xor a ld [wd09b], a - ld [$ffb7], a + ld [hJoy7], a ld [W_SUBANIMTRANSFORM], a ; W_SUBANIMTRANSFORM call Func_711ab pop hl @@ -188,7 +188,7 @@ LoadTownMap_Fly: ; 70f90 (1c:4f90) push hl call DelayFrame call JoypadLowSensitivity - ld a, [$ffb5] + ld a, [hJoy5] ld b, a pop hl and $c3 diff --git a/home.asm b/home.asm index ad010cde5f..f83662caa2 100644 --- a/home.asm +++ b/home.asm @@ -102,34 +102,34 @@ Start:: INCLUDE "home/joypad.asm" - INCLUDE "data/map_header_pointers.asm" - INCLUDE "home/overworld.asm" -; this is used to check if the player wants to interrupt the opening sequence at several points -; XXX is this used anywhere else? -; INPUT: -; c = number of frames to wait -; sets carry if Up+Select+B, Start, or A is pressed within c frames -; unsets carry otherwise + CheckForUserInterruption:: ; 12f8 (0:12f8) +; Return carry if Up+Select+B, Start or A are pressed in c frames. +; Used only in the intro and title screen. call DelayFrame + push bc call JoypadLowSensitivity pop bc - ld a,[hJoyHeld] ; currently pressed buttons - cp a,%01000110 ; Up, Select button, B button - jr z,.setCarry ; if all three keys are pressed - ld a,[$ffb5] ; either newly pressed buttons or currently pressed buttons at low sampling rate - and a,%00001001 ; Start button, A button - jr nz,.setCarry ; if either key is pressed + + ld a, [hJoyHeld] + cp D_UP + SELECT + B_BUTTON + jr z, .input + + ld a, [hJoy5] + and START | A_BUTTON + jr nz, .input + dec c - jr nz,CheckForUserInterruption -.unsetCarry + jr nz, CheckForUserInterruption + and a ret -.setCarry + +.input scf ret @@ -1347,7 +1347,7 @@ DisplayListMenuID:: ; 2be6 (0:2be6) xor a ld [H_AUTOBGTRANSFERENABLED],a ; disable auto-transfer ld a,1 - ld [$ffb7],a ; joypad state update flag + ld [hJoy7],a ; joypad state update flag ld a,[W_BATTLETYPE] and a ; is it the Old Man battle? jr nz,.specialBattleType @@ -1501,7 +1501,7 @@ DisplayListMenuIDLoop:: ; 2c53 (0:2c53) ld a,[wCurrentMenuItem] ld [wd12d],a xor a - ld [$ffb7],a ; joypad state update flag + ld [hJoy7],a ; joypad state update flag ld hl,wd730 res 6,[hl] ; turn on letter printing delay jp BankswitchBack @@ -1662,7 +1662,7 @@ ExitListMenu:: ; 2e3b (0:2e3b) ld [wd12e],a ld [wcc37],a xor a - ld [$ffb7],a + ld [hJoy7],a ld hl,wd730 res 6,[hl] call BankswitchBack @@ -3347,29 +3347,29 @@ CopyString:: ; 3829 (0:3829) ret ; this function is used when lower button sensitivity is wanted (e.g. menus) -; OUTPUT: [$ffb5] = pressed buttons in usual format -; there are two flags that control its functionality, [$ffb6] and [$ffb7] +; OUTPUT: [hJoy5] = pressed buttons in usual format +; there are two flags that control its functionality, [hJoy6] and [hJoy7] ; there are esentially three modes of operation ; 1. Get newly pressed buttons only -; ([$ffb7] == 0, [$ffb6] == any) -; Just copies [hJoyPressed] to [$ffb5]. +; ([hJoy7] == 0, [hJoy6] == any) +; Just copies [hJoyPressed] to [hJoy5]. ; 2. Get currently pressed buttons at low sample rate with delay -; ([$ffb7] == 1, [$ffb6] != 0) +; ([hJoy7] == 1, [hJoy6] != 0) ; If the user holds down buttons for more than half a second, ; report buttons as being pressed up to 12 times per second thereafter. ; If the user holds down buttons for less than half a second, ; report only one button press. ; 3. Same as 2, but report no buttons as pressed if A or B is held down. -; ([$ffb7] == 1, [$ffb6] == 0) +; ([hJoy7] == 1, [hJoy6] == 0) JoypadLowSensitivity:: ; 3831 (0:3831) call Joypad - ld a,[$ffb7] ; flag + ld a,[hJoy7] ; flag and a ; get all currently pressed buttons or only newly pressed buttons? ld a,[hJoyPressed] ; newly pressed buttons jr z,.storeButtonState ld a,[hJoyHeld] ; all currently pressed buttons .storeButtonState - ld [$ffb5],a + ld [hJoy5],a ld a,[hJoyPressed] ; newly pressed buttons and a ; have any buttons been newly pressed since last check? jr z,.noNewlyPressedButtons @@ -3383,18 +3383,18 @@ JoypadLowSensitivity:: ; 3831 (0:3831) jr z,.delayOver .delayNotOver xor a - ld [$ffb5],a ; report no buttons as pressed + ld [hJoy5],a ; report no buttons as pressed ret .delayOver -; if [$ffb6] = 0 and A or B is pressed, report no buttons as pressed +; if [hJoy6] = 0 and A or B is pressed, report no buttons as pressed ld a,[hJoyHeld] and a,%00000011 ; A and B buttons jr z,.setShortDelay - ld a,[$ffb6] ; flag + ld a,[hJoy6] ; flag and a jr nz,.setShortDelay xor a - ld [$ffb5],a + ld [hJoy5],a .setShortDelay ld a,5 ; 1/12 of a second delay ld [H_FRAMECOUNTER],a @@ -3421,7 +3421,7 @@ WaitForTextScrollButtonPress:: ; 3865 (0:3865) pop hl call JoypadLowSensitivity predef Func_5a5f - ld a, [$ffb5] + ld a, [hJoy5] and A_BUTTON | B_BUTTON jr z, .asm_3872 pop af @@ -3888,7 +3888,7 @@ HandleMenuInputPokemonSelection:: ; 3ac2 (0:3ac2) .getJoypadState pop hl call JoypadLowSensitivity - ld a,[$ffb5] + ld a,[hJoy5] and a ; was a key pressed? jr nz,.keyPressed push hl @@ -3911,7 +3911,7 @@ HandleMenuInputPokemonSelection:: ; 3ac2 (0:3ac2) .keyPressed xor a ld [wcc4b],a - ld a,[$ffb5] + ld a,[hJoy5] ld b,a bit 6,a ; pressed Up key? jr z,.checkIfDownPressed @@ -3953,7 +3953,7 @@ HandleMenuInputPokemonSelection:: ; 3ac2 (0:3ac2) and b ; does the menu care about any of the pressed keys? jp z,.loop1 .checkIfAButtonOrBButtonPressed - ld a,[$ffb5] + ld a,[hJoy5] and a,%00000011 ; pressed A button or B button? jr z,.skipPlayingSound .AButtonOrBButtonPressed @@ -3971,7 +3971,7 @@ HandleMenuInputPokemonSelection:: ; 3ac2 (0:3ac2) ld [H_DOWNARROWBLINKCNT1],a ; restore previous values xor a ld [wMenuWrappingEnabled],a ; disable menu wrapping - ld a,[$ffb5] + ld a,[hJoy5] ret .noWrappingAround ld a,[wcc37] diff --git a/hram.asm b/hram.asm index b88c248b90..4599e9506b 100644 --- a/hram.asm +++ b/hram.asm @@ -1,8 +1,8 @@ -H_SPRITEWIDTH EQU $FF8B ; in bytes +H_SPRITEWIDTH EQU $FF8B ; in tiles H_SPRITEINTERLACECOUNTER EQU $FF8B -H_SPRITEHEIGHT EQU $FF8C ; in bytes -H_SPRITEOFFSET EQU $FF8D +H_SPRITEHEIGHT EQU $FF8C ; in tiles +H_SPRITEOFFSET EQU $FF8D hSoftReset EQU $FF8A ; Initialized to 16. @@ -14,28 +14,31 @@ hSoftReset EQU $FF8A H_DOWNARROWBLINKCNT1 EQU $FF8B H_DOWNARROWBLINKCNT2 EQU $FF8C -; Note: the following multiplication and division addresses are used for multiple purposes -; and so they overlap with each other +; Multiplcation and division variables are meant +; to overlap for back-to-back usage. Big endian. -H_MULTIPLICAND EQU $FF96 ; 3 bytes, big endian order +H_MULTIPLICAND EQU $FF96 ; 3 bytes H_MULTIPLIER EQU $FF99 ; 1 byte -H_PRODUCT EQU $FF95 ; 4 bytes, big endian order +H_PRODUCT EQU $FF95 ; 4 bytes -H_DIVIDEND EQU $FF95 ; 4 bytes, big endian order +H_DIVIDEND EQU $FF95 ; 4 bytes H_DIVISOR EQU $FF99 ; 1 byte -H_QUOTIENT EQU $FF95 ; 4 bytes, big endian order +H_QUOTIENT EQU $FF95 ; 4 bytes H_REMAINDER EQU $FF99 ; 1 byte -; used to convert numbers to decimal -H_PASTLEADINGZEROES EQU $FF95 ; flag to indicate that a nonzero digit has been printed -H_NUMTOPRINT EQU $FF96 ; 3 bytes, big endian order -H_POWEROFTEN EQU $FF99 ; 3 bytes, big endian order -H_SAVEDNUMTOPRINT EQU $FF9C ; 3 bytes, big endian order (to back out of a subtraction) - -hJoyHeldLast EQU $FFB1 -hJoyReleased EQU $FFB2 -hJoyPressed EQU $FFB3 -hJoyHeld EQU $FFB4 +; PrintNumber (big endian). +H_PASTLEADINGZEROES EQU $FF95 ; last char printed +H_NUMTOPRINT EQU $FF96 ; 3 bytes +H_POWEROFTEN EQU $FF99 ; 3 bytes +H_SAVEDNUMTOPRINT EQU $FF9C ; 3 bytes + +hJoyHeldLast EQU $FFB1 +hJoyReleased EQU $FFB2 +hJoyPressed EQU $FFB3 +hJoyHeld EQU $FFB4 +hJoy5 EQU $FFB5 +hJoy6 EQU $FFB6 +hJoy7 EQU $FFB7 H_LOADEDROMBANK EQU $FFB8 From 342791a001cecbfd8192ced7dd2478485d98fa45 Mon Sep 17 00:00:00 2001 From: yenatch Date: Mon, 1 Sep 2014 17:59:10 -0700 Subject: [PATCH 014/100] Use a macro for move attributes. The formatting was pretty bad, so that's fixed too. --- data/moves.asm | 345 +++++++++++++++++++++++++------------------------ macros.asm | 3 + 2 files changed, 180 insertions(+), 168 deletions(-) diff --git a/data/moves.asm b/data/moves.asm index 08da533d9b..22165b7ded 100755 --- a/data/moves.asm +++ b/data/moves.asm @@ -1,168 +1,177 @@ -Moves: ; 38000 (e:4000) -; characteristics of each move -; animation, effect, power, type, accuracy, PP - db POUND ,NO_ADDITIONAL_EFFECT ,$28,NORMAL, $FF,35 - db KARATE_CHOP ,NO_ADDITIONAL_EFFECT ,$32,NORMAL, $FF,25 - db DOUBLESLAP ,TWO_TO_FIVE_ATTACKS_EFFECT,$0F,NORMAL, $D8,10 - db COMET_PUNCH ,TWO_TO_FIVE_ATTACKS_EFFECT,$12,NORMAL, $D8,15 - db MEGA_PUNCH ,NO_ADDITIONAL_EFFECT ,$50,NORMAL, $D8,20 - db PAY_DAY ,PAY_DAY_EFFECT ,$28,NORMAL, $FF,20 - db FIRE_PUNCH ,BURN_SIDE_EFFECT1 ,$4B,FIRE, $FF,15 - db ICE_PUNCH ,FREEZE_SIDE_EFFECT ,$4B,ICE, $FF,15 - db THUNDERPUNCH,PARALYZE_SIDE_EFFECT1 ,$4B,ELECTRIC,$FF,15 - db SCRATCH ,NO_ADDITIONAL_EFFECT ,$28,NORMAL, $FF,35 - db VICEGRIP ,NO_ADDITIONAL_EFFECT ,$37,NORMAL, $FF,30 - db GUILLOTINE ,OHKO_EFFECT ,$01,NORMAL, $4C,5 - db RAZOR_WIND ,CHARGE_EFFECT ,$50,NORMAL, $BF,10 - db SWORDS_DANCE,ATTACK_UP2_EFFECT ,$00,NORMAL, $FF,30 - db CUT ,NO_ADDITIONAL_EFFECT ,$32,NORMAL, $F2,30 - db GUST ,NO_ADDITIONAL_EFFECT ,$28,NORMAL, $FF,35 - db WING_ATTACK ,NO_ADDITIONAL_EFFECT ,$23,FLYING, $FF,35 - db WHIRLWIND ,SWITCH_AND_TELEPORT_EFFECT,$00,NORMAL, $D8,20 - db FLY ,FLY_EFFECT ,$46,FLYING, $F2,15 - db BIND ,TRAPPING_EFFECT ,$0F,NORMAL, $BF,20 - db SLAM ,NO_ADDITIONAL_EFFECT ,$50,NORMAL, $BF,20 - db VINE_WHIP ,NO_ADDITIONAL_EFFECT ,$23,GRASS, $FF,10 - db STOMP ,FLINCH_SIDE_EFFECT2 ,$41,NORMAL, $FF,20 - db DOUBLE_KICK ,ATTACK_TWICE_EFFECT ,$1E,FIGHTING,$FF,30 - db MEGA_KICK ,NO_ADDITIONAL_EFFECT ,$78,NORMAL, $BF,5 - db JUMP_KICK ,JUMP_KICK_EFFECT ,$46,FIGHTING,$F2,25 - db ROLLING_KICK,FLINCH_SIDE_EFFECT2 ,$3C,FIGHTING,$D8,15 - db SAND_ATTACK ,ACCURACY_DOWN1_EFFECT ,$00,NORMAL, $FF,15 - db HEADBUTT ,FLINCH_SIDE_EFFECT2 ,$46,NORMAL, $FF,15 - db HORN_ATTACK ,NO_ADDITIONAL_EFFECT ,$41,NORMAL, $FF,25 - db FURY_ATTACK ,TWO_TO_FIVE_ATTACKS_EFFECT,$0F,NORMAL, $D8,20 - db HORN_DRILL ,OHKO_EFFECT ,$01,NORMAL, $4C,5 - db TACKLE ,NO_ADDITIONAL_EFFECT ,$23,NORMAL, $F2,35 - db BODY_SLAM ,PARALYZE_SIDE_EFFECT2 ,$55,NORMAL, $FF,15 - db WRAP ,TRAPPING_EFFECT ,$0F,NORMAL, $D8,20 - db TAKE_DOWN ,RECOIL_EFFECT ,$5A,NORMAL, $D8,20 - db THRASH ,THRASH_PETAL_DANCE_EFFECT ,$5A,NORMAL, $FF,20 - db DOUBLE_EDGE ,RECOIL_EFFECT ,$64,NORMAL, $FF,15 - db TAIL_WHIP ,DEFENSE_DOWN1_EFFECT ,$00,NORMAL, $FF,30 - db POISON_STING,POISON_SIDE_EFFECT1 ,$0F,POISON, $FF,35 - db TWINEEDLE ,TWINEEDLE_EFFECT ,$19,BUG, $FF,20 - db PIN_MISSILE ,TWO_TO_FIVE_ATTACKS_EFFECT,$0E,BUG, $D8,20 - db LEER ,DEFENSE_DOWN1_EFFECT ,$00,NORMAL, $FF,30 - db BITE ,FLINCH_SIDE_EFFECT1 ,$3C,NORMAL, $FF,25 - db GROWL ,ATTACK_DOWN1_EFFECT ,$00,NORMAL, $FF,40 - db ROAR ,SWITCH_AND_TELEPORT_EFFECT,$00,NORMAL, $FF,20 - db SING ,SLEEP_EFFECT ,$00,NORMAL, $8C,15 - db SUPERSONIC ,CONFUSION_EFFECT ,$00,NORMAL, $8C,20 - db SONICBOOM ,SPECIAL_DAMAGE_EFFECT ,$01,NORMAL, $E5,20 - db DISABLE ,DISABLE_EFFECT ,$00,NORMAL, $8C,20 - db ACID ,DEFENSE_DOWN_SIDE_EFFECT ,$28,POISON, $FF,30 - db EMBER ,BURN_SIDE_EFFECT1 ,$28,FIRE, $FF,25 - db FLAMETHROWER,BURN_SIDE_EFFECT1 ,$5F,FIRE, $FF,15 - db MIST ,MIST_EFFECT ,$00,ICE, $FF,30 - db WATER_GUN ,NO_ADDITIONAL_EFFECT ,$28,WATER, $FF,25 - db HYDRO_PUMP ,NO_ADDITIONAL_EFFECT ,$78,WATER, $CC,5 - db SURF ,NO_ADDITIONAL_EFFECT ,$5F,WATER, $FF,15 - db ICE_BEAM ,FREEZE_SIDE_EFFECT ,$5F,ICE, $FF,10 - db BLIZZARD ,FREEZE_SIDE_EFFECT ,$78,ICE, $E5,5 - db PSYBEAM ,CONFUSION_SIDE_EFFECT ,$41,PSYCHIC, $FF,20 - db BUBBLEBEAM ,SPEED_DOWN_SIDE_EFFECT ,$41,WATER, $FF,20 - db AURORA_BEAM ,ATTACK_DOWN_SIDE_EFFECT ,$41,ICE, $FF,20 - db HYPER_BEAM ,HYPER_BEAM_EFFECT ,$96,NORMAL, $E5,5 - db PECK ,NO_ADDITIONAL_EFFECT ,$23,FLYING, $FF,35 - db DRILL_PECK ,NO_ADDITIONAL_EFFECT ,$50,FLYING, $FF,20 - db SUBMISSION ,RECOIL_EFFECT ,$50,FIGHTING,$CC,25 - db LOW_KICK ,FLINCH_SIDE_EFFECT2 ,$32,FIGHTING,$E5,20 - db COUNTER ,NO_ADDITIONAL_EFFECT ,$01,FIGHTING,$FF,20 - db SEISMIC_TOSS,SPECIAL_DAMAGE_EFFECT ,$01,FIGHTING,$FF,20 - db STRENGTH ,NO_ADDITIONAL_EFFECT ,$50,NORMAL, $FF,15 - db ABSORB ,DRAIN_HP_EFFECT ,$14,GRASS, $FF,20 - db MEGA_DRAIN ,DRAIN_HP_EFFECT ,$28,GRASS, $FF,10 - db LEECH_SEED ,LEECH_SEED_EFFECT ,$00,GRASS, $E5,10 - db GROWTH ,SPECIAL_UP1_EFFECT ,$00,NORMAL, $FF,40 - db RAZOR_LEAF ,NO_ADDITIONAL_EFFECT ,$37,GRASS, $F2,25 - db SOLARBEAM ,CHARGE_EFFECT ,$78,GRASS, $FF,10 - db POISONPOWDER,POISON_EFFECT ,$00,POISON, $BF,35 - db STUN_SPORE ,PARALYZE_EFFECT ,$00,GRASS, $BF,30 - db SLEEP_POWDER,SLEEP_EFFECT ,$00,GRASS, $BF,15 - db PETAL_DANCE ,THRASH_PETAL_DANCE_EFFECT ,$46,GRASS, $FF,20 - db STRING_SHOT ,SPEED_DOWN1_EFFECT ,$00,BUG, $F2,40 - db DRAGON_RAGE ,SPECIAL_DAMAGE_EFFECT ,$01,DRAGON, $FF,10 - db FIRE_SPIN ,TRAPPING_EFFECT ,$0F,FIRE, $B2,15 - db THUNDERSHOCK,PARALYZE_SIDE_EFFECT1 ,$28,ELECTRIC,$FF,30 - db THUNDERBOLT ,PARALYZE_SIDE_EFFECT1 ,$5F,ELECTRIC,$FF,15 - db THUNDER_WAVE,PARALYZE_EFFECT ,$00,ELECTRIC,$FF,20 - db THUNDER ,PARALYZE_SIDE_EFFECT1 ,$78,ELECTRIC,$B2,10 - db ROCK_THROW ,NO_ADDITIONAL_EFFECT ,$32,ROCK, $A5,15 - db EARTHQUAKE ,NO_ADDITIONAL_EFFECT ,$64,GROUND, $FF,10 - db FISSURE ,OHKO_EFFECT ,$01,GROUND, $4C,5 - db DIG ,CHARGE_EFFECT ,$64,GROUND, $FF,10 - db TOXIC ,POISON_EFFECT ,$00,POISON, $D8,10 - db CONFUSION ,CONFUSION_SIDE_EFFECT ,$32,PSYCHIC, $FF,25 - db PSYCHIC_M ,SPECIAL_DOWN_SIDE_EFFECT ,$5A,PSYCHIC, $FF,10 - db HYPNOSIS ,SLEEP_EFFECT ,$00,PSYCHIC, $99,20 - db MEDITATE ,ATTACK_UP1_EFFECT ,$00,PSYCHIC, $FF,40 - db AGILITY ,SPEED_UP2_EFFECT ,$00,PSYCHIC, $FF,30 - db QUICK_ATTACK,NO_ADDITIONAL_EFFECT ,$28,NORMAL, $FF,30 - db RAGE ,RAGE_EFFECT ,$14,NORMAL, $FF,20 - db TELEPORT ,SWITCH_AND_TELEPORT_EFFECT,$00,PSYCHIC, $FF,20 - db NIGHT_SHADE ,SPECIAL_DAMAGE_EFFECT ,$00,GHOST, $FF,15 - db MIMIC ,MIMIC_EFFECT ,$00,NORMAL, $FF,10 - db SCREECH ,DEFENSE_DOWN2_EFFECT ,$00,NORMAL, $D8,40 - db DOUBLE_TEAM ,EVASION_UP1_EFFECT ,$00,NORMAL, $FF,15 - db RECOVER ,HEAL_EFFECT ,$00,NORMAL, $FF,20 - db HARDEN ,DEFENSE_UP1_EFFECT ,$00,NORMAL, $FF,30 - db MINIMIZE ,EVASION_UP1_EFFECT ,$00,NORMAL, $FF,20 - db SMOKESCREEN ,ACCURACY_DOWN1_EFFECT ,$00,NORMAL, $FF,20 - db CONFUSE_RAY ,CONFUSION_EFFECT ,$00,GHOST, $FF,10 - db WITHDRAW ,DEFENSE_UP1_EFFECT ,$00,WATER, $FF,40 - db DEFENSE_CURL,DEFENSE_UP1_EFFECT ,$00,NORMAL, $FF,40 - db BARRIER ,DEFENSE_UP2_EFFECT ,$00,PSYCHIC, $FF,30 - db LIGHT_SCREEN,LIGHT_SCREEN_EFFECT ,$00,PSYCHIC, $FF,30 - db HAZE ,HAZE_EFFECT ,$00,ICE, $FF,30 - db REFLECT ,REFLECT_EFFECT ,$00,PSYCHIC, $FF,20 - db FOCUS_ENERGY,FOCUS_ENERGY_EFFECT ,$00,NORMAL, $FF,30 - db BIDE ,BIDE_EFFECT ,$00,NORMAL, $FF,10 - db METRONOME ,METRONOME_EFFECT ,$00,NORMAL, $FF,10 - db MIRROR_MOVE ,MIRROR_MOVE_EFFECT ,$00,FLYING, $FF,20 - db SELFDESTRUCT,EXPLODE_EFFECT ,$82,NORMAL, $FF,5 - db EGG_BOMB ,NO_ADDITIONAL_EFFECT ,$64,NORMAL, $BF,10 - db LICK ,PARALYZE_SIDE_EFFECT2 ,$14,GHOST, $FF,30 - db SMOG ,POISON_SIDE_EFFECT2 ,$14,POISON, $B2,20 - db SLUDGE ,POISON_SIDE_EFFECT2 ,$41,POISON, $FF,20 - db BONE_CLUB ,FLINCH_SIDE_EFFECT1 ,$41,GROUND, $D8,20 - db FIRE_BLAST ,BURN_SIDE_EFFECT2 ,$78,FIRE, $D8,5 - db WATERFALL ,NO_ADDITIONAL_EFFECT ,$50,WATER, $FF,15 - db CLAMP ,TRAPPING_EFFECT ,$23,WATER, $BF,10 - db SWIFT ,SWIFT_EFFECT ,$3C,NORMAL, $FF,20 - db SKULL_BASH ,CHARGE_EFFECT ,$64,NORMAL, $FF,15 - db SPIKE_CANNON,TWO_TO_FIVE_ATTACKS_EFFECT,$14,NORMAL, $FF,15 - db CONSTRICT ,SPEED_DOWN_SIDE_EFFECT ,$0A,NORMAL, $FF,35 - db AMNESIA ,SPECIAL_UP2_EFFECT ,$00,PSYCHIC, $FF,20 - db KINESIS ,ACCURACY_DOWN1_EFFECT ,$00,PSYCHIC, $CC,15 - db SOFTBOILED ,HEAL_EFFECT ,$00,NORMAL, $FF,10 - db HI_JUMP_KICK,JUMP_KICK_EFFECT ,$55,FIGHTING,$E5,20 - db GLARE ,PARALYZE_EFFECT ,$00,NORMAL, $BF,30 - db DREAM_EATER ,DREAM_EATER_EFFECT ,$64,PSYCHIC, $FF,15 - db POISON_GAS ,POISON_EFFECT ,$00,POISON, $8C,40 - db BARRAGE ,TWO_TO_FIVE_ATTACKS_EFFECT,$0F,NORMAL, $D8,20 - db LEECH_LIFE ,DRAIN_HP_EFFECT ,$14,BUG, $FF,15 - db LOVELY_KISS ,SLEEP_EFFECT ,$00,NORMAL, $BF,10 - db SKY_ATTACK ,CHARGE_EFFECT ,$8C,FLYING, $E5,5 - db TRANSFORM ,TRANSFORM_EFFECT ,$00,NORMAL, $FF,10 - db BUBBLE ,SPEED_DOWN_SIDE_EFFECT ,$14,WATER, $FF,30 - db DIZZY_PUNCH ,NO_ADDITIONAL_EFFECT ,$46,NORMAL, $FF,10 - db SPORE ,SLEEP_EFFECT ,$00,GRASS, $FF,15 - db FLASH ,ACCURACY_DOWN1_EFFECT ,$00,NORMAL, $B2,20 - db PSYWAVE ,SPECIAL_DAMAGE_EFFECT ,$01,PSYCHIC, $CC,15 - db SPLASH ,SPLASH_EFFECT ,$00,NORMAL, $FF,40 - db ACID_ARMOR ,DEFENSE_UP2_EFFECT ,$00,POISON, $FF,40 - db CRABHAMMER ,NO_ADDITIONAL_EFFECT ,$5A,WATER, $D8,10 - db EXPLOSION ,EXPLODE_EFFECT ,$AA,NORMAL, $FF,5 - db FURY_SWIPES ,TWO_TO_FIVE_ATTACKS_EFFECT,$12,NORMAL, $CC,15 - db BONEMERANG ,ATTACK_TWICE_EFFECT ,$32,GROUND, $E5,10 - db REST ,HEAL_EFFECT ,$00,PSYCHIC, $FF,10 - db ROCK_SLIDE ,NO_ADDITIONAL_EFFECT ,$4B,ROCK, $E5,10 - db HYPER_FANG ,FLINCH_SIDE_EFFECT1 ,$50,NORMAL, $E5,15 - db SHARPEN ,ATTACK_UP1_EFFECT ,$00,NORMAL, $FF,30 - db CONVERSION ,CONVERSION_EFFECT ,$00,NORMAL, $FF,30 - db TRI_ATTACK ,NO_ADDITIONAL_EFFECT ,$50,NORMAL, $FF,10 - db SUPER_FANG ,SUPER_FANG_EFFECT ,$01,NORMAL, $E5,10 - db SLASH ,NO_ADDITIONAL_EFFECT ,$46,NORMAL, $FF,20 - db SUBSTITUTE ,SUBSTITUTE_EFFECT ,$00,NORMAL, $FF,10 - db STRUGGLE ,RECOIL_EFFECT ,$32,NORMAL, $FF,10 +Moves: +; Characteristics of each move. + +move: macro + db \1 ; animation (interchangeable with move id) + db \2 ; effect + db \3 ; power + db \4 ; type + db \5 percent ; accuracy + db \6 ; pp +endm + + move POUND, NO_ADDITIONAL_EFFECT, 40, NORMAL, 100, 35 + move KARATE_CHOP, NO_ADDITIONAL_EFFECT, 50, NORMAL, 100, 25 + move DOUBLESLAP, TWO_TO_FIVE_ATTACKS_EFFECT, 15, NORMAL, 85, 10 + move COMET_PUNCH, TWO_TO_FIVE_ATTACKS_EFFECT, 18, NORMAL, 85, 15 + move MEGA_PUNCH, NO_ADDITIONAL_EFFECT, 80, NORMAL, 85, 20 + move PAY_DAY, PAY_DAY_EFFECT, 40, NORMAL, 100, 20 + move FIRE_PUNCH, BURN_SIDE_EFFECT1, 75, FIRE, 100, 15 + move ICE_PUNCH, FREEZE_SIDE_EFFECT, 75, ICE, 100, 15 + move THUNDERPUNCH, PARALYZE_SIDE_EFFECT1, 75, ELECTRIC, 100, 15 + move SCRATCH, NO_ADDITIONAL_EFFECT, 40, NORMAL, 100, 35 + move VICEGRIP, NO_ADDITIONAL_EFFECT, 55, NORMAL, 100, 30 + move GUILLOTINE, OHKO_EFFECT, 1, NORMAL, 30, 5 + move RAZOR_WIND, CHARGE_EFFECT, 80, NORMAL, 75, 10 + move SWORDS_DANCE, ATTACK_UP2_EFFECT, 0, NORMAL, 100, 30 + move CUT, NO_ADDITIONAL_EFFECT, 50, NORMAL, 95, 30 + move GUST, NO_ADDITIONAL_EFFECT, 40, NORMAL, 100, 35 + move WING_ATTACK, NO_ADDITIONAL_EFFECT, 35, FLYING, 100, 35 + move WHIRLWIND, SWITCH_AND_TELEPORT_EFFECT, 0, NORMAL, 85, 20 + move FLY, FLY_EFFECT, 70, FLYING, 95, 15 + move BIND, TRAPPING_EFFECT, 15, NORMAL, 75, 20 + move SLAM, NO_ADDITIONAL_EFFECT, 80, NORMAL, 75, 20 + move VINE_WHIP, NO_ADDITIONAL_EFFECT, 35, GRASS, 100, 10 + move STOMP, FLINCH_SIDE_EFFECT2, 65, NORMAL, 100, 20 + move DOUBLE_KICK, ATTACK_TWICE_EFFECT, 30, FIGHTING, 100, 30 + move MEGA_KICK, NO_ADDITIONAL_EFFECT, 120, NORMAL, 75, 5 + move JUMP_KICK, JUMP_KICK_EFFECT, 70, FIGHTING, 95, 25 + move ROLLING_KICK, FLINCH_SIDE_EFFECT2, 60, FIGHTING, 85, 15 + move SAND_ATTACK, ACCURACY_DOWN1_EFFECT, 0, NORMAL, 100, 15 + move HEADBUTT, FLINCH_SIDE_EFFECT2, 70, NORMAL, 100, 15 + move HORN_ATTACK, NO_ADDITIONAL_EFFECT, 65, NORMAL, 100, 25 + move FURY_ATTACK, TWO_TO_FIVE_ATTACKS_EFFECT, 15, NORMAL, 85, 20 + move HORN_DRILL, OHKO_EFFECT, 1, NORMAL, 30, 5 + move TACKLE, NO_ADDITIONAL_EFFECT, 35, NORMAL, 95, 35 + move BODY_SLAM, PARALYZE_SIDE_EFFECT2, 85, NORMAL, 100, 15 + move WRAP, TRAPPING_EFFECT, 15, NORMAL, 85, 20 + move TAKE_DOWN, RECOIL_EFFECT, 90, NORMAL, 85, 20 + move THRASH, THRASH_PETAL_DANCE_EFFECT, 90, NORMAL, 100, 20 + move DOUBLE_EDGE, RECOIL_EFFECT, 100, NORMAL, 100, 15 + move TAIL_WHIP, DEFENSE_DOWN1_EFFECT, 0, NORMAL, 100, 30 + move POISON_STING, POISON_SIDE_EFFECT1, 15, POISON, 100, 35 + move TWINEEDLE, TWINEEDLE_EFFECT, 25, BUG, 100, 20 + move PIN_MISSILE, TWO_TO_FIVE_ATTACKS_EFFECT, 14, BUG, 85, 20 + move LEER, DEFENSE_DOWN1_EFFECT, 0, NORMAL, 100, 30 + move BITE, FLINCH_SIDE_EFFECT1, 60, NORMAL, 100, 25 + move GROWL, ATTACK_DOWN1_EFFECT, 0, NORMAL, 100, 40 + move ROAR, SWITCH_AND_TELEPORT_EFFECT, 0, NORMAL, 100, 20 + move SING, SLEEP_EFFECT, 0, NORMAL, 55, 15 + move SUPERSONIC, CONFUSION_EFFECT, 0, NORMAL, 55, 20 + move SONICBOOM, SPECIAL_DAMAGE_EFFECT, 1, NORMAL, 90, 20 + move DISABLE, DISABLE_EFFECT, 0, NORMAL, 55, 20 + move ACID, DEFENSE_DOWN_SIDE_EFFECT, 40, POISON, 100, 30 + move EMBER, BURN_SIDE_EFFECT1, 40, FIRE, 100, 25 + move FLAMETHROWER, BURN_SIDE_EFFECT1, 95, FIRE, 100, 15 + move MIST, MIST_EFFECT, 0, ICE, 100, 30 + move WATER_GUN, NO_ADDITIONAL_EFFECT, 40, WATER, 100, 25 + move HYDRO_PUMP, NO_ADDITIONAL_EFFECT, 120, WATER, 80, 5 + move SURF, NO_ADDITIONAL_EFFECT, 95, WATER, 100, 15 + move ICE_BEAM, FREEZE_SIDE_EFFECT, 95, ICE, 100, 10 + move BLIZZARD, FREEZE_SIDE_EFFECT, 120, ICE, 90, 5 + move PSYBEAM, CONFUSION_SIDE_EFFECT, 65, PSYCHIC, 100, 20 + move BUBBLEBEAM, SPEED_DOWN_SIDE_EFFECT, 65, WATER, 100, 20 + move AURORA_BEAM, ATTACK_DOWN_SIDE_EFFECT, 65, ICE, 100, 20 + move HYPER_BEAM, HYPER_BEAM_EFFECT, 150, NORMAL, 90, 5 + move PECK, NO_ADDITIONAL_EFFECT, 35, FLYING, 100, 35 + move DRILL_PECK, NO_ADDITIONAL_EFFECT, 80, FLYING, 100, 20 + move SUBMISSION, RECOIL_EFFECT, 80, FIGHTING, 80, 25 + move LOW_KICK, FLINCH_SIDE_EFFECT2, 50, FIGHTING, 90, 20 + move COUNTER, NO_ADDITIONAL_EFFECT, 1, FIGHTING, 100, 20 + move SEISMIC_TOSS, SPECIAL_DAMAGE_EFFECT, 1, FIGHTING, 100, 20 + move STRENGTH, NO_ADDITIONAL_EFFECT, 80, NORMAL, 100, 15 + move ABSORB, DRAIN_HP_EFFECT, 20, GRASS, 100, 20 + move MEGA_DRAIN, DRAIN_HP_EFFECT, 40, GRASS, 100, 10 + move LEECH_SEED, LEECH_SEED_EFFECT, 0, GRASS, 90, 10 + move GROWTH, SPECIAL_UP1_EFFECT, 0, NORMAL, 100, 40 + move RAZOR_LEAF, NO_ADDITIONAL_EFFECT, 55, GRASS, 95, 25 + move SOLARBEAM, CHARGE_EFFECT, 120, GRASS, 100, 10 + move POISONPOWDER, POISON_EFFECT, 0, POISON, 75, 35 + move STUN_SPORE, PARALYZE_EFFECT, 0, GRASS, 75, 30 + move SLEEP_POWDER, SLEEP_EFFECT, 0, GRASS, 75, 15 + move PETAL_DANCE, THRASH_PETAL_DANCE_EFFECT, 70, GRASS, 100, 20 + move STRING_SHOT, SPEED_DOWN1_EFFECT, 0, BUG, 95, 40 + move DRAGON_RAGE, SPECIAL_DAMAGE_EFFECT, 1, DRAGON, 100, 10 + move FIRE_SPIN, TRAPPING_EFFECT, 15, FIRE, 70, 15 + move THUNDERSHOCK, PARALYZE_SIDE_EFFECT1, 40, ELECTRIC, 100, 30 + move THUNDERBOLT, PARALYZE_SIDE_EFFECT1, 95, ELECTRIC, 100, 15 + move THUNDER_WAVE, PARALYZE_EFFECT, 0, ELECTRIC, 100, 20 + move THUNDER, PARALYZE_SIDE_EFFECT1, 120, ELECTRIC, 70, 10 + move ROCK_THROW, NO_ADDITIONAL_EFFECT, 50, ROCK, 65, 15 + move EARTHQUAKE, NO_ADDITIONAL_EFFECT, 100, GROUND, 100, 10 + move FISSURE, OHKO_EFFECT, 1, GROUND, 30, 5 + move DIG, CHARGE_EFFECT, 100, GROUND, 100, 10 + move TOXIC, POISON_EFFECT, 0, POISON, 85, 10 + move CONFUSION, CONFUSION_SIDE_EFFECT, 50, PSYCHIC, 100, 25 + move PSYCHIC_M, SPECIAL_DOWN_SIDE_EFFECT, 90, PSYCHIC, 100, 10 + move HYPNOSIS, SLEEP_EFFECT, 0, PSYCHIC, 60, 20 + move MEDITATE, ATTACK_UP1_EFFECT, 0, PSYCHIC, 100, 40 + move AGILITY, SPEED_UP2_EFFECT, 0, PSYCHIC, 100, 30 + move QUICK_ATTACK, NO_ADDITIONAL_EFFECT, 40, NORMAL, 100, 30 + move RAGE, RAGE_EFFECT, 20, NORMAL, 100, 20 + move TELEPORT, SWITCH_AND_TELEPORT_EFFECT, 0, PSYCHIC, 100, 20 + move NIGHT_SHADE, SPECIAL_DAMAGE_EFFECT, 0, GHOST, 100, 15 + move MIMIC, MIMIC_EFFECT, 0, NORMAL, 100, 10 + move SCREECH, DEFENSE_DOWN2_EFFECT, 0, NORMAL, 85, 40 + move DOUBLE_TEAM, EVASION_UP1_EFFECT, 0, NORMAL, 100, 15 + move RECOVER, HEAL_EFFECT, 0, NORMAL, 100, 20 + move HARDEN, DEFENSE_UP1_EFFECT, 0, NORMAL, 100, 30 + move MINIMIZE, EVASION_UP1_EFFECT, 0, NORMAL, 100, 20 + move SMOKESCREEN, ACCURACY_DOWN1_EFFECT, 0, NORMAL, 100, 20 + move CONFUSE_RAY, CONFUSION_EFFECT, 0, GHOST, 100, 10 + move WITHDRAW, DEFENSE_UP1_EFFECT, 0, WATER, 100, 40 + move DEFENSE_CURL, DEFENSE_UP1_EFFECT, 0, NORMAL, 100, 40 + move BARRIER, DEFENSE_UP2_EFFECT, 0, PSYCHIC, 100, 30 + move LIGHT_SCREEN, LIGHT_SCREEN_EFFECT, 0, PSYCHIC, 100, 30 + move HAZE, HAZE_EFFECT, 0, ICE, 100, 30 + move REFLECT, REFLECT_EFFECT, 0, PSYCHIC, 100, 20 + move FOCUS_ENERGY, FOCUS_ENERGY_EFFECT, 0, NORMAL, 100, 30 + move BIDE, BIDE_EFFECT, 0, NORMAL, 100, 10 + move METRONOME, METRONOME_EFFECT, 0, NORMAL, 100, 10 + move MIRROR_MOVE, MIRROR_MOVE_EFFECT, 0, FLYING, 100, 20 + move SELFDESTRUCT, EXPLODE_EFFECT, 130, NORMAL, 100, 5 + move EGG_BOMB, NO_ADDITIONAL_EFFECT, 100, NORMAL, 75, 10 + move LICK, PARALYZE_SIDE_EFFECT2, 20, GHOST, 100, 30 + move SMOG, POISON_SIDE_EFFECT2, 20, POISON, 70, 20 + move SLUDGE, POISON_SIDE_EFFECT2, 65, POISON, 100, 20 + move BONE_CLUB, FLINCH_SIDE_EFFECT1, 65, GROUND, 85, 20 + move FIRE_BLAST, BURN_SIDE_EFFECT2, 120, FIRE, 85, 5 + move WATERFALL, NO_ADDITIONAL_EFFECT, 80, WATER, 100, 15 + move CLAMP, TRAPPING_EFFECT, 35, WATER, 75, 10 + move SWIFT, SWIFT_EFFECT, 60, NORMAL, 100, 20 + move SKULL_BASH, CHARGE_EFFECT, 100, NORMAL, 100, 15 + move SPIKE_CANNON, TWO_TO_FIVE_ATTACKS_EFFECT, 20, NORMAL, 100, 15 + move CONSTRICT, SPEED_DOWN_SIDE_EFFECT, 10, NORMAL, 100, 35 + move AMNESIA, SPECIAL_UP2_EFFECT, 0, PSYCHIC, 100, 20 + move KINESIS, ACCURACY_DOWN1_EFFECT, 0, PSYCHIC, 80, 15 + move SOFTBOILED, HEAL_EFFECT, 0, NORMAL, 100, 10 + move HI_JUMP_KICK, JUMP_KICK_EFFECT, 85, FIGHTING, 90, 20 + move GLARE, PARALYZE_EFFECT, 0, NORMAL, 75, 30 + move DREAM_EATER, DREAM_EATER_EFFECT, 100, PSYCHIC, 100, 15 + move POISON_GAS, POISON_EFFECT, 0, POISON, 55, 40 + move BARRAGE, TWO_TO_FIVE_ATTACKS_EFFECT, 15, NORMAL, 85, 20 + move LEECH_LIFE, DRAIN_HP_EFFECT, 20, BUG, 100, 15 + move LOVELY_KISS, SLEEP_EFFECT, 0, NORMAL, 75, 10 + move SKY_ATTACK, CHARGE_EFFECT, 140, FLYING, 90, 5 + move TRANSFORM, TRANSFORM_EFFECT, 0, NORMAL, 100, 10 + move BUBBLE, SPEED_DOWN_SIDE_EFFECT, 20, WATER, 100, 30 + move DIZZY_PUNCH, NO_ADDITIONAL_EFFECT, 70, NORMAL, 100, 10 + move SPORE, SLEEP_EFFECT, 0, GRASS, 100, 15 + move FLASH, ACCURACY_DOWN1_EFFECT, 0, NORMAL, 70, 20 + move PSYWAVE, SPECIAL_DAMAGE_EFFECT, 1, PSYCHIC, 80, 15 + move SPLASH, SPLASH_EFFECT, 0, NORMAL, 100, 40 + move ACID_ARMOR, DEFENSE_UP2_EFFECT, 0, POISON, 100, 40 + move CRABHAMMER, NO_ADDITIONAL_EFFECT, 90, WATER, 85, 10 + move EXPLOSION, EXPLODE_EFFECT, 170, NORMAL, 100, 5 + move FURY_SWIPES, TWO_TO_FIVE_ATTACKS_EFFECT, 18, NORMAL, 80, 15 + move BONEMERANG, ATTACK_TWICE_EFFECT, 50, GROUND, 90, 10 + move REST, HEAL_EFFECT, 0, PSYCHIC, 100, 10 + move ROCK_SLIDE, NO_ADDITIONAL_EFFECT, 75, ROCK, 90, 10 + move HYPER_FANG, FLINCH_SIDE_EFFECT1, 80, NORMAL, 90, 15 + move SHARPEN, ATTACK_UP1_EFFECT, 0, NORMAL, 100, 30 + move CONVERSION, CONVERSION_EFFECT, 0, NORMAL, 100, 30 + move TRI_ATTACK, NO_ADDITIONAL_EFFECT, 80, NORMAL, 100, 10 + move SUPER_FANG, SUPER_FANG_EFFECT, 1, NORMAL, 90, 10 + move SLASH, NO_ADDITIONAL_EFFECT, 70, NORMAL, 100, 20 + move SUBSTITUTE, SUBSTITUTE_EFFECT, 0, NORMAL, 100, 10 + move STRUGGLE, RECOIL_EFFECT, 50, NORMAL, 100, 10 diff --git a/macros.asm b/macros.asm index 8244c8c9a0..52518d4716 100644 --- a/macros.asm +++ b/macros.asm @@ -11,6 +11,9 @@ page EQUS "db $49," ; Start a new Pokedex page. dex EQUS "db $5f, $50" ; End a Pokedex entry. +percent EQUS "* $ff / 100" + + homecall: MACRO ld a, [H_LOADEDROMBANK] push af From daf4fc87ae66e2c3d56840774efba10a9b903ee3 Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Mon, 8 Sep 2014 23:32:33 -0700 Subject: [PATCH 015/100] Add comments regarding menus and sprites --- engine/overworld/movement.asm | 17 ++++++++++------- engine/overworld/pokemart.asm | 6 +++--- home.asm | 3 ++- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/engine/overworld/movement.asm b/engine/overworld/movement.asm index dbec2e4fa9..d84079adb2 100644 --- a/engine/overworld/movement.asm +++ b/engine/overworld/movement.asm @@ -1,22 +1,25 @@ UpdatePlayerSprite: ; 4e31 (1:4e31) ld a, [wSpriteStateData2] and a - jr z, .asm_4e41 + jr z, .checkIfTextBoxInFrontOfSprite cp $ff - jr z, .asm_4e4a + jr z, .disableSprite dec a ld [wSpriteStateData2], a - jr .asm_4e4a -.asm_4e41 + jr .disableSprite +; check if a text box is in front of the sprite by checking if the lower left +; background tile the sprite is standing on is greater than $5F, which is +; the maximum number for map tiles +.checkIfTextBoxInFrontOfSprite aCoord 8, 9 ld [$ff93], a cp $60 - jr c, .asm_4e50 -.asm_4e4a + jr c, .lowerLeftTileIsMapTile +.disableSprite ld a, $ff ld [wSpriteStateData1 + 2], a ret -.asm_4e50 +.lowerLeftTileIsMapTile call DetectCollisionBetweenSprites ld h, $c1 ld a, [wWalkCounter] ; wcfc5 diff --git a/engine/overworld/pokemart.asm b/engine/overworld/pokemart.asm index 3b06bd2c0c..1c2c23bfc9 100755 --- a/engine/overworld/pokemart.asm +++ b/engine/overworld/pokemart.asm @@ -173,13 +173,13 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20) ld [wcf0a],a .skipSettingFlag2 ld a,(SFX_02_5a - SFX_Headers_02) / 3 - call PlaySoundWaitForCurrent ; play sound - call WaitForSoundToFinish ; wait until sound is done playing + call PlaySoundWaitForCurrent + call WaitForSoundToFinish ld hl,PokemartBoughtItemText call PrintText jp .buyMenuLoop .returnToMainPokemartMenu - call LoadScreenTilesFromBuffer1 ; restore save screen + call LoadScreenTilesFromBuffer1 ld a,$13 ld [wd125],a call DisplayTextBoxID ; draw money text box diff --git a/home.asm b/home.asm index 2eea88eae5..870fb99a12 100644 --- a/home.asm +++ b/home.asm @@ -1936,7 +1936,8 @@ DisplayListMenuID:: ; 2be6 (0:2be6) ld a,$0d ; list menu text box ID ld [wd125],a call DisplayTextBoxID ; draw the menu text box - call UpdateSprites ; move sprites + call UpdateSprites ; disable sprites behind the text box +; the code up to .skipMovingSprites appears to be useless hlCoord 4, 2 ; coordinates of upper left corner of menu text box ld de,$090e ; height and width of menu text box ld a,[wListMenuID] From 91793015e53dbed09576f825d39e71bc59bf90a5 Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Tue, 9 Sep 2014 20:55:19 -0700 Subject: [PATCH 016/100] Labelled and commented mostly sprite-related things --- audio.asm | 2 +- constants/misc_constants.asm | 5 + constants/sprite_constants.asm | 10 +- data/mapObjects/fuchsiahouse2.asm | 2 +- data/mapObjects/seafoamislands1.asm | 4 +- data/mapObjects/seafoamislands2.asm | 4 +- data/mapObjects/seafoamislands3.asm | 4 +- data/mapObjects/seafoamislands4.asm | 8 +- data/mapObjects/victoryroad1.asm | 6 +- data/mapObjects/victoryroad2.asm | 6 +- data/mapObjects/victoryroad3.asm | 8 +- engine/battle/4_2.asm | 2 +- engine/battle/animations.asm | 26 +-- engine/evolve_trade.asm | 2 +- engine/evos_moves.asm | 2 +- engine/hidden_object_functions7.asm | 2 +- engine/in_game_trades.asm | 2 +- engine/items/items.asm | 24 +-- engine/menu/diploma.asm | 2 +- engine/menu/naming_screen.asm | 4 +- engine/menu/pokedex.asm | 4 +- engine/menu/start_sub_menus.asm | 18 +-- engine/overworld/cut.asm | 38 ++--- engine/overworld/cut2.asm | 14 +- engine/overworld/doors.asm | 15 +- engine/overworld/elevator.asm | 2 +- engine/overworld/ledges.asm | 8 +- engine/overworld/movement.asm | 14 +- engine/overworld/npc_movement.asm | 138 ++++++++-------- engine/overworld/pewter_guys.asm | 12 +- engine/overworld/player_animations.asm | 2 +- engine/overworld/ssanne.asm | 48 +++--- engine/overworld/trainers.asm | 58 +++---- engine/predefs.asm | 6 +- engine/slot_machine.asm | 2 +- engine/turn_sprite.asm | 18 +-- home.asm | 126 ++++++++------- home/audio.asm | 2 +- home/overworld.asm | 41 +++-- hram.asm | 3 + main.asm | 214 +++++++++++++------------ scripts/agatha.asm | 22 +-- scripts/battlecenterm.asm | 2 +- scripts/billshouse.asm | 2 +- scripts/bruno.asm | 22 +-- scripts/ceruleancity.asm | 6 +- scripts/cinnabarisland.asm | 10 +- scripts/daycarem.asm | 2 +- scripts/fightingdojo.asm | 4 +- scripts/gary.asm | 24 +-- scripts/halloffameroom.asm | 10 +- scripts/lance.asm | 8 +- scripts/lorelei.asm | 22 +-- scripts/museum1f.asm | 6 +- scripts/namerater.asm | 2 +- scripts/oakslab.asm | 130 +++++++-------- scripts/pallettown.asm | 16 +- scripts/pewtercity.asm | 50 +++--- scripts/pewterpokecenter.asm | 2 +- scripts/pokemontower2.asm | 4 +- scripts/pokemontower6.asm | 8 +- scripts/rockethideout2.asm | 6 +- scripts/rockethideout3.asm | 4 +- scripts/route16gate.asm | 16 +- scripts/route18gate.asm | 16 +- scripts/route22.asm | 14 +- scripts/route22gate.asm | 8 +- scripts/route23.asm | 8 +- scripts/route24.asm | 8 +- scripts/route5gate.asm | 8 +- scripts/route6gate.asm | 8 +- scripts/route7gate.asm | 8 +- scripts/route8gate.asm | 8 +- scripts/safarizoneentrance.asm | 8 +- scripts/seafoamislands4.asm | 14 +- scripts/seafoamislands5.asm | 16 +- scripts/silphco11.asm | 2 +- scripts/silphco7.asm | 6 +- scripts/ssanne2.asm | 4 +- scripts/ssanne7.asm | 2 +- scripts/vermilioncity.asm | 16 +- scripts/vermiliondock.asm | 8 +- scripts/viridiancity.asm | 8 +- scripts/viridiangym.asm | 4 +- scripts/viridianmart.asm | 8 +- wram.asm | 88 ++++++++-- 86 files changed, 828 insertions(+), 728 deletions(-) diff --git a/audio.asm b/audio.asm index 6dffd23a12..2f161426ba 100644 --- a/audio.asm +++ b/audio.asm @@ -563,7 +563,7 @@ Func_7d13b:: ; 7d13b (1f:513b) ld a, [hli] ld c, [hl] call PlayMusic - jp Func_2307 + jp PlayDefaultMusic PokedexRatingSfxPointers: ; 7d162 (1f:5162) db (SFX_1f_51 - SFX_Headers_1f) / 3, BANK(SFX_1f_51) diff --git a/constants/misc_constants.asm b/constants/misc_constants.asm index 29f15035d5..65144c1ec8 100644 --- a/constants/misc_constants.asm +++ b/constants/misc_constants.asm @@ -18,3 +18,8 @@ NUM_BOXES EQU 12 HOF_MON EQU $10 HOF_TEAM EQU PARTY_LENGTH * HOF_MON NUM_HOF_TEAMS EQU 50 + +NPC_MOVEMENT_DOWN EQU $00 +NPC_MOVEMENT_UP EQU $40 +NPC_MOVEMENT_LEFT EQU $80 +NPC_MOVEMENT_RIGHT EQU $C0 \ No newline at end of file diff --git a/constants/sprite_constants.asm b/constants/sprite_constants.asm index cc791a5764..b3ae8e2146 100755 --- a/constants/sprite_constants.asm +++ b/constants/sprite_constants.asm @@ -86,4 +86,12 @@ SPRITE_LYING_OLD_MAN EQU $48 ; different kinds of people events ITEM EQU $80 -TRAINER EQU $40 \ No newline at end of file +TRAINER EQU $40 + +BOULDER_MOVEMENT_BYTE_2 EQU $10 + +; sprite facing directions +SPRITE_FACING_DOWN EQU $00 +SPRITE_FACING_UP EQU $04 +SPRITE_FACING_LEFT EQU $08 +SPRITE_FACING_RIGHT EQU $0C \ No newline at end of file diff --git a/data/mapObjects/fuchsiahouse2.asm b/data/mapObjects/fuchsiahouse2.asm index 9f18768d41..f2958f022f 100755 --- a/data/mapObjects/fuchsiahouse2.asm +++ b/data/mapObjects/fuchsiahouse2.asm @@ -12,7 +12,7 @@ FuchsiaHouse2Object: ; 0x75180 (size=45) db $3 ; people db SPRITE_WARDEN, $3 + 4, $2 + 4, $ff, $ff, $1 ; person db SPRITE_BALL, $3 + 4, $8 + 4, $ff, $ff, ITEM | $2, RARE_CANDY - db SPRITE_BOULDER, $4 + 4, $8 + 4, $ff, $10, $3 ; person + db SPRITE_BOULDER, $4 + 4, $8 + 4, $ff, BOULDER_MOVEMENT_BYTE_2, $3 ; person ; warp-to EVENT_DISP FUCHSIA_HOUSE_2_WIDTH, $7, $4 diff --git a/data/mapObjects/seafoamislands1.asm b/data/mapObjects/seafoamislands1.asm index 85f344e8a5..62fc832093 100755 --- a/data/mapObjects/seafoamislands1.asm +++ b/data/mapObjects/seafoamislands1.asm @@ -13,8 +13,8 @@ SeafoamIslands1Object: ; 0x4484f (size=72) db $0 ; signs db $2 ; people - db SPRITE_BOULDER, $a + 4, $12 + 4, $ff, $10, $1 ; person - db SPRITE_BOULDER, $7 + 4, $1a + 4, $ff, $10, $2 ; person + db SPRITE_BOULDER, $a + 4, $12 + 4, $ff, BOULDER_MOVEMENT_BYTE_2, $1 ; person + db SPRITE_BOULDER, $7 + 4, $1a + 4, $ff, BOULDER_MOVEMENT_BYTE_2, $2 ; person ; warp-to EVENT_DISP SEAFOAM_ISLANDS_1_WIDTH, $11, $4 diff --git a/data/mapObjects/seafoamislands2.asm b/data/mapObjects/seafoamislands2.asm index 56251d1c8e..821a38cd0a 100755 --- a/data/mapObjects/seafoamislands2.asm +++ b/data/mapObjects/seafoamislands2.asm @@ -13,8 +13,8 @@ SeafoamIslands2Object: ; 0x46376 (size=72) db $0 ; signs db $2 ; people - db SPRITE_BOULDER, $6 + 4, $11 + 4, $ff, $10, $1 ; person - db SPRITE_BOULDER, $6 + 4, $16 + 4, $ff, $10, $2 ; person + db SPRITE_BOULDER, $6 + 4, $11 + 4, $ff, BOULDER_MOVEMENT_BYTE_2, $1 ; person + db SPRITE_BOULDER, $6 + 4, $16 + 4, $ff, BOULDER_MOVEMENT_BYTE_2, $2 ; person ; warp-to EVENT_DISP SEAFOAM_ISLANDS_2_WIDTH, $2, $4 ; SEAFOAM_ISLANDS_3 diff --git a/data/mapObjects/seafoamislands3.asm b/data/mapObjects/seafoamislands3.asm index 82d963a17d..0370805d25 100755 --- a/data/mapObjects/seafoamislands3.asm +++ b/data/mapObjects/seafoamislands3.asm @@ -13,8 +13,8 @@ SeafoamIslands3Object: ; 0x464b2 (size=72) db $0 ; signs db $2 ; people - db SPRITE_BOULDER, $6 + 4, $12 + 4, $ff, $10, $1 ; person - db SPRITE_BOULDER, $6 + 4, $17 + 4, $ff, $10, $2 ; person + db SPRITE_BOULDER, $6 + 4, $12 + 4, $ff, BOULDER_MOVEMENT_BYTE_2, $1 ; person + db SPRITE_BOULDER, $6 + 4, $17 + 4, $ff, BOULDER_MOVEMENT_BYTE_2, $2 ; person ; warp-to EVENT_DISP SEAFOAM_ISLANDS_3_WIDTH, $3, $5 ; SEAFOAM_ISLANDS_2 diff --git a/data/mapObjects/seafoamislands4.asm b/data/mapObjects/seafoamislands4.asm index aa18110ab3..3f1baa1d04 100755 --- a/data/mapObjects/seafoamislands4.asm +++ b/data/mapObjects/seafoamislands4.asm @@ -13,10 +13,10 @@ SeafoamIslands4Object: ; 0x466a6 (size=96) db $0 ; signs db $6 ; people - db SPRITE_BOULDER, $e + 4, $5 + 4, $ff, $10, $1 ; person - db SPRITE_BOULDER, $f + 4, $3 + 4, $ff, $10, $2 ; person - db SPRITE_BOULDER, $e + 4, $8 + 4, $ff, $10, $3 ; person - db SPRITE_BOULDER, $e + 4, $9 + 4, $ff, $10, $4 ; person + db SPRITE_BOULDER, $e + 4, $5 + 4, $ff, BOULDER_MOVEMENT_BYTE_2, $1 ; person + db SPRITE_BOULDER, $f + 4, $3 + 4, $ff, BOULDER_MOVEMENT_BYTE_2, $2 ; person + db SPRITE_BOULDER, $e + 4, $8 + 4, $ff, BOULDER_MOVEMENT_BYTE_2, $3 ; person + db SPRITE_BOULDER, $e + 4, $9 + 4, $ff, BOULDER_MOVEMENT_BYTE_2, $4 ; person db SPRITE_BOULDER, $6 + 4, $12 + 4, $ff, $ff, $5 ; person db SPRITE_BOULDER, $6 + 4, $13 + 4, $ff, $ff, $6 ; person diff --git a/data/mapObjects/victoryroad1.asm b/data/mapObjects/victoryroad1.asm index ebca80449f..96cb23bbac 100755 --- a/data/mapObjects/victoryroad1.asm +++ b/data/mapObjects/victoryroad1.asm @@ -13,9 +13,9 @@ VictoryRoad1Object: ; 0x5dab8 (size=76) db SPRITE_BLACK_HAIR_BOY_1, $2 + 4, $3 + 4, $ff, $d0, TRAINER | $2, COOLTRAINER_M + $C8, $5 db SPRITE_BALL, $0 + 4, $b + 4, $ff, $ff, ITEM | $3, TM_43 db SPRITE_BALL, $2 + 4, $9 + 4, $ff, $ff, ITEM | $4, RARE_CANDY - db SPRITE_BOULDER, $f + 4, $5 + 4, $ff, $10, $5 ; person - db SPRITE_BOULDER, $2 + 4, $e + 4, $ff, $10, $6 ; person - db SPRITE_BOULDER, $a + 4, $2 + 4, $ff, $10, $7 ; person + db SPRITE_BOULDER, $f + 4, $5 + 4, $ff, BOULDER_MOVEMENT_BYTE_2, $5 ; person + db SPRITE_BOULDER, $2 + 4, $e + 4, $ff, BOULDER_MOVEMENT_BYTE_2, $6 ; person + db SPRITE_BOULDER, $a + 4, $2 + 4, $ff, BOULDER_MOVEMENT_BYTE_2, $7 ; person ; warp-to EVENT_DISP VICTORY_ROAD_1_WIDTH, $11, $8 diff --git a/data/mapObjects/victoryroad2.asm b/data/mapObjects/victoryroad2.asm index c714bb51d2..39ec23c55e 100755 --- a/data/mapObjects/victoryroad2.asm +++ b/data/mapObjects/victoryroad2.asm @@ -23,9 +23,9 @@ VictoryRoad2Object: ; 0x51915 (size=154) db SPRITE_BALL, $9 + 4, $12 + 4, $ff, $ff, ITEM | $8, FULL_HEAL db SPRITE_BALL, $b + 4, $9 + 4, $ff, $ff, ITEM | $9, TM_05 db SPRITE_BALL, $0 + 4, $b + 4, $ff, $ff, ITEM | $a, GUARD_SPEC_ - db SPRITE_BOULDER, $e + 4, $4 + 4, $ff, $10, $b ; person - db SPRITE_BOULDER, $5 + 4, $5 + 4, $ff, $10, $c ; person - db SPRITE_BOULDER, $10 + 4, $17 + 4, $ff, $10, $d ; person + db SPRITE_BOULDER, $e + 4, $4 + 4, $ff, BOULDER_MOVEMENT_BYTE_2, $b ; person + db SPRITE_BOULDER, $5 + 4, $5 + 4, $ff, BOULDER_MOVEMENT_BYTE_2, $c ; person + db SPRITE_BOULDER, $10 + 4, $17 + 4, $ff, BOULDER_MOVEMENT_BYTE_2, $d ; person ; warp-to EVENT_DISP VICTORY_ROAD_2_WIDTH, $8, $0 ; VICTORY_ROAD_1 diff --git a/data/mapObjects/victoryroad3.asm b/data/mapObjects/victoryroad3.asm index d22014fa5d..998a189d59 100755 --- a/data/mapObjects/victoryroad3.asm +++ b/data/mapObjects/victoryroad3.asm @@ -16,10 +16,10 @@ VictoryRoad3Object: ; 0x44acd (size=106) db SPRITE_LASS, $3 + 4, $d + 4, $ff, $d3, TRAINER | $4, COOLTRAINER_F + $C8, $3 db SPRITE_BALL, $5 + 4, $1a + 4, $ff, $ff, ITEM | $5, MAX_REVIVE db SPRITE_BALL, $7 + 4, $7 + 4, $ff, $ff, ITEM | $6, TM_47 - db SPRITE_BOULDER, $3 + 4, $16 + 4, $ff, $10, $7 ; person - db SPRITE_BOULDER, $c + 4, $d + 4, $ff, $10, $8 ; person - db SPRITE_BOULDER, $a + 4, $18 + 4, $ff, $10, $9 ; person - db SPRITE_BOULDER, $f + 4, $16 + 4, $ff, $10, $a ; person + db SPRITE_BOULDER, $3 + 4, $16 + 4, $ff, BOULDER_MOVEMENT_BYTE_2, $7 ; person + db SPRITE_BOULDER, $c + 4, $d + 4, $ff, BOULDER_MOVEMENT_BYTE_2, $8 ; person + db SPRITE_BOULDER, $a + 4, $18 + 4, $ff, BOULDER_MOVEMENT_BYTE_2, $9 ; person + db SPRITE_BOULDER, $f + 4, $16 + 4, $ff, BOULDER_MOVEMENT_BYTE_2, $a ; person ; warp-to EVENT_DISP VICTORY_ROAD_3_WIDTH, $7, $17 ; VICTORY_ROAD_2 diff --git a/engine/battle/4_2.asm b/engine/battle/4_2.asm index bdbf70c5f8..79594bdd23 100755 --- a/engine/battle/4_2.asm +++ b/engine/battle/4_2.asm @@ -88,7 +88,7 @@ PickUpPayDayMoneyText: ; 1386b (4:786b) db "@" Func_13870: ; 13870 (4:7870) - ld a, [wcc57] + ld a, [wNPCMovementScriptPointerTableNum] and a ret nz ld a, [wd736] diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm index 6df682a0ee..a094b34c4d 100755 --- a/engine/battle/animations.asm +++ b/engine/battle/animations.asm @@ -1411,50 +1411,50 @@ Func_79329: ; 79329 (1e:5329) ld [hli], a ret -Func_79337: ; 79337 (1e:5337) +AdjustOAMBlockXPos: ; 79337 (1e:5337) ld l, e ld h, d -Func_79339: ; 79339 (1e:5339) +AdjustOAMBlockXPos2: ; 79339 (1e:5339) ld de, $4 -.asm_7933c +.loop ld a, [wd08a] ld b, a ld a, [hl] add b cp $a8 - jr c, .asm_7934a + jr c, .skipPuttingEntryOffScreen dec hl ld a, $a0 ld [hli], a -.asm_7934a +.skipPuttingEntryOffScreen ld [hl], a add hl, de dec c - jr nz, .asm_7933c + jr nz, .loop ret -Func_79350: ; 79350 (1e:5350) +AdjustOAMBlockYPos: ; 79350 (1e:5350) ld l, e ld h, d -Func_79352: ; 79352 (1e:5352) +AdjustOAMBlockYPos2: ; 79352 (1e:5352) ld de, $4 -.asm_79355 +.loop ld a, [wd08a] ld b, a ld a, [hl] add b cp $70 - jr c, .asm_79363 + jr c, .skipSettingPreviousEntrysAttribute dec hl - ld a, $a0 + ld a, $a0 ; bug, sets previous OAM entry's attribute ld [hli], a -.asm_79363 +.skipSettingPreviousEntrysAttribute ld [hl], a add hl, de dec c - jr nz, .asm_79355 + jr nz, .loop ret AnimationBlinkEnemyMon: ; 79369 (1e:5369) diff --git a/engine/evolve_trade.asm b/engine/evolve_trade.asm index 97c261d0c3..7fbd4607b9 100755 --- a/engine/evolve_trade.asm +++ b/engine/evolve_trade.asm @@ -41,4 +41,4 @@ EvolveTradeMon: ; 17d7d (5:7d7d) callab TryEvolvingMon xor a ld [W_ISLINKBATTLE], a ; W_ISLINKBATTLE - jp Func_2307 + jp PlayDefaultMusic diff --git a/engine/evos_moves.asm b/engine/evos_moves.asm index 90f89bce35..61ddb4e734 100755 --- a/engine/evos_moves.asm +++ b/engine/evos_moves.asm @@ -254,7 +254,7 @@ Evolution_PartyMonLoop: ; loop over party mons ret nz ld a, [wd121] and a - call nz, Func_2307 + call nz, PlayDefaultMusic ret ; checks if the evolved mon's name is different from the standard name (i.e. it has a nickname) diff --git a/engine/hidden_object_functions7.asm b/engine/hidden_object_functions7.asm index 848f6f3d07..07cf5651de 100755 --- a/engine/hidden_object_functions7.asm +++ b/engine/hidden_object_functions7.asm @@ -357,7 +357,7 @@ BillsHousePC: ; 1eb6e (7:6b6e) ld a, (SFX_02_3a - SFX_Headers_02) / 3 call PlaySound call WaitForSoundToFinish - call Func_2307 + call PlayDefaultMusic ld hl, wd7f2 set 3, [hl] ret diff --git a/engine/in_game_trades.asm b/engine/in_game_trades.asm index 7f0b21c164..ad9de8b132 100755 --- a/engine/in_game_trades.asm +++ b/engine/in_game_trades.asm @@ -150,7 +150,7 @@ Func_71c07: ; 71c07 (1c:5c07) Func_71ca2: ; 71ca2 (1c:5ca2) call GBPalWhiteOutWithDelay3 - call Func_3dbe + call RestoreScreenTilesAndReloadTilePatterns call ReloadTilesetTilePatterns call LoadScreenTilesFromBuffer2 call Delay3 diff --git a/engine/items/items.asm b/engine/items/items.asm index b45c20da8c..860479e75a 100755 --- a/engine/items/items.asm +++ b/engine/items/items.asm @@ -517,7 +517,7 @@ ItemUseBicycle: ; d977 (3:5977) call ItemUseReloadOverworldData xor a ld [wd700],a ; change player state to walking - call Func_2307 ; play walking music + call PlayDefaultMusic ; play walking music ld hl,GotOffBicycleText jr .printText .tryToGetOnBike @@ -529,7 +529,7 @@ ItemUseBicycle: ; d977 (3:5977) inc a ld [wd700],a ; change player state to bicycling ld hl,GotOnBicycleText - call Func_2307 ; play bike riding music + call PlayDefaultMusic ; play bike riding music .printText jp PrintText @@ -551,7 +551,7 @@ ItemUseSurfboard: ; d9b4 (3:59b4) set 7,[hl] ld a,2 ld [wd700],a ; change player state to surfing - call Func_2307 ; play surfing music + call PlayDefaultMusic ; play surfing music ld hl,SurfingGotOnText jp PrintText .tryToStopSurfing @@ -589,28 +589,28 @@ ItemUseSurfboard: ; d9b4 (3:59b4) ld [wd700],a ; change player state to walking dec a ld [wJoyIgnore],a - call Func_2307 ; play walking music + call PlayDefaultMusic ; play walking music jp LoadWalkingPlayerSpriteGraphics ; uses a simulated button press to make the player move forward .makePlayerMoveForward ld a,[wd52a] ; direction the player is going bit 3,a - ld b,%01000000 ; Up key + ld b,D_UP jr nz,.storeSimulatedButtonPress bit 2,a - ld b,%10000000 ; Down key + ld b,D_DOWN jr nz,.storeSimulatedButtonPress bit 1,a - ld b,%00100000 ; Left key + ld b,D_LEFT jr nz,.storeSimulatedButtonPress - ld b,%00010000 ; Right key + ld b,D_RIGHT .storeSimulatedButtonPress ld a,b - ld [wccd3],a ; base address of simulated button presses + ld [wSimulatedJoypadStatesEnd],a xor a - ld [wcd39],a + ld [wWastedByteCD39],a inc a - ld [wcd38],a ; index of current simulated button press + ld [wSimulatedJoypadStatesIndex],a ret SurfingGotOnText: ; da4c (3:5a4c) @@ -1727,7 +1727,7 @@ PlayedFluteHadEffectText: ; e215 (3:6215) ld a,[wc028] cp a,$b8 jr z,.musicWaitLoop - call Func_2307 ; start playing normal music again + call PlayDefaultMusic ; start playing normal music again .done jp TextScriptEnd ; end text diff --git a/engine/menu/diploma.asm b/engine/menu/diploma.asm index 023c6177d4..adf4c39626 100755 --- a/engine/menu/diploma.asm +++ b/engine/menu/diploma.asm @@ -61,7 +61,7 @@ DisplayDiploma: ; 566e2 (15:66e2) ld hl, wd730 res 6, [hl] call GBPalWhiteOutWithDelay3 - call Func_3dbe + call RestoreScreenTilesAndReloadTilePatterns call Delay3 jp GBPalNormal diff --git a/engine/menu/naming_screen.asm b/engine/menu/naming_screen.asm index 7a0e7691b0..f7fc883c58 100755 --- a/engine/menu/naming_screen.asm +++ b/engine/menu/naming_screen.asm @@ -33,7 +33,7 @@ AskName: ; 64eb (1:64eb) ld a, [W_ISINBATTLE] ; W_ISINBATTLE and a jr nz, .asm_653e - call Func_3e08 + call ReloadMapSpriteTilePatterns .asm_653e call LoadScreenTilesFromBuffer1 pop hl @@ -61,7 +61,7 @@ Func_655c: ; 655c (1:655c) ld [wd07d], a call DisplayNamingScreen call GBPalWhiteOutWithDelay3 - call Func_3dbe + call RestoreScreenTilesAndReloadTilePatterns call LoadGBPal ld a, [wcf4b] cp $50 diff --git a/engine/menu/pokedex.asm b/engine/menu/pokedex.asm index 63e440f840..8f4bc508ea 100755 --- a/engine/menu/pokedex.asm +++ b/engine/menu/pokedex.asm @@ -36,8 +36,8 @@ ShowPokedexMenu: ; 40000 (10:4000) ld [wCurrentMenuItem],a ld [wLastMenuItem],a ld [$ffb7],a - ld [wcd3a],a - ld [wcd3b],a + ld [wWastedByteCD3A],a + ld [wOverrideSimulatedJoypadStatesMask],a pop af ld [wListScrollOffset],a call GBPalWhiteOutWithDelay3 diff --git a/engine/menu/start_sub_menus.asm b/engine/menu/start_sub_menus.asm index 6a64567586..e774565ad1 100755 --- a/engine/menu/start_sub_menus.asm +++ b/engine/menu/start_sub_menus.asm @@ -25,7 +25,7 @@ StartMenu_Pokemon: ; 130a9 (4:70a9) jr nc,.chosePokemon .exitMenu call GBPalWhiteOutWithDelay3 - call Func_3dbe + call RestoreScreenTilesAndReloadTilePatterns call LoadGBPal jp RedisplayStartMenu .chosePokemon @@ -273,7 +273,7 @@ StartMenu_Pokemon: ; 130a9 (4:70a9) TX_FAR _NotHealthyEnoughText db "@" .goBackToMap - call Func_3dbe + call RestoreScreenTilesAndReloadTilePatterns jp CloseTextDisplay .newBadgeRequired ld hl,.newBadgeRequiredText @@ -413,7 +413,7 @@ StartMenu_Item: ; 13302 (4:7302) cp a,$02 jp z,.partyMenuNotDisplayed call GBPalWhiteOutWithDelay3 - call Func_3dbe + call RestoreScreenTilesAndReloadTilePatterns pop af ld [wcfcb],a jp StartMenu_Item @@ -790,7 +790,7 @@ SwitchPartyMon_Stats: ; 13653 (4:7653) ld a, [wCurrentMenuItem] ; wCurrentMenuItem call AddNTimes push hl - ld de, wcc97 + ld de, wSwitchPartyMonTempBuffer ld bc, $2c call CopyData ld hl, wPartyMons @@ -802,14 +802,14 @@ SwitchPartyMon_Stats: ; 13653 (4:7653) ld bc, $2c call CopyData pop de - ld hl, wcc97 + ld hl, wSwitchPartyMonTempBuffer ld bc, $2c call CopyData ld hl, wPartyMonOT ; wd273 ld a, [wCurrentMenuItem] ; wCurrentMenuItem call SkipFixedLengthTextEntries push hl - ld de, wcc97 + ld de, wSwitchPartyMonTempBuffer ld bc, $b call CopyData ld hl, wPartyMonOT ; wd273 @@ -820,14 +820,14 @@ SwitchPartyMon_Stats: ; 13653 (4:7653) ld bc, $b call CopyData pop de - ld hl, wcc97 + ld hl, wSwitchPartyMonTempBuffer ld bc, $b call CopyData ld hl, wPartyMonNicks ; wPartyMonNicks ld a, [wCurrentMenuItem] ; wCurrentMenuItem call SkipFixedLengthTextEntries push hl - ld de, wcc97 + ld de, wSwitchPartyMonTempBuffer ld bc, $b call CopyData ld hl, wPartyMonNicks ; wPartyMonNicks @@ -838,7 +838,7 @@ SwitchPartyMon_Stats: ; 13653 (4:7653) ld bc, $b call CopyData pop de - ld hl, wcc97 + ld hl, wSwitchPartyMonTempBuffer ld bc, $b call CopyData ld a, [wMenuItemToSwap] diff --git a/engine/overworld/cut.asm b/engine/overworld/cut.asm index d4d327e7bc..59abe7914e 100755 --- a/engine/overworld/cut.asm +++ b/engine/overworld/cut.asm @@ -36,7 +36,7 @@ asm_ef82: ; ef82 (3:6f82) set 6, [hl] call GBPalWhiteOutWithDelay3 call ClearSprites - call Func_3dbe + call RestoreScreenTilesAndReloadTilePatterns ld a, $90 ld [hVBlankWY], a call Delay3 @@ -87,17 +87,17 @@ AnimateCutTree: ; eff7 (3:6ff7) ld hl, vChars1 + $7e0 ld bc, (BANK(Overworld_GFX) << 8) + $02 call CopyVideoData - jr asm_f055 + jr WriteCutTreeBoulderDustAnimationOAMBlock .asm_f020 ld hl, vChars1 + $7c0 - call LoadCutTreeOAM + call LoadCutTreeAnimationTilePattern ld hl, vChars1 + $7d0 - call LoadCutTreeOAM + call LoadCutTreeAnimationTilePattern ld hl, vChars1 + $7e0 - call LoadCutTreeOAM + call LoadCutTreeAnimationTilePattern ld hl, vChars1 + $7f0 - call LoadCutTreeOAM - call asm_f055 + call LoadCutTreeAnimationTilePattern + call WriteCutTreeBoulderDustAnimationOAMBlock ld hl, wOAMBuffer + $93 ld de, $4 ld a, $30 @@ -110,26 +110,27 @@ AnimateCutTree: ; eff7 (3:6ff7) jr nz, .asm_f044 ret -LoadCutTreeOAM: ; f04c (3:704c) +LoadCutTreeAnimationTilePattern: ; f04c (3:704c) ld de, AnimationTileset2 + $60 ; $474e ; tile depicting a leaf ld bc, (BANK(AnimationTileset2) << 8) + $01 jp CopyVideoData -asm_f055: ; f055 (3:7055) - call Func_f068 + +WriteCutTreeBoulderDustAnimationOAMBlock: ; f055 (3:7055) + call GetCutTreeBoulderDustAnimationOffsets ld a, $9 - ld de, CutTreeOAM ; $7060 + ld de, CutTreeBoulderDustAnimationTilesAndAttributes jp WriteOAMBlock -CutTreeOAM: ; f060 (3:7060) +CutTreeBoulderDustAnimationTilesAndAttributes: ; f060 (3:7060) db $FC,$10,$FD,$10 db $FE,$10,$FF,$10 -Func_f068: ; f068 (3:7068) +GetCutTreeBoulderDustAnimationOffsets: ; f068 (3:7068) ld hl, wSpriteStateData1 + 4 - ld a, [hli] + ld a, [hli] ; player's sprite screen Y position ld b, a inc hl - ld a, [hli] + ld a, [hli] ; player's sprite screen X position ld c, a ; bc holds ypos/xpos of player's sprite inc hl inc hl @@ -139,9 +140,9 @@ Func_f068: ; f068 (3:7068) ld d, $0 ; de holds direction (00: down, 02: up, 04: left, 06: right) ld a, [wcd50] and a - ld hl, CutTreeAnimationOffsets ; $708f + ld hl, CutTreeAnimationOffsets jr z, .asm_f084 - ld hl, CutTreeAnimationOffsets2 ; $7097 + ld hl, BoulderDustAnimationOffsets .asm_f084 add hl, de ld e, [hl] @@ -162,8 +163,7 @@ CutTreeAnimationOffsets: ; f08f (3:708f) db -8, 20 ; player is facing left db 24, 20 ; player is facing right -CutTreeAnimationOffsets2: ; f097 (3:7097) -; Not sure if these ever get used. CutTreeAnimationOffsets only seems to be used. +BoulderDustAnimationOffsets: ; f097 (3:7097) ; Each pair represents the x and y pixels offsets from the player of where the cut tree animation should be drawn ; These offsets represent 2 blocks away from the player db 8, 52 ; player is facing down diff --git a/engine/overworld/cut2.asm b/engine/overworld/cut2.asm index 08f6d6518c..de2b9d5570 100755 --- a/engine/overworld/cut2.asm +++ b/engine/overworld/cut2.asm @@ -9,12 +9,12 @@ Func_79e96: ; 79e96 (1e:5e96) ld a, $1 ld [wd08a], a ld c, $2 - call Func_79339 + call AdjustOAMBlockXPos2 ld hl, wOAMBuffer + $99 ld a, $ff ld [wd08a], a ld c, $2 - call Func_79339 + call AdjustOAMBlockXPos2 ld a, [rOBP1] ; $ff49 xor $64 ld [rOBP1], a ; $ff49 @@ -37,7 +37,7 @@ Func_79e96: ; 79e96 (1e:5e96) ld a, $2 ld [wd08a], a ld c, $4 - call Func_79352 + call AdjustOAMBlockYPos2 pop bc dec c jr nz, .asm_79eca @@ -49,22 +49,22 @@ Func_79eed: ; 79eed (1e:5eed) ld a, $1 ld [wd08a], a ld c, $1 - call Func_79339 + call AdjustOAMBlockXPos2 ld hl, wOAMBuffer + $95 ld a, $2 ld [wd08a], a ld c, $1 - call Func_79339 + call AdjustOAMBlockXPos2 ld hl, wOAMBuffer + $99 ld a, $fe ld [wd08a], a ld c, $1 - call Func_79339 + call AdjustOAMBlockXPos2 ld hl, wOAMBuffer + $9d ld a, $ff ld [wd08a], a ld c, $1 - call Func_79339 + call AdjustOAMBlockXPos2 ld a, [rOBP1] ; $ff49 xor $64 ld [rOBP1], a ; $ff49 diff --git a/engine/overworld/doors.asm b/engine/overworld/doors.asm index 42ebb1744b..85ff58b2d6 100755 --- a/engine/overworld/doors.asm +++ b/engine/overworld/doors.asm @@ -1,26 +1,27 @@ -HandleDoors: ; 1a609 (6:6609) +; returns whether the player is standing on a door in carry +IsPlayerStandingOnDoor: ; 1a609 (6:6609) push de ld hl, DoorTileIDPointers ; $662c ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET ld de, $3 call IsInArray pop de - jr nc, .asm_1a62a + jr nc, .notStandingOnDoor inc hl ld a, [hli] ld h, [hl] ld l, a - aCoord 8, 9 + aCoord 8, 9 ; a = lower left background tile under player's sprite ld b, a -.asm_1a621 +.loop ld a, [hli] and a - jr z, .asm_1a62a + jr z, .notStandingOnDoor cp b - jr nz, .asm_1a621 + jr nz, .loop scf ret -.asm_1a62a +.notStandingOnDoor and a ret diff --git a/engine/overworld/elevator.asm b/engine/overworld/elevator.asm index 10b3b00334..d1d7d82a45 100755 --- a/engine/overworld/elevator.asm +++ b/engine/overworld/elevator.asm @@ -38,7 +38,7 @@ ShakeElevator: ; 7bf15 (1e:7f15) cp $b9 jr z, .asm_7bf57 call UpdateSprites - jp Func_2307 + jp PlayDefaultMusic Func_7bf64: ; 7bf64 (1e:7f64) ld hl, wd527 diff --git a/engine/overworld/ledges.asm b/engine/overworld/ledges.asm index 43df82e25c..21e1b567b8 100755 --- a/engine/overworld/ledges.asm +++ b/engine/overworld/ledges.asm @@ -43,12 +43,12 @@ HandleLedges: ; 1a672 (6:6672) ld [wJoyIgnore], a ld hl, wd736 set 6, [hl] - call Func_3486 + call StartSimulatingJoypadStates ld a, e - ld [wccd3], a - ld [wccd4], a + ld [wSimulatedJoypadStatesEnd], a + ld [wSimulatedJoypadStatesEnd + 1], a ld a, $2 - ld [wcd38], a + ld [wSimulatedJoypadStatesIndex], a call LoadHoppingShadowOAM ld a, (SFX_02_4e - SFX_Headers_02) / 3 call PlaySound diff --git a/engine/overworld/movement.asm b/engine/overworld/movement.asm index d84079adb2..3b9cac7db8 100644 --- a/engine/overworld/movement.asm +++ b/engine/overworld/movement.asm @@ -168,8 +168,8 @@ Func_4ed1: ; 4ed1 (1:4ed1) ld hl, wd730 res 0, [hl] xor a - ld [wcd38], a - ld [wcd3a], a + ld [wSimulatedJoypadStatesIndex], a + ld [wWastedByteCD3A], a ret .asm_4f4b cp $fe @@ -493,6 +493,8 @@ CheckSpriteAvailability: ; 50dc (1:50dc) cp b jr c, .spriteInvisible ; right of screen region .skipXVisibilityTest +; make the sprite invisible if a text box is in front of it +; $5F is the maximum number for map tiles call getTileSpriteStandsOn ld d, $60 ld a, [hli] @@ -719,8 +721,8 @@ Func_5236: ; 5236 (1:5236) bit 7, [hl] set 7, [hl] jp z, Func_52a6 - ld hl, wcc97 - ld a, [wcd37] + ld hl, wNPCMovementDirections2 + ld a, [wNPCMovementDirections2Index] add l ld l, a jr nc, .asm_5251 @@ -773,13 +775,13 @@ Func_5236: ; 5236 (1:5236) ret nz ld a, $8 ld [wcf18], a - ld hl, wcd37 + ld hl, wNPCMovementDirections2Index inc [hl] ret Func_52a6: ; 52a6 (1:52a6) xor a - ld [wcd37], a + ld [wNPCMovementDirections2Index], a ld a, $8 ld [wcf18], a jp Func_52c3 diff --git a/engine/overworld/npc_movement.asm b/engine/overworld/npc_movement.asm index 2cf6fea952..e49c6af119 100755 --- a/engine/overworld/npc_movement.asm +++ b/engine/overworld/npc_movement.asm @@ -1,25 +1,25 @@ -Func_1a3e0: ; 1a3e0 (6:63e0) +PlayerStepOutFromDoor: ; 1a3e0 (6:63e0) ld hl, wd730 res 1, [hl] - call HandleDoors - jr nc, .asm_1a406 + call IsPlayerStandingOnDoor + jr nc, .notStandingOnDoor ld a, $fc ld [wJoyIgnore], a ld hl, wd736 set 1, [hl] ld a, $1 - ld [wcd38], a - ld a, $80 - ld [wccd3], a + ld [wSimulatedJoypadStatesIndex], a + ld a, D_DOWN + ld [wSimulatedJoypadStatesEnd], a xor a ld [wSpriteStateData1 + 2], a - call Func_3486 + call StartSimulatingJoypadStates ret -.asm_1a406 +.notStandingOnDoor xor a - ld [wcd3a], a - ld [wcd38], a - ld [wccd3], a + ld [wWastedByteCD3A], a + ld [wSimulatedJoypadStatesIndex], a + ld [wSimulatedJoypadStatesEnd], a ld hl, wd736 res 0, [hl] res 1, [hl] @@ -27,7 +27,7 @@ Func_1a3e0: ; 1a3e0 (6:63e0) res 7, [hl] ret -Func_1a41d: ; 1a41d (6:641d) +_EndNPCMovementScript: ; 1a41d (6:641d) ld hl, wd730 res 7, [hl] ld hl, wd72e @@ -36,15 +36,15 @@ Func_1a41d: ; 1a41d (6:641d) res 0, [hl] res 1, [hl] xor a - ld [wcf17], a - ld [wcc57], a - ld [wcf10], a - ld [wcd3a], a - ld [wcd38], a - ld [wccd3], a + ld [wNPCMovementScriptSpriteOffset], a + ld [wNPCMovementScriptPointerTableNum], a + ld [wNPCMovementScriptFunctionNum], a + ld [wWastedByteCD3A], a + ld [wSimulatedJoypadStatesIndex], a + ld [wSimulatedJoypadStatesEnd], a ret -PointerTable_1a442: ; 1a442 (6:6442) +ProfOakMovementScriptPointerTable: ; 1a442 (6:6442) dw Func_1a44c dw Func_1a485 dw Func_1a4a1 @@ -58,20 +58,20 @@ Func_1a44c: ; 1a44c (6:644c) jr z, .asm_1a475 ld b, $0 ld c, a - ld hl, wcc97 + ld hl, wNPCMovementDirections2 ld a, $80 call FillMemory ld [hl], $ff ld a, [wcf13] ld [H_DOWNARROWBLINKCNT2], a ; $ff8c - ld de, wcc97 + ld de, wNPCMovementDirections2 call MoveSprite ld a, $1 - ld [wcf10], a + ld [wNPCMovementScriptFunctionNum], a jr .asm_1a47a .asm_1a475 ld a, $3 - ld [wcf10], a + ld [wNPCMovementScriptFunctionNum], a .asm_1a47a ld hl, W_FLAGS_D733 set 1, [hl] @@ -84,33 +84,33 @@ Func_1a485: ; 1a485 (6:6485) bit 0, a ret nz ld a, [wcca1] - ld [wcd38], a + ld [wSimulatedJoypadStatesIndex], a ld [$ff95], a - predef Func_f9a0 - call Func_3486 + predef ConvertNPCMovementDirectionsToJoypadMasks + call StartSimulatingJoypadStates ld a, $2 - ld [wcf10], a + ld [wNPCMovementScriptFunctionNum], a ret Func_1a4a1: ; 1a4a1 (6:64a1) - ld a, [wcd38] + ld a, [wSimulatedJoypadStatesIndex] and a ret nz Func_1a4a6: ; 1a4a6 (6:64a6) xor a - ld [wcd3b], a + ld [wOverrideSimulatedJoypadStatesMask], a ld a, [wcf13] swap a - ld [wcf17], a + ld [wNPCMovementScriptSpriteOffset], a xor a ld [wSpriteStateData2 + $06], a - ld hl, wccd3 + ld hl, wSimulatedJoypadStatesEnd ld de, RLEList_1a4e9 call DecodeRLEList dec a - ld [wcd38], a - ld hl, wcc97 + ld [wSimulatedJoypadStatesIndex], a + ld hl, wNPCMovementDirections2 ld de, RLEList_1a4dc call DecodeRLEList ld hl, wd72e @@ -118,7 +118,7 @@ Func_1a4a6: ; 1a4a6 (6:64a6) ld hl, wd730 set 7, [hl] ld a, $4 - ld [wcf10], a + ld [wNPCMovementScriptFunctionNum], a ret RLEList_1a4dc: ; 1a4dc (6:64dc) @@ -131,15 +131,15 @@ RLEList_1a4dc: ; 1a4dc (6:64dc) db $FF RLEList_1a4e9: ; 1a4e9 (6:64e9) - db $40, $02 - db $10, $03 - db $80, $05 - db $20, $01 - db $80, $06 + db D_UP, $02 + db D_RIGHT, $03 + db D_DOWN, $05 + db D_LEFT, $01 + db D_DOWN, $06 db $FF Func_1a4f4: ; 1a4f4 (6:64f4) - ld a, [wcd38] + ld a, [wSimulatedJoypadStatesIndex] and a ret nz ld a, $0 @@ -149,11 +149,11 @@ Func_1a4f4: ; 1a4f4 (6:64f4) res 7, [hl] ld hl, wd72e res 7, [hl] - jp Func_314e + jp EndNPCMovementScript -PointerTable_1a510: ; 1a510 (6:6510) +PewterMuseumGuyMovementScriptPointerTable: ; 1a510 (6:6510) dw Func_1a514 - dw Func_1a56b + dw PewterMovementScriptDone Func_1a514: ; 1a514 (6:6514) ld a, BANK(Music_MuseumGuy) @@ -164,30 +164,30 @@ Func_1a514: ; 1a514 (6:6514) call PlaySound ld a, [wcf13] swap a - ld [wcf17], a - call Func_3486 - ld hl, wccd3 + ld [wNPCMovementScriptSpriteOffset], a + call StartSimulatingJoypadStates + ld hl, wSimulatedJoypadStatesEnd ld de, RLEList_PewterMuseumPlayer call DecodeRLEList dec a - ld [wcd38], a + ld [wSimulatedJoypadStatesIndex], a xor a ld [wd12f], a predef PewterGuys - ld hl, wcc97 + ld hl, wNPCMovementDirections2 ld de, RLEList_PewterMuseumGuy call DecodeRLEList ld hl, wd72e res 7, [hl] ld a, $1 - ld [wcf10], a + ld [wNPCMovementScriptFunctionNum], a ret RLEList_PewterMuseumPlayer: ; 1a559 (6:6559) - db $00, $01 - db $40, $03 - db $20, $0D - db $40, $06 + db 0, $01 + db D_UP, $03 + db D_LEFT, $0D + db D_UP, $06 db $FF RLEList_PewterMuseumGuy: ; 1a562 (6:6562) @@ -197,19 +197,19 @@ RLEList_PewterMuseumGuy: ; 1a562 (6:6562) db $80, $01 db $FF -Func_1a56b: ; 1a56b (6:656b) - ld a, [wcd38] +PewterMovementScriptDone: ; 1a56b (6:656b) + ld a, [wSimulatedJoypadStatesIndex] and a ret nz ld hl, wd730 res 7, [hl] ld hl, wd72e res 7, [hl] - jp Func_314e + jp EndNPCMovementScript -PointerTable_1a57d: ; 1a57d (6:657d) +PewterGymGuyMovementScriptPointerTable: ; 1a57d (6:657d) dw Func_1a581 - dw Func_1a56b + dw PewterMovementScriptDone Func_1a581: ; 1a581 (6:6581) ld a, BANK(Music_MuseumGuy) @@ -220,18 +220,18 @@ Func_1a581: ; 1a581 (6:6581) call PlaySound ld a, [wcf13] swap a - ld [wcf17], a + ld [wNPCMovementScriptSpriteOffset], a xor a ld [wSpriteStateData2 + $06], a - ld hl, wccd3 + ld hl, wSimulatedJoypadStatesEnd ld de, RLEList_PewterGymPlayer call DecodeRLEList dec a - ld [wcd38], a + ld [wSimulatedJoypadStatesIndex], a ld a, $1 ld [wd12f], a predef PewterGuys - ld hl, wcc97 + ld hl, wNPCMovementDirections2 ld de, RLEList_PewterGymGuy call DecodeRLEList ld hl, wd72e @@ -239,16 +239,16 @@ Func_1a581: ; 1a581 (6:6581) ld hl, wd730 set 7, [hl] ld a, $1 - ld [wcf10], a + ld [wNPCMovementScriptFunctionNum], a ret RLEList_PewterGymPlayer: ; 1a5cd (6:65cd) - db $00, $01 - db $10, $02 - db $80, $05 - db $20, $0B - db $40, $05 - db $20, $0F + db 0, $01 + db D_RIGHT, $02 + db D_DOWN, $05 + db D_LEFT, $0B + db D_UP, $05 + db D_LEFT, $0F db $FF RLEList_PewterGymGuy: ; 1a5da (6:65da) diff --git a/engine/overworld/pewter_guys.asm b/engine/overworld/pewter_guys.asm index 2f3001fb46..eb6dd5ac0f 100755 --- a/engine/overworld/pewter_guys.asm +++ b/engine/overworld/pewter_guys.asm @@ -1,8 +1,8 @@ PewterGuys: ; 37ca1 (d:7ca1) - ld hl, wccd3 - ld a, [wcd38] - dec a - ld [wcd38], a + ld hl, wSimulatedJoypadStatesEnd + ld a, [wSimulatedJoypadStatesIndex] + dec a ; this decrement causes it to overwrite the last byte before $FF in the list + ld [wSimulatedJoypadStatesIndex], a ld d, 0 ld e, a add hl, de @@ -37,9 +37,9 @@ PewterGuys: ; 37ca1 (d:7ca1) ret z ld [de], a inc de - ld a, [wcd38] + ld a, [wSimulatedJoypadStatesIndex] inc a - ld [wcd38], a + ld [wSimulatedJoypadStatesIndex], a jr .asm_37cd2 .asm_37ce1 inc hl diff --git a/engine/overworld/player_animations.asm b/engine/overworld/player_animations.asm index a0d8175f09..f915a2b9db 100755 --- a/engine/overworld/player_animations.asm +++ b/engine/overworld/player_animations.asm @@ -34,7 +34,7 @@ Func_70510: ; 70510 (1c:4510) ld hl, wcd48 call Func_70730 .asm_70558 - call Func_2307 + call PlayDefaultMusic .asm_7055b jp Func_70772 .asm_7055e diff --git a/engine/overworld/ssanne.asm b/engine/overworld/ssanne.asm index 8fd8f99a0a..bdbbd17e7d 100755 --- a/engine/overworld/ssanne.asm +++ b/engine/overworld/ssanne.asm @@ -1,37 +1,37 @@ -Func_79f54: ; 79f54 (1e:5f54) +AnimateBoulderDust: ; 79f54 (1e:5f54) ld a, $1 - ld [wcd50], a + ld [wcd50], a ; select the boulder dust offsets ld a, [wcfcb] push af ld a, $ff ld [wcfcb], a - ld a, $e4 - ld [rOBP1], a ; $ff49 + ld a, %11100100 + ld [rOBP1], a call LoadSmokeTileFourTimes - callba asm_f055 - ld c, $8 -.asm_79f73 + callba WriteCutTreeBoulderDustAnimationOAMBlock + ld c, 8 ; number of steps in animation +.loop push bc - call Func_79f92 - ld bc, .asm_79f7e + call GetMoveBoulderDustFunctionPointer + ld bc, .returnAddress push bc ld c, $4 jp [hl] -.asm_79f7e - ld a, [rOBP1] ; $ff49 - xor $64 - ld [rOBP1], a ; $ff49 +.returnAddress + ld a, [rOBP1] + xor %01100100 + ld [rOBP1], a call Delay3 pop bc dec c - jr nz, .asm_79f73 + jr nz, .loop pop af ld [wcfcb], a jp LoadPlayerSpriteGraphics -Func_79f92: ; 79f92 (1e:5f92) - ld a, [wSpriteStateData1 + 9] - ld hl, PointerTable_79fb0 ; $5fb0 +GetMoveBoulderDustFunctionPointer: ; 79f92 (1e:5f92) + ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction + ld hl, MoveBoulderDustFunctionPointerTable ld c, a ld b, $0 add hl, bc @@ -51,18 +51,22 @@ Func_79f92: ; 79f92 (1e:5f92) pop hl ret -PointerTable_79fb0: ; 79fb0 (1e:5fb0) +MoveBoulderDustFunctionPointerTable: ; 79fb0 (1e:5fb0) +; facing down db $FF,$00 - dw Func_79350 + dw AdjustOAMBlockYPos +; facing up db $01,$00 - dw Func_79350 + dw AdjustOAMBlockYPos +; facing left db $01,$01 - dw Func_79337 + dw AdjustOAMBlockXPos +; facing right db $FF,$01 - dw Func_79337 + dw AdjustOAMBlockXPos LoadSmokeTileFourTimes: ; 79fc0 (1e:5fc0) ld hl, vChars1 + $7c0 diff --git a/engine/overworld/trainers.asm b/engine/overworld/trainers.asm index b05ddbf13a..5237df0d8d 100755 --- a/engine/overworld/trainers.asm +++ b/engine/overworld/trainers.asm @@ -1,9 +1,9 @@ -Func_567f9: ; 567f9 (15:67f9) +_GetSpritePosition1: ; 567f9 (15:67f9) ld hl, wSpriteStateData1 ld de, $4 ld a, [wcf13] - ld [H_DOWNARROWBLINKCNT2], a ; $ff8c - call Func_56903 + ld [H_SPRITEINDEX], a + call GetSpriteDataPointer ld a, [hli] ld [$ffeb], a inc hl @@ -17,50 +17,50 @@ Func_567f9: ; 567f9 (15:67f9) ld [$ffee], a ret -Func_56819: ; 56819 (15:6819) +_GetSpritePosition2: ; 56819 (15:6819) ld hl, wSpriteStateData1 - ld de, $0004 + ld de, $4 ld a, [wcf13] - ld [H_DOWNARROWBLINKCNT2], a ; $ff8c - call Func_56903 - ld a, [hli] + ld [H_SPRITEINDEX], a + call GetSpriteDataPointer + ld a, [hli] ; c1x4 (screen Y pos) ld [wd130], a inc hl - ld a, [hl] + ld a, [hl] ; c1x6 (screen X pos) ld [wd131], a - ld de, $00fe + ld de, $104 - $6 add hl, de - ld a, [hli] + ld a, [hli] ; c2x4 (map Y pos) ld [wd132], a - ld a, [hl] + ld a, [hl] ; c2x5 (map X pos) ld [wd133], a ret -Func_5683d: ; 5683d (15:683d) +_SetSpritePosition1: ; 5683d (15:683d) ld hl, wSpriteStateData1 ld de, $4 ld a, [wcf13] - ld [H_DOWNARROWBLINKCNT2], a ; $ff8c - call Func_56903 - ld a, [$ffeb] + ld [H_SPRITEINDEX], a + call GetSpriteDataPointer + ld a, [$ffeb] ; c1x4 (screen Y pos) ld [hli], a inc hl - ld a, [$ffec] + ld a, [$ffec] ; c1x6 (screen X pos) ld [hl], a - ld de, $fe + ld de, $104 - $6 add hl, de - ld a, [$ffed] + ld a, [$ffed] ; c2x4 (map Y pos) ld [hli], a - ld a, [$ffee] + ld a, [$ffee] ; c2x5 (map X pos) ld [hl], a ret -Func_5685d: ; 5685d (15:685d) +_SetSpritePosition2: ; 5685d (15:685d) ld hl, wSpriteStateData1 ld de, $0004 ld a, [wcf13] - ld [H_DOWNARROWBLINKCNT2], a ; $ff8c - call Func_56903 + ld [H_SPRITEINDEX], a + call GetSpriteDataPointer ld a, [wd130] ld [hli], a inc hl @@ -139,18 +139,20 @@ TrainerWalkUpToPlayer: ; 56881 (15:6881) ld b, $0 ld a, $80 ; a = direction to go to .writeWalkScript - ld hl, wcc97 - ld de, wcc97 + ld hl, wNPCMovementDirections2 + ld de, wNPCMovementDirections2 call FillMemory ; write the necessary steps to reach player ld [hl], $ff ; write end of list sentinel ld a, [wcf13] - ld [H_DOWNARROWBLINKCNT2], a ; $ff8c + ld [H_SPRITEINDEX], a jp MoveSprite_ -Func_56903: ; 56903 (15:6903) +; input: de = offset within sprite entry +; output: de = pointer to sprite data +GetSpriteDataPointer: ; 56903 (15:6903) push de add hl, de - ld a, [H_DOWNARROWBLINKCNT2] ; $ff8c + ld a, [H_SPRITEINDEX] swap a ld d, $0 ld e, a diff --git a/engine/predefs.asm b/engine/predefs.asm index 669d77f42d..c492a20605 100755 --- a/engine/predefs.asm +++ b/engine/predefs.asm @@ -84,10 +84,10 @@ PredefPointers:: ; 4fe79 (13:7e79) dbw $03,Func_3eb5 ; for these two, the bank number is actually 0 dbw $03,GiveItem add_predef Func_480eb - add_predef Func_f8ba + add_predef FindPathToPlayer add_predef Func_480ff - add_predef Func_f929 - add_predef Func_f9a0 + add_predef CalcPositionOfPlayerRelativeToNPC + add_predef ConvertNPCMovementDirectionsToJoypadMasks add_predef Func_48125 add_predef UpdateHPBar add_predef HPBarLength diff --git a/engine/slot_machine.asm b/engine/slot_machine.asm index e43cc9ab24..ed6f52fb43 100755 --- a/engine/slot_machine.asm +++ b/engine/slot_machine.asm @@ -42,7 +42,7 @@ PromptUserToPlaySlots: ; 3730e (d:730e) ld a, $1 ld [wcfcb], a call GoPAL_SET_CF1C - call Func_3e08 + call ReloadMapSpriteTilePatterns call ReloadTilesetTilePatterns .skip call LoadScreenTilesFromBuffer2 diff --git a/engine/turn_sprite.asm b/engine/turn_sprite.asm index ecd8cf0295..84037cfe43 100755 --- a/engine/turn_sprite.asm +++ b/engine/turn_sprite.asm @@ -1,25 +1,25 @@ -Func_13074: ; 13074 (4:7074) +UpdateSpriteFacingOffsetAndDelayMovement: ; 13074 (4:7074) ld h, $c2 ld a, [H_CURRENTSPRITEOFFSET] add $8 ld l, a - ld a, $7f - ld [hl], a + ld a, $7f ; maximum movement delay + ld [hl], a ; c2x8 (movement delay) dec h ld a, [H_CURRENTSPRITEOFFSET] add $9 ld l, a - ld a, [hld] + ld a, [hld] ; c1x9 (facing direction) ld b, a xor a ld [hld], a - ld [hl], a + ld [hl], a ; c1x8 (walk animation frame) ld a, [H_CURRENTSPRITEOFFSET] add $2 ld l, a - ld a, [hl] - or b + ld a, [hl] ; c1x2 (facing and animation table offset) + or b ; or in the facing direction ld [hld], a - ld a, $2 - ld [hl], a + ld a, $2 ; delayed movement status + ld [hl], a ; c1x1 (movement status) ret diff --git a/home.asm b/home.asm index 870fb99a12..735d087d58 100644 --- a/home.asm +++ b/home.asm @@ -256,6 +256,7 @@ LoadMonData:: ; 1372 (0:1372) jp Bankswitch ; writes c to wd0dc+b +; XXX unused? Func_137a:: ; 137a (0:137a) ld hl, wd0dc ld e, b @@ -538,6 +539,7 @@ PrintLevelCommon:: ; 1523 (0:1523) ld b,$41 ; no leading zeroes, left-aligned, one byte jp PrintNumber +; XXX unused? Func_152e:: ; 152e (0:152e) ld hl,wd0dc ld c,a @@ -1627,7 +1629,7 @@ DisplayTextID:: ; 2920 (0:2920) push hl push de push bc - callba Func_13074 ; update the graphics of the sprite the player is talking to (to face the right direction) + callba UpdateSpriteFacingOffsetAndDelayMovement ; update the graphics of the sprite the player is talking to (to face the right direction) pop bc pop de ld hl,W_MAPSPRITEDATA ; NPC text entries @@ -2686,7 +2688,7 @@ DisplayTextBoxID:: ; 30e8 (0:30e8) ret Func_30fd:: ; 30fd (0:30fd) - ld a, [wcc57] + ld a, [wNPCMovementScriptPointerTableNum] and a ret nz ld a, [wd736] @@ -2696,46 +2698,46 @@ Func_30fd:: ; 30fd (0:30fd) and $80 ret -Func_310e:: ; 310e (0:310e) +RunNPCMovementScript:: ; 310e (0:310e) ld hl, wd736 bit 0, [hl] res 0, [hl] - jr nz, .asm_3146 - ld a, [wcc57] + jr nz, .playerStepOutFromDoor + ld a, [wNPCMovementScriptPointerTableNum] and a ret z dec a add a - ld d, $0 + ld d, 0 ld e, a - ld hl, .pointerTable_3140 + ld hl, .NPCMovementScriptPointerTables add hl, de ld a, [hli] ld h, [hl] ld l, a ld a, [H_LOADEDROMBANK] push af - ld a, [wcc58] + ld a, [wNPCMovementScriptBank] ld [H_LOADEDROMBANK], a ld [$2000], a - ld a, [wcf10] + ld a, [wNPCMovementScriptFunctionNum] call CallFunctionInTable pop af ld [H_LOADEDROMBANK], a ld [$2000], a ret -.pointerTable_3140 - dw PointerTable_1a442 - dw PointerTable_1a510 - dw PointerTable_1a57d -.asm_3146 - ld b, BANK(Func_1a3e0) - ld hl, Func_1a3e0 +.NPCMovementScriptPointerTables + dw ProfOakMovementScriptPointerTable + dw PewterMuseumGuyMovementScriptPointerTable + dw PewterGymGuyMovementScriptPointerTable +.playerStepOutFromDoor + ld b, BANK(PlayerStepOutFromDoor) + ld hl, PlayerStepOutFromDoor jp Bankswitch -Func_314e:: ; 314e (0:314e) - ld b, BANK(Func_1a41d) - ld hl, Func_1a41d +EndNPCMovementScript:: ; 314e (0:314e) + ld b, BANK(_EndNPCMovementScript) + ld hl, _EndNPCMovementScript jp Bankswitch Func_3156:: ; 3156 (0:3156) @@ -2978,22 +2980,22 @@ InitBattleEnemyParameters:: ; 32d7 (0:32d7) ld [W_CURENEMYLVL], a ; W_CURENEMYLVL ret -Func_32ef:: ; 32ef (0:32ef) - ld hl, Func_567f9 +GetSpritePosition1:: ; 32ef (0:32ef) + ld hl, _GetSpritePosition1 jr asm_3301 -Func_32f4:: ; 32f4 (0:32f4) - ld hl, Func_56819 +GetSpritePosition2:: ; 32f4 (0:32f4) + ld hl, _GetSpritePosition2 jr asm_3301 ; 0x32f7 $8 -Func_32f9:: ; 32f9 (0:32f9) - ld hl, Func_5683d +SetSpritePosition1:: ; 32f9 (0:32f9) + ld hl, _SetSpritePosition1 jr asm_3301 -Func_32fe:: ; 32fe (0:32fe) - ld hl, Func_5685d +SetSpritePosition2:: ; 32fe (0:32fe) + ld hl, _SetSpritePosition2 asm_3301:: ; 3301 (0:3301) - ld b, BANK(Func_567f9) ; BANK(Func_56819), BANK(Func_5683d), BANK(Func_5685d) + ld b, BANK(_GetSpritePosition1) ; BANK(_GetSpritePosition2), BANK(_SetSpritePosition1), BANK(_SetSpritePosition2) jp Bankswitch ; indirect jump to one of the four functions CheckForEngagingTrainers:: ; 3306 (0:3306) @@ -3187,10 +3189,10 @@ Func_3442:: ; 3442 (0:3442) ld a, [hli] ld d, [hl] ld e, a - ld hl, wccd3 + ld hl, wSimulatedJoypadStatesEnd call DecodeRLEList dec a - ld [wcd38], a + ld [wSimulatedJoypadStatesIndex], a ret .asm_345b inc hl @@ -3225,10 +3227,10 @@ FuncTX_PokemonCenterPC:: ; 347f (0:347f) ld hl, ActivatePC jr bankswitchAndContinue -Func_3486:: ; 3486 (0:3486) +StartSimulatingJoypadStates:: ; 3486 (0:3486) xor a - ld [wcd3b], a - ld [wSpriteStateData2 + $06], a + ld [wOverrideSimulatedJoypadStatesMask], a + ld [wSpriteStateData2 + $06], a ; player's sprite movement byte 1 ld hl, wd730 set 7, [hl] ret @@ -3249,21 +3251,21 @@ DisplayPokedex:: ; 349b (0:349b) ld hl, Func_7c18 jp Bankswitch -Func_34a6:: ; 34a6 (0:34a6) - call Func_34ae +SetSpriteFacingDirectionAndDelay:: ; 34a6 (0:34a6) + call SetSpriteFacingDirection ld c, $6 jp DelayFrames -Func_34ae:: ; 34ae (0:34ae) +SetSpriteFacingDirection:: ; 34ae (0:34ae) ld a, $9 - ld [H_DOWNARROWBLINKCNT1], a ; $ff8b - call Func_34fc + ld [H_SPRITEDATAOFFSET], a + call GetPointerWithinSpriteStateData1 ld a, [$ff8d] ld [hl], a ret -Func_34b9:: ; 34b9 (0:34b9) - ld de, $fff9 +SetSpriteImageIndexAfterSettingFacingDirection:: ; 34b9 (0:34b9) + ld de, -7 add hl, de ld [hl], a ret @@ -3332,16 +3334,17 @@ CheckBoulderCoords:: ; 34e4 (0:34e4) pop hl jp CheckCoords -Func_34fc:: ; 34fc (0:34fc) +GetPointerWithinSpriteStateData1:: ; 34fc (0:34fc) ld h, $c1 - jr asm_3502 + jr _GetPointerWithinSpriteStateData -Func_3500:: ; 3500 (0:3500) +GetPointerWithinSpriteStateData2:: ; 3500 (0:3500) ld h, $c2 -asm_3502:: ; 3502 (0:3502) - ld a, [H_DOWNARROWBLINKCNT1] ; $ff8b + +_GetPointerWithinSpriteStateData: + ld a, [H_SPRITEDATAOFFSET] ld b, a - ld a, [H_DOWNARROWBLINKCNT2] ; $ff8c + ld a, [H_SPRITEINDEX] swap a add b ld l, a @@ -3402,7 +3405,7 @@ SetSpriteMovementBytesToFF:: ; 3541 (0:3541) ; returns the sprite movement byte 1 pointer for sprite [$FF8C] in hl GetSpriteMovementByte1Pointer:: ; 354e (0:354e) ld h,$C2 - ld a,[$FF8C] ; the sprite to move + ld a,[H_SPRITEINDEX] ; the sprite to move swap a add a,6 ld l,a @@ -3591,30 +3594,31 @@ MoveSprite_:: ; 363d (0:363d) set 0,[hl] pop hl xor a - ld [wcd3b],a - ld [wccd3],a + ld [wOverrideSimulatedJoypadStatesMask],a + ld [wSimulatedJoypadStatesEnd],a dec a ld [wJoyIgnore],a - ld [wcd3a],a + ld [wWastedByteCD3A],a ret -Func_366b:: ; 366b (0:366b) +; divides [$ffe5] by [$ffe6] and stores the quotient in [$ffe7] +DivideBytes:: ; 366b (0:366b) push hl ld hl, $ffe7 xor a ld [hld], a ld a, [hld] and a - jr z, .asm_367e + jr z, .done ld a, [hli] -.asm_3676 +.loop sub [hl] - jr c, .asm_367e + jr c, .done inc hl inc [hl] dec hl - jr .asm_3676 -.asm_367e + jr .loop +.done pop hl ret @@ -5008,11 +5012,11 @@ IsInRestOfArray:: ret -Func_3dbe:: ; 3dbe (0:3dbe) +RestoreScreenTilesAndReloadTilePatterns:: ; 3dbe (0:3dbe) call ClearSprites ld a, $1 ld [wcfcb], a - call Func_3e08 + call ReloadMapSpriteTilePatterns call LoadScreenTilesFromBuffer2 call LoadTextBoxTilePatterns call GoPAL_SET_CF1C @@ -5068,14 +5072,16 @@ GetHealthBarColor:: ld [hl], d ret -Func_3e08:: ; 3e08 (0:3e08) +; Copy the current map's sprites' tile patterns to VRAM again after they have +; been overwritten by other tile patterns. +ReloadMapSpriteTilePatterns:: ; 3e08 (0:3e08) ld hl, wcfc4 ld a, [hl] push af res 0, [hl] push hl xor a - ld [W_SPRITESETID], a ; W_SPRITESETID + ld [W_SPRITESETID], a call DisableLCD callba InitMapSprites call EnableLCD diff --git a/home/audio.asm b/home/audio.asm index fa62cc8a8f..8dcc0d93c1 100644 --- a/home/audio.asm +++ b/home/audio.asm @@ -1,4 +1,4 @@ -Func_2307:: ; 2307 (0:2307) +PlayDefaultMusic:: ; 2307 (0:2307) call WaitForSoundToFinish xor a ld c, a diff --git a/home/overworld.asm b/home/overworld.asm index 91f46dc0b0..a8747f2d9c 100644 --- a/home/overworld.asm +++ b/home/overworld.asm @@ -362,7 +362,7 @@ NewBattle:: ; 0683 (0:0683) ; function to make bikes twice as fast as walking BikeSpeedup:: ; 06a0 (0:06a0) - ld a,[wcc57] + ld a,[wNPCMovementScriptPointerTableNum] and a ret nz ld a,[W_CURMAP] @@ -520,7 +520,7 @@ WarpFound2:: ; 073c (0:073c) ld [wd35d],a .done ld hl,wd736 - set 0,[hl] + set 0,[hl] ; have the player's sprite step out from the door (if there is one) call Func_12da jp EnterMap @@ -1203,9 +1203,9 @@ CollisionCheckOnLand:: ; 0bd1 (0:0bd1) bit 6,a ; is the player jumping? jr nz,.noCollision ; if not jumping a ledge - ld a,[wcd38] + ld a,[wSimulatedJoypadStatesIndex] and a - jr nz,.noCollision + jr nz,.noCollision ; no collisions when the player's movements are being controlled by the game ld a,[wd52a] ; the direction that the player is trying to go in ld d,a ld a,[wSpriteStateData1 + 12] ; the player sprite's collision data (bit field) (set in the sprite movement code) @@ -1835,28 +1835,27 @@ JoypadOverworld:: ; 0f4d (0:0f4d) ld a,[W_CURMAP] cp a,ROUTE_17 ; Cycling Road jr nz,.notForcedDownwards - ld a,[hJoyHeld] ; current joypad state - and a,%11110011 ; bit mask for all directions and A/B + ld a,[hJoyHeld] + and a,D_DOWN | D_UP | D_LEFT | D_RIGHT | B_BUTTON | A_BUTTON jr nz,.notForcedDownwards - ld a,%10000000 ; down pressed + ld a,D_DOWN ld [hJoyHeld],a ; on the cycling road, if there isn't a trainer and the player isn't pressing buttons, simulate a down press .notForcedDownwards ld a,[wd730] bit 7,a ret z ; if simulating button presses - ld a,[hJoyHeld] ; current joypad state + ld a,[hJoyHeld] ld b,a - ld a,[wcd3b] ; bit mask for button presses that override simulated ones + ld a,[wOverrideSimulatedJoypadStatesMask] ; bit mask for button presses that override simulated ones and b ret nz ; return if the simulated button presses are overridden - ld hl,wcd38 ; index of current simulated button press + ld hl,wSimulatedJoypadStatesIndex dec [hl] ld a,[hl] cp a,$ff jr z,.doneSimulating ; if the end of the simulated button presses has been reached - ld hl,wccd3 ; base address of simulated button presses -; add offset to base address + ld hl,wSimulatedJoypadStatesEnd add l ld l,a jr nc,.noCarry @@ -1872,9 +1871,9 @@ JoypadOverworld:: ; 0f4d (0:0f4d) ; if done simulating button presses .doneSimulating xor a - ld [wcd3a],a - ld [wcd38],a - ld [wccd3],a + ld [wWastedByteCD3A],a + ld [wSimulatedJoypadStatesIndex],a + ld [wSimulatedJoypadStatesEnd],a ld [wJoyIgnore],a ld [hJoyHeld],a ld hl,wd736 @@ -1944,7 +1943,7 @@ CollisionCheckOnWater:: ; 0fb7 (0:0fb7) xor a ld [wd700],a call LoadPlayerSpriteGraphics - call Func_2307 + call PlayDefaultMusic jr .noCollision .checkIfVermilionDockTileset ld a, [W_CURMAPTILESET] ; tileset @@ -1957,16 +1956,16 @@ RunMapScript:: ; 101b (0:101b) push hl push de push bc - callba Func_f225 ; check if the player is pushing a boulder + callba TryPushingBoulder ld a,[wFlags_0xcd60] - bit 1,a ; is the player pushing a boulder? + bit 1,a ; play boulder dust animation jr z,.afterBoulderEffect - callba Func_f2b5 ; displays dust effect when pushing a boulder + callba DoBoulderDustAnimation .afterBoulderEffect pop bc pop de pop hl - call Func_310e + call RunNPCMovementScript ld a,[W_CURMAP] ; current map number call SwitchToMapRomBank ; change to the ROM bank the map's data is in ld hl,W_MAPSCRIPTPTR @@ -2400,4 +2399,4 @@ ForceBikeOrSurf:: ; 12ed (0:12ed) ld b, BANK(RedSprite) ld hl, LoadPlayerSpriteGraphics call Bankswitch - jp Func_2307 ; update map/player state? + jp PlayDefaultMusic ; update map/player state? diff --git a/hram.asm b/hram.asm index 1297480aee..551ec67daa 100644 --- a/hram.asm +++ b/hram.asm @@ -14,6 +14,9 @@ hSoftReset EQU $FF8A H_DOWNARROWBLINKCNT1 EQU $FF8B H_DOWNARROWBLINKCNT2 EQU $FF8C +H_SPRITEDATAOFFSET EQU $FF8B +H_SPRITEINDEX EQU $FF8C + ; Note: the following multiplication and division addresses are used for multiple purposes ; and so they overlap with each other diff --git a/main.asm b/main.asm index d9ed7bf7a2..a64d92b75b 100755 --- a/main.asm +++ b/main.asm @@ -26,9 +26,9 @@ Func_40b0:: ld [wd700], a ld [W_ISINBATTLE], a ld [wd35d], a - ld [wcf10], a + ld [wNPCMovementScriptFunctionNum], a ld [hJoyHeld], a - ld [wcc57], a + ld [wNPCMovementScriptPointerTableNum], a ld [wFlags_0xcd60], a ld [$ff9f], a @@ -213,7 +213,7 @@ UpdateNonPlayerSprite: dec a swap a ld [$ff93], a ; $10 * sprite# - ld a, [wcf17] ; some sprite offset? + ld a, [wNPCMovementScriptSpriteOffset] ; some sprite offset? ld b, a ld a, [H_CURRENTSPRITEOFFSET] cp b @@ -2247,7 +2247,7 @@ Func_c49d: ; c49d (3:449d) push hl push de push bc - callba HandleDoors + callba IsPlayerStandingOnDoor jr c, .asm_c4c8 ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET add a @@ -3388,70 +3388,71 @@ MissableObjectFlagAction: ld c, a ret -Func_f225: ; f225 (3:7225) +TryPushingBoulder: ; f225 (3:7225) ld a, [wd728] - bit 0, a + bit 0, a ; using Strength? ret z ld a, [wFlags_0xcd60] - bit 1, a + bit 1, a ; has boulder dust animation from previous push played yet? ret nz xor a - ld [H_DOWNARROWBLINKCNT2], a ; $ff8c + ld [$ff8c], a call IsSpriteInFrontOfPlayer - ld a, [H_DOWNARROWBLINKCNT2] ; $ff8c + ld a, [$ff8c] ld [wd718], a and a - jp z, Func_f2dd + jp z, ResetBoulderPushFlags ld hl, wSpriteStateData1 + 1 ld d, $0 - ld a, [H_DOWNARROWBLINKCNT2] ; $ff8c + ld a, [$ff8c] swap a ld e, a add hl, de res 7, [hl] call GetSpriteMovementByte2Pointer ld a, [hl] - cp $10 - jp nz, Func_f2dd + cp BOULDER_MOVEMENT_BYTE_2 + jp nz, ResetBoulderPushFlags ld hl, wFlags_0xcd60 bit 6, [hl] - set 6, [hl] - ret z + set 6, [hl] ; indicate that the player has tried pushing + ret z ; the player must try pushing twice before the boulder will move ld a, [hJoyHeld] and $f0 ret z predef Func_c60b ld a, [wd71c] and a - jp nz, Func_f2dd + jp nz, ResetBoulderPushFlags ld a, [hJoyHeld] ld b, a - ld a, [wSpriteStateData1 + 9] - cp $4 - jr z, .asm_f289 - cp $8 - jr z, .asm_f291 - cp $c - jr z, .asm_f299 + ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction + cp SPRITE_FACING_UP + jr z, .pushBoulderUp + cp SPRITE_FACING_LEFT + jr z, .pushBoulderLeft + cp SPRITE_FACING_RIGHT + jr z, .pushBoulderRight +.pushBoulderDown bit 7, b ret z - ld de, MovementData_f2af - jr .asm_f29f -.asm_f289 + ld de, PushBoulderDownMovementData + jr .done +.pushBoulderUp bit 6, b ret z - ld de, MovementData_f2ad - jr .asm_f29f -.asm_f291 + ld de, PushBoulderUpMovementData + jr .done +.pushBoulderLeft bit 5, b ret z - ld de, MovementData_f2b1 - jr .asm_f29f -.asm_f299 + ld de, PushBoulderLeftMovementData + jr .done +.pushBoulderRight bit 4, b ret z - ld de, MovementData_f2b3 -.asm_f29f + ld de, PushBoulderRightMovementData +.done call MoveSprite ld a, (SFX_02_53 - SFX_Headers_02) / 3 call PlaySound @@ -3459,26 +3460,26 @@ Func_f225: ; f225 (3:7225) set 1, [hl] ret -MovementData_f2ad: ; f2ad (3:72ad) - db $40,$FF +PushBoulderUpMovementData: ; f2ad (3:72ad) + db NPC_MOVEMENT_UP,$FF -MovementData_f2af: ; f2af (3:72af) - db $00,$FF +PushBoulderDownMovementData: ; f2af (3:72af) + db NPC_MOVEMENT_DOWN,$FF -MovementData_f2b1: ; f2b1 (3:72b1) - db $80,$FF +PushBoulderLeftMovementData: ; f2b1 (3:72b1) + db NPC_MOVEMENT_LEFT,$FF -MovementData_f2b3: ; f2b3 (3:72b3) - db $C0,$FF +PushBoulderRightMovementData: ; f2b3 (3:72b3) + db NPC_MOVEMENT_RIGHT,$FF -Func_f2b5: ; f2b5 (3:72b5) +DoBoulderDustAnimation: ; f2b5 (3:72b5) ld a, [wd730] bit 0, a ret nz - callab Func_79f54 + callab AnimateBoulderDust call DiscardButtonPresses ld [wJoyIgnore], a - call Func_f2dd + call ResetBoulderPushFlags set 7, [hl] ld a, [wd718] ld [H_DOWNARROWBLINKCNT2], a ; $ff8c @@ -3487,7 +3488,7 @@ Func_f2b5: ; f2b5 (3:72b5) ld a, (SFX_02_56 - SFX_Headers_02) / 3 jp PlaySound -Func_f2dd: ; f2dd (3:72dd) +ResetBoulderPushFlags: ; f2dd (3:72dd) ld hl, wFlags_0xcd60 res 1, [hl] res 6, [hl] @@ -4460,20 +4461,19 @@ IsItemInBag_: ; f8a5 (3:78a5) ld b, $0 ret -Func_f8ba: ; f8ba (3:78ba) +FindPathToPlayer: ; f8ba (3:78ba) xor a ld hl, $ff97 ld [hli], a ld [hli], a ld [hli], a ld [hl], a - ld hl, wcc97 + ld hl, wNPCMovementDirections2 ld de, $0 - -Func_f8c8: ; f8c8 (3:78c8) - ld a, [H_REMAINDER] ; $ff99 (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) +.loop + ld a, [$ff99] ld b, a - ld a, [H_DIVIDEND] ; $ff95 (aliases: H_PRODUCT, H_PASTLEADINGZEROES, H_QUOTIENT) + ld a, [$ff95] ; Y distance in steps call CalcDifference ld d, a and a @@ -4484,7 +4484,7 @@ Func_f8c8: ; f8c8 (3:78c8) .asm_f8da ld a, [$ff9a] ld b, a - ld a, [H_NUMTOPRINT] ; $ff96 (aliases: H_MULTIPLICAND) + ld a, [$ff96] ; X distance in steps call CalcDifference ld e, a and a @@ -4495,17 +4495,17 @@ Func_f8c8: ; f8c8 (3:78c8) .asm_f8ec ld a, [$ff98] cp $3 - jr z, .asm_f926 + jr z, .done ld a, e cp d jr c, .asm_f90a ld a, [$ff9d] bit 1, a jr nz, .asm_f900 - ld d, $c0 + ld d, NPC_MOVEMENT_RIGHT jr .asm_f902 .asm_f900 - ld d, $80 + ld d, NPC_MOVEMENT_LEFT .asm_f902 ld a, [$ff9a] add $1 @@ -4515,91 +4515,93 @@ Func_f8c8: ; f8c8 (3:78c8) ld a, [$ff9d] bit 0, a jr nz, .asm_f914 - ld d, $0 + ld d, NPC_MOVEMENT_DOWN jr .asm_f916 .asm_f914 - ld d, $40 + ld d, NPC_MOVEMENT_UP .asm_f916 - ld a, [H_REMAINDER] ; $ff99 (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) + ld a, [$ff99] add $1 - ld [H_REMAINDER], a ; $ff99 (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) + ld [$ff99], a .asm_f91c ld a, d ld [hli], a ld a, [$ff97] inc a ld [$ff97], a - jp Func_f8c8 -.asm_f926 + jp .loop +.done ld [hl], $ff ret -Func_f929: ; f929 (3:7929) +CalcPositionOfPlayerRelativeToNPC: ; f929 (3:7929) xor a ld [$ff9d], a - ld a, [wSpriteStateData1 + 4] + ld a, [wSpriteStateData1 + 4] ; player's sprite screen Y position in pixels ld d, a - ld a, [wSpriteStateData1 + 6] + ld a, [wSpriteStateData1 + 6] ; player's sprite screen X position in pixels ld e, a ld hl, wSpriteStateData1 - ld a, [H_DIVIDEND] ; $ff95 (aliases: H_PRODUCT, H_PASTLEADINGZEROES, H_QUOTIENT) + ld a, [$ff95] ; sprite offset add l add $4 ld l, a - jr nc, .asm_f940 + jr nc, .noCarry inc h -.asm_f940 +.noCarry ld a, d ld b, a - ld a, [hli] + ld a, [hli] ; NPC sprite screen Y position in pixels call CalcDifference - jr nc, .asm_f953 + jr nc, .NPCSouthOfOrAlignedWithPlayer +.NPCNorthOfPlayer push hl ld hl, $ff9d bit 0, [hl] set 0, [hl] pop hl - jr .asm_f95c -.asm_f953 + jr .divideYDistance +.NPCSouthOfOrAlignedWithPlayer push hl ld hl, $ff9d bit 0, [hl] res 0, [hl] pop hl -.asm_f95c +.divideYDistance push hl ld hl, $ffe5 ld [hli], a - ld a, $10 + ld a, 16 ld [hli], a - call Func_366b - ld a, [hl] - ld [H_DIVIDEND], a ; $ff95 (aliases: H_PRODUCT, H_PASTLEADINGZEROES, H_QUOTIENT) + call DivideBytes ; divide Y absolute distance by 16 + ld a, [hl] ; quotient + ld [$ff95], a pop hl inc hl ld b, e - ld a, [hl] + ld a, [hl] ; NPC sprite screen X position in pixels call CalcDifference - jr nc, .asm_f97e + jr nc, .NPCEastOfOrAlignedWithPlayer +.NPCWestOfPlayer push hl ld hl, $ff9d bit 1, [hl] set 1, [hl] pop hl - jr .asm_f987 -.asm_f97e + jr .divideXDistance +.NPCEastOfOrAlignedWithPlayer push hl ld hl, $ff9d bit 1, [hl] res 1, [hl] pop hl -.asm_f987 +.divideXDistance ld [$ffe5], a - ld a, $10 + ld a, 16 ld [$ffe6], a - call Func_366b - ld a, [$ffe7] - ld [H_NUMTOPRINT], a ; $ff96 (aliases: H_MULTIPLICAND) + call DivideBytes ; divide X absolute distance by 16 + ld a, [$ffe7] ; quotient + ld [$ff96], a ld a, [$ff9b] and a ret z @@ -4609,47 +4611,51 @@ Func_f929: ; f929 (3:7929) ld [$ff9d], a ret -Func_f9a0: ; f9a0 (3:79a0) +ConvertNPCMovementDirectionsToJoypadMasks: ; f9a0 (3:79a0) ld a, [$ff95] - ld [wcd37], a + ld [wNPCMovementDirections2Index], a dec a - ld de, wccd3 - ld hl, wcc97 + ld de, wSimulatedJoypadStatesEnd + ld hl, wNPCMovementDirections2 add l ld l, a - jr nc, .asm_f9b1 + jr nc, .loop inc h -.asm_f9b1 +.loop ld a, [hld] - call Func_f9bf + call ConvertNPCMovementDirectionToJoypadMask ld [de], a inc de ld a, [$ff95] dec a ld [$ff95], a - jr nz, .asm_f9b1 + jr nz, .loop ret -Func_f9bf: ; f9bf (3:79bf) +ConvertNPCMovementDirectionToJoypadMask: ; f9bf (3:79bf) push hl ld b, a - ld hl, DataTable_f9d2 -.asm_f9c4 + ld hl, NPCMovementDirectionsToJoypadMasksTable +.loop ld a, [hli] cp $ff - jr z, .asm_f9d0 + jr z, .done cp b - jr z, .asm_f9cf + jr z, .loadJoypadMask inc hl - jr .asm_f9c4 -.asm_f9cf + jr .loop +.loadJoypadMask ld a, [hl] -.asm_f9d0 +.done pop hl ret -DataTable_f9d2: ; f9d2 (3:79d2) - db $40, $40, $00, $80, $80, $20, $c0, $10, $ff +NPCMovementDirectionsToJoypadMasksTable: ; f9d2 (3:79d2) + db NPC_MOVEMENT_UP, D_UP + db NPC_MOVEMENT_DOWN, D_DOWN + db NPC_MOVEMENT_LEFT, D_LEFT + db NPC_MOVEMENT_RIGHT, D_RIGHT + db $ff Func_f9db: ; f9db (3:79db) ret diff --git a/scripts/agatha.asm b/scripts/agatha.asm index b31fc4127c..ca7c0ed84e 100755 --- a/scripts/agatha.asm +++ b/scripts/agatha.asm @@ -41,8 +41,8 @@ AgathaScriptPointers: ; 76469 (1d:6469) AgathaScript4: ; 76473 (1d:6473) ret asm_76474: ; 76474 (1d:6474) - ld hl, wccd3 - ld a, $40 + ld hl, wSimulatedJoypadStatesEnd + ld a, D_UP ld [hli], a ld [hli], a ld [hli], a @@ -50,8 +50,8 @@ asm_76474: ; 76474 (1d:6474) ld [hli], a ld [hl], a ld a, $6 - ld [wcd38], a - call Func_3486 + ld [wSimulatedJoypadStatesIndex], a + call StartSimulatingJoypadStates ld a, $3 ld [W_AGATHACURSCRIPT], a ld [W_CURMAPSCRIPT], a @@ -64,8 +64,8 @@ AgathaScript0: ; 76490 (1d:6490) xor a ld [hJoyPressed], a ld [hJoyHeld], a - ld [wccd3], a - ld [wcd38], a + ld [wSimulatedJoypadStatesEnd], a + ld [wSimulatedJoypadStatesIndex], a ld a, [wWhichTrade] ; wWhichTrade cp $3 jr c, .asm_764b4 @@ -77,11 +77,11 @@ AgathaScript0: ; 76490 (1d:6490) ld a, $2 ld [H_DOWNARROWBLINKCNT2], a ; $ff8c call DisplayTextID - ld a, $40 - ld [wccd3], a + ld a, D_UP + ld [wSimulatedJoypadStatesEnd], a ld a, $1 - ld [wcd38], a - call Func_3486 + ld [wSimulatedJoypadStatesIndex], a + call StartSimulatingJoypadStates ld a, $3 ld [W_AGATHACURSCRIPT], a ld [W_CURMAPSCRIPT], a @@ -95,7 +95,7 @@ CoordsData_764d1: ; 764d1 (1d:64d1) db $FF AgathaScript3: ; 764da (1d:64da) - ld a, [wcd38] + ld a, [wSimulatedJoypadStatesIndex] and a ret nz call Delay3 diff --git a/scripts/battlecenterm.asm b/scripts/battlecenterm.asm index b65380d2fa..5ab697a121 100755 --- a/scripts/battlecenterm.asm +++ b/scripts/battlecenterm.asm @@ -9,7 +9,7 @@ BattleCenterMScript: ; 4fd10 (13:7d10) ld [$ff8d], a ld a, $1 ld [$ff8c], a - call Func_34ae + call SetSpriteFacingDirection ld hl, wd72d bit 0, [hl] set 0, [hl] diff --git a/scripts/billshouse.asm b/scripts/billshouse.asm index 3a8a33c0ae..b30a8602a9 100755 --- a/scripts/billshouse.asm +++ b/scripts/billshouse.asm @@ -66,7 +66,7 @@ BillsHouseScript3: ; 1e7c5 (7:67c5) ld [$ffed], a ld a, $5 ld [$ffee], a - call Func_32f9 + call SetSpritePosition1 ld a, $62 ld [wcc4d], a predef ShowObject diff --git a/scripts/bruno.asm b/scripts/bruno.asm index d0382fa4de..553469d0d7 100755 --- a/scripts/bruno.asm +++ b/scripts/bruno.asm @@ -41,8 +41,8 @@ BrunoScriptPointers: ; 76312 (1d:6312) BrunoScript4: ; 7631c (1d:631c) ret asm_7631d: ; 7631d (1d:631d) - ld hl, wccd3 - ld a, $40 + ld hl, wSimulatedJoypadStatesEnd + ld a, D_UP ld [hli], a ld [hli], a ld [hli], a @@ -50,8 +50,8 @@ asm_7631d: ; 7631d (1d:631d) ld [hli], a ld [hl], a ld a, $6 - ld [wcd38], a - call Func_3486 + ld [wSimulatedJoypadStatesIndex], a + call StartSimulatingJoypadStates ld a, $3 ld [W_BRUNOCURSCRIPT], a ld [W_CURMAPSCRIPT], a @@ -64,8 +64,8 @@ BrunoScript0: ; 76339 (1d:6339) xor a ld [hJoyPressed], a ld [hJoyHeld], a - ld [wccd3], a - ld [wcd38], a + ld [wSimulatedJoypadStatesEnd], a + ld [wSimulatedJoypadStatesIndex], a ld a, [wWhichTrade] ; wWhichTrade cp $3 jr c, .asm_7635d @@ -77,11 +77,11 @@ BrunoScript0: ; 76339 (1d:6339) ld a, $2 ld [H_DOWNARROWBLINKCNT2], a ; $ff8c call DisplayTextID - ld a, $40 - ld [wccd3], a + ld a, D_UP + ld [wSimulatedJoypadStatesEnd], a ld a, $1 - ld [wcd38], a - call Func_3486 + ld [wSimulatedJoypadStatesIndex], a + call StartSimulatingJoypadStates ld a, $3 ld [W_BRUNOCURSCRIPT], a ld [W_CURMAPSCRIPT], a @@ -95,7 +95,7 @@ CoordsData_7637a: ; 7637a (1d:637a) db $FF BrunoScript3: ; 76383 (1d:6383) - ld a, [wcd38] + ld a, [wSimulatedJoypadStatesIndex] and a ret nz call Delay3 diff --git a/scripts/ceruleancity.asm b/scripts/ceruleancity.asm index 419dbd8c2c..90ccab679c 100755 --- a/scripts/ceruleancity.asm +++ b/scripts/ceruleancity.asm @@ -85,7 +85,7 @@ CeruleanCityScript0: ; 194c8 (6:54c8) ld [$ff8c], a ld a, $5 ld [$ff8b], a - call Func_3500 + call GetPointerWithinSpriteStateData2 ld [hl], $19 .asm_19535 ld a, $5 @@ -117,7 +117,7 @@ CeruleanCityScript_1955d: ; 1955d (6:555d) ld [$ff8c],a xor a ld [$ff8d],a - jp Func_34a6 ; face object + jp SetSpriteFacingDirectionAndDelay ; face object CeruleanCityScript1: ; 19567 (6:5567) ld a, [wd730] @@ -209,7 +209,7 @@ CeruleanCityScript3: ; 19610 (6:5610) predef HideObject xor a ld [wJoyIgnore], a - call Func_2307 + call PlayDefaultMusic ld a, $0 ld [W_CERULEANCITYCURSCRIPT], a ret diff --git a/scripts/cinnabarisland.asm b/scripts/cinnabarisland.asm index 8d27198b57..33a497c459 100755 --- a/scripts/cinnabarisland.asm +++ b/scripts/cinnabarisland.asm @@ -32,10 +32,10 @@ CinnabarIslandScript0: ; 1ca38 (7:4a38) xor a ld [hJoyHeld], a ld a, $1 - ld [wcd38], a - ld a, $80 - ld [wccd3], a - call Func_3486 + ld [wSimulatedJoypadStatesIndex], a + ld a, D_DOWN + ld [wSimulatedJoypadStatesEnd], a + call StartSimulatingJoypadStates xor a ld [wSpriteStateData1 + 9], a ld [wJoyIgnore], a @@ -44,7 +44,7 @@ CinnabarIslandScript0: ; 1ca38 (7:4a38) ret CinnabarIslandScript1: ; 1ca73 (7:4a73) - ld a, [wcd38] + ld a, [wSimulatedJoypadStatesIndex] and a ret nz call Delay3 diff --git a/scripts/daycarem.asm b/scripts/daycarem.asm index 73ae66364d..55a9f11111 100755 --- a/scripts/daycarem.asm +++ b/scripts/daycarem.asm @@ -30,7 +30,7 @@ DayCareMText1: ; 56254 (15:6254) call DisplayPartyMenu push af call GBPalWhiteOutWithDelay3 - call Func_3dbe + call RestoreScreenTilesAndReloadTilePatterns call LoadGBPal pop af ld hl, DayCareMText_56437 diff --git a/scripts/fightingdojo.asm b/scripts/fightingdojo.asm index 5f244781c4..0fbff74a4b 100755 --- a/scripts/fightingdojo.asm +++ b/scripts/fightingdojo.asm @@ -48,7 +48,7 @@ FightingDojoScript1: ; 5cd83 (17:4d83) ld [$ff8c], a ld a, $8 ld [$ff8d], a - call Func_34a6 + call SetSpriteFacingDirectionAndDelay ld a, $1 ld [$ff8c], a call DisplayTextID @@ -67,7 +67,7 @@ FightingDojoScript3: ; 5cdc6 (17:4dc6) ld [$ff8c], a ld a, $8 ld [$ff8d], a - call Func_34a6 + call SetSpriteFacingDirectionAndDelay .asm_5cde4 ld a, $f0 diff --git a/scripts/gary.asm b/scripts/gary.asm index f909a618d3..b32e35951f 100755 --- a/scripts/gary.asm +++ b/scripts/gary.asm @@ -29,12 +29,12 @@ GaryScript0: ; 75f47 (1d:5f47) GaryScript1: ; 75f48 (1d:5f48) ld a, $ff ld [wJoyIgnore], a - ld hl, wccd3 + ld hl, wSimulatedJoypadStatesEnd ld de, RLEMovement75f63 call DecodeRLEList dec a - ld [wcd38], a - call Func_3486 + ld [wSimulatedJoypadStatesIndex], a + call StartSimulatingJoypadStates ld a, $2 ld [W_GARYCURSCRIPT], a ret @@ -46,7 +46,7 @@ RLEMovement75f63: ; 75f63 (1d:5f63) db $ff GaryScript2: ; 75f6a (1d:5f6a) - ld a, [wcd38] + ld a, [wSimulatedJoypadStatesIndex] and a ret nz call Delay3 @@ -140,12 +140,12 @@ GaryScript5: ; 7601a (1d:601a) ld [$ff8c], a ld a, $8 ld [$ff8d], a - call Func_34a6 + call SetSpriteFacingDirectionAndDelay ld a, $2 ld [$ff8c], a xor a ld [$ff8d], a - call Func_34a6 ; face object + call SetSpriteFacingDirectionAndDelay ; face object ld a, $3 ld [$ff8c], a call GaryScript_760c8 @@ -158,7 +158,7 @@ GaryScript6: ; 76047 (1d:6047) ld [$ff8c], a ld a, $c ld [$ff8d], a - call Func_34a6 ; face object + call SetSpriteFacingDirectionAndDelay ; face object ld a, $4 ld [$ff8c], a call GaryScript_760c8 @@ -171,7 +171,7 @@ GaryScript7: ; 7605f (1d:605f) ld [$ff8c], a xor a ld [$ff8d], a - call Func_34a6 ; face object + call SetSpriteFacingDirectionAndDelay ; face object ld a, $5 ld [$ff8c], a call GaryScript_760c8 @@ -200,12 +200,12 @@ GaryScript8: ; 76083 (1d:6083) GaryScript9: ; 76099 (1d:6099) ld a, $ff ld [wJoyIgnore], a - ld hl, wccd3 + ld hl, wSimulatedJoypadStatesEnd ld de, RLEMovement760b4 call DecodeRLEList dec a - ld [wcd38], a - call Func_3486 + ld [wSimulatedJoypadStatesIndex], a + call StartSimulatingJoypadStates ld a, $a ld [W_GARYCURSCRIPT], a ret @@ -216,7 +216,7 @@ RLEMovement760b4 ; 760b4 (1d:60b4) db $ff GaryScript10: ; 760b9 (1d:60b9) - ld a, [wcd38] + ld a, [wSimulatedJoypadStatesIndex] and a ret nz xor a diff --git a/scripts/halloffameroom.asm b/scripts/halloffameroom.asm index 1273305e2d..fb5cad3a9e 100755 --- a/scripts/halloffameroom.asm +++ b/scripts/halloffameroom.asm @@ -62,12 +62,12 @@ HallofFameRoomScript2: ; 5a4bb (16:64bb) HallofFameRoomScript0: ; 5a50d (16:650d) ld a, $ff ld [wJoyIgnore], a - ld hl, wccd3 + ld hl, wSimulatedJoypadStatesEnd ld de, RLEMovement5a528 call DecodeRLEList dec a - ld [wcd38], a - call Func_3486 + ld [wSimulatedJoypadStatesIndex], a + call StartSimulatingJoypadStates ld a, $1 ld [W_HALLOFFAMEROOMCURSCRIPT], a ret @@ -77,7 +77,7 @@ RLEMovement5a528: ; 5a528 (16:6528) db $ff HallofFameRoomScript1: ; 5a52b (16:652b) - ld a, [wcd38] + ld a, [wSimulatedJoypadStatesIndex] and a ret nz ld a, $1 @@ -87,7 +87,7 @@ HallofFameRoomScript1: ; 5a52b (16:652b) call SetSpriteMovementBytesToFF ld a, $8 ld [$ff8d], a - call Func_34a6 + call SetSpriteFacingDirectionAndDelay call Delay3 xor a ld [wJoyIgnore], a diff --git a/scripts/lance.asm b/scripts/lance.asm index 9029504249..d5ca4e5cc7 100755 --- a/scripts/lance.asm +++ b/scripts/lance.asm @@ -99,12 +99,12 @@ LanceScript2: ; 5a349 (16:6349) LanceScript_5a35b: ; 5a35b (16:635b) ld a, $ff ld [wJoyIgnore], a - ld hl, wccd3 + ld hl, wSimulatedJoypadStatesEnd ld de, RLEList_5a379 call DecodeRLEList dec a - ld [wcd38], a - call Func_3486 + ld [wSimulatedJoypadStatesIndex], a + call StartSimulatingJoypadStates ld a, $3 ld [W_LANCECURSCRIPT], a ld [W_CURMAPSCRIPT], a @@ -118,7 +118,7 @@ RLEList_5a379: ; 5a379 (16:6379) db $FF LanceScript3: ; 5a382 (16:6382) - ld a, [wcd38] + ld a, [wSimulatedJoypadStatesIndex] and a ret nz call Delay3 diff --git a/scripts/lorelei.asm b/scripts/lorelei.asm index 670b6b66b9..33f419a3cf 100755 --- a/scripts/lorelei.asm +++ b/scripts/lorelei.asm @@ -42,8 +42,8 @@ LoreleiScriptPointers: ; 761bb (1d:61bb) LoreleiScript4: ; 761c5 (1d:61c5) ret asm_761c6: ; 761c6 (1d:61c6) - ld hl, wccd3 - ld a, $40 + ld hl, wSimulatedJoypadStatesEnd + ld a, D_UP ld [hli], a ld [hli], a ld [hli], a @@ -51,8 +51,8 @@ asm_761c6: ; 761c6 (1d:61c6) ld [hli], a ld [hl], a ld a, $6 - ld [wcd38], a - call Func_3486 + ld [wSimulatedJoypadStatesIndex], a + call StartSimulatingJoypadStates ld a, $3 ld [W_LORELEICURSCRIPT], a ld [W_CURMAPSCRIPT], a @@ -64,8 +64,8 @@ LoreleiScript0: ; 761e2 (1d:61e2) xor a ld [hJoyPressed], a ld [hJoyHeld], a - ld [wccd3], a - ld [wcd38], a + ld [wSimulatedJoypadStatesEnd], a + ld [wSimulatedJoypadStatesIndex], a ld a, [wWhichTrade] ; wWhichTrade cp $3 jr c, .asm_76206 @@ -77,11 +77,11 @@ LoreleiScript0: ; 761e2 (1d:61e2) ld a, $2 ld [H_DOWNARROWBLINKCNT2], a ; $ff8c call DisplayTextID - ld a, $40 - ld [wccd3], a + ld a, D_UP + ld [wSimulatedJoypadStatesEnd], a ld a, $1 - ld [wcd38], a - call Func_3486 + ld [wSimulatedJoypadStatesIndex], a + call StartSimulatingJoypadStates ld a, $3 ld [W_LORELEICURSCRIPT], a ld [W_CURMAPSCRIPT], a @@ -95,7 +95,7 @@ CoordsData_76223: ; 76223 (1d:6223) db $FF LoreleiScript3: ; 7622c (1d:622c) - ld a, [wcd38] + ld a, [wSimulatedJoypadStatesIndex] and a ret nz call Delay3 diff --git a/scripts/museum1f.asm b/scripts/museum1f.asm index e593cf397c..10dc9f4285 100755 --- a/scripts/museum1f.asm +++ b/scripts/museum1f.asm @@ -115,10 +115,10 @@ Museum1FText1: ; 5c135 (17:4135) ld hl, Museum1FText_5c21a ; $421a call PrintText ld a, $1 - ld [wcd38], a + ld [wSimulatedJoypadStatesIndex], a ld a, $80 - ld [wccd3], a - call Func_3486 + ld [wSimulatedJoypadStatesEnd], a + call StartSimulatingJoypadStates call UpdateSprites jr asm_d1145 .asm_0b094 diff --git a/scripts/namerater.asm b/scripts/namerater.asm index 28d53b1e62..2295944fe7 100755 --- a/scripts/namerater.asm +++ b/scripts/namerater.asm @@ -55,7 +55,7 @@ NameRaterText1: ; 1da56 (7:5a56) call DisplayPartyMenu push af call GBPalWhiteOutWithDelay3 - call Func_3dbe + call RestoreScreenTilesAndReloadTilePatterns call LoadGBPal pop af jr c, .asm_1daae ; 0x1da80 $2c diff --git a/scripts/oakslab.asm b/scripts/oakslab.asm index fb56aade3f..faf86f1a4c 100755 --- a/scripts/oakslab.asm +++ b/scripts/oakslab.asm @@ -35,7 +35,7 @@ OaksLabScript0: ; 1cb4e (7:4b4e) ld a, [wd74b] bit 7, a ret z - ld a, [wcf10] + ld a, [wNPCMovementScriptFunctionNum] and a ret nz ld a, $31 @@ -50,7 +50,7 @@ OaksLabScript0: ; 1cb4e (7:4b4e) OaksLabScript1: ; 1cb6e (7:4b6e) ld a, $8 - ld [$ff8c], a + ld [H_SPRITEINDEX], a ld de, OakEntryMovement call MoveSprite @@ -78,22 +78,22 @@ OaksLabScript2: ; 1cb82 (7:4b82) OaksLabScript3: ; 1cba2 (7:4ba2) call Delay3 - ld hl, wccd3 + ld hl, wSimulatedJoypadStatesEnd ld de, PlayerEntryMovementRLE call DecodeRLEList dec a - ld [wcd38], a - call Func_3486 + ld [wSimulatedJoypadStatesIndex], a + call StartSimulatingJoypadStates ld a, $1 - ld [$ff8c], a + ld [H_SPRITEINDEX], a xor a ld [$ff8d], a - call Func_34a6 ; face object + call SetSpriteFacingDirectionAndDelay ld a, $5 - ld [$ff8c], a + ld [H_SPRITEINDEX], a xor a ld [$ff8d], a - call Func_34a6 ; face object + call SetSpriteFacingDirectionAndDelay ld a, $4 ld [W_OAKSLABCURSCRIPT], a @@ -103,7 +103,7 @@ PlayerEntryMovementRLE: ; 1cbcf (7:4bcf) db $40, $8, $ff OaksLabScript4: ; 1cbd2 (7:4bd2) - ld a, [wcd38] + ld a, [wSimulatedJoypadStatesIndex] and a ret nz ld hl, wd747 @@ -111,14 +111,14 @@ OaksLabScript4: ; 1cbd2 (7:4bd2) ld hl, wd74b set 0, [hl] ld a, $1 - ld [$ff8c], a + ld [H_SPRITEINDEX], a ld a, $4 ld [$ff8d], a - call Func_34a6 ; face object + call SetSpriteFacingDirectionAndDelay call UpdateSprites ld hl, W_FLAGS_D733 res 1, [hl] - call Func_2307 + call PlayDefaultMusic ld a, $5 ld [W_OAKSLABCURSCRIPT], a @@ -156,24 +156,24 @@ OaksLabScript6: ; 1cc36 (7:4c36) cp $6 ret nz ld a, $5 - ld [$ff8c], a + ld [H_SPRITEINDEX], a xor a ld [$ff8d], a - call Func_34a6 ; face object + call SetSpriteFacingDirectionAndDelay ld a, $1 - ld [$ff8c], a + ld [H_SPRITEINDEX], a xor a ld [$ff8d], a - call Func_34a6 ; face object + call SetSpriteFacingDirectionAndDelay call UpdateSprites ld a, $c ld [$ff8c], a call DisplayTextID ld a, $1 - ld [wcd38], a + ld [wSimulatedJoypadStatesIndex], a ld a, $40 - ld [wccd3], a - call Func_3486 + ld [wSimulatedJoypadStatesEnd], a + call StartSimulatingJoypadStates ld a, $8 ld [wd528], a @@ -182,7 +182,7 @@ OaksLabScript6: ; 1cc36 (7:4c36) ret OaksLabScript7: ; 1cc72 (7:4c72) - ld a, [wcd38] + ld a, [wSimulatedJoypadStatesIndex] and a ret nz call Delay3 @@ -231,10 +231,10 @@ OaksLabScript8: ; 1cc80 (7:4c80) jr nz, .asm_1ccf3 ; 0x1cccd $24 push hl ld a, $1 - ld [$ff8c], a + ld [H_SPRITEINDEX], a ld a, $4 ld [$ff8b], a - call Func_34fc + call GetPointerWithinSpriteStateData1 push hl ld [hl], $4c inc hl @@ -256,7 +256,7 @@ OaksLabScript8: ; 1cc80 (7:4c80) .asm_1ccf3 ld a, $1 - ld [$ff8c], a + ld [H_SPRITEINDEX], a call MoveSprite ld a, $9 @@ -270,10 +270,10 @@ OaksLabScript9: ; 1cd00 (7:4d00) ld a, $fc ld [wJoyIgnore], a ld a, $1 - ld [$ff8c], a + ld [H_SPRITEINDEX], a ld a, $4 ld [$ff8d], a - call Func_34a6 ; face object + call SetSpriteFacingDirectionAndDelay ld a, $d ld [$ff8c], a call DisplayTextID @@ -299,10 +299,10 @@ OaksLabScript9: ; 1cd00 (7:4d00) ld [wd11e], a call GetMonName ld a, $1 - ld [$ff8c], a + ld [H_SPRITEINDEX], a ld a, $4 ld [$ff8d], a - call Func_34a6 ; face object + call SetSpriteFacingDirectionAndDelay ld a, $e ld [$ff8c], a call DisplayTextID @@ -320,10 +320,10 @@ OaksLabScript10: ; 1cd6d (7:4d6d) cp $6 ret nz ld a, $1 - ld [$ff8c], a + ld [H_SPRITEINDEX], a xor a ld [$ff8d], a - call Func_34a6 ; face object + call SetSpriteFacingDirectionAndDelay ld a, $8 ld [wd528], a ld c, BANK(Music_MeetRival) @@ -337,14 +337,14 @@ OaksLabScript10: ; 1cd6d (7:4d6d) ld a, $1 swap a ld [$ff95], a - predef Func_f929 + predef CalcPositionOfPlayerRelativeToNPC ld a, [$ff95] dec a ld [$ff95], a - predef Func_f8ba - ld de, wcc97 + predef FindPathToPlayer + ld de, wNPCMovementDirections2 ld a, $1 - ld [$ff8c], a + ld [H_SPRITEINDEX], a call MoveSprite ld a, $b @@ -375,7 +375,7 @@ OaksLabScript11: ; 1cdb9 (7:4db9) ld [W_TRAINERNO], a ld a, $1 ld [wcf13], a - call Func_32ef + call GetSpritePosition1 ld hl, OaksLabText_1d3be ld de, OaksLabText_1d3c3 call PreBattleSaveRegisters @@ -398,12 +398,12 @@ OaksLabScript12: ; 1ce03 (7:4e03) call UpdateSprites ld a, $1 ld [wcf13], a - call Func_32f9 + call SetSpritePosition1 ld a, $1 - ld [$ff8c], a + ld [H_SPRITEINDEX], a xor a ld [$ff8d], a - call Func_34a6 ; face object + call SetSpriteFacingDirectionAndDelay predef HealParty ld hl, wd74b set 3, [hl] @@ -420,7 +420,7 @@ OaksLabScript13: ; 1ce32 (7:4e32) call DisplayTextID callba Music_RivalAlternateStart ld a, $1 - ld [$ff8c], a + ld [H_SPRITEINDEX], a ld de, .RivalExitMovement call MoveSprite ld a, [W_XCOORD] @@ -450,7 +450,7 @@ OaksLabScript14: ; 1ce6d (7:4e6d) predef HideObject xor a ld [wJoyIgnore], a - call Func_2307 ; reset to map music + call PlayDefaultMusic ; reset to map music ld a, $12 ld [W_OAKSLABCURSCRIPT], a jr .done ; 0x1ce8a $23 @@ -491,17 +491,17 @@ OaksLabScript15: ; 1ceb0 (7:4eb0) ld a, $2a ld [wcc4d], a predef ShowObject - ld a, [wcd37] + ld a, [wNPCMovementDirections2Index] ld [wd157], a ld b, $0 ld c, a - ld hl, wcc97 + ld hl, wNPCMovementDirections2 ld a, $40 call FillMemory ld [hl], $ff ld a, $1 - ld [$ff8c], a - ld de, wcc97 + ld [H_SPRITEINDEX], a + ld de, wNPCMovementDirections2 call MoveSprite ld a, $10 @@ -510,22 +510,22 @@ OaksLabScript15: ; 1ceb0 (7:4eb0) OaksLabScript_1cefd ; 1cefd (7:4efd) ld a, $1 - ld [$ff8c], a + ld [H_SPRITEINDEX], a ld a, $4 ld [$ff8d], a - call Func_34a6 ; face object + call SetSpriteFacingDirectionAndDelay ld a, $8 - ld [$ff8c], a + ld [H_SPRITEINDEX], a xor a ld [$ff8d], a - jp Func_34a6 ; face object + jp SetSpriteFacingDirectionAndDelay OaksLabScript16: ; 1cf12 (7:4f12) ld a, [wd730] bit 0, a ret nz call EnableAutoTextBoxDrawing - call Func_2307 + call PlayDefaultMusic ld a, $fc ld [wJoyIgnore], a call OaksLabScript_1cefd @@ -558,10 +558,10 @@ OaksLabScript16: ; 1cf12 (7:4f12) ld [$ff8c], a call DisplayTextID ld a, $1 - ld [$ff8c], a + ld [H_SPRITEINDEX], a ld a, $c ld [$ff8d], a - call Func_34a6 ; face object + call SetSpriteFacingDirectionAndDelay call Delay3 ld a, $1b ld [$ff8c], a @@ -579,7 +579,7 @@ OaksLabScript16: ; 1cf12 (7:4f12) ld a, [wd157] ld b, $0 ld c, a - ld hl, wcc97 + ld hl, wNPCMovementDirections2 xor a call FillMemory ld [hl], $ff @@ -588,8 +588,8 @@ OaksLabScript16: ; 1cf12 (7:4f12) call PlaySound callba Music_RivalAlternateStart ld a, $1 - ld [$ff8c], a - ld de, wcc97 + ld [H_SPRITEINDEX], a + ld de, wNPCMovementDirections2 call MoveSprite ld a, $11 @@ -600,7 +600,7 @@ OaksLabScript17: ; 1cfd4 (7:4fd4) ld a, [wd730] bit 0, a ret nz - call Func_2307 + call PlayDefaultMusic ld a, $2a ld [wcc4d], a predef HideObject @@ -652,7 +652,7 @@ OaksLabScript_1d02b: ; 1d02b (7:502b) cp $3 jr nz, .asm_1d045 ; 0x1d038 $b ld a, $4 - ld [wcd37], a + ld [wNPCMovementDirections2Index], a ld a, $30 ld b, $b jr .asm_1d068 ; 0x1d043 $23 @@ -660,13 +660,13 @@ OaksLabScript_1d02b: ; 1d02b (7:502b) cp $1 jr nz, .asm_1d054 ; 0x1d047 $b ld a, $2 - ld [wcd37], a + ld [wNPCMovementDirections2Index], a ld a, $30 ld b, $9 jr .asm_1d068 ; 0x1d052 $14 .asm_1d054 ld a, $3 - ld [wcd37], a + ld [wNPCMovementDirections2Index], a ld b, $a ld a, [W_XCOORD] cp $4 @@ -681,7 +681,7 @@ OaksLabScript_1d02b: ; 1d02b (7:502b) ld [$ffed], a ld a, $1 ld [wcf13], a - call Func_32f9 + call SetSpritePosition1 ret OaksLabScript_1d076: ; 1d076 (7:5076) @@ -817,17 +817,17 @@ OaksLabText39: ; 1d152 (7:5152) OaksLabScript_1d157: ; 1d157 (7:5157) ld a, $5 - ld [$ff8c], a + ld [H_SPRITEINDEX], a ld a, $9 ld [$ff8b], a - call Func_34fc + call GetPointerWithinSpriteStateData1 ld [hl], $0 ; manually fixed some disassembler issues around here ld a, $1 - ld [$FF8c], a + ld [H_SPRITEINDEX], a ld a, $9 ld [$ff8b], a - call Func_34fc + call GetPointerWithinSpriteStateData1 ld [hl], $c ld hl, wd730 set 6, [hl] @@ -924,10 +924,10 @@ OaksLabReceivedMonText: ; 1d227 (7:5227) OaksLabScript_1d22d: ; 1d22d (7:522d) ld a, $5 - ld [$ff8c], a + ld [H_SPRITEINDEX], a ld a, $9 ld [$ff8b], a - call Func_34fc + call GetPointerWithinSpriteStateData1 ld [hl], $0 ld hl, OaksLabLastMonText call PrintText diff --git a/scripts/pallettown.asm b/scripts/pallettown.asm index 16098dcf96..59660a90fc 100755 --- a/scripts/pallettown.asm +++ b/scripts/pallettown.asm @@ -68,7 +68,7 @@ PalletTownScript2: ; 18ed2 (6:4ed2) ld [$FF8C],a ld a,4 ld [$FF8D],a - call Func_34a6 + call SetSpriteFacingDirectionAndDelay call Delay3 ld a,1 ld [W_YCOORD],a @@ -77,11 +77,11 @@ PalletTownScript2: ; 18ed2 (6:4ed2) ld a,1 swap a ld [$FF95],a - predef Func_f929 + predef CalcPositionOfPlayerRelativeToNPC ld hl,$FF95 dec [hl] - predef Func_f8ba ; load Oak’s movement into wcc97 - ld de,wcc97 + predef FindPathToPlayer ; load Oak’s movement into wNPCMovementDirections2 + ld de,wNPCMovementDirections2 ld a,1 ; oak ld [$FF8C],a call MoveSprite @@ -111,11 +111,11 @@ PalletTownScript3: ; 18f12 (6:4f12) ld a,1 ld [wcf13],a xor a - ld [wcf10],a + ld [wNPCMovementScriptFunctionNum],a ld a,1 - ld [wcc57],a + ld [wNPCMovementScriptPointerTableNum],a ld a,[H_LOADEDROMBANK] - ld [wcc58],a + ld [wNPCMovementScriptBank],a ; trigger the next script ld a,4 @@ -123,7 +123,7 @@ PalletTownScript3: ; 18f12 (6:4f12) ret PalletTownScript4: ; 18f4b (6:4f4b) - ld a,[wcc57] + ld a,[wNPCMovementScriptPointerTableNum] and a ret nz diff --git a/scripts/pewtercity.asm b/scripts/pewtercity.asm index e7a143f9e0..2b8dfc3f8f 100755 --- a/scripts/pewtercity.asm +++ b/scripts/pewtercity.asm @@ -42,18 +42,18 @@ CoordsData_19277: ; 19277 (6:5277) db $ff PewterCityScript1: ; 19280 (6:5280) - ld a, [wcc57] + ld a, [wNPCMovementScriptPointerTableNum] and a ret nz ld a, $3 - ld [$ff8c], a - ld a, $4 + ld [H_SPRITEINDEX], a + ld a, SPRITE_FACING_UP ld [$ff8d], a - call Func_34a6 - ld a, $34 + call SetSpriteFacingDirectionAndDelay + ld a, ($3 << 4) | SPRITE_FACING_UP ld [$ff8d], a - call Func_34b9 - call Func_2307 + call SetSpriteImageIndexAfterSettingFacingDirection + call PlayDefaultMusic ld hl, wFlags_0xcd60 set 4, [hl] ld a, $d @@ -69,7 +69,7 @@ PewterCityScript1: ; 19280 (6:5280) ld [$ffee], a ld a, $3 ld [wcf13], a - call Func_32f9 + call SetSpritePosition1 ld a, $3 ld [$ff8c], a ld de, MovementData_PewterMuseumGuyExit ; $52ce @@ -95,7 +95,7 @@ PewterCityScript2: ; 192d3 (6:52d3) PewterCityScript3: ; 192e9 (6:52e9) ld a, $3 ld [wcf13], a - call Func_32fe + call SetSpritePosition2 ld a, $3 ld [wcc4d], a predef ShowObject @@ -106,18 +106,18 @@ PewterCityScript3: ; 192e9 (6:52e9) ret PewterCityScript4: ; 19305 (6:5305) - ld a, [wcc57] + ld a, [wNPCMovementScriptPointerTableNum] and a ret nz ld a, $5 ld [$ff8c], a - ld a, $8 + ld a, SPRITE_FACING_LEFT ld [$ff8d], a - call Func_34a6 - ld a, $18 + call SetSpriteFacingDirectionAndDelay + ld a, ($1 << 4) | SPRITE_FACING_LEFT ld [$ff8d], a - call Func_34b9 - call Func_2307 + call SetSpriteImageIndexAfterSettingFacingDirection + call PlayDefaultMusic ld hl, wFlags_0xcd60 set 4, [hl] ld a, $e @@ -133,7 +133,7 @@ PewterCityScript4: ; 19305 (6:5305) ld [$ffee], a ld a, $5 ld [wcf13], a - call Func_32f9 + call SetSpritePosition1 ld a, $5 ld [$ff8c], a ld de, MovementData_PewterGymGuyExit @@ -159,7 +159,7 @@ PewterCityScript5: ; 19359 (6:5359) PewterCityScript6: ; 1936f (6:536f) ld a, $5 ld [wcf13], a - call Func_32fe + call SetSpritePosition2 ld a, $4 ld [wcc4d], a predef ShowObject @@ -210,14 +210,14 @@ PewterCityText3: ; 193b1 (6:53b1) xor a ldh [$b3], a ldh [$b4], a - ld [wcf10], a + ld [wNPCMovementScriptFunctionNum], a ld a, $2 - ld [wcc57], a + ld [wNPCMovementScriptPointerTableNum], a ldh a, [$b8] - ld [wcc58], a + ld [wNPCMovementScriptBank], a ld a, $3 ld [wcf13], a - call Func_32f4 + call GetSpritePosition2 ld a, $1 ld [W_PEWTERCITYCURSCRIPT], a .asm_ac429 ; 0x193ee @@ -274,14 +274,14 @@ PewterCityText5: ; 19436 (6:5436) call PrintText xor a ldh [$b4], a - ld [wcf10], a + ld [wNPCMovementScriptFunctionNum], a ld a, $3 - ld [wcc57], a + ld [wNPCMovementScriptPointerTableNum], a ldh a, [$b8] - ld [wcc58], a + ld [wNPCMovementScriptBank], a ld a, $5 ld [wcf13], a - call Func_32f4 + call GetSpritePosition2 ld a, $4 ld [W_PEWTERCITYCURSCRIPT], a jp TextScriptEnd diff --git a/scripts/pewterpokecenter.asm b/scripts/pewterpokecenter.asm index 252c6d5be8..1871ad5f30 100755 --- a/scripts/pewterpokecenter.asm +++ b/scripts/pewterpokecenter.asm @@ -61,7 +61,7 @@ PewterPokecenterText3: ; 5c59b (17:459b) jr nz, .asm_5c5d1 ; 0x5c5f6 $d9 ld c, $30 call DelayFrames - call Func_2307 + call PlayDefaultMusic jp TextScriptEnd PewterPokecenterText5: ; 5c603 (17:4603) diff --git a/scripts/pokemontower2.asm b/scripts/pokemontower2.asm index f370d7b718..38dd1bc52a 100755 --- a/scripts/pokemontower2.asm +++ b/scripts/pokemontower2.asm @@ -46,7 +46,7 @@ PokemonTower2Script0: ; 6050f (18:450f) ld [$ff8c], a ld a, b ld [$ff8d], a - call Func_34a6 + call SetSpriteFacingDirectionAndDelay ld a, $1 ld [$ff8c], a call DisplayTextID @@ -104,7 +104,7 @@ PokemonTower2Script2: ; 605bb (18:45bb) predef HideObject xor a ld [wJoyIgnore], a - call Func_2307 + call PlayDefaultMusic ld a, $0 ld [W_POKEMONTOWER2CURSCRIPT], a ld [W_CURMAPSCRIPT], a diff --git a/scripts/pokemontower6.asm b/scripts/pokemontower6.asm index 646c956a51..6320e2af0d 100755 --- a/scripts/pokemontower6.asm +++ b/scripts/pokemontower6.asm @@ -73,12 +73,12 @@ PokemonTower6Script4: ; 60b48 (18:4b48) ret .asm_60b82 ld a, $1 - ld [wcd38], a + ld [wSimulatedJoypadStatesIndex], a ld a, $10 - ld [wccd3], a + ld [wSimulatedJoypadStatesEnd], a xor a ld [wSpriteStateData2 + $06], a - ld [wcd3b], a + ld [wOverrideSimulatedJoypadStatesMask], a ld hl, wd730 set 7, [hl] ld a, $3 @@ -87,7 +87,7 @@ PokemonTower6Script4: ; 60b48 (18:4b48) ret PokemonTower6Script3: ; 60ba1 (18:4ba1) - ld a, [wcd38] + ld a, [wSimulatedJoypadStatesIndex] and a ret nz call Delay3 diff --git a/scripts/rockethideout2.asm b/scripts/rockethideout2.asm index aa8d31a4f5..326c160555 100755 --- a/scripts/rockethideout2.asm +++ b/scripts/rockethideout2.asm @@ -24,7 +24,7 @@ RocketHideout2Script0: ; 44e42 (11:4e42) jp z, CheckFightingMapTrainers ld hl, wd736 set 7, [hl] - call Func_3486 + call StartSimulatingJoypadStates ld a, (SFX_02_52 - SFX_Headers_02) / 3 call PlaySound ld a, $ff @@ -306,7 +306,7 @@ RocketHideout2ArrowMovement36: ; 44fbb (11:4fbb) db $FF RocketHideout2Script3: ; 44fc2 (11:4fc2) - ld a, [wcd38] + ld a, [wSimulatedJoypadStatesIndex] and a jr nz, LoadSpinnerArrowTiles xor a @@ -333,7 +333,7 @@ LoadSpinnerArrowTiles: ; 44fd7 (11:4fd7) jr z, .asm_44ff6 ld hl, GymSpinnerArrows ; $5053 .asm_44ff6 - ld a, [wcd38] + ld a, [wSimulatedJoypadStatesIndex] bit 0, a jr nz, .asm_45001 ld de, $18 diff --git a/scripts/rockethideout3.asm b/scripts/rockethideout3.asm index e3223a85e9..3870c6b63a 100755 --- a/scripts/rockethideout3.asm +++ b/scripts/rockethideout3.asm @@ -24,7 +24,7 @@ RocketHideout3Script0: ; 45240 (11:5240) jp z, CheckFightingMapTrainers ld hl, wd736 set 7, [hl] - call Func_3486 + call StartSimulatingJoypadStates ld a, (SFX_02_52 - SFX_Headers_02) / 3 call PlaySound ld a, $ff @@ -136,7 +136,7 @@ RocketHideout3ArrowMovement12: ; 452e1 (11:52e1) db $FF RocketHideout3Script3 ; 452e4 (11:452e4) - ld a, [wcd38] + ld a, [wSimulatedJoypadStatesIndex] and a jp nz, LoadSpinnerArrowTiles xor a diff --git a/scripts/route16gate.asm b/scripts/route16gate.asm index e7179ea7ae..54bca41360 100755 --- a/scripts/route16gate.asm +++ b/scripts/route16gate.asm @@ -28,13 +28,13 @@ Route16GateScript0: ; 496d7 (12:56d7) jr z, .asm_4970e ; 0x496f1 $1b ld a, [wWhichTrade] dec a - ld [wcd38], a + ld [wSimulatedJoypadStatesIndex], a ld b, $0 ld c, a ld a, $40 - ld hl, wccd3 + ld hl, wSimulatedJoypadStatesEnd call FillMemory - call Func_3486 + call StartSimulatingJoypadStates ld a, $1 ld [W_ROUTE16GATECURSCRIPT], a ret @@ -51,7 +51,7 @@ CoordsData_49714: ; 49714 (12:5714) db $FF Route16GateScript1: ; 4971d (12:571d) - ld a, [wcd38] + ld a, [wSimulatedJoypadStatesIndex] and a ret nz ld a, $f0 @@ -62,16 +62,16 @@ Route16GateScript2: ; 49727 (12:5727) ld [H_SPRITEHEIGHT], a call DisplayTextID ld a, $1 - ld [wcd38], a + ld [wSimulatedJoypadStatesIndex], a ld a, $10 - ld [wccd3], a - call Func_3486 + ld [wSimulatedJoypadStatesEnd], a + call StartSimulatingJoypadStates ld a, $3 ld [W_ROUTE16GATECURSCRIPT], a ret Route16GateScript3: ; 49741 (12:5741) - ld a, [wcd38] + ld a, [wSimulatedJoypadStatesIndex] and a ret nz xor a diff --git a/scripts/route18gate.asm b/scripts/route18gate.asm index 03c4b9218c..1500f5789d 100755 --- a/scripts/route18gate.asm +++ b/scripts/route18gate.asm @@ -28,13 +28,13 @@ Route18GateScript0: ; 4988f (12:588f) jr z, .asm_498c6 ; 0x498a9 $1b ld a, [wWhichTrade] dec a - ld [wcd38], a + ld [wSimulatedJoypadStatesIndex], a ld b, $0 ld c, a ld a, $40 - ld hl, wccd3 + ld hl, wSimulatedJoypadStatesEnd call FillMemory - call Func_3486 + call StartSimulatingJoypadStates ld a, $1 ld [W_ROUTE18GATECURSCRIPT], a ret @@ -51,7 +51,7 @@ CoordsData_498cc: ; 498cc (12:58cc) db $FF Route18GateScript1: ; 498d5 (12:58d5) - ld a, [wcd38] + ld a, [wSimulatedJoypadStatesIndex] and a ret nz ld a, $f0 @@ -62,16 +62,16 @@ Route18GateScript2: ; 498df (12:58df) ld [H_SPRITEHEIGHT], a call DisplayTextID ld a, $1 - ld [wcd38], a + ld [wSimulatedJoypadStatesIndex], a ld a, $10 - ld [wccd3], a - call Func_3486 + ld [wSimulatedJoypadStatesEnd], a + call StartSimulatingJoypadStates ld a, $3 ld [W_ROUTE18GATECURSCRIPT], a ret Route18GateScript3: ; 498f9 (12:58f9) - ld a, [wcd38] + ld a, [wSimulatedJoypadStatesIndex] and a ret nz xor a diff --git a/scripts/route22.asm b/scripts/route22.asm index aba6a479f7..cd47d1dcf9 100755 --- a/scripts/route22.asm +++ b/scripts/route22.asm @@ -45,7 +45,7 @@ Route22MoveRivalSprite: ; 50ee6 (14:4ee6) call MoveSprite ld a, $c ld [$ff8d], a - jp Func_34a6 + jp SetSpriteFacingDirectionAndDelay Route22RivalMovementData: ; 50efb (14:4efb) db $C0,$C0,$C0,$C0,$FF ; move right 4 times @@ -117,7 +117,7 @@ Route22Script1: ; 50f62 (14:4f62) ld [$ff8d], a ld a, $1 ld [$ff8c], a - call Func_34a6 + call SetSpriteFacingDirectionAndDelay xor a ld [wJoyIgnore], a ld a, $1 @@ -158,7 +158,7 @@ Route22Script2: ; 50fb5 (14:4fb5) ld [$ff8d], a ld a, $1 ld [$ff8c], a - call Func_34a6 + call SetSpriteFacingDirectionAndDelay ld a, $f0 ld [wJoyIgnore], a ld hl, wd7eb @@ -208,7 +208,7 @@ Route22Script3: ; 5102a (14:502a) ld a, $22 ld [wcc4d], a predef HideObject - call Func_2307 + call PlayDefaultMusic ld hl, wd7eb res 0, [hl] res 7, [hl] @@ -259,7 +259,7 @@ Route22Script4: ; 51087 (14:5087) ld a, $c .asm_510a8 ld [$ff8d], a - call Func_34a6 + call SetSpriteFacingDirectionAndDelay xor a ld [wJoyIgnore], a ld a, $2 @@ -303,7 +303,7 @@ Route22Script5: ; 510df (14:50df) ld a, $c .asm_51102 ld [$ff8d], a - call Func_34a6 + call SetSpriteFacingDirectionAndDelay ld a, $f0 ld [wJoyIgnore], a ld hl, wd7eb @@ -353,7 +353,7 @@ Route22Script6: ; 51151 (14:5151) ld a, $23 ld [wcc4d], a predef HideObject - call Func_2307 + call PlayDefaultMusic ld hl, wd7eb res 1, [hl] res 7, [hl] diff --git a/scripts/route22gate.asm b/scripts/route22gate.asm index 107926cf7b..6618d6a2ce 100755 --- a/scripts/route22gate.asm +++ b/scripts/route22gate.asm @@ -34,15 +34,15 @@ Route22GateScriptCoords: ; 1e6b5 (7:66b5) Route22GateScript_1e6ba: ; 1e6ba (7:66ba) ld a, $1 - ld [wcd38], a + ld [wSimulatedJoypadStatesIndex], a ld a, $80 - ld [wccd3], a + ld [wSimulatedJoypadStatesEnd], a ld [wSpriteStateData1 + 9], a ld [wJoyIgnore], a - jp Func_3486 + jp StartSimulatingJoypadStates Route22GateScript1: ; 1e6cd (7:66cd) - ld a, [wcd38] + ld a, [wSimulatedJoypadStatesIndex] and a ret nz xor a diff --git a/scripts/route23.asm b/scripts/route23.asm index 5518460020..175250711a 100755 --- a/scripts/route23.asm +++ b/scripts/route23.asm @@ -118,16 +118,16 @@ CascadeBadgeText: ; 512cb (14:52cb) Route23Script_512d8: ; 512d8 (14:52d8) ld a, $1 - ld [wcd38], a + ld [wSimulatedJoypadStatesIndex], a ld a, $80 - ld [wccd3], a + ld [wSimulatedJoypadStatesEnd], a xor a ld [wSpriteStateData1 + 9], a ld [wJoyIgnore], a - jp Func_3486 + jp StartSimulatingJoypadStates Route23Script1: ; 512ec (14:52ec) - ld a, [wcd38] + ld a, [wSimulatedJoypadStatesIndex] and a ret nz Route23Script2: ; 512f1 (14:52f1) diff --git a/scripts/route24.asm b/scripts/route24.asm index cafb3f8ead..89ddeded8e 100755 --- a/scripts/route24.asm +++ b/scripts/route24.asm @@ -38,10 +38,10 @@ Route24Script0: ; 513d5 (14:53d5) res 1, [hl] ret z ld a, $80 - ld [wccd3], a + ld [wSimulatedJoypadStatesEnd], a ld a, $1 - ld [wcd38], a - call Func_3486 + ld [wSimulatedJoypadStatesIndex], a + call StartSimulatingJoypadStates ld a, $4 ld [W_ROUTE24CURSCRIPT], a ld [W_CURMAPSCRIPT], a @@ -51,7 +51,7 @@ CoordsData_5140e: ; 5140e (14:540e) db $0F,$0A,$FF Route24Script4: ; 51411 (14:5411) - ld a, [wcd38] + ld a, [wSimulatedJoypadStatesIndex] and a ret nz call Delay3 diff --git a/scripts/route5gate.asm b/scripts/route5gate.asm index d7abeff5ab..87acd01a2c 100755 --- a/scripts/route5gate.asm +++ b/scripts/route5gate.asm @@ -10,10 +10,10 @@ Route5GateScriptPointers: ; 1df3f (7:5f3f) Route5GateScript_1df43: ; 1df43 (7:5f43) ld a, $40 - ld [wccd3], a + ld [wSimulatedJoypadStatesEnd], a ld a, $1 - ld [wcd38], a - jp Func_3486 + ld [wSimulatedJoypadStatesIndex], a + jp StartSimulatingJoypadStates Route5GateScript0: ; 1df50 (7:5f50) ld a, [wd728] @@ -51,7 +51,7 @@ CoordsData_1df8f: ; 1df8f (7:5f8f) db $ff Route5GateScript1: ; 1df94 (7:5f94) - ld a, [wcd38] + ld a, [wSimulatedJoypadStatesIndex] and a ret nz call Delay3 diff --git a/scripts/route6gate.asm b/scripts/route6gate.asm index 9945f80f3e..44d03a757c 100755 --- a/scripts/route6gate.asm +++ b/scripts/route6gate.asm @@ -43,7 +43,7 @@ CoordsData_1e08c: ; 1e08c (7:608c) db $02,$04,$FF Route6GateScript1: ; 1e091 (7:6091) - ld a, [wcd38] + ld a, [wSimulatedJoypadStatesIndex] and a ret nz call Delay3 @@ -56,12 +56,12 @@ Route6GateScript_1e0a1: ; 1e0a1 (7:60a1) ld hl, wd730 set 7, [hl] ld a, $80 - ld [wccd3], a + ld [wSimulatedJoypadStatesEnd], a ld a, $1 - ld [wcd38], a + ld [wSimulatedJoypadStatesIndex], a xor a ld [wSpriteStateData2 + $06], a - ld [wcd3b], a + ld [wOverrideSimulatedJoypadStatesMask], a ret Route6GateTextPointers: ; 1e0b8 (7:60b8) diff --git a/scripts/route7gate.asm b/scripts/route7gate.asm index c959970621..beab96bf47 100755 --- a/scripts/route7gate.asm +++ b/scripts/route7gate.asm @@ -13,12 +13,12 @@ Route7GateScript_1e111: ; 1e111 (7:6111) ld hl, wd730 set 7, [hl] ld a, $20 - ld [wccd3], a + ld [wSimulatedJoypadStatesEnd], a ld a, $1 - ld [wcd38], a + ld [wSimulatedJoypadStatesIndex], a xor a ld [wSpriteStateData2 + $06], a - ld [wcd3b], a + ld [wOverrideSimulatedJoypadStatesMask], a ret Route7GateScript0: ; 1e128 (7:6128) @@ -57,7 +57,7 @@ CoordsData_1e167: ; 1e167 (7:6167) db $ff Route7GateScript1: ; 1e16c (7:616c) - ld a, [wcd38] + ld a, [wSimulatedJoypadStatesIndex] and a ret nz call Delay3 diff --git a/scripts/route8gate.asm b/scripts/route8gate.asm index aff001b464..8ea12f0418 100755 --- a/scripts/route8gate.asm +++ b/scripts/route8gate.asm @@ -12,12 +12,12 @@ Route8GateScript_1e1d7: ; 1e1d7 (7:61d7) ld hl, wd730 set 7, [hl] ld a, $10 - ld [wccd3], a + ld [wSimulatedJoypadStatesEnd], a ld a, $1 - ld [wcd38], a + ld [wSimulatedJoypadStatesIndex], a xor a ld [wSpriteStateData2 + $06], a - ld [wcd3b], a + ld [wOverrideSimulatedJoypadStatesMask], a ret Route8GateScript0: ; 1e1ee (7:61ee) @@ -55,7 +55,7 @@ CoordsData_1e22c: ; 1e22c (7:622c) db $ff Route8GateScript1: ; 1e231 (7:6231) - ld a, [wcd38] + ld a, [wSimulatedJoypadStatesIndex] and a ret nz call Delay3 diff --git a/scripts/safarizoneentrance.asm b/scripts/safarizoneentrance.asm index ffc7f40202..8ae81f8170 100755 --- a/scripts/safarizoneentrance.asm +++ b/scripts/safarizoneentrance.asm @@ -121,14 +121,14 @@ SafariZoneEntranceScript_752a3: ; 752a3 (1d:52a3) push af ld b, $0 ld a, c - ld [wcd38], a - ld hl, wccd3 + ld [wSimulatedJoypadStatesIndex], a + ld hl, wSimulatedJoypadStatesEnd pop af call FillMemory - jp Func_3486 + jp StartSimulatingJoypadStates SafariZoneEntranceScript_752b4: ; 752b4 (1d:52b4) - ld a, [wcd38] + ld a, [wSimulatedJoypadStatesIndex] and a ret diff --git a/scripts/seafoamislands4.asm b/scripts/seafoamislands4.asm index ac573994e8..909a8d9a97 100755 --- a/scripts/seafoamislands4.asm +++ b/scripts/seafoamislands4.asm @@ -66,12 +66,12 @@ SeafoamIslands4Script0: ; 46603 (11:6603) ld a, [W_XCOORD] cp $f ret nz - ld hl, wccd3 + ld hl, wSimulatedJoypadStatesEnd ld de, RLEMovement46632 call DecodeRLEList dec a - ld [wcd38], a - call Func_3486 + ld [wSimulatedJoypadStatesIndex], a + call StartSimulatingJoypadStates ld hl, W_FLAGS_D733 set 2, [hl] ld a, $1 @@ -85,7 +85,7 @@ RLEMovement46632: ; 46632 (11:6632) db $ff SeafoamIslands4Script1: ; 46639 (11:6639) - ld a, [wcd38] + ld a, [wSimulatedJoypadStatesIndex] and a ret nz ld a, $0 @@ -108,10 +108,10 @@ SeafoamIslands4Script2: ; 46644 (11:6644) .asm_4665e ld de, RLEData_46688 .asm_46661 - ld hl, wccd3 + ld hl, wSimulatedJoypadStatesEnd call DecodeRLEList dec a - ld [wcd38], a + ld [wSimulatedJoypadStatesIndex], a xor a ld [wSpriteStateData2 + $06], a ld hl, wd730 @@ -130,7 +130,7 @@ RLEData_46688: ; 46688 (11:6688) db $80,$06,$10,$02,$80,$04,$FF SeafoamIslands4Script3: ; 4668f (11:668f) - ld a, [wcd38] + ld a, [wSimulatedJoypadStatesIndex] and a ret nz ld a, $0 diff --git a/scripts/seafoamislands5.asm b/scripts/seafoamislands5.asm index bea63321e2..c4936ac158 100755 --- a/scripts/seafoamislands5.asm +++ b/scripts/seafoamislands5.asm @@ -44,10 +44,10 @@ SeafoamIslands5Script0: ; 467c7 (11:67c7) .asm_467e6 ld a, $1 .asm_467e8 - ld [wcd38], a + ld [wSimulatedJoypadStatesIndex], a ld a, $40 - ld [wccd3], a - call Func_3486 + ld [wSimulatedJoypadStatesEnd], a + call StartSimulatingJoypadStates ld hl, W_FLAGS_D733 res 2, [hl] ld a, $1 @@ -62,7 +62,7 @@ CoordsData_467fe: ; 467fe (11:67fe) db $FF SeafoamIslands5Script1: ; 46807 (11:6807) - ld a, [wcd38] + ld a, [wSimulatedJoypadStatesIndex] and a ret nz xor a @@ -89,11 +89,11 @@ SeafoamIslands5Script2: ; 46816 (11:6816) .asm_46837 ld de, RLEMovementData_46852 .asm_4683a - ld hl, wccd3 + ld hl, wSimulatedJoypadStatesEnd call DecodeRLEList dec a - ld [wcd38], a - call Func_3486 + ld [wSimulatedJoypadStatesIndex], a + call StartSimulatingJoypadStates ld a, $3 .asm_46849 ld [W_SEAFOAMISLANDS5CURSCRIPT], a @@ -117,7 +117,7 @@ RLEMovementData_46859: ; 46859 (11:6859) db $FF SeafoamIslands5Script3: ; 46860 (11:6860) - ld a, [wcd38] + ld a, [wSimulatedJoypadStatesIndex] ld b, a cp $1 call z, SeaFoamIslands5Script_46872 diff --git a/scripts/silphco11.asm b/scripts/silphco11.asm index b63bc5231e..dfdfbe1d39 100755 --- a/scripts/silphco11.asm +++ b/scripts/silphco11.asm @@ -160,7 +160,7 @@ SilphCo11Script_6221a: ; 6221a (18:621a) ld [H_DOWNARROWBLINKCNT2], a ; $ff8c ld a, b ld [$ff8d], a - jp Func_34a6 + jp SetSpriteFacingDirectionAndDelay SilphCo11Script5: ; 62227 (18:6227) ld a, [W_ISINBATTLE] ; W_ISINBATTLE diff --git a/scripts/silphco7.asm b/scripts/silphco7.asm index bd611763fb..fff1246e46 100755 --- a/scripts/silphco7.asm +++ b/scripts/silphco7.asm @@ -211,7 +211,7 @@ SilphCo7Script4: ; 51cc8 (14:5cc8) ld [H_DOWNARROWBLINKCNT2], a ; $ff8c ld a, $4 ld [$ff8d], a - call Func_34a6 + call SetSpriteFacingDirectionAndDelay ld a, $f ld [H_DOWNARROWBLINKCNT2], a ; $ff8c call DisplayTextID @@ -244,7 +244,7 @@ SilphCo7Script5: ; 51d25 (14:5d25) ld a, $a7 ld [wcc4d], a predef HideObject - call Func_2307 + call PlayDefaultMusic xor a ld [wJoyIgnore], a jp SilphCo7Text_51c10 @@ -323,7 +323,7 @@ SilphCo7Text1: ld bc, (LAPRAS << 8) | 15 call GivePokemon jr nc, .done - ld a, [wccd3] + ld a, [wSimulatedJoypadStatesEnd] and a call z, WaitForTextScrollButtonPress call EnableAutoTextBoxDrawing diff --git a/scripts/ssanne2.asm b/scripts/ssanne2.asm index f3822ec701..50deba6517 100755 --- a/scripts/ssanne2.asm +++ b/scripts/ssanne2.asm @@ -79,7 +79,7 @@ SSAnne2Script_61416: ; 61416 (18:5416) ld [$ff8d], a ld a, $2 ld [H_DOWNARROWBLINKCNT2], a ; $ff8c - jp Func_34a6 + jp SetSpriteFacingDirectionAndDelay SSAnne2Script1: ; 61430 (18:5430) ld a, [wd730] @@ -163,7 +163,7 @@ SSAnne2Script3: ; 614be (18:54be) ld a, $71 ld [wcc4d], a predef HideObject - call Func_2307 + call PlayDefaultMusic ld a, $4 ld [W_SSANNE2CURSCRIPT], a ret diff --git a/scripts/ssanne7.asm b/scripts/ssanne7.asm index b708b4fd24..1ca97ce28c 100755 --- a/scripts/ssanne7.asm +++ b/scripts/ssanne7.asm @@ -64,7 +64,7 @@ SSAnne7RubText: ; 618ec (18:58ec) ld a, [wc026] cp MUSIC_PKMN_HEALED jr z, .asm_61910 ; 0x61915 $f9 - call Func_2307 + call PlayDefaultMusic ld hl, wd803 set 1, [hl] ld hl, wd72d diff --git a/scripts/vermilioncity.asm b/scripts/vermilioncity.asm index da70b819cd..5309c7f6be 100755 --- a/scripts/vermilioncity.asm +++ b/scripts/vermilioncity.asm @@ -61,10 +61,10 @@ VermilionCityScript0: ; 197e6 (6:57e6) ret nz .asm_19810 ld a, $40 - ld [wccd3], a + ld [wSimulatedJoypadStatesEnd], a ld a, $1 - ld [wcd38], a - call Func_3486 + ld [wSimulatedJoypadStatesIndex], a + call StartSimulatingJoypadStates ld a, $1 ld [W_VERMILIONCITYCURSCRIPT], a ret @@ -85,17 +85,17 @@ VermilionCityScript2: ; 19833 (6:5833) ld a, $ff ld [wJoyIgnore], a ld a, $40 - ld [wccd3], a + ld [wSimulatedJoypadStatesEnd], a ld [wccd4], a ld a, $2 - ld [wcd38], a - call Func_3486 + ld [wSimulatedJoypadStatesIndex], a + call StartSimulatingJoypadStates ld a, $3 ld [W_VERMILIONCITYCURSCRIPT], a ret VermilionCityScript3: ; 1984e (6:584e) - ld a, [wcd38] + ld a, [wSimulatedJoypadStatesIndex] and a ret nz xor a @@ -106,7 +106,7 @@ VermilionCityScript3: ; 1984e (6:584e) ret VermilionCityScript1: ; 1985f (6:585f) - ld a, [wcd38] + ld a, [wSimulatedJoypadStatesIndex] and a ret nz ld c, $a diff --git a/scripts/vermiliondock.asm b/scripts/vermiliondock.asm index 77216739ac..ca0ce66bfc 100755 --- a/scripts/vermiliondock.asm +++ b/scripts/vermiliondock.asm @@ -14,23 +14,23 @@ VermilionDockScript: ; 1db52 (7:5b52) call Delay3 ld hl, wd730 set 7, [hl] - ld hl, wccd3 + ld hl, wSimulatedJoypadStatesEnd ld a, $40 ld [hli], a ld [hli], a ld [hl], a ld a, $3 - ld [wcd38], a + ld [wSimulatedJoypadStatesIndex], a xor a ld [wSpriteStateData2 + $06], a - ld [wcd3b], a + ld [wOverrideSimulatedJoypadStatesMask], a dec a ld [wJoyIgnore], a ret .asm_1db8d bit 5, [hl] ret nz - ld a, [wcd38] + ld a, [wSimulatedJoypadStatesIndex] and a ret nz ld [wJoyIgnore], a diff --git a/scripts/viridiancity.asm b/scripts/viridiancity.asm index 7a76928008..d0b2b4ae23 100755 --- a/scripts/viridiancity.asm +++ b/scripts/viridiancity.asm @@ -108,7 +108,7 @@ ViridianCityScript2: ; 1908f (6:508f) ret ViridianCityScript3: ; 190c1 (6:50c1) - ld a, [wcd38] + ld a, [wSimulatedJoypadStatesIndex] and a ret nz call Delay3 @@ -117,11 +117,11 @@ ViridianCityScript3: ; 190c1 (6:50c1) ret ViridianCityScript_190cf: ; 190cf (6:50cf) - call Func_3486 + call StartSimulatingJoypadStates ld a, $1 - ld [wcd38], a + ld [wSimulatedJoypadStatesIndex], a ld a, $80 - ld [wccd3], a + ld [wSimulatedJoypadStatesEnd], a xor a ld [wSpriteStateData1 + 9], a ld [wJoyIgnore], a diff --git a/scripts/viridiangym.asm b/scripts/viridiangym.asm index 65ad3553ba..4c9e68219b 100755 --- a/scripts/viridiangym.asm +++ b/scripts/viridiangym.asm @@ -38,7 +38,7 @@ ViridianGymScript0: ; 748eb (1d:48eb) call Func_3442 cp $ff jp z, CheckFightingMapTrainers - call Func_3486 + call StartSimulatingJoypadStates ld hl, wd736 set 7, [hl] ld a, (SFX_02_52 - SFX_Headers_02) / 3 @@ -121,7 +121,7 @@ ViridianGymArrowMovement12: ; 74968 (1d:4968) db $20,$0C,$FF ViridianGymScript4: ; 7496b (1d:496b) - ld a, [wcd38] + ld a, [wSimulatedJoypadStatesIndex] and a jr nz, .asm_74980 xor a diff --git a/scripts/viridianmart.asm b/scripts/viridianmart.asm index a02231f8ca..d33dfe8133 100755 --- a/scripts/viridianmart.asm +++ b/scripts/viridianmart.asm @@ -30,12 +30,12 @@ ViridianMartScript0: ; 1d49b (7:549b) ld a, $4 ld [$ff8c], a call DisplayTextID - ld hl, wccd3 + ld hl, wSimulatedJoypadStatesEnd ld de, RLEMovement1d4bb call DecodeRLEList dec a - ld [wcd38], a - call Func_3486 + ld [wSimulatedJoypadStatesIndex], a + call StartSimulatingJoypadStates ld a, $1 ld [W_VIRIDIANMARKETCURSCRIPT], a ret @@ -46,7 +46,7 @@ RLEMovement1d4bb: ; 1d4bb (7:54bb) db $ff ViridianMartScript1: ; 1d4c0 (7:54c0) - ld a, [wcd38] + ld a, [wSimulatedJoypadStatesIndex] and a ret nz call Delay3 diff --git a/wram.asm b/wram.asm index 468e776e6f..b98372f04f 100755 --- a/wram.asm +++ b/wram.asm @@ -287,8 +287,16 @@ wTrainerHeaderFlagBit:: ; cc55 ds 1 -wcc57:: ds 1 -wcc58:: ds 3 +wNPCMovementScriptPointerTableNum:: ; cc57 +; which NPC movement script pointer is being used +; 0 if an NPC movement script is not running + ds 1 + +wNPCMovementScriptBank:: ; cc58 +; ROM bank of current NPC movement script + ds 1 + + ds 2 wHallOfFame:: ; cc5b wcc5b:: ds 1 @@ -298,12 +306,23 @@ wcc5e:: ds 13 wcc6b:: ds 14 wcc79:: ds 30 -wcc97:: ds 10 + +wNPCMovementDirections2:: ; cc97 + +wSwitchPartyMonTempBuffer:: ; cc97 +; temporary buffer when swapping party mon data + ds 10 + wcca1:: ds 49 wRLEByteCount:: ; ccd2 ds 1 +wSimulatedJoypadStatesEnd:: ; ccd3 +; this is the end of the joypad states +; the list starts above this address and extends downwards in memory until here +; overloaded with below labels + wccd3:: ds 1 wccd4:: ds 1 wccd5:: ds 2 @@ -452,11 +471,30 @@ wEnemyMonEvasionMod:: ; cd33 ds 1 wcd34:: ds 3 + +wNPCMovementDirections2Index:: ; cd37 + wcd37:: ds 1 -wcd38:: ds 1 -wcd39:: ds 1 -wcd3a:: ds 1 -wcd3b:: ds 2 + +wSimulatedJoypadStatesIndex:: ; cd38 +; the next simulated joypad state is at wSimulatedJoypadStatesEnd plus this value minus 1 +; 0 if the joypad state is not being simulated + ds 1 + +wWastedByteCD39:: ; cd39 +; written to but nothing ever reads it + ds 1 + +wWastedByteCD3A:: ; cd3a +; written to but nothing ever reads it + ds 1 + +wOverrideSimulatedJoypadStatesMask:: ; cd3b +; mask indicating which real button presses can override simulated ones +; XXX is it ever not 0? + ds 1 + + ds 1 wWhichTrade:: ; cd3d ; which entry from TradeMons to select @@ -499,6 +537,8 @@ wcd5f:: ds 1 wFlags_0xcd60:: ; cd60 ; bit 0: is player engaged by trainer (to avoid being engaged by multiple trainers simultaneously) +; bit 1: boulder dust animation (from using Strength) pending +; bit 6: tried pushing against boulder once (you need to push twice before it will move) ds 1 ds 9 @@ -557,7 +597,12 @@ wcf0c:: ds 1 wcf0d:: ds 1 wcf0e:: ds 1 wcf0f:: ds 1 -wcf10:: ds 1 + +wNPCMovementScriptFunctionNum:: ; cf10 +; which script function within the pointer table indicated by +; wNPCMovementScriptPointerTableNum + ds 1 + wcf11:: ds 1 wPredefParentBank:: ; cf12 @@ -571,7 +616,10 @@ wCurSpriteMovement2:: ; cf14 ds 2 -wcf17:: ds 1 +wNPCMovementScriptSpriteOffset:: ; cf17 +; sprite offset of sprite being controlled by NPC movement script + ds 1 + wcf18:: ds 2 wGBC:: ; cf1a @@ -1657,12 +1705,24 @@ wd71c:: ds 1 wd71d:: ds 1 wd71e:: ds 1 wd71f:: ds 9 -wd728:: ds 2 + +wd728:: +; bit 0: using Strength outside of battle + ds 1 + + ds 1 + wd72a:: ds 2 wd72c:: ds 1 wd72d:: ds 1 wd72e:: ds 2 -wd730:: ds 2 + +wd730:: +; bit 7: set if joypad states are being simulated in the overworld + ds 1 + + ds 1 + wd732:: ds 1 W_FLAGS_D733:: ; d733 @@ -1670,7 +1730,11 @@ W_FLAGS_D733:: ; d733 ds 1 wd734:: ds 2 -wd736:: ds 1 + +wd736:: ; d736 +; bit 0: check if the player is standing on a door and make him walk down a step if so + ds 1 + wd737:: ds 4 wd73b:: ds 1 wd73c:: ds 3 From 0c916aea3353ed1bf2750be403b0da9ea0b922d4 Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Sat, 13 Sep 2014 00:50:56 -0700 Subject: [PATCH 017/100] Commented more sprite and map code --- data/special_warps.asm | 3 + engine/battle/14.asm | 2 +- engine/battle/1c.asm | 2 +- engine/battle/4_2.asm | 4 +- engine/battle/animations.asm | 6 +- engine/battle/core.asm | 14 +- engine/battle/d.asm | 2 +- engine/cable_club.asm | 4 +- engine/evos_moves.asm | 2 +- engine/give_pokemon.asm | 2 +- engine/hall_of_fame.asm | 8 +- engine/hidden_object_functions14.asm | 2 +- engine/hidden_object_functions17.asm | 2 +- engine/hidden_object_functions18.asm | 2 +- engine/hidden_object_functions3.asm | 2 +- engine/hidden_object_functions7.asm | 8 +- engine/in_game_trades.asm | 2 +- engine/intro.asm | 2 +- engine/items/items.asm | 40 +- engine/menu/diploma.asm | 2 +- engine/menu/league_pc.asm | 6 +- engine/menu/main_menu.asm | 27 +- engine/menu/naming_screen.asm | 8 +- engine/menu/pc.asm | 2 +- engine/menu/players_pc.asm | 2 +- engine/menu/start_menu.asm | 4 +- engine/menu/start_sub_menus.asm | 10 +- engine/mon_party_sprites.asm | 2 +- engine/oak_speech.asm | 18 +- engine/overworld/card_key.asm | 4 +- engine/overworld/cut.asm | 10 +- engine/overworld/doors.asm | 4 +- engine/overworld/emotion_bubbles.asm | 6 +- engine/overworld/healing_machine.asm | 2 +- engine/overworld/hidden_items.asm | 4 +- engine/overworld/hidden_objects.asm | 4 +- engine/overworld/item.asm | 2 +- engine/overworld/ledges.asm | 50 +- engine/overworld/npc_movement.asm | 20 +- engine/overworld/oam.asm | 4 +- engine/overworld/player_animations.asm | 346 +++++++------- engine/overworld/pokemart.asm | 2 +- engine/overworld/ssanne.asm | 6 +- engine/overworld/trainers.asm | 12 +- engine/palettes.asm | 4 +- engine/predefs.asm | 14 +- engine/predefs12.asm | 13 +- engine/predefs7.asm | 2 +- engine/slot_machine.asm | 8 +- engine/town_map.asm | 8 +- engine/trade.asm | 4 +- home.asm | 52 +-- home/audio.asm | 2 +- home/fade.asm | 22 +- home/init.asm | 2 +- home/overworld.asm | 236 +++++----- home/predef.asm | 2 +- main.asm | 621 +++++++++++++------------ scripts/billshouse.asm | 2 +- scripts/celadongamecorner.asm | 6 +- scripts/celadongym.asm | 2 +- scripts/celadonmansion3.asm | 2 +- scripts/celadonmartelevator.asm | 6 +- scripts/celadonmartroof.asm | 2 +- scripts/ceruleancity.asm | 6 +- scripts/ceruleancity2.asm | 4 +- scripts/ceruleangym.asm | 2 +- scripts/ceruleanhouse2.asm | 4 +- scripts/cinnabargym.asm | 4 +- scripts/copycatshouse2f.asm | 2 +- scripts/daycarem.asm | 2 +- scripts/fightingdojo.asm | 2 +- scripts/fuchsiagym.asm | 2 +- scripts/mansion1.asm | 2 +- scripts/mansion2.asm | 2 +- scripts/mansion3.asm | 8 +- scripts/mtmoon3.asm | 8 +- scripts/museum1f.asm | 4 +- scripts/namerater.asm | 2 +- scripts/oakslab.asm | 22 +- scripts/pallettown.asm | 4 +- scripts/pewtercity.asm | 12 +- scripts/pewtergym.asm | 2 +- scripts/pewtermart.asm | 2 +- scripts/pewterpokecenter.asm | 2 +- scripts/pokemontower5.asm | 4 +- scripts/pokemontower7.asm | 12 +- scripts/redshouse1f.asm | 4 +- scripts/rockethideout4.asm | 6 +- scripts/rockethideoutelevator.asm | 6 +- scripts/route12gateupstairs.asm | 2 +- scripts/route22.asm | 4 +- scripts/route24.asm | 2 +- scripts/saffrongym.asm | 2 +- scripts/seafoamislands1.asm | 2 +- scripts/seafoamislands2.asm | 2 +- scripts/seafoamislands3.asm | 2 +- scripts/seafoamislands4.asm | 2 +- scripts/seafoamislands5.asm | 4 +- scripts/silphco11.asm | 6 +- scripts/silphco9.asm | 4 +- scripts/silphcoelevator.asm | 6 +- scripts/ssanne9.asm | 4 +- scripts/vermiliondock.asm | 8 +- scripts/vermiliongym.asm | 2 +- scripts/victoryroad3.asm | 2 +- scripts/viridiangym.asm | 8 +- wram.asm | 169 +++++-- 108 files changed, 1091 insertions(+), 946 deletions(-) diff --git a/data/special_warps.asm b/data/special_warps.asm index 418b57f223..480bac89e1 100755 --- a/data/special_warps.asm +++ b/data/special_warps.asm @@ -1,3 +1,6 @@ +; Format: (size 2 bytes) +; 00: target map ID +; 01: which dungeon warp in the source map was used DungeonWarpList: ; 63bf (1:63bf) db SEAFOAM_ISLANDS_2,$01 db SEAFOAM_ISLANDS_2,$02 diff --git a/engine/battle/14.asm b/engine/battle/14.asm index 01a8f48a2f..530032a0aa 100755 --- a/engine/battle/14.asm +++ b/engine/battle/14.asm @@ -15,7 +15,7 @@ Func_525af: ; 525af (14:65af) ld [wPartyGainExpFlags], a ld [wPlayerMonNumber], a ; wPlayerMonNumber ld [wEscapedFromBattle], a - ld [wd35d], a + ld [wMapPalOffset], a ld hl, wcf1d ld [hli], a ld [hl], a diff --git a/engine/battle/1c.asm b/engine/battle/1c.asm index 3f23a27ca2..1c69c00f97 100755 --- a/engine/battle/1c.asm +++ b/engine/battle/1c.asm @@ -89,7 +89,7 @@ BattleTransition: ; 7096d (1c:496d) xor a ld [hVBlankWY], a dec a - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a call DelayFrame ld hl, wSpriteStateData1 + 2 ld a, [H_DOWNARROWBLINKCNT2] diff --git a/engine/battle/4_2.asm b/engine/battle/4_2.asm index 79594bdd23..133acdccfc 100755 --- a/engine/battle/4_2.asm +++ b/engine/battle/4_2.asm @@ -71,7 +71,7 @@ EndOfBattle: ; 137aa (4:77aa) call WaitForSoundToFinish call GBPalWhiteOut ld a, $ff - ld [wd42f], a + ld [wDestinationWarpID], a ret YouWinText: ; 13853 (4:7853) @@ -94,7 +94,7 @@ Func_13870: ; 13870 (4:7870) ld a, [wd736] and a ret nz - callab Func_c49d + callab IsPlayerStandingOnDoorTileOrWarpTile jr nc, .asm_13888 .asm_13884 ld a, $1 diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm index a094b34c4d..15d94f05bf 100755 --- a/engine/battle/animations.asm +++ b/engine/battle/animations.asm @@ -517,7 +517,7 @@ Func_78e01: ; 78e01 (1e:4e01) ret Func_78e23: ; 78e23 (1e:4e23) - ld a, [wcf1b] + ld a, [wOnSGB] and a ld a, $e4 jr z, .asm_78e47 @@ -1091,7 +1091,7 @@ CallWithTurnFlipped: ; 79155 (1e:5155) AnimationFlashScreenLong: ; 79165 (1e:5165) ld a,3 ; cycle through the palettes 3 times ld [wd08a],a - ld a,[wcf1b] ; running on SGB? + ld a,[wOnSGB] ; running on SGB? and a ld hl,FlashScreenLongMonochrome jr z,.loop @@ -1211,7 +1211,7 @@ Func_791f9: ; 791f9 (1e:51f9) ld bc, $4040 Func_791fc: ; 791fc (1e:51fc) - ld a, [wcf1b] + ld a, [wOnSGB] and a ld a, b jr z, .asm_79204 diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 4b1ceedd10..26465b8f28 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -139,7 +139,7 @@ SlidePlayerAndEnemySilhouettesOnScreen: ; 3c04c (f:404c) ld [$ffd7], a ld [hVBlankSCY], a dec a - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a call Delay3 xor a ld [H_AUTOBGTRANSFERENABLED], a @@ -6247,7 +6247,7 @@ DoBattleTransitionAndInitBattleVariables: ; 3ec32 (f:6c32) ld [wMenuJoypadPollCount], a callab DisplayLinkBattleVersusTextBox ld a, $1 - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a call ClearScreen .next call DelayFrame @@ -6256,7 +6256,7 @@ DoBattleTransitionAndInitBattleVariables: ; 3ec32 (f:6c32) ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a ld a, $ff - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a call ClearSprites call ClearScreen xor a @@ -6729,16 +6729,16 @@ asm_3ef23: ; 3ef23 (f:6f23) bit 1, a jr z, .asm_3ef2f ld a, [hJoyHeld] - bit 1, a + bit 1, a ; B button pressed? ret nz .asm_3ef2f - ld a, [wd13c] + ld a, [wNumberOfNoRandomBattleStepsLeft] and a ret nz callab Func_13870 ret nz asm_3ef3d: ; 3ef3d (f:6f3d) - ld a, [wd35d] + ld a, [wMapPalOffset] push af ld hl, wd358 ld a, [hl] @@ -6849,7 +6849,7 @@ InitBattle_Common: ; 3efeb (f:6feb) pop af ld [wd358], a pop af - ld [wd35d], a + ld [wMapPalOffset], a ld a, [wd0d4] ld [$ffd7], a scf diff --git a/engine/battle/d.asm b/engine/battle/d.asm index dcd58ec4e7..94a07eb655 100755 --- a/engine/battle/d.asm +++ b/engine/battle/d.asm @@ -17,7 +17,7 @@ DisplayLinkBattleVersusTextBox: ; 372d6 (d:72d6) ld [hli], a ld [hl], $6a xor a - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a callab SetupPlayerAndEnemyPokeballs ld c, 150 jp DelayFrames diff --git a/engine/cable_club.asm b/engine/cable_club.asm index 8cb70cbf6e..9b4017e274 100755 --- a/engine/cable_club.asm +++ b/engine/cable_club.asm @@ -570,13 +570,13 @@ Func_577d: ; 577d (1:577d) xor a ld [wd72d], a dec a - ld [wd42f], a + ld [wDestinationWarpID], a call LoadMapData callba Func_c335 pop hl pop af ld [hl], a - call GBFadeIn2 + call GBFadeInFromWhite ret Func_57a2: diff --git a/engine/evos_moves.asm b/engine/evos_moves.asm index 61ddb4e734..240fd9faf5 100755 --- a/engine/evos_moves.asm +++ b/engine/evos_moves.asm @@ -127,7 +127,7 @@ Evolution_PartyMonLoop: ; loop over party mons ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a ld a, $ff - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a call ClearSprites callab Func_7bde9 jp c, CancelledEvolution diff --git a/engine/give_pokemon.asm b/engine/give_pokemon.asm index dd5e92647d..d4d45bfb89 100755 --- a/engine/give_pokemon.asm +++ b/engine/give_pokemon.asm @@ -43,7 +43,7 @@ _GivePokemon: ; 4fda5 (13:7da5) call SetPokedexOwnedFlag call AddPartyMon ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld [wccd3], a scf ret diff --git a/engine/hall_of_fame.asm b/engine/hall_of_fame.asm index dd988cf193..30ae626633 100755 --- a/engine/hall_of_fame.asm +++ b/engine/hall_of_fame.asm @@ -18,7 +18,7 @@ AnimateHallOfFame: ; 701a0 (1c:41a0) ld bc, HOF_TEAM call FillMemory xor a - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a ld [$ffd7], a ld [W_SPRITEFLIPPED], a ld [wd358], a @@ -66,7 +66,7 @@ AnimateHallOfFame: ; 701a0 (1c:41a0) call PlaceString ld c, 180 call DelayFrames - call GBFadeOut2 + call GBFadeOutToWhite pop bc pop hl jr .asm_701fb @@ -125,7 +125,7 @@ Func_70278: ; 70278 (1c:4278) call Func_7036d ld d, $a0 ld e, $4 - ld a, [wcf1b] + ld a, [wOnSGB] and a jr z, .asm_702c7 sla e @@ -282,4 +282,4 @@ Func_70423: ; 70423 (1c:4423) ld [wcfc9], a ld a, $ff ld [wMusicHeaderPointer], a - jp GBFadeOut2 + jp GBFadeOutToWhite diff --git a/engine/hidden_object_functions14.asm b/engine/hidden_object_functions14.asm index 0d3598f2ea..a162c9051c 100755 --- a/engine/hidden_object_functions14.asm +++ b/engine/hidden_object_functions14.asm @@ -1,7 +1,7 @@ PrintNotebookText: ; 52996 (14:6996) call EnableAutoTextBoxDrawing ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld a, [wTrainerSpriteOffset] jp PrintPredefTextID diff --git a/engine/hidden_object_functions17.asm b/engine/hidden_object_functions17.asm index fccd426798..f1a07542b4 100755 --- a/engine/hidden_object_functions17.asm +++ b/engine/hidden_object_functions17.asm @@ -89,7 +89,7 @@ DisplayMonFrontSpriteInBox: ; 5dbd9 (17:5bd9) PrintBlackboardLinkCableText: ; 5dc1a (17:5c1a) call EnableAutoTextBoxDrawing ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld a, [wWhichTrade] call PrintPredefTextID ret diff --git a/engine/hidden_object_functions18.asm b/engine/hidden_object_functions18.asm index 5ccb43c280..9dd7fac724 100755 --- a/engine/hidden_object_functions18.asm +++ b/engine/hidden_object_functions18.asm @@ -181,7 +181,7 @@ OpenPokemonCenterPC: ; 62516 (18:6516) ret nz call EnableAutoTextBoxDrawing ld a, $1 - ld [wcf0c], a + ld [wAutoTextBoxDrawingControl], a ld a, $1f ; PredefText1f jp PrintPredefTextID diff --git a/engine/hidden_object_functions3.asm b/engine/hidden_object_functions3.asm index 11b91cd344..09d9ebccbf 100755 --- a/engine/hidden_object_functions3.asm +++ b/engine/hidden_object_functions3.asm @@ -114,7 +114,7 @@ TownMapText: ; fc12 (3:7c12) db $06 db $08 ; asm ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld hl, wd730 set 6, [hl] call GBPalWhiteOutWithDelay3 diff --git a/engine/hidden_object_functions7.asm b/engine/hidden_object_functions7.asm index 07cf5651de..c00749e4fc 100755 --- a/engine/hidden_object_functions7.asm +++ b/engine/hidden_object_functions7.asm @@ -83,7 +83,7 @@ asm_1e9b0: ; 1e9b0 (7:69b0) ld a, $9c ld [H_DOWNARROWBLINKCNT1], a ; $ff8b ld a, $3 - ld [wd42f], a + ld [wDestinationWarpID], a ld a, $5 ld [W_SAFARIZONEENTRANCECURSCRIPT], a ld hl, wd790 @@ -152,7 +152,7 @@ CinnabarGymQuiz: ; 1ea25 (7:6a25) ld l, a call PrintText ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a call CinnabarGymQuiz_1ea92 jp TextScriptEnd @@ -334,7 +334,7 @@ BillsHousePC: ; 1eb6e (7:6b6e) jp PrintPredefTextID .asm_1eb8b ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld a, $2e call PrintPredefTextID ld c, $20 @@ -363,7 +363,7 @@ BillsHousePC: ; 1eb6e (7:6b6e) ret .asm_1ebd2 ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld a, $2f call PrintPredefTextID ret diff --git a/engine/in_game_trades.asm b/engine/in_game_trades.asm index ad9de8b132..4f232eb4cd 100755 --- a/engine/in_game_trades.asm +++ b/engine/in_game_trades.asm @@ -88,7 +88,7 @@ Func_71c07: ; 71c07 (1c:5c07) xor a ld [wd07d],a dec a - ld [wcfcb],a + ld [wUpdateSpritesEnabled],a call DisplayPartyMenu push af call Func_71ca2 diff --git a/engine/intro.asm b/engine/intro.asm index 801324a56f..68bf8b506b 100755 --- a/engine/intro.asm +++ b/engine/intro.asm @@ -5,7 +5,7 @@ PlayIntro: ; 41682 (10:5682) ld [H_AUTOBGTRANSFERENABLED], a call PlayShootingStar call PlayIntroScene - call GBFadeOut2 + call GBFadeOutToWhite xor a ld [$ffae], a ld [H_AUTOBGTRANSFERENABLED], a diff --git a/engine/items/items.asm b/engine/items/items.asm index 860479e75a..b2bff82225 100755 --- a/engine/items/items.asm +++ b/engine/items/items.asm @@ -507,8 +507,8 @@ ItemUseBicycle: ; d977 (3:5977) ld a,[W_ISINBATTLE] and a jp nz,ItemUseNotTime - ld a,[wd700] - ld [wd11a],a + ld a,[wWalkBikeSurfState] + ld [wWalkBikeSurfStateCopy],a cp a,2 ; is the player surfing? jp z,ItemUseNotTime dec a ; is player already bicycling? @@ -516,7 +516,7 @@ ItemUseBicycle: ; d977 (3:5977) .getOffBike call ItemUseReloadOverworldData xor a - ld [wd700],a ; change player state to walking + ld [wWalkBikeSurfState],a ; change player state to walking call PlayDefaultMusic ; play walking music ld hl,GotOffBicycleText jr .printText @@ -527,7 +527,7 @@ ItemUseBicycle: ; d977 (3:5977) xor a ; no keys pressed ld [hJoyHeld],a ; current joypad state inc a - ld [wd700],a ; change player state to bicycling + ld [wWalkBikeSurfState],a ; change player state to bicycling ld hl,GotOnBicycleText call PlayDefaultMusic ; play bike riding music .printText @@ -535,8 +535,8 @@ ItemUseBicycle: ; d977 (3:5977) ; used for Surf out-of-battle effect ItemUseSurfboard: ; d9b4 (3:59b4) - ld a,[wd700] - ld [wd11a],a + ld a,[wWalkBikeSurfState] + ld [wWalkBikeSurfStateCopy],a cp a,2 ; is the player already surfing? jr z,.tryToStopSurfing .tryToSurf @@ -550,7 +550,7 @@ ItemUseSurfboard: ; d9b4 (3:59b4) ld hl,wd730 set 7,[hl] ld a,2 - ld [wd700],a ; change player state to surfing + ld [wWalkBikeSurfState],a ; change player state to surfing call PlayDefaultMusic ; play surfing music ld hl,SurfingGotOnText jp PrintText @@ -570,7 +570,7 @@ ItemUseSurfboard: ; d9b4 (3:59b4) ld a,[hli] ld h,[hl] ld l,a ; hl now points to passable tiles - ld a,[wcfc6] ; tile in front of the player + ld a,[wTileInFrontOfPlayer] ; tile in front of the player ld b,a .passableTileLoop ld a,[hli] @@ -586,7 +586,7 @@ ItemUseSurfboard: ; d9b4 (3:59b4) ld hl,wd730 set 7,[hl] xor a - ld [wd700],a ; change player state to walking + ld [wWalkBikeSurfState],a ; change player state to walking dec a ld [wJoyIgnore],a call PlayDefaultMusic ; play walking music @@ -636,7 +636,7 @@ ItemUseEvoStone: ; da5b (3:5a5b) ld a,$05 ; evolution stone party menu ld [wd07d],a ld a,$ff - ld [wcfcb],a + ld [wUpdateSpritesEnabled],a call DisplayPartyMenu pop bc jr c,.canceledItemUse @@ -681,7 +681,7 @@ ItemUseMedicine: ; dabb (3:5abb) ld a,$01 ld [wd07d],a ; item use party menu ld a,$ff - ld [wcfcb],a + ld [wUpdateSpritesEnabled],a ld a,[wd152] and a ; using Softboiled? jr z,.notUsingSoftboiled @@ -1096,7 +1096,7 @@ ItemUseMedicine: ; dabb (3:5abb) ld [H_AUTOBGTRANSFERENABLED],a call ClearScreen dec a - ld [wcfcb],a + ld [wUpdateSpritesEnabled],a call RedrawPartyMenu ; redraws the party menu and displays the message ld a,1 ld [H_AUTOBGTRANSFERENABLED],a @@ -1278,7 +1278,7 @@ ItemUseMedicine: ; dabb (3:5abb) ld [wccd4],a callab TryEvolvingMon ; evolve pokemon, if appropriate ld a,$01 - ld [wcfcb],a + ld [wUpdateSpritesEnabled],a pop af ld [wcf91],a pop af @@ -1424,8 +1424,8 @@ ItemUseXAccuracy: ; e013 (3:6013) ItemUseCardKey: ; e022 (3:6022) xor a ld [wd71f],a - call Func_c586 - ld a,[Func_c586] ; $4586 + call GetTileAndCoordsInFrontOfPlayer + ld a,[GetTileAndCoordsInFrontOfPlayer] ; $4586 cp a,$18 jr nz,.next0 ld hl,CardKeyTable1 @@ -1796,7 +1796,7 @@ RodResponse: ; e28d (3:628d) ld [W_CUROPPONENT], a .next - ld hl, wd700 + ld hl, wWalkBikeSurfState ld a, [hl] ; store the value in a push af push hl @@ -1818,7 +1818,7 @@ FishingInit: ; e2b4 (3:62b4) .notInBattle call IsNextTileShoreOrWater ret c - ld a,[wd700] + ld a,[wWalkBikeSurfState] cp a,2 ; Surfing? jr z,.surfing call ItemUseReloadOverworldData @@ -1877,7 +1877,7 @@ ItemUsePPRestore: ; e31e (3:631e) ld [wWhichTrade],a .chooseMon xor a - ld [wcfcb],a + ld [wUpdateSpritesEnabled],a ld a,$01 ; item use party menu ld [wd07d],a call DisplayPartyMenu @@ -2117,7 +2117,7 @@ ItemUseTMHM: ; e479 (3:6479) ld bc,14 call CopyData ld a,$ff - ld [wcfcb],a + ld [wUpdateSpritesEnabled],a ld a,$03 ; teach TM/HM party menu ld [wd07d],a call DisplayPartyMenu @@ -2744,7 +2744,7 @@ IsNextTileShoreOrWater: ; e8b8 (3:68b8) jr nc, .notShoreOrWater ld a, [W_CURMAPTILESET] cp SHIP_PORT ; Vermilion Dock tileset - ld a, [wcfc6] ; tile in front of player + ld a, [wTileInFrontOfPlayer] ; tile in front of player jr z, .skipShoreTiles ; if it's the Vermilion Dock tileset cp $48 ; eastern shore tile in Safari Zone jr z, .shoreOrWater diff --git a/engine/menu/diploma.asm b/engine/menu/diploma.asm index adf4c39626..95b2a87d6f 100755 --- a/engine/menu/diploma.asm +++ b/engine/menu/diploma.asm @@ -3,7 +3,7 @@ DisplayDiploma: ; 566e2 (15:66e2) call GBPalWhiteOutWithDelay3 call ClearScreen xor a - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a ld hl, wd730 set 6, [hl] call DisableLCD diff --git a/engine/menu/league_pc.asm b/engine/menu/league_pc.asm index 4833e57d7c..ffde236a1a 100755 --- a/engine/menu/league_pc.asm +++ b/engine/menu/league_pc.asm @@ -4,14 +4,14 @@ PKMNLeaguePC: ; 0x7657e ld hl, wd730 set 6, [hl] push hl - ld a, [wcfcb] + ld a, [wUpdateSpritesEnabled] push af ld a, [$ffD7] push af xor a ld [$ffD7], a ld [W_SPRITEFLIPPED], a - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a ld [wTrainerScreenX], a ld [wcd42], a ld a, [wd5a2] @@ -40,7 +40,7 @@ PKMNLeaguePC: ; 0x7657e pop af ld [$ffD7], a pop af - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a pop hl res 6, [hl] call GBPalWhiteOutWithDelay3 diff --git a/engine/menu/main_menu.asm b/engine/menu/main_menu.asm index 4044da43b6..6ffc624915 100755 --- a/engine/menu/main_menu.asm +++ b/engine/menu/main_menu.asm @@ -111,16 +111,16 @@ MainMenu: ; 5af2 (1:5af2) call DelayFrames ld a,[wd5a2] and a - jp z,Func_5d5f + jp z,SpecialEnterMap ld a,[W_CURMAP] ; map ID cp a,HALL_OF_FAME - jp nz,Func_5d5f + jp nz,SpecialEnterMap xor a - ld [wd71a],a + ld [wDestinationMap],a ld hl,wd732 - set 2,[hl] - call Func_62ce - jp Func_5d5f + set 2,[hl] ; fly warp or dungeon warp + call SpecialWarpIn + jp SpecialEnterMap Func_5bff: ; 5bff (1:5bff) ld a,1 ld [wd358],a @@ -247,7 +247,7 @@ LinkMenu: ; 5c0a (1:5c0a) cp $2 jr z, .asm_5d2d xor a - ld [wd700], a + ld [wWalkBikeSurfState], a ld a, [wCurrentMenuItem] ; wCurrentMenuItem and a ld a, TRADE_CENTER @@ -262,8 +262,8 @@ LinkMenu: ; 5c0a (1:5c0a) ld hl, wd732 res 1, [hl] ld a, [W_ANIMATIONID] ; W_ANIMATIONID - ld [wd71a], a - call Func_62ce + ld [wDestinationMap], a + call SpecialWarpIn ld c, $14 call DelayFrames xor a @@ -272,7 +272,7 @@ LinkMenu: ; 5c0a (1:5c0a) inc a ld [W_ISLINKBATTLE], a ; W_ISLINKBATTLE ld [wcc47], a - jr Func_5d5f + jr SpecialEnterMap .asm_5d2d xor a ld [wMenuJoypadPollCount], a ; wMenuJoypadPollCount @@ -303,16 +303,17 @@ Func_5d52: ; 5d52 (1:5d52) ld c, $14 call DelayFrames -Func_5d5f: ; 5d5f (1:5d5f) +; enter map after using a special warp or loading the game from the main menu +SpecialEnterMap: ; 5d5f (1:5d5f) xor a ld [hJoyPressed], a ld [hJoyHeld], a ld [$ffb5], a ld [wd72d], a ld hl, wd732 - set 0, [hl] + set 0, [hl] ; count play time call ResetPlayerSpriteData - ld c, $14 + ld c, 20 call DelayFrames ld a, [wcc47] and a diff --git a/engine/menu/naming_screen.asm b/engine/menu/naming_screen.asm index f7fc883c58..b7db452ac1 100755 --- a/engine/menu/naming_screen.asm +++ b/engine/menu/naming_screen.asm @@ -22,10 +22,10 @@ AskName: ; 64eb (1:64eb) ld a, [wCurrentMenuItem] ; wCurrentMenuItem and a jr nz, .asm_654c - ld a, [wcfcb] + ld a, [wUpdateSpritesEnabled] push af xor a - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a push hl ld a, $2 ld [wd07d], a @@ -38,7 +38,7 @@ AskName: ; 64eb (1:64eb) call LoadScreenTilesFromBuffer1 pop hl pop af - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a ld a, [wcf4b] cp $50 ret nz @@ -56,7 +56,7 @@ DoYouWantToNicknameText: ; 0x6557 Func_655c: ; 655c (1:655c) ld hl, wHPBarMaxHP xor a - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a ld a, $2 ld [wd07d], a call DisplayNamingScreen diff --git a/engine/menu/pc.asm b/engine/menu/pc.asm index 4df6c826a3..97895ca6e6 100755 --- a/engine/menu/pc.asm +++ b/engine/menu/pc.asm @@ -86,7 +86,7 @@ BillsPC: ; 17ee4 (5:7ee4) callba BillsPC_ ReloadMainMenu: ; 17f06 (5:7f06) xor a - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a call ReloadMapData call UpdateSprites ;XXX: moves sprites jp PCMainMenu diff --git a/engine/menu/players_pc.asm b/engine/menu/players_pc.asm index 4ff1b16f0f..5f1175eb0e 100755 --- a/engine/menu/players_pc.asm +++ b/engine/menu/players_pc.asm @@ -78,7 +78,7 @@ Func_796d: ; 796d (1:796d) ld hl, wd730 res 6, [hl] xor a - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ret Func_7995: ; 7995 (1:7995) diff --git a/engine/menu/start_menu.asm b/engine/menu/start_menu.asm index be172a67c0..da17822bbe 100755 --- a/engine/menu/start_menu.asm +++ b/engine/menu/start_menu.asm @@ -2,8 +2,8 @@ DisplayStartMenu:: ; 2acd (0:2acd) ld a,$04 ; hardcoded Bank, not sure what's it refers to ld [H_LOADEDROMBANK],a ld [$2000],a ; ROM bank 4 - ld a,[wd700] ; walking/biking/surfing - ld [wd11a],a + ld a,[wWalkBikeSurfState] ; walking/biking/surfing + ld [wWalkBikeSurfStateCopy],a ld a, (SFX_02_3f - SFX_Headers_02) / 3 ; Start menu sound call PlaySound diff --git a/engine/menu/start_sub_menus.asm b/engine/menu/start_sub_menus.asm index e774565ad1..e91386b0a8 100755 --- a/engine/menu/start_sub_menus.asm +++ b/engine/menu/start_sub_menus.asm @@ -13,7 +13,7 @@ StartMenu_Pokemon: ; 130a9 (4:70a9) xor a ld [wMenuItemToSwap],a ld [wd07d],a - ld [wcfcb],a + ld [wUpdateSpritesEnabled],a call DisplayPartyMenu jr .checkIfPokemonChosen .loop @@ -184,7 +184,7 @@ StartMenu_Pokemon: ; 130a9 (4:70a9) bit 0,a ; does the player have the Boulder Badge? jp z,.newBadgeRequired xor a - ld [wd35d],a + ld [wMapPalOffset],a ld hl,.flashLightsAreaText call PrintText call GBPalWhiteOutWithDelay3 @@ -406,7 +406,7 @@ StartMenu_Item: ; 13302 (4:7302) jp z,ItemMenuLoop jp CloseStartMenu .useItem_partyMenu - ld a,[wcfcb] + ld a,[wUpdateSpritesEnabled] push af call UseItem ld a,[wcd6a] @@ -415,11 +415,11 @@ StartMenu_Item: ; 13302 (4:7302) call GBPalWhiteOutWithDelay3 call RestoreScreenTilesAndReloadTilePatterns pop af - ld [wcfcb],a + ld [wUpdateSpritesEnabled],a jp StartMenu_Item .partyMenuNotDisplayed pop af - ld [wcfcb],a + ld [wUpdateSpritesEnabled],a jp ItemMenuLoop .tossItem call IsKeyItem diff --git a/engine/mon_party_sprites.asm b/engine/mon_party_sprites.asm index e05bdd55dc..5fa5c3bc74 100755 --- a/engine/mon_party_sprites.asm +++ b/engine/mon_party_sprites.asm @@ -21,7 +21,7 @@ GetAnimationSpeed: ; 7170a (1c:570a) ld c, a ld hl, PartyMonSpeeds add hl, bc - ld a, [wcf1b] + ld a, [wOnSGB] xor $1 add [hl] ld c, a diff --git a/engine/oak_speech.asm b/engine/oak_speech.asm index e54741f25c..518bea2a81 100755 --- a/engine/oak_speech.asm +++ b/engine/oak_speech.asm @@ -49,8 +49,8 @@ OakSpeech: ; 6115 (1:6115) ld [wcf96],a call AddItemToInventory ; give one potion ld a,[W_ANIMATIONID] - ld [wd71a],a - call Func_62ce + ld [wDestinationMap],a + call SpecialWarpIn xor a ld [$FFD7],a ld a,[wd732] @@ -62,7 +62,7 @@ OakSpeech: ; 6115 (1:6115) call FadeInIntroPic ld hl,OakSpeechText1 call PrintText ; prints text box - call GBFadeOut2 + call GBFadeOutToWhite call ClearScreen ld a,NIDORINO ld [wd0b5],a ; pic displayed is stored at this location @@ -73,7 +73,7 @@ OakSpeech: ; 6115 (1:6115) call MovePicLeft ld hl,OakSpeechText2 call PrintText ; Prints text box - call GBFadeOut2 + call GBFadeOutToWhite call ClearScreen ld de,RedPicFront ld bc,(Bank(RedPicFront) << 8) | $00 @@ -82,7 +82,7 @@ OakSpeech: ; 6115 (1:6115) ld hl,IntroducePlayerText call PrintText call LoadDefaultNamesPlayer ; brings up NewName/Red/etc menu - call GBFadeOut2 + call GBFadeOutToWhite call ClearScreen ld de,Rival1Pic ld bc,(Bank(Rival1Pic) << 8) | $00 @@ -93,12 +93,12 @@ OakSpeech: ; 6115 (1:6115) call LoadDefaultNamesRival Func_61bc: ; 61bc (1:61bc) - call GBFadeOut2 + call GBFadeOutToWhite call ClearScreen ld de,RedPicFront ld bc,(Bank(RedPicFront) << 8) | $00 call IntroPredef3B - call GBFadeIn2 + call GBFadeInFromWhite ld a,[wd72d] and a jr nz,.next @@ -148,10 +148,10 @@ Func_61bc: ; 61bc (1:61bc) call ClearScreenArea call LoadTextBoxTilePatterns ld a,1 - ld [wcfcb],a + ld [wUpdateSpritesEnabled],a ld c,$32 call DelayFrames - call GBFadeOut2 + call GBFadeOutToWhite jp ClearScreen OakSpeechText1: ; 6253 (1:6253) TX_FAR _OakSpeechText1 diff --git a/engine/overworld/card_key.asm b/engine/overworld/card_key.asm index f48c26f4a8..885932d512 100755 --- a/engine/overworld/card_key.asm +++ b/engine/overworld/card_key.asm @@ -8,8 +8,8 @@ PrintCardKeyText: ; 52673 (14:6673) ret z cp b jr nz, .asm_5267a - predef Func_c586 - ld a, [wcfc6] + predef GetTileAndCoordsInFrontOfPlayer + ld a, [wTileInFrontOfPlayer] cp $18 jr z, .asm_5269c cp $24 diff --git a/engine/overworld/cut.asm b/engine/overworld/cut.asm index 59abe7914e..0cbc021403 100755 --- a/engine/overworld/cut.asm +++ b/engine/overworld/cut.asm @@ -6,13 +6,13 @@ UsedCut: ; ef54 (3:6f54) jr z, .asm_ef6b cp GYM jr nz, .asm_ef77 - ld a, [wcfc6] + ld a, [wTileInFrontOfPlayer] cp $50 ; gym cut tree jr nz, .asm_ef77 jr asm_ef82 .asm_ef6b dec a - ld a, [wcfc6] + ld a, [wTileInFrontOfPlayer] cp $3d ; cut tree jr z, asm_ef82 cp $52 ; grass @@ -52,14 +52,14 @@ asm_ef82: ; ef82 (3:6f82) ld hl, wd730 res 6, [hl] ld a, $ff - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a call AnimateCutTree ld de, CutTreeBlockSwaps ; $7100 call Func_f09f call Func_eedc callba Func_79e96 ld a, $1 - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a ld a, (SFX_02_56 - SFX_Headers_02) / 3 call PlaySound ld a, $90 @@ -178,7 +178,7 @@ Func_f09f: ; f09f (3:709f) ld c, a ld b, $0 ld d, $0 - ld hl, wd35f + ld hl, wCurrentTileBlockMapViewPointer ld a, [hli] ld h, [hl] ld l, a diff --git a/engine/overworld/doors.asm b/engine/overworld/doors.asm index 85ff58b2d6..ac345af953 100755 --- a/engine/overworld/doors.asm +++ b/engine/overworld/doors.asm @@ -1,5 +1,5 @@ -; returns whether the player is standing on a door in carry -IsPlayerStandingOnDoor: ; 1a609 (6:6609) +; returns whether the player is standing on a door tile in carry +IsPlayerStandingOnDoorTile: ; 1a609 (6:6609) push de ld hl, DoorTileIDPointers ; $662c ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET diff --git a/engine/overworld/emotion_bubbles.asm b/engine/overworld/emotion_bubbles.asm index ae7702b46f..7106063b79 100755 --- a/engine/overworld/emotion_bubbles.asm +++ b/engine/overworld/emotion_bubbles.asm @@ -11,10 +11,10 @@ EmotionBubble: ; 17c47 (5:7c47) ld hl, vChars1 + $780 ld bc, (BANK(EmotionBubblesPointerTable) << 8) + $04 call CopyVideoData - ld a, [wcfcb] + ld a, [wUpdateSpritesEnabled] push af ld a, $ff - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a ld a, [wd736] bit 6, a ld hl, wOAMBuffer + $8f @@ -51,7 +51,7 @@ EmotionBubble: ; 17c47 (5:7c47) ld c, $3c call DelayFrames pop af - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a call DelayFrame jp UpdateSprites diff --git a/engine/overworld/healing_machine.asm b/engine/overworld/healing_machine.asm index 9c93583db3..5317463010 100755 --- a/engine/overworld/healing_machine.asm +++ b/engine/overworld/healing_machine.asm @@ -3,7 +3,7 @@ AnimateHealingMachine: ; 70433 (1c:4433) ld hl, vChars0 + $7c0 ld bc, (BANK(PokeCenterFlashingMonitorAndHealBall) << 8) + $03 call CopyVideoData - ld hl, wcfcb + ld hl, wUpdateSpritesEnabled ld a, [hl] push af ld [hl], $ff diff --git a/engine/overworld/hidden_items.asm b/engine/overworld/hidden_items.asm index 77bd8fe6ca..befe293574 100755 --- a/engine/overworld/hidden_items.asm +++ b/engine/overworld/hidden_items.asm @@ -12,7 +12,7 @@ HiddenItems: ; 76688 (1d:6688) ret nz call EnableAutoTextBoxDrawing ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld a, [wWhichTrade] ; item ID ld [wd11e], a call GetItemName @@ -42,7 +42,7 @@ FoundHiddenItemText: ; 7675b (1d:675b) .BagFull call WaitForTextScrollButtonPress ; wait for button press xor a - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld hl, HiddenItemBagFullText call PrintText jp TextScriptEnd diff --git a/engine/overworld/hidden_objects.asm b/engine/overworld/hidden_objects.asm index d2114293ab..1be5170c48 100755 --- a/engine/overworld/hidden_objects.asm +++ b/engine/overworld/hidden_objects.asm @@ -1,13 +1,13 @@ Func_46981: ; 46981 (11:6981) xor a - ld [wd71e], a + ld [wWhichDungeonWarp], a ld a, [wd72d] bit 4, a ret nz call ArePlayerCoordsInArray ret nc ld a, [wWhichTrade] ; wWhichTrade - ld [wd71e], a + ld [wWhichDungeonWarp], a ld hl, wd72d set 4, [hl] ld hl, wd732 diff --git a/engine/overworld/item.asm b/engine/overworld/item.asm index a69ec106d9..a49fc26857 100644 --- a/engine/overworld/item.asm +++ b/engine/overworld/item.asm @@ -34,7 +34,7 @@ PickupItem: ld [wcc4d], a predef HideObject ld a, 1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld hl, FoundItemText jr .print diff --git a/engine/overworld/ledges.asm b/engine/overworld/ledges.asm index 21e1b567b8..b8c1918188 100755 --- a/engine/overworld/ledges.asm +++ b/engine/overworld/ledges.asm @@ -1,48 +1,48 @@ HandleLedges: ; 1a672 (6:6672) ld a, [wd736] - bit 6, a + bit 6, a ; already jumping down ledge ret nz ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET and a ; OVERWORLD ret nz - predef Func_c586 + predef GetTileAndCoordsInFrontOfPlayer ld a, [wSpriteStateData1 + 9] ld b, a aCoord 8, 9 ld c, a - ld a, [wcfc6] + ld a, [wTileInFrontOfPlayer] ld d, a - ld hl, LedgeTiles ; $66cf -.asm_1a691 + ld hl, LedgeTiles +.loop ld a, [hli] cp $ff ret z cp b - jr nz, .asm_1a6a4 + jr nz, .nextLedgeTile1 ld a, [hli] cp c - jr nz, .asm_1a6a5 + jr nz, .nextLedgeTile2 ld a, [hli] cp d - jr nz, .asm_1a6a6 + jr nz, .nextLedgeTile3 ld a, [hl] ld e, a - jr .asm_1a6a9 -.asm_1a6a4 + jr .foundMatch +.nextLedgeTile1 inc hl -.asm_1a6a5 +.nextLedgeTile2 inc hl -.asm_1a6a6 +.nextLedgeTile3 inc hl - jr .asm_1a691 -.asm_1a6a9 + jr .loop +.foundMatch ld a, [hJoyHeld] and e ret z ld a, $ff ld [wJoyIgnore], a ld hl, wd736 - set 6, [hl] + set 6, [hl] ; jumping down ledge call StartSimulatingJoypadStates ld a, e ld [wSimulatedJoypadStatesEnd], a @@ -56,24 +56,24 @@ HandleLedges: ; 1a672 (6:6672) ; (player direction) (tile player standing on) (ledge tile) (input required) LedgeTiles: ; 1a6cf (6:66cf) - db $00,$2C,$37,$80 - db $00,$39,$36,$80 - db $00,$39,$37,$80 - db $08,$2C,$27,$20 - db $08,$39,$27,$20 - db $0C,$2C,$0D,$10 - db $0C,$2C,$1D,$10 - db $0C,$39,$0D,$10 + db SPRITE_FACING_DOWN, $2C,$37,D_DOWN + db SPRITE_FACING_DOWN, $39,$36,D_DOWN + db SPRITE_FACING_DOWN, $39,$37,D_DOWN + db SPRITE_FACING_LEFT, $2C,$27,D_LEFT + db SPRITE_FACING_LEFT, $39,$27,D_LEFT + db SPRITE_FACING_RIGHT,$2C,$0D,D_RIGHT + db SPRITE_FACING_RIGHT,$2C,$1D,D_RIGHT + db SPRITE_FACING_RIGHT,$39,$0D,D_RIGHT db $FF LoadHoppingShadowOAM: ; 1a6f0 (6:66f0) ld hl, vChars1 + $7f0 - ld de, LedgeHoppingShadow ; $6708 + ld de, LedgeHoppingShadow ld bc, (BANK(LedgeHoppingShadow) << 8) + $01 call CopyVideoDataDouble ld a, $9 ld bc, $5448 ; b, c = y, x coordinates of shadow - ld de, LedgeHoppingShadowOAM ; $6710 + ld de, LedgeHoppingShadowOAM call WriteOAMBlock ret diff --git a/engine/overworld/npc_movement.asm b/engine/overworld/npc_movement.asm index e49c6af119..07a73be674 100755 --- a/engine/overworld/npc_movement.asm +++ b/engine/overworld/npc_movement.asm @@ -1,7 +1,7 @@ PlayerStepOutFromDoor: ; 1a3e0 (6:63e0) ld hl, wd730 res 1, [hl] - call IsPlayerStandingOnDoor + call IsPlayerStandingOnDoorTile jr nc, .notStandingOnDoor ld a, $fc ld [wJoyIgnore], a @@ -62,7 +62,7 @@ Func_1a44c: ; 1a44c (6:644c) ld a, $80 call FillMemory ld [hl], $ff - ld a, [wcf13] + ld a, [wSpriteIndex] ld [H_DOWNARROWBLINKCNT2], a ; $ff8c ld de, wNPCMovementDirections2 call MoveSprite @@ -100,18 +100,18 @@ Func_1a4a1: ; 1a4a1 (6:64a1) Func_1a4a6: ; 1a4a6 (6:64a6) xor a ld [wOverrideSimulatedJoypadStatesMask], a - ld a, [wcf13] + ld a, [wSpriteIndex] swap a ld [wNPCMovementScriptSpriteOffset], a xor a ld [wSpriteStateData2 + $06], a ld hl, wSimulatedJoypadStatesEnd - ld de, RLEList_1a4e9 + ld de, RLEList_PlayerWalkToLab call DecodeRLEList dec a ld [wSimulatedJoypadStatesIndex], a ld hl, wNPCMovementDirections2 - ld de, RLEList_1a4dc + ld de, RLEList_ProfOakWalkToLab call DecodeRLEList ld hl, wd72e res 7, [hl] @@ -121,7 +121,7 @@ Func_1a4a6: ; 1a4a6 (6:64a6) ld [wNPCMovementScriptFunctionNum], a ret -RLEList_1a4dc: ; 1a4dc (6:64dc) +RLEList_ProfOakWalkToLab: ; 1a4dc (6:64dc) db $00, $05 db $80, $01 db $00, $05 @@ -130,7 +130,7 @@ RLEList_1a4dc: ; 1a4dc (6:64dc) db $E0, $01 db $FF -RLEList_1a4e9: ; 1a4e9 (6:64e9) +RLEList_PlayerWalkToLab: ; 1a4e9 (6:64e9) db D_UP, $02 db D_RIGHT, $03 db D_DOWN, $05 @@ -162,7 +162,7 @@ Func_1a514: ; 1a514 (6:6514) ld a, MUSIC_MUSEUM_GUY ld [wc0ee], a call PlaySound - ld a, [wcf13] + ld a, [wSpriteIndex] swap a ld [wNPCMovementScriptSpriteOffset], a call StartSimulatingJoypadStates @@ -218,7 +218,7 @@ Func_1a581: ; 1a581 (6:6581) ld a, MUSIC_MUSEUM_GUY ld [wc0ee], a call PlaySound - ld a, [wcf13] + ld a, [wSpriteIndex] swap a ld [wNPCMovementScriptSpriteOffset], a xor a @@ -276,7 +276,7 @@ Func_1a5e7: ; 1a5e7 (6:65e7) ret z jr .loop .notRival - ld a, [wcf13] + ld a, [wSpriteIndex] ld [H_DOWNARROWBLINKCNT2], a ; $ff8c jp SetSpriteMovementBytesToFF diff --git a/engine/overworld/oam.asm b/engine/overworld/oam.asm index 63495d22fa..b424725750 100644 --- a/engine/overworld/oam.asm +++ b/engine/overworld/oam.asm @@ -2,13 +2,13 @@ PrepareOAMData: ; Determine OAM data for currently visible ; sprites and write it to wOAMBuffer. - ld a, [wcfcb] + ld a, [wUpdateSpritesEnabled] dec a jr z, .asm_4b1e cp 0 - 1 ret nz - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a jp HideSprites .asm_4b1e diff --git a/engine/overworld/player_animations.asm b/engine/overworld/player_animations.asm index f915a2b9db..473b0d5ada 100755 --- a/engine/overworld/player_animations.asm +++ b/engine/overworld/player_animations.asm @@ -1,66 +1,67 @@ -Func_70510: ; 70510 (1c:4510) - call Func_706ef +EnterMapAnim: ; 70510 (1c:4510) + call InitFacingDirectionBuffer ld a, $ec - ld [wSpriteStateData1 + 4], a + ld [wSpriteStateData1 + 4], a ; player's sprite Y screen position call Delay3 push hl - call GBFadeIn2 + call GBFadeInFromWhite ld hl, W_FLAGS_D733 - bit 7, [hl] + bit 7, [hl] ; used fly out of battle? res 7, [hl] - jr nz, .asm_70568 + jr nz, .flyAnimation ld a, (SFX_02_4c - SFX_Headers_02) / 3 call PlaySound ld hl, wd732 - bit 4, [hl] + bit 4, [hl] ; used dungeon warp? res 4, [hl] pop hl - jr nz, .asm_7055e - call Func_705aa + jr nz, .dungeonWarpAnimation + call PlayerSpinWhileMovingDown ld a, (SFX_02_4f - SFX_Headers_02) / 3 call PlaySound - call Func_70787 + call IsPlayerStandingOnWarpPadOrHole ld a, b and a - jr nz, .asm_7055b - ld hl, wWhichTrade ; wWhichTrade + jr nz, .done +; if the player is not standing on a warp pad or hole + ld hl, wPlayerSpinInPlaceAnimFrameDelay xor a - ld [hli], a + ld [hli], a ; wPlayerSpinInPlaceAnimFrameDelay inc a - ld [hli], a + ld [hli], a ; wPlayerSpinInPlaceAnimFrameDelayDelta ld a, $8 - ld [hli], a - ld [hl], $ff + ld [hli], a ; wPlayerSpinInPlaceAnimFrameDelayEndValue + ld [hl], $ff ; wPlayerSpinInPlaceAnimSoundID ld hl, wcd48 - call Func_70730 -.asm_70558 + call PlayerSpinInPlace +.restoreDefaultMusic call PlayDefaultMusic -.asm_7055b - jp Func_70772 -.asm_7055e - ld c, $32 +.done + jp RestoreFacingDirectionAndYScreenPos +.dungeonWarpAnimation + ld c, 50 call DelayFrames - call Func_705aa - jr .asm_7055b -.asm_70568 + call PlayerSpinWhileMovingDown + jr .done +.flyAnimation pop hl - ld de, BirdSprite ; $4d80 + ld de, BirdSprite ld hl, vNPCSprites ld bc, (BANK(BirdSprite) << 8) + $0c call CopyVideoData - call Func_706d7 + call LoadBirdSpriteGraphics ld a, (SFX_02_50 - SFX_Headers_02) / 3 call PlaySound - ld hl, wWhichTrade ; wWhichTrade - xor a - ld [hli], a - ld a, $c - ld [hli], a - ld [hl], $8 + ld hl, wFlyAnimUsingCoordList + xor a ; is using coord list + ld [hli], a ; wFlyAnimUsingCoordList + ld a, 12 + ld [hli], a ; wFlyAnimCounter + ld [hl], $8 ; wFlyAnimBirdSpriteImageIndex (facing right) ld de, FlyAnimationEnterScreenCoords ; $4592 - call Func_706ae + call DoFlyAnimation call LoadPlayerSpriteGraphics - jr .asm_70558 + jr .restoreDefaultMusic FlyAnimationEnterScreenCoords: ; 70592 (1c:4592) ; y, x pairs @@ -79,90 +80,92 @@ FlyAnimationEnterScreenCoords: ; 70592 (1c:4592) db $3C, $48 db $3C, $40 -Func_705aa: ; 705aa (1c:45aa) - ld hl, wWhichTrade ; wWhichTrade +PlayerSpinWhileMovingDown: ; 705aa (1c:45aa) + ld hl, wPlayerSpinWhileMovingUpOrDownAnimDeltaY ld a, $10 - ld [hli], a + ld [hli], a ; wPlayerSpinWhileMovingUpOrDownAnimDeltaY ld a, $3c - ld [hli], a - call Func_7077f - ld [hl], a - jp Func_70755 + ld [hli], a ; wPlayerSpinWhileMovingUpOrDownAnimMaxY + call GetPlayerTeleportAnimFrameDelay + ld [hl], a ; wPlayerSpinWhileMovingUpOrDownAnimFrameDelay + jp PlayerSpinWhileMovingUpOrDown _LeaveMapAnim: ; 705ba (1c:45ba) - call Func_706ef - call Func_70787 + call InitFacingDirectionBuffer + call IsPlayerStandingOnWarpPadOrHole ld a, b and a - jr z, .asm_705ef + jr z, .playerNotStandingOnWarpPadOrHole dec a - jp nz, Func_7067d -.asm_705c8 + jp nz, LeaveMapThroughHoleAnim +.spinWhileMovingUp ld a, (SFX_02_4b - SFX_Headers_02) / 3 call PlaySound - ld hl, wWhichTrade ; wWhichTrade - ld a, $f0 - ld [hli], a + ld hl, wPlayerSpinWhileMovingUpOrDownAnimDeltaY + ld a, -$10 + ld [hli], a ; wPlayerSpinWhileMovingUpOrDownAnimDeltaY ld a, $ec - ld [hli], a - call Func_7077f - ld [hl], a - call Func_70755 - call Func_70787 + ld [hli], a ; wPlayerSpinWhileMovingUpOrDownAnimMaxY + call GetPlayerTeleportAnimFrameDelay + ld [hl], a ; wPlayerSpinWhileMovingUpOrDownAnimFrameDelay + call PlayerSpinWhileMovingUpOrDown + call IsPlayerStandingOnWarpPadOrHole ld a, b dec a - jr z, .asm_705e9 - ld c, $a + jr z, .playerStandingOnWarpPad +; if not standing on a warp pad, there is an extra delay + ld c, 10 call DelayFrames -.asm_705e9 - call GBFadeOut2 - jp Func_70772 -.asm_705ef +.playerStandingOnWarpPad + call GBFadeOutToWhite + jp RestoreFacingDirectionAndYScreenPos +.playerNotStandingOnWarpPadOrHole ld a, $4 call StopMusic ld a, [wd732] - bit 6, a - jr z, .asm_70610 - ld hl, wWhichTrade ; wWhichTrade - ld a, $10 - ld [hli], a - ld a, $ff - ld [hli], a + bit 6, a ; is the last used pokemon center the destination? + jr z, .flyAnimation +; if going to the last used pokemon center + ld hl, wPlayerSpinInPlaceAnimFrameDelay + ld a, 16 + ld [hli], a ; wPlayerSpinInPlaceAnimFrameDelay + ld a, -1 + ld [hli], a ; wPlayerSpinInPlaceAnimFrameDelayDelta xor a - ld [hli], a - ld [hl], $a1 + ld [hli], a ; wPlayerSpinInPlaceAnimFrameDelayEndValue + ld [hl], $a1 ; wPlayerSpinInPlaceAnimSoundID ld hl, wcd48 - call Func_70730 - jr .asm_705c8 -.asm_70610 - call Func_706d7 - ld hl, wWhichTrade ; wWhichTrade - ld a, $ff - ld [hli], a - ld a, $8 - ld [hli], a - ld [hl], $c - call Func_706ae + call PlayerSpinInPlace + jr .spinWhileMovingUp +.flyAnimation + call LoadBirdSpriteGraphics + ld hl, wFlyAnimUsingCoordList + ld a, $ff ; is not using coord list (flap in place) + ld [hli], a ; wFlyAnimUsingCoordList + ld a, 8 + ld [hli], a ; wFlyAnimCounter + ld [hl], $c ; wFlyAnimBirdSpriteImageIndex + call DoFlyAnimation ld a, (SFX_02_50 - SFX_Headers_02) / 3 call PlaySound - ld hl, wWhichTrade ; wWhichTrade - xor a - ld [hli], a + ld hl, wFlyAnimUsingCoordList + xor a ; is using coord list + ld [hli], a ; wFlyAnimUsingCoordList ld a, $c - ld [hli], a - ld [hl], $c + ld [hli], a ; wFlyAnimCounter + ld [hl], $c ; wFlyAnimBirdSpriteImageIndex (facing right) ld de, FlyAnimationScreenCoords1 ; $464f - call Func_706ae - ld c, $28 + call DoFlyAnimation + ld c, 40 call DelayFrames - ld hl, wTrainerEngageDistance - ld a, $b - ld [hli], a - ld [hl], $8 + ld hl, wFlyAnimCounter + ld a, 11 + ld [hli], a ; wFlyAnimCounter + ld [hl], $8 ; wFlyAnimBirdSpriteImageIndex (facing left) ld de, FlyAnimationScreenCoords2 ; $4667 - call Func_706ae - call GBFadeOut2 - jp Func_70772 + call DoFlyAnimation + call GBFadeOutToWhite + jp RestoreFacingDirectionAndYScreenPos FlyAnimationScreenCoords1: ; 7064f (1c:464f) ; y, x pairs @@ -198,33 +201,35 @@ FlyAnimationScreenCoords2: ; 70667 (1c:4667) db $F0, $00 -Func_7067d: ; 7067d (1c:467d) +LeaveMapThroughHoleAnim: ; 7067d (1c:467d) ld a, $ff - ld [wcfcb], a - ld a, [wOAMBuffer + $02] - ld [wOAMBuffer + $0a], a - ld a, [wOAMBuffer + $06] - ld [wOAMBuffer + $0e], a + ld [wUpdateSpritesEnabled], a ; disable UpdateSprites + ; shift upper half of player's sprite down 8 pixels and hide lower half + ld a, [wOAMBuffer + 0 * 4 + 2] + ld [wOAMBuffer + 2 * 4 + 2], a + ld a, [wOAMBuffer + 1 * 4 + 2] + ld [wOAMBuffer + 3 * 4 + 2], a ld a, $a0 - ld [wOAMBuffer], a - ld [wOAMBuffer + $04], a - ld c, $2 + ld [wOAMBuffer + 0 * 4], a + ld [wOAMBuffer + 1 * 4], a + ld c, 2 call DelayFrames + ; hide lower half of player's sprite ld a, $a0 - ld [wOAMBuffer + $08], a - ld [wOAMBuffer + $0c], a - call GBFadeOut2 + ld [wOAMBuffer + 2 * 4], a + ld [wOAMBuffer + 3 * 4], a + call GBFadeOutToWhite ld a, $1 - ld [wcfcb], a - jp Func_70772 + ld [wUpdateSpritesEnabled], a ; enable UpdateSprites + jp RestoreFacingDirectionAndYScreenPos -Func_706ae: ; 706ae (1c:46ae) - ld a, [wTrainerFacingDirection] - xor $1 - ld [wTrainerFacingDirection], a +DoFlyAnimation: ; 706ae (1c:46ae) + ld a, [wFlyAnimBirdSpriteImageIndex] + xor $1 ; make the bird flap its wings + ld [wFlyAnimBirdSpriteImageIndex], a ld [wSpriteStateData1 + 2], a call Delay3 - ld a, [wWhichTrade] ; wWhichTrade + ld a, [wFlyAnimUsingCoordList] cp $ff jr z, .asm_706cd ld hl, wSpriteStateData1 + 4 @@ -236,13 +241,13 @@ Func_706ae: ; 706ae (1c:46ae) inc de ld [hl], a .asm_706cd - ld a, [wTrainerEngageDistance] + ld a, [wFlyAnimCounter] dec a - ld [wTrainerEngageDistance], a - jr nz, Func_706ae + ld [wFlyAnimCounter], a + jr nz, DoFlyAnimation ret -Func_706d7: ; 706d7 (1c:46d7) +LoadBirdSpriteGraphics: ; 706d7 (1c:46d7) ld de, BirdSprite ; $4d80 ld hl, vNPCSprites ld bc, (BANK(BirdSprite) << 8) + $0c @@ -252,32 +257,32 @@ Func_706d7: ; 706d7 (1c:46d7) ld bc, (BANK(BirdSprite) << 8) + $0c jp CopyVideoData -Func_706ef: ; 706ef (1c:46ef) - ld a, [wSpriteStateData1 + 2] +InitFacingDirectionBuffer: ; 706ef (1c:46ef) + ld a, [wSpriteStateData1 + 2] ; player's sprite facing direction (image index is locked to standing images) ld [wcd50], a - ld a, [wSpriteStateData1 + 4] + ld a, [wSpriteStateData1 + 4] ; player's sprite Y screen position ld [wcd4f], a - ld hl, PlayerSpinningFacingOrder ; $4713 + ld hl, PlayerSpinningFacingOrder ld de, wcd48 ld bc, $4 call CopyData - ld a, [wSpriteStateData1 + 2] + ld a, [wSpriteStateData1 + 2] ; player's sprite facing direction (image index is locked to standing images) ld hl, wcd48 -.asm_7070d +.loop cp [hl] inc hl - jr nz, .asm_7070d + jr nz, .loop dec hl ret PlayerSpinningFacingOrder: ; 70713 (1c:4713) ; The order of the direction the player's sprite is facing when teleporting ; away. Creates a spinning effect. - db $00, $08, $04, $0C ; down, left, up, right + db SPRITE_FACING_DOWN, SPRITE_FACING_LEFT, SPRITE_FACING_UP, SPRITE_FACING_RIGHT -Func_70717: ; 70717 (1c:4717) +SpinPlayerSprite: ; 70717 (1c:4717) ld a, [hl] - ld [wSpriteStateData1 + 2], a + ld [wSpriteStateData1 + 2], a ; player's sprite facing direction (image index is locked to standing images) push hl ld hl, wcd48 ld de, wcd47 @@ -288,84 +293,85 @@ Func_70717: ; 70717 (1c:4717) pop hl ret -Func_70730: ; 70730 (1c:4730) - call Func_70717 - ld a, [wWhichTrade] ; wWhichTrade +PlayerSpinInPlace: ; 70730 (1c:4730) + call SpinPlayerSprite + ld a, [wPlayerSpinInPlaceAnimFrameDelay] ld c, a and $3 jr nz, .asm_70743 - ld a, [wTrainerScreenY] + ld a, [wPlayerSpinInPlaceAnimSoundID] cp $ff call nz, PlaySound .asm_70743 - ld a, [wTrainerEngageDistance] + ld a, [wPlayerSpinInPlaceAnimFrameDelayDelta] add c - ld [wWhichTrade], a ; wWhichTrade + ld [wPlayerSpinInPlaceAnimFrameDelay], a ld c, a - ld a, [wTrainerFacingDirection] + ld a, [wPlayerSpinInPlaceAnimFrameDelayEndValue] cp c ret z call DelayFrames - jr Func_70730 + jr PlayerSpinInPlace -Func_70755: ; 70755 (1c:4755) - call Func_70717 - ld a, [wWhichTrade] ; wWhichTrade +PlayerSpinWhileMovingUpOrDown: ; 70755 (1c:4755) + call SpinPlayerSprite + ld a, [wPlayerSpinWhileMovingUpOrDownAnimDeltaY] ld c, a - ld a, [wSpriteStateData1 + 4] + ld a, [wSpriteStateData1 + 4] ; player's sprite Y screen position add c ld [wSpriteStateData1 + 4], a ld c, a - ld a, [wTrainerEngageDistance] + ld a, [wPlayerSpinWhileMovingUpOrDownAnimMaxY] cp c ret z - ld a, [wTrainerFacingDirection] + ld a, [wPlayerSpinWhileMovingUpOrDownAnimFrameDelay] ld c, a call DelayFrames - jr Func_70755 + jr PlayerSpinWhileMovingUpOrDown -Func_70772: ; 70772 (1c:4772) +RestoreFacingDirectionAndYScreenPos: ; 70772 (1c:4772) ld a, [wcd4f] ld [wSpriteStateData1 + 4], a ld a, [wcd50] ld [wSpriteStateData1 + 2], a ret -Func_7077f: ; 7077f (1c:477f) - ld a, [wcf1b] +; if SGB, 2 frames, else 3 frames +GetPlayerTeleportAnimFrameDelay: ; 7077f (1c:477f) + ld a, [wOnSGB] xor $1 inc a inc a ret -Func_70787: ; 70787 (1c:4787) +IsPlayerStandingOnWarpPadOrHole: ; 70787 (1c:4787) ld b, 0 - ld hl, DataTable_707a9 ; $47a9 - ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET + ld hl, .warpPadAndHoleData + ld a, [W_CURMAPTILESET] ld c, a -.asm_70790 +.loop ld a, [hli] cp $ff - jr z, .asm_707a4 + jr z, .done cp c - jr nz, .asm_7079e + jr nz, .nextEntry aCoord 8, 9 cp [hl] - jr z, .asm_707a2 -.asm_7079e + jr z, .foundMatch +.nextEntry inc hl inc hl - jr .asm_70790 -.asm_707a2 + jr .loop +.foundMatch inc hl ld b, [hl] -.asm_707a4 +.done ld a, b ld [wcd5b], a ret ; format: db tileset id, tile id, value to be put in wcd5b -DataTable_707a9: ; 707a9 (1c:47a9) +.warpPadAndHoleData: ; 707a9 (1c:47a9) db FACILITY, $20, 1 ; warp pad db FACILITY, $11, 2 ; hole db CAVERN, $22, 2 ; hole @@ -454,7 +460,7 @@ ItsABiteText: ; 70851 (1c:4851) db "@" FishingRodGfxProperties: ; 70856 (1c:4856) -; specicies how the fishing rod should be drawn on the screen +; specifies how the fishing rod should be drawn on the screen ; first byte = screen y coordinate ; second byte = screen x coordinate ; third byte = tile number @@ -482,21 +488,21 @@ RedFishingTiles: ; 70866 (1c:4866) dw vNPCSprites2 + $7d0 _HandleMidJump: ; 7087e (1c:487e) - ld a, [wd714] + ld a, [wPlayerJumpingYScreenCoordsIndex] ld c, a inc a cp $10 - jr nc, .asm_70895 - ld [wd714], a - ld b, $0 - ld hl, PlayerJumpingYScreenCoords ; $48ba + jr nc, .finishedJump + ld [wPlayerJumpingYScreenCoordsIndex], a + ld b, 0 + ld hl, PlayerJumpingYScreenCoords add hl, bc ld a, [hl] ld [wSpriteStateData1 + 4], a ; player's sprite y coordinate ret -.asm_70895 - ld a, [wWalkCounter] ; wcfc5 - cp $0 +.finishedJump + ld a, [wWalkCounter] + cp 0 ret nz call UpdateSprites call Delay3 @@ -504,11 +510,11 @@ _HandleMidJump: ; 7087e (1c:487e) ld [hJoyHeld], a ld [hJoyPressed], a ld [hJoyReleased], a - ld [wd714], a + ld [wPlayerJumpingYScreenCoordsIndex], a ld hl, wd736 - res 6, [hl] + res 6, [hl] ; not jumping down a ledge any more ld hl, wd730 - res 7, [hl] + res 7, [hl] ; not simulating joypad states any more xor a ld [wJoyIgnore], a ret diff --git a/engine/overworld/pokemart.asm b/engine/overworld/pokemart.asm index 1c2c23bfc9..a27f6b0a48 100755 --- a/engine/overworld/pokemart.asm +++ b/engine/overworld/pokemart.asm @@ -203,7 +203,7 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20) ld hl,PokemartThankYouText call PrintText ld a,$01 - ld [wcfcb],a + ld [wUpdateSpritesEnabled],a call UpdateSprites ; move sprites ld a,[wd07e] ld [wListScrollOffset],a diff --git a/engine/overworld/ssanne.asm b/engine/overworld/ssanne.asm index bdbbd17e7d..f1a8ecf93d 100755 --- a/engine/overworld/ssanne.asm +++ b/engine/overworld/ssanne.asm @@ -1,10 +1,10 @@ AnimateBoulderDust: ; 79f54 (1e:5f54) ld a, $1 ld [wcd50], a ; select the boulder dust offsets - ld a, [wcfcb] + ld a, [wUpdateSpritesEnabled] push af ld a, $ff - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a ld a, %11100100 ld [rOBP1], a call LoadSmokeTileFourTimes @@ -26,7 +26,7 @@ AnimateBoulderDust: ; 79f54 (1e:5f54) dec c jr nz, .loop pop af - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a jp LoadPlayerSpriteGraphics GetMoveBoulderDustFunctionPointer: ; 79f92 (1e:5f92) diff --git a/engine/overworld/trainers.asm b/engine/overworld/trainers.asm index 5237df0d8d..4aaab3edf8 100755 --- a/engine/overworld/trainers.asm +++ b/engine/overworld/trainers.asm @@ -1,7 +1,7 @@ _GetSpritePosition1: ; 567f9 (15:67f9) ld hl, wSpriteStateData1 ld de, $4 - ld a, [wcf13] + ld a, [wSpriteIndex] ld [H_SPRITEINDEX], a call GetSpriteDataPointer ld a, [hli] @@ -20,7 +20,7 @@ _GetSpritePosition1: ; 567f9 (15:67f9) _GetSpritePosition2: ; 56819 (15:6819) ld hl, wSpriteStateData1 ld de, $4 - ld a, [wcf13] + ld a, [wSpriteIndex] ld [H_SPRITEINDEX], a call GetSpriteDataPointer ld a, [hli] ; c1x4 (screen Y pos) @@ -39,7 +39,7 @@ _GetSpritePosition2: ; 56819 (15:6819) _SetSpritePosition1: ; 5683d (15:683d) ld hl, wSpriteStateData1 ld de, $4 - ld a, [wcf13] + ld a, [wSpriteIndex] ld [H_SPRITEINDEX], a call GetSpriteDataPointer ld a, [$ffeb] ; c1x4 (screen Y pos) @@ -58,7 +58,7 @@ _SetSpritePosition1: ; 5683d (15:683d) _SetSpritePosition2: ; 5685d (15:685d) ld hl, wSpriteStateData1 ld de, $0004 - ld a, [wcf13] + ld a, [wSpriteIndex] ld [H_SPRITEINDEX], a call GetSpriteDataPointer ld a, [wd130] @@ -75,7 +75,7 @@ _SetSpritePosition2: ; 5685d (15:685d) ret TrainerWalkUpToPlayer: ; 56881 (15:6881) - ld a, [wcf13] + ld a, [wSpriteIndex] swap a ld [wTrainerSpriteOffset], a ; wWhichTrade call ReadTrainerScreenPosition @@ -143,7 +143,7 @@ TrainerWalkUpToPlayer: ; 56881 (15:6881) ld de, wNPCMovementDirections2 call FillMemory ; write the necessary steps to reach player ld [hl], $ff ; write end of list sentinel - ld a, [wcf13] + ld a, [wSpriteIndex] ld [H_SPRITEINDEX], a jp MoveSprite_ diff --git a/engine/palettes.asm b/engine/palettes.asm index eafd8ef663..67afc12d77 100755 --- a/engine/palettes.asm +++ b/engine/palettes.asm @@ -380,11 +380,11 @@ SendSGBPacket: ; 71feb (1c:5feb) LoadSGB: ; 7202b (1c:602b) xor a - ld [wcf1b], a + ld [wOnSGB], a call Func_7209b ret nc ld a, $1 - ld [wcf1b], a + ld [wOnSGB], a ld a, [wGBC] and a jr z, .asm_7203f diff --git a/engine/predefs.asm b/engine/predefs.asm index c492a20605..0a5eff0395 100755 --- a/engine/predefs.asm +++ b/engine/predefs.asm @@ -71,19 +71,19 @@ PredefPointers:: ; 4fe79 (13:7e79) add_predef FlagActionPredef add_predef HideObject add_predef IsObjectHidden - add_predef Func_c69c + add_predef ApplyOutOfBattlePoisonDamage add_predef AnyPartyAlive add_predef ShowObject add_predef ShowObject2 add_predef Func_ee9e add_predef InitPlayerData2 - add_predef Func_c754 + add_predef LoadTilesetHeader add_predef LearnMoveFromLevelUp add_predef LearnMove add_predef IsItemInBag_ ; 1C, used in Pokémon Tower dbw $03,Func_3eb5 ; for these two, the bank number is actually 0 dbw $03,GiveItem - add_predef Func_480eb + add_predef ChangeBGPalColor0_4Frames add_predef FindPathToPlayer add_predef Func_480ff add_predef CalcPositionOfPlayerRelativeToNPC @@ -105,7 +105,7 @@ PredefPointers:: ; 4fe79 (13:7e79) add_predef PlayIntro add_predef Func_79869 add_predef FlashScreen - add_predef Func_c586 + add_predef GetTileAndCoordsInFrontOfPlayer add_predef StatusScreen add_predef StatusScreen2 add_predef Func_410e2 @@ -140,9 +140,9 @@ PredefPointers:: ; 4fe79 (13:7e79) add_predef HallOfFamePC add_predef DisplayDexRating dbw $1E, _LeaveMapAnim ; wrong bank - dbw $1E, Func_70510 ; wrong bank - add_predef Func_c5be - add_predef Func_c60b + dbw $1E, EnterMapAnim ; wrong bank + add_predef GetTileTwoStepsInFrontOfPlayer + add_predef CheckForCollisionWhenPushingBoulder add_predef PrintStrengthTxt add_predef PickupItem add_predef Func_27d98 diff --git a/engine/predefs12.asm b/engine/predefs12.asm index 380cfc1c91..90032a14be 100755 --- a/engine/predefs12.asm +++ b/engine/predefs12.asm @@ -1,13 +1,14 @@ -Func_480eb: ; 480eb (12:40eb) +; b = new colour for BG colour 0 (usually white) for 4 frames +ChangeBGPalColor0_4Frames: ; 480eb (12:40eb) call GetPredefRegisters - ld a, [rBGP] ; $ff47 + ld a, [rBGP] or b - ld [rBGP], a ; $ff47 + ld [rBGP], a ld c, $4 call DelayFrames - ld a, [rBGP] ; $ff47 - and $fc - ld [rBGP], a ; $ff47 + ld a, [rBGP] + and %11111100 + ld [rBGP], a ret Func_480ff: ; 480ff (12:40ff) diff --git a/engine/predefs7.asm b/engine/predefs7.asm index 469fe0c40a..b6c3bbbc79 100755 --- a/engine/predefs7.asm +++ b/engine/predefs7.asm @@ -31,7 +31,7 @@ Func_1c9c6: ; 1c9c6 (7:49c6) ld b, a ld a, [hl] ld c, a - ld hl, wd3af + ld hl, wWarpEntries call Func_1ca0d Func_1ca0d: ; 1ca0d (7:4a0d) diff --git a/engine/slot_machine.asm b/engine/slot_machine.asm index ed6f52fb43..6964b94e12 100755 --- a/engine/slot_machine.asm +++ b/engine/slot_machine.asm @@ -1,7 +1,7 @@ PromptUserToPlaySlots: ; 3730e (d:730e) call SaveScreenTilesToBuffer2 ld a, BANK(DisplayTextIDInit) - ld [wcf0c], a + ld [wAutoTextBoxDrawingControl], a ld b, a ld hl, DisplayTextIDInit call Bankswitch @@ -12,7 +12,7 @@ PromptUserToPlaySlots: ; 3730e (d:730e) and a jr nz, .skip dec a - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a ld hl, wcd4f xor a ld [hli], a @@ -40,7 +40,7 @@ PromptUserToPlaySlots: ; 3730e (d:730e) ld [W_SUBANIMSUBENTRYADDR], a call GBPalWhiteOutWithDelay3 ld a, $1 - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a call GoPAL_SET_CF1C call ReloadMapSpriteTilePatterns call ReloadTilesetTilePatterns @@ -221,7 +221,7 @@ SlotMachine_374ad: ; 374ad (d:74ad) call SlotMachine_374fb call SlotMachine_37517 ret c - ld a, [wcf1b] + ld a, [wOnSGB] xor $1 inc a ld c, a diff --git a/engine/town_map.asm b/engine/town_map.asm index 2cd3728439..6d10c22266 100755 --- a/engine/town_map.asm +++ b/engine/town_map.asm @@ -1,6 +1,6 @@ DisplayTownMap: ; 70e3e (1c:4e3e) call LoadTownMap - ld hl, wcfcb + ld hl, wUpdateSpritesEnabled ld a, [hl] push af ld [hl], $ff @@ -111,7 +111,7 @@ TownMapCursor: ; 70f40 (1c:4f40) LoadTownMap_Nest: ; 70f60 (1c:4f60) call LoadTownMap - ld hl, wcfcb + ld hl, wUpdateSpritesEnabled ld a, [hl] push af ld [hl], $ff @@ -148,7 +148,7 @@ LoadTownMap_Fly: ; 70f90 (1c:4f90) ld bc, (BANK(TownMapUpArrow) << 8) + $01 call CopyVideoDataDouble call Func_71070 - ld hl, wcfcb + ld hl, wUpdateSpritesEnabled ld a, [hl] push af ld [hl], $ff @@ -206,7 +206,7 @@ LoadTownMap_Fly: ; 70f90 (1c:4f90) ld a, (SFX_02_3e - SFX_Headers_02) / 3 call PlaySound ld a, [hl] - ld [wd71a], a + ld [wDestinationMap], a ld hl, wd732 set 3, [hl] inc hl diff --git a/engine/trade.asm b/engine/trade.asm index 0f245fc5dc..5be77f3e56 100755 --- a/engine/trade.asm +++ b/engine/trade.asm @@ -119,10 +119,10 @@ LoadTradingGFXAndMonNames: ; 411a1 (10:51a1) call FillMemory call ClearSprites ld a, $ff - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a ld hl, wd730 set 6, [hl] - ld a, [wcf1b] + ld a, [wOnSGB] and a ld a, $e4 jr z, .asm_411e5 diff --git a/home.asm b/home.asm index 735d087d58..87215991f9 100644 --- a/home.asm +++ b/home.asm @@ -173,7 +173,7 @@ LoadDestinationWarpPosition:: ; 1313 (0:1313) ld b,0 add hl,bc ld bc,4 - ld de,wd35f + ld de,wCurrentTileBlockMapViewPointer call CopyData pop af ld [H_LOADEDROMBANK],a @@ -1464,7 +1464,7 @@ INCLUDE "home/audio.asm" UpdateSprites:: ; 2429 (0:2429) - ld a, [wcfcb] + ld a, [wUpdateSpritesEnabled] dec a ret nz ld a, [H_LOADEDROMBANK] @@ -1607,18 +1607,18 @@ DisplayTextID:: ; 2920 (0:2920) ld l,a ; hl = map text pointer ld d,$00 ld a,[$ff8c] ; text ID - ld [wcf13],a + ld [wSpriteIndex],a and a jp z,DisplayStartMenu - cp a,$d3 ; safari game over + cp a,$d3 jp z,DisplaySafariGameOverText - cp a,$d0 ; fainted + cp a,$d0 jp z,DisplayPokemonFaintedText - cp a,$d1 ; blacked out + cp a,$d1 jp z,DisplayPlayerBlackedOutText - cp a,$d2 ; repel wore off + cp a,$d2 jp z,DisplayRepelWoreOffText - ld a,[W_NUMSPRITES] ; number of sprites + ld a,[W_NUMSPRITES] ld e,a ld a,[$ff8c] ; sprite ID cp e @@ -1678,7 +1678,7 @@ DisplayTextID:: ; 2920 (0:2920) jr AfterDisplayingTextID .notSpecialCase call Func_3c59 ; display the text - ld a,[wcc3c] + ld a,[wDoNotWaitForButtonPressAfterDisplayingText] and a jr nz,HoldTextDisplayOpen @@ -1723,13 +1723,13 @@ CloseTextDisplay:: ; 29e8 (0:29e8) ld hl,wcfc4 res 0,[hl] ld a,[wd732] - bit 3,a + bit 3,a ; used fly warp call z,LoadPlayerSpriteGraphics call LoadCurrentMapView pop af ld [H_LOADEDROMBANK],a ld [$2000],a - jp UpdateSprites ; move sprites + jp UpdateSprites DisplayPokemartDialogue:: ; 2a2e (0:2a2e) push hl @@ -1757,7 +1757,7 @@ PokemartGreetingText:: ; 2a55 (0:2a55) LoadItemList:: ; 2a5a (0:2a5a) ld a,$01 - ld [wcfcb],a + ld [wUpdateSpritesEnabled],a ld a,h ld [wd128],a ld a,l @@ -1805,7 +1805,7 @@ DisplayPlayerBlackedOutText:: ; 2aa9 (0:2aa9) ld hl,PlayerBlackedOutText call PrintText ld a,[wd732] - res 5,a + res 5,a ; reset forced to use bike bit ld [wd732],a jp HoldTextDisplayOpen @@ -2616,7 +2616,7 @@ ChooseFlyDestination:: ; 30a9 (0:30a9) ; causes the text box to close without waiting for a button press after displaying text DisableWaitingAfterTextDisplay:: ; 30b6 (0:30b6) ld a,$01 - ld [wcc3c],a + ld [wDoNotWaitForButtonPressAfterDisplayingText],a ret ; uses an item @@ -2872,11 +2872,11 @@ TalkToTrainer:: ; 31cc (0:31cc) ; checks if any trainers are seeing the player and wanting to fight CheckFightingMapTrainers:: ; 3219 (0:3219) call CheckForEngagingTrainers - ld a, [wcf13] + ld a, [wSpriteIndex] cp $ff jr nz, .trainerEngaging xor a - ld [wcf13], a + ld [wSpriteIndex], a ld [wTrainerHeaderFlagBit], a ret .trainerEngaging @@ -2900,7 +2900,7 @@ Func_324c:: ; 324c (0:324c) and $1 ret nz ld [wJoyIgnore], a - ld a, [wcf13] + ld a, [wSpriteIndex] ld [H_DOWNARROWBLINKCNT2], a ; $ff8c call DisplayTextID @@ -2939,7 +2939,7 @@ EndTrainerBattle:: ; 3275 (0:3275) jr nc, .skipRemoveSprite ; test if trainer was fought (in that case skip removing the corresponding sprite) ld hl, W_MISSABLEOBJECTLIST ld de, $2 - ld a, [wcf13] + ld a, [wSpriteIndex] call IsInArray ; search for sprite ID inc hl ld a, [hl] @@ -3006,7 +3006,7 @@ CheckForEngagingTrainers:: ; 3306 (0:3306) .trainerLoop call StoreTrainerHeaderPointer ; set trainer header pointer to current trainer ld a, [de] - ld [wcf13], a ; store trainer flag's bit + ld [wSpriteIndex], a ; store trainer flag's bit ld [wTrainerHeaderFlagBit], a cp $ff ret z @@ -3028,7 +3028,7 @@ CheckForEngagingTrainers:: ; 3306 (0:3306) ld a, [hl] ; read trainer engage distance pop hl ld [wTrainerEngageDistance], a - ld a, [wcf13] + ld a, [wSpriteIndex] swap a ld [wTrainerSpriteOffset], a ; wWhichTrade predef TrainerEngage @@ -3059,11 +3059,11 @@ PreBattleSaveRegisters:: ; 3354 (0:3354) ret ; loads data of some trainer on the current map and plays pre-battle music -; [wcf13]: sprite ID of trainer who is engaged +; [wSpriteIndex]: sprite ID of trainer who is engaged EngageMapTrainer:: ; 336a (0:336a) ld hl, W_MAPSPRITEEXTRADATA ld d, $0 - ld a, [wcf13] + ld a, [wSpriteIndex] dec a add a ld e, a @@ -4708,9 +4708,9 @@ DisableAutoTextBoxDrawing:: ; 3c3f (0:3c3f) ld a,$01 AutoTextBoxDrawingCommon:: ; 3c41 (0:3c41) - ld [wcf0c],a ; control text box drawing + ld [wAutoTextBoxDrawingControl],a xor a - ld [wcc3c],a ; make DisplayTextID wait for button press + ld [wDoNotWaitForButtonPressAfterDisplayingText],a ; make DisplayTextID wait for button press ret PrintText:: ; 3c49 (0:3c49) @@ -5015,7 +5015,7 @@ IsInRestOfArray:: RestoreScreenTilesAndReloadTilePatterns:: ; 3dbe (0:3dbe) call ClearSprites ld a, $1 - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a call ReloadMapSpriteTilePatterns call LoadScreenTilesFromBuffer2 call LoadTextBoxTilePatterns @@ -5052,7 +5052,7 @@ GBPalWhiteOut:: GoPAL_SET_CF1C:: ; 3ded (0:3ded) ld b,$ff GoPAL_SET:: ; 3def (0:3def) - ld a,[wcf1b] + ld a,[wOnSGB] and a ret z predef_jump Func_71ddf diff --git a/home/audio.asm b/home/audio.asm index 8dcc0d93c1..9210924c2d 100644 --- a/home/audio.asm +++ b/home/audio.asm @@ -17,7 +17,7 @@ Func_2312:: ; 2312 (0:2312) ld c, $8 ld d, c asm_2324:: ; 2324 (0:2324) - ld a, [wd700] + ld a, [wWalkBikeSurfState] and a jr z, .asm_2343 cp $2 diff --git a/home/fade.asm b/home/fade.asm index 9b55eaf285..08e087b4b0 100644 --- a/home/fade.asm +++ b/home/fade.asm @@ -1,7 +1,7 @@ ; These routines manage gradual fading ; (e.g., entering a doorway) LoadGBPal:: - ld a, [wd35d] ;tells if cur.map is dark (requires HM5_FLASH?) + ld a, [wMapPalOffset] ;tells if cur.map is dark (requires HM5_FLASH?) ld b, a ld hl, FadePal4 ld a, l @@ -18,16 +18,16 @@ LoadGBPal:: ld [rOBP1], a ret -GBFadeOut1:: +GBFadeInFromBlack:: ld hl, FadePal1 ld b, 4 - jr GBFadeOutCommon + jr GBFadeIncCommon -GBFadeOut2:: +GBFadeOutToWhite:: ld hl, FadePal6 ld b, 3 -GBFadeOutCommon:: +GBFadeIncCommon: ld a, [hli] ld [rBGP], a ld a, [hli] @@ -37,19 +37,19 @@ GBFadeOutCommon:: ld c, 8 call DelayFrames dec b - jr nz, GBFadeOutCommon + jr nz, GBFadeIncCommon ret -GBFadeIn1:: +GBFadeOutToBlack:: ld hl, FadePal4 + 2 ld b, 4 - jr GBFadeInCommon + jr GBFadeDecCommon -GBFadeIn2:: +GBFadeInFromWhite:: ld hl, FadePal7 + 2 ld b, 3 -GBFadeInCommon:: +GBFadeDecCommon: ld a, [hld] ld [rOBP1], a ld a, [hld] @@ -59,7 +59,7 @@ GBFadeInCommon:: ld c, 8 call DelayFrames dec b - jr nz, GBFadeInCommon + jr nz, GBFadeDecCommon ret FadePal1:: db %11111111, %11111111, %11111111 diff --git a/home/init.asm b/home/init.asm index cf8f448ec7..402a402e02 100644 --- a/home/init.asm +++ b/home/init.asm @@ -105,7 +105,7 @@ rLCDC_DEFAULT EQU %11100011 xor a ld [$ffbc], a dec a - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a predef PlayIntro diff --git a/home/overworld.asm b/home/overworld.asm index a8747f2d9c..9dbfdfb764 100644 --- a/home/overworld.asm +++ b/home/overworld.asm @@ -12,11 +12,11 @@ EnterMap:: call LoadMapData callba Func_c335 ; initialize map variables ld hl, wd72c - bit 0, [hl] - jr z, .doNotCountSteps - ld a, 3 - ld [wd13c], a ; some kind of step counter (counts up to 3 steps?) -.doNotCountSteps + bit 0, [hl] ; has the player already made 3 steps since the last battle? + jr z, .skipGivingThreeStepsOfNoRandomBattles + ld a, 3 ; minimum number of steps between battles + ld [wNumberOfNoRandomBattleStepsLeft], a +.skipGivingThreeStepsOfNoRandomBattles ld hl, wd72e bit 5, [hl] ; did a battle happen immediately before this? res 5, [hl] ; unset the "battle just happened" flag @@ -24,12 +24,12 @@ EnterMap:: call nz, MapEntryAfterBattle ld hl, wd732 ld a, [hl] - and 1 << 4 | 1 << 3 - jr z, .didNotFlyOrTeleportIn + and 1 << 4 | 1 << 3 ; fly warp or dungeon warp + jr z, .didNotEnterUsingFlyWarpOrDungeonWarp res 3, [hl] - callba Func_70510 ; display fly/teleport in graphical effect + callba EnterMapAnim ; display fly/teleport in graphical effect call UpdateSprites -.didNotFlyOrTeleportIn +.didNotEnterUsingFlyWarpOrDungeonWarp callba CheckForceBikeOrSurf ; handle currents in SF islands and forced bike riding in cycling road ld hl, wd72d res 5, [hl] @@ -61,8 +61,8 @@ OverworldLoopLessDelay:: res 3,[hl] jp nz,WarpFound2 ld a,[wd732] - and a,$18 - jp nz,HandleFlyOrTeleportAway + and a,1 << 4 | 1 << 3 ; fly warp or dungeon warp + jp nz,HandleFlyWarpOrDungeonWarp ld a,[W_CUROPPONENT] and a jp nz,.newBattle @@ -98,8 +98,8 @@ OverworldLoopLessDelay:: and a jp z,OverworldLoop .displayDialogue - predef Func_c586 ; check what is in front of the player - call UpdateSprites ; move sprites + predef GetTileAndCoordsInFrontOfPlayer + call UpdateSprites ld a,[wFlags_0xcd60] bit 2,a jr nz,.checkForOpponent @@ -117,8 +117,8 @@ OverworldLoopLessDelay:: jr z,.changeMap predef LoadSAV ld a,[W_CURMAP] - ld [wd71a],a - call Func_62ce + ld [wDestinationMap],a + call SpecialWarpIn ld a,[W_CURMAP] call SwitchToMapRomBank ; switch to the ROM bank of the current map ld hl,W_CURMAPTILESET @@ -133,7 +133,7 @@ OverworldLoopLessDelay:: .noDirectionButtonsPressed ld hl,wFlags_0xcd60 res 2,[hl] - call UpdateSprites ; move sprites + call UpdateSprites ld a,$01 ld [wcc4b],a ld a,[wd528] ; the direction that was pressed last time @@ -225,18 +225,20 @@ OverworldLoopLessDelay:: .noDirectionChange ld a,[wd52a] ; current direction ld [wd528],a ; save direction - call UpdateSprites ; move sprites - ld a,[wd700] + call UpdateSprites + ld a,[wWalkBikeSurfState] cp a,$02 ; surfing jr z,.surfing ; not surfing call CollisionCheckOnLand jr nc,.noCollision +; collision occurred push hl ld hl,wd736 - bit 2,[hl] + bit 2,[hl] ; standing on warp flag pop hl jp z,OverworldLoop +; collision occurred while standing on a warp push hl call ExtraWarpCheck ; sets carry if there is a potential to warp pop hl @@ -259,7 +261,7 @@ OverworldLoopLessDelay:: .moveAhead2 ld hl,wFlags_0xcd60 res 2,[hl] - ld a,[wd700] + ld a,[wWalkBikeSurfState] dec a ; riding a bike? jr nz,.normalPlayerSpriteAdvancement ld a,[wd736] @@ -276,16 +278,16 @@ OverworldLoopLessDelay:: bit 7,a jr nz,.doneStepCounting ; if button presses are being simulated, don't count steps ; step counting - ld hl,wd13b ; step counter + ld hl,wStepCounter dec [hl] ld a,[wd72c] bit 0,a jr z,.doneStepCounting - ld hl,wd13c + ld hl,wNumberOfNoRandomBattleStepsLeft dec [hl] jr nz,.doneStepCounting ld hl,wd72c - res 0,[hl] + res 0,[hl] ; indicate that the player has stepped thrice since the last battle .doneStepCounting ld a,[wd790] bit 7,a ; in the safari zone? @@ -298,14 +300,14 @@ OverworldLoopLessDelay:: ld a,[W_ISINBATTLE] and a jp nz,CheckWarpsNoCollision - predef Func_c69c ; decrement HP of poisoned pokemon + predef ApplyOutOfBattlePoisonDamage ; also increment daycare mon exp ld a,[wd12d] and a jp nz,HandleBlackOut ; if all pokemon fainted .newBattle call NewBattle ld hl,wd736 - res 2,[hl] + res 2,[hl] ; standing on warp flag jp nc,CheckWarpsNoCollision ; check for warps if there was no battle .battleOccurred ld hl,wd72d @@ -316,7 +318,7 @@ OverworldLoopLessDelay:: set 5,[hl] set 6,[hl] xor a - ld [hJoyHeld],a ; clear joypad state + ld [hJoyHeld],a ld a,[W_CURMAP] cp a,CINNABAR_GYM jr nz,.notCinnabarGym @@ -327,8 +329,8 @@ OverworldLoopLessDelay:: set 5,[hl] ld a,[W_CURMAP] cp a,OAKS_LAB - jp z,.noFaintCheck - callab AnyPartyAlive ; check if all the player's pokemon fainted + jp z,.noFaintCheck ; no blacking out if the player lost to the rival in Oak's lab + callab AnyPartyAlive ld a,d and a jr z,.allPokemonFainted @@ -355,7 +357,7 @@ NewBattle:: ; 0683 (0:0683) jr nz,.noBattle ld b, BANK(InitBattle) ld hl, InitBattle - jp Bankswitch ; determines if a battle will occur and runs the battle if so + jp Bankswitch .noBattle and a ret @@ -368,25 +370,25 @@ BikeSpeedup:: ; 06a0 (0:06a0) ld a,[W_CURMAP] cp a,ROUTE_17 ; Cycling Road jr nz,.goFaster - ld a,[hJoyHeld] ; current joypad state - and a,%01110000 ; bit mask for up, left, right buttons + ld a,[hJoyHeld] + and a,D_UP | D_LEFT | D_RIGHT ret nz .goFaster jp AdvancePlayerSprite ; check if the player has stepped onto a warp after having not collided CheckWarpsNoCollision:: ; 06b4 (0:06b4) - ld a,[wd3ae] ; number of warps + ld a,[wNumberOfWarps] and a jp z,CheckMapConnections - ld a,[wd3ae] ; number of warps - ld b,$00 + ld a,[wNumberOfWarps] + ld b,0 ld c,a ld a,[W_YCOORD] ld d,a ld a,[W_XCOORD] ld e,a - ld hl,wd3af ; start of warp entries + ld hl,wWarpEntries CheckWarpsNoCollisionLoop:: ; 06cc (0:06cc) ld a,[hli] ; check if the warp's Y position matches cp d @@ -398,14 +400,14 @@ CheckWarpsNoCollisionLoop:: ; 06cc (0:06cc) push hl push bc ld hl,wd736 - set 2,[hl] - callba Func_c49d ; check if the player sprite is standing on a "door" tile + set 2,[hl] ; standing on warp flag + callba IsPlayerStandingOnDoorTileOrWarpTile pop bc pop hl - jr c,WarpFound1 ; if it is, go to 0735 + jr c,WarpFound1 ; jump if standing on door or warp push hl push bc - call ExtraWarpCheck ; sets carry if the warp is confirmed + call ExtraWarpCheck pop bc pop hl jr nc,CheckWarpsNoCollisionRetry2 @@ -418,16 +420,16 @@ CheckWarpsNoCollisionLoop:: ; 06cc (0:06cc) call Joypad pop bc pop de - ld a,[hJoyHeld] ; current joypad state - and a,%11110000 ; bit mask for directional buttons + ld a,[hJoyHeld] + and a,D_DOWN | D_UP | D_LEFT | D_RIGHT jr z,CheckWarpsNoCollisionRetry2 ; if directional buttons aren't being pressed, do not pass through the warp jr WarpFound1 ; check if the player has stepped onto a warp after having collided CheckWarpsCollision:: ; 0706 (0:0706) - ld a,[wd3ae] ; number of warps + ld a,[wNumberOfWarps] ld c,a - ld hl,wd3af ; start of warp entries + ld hl,wWarpEntries .loop ld a,[hli] ; Y coordinate of warp ld b,a @@ -440,7 +442,7 @@ CheckWarpsCollision:: ; 0706 (0:0706) cp b jr nz,.retry2 ld a,[hli] - ld [wd42f],a ; save target warp ID + ld [wDestinationWarpID],a ld a,[hl] ld [$ff8b],a ; save target map jr WarpFound2 @@ -462,12 +464,12 @@ CheckWarpsNoCollisionRetry2:: ; 0730 (0:0730) WarpFound1:: ; 0735 (0:0735) ld a,[hli] - ld [wd42f],a ; save target warp ID + ld [wDestinationWarpID],a ld a,[hli] ld [$ff8b],a ; save target map WarpFound2:: ; 073c (0:073c) - ld a,[wd3ae] ; number of warps + ld a,[wNumberOfWarps] sub c ld [wd73b],a ; save ID of used warp ld a,[W_CURMAP] @@ -484,8 +486,8 @@ WarpFound2:: ; 073c (0:073c) cp a,ROCK_TUNNEL_1 jr nz,.notRockTunnel ld a,$06 - ld [wd35d],a - call GBFadeIn1 + ld [wMapPalOffset],a + call GBFadeOutToBlack .notRockTunnel call PlayMapChangeSound jr .done @@ -496,16 +498,16 @@ WarpFound2:: ; 073c (0:073c) jr z,.goBackOutside ; if not going back to the previous map ld [W_CURMAP],a ; current map number - callba Func_70787 ; check if the warp was a Silph Co. teleporter + callba IsPlayerStandingOnWarpPadOrHole ld a,[wcd5b] - dec a - jr nz,.notTeleporter -; if it's a Silph Co. teleporter + dec a ; is the player on a warp pad? + jr nz,.notWarpPad +; if the player is on a warp pad ld hl,wd732 set 3,[hl] call LeaveMapAnim jr .skipMapChangeSound -.notTeleporter +.notWarpPad call PlayMapChangeSound .skipMapChangeSound ld hl,wd736 @@ -517,7 +519,7 @@ WarpFound2:: ; 073c (0:073c) ld [W_CURMAP],a call PlayMapChangeSound xor a - ld [wd35d],a + ld [wMapPalOffset],a .done ld hl,wd736 set 0,[hl] ; have the player's sprite step out from the door (if there is one) @@ -562,9 +564,9 @@ CheckMapConnections:: ; 07ba (0:07ba) jr nz,.pointerAdjustmentLoop1 .savePointer1 ld a,l - ld [wd35f],a ; pointer to upper left corner of current tile block map section + ld [wCurrentTileBlockMapViewPointer],a ; pointer to upper left corner of current tile block map section ld a,h - ld [wd360],a + ld [wCurrentTileBlockMapViewPointer + 1],a jp .loadNewMap .checkEastMap ld b,a @@ -598,9 +600,9 @@ CheckMapConnections:: ; 07ba (0:07ba) jr nz,.pointerAdjustmentLoop2 .savePointer2 ld a,l - ld [wd35f],a ; pointer to upper left corner of current tile block map section + ld [wCurrentTileBlockMapViewPointer],a ; pointer to upper left corner of current tile block map section ld a,h - ld [wd360],a + ld [wCurrentTileBlockMapViewPointer + 1],a jp .loadNewMap .checkNorthMap ld a,[W_YCOORD] @@ -624,9 +626,9 @@ CheckMapConnections:: ; 07ba (0:07ba) srl c add hl,bc ld a,l - ld [wd35f],a ; pointer to upper left corner of current tile block map section + ld [wCurrentTileBlockMapViewPointer],a ; pointer to upper left corner of current tile block map section ld a,h - ld [wd360],a + ld [wCurrentTileBlockMapViewPointer + 1],a jp .loadNewMap .checkSouthMap ld b,a @@ -651,9 +653,9 @@ CheckMapConnections:: ; 07ba (0:07ba) srl c add hl,bc ld a,l - ld [wd35f],a ; pointer to upper left corner of current tile block map section + ld [wCurrentTileBlockMapViewPointer],a ; pointer to upper left corner of current tile block map section ld a,h - ld [wd360],a + ld [wCurrentTileBlockMapViewPointer + 1],a .loadNewMap ; load the connected map that was entered call LoadMapHeader call Func_2312 ; music @@ -678,10 +680,10 @@ PlayMapChangeSound:: ; 08c9 (0:08c9) ld a,(SFX_02_5c - SFX_Headers_02) / 3 .playSound call PlaySound - ld a,[wd35d] + ld a,[wMapPalOffset] and a ret nz - jp GBFadeIn1 + jp GBFadeOutToBlack CheckIfInOutsideMap:: ; 08e1 (0:08e1) ; If the player is in an outside map (a town or route), set the z flag @@ -719,37 +721,37 @@ ExtraWarpCheck:: ; 08e9 (0:08e9) cp PLATEAU ; Indigo Plateau tileset jr z, .useFunction2 .useFunction1 - ld hl, Func_c3ff + ld hl, IsPlayerFacingEdgeOfMap jr .doBankswitch .useFunction2 - ld hl, Func_c44e + ld hl, IsWarpTileInFrontOfPlayer .doBankswitch - ld b, BANK(Func_c44e) + ld b, BANK(IsWarpTileInFrontOfPlayer) jp Bankswitch MapEntryAfterBattle:: ; 091f (0:091f) - callba Func_c35f ; function that appears to disable warp testing after collisions if the player is standing on a warp - ld a,[wd35d] + callba IsPlayerStandingOnWarp ; for enabling warp testing after collisions + ld a,[wMapPalOffset] and a - jp z,GBFadeIn2 + jp z,GBFadeInFromWhite jp LoadGBPal HandleBlackOut:: ; For when all the player's pokemon faint. ; Does not print the "blacked out" message. - call GBFadeIn1 + call GBFadeOutToBlack ld a, $08 call StopMusic ld hl, wd72e res 5, [hl] - ld a, Bank(Func_40b0) ; also Bank(Func_62ce) and Bank(Func_5d5f) + ld a, Bank(ResetStatusAndHalveMoneyOnBlackout) ; also Bank(SpecialWarpIn) and Bank(SpecialEnterMap) ld [H_LOADEDROMBANK], a ld [MBC3RomBank], a - call Func_40b0 - call Func_62ce + call ResetStatusAndHalveMoneyOnBlackout + call SpecialWarpIn call Func_2312 - jp Func_5d5f + jp SpecialEnterMap StopMusic:: ld [wMusicHeaderPointer], a @@ -762,23 +764,23 @@ StopMusic:: jr nz, .wait jp StopAllSounds -HandleFlyOrTeleportAway:: +HandleFlyWarpOrDungeonWarp:: call UpdateSprites call Delay3 xor a ld [wBattleResult], a - ld [wd700], a + ld [wWalkBikeSurfState], a ld [W_ISINBATTLE], a - ld [wd35d], a + ld [wMapPalOffset], a ld hl, wd732 - set 2, [hl] - res 5, [hl] + set 2, [hl] ; fly warp or dungeon warp + res 5, [hl] ; forced to ride bike call LeaveMapAnim - ld a, Bank(Func_62ce) + ld a, Bank(SpecialWarpIn) ld [H_LOADEDROMBANK], a ld [$2000], a - call Func_62ce - jp Func_5d5f + call SpecialWarpIn + jp SpecialEnterMap LeaveMapAnim:: ld b, BANK(_LeaveMapAnim) @@ -792,7 +794,7 @@ LoadPlayerSpriteGraphics:: ; 1: biking ; 2: surfing - ld a, [wd700] + ld a, [wWalkBikeSurfState] dec a jr z, .ridingBike @@ -809,12 +811,12 @@ LoadPlayerSpriteGraphics:: .startWalking xor a - ld [wd700], a - ld [wd11a], a + ld [wWalkBikeSurfState], a + ld [wWalkBikeSurfStateCopy], a jp LoadWalkingPlayerSpriteGraphics .determineGraphics - ld a, [wd700] + ld a, [wWalkBikeSurfState] and a jp z, LoadWalkingPlayerSpriteGraphics dec a @@ -1065,7 +1067,7 @@ IsSpriteOrSignInFrontOfPlayer:: ; 0b23 (0:0b23) and a jr z,.extendRangeOverCounter ; if there are signs - predef Func_c586 ; get the coordinates in front of the player in de + predef GetTileAndCoordsInFrontOfPlayer ; get the coordinates in front of the player in de ld hl,wd4b1 ; start of sign coordinates ld a,[wd4b0] ; number of signs in the map ld b,a @@ -1099,7 +1101,7 @@ IsSpriteOrSignInFrontOfPlayer:: ; 0b23 (0:0b23) jr nz,.signLoop ; check if the player is front of a counter in a pokemon center, pokemart, etc. and if so, extend the range at which he can talk to the NPC .extendRangeOverCounter - predef Func_c586 ; get the tile in front of the player in c + predef GetTileAndCoordsInFrontOfPlayer ; get the tile in front of the player in c ld hl,W_TILESETTALKINGOVERTILES ; list of tiles that extend talking range (counter tiles) ld b,$03 ld d,$20 ; talking range in pixels (long range) @@ -1239,8 +1241,8 @@ CollisionCheckOnLand:: ; 0bd1 (0:0bd1) ; function that checks if the tile in front of the player is passable ; clears carry if it is, sets carry if not CheckTilePassable:: ; 0c10 (0:0c10) - predef Func_c586 ; get tile in front of player - ld a,[wcfc6] ; tile in front of player + predef GetTileAndCoordsInFrontOfPlayer ; get tile in front of player + ld a,[wTileInFrontOfPlayer] ; tile in front of player ld c,a ld hl,W_TILESETCOLLISIONPTR ; pointer to list of passable tiles ld a,[hli] @@ -1263,7 +1265,7 @@ CheckTilePassable:: ; 0c10 (0:0c10) ; sets carry if there is a collision and unsets carry if not CheckForJumpingAndTilePairCollisions:: ; 0c2a (0:0c2a) push hl - predef Func_c586 ; get the tile in front of the player + predef GetTileAndCoordsInFrontOfPlayer ; get the tile in front of the player push de push bc callba HandleLedges ; check if the player is trying to jump a ledge @@ -1276,12 +1278,12 @@ CheckForJumpingAndTilePairCollisions:: ; 0c2a (0:0c2a) ret nz ; if not jumping -Func_c44:: ; 0c44 (0:0c44) +CheckForTilePairCollisions2:: ; 0c44 (0:0c44) aCoord 8, 9 ; tile the player is on ld [wcf0e],a CheckForTilePairCollisions:: ; 0c4a (0:0c4a) - ld a,[wcfc6] ; tile in front of the player + ld a,[wTileInFrontOfPlayer] ld c,a .tilePairCollisionLoop ld a,[W_CURMAPTILESET] ; tileset number @@ -1357,9 +1359,9 @@ LoadCurrentMapView:: ; 0caa (0:0caa) ld a,[W_TILESETBANK] ; tile data ROM bank ld [H_LOADEDROMBANK],a ld [$2000],a ; switch to ROM bank that contains tile data - ld a,[wd35f] ; address of upper left corner of current map view + ld a,[wCurrentTileBlockMapViewPointer] ; address of upper left corner of current map view ld e,a - ld a,[wd360] + ld a,[wCurrentTileBlockMapViewPointer + 1] ld d,a ld hl,wTileMapBackup ld b,$05 @@ -1531,9 +1533,9 @@ AdvancePlayerSprite:: ; 0d27 (0:0d27) ; moved into the tile block to the east xor a ld [hl],a - ld hl,wd4e3 + ld hl,wXOffsetSinceLastSpecialWarp inc [hl] - ld de,wd35f + ld de,wCurrentTileBlockMapViewPointer call MoveTileBlockMapPointerEast jr .updateMapView .checkForMoveToWestBlock @@ -1542,9 +1544,9 @@ AdvancePlayerSprite:: ; 0d27 (0:0d27) ; moved into the tile block to the west ld a,$01 ld [hl],a - ld hl,wd4e3 + ld hl,wXOffsetSinceLastSpecialWarp dec [hl] - ld de,wd35f + ld de,wCurrentTileBlockMapViewPointer call MoveTileBlockMapPointerWest jr .updateMapView .adjustYCoordWithinBlock @@ -1557,9 +1559,9 @@ AdvancePlayerSprite:: ; 0d27 (0:0d27) ; moved into the tile block to the south xor a ld [hl],a - ld hl,wd4e2 + ld hl,wYOffsetSinceLastSpecialWarp inc [hl] - ld de,wd35f + ld de,wCurrentTileBlockMapViewPointer ld a,[W_CURMAPWIDTH] call MoveTileBlockMapPointerSouth jr .updateMapView @@ -1569,9 +1571,9 @@ AdvancePlayerSprite:: ; 0d27 (0:0d27) ; moved into the tile block to the north ld a,$01 ld [hl],a - ld hl,wd4e2 + ld hl,wYOffsetSinceLastSpecialWarp dec [hl] - ld de,wd35f + ld de,wCurrentTileBlockMapViewPointer ld a,[W_CURMAPWIDTH] call MoveTileBlockMapPointerNorth .updateMapView @@ -1905,8 +1907,8 @@ CollisionCheckOnWater:: ; 0fb7 (0:0fb7) ld hl,TilePairCollisionsWater call CheckForJumpingAndTilePairCollisions jr c,.collision - predef Func_c586 ; get tile in front of player (puts it in c and [wcfc6]) - ld a,[wcfc6] ; tile in front of player + predef GetTileAndCoordsInFrontOfPlayer ; get tile in front of player (puts it in c and [wTileInFrontOfPlayer]) + ld a,[wTileInFrontOfPlayer] ; tile in front of player cp a,$14 ; water tile jr z,.noCollision ; keep surfing if it's a water tile cp a,$32 ; either the left tile of the S.S. Anne boarding platform or the tile on eastern coastlines (depending on the current tileset) @@ -1941,7 +1943,7 @@ CollisionCheckOnWater:: ; 0fb7 (0:0fb7) ret .stopSurfing xor a - ld [wd700],a + ld [wWalkBikeSurfState],a call LoadPlayerSpriteGraphics call PlayDefaultMusic jr .noCollision @@ -2089,12 +2091,12 @@ LoadMapHeader:: ; 107c (0:107c) ld a,[hli] ld [de],a ; save background tile ID .loadWarpData - ld a,[hli] ; number of warps - ld [wd3ae],a ; save the number of warps - and a ; are there any warps? - jr z,.loadSignData ; if not, skip this + ld a,[hli] + ld [wNumberOfWarps],a + and a + jr z,.loadSignData ld c,a - ld de,wd3af ; base address of warps + ld de,wWarpEntries .warpLoop ; one warp per loop iteration ld b,$04 .warpInnerLoop @@ -2258,8 +2260,8 @@ LoadMapHeader:: ; 107c (0:107c) dec b jp nz,.loadSpriteLoop .finishUp - predef Func_c754 ; load tileset data - callab LoadWildData ; load wild pokemon data + predef LoadTilesetHeader + callab LoadWildData pop hl ; restore hl from before going to the warp/sign/sprite data (this value was saved for seemingly no purpose) ld a,[W_CURMAPHEIGHT] ; map height in 4x4 tile blocks add a ; double it @@ -2312,7 +2314,7 @@ LoadMapData:: ; 1241 (0:1241) ld [$ffae],a ld [wWalkCounter],a ld [wd119],a - ld [wd11a],a + ld [wWalkBikeSurfStateCopy],a ld [W_SPRITESETID],a call LoadTextBoxTilePatterns call LoadMapHeader @@ -2341,13 +2343,13 @@ LoadMapData:: ; 1241 (0:1241) dec b jr nz,.vramCopyLoop ld a,$01 - ld [wcfcb],a + ld [wUpdateSpritesEnabled],a call EnableLCD ld b,$09 call GoPAL_SET call LoadPlayerSpriteGraphics ld a,[wd732] - and a,$18 ; did the player fly or teleport in? + and a,1 << 4 | 1 << 3 ; fly warp or dungeon warp jr nz,.restoreRomBank ld a,[W_FLAGS_D733] bit 1,a diff --git a/home/predef.asm b/home/predef.asm index 1777d09f67..8efe30003d 100644 --- a/home/predef.asm +++ b/home/predef.asm @@ -7,7 +7,7 @@ Predef:: ld [wPredefID], a ; A hack for LoadDestinationWarpPosition. - ; See Func_c754 (predef $19). + ; See LoadTilesetHeader (predef $19). ld a, [H_LOADEDROMBANK] ld [wPredefParentBank], a diff --git a/main.asm b/main.asm index a64d92b75b..22721cdb6c 100755 --- a/main.asm +++ b/main.asm @@ -19,13 +19,13 @@ SECTION "bank1",ROMX,BANK[$1] INCLUDE "data/facing.asm" -Func_40b0:: +ResetStatusAndHalveMoneyOnBlackout:: ; Reset player status on blackout. xor a ld [wBattleResult], a - ld [wd700], a + ld [wWalkBikeSurfState], a ld [W_ISINBATTLE], a - ld [wd35d], a + ld [wMapPalOffset], a ld [wNPCMovementScriptFunctionNum], a ld [hJoyHeld], a ld [wNPCMovementScriptPointerTableNum], a @@ -578,7 +578,7 @@ TestBattle: ; When the battle ends, ; do it all again. ld a, 1 - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a ld [H_AUTOBGTRANSFERENABLED], a jr .loop @@ -597,19 +597,20 @@ INCLUDE "engine/menu/main_menu.asm" INCLUDE "engine/oak_speech.asm" -Func_62ce: ; 62ce (1:62ce) - call Func_62ff - predef Func_c754 +SpecialWarpIn: ; 62ce (1:62ce) + call LoadSpecialWarpData + predef LoadTilesetHeader ld hl,wd732 - bit 2,[hl] + bit 2,[hl] ; dungeon warp or fly warp? res 2,[hl] jr z,.next - ld a,[wd71a] +; if dungeon warp or fly warp + ld a,[wDestinationMap] jr .next2 .next bit 1,[hl] jr z,.next3 - call Func_64ea + call EmptyFunc .next3 ld a,0 .next2 @@ -620,125 +621,128 @@ Func_62ce: ; 62ce (1:62ce) ld a,b .next4 ld hl,wd732 - bit 4,[hl] + bit 4,[hl] ; dungeon warp? ret nz +; if not dungeon warp ld [wLastMap],a ret -Func_62ff: ; 62ff (1:62ff) +; gets the map ID, tile block map view pointer, tileset, and coordinates +LoadSpecialWarpData: ; 62ff (1:62ff) ld a, [wd72d] cp BATTLE_CENTER - jr nz, .asm_6314 - ld hl, BattleCenterSpec1 ; $6428 + jr nz, .notBattleCenter + ld hl, BattleCenterSpec1 ld a, [$ffaa] cp $2 - jr z, .asm_6334 - ld hl, BattleCenterSpec2 ; $6430 - jr .asm_6334 -.asm_6314 + jr z, .copyWarpData + ld hl, BattleCenterSpec2 + jr .copyWarpData +.notBattleCenter cp TRADE_CENTER - jr nz, .asm_6326 - ld hl, TradeCenterSpec1 ; $6438 + jr nz, .notTradeCenter + ld hl, TradeCenterSpec1 ld a, [$ffaa] cp $2 - jr z, .asm_6334 - ld hl, TradeCenterSpec2 ; $6440 - jr .asm_6334 -.asm_6326 + jr z, .copyWarpData + ld hl, TradeCenterSpec2 + jr .copyWarpData +.notTradeCenter ld a, [wd732] bit 1, a - jr nz, .asm_6346 + jr nz, .notFirstMap bit 2, a - jr nz, .asm_6346 - ld hl, FirstMapSpec ; $6420 -.asm_6334 - ld de, W_CURMAP ; W_CURMAP + jr nz, .notFirstMap + ld hl, FirstMapSpec +.copyWarpData + ld de, W_CURMAP ld c, $7 -.asm_6339 +.copyWarpDataLoop ld a, [hli] ld [de], a inc de dec c - jr nz, .asm_6339 + jr nz, .copyWarpDataLoop ld a, [hli] - ld [W_CURMAPTILESET], a ; W_CURMAPTILESET + ld [W_CURMAPTILESET], a xor a - jr .asm_63b3 -.asm_6346 + jr .done +.notFirstMap ld a, [wLastMap] ld hl, wd732 - bit 4, [hl] - jr nz, .asm_635b - bit 6, [hl] + bit 4, [hl] ; used dungeon warp (jumped down hole/waterfall)? + jr nz, .usedDunegonWarp + bit 6, [hl] ; return to last pokemon center (or player's house)? res 6, [hl] - jr z, .asm_638e + jr z, .otherDestination +; return to last pokemon center or player's house ld a, [wLastBlackoutMap] - jr .asm_6391 -.asm_635b + jr .usedFlyWarp +.usedDunegonWarp ld hl, wd72d res 4, [hl] - ld a, [wd71d] + ld a, [wDungeonWarpDestinationMap] ld b, a - ld [W_CURMAP], a ; W_CURMAP - ld a, [wd71e] + ld [W_CURMAP], a + ld a, [wWhichDungeonWarp] ld c, a - ld hl, DungeonWarpList ; $63bf + ld hl, DungeonWarpList ld de, $0 ld a, $6 ld [wd12f], a -.asm_6376 +.dungeonWarpListLoop ld a, [hli] cp b - jr z, .asm_637d + jr z, .matchedDungeonWarpDestinationMap inc hl - jr .asm_6381 -.asm_637d + jr .nextDungeonWarp +.matchedDungeonWarpDestinationMap ld a, [hli] cp c - jr z, .asm_6388 -.asm_6381 + jr z, .matchedDungeonWarpID +.nextDungeonWarp ld a, [wd12f] add e ld e, a - jr .asm_6376 -.asm_6388 - ld hl, DungeonWarpData ; $63d8 + jr .dungeonWarpListLoop +.matchedDungeonWarpID + ld hl, DungeonWarpData add hl, de - jr .asm_63a4 -.asm_638e - ld a, [wd71a] -.asm_6391 + jr .copyWarpData2 +.otherDestination + ld a, [wDestinationMap] +.usedFlyWarp ld b, a - ld [W_CURMAP], a ; W_CURMAP - ld hl, FlyWarpDataPtr ; $6448 -.asm_6398 + ld [W_CURMAP], a + ld hl, FlyWarpDataPtr +.flyWarpDataPtrLoop ld a, [hli] inc hl cp b - jr z, .asm_63a1 + jr z, .foundFlyWarpMatch inc hl inc hl - jr .asm_6398 -.asm_63a1 + jr .flyWarpDataPtrLoop +.foundFlyWarpMatch ld a, [hli] ld h, [hl] ld l, a -.asm_63a4 - ld de, wd35f +.copyWarpData2 + ld de, wCurrentTileBlockMapViewPointer ld c, $6 -.asm_63a9 +.copyWarpDataLoop2 ld a, [hli] ld [de], a inc de dec c - jr nz, .asm_63a9 - xor a - ld [W_CURMAPTILESET], a ; W_CURMAPTILESET -.asm_63b3 - ld [wd4e2], a - ld [wd4e3], a - ld a, $ff - ld [wd42f], a + jr nz, .copyWarpDataLoop2 + xor a ; OVERWORLD + ld [W_CURMAPTILESET], a +.done + ld [wYOffsetSinceLastSpecialWarp], a + ld [wXOffsetSinceLastSpecialWarp], a + ld a, $ff ; the player's coordinates have already been updated using a special warp, so don't use any of the normal warps + ld [wDestinationWarpID], a ret INCLUDE "data/special_warps.asm" @@ -774,7 +778,7 @@ IshiharaTeam: ; 64df (1:64df) db ARTICUNO,57 db $FF -Func_64ea: ; 64ea (1:64ea) +EmptyFunc: ; 64ea (1:64ea) ret INCLUDE "engine/menu/naming_screen.asm" @@ -989,7 +993,7 @@ SafariZoneRestHouses: DisplayTextIDInit: ; 7096 (1:7096) xor a ld [wListMenuID],a - ld a,[wcf0c] + ld a,[wAutoTextBoxDrawingControl] bit 0,a jr nz,.skipDrawingTextBoxBorder ld a,[$ff8c] ; text ID (or sprite ID) @@ -2005,7 +2009,7 @@ Func_7c18: ; 7c18 (1:7c18) ld hl, wPokedexSeen predef FlagActionPredef ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ret @@ -2023,7 +2027,7 @@ Func_c335: ; c335 (3:4335) ld [rWY], a ; $ff4a xor a ld [H_AUTOBGTRANSFERENABLED], a ; $ffba - ld [wd13b], a + ld [wStepCounter], a ld [W_LONEATTACKNO], a ; W_GYMLEADERNO ld [hJoyPressed], a ld [hJoyReleased], a @@ -2038,36 +2042,37 @@ Func_c335: ; c335 (3:4335) call FillMemory ret -Func_c35f: ; c35f (3:435f) - ld a, [wd3ae] +; only used for setting bit 2 of wd736 upon entering a new map +IsPlayerStandingOnWarp: ; c35f (3:435f) + ld a, [wNumberOfWarps] and a ret z ld c, a - ld hl, wd3af -.asm_c368 - ld a, [W_YCOORD] ; wd361 + ld hl, wWarpEntries +.loop + ld a, [W_YCOORD] cp [hl] - jr nz, .asm_c383 + jr nz, .nextWarp1 inc hl - ld a, [W_XCOORD] ; wd362 + ld a, [W_XCOORD] cp [hl] - jr nz, .asm_c384 + jr nz, .nextWarp2 inc hl - ld a, [hli] - ld [wd42f], a - ld a, [hl] - ld [H_DOWNARROWBLINKCNT1], a ; $ff8b + ld a, [hli] ; target warp + ld [wDestinationWarpID], a + ld a, [hl] ; target map + ld [$ff8b], a ld hl, wd736 - set 2, [hl] + set 2, [hl] ; standing on warp flag ret -.asm_c383 +.nextWarp1 inc hl -.asm_c384 +.nextWarp2 inc hl inc hl inc hl dec c - jr nz, .asm_c368 + jr nz, .loop ret CheckForceBikeOrSurf: ; c38b (3:438b) @@ -2107,8 +2112,8 @@ CheckForceBikeOrSurf: ; c38b (3:438b) ld hl, wd732 set 5, [hl] ld a, $1 - ld [wd700], a - ld [wd11a], a + ld [wWalkBikeSurfState], a + ld [wWalkBikeSurfStateCopy], a jp ForceBikeOrSurf .incorrectMap inc hl @@ -2117,30 +2122,30 @@ CheckForceBikeOrSurf: ; c38b (3:438b) jr .loop .forceSurfing ld a, $2 - ld [wd700], a - ld [wd11a], a + ld [wWalkBikeSurfState], a + ld [wWalkBikeSurfStateCopy], a jp ForceBikeOrSurf INCLUDE "data/force_bike_surf.asm" -Func_c3ff: ; c3ff (3:43ff) +IsPlayerFacingEdgeOfMap: ; c3ff (3:43ff) push hl push de push bc - ld a, [wSpriteStateData1 + 9] + ld a, [wSpriteStateData1 + 9] ; player sprite's facing direction srl a ld c, a ld b, $0 - ld hl, PointerTable_c422 ; $4422 + ld hl, .functionPointerTable add hl, bc ld a, [hli] ld h, [hl] ld l, a - ld a, [W_YCOORD] ; wd361 + ld a, [W_YCOORD] ld b, a - ld a, [W_XCOORD] ; wd362 + ld a, [W_XCOORD] ld c, a - ld de, .asm_c41e ; $441e + ld de, .asm_c41e push de jp [hl] .asm_c41e @@ -2149,34 +2154,34 @@ Func_c3ff: ; c3ff (3:43ff) pop hl ret -PointerTable_c422: ; c422 (3:4422) - dw .asm_c42a - dw .asm_4434 - dw .asm_443A - dw .asm_4440 +.functionPointerTable + dw .facingDown + dw .facingUp + dw .facingLeft + dw .facingRight -.asm_c42a - ld a, [W_CURMAPHEIGHT] ; wd368 +.facingDown + ld a, [W_CURMAPHEIGHT] add a dec a cp b jr z, .setCarry jr .resetCarry -.asm_4434 +.facingUp ld a, b and a jr z, .setCarry jr .resetCarry -.asm_443A +.facingLeft ld a, c and a jr z, .setCarry jr .resetCarry -.asm_4440 - ld a, [W_CURMAPWIDTH] ; wd369 +.facingRight + ld a, [W_CURMAPWIDTH] add a dec a cp c @@ -2189,71 +2194,71 @@ PointerTable_c422: ; c422 (3:4422) scf ret -Func_c44e: ; c44e (3:444e) +IsWarpTileInFrontOfPlayer: ; c44e (3:444e) push hl push de push bc - call Func_c589 - ld a, [W_CURMAP] ; W_CURMAP + call _GetTileAndCoordsInFrontOfPlayer + ld a, [W_CURMAP] cp SS_ANNE_5 jr z, .ssAnne5 - ld a, [wSpriteStateData1 + 9] + ld a, [wSpriteStateData1 + 9] ; player sprite's facing direction srl a ld c, a - ld b, $0 - ld hl, .pointerTable_c477 ; $4477 + ld b, 0 + ld hl, .warpTileListPointers add hl, bc ld a, [hli] ld h, [hl] ld l, a - ld a, [wcfc6] + ld a, [wTileInFrontOfPlayer] ld de, $1 call IsInArray -.asm_c473 +.done pop bc pop de pop hl ret -.pointerTable_c477: ; c477 (3:4477) - dw .arrayData_c47f - dw .arrayData_c487 - dw .arrayData_c48a - dw .arrayData_c48d +.warpTileListPointers: ; c477 (3:4477) + dw .facingDownWarpTiles + dw .facingUpWarpTiles + dw .facingLeftWarpTiles + dw .facingRightWarpTiles -.arrayData_c47f +.facingDownWarpTiles db $01,$12,$17,$3D,$04,$18,$33,$FF -.arrayData_c487 +.facingUpWarpTiles db $01,$5C,$FF -.arrayData_c48a +.facingLeftWarpTiles db $1A,$4B,$FF -.arrayData_c48d +.facingRightWarpTiles db $0F,$4E,$FF .ssAnne5 - ld a, [wcfc6] + ld a, [wTileInFrontOfPlayer] cp $15 - jr nz, .asm_c49a + jr nz, .notSSAnne5Warp scf - jr .asm_c473 -.asm_c49a + jr .done +.notSSAnne5Warp and a - jr .asm_c473 + jr .done -Func_c49d: ; c49d (3:449d) +IsPlayerStandingOnDoorTileOrWarpTile: ; c49d (3:449d) push hl push de push bc - callba IsPlayerStandingOnDoor - jr c, .asm_c4c8 - ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET + callba IsPlayerStandingOnDoorTile + jr c, .done + ld a, [W_CURMAPTILESET] add a ld c, a ld b, $0 - ld hl, WarpTileIDPointers ; $44cc + ld hl, WarpTileIDPointers add hl, bc ld a, [hli] ld h, [hl] @@ -2261,10 +2266,10 @@ Func_c49d: ; c49d (3:449d) ld de, $1 aCoord 8, 9 call IsInArray - jr nc, .asm_c4c8 + jr nc, .done ld hl, wd736 res 2, [hl] -.asm_c4c8 +.done pop bc pop de pop hl @@ -2310,223 +2315,237 @@ SafariSteps: ; c579 (3:4579) SafariBallText: ; c57e (3:457e) db "BALL×× @" -Func_c586: ; c586 (3:4586) +GetTileAndCoordsInFrontOfPlayer: ; c586 (3:4586) call GetPredefRegisters -Func_c589: ; c589 (3:4589) - ld a, [W_YCOORD] ; wd361 +_GetTileAndCoordsInFrontOfPlayer: ; c589 (3:4589) + ld a, [W_YCOORD] ld d, a - ld a, [W_XCOORD] ; wd362 + ld a, [W_XCOORD] ld e, a - ld a, [wSpriteStateData1 + 9] + ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction and a - jr nz, .asm_c59d + jr nz, .notFacingDown +; facing down aCoord 8, 11 inc d - jr .asm_c5b9 -.asm_c59d - cp $4 - jr nz, .asm_c5a7 + jr .storeTile +.notFacingDown + cp SPRITE_FACING_UP + jr nz, .notFacingUp +; facing up aCoord 8, 7 dec d - jr .asm_c5b9 -.asm_c5a7 - cp $8 - jr nz, .asm_c5b1 + jr .storeTile +.notFacingUp + cp SPRITE_FACING_LEFT + jr nz, .notFacingLeft +; facing left aCoord 6, 9 dec e - jr .asm_c5b9 -.asm_c5b1 - cp $c - jr nz, .asm_c5b9 + jr .storeTile +.notFacingLeft + cp SPRITE_FACING_RIGHT + jr nz, .storeTile +; facing right aCoord 10, 9 inc e -.asm_c5b9 +.storeTile ld c, a - ld [wcfc6], a + ld [wTileInFrontOfPlayer], a ret -Func_c5be: ; c5be (3:45be) +GetTileTwoStepsInFrontOfPlayer: ; c5be (3:45be) xor a ld [$ffdb], a - ld hl, W_YCOORD ; wd361 + ld hl, W_YCOORD ld a, [hli] ld d, a ld e, [hl] - ld a, [wSpriteStateData1 + 9] + ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction and a - jr nz, .asm_c5d8 + jr nz, .notFacingDown +; facing down ld hl, $ffdb set 0, [hl] aCoord 8, 13 inc d - jr .asm_c603 -.asm_c5d8 - cp $4 - jr nz, .asm_c5e7 + jr .storeTile +.notFacingDown + cp SPRITE_FACING_UP + jr nz, .notFacingUp +; facing up ld hl, $ffdb set 1, [hl] aCoord 8, 5 dec d - jr .asm_c603 -.asm_c5e7 - cp $8 - jr nz, .asm_c5f6 + jr .storeTile +.notFacingUp + cp SPRITE_FACING_LEFT + jr nz, .notFacingLeft +; facing left ld hl, $ffdb set 2, [hl] aCoord 4, 9 dec e - jr .asm_c603 -.asm_c5f6 - cp $c - jr nz, .asm_c603 + jr .storeTile +.notFacingLeft + cp SPRITE_FACING_RIGHT + jr nz, .storeTile +; facing right ld hl, $ffdb set 3, [hl] aCoord 12, 9 inc e -.asm_c603 +.storeTile ld c, a - ld [wd71c], a - ld [wcfc6], a + ld [wTileInFrontOfBoulderAndBoulderCollisionResult], a + ld [wTileInFrontOfPlayer], a ret -Func_c60b: ; c60b (3:460b) - call Func_c5be +CheckForCollisionWhenPushingBoulder: ; c60b (3:460b) + call GetTileTwoStepsInFrontOfPlayer ld hl, W_TILESETCOLLISIONPTR ld a, [hli] ld h, [hl] ld l, a -.asm_c614 +.loop ld a, [hli] cp $ff - jr z, .asm_c632 + jr z, .done ; if the tile two steps ahead is not passable cp c - jr nz, .asm_c614 - ld hl, $c7e - call Func_c44 + jr nz, .loop + ld hl, TilePairCollisionsLand + call CheckForTilePairCollisions2 ld a, $ff - jr c, .asm_c632 - ld a, [wd71c] - cp $15 + jr c, .done ; if there is an elevation difference between the current tile and the one two steps ahead + ld a, [wTileInFrontOfBoulderAndBoulderCollisionResult] + cp $15 ; stairs tile ld a, $ff - jr z, .asm_c632 - call Func_c636 -.asm_c632 - ld [wd71c], a + jr z, .done ; if the tile two steps ahead is stairs + call CheckForBoulderCollisionWithSprites +.done + ld [wTileInFrontOfBoulderAndBoulderCollisionResult], a ret -Func_c636: ; c636 (3:4636) - ld a, [wd718] +; sets a to $ff if there is a collision and $00 if there is no collision +CheckForBoulderCollisionWithSprites: ; c636 (3:4636) + ld a, [wBoulderSpriteIndex] dec a swap a - ld d, $0 + ld d, 0 ld e, a ld hl, wSpriteStateData2 + $14 add hl, de - ld a, [hli] + ld a, [hli] ; map Y position ld [$ffdc], a - ld a, [hl] + ld a, [hl] ; map X position ld [$ffdd], a - ld a, [W_NUMSPRITES] ; W_NUMSPRITES + ld a, [W_NUMSPRITES] ld c, a ld de, $f ld hl, wSpriteStateData2 + $14 ld a, [$ffdb] - and $3 - jr z, .asm_c678 -.asm_c659 + and $3 ; facing up or down? + jr z, .pushingHorizontallyLoop +.pushingVerticallyLoop inc hl ld a, [$ffdd] cp [hl] - jr nz, .asm_c672 + jr nz, .nextSprite1 ; if X coordinates don't match dec hl ld a, [hli] ld b, a ld a, [$ffdb] rrca - jr c, .asm_c66c + jr c, .pushingDown +; pushing up ld a, [$ffdc] dec a - jr .asm_c66f -.asm_c66c + jr .compareYCoords +.pushingDown ld a, [$ffdc] inc a -.asm_c66f +.compareYCoords cp b - jr z, .asm_c697 -.asm_c672 + jr z, .failure +.nextSprite1 dec c - jr z, .asm_c69a + jr z, .success add hl, de - jr .asm_c659 -.asm_c678 + jr .pushingVerticallyLoop +.pushingHorizontallyLoop ld a, [hli] ld b, a ld a, [$ffdc] cp b - jr nz, .asm_c691 + jr nz, .nextSprite2 ld b, [hl] ld a, [$ffdb] bit 2, a - jr nz, .asm_c68b + jr nz, .pushingLeft +; pushing right ld a, [$ffdd] inc a - jr .asm_c68e -.asm_c68b + jr .compareXCoords +.pushingLeft ld a, [$ffdd] dec a -.asm_c68e +.compareXCoords cp b - jr z, .asm_c697 -.asm_c691 + jr z, .failure +.nextSprite2 dec c - jr z, .asm_c69a + jr z, .success add hl, de - jr .asm_c678 -.asm_c697 + jr .pushingHorizontallyLoop +.failure ld a, $ff ret -.asm_c69a +.success xor a ret -Func_c69c: ; c69c (3:469c) +ApplyOutOfBattlePoisonDamage: ; c69c (3:469c) ld a, [wd730] add a - jp c, .asm_c74f - ld a, [wPartyCount] ; wPartyCount + jp c, .noBlackOut + ld a, [wPartyCount] and a - jp z, .asm_c74f - call Func_c8de - ld a, [wd13b] - and $3 - jp nz, .asm_c74f - ld [wWhichPokemon], a ; wWhichPokemon - ld hl, wPartyMon1Status ; wPartyMon1Status - ld de, wPartySpecies ; wPartySpecies -.asm_c6be + jp z, .noBlackOut + call IncrementDayCareMonExp + ld a, [wStepCounter] + and $3 ; is the counter a multiple of 4? + jp nz, .noBlackOut ; only apply poison damage every fourth step + ld [wWhichPokemon], a + ld hl, wPartyMon1Status + ld de, wPartySpecies +.applyDamageLoop ld a, [hl] - and $8 - jr z, .asm_c6fd + and (1 << PSN) + jr z, .nextMon2 ; not poisoned dec hl dec hl ld a, [hld] ld b, a ld a, [hli] or b - jr z, .asm_c6fb + jr z, .nextMon ; already fainted +; subtract 1 from HP ld a, [hl] dec a ld [hld], a inc a - jr nz, .asm_c6d5 + jr nz, .noBorrow +; borrow 1 from upper byte of HP dec [hl] inc hl - jr .asm_c6fb -.asm_c6d5 + jr .nextMon +.noBorrow ld a, [hli] or [hl] - jr nz, .asm_c6fb + jr nz, .nextMon ; didn't faint from damage +; the mon fainted from the damage push hl inc hl inc hl @@ -2534,134 +2553,134 @@ Func_c69c: ; c69c (3:469c) ld a, [de] ld [wd11e], a push de - ld a, [wWhichPokemon] ; wWhichPokemon - ld hl, wPartyMonNicks ; wPartyMonNicks + ld a, [wWhichPokemon] + ld hl, wPartyMonNicks call GetPartyMonName xor a ld [wJoyIgnore], a call EnableAutoTextBoxDrawing ld a, $d0 - ld [H_DOWNARROWBLINKCNT2], a ; $ff8c + ld [$ff8c], a call DisplayTextID pop de pop hl -.asm_c6fb +.nextMon inc hl inc hl -.asm_c6fd +.nextMon2 inc de ld a, [de] inc a - jr z, .asm_c70e - ld bc, $2c + jr z, .applyDamageLoopDone + ld bc, wPartyMon2 - wPartyMon1 add hl, bc push hl - ld hl, wWhichPokemon ; wWhichPokemon + ld hl, wWhichPokemon inc [hl] pop hl - jr .asm_c6be -.asm_c70e - ld hl, wPartyMon1Status ; wPartyMon1Status - ld a, [wPartyCount] ; wPartyCount + jr .applyDamageLoop +.applyDamageLoopDone + ld hl, wPartyMon1Status + ld a, [wPartyCount] ld d, a - ld e, $0 -.asm_c717 + ld e, 0 +.countPoisonedLoop ld a, [hl] - and $8 + and (1 << PSN) or e ld e, a - ld bc, $2c + ld bc, wPartyMon2 - wPartyMon1 add hl, bc dec d - jr nz, .asm_c717 + jr nz, .countPoisonedLoop ld a, e - and a - jr z, .asm_c733 + and a ; are any party members poisoned? + jr z, .skipPoisonEffectAndSound ld b, $2 - predef Func_480eb + predef ChangeBGPalColor0_4Frames ; change BG white to dark grey for 4 frames ld a, (SFX_02_43 - SFX_Headers_02) / 3 call PlaySound -.asm_c733 +.skipPoisonEffectAndSound predef AnyPartyAlive ld a, d and a - jr nz, .asm_c74f + jr nz, .noBlackOut call EnableAutoTextBoxDrawing ld a, $d1 - ld [H_DOWNARROWBLINKCNT2], a ; $ff8c + ld [$ff8c], a call DisplayTextID ld hl, wd72e set 5, [hl] ld a, $ff - jr .asm_c750 -.asm_c74f + jr .done +.noBlackOut xor a -.asm_c750 +.done ld [wd12d], a ret -Func_c754: ; c754 (3:4754) +LoadTilesetHeader: ; c754 (3:4754) call GetPredefRegisters push hl - ld d, $0 - ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET + ld d, 0 + ld a, [W_CURMAPTILESET] add a add a ld b, a add a - add b - jr nc, .asm_c765 + add b ; a = tileset * 12 + jr nc, .noCarry inc d -.asm_c765 +.noCarry ld e, a ld hl, Tilesets add hl, de ld de, W_TILESETBANK ld c, $b -.asm_c76f +.copyTilesetHeaderLoop ld a, [hli] ld [de], a inc de dec c - jr nz, .asm_c76f + jr nz, .copyTilesetHeaderLoop ld a, [hl] ld [$ffd7], a xor a ld [$ffd8], a pop hl - ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET + ld a, [W_CURMAPTILESET] push hl push de - ld hl, DungeonTilesets ; $47b2 + ld hl, DungeonTilesets ld de, $1 call IsInArray pop de pop hl jr c, .asm_c797 - ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET + ld a, [W_CURMAPTILESET] ld b, a - ld a, [H_DOWNARROWBLINKCNT1] ; $ff8b + ld a, [$ff8b] cp b - jr z, .asm_c7b1 + jr z, .done .asm_c797 - ld a, [wd42f] + ld a, [wDestinationWarpID] cp $ff - jr z, .asm_c7b1 + jr z, .done call LoadDestinationWarpPosition - ld a, [W_YCOORD] ; wd361 + ld a, [W_YCOORD] and $1 - ld [W_YBLOCKCOORD], a ; wd363 - ld a, [W_XCOORD] ; wd362 + ld [W_YBLOCKCOORD], a + ld a, [W_XCOORD] and $1 - ld [W_XBLOCKCOORD], a ; wd364 -.asm_c7b1 + ld [W_XBLOCKCOORD], a +.done ret INCLUDE "data/dungeon_tilesets.asm" INCLUDE "data/tileset_headers.asm" -Func_c8de: ; c8de (3:48de) +IncrementDayCareMonExp: ; c8de (3:48de) ld a, [W_DAYCARE_IN_USE] and a ret z @@ -3073,9 +3092,9 @@ Func_ee9e: ; ee9e (3:6e9e) add hl, bc ld a, [wd09f] ld [hl], a - ld a, [wd35f] + ld a, [wCurrentTileBlockMapViewPointer] ld c, a - ld a, [wd360] + ld a, [wCurrentTileBlockMapViewPointer + 1] ld b, a call Func_ef4e ret c @@ -3399,7 +3418,7 @@ TryPushingBoulder: ; f225 (3:7225) ld [$ff8c], a call IsSpriteInFrontOfPlayer ld a, [$ff8c] - ld [wd718], a + ld [wBoulderSpriteIndex], a and a jp z, ResetBoulderPushFlags ld hl, wSpriteStateData1 + 1 @@ -3420,9 +3439,9 @@ TryPushingBoulder: ; f225 (3:7225) ld a, [hJoyHeld] and $f0 ret z - predef Func_c60b - ld a, [wd71c] - and a + predef CheckForCollisionWhenPushingBoulder + ld a, [wTileInFrontOfBoulderAndBoulderCollisionResult] + and a ; was there a collision? jp nz, ResetBoulderPushFlags ld a, [hJoyHeld] ld b, a @@ -3481,8 +3500,8 @@ DoBoulderDustAnimation: ; f2b5 (3:72b5) ld [wJoyIgnore], a call ResetBoulderPushFlags set 7, [hl] - ld a, [wd718] - ld [H_DOWNARROWBLINKCNT2], a ; $ff8c + ld a, [wBoulderSpriteIndex] + ld [H_SPRITEINDEX], a call GetSpriteMovementByte2Pointer ld [hl], $10 ld a, (SFX_02_56 - SFX_Headers_02) / 3 diff --git a/scripts/billshouse.asm b/scripts/billshouse.asm index b30a8602a9..14882d1a88 100755 --- a/scripts/billshouse.asm +++ b/scripts/billshouse.asm @@ -57,7 +57,7 @@ BillsHouseScript3: ; 1e7c5 (7:67c5) ld a, $f0 ld [wJoyIgnore], a ld a, $2 - ld [wcf13], a + ld [wSpriteIndex], a ld a, $c ld [$ffeb], a ld a, $40 diff --git a/scripts/celadongamecorner.asm b/scripts/celadongamecorner.asm index 9746f54ea3..87239910b1 100755 --- a/scripts/celadongamecorner.asm +++ b/scripts/celadongamecorner.asm @@ -236,7 +236,7 @@ CeladonGameCornerText5: ; 48d4a (12:4d4a) ld hl, wd77e set 2, [hl] ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld hl, Received10CoinsText jr .asm_c7d1a ; 0x48d87 .asm_d0957 ; 0x48d89 @@ -411,7 +411,7 @@ CeladonGameCornerText11: ; 48e9d (12:4e9d) ld de, CeladonGameCornerText_48ed3 call PreBattleSaveRegisters ldh a, [$8c] - ld [wcf13], a + ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters xor a @@ -437,7 +437,7 @@ CeladonGameCornerText13: ; 48ed8 (12:4ed8) CeladonGameCornerText12: ; 48edd (12:4edd) db $08 ; asm ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld hl, CeladonGameCornerText_48f09 call PrintText call WaitForSoundToFinish diff --git a/scripts/celadongym.asm b/scripts/celadongym.asm index 6d44175ebb..092bff888c 100755 --- a/scripts/celadongym.asm +++ b/scripts/celadongym.asm @@ -179,7 +179,7 @@ CeladonGymText1: ; 48a11 (12:4a11) ld de, CeladonGymText_48a63 call PreBattleSaveRegisters ldh a, [$8c] - ld [wcf13], a + ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters ld a, $4 diff --git a/scripts/celadonmansion3.asm b/scripts/celadonmansion3.asm index 73cd45ed66..47190c92b6 100755 --- a/scripts/celadonmansion3.asm +++ b/scripts/celadonmansion3.asm @@ -51,7 +51,7 @@ DirectorText: ; 487b2 (12:47b2) db $8 ; asm callab DisplayDiploma ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a jp TextScriptEnd GameFreakPCText1: ; 487eb (12:47eb) diff --git a/scripts/celadonmartelevator.asm b/scripts/celadonmartelevator.asm index 1e32647de2..ff83576577 100755 --- a/scripts/celadonmartelevator.asm +++ b/scripts/celadonmartelevator.asm @@ -9,13 +9,13 @@ CeladonMartElevatorScript: ; 48600 (12:4600) res 7, [hl] call nz, CeladonMartElevatorScript_48654 xor a - ld [wcf0c], a + ld [wAutoTextBoxDrawingControl], a inc a - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ret CeladonMartElevatorScript_4861c: ; 4861c (12:461c) - ld hl, wd3af + ld hl, wWarpEntries ld a, [wd73b] ld b, a ld a, [wd73c] diff --git a/scripts/celadonmartroof.asm b/scripts/celadonmartroof.asm index 370255250a..fa34b8cd2f 100755 --- a/scripts/celadonmartroof.asm +++ b/scripts/celadonmartroof.asm @@ -230,7 +230,7 @@ CeladonMartRoofText2: ; 4856c (12:456c) and a jr z, .asm_914b9 ; 0x48574 ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld hl, CeladonMartRoofText4 call PrintText call YesNoChoice diff --git a/scripts/ceruleancity.asm b/scripts/ceruleancity.asm index 90ccab679c..d97f9723bd 100755 --- a/scripts/ceruleancity.asm +++ b/scripts/ceruleancity.asm @@ -64,7 +64,7 @@ CeruleanCityScript0: ; 194c8 (6:54c8) ld hl, CeruleanCityCoords2 call ArePlayerCoordsInArray ret nc - ld a, [wd700] + ld a, [wWalkBikeSurfState] and a jr z, .asm_19512 ; 0x19508 $8 ld a, $ff @@ -279,7 +279,7 @@ CeruleanCityText2: ; 1967c (6:567c) ld de, CeruleanCityText_196ee call PreBattleSaveRegisters ld a, [$ff8c] - ld [wcf13], a + ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters ld a, $4 @@ -296,7 +296,7 @@ CeruleanCityText2: ; 1967c (6:567c) jr .Done .Success ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld hl, ReceivedTM28Text call PrintText callba Func_74872 diff --git a/scripts/ceruleancity2.asm b/scripts/ceruleancity2.asm index 57c9ea4af7..e65ef2c5f2 100755 --- a/scripts/ceruleancity2.asm +++ b/scripts/ceruleancity2.asm @@ -2,7 +2,7 @@ Func_74872: ; 74872 (1d:4872) ; code similar to this appears in a lot of banks; this particular ; one is called after you beat the Rocket that gives you TM28 DIG. ; the screen then fades out, he disappears, and fades back in - call GBFadeIn1 + call GBFadeOutToBlack ld a, $07 ld [wcc4d], a predef ShowObject @@ -12,5 +12,5 @@ Func_74872: ; 74872 (1d:4872) ld a, $06 ld [wcc4d], a predef HideObject - call GBFadeOut1 + call GBFadeInFromBlack ret diff --git a/scripts/ceruleangym.asm b/scripts/ceruleangym.asm index 19296fe234..ae6a40a09e 100755 --- a/scripts/ceruleangym.asm +++ b/scripts/ceruleangym.asm @@ -128,7 +128,7 @@ CeruleanGymText1: ; 5c771 (17:4771) ld de, CeruleanGymText_5c7d8 call PreBattleSaveRegisters ldh a, [$8c] - ld [wcf13], a + ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters ld a, $2 diff --git a/scripts/ceruleanhouse2.asm b/scripts/ceruleanhouse2.asm index 7cc1aa74ee..3fa7218394 100755 --- a/scripts/ceruleanhouse2.asm +++ b/scripts/ceruleanhouse2.asm @@ -1,8 +1,8 @@ CeruleanHouse2Script: ; 74e09 (1d:4e09) ld a, $1 - ld [wcf0c], a + ld [wAutoTextBoxDrawingControl], a dec a - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ret CeruleanHouse2TextPointers: ; 74e13 (1d:4e13) diff --git a/scripts/cinnabargym.asm b/scripts/cinnabargym.asm index 8ce02e8140..65fd1db949 100755 --- a/scripts/cinnabargym.asm +++ b/scripts/cinnabargym.asm @@ -187,13 +187,13 @@ CinnabarGymTextPointers: ; 7589f (1d:589f) CinnabarGymScript_758b7: ; 758b7 (1d:58b7) ld a, [H_DOWNARROWBLINKCNT2] ; $ff8c - ld [wcf13], a + ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters ld hl, wd72d set 6, [hl] set 7, [hl] - ld a, [wcf13] + ld a, [wSpriteIndex] cp $1 jr z, .asm_758d4 ld a, $2 diff --git a/scripts/copycatshouse2f.asm b/scripts/copycatshouse2f.asm index ea1e91b3b6..b7a1255cd5 100755 --- a/scripts/copycatshouse2f.asm +++ b/scripts/copycatshouse2f.asm @@ -16,7 +16,7 @@ CopycatsHouse2FText1: ; 5cc82 (17:4c82) bit 0, a jr nz, .asm_7ccf3 ; 0x5cc88 ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld hl, CopycatsHouse2FText_5ccd4 call PrintText ld b, POKE_DOLL diff --git a/scripts/daycarem.asm b/scripts/daycarem.asm index 55a9f11111..f2bf3188ce 100755 --- a/scripts/daycarem.asm +++ b/scripts/daycarem.asm @@ -24,7 +24,7 @@ DayCareMText1: ; 56254 (15:6254) ld hl, DayCareMText_56414 call PrintText xor a - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a ld [wd07d], a ld [wMenuItemToSwap], a call DisplayPartyMenu diff --git a/scripts/fightingdojo.asm b/scripts/fightingdojo.asm index 0fbff74a4b..fb8d7b19cb 100755 --- a/scripts/fightingdojo.asm +++ b/scripts/fightingdojo.asm @@ -149,7 +149,7 @@ FightingDojoText1: ; 5ce44 (17:4e44) ld de, FightingDojoText_5ce93 call PreBattleSaveRegisters ldh a, [$8c] - ld [wcf13], a + ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters ld a, $3 diff --git a/scripts/fuchsiagym.asm b/scripts/fuchsiagym.asm index 09a767eba3..14ffdfa968 100755 --- a/scripts/fuchsiagym.asm +++ b/scripts/fuchsiagym.asm @@ -168,7 +168,7 @@ FuchsiaGymText1: ; 75534 (1d:5534) ld de, UnnamedText_75586 call PreBattleSaveRegisters ldh a, [$8c] - ld [wcf13], a + ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters ld a, $5 diff --git a/scripts/mansion1.asm b/scripts/mansion1.asm index ee1b42b47b..7621897f2a 100755 --- a/scripts/mansion1.asm +++ b/scripts/mansion1.asm @@ -106,7 +106,7 @@ Mansion1Text4: ; 4435a (11:435a) and a jr nz, .asm_4438c ; 0x44368 $22 ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld hl, wd126 set 5, [hl] ld hl, MansionSwitchPressedText diff --git a/scripts/mansion2.asm b/scripts/mansion2.asm index 302616376f..1b7a28a3af 100755 --- a/scripts/mansion2.asm +++ b/scripts/mansion2.asm @@ -112,7 +112,7 @@ Mansion2Text5: ; 52087 (14:6087) and a jr nz, .asm_520b9 ; 0x52095 $22 ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld hl, wd126 set 5, [hl] ld hl, Mansion2Text_520c7 diff --git a/scripts/mansion3.asm b/scripts/mansion3.asm index 4e9c227101..494fba13fa 100755 --- a/scripts/mansion3.asm +++ b/scripts/mansion3.asm @@ -40,7 +40,7 @@ Mansion3ScriptPointers: ; 52235 (14:6235) Mansion3Script0: ; 5223b (14:623b) ld hl, CoordsData_52254 call Mansion3Script_5225b - ld a, [wd71e] + ld a, [wWhichDungeonWarp] and a jp z, CheckFightingMapTrainers cp $3 @@ -48,7 +48,7 @@ Mansion3Script0: ; 5223b (14:623b) jr nz, .asm_52250 ld a, $d6 .asm_52250 - ld [wd71d], a + ld [wDungeonWarpDestinationMap], a ret CoordsData_52254: ; 52254 (14:6254) @@ -59,14 +59,14 @@ CoordsData_52254: ; 52254 (14:6254) Mansion3Script_5225b: ; 5225b (14:625b) xor a - ld [wd71e], a + ld [wWhichDungeonWarp], a ld a, [wd72d] bit 4, a ret nz call ArePlayerCoordsInArray ret nc ld a, [wWhichTrade] ; wWhichTrade - ld [wd71e], a + ld [wWhichDungeonWarp], a ld hl, wd72d set 4, [hl] ld hl, wd732 diff --git a/scripts/mtmoon3.asm b/scripts/mtmoon3.asm index 8d6aaeed4f..7163840917 100755 --- a/scripts/mtmoon3.asm +++ b/scripts/mtmoon3.asm @@ -138,7 +138,7 @@ MtMoon3Script5: ; 49dfb (12:5dfb) ld a, $f0 ld [wJoyIgnore], a ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld a, $a ld [H_DOWNARROWBLINKCNT2], a ; $ff8c call DisplayTextID @@ -230,7 +230,7 @@ MtMoon3Text1: ; 49e79 (12:5e79) ld de, MtMoon3Text_49f8a call PreBattleSaveRegisters ldh a, [$8c] - ld [wcf13], a + ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters ld a, $3 @@ -270,7 +270,7 @@ MtMoon3Text5: ; 49edf (12:5edf) MtMoon3Text6: ; 49ee9 (12:5ee9) db $08 ; asm ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld hl, MtMoon3Text_49f24 call PrintText call YesNoChoice @@ -299,7 +299,7 @@ MtMoon3Text_49f24: ; 49f24 (12:5f24) MtMoon3Text7: ; 49f29 (12:5f29) db $08 ; asm ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld hl, MtMoon3Text_49f64 call PrintText call YesNoChoice diff --git a/scripts/museum1f.asm b/scripts/museum1f.asm index 10dc9f4285..a701e1a46c 100755 --- a/scripts/museum1f.asm +++ b/scripts/museum1f.asm @@ -1,8 +1,8 @@ Museum1FScript: ; 5c0f7 (17:40f7) ld a, $1 - ld [wcf0c], a + ld [wAutoTextBoxDrawingControl], a xor a - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld hl, Museum1FScriptPointers ld a, [W_MUSEUM1FCURSCRIPT] jp CallFunctionInTable diff --git a/scripts/namerater.asm b/scripts/namerater.asm index 2295944fe7..c9e3bfb467 100755 --- a/scripts/namerater.asm +++ b/scripts/namerater.asm @@ -50,7 +50,7 @@ NameRaterText1: ; 1da56 (7:5a56) call PrintText xor a ld [wd07d], a - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a ld [wMenuItemToSwap], a call DisplayPartyMenu push af diff --git a/scripts/oakslab.asm b/scripts/oakslab.asm index faf86f1a4c..8666d18e02 100755 --- a/scripts/oakslab.asm +++ b/scripts/oakslab.asm @@ -3,9 +3,9 @@ OaksLabScript: ; 1cb0e (7:4b0e) bit 6, a call nz, OaksLabScript_1d076 ld a, $1 - ld [wcf0c], a + ld [wAutoTextBoxDrawingControl], a xor a - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld hl, OaksLabScriptPointers ld a, [W_OAKSLABCURSCRIPT] jp CallFunctionInTable @@ -374,7 +374,7 @@ OaksLabScript11: ; 1cdb9 (7:4db9) .done ld [W_TRAINERNO], a ld a, $1 - ld [wcf13], a + ld [wSpriteIndex], a call GetSpritePosition1 ld hl, OaksLabText_1d3be ld de, OaksLabText_1d3c3 @@ -397,7 +397,7 @@ OaksLabScript12: ; 1ce03 (7:4e03) ld [wd528], a call UpdateSprites ld a, $1 - ld [wcf13], a + ld [wSpriteIndex], a call SetSpritePosition1 ld a, $1 ld [H_SPRITEINDEX], a @@ -680,7 +680,7 @@ OaksLabScript_1d02b: ; 1d02b (7:502b) ld a, b ld [$ffed], a ld a, $1 - ld [wcf13], a + ld [wSpriteIndex], a call SetSpritePosition1 ret @@ -801,7 +801,7 @@ OaksLabScript_1d133: ; 1d133 (7:5133) ld [wcf91], a ld [wd11e], a ld a, b - ld [wcf13], a + ld [wSpriteIndex], a ld a, [wd74b] bit 2, a jp nz, OaksLabScript_1d22d @@ -837,7 +837,7 @@ OaksLabScript_1d157: ; 1d157 (7:5157) call ReloadMapData ld c, $a call DelayFrames - ld a, [wcf13] + ld a, [wSpriteIndex] cp $2 jr z, OaksLabLookAtCharmander cp $3 @@ -868,7 +868,7 @@ OaksLabBulbasaurText: ; 1d1ae (7:51ae) OaksLabMonChoiceMenu: ; 1d1b3 (7:51b3) call PrintText ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a call YesNoChoice ; yes/no menu ld a, [wCurrentMenuItem] and a @@ -877,7 +877,7 @@ OaksLabMonChoiceMenu: ; 1d1b3 (7:51b3) ld [W_PLAYERSTARTER], a ld [wd11e], a call GetMonName - ld a, [wcf13] + ld a, [wSpriteIndex] cp $2 jr nz, asm_1d1db ; 0x1d1d5 $4 ld a, $2b @@ -893,7 +893,7 @@ asm_1d1e5: ; 1d1e5 (7:51e5) ld [wcc4d], a predef HideObject ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld hl, OaksLabMonEnergeticText call PrintText ld hl, OaksLabReceivedMonText @@ -956,7 +956,7 @@ OaksLabText5: ; 1d248 (7:5248) ld hl, OaksLabText_1d31d call PrintText ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a predef DisplayDexRating jp .asm_0f042 .asm_b28b0 ; 0x1d279 diff --git a/scripts/pallettown.asm b/scripts/pallettown.asm index 59660a90fc..e7bd2f5789 100755 --- a/scripts/pallettown.asm +++ b/scripts/pallettown.asm @@ -109,7 +109,7 @@ PalletTownScript3: ; 18f12 (6:4f12) ld a,$FF ld [wJoyIgnore],a ld a,1 - ld [wcf13],a + ld [wSpriteIndex],a xor a ld [wNPCMovementScriptFunctionNum],a ld a,1 @@ -171,7 +171,7 @@ PalletTownText1: ; 18f96 (6:4f96) and a jr nz,.next ld a,1 - ld [wcc3c],a + ld [wDoNotWaitForButtonPressAfterDisplayingText],a ld hl,OakAppearsText jr .done .next diff --git a/scripts/pewtercity.asm b/scripts/pewtercity.asm index 2b8dfc3f8f..ba32454aa5 100755 --- a/scripts/pewtercity.asm +++ b/scripts/pewtercity.asm @@ -68,7 +68,7 @@ PewterCityScript1: ; 19280 (6:5280) ld a, $11 ld [$ffee], a ld a, $3 - ld [wcf13], a + ld [wSpriteIndex], a call SetSpritePosition1 ld a, $3 ld [$ff8c], a @@ -94,7 +94,7 @@ PewterCityScript2: ; 192d3 (6:52d3) PewterCityScript3: ; 192e9 (6:52e9) ld a, $3 - ld [wcf13], a + ld [wSpriteIndex], a call SetSpritePosition2 ld a, $3 ld [wcc4d], a @@ -132,7 +132,7 @@ PewterCityScript4: ; 19305 (6:5305) ld a, $10 ld [$ffee], a ld a, $5 - ld [wcf13], a + ld [wSpriteIndex], a call SetSpritePosition1 ld a, $5 ld [$ff8c], a @@ -158,7 +158,7 @@ PewterCityScript5: ; 19359 (6:5359) PewterCityScript6: ; 1936f (6:536f) ld a, $5 - ld [wcf13], a + ld [wSpriteIndex], a call SetSpritePosition2 ld a, $4 ld [wcc4d], a @@ -216,7 +216,7 @@ PewterCityText3: ; 193b1 (6:53b1) ldh a, [$b8] ld [wNPCMovementScriptBank], a ld a, $3 - ld [wcf13], a + ld [wSpriteIndex], a call GetSpritePosition2 ld a, $1 ld [W_PEWTERCITYCURSCRIPT], a @@ -280,7 +280,7 @@ PewterCityText5: ; 19436 (6:5436) ldh a, [$b8] ld [wNPCMovementScriptBank], a ld a, $5 - ld [wcf13], a + ld [wSpriteIndex], a call GetSpritePosition2 ld a, $4 ld [W_PEWTERCITYCURSCRIPT], a diff --git a/scripts/pewtergym.asm b/scripts/pewtergym.asm index 2feb981768..0ab4c3a4ed 100755 --- a/scripts/pewtergym.asm +++ b/scripts/pewtergym.asm @@ -128,7 +128,7 @@ PewterGymText1: ; 5c44e (17:444e) ld de, PewterGymText_5c4bc call PreBattleSaveRegisters ldh a, [$8c] - ld [wcf13], a + ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters ld a, $1 diff --git a/scripts/pewtermart.asm b/scripts/pewtermart.asm index 4e867aee17..8fe99d94b8 100755 --- a/scripts/pewtermart.asm +++ b/scripts/pewtermart.asm @@ -1,7 +1,7 @@ PewterMartScript: ; 74cad (1d:4cad) call EnableAutoTextBoxDrawing ld a, $1 - ld [wcf0c], a + ld [wAutoTextBoxDrawingControl], a ret PewterMartTextPointers: ; 74cb6 (1d:4cb6) diff --git a/scripts/pewterpokecenter.asm b/scripts/pewterpokecenter.asm index 1871ad5f30..2f4fd7afae 100755 --- a/scripts/pewterpokecenter.asm +++ b/scripts/pewterpokecenter.asm @@ -18,7 +18,7 @@ PewterPokecenterText2: ; 5c596 (17:4596) PewterPokecenterText3: ; 5c59b (17:459b) db $8 ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld hl, PewterPokecenterText5 call PrintText ld a, $ff diff --git a/scripts/pokemontower5.asm b/scripts/pokemontower5.asm index 317690a26e..6dd694acfd 100755 --- a/scripts/pokemontower5.asm +++ b/scripts/pokemontower5.asm @@ -33,10 +33,10 @@ PokemonTower5Script0: ; 6094b (18:494b) ld hl, wd72e set 4, [hl] predef HealParty - call GBFadeOut2 + call GBFadeOutToWhite call Delay3 call Delay3 - call GBFadeIn2 + call GBFadeInFromWhite ld a, $7 ld [H_DOWNARROWBLINKCNT2], a ; $ff8c call DisplayTextID diff --git a/scripts/pokemontower7.asm b/scripts/pokemontower7.asm index 431855cb69..6ebf15d5db 100755 --- a/scripts/pokemontower7.asm +++ b/scripts/pokemontower7.asm @@ -30,7 +30,7 @@ PokemonTower7Script2: ; 60d23 (18:4d23) call EndTrainerBattle ld a, $f0 ld [wJoyIgnore], a - ld a, [wcf13] + ld a, [wSpriteIndex] ld [H_DOWNARROWBLINKCNT2], a ; $ff8c call DisplayTextID call PokemonTower7Script_60db6 @@ -44,7 +44,7 @@ PokemonTower7Script3: ; 60d56 (18:4d56) bit 0, a ret nz ld hl, W_MISSABLEOBJECTLIST - ld a, [wcf13] + ld a, [wSpriteIndex] ld b, a .missableObjectsListLoop ld a, [hli] @@ -55,7 +55,7 @@ PokemonTower7Script3: ; 60d56 (18:4d56) predef HideObject xor a ld [wJoyIgnore], a - ld [wcf13], a + ld [wSpriteIndex], a ld [wTrainerHeaderFlagBit], a ld [wda38], a ld a, $0 @@ -74,7 +74,7 @@ PokemonTower7Script4: ; 60d86 (18:4d86) ld a, $95 ld [H_DOWNARROWBLINKCNT1], a ; $ff8b ld a, $1 - ld [wd42f], a + ld [wDestinationWarpID], a ld a, LAVENDER_TOWN ld [wLastMap], a ld hl, wd72d @@ -86,7 +86,7 @@ PokemonTower7Script4: ; 60d86 (18:4d86) PokemonTower7Script_60db6: ; 60db6 (18:4db6) ld hl, CoordsData_60de3 ; $4de3 - ld a, [wcf13] + ld a, [wSpriteIndex] dec a swap a ld d, $0 @@ -106,7 +106,7 @@ PokemonTower7Script_60db6: ; 60db6 (18:4db6) ld a, [hli] ld d, [hl] ld e, a - ld a, [wcf13] + ld a, [wSpriteIndex] ld [H_DOWNARROWBLINKCNT2], a ; $ff8c jp MoveSprite .asm_60dde diff --git a/scripts/redshouse1f.asm b/scripts/redshouse1f.asm index 0e3e331b2f..7b3f1f8744 100755 --- a/scripts/redshouse1f.asm +++ b/scripts/redshouse1f.asm @@ -25,7 +25,7 @@ MomWakeUpText: ; 48185 (12:4185) MomHealPokemon: ; 4818a (12:418a) ld hl, MomHealText1 call PrintText - call GBFadeOut2 + call GBFadeOutToWhite call ReloadMapData predef HealParty ld a, MUSIC_PKMN_HEALED @@ -38,7 +38,7 @@ MomHealPokemon: ; 4818a (12:418a) ld a, [wd35b] ld [wc0ee], a call PlaySound - call GBFadeIn2 + call GBFadeInFromWhite ld hl, MomHealText2 jp PrintText diff --git a/scripts/rockethideout4.asm b/scripts/rockethideout4.asm index 5c99f3a12f..ddac941ab8 100755 --- a/scripts/rockethideout4.asm +++ b/scripts/rockethideout4.asm @@ -58,7 +58,7 @@ RocketHideout4Script3: ; 454b6 (11:54b6) ld a, $a ld [H_SPRITEHEIGHT], a call DisplayTextID - call GBFadeIn1 + call GBFadeOutToBlack ld a, $83 ld [wcc4d], a predef HideObject @@ -66,7 +66,7 @@ RocketHideout4Script3: ; 454b6 (11:54b6) ld [wcc4d], a predef ShowObject call UpdateSprites - call GBFadeOut1 + call GBFadeInFromBlack xor a ld [wJoyIgnore], a ld hl, wd126 @@ -132,7 +132,7 @@ RocketHideout4Text1: ; 4553a (11:553a) ld de, RocketHideout4Text_4557f call PreBattleSaveRegisters ldh a, [$8c] - ld [wcf13], a + ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters xor a diff --git a/scripts/rockethideoutelevator.asm b/scripts/rockethideoutelevator.asm index 73313dd79a..e7bc24f3d5 100755 --- a/scripts/rockethideoutelevator.asm +++ b/scripts/rockethideoutelevator.asm @@ -9,13 +9,13 @@ RocketHideoutElevatorScript: ; 45710 (11:5710) res 7, [hl] call nz, RocketHideoutElevatorScript_4575f xor a - ld [wcf0c], a + ld [wAutoTextBoxDrawingControl], a inc a - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ret RocketHideoutElevatorScript_4572c: ; 4572c (11:572c) - ld hl, wd3af + ld hl, wWarpEntries ld a, [wd73b] ld b, a ld a, [wd73c] diff --git a/scripts/route12gateupstairs.asm b/scripts/route12gateupstairs.asm index 94a4f9a21e..c4c05cd69b 100755 --- a/scripts/route12gateupstairs.asm +++ b/scripts/route12gateupstairs.asm @@ -75,5 +75,5 @@ Route12GateUpstairsScript_495c9: ; 495c9 (12:55c9) call PrintText xor a .asm_495d8 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a jp TextScriptEnd diff --git a/scripts/route22.asm b/scripts/route22.asm index cd47d1dcf9..667edd65cc 100755 --- a/scripts/route22.asm +++ b/scripts/route22.asm @@ -83,7 +83,7 @@ Route22Script0: ; 50f00 (14:4f00) xor a ld [wcd50], a predef EmotionBubble - ld a, [wd700] + ld a, [wWalkBikeSurfState] and a jr z, .asm_50f4e ; 0x50f44 $8 ld a, $ff @@ -222,7 +222,7 @@ Route22Script_5104e: ; 5104e (14:504e) xor a ld [wcd50], a predef EmotionBubble - ld a, [wd700] + ld a, [wWalkBikeSurfState] and a jr z, .skipYVisibilityTesta ld a, $ff diff --git a/scripts/route24.asm b/scripts/route24.asm index 89ddeded8e..ea48053b2a 100755 --- a/scripts/route24.asm +++ b/scripts/route24.asm @@ -171,7 +171,7 @@ Route24Text1: ; 514a4 (14:54a4) ld de, Route24Text_5152b call PreBattleSaveRegisters ld a, [$ff8c] - ld [wcf13], a + ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters xor a diff --git a/scripts/saffrongym.asm b/scripts/saffrongym.asm index 336d40e9b8..39f4df10a2 100755 --- a/scripts/saffrongym.asm +++ b/scripts/saffrongym.asm @@ -180,7 +180,7 @@ SaffronGymText1: ; 5d118 (17:5118) ld de, SaffronGymText_5d167 call PreBattleSaveRegisters ldh a, [$8c] - ld [wcf13], a + ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters ld a, $6 diff --git a/scripts/seafoamislands1.asm b/scripts/seafoamislands1.asm index 55bbd43e8a..1fe0852b62 100755 --- a/scripts/seafoamislands1.asm +++ b/scripts/seafoamislands1.asm @@ -34,7 +34,7 @@ SeafoamIslands1Script: ; 447e9 (11:47e9) predef_jump ShowObject .asm_4483b ld a, $9f - ld [wd71d], a + ld [wDungeonWarpDestinationMap], a ld hl, Seafoam1HolesCoords jp Func_46981 diff --git a/scripts/seafoamislands2.asm b/scripts/seafoamislands2.asm index b14c16d8ff..e392620ac2 100755 --- a/scripts/seafoamislands2.asm +++ b/scripts/seafoamislands2.asm @@ -32,7 +32,7 @@ SeafoamIslands2Script: ; 46315 (11:6315) predef_jump ShowObject .asm_46362 ld a, $a0 - ld [wd71d], a + ld [wDungeonWarpDestinationMap], a ld hl, Seafoam2HolesCoords jp Func_46981 diff --git a/scripts/seafoamislands3.asm b/scripts/seafoamislands3.asm index aa7b361587..ba34a2c3ca 100755 --- a/scripts/seafoamislands3.asm +++ b/scripts/seafoamislands3.asm @@ -32,7 +32,7 @@ SeafoamIslands3Script: ; 46451 (11:6451) predef_jump ShowObject .asm_4649e ld a, $a1 - ld [wd71d], a + ld [wDungeonWarpDestinationMap], a ld hl, Seafoam3HolesCoords jp Func_46981 diff --git a/scripts/seafoamislands4.asm b/scripts/seafoamislands4.asm index 909a8d9a97..a56382dd38 100755 --- a/scripts/seafoamislands4.asm +++ b/scripts/seafoamislands4.asm @@ -33,7 +33,7 @@ SeafoamIslands4Script: ; 4658d (11:658d) jr .asm_465ed ; 0x465da $11 .asm_465dc ld a, $a2 - ld [wd71d], a + ld [wDungeonWarpDestinationMap], a ld hl, Seafoam4HolesCoords call Func_46981 ld a, [wd732] diff --git a/scripts/seafoamislands5.asm b/scripts/seafoamislands5.asm index c4936ac158..b554034b48 100755 --- a/scripts/seafoamislands5.asm +++ b/scripts/seafoamislands5.asm @@ -130,8 +130,8 @@ SeafoamIslands5Script3: ; 46860 (11:6860) SeaFoamIslands5Script_46872: ; 46872 (11:6872) xor a - ld [wd700], a - ld [wd11a], a + ld [wWalkBikeSurfState], a + ld [wWalkBikeSurfStateCopy], a jp ForceBikeOrSurf SeafoamIslands5TextPointers: ; 4687c (11:687c) diff --git a/scripts/silphco11.asm b/scripts/silphco11.asm index dfdfbe1d39..32a455ec8f 100755 --- a/scripts/silphco11.asm +++ b/scripts/silphco11.asm @@ -182,11 +182,11 @@ SilphCo11Script5: ; 62227 (18:6227) ld a, $6 ld [H_DOWNARROWBLINKCNT2], a ; $ff8c call DisplayTextID - call GBFadeIn1 + call GBFadeOutToBlack call SilphCo11Script_6216d call UpdateSprites call Delay3 - call GBFadeOut1 + call GBFadeInFromBlack ld hl, wd838 set 7, [hl] xor a @@ -223,7 +223,7 @@ SilphCo11Script4: ; 62293 (18:6293) ld de, SilphCo10Text_62330 ; $6330 call PreBattleSaveRegisters ld a, [H_DOWNARROWBLINKCNT2] ; $ff8c - ld [wcf13], a + ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters xor a diff --git a/scripts/silphco9.asm b/scripts/silphco9.asm index c4f7a89509..44059b56d2 100755 --- a/scripts/silphco9.asm +++ b/scripts/silphco9.asm @@ -164,9 +164,9 @@ SilphCo9Text1: ; 5d8b8 (17:58b8) ld hl, SilphCo9Text_5d8e5 call PrintText predef HealParty - call GBFadeOut2 + call GBFadeOutToWhite call Delay3 - call GBFadeIn2 + call GBFadeInFromWhite ld hl, SilphCo9Text_5d8ea call PrintText jr .asm_b6e28 ; 0x5d8da diff --git a/scripts/silphcoelevator.asm b/scripts/silphcoelevator.asm index 853d735769..48d406cc3d 100755 --- a/scripts/silphcoelevator.asm +++ b/scripts/silphcoelevator.asm @@ -9,13 +9,13 @@ SilphCoElevatorScript: ; 457c0 (11:57c0) res 7, [hl] call nz, SilphCoElevatorScript_45827 xor a - ld [wcf0c], a + ld [wAutoTextBoxDrawingControl], a inc a - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ret SilphCoElevatorScript_457dc: ; 457dc (11:57dc) - ld hl, wd3af + ld hl, wWarpEntries ld a, [wd73b] ld b, a ld a, [wd73c] diff --git a/scripts/ssanne9.asm b/scripts/ssanne9.asm index 2ec0f28c5f..f25d553295 100755 --- a/scripts/ssanne9.asm +++ b/scripts/ssanne9.asm @@ -1,8 +1,8 @@ SSAnne9Script: ; 61b4b (18:5b4b) ld a, $1 - ld [wcf0c], a + ld [wAutoTextBoxDrawingControl], a xor a - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld hl, SSAnne9TrainerHeaders ld de, SSAnne9ScriptPointers ld a, [W_SSANNE9CURSCRIPT] diff --git a/scripts/vermiliondock.asm b/scripts/vermiliondock.asm index ca0ce66bfc..6ed2d23dfc 100755 --- a/scripts/vermiliondock.asm +++ b/scripts/vermiliondock.asm @@ -5,7 +5,7 @@ VermilionDockScript: ; 1db52 (7:5b52) jr nz, .asm_1db8d ; 0x1db5a $31 bit 0, [hl] ret z - ld a, [wd42f] + ld a, [wDestinationWarpID] cp $1 ret nz bit 2, [hl] @@ -75,7 +75,7 @@ VermilionDock_1db9b: ; 1db9b (7:5b9b) ld a, (SFX_02_54 - SFX_Headers_02) / 3 call PlaySoundWaitForCurrent ld a, $ff - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a ld d, $0 ld e, $8 .asm_1dbfa @@ -111,14 +111,14 @@ VermilionDock_1db9b: ; 1db9b (7:5b9b) ld a, $90 ld [hVBlankWY], a ld a, $1 - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a pop hl pop bc ld [hl], b dec hl ld [hl], c call LoadPlayerSpriteGraphics - ld hl, wd3ae + ld hl, wNumberOfWarps dec [hl] ret diff --git a/scripts/vermiliongym.asm b/scripts/vermiliongym.asm index fa6b2fc2af..685bd2cbb7 100755 --- a/scripts/vermiliongym.asm +++ b/scripts/vermiliongym.asm @@ -158,7 +158,7 @@ VermilionGymText1: ; 5cb1d (17:4b1d) ld de, ReceivedThunderbadgeText call PreBattleSaveRegisters ldh a, [$8c] - ld [wcf13], a + ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters ld a, $3 diff --git a/scripts/victoryroad3.asm b/scripts/victoryroad3.asm index e35e9131f7..e7d5ed1211 100755 --- a/scripts/victoryroad3.asm +++ b/scripts/victoryroad3.asm @@ -61,7 +61,7 @@ VictoryRoad3Script0: ; 449b7 (11:49b7) .asm_449fe ld a, $c2 - ld [wd71d], a + ld [wDungeonWarpDestinationMap], a ld hl, .coordsData_449f9 ; $49f9 call Func_46981 ld a, [wWhichTrade] ; wWhichTrade diff --git a/scripts/viridiangym.asm b/scripts/viridiangym.asm index 4c9e68219b..6b0673d1fa 100755 --- a/scripts/viridiangym.asm +++ b/scripts/viridiangym.asm @@ -286,16 +286,16 @@ ViridianGymText1: ; 74a69 (1d:4a69) jr .asm_6dff7 ; 0x74a7b .asm_9fc95 ; 0x74a7d ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld hl, ViridianGymText_74ad9 call PrintText - call GBFadeIn1 + call GBFadeOutToBlack ld a, $32 ld [wcc4d], a predef HideObject call UpdateSprites call Delay3 - call GBFadeOut1 + call GBFadeInFromBlack jr .asm_6dff7 ; 0x74a9e .asm_6de66 ; 0x74aa0 ld hl, ViridianGymText_74ace @@ -307,7 +307,7 @@ ViridianGymText1: ; 74a69 (1d:4a69) ld de, ViridianGymText_74ad3 call PreBattleSaveRegisters ldh a, [$8c] - ld [wcf13], a + ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters ld a, $8 diff --git a/wram.asm b/wram.asm index b98372f04f..a9bad0817e 100755 --- a/wram.asm +++ b/wram.asm @@ -260,7 +260,11 @@ wcc37:: ds 1 wcc38:: ds 2 wcc3a:: ds 1 wcc3b:: ds 1 -wcc3c:: ds 1 + +wDoNotWaitForButtonPressAfterDisplayingText:: ; cc3c +; if non-zero, skip waiting for a button press after displaying text in DisplayTextID + ds 1 + wcc3d:: ds 1 wcc3e:: ds 4 wcc42:: ds 1 @@ -496,17 +500,40 @@ wOverrideSimulatedJoypadStatesMask:: ; cd3b ds 1 +wFlyAnimUsingCoordList:: ; cd3d + +wPlayerSpinInPlaceAnimFrameDelay:: ; cd3d + +wPlayerSpinWhileMovingUpOrDownAnimDeltaY:: ; cd3d + wWhichTrade:: ; cd3d ; which entry from TradeMons to select ; ds 1 wTrainerSpriteOffset:: ; cd3d ds 1 + +wFlyAnimCounter:: ; cd3e + +wPlayerSpinInPlaceAnimFrameDelayDelta:: ; cd3e + +wPlayerSpinWhileMovingUpOrDownAnimMaxY:: ; cd3e + wTrainerEngageDistance:: ; cd3e ds 1 + +wFlyAnimBirdSpriteImageIndex:: ; cd3f + +wPlayerSpinInPlaceAnimFrameDelayEndValue:: ; cd3f + +wPlayerSpinWhileMovingUpOrDownAnimFrameDelay:: ; cd3f + wTrainerFacingDirection:: ; cd3f wcd3f:: ds 1 + +wPlayerSpinInPlaceAnimSoundID:: ; cd40 + wTrainerScreenY:: ; cd40 ds 1 wTrainerScreenX:: ; cd41 @@ -593,7 +620,11 @@ wBattleResult:: ; cf0b ; $01 - lose ; $02 - draw ds 1 -wcf0c:: ds 1 + +wAutoTextBoxDrawingControl:: ; cf0c +; bit 0: if set, DisplayTextID automatically draws a text box + ds 1 + wcf0d:: ds 1 wcf0e:: ds 1 wcf0f:: ds 1 @@ -608,7 +639,7 @@ wcf11:: ds 1 wPredefParentBank:: ; cf12 ds 1 -wcf13:: ds 1 +wSpriteIndex:: ds 1 wCurSpriteMovement2:: ; cf14 ; movement byte 2 of current sprite @@ -625,7 +656,10 @@ wcf18:: ds 2 wGBC:: ; cf1a ds 1 -wcf1b:: ds 1 +wOnSGB:: ; cf1b +; if running on SGB, it's 1, else it's 0 + ds 1 + wcf1c:: ds 1 wcf1d:: ds 1 wcf1e:: ds 1 @@ -692,7 +726,9 @@ wWalkCounter:: ; cfc5 ; walk animation counter ds 1 -wcfc6:: ds 1 +wTileInFrontOfPlayer:: ; cfc6 +; background tile number in front of the player (either 1 or 2 steps ahead) + ds 1 wMusicHeaderPointer:: ; cfc7 ; (the current music channel address - $4000) / 3 @@ -701,7 +737,10 @@ wMusicHeaderPointer:: ; cfc7 wcfc8:: ds 1 wcfc9:: ds 1 wcfca:: ds 1 -wcfcb:: ds 1 + +wUpdateSpritesEnabled:: ; cfcb +; $01 enables UpdateSprites; anything else disables it + ds 1 W_ENEMYMOVENUM:: ; cfcc ds 1 @@ -1121,7 +1160,11 @@ wd0dc:: ds 4 wd0e0:: ds 1 wd0e1:: ds 56 wd119:: ds 1 -wd11a:: ds 1 + +wWalkBikeSurfStateCopy:: ; d11a +; wWalkBikeSurfState is sometimes copied here, but it doesn't seem to be used for anything + ds 1 + wd11b:: ds 1 wd11c:: ds 1 wd11d:: ds 1 @@ -1158,8 +1201,14 @@ wd132:: ds 1 wd133:: ds 6 wd139:: ds 1 wd13a:: ds 1 -wd13b:: ds 1 -wd13c:: ds 1 + +wStepCounter:: ; d13b +; counts down once every step + ds 1 + +wNumberOfNoRandomBattleStepsLeft:: ; d13c +; after a battle, you have at least 3 steps before a random battle can occur + ds 1 W_PRIZE1:: ; d13d ds 1 @@ -1246,13 +1295,18 @@ wPlayerID:: ; d359 wd35b:: ds 1 wd35c:: ds 1 -wd35d:: ds 1 + +wMapPalOffset:: ; d35d +; offset subtracted from FadePal4 to get the background and object palettes for the current map +; normally, it is 0. it is 6 when Flash is needed, causing FadePal2 to be used instead of FadePal4 + ds 1 W_CURMAP:: ; d35e ds 1 -wd35f:: ds 1 -wd360:: ds 1 +wCurrentTileBlockMapViewPointer:: ; d35f +; pointer to the upper left corner of the current view in the tile block map + ds 2 W_YCOORD:: ; d361 ; player’s position on the current map @@ -1364,26 +1418,42 @@ W_SPRITESETID:: ; d3a8 wd3a9:: ds 1 wd3aa:: ds 3 wd3ad:: ds 1 -wd3ae:: ds 1 -wd3af:: ds 128 -wd42f:: ds 129 + +wNumberOfWarps:: ; d3ae +; number of warps in current map + ds 1 + +wWarpEntries:: ; d3af +; current map warp entries + ds 128 + +wDestinationWarpID:: ; d42f +; if $ff, the player's coordinates are not updated when entering the map + ds 1 + + ds 128 + wd4b0:: ds 1 wd4b1:: ds 32 wd4d1:: ds 16 W_NUMSPRITES:: ; d4e1 ; number of sprites on the current map -; two bytes per sprite (movement byte 2 , text ID) ds 1 -wd4e2:: ds 1 -wd4e3:: ds 1 +; these two variables track the X and Y offset in blocks from the last special warp used +; they don't seem to be used for anything +wYOffsetSinceLastSpecialWarp:: ; d4e2 + ds 1 +wXOffsetSinceLastSpecialWarp:: ; d4e3 + ds 1 W_MAPSPRITEDATA:: ; d4e4 -; two bytes per sprite (trainer class/item ID , trainer set ID) +; two bytes per sprite (movement byte 2, text ID) ds 32 W_MAPSPRITEEXTRADATA:: ; d504 +; two bytes per sprite (trainer class/item ID, trainer set ID) ds 32 wd524:: ds 1 @@ -1661,7 +1731,14 @@ W_ROUTE18GATECURSCRIPT:: ; d669 wd6f0:: ds 14 wd6fe:: ds 2 -wd700:: ds 11 + +wWalkBikeSurfState:: ; d700 +; $00 = walking +; $01 = biking +; $02 = surfing + ds 1 + + ds 10 W_TOWNVISITEDFLAG:: ; d70b flag_array 13 @@ -1684,7 +1761,8 @@ W_ENEMYMONORTRAINERCLASS:: ; d713 ; trainer classes start at $c8 ds 1 -wd714:: ds 1 +wPlayerJumpingYScreenCoordsIndex:: ; d714 + ds 1 W_RIVALSTARTER:: ; d715 ds 1 @@ -1694,16 +1772,32 @@ W_RIVALSTARTER:: ; d715 W_PLAYERSTARTER:: ; d717 ds 1 -wd718:: ds 1 +wBoulderSpriteIndex:: ; d718 +; sprite index of the boulder the player is trying to push + ds 1 wLastBlackoutMap:: ; d719 ds 1 -wd71a:: ds 1 +wDestinationMap:: ; d71a +; destination map (for certain types of special warps, not ordinary walking) + ds 1 + wd71b:: ds 1 -wd71c:: ds 1 -wd71d:: ds 1 -wd71e:: ds 1 + +wTileInFrontOfBoulderAndBoulderCollisionResult:: ; d71c +; used to store the tile in front of the boulder when trying to push a boulder +; also used to store the result of the collision check ($ff for a collision and $00 for no collision) + ds 1 + +wDungeonWarpDestinationMap:: ; d71d +; destination map for dungeon warps + ds 1 + +wWhichDungeonWarp:: ; d71e +; which dungeon warp within the source map was used + ds 1 + wd71f:: ds 9 wd728:: @@ -1713,7 +1807,11 @@ wd728:: ds 1 wd72a:: ds 2 -wd72c:: ds 1 + +wd72c:: ; d72c +; bit 0: if not set, the 3 minimum steps between random battles have passed + ds 1 + wd72d:: ds 1 wd72e:: ds 2 @@ -1723,16 +1821,31 @@ wd730:: ds 1 -wd732:: ds 1 +wd732:: ; d732 +; bit 0: play time being counted +; bit 1: remnant of debug mode? not set by the game code. +; if it is set +; 1. skips most of Prof. Oak's speech, and uses NINTEN as the player's name and SONY as the rival's name +; 2. does not have the player start in floor two of the playyer's house (instead sending them to [wLastMap]) +; 3. allows wild battles to be avoided by holding down B +; bit 2: the target warp is a fly warp (bit 3 set or blacked out) or a dungeon warp (bit 4 set) +; bit 3: used warp pad, escape rope, dig, teleport, or fly, so the target warp is a "fly warp" +; bit 4: jumped into hole (Pokemon Mansion, Seafoam Islands, Victory Road) or went down waterfall (Seafoam Islands), so the target warp is a "dungeon warp" +; bit 5: currently being forced to ride bike (cycling road) +; bit 6: map destination is [wLastBlackoutMap] (usually the last used pokemon center, but could be the player's house) + ds 1 W_FLAGS_D733:: ; d733 ; bit 4: use variable [W_CURMAPSCRIPT] instead of the provided index for next frame's map script (used to start battle when talking to trainers) +; bit 7: used fly out of battle ds 1 wd734:: ds 2 wd736:: ; d736 ; bit 0: check if the player is standing on a door and make him walk down a step if so +; bit 2: standing on a warp +; bit 6: jumping down a ledge ds 1 wd737:: ds 4 From 2ed65d9c3e3ba60939ebe2928ffddc06a90b1876 Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Sun, 14 Sep 2014 11:29:18 -0700 Subject: [PATCH 018/100] Commented/labelled misc functions --- constants/hardware_constants.asm | 20 +-- engine/battle/14.asm | 2 +- engine/battle/core.asm | 8 +- engine/cable_club.asm | 2 +- engine/evolution.asm | 2 +- engine/evos_moves.asm | 4 +- engine/hall_of_fame.asm | 2 +- engine/hidden_object_functions18.asm | 2 +- engine/hidden_object_functions3.asm | 27 ++-- engine/hidden_object_functions7.asm | 6 +- engine/in_game_trades.asm | 2 +- engine/menu/bills_pc.asm | 2 +- engine/menu/league_pc.asm | 6 +- engine/menu/pokedex.asm | 6 +- engine/menu/start_sub_menus.asm | 6 +- engine/menu/status_screen.asm | 12 +- engine/oak_speech.asm | 2 +- engine/overworld/card_key.asm | 66 ++++---- engine/overworld/cut.asm | 4 +- engine/overworld/elevator.asm | 2 +- engine/overworld/hidden_objects.asm | 110 +++++++------- engine/overworld/npc_movement.asm | 13 +- engine/play_time.asm | 26 ++-- engine/predefs.asm | 8 +- engine/save.asm | 192 ++++++++++++------------ engine/titlescreen.asm | 2 +- engine/town_map.asm | 41 ++--- engine/trade.asm | 2 +- home.asm | 217 ++++++++++++++------------- home/init.asm | 4 +- home/overworld.asm | 112 +++++++------- home/vblank.asm | 8 +- home/vcopy.asm | 7 +- hram.asm | 9 ++ macros.asm | 4 +- main.asm | 94 ++++++------ scripts/agatha.asm | 4 +- scripts/bruno.asm | 4 +- scripts/celadongamecorner.asm | 6 +- scripts/celadongym.asm | 4 +- scripts/ceruleancity.asm | 4 +- scripts/ceruleangym.asm | 4 +- scripts/cinnabargym.asm | 16 +- scripts/fightingdojo.asm | 4 +- scripts/fuchsiagym.asm | 4 +- scripts/gary.asm | 2 +- scripts/lance.asm | 4 +- scripts/lorelei.asm | 4 +- scripts/mansion1.asm | 4 +- scripts/mansion2.asm | 4 +- scripts/mansion3.asm | 2 +- scripts/mansion4.asm | 2 +- scripts/mtmoon1.asm | 2 +- scripts/mtmoon3.asm | 4 +- scripts/oakslab.asm | 2 +- scripts/pewtergym.asm | 4 +- scripts/pokemontower2.asm | 2 +- scripts/pokemontower3.asm | 2 +- scripts/pokemontower4.asm | 2 +- scripts/pokemontower5.asm | 2 +- scripts/pokemontower6.asm | 2 +- scripts/pokemontower7.asm | 2 +- scripts/powerplant.asm | 2 +- scripts/rockethideout1.asm | 4 +- scripts/rockethideout2.asm | 4 +- scripts/rockethideout3.asm | 4 +- scripts/rockethideout4.asm | 6 +- scripts/rocktunnel1.asm | 2 +- scripts/rocktunnel2.asm | 2 +- scripts/route10.asm | 2 +- scripts/route11.asm | 2 +- scripts/route12.asm | 2 +- scripts/route13.asm | 2 +- scripts/route14.asm | 2 +- scripts/route15.asm | 2 +- scripts/route16.asm | 2 +- scripts/route17.asm | 2 +- scripts/route18.asm | 2 +- scripts/route19.asm | 2 +- scripts/route20.asm | 2 +- scripts/route21.asm | 2 +- scripts/route22.asm | 4 +- scripts/route24.asm | 4 +- scripts/route25.asm | 2 +- scripts/route3.asm | 2 +- scripts/route4.asm | 2 +- scripts/route6.asm | 2 +- scripts/route8.asm | 2 +- scripts/route9.asm | 2 +- scripts/saffrongym.asm | 4 +- scripts/silphco10.asm | 4 +- scripts/silphco11.asm | 10 +- scripts/silphco2.asm | 10 +- scripts/silphco3.asm | 6 +- scripts/silphco4.asm | 10 +- scripts/silphco5.asm | 8 +- scripts/silphco6.asm | 4 +- scripts/silphco7.asm | 14 +- scripts/silphco8.asm | 8 +- scripts/silphco9.asm | 14 +- scripts/ssanne10.asm | 2 +- scripts/ssanne2.asm | 2 +- scripts/ssanne5.asm | 2 +- scripts/ssanne8.asm | 2 +- scripts/ssanne9.asm | 2 +- scripts/unknowndungeon3.asm | 2 +- scripts/vermiliondock.asm | 6 +- scripts/vermiliongym.asm | 6 +- scripts/victoryroad1.asm | 4 +- scripts/victoryroad2.asm | 4 +- scripts/victoryroad3.asm | 4 +- scripts/viridianforest.asm | 2 +- scripts/viridiangym.asm | 6 +- wram.asm | 69 +++++++-- 114 files changed, 733 insertions(+), 668 deletions(-) diff --git a/constants/hardware_constants.asm b/constants/hardware_constants.asm index 8e926a117e..e875622dfc 100644 --- a/constants/hardware_constants.asm +++ b/constants/hardware_constants.asm @@ -2,27 +2,17 @@ GBC EQU $11 -; MBC3 -MBC3SRamEnable EQU $0000 -MBC3RomBank EQU $2000 -MBC3SRamBank EQU $4000 -MBC3LatchClock EQU $6000 -MBC3RTC EQU $a000 +; MBC1 +MBC1SRamEnable EQU $0000 +MBC1RomBank EQU $2000 +MBC1SRamBank EQU $4000 +MBC1SRamBankingMode EQU $6000 SRAM_DISABLE EQU $00 SRAM_ENABLE EQU $0a NUM_SRAM_BANKS EQU 4 -RTC_S EQU $08 ; Seconds 0-59 (0-3Bh) -RTC_M EQU $09 ; Minutes 0-59 (0-3Bh) -RTC_H EQU $0a ; Hours 0-23 (0-17h) -RTC_DL EQU $0b ; Lower 8 bits of Day Counter (0-FFh) -RTC_DH EQU $0c ; Upper 1 bit of Day Counter, Carry Bit, Halt Flag - ; Bit 0 Most significant bit of Day Counter (Bit 8) - ; Bit 6 Halt (0=Active, 1=Stop Timer) - ; Bit 7 Day Counter Carry Bit (1=Counter Overflow) - ; interrupt flags VBLANK EQU 0 LCD_STAT EQU 1 diff --git a/engine/battle/14.asm b/engine/battle/14.asm index 530032a0aa..18aaa5e1b8 100755 --- a/engine/battle/14.asm +++ b/engine/battle/14.asm @@ -1,5 +1,5 @@ Func_525af: ; 525af (14:65af) - ld a, [$ffd7] + ld a, [hTilesetType] ld [wd0d4], a xor a ld [wcd6a], a diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 26465b8f28..7b1c1d129c 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -136,7 +136,7 @@ SlidePlayerAndEnemySilhouettesOnScreen: ; 3c04c (f:404c) ld [hVBlankWY], a ld [rWY], a xor a - ld [$ffd7], a + ld [hTilesetType], a ld [hVBlankSCY], a dec a ld [wUpdateSpritesEnabled], a @@ -1015,7 +1015,7 @@ TrainerBattleVictory: ; 3c696 (f:4696) call ScrollTrainerPicAfterBattle ld c, $28 call DelayFrames - call Func_3381 + call PrintEndBattleText ld hl, MoneyForWinningText call PrintText ld de, wPlayerMoney + 2 @@ -6263,7 +6263,7 @@ DoBattleTransitionAndInitBattleVariables: ; 3ec32 (f:6c32) ld [H_AUTOBGTRANSFERENABLED], a ld [hVBlankWY], a ld [rWY], a - ld [$ffd7], a + ld [hTilesetType], a ld hl, wd060 ld [hli], a ld [hli], a @@ -6851,7 +6851,7 @@ InitBattle_Common: ; 3efeb (f:6feb) pop af ld [wMapPalOffset], a ld a, [wd0d4] - ld [$ffd7], a + ld [hTilesetType], a scf ret .emptyString diff --git a/engine/cable_club.asm b/engine/cable_club.asm index 9b4017e274..34a9d0a122 100755 --- a/engine/cable_club.asm +++ b/engine/cable_club.asm @@ -572,7 +572,7 @@ Func_577d: ; 577d (1:577d) dec a ld [wDestinationWarpID], a call LoadMapData - callba Func_c335 + callba ClearVariablesAfterLoadingMapData pop hl pop af ld [hl], a diff --git a/engine/evolution.asm b/engine/evolution.asm index 07ccdbda97..106107d2b4 100755 --- a/engine/evolution.asm +++ b/engine/evolution.asm @@ -19,7 +19,7 @@ Func_7bde9: ; 7bde9 (1e:7de9) call Delay3 xor a ld [H_AUTOBGTRANSFERENABLED], a ; $ffba - ld [$ffd7], a + ld [hTilesetType], a ld a, [wHPBarMaxHP] ld [wcf1d], a ld c, $0 diff --git a/engine/evos_moves.asm b/engine/evos_moves.asm index 240fd9faf5..bda4c9ff28 100755 --- a/engine/evos_moves.asm +++ b/engine/evos_moves.asm @@ -11,7 +11,7 @@ TryEvolvingMon: ; 3ad0e (e:6d0e) ; this is only called after battle ; it is supposed to do level up evolutions, though there is a bug that allows item evolutions to occur EvolutionAfterBattle: ; 3ad1c (e:6d1c) - ld a, [$ffd7] + ld a, [hTilesetType] push af xor a ld [wd121], a @@ -245,7 +245,7 @@ Evolution_PartyMonLoop: ; loop over party mons pop bc pop hl pop af - ld [$ffd7], a + ld [hTilesetType], a ld a, [W_ISLINKBATTLE] cp $32 ret z diff --git a/engine/hall_of_fame.asm b/engine/hall_of_fame.asm index 30ae626633..406fac01ae 100755 --- a/engine/hall_of_fame.asm +++ b/engine/hall_of_fame.asm @@ -19,7 +19,7 @@ AnimateHallOfFame: ; 701a0 (1c:41a0) call FillMemory xor a ld [wUpdateSpritesEnabled], a - ld [$ffd7], a + ld [hTilesetType], a ld [W_SPRITEFLIPPED], a ld [wd358], a ld [wTrainerScreenY], a diff --git a/engine/hidden_object_functions18.asm b/engine/hidden_object_functions18.asm index 9dd7fac724..7696626f2a 100755 --- a/engine/hidden_object_functions18.asm +++ b/engine/hidden_object_functions18.asm @@ -70,7 +70,7 @@ PrintBenchGuyText: ; 6245d (18:645d) ld a, [hl] jp PrintPredefTextID -; format: db map id, 08, text id of PointerTable_3f22 +; format: db map id, 08, text id of PredefTextIDPointerTable PokeCenterMapIDList: ; 6247e (18:647e) db VIRIDIAN_POKECENTER,$08,$0F db PEWTER_POKECENTER,$08,$10 diff --git a/engine/hidden_object_functions3.asm b/engine/hidden_object_functions3.asm index 09d9ebccbf..d3d83f0875 100755 --- a/engine/hidden_object_functions3.asm +++ b/engine/hidden_object_functions3.asm @@ -1,22 +1,23 @@ ; prints text for bookshelves in buildings without sign events PrintBookshelfText: ; fb50 (3:7b50) - ld a, [wSpriteStateData1 + 9] - cp $4 - jr nz, .asm_fb7f - ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET + ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction + cp SPRITE_FACING_UP + jr nz, .noMatch +; facing up + ld a, [W_CURMAPTILESET] ld b, a aCoord 8, 7 ld c, a - ld hl, BookshelfTileIDs ; $7b8b -.asm_fb62 + ld hl, BookshelfTileIDs +.loop ld a, [hli] cp $ff - jr z, .asm_fb7f + jr z, .noMatch cp b - jr nz, .asm_fb7b + jr nz, .nextBookshelfEntry1 ld a, [hli] cp c - jr nz, .asm_fb7c + jr nz, .nextBookshelfEntry2 ld a, [hl] push af call EnableAutoTextBoxDrawing @@ -25,12 +26,12 @@ PrintBookshelfText: ; fb50 (3:7b50) xor a ld [$ffdb], a ret -.asm_fb7b +.nextBookshelfEntry1 inc hl -.asm_fb7c +.nextBookshelfEntry2 inc hl - jr .asm_fb62 -.asm_fb7f + jr .loop +.noMatch ld a, $ff ld [$ffdb], a ld b, BANK(PrintCardKeyText) diff --git a/engine/hidden_object_functions7.asm b/engine/hidden_object_functions7.asm index c00749e4fc..012e941d92 100755 --- a/engine/hidden_object_functions7.asm +++ b/engine/hidden_object_functions7.asm @@ -60,7 +60,7 @@ SafariZoneCheckSteps: ; 1e997 (7:6997) ld [wSafariSteps + 1], a ; wd70e asm_1e9ab: ; 1e9ab (7:69ab) xor a - ld [wda46], a + ld [wSafariZoneGameOver], a ret asm_1e9b0: ; 1e9b0 (7:69b0) call EnableAutoTextBoxDrawing @@ -89,7 +89,7 @@ asm_1e9b0: ; 1e9b0 (7:69b0) ld hl, wd790 set 6, [hl] ld a, $1 - ld [wda46], a + ld [wSafariZoneGameOver], a ret PrintSafariGameOverText: ; 1e9ed (7:69ed) @@ -291,7 +291,7 @@ CinnabarGymQuiz_1eb0a: ; 1eb0a (7:6b0a) .asm_1eb38 pop bc ld [wd09f], a - predef Func_ee9e + predef ReplaceTileBlock ld hl, $ffdb dec [hl] jr nz, .asm_1eb0e diff --git a/engine/in_game_trades.asm b/engine/in_game_trades.asm index 4f232eb4cd..7464edb373 100755 --- a/engine/in_game_trades.asm +++ b/engine/in_game_trades.asm @@ -138,7 +138,7 @@ Func_71c07: ; 71c07 (1c:5c07) callab EvolveTradeMon call ClearScreen call Func_71ca2 - callba Func_eedc + callba RedrawMapView and a ld a,$3 jr .asm_ee803 ; 0x71c9b $1 diff --git a/engine/menu/bills_pc.asm b/engine/menu/bills_pc.asm index b5ee9b94e4..65b70bb1c5 100644 --- a/engine/menu/bills_pc.asm +++ b/engine/menu/bills_pc.asm @@ -332,7 +332,7 @@ Func_21673: ; 21673 (8:5673) jp Func_214e8 Func_216b3: ; 216b3 (8:56b3) - callba Func_738a1 + callba ChangeBox jp Func_214e8 Func_216be: ; 216be (8:56be) diff --git a/engine/menu/league_pc.asm b/engine/menu/league_pc.asm index ffde236a1a..a6dd70214e 100755 --- a/engine/menu/league_pc.asm +++ b/engine/menu/league_pc.asm @@ -6,10 +6,10 @@ PKMNLeaguePC: ; 0x7657e push hl ld a, [wUpdateSpritesEnabled] push af - ld a, [$ffD7] + ld a, [hTilesetType] push af xor a - ld [$ffD7], a + ld [hTilesetType], a ld [W_SPRITEFLIPPED], a ld [wUpdateSpritesEnabled], a ld [wTrainerScreenX], a @@ -38,7 +38,7 @@ PKMNLeaguePC: ; 0x7657e jr nz, .first .second pop af - ld [$ffD7], a + ld [hTilesetType], a pop af ld [wUpdateSpritesEnabled], a pop hl diff --git a/engine/menu/pokedex.asm b/engine/menu/pokedex.asm index 8f4bc508ea..152b81290e 100755 --- a/engine/menu/pokedex.asm +++ b/engine/menu/pokedex.asm @@ -404,10 +404,10 @@ ShowPokedexDataInternal: ; 402e2 (10:42e2) call GoPAL_SET pop af ld [wd11e],a - ld a,[$ffd7] + ld a,[hTilesetType] push af xor a - ld [$ffd7],a + ld [hTilesetType],a hlCoord 0, 0 ld de,1 ld bc,$6414 @@ -554,7 +554,7 @@ ShowPokedexDataInternal: ; 402e2 (10:42e2) and a,%00000011 ; A button and B button jr z,.waitForButtonPress pop af - ld [$ffd7],a + ld [hTilesetType],a call GBPalWhiteOut call ClearScreen call GoPAL_SET_CF1C diff --git a/engine/menu/start_sub_menus.asm b/engine/menu/start_sub_menus.asm index e91386b0a8..c6373e765f 100755 --- a/engine/menu/start_sub_menus.asm +++ b/engine/menu/start_sub_menus.asm @@ -500,10 +500,10 @@ StartMenu_TrainerInfo: ; 13460 (4:7460) call GBPalWhiteOut call ClearScreen call UpdateSprites ; move sprites - ld a,[$ffd7] + ld a,[hTilesetType] push af xor a - ld [$ffd7],a + ld [hTilesetType],a call DrawTrainerInfo predef DrawBadges ; draw badges ld b,$0d @@ -517,7 +517,7 @@ StartMenu_TrainerInfo: ; 13460 (4:7460) call ReloadMapData call LoadGBPal pop af - ld [$ffd7],a + ld [hTilesetType],a jp RedisplayStartMenu ; loads tile patterns and draws everything except for gym leader faces / badges diff --git a/engine/menu/status_screen.asm b/engine/menu/status_screen.asm index 65b06e9da5..f215fd0e81 100755 --- a/engine/menu/status_screen.asm +++ b/engine/menu/status_screen.asm @@ -36,10 +36,10 @@ StatusScreen: ; 12953 (4:6953) ld hl, vChars2 + $720 ld bc,(BANK(PTile) << 8 | $01) call CopyVideoDataDouble ; P (for PP), inline - ld a, [$ffd7] + ld a, [hTilesetType] push af xor a - ld [$ffd7], a + ld [hTilesetType], a hlCoord 19, 1 ld bc, $060a call DrawLineBox ; Draws the box around name, HP and status @@ -109,7 +109,7 @@ StatusScreen: ; 12953 (4:6953) call PlayCry ; play Pokémon cry call WaitForTextScrollButtonPress ; wait for button pop af - ld [$ffd7], a + ld [hTilesetType], a ret .unk_12a7e ; 0x12a7e ; I don't know what this does, iterates over pointers? ld a, [wcc49] @@ -227,10 +227,10 @@ StatsText: ; 12b3a (4:6b3a) next "SPECIAL@" StatusScreen2: ; 12b57 (4:6b57) - ld a, [$ffd7] + ld a, [hTilesetType] push af xor a - ld [$ffd7], a + ld [hTilesetType], a ld [$ffba], a ld bc, $0005 ld hl, wd0dc @@ -360,7 +360,7 @@ StatusScreen2: ; 12b57 (4:6b57) call Delay3 call WaitForTextScrollButtonPress ; wait for button pop af - ld [$ffd7], a + ld [hTilesetType], a ld hl, wd72c res 1, [hl] ld a, $77 diff --git a/engine/oak_speech.asm b/engine/oak_speech.asm index 518bea2a81..0cbdaa3dee 100755 --- a/engine/oak_speech.asm +++ b/engine/oak_speech.asm @@ -52,7 +52,7 @@ OakSpeech: ; 6115 (1:6115) ld [wDestinationMap],a call SpecialWarpIn xor a - ld [$FFD7],a + ld [hTilesetType],a ld a,[wd732] bit 1,a ; XXX when is bit 1 set? jp nz,Func_61bc ; easter egg: skip the intro diff --git a/engine/overworld/card_key.asm b/engine/overworld/card_key.asm index 885932d512..c4df0d51b0 100755 --- a/engine/overworld/card_key.asm +++ b/engine/overworld/card_key.asm @@ -2,18 +2,18 @@ PrintCardKeyText: ; 52673 (14:6673) ld hl, SilphCoMapList ld a, [W_CURMAP] ld b, a -.asm_5267a +.silphCoMapListLoop ld a, [hli] cp $ff ret z cp b - jr nz, .asm_5267a + jr nz, .silphCoMapListLoop predef GetTileAndCoordsInFrontOfPlayer ld a, [wTileInFrontOfPlayer] cp $18 - jr z, .asm_5269c + jr z, .cardKeyDoorInFrontOfPlayer cp $24 - jr z, .asm_5269c + jr z, .cardKeyDoorInFrontOfPlayer ld b, a ld a, [W_CURMAP] cp SILPH_CO_11F @@ -21,41 +21,41 @@ PrintCardKeyText: ; 52673 (14:6673) ld a, b cp $5e ret nz -.asm_5269c +.cardKeyDoorInFrontOfPlayer ld b, CARD_KEY call IsItemInBag - jr z, .asm_526dc - call Func_526fd + jr z, .noCardKey + call GetCoordsInFrontOfPlayer push de ld a, $1 - ld [H_DOWNARROWBLINKCNT2], a ; $ff8c + ld [H_DOWNARROWBLINKCNT2], a call PrintPredefTextID pop de srl d ld a, d ld b, a - ld [wd73f], a + ld [wCardKeyDoorY], a srl e ld a, e ld c, a - ld [wd740], a - ld a, [W_CURMAP] ; W_CURMAP + ld [wCardKeyDoorX], a + ld a, [W_CURMAP] cp SILPH_CO_11F - jr nz, .asm_526c8 + jr nz, .notSilphCo11F ld a, $3 - jr .asm_526ca -.asm_526c8 + jr .replaceCardKeyDoorTileBlock +.notSilphCo11F ld a, $e -.asm_526ca +.replaceCardKeyDoorTileBlock ld [wd09f], a - predef Func_ee9e + predef ReplaceTileBlock ld hl, wd126 set 5, [hl] ld a, (SFX_1f_57 - SFX_Headers_1f) / 3 jp PlaySound -.asm_526dc +.noCardKey ld a, $2 - ld [H_DOWNARROWBLINKCNT2], a ; $ff8c + ld [H_DOWNARROWBLINKCNT2], a jp PrintPredefTextID SilphCoMapList: ; 526e3 (14:66e3) @@ -81,26 +81,32 @@ CardKeyFailText: ; 526f8 (14:66f8) TX_FAR _CardKeyFailText db "@" -Func_526fd: ; 526fd (14:66fd) - ld a, [W_YCOORD] ; wd361 +; d = Y +; e = X +GetCoordsInFrontOfPlayer: ; 526fd (14:66fd) + ld a, [W_YCOORD] ld d, a - ld a, [W_XCOORD] ; wd362 + ld a, [W_XCOORD] ld e, a - ld a, [wSpriteStateData1 + 9] + ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction and a - jr nz, .asm_5270d + jr nz, .notFacingDown +; facing down inc d ret -.asm_5270d - cp $4 - jr nz, .asm_52713 +.notFacingDown + cp SPRITE_FACING_UP + jr nz, .notFacingUp +; facing up dec d ret -.asm_52713 - cp $8 - jr nz, .asm_52719 +.notFacingUp + cp SPRITE_FACING_LEFT + jr nz, .notFacingLeft +; facing left dec e ret -.asm_52719 +.notFacingLeft +; facing right inc e ret diff --git a/engine/overworld/cut.asm b/engine/overworld/cut.asm index 0cbc021403..f57b646581 100755 --- a/engine/overworld/cut.asm +++ b/engine/overworld/cut.asm @@ -56,7 +56,7 @@ asm_ef82: ; ef82 (3:6f82) call AnimateCutTree ld de, CutTreeBlockSwaps ; $7100 call Func_f09f - call Func_eedc + call RedrawMapView callba Func_79e96 ld a, $1 ld [wUpdateSpritesEnabled], a @@ -65,7 +65,7 @@ asm_ef82: ; ef82 (3:6f82) ld a, $90 ld [hVBlankWY], a call UpdateSprites - jp Func_eedc + jp RedrawMapView UsedCutText: ; eff2 (3:6ff2) TX_FAR _UsedCutText diff --git a/engine/overworld/elevator.asm b/engine/overworld/elevator.asm index d1d7d82a45..c2191b919d 100755 --- a/engine/overworld/elevator.asm +++ b/engine/overworld/elevator.asm @@ -41,7 +41,7 @@ ShakeElevator: ; 7bf15 (1e:7f15) jp PlayDefaultMusic Func_7bf64: ; 7bf64 (1e:7f64) - ld hl, wd527 + ld hl, wMapViewVRAMPointer + 1 ld a, [hld] push af ld a, [hl] diff --git a/engine/overworld/hidden_objects.asm b/engine/overworld/hidden_objects.asm index 1be5170c48..ae67aeed00 100755 --- a/engine/overworld/hidden_objects.asm +++ b/engine/overworld/hidden_objects.asm @@ -6,7 +6,7 @@ Func_46981: ; 46981 (11:6981) ret nz call ArePlayerCoordsInArray ret nc - ld a, [wWhichTrade] ; wWhichTrade + ld a, [wWhichTrade] ld [wWhichDungeonWarp], a ld hl, wd72d set 4, [hl] @@ -14,7 +14,8 @@ Func_46981: ; 46981 (11:6981) set 4, [hl] ret -Func_469a0: ; 469a0 (11:69a0) +; if a hidden object was found, stores $00 in [$ffee], else stores $ff +CheckForHiddenObject: ; 469a0 (11:69a0) ld hl, $ffeb xor a ld [hli], a @@ -22,107 +23,110 @@ Func_469a0: ; 469a0 (11:69a0) ld [hli], a ld [hl], a ld de, $0 - ld hl, HiddenObjectMaps ; $6a40 -.asm_469ae + ld hl, HiddenObjectMaps +.hiddenMapLoop ld a, [hli] ld b, a cp $ff - jr z, .asm_469fc - ld a, [W_CURMAP] ; W_CURMAP + jr z, .noMatch + ld a, [W_CURMAP] cp b - jr z, .asm_469be + jr z, .foundMatchingMap inc de inc de - jr .asm_469ae -.asm_469be - ld hl, HiddenObjectPointers ; $6a96 + jr .hiddenMapLoop +.foundMatchingMap + ld hl, HiddenObjectPointers add hl, de ld a, [hli] ld h, [hl] ld l, a push hl - ld hl, wWhichTrade ; wWhichTrade + ld hl, wHiddenObjectFunctionArgument xor a ld [hli], a ld [hli], a ld [hl], a pop hl -.asm_469ce +.hiddenObjectLoop ld a, [hli] cp $ff - jr z, .asm_469fc - ld [wTrainerScreenY], a + jr z, .noMatch + ld [wHiddenObjectY], a ld b, a ld a, [hli] - ld [wTrainerScreenX], a + ld [wHiddenObjectX], a ld c, a - call Func_46a01 + call CheckIfCoordsInFrontOfPlayerMatch ld a, [$ffea] and a - jr z, .asm_469f0 + jr z, .foundMatchingObject inc hl inc hl inc hl inc hl push hl - ld hl, wTrainerFacingDirection + ld hl, wHiddenObjectIndex inc [hl] pop hl - jr .asm_469ce -.asm_469f0 + jr .hiddenObjectLoop +.foundMatchingObject ld a, [hli] - ld [wWhichTrade], a ; wWhichTrade + ld [wHiddenObjectFunctionArgument], a ld a, [hli] - ld [wTrainerEngageDistance], a + ld [wHiddenObjectFunctionRomBank], a ld a, [hli] ld h, [hl] ld l, a ret -.asm_469fc +.noMatch ld a, $ff ld [$ffee], a ret -Func_46a01: ; 46a01 (11:6a01) - ld a, [wSpriteStateData1 + 9] - cp $4 - jr z, .asm_46a16 - cp $8 - jr z, .asm_46a25 - cp $c - jr z, .asm_46a2b - ld a, [W_YCOORD] ; wd361 +; checks if the coordinates in front of the player's sprite match Y in b and X in c +; [$ffea] = $00 if they match, $ff if they don't match +CheckIfCoordsInFrontOfPlayerMatch: ; 46a01 (11:6a01) + ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction + cp SPRITE_FACING_UP + jr z, .facingUp + cp SPRITE_FACING_LEFT + jr z, .facingLeft + cp SPRITE_FACING_RIGHT + jr z, .facingRight +; facing down + ld a, [W_YCOORD] inc a - jr .asm_46a1a -.asm_46a16 - ld a, [W_YCOORD] ; wd361 + jr .upDownCommon +.facingUp + ld a, [W_YCOORD] dec a -.asm_46a1a +.upDownCommon cp b - jr nz, .asm_46a3b - ld a, [W_XCOORD] ; wd362 + jr nz, .didNotMatch + ld a, [W_XCOORD] cp c - jr nz, .asm_46a3b - jr .asm_46a38 -.asm_46a25 - ld a, [W_XCOORD] ; wd362 + jr nz, .didNotMatch + jr .matched +.facingLeft + ld a, [W_XCOORD] dec a - jr .asm_46a2f -.asm_46a2b - ld a, [W_XCOORD] ; wd362 + jr .leftRightCommon +.facingRight + ld a, [W_XCOORD] inc a -.asm_46a2f +.leftRightCommon cp c - jr nz, .asm_46a3b - ld a, [W_YCOORD] ; wd361 + jr nz, .didNotMatch + ld a, [W_YCOORD] cp b - jr nz, .asm_46a3b -.asm_46a38 + jr nz, .didNotMatch +.matched xor a - jr .asm_46a3d -.asm_46a3b + jr .done +.didNotMatch ld a, $ff -.asm_46a3d +.done ld [$ffea], a ret diff --git a/engine/overworld/npc_movement.asm b/engine/overworld/npc_movement.asm index 07a73be674..84e3985301 100755 --- a/engine/overworld/npc_movement.asm +++ b/engine/overworld/npc_movement.asm @@ -260,12 +260,11 @@ RLEList_PewterGymGuy: ; 1a5da (6:65da) db $C0, $03 db $FF -; XXX why would this function want to return on POKEMONTOWER_7? -Func_1a5e7: ; 1a5e7 (6:65e7) - ld a, [W_CURMAP] ; W_CURMAP +FreezeEnemyTrainerSprite: ; 1a5e7 (6:65e7) + ld a, [W_CURMAP] cp POKEMONTOWER_7 - ret z - ld hl, RivalIDs ; $6605 + ret z ; the Rockets on Pokemon Tower 7F leave after battling, so don't freeze them + ld hl, RivalIDs ld a, [wEngagedTrainerClass] ld b, a .loop @@ -273,11 +272,11 @@ Func_1a5e7: ; 1a5e7 (6:65e7) cp $ff jr z, .notRival cp b - ret z + ret z ; the rival leaves after battling, so don't freeze him jr .loop .notRival ld a, [wSpriteIndex] - ld [H_DOWNARROWBLINKCNT2], a ; $ff8c + ld [H_SPRITEINDEX], a jp SetSpriteMovementBytesToFF RivalIDs: ; 1a605 (6:6605) diff --git a/engine/play_time.asm b/engine/play_time.asm index db7d6f67bc..74da9c59a8 100755 --- a/engine/play_time.asm +++ b/engine/play_time.asm @@ -1,25 +1,25 @@ -Func_18dee: ; 18dee (6:4dee) - call Func_18e36 +TrackPlayTime: ; 18dee (6:4dee) + call CountDownIgnoreInputBitReset ld a, [wd732] bit 0, a ret z - ld a, [W_PLAYTIMEMINUTES] ; wda42 + ld a, [W_PLAYTIMEMINUTES] and a ret nz - ld a, [W_PLAYTIMEFRAMES] ; wda45 + ld a, [W_PLAYTIMEFRAMES] inc a - ld [W_PLAYTIMEFRAMES], a ; wda45 + ld [W_PLAYTIMEFRAMES], a cp 60 ret nz xor a - ld [W_PLAYTIMEFRAMES], a ; wda45 - ld a, [W_PLAYTIMESECONDS] ; wda44 + ld [W_PLAYTIMEFRAMES], a + ld a, [W_PLAYTIMESECONDS] inc a - ld [W_PLAYTIMESECONDS], a ; wda44 + ld [W_PLAYTIMESECONDS], a cp 60 ret nz xor a - ld [W_PLAYTIMESECONDS], a ; wda44 + ld [W_PLAYTIMESECONDS], a ld a, [W_PLAYTIMEMINUTES + 1] inc a ld [W_PLAYTIMEMINUTES + 1], a @@ -33,11 +33,11 @@ Func_18dee: ; 18dee (6:4dee) cp $ff ret nz ld a, $ff - ld [W_PLAYTIMEMINUTES], a ; wda42 + ld [W_PLAYTIMEMINUTES], a ret -Func_18e36: ; 18e36 (6:4e36) - ld a, [wd13a] +CountDownIgnoreInputBitReset: ; 18e36 (6:4e36) + ld a, [wIgnoreInputCounter] and a jr nz, .asm_18e40 ld a, $ff @@ -45,7 +45,7 @@ Func_18e36: ; 18e36 (6:4e36) .asm_18e40 dec a .asm_18e41 - ld [wd13a], a + ld [wIgnoreInputCounter], a and a ret nz ld a, [wd730] diff --git a/engine/predefs.asm b/engine/predefs.asm index 0a5eff0395..b73c485af0 100755 --- a/engine/predefs.asm +++ b/engine/predefs.asm @@ -58,7 +58,7 @@ PredefPointers:: ; 4fe79 (13:7e79) add_predef ScaleSpriteByTwo add_predef LoadMonBackPic add_predef Func_79aba - add_predef Func_f132 + add_predef LoadMissableObjects add_predef HealParty add_predef MoveAnimation; 08 play move animation add_predef DivideBCDPredef @@ -75,13 +75,13 @@ PredefPointers:: ; 4fe79 (13:7e79) add_predef AnyPartyAlive add_predef ShowObject add_predef ShowObject2 - add_predef Func_ee9e + add_predef ReplaceTileBlock add_predef InitPlayerData2 add_predef LoadTilesetHeader add_predef LearnMoveFromLevelUp add_predef LearnMove add_predef IsItemInBag_ ; 1C, used in Pokémon Tower - dbw $03,Func_3eb5 ; for these two, the bank number is actually 0 + dbw $03,CheckForHiddenObjectOrBookshelfOrCardKeyDoor ; for these two, the bank number is actually 0 dbw $03,GiveItem add_predef ChangeBGPalColor0_4Frames add_predef FindPathToPlayer @@ -117,7 +117,7 @@ PredefPointers:: ; 4fe79 (13:7e79) add_predef WriteMonMoves add_predef SaveSAV add_predef LoadSGB - add_predef Func_f113 + add_predef MarkTownVisitedAndLoadMissableObjects add_predef SetPartyMonTypes add_predef CanLearnTM add_predef TMToMove diff --git a/engine/save.asm b/engine/save.asm index fcfbd13364..f4057577db 100755 --- a/engine/save.asm +++ b/engine/save.asm @@ -32,11 +32,11 @@ FileDataDestroyedText: ; 7361e (1c:761e) db "@" LoadSAVCheckSum: ; 73623 (1c:7623) - ld a, $a - ld [$0], a + ld a, SRAM_ENABLE + ld [MBC1SRamEnable], a ld a, $1 - ld [$6000], a - ld [$4000], a + ld [MBC1SRamBankingMode], a + ld [MBC1SRamBank], a ld hl, $a598 ; hero name located in SRAM ld bc, $f8b ; but here checks the full SAV call SAVCheckSum @@ -58,30 +58,30 @@ LoadSAVCheckSum: ; 73623 (1c:7623) ld bc, $b call CopyData ld hl, $a5a3 - ld de, wPokedexOwned ; wPokedexOwned + ld de, wPokedexOwned ld bc, $789 call CopyData - ld hl, W_CURMAPTILESET ; W_CURMAPTILESET + ld hl, W_CURMAPTILESET set 7, [hl] ld hl, $ad2c ld de, wSpriteStateData1 ld bc, $200 call CopyData ld a, [$b522] - ld [$ffd7], a + ld [hTilesetType], a ld hl, $b0c0 - ld de, W_NUMINBOX ; wda80 - ld bc, $462 + ld de, W_NUMINBOX + ld bc, wBoxMonNicksEnd - W_NUMINBOX call CopyData and a jp SAVGoodChecksum LoadSAVCheckSum1: ; 73690 (1c:7690) - ld a, $a - ld [$0], a + ld a, SRAM_ENABLE + ld [MBC1SRamEnable], a ld a, $1 - ld [$6000], a - ld [$4000], a + ld [MBC1SRamBankingMode], a + ld [MBC1SRamBank], a ld hl, $a598 ; hero name located in SRAM ld bc, $f8b ; but here checks the full SAV call SAVCheckSum @@ -90,18 +90,18 @@ LoadSAVCheckSum1: ; 73690 (1c:7690) cp c jr nz, SAVBadCheckSum ld hl, $b0c0 - ld de, W_NUMINBOX ; wda80 - ld bc, $462 + ld de, W_NUMINBOX + ld bc, wBoxMonNicksEnd - W_NUMINBOX call CopyData and a jp SAVGoodChecksum LoadSAVCheckSum2: ; 736bd (1c:76bd) - ld a, $a - ld [$0], a + ld a, SRAM_ENABLE + ld [MBC1SRamEnable], a ld a, $1 - ld [$6000], a - ld [$4000], a + ld [MBC1SRamBankingMode], a + ld [MBC1SRamBank], a ld hl, $a598 ; hero name located in SRAM ld bc, $f8b ; but here checks the full SAV call SAVCheckSum @@ -125,8 +125,8 @@ SAVBadCheckSum: ; 736f7 (1c:76f7) SAVGoodChecksum: ; 736f8 (1c:76f8) ld a, $0 - ld [$6000], a - ld [$0], a + ld [MBC1SRamBankingMode], a + ld [MBC1SRamEnable], a ret Func_73701: ; 0x73701 @@ -193,67 +193,67 @@ OlderFileWillBeErasedText: ; 73787 (1c:7787) db "@" SaveSAVtoSRAM0: ; 7378c (1c:778c) - ld a, $a - ld [$0], a + ld a, SRAM_ENABLE + ld [MBC1SRamEnable], a ld a, $1 - ld [$6000], a - ld [$4000], a - ld hl, wPlayerName ; wd158 + ld [MBC1SRamBankingMode], a + ld [MBC1SRamBank], a + ld hl, wPlayerName ld de, $a598 ld bc, $b call CopyData - ld hl, wPokedexOwned ; wPokedexOwned + ld hl, wPokedexOwned ld de, $a5a3 - ld bc, $789 + ld bc, W_NUMINBOX - wPokedexOwned call CopyData - ld hl, wSpriteStateData1 ; OAM? + ld hl, wSpriteStateData1 ld de, $ad2c ld bc, $200 call CopyData - ld hl, W_NUMINBOX ; wda80 + ld hl, W_NUMINBOX ld de, $b0c0 - ld bc, $462 + ld bc, wBoxMonNicksEnd - W_NUMINBOX call CopyData - ld a, [$ffd7] + ld a, [hTilesetType] ld [$b522], a ld hl, $a598 ld bc, $f8b call SAVCheckSum ld [$b523], a xor a - ld [$6000], a - ld [$0], a + ld [MBC1SRamBankingMode], a + ld [MBC1SRamEnable], a ret SaveSAVtoSRAM1: ; 737e2 (1c:77e2) ; stored pokémon - ld a, $a - ld [$0], a + ld a, SRAM_ENABLE + ld [MBC1SRamEnable], a ld a, $1 - ld [$6000], a - ld [$4000], a - ld hl, W_NUMINBOX ; wda80 + ld [MBC1SRamBankingMode], a + ld [MBC1SRamBank], a + ld hl, W_NUMINBOX ld de, $b0c0 - ld bc, $462 + ld bc, wBoxMonNicksEnd - W_NUMINBOX call CopyData ld hl, $a598 ld bc, $f8b call SAVCheckSum ld [$b523], a xor a - ld [$6000], a - ld [$0], a + ld [MBC1SRamBankingMode], a + ld [MBC1SRamEnable], a ret SaveSAVtoSRAM2: ; 7380f (1c:780f) - ld a, $a - ld [$0], a + ld a, SRAM_ENABLE + ld [MBC1SRamEnable], a ld a, $1 - ld [$6000], a - ld [$4000], a - ld hl, wPartyCount ; wPartyCount + ld [MBC1SRamBankingMode], a + ld [MBC1SRamBank], a + ld hl, wPartyCount ld de, $af2c - ld bc, $194 + ld bc, wPokedexOwned - wPartyCount call CopyData ld hl, wPokedexOwned ; pokédex only ld de, $a5a3 @@ -264,8 +264,8 @@ SaveSAVtoSRAM2: ; 7380f (1c:780f) call SAVCheckSum ld [$b523], a xor a - ld [$6000], a - ld [$0], a + ld [MBC1SRamBankingMode], a + ld [MBC1SRamEnable], a ret SaveSAVtoSRAM: ; 73848 (1c:7848) @@ -334,13 +334,13 @@ PointerTable_73895: ; 73895 (1c:7895) dw $B188 dw $B5EA -Func_738a1:: ; 738a1 (1c:78a1) +ChangeBox:: ; 738a1 (1c:78a1) ld hl, WhenYouChangeBoxText call PrintText call YesNoChoice - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + ld a, [wCurrentMenuItem] and a - ret nz + ret nz ; return if No was chosen ld hl, wd5a0 bit 7, [hl] call z, Func_73a29 @@ -356,25 +356,25 @@ Func_738a1:: ; 738a1 (1c:78a1) call Func_7387b ld e, l ld d, h - ld hl, W_NUMINBOX ; wda80 + ld hl, W_NUMINBOX call Func_7390e - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + ld a, [wCurrentMenuItem] set 7, a ld [wd5a0], a call Func_7387b - ld de, W_NUMINBOX ; wda80 + ld de, W_NUMINBOX call Func_7390e - ld hl, W_MAPTEXTPTR ; wd36c - ld de, wWhichTrade ; wWhichTrade + ld hl, W_MAPTEXTPTR + ld de, wChangeBoxSavedMapTextPointer ld a, [hli] ld [de], a inc de ld a, [hl] ld [de], a - call Func_3f05 + call RestoreMapTextPointer call SaveSAVtoSRAM - ld hl, wWhichTrade ; wWhichTrade - call Func_3f0f + ld hl, wChangeBoxSavedMapTextPointer + call SetMapTextPointer ld a, (SFX_02_5d - SFX_Headers_02) / 3 call PlaySoundWaitForCurrent call WaitForSoundToFinish @@ -386,12 +386,12 @@ WhenYouChangeBoxText: ; 73909 (1c:7909) Func_7390e: ; 7390e (1c:790e) push hl - ld a, $a - ld [$0], a + ld a, SRAM_ENABLE + ld [MBC1SRamEnable], a ld a, $1 - ld [$6000], a + ld [MBC1SRamBankingMode], a ld a, b - ld [$4000], a + ld [MBC1SRamBank], a ld bc, $462 call CopyData pop hl @@ -405,8 +405,8 @@ Func_7390e: ; 7390e (1c:790e) ld [$ba4c], a call Func_73863 xor a - ld [$6000], a - ld [$0], a + ld [MBC1SRamBankingMode], a + ld [MBC1SRamEnable], a ret Func_7393f: ; 7393f (1c:793f) @@ -502,19 +502,19 @@ BoxNoText: ; 73a21 (1c:7a21) db "BOX No.@" Func_73a29: ; 73a29 (1c:7a29) - ld a, $a - ld [$0], a + ld a, SRAM_ENABLE + ld [MBC1SRamEnable], a ld a, $1 - ld [$6000], a + ld [MBC1SRamBankingMode], a ld a, $2 - ld [$4000], a + ld [MBC1SRamBank], a call Func_73a4b ld a, $3 - ld [$4000], a + ld [MBC1SRamBank], a call Func_73a4b xor a - ld [$6000], a - ld [$0], a + ld [MBC1SRamBankingMode], a + ld [MBC1SRamEnable], a ret Func_73a4b: ; 73a4b (1c:7a4b) @@ -547,19 +547,19 @@ Func_73a7f: ; 73a7f (1c:7a7f) Func_73a84: ; 73a84 (1c:7a84) ld hl, wWhichTrade ; wWhichTrade push hl - ld a, $a - ld [$0], a + ld a, SRAM_ENABLE + ld [MBC1SRamEnable], a ld a, $1 - ld [$6000], a + ld [MBC1SRamBankingMode], a ld a, $2 - ld [$4000], a + ld [MBC1SRamBank], a call Func_73ab8 ld a, $3 - ld [$4000], a + ld [MBC1SRamBank], a call Func_73ab8 xor a - ld [$6000], a - ld [$0], a + ld [MBC1SRamBankingMode], a + ld [MBC1SRamEnable], a pop hl ld a, [wd5a0] and $7f @@ -592,8 +592,8 @@ SAVCheckRandomID: ;$7ad1 ld a,$0a ld [$0000],a ld a,$01 - ld [$6000],a - ld [$4000],a + ld [MBC1SRamBankingMode],a + ld [MBC1SRamBank],a ld a,[$a598] and a jr z,.next @@ -615,7 +615,7 @@ SAVCheckRandomID: ;$7ad1 cp h .next ld a,$00 - ld [$6000],a + ld [MBC1SRamBankingMode],a ld [$0000],a ret @@ -653,23 +653,23 @@ LoadHallOfFameTeams: ; 73b3f (1c:7b3f) ; fallthrough HallOfFame_Copy: ; 73b51 (1c:7b51) - ld a, $a - ld [$0], a + ld a, SRAM_ENABLE + ld [MBC1SRamEnable], a ld a, $1 - ld [$6000], a + ld [MBC1SRamBankingMode], a xor a - ld [$4000], a + ld [MBC1SRamBank], a call CopyData xor a - ld [$6000], a - ld [$0], a + ld [MBC1SRamBankingMode], a + ld [MBC1SRamEnable], a ret Func_73b6a: ; 73b6a (1c:7b6a) - ld a, $a - ld [$0], a + ld a, SRAM_ENABLE + ld [MBC1SRamEnable], a ld a, $1 - ld [$6000], a + ld [MBC1SRamBankingMode], a xor a call PadSRAM_FF ld a, $1 @@ -679,12 +679,12 @@ Func_73b6a: ; 73b6a (1c:7b6a) ld a, $3 call PadSRAM_FF xor a - ld [$6000], a - ld [$0], a + ld [MBC1SRamBankingMode], a + ld [MBC1SRamEnable], a ret PadSRAM_FF: ; 73b8f (1c:7b8f) - ld [$4000], a + ld [MBC1SRamBank], a ld hl, $a000 ld bc, $2000 ld a, $ff diff --git a/engine/titlescreen.asm b/engine/titlescreen.asm index 3f9cc61375..ca81eff852 100755 --- a/engine/titlescreen.asm +++ b/engine/titlescreen.asm @@ -26,7 +26,7 @@ LoadTitlescreenGraphics: ; 42dd (1:42dd) ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a ; $ffba xor a - ld [$ffd7], a + ld [hTilesetType], a ld [$ffae], a ld a, $40 ld [$ffaf], a diff --git a/engine/town_map.asm b/engine/town_map.asm index 6d10c22266..3b7506d5ea 100755 --- a/engine/town_map.asm +++ b/engine/town_map.asm @@ -64,7 +64,7 @@ Func_70e92: ; 70e92 (1c:4e92) ld bc, $10 call CopyData .asm_70ec8 - call Func_716c6 + call TownMapSpriteBlinkingAnimation call JoypadLowSensitivity ld a, [$ffb5] ld b, a @@ -77,9 +77,9 @@ Func_70e92: ; 70e92 (1c:4e92) bit 7, b jr nz, .asm_70f01 xor a - ld [wd09b], a + ld [wTownMapSpriteBlinkingEnabled], a ld [$ffb7], a - ld [W_SUBANIMTRANSFORM], a ; W_SUBANIMTRANSFORM + ld [wTownMapSpriteBlinkingCounter], a call Func_711ab pop hl pop af @@ -213,7 +213,7 @@ LoadTownMap_Fly: ; 70f90 (1c:4f90) set 7, [hl] .asm_71037 xor a - ld [wd09b], a + ld [wTownMapSpriteBlinkingEnabled], a call GBPalWhiteOutWithDelay3 pop hl pop af @@ -319,9 +319,9 @@ LoadTownMap: ; 7109b (1c:509b) call Delay3 call GBPalNormal xor a - ld [W_SUBANIMTRANSFORM], a ; W_SUBANIMTRANSFORM + ld [wTownMapSpriteBlinkingCounter], a inc a - ld [wd09b], a + ld [wTownMapSpriteBlinkingEnabled], a ret CompressedMap: ; 71100 (1c:5100) @@ -330,7 +330,7 @@ CompressedMap: ; 71100 (1c:5100) Func_711ab: ; 711ab (1c:51ab) xor a - ld [wd09b], a + ld [wTownMapSpriteBlinkingEnabled], a call GBPalWhiteOut call ClearScreen call ClearSprites @@ -570,29 +570,30 @@ INCLUDE "text/map_names.asm" MonNestIcon: ; 716be (1c:56be) INCBIN "gfx/mon_nest_icon.1bpp" -Func_716c6: ; 716c6 (1c:56c6) - ld a, [W_SUBANIMTRANSFORM] ; W_SUBANIMTRANSFORM +TownMapSpriteBlinkingAnimation: ; 716c6 (1c:56c6) + ld a, [wTownMapSpriteBlinkingCounter] inc a - cp $19 - jr z, .asm_716e1 - cp $32 - jr nz, .asm_716f1 + cp 25 + jr z, .hideSprites + cp 50 + jr nz, .done +; show sprites when the counter reaches 50 ld hl, wTileMapBackup ld de, wOAMBuffer ld bc, $90 call CopyData xor a - jr .asm_716f1 -.asm_716e1 + jr .done +.hideSprites ld hl, wOAMBuffer ld b, $24 ld de, $4 -.asm_716e9 +.hideSpritesLoop ld [hl], $a0 add hl, de dec b - jr nz, .asm_716e9 - ld a, $19 -.asm_716f1 - ld [W_SUBANIMTRANSFORM], a ; W_SUBANIMTRANSFORM + jr nz, .hideSpritesLoop + ld a, 25 +.done + ld [wTownMapSpriteBlinkingCounter], a jp DelayFrame diff --git a/engine/trade.asm b/engine/trade.asm index 5be77f3e56..d134e15ac0 100755 --- a/engine/trade.asm +++ b/engine/trade.asm @@ -475,7 +475,7 @@ Func_4149f: ; 4149f (10:549f) Func_414ae: ; 414ae (10:54ae) push hl hlCoord 0, 4 - call ScheduleRowRedrawHelper + call CopyToScreenEdgeTiles pop hl ld a, h ld [H_SCREENEDGEREDRAWADDR + 1], a diff --git a/home.asm b/home.asm index 87215991f9..19ab171501 100644 --- a/home.asm +++ b/home.asm @@ -86,11 +86,11 @@ FarCopyData:: push af ld a, [wBuffer] ld [H_LOADEDROMBANK], a - ld [MBC3RomBank], a + ld [MBC1RomBank], a call CopyData pop af ld [H_LOADEDROMBANK], a - ld [MBC3RomBank], a + ld [MBC1RomBank], a ret CopyData:: @@ -346,10 +346,10 @@ GetCryData:: ; 13d9 (0:13d9) ret DisplayPartyMenu:: ; 13fc (0:13fc) - ld a,[$ffd7] + ld a,[hTilesetType] push af xor a - ld [$ffd7],a + ld [hTilesetType],a call GBPalWhiteOutWithDelay3 call ClearSprites call PartyMenuInit @@ -357,10 +357,10 @@ DisplayPartyMenu:: ; 13fc (0:13fc) jp HandlePartyMenuInput GoBackToPartyMenu:: ; 1411 (0:1411) - ld a,[$ffd7] + ld a,[hTilesetType] push af xor a - ld [$ffd7],a + ld [hTilesetType],a call PartyMenuInit call RedrawPartyMenu jp HandlePartyMenuInput @@ -422,7 +422,7 @@ HandlePartyMenuInput:: ; 145a (0:145a) and a jp nz,.swappingPokemon pop af - ld [$ffd7],a + ld [hTilesetType],a bit 1,b jr nz,.noPokemonChosen ld a,[wPartyCount] @@ -920,11 +920,11 @@ FarCopyData2:: push af ld a,[$ff8b] ld [H_LOADEDROMBANK],a - ld [MBC3RomBank],a + ld [MBC1RomBank],a call CopyData pop af ld [H_LOADEDROMBANK],a - ld [MBC3RomBank],a + ld [MBC1RomBank],a ret FarCopyData3:: @@ -934,7 +934,7 @@ FarCopyData3:: push af ld a,[$ff8b] ld [H_LOADEDROMBANK],a - ld [MBC3RomBank],a + ld [MBC1RomBank],a push hl push de push de @@ -946,7 +946,7 @@ FarCopyData3:: pop hl pop af ld [H_LOADEDROMBANK],a - ld [MBC3RomBank],a + ld [MBC1RomBank],a ret FarCopyDataDouble:: @@ -957,7 +957,7 @@ FarCopyDataDouble:: push af ld a,[$ff8b] ld [H_LOADEDROMBANK],a - ld [MBC3RomBank],a + ld [MBC1RomBank],a .loop ld a,[hli] ld [de],a @@ -970,7 +970,7 @@ FarCopyDataDouble:: jr nz,.loop pop af ld [H_LOADEDROMBANK],a - ld [MBC3RomBank],a + ld [MBC1RomBank],a ret CopyVideoData:: @@ -988,7 +988,7 @@ CopyVideoData:: ld a, b ld [H_LOADEDROMBANK], a - ld [MBC3RomBank], a + ld [MBC1RomBank], a ld a, e ld [H_VBCOPYSRC], a @@ -1010,7 +1010,7 @@ CopyVideoData:: call DelayFrame ld a, [$ff8b] ld [H_LOADEDROMBANK], a - ld [MBC3RomBank], a + ld [MBC1RomBank], a pop af ld [H_AUTOBGTRANSFERENABLED], a ret @@ -1037,7 +1037,7 @@ CopyVideoDataDouble:: ld a, b ld [H_LOADEDROMBANK], a - ld [MBC3RomBank], a + ld [MBC1RomBank], a ld a, e ld [H_VBCOPYDOUBLESRC], a @@ -1059,7 +1059,7 @@ CopyVideoDataDouble:: call DelayFrame ld a, [$ff8b] ld [H_LOADEDROMBANK], a - ld [MBC3RomBank], a + ld [MBC1RomBank], a pop af ld [H_AUTOBGTRANSFERENABLED], a ret @@ -2687,12 +2687,14 @@ DisplayTextBoxID:: ; 30e8 (0:30e8) ld [$2000],a ret -Func_30fd:: ; 30fd (0:30fd) +; not zero if an NPC movement script is running, the player character is +; automatically stepping down from a door, or joypad states are being simulated +IsPlayerCharacterBeingControlledByGame:: ; 30fd (0:30fd) ld a, [wNPCMovementScriptPointerTableNum] and a ret nz ld a, [wd736] - bit 1, a + bit 1, a ; currently stepping down from door bit ret nz ld a, [wd730] and $80 @@ -2740,7 +2742,7 @@ EndNPCMovementScript:: ; 314e (0:314e) ld hl, _EndNPCMovementScript jp Bankswitch -Func_3156:: ; 3156 (0:3156) +EmptyFunc2:: ; 3156 (0:3156) ret ; stores hl in [W_TRAINERHEADERPTR] @@ -2831,7 +2833,6 @@ ReadTrainerHeaderInfo:: ; 3193 (0:3193) TrainerFlagAction:: predef_jump FlagActionPredef -; direct talking to a trainer (rather than getting seen by one) TalkToTrainer:: ; 31cc (0:31cc) call StoreTrainerHeaderPointer xor a @@ -2858,16 +2859,17 @@ TalkToTrainer:: ; 31cc (0:31cc) ld a, $8 call ReadTrainerHeaderInfo ; read end battle text pop de - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ld hl, W_FLAGS_D733 set 4, [hl] ; activate map script index override (index is set below) ld hl, wFlags_0xcd60 - bit 0, [hl] ; test if player is already being engaged by another trainer + bit 0, [hl] ; test if player is already engaging the trainer (because the trainer saw the player) ret nz +; if the player talked to the trainer of his own volition call EngageMapTrainer ld hl, W_CURMAPSCRIPT - inc [hl] ; progress map script index (assuming it was 0 before) to start pre-battle routines - jp Func_325d + inc [hl] ; increment map script index before StartTrainerBattle increments it again (next script function is usually EndTrainerBattle) + jp StartTrainerBattle ; checks if any trainers are seeing the player and wanting to fight CheckFightingMapTrainers:: ; 3219 (0:3219) @@ -2892,19 +2894,21 @@ CheckFightingMapTrainers:: ; 3219 (0:3219) ldh [$b4], a call TrainerWalkUpToPlayer_Bank0 ld hl, W_CURMAPSCRIPT - inc [hl] ; progress to battle phase 1 (engaging) + inc [hl] ; increment map script index (next script function is usually DisplayEnemyTrainerTextAndStartBattle) ret -Func_324c:: ; 324c (0:324c) +; display the before battle text after the enemy trainer has walked up to the player's sprite +DisplayEnemyTrainerTextAndStartBattle:: ; 324c (0:324c) ld a, [wd730] and $1 - ret nz + ret nz ; return if the enemy trainer hasn't finished walking to the player's sprite ld [wJoyIgnore], a ld a, [wSpriteIndex] - ld [H_DOWNARROWBLINKCNT2], a ; $ff8c + ld [hSpriteIndexOrTextID], a call DisplayTextID + ; fall through -Func_325d:: ; 325d (0:325d) +StartTrainerBattle:: ; 325d (0:325d) xor a ld [wJoyIgnore], a call InitBattleEnemyParameters @@ -2914,7 +2918,7 @@ Func_325d:: ; 325d (0:325d) ld hl, wd72e set 1, [hl] ld hl, W_CURMAPSCRIPT - inc [hl] ; progress to battle phase 2 (battling) + inc [hl] ; increment map script index (next script function is usually EndTrainerBattle) ret EndTrainerBattle:: ; 3275 (0:3275) @@ -3044,18 +3048,19 @@ CheckForEngagingTrainers:: ; 3306 (0:3306) ld e, l jr .trainerLoop -; saves loaded rom bank and hl as well as de registers -PreBattleSaveRegisters:: ; 3354 (0:3354) +; hl = text if the player wins +; de = text if the player loses +SaveEndBattleTextPointers:: ; 3354 (0:3354) ld a, [H_LOADEDROMBANK] - ld [W_PBSTOREDROMBANK], a + ld [wEndBattleTextRomBank], a ld a, h - ld [W_PBSTOREDREGISTERH], a + ld [wEndBattleWinTextPointer], a ld a, l - ld [W_PBSTOREDREGISTERL], a + ld [wEndBattleWinTextPointer + 1], a ld a, d - ld [W_PBSTOREDREGISTERD], a + ld [wEndBattleLoseTextPointer], a ld a, e - ld [W_PBSTOREDREGISTERE], a + ld [wEndBattleLoseTextPointer + 1], a ret ; loads data of some trainer on the current map and plays pre-battle music @@ -3074,7 +3079,7 @@ EngageMapTrainer:: ; 336a (0:336a) ld [wEnemyMonAttackMod], a ; wcd2e jp PlayTrainerMusic -Func_3381:: ; 3381 (0:3381) +PrintEndBattleText:: ; 3381 (0:3381) push hl ld hl, wd72d bit 7, [hl] @@ -3083,45 +3088,45 @@ Func_3381:: ; 3381 (0:3381) ret z ld a, [H_LOADEDROMBANK] push af - ld a, [W_PBSTOREDROMBANK] + ld a, [wEndBattleTextRomBank] ld [H_LOADEDROMBANK], a - ld [$2000], a + ld [MBC1RomBank], a push hl callba SaveTrainerName - ld hl, TrainerNameText + ld hl, TrainerEndBattleText call PrintText pop hl pop af ld [H_LOADEDROMBANK], a - ld [$2000], a - callba Func_1a5e7 + ld [MBC1RomBank], a + callba FreezeEnemyTrainerSprite jp WaitForSoundToFinish -Func_33b7:: ; 33b7 (0:33b7) +GetSavedEndBattleTextPointer:: ; 33b7 (0:33b7) ld a, [wBattleResult] and a - jr nz, .asm_33c6 - ld a, [W_PBSTOREDREGISTERH] +; won battle + jr nz, .lostBattle + ld a, [wEndBattleWinTextPointer] ld h, a - ld a, [W_PBSTOREDREGISTERL] + ld a, [wEndBattleWinTextPointer + 1] ld l, a ret -.asm_33c6 - ld a, [W_PBSTOREDREGISTERD] +.lostBattle + ld a, [wEndBattleLoseTextPointer] ld h, a - ld a, [W_PBSTOREDREGISTERE] + ld a, [wEndBattleLoseTextPointer + 1] ld l, a ret -TrainerNameText:: ; 33cf (0:33cf) +TrainerEndBattleText:: ; 33cf (0:33cf) TX_FAR _TrainerNameText db $08 - -Func_33d4:: ; 33d4 (0:33d4) - call Func_33b7 + call GetSavedEndBattleTextPointer call TextCommandProcessor jp TextScriptEnd +; XXX unused? Func_33dd:: ; 33dd (0:33dd) ld a, [wFlags_0xcd60] bit 0, a @@ -3177,15 +3182,19 @@ PlayTrainerMusic:: ; 33e8 (0:33e8) INCLUDE "data/trainer_types.asm" -Func_3442:: ; 3442 (0:3442) +; checks if the player's coordinates match an arrow movement tile's coordinates +; and if so, decodes the RLE movement data +; b = player Y +; c = player X +DecodeArrowMovementRLE:: ; 3442 (0:3442) ld a, [hli] cp $ff - ret z + ret z ; no match in the list cp b - jr nz, .asm_345b + jr nz, .nextArrowMovementTileEntry1 ld a, [hli] cp c - jr nz, .asm_345c + jr nz, .nextArrowMovementTileEntry2 ld a, [hli] ld d, [hl] ld e, a @@ -3194,12 +3203,12 @@ Func_3442:: ; 3442 (0:3442) dec a ld [wSimulatedJoypadStatesIndex], a ret -.asm_345b +.nextArrowMovementTileEntry1 inc hl -.asm_345c +.nextArrowMovementTileEntry2 inc hl inc hl - jr Func_3442 + jr DecodeArrowMovementRLE FuncTX_ItemStoragePC:: ; 3460 (0:3460) call SaveScreenTilesToBuffer2 @@ -3313,14 +3322,14 @@ CheckCoords:: ; 34c7 (0:34c7) ; tests if a boulder's coordinates are in a specified array ; INPUT: ; hl = address of array -; ff8c = which boulder to check? XXX +; [H_SPRITEINDEX] = index of boulder sprite ; OUTPUT: ; [wWhichTrade] = if there is match, the matching array index ; sets carry if the coordinates are in the array, clears carry if not CheckBoulderCoords:: ; 34e4 (0:34e4) push hl ld hl, wSpriteStateData2 + $04 - ld a, [$ff8c] + ld a, [H_SPRITEINDEX] swap a ld d, $0 ld e, a @@ -3971,21 +3980,21 @@ JoypadLowSensitivity:: ; 3831 (0:3831) ret WaitForTextScrollButtonPress:: ; 3865 (0:3865) - ld a, [H_DOWNARROWBLINKCNT1] ; $ff8b + ld a, [H_DOWNARROWBLINKCNT1] push af - ld a, [H_DOWNARROWBLINKCNT2] ; $ff8c + ld a, [H_DOWNARROWBLINKCNT2] push af xor a - ld [H_DOWNARROWBLINKCNT1], a ; $ff8b + ld [H_DOWNARROWBLINKCNT1], a ld a, $6 - ld [H_DOWNARROWBLINKCNT2], a ; $ff8c -.asm_3872 + ld [H_DOWNARROWBLINKCNT2], a +.loop push hl - ld a, [wd09b] + ld a, [wTownMapSpriteBlinkingEnabled] and a - jr z, .asm_387c - call Func_716c6 -.asm_387c + jr z, .skipAnimation + call TownMapSpriteBlinkingAnimation +.skipAnimation hlCoord 18, 16 call HandleDownArrowBlinkTiming pop hl @@ -3993,16 +4002,16 @@ WaitForTextScrollButtonPress:: ; 3865 (0:3865) predef Func_5a5f ld a, [$ffb5] and A_BUTTON | B_BUTTON - jr z, .asm_3872 + jr z, .loop pop af - ld [H_DOWNARROWBLINKCNT2], a ; $ff8c + ld [H_DOWNARROWBLINKCNT2], a pop af - ld [H_DOWNARROWBLINKCNT1], a ; $ff8b + ld [H_DOWNARROWBLINKCNT1], a ret -; (unlass in link battle) waits for A or B being pressed and outputs the scrolling sound effect +; (unless in link battle) waits for A or B being pressed and outputs the scrolling sound effect ManualTextScroll:: ; 3898 (0:3898) - ld a, [W_ISLINKBATTLE] ; W_ISLINKBATTLE + ld a, [W_ISLINKBATTLE] cp $4 jr z, .inLinkBattle call WaitForTextScrollButtonPress @@ -5145,70 +5154,72 @@ Func_3ead:: ; 3ead (0:3ead) ld hl, CinnabarGymQuiz_1eb0a jp Bankswitch -Func_3eb5:: ; 3eb5 (0:3eb5) +CheckForHiddenObjectOrBookshelfOrCardKeyDoor:: ; 3eb5 (0:3eb5) ld a, [H_LOADEDROMBANK] push af ld a, [hJoyHeld] - bit 0, a - jr z, .asm_3eea - ld a, Bank(Func_469a0) - ld [$2000], a + bit 0, a ; A button + jr z, .nothingFound +; A button is pressed + ld a, Bank(CheckForHiddenObject) + ld [MBC1RomBank], a ld [H_LOADEDROMBANK], a - call Func_469a0 + call CheckForHiddenObject ld a, [$ffee] and a - jr nz, .asm_3edd - ld a, [wTrainerEngageDistance] - ld [$2000], a + jr nz, .hiddenObjectNotFound + ld a, [wHiddenObjectFunctionRomBank] + ld [MBC1RomBank], a ld [H_LOADEDROMBANK], a - ld de, .asm_3eda + ld de, .returnAddress push de jp [hl] -.asm_3eda +.returnAddress xor a - jr .asm_3eec -.asm_3edd + jr .done +.hiddenObjectNotFound callba PrintBookshelfText ld a, [$ffdb] and a - jr z, .asm_3eec -.asm_3eea + jr z, .done +.nothingFound ld a, $ff -.asm_3eec +.done ld [$ffeb], a pop af - ld [$2000], a + ld [MBC1RomBank], a ld [H_LOADEDROMBANK], a ret PrintPredefTextID:: ; 3ef5 (0:3ef5) ld [H_DOWNARROWBLINKCNT2], a ; $ff8c - ld hl, PointerTable_3f22 - call Func_3f0f + ld hl, PredefTextIDPointerTable + call SetMapTextPointer ld hl, wcf11 set 0, [hl] call DisplayTextID + ; fall through -Func_3f05:: ; 3f05 (0:3f05) - ld hl, W_MAPTEXTPTR ; wd36c +RestoreMapTextPointer:: ; 3f05 (0:3f05) + ld hl, W_MAPTEXTPTR ld a, [$ffec] ld [hli], a ld a, [$ffed] ld [hl], a ret -Func_3f0f:: ; 3f0f (0:3f0f) - ld a, [W_MAPTEXTPTR] ; wd36c +SetMapTextPointer:: ; 3f0f (0:3f0f) + ld a, [W_MAPTEXTPTR] ld [$ffec], a ld a, [W_MAPTEXTPTR + 1] ld [$ffed], a ld a, l - ld [W_MAPTEXTPTR], a ; wd36c + ld [W_MAPTEXTPTR], a ld a, h ld [W_MAPTEXTPTR + 1], a ret -PointerTable_3f22:: ; 3f22 (0:3f22) +PredefTextIDPointerTable:: ; 3f22 (0:3f22) dw CardKeySuccessText ; id = 01 dw CardKeyFailText ; id = 02 dw RedBedroomPC ; id = 03 diff --git a/home/init.asm b/home/init.asm index 402a402e02..e170fe7827 100644 --- a/home/init.asm +++ b/home/init.asm @@ -61,11 +61,11 @@ rLCDC_DEFAULT EQU %11100011 ld a, Bank(WriteDMACodeToHRAM) ld [H_LOADEDROMBANK], a - ld [MBC3RomBank], a + ld [MBC1RomBank], a call WriteDMACodeToHRAM xor a - ld [$ffd7], a + ld [hTilesetType], a ld [$ff41], a ld [$ffae], a ld [$ffaf], a diff --git a/home/overworld.asm b/home/overworld.asm index 9dbfdfb764..5079118426 100644 --- a/home/overworld.asm +++ b/home/overworld.asm @@ -10,7 +10,7 @@ EnterMap:: ld a, $ff ld [wJoyIgnore], a call LoadMapData - callba Func_c335 ; initialize map variables + callba ClearVariablesAfterLoadingMapData ld hl, wd72c bit 0, [hl] ; has the player already made 3 steps since the last battle? jr z, .skipGivingThreeStepsOfNoRandomBattles @@ -20,14 +20,14 @@ EnterMap:: ld hl, wd72e bit 5, [hl] ; did a battle happen immediately before this? res 5, [hl] ; unset the "battle just happened" flag - call z, Func_12e7 + call z, ResetUsingStrengthOutOfBattleBit call nz, MapEntryAfterBattle ld hl, wd732 ld a, [hl] and 1 << 4 | 1 << 3 ; fly warp or dungeon warp jr z, .didNotEnterUsingFlyWarpOrDungeonWarp res 3, [hl] - callba EnterMapAnim ; display fly/teleport in graphical effect + callba EnterMapAnim call UpdateSprites .didNotEnterUsingFlyWarpOrDungeonWarp callba CheckForceBikeOrSurf ; handle currents in SF islands and forced bike riding in cycling road @@ -53,7 +53,7 @@ OverworldLoopLessDelay:: jp nz,.moveAhead ; if the player sprite has not yet completed the walking animation call JoypadOverworld ; get joypad state (which is possibly simulated) callba SafariZoneCheck - ld a,[wda46] + ld a,[wSafariZoneGameOver] and a jp nz,WarpFound2 ld hl,wd72d @@ -78,7 +78,7 @@ OverworldLoopLessDelay:: jr z,.startButtonNotPressed ; if START is pressed xor a - ld [$ff8c],a ; the $2920 ID for the start menu is 0 + ld [hSpriteIndexOrTextID],a ; start menu text ID jp .displayDialogue .startButtonNotPressed bit 0,a ; A button @@ -87,14 +87,14 @@ OverworldLoopLessDelay:: ld a,[wd730] bit 2,a jp nz,.noDirectionButtonsPressed - call Func_30fd + call IsPlayerCharacterBeingControlledByGame jr nz,.checkForOpponent - call Func_3eb5 ; check for hidden items, PC's, etc. + call CheckForHiddenObjectOrBookshelfOrCardKeyDoor ld a,[$ffeb] and a - jp z,OverworldLoop - call IsSpriteOrSignInFrontOfPlayer ; check for sign or sprite in front of the player - ld a,[$ff8c] ; $2920 ID for NPC/sign text, if any + jp z,OverworldLoop ; jump if a hidden object or bookshelf was found, but not if a card key door was found + call IsSpriteOrSignInFrontOfPlayer + ld a,[hSpriteIndexOrTextID] and a jp z,OverworldLoop .displayDialogue @@ -293,7 +293,7 @@ OverworldLoopLessDelay:: bit 7,a ; in the safari zone? jr z,.notSafariZone callba SafariZoneCheckSteps - ld a,[wda46] + ld a,[wSafariZoneGameOver] and a jp nz,WarpFound2 .notSafariZone @@ -350,8 +350,8 @@ NewBattle:: ; 0683 (0:0683) ld a,[wd72d] bit 4,a jr nz,.noBattle - call Func_30fd - jr nz,.noBattle + call IsPlayerCharacterBeingControlledByGame + jr nz,.noBattle ; no battle if the player character is under the game's control ld a,[wd72e] bit 4,a jr nz,.noBattle @@ -523,7 +523,7 @@ WarpFound2:: ; 073c (0:073c) .done ld hl,wd736 set 0,[hl] ; have the player's sprite step out from the door (if there is one) - call Func_12da + call IgnoreInputForHalfSecond jp EnterMap ContinueCheckWarpsNoCollisionLoop:: ; 07b5 (0:07b5) @@ -747,7 +747,7 @@ HandleBlackOut:: res 5, [hl] ld a, Bank(ResetStatusAndHalveMoneyOnBlackout) ; also Bank(SpecialWarpIn) and Bank(SpecialEnterMap) ld [H_LOADEDROMBANK], a - ld [MBC3RomBank], a + ld [MBC1RomBank], a call ResetStatusAndHalveMoneyOnBlackout call SpecialWarpIn call Func_2312 @@ -798,7 +798,7 @@ LoadPlayerSpriteGraphics:: dec a jr z, .ridingBike - ld a, [$ffd7] + ld a, [hTilesetType] and a jr nz, .determineGraphics jr .startWalking @@ -1058,11 +1058,11 @@ LoadEastWestConnectionsTileMap:: ; 0b02 (0:0b02) ret ; function to check if there is a sign or sprite in front of the player -; if so, it is stored in [$FF8C] -; if not, [$FF8C] is set to 0 +; if so, it is stored in [hSpriteIndexOrTextID] +; if not, [hSpriteIndexOrTextID] is set to 0 IsSpriteOrSignInFrontOfPlayer:: ; 0b23 (0:0b23) xor a - ld [$ff8c],a + ld [hSpriteIndexOrTextID],a ld a,[wd4b0] ; number of signs in the map and a jr z,.extendRangeOverCounter @@ -1092,7 +1092,7 @@ IsSpriteOrSignInFrontOfPlayer:: ; 0b23 (0:0b23) dec c add hl,bc ld a,[hl] - ld [$ff8c],a ; store sign text ID + ld [hSpriteIndexOrTextID],a ; store sign text ID pop bc pop hl ret @@ -1113,7 +1113,7 @@ IsSpriteOrSignInFrontOfPlayer:: ; 0b23 (0:0b23) jr nz,.counterTilesLoop ; part of the above function, but sometimes its called on its own, when signs are irrelevant -; the caller must zero [$FF8C] +; the caller must zero [hSpriteIndexOrTextID] IsSpriteInFrontOfPlayer:: ; 0b6b (0:0b6b) ld d,$10 ; talking range in pixels (normal range) IsSpriteInFrontOfPlayer2:: ; 0b6d (0:0b6d) @@ -1195,7 +1195,7 @@ IsSpriteInFrontOfPlayer2:: ; 0b6d (0:0b6d) ld l,a set 7,[hl] ld a,e - ld [$ff8c],a ; store sprite ID + ld [hSpriteIndexOrTextID],a ret ; function to check if the player will jump down a ledge and check if the tile ahead is passable (when not surfing) @@ -1214,9 +1214,9 @@ CollisionCheckOnLand:: ; 0bd1 (0:0bd1) and d ; check if a sprite is in the direction the player is trying to go jr nz,.collision xor a - ld [$ff8c],a + ld [hSpriteIndexOrTextID],a call IsSpriteInFrontOfPlayer ; check for sprite collisions again? when does the above check fail to detect a sprite collision? - ld a,[$ff8c] + ld a,[hSpriteIndexOrTextID] and a ; was there a sprite collision? jr nz,.collision ; if no sprite collision @@ -1467,7 +1467,7 @@ AdvancePlayerSprite:: ; 0d27 (0:0d27) cp a,$01 jr nz,.checkIfMovingWest ; moving east - ld a,[wd526] + ld a,[wMapViewVRAMPointer] ld e,a and a,$e0 ld d,a @@ -1475,13 +1475,13 @@ AdvancePlayerSprite:: ; 0d27 (0:0d27) add a,$02 and a,$1f or d - ld [wd526],a + ld [wMapViewVRAMPointer],a jr .adjustXCoordWithinBlock .checkIfMovingWest cp a,$ff jr nz,.checkIfMovingSouth ; moving west - ld a,[wd526] + ld a,[wMapViewVRAMPointer] ld e,a and a,$e0 ld d,a @@ -1489,36 +1489,36 @@ AdvancePlayerSprite:: ; 0d27 (0:0d27) sub a,$02 and a,$1f or d - ld [wd526],a + ld [wMapViewVRAMPointer],a jr .adjustXCoordWithinBlock .checkIfMovingSouth ld a,b cp a,$01 jr nz,.checkIfMovingNorth ; moving south - ld a,[wd526] + ld a,[wMapViewVRAMPointer] add a,$40 - ld [wd526],a + ld [wMapViewVRAMPointer],a jr nc,.adjustXCoordWithinBlock - ld a,[wd527] + ld a,[wMapViewVRAMPointer + 1] inc a and a,$03 or a,$98 - ld [wd527],a + ld [wMapViewVRAMPointer + 1],a jr .adjustXCoordWithinBlock .checkIfMovingNorth cp a,$ff jr nz,.adjustXCoordWithinBlock ; moving north - ld a,[wd526] + ld a,[wMapViewVRAMPointer] sub a,$40 - ld [wd526],a + ld [wMapViewVRAMPointer],a jr nc,.adjustXCoordWithinBlock - ld a,[wd527] + ld a,[wMapViewVRAMPointer + 1] dec a and a,$03 or a,$98 - ld [wd527],a + ld [wMapViewVRAMPointer + 1],a .adjustXCoordWithinBlock ld a,c and a @@ -1694,18 +1694,18 @@ MoveTileBlockMapPointerNorth:: ; 0e85 (0:0e85) ScheduleNorthRowRedraw:: ; 0e91 (0:0e91) hlCoord 0, 0 - call ScheduleRowRedrawHelper - ld a,[wd526] + call CopyToScreenEdgeTiles + ld a,[wMapViewVRAMPointer] ld [H_SCREENEDGEREDRAWADDR],a - ld a,[wd527] + ld a,[wMapViewVRAMPointer + 1] ld [H_SCREENEDGEREDRAWADDR + 1],a ld a,REDRAWROW ld [H_SCREENEDGEREDRAW],a ret -ScheduleRowRedrawHelper:: ; 0ea6 (0:0ea6) +CopyToScreenEdgeTiles:: ; 0ea6 (0:0ea6) ld de,wScreenEdgeTiles - ld c,$28 + ld c,2 * 20 .loop ld a,[hli] ld [de],a @@ -1716,10 +1716,10 @@ ScheduleRowRedrawHelper:: ; 0ea6 (0:0ea6) ScheduleSouthRowRedraw:: ; 0eb2 (0:0eb2) hlCoord 0, 16 - call ScheduleRowRedrawHelper - ld a,[wd526] + call CopyToScreenEdgeTiles + ld a,[wMapViewVRAMPointer] ld l,a - ld a,[wd527] + ld a,[wMapViewVRAMPointer + 1] ld h,a ld bc,$0200 add hl,bc @@ -1736,7 +1736,7 @@ ScheduleSouthRowRedraw:: ; 0eb2 (0:0eb2) ScheduleEastColumnRedraw:: ; 0ed3 (0:0ed3) hlCoord 18, 0 call ScheduleColumnRedrawHelper - ld a,[wd526] + ld a,[wMapViewVRAMPointer] ld c,a and a,$e0 ld b,a @@ -1745,7 +1745,7 @@ ScheduleEastColumnRedraw:: ; 0ed3 (0:0ed3) and a,$1f or b ld [H_SCREENEDGEREDRAWADDR],a - ld a,[wd527] + ld a,[wMapViewVRAMPointer + 1] ld [H_SCREENEDGEREDRAWADDR + 1],a ld a,REDRAWCOL ld [H_SCREENEDGEREDRAW],a @@ -1774,9 +1774,9 @@ ScheduleColumnRedrawHelper:: ; 0ef2 (0:0ef2) ScheduleWestColumnRedraw:: ; 0f08 (0:0f08) hlCoord 0, 0 call ScheduleColumnRedrawHelper - ld a,[wd526] + ld a,[wMapViewVRAMPointer] ld [H_SCREENEDGEREDRAWADDR],a - ld a,[wd527] + ld a,[wMapViewVRAMPointer + 1] ld [H_SCREENEDGEREDRAWADDR + 1],a ld a,REDRAWCOL ld [H_SCREENEDGEREDRAW],a @@ -2013,7 +2013,7 @@ LoadPlayerSpriteGraphicsCommon:: ; 1063 (0:1063) ; function to load data from the map header LoadMapHeader:: ; 107c (0:107c) - callba Func_f113 + callba MarkTownVisitedAndLoadMissableObjects ld a,[W_CURMAPTILESET] ld [wd119],a ld a,[W_CURMAP] @@ -2307,9 +2307,9 @@ LoadMapData:: ; 1241 (0:1241) push af call DisableLCD ld a,$98 - ld [wd527],a + ld [wMapViewVRAMPointer + 1],a xor a - ld [wd526],a + ld [wMapViewVRAMPointer],a ld [$ffaf],a ld [$ffae],a ld [wWalkCounter],a @@ -2383,16 +2383,16 @@ SwitchToMapRomBank:: ; 12bc (0:12bc) pop hl ret -Func_12da:: ; 12da (0:12da) - ld a, $1e - ld [wd13a], a +IgnoreInputForHalfSecond: ; 12da (0:12da) + ld a, 30 + ld [wIgnoreInputCounter], a ld hl, wd730 ld a, [hl] or $26 - ld [hl], a + ld [hl], a ; set ignore input bit ret -Func_12e7:: ; 12e7 (0:12e7) +ResetUsingStrengthOutOfBattleBit: ; 12e7 (0:12e7) ld hl, wd728 res 0, [hl] ret diff --git a/home/vblank.asm b/home/vblank.asm index b4daaa8be0..d660f270b2 100644 --- a/home/vblank.asm +++ b/home/vblank.asm @@ -29,7 +29,7 @@ VBlank:: call $ff80 ; hOAMDMA ld a, Bank(PrepareOAMData) ld [H_LOADEDROMBANK], a - ld [MBC3RomBank], a + ld [MBC1RomBank], a call PrepareOAMData ; VBlank-sensitive operations end. @@ -54,7 +54,7 @@ VBlank:: ld a, [wc0ef] ; music ROM bank ld [H_LOADEDROMBANK], a - ld [MBC3RomBank], a + ld [MBC1RomBank], a cp BANK(Music2_UpdateMusic) jr nz, .notbank2 @@ -72,7 +72,7 @@ VBlank:: call Music1f_UpdateMusic .afterMusic - callba Func_18dee ; keep track of time played + callba TrackPlayTime ; keep track of time played ld a, [$fff9] and a @@ -80,7 +80,7 @@ VBlank:: ld a, [wd122] ld [H_LOADEDROMBANK], a - ld [MBC3RomBank], a + ld [MBC1RomBank], a pop hl pop de diff --git a/home/vcopy.asm b/home/vcopy.asm index 81fcb99163..d42293d994 100644 --- a/home/vcopy.asm +++ b/home/vcopy.asm @@ -376,9 +376,9 @@ UpdateMovingBgTiles:: ; Animate water and flower ; tiles in the overworld. - ld a, [$ffd7] + ld a, [hTilesetType] and a - ret z + ret z ; no animations if indoors (or if a menu set this to 0) ld a, [$ffd8] inc a @@ -412,9 +412,10 @@ UpdateMovingBgTiles:: dec c jr nz, .left .done - ld a, [$ffd7] + ld a, [hTilesetType] rrca ret nc +; if in a cave, no flower animations xor a ld [$ffd8], a ret diff --git a/hram.asm b/hram.asm index 551ec67daa..013761d6a1 100644 --- a/hram.asm +++ b/hram.asm @@ -17,6 +17,9 @@ H_DOWNARROWBLINKCNT2 EQU $FF8C H_SPRITEDATAOFFSET EQU $FF8B H_SPRITEINDEX EQU $FF8C +; DisplayTextID's argument +hSpriteIndexOrTextID EQU $FF8C + ; Note: the following multiplication and division addresses are used for multiple purposes ; and so they overlap with each other @@ -120,6 +123,12 @@ H_FRAMECOUNTER EQU $FFD5 ; decremented every V-blank (used for delays) ; you can detect that the V-blank handler has run since then. H_VBLANKOCCURRED EQU $FFD6 +; 00 = indoor +; 01 = cave +; 02 = outdoor +; this is often set to 00 in order to turn off water and flower BG tile animations +hTilesetType EQU $FFD7 + H_CURRENTSPRITEOFFSET EQU $FFDA ; multiple of $10 H_WHOSETURN EQU $FFF3 ; 0 on player’s turn, 1 on enemy’s turn diff --git a/macros.asm b/macros.asm index 8244c8c9a0..0aa76291de 100644 --- a/macros.asm +++ b/macros.asm @@ -16,11 +16,11 @@ homecall: MACRO push af ld a, BANK(\1) ld [H_LOADEDROMBANK], a - ld [MBC3RomBank], a + ld [MBC1RomBank], a call \1 pop af ld [H_LOADEDROMBANK], a - ld [MBC3RomBank], a + ld [MBC1RomBank], a ENDM callba: MACRO diff --git a/main.asm b/main.asm index 22721cdb6c..72cef23b18 100755 --- a/main.asm +++ b/main.asm @@ -2021,12 +2021,12 @@ INCLUDE "data/map_songs.asm" INCLUDE "data/map_header_banks.asm" -Func_c335: ; c335 (3:4335) +ClearVariablesAfterLoadingMapData: ; c335 (3:4335) ld a, $90 ld [hVBlankWY], a - ld [rWY], a ; $ff4a + ld [rWY], a xor a - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba + ld [H_AUTOBGTRANSFERENABLED], a ld [wStepCounter], a ld [W_LONEATTACKNO], a ; W_GYMLEADERNO ld [hJoyPressed], a @@ -2034,10 +2034,10 @@ Func_c335: ; c335 (3:4335) ld [hJoyHeld], a ld [wcd6a], a ld [wd5a3], a - ld hl, wd73f + ld hl, wCardKeyDoorY ld [hli], a ld [hl], a - ld hl, wWhichTrade ; wWhichTrade + ld hl, wWhichTrade ld bc, $1e call FillMemory ret @@ -2509,7 +2509,7 @@ CheckForBoulderCollisionWithSprites: ; c636 (3:4636) ApplyOutOfBattlePoisonDamage: ; c69c (3:469c) ld a, [wd730] add a - jp c, .noBlackOut + jp c, .noBlackOut ; no black out if joypad states are being simulated ld a, [wPartyCount] and a jp z, .noBlackOut @@ -2644,7 +2644,7 @@ LoadTilesetHeader: ; c754 (3:4754) dec c jr nz, .copyTilesetHeaderLoop ld a, [hl] - ld [$ffd7], a + ld [hTilesetType], a xor a ld [$ffd8], a pop hl @@ -3068,10 +3068,14 @@ DrawBadges: ; ea03 (3:6a03) GymLeaderFaceAndBadgeTileGraphics: ; ea9e (3:6a9e) INCBIN "gfx/badges.2bpp" -Func_ee9e: ; ee9e (3:6e9e) +; replaces a tile block with the one specified in [wNewTileBlockID] +; and redraws the map view if necessary +; b = Y +; c = X +ReplaceTileBlock: ; ee9e (3:6e9e) call GetPredefRegisters ld hl, wOverworldMap - ld a, [W_CURMAPWIDTH] ; wd369 + ld a, [W_CURMAPWIDTH] add $6 ld e, a ld d, $0 @@ -3083,21 +3087,22 @@ Func_ee9e: ; ee9e (3:6e9e) ld e, a ld a, b and a - jr z, .asm_eebb -.asm_eeb7 + jr z, .addX +; add width * Y +.addWidthYTimesLoop add hl, de dec b - jr nz, .asm_eeb7 -.asm_eebb - add hl, bc - ld a, [wd09f] + jr nz, .addWidthYTimesLoop +.addX + add hl, bc ; add X + ld a, [wNewTileBlockID] ld [hl], a ld a, [wCurrentTileBlockMapViewPointer] ld c, a ld a, [wCurrentTileBlockMapViewPointer + 1] ld b, a - call Func_ef4e - ret c + call CompareHLWithBC + ret c ; return if the replaced tile block is below the map view in memory push hl ld l, e ld h, $0 @@ -3108,27 +3113,27 @@ Func_ee9e: ; ee9e (3:6e9e) add hl, de add hl, bc pop bc - call Func_ef4e - ret c + call CompareHLWithBC + ret c ; return if the replaced tile block is above the map view in memory -Func_eedc: ; eedc (3:6edc) +RedrawMapView: ; eedc (3:6edc) ld a, [W_ISINBATTLE] ; W_ISINBATTLE inc a ret z - ld a, [H_AUTOBGTRANSFERENABLED] ; $ffba + ld a, [H_AUTOBGTRANSFERENABLED] push af - ld a, [$ffd7] + ld a, [hTilesetType] push af xor a - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba - ld [$ffd7], a + ld [H_AUTOBGTRANSFERENABLED], a + ld [hTilesetType], a ; no flower/water BG tile animations call LoadCurrentMapView call GoPAL_SET_CF1C - ld hl, wd526 + ld hl, wMapViewVRAMPointer ld a, [hli] ld h, [hl] ld l, a - ld de, $ffc0 + ld de, -2 * 32 add hl, de ld a, h and $3 @@ -3137,21 +3142,21 @@ Func_eedc: ; eedc (3:6edc) ld [wHPBarMaxHP], a ld a, h ld [wHPBarMaxHP + 1], a - ld a, $2 + ld a, 2 ld [$ffbe], a - ld c, $9 -.asm_ef0f + ld c, 9 ; number of rows of 2x2 tiles (this covers the whole screen) +.redrawRowLoop push bc push hl push hl - ld hl, wOAMBuffer + $78 - ld de, $14 + ld hl, wTileMap - 2 * 20 + ld de, 20 ld a, [$ffbe] .asm_ef1a add hl, de dec a jr nz, .asm_ef1a - call ScheduleRowRedrawHelper + call CopyToScreenEdgeTiles pop hl ld de, $20 ld a, [$ffbe] @@ -3163,11 +3168,11 @@ Func_eedc: ; eedc (3:6edc) or $98 dec c jr nz, .asm_ef28 - ld [$ffd2], a + ld [H_SCREENEDGEREDRAWADDR + 1], a ld a, l - ld [H_SCREENEDGEREDRAWADDR], a ; $ffd1 - ld a, $2 - ld [H_SCREENEDGEREDRAW], a ; $ffd0 + ld [H_SCREENEDGEREDRAWADDR], a + ld a, REDRAWROW + ld [H_SCREENEDGEREDRAW], a call DelayFrame ld hl, $ffbe inc [hl] @@ -3175,14 +3180,14 @@ Func_eedc: ; eedc (3:6edc) pop hl pop bc dec c - jr nz, .asm_ef0f + jr nz, .redrawRowLoop pop af - ld [$ffd7], a + ld [hTilesetType], a pop af - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba + ld [H_AUTOBGTRANSFERENABLED], a ret -Func_ef4e: ; ef4e (3:6f4e) +CompareHLWithBC: ; ef4e (3:6f4e) ld a, h sub b ret nz @@ -3192,8 +3197,8 @@ Func_ef4e: ; ef4e (3:6f4e) INCLUDE "engine/overworld/cut.asm" -Func_f113: ; f113 (3:7113) - ld a, [W_CURMAP] ; W_CURMAP +MarkTownVisitedAndLoadMissableObjects: ; f113 (3:7113) + ld a, [W_CURMAP] cp ROUTE_1 jr nc, .notInTown ld c, a @@ -3202,15 +3207,16 @@ Func_f113: ; f113 (3:7113) predef FlagActionPredef .notInTown ld hl, MapHSPointers - ld a, [W_CURMAP] ; W_CURMAP + ld a, [W_CURMAP] ld b, $0 ld c, a add hl, bc add hl, bc ld a, [hli] ; load missable objects pointer in hl ld h, [hl] + ; fall through -Func_f132: ; f132 (3:7132) +LoadMissableObjects: ; f132 (3:7132) ld l, a push hl ld de, MapHS00 ; calculate difference between out pointer and the base pointer diff --git a/scripts/agatha.asm b/scripts/agatha.asm index ca7c0ed84e..a8f9e13764 100755 --- a/scripts/agatha.asm +++ b/scripts/agatha.asm @@ -24,7 +24,7 @@ AgathaScript_76443: ; 76443 (1d:6443) AgathaScript_76459: ; 76459 (1d:6459) ld [wd09f], a ld bc, $2 - predef_jump Func_ee9e + predef_jump ReplaceTileBlock AgathaScript_76464: ; 76464 (1d:6464) xor a @@ -33,7 +33,7 @@ AgathaScript_76464: ; 76464 (1d:6464) AgathaScriptPointers: ; 76469 (1d:6469) dw AgathaScript0 - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw AgathaScript2 dw AgathaScript3 dw AgathaScript4 diff --git a/scripts/bruno.asm b/scripts/bruno.asm index 553469d0d7..ffe05bcead 100755 --- a/scripts/bruno.asm +++ b/scripts/bruno.asm @@ -24,7 +24,7 @@ BrunoScript_762ec: ; 762ec (1d:62ec) BrunoScript_76302: ; 76302 (1d:6302) ld [wd09f], a ld bc, $2 - predef_jump Func_ee9e + predef_jump ReplaceTileBlock BrunoScript_7630d: ; 7630d (1d:630d) xor a @@ -33,7 +33,7 @@ BrunoScript_7630d: ; 7630d (1d:630d) BrunoScriptPointers: ; 76312 (1d:6312) dw BrunoScript0 - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw BrunoScript2 dw BrunoScript3 dw BrunoScript4 diff --git a/scripts/celadongamecorner.asm b/scripts/celadongamecorner.asm index 87239910b1..e8d90a5a9b 100755 --- a/scripts/celadongamecorner.asm +++ b/scripts/celadongamecorner.asm @@ -34,7 +34,7 @@ CeladonGameCornerScript_48bec: ; 48bec (12:4bec) ld a, $2a ld [wd09f], a ld bc, $0208 - predef_jump Func_ee9e + predef_jump ReplaceTileBlock CeladonGameCornerScript_48c07: ; 48c07 (12:4c07) xor a @@ -409,7 +409,7 @@ CeladonGameCornerText11: ; 48e9d (12:4e9d) set 7, [hl] ld hl, CeladonGameCornerText_48ed3 ld de, CeladonGameCornerText_48ed3 - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ldh a, [$8c] ld [wSpriteIndex], a call EngageMapTrainer @@ -449,7 +449,7 @@ CeladonGameCornerText12: ; 48edd (12:4edd) ld a, $43 ld [wd09f], a ld bc, $0208 - predef Func_ee9e + predef ReplaceTileBlock jp TextScriptEnd CeladonGameCornerText_48f09: ; 48f09 (12:4f09) diff --git a/scripts/celadongym.asm b/scripts/celadongym.asm index 092bff888c..b1b1060c00 100755 --- a/scripts/celadongym.asm +++ b/scripts/celadongym.asm @@ -31,7 +31,7 @@ CeladonGymText_48943: ; 48943 (12:4943) CeladonGymScriptPointers: ; 4894e (12:494e) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle dw CeladonGymScript3 @@ -177,7 +177,7 @@ CeladonGymText1: ; 48a11 (12:4a11) set 7, [hl] ld hl, CeladonGymText_48a63 ld de, CeladonGymText_48a63 - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ldh a, [$8c] ld [wSpriteIndex], a call EngageMapTrainer diff --git a/scripts/ceruleancity.asm b/scripts/ceruleancity.asm index d97f9723bd..9782466274 100755 --- a/scripts/ceruleancity.asm +++ b/scripts/ceruleancity.asm @@ -133,7 +133,7 @@ CeruleanCityScript1: ; 19567 (6:5567) set 7, [hl] ld hl, CeruleanCityText_1966d ld de, CeruleanCityText_19672 - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ld a, SONY1 + $c8 ld [W_CUROPPONENT], a @@ -277,7 +277,7 @@ CeruleanCityText2: ; 1967c (6:567c) set 7, [hl] ld hl, CeruleanCityText_196ee ld de, CeruleanCityText_196ee - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ld a, [$ff8c] ld [wSpriteIndex], a call EngageMapTrainer diff --git a/scripts/ceruleangym.asm b/scripts/ceruleangym.asm index ae6a40a09e..079844f39b 100755 --- a/scripts/ceruleangym.asm +++ b/scripts/ceruleangym.asm @@ -31,7 +31,7 @@ CeruleanGymScript_5c6ed: ; 5c6ed (17:46ed) CeruleanGymScriptPointers: ; 5c6f8 (17:46f8) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle dw CeruleanGymScript3 @@ -126,7 +126,7 @@ CeruleanGymText1: ; 5c771 (17:4771) set 7, [hl] ld hl, CeruleanGymText_5c7d8 ld de, CeruleanGymText_5c7d8 - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ldh a, [$8c] ld [wSpriteIndex], a call EngageMapTrainer diff --git a/scripts/cinnabargym.asm b/scripts/cinnabargym.asm index 65fd1db949..48133c5265 100755 --- a/scripts/cinnabargym.asm +++ b/scripts/cinnabargym.asm @@ -224,7 +224,7 @@ CinnabarGymText1: ; 758df (1d:58df) call PrintText ld hl, BlaineEndBattleText ld de, BlaineEndBattleText - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ld a, $7 ld [W_GYMLEADERNO], a jp CinnabarGymScript_758b7 @@ -267,7 +267,7 @@ CinnabarGymText2: ; 75939 (1d:5939) call PrintText ld hl, CinnabarGymText_75964 ld de, CinnabarGymText_75964 ; $5964 XXX - call PreBattleSaveRegisters + call SaveEndBattleTextPointers jp CinnabarGymScript_758b7 .asm_46bb4 ; 0x75956 ld hl, CinnabarGymText_75969 @@ -296,7 +296,7 @@ CinnabarGymText3: ; 7596e (1d:596e) call PrintText ld hl, CinnabarGymText_75999 ld de, CinnabarGymText_75999 ; $5999 XXX - call PreBattleSaveRegisters + call SaveEndBattleTextPointers jp CinnabarGymScript_758b7 .asm_4b406 ; 0x7598b ld hl, CinnabarGymText_7599e @@ -325,7 +325,7 @@ CinnabarGymText4: ; 759a3 (1d:59a3) call PrintText ld hl, CinnabarGymText_759ce ld de, CinnabarGymText_759ce ; $59ce XXX - call PreBattleSaveRegisters + call SaveEndBattleTextPointers jp CinnabarGymScript_758b7 .asm_c0673 ; 0x759c0 ld hl, CinnabarGymText_759d3 @@ -354,7 +354,7 @@ CinnabarGymText5: ; 759d8 (1d:59d8) call PrintText ld hl, CinnabarGymText_75a03 ld de, CinnabarGymText_75a03 ; $5a03 XXX - call PreBattleSaveRegisters + call SaveEndBattleTextPointers jp CinnabarGymScript_758b7 .asm_5cfd7 ; 0x759f5 ld hl, CinnabarGymText_75a08 @@ -383,7 +383,7 @@ CinnabarGymText6: ; 75a0d (1d:5a0d) call PrintText ld hl, CinnabarGymText_75a38 ld de, CinnabarGymText_75a38 - call PreBattleSaveRegisters + call SaveEndBattleTextPointers jp CinnabarGymScript_758b7 .asm_776b4 ; 0x75a2a ld hl, CinnabarGymText_75a3d @@ -412,7 +412,7 @@ CinnabarGymText7: ; 75a42 (1d:5a42) call PrintText ld hl, CinnabarGymText_75a6d ld de, CinnabarGymText_75a6d - call PreBattleSaveRegisters + call SaveEndBattleTextPointers jp CinnabarGymScript_758b7 .asm_2f755 ; 0x75a5f ld hl, CinnabarGymText_75a72 @@ -441,7 +441,7 @@ CinnabarGymText8: ; 75a77 (1d:5a77) call PrintText ld hl, CinnabarGymText_75aa2 ld de, CinnabarGymText_75aa2 ; $5aa2 XXX - call PreBattleSaveRegisters + call SaveEndBattleTextPointers jp CinnabarGymScript_758b7 .asm_d87be ; 0x75a94 ld hl, CinnabarGymText_75aa7 diff --git a/scripts/fightingdojo.asm b/scripts/fightingdojo.asm index fb8d7b19cb..4a55347e46 100755 --- a/scripts/fightingdojo.asm +++ b/scripts/fightingdojo.asm @@ -16,7 +16,7 @@ FightingDojoScript_5cd70: ; 5cd70 (17:4d70) FightingDojoScriptPointers: ; 5cd7b (17:4d7b) dw FightingDojoScript1 - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle dw FightingDojoScript3 @@ -147,7 +147,7 @@ FightingDojoText1: ; 5ce44 (17:4e44) set 7, [hl] ld hl, FightingDojoText_5ce93 ld de, FightingDojoText_5ce93 - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ldh a, [$8c] ld [wSpriteIndex], a call EngageMapTrainer diff --git a/scripts/fuchsiagym.asm b/scripts/fuchsiagym.asm index 14ffdfa968..43d977d7ad 100755 --- a/scripts/fuchsiagym.asm +++ b/scripts/fuchsiagym.asm @@ -32,7 +32,7 @@ FuchsiaGymScript_75477: ; 75477 (1d:5477) FuchsiaGymScriptPointers: ; 75482 (1d:5482) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle dw FuchsiaGymScript3 @@ -166,7 +166,7 @@ FuchsiaGymText1: ; 75534 (1d:5534) set 7, [hl] ld hl, UnnamedText_75586 ld de, UnnamedText_75586 - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ldh a, [$8c] ld [wSpriteIndex], a call EngageMapTrainer diff --git a/scripts/gary.asm b/scripts/gary.asm index b32e35951f..fa3311521f 100755 --- a/scripts/gary.asm +++ b/scripts/gary.asm @@ -63,7 +63,7 @@ GaryScript2: ; 75f6a (1d:5f6a) set 7, [hl] ld hl, GaryText_760f9 ld de, GaryText_760fe - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ld a, SONY3 + $c8 ld [W_CUROPPONENT], a diff --git a/scripts/lance.asm b/scripts/lance.asm index d5ca4e5cc7..f252309800 100755 --- a/scripts/lance.asm +++ b/scripts/lance.asm @@ -34,7 +34,7 @@ LanceScript_5a2de: ; 5a2de (16:62de) ld bc, $603 LanceScript_5a2f0: ; 5a2f0 (16:62f0) - predef_jump Func_ee9e + predef_jump ReplaceTileBlock LanceScript_5a2f5: ; 5a2f5 (16:62f5) xor a @@ -43,7 +43,7 @@ LanceScript_5a2f5: ; 5a2f5 (16:62f5) LanceScriptPointers: ; 5a2fa (16:62fa) dw LanceScript0 - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw LanceScript2 dw LanceScript3 dw LanceScript4 diff --git a/scripts/lorelei.asm b/scripts/lorelei.asm index 33f419a3cf..ab769d948c 100755 --- a/scripts/lorelei.asm +++ b/scripts/lorelei.asm @@ -25,7 +25,7 @@ LoreleiScript_76191: ; 76191 (1d:6191) .asm_761ab ld [wd09f], a ld bc, $2 - predef_jump Func_ee9e + predef_jump ReplaceTileBlock LoreleiScript_761b6: ; 761b6 (1d:61b6) xor a @@ -34,7 +34,7 @@ LoreleiScript_761b6: ; 761b6 (1d:61b6) LoreleiScriptPointers: ; 761bb (1d:61bb) dw LoreleiScript0 - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw LoreleiScript2 dw LoreleiScript3 dw LoreleiScript4 diff --git a/scripts/mansion1.asm b/scripts/mansion1.asm index 7621897f2a..3e067a98b4 100755 --- a/scripts/mansion1.asm +++ b/scripts/mansion1.asm @@ -43,7 +43,7 @@ Mansion1Script_4430b: ; 4430b (11:430b) ld a, $e ld [wd09f], a asm_44310: ; 44310 (11:4310) - predef Func_ee9e + predef ReplaceTileBlock ret Mansion1Script_Switches: ; 44316 (11:4316) @@ -58,7 +58,7 @@ Mansion1Script_Switches: ; 44316 (11:4316) Mansion1ScriptPointers: ; 44326 (11:4326) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle Mansion1TextPointers: ; 4432c (11:432c) diff --git a/scripts/mansion2.asm b/scripts/mansion2.asm index 1b7a28a3af..c643d22946 100755 --- a/scripts/mansion2.asm +++ b/scripts/mansion2.asm @@ -40,7 +40,7 @@ Mansion2Script_51fee: ; 51fee (14:5fee) Mansion2Script_5202f: ; 5202f (14:602f) ld [wd09f], a - predef_jump Func_ee9e + predef_jump ReplaceTileBlock Mansion2Script_Switches: ; 52037 (14:6037) ld a, [wSpriteStateData1 + 9] @@ -54,7 +54,7 @@ Mansion2Script_Switches: ; 52037 (14:6037) Mansion2ScriptPointers: ; 52047 (14:6047) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle Mansion2TextPointers: ; 5204d (14:604d) diff --git a/scripts/mansion3.asm b/scripts/mansion3.asm index 494fba13fa..6ad02dd9c9 100755 --- a/scripts/mansion3.asm +++ b/scripts/mansion3.asm @@ -34,7 +34,7 @@ Mansion3Script_52204: ; 52204 (14:6204) Mansion3ScriptPointers: ; 52235 (14:6235) dw Mansion3Script0 - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle Mansion3Script0: ; 5223b (14:623b) diff --git a/scripts/mansion4.asm b/scripts/mansion4.asm index cfd78c5f43..b89af5f208 100755 --- a/scripts/mansion4.asm +++ b/scripts/mansion4.asm @@ -56,7 +56,7 @@ Mansion4Script_Switches: ; 52420 (14:6420) Mansion4ScriptPointers: ; 52430 (14:6430) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle Mansion4TextPointers: ; 52436 (14:6436) diff --git a/scripts/mtmoon1.asm b/scripts/mtmoon1.asm index 42f98d98fa..def597ba66 100755 --- a/scripts/mtmoon1.asm +++ b/scripts/mtmoon1.asm @@ -9,7 +9,7 @@ MtMoon1Script: ; 499c8 (12:59c8) MtMoon1ScriptPointers: ; 499db (12:59db) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle MtMoon1TextPointers: ; 499e1 (12:59e1) diff --git a/scripts/mtmoon3.asm b/scripts/mtmoon3.asm index 7163840917..f0124be0fa 100755 --- a/scripts/mtmoon3.asm +++ b/scripts/mtmoon3.asm @@ -47,7 +47,7 @@ MtMoon3Script_49d58: ; 49d58 (12:5d58) MtMoon3ScriptPointers: ; 49d63 (12:5d63) dw MtMoon3Script0 - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle dw MtMoon3Script3 dw MtMoon3Script4 @@ -228,7 +228,7 @@ MtMoon3Text1: ; 49e79 (12:5e79) set 7, [hl] ld hl, MtMoon3Text_49f8a ld de, MtMoon3Text_49f8a - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ldh a, [$8c] ld [wSpriteIndex], a call EngageMapTrainer diff --git a/scripts/oakslab.asm b/scripts/oakslab.asm index 8666d18e02..574c68142d 100755 --- a/scripts/oakslab.asm +++ b/scripts/oakslab.asm @@ -378,7 +378,7 @@ OaksLabScript11: ; 1cdb9 (7:4db9) call GetSpritePosition1 ld hl, OaksLabText_1d3be ld de, OaksLabText_1d3c3 - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ld hl, wd72d set 6, [hl] set 7, [hl] diff --git a/scripts/pewtergym.asm b/scripts/pewtergym.asm index 0ab4c3a4ed..21d3fe74be 100755 --- a/scripts/pewtergym.asm +++ b/scripts/pewtergym.asm @@ -31,7 +31,7 @@ PewterGymScript_5c3bf: ; 5c3bf (17:43bf) PewterGymScriptPointers: ; 5c3ca (17:43ca) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle dw PewterGymScript3 @@ -126,7 +126,7 @@ PewterGymText1: ; 5c44e (17:444e) set 7, [hl] ld hl, PewterGymText_5c4bc ld de, PewterGymText_5c4bc - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ldh a, [$8c] ld [wSpriteIndex], a call EngageMapTrainer diff --git a/scripts/pokemontower2.asm b/scripts/pokemontower2.asm index 38dd1bc52a..3c9ec72df8 100755 --- a/scripts/pokemontower2.asm +++ b/scripts/pokemontower2.asm @@ -130,7 +130,7 @@ PokemonTower2Text1: ; 605df (18:45df) set 7, [hl] ld hl, PokemonTower2Text_60632 ld de, PokemonTower2Text_60637 ; XXX $4637 - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ld a, SONY2 + $c8 ld [W_CUROPPONENT], a diff --git a/scripts/pokemontower3.asm b/scripts/pokemontower3.asm index f05623fbf9..8df5bfc5d4 100755 --- a/scripts/pokemontower3.asm +++ b/scripts/pokemontower3.asm @@ -9,7 +9,7 @@ PokemonTower3Script: ; 606cc (18:46cc) PokemonTower3ScriptPointers: ; 606df (18:46df) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle PokemonTower3TextPointers: ; 606e5 (18:46e5) diff --git a/scripts/pokemontower4.asm b/scripts/pokemontower4.asm index e48b968193..760bb6042c 100755 --- a/scripts/pokemontower4.asm +++ b/scripts/pokemontower4.asm @@ -9,7 +9,7 @@ PokemonTower4Script: ; 607f6 (18:47f6) PokemonTower4ScriptPointers: ; 60809 (18:4809) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle PokemonTower4TextPointers: ; 6080f (18:480f) diff --git a/scripts/pokemontower5.asm b/scripts/pokemontower5.asm index 6dd694acfd..b70f9e2861 100755 --- a/scripts/pokemontower5.asm +++ b/scripts/pokemontower5.asm @@ -9,7 +9,7 @@ PokemonTower5Script: ; 60932 (18:4932) PokemonTower5ScriptPointers: ; 60945 (18:4945) dw PokemonTower5Script0 - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle PokemonTower5Script0: ; 6094b (18:494b) diff --git a/scripts/pokemontower6.asm b/scripts/pokemontower6.asm index 6320e2af0d..58968d172d 100755 --- a/scripts/pokemontower6.asm +++ b/scripts/pokemontower6.asm @@ -16,7 +16,7 @@ PokemonTower6Script_60b02: ; 60b02 (18:4b02) PokemonTower6ScriptPointers: ; 60b0d (18:4b0d) dw PokemonTower6Script0 - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle dw PokemonTower6Script3 dw PokemonTower6Script4 diff --git a/scripts/pokemontower7.asm b/scripts/pokemontower7.asm index 6ebf15d5db..cc736a0875 100755 --- a/scripts/pokemontower7.asm +++ b/scripts/pokemontower7.asm @@ -16,7 +16,7 @@ PokemonTower7Script_60d18: ; 60d18 (18:4d18) PokemonTower7ScriptPointers: ; 60d23 (18:4d23) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw PokemonTower7Script2 dw PokemonTower7Script3 dw PokemonTower7Script4 diff --git a/scripts/powerplant.asm b/scripts/powerplant.asm index b90ba7a1c2..ec4f89b3e6 100755 --- a/scripts/powerplant.asm +++ b/scripts/powerplant.asm @@ -9,7 +9,7 @@ PowerPlantScript: ; 1e2c6 (7:62c6) PowerPlantScriptPointers: ; 1e2d9 (7:62d9) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle PowerPlantTextPointers: ; 1e2df (7:62df) diff --git a/scripts/rockethideout1.asm b/scripts/rockethideout1.asm index 43e4fd2669..499f77ef03 100755 --- a/scripts/rockethideout1.asm +++ b/scripts/rockethideout1.asm @@ -30,11 +30,11 @@ RocketHideout1Script_44be0: ; 44be0 (11:4be0) .asm_44c03 ld [wd09f], a ld bc, $080c - predef_jump Func_ee9e + predef_jump ReplaceTileBlock RocketHideout1ScriptPointers: ; 44c0e (11:4c0e) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle RocketHideout1TextPointers: ; 44c14 (11:4c14) diff --git a/scripts/rockethideout2.asm b/scripts/rockethideout2.asm index 326c160555..9975465831 100755 --- a/scripts/rockethideout2.asm +++ b/scripts/rockethideout2.asm @@ -9,7 +9,7 @@ RocketHideout2Script: ; 44e27 (11:4e27) RocketHideout2ScriptPointers: ; 44e3a (11:4e3a) dw RocketHideout2Script0 - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle dw RocketHideout2Script3 @@ -19,7 +19,7 @@ RocketHideout2Script0: ; 44e42 (11:4e42) ld a, [W_XCOORD] ld c, a ld hl, RocketHideout2ArrowTilePlayerMovement - call Func_3442 + call DecodeArrowMovementRLE cp $ff jp z, CheckFightingMapTrainers ld hl, wd736 diff --git a/scripts/rockethideout3.asm b/scripts/rockethideout3.asm index 3870c6b63a..6dc467ab42 100755 --- a/scripts/rockethideout3.asm +++ b/scripts/rockethideout3.asm @@ -9,7 +9,7 @@ RocketHideout3Script: ; 45225 (11:5225) RocketHideout3ScriptPointers: ; 45238 (11:5238) dw RocketHideout3Script0 - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle dw RocketHideout3Script3 @@ -19,7 +19,7 @@ RocketHideout3Script0: ; 45240 (11:5240) ld a, [W_XCOORD] ld c, a ld hl, RocketHideout3ArrowTilePlayerMovement - call Func_3442 + call DecodeArrowMovementRLE cp $ff jp z, CheckFightingMapTrainers ld hl, wd736 diff --git a/scripts/rockethideout4.asm b/scripts/rockethideout4.asm index ddac941ab8..097512c36b 100755 --- a/scripts/rockethideout4.asm +++ b/scripts/rockethideout4.asm @@ -31,7 +31,7 @@ RocketHideout4Script_45473: ; 45473 (11:5473) .asm_45498 ld [wd09f], a ld bc, $050c - predef_jump Func_ee9e + predef_jump ReplaceTileBlock RocketHideout4Script_454a3: ; 454a3 (11:54a3) xor a @@ -42,7 +42,7 @@ RocketHideout4Script_454a3: ; 454a3 (11:54a3) RocketHideout4ScriptPointers: ; 454ae (11:54ae)c dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle dw RocketHideout4Script3 @@ -130,7 +130,7 @@ RocketHideout4Text1: ; 4553a (11:553a) set 7, [hl] ld hl, RocketHideout4Text_4557f ld de, RocketHideout4Text_4557f - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ldh a, [$8c] ld [wSpriteIndex], a call EngageMapTrainer diff --git a/scripts/rocktunnel1.asm b/scripts/rocktunnel1.asm index ad6e493f67..1d514a051d 100755 --- a/scripts/rocktunnel1.asm +++ b/scripts/rocktunnel1.asm @@ -9,7 +9,7 @@ RockTunnel1Script: ; 444dc (11:44dc) RockTunnel1ScriptPointers: ; 444ef (11:44ef) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle RockTunnel1TextPointers: ; 444f5 (11:44f5) diff --git a/scripts/rocktunnel2.asm b/scripts/rocktunnel2.asm index a35a7325bc..98b804a7c2 100755 --- a/scripts/rocktunnel2.asm +++ b/scripts/rocktunnel2.asm @@ -9,7 +9,7 @@ RockTunnel2Script: ; 45feb (11:5feb) RockTunnel2ScriptPointers: ; 45ffe (11:5ffe) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle RockTunnel2TextPointers: ; 46004 (11:6004) diff --git a/scripts/route10.asm b/scripts/route10.asm index e5e0dec248..c587b1df81 100755 --- a/scripts/route10.asm +++ b/scripts/route10.asm @@ -9,7 +9,7 @@ Route10Script: ; 59336 (16:5336) Route10ScriptPointers: ; 59349 (16:5349) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle Route10TextPointers: ; 5934f (16:534f) diff --git a/scripts/route11.asm b/scripts/route11.asm index fb50937e35..629a6efd9a 100755 --- a/scripts/route11.asm +++ b/scripts/route11.asm @@ -9,7 +9,7 @@ Route11Script: ; 5944c (16:544c) Route11ScriptPointers: ; 5945f (16:545f) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle Route11TextPointers: ; 59465 (16:5465) diff --git a/scripts/route12.asm b/scripts/route12.asm index 04b8620718..a38f6b8353 100755 --- a/scripts/route12.asm +++ b/scripts/route12.asm @@ -16,7 +16,7 @@ Route12Script_59606: ; 59606 (16:5606) Route12ScriptPointers: ; 59611 (16:5611) dw Route12Script0 - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle dw Route12Script3 diff --git a/scripts/route13.asm b/scripts/route13.asm index b78b7cb241..21862dfc09 100755 --- a/scripts/route13.asm +++ b/scripts/route13.asm @@ -9,7 +9,7 @@ Route13Script: ; 5581e (15:581e) Route13ScriptPointers: ; 55831 (15:5831) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle Route13TextPointers: ; 55837 (15:5837) diff --git a/scripts/route14.asm b/scripts/route14.asm index 9d8d8fcb7d..d430f85890 100755 --- a/scripts/route14.asm +++ b/scripts/route14.asm @@ -9,7 +9,7 @@ Route14Script: ; 559d3 (15:59d3) Route14ScriptPointers: ; 559e6 (15:59e6) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle Route14TextPointers: ; 559ec (15:59ec) diff --git a/scripts/route15.asm b/scripts/route15.asm index 789ace2101..733d4a1cc1 100755 --- a/scripts/route15.asm +++ b/scripts/route15.asm @@ -9,7 +9,7 @@ Route15Script: ; 597ae (16:57ae) Route15ScriptPointers: ; 597c1 (16:57c1) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle Route15TextPointers: ; 597c7 (16:57c7) diff --git a/scripts/route16.asm b/scripts/route16.asm index 2e60d77ba3..59f8cb24fc 100755 --- a/scripts/route16.asm +++ b/scripts/route16.asm @@ -16,7 +16,7 @@ Route16Script_59946: ; 59946 (16:5946) Route16ScriptPointers: ; 59951 (16:5951) dw Route16Script0 - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle dw Route16Script3 diff --git a/scripts/route17.asm b/scripts/route17.asm index 78ceb2ae7e..ffd006346c 100755 --- a/scripts/route17.asm +++ b/scripts/route17.asm @@ -9,7 +9,7 @@ Route17Script: ; 55b7a (15:5b7a) Route17ScriptPointers: ; 55b8d (15:5b8d) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle Route17TextPointers: ; 55b93 (15:5b93) diff --git a/scripts/route18.asm b/scripts/route18.asm index a0e4487aad..de2fe19a99 100755 --- a/scripts/route18.asm +++ b/scripts/route18.asm @@ -9,7 +9,7 @@ Route18Script: ; 59ac7 (16:5ac7) Route18ScriptPointers: ; 59ada (16:5ada) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle Route18TextPointers: ; 59ae0 (16:5ae0) diff --git a/scripts/route19.asm b/scripts/route19.asm index 6c749b0375..40c7aeb324 100755 --- a/scripts/route19.asm +++ b/scripts/route19.asm @@ -9,7 +9,7 @@ Route19Script: ; 55d44 (15:5d44) Route19ScriptPointers: ; 55d57 (15:5d57) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle Route19TextPointers: ; 55d5d (15:5d5d) diff --git a/scripts/route20.asm b/scripts/route20.asm index 7e8df3dac8..47edf37671 100755 --- a/scripts/route20.asm +++ b/scripts/route20.asm @@ -58,7 +58,7 @@ Route20Script_50d14: ; 50d14 (14:4d14) Route20ScriptPointers: ; 50d1c (14:4d1c) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle Route20TextPointers: ; 50d22 (14:4d22) diff --git a/scripts/route21.asm b/scripts/route21.asm index 034282f881..de2046dc81 100755 --- a/scripts/route21.asm +++ b/scripts/route21.asm @@ -9,7 +9,7 @@ Route21Script: ; 55eeb (15:5eeb) Route21ScriptPointers: ; 55efe (15:5efe) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle Route21TextPointers: ; 55f04 (15:5f04) diff --git a/scripts/route22.asm b/scripts/route22.asm index 667edd65cc..233d42c3ef 100755 --- a/scripts/route22.asm +++ b/scripts/route22.asm @@ -128,7 +128,7 @@ Route22Script1: ; 50f62 (14:4f62) set 7, [hl] ld hl, Route22RivalDefeatedText1 ld de, Route22Text_511bc - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ld a, SONY1 + $c8 ld [W_CUROPPONENT], a ld hl, StarterMons_50faf ; $4faf @@ -270,7 +270,7 @@ Route22Script4: ; 51087 (14:5087) set 7, [hl] ld hl, Route22RivalDefeatedText2 ; $51cb ld de, Route22Text_511d0 ; $51d0 - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ld a, SONY2 + $c8 ld [W_CUROPPONENT], a ; wd059 ld hl, StarterMons_510d9 ; $50d9 diff --git a/scripts/route24.asm b/scripts/route24.asm index ea48053b2a..6916cbe724 100755 --- a/scripts/route24.asm +++ b/scripts/route24.asm @@ -16,7 +16,7 @@ Route24Script_513c0: ; 513c0 (14:53c0) Route24ScriptPointers: ; 513cb (14:53cb) dw Route24Script0 - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle dw Route24Script3 dw Route24Script4 @@ -169,7 +169,7 @@ Route24Text1: ; 514a4 (14:54a4) set 7, [hl] ld hl, Route24Text_5152b ld de, Route24Text_5152b - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ld a, [$ff8c] ld [wSpriteIndex], a call EngageMapTrainer diff --git a/scripts/route25.asm b/scripts/route25.asm index 088be3a292..720259ca2c 100755 --- a/scripts/route25.asm +++ b/scripts/route25.asm @@ -38,7 +38,7 @@ Route25Script_515e1: ; 515e1 (14:55e1) Route25ScriptPointers: ; 51622 (14:5622) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle Route25TextPointers: ; 51628 (14:5628) diff --git a/scripts/route3.asm b/scripts/route3.asm index 5cd35fd97c..acb2afce85 100755 --- a/scripts/route3.asm +++ b/scripts/route3.asm @@ -9,7 +9,7 @@ Route3Script: ; 554f8 (15:54f8) Route3ScriptPointers: ; 5550b (15:550b) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle Route3TextPointers: ; 55511 (15:5511) diff --git a/scripts/route4.asm b/scripts/route4.asm index fa23459058..5eafb4f725 100755 --- a/scripts/route4.asm +++ b/scripts/route4.asm @@ -9,7 +9,7 @@ Route4Script: ; 55658 (15:5658) Route4ScriptPointers: ; 5566b (15:566b) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle Route4TextPointers: ; 55671 (15:5671) diff --git a/scripts/route6.asm b/scripts/route6.asm index 018c1b806a..ee6258cd74 100755 --- a/scripts/route6.asm +++ b/scripts/route6.asm @@ -9,7 +9,7 @@ Route6Script: ; 590b0 (16:50b0) Route6ScriptPointers: ; 590c3 (16:50c3) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle Route6TextPointers: ; 590c9 (16:50c9) diff --git a/scripts/route8.asm b/scripts/route8.asm index bf41b5ae75..eed57c7bbf 100755 --- a/scripts/route8.asm +++ b/scripts/route8.asm @@ -9,7 +9,7 @@ Route8Script: ; 591b6 (16:51b6) Route8ScriptPointers: ; 591c9 (16:51c9) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle Route8TextPointers: ; 591cf (16:51cf) diff --git a/scripts/route9.asm b/scripts/route9.asm index f14abef88f..77b216c633 100755 --- a/scripts/route9.asm +++ b/scripts/route9.asm @@ -9,7 +9,7 @@ Route9Script: ; 556bc (15:56bc) Route9ScriptPointers: ; 556cf (15:56cf) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle Route9TextPointers: ; 556d5 (15:56d5) diff --git a/scripts/saffrongym.asm b/scripts/saffrongym.asm index 39f4df10a2..7c2eb5594d 100755 --- a/scripts/saffrongym.asm +++ b/scripts/saffrongym.asm @@ -31,7 +31,7 @@ SaffronGymText_5d048: ; 5d048 (17:5048) SaffronGymScriptPointers: ; 5d053 (17:5053) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle dw SaffronGymScript3 @@ -178,7 +178,7 @@ SaffronGymText1: ; 5d118 (17:5118) set 7, [hl] ld hl, SaffronGymText_5d167 ld de, SaffronGymText_5d167 - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ldh a, [$8c] ld [wSpriteIndex], a call EngageMapTrainer diff --git a/scripts/silphco10.asm b/scripts/silphco10.asm index c831655f00..7d044aca37 100755 --- a/scripts/silphco10.asm +++ b/scripts/silphco10.asm @@ -22,7 +22,7 @@ SilphCo10Script_5a14f: ; 5a14f (16:614f) ld a, $54 ld [wd09f], a ld bc, $405 - predef_jump Func_ee9e + predef_jump ReplaceTileBlock DataTable_5a173: ; 5a173 (16:6173) db $04,$05,$FF @@ -37,7 +37,7 @@ SilphCo10Text_5a176: ; 5a176 (16:6176) SilphCo10ScriptPointers: ; 5a180 (16:6180) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle SilphCo10TextPointers: ; 5a186 (16:6186) diff --git a/scripts/silphco11.asm b/scripts/silphco11.asm index 32a455ec8f..43ae72f6b5 100755 --- a/scripts/silphco11.asm +++ b/scripts/silphco11.asm @@ -22,14 +22,14 @@ SilphCo11Script_62110: ; 62110 (18:6110) ld a, $20 ld [wd09f], a ld bc, $603 - predef_jump Func_ee9e + predef_jump ReplaceTileBlock DataTable_62134: ; 62134 (18:6134) db $06,$03,$FF SilphCo11Script_62137: ; 62137 (18:6137) push hl - ld hl, wd73f + ld hl, wCardKeyDoorY ld a, [hli] ld b, a ld a, [hl] @@ -53,7 +53,7 @@ SilphCo11Script_62137: ; 62137 (18:6137) ld a, [hli] cp c jr nz, .asm_62143 - ld hl, wd73f + ld hl, wCardKeyDoorY xor a ld [hli], a ld [hl], a @@ -116,7 +116,7 @@ SilphCo11Script_621c8: ; 621c8 (18:61c8) SilphCo11ScriptPointers: ; 621cf (18:61cf) dw SilphCo11Script0 - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle dw SilphCo11Script3 dw SilphCo11Script4 @@ -221,7 +221,7 @@ SilphCo11Script4: ; 62293 (18:6293) set 7, [hl] ld hl, SilphCo10Text_62330 ; $6330 ld de, SilphCo10Text_62330 ; $6330 - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ld a, [H_DOWNARROWBLINKCNT2] ; $ff8c ld [wSpriteIndex], a call EngageMapTrainer diff --git a/scripts/silphco2.asm b/scripts/silphco2.asm index 20d689e66b..63803acd94 100755 --- a/scripts/silphco2.asm +++ b/scripts/silphco2.asm @@ -23,7 +23,7 @@ SilphCo2Script_59d07: ; 59d07 (16:5d07) ld a, $54 ld [wd09f], a ld bc, $0202 - predef Func_ee9e + predef ReplaceTileBlock pop af .asm_59d2e bit 6, a @@ -31,14 +31,14 @@ SilphCo2Script_59d07: ; 59d07 (16:5d07) ld a, $54 ld [wd09f], a ld bc, $0502 - predef_jump Func_ee9e + predef_jump ReplaceTileBlock DataTable_59d3e: ; 59d3e (16:5d3e) db $02,$02,$05,$02,$FF SilphCo2Script_59d43: ; 59d43 (16:5d43) push hl - ld hl, wd73f + ld hl, wCardKeyDoorY ld a, [hli] ld b, a ld a, [hl] @@ -62,7 +62,7 @@ SilphCo2Script_59d43: ; 59d43 (16:5d43) ld a, [hli] cp c jr nz, .asm_59d4f - ld hl, wd73f + ld hl, wCardKeyDoorY xor a ld [hli], a ld [hl], a @@ -87,7 +87,7 @@ SilphCo2Script_59d6f: ; 59d6f (16:5d6f) SilphCo2ScriptPointers: ; 59d80 (16:5d80) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle SilphCo2TextPointers: ; 59d86 (16:5d86) diff --git a/scripts/silphco3.asm b/scripts/silphco3.asm index 5527d92389..7b0c67c136 100755 --- a/scripts/silphco3.asm +++ b/scripts/silphco3.asm @@ -23,7 +23,7 @@ SilphCo3Script_59f71: ; 59f71 (16:5f71) ld a, $5f ld [wd09f], a ld bc, $404 - predef Func_ee9e + predef ReplaceTileBlock pop af .asm_59f98 bit 1, a @@ -31,7 +31,7 @@ SilphCo3Script_59f71: ; 59f71 (16:5f71) ld a, $5f ld [wd09f], a ld bc, $408 - predef_jump Func_ee9e + predef_jump ReplaceTileBlock DataTable_59fa8: ; 59fa8 (16:5fa8) db $04,$04,$04,$08,$FF @@ -51,7 +51,7 @@ SilphCo3Script_59fad: ; 59fad (16:5fad) SilphCo3ScriptPointers: ; 59fbe (16:5fbe) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle SilphCo3TextPointers: ; 59fc4 (16:5fc4) diff --git a/scripts/silphco4.asm b/scripts/silphco4.asm index 718077ce73..15a46dd319 100755 --- a/scripts/silphco4.asm +++ b/scripts/silphco4.asm @@ -23,7 +23,7 @@ SilphCo4Script_19d21: ; 19d21 (6:5d21) ld a, $54 ld [wd09f], a ld bc, $0602 - predef Func_ee9e + predef ReplaceTileBlock pop af .asm_19d48 bit 1, a @@ -31,14 +31,14 @@ SilphCo4Script_19d21: ; 19d21 (6:5d21) ld a, $54 ld [wd09f], a ld bc, $0406 - predef_jump Func_ee9e + predef_jump ReplaceTileBlock SilphCo4Data19d58: ; 19d58 (6:5d58) db $06, $02, $04, $06, $ff SilphCo4Script_19d5d: ; 19d5d (6:5d5d) push hl - ld hl, wd73f + ld hl, wCardKeyDoorY ld a, [hli] ld b, a ld a, [hl] @@ -62,7 +62,7 @@ SilphCo4Script_19d5d: ; 19d5d (6:5d5d) ld a, [hli] cp c jr nz, .asm_19d69 ; 0x19d7c $eb - ld hl, wd73f + ld hl, wCardKeyDoorY xor a ld [hli], a ld [hl], a @@ -87,7 +87,7 @@ SilphCo4Script_19d89: ; 19d89 (6:5d89) SilphCo4ScriptPointers: ; 19d9a (6:5d9a) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle SilphCo4TextPointers: ; 19da0 (6:5da0) diff --git a/scripts/silphco5.asm b/scripts/silphco5.asm index 709af20bdd..0b63708bda 100755 --- a/scripts/silphco5.asm +++ b/scripts/silphco5.asm @@ -23,7 +23,7 @@ SilphCo5Script_19f4d: ; 19f4d (6:5f4d) ld a, $5f ld [wd09f], a ld bc, $0203 - predef Func_ee9e + predef ReplaceTileBlock pop af .asm_19f74 bit 1, a @@ -32,7 +32,7 @@ SilphCo5Script_19f4d: ; 19f4d (6:5f4d) ld a, $5f ld [wd09f], a ld bc, $0603 - predef Func_ee9e + predef ReplaceTileBlock pop af .asm_19f87 bit 2, a @@ -40,7 +40,7 @@ SilphCo5Script_19f4d: ; 19f4d (6:5f4d) ld a, $5f ld [wd09f], a ld bc, $0507 - predef_jump Func_ee9e + predef_jump ReplaceTileBlock SilphCo5Coords: ; 19f97 (6:5f97) ; coords? db $02, $03, $06, $03, $05, $07, $ff @@ -65,7 +65,7 @@ SilphCo5Script_19f9e: ; 19f9e (6:5f9e) SilphCo5ScriptPointers: ; 19fb6 (6:5fb6) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle SilphCo5TextPointers: ; 19fbc (6:5fbc) diff --git a/scripts/silphco6.asm b/scripts/silphco6.asm index 4a9477c667..137e31be00 100755 --- a/scripts/silphco6.asm +++ b/scripts/silphco6.asm @@ -22,7 +22,7 @@ SilphCo6Script_1a1bf: ; 1a1bf (6:61bf) ld a, $5f ld [wd09f], a ld bc, $0602 - predef_jump Func_ee9e + predef_jump ReplaceTileBlock SilphCo6Coords1: ; 1a1e3 (6:61e3) db $06, $02 @@ -38,7 +38,7 @@ SilphCo6Script_1a1e6: ; 1a1e6 (6:61e6) SilphCo6ScriptPointers: ; 1a1f0 (6:61f0) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle SilphCo6TextPointers: ; 1a1f6 (6:61f6) diff --git a/scripts/silphco7.asm b/scripts/silphco7.asm index fff1246e46..2fc3c51a1c 100755 --- a/scripts/silphco7.asm +++ b/scripts/silphco7.asm @@ -23,7 +23,7 @@ SilphCo7Script_51b77: ; 51b77 (14:5b77) ld a, $54 ld [wd09f], a ld bc, $305 - predef Func_ee9e + predef ReplaceTileBlock pop af .asm_51b9e bit 5, a @@ -32,7 +32,7 @@ SilphCo7Script_51b77: ; 51b77 (14:5b77) ld a, $54 ld [wd09f], a ld bc, $20a - predef Func_ee9e + predef ReplaceTileBlock pop af .asm_51bb1 bit 6, a @@ -40,14 +40,14 @@ SilphCo7Script_51b77: ; 51b77 (14:5b77) ld a, $54 ld [wd09f], a ld bc, $60a - predef_jump Func_ee9e + predef_jump ReplaceTileBlock DataTable_51bc1: ; 51bc1 (14:5bc1) db $03,$05,$02,$0A,$06,$0A,$FF SilphCo7Text_51bc8: ; 51bc8 (14:5bc8) push hl - ld hl, wd73f + ld hl, wCardKeyDoorY ld a, [hli] ld b, a ld a, [hl] @@ -71,7 +71,7 @@ SilphCo7Text_51bc8: ; 51bc8 (14:5bc8) ld a, [hli] cp c jr nz, .asm_51bd4 - ld hl, wd73f + ld hl, wCardKeyDoorY xor a ld [hli], a ld [hl], a @@ -110,7 +110,7 @@ SilphCo7Text_51c10: ; 51c10 (14:5c10) SilphCo7ScriptPointers: ; 51c17 (14:5c17) dw SilphCo7Script0 - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle dw SilphCo7Script3 dw SilphCo7Script4 @@ -177,7 +177,7 @@ SilphCo7Script3: ; 51c82 (14:5c82) set 7, [hl] ld hl, SilphCo7Text14 ; $5ec8 ld de, SilphCo7Text_51ecd ; $5ecd - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ld a, SONY2 + $c8 ld [W_CUROPPONENT], a ; wd059 ld a, [W_RIVALSTARTER] ; wd715 diff --git a/scripts/silphco8.asm b/scripts/silphco8.asm index cc508e6183..ebca9b95e3 100755 --- a/scripts/silphco8.asm +++ b/scripts/silphco8.asm @@ -22,14 +22,14 @@ SilphCo8Script_5651a: ; 5651a (15:651a) ld a, $5f ld [wd09f], a ld bc, $403 - predef_jump Func_ee9e + predef_jump ReplaceTileBlock DataTable_5653e: ; 5653e (15:653e) db $04,$03,$FF SilphCo8Script_56541: ; 56541 (15:6541) push hl - ld hl, wd73f + ld hl, wCardKeyDoorY ld a, [hli] ld b, a ld a, [hl] @@ -53,7 +53,7 @@ SilphCo8Script_56541: ; 56541 (15:6541) ld a, [hli] cp c jr nz, .asm_5654d - ld hl, wd73f + ld hl, wCardKeyDoorY xor a ld [hli], a ld [hl], a @@ -73,7 +73,7 @@ SilphCo8Script_5656d: ; 5656d (15:656d) SilphCo8ScriptPointers: ; 56577 (15:6577) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle SilphCo8TextPointers: ; 5657d (15:657d) diff --git a/scripts/silphco9.asm b/scripts/silphco9.asm index 44059b56d2..e8b16927e9 100755 --- a/scripts/silphco9.asm +++ b/scripts/silphco9.asm @@ -23,7 +23,7 @@ SilphCo9Script_5d7d1: ; 5d7d1 (17:57d1) ld a, $5f ld [wd09f], a ld bc, $401 - predef Func_ee9e + predef ReplaceTileBlock pop af .asm_5d7f8 bit 1, a @@ -32,7 +32,7 @@ SilphCo9Script_5d7d1: ; 5d7d1 (17:57d1) ld a, $54 ld [wd09f], a ld bc, $209 - predef Func_ee9e + predef ReplaceTileBlock pop af .asm_5d80b bit 2, a @@ -41,7 +41,7 @@ SilphCo9Script_5d7d1: ; 5d7d1 (17:57d1) ld a, $54 ld [wd09f], a ld bc, $509 - predef Func_ee9e + predef ReplaceTileBlock pop af .asm_5d81e bit 3, a @@ -49,14 +49,14 @@ SilphCo9Script_5d7d1: ; 5d7d1 (17:57d1) ld a, $5f ld [wd09f], a ld bc, $605 - predef_jump Func_ee9e + predef_jump ReplaceTileBlock DataTable_5d82e: ; 5d82e (17:582e) db $04,$01,$02,$09,$05,$09,$06,$05,$FF SilphCo9Script_5d837: ; 5d837 (17:5837) push hl - ld hl, wd73f + ld hl, wCardKeyDoorY ld a, [hli] ld b, a ld a, [hl] @@ -80,7 +80,7 @@ SilphCo9Script_5d837: ; 5d837 (17:5837) ld a, [hli] cp c jr nz, .asm_5d843 - ld hl, wd73f + ld hl, wCardKeyDoorY xor a ld [hli], a ld [hl], a @@ -117,7 +117,7 @@ SilphCo9Script_5d863: ; 5d863 (17:5863) SilphCo9ScriptPointers: ; 5d885 (17:5885) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle SilphCo9TextPointers: ; 5d88b (17:588b) diff --git a/scripts/ssanne10.asm b/scripts/ssanne10.asm index 60eb28f237..8f3ff9a447 100755 --- a/scripts/ssanne10.asm +++ b/scripts/ssanne10.asm @@ -9,7 +9,7 @@ SSAnne10Script: ; 61d55 (18:5d55) SSAnne10ScriptPointers: ; 61d68 (18:5d68) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle SSAnne10TextPointers: ; 61d6e (18:5d6e) diff --git a/scripts/ssanne2.asm b/scripts/ssanne2.asm index 50deba6517..c5943a547a 100755 --- a/scripts/ssanne2.asm +++ b/scripts/ssanne2.asm @@ -186,7 +186,7 @@ SSAnne2Text2: ; 614e6 (18:54e6) set 7, [hl] ld hl, SSAnneRivalDefeatedText ld de, SSAnneRivalWonText - call PreBattleSaveRegisters + call SaveEndBattleTextPointers jp TextScriptEnd SSAnneRivalBeforeBattleText: ; 61500 (18:5500) diff --git a/scripts/ssanne5.asm b/scripts/ssanne5.asm index ea7ff2825f..96b94c523d 100755 --- a/scripts/ssanne5.asm +++ b/scripts/ssanne5.asm @@ -9,7 +9,7 @@ SSAnne5Script: ; 616ae (18:56ae) SSAnne5ScriptPointers: ; 616c1 (18:56c1) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle SSAnne5TextPointers: ; 616c7 (18:56c7) diff --git a/scripts/ssanne8.asm b/scripts/ssanne8.asm index a2abb4bb84..ff7fc57b26 100755 --- a/scripts/ssanne8.asm +++ b/scripts/ssanne8.asm @@ -9,7 +9,7 @@ SSAnne8Script: ; 61976 (18:5976) SSAnne8ScriptPointers: ; 61989 (18:5989) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle SSAnne8TextPointers: ; 6198f (18:598f) diff --git a/scripts/ssanne9.asm b/scripts/ssanne9.asm index f25d553295..db34fcf284 100755 --- a/scripts/ssanne9.asm +++ b/scripts/ssanne9.asm @@ -12,7 +12,7 @@ SSAnne9Script: ; 61b4b (18:5b4b) SSAnne9ScriptPointers: ; 61b64 (18:5b64) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle SSAnne9TextPointers: ; 61b6a (18:5b6a) diff --git a/scripts/unknowndungeon3.asm b/scripts/unknowndungeon3.asm index 2ca624a895..d207891606 100755 --- a/scripts/unknowndungeon3.asm +++ b/scripts/unknowndungeon3.asm @@ -9,7 +9,7 @@ UnknownDungeon3Script: ; 45ef0 (11:5ef0) UnknownDungeon3ScriptPointers: ; 45f03 (11:5f03) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle UnknownDungeon3TextPointers: ; 45f09 (11:5f09) diff --git a/scripts/vermiliondock.asm b/scripts/vermiliondock.asm index 6ed2d23dfc..dca1c66ce5 100755 --- a/scripts/vermiliondock.asm +++ b/scripts/vermiliondock.asm @@ -66,7 +66,7 @@ VermilionDock_1db9b: ; 1db9b (7:5b9b) ld [$ff49], a ld a, $58 ld [wTrainerEngageDistance], a - ld hl, wd526 + ld hl, wMapViewVRAMPointer ld c, [hl] inc hl ld b, [hl] @@ -82,9 +82,9 @@ VermilionDock_1db9b: ; 1db9b (7:5b9b) ld hl, $0002 add hl, bc ld a, l - ld [wd526], a + ld [wMapViewVRAMPointer], a ld a, h - ld [wd527], a + ld [wMapViewVRAMPointer + 1], a push hl push de call ScheduleEastColumnRedraw diff --git a/scripts/vermiliongym.asm b/scripts/vermiliongym.asm index 685bd2cbb7..6178dafb9c 100755 --- a/scripts/vermiliongym.asm +++ b/scripts/vermiliongym.asm @@ -40,7 +40,7 @@ VermilionGymScript_5ca6d: ; 5ca6d (17:4a6d) .asm_5ca7f ld [wd09f], a ld bc, $202 - predef_jump Func_ee9e + predef_jump ReplaceTileBlock VermilionGymScript_5ca8a: ; 5ca8a (17:4a8a) xor a @@ -51,7 +51,7 @@ VermilionGymScript_5ca8a: ; 5ca8a (17:4a8a) VermilionGymScriptPointers: ; 5ca95 (17:4a95) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle dw VermilionGymScript3 @@ -156,7 +156,7 @@ VermilionGymText1: ; 5cb1d (17:4b1d) set 7, [hl] ld hl, ReceivedThunderbadgeText ld de, ReceivedThunderbadgeText - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ldh a, [$8c] ld [wSpriteIndex], a call EngageMapTrainer diff --git a/scripts/victoryroad1.asm b/scripts/victoryroad1.asm index cebd807024..b6d2bf3e3d 100755 --- a/scripts/victoryroad1.asm +++ b/scripts/victoryroad1.asm @@ -17,11 +17,11 @@ VictoryRoad1Script: ; 5da0a (17:5a0a) ld a, $1d ld [wd09f], a ld bc, $604 - predef_jump Func_ee9e + predef_jump ReplaceTileBlock VictoryRoad1ScriptPointers: ; 5da3a (17:5a3a) dw VictoryRoad1Script0 - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle VictoryRoad1Script0: ; 5da40 (17:5a40) diff --git a/scripts/victoryroad2.asm b/scripts/victoryroad2.asm index cf52e3a3e0..4aab61ca5f 100755 --- a/scripts/victoryroad2.asm +++ b/scripts/victoryroad2.asm @@ -36,12 +36,12 @@ VictoryRoad2Script_517c9: ; 517c9 (14:57c9) VictoryRoad2Script_517e2: ; 517e2 (14:57e2) ld [wd09f], a - predef Func_ee9e + predef ReplaceTileBlock ret VictoryRoad2ScriptPointers: ; 517eb (14:57eb) dw VictoryRoad2Script0 - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle VictoryRoad2Script0: ; 517f1 (14:57f1) diff --git a/scripts/victoryroad3.asm b/scripts/victoryroad3.asm index e7d5ed1211..99926498a4 100755 --- a/scripts/victoryroad3.asm +++ b/scripts/victoryroad3.asm @@ -19,11 +19,11 @@ VictoryRoad3Script_44996: ; 44996 (11:4996) ld a, $1d ld [wd09f], a ld bc, $503 - predef_jump Func_ee9e + predef_jump ReplaceTileBlock VictoryRoad3ScriptPointers: ; 449b1 (11:49b1) dw VictoryRoad3Script0 - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle VictoryRoad3Script0: ; 449b7 (11:49b7) diff --git a/scripts/viridianforest.asm b/scripts/viridianforest.asm index 3744fc7886..4ec1c0aad4 100755 --- a/scripts/viridianforest.asm +++ b/scripts/viridianforest.asm @@ -9,7 +9,7 @@ ViridianForestScript: ; 6110d (18:510d) ViridianForestScriptPointers: ; 61120 (18:5120) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle ViridianForestTextPointers: ; 61126 (18:5126) diff --git a/scripts/viridiangym.asm b/scripts/viridiangym.asm index 6b0673d1fa..3aa23b434f 100755 --- a/scripts/viridiangym.asm +++ b/scripts/viridiangym.asm @@ -24,7 +24,7 @@ ViridianGymScript_748d6: ; 748d6 (1d:48d6) ViridianGymScriptPointers: ; 748e1 (1d:48e1) dw ViridianGymScript0 - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle dw ViridianGymScript3 dw ViridianGymScript4 @@ -35,7 +35,7 @@ ViridianGymScript0: ; 748eb (1d:48eb) ld a, [W_XCOORD] ; wd362 ld c, a ld hl, ViridianGymArrowTilePlayerMovement - call Func_3442 + call DecodeArrowMovementRLE cp $ff jp z, CheckFightingMapTrainers call StartSimulatingJoypadStates @@ -305,7 +305,7 @@ ViridianGymText1: ; 74a69 (1d:4a69) set 7, [hl] ld hl, ViridianGymText_74ad3 ld de, ViridianGymText_74ad3 - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ldh a, [$8c] ld [wSpriteIndex], a call EngageMapTrainer diff --git a/wram.asm b/wram.asm index a9bad0817e..15c339d147 100755 --- a/wram.asm +++ b/wram.asm @@ -500,15 +500,18 @@ wOverrideSimulatedJoypadStatesMask:: ; cd3b ds 1 +wChangeBoxSavedMapTextPointer:: ; cd3d + wFlyAnimUsingCoordList:: ; cd3d wPlayerSpinInPlaceAnimFrameDelay:: ; cd3d wPlayerSpinWhileMovingUpOrDownAnimDeltaY:: ; cd3d +wHiddenObjectFunctionArgument:: ; cd3d + wWhichTrade:: ; cd3d ; which entry from TradeMons to select -; ds 1 wTrainerSpriteOffset:: ; cd3d ds 1 @@ -519,6 +522,8 @@ wPlayerSpinInPlaceAnimFrameDelayDelta:: ; cd3e wPlayerSpinWhileMovingUpOrDownAnimMaxY:: ; cd3e +wHiddenObjectFunctionRomBank:: ; cd3e + wTrainerEngageDistance:: ; cd3e ds 1 @@ -528,14 +533,21 @@ wPlayerSpinInPlaceAnimFrameDelayEndValue:: ; cd3f wPlayerSpinWhileMovingUpOrDownAnimFrameDelay:: ; cd3f +wHiddenObjectIndex:: ; cd3f + wTrainerFacingDirection:: ; cd3f wcd3f:: ds 1 wPlayerSpinInPlaceAnimSoundID:: ; cd40 +wHiddenObjectY:: ; cd40 + wTrainerScreenY:: ; cd40 ds 1 + +wHiddenObjectX:: ; cd40 + wTrainerScreenX:: ; cd41 ds 1 @@ -992,6 +1004,8 @@ W_NUMFBTILES:: ; d089 wd08a:: ds 1 +wTownMapSpriteBlinkingCounter:: ; d08b + W_SUBANIMTRANSFORM:: ; d08b ; controls what transformations are applied to the subanimation ; 01: flip horizontally and vertically @@ -1000,18 +1014,15 @@ W_SUBANIMTRANSFORM:: ; d08b ; 04: reverse the subanimation ds 1 -W_PBSTOREDREGISTERH:: ; d08c - ds 1 -W_PBSTOREDREGISTERL:: ; d08d - ds 1 -W_PBSTOREDREGISTERD:: ; d08e - ds 1 -W_PBSTOREDREGISTERE:: ; d08f - ds 1 +wEndBattleWinTextPointer:: ; d08c + ds 2 + +wEndBattleLoseTextPointer:: ; d08e + ds 2 ds 2 -W_PBSTOREDROMBANK:: ; d092 +wEndBattleTextRomBank:: ; d092 ds 1 ds 1 @@ -1026,6 +1037,11 @@ W_SUBANIMSUBENTRYADDR:: ; d096 ds 2 wd09a:: ds 1 + +wTownMapSpriteBlinkingEnabled:: ; d09b +; non-zero when enabled. causes nest locations to blink on and off. +; the town selection cursor will blink regardless of what this value is + wd09b:: ds 1 W_FBDESTADDR:: ; d09c @@ -1044,6 +1060,8 @@ W_FBMODE:: ; d09e ; contain the upper and lower bit of each of the 8 pixels, respectively ds 1 +wNewTileBlockID:: ; d09f + wd09f:: ds 1 wd0a0:: ds 1 @@ -1200,7 +1218,11 @@ wd131:: ds 1 wd132:: ds 1 wd133:: ds 6 wd139:: ds 1 -wd13a:: ds 1 + +wIgnoreInputCounter:: ; d13a +; counts downward each frame +; when it hits 0, bit 5 (ignore input bit) of wd730 is reset + ds 1 wStepCounter:: ; d13b ; counts down once every step @@ -1458,8 +1480,11 @@ W_MAPSPRITEEXTRADATA:: ; d504 wd524:: ds 1 wd525:: ds 1 -wd526:: ds 1 -wd527:: ds 1 + +wMapViewVRAMPointer:: ; d526 +; the address of the upper left corner of the visible portion of the BG tile map in VRAM + ds 2 + wd528:: ds 1 wd529:: ds 1 wd52a:: ds 1 @@ -1816,6 +1841,9 @@ wd72d:: ds 1 wd72e:: ds 2 wd730:: +; bit 0: NPC sprite being moved by script +; bit 5: ignore joypad input +; bit 6: print text with no delay between each letter ; bit 7: set if joypad states are being simulated in the overworld ds 1 @@ -1844,6 +1872,7 @@ wd734:: ds 2 wd736:: ; d736 ; bit 0: check if the player is standing on a door and make him walk down a step if so +; bit 1: the player is currently stepping down from a door ; bit 2: standing on a warp ; bit 6: jumping down a ledge ds 1 @@ -1851,8 +1880,15 @@ wd736:: ; d736 wd737:: ds 4 wd73b:: ds 1 wd73c:: ds 3 -wd73f:: ds 1 -wd740:: ds 3 + +wCardKeyDoorY:: ; d73f + ds 1 + +wCardKeyDoorX:: ; d740 + ds 1 + + ds 2 + wd743:: ds 1 wd744:: ds 3 wd747:: ds 3 @@ -2028,7 +2064,8 @@ W_PLAYTIMESECONDS:: ; da44 W_PLAYTIMEFRAMES:: ; da45 ds 1 -wda46:: ds 1 +wSafariZoneGameOver:: ; da46 + ds 1 W_NUMSAFARIBALLS:: ; da47 ds 1 From 29aff84107a6463a94f0d7d81de8a1603e0d741f Mon Sep 17 00:00:00 2001 From: yenatch Date: Wed, 17 Sep 2014 12:35:51 -0700 Subject: [PATCH 019/100] Enumerate move constants and add unnamed animation constants. --- constants/move_constants.asm | 390 +++++++++++++++++++---------------- macros.asm | 11 + 2 files changed, 219 insertions(+), 182 deletions(-) diff --git a/constants/move_constants.asm b/constants/move_constants.asm index 816bd11500..0899c594ff 100644 --- a/constants/move_constants.asm +++ b/constants/move_constants.asm @@ -1,184 +1,210 @@ -NUM_ATTACKS EQU $A4 +const_value = 1 -POUND EQU $01 -KARATE_CHOP EQU $02 -DOUBLESLAP EQU $03 -COMET_PUNCH EQU $04 -MEGA_PUNCH EQU $05 -PAY_DAY EQU $06 -FIRE_PUNCH EQU $07 -ICE_PUNCH EQU $08 -THUNDERPUNCH EQU $09 -SCRATCH EQU $0A -VICEGRIP EQU $0B -GUILLOTINE EQU $0C -RAZOR_WIND EQU $0D -SWORDS_DANCE EQU $0E -CUT EQU $0F -GUST EQU $10 -WING_ATTACK EQU $11 -WHIRLWIND EQU $12 -FLY EQU $13 -BIND EQU $14 -SLAM EQU $15 -VINE_WHIP EQU $16 -STOMP EQU $17 -DOUBLE_KICK EQU $18 -MEGA_KICK EQU $19 -JUMP_KICK EQU $1A -ROLLING_KICK EQU $1B -SAND_ATTACK EQU $1C -HEADBUTT EQU $1D -HORN_ATTACK EQU $1E -FURY_ATTACK EQU $1F -HORN_DRILL EQU $20 -TACKLE EQU $21 -BODY_SLAM EQU $22 -WRAP EQU $23 -TAKE_DOWN EQU $24 -THRASH EQU $25 -DOUBLE_EDGE EQU $26 -TAIL_WHIP EQU $27 -POISON_STING EQU $28 -TWINEEDLE EQU $29 -PIN_MISSILE EQU $2A -LEER EQU $2B -BITE EQU $2C -GROWL EQU $2D -ROAR EQU $2E -SING EQU $2F -SUPERSONIC EQU $30 -SONICBOOM EQU $31 -DISABLE EQU $32 -ACID EQU $33 -EMBER EQU $34 -FLAMETHROWER EQU $35 -MIST EQU $36 -WATER_GUN EQU $37 -HYDRO_PUMP EQU $38 -SURF EQU $39 -ICE_BEAM EQU $3A -BLIZZARD EQU $3B -PSYBEAM EQU $3C -BUBBLEBEAM EQU $3D -AURORA_BEAM EQU $3E -HYPER_BEAM EQU $3F -PECK EQU $40 -DRILL_PECK EQU $41 -SUBMISSION EQU $42 -LOW_KICK EQU $43 -COUNTER EQU $44 -SEISMIC_TOSS EQU $45 -STRENGTH EQU $46 -ABSORB EQU $47 -MEGA_DRAIN EQU $48 -LEECH_SEED EQU $49 -GROWTH EQU $4A -RAZOR_LEAF EQU $4B -SOLARBEAM EQU $4C -POISONPOWDER EQU $4D -STUN_SPORE EQU $4E -SLEEP_POWDER EQU $4F -PETAL_DANCE EQU $50 -STRING_SHOT EQU $51 -DRAGON_RAGE EQU $52 -FIRE_SPIN EQU $53 -THUNDERSHOCK EQU $54 -THUNDERBOLT EQU $55 -THUNDER_WAVE EQU $56 -THUNDER EQU $57 -ROCK_THROW EQU $58 -EARTHQUAKE EQU $59 -FISSURE EQU $5A -DIG EQU $5B -TOXIC EQU $5C -CONFUSION EQU $5D -PSYCHIC_M EQU $5E -HYPNOSIS EQU $5F -MEDITATE EQU $60 -AGILITY EQU $61 -QUICK_ATTACK EQU $62 -RAGE EQU $63 -TELEPORT EQU $64 -NIGHT_SHADE EQU $65 -MIMIC EQU $66 -SCREECH EQU $67 -DOUBLE_TEAM EQU $68 -RECOVER EQU $69 -HARDEN EQU $6A -MINIMIZE EQU $6B -SMOKESCREEN EQU $6C -CONFUSE_RAY EQU $6D -WITHDRAW EQU $6E -DEFENSE_CURL EQU $6F -BARRIER EQU $70 -LIGHT_SCREEN EQU $71 -HAZE EQU $72 -REFLECT EQU $73 -FOCUS_ENERGY EQU $74 -BIDE EQU $75 -METRONOME EQU $76 -MIRROR_MOVE EQU $77 -SELFDESTRUCT EQU $78 -EGG_BOMB EQU $79 -LICK EQU $7A -SMOG EQU $7B -SLUDGE EQU $7C -BONE_CLUB EQU $7D -FIRE_BLAST EQU $7E -WATERFALL EQU $7F -CLAMP EQU $80 -SWIFT EQU $81 -SKULL_BASH EQU $82 -SPIKE_CANNON EQU $83 -CONSTRICT EQU $84 -AMNESIA EQU $85 -KINESIS EQU $86 -SOFTBOILED EQU $87 -HI_JUMP_KICK EQU $88 -GLARE EQU $89 -DREAM_EATER EQU $8A -POISON_GAS EQU $8B -BARRAGE EQU $8C -LEECH_LIFE EQU $8D -LOVELY_KISS EQU $8E -SKY_ATTACK EQU $8F -TRANSFORM EQU $90 -BUBBLE EQU $91 -DIZZY_PUNCH EQU $92 -SPORE EQU $93 -FLASH EQU $94 -PSYWAVE EQU $95 -SPLASH EQU $96 -ACID_ARMOR EQU $97 -CRABHAMMER EQU $98 -EXPLOSION EQU $99 -FURY_SWIPES EQU $9A -BONEMERANG EQU $9B -REST EQU $9C -ROCK_SLIDE EQU $9D -HYPER_FANG EQU $9E -SHARPEN EQU $9F -CONVERSION EQU $A0 -TRI_ATTACK EQU $A1 -SUPER_FANG EQU $A2 -SLASH EQU $A3 -SUBSTITUTE EQU $A4 -STRUGGLE EQU $A5 + const POUND + const KARATE_CHOP + const DOUBLESLAP + const COMET_PUNCH + const MEGA_PUNCH + const PAY_DAY + const FIRE_PUNCH + const ICE_PUNCH + const THUNDERPUNCH + const SCRATCH + const VICEGRIP + const GUILLOTINE + const RAZOR_WIND + const SWORDS_DANCE + const CUT + const GUST + const WING_ATTACK + const WHIRLWIND + const FLY + const BIND + const SLAM + const VINE_WHIP + const STOMP + const DOUBLE_KICK + const MEGA_KICK + const JUMP_KICK + const ROLLING_KICK + const SAND_ATTACK + const HEADBUTT + const HORN_ATTACK + const FURY_ATTACK + const HORN_DRILL + const TACKLE + const BODY_SLAM + const WRAP + const TAKE_DOWN + const THRASH + const DOUBLE_EDGE + const TAIL_WHIP + const POISON_STING + const TWINEEDLE + const PIN_MISSILE + const LEER + const BITE + const GROWL + const ROAR + const SING + const SUPERSONIC + const SONICBOOM + const DISABLE + const ACID + const EMBER + const FLAMETHROWER + const MIST + const WATER_GUN + const HYDRO_PUMP + const SURF + const ICE_BEAM + const BLIZZARD + const PSYBEAM + const BUBBLEBEAM + const AURORA_BEAM + const HYPER_BEAM + const PECK + const DRILL_PECK + const SUBMISSION + const LOW_KICK + const COUNTER + const SEISMIC_TOSS + const STRENGTH + const ABSORB + const MEGA_DRAIN + const LEECH_SEED + const GROWTH + const RAZOR_LEAF + const SOLARBEAM + const POISONPOWDER + const STUN_SPORE + const SLEEP_POWDER + const PETAL_DANCE + const STRING_SHOT + const DRAGON_RAGE + const FIRE_SPIN + const THUNDERSHOCK + const THUNDERBOLT + const THUNDER_WAVE + const THUNDER + const ROCK_THROW + const EARTHQUAKE + const FISSURE + const DIG + const TOXIC + const CONFUSION + const PSYCHIC_M + const HYPNOSIS + const MEDITATE + const AGILITY + const QUICK_ATTACK + const RAGE + const TELEPORT + const NIGHT_SHADE + const MIMIC + const SCREECH + const DOUBLE_TEAM + const RECOVER + const HARDEN + const MINIMIZE + const SMOKESCREEN + const CONFUSE_RAY + const WITHDRAW + const DEFENSE_CURL + const BARRIER + const LIGHT_SCREEN + const HAZE + const REFLECT + const FOCUS_ENERGY + const BIDE + const METRONOME + const MIRROR_MOVE + const SELFDESTRUCT + const EGG_BOMB + const LICK + const SMOG + const SLUDGE + const BONE_CLUB + const FIRE_BLAST + const WATERFALL + const CLAMP + const SWIFT + const SKULL_BASH + const SPIKE_CANNON + const CONSTRICT + const AMNESIA + const KINESIS + const SOFTBOILED + const HI_JUMP_KICK + const GLARE + const DREAM_EATER + const POISON_GAS + const BARRAGE + const LEECH_LIFE + const LOVELY_KISS + const SKY_ATTACK + const TRANSFORM + const BUBBLE + const DIZZY_PUNCH + const SPORE + const FLASH + const PSYWAVE + const SPLASH + const ACID_ARMOR + const CRABHAMMER + const EXPLOSION + const FURY_SWIPES + const BONEMERANG + const REST + const ROCK_SLIDE + const HYPER_FANG + const SHARPEN + const CONVERSION + const TRI_ATTACK + const SUPER_FANG + const SLASH + const SUBSTITUTE -; these do double duty as animation identifiers -SHOWPIC_ANIM EQU $A6 ; redraw monster pic -STATUS_AFFECTED_ANIM EQU $A7 ; effect when monster receives a status aliment -XSTATITEM_ANIM EQU $AE ; use X Attack/Defense/Speed/Special -BURN_PSN_ANIM EQU $BA ; Plays when a monster is burned or poisoned -SLP_ANIM EQU $BD ; sleeping monster -CONF_ANIM EQU $BF ; confused monster -TOSS_ANIM EQU $C1 ; toss Poké Ball -SHAKE_ANIM EQU $C2 ; shaking Poké Ball when catching monster -POOF_ANIM EQU $C3 ; puff of smoke -BLOCKBALL_ANIM EQU $C4 ; trainer knocks away Poké Ball -GREATTOSS_ANIM EQU $C5 ; toss Great Ball -ULTRATOSS_ANIM EQU $C6 ; toss Ultra Ball or Master Ball -HIDEPIC_ANIM EQU $C8 ; monster disappears -ROCK_ANIM EQU $C9 ; throw rock -BAIT_ANIM EQU $CA ; throw bait +NUM_ATTACKS EQU const_value + -1 + + const STRUGGLE + + ; Moves do double duty as animation identifiers. + + const SHOWPIC_ANIM + const STATUS_AFFECTED_ANIM + const ANIM_A8 + const ANIM_A9 + const ANIM_AA + const ANIM_AB + const ANIM_AC + const ANIM_AD + const XSTATITEM_ANIM ; use X Attack/Defense/Speed/Special + const ANIM_AF + const ANIM_B0 + const ANIM_B1 + const ANIM_B2 + const ANIM_B3 + const ANIM_B4 + const ANIM_B5 + const ANIM_B6 + const ANIM_B7 + const ANIM_B8 + const ANIM_B9 + const BURN_PSN_ANIM ; Plays when a monster is burned or poisoned + const ANIM_BB + const ANIM_BC + const SLP_ANIM ; sleeping monster + const ANIM_BE + const CONF_ANIM ; confused monster + const ANIM_C0 + const TOSS_ANIM ; toss Poké Ball + const SHAKE_ANIM ; shaking Poké Ball when catching monster + const POOF_ANIM ; puff of smoke + const BLOCKBALL_ANIM ; trainer knocks away Poké Ball + const GREATTOSS_ANIM ; toss Great Ball + const ULTRATOSS_ANIM ; toss Ultra Ball or Master Ball + const ANIM_C7 + const HIDEPIC_ANIM ; monster disappears + const ROCK_ANIM ; throw rock + const BAIT_ANIM ; throw bait diff --git a/macros.asm b/macros.asm index 52518d4716..ca2dc82d22 100644 --- a/macros.asm +++ b/macros.asm @@ -14,6 +14,17 @@ dex EQUS "db $5f, $50" ; End a Pokedex entry. percent EQUS "* $ff / 100" +; Constant enumeration is useful for monsters, items, moves, etc. +const_def: MACRO +const_value = 0 +ENDM + +const: MACRO +\1 EQU const_value +const_value = const_value + 1 +ENDM + + homecall: MACRO ld a, [H_LOADEDROMBANK] push af From aa361c3bf7a302dd9a883ff869c06305f3fc0436 Mon Sep 17 00:00:00 2001 From: yenatch Date: Wed, 17 Sep 2014 12:37:47 -0700 Subject: [PATCH 020/100] Use move animation constants instead of static values. This allows new moves and animations to be added without overlap. --- engine/battle/animations.asm | 14 +++++++------- engine/battle/core.asm | 24 ++++++++++++------------ engine/trade.asm | 12 ++++++------ 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm index cc598de4c8..a8ed3865a8 100755 --- a/engine/battle/animations.asm +++ b/engine/battle/animations.asm @@ -525,9 +525,9 @@ Func_78e23: ; 78e23 (1e:4e23) ld [wcc79], a ld b, $e4 ld a, [W_ANIMATIONID] ; W_ANIMATIONID - cp $aa + cp ANIM_AA jr c, .asm_78e3f - cp $ae + cp ANIM_AD + 1 jr nc, .asm_78e3f ld b, $f0 .asm_78e3f @@ -697,13 +697,13 @@ AnimationIdSpecialEffects: ; 78ef5 (1e:4ef5) db ROCK_SLIDE dw DoRockSlideSpecialEffects - db $AA + db ANIM_AA dw Func_79041 - db $AB + db ANIM_AB dw Func_7904c - db $AC + db ANIM_AC dw Func_7907c db TOSS_ANIM @@ -2855,10 +2855,10 @@ TossBallAnimation: ; 79e16 (1e:5e16) .PokeBallAnimations: ; 79e50 (1e:5e50) ; sequence of animations that make up the Poké Ball toss - db POOF_ANIM,HIDEPIC_ANIM,$C2,POOF_ANIM,SHOWPIC_ANIM + db POOF_ANIM,HIDEPIC_ANIM,SHAKE_ANIM,POOF_ANIM,SHOWPIC_ANIM .BlockBall ; 5E55 - ld a,$C1 + ld a,TOSS_ANIM ld [W_ANIMATIONID],a call PlayAnimation ld a,(SFX_08_43 - SFX_Headers_08) / 3 diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 399a8ee758..4baa7a76e9 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -7062,16 +7062,16 @@ PoisonEffect: ; 3f24f (f:724f) dec de ld a, [H_WHOSETURN] ; $fff3 and a - ld b, $c7 + ld b, ANIM_C7 ld hl, W_PLAYERBATTSTATUS3 ; W_PLAYERBATTSTATUS3 ld a, [de] ld de, W_PLAYERTOXICCOUNTER ; wd06c jr nz, .asm_3f2b0 - ld b, $a9 + ld b, ANIM_A9 ld hl, W_ENEMYBATTSTATUS3 ; W_ENEMYBATTSTATUS3 ld de, W_ENEMYTOXICCOUNTER ; wd071 .asm_3f2b0 - cp $5c + cp TOXIC jr nz, .asm_3f2bd set 0, [hl] xor a @@ -7173,14 +7173,14 @@ FreezeBurnParalyzeEffect: ; 3f30c (f:730c) ld a, 1 << PAR ld [wEnemyMonStatus], a call Func_3ed27 ;quarter speed of affected monster - ld a, $a9 + ld a, ANIM_A9 call Func_3fbb9 ;animation jp PrintMayNotAttackText ;print paralysis text .burn ld a, 1 << BRN ld [wEnemyMonStatus], a call Func_3ed64 - ld a, $a9 + ld a, ANIM_A9 call Func_3fbb9 ;animation ld hl, BurnedText jp PrintText @@ -7188,7 +7188,7 @@ FreezeBurnParalyzeEffect: ; 3f30c (f:730c) call Func_3f9cf ;resets bit 5 of the D063/D068 flags ld a, 1 << FRZ ld [wEnemyMonStatus], a - ld a, $a9 + ld a, ANIM_A9 call Func_3fbb9 ;animation ld hl, FrozenText jp PrintText @@ -7726,7 +7726,7 @@ BideEffect: ; 3f6e5 (f:76e5) inc a ld [bc], a ld a, [H_WHOSETURN] - add $ae + add XSTATITEM_ANIM jp Func_3fb96 ThrashPetalDanceEffect: ; 3f717 (f:7717) @@ -7745,7 +7745,7 @@ ThrashPetalDanceEffect: ; 3f717 (f:7717) inc a ld [de], a ld a, [H_WHOSETURN] ; $fff3 - add $b0 + add ANIM_B0 jp Func_3fb96 SwitchAndTeleportEffect: ; 3f739 (f:7739) @@ -7941,11 +7941,11 @@ ChargeEffect: ; 3f88c (f:788c) ld de, W_PLAYERMOVEEFFECT ; wcfd3 ld a, [H_WHOSETURN] ; $fff3 and a - ld b, $ae + ld b, XSTATITEM_ANIM jr z, .asm_3f8a1 ld hl, W_ENEMYBATTSTATUS1 ; W_ENEMYBATTSTATUS1 ld de, W_ENEMYMOVEEFFECT ; W_ENEMYMOVEEFFECT - ld b, $af + ld b, ANIM_AF .asm_3f8a1 set 4, [hl] ld a, [de] @@ -7953,13 +7953,13 @@ ChargeEffect: ; 3f88c (f:788c) cp FLY_EFFECT jr nz, .asm_3f8ad set 6, [hl] ; mon is now invulnerable to typical attacks (fly/dig) - ld b, $64 + ld b, TELEPORT .asm_3f8ad ld a, [de] cp DIG jr nz, .asm_3f8b6 set 6, [hl] ; mon is now invulnerable to typical attacks (fly/dig) - ld b, $c0 + ld b, ANIM_C0 .asm_3f8b6 xor a ld [wcc5b], a diff --git a/engine/trade.asm b/engine/trade.asm index 54abdab6ec..199513afe7 100755 --- a/engine/trade.asm +++ b/engine/trade.asm @@ -203,9 +203,9 @@ Func_41245: ; 41245 (10:5245) and a jr nz, .asm_41273 call Delay50 - ld a, $ad + ld a, ANIM_AD call Func_41676 - ld a, $aa + ld a, ANIM_AA call Func_41676 ld a, [wWhichTrade] ; wWhichTrade call PlayCry @@ -242,9 +242,9 @@ Func_41298: ; 41298 (10:5298) ret Func_412d2: ; 412d2 (10:52d2) - ld a, $ab + ld a, ANIM_AB call Func_41676 - ld c, $a + ld c, 10 call DelayFrames ld a, $e4 ld [rOBP0], a ; $ff48 @@ -295,7 +295,7 @@ UnknownOAM_4132e: ; 4132e (10:532e) db $7E,$40,$7E,$60 Func_41336: ; 41336 (10:5336) - ld a, $ac + ld a, ANIM_AC call Func_41676 call Func_415c8 hlCoord 4, 10 @@ -308,7 +308,7 @@ Func_41336: ; 41336 (10:5336) ld [H_AUTOBGTRANSFERENABLED], a ; $ffba ld a, [wTrainerEngageDistance] call Func_415a4 - ld a, $ad + ld a, ANIM_AD call Func_41676 ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a ; $ffba From a850331d313e0575c48af865eb62dc9c7a3850c6 Mon Sep 17 00:00:00 2001 From: yenatch Date: Wed, 17 Sep 2014 12:57:02 -0700 Subject: [PATCH 021/100] Use a macro to define version constants. --- version.asm | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/version.asm b/version.asm index 6f80aa1cff..7d9fa0366e 100644 --- a/version.asm +++ b/version.asm @@ -1,20 +1,11 @@ -if !def(_RED) -_RED EQU 0 -endc - -if !def(_BLUE) -_BLUE EQU 0 -endc - -if !def(_JAPAN) -_JAPAN EQU 0 -endc - -if !def(_GREEN) -_GREEN EQU 0 -endc - -if !def(_YELLOW) -_YELLOW EQU 0 +check_ver: MACRO +if !def(\1) +\1 EQU 0 endc +ENDM + check_ver _RED + check_ver _BLUE + check_ver _JAPAN + check_ver _GREEN + check_ver _YELLOW From fcfed136c6a0c094314bf75441af4d4b43cfc999 Mon Sep 17 00:00:00 2001 From: yenatch Date: Wed, 17 Sep 2014 13:16:34 -0700 Subject: [PATCH 022/100] Don't define addresses for ROM0 sections in home.asm. Instead, occupy the space reserved for the rom header so there is no collision. --- home.asm | 46 +++++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/home.asm b/home.asm index f83662caa2..112bf265ed 100644 --- a/home.asm +++ b/home.asm @@ -1,35 +1,36 @@ + ; The rst vectors are unused. -SECTION "rst00", ROM0[$00] +SECTION "rst 00", ROM0 [$00] rst $38 -SECTION "rst08", ROM0[$08] +SECTION "rst 08", ROM0 [$08] rst $38 -SECTION "rst10", ROM0[$10] +SECTION "rst 10", ROM0 [$10] rst $38 -SECTION "rst18", ROM0[$18] +SECTION "rst 18", ROM0 [$18] rst $38 -SECTION "rst20", ROM0[$20] +SECTION "rst 20", ROM0 [$20] rst $38 -SECTION "rst28", ROM0[$28] +SECTION "rst 28", ROM0 [$28] rst $38 -SECTION "rst30", ROM0[$30] +SECTION "rst 30", ROM0 [$30] rst $38 -SECTION "rst38", ROM0[$38] +SECTION "rst 38", ROM0 [$38] rst $38 -; interrupts -SECTION "vblank", ROM0[$40] +; Hardware interrupts +SECTION "vblank", ROM0 [$40] jp VBlank -SECTION "lcdc", ROM0[$48] +SECTION "hblank", ROM0 [$48] rst $38 -SECTION "timer", ROM0[$50] +SECTION "timer", ROM0 [$50] jp Timer -SECTION "serial", ROM0[$58] +SECTION "serial", ROM0 [$58] jp Serial -SECTION "joypad", ROM0[$60] +SECTION "joypad", ROM0 [$60] reti -SECTION "bank0",ROM0[$61] +SECTION "Home", ROM0 DisableLCD:: xor a @@ -82,12 +83,23 @@ HideSprites:: INCLUDE "home/copy.asm" -SECTION "Entry", ROM0[$100] + +SECTION "Entry", ROM0 [$100] + nop jp Start -SECTION "Start", ROM0[$150] +SECTION "Header", ROM0 [$104] + + ; The header is generated by rgbfix. + ; The space here is allocated to prevent code from being overwritten. + + ds $150 - $104 + + + +SECTION "Main", ROM0 Start:: cp GBC From 3de9d14d3e1ed14b880c0064a6141d9d9ca9b828 Mon Sep 17 00:00:00 2001 From: yenatch Date: Wed, 17 Sep 2014 21:02:59 -0700 Subject: [PATCH 023/100] Recomment misc functions in home.asm. --- constants/misc_constants.asm | 22 +- home.asm | 861 ++++++++++++++++++----------------- 2 files changed, 447 insertions(+), 436 deletions(-) diff --git a/constants/misc_constants.asm b/constants/misc_constants.asm index 29f15035d5..620671712e 100644 --- a/constants/misc_constants.asm +++ b/constants/misc_constants.asm @@ -1,12 +1,3 @@ -A_BUTTON EQU %00000001 -B_BUTTON EQU %00000010 -SELECT EQU %00000100 -START EQU %00001000 -D_RIGHT EQU %00010000 -D_LEFT EQU %00100000 -D_UP EQU %01000000 -D_DOWN EQU %10000000 - MAX_LEVEL EQU 100 NUM_MOVES EQU 4 @@ -18,3 +9,16 @@ NUM_BOXES EQU 12 HOF_MON EQU $10 HOF_TEAM EQU PARTY_LENGTH * HOF_MON NUM_HOF_TEAMS EQU 50 + + +A_BUTTON EQU %00000001 +B_BUTTON EQU %00000010 +SELECT EQU %00000100 +START EQU %00001000 +D_RIGHT EQU %00010000 +D_LEFT EQU %00100000 +D_UP EQU %01000000 +D_DOWN EQU %10000000 + +SCREEN_WIDTH EQU 20 +SCREEN_HEIGHT EQU 18 diff --git a/home.asm b/home.asm index 112bf265ed..7b5c8c6bb2 100644 --- a/home.asm +++ b/home.asm @@ -169,63 +169,76 @@ LoadDestinationWarpPosition:: ; 1313 (0:1313) ld [$2000],a ret -; INPUT: -; c: if nonzero, show at least a sliver of health -; d = number of HP bar sections (normally 6) -; e = health (in eighths of bar sections) (normally out of 48) + DrawHPBar:: ; 1336 (0:1336) +; Draw an HP bar d tiles long, and fill it to e pixels. +; If c is nonzero, show at least a sliver regardless. +; The right end of the bar changes with [wListMenuID]. + push hl push de push bc - ld a,$71 ; left of HP bar tile 1 - ld [hli],a - ld a,$62 ; left of HP bar tile 2 - ld [hli],a + + ; Left + ld a, $71 ; "HP:" + ld [hli], a + ld a, $62 + ld [hli], a + push hl - ld a,$63 ; empty bar section tile -.drawEmptyBarLoop + + ; Middle + ld a, $63 ; empty +.draw ld [hli],a dec d - jr nz,.drawEmptyBarLoop + jr nz, .draw + + ; Right ld a,[wListMenuID] - dec a ; what should the right of HP bar tile be? - ld a,$6d ; right of HP bar tile, in status screen and battles - jr z,.writeTile - dec a ; right of HP bar tile, in pokemon menu -.writeTile + dec a + ld a, $6d ; status screen and battle + jr z, .ok + dec a ; pokemon menu +.ok ld [hl],a + pop hl - ld a,e - and a ; is there enough health to show up on the HP bar? - jr nz,.loop ; if so, draw the HP bar - ld a,c - and a ; should a sliver of health be shown no matter what? - jr z,.done - ld e,1 ; if so, fill one eighth of a bar section -; loop to draw every full bar section -.loop - ld a,e - sub a,8 - jr c,.drawPartialBarSection - ld e,a - ld a,$6b ; filled bar section tile - ld [hli],a - ld a,e + + ld a, e and a - jr z,.done - jr .loop -; draws a partial bar section at the end (if necessary) -; there are 7 possible partial bar sections from 1/8 to 7/8 full -.drawPartialBarSection - ld a,$63 ; empty bar section tile - add e ; add e to get the appropriate partial bar section tile - ld [hl],a ; write the tile + jr nz, .fill + + ; If c iz nonzero, draw a pixel anyway. + ld a, c + and a + jr z, .done + ld e, 1 + +.fill + ld a, e + sub 8 + jr c, .partial + ld e, a + ld a, $6b ; full + ld [hli], a + ld a, e + and a + jr z, .done + jr .fill + +.partial + ; Fill remaining pixels at the end if necessary. + ld a, $63 ; empty + add e + ld [hl], a .done pop bc pop de pop hl ret + ; loads pokemon data from one of multiple sources to wcf98 ; loads base stats to W_MONHDEXNUM ; INPUT: @@ -240,22 +253,22 @@ DrawHPBar:: ; 1336 (0:1336) ; wcf98 = base address of pokemon data ; W_MONHDEXNUM = base address of base stats LoadMonData:: ; 1372 (0:1372) - ld hl,LoadMonData_ - ld b,BANK(LoadMonData_) + ld hl, LoadMonData_ + ld b, BANK(LoadMonData_) jp Bankswitch ; writes c to wd0dc+b Func_137a:: ; 137a (0:137a) ld hl, wd0dc ld e, b - ld d, $0 + ld d, 0 add hl, de ld a, c ld [hl], a ret LoadFlippedFrontSpriteByMonIndex:: ; 1384 (0:1384) - ld a, $1 + ld a, 1 ld [W_SPRITEFLIPPED], a LoadFrontSpriteByMonIndex:: ; 1389 (0:1389) @@ -271,9 +284,9 @@ LoadFrontSpriteByMonIndex:: ; 1389 (0:1389) ld [hl], b and a pop hl - jr z, .invalidDexNumber ; dex #0 invalid + jr z, .invalidDexNumber ; dex #0 invalid cp NUM_POKEMON + 1 - jr c, .validDexNumber ; dex >#151 invalid + jr c, .validDexNumber ; dex >#151 invalid .invalidDexNumber ld a, RHYDON ; $1 ld [wcf91], a @@ -298,41 +311,44 @@ LoadFrontSpriteByMonIndex:: ; 1389 (0:1389) ld [$2000], a ret -; plays the cry of a pokemon -; INPUT: -; a = pokemon ID + PlayCry:: ; 13d0 (0:13d0) +; Play monster a's cry. call GetCryData - call PlaySound ; play cry - jp WaitForSoundToFinish ; wait for sound to be done playing + call PlaySound + jp WaitForSoundToFinish -; gets a pokemon's cry data -; INPUT: -; a = pokemon ID GetCryData:: ; 13d9 (0:13d9) +; Load cry data for monster a. dec a - ld c,a - ld b,0 - ld hl,CryData - add hl,bc - add hl,bc - add hl,bc - ld a,Bank(CryData) + ld c, a + ld b, 0 + ld hl, CryData + add hl, bc + add hl, bc + add hl, bc + + ld a, Bank(CryData) call BankswitchHome - ld a,[hli] - ld b,a - ld a,[hli] - ld [wc0f1],a - ld a,[hl] - ld [wc0f2],a + ld a, [hli] + ld b, a ; cry id + ld a, [hli] + ld [wc0f1], a + ld a, [hl] + ld [wc0f2], a call BankswitchBack - ld a,b ; a = cryID - ld c,$14 ; base sound ID for pokemon cries - rlca - add b ; a = cryID * 3 - add c ; a = $14 + cryID * 3 + + ; Cry headers have 3 channels, + ; and start from index $14, + ; so add 3 times the cry id. + ld a, b + ld c, $14 + rlca ; * 2 + add b + add c ret + DisplayPartyMenu:: ; 13fc (0:13fc) ld a,[$ffd7] push af @@ -354,42 +370,42 @@ GoBackToPartyMenu:: ; 1411 (0:1411) jp HandlePartyMenuInput PartyMenuInit:: ; 1420 (0:1420) - ld a,$01 + ld a, 1 ; hardcoded bank call BankswitchHome call LoadHpBarAndStatusTilePatterns - ld hl,wd730 - set 6,[hl] ; turn off letter printing delay + ld hl, wd730 + set 6, [hl] ; turn off letter printing delay xor a - ld [wcc49],a - ld [wcc37],a - ld hl,wTopMenuItemY + ld [wcc49], a + ld [wcc37], a + ld hl, wTopMenuItemY inc a - ld [hli],a ; top menu item Y + ld [hli], a ; top menu item Y xor a - ld [hli],a ; top menu item X - ld a,[wcc2b] + ld [hli], a ; top menu item X + ld a, [wcc2b] push af - ld [hli],a ; current menu item ID + ld [hli], a ; current menu item ID inc hl - ld a,[wPartyCount] + ld a, [wPartyCount] and a ; are there more than 0 pokemon in the party? - jr z,.storeMaxMenuItemID + jr z, .storeMaxMenuItemID dec a ; if party is not empty, the max menu item ID is ([wPartyCount] - 1) ; otherwise, it is 0 .storeMaxMenuItemID - ld [hli],a ; max menu item ID - ld a,[wd11f] + ld [hli], a ; max menu item ID + ld a, [wd11f] and a - ld a,%00000011 ; A button and B button - jr z,.next + ld a, A_BUTTON + B_BUTTON + jr z, .next xor a - ld [wd11f],a + ld [wd11f], a inc a .next - ld [hli],a ; menu watched keys + ld [hli], a ; menu watched keys pop af - ld [hl],a ; old menu item ID + ld [hl], a ; old menu item ID ret HandlePartyMenuInput:: ; 145a (0:145a) @@ -672,7 +688,7 @@ PrintBCDNumber:: ; 15cd (0:15cd) ret PrintBCDDigit:: ; 1604 (0:1604) - and a,%00001111 + and $f and a jr z,.zeroDigit .nonzeroDigit @@ -1403,7 +1419,7 @@ DisplayListMenuID:: ; 2be6 (0:2be6) ld [wTopMenuItemY],a ld a,5 ld [wTopMenuItemX],a - ld a,%00000111 ; A button, B button, Select button + ld a,A_BUTTON | B_BUTTON | SELECT ld [wMenuWatchedKeys],a ld c,10 call DelayFrames @@ -1827,7 +1843,7 @@ PrintListMenuEntries:: ; 2e5a (0:2e5a) ld bc,20 + 8 ; 1 row down and 8 columns right add hl,bc ld a,"×" - ldi [hl],a + ld [hli],a ld a,[wd11e] push af ld a,[de] @@ -2653,8 +2669,8 @@ FuncTX_ItemStoragePC:: ; 3460 (0:3460) FuncTX_BillsPC:: ; 346a (0:346a) call SaveScreenTilesToBuffer2 - ld b, BANK(Func_214c2) - ld hl, Func_214c2 + ld b, BANK(BillsPC_) + ld hl, BillsPC_ jr bankswitchAndContinue FuncTX_SlotMachine:: ; 3474 (0:3474) @@ -3064,65 +3080,63 @@ Func_366b:: ; 366b (0:366b) pop hl ret -; copies the tile patterns for letters and numbers into VRAM -LoadFontTilePatterns:: ; 3680 (0:3680) - ld a,[rLCDC] - bit 7,a ; is the LCD enabled? - jr nz,.lcdEnabled -.lcdDisabled - ld hl,FontGraphics - ld de,vFont - ld bc,$400 - ld a,BANK(FontGraphics) + +LoadFontTilePatterns:: + ld a, [rLCDC] + bit 7, a ; is the LCD enabled? + jr nz, .on +.off + ld hl, FontGraphics + ld de, vFont + ld bc, $400 + ld a, BANK(FontGraphics) jp FarCopyDataDouble ; if LCD is off, transfer all at once -.lcdEnabled - ld de,FontGraphics - ld hl,vFont - ld bc,(BANK(FontGraphics) << 8 | $80) +.on + ld de, FontGraphics + ld hl, vFont + ld bc, BANK(FontGraphics) << 8 | $80 jp CopyVideoDataDouble ; if LCD is on, transfer during V-blank -; copies the text box tile patterns into VRAM -LoadTextBoxTilePatterns:: ; 36a0 (0:36a0) - ld a,[rLCDC] - bit 7,a ; is the LCD enabled? - jr nz,.lcdEnabled -.lcdDisabled - ld hl,TextBoxGraphics - ld de,vChars2 + $600 - ld bc,$200 - ld a,BANK(TextBoxGraphics) +LoadTextBoxTilePatterns:: + ld a, [rLCDC] + bit 7, a ; is the LCD enabled? + jr nz, .on +.off + ld hl, TextBoxGraphics + ld de, vChars2 + $600 + ld bc, $200 + ld a, BANK(TextBoxGraphics) jp FarCopyData2 ; if LCD is off, transfer all at once -.lcdEnabled - ld de,TextBoxGraphics - ld hl,vChars2 + $600 - ld bc,(BANK(TextBoxGraphics) << 8 | $20) +.on + ld de, TextBoxGraphics + ld hl, vChars2 + $600 + ld bc, BANK(TextBoxGraphics) << 8 | $20 jp CopyVideoData ; if LCD is on, transfer during V-blank -; copies HP bar and status display tile patterns into VRAM -LoadHpBarAndStatusTilePatterns:: ; 36c0 (0:36c0) - ld a,[rLCDC] - bit 7,a ; is the LCD enabled? - jr nz,.lcdEnabled -.lcdDisabled - ld hl,HpBarAndStatusGraphics - ld de,vChars2 + $620 - ld bc,$1e0 - ld a,BANK(HpBarAndStatusGraphics) +LoadHpBarAndStatusTilePatterns:: + ld a, [rLCDC] + bit 7, a ; is the LCD enabled? + jr nz, .on +.off + ld hl, HpBarAndStatusGraphics + ld de, vChars2 + $620 + ld bc, $1e0 + ld a, BANK(HpBarAndStatusGraphics) jp FarCopyData2 ; if LCD is off, transfer all at once -.lcdEnabled - ld de,HpBarAndStatusGraphics - ld hl,vChars2 + $620 - ld bc,(BANK(HpBarAndStatusGraphics) << 8 | $1e) +.on + ld de, HpBarAndStatusGraphics + ld hl, vChars2 + $620 + ld bc, BANK(HpBarAndStatusGraphics) << 8 | $1e jp CopyVideoData ; if LCD is on, transfer during V-blank -;Fills memory range with the specified byte. -;input registers a = fill_byte, bc = length, hl = address -FillMemory:: ; 36e0 (0:36e0) + +FillMemory:: +; Fill bc bytes at hl with a. push de ld d, a .loop ld a, d - ldi [hl], a + ld [hli], a dec bc ld a, b or c @@ -3130,15 +3144,16 @@ FillMemory:: ; 36e0 (0:36e0) pop de ret -; loads sprite that de points to -; bank of sprite is given in a + UncompressSpriteFromDE:: ; 36eb (0:36eb) +; Decompress pic at a:de. ld hl, W_SPRITEINPUTPTR ld [hl], e inc hl ld [hl], d jp UncompressSpriteData + SaveScreenTilesToBuffer2:: ; 36f4 (0:36f4) ld hl, wTileMap ld de, wTileMapBackup2 @@ -3229,8 +3244,12 @@ GetName:: ; 376b (0:376b) ; returns pointer to name in de ld a,[wd0b5] ld [wd11e],a + + ; TM names are separate from item names. + ; BUG: This applies to all names instead of just items. cp HM_01 - jp nc,GetMachineName + jp nc, GetMachineName + ld a,[H_LOADEDROMBANK] push af push hl @@ -3400,7 +3419,7 @@ JoypadLowSensitivity:: ; 3831 (0:3831) .delayOver ; if [hJoy6] = 0 and A or B is pressed, report no buttons as pressed ld a,[hJoyHeld] - and a,%00000011 ; A and B buttons + and A_BUTTON | B_BUTTON jr z,.setShortDelay ld a,[hJoy6] ; flag and a @@ -3513,7 +3532,7 @@ PrintLetterDelay:: ; 38d3 (0:38d3) bit 0,a jr z,.waitOneFrame ld a,[W_OPTIONS] - and a,$0f + and $f ld [H_FRAMECOUNTER],a jr .checkButtons .waitOneFrame @@ -3966,7 +3985,7 @@ HandleMenuInputPokemonSelection:: ; 3ac2 (0:3ac2) jp z,.loop1 .checkIfAButtonOrBButtonPressed ld a,[hJoy5] - and a,%00000011 ; pressed A button or B button? + and A_BUTTON | B_BUTTON jr z,.skipPlayingSound .AButtonOrBButtonPressed push hl @@ -3996,14 +4015,14 @@ PlaceMenuCursor:: ; 3b7c (0:3b7c) and a ; is the y coordinate 0? jr z,.adjustForXCoord ld hl,wTileMap - ld bc,20 ; screen width + ld bc,SCREEN_WIDTH .topMenuItemLoop add hl,bc dec a jr nz,.topMenuItemLoop .adjustForXCoord ld a,[wTopMenuItemX] - ld b,$00 + ld b,0 ld c,a add hl,bc push hl @@ -4156,7 +4175,7 @@ AutoTextBoxDrawingCommon:: ; 3c41 (0:3c41) ret PrintText:: ; 3c49 (0:3c49) -; given a pointer in hl, print the text there +; Print text hl at (1, 14). push hl ld a,1 ld [wd125],a @@ -4168,256 +4187,244 @@ Func_3c59:: ; 3c59 (0:3c59) bcCoord 1, 14 jp TextCommandProcessor -; converts a big-endian binary number into decimal and prints it -; INPUT: -; b = flags and number of bytes -; bit 7: if set, print leading zeroes -; if unset, do not print leading zeroes -; bit 6: if set, left-align the string (do not pad empty digits with spaces) -; if unset, right-align the string -; bits 4-5: unused -; bits 0-3: number of bytes (only 1 - 3 bytes supported) -; c = number of decimal digits -; de = address of the number (big-endian) -PrintNumber:: ; 3c5f (0:3c5f) + +PrintNumber:: ; 3c5f +; Print the c-digit, b-byte value at de. +; Allows 2 to 7 digits. For 1-digit numbers, add +; the value to char "0" instead of calling PrintNumber. +; Flags LEADING_ZEROES and LEFT_ALIGN can be given +; in bits 7 and 6 of b respectively. +LEADING_ZEROES EQU 7 +LEFT_ALIGN EQU 6 + push bc xor a - ld [H_PASTLEADINGZEROES],a - ld [H_NUMTOPRINT],a - ld [H_NUMTOPRINT + 1],a - ld a,b - and a,%00001111 - cp a,1 - jr z,.oneByte - cp a,2 - jr z,.twoBytes -.threeBytes - ld a,[de] - ld [H_NUMTOPRINT],a + ld [H_PASTLEADINGZEROES], a + ld [H_NUMTOPRINT], a + ld [H_NUMTOPRINT + 1], a + ld a, b + and $f + cp 1 + jr z, .byte + cp 2 + jr z, .word +.long + ld a, [de] + ld [H_NUMTOPRINT], a inc de - ld a,[de] - ld [H_NUMTOPRINT + 1],a + ld a, [de] + ld [H_NUMTOPRINT + 1], a inc de - ld a,[de] - ld [H_NUMTOPRINT + 2],a - jr .checkNumDigits -.twoBytes - ld a,[de] - ld [H_NUMTOPRINT + 1],a + ld a, [de] + ld [H_NUMTOPRINT + 2], a + jr .start + +.word + ld a, [de] + ld [H_NUMTOPRINT + 1], a inc de - ld a,[de] - ld [H_NUMTOPRINT + 2],a - jr .checkNumDigits -.oneByte - ld a,[de] - ld [H_NUMTOPRINT + 2],a -.checkNumDigits + ld a, [de] + ld [H_NUMTOPRINT + 2], a + jr .start + +.byte + ld a, [de] + ld [H_NUMTOPRINT + 2], a + +.start push de - ld d,b - ld a,c - ld b,a - xor a - ld c,a - ld a,b ; a = number of decimal digits - cp a,2 - jr z,.tensPlace - cp a,3 - jr z,.hundredsPlace - cp a,4 - jr z,.thousandsPlace - cp a,5 - jr z,.tenThousandsPlace - cp a,6 - jr z,.hundredThousandsPlace -.millionsPlace - ld a,1000000 >> 16 - ld [H_POWEROFTEN],a - ld a,(1000000 >> 8) & $FF - ld [H_POWEROFTEN + 1],a - ld a,1000000 & $FF - ld [H_POWEROFTEN + 2],a - call PrintNumber_PrintDigit - call PrintNumber_AdvancePointer -.hundredThousandsPlace - ld a,100000 >> 16 - ld [H_POWEROFTEN],a - ld a,(100000 >> 8) & $FF - ld [H_POWEROFTEN + 1],a - ld a,100000 & $FF - ld [H_POWEROFTEN + 2],a - call PrintNumber_PrintDigit - call PrintNumber_AdvancePointer -.tenThousandsPlace - xor a - ld [H_POWEROFTEN],a - ld a,10000 >> 8 - ld [H_POWEROFTEN + 1],a - ld a,10000 & $FF - ld [H_POWEROFTEN + 2],a - call PrintNumber_PrintDigit - call PrintNumber_AdvancePointer -.thousandsPlace - xor a - ld [H_POWEROFTEN],a - ld a,1000 >> 8 - ld [H_POWEROFTEN + 1],a - ld a,1000 & $FF - ld [H_POWEROFTEN + 2],a - call PrintNumber_PrintDigit - call PrintNumber_AdvancePointer -.hundredsPlace - xor a - ld [H_POWEROFTEN],a + + ld d, b + ld a, c + ld b, a xor a - ld [H_POWEROFTEN + 1],a - ld a,100 - ld [H_POWEROFTEN + 2],a - call PrintNumber_PrintDigit - call PrintNumber_AdvancePointer -.tensPlace - ld c,00 - ld a,[H_NUMTOPRINT + 2] -.loop - cp a,10 - jr c,.underflow - sub a,10 + ld c, a + ld a, b + + cp 2 + jr z, .tens + cp 3 + jr z, .hundreds + cp 4 + jr z, .thousands + cp 5 + jr z, .ten_thousands + cp 6 + jr z, .hundred_thousands + +print_digit: macro + +if (\1) / $10000 + ld a, \1 / $10000 % $100 +else xor a +endc + ld [H_POWEROFTEN + 0], a + +if (\1) / $100 + ld a, \1 / $100 % $100 +else xor a +endc + ld [H_POWEROFTEN + 1], a + + ld a, \1 / $1 % $100 + ld [H_POWEROFTEN + 2], a + + call .PrintDigit + call .NextDigit +endm + +.millions print_digit 1000000 +.hundred_thousands print_digit 100000 +.ten_thousands print_digit 10000 +.thousands print_digit 1000 +.hundreds print_digit 100 + +.tens + ld c, 0 + ld a, [H_NUMTOPRINT + 2] +.mod + cp 10 + jr c, .ok + sub 10 inc c - jr .loop -.underflow - ld b,a - ld a,[H_PASTLEADINGZEROES] + jr .mod +.ok + + ld b, a + ld a, [H_PASTLEADINGZEROES] or c - ld [H_PASTLEADINGZEROES],a - jr nz,.pastLeadingZeroes - call PrintNumber_PrintLeadingZero - jr .advancePointer -.pastLeadingZeroes - ld a,"0" + ld [H_PASTLEADINGZEROES], a + jr nz, .past + call .PrintLeadingZero + jr .next +.past + ld a, "0" add c - ld [hl],a -.advancePointer - call PrintNumber_AdvancePointer -.onesPlace - ld a,"0" + ld [hl], a +.next + + call .NextDigit +.ones + ld a, "0" add b - ld [hli],a + ld [hli], a pop de dec de pop bc ret -; prints a decimal digit -; This works by repeatedely subtracting a power of ten until the number becomes negative. -; The number of subtractions it took in order to make the number negative is the digit for the current number place. -; The last value that the number had before becoming negative is kept as the new value of the number. -; A more succinct description is that the number is divided by a power of ten -; and the quotient becomes the digit while the remainder is stored as the new value of the number. -PrintNumber_PrintDigit:: ; 3d25 (0:3d25) - ld c,0 ; counts number of loop iterations to determine the decimal digit +.PrintDigit: +; Divide by the current decimal place. +; Print the quotient, and keep the modulus. + ld c, 0 .loop - ld a,[H_POWEROFTEN] - ld b,a - ld a,[H_NUMTOPRINT] - ld [H_SAVEDNUMTOPRINT],a + ld a, [H_POWEROFTEN] + ld b, a + ld a, [H_NUMTOPRINT] + ld [H_SAVEDNUMTOPRINT], a cp b - jr c,.underflow0 + jr c, .underflow0 sub b - ld [H_NUMTOPRINT],a - ld a,[H_POWEROFTEN + 1] - ld b,a - ld a,[H_NUMTOPRINT + 1] - ld [H_SAVEDNUMTOPRINT + 1],a + ld [H_NUMTOPRINT], a + ld a, [H_POWEROFTEN + 1] + ld b, a + ld a, [H_NUMTOPRINT + 1] + ld [H_SAVEDNUMTOPRINT + 1], a cp b - jr nc,.noBorrowForByte1 -.byte1BorrowFromByte0 - ld a,[H_NUMTOPRINT] - or a,0 - jr z,.underflow1 + jr nc, .noborrow1 + + ld a, [H_NUMTOPRINT] + or 0 + jr z, .underflow1 dec a - ld [H_NUMTOPRINT],a - ld a,[H_NUMTOPRINT + 1] -.noBorrowForByte1 + ld [H_NUMTOPRINT], a + ld a, [H_NUMTOPRINT + 1] +.noborrow1 + sub b - ld [H_NUMTOPRINT + 1],a - ld a,[H_POWEROFTEN + 2] - ld b,a - ld a,[H_NUMTOPRINT + 2] - ld [H_SAVEDNUMTOPRINT + 2],a + ld [H_NUMTOPRINT + 1], a + ld a, [H_POWEROFTEN + 2] + ld b, a + ld a, [H_NUMTOPRINT + 2] + ld [H_SAVEDNUMTOPRINT + 2], a cp b - jr nc,.noBorrowForByte2 -.byte2BorrowFromByte1 - ld a,[H_NUMTOPRINT + 1] + jr nc, .noborrow2 + + ld a, [H_NUMTOPRINT + 1] and a - jr nz,.finishByte2BorrowFromByte1 -.byte2BorrowFromByte0 - ld a,[H_NUMTOPRINT] + jr nz, .borrowed + + ld a, [H_NUMTOPRINT] and a - jr z,.underflow2 + jr z, .underflow2 dec a - ld [H_NUMTOPRINT],a + ld [H_NUMTOPRINT], a xor a -.finishByte2BorrowFromByte1 +.borrowed + dec a - ld [H_NUMTOPRINT + 1],a - ld a,[H_NUMTOPRINT + 2] -.noBorrowForByte2 + ld [H_NUMTOPRINT + 1], a + ld a, [H_NUMTOPRINT + 2] +.noborrow2 sub b - ld [H_NUMTOPRINT + 2],a + ld [H_NUMTOPRINT + 2], a inc c jr .loop + .underflow2 - ld a,[H_SAVEDNUMTOPRINT + 1] - ld [H_NUMTOPRINT + 1],a + ld a, [H_SAVEDNUMTOPRINT + 1] + ld [H_NUMTOPRINT + 1], a .underflow1 - ld a,[H_SAVEDNUMTOPRINT] - ld [H_NUMTOPRINT],a + ld a, [H_SAVEDNUMTOPRINT] + ld [H_NUMTOPRINT], a .underflow0 - ld a,[H_PASTLEADINGZEROES] + ld a, [H_PASTLEADINGZEROES] or c - jr z,PrintNumber_PrintLeadingZero - ld a,"0" + jr z, .PrintLeadingZero + + ld a, "0" add c - ld [hl],a - ld [H_PASTLEADINGZEROES],a + ld [hl], a + ld [H_PASTLEADINGZEROES], a ret -; prints a leading zero unless they are turned off in the flags -PrintNumber_PrintLeadingZero:: ; 3d83 (0:3d83) - bit 7,d ; print leading zeroes? +.PrintLeadingZero: + bit LEADING_ZEROES, d ret z - ld [hl],"0" - ret - -; increments the pointer unless leading zeroes are not being printed, -; the number is left-aligned, and no nonzero digits have been printed yet -PrintNumber_AdvancePointer:: ; 3d89 (0:3d89) - bit 7,d ; print leading zeroes? - jr nz,.incrementPointer - bit 6,d ; left alignment or right alignment? - jr z,.incrementPointer - ld a,[H_PASTLEADINGZEROES] + ld [hl], "0" + ret + +.NextDigit: +; Increment unless the number is left-aligned, +; leading zeroes are not printed, and no digits +; have been printed yet. + bit LEADING_ZEROES, d + jr nz, .inc + bit LEFT_ALIGN, d + jr z, .inc + ld a, [H_PASTLEADINGZEROES] and a ret z -.incrementPointer +.inc inc hl ret -; calls a function from a table of function pointers -; INPUT: -; a = index within table -; hl = address of function pointer table -CallFunctionInTable:: ; 3d97 (0:3d97) + +CallFunctionInTable:: +JumpTable:: +; Call function a in jumptable hl. +; de is not preserved. push hl push de push bc add a - ld d,0 - ld e,a - add hl,de - ld a,[hli] - ld h,[hl] - ld l,a - ld de,.returnAddress + ld d, 0 + ld e, a + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + ld de, .returnAddress push de jp [hl] .returnAddress @@ -4570,7 +4577,7 @@ Random:: push de push bc callba Random_ - ld a,[hRandomAdd] + ld a, [hRandomAdd] pop bc pop de pop hl @@ -4623,95 +4630,95 @@ Func_3eb5:: ; 3eb5 (0:3eb5) PrintPredefTextID:: ; 3ef5 (0:3ef5) ld [H_DOWNARROWBLINKCNT2], a ; $ff8c - ld hl, PointerTable_3f22 + ld hl, TextPredefs call Func_3f0f ld hl, wcf11 set 0, [hl] call DisplayTextID Func_3f05:: ; 3f05 (0:3f05) - ld hl, W_MAPTEXTPTR ; wd36c + ld hl, W_MAPTEXTPTR ld a, [$ffec] ld [hli], a - ld a, [$ffed] + ld a, [$ffec + 1] ld [hl], a ret Func_3f0f:: ; 3f0f (0:3f0f) - ld a, [W_MAPTEXTPTR] ; wd36c + ld a, [W_MAPTEXTPTR] ld [$ffec], a ld a, [W_MAPTEXTPTR + 1] - ld [$ffed], a + ld [$ffec + 1], a ld a, l - ld [W_MAPTEXTPTR], a ; wd36c + ld [W_MAPTEXTPTR], a ld a, h ld [W_MAPTEXTPTR + 1], a ret -PointerTable_3f22:: ; 3f22 (0:3f22) - dw CardKeySuccessText ; id = 01 - dw CardKeyFailText ; id = 02 - dw RedBedroomPC ; id = 03 - dw RedBedroomSNESText ; id = 04 - dw PushStartText ; id = 05 - dw SaveOptionText ; id = 06 - dw StrengthsAndWeaknessesText ; id = 07 - dw OakLabEmailText ; id = 08 - dw AerodactylFossilText ; id = 09 - dw Route15UpstairsBinocularsText ; id = 0A - dw KabutopsFossilText ; id = 0B - dw GymStatueText1 ; id = 0C - dw GymStatueText2 ; id = 0D - dw BookcaseText ; id = 0E - dw ViridianCityPokecenterBenchGuyText ; id = 0F - dw PewterCityPokecenterBenchGuyText ; id = 10 - dw CeruleanCityPokecenterBenchGuyText ; id = 11 - dw LavenderCityPokecenterBenchGuyText ; id = 12 - dw VermilionCityPokecenterBenchGuyText ; id = 13 - dw CeladonCityPokecenterBenchGuyText ; id = 14 - dw CeladonCityHotelText ; id = 15 - dw FuchsiaCityPokecenterBenchGuyText ; id = 16 - dw CinnabarIslandPokecenterBenchGuyText ; id = 17 - dw SaffronCityPokecenterBenchGuyText ; id = 18 - dw MtMoonPokecenterBenchGuyText ; id = 19 - dw RockTunnelPokecenterBenchGuyText ; id = 1A - dw UnusedBenchGuyText1 ; id = 1B - dw UnusedBenchGuyText2 ; id = 1C - dw UnusedBenchGuyText3 ; id = 1D - dw TerminatorText_62508 ; id = 1E - dw PredefText1f ; id = 1F - dw ViridianSchoolNotebook ; id = 20 - dw ViridianSchoolBlackboard ; id = 21 - dw JustAMomentText ; id = 22 - dw PredefText23 ; id = 23 - dw FoundHiddenItemText ; id = 24 - dw HiddenItemBagFullText ; id = 25 - dw VermilionGymTrashText ; id = 26 - dw IndigoPlateauHQText ; id = 27 - dw GameCornerOutOfOrderText ; id = 28 - dw GameCornerOutToLunchText ; id = 29 - dw GameCornerSomeonesKeysText ; id = 2A - dw FoundHiddenCoinsText ; id = 2B - dw DroppedHiddenCoinsText ; id = 2C - dw BillsHouseMonitorText ; id = 2D - dw BillsHouseInitiatedText ; id = 2E - dw BillsHousePokemonList ; id = 2F - dw MagazinesText ; id = 30 - dw CinnabarGymQuiz ; id = 31 - dw GameCornerNoCoinsText ; id = 32 - dw GameCornerCoinCaseText ; id = 33 - dw LinkCableHelp ; id = 34 - dw TMNotebook ; id = 35 - dw FightingDojoText ; id = 36 - dw FightingDojoText_52a10 ; id = 37 - dw FightingDojoText_52a1d ; id = 38 - dw NewBicycleText ; id = 39 - dw IndigoPlateauStatues ; id = 3A - dw VermilionGymTrashSuccesText1 ; id = 3B - dw VermilionGymTrashSuccesText2 ; id = 3C - dw VermilionGymTrashSuccesText3 ; id = 3D - dw VermilionGymTrashFailText ; id = 3E - dw TownMapText ; id = 3F - dw BookOrSculptureText ; id = 40 - dw ElevatorText ; id = 41 - dw PokemonStuffText ; id = 42 +TextPredefs:: + dw CardKeySuccessText ; 01 + dw CardKeyFailText ; 02 + dw RedBedroomPC ; 03 + dw RedBedroomSNESText ; 04 + dw PushStartText ; 05 + dw SaveOptionText ; 06 + dw StrengthsAndWeaknessesText ; 07 + dw OakLabEmailText ; 08 + dw AerodactylFossilText ; 09 + dw Route15UpstairsBinocularsText ; 0A + dw KabutopsFossilText ; 0B + dw GymStatueText1 ; 0C + dw GymStatueText2 ; 0D + dw BookcaseText ; 0E + dw ViridianCityPokecenterBenchGuyText ; 0F + dw PewterCityPokecenterBenchGuyText ; 10 + dw CeruleanCityPokecenterBenchGuyText ; 11 + dw LavenderCityPokecenterBenchGuyText ; 12 + dw VermilionCityPokecenterBenchGuyText ; 13 + dw CeladonCityPokecenterBenchGuyText ; 14 + dw CeladonCityHotelText ; 15 + dw FuchsiaCityPokecenterBenchGuyText ; 16 + dw CinnabarIslandPokecenterBenchGuyText ; 17 + dw SaffronCityPokecenterBenchGuyText ; 18 + dw MtMoonPokecenterBenchGuyText ; 19 + dw RockTunnelPokecenterBenchGuyText ; 1A + dw UnusedBenchGuyText1 ; 1B + dw UnusedBenchGuyText2 ; 1C + dw UnusedBenchGuyText3 ; 1D + dw TerminatorText_62508 ; 1E + dw PredefText1f ; 1F + dw ViridianSchoolNotebook ; 20 + dw ViridianSchoolBlackboard ; 21 + dw JustAMomentText ; 22 + dw PredefText23 ; 23 + dw FoundHiddenItemText ; 24 + dw HiddenItemBagFullText ; 25 + dw VermilionGymTrashText ; 26 + dw IndigoPlateauHQText ; 27 + dw GameCornerOutOfOrderText ; 28 + dw GameCornerOutToLunchText ; 29 + dw GameCornerSomeonesKeysText ; 2A + dw FoundHiddenCoinsText ; 2B + dw DroppedHiddenCoinsText ; 2C + dw BillsHouseMonitorText ; 2D + dw BillsHouseInitiatedText ; 2E + dw BillsHousePokemonList ; 2F + dw MagazinesText ; 30 + dw CinnabarGymQuiz ; 31 + dw GameCornerNoCoinsText ; 32 + dw GameCornerCoinCaseText ; 33 + dw LinkCableHelp ; 34 + dw TMNotebook ; 35 + dw FightingDojoText ; 36 + dw FightingDojoText_52a10 ; 37 + dw FightingDojoText_52a1d ; 38 + dw NewBicycleText ; 39 + dw IndigoPlateauStatues ; 3A + dw VermilionGymTrashSuccesText1 ; 3B + dw VermilionGymTrashSuccesText2 ; 3C + dw VermilionGymTrashSuccesText3 ; 3D + dw VermilionGymTrashFailText ; 3E + dw TownMapText ; 3F + dw BookOrSculptureText ; 40 + dw ElevatorText ; 41 + dw PokemonStuffText ; 42 From d59dfadf66926ea0c7b5f8bbeaa9b83ee7bb3cb5 Mon Sep 17 00:00:00 2001 From: yenatch Date: Wed, 17 Sep 2014 21:15:11 -0700 Subject: [PATCH 024/100] Add macros for text predefs. --- home.asm | 132 ++++++++++++++++++++++++++--------------------------- macros.asm | 18 ++++++++ 2 files changed, 84 insertions(+), 66 deletions(-) diff --git a/home.asm b/home.asm index 7b5c8c6bb2..26ce6341b9 100644 --- a/home.asm +++ b/home.asm @@ -4656,69 +4656,69 @@ Func_3f0f:: ; 3f0f (0:3f0f) ret TextPredefs:: - dw CardKeySuccessText ; 01 - dw CardKeyFailText ; 02 - dw RedBedroomPC ; 03 - dw RedBedroomSNESText ; 04 - dw PushStartText ; 05 - dw SaveOptionText ; 06 - dw StrengthsAndWeaknessesText ; 07 - dw OakLabEmailText ; 08 - dw AerodactylFossilText ; 09 - dw Route15UpstairsBinocularsText ; 0A - dw KabutopsFossilText ; 0B - dw GymStatueText1 ; 0C - dw GymStatueText2 ; 0D - dw BookcaseText ; 0E - dw ViridianCityPokecenterBenchGuyText ; 0F - dw PewterCityPokecenterBenchGuyText ; 10 - dw CeruleanCityPokecenterBenchGuyText ; 11 - dw LavenderCityPokecenterBenchGuyText ; 12 - dw VermilionCityPokecenterBenchGuyText ; 13 - dw CeladonCityPokecenterBenchGuyText ; 14 - dw CeladonCityHotelText ; 15 - dw FuchsiaCityPokecenterBenchGuyText ; 16 - dw CinnabarIslandPokecenterBenchGuyText ; 17 - dw SaffronCityPokecenterBenchGuyText ; 18 - dw MtMoonPokecenterBenchGuyText ; 19 - dw RockTunnelPokecenterBenchGuyText ; 1A - dw UnusedBenchGuyText1 ; 1B - dw UnusedBenchGuyText2 ; 1C - dw UnusedBenchGuyText3 ; 1D - dw TerminatorText_62508 ; 1E - dw PredefText1f ; 1F - dw ViridianSchoolNotebook ; 20 - dw ViridianSchoolBlackboard ; 21 - dw JustAMomentText ; 22 - dw PredefText23 ; 23 - dw FoundHiddenItemText ; 24 - dw HiddenItemBagFullText ; 25 - dw VermilionGymTrashText ; 26 - dw IndigoPlateauHQText ; 27 - dw GameCornerOutOfOrderText ; 28 - dw GameCornerOutToLunchText ; 29 - dw GameCornerSomeonesKeysText ; 2A - dw FoundHiddenCoinsText ; 2B - dw DroppedHiddenCoinsText ; 2C - dw BillsHouseMonitorText ; 2D - dw BillsHouseInitiatedText ; 2E - dw BillsHousePokemonList ; 2F - dw MagazinesText ; 30 - dw CinnabarGymQuiz ; 31 - dw GameCornerNoCoinsText ; 32 - dw GameCornerCoinCaseText ; 33 - dw LinkCableHelp ; 34 - dw TMNotebook ; 35 - dw FightingDojoText ; 36 - dw FightingDojoText_52a10 ; 37 - dw FightingDojoText_52a1d ; 38 - dw NewBicycleText ; 39 - dw IndigoPlateauStatues ; 3A - dw VermilionGymTrashSuccesText1 ; 3B - dw VermilionGymTrashSuccesText2 ; 3C - dw VermilionGymTrashSuccesText3 ; 3D - dw VermilionGymTrashFailText ; 3E - dw TownMapText ; 3F - dw BookOrSculptureText ; 40 - dw ElevatorText ; 41 - dw PokemonStuffText ; 42 + add_tx_pre CardKeySuccessText ; 01 + add_tx_pre CardKeyFailText ; 02 + add_tx_pre RedBedroomPC ; 03 + add_tx_pre RedBedroomSNESText ; 04 + add_tx_pre PushStartText ; 05 + add_tx_pre SaveOptionText ; 06 + add_tx_pre StrengthsAndWeaknessesText ; 07 + add_tx_pre OakLabEmailText ; 08 + add_tx_pre AerodactylFossilText ; 09 + add_tx_pre Route15UpstairsBinocularsText ; 0A + add_tx_pre KabutopsFossilText ; 0B + add_tx_pre GymStatueText1 ; 0C + add_tx_pre GymStatueText2 ; 0D + add_tx_pre BookcaseText ; 0E + add_tx_pre ViridianCityPokecenterBenchGuyText ; 0F + add_tx_pre PewterCityPokecenterBenchGuyText ; 10 + add_tx_pre CeruleanCityPokecenterBenchGuyText ; 11 + add_tx_pre LavenderCityPokecenterBenchGuyText ; 12 + add_tx_pre VermilionCityPokecenterBenchGuyText ; 13 + add_tx_pre CeladonCityPokecenterBenchGuyText ; 14 + add_tx_pre CeladonCityHotelText ; 15 + add_tx_pre FuchsiaCityPokecenterBenchGuyText ; 16 + add_tx_pre CinnabarIslandPokecenterBenchGuyText ; 17 + add_tx_pre SaffronCityPokecenterBenchGuyText ; 18 + add_tx_pre MtMoonPokecenterBenchGuyText ; 19 + add_tx_pre RockTunnelPokecenterBenchGuyText ; 1A + add_tx_pre UnusedBenchGuyText1 ; 1B + add_tx_pre UnusedBenchGuyText2 ; 1C + add_tx_pre UnusedBenchGuyText3 ; 1D + add_tx_pre TerminatorText_62508 ; 1E + add_tx_pre PredefText1f ; 1F + add_tx_pre ViridianSchoolNotebook ; 20 + add_tx_pre ViridianSchoolBlackboard ; 21 + add_tx_pre JustAMomentText ; 22 + add_tx_pre PredefText23 ; 23 + add_tx_pre FoundHiddenItemText ; 24 + add_tx_pre HiddenItemBagFullText ; 25 + add_tx_pre VermilionGymTrashText ; 26 + add_tx_pre IndigoPlateauHQText ; 27 + add_tx_pre GameCornerOutOfOrderText ; 28 + add_tx_pre GameCornerOutToLunchText ; 29 + add_tx_pre GameCornerSomeonesKeysText ; 2A + add_tx_pre FoundHiddenCoinsText ; 2B + add_tx_pre DroppedHiddenCoinsText ; 2C + add_tx_pre BillsHouseMonitorText ; 2D + add_tx_pre BillsHouseInitiatedText ; 2E + add_tx_pre BillsHousePokemonList ; 2F + add_tx_pre MagazinesText ; 30 + add_tx_pre CinnabarGymQuiz ; 31 + add_tx_pre GameCornerNoCoinsText ; 32 + add_tx_pre GameCornerCoinCaseText ; 33 + add_tx_pre LinkCableHelp ; 34 + add_tx_pre TMNotebook ; 35 + add_tx_pre FightingDojoText ; 36 + add_tx_pre FightingDojoText_52a10 ; 37 + add_tx_pre FightingDojoText_52a1d ; 38 + add_tx_pre NewBicycleText ; 39 + add_tx_pre IndigoPlateauStatues ; 3A + add_tx_pre VermilionGymTrashSuccesText1 ; 3B + add_tx_pre VermilionGymTrashSuccesText2 ; 3C + add_tx_pre VermilionGymTrashSuccesText3 ; 3D + add_tx_pre VermilionGymTrashFailText ; 3E + add_tx_pre TownMapText ; 3F + add_tx_pre BookOrSculptureText ; 40 + add_tx_pre ElevatorText ; 41 + add_tx_pre PokemonStuffText ; 42 diff --git a/macros.asm b/macros.asm index ca2dc82d22..f219d25c38 100644 --- a/macros.asm +++ b/macros.asm @@ -203,6 +203,24 @@ predef_jump: MACRO ENDM +add_tx_pre: MACRO +\1_id:: dw \1 +ENDM + +tx_pre_id: MACRO + ld a, (\1_id - TextPredefs) / 2 +ENDM + +tx_pre: MACRO + tx_pre_id \1 + call PrintPredefTextID +ENDM + +tx_pre_jump: MACRO + tx_pre_id \1 + jp PrintPredefTextID +ENDM + ;1_channel EQU $00 ;2_channels EQU $40 From f1667eb6b533eafbb5121ac605401df69960f6df Mon Sep 17 00:00:00 2001 From: yenatch Date: Fri, 19 Sep 2014 13:09:37 -0700 Subject: [PATCH 025/100] Fix the symfile and mapfile filenames. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e361636149..20e86bb2b1 100644 --- a/Makefile +++ b/Makefile @@ -94,7 +94,7 @@ $(all_obj): $$*.tx $$(patsubst %.asm, %.tx, $$($$*_dep)) # Link objects together to build a rom. # Make a symfile for debugging. rgblink will segfault if a mapfile isn't made too. -link = rgblink -n $*.sym -m $*.map +link = rgblink -n poke$*.sym -m poke$*.map poke%.gbc: $$(%_obj) $(link) -o $@ $^ From 52f17d9cce9f07427884a297dfc5fa4dc7783c2a Mon Sep 17 00:00:00 2001 From: "U-Daniel-PC\\Daniel" Date: Fri, 19 Sep 2014 23:23:01 -0400 Subject: [PATCH 026/100] Bump submodule python tools now include new red music command names --- extras | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extras b/extras index 698b0fc7e6..a87f66964c 160000 --- a/extras +++ b/extras @@ -1 +1 @@ -Subproject commit 698b0fc7e63d3dadf07247015e230bce145cc500 +Subproject commit a87f66964cc602ff5575efebf27c388ef03fa94d From 3379bd7b73b7e6c7e011520c7fc0b2b51422d67e Mon Sep 17 00:00:00 2001 From: "U-Daniel-PC\\Daniel" Date: Sat, 20 Sep 2014 00:32:05 -0400 Subject: [PATCH 027/100] Fix capitalization --- data/baseStats/nidoranf.asm | 2 +- data/baseStats/nidoranm.asm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/data/baseStats/nidoranf.asm b/data/baseStats/nidoranf.asm index 7d3b194091..24caa7ab12 100755 --- a/data/baseStats/nidoranf.asm +++ b/data/baseStats/nidoranf.asm @@ -9,7 +9,7 @@ db POISON ; species type 1 db POISON ; species type 2 db 235 ; catch rate db 59 ; base exp yield -INCBIN "pic/bmon/nidoranF.pic",0,1 ; 55, sprite dimensions +INCBIN "pic/bmon/nidoranf.pic",0,1 ; 55, sprite dimensions dw NidoranFPicFront dw NidoranFPicBack ; attacks known at lvl 0 diff --git a/data/baseStats/nidoranm.asm b/data/baseStats/nidoranm.asm index 1cf36df000..1b33b61cfb 100755 --- a/data/baseStats/nidoranm.asm +++ b/data/baseStats/nidoranm.asm @@ -9,7 +9,7 @@ db POISON ; species type 1 db POISON ; species type 2 db 235 ; catch rate db 60 ; base exp yield -INCBIN "pic/bmon/nidoranM.pic",0,1 ; 55, sprite dimensions +INCBIN "pic/bmon/nidoranm.pic",0,1 ; 55, sprite dimensions dw NidoranMPicFront dw NidoranMPicBack ; attacks known at lvl 0 From 6866df277f7f7685ae087c9e54d537873a941575 Mon Sep 17 00:00:00 2001 From: yenatch Date: Tue, 23 Sep 2014 14:56:07 -0700 Subject: [PATCH 028/100] Add comments for move ids. --- constants/move_constants.asm | 328 +++++++++++++++++------------------ 1 file changed, 164 insertions(+), 164 deletions(-) diff --git a/constants/move_constants.asm b/constants/move_constants.asm index 0899c594ff..676f06f2a9 100644 --- a/constants/move_constants.asm +++ b/constants/move_constants.asm @@ -1,169 +1,169 @@ const_value = 1 - const POUND - const KARATE_CHOP - const DOUBLESLAP - const COMET_PUNCH - const MEGA_PUNCH - const PAY_DAY - const FIRE_PUNCH - const ICE_PUNCH - const THUNDERPUNCH - const SCRATCH - const VICEGRIP - const GUILLOTINE - const RAZOR_WIND - const SWORDS_DANCE - const CUT - const GUST - const WING_ATTACK - const WHIRLWIND - const FLY - const BIND - const SLAM - const VINE_WHIP - const STOMP - const DOUBLE_KICK - const MEGA_KICK - const JUMP_KICK - const ROLLING_KICK - const SAND_ATTACK - const HEADBUTT - const HORN_ATTACK - const FURY_ATTACK - const HORN_DRILL - const TACKLE - const BODY_SLAM - const WRAP - const TAKE_DOWN - const THRASH - const DOUBLE_EDGE - const TAIL_WHIP - const POISON_STING - const TWINEEDLE - const PIN_MISSILE - const LEER - const BITE - const GROWL - const ROAR - const SING - const SUPERSONIC - const SONICBOOM - const DISABLE - const ACID - const EMBER - const FLAMETHROWER - const MIST - const WATER_GUN - const HYDRO_PUMP - const SURF - const ICE_BEAM - const BLIZZARD - const PSYBEAM - const BUBBLEBEAM - const AURORA_BEAM - const HYPER_BEAM - const PECK - const DRILL_PECK - const SUBMISSION - const LOW_KICK - const COUNTER - const SEISMIC_TOSS - const STRENGTH - const ABSORB - const MEGA_DRAIN - const LEECH_SEED - const GROWTH - const RAZOR_LEAF - const SOLARBEAM - const POISONPOWDER - const STUN_SPORE - const SLEEP_POWDER - const PETAL_DANCE - const STRING_SHOT - const DRAGON_RAGE - const FIRE_SPIN - const THUNDERSHOCK - const THUNDERBOLT - const THUNDER_WAVE - const THUNDER - const ROCK_THROW - const EARTHQUAKE - const FISSURE - const DIG - const TOXIC - const CONFUSION - const PSYCHIC_M - const HYPNOSIS - const MEDITATE - const AGILITY - const QUICK_ATTACK - const RAGE - const TELEPORT - const NIGHT_SHADE - const MIMIC - const SCREECH - const DOUBLE_TEAM - const RECOVER - const HARDEN - const MINIMIZE - const SMOKESCREEN - const CONFUSE_RAY - const WITHDRAW - const DEFENSE_CURL - const BARRIER - const LIGHT_SCREEN - const HAZE - const REFLECT - const FOCUS_ENERGY - const BIDE - const METRONOME - const MIRROR_MOVE - const SELFDESTRUCT - const EGG_BOMB - const LICK - const SMOG - const SLUDGE - const BONE_CLUB - const FIRE_BLAST - const WATERFALL - const CLAMP - const SWIFT - const SKULL_BASH - const SPIKE_CANNON - const CONSTRICT - const AMNESIA - const KINESIS - const SOFTBOILED - const HI_JUMP_KICK - const GLARE - const DREAM_EATER - const POISON_GAS - const BARRAGE - const LEECH_LIFE - const LOVELY_KISS - const SKY_ATTACK - const TRANSFORM - const BUBBLE - const DIZZY_PUNCH - const SPORE - const FLASH - const PSYWAVE - const SPLASH - const ACID_ARMOR - const CRABHAMMER - const EXPLOSION - const FURY_SWIPES - const BONEMERANG - const REST - const ROCK_SLIDE - const HYPER_FANG - const SHARPEN - const CONVERSION - const TRI_ATTACK - const SUPER_FANG - const SLASH - const SUBSTITUTE + const POUND ; 01 + const KARATE_CHOP ; 02 + const DOUBLESLAP ; 03 + const COMET_PUNCH ; 04 + const MEGA_PUNCH ; 05 + const PAY_DAY ; 06 + const FIRE_PUNCH ; 07 + const ICE_PUNCH ; 08 + const THUNDERPUNCH ; 09 + const SCRATCH ; 0a + const VICEGRIP ; 0b + const GUILLOTINE ; 0c + const RAZOR_WIND ; 0d + const SWORDS_DANCE ; 0e + const CUT ; 0f + const GUST ; 10 + const WING_ATTACK ; 11 + const WHIRLWIND ; 12 + const FLY ; 13 + const BIND ; 14 + const SLAM ; 15 + const VINE_WHIP ; 16 + const STOMP ; 17 + const DOUBLE_KICK ; 18 + const MEGA_KICK ; 19 + const JUMP_KICK ; 1a + const ROLLING_KICK ; 1b + const SAND_ATTACK ; 1c + const HEADBUTT ; 1d + const HORN_ATTACK ; 1e + const FURY_ATTACK ; 1f + const HORN_DRILL ; 20 + const TACKLE ; 21 + const BODY_SLAM ; 22 + const WRAP ; 23 + const TAKE_DOWN ; 24 + const THRASH ; 25 + const DOUBLE_EDGE ; 26 + const TAIL_WHIP ; 27 + const POISON_STING ; 28 + const TWINEEDLE ; 29 + const PIN_MISSILE ; 2a + const LEER ; 2b + const BITE ; 2c + const GROWL ; 2d + const ROAR ; 2e + const SING ; 2f + const SUPERSONIC ; 30 + const SONICBOOM ; 31 + const DISABLE ; 32 + const ACID ; 33 + const EMBER ; 34 + const FLAMETHROWER ; 35 + const MIST ; 36 + const WATER_GUN ; 37 + const HYDRO_PUMP ; 38 + const SURF ; 39 + const ICE_BEAM ; 3a + const BLIZZARD ; 3b + const PSYBEAM ; 3c + const BUBBLEBEAM ; 3d + const AURORA_BEAM ; 3e + const HYPER_BEAM ; 3f + const PECK ; 40 + const DRILL_PECK ; 41 + const SUBMISSION ; 42 + const LOW_KICK ; 43 + const COUNTER ; 44 + const SEISMIC_TOSS ; 45 + const STRENGTH ; 46 + const ABSORB ; 47 + const MEGA_DRAIN ; 48 + const LEECH_SEED ; 49 + const GROWTH ; 4a + const RAZOR_LEAF ; 4b + const SOLARBEAM ; 4c + const POISONPOWDER ; 4d + const STUN_SPORE ; 4e + const SLEEP_POWDER ; 4f + const PETAL_DANCE ; 50 + const STRING_SHOT ; 51 + const DRAGON_RAGE ; 52 + const FIRE_SPIN ; 53 + const THUNDERSHOCK ; 54 + const THUNDERBOLT ; 55 + const THUNDER_WAVE ; 56 + const THUNDER ; 57 + const ROCK_THROW ; 58 + const EARTHQUAKE ; 59 + const FISSURE ; 5a + const DIG ; 5b + const TOXIC ; 5c + const CONFUSION ; 5d + const PSYCHIC_M ; 5e + const HYPNOSIS ; 5f + const MEDITATE ; 60 + const AGILITY ; 61 + const QUICK_ATTACK ; 62 + const RAGE ; 63 + const TELEPORT ; 64 + const NIGHT_SHADE ; 65 + const MIMIC ; 66 + const SCREECH ; 67 + const DOUBLE_TEAM ; 68 + const RECOVER ; 69 + const HARDEN ; 6a + const MINIMIZE ; 6b + const SMOKESCREEN ; 6c + const CONFUSE_RAY ; 6d + const WITHDRAW ; 6e + const DEFENSE_CURL ; 6f + const BARRIER ; 70 + const LIGHT_SCREEN ; 71 + const HAZE ; 72 + const REFLECT ; 73 + const FOCUS_ENERGY ; 74 + const BIDE ; 75 + const METRONOME ; 76 + const MIRROR_MOVE ; 77 + const SELFDESTRUCT ; 78 + const EGG_BOMB ; 79 + const LICK ; 7a + const SMOG ; 7b + const SLUDGE ; 7c + const BONE_CLUB ; 7d + const FIRE_BLAST ; 7e + const WATERFALL ; 7f + const CLAMP ; 80 + const SWIFT ; 81 + const SKULL_BASH ; 82 + const SPIKE_CANNON ; 83 + const CONSTRICT ; 84 + const AMNESIA ; 85 + const KINESIS ; 86 + const SOFTBOILED ; 87 + const HI_JUMP_KICK ; 88 + const GLARE ; 89 + const DREAM_EATER ; 8a + const POISON_GAS ; 8b + const BARRAGE ; 8c + const LEECH_LIFE ; 8d + const LOVELY_KISS ; 8e + const SKY_ATTACK ; 8f + const TRANSFORM ; 90 + const BUBBLE ; 91 + const DIZZY_PUNCH ; 92 + const SPORE ; 93 + const FLASH ; 94 + const PSYWAVE ; 95 + const SPLASH ; 96 + const ACID_ARMOR ; 97 + const CRABHAMMER ; 98 + const EXPLOSION ; 99 + const FURY_SWIPES ; 9a + const BONEMERANG ; 9b + const REST ; 9c + const ROCK_SLIDE ; 9d + const HYPER_FANG ; 9e + const SHARPEN ; 9f + const CONVERSION ; a0 + const TRI_ATTACK ; a1 + const SUPER_FANG ; a2 + const SLASH ; a3 + const SUBSTITUTE ; a4 NUM_ATTACKS EQU const_value + -1 From a81487e9c6ee271f0ffeaacd681b929c0b4afaf0 Mon Sep 17 00:00:00 2001 From: yenatch Date: Tue, 23 Sep 2014 15:02:03 -0700 Subject: [PATCH 029/100] Rename hVBlank* constants to h*. --- engine/HoF_room_pc.asm | 2 +- engine/battle/1c.asm | 2 +- engine/battle/animations.asm | 12 ++++++------ engine/battle/core.asm | 12 ++++++------ engine/hall_of_fame.asm | 4 ++-- engine/hidden_object_functions17.asm | 4 ++-- engine/hidden_object_functions3.asm | 2 +- engine/overworld/cut.asm | 6 +++--- engine/titlescreen.asm | 16 ++++++++-------- engine/trade.asm | 6 +++--- home.asm | 2 +- home/init.asm | 2 +- home/vblank.asm | 6 +++--- hram.asm | 6 +++--- main.asm | 4 ++-- scripts/vermiliondock.asm | 4 ++-- 16 files changed, 45 insertions(+), 45 deletions(-) diff --git a/engine/HoF_room_pc.asm b/engine/HoF_room_pc.asm index 4eec737702..ae4ecb0d24 100755 --- a/engine/HoF_room_pc.asm +++ b/engine/HoF_room_pc.asm @@ -92,7 +92,7 @@ DisplayCreditsMon: ; 740cb (1d:40cb) dec c jr nz,.next2 xor a - ld [hVBlankWY],a + ld [hWY],a ld a,$C0 ld [$FF47],a ret diff --git a/engine/battle/1c.asm b/engine/battle/1c.asm index 1c69c00f97..bceeac2be1 100755 --- a/engine/battle/1c.asm +++ b/engine/battle/1c.asm @@ -87,7 +87,7 @@ BattleTransition: ; 7096d (1c:496d) ld [H_AUTOBGTRANSFERENABLED], a call Delay3 xor a - ld [hVBlankWY], a + ld [hWY], a dec a ld [wUpdateSpritesEnabled], a call DelayFrame diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm index 58d4e60a85..349d1d5d2a 100755 --- a/engine/battle/animations.asm +++ b/engine/battle/animations.asm @@ -1962,7 +1962,7 @@ AnimationWavyScreen: ; 79666 (1e:5666) xor a ld [H_AUTOBGTRANSFERENABLED], a ld a, $90 - ld [hVBlankWY], a + ld [hWY], a ld d, $80 ld e, $8f ld c, $ff @@ -1984,7 +1984,7 @@ AnimationWavyScreen: ; 79666 (1e:5666) dec c jr nz, .asm_7967f xor a - ld [hVBlankWY], a + ld [hWY], a call SaveScreenTilesToBuffer2 call ClearScreen ld a, $1 @@ -2744,11 +2744,11 @@ AnimationShakeEnemyHUD: ; 79d77 (1e:5d77) ld hl, vBGMap0 call Func_79e0d ld a, $90 - ld [hVBlankWY], a + ld [hWY], a ld hl, vBGMap0 + $320 call Func_79e0d ld a, $38 - ld [hVBlankWY], a + ld [hWY], a call Func_792fd ld hl, vBGMap0 call Func_79e0d @@ -2759,11 +2759,11 @@ AnimationShakeEnemyHUD: ; 79d77 (1e:5d77) call AnimationShowMonPic call ClearSprites ld a, $90 - ld [hVBlankWY], a + ld [hWY], a ld hl, vBGMap1 call Func_79e0d xor a - ld [hVBlankWY], a + ld [hWY], a call SaveScreenTilesToBuffer1 ld hl, vBGMap0 call Func_79e0d diff --git a/engine/battle/core.asm b/engine/battle/core.asm index c2616ff753..263fafa1b4 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -133,11 +133,11 @@ SlidePlayerAndEnemySilhouettesOnScreen: ; 3c04c (f:404c) jr nz, .copyRowLoop call EnableLCD ld a, $90 - ld [hVBlankWY], a + ld [hWY], a ld [rWY], a xor a ld [hTilesetType], a - ld [hVBlankSCY], a + ld [hSCY], a dec a ld [wUpdateSpritesEnabled], a call Delay3 @@ -146,7 +146,7 @@ SlidePlayerAndEnemySilhouettesOnScreen: ; 3c04c (f:404c) ld b, $70 ld c, $90 ld a, c - ld [hVBlankSCX], a + ld [hSCX], a call DelayFrame ld a, %11100100 ; inverted palette for silhouette effect ld [rBGP], a @@ -163,7 +163,7 @@ SlidePlayerAndEnemySilhouettesOnScreen: ; 3c04c (f:404c) call SetScrollXForSlidingPlayerBodyLeft ; end background scrolling on line $60 call SlidePlayerHeadLeft ld a, c - ld [hVBlankSCX], a + ld [hSCX], a dec c dec c jr nz, .slideSilhouettesLoop @@ -174,7 +174,7 @@ SlidePlayerAndEnemySilhouettesOnScreen: ; 3c04c (f:404c) hlCoord 1, 5 predef Func_3f0c6 xor a - ld [hVBlankWY], a + ld [hWY], a ld [rWY], a inc a ld [H_AUTOBGTRANSFERENABLED], a @@ -6283,7 +6283,7 @@ DoBattleTransitionAndInitBattleVariables: ; 3ec32 (f:6c32) call ClearScreen xor a ld [H_AUTOBGTRANSFERENABLED], a - ld [hVBlankWY], a + ld [hWY], a ld [rWY], a ld [hTilesetType], a ld hl, wd060 diff --git a/engine/hall_of_fame.asm b/engine/hall_of_fame.asm index 406fac01ae..4b7e66db17 100755 --- a/engine/hall_of_fame.asm +++ b/engine/hall_of_fame.asm @@ -32,7 +32,7 @@ AnimateHallOfFame: ; 701a0 (1c:41a0) inc [hl] .asm_701eb ld a, $90 - ld [hVBlankWY], a + ld [hWY], a ld c, BANK(Music_HallOfFame) ld a, MUSIC_HALL_OF_FAME call PlayMusic @@ -86,7 +86,7 @@ AnimateHallOfFame: ; 701a0 (1c:41a0) call Func_70377 call Func_70423 xor a - ld [hVBlankWY], a + ld [hWY], a ld hl, rLCDC ; $ff40 res 3, [hl] ret diff --git a/engine/hidden_object_functions17.asm b/engine/hidden_object_functions17.asm index f1a07542b4..d966b7209d 100755 --- a/engine/hidden_object_functions17.asm +++ b/engine/hidden_object_functions17.asm @@ -64,7 +64,7 @@ DisplayMonFrontSpriteInBox: ; 5dbd9 (17:5bd9) ld [H_AUTOBGTRANSFERENABLED], a ; $ffba call Delay3 xor a - ld [hVBlankWY], a + ld [hWY], a call SaveScreenTilesToBuffer1 ld a, $11 ld [wd125], a @@ -83,7 +83,7 @@ DisplayMonFrontSpriteInBox: ; 5dbd9 (17:5bd9) call LoadScreenTilesFromBuffer1 call Delay3 ld a, $90 - ld [hVBlankWY], a + ld [hWY], a ret PrintBlackboardLinkCableText: ; 5dc1a (17:5c1a) diff --git a/engine/hidden_object_functions3.asm b/engine/hidden_object_functions3.asm index d3d83f0875..c471c7bb1d 100755 --- a/engine/hidden_object_functions3.asm +++ b/engine/hidden_object_functions3.asm @@ -120,7 +120,7 @@ TownMapText: ; fc12 (3:7c12) set 6, [hl] call GBPalWhiteOutWithDelay3 xor a - ld [hVBlankWY], a + ld [hWY], a inc a ld [H_AUTOBGTRANSFERENABLED], a call LoadFontTilePatterns diff --git a/engine/overworld/cut.asm b/engine/overworld/cut.asm index f57b646581..7b92bca301 100755 --- a/engine/overworld/cut.asm +++ b/engine/overworld/cut.asm @@ -38,14 +38,14 @@ asm_ef82: ; ef82 (3:6f82) call ClearSprites call RestoreScreenTilesAndReloadTilePatterns ld a, $90 - ld [hVBlankWY], a + ld [hWY], a call Delay3 call LoadGBPal call LoadCurrentMapView call SaveScreenTilesToBuffer2 call Delay3 xor a - ld [hVBlankWY], a + ld [hWY], a ld hl, UsedCutText call PrintText call LoadScreenTilesFromBuffer2 @@ -63,7 +63,7 @@ asm_ef82: ; ef82 (3:6f82) ld a, (SFX_02_56 - SFX_Headers_02) / 3 call PlaySound ld a, $90 - ld [hVBlankWY], a + ld [hWY], a call UpdateSprites jp RedrawMapView diff --git a/engine/titlescreen.asm b/engine/titlescreen.asm index ca81eff852..0bf4f4a561 100755 --- a/engine/titlescreen.asm +++ b/engine/titlescreen.asm @@ -11,7 +11,7 @@ SetDefaultNamesBeforeTitlescreen: ; 42b7 (1:42b7) ld de, W_RIVALNAME ; wd34a call CopyFixedLengthText xor a - ld [hVBlankWY], a + ld [hWY], a ld [wd358], a ld hl, wd732 ld [hli], a @@ -31,7 +31,7 @@ LoadTitlescreenGraphics: ; 42dd (1:42dd) ld a, $40 ld [$ffaf], a ld a, $90 - ld [hVBlankWY], a + ld [hWY], a call ClearScreen call DisableLCD call LoadFontTilePatterns @@ -127,7 +127,7 @@ ENDC call Func_4533 call SaveScreenTilesToBuffer1 ld a, $40 - ld [hVBlankWY], a + ld [hWY], a call LoadScreenTilesFromBuffer2 ld a, $98 call Func_4533 @@ -182,7 +182,7 @@ ENDC call PlaySound call PrintGameVersionOnTitleScreen ld a, $90 - ld [hVBlankWY], a + ld [hWY], a ld d, $90 .asm_440a ld h, d @@ -225,7 +225,7 @@ ENDC call GBPalWhiteOutWithDelay3 call ClearSprites xor a - ld [hVBlankWY], a + ld [hWY], a inc a ld [H_AUTOBGTRANSFERENABLED], a ; $ffba call ClearScreen @@ -270,7 +270,7 @@ Func_4496: ; 4496 (1:4496) call Func_4524 ld a, $90 - ld [hVBlankWY], a + ld [hWY], a ld d, 1 ; scroll out callba TitleScroll ret @@ -279,7 +279,7 @@ Func_44c1: ; 44c1 (1:44c1) ld d, 0 ; scroll in callba TitleScroll xor a - ld [hVBlankWY], a + ld [hWY], a ret Func_44cf: ; 44cf (1:44cf) @@ -353,7 +353,7 @@ Func_4533: ; 4533 (1:4533) LoadCopyrightAndTextBoxTiles: ; 4538 (1:4538) xor a - ld [hVBlankWY], a + ld [hWY], a call ClearScreen call LoadTextBoxTilePatterns diff --git a/engine/trade.asm b/engine/trade.asm index 4d6c044cab..4a8f865ad3 100755 --- a/engine/trade.asm +++ b/engine/trade.asm @@ -175,7 +175,7 @@ Func_41245: ; 41245 (10:5245) ld a, $ab ld [rLCDC], a ; $ff40 ld a, $50 - ld [hVBlankWY], a + ld [hWY], a ld a, $86 ld [rWX], a ; $ff4b ld [$ffae], a @@ -397,7 +397,7 @@ Func_41411: ; 41411 (10:5411) xor a ld [$ffae], a ld a, $90 - ld [hVBlankWY], a + ld [hWY], a ret Func_4142d: ; 4142d (10:542d) @@ -655,7 +655,7 @@ Func_415c8: ; 415c8 (10:55c8) ld a, $7 ld [rWX], a ; $ff4b xor a - ld [hVBlankWY], a + ld [hWY], a ld a, $90 ld [$ffae], a ret diff --git a/home.asm b/home.asm index 87f800a33a..a4882007d5 100644 --- a/home.asm +++ b/home.asm @@ -1162,7 +1162,7 @@ CloseTextDisplay:: ; 29e8 (0:29e8) ld a,[W_CURMAP] call SwitchToMapRomBank ld a,$90 - ld [hVBlankWY],a ; move the window off the screen + ld [hWY],a ; move the window off the screen call DelayFrame call LoadGBPal xor a diff --git a/home/init.asm b/home/init.asm index e170fe7827..e4c2400192 100644 --- a/home/init.asm +++ b/home/init.asm @@ -74,7 +74,7 @@ rLCDC_DEFAULT EQU %11100011 ld [rIE], a ld a, 144 ; move the window off-screen - ld [hVBlankWY], a + ld [hWY], a ld [rWY], a ld a, 7 ld [rWX], a diff --git a/home/vblank.asm b/home/vblank.asm index d660f270b2..5d49ec517e 100644 --- a/home/vblank.asm +++ b/home/vblank.asm @@ -8,15 +8,15 @@ VBlank:: ld a, [H_LOADEDROMBANK] ld [wd122], a - ld a, [hVBlankSCX] + ld a, [hSCX] ld [rSCX], a - ld a, [hVBlankSCY] + ld a, [hSCY] ld [rSCY], a ld a, [wd0a0] and a jr nz, .ok - ld a, [hVBlankWY] + ld a, [hWY] ld [rWY], a .ok diff --git a/hram.asm b/hram.asm index 6bf0b76f7d..644315ec3a 100644 --- a/hram.asm +++ b/hram.asm @@ -39,9 +39,9 @@ H_POWEROFTEN EQU $FF99 ; 3 bytes H_SAVEDNUMTOPRINT EQU $FF9C ; 3 bytes ; these values are copied to SCX, SCY, and WY during V-blank -hVBlankSCX EQU $FFAE -hVBlankSCY EQU $FFAF -hVBlankWY EQU $FFB0 +hSCX EQU $FFAE +hSCY EQU $FFAF +hWY EQU $FFB0 hJoyHeldLast EQU $FFB1 hJoyReleased EQU $FFB2 diff --git a/main.asm b/main.asm index 8cc71c7126..f49e5b24fb 100755 --- a/main.asm +++ b/main.asm @@ -1063,7 +1063,7 @@ DisplayTextIDInit: ; 7096 (1:7096) ld b,$9c ; window background address call CopyScreenTileBufferToVRAM ; transfer background in WRAM to VRAM xor a - ld [hVBlankWY],a ; put the window on the screen + ld [hWY],a ; put the window on the screen call LoadFontTilePatterns ld a,$01 ld [H_AUTOBGTRANSFERENABLED],a ; enable continuous WRAM to VRAM transfer each V-blank @@ -2023,7 +2023,7 @@ INCLUDE "data/map_header_banks.asm" ClearVariablesAfterLoadingMapData: ; c335 (3:4335) ld a, $90 - ld [hVBlankWY], a + ld [hWY], a ld [rWY], a xor a ld [H_AUTOBGTRANSFERENABLED], a diff --git a/scripts/vermiliondock.asm b/scripts/vermiliondock.asm index dca1c66ce5..7b23c41eb3 100755 --- a/scripts/vermiliondock.asm +++ b/scripts/vermiliondock.asm @@ -106,10 +106,10 @@ VermilionDock_1db9b: ; 1db9b (7:5b9b) jr nz, .asm_1dbfa ; 0x1dc22 $d6 xor a ld [$ff4a], a - ld [hVBlankWY], a + ld [hWY], a call VermilionDock_1dc94 ld a, $90 - ld [hVBlankWY], a + ld [hWY], a ld a, $1 ld [wUpdateSpritesEnabled], a pop hl From 070c9649645f564c081bfaedbe07b64191868e2d Mon Sep 17 00:00:00 2001 From: yenatch Date: Tue, 23 Sep 2014 15:07:38 -0700 Subject: [PATCH 030/100] Accidentally committed .orig files from merge dff0cdeb. --- engine/battle/core.asm.orig | 8639 ---------------------------------- engine/menu/pokedex.asm.orig | 647 --- engine/town_map.asm.orig | 605 --- 3 files changed, 9891 deletions(-) delete mode 100755 engine/battle/core.asm.orig delete mode 100755 engine/menu/pokedex.asm.orig delete mode 100755 engine/town_map.asm.orig diff --git a/engine/battle/core.asm.orig b/engine/battle/core.asm.orig deleted file mode 100755 index b8314a82a0..0000000000 --- a/engine/battle/core.asm.orig +++ /dev/null @@ -1,8639 +0,0 @@ -BattleCore: - -; These are move effects (second value from the Moves table in bank $E). -EffectsArray1: ; 3c000 (f:4000) - db CONVERSION_EFFECT - db HAZE_EFFECT - db SWITCH_AND_TELEPORT_EFFECT - db MIST_EFFECT - db FOCUS_ENERGY_EFFECT - db CONFUSION_EFFECT - db HEAL_EFFECT - db TRANSFORM_EFFECT - db LIGHT_SCREEN_EFFECT - db REFLECT_EFFECT - db POISON_EFFECT - db PARALYZE_EFFECT - db SUBSTITUTE_EFFECT - db MIMIC_EFFECT - db LEECH_SEED_EFFECT - db SPLASH_EFFECT - db -1 -EffectsArray2: ; 3c011 (f:4011) -; moves that do damage but not through normal calculations -; e.g., Super Fang, Psywave - db SUPER_FANG_EFFECT - db SPECIAL_DAMAGE_EFFECT - db -1 -EffectsArray3: ; 3c014 (f:4014) -; non-damaging, stat‐affecting or status‐causing moves? -; e.g., Meditate, Bide, Hypnosis - db $01 - db ATTACK_UP1_EFFECT - db DEFENSE_UP1_EFFECT - db SPEED_UP1_EFFECT - db SPECIAL_UP1_EFFECT - db ACCURACY_UP1_EFFECT - db EVASION_UP1_EFFECT - db ATTACK_DOWN1_EFFECT - db DEFENSE_DOWN1_EFFECT - db SPEED_DOWN1_EFFECT - db SPECIAL_DOWN1_EFFECT - db ACCURACY_DOWN1_EFFECT - db EVASION_DOWN1_EFFECT - db BIDE_EFFECT - db SLEEP_EFFECT - db ATTACK_UP2_EFFECT - db DEFENSE_UP2_EFFECT - db SPEED_UP2_EFFECT - db SPECIAL_UP2_EFFECT - db ACCURACY_UP2_EFFECT - db EVASION_UP2_EFFECT - db ATTACK_DOWN2_EFFECT - db DEFENSE_DOWN2_EFFECT - db SPEED_DOWN2_EFFECT - db SPECIAL_DOWN2_EFFECT - db ACCURACY_DOWN2_EFFECT - db EVASION_DOWN2_EFFECT - db -1 -EffectsArray4: ; 3c030 (f:4030) -; Attacks that aren't finished after they faint the opponent. - db DRAIN_HP_EFFECT - db EXPLODE_EFFECT - db DREAM_EATER_EFFECT - db PAY_DAY_EFFECT - db TWO_TO_FIVE_ATTACKS_EFFECT - db $1E - db ATTACK_TWICE_EFFECT - db RECOIL_EFFECT - db TWINEEDLE_EFFECT - db RAGE_EFFECT - db -1 -EffectsArray5: ; 3c03b (f:403b) - db DRAIN_HP_EFFECT - db EXPLODE_EFFECT - db DREAM_EATER_EFFECT - db PAY_DAY_EFFECT - db SWIFT_EFFECT - db TWO_TO_FIVE_ATTACKS_EFFECT - db $1E - db CHARGE_EFFECT - db SUPER_FANG_EFFECT - db SPECIAL_DAMAGE_EFFECT - db FLY_EFFECT - db ATTACK_TWICE_EFFECT - db JUMP_KICK_EFFECT - db RECOIL_EFFECT - ; fallthrough to Next EffectsArray -EffectsArray5B: ; 3c049 (f:4049) -; moves that prevent the player from switching moves? - db THRASH_PETAL_DANCE_EFFECT - db TRAPPING_EFFECT - db -1 - -SlidePlayerAndEnemySilhouettesOnScreen: ; 3c04c (f:404c) - call LoadPlayerBackPic - ld a, $1 ; the usual text box at the bottom of the screen - ld [wd125], a - call DisplayTextBoxID - hlCoord 1, 5 - ld bc, $307 - call ClearScreenArea - call DisableLCD - call LoadFontTilePatterns - call LoadHudAndHpBarAndStatusTilePatterns - ld hl, vBGMap0 - ld bc, $400 -.clearBackgroundLoop - ld a, $7f - ld [hli], a - dec bc - ld a, b - or c - jr nz, .clearBackgroundLoop -; copy the work RAM tile map to VRAM - ld hl, wTileMap - ld de, vBGMap0 - ld b, 18 ; number of rows -.copyRowLoop - ld c, 20 ; number of columns -.copyColumnLoop - ld a, [hli] - ld [de], a - inc e - dec c - jr nz, .copyColumnLoop - ld a, 12 ; number of off screen tiles to the right of screen in VRAM - add e ; skip the off screen tiles - ld e, a - jr nc, .noCarry - inc d -.noCarry - dec b - jr nz, .copyRowLoop - call EnableLCD - ld a, $90 - ld [hVBlankWY], a - ld [rWY], a - xor a - ld [hTilesetType], a - ld [hVBlankSCY], a - dec a - ld [wUpdateSpritesEnabled], a - call Delay3 - xor a - ld [H_AUTOBGTRANSFERENABLED], a - ld b, $70 - ld c, $90 - ld a, c - ld [hVBlankSCX], a - call DelayFrame - ld a, %11100100 ; inverted palette for silhouette effect - ld [rBGP], a - ld [rOBP0], a - ld [rOBP1], a -.slideSilhouettesLoop ; slide silhouettes of the player's pic and the enemy's pic onto the screen - ld h, b - ld l, $40 - call SetScrollXForSlidingPlayerBodyLeft ; begin background scrolling on line $40 - inc b - inc b - ld h, $0 - ld l, $60 - call SetScrollXForSlidingPlayerBodyLeft ; end background scrolling on line $60 - call SlidePlayerHeadLeft - ld a, c - ld [hVBlankSCX], a - dec c - dec c - jr nz, .slideSilhouettesLoop - ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a - ld a, $31 - ld [$ffe1], a - hlCoord 1, 5 - predef Func_3f0c6 - xor a - ld [hVBlankWY], a - ld [rWY], a - inc a - ld [H_AUTOBGTRANSFERENABLED], a - call Delay3 - ld b, $1 - call GoPAL_SET - call HideSprites - ld hl, PrintBeginningBattleText - ld b, BANK(PrintBeginningBattleText) - jp Bankswitch - -; when a battle is starting, silhouettes of the player's pic and the enemy's pic are slid onto the screen -; the lower of the player's pic (his body) is part of the background, but his head is a sprite -; the reason for this is that it shares Y coordinates with the lower part of the enemy pic, so background scrolling wouldn't work for both pics -; instead, the enemy pic is part of the background and uses the scroll register, while the player's head is a sprite and is slid by changing its X coordinates in a loop -SlidePlayerHeadLeft: ; 3c0ff (f:40ff) - push bc - ld hl, wOAMBuffer + $01 - ld c, $15 ; number of OAM entries - ld de, $4 ; size of OAM entry -.loop - dec [hl] ; decrement X - dec [hl] ; decrement X - add hl, de ; next OAM entry - dec c - jr nz, .loop - pop bc - ret - -SetScrollXForSlidingPlayerBodyLeft: ; 3c110 (f:4110) - ld a, [rLY] - cp l - jr nz, SetScrollXForSlidingPlayerBodyLeft - ld a, h - ld [rSCX], a -.loop - ld a, [rLY] - cp h - jr z, .loop - ret - -StartBattle: ; 3c11e (f:411e) - xor a - ld [wPartyGainExpFlags], a - ld [wPartyFoughtCurrentEnemyFlags], a - ld [wcd6a], a - inc a - ld [wd11d], a - ld hl, wEnemyMon1HP - ld bc, wEnemyMon2 - wEnemyMon1 - 1 - ld d, $3 -.findFirstAliveEnemyMonLoop - inc d - ld a, [hli] - or [hl] - jr nz, .foundFirstAliveEnemyMon - add hl, bc - jr .findFirstAliveEnemyMonLoop -.foundFirstAliveEnemyMon - ld a, d - ld [wcc3e], a - ld a, [W_ISINBATTLE] - dec a ; is it a trainer battle? - call nz, EnemySendOutFirstMon ; if it is a trainer battle, send out enemy mon - ld c, 40 - call DelayFrames - call SaveScreenTilesToBuffer1 -.checkAnyPartyAlive - call AnyPartyAlive - ld a, d - and a - jp z, HandlePlayerBlackOut ; jump if no mon is alive - call LoadScreenTilesFromBuffer1 - ld a, [W_BATTLETYPE] - and a ; is it a normal battle? - jp z, .playerSendOutFirstMon ; if so, send out player mon -; safari zone battle -.displaySafariZoneBattleMenu - call DisplayBattleMenu - ret c ; return if the player ran from battle - ld a, [wcd6a] - and a ; was the item used successfully? - jr z, .displaySafariZoneBattleMenu ; if not, display the menu again; XXX does this ever jump? - ld a, [W_NUMSAFARIBALLS] - and a - jr nz, .notOutOfSafariBalls - call LoadScreenTilesFromBuffer1 - ld hl, .outOfSafariBallsText - jp PrintText -.notOutOfSafariBalls - callab PrintSafariZoneBattleText - ld a, [wEnemyMonSpeed + 1] - add a - ld b, a ; init b (which is later compared with random value) to (enemy speed % 256) * 2 - jp c, EnemyRan ; if (enemy speed % 256) > 127, the enemy runs - ld a, [wSafariBaitFactor] - and a ; is bait factor 0? - jr z, .checkEscapeFactor -; bait factor is not 0 -; divide b by 4 (making the mon less likely to run) - srl b - srl b -.checkEscapeFactor - ld a, [wSafariEscapeFactor] - and a ; is escape factor 0? - jr z, .compareWithRandomValue -; escape factor is not 0 -; multiply b by 2 (making the mon more likely to run) - sla b - jr nc, .compareWithRandomValue -; cap b at 255 - ld b, $ff -.compareWithRandomValue - call Random - cp b - jr nc, .checkAnyPartyAlive - jr EnemyRan ; if b was greater than the random value, the enemy runs - -.outOfSafariBallsText - TX_FAR _OutOfSafariBallsText - db "@" - -.playerSendOutFirstMon - xor a - ld [wWhichPokemon], a -.findFirstAliveMonLoop - call HasMonFainted - jr nz, .foundFirstAliveMon -; fainted, go to the next one - ld hl, wWhichPokemon - inc [hl] - jr .findFirstAliveMonLoop -.foundFirstAliveMon - ld a, [wWhichPokemon] - ld [wPlayerMonNumber], a - inc a - ld hl, wPartySpecies - 1 - ld c, a - ld b, 0 - add hl, bc - ld a, [hl] ; species - ld [wcf91], a - ld [wBattleMonSpecies2], a - call LoadScreenTilesFromBuffer1 - hlCoord 1, 5 - ld a, $9 - call SlideTrainerPicOffScreen - call SaveScreenTilesToBuffer1 - ld a, [wWhichPokemon] - ld c, a - ld b, $1 - push bc - ld hl, wPartyGainExpFlags - predef FlagActionPredef - ld hl, wPartyFoughtCurrentEnemyFlags - pop bc - predef FlagActionPredef - call LoadBattleMonFromParty - call LoadScreenTilesFromBuffer1 - call SendOutMon - jr MainInBattleLoop - -; wild mon or link battle enemy ran from battle -EnemyRan: ; 3c202 (f:4202) - call LoadScreenTilesFromBuffer1 - ld a, [W_ISLINKBATTLE] - cp $4 - ld hl, WildRanText - jr nz, .printText -; link battle - xor a - ld [wBattleResult], a - ld hl, EnemyRanText -.printText - call PrintText - ld a, (SFX_08_44 - SFX_Headers_08) / 3 - call PlaySoundWaitForCurrent - xor a - ld [H_WHOSETURN], a - ld hl, AnimationSlideEnemyMonOut - ld b, BANK(AnimationSlideEnemyMonOut) - jp Bankswitch - -WildRanText: ; 3c229 (f:4229) - TX_FAR _WildRanText - db "@" - -EnemyRanText: ; 3c22e (f:422e) - TX_FAR _EnemyRanText - db "@" - -MainInBattleLoop: ; 3c233 (f:4233) - call ReadPlayerMonCurHPAndStatus - ld hl, wBattleMonHP - ld a, [hli] - or [hl] ; is battle mon HP 0? - jp z, HandlePlayerMonFainted ; if battle mon HP is 0, jump - ld hl, wEnemyMonHP - ld a, [hli] - or [hl] ; is enemy mon HP 0? - jp z, HandleEnemyMonFainted ; if enemy mon HP is 0, jump - call SaveScreenTilesToBuffer1 - xor a - ld [wd11d], a - ld a, [W_PLAYERBATTSTATUS2] - and %01100000 ; check if the player is using Rage or needs to recharge - jr nz, .selectEnemyMove -; the player is not using Rage and doesn't need to recharge - ld hl, W_ENEMYBATTSTATUS1 - res 3, [hl] ; reset flinch bit - ld hl, W_PLAYERBATTSTATUS1 - res 3, [hl] ; reset flinch bit - ld a, [hl] - and %00010010 ; check if the player is thrashing about or charging for an attack - jr nz, .selectEnemyMove ; if so, jump -; the player is neither thrashing about nor charging for an attack - call DisplayBattleMenu ; show battle menu - ret c ; return if player ran from battle - ld a, [wEscapedFromBattle] - and a - ret nz ; return if pokedoll was used to escape from battle - ld a, [wBattleMonStatus] - and (1 << FRZ) | SLP ; is mon frozen or asleep? - jr nz, .selectEnemyMove ; if so, jump - ld a, [W_PLAYERBATTSTATUS1] - and %00100001 ; check player is using Bide or using a multi-turn attack like wrap - jr nz, .selectEnemyMove ; if so, jump - ld a, [W_ENEMYBATTSTATUS1] - bit 5, a ; check if enemy is using a multi-turn attack like wrap - jr z, .selectPlayerMove ; if not, jump -; enemy is using a mult-turn attack like wrap, so player is trapped and cannot select a move - ld a, $ff - ld [wPlayerSelectedMove], a - jr .selectEnemyMove -.selectPlayerMove - ld a, [wcd6a] - and a - jr nz, .selectEnemyMove - ld [wMoveMenuType], a - inc a - ld [W_ANIMATIONID], a - xor a - ld [wMenuItemToSwap], a - call MoveSelectionMenu - push af - call LoadScreenTilesFromBuffer1 - call DrawHUDsAndHPBars - pop af - jr nz, MainInBattleLoop ; if the player didn't select a move, jump -.selectEnemyMove - call SelectEnemyMove - ld a, [W_ISLINKBATTLE] - cp $4 - jr nz, .noLinkBattle -; link battle - ld a, [wcc3e] - cp $f - jp z, EnemyRan - cp $e - jr z, .noLinkBattle - cp $d - jr z, .noLinkBattle - sub $4 - jr c, .noLinkBattle -; the link battle enemy has switched mons - ld a, [W_PLAYERBATTSTATUS1] - bit 5, a ; check if using multi-turn move like Wrap - jr z, .asm_3c2dd - ld a, [wPlayerMoveListIndex] - ld hl, wBattleMonMoves - ld c, a - ld b, 0 - add hl, bc - ld a, [hl] - cp METRONOME - jr nz, .asm_3c2dd - ld [wPlayerSelectedMove], a -.asm_3c2dd - callab SwitchEnemyMon -.noLinkBattle - ld a, [wPlayerSelectedMove] - cp QUICK_ATTACK - jr nz, .playerDidNotUseQuickAttack - ld a, [wEnemySelectedMove] - cp QUICK_ATTACK - jr z, .compareSpeed ; if both used Quick Attack - jp .playerMovesFirst ; if player used Quick Attack and enemy didn't -.playerDidNotUseQuickAttack - ld a, [wEnemySelectedMove] - cp QUICK_ATTACK - jr z, .enemyMovesFirst ; if enemy used Quick Attack and player didn't - ld a, [wPlayerSelectedMove] - cp COUNTER - jr nz, .playerDidNotUseCounter - ld a, [wEnemySelectedMove] - cp COUNTER - jr z, .compareSpeed ; if both used Counter - jr .enemyMovesFirst ; if player used Counter and enemy didn't -.playerDidNotUseCounter - ld a, [wEnemySelectedMove] - cp COUNTER - jr z, .playerMovesFirst ; if enemy used Counter and player didn't -.compareSpeed - ld de, wBattleMonSpeed ; player speed value - ld hl, wEnemyMonSpeed ; enemy speed value - ld c, $2 - call StringCmp ; compare speed values - jr z, .speedEqual - jr nc, .playerMovesFirst ; if player is faster - jr .enemyMovesFirst ; if enemy is faster -.speedEqual - ld a, [$ffaa] - cp $2 - jr z, .invertOutcome - call BattleRandom - cp $80 - jr c, .playerMovesFirst - jr .enemyMovesFirst -.invertOutcome - call BattleRandom - cp $80 - jr c, .enemyMovesFirst - jr .playerMovesFirst -.enemyMovesFirst - ld a, $1 - ld [H_WHOSETURN], a - callab TrainerAI - jr c, .AIActionUsedEnemyFirst - call ExecuteEnemyMove - ld a, [wEscapedFromBattle] - and a ; was Teleport, Road, or Whirlwind used to escape from battle? - ret nz ; if so, return - ld a, b - and a - jp z, HandlePlayerMonFainted -.AIActionUsedEnemyFirst - call HandlePoisonBurnLeechSeed - jp z, HandleEnemyMonFainted - call DrawHUDsAndHPBars - call ExecutePlayerMove - ld a, [wEscapedFromBattle] - and a ; was Teleport, Road, or Whirlwind used to escape from battle? - ret nz ; if so, return - ld a, b - and a - jp z, HandleEnemyMonFainted - call HandlePoisonBurnLeechSeed - jp z, HandlePlayerMonFainted - call DrawHUDsAndHPBars - call CheckNumAttacksLeft - jp MainInBattleLoop -.playerMovesFirst - call ExecutePlayerMove - ld a, [wEscapedFromBattle] - and a ; was Teleport, Road, or Whirlwind used to escape from battle? - ret nz ; if so, return - ld a, b - and a - jp z, HandleEnemyMonFainted - call HandlePoisonBurnLeechSeed - jp z, HandlePlayerMonFainted - call DrawHUDsAndHPBars - ld a, $1 - ld [H_WHOSETURN], a - callab TrainerAI - jr c, .AIActionUsedPlayerFirst - call ExecuteEnemyMove - ld a, [wEscapedFromBattle] - and a ; was Teleport, Road, or Whirlwind used to escape from battle? - ret nz ; if so, return - ld a, b - and a - jp z, HandlePlayerMonFainted -.AIActionUsedPlayerFirst - call HandlePoisonBurnLeechSeed - jp z, HandleEnemyMonFainted - call DrawHUDsAndHPBars - call CheckNumAttacksLeft - jp MainInBattleLoop - -HandlePoisonBurnLeechSeed: ; 3c3bd (f:43bd) - ld hl, wBattleMonHP - ld de, wBattleMonStatus - ld a, [H_WHOSETURN] - and a - jr z, .playersTurn - ld hl, wEnemyMonHP - ld de, wEnemyMonStatus -.playersTurn - ld a, [de] - and (1 << BRN) | (1 << PSN) - jr z, .notBurnedOrPoisoned - push hl - ld hl, HurtByPoisonText - ld a, [de] - and 1 << BRN - jr z, .poisoned - ld hl, HurtByBurnText -.poisoned - call PrintText - xor a - ld [wcc5b], a - ld a,BURN_PSN_ANIM - call PlayMoveAnimation ; play burn/poison animation - pop hl - call HandlePoisonBurnLeechSeed_DecreaseOwnHP -.notBurnedOrPoisoned - ld de, W_PLAYERBATTSTATUS2 - ld a, [H_WHOSETURN] - and a - jr z, .playersTurn2 - ld de, W_ENEMYBATTSTATUS2 -.playersTurn2 - ld a, [de] - add a - jr nc, .notLeechSeeded - push hl - ld a, [H_WHOSETURN] - push af - xor $1 - ld [H_WHOSETURN], a - xor a - ld [wcc5b], a - ld a,ABSORB - call PlayMoveAnimation ; play leech seed animation (from opposing mon) - pop af - ld [H_WHOSETURN], a - pop hl - call HandlePoisonBurnLeechSeed_DecreaseOwnHP - call HandlePoisonBurnLeechSeed_IncreaseEnemyHP - push hl - ld hl, HurtByLeechSeedText - call PrintText - pop hl -.notLeechSeeded - ld a, [hli] - or [hl] - ret nz ; test if fainted - call DrawHUDsAndHPBars - ld c, $14 - call DelayFrames - xor a - ret - -HurtByPoisonText: ; 3c42e (f:442e) - TX_FAR _HurtByPoisonText - db "@" - -HurtByBurnText: ; 3c433 (f:4433) - TX_FAR _HurtByBurnText - db "@" - -HurtByLeechSeedText: ; 3c438 (f:4438) - TX_FAR _HurtByLeechSeedText - db "@" - -; decreases the mon's current HP by 1/16 of the Max HP (multiplied by number of toxic ticks if active) -; note that the toxic ticks are considered even if the damage is not poison (hence the Leech Seed glitch) -; hl: HP pointer -; bc (out): total damage -HandlePoisonBurnLeechSeed_DecreaseOwnHP: ; 3c43d (f:443d) - push hl - push hl - ld bc, $e ; skip to max HP - add hl, bc - ld a, [hli] ; load max HP - ld [wHPBarMaxHP+1], a - ld b, a - ld a, [hl] - ld [wHPBarMaxHP], a - ld c, a - srl b - rr c - srl b - rr c - srl c - srl c ; c = max HP/16 (assumption: HP < 1024) - ld a, c - and a - jr nz, .nonZeroDamage - inc c ; damage is at least 1 -.nonZeroDamage - ld hl, W_PLAYERBATTSTATUS3 - ld de, W_PLAYERTOXICCOUNTER - ld a, [H_WHOSETURN] - and a - jr z, .playersTurn - ld hl, W_ENEMYBATTSTATUS3 - ld de, W_ENEMYTOXICCOUNTER -.playersTurn - bit 0, [hl] - jr z, .noToxic - ld a, [de] ; increment toxic counter - inc a - ld [de], a - ld hl, $0000 -.toxicTicksLoop - add hl, bc - dec a - jr nz, .toxicTicksLoop - ld b, h ; bc = damage * toxic counter - ld c, l -.noToxic - pop hl - inc hl - ld a, [hl] ; subtract total damage from current HP - ld [wHPBarOldHP], a - sub c - ld [hld], a - ld [wHPBarNewHP], a - ld a, [hl] - ld [wHPBarOldHP+1], a - sbc b - ld [hl], a - ld [wHPBarNewHP+1], a - jr nc, .noOverkill - xor a ; overkill: zero HP - ld [hli], a - ld [hl], a - ld [wHPBarNewHP], a - ld [wHPBarNewHP+1], a -.noOverkill - call UpdateCurMonHPBar - pop hl - ret - -; adds bc to enemy HP -HandlePoisonBurnLeechSeed_IncreaseEnemyHP: ; 3c4a3 (f:44a3) - push hl - ld hl, wEnemyMonMaxHP - ld a, [H_WHOSETURN] - and a - jr z, .playersTurn - ld hl, wBattleMonMaxHP -.playersTurn - ld a, [hli] - ld [wHPBarMaxHP+1], a - ld a, [hl] - ld [wHPBarMaxHP], a - ld de, $fff2 - add hl, de ; skip back fomr max hp to current hp - ld a, [hl] - ld [wHPBarOldHP], a ; add bc to current HP - add c - ld [hld], a - ld [wHPBarNewHP], a - ld a, [hl] - ld [wHPBarOldHP+1], a - adc b - ld [hli], a - ld [wHPBarNewHP+1], a - ld a, [wHPBarMaxHP] - ld c, a - ld a, [hld] - sub c - ld a, [wHPBarMaxHP+1] - ld b, a - ld a, [hl] - sbc b - jr c, .noOverfullHeal - ld a, b ; overfull heal, set HP to max HP - ld [hli], a - ld [wHPBarNewHP+1], a - ld a, c - ld [hl], a - ld [wHPBarNewHP], a -.noOverfullHeal - ld a, [H_WHOSETURN] - xor $1 - ld [H_WHOSETURN], a - call UpdateCurMonHPBar - ld a, [H_WHOSETURN] - xor $1 - ld [H_WHOSETURN], a - pop hl - ret - -UpdateCurMonHPBar: ; 3c4f6 (f:44f6) - hlCoord 10, 9 ; tile pointer to player HP bar - ld a, [H_WHOSETURN] - and a - ld a, $1 - jr z, .playersTurn - hlCoord 2, 2 ; tile pointer to enemy HP bar - xor a -.playersTurn - push bc - ld [wListMenuID], a - predef UpdateHPBar2 - pop bc - ret - -CheckNumAttacksLeft: ; 3c50f (f:450f) - ld a, [wPlayerNumAttacksLeft] - and a - jr nz, .checkEnemy -; player has 0 attacks left - ld hl, W_PLAYERBATTSTATUS1 - res 5, [hl] ; player not using multi-turn attack like wrap any more -.checkEnemy - ld a, [wEnemyNumAttacksLeft] - and a - ret nz -; enemy has 0 attacks left - ld hl, W_ENEMYBATTSTATUS1 - res 5, [hl] ; enemy not using multi-turn attack like wrap any more - ret - -HandleEnemyMonFainted: ; 3c525 (f:4525) - xor a - ld [wccf0], a - call FaintEnemyPokemon - call AnyPartyAlive - ld a, d - and a - jp z, HandlePlayerBlackOut ; if no party mons are alive, the player blacks out - ld hl, wBattleMonHP - ld a, [hli] - or [hl] ; is battle mon HP zero? - call nz, DrawPlayerHUDAndHPBar ; if battle mon HP is not zero, draw player HD and HP bar - ld a, [W_ISINBATTLE] - dec a - ret z ; return if it's a wild battle - call AnyEnemyPokemonAliveCheck - jp z, TrainerBattleVictory - ld hl, wBattleMonHP - ld a, [hli] - or [hl] ; does battle mon have 0 HP? - jr nz, .skipReplacingBattleMon ; if not, skip replacing battle mon - call DoUseNextMonDialogue ; this call is useless in a trainer battle. it shouldn't be here - ret c - call ChooseNextMon -.skipReplacingBattleMon - ld a, $1 - ld [wcd6a], a - call ReplaceFaintedEnemyMon - jp z, EnemyRan - xor a - ld [wcd6a], a - jp MainInBattleLoop - -FaintEnemyPokemon ; 0x3c567 - call ReadPlayerMonCurHPAndStatus - ld a, [W_ISINBATTLE] - dec a - jr z, .wild - ld a, [wEnemyMonPartyPos] - ld hl, wEnemyMon1HP - ld bc, wEnemyMon2 - wEnemyMon1 - call AddNTimes - xor a - ld [hli], a - ld [hl], a -.wild - ld hl, W_PLAYERBATTSTATUS1 - res 2, [hl] - xor a - ld [W_NUMHITS], a - ld hl, wd065 ; enemy statuses - ld [hli], a - ld [hli], a - ld [hli], a - ld [hli], a - ld [hl], a - ld [W_ENEMYDISABLEDMOVE], a - ld [wccef], a - ld [wccf3], a - ld hl, wccf1 - ld [hli], a - ld [hl], a - hlCoord 12, 5 - deCoord 12, 6 - call SlideDownFaintedMonPic - ld hl, wTileMap - ld bc, $40b - call ClearScreenArea - ld a, [W_ISINBATTLE] - dec a - jr z, .wild_win - xor a - ld [wc0f1], a - ld [wc0f2], a - ld a, (SFX_08_48 - SFX_Headers_08) / 3 ; SFX_FALL? - call PlaySoundWaitForCurrent -.sfxwait - ld a, [wc02a] - cp (SFX_08_48 - SFX_Headers_08) / 3 - jr z, .sfxwait - ld a, (SFX_08_43 - SFX_Headers_08) / 3 ; SFX_DROP - call PlaySound - call WaitForSoundToFinish - jr .sfxplayed -.wild_win - call Func_3c643 - ld a, MUSIC_DEFEATED_WILD_MON - call PlayBattleVictoryMusic -.sfxplayed - ld hl, wBattleMonHP - ld a, [hli] - or [hl] - jr nz, .playermonnotfaint - ld a, [wccf0] - and a - jr nz, .playermonnotfaint - call RemoveFaintedPlayerMon -.playermonnotfaint - call AnyPartyAlive - ld a, d - and a - ret z - ld hl, EnemyMonFaintedText - call PrintText - call PrintEmptyString - call SaveScreenTilesToBuffer1 - xor a - ld [wBattleResult], a - ld b, EXP__ALL - call IsItemInBag - push af - jr z, .giveExpToMonsThatFought ; if no exp all, then jump - -; the player has exp all -; first, we halve the values that determine exp gain -; the enemy mon base stats are added to stat exp, so they are halved -; the base exp (which determines normal exp) is also halved - ld hl, wEnemyMonBaseStats - ld b, $7 -.halveExpDataLoop - srl [hl] - inc hl - dec b - jr nz, .halveExpDataLoop - -; give exp (divided evenly) to the mons that actually fought in battle against the enemy mon that has fainted -; if exp all is in the bag, this will be only be half of the stat exp and normal exp, due to the above loop -.giveExpToMonsThatFought - xor a - ld [wcc5b], a - callab GainExperience - pop af - ret z ; return if no exp all - -; the player has exp all -; now, set the gain exp flag for every party member -; half of the total stat exp and normal exp will divided evenly amongst every party member - ld a, $1 - ld [wcc5b], a - ld a, [wPartyCount] - ld b, 0 -.gainExpFlagsLoop - scf - rl b - dec a - jr nz, .gainExpFlagsLoop - ld a, b - ld [wPartyGainExpFlags], a - ld hl, GainExperience - ld b, BANK(GainExperience) - jp Bankswitch - -EnemyMonFaintedText: ; 0x3c63e - TX_FAR _EnemyMonFaintedText - db "@" - -Func_3c643: ; 3c643 (f:4643) - xor a - ld [wd083], a - ld [wc02a], a - inc a - ld [wccf6], a - ret - -AnyEnemyPokemonAliveCheck: ; 3c64f (f:464f) - ld a, [wEnemyPartyCount] - ld b, a - xor a - ld hl, wEnemyMon1HP - ld de, $2c -.asm_3c65a - or [hl] - inc hl - or [hl] - dec hl - add hl, de - dec b - jr nz, .asm_3c65a - and a - ret - -; stores whether enemy ran in Z flag -ReplaceFaintedEnemyMon: ; 3c664 (f:4664) - ld hl, wcf1e - ld e, $30 - call GetBattleHealthBarColor - callab DrawEnemyPokeballs - ld a, [W_ISLINKBATTLE] - cp $4 - jr nz, .asm_3c687 -; link battle - call LinkBattleExchangeData - ld a, [wcc3e] - cp $f - ret z - call LoadScreenTilesFromBuffer1 -.asm_3c687 - call EnemySendOut - xor a - ld [W_ENEMYMOVENUM], a - ld [wcd6a], a - ld [wccd5], a - inc a ; reset Z flag - ret - -TrainerBattleVictory: ; 3c696 (f:4696) - call Func_3c643 - ld b, MUSIC_DEFEATED_GYM_LEADER - ld a, [W_GYMLEADERNO] - and a - jr nz, .gymleader - ld b, MUSIC_DEFEATED_TRAINER -.gymleader - ld a, [W_TRAINERCLASS] - cp SONY3 ; final battle against rival - jr nz, .notrival - ld b, MUSIC_DEFEATED_GYM_LEADER - ld hl, W_FLAGS_D733 - set 1, [hl] -.notrival - ld a, [W_ISLINKBATTLE] - cp $4 - ld a, b - call nz, PlayBattleVictoryMusic - ld hl, TrainerDefeatedText - call PrintText - ld a, [W_ISLINKBATTLE] - cp $4 - ret z - call ScrollTrainerPicAfterBattle - ld c, $28 - call DelayFrames - call PrintEndBattleText - ld hl, MoneyForWinningText - call PrintText - ld de, wPlayerMoney + 2 - ld hl, wd07b - ld c, $3 - predef_jump AddBCDPredef - -MoneyForWinningText: ; 3c6e4 (f:46e4) - TX_FAR _MoneyForWinningText - db "@" - -TrainerDefeatedText: ; 3c6e9 (f:46e9) - TX_FAR _TrainerDefeatedText - db "@" - -PlayBattleVictoryMusic: ; 3c6ee (f:46ee) - push af - ld a, $ff - ld [wc0ee], a - call PlaySoundWaitForCurrent - ld c, BANK(Music_DefeatedTrainer) - pop af - call PlayMusic - jp Delay3 - -HandlePlayerMonFainted: ; 3c700 (f:4700) - ld a, $1 - ld [wccf0], a - call RemoveFaintedPlayerMon - call AnyPartyAlive ; test if any more mons are alive - ld a, d - and a - jp z, HandlePlayerBlackOut - ld hl, wEnemyMonHP - ld a, [hli] - or [hl] ; is enemy mon's HP 0? - jr nz, .doUseNextMonDialogue ; if not, jump -; the enemy mon has 0 HP - call FaintEnemyPokemon - ld a, [W_ISINBATTLE] - dec a - ret z ; if wild encounter, battle is over - call AnyEnemyPokemonAliveCheck - jp z, TrainerBattleVictory -.doUseNextMonDialogue - call DoUseNextMonDialogue - ret c ; return if the player ran from battle - call ChooseNextMon - jp nz, MainInBattleLoop ; if the enemy mon has more than 0 HP, go back to battle loop -; the enemy mon has 0 HP - ld a, $1 - ld [wcd6a], a - call ReplaceFaintedEnemyMon - jp z, EnemyRan ; if enemy ran from battle rather than sending out another mon, jump - xor a - ld [wcd6a], a - jp MainInBattleLoop - -; resets flags, slides mon's pic down, plays cry, and prints fainted message -RemoveFaintedPlayerMon: ; 3c741 (f:4741) - ld a, [wPlayerMonNumber] - ld c, a - ld hl, wPartyGainExpFlags - ld b, $0 - predef FlagActionPredef ; clear gain exp flag for fainted mon - ld hl, W_ENEMYBATTSTATUS1 - res 2, [hl] ; reset "attacking multiple times" flag - ld a, [wd083] - bit 7, a ; skip sound flag (red bar (?)) - jr z, .skipWaitForSound - ld a, $ff - ld [wd083], a - call WaitForSoundToFinish -.skipWaitForSound - ld hl, wcd05 - ld [hli], a - ld [hl], a - ld [wBattleMonStatus], a - call ReadPlayerMonCurHPAndStatus - hlCoord 9, 7 - ld bc, $50b - call ClearScreenArea - hlCoord 1, 10 - deCoord 1, 11 - call SlideDownFaintedMonPic - ld a, $1 - ld [wBattleResult], a - ld a, [wccf0] - and a - ret z - ld a, [wBattleMonSpecies] - call PlayCry - ld hl, PlayerMonFaintedText - jp PrintText - -PlayerMonFaintedText: ; 3c796 (f:4796) - TX_FAR _PlayerMonFaintedText - db "@" - -; asks if you want to use next mon -; stores whether you ran in C flag -DoUseNextMonDialogue: ; 3c79b (f:479b) - call PrintEmptyString - call SaveScreenTilesToBuffer1 - ld a, [W_ISINBATTLE] - and a - dec a - ret nz ; return if it's a trainer battle - ld hl, UseNextMonText - call PrintText -.displayYesNoBox - hlCoord 13, 9 - ld bc, $a0e - ld a, $14 ; yes/no text box - ld [wd125], a - call DisplayTextBoxID - ld a, [wd12e] - cp $2 ; did the player choose NO? - jr z, .tryRunning ; if the player chose NO, try running - and a ; reset carry - ret -.tryRunning - ld a, [wCurrentMenuItem] - and a - jr z, .displayYesNoBox ; xxx when does this happen? - ld hl, wPartyMon1Speed - ld de, wEnemyMonSpeed - jp TryRunningFromBattle - -UseNextMonText: ; 3c7d3 (f:47d3) - TX_FAR _UseNextMonText - db "@" - -; choose next player mon to send out -; stores whether enemy mon has no HP left in Z flag -ChooseNextMon: ; 3c7d8 (f:47d8) - ld a, $2 - ld [wd07d], a - call DisplayPartyMenu -.checkIfMonChosen - jr nc, .monChosen -.goBackToPartyMenu - call GoBackToPartyMenu - jr .checkIfMonChosen -.monChosen - call HasMonFainted - jr z, .goBackToPartyMenu ; if mon fainted, you have to choose another - ld a, [W_ISLINKBATTLE] - cp $4 - jr nz, .asm_3c7fa - inc a - ld [wcd6a], a - call LinkBattleExchangeData -.asm_3c7fa - xor a - ld [wcd6a], a - call ClearSprites - ld a, [wWhichPokemon] - ld [wPlayerMonNumber], a - ld c, a - ld hl, wPartyGainExpFlags - ld b, $1 - push bc - predef FlagActionPredef - pop bc - ld hl, wPartyFoughtCurrentEnemyFlags - predef FlagActionPredef - call LoadBattleMonFromParty - call GBPalWhiteOut - call LoadHudTilePatterns - call LoadScreenTilesFromBuffer1 - call GoPAL_SET_CF1C - call GBPalNormal - call SendOutMon - ld hl, wEnemyMonHP - ld a, [hli] - or [hl] - ret - -; called when player is out of usable mons. -; prints approriate lose message, sets carry flag if player blacked out (special case for initial rival fight) -HandlePlayerBlackOut: ; 3c837 (f:4837) - ld a, [W_ISLINKBATTLE] - cp $4 - jr z, .notSony1Battle - ld a, [W_CUROPPONENT] - cp $c8 + SONY1 - jr nz, .notSony1Battle - ld hl, wTileMap ; sony 1 battle - ld bc, $815 - call ClearScreenArea - call ScrollTrainerPicAfterBattle - ld c, $28 - call DelayFrames - ld hl, Sony1WinText - call PrintText - ld a, [W_CURMAP] - cp OAKS_LAB - ret z ; starter battle in oak's lab: don't black out -.notSony1Battle - ld b, $0 - call GoPAL_SET - ld hl, PlayerBlackedOutText2 - ld a, [W_ISLINKBATTLE] - cp $4 - jr nz, .noLinkBattle - ld hl, LinkBattleLostText -.noLinkBattle - call PrintText - ld a, [wd732] - res 5, a - ld [wd732], a - call ClearScreen - scf - ret - -Sony1WinText: ; 3c884 (f:4884) - TX_FAR _Sony1WinText - db "@" - -PlayerBlackedOutText2: ; 3c889 (f:4889) - TX_FAR _PlayerBlackedOutText2 - db "@" - -LinkBattleLostText: ; 3c88e (f:488e) - TX_FAR _LinkBattleLostText - db "@" - -; slides pic of fainted mon downwards until it disappears -; bug: when this is called, [H_AUTOBGTRANSFERENABLED] is non-zero, so there is screen tearing -SlideDownFaintedMonPic: ; 3c893 (f:4893) - ld a, [wd730] - push af - set 6, a - ld [wd730], a - ld b, 7 ; number of times to slide -.slideStepLoop ; each iteration, the mon is slid down one row - push bc - push de - push hl - ld b, 6 ; number of rows -.rowLoop - push bc - push hl - push de - ld bc, $7 - call CopyData - pop de - pop hl - ld bc, -20 - add hl, bc - push hl - ld h, d - ld l, e - add hl, bc - ld d, h - ld e, l - pop hl - pop bc - dec b - jr nz, .rowLoop - ld bc, 20 - add hl, bc - ld de, SevenSpacesText - call PlaceString - ld c, 2 - call DelayFrames - pop hl - pop de - pop bc - dec b - jr nz, .slideStepLoop - pop af - ld [wd730], a - ret - -SevenSpacesText: ; 3c8d7 (f:48d7) - db " @" - -; slides the player or enemy trainer off screen -; a is the number of tiles to slide it horizontally (always 9 for the player trainer or 8 for the enemy trainer) -; if a is 8, the slide is to the right, else it is to the left -; bug: when this is called, [H_AUTOBGTRANSFERENABLED] is non-zero, so there is screen tearing -SlideTrainerPicOffScreen: ; 3c8df (f:48df) - ld [$FF8B], a - ld c, a -.slideStepLoop ; each iteration, the trainer pic is slid one tile left/right - push bc - push hl - ld b, 7 ; number of rows -.rowLoop - push hl - ld a, [$FF8B] - ld c, a -.columnLoop - ld a, [$FF8B] - cp 8 - jr z, .slideRight -.slideLeft ; slide player sprite off screen - ld a, [hld] - ld [hli], a - inc hl - jr .nextColumn -.slideRight ; slide enemy trainer sprite off screen - ld a, [hli] - ld [hld], a - dec hl -.nextColumn - dec c - jr nz, .columnLoop - pop hl - ld de, 20 - add hl, de - dec b - jr nz, .rowLoop - ld c, 2 - call DelayFrames - pop hl - pop bc - dec c - jr nz, .slideStepLoop - ret - -; send out a trainer's mon -EnemySendOut: ; 3c90e (f:490e) - ld hl,wPartyGainExpFlags - xor a - ld [hl],a - ld a,[wPlayerMonNumber] - ld c,a - ld b,1 - push bc - predef FlagActionPredef - ld hl,wPartyFoughtCurrentEnemyFlags - xor a - ld [hl],a - pop bc - predef FlagActionPredef - -; don't change wPartyGainExpFlags or wPartyFoughtCurrentEnemyFlags -EnemySendOutFirstMon: ; 3c92a (f:492a) - xor a - ld hl,wd065 - ld [hli],a - ld [hli],a - ld [hli],a - ld [hli],a - ld [hl],a - ld [W_ENEMYDISABLEDMOVE],a - ld [wccef],a - ld [wccf3],a - ld hl,wccf1 - ld [hli],a - ld [hl],a - dec a - ld [wAICount],a - ld hl,W_PLAYERBATTSTATUS1 - res 5,[hl] - hlCoord 18, 0 - ld a,8 - call SlideTrainerPicOffScreen - call PrintEmptyString - call SaveScreenTilesToBuffer1 - ld a,[W_ISLINKBATTLE] - cp 4 - jr nz,.next - ld a,[wcc3e] - sub 4 - ld [wWhichPokemon],a - jr .next3 -.next - ld b,$FF -.next2 - inc b - ld a,[wEnemyMonPartyPos] - cp b - jr z,.next2 - ld hl,wEnemyMon1 - ld a,b - ld [wWhichPokemon],a - push bc - ld bc,wEnemyMon2 - wEnemyMon1 - call AddNTimes - pop bc - inc hl - ld a,[hli] - ld c,a - ld a,[hl] - or c - jr z,.next2 -.next3 - ld a,[wWhichPokemon] - ld hl,wEnemyMon1Level - ld bc,wEnemyMon2 - wEnemyMon1 - call AddNTimes - ld a,[hl] - ld [W_CURENEMYLVL],a - ld a,[wWhichPokemon] - inc a - ld hl,wEnemyPartyCount - ld c,a - ld b,0 - add hl,bc - ld a,[hl] - ld [wEnemyMonSpecies2],a - ld [wcf91],a - call LoadEnemyMonData - ld hl,wEnemyMonHP - ld a,[hli] - ld [wcce3],a - ld a,[hl] - ld [wcce4],a - ld a,1 - ld [wCurrentMenuItem],a - ld a,[wd11d] - dec a - jr z,.next4 - ld a,[wPartyCount] - dec a - jr z,.next4 - ld a,[W_ISLINKBATTLE] - cp 4 - jr z,.next4 - ld a,[W_OPTIONS] - bit 6,a - jr nz,.next4 - ld hl, TrainerAboutToUseText - call PrintText - hlCoord 0, 7 - ld bc,$0801 - ld a,$14 - ld [wd125],a - call DisplayTextBoxID - ld a,[wCurrentMenuItem] - and a - jr nz,.next4 - ld a,2 - ld [wd07d],a - call DisplayPartyMenu -.next9 - ld a,1 - ld [wCurrentMenuItem],a - jr c,.next7 - ld hl,wPlayerMonNumber - ld a,[wWhichPokemon] - cp [hl] - jr nz,.next6 - ld hl,AlreadyOutText - call PrintText -.next8 - call GoBackToPartyMenu - jr .next9 -.next6 - call HasMonFainted - jr z,.next8 - xor a - ld [wCurrentMenuItem],a -.next7 - call GBPalWhiteOut - call LoadHudTilePatterns - call LoadScreenTilesFromBuffer1 -.next4 - call ClearSprites - ld hl,wTileMap - ld bc,$040B - call ClearScreenArea - ld b,1 - call GoPAL_SET - call GBPalNormal - ld hl,TrainerSentOutText - call PrintText - ld a,[wEnemyMonSpecies2] - ld [wcf91],a - ld [wd0b5],a - call GetMonHeader - ld de,vFrontPic - call LoadMonFrontSprite - ld a,$CF - ld [$FFE1],a - hlCoord 15, 6 - predef Func_3f073 - ld a,[wEnemyMonSpecies2] - call PlayCry - call DrawEnemyHUDAndHPBar - ld a,[wCurrentMenuItem] - and a - ret nz - xor a - ld [wPartyGainExpFlags],a - ld [wPartyFoughtCurrentEnemyFlags],a - call SaveScreenTilesToBuffer1 - jp SwitchPlayerMon - -TrainerAboutToUseText: ; 3ca79 (f:4a79) - TX_FAR _TrainerAboutToUseText - db "@" - -TrainerSentOutText: ; 3ca7e (f:4a7e) - TX_FAR _TrainerSentOutText - db "@" - -; tests if the player has any pokemon that are not fainted -; sets d = 0 if all fainted, d != 0 if some mons are still alive -AnyPartyAlive: ; 3ca83 (f:4a83) - ld a, [wPartyCount] - ld e, a - xor a - ld hl, wPartyMon1HP - ld bc, wPartyMon2 - wPartyMon1 - 1 -.partyMonsLoop - or [hl] - inc hl - or [hl] - add hl, bc - dec e - jr nz, .partyMonsLoop - ld d, a - ret - -; tests if player mon has fainted -; stores whether mon has fainted in Z flag -HasMonFainted: ; 3ca97 (f:4a97) - ld a, [wWhichPokemon] - ld hl, wPartyMon1HP - ld bc, wPartyMon2 - wPartyMon1 - call AddNTimes - ld a, [hli] - or [hl] - ret nz - ld a, [wd11d] - and a - jr nz, .done - ld hl, NoWillText - call PrintText -.done - xor a - ret - -NoWillText: ; 3cab4 (f:4ab4) - TX_FAR _NoWillText - db "@" - -; try to run from battle (hl = player speed, de = enemy speed) -; stores whether the attempt was successful in carry flag -TryRunningFromBattle: ; 3cab9 (f:4ab9) - call IsGhostBattle - jp z, .canEscape ; jump if it's a ghost battle - ld a, [W_BATTLETYPE] - cp $2 - jp z, .canEscape ; jump if it's a safari battle - ld a, [W_ISLINKBATTLE] - cp $4 - jp z, .canEscape - ld a, [W_ISINBATTLE] - dec a - jr nz, .trainerBattle ; jump if it's a trainer battle - ld a, [wNumRunAttempts] - inc a - ld [wNumRunAttempts], a - ld a, [hli] - ld [H_MULTIPLICAND + 1], a - ld a, [hl] - ld [H_MULTIPLICAND + 2], a - ld a, [de] - ld [$ff8d], a - inc de - ld a, [de] - ld [$ff8e], a - call LoadScreenTilesFromBuffer1 - ld de, H_MULTIPLICAND + 1 - ld hl, $ff8d - ld c, $2 - call StringCmp - jr nc, .canEscape ; jump if player speed greater than enemy speed - xor a - ld [H_MULTIPLICAND], a - ld a, 32 - ld [H_MULTIPLIER], a - call Multiply ; multiply player speed by 32 - ld a, [H_PRODUCT + 2] - ld [H_DIVIDEND], a - ld a, [H_PRODUCT + 3] - ld [H_DIVIDEND + 1], a - ld a, [$ff8d] - ld b, a - ld a, [$ff8e] -; divide enemy speed by 4 - srl b - rr a - srl b - rr a - and a - jr z, .canEscape ; jump if enemy speed divided by 4, mod 256 is 0 - ld [H_DIVISOR], a ; ((enemy speed / 4) % 256) - ld b, $2 - call Divide ; divide (player speed * 32) by ((enemy speed / 4) % 256) - ld a, [H_QUOTIENT + 2] - and a ; is the quotient greater than 256? - jr nz, .canEscape ; if so, the player can escape - ld a, [wNumRunAttempts] - ld c, a -; add 30 to the quotient for each run attempt -.loop - dec c - jr z, .compareWithRandomValue - ld b, 30 - ld a, [H_QUOTIENT + 3] - add b - ld [H_QUOTIENT + 3], a - jr c, .canEscape - jr .loop -.compareWithRandomValue - call BattleRandom - ld b, a - ld a, [H_QUOTIENT + 3] - cp b - jr nc, .canEscape ; if the random value was less than or equal to the quotient plus 30 times the number of attempts, the player can escape -; can't escape - ld a, $1 - ld [wcd6a], a - ld hl, CantEscapeText - jr .printCantEscapeOrNoRunningText -.trainerBattle - ld hl, NoRunningText -.printCantEscapeOrNoRunningText - call PrintText - ld a, $1 - ld [wd11f], a - call SaveScreenTilesToBuffer1 - and a ; reset carry - ret -.canEscape - ld a, [W_ISLINKBATTLE] - cp $4 - ld a, $2 - jr nz, .playSound -; link battle - call SaveScreenTilesToBuffer1 - xor a - ld [wcd6a], a - ld a, $f - ld [wPlayerMoveListIndex], a - call LinkBattleExchangeData - call LoadScreenTilesFromBuffer1 - ld a, [wcc3e] - cp $f - ld a, $2 - jr z, .playSound - dec a -.playSound - ld [wBattleResult], a - ld a, (SFX_08_44 - SFX_Headers_08) / 3 - call PlaySoundWaitForCurrent - ld hl, GotAwayText - call PrintText - call WaitForSoundToFinish - call SaveScreenTilesToBuffer1 - scf ; set carry - ret - -CantEscapeText: ; 3cb97 (f:4b97) - TX_FAR _CantEscapeText - db "@" - -NoRunningText: ; 3cb9c (f:4b9c) - TX_FAR _NoRunningText - db "@" - -GotAwayText: ; 3cba1 (f:4ba1) - TX_FAR _GotAwayText - db "@" - -; copies from party data to battle mon data when sending out a new player mon -LoadBattleMonFromParty: ; 3cba6 (f:4ba6) - ld a, [wWhichPokemon] - ld bc, $2c - ld hl, wPartyMon1Species - call AddNTimes - ld de, wBattleMonSpecies - ld bc, $c - call CopyData - ld bc, $f - add hl, bc - ld de, wBattleMonDVs - ld bc, $2 - call CopyData - ld de, wBattleMonPP - ld bc, $4 - call CopyData - ld de, wBattleMonLevel - ld bc, $b - call CopyData - ld a, [wBattleMonSpecies2] - ld [wd0b5], a - call GetMonHeader - ld hl, wPartyMonNicks - ld a, [wPlayerMonNumber] - call SkipFixedLengthTextEntries - ld de, wBattleMonNick - ld bc, $b - call CopyData - ld hl, wBattleMonLevel - ld de, wPlayerMonUnmodifiedLevel ; block of memory used for unmodified stats - ld bc, $b - call CopyData - call ApplyBurnAndParalysisPenaltiesToPlayer - call ApplyBadgeStatBoosts - ld a, $7 ; default stat modifier - ld b, $8 - ld hl, wPlayerMonAttackMod -.statModLoop - ld [hli], a - dec b - jr nz, .statModLoop - ret - -; copies from enemy party data to current enemy mon data when sending out a new enemy mon -LoadEnemyMonFromParty: ; 3cc13 (f:4c13) - ld a, [wWhichPokemon] - ld bc, $2c - ld hl, wEnemyMons - call AddNTimes - ld de, wEnemyMonSpecies - ld bc, $c - call CopyData - ld bc, $f - add hl, bc - ld de, wEnemyMonDVs - ld bc, $2 - call CopyData - ld de, wEnemyMonPP - ld bc, $4 - call CopyData - ld de, wEnemyMonLevel - ld bc, $b - call CopyData - ld a, [wEnemyMonSpecies] - ld [wd0b5], a - call GetMonHeader - ld hl, wEnemyMonNicks - ld a, [wWhichPokemon] - call SkipFixedLengthTextEntries - ld de, wEnemyMonNick - ld bc, $b - call CopyData - ld hl, wEnemyMonLevel - ld de, wEnemyMonUnmodifiedLevel ; block of memory used for unmodified stats - ld bc, $b - call CopyData - call ApplyBurnAndParalysisPenaltiesToEnemy - ld hl, W_MONHBASESTATS - ld de, wEnemyMonBaseStats - ld b, $5 -.copyBaseStatsLoop - ld a, [hli] - ld [de], a - inc de - dec b - jr nz, .copyBaseStatsLoop - ld a, $7 ; default stat modifier - ld b, $8 - ld hl, wEnemyMonStatMods -.statModLoop - ld [hli], a - dec b - jr nz, .statModLoop - ld a, [wWhichPokemon] - ld [wEnemyMonPartyPos], a - ret - -SendOutMon: ; 3cc91 (f:4c91) - callab PrintSendOutMonMessage - ld hl, wEnemyMonHP - ld a, [hli] - or [hl] ; is enemy mon HP zero? - jp z, .skipDrawingEnemyHUDAndHPBar; if HP is zero, skip drawing the HUD and HP bar - call DrawEnemyHUDAndHPBar -.skipDrawingEnemyHUDAndHPBar - call DrawPlayerHUDAndHPBar - predef LoadMonBackPic - xor a - ld [$ffe1], a - ld hl, wcc2d - ld [hli], a - ld [hl], a - ld [wcc5b], a - ld [wd05b], a - ld [W_PLAYERMOVENUM], a - ld hl, wccf1 - ld [hli], a - ld [hl], a - ld hl, wd060 - ld [hli], a - ld [hli], a - ld [hli], a - ld [hli], a - ld [hl], a - ld [W_PLAYERDISABLEDMOVE], a - ld [wccee], a - ld [wccf7], a - ld b, $1 - call GoPAL_SET - ld hl, W_ENEMYBATTSTATUS1 - res 5, [hl] - ld a, $1 - ld [H_WHOSETURN], a - ld a, POOF_ANIM - call PlayMoveAnimation - hlCoord 4, 11 - predef Func_3f073 - ld a, [wcf91] - call PlayCry - call PrintEmptyString - jp SaveScreenTilesToBuffer1 - -; show 2 stages of the player getting smaller before disappearing -AnimateRetreatingPlayerMon: ; 3ccfa (f:4cfa) - hlCoord 1, 5 - ld bc, $707 - call ClearScreenArea - hlCoord 3, 7 - ld bc, $505 - xor a - ld [wcd6c], a - ld [H_DOWNARROWBLINKCNT1], a - predef Func_79aba - ld c, $4 - call DelayFrames - call .clearScreenArea - hlCoord 4, 9 - ld bc, $303 - ld a, $1 - ld [wcd6c], a - xor a - ld [H_DOWNARROWBLINKCNT1], a - predef Func_79aba - call Delay3 - call .clearScreenArea - ld a, $4c - Coorda 5, 11 -.clearScreenArea - hlCoord 1, 5 - ld bc, $707 - jp ClearScreenArea - -; reads player's current mon's HP into wBattleMonHP -ReadPlayerMonCurHPAndStatus: ; 3cd43 (f:4d43) - ld a, [wPlayerMonNumber] - ld hl, wPartyMon1HP - ld bc, wPartyMon2 - wPartyMon1 - call AddNTimes - ld d, h - ld e, l - ld hl, wBattleMonHP - ld bc, $4 ; 2 bytes HP, 1 byte unknown (unused?), 1 byte status - jp CopyData - -DrawHUDsAndHPBars: ; 3cd5a (f:4d5a) - call DrawPlayerHUDAndHPBar - jp DrawEnemyHUDAndHPBar - -DrawPlayerHUDAndHPBar: ; 3cd60 (f:4d60) - xor a - ld [H_AUTOBGTRANSFERENABLED], a - hlCoord 9, 7 - ld bc, $50b - call ClearScreenArea - callab PlacePlayerHUDTiles - hlCoord 18, 9 - ld [hl], $73 - ld de, wBattleMonNick - hlCoord 10, 7 - call CenterMonName - call PlaceString - ld hl, wBattleMonSpecies - ld de, wcf98 - ld bc, $c - call CopyData - ld hl, wBattleMonLevel - ld de, wcfb9 - ld bc, $b - call CopyData - hlCoord 14, 8 - push hl - inc hl - ld de, wcf9c - call PrintStatusConditionNotFainted - pop hl - jr nz, .asm_3cdae - call PrintLevel -.asm_3cdae - ld a, [wcf98] - ld [wcf91], a - hlCoord 10, 9 - predef DrawHP - ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a - ld hl, wcf1d - call GetBattleHealthBarColor - ld hl, wBattleMonHP - ld a, [hli] - or [hl] - jr z, .asm_3cdd9 - ld a, [wccf6] - and a - ret nz - ld a, [wcf1d] - cp $2 - jr z, .asm_3cde6 -.asm_3cdd9 - ld hl, wd083 - bit 7, [hl] - ld [hl], $0 - ret z - xor a - ld [wc02a], a - ret -.asm_3cde6 - ld hl, wd083 - set 7, [hl] - ret - -DrawEnemyHUDAndHPBar: ; 3cdec (f:4dec) - xor a - ld [H_AUTOBGTRANSFERENABLED], a - ld hl, wTileMap - ld bc, $40c - call ClearScreenArea - callab PlaceEnemyHUDTiles - ld de, wEnemyMonNick - hlCoord 1, 0 - call CenterMonName - call PlaceString - hlCoord 4, 1 - push hl - inc hl - ld de, wEnemyMonStatus - call PrintStatusConditionNotFainted - pop hl - jr nz, .skipPrintLevel ; if the mon has a status condition, skip printing the level - ld a, [wEnemyMonLevel] - ld [wcfb9], a - call PrintLevel -.skipPrintLevel - ld hl, wEnemyMonHP - ld a, [hli] - ld [H_MULTIPLICAND + 1], a - ld a, [hld] - ld [H_MULTIPLICAND + 2], a - or [hl] ; is current HP zero? - jr nz, .hpNonzero -; current HP is 0 -; set variables for DrawHPBar - ld c, a - ld e, a - ld d, $6 - jp .drawHPBar -.hpNonzero - xor a - ld [H_MULTIPLICAND], a - ld a, 48 - ld [H_MULTIPLIER], a - call Multiply ; multiply current HP by 48 - ld hl, wEnemyMonMaxHP - ld a, [hli] - ld b, a - ld a, [hl] - ld [H_DIVISOR], a - ld a, b - and a ; is max HP > 255? - jr z, .doDivide -; if max HP > 255, scale both (current HP * 48) and max HP by dividing by 4 so that max HP fits in one byte -; (it needs to be one byte so it can be used as the divisor for the Divide function) - ld a, [H_DIVISOR] - srl b - rr a - srl b - rr a - ld [H_DIVISOR], a - ld a, [H_PRODUCT + 2] - ld b, a - srl b - ld a, [H_PRODUCT + 3] - rr a - srl b - rr a - ld [H_PRODUCT + 3], a - ld a, b - ld [H_PRODUCT + 2], a -.doDivide - ld a, [H_PRODUCT + 2] - ld [H_DIVIDEND], a - ld a, [H_PRODUCT + 3] - ld [H_DIVIDEND + 1], a - ld a, $2 - ld b, a - call Divide ; divide (current HP * 48) by max HP - ld a, [H_QUOTIENT + 3] -; set variables for DrawHPBar - ld e, a - ld a, $6 - ld d, a - ld c, a -.drawHPBar - xor a - ld [wListMenuID], a - hlCoord 2, 2 - call DrawHPBar - ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a - ld hl, wcf1e - -GetBattleHealthBarColor: ; 3ce90 (f:4e90) - ld b, [hl] - call GetHealthBarColor - ld a, [hl] - cp b - ret z - ld b, $1 - jp GoPAL_SET - -; center's mon's name on the battle screen -; if the name is 1 or 2 letters long, it is printed 2 spaces more to the right than usual (i.e. for names longer than 4 letters) -; if the name is 3 or 4 letters long, it is printed 1 space more to the right than usual (i.e. for names longer than 4 letters) -CenterMonName: ; 3ce9c (f:4e9c) - push de - inc hl - inc hl - ld b, $2 -.loop - inc de - ld a, [de] - cp $50 - jr z, .done - inc de - ld a, [de] - cp $50 - jr z, .done - dec hl - dec b - jr nz, .loop -.done - pop de - ret - -DisplayBattleMenu: ; 3ceb3 (f:4eb3) - call LoadScreenTilesFromBuffer1 ; restore saved screen - ld a, [W_BATTLETYPE] - and a - jr nz, .nonstandardbattle - call DrawHUDsAndHPBars - call PrintEmptyString - call SaveScreenTilesToBuffer1 -.nonstandardbattle - ld a, [W_BATTLETYPE] - cp $2 ; safari - ld a, $b ; safari menu id - jr nz, .menuselected - ld a, $1b ; regular menu id -.menuselected - ld [wd125], a - call DisplayTextBoxID - ld a, [W_BATTLETYPE] - dec a - jp nz, .handleBattleMenuInput ; handle menu input if it's not the old man tutorial -; the following happens for the old man tutorial - ld hl, wPlayerName - ld de, W_GRASSRATE - ld bc, $b - call CopyData ; temporarily save the player name in unused space, - ; which is supposed to get overwritten when entering a - ; map with wild pokémon. due to an oversight, the data - ; may not get overwritten (cinnabar) and the infamous - ; missingno. glitch can show up. - ld hl, .oldManName - ld de, wPlayerName - ld bc, $b - call CopyData - ; the following simulates the keystrokes by drawing menus on screen - hlCoord 9, 14 - ld [hl], "▶" - ld c, $50 - call DelayFrames - ld [hl], $7f - hlCoord 9, 16 - ld [hl], "▶" - ld c, $32 - call DelayFrames - ld [hl], $ec - ld a, $2 ; select the "ITEM" menu - jp .upperLeftMenuItemWasNotSelected -.oldManName - db "OLD MAN@" -.handleBattleMenuInput - ld a, [wcc2d] - ld [wCurrentMenuItem], a - ld [wLastMenuItem], a - sub 2 ; check if the cursor is in the left column - jr c, .leftColumn -; cursor is in the right column - ld [wCurrentMenuItem], a - ld [wLastMenuItem], a - jr .rightColumn -.leftColumn ; put cursor in left column of menu - ld a, [W_BATTLETYPE] - cp $2 - ld a, " " - jr z, .safariLeftColumn -; put cursor in left column for normal battle menu (i.e. when it's not a Safari battle) - Coorda 15, 14 ; clear upper cursor position in right column - Coorda 15, 16 ; clear lower cursor position in right column - ld b, $9 ; top menu item X - jr .leftColumn_WaitForInput -.safariLeftColumn - Coorda 13, 14 - Coorda 13, 16 - hlCoord 7, 14 - ld de, W_NUMSAFARIBALLS - ld bc, $102 - call PrintNumber - ld b, $1 ; top menu item X -.leftColumn_WaitForInput - ld hl, wTopMenuItemY - ld a, $e - ld [hli], a ; wTopMenuItemY - ld a, b - ld [hli], a ; wTopMenuItemX - inc hl - inc hl - ld a, $1 - ld [hli], a ; wMaxMenuItem - ld [hl], D_RIGHT | A_BUTTON ; wMenuWatchedKeys - call HandleMenuInput - bit 4, a ; check if right was pressed - jr nz, .rightColumn - jr .AButtonPressed ; the A button was pressed -.rightColumn ; put cursor in right column of menu - ld a, [W_BATTLETYPE] - cp $2 - ld a, " " - jr z, .safariRightColumn -; put cursor in right column for normal battle menu (i.e. when it's not a Safari battle) - Coorda 9, 14 ; clear upper cursor position in left column - Coorda 9, 16 ; clear lower cursor position in left column - ld b, $f ; top menu item X - jr .rightColumn_WaitForInput -.safariRightColumn - Coorda 1, 14 ; clear upper cursor position in left column - Coorda 1, 16 ; clear lower cursor position in left column - hlCoord 7, 14 - ld de, W_NUMSAFARIBALLS - ld bc, $102 - call PrintNumber - ld b, $d ; top menu item X -.rightColumn_WaitForInput - ld hl, wTopMenuItemY - ld a, $e - ld [hli], a ; wTopMenuItemY - ld a, b - ld [hli], a ; wTopMenuItemX - inc hl - inc hl - ld a, $1 - ld [hli], a ; wMaxMenuItem - ld a, D_LEFT | A_BUTTON - ld [hli], a ; wMenuWatchedKeys - call HandleMenuInput - bit 5, a ; check if left was pressed - jr nz, .leftColumn ; if left was pressed, jump - ld a, [wCurrentMenuItem] - add $2 ; if we're in the right column, the actual id is +2 - ld [wCurrentMenuItem], a -.AButtonPressed - call PlaceUnfilledArrowMenuCursor - ld a, [W_BATTLETYPE] - cp $2 ; is it a Safari battle? - ld a, [wCurrentMenuItem] - ld [wcc2d], a - jr z, .handleMenuSelection -; not Safari battle -; swap the IDs of the item menu and party menu (this is probably because they swapped the positions of these menu items in first generation English versions) - cp $1 ; was the item menu selected? - jr nz, .notItemMenu -; item menu was selected - inc a ; increment a to 2 - jr .handleMenuSelection -.notItemMenu - cp $2 ; was the party menu selected? - jr nz, .handleMenuSelection -; party menu selected - dec a ; decrement a to 1 -.handleMenuSelection - and a - jr nz, .upperLeftMenuItemWasNotSelected -; the upper left menu item was selected - ld a, [W_BATTLETYPE] - cp $2 - jr z, .throwSafariBallWasSelected -; the "FIGHT" menu was selected - xor a - ld [wNumRunAttempts], a - jp LoadScreenTilesFromBuffer1 ; restore saved screen and return -.throwSafariBallWasSelected - ld a, SAFARI_BALL - ld [wcf91], a - jr .useItem -.upperLeftMenuItemWasNotSelected ; a menu item other than the upper left item was selected - cp $2 - jp nz, .partyMenuOrRockOrRunWasSelected -; either the bag (normal battle) or bait (safari battle) was selected - ld a, [W_ISLINKBATTLE] - cp $4 - jr nz, .notLinkBattle -; can't use items in link battles - ld hl, .itemsCantBeUsedHereText - call PrintText - jp DisplayBattleMenu -.notLinkBattle - call SaveScreenTilesToBuffer2 - ld a, [W_BATTLETYPE] - cp $2 ; is it a safari battle? - jr nz, .bagWasSelected -; bait was selected - ld a, SAFARI_BAIT - ld [wcf91], a - jr .useItem -.bagWasSelected - call LoadScreenTilesFromBuffer1 - ld a, [W_BATTLETYPE] - and a ; is it a normal battle? - jr nz, .next -; normal battle - call DrawHUDsAndHPBars -.next - ld a, [W_BATTLETYPE] - dec a ; is it the old man tutorial? - jr nz, .getPlayerBagPointer ; no, it is a normal battle - ld hl, .oldManItemList - ld a, l - ld [wcf8b], a - ld a, h - ld [wcf8c], a -<<<<<<< HEAD - jr Func_3d03c - -OldManItemList: ; 3d02d (f:502d) - db 1 ; # items - db POKE_BALL, 50 - db -1 - -Func_3d031 - ld hl, wNumBagItems ; wNumBagItems -======= - jr .displayBagMenu -.oldManItemList - db $01, POKE_BALL, 50, $ff -.getPlayerBagPointer ; get the pointer to player's bag when in a normal battle - ld hl, wNumBagItems ->>>>>>> yama/master - ld a, l - ld [wcf8b], a - ld a, h - ld [wcf8c], a -.displayBagMenu - xor a - ld [wcf93], a - ld a, ITEMLISTMENU - ld [wListMenuID], a - ld a, [wcc2c] - ld [wCurrentMenuItem], a - call DisplayListMenuID - ld a, [wCurrentMenuItem] - ld [wcc2c], a - ld a, $0 - ld [wcc37], a - ld [wMenuItemToSwap], a - jp c, DisplayBattleMenu ; go back to battle menu if an item was not selected -.useItem ; either use an item from the bag or use a safari zone item - ld a, [wcf91] - ld [wd11e], a - call GetItemName - call CopyStringToCF4B ; copy name - xor a - ld [wd152], a - call UseItem - call LoadHudTilePatterns - call ClearSprites - xor a - ld [wCurrentMenuItem], a - ld a, [W_BATTLETYPE] - cp $2 ; is it a safari battle? - jr z, .checkIfMonCaptured - ld a, [wcd6a] - and a ; was the item used successfully? - jp z, .bagWasSelected ; if not, go back to the bag menu - ld a, [W_PLAYERBATTSTATUS1] - bit 5, a ; is the player using a multi-turn move like wrap? - jr z, .checkIfMonCaptured - ld hl, wPlayerNumAttacksLeft - dec [hl] - jr nz, .checkIfMonCaptured - ld hl, W_PLAYERBATTSTATUS1 - res 5, [hl] ; not using multi-turn move any more -.checkIfMonCaptured - ld a, [wd11c] - and a ; was the enemy mon captured with a ball? - jr nz, .returnAfterCapturingMon - ld a, [W_BATTLETYPE] - cp $2 ; is it a safari battle? - jr z, .returnAfterUsingItem_NoCapture -; not a safari battle - call LoadScreenTilesFromBuffer1 - call DrawHUDsAndHPBars - call Delay3 -.returnAfterUsingItem_NoCapture - call GBPalNormal - and a ; reset carry - ret -.returnAfterCapturingMon - call GBPalNormal - xor a - ld [wd11c], a - ld a, $2 - ld [wBattleResult], a - scf ; set carry - ret - -.itemsCantBeUsedHereText - TX_FAR _ItemsCantBeUsedHereText - db "@" - -.partyMenuOrRockOrRunWasSelected - dec a ; was Run selected? - jp nz, BattleMenu_RunWasSelected -; party menu or rock was selected - call SaveScreenTilesToBuffer2 - ld a, [W_BATTLETYPE] - cp $2 ; is it a safari battle? - jr nz, .partyMenuWasSelected -; safari battle - ld a, SAFARI_ROCK - ld [wcf91], a - jp .useItem -.partyMenuWasSelected - call LoadScreenTilesFromBuffer1 - xor a - ld [wd07d], a - ld [wMenuItemToSwap], a - call DisplayPartyMenu -.checkIfPartyMonWasSelected - jp nc, .partyMonWasSelected ; if a party mon was selected, jump, else we quit the party menu -.quitPartyMenu - call ClearSprites - call GBPalWhiteOut - call LoadHudTilePatterns - call LoadScreenTilesFromBuffer2 - call GoPAL_SET_CF1C - call GBPalNormal - jp DisplayBattleMenu -.partyMonDeselected - hlCoord 11, 11 - ld bc, $81 - ld a, $7f - call FillMemory - xor a - ld [wd07d], a - call GoBackToPartyMenu - jr .checkIfPartyMonWasSelected -.partyMonWasSelected - ld a, $c ; switch/stats/cancel menu - ld [wd125], a - call DisplayTextBoxID - ld hl, wTopMenuItemY - ld a, $c - ld [hli], a ; wTopMenuItemY - ld [hli], a ; wTopMenuItemX - xor a - ld [hli], a ; wCurrentMenuItem - inc hl - ld a, $2 - ld [hli], a ; wMaxMenuItem - ld a, B_BUTTON | A_BUTTON - ld [hli], a ; wMenuWatchedKeys - xor a - ld [hl], a ; wLastMenuItem - call HandleMenuInput - bit 1, a ; was A pressed? - jr nz, .partyMonDeselected ; if B was pressed, jump -; A was pressed - call PlaceUnfilledArrowMenuCursor - ld a, [wCurrentMenuItem] - cp $2 ; was Cancel selected? - jr z, .quitPartyMenu ; if so, quit the party menu entirely - and a ; was Switch selected? - jr z, .switchMon ; if so, jump -; Stats was selected - xor a - ld [wcc49], a - ld hl, wPartyMon1 - call ClearSprites -; display the two status screens - predef StatusScreen - predef StatusScreen2 -; now we need to reload the enemy mon pic - ld a, [W_ENEMYBATTSTATUS2] - bit 4, a ; does the enemy mon have a substitute? - ld hl, AnimationSubstitute - jr nz, .doEnemyMonAnimation -; enemy mon doesn't have substitute - ld a, [wccf3] - and a ; has the enemy mon used Minimise? - ld hl, AnimationMinimizeMon - jr nz, .doEnemyMonAnimation -; enemy mon is not minimised - ld a, [wEnemyMonSpecies] - ld [wcf91], a - ld [wd0b5], a - call GetMonHeader - ld de, vFrontPic - call LoadMonFrontSprite - jr .enemyMonPicReloaded -.doEnemyMonAnimation - ld b, BANK(AnimationSubstitute) ; BANK(AnimationMinimizeMon) - call Bankswitch -.enemyMonPicReloaded ; enemy mon pic has been reloaded, so return to the party menu - jp .partyMenuWasSelected -.switchMon - ld a, [wPlayerMonNumber] - ld d, a - ld a, [wWhichPokemon] - cp d ; check if the mon to switch to is already out - jr nz, .notAlreadyOut -; mon is already out - ld hl, AlreadyOutText - call PrintText - jp .partyMonDeselected -.notAlreadyOut - call HasMonFainted - jp z, .partyMonDeselected ; can't switch to fainted mon - ld a, $1 - ld [wcd6a], a - call GBPalWhiteOut - call ClearSprites - call LoadHudTilePatterns - call LoadScreenTilesFromBuffer1 - call GoPAL_SET_CF1C - call GBPalNormal -; fall through to SwitchPlayerMon - -SwitchPlayerMon: ; 3d1ba (f:51ba) - callab RetreatMon - ld c, $32 - call DelayFrames - call AnimateRetreatingPlayerMon - ld a, [wWhichPokemon] - ld [wPlayerMonNumber], a - ld c, a - ld b, $1 - push bc - ld hl, wPartyGainExpFlags - predef FlagActionPredef - pop bc - ld hl, wPartyFoughtCurrentEnemyFlags - predef FlagActionPredef - call LoadBattleMonFromParty - call SendOutMon - call SaveScreenTilesToBuffer1 - ld a, $2 - ld [wCurrentMenuItem], a - and a - ret - -AlreadyOutText: ; 3d1f5 (f:51f5) - TX_FAR _AlreadyOutText - db "@" - -BattleMenu_RunWasSelected: ; 3d1fa (f:51fa) - call LoadScreenTilesFromBuffer1 - ld a, $3 - ld [wCurrentMenuItem], a - ld hl, wBattleMonSpeed - ld de, wEnemyMonSpeed - call TryRunningFromBattle - ld a, $0 - ld [wd11f], a - ret c - ld a, [wcd6a] - and a - ret nz - jp DisplayBattleMenu - -MoveSelectionMenu: ; 3d219 (f:5219) - ld a, [wMoveMenuType] - dec a - jr z, .mimicmenu - dec a - jr z, .relearnmenu - jr .regularmenu - -.loadmoves - ld de, wd0dc - ld bc, $4 - call CopyData - callab Func_39b87 - ret - -.writemoves - ld de, wd0e1 - ld a, [$fff6] - set 2, a - ld [$fff6], a - call PlaceString - ld a, [$fff6] - res 2, a - ld [$fff6], a - ret - -.regularmenu - call Func_3d3f5 - ret z - ld hl, wBattleMonMoves - call .loadmoves - hlCoord 4, 12 - ld b, $4 - ld c, $e - di - call TextBoxBorder - hlCoord 4, 12 - ld [hl], $7a - hlCoord 10, 12 - ld [hl], $7e - ei - hlCoord 6, 13 - call .writemoves - ld b, $5 - ld a, $c - jr .menuset -.mimicmenu - ld hl, wEnemyMonMoves - call .loadmoves - hlCoord 0, 7 - ld b, $4 - ld c, $e - call TextBoxBorder - hlCoord 2, 8 - call .writemoves - ld b, $1 - ld a, $7 - jr .menuset -.relearnmenu - ld a, [wWhichPokemon] - ld hl, wPartyMon1Moves - ld bc, $2c - call AddNTimes - call .loadmoves - hlCoord 4, 7 - ld b, $4 - ld c, $e - call TextBoxBorder - hlCoord 6, 8 - call .writemoves - ld b, $5 - ld a, $7 -.menuset - ld hl, wTopMenuItemY - ld [hli], a - ld a, b - ld [hli], a - ld a, [wMoveMenuType] - cp $1 - jr z, .selectedmoveknown - ld a, $1 - jr nc, .selectedmoveknown - ld a, [wPlayerMoveListIndex] - inc a -.selectedmoveknown - ld [hli], a - inc hl ; wTileBehindCursor untouched - ld a, [wcd6c] - inc a - inc a - ld [hli], a - ld a, [wMoveMenuType] - dec a - ld b, $c1 ; can't use B - jr z, .matchedkeyspicked - dec a - ld b, $c3 - jr z, .matchedkeyspicked - ld a, [W_ISLINKBATTLE] - cp $4 - jr z, .matchedkeyspicked - ld a, [W_FLAGS_D733] - bit 0, a - ld b, $c7 - jr z, .matchedkeyspicked - ld b, $ff -.matchedkeyspicked - ld a, b - ld [hli], a - ld a, [wMoveMenuType] - cp $1 - jr z, .movelistindex1 - ld a, [wPlayerMoveListIndex] - inc a -.movelistindex1 - ld [hl], a - -Func_3d2fe: ; 3d2fe (f:52fe) - ld a, [wMoveMenuType] - and a - jr z, .battleselect - dec a - jr nz, .select - hlCoord 1, 14 - ld de, WhichTechniqueString - call PlaceString - jr .select -.battleselect - ld a, [W_FLAGS_D733] - bit 0, a - jr nz, .select - call Func_3d4b6 - ld a, [wMenuItemToSwap] - and a - jr z, .select - hlCoord 5, 13 - dec a - ld bc, $14 - call AddNTimes - ld [hl], $ec -.select - ld hl, $fff6 - set 1, [hl] - call HandleMenuInput - ld hl, $fff6 - res 1, [hl] - bit 6, a - jp nz, Func_3d3c9 ; up - bit 7, a - jp nz, Func_3d3dd ; down - bit 2, a - jp nz, SwapMovesInMenu ; select - bit 1, a ; B, but was it reset above? - push af - xor a - ld [wMenuItemToSwap], a - ld a, [wCurrentMenuItem] - dec a - ld [wCurrentMenuItem], a - ld b, a - ld a, [wMoveMenuType] - dec a ; if not mimic - jr nz, .nob - pop af - ret -.nob - dec a - ld a, b - ld [wPlayerMoveListIndex], a - jr nz, .moveselected - pop af - ret -.moveselected - pop af - ret nz - ld hl, wBattleMonPP - ld a, [wCurrentMenuItem] - ld c, a - ld b, $0 - add hl, bc - ld a, [hl] - and $3f - jr z, .nopp - ld a, [W_PLAYERDISABLEDMOVE] - swap a - and $f - dec a - cp c - jr z, .disabled - ld a, [W_PLAYERBATTSTATUS3] - bit 3, a ; transformed - jr nz, .dummy ; game freak derp -.dummy - ld a, [wCurrentMenuItem] - ld hl, wBattleMonMoves - ld c, a - ld b, $0 - add hl, bc - ld a, [hl] - ld [wPlayerSelectedMove], a - xor a - ret -.disabled - ld hl, MoveDisabledText - jr .print -.nopp - ld hl, MoveNoPPText -.print - call PrintText - call LoadScreenTilesFromBuffer1 - jp MoveSelectionMenu - -MoveNoPPText: ; 3d3ae (f:53ae) - TX_FAR _MoveNoPPText - db "@" - -MoveDisabledText: ; 3d3b3 (f:53b3) - TX_FAR _MoveDisabledText - db "@" - -WhichTechniqueString: ; 3d3b8 (f:53b8) - db "WHICH TECHNIQUE?@" - -Func_3d3c9: ; 3d3c9 (f:53c9) - ld a, [wCurrentMenuItem] - and a - jp nz, Func_3d2fe - call EraseMenuCursor - ld a, [wcd6c] - inc a - ld [wCurrentMenuItem], a - jp Func_3d2fe - -Func_3d3dd: ; 3d3dd (f:53dd) - ld a, [wCurrentMenuItem] - ld b, a - ld a, [wcd6c] - inc a - inc a - cp b - jp nz, Func_3d2fe - call EraseMenuCursor - ld a, $1 - ld [wCurrentMenuItem], a - jp Func_3d2fe - -Func_3d3f5: ; 3d3f5 (f:53f5) - ld a, STRUGGLE - ld [wPlayerSelectedMove], a - ld a, [W_PLAYERDISABLEDMOVE] - and a - ld hl, wBattleMonPP - jr nz, .asm_3d40e - ld a, [hli] - or [hl] - inc hl - or [hl] - inc hl - or [hl] - and $3f - ret nz - jr .asm_3d423 -.asm_3d40e - swap a - and $f - ld b, a - ld d, $5 - xor a -.asm_3d416 - dec d - jr z, .asm_3d421 - ld c, [hl] - inc hl - dec b - jr z, .asm_3d416 - or c - jr .asm_3d416 -.asm_3d421 - and a - ret nz -.asm_3d423 - ld hl, NoMovesLeftText - call PrintText - ld c, $3c - call DelayFrames - xor a - ret - -NoMovesLeftText: ; 3d430 (f:5430) - TX_FAR _NoMovesLeftText - db "@" - -SwapMovesInMenu: ; 3d435 (f:5435) - ld a, [wMenuItemToSwap] - and a - jr z, .noMenuItemSelected - ld hl, wBattleMonMoves - call .swapBytes ; swap moves - ld hl, wBattleMonPP - call .swapBytes ; swap move PP -; update the index of the disabled move if necessary - ld hl, W_PLAYERDISABLEDMOVE - ld a, [hl] - swap a - and $f - ld b, a - ld a, [wCurrentMenuItem] - cp b - jr nz, .next - ld a, [hl] - and $f - ld b, a - ld a, [wMenuItemToSwap] - swap a - add b - ld [hl], a - jr .swapMovesInPartyMon -.next - ld a, [wMenuItemToSwap] - cp b - jr nz, .swapMovesInPartyMon - ld a, [hl] - and $f - ld b, a - ld a, [wCurrentMenuItem] - swap a - add b - ld [hl], a -.swapMovesInPartyMon - ld hl, wPartyMon1Moves - ld a, [wPlayerMonNumber] - ld bc, wPartyMon2 - wPartyMon1 - call AddNTimes - push hl - call .swapBytes ; swap moves - pop hl - ld bc, $15 - add hl, bc - call .swapBytes ; swap move PP - xor a - ld [wMenuItemToSwap], a ; deselect the item - jp MoveSelectionMenu -.swapBytes - push hl - ld a, [wMenuItemToSwap] - dec a - ld c, a - ld b, 0 - add hl, bc - ld d, h - ld e, l - pop hl - ld a, [wCurrentMenuItem] - dec a - ld c, a - ld b, 0 - add hl, bc - ld a, [de] - ld b, [hl] - ld [hl], a - ld a, b - ld [de], a - ret -.noMenuItemSelected - ld a, [wCurrentMenuItem] - ld [wMenuItemToSwap], a ; select the current menu item for swapping - jp MoveSelectionMenu - -Func_3d4b6: ; 3d4b6 (f:54b6) - xor a - ld [H_AUTOBGTRANSFERENABLED], a - hlCoord 0, 8 - ld b, $3 - ld c, $9 - call TextBoxBorder - ld a, [W_PLAYERDISABLEDMOVE] - and a - jr z, .asm_3d4df - swap a - and $f - ld b, a - ld a, [wCurrentMenuItem] - cp b - jr nz, .asm_3d4df - hlCoord 1, 10 - ld de, DisabledText - call PlaceString - jr .asm_3d54e -.asm_3d4df - ld hl, wCurrentMenuItem - dec [hl] - xor a - ld [H_WHOSETURN], a - ld hl, wBattleMonMoves - ld a, [wCurrentMenuItem] - ld c, a - ld b, $0 - add hl, bc - ld a, [hl] - ld [wPlayerSelectedMove], a - ld a, [wPlayerMonNumber] - ld [wWhichPokemon], a - ld a, $4 - ld [wcc49], a - callab GetMaxPP - ld hl, wCurrentMenuItem - ld c, [hl] - inc [hl] - ld b, $0 - ld hl, wBattleMonPP - add hl, bc - ld a, [hl] - and $3f - ld [wcd6d], a - hlCoord 1, 9 - ld de, TypeText - call PlaceString - hlCoord 7, 11 - ld [hl], "/" - hlCoord 5, 9 - ld [hl], "/" - hlCoord 5, 11 - ld de, wcd6d - ld bc, $102 - call PrintNumber - hlCoord 8, 11 - ld de, wd11e - ld bc, $102 - call PrintNumber - call GetCurrentMove - hlCoord 2, 10 - predef Func_27d98 -.asm_3d54e - ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a - jp Delay3 - -DisabledText: ; 3d555 (f:5555) - db "disabled!@" - -TypeText: ; 3d55f (f:555f) - db "TYPE@" - -SelectEnemyMove: ; 3d564 (f:5564) - ld a, [W_ISLINKBATTLE] - sub $4 - jr nz, .noLinkBattle -; link battle - call SaveScreenTilesToBuffer1 - call LinkBattleExchangeData - call LoadScreenTilesFromBuffer1 - ld a, [wcc3e] - cp $e - jp z, .asm_3d601 - cp $d - jr z, .unableToMove - cp $4 - ret nc - ld [wEnemyMoveListIndex], a - ld c, a - ld hl, wEnemyMonMoves - ld b, $0 - add hl, bc - ld a, [hl] - jr .done -.noLinkBattle - ld a, [W_ENEMYBATTSTATUS2] - and $60 ; need to recharge or using rage - ret nz - ld hl, W_ENEMYBATTSTATUS1 - ld a, [hl] - and $12 ; using multi-turn move or bide - ret nz - ld a, [wEnemyMonStatus] - and SLP | 1 << FRZ ; sleeping or frozen - ret nz - ld a, [W_ENEMYBATTSTATUS1] - and $21 ; using fly/dig or thrash/petal dance - ret nz - ld a, [W_PLAYERBATTSTATUS1] - bit 5, a ; caught in player's multi-turn move (e.g. wrap) - jr z, .notCaughtInWrap -.unableToMove - ld a, $ff - jr .done -.notCaughtInWrap - ld hl, wEnemyMonMoves+1 ; 2nd enemy move - ld a, [hld] - and a - jr nz, .atLeastTwoMovesAvailable - ld a, [W_ENEMYDISABLEDMOVE] - and a - ld a, STRUGGLE ; struggle if the only move is disabled - jr nz, .done -.atLeastTwoMovesAvailable - ld a, [W_ISINBATTLE] - dec a - jr z, .chooseRandomMove ; wild encounter - callab AIEnemyTrainerChooseMoves -.chooseRandomMove - push hl - call BattleRandom - ld b, $1 - cp $3f ; select move 1 in [0,3e] (63/256 chance) - jr c, .moveChosen - inc hl - inc b - cp $7f ; select move 1 in [3f,7e] (64/256 chance) - jr c, .moveChosen - inc hl - inc b - cp $be ; select move 1 in [7f,bd] (63/256 chance) - jr c, .moveChosen - inc hl - inc b ; select move 4 in [be,ff] (66/256 chance) -.moveChosen - ld a, b - dec a - ld [wEnemyMoveListIndex], a - ld a, [W_ENEMYDISABLEDMOVE] - swap a - and $f - cp b - ld a, [hl] - pop hl - jr z, .chooseRandomMove ; move disabled, try again - and a - jr z, .chooseRandomMove ; move non-existant, try again -.done - ld [wEnemySelectedMove], a - ret -.asm_3d601 - ld a, STRUGGLE - jr .done - -; this appears to exchange data with the other gameboy during link battles -LinkBattleExchangeData: ; 3d605 (f:5605) - ld a, $ff - ld [wcc3e], a - ld a, [wPlayerMoveListIndex] - cp $f ; is the player running from battle? - jr z, .asm_3d630 - ld a, [wcd6a] - and a - jr nz, .asm_3d629 - ld a, [wPlayerSelectedMove] - cp STRUGGLE - ld b, $e - jr z, .asm_3d62f - dec b - inc a - jr z, .asm_3d62f - ld a, [wPlayerMoveListIndex] - jr .asm_3d630 -.asm_3d629 - ld a, [wWhichPokemon] - add $4 - ld b, a -.asm_3d62f - ld a, b -.asm_3d630 - ld [wcc42], a - callab PrintWaitingText -.asm_3d63b - call Func_22c3 - call DelayFrame - ld a, [wcc3e] - inc a - jr z, .asm_3d63b - ld b, $a -.asm_3d649 - call DelayFrame - call Func_22c3 - dec b - jr nz, .asm_3d649 - ld b, $a -.asm_3d654 - call DelayFrame - call Func_22ed - dec b - jr nz, .asm_3d654 - ret - -ExecutePlayerMove: ; 3d65e (f:565e) - xor a - ld [H_WHOSETURN], a - ld a, [wPlayerSelectedMove] - inc a - jp z, Func_3d80a - xor a - ld [W_MOVEMISSED], a - ld [wcced], a - ld [wccf4], a - ld a, $a - ld [wd05b], a - ld a, [wcd6a] - and a - jp nz, Func_3d80a - call PrintGhostText - jp z, Func_3d80a - call CheckPlayerStatusConditions - jr nz, .asm_3d68a - jp [hl] -.asm_3d68a - call GetCurrentMove - ld hl, W_PLAYERBATTSTATUS1 - bit 4, [hl] - jr nz, asm_3d6a9 - call CheckForDisobedience - jp z, Func_3d80a - -Func_3d69a: ; 3d69a (f:569a) - ld a, [W_PLAYERMOVEEFFECT] - cp CHARGE_EFFECT - jp z, JumpMoveEffect - cp FLY_EFFECT - jp z, JumpMoveEffect - jr asm_3d6b0 - -; in-battle stuff -asm_3d6a9: ; 3d6a9 (f:56a9) - ld hl,W_PLAYERBATTSTATUS1 - res 4,[hl] - res 6,[hl] -asm_3d6b0: ; 3d6b0 (f:56b0) - call PrintMonName1Text - ld hl,DecrementPP - ld de,wPlayerSelectedMove ; pointer to the move just used - ld b,BANK(DecrementPP) - call Bankswitch - ld a,[W_PLAYERMOVEEFFECT] ; effect of the move just used - ld hl,EffectsArray1 - ld de,1 - call IsInArray - jp c,JumpMoveEffect - ld a,[W_PLAYERMOVEEFFECT] - ld hl,EffectsArray5B - ld de,1 - call IsInArray - call c,JumpMoveEffect -asm_3d6dc: ; 3d6dc (f:56dc) - ld a,[W_PLAYERMOVEEFFECT] - ld hl,EffectsArray2 - ld de,1 - call IsInArray - jp c,.asm_3d702 - call CriticalHitTest - call HandleCounterMove - jr z,asm_3d705 - call GetDamageVarsForPlayerAttack - call CalculateDamage - jp z,asm_3d74b - call AdjustDamageForMoveType - call RandomizeDamage -.asm_3d702 - call MoveHitTest -asm_3d705 - ld a,[W_MOVEMISSED] - and a - jr z,asm_3d714 - ld a,[W_PLAYERMOVEEFFECT] - sub a,7 - jr z,asm_3d71e - jr asm_3d74b -asm_3d714 - ld a,[W_PLAYERMOVEEFFECT] - and a - ld a,4 - jr z,asm_3d71e - ld a,5 -asm_3d71e - push af - ld a,[W_PLAYERBATTSTATUS2] - bit 4,a - ld hl,Func_79747 - ld b,BANK(Func_79747) - call nz,Bankswitch - pop af - ld [wcc5b],a - ld a,[W_PLAYERMOVENUM] - call PlayMoveAnimation - call Func_3eed3 - call DrawPlayerHUDAndHPBar - ld a,[W_PLAYERBATTSTATUS2] - bit 4,a - ld hl,Func_79771 - ld b,BANK(Func_79771) - call nz,Bankswitch - jr asm_3d766 -asm_3d74b - ld c,$1E - call DelayFrames - ld a,[W_PLAYERMOVEEFFECT] - cp a,FLY_EFFECT - jr z,.next5 - cp a,CHARGE_EFFECT - jr z,.next5 - jr asm_3d766 -.next5 - xor a - ld [wcc5b],a - ld a,STATUS_AFFECTED_ANIM - call PlayMoveAnimation -asm_3d766 - ld a,[W_PLAYERMOVEEFFECT] - cp a,MIRROR_MOVE_EFFECT - jr nz,.next6 - call MirrorMoveCopyMove - jp z,Func_3d80a - xor a - ld [wcced],a - jp Func_3d69a -.next6 - cp a,METRONOME_EFFECT - jr nz,.next7 - call MetronomePickMove - jp Func_3d69a -.next7 - ld a,[W_PLAYERMOVEEFFECT] - ld hl,EffectsArray3 - ld de,1 - call IsInArray - jp c,JumpMoveEffect - ld a,[W_MOVEMISSED] - and a - jr z,.next8 - call PrintMoveFailureText - ld a,[W_PLAYERMOVEEFFECT] - cp a,EXPLODE_EFFECT - jr z,.next9 - jp Func_3d80a -.next8 - call ApplyAttackToEnemyPokemon - call PrintCriticalOHKOText - callab DisplayEffectiveness - ld a,1 - ld [wccf4],a -.next9 - ld a,[W_PLAYERMOVEEFFECT] - ld hl,EffectsArray4 - ld de,1 - call IsInArray - call c,JumpMoveEffect - ld hl,wEnemyMonHP - ld a,[hli] - ld b,[hl] - or b - ret z - call HandleBuildingRage - - ld hl,W_PLAYERBATTSTATUS1 - bit 2,[hl] - jr z,.next10 - ld a,[wPlayerNumAttacksLeft] - dec a - ld [wPlayerNumAttacksLeft],a - jp nz,asm_3d714 - - res 2,[hl] - ld hl,MultiHitText - call PrintText - xor a - ld [W_NUMHITS],a ; reset -.next10 - ld a,[W_PLAYERMOVEEFFECT] - and a - jp z,Func_3d80a - ld hl,EffectsArray5 - ld de,1 - call IsInArray - call nc,JumpMoveEffect - jp Func_3d80a - -MultiHitText: ; 3d805 (f:5805) - TX_FAR _MultiHitText - db "@" - -Func_3d80a: ; 3d80a (f:580a) - xor a - ld [wcd6a],a - ld b,1 - ret - -PrintGhostText: ; 3d811 (f:5811) -; print the ghost battle messages - call IsGhostBattle - ret nz - ld a,[H_WHOSETURN] - and a - jr nz,.Ghost - ld a,[wBattleMonStatus] ; player’s turn - and a,SLP | (1 << FRZ) - ret nz - ld hl,ScaredText - call PrintText - xor a - ret -.Ghost ; ghost’s turn - ld hl,GetOutText - call PrintText - xor a - ret - -ScaredText: ; 3d830 (f:5830) - TX_FAR _ScaredText - db "@" - -GetOutText: ; 3d835 (f:5835) - TX_FAR _GetOutText - db "@" - -IsGhostBattle: ; 3d83a (f:583a) - ld a,[W_ISINBATTLE] - dec a - ret nz - ld a,[W_CURMAP] - cp a,POKEMONTOWER_1 - jr c,.next - cp a,LAVENDER_HOUSE_1 - jr nc,.next - ld b,SILPH_SCOPE - call IsItemInBag - ret z -.next - ld a,1 - and a - ret - -; checks for various status conditions affecting the player mon -; stores whether the mon cannot use a move this turn in Z flag -CheckPlayerStatusConditions: ; 3d854 (f:5854) - ld hl,wBattleMonStatus - ld a,[hl] - and a,SLP ; sleep mask - jr z,.FrozenCheck - -; sleeping - dec a - ld [wBattleMonStatus],a ; decrement number of turns left - and a - jr z,.WakeUp ; if the number of turns hit 0, wake up -; fast asleep - xor a - ld [wcc5b],a - ld a,SLP_ANIM - 1 - call PlayMoveAnimation - ld hl,FastAsleepText - call PrintText - jr .sleepDone -.WakeUp - ld hl,WokeUpText - call PrintText -.sleepDone - xor a - ld [wccf1],a - ld hl,Func_3d80a - jp .CannotUseMove - -.FrozenCheck - bit FRZ,[hl] ; frozen? - jr z,.HeldInPlaceCheck - ld hl,IsFrozenText - call PrintText - xor a - ld [wccf1],a - ld hl,Func_3d80a - jp .CannotUseMove - -.HeldInPlaceCheck - ld a,[W_ENEMYBATTSTATUS1] - bit 5,a - jp z,.FlinchedCheck - ld hl,CantMoveText - call PrintText - ld hl,Func_3d80a - jp .CannotUseMove - -.FlinchedCheck - ld hl,W_PLAYERBATTSTATUS1 - bit 3,[hl] - jp z,.HyperBeamCheck - res 3,[hl] - ld hl,FlinchedText - call PrintText - ld hl,Func_3d80a - jp .CannotUseMove - -.HyperBeamCheck - ld hl,W_PLAYERBATTSTATUS2 - bit 5,[hl] - jr z,.AnyMoveDisabledCheck - res 5,[hl] - ld hl,MustRechargeText - call PrintText - ld hl,Func_3d80a - jp .CannotUseMove - -.AnyMoveDisabledCheck - ld hl,W_PLAYERDISABLEDMOVE - ld a,[hl] - and a - jr z,.ConfusedCheck - dec a - ld [hl],a - and a,$F - jr nz,.ConfusedCheck - ld [hl],a - ld [wccee],a - ld hl,DisabledNoMoreText - call PrintText - -.ConfusedCheck - ld a,[W_PLAYERBATTSTATUS1] - add a - jr nc,.TriedToUseDisabledMoveCheck - ld hl,wd06b - dec [hl] - jr nz,.IsConfused - ld hl,W_PLAYERBATTSTATUS1 - res 7,[hl] - ld hl,ConfusedNoMoreText - call PrintText - jr .TriedToUseDisabledMoveCheck -.IsConfused - ld hl,IsConfusedText - call PrintText - xor a - ld [wcc5b],a - ld a,CONF_ANIM - 1 - call PlayMoveAnimation - call BattleRandom - cp a,$80 - jr c,.TriedToUseDisabledMoveCheck - ld hl,W_PLAYERBATTSTATUS1 - ld a,[hl] - and a,$80 ; confused - ld [hl],a - call PrintHurtItselfText - jr .MonHurtItselfOrFullyParalysed - -.TriedToUseDisabledMoveCheck - ld a,[wccee] - and a - jr z,.ParalysisCheck - ld hl,wPlayerSelectedMove - cp [hl] - jr nz,.ParalysisCheck - call PrintMoveIsDisabledText - ld hl,Func_3d80a - jp .CannotUseMove - -.ParalysisCheck - ld hl,wBattleMonStatus - bit PAR,[hl] - jr z,.BideCheck - call BattleRandom - cp a,$3F - jr nc,.BideCheck - ld hl,FullyParalyzedText - call PrintText - -.MonHurtItselfOrFullyParalysed - ld hl,W_PLAYERBATTSTATUS1 - ld a,[hl] - and a,$CC ; clear bide, thrashing, charging up, and multi-turn moves such as warp - ld [hl],a - ld a,[W_PLAYERMOVEEFFECT] - cp a,FLY_EFFECT - jr z,.FlyOrChargeEffect - cp a,CHARGE_EFFECT - jr z,.FlyOrChargeEffect - jr .NotFlyOrChargeEffect - -.FlyOrChargeEffect - xor a - ld [wcc5b],a - ld a,STATUS_AFFECTED_ANIM - call PlayMoveAnimation -.NotFlyOrChargeEffect - ld hl,Func_3d80a - jp .CannotUseMove - -.BideCheck - ld hl,W_PLAYERBATTSTATUS1 - bit 0,[hl] ; is mon using bide? - jr z,.ThrashingAboutCheck - xor a - ld [W_PLAYERMOVENUM],a - ld hl,W_DAMAGE - ld a,[hli] - ld b,a - ld c,[hl] - ld hl,wd075 - ld a,[hl] - add c - ld [hld],a - ld a,[hl] - adc b - ld [hl],a - ld hl,wPlayerNumAttacksLeft - dec [hl] - jr z,.UnleashEnergy - ld hl,Func_3d80a - jp .CannotUseMove -.UnleashEnergy - ld hl,W_PLAYERBATTSTATUS1 - res 0,[hl] ; not using bide any more - ld hl,UnleashedEnergyText - call PrintText - ld a,1 - ld [W_PLAYERMOVEPOWER],a - ld hl,wd075 - ld a,[hld] - add a - ld b,a - ld [wd0d8],a - ld a,[hl] - rl a - ld [W_DAMAGE],a - or b - jr nz,.next - ld a,1 - ld [W_MOVEMISSED],a -.next - xor a - ld [hli],a - ld [hl],a - ld a,BIDE - ld [W_PLAYERMOVENUM],a - ld hl,asm_3d705 - jp .CannotUseMove - -.ThrashingAboutCheck - bit 1,[hl] ; is mon using thrash or petal dance? - jr z,.MultiturnMoveCheck - ld a,THRASH - ld [W_PLAYERMOVENUM],a - ld hl,ThrashingAboutText - call PrintText - ld hl,wPlayerNumAttacksLeft - dec [hl] - ld hl,asm_3d6dc - jp nz,.CannotUseMove - push hl - ld hl,W_PLAYERBATTSTATUS1 - res 1,[hl] - set 7,[hl] - call BattleRandom - and a,3 - inc a - inc a - ld [wd06b],a - pop hl - jp .CannotUseMove - -.MultiturnMoveCheck - bit 5,[hl] ; is mon using multi-turn move? - jp z,.RageCheck - ld hl,AttackContinuesText - call PrintText - ld a,[wPlayerNumAttacksLeft] - dec a - ld [wPlayerNumAttacksLeft],a - ld hl,asm_3d714 - jp nz,.CannotUseMove - jp .CannotUseMove - -.RageCheck - ld a, [W_PLAYERBATTSTATUS2] - bit 6, a ; is mon using rage? - jp z, .CanUseMove - ld a, RAGE - ld [wd11e], a - call GetMoveName - call CopyStringToCF4B - xor a - ld [W_PLAYERMOVEEFFECT], a - ld hl, asm_3d6b0 - jp .CannotUseMove - -.CannotUseMove - xor a - ret - -.CanUseMove - ld a, $1 - and a - ret - -FastAsleepText: ; 3da3d (f:5a3d) - TX_FAR _FastAsleepText - db "@" - -WokeUpText: ; 3da42 (f:5a42) - TX_FAR _WokeUpText - db "@" - -IsFrozenText: ; 3da47 (f:5a47) - TX_FAR _IsFrozenText - db "@" - -FullyParalyzedText: ; 3da4c (f:5a4c) - TX_FAR _FullyParalyzedText - db "@" - -FlinchedText: ; 3da51 (f:5a51) - TX_FAR _FlinchedText - db "@" - -MustRechargeText: ; 3da56 (f:5a56) - TX_FAR _MustRechargeText - db "@" - -DisabledNoMoreText: ; 3da5b (f:5a5b) - TX_FAR _DisabledNoMoreText - db "@" - -IsConfusedText: ; 3da60 (f:5a60) - TX_FAR _IsConfusedText - db "@" - -HurtItselfText: ; 3da65 (f:5a65) - TX_FAR _HurtItselfText - db "@" - -ConfusedNoMoreText: ; 3da6a (f:5a6a) - TX_FAR _ConfusedNoMoreText - db "@" - -SavingEnergyText: ; 3da6f (f:5a6f) - TX_FAR _SavingEnergyText - db "@" - -UnleashedEnergyText: ; 3da74 (f:5a74) - TX_FAR _UnleashedEnergyText - db "@" - -ThrashingAboutText: ; 3da79 (f:5a79) - TX_FAR _ThrashingAboutText - db "@" - -AttackContinuesText: ; 3da7e (f:5a7e) - TX_FAR _AttackContinuesText - db "@" - -CantMoveText: ; 3da83 (f:5a83) - TX_FAR _CantMoveText - db "@" - -PrintMoveIsDisabledText: ; 3da88 (f:5a88) - ld hl, wPlayerSelectedMove - ld de, W_PLAYERBATTSTATUS1 - ld a, [H_WHOSETURN] - and a - jr z, .asm_3da97 - inc hl - ld de, W_ENEMYBATTSTATUS1 -.asm_3da97 - ld a, [de] - res 4, a - ld [de], a - ld a, [hl] - ld [wd11e], a - call GetMoveName - ld hl, MoveIsDisabledText - jp PrintText - -MoveIsDisabledText: ; 3daa8 (f:5aa8) - TX_FAR _MoveIsDisabledText - db "@" - -PrintHurtItselfText: ; 3daad (f:5aad) - ld hl, HurtItselfText - call PrintText - ld hl, wEnemyMonDefense - ld a, [hli] - push af - ld a, [hld] - push af - ld a, [wBattleMonDefense] - ld [hli], a - ld a, [wBattleMonDefense + 1] - ld [hl], a - ld hl, W_PLAYERMOVEEFFECT - push hl - ld a, [hl] - push af - xor a - ld [hli], a - ld [wCriticalHitOrOHKO], a - ld a, $28 - ld [hli], a - xor a - ld [hl], a - call GetDamageVarsForPlayerAttack - call CalculateDamage - pop af - pop hl - ld [hl], a - ld hl, wEnemyMonDefense + 1 - pop af - ld [hld], a - pop af - ld [hl], a - xor a - ld [wcc5b], a - inc a - ld [H_WHOSETURN], a - call PlayMoveAnimation - call DrawPlayerHUDAndHPBar - xor a - ld [H_WHOSETURN], a - jp ApplyDamageToPlayerPokemon - -PrintMonName1Text: ; 3daf5 (f:5af5) - ld hl, MonName1Text - jp PrintText - -MonName1Text: ; 3dafb (f:5afb) - TX_FAR _MonName1Text - db $08 ; asm - ld a, [H_WHOSETURN] - and a - ld a, [W_PLAYERMOVENUM] - ld hl, wccf1 - jr z, .asm_3db11 - ld a, [W_ENEMYMOVENUM] - ld hl, wccf2 -.asm_3db11 - ld [hl], a - ld [wd11e], a - call Func_3db85 - ld a, [wcced] - and a - ld hl, Used2Text - ret nz - ld a, [wd11e] - cp DOUBLESLAP - ld hl, Used2Text - ret c - ld hl, Used1Text - ret - -Used1Text: ; 3db2d (f:5b2d) - TX_FAR _Used1Text - db $08 ; asm - jr PrintInsteadText - -Used2Text: ; 3db34 (f:5b34) - TX_FAR _Used2Text - db $08 ; asm - -PrintInsteadText: ; 3db39 (f:5b39) - ld a, [wcced] - and a - jr z, PrintCF4BText - ld hl, InsteadText - ret - -InsteadText: ; 3db43 (f:5b43) - TX_FAR _InsteadText - db $08 ; asm - -PrintCF4BText: ; 3db48 (f:5b48) - ld hl, CF4BText - ret - -CF4BText: ; 3db4c (f:5b4c) - TX_FAR _CF4BText - db $08 ; asm - ld hl, ExclamationPointPointerTable - ld a, [wd11e] - add a - push bc - ld b, $0 - ld c, a - add hl, bc - pop bc - ld a, [hli] - ld h, [hl] - ld l, a - ret - -ExclamationPointPointerTable: ; 3db62 (f:5b62) - dw ExclamationPoint1Text - dw ExclamationPoint2Text - dw ExclamationPoint3Text - dw ExclamationPoint4Text - dw ExclamationPoint5Text - -ExclamationPoint1Text: ; 3db6c (f:5b6c) - TX_FAR _ExclamationPoint1Text - db "@" - -ExclamationPoint2Text: ; 3db71 (f:5b71) - TX_FAR _ExclamationPoint2Text - db "@" - -ExclamationPoint3Text: ; 3db76 (f:5b76) - TX_FAR _ExclamationPoint3Text - db "@" - -ExclamationPoint4Text: ; 3db7b (f:5b7b) - TX_FAR _ExclamationPoint4Text - db "@" - -ExclamationPoint5Text: ; 3db80 (f:5b80) - TX_FAR _ExclamationPoint5Text - db "@" - -Func_3db85: ; 3db85 (f:5b85) - push bc - ld a, [wd11e] ; move number - ld c, a - ld b, $0 - ld hl, UnknownMovesList_3dba3 -.asm_3db8f - ld a, [hli] - cp $ff - jr z, .asm_3db9d - cp c - jr z, .asm_3db9d - and a - jr nz, .asm_3db8f - inc b - jr .asm_3db8f -.asm_3db9d - ld a, b - ld [wd11e], a - pop bc - ret - -UnknownMovesList_3dba3: ; 3dba3 (f:5ba3) - db SWORDS_DANCE, GROWTH - db $00 - db RECOVER, BIDE, SELFDESTRUCT, AMNESIA - db $00 - db MEDITATE, AGILITY, TELEPORT, MIMIC, DOUBLE_TEAM, BARRAGE - db $00 - db POUND, SCRATCH, VICEGRIP, WING_ATTACK, FLY, BIND, SLAM, HORN_ATTACK, BODY_SLAM - db WRAP, THRASH, TAIL_WHIP, LEER, BITE, GROWL, ROAR, SING, PECK, COUNTER - db STRENGTH, ABSORB, STRING_SHOT, EARTHQUAKE, FISSURE, DIG, TOXIC, SCREECH, HARDEN - db MINIMIZE, WITHDRAW, DEFENSE_CURL, METRONOME, LICK, CLAMP, CONSTRICT, POISON_GAS - db LEECH_LIFE, BUBBLE, FLASH, SPLASH, ACID_ARMOR, FURY_SWIPES, REST, SHARPEN, SLASH, SUBSTITUTE - db $00 - db $FF ; terminator - -PrintMoveFailureText: ; 3dbe2 (f:5be2) - ld de, W_PLAYERMOVEEFFECT - ld a, [H_WHOSETURN] - and a - jr z, .playersTurn - ld de, W_ENEMYMOVEEFFECT -.playersTurn - ld hl, DoesntAffectMonText - ld a, [wd05b] - and $7f - jr z, .asm_3dc04 - ld hl, AttackMissedText - ld a, [wCriticalHitOrOHKO] - cp $ff - jr nz, .asm_3dc04 - ld hl, UnaffectedText -.asm_3dc04 - push de - call PrintText - xor a - ld [wCriticalHitOrOHKO], a - pop de - ld a, [de] - cp JUMP_KICK_EFFECT - ret nz - - ; if you get here, the mon used hi jump kick and missed - ld hl, W_DAMAGE - ld a, [hli] - ld b, [hl] - srl a - rr b - srl a - rr b - srl a - rr b - ld [hl], b - dec hl - ld [hli], a - or b - jr nz, .asm_3dc2a - inc a - ld [hl], a -.asm_3dc2a - ld hl, KeptGoingAndCrashedText - call PrintText - ld b, $4 - predef Func_48125 - ld a, [H_WHOSETURN] - and a - jr nz, .asm_3dc3f - jp ApplyDamageToPlayerPokemon -.asm_3dc3f - jp ApplyDamageToEnemyPokemon - -AttackMissedText: ; 3dc42 (f:5c42) - TX_FAR _AttackMissedText - db "@" - -KeptGoingAndCrashedText: ; 3dc47 (f:5c47) - TX_FAR _KeptGoingAndCrashedText - db "@" - -UnaffectedText: ; 3dc4c (f:5c4c) - TX_FAR _UnaffectedText - db "@" - -PrintDoesntAffectText: ; 3dc51 (f:5c51) - ld hl, DoesntAffectMonText - jp PrintText - -DoesntAffectMonText: ; 3dc57 (f:5c57) - TX_FAR _DoesntAffectMonText - db "@" - -; if there was a critical hit or an OHKO was successful, print the corresponding text -PrintCriticalOHKOText: ; 3dc5c (f:5c5c) - ld a, [wCriticalHitOrOHKO] - and a - jr z, .done ; do nothing if there was no critical hit or successful OHKO - dec a - add a - ld hl, CriticalOHKOTextPointers - ld b, $0 - ld c, a - add hl, bc - ld a, [hli] - ld h, [hl] - ld l, a - call PrintText - xor a - ld [wCriticalHitOrOHKO], a -.done - ld c, $14 - jp DelayFrames - -CriticalOHKOTextPointers: ; 3dc7a (f:5c7a) - dw CriticalHitText - dw OHKOText - -CriticalHitText: ; 3dc7e (f:5c7e) - TX_FAR _CriticalHitText - db "@" - -OHKOText: ; 3dc83 (f:5c83) - TX_FAR _OHKOText - db "@" - -; checks if a traded mon will disobey due to lack of badges -; stores whether the mon will use a move in Z flag -CheckForDisobedience: ; 3dc88 (f:5c88) - xor a - ld [wcced], a - ld a, [W_ISLINKBATTLE] - cp $4 - jr nz, .checkIfMonIsTraded - ld a, $1 - and a - ret -; compare the mon's original trainer ID with the player's ID to see if it was traded -.checkIfMonIsTraded - ld hl, wPartyMon1OTID - ld bc, wPartyMon2 - wPartyMon1 - ld a, [wPlayerMonNumber] - call AddNTimes - ld a, [wPlayerID] - cp [hl] - jr nz, .monIsTraded - inc hl - ld a, [wPlayerID + 1] - cp [hl] - jp z, .canUseMove -; it was traded -.monIsTraded -; what level might disobey? - ld hl, W_OBTAINEDBADGES - bit 7, [hl] - ld a, 101 - jr nz, .next - bit 5, [hl] - ld a, 70 - jr nz, .next - bit 3, [hl] - ld a, 50 - jr nz, .next - bit 1, [hl] - ld a, 30 - jr nz, .next - ld a, 10 -.next - ld b, a - ld c, a - ld a, [wBattleMonLevel] - ld d, a - add b - ld b, a - jr nc, .noCarry - ld b, $ff ; cap b at $ff -.noCarry - ld a, c - cp d - jp nc, .canUseMove -.loop1 - call BattleRandom - swap a - cp b - jr nc, .loop1 - cp c - jp c, .canUseMove -.loop2 - call BattleRandom - cp b - jr nc, .loop2 - cp c - jr c, .useRandomMove - ld a, d - sub c - ld b, a - call BattleRandom - swap a - sub b - jr c, .monNaps - cp b - jr nc, .monDoesNothing - ld hl, WontObeyText - call PrintText - call PrintHurtItselfText - jp .cannotUseMove -.monNaps - call BattleRandom - add a - swap a - and SLP ; sleep mask - jr z, .monNaps ; keep trying until we get at least 1 turn of sleep - ld [wBattleMonStatus], a - ld hl, BeganToNapText - jr .printText -.monDoesNothing - call BattleRandom - and $3 - ld hl, LoafingAroundText - and a - jr z, .printText - ld hl, WontObeyText - dec a - jr z, .printText - ld hl, TurnedAwayText - dec a - jr z, .printText - ld hl, IgnoredOrdersText -.printText - call PrintText - jr .cannotUseMove -.useRandomMove - ld a, [wBattleMonMoves + 1] - and a ; is the second move slot empty? - jr z, .monDoesNothing ; mon will not use move if it only knows one move - ld a, [wccee] - and a - jr nz, .monDoesNothing - ld a, [wPlayerSelectedMove] - cp STRUGGLE - jr z, .monDoesNothing ; mon will not use move if struggling -; check if only one move has remaining PP - ld hl, wBattleMonPP - push hl - ld a, [hli] - and $3f - ld b, a - ld a, [hli] - and $3f - add b - ld b, a - ld a, [hli] - and $3f - add b - ld b, a - ld a, [hl] - and $3f - add b - pop hl - push af - ld a, [wCurrentMenuItem] - ld c, a - ld b, $0 - add hl, bc - ld a, [hl] - and $3f - ld b, a - pop af - cp b - jr z, .monDoesNothing ; mon will not use move if only one move has remaining PP - ld a, $1 - ld [wcced], a - ld a, [wMaxMenuItem] - ld b, a - ld a, [wCurrentMenuItem] - ld c, a -.chooseMove - call BattleRandom - and $3 - cp b - jr nc, .chooseMove ; if the random number is greater than the move count, choose another - cp c - jr z, .chooseMove ; if the random number matches the move the player selected, choose another - ld [wCurrentMenuItem], a - ld hl, wBattleMonPP - ld e, a - ld d, $0 - add hl, de - ld a, [hl] - and a ; does the move have any PP left? - jr z, .chooseMove ; if the move has no PP left, choose another - ld a, [wCurrentMenuItem] - ld c, a - ld b, $0 - ld hl, wBattleMonMoves - add hl, bc - ld a, [hl] - ld [wPlayerSelectedMove], a - call GetCurrentMove -.canUseMove - ld a, $1 - and a; clear Z flag - ret -.cannotUseMove - xor a ; set Z flag - ret - -LoafingAroundText: ; 3ddb6 (f:5db6) - TX_FAR _LoafingAroundText - db "@" - -BeganToNapText: ; 3ddbb (f:5dbb) - TX_FAR _BeganToNapText - db "@" - -WontObeyText: ; 3ddc0 (f:5dc0) - TX_FAR _WontObeyText - db "@" - -TurnedAwayText: ; 3ddc5 (f:5dc5) - TX_FAR _TurnedAwayText - db "@" - -IgnoredOrdersText: ; 3ddca (f:5dca) - TX_FAR _IgnoredOrdersText - db "@" - -; sets b, c, d, and e for the CalculateDamage routine in the case of an attack by the player mon -GetDamageVarsForPlayerAttack: ; 3ddcf (f:5dcf) - xor a - ld hl, W_DAMAGE ; damage to eventually inflict, initialise to zero - ldi [hl], a - ld [hl], a - ld hl, W_PLAYERMOVEPOWER - ld a, [hli] - and a - ld d, a ; d = move power - ret z ; return if move power is zero - ld a, [hl] ; a = [W_PLAYERMOVETYPE] - cp FIRE ; types >= FIRE are all special - jr nc, .specialAttack -.physicalAttack - ld hl, wEnemyMonDefense - ld a, [hli] - ld b, a - ld c, [hl] ; bc = enemy defense - ld a, [W_ENEMYBATTSTATUS3] - bit 2, a ; check for Reflect - jr z, .physicalAttackCritCheck -; if the enemy has used Reflect, double the enemy's defense - sla c - rl b -.physicalAttackCritCheck - ld hl, wBattleMonAttack - ld a, [wCriticalHitOrOHKO] - and a ; check for critical hit - jr z, .scaleStats -; in the case of a critical hit, reset the player's attack and the enemy's defense to their base values - ld c, 3 ; defense stat - call GetEnemyMonStat - ld a, [$ff97] - ld b, a - ld a, [$ff98] - ld c, a - push bc - ld hl, wPartyMon1Attack - ld a, [wPlayerMonNumber] - ld bc, wPartyMon2 - wPartyMon1 - call AddNTimes - pop bc - jr .scaleStats -.specialAttack - ld hl, wEnemyMonSpecial - ld a, [hli] - ld b, a - ld c, [hl] ; bc = enemy special - ld a, [W_ENEMYBATTSTATUS3] - bit 1, a ; check for Light Screen - jr z, .specialAttackCritCheck -; if the enemy has used Light Screen, double the enemy's special - sla c - rl b -.specialAttackCritCheck - ld hl, wBattleMonSpecial - ld a, [wCriticalHitOrOHKO] - and a ; check for critical hit - jr z, .scaleStats -; in the case of a critical hit, reset the player's and enemy's specials to their base values - ld c, 5 ; special stat - call GetEnemyMonStat - ld a, [$ff97] - ld b, a - ld a, [$ff98] - ld c, a - push bc - ld hl, wPartyMon1Special - ld a, [wPlayerMonNumber] - ld bc, wPartyMon2 - wPartyMon1 - call AddNTimes - pop bc -; if either the offensive or defensive stat is too large to store in a byte, scale both stats by dividing them by 4 -; this allows values with up to 10 bits (values up to 1023) to be handled -; anything larger will wrap around -.scaleStats - ld a, [hli] - ld l, [hl] - ld h, a ; hl = player's offensive stat - or b ; is either high byte nonzero? - jr z, .next ; if not, we don't need to scale - ; bc /= 4 (scale enemy's defensive stat) - srl b - rr c - srl b - rr c - ; hl /= 4 (scale player's offensive stat) - srl h - rr l - srl h - rr l - ld a, l - or h ; is the player's offensive stat 0? - jr nz, .next - inc l ; if the player's offensive stat is 0, bump it up to 1 -.next - ld b, l ; b = player's offensive stat (possibly scaled) (c already contains enemy's defensive stat (possibly scaled)) - ld a, [wBattleMonLevel] - ld e, a ; e = level - ld a, [wCriticalHitOrOHKO] - and a ; check for critical hit - jr z, .done - sla e ; double level if it was a critical hit -.done - ld a, 1 - and a - ret - -; sets b, c, d, and e for the CalculateDamage routine in the case of an attack by the enemy mon -GetDamageVarsForEnemyAttack: ; 3de75 (f:5e75) - ld hl, W_DAMAGE ; damage to eventually inflict, initialise to zero - xor a - ld [hli], a - ld [hl], a - ld hl, W_ENEMYMOVEPOWER - ld a, [hli] - ld d, a ; d = move power - and a - ret z ; return if move power is zero - ld a, [hl] ; a = [W_ENEMYMOVETYPE] - cp FIRE ; types >= FIRE are all special - jr nc, .specialAttack -.physicalAttack - ld hl, wBattleMonDefense - ld a, [hli] - ld b, a - ld c, [hl] ; bc = player defense - ld a, [W_PLAYERBATTSTATUS3] - bit 2, a ; check for Reflect - jr z, .physicalAttackCritCheck -; if the player has used Reflect, double the player's defense - sla c - rl b -.physicalAttackCritCheck - ld hl, wEnemyMonAttack - ld a, [wCriticalHitOrOHKO] - and a ; check for critical hit - jr z, .scaleStats -; in the case of a critical hit, reset the player's defense and the enemy's attack to their base values - ld hl, wPartyMon1Defense - ld a, [wPlayerMonNumber] - ld bc, wPartyMon2 - wPartyMon1 - call AddNTimes - ld a, [hli] - ld b, a - ld c, [hl] - push bc - ld c, 2 ; attack stat - call GetEnemyMonStat - ld hl, $ff97 - pop bc - jr .scaleStats -.specialAttack - ld hl, wBattleMonSpecial - ld a, [hli] - ld b, a - ld c, [hl] - ld a, [W_PLAYERBATTSTATUS3] - bit 1, a ; check for Light Screen - jr z, .specialAttackCritCheck -; if the player has used Light Screen, double the player's special - sla c - rl b -.specialAttackCritCheck - ld hl, wEnemyMonSpecial - ld a, [wCriticalHitOrOHKO] - and a ; check for critical hit - jr z, .scaleStats -; in the case of a critical hit, reset the player's and enemy's specials to their base values - ld hl, wPartyMon1Special - ld a, [wPlayerMonNumber] - ld bc, wPartyMon2 - wPartyMon1 - call AddNTimes - ld a, [hli] - ld b, a - ld c, [hl] - push bc - ld c, 5 ; special stat - call GetEnemyMonStat - ld hl, $ff97 - pop bc -; if either the offensive or defensive stat is too large to store in a byte, scale both stats by dividing them by 4 -; this allows values with up to 10 bits (values up to 1023) to be handled -; anything larger will wrap around -.scaleStats - ld a, [hli] - ld l, [hl] - ld h, a ; hl = enemy's offensive stat - or b ; is either high byte nonzero? - jr z, .next ; if not, we don't need to scale -; bc /= 4 (scale player's defensive stat) - srl b - rr c - srl b - rr c -; hl /= 4 (scale enemy's offensive stat) - srl h - rr l - srl h - rr l - ld a, l - or h ; is the enemy's offensive stat 0? - jr nz, .next - inc l ; if the enemy's offensive stat is 0, bump it up to 1 -.next - ld b, l ; b = enemy's offensive stat (possibly scaled) (c already contains player's defensive stat (possibly scaled)) - ld a, [wEnemyMonLevel] - ld e, a - ld a, [wCriticalHitOrOHKO] - and a ; check for critical hit - jr z, .done - sla e ; double level if it was a critical hit -.done - ld a, $1 - and a - and a - ret - -; get stat c of enemy mon -; c: stat to get (HP=1,Attack=2,Defense=3,Speed=4,Special=5) -GetEnemyMonStat: ; 3df1c (f:5f1c) - push de - push bc - ld a, [W_ISLINKBATTLE] - cp $4 - jr nz, .asm_3df40 - ld hl, wEnemyMon1Stats - dec c - sla c - ld b, $0 - add hl, bc - ld a, [wEnemyMonPartyPos] - ld bc, wEnemyMon2 - wEnemyMon1 - call AddNTimes - ld a, [hli] - ld [$ff97], a - ld a, [hl] - ld [$ff98], a - pop bc - pop de - ret -.asm_3df40 - ld a, [wEnemyMonLevel] - ld [W_CURENEMYLVL], a - ld a, [wEnemyMonSpecies] - ld [wd0b5], a - call GetMonHeader - ld hl, wEnemyMonDVs - ld de, wcfaf - ld a, [hli] - ld [de], a - inc de - ld a, [hl] - ld [de], a - pop bc - ld b, $0 - ld hl, wcfa4 - call CalcStat - pop de - ret - -CalculateDamage: ; 3df65 (f:5f65) -; input: -; b: attack -; c: opponent defense -; d: base power -; e: level - - ld a, [$fff3] ; whose turn? - and a - ld a, [W_PLAYERMOVEEFFECT] - jr z, .effect - ld a, [W_ENEMYMOVEEFFECT] -.effect - -; EXPLODE_EFFECT halves defense. - cp a, EXPLODE_EFFECT - jr nz, .ok - srl c - jr nz, .ok - inc c ; ...with a minimum value of 1 (used as a divisor later on) -.ok - -; Multi-hit attacks may or may not have 0 bp. - cp a, TWO_TO_FIVE_ATTACKS_EFFECT - jr z, .skipbp - cp a, $1e - jr z, .skipbp - -; Calculate OHKO damage based on remaining HP. - cp a, OHKO_EFFECT - jp z, Func_3e016 - -; Don't calculate damage for moves that don't do any. - ld a, d ; base power - and a - ret z -.skipbp - - xor a - ld hl, H_DIVIDEND - ldi [hl], a - ldi [hl], a - ld [hl], a - -; Multiply level by 2 - ld a, e ; level - add a - jr nc, .nc - push af - ld a, 1 - ld [hl], a - pop af -.nc - inc hl - ldi [hl], a - -; Divide by 5 - ld a, 5 - ldd [hl], a - push bc - ld b, 4 - call Divide - pop bc - -; Add 2 - inc [hl] - inc [hl] - - inc hl ; multiplier - -; Multiply by attack base power - ld [hl], d - call Multiply - -; Multiply by attack stat - ld [hl], b - call Multiply - -; Divide by defender's defense stat - ld [hl], c - ld b, 4 - call Divide - -; Divide by 50 - ld [hl], 50 - ld b, 4 - call Divide - - ld hl, W_DAMAGE - ld b, [hl] - ld a, [H_QUOTIENT + 3] - add b - ld [H_QUOTIENT + 3], a - jr nc, .asm_3dfd0 - - ld a, [H_QUOTIENT + 2] - inc a - ld [H_QUOTIENT + 2], a - and a - jr z, .asm_3e004 - -.asm_3dfd0 - ld a, [H_QUOTIENT] - ld b, a - ld a, [H_QUOTIENT + 1] - or a - jr nz, .asm_3e004 - - ld a, [H_QUOTIENT + 2] - cp 998 / $100 - jr c, .asm_3dfe8 - cp 998 / $100 + 1 - jr nc, .asm_3e004 - ld a, [H_QUOTIENT + 3] - cp 998 % $100 - jr nc, .asm_3e004 - -.asm_3dfe8 - inc hl - ld a, [H_QUOTIENT + 3] - ld b, [hl] - add b - ld [hld], a - - ld a, [H_QUOTIENT + 2] - ld b, [hl] - adc b - ld [hl], a - jr c, .asm_3e004 - - ld a, [hl] - cp 998 / $100 - jr c, .asm_3e00a - cp 998 / $100 + 1 - jr nc, .asm_3e004 - inc hl - ld a, [hld] - cp 998 % $100 - jr c, .asm_3e00a - -.asm_3e004 - ld a, 997 / $100 - ld [hli], a - ld a, 997 % $100 - ld [hld], a - -.asm_3e00a - inc hl - ld a, [hl] - add 2 - ld [hld], a - jr nc, .done - inc [hl] -.done - - ld a, 1 - and a - ret - -Func_3e016: ; 3e016 (f:6016) - call JumpMoveEffect - ld a, [W_MOVEMISSED] - dec a - ret - - -UnusedHighCriticalMoves: ; 3e01e (f:601e) - db KARATE_CHOP - db RAZOR_LEAF - db CRABHAMMER - db SLASH - db $FF -; 3e023 - -; determines if attack is a critical hit -; azure heights claims "the fastest pokémon (who are,not coincidentally, -; among the most popular) tend to CH about 20 to 25% of the time." -CriticalHitTest: ; 3e023 (f:6023) - xor a - ld [wCriticalHitOrOHKO], a - ld a, [H_WHOSETURN] - and a - ld a, [wEnemyMonSpecies] - jr nz, .asm_3e032 - ld a, [wBattleMonSpecies] -.asm_3e032 - ld [wd0b5], a - call GetMonHeader - ld a, [W_MONHBASESPEED] - ld b, a - srl b ; (effective (base speed/2)) - ld a, [H_WHOSETURN] - and a - ld hl, W_PLAYERMOVEPOWER - ld de, W_PLAYERBATTSTATUS2 - jr z, .calcCriticalHitProbability - ld hl, W_ENEMYMOVEPOWER - ld de, W_ENEMYBATTSTATUS2 -.calcCriticalHitProbability ; 0x3e04f - ld a, [hld] ; read base power from RAM - and a - ret z ; do nothing if zero - dec hl - ld c, [hl] ; read move id - ld a, [de] - bit 2, a ; test for focus energy - jr nz, .focusEnergyUsed ; bug: using focus energy causes a shift to the right instead of left, - ; resulting in 1/4 the usual crit chance - sla b ; (effective (base speed/2)*2) - jr nc, .noFocusEnergyUsed - ld b, $ff ; cap at 255/256 - jr .noFocusEnergyUsed -.focusEnergyUsed - srl b -.noFocusEnergyUsed - ld hl, HighCriticalMoves ; table of high critical hit moves -.Loop - ld a, [hli] ; read move from move table - cp c ; does it match the move about to be used? - jr z, .HighCritical ; if so, the move about to be used is a high critical hit ratio move - inc a ; move on to the next move, FF terminates loop - jr nz, .Loop ; check the next move in HighCriticalMoves - srl b ; /2 for regular move (effective (base speed / 2)) - jr .SkipHighCritical ; continue as a normal move -.HighCritical - sla b ; *2 for high critical hit moves - jr nc, .noCarry - ld b, $ff ; cap at 255/256 -.noCarry - sla b ; *4 for high critical move (effective (base speed/2)*8)) - jr nc, .SkipHighCritical - ld b, $ff -.SkipHighCritical - call BattleRandom ; generates a random value, in "a" - rlc a - rlc a - rlc a - cp b ; check a against calculated crit rate - ret nc ; no critical hit if no borrow - ld a, $1 - ld [wCriticalHitOrOHKO], a ; set critical hit flag - ret - -; high critical hit moves -HighCriticalMoves: ; 3e08e (f:608e) - db KARATE_CHOP - db RAZOR_LEAF - db CRABHAMMER - db SLASH - db $FF - - -; function to determine if Counter hits and if so, how much damage it does -HandleCounterMove: ; 3e093 (f:6093) - ld a,[H_WHOSETURN] ; whose turn - and a -; player's turn - ld hl,wEnemySelectedMove - ld de,W_ENEMYMOVEPOWER - ld a,[wPlayerSelectedMove] - jr z,.next -; enemy's turn - ld hl,wPlayerSelectedMove - ld de,W_PLAYERMOVEPOWER - ld a,[wEnemySelectedMove] -.next - cp a,COUNTER - ret nz ; return if not using Counter - ld a,$01 - ld [W_MOVEMISSED],a ; initialize the move missed variable to true (it is set to false below if the move hits) - ld a,[hl] - cp a,COUNTER - ret z ; if the target also used Counter, miss - ld a,[de] - and a - ret z ; if the move the target used has 0 power, miss -; check if the move the target used was Normal or Fighting type - inc de - ld a,[de] - and a ; normal type - jr z,.counterableType - cp a,FIGHTING - jr z,.counterableType -; if the move wasn't Normal or Fighting type, miss - xor a - ret -.counterableType - ld hl,W_DAMAGE - ld a,[hli] - or [hl] - ret z ; Counter misses if the target did no damage to the Counter user -; double the damage that the target did to the Counter user - ld a,[hl] - add a - ldd [hl],a - ld a,[hl] - adc a - ld [hl],a - jr nc,.noCarry -; damage is capped at 0xFFFF - ld a,$ff - ld [hli],a - ld [hl],a -.noCarry - xor a - ld [W_MOVEMISSED],a - call MoveHitTest ; do the normal move hit test in addition to Counter's special rules - xor a - ret - -ApplyAttackToEnemyPokemon: ; 3e0df (f:60df) - ld a,[W_PLAYERMOVEEFFECT] - cp a,OHKO_EFFECT - jr z,ApplyDamageToEnemyPokemon - cp a,SUPER_FANG_EFFECT - jr z,.superFangEffect - cp a,SPECIAL_DAMAGE_EFFECT - jr z,.specialDamage - ld a,[W_PLAYERMOVEPOWER] - and a - jp z,ApplyAttackToEnemyPokemonDone - jr ApplyDamageToEnemyPokemon -.superFangEffect -; set the damage to half the target's HP - ld hl,wEnemyMonHP - ld de,W_DAMAGE - ld a,[hli] - srl a - ld [de],a - inc de - ld b,a - ld a,[hl] - rr a - ld [de],a - or b - jr nz,ApplyDamageToEnemyPokemon -; make sure Super Fang's damage is always at least 1 - ld a,$01 - ld [de],a - jr ApplyDamageToEnemyPokemon -.specialDamage - ld hl,wBattleMonLevel - ld a,[hl] - ld b,a - ld a,[W_PLAYERMOVENUM] - cp a,SEISMIC_TOSS - jr z,.storeDamage - cp a,NIGHT_SHADE - jr z,.storeDamage - ld b,SONICBOOM_DAMAGE - cp a,SONICBOOM - jr z,.storeDamage - ld b,DRAGON_RAGE_DAMAGE - cp a,DRAGON_RAGE - jr z,.storeDamage -; Psywave - ld a,[hl] - ld b,a - srl a - add b - ld b,a ; b = level * 1.5 -; loop until a random number in the range [1, b) is found -.loop - call BattleRandom - and a - jr z,.loop - cp b - jr nc,.loop - ld b,a -.storeDamage - ld hl,W_DAMAGE - xor a - ld [hli],a - ld a,b - ld [hl],a - -ApplyDamageToEnemyPokemon: ; 3e142 (f:6142) - ld hl,W_DAMAGE - ld a,[hli] - ld b,a - ld a,[hl] - or b - jr z,ApplyAttackToEnemyPokemonDone ; we're done if damage is 0 - ld a,[W_ENEMYBATTSTATUS2] - bit 4,a ; does the enemy have a substitute? - jp nz,AttackSubstitute -; subtract the damage from the pokemon's current HP -; also, save the current HP at wHPBarOldHP - ld a,[hld] - ld b,a - ld a,[wEnemyMonHP + 1] - ld [wHPBarOldHP],a - sub b - ld [wEnemyMonHP + 1],a - ld a,[hl] - ld b,a - ld a,[wEnemyMonHP] - ld [wHPBarOldHP+1],a - sbc b - ld [wEnemyMonHP],a - jr nc,.animateHpBar -; if more damage was done than the current HP, zero the HP and set the damage -; equal to how much HP the pokemon had before the attack - ld a,[wHPBarOldHP+1] - ld [hli],a - ld a,[wHPBarOldHP] - ld [hl],a - xor a - ld hl,wEnemyMonHP - ld [hli],a - ld [hl],a -.animateHpBar - ld hl,wEnemyMonMaxHP - ld a,[hli] - ld [wHPBarMaxHP+1],a - ld a,[hl] - ld [wHPBarMaxHP],a - ld hl,wEnemyMonHP - ld a,[hli] - ld [wHPBarNewHP+1],a - ld a,[hl] - ld [wHPBarNewHP],a - hlCoord 2, 2 - xor a - ld [wListMenuID],a - predef UpdateHPBar2 ; animate the HP bar shortening -ApplyAttackToEnemyPokemonDone: ; 3e19d (f:619d) - jp DrawHUDsAndHPBars - -ApplyAttackToPlayerPokemon: ; 3e1a0 (f:61a0) - ld a,[W_ENEMYMOVEEFFECT] - cp a,OHKO_EFFECT - jr z,ApplyDamageToPlayerPokemon - cp a,SUPER_FANG_EFFECT - jr z,.superFangEffect - cp a,SPECIAL_DAMAGE_EFFECT - jr z,.specialDamage - ld a,[W_ENEMYMOVEPOWER] - and a - jp z,ApplyAttackToPlayerPokemonDone - jr ApplyDamageToPlayerPokemon -.superFangEffect -; set the damage to half the target's HP - ld hl,wBattleMonHP - ld de,W_DAMAGE - ld a,[hli] - srl a - ld [de],a - inc de - ld b,a - ld a,[hl] - rr a - ld [de],a - or b - jr nz,ApplyDamageToPlayerPokemon -; make sure Super Fang's damage is always at least 1 - ld a,$01 - ld [de],a - jr ApplyDamageToPlayerPokemon -.specialDamage - ld hl,wEnemyMonLevel - ld a,[hl] - ld b,a - ld a,[W_ENEMYMOVENUM] - cp a,SEISMIC_TOSS - jr z,.storeDamage - cp a,NIGHT_SHADE - jr z,.storeDamage - ld b,SONICBOOM_DAMAGE - cp a,SONICBOOM - jr z,.storeDamage - ld b,DRAGON_RAGE_DAMAGE - cp a,DRAGON_RAGE - jr z,.storeDamage -; Psywave - ld a,[hl] - ld b,a - srl a - add b - ld b,a ; b = attacker's level * 1.5 -; loop until a random number in the range [0, b) is found -; this differs from the range when the player attacks, which is [1, b) -; it's possible for the enemy to do 0 damage with Psywave, but the player always does at least 1 damage -.loop - call BattleRandom - cp b - jr nc,.loop - ld b,a -.storeDamage - ld hl,W_DAMAGE - xor a - ld [hli],a - ld a,b - ld [hl],a - -ApplyDamageToPlayerPokemon: ; 3e200 (f:6200) - ld hl,W_DAMAGE - ld a,[hli] - ld b,a - ld a,[hl] - or b - jr z,ApplyAttackToPlayerPokemonDone ; we're done if damage is 0 - ld a,[W_PLAYERBATTSTATUS2] - bit 4,a ; does the player have a substitute? - jp nz,AttackSubstitute -; subtract the damage from the pokemon's current HP -; also, save the current HP at wHPBarOldHP and the new HP at wHPBarNewHP - ld a,[hld] - ld b,a - ld a,[wBattleMonHP + 1] - ld [wHPBarOldHP],a - sub b - ld [wBattleMonHP + 1],a - ld [wHPBarNewHP],a - ld b,[hl] - ld a,[wBattleMonHP] - ld [wHPBarOldHP+1],a - sbc b - ld [wBattleMonHP],a - ld [wHPBarNewHP+1],a - jr nc,.animateHpBar -; if more damage was done than the current HP, zero the HP and set the damage -; equal to how much HP the pokemon had before the attack - ld a,[wHPBarOldHP+1] - ld [hli],a - ld a,[wHPBarOldHP] - ld [hl],a - xor a - ld hl,wBattleMonHP - ld [hli],a - ld [hl],a - ld hl,wHPBarNewHP - ld [hli],a - ld [hl],a -.animateHpBar - ld hl,wBattleMonMaxHP - ld a,[hli] - ld [wHPBarMaxHP+1],a - ld a,[hl] - ld [wHPBarMaxHP],a - hlCoord 10, 9 - ld a,$01 - ld [wListMenuID],a - predef UpdateHPBar2 ; animate the HP bar shortening -ApplyAttackToPlayerPokemonDone - jp DrawHUDsAndHPBars - -AttackSubstitute: ; 3e25e (f:625e) - ld hl,SubstituteTookDamageText - call PrintText -; values for player turn - ld de,wEnemySubstituteHP - ld bc,W_ENEMYBATTSTATUS2 - ld a,[H_WHOSETURN] - and a - jr z,.applyDamageToSubstitute -; values for enemy turn - ld de,wPlayerSubstituteHP - ld bc,W_PLAYERBATTSTATUS2 -.applyDamageToSubstitute - ld hl,W_DAMAGE - ld a,[hli] - and a - jr nz,.substituteBroke ; damage > 0xFF always breaks substitutes -; subtract damage from HP of substitute - ld a,[de] - sub [hl] - ld [de],a - ret nc -.substituteBroke - ld h,b - ld l,c - res 4,[hl] ; unset the substitute bit - ld hl,SubstituteBrokeText - call PrintText -; flip whose turn it is for the next function call - ld a,[H_WHOSETURN] - xor a,$01 - ld [H_WHOSETURN],a - callab Func_79747 ; animate the substitute breaking -; flip the turn back to the way it was - ld a,[H_WHOSETURN] - xor a,$01 - ld [H_WHOSETURN],a - ld hl,W_PLAYERMOVEEFFECT ; value for player's turn - and a - jr z,.nullifyEffect - ld hl,W_ENEMYMOVEEFFECT ; value for enemy's turn -.nullifyEffect - xor a - ld [hl],a ; zero the effect of the attacker's move - jp DrawHUDsAndHPBars - -SubstituteTookDamageText: ; 3e2ac (f:62ac) - TX_FAR _SubstituteTookDamageText - db "@" - -SubstituteBrokeText: ; 3e2b1 (f:62b1) - TX_FAR _SubstituteBrokeText - db "@" - -; this function raises the attack modifier of a pokemon using Rage when that pokemon is attacked -HandleBuildingRage: ; 3e2b6 (f:62b6) -; values for the player turn - ld hl,W_ENEMYBATTSTATUS2 - ld de,wEnemyMonStatMods - ld bc,W_ENEMYMOVENUM - ld a,[H_WHOSETURN] - and a - jr z,.next -; values for the enemy turn - ld hl,W_PLAYERBATTSTATUS2 - ld de,wPlayerMonStatMods - ld bc,W_PLAYERMOVENUM -.next - bit 6,[hl] ; is the pokemon being attacked under the effect of Rage? - ret z ; return if not - ld a,[de] - cp a,$0d ; maximum stat modifier value - ret z ; return if attack modifier is already maxed - ld a,[H_WHOSETURN] - xor a,$01 ; flip turn for the stat modifier raising function - ld [H_WHOSETURN],a -; change the target pokemon's move to $00 and the effect to the one -; that causes the attack modifier to go up one stage - ld h,b - ld l,c - ld [hl],$00 ; null move number - inc hl - ld [hl],ATTACK_UP1_EFFECT - push hl - ld hl,BuildingRageText - call PrintText - call StatModifierUpEffect ; stat modifier raising function - pop hl - xor a - ldd [hl],a ; null move effect - ld a,RAGE - ld [hl],a ; restore the target pokemon's move number to Rage - ld a,[H_WHOSETURN] - xor a,$01 ; flip turn back to the way it was - ld [H_WHOSETURN],a - ret - -BuildingRageText: ; 3e2f8 (f:62f8) - TX_FAR _BuildingRageText - db "@" - -; copy last move for Mirror Move -; sets zero flag on failure and unsets zero flag on success -MirrorMoveCopyMove: ; 3e2fd (f:62fd) - ld a,[H_WHOSETURN] - and a -; values for player turn - ld a,[wccf2] - ld hl,wPlayerSelectedMove - ld de,W_PLAYERMOVENUM - jr z,.next -; values for enemy turn - ld a,[wccf1] - ld de,W_ENEMYMOVENUM - ld hl,wEnemySelectedMove -.next - ld [hl],a - cp a,MIRROR_MOVE ; did the target pokemon also use Mirror Move? - jr z,.mirrorMoveFailed - and a ; null move? - jr nz,ReloadMoveData -.mirrorMoveFailed -; Mirror Move fails on itself and null moves - ld hl,MirrorMoveFailedText - call PrintText - xor a - ret - -MirrorMoveFailedText: ; 3e324 (f:6324) - TX_FAR _MirrorMoveFailedText - db "@" - -; function used to reload move data for moves like Mirror Move and Metronome -ReloadMoveData: ; 3e329 (f:6329) - ld [wd11e],a - dec a - ld hl,Moves - ld bc,$0006 - call AddNTimes - ld a,BANK(Moves) - call FarCopyData ; copy the move's stats - call IncrementMovePP -; the follow two function calls are used to reload the move name - call GetMoveName - call CopyStringToCF4B - ld a,$01 - and a - ret - -; function that picks a random move for metronome -MetronomePickMove: ; 3e348 (f:6348) - xor a - ld [wcc5b],a - ld a,METRONOME - call PlayMoveAnimation ; play Metronome's animation -; values for player turn - ld de,W_PLAYERMOVENUM - ld hl,wPlayerSelectedMove - ld a,[H_WHOSETURN] - and a - jr z,.pickMoveLoop -; values for enemy turn - ld de,W_ENEMYMOVENUM - ld hl,wEnemySelectedMove -; loop to pick a random number in the range [1, $a5) to be the move used by Metronome -.pickMoveLoop - call BattleRandom - and a - jr z,.pickMoveLoop - cp a,NUM_ATTACKS + 1 ; max normal move number + 1 (this is Struggle's move number) - jr nc,.pickMoveLoop - cp a,METRONOME - jr z,.pickMoveLoop - ld [hl],a - jr ReloadMoveData - -; this function increments the current move's PP -; it's used to prevent moves that run another move within the same turn -; (like Mirror Move and Metronome) from losing 2 PP -IncrementMovePP: ; 3e373 (f:6373) - ld a,[H_WHOSETURN] - and a -; values for player turn - ld hl,wBattleMonPP - ld de,wPartyMon1PP - ld a,[wPlayerMoveListIndex] - jr z,.next -; values for enemy turn - ld hl,wEnemyMonPP - ld de,wEnemyMon1PP - ld a,[wEnemyMoveListIndex] -.next - ld b,$00 - ld c,a - add hl,bc - inc [hl] ; increment PP in the currently battling pokemon memory location - ld h,d - ld l,e - add hl,bc - ld a,[H_WHOSETURN] - and a - ld a,[wPlayerMonNumber] ; value for player turn - jr z,.next2 - ld a,[wEnemyMonPartyPos] ; value for enemy turn -.next2 - ld bc,wEnemyMon2 - wEnemyMon1 - call AddNTimes - inc [hl] ; increment PP in the party memory location - ret - -; function to adjust the base damage of an attack to account for type effectiveness -AdjustDamageForMoveType: ; 3e3a5 (f:63a5) -; values for player turn - ld hl,wBattleMonType - ld a,[hli] - ld b,a ; b = type 1 of attacker - ld c,[hl] ; c = type 2 of attacker - ld hl,wEnemyMonType - ld a,[hli] - ld d,a ; d = type 1 of defender - ld e,[hl] ; e = type 2 of defender - ld a,[W_PLAYERMOVETYPE] - ld [wd11e],a - ld a,[H_WHOSETURN] - and a - jr z,.next -; values for enemy turn - ld hl,wEnemyMonType - ld a,[hli] - ld b,a ; b = type 1 of attacker - ld c,[hl] ; c = type 2 of attacker - ld hl,wBattleMonType - ld a,[hli] - ld d,a ; d = type 1 of defender - ld e,[hl] ; e = type 2 of defender - ld a,[W_ENEMYMOVETYPE] - ld [wd11e],a -.next - ld a,[wd11e] ; move type - cp b ; does the move type match type 1 of the attacker? - jr z,.sameTypeAttackBonus - cp c ; does the move type match type 2 of the attacker? - jr z,.sameTypeAttackBonus - jr .skipSameTypeAttackBonus -.sameTypeAttackBonus -; if the move type matches one of the attacker's types - ld hl,W_DAMAGE + 1 - ld a,[hld] - ld h,[hl] - ld l,a ; hl = damage - ld b,h - ld c,l ; bc = damage - srl b - rr c ; bc = floor(0.5 * damage) - add hl,bc ; hl = floor(1.5 * damage) -; store damage - ld a,h - ld [W_DAMAGE],a - ld a,l - ld [W_DAMAGE + 1],a - ld hl,wd05b - set 7,[hl] -.skipSameTypeAttackBonus - ld a,[wd11e] - ld b,a ; b = move type - ld hl,TypeEffects -.loop - ld a,[hli] ; a = "attacking type" of the current type pair - cp a,$ff - jr z,.done - cp b ; does move type match "attacking type"? - jr nz,.nextTypePair - ld a,[hl] ; a = "defending type" of the current type pair - cp d ; does type 1 of defender match "defending type"? - jr z,.matchingPairFound - cp e ; does type 2 of defender match "defending type"? - jr z,.matchingPairFound - jr .nextTypePair -.matchingPairFound -; if the move type matches the "attacking type" and one of the defender's types matches the "defending type" - push hl - push bc - inc hl - ld a,[wd05b] - and a,$80 - ld b,a - ld a,[hl] ; a = damage multiplier - ld [H_MULTIPLIER],a - add b - ld [wd05b],a - xor a - ld [H_MULTIPLICAND],a - ld hl,W_DAMAGE - ld a,[hli] - ld [H_MULTIPLICAND + 1],a - ld a,[hld] - ld [H_MULTIPLICAND + 2],a - call Multiply - ld a,10 - ld [H_DIVISOR],a - ld b,$04 - call Divide - ld a,[H_QUOTIENT + 2] - ld [hli],a - ld b,a - ld a,[H_QUOTIENT + 3] - ld [hl],a - or b ; is damage 0? - jr nz,.skipTypeImmunity -.typeImmunity -; if damage is 0, make the move miss - inc a - ld [W_MOVEMISSED],a -.skipTypeImmunity - pop bc - pop hl -.nextTypePair - inc hl - inc hl - jp .loop -.done - ret - -; function to tell how effective the type of an enemy attack is on the player's current pokemon -; this doesn't take into account the effects that dual types can have -; (e.g. 4x weakness / resistance, weaknesses and resistances canceling) -; the result is stored in [wd11e] -; ($05 is not very effective, $10 is neutral, $14 is super effective) -; as far is can tell, this is only used once in some AI code to help decide which move to use -AIGetTypeEffectiveness: ; 3e449 (f:6449) - ld a,[W_ENEMYMOVETYPE] - ld d,a ; d = type of enemy move - ld hl,wBattleMonType - ld b,[hl] ; b = type 1 of player's pokemon - inc hl - ld c,[hl] ; c = type 2 of player's pokemon - ld a,$10 - ld [wd11e],a ; initialize [wd11e] to neutral effectiveness - ld hl,TypeEffects -.loop - ld a,[hli] - cp a,$ff - ret z - cp d ; match the type of the move - jr nz,.nextTypePair1 - ld a,[hli] - cp b ; match with type 1 of pokemon - jr z,.done - cp c ; or match with type 2 of pokemon - jr z,.done - jr .nextTypePair2 -.nextTypePair1 - inc hl -.nextTypePair2 - inc hl - jr .loop -.done - ld a,[hl] - ld [wd11e],a ; store damage multiplier - ret - -INCLUDE "data/type_effects.asm" - -; some tests that need to pass for a move to hit -MoveHitTest: ; 3e56b (f:656b) -; player's turn - ld hl,W_ENEMYBATTSTATUS1 - ld de,W_PLAYERMOVEEFFECT - ld bc,wEnemyMonStatus - ld a,[H_WHOSETURN] - and a - jr z,.dreamEaterCheck -; enemy's turn - ld hl,W_PLAYERBATTSTATUS1 - ld de,W_ENEMYMOVEEFFECT - ld bc,wBattleMonStatus -.dreamEaterCheck - ld a,[de] - cp a,DREAM_EATER_EFFECT - jr nz,.swiftCheck - ld a,[bc] - and a,$07 ; is the target pokemon sleeping? - jp z,.moveMissed -.swiftCheck - ld a,[de] - cp a,SWIFT_EFFECT - ret z ; Swift never misses (interestingly, Azure Heights lists this is a myth, but it appears to be true) - call CheckTargetSubstitute ; substitute check (note that this overwrites a) - jr z,.checkForDigOrFlyStatus -; this code is buggy. it's supposed to prevent HP draining moves from working on substitutes. -; since $7b79 overwrites a with either $00 or $01, it never works. - cp a,DRAIN_HP_EFFECT - jp z,.moveMissed - cp a,DREAM_EATER_EFFECT - jp z,.moveMissed -.checkForDigOrFlyStatus - bit 6,[hl] - jp nz,.moveMissed - ld a,[H_WHOSETURN] - and a - jr nz,.enemyTurn -.playerTurn -; this checks if the move effect is disallowed by mist - ld a,[W_PLAYERMOVEEFFECT] - cp a,ATTACK_DOWN1_EFFECT - jr c,.skipEnemyMistCheck - cp a,BIDE_EFFECT - jr c,.enemyMistCheck - cp a,$3a - jr c,.skipEnemyMistCheck - cp a,POISON_EFFECT - jr c,.enemyMistCheck - jr .skipEnemyMistCheck -.enemyMistCheck -; if move effect is from $12 to $19 inclusive or $3a to $41 inclusive -; i.e. the following moves -; GROWL, TAIL WHIP, LEER, STRING SHOT, SAND-ATTACK, SMOKESCREEN, KINESIS, -; FLASH, CONVERSION, HAZE*, SCREECH, LIGHT SCREEN*, REFLECT* -; the moves that are marked with an asterisk are not affected since this -; function is not called when those moves are used -; XXX are there are any others like those three? - ld a,[W_ENEMYBATTSTATUS2] - bit 1,a ; is mon protected by mist? - jp nz,.moveMissed -.skipEnemyMistCheck - ld a,[W_PLAYERBATTSTATUS2] - bit 0,a ; is the player using X Accuracy? - ret nz ; if so, always hit regardless of accuracy/evasion - jr .calcHitChance -.enemyTurn - ld a,[W_ENEMYMOVEEFFECT] - cp a,ATTACK_DOWN1_EFFECT - jr c,.skipPlayerMistCheck - cp a,BIDE_EFFECT - jr c,.playerMistCheck - cp a,$3a - jr c,.skipPlayerMistCheck - cp a,POISON_EFFECT - jr c,.playerMistCheck - jr .skipPlayerMistCheck -.playerMistCheck -; similar to enemy mist check - ld a,[W_PLAYERBATTSTATUS2] - bit 1,a ; is mon protected by mist? - jp nz,.moveMissed -.skipPlayerMistCheck - ld a,[W_ENEMYBATTSTATUS2] - bit 0,a ; is the enemy using X Accuracy? - ret nz ; if so, always hit regardless of accuracy/evasion -.calcHitChance - call CalcHitChance ; scale the move accuracy according to attacker's accuracy and target's evasion - ld a,[W_PLAYERMOVEACCURACY] - ld b,a - ld a,[H_WHOSETURN] - and a - jr z,.doAccuracyCheck - ld a,[W_ENEMYMOVEACCURACY] - ld b,a -.doAccuracyCheck -; if the random number generated is greater than or equal to the scaled accuracy, the move misses -; note that this means that even the highest accuracy is still just a 255/256 chance, not 100% - call BattleRandom - cp b - jr nc,.moveMissed - ret -.moveMissed - xor a - ld hl,W_DAMAGE ; zero the damage - ld [hli],a - ld [hl],a - inc a - ld [W_MOVEMISSED],a - ld a,[H_WHOSETURN] - and a - jr z,.playerTurn2 -.enemyTurn2 - ld hl,W_ENEMYBATTSTATUS1 - res 5,[hl] ; end multi-turn attack e.g. wrap - ret -.playerTurn2 - ld hl,W_PLAYERBATTSTATUS1 - res 5,[hl] ; end multi-turn attack e.g. wrap - ret - -; values for player turn -CalcHitChance: ; 3e624 (f:6624) - ld hl,W_PLAYERMOVEACCURACY - ld a,[H_WHOSETURN] - and a - ld a,[wPlayerMonAccuracyMod] - ld b,a - ld a,[wEnemyMonEvasionMod] - ld c,a - jr z,.next -; values for enemy turn - ld hl,W_ENEMYMOVEACCURACY - ld a,[wEnemyMonAccuracyMod] - ld b,a - ld a,[wPlayerMonEvasionMod] - ld c,a -.next - ld a,$0e - sub c - ld c,a ; c = 14 - EVASIONMOD (this "reflects" the value over 7, so that an increase in the target's evasion decreases the hit chance instead of increasing the hit chance) -; zero the high bytes of the multiplicand - xor a - ld [H_MULTIPLICAND],a - ld [H_MULTIPLICAND + 1],a - ld a,[hl] - ld [H_MULTIPLICAND + 2],a ; set multiplicand to move accuracy - push hl - ld d,$02 ; loop has two iterations -; loop to do the calculations, the first iteration multiplies by the accuracy ratio and the second iteration multiplies by the evasion ratio -.loop - push bc - ld hl, StatModifierRatios ; $76cb ; stat modifier ratios - dec b - sla b - ld c,b - ld b,$00 - add hl,bc ; hl = address of stat modifier ratio - pop bc - ld a,[hli] - ld [H_MULTIPLIER],a ; set multiplier to the numerator of the ratio - call Multiply - ld a,[hl] - ld [H_DIVISOR],a ; set divisor to the the denominator of the ratio (the dividend is the product of the previous multiplication) - ld b,$04 ; number of bytes in the dividend - call Divide - ld a,[H_QUOTIENT + 3] - ld b,a - ld a,[H_QUOTIENT + 2] - or b - jp nz,.nextCalculation -; make sure the result is always at least one - ld [H_QUOTIENT + 2],a - ld a,$01 - ld [H_QUOTIENT + 3],a -.nextCalculation - ld b,c - dec d - jr nz,.loop - ld a,[H_QUOTIENT + 2] - and a ; is the calculated hit chance over 0xFF? - ld a,[H_QUOTIENT + 3] - jr z,.storeAccuracy -; if calculated hit chance over 0xFF - ld a,$ff ; set the hit chance to 0xFF -.storeAccuracy - pop hl - ld [hl],a ; store the hit chance in the move accuracy variable - ret - -; multiplies damage by a random percentage from ~85% to 100% -RandomizeDamage: ; 3e687 (f:6687) - ld hl, W_DAMAGE - ld a, [hli] - and a - jr nz, .DamageGreaterThanOne - ld a, [hl] - cp 2 - ret c -.DamageGreaterThanOne - xor a - ld [H_MULTIPLICAND], a - dec hl - ld a, [hli] - ld [H_MULTIPLICAND + 1], a - ld a, [hl] - ld [H_MULTIPLICAND + 2], a -; loop until a random number greater than or equal to 217 is generated -.loop - call BattleRandom - rrca - cp 217 - jr c, .loop - ld [H_MULTIPLIER], a - call Multiply ; multiply damage by the random number, which is in the range [217, 255] - ld a, 255 - ld [H_DIVISOR], a - ld b, $4 - call Divide ; divide the result by 255 -; store the modified damage - ld a, [H_QUOTIENT + 2] - ld hl, W_DAMAGE - ld [hli], a - ld a, [H_QUOTIENT + 3] - ld [hl], a - ret - -ExecuteEnemyMove: ; 3e6bc (f:66bc) - ld a, [wEnemySelectedMove] - inc a - jp z, Func_3e88c - call PrintGhostText - jp z, Func_3e88c - ld a, [W_ISLINKBATTLE] - cp $4 - jr nz, .asm_3e6dc - ld b, $1 - ld a, [wcc3e] - cp $e - jr z, .asm_3e6dc - cp $4 - ret nc -.asm_3e6dc - ld hl, wccd5 - inc [hl] - xor a - ld [W_MOVEMISSED], a - ld [wccf4], a - ld a, $a - ld [wd05b], a - call CheckEnemyStatusConditions - jr nz, .canUseMove - jp [hl] -.canUseMove - ld hl, W_ENEMYBATTSTATUS1 - bit 4, [hl] ; is the enemy charging up for attack? - jr nz, asm_3e70b ; if so, jump - call GetCurrentMove - -Func_3e6fc: ; 3e6fc (f:66fc) - ld a, [W_ENEMYMOVEEFFECT] - cp CHARGE_EFFECT - jp z, JumpMoveEffect - cp FLY_EFFECT - jp z, JumpMoveEffect - jr asm_3e72b -asm_3e70b: ; 3e70b (f:670b) - ld hl, W_ENEMYBATTSTATUS1 - res 4, [hl] ; no longer charging up for attack - res 6, [hl] ; no longer invulnerable to typical attacks - ld a, [W_ENEMYMOVENUM] - ld [wd0b5], a - ld a, BANK(MoveNames) - ld [wPredefBank], a - ld a, MOVE_NAME - ld [W_LISTTYPE], a - call GetName - ld de, wcd6d - call CopyStringToCF4B -asm_3e72b: ; 3e72b (f:672b) - xor a - ld [wcced], a - call PrintMonName1Text - ld a, [W_ENEMYMOVEEFFECT] - ld hl, EffectsArray1 - ld de, $1 - call IsInArray - jp c, JumpMoveEffect - ld a, [W_ENEMYMOVEEFFECT] - ld hl, EffectsArray5B - ld de, $1 - call IsInArray - call c, JumpMoveEffect -asm_3e750: ; 3e750 (f:6750) - call SwapPlayerAndEnemyLevels - ld a, [W_ENEMYMOVEEFFECT] - ld hl, EffectsArray2 - ld de, $1 - call IsInArray - jp c, Func_3e77f - call CriticalHitTest - call HandleCounterMove - jr z, asm_3e782 - call SwapPlayerAndEnemyLevels - call GetDamageVarsForEnemyAttack - call SwapPlayerAndEnemyLevels - call CalculateDamage - jp z, Func_3e7d1 - call AdjustDamageForMoveType - call RandomizeDamage - -Func_3e77f: ; 3e77f (f:677f) - call MoveHitTest -asm_3e782: ; 3e782 (f:6782) - ld a, [W_MOVEMISSED] - and a - jr z, .asm_3e791 - ld a, [W_ENEMYMOVEEFFECT] - cp EXPLODE_EFFECT - jr z, asm_3e7a0 - jr Func_3e7d1 -.asm_3e791 - call SwapPlayerAndEnemyLevels - -Func_3e794: ; 3e794 (f:6794) - ld a, [W_ENEMYMOVEEFFECT] - and a - ld a, $1 - jr z, asm_3e7a4 - ld a, $2 - jr asm_3e7a4 -asm_3e7a0: ; 3e7a0 (f:67a0) - call SwapPlayerAndEnemyLevels - xor a -asm_3e7a4: ; 3e7a4 (f:67a4) - push af - ld a, [W_ENEMYBATTSTATUS2] - bit 4, a ; does mon have a substitute? - ld hl, Func_79747 - ld b, BANK(Func_79747) - call nz, Bankswitch - pop af - ld [wcc5b], a - ld a, [W_ENEMYMOVENUM] - call PlayMoveAnimation - call Func_3eed3 - call DrawEnemyHUDAndHPBar - ld a, [W_ENEMYBATTSTATUS2] - bit 4, a ; does mon have a substitute? - ld hl, Func_79771 - ld b, BANK(Func_79771) - call nz, Bankswitch ; slide the substitute's sprite out - jr asm_3e7ef - -Func_3e7d1: ; 3e7d1 (f:67d1) - call SwapPlayerAndEnemyLevels - ld c, $1e - call DelayFrames - ld a, [W_ENEMYMOVEEFFECT] - cp FLY_EFFECT - jr z, .asm_3e7e6 - cp CHARGE_EFFECT - jr z, .asm_3e7e6 - jr asm_3e7ef -.asm_3e7e6 - xor a - ld [wcc5b], a - ld a,STATUS_AFFECTED_ANIM - call PlayMoveAnimation -asm_3e7ef: ; 3e7ef (f:67ef) - ld a, [W_ENEMYMOVEEFFECT] - cp MIRROR_MOVE_EFFECT - jr nz, .notMirrorMoveEffect - call MirrorMoveCopyMove - jp z, Func_3e88c - jp Func_3e6fc -.notMirrorMoveEffect - cp METRONOME_EFFECT - jr nz, .notMetronomeEffect - call MetronomePickMove - jp Func_3e6fc -.notMetronomeEffect - ld a, [W_ENEMYMOVEEFFECT] - ld hl, EffectsArray3 - ld de, $1 - call IsInArray - jp c, JumpMoveEffect - ld a, [W_MOVEMISSED] - and a - jr z, .asm_3e82b - call PrintMoveFailureText - ld a, [W_ENEMYMOVEEFFECT] - cp EXPLODE_EFFECT - jr z, .asm_3e83e - jp Func_3e88c -.asm_3e82b - call ApplyAttackToPlayerPokemon - call PrintCriticalOHKOText - callab DisplayEffectiveness - ld a, 1 - ld [wccf4], a -.asm_3e83e - ld a, [W_ENEMYMOVEEFFECT] - ld hl, EffectsArray4 - ld de, $1 - call IsInArray - call c, JumpMoveEffect - ld hl, wBattleMonHP - ld a, [hli] - ld b, [hl] - or b - ret z - call HandleBuildingRage - ld hl, W_ENEMYBATTSTATUS1 - bit 2, [hl] ; is mon hitting multiple times? (example: double kick) - jr z, .asm_3e873 - push hl - ld hl, wEnemyNumAttacksLeft - dec [hl] - pop hl - jp nz, Func_3e794 - res 2, [hl] ; mon is no longer hitting multiple times - ld hl, HitXTimesText - call PrintText - xor a - ld [wcd05], a -.asm_3e873 - ld a, [W_ENEMYMOVEEFFECT] - and a - jr z, Func_3e88c - ld hl, EffectsArray5 - ld de, $1 - call IsInArray - call nc, JumpMoveEffect - jr Func_3e88c - -HitXTimesText: ; 3e887 (f:6887) - TX_FAR _HitXTimesText - db "@" - -Func_3e88c: ; 3e88c (f:688c) - ld b, $1 - ret - -; checks for various status conditions affecting the enemy mon -; stores whether the mon cannot use a move this turn in Z flag -CheckEnemyStatusConditions: ; 3e88f (f:688f) - ld hl, wEnemyMonStatus - ld a, [hl] - and SLP ; sleep mask - jr z, .checkIfFrozen - dec a ; decrement number of turns left - ld [wEnemyMonStatus], a - and a - jr z, .wokeUp ; if the number of turns hit 0, wake up - ld hl, FastAsleepText - call PrintText - xor a - ld [wcc5b], a - ld a,SLP_ANIM - call PlayMoveAnimation - jr .next1 -.wokeUp - ld hl, WokeUpText - call PrintText -.next1 - xor a - ld [wccf2], a - ld hl, Func_3e88c - jp .cannotUseMove -.checkIfFrozen - bit FRZ, [hl] - jr z, .checkIfTrapped - ld hl, IsFrozenText - call PrintText - xor a - ld [wccf2], a - ld hl, Func_3e88c - jp .cannotUseMove -.checkIfTrapped - ld a, [W_PLAYERBATTSTATUS1] - bit 5, a ; is the player using a multi-turn attack like warp - jp z, .checkIfFlinched - ld hl, CantMoveText - call PrintText - ld hl, Func_3e88c - jp .cannotUseMove -.checkIfFlinched - ld hl, W_ENEMYBATTSTATUS1 - bit 3, [hl] ; check if enemy mon flinched - jp z, .checkIfMustRecharge - res 3, [hl] - ld hl, FlinchedText - call PrintText - ld hl, Func_3e88c - jp .cannotUseMove -.checkIfMustRecharge - ld hl, W_ENEMYBATTSTATUS2 - bit 5, [hl] ; check if enemy mon has to recharge after using a move - jr z, .checkIfAnyMoveDisabled - res 5, [hl] - ld hl, MustRechargeText - call PrintText - ld hl, Func_3e88c - jp .cannotUseMove -.checkIfAnyMoveDisabled - ld hl, W_ENEMYDISABLEDMOVE - ld a, [hl] - and a - jr z, .checkIfConfused - dec a - ld [hl], a - and $f - jr nz, .checkIfConfused - ld [hl], a - ld [wccef], a - ld hl, DisabledNoMoreText - call PrintText -.checkIfConfused - ld a, [W_ENEMYBATTSTATUS1] - add a ; check if enemy mon is confused - jp nc, .checkIfTriedToUseDisabledMove - ld hl, wd070 - dec [hl] - jr nz, .isConfused - ld hl, W_ENEMYBATTSTATUS1 - res 7, [hl] - ld hl, ConfusedNoMoreText - call PrintText - jp .checkIfTriedToUseDisabledMove -.isConfused - ld hl, IsConfusedText - call PrintText - xor a - ld [wcc5b], a - ld a,CONF_ANIM - call PlayMoveAnimation - call BattleRandom - cp $80 - jr c, .checkIfTriedToUseDisabledMove - ld hl, W_ENEMYBATTSTATUS1 - ld a, [hl] - and $80 - ld [hl], a - ld hl, HurtItselfText - call PrintText - ld hl, wBattleMonDefense - ld a, [hli] - push af - ld a, [hld] - push af - ld a, [wEnemyMonDefense] - ld [hli], a - ld a, [wEnemyMonDefense + 1] - ld [hl], a - ld hl, W_ENEMYMOVEEFFECT - push hl - ld a, [hl] - push af - xor a - ld [hli], a - ld [wCriticalHitOrOHKO], a - ld a, $28 - ld [hli], a - xor a - ld [hl], a - call GetDamageVarsForEnemyAttack - call CalculateDamage - pop af - pop hl - ld [hl], a - ld hl, wBattleMonDefense + 1 - pop af - ld [hld], a - pop af - ld [hl], a - xor a - ld [wcc5b], a - ld [H_WHOSETURN], a - ld a, POUND - call PlayMoveAnimation - ld a, $1 - ld [H_WHOSETURN], a - call ApplyDamageToEnemyPokemon - jr .monHurtItselfOrFullyParalysed -.checkIfTriedToUseDisabledMove - ld a, [wccef] - and a - jr z, .checkIfParalysed - ld hl, wEnemySelectedMove - cp [hl] - jr nz, .checkIfParalysed - call PrintMoveIsDisabledText - ld hl, Func_3e88c - jp .cannotUseMove -.checkIfParalysed - ld hl, wEnemyMonStatus - bit PAR, [hl] - jr z, .checkIfUsingBide - call BattleRandom - cp $3f - jr nc, .checkIfUsingBide - ld hl, FullyParalyzedText - call PrintText -.monHurtItselfOrFullyParalysed - ld hl, W_ENEMYBATTSTATUS1 - ld a, [hl] - and $cc ; clear bide, thrashing, charging up, and multi-turn moves such as warp - ld [hl], a - ld a, [W_ENEMYMOVEEFFECT] - cp FLY_EFFECT - jr z, .flyOrChargeEffect - cp CHARGE_EFFECT - jr z, .flyOrChargeEffect - jr .notFlyOrChargeEffect -.flyOrChargeEffect - xor a - ld [wcc5b], a - ld a, STATUS_AFFECTED_ANIM - call PlayMoveAnimation -.notFlyOrChargeEffect - ld hl, Func_3e88c - jp .cannotUseMove -.checkIfUsingBide - ld hl, W_ENEMYBATTSTATUS1 - bit 0, [hl] ; is mon using bide? - jr z, .checkIfThrashingAbout - xor a - ld [W_ENEMYMOVENUM], a - ld hl, W_DAMAGE - ld a, [hli] - ld b, a - ld c, [hl] - ld hl, wcd06 - ld a, [hl] - add c - ld [hld], a - ld a, [hl] - adc b - ld [hl], a - ld hl, wEnemyNumAttacksLeft - dec [hl] - jr z, .unleashEnergy - ld hl, Func_3e88c - jp .cannotUseMove -.unleashEnergy - ld hl, W_ENEMYBATTSTATUS1 - res 0, [hl] ; not using bide any more - ld hl, UnleashedEnergyText - call PrintText - ld a, $1 - ld [W_ENEMYMOVEPOWER], a - ld hl, wcd06 - ld a, [hld] - add a - ld b, a - ld [wd0d8], a - ld a, [hl] - rl a - ld [W_DAMAGE], a - or b - jr nz, .next2 - ld a, $1 - ld [W_MOVEMISSED], a -.next2 - xor a - ld [hli], a - ld [hl], a - ld a, BIDE - ld [W_ENEMYMOVENUM], a - call SwapPlayerAndEnemyLevels - ld hl, asm_3e782 - jp .cannotUseMove -.checkIfThrashingAbout - bit 1, [hl] ; is mon using thrash or petal dance? - jr z, .checkIfUsingMultiturnMove - ld a, THRASH - ld [W_ENEMYMOVENUM], a - ld hl, ThrashingAboutText - call PrintText - ld hl, wEnemyNumAttacksLeft - dec [hl] - ld hl, asm_3e750 - jp nz, .cannotUseMove - push hl - ld hl, W_ENEMYBATTSTATUS1 - res 1, [hl] ; mon is no longer using thrash or petal dance - set 7, [hl] ; mon is now confused - call BattleRandom - and $3 - inc a - inc a - ld [wd070], a - pop hl - jp .cannotUseMove -.checkIfUsingMultiturnMove - bit 5, [hl] ; is mon using multi-turn move? - jp z, .checkIfUsingRage - ld hl, AttackContinuesText - call PrintText - ld hl, wEnemyNumAttacksLeft - dec [hl] - ld hl, Func_3e794 - jp nz, .cannotUseMove - jp .cannotUseMove -.checkIfUsingRage - ld a, [W_ENEMYBATTSTATUS2] - bit 6, a ; is mon using rage? - jp z, .canUseMove - ld a, RAGE - ld [wd11e], a - call GetMoveName - call CopyStringToCF4B - xor a - ld [W_ENEMYMOVEEFFECT], a - ld hl, asm_3e72b - jp .cannotUseMove -.cannotUseMove - xor a ; set Z flag - ret -.canUseMove - ld a, $1 - and a ; clear Z flag - ret - -GetCurrentMove: ; 3eabe (f:6abe) - ld a, [H_WHOSETURN] - and a - jp z, .player - ld de, W_ENEMYMOVENUM - ld a, [wEnemySelectedMove] - jr .selected -.player - ld de, W_PLAYERMOVENUM - ld a, [W_FLAGS_D733] - bit 0, a - ld a, [wccd9] - jr nz, .selected - ld a, [wPlayerSelectedMove] -.selected - ld [wd0b5], a - dec a - ld hl, Moves - ld bc, $6 - call AddNTimes - ld a, BANK(Moves) - call FarCopyData - - ld a, BANK(MoveNames) - ld [wPredefBank], a - ld a, MOVE_NAME - ld [W_LISTTYPE], a - call GetName - ld de, wcd6d - jp CopyStringToCF4B - -LoadEnemyMonData: ; 3eb01 (f:6b01) - ld a, [W_ISLINKBATTLE] - cp $4 - jp z, LoadEnemyMonFromParty - ld a, [wEnemyMonSpecies2] - ld [wEnemyMonSpecies], a - ld [wd0b5], a - call GetMonHeader - ld a, [W_ENEMYBATTSTATUS3] - bit 3, a ; is enemy mon transformed? - ld hl, wcceb ; copied DVs from when it used Transform - ld a, [hli] - ld b, [hl] - jr nz, .storeDVs - ld a, [W_ISINBATTLE] - cp $2 ; is it a trainer battle? -; fixed DVs for trainer mon - ld a, $98 - ld b, $88 - jr z, .storeDVs -; random DVs for wild mon - call BattleRandom - ld b, a - call BattleRandom -.storeDVs - ld hl, wEnemyMonDVs - ld [hli], a - ld [hl], b - ld de, wEnemyMonLevel - ld a, [W_CURENEMYLVL] - ld [de], a - inc de - ld b, $0 - ld hl, wEnemyMonHP - push hl - call CalcStats - pop hl - ld a, [W_ISINBATTLE] - cp $2 ; is it a trainer battle? - jr z, .copyHPAndStatusFromPartyData - ld a, [W_ENEMYBATTSTATUS3] - bit 3, a ; is enemy mon transformed? - jr nz, .copyTypes ; if transformed, jump -; if it's a wild mon and not transformed, init the current HP to max HP and the status to 0 - ld a, [wEnemyMonMaxHP] - ld [hli], a - ld a, [wEnemyMonMaxHP+1] - ld [hli], a - xor a - inc hl - ld [hl], a ; init status to 0 - jr .copyTypes -; if it's a trainer mon, copy the HP and status from the enemy party data -.copyHPAndStatusFromPartyData - ld hl, wEnemyMon1HP - ld a, [wWhichPokemon] - ld bc, wEnemyMon2 - wEnemyMon1 - call AddNTimes - ld a, [hli] - ld [wEnemyMonHP], a - ld a, [hli] - ld [wEnemyMonHP + 1], a - ld a, [wWhichPokemon] - ld [wEnemyMonPartyPos], a - inc hl - ld a, [hl] - ld [wEnemyMonStatus], a - jr .copyTypes -.copyTypes - ld hl, W_MONHTYPES - ld de, wEnemyMonType - ld a, [hli] ; copy type 1 - ld [de], a - inc de - ld a, [hli] ; copy type 2 - ld [de], a - inc de - ld a, [hli] ; copy catch rate - ld [de], a - inc de - ld a, [W_ISINBATTLE] - cp $2 ; is it a trainer battle? - jr nz, .copyStandardMoves -; if it's a trainer battle, copy moves from enemy party data - ld hl, wEnemyMon1Moves - ld a, [wWhichPokemon] - ld bc, wEnemyMon2 - wEnemyMon1 - call AddNTimes - ld bc, NUM_MOVES - call CopyData - jr .loadMovePPs -.copyStandardMoves -; for a wild mon, first copy default moves from the mon header - ld hl, W_MONHMOVES - ld a, [hli] - ld [de], a - inc de - ld a, [hli] - ld [de], a - inc de - ld a, [hli] - ld [de], a - inc de - ld a, [hl] - ld [de], a - dec de - dec de - dec de - xor a - ld [wHPBarMaxHP], a - predef WriteMonMoves ; get moves based on current level -.loadMovePPs - ld hl, wEnemyMonMoves - ld de, wEnemyMonSpecial + 1 - predef LoadMovePPs - ld hl, W_MONHBASESTATS - ld de, wEnemyMonBaseStats - ld b, $5 -.copyBaseStatsLoop - ld a, [hli] - ld [de], a - inc de - dec b - jr nz, .copyBaseStatsLoop - ld hl, W_MONHCATCHRATE - ld a, [hli] - ld [de], a - inc de - ld a, [hl] ; base exp - ld [de], a - ld a, [wEnemyMonSpecies2] - ld [wd11e], a - call GetMonName - ld hl, wcd6d - ld de, wEnemyMonNick - ld bc, $b - call CopyData - ld a, [wEnemyMonSpecies2] - ld [wd11e], a - predef IndexToPokedex - ld a, [wd11e] - dec a - ld c, a - ld b, $1 - ld hl, wPokedexSeen - predef FlagActionPredef ; mark this mon as seen in the pokedex - ld hl, wEnemyMonLevel - ld de, wEnemyMonUnmodifiedLevel - ld bc, $b - call CopyData - ld a, $7 ; default stat mod - ld b, $8 ; number of stat mods - ld hl, wEnemyMonStatMods -.statModLoop - ld [hli], a - dec b - jr nz, .statModLoop - ret - -; calls BattleTransition to show the battle transition animation and initializes some battle variables -DoBattleTransitionAndInitBattleVariables: ; 3ec32 (f:6c32) - ld a, [W_ISLINKBATTLE] - cp $4 - jr nz, .next -; link battle - xor a - ld [wMenuJoypadPollCount], a - callab DisplayLinkBattleVersusTextBox - ld a, $1 - ld [wUpdateSpritesEnabled], a - call ClearScreen -.next - call DelayFrame - predef BattleTransition - callab LoadHudAndHpBarAndStatusTilePatterns - ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a - ld a, $ff - ld [wUpdateSpritesEnabled], a - call ClearSprites - call ClearScreen - xor a - ld [H_AUTOBGTRANSFERENABLED], a - ld [hVBlankWY], a - ld [rWY], a - ld [hTilesetType], a - ld hl, wd060 - ld [hli], a - ld [hli], a - ld [hli], a - ld [hli], a - ld [hl], a - ld [W_PLAYERDISABLEDMOVE], a - ret - -; swaps the level values of the BattleMon and EnemyMon structs -SwapPlayerAndEnemyLevels: ; 3ec81 (f:6c81) - push bc - ld a, [wBattleMonLevel] - ld b, a - ld a, [wEnemyMonLevel] - ld [wBattleMonLevel], a - ld a, b - ld [wEnemyMonLevel], a - pop bc - ret - -; loads either red back pic or old man back pic -; also writes OAM data and loads tile patterns for the Red or Old Man back sprite's head -; (for use when scrolling the player sprite and enemy's silhouettes on screen) -LoadPlayerBackPic: ; 3ec92 (f:6c92) - ld a, [W_BATTLETYPE] - dec a ; is it the old man tutorial? - ld de, RedPicBack - jr nz, .next - ld de, OldManPic -.next - ld a, BANK(RedPicBack) - call UncompressSpriteFromDE - predef ScaleSpriteByTwo - ld hl, wOAMBuffer - xor a - ld [$FF8B], a ; initial tile number - ld b, $7 ; 7 columns - ld e, $a0 ; X for the left-most column -.loop ; each loop iteration writes 3 OAM entries in a vertical column - ld c, $3 ; 3 tiles per column - ld d, $38 ; Y for the top of each column -.innerLoop ; each loop iteration writes 1 OAM entry in the column - ld [hl], d ; OAM Y - inc hl - ld [hl], e ; OAM X - ld a, $8 ; height of tile - add d ; increase Y by height of tile - ld d, a - inc hl - ld a, [$FF8B] - ld [hli], a ; OAM tile number - inc a ; increment tile number - ld [$FF8B], a - inc hl - dec c - jr nz, .innerLoop - ld a, [$FF8B] - add $4 ; increase tile number by 4 - ld [$FF8B], a - ld a, $8 ; width of tile - add e ; increase X by width of tile - ld e, a - dec b - jr nz, .loop - ld de, vBackPic - call InterlaceMergeSpriteBuffers - ld a, $a - ld [$0], a - xor a - ld [$4000], a - ld hl, vSprites - ld de, S_SPRITEBUFFER1 - ld a, [H_LOADEDROMBANK] - ld b, a - ld c, 7 * 7 - call CopyVideoData - xor a - ld [$0], a - ld a, $31 - ld [$ffe1], a - hlCoord 1, 5 - predef_jump Func_3f0c6 - -Func_3ed02: ; 3ed02 (f:6d02) - callab Func_39680 - ld hl, Func_396a7 - ld b, BANK(Func_396a7) - jp Bankswitch - -ScrollTrainerPicAfterBattle: ; 3ed12 (f:6d12) - ld hl, _ScrollTrainerPicAfterBattle - ld b, BANK(_ScrollTrainerPicAfterBattle) - jp Bankswitch - -ApplyBurnAndParalysisPenaltiesToPlayer: ; 3ed1a (f:6d1a) - ld a, $1 - jr ApplyBurnAndParalysisPenalties - -ApplyBurnAndParalysisPenaltiesToEnemy: ; 3ed1e (f:6d1e) - xor a - -ApplyBurnAndParalysisPenalties: ; 3ed1f (f:6d1f) - ld [H_WHOSETURN], a - call QuarterSpeedDueToParalysis - jp HalveAttackDueToBurn - -QuarterSpeedDueToParalysis: ; 3ed27 (f:6d27) - ld a, [H_WHOSETURN] - and a - jr z, .playerTurn -.enemyTurn ; quarter the player's speed - ld a, [wBattleMonStatus] - and 1 << PAR - ret z ; return if player not paralysed - ld hl, wBattleMonSpeed + 1 - ld a, [hld] - ld b, a - ld a, [hl] - srl a - rr b - srl a - rr b - ld [hli], a - or b - jr nz, .storePlayerSpeed - ld b, 1 ; give the player a minimum of at least one speed point -.storePlayerSpeed - ld [hl], b - ret -.playerTurn ; quarter the enemy's speed - ld a, [wEnemyMonStatus] - and 1 << PAR - ret z ; return if enemy not paralysed - ld hl, wEnemyMonSpeed + 1 - ld a, [hld] - ld b, a - ld a, [hl] - srl a - rr b - srl a - rr b - ld [hli], a - or b - jr nz, .storeEnemySpeed - ld b, 1 ; give the enemy a minimum of at least one speed point -.storeEnemySpeed - ld [hl], b - ret - -HalveAttackDueToBurn: ; 3ed64 (f:6d64) - ld a, [H_WHOSETURN] - and a - jr z, .playerTurn -.enemyTurn ; halve the player's attack - ld a, [wBattleMonStatus] - and 1 << BRN - ret z ; return if player not burnt - ld hl, wBattleMonAttack + 1 - ld a, [hld] - ld b, a - ld a, [hl] - srl a - rr b - ld [hli], a - or b - jr nz, .storePlayerAttack - ld b, 1 ; give the player a minimum of at least one attack point -.storePlayerAttack - ld [hl], b - ret -.playerTurn ; halve the enemy's attack - ld a, [wEnemyMonStatus] - and 1 << BRN - ret z ; return if enemy not burnt - ld hl, wEnemyMonAttack + 1 - ld a, [hld] - ld b, a - ld a, [hl] - srl a - rr b - ld [hli], a - or b - jr nz, .storeEnemyAttack - ld b, 1 ; give the enemy a minimum of at least one attack point -.storeEnemyAttack - ld [hl], b - ret - -CalculateModifiedStats: ; 3ed99 (f:6d99) - ld c, 0 -.loop - call CalculateModifiedStat - inc c - ld a, c - cp 4 - jr nz, .loop - ret - -; calculate modified stat for stat c (0 = attack, 1 = defense, 2 = speed, 3 = special) -CalculateModifiedStat: ; 3eda5 (f:6da5) - push bc - push bc - ld a, [wd11e] - and a - ld a, c - ld hl, wBattleMonAttack - ld de, wPlayerMonUnmodifiedAttack - ld bc, wPlayerMonAttackMod - jr z, .next - ld hl, wEnemyMonAttack - ld de, wEnemyMonUnmodifiedAttack - ld bc, wEnemyMonStatMods -.next - add c - ld c, a - jr nc, .noCarry1 - inc b -.noCarry1 - ld a, [bc] - pop bc - ld b, a - push bc - sla c - ld b, 0 - add hl, bc - ld a, c - add e - ld e, a - jr nc, .noCarry2 - inc d -.noCarry2 - pop bc - push hl - ld hl, StatModifierRatios - dec b - sla b - ld c, b - ld b, 0 - add hl, bc - xor a - ld [H_MULTIPLICAND], a - ld a, [de] - ld [H_MULTIPLICAND + 1], a - inc de - ld a, [de] - ld [H_MULTIPLICAND + 2], a - ld a, [hli] - ld [H_MULTIPLIER], a - call Multiply - ld a, [hl] - ld [H_DIVISOR], a - ld b, $4 - call Divide - pop hl - ld a, [H_DIVIDEND + 3] - sub 999 % $100 - ld a, [H_DIVIDEND + 2] - sbc 999 / $100 - jp c, .storeNewStatValue -; cap the stat at 999 - ld a, 999 / $100 - ld [H_DIVIDEND + 2], a - ld a, 999 % $100 - ld [H_DIVIDEND + 3], a -.storeNewStatValue - ld a, [H_DIVIDEND + 2] - ld [hli], a - ld b, a - ld a, [H_DIVIDEND + 3] - ld [hl], a - or b - jr nz, .done - inc [hl] ; if the stat is 0, bump it up to 1 -.done - pop bc - ret - -ApplyBadgeStatBoosts: ; 3ee19 (f:6e19) - ld a, [W_ISLINKBATTLE] - cp $4 - ret z ; return if link battle - ld a, [W_OBTAINEDBADGES] - ld b, a - ld hl, wBattleMonAttack - ld c, $4 -; the boost is applied for badges whose bit position is even -; the order of boosts matches the order they are laid out in RAM -; Boulder (bit 0) - attack -; Thunder (bit 2) - defense -; Soul (bit 4) - speed -; Volcano (bit 6) - special -.loop - srl b - call c, .applyBoostToStat - inc hl - inc hl - srl b - dec c - jr nz, .loop - ret - -; multiply stat at hl by 1.125 -; cap stat at 999 -.applyBoostToStat - ld a, [hli] - ld d, a - ld e, [hl] - srl d - rr e - srl d - rr e - srl d - rr e - ld a, [hl] - add e - ld [hld], a - ld a, [hl] - adc d - ld [hli], a - ld a, [hld] - sub 999 % $100 - ld a, [hl] - sbc 999 / $100 - ret c - ld a, 999 / $100 - ld [hli], a - ld a, 999 % $100 - ld [hld], a - ret - -LoadHudAndHpBarAndStatusTilePatterns: ; 3ee58 (f:6e58) - call LoadHpBarAndStatusTilePatterns - -LoadHudTilePatterns: ; 3ee5b (f:6e5b) - ld a, [rLCDC] - add a ; is LCD disabled? - jr c, .lcdEnabled -.lcdDisabled - ld hl, BattleHudTiles1 - ld de, vChars2 + $6d0 - ld bc, $18 - ld a, BANK(BattleHudTiles1) - call FarCopyDataDouble - ld hl, BattleHudTiles2 - ld de, vChars2 + $730 - ld bc, $30 - ld a, BANK(BattleHudTiles2) - jp FarCopyDataDouble -.lcdEnabled - ld de, BattleHudTiles1 - ld hl, vChars2 + $6d0 - ld bc, (BANK(BattleHudTiles1) << 8) + $03 - call CopyVideoDataDouble - ld de, BattleHudTiles2 - ld hl, vChars2 + $730 - ld bc, (BANK(BattleHudTiles2) << 8) + $06 - jp CopyVideoDataDouble - -PrintEmptyString: ; 3ee94 (f:6e94) - ld hl, .emptyString - jp PrintText -.emptyString - db "@" - - -BattleRandom: -; Link battles use a shared PRNG. - - ld a, [W_ISLINKBATTLE] - cp $4 - jp nz, Random - - push hl - push bc - ld a, [wccde] - ld c, a - ld b, 0 - ld hl, wd148 - add hl, bc - inc a - ld [wccde], a - cp 9 - ld a, [hl] - pop bc - pop hl - ret c - - push hl - push bc - push af - - xor a - ld [wccde], a - - ld hl, wd148 - ld b, 9 -.loop - ld a, [hl] - ld c, a - add a - add a - add c - inc a - ld [hli], a - dec b - jr nz, .loop - - pop af - pop bc - pop hl - ret - - -Func_3eed3: ; 3eed3 (f:6ed3) - ld a, [H_WHOSETURN] - and a - ld hl, wEnemyMonType1 ; wcfea (aliases: wEnemyMonType) - ld de, W_ENEMYBATTSTATUS1 - ld a, [W_PLAYERMOVENUM] - jr z, .asm_3eeea - ld hl, wBattleMonType1 ; wd019 (aliases: wBattleMonType) - ld de, W_ENEMYBATTSTATUS1 - ld a, [W_ENEMYMOVENUM] -.asm_3eeea - cp SELFDESTRUCT - jr z, .asm_3eef1 - cp EXPLOSION - ret nz -.asm_3eef1 - ld a, [de] - bit 6, a ; fly/dig - ret nz - ld a, [hli] - cp GHOST - ret z - ld a, [hl] - cp GHOST - ret z - ld a, [W_MOVEMISSED] - and a - ret nz - ld a, MEGA_PUNCH - ld [wcc5b], a - -PlayMoveAnimation: ; 3ef07 (f:6f07) - ld [W_ANIMATIONID],a - call Delay3 - predef_jump MoveAnimation - -InitBattle: ; 3ef12 (f:6f12) - ld a, [W_CUROPPONENT] - and a - jr z, asm_3ef23 - -InitOpponent: ; 3ef18 (f:6f18) - ld a, [W_CUROPPONENT] - ld [wcf91], a - ld [wEnemyMonSpecies2], a - jr asm_3ef3d -asm_3ef23: ; 3ef23 (f:6f23) - ld a, [wd732] - bit 1, a - jr z, .asm_3ef2f - ld a, [hJoyHeld] - bit 1, a ; B button pressed? - ret nz -.asm_3ef2f - ld a, [wNumberOfNoRandomBattleStepsLeft] - and a - ret nz - callab Func_13870 - ret nz -asm_3ef3d: ; 3ef3d (f:6f3d) - ld a, [wMapPalOffset] - push af - ld hl, wd358 - ld a, [hl] - push af - res 1, [hl] - callab Func_525af - ld a, [wEnemyMonSpecies2] - sub $c8 - jp c, InitWildBattle - ld [W_TRAINERCLASS], a - call GetTrainerInformation - callab ReadTrainer - call DoBattleTransitionAndInitBattleVariables - call _LoadTrainerPic - xor a - ld [wEnemyMonSpecies2], a - ld [$ffe1], a - dec a - ld [wAICount], a - hlCoord 12, 0 - predef Func_3f0c6 - ld a, $ff - ld [wEnemyMonPartyPos], a - ld a, $2 - ld [W_ISINBATTLE], a - jp InitBattle_Common - -InitWildBattle: ; 3ef8b (f:6f8b) - ld a, $1 - ld [W_ISINBATTLE], a - call LoadEnemyMonData - call DoBattleTransitionAndInitBattleVariables - ld a, [W_CUROPPONENT] - cp MAROWAK - jr z, .isGhost - call IsGhostBattle - jr nz, .isNoGhost -.isGhost - ld hl, W_MONHSPRITEDIM - ld a, $66 - ld [hli], a ; write sprite dimensions - ld bc, GhostPic - ld a, c - ld [hli], a ; write front sprite pointer - ld [hl], b - ld hl, wEnemyMonNick ; set name to "GHOST" - ld a, "G" - ld [hli], a - ld a, "H" - ld [hli], a - ld a, "O" - ld [hli], a - ld a, "S" - ld [hli], a - ld a, "T" - ld [hli], a - ld [hl], "@" - ld a, [wcf91] - push af - ld a, MON_GHOST - ld [wcf91], a - ld de, vFrontPic - call LoadMonFrontSprite ; load ghost sprite - pop af - ld [wcf91], a - jr .spriteLoaded -.isNoGhost - ld de, vFrontPic - call LoadMonFrontSprite ; load mon sprite -.spriteLoaded - xor a - ld [W_TRAINERCLASS], a - ld [$ffe1], a - hlCoord 12, 0 - predef Func_3f0c6 - -; common code that executes after init battle code specific to trainer or wild battles -InitBattle_Common: ; 3efeb (f:6feb) - ld b, $0 - call GoPAL_SET - call SlidePlayerAndEnemySilhouettesOnScreen - xor a - ld [H_AUTOBGTRANSFERENABLED], a - ld hl, .emptyString - call PrintText - call SaveScreenTilesToBuffer1 - call ClearScreen - ld a, $98 - ld [$ffbd], a - ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a - call Delay3 - ld a, $9c - ld [$ffbd], a - call LoadScreenTilesFromBuffer1 - hlCoord 9, 7 - ld bc, $50a - call ClearScreenArea - hlCoord 1, 0 - ld bc, $40a - call ClearScreenArea - call ClearSprites - ld a, [W_ISINBATTLE] - dec a ; is it a wild battle? - call z, DrawEnemyHUDAndHPBar ; draw enemy HUD and HP bar if it's a wild battle - call StartBattle - callab EndOfBattle - pop af - ld [wd358], a - pop af - ld [wMapPalOffset], a - ld a, [wd0d4] - ld [hTilesetType], a - scf - ret -.emptyString - db "@" - -_LoadTrainerPic: ; 3f04b (f:704b) -; wd033-wd034 contain pointer to pic - ld a, [wd033] - ld e, a - ld a, [wd034] - ld d, a ; de contains pointer to trainer pic - ld a, [W_ISLINKBATTLE] - and a - ld a, Bank(TrainerPics) ; this is where all the trainer pics are (not counting Red's) - jr z, .loadSprite - ld a, Bank(RedPicFront) -.loadSprite - call UncompressSpriteFromDE - ld de, vFrontPic - ld a, $77 - ld c, a - jp LoadUncompressedSpriteData - -Func_3f069: ; 3f069 (f:7069) - xor a - ld [wc0f1], a - ld [wc0f2], a - jp PlaySound - -Func_3f073: ; 3f073 (f:7073) - ld a, [wPredefRegisters] - ld h, a - ld a, [wPredefRegisters + 1] - ld l, a - ld a, [$ffe1] - ld [H_DOWNARROWBLINKCNT1], a - ld b, $4c - ld a, [W_ISINBATTLE] - and a - jr z, .asm_3f0bc - add b - ld [hl], a - call Delay3 - ld bc, -41 - add hl, bc - ld a, $1 - ld [wcd6c], a - ld bc, $303 - predef Func_79aba - ld c, $4 - call DelayFrames - ld bc, -41 - add hl, bc - xor a - ld [wcd6c], a - ld bc, $505 - predef Func_79aba - ld c, $5 - call DelayFrames - ld bc, -41 - jr .asm_3f0bf -.asm_3f0bc - ld bc, -123 -.asm_3f0bf - add hl, bc - ld a, [H_DOWNARROWBLINKCNT1] - add $31 - jr asm_3f0d0 - -Func_3f0c6: ; 3f0c6 (f:70c6) - ld a, [wPredefRegisters] - ld h, a - ld a, [wPredefRegisters + 1] - ld l, a - ld a, [$ffe1] -asm_3f0d0: ; 3f0d0 (f:70d0) - ld bc, $707 - ld de, $14 - push af - ld a, [W_SPRITEFLIPPED] - and a - jr nz, .asm_3f0ed - pop af -.asm_3f0de - push bc - push hl -.asm_3f0e0 - ld [hl], a - add hl, de - inc a - dec c - jr nz, .asm_3f0e0 - pop hl - inc hl - pop bc - dec b - jr nz, .asm_3f0de - ret -.asm_3f0ed - push bc - ld b, $0 - dec c - add hl, bc - pop bc - pop af -.asm_3f0f4 - push bc - push hl -.asm_3f0f6 - ld [hl], a - add hl, de - inc a - dec c - jr nz, .asm_3f0f6 - pop hl - dec hl - pop bc - dec b - jr nz, .asm_3f0f4 - ret - -LoadMonBackPic: -; Assumes the monster's attributes have -; been loaded with GetMonHeader. - ld a, [wBattleMonSpecies2] - ld [wcf91], a - hlCoord 1, 5 - ld b, $7 - ld c, $8 - call ClearScreenArea - ld hl, W_MONHBACKSPRITE - W_MONHEADER - call UncompressMonSprite - predef ScaleSpriteByTwo - ld de, vBackPic - call InterlaceMergeSpriteBuffers ; combine the two buffers to a single 2bpp sprite - ld hl, vSprites - ld de, vBackPic - ld c, (2*SPRITEBUFFERSIZE)/16 ; count of 16-byte chunks to be copied - ld a, [H_LOADEDROMBANK] - ld b, a - jp CopyVideoData - -JumpMoveEffect: ; 3f132 (f:7132) - call _JumpMoveEffect - ld b, $1 - ret - -_JumpMoveEffect: ; 3f138 (f:7138) - ld a, [$fff3] ;whose turn? - and a - ld a, [W_PLAYERMOVEEFFECT] - jr z, .next1 - ld a, [W_ENEMYMOVEEFFECT] -.next1 - dec a ;subtract 1, there is no special effect for 00 - add a ;x2, 16bit pointers - ld hl, MoveEffectPointerTable - ld b, 0 - ld c, a - add hl, bc - ld a, [hli] - ld h, [hl] - ld l, a - jp [hl] ;jump to special effect handler - -MoveEffectPointerTable: ; 3f150 (f:7150) - dw SleepEffect ; unused effect - dw PoisonEffect ; POISON_SIDE_EFFECT1 - dw DrainHPEffect ; DRAIN_HP_EFFECT - dw FreezeBurnParalyzeEffect ; BURN_SIDE_EFFECT1 - dw FreezeBurnParalyzeEffect ; FREEZE_SIDE_EFFECT - dw FreezeBurnParalyzeEffect ; PARALYZE_SIDE_EFFECT1 - dw ExplodeEffect ; EXPLODE_EFFECT - dw DrainHPEffect ; DREAM_EATER_EFFECT - dw $0000 ; MIRROR_MOVE_EFFECT - dw StatModifierUpEffect ; ATTACK_UP1_EFFECT - dw StatModifierUpEffect ; DEFENSE_UP1_EFFECT - dw StatModifierUpEffect ; SPEED_UP1_EFFECT - dw StatModifierUpEffect ; SPECIAL_UP1_EFFECT - dw StatModifierUpEffect ; ACCURACY_UP1_EFFECT - dw StatModifierUpEffect ; EVASION_UP1_EFFECT - dw PayDayEffect ; PAY_DAY_EFFECT - dw $0000 ; SWIFT_EFFECT - dw StatModifierDownEffect ; ATTACK_DOWN1_EFFECT - dw StatModifierDownEffect ; DEFENSE_DOWN1_EFFECT - dw StatModifierDownEffect ; SPEED_DOWN1_EFFECT - dw StatModifierDownEffect ; SPECIAL_DOWN1_EFFECT - dw StatModifierDownEffect ; ACCURACY_DOWN1_EFFECT - dw StatModifierDownEffect ; EVASION_DOWN1_EFFECT - dw ConversionEffect ; CONVERSION_EFFECT - dw HazeEffect ; HAZE_EFFECT - dw BideEffect ; BIDE_EFFECT - dw ThrashPetalDanceEffect ; THRASH_PETAL_DANCE_EFFECT - dw SwitchAndTeleportEffect ; SWITCH_AND_TELEPORT_EFFECT - dw TwoToFiveAttacksEffect ; TWO_TO_FIVE_ATTACKS_EFFECT - dw TwoToFiveAttacksEffect ; unused effect - dw FlichSideEffect ; FLINCH_SIDE_EFFECT1 - dw SleepEffect ; SLEEP_EFFECT - dw PoisonEffect ; POISON_SIDE_EFFECT2 - dw FreezeBurnParalyzeEffect ; BURN_SIDE_EFFECT2 - dw FreezeBurnParalyzeEffect ; unused effect - dw FreezeBurnParalyzeEffect ; PARALYZE_SIDE_EFFECT2 - dw FlichSideEffect ; FLINCH_SIDE_EFFECT2 - dw OneHitKOEffect ; OHKO_EFFECT - dw ChargeEffect ; CHARGE_EFFECT - dw $0000 ; SUPER_FANG_EFFECT - dw $0000 ; SPECIAL_DAMAGE_EFFECT - dw TrappingEffect ; TRAPPING_EFFECT - dw ChargeEffect ; FLY_EFFECT - dw TwoToFiveAttacksEffect ; ATTACK_TWICE_EFFECT - dw $0000 ; JUMP_KICK_EFFECT - dw MistEffect ; MIST_EFFECT - dw FocusEnergyEffect ; FOCUS_ENERGY_EFFECT - dw RecoilEffect ; RECOIL_EFFECT - dw ConfusionEffect ; CONFUSION_EFFECT - dw StatModifierUpEffect ; ATTACK_UP2_EFFECT - dw StatModifierUpEffect ; DEFENSE_UP2_EFFECT - dw StatModifierUpEffect ; SPEED_UP2_EFFECT - dw StatModifierUpEffect ; SPECIAL_UP2_EFFECT - dw StatModifierUpEffect ; ACCURACY_UP2_EFFECT - dw StatModifierUpEffect ; EVASION_UP2_EFFECT - dw HealEffect ; HEAL_EFFECT - dw TransformEffect ; TRANSFORM_EFFECT - dw StatModifierDownEffect ; ATTACK_DOWN2_EFFECT - dw StatModifierDownEffect ; DEFENSE_DOWN2_EFFECT - dw StatModifierDownEffect ; SPEED_DOWN2_EFFECT - dw StatModifierDownEffect ; SPECIAL_DOWN2_EFFECT - dw StatModifierDownEffect ; ACCURACY_DOWN2_EFFECT - dw StatModifierDownEffect ; EVASION_DOWN2_EFFECT - dw ReflectLightScreenEffect ; LIGHT_SCREEN_EFFECT - dw ReflectLightScreenEffect ; REFLECT_EFFECT - dw PoisonEffect ; POISON_EFFECT - dw ParalyzeEffect ; PARALYZE_EFFECT - dw StatModifierDownEffect ; ATTACK_DOWN_SIDE_EFFECT - dw StatModifierDownEffect ; DEFENSE_DOWN_SIDE_EFFECT - dw StatModifierDownEffect ; SPEED_DOWN_SIDE_EFFECT - dw StatModifierDownEffect ; SPECIAL_DOWN_SIDE_EFFECT - dw StatModifierDownEffect ; unused effect - dw StatModifierDownEffect ; unused effect - dw StatModifierDownEffect ; unused effect - dw StatModifierDownEffect ; unused effect - dw ConfusionSideEffect ; CONFUSION_SIDE_EFFECT - dw TwoToFiveAttacksEffect ; TWINEEDLE_EFFECT - dw $0000 ; unused effect - dw SubstituteEffect ; SUBSTITUTE_EFFECT - dw HyperBeamEffect ; HYPER_BEAM_EFFECT - dw RageEffect ; RAGE_EFFECT - dw MimicEffect ; MIMIC_EFFECT - dw $0000 ; METRONOME_EFFECT - dw LeechSeedEffect ; LEECH_SEED_EFFECT - dw SplashEffect ; SPLASH_EFFECT - dw DisableEffect ; DISABLE_EFFECT - -SleepEffect: ; 3f1fc (f:71fc) - ld de, wEnemyMonStatus - ld bc, W_ENEMYBATTSTATUS2 - ld a, [H_WHOSETURN] - and a - jp z, .asm_3f20e - ld de, wBattleMonStatus - ld bc, W_PLAYERBATTSTATUS2 - -.asm_3f20e - ld a, [bc] - bit 5, a ; does the mon need to recharge? (hyper beam) - res 5, a ; mon no longer needs to recharge - ld [bc], a - jr nz, .asm_3f231 - ld a, [de] - ld b, a - and $7 - jr z, .asm_3f222 - ld hl, AlreadyAsleepText - jp PrintText -.asm_3f222 - ld a, b - and a - jr nz, .asm_3f242 - push de - call MoveHitTest - pop de - ld a, [W_MOVEMISSED] - and a - jr nz, .asm_3f242 -.asm_3f231 - call BattleRandom - and $7 - jr z, .asm_3f231 - ld [de], a - call Func_3fb89 - ld hl, FellAsleepText - jp PrintText -.asm_3f242 - jp PrintDidntAffectText - -FellAsleepText: ; 3f245 (f:7245) - TX_FAR _FellAsleepText - db "@" - -AlreadyAsleepText: ; 3f24a (f:724a) - TX_FAR _AlreadyAsleepText - db "@" - -PoisonEffect: ; 3f24f (f:724f) - ld hl, wEnemyMonStatus - ld de, W_PLAYERMOVEEFFECT - ld a, [H_WHOSETURN] - and a - jr z, .asm_3f260 - ld hl, wBattleMonStatus - ld de, W_ENEMYMOVEEFFECT -.asm_3f260 - call CheckTargetSubstitute - jr nz, .asm_3f2d3 - ld a, [hli] - ld b, a - and a - jr nz, .asm_3f2d3 - ld a, [hli] - cp $3 - jr z, .asm_3f2d3 - ld a, [hld] - cp $3 - jr z, .asm_3f2d3 - ld a, [de] - cp POISON_SIDE_EFFECT1 - ld b, $34 ; ~20% chance of poisoning - jr z, .asm_3f290 - cp POISON_SIDE_EFFECT2 - ld b, $67 ; ~40% chance of poisoning - jr z, .asm_3f290 - push hl - push de - call MoveHitTest - pop de - pop hl - ld a, [W_MOVEMISSED] - and a - jr nz, .asm_3f2d7 - jr .asm_3f295 -.asm_3f290 - call BattleRandom - cp b - ret nc -.asm_3f295 - dec hl - set 3, [hl] - push de - dec de - ld a, [H_WHOSETURN] - and a -<<<<<<< HEAD - ld b, ANIM_C7 - ld hl, W_PLAYERBATTSTATUS3 ; W_PLAYERBATTSTATUS3 -======= - ld b, $c7 - ld hl, W_PLAYERBATTSTATUS3 ->>>>>>> yama/master - ld a, [de] - ld de, W_PLAYERTOXICCOUNTER - jr nz, .asm_3f2b0 -<<<<<<< HEAD - ld b, ANIM_A9 - ld hl, W_ENEMYBATTSTATUS3 ; W_ENEMYBATTSTATUS3 - ld de, W_ENEMYTOXICCOUNTER ; wd071 -======= - ld b, $a9 - ld hl, W_ENEMYBATTSTATUS3 - ld de, W_ENEMYTOXICCOUNTER ->>>>>>> yama/master -.asm_3f2b0 - cp TOXIC - jr nz, .asm_3f2bd - set 0, [hl] - xor a - ld [de], a - ld hl, BadlyPoisonedText - jr .asm_3f2c0 -.asm_3f2bd - ld hl, PoisonedText -.asm_3f2c0 - pop de - ld a, [de] - cp POISON_EFFECT - jr z, .asm_3f2cd - ld a, b - call Func_3fb96 - jp PrintText -.asm_3f2cd - call Func_3fb89 - jp PrintText -.asm_3f2d3 - ld a, [de] - cp POISON_EFFECT - ret nz -.asm_3f2d7 - ld c, $32 - call DelayFrames - jp PrintDidntAffectText - -PoisonedText: ; 3f2df (f:72df) - TX_FAR _PoisonedText - db "@" - -BadlyPoisonedText: ; 3f2e4 (f:72e4) - TX_FAR _BadlyPoisonedText - db "@" - -DrainHPEffect: ; 3f2e9 (f:72e9) - ld hl, DrainHPEffect_ - ld b, BANK(DrainHPEffect_) - jp Bankswitch - -ExplodeEffect: ; 3f2f1 (f:72f1) - ld hl, wBattleMonHP - ld de, W_PLAYERBATTSTATUS2 - ld a, [H_WHOSETURN] - and a - jr z, .asm_3f302 - ld hl, wEnemyMonHP - ld de, W_ENEMYBATTSTATUS2 -.asm_3f302 - xor a - ld [hli], a ; set the mon's HP to 0 - ld [hli], a - inc hl - ld [hl], a ; set mon's status to 0 - ld a, [de] - res 7, a ; clear mon's leech seed status - ld [de], a - ret - -FreezeBurnParalyzeEffect: ; 3f30c (f:730c) - xor a - ld [wcc5b], a - call CheckTargetSubstitute ;test bit 4 of d063/d068 flags [target has substitute flag] - ret nz ;return if they have a substitute, can't effect them - ld a, [$fff3] ;whose turn? - and a - jp nz, opponentAttacker - ld a, [wEnemyMonStatus] - and a - jp nz, CheckDefrost - ;opponent has no existing status - ld a, [W_PLAYERMOVETYPE] - ld b, a - ld a, [wEnemyMonType1] - cp b - ret z ;return if they match [can't freeze an ice type etc.] - ld a, [wEnemyMonType2] - cp b - ret z ;return.. - ld a, [W_PLAYERMOVEEFFECT] - cp a, 7 ;10% status effects are 04, 05, 06 so 07 will set carry for those - ld b, $1a ;[1A-1]/100 or [26-1]/256 = 9.8%~ chance - jr c, .next1 ;branch ahead if this is a 10% chance effect.. - ld b, $4d ;..or use [4D-1]/100 or [76-1]/256 = 29.7%~ chance - sub a, $1e ;subtract $1E to map to equivalent 10% chance effects -.next1 - push af ;push effect... - call BattleRandom ;get random 8bit value for probability test - cp b ;success? - pop bc ;...pop effect into C - ret nc ;do nothing if random value is >= 1A or 4D [no status applied] - ;the test passed - ld a, b ;what type of effect is this? - cp a, BURN_SIDE_EFFECT1 - jr z, .burn - cp a, FREEZE_SIDE_EFFECT - jr z, .freeze - ld a, 1 << PAR - ld [wEnemyMonStatus], a -<<<<<<< HEAD - call Func_3ed27 ;quarter speed of affected monster - ld a, ANIM_A9 -======= - call QuarterSpeedDueToParalysis ;quarter speed of affected monster - ld a, $a9 ->>>>>>> yama/master - call Func_3fbb9 ;animation - jp PrintMayNotAttackText ;print paralysis text -.burn - ld a, 1 << BRN - ld [wEnemyMonStatus], a -<<<<<<< HEAD - call Func_3ed64 - ld a, ANIM_A9 -======= - call HalveAttackDueToBurn - ld a, $a9 ->>>>>>> yama/master - call Func_3fbb9 ;animation - ld hl, BurnedText - jp PrintText -.freeze - call Func_3f9cf ;resets bit 5 of the D063/D068 flags - ld a, 1 << FRZ - ld [wEnemyMonStatus], a - ld a, ANIM_A9 - call Func_3fbb9 ;animation - ld hl, FrozenText - jp PrintText -opponentAttacker: ; 3f382 (f:7382) - ld a, [wBattleMonStatus] ;this appears to the same as above with addresses swapped for opponent - and a - jp nz, CheckDefrost - ld a, [W_ENEMYMOVETYPE] - ld b, a - ld a, [wBattleMonType1] - cp b - ret z - ld a, [wBattleMonType2] - cp b - ret z - ld a, [W_ENEMYMOVEEFFECT] - cp a, 7 - ld b, $1a - jr c, .next1 - ld b, $4d - sub a, $1e -.next1 - push af - call BattleRandom - cp b - pop bc - ret nc - ld a, b - cp a, BURN_SIDE_EFFECT1 - jr z, .burn - cp a, FREEZE_SIDE_EFFECT - jr z, .freeze - ld a, 1 << PAR - ld [wBattleMonStatus], a - call QuarterSpeedDueToParalysis - jp PrintMayNotAttackText -.burn - ld a, 1 << BRN - ld [wBattleMonStatus], a - call HalveAttackDueToBurn - ld hl, BurnedText - jp PrintText -.freeze - ld a, 1 << FRZ - ld [wBattleMonStatus], a - ld hl, FrozenText - jp PrintText - -BurnedText: ; 3f3d8 (f:73d8) - TX_FAR _BurnedText - db "@" - -FrozenText: ; 3f3dd (f:73dd) - TX_FAR _FrozenText - db "@" - -CheckDefrost: ; 3f3e2 (f:73e2) - and a, 1 << FRZ ;are they frozen? - ret z ;return if so - ;not frozen - ld a, [$fff3] ;whose turn? - and a - jr nz, .opponent - ;player [attacker] - ld a, [W_PLAYERMOVETYPE] - sub a, FIRE - ret nz ;return if it isn't fire - ;type is fire - ld [wEnemyMonStatus], a ;set opponent status to 00 ["defrost" a frozen monster] - ld hl, wEnemyMon1Status - ld a, [wEnemyMonPartyPos] - ld bc, wEnemyMon2 - wEnemyMon1 - call AddNTimes - xor a - ld [hl], a ;clear status in roster - ld hl, FireDefrostedText - jr .common -.opponent - ld a, [W_ENEMYMOVETYPE] ;same as above with addresses swapped - sub a, FIRE - ret nz - ld [wBattleMonStatus], a - ld hl, wPartyMon1Status - ld a, [wPlayerMonNumber] - ld bc, wPartyMon2 - wPartyMon1 - call AddNTimes - xor a - ld [hl], a - ld hl, FireDefrostedText -.common - jp PrintText - -FireDefrostedText: ; 3f423 (f:7423) - TX_FAR _FireDefrostedText - db "@" - -StatModifierUpEffect: ; 3f428 (f:7428) - ld hl, wPlayerMonStatMods - ld de, W_PLAYERMOVEEFFECT - ld a, [H_WHOSETURN] - and a - jr z, .asm_3f439 - ld hl, wEnemyMonStatMods - ld de, W_ENEMYMOVEEFFECT -.asm_3f439 - ld a, [de] - sub $a - cp $8 - jr c, .asm_3f442 - sub $28 -.asm_3f442 - ld c, a - ld b, $0 - add hl, bc - ld b, [hl] - inc b - ld a, $d - cp b - jp c, Func_3f522 - ld a, [de] - cp $12 - jr c, .asm_3f45a - inc b - ld a, $d - cp b - jr nc, .asm_3f45a - ld b, a -.asm_3f45a - ld [hl], b - ld a, c - cp $4 - jr nc, asm_3f4ca - push hl - ld hl, wBattleMonAttack + 1 - ld de, wcd12 - ld a, [H_WHOSETURN] - and a - jr z, .asm_3f472 - ld hl, wEnemyMonAttack + 1 - ld de, wEnemyMonUnmodifiedAttack -.asm_3f472 - push bc - sla c - ld b, $0 - add hl, bc - ld a, c - add e - ld e, a - jr nc, .asm_3f47e - inc d -.asm_3f47e - pop bc - ld a, [hld] - sub $e7 - jr nz, .asm_3f48a - ld a, [hl] - sbc $3 - jp z, Func_3f520 -.asm_3f48a - push hl - push bc - ld hl, StatModifierRatios - dec b - sla b - ld c, b - ld b, $0 - add hl, bc - pop bc - xor a - ld [H_NUMTOPRINT], a ; $ff96 (aliases: H_MULTIPLICAND) - ld a, [de] - ld [$ff97], a - inc de - ld a, [de] - ld [$ff98], a - ld a, [hli] - ld [H_REMAINDER], a ; $ff99 (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) - call Multiply - ld a, [hl] - ld [H_REMAINDER], a ; $ff99 (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) - ld b, $4 - call Divide - pop hl - ld a, [$ff98] - sub $e7 - ld a, [$ff97] - sbc $3 - jp c, Func_3f4c3 - ld a, 999 / $100 - ld [$ff97], a - ld a, 999 % $100 - ld [$ff98], a - -Func_3f4c3: ; 3f4c3 (f:74c3) - ld a, [$ff97] - ld [hli], a - ld a, [$ff98] - ld [hl], a - pop hl -asm_3f4ca: ; 3f4ca (f:74ca) - ld b, c - inc b - call Func_3f688 - ld hl, W_PLAYERBATTSTATUS2 - ld de, W_PLAYERMOVENUM - ld bc, wccf7 - ld a, [H_WHOSETURN] - and a - jr z, .asm_3f4e6 - ld hl, W_ENEMYBATTSTATUS2 - ld de, W_ENEMYMOVENUM - ld bc, wccf3 -.asm_3f4e6 - ld a, [de] - cp MINIMIZE - jr nz, .asm_3f4f9 - bit 4, [hl] - push af - push bc - ld hl, Func_79747 - ld b, BANK(Func_79747) - push de - call nz, Bankswitch - pop de -.asm_3f4f9 - call Func_3fba8 - ld a, [de] - cp MINIMIZE - jr nz, .asm_3f50e - pop bc - ld a, $1 - ld [bc], a - ld hl, Func_79771 - ld b, BANK(Func_79771) - pop af - call nz, Bankswitch -.asm_3f50e - ld a, [H_WHOSETURN] - and a - call z, ApplyBadgeStatBoosts - ld hl, MonsStatsRoseText - call PrintText - call QuarterSpeedDueToParalysis - jp HalveAttackDueToBurn - -Func_3f520: ; 3f520 (f:7520) - pop hl - dec [hl] - -Func_3f522: ; 3f522 (f:7522) - ld hl, NothingHappenedText - jp PrintText - -MonsStatsRoseText: ; 3f528 (f:7528) - TX_FAR _MonsStatsRoseText - db $08 ; asm - ld hl, GreatlyRoseText - ld a, [H_WHOSETURN] - and a - ld a, [W_PLAYERMOVEEFFECT] - jr z, .asm_3f53b - ld a, [W_ENEMYMOVEEFFECT] -.asm_3f53b - cp ATTACK_DOWN1_EFFECT - ret nc - ld hl, RoseText - ret - -GreatlyRoseText: ; 3f542 (f:7542) - db $0a - TX_FAR _GreatlyRoseText - -RoseText: ; 3f547 (f:7547) - TX_FAR _RoseText - db "@" - -StatModifierDownEffect: ; 3f54c (f:754c) - ld hl, wEnemyMonStatMods - ld de, W_PLAYERMOVEEFFECT - ld bc, W_ENEMYBATTSTATUS1 - ld a, [H_WHOSETURN] - and a - jr z, .asm_3f572 - ld hl, wPlayerMonStatMods - ld de, W_ENEMYMOVEEFFECT - ld bc, W_PLAYERBATTSTATUS1 - ld a, [W_ISLINKBATTLE] - cp $4 - jr z, .asm_3f572 - call BattleRandom - cp $40 - jp c, Func_3f65a -.asm_3f572 - call CheckTargetSubstitute - jp nz, Func_3f65a - ld a, [de] - cp ATTACK_DOWN_SIDE_EFFECT - jr c, .asm_3f58a - call BattleRandom - cp SPLASH_EFFECT - jp nc, Func_3f650 - ld a, [de] - sub ATTACK_DOWN_SIDE_EFFECT - jr .asm_3f5a9 -.asm_3f58a - push hl - push de - push bc - call MoveHitTest - pop bc - pop de - pop hl - ld a, [W_MOVEMISSED] - and a - jp nz, Func_3f65a - ld a, [bc] - bit 6, a - jp nz, Func_3f65a - ld a, [de] - sub $12 - cp $8 - jr c, .asm_3f5a9 - sub $28 -.asm_3f5a9 - ld c, a - ld b, $0 - add hl, bc - ld b, [hl] - dec b - jp z, Func_3f650 - ld a, [de] - cp $24 - jr c, .asm_3f5bf - cp $44 - jr nc, .asm_3f5bf - dec b - jr nz, .asm_3f5bf - inc b -.asm_3f5bf - ld [hl], b - ld a, c - cp $4 - jr nc, asm_3f62c - push hl - push de - ld hl, wEnemyMonAttack + 1 - ld de, wEnemyMonUnmodifiedAttack - ld a, [H_WHOSETURN] - and a - jr z, .asm_3f5d8 - ld hl, wBattleMonAttack + 1 - ld de, wcd12 -.asm_3f5d8 - push bc - sla c - ld b, $0 - add hl, bc - ld a, c - add e - ld e, a - jr nc, .asm_3f5e4 - inc d -.asm_3f5e4 - pop bc - ld a, [hld] - sub $1 - jr nz, .asm_3f5ef - ld a, [hl] - and a - jp z, Func_3f64d -.asm_3f5ef - push hl - push bc - ld hl, StatModifierRatios - dec b - sla b - ld c, b - ld b, $0 - add hl, bc - pop bc - xor a - ld [H_NUMTOPRINT], a ; $ff96 (aliases: H_MULTIPLICAND) - ld a, [de] - ld [$ff97], a - inc de - ld a, [de] - ld [$ff98], a - ld a, [hli] - ld [H_REMAINDER], a ; $ff99 (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) - call Multiply - ld a, [hl] - ld [H_REMAINDER], a ; $ff99 (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) - ld b, $4 - call Divide - pop hl - ld a, [$ff98] - ld b, a - ld a, [$ff97] - or b - jp nz, Func_3f624 - ld [$ff97], a - ld a, $1 - ld [$ff98], a - -Func_3f624: ; 3f624 (f:7624) - ld a, [$ff97] - ld [hli], a - ld a, [$ff98] - ld [hl], a - pop de - pop hl -asm_3f62c: ; 3f62c (f:762c) - ld b, c - inc b - push de - call Func_3f688 - pop de - ld a, [de] - cp $44 - jr nc, .asm_3f63b - call Func_3fb89 -.asm_3f63b - ld a, [H_WHOSETURN] - and a - call nz, ApplyBadgeStatBoosts - ld hl, MonsStatsFellText - call PrintText - call QuarterSpeedDueToParalysis - jp HalveAttackDueToBurn - -Func_3f64d: ; 3f64d (f:764d) - pop de - pop hl - inc [hl] - -Func_3f650: ; 3f650 (f:7650) - ld a, [de] - cp ATTACK_DOWN_SIDE_EFFECT - ret nc - ld hl, NothingHappenedText - jp PrintText - -Func_3f65a: ; 3f65a (f:765a) - ld a, [de] - cp $44 - ret nc - jp Func_3fb4e - -MonsStatsFellText: ; 3f661 (f:7661) - TX_FAR _MonsStatsFellText - db $08 ; asm - ld hl, FellText - ld a, [H_WHOSETURN] - and a - ld a, [W_PLAYERMOVEEFFECT] - jr z, .asm_3f674 - ld a, [W_ENEMYMOVEEFFECT] -.asm_3f674 - cp $1a - ret c - cp $44 - ret nc - ld hl, GreatlyFellText - ret - -GreatlyFellText: ; 3f67e (f:767e) - db $0a - TX_FAR _GreatlyFellText - -FellText: ; 3f683 (f:7683) - TX_FAR _FellText - db "@" - -Func_3f688: ; 3f688 (f:7688) - ld hl, StatsTextStrings - ld c, $50 -.asm_3f68d - dec b - jr z, .asm_3f696 -.asm_3f690 - ld a, [hli] - cp c - jr z, .asm_3f68d - jr .asm_3f690 -.asm_3f696 - ld de, wcf4b - ld bc, $a - jp CopyData - -StatsTextStrings: ; 3f69f (f:769f) - db "ATTACK@" - db "DEFENSE@" - db "SPEED@" - db "SPECIAL@" - db "ACCURACY@" - db "EVADE@" - -StatModifierRatios: ; 3f6cb (f:76cb) -; first byte is numerator, second byte is denominator - db 25, 100 ; 0.25 - db 28, 100 ; 0.28 - db 33, 100 ; 0.33 - db 40, 100 ; 0.40 - db 50, 100 ; 0.50 - db 66, 100 ; 0.66 - db 1, 1 ; 1.00 - db 15, 10 ; 1.50 - db 2, 1 ; 2.00 - db 25, 10 ; 2.50 - db 3, 1 ; 3.00 - db 35, 10 ; 3.50 - db 4, 1 ; 4.00 - -BideEffect: ; 3f6e5 (f:76e5) - ld hl, W_PLAYERBATTSTATUS1 - ld de, W_NUMHITS - ld bc, wPlayerNumAttacksLeft - ld a, [H_WHOSETURN] - and a - jr z, .asm_3f6fc - ld hl, W_ENEMYBATTSTATUS1 - ld de, wcd05 - ld bc, wEnemyNumAttacksLeft -.asm_3f6fc - set 0, [hl] ; mon is now using bide - xor a - ld [de], a - inc de - ld [de], a - ld [W_PLAYERMOVEEFFECT], a - ld [W_ENEMYMOVEEFFECT], a - call BattleRandom - and $1 - inc a - inc a - ld [bc], a - ld a, [H_WHOSETURN] - add XSTATITEM_ANIM - jp Func_3fb96 - -ThrashPetalDanceEffect: ; 3f717 (f:7717) - ld hl, W_PLAYERBATTSTATUS1 - ld de, wPlayerNumAttacksLeft - ld a, [H_WHOSETURN] - and a - jr z, .asm_3f728 - ld hl, W_ENEMYBATTSTATUS1 - ld de, wEnemyNumAttacksLeft -.asm_3f728 - set 1, [hl] ; mon is now using thrash/petal dance - call BattleRandom - and $1 - inc a - inc a - ld [de], a -<<<<<<< HEAD - ld a, [H_WHOSETURN] ; $fff3 - add ANIM_B0 -======= - ld a, [H_WHOSETURN] - add $b0 ->>>>>>> yama/master - jp Func_3fb96 - -SwitchAndTeleportEffect: ; 3f739 (f:7739) - ld a, [H_WHOSETURN] - and a - jr nz, .asm_3f791 - ld a, [W_ISINBATTLE] - dec a - jr nz, .asm_3f77e - ld a, [W_CURENEMYLVL] - ld b, a - ld a, [wBattleMonLevel] - cp b - jr nc, .asm_3f76e - add b - ld c, a - inc c -.asm_3f751 - call BattleRandom - cp c - jr nc, .asm_3f751 - srl b - srl b - cp b - jr nc, .asm_3f76e - ld c, $32 - call DelayFrames - ld a, [W_PLAYERMOVENUM] - cp TELEPORT - jp nz, PrintDidntAffectText - jp PrintButItFailedText_ -.asm_3f76e - call ReadPlayerMonCurHPAndStatus - xor a - ld [wcc5b], a - inc a - ld [wEscapedFromBattle], a - ld a, [W_PLAYERMOVENUM] - jr .asm_3f7e4 -.asm_3f77e - ld c, $32 - call DelayFrames - ld hl, IsUnaffectedText - ld a, [W_PLAYERMOVENUM] - cp TELEPORT - jp nz, PrintText - jp PrintButItFailedText_ -.asm_3f791 - ld a, [W_ISINBATTLE] - dec a - jr nz, .asm_3f7d1 - ld a, [wBattleMonLevel] - ld b, a - ld a, [W_CURENEMYLVL] - cp b - jr nc, .asm_3f7c1 - add b - ld c, a - inc c -.asm_3f7a4 - call BattleRandom - cp c - jr nc, .asm_3f7a4 - srl b - srl b - cp b - jr nc, .asm_3f7c1 - ld c, $32 - call DelayFrames - ld a, [W_ENEMYMOVENUM] - cp TELEPORT - jp nz, PrintDidntAffectText - jp PrintButItFailedText_ -.asm_3f7c1 - call ReadPlayerMonCurHPAndStatus - xor a - ld [wcc5b], a - inc a - ld [wEscapedFromBattle], a - ld a, [W_ENEMYMOVENUM] - jr .asm_3f7e4 -.asm_3f7d1 - ld c, $32 - call DelayFrames - ld hl, IsUnaffectedText - ld a, [W_ENEMYMOVENUM] - cp TELEPORT - jp nz, PrintText - jp Func_3fb4e -.asm_3f7e4 - push af - call Func_3fbb9 - ld c, $14 - call DelayFrames - pop af - ld hl, RanFromBattleText - cp TELEPORT - jr z, .asm_3f7ff - ld hl, RanAwayScaredText - cp ROAR - jr z, .asm_3f7ff - ld hl, WasBlownAwayText -.asm_3f7ff - jp PrintText - -RanFromBattleText: ; 3f802 (f:7802) - TX_FAR _RanFromBattleText - db "@" - -RanAwayScaredText: ; 3f807 (f:7807) - TX_FAR _RanAwayScaredText - db "@" - -WasBlownAwayText: ; 3f80c (f:780c) - TX_FAR _WasBlownAwayText - db "@" - -TwoToFiveAttacksEffect: ; 3f811 (f:7811) - ld hl, W_PLAYERBATTSTATUS1 - ld de, wPlayerNumAttacksLeft - ld bc, W_NUMHITS - ld a, [H_WHOSETURN] - and a - jr z, .asm_3f828 - ld hl, W_ENEMYBATTSTATUS1 - ld de, wEnemyNumAttacksLeft - ld bc, wcd05 -.asm_3f828 - bit 2, [hl] ; is mon attacking multiple times? - ret nz - set 2, [hl] ; mon is now attacking multiple times - ld hl, W_PLAYERMOVEEFFECT - ld a, [H_WHOSETURN] - and a - jr z, .asm_3f838 - ld hl, W_ENEMYMOVEEFFECT -.asm_3f838 - ld a, [hl] - cp TWINEEDLE_EFFECT - jr z, .asm_3f856 - cp ATTACK_TWICE_EFFECT - ld a, $2 - jr z, .asm_3f853 - call BattleRandom - and $3 - cp $2 - jr c, .asm_3f851 - call BattleRandom - and $3 -.asm_3f851 - inc a - inc a -.asm_3f853 - ld [de], a - ld [bc], a - ret -.asm_3f856 - ld a, $2 - ld [hl], a - jr .asm_3f853 - -FlichSideEffect: ; 3f85b (f:785b) - call CheckTargetSubstitute - ret nz - ld hl, W_ENEMYBATTSTATUS1 - ld de, W_PLAYERMOVEEFFECT - ld a, [H_WHOSETURN] - and a - jr z, .asm_3f870 - ld hl, W_PLAYERBATTSTATUS1 - ld de, W_ENEMYMOVEEFFECT -.asm_3f870 - ld a, [de] - cp FLINCH_SIDE_EFFECT1 - ld b, $1a ; ~10% chance of flinch - jr z, .asm_3f879 - ld b, $4d ; ~30% chance of flinch -.asm_3f879 - call BattleRandom - cp b - ret nc - set 3, [hl] ; set mon's status to flinching - call Func_3f9cf - ret - -OneHitKOEffect: ; 3f884 (f:7884) - ld hl, OneHitKOEffect_ - ld b, BANK(OneHitKOEffect_) - jp Bankswitch - -ChargeEffect: ; 3f88c (f:788c) - ld hl, W_PLAYERBATTSTATUS1 - ld de, W_PLAYERMOVEEFFECT - ld a, [H_WHOSETURN] - and a - ld b, XSTATITEM_ANIM - jr z, .asm_3f8a1 -<<<<<<< HEAD - ld hl, W_ENEMYBATTSTATUS1 ; W_ENEMYBATTSTATUS1 - ld de, W_ENEMYMOVEEFFECT ; W_ENEMYMOVEEFFECT - ld b, ANIM_AF -======= - ld hl, W_ENEMYBATTSTATUS1 - ld de, W_ENEMYMOVEEFFECT - ld b, $af ->>>>>>> yama/master -.asm_3f8a1 - set 4, [hl] - ld a, [de] - dec de ; de contains enemy or player MOVENUM - cp FLY_EFFECT - jr nz, .asm_3f8ad - set 6, [hl] ; mon is now invulnerable to typical attacks (fly/dig) - ld b, TELEPORT -.asm_3f8ad - ld a, [de] - cp DIG - jr nz, .asm_3f8b6 - set 6, [hl] ; mon is now invulnerable to typical attacks (fly/dig) - ld b, ANIM_C0 -.asm_3f8b6 - xor a - ld [wcc5b], a - ld a, b - call Func_3fbb9 - ld a, [de] - ld [wWhichTrade], a - ld hl, ChargeMoveEffectText - jp PrintText - -ChargeMoveEffectText: ; 3f8c8 (f:78c8) - TX_FAR _ChargeMoveEffectText - db $08 ; asm - ld a, [wWhichTrade] - cp RAZOR_WIND - ld hl, MadeWhirlwindText - jr z, .asm_3f8f8 - cp SOLARBEAM - ld hl, TookInSunlightText - jr z, .asm_3f8f8 - cp SKULL_BASH - ld hl, LoweredItsHeadText - jr z, .asm_3f8f8 - cp SKY_ATTACK - ld hl, SkyAttackGlowingText - jr z, .asm_3f8f8 - cp FLY - ld hl, FlewUpHighText - jr z, .asm_3f8f8 - cp DIG - ld hl, DugAHoleText -.asm_3f8f8 - ret - -MadeWhirlwindText: ; 3f8f9 (f:78f9) - TX_FAR _MadeWhirlwindText - db "@" - -TookInSunlightText: ; 3f8fe (f:78fe) - TX_FAR _TookInSunlightText - db "@" - -LoweredItsHeadText: ; 3f903 (f:7903) - TX_FAR _LoweredItsHeadText - db "@" - -SkyAttackGlowingText: ; 3f908 (f:7908) - TX_FAR _SkyAttackGlowingText - db "@" - -FlewUpHighText: ; 3f90d (f:790d) - TX_FAR _FlewUpHighText - db "@" - -DugAHoleText: ; 3f912 (f:7912) - TX_FAR _DugAHoleText - db "@" - -TrappingEffect: ; 3f917 (f:7917) - ld hl, W_PLAYERBATTSTATUS1 - ld de, wPlayerNumAttacksLeft - ld a, [H_WHOSETURN] - and a - jr z, .asm_3f928 - ld hl, W_ENEMYBATTSTATUS1 - ld de, wEnemyNumAttacksLeft -.asm_3f928 - bit 5, [hl] - ret nz - call Func_3f9cf - set 5, [hl] - call BattleRandom - and $3 - cp $2 - jr c, .asm_3f93e - call BattleRandom - and $3 -.asm_3f93e - inc a - ld [de], a - ret - -MistEffect: ; 3f941 (f:7941) - ld hl, MistEffect_ - ld b, BANK(MistEffect_) - jp Bankswitch - -FocusEnergyEffect: ; 3f949 (f:7949) - ld hl, FocusEnergyEffect_ - ld b, BANK(FocusEnergyEffect_) - jp Bankswitch - -RecoilEffect: ; 3f951 (f:7951) - ld hl, RecoilEffect_ - ld b, BANK(RecoilEffect_) - jp Bankswitch - -ConfusionSideEffect: ; 3f959 (f:7959) - call BattleRandom - cp $19 - ret nc - jr Func_3f96f - -ConfusionEffect: ; 3f961 (f:7961) - call CheckTargetSubstitute - jr nz, Func_3f9a6 - call MoveHitTest - ld a, [W_MOVEMISSED] - and a - jr nz, Func_3f9a6 - -Func_3f96f: ; 3f96f (f:796f) - ld a, [H_WHOSETURN] - and a - ld hl, W_ENEMYBATTSTATUS1 - ld bc, wd070 - ld a, [W_PLAYERMOVEEFFECT] - jr z, .asm_3f986 - ld hl, W_PLAYERBATTSTATUS1 - ld bc, wd06b - ld a, [W_ENEMYMOVEEFFECT] -.asm_3f986 - bit 7, [hl] ; is mon confused? - jr nz, Func_3f9a6 - set 7, [hl] ; mon is now confused - push af - call BattleRandom - and $3 - inc a - inc a - ld [bc], a - pop af - cp CONFUSION_SIDE_EFFECT - call nz, Func_3fb89 - ld hl, BecameConfusedText - jp PrintText - -BecameConfusedText: ; 3f9a1 (f:79a1) - TX_FAR _BecameConfusedText - db "@" - -Func_3f9a6: ; 3f9a6 (f:79a6) - cp CONFUSION_SIDE_EFFECT - ret z - ld c, $32 - call DelayFrames - jp Func_3fb4e - -ParalyzeEffect: ; 3f9b1 (f:79b1) - ld hl, ParalyzeEffect_ - ld b, BANK(ParalyzeEffect_) - jp Bankswitch - -SubstituteEffect: ; 3f9b9 (f:79b9) - ld hl, SubstituteEffectHandler - ld b, BANK(SubstituteEffectHandler) - jp Bankswitch - -HyperBeamEffect: ; 3f9c1 (f:79c1) - ld hl, W_PLAYERBATTSTATUS2 - ld a, [H_WHOSETURN] - and a - jr z, .asm_3f9cc - ld hl, W_ENEMYBATTSTATUS2 -.asm_3f9cc - set 5, [hl] ; mon now needs to recharge - ret - -Func_3f9cf: ; 3f9cf (f:79cf) - push hl - ld hl, W_ENEMYBATTSTATUS2 - ld a, [H_WHOSETURN] - and a - jr z, .asm_3f9db - ld hl, W_PLAYERBATTSTATUS2 -.asm_3f9db - res 5, [hl] ; mon no longer needs to recharge - pop hl - ret - -RageEffect: ; 3f9df (f:79df) - ld hl, W_PLAYERBATTSTATUS2 - ld a, [H_WHOSETURN] - and a - jr z, .player - ld hl, W_ENEMYBATTSTATUS2 -.player - set 6, [hl] ; mon is now in "rage" mode - ret - -MimicEffect: ; 3f9ed (f:79ed) - ld c, $32 - call DelayFrames - call MoveHitTest - ld a, [W_MOVEMISSED] - and a - jr nz, .asm_3fa74 - ld a, [H_WHOSETURN] - and a - ld hl, wBattleMonMoves - ld a, [W_PLAYERBATTSTATUS1] - jr nz, .asm_3fa13 - ld a, [W_ISLINKBATTLE] - cp $4 - jr nz, .asm_3fa3a - ld hl, wEnemyMonMoves - ld a, [W_ENEMYBATTSTATUS1] -.asm_3fa13 - bit 6, a - jr nz, .asm_3fa74 -.asm_3fa17 - push hl - call BattleRandom - and $3 - ld c, a - ld b, $0 - add hl, bc - ld a, [hl] - pop hl - and a - jr z, .asm_3fa17 - ld d, a - ld a, [H_WHOSETURN] - and a - ld hl, wBattleMonMoves - ld a, [wPlayerMoveListIndex] - jr z, .asm_3fa5f - ld hl, wEnemyMonMoves - ld a, [wEnemyMoveListIndex] - jr .asm_3fa5f -.asm_3fa3a - ld a, [W_ENEMYBATTSTATUS1] - bit 6, a - jr nz, .asm_3fa74 - ld a, [wCurrentMenuItem] - push af - ld a, $1 - ld [wMoveMenuType], a - call MoveSelectionMenu - call LoadScreenTilesFromBuffer1 - ld hl, wEnemyMonMoves - ld a, [wCurrentMenuItem] - ld c, a - ld b, $0 - add hl, bc - ld d, [hl] - pop af - ld hl, wBattleMonMoves -.asm_3fa5f - ld c, a - ld b, $0 - add hl, bc - ld a, d - ld [hl], a - ld [wd11e], a - call GetMoveName - call Func_3fba8 - ld hl, MimicLearnedMoveText - jp PrintText -.asm_3fa74 - jp PrintButItFailedText_ - -MimicLearnedMoveText: ; 3fa77 (f:7a77) - TX_FAR _MimicLearnedMoveText - db "@" - -LeechSeedEffect: ; 3fa7c (f:7a7c) - ld hl, LeechSeedEffect_ - ld b, BANK(LeechSeedEffect_) - jp Bankswitch - -SplashEffect: ; 3fa84 (f:7a84) - call Func_3fba8 - jp PrintNoEffectText - -DisableEffect: ; 3fa8a (f:7a8a) - call MoveHitTest - ld a, [W_MOVEMISSED] - and a - jr nz, .asm_3fb06 - ld de, W_ENEMYDISABLEDMOVE - ld hl, wEnemyMonMoves - ld a, [H_WHOSETURN] - and a - jr z, .asm_3faa4 - ld de, W_PLAYERDISABLEDMOVE - ld hl, wBattleMonMoves -.asm_3faa4 - ld a, [de] - and a - jr nz, .asm_3fb06 -.asm_3faa8 - push hl - call BattleRandom - and $3 - ld c, a - ld b, $0 - add hl, bc - ld a, [hl] - pop hl - and a - jr z, .asm_3faa8 - ld [wd11e], a - push hl - ld a, [H_WHOSETURN] - and a - ld hl, wBattleMonPP - jr nz, .asm_3facf - ld a, [W_ISLINKBATTLE] - cp $4 - pop hl - jr nz, .asm_3fae1 - push hl - ld hl, wEnemyMonPP -.asm_3facf - push hl - ld a, [hli] - or [hl] - inc hl - or [hl] - inc hl - or [hl] - and $3f - pop hl - jr z, .asm_3fb05 - add hl, bc - ld a, [hl] - pop hl - and a - jr z, .asm_3faa8 -.asm_3fae1 - call BattleRandom - and $7 - inc a - inc c - swap c - add c - ld [de], a - call Func_3fb89 - ld hl, wccee - ld a, [H_WHOSETURN] - and a - jr nz, .asm_3faf8 - inc hl -.asm_3faf8 - ld a, [wd11e] - ld [hl], a - call GetMoveName - ld hl, MoveWasDisabledText - jp PrintText -.asm_3fb05 - pop hl -.asm_3fb06 - jp PrintButItFailedText_ - -MoveWasDisabledText: ; 3fb09 (f:7b09) - TX_FAR _MoveWasDisabledText - db "@" - -PayDayEffect: ; 3fb0e (f:7b0e) - ld hl, PayDayEffect_ - ld b, BANK(PayDayEffect_) - jp Bankswitch - -ConversionEffect: ; 3fb16 (f:7b16) - ld hl, ConversionEffect_ - ld b, BANK(ConversionEffect_) - jp Bankswitch - -HazeEffect: ; 3fb1e (f:7b1e) - ld hl, HazeEffect_ - ld b, BANK(HazeEffect_) - jp Bankswitch - -HealEffect: ; 3fb26 (f:7b26) - ld hl, HealEffect_ - ld b, BANK(HealEffect_) - jp Bankswitch - -TransformEffect: ; 3fb2e (f:7b2e) - ld hl, TransformEffect_ - ld b, BANK(TransformEffect_) - jp Bankswitch - -ReflectLightScreenEffect: ; 3fb36 (f:7b36) - ld hl, ReflectLightScreenEffect_ - ld b, BANK(ReflectLightScreenEffect_) - jp Bankswitch - -NothingHappenedText: ; 3fb3e (f:7b3e) - TX_FAR _NothingHappenedText - db "@" - -PrintNoEffectText: ; 3fb43 (f:7b43) - ld hl, NoEffectText - jp PrintText - -NoEffectText: ; 3fb49 (f:7b49) - TX_FAR _NoEffectText - db "@" - -Func_3fb4e: ; 3fb4e (f:7b4e) - ld a, [wccf4] - and a - ret nz - -PrintButItFailedText_: ; 3fb53 (f:7b53) - ld hl, ButItFailedText - jp PrintText - -ButItFailedText: ; 3fb59 (f:7b59) - TX_FAR _ButItFailedText - db "@" - -PrintDidntAffectText: ; 3fb5e (f:7b5e) - ld hl, DidntAffectText - jp PrintText - -DidntAffectText: ; 3fb64 (f:7b64) - TX_FAR _DidntAffectText - db "@" - -IsUnaffectedText: ; 3fb69 (f:7b69) - TX_FAR _IsUnaffectedText - db "@" - -PrintMayNotAttackText: ; 3fb6e (f:7b6e) - ld hl, ParalyzedMayNotAttackText - jp PrintText - -ParalyzedMayNotAttackText: ; 3fb74 (f:7b74) - TX_FAR _ParalyzedMayNotAttackText - db "@" - -CheckTargetSubstitute: ; 3fb79 (f:7b79) - push hl - ld hl, W_ENEMYBATTSTATUS2 - ld a, [$fff3] ;whose turn? - and a - jr z, .next1 - ld hl, W_PLAYERBATTSTATUS2 -.next1 - bit 4, [hl] ;test bit 4 in d063/d068 flags - pop hl - ret - -Func_3fb89: ; 3fb89 (f:7b89) - ld a, [H_WHOSETURN] - and a - ld a, [W_PLAYERMOVENUM] - jr z, .asm_3fb94 - ld a, [W_ENEMYMOVENUM] -.asm_3fb94 - and a - ret z - -Func_3fb96: ; 3fb96 (f:7b96) - ld [W_ANIMATIONID], a - ld a, [H_WHOSETURN] - and a - ld a, $6 - jr z, .asm_3fba2 - ld a, $3 -.asm_3fba2 - ld [wcc5b], a - jp Func_3fbbc - -Func_3fba8: ; 3fba8 (f:7ba8) - xor a - ld [wcc5b], a - ld a, [H_WHOSETURN] - and a - ld a, [W_PLAYERMOVENUM] - jr z, .asm_3fbb7 - ld a, [W_ENEMYMOVENUM] -.asm_3fbb7 - and a - ret z - -Func_3fbb9: ; 3fbb9 (f:7bb9) - ld [W_ANIMATIONID], a - -Func_3fbbc: ; 3fbbc (f:7bbc) - push hl - push de - push bc - predef MoveAnimation - pop bc - pop de - pop hl - ret diff --git a/engine/menu/pokedex.asm.orig b/engine/menu/pokedex.asm.orig deleted file mode 100755 index 7d7d2b3851..0000000000 --- a/engine/menu/pokedex.asm.orig +++ /dev/null @@ -1,647 +0,0 @@ -ShowPokedexMenu: ; 40000 (10:4000) - call GBPalWhiteOut - call ClearScreen - call UpdateSprites ; move sprites - ld a,[wListScrollOffset] - push af - xor a - ld [wCurrentMenuItem],a - ld [wListScrollOffset],a - ld [wLastMenuItem],a - inc a - ld [wd11e],a - ld [hJoy7],a -.setUpGraphics - ld b,$08 - call GoPAL_SET - callab LoadPokedexTilePatterns -.doPokemonListMenu - ld hl,wTopMenuItemY - ld a,3 - ld [hli],a ; top menu item Y - xor a - ld [hli],a ; top menu item X - inc a - ld [wcc37],a - inc hl - inc hl - ld a,6 - ld [hli],a ; max menu item ID - ld [hl],%00110011 ; menu watched keys (Left, Right, B button, A button) - call HandlePokedexListMenu - jr c,.goToSideMenu ; if the player chose a pokemon from the list -.exitPokedex - xor a - ld [wcc37],a - ld [wCurrentMenuItem],a - ld [wLastMenuItem],a -<<<<<<< HEAD - ld [hJoy7],a - ld [wcd3a],a - ld [wcd3b],a -======= - ld [$ffb7],a - ld [wWastedByteCD3A],a - ld [wOverrideSimulatedJoypadStatesMask],a ->>>>>>> yama/master - pop af - ld [wListScrollOffset],a - call GBPalWhiteOutWithDelay3 - call GoPAL_SET_CF1C - jp ReloadMapData -.goToSideMenu - call HandlePokedexSideMenu - dec b - jr z,.exitPokedex ; if the player chose Quit - dec b - jr z,.doPokemonListMenu ; if pokemon not seen or player pressed B button - jp .setUpGraphics ; if pokemon data or area was shown - -; handles the menu on the lower right in the pokedex screen -; OUTPUT: -; b = reason for exiting menu -; 00: showed pokemon data or area -; 01: the player chose Quit -; 02: the pokemon has not been seen yet or the player pressed the B button -HandlePokedexSideMenu: ; 4006d (10:406d) - call PlaceUnfilledArrowMenuCursor - ld a,[wCurrentMenuItem] - push af - ld b,a - ld a,[wLastMenuItem] - push af - ld a,[wListScrollOffset] - push af - add b - inc a - ld [wd11e],a - ld a,[wd11e] - push af - ld a,[wWhichTrade] - push af - ld hl,wPokedexSeen - call IsPokemonBitSet - ld b,2 - jr z,.exitSideMenu - call PokedexToIndex - ld hl,wTopMenuItemY - ld a,10 - ld [hli],a ; top menu item Y - ld a,15 - ld [hli],a ; top menu item X - xor a - ld [hli],a ; current menu item ID - inc hl - ld a,3 - ld [hli],a ; max menu item ID - ld [hli],a ; menu watched keys (A button and B button) - xor a - ld [hli],a ; old menu item ID - ld [wcc37],a -.handleMenuInput - call HandleMenuInput - bit 1,a ; was the B button pressed? - ld b,2 - jr nz,.buttonBPressed - ld a,[wCurrentMenuItem] - and a - jr z,.choseData - dec a - jr z,.choseCry - dec a - jr z,.choseArea -.choseQuit - ld b,1 -.exitSideMenu - pop af - ld [wWhichTrade],a - pop af - ld [wd11e],a - pop af - ld [wListScrollOffset],a - pop af - ld [wLastMenuItem],a - pop af - ld [wCurrentMenuItem],a - push bc - hlCoord 0, 3 - ld de,20 - ld bc,$7f0d ; 13 blank tiles - call DrawTileLine ; cover up the menu cursor in the pokemon list - pop bc - ret -.buttonBPressed - push bc - hlCoord 15, 10 - ld de,20 - ld bc,$7f07 ; 7 blank tiles - call DrawTileLine ; cover up the menu cursor in the side menu - pop bc - jr .exitSideMenu -.choseData - call ShowPokedexDataInternal - ld b,0 - jr .exitSideMenu -; play pokemon cry -.choseCry - ld a,[wd11e] - call GetCryData ; get cry data - call PlaySound ; play sound - jr .handleMenuInput -.choseArea - predef LoadTownMap_Nest ; display pokemon areas - ld b,0 - jr .exitSideMenu - -; handles the list of pokemon on the left of the pokedex screen -; sets carry flag if player presses A, unsets carry flag if player presses B -HandlePokedexListMenu: ; 40111 (10:4111) - xor a - ld [H_AUTOBGTRANSFERENABLED],a -; draw the horizontal line separating the seen and owned amounts from the menu - hlCoord 15, 8 - ld a,$7a ; horizontal line tile - ld [hli],a - ld [hli],a - ld [hli],a - ld [hli],a - ld [hli],a - hlCoord 14, 0 - ld [hl],$71 ; vertical line tile - hlCoord 14, 1 - call DrawPokedexVerticalLine - hlCoord 14, 9 - call DrawPokedexVerticalLine - ld hl,wPokedexSeen - ld b,wPokedexSeenEnd - wPokedexSeen - call CountSetBits - ld de,wd11e - hlCoord 16, 3 - ld bc,$0103 - call PrintNumber ; print number of seen pokemon - ld hl,wPokedexOwned - ld b,wPokedexOwnedEnd - wPokedexOwned - call CountSetBits - ld de,wd11e - hlCoord 16, 6 - ld bc,$0103 - call PrintNumber ; print number of owned pokemon - hlCoord 16, 2 - ld de,PokedexSeenText - call PlaceString - hlCoord 16, 5 - ld de,PokedexOwnText - call PlaceString - hlCoord 1, 1 - ld de,PokedexContentsText - call PlaceString - hlCoord 16, 10 - ld de,PokedexMenuItemsText - call PlaceString -; find the highest pokedex number among the pokemon the player has seen - ld hl,wPokedexSeenEnd - 1 - ld b,153 -.maxSeenPokemonLoop - ld a,[hld] - ld c,8 -.maxSeenPokemonInnerLoop - dec b - sla a - jr c,.storeMaxSeenPokemon - dec c - jr nz,.maxSeenPokemonInnerLoop - jr .maxSeenPokemonLoop -.storeMaxSeenPokemon - ld a,b - ld [wWhichTrade],a ; max seen pokemon -.loop - xor a - ld [H_AUTOBGTRANSFERENABLED],a - hlCoord 4, 2 - ld bc,$0e0a - call ClearScreenArea - hlCoord 1, 3 - ld a,[wListScrollOffset] - ld [wd11e],a - ld d,7 - ld a,[wWhichTrade] - cp a,7 - jr nc,.printPokemonLoop - ld d,a - dec a - ld [wMaxMenuItem],a -; loop to print pokemon pokedex numbers and names -; if the player has owned the pokemon, it puts a pokeball beside the name -.printPokemonLoop - ld a,[wd11e] - inc a - ld [wd11e],a - push af - push de - push hl - ld de,-20 - add hl,de - ld de,wd11e - ld bc,$8103 - call PrintNumber ; print the pokedex number - ld de,20 - add hl,de - dec hl - push hl - ld hl,wPokedexOwned - call IsPokemonBitSet - pop hl - ld a," " - jr z,.writeTile - ld a,$72 ; pokeball tile -.writeTile - ld [hl],a ; put a pokeball next to pokemon that the player has owned - push hl - ld hl,wPokedexSeen - call IsPokemonBitSet - jr nz,.getPokemonName ; if the player has seen the pokemon - ld de,.dashedLine ; print a dashed line in place of the name if the player hasn't seen the pokemon - jr .skipGettingName -.dashedLine ; for unseen pokemon in the list - db "----------@" -.getPokemonName - call PokedexToIndex - call GetMonName -.skipGettingName - pop hl - inc hl - call PlaceString - pop hl - ld bc,2 * 20 - add hl,bc - pop de - pop af - ld [wd11e],a - dec d - jr nz,.printPokemonLoop - ld a,01 - ld [H_AUTOBGTRANSFERENABLED],a - call Delay3 - call GBPalNormal - call HandleMenuInput - bit 1,a ; was the B button pressed? - jp nz,.buttonBPressed -.checkIfUpPressed - bit 6,a ; was Up pressed? - jr z,.checkIfDownPressed -.upPressed ; scroll up one row - ld a,[wListScrollOffset] - and a - jp z,.loop - dec a - ld [wListScrollOffset],a - jp .loop -.checkIfDownPressed - bit 7,a ; was Down pressed? - jr z,.checkIfRightPressed -.downPressed ; scroll down one row - ld a,[wWhichTrade] - cp a,7 - jp c,.loop - sub a,7 - ld b,a - ld a,[wListScrollOffset] - cp b - jp z,.loop - inc a - ld [wListScrollOffset],a - jp .loop -.checkIfRightPressed - bit 4,a ; was Right pressed? - jr z,.checkIfLeftPressed -.rightPressed ; scroll down 7 rows - ld a,[wWhichTrade] - cp a,7 - jp c,.loop - sub a,6 - ld b,a - ld a,[wListScrollOffset] - add a,7 - ld [wListScrollOffset],a - cp b - jp c,.loop - dec b - ld a,b - ld [wListScrollOffset],a - jp .loop -.checkIfLeftPressed ; scroll up 7 rows - bit 5,a ; was Left pressed? - jr z,.buttonAPressed -.leftPressed - ld a,[wListScrollOffset] - sub a,7 - ld [wListScrollOffset],a - jp nc,.loop - xor a - ld [wListScrollOffset],a - jp .loop -.buttonAPressed - scf - ret -.buttonBPressed - and a - ret - -DrawPokedexVerticalLine: ; 4028e (10:428e) - ld c,9 ; height of line - ld de,20 ; width of screen - ld a,$71 ; vertical line tile -.loop - ld [hl],a - add hl,de - xor a,1 ; toggle between vertical line tile and box tile - dec c - jr nz,.loop - ret - -PokedexSeenText: ; 4029d (10:429d) - db "SEEN@" - -PokedexOwnText: ; 402a2 (10:42a2) - db "OWN@" - -PokedexContentsText: ; 402a6 (10:42a6) - db "CONTENTS@" - -PokedexMenuItemsText: ; 402af (10:42af) - db "DATA" - next "CRY" - next "AREA" - next "QUIT@" - -; tests if a pokemon's bit is set in the seen or owned pokemon bit fields -; INPUT: -; [wd11e] = pokedex number -; hl = address of bit field -IsPokemonBitSet: ; 402c2 (10:42c2) - ld a,[wd11e] - dec a - ld c,a - ld b,2 - predef FlagActionPredef - ld a,c - and a - ret - -; function to display pokedex data from outside the pokedex -ShowPokedexData: ; 402d1 (10:42d1) - call GBPalWhiteOutWithDelay3 - call ClearScreen - call UpdateSprites - callab LoadPokedexTilePatterns ; load pokedex tiles - -; function to display pokedex data from inside the pokedex -ShowPokedexDataInternal: ; 402e2 (10:42e2) - ld hl,wd72c - set 1,[hl] - ld a,$33 ; 3/7 volume - ld [$ff24],a - call GBPalWhiteOut ; zero all palettes - call ClearScreen - ld a,[wd11e] ; pokemon ID - ld [wcf91],a - push af - ld b,04 - call GoPAL_SET - pop af - ld [wd11e],a - ld a,[hTilesetType] - push af - xor a - ld [hTilesetType],a - hlCoord 0, 0 - ld de,1 - ld bc,$6414 - call DrawTileLine ; draw top border - hlCoord 0, 17 - ld b,$6f - call DrawTileLine ; draw bottom border - hlCoord 0, 1 - ld de,20 - ld bc,$6610 - call DrawTileLine ; draw left border - hlCoord 19, 1 - ld b,$67 - call DrawTileLine ; draw right border - ld a,$63 ; upper left corner tile - Coorda 0, 0 - ld a,$65 ; upper right corner tile - Coorda 19, 0 - ld a,$6c ; lower left corner tile - Coorda 0, 17 - ld a,$6e ; lower right corner tile - Coorda 19, 17 - hlCoord 0, 9 - ld de,PokedexDataDividerLine - call PlaceString ; draw horizontal divider line - hlCoord 9, 6 - ld de,HeightWeightText - call PlaceString - call GetMonName - hlCoord 9, 2 - call PlaceString - ld hl,PokedexEntryPointers - ld a,[wd11e] - dec a - ld e,a - ld d,0 - add hl,de - add hl,de - ld a,[hli] - ld e,a - ld d,[hl] ; de = address of pokedex entry - hlCoord 9, 4 - call PlaceString ; print species name - ld h,b - ld l,c - push de - ld a,[wd11e] - push af - call IndexToPokedex - hlCoord 2, 8 - ld a, "№" - ld [hli],a - ld a,$f2 - ld [hli],a - ld de,wd11e - ld bc,$8103 - call PrintNumber ; print pokedex number - ld hl,wPokedexOwned - call IsPokemonBitSet - pop af - ld [wd11e],a - ld a,[wcf91] - ld [wd0b5],a - pop de - push af - push bc - push de - push hl - call Delay3 - call GBPalNormal - call GetMonHeader ; load pokemon picture location - hlCoord 1, 1 - call LoadFlippedFrontSpriteByMonIndex ; draw pokemon picture - ld a,[wcf91] - call PlayCry ; play pokemon cry - pop hl - pop de - pop bc - pop af - ld a,c - and a - jp z,.waitForButtonPress ; if the pokemon has not been owned, don't print the height, weight, or description - inc de ; de = address of feet (height) - ld a,[de] ; reads feet, but a is overwritten without being used - hlCoord 12, 6 - ld bc,$0102 - call PrintNumber ; print feet (height) - ld a,$60 ; feet symbol tile (one tick) - ld [hl],a - inc de - inc de ; de = address of inches (height) - hlCoord 15, 6 - ld bc,$8102 - call PrintNumber ; print inches (height) - ld a,$61 ; inches symbol tile (two ticks) - ld [hl],a -; now print the weight (note that weight is stored in tenths of pounds internally) - inc de - inc de - inc de ; de = address of upper byte of weight - push de -; put weight in big-endian order at $ff8b - ld hl,$ff8b - ld a,[hl] ; save existing value of [$ff8b] - push af - ld a,[de] ; a = upper byte of weight - ld [hli],a ; store upper byte of weight in [$ff8b] - ld a,[hl] ; save existing value of [$ff8c] - push af - dec de - ld a,[de] ; a = lower byte of weight - ld [hl],a ; store lower byte of weight in [$ff8c] - ld de,$ff8b - hlCoord 11, 8 - ld bc,$0205 ; no leading zeroes, right-aligned, 2 bytes, 5 digits - call PrintNumber ; print weight - hlCoord 14, 8 - ld a,[$ff8c] - sub a,10 - ld a,[$ff8b] - sbc a,0 - jr nc,.next - ld [hl],"0" ; if the weight is less than 10, put a 0 before the decimal point -.next - inc hl - ld a,[hli] - ld [hld],a ; make space for the decimal point by moving the last digit forward one tile - ld [hl],$f2 ; decimal point tile - pop af - ld [$ff8c],a ; restore original value of [$ff8c] - pop af - ld [$ff8b],a ; restore original value of [$ff8b] - pop hl - inc hl ; hl = address of pokedex description text - bcCoord 1, 11 - ld a,2 - ld [$fff4],a - call TextCommandProcessor ; print pokedex description text - xor a - ld [$fff4],a -.waitForButtonPress - call JoypadLowSensitivity - ld a,[hJoy5] - and a,%00000011 ; A button and B button - jr z,.waitForButtonPress - pop af - ld [hTilesetType],a - call GBPalWhiteOut - call ClearScreen - call GoPAL_SET_CF1C - call LoadTextBoxTilePatterns - call GBPalNormal - ld hl,wd72c - res 1,[hl] - ld a,$77 ; max volume - ld [$ff24],a - ret - -HeightWeightText: ; 40448 (10:4448) - db "HT ?",$60,"??",$61,$4E,"WT ???lb@" - -; XXX does anything point to this? -Unknown_4045D: ; 4045d (10:445d) - db $54,$50 - -; horizontal line that divides the pokedex text description from the rest of the data -PokedexDataDividerLine: ; 4045f (10:445f) - db $68,$69,$6B,$69,$6B - db $69,$6B,$69,$6B,$6B - db $6B,$6B,$69,$6B,$69 - db $6B,$69,$6B,$69,$6A - db $50 - -; draws a line of tiles -; INPUT: -; b = tile ID -; c = number of tile ID's to write -; de = amount to destination address after each tile (1 for horizontal, 20 for vertical) -; hl = destination address -DrawTileLine: ; 40474 (10:4474) - push bc - push de -.loop - ld [hl],b - add hl,de - dec c - jr nz,.loop - pop de - pop bc - ret - -INCLUDE "data/pokedex_entries.asm" - -PokedexToIndex: ; 40ff9 (10:4ff9) - ; converts the Pokédex number at wd11e to an index - push bc - push hl - ld a,[wd11e] - ld b,a - ld c,0 - ld hl,PokedexOrder - -.loop ; go through the list until we find an entry with a matching dex number - inc c - ld a,[hli] - cp b - jr nz,.loop - - ld a,c - ld [wd11e],a - pop hl - pop bc - ret - -IndexToPokedex: ; 41010 (10:5010) - ; converts the indexédex number at wd11e to a Pokédex number - push bc - push hl - ld a,[wd11e] - dec a - ld hl,PokedexOrder - ld b,0 - ld c,a - add hl,bc - ld a,[hl] - ld [wd11e],a - pop hl - pop bc - ret - -INCLUDE "data/pokedex_order.asm" diff --git a/engine/town_map.asm.orig b/engine/town_map.asm.orig deleted file mode 100755 index 9ccc03c0e7..0000000000 --- a/engine/town_map.asm.orig +++ /dev/null @@ -1,605 +0,0 @@ -DisplayTownMap: ; 70e3e (1c:4e3e) - call LoadTownMap - ld hl, wUpdateSpritesEnabled - ld a, [hl] - push af - ld [hl], $ff - push hl - ld a, $1 - ld [hJoy7], a - ld a, [W_CURMAP] ; W_CURMAP - push af - ld b, $0 - call Func_711c4 - hlCoord 1, 0 - ld de, wcd6d - call PlaceString - ld hl, wOAMBuffer - ld de, wTileMapBackup - ld bc, $10 - call CopyData - ld hl, vSprites + $40 - ld de, TownMapCursor ; $4f40 - ld bc, (BANK(TownMapCursor) << 8) + $04 - call CopyVideoDataDouble - xor a - ld [wWhichTrade], a ; wWhichTrade - pop af - jr Func_70e92 - -Func_70e7e: ; 70e7e (1c:4e7e) - ld hl, wTileMap - ld bc, $114 - call ClearScreenArea - ld hl, TownMapOrder ; $4f11 - ld a, [wWhichTrade] ; wWhichTrade - ld c, a - ld b, $0 - add hl, bc - ld a, [hl] - -Func_70e92: ; 70e92 (1c:4e92) - ld de, wHPBarMaxHP - call Func_712f1 - ld a, [de] - push hl - call Func_71258 - ld a, $4 - ld [wcd5b], a - ld hl, wOAMBuffer + $10 - call Func_71279 - pop hl - ld de, wcd6d -.asm_70eac - ld a, [hli] - ld [de], a - inc de - cp $50 - jr nz, .asm_70eac - hlCoord 1, 0 - ld de, wcd6d - call PlaceString - ld hl, wOAMBuffer + $10 - ld de, wTileMapBackup + 16 - ld bc, $10 - call CopyData -.asm_70ec8 - call TownMapSpriteBlinkingAnimation - call JoypadLowSensitivity - ld a, [hJoy5] - ld b, a - and $c3 - jr z, .asm_70ec8 - ld a, (SFX_02_3c - SFX_Headers_02) / 3 - call PlaySound - bit 6, b - jr nz, .asm_70ef2 - bit 7, b - jr nz, .asm_70f01 - xor a -<<<<<<< HEAD - ld [wd09b], a - ld [hJoy7], a - ld [W_SUBANIMTRANSFORM], a ; W_SUBANIMTRANSFORM -======= - ld [wTownMapSpriteBlinkingEnabled], a - ld [$ffb7], a - ld [wTownMapSpriteBlinkingCounter], a ->>>>>>> yama/master - call Func_711ab - pop hl - pop af - ld [hl], a - ret -.asm_70ef2 - ld a, [wWhichTrade] ; wWhichTrade - inc a - cp $2f - jr nz, .asm_70efb - xor a -.asm_70efb - ld [wWhichTrade], a ; wWhichTrade - jp Func_70e7e -.asm_70f01 - ld a, [wWhichTrade] ; wWhichTrade - dec a - cp $ff - jr nz, .asm_70f0b - ld a, $2e -.asm_70f0b - ld [wWhichTrade], a ; wWhichTrade - jp Func_70e7e - -INCLUDE "data/town_map_order.asm" - -TownMapCursor: ; 70f40 (1c:4f40) - INCBIN "gfx/town_map_cursor.1bpp" - -LoadTownMap_Nest: ; 70f60 (1c:4f60) - call LoadTownMap - ld hl, wUpdateSpritesEnabled - ld a, [hl] - push af - ld [hl], $ff - push hl - call Func_711ef - call GetMonName - hlCoord 1, 0 - call PlaceString - ld h, b - ld l, c - ld de, MonsNestText - call PlaceString - call WaitForTextScrollButtonPress - call Func_711ab - pop hl - pop af - ld [hl], a - ret - -MonsNestText: ; 70f89 (1c:4f89) - db "'s NEST@" - -LoadTownMap_Fly: ; 70f90 (1c:4f90) - call ClearSprites - call LoadTownMap - call LoadPlayerSpriteGraphics - call LoadFontTilePatterns - ld de, BirdSprite ; $4d80 - ld hl, vSprites + $40 - ld bc, (BANK(BirdSprite) << 8) + $0c - call CopyVideoData - ld de, TownMapUpArrow ; $5093 - ld hl, vChars1 + $6d0 - ld bc, (BANK(TownMapUpArrow) << 8) + $01 - call CopyVideoDataDouble - call Func_71070 - ld hl, wUpdateSpritesEnabled - ld a, [hl] - push af - ld [hl], $ff - push hl - ld hl, wTileMap - ld de, ToText - call PlaceString - ld a, [W_CURMAP] ; W_CURMAP - ld b, $0 - call Func_711c4 - ld hl, wTrainerEngageDistance - deCoord 18, 0 - -.townMapFlyLoop - ld a, $7f - ld [de], a - push hl - push hl - hlCoord 3, 0 - ld bc, $10f - call ClearScreenArea - pop hl - ld a, [hl] - ld b, $4 - call Func_711c4 - hlCoord 3, 0 - ld de, wcd6d - call PlaceString - ld c, $f - call DelayFrames - hlCoord 18, 0 - ld [hl], $ed - hlCoord 19, 0 - ld [hl], $ee - pop hl -.asm_71004 - push hl - call DelayFrame - call JoypadLowSensitivity - ld a, [hJoy5] - ld b, a - pop hl - and $c3 - jr z, .asm_71004 - bit 0, b - jr nz, .asm_71026 - ld a, (SFX_02_3c - SFX_Headers_02) / 3 - call PlaySound - bit 6, b - jr nz, .asm_71042 - bit 7, b - jr nz, .asm_71058 - jr .asm_71037 -.asm_71026 - ld a, (SFX_02_3e - SFX_Headers_02) / 3 - call PlaySound - ld a, [hl] - ld [wDestinationMap], a - ld hl, wd732 - set 3, [hl] - inc hl - set 7, [hl] -.asm_71037 - xor a - ld [wTownMapSpriteBlinkingEnabled], a - call GBPalWhiteOutWithDelay3 - pop hl - pop af - ld [hl], a - ret -.asm_71042 - deCoord 18, 0 - inc hl - ld a, [hl] - cp $ff - jr z, .asm_71052 - cp $fe - jr z, .asm_71042 - jp .townMapFlyLoop -.asm_71052 - ld hl, wTrainerEngageDistance - jp .townMapFlyLoop -.asm_71058 - deCoord 19, 0 - dec hl - ld a, [hl] - cp $ff - jr z, .asm_71068 - cp $fe - jr z, .asm_71058 - jp .townMapFlyLoop -.asm_71068 - ld hl, wcd49 - jr .asm_71058 - -ToText: ; 7106d (1c:506d) - db "To@" - -Func_71070: ; 71070 (1c:5070) - ld hl, wWhichTrade ; wWhichTrade - ld [hl], $ff - inc hl - ld a, [W_TOWNVISITEDFLAG] - ld e, a - ld a, [W_TOWNVISITEDFLAG + 1] - ld d, a - ld bc, $b -.asm_71081 - srl d - rr e - ld a, $fe - jr nc, .asm_7108a - ld a, b -.asm_7108a - ld [hl], a - inc hl - inc b - dec c - jr nz, .asm_71081 - ld [hl], $ff - ret - -TownMapUpArrow: ; 71093 (1c:5093) - INCBIN "gfx/up_arrow.1bpp" - -LoadTownMap: ; 7109b (1c:509b) - call GBPalWhiteOutWithDelay3 - call ClearScreen - call UpdateSprites - ld hl, wTileMap - ld b, $12 - ld c, $12 - call TextBoxBorder - call DisableLCD - ld hl, WorldMapTileGraphics ; $65a8 - ld de, vChars2 + $600 - ld bc, $100 - ld a, BANK(WorldMapTileGraphics) - call FarCopyData2 - ld hl, MonNestIcon ; $56be - ld de, vSprites + $40 - ld bc, $8 - ld a, BANK(MonNestIcon) - call FarCopyDataDouble - ld hl, wTileMap - ld de, CompressedMap ; $5100 -.asm_710d3 - ld a, [de] - and a - jr z, .asm_710e9 - ld b, a - and $f - ld c, a - ld a, b - swap a - and $f - add $60 -.asm_710e2 - ld [hli], a - dec c - jr nz, .asm_710e2 - inc de - jr .asm_710d3 -.asm_710e9 - call EnableLCD - ld b, $2 - call GoPAL_SET - call Delay3 - call GBPalNormal - xor a - ld [wTownMapSpriteBlinkingCounter], a - inc a - ld [wTownMapSpriteBlinkingEnabled], a - ret - -CompressedMap: ; 71100 (1c:5100) -; you can decompress this file with the redrle program in the extras/ dir - INCBIN "gfx/town_map.rle" - -Func_711ab: ; 711ab (1c:51ab) - xor a - ld [wTownMapSpriteBlinkingEnabled], a - call GBPalWhiteOut - call ClearScreen - call ClearSprites - call LoadPlayerSpriteGraphics - call LoadFontTilePatterns - call UpdateSprites - jp GoPAL_SET_CF1C - -Func_711c4: ; 711c4 (1c:51c4) - push af - ld a, b - ld [wcd5b], a - pop af - ld de, wHPBarMaxHP - call Func_712f1 - ld a, [de] - push hl - call Func_71258 - call Func_7126d - pop hl - ld de, wcd6d -.asm_711dc - ld a, [hli] - ld [de], a - inc de - cp $50 - jr nz, .asm_711dc - ld hl, wOAMBuffer - ld de, wTileMapBackup - ld bc, $a0 - jp CopyData - -Func_711ef: ; 711ef (1c:51ef) - callba Func_e9cb - call Func_712d9 - ld hl, wOAMBuffer - ld de, wHPBarMaxHP -.asm_71200 - ld a, [de] - cp $ff - jr z, .asm_7121d - and a - jr z, .asm_7121a - push hl - call Func_712f1 - pop hl - ld a, [de] - cp $19 - jr z, .asm_7121a - call Func_71258 - ld a, $4 - ld [hli], a - xor a - ld [hli], a -.asm_7121a - inc de - jr .asm_71200 -.asm_7121d - ld a, l - and a - jr nz, .asm_71236 - hlCoord 1, 7 - ld b, $2 - ld c, $f - call TextBoxBorder - hlCoord 2, 9 - ld de, AreaUnknownText - call PlaceString - jr .asm_7123e -.asm_71236 - ld a, [W_CURMAP] ; W_CURMAP - ld b, $0 - call Func_711c4 -.asm_7123e - ld hl, wOAMBuffer - ld de, wTileMapBackup - ld bc, $a0 - jp CopyData - -AreaUnknownText: ; 7124a (1c:524a) - db " AREA UNKNOWN@" - -Func_71258: ; 71258 (1c:5258) - push af - and $f0 - srl a - add $18 - ld b, a - ld [hli], a - pop af - and $f - swap a - srl a - add $18 - ld c, a - ld [hli], a - ret - -Func_7126d: ; 7126d (1c:526d) - ld a, [wcd5b] - and a - ld hl, wOAMBuffer + $90 - jr z, Func_71279 - ld hl, wOAMBuffer + $80 - -Func_71279: ; 71279 (1c:5279) - push hl - ld hl, $fcfc - add hl, bc - ld b, h - ld c, l - pop hl - -Func_71281: ; 71281 (1c:5281) - ld de, $202 -.asm_71284 - push de - push bc -.asm_71286 - ld a, b - ld [hli], a - ld a, c - ld [hli], a - ld a, [wcd5b] - ld [hli], a - inc a - ld [wcd5b], a - xor a - ld [hli], a - inc d - ld a, $8 - add c - ld c, a - dec e - jr nz, .asm_71286 - pop bc - pop de - ld a, $8 - add b - ld b, a - dec d - jr nz, .asm_71284 - ret - -Func_712a6: ; 712a6 (1c:52a6) - xor a - ld [wcd5c], a - ld de, $202 -.asm_712ad - push de - push bc -.asm_712af - ld a, b - ld [hli], a - ld a, c - ld [hli], a - ld a, [wcd5b] - ld [hli], a - ld a, [wcd5c] - ld [hli], a - xor $20 - ld [wcd5c], a - inc d - ld a, $8 - add c - ld c, a - dec e - jr nz, .asm_712af - pop bc - pop de - push hl - ld hl, wcd5b - inc [hl] - inc [hl] - pop hl - ld a, $8 - add b - ld b, a - dec d - jr nz, .asm_712ad - ret - -Func_712d9: ; 712d9 (1c:52d9) - ld de, wHPBarMaxHP -.asm_712dc - ld a, [de] - inc de - cp $ff - ret z - ld c, a - ld l, e - ld h, d -.asm_712e4 - ld a, [hl] - cp $ff - jr z, .asm_712dc - cp c - jr nz, .asm_712ee - xor a - ld [hl], a -.asm_712ee - inc hl - jr .asm_712e4 - -Func_712f1: ; 712f1 (1c:52f1) - cp REDS_HOUSE_1F - jr c, .asm_71304 - ld bc, $4 - ld hl, InternalMapEntries ; $5382 -.asm_712fb - cp [hl] - jr c, .asm_71301 - add hl, bc - jr .asm_712fb -.asm_71301 - inc hl - jr .asm_7130d -.asm_71304 - ld hl, ExternalMapEntries ; $5313 - ld c, a - ld b, $0 - add hl, bc - add hl, bc - add hl, bc -.asm_7130d - ld a, [hli] - ld [de], a - ld a, [hli] - ld h, [hl] - ld l, a - ret - -INCLUDE "data/town_map_entries.asm" - -INCLUDE "text/map_names.asm" - -MonNestIcon: ; 716be (1c:56be) - INCBIN "gfx/mon_nest_icon.1bpp" - -TownMapSpriteBlinkingAnimation: ; 716c6 (1c:56c6) - ld a, [wTownMapSpriteBlinkingCounter] - inc a - cp 25 - jr z, .hideSprites - cp 50 - jr nz, .done -; show sprites when the counter reaches 50 - ld hl, wTileMapBackup - ld de, wOAMBuffer - ld bc, $90 - call CopyData - xor a - jr .done -.hideSprites - ld hl, wOAMBuffer - ld b, $24 - ld de, $4 -.hideSpritesLoop - ld [hl], $a0 - add hl, de - dec b - jr nz, .hideSpritesLoop - ld a, 25 -.done - ld [wTownMapSpriteBlinkingCounter], a - jp DelayFrame From de39851f4a06da54856b1da36edf92e3ab9fb9cc Mon Sep 17 00:00:00 2001 From: "U-Daniel-PC\\Daniel" Date: Thu, 25 Sep 2014 19:21:49 -0400 Subject: [PATCH 031/100] Make Hide/Show objects more dynamic be on the look out for more static ids in the wild unused constants are still included because a script could be written to check whether the player has picked up an item/fought a legendary etc. --- constants.asm | 1 + constants/hide_show_constants.asm | 234 ++++++++++++++++++++++++++++++ scripts/billshouse.asm | 8 +- scripts/blueshouse.asm | 2 +- scripts/celadongamecorner.asm | 2 +- scripts/celadonmansion5.asm | 2 +- scripts/ceruleancity.asm | 6 +- scripts/ceruleancity2.asm | 6 +- scripts/fightingdojo.asm | 4 +- scripts/gary.asm | 4 +- scripts/halloffameroom.asm | 2 +- scripts/mtmoon3.asm | 8 +- scripts/museum1f.asm | 2 +- scripts/oakslab.asm | 34 ++--- scripts/pallettown.asm | 6 +- scripts/pewtercity.asm | 8 +- scripts/pewtergym.asm | 4 +- scripts/pokemontower2.asm | 2 +- scripts/pokemontower7.asm | 8 +- scripts/rockethideout4.asm | 6 +- scripts/route12.asm | 2 +- scripts/route16.asm | 2 +- scripts/route20.asm | 8 +- scripts/route22.asm | 4 +- scripts/route23.asm | 4 +- scripts/route25.asm | 8 +- scripts/seafoamislands1.asm | 8 +- scripts/seafoamislands2.asm | 8 +- scripts/seafoamislands3.asm | 8 +- scripts/seafoamislands4.asm | 8 +- scripts/silphco1.asm | 2 +- scripts/silphco11.asm | 53 ++++++- scripts/silphco7.asm | 2 +- scripts/ssanne2.asm | 4 +- scripts/victoryroad3.asm | 4 +- scripts/viridiangym.asm | 4 +- 36 files changed, 377 insertions(+), 101 deletions(-) create mode 100755 constants/hide_show_constants.asm diff --git a/constants.asm b/constants.asm index b427e3c705..d92dfb95c1 100644 --- a/constants.asm +++ b/constants.asm @@ -27,6 +27,7 @@ INCLUDE "constants/list_constants.asm" INCLUDE "constants/map_constants.asm" INCLUDE "constants/map_dimensions.asm" INCLUDE "constants/connection_constants.asm" +INCLUDE "constants/hide_show_constants.asm" INCLUDE "constants/credits_constants.asm" INCLUDE "constants/music_constants.asm" INCLUDE "constants/tilesets.asm" diff --git a/constants/hide_show_constants.asm b/constants/hide_show_constants.asm new file mode 100755 index 0000000000..c5bcf76312 --- /dev/null +++ b/constants/hide_show_constants.asm @@ -0,0 +1,234 @@ +; this is a list of the sprites that can be enabled/disabled during the game +; sprites marked with an X are constants that are never used +; because those sprites are not (de)activated in a map's script +; (they are either items or sprites that deactivate after battle +; and are detected in W_MISSABLEOBJECTLIST) + +HS_PALLET_TOWN_OAK EQU $00 +HS_LYING_OLD_MAN EQU $01 +HS_OLD_MAN EQU $02 +HS_MUSEUM_GUY EQU $03 +HS_GYM_GUY EQU $04 +HS_CERULEAN_RIVAL EQU $05 +HS_CERULEAN_ROCKET EQU $06 +HS_CERULEAN_GUARD_1 EQU $07 +HS_UNKNOWN_DUNGEON_GUY EQU $08 +HS_CERULEAN_GUARD_2 EQU $09 +HS_SAFFRON_CITY_1 EQU $0A +HS_SAFFRON_CITY_2 EQU $0B +HS_SAFFRON_CITY_3 EQU $0C +HS_SAFFRON_CITY_4 EQU $0D +HS_SAFFRON_CITY_5 EQU $0E +HS_SAFFRON_CITY_6 EQU $0F +HS_SAFFRON_CITY_7 EQU $10 +HS_SAFFRON_CITY_8 EQU $11 +HS_SAFFRON_CITY_9 EQU $12 +HS_SAFFRON_CITY_A EQU $13 +HS_SAFFRON_CITY_B EQU $14 +HS_SAFFRON_CITY_C EQU $15 +HS_SAFFRON_CITY_D EQU $16 +HS_SAFFRON_CITY_E EQU $17 +HS_SAFFRON_CITY_F EQU $18 +HS_ROUTE_2_ITEM_1 EQU $19 ; X +HS_ROUTE_2_ITEM_2 EQU $1A ; X +HS_ROUTE_4_ITEM EQU $1B ; X +HS_ROUTE_9_ITEM EQU $1C ; X +HS_ROUTE_12_SNORLAX EQU $1D +HS_ROUTE_12_ITEM_1 EQU $1E ; X +HS_ROUTE_12_ITEM_2 EQU $1F ; X +HS_ROUTE_15_ITEM EQU $20 ; X +HS_ROUTE_16_SNORLAX EQU $21 +HS_ROUTE_22_RIVAL_1 EQU $22 +HS_ROUTE_22_RIVAL_2 EQU $23 +HS_NUGGET_BRIDGE_GUY EQU $24 +HS_ROUTE_24_ITEM EQU $25 ; X +HS_ROUTE_25_ITEM EQU $26 ; X +HS_DAISY_SITTING EQU $27 +HS_DAISY_WALKING EQU $28 +HS_TOWN_MAP EQU $29 +HS_OAKS_LAB_RIVAL EQU $2A +HS_STARTER_BALL_1 EQU $2B +HS_STARTER_BALL_2 EQU $2C +HS_STARTER_BALL_3 EQU $2D +HS_OAKS_LAB_OAK_1 EQU $2E +HS_POKEDEX_1 EQU $2F +HS_POKEDEX_2 EQU $30 +HS_OAKS_LAB_OAK_2 EQU $31 +HS_VIRIDIAN_GYM_GIOVANNI EQU $32 +HS_VIRIDIAN_GYM_ITEM EQU $33 ; X +HS_OLD_AMBER EQU $34 +HS_UNKNOWN_DUNGEON_1_ITEM_1 EQU $35 ; X +HS_UNKNOWN_DUNGEON_1_ITEM_2 EQU $36 ; X +HS_UNKNOWN_DUNGEON_1_ITEM_3 EQU $37 ; X +HS_POKEMONTOWER_2_RIVAL EQU $38 +HS_POKEMONTOWER_3_ITEM EQU $39 ; X +HS_POKEMONTOWER_4_ITEM_1 EQU $3A ; X +HS_POKEMONTOWER_4_ITEM_2 EQU $3B ; X +HS_POKEMONTOWER_4_ITEM_3 EQU $3C ; X +HS_POKEMONTOWER_5_ITEM EQU $3D ; X +HS_POKEMONTOWER_6_ITEM_1 EQU $3E ; X +HS_POKEMONTOWER_6_ITEM_2 EQU $3F ; X +HS_POKEMONTOWER_7_ROCKET_1 EQU $40 ; X +HS_POKEMONTOWER_7_ROCKET_2 EQU $41 ; X +HS_POKEMONTOWER_7_ROCKET_3 EQU $42 ; X +HS_POKEMONTOWER_7_MR_FUJI EQU $43 +HS_LAVENDER_HOUSE_1_MR_FUJI EQU $44 +HS_CELADON_MANSION_5_GIFT EQU $45 +HS_GAME_CORNER_ROCKET EQU $46 +HS_FUCHSIA_HOUSE_2_ITEM EQU $47 ; X +HS_MANSION_1_ITEM_1 EQU $48 ; X +HS_MANSION_1_ITEM_2 EQU $49 ; X +HS_FIGHTING_DOJO_GIFT_1 EQU $4A +HS_FIGHTING_DOJO_GIFT_2 EQU $4B +HS_SILPH_CO_1F_1 EQU $4C +HS_VOLTORB_1 EQU $4D ; X +HS_VOLTORB_2 EQU $4E ; X +HS_VOLTORB_3 EQU $4F ; X +HS_ELECTRODE_1 EQU $50 ; X +HS_VOLTORB_4 EQU $51 ; X +HS_VOLTORB_5 EQU $52 ; X +HS_ELECTRODE_2 EQU $53 ; X +HS_VOLTORB_6 EQU $54 ; X +HS_ZAPDOS EQU $55 ; X +HS_POWER_PLANT_ITEM_1 EQU $56 ; X +HS_POWER_PLANT_ITEM_2 EQU $57 ; X +HS_POWER_PLANT_ITEM_3 EQU $58 ; X +HS_POWER_PLANT_ITEM_4 EQU $59 ; X +HS_POWER_PLANT_ITEM_5 EQU $5A ; X +HS_MOLTRES EQU $5B ; X +HS_VICTORY_ROAD_2_ITEM_1 EQU $5C ; X +HS_VICTORY_ROAD_2_ITEM_2 EQU $5D ; X +HS_VICTORY_ROAD_2_ITEM_3 EQU $5E ; X +HS_VICTORY_ROAD_2_ITEM_4 EQU $5F ; X +HS_VICTORY_ROAD_2_BOULDER EQU $60 +HS_BILL_POKEMON EQU $61 +HS_BILL_1 EQU $62 +HS_BILL_2 EQU $63 +HS_VIRIDIAN_FOREST_ITEM_1 EQU $64 ; X +HS_VIRIDIAN_FOREST_ITEM_2 EQU $65 ; X +HS_VIRIDIAN_FOREST_ITEM_3 EQU $66 ; X +HS_MT_MOON_1_ITEM_1 EQU $67 ; X +HS_MT_MOON_1_ITEM_2 EQU $68 ; X +HS_MT_MOON_1_ITEM_3 EQU $69 ; X +HS_MT_MOON_1_ITEM_4 EQU $6A ; X +HS_MT_MOON_1_ITEM_5 EQU $6B ; X +HS_MT_MOON_1_ITEM_6 EQU $6C ; X +HS_MT_MOON_3_FOSSIL_1 EQU $6D +HS_MT_MOON_3_FOSSIL_2 EQU $6E +HS_MT_MOON_3_ITEM_1 EQU $6F ; X +HS_MT_MOON_3_ITEM_2 EQU $70 ; X +HS_SS_ANNE_2_RIVAL EQU $71 +HS_SS_ANNE_8_ITEM EQU $72 ; X +HS_SS_ANNE_9_ITEM_1 EQU $73 ; X +HS_SS_ANNE_9_ITEM_2 EQU $74 ; X +HS_SS_ANNE_10_ITEM_1 EQU $75 ; X +HS_SS_ANNE_10_ITEM_2 EQU $76 ; X +HS_SS_ANNE_10_ITEM_3 EQU $77 ; X +HS_VICTORY_ROAD_3_ITEM_1 EQU $78 ; X +HS_VICTORY_ROAD_3_ITEM_2 EQU $79 ; X +HS_VICTORY_ROAD_3_BOULDER EQU $7A +HS_ROCKET_HIDEOUT_1_ITEM_1 EQU $7B ; X +HS_ROCKET_HIDEOUT_1_ITEM_2 EQU $7C ; X +HS_ROCKET_HIDEOUT_2_ITEM_1 EQU $7D ; X +HS_ROCKET_HIDEOUT_2_ITEM_2 EQU $7E ; X +HS_ROCKET_HIDEOUT_2_ITEM_3 EQU $7F ; X +HS_ROCKET_HIDEOUT_2_ITEM_4 EQU $80 ; X +HS_ROCKET_HIDEOUT_3_ITEM_1 EQU $81 ; X +HS_ROCKET_HIDEOUT_3_ITEM_2 EQU $82 ; X +HS_ROCKET_HIDEOUT_4_GIOVANNI EQU $83 +HS_ROCKET_HIDEOUT_4_ITEM_1 EQU $84 ; X +HS_ROCKET_HIDEOUT_4_ITEM_2 EQU $85 ; X +HS_ROCKET_HIDEOUT_4_ITEM_3 EQU $86 ; X +HS_ROCKET_HIDEOUT_4_ITEM_4 EQU $87 +HS_ROCKET_HIDEOUT_4_ITEM_5 EQU $88 +HS_SILPH_CO_2F_1 EQU $89 ; XXX never (de)activated? +HS_SILPH_CO_2F_2 EQU $8A +HS_SILPH_CO_2F_3 EQU $8B +HS_SILPH_CO_2F_4 EQU $8C +HS_SILPH_CO_2F_5 EQU $8D +HS_SILPH_CO_3F_1 EQU $8E +HS_SILPH_CO_3F_2 EQU $8F +HS_SILPH_CO_3F_3 EQU $90 ; X +HS_SILPH_CO_4F_1 EQU $91 +HS_SILPH_CO_4F_2 EQU $92 +HS_SILPH_CO_4F_3 EQU $93 +HS_SILPH_CO_4F_4 EQU $94 ; X +HS_SILPH_CO_4F_5 EQU $95 ; X +HS_SILPH_CO_4F_6 EQU $96 ; X +HS_SILPH_CO_5F_1 EQU $97 +HS_SILPH_CO_5F_2 EQU $98 +HS_SILPH_CO_5F_3 EQU $99 +HS_SILPH_CO_5F_4 EQU $9A +HS_SILPH_CO_5F_5 EQU $9B ; X +HS_SILPH_CO_5F_6 EQU $9C ; X +HS_SILPH_CO_5F_7 EQU $9D ; X +HS_SILPH_CO_6F_1 EQU $9E +HS_SILPH_CO_6F_2 EQU $9F +HS_SILPH_CO_6F_3 EQU $A0 +HS_SILPH_CO_6F_4 EQU $A1 ; X +HS_SILPH_CO_6F_5 EQU $A2 ; X +HS_SILPH_CO_7F_1 EQU $A3 +HS_SILPH_CO_7F_2 EQU $A4 +HS_SILPH_CO_7F_3 EQU $A5 +HS_SILPH_CO_7F_4 EQU $A6 +HS_SILPH_CO_7F_5 EQU $A7 +HS_SILPH_CO_7F_6 EQU $A8 ; X +HS_SILPH_CO_7F_7 EQU $A9 ; X +HS_SILPH_CO_7F_8 EQU $AA ; X +HS_SILPH_CO_8F_1 EQU $AB +HS_SILPH_CO_8F_2 EQU $AC +HS_SILPH_CO_8F_3 EQU $AD +HS_SILPH_CO_9F_1 EQU $AE +HS_SILPH_CO_9F_2 EQU $AF +HS_SILPH_CO_9F_3 EQU $B0 +HS_SILPH_CO_10F_1 EQU $B1 +HS_SILPH_CO_10F_2 EQU $B2 +HS_SILPH_CO_10F_3 EQU $B3 ; X +HS_SILPH_CO_10F_4 EQU $B4 ; X +HS_SILPH_CO_10F_5 EQU $B5 ; X +HS_SILPH_CO_10F_6 EQU $B6 ; X +HS_SILPH_CO_11F_1 EQU $B7 +HS_SILPH_CO_11F_2 EQU $B8 +HS_SILPH_CO_11F_3 EQU $B9 +;HS_MAP_F4_1 EQU $BA +HS_MANSION_2_ITEM EQU $BB ; X +HS_MANSION_3_ITEM_1 EQU $BC ; X +HS_MANSION_3_ITEM_2 EQU $BD ; X +HS_MANSION_4_ITEM_1 EQU $BE ; X +HS_MANSION_4_ITEM_2 EQU $BF ; X +HS_MANSION_4_ITEM_3 EQU $C0 ; X +HS_MANSION_4_ITEM_4 EQU $C1 ; X +HS_MANSION_4_ITEM_5 EQU $C2 ; X +HS_SAFARI_ZONE_EAST_ITEM_1 EQU $C3 ; X +HS_SAFARI_ZONE_EAST_ITEM_2 EQU $C4 ; X +HS_SAFARI_ZONE_EAST_ITEM_3 EQU $C5 ; X +HS_SAFARI_ZONE_EAST_ITEM_4 EQU $C6 ; X +HS_SAFARI_ZONE_NORTH_ITEM_1 EQU $C7 ; X +HS_SAFARI_ZONE_NORTH_ITEM_2 EQU $C8 ; X +HS_SAFARI_ZONE_WEST_ITEM_1 EQU $C9 ; X +HS_SAFARI_ZONE_WEST_ITEM_2 EQU $CA ; X +HS_SAFARI_ZONE_WEST_ITEM_3 EQU $CB ; X +HS_SAFARI_ZONE_WEST_ITEM_4 EQU $CC ; X +HS_SAFARI_ZONE_CENTER_ITEM EQU $CD ; X +HS_UNKNOWN_DUNGEON_2_ITEM_1 EQU $CE ; X +HS_UNKNOWN_DUNGEON_2_ITEM_2 EQU $CF ; X +HS_UNKNOWN_DUNGEON_2_ITEM_3 EQU $D0 ; X +HS_MEWTWO EQU $D1 ; X +HS_UNKNOWN_DUNGEON_3_ITEM_1 EQU $D2 ; X +HS_UNKNOWN_DUNGEON_3_ITEM_2 EQU $D3 ; X +HS_VICTORY_ROAD_1_ITEM_1 EQU $D4 ; X +HS_VICTORY_ROAD_1_ITEM_2 EQU $D5 ; X +HS_CHAMPIONS_ROOM_OAK EQU $D6 +HS_SEAFOAM_ISLANDS_1_BOULDER_1 EQU $D7 +HS_SEAFOAM_ISLANDS_1_BOULDER_2 EQU $D8 +HS_SEAFOAM_ISLANDS_2_BOULDER_1 EQU $D9 +HS_SEAFOAM_ISLANDS_2_BOULDER_2 EQU $DA +HS_SEAFOAM_ISLANDS_3_BOULDER_1 EQU $DB +HS_SEAFOAM_ISLANDS_3_BOULDER_2 EQU $DC +HS_SEAFOAM_ISLANDS_4_BOULDER_1 EQU $DD +HS_SEAFOAM_ISLANDS_4_BOULDER_2 EQU $DE +HS_SEAFOAM_ISLANDS_4_BOULDER_3 EQU $DF +HS_SEAFOAM_ISLANDS_4_BOULDER_4 EQU $E0 +HS_SEAFOAM_ISLANDS_5_BOULDER_1 EQU $E1 +HS_SEAFOAM_ISLANDS_5_BOULDER_2 EQU $E2 +HS_ARTICUNO EQU $E3 ; X diff --git a/scripts/billshouse.asm b/scripts/billshouse.asm index 14882d1a88..61a575b9ab 100755 --- a/scripts/billshouse.asm +++ b/scripts/billshouse.asm @@ -39,7 +39,7 @@ BillsHouseScript2: ; 1e7a6 (7:67a6) ld a, [wd730] bit 0, a ret nz - ld a, $61 + ld a, HS_BILL_POKEMON ld [wcc4d], a predef HideObject ld hl, wd7f2 @@ -67,7 +67,7 @@ BillsHouseScript3: ; 1e7c5 (7:67c5) ld a, $5 ld [$ffee], a call SetSpritePosition1 - ld a, $62 + ld a, HS_BILL_1 ld [wcc4d], a predef ShowObject ld c, $8 @@ -161,10 +161,10 @@ BillsHouseText2: ; 1e874 (7:6874) call PrintText ld hl, wd7f2 set 4, [hl] - ld a, $7 + ld a, HS_CERULEAN_GUARD_1 ld [wcc4d], a predef ShowObject - ld a, $9 + ld a, HS_CERULEAN_GUARD_2 ld [wcc4d], a predef HideObject .asm_5491f ; 0x1e8a9 diff --git a/scripts/blueshouse.asm b/scripts/blueshouse.asm index 4f336ea9d2..ab05e28616 100755 --- a/scripts/blueshouse.asm +++ b/scripts/blueshouse.asm @@ -42,7 +42,7 @@ BluesHouseText1: ; 19b5d (6:5b5d) ld bc,(TOWN_MAP << 8) | 1 call GiveItem jr nc, .BagFull - ld a,$29 + ld a,HS_TOWN_MAP ld [wcc4d],a predef HideObject ; hide table map object ld hl,GotMapText diff --git a/scripts/celadongamecorner.asm b/scripts/celadongamecorner.asm index e8d90a5a9b..3e7b994e9c 100755 --- a/scripts/celadongamecorner.asm +++ b/scripts/celadongamecorner.asm @@ -94,7 +94,7 @@ CeladonGameCornerScript2: ; 48c69 (12:4c69) ret nz xor a ld [wJoyIgnore], a - ld a, $46 + ld a, HS_GAME_CORNER_ROCKET ld [wcc4d], a predef HideObject ld hl, wd126 diff --git a/scripts/celadonmansion5.asm b/scripts/celadonmansion5.asm index 66ef96d8f7..c18e36c651 100755 --- a/scripts/celadonmansion5.asm +++ b/scripts/celadonmansion5.asm @@ -14,7 +14,7 @@ CeladonMansion5Text2: ; 1dd46 (7:5d46) ld bc,(EEVEE << 8) | 25 call GivePokemon jr nc, .asm_24365 ; 0x1dd4d - ld a, $45 + ld a, HS_CELADON_MANSION_5_GIFT ld [wcc4d], a predef HideObject .asm_24365 ; 0x1dd59 diff --git a/scripts/ceruleancity.asm b/scripts/ceruleancity.asm index 9782466274..bbddad79be 100755 --- a/scripts/ceruleancity.asm +++ b/scripts/ceruleancity.asm @@ -8,7 +8,7 @@ CeruleanCityScript_1948c: ; 1948c (6:548c) xor a ld [wJoyIgnore], a ld [W_CERULEANCITYCURSCRIPT], a - ld a, $5 + ld a, HS_CERULEAN_RIVAL ld [wcc4d], a predef_jump HideObject @@ -88,7 +88,7 @@ CeruleanCityScript0: ; 194c8 (6:54c8) call GetPointerWithinSpriteStateData2 ld [hl], $19 .asm_19535 - ld a, $5 + ld a, HS_CERULEAN_RIVAL ld [wcc4d], a predef ShowObject ld de, CeruleanCityMovement1 @@ -204,7 +204,7 @@ CeruleanCityScript3: ; 19610 (6:5610) ld a, [wd730] bit 0, a ret nz - ld a, $5 + ld a, HS_CERULEAN_RIVAL ld [wcc4d], a predef HideObject xor a diff --git a/scripts/ceruleancity2.asm b/scripts/ceruleancity2.asm index e65ef2c5f2..72ee4a86bc 100755 --- a/scripts/ceruleancity2.asm +++ b/scripts/ceruleancity2.asm @@ -3,13 +3,13 @@ Func_74872: ; 74872 (1d:4872) ; one is called after you beat the Rocket that gives you TM28 DIG. ; the screen then fades out, he disappears, and fades back in call GBFadeOutToBlack - ld a, $07 + ld a, HS_CERULEAN_GUARD_1 ld [wcc4d], a predef ShowObject - ld a, $09 + ld a, HS_CERULEAN_GUARD_2 ld [wcc4d], a predef HideObject - ld a, $06 + ld a, HS_CERULEAN_ROCKET ld [wcc4d], a predef HideObject call GBFadeInFromBlack diff --git a/scripts/fightingdojo.asm b/scripts/fightingdojo.asm index 4a55347e46..e26da1b119 100755 --- a/scripts/fightingdojo.asm +++ b/scripts/fightingdojo.asm @@ -279,7 +279,7 @@ FightingDojoText6: ; 5cf06 (17:4f06) jr nc, .done ; once Poké Ball is taken, hide sprite - ld a, $4a + ld a, HS_FIGHTING_DOJO_GIFT_1 ld [wcc4d], a predef HideObject ld hl, wd7b1 @@ -320,7 +320,7 @@ FightingDojoText7: ; 5cf4e (17:4f4e) set 0, [hl] ; once Poké Ball is taken, hide sprite - ld a, $4b + ld a, HS_FIGHTING_DOJO_GIFT_2 ld [wcc4d], a predef HideObject .done diff --git a/scripts/gary.asm b/scripts/gary.asm index fa3311521f..c0785cabb2 100755 --- a/scripts/gary.asm +++ b/scripts/gary.asm @@ -120,7 +120,7 @@ GaryScript4: ; 75fe4 (1d:5fe4) ld a, $2 ld [$ff8c], a call MoveSprite - ld a, $d6 + ld a, HS_CHAMPIONS_ROOM_OAK ld [wcc4d], a predef ShowObject ld a, $5 @@ -190,7 +190,7 @@ GaryScript8: ; 76083 (1d:6083) ld a, [wd730] bit 0, a ret nz - ld a, $d6 + ld a, HS_CHAMPIONS_ROOM_OAK ld [wcc4d], a predef HideObject ld a, $9 diff --git a/scripts/halloffameroom.asm b/scripts/halloffameroom.asm index fb5cad3a9e..c44622c711 100755 --- a/scripts/halloffameroom.asm +++ b/scripts/halloffameroom.asm @@ -98,7 +98,7 @@ HallofFameRoomScript1: ; 5a52b (16:652b) call DisplayTextID ld a, $ff ld [wJoyIgnore], a - ld a, $8 + ld a, HS_UNKNOWN_DUNGEON_GUY ld [wcc4d], a predef HideObject ld a, $2 diff --git a/scripts/mtmoon3.asm b/scripts/mtmoon3.asm index f0124be0fa..eb0fc301fe 100755 --- a/scripts/mtmoon3.asm +++ b/scripts/mtmoon3.asm @@ -145,10 +145,10 @@ MtMoon3Script5: ; 49dfb (12:5dfb) ld a, [wd7f6] bit 6, a jr z, .asm_49e1d - ld a, $6e + ld a, HS_MT_MOON_3_FOSSIL_2 jr .asm_49e1f .asm_49e1d - ld a, $6d + ld a, HS_MT_MOON_3_FOSSIL_1 .asm_49e1f ld [wcc4d], a predef HideObject @@ -281,7 +281,7 @@ MtMoon3Text6: ; 49ee9 (12:5ee9) call GiveItem jp nc, MtMoon3Script_49f76 call MtMoon3Script_49f69 - ld a, $6d + ld a, HS_MT_MOON_3_FOSSIL_1 ld [wcc4d], a predef HideObject ld hl, wd7f6 @@ -310,7 +310,7 @@ MtMoon3Text7: ; 49f29 (12:5f29) call GiveItem jp nc, MtMoon3Script_49f76 call MtMoon3Script_49f69 - ld a, $6e + ld a, HS_MT_MOON_3_FOSSIL_2 ld [wcc4d], a predef HideObject ld hl, wd7f6 diff --git a/scripts/museum1f.asm b/scripts/museum1f.asm index a701e1a46c..cbb3bb6709 100755 --- a/scripts/museum1f.asm +++ b/scripts/museum1f.asm @@ -200,7 +200,7 @@ Museum1FText3: ; 5c256 (17:4256) jr nc, .BagFull ld hl, wd754 set 1, [hl] - ld a, $34 + ld a, HS_OLD_AMBER ld [wcc4d], a predef HideObject ld hl, ReceivedOldAmberText diff --git a/scripts/oakslab.asm b/scripts/oakslab.asm index 574c68142d..6b7d5e1e73 100755 --- a/scripts/oakslab.asm +++ b/scripts/oakslab.asm @@ -38,7 +38,7 @@ OaksLabScript0: ; 1cb4e (7:4b4e) ld a, [wNPCMovementScriptFunctionNum] and a ret nz - ld a, $31 + ld a, HS_OAKS_LAB_OAK_2 ld [wcc4d], a predef ShowObject ld hl, wd72e @@ -65,10 +65,10 @@ OaksLabScript2: ; 1cb82 (7:4b82) ld a, [wd730] bit 0, a ret nz - ld a, $31 + ld a, HS_OAKS_LAB_OAK_2 ld [wcc4d], a predef HideObject - ld a, $2e + ld a, HS_OAKS_LAB_OAK_1 ld [wcc4d], a predef ShowObject @@ -280,15 +280,15 @@ OaksLabScript9: ; 1cd00 (7:4d00) ld a, [wTrainerEngageDistance] cp $2 jr nz, .asm_1cd28 ; 0x1cd22 $4 - ld a, $2b + ld a, HS_STARTER_BALL_1 jr .asm_1cd32 ; 0x1cd26 $a .asm_1cd28 cp $3 jr nz, .asm_1cd30 ; 0x1cd2a $4 - ld a, $2c + ld a, HS_STARTER_BALL_2 jr .asm_1cd32 ; 0x1cd2e $2 .asm_1cd30 - ld a, $2d + ld a, HS_STARTER_BALL_3 .asm_1cd32 ld [wcc4d], a predef HideObject @@ -445,7 +445,7 @@ OaksLabScript14: ; 1ce6d (7:4e6d) ld a, [wd730] bit 0, a jr nz, .asm_1ce8c ; 0x1ce72 $18 - ld a, $2a + ld a, HS_OAKS_LAB_RIVAL ld [wcc4d], a predef HideObject xor a @@ -488,7 +488,7 @@ OaksLabScript15: ; 1ceb0 (7:4eb0) ld [$ff8c], a call DisplayTextID call OaksLabScript_1d02b - ld a, $2a + ld a, HS_OAKS_LAB_RIVAL ld [wcc4d], a predef ShowObject ld a, [wNPCMovementDirections2Index] @@ -547,10 +547,10 @@ OaksLabScript16: ; 1cf12 (7:4f12) ld [$ff8c], a call DisplayTextID call Delay3 - ld a, $2f + ld a, HS_POKEDEX_1 ld [wcc4d], a predef HideObject - ld a, $30 + ld a, HS_POKEDEX_2 ld [wcc4d], a predef HideObject call OaksLabScript_1cefd @@ -570,10 +570,10 @@ OaksLabScript16: ; 1cf12 (7:4f12) set 5, [hl] ld hl, wd74e set 0, [hl] - ld a, $1 + ld a, HS_LYING_OLD_MAN ld [wcc4d], a predef HideObject - ld a, $2 + ld a, HS_OLD_MAN ld [wcc4d], a predef ShowObject ld a, [wd157] @@ -601,14 +601,14 @@ OaksLabScript17: ; 1cfd4 (7:4fd4) bit 0, a ret nz call PlayDefaultMusic - ld a, $2a + ld a, HS_OAKS_LAB_RIVAL ld [wcc4d], a predef HideObject ld hl, wd7eb set 0, [hl] res 1, [hl] set 7, [hl] - ld a, $22 + ld a, HS_ROUTE_22_RIVAL_1 ld [wcc4d], a predef ShowObject ld a, $5 @@ -880,15 +880,15 @@ OaksLabMonChoiceMenu: ; 1d1b3 (7:51b3) ld a, [wSpriteIndex] cp $2 jr nz, asm_1d1db ; 0x1d1d5 $4 - ld a, $2b + ld a, HS_STARTER_BALL_1 jr asm_1d1e5 ; 0x1d1d9 $a asm_1d1db: ; 1d1db (7:51db) cp $3 jr nz, asm_1d1e3 ; 0x1d1dd $4 - ld a, $2c + ld a, HS_STARTER_BALL_2 jr asm_1d1e5 ; 0x1d1e1 $2 asm_1d1e3: ; 1d1e3 (7:51e3) - ld a, $2d + ld a, HS_STARTER_BALL_3 asm_1d1e5: ; 1d1e5 (7:51e5) ld [wcc4d], a predef HideObject diff --git a/scripts/pallettown.asm b/scripts/pallettown.asm index e7bd2f5789..c43b96825a 100755 --- a/scripts/pallettown.asm +++ b/scripts/pallettown.asm @@ -54,7 +54,7 @@ PalletTownScript1: ; 18eb2 (6:4eb2) call DisplayTextID ld a,$FF ld [wJoyIgnore],a - ld a,0 + ld a,HS_PALLET_TOWN_OAK ld [wcc4d],a predef ShowObject @@ -141,10 +141,10 @@ PalletTownScript5: ; 18f56 (6:4f56) jr nz,.next ld hl,wd74a set 2,[hl] - ld a,$27 + ld a,HS_DAISY_SITTING ld [wcc4d],a predef HideObject - ld a,$28 + ld a,HS_DAISY_WALKING ld [wcc4d],a predef_jump ShowObject .next diff --git a/scripts/pewtercity.asm b/scripts/pewtercity.asm index ba32454aa5..55369df9d5 100755 --- a/scripts/pewtercity.asm +++ b/scripts/pewtercity.asm @@ -85,7 +85,7 @@ PewterCityScript2: ; 192d3 (6:52d3) ld a, [wd730] bit 0, a ret nz - ld a, $3 + ld a, HS_MUSEUM_GUY ld [wcc4d], a predef HideObject ld a, $3 @@ -96,7 +96,7 @@ PewterCityScript3: ; 192e9 (6:52e9) ld a, $3 ld [wSpriteIndex], a call SetSpritePosition2 - ld a, $3 + ld a, HS_MUSEUM_GUY ld [wcc4d], a predef ShowObject xor a @@ -149,7 +149,7 @@ PewterCityScript5: ; 19359 (6:5359) ld a, [wd730] bit 0, a ret nz - ld a, $4 + ld a, HS_GYM_GUY ld [wcc4d], a predef HideObject ld a, $6 @@ -160,7 +160,7 @@ PewterCityScript6: ; 1936f (6:536f) ld a, $5 ld [wSpriteIndex], a call SetSpritePosition2 - ld a, $4 + ld a, HS_GYM_GUY ld [wcc4d], a predef ShowObject xor a diff --git a/scripts/pewtergym.asm b/scripts/pewtergym.asm index 21d3fe74be..9f9c7c3b59 100755 --- a/scripts/pewtergym.asm +++ b/scripts/pewtergym.asm @@ -67,10 +67,10 @@ PewterGymScript_5c3df: ; 5c3df (17:43df) ld hl, wd72a set 0, [hl] - ld a, $4 + ld a, HS_GYM_GUY ld [wcc4d], a predef HideObject - ld a, $22 + ld a, HS_ROUTE_22_RIVAL_1 ld [wcc4d], a predef HideObject diff --git a/scripts/pokemontower2.asm b/scripts/pokemontower2.asm index 3c9ec72df8..dc9275f256 100755 --- a/scripts/pokemontower2.asm +++ b/scripts/pokemontower2.asm @@ -99,7 +99,7 @@ PokemonTower2Script2: ; 605bb (18:45bb) ld a, [wd730] bit 0, a ret nz - ld a, $38 + ld a, HS_POKEMONTOWER_2_RIVAL ld [wcc4d], a predef HideObject xor a diff --git a/scripts/pokemontower7.asm b/scripts/pokemontower7.asm index cc736a0875..5f0ed52105 100755 --- a/scripts/pokemontower7.asm +++ b/scripts/pokemontower7.asm @@ -66,7 +66,7 @@ PokemonTower7Script3: ; 60d56 (18:4d56) PokemonTower7Script4: ; 60d86 (18:4d86) ld a, $ff ld [wJoyIgnore], a - ld a, $43 + ld a, HS_POKEMONTOWER_7_MR_FUJI ld [wcc4d], a predef HideObject ld a, $4 @@ -222,13 +222,13 @@ PokemonTower7Text4: ; 60e8a (18:4e8a) set 7, [hl] ld hl, wd769 set 7, [hl] - ld a, $44 + ld a, HS_LAVENDER_HOUSE_1_MR_FUJI ld [wcc4d], a predef ShowObject - ld a, $17 + ld a, HS_SAFFRON_CITY_E ld [wcc4d], a predef HideObject - ld a, $18 + ld a, HS_SAFFRON_CITY_F ld [wcc4d], a predef ShowObject ld a, $4 diff --git a/scripts/rockethideout4.asm b/scripts/rockethideout4.asm index 097512c36b..f1b466536c 100755 --- a/scripts/rockethideout4.asm +++ b/scripts/rockethideout4.asm @@ -59,10 +59,10 @@ RocketHideout4Script3: ; 454b6 (11:54b6) ld [H_SPRITEHEIGHT], a call DisplayTextID call GBFadeOutToBlack - ld a, $83 + ld a, HS_ROCKET_HIDEOUT_4_GIOVANNI ld [wcc4d], a predef HideObject - ld a, $87 + ld a, HS_ROCKET_HIDEOUT_4_ITEM_4 ld [wcc4d], a predef ShowObject call UpdateSprites @@ -217,7 +217,7 @@ RocketHideout4AfterBattleText4: ; 455cf (11:55cf) bit 6, [hl] set 6, [hl] jr nz, .asm_455e9 ; 0x455dd $a - ld a, $88 + ld a, HS_ROCKET_HIDEOUT_4_ITEM_5 ld [wcc4d], a predef ShowObject .asm_455e9 diff --git a/scripts/route12.asm b/scripts/route12.asm index a38f6b8353..fdaf2a85cd 100755 --- a/scripts/route12.asm +++ b/scripts/route12.asm @@ -34,7 +34,7 @@ Route12Script0: ; 59619 (16:5619) ld [W_CUROPPONENT], a ; wd059 ld a, 30 ld [W_CURENEMYLVL], a ; W_CURENEMYLVL - ld a, $1d + ld a, HS_ROUTE_12_SNORLAX ld [wcc4d], a predef HideObject ld a, $3 diff --git a/scripts/route16.asm b/scripts/route16.asm index 59f8cb24fc..ef5b5859ba 100755 --- a/scripts/route16.asm +++ b/scripts/route16.asm @@ -34,7 +34,7 @@ Route16Script0: ; 59959 (16:5959) ld [W_CUROPPONENT], a ; wd059 ld a, 30 ld [W_CURENEMYLVL], a ; W_CURENEMYLVL - ld a, $21 + ld a, HS_ROUTE_16_SNORLAX ld [wcc4d], a predef HideObject call UpdateSprites diff --git a/scripts/route20.asm b/scripts/route20.asm index 47edf37671..db4b999942 100755 --- a/scripts/route20.asm +++ b/scripts/route20.asm @@ -38,13 +38,13 @@ Route20Script_50cc6: ; 50cc6 (14:4cc6) and $3 cp $3 ret z - ld a, $dd + ld a, HS_SEAFOAM_ISLANDS_4_BOULDER_1 call Route20Script_50d0c - ld a, $de + ld a, HS_SEAFOAM_ISLANDS_4_BOULDER_2 call Route20Script_50d0c - ld a, $e1 + ld a, HS_SEAFOAM_ISLANDS_5_BOULDER_1 call Route20Script_50d14 - ld a, $e2 + ld a, HS_SEAFOAM_ISLANDS_5_BOULDER_2 call Route20Script_50d14 ret diff --git a/scripts/route22.asm b/scripts/route22.asm index 233d42c3ef..9181380aaa 100755 --- a/scripts/route22.asm +++ b/scripts/route22.asm @@ -205,7 +205,7 @@ Route22Script3: ; 5102a (14:502a) ret nz xor a ld [wJoyIgnore], a - ld a, $22 + ld a, HS_ROUTE_22_RIVAL_1 ld [wcc4d], a predef HideObject call PlayDefaultMusic @@ -350,7 +350,7 @@ Route22Script6: ; 51151 (14:5151) ret nz xor a ld [wJoyIgnore], a - ld a, $23 + ld a, HS_ROUTE_22_RIVAL_2 ld [wcc4d], a predef HideObject call PlayDefaultMusic diff --git a/scripts/route23.asm b/scripts/route23.asm index 175250711a..6d3849f415 100755 --- a/scripts/route23.asm +++ b/scripts/route23.asm @@ -16,10 +16,10 @@ Route23Script_511e9: ; 511e9 (14:51e9) ld hl, wd813 res 0, [hl] res 6, [hl] - ld a, $7a + ld a, HS_VICTORY_ROAD_3_BOULDER ld [wcc4d], a predef ShowObject - ld a, $60 + ld a, HS_VICTORY_ROAD_2_BOULDER ld [wcc4d], a predef_jump HideObject diff --git a/scripts/route25.asm b/scripts/route25.asm index 720259ca2c..b915bdeeda 100755 --- a/scripts/route25.asm +++ b/scripts/route25.asm @@ -19,20 +19,20 @@ Route25Script_515e1: ; 515e1 (14:55e1) bit 5, [hl] jr nz, .asm_515ff res 6, [hl] - ld a, $61 + ld a, HS_BILL_POKEMON ld [wcc4d], a predef_jump ShowObject .asm_515ff bit 4, [hl] ret z set 7, [hl] - ld a, $24 + ld a, HS_NUGGET_BRIDGE_GUY ld [wcc4d], a predef HideObject - ld a, $62 + ld a, HS_BILL_1 ld [wcc4d], a predef HideObject - ld a, $63 + ld a, HS_BILL_2 ld [wcc4d], a predef_jump ShowObject diff --git a/scripts/seafoamislands1.asm b/scripts/seafoamislands1.asm index 1fe0852b62..2e64c9d7d9 100755 --- a/scripts/seafoamislands1.asm +++ b/scripts/seafoamislands1.asm @@ -14,16 +14,16 @@ SeafoamIslands1Script: ; 447e9 (11:47e9) cp $1 jr nz, .asm_44819 ; 0x44809 $e set 6, [hl] - ld a, $d7 + ld a, HS_SEAFOAM_ISLANDS_1_BOULDER_1 ld [wd079], a - ld a, $d9 + ld a, HS_SEAFOAM_ISLANDS_2_BOULDER_1 ld [wd07a], a jr .asm_44825 ; 0x44817 $c .asm_44819 set 7, [hl] - ld a, $d8 + ld a, HS_SEAFOAM_ISLANDS_1_BOULDER_2 ld [wd079], a - ld a, $da + ld a, HS_SEAFOAM_ISLANDS_2_BOULDER_2 ld [wd07a], a .asm_44825 ld a, [wd079] diff --git a/scripts/seafoamislands2.asm b/scripts/seafoamislands2.asm index e392620ac2..66fe9297ea 100755 --- a/scripts/seafoamislands2.asm +++ b/scripts/seafoamislands2.asm @@ -12,16 +12,16 @@ SeafoamIslands2Script: ; 46315 (11:6315) cp $1 jr nz, .asm_46340 ; 0x46330 $e set 0, [hl] - ld a, $d9 + ld a, HS_SEAFOAM_ISLANDS_2_BOULDER_1 ld [wd079], a - ld a, $db + ld a, HS_SEAFOAM_ISLANDS_3_BOULDER_1 ld [wd07a], a jr .asm_4634c ; 0x4633e $c .asm_46340 set 1, [hl] - ld a, $da + ld a, HS_SEAFOAM_ISLANDS_2_BOULDER_2 ld [wd079], a - ld a, $dc + ld a, HS_SEAFOAM_ISLANDS_3_BOULDER_2 ld [wd07a], a .asm_4634c ld a, [wd079] diff --git a/scripts/seafoamislands3.asm b/scripts/seafoamislands3.asm index ba34a2c3ca..fb7d05baf6 100755 --- a/scripts/seafoamislands3.asm +++ b/scripts/seafoamislands3.asm @@ -12,16 +12,16 @@ SeafoamIslands3Script: ; 46451 (11:6451) cp $1 jr nz, .asm_4647c ; 0x4646c $e set 0, [hl] - ld a, $db + ld a, HS_SEAFOAM_ISLANDS_3_BOULDER_1 ld [wd079], a - ld a, $df + ld a, HS_SEAFOAM_ISLANDS_4_BOULDER_3 ld [wd07a], a jr .asm_46488 ; 0x4647a $c .asm_4647c set 1, [hl] - ld a, $dc + ld a, HS_SEAFOAM_ISLANDS_3_BOULDER_2 ld [wd079], a - ld a, $e0 + ld a, HS_SEAFOAM_ISLANDS_4_BOULDER_4 ld [wd07a], a .asm_46488 ld a, [wd079] diff --git a/scripts/seafoamislands4.asm b/scripts/seafoamislands4.asm index a56382dd38..7e519f86d2 100755 --- a/scripts/seafoamislands4.asm +++ b/scripts/seafoamislands4.asm @@ -12,16 +12,16 @@ SeafoamIslands4Script: ; 4658d (11:658d) cp $1 jr nz, .asm_465b8 ; 0x465a8 $e set 0, [hl] - ld a, $dd + ld a, HS_SEAFOAM_ISLANDS_4_BOULDER_1 ld [wd079], a - ld a, $e1 + ld a, HS_SEAFOAM_ISLANDS_5_BOULDER_1 ld [wd07a], a jr .asm_465c4 ; 0x465b6 $c .asm_465b8 set 1, [hl] - ld a, $de + ld a, HS_SEAFOAM_ISLANDS_4_BOULDER_2 ld [wd079], a - ld a, $e2 + ld a, HS_SEAFOAM_ISLANDS_5_BOULDER_2 ld [wd07a], a .asm_465c4 ld a, [wd079] diff --git a/scripts/silphco1.asm b/scripts/silphco1.asm index 990e5c2aa4..8a399a4c69 100755 --- a/scripts/silphco1.asm +++ b/scripts/silphco1.asm @@ -7,7 +7,7 @@ SilphCo1Script: ; 5d44e (17:544e) bit 7, [hl] set 7, [hl] ret nz - ld a, $4c + ld a, HS_SILPH_CO_1F_1 ld [wcc4d], a predef_jump ShowObject diff --git a/scripts/silphco11.asm b/scripts/silphco11.asm index 43ae72f6b5..7bb6e44852 100755 --- a/scripts/silphco11.asm +++ b/scripts/silphco11.asm @@ -95,14 +95,55 @@ SilphCo11Script_6216d: ; 6216d (18:616d) jr .asm_62184 MissableObjectIDs_62194: ; 62194 (18:6194) - db $11,$12,$13,$14,$15,$16,$FF + db HS_SAFFRON_CITY_8 + db HS_SAFFRON_CITY_9 + db HS_SAFFRON_CITY_A + db HS_SAFFRON_CITY_B + db HS_SAFFRON_CITY_C + db HS_SAFFRON_CITY_D + db $FF MissableObjectIDs_6219b: ; 6219b (18:619b) - db $0A,$0B,$0C,$0D,$0E,$0F,$10,$17 - db $18,$8A,$8B,$8C,$8D,$8E,$8F,$91 - db $92,$93,$97,$98,$99,$9A,$9E,$9F - db $A0,$A3,$A4,$A5,$A6,$AB,$AC,$AD - db $AE,$AF,$B0,$B1,$B2,$B7,$B8,$B9 + db HS_SAFFRON_CITY_1 + db HS_SAFFRON_CITY_2 + db HS_SAFFRON_CITY_3 + db HS_SAFFRON_CITY_4 + db HS_SAFFRON_CITY_5 + db HS_SAFFRON_CITY_6 + db HS_SAFFRON_CITY_7 + db HS_SAFFRON_CITY_E + db HS_SAFFRON_CITY_F + db HS_SILPH_CO_2F_2 + db HS_SILPH_CO_2F_3 + db HS_SILPH_CO_2F_4 + db HS_SILPH_CO_2F_5 + db HS_SILPH_CO_3F_1 + db HS_SILPH_CO_3F_2 + db HS_SILPH_CO_4F_1 + db HS_SILPH_CO_4F_2 + db HS_SILPH_CO_4F_3 + db HS_SILPH_CO_5F_1 + db HS_SILPH_CO_5F_2 + db HS_SILPH_CO_5F_3 + db HS_SILPH_CO_5F_4 + db HS_SILPH_CO_6F_1 + db HS_SILPH_CO_6F_2 + db HS_SILPH_CO_6F_3 + db HS_SILPH_CO_7F_1 + db HS_SILPH_CO_7F_2 + db HS_SILPH_CO_7F_3 + db HS_SILPH_CO_7F_4 + db HS_SILPH_CO_8F_1 + db HS_SILPH_CO_8F_2 + db HS_SILPH_CO_8F_3 + db HS_SILPH_CO_9F_1 + db HS_SILPH_CO_9F_2 + db HS_SILPH_CO_9F_3 + db HS_SILPH_CO_10F_1 + db HS_SILPH_CO_10F_2 + db HS_SILPH_CO_11F_1 + db HS_SILPH_CO_11F_2 + db HS_SILPH_CO_11F_3 db $FF SilphCo11Script_621c4: ; 621c4 (18:61c4) diff --git a/scripts/silphco7.asm b/scripts/silphco7.asm index 2fc3c51a1c..d4db9ebbff 100755 --- a/scripts/silphco7.asm +++ b/scripts/silphco7.asm @@ -241,7 +241,7 @@ SilphCo7Script5: ; 51d25 (14:5d25) ld a, [wd730] bit 0, a ret nz - ld a, $a7 + ld a, HS_SILPH_CO_7F_5 ld [wcc4d], a predef HideObject call PlayDefaultMusic diff --git a/scripts/ssanne2.asm b/scripts/ssanne2.asm index c5943a547a..474aaa6057 100755 --- a/scripts/ssanne2.asm +++ b/scripts/ssanne2.asm @@ -32,7 +32,7 @@ SSAnne2Script0: ; 613be (18:53be) call PlayMusic ld a, [wWhichTrade] ld [$ffdb], a - ld a, $71 + ld a, HS_SS_ANNE_2_RIVAL ld [wcc4d], a predef ShowObject call Delay3 @@ -160,7 +160,7 @@ SSAnne2Script3: ; 614be (18:54be) ret nz xor a ld [wJoyIgnore], a - ld a, $71 + ld a, HS_SS_ANNE_2_RIVAL ld [wcc4d], a predef HideObject call PlayDefaultMusic diff --git a/scripts/victoryroad3.asm b/scripts/victoryroad3.asm index 99926498a4..01269a3f2e 100755 --- a/scripts/victoryroad3.asm +++ b/scripts/victoryroad3.asm @@ -47,10 +47,10 @@ VictoryRoad3Script0: ; 449b7 (11:49b7) bit 6, [hl] set 6, [hl] jr nz, .asm_449fe - ld a, $7a + ld a, HS_VICTORY_ROAD_3_BOULDER ld [wcc4d], a predef HideObject - ld a, $60 + ld a, HS_VICTORY_ROAD_2_BOULDER ld [wcc4d], a predef_jump ShowObject diff --git a/scripts/viridiangym.asm b/scripts/viridiangym.asm index 3aa23b434f..6ced7d8297 100755 --- a/scripts/viridiangym.asm +++ b/scripts/viridiangym.asm @@ -175,7 +175,7 @@ ViridianGymScript3_74995: ; 74995 (1d:4995) or %00000011 ld [wd752], a - ld a, $23 + ld a, HS_ROUTE_22_RIVAL_2 ld [wcc4d], a predef ShowObject ld hl, wd7eb @@ -290,7 +290,7 @@ ViridianGymText1: ; 74a69 (1d:4a69) ld hl, ViridianGymText_74ad9 call PrintText call GBFadeOutToBlack - ld a, $32 + ld a, HS_VIRIDIAN_GYM_GIOVANNI ld [wcc4d], a predef HideObject call UpdateSprites From 4d60e6f1a95749238a24d0cc7c44c5bfd6512be4 Mon Sep 17 00:00:00 2001 From: "U-Daniel-PC\\Daniel" Date: Fri, 26 Sep 2014 07:37:21 -0400 Subject: [PATCH 032/100] Enumerate hide/show constants --- constants/hide_show_constants.asm | 458 +++++++++++++++--------------- scripts/silphco7.asm | 2 +- 2 files changed, 231 insertions(+), 229 deletions(-) diff --git a/constants/hide_show_constants.asm b/constants/hide_show_constants.asm index c5bcf76312..1c5beb779f 100755 --- a/constants/hide_show_constants.asm +++ b/constants/hide_show_constants.asm @@ -4,231 +4,233 @@ ; (they are either items or sprites that deactivate after battle ; and are detected in W_MISSABLEOBJECTLIST) -HS_PALLET_TOWN_OAK EQU $00 -HS_LYING_OLD_MAN EQU $01 -HS_OLD_MAN EQU $02 -HS_MUSEUM_GUY EQU $03 -HS_GYM_GUY EQU $04 -HS_CERULEAN_RIVAL EQU $05 -HS_CERULEAN_ROCKET EQU $06 -HS_CERULEAN_GUARD_1 EQU $07 -HS_UNKNOWN_DUNGEON_GUY EQU $08 -HS_CERULEAN_GUARD_2 EQU $09 -HS_SAFFRON_CITY_1 EQU $0A -HS_SAFFRON_CITY_2 EQU $0B -HS_SAFFRON_CITY_3 EQU $0C -HS_SAFFRON_CITY_4 EQU $0D -HS_SAFFRON_CITY_5 EQU $0E -HS_SAFFRON_CITY_6 EQU $0F -HS_SAFFRON_CITY_7 EQU $10 -HS_SAFFRON_CITY_8 EQU $11 -HS_SAFFRON_CITY_9 EQU $12 -HS_SAFFRON_CITY_A EQU $13 -HS_SAFFRON_CITY_B EQU $14 -HS_SAFFRON_CITY_C EQU $15 -HS_SAFFRON_CITY_D EQU $16 -HS_SAFFRON_CITY_E EQU $17 -HS_SAFFRON_CITY_F EQU $18 -HS_ROUTE_2_ITEM_1 EQU $19 ; X -HS_ROUTE_2_ITEM_2 EQU $1A ; X -HS_ROUTE_4_ITEM EQU $1B ; X -HS_ROUTE_9_ITEM EQU $1C ; X -HS_ROUTE_12_SNORLAX EQU $1D -HS_ROUTE_12_ITEM_1 EQU $1E ; X -HS_ROUTE_12_ITEM_2 EQU $1F ; X -HS_ROUTE_15_ITEM EQU $20 ; X -HS_ROUTE_16_SNORLAX EQU $21 -HS_ROUTE_22_RIVAL_1 EQU $22 -HS_ROUTE_22_RIVAL_2 EQU $23 -HS_NUGGET_BRIDGE_GUY EQU $24 -HS_ROUTE_24_ITEM EQU $25 ; X -HS_ROUTE_25_ITEM EQU $26 ; X -HS_DAISY_SITTING EQU $27 -HS_DAISY_WALKING EQU $28 -HS_TOWN_MAP EQU $29 -HS_OAKS_LAB_RIVAL EQU $2A -HS_STARTER_BALL_1 EQU $2B -HS_STARTER_BALL_2 EQU $2C -HS_STARTER_BALL_3 EQU $2D -HS_OAKS_LAB_OAK_1 EQU $2E -HS_POKEDEX_1 EQU $2F -HS_POKEDEX_2 EQU $30 -HS_OAKS_LAB_OAK_2 EQU $31 -HS_VIRIDIAN_GYM_GIOVANNI EQU $32 -HS_VIRIDIAN_GYM_ITEM EQU $33 ; X -HS_OLD_AMBER EQU $34 -HS_UNKNOWN_DUNGEON_1_ITEM_1 EQU $35 ; X -HS_UNKNOWN_DUNGEON_1_ITEM_2 EQU $36 ; X -HS_UNKNOWN_DUNGEON_1_ITEM_3 EQU $37 ; X -HS_POKEMONTOWER_2_RIVAL EQU $38 -HS_POKEMONTOWER_3_ITEM EQU $39 ; X -HS_POKEMONTOWER_4_ITEM_1 EQU $3A ; X -HS_POKEMONTOWER_4_ITEM_2 EQU $3B ; X -HS_POKEMONTOWER_4_ITEM_3 EQU $3C ; X -HS_POKEMONTOWER_5_ITEM EQU $3D ; X -HS_POKEMONTOWER_6_ITEM_1 EQU $3E ; X -HS_POKEMONTOWER_6_ITEM_2 EQU $3F ; X -HS_POKEMONTOWER_7_ROCKET_1 EQU $40 ; X -HS_POKEMONTOWER_7_ROCKET_2 EQU $41 ; X -HS_POKEMONTOWER_7_ROCKET_3 EQU $42 ; X -HS_POKEMONTOWER_7_MR_FUJI EQU $43 -HS_LAVENDER_HOUSE_1_MR_FUJI EQU $44 -HS_CELADON_MANSION_5_GIFT EQU $45 -HS_GAME_CORNER_ROCKET EQU $46 -HS_FUCHSIA_HOUSE_2_ITEM EQU $47 ; X -HS_MANSION_1_ITEM_1 EQU $48 ; X -HS_MANSION_1_ITEM_2 EQU $49 ; X -HS_FIGHTING_DOJO_GIFT_1 EQU $4A -HS_FIGHTING_DOJO_GIFT_2 EQU $4B -HS_SILPH_CO_1F_1 EQU $4C -HS_VOLTORB_1 EQU $4D ; X -HS_VOLTORB_2 EQU $4E ; X -HS_VOLTORB_3 EQU $4F ; X -HS_ELECTRODE_1 EQU $50 ; X -HS_VOLTORB_4 EQU $51 ; X -HS_VOLTORB_5 EQU $52 ; X -HS_ELECTRODE_2 EQU $53 ; X -HS_VOLTORB_6 EQU $54 ; X -HS_ZAPDOS EQU $55 ; X -HS_POWER_PLANT_ITEM_1 EQU $56 ; X -HS_POWER_PLANT_ITEM_2 EQU $57 ; X -HS_POWER_PLANT_ITEM_3 EQU $58 ; X -HS_POWER_PLANT_ITEM_4 EQU $59 ; X -HS_POWER_PLANT_ITEM_5 EQU $5A ; X -HS_MOLTRES EQU $5B ; X -HS_VICTORY_ROAD_2_ITEM_1 EQU $5C ; X -HS_VICTORY_ROAD_2_ITEM_2 EQU $5D ; X -HS_VICTORY_ROAD_2_ITEM_3 EQU $5E ; X -HS_VICTORY_ROAD_2_ITEM_4 EQU $5F ; X -HS_VICTORY_ROAD_2_BOULDER EQU $60 -HS_BILL_POKEMON EQU $61 -HS_BILL_1 EQU $62 -HS_BILL_2 EQU $63 -HS_VIRIDIAN_FOREST_ITEM_1 EQU $64 ; X -HS_VIRIDIAN_FOREST_ITEM_2 EQU $65 ; X -HS_VIRIDIAN_FOREST_ITEM_3 EQU $66 ; X -HS_MT_MOON_1_ITEM_1 EQU $67 ; X -HS_MT_MOON_1_ITEM_2 EQU $68 ; X -HS_MT_MOON_1_ITEM_3 EQU $69 ; X -HS_MT_MOON_1_ITEM_4 EQU $6A ; X -HS_MT_MOON_1_ITEM_5 EQU $6B ; X -HS_MT_MOON_1_ITEM_6 EQU $6C ; X -HS_MT_MOON_3_FOSSIL_1 EQU $6D -HS_MT_MOON_3_FOSSIL_2 EQU $6E -HS_MT_MOON_3_ITEM_1 EQU $6F ; X -HS_MT_MOON_3_ITEM_2 EQU $70 ; X -HS_SS_ANNE_2_RIVAL EQU $71 -HS_SS_ANNE_8_ITEM EQU $72 ; X -HS_SS_ANNE_9_ITEM_1 EQU $73 ; X -HS_SS_ANNE_9_ITEM_2 EQU $74 ; X -HS_SS_ANNE_10_ITEM_1 EQU $75 ; X -HS_SS_ANNE_10_ITEM_2 EQU $76 ; X -HS_SS_ANNE_10_ITEM_3 EQU $77 ; X -HS_VICTORY_ROAD_3_ITEM_1 EQU $78 ; X -HS_VICTORY_ROAD_3_ITEM_2 EQU $79 ; X -HS_VICTORY_ROAD_3_BOULDER EQU $7A -HS_ROCKET_HIDEOUT_1_ITEM_1 EQU $7B ; X -HS_ROCKET_HIDEOUT_1_ITEM_2 EQU $7C ; X -HS_ROCKET_HIDEOUT_2_ITEM_1 EQU $7D ; X -HS_ROCKET_HIDEOUT_2_ITEM_2 EQU $7E ; X -HS_ROCKET_HIDEOUT_2_ITEM_3 EQU $7F ; X -HS_ROCKET_HIDEOUT_2_ITEM_4 EQU $80 ; X -HS_ROCKET_HIDEOUT_3_ITEM_1 EQU $81 ; X -HS_ROCKET_HIDEOUT_3_ITEM_2 EQU $82 ; X -HS_ROCKET_HIDEOUT_4_GIOVANNI EQU $83 -HS_ROCKET_HIDEOUT_4_ITEM_1 EQU $84 ; X -HS_ROCKET_HIDEOUT_4_ITEM_2 EQU $85 ; X -HS_ROCKET_HIDEOUT_4_ITEM_3 EQU $86 ; X -HS_ROCKET_HIDEOUT_4_ITEM_4 EQU $87 -HS_ROCKET_HIDEOUT_4_ITEM_5 EQU $88 -HS_SILPH_CO_2F_1 EQU $89 ; XXX never (de)activated? -HS_SILPH_CO_2F_2 EQU $8A -HS_SILPH_CO_2F_3 EQU $8B -HS_SILPH_CO_2F_4 EQU $8C -HS_SILPH_CO_2F_5 EQU $8D -HS_SILPH_CO_3F_1 EQU $8E -HS_SILPH_CO_3F_2 EQU $8F -HS_SILPH_CO_3F_3 EQU $90 ; X -HS_SILPH_CO_4F_1 EQU $91 -HS_SILPH_CO_4F_2 EQU $92 -HS_SILPH_CO_4F_3 EQU $93 -HS_SILPH_CO_4F_4 EQU $94 ; X -HS_SILPH_CO_4F_5 EQU $95 ; X -HS_SILPH_CO_4F_6 EQU $96 ; X -HS_SILPH_CO_5F_1 EQU $97 -HS_SILPH_CO_5F_2 EQU $98 -HS_SILPH_CO_5F_3 EQU $99 -HS_SILPH_CO_5F_4 EQU $9A -HS_SILPH_CO_5F_5 EQU $9B ; X -HS_SILPH_CO_5F_6 EQU $9C ; X -HS_SILPH_CO_5F_7 EQU $9D ; X -HS_SILPH_CO_6F_1 EQU $9E -HS_SILPH_CO_6F_2 EQU $9F -HS_SILPH_CO_6F_3 EQU $A0 -HS_SILPH_CO_6F_4 EQU $A1 ; X -HS_SILPH_CO_6F_5 EQU $A2 ; X -HS_SILPH_CO_7F_1 EQU $A3 -HS_SILPH_CO_7F_2 EQU $A4 -HS_SILPH_CO_7F_3 EQU $A5 -HS_SILPH_CO_7F_4 EQU $A6 -HS_SILPH_CO_7F_5 EQU $A7 -HS_SILPH_CO_7F_6 EQU $A8 ; X -HS_SILPH_CO_7F_7 EQU $A9 ; X -HS_SILPH_CO_7F_8 EQU $AA ; X -HS_SILPH_CO_8F_1 EQU $AB -HS_SILPH_CO_8F_2 EQU $AC -HS_SILPH_CO_8F_3 EQU $AD -HS_SILPH_CO_9F_1 EQU $AE -HS_SILPH_CO_9F_2 EQU $AF -HS_SILPH_CO_9F_3 EQU $B0 -HS_SILPH_CO_10F_1 EQU $B1 -HS_SILPH_CO_10F_2 EQU $B2 -HS_SILPH_CO_10F_3 EQU $B3 ; X -HS_SILPH_CO_10F_4 EQU $B4 ; X -HS_SILPH_CO_10F_5 EQU $B5 ; X -HS_SILPH_CO_10F_6 EQU $B6 ; X -HS_SILPH_CO_11F_1 EQU $B7 -HS_SILPH_CO_11F_2 EQU $B8 -HS_SILPH_CO_11F_3 EQU $B9 -;HS_MAP_F4_1 EQU $BA -HS_MANSION_2_ITEM EQU $BB ; X -HS_MANSION_3_ITEM_1 EQU $BC ; X -HS_MANSION_3_ITEM_2 EQU $BD ; X -HS_MANSION_4_ITEM_1 EQU $BE ; X -HS_MANSION_4_ITEM_2 EQU $BF ; X -HS_MANSION_4_ITEM_3 EQU $C0 ; X -HS_MANSION_4_ITEM_4 EQU $C1 ; X -HS_MANSION_4_ITEM_5 EQU $C2 ; X -HS_SAFARI_ZONE_EAST_ITEM_1 EQU $C3 ; X -HS_SAFARI_ZONE_EAST_ITEM_2 EQU $C4 ; X -HS_SAFARI_ZONE_EAST_ITEM_3 EQU $C5 ; X -HS_SAFARI_ZONE_EAST_ITEM_4 EQU $C6 ; X -HS_SAFARI_ZONE_NORTH_ITEM_1 EQU $C7 ; X -HS_SAFARI_ZONE_NORTH_ITEM_2 EQU $C8 ; X -HS_SAFARI_ZONE_WEST_ITEM_1 EQU $C9 ; X -HS_SAFARI_ZONE_WEST_ITEM_2 EQU $CA ; X -HS_SAFARI_ZONE_WEST_ITEM_3 EQU $CB ; X -HS_SAFARI_ZONE_WEST_ITEM_4 EQU $CC ; X -HS_SAFARI_ZONE_CENTER_ITEM EQU $CD ; X -HS_UNKNOWN_DUNGEON_2_ITEM_1 EQU $CE ; X -HS_UNKNOWN_DUNGEON_2_ITEM_2 EQU $CF ; X -HS_UNKNOWN_DUNGEON_2_ITEM_3 EQU $D0 ; X -HS_MEWTWO EQU $D1 ; X -HS_UNKNOWN_DUNGEON_3_ITEM_1 EQU $D2 ; X -HS_UNKNOWN_DUNGEON_3_ITEM_2 EQU $D3 ; X -HS_VICTORY_ROAD_1_ITEM_1 EQU $D4 ; X -HS_VICTORY_ROAD_1_ITEM_2 EQU $D5 ; X -HS_CHAMPIONS_ROOM_OAK EQU $D6 -HS_SEAFOAM_ISLANDS_1_BOULDER_1 EQU $D7 -HS_SEAFOAM_ISLANDS_1_BOULDER_2 EQU $D8 -HS_SEAFOAM_ISLANDS_2_BOULDER_1 EQU $D9 -HS_SEAFOAM_ISLANDS_2_BOULDER_2 EQU $DA -HS_SEAFOAM_ISLANDS_3_BOULDER_1 EQU $DB -HS_SEAFOAM_ISLANDS_3_BOULDER_2 EQU $DC -HS_SEAFOAM_ISLANDS_4_BOULDER_1 EQU $DD -HS_SEAFOAM_ISLANDS_4_BOULDER_2 EQU $DE -HS_SEAFOAM_ISLANDS_4_BOULDER_3 EQU $DF -HS_SEAFOAM_ISLANDS_4_BOULDER_4 EQU $E0 -HS_SEAFOAM_ISLANDS_5_BOULDER_1 EQU $E1 -HS_SEAFOAM_ISLANDS_5_BOULDER_2 EQU $E2 -HS_ARTICUNO EQU $E3 ; X +const_value = 0 + + const HS_PALLET_TOWN_OAK ; 00 + const HS_LYING_OLD_MAN ; 01 + const HS_OLD_MAN ; 02 + const HS_MUSEUM_GUY ; 03 + const HS_GYM_GUY ; 04 + const HS_CERULEAN_RIVAL ; 05 + const HS_CERULEAN_ROCKET ; 06 + const HS_CERULEAN_GUARD_1 ; 07 + const HS_UNKNOWN_DUNGEON_GUY ; 08 + const HS_CERULEAN_GUARD_2 ; 09 + const HS_SAFFRON_CITY_1 ; 0A + const HS_SAFFRON_CITY_2 ; 0B + const HS_SAFFRON_CITY_3 ; 0C + const HS_SAFFRON_CITY_4 ; 0D + const HS_SAFFRON_CITY_5 ; 0E + const HS_SAFFRON_CITY_6 ; 0F + const HS_SAFFRON_CITY_7 ; 10 + const HS_SAFFRON_CITY_8 ; 11 + const HS_SAFFRON_CITY_9 ; 12 + const HS_SAFFRON_CITY_A ; 13 + const HS_SAFFRON_CITY_B ; 14 + const HS_SAFFRON_CITY_C ; 15 + const HS_SAFFRON_CITY_D ; 16 + const HS_SAFFRON_CITY_E ; 17 + const HS_SAFFRON_CITY_F ; 18 + const HS_ROUTE_2_ITEM_1 ; 19 X + const HS_ROUTE_2_ITEM_2 ; 1A X + const HS_ROUTE_4_ITEM ; 1B X + const HS_ROUTE_9_ITEM ; 1C X + const HS_ROUTE_12_SNORLAX ; 1D + const HS_ROUTE_12_ITEM_1 ; 1E X + const HS_ROUTE_12_ITEM_2 ; 1F X + const HS_ROUTE_15_ITEM ; 20 X + const HS_ROUTE_16_SNORLAX ; 21 + const HS_ROUTE_22_RIVAL_1 ; 22 + const HS_ROUTE_22_RIVAL_2 ; 23 + const HS_NUGGET_BRIDGE_GUY ; 24 + const HS_ROUTE_24_ITEM ; 25 X + const HS_ROUTE_25_ITEM ; 26 X + const HS_DAISY_SITTING ; 27 + const HS_DAISY_WALKING ; 28 + const HS_TOWN_MAP ; 29 + const HS_OAKS_LAB_RIVAL ; 2A + const HS_STARTER_BALL_1 ; 2B + const HS_STARTER_BALL_2 ; 2C + const HS_STARTER_BALL_3 ; 2D + const HS_OAKS_LAB_OAK_1 ; 2E + const HS_POKEDEX_1 ; 2F + const HS_POKEDEX_2 ; 30 + const HS_OAKS_LAB_OAK_2 ; 31 + const HS_VIRIDIAN_GYM_GIOVANNI ; 32 + const HS_VIRIDIAN_GYM_ITEM ; 33 X + const HS_OLD_AMBER ; 34 + const HS_UNKNOWN_DUNGEON_1_ITEM_1 ; 35 X + const HS_UNKNOWN_DUNGEON_1_ITEM_2 ; 36 X + const HS_UNKNOWN_DUNGEON_1_ITEM_3 ; 37 X + const HS_POKEMONTOWER_2_RIVAL ; 38 + const HS_POKEMONTOWER_3_ITEM ; 39 X + const HS_POKEMONTOWER_4_ITEM_1 ; 3A X + const HS_POKEMONTOWER_4_ITEM_2 ; 3B X + const HS_POKEMONTOWER_4_ITEM_3 ; 3C X + const HS_POKEMONTOWER_5_ITEM ; 3D X + const HS_POKEMONTOWER_6_ITEM_1 ; 3E X + const HS_POKEMONTOWER_6_ITEM_2 ; 3F X + const HS_POKEMONTOWER_7_ROCKET_1 ; 40 X + const HS_POKEMONTOWER_7_ROCKET_2 ; 41 X + const HS_POKEMONTOWER_7_ROCKET_3 ; 42 X + const HS_POKEMONTOWER_7_MR_FUJI ; 43 + const HS_LAVENDER_HOUSE_1_MR_FUJI ; 44 + const HS_CELADON_MANSION_5_GIFT ; 45 + const HS_GAME_CORNER_ROCKET ; 46 + const HS_FUCHSIA_HOUSE_2_ITEM ; 47 X + const HS_MANSION_1_ITEM_1 ; 48 X + const HS_MANSION_1_ITEM_2 ; 49 X + const HS_FIGHTING_DOJO_GIFT_1 ; 4A + const HS_FIGHTING_DOJO_GIFT_2 ; 4B + const HS_SILPH_CO_1F_1 ; 4C + const HS_VOLTORB_1 ; 4D X + const HS_VOLTORB_2 ; 4E X + const HS_VOLTORB_3 ; 4F X + const HS_ELECTRODE_1 ; 50 X + const HS_VOLTORB_4 ; 51 X + const HS_VOLTORB_5 ; 52 X + const HS_ELECTRODE_2 ; 53 X + const HS_VOLTORB_6 ; 54 X + const HS_ZAPDOS ; 55 X + const HS_POWER_PLANT_ITEM_1 ; 56 X + const HS_POWER_PLANT_ITEM_2 ; 57 X + const HS_POWER_PLANT_ITEM_3 ; 58 X + const HS_POWER_PLANT_ITEM_4 ; 59 X + const HS_POWER_PLANT_ITEM_5 ; 5A X + const HS_MOLTRES ; 5B X + const HS_VICTORY_ROAD_2_ITEM_1 ; 5C X + const HS_VICTORY_ROAD_2_ITEM_2 ; 5D X + const HS_VICTORY_ROAD_2_ITEM_3 ; 5E X + const HS_VICTORY_ROAD_2_ITEM_4 ; 5F X + const HS_VICTORY_ROAD_2_BOULDER ; 60 + const HS_BILL_POKEMON ; 61 + const HS_BILL_1 ; 62 + const HS_BILL_2 ; 63 + const HS_VIRIDIAN_FOREST_ITEM_1 ; 64 X + const HS_VIRIDIAN_FOREST_ITEM_2 ; 65 X + const HS_VIRIDIAN_FOREST_ITEM_3 ; 66 X + const HS_MT_MOON_1_ITEM_1 ; 67 X + const HS_MT_MOON_1_ITEM_2 ; 68 X + const HS_MT_MOON_1_ITEM_3 ; 69 X + const HS_MT_MOON_1_ITEM_4 ; 6A X + const HS_MT_MOON_1_ITEM_5 ; 6B X + const HS_MT_MOON_1_ITEM_6 ; 6C X + const HS_MT_MOON_3_FOSSIL_1 ; 6D + const HS_MT_MOON_3_FOSSIL_2 ; 6E + const HS_MT_MOON_3_ITEM_1 ; 6F X + const HS_MT_MOON_3_ITEM_2 ; 70 X + const HS_SS_ANNE_2_RIVAL ; 71 + const HS_SS_ANNE_8_ITEM ; 72 X + const HS_SS_ANNE_9_ITEM_1 ; 73 X + const HS_SS_ANNE_9_ITEM_2 ; 74 X + const HS_SS_ANNE_10_ITEM_1 ; 75 X + const HS_SS_ANNE_10_ITEM_2 ; 76 X + const HS_SS_ANNE_10_ITEM_3 ; 77 X + const HS_VICTORY_ROAD_3_ITEM_1 ; 78 X + const HS_VICTORY_ROAD_3_ITEM_2 ; 79 X + const HS_VICTORY_ROAD_3_BOULDER ; 7A + const HS_ROCKET_HIDEOUT_1_ITEM_1 ; 7B X + const HS_ROCKET_HIDEOUT_1_ITEM_2 ; 7C X + const HS_ROCKET_HIDEOUT_2_ITEM_1 ; 7D X + const HS_ROCKET_HIDEOUT_2_ITEM_2 ; 7E X + const HS_ROCKET_HIDEOUT_2_ITEM_3 ; 7F X + const HS_ROCKET_HIDEOUT_2_ITEM_4 ; 80 X + const HS_ROCKET_HIDEOUT_3_ITEM_1 ; 81 X + const HS_ROCKET_HIDEOUT_3_ITEM_2 ; 82 X + const HS_ROCKET_HIDEOUT_4_GIOVANNI ; 83 + const HS_ROCKET_HIDEOUT_4_ITEM_1 ; 84 X + const HS_ROCKET_HIDEOUT_4_ITEM_2 ; 85 X + const HS_ROCKET_HIDEOUT_4_ITEM_3 ; 86 X + const HS_ROCKET_HIDEOUT_4_ITEM_4 ; 87 + const HS_ROCKET_HIDEOUT_4_ITEM_5 ; 88 + const HS_SILPH_CO_2F_1 ; 89 XXX never (de)activated? + const HS_SILPH_CO_2F_2 ; 8A + const HS_SILPH_CO_2F_3 ; 8B + const HS_SILPH_CO_2F_4 ; 8C + const HS_SILPH_CO_2F_5 ; 8D + const HS_SILPH_CO_3F_1 ; 8E + const HS_SILPH_CO_3F_2 ; 8F + const HS_SILPH_CO_3F_ITEM ; 90 X + const HS_SILPH_CO_4F_1 ; 91 + const HS_SILPH_CO_4F_2 ; 92 + const HS_SILPH_CO_4F_3 ; 93 + const HS_SILPH_CO_4F_ITEM_1 ; 94 X + const HS_SILPH_CO_4F_ITEM_2 ; 95 X + const HS_SILPH_CO_4F_ITEM_3 ; 96 X + const HS_SILPH_CO_5F_1 ; 97 + const HS_SILPH_CO_5F_2 ; 98 + const HS_SILPH_CO_5F_3 ; 99 + const HS_SILPH_CO_5F_4 ; 9A + const HS_SILPH_CO_5F_ITEM_1 ; 9B X + const HS_SILPH_CO_5F_ITEM_2 ; 9C X + const HS_SILPH_CO_5F_ITEM_3 ; 9D X + const HS_SILPH_CO_6F_1 ; 9E + const HS_SILPH_CO_6F_2 ; 9F + const HS_SILPH_CO_6F_3 ; A0 + const HS_SILPH_CO_6F_ITEM_1 ; A1 X + const HS_SILPH_CO_6F_ITEM_2 ; A2 X + const HS_SILPH_CO_7F_1 ; A3 + const HS_SILPH_CO_7F_2 ; A4 + const HS_SILPH_CO_7F_3 ; A5 + const HS_SILPH_CO_7F_4 ; A6 + const HS_SILPH_CO_7F_RIVAL ; A7 + const HS_SILPH_CO_7F_ITEM_1 ; A8 X + const HS_SILPH_CO_7F_ITEM_2 ; A9 X + const HS_SILPH_CO_7F_8 ; AA XXX sprite doesn't exist + const HS_SILPH_CO_8F_1 ; AB + const HS_SILPH_CO_8F_2 ; AC + const HS_SILPH_CO_8F_3 ; AD + const HS_SILPH_CO_9F_1 ; AE + const HS_SILPH_CO_9F_2 ; AF + const HS_SILPH_CO_9F_3 ; B0 + const HS_SILPH_CO_10F_1 ; B1 + const HS_SILPH_CO_10F_2 ; B2 + const HS_SILPH_CO_10F_3 ; B3 XXX never (de)activated? + const HS_SILPH_CO_10F_ITEM_1 ; B4 X + const HS_SILPH_CO_10F_ITEM_2 ; B5 X + const HS_SILPH_CO_10F_ITEM_3 ; B6 X + const HS_SILPH_CO_11F_1 ; B7 + const HS_SILPH_CO_11F_2 ; B8 + const HS_SILPH_CO_11F_3 ; B9 + const HS_MAP_F4_1 ; BA XXX sprite doesn't exist + const HS_MANSION_2_ITEM ; BB X + const HS_MANSION_3_ITEM_1 ; BC X + const HS_MANSION_3_ITEM_2 ; BD X + const HS_MANSION_4_ITEM_1 ; BE X + const HS_MANSION_4_ITEM_2 ; BF X + const HS_MANSION_4_ITEM_3 ; C0 X + const HS_MANSION_4_ITEM_4 ; C1 X + const HS_MANSION_4_ITEM_5 ; C2 X + const HS_SAFARI_ZONE_EAST_ITEM_1 ; C3 X + const HS_SAFARI_ZONE_EAST_ITEM_2 ; C4 X + const HS_SAFARI_ZONE_EAST_ITEM_3 ; C5 X + const HS_SAFARI_ZONE_EAST_ITEM_4 ; C6 X + const HS_SAFARI_ZONE_NORTH_ITEM_1 ; C7 X + const HS_SAFARI_ZONE_NORTH_ITEM_2 ; C8 X + const HS_SAFARI_ZONE_WEST_ITEM_1 ; C9 X + const HS_SAFARI_ZONE_WEST_ITEM_2 ; CA X + const HS_SAFARI_ZONE_WEST_ITEM_3 ; CB X + const HS_SAFARI_ZONE_WEST_ITEM_4 ; CC X + const HS_SAFARI_ZONE_CENTER_ITEM ; CD X + const HS_UNKNOWN_DUNGEON_2_ITEM_1 ; CE X + const HS_UNKNOWN_DUNGEON_2_ITEM_2 ; CF X + const HS_UNKNOWN_DUNGEON_2_ITEM_3 ; D0 X + const HS_MEWTWO ; D1 X + const HS_UNKNOWN_DUNGEON_3_ITEM_1 ; D2 X + const HS_UNKNOWN_DUNGEON_3_ITEM_2 ; D3 X + const HS_VICTORY_ROAD_1_ITEM_1 ; D4 X + const HS_VICTORY_ROAD_1_ITEM_2 ; D5 X + const HS_CHAMPIONS_ROOM_OAK ; D6 + const HS_SEAFOAM_ISLANDS_1_BOULDER_1 ; D7 + const HS_SEAFOAM_ISLANDS_1_BOULDER_2 ; D8 + const HS_SEAFOAM_ISLANDS_2_BOULDER_1 ; D9 + const HS_SEAFOAM_ISLANDS_2_BOULDER_2 ; DA + const HS_SEAFOAM_ISLANDS_3_BOULDER_1 ; DB + const HS_SEAFOAM_ISLANDS_3_BOULDER_2 ; DC + const HS_SEAFOAM_ISLANDS_4_BOULDER_1 ; DD + const HS_SEAFOAM_ISLANDS_4_BOULDER_2 ; DE + const HS_SEAFOAM_ISLANDS_4_BOULDER_3 ; DF + const HS_SEAFOAM_ISLANDS_4_BOULDER_4 ; E0 + const HS_SEAFOAM_ISLANDS_5_BOULDER_1 ; E1 + const HS_SEAFOAM_ISLANDS_5_BOULDER_2 ; E2 + const HS_ARTICUNO ; E3 X diff --git a/scripts/silphco7.asm b/scripts/silphco7.asm index d4db9ebbff..23eb795c92 100755 --- a/scripts/silphco7.asm +++ b/scripts/silphco7.asm @@ -241,7 +241,7 @@ SilphCo7Script5: ; 51d25 (14:5d25) ld a, [wd730] bit 0, a ret nz - ld a, HS_SILPH_CO_7F_5 + ld a, HS_SILPH_CO_7F_RIVAL ld [wcc4d], a predef HideObject call PlayDefaultMusic From 0991bd3abed50f4d249da1ef38d77cd5cd39a77e Mon Sep 17 00:00:00 2001 From: "U-Daniel-PC\\Daniel" Date: Fri, 26 Sep 2014 09:26:18 -0400 Subject: [PATCH 033/100] A few static hide/show ids --- scripts/route20.asm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/route20.asm b/scripts/route20.asm index db4b999942..4ef57e232e 100755 --- a/scripts/route20.asm +++ b/scripts/route20.asm @@ -31,7 +31,13 @@ Route20Script_50cc6: ; 50cc6 (14:4cc6) jr .asm_50cdc .MissableObjectIDs: ; 50ce8 (14:4ce8) - db $D9,$DA,$DB,$DC,$DF,$E0,$FF + db HS_SEAFOAM_ISLANDS_2_BOULDER_1 + db HS_SEAFOAM_ISLANDS_2_BOULDER_2 + db HS_SEAFOAM_ISLANDS_3_BOULDER_1 + db HS_SEAFOAM_ISLANDS_3_BOULDER_2 + db HS_SEAFOAM_ISLANDS_4_BOULDER_3 + db HS_SEAFOAM_ISLANDS_4_BOULDER_4 + db $FF .asm_50cef ld a, [wd881] From 906bd59e778243f84cb6fa7b06ae48019fc5805a Mon Sep 17 00:00:00 2001 From: IIMarckus Date: Thu, 9 Oct 2014 00:14:18 -0600 Subject: [PATCH 034/100] Add Yellow player/rival names. --- engine/oak_speech2.asm | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/engine/oak_speech2.asm b/engine/oak_speech2.asm index 9d994047c6..6a0490f0a4 100755 --- a/engine/oak_speech2.asm +++ b/engine/oak_speech2.asm @@ -213,6 +213,22 @@ DefaultNamesRival: ; 6abe (1:6abe) db "@" ENDC +IF _YELLOW +DefaultNamesPlayer: + db "NEW NAME" + next "YELLOW" + next "ASH" + next "JACK" + db "@" + +DefaultNamesRival: + db "NEW NAME" + next "BLUE" + next "GARY" + next "JOHN" + db "@" +ENDC + Func_6ad6: ; 6ad6 (1:6ad6) ld b, a ld c, $0 @@ -246,6 +262,12 @@ DefaultNamesPlayerList: ; 6af2 (1:6af2) DefaultNamesRivalList: ; 6b08 (1:6b08) db "NEW NAME@RED@ASH@JACK@" ENDC +IF _YELLOW +DefaultNamesPlayerList: + db "NEW NAME@YELLOW@ASH@JACK@" +DefaultNamesRivalList: + db "NEW NAME@BLUE@GARY@JOHN@" +ENDC TextTerminator_6b20: ; 6b20 (1:6b20) db "@" From 6e14461fa6d5085349e4746b61c526f3c94be19f Mon Sep 17 00:00:00 2001 From: IIMarckus Date: Fri, 10 Oct 2014 01:46:06 -0600 Subject: [PATCH 035/100] Add a lot of Yellow text changes. --- data/trades.asm | 13 ++ engine/battle/core.asm | 4 + engine/menu/bills_pc.asm | 3 + engine/menu/pokedex.asm | 3 + preprocessor.py | 3 + text.asm | 170 +++++++++++++++++++++ text/maps/agatha.asm | 4 + text/maps/bills_house.asm | 7 + text/maps/blues_house.asm | 8 + text/maps/daycare_2.asm | 4 + text/maps/hall_of_fame.asm | 4 + text/maps/lance.asm | 4 + text/maps/mt_moon_1f.asm | 5 +- text/maps/mt_moon_b2f.asm | 24 ++- text/maps/museum_1f.asm | 4 + text/maps/museum_2f.asm | 16 +- text/maps/oaks_lab.asm | 201 ++++++++++++++++++++++++- text/maps/pewter_gym_2.asm | 37 +++++ text/maps/pewter_mart.asm | 4 + text/maps/pewter_pokecenter.asm | 16 +- text/maps/reds_house_1f.asm | 16 ++ text/maps/rocket_hideout_b4f.asm | 25 +++ text/maps/route_10.asm | 4 + text/maps/route_12.asm | 4 + text/maps/route_12_gate_upstairs.asm | 4 + text/maps/route_14.asm | 4 + text/maps/route_16.asm | 4 + text/maps/route_17.asm | 4 + text/maps/route_22.asm | 6 + text/maps/route_25.asm | 35 +++++ text/maps/route_3.asm | 5 + text/maps/route_6.asm | 36 +++++ text/maps/route_8.asm | 4 + text/maps/route_9.asm | 17 +++ text/maps/saffron_gates.asm | 8 + text/maps/school.asm | 9 +- text/maps/silph_co_10f.asm | 25 +++ text/maps/silph_co_11f.asm | 8 + text/maps/silph_co_2f.asm | 4 + text/maps/silph_co_5f_1.asm | 4 + text/maps/silph_co_7f.asm | 8 + text/maps/ss_anne_6.asm | 4 + text/maps/ss_anne_7.asm | 8 + text/maps/ss_anne_9.asm | 4 + text/maps/surf_house.asm | 99 ++++++++++++ text/maps/viridian_forest.asm | 40 +++++ text/maps/viridian_forest_entrance.asm | 12 +- text/maps/viridian_gym.asm | 8 + text/maps/viridian_mart.asm | 13 +- 49 files changed, 945 insertions(+), 11 deletions(-) create mode 100644 text/maps/surf_house.asm diff --git a/data/trades.asm b/data/trades.asm index 2593f01cf9..64215df296 100755 --- a/data/trades.asm +++ b/data/trades.asm @@ -1,5 +1,17 @@ TradeMons: ; 71b7b (1c:5b7b) ; givemonster, getmonster, textstring, nickname (11 bytes), 14 bytes total +IF _YELLOW + db LICKITUNG, DUGTRIO, 0,"GURIO@@@@@@" + db CLEFAIRY, MR_MIME, 0,"MILES@@@@@@" + db BUTTERFREE,BEEDRILL, 2,"STINGER@@@@" + db KANGASKHAN,MUK, 0,"STICKY@@@@@" + db MEW, MEW, 2,"BART@@@@@@@" + db TANGELA, PARASECT, 0,"SPIKE@@@@@@" + db PIDGEOT, PIDGEOT, 1,"MARTY@@@@@@" + db GOLDUCK, RHYDON, 1,"BUFFY@@@@@@" + db GROWLITHE, DEWGONG, 2,"CEZANNE@@@@" + db CUBONE, MACHOKE, 2,"RICKY@@@@@@" +ELSE db NIDORINO, NIDORINA, 0,"TERRY@@@@@@" db ABRA, MR_MIME, 0,"MARCEL@@@@@" db BUTTERFREE,BEEDRILL, 2,"CHIKUCHIKU@" @@ -10,3 +22,4 @@ TradeMons: ; 71b7b (1c:5b7b) db RAICHU, ELECTRODE, 1,"DORIS@@@@@@" db VENONAT, TANGELA, 2,"CRINKLES@@@" db NIDORAN_M, NIDORAN_F, 2,"SPOT@@@@@@@" +ENDC diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 263fafa1b4..128b735655 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -2954,7 +2954,11 @@ Func_3d4b6: ; 3d4b6 (f:54b6) jp Delay3 DisabledText: ; 3d555 (f:5555) +IF _YELLOW + db "Disabled!@" +ELSE db "disabled!@" +ENDC TypeText: ; 3d55f (f:555f) db "TYPE@" diff --git a/engine/menu/bills_pc.asm b/engine/menu/bills_pc.asm index f1a0e798bf..16fbd37675 100644 --- a/engine/menu/bills_pc.asm +++ b/engine/menu/bills_pc.asm @@ -345,6 +345,9 @@ BillsPCMenuText: ; 216e1 (8:56e1) next "DEPOSIT ", $4a next "RELEASE ", $4a next "CHANGE BOX" +IF _YELLOW + next "PRINT BOX" +ENDC next "SEE YA!" db "@" diff --git a/engine/menu/pokedex.asm b/engine/menu/pokedex.asm index 227728a0ca..2e5d676f68 100755 --- a/engine/menu/pokedex.asm +++ b/engine/menu/pokedex.asm @@ -366,6 +366,9 @@ PokedexMenuItemsText: ; 402af (10:42af) db "DATA" next "CRY" next "AREA" +IF _YELLOW + next "PRNT" +ENDC next "QUIT@" ; tests if a pokemon's bit is set in the seen or owned pokemon bit fields diff --git a/preprocessor.py b/preprocessor.py index ee22761236..6cd6ab05a7 100644 --- a/preprocessor.py +++ b/preprocessor.py @@ -176,6 +176,9 @@ "№": 0x74, +"′": 0x71, +"″": 0x73, + " ": 0x7F, "A": 0x80, "B": 0x81, diff --git a/text.asm b/text.asm index c6cd43e389..f230cf3efa 100644 --- a/text.asm +++ b/text.asm @@ -166,6 +166,13 @@ _OaksAideNoRoomText:: ; 802ec (20:42ec) text "." done +IF DEF(_YELLOW) +_NurseChanseyText:: + text "CHANSEY: Chaaan" + line "sey! + done +ENDC + INCLUDE "text/maps/viridian_forest.asm" INCLUDE "text/maps/mt_moon_1f.asm" INCLUDE "text/maps/mt_moon_b1f.asm" @@ -573,6 +580,12 @@ _CinnabarGymQuizIntroText:: ; 887b7 (22:47b7) line "Here we go!" prompt +IF DEF(_YELLOW) + text "#MON Quiz!" + line "Test your skill!" + done +ENDC + _CinnabarQuizQuestionsText1:: ; 8886d (22:486d) text "CATERPIE evolves" line "into BUTTERFREE?" @@ -834,6 +847,16 @@ _KabutopsFossilText:: ; 88fd5 (22:4fd5) cont "rare #MON." done +IF DEF(_YELLOW) +_FanClubPicture1Text:: + text "My cute RAPIDASH." + done + +_FanClubPicture2Text:: + text "My beloved FEAROW." + done +ENDC + _LinkCableHelpText1:: ; 89001 (22:5001) text "TRAINER TIPS" @@ -1172,6 +1195,12 @@ _GotAwayText:: ; 8981f (22:581f) text "Got away safely!" prompt +IF DEF(_YELLOW) +_RunAwayText:: + text "Hurry, get away!" + prompt +ENDC + _ItemsCantBeUsedHereText:: ; 89831 (22:5831) text "Items can't be" line "used here." @@ -1565,6 +1594,13 @@ _WhichFloorText:: ; 89dad (22:5dad) line "you want? " done +IF DEF(_YELLOW) +_SleepingPikachuText1:: + text "There isn't any" + line "response..." + prompt +ENDC + _PartyMenuNormalText:: ; 89dc8 (22:5dc8) text "Choose a #MON." done @@ -1580,7 +1616,11 @@ _PartyMenuBattleText:: ; 89df1 (22:5df1) done _PartyMenuUseTMText:: ; 89e08 (22:5e08) +IF DEF(_YELLOW) + text "Teach to which" +ELSE text "Use TM on which" +ENDC line "#MON?" done @@ -1752,6 +1792,13 @@ _AccessedHoFPCText:: ; 8a0f4 (22:60f4) line "OF FAME List." prompt +IF DEF(_YELLOW) +_SleepingPikachuText2:: + text "There isn't any" + line "response..." + prompt +ENDC + _SwitchOnText:: ; 0x8a131 text "Switch on!" prompt @@ -1805,6 +1852,14 @@ _CantTakeMonText:: ; 0x8a1f6 line "first." prompt +IF DEF(_YELLOW) +_PikachuUnhappyText:: + TX_RAM $cd6d + text "looks" + line "unhappy about it!" + prompt +ENDC + _ReleaseWhichMonText:: ; 0x8a228 text "Release which" line "#MON?" @@ -1926,6 +1981,111 @@ _WillBeTradedText:: ; 8a677 (22:6677) cont "be traded." done +IF DEF(_YELLOW) +_Colosseum3MonsText:: + text "You need 3 #MON" + line "to fight!" + prompt + +_ColosseumMewText:: + text "Sorry, MEW can't" + line "attend!" + prompt + +_ColosseumDifferentMonsText:: + text "Your #MON must" + line "all be different!" + prompt + +_ColosseumMaxL55Text:: + text "No #MON can" + line "exceed L55!" + prompt + +_ColosseumMinL50Text:: + text "All #MON must" + line "be at least L50!" + prompt + +_ColosseumTotalL155Text:: + text "Your total levels" + line "exceed 155!" + prompt + +_ColosseumMaxL30Text:: + text "No #MON can" + line "exceed L30!" + prompt + +_ColosseumMinL25Text:: + text "All #MON must" + line "be at least L25!" + prompt + +_ColosseumTotalL80Text:: + text "Your total levels" + line "exceed 80!" + prompt + +_ColosseumMaxL20Text:: + text "No #MON can" + line "exceed L20!" + prompt + +_ColosseumMinL15Text:: + text "All #MON must" + line "be at least L15!" + prompt + +_ColosseumTotalL50Text:: + text "Your total levels" + line "exceed 50!" + prompt + +_ColosseumHeightText:: + TX_RAM $CD6D + text " is over" + line "6′8″ tall!" + prompt + +_ColosseumWeightText:: + TX_RAM $CD6D + text " weighs" + line "over 44 pounds!" + prompt + +_ColosseumEvolvedText:: + TX_RAM $CD6D + text " is an" + line "evolved #MON!" + prompt + +_ColosseumIneligibleText:: + text "Your opponent is" + line "ineligible." + prompt + +_ColosseumWhereToText:: + text "Where would you" + line "like to go?" + prompt + +_ColosseumPleaseWaitText:: + text "OK, please wait" + line "just a moment." + prompt + +_ColosseumCanceledText:: + text "The link was" + line "canceled." + prompt + +_ColosseumVersionText:: + text "The game versions" + line "don't match." + prompt +ENDC + _Char00Text:: ; 8a696 (22:6696) TX_NUM $FF8C,1,2 text " ERROR." @@ -1934,6 +2094,13 @@ _Char00Text:: ; 8a696 (22:6696) _Char55Text:: ; 8a6a3 (22:66a3) text $4B,"@@" +IF DEF(_YELLOW) +_NoPokemonText:: + text "There are no" + line "#MON here!" + prompt +ENDC + INCLUDE "text/maps/digletts_cave_route_2_entrance.asm" INCLUDE "text/maps/viridian_forest_exit.asm" INCLUDE "text/maps/route_2_house.asm" @@ -1968,6 +2135,9 @@ INCLUDE "text/maps/route_16_gate_upstairs.asm" INCLUDE "text/maps/route_16_house.asm" INCLUDE "text/maps/route_18_gate.asm" INCLUDE "text/maps/route_18_gate_upstairs.asm" +IF DEF(_YELLOW) +INCLUDE "text/maps/surf_house.asm" +ENDC INCLUDE "text/maps/pokemon_league_gate.asm" INCLUDE "text/maps/victory_road_2f.asm" INCLUDE "text/maps/bills_house.asm" diff --git a/text/maps/agatha.asm b/text/maps/agatha.asm index cd0b1bb539..295a4d84e6 100644 --- a/text/maps/agatha.asm +++ b/text/maps/agatha.asm @@ -23,7 +23,11 @@ _AgathaBeforeBattleText:: ; 8686b (21:686b) done _AgathaEndBattleText:: ; 86970 (21:6970) +IF DEF(_YELLOW) + text "Woo-hoo! +ELSE text "Oh ho!" +ENDC line "You're something" cont "special, child!" prompt diff --git a/text/maps/bills_house.asm b/text/maps/bills_house.asm index 5963d7ea09..3ec1e3f320 100644 --- a/text/maps/bills_house.asm +++ b/text/maps/bills_house.asm @@ -1,3 +1,10 @@ +IF DEF(_YELLOW) +_BillsHouseDontLeaveText:: + text "Whoa, don't go" + line "anywhere, wait!" + done +ENDC + _BillsHouseText_1e865:: ; 8d267 (23:5267) text "Hiya! I'm a" line "#MON..." diff --git a/text/maps/blues_house.asm b/text/maps/blues_house.asm index 147b23fbf7..a5b155f2c9 100644 --- a/text/maps/blues_house.asm +++ b/text/maps/blues_house.asm @@ -29,11 +29,19 @@ _DaisyUseMapText:: done _BluesHouseText2:: +IF DEF(_YELLOW) + text "Spending time" + line "with your #MON" + cont "makes them more" + cont "friendly to you." + done +ELSE text "#MON are living" line "things! If they" cont "get tired, give" cont "them a rest!" done +ENDC _BluesHouseText3:: text "It's a big map!" diff --git a/text/maps/daycare_2.asm b/text/maps/daycare_2.asm index ac9720bab8..c6478a764e 100644 --- a/text/maps/daycare_2.asm +++ b/text/maps/daycare_2.asm @@ -3,7 +3,11 @@ _DayCareMText_56437:: ; 8c000 (23:4000) line "@@" _DayCareMText_5643b:: ; 8c013 (23:4013) +IF DEF(_YELLOW) + text "Come again." +ELSE text "come again." +ENDC done _DayCareMText_56440:: ; 8c020 (23:4020) diff --git a/text/maps/hall_of_fame.asm b/text/maps/hall_of_fame.asm index ab5b9b15b7..cb0cc6227f 100644 --- a/text/maps/hall_of_fame.asm +++ b/text/maps/hall_of_fame.asm @@ -1,6 +1,10 @@ _HallofFameRoomText1:: ; 85fb5 (21:5fb5) text "OAK: Er-hem!" +IF DEF(_YELLOW) + line "Congratulations," +ELSE line "Congratulations" +ENDC cont $52, "!" para "This floor is the" diff --git a/text/maps/lance.asm b/text/maps/lance.asm index 1da4e8f15f..35ef354636 100644 --- a/text/maps/lance.asm +++ b/text/maps/lance.asm @@ -1,6 +1,10 @@ _LanceBeforeBattleText:: ; 85d3c (21:5d3c) text "Ah! I heard about" +IF DEF(_YELLOW) + line "you, ", $52, "!" +ELSE line "you ", $52, "!" +ENDC para "I lead the ELITE" line "FOUR! You can" diff --git a/text/maps/mt_moon_1f.asm b/text/maps/mt_moon_1f.asm index ad9c859893..0577adf3cc 100644 --- a/text/maps/mt_moon_1f.asm +++ b/text/maps/mt_moon_1f.asm @@ -115,6 +115,9 @@ _MtMoon1AfterBattleText8:: ; 80901 (20:4901) _MtMoon1Text14:: ; 8093a (20:493a) text "Beware! ZUBAT is" +IF DEF(_YELLOW) + line "a bloodsucker!" +ELSE line "a blood sucker!" +ENDC done - diff --git a/text/maps/mt_moon_b2f.asm b/text/maps/mt_moon_b2f.asm index f8357f00a3..648238714e 100644 --- a/text/maps/mt_moon_b2f.asm +++ b/text/maps/mt_moon_b2f.asm @@ -1,3 +1,26 @@ +IF DEF(_YELLOW) +_MtMoonJessieJamesText1:: + text "Stop right there!@@" + +_MtMoonJessieJamesText2:: + text "That fossil is" + line "TEAM ROCKET's!" + + para "Surrender now, or" + line "prepare to fight!" + done + +_MtMoonJessieJamesText3:: + text "A" + line "brat beat us?" + prompt + +_MtMoonJessieJamesText4:: + text "TEAM ROCKET, blast" + line "off at the speed" + cont "of light!@@" +ENDC + _MtMoon3Text_49f24:: ; 8095e (20:495e) text "You want the" line "DOME FOSSIL?" @@ -120,4 +143,3 @@ _MtMoon3AfterBattleText5:: ; 80c46 (20:4c46) line "here long before" cont "people came." done - diff --git a/text/maps/museum_1f.asm b/text/maps/museum_1f.asm index f5f847d310..7371a3121a 100644 --- a/text/maps/museum_1f.asm +++ b/text/maps/museum_1f.asm @@ -72,7 +72,11 @@ _Museum1FText_5c28e:: ; 966b4 (25:66b4) para "But, my colleagues" line "just ignore me!" +IF DEF(_YELLOW) + para "So, I have a favor" +ELSE para "So I have a favor" +ENDC line "to ask!" para "Take this to a" diff --git a/text/maps/museum_2f.asm b/text/maps/museum_2f.asm index 7594c7976c..46238725e2 100644 --- a/text/maps/museum_2f.asm +++ b/text/maps/museum_2f.asm @@ -33,6 +33,21 @@ _Museum2FText5:: ; 96911 (25:6911) line "soon, I promise!" done +IF DEF(_YELLOW) +_Museum2FPikachuText1:: + text "Your PIKACHU looks" + line "untamed." + cont "May I have it for" + cont "my daughter?" + done + +_Museum2FPikachuText2:: + text "I'd like to get" + line "that PIKACHU off" + cont "you, but it's too" + cont "attached to you." +ENDC + _Museum2FText6:: ; 96933 (25:6933) text "SPACE SHUTTLE" line "COLUMBIA" @@ -43,4 +58,3 @@ _Museum2FText7:: ; 9694b (25:694b) line "fell on MT.MOON." cont "(MOON STONE?)" done - diff --git a/text/maps/oaks_lab.asm b/text/maps/oaks_lab.asm index 8b45742cac..58f55b859b 100644 --- a/text/maps/oaks_lab.asm +++ b/text/maps/oaks_lab.asm @@ -1,29 +1,60 @@ _OaksLabGaryText1:: ; 94d5b (25:4d5b) - text $53, ": Yo" - line $52, "! Gramps" + text $53,": Yo" + line $52,"! Gramps" cont "isn't around!" + +IF DEF(_YELLOW) + para "I ran here 'cos" + line "he said he had a" + cont "#MON for me." +ENDC done _OaksLabText40:: ; 94d79 (25:4d79) - text $53, ": Heh, I" +IF DEF(_YELLOW) + text $53,": Humph!" + line "I'll get a better" + cont "#MON than you!" + done +ELSE + text $53,": Heh, I" line "don't need to be" cont "greedy like you!" para "Go ahead and" line "choose, ", $52, "!" done +ENDC _OaksLabText41:: ; 94dbd (25:4dbd) - text $53, ": My" +IF DEF(_YELLOW) + text $53,": Heh, my" +ELSE + text $53,": My" +ENDC line "#MON looks a" cont "lot stronger." done _OaksLabText39:: ; 94ddf (25:4ddf) +IF DEF(_YELLOW) + text "That's a #" + line "BALL. There's a" + cont "#MON inside!" + done +ELSE text "Those are #" line "BALLs. They" cont "contain #MON!" done +ENDC + +IF DEF(_YELLOW) +_OaksLabPikachuText:: + text "OAK: Go ahead," + line "it's yours!" + done +ENDC _OaksLabCharmanderText:: ; 94e06 (25:4e06) text "So! You want the" @@ -70,14 +101,26 @@ _OaksLabText_1d2f5:: ; 94ef8 (25:4ef8) line "#MON appears," cont "your #MON can" cont "fight against it!" + +IF DEF(_YELLOW) + para "Afterward, go on" + line "to the next town." +ENDC done _OaksLabText_1d2fa:: ; 94f36 (25:4f36) +IF DEF(_YELLOW) + text "OAK: You should" + line "talk to it and" + cont "see how it feels." + done +ELSE text "OAK: ", $52, "," line "raise your young" cont "#MON by making" cont "it fight!" done +ENDC _OaksLabDeliverParcelText1:: ; 94f69 (25:4f69) text "OAK: Oh, ", $52, "!" @@ -103,7 +146,15 @@ _OaksLabDeliverParcelText2:: ; 9500f (25:500f) para "Ah! This is the" line "custom # BALL" cont "I ordered!" +IF DEF(_YELLOW) + cont "Thanks, ",$52,"!" + + para "By the way, I must" + line "ask you to do" + cont "something for me." +ELSE cont "Thank you!" +ENDC done _OaksLabAroundWorldText:: ; 95045 (25:5045) @@ -132,7 +183,12 @@ _OaksLabGivePokeballsText2:: ; 950f2 (25:50f2) line "#MON appears," cont "it's fair game." +IF DEF(_YELLOW) + para "Just like I showed" + line "you, throw a #" +ELSE para "Just throw a #" +ENDC line "BALL at it and try" line "to catch it!" @@ -188,6 +244,29 @@ _OaksLabRivalWaitingText:: ; 952bb (25:52bb) done _OaksLabChooseMonText:: ; 952df (25:52df) +IF DEF(_YELLOW) + text "OAK: Hmm? ",$53,"?" + line "Why are you here" + cont "already?" + + para "I said for you to" + line "come by later..." + + para "Ah, whatever!" + line "Just wait there." + + para "Look, ",$52,"! Do" + line "you see that ball" + cont "on the table?" + + para "It's called a #" + line "BALL. It holds a" + cont "#MON inside." + + para "You may have it!" + line "Go on, take it!" + done +ELSE text "OAK: ", $53, "?" line "Let me think..." @@ -214,6 +293,7 @@ _OaksLabChooseMonText:: ; 952df (25:52df) cont "but you can have" cont "one! Choose!" done +ENDC _OaksLabRivalInterjectionText:: ; 953dc (25:53dc) text $53, ": Hey!" @@ -222,10 +302,70 @@ _OaksLabRivalInterjectionText:: ; 953dc (25:53dc) done _OaksLabBePatientText:: ; 953fc (25:53fc) +IF DEF(_YELLOW) + text "OAK: Be patient," + line $53,", I'll give" + cont "you one later." + done +ELSE text "OAK: Be patient!" line $53, ", you can" cont "have one too!" done +ENDC + +IF DEF(_YELLOW) +_OaksLabRivalTakesText1:: + text $53,": No way!" + line $52,", I want" + cont "this #MON!" + prompt + +_OaksLabRivalTakesText2:: + text $53," snatched" + line "the #MON!@@" + +_OaksLabRivalTakesText3:: + text "OAK: ",$53,"! What" + line "are you doing?" + prompt + +_OaksLabRivalTakesText4:: + text $53,": Gramps, I" + line "want this one!" + prompt + +_OaksLabRivalTakesText5:: + text "OAK: But, I... Oh," + line "all right then." + cont "That #MON is" + cont "yours." + + para "I was going to" + line "give you one" + cont "anyway..." + + para $52,", come over" + line "here." + done + +_OaksLabOakGivesText:: + text "OAK: ",$52,", this" + line "is the #MON I" + cont "caught earlier." + + para "You can have it." + line "I caught it in" + cont "the wild and it's" + cont "not tame yet." + prompt + +_OaksLabReceivedText:: + text $52," received" + line "a " + TX_RAM $CD6D + text "!@@" +ENDC _OaksLabLeavingText:: ; 95427 (25:5427) text "OAK: Hey! Don't go" @@ -275,20 +415,64 @@ _OaksLabRivalToughenUpText:: ; 95502 (25:5502) line "Smell you later!" done +IF DEF(_YELLOW) +_OaksLabPikachuDislikesPokeballsText1:: + text "OAK: What?" + done + +_OaksLabPikachuDislikesPokeballsText2:: + text "OAK: Would you" + line "look at that!" + + para "It's odd, but it" + line "appears that your" + cont "PIKACHU dislikes" + cont "# BALLs." + + para "You should just" + line "keep it with you." + + para "That should make" + line "it happy!" + + para "You can talk to it" + line "and see how it" + cont "feels about you." + done +ENDC + _OaksLabText21:: ; 95551 (25:5551) text $53, ": Gramps!" done _OaksLabText22:: ; 9555d (25:555d) +IF DEF(_YELLOW) + text $53,": Gramps," + line "my #MON has" + cont "grown stronger!" + cont "Check it out!" + done +ELSE text $53, ": What did" line "you call me for?" done +ENDC _OaksLabText23:: ; 9557b (25:557b) +IF DEF(_YELLOW) + text "OAK: Ah, ",$53,"," + line "good timing!" + + para "I needed to ask" + line "both of you to do" + cont "something for me." + done +ELSE text "OAK: Oh right! I" line "have a request" cont "of you two." done +ENDC _OaksLabText24:: ; 955a8 (25:55a8) text "On the desk there" @@ -416,8 +600,13 @@ _OaksLabText_4421a:: ; 9596d (25:596d) done _OaksLabText_4421f:: ; 959b8 (25:59b8) +IF DEF(_YELLOW) + text "Oh! This is get-" + line "ting even better!" +ELSE text "Ho! This is geting" line "even better!" +ENDC done _OaksLabText_44224:: ; 959d9 (25:59d9) @@ -472,7 +661,11 @@ _OaksLabText_44247:: ; 95b39 (25:5b39) _OaksLabText_4424c:: ; 95b6f (25:5b6f) text "Your #DEX is" +IF DEF(_YELLOW) + line "fully complete!" +ELSE line "entirely complete!" +ENDC cont "Congratulations!" done diff --git a/text/maps/pewter_gym_2.asm b/text/maps/pewter_gym_2.asm index a503f75523..433fd649de 100644 --- a/text/maps/pewter_gym_2.asm +++ b/text/maps/pewter_gym_2.asm @@ -3,6 +3,23 @@ _PewterGymText_5c4a3:: ; 98000 (26:4000) line "kinds of trainers" cont "in the world!" +IF DEF(_YELLOW) + para "Some raise #MON" + line "for fights. Some" + cont "see them as pets." + + para "I'm in training to" + line "become a #MON" + cont "breeder." + + para "If you take your" + line "#MON training" + cont "seriously, go" + cont "visit the GYM in" + cont "CERULEAN and test" + cont "your abilities!" + done +ELSE para "You appear to be" line "very gifted as a" cont "#MON trainer!" @@ -11,6 +28,7 @@ _PewterGymText_5c4a3:: ; 98000 (26:4000) line "CERULEAN and test" cont "your abilities!" done +ENDC _TM34PreReceiveText:: ; 98092 (26:4092) text "Wait! Take this" @@ -72,7 +90,11 @@ _PewterGymText_5c4c1:: ; 98232 (26:4232) para "The technique" line "FLASH can now be" +IF DEF(_YELLOW) + cont "used anytime!" +ELSE cont "used any time!" +ENDC prompt _PewterGymBattleText1:: ; 982ae (26:42ae) @@ -141,3 +163,18 @@ _PewterGymText_5c529:: ; 9849f (26:449f) cont "champ material!" done +IF DEF(_YELLOW) +_PewterGymGuyText:: + text "All right! Let's" + line "get happening!" + + para "It will be tough" + line "for your PIKACHU" + cont "at this GYM!" + + para "Electric attacks" + line "are harmless to" + cont "BROCK's ground-" + cont "type #MON." + done +ENDC diff --git a/text/maps/pewter_mart.asm b/text/maps/pewter_mart.asm index a33974dbed..71760b7b77 100644 --- a/text/maps/pewter_mart.asm +++ b/text/maps/pewter_mart.asm @@ -1,5 +1,9 @@ _PewterMartText_74cc6:: ; 985ac (26:45ac) +IF DEF(_YELLOW) + text "A shady old man" +ELSE text "A shady, old man" +ENDC line "got me to buy" cont "this really weird" cont "fish #MON!" diff --git a/text/maps/pewter_pokecenter.asm b/text/maps/pewter_pokecenter.asm index 4493c079a7..114fed16c6 100644 --- a/text/maps/pewter_pokecenter.asm +++ b/text/maps/pewter_pokecenter.asm @@ -8,8 +8,22 @@ _PewterPokecenterText1:: ; 98704 (26:4704) para "Scram!" done +IF DEF(_YELLOW) +_PewterPokecenterText2:: + text "#MON CENTERS" + line "are wonderful!" + + para "They heal #MON" + line "completely." + + para "Even conditions" + line "like sleep, burn," + cont "poison and others" + cont "are cured." + done +ENDC + _PewterPokecenterText5:: ; 98744 (26:4744) text "JIGGLYPUFF: Puu" line "pupuu!" done - diff --git a/text/maps/reds_house_1f.asm b/text/maps/reds_house_1f.asm index 729c5b46c6..16cf512953 100644 --- a/text/maps/reds_house_1f.asm +++ b/text/maps/reds_house_1f.asm @@ -1,7 +1,11 @@ _MomWakeUpText:: text "MOM: Right." line "All boys leave" +IF DEF(_YELLOW) + cont "home someday." +ELSE cont "home some day." +ENDC cont "It said so on TV." para "PROF.OAK, next" @@ -10,10 +14,22 @@ _MomWakeUpText:: done _MomHealText1:: +IF DEF(_YELLOW) + text "MOM: ",$52,", if" + line "your drive your" + cont "#MON too hard," + cont "they'll dislike" + cont "you." + + para "You should take a" + line "rest." + prompt +ELSE text "MOM: ",$52,"!" line "You should take a" cont "quick rest." prompt +ENDC _MomHealText2:: text "MOM: Oh good!" diff --git a/text/maps/rocket_hideout_b4f.asm b/text/maps/rocket_hideout_b4f.asm index ecf01ec88c..e069e4a975 100644 --- a/text/maps/rocket_hideout_b4f.asm +++ b/text/maps/rocket_hideout_b4f.asm @@ -1,3 +1,28 @@ +IF DEF(_YELLOW) +_RocketHideoutJessieJamesText1:: + text "Not another step," + line "brat!@@" + +_RocketHideoutJessieJamesText2:: + text "How dare you" + line "humiliate us at" + cont "MT.MOON!" + + para "It's payback time," + line "you brat!" + done + +_RocketHideoutJessieJamesText3:: + text "Such" + line "a dreadful twerp!" + prompt + +_RocketHideoutJessieJamesText4:: + text "Looks like TEAM" + line "ROCKET's blasting" + cont "off again!@@" +ENDC + _RocketHideout4Text_4557a:: ; 8223e (20:623e) text "So! I must say, I" line "am impressed you" diff --git a/text/maps/route_10.asm b/text/maps/route_10.asm index f6e4e394e3..795f7e692d 100644 --- a/text/maps/route_10.asm +++ b/text/maps/route_10.asm @@ -33,7 +33,11 @@ _Route10AfterBattleText2:: ; 8e6f5 (23:66f5) done _Route10BattleText3:: ; 8e71c (23:671c) +IF DEF(_YELLOW) + text "Hi, kid, want to" +ELSE text "Hi kid, want to" +ENDC line "see my #MON?" done diff --git a/text/maps/route_12.asm b/text/maps/route_12.asm index ef71d2795c..12925104de 100644 --- a/text/maps/route_12.asm +++ b/text/maps/route_12.asm @@ -109,7 +109,11 @@ _Route12EndBattleText6:: ; 90318 (24:4318) _Route12AfterBattleText6:: ; 90329 (24:4329) text "It's all right." line "Losing doesn't" +IF DEF(_YELLOW) + cont "bug me anymore." +ELSE cont "bug me any more." +ENDC done _Route12BattleText7:: ; 90358 (24:4358) diff --git a/text/maps/route_12_gate_upstairs.asm b/text/maps/route_12_gate_upstairs.asm index 3d22e3894f..3e8fb60cb1 100644 --- a/text/maps/route_12_gate_upstairs.asm +++ b/text/maps/route_12_gate_upstairs.asm @@ -5,7 +5,11 @@ _TM39PreReceiveText:: ; 8c86b (23:486b) para "You can have this" line "TM. I don't need" +IF DEF(_YELLOW) + cont "it anymore..." +ELSE cont "it any more..." +ENDC prompt _ReceivedTM39Text:: ; 8c8c6 (23:48c6) diff --git a/text/maps/route_14.asm b/text/maps/route_14.asm index d58630a840..b542274ea8 100644 --- a/text/maps/route_14.asm +++ b/text/maps/route_14.asm @@ -10,7 +10,11 @@ _Route14EndBattleText1:: ; 9083f (24:483f) prompt _Route14AfterBattleText1:: ; 90851 (24:4851) +IF DEF(_YELLOW) + text "You have some HMs," +ELSE text "You have some HMs" +ENDC line "right? #MON" cont "can't ever forget" cont "those moves." diff --git a/text/maps/route_16.asm b/text/maps/route_16.asm index d98aaa12a6..ec77ec6fd3 100644 --- a/text/maps/route_16.asm +++ b/text/maps/route_16.asm @@ -19,7 +19,11 @@ _Route16BattleText2:: ; 910d7 (24:50d7) done _Route16EndBattleText2:: ; 910f1 (24:50f1) +IF DEF(_YELLOW) + text "Knock-" +ELSE text "Knock" +ENDC line "out!" prompt diff --git a/text/maps/route_17.asm b/text/maps/route_17.asm index d07c3a860f..b053b47339 100644 --- a/text/maps/route_17.asm +++ b/text/maps/route_17.asm @@ -133,7 +133,11 @@ _Route17AfterBattleText9:: ; 915dd (24:55dd) done _Route17BattleText10:: ; 91600 (24:5600) +IF DEF(_YELLOW) + text "Get lost, kid!" +ELSE text "Get lost kid!" +ENDC line "I'm bushed!" done diff --git a/text/maps/route_22.asm b/text/maps/route_22.asm index 5ce0b87944..9935ce80d7 100644 --- a/text/maps/route_22.asm +++ b/text/maps/route_22.asm @@ -59,9 +59,15 @@ _Route22RivalBeforeBattleText2:: ; 92450 (24:6450) line "the BADGEs too?" cont "That's cool!" +IF DEF(_YELLOW) + para "Then I'll whip" + line "you, ", $52, ", as" + cont "a warmup for" +ELSE para "Then I'll whip you" line $52, " as a" cont "warm up for" +ENDC cont "#MON LEAGUE!" para "Come on!" diff --git a/text/maps/route_25.asm b/text/maps/route_25.asm index fb65cad867..d73611f2df 100644 --- a/text/maps/route_25.asm +++ b/text/maps/route_25.asm @@ -1,3 +1,33 @@ +IF DEF(_YELLOW) +_Route25DamianText1:: + text "I'm not good at" + line "raising #MON." + + para "I should release" + line "my CHARMANDER" + cont "because I haven't" + cont "raised it well..." + + para "If you promise me" + line "you'll care for" + cont "it, it's yours." + done + +_Route25DamianText2:: + text "Take good care of" + line "my CHARMANDER!@@" + +_Route25DamianText3:: + text "Oh... I'd better" + line "release it then." + done + +_Route25DamianText4:: + text "How's CHARMANDER" + line "doing?" + done +ENDC + _Route25BattleText1:: ; 9421e (25:421e) text "Local trainers" line "come here to" @@ -56,8 +86,13 @@ _Route25BattleText4:: ; 94369 (25:4369) done _Route25EndBattleText4:: ; 94385 (25:4385) +IF DEF(_YELLOW) + text "I'm in" + line "a slump!" +ELSE text "I was in" line "bad condition!" +ENDC prompt _Route25AfterBattleText4:: ; 9439e (25:439e) diff --git a/text/maps/route_3.asm b/text/maps/route_3.asm index 248a11dd5f..95612425cb 100644 --- a/text/maps/route_3.asm +++ b/text/maps/route_3.asm @@ -66,8 +66,13 @@ _Route3BattleText4:: ; 8d924 (23:5924) _Route3EndBattleText4:: ; 8d944 (23:5944) text "If I" +IF DEF(_YELLOW) + line "had new #MON," + cont "I would've won!" +ELSE line "had new #MON I" cont "would've won!" +ENDC prompt _Route3AfterBattleText4:: ; 8d966 (23:5966) diff --git a/text/maps/route_6.asm b/text/maps/route_6.asm index 7d0a6097c4..3a54f4618f 100644 --- a/text/maps/route_6.asm +++ b/text/maps/route_6.asm @@ -1,3 +1,38 @@ +IF DEF(_YELLOW) +_Route6BattleText1:: + text "I'm doing this" + line "out of love." + cont "Leave me alone!" + done + +_Route6EndBattleText1:: + text "No," + line "this can't be..." + prompt + +_Route6AfterBattleText1:: + text "My love will leave" + line "me in disgust." + done + +_Route6BattleText2:: + text "I'm training for" + line "my love. Don't" + cont "bother me!" + done + +_Route6EndBattleText2:: + text "My" + line "textbook never..." + prompt + +_Route6AfterBattleText2:: + text "Now I understand," + line "#MON isn't" + cont "about calculated" + cont "numbers." + done +ELSE _Route6BattleText1:: ; 8dc38 (23:5c38) text "Who's there?" line "Quit listening in" @@ -24,6 +59,7 @@ _Route6EndBattleText2:: ; 8dcb3 (23:5cb3) text "Ugh!" line "I hate losing!" prompt +ENDC _Route6BattleText3:: ; 8dcc8 (23:5cc8) text "There aren't many" diff --git a/text/maps/route_8.asm b/text/maps/route_8.asm index 1f3f74fdce..62e2aff31a 100644 --- a/text/maps/route_8.asm +++ b/text/maps/route_8.asm @@ -104,7 +104,11 @@ _Route8EndBattleText7:: ; 8e116 (23:6116) prompt _Route8AfterBattleText7:: ; 8e12a (23:612a) +if DEF(_YELLOW) + text "SAFFRON's gate-" +ELSE text "SAFFRON's gate" +ENDC line "keeper won't let" cont "us through." cont "He's so mean!" diff --git a/text/maps/route_9.asm b/text/maps/route_9.asm index 978a5a3f66..353eb7792d 100644 --- a/text/maps/route_9.asm +++ b/text/maps/route_9.asm @@ -15,6 +15,23 @@ _Route9AfterBattleText1:: ; 8e2c8 (23:62c8) cont "dark tunnel ahead." done +IF DEF(_YELLOW) +_Route9BattleTextAJ:: + text "I aim to be the" + line "ultimate trainer!" + done + +_Route9EndBattleTextAJ:: + text "My" + line "SANDSHREW lost?" + prompt + +_Route9AfterBattleTextAJ:: + text "I'll restart my" + line "100-win streak" + cont "with SANDSHREW." +ENDC + _Route9BattleText2:: ; 8e2ff (23:62ff) text "Who's that walking" line "with those good" diff --git a/text/maps/saffron_gates.asm b/text/maps/saffron_gates.asm index 0212a7dd99..b7db175127 100644 --- a/text/maps/saffron_gates.asm +++ b/text/maps/saffron_gates.asm @@ -3,7 +3,11 @@ _SaffronGateText_1dfe7:: ; 8aa5c (22:6a5c) line "Gee, I'm thirsty," cont "though!" +IF DEF(_YELLOW) + para "Oh, wait there," +ELSE para "Oh wait there," +ENDC line "the road's closed." done @@ -18,7 +22,11 @@ _SaffronGateText_8aaa9:: ; 8aaa9 (22:6aa9) _SaffronGateText_1dff1:: ; 8aaef (22:6aef) db $0 para "..." +IF DEF(_YELLOW) + line "Glug, glug..." +ELSE line "Glug glug..." +ENDC cont "..." cont "Gulp..." cont "If you want to go" diff --git a/text/maps/school.asm b/text/maps/school.asm index ce0c017512..9bdd900498 100644 --- a/text/maps/school.asm +++ b/text/maps/school.asm @@ -4,6 +4,14 @@ _SchoolText1:: ; 95d15 (25:5d15) cont "my notes." done +IF DEF(_YELLOW) +_SchoolText3:: + text "Sis says #MON" + line "will become tame" + cont "if you treat them" + cont "nicely." +ENDC + _SchoolText2:: ; 95d40 (25:5d40) text "Okay!" @@ -11,4 +19,3 @@ _SchoolText2:: ; 95d40 (25:5d40) line "the blackboard" cont "carefully!" done - diff --git a/text/maps/silph_co_10f.asm b/text/maps/silph_co_10f.asm index a5a3877e97..75aa60039a 100644 --- a/text/maps/silph_co_10f.asm +++ b/text/maps/silph_co_10f.asm @@ -41,3 +41,28 @@ _SilphCo10AfterBattleText2:: ; 84e66 (21:4e66) cont "Then go on home!" done +IF DEF(_YELLOW) +_SilphCoJessieJamesText1:: + text "Hold it right" + line "there, brat!@@" + +_SilphCoJessieJamesText2:: + text "Our BOSS is in a" + line "meeting!" + + para "You better not" + line "disturb him!" + done + +_SilphCoJessieJamesText3:: + text "Like" + line "always..." + prompt + +_SilphCoJessieJamesText4:: + text "TEAM ROCKET, blast" + line "off at the speed" + cont "of light!" + + para "Again...@@" +ENDC diff --git a/text/maps/silph_co_11f.asm b/text/maps/silph_co_11f.asm index caacd757b8..3dbeee95a5 100644 --- a/text/maps/silph_co_11f.asm +++ b/text/maps/silph_co_11f.asm @@ -58,7 +58,11 @@ _SilphCo11Text2:: ; 8502f (21:502f) done _SilphCo11Text3:: ; 85075 (21:5075) +IF DEF(_YELLOW) + text "Ah, ", $52, "!" +ELSE text "Ah ", $52, "!" +ENDC line "So we meet again!" para "The PRESIDENT and" @@ -70,7 +74,11 @@ _SilphCo11Text3:: ; 85075 (21:5075) line "out of grown-up" cont "matters..." +IF DEF(_YELLOW) + para "or, experience a" +ELSE para "Or, experience a" +ENDC line "world of pain!" done diff --git a/text/maps/silph_co_2f.asm b/text/maps/silph_co_2f.asm index 8096d806e5..4437880c0c 100644 --- a/text/maps/silph_co_2f.asm +++ b/text/maps/silph_co_2f.asm @@ -72,7 +72,11 @@ _SilphCo2EndBattleText3:: ; 8260f (20:660f) prompt _SilphCo2AfterBattleText3:: ; 82617 (20:6617) +IF DEF(_YELLOW) + text "Diamond-shaped" +ELSE text "Diamond shaped" +ENDC line "tiles are" cont "teleport blocks!" diff --git a/text/maps/silph_co_5f_1.asm b/text/maps/silph_co_5f_1.asm index 8a406e677e..7435c91074 100644 --- a/text/maps/silph_co_5f_1.asm +++ b/text/maps/silph_co_5f_1.asm @@ -47,6 +47,10 @@ _SilphCo5AfterBattleText3:: ; 82a43 (20:6a43) _SilphCo5BattleText4:: ; 82a81 (20:6a81) text "Whaaat? There" line "shouldn't be any" +IF DEF(_YELLOW) + cont "children here!" +ELSE cont "children here?" +ENDC done diff --git a/text/maps/silph_co_7f.asm b/text/maps/silph_co_7f.asm index b3c92aaf8f..5b56ad4388 100644 --- a/text/maps/silph_co_7f.asm +++ b/text/maps/silph_co_7f.asm @@ -79,7 +79,11 @@ _SilphCo7Text_51e4b:: done _SilphCo7BattleText1:: ; 846ff (21:46ff) +IF DEF(_YELLOW) + text "Aha! I smell a" +ELSE text "Oh ho! I smell a" +ENDC line "little rat!" done @@ -167,7 +171,11 @@ _SilphCo7Text_51ec3:: ; 848a2 (21:48a2) done _SilphCo7Text_51ec8:: ; 8494a (21:494a) +IF DEF(_YELLOW) + text "Oh-oh!" +ELSE text "Oh ho!" +ENDC line "So, you are ready" cont "for BOSS ROCKET!" prompt diff --git a/text/maps/ss_anne_6.asm b/text/maps/ss_anne_6.asm index 5909c8b960..59828a5160 100644 --- a/text/maps/ss_anne_6.asm +++ b/text/maps/ss_anne_6.asm @@ -47,7 +47,11 @@ _SSAnne6Text_61807:: ; 81203 (20:5203) prompt _SSAnne6Text_6180c:: ; 81233 (20:5233) +IF DEF(_YELLOW) + text "Salade de Salmon!" +ELSE text "Salmon du Salad!" +ENDC para "Les guests may" line "gripe it's fish" diff --git a/text/maps/ss_anne_7.asm b/text/maps/ss_anne_7.asm index daef3e4a42..2a77046486 100644 --- a/text/maps/ss_anne_7.asm +++ b/text/maps/ss_anne_7.asm @@ -27,7 +27,11 @@ _ReceivingHM01Text:: ; 81347 (20:5347) para "Teach it to your" line "#MON and you" cont "can see it CUT" +IF DEF(_YELLOW) + cont "anytime!" +ELSE cont "any time!" +ENDC prompt _ReceivedHM01Text:: ; 8140d (20:540d) @@ -40,7 +44,11 @@ _SSAnne7Text_61932:: ; 8141c (20:541c) text "CAPTAIN: Whew!" para "Now that I'm not" +IF DEF(_YELLOW) + line "sick anymore, I" +ELSE line "sick any more, I" +ENDC cont "guess it's time." done diff --git a/text/maps/ss_anne_9.asm b/text/maps/ss_anne_9.asm index e133fc2cc8..c96a758183 100644 --- a/text/maps/ss_anne_9.asm +++ b/text/maps/ss_anne_9.asm @@ -1,5 +1,9 @@ _SSAnne9Text_61bf2:: ; 81799 (20:5799) +IF DEF(_YELLOW) + text "In all my travels," +ELSE text "In all my travels" +ENDC line "I've never seen" cont "any #MON sleep" cont "like this one!" diff --git a/text/maps/surf_house.asm b/text/maps/surf_house.asm new file mode 100644 index 0000000000..b43df5cf23 --- /dev/null +++ b/text/maps/surf_house.asm @@ -0,0 +1,99 @@ +SurfinDudeText1:: + text "Whoa!" + + para "Your PIKACHU knows" + line "how to SURF! So," + cont "I'm not alone..." + + para "Great! You earned" + line "the right to SURF" + cont "with the DUDE!" + + para "Give it a go?" + done + +SurfinDudeText2:: + text "Come SURF anytime," + line "my friend!" + done + +SurfinDudeText3:: + text "Wanna go SURF?" + done + +SurfinDudeText4:: + text "Dogs and burgers" + line "on special today!" + done + +BeachHousePikachuText:: + text "PIKACHU: Pikaa." + done + +BeachHouseSign1Text1:: + text "SURFIN' DUDE's" + line "scribbles..." + + para "When I shoot the" + line "tube, the tunes" + cont "hit the groove!" + done + +BeachHouseSign1Text2:: + text "30 years of waves!" + line "SURFIN' DUDE" + done + +BeachHouseSign2Text1:: + text "SURFING TIP 1!" + + para "After flips, line" + line "the board up with" + cont "a wave for a cool" + cont "effect!" + done + +BeachHouseSign2Text2:: + text "SUMMER BEACH HOUSE" + line "#MON welcome!" + done + +BeachHouseSign3Text1:: + text "SURFING TIP 2!" + + para "Pulling flips in" + line "a jump is totally" + cont "rad!" + done + +BeachHouseSign3Text2:: + text "The sea unites" + line "all in surfdom!" + done + +BeachHousePrinterText1:: + text "SUMMER BEACH HOUSE" + line "PRINTER, it says.@@" + +BeachHousePrinterText2:: + text "The Hi.Score is" + line "shown." + + para "PRINT it out?" + done + +BeachHousePrinterText3:: + text "SUMMER BEACH HOUSE" + line "PRINTER, it says." + + para "The Hi.Score is" + line "shown." + + para "PRINT it out?" + done + +BeachHousePrinterText4:: + text "PRINT completed.@@" + +BeachHousePrinterText5:: + text "PRINT error!@@" diff --git a/text/maps/viridian_forest.asm b/text/maps/viridian_forest.asm index 9b0f6d9965..aa6ab4abf4 100644 --- a/text/maps/viridian_forest.asm +++ b/text/maps/viridian_forest.asm @@ -9,7 +9,11 @@ _ViridianForestText1:: ; 8031d (20:431d) _ViridianForestBattleText1:: ; 80359 (20:4359) text "Hey! You have" line "#MON! Come on!" +IF DEF(_YELLOW) + cont "Let's battle 'em!" +ELSE cont "Let's battle'em!" +ENDC done _ViridianForestEndBattleText1:: ; 80387 (20:4387) @@ -62,6 +66,42 @@ _ViridianFrstAfterBattleText3:: ; 80475 (20:4475) cont "dropped!" done +if DEF(_YELLOW) +_ViridianForestBattleTextPikaGirl:: + text "Hi, do you have a" + line "PIKACHU?" + done + +_ViridianForestEndBattleTextPikaGirl:: + text "Oh no," + line "really?" + prompt + +_ViridianForestAfterBattleTextPikaGirl:: + text "I looked forever," + line "but I never found" + cont "a PIKACHU here!" + done + +_ViridianForestBattleTextSamurai:: + text "I'm gonna be the" + line "best. You just" + cont "can't beat me!" + done + +_ViridianForestEndBattleTextSamurai:: + text "After" + line "all I did..." + prompt + +_ViridianForestAfterBattleTextSamurai:: + text "A METAPOD is cool" + line "because its" + cont "attack is its" + cont "defense!" + done +ENDC + _ViridianForestText8:: ; 804c7 (20:44c7) text "I ran out of #" line "BALLs to catch" diff --git a/text/maps/viridian_forest_entrance.asm b/text/maps/viridian_forest_entrance.asm index dcba02b4ea..770f2b5b0a 100644 --- a/text/maps/viridian_forest_entrance.asm +++ b/text/maps/viridian_forest_entrance.asm @@ -6,9 +6,19 @@ _ViridianForestEntranceText1:: ; 8a868 (22:6868) done _ViridianForestEntranceText2:: ; 8a8ab (22:68ab) +IF DEF(_YELLOW) + text "You have to roam" + line "far to get new" + cont "kinds of #MON." + + para "Look for other" + line "types outside of" + cont "VIRIDIAN FOREST." + done +ELSE text "RATTATA may be" line "small, but its" cont "bite is wicked!" cont "Did you get one?" done - +ENDC diff --git a/text/maps/viridian_gym.asm b/text/maps/viridian_gym.asm index e1828c3206..10a2a5979f 100644 --- a/text/maps/viridian_gym.asm +++ b/text/maps/viridian_gym.asm @@ -38,7 +38,11 @@ _ViridianGymText_74ad9:: ; 95f2b (25:5f2b) cont "of #MON!" para "Let us meet again" +IF DEF(_YELLOW) + line "someday!" +ELSE line "some day!" +ENDC cont "Farewell!@@" _ViridianGymText12:: ; 95fcc (25:5fcc) @@ -205,7 +209,11 @@ _ViridianGymEndBattleText8:: ; 96403 (25:6403) prompt _ViridianGymAfterBattleText8:: ; 96412 (25:6412) +IF DEF(_YELLOW) + text "You can go on to" +ELSE text "You can go onto" +ENDC line "#MON LEAGUE" cont "only by defeating" cont "our GYM LEADER!" diff --git a/text/maps/viridian_mart.asm b/text/maps/viridian_mart.asm index 6cddaeaf3e..ed3343f1f7 100644 --- a/text/maps/viridian_mart.asm +++ b/text/maps/viridian_mart.asm @@ -38,12 +38,23 @@ ViridianMartParcelQuestText:: ; 95c79 (25:5c79) line "OAK's PARCEL!@@" _ViridianMartText2:: ; 95cd5 (25:5cd5) +IF DEF(_YELLOW) + text "This shop sells a" + line "lot of PARLYZ" + cont "HEALs." +ELSE text "This shop sells" line "many ANTIDOTEs." +ENDC done _ViridianMartText3:: ; 95cf6 (25:5cf6) +IF DEF(_YELLOW) + text "The shop finally" + line "has some POTIONs" + cont "in stock." +ELSE text "No! POTIONs are" line "all sold out." +ENDC done - From 00049b6f3986b4052f9e91c3cce7b26cf1499129 Mon Sep 17 00:00:00 2001 From: IIMarckus Date: Fri, 10 Oct 2014 02:01:47 -0600 Subject: [PATCH 036/100] Fix typo in previous. --- text/maps/agatha.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text/maps/agatha.asm b/text/maps/agatha.asm index 295a4d84e6..9e20b7aab9 100644 --- a/text/maps/agatha.asm +++ b/text/maps/agatha.asm @@ -24,7 +24,7 @@ _AgathaBeforeBattleText:: ; 8686b (21:686b) _AgathaEndBattleText:: ; 86970 (21:6970) IF DEF(_YELLOW) - text "Woo-hoo! + text "Woo-hoo!" ELSE text "Oh ho!" ENDC From bf6a1bab616bce9feaaa53409867140ffa33890d Mon Sep 17 00:00:00 2001 From: IIMarckus Date: Fri, 10 Oct 2014 03:44:52 -0600 Subject: [PATCH 037/100] =?UTF-8?q?Better=20document=20the=20=E2=80=9Ccan?= =?UTF-8?q?=20encounter=20Pok=C3=A9mon=20outside=20grass=E2=80=9D=20code.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pointed out by Lin. --- engine/battle/4_2.asm | 47 ++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/engine/battle/4_2.asm b/engine/battle/4_2.asm index aaada4925a..ef4798bd95 100755 --- a/engine/battle/4_2.asm +++ b/engine/battle/4_2.asm @@ -110,31 +110,36 @@ Func_13870: ; 13870 (4:7870) jr z, .asm_13905 ld [wd0db], a .asm_1389e +; determine if wild pokémon can appear where we’re standing. +; are we standing in grass/water? hlCoord 9, 9 ld c, [hl] ld a, [W_GRASSTILE] cp c - ld a, [W_GRASSRATE] ; W_GRASSRATE - jr z, .asm_138c4 - ld a, $14 + ld a, [W_GRASSRATE] + jr z, .CanEncounter + ld a, $14 ; in all tilesets with a water tile, this is its id cp c - ld a, [W_WATERRATE] ; wEnemyMon1Species - jr z, .asm_138c4 - ld a, [W_CURMAP] ; W_CURMAP - cp REDS_HOUSE_1F - jr c, .asm_13912 - ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET + ld a, [W_WATERRATE] + jr z, .CanEncounter +; even if not in grass/water, standing anywhere we can encounter pokémon +; so long as the map is “indoor” and has wild pokémon defined. +; …as long as it’s not Viridian Forest or Safari Zone. + ld a, [W_CURMAP] + cp REDS_HOUSE_1F ; is this an indoor map? + jr c, .CantEncounter + ld a, [W_CURMAPTILESET] cp FOREST ; Viridian Forest/Safari Zone - jr z, .asm_13912 - ld a, [W_GRASSRATE] ; W_GRASSRATE -.asm_138c4 + jr z, .CantEncounter + ld a, [W_GRASSRATE] +.CanEncounter ld b, a ld a, [hRandomAdd] cp b - jr nc, .asm_13912 + jr nc, .CantEncounter ld a, [hRandomSub] ld b, a - ld hl, WildMonEncounterSlotChances ; $7918 + ld hl, WildMonEncounterSlotChances .asm_138d0 ld a, [hli] cp b @@ -143,27 +148,27 @@ Func_13870: ; 13870 (4:7870) jr .asm_138d0 .asm_138d7 ld c, [hl] - ld hl, W_GRASSMONS ; wd888 + ld hl, W_GRASSMONS aCoord 8, 9 cp $14 jr nz, .asm_138e5 - ld hl, W_WATERMONS ; wd8a5 (aliases: wEnemyMon1HP) + ld hl, W_WATERMONS .asm_138e5 ld b, $0 add hl, bc ld a, [hli] - ld [W_CURENEMYLVL], a ; W_CURENEMYLVL + ld [W_CURENEMYLVL], a ld a, [hl] ld [wcf91], a ld [wEnemyMonSpecies2], a ld a, [wd0db] and a jr z, .asm_13916 - ld a, [wPartyMon1Level] ; wPartyMon1Level + ld a, [wPartyMon1Level] ld b, a - ld a, [W_CURENEMYLVL] ; W_CURENEMYLVL + ld a, [W_CURENEMYLVL] cp b - jr c, .asm_13912 + jr c, .CantEncounter jr .asm_13916 .asm_13905 ld [wd0db], a @@ -171,7 +176,7 @@ Func_13870: ; 13870 (4:7870) ld [H_DOWNARROWBLINKCNT2], a ; $ff8c call EnableAutoTextBoxDrawing call DisplayTextID -.asm_13912 +.CantEncounter ld a, $1 and a ret From 008cface5253f5e3e786daea365d9528a50e8dbf Mon Sep 17 00:00:00 2001 From: IIMarckus Date: Thu, 16 Oct 2014 00:12:44 -0600 Subject: [PATCH 038/100] Minor comment/label improvements in Cinnabar Lab. --- engine/predefs.asm | 2 +- scripts/lab4.asm | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/engine/predefs.asm b/engine/predefs.asm index b73c485af0..b21ff8842d 100755 --- a/engine/predefs.asm +++ b/engine/predefs.asm @@ -80,7 +80,7 @@ PredefPointers:: ; 4fe79 (13:7e79) add_predef LoadTilesetHeader add_predef LearnMoveFromLevelUp add_predef LearnMove - add_predef IsItemInBag_ ; 1C, used in Pokémon Tower + add_predef IsItemInBag_ dbw $03,CheckForHiddenObjectOrBookshelfOrCardKeyDoor ; for these two, the bank number is actually 0 dbw $03,GiveItem add_predef ChangeBGPalColor0_4Frames diff --git a/scripts/lab4.asm b/scripts/lab4.asm index a1df338769..c2d8d3048e 100755 --- a/scripts/lab4.asm +++ b/scripts/lab4.asm @@ -6,14 +6,16 @@ Lab4TextPointers: ; 75d34 (1d:5d34) dw Lab4Text2 Lab4Script_75d38: ; 75d38 (1d:5d38) +; construct a list of all fossils in the player's bag + xor a ld [wcd37], a ld de, wcc5b ld hl, FossilsList -.asm_75d42 +.loop ld a, [hli] and a - jr z, .asm_75d64 + jr z, .done push hl push de ld [wd11e], a @@ -23,7 +25,9 @@ Lab4Script_75d38: ; 75d38 (1d:5d38) pop hl ld a, b and a - jr z, .asm_75d42 + jr z, .loop + + ; A fossil's in the bag ld a, [wd11e] ld [de], a inc de @@ -31,8 +35,8 @@ Lab4Script_75d38: ; 75d38 (1d:5d38) ld hl, wcd37 inc [hl] pop hl - jr .asm_75d42 -.asm_75d64 + jr .loop +.done ld a, $ff ld [de], a ret @@ -75,7 +79,7 @@ Lab4Text1: ; 75d6c (1d:5d6c) set 2, [hl] ld a, [W_FOSSILMON] ld b, a - ld c, $1e + ld c, 30 call GivePokemon jr nc, .asm_75d93 ; 0x75db9 $d8 ld hl, wd7a3 From a3d3f8324a670aad8bf1348b65192544c8ab2d9f Mon Sep 17 00:00:00 2001 From: IIMarckus Date: Fri, 17 Oct 2014 02:42:32 -0600 Subject: [PATCH 039/100] Kill version.asm. --- audio/sfx/sfx_1f_5d.asm | 4 +- constants.asm | 2 - data/baseStats/alakazam.asm | 9 ++--- data/baseStats/butterfree.asm | 7 ++-- data/baseStats/chansey.asm | 7 ++-- data/baseStats/charizard.asm | 7 ++-- data/baseStats/diglett.asm | 7 ++-- data/baseStats/dugtrio.asm | 7 ++-- data/baseStats/eevee.asm | 7 ++-- data/baseStats/flareon.asm | 7 ++-- data/baseStats/gyarados.asm | 13 +++---- data/baseStats/jolteon.asm | 7 ++-- data/baseStats/kadabra.asm | 9 ++--- data/baseStats/marowak.asm | 11 +++--- data/baseStats/primeape.asm | 4 +- data/baseStats/vaporeon.asm | 7 ++-- data/baseStats/venomoth.asm | 9 ++--- data/baseStats/venonat.asm | 13 +++---- data/mapObjects/route19.asm | 7 ++-- data/prize_mon_levels.asm | 4 +- data/prizes.asm | 16 ++++---- data/sgb_border.asm | 20 +++++----- data/super_palettes.asm | 16 ++++---- data/title_mons.asm | 6 +-- data/trades.asm | 2 +- data/trainer_moves.asm | 7 +++- data/trainer_parties.asm | 56 +++++++++++++-------------- data/wildPokemon/mansion1.asm | 6 +-- data/wildPokemon/mansion2.asm | 8 ++-- data/wildPokemon/mansion3.asm | 8 ++-- data/wildPokemon/mansionb1.asm | 9 ++--- data/wildPokemon/mtmoon1.asm | 21 +++++----- data/wildPokemon/mtmoonb1.asm | 25 ++++++------ data/wildPokemon/mtmoonb2.asm | 25 ++++++------ data/wildPokemon/pokemontower3.asm | 18 ++++----- data/wildPokemon/pokemontower4.asm | 18 ++++----- data/wildPokemon/pokemontower5.asm | 26 ++++++------- data/wildPokemon/pokemontower6.asm | 26 ++++++------- data/wildPokemon/pokemontower7.asm | 27 ++++++------- data/wildPokemon/powerplant.asm | 33 +++++++--------- data/wildPokemon/rocktunnel1.asm | 30 +++++++------- data/wildPokemon/rocktunnel2.asm | 31 +++++++-------- data/wildPokemon/route1.asm | 25 ++++++------ data/wildPokemon/route10.asm | 6 +-- data/wildPokemon/route11.asm | 6 +-- data/wildPokemon/route12.asm | 6 +-- data/wildPokemon/route13.asm | 6 +-- data/wildPokemon/route14.asm | 6 +-- data/wildPokemon/route15.asm | 6 +-- data/wildPokemon/route16.asm | 26 ++++++------- data/wildPokemon/route17.asm | 25 ++++++------ data/wildPokemon/route18.asm | 25 ++++++------ data/wildPokemon/route2.asm | 33 ++++++++-------- data/wildPokemon/route21.asm | 25 ++++++------ data/wildPokemon/route22.asm | 6 +-- data/wildPokemon/route23.asm | 35 ++++++++--------- data/wildPokemon/route24.asm | 8 ++-- data/wildPokemon/route25.asm | 8 ++-- data/wildPokemon/route3.asm | 25 ++++++------ data/wildPokemon/route4.asm | 6 +-- data/wildPokemon/route5.asm | 8 ++-- data/wildPokemon/route6.asm | 8 ++-- data/wildPokemon/route7.asm | 8 ++-- data/wildPokemon/route8.asm | 8 ++-- data/wildPokemon/route9.asm | 6 +-- data/wildPokemon/safarizone1.asm | 10 ++--- data/wildPokemon/safarizone2.asm | 42 ++++++++++---------- data/wildPokemon/safarizone3.asm | 8 ++-- data/wildPokemon/safarizonecenter.asm | 8 ++-- data/wildPokemon/seafoamisland1.asm | 8 ++-- data/wildPokemon/seafoamislandb1.asm | 8 ++-- data/wildPokemon/seafoamislandb2.asm | 8 ++-- data/wildPokemon/seafoamislandb3.asm | 8 ++-- data/wildPokemon/seafoamislandb4.asm | 8 ++-- data/wildPokemon/unknowndungeon1.asm | 34 ++++++++-------- data/wildPokemon/unknowndungeon2.asm | 30 +++++++------- data/wildPokemon/unknowndungeonb1.asm | 30 +++++++------- data/wildPokemon/victoryroad1.asm | 25 ++++++------ data/wildPokemon/victoryroad2.asm | 25 ++++++------ data/wildPokemon/victoryroad3.asm | 25 ++++++------ data/wildPokemon/viridianforest.asm | 31 +++++++-------- data/wild_mons.asm | 2 +- engine/battle/animations.asm | 4 +- engine/battle/core.asm | 2 +- engine/intro.asm | 4 +- engine/menu/bills_pc.asm | 2 +- engine/menu/pokedex.asm | 2 +- engine/oak_speech2.asm | 12 +++--- engine/slot_machine.asm | 4 +- engine/titlescreen.asm | 12 +++--- main.asm | 4 +- text/credits_text.asm | 4 +- version.asm | 11 ------ 93 files changed, 603 insertions(+), 671 deletions(-) delete mode 100644 version.asm diff --git a/audio/sfx/sfx_1f_5d.asm b/audio/sfx/sfx_1f_5d.asm index 297f826d68..f0606032c3 100644 --- a/audio/sfx/sfx_1f_5d.asm +++ b/audio/sfx/sfx_1f_5d.asm @@ -1,6 +1,6 @@ SFX_1f_5d_Ch1: ; 7c45e (1f:445e) duty 2 -IF _RED +IF DEF(_RED) unknownsfx0x20 4, 244, 0, 7 unknownsfx0x20 3, 228, 128, 6 unknownsfx0x20 3, 228, 192, 6 @@ -18,7 +18,7 @@ ENDC SFX_1f_5d_Ch2: ; 7c475 (1f:4475) duty 2 -IF _RED +IF DEF(_RED) unknownsfx0x20 4, 8, 0, 0 unknownsfx0x20 3, 212, 1, 7 unknownsfx0x20 3, 196, 129, 6 diff --git a/constants.asm b/constants.asm index b427e3c705..68d1fb3ad6 100644 --- a/constants.asm +++ b/constants.asm @@ -1,5 +1,3 @@ -INCLUDE "version.asm" - INCLUDE "macros.asm" INCLUDE "hram.asm" diff --git a/data/baseStats/alakazam.asm b/data/baseStats/alakazam.asm index dfea0c683c..2ee79e6f00 100755 --- a/data/baseStats/alakazam.asm +++ b/data/baseStats/alakazam.asm @@ -14,13 +14,12 @@ dw AlakazamPicFront dw AlakazamPicBack ; attacks known at lvl 0 db TELEPORT -IF !_YELLOW - db CONFUSION - db DISABLE -ENDC -IF _YELLOW +IF DEF(_YELLOW) db KINESIS db 0 +ELSE + db CONFUSION + db DISABLE ENDC db 0 db 3 ; growth rate diff --git a/data/baseStats/butterfree.asm b/data/baseStats/butterfree.asm index 1c9231f024..593d5f7847 100755 --- a/data/baseStats/butterfree.asm +++ b/data/baseStats/butterfree.asm @@ -25,10 +25,9 @@ db %00111000 db %11110000 db %01000011 db %00101000 -IF !_YELLOW - db %00000010 -ENDC -IF _YELLOW +IF DEF(_YELLOW) db %01000010 +ELSE + db %00000010 ENDC db 0 ; padding diff --git a/data/baseStats/chansey.asm b/data/baseStats/chansey.asm index 351de4cf54..130a3d0008 100755 --- a/data/baseStats/chansey.asm +++ b/data/baseStats/chansey.asm @@ -14,11 +14,10 @@ dw ChanseyPicFront dw ChanseyPicBack ; attacks known at lvl 0 db POUND -IF !_YELLOW - db DOUBLESLAP -ENDC -IF _YELLOW +IF DEF(_YELLOW) db TAIL_WHIP +ELSE + db DOUBLESLAP ENDC db 0 db 0 diff --git a/data/baseStats/charizard.asm b/data/baseStats/charizard.asm index b6f651755d..5cbecb91c6 100755 --- a/data/baseStats/charizard.asm +++ b/data/baseStats/charizard.asm @@ -25,10 +25,9 @@ db %01001111 db %11001110 db %11100011 db %00001000 -IF !_YELLOW - db %00100110 -ENDC -IF _YELLOW +IF DEF(_YELLOW) db %00101110 +ELSE + db %00100110 ENDC db 0 ; padding diff --git a/data/baseStats/diglett.asm b/data/baseStats/diglett.asm index 7e8a3bbb4f..4944572bf8 100755 --- a/data/baseStats/diglett.asm +++ b/data/baseStats/diglett.asm @@ -25,10 +25,9 @@ db %00001000 db %11001110 db %00000010 db %10001000 -IF !_YELLOW - db %00000010 -ENDC -IF _YELLOW +IF DEF(_YELLOW) db %00000110 +ELSE + db %00000010 ENDC db 0 ; padding diff --git a/data/baseStats/dugtrio.asm b/data/baseStats/dugtrio.asm index dfdd0eb9a1..0c4bad3b66 100755 --- a/data/baseStats/dugtrio.asm +++ b/data/baseStats/dugtrio.asm @@ -25,10 +25,9 @@ db %00001000 db %11001110 db %00000010 db %10001000 -IF !_YELLOW - db %00000010 -ENDC -IF _YELLOW +IF DEF(_YELLOW) db %00000110 +ELSE + db %00000010 ENDC db 0 ; padding diff --git a/data/baseStats/eevee.asm b/data/baseStats/eevee.asm index 3632eef13c..978aa4bb40 100755 --- a/data/baseStats/eevee.asm +++ b/data/baseStats/eevee.asm @@ -14,11 +14,10 @@ dw EeveePicFront dw EeveePicBack ; attacks known at lvl 0 db TACKLE -IF !_YELLOW - db SAND_ATTACK -ENDC -IF _YELLOW +IF DEF(_YELLOW) db TAIL_WHIP +ELSE + db SAND_ATTACK ENDC db 0 db 0 diff --git a/data/baseStats/flareon.asm b/data/baseStats/flareon.asm index 219c7e7c53..ce4a8f0aac 100755 --- a/data/baseStats/flareon.asm +++ b/data/baseStats/flareon.asm @@ -14,11 +14,10 @@ dw FlareonPicFront dw FlareonPicBack ; attacks known at lvl 0 db TACKLE -IF !_YELLOW - db SAND_ATTACK -ENDC -IF _YELLOW +IF DEF(_YELLOW) db TAIL_WHIP +ELSE + db SAND_ATTACK ENDC db QUICK_ATTACK db EMBER diff --git a/data/baseStats/gyarados.asm b/data/baseStats/gyarados.asm index 0d23564f1d..c9e6dc31c4 100755 --- a/data/baseStats/gyarados.asm +++ b/data/baseStats/gyarados.asm @@ -13,17 +13,16 @@ INCBIN "pic/bmon/gyarados.pic",0,1 ; 77, sprite dimensions dw GyaradosPicFront dw GyaradosPicBack ; attacks known at lvl 0 -IF !_YELLOW -db BITE -db DRAGON_RAGE -db LEER -db HYDRO_PUMP -ENDC -IF _YELLOW +IF DEF(_YELLOW) db TACKLE db 0 db 0 db 0 +ELSE +db BITE +db DRAGON_RAGE +db LEER +db HYDRO_PUMP ENDC db 5 ; growth rate ; learnset diff --git a/data/baseStats/jolteon.asm b/data/baseStats/jolteon.asm index d9ef0440ba..5dc3532aba 100755 --- a/data/baseStats/jolteon.asm +++ b/data/baseStats/jolteon.asm @@ -14,11 +14,10 @@ dw JolteonPicFront dw JolteonPicBack ; attacks known at lvl 0 db TACKLE -IF !_YELLOW - db SAND_ATTACK -ENDC -IF _YELLOW +IF DEF(_YELLOW) db TAIL_WHIP +ELSE + db SAND_ATTACK ENDC db QUICK_ATTACK db THUNDERSHOCK diff --git a/data/baseStats/kadabra.asm b/data/baseStats/kadabra.asm index 1f1fe61a64..85ee8a3515 100755 --- a/data/baseStats/kadabra.asm +++ b/data/baseStats/kadabra.asm @@ -14,13 +14,12 @@ dw KadabraPicFront dw KadabraPicBack ; attacks known at lvl 0 db TELEPORT -IF !_YELLOW - db CONFUSION - db DISABLE -ENDC -IF _YELLOW +IF DEF(_YELLOW) DB KINESIS db 0 +ELSE + db CONFUSION + db DISABLE ENDC db 0 db 3 ; growth rate diff --git a/data/baseStats/marowak.asm b/data/baseStats/marowak.asm index 3b101fde44..64bfb0d638 100755 --- a/data/baseStats/marowak.asm +++ b/data/baseStats/marowak.asm @@ -14,15 +14,14 @@ dw MarowakPicFront dw MarowakPicBack ; attacks known at lvl 0 db BONE_CLUB -IF !_YELLOW - db GROWL - db LEER - db FOCUS_ENERGY -ENDC -IF _YELLOW +IF DEF(_YELLOW) db TAIL_WHIP db 0 db 0 +ELSE + db GROWL + db LEER + db FOCUS_ENERGY ENDC db 0 ; growth rate ; learnset diff --git a/data/baseStats/primeape.asm b/data/baseStats/primeape.asm index f88511df0d..eeab800b95 100755 --- a/data/baseStats/primeape.asm +++ b/data/baseStats/primeape.asm @@ -14,12 +14,12 @@ dw PrimeapePicFront dw PrimeapePicBack ; attacks known at lvl 0 db SCRATCH -IF !_YELLOW +IF !DEF(_YELLOW) db LEER ENDC db KARATE_CHOP db FURY_SWIPES -IF _YELLOW +IF DEF(_YELLOW) db LOW_KICK ENDC db 0 ; growth rate diff --git a/data/baseStats/vaporeon.asm b/data/baseStats/vaporeon.asm index 33ccc5174f..ed4b7a1e6c 100755 --- a/data/baseStats/vaporeon.asm +++ b/data/baseStats/vaporeon.asm @@ -14,11 +14,10 @@ dw VaporeonPicFront dw VaporeonPicBack ; attacks known at lvl 0 db TACKLE -IF !_YELLOW - db SAND_ATTACK -ENDC -IF _YELLOW +IF DEF(_YELLOW) db TAIL_WHIP +ELSE + db SAND_ATTACK ENDC db QUICK_ATTACK db WATER_GUN diff --git a/data/baseStats/venomoth.asm b/data/baseStats/venomoth.asm index 0a4d446159..f38be71c25 100755 --- a/data/baseStats/venomoth.asm +++ b/data/baseStats/venomoth.asm @@ -15,13 +15,12 @@ dw VenomothPicBack ; attacks known at lvl 0 db TACKLE db DISABLE -IF !_YELLOW - db POISONPOWDER - db LEECH_LIFE -ENDC -IF _YELLOW +IF DEF(_YELLOW) db SUPERSONIC db CONFUSION +ELSE + db POISONPOWDER + db LEECH_LIFE ENDC db 0 ; growth rate ; learnset diff --git a/data/baseStats/venonat.asm b/data/baseStats/venonat.asm index 4543a7303a..62e8aaef40 100755 --- a/data/baseStats/venonat.asm +++ b/data/baseStats/venonat.asm @@ -22,17 +22,16 @@ db 0 ; growth rate db %00100000 db %00000011 db %00111000 -IF !_YELLOW - db %11010000 - db %00000011 - db %00101000 - db %00000010 -ENDC -IF _YELLOW +IF DEF(_YELLOW) db %11110000 db %01000011 db %00101000 db %00100010 +ELSE + db %11010000 + db %00000011 + db %00101000 + db %00000010 ENDC db 0 ; padding diff --git a/data/mapObjects/route19.asm b/data/mapObjects/route19.asm index 806e92caf2..8ce41558e6 100755 --- a/data/mapObjects/route19.asm +++ b/data/mapObjects/route19.asm @@ -1,11 +1,10 @@ Route19Object: ; 0x54e9a (size=87) db $43 ; border block - IF _YELLOW + IF DEF(_YELLOW) db $1 ; warps db $9, $5, $0, $f8 ; SURF_HOUSE - ENDC - IF !_YELLOW + ELSE db $0 ; warps ENDC @@ -25,6 +24,6 @@ Route19Object: ; 0x54e9a (size=87) db SPRITE_SWIMMER, $2c + 4, $a + 4, $ff, $d0, TRAINER | $a, BEAUTY + $C8, $e ; warp-to - IF _YELLOW + IF DEF(_YELLOW) EVENT_DISP ROUTE_19_WIDTH, $9, $5 ; SURF_HOUSE ENDC diff --git a/data/prize_mon_levels.asm b/data/prize_mon_levels.asm index 6b10eb2f32..1437649c58 100755 --- a/data/prize_mon_levels.asm +++ b/data/prize_mon_levels.asm @@ -1,5 +1,5 @@ PrizeMonLevelDictionary: ; 5298a (14:698a) -IF _RED +IF DEF(_RED) db ABRA,9 db CLEFAIRY,8 db NIDORINA,17 @@ -8,7 +8,7 @@ IF _RED db SCYTHER,25 db PORYGON,26 ENDC -IF _BLUE +IF DEF(_BLUE) db ABRA,6 db CLEFAIRY,12 db NIDORINO,17 diff --git a/data/prizes.asm b/data/prizes.asm index 1fab54fce8..92736715da 100755 --- a/data/prizes.asm +++ b/data/prizes.asm @@ -14,19 +14,19 @@ NoThanksText: ; 5284f (14:684f) PrizeMenuMon1Entries: ; 52859 (14:6859) db ABRA db CLEFAIRY -IF _RED +IF DEF(_RED) db NIDORINA ENDC -IF _BLUE +IF DEF(_BLUE) db NIDORINO ENDC db "@" PrizeMenuMon1Cost: ; 5285d (14:685d) -IF _RED +IF DEF(_RED) db $01,$80 db $05,$00 ENDC -IF _BLUE +IF DEF(_BLUE) db $01,$20 db $07,$50 ENDC @@ -34,23 +34,23 @@ ENDC db "@" PrizeMenuMon2Entries: ; 52864 (14:6864) -IF _RED +IF DEF(_RED) db DRATINI db SCYTHER ENDC -IF _BLUE +IF DEF(_BLUE) db PINSIR db DRATINI ENDC db PORYGON db "@" PrizeMenuMon2Cost: ; 52868 (14:6868) -IF _RED +IF DEF(_RED) db $28,$00 db $55,$00 db $99,$99 ENDC -IF _BLUE +IF DEF(_BLUE) db $25,$00 db $46,$00 db $65,$00 diff --git a/data/sgb_border.asm b/data/sgb_border.asm index 5a0bbb2dc4..e1da84acf3 100755 --- a/data/sgb_border.asm +++ b/data/sgb_border.asm @@ -1,20 +1,20 @@ BorderPalettes: ; 72788 (1c:6788) -IF _RED +IF DEF(_RED) INCBIN "gfx/red/sgbborder.map" ENDC -IF _BLUE +IF DEF(_BLUE) INCBIN "gfx/blue/sgbborder.map" ENDC ds $100 -IF _RED +IF DEF(_RED) RGB 30,29,29 ; PAL_SGB1 RGB 25,22,25 RGB 25,17,21 RGB 24,14,12 ENDC -IF _BLUE +IF DEF(_BLUE) RGB 0,0,0 ; PAL_SGB1 (the first color is not defined, but if used, turns up as 30,29,29... o_O) RGB 10,17,26 RGB 5,9,20 @@ -23,13 +23,13 @@ ENDC ds $18 -IF _RED +IF DEF(_RED) RGB 30,29,29 ; PAL_SGB2 RGB 22,31,16 RGB 27,20,6 RGB 15,15,15 ENDC -IF _BLUE +IF DEF(_BLUE) RGB 30,29,29 ; PAL_SGB2 RGB 27,11,6 RGB 5,9,20 @@ -38,13 +38,13 @@ ENDC ds $18 -IF _RED +IF DEF(_RED) RGB 30,29,29 ; PAL_SGB3 RGB 31,31,17 RGB 18,21,29 RGB 15,15,15 ENDC -IF _BLUE +IF DEF(_BLUE) RGB 30,29,29 ; PAL_SGB3 RGB 12,15,11 RGB 5,9,20 @@ -54,9 +54,9 @@ ENDC ds $18 SGBBorderGraphics: ; 72fe8 (1c:6fe8) -IF _RED +IF DEF(_RED) INCBIN "gfx/red/sgbborder.2bpp" ENDC -IF _BLUE +IF DEF(_BLUE) INCBIN "gfx/blue/sgbborder.2bpp" ENDC diff --git a/data/super_palettes.asm b/data/super_palettes.asm index 6ab708be66..c1afb00390 100755 --- a/data/super_palettes.asm +++ b/data/super_palettes.asm @@ -52,13 +52,13 @@ SuperPalettes: ; 72660 (1c:6660) RGB 20,26,31 RGB 17,23,10 RGB 3,2,2 -IF _RED +IF DEF(_RED) RGB 31,29,31 ; PAL_LOGO1 RGB 30,30,17 RGB 17,23,10 RGB 21,0,4 ENDC -IF _BLUE +IF DEF(_BLUE) RGB 31,29,31 ; PAL_LOGO1 RGB 30,30,17 RGB 21,0,4 @@ -118,28 +118,28 @@ ENDC RGB 3,2,2 RGB 31,29,31 ; PAL_SLOTS2 RGB 31,31,17 -IF _RED +IF DEF(_RED) RGB 25,17,21 ENDC -IF _BLUE +IF DEF(_BLUE) RGB 16,19,29 ENDC RGB 3,2,2 RGB 31,29,31 ; PAL_SLOTS3 RGB 22,31,16 -IF _RED +IF DEF(_RED) RGB 25,17,21 ENDC -IF _BLUE +IF DEF(_BLUE) RGB 16,19,29 ENDC RGB 3,2,2 RGB 31,29,31 ; PAL_SLOTS4 -IF _RED +IF DEF(_RED) RGB 16,19,29 RGB 25,17,21 ENDC -IF _BLUE +IF DEF(_BLUE) RGB 25,17,21 RGB 16,19,29 ENDC diff --git a/data/title_mons.asm b/data/title_mons.asm index 2781b78dbe..abcf1bb4d6 100755 --- a/data/title_mons.asm +++ b/data/title_mons.asm @@ -1,6 +1,6 @@ TitleMons: ; 4588 (1:4588) ; mons on the title screen are randomly chosen from here -IF _RED +IF DEF(_RED) db CHARMANDER db SQUIRTLE db BULBASAUR @@ -18,7 +18,7 @@ IF _RED db PONYTA db MAGIKARP ENDC -IF _GREEN +IF DEF(_GREEN) db BULBASAUR db CHARMANDER db SQUIRTLE @@ -36,7 +36,7 @@ IF _GREEN db PONYTA db MAGIKARP ENDC -IF _BLUE +IF DEF(_BLUE) db SQUIRTLE db CHARMANDER db BULBASAUR diff --git a/data/trades.asm b/data/trades.asm index 64215df296..b761fecf31 100755 --- a/data/trades.asm +++ b/data/trades.asm @@ -1,6 +1,6 @@ TradeMons: ; 71b7b (1c:5b7b) ; givemonster, getmonster, textstring, nickname (11 bytes), 14 bytes total -IF _YELLOW +IF DEF(_YELLOW) db LICKITUNG, DUGTRIO, 0,"GURIO@@@@@@" db CLEFAIRY, MR_MIME, 0,"MILES@@@@@@" db BUTTERFREE,BEEDRILL, 2,"STINGER@@@@" diff --git a/data/trainer_moves.asm b/data/trainer_moves.asm index 61a3d6500c..432f0fed30 100755 --- a/data/trainer_moves.asm +++ b/data/trainer_moves.asm @@ -1,3 +1,4 @@ +IF !DEF(YELLOW) LoneMoves: ; 39d22 (e:5d22) ; these are used for gym leaders. ; this is not automatic! you have to write the number you want to W_LONEATTACKNO @@ -31,12 +32,14 @@ TeamMoves: ; 39d32 (e:5d32) db LANCE,BARRIER db $FF -if _YELLOW -; different format from above. +ELSE +; yellow has its own format. ; entry ≔ trainerclass, trainerid, moveset+, 0 ; moveset ≔ partymon, partymon'smove, moveid +LoneMoves: +TeamMoves: db BUG_CATCHER,$f db 2,2,TACKLE db 2,3,STRING_SHOT diff --git a/data/trainer_parties.asm b/data/trainer_parties.asm index 5b60bb2988..b121efc08f 100755 --- a/data/trainer_parties.asm +++ b/data/trainer_parties.asm @@ -33,11 +33,11 @@ YoungsterData: ; 39d99 (e:5d99) db 17,RATTATA,RATTATA,RATICATE,0 db 18,NIDORAN_M,NIDORINO,0 db 17,SPEAROW,RATTATA,RATTATA,SPEAROW,0 -if _YELLOW +if DEF(_YELLOW) db 24,SANDSHREW,0 endc BugCatcherData: ; 39dce (e:5dce) -if _YELLOW +if DEF(_YELLOW) db 7,CATERPIE,CATERPIE,0 db 6,METAPOD,CATERPIE,METAPOD,0 db 10,CATERPIE,0 @@ -57,7 +57,7 @@ endc db 18,METAPOD,CATERPIE,VENONAT,0 db 19,BEEDRILL,BEEDRILL,0 db 20,CATERPIE,WEEDLE,VENONAT,0 -if _YELLOW +if DEF(_YELLOW) db 8,CATERPIE,METAPOD,0 endc LassData: ; 39e0c (e:5e0c) @@ -72,14 +72,14 @@ LassData: ; 39e0c (e:5e0c) db 15,NIDORAN_M,NIDORAN_F,0 db 13,ODDISH,PIDGEY,ODDISH,0 db 18,PIDGEY,NIDORAN_F,0 -if _YELLOW +if DEF(_YELLOW) db 20,JIGGLYPUFF,0 else db 18,RATTATA,PIKACHU,0 endc db 23,NIDORAN_F,NIDORINA,0 db 24,MEOWTH,MEOWTH,MEOWTH,0 -if _YELLOW +if DEF(_YELLOW) db 19,PIDGEY,RATTATA,NIDORAN_F,MEOWTH,NIDORAN_M,0 else db 19,PIDGEY,RATTATA,NIDORAN_M,MEOWTH,PIKACHU,0 @@ -87,7 +87,7 @@ endc db 22,CLEFAIRY,CLEFAIRY,0 db 23,BELLSPROUT,WEEPINBELL,0 db 23,ODDISH,GLOOM,0 -if _YELLOW +if DEF(_YELLOW) db 6,NIDORAN_F,NIDORAN_M,0 endc SailorData: ; 39e58 (e:5e58) @@ -98,13 +98,13 @@ SailorData: ; 39e58 (e:5e58) db 18,TENTACOOL,STARYU,0 db 17,HORSEA,HORSEA,HORSEA,0 db 20,MACHOP,0 -if _YELLOW +if DEF(_YELLOW) db 24,MAGNEMITE,0 else db 21,PIKACHU,PIKACHU,0 endc JrTrainerMData: ; 39e78 (e:5e78) -if _YELLOW +if DEF(_YELLOW) db 9,DIGLETT,SANDSHREW,0 else db 11,DIGLETT,SANDSHREW,0 @@ -117,12 +117,12 @@ endc db 21,GROWLITHE,CHARMANDER,0 db 19,RATTATA,DIGLETT,EKANS,SANDSHREW,0 db 29,NIDORAN_M,NIDORINO,0 -if _YELLOW +if DEF(_YELLOW) db 16,WEEPINBELL,0 endc JrTrainerFData: ; 39e9d (e:5e9d) db 19,GOLDEEN,0 -if _YELLOW +if DEF(_YELLOW) db 16,ODDISH,BELLSPROUT,0 else db 16,RATTATA,PIKACHU,0 @@ -131,7 +131,7 @@ endc db 22,BULBASAUR,0 db 18,ODDISH,BELLSPROUT,ODDISH,BELLSPROUT,0 db 23,MEOWTH,0 -if _YELLOW +if DEF(_YELLOW) db 20,JIGGLYPUFF,CLEFAIRY,0 else db 20,PIKACHU,CLEFAIRY,0 @@ -140,7 +140,7 @@ endc db 21,JIGGLYPUFF,PIDGEY,MEOWTH,0 db 22,ODDISH,BULBASAUR,0 db 24,BULBASAUR,IVYSAUR,0 -if _YELLOW +if DEF(_YELLOW) db 24,PIDGEY,MEOWTH,RATTATA,PIDGEY,MEOWTH,0 else db 24,PIDGEY,MEOWTH,RATTATA,PIKACHU,MEOWTH,0 @@ -153,7 +153,7 @@ endc db 20,MEOWTH,ODDISH,PIDGEY,0 db 19,PIDGEY,RATTATA,RATTATA,BELLSPROUT,0 db 28,GLOOM,ODDISH,ODDISH,0 -if _YELLOW +if DEF(_YELLOW) db 29,PIDGEY,PIDGEOTTO,0 else db 29,PIKACHU,RAICHU,0 @@ -161,7 +161,7 @@ endc db 33,CLEFAIRY,0 db 29,BELLSPROUT,ODDISH,TANGELA,0 db 30,TENTACOOL,HORSEA,SEEL,0 -if _YELLOW +if DEF(_YELLOW) db 20,CUBONE,0 endc PokemaniacData: ; 39f09 (e:5f09) @@ -282,7 +282,7 @@ BeautyData: ; 3a0d1 (e:60d1) db 21,ODDISH,BELLSPROUT,ODDISH,BELLSPROUT,0 db 24,BELLSPROUT,BELLSPROUT,0 db 26,EXEGGCUTE,0 -if _YELLOW +if DEF(_YELLOW) db 27,RATTATA,VULPIX,RATTATA,0 else db 27,RATTATA,PIKACHU,RATTATA,0 @@ -304,7 +304,7 @@ PsychicData: ; 3a115 (e:6115) db 33,SLOWPOKE,SLOWPOKE,SLOWBRO,0 db 38,SLOWBRO,0 RockerData: ; 3a127 (e:6127) -if _YELLOW +if DEF(_YELLOW) db 20,VOLTORB,VOLTORB,VOLTORB,0 else db 20,VOLTORB,MAGNEMITE,VOLTORB,0 @@ -355,7 +355,7 @@ BlackbeltData: ; 3a1be (e:61be) db 38,MACHOKE,MACHOP,MACHOKE,0 db 43,MACHOKE,MACHOP,MACHOKE,0 Green1Data: ; 3a1e4 (e:61e4) -if _YELLOW +if DEF(_YELLOW) db 5,EEVEE,0 db $FF,9,SPEAROW,8,EEVEE,0 db $FF,18,SPEAROW,15,SANDSHREW,15,RATTATA,17,EEVEE,0 @@ -391,7 +391,7 @@ ScientistData: ; 3a241 (e:6241) db 33,MAGNEMITE,MAGNETON,VOLTORB,0 db 34,MAGNEMITE,ELECTRODE,0 GiovanniData: ; 3a27e (e:627e) -if _YELLOW +if DEF(_YELLOW) db $FF,25,ONIX,24,RHYHORN,29,PERSIAN,0 db $FF,37,NIDORINO,35,PERSIAN,37,RHYHORN,41,NIDOQUEEN,0 db $FF,50,DUGTRIO,53,PERSIAN,53,NIDOQUEEN,55,NIDOKING,55,RHYDON,0 @@ -442,7 +442,7 @@ RocketData: ; 3a29c (e:629c) db 33,MACHOKE,0 db 25,RATTATA,RATTATA,ZUBAT,RATTATA,EKANS,0 db 32,CUBONE,DROWZEE,MAROWAK,0 -if _YELLOW +if DEF(_YELLOW) JessieJamesData: db 14,EKANS,MEOWTH,KOFFING,0 db 25,KOFFING,MEOWTH,EKANS,0 @@ -476,7 +476,7 @@ CooltrainerFData: ; 3a385 (e:6385) BrunoData: ; 3a3a9 (e:63a9) db $FF,53,ONIX,55,HITMONCHAN,55,HITMONLEE,56,ONIX,58,MACHAMP,0 BrockData: ; 3a3b5 (e:63b5) -if _YELLOW +if DEF(_YELLOW) db $FF,10,GEODUDE,12,ONIX,0 else db $FF,12,GEODUDE,14,ONIX,0 @@ -484,31 +484,31 @@ endc MistyData: ; 3a3bb (e:63bb) db $FF,18,STARYU,21,STARMIE,0 LtSurgeData: ; 3a3c1 (e:63c1) -if _YELLOW +if DEF(_YELLOW) db $FF,28,RAICHU,0 else db $FF,21,VOLTORB,18,PIKACHU,24,RAICHU,0 endc ErikaData: ; 3a3c9 (e:63c9) -if _YELLOW +if DEF(_YELLOW) db $FF,30,TANGELA,32,WEEPINBELL,32,GLOOM,0 else db $FF,29,VICTREEBEL,24,TANGELA,29,VILEPLUME,0 endc KogaData: ; 3a3d1 (e:63d1) -if _YELLOW +if DEF(_YELLOW) db $FF,44,VENONAT,46,VENONAT,48,VENONAT,50,VENOMOTH,0 else db $FF,37,KOFFING,39,MUK,37,KOFFING,43,WEEZING,0 endc BlaineData: ; 3a3db (e:63db) -if _YELLOW +if DEF(_YELLOW) db $FF,48,NINETALES,50,RAPIDASH,54,ARCANINE,0 else db $FF,42,GROWLITHE,40,PONYTA,42,RAPIDASH,47,ARCANINE,0 endc SabrinaData: ; 3a3e5 (e:63e5) -if _YELLOW +if DEF(_YELLOW) db $FF,50,ABRA,50,KADABRA,50,ALAKAZAM,0 else db $FF,38,KADABRA,37,MR_MIME,38,VENOMOTH,43,ALAKAZAM,0 @@ -516,7 +516,7 @@ endc GentlemanData: ; 3a3ef (e:63ef) db 18,GROWLITHE,GROWLITHE,0 db 19,NIDORAN_M,NIDORAN_F,0 -if _YELLOW +if DEF(_YELLOW) db 22,VOLTORB,MAGNEMITE,0 else db 23,PIKACHU,0 @@ -524,7 +524,7 @@ endc db 48,PRIMEAPE,0 db 17,GROWLITHE,PONYTA,0 Green2Data: ; 3a401 (e:6401) -if _YELLOW +if DEF(_YELLOW) db $FF,19,SPEAROW,16,RATTATA,18,SANDSHREW,20,EEVEE,0 db $FF,25,FEAROW,23,SHELLDER,22,VULPIX,20,SANDSHREW,25,EEVEE,0 db $FF,25,FEAROW,23,MAGNEMITE,22,SHELLDER,20,SANDSHREW,25,EEVEE,0 @@ -550,7 +550,7 @@ else db $FF,47,PIDGEOT,45,RHYHORN,45,EXEGGCUTE,47,GYARADOS,50,ALAKAZAM,53,CHARIZARD,0 endc Green3Data: ; 3a491 (e:6491) -if _YELLOW +if DEF(_YELLOW) db $FF,61,SANDSLASH,59,ALAKAZAM,61,EXEGGUTOR,61,CLOYSTER,63,NINETALES,65,JOLTEON,0 db $FF,61,SANDSLASH,59,ALAKAZAM,61,EXEGGUTOR,61,MAGNETON,63,CLOYSTER,65,FLAREON,0 db $FF,61,SANDSLASH,59,ALAKAZAM,61,EXEGGUTOR,61,NINETALES,63,MAGNETON,65,VAPOREON,0 diff --git a/data/wildPokemon/mansion1.asm b/data/wildPokemon/mansion1.asm index 825478961f..e96b9d4217 100755 --- a/data/wildPokemon/mansion1.asm +++ b/data/wildPokemon/mansion1.asm @@ -1,6 +1,6 @@ MansionMons1: db $0A - IF _RED + IF DEF(_RED) db 32,KOFFING db 30,KOFFING db 34,PONYTA @@ -13,7 +13,7 @@ MansionMons1: db 39,MUK ENDC - IF _GREEN || _BLUE + IF DEF(_GREEN) || DEF(_BLUE) db 32,GRIMER db 30,GRIMER db 34,PONYTA @@ -26,7 +26,7 @@ MansionMons1: db 39,WEEZING ENDC - IF _YELLOW + IF DEF(_YELLOW) db 34,RATTATA db 34,RATICATE db 23,GRIMER diff --git a/data/wildPokemon/mansion2.asm b/data/wildPokemon/mansion2.asm index 8ebbb41431..77cce4085c 100755 --- a/data/wildPokemon/mansion2.asm +++ b/data/wildPokemon/mansion2.asm @@ -1,6 +1,6 @@ MansionMons2: db $0A - IF _RED + IF DEF(_RED) db 32,GROWLITHE db 34,KOFFING db 34,KOFFING @@ -13,7 +13,7 @@ MansionMons2: db 37,MUK ENDC - IF _GREEN || !_JAPAN && _BLUE + IF DEF(_GREEN) || !DEF(_JAPAN) && DEF(_BLUE) db 32,VULPIX db 34,GRIMER db 34,GRIMER @@ -26,7 +26,7 @@ MansionMons2: db 37,WEEZING ENDC - IF _JAPAN && _BLUE + IF DEF(_JAPAN) && DEF(_BLUE) db 32,GROWLITHE db 34,GRIMER db 34,GRIMER @@ -39,7 +39,7 @@ MansionMons2: db 37,WEEZING ENDC - IF _YELLOW + IF DEF(_YELLOW) db 37,RATTATA db 37,RATICATE db 26,GRIMER diff --git a/data/wildPokemon/mansion3.asm b/data/wildPokemon/mansion3.asm index a1b126acbd..eceb0296e4 100755 --- a/data/wildPokemon/mansion3.asm +++ b/data/wildPokemon/mansion3.asm @@ -1,6 +1,6 @@ MansionMons3: db $0A - IF _RED + IF DEF(_RED) db 31,KOFFING db 33,GROWLITHE db 35,KOFFING @@ -13,7 +13,7 @@ MansionMons3: db 42,MUK ENDC - IF _GREEN || !_JAPAN && _BLUE + IF DEF(_GREEN) || !DEF(_JAPAN) && DEF(_BLUE) db 31,GRIMER db 33,VULPIX db 35,GRIMER @@ -26,7 +26,7 @@ MansionMons3: db 42,WEEZING ENDC - IF _JAPAN && _BLUE + IF DEF(_JAPAN) && DEF(_BLUE) db 31,GRIMER db 33,GROWLITHE db 35,GRIMER @@ -39,7 +39,7 @@ MansionMons3: db 42,WEEZING ENDC - IF _YELLOW + IF DEF(_YELLOW) db 40,RATTATA db 40,RATICATE db 32,GRIMER diff --git a/data/wildPokemon/mansionb1.asm b/data/wildPokemon/mansionb1.asm index 23831eeb4f..9dcd989314 100755 --- a/data/wildPokemon/mansionb1.asm +++ b/data/wildPokemon/mansionb1.asm @@ -1,6 +1,6 @@ MansionMonsB1: db $0A - IF _RED + IF DEF(_RED) db 33,KOFFING db 31,KOFFING db 35,GROWLITHE @@ -13,7 +13,7 @@ MansionMonsB1: db 42,MUK ENDC - IF _GREEN || !_JAPAN && _BLUE + IF DEF(_GREEN) || !DEF(_JAPAN) && DEF(_BLUE) db 33,GRIMER db 31,GRIMER db 35,VULPIX @@ -26,7 +26,7 @@ MansionMonsB1: db 42,WEEZING ENDC - IF _JAPAN && _BLUE + IF DEF(_JAPAN) && DEF(_BLUE) db 33,GRIMER db 31,GRIMER db 35,GROWLITHE @@ -39,7 +39,7 @@ MansionMonsB1: db 42,WEEZING ENDC - IF _YELLOW + IF DEF(_YELLOW) db 35,GRIMER db 38,GRIMER db 37,RATICATE @@ -53,4 +53,3 @@ MansionMonsB1: ENDC db $00 - diff --git a/data/wildPokemon/mtmoon1.asm b/data/wildPokemon/mtmoon1.asm index 5ba1d030fa..a8018b82a9 100755 --- a/data/wildPokemon/mtmoon1.asm +++ b/data/wildPokemon/mtmoon1.asm @@ -1,28 +1,27 @@ MoonMons1: db $0A - IF !_YELLOW + IF DEF(_YELLOW) db 8,ZUBAT - db 7,ZUBAT db 9,ZUBAT - db 8,GEODUDE + db 10,GEODUDE db 6,ZUBAT + db 7,ZUBAT db 10,ZUBAT db 10,GEODUDE - db 8,PARAS db 11,ZUBAT - db 8,CLEFAIRY - ENDC - IF _YELLOW + db 12,SANDSHREW + db 11,CLEFAIRY + ELSE db 8,ZUBAT + db 7,ZUBAT db 9,ZUBAT - db 10,GEODUDE + db 8,GEODUDE db 6,ZUBAT - db 7,ZUBAT db 10,ZUBAT db 10,GEODUDE + db 8,PARAS db 11,ZUBAT - db 12,SANDSHREW - db 11,CLEFAIRY + db 8,CLEFAIRY ENDC db $00 diff --git a/data/wildPokemon/mtmoonb1.asm b/data/wildPokemon/mtmoonb1.asm index 0f3639c110..c78b8471a1 100755 --- a/data/wildPokemon/mtmoonb1.asm +++ b/data/wildPokemon/mtmoonb1.asm @@ -1,18 +1,6 @@ MoonMonsB1: db $0A - IF !_YELLOW - db 8,ZUBAT - db 7,ZUBAT - db 7,GEODUDE - db 8,GEODUDE - db 9,ZUBAT - db 10,PARAS - db 10,ZUBAT - db 11,ZUBAT - db 9,CLEFAIRY - db 9,GEODUDE - ENDC - IF _YELLOW + IF DEF(_YELLOW) db 8,ZUBAT db 9,ZUBAT db 10,GEODUDE @@ -23,6 +11,17 @@ MoonMonsB1: db 11,ZUBAT db 12,SANDSHREW db 11,CLEFAIRY + ELSE + db 8,ZUBAT + db 7,ZUBAT + db 7,GEODUDE + db 8,GEODUDE + db 9,ZUBAT + db 10,PARAS + db 10,ZUBAT + db 11,ZUBAT + db 9,CLEFAIRY + db 9,GEODUDE ENDC db $00 diff --git a/data/wildPokemon/mtmoonb2.asm b/data/wildPokemon/mtmoonb2.asm index 34966cd848..0118a89844 100755 --- a/data/wildPokemon/mtmoonb2.asm +++ b/data/wildPokemon/mtmoonb2.asm @@ -1,18 +1,6 @@ MoonMonsB2: db $0A - IF !_YELLOW - db 9,ZUBAT - db 9,GEODUDE - db 10,ZUBAT - db 10,GEODUDE - db 11,ZUBAT - db 10,PARAS - db 12,PARAS - db 10,CLEFAIRY - db 12,ZUBAT - db 12,CLEFAIRY - ENDC - IF _YELLOW + IF DEF(_YELLOW) db 10,ZUBAT db 11,GEODUDE db 13,PARAS @@ -23,6 +11,17 @@ MoonMonsB2: db 9,CLEFAIRY db 11,CLEFAIRY db 13,CLEFAIRY + ELSE + db 9,ZUBAT + db 9,GEODUDE + db 10,ZUBAT + db 10,GEODUDE + db 11,ZUBAT + db 10,PARAS + db 12,PARAS + db 10,CLEFAIRY + db 12,ZUBAT + db 12,CLEFAIRY ENDC db $00 diff --git a/data/wildPokemon/pokemontower3.asm b/data/wildPokemon/pokemontower3.asm index e2b393986e..4e3a7c6275 100755 --- a/data/wildPokemon/pokemontower3.asm +++ b/data/wildPokemon/pokemontower3.asm @@ -1,29 +1,27 @@ TowerMons3: db $0A - IF !_YELLOW + IF DEF(_YELLOW) db 20,GASTLY db 21,GASTLY db 22,GASTLY db 23,GASTLY + db 24,GASTLY db 19,GASTLY db 18,GASTLY - db 24,GASTLY - db 20,CUBONE - db 22,CUBONE + db 25,GASTLY + db 20,HAUNTER db 25,HAUNTER - ENDC - - IF _YELLOW + ELSE db 20,GASTLY db 21,GASTLY db 22,GASTLY db 23,GASTLY - db 24,GASTLY db 19,GASTLY db 18,GASTLY - db 25,GASTLY - db 20,HAUNTER + db 24,GASTLY + db 20,CUBONE + db 22,CUBONE db 25,HAUNTER ENDC diff --git a/data/wildPokemon/pokemontower4.asm b/data/wildPokemon/pokemontower4.asm index 3f38af206c..e0de809fac 100755 --- a/data/wildPokemon/pokemontower4.asm +++ b/data/wildPokemon/pokemontower4.asm @@ -1,30 +1,28 @@ TowerMons4: db $0A - IF !_YELLOW + IF DEF(_YELLOW) db 20,GASTLY db 21,GASTLY db 22,GASTLY db 23,GASTLY + db 24,GASTLY db 19,GASTLY db 18,GASTLY + db 25,GASTLY + db 20,HAUNTER db 25,HAUNTER - db 20,CUBONE - db 22,CUBONE - db 24,GASTLY - ENDC - - IF _YELLOW + ELSE db 20,GASTLY db 21,GASTLY db 22,GASTLY db 23,GASTLY - db 24,GASTLY db 19,GASTLY db 18,GASTLY - db 25,GASTLY - db 20,HAUNTER db 25,HAUNTER + db 20,CUBONE + db 22,CUBONE + db 24,GASTLY ENDC db $00 diff --git a/data/wildPokemon/pokemontower5.asm b/data/wildPokemon/pokemontower5.asm index 970984486a..9f97b98e67 100755 --- a/data/wildPokemon/pokemontower5.asm +++ b/data/wildPokemon/pokemontower5.asm @@ -1,20 +1,7 @@ TowerMons5: db $0A - IF !_YELLOW - db 20,GASTLY - db 21,GASTLY - db 22,GASTLY - db 23,GASTLY - db 19,GASTLY - db 18,GASTLY - db 25,HAUNTER - db 20,CUBONE - db 22,CUBONE - db 24,GASTLY - ENDC - - IF _YELLOW + IF DEF(_YELLOW) db 22,GASTLY db 23,GASTLY db 24,GASTLY @@ -25,6 +12,17 @@ TowerMons5: db 27,GASTLY db 22,HAUNTER db 27,HAUNTER + ELSE + db 20,GASTLY + db 21,GASTLY + db 22,GASTLY + db 23,GASTLY + db 19,GASTLY + db 18,GASTLY + db 25,HAUNTER + db 20,CUBONE + db 22,CUBONE + db 24,GASTLY ENDC db $00 diff --git a/data/wildPokemon/pokemontower6.asm b/data/wildPokemon/pokemontower6.asm index abd2969a0d..b97e2ddd08 100755 --- a/data/wildPokemon/pokemontower6.asm +++ b/data/wildPokemon/pokemontower6.asm @@ -1,20 +1,7 @@ TowerMons6: db $0F - IF !_YELLOW - db 21,GASTLY - db 22,GASTLY - db 23,GASTLY - db 24,GASTLY - db 20,GASTLY - db 19,GASTLY - db 26,HAUNTER - db 22,CUBONE - db 24,CUBONE - db 28,HAUNTER - ENDC - - IF _YELLOW + IF DEF(_YELLOW) db 22,GASTLY db 23,GASTLY db 24,GASTLY @@ -25,6 +12,17 @@ TowerMons6: db 27,GASTLY db 22,HAUNTER db 27,HAUNTER + ELSE + db 21,GASTLY + db 22,GASTLY + db 23,GASTLY + db 24,GASTLY + db 20,GASTLY + db 19,GASTLY + db 26,HAUNTER + db 22,CUBONE + db 24,CUBONE + db 28,HAUNTER ENDC db $00 diff --git a/data/wildPokemon/pokemontower7.asm b/data/wildPokemon/pokemontower7.asm index 2daf3a2d41..b0d945348a 100755 --- a/data/wildPokemon/pokemontower7.asm +++ b/data/wildPokemon/pokemontower7.asm @@ -1,21 +1,7 @@ TowerMons7: db $0F - IF !_YELLOW - db 21,GASTLY - db 22,GASTLY - db 23,GASTLY - db 24,GASTLY - db 20,GASTLY - db 28,HAUNTER - db 22,CUBONE - db 24,CUBONE - db 28,HAUNTER - db 30,HAUNTER - - ENDC - - IF _YELLOW + IF DEF(_YELLOW) db 24,GASTLY db 25,GASTLY db 26,GASTLY @@ -26,6 +12,17 @@ TowerMons7: db 29,GASTLY db 24,HAUNTER db 29,HAUNTER + ELSE + db 21,GASTLY + db 22,GASTLY + db 23,GASTLY + db 24,GASTLY + db 20,GASTLY + db 28,HAUNTER + db 22,CUBONE + db 24,CUBONE + db 28,HAUNTER + db 30,HAUNTER ENDC db $00 diff --git a/data/wildPokemon/powerplant.asm b/data/wildPokemon/powerplant.asm index a67ab2e975..f956fcf28c 100755 --- a/data/wildPokemon/powerplant.asm +++ b/data/wildPokemon/powerplant.asm @@ -1,7 +1,18 @@ PowerPlantMons: db $0A - IF !_YELLOW - + + IF DEF(_YELLOW) + db 30,MAGNEMITE + db 35,MAGNEMITE + db 33,MAGNETON + db 33,VOLTORB + db 37,VOLTORB + db 33,GRIMER + db 37,GRIMER + db 38,MAGNETON + db 33,MUK + db 37,MUK + ELSE db 21,VOLTORB db 21,MAGNEMITE db 20,PIKACHU @@ -10,28 +21,14 @@ PowerPlantMons: db 23,VOLTORB db 32,MAGNETON db 35,MAGNETON - IF _RED + IF DEF(_RED) db 33,ELECTABUZZ db 36,ELECTABUZZ ENDC - IF _GREEN || _BLUE + IF DEF(_GREEN) || DEF(_BLUE) db 33,RAICHU db 36,RAICHU ENDC ENDC - IF _YELLOW - db 30,MAGNEMITE - db 35,MAGNEMITE - db 33,MAGNETON - db 33,VOLTORB - db 37,VOLTORB - db 33,GRIMER - db 37,GRIMER - db 38,MAGNETON - db 33,MUK - db 37,MUK - ENDC - db $00 - diff --git a/data/wildPokemon/rocktunnel1.asm b/data/wildPokemon/rocktunnel1.asm index e89040432c..992a4e7349 100755 --- a/data/wildPokemon/rocktunnel1.asm +++ b/data/wildPokemon/rocktunnel1.asm @@ -1,16 +1,27 @@ TunnelMonsB1: db $0F - IF !_YELLOW + IF DEF(_YELLOW) + db 15,ZUBAT + db 16,GEODUDE + db 17,ZUBAT + db 19,ZUBAT + db 18,GEODUDE + db 20,GEODUDE + db 21,ZUBAT + db 17,MACHOP + db 19,MACHOP + db 21,MACHOP + ELSE db 16,ZUBAT db 17,ZUBAT db 17,GEODUDE db 15,MACHOP db 16,GEODUDE - IF _RED || _GREEN || (_BLUE && !_JAPAN) + IF DEF(_RED) || DEF(_GREEN) || (DEF(_BLUE) && !DEF(_JAPAN)) db 18,ZUBAT ENDC - IF (_BLUE && _JAPAN) + IF (DEF(_BLUE) && DEF(_JAPAN)) db 18,DITTO ENDC db 15,ZUBAT @@ -19,18 +30,5 @@ TunnelMonsB1: db 15,ONIX ENDC - IF _YELLOW - db 15,ZUBAT - db 16,GEODUDE - db 17,ZUBAT - db 19,ZUBAT - db 18,GEODUDE - db 20,GEODUDE - db 21,ZUBAT - db 17,MACHOP - db 19,MACHOP - db 21,MACHOP - ENDC - db $00 diff --git a/data/wildPokemon/rocktunnel2.asm b/data/wildPokemon/rocktunnel2.asm index f158453e44..0a47d98407 100755 --- a/data/wildPokemon/rocktunnel2.asm +++ b/data/wildPokemon/rocktunnel2.asm @@ -1,15 +1,27 @@ TunnelMonsB2: db $0F - IF !_YELLOW + + IF DEF(_YELLOW) + db 20,ZUBAT + db 17,GEODUDE + db 18,MACHOP + db 21,ZUBAT + db 22,ZUBAT + db 21,GEODUDE + db 20,MACHOP + db 14,ONIX + db 18,ONIX + db 22,ONIX + ELSE db 16,ZUBAT db 17,ZUBAT db 17,GEODUDE db 15,MACHOP db 16,GEODUDE - IF _RED || _GREEN || (_BLUE && !_JAPAN) + IF DEF(_RED) || DEF(_GREEN) || (DEF(_BLUE) && !DEF(_JAPAN)) db 18,ZUBAT ENDC - IF (_BLUE && _JAPAN) + IF DEF(_BLUE) && DEF(_JAPAN) db 18,DITTO ENDC db 17,MACHOP @@ -18,18 +30,5 @@ TunnelMonsB2: db 18,GEODUDE ENDC - IF _YELLOW - db 20,ZUBAT - db 17,GEODUDE - db 18,MACHOP - db 21,ZUBAT - db 22,ZUBAT - db 21,GEODUDE - db 20,MACHOP - db 14,ONIX - db 18,ONIX - db 22,ONIX - ENDC - db $00 diff --git a/data/wildPokemon/route1.asm b/data/wildPokemon/route1.asm index bbad3c9e37..8e5b6897c4 100755 --- a/data/wildPokemon/route1.asm +++ b/data/wildPokemon/route1.asm @@ -1,18 +1,6 @@ Route1Mons: db $19 - IF !_YELLOW - db 3,PIDGEY - db 3,RATTATA - db 3,RATTATA - db 2,RATTATA - db 2,PIDGEY - db 3,PIDGEY - db 3,PIDGEY - db 4,RATTATA - db 4,PIDGEY - db 5,PIDGEY - ENDC - IF _YELLOW + IF DEF(_YELLOW) db 3,PIDGEY db 4,PIDGEY db 2,RATTATA @@ -23,6 +11,17 @@ Route1Mons: db 4,RATTATA db 6,PIDGEY db 7,PIDGEY + ELSE + db 3,PIDGEY + db 3,RATTATA + db 3,RATTATA + db 2,RATTATA + db 2,PIDGEY + db 3,PIDGEY + db 3,PIDGEY + db 4,RATTATA + db 4,PIDGEY + db 5,PIDGEY ENDC db $00 diff --git a/data/wildPokemon/route10.asm b/data/wildPokemon/route10.asm index 185e41fe11..7cfaf25cb5 100755 --- a/data/wildPokemon/route10.asm +++ b/data/wildPokemon/route10.asm @@ -1,7 +1,7 @@ Route10Mons: db $0F - IF _RED + IF DEF(_RED) db 16,VOLTORB db 16,SPEAROW db 14,VOLTORB @@ -14,7 +14,7 @@ Route10Mons: db 17,EKANS ENDC - IF !_RED + IF DEF(_BLUE) || DEF(_GREEN) db 16,VOLTORB db 16,SPEAROW db 14,VOLTORB @@ -27,7 +27,7 @@ Route10Mons: db 17,SANDSHREW ENDC - IF _YELLOW + IF DEF(_YELLOW) db 16,MAGNEMITE db 18,RATTATA db 18,MAGNEMITE diff --git a/data/wildPokemon/route11.asm b/data/wildPokemon/route11.asm index 6f724e80c0..66c52c204e 100755 --- a/data/wildPokemon/route11.asm +++ b/data/wildPokemon/route11.asm @@ -1,7 +1,7 @@ Route11Mons: db $0F - IF _RED + IF DEF(_RED) db 14,EKANS db 15,SPEAROW db 12,EKANS @@ -14,7 +14,7 @@ Route11Mons: db 15,DROWZEE ENDC - IF _GREEN || _BLUE + IF DEF(_GREEN) || DEF(_BLUE) db 14,SANDSHREW db 15,SPEAROW db 12,SANDSHREW @@ -27,7 +27,7 @@ Route11Mons: db 15,DROWZEE ENDC - IF _YELLOW + IF DEF(_YELLOW) db 16,PIDGEY db 15,RATTATA db 18,PIDGEY diff --git a/data/wildPokemon/route12.asm b/data/wildPokemon/route12.asm index b15a222394..7f5e47fe63 100755 --- a/data/wildPokemon/route12.asm +++ b/data/wildPokemon/route12.asm @@ -1,7 +1,7 @@ Route12Mons: db $0F - IF _RED || (_JAPAN && _BLUE) + IF DEF(_RED) || (DEF(_JAPAN) && DEF(_BLUE)) db 24,ODDISH db 25,PIDGEY db 23,PIDGEY @@ -15,7 +15,7 @@ Route12Mons: db $00 ENDC - IF _GREEN || (!_JAPAN && _BLUE) + IF DEF(_GREEN) || (!DEF(_JAPAN) && DEF(_BLUE)) db 24,BELLSPROUT db 25,PIDGEY db 23,PIDGEY @@ -29,7 +29,7 @@ Route12Mons: db $00 ENDC - IF _YELLOW + IF DEF(_YELLOW) db 25,ODDISH db 25,BELLSPROUT db 28,PIDGEY diff --git a/data/wildPokemon/route13.asm b/data/wildPokemon/route13.asm index 5293bf2168..1b694f3615 100755 --- a/data/wildPokemon/route13.asm +++ b/data/wildPokemon/route13.asm @@ -1,5 +1,5 @@ Route13Mons: - IF _RED || (_JAPAN && _BLUE) + IF DEF(_RED) || (DEF(_JAPAN) && DEF(_BLUE)) db $14 db 24,ODDISH db 25,PIDGEY @@ -14,7 +14,7 @@ Route13Mons: db $00 ENDC - IF _GREEN || (!_JAPAN && _BLUE) + IF DEF(_GREEN) || (!DEF(_JAPAN) && DEF(_BLUE)) db $14 db 24,BELLSPROUT db 25,PIDGEY @@ -29,7 +29,7 @@ Route13Mons: db $00 ENDC - IF _YELLOW + IF DEF(_YELLOW) db $0F db 25,ODDISH db 25,BELLSPROUT diff --git a/data/wildPokemon/route14.asm b/data/wildPokemon/route14.asm index 76d9118f7a..999981af73 100755 --- a/data/wildPokemon/route14.asm +++ b/data/wildPokemon/route14.asm @@ -1,6 +1,6 @@ Route14Mons: db $0F - IF _RED || (_JAPAN && _BLUE) + IF DEF(_RED) || (DEF(_JAPAN) && DEF(_BLUE)) db 24,ODDISH db 26,PIDGEY db 23,DITTO @@ -13,7 +13,7 @@ Route14Mons: db 30,PIDGEOTTO ENDC - IF _GREEN || (!_JAPAN && _BLUE) + IF DEF(_GREEN) || (!DEF(_JAPAN) && DEF(_BLUE)) db 24,BELLSPROUT db 26,PIDGEY db 23,DITTO @@ -26,7 +26,7 @@ Route14Mons: db 30,PIDGEOTTO ENDC - IF _YELLOW + IF DEF(_YELLOW) db 26,ODDISH db 26,BELLSPROUT db 24,VENONAT diff --git a/data/wildPokemon/route15.asm b/data/wildPokemon/route15.asm index 4a0d3fc3a2..d924052a09 100755 --- a/data/wildPokemon/route15.asm +++ b/data/wildPokemon/route15.asm @@ -1,6 +1,6 @@ Route15Mons: db $0F - IF _RED || (_JAPAN && _BLUE) + IF DEF(_RED) || (DEF(_JAPAN) && DEF(_BLUE)) db 24,ODDISH db 26,DITTO db 23,PIDGEY @@ -13,7 +13,7 @@ Route15Mons: db 30,PIDGEOTTO ENDC - IF _GREEN || (!_JAPAN && _BLUE) + IF DEF(_GREEN) || (!DEF(_JAPAN) && DEF(_BLUE)) db 24,BELLSPROUT db 26,DITTO db 23,PIDGEY @@ -26,7 +26,7 @@ Route15Mons: db 30,PIDGEOTTO ENDC - IF _YELLOW + IF DEF(_YELLOW) db 26,ODDISH db 26,BELLSPROUT db 24,VENONAT diff --git a/data/wildPokemon/route16.asm b/data/wildPokemon/route16.asm index 344081649c..468e37778a 100755 --- a/data/wildPokemon/route16.asm +++ b/data/wildPokemon/route16.asm @@ -1,19 +1,6 @@ Route16Mons: db $19 - IF !_YELLOW - db 20,SPEAROW - db 22,SPEAROW - db 18,RATTATA - db 20,DODUO - db 20,RATTATA - db 18,DODUO - db 22,DODUO - db 22,RATTATA - db 23,RATICATE - db 25,RATICATE - ENDC - - IF _YELLOW + IF DEF(_YELLOW) db 22,SPEAROW db 22,DODUO db 23,RATTATA @@ -24,6 +11,17 @@ Route16Mons: db 24,FEAROW db 25,RATICATE db 26,RATICATE + ELSE + db 20,SPEAROW + db 22,SPEAROW + db 18,RATTATA + db 20,DODUO + db 20,RATTATA + db 18,DODUO + db 22,DODUO + db 22,RATTATA + db 23,RATICATE + db 25,RATICATE ENDC db $00 diff --git a/data/wildPokemon/route17.asm b/data/wildPokemon/route17.asm index 75882ec5b5..36283a99e2 100755 --- a/data/wildPokemon/route17.asm +++ b/data/wildPokemon/route17.asm @@ -1,19 +1,7 @@ Route17Mons: db $19 - IF !_YELLOW - db 20,SPEAROW - db 22,SPEAROW - db 25,RATICATE - db 24,DODUO - db 27,RATICATE - db 26,DODUO - db 28,DODUO - db 29,RATICATE - db 25,FEAROW - db 27,FEAROW - ENDC - IF _YELLOW + IF DEF(_YELLOW) db 26,DODUO db 27,FEAROW db 27,DODUO @@ -24,6 +12,17 @@ Route17Mons: db 28,DODUO db 32,PONYTA db 29,DODRIO + ELSE + db 20,SPEAROW + db 22,SPEAROW + db 25,RATICATE + db 24,DODUO + db 27,RATICATE + db 26,DODUO + db 28,DODUO + db 29,RATICATE + db 25,FEAROW + db 27,FEAROW ENDC db $00 diff --git a/data/wildPokemon/route18.asm b/data/wildPokemon/route18.asm index 8820f0458f..e16fc8ace2 100755 --- a/data/wildPokemon/route18.asm +++ b/data/wildPokemon/route18.asm @@ -1,19 +1,7 @@ Route18Mons: db $19 - IF !_YELLOW - db 20,SPEAROW - db 22,SPEAROW - db 25,RATICATE - db 24,DODUO - db 25,FEAROW - db 26,DODUO - db 28,DODUO - db 29,RATICATE - db 27,FEAROW - db 29,FEAROW - ENDC - IF _YELLOW + IF DEF(_YELLOW) db 22,SPEAROW db 22,DODUO db 23,RATTATA @@ -24,6 +12,17 @@ Route18Mons: db 24,FEAROW db 25,RATICATE db 26,RATICATE + ELSE + db 20,SPEAROW + db 22,SPEAROW + db 25,RATICATE + db 24,DODUO + db 25,FEAROW + db 26,DODUO + db 28,DODUO + db 29,RATICATE + db 27,FEAROW + db 29,FEAROW ENDC db $00 diff --git a/data/wildPokemon/route2.asm b/data/wildPokemon/route2.asm index 57d7f87fc0..8f9eb4e5c4 100755 --- a/data/wildPokemon/route2.asm +++ b/data/wildPokemon/route2.asm @@ -1,40 +1,39 @@ Route2Mons: db $19 - IF !_YELLOW + IF DEF(_YELLOW) + db 3,RATTATA + db 3,PIDGEY + db 4,RATTATA + db 4,NIDORAN_M + db 4,NIDORAN_F + db 5,PIDGEY + db 6,NIDORAN_M + db 6,NIDORAN_F + db 7,PIDGEY + db 7,PIDGEY + ELSE db 3,RATTATA db 3,PIDGEY db 4,PIDGEY db 4,RATTATA db 5,PIDGEY - if _RED + if DEF(_RED) db 3,WEEDLE ENDC - if _BLUE + if DEF(_BLUE) db 3,CATERPIE ENDC db 2,RATTATA db 5,RATTATA - if _RED + if DEF(_RED) db 4,WEEDLE db 5,WEEDLE ENDC - if _BLUE + if DEF(_BLUE) db 4,CATERPIE db 5,CATERPIE ENDC ENDC - IF _YELLOW - db 3,RATTATA - db 3,PIDGEY - db 4,RATTATA - db 4,NIDORAN_M - db 4,NIDORAN_F - db 5,PIDGEY - db 6,NIDORAN_M - db 6,NIDORAN_F - db 7,PIDGEY - db 7,PIDGEY - ENDC db $00 diff --git a/data/wildPokemon/route21.asm b/data/wildPokemon/route21.asm index a29753eb9a..7017081d34 100755 --- a/data/wildPokemon/route21.asm +++ b/data/wildPokemon/route21.asm @@ -1,19 +1,7 @@ Route21Mons: db $19 - IF !_YELLOW - db 21,RATTATA - db 23,PIDGEY - db 30,RATICATE - db 23,RATTATA - db 21,PIDGEY - db 30,PIDGEOTTO - db 32,PIDGEOTTO - db 28,TANGELA - db 30,TANGELA - db 32,TANGELA - ENDC - IF _YELLOW + IF DEF(_YELLOW) db 15,PIDGEY db 13,RATTATA db 13,PIDGEY @@ -24,6 +12,17 @@ Route21Mons: db 17,PIDGEOTTO db 19,PIDGEOTTO db 15,PIDGEOTTO + ELSE + db 21,RATTATA + db 23,PIDGEY + db 30,RATICATE + db 23,RATTATA + db 21,PIDGEY + db 30,PIDGEOTTO + db 32,PIDGEOTTO + db 28,TANGELA + db 30,TANGELA + db 32,TANGELA ENDC db $05 diff --git a/data/wildPokemon/route22.asm b/data/wildPokemon/route22.asm index 36ff9a57e7..78c5631abc 100755 --- a/data/wildPokemon/route22.asm +++ b/data/wildPokemon/route22.asm @@ -1,6 +1,6 @@ Route22Mons: db $19 - IF _RED || (_JAPAN && _BLUE) + IF DEF(_RED) || (DEF(_JAPAN) && DEF(_BLUE)) db 3,RATTATA db 3,NIDORAN_M db 4,RATTATA @@ -12,7 +12,7 @@ Route22Mons: db 3,NIDORAN_F db 4,NIDORAN_F ENDC - IF _GREEN || (!_JAPAN && _BLUE) + IF DEF(_GREEN) || (!DEF(_JAPAN) && DEF(_BLUE)) db 3,RATTATA db 3,NIDORAN_F db 4,RATTATA @@ -24,7 +24,7 @@ Route22Mons: db 3,NIDORAN_M db 4,NIDORAN_M ENDC - IF _YELLOW + IF DEF(_YELLOW) db 2,NIDORAN_M db 2,NIDORAN_F db 3,MANKEY diff --git a/data/wildPokemon/route23.asm b/data/wildPokemon/route23.asm index cfdd8eff0c..1320868c81 100755 --- a/data/wildPokemon/route23.asm +++ b/data/wildPokemon/route23.asm @@ -1,10 +1,22 @@ Route23Mons: db $0A - IF !_YELLOW - IF _RED + + IF DEF(_YELLOW) + db 41,NIDORINO + db 41,NIDORINA + db 36,MANKEY + db 44,NIDORINO + db 44,NIDORINA + db 40,FEAROW + db 41,MANKEY + db 45,FEAROW + db 41,PRIMEAPE + db 46,PRIMEAPE + ELSE + IF DEF(_RED) db 26,EKANS ENDC - IF !_RED + IF !DEF(_RED) db 26,SANDSHREW ENDC db 33,DITTO @@ -12,10 +24,10 @@ Route23Mons: db 38,FEAROW db 38,DITTO db 38,FEAROW - IF _RED + IF DEF(_RED) db 41,ARBOK ENDC - IF !_RED + IF !DEF(_RED) db 41,SANDSLASH ENDC db 43,DITTO @@ -23,18 +35,5 @@ Route23Mons: db 43,FEAROW ENDC - IF _YELLOW - db 41,NIDORINO - db 41,NIDORINA - db 36,MANKEY - db 44,NIDORINO - db 44,NIDORINA - db 40,FEAROW - db 41,MANKEY - db 45,FEAROW - db 41,PRIMEAPE - db 46,PRIMEAPE - ENDC - db $00 diff --git a/data/wildPokemon/route24.asm b/data/wildPokemon/route24.asm index e4ff986aef..d586927f1d 100755 --- a/data/wildPokemon/route24.asm +++ b/data/wildPokemon/route24.asm @@ -1,7 +1,7 @@ Route24Mons: db $19 - IF _RED + IF DEF(_RED) db 7,WEEDLE db 8,KAKUNA db 12,PIDGEY @@ -14,7 +14,7 @@ Route24Mons: db 12,ABRA ENDC - IF _GREEN || !_JAPAN && _BLUE + IF DEF(_GREEN) || !DEF(_JAPAN) && DEF(_BLUE) db 7,CATERPIE db 8,METAPOD db 12,PIDGEY @@ -27,7 +27,7 @@ Route24Mons: db 12,ABRA ENDC - IF _JAPAN && _BLUE + IF DEF(_JAPAN) && DEF(_BLUE) db 7,CATERPIE db 8,METAPOD db 12,PIDGEY @@ -40,7 +40,7 @@ Route24Mons: db 12,ABRA ENDC - IF _YELLOW + IF DEF(_YELLOW) db 12,ODDISH db 12,BELLSPROUT db 13,PIDGEY diff --git a/data/wildPokemon/route25.asm b/data/wildPokemon/route25.asm index 3d2254730d..4609c7cd2a 100755 --- a/data/wildPokemon/route25.asm +++ b/data/wildPokemon/route25.asm @@ -1,7 +1,7 @@ Route25Mons: db $0F - IF _RED + IF DEF(_RED) db 8,WEEDLE db 9,KAKUNA db 13,PIDGEY @@ -14,7 +14,7 @@ Route25Mons: db 8,CATERPIE ENDC - IF _GREEN || !_JAPAN && _BLUE + IF DEF(_GREEN) || !DEF(_JAPAN) && DEF(_BLUE) db 8,CATERPIE db 9,METAPOD db 13,PIDGEY @@ -27,7 +27,7 @@ Route25Mons: db 8,WEEDLE ENDC - IF _JAPAN && _BLUE + IF DEF(_JAPAN) && DEF(_BLUE) db 8,CATERPIE db 9,METAPOD db 13,PIDGEY @@ -40,7 +40,7 @@ Route25Mons: db 8,WEEDLE ENDC - IF _YELLOW + IF DEF(_YELLOW) db 12,ODDISH db 12,BELLSPROUT db 13,PIDGEY diff --git a/data/wildPokemon/route3.asm b/data/wildPokemon/route3.asm index 21230f421f..fe7c5da9fc 100755 --- a/data/wildPokemon/route3.asm +++ b/data/wildPokemon/route3.asm @@ -1,18 +1,6 @@ Route3Mons: db $14 - IF !_YELLOW - db 6,PIDGEY - db 5,SPEAROW - db 7,PIDGEY - db 6,SPEAROW - db 7,SPEAROW - db 8,PIDGEY - db 8,SPEAROW - db 3,JIGGLYPUFF - db 5,JIGGLYPUFF - db 7,JIGGLYPUFF - ENDC - IF _YELLOW + IF DEF(_YELLOW) db 8,SPEAROW db 9,SPEAROW db 9,MANKEY @@ -23,6 +11,17 @@ Route3Mons: db 12,RATTATA db 11,SPEAROW db 12,SPEAROW + ELSE + db 6,PIDGEY + db 5,SPEAROW + db 7,PIDGEY + db 6,SPEAROW + db 7,SPEAROW + db 8,PIDGEY + db 8,SPEAROW + db 3,JIGGLYPUFF + db 5,JIGGLYPUFF + db 7,JIGGLYPUFF ENDC db $00 diff --git a/data/wildPokemon/route4.asm b/data/wildPokemon/route4.asm index f7eb80ee08..40c3b7b524 100755 --- a/data/wildPokemon/route4.asm +++ b/data/wildPokemon/route4.asm @@ -1,7 +1,7 @@ Route4Mons: db $14 - IF _RED + IF DEF(_RED) db 10,RATTATA db 10,SPEAROW db 8,RATTATA @@ -14,7 +14,7 @@ Route4Mons: db 12,EKANS ENDC - IF !_RED + IF DEF(_BLUE) || DEF(_GREEN) db 10,RATTATA db 10,SPEAROW db 8,RATTATA @@ -27,7 +27,7 @@ Route4Mons: db 12,SANDSHREW ENDC - IF _YELLOW + IF DEF(_YELLOW) db 8,SPEAROW db 9,SPEAROW db 9,MANKEY diff --git a/data/wildPokemon/route5.asm b/data/wildPokemon/route5.asm index 4b018cd620..aa67ca87fc 100755 --- a/data/wildPokemon/route5.asm +++ b/data/wildPokemon/route5.asm @@ -1,7 +1,7 @@ Route5Mons: db $0F - IF _RED + IF DEF(_RED) db 13,ODDISH db 13,PIDGEY db 15,PIDGEY @@ -14,7 +14,7 @@ Route5Mons: db 16,MANKEY ENDC - IF _GREEN || !_JAPAN && _BLUE + IF DEF(_GREEN) || !DEF(_JAPAN) && DEF(_BLUE) db 13,BELLSPROUT db 13,PIDGEY db 15,PIDGEY @@ -27,7 +27,7 @@ Route5Mons: db 16,MEOWTH ENDC - IF _JAPAN && _BLUE + IF DEF(_JAPAN) && DEF(_BLUE) db 13,ODDISH db 13,PIDGEY db 15,PIDGEY @@ -40,7 +40,7 @@ Route5Mons: db 16,MEOWTH ENDC - IF _YELLOW + IF DEF(_YELLOW) db 15,PIDGEY db 14,RATTATA db 7,ABRA diff --git a/data/wildPokemon/route6.asm b/data/wildPokemon/route6.asm index 253a594327..86e0c05f0b 100755 --- a/data/wildPokemon/route6.asm +++ b/data/wildPokemon/route6.asm @@ -1,7 +1,7 @@ Route6Mons: db $0F - IF _RED + IF DEF(_RED) db 13,ODDISH db 13,PIDGEY db 15,PIDGEY @@ -15,7 +15,7 @@ Route6Mons: db $00 ENDC - IF _GREEN || !_JAPAN && _BLUE + IF DEF(_GREEN) || !DEF(_JAPAN) && DEF(_BLUE) db 13,BELLSPROUT db 13,PIDGEY db 15,PIDGEY @@ -29,7 +29,7 @@ Route6Mons: db $00 ENDC - IF _JAPAN && _BLUE + IF DEF(_JAPAN) && DEF(_BLUE) db 13,ODDISH db 13,PIDGEY db 15,PIDGEY @@ -43,7 +43,7 @@ Route6Mons: db $00 ENDC - IF _YELLOW + IF DEF(_YELLOW) db 15,PIDGEY db 14,RATTATA db 7,ABRA diff --git a/data/wildPokemon/route7.asm b/data/wildPokemon/route7.asm index 42073d1146..505b632ba6 100755 --- a/data/wildPokemon/route7.asm +++ b/data/wildPokemon/route7.asm @@ -1,7 +1,7 @@ Route7Mons: db $0F - IF _RED + IF DEF(_RED) db 19,PIDGEY db 19,ODDISH db 17,MANKEY @@ -14,7 +14,7 @@ Route7Mons: db 20,MANKEY ENDC - IF _GREEN || !_JAPAN && _BLUE + IF DEF(_GREEN) || !DEF(_JAPAN) && DEF(_BLUE) db 19,PIDGEY db 19,BELLSPROUT db 17,MEOWTH @@ -27,7 +27,7 @@ Route7Mons: db 20,MEOWTH ENDC - IF _JAPAN && _BLUE + IF DEF(_JAPAN) && DEF(_BLUE) db 19,PIDGEY db 19,ODDISH db 17,MEOWTH @@ -40,7 +40,7 @@ Route7Mons: db 20,MEOWTH ENDC - IF _YELLOW + IF DEF(_YELLOW) db 20,PIDGEY db 22,PIDGEY db 20,RATTATA diff --git a/data/wildPokemon/route8.asm b/data/wildPokemon/route8.asm index 59c3082d6e..67905134bb 100755 --- a/data/wildPokemon/route8.asm +++ b/data/wildPokemon/route8.asm @@ -1,7 +1,7 @@ Route8Mons: db $0F - IF _RED + IF DEF(_RED) db 18,PIDGEY db 18,MANKEY db 17,EKANS @@ -14,7 +14,7 @@ Route8Mons: db 18,GROWLITHE ENDC - IF _GREEN || !_JAPAN && _BLUE + IF DEF(_GREEN) || !DEF(_JAPAN) && DEF(_BLUE) db 18,PIDGEY db 18,MEOWTH db 17,SANDSHREW @@ -27,7 +27,7 @@ Route8Mons: db 18,VULPIX ENDC - IF _JAPAN && _BLUE + IF DEF(_JAPAN) && DEF(_BLUE) db 18,PIDGEY db 18,MEOWTH db 17,SANDSHREW @@ -40,7 +40,7 @@ Route8Mons: db 18,GROWLITHE ENDC - IF _YELLOW + IF DEF(_YELLOW) db 20,PIDGEY db 22,PIDGEY db 20,RATTATA diff --git a/data/wildPokemon/route9.asm b/data/wildPokemon/route9.asm index 03523e4fb6..d563aa2b75 100755 --- a/data/wildPokemon/route9.asm +++ b/data/wildPokemon/route9.asm @@ -1,7 +1,7 @@ Route9Mons: db $0F - IF _RED + IF DEF(_RED) db 16,RATTATA db 16,SPEAROW db 14,RATTATA @@ -14,7 +14,7 @@ Route9Mons: db 17,EKANS ENDC - IF !_RED && !_YELLOW + IF DEF(_GREEN) || DEF(_BLUE) db 16,RATTATA db 16,SPEAROW db 14,RATTATA @@ -27,7 +27,7 @@ Route9Mons: db 17,SANDSHREW ENDC - IF _YELLOW + IF DEF(_YELLOW) db 16,NIDORAN_M db 16,NIDORAN_F db 18,RATTATA diff --git a/data/wildPokemon/safarizone1.asm b/data/wildPokemon/safarizone1.asm index 29e3f29b97..3781af0e6b 100755 --- a/data/wildPokemon/safarizone1.asm +++ b/data/wildPokemon/safarizone1.asm @@ -1,6 +1,6 @@ ZoneMons1: db $1E - IF _RED || (_JAPAN && _BLUE) + IF DEF(_RED) || (DEF(_JAPAN) && DEF(_BLUE)) db 24,NIDORAN_M db 26,DODUO db 22,PARAS @@ -9,16 +9,16 @@ ZoneMons1: db 23,EXEGGCUTE db 24,NIDORAN_F db 25,PARASECT - IF _RED + IF DEF(_RED) db 25,KANGASKHAN ENDC - IF _JAPAN && _BLUE + IF DEF(_JAPAN) && DEF(_BLUE) db 25,LICKITUNG ENDC db 28,SCYTHER ENDC - IF _GREEN || (!_JAPAN && _BLUE) + IF DEF(_GREEN) || (!DEF(_JAPAN) && DEF(_BLUE)) db 24,NIDORAN_F db 26,DODUO db 22,PARAS @@ -31,7 +31,7 @@ ZoneMons1: db 28,PINSIR ENDC - IF _YELLOW + IF DEF(_YELLOW) db 21,NIDORAN_M db 29,NIDORAN_F db 22,EXEGGCUTE diff --git a/data/wildPokemon/safarizone2.asm b/data/wildPokemon/safarizone2.asm index 2adb18ed4c..5de4ad00ae 100755 --- a/data/wildPokemon/safarizone2.asm +++ b/data/wildPokemon/safarizone2.asm @@ -1,50 +1,48 @@ ZoneMons2: db $1E - IF !_YELLOW - IF _RED || (_JAPAN && _BLUE) + IF DEF(_YELLOW) + db 36,NIDORAN_M + db 14,NIDORAN_F + db 20,EXEGGCUTE + db 25,RHYHORN + db 23,NIDORINA + db 28,KANGASKHAN + db 16,CUBONE + db 33,KANGASKHAN + db 25,SCYTHER + db 15,PINSIR + ELSE + IF DEF(_RED) || (DEF(_JAPAN) && DEF(_BLUE)) db 22,NIDORAN_M ENDC - IF _GREEN || (!_JAPAN && _BLUE) + IF DEF(_GREEN) || (!DEF(_JAPAN) && DEF(_BLUE)) db 22,NIDORAN_F ENDC db 26,RHYHORN db 23,PARAS db 25,EXEGGCUTE - IF _RED || (_JAPAN && _BLUE) + IF DEF(_RED) || (DEF(_JAPAN) && DEF(_BLUE)) db 30,NIDORINO ENDC - IF _GREEN || (!_JAPAN && _BLUE) + IF DEF(_GREEN) || (!DEF(_JAPAN) && DEF(_BLUE)) db 30,NIDORINA ENDC db 27,EXEGGCUTE - IF _RED || (_JAPAN && _BLUE) + IF DEF(_RED) || (DEF(_JAPAN) && DEF(_BLUE)) db 30,NIDORINA ENDC - IF _GREEN || (!_JAPAN && _BLUE) + IF DEF(_GREEN) || (!DEF(_JAPAN) && DEF(_BLUE)) db 30,NIDORINO ENDC db 32,VENOMOTH db 26,CHANSEY - IF _RED || _GREEN || (!_JAPAN && _BLUE) + IF DEF(_RED) || DEF(_GREEN) || (!DEF(_JAPAN) && DEF(_BLUE)) db 28,TAUROS ENDC - IF (_JAPAN && _BLUE) + IF (DEF(_JAPAN) && DEF(_BLUE)) db 28,PINSIR ENDC ENDC - IF _YELLOW - db 36,NIDORAN_M - db 14,NIDORAN_F - db 20,EXEGGCUTE - db 25,RHYHORN - db 23,NIDORINA - db 28,KANGASKHAN - db 16,CUBONE - db 33,KANGASKHAN - db 25,SCYTHER - db 15,PINSIR - ENDC - db $00 diff --git a/data/wildPokemon/safarizone3.asm b/data/wildPokemon/safarizone3.asm index 436ab937a8..c13cd378cb 100755 --- a/data/wildPokemon/safarizone3.asm +++ b/data/wildPokemon/safarizone3.asm @@ -1,6 +1,6 @@ ZoneMons3: db $1E - IF _RED + IF DEF(_RED) db 25,NIDORAN_M db 26,DODUO db 23,VENONAT @@ -13,7 +13,7 @@ ZoneMons3: db 28,KANGASKHAN ENDC - IF _GREEN || (!_JAPAN && _BLUE) + IF DEF(_GREEN) || (!DEF(_JAPAN) && DEF(_BLUE)) db 25,NIDORAN_F db 26,DODUO db 23,VENONAT @@ -26,7 +26,7 @@ ZoneMons3: db 28,KANGASKHAN ENDC - IF _JAPAN && _BLUE + IF DEF(_JAPAN) && DEF(_BLUE) db 25,NIDORAN_M db 26,DODUO db 23,VENONAT @@ -39,7 +39,7 @@ ZoneMons3: db 28,LICKITUNG ENDC - IF _YELLOW + IF DEF(_YELLOW) db 29,NIDORAN_M db 21,NIDORAN_F db 22,EXEGGCUTE diff --git a/data/wildPokemon/safarizonecenter.asm b/data/wildPokemon/safarizonecenter.asm index 35eb7fd4e8..7b50e5b9b1 100755 --- a/data/wildPokemon/safarizonecenter.asm +++ b/data/wildPokemon/safarizonecenter.asm @@ -1,6 +1,6 @@ ZoneMonsCenter: db $1E - IF _RED + IF DEF(_RED) db 22,NIDORAN_M db 25,RHYHORN db 22,VENONAT @@ -13,7 +13,7 @@ ZoneMonsCenter: db 23,CHANSEY ENDC - IF _GREEN || (!_JAPAN && _BLUE) + IF DEF(_GREEN) || (!DEF(_JAPAN) && DEF(_BLUE)) db 22,NIDORAN_F db 25,RHYHORN db 22,VENONAT @@ -26,7 +26,7 @@ ZoneMonsCenter: db 23,CHANSEY ENDC - IF _JAPAN && _BLUE + IF DEF(_JAPAN) && DEF(_BLUE) db 22,NIDORAN_M db 25,RHYHORN db 22,VENONAT @@ -39,7 +39,7 @@ ZoneMonsCenter: db 23,CHANSEY ENDC - IF _YELLOW + IF DEF(_YELLOW) db 14,NIDORAN_M db 36,NIDORAN_F db 24,EXEGGCUTE diff --git a/data/wildPokemon/seafoamisland1.asm b/data/wildPokemon/seafoamisland1.asm index 506dd98eeb..45d0a707ff 100755 --- a/data/wildPokemon/seafoamisland1.asm +++ b/data/wildPokemon/seafoamisland1.asm @@ -1,6 +1,6 @@ IslandMons1: db $0F - IF _RED + IF DEF(_RED) db 30,SEEL db 30,SLOWPOKE db 30,SHELLDER @@ -13,7 +13,7 @@ IslandMons1: db 38,GOLDUCK ENDC - IF _GREEN || !_JAPAN && _BLUE + IF DEF(_GREEN) || !DEF(_JAPAN) && DEF(_BLUE) db 30,SEEL db 30,PSYDUCK db 30,STARYU @@ -26,7 +26,7 @@ IslandMons1: db 38,SLOWBRO ENDC - IF _JAPAN && _BLUE + IF DEF(_JAPAN) && DEF(_BLUE) db 30,SEEL db 30,HORSEA db 30,STARYU @@ -39,7 +39,7 @@ IslandMons1: db 38,SLOWBRO ENDC - IF _YELLOW + IF DEF(_YELLOW) db 18,ZUBAT db 25,KRABBY db 27,KRABBY diff --git a/data/wildPokemon/seafoamislandb1.asm b/data/wildPokemon/seafoamislandb1.asm index 044753b438..3f6ef7b611 100755 --- a/data/wildPokemon/seafoamislandb1.asm +++ b/data/wildPokemon/seafoamislandb1.asm @@ -1,6 +1,6 @@ IslandMonsB1: db $0A - IF _RED + IF DEF(_RED) db 30,STARYU db 30,HORSEA db 32,SHELLDER @@ -13,7 +13,7 @@ IslandMonsB1: db 37,SEADRA ENDC - IF _GREEN || !_JAPAN && _BLUE + IF DEF(_GREEN) || !DEF(_JAPAN) && DEF(_BLUE) db 30,SHELLDER db 30,KRABBY db 32,STARYU @@ -26,7 +26,7 @@ IslandMonsB1: db 37,KINGLER ENDC - IF _JAPAN && _BLUE + IF DEF(_JAPAN) && DEF(_BLUE) db 30,SHELLDER db 30,KRABBY db 32,STARYU @@ -39,7 +39,7 @@ IslandMonsB1: db 37,KINGLER ENDC - IF _YELLOW + IF DEF(_YELLOW) db 27,ZUBAT db 26,KRABBY db 36,ZUBAT diff --git a/data/wildPokemon/seafoamislandb2.asm b/data/wildPokemon/seafoamislandb2.asm index 2b7a3ef8bb..5df1cca908 100755 --- a/data/wildPokemon/seafoamislandb2.asm +++ b/data/wildPokemon/seafoamislandb2.asm @@ -1,6 +1,6 @@ IslandMonsB2: db $0A - IF _RED + IF DEF(_RED) db 30,SEEL db 30,SLOWPOKE db 32,SEEL @@ -13,7 +13,7 @@ IslandMonsB2: db 37,SLOWBRO ENDC - IF _GREEN || !_JAPAN && _BLUE + IF DEF(_GREEN) || !DEF(_JAPAN) && DEF(_BLUE) db 30,SEEL db 30,PSYDUCK db 32,SEEL @@ -26,7 +26,7 @@ IslandMonsB2: db 37,GOLDUCK ENDC - IF _JAPAN && _BLUE + IF DEF(_JAPAN) && DEF(_BLUE) db 30,SEEL db 30,HORSEA db 32,SEEL @@ -39,7 +39,7 @@ IslandMonsB2: db 37,JYNX ENDC - IF _YELLOW + IF DEF(_YELLOW) db 27,ZUBAT db 27,KRABBY db 36,ZUBAT diff --git a/data/wildPokemon/seafoamislandb3.asm b/data/wildPokemon/seafoamislandb3.asm index ac9769b412..e8560c9a2e 100755 --- a/data/wildPokemon/seafoamislandb3.asm +++ b/data/wildPokemon/seafoamislandb3.asm @@ -1,6 +1,6 @@ IslandMonsB3: db $0A - IF _RED + IF DEF(_RED) db 31,SLOWPOKE db 31,SEEL db 33,SLOWPOKE @@ -13,7 +13,7 @@ IslandMonsB3: db 37,DEWGONG ENDC - IF _GREEN || !_JAPAN && _BLUE + IF DEF(_GREEN) || !DEF(_JAPAN) && DEF(_BLUE) db 31,PSYDUCK db 31,SEEL db 33,PSYDUCK @@ -26,7 +26,7 @@ IslandMonsB3: db 37,DEWGONG ENDC - IF _JAPAN && _BLUE + IF DEF(_JAPAN) && DEF(_BLUE) db 31,HORSEA db 31,SEEL db 33,HORSEA @@ -39,7 +39,7 @@ IslandMonsB3: db 37,DEWGONG ENDC - IF _YELLOW + IF DEF(_YELLOW) db 27,GOLBAT db 36,ZUBAT db 29,KRABBY diff --git a/data/wildPokemon/seafoamislandb4.asm b/data/wildPokemon/seafoamislandb4.asm index af5c7e0295..7f8977d6c9 100755 --- a/data/wildPokemon/seafoamislandb4.asm +++ b/data/wildPokemon/seafoamislandb4.asm @@ -1,6 +1,6 @@ IslandMonsB4: db $0A - IF _RED + IF DEF(_RED) db 31,HORSEA db 31,SHELLDER db 33,HORSEA @@ -13,7 +13,7 @@ IslandMonsB4: db 32,GOLBAT ENDC - IF _GREEN || !_JAPAN && _BLUE + IF DEF(_GREEN) || !DEF(_JAPAN) && DEF(_BLUE) db 31,KRABBY db 31,STARYU db 33,KRABBY @@ -26,7 +26,7 @@ IslandMonsB4: db 32,GOLBAT ENDC - IF _JAPAN && _BLUE + IF DEF(_JAPAN) && DEF(_BLUE) db 31,KRABBY db 31,STARYU db 33,KRABBY @@ -39,7 +39,7 @@ IslandMonsB4: db 32,GOLBAT ENDC - IF _YELLOW + IF DEF(_YELLOW) db 36,GOLBAT db 36,ZUBAT db 30,KRABBY diff --git a/data/wildPokemon/unknowndungeon1.asm b/data/wildPokemon/unknowndungeon1.asm index 4feb568cad..504d32f1de 100755 --- a/data/wildPokemon/unknowndungeon1.asm +++ b/data/wildPokemon/unknowndungeon1.asm @@ -1,20 +1,31 @@ DungeonMons1: db $0A - IF !_YELLOW + IF DEF(_YELLOW) + db 50,GOLBAT + db 55,GOLBAT + db 45,GRAVELER + db 55,GLOOM + db 55,WEEPINBELL + db 52,SANDSLASH + db 54,VENOMOTH + db 54,PARASECT + db 55,DITTO + db 60,DITTO + ELSE db 46,GOLBAT db 46,HYPNO db 46,MAGNETON - IF _RED || _GREEN || (!_JAPAN && _BLUE) + IF DEF(_RED) || DEF(_GREEN) || (!DEF(_JAPAN) && DEF(_BLUE)) db 49,DODRIO ENDC - IF _JAPAN && _BLUE + IF DEF(_JAPAN) && DEF(_BLUE) db 49,RAPIDASH ENDC db 49,VENOMOTH - IF _RED + IF DEF(_RED) db 52,ARBOK ENDC - IF !_RED + IF !DEF(_RED) db 52,SANDSLASH ENDC db 49,KADABRA @@ -23,18 +34,5 @@ DungeonMons1: db 53,DITTO ENDC - IF _YELLOW - db 50,GOLBAT - db 55,GOLBAT - db 45,GRAVELER - db 55,GLOOM - db 55,WEEPINBELL - db 52,SANDSLASH - db 54,VENOMOTH - db 54,PARASECT - db 55,DITTO - db 60,DITTO - ENDC - db $00 diff --git a/data/wildPokemon/unknowndungeon2.asm b/data/wildPokemon/unknowndungeon2.asm index a09c985c71..9422f3a0ef 100755 --- a/data/wildPokemon/unknowndungeon2.asm +++ b/data/wildPokemon/unknowndungeon2.asm @@ -1,14 +1,25 @@ DungeonMons2: db $0F - IF !_YELLOW + IF DEF(_YELLOW) + db 52,GOLBAT + db 57,GOLBAT + db 50,GRAVELER + db 56,SANDSLASH + db 50,RHYHORN + db 60,DITTO + db 58,GLOOM + db 58,WEEPINBELL + db 60,RHYDON + db 58,RHYDON + ELSE db 51,DODRIO db 51,VENOMOTH db 51,KADABRA db 52,RHYDON - IF _RED || _GREEN || (_BLUE && !_JAPAN) + IF DEF(_RED) || DEF(_GREEN) || (DEF(_BLUE) && !DEF(_JAPAN)) db 52,MAROWAK ENDC - IF (_BLUE && _JAPAN) + IF (DEF(_BLUE) && DEF(_JAPAN)) db 52,MAROWAK ENDC db 52,ELECTRODE @@ -18,18 +29,5 @@ DungeonMons2: db 60,DITTO ENDC - IF _YELLOW - db 52,GOLBAT - db 57,GOLBAT - db 50,GRAVELER - db 56,SANDSLASH - db 50,RHYHORN - db 60,DITTO - db 58,GLOOM - db 58,WEEPINBELL - db 60,RHYDON - db 58,RHYDON - ENDC - db $00 diff --git a/data/wildPokemon/unknowndungeonb1.asm b/data/wildPokemon/unknowndungeonb1.asm index 7ab1c9648a..6a88edb2ce 100755 --- a/data/wildPokemon/unknowndungeonb1.asm +++ b/data/wildPokemon/unknowndungeonb1.asm @@ -1,16 +1,27 @@ DungeonMonsB1: db $19 - IF !_YELLOW + IF DEF(_YELLOW) + db 54,GOLBAT + db 59,GOLBAT + db 55,GRAVELER + db 52,RHYHORN + db 62,RHYDON + db 60,DITTO + db 56,CHANSEY + db 65,DITTO + db 55,LICKITUNG + db 50,LICKITUNG + ELSE db 55,RHYDON db 55,MAROWAK db 55,ELECTRODE db 64,CHANSEY db 64,PARASECT db 64,RAICHU - IF _RED + IF DEF(_RED) db 57,ARBOK ENDC - IF !_RED + IF DEF(_BLUE) || DEF(_GREEN) db 57,SANDSLASH ENDC db 65,DITTO @@ -18,18 +29,5 @@ DungeonMonsB1: db 67,DITTO ENDC - IF _YELLOW - db 54,GOLBAT - db 59,GOLBAT - db 55,GRAVELER - db 52,RHYHORN - db 62,RHYDON - db 60,DITTO - db 56,CHANSEY - db 65,DITTO - db 55,LICKITUNG - db 50,LICKITUNG - ENDC - db $00 diff --git a/data/wildPokemon/victoryroad1.asm b/data/wildPokemon/victoryroad1.asm index 1ec65cf5a5..98914a91d9 100755 --- a/data/wildPokemon/victoryroad1.asm +++ b/data/wildPokemon/victoryroad1.asm @@ -1,19 +1,7 @@ PlateauMons1: db $0F - IF !_YELLOW - db 24,MACHOP - db 26,GEODUDE - db 22,ZUBAT - db 36,ONIX - db 39,ONIX - db 42,ONIX - db 41,GRAVELER - db 41,GOLBAT - db 42,MACHOKE - db 43,MAROWAK - ENDC - IF _YELLOW + IF DEF(_YELLOW) db 26,GEODUDE db 31,GEODUDE db 36,GEODUDE @@ -24,6 +12,17 @@ PlateauMons1: db 45,ONIX db 41,GRAVELER db 47,GRAVELER + ELSE + db 24,MACHOP + db 26,GEODUDE + db 22,ZUBAT + db 36,ONIX + db 39,ONIX + db 42,ONIX + db 41,GRAVELER + db 41,GOLBAT + db 42,MACHOKE + db 43,MAROWAK ENDC db $00 diff --git a/data/wildPokemon/victoryroad2.asm b/data/wildPokemon/victoryroad2.asm index 87159e96d8..ffe117bc12 100755 --- a/data/wildPokemon/victoryroad2.asm +++ b/data/wildPokemon/victoryroad2.asm @@ -1,19 +1,7 @@ PlateauMons2: db $0A - IF !_YELLOW - db 22,MACHOP - db 24,GEODUDE - db 26,ZUBAT - db 36,ONIX - db 39,ONIX - db 42,ONIX - db 41,MACHOKE - db 40,GOLBAT - db 40,MAROWAK - db 43,GRAVELER - ENDC - IF _YELLOW + IF DEF(_YELLOW) db 31,GEODUDE db 36,GEODUDE db 41,GEODUDE @@ -24,6 +12,17 @@ PlateauMons2: db 47,ONIX db 39,MACHOKE db 42,MACHOKE + ELSE + db 22,MACHOP + db 24,GEODUDE + db 26,ZUBAT + db 36,ONIX + db 39,ONIX + db 42,ONIX + db 41,MACHOKE + db 40,GOLBAT + db 40,MAROWAK + db 43,GRAVELER ENDC db $00 diff --git a/data/wildPokemon/victoryroad3.asm b/data/wildPokemon/victoryroad3.asm index ae52eeb690..7c1b2c1caa 100755 --- a/data/wildPokemon/victoryroad3.asm +++ b/data/wildPokemon/victoryroad3.asm @@ -1,19 +1,7 @@ PlateauMons3: db $0F - IF !_YELLOW - db 24,MACHOP - db 26,GEODUDE - db 22,ZUBAT - db 42,ONIX - db 40,VENOMOTH - db 45,ONIX - db 43,GRAVELER - db 41,GOLBAT - db 42,MACHOKE - db 45,MACHOKE - ENDC - IF _YELLOW + IF DEF(_YELLOW) db 36,GEODUDE db 44,GOLBAT db 41,GEODUDE @@ -24,6 +12,17 @@ PlateauMons3: db 45,MACHOKE db 47,GRAVELER db 47,GRAVELER + ELSE + db 24,MACHOP + db 26,GEODUDE + db 22,ZUBAT + db 42,ONIX + db 40,VENOMOTH + db 45,ONIX + db 43,GRAVELER + db 41,GOLBAT + db 42,MACHOKE + db 45,MACHOKE ENDC db $00 diff --git a/data/wildPokemon/viridianforest.asm b/data/wildPokemon/viridianforest.asm index 2ca828eb8e..bac991c5ed 100755 --- a/data/wildPokemon/viridianforest.asm +++ b/data/wildPokemon/viridianforest.asm @@ -1,7 +1,19 @@ ForestMons: - IF !_YELLOW + IF DEF(_YELLOW) + db $19 + db 3,CATERPIE + db 4,METAPOD + db 4,CATERPIE + db 5,CATERPIE + db 4,PIDGEY + db 6,PIDGEY + db 6,CATERPIE + db 6,METAPOD + db 8,PIDGEY + db 9,PIDGEOTTO + ELSE db $08 - IF _RED + IF DEF(_RED) db 4,WEEDLE db 5,KAKUNA db 3,WEEDLE @@ -11,7 +23,7 @@ ForestMons: db 4,METAPOD db 3,CATERPIE ENDC - IF _BLUE || _GREEN + IF DEF(_BLUE) || DEF(_GREEN) db 4,CATERPIE db 5,METAPOD db 3,CATERPIE @@ -26,19 +38,6 @@ ForestMons: db 5,PIKACHU ENDC - IF _YELLOW - db $19 - db 3,CATERPIE - db 4,METAPOD - db 4,CATERPIE - db 5,CATERPIE - db 4,PIDGEY - db 6,PIDGEY - db 6,CATERPIE - db 6,METAPOD - db 8,PIDGEY - db 9,PIDGEOTTO - ENDC db $00 diff --git a/data/wild_mons.asm b/data/wild_mons.asm index 2bc062f3a5..ac1bb3cc7a 100755 --- a/data/wild_mons.asm +++ b/data/wild_mons.asm @@ -247,7 +247,7 @@ WildDataPointers: ; ceeb (3:4eeb) dw NoMons dw NoMons dw NoMons - IF _YELLOW + IF DEF(_YELLOW) dw NoMons ENDC dw $FFFF diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm index 349d1d5d2a..0e5c025fa9 100755 --- a/engine/battle/animations.asm +++ b/engine/battle/animations.asm @@ -367,10 +367,10 @@ AnimationTileset2: ; 786ee (1e:46ee) INCBIN "gfx/attack_anim_2.2bpp" SlotMachineTiles2: ; 78bde (1e:4bde) -IF _RED +IF DEF(_RED) INCBIN "gfx/red/slotmachine2.2bpp" ENDC -IF _BLUE +IF DEF(_BLUE) INCBIN "gfx/blue/slotmachine2.2bpp" ENDC diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 128b735655..43373fdd08 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -2954,7 +2954,7 @@ Func_3d4b6: ; 3d4b6 (f:54b6) jp Delay3 DisabledText: ; 3d555 (f:5555) -IF _YELLOW +IF DEF(_YELLOW) db "Disabled!@" ELSE db "disabled!@" diff --git a/engine/intro.asm b/engine/intro.asm index 68bf8b506b..ace43beb89 100755 --- a/engine/intro.asm +++ b/engine/intro.asm @@ -429,13 +429,13 @@ FightIntroBackMon: ; 41a99 (10:5a99) FightIntroFrontMon: ; 42099 (10:6099) -IF _RED +IF DEF(_RED) INCBIN "gfx/red/intro_nido_1.6x6.2bpp" INCBIN "gfx/red/intro_nido_2.6x6.2bpp" INCBIN "gfx/red/intro_nido_3.6x6.2bpp" ds $10 ; blank tile ENDC -IF _BLUE +IF DEF(_BLUE) INCBIN "gfx/blue/intro_purin_1.6x6.2bpp" INCBIN "gfx/blue/intro_purin_2.6x6.2bpp" INCBIN "gfx/blue/intro_purin_3.6x6.2bpp" diff --git a/engine/menu/bills_pc.asm b/engine/menu/bills_pc.asm index 16fbd37675..891ef6e80a 100644 --- a/engine/menu/bills_pc.asm +++ b/engine/menu/bills_pc.asm @@ -345,7 +345,7 @@ BillsPCMenuText: ; 216e1 (8:56e1) next "DEPOSIT ", $4a next "RELEASE ", $4a next "CHANGE BOX" -IF _YELLOW +IF DEF(_YELLOW) next "PRINT BOX" ENDC next "SEE YA!" diff --git a/engine/menu/pokedex.asm b/engine/menu/pokedex.asm index 2e5d676f68..e636e59dec 100755 --- a/engine/menu/pokedex.asm +++ b/engine/menu/pokedex.asm @@ -366,7 +366,7 @@ PokedexMenuItemsText: ; 402af (10:42af) db "DATA" next "CRY" next "AREA" -IF _YELLOW +IF DEF(_YELLOW) next "PRNT" ENDC next "QUIT@" diff --git a/engine/oak_speech2.asm b/engine/oak_speech2.asm index 6a0490f0a4..34d98fd704 100755 --- a/engine/oak_speech2.asm +++ b/engine/oak_speech2.asm @@ -181,7 +181,7 @@ DisplayIntroNameTextBox: ; 6a6c (1:6a6c) .namestring ; 6aa3 (1:6aa3) db "NAME@" -IF _RED +IF DEF(_RED) DefaultNamesPlayer: ; 6aa8 (1:6aa8) db "NEW NAME" next "RED" @@ -197,7 +197,7 @@ DefaultNamesRival: ; 6abe (1:6abe) db "@" ENDC -IF _BLUE +IF DEF(_BLUE) DefaultNamesPlayer: ; 6aa8 (1:6aa8) db "NEW NAME" next "BLUE" @@ -213,7 +213,7 @@ DefaultNamesRival: ; 6abe (1:6abe) db "@" ENDC -IF _YELLOW +IF DEF(_YELLOW) DefaultNamesPlayer: db "NEW NAME" next "YELLOW" @@ -250,19 +250,19 @@ Func_6ad6: ; 6ad6 (1:6ad6) ld de, wcd6d ld bc, $14 jp CopyData -IF _RED +IF DEF(_RED) DefaultNamesPlayerList: ; 6af2 (1:6af2) db "NEW NAME@RED@ASH@JACK@" DefaultNamesRivalList: ; 6b08 (1:6b08) db "NEW NAME@BLUE@GARY@JOHN@" ENDC -IF _BLUE +IF DEF(_BLUE) DefaultNamesPlayerList: ; 6af2 (1:6af2) db "NEW NAME@BLUE@GARY@JOHN@" DefaultNamesRivalList: ; 6b08 (1:6b08) db "NEW NAME@RED@ASH@JACK@" ENDC -IF _YELLOW +IF DEF(_YELLOW) DefaultNamesPlayerList: db "NEW NAME@YELLOW@ASH@JACK@" DefaultNamesRivalList: diff --git a/engine/slot_machine.asm b/engine/slot_machine.asm index b24b2d2562..5b72c8b121 100755 --- a/engine/slot_machine.asm +++ b/engine/slot_machine.asm @@ -862,9 +862,9 @@ SLOTSMOUSE EQU $1614 INCLUDE "data/slot_machine_wheels.asm" SlotMachineTiles1: ; 37a51 (d:7a51) -IF _RED +IF DEF(_RED) INCBIN "gfx/red/slotmachine1.2bpp" ENDC -IF _BLUE +IF DEF(_BLUE) INCBIN "gfx/blue/slotmachine1.2bpp" ENDC diff --git a/engine/titlescreen.asm b/engine/titlescreen.asm index 0bf4f4a561..e13b7da6e7 100755 --- a/engine/titlescreen.asm +++ b/engine/titlescreen.asm @@ -56,11 +56,11 @@ LoadTitlescreenGraphics: ; 42dd (1:42dd) ld a, BANK(PokemonLogoGraphics) call FarCopyData2 ; second chunk ld hl, Version_GFX ; $402f -IF _RED +IF DEF(_RED) ld de,vChars2 + $600 ld bc,$50 ENDC -IF _BLUE +IF DEF(_BLUE) ld de,vChars2 + $600 + $10 ld bc,$50 - $10 ENDC @@ -114,10 +114,10 @@ ENDC call SaveScreenTilesToBuffer2 call LoadScreenTilesFromBuffer2 call EnableLCD -IF _RED +IF DEF(_RED) ld a,CHARMANDER ; which Pokemon to show first on the title screen ENDC -IF _BLUE +IF DEF(_BLUE) ld a,SQUIRTLE ; which Pokemon to show first on the title screen ENDC @@ -382,9 +382,9 @@ PrintGameVersionOnTitleScreen: ; 4598 (1:4598) ; these point to special tiles specifically loaded for that purpose and are not usual text VersionOnTitleScreenText: ; 45a1 (1:45a1) -IF _RED +IF DEF(_RED) db $60,$61,$7F,$65,$66,$67,$68,$69,"@" ; "Red Version" ENDC -IF _BLUE +IF DEF(_BLUE) db $61,$62,$63,$64,$65,$66,$67,$68,"@" ; "Blue Version" ENDC diff --git a/main.asm b/main.asm index f49e5b24fb..27f01b97d7 100755 --- a/main.asm +++ b/main.asm @@ -6414,10 +6414,10 @@ SECTION "bank1A",ROMX,BANK[$1A] INCLUDE "engine/battle/1a.asm" Version_GFX: -IF _RED +IF DEF(_RED) INCBIN "gfx/red/redgreenversion.1bpp" ; 10 tiles ENDC -IF _BLUE +IF DEF(_BLUE) INCBIN "gfx/blue/blueversion.1bpp" ; 8 tiles ENDC diff --git a/text/credits_text.asm b/text/credits_text.asm index c2c9e429a3..2c638b9eab 100755 --- a/text/credits_text.asm +++ b/text/credits_text.asm @@ -65,10 +65,10 @@ CreditsTextPointers: ; 742c3 (1d:42c3) dw CredPAAD CredVersion: ; 74343 (1d:4343) ; this 1 byte difference makes all bank addresses offset by 1 in the blue version -IF _RED +IF DEF(_RED) db -8, "RED VERSION STAFF@" ENDC -IF _BLUE +IF DEF(_BLUE) db -8, "BLUE VERSION STAFF@" ENDC CredTajiri: ; 74356 (1d:4356) diff --git a/version.asm b/version.asm deleted file mode 100644 index 7d9fa0366e..0000000000 --- a/version.asm +++ /dev/null @@ -1,11 +0,0 @@ -check_ver: MACRO -if !def(\1) -\1 EQU 0 -endc -ENDM - - check_ver _RED - check_ver _BLUE - check_ver _JAPAN - check_ver _GREEN - check_ver _YELLOW From 7db2fe99f83e196a92bd3dab2e4c6b8c7b191682 Mon Sep 17 00:00:00 2001 From: IIMarckus Date: Fri, 17 Oct 2014 08:13:51 -0600 Subject: [PATCH 040/100] Add more from the beach house. --- constants/map_dimensions.asm | 7 +- constants/tilesets.asm | 4 +- data/mapHeaders/beach_house.asm | 6 + data/mapObjects/beach_house.asm | 20 ++ main.asm | 3 + maps/beach_house.blk | 1 + scripts/beach_house.asm | 195 ++++++++++++++++++ text.asm | 2 +- text/maps/{surf_house.asm => beach_house.asm} | 36 ++-- 9 files changed, 255 insertions(+), 19 deletions(-) create mode 100644 data/mapHeaders/beach_house.asm create mode 100644 data/mapObjects/beach_house.asm create mode 100644 maps/beach_house.blk create mode 100644 scripts/beach_house.asm rename text/maps/{surf_house.asm => beach_house.asm} (72%) diff --git a/constants/map_dimensions.asm b/constants/map_dimensions.asm index 7339e153e6..2c6075faa8 100755 --- a/constants/map_dimensions.asm +++ b/constants/map_dimensions.asm @@ -890,4 +890,9 @@ BRUNOS_ROOM_WIDTH EQU $05 ; Agatha_h map_id=247 AGATHAS_ROOM_HEIGHT EQU $06 -AGATHAS_ROOM_WIDTH EQU $05 \ No newline at end of file +AGATHAS_ROOM_WIDTH EQU $05 + +IF DEF(_YELLOW) +BEACH_HOUSE_HEIGHT EQU 4 +BEACH_HOUSE_WIDTH EQU 7 +ENDC diff --git a/constants/tilesets.asm b/constants/tilesets.asm index e364db76ae..ba549646d8 100644 --- a/constants/tilesets.asm +++ b/constants/tilesets.asm @@ -22,4 +22,6 @@ LAB EQU 20 CLUB EQU 21 FACILITY EQU 22 PLATEAU EQU 23 - +IF DEF(_YELLOW) +BEACH_HOUSE_TILESET EQU 24 +ENDC diff --git a/data/mapHeaders/beach_house.asm b/data/mapHeaders/beach_house.asm new file mode 100644 index 0000000000..4dc109ae2c --- /dev/null +++ b/data/mapHeaders/beach_house.asm @@ -0,0 +1,6 @@ +BeachHouse_h: + db BEACH_HOUSE_TILESET + dw BEACH_HOUSE_HEIGHT, BEACH_HOUSE_WIDTH ; dimensions (y, x) + dw BeachHouseBlockdata,BeachHouseTextPointers,BeachHouseScript ; blocks, texts, scripts + db 0 ; connections + dw BeachHouseObjects ; objects diff --git a/data/mapObjects/beach_house.asm b/data/mapObjects/beach_house.asm new file mode 100644 index 0000000000..2f83603796 --- /dev/null +++ b/data/mapObjects/beach_house.asm @@ -0,0 +1,20 @@ +BeachHouseObjects: ; 0xf23a4 + db $a ; border block + + db 2 ; warps + db 7,2,0,$ff + db 7,3,0,$ff + + db 4 ; signs + db 0,3,3 + db 0,7,4, + db 0,$b,5 + db 1,$d,6 + + db 2 ; people + db $27, 3+4, 2+4, $ff, $d0, 1 ; surfin' dude + db $3d, 3+4, 5+4, $fe, $01, 2 ; pikachu + + ; warp-to + EVENT_DISP BEACH_HOUSE_WIDTH,7,2 + EVENT_DISP BEACH_HOUSE_WIDTH,7,3 diff --git a/main.asm b/main.asm index 27f01b97d7..e0f3ac2ff3 100755 --- a/main.asm +++ b/main.asm @@ -5715,6 +5715,9 @@ CeladonHotelBlocks: INCBIN "maps/celadonhotel.blk" INCLUDE "data/mapHeaders/mtmoonpokecenter.asm" INCLUDE "scripts/mtmoonpokecenter.asm" +IF DEF(_YELLOW) +INCLUDE "scripts/beach_house.asm" +ENDC INCLUDE "data/mapObjects/mtmoonpokecenter.asm" INCLUDE "data/mapHeaders/rocktunnelpokecenter.asm" diff --git a/maps/beach_house.blk b/maps/beach_house.blk new file mode 100644 index 0000000000..5bcdb58a9c --- /dev/null +++ b/maps/beach_house.blk @@ -0,0 +1 @@ +      \ No newline at end of file diff --git a/scripts/beach_house.asm b/scripts/beach_house.asm new file mode 100644 index 0000000000..82d72c83f5 --- /dev/null +++ b/scripts/beach_house.asm @@ -0,0 +1,195 @@ +BeachHouseScript: + call $3c29 + ret + +BeachHouseTextPointers: + dw SurfinDudeText + dw BeachHousePikachuText + dw BeachHouseSign1Text + dw BeachHouseSign2Text + dw BeachHouseSign3Text + dw BeachHouseSign4Text + +SurfinDudeText: + db 8 + ld a,[$d471] + bit 6,a + jr nz,.next + ld hl,.SurfinDudeText4 + call PrintText + jr .xf2271 +.next + ld hl,$d492 + bit 0,[hl] + set 0,[hl] + jr nz,.next2 + ld hl,.SurfinDudeText1 + jr .next3 +.next2 + ld hl,.SurfinDudeText3 +.next3 + call PrintText + call $35ef + ld a,[$cc26] + and a + jr nz,.xf226b + ld a,1 + ld [$cc3c],a + ld b,$3e + ld hl,$4000 + call $3e84 + ld hl,$d492 + set 1,[hl] + jr .xf2271 +.xf226b + ld hl,.SurfinDudeText2 + call PrintText +.xf2271 + jp TextScriptEnd + +.SurfinDudeText1 + TX_FAR _SurfinDudeText1 + db "@" +.SurfinDudeText2 + TX_FAR _SurfinDudeText2 + db "@" +.SurfinDudeText3 + TX_FAR _SurfinDudeText3 + db "@" +.SurfinDudeText4 + TX_FAR _SurfinDudeText4 + db "@" + +BeachHousePikachuText: + db 8 + ld hl,.BeachHousePikachuText + call PrintText + ld a,PIKACHU + call PlayCry + call WaitForSoundToFinish + jp TextScriptEnd + +.BeachHousePikachuText + TX_FAR _BeachHousePikachuText + db "@" + +BeachHouseSign1Text: + db 8 + ld hl,.BeachHouseSign1Text2 + ld a,[$d471] + bit 6,a + jr z,.next + ld hl,.BeachHouseSign1Text1 +.next + call PrintText + jp TextScriptEnd + +.BeachHouseSign1Text1 + TX_FAR _BeachHouseSign1Text1 + db "@" +.BeachHouseSign1Text2 + TX_FAR _BeachHouseSign1Text2 + db "@" + +BeachHouseSign2Text: + db 8 + ld hl,.BeachHouseSign2Text2 + ld a,[$d471] + bit 6,a + jr z,.next + ld hl,.BeachHouseSign2Text1 +.next + call PrintText + jp TextScriptEnd + +.BeachHouseSign2Text1 + TX_FAR _BeachHouseSign2Text1 + db "@" +.BeachHouseSign2Text2 + TX_FAR _BeachHouseSign2Text2 + db "@" + +BeachHouseSign3Text: + db 8 + ld hl,$62f4 + ld a,[$d471] + bit 6,a + jr z,.next + ld hl,.BeachHouseSign3Text1 +.next + call PrintText + jp TextScriptEnd + +.BeachHouseSign3Text1 + TX_FAR _BeachHouseSign3Text1 + db "@" +.BeachHouseSign3Text2 + TX_FAR _BeachHouseSign3Text2 + db "@" + +BeachHouseSign4Text: + db 8 + ld a,1 + ld [$cc3c],a + ld a,[$d471] + bit 6,a + jr z,.xf2369 + + ld hl,$d492 + bit 1,[hl] + jr z,.next2 + ld a,0 + ld [$cc3c],a +.next2 + ld hl,.BeachHousePrinterText2 + call PrintText + ld a,[$d492] + bit 1,a + jr z,.xf236f + + ld a,1 + ld [$cc3c],a + ld hl,.BeachHousePrinterText3 + call PrintText + call $35ef + ld a,[$cc26] + and a + jp z,$63d0 ; 0xf23d0 + call $36ec + ld hl,$d72f + set 6,[hl] + xor a + ld [$cfca],a + ld hl,$510a + ld b,$3a + call $3e84 + call $3852 + ld hl,$d72f + res 6,[hl] + call $3dd8 + call $2f83 + call $3dc2 + call $36f8 + call $3ddb + call $3de0 + ld a,1 + ld [$cfca],a + jr .xf236f +.xf2369 + ld hl,.BeachHousePrinterText1 + call PrintText +.xf236f + jp TextScriptEnd + +.BeachHousePrinterText1 + TX_FAR _BeachHousePrinterText1 + db $d,"@" +.BeachHousePrinterText2 + TX_FAR _BeachHousePrinterText2 + db $d,"@" +.BeachHousePrinterText3 + TX_FAR _BeachHousePrinterText3 + db "@" +.xf2383 + TX_FAR _BeachHousePrinterText4 + db "@" diff --git a/text.asm b/text.asm index f230cf3efa..f1db4f5412 100644 --- a/text.asm +++ b/text.asm @@ -2136,7 +2136,7 @@ INCLUDE "text/maps/route_16_house.asm" INCLUDE "text/maps/route_18_gate.asm" INCLUDE "text/maps/route_18_gate_upstairs.asm" IF DEF(_YELLOW) -INCLUDE "text/maps/surf_house.asm" +INCLUDE "text/maps/beach_house.asm" ENDC INCLUDE "text/maps/pokemon_league_gate.asm" INCLUDE "text/maps/victory_road_2f.asm" diff --git a/text/maps/surf_house.asm b/text/maps/beach_house.asm similarity index 72% rename from text/maps/surf_house.asm rename to text/maps/beach_house.asm index b43df5cf23..318b6013d6 100644 --- a/text/maps/surf_house.asm +++ b/text/maps/beach_house.asm @@ -1,4 +1,4 @@ -SurfinDudeText1:: +_SurfinDudeText1:: text "Whoa!" para "Your PIKACHU knows" @@ -12,25 +12,25 @@ SurfinDudeText1:: para "Give it a go?" done -SurfinDudeText2:: +_SurfinDudeText2:: text "Come SURF anytime," line "my friend!" done -SurfinDudeText3:: +_SurfinDudeText3:: text "Wanna go SURF?" done -SurfinDudeText4:: +_SurfinDudeText4:: text "Dogs and burgers" line "on special today!" done -BeachHousePikachuText:: +_BeachHousePikachuText:: text "PIKACHU: Pikaa." done -BeachHouseSign1Text1:: +_BeachHouseSign1Text1:: text "SURFIN' DUDE's" line "scribbles..." @@ -39,12 +39,12 @@ BeachHouseSign1Text1:: cont "hit the groove!" done -BeachHouseSign1Text2:: +_BeachHouseSign1Text2:: text "30 years of waves!" line "SURFIN' DUDE" done -BeachHouseSign2Text1:: +_BeachHouseSign2Text1:: text "SURFING TIP 1!" para "After flips, line" @@ -53,12 +53,12 @@ BeachHouseSign2Text1:: cont "effect!" done -BeachHouseSign2Text2:: +_BeachHouseSign2Text2:: text "SUMMER BEACH HOUSE" line "#MON welcome!" done -BeachHouseSign3Text1:: +_BeachHouseSign3Text1:: text "SURFING TIP 2!" para "Pulling flips in" @@ -66,23 +66,27 @@ BeachHouseSign3Text1:: cont "rad!" done -BeachHouseSign3Text2:: +_BeachHouseSign3Text2:: text "The sea unites" line "all in surfdom!" done -BeachHousePrinterText1:: +_BeachHousePrinterText1:: + text "It's some sort of" + line "a machine...@@" + +_BeachHousePrinterText2:: text "SUMMER BEACH HOUSE" line "PRINTER, it says.@@" -BeachHousePrinterText2:: +_BeachHousePrinterText3:: text "The Hi.Score is" line "shown." para "PRINT it out?" done -BeachHousePrinterText3:: +_BeachHousePrinterText4:: text "SUMMER BEACH HOUSE" line "PRINTER, it says." @@ -92,8 +96,8 @@ BeachHousePrinterText3:: para "PRINT it out?" done -BeachHousePrinterText4:: +_BeachHousePrinterText5:: text "PRINT completed.@@" -BeachHousePrinterText5:: +_BeachHousePrinterText6:: text "PRINT error!@@" From 60bc4b9b9b9ed7c03e549a39d4f29998e951b01f Mon Sep 17 00:00:00 2001 From: IIMarckus Date: Fri, 17 Oct 2014 09:01:48 -0600 Subject: [PATCH 041/100] Fix Route 19 for Yellow. --- data/mapObjects/route19.asm | 17 +++++++++++++---- main.asm | 4 ++++ maps/route19-yellow.blk | 1 + 3 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 maps/route19-yellow.blk diff --git a/data/mapObjects/route19.asm b/data/mapObjects/route19.asm index 8ce41558e6..935e11ed8b 100755 --- a/data/mapObjects/route19.asm +++ b/data/mapObjects/route19.asm @@ -3,17 +3,26 @@ Route19Object: ; 0x54e9a (size=87) IF DEF(_YELLOW) db $1 ; warps - db $9, $5, $0, $f8 ; SURF_HOUSE + db $9, $5, $0, $f8 ; BEACH_HOUSE ELSE db $0 ; warps ENDC db $1 ; signs +IF DEF(_YELLOW) + db $b,$b,$b +ELSE db $9, $b, $b ; Route19Text11 +ENDC db $a ; people - db SPRITE_BLACK_HAIR_BOY_1, $7 + 4, $8 + 4, $ff, $d2, TRAINER | $1, SWIMMER + $C8, $2 - db SPRITE_BLACK_HAIR_BOY_1, $7 + 4, $d + 4, $ff, $d2, TRAINER | $2, SWIMMER + $C8, $3 +IF DEF(_YELLOW) + db SPRITE_BLACK_HAIR_BOY_1, $7 + 4, $9 + 4, $ff, $d3, TRAINER | 1, SWIMMER + $C8, 2 + db SPRITE_BLACK_HAIR_BOY_1, $9 + 4, $c + 4, $ff, $d2, TRAINER | 2, SWIMMER + $C8, 3 +ELSE + db SPRITE_BLACK_HAIR_BOY_1, $7 + 4, $8 + 4, $ff, $d2, TRAINER | 1, SWIMMER + $C8, 2 + db SPRITE_BLACK_HAIR_BOY_1, $7 + 4, $d + 4, $ff, $d2, TRAINER | 2, SWIMMER + $C8, 3 +ENDC db SPRITE_SWIMMER, $19 + 4, $d + 4, $ff, $d2, TRAINER | $3, SWIMMER + $C8, $4 db SPRITE_SWIMMER, $1b + 4, $4 + 4, $ff, $d3, TRAINER | $4, SWIMMER + $C8, $5 db SPRITE_SWIMMER, $1f + 4, $10 + 4, $ff, $d1, TRAINER | $5, SWIMMER + $C8, $6 @@ -25,5 +34,5 @@ Route19Object: ; 0x54e9a (size=87) ; warp-to IF DEF(_YELLOW) - EVENT_DISP ROUTE_19_WIDTH, $9, $5 ; SURF_HOUSE + EVENT_DISP ROUTE_19_WIDTH, $9, $5 ; BEACH_HOUSE ENDC diff --git a/main.asm b/main.asm index e0f3ac2ff3..2423d139a1 100755 --- a/main.asm +++ b/main.asm @@ -5965,7 +5965,11 @@ Route17Blocks: INCBIN "maps/route17.blk" INCLUDE "data/mapHeaders/route19.asm" INCLUDE "data/mapObjects/route19.asm" +IF DEF(_YELLOW) +Route19Blocks: INCBIN "maps/route19-yellow.blk" +ELSE Route19Blocks: INCBIN "maps/route19.blk" +ENDC INCLUDE "data/mapHeaders/route21.asm" INCLUDE "data/mapObjects/route21.asm" diff --git a/maps/route19-yellow.blk b/maps/route19-yellow.blk new file mode 100644 index 0000000000..3fc5849460 --- /dev/null +++ b/maps/route19-yellow.blk @@ -0,0 +1 @@ +(,)(,)(,)$W%$W%CCC11111CCC111CCk1111kkCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCkkkkkkkkk \ No newline at end of file From 50a39daa74a132397f7d389d1878158970e55bfc Mon Sep 17 00:00:00 2001 From: IIMarckus Date: Fri, 17 Oct 2014 09:24:04 -0600 Subject: [PATCH 042/100] More idioms. --- constants/map_constants.asm | 4 +++- data/mapObjects/beach_house.asm | 2 +- data/mapObjects/route19.asm | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/constants/map_constants.asm b/constants/map_constants.asm index 4e4e314f38..3703f6c517 100644 --- a/constants/map_constants.asm +++ b/constants/map_constants.asm @@ -246,4 +246,6 @@ TRADE_CENTER EQU $F0 LORELEIS_ROOM EQU $F5 BRUNOS_ROOM EQU $F6 AGATHAS_ROOM EQU $F7 -BEACH_HOUSE EQU $F8 ; Yellow only \ No newline at end of file +IF DEF(_YELLOW) +BEACH_HOUSE EQU $F8 +ENDC diff --git a/data/mapObjects/beach_house.asm b/data/mapObjects/beach_house.asm index 2f83603796..bad05ac977 100644 --- a/data/mapObjects/beach_house.asm +++ b/data/mapObjects/beach_house.asm @@ -12,7 +12,7 @@ BeachHouseObjects: ; 0xf23a4 db 1,$d,6 db 2 ; people - db $27, 3+4, 2+4, $ff, $d0, 1 ; surfin' dude + db SPRITE_FISHER, 3+4, 2+4, $ff, $d0, 1 ; surfin' dude db $3d, 3+4, 5+4, $fe, $01, 2 ; pikachu ; warp-to diff --git a/data/mapObjects/route19.asm b/data/mapObjects/route19.asm index 935e11ed8b..c225ed29d0 100755 --- a/data/mapObjects/route19.asm +++ b/data/mapObjects/route19.asm @@ -3,7 +3,7 @@ Route19Object: ; 0x54e9a (size=87) IF DEF(_YELLOW) db $1 ; warps - db $9, $5, $0, $f8 ; BEACH_HOUSE + db $9, $5, $0, BEACH_HOUSE ELSE db $0 ; warps ENDC From 292cf55baddf6d0f32b9d59816497c2041e99953 Mon Sep 17 00:00:00 2001 From: IIMarckus Date: Fri, 17 Oct 2014 09:28:15 -0600 Subject: [PATCH 043/100] More idioms. --- scripts/beach_house.asm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/beach_house.asm b/scripts/beach_house.asm index 82d72c83f5..7f0f54cf52 100644 --- a/scripts/beach_house.asm +++ b/scripts/beach_house.asm @@ -17,7 +17,7 @@ SurfinDudeText: jr nz,.next ld hl,.SurfinDudeText4 call PrintText - jr .xf2271 + jr .done .next ld hl,$d492 bit 0,[hl] @@ -29,8 +29,8 @@ SurfinDudeText: ld hl,.SurfinDudeText3 .next3 call PrintText - call $35ef - ld a,[$cc26] + call YesNoChoice + ld a,[wCurrentMenuItem] and a jr nz,.xf226b ld a,1 @@ -40,11 +40,11 @@ SurfinDudeText: call $3e84 ld hl,$d492 set 1,[hl] - jr .xf2271 + jr .done .xf226b ld hl,.SurfinDudeText2 call PrintText -.xf2271 +.done jp TextScriptEnd .SurfinDudeText1 @@ -151,8 +151,8 @@ BeachHouseSign4Text: ld [$cc3c],a ld hl,.BeachHousePrinterText3 call PrintText - call $35ef - ld a,[$cc26] + call YesNoChoice + ld a,[wCurrentMenuItem] and a jp z,$63d0 ; 0xf23d0 call $36ec From 16ad16302e0c5ee116c697454cb98a62cf0bb58b Mon Sep 17 00:00:00 2001 From: IIMarckus Date: Fri, 17 Oct 2014 11:13:22 -0600 Subject: [PATCH 044/100] Add the beach house tileset. --- data/collision.asm | 3 +++ data/tileset_headers.asm | 3 +++ gfx/blocksets/beachhouse.bst | Bin 0 -> 320 bytes gfx/tilesets/beachhouse.png | Bin 0 -> 566 bytes gfx/tilesets/beachhouse.tilecoll | 1 + main.asm | 10 ++++++++++ 6 files changed, 17 insertions(+) create mode 100644 gfx/blocksets/beachhouse.bst create mode 100644 gfx/tilesets/beachhouse.png create mode 100644 gfx/tilesets/beachhouse.tilecoll diff --git a/data/collision.asm b/data/collision.asm index 7857924243..d3659e2a9d 100644 --- a/data/collision.asm +++ b/data/collision.asm @@ -22,3 +22,6 @@ Lab_Coll:: INCBIN "gfx/tilesets/lab.tilecoll" Club_Coll:: INCBIN "gfx/tilesets/club.tilecoll" Facility_Coll:: INCBIN "gfx/tilesets/facility.tilecoll" Plateau_Coll:: INCBIN "gfx/tilesets/plateau.tilecoll" +IF DEF(_YELLOW) +BeachHouse_Coll:: INCBIN "gfx/tilesets/beachhouse.tilecoll" +ENDC diff --git a/data/tileset_headers.asm b/data/tileset_headers.asm index 84cfaffdec..6631b8f0ac 100755 --- a/data/tileset_headers.asm +++ b/data/tileset_headers.asm @@ -23,3 +23,6 @@ Tilesets: ; c7be (3:47be) tileset Club_Block, Club_GFX, Club_Coll, $07,$17,$FF, $FF, INDOOR tileset Facility_Block, Facility_GFX, Facility_Coll, $12,$FF,$FF, $FF, CAVE tileset Plateau_Block, Plateau_GFX, Plateau_Coll, $FF,$FF,$FF, $45, CAVE +IF DEF(_YELLOW) + tileset BeachHouse_Block, BeachHouse_GFX, BeachHouse_Coll, $FF,$FF,$FF, $FF, INDOOR +ENDC diff --git a/gfx/blocksets/beachhouse.bst b/gfx/blocksets/beachhouse.bst new file mode 100644 index 0000000000000000000000000000000000000000..bafbe0b24d7be0f0dd48a33977fa6a1c5aaf1ce5 GIT binary patch literal 320 zcmaiu$qs@*42Iho<9e|(#`U705YPjQD|&GEUEvMj<>W982_F0|Uz)#d{xnOoyvU2x zSV+fJdVdgd<12khTu;d3NojvAWO7y-3}|pX#|y$Bv~0_c;wY}?0L>P_a6|^qt9iKs z*zOR!J;dpZ_xXRn2H!PG1|`oIQM*I*{t%5PoK_YRQEC46Yk=zwV7@@SKMeiZn2?a4>2@TiU%#y2JAnOV*{4rE$O9r3$Yfq z)4R9g8ZC&F_SpZyi)_S;eRX{Mi)Qyd;vdjCEG&HZ?!0-kK(rqeGXTlzetf^leFcai zsMRdC0W#Civ8V-z7B3NXPSz(YT0ms+Vj*{T_SNKe0>nM|30pg(g^{tLmXh!d@$E+R ziQ=7{+QZ)dRoe$oFR63DM+QK>3O~=i=}%0RWg|(B#t{uaPaMz*z`3Sd{tF z^WJk|UNo>-O5C_pxe7y&z@fU`ZKHW7;^b5E@35+v{w{JY@WRZf9F><_9|V}Y{R zHCRcAuR8##g8RSuas1*!P=;KK-Fec0s5_Aa{141iP`gQhcmp6B4DKQ327-qG#eqO} zF491bV|h552>6dNfT0L9vJ!;j&;v_^3DpUGf^)HE1__3%PjFT~n|_ndv+t%JtX+iQ z)6ae|9!)d;gaXn{N?^GCAU;%l%)~x80A?N_f6n|XSljf%ESt`-QLnqlmXN<(Qw0@E zl;#kRx|`h=dzyrb>69MS{~pb56{?(VsGtL|G)MIA;Kl1l;>ia~O#mqQ$DF~u!y_-% zgbaW^Aus2^9$o0&YBklhXI>0$x0ttj8CwN>L;WY<8ha;=9{AnTr~m)}07*qoM6N<$ Ef|}U}+W-In literal 0 HcmV?d00001 diff --git a/gfx/tilesets/beachhouse.tilecoll b/gfx/tilesets/beachhouse.tilecoll new file mode 100644 index 0000000000..54ddac1942 --- /dev/null +++ b/gfx/tilesets/beachhouse.tilecoll @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/main.asm b/main.asm index 2423d139a1..7ee32d9308 100755 --- a/main.asm +++ b/main.asm @@ -6635,3 +6635,13 @@ INCLUDE "engine/evolution.asm" INCLUDE "engine/overworld/elevator.asm" INCLUDE "engine/items/tm_prices.asm" + +IF DEF(_YELLOW) +SECTION "bank3C",ROMX[$314],BANK[$3C] + +BeachHouse_GFX: + INCBIN "gfx/tilesets/beachhouse.2bpp" + +BeachHouse_Block: + INCBIN "gfx/blocksets/beachhouse.bst" +ENDC From 1d579928dc0a3ecbaa169ae76a7abcc310e2c7ce Mon Sep 17 00:00:00 2001 From: IIMarckus Date: Fri, 17 Oct 2014 12:16:52 -0600 Subject: [PATCH 045/100] Modularize the beach house. --- constants/map_constants.asm | 2 +- constants/map_dimensions.asm | 2 +- constants/tilesets.asm | 2 +- data/collision.asm | 2 +- data/mapObjects/route19.asm | 8 ++++---- data/map_header_banks.asm | 3 +++ data/map_header_pointers.asm | 3 +++ data/map_songs.asm | 3 +++ data/tileset_headers.asm | 2 +- main.asm | 11 +++++++---- text.asm | 2 +- yellow.asm | 1 + 12 files changed, 27 insertions(+), 14 deletions(-) diff --git a/constants/map_constants.asm b/constants/map_constants.asm index 3703f6c517..11deedd057 100644 --- a/constants/map_constants.asm +++ b/constants/map_constants.asm @@ -246,6 +246,6 @@ TRADE_CENTER EQU $F0 LORELEIS_ROOM EQU $F5 BRUNOS_ROOM EQU $F6 AGATHAS_ROOM EQU $F7 -IF DEF(_YELLOW) +IF DEF(_OPTION_BEACH_HOUSE) BEACH_HOUSE EQU $F8 ENDC diff --git a/constants/map_dimensions.asm b/constants/map_dimensions.asm index 2c6075faa8..236ccac4c3 100755 --- a/constants/map_dimensions.asm +++ b/constants/map_dimensions.asm @@ -892,7 +892,7 @@ BRUNOS_ROOM_WIDTH EQU $05 AGATHAS_ROOM_HEIGHT EQU $06 AGATHAS_ROOM_WIDTH EQU $05 -IF DEF(_YELLOW) +IF DEF(_OPTION_BEACH_HOUSE) BEACH_HOUSE_HEIGHT EQU 4 BEACH_HOUSE_WIDTH EQU 7 ENDC diff --git a/constants/tilesets.asm b/constants/tilesets.asm index ba549646d8..bf15f24e9c 100644 --- a/constants/tilesets.asm +++ b/constants/tilesets.asm @@ -22,6 +22,6 @@ LAB EQU 20 CLUB EQU 21 FACILITY EQU 22 PLATEAU EQU 23 -IF DEF(_YELLOW) +IF DEF(_OPTION_BEACH_HOUSE) BEACH_HOUSE_TILESET EQU 24 ENDC diff --git a/data/collision.asm b/data/collision.asm index d3659e2a9d..46d5ddc635 100644 --- a/data/collision.asm +++ b/data/collision.asm @@ -22,6 +22,6 @@ Lab_Coll:: INCBIN "gfx/tilesets/lab.tilecoll" Club_Coll:: INCBIN "gfx/tilesets/club.tilecoll" Facility_Coll:: INCBIN "gfx/tilesets/facility.tilecoll" Plateau_Coll:: INCBIN "gfx/tilesets/plateau.tilecoll" -IF DEF(_YELLOW) +IF DEF(_OPTION_BEACH_HOUSE) BeachHouse_Coll:: INCBIN "gfx/tilesets/beachhouse.tilecoll" ENDC diff --git a/data/mapObjects/route19.asm b/data/mapObjects/route19.asm index c225ed29d0..7d3a342c85 100755 --- a/data/mapObjects/route19.asm +++ b/data/mapObjects/route19.asm @@ -1,7 +1,7 @@ Route19Object: ; 0x54e9a (size=87) db $43 ; border block - IF DEF(_YELLOW) + IF DEF(_OPTION_BEACH_HOUSE) db $1 ; warps db $9, $5, $0, BEACH_HOUSE ELSE @@ -9,14 +9,14 @@ Route19Object: ; 0x54e9a (size=87) ENDC db $1 ; signs -IF DEF(_YELLOW) +IF DEF(_OPTION_BEACH_HOUSE) db $b,$b,$b ELSE db $9, $b, $b ; Route19Text11 ENDC db $a ; people -IF DEF(_YELLOW) +IF DEF(_OPTION_BEACH_HOUSE) db SPRITE_BLACK_HAIR_BOY_1, $7 + 4, $9 + 4, $ff, $d3, TRAINER | 1, SWIMMER + $C8, 2 db SPRITE_BLACK_HAIR_BOY_1, $9 + 4, $c + 4, $ff, $d2, TRAINER | 2, SWIMMER + $C8, 3 ELSE @@ -33,6 +33,6 @@ ENDC db SPRITE_SWIMMER, $2c + 4, $a + 4, $ff, $d0, TRAINER | $a, BEAUTY + $C8, $e ; warp-to - IF DEF(_YELLOW) + IF DEF(_OPTION_BEACH_HOUSE) EVENT_DISP ROUTE_19_WIDTH, $9, $5 ; BEACH_HOUSE ENDC diff --git a/data/map_header_banks.asm b/data/map_header_banks.asm index abc413c790..f6bd8d99d0 100755 --- a/data/map_header_banks.asm +++ b/data/map_header_banks.asm @@ -248,3 +248,6 @@ MapHeaderBanks: ; c23d (3:423d) db BANK(Lorelei_h) db BANK(Bruno_h) db BANK(Agatha_h) +IF DEF(_OPTION_BEACH_HOUSE) + db BANK(BeachHouse_h) +ENDC diff --git a/data/map_header_pointers.asm b/data/map_header_pointers.asm index 4f3248fc0e..771989a56e 100755 --- a/data/map_header_pointers.asm +++ b/data/map_header_pointers.asm @@ -248,3 +248,6 @@ MapHeaderPointers:: ; 01ae (0:01ae) dw Lorelei_h dw Bruno_h dw Agatha_h ;247 +IF DEF(_OPTION_BEACH_HOUSE) + dw BeachHouse_h +ENDC diff --git a/data/map_songs.asm b/data/map_songs.asm index c551a76d99..1d7ab269a0 100755 --- a/data/map_songs.asm +++ b/data/map_songs.asm @@ -247,3 +247,6 @@ MapSongBanks: ; c04d (3:404d) db MUSIC_GYM, BANK(Music_Gym) ; Lorelei db MUSIC_DUNGEON1, BANK(Music_Dungeon1) ; Bruno db MUSIC_POKEMON_TOWER, BANK(Music_PokemonTower) ; Agatha +IF DEF(_OPTION_BEACH_HOUSE) + db MUSIC_ROUTES3, BANK(Music_Routes3) ; BeachHouse +ENDC diff --git a/data/tileset_headers.asm b/data/tileset_headers.asm index 6631b8f0ac..3e2e68bb34 100755 --- a/data/tileset_headers.asm +++ b/data/tileset_headers.asm @@ -23,6 +23,6 @@ Tilesets: ; c7be (3:47be) tileset Club_Block, Club_GFX, Club_Coll, $07,$17,$FF, $FF, INDOOR tileset Facility_Block, Facility_GFX, Facility_Coll, $12,$FF,$FF, $FF, CAVE tileset Plateau_Block, Plateau_GFX, Plateau_Coll, $FF,$FF,$FF, $45, CAVE -IF DEF(_YELLOW) +IF DEF(_OPTION_BEACH_HOUSE) tileset BeachHouse_Block, BeachHouse_GFX, BeachHouse_Coll, $FF,$FF,$FF, $FF, INDOOR ENDC diff --git a/main.asm b/main.asm index 7ee32d9308..8bc9c17c38 100755 --- a/main.asm +++ b/main.asm @@ -5715,8 +5715,11 @@ CeladonHotelBlocks: INCBIN "maps/celadonhotel.blk" INCLUDE "data/mapHeaders/mtmoonpokecenter.asm" INCLUDE "scripts/mtmoonpokecenter.asm" -IF DEF(_YELLOW) +IF DEF(_OPTION_BEACH_HOUSE) +INCLUDE "data/mapHeaders/beach_house.asm" INCLUDE "scripts/beach_house.asm" +BeachHouseBlockdata: INCBIN "maps/beach_house.blk" +INCLUDE "data/mapObjects/beach_house.asm" ENDC INCLUDE "data/mapObjects/mtmoonpokecenter.asm" @@ -5965,7 +5968,7 @@ Route17Blocks: INCBIN "maps/route17.blk" INCLUDE "data/mapHeaders/route19.asm" INCLUDE "data/mapObjects/route19.asm" -IF DEF(_YELLOW) +IF DEF(_OPTION_BEACH_HOUSE) Route19Blocks: INCBIN "maps/route19-yellow.blk" ELSE Route19Blocks: INCBIN "maps/route19.blk" @@ -6636,8 +6639,8 @@ INCLUDE "engine/overworld/elevator.asm" INCLUDE "engine/items/tm_prices.asm" -IF DEF(_YELLOW) -SECTION "bank3C",ROMX[$314],BANK[$3C] +IF DEF(_OPTION_BEACH_HOUSE) +SECTION "bank3C",ROMX[$4314],BANK[$3C] BeachHouse_GFX: INCBIN "gfx/tilesets/beachhouse.2bpp" diff --git a/text.asm b/text.asm index f1db4f5412..61c8675fc0 100644 --- a/text.asm +++ b/text.asm @@ -2135,7 +2135,7 @@ INCLUDE "text/maps/route_16_gate_upstairs.asm" INCLUDE "text/maps/route_16_house.asm" INCLUDE "text/maps/route_18_gate.asm" INCLUDE "text/maps/route_18_gate_upstairs.asm" -IF DEF(_YELLOW) +IF DEF(_OPTION_BEACH_HOUSE) INCLUDE "text/maps/beach_house.asm" ENDC INCLUDE "text/maps/pokemon_league_gate.asm" diff --git a/yellow.asm b/yellow.asm index 2dedf5862b..8e5956c63a 100644 --- a/yellow.asm +++ b/yellow.asm @@ -1 +1,2 @@ _YELLOW EQU 1 +_OPTION_BEACH_HOUSE EQU 1 From 21b2ab0065155a3f1aa8406e24f0a02929c06ea4 Mon Sep 17 00:00:00 2001 From: IIMarckus Date: Fri, 17 Oct 2014 13:08:40 -0600 Subject: [PATCH 046/100] Fix a few more bugs in the beach house. --- data/mapHeaders/beach_house.asm | 3 ++- data/mapObjects/beach_house.asm | 2 +- data/wild_mons.asm | 2 +- main.asm | 12 ++++++------ 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/data/mapHeaders/beach_house.asm b/data/mapHeaders/beach_house.asm index 4dc109ae2c..11579ef1e2 100644 --- a/data/mapHeaders/beach_house.asm +++ b/data/mapHeaders/beach_house.asm @@ -1,6 +1,7 @@ BeachHouse_h: + db BEACH_HOUSE_TILESET - dw BEACH_HOUSE_HEIGHT, BEACH_HOUSE_WIDTH ; dimensions (y, x) + db BEACH_HOUSE_HEIGHT, BEACH_HOUSE_WIDTH ; dimensions (y, x) dw BeachHouseBlockdata,BeachHouseTextPointers,BeachHouseScript ; blocks, texts, scripts db 0 ; connections dw BeachHouseObjects ; objects diff --git a/data/mapObjects/beach_house.asm b/data/mapObjects/beach_house.asm index bad05ac977..ad648931d4 100644 --- a/data/mapObjects/beach_house.asm +++ b/data/mapObjects/beach_house.asm @@ -7,7 +7,7 @@ BeachHouseObjects: ; 0xf23a4 db 4 ; signs db 0,3,3 - db 0,7,4, + db 0,7,4 db 0,$b,5 db 1,$d,6 diff --git a/data/wild_mons.asm b/data/wild_mons.asm index ac1bb3cc7a..f29fd34083 100755 --- a/data/wild_mons.asm +++ b/data/wild_mons.asm @@ -247,7 +247,7 @@ WildDataPointers: ; ceeb (3:4eeb) dw NoMons dw NoMons dw NoMons - IF DEF(_YELLOW) + IF DEF(_OPTION_BEACH_HOUSE) dw NoMons ENDC dw $FFFF diff --git a/main.asm b/main.asm index 8bc9c17c38..400c6806c4 100755 --- a/main.asm +++ b/main.asm @@ -5059,6 +5059,12 @@ INCLUDE "data/mapHeaders/billshouse.asm" INCLUDE "scripts/billshouse.asm" INCLUDE "data/mapObjects/billshouse.asm" BillsHouseBlocks: INCBIN "maps/billshouse.blk" +IF DEF(_OPTION_BEACH_HOUSE) +INCLUDE "data/mapHeaders/beach_house.asm" +INCLUDE "scripts/beach_house.asm" +BeachHouseBlockdata: INCBIN "maps/beach_house.blk" +INCLUDE "data/mapObjects/beach_house.asm" +ENDC INCLUDE "engine/menu/oaks_pc.asm" @@ -5715,12 +5721,6 @@ CeladonHotelBlocks: INCBIN "maps/celadonhotel.blk" INCLUDE "data/mapHeaders/mtmoonpokecenter.asm" INCLUDE "scripts/mtmoonpokecenter.asm" -IF DEF(_OPTION_BEACH_HOUSE) -INCLUDE "data/mapHeaders/beach_house.asm" -INCLUDE "scripts/beach_house.asm" -BeachHouseBlockdata: INCBIN "maps/beach_house.blk" -INCLUDE "data/mapObjects/beach_house.asm" -ENDC INCLUDE "data/mapObjects/mtmoonpokecenter.asm" INCLUDE "data/mapHeaders/rocktunnelpokecenter.asm" From deb2db01cb7cf36f0f6302cb548f096c5d312c1c Mon Sep 17 00:00:00 2001 From: IIMarckus Date: Fri, 17 Oct 2014 13:16:11 -0600 Subject: [PATCH 047/100] Replace hardcoded pointer with label. --- scripts/beach_house.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/beach_house.asm b/scripts/beach_house.asm index 7f0f54cf52..67c29f1b6b 100644 --- a/scripts/beach_house.asm +++ b/scripts/beach_house.asm @@ -111,7 +111,7 @@ BeachHouseSign2Text: BeachHouseSign3Text: db 8 - ld hl,$62f4 + ld hl,.BeachHouseSign3Text2 ld a,[$d471] bit 6,a jr z,.next From 9004b33ab7986b617ca950e41b42d677d5378913 Mon Sep 17 00:00:00 2001 From: IIMarckus Date: Fri, 17 Oct 2014 13:24:51 -0600 Subject: [PATCH 048/100] Add a shifted person object on Route 19 in Yellow. --- data/mapObjects/route19.asm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/data/mapObjects/route19.asm b/data/mapObjects/route19.asm index 7d3a342c85..c6f80b6cd9 100755 --- a/data/mapObjects/route19.asm +++ b/data/mapObjects/route19.asm @@ -26,7 +26,11 @@ ENDC db SPRITE_SWIMMER, $19 + 4, $d + 4, $ff, $d2, TRAINER | $3, SWIMMER + $C8, $4 db SPRITE_SWIMMER, $1b + 4, $4 + 4, $ff, $d3, TRAINER | $4, SWIMMER + $C8, $5 db SPRITE_SWIMMER, $1f + 4, $10 + 4, $ff, $d1, TRAINER | $5, SWIMMER + $C8, $6 +IF DEF(_OPTION_BEACH_HOUSE) + db SPRITE_SWIMMER, $d + 4, $9 + 4, $ff, $d0, TRAINER | $6, SWIMMER + $C8, $7 +ELSE db SPRITE_SWIMMER, $b + 4, $9 + 4, $ff, $d0, TRAINER | $6, SWIMMER + $C8, $7 +ENDC db SPRITE_SWIMMER, $2b + 4, $8 + 4, $ff, $d2, TRAINER | $7, BEAUTY + $C8, $c db SPRITE_SWIMMER, $2b + 4, $b + 4, $ff, $d3, TRAINER | $8, BEAUTY + $C8, $d db SPRITE_SWIMMER, $2a + 4, $9 + 4, $ff, $d1, TRAINER | $9, SWIMMER + $C8, $8 From 2e376fecabd5216d6358c03789e9903b7cb1bd19 Mon Sep 17 00:00:00 2001 From: IIMarckus Date: Fri, 17 Oct 2014 15:13:14 -0600 Subject: [PATCH 049/100] Add some Yellow text from the Safari Zone entrance. --- yellow.asm | 1 + 1 file changed, 1 insertion(+) diff --git a/yellow.asm b/yellow.asm index 8e5956c63a..b1417eff24 100644 --- a/yellow.asm +++ b/yellow.asm @@ -1,2 +1,3 @@ _YELLOW EQU 1 _OPTION_BEACH_HOUSE EQU 1 +_OPTION_LOWCOST_SAFARI EQU 1 From a36e090d43de2f66b26616e3c46f0da8f7d52466 Mon Sep 17 00:00:00 2001 From: IIMarckus Date: Fri, 17 Oct 2014 22:47:31 -0600 Subject: [PATCH 050/100] Add parts of the Safari Zone entrance script from Yellow. --- scripts/safarizoneentrance-yellow.asm | 257 ++++++++++++++++++++++++++ scripts/safarizoneentrance.asm | 209 +++++++++++---------- text/maps/safari_zone_entrance.asm | 46 +++++ wram.asm | 3 + 4 files changed, 410 insertions(+), 105 deletions(-) create mode 100644 scripts/safarizoneentrance-yellow.asm diff --git a/scripts/safarizoneentrance-yellow.asm b/scripts/safarizoneentrance-yellow.asm new file mode 100644 index 0000000000..93f9162023 --- /dev/null +++ b/scripts/safarizoneentrance-yellow.asm @@ -0,0 +1,257 @@ +.xf1f77 + ld hl,.ForJust500Text + call PrintText + ld a,$13 + ld [wd125],a + call DisplayTextBoxID + call YesNoChoice + ld a,[wCurrentMenuItem] + and a + jp nz,.PleaseComeAgain + ld hl,$d346 ; yellow d346 + ld a,[hli] + or [hl] + inc hl + or [hl] + jr nz,.xf1f9f +.xf1f98 + call .xf20ce + jr c,.CantPayWalkDown + jr .xf1ff2 + +.xf1f9f + xor a + ld [$ff9f],a + ld a,$05 + ld [$ffa0],a + ld a,$00 + ld [$ffa1],a + call HasEnoughMoney + jr nc,.success + ld hl,.NotEnoughMoneyText + call PrintText + call .xf2077 + jr c,.CantPayWalkDown + jr .xf1ff2 + +.success + xor a + ld [wSubtrahend],a + ld a,$05 + ld [wSubtrahend+1],a + ld a,$00 + ld [wSubtrahend+2],a + ld hl,wTrainerFacingDirection + ld de,wPlayerMoney + 2 + ld c,3 + predef SubBCDPredef + ld a,$b2 + call $3736 + call $373e + ld a,$13 + ld [wd125],a + call DisplayTextBoxID + ld hl,.MakePaymentText + call PrintText + ld a,30 + ld hl,(502 / $100) << 8 | (502 % $100) +.xf1ff2 + ld [W_NUMSAFARIBALLS],a + ld a,h + ld [wSafariSteps],a + ld a,l + ld [wSafariSteps + 1],a + ld a,$40 + ld c,3 + call SafariZoneEntranceAutoWalk + ld hl,wd790 + set 7,[hl] + res 6,[hl] + ld a,3 + ld [W_SAFARIZONEENTRANCECURSCRIPT],a + jr .done + +.PleaseComeAgain + ld hl,.PleaseComeAgainText + call PrintText +.CantPayWalkDown + ld a,$80 + ld c,1 + call SafariZoneEntranceAutoWalk + ld a,4 + ld [W_SAFARIZONEENTRANCECURSCRIPT],a +.done + ret + +.ForJust500Text + TX_FAR SafariZoneEntranceText_9e6e4 + db "@" + +.MakePaymentText + TX_FAR SafariZoneEntranceText_9e747 + db $b + TX_FAR _SafariZoneEntranceText_75360 + db "@" + +.PleaseComeAgainText + TX_FAR _SafariZoneEntranceText_75365 + db "@" + +.NotEnoughMoneyText + TX_FAR _SafariZoneEntranceText_7536a + db "@" + +.SafariZoneEntranceText2 + ld hl,.FirstTimeQuestionText + call PrintText + call YesNoChoice + ld a,[wCurrentMenuItem] + and a + ld hl,.RegularText + jr nz,.Explanation + ld hl,.ExplanationText +.Explanation + call PrintText + ret + +.FirstTimeQuestionText + TX_FAR _SafariZoneEntranceText_753e6 + db "@" + +.ExplanationText + TX_FAR _SafariZoneEntranceText_753eb + db "@" + +.RegularText + TX_FAR _SafariZoneEntranceText_753f0 + db "@" + +SafariZoneEntranceAutoWalk: + push af + ld b,0 + ld a,c + ld [wSimulatedJoypadStatesIndex],a + ld hl,wSimulatedJoypadStatesEnd + pop af + call FillMemory + jp StartSimulatingJoypadStates + +.xf2077 + ld hl,$d346 + ld de,$ff9f + ld bc,3 + call $1b + xor a + ld [$ffa2],a + ld [$ffa3],a + ld a,$17 + ld [$ffa4],a + ld a,$d + call $3eb4 + ld a,[$ffa4] + call .xf211e + pop af + ld hl,$d346 + xor a + ld bc,3 + call $166e + ld hl,.OhAllRightText + call $3c46 + ld a,$13 + ld a,[$d124] + call $3010 + ld hl,.CantGive30BallsText + call PrintText + pop af + inc a + jr z,.xf20bd + cp $1d + jr c,.xf20bf +.xf20bd + ld a,$1d +.xf20bf + ld hl,$1f6 + and a + ret + +.OhAllRightText + TX_FAR _SafariZoneLowCostText1 + db "@" + +.CantGive30BallsText + TX_FAR _SafariZoneLowCostText2 + db "@" + +.xf20ce + ld hl,$d70c + ld a,[hl] + push af + inc [hl] + ld e,a + ld d,0 + ld hl,.lowcosttextpointers + add hl,de + add hl,de + ld a,[hli] + ld h,[hl] + ld l,a + call PrintText + pop af + cp 3 + jr z,.next + scf + ret + +.next + ld hl,.xf20f6 + call $3c46 + ld a,1 + ld hl,$01f6 + and a + ret + +.xf20f6 + TX_FAR _SafariZoneLowCostText3 + db $b + TX_FAR _SafariZoneLowCostText4 + db "@" + +.lowcosttextpointers + dw .xf210a + dw .xf210f + dw .xf2114 + dw .xf2119 + dw .xf2119 + +.xf210a + TX_FAR _SafariZoneLowCostText5 + db "@" + +.xf210f + TX_FAR _SafariZoneLowCostText6 + db "@" + +.xf2114 + TX_FAR _SafariZoneLowCostText7 + db "@" + +.xf2119 + TX_FAR _SafariZoneLowCostText8 + db "@" + +.xf211e + push hl + ld c,a + and $f + ld l,a + ld h,0 + ld a,c + and $f0 + swap a + ld bc,$a + call $3a74 + ld a,l + pop hl + ret + +.xf2133 diff --git a/scripts/safarizoneentrance.asm b/scripts/safarizoneentrance.asm index 8ae81f8170..e5653ff1b8 100755 --- a/scripts/safarizoneentrance.asm +++ b/scripts/safarizoneentrance.asm @@ -5,16 +5,16 @@ SafariZoneEntranceScript: ; 751cd (1d:51cd) jp CallFunctionInTable SafariZoneEntranceScriptPointers: ; 751d9 (1d:51d9) - dw SafariZoneEntranceScript0 - dw SafariZoneEntranceScript1 - dw SafariZoneEntranceScript2 - dw SafariZoneEntranceScript3 - dw SafariZoneEntranceScript4 - dw SafariZoneEntranceScript5 - dw SafariZoneEntranceScript6 + dw .SafariZoneEntranceScript0 + dw .SafariZoneEntranceScript1 + dw .SafariZoneEntranceScript2 + dw .SafariZoneEntranceScript3 + dw .SafariZoneEntranceScript4 + dw .SafariZoneEntranceScript5 + dw .SafariZoneEntranceScript6 -SafariZoneEntranceScript0: ; 751e7 (1d:51e7) - ld hl, CoordsData_75221 +.SafariZoneEntranceScript0 + ld hl, .CoordsData_75221 call ArePlayerCoordsInArray ret nc ld a, $3 @@ -35,22 +35,22 @@ SafariZoneEntranceScript0: ; 751e7 (1d:51e7) .asm_7520f ld a, $10 ld c, $1 - call SafariZoneEntranceScript_752a3 + call SafariZoneEntranceAutoWalk ld a, $f0 ld [wJoyIgnore], a ld a, $1 ld [W_SAFARIZONEENTRANCECURSCRIPT], a ret -CoordsData_75221: ; 75221 (1d:5221) +.CoordsData_75221: ; 75221 (1d:5221) db $02,$03 db $02,$04 db $FF -SafariZoneEntranceScript1: ; 75226 (1d:5226) +.SafariZoneEntranceScript1 call SafariZoneEntranceScript_752b4 ret nz -SafariZoneEntranceScript2: ; 7522a (1d:522a) +.SafariZoneEntranceScript2 xor a ld [hJoyHeld], a ld [wJoyIgnore], a @@ -62,7 +62,7 @@ SafariZoneEntranceScript2: ; 7522a (1d:522a) ld [wJoyIgnore], a ret -SafariZoneEntranceScript3: ; 75240 (1d:5240) +.SafariZoneEntranceScript3 call SafariZoneEntranceScript_752b4 ret nz xor a @@ -71,7 +71,7 @@ SafariZoneEntranceScript3: ; 75240 (1d:5240) ld [W_SAFARIZONEENTRANCECURSCRIPT], a ret -SafariZoneEntranceScript5: ; 7524e (1d:524e) +.SafariZoneEntranceScript5 ld a, $4 ld [wd528], a ld hl, wd790 @@ -89,7 +89,7 @@ SafariZoneEntranceScript5: ; 7524e (1d:524e) ld [W_NUMSAFARIBALLS], a ld a, $80 ld c, $3 - call SafariZoneEntranceScript_752a3 + call SafariZoneEntranceAutoWalk ld a, $4 ld [W_SAFARIZONEENTRANCECURSCRIPT], a jr .asm_75286 ; 0x7527d $7 @@ -100,7 +100,7 @@ SafariZoneEntranceScript5: ; 7524e (1d:524e) .asm_75286 ret -SafariZoneEntranceScript4: ; 75287 (1d:5287) +.SafariZoneEntranceScript4 call SafariZoneEntranceScript_752b4 ret nz xor a @@ -109,7 +109,7 @@ SafariZoneEntranceScript4: ; 75287 (1d:5287) ld [W_SAFARIZONEENTRANCECURSCRIPT], a ret -SafariZoneEntranceScript6: ; 75295 (1d:5295) +.SafariZoneEntranceScript6 call SafariZoneEntranceScript_752b4 ret nz call Delay3 @@ -117,128 +117,127 @@ SafariZoneEntranceScript6: ; 75295 (1d:5295) ld [W_SAFARIZONEENTRANCECURSCRIPT], a ret -SafariZoneEntranceScript_752a3: ; 752a3 (1d:52a3) +SafariZoneEntranceAutoWalk: push af - ld b, $0 - ld a, c - ld [wSimulatedJoypadStatesIndex], a - ld hl, wSimulatedJoypadStatesEnd + ld b,0 + ld a,c + ld [wSimulatedJoypadStatesIndex],a + ld hl,wSimulatedJoypadStatesEnd pop af call FillMemory jp StartSimulatingJoypadStates -SafariZoneEntranceScript_752b4: ; 752b4 (1d:52b4) +SafariZoneEntranceScript_752b4: ld a, [wSimulatedJoypadStatesIndex] and a ret SafariZoneEntranceTextPointers: ; 752b9 (1d:52b9) - dw SafariZoneEntranceText1 - dw SafariZoneEntranceText2 - dw SafariZoneEntranceText3 - dw SafariZoneEntranceText4 - dw SafariZoneEntranceText5 - dw SafariZoneEntranceText6 + dw .SafariZoneEntranceText1 + dw .SafariZoneEntranceText2 + dw .SafariZoneEntranceText1 + dw .SafariZoneEntranceText4 + dw .SafariZoneEntranceText5 + dw .SafariZoneEntranceText6 -SafariZoneEntranceText3: ; 752c5 (1d:52c5) -SafariZoneEntranceText1: ; 752c5 (1d:52c5) +.SafariZoneEntranceText1 TX_FAR _SafariZoneEntranceText1 db "@" -SafariZoneEntranceText4: ; 752ca (1d:52ca) +.SafariZoneEntranceText4 TX_FAR SafariZoneEntranceText_9e6e4 ; 0x9e6e4 db $8 ld a, $13 - ld [wd125], a + ld [wd125],a call DisplayTextBoxID call YesNoChoice - ld a, [wCurrentMenuItem] + ld a,[wCurrentMenuItem] and a - jp nz, .asm_75346 + jp nz,.PleaseComeAgain xor a - ld [$ff9f], a - ld a, $5 - ld [$ffa0], a - ld a, $0 - ld [$ffa1], a + ld [$ff9f],a + ld a,$05 + ld [$ffa0],a + ld a,$00 + ld [$ffa1],a call HasEnoughMoney - jr nc, .asm_752f9 ; 0x752ef $8 - ld hl, SafariZoneEntranceText_7536a + jr nc,.success + ld hl,.NotEnoughMoneyText call PrintText - jr .asm_7534c ; 0x752f7 $53 -.asm_752f9 + jr .CantPayWalkDown + +.success xor a - ld [wWhichTrade], a - ld a, $5 - ld [wTrainerEngageDistance], a - ld a, $0 - ld [wTrainerFacingDirection], a - ld hl, wTrainerFacingDirection - ld de, wPlayerMoney + 2 - ld c, $3 + ld [wSubtrahend],a + ld a,$05 + ld [wSubtrahend+1],a + ld a,$00 + ld [wSubtrahend+2],a + ld hl,wTrainerFacingDirection + ld de,wPlayerMoney + 2 + ld c,3 predef SubBCDPredef - ld a, $13 - ld [wd125], a + ld a,$13 + ld [wd125],a call DisplayTextBoxID - ld hl, SafariZoneEntranceText_7535b + ld hl,.MakePaymentText call PrintText - ld a, $1e - ld [W_NUMSAFARIBALLS], a - ld a, 502 / $100 - ld [wSafariSteps], a + ld a,30 + ld [W_NUMSAFARIBALLS],a + ld a,502 / $100 + ld [wSafariSteps],a ld a, 502 % $100 - ld [wSafariSteps + 1], a - ld a, $40 - ld c, $3 - call SafariZoneEntranceScript_752a3 - ld hl, wd790 - set 7, [hl] - res 6, [hl] - ld a, $3 - ld [W_SAFARIZONEENTRANCECURSCRIPT], a - jr .asm_75358 ; 0x75344 $12 -.asm_75346 - ld hl, SafariZoneEntranceText_75365 + ld [wSafariSteps + 1],a + ld a,$40 + ld c,3 + call SafariZoneEntranceAutoWalk + ld hl,wd790 + set 7,[hl] + res 6,[hl] + ld a,3 + ld [W_SAFARIZONEENTRANCECURSCRIPT],a + jr .done + +.PleaseComeAgain + ld hl,.PleaseComeAgainText call PrintText -.asm_7534c - ld a, $80 - ld c, $1 - call SafariZoneEntranceScript_752a3 - ld a, $4 - ld [W_SAFARIZONEENTRANCECURSCRIPT], a -.asm_75358 +.CantPayWalkDown + ld a,$80 + ld c,1 + call SafariZoneEntranceAutoWalk + ld a,4 + ld [W_SAFARIZONEENTRANCECURSCRIPT],a +.done jp TextScriptEnd -SafariZoneEntranceText_7535b: ; 7535b (1d:535b) - TX_FAR SafariZoneEntranceText_9e747 ; 0x9e747 - db $0B - -SafariZoneEntranceText_75360: ; 75360 (1d:5360) +.MakePaymentText + TX_FAR SafariZoneEntranceText_9e747 + db $b TX_FAR _SafariZoneEntranceText_75360 db "@" -SafariZoneEntranceText_75365: ; 75365 (1d:5365) +.PleaseComeAgainText TX_FAR _SafariZoneEntranceText_75365 db "@" -SafariZoneEntranceText_7536a: ; 7536a (1d:536a) +.NotEnoughMoneyText TX_FAR _SafariZoneEntranceText_7536a db "@" -SafariZoneEntranceText5: ; 7536f (1d:536f) +.SafariZoneEntranceText5 TX_FAR SafariZoneEntranceText_9e814 ; 0x9e814 db $8 call YesNoChoice - ld a, [wCurrentMenuItem] + ld a,[wCurrentMenuItem] and a jr nz, .asm_7539c ; 0x7537b $1f - ld hl, SafariZoneEntranceText_753bb + ld hl, .SafariZoneEntranceText_753bb call PrintText xor a ld [wSpriteStateData1 + 9], a ld a, $80 ld c, $3 - call SafariZoneEntranceScript_752a3 + call SafariZoneEntranceAutoWalk ld hl, wd790 res 6, [hl] res 7, [hl] @@ -246,13 +245,13 @@ SafariZoneEntranceText5: ; 7536f (1d:536f) ld [wcf0d], a jr .asm_753b3 ; 0x7539a $17 .asm_7539c - ld hl, SafariZoneEntranceText_753c0 + ld hl, .SafariZoneEntranceText_753c0 call PrintText ld a, $4 ld [wSpriteStateData1 + 9], a ld a, $40 ld c, $1 - call SafariZoneEntranceScript_752a3 + call SafariZoneEntranceAutoWalk ld a, $5 ld [wcf0d], a .asm_753b3 @@ -260,40 +259,40 @@ SafariZoneEntranceText5: ; 7536f (1d:536f) ld [W_SAFARIZONEENTRANCECURSCRIPT], a jp TextScriptEnd -SafariZoneEntranceText_753bb: ; 753bb (1d:53bb) +.SafariZoneEntranceText_753bb TX_FAR _SafariZoneEntranceText_753bb db "@" -SafariZoneEntranceText_753c0: ; 753c0 (1d:53c0) +.SafariZoneEntranceText_753c0 TX_FAR _SafariZoneEntranceText_753c0 db "@" -SafariZoneEntranceText6: ; 753c5 (1d:53c5) +.SafariZoneEntranceText6 TX_FAR _SafariZoneEntranceText_753c5 db "@" -SafariZoneEntranceText2: ; 753ca (1d:53ca) +.SafariZoneEntranceText2 db $08 ; asm - ld hl, SafariZoneEntranceText_753e6 + ld hl,.FirstTimeQuestionText call PrintText call YesNoChoice - ld a, [wCurrentMenuItem] + ld a,[wCurrentMenuItem] and a - ld hl, SafariZoneEntranceText_753f0 - jr nz, .asm_278a6 ; 0x753db - ld hl, SafariZoneEntranceText_753eb -.asm_278a6 ; 0x753e0 + ld hl,.RegularText + jr nz,.Explanation + ld hl,.ExplanationText +.Explanation call PrintText jp TextScriptEnd -SafariZoneEntranceText_753e6: ; 753e6 (1d:53e6) +.FirstTimeQuestionText TX_FAR _SafariZoneEntranceText_753e6 db "@" -SafariZoneEntranceText_753eb: ; 753eb (1d:53eb) +.ExplanationText TX_FAR _SafariZoneEntranceText_753eb db "@" -SafariZoneEntranceText_753f0: ; 753f0 (1d:53f0) +.RegularText TX_FAR _SafariZoneEntranceText_753f0 db "@" diff --git a/text/maps/safari_zone_entrance.asm b/text/maps/safari_zone_entrance.asm index 119d23019e..79f70ea4a9 100644 --- a/text/maps/safari_zone_entrance.asm +++ b/text/maps/safari_zone_entrance.asm @@ -92,3 +92,49 @@ _SafariZoneEntranceText_753f0:: ; 9e993 (27:6993) line "regular here!" done +IF DEF(_OPTION_LOWCOST_SAFARI) +_SafariZoneLowCostText1:: + db 0 + para "Oh, all right, pay" + line "me what you have." + prompt + +_SafariZoneLowCostText2:: + text "But, I can't give" + line "you all 30 BALLs." + done + +_SafariZoneLowCostText3:: + db 0 + para "You're persistent," + line "aren't you?" + + para "OK, you can go in" + line "for free, but" + cont "just this once!@@" + +_SafariZoneLowCostText4:: + db 0 + done + +_SafariZoneLowCostText5:: + text "I'm sorry, but you" + line "have to pay to" + cont "enter." + done + +_SafariZoneLowCostText6:: + text "You can't enter" + line "without paying!" + done + +_SafariZoneLowCostText7:: + text "I said, no money," + line "no entry!" + done + +_SafariZoneLowCostText8:: + text "Read my lips, NO!" + line "Get it?" + done +ENDC diff --git a/wram.asm b/wram.asm index 15c339d147..86d1015281 100755 --- a/wram.asm +++ b/wram.asm @@ -510,6 +510,9 @@ wPlayerSpinWhileMovingUpOrDownAnimDeltaY:: ; cd3d wHiddenObjectFunctionArgument:: ; cd3d +wSubtrahend:: ; cd3d +; subtract (BCD) wSubtrahend, wSubtrahend+1, wSubtrahend+2 + wWhichTrade:: ; cd3d ; which entry from TradeMons to select From 519dd7fd56c4688ead80e444d945fc188cea5b66 Mon Sep 17 00:00:00 2001 From: IIMarckus Date: Sat, 18 Oct 2014 08:57:53 -0600 Subject: [PATCH 051/100] Improve labels for Yellow Safari Zone entrance. --- scripts/safarizoneentrance-yellow.asm | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/scripts/safarizoneentrance-yellow.asm b/scripts/safarizoneentrance-yellow.asm index 93f9162023..1f1b6c23a9 100644 --- a/scripts/safarizoneentrance-yellow.asm +++ b/scripts/safarizoneentrance-yellow.asm @@ -137,38 +137,37 @@ SafariZoneEntranceAutoWalk: jp StartSimulatingJoypadStates .xf2077 - ld hl,$d346 + ld hl,wPlayerMoney ld de,$ff9f ld bc,3 - call $1b + call $b1 ; yellow $00b1 xor a ld [$ffa2],a ld [$ffa3],a - ld a,$17 + ld a,$17 ; ¥17 per safari ball ld [$ffa4],a - ld a,$d - call $3eb4 + predef DivideBCDPredef3 ld a,[$ffa4] call .xf211e pop af ld hl,$d346 xor a ld bc,3 - call $166e + call FillMemory ld hl,.OhAllRightText - call $3c46 + call Func_3c59 ld a,$13 ld a,[$d124] - call $3010 + call DisplayTextBoxID ld hl,.CantGive30BallsText call PrintText pop af inc a jr z,.xf20bd - cp $1d + cp 29 jr c,.xf20bf .xf20bd - ld a,$1d + ld a,29 .xf20bf ld hl,$1f6 and a From d0bb99ec893c3880a8b606e7680bcdbaee71a46d Mon Sep 17 00:00:00 2001 From: IIMarckus Date: Tue, 21 Oct 2014 01:31:34 -0600 Subject: [PATCH 052/100] =?UTF-8?q?Add=20Yellow=E2=80=99s=20slot=20machine?= =?UTF-8?q?=20graphics.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- engine/battle/animations.asm | 3 +++ engine/slot_machine.asm | 3 +++ gfx/yellow/slotmachine1.png | Bin 0 -> 470 bytes gfx/yellow/slotmachine2.png | Bin 0 -> 379 bytes 4 files changed, 6 insertions(+) create mode 100644 gfx/yellow/slotmachine1.png create mode 100644 gfx/yellow/slotmachine2.png diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm index 0e5c025fa9..addcd8d6cf 100755 --- a/engine/battle/animations.asm +++ b/engine/battle/animations.asm @@ -373,6 +373,9 @@ ENDC IF DEF(_BLUE) INCBIN "gfx/blue/slotmachine2.2bpp" ENDC +INF DEF(_YELLOW) + INCBIN "gfx/yellow/slotmachine2.2bpp" +ENDC MoveAnimation: ; 78d5e (1e:4d5e) push hl diff --git a/engine/slot_machine.asm b/engine/slot_machine.asm index 5b72c8b121..a8b978f88d 100755 --- a/engine/slot_machine.asm +++ b/engine/slot_machine.asm @@ -868,3 +868,6 @@ ENDC IF DEF(_BLUE) INCBIN "gfx/blue/slotmachine1.2bpp" ENDC +IF DEF(_YELLOW) + INCBIN "gfx/yellow/slotmachine1.2bpp" +ENDC diff --git a/gfx/yellow/slotmachine1.png b/gfx/yellow/slotmachine1.png new file mode 100644 index 0000000000000000000000000000000000000000..335ce97c0e61ce4346f6a69a7656d2ac4a022314 GIT binary patch literal 470 zcmV;{0V)28P)>m0004CHid%KPB0`LU)U`|B(8cAg z&W^&9!dr!U&TVXhZTN9}@}2LyIk}{Cnj}fiK|<$>!+mD+LhK!zcnnpu<@ent*rgo z{xYG*_8<1TiWGAD!?5x?8`*Fs6nj*UAhRJ-z zwz+Ub8SzL-DlX{0a2>wQ$XA9gIMI7O{cB9G)91Xk#m0fhdEP)E3}t~iSJp8v(&JEXtN+h zBcgOEh7xTSB}>613|sJKOtIJ7g#Cd+9b-M%7QW|Wu Date: Wed, 22 Oct 2014 23:30:09 -0600 Subject: [PATCH 053/100] Fix typo introduced in last commit. --- engine/battle/animations.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm index addcd8d6cf..9c15a98dc1 100755 --- a/engine/battle/animations.asm +++ b/engine/battle/animations.asm @@ -373,7 +373,7 @@ ENDC IF DEF(_BLUE) INCBIN "gfx/blue/slotmachine2.2bpp" ENDC -INF DEF(_YELLOW) +IF DEF(_YELLOW) INCBIN "gfx/yellow/slotmachine2.2bpp" ENDC From b17d958e6016588ecc1f1f842ad2194dd7d7c4d9 Mon Sep 17 00:00:00 2001 From: IIMarckus Date: Fri, 24 Oct 2014 01:50:40 -0600 Subject: [PATCH 054/100] Add more text changes from Yellow. --- text.asm | 12 ++++ text/maps/celadon_city.asm | 16 ++++++ text/maps/celadon_dept_store_4f.asm | 9 +++ text/maps/celadon_dept_store_roof.asm | 4 ++ text/maps/cerulean_badge_house.asm | 8 +++ text/maps/cerulean_city.asm | 51 +++++++++++++++++ text/maps/cerulean_gym.asm | 28 ++++++++++ text/maps/cerulean_trade_house.asm | 40 +++++++++++++- text/maps/cinnabar_island.asm | 4 ++ text/maps/copycats_house_1f.asm | 6 +- text/maps/fan_club.asm | 79 +++++++++++++++++++++++++++ text/maps/fighting_dojo.asm | 8 +++ text/maps/fuchsia_city.asm | 4 ++ text/maps/name_rater.asm | 4 ++ text/maps/pokemon_tower_7f.asm | 26 +++++++++ text/maps/saffron_gym.asm | 4 ++ text/maps/vermilion_gym_1.asm | 23 +++++++- text/maps/vermilion_gym_2.asm | 4 ++ 18 files changed, 327 insertions(+), 3 deletions(-) diff --git a/text.asm b/text.asm index 61c8675fc0..2c15004c26 100644 --- a/text.asm +++ b/text.asm @@ -3305,12 +3305,20 @@ _Thanks2Text:: ; a8209 (2a:4209) done _AfterTrade2Text:: ; a8212 (2a:4212) +IF DEF(_YELLOW) + text "Hello there! Your" + line "old @" + TX_RAM wcd13 + db " is" + cont "magnificent!" +ELSE text "The @" TX_RAM wcd13 text " you" line "traded to me" para "went and evolved!" +ENDC done _WannaTrade3Text:: ; a8240 (2a:4240) @@ -3340,7 +3348,11 @@ _WrongMon3Text:: ; a8284 (2a:4284) done _Thanks3Text:: ; a82bc (2a:42bc) +IF DEF(_YELLOW) + text "Thanks, pal!" +ELSE text "Thanks pal!" +ENDC done _AfterTrade3Text:: ; a82c9 (2a:42c9) diff --git a/text/maps/celadon_city.asm b/text/maps/celadon_city.asm index 585ece03b3..6a02d125df 100644 --- a/text/maps/celadon_city.asm +++ b/text/maps/celadon_city.asm @@ -1,10 +1,18 @@ _CeladonCityText1:: ; a59fb (29:59fb) text "I got my KOFFING" +IF DEF(_YELLOW) + line "from my friend!" + + para "We get along now," + line "because I was" + cont "very nice to it!" +ELSE line "in CINNABAR!" para "It's nice, but it" line "breathes poison" cont "when it's angry!" +ENDC done _CeladonCityText2:: ; a5a4b (29:5a4b) @@ -111,7 +119,11 @@ _CeladonCityText13:: ; a5d41 (29:5d41) line "#MON GYM" cont "LEADER: ERIKA" +IF DEF(_YELLOW) + para "The Nature-Loving" +ELSE para "The Nature Loving" +ENDC line "Princess!" done @@ -148,6 +160,10 @@ _CeladonCityText17:: ; a5e3e (29:5e3e) _CeladonCityText18:: ; a5e6a (29:5e6a) text "ROCKET GAME CORNER" line "The playground" +IF DEF(_YELLOW) + cont "for grownups!" +ELSE cont "for grown-ups!" +ENDC done diff --git a/text/maps/celadon_dept_store_4f.asm b/text/maps/celadon_dept_store_4f.asm index ed4898427b..de33021b38 100644 --- a/text/maps/celadon_dept_store_4f.asm +++ b/text/maps/celadon_dept_store_4f.asm @@ -1,7 +1,16 @@ _CeladonMart4Text2:: ; 9cad4 (27:4ad4) text "I'm getting a" +IF DEF(_YELLOW) + line "gift for COPYCAT" + cont "in CERULEAN CITY." + + para "It's got to be a" + line "# DOLL. They" + cont "are trendy!" +ELSE line "# DOLL for my" cont "girl friend!" +ENDC done _CeladonMart4Text3:: ; 9cafd (27:4afd) diff --git a/text/maps/celadon_dept_store_roof.asm b/text/maps/celadon_dept_store_roof.asm index 851afc41fb..f2eef61388 100644 --- a/text/maps/celadon_dept_store_roof.asm +++ b/text/maps/celadon_dept_store_roof.asm @@ -50,10 +50,14 @@ _CeladonMartRoofText_4850f:: ; 9cca5 (27:4ca5) para "@" TX_RAM wcf4b text " contains" +IF DEF(_YELLOW) + line "ROCK SLIDE!@@" +ELSE line "ROCK SLIDE!" para "It can spook the" line "target sometimes!@@" +ENDC _CeladonMartRoofText_48515:: ; 9cce6 (27:4ce6) text "Yay!" diff --git a/text/maps/cerulean_badge_house.asm b/text/maps/cerulean_badge_house.asm index cc0be65932..d546066ab7 100644 --- a/text/maps/cerulean_badge_house.asm +++ b/text/maps/cerulean_badge_house.asm @@ -19,7 +19,11 @@ _CeruleanHouse2Text_74e7c:: ; 9913a (26:513a) done _CeruleanHouse2Text_74e81:: ; 99170 (26:5170) +IF DEF(_YELLOW) + text "Come visit me any-" +ELSE text "Come visit me any" +ENDC line "time you wish." done @@ -29,7 +33,11 @@ _CeruleanHouse2Text_74e96:: ; 99192 (26:5192) cont "a little bit." para "It also lets you" +IF DEF(_YELLOW) + line "use FLASH any-" +ELSE line "use FLASH any" +ENDC cont "time you desire." prompt diff --git a/text/maps/cerulean_city.asm b/text/maps/cerulean_city.asm index 1daf316613..f014ee5d48 100644 --- a/text/maps/cerulean_city.asm +++ b/text/maps/cerulean_city.asm @@ -120,6 +120,15 @@ _CeruleanCityText5:: ; a50ba (29:50ba) done _CeruleanCityText6:: ; a50f6 (29:50f6) +IF DEF(_YELLOW) + text "These poor people" + line "here were robbed." + + para "We're positive" + line "that TEAM ROCKET" + cont "is behind this" + cont "terrible deed." +ELSE text "The people here" line "were robbed." @@ -127,31 +136,57 @@ _CeruleanCityText6:: ; a50f6 (29:50f6) line "TEAM ROCKET is" cont "behind this most" cont "heinous crime!" +ENDC para "Even our POLICE" +IF DEF(_YELLOW) + line "FORCE has trouble" +ELSE line "force has trouble" +ENDC cont "with the ROCKETs!" done _CeruleanCityText_19730:: ; a5188 (29:5188) +IF DEF(_YELLOW) + text "OK! ELECTRODE!" +ELSE text "OK! SLOWBRO!" +ENDC line "Use SONICBOOM!" +IF DEF(_YELLOW) + cont "Please ELECTRODE," +ELSE cont "Come on, SLOWBRO" +ENDC cont "pay attention!" done _CeruleanCityText_19735:: ; a51c5 (29:51c5) +IF DEF(_YELLOW) + text "ELECTRODE, TACKLE!" +ELSE text "SLOWBRO punch!" +ENDC line "No! You blew it" cont "again!" done _CeruleanCityText_1973a:: ; a51ec (29:51ec) +IF DEF(_YELLOW) + text "ELECTRODE, SWIFT!" +ELSE text "SLOWBRO, WITHDRAW!" +ENDC line "No! That's wrong!" +IF DEF(_YELLOW) + para "Training #MON" + line "is difficult!" +ELSE para "It's so hard to" line "control #MON!" +ENDC para "Your #MON's" line "obedience depends" @@ -160,22 +195,38 @@ _CeruleanCityText_1973a:: ; a51ec (29:51ec) done _CeruleanCityText_1976f:: ; a526b (29:526b) +IF DEF(_YELLOW) + text "ELECTRODE took a" +ELSE text "SLOWBRO took a" +ENDC line "snooze..." done _CeruleanCityText_19774:: ; a5285 (29:5285) +IF DEF(_YELLOW) + text "ELECTRODE is" +ELSE text "SLOWBRO is" +ENDC line "loafing around..." done _CeruleanCityText_19779:: ; a52a3 (29:52a3) +IF DEF(_YELLOW) + text "ELECTRODE turned" +ELSE text "SLOWBRO turned" +ENDC line "away..." done _CeruleanCityText_1977e:: ; a52bb (29:52bb) +IF DEF(_YELLOW) + text "ELECTRODE" +ELSE text "SLOWBRO" +ENDC line "ignored orders..." done diff --git a/text/maps/cerulean_gym.asm b/text/maps/cerulean_gym.asm index b0d2d3d143..f4234fc489 100644 --- a/text/maps/cerulean_gym.asm +++ b/text/maps/cerulean_gym.asm @@ -2,6 +2,11 @@ _CeruleanGymText_5c7be:: ; 989c1 (26:49c1) text "Hi, you're a new" line "face!" +IF DEF(_YELLOW) + para "What's your policy" + line "on #MON? What" + cont "is your approach?" +ELSE para "Trainers who want" line "to turn pro have" cont "to have a policy" @@ -10,11 +15,21 @@ _CeruleanGymText_5c7be:: ; 989c1 (26:49c1) para "What is your" line "approach when you" cont "catch #MON?" +ENDC para "My policy is an" line "all-out offensive" cont "with water-type" cont "#MON!" + +IF DEF(_YELLOW) + para "MISTY, the world-" + line "famous beauty, is" + cont "your host!" + + para "Are you ready," + line "sweetie?" +ENDC done _CeruleanGymText_5c7c3:: ; 98a7b (26:4a7b) @@ -35,7 +50,11 @@ _CeruleanGymText_5c7c8:: ; 98ab0 (26:4ab0) para "There's more, you" line "can now use CUT" +IF DEF(_YELLOW) + cont "anytime!" +ELSE cont "any time!" +ENDC para "You can CUT down" line "small bushes to" @@ -55,8 +74,13 @@ _CeruleanGymText_5c7d3:: ; 98b90 (26:4b90) done _CeruleanGymText_5c7d8:: ; 98bb0 (26:4bb0) +IF DEF(_YELLOW) + text "I can't" + line "believe I lost!" +ELSE text "Wow!" line "You're too much!" +ENDC para "All right!" @@ -125,7 +149,11 @@ _CeruleanGymText_5c82f:: ; 98db0 (26:4db0) text "You beat MISTY!" line "What'd I tell ya?" +IF DEF(_YELLOW) + para "You and me, kid," +ELSE para "You and me kid," +ENDC line "we make a pretty" cont "darn good team!" done diff --git a/text/maps/cerulean_trade_house.asm b/text/maps/cerulean_trade_house.asm index 78c9f76ad6..c22f24a97d 100644 --- a/text/maps/cerulean_trade_house.asm +++ b/text/maps/cerulean_trade_house.asm @@ -1,3 +1,42 @@ +IF DEF(_YELLOW) +MelanieText1:: + text "I nursed this" + line "BULBASAUR back to" + cont "health." + + para "It needs a good" + line "trainer to take" + cont "care of it now.@@" + +MelanieText2:: + text "I know! Would you" + line "take care of this" + cont "BULBASAUR?" + done + +MelanieText3:: + text "Please take care" + line "of BULBASAUR!@@" + +MelanieText4:: + text "Is BULBASAUR" + line "doing well?@@" + +MelanieText5:: + text "Oh..." + line "That's too bad...@@" + +MelanieBulbasaurText:: + text "BULBASAUR: Bubba!" + line "Zoar!@@" + +MelanieOddishText:: + text "ODDISH: Orddissh!@@" + +MelanieSandshrewText:: + text "SANDSHREW: Pikii!@@" +ENDC + _CeruleanHouse1Text1:: ; 9888c (26:488c) text "My husband likes" line "trading #MON." @@ -7,4 +46,3 @@ _CeruleanHouse1Text1:: ; 9888c (26:488c) cont "you please trade" cont "with him?" done - diff --git a/text/maps/cinnabar_island.asm b/text/maps/cinnabar_island.asm index dea97d1053..897368d274 100644 --- a/text/maps/cinnabar_island.asm +++ b/text/maps/cinnabar_island.asm @@ -13,7 +13,11 @@ _CinnabarIslandText1:: ; a61e6 (29:61e6) _CinnabarIslandText2:: ; a622a (29:622a) text "Scientists conduct" line "experiments in" +IF DEF(_YELLOW) + cont "the burned-out" +ELSE cont "the burned out" +ENDC cont "building." done diff --git a/text/maps/copycats_house_1f.asm b/text/maps/copycats_house_1f.asm index 0af104a4ba..419fa250e7 100644 --- a/text/maps/copycats_house_1f.asm +++ b/text/maps/copycats_house_1f.asm @@ -16,6 +16,10 @@ _CopycatsHouse1FText2:: ; a1535 (28:5535) done _CopycatsHouse1FText3:: ; a1596 (28:5596) +IF DEF(_YELLOW) + text "CHANSEY: Chaan + line "sey!@@" +ELSE text "CHANSEY: Chaan!" line "Sii!@@" - +ENDC diff --git a/text/maps/fan_club.asm b/text/maps/fan_club.asm index b623fa4a0e..bb1ca0f0a3 100644 --- a/text/maps/fan_club.asm +++ b/text/maps/fan_club.asm @@ -1,15 +1,35 @@ PikachuFanText:: text "Won't you admire" +IF DEF(_YELLOW) + line "my CLEFAIRY's" +ELSE line "my PIKACHU's" +ENDC cont "adorable tail?" done PikachuFanBetterText:: +IF DEF(_YELLOW) + text "Humph! My CLEFAIRY" +ELSE text "Humph! My PIKACHU" +ENDC line "is twice as cute" cont "as that one!" done +IF DEF(_YELLOW) +PikachuFanPrintText:: + text "Our CHAIRMAN's new" + line "hobby is taking" + cont "#MON photos." + + para "He gave me a nice" + line "PRINT of my cute" + cont "CLEFAIRY." + done +ENDC + SeelFanText:: text "I just love my" line "SEEL!" @@ -25,9 +45,22 @@ SeelFanBetterText:: line "more attractive!" done +IF DEF(_YELLOW) +SeelFanPrintText:: + text "I'm going to hook" + line "up the cable to" + cont "get a photo PRINT" + cont "of my SEEL!" + done +ENDC + FanClubPikachuText:: +IF DEF(_YELLOW) + text "CLEFAIRY: Pippii!" +ELSE text "PIKACHU: Chu!" line "Pikachu!" +ENDC done FanClubSeelText:: @@ -38,8 +71,14 @@ FanClubMeetChairText:: text "I chair the" line "#MON Fan Club!" +IF DEF(_YELLOW) + para "I have more than" + line "100 #MON. I" + cont "love them all!" +ELSE para "I have collected" line "over 100 #MON!" +ENDC para "I'm very fussy" line "when it comes to" @@ -47,8 +86,13 @@ FanClubMeetChairText:: para "So..." +IF DEF(_YELLOW) + para "Did you come to" + line "hear me brag" +ELSE para "Did you come" line "visit to hear" +ENDC cont "about my #MON?" done @@ -125,8 +169,43 @@ FanClubBagFullText:: line "this!" done +IF DEF(_YELLOW) +FanClubChairPrintText1:: + text "Hi there, ",$52,"!" + line "Have you seen my" + cont "#MON photos?" + + para "I have them framed" + line "up on that wall." + + para "Ah, I know!" + + para "Would you like me" + line "to take a photo" + cont "of your #MON?" + done + +FanClubChairPrintText2:: + text "No? That's really" + line "disappointing." + done + +FanClubChairPrintText3:: + text "OK, I'm done." + done + +FanClubChairPrintText4:: + text "Maybe we won't" + line "PRINT this now." + done +ENDC + _FanClubText6:: ; 9a948 (26:6948) +IF DEF(_YELLOW) + text "Our CHAIRMAN is" +ELSE text "Our Chairman is" +ENDC line "very vocal about" cont "#MON." done diff --git a/text/maps/fighting_dojo.asm b/text/maps/fighting_dojo.asm index 6f01e5fa2c..9cf7ba4e72 100644 --- a/text/maps/fighting_dojo.asm +++ b/text/maps/fighting_dojo.asm @@ -114,13 +114,21 @@ _FightingDojoAfterBattleText4:: ; a1b1a (28:5b1a) _WantHitmonleeText:: ; a1b4a (28:5b4a) text "You want the" +IF DEF(_YELLOW) + line "hard-kicking" +ELSE line "hard kicking" +ENDC cont "HITMONLEE?" done _WantHitmonchanText:: ; a1b70 (28:5b70) text "You want the" +IF DEF(_YELLOW) + line "piston-punching" +ELSE line "piston punching" +ENDC cont "HITMONCHAN?" done diff --git a/text/maps/fuchsia_city.asm b/text/maps/fuchsia_city.asm index aa35c16d74..bcb80d0e2e 100644 --- a/text/maps/fuchsia_city.asm +++ b/text/maps/fuchsia_city.asm @@ -58,7 +58,11 @@ _FuchsiaCityText18:: ; a6011 (29:6011) cont "LEADER: KOGA" para "The Poisonous" +IF DEF(_YELLOW) + line "Ninja Master!" +ELSE line "Ninja Master" +ENDC done _FuchsiaCityChanseyText:: ; a6050 (29:6050) diff --git a/text/maps/name_rater.asm b/text/maps/name_rater.asm index 4a81ecf15a..2baec7272e 100644 --- a/text/maps/name_rater.asm +++ b/text/maps/name_rater.asm @@ -43,7 +43,11 @@ _NameRaterText_1dac7:: ; 9a404 (26:6404) done _NameRaterText_1dacc:: ; 9a44c (26:644c) +IF DEF(_YELLOW) + text "Fine! Come any-" +ELSE text "Fine! Come any" +ENDC line "time you like!" done diff --git a/text/maps/pokemon_tower_7f.asm b/text/maps/pokemon_tower_7f.asm index 235fc218a5..c049dce1fe 100644 --- a/text/maps/pokemon_tower_7f.asm +++ b/text/maps/pokemon_tower_7f.asm @@ -1,3 +1,29 @@ +IF DEF(_YELLOW) +_PokemonTowerJessieJamesText1:: + text "Stop right there!@@" + +_PokemonTowerJessieJamesText2:: + text "Grampa here wanted" + line "to complain, so" + cont "we're setting him" + cont "straight." + + para "So render yourself" + line "invisible, or" + cont "prepare to fight!" + done + +_PokemonTowerJessieJamesText3:: + text "You" + line "will regret this!" + prompt + +_PokemonTowerJessieJamesText4:: + text "Looks like TEAM" + line "ROCKET's blasting" + cont "off again!@@" +ENDC + _PokemonTower7Text_60ec4:: ; 99c1a (26:5c1a) text "MR.FUJI: Heh? You" line "came to save me?" diff --git a/text/maps/saffron_gym.asm b/text/maps/saffron_gym.asm index d85e1b1ac1..3236c7b2e4 100644 --- a/text/maps/saffron_gym.asm +++ b/text/maps/saffron_gym.asm @@ -131,8 +131,12 @@ _SaffronGymEndBattleText2:: ; a2002 (28:6002) _SaffronGymAfterBattleText2:: ; a2019 (28:6019) text "Psychic #MON" +IF DEF(_YELLOW) + line "fear only bugs!" +ELSE line "fear only ghosts" cont "and bugs!" +ENDC done _SaffronGymBattleText3:: ; a2042 (28:6042) diff --git a/text/maps/vermilion_gym_1.asm b/text/maps/vermilion_gym_1.asm index 10868bd434..dfa452795b 100644 --- a/text/maps/vermilion_gym_1.asm +++ b/text/maps/vermilion_gym_1.asm @@ -1,4 +1,25 @@ _VermilionGymText_5cb6d:: ; 9aaa5 (26:6aa5) +IF DEF(_YELLOW) + text "Ten-hut! Welcome" + line "to VERMILION GYM!" + + para "Will you look at" + line "that, a pint-size" + cont "challenger!" + + para "Hahaha! You've got" + line "big and brassy" + cont "nerves to take me" + cont "on with your puny" + cont "power!" + + para "A #MON battle" + line "is war! I'll show" + cont "you, civilian!" + + para "I'll shock you" + line "into surrender!" +ELSE text "Hey, kid! What do" line "you think you're" cont "doing here?" @@ -18,5 +39,5 @@ _VermilionGymText_5cb6d:: ; 9aaa5 (26:6aa5) para "The same as I'll" line "do to you!" +ENDC done - diff --git a/text/maps/vermilion_gym_2.asm b/text/maps/vermilion_gym_2.asm index 2788d840de..ee7d14ee14 100644 --- a/text/maps/vermilion_gym_2.asm +++ b/text/maps/vermilion_gym_2.asm @@ -16,7 +16,11 @@ _VermilionGymText_5cb77:: ; 9c069 (27:4069) cont "#MON's SPEED!" para "It also lets your" +IF DEF(_YELLOW) + line "#MON FLY any-" +ELSE line "#MON FLY any" +ENDC cont "time, kid!" para "You're special," From 5ea1d8a61f8ba733f2438b963fdc30b766cd808f Mon Sep 17 00:00:00 2001 From: IIMarckus Date: Sun, 26 Oct 2014 21:00:29 -0600 Subject: [PATCH 055/100] =?UTF-8?q?Labels=20for=20Fuji=20in=20Pok=C3=A9mon?= =?UTF-8?q?=20Tower.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/mapObjects/pokemontower7.asm | 7 +++++++ scripts/pokemontower7.asm | 14 +++++++------- text/maps/pokemon_tower_7f.asm | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/data/mapObjects/pokemontower7.asm b/data/mapObjects/pokemontower7.asm index 629747827f..ca5aa66987 100755 --- a/data/mapObjects/pokemontower7.asm +++ b/data/mapObjects/pokemontower7.asm @@ -6,11 +6,18 @@ PokemonTower7Object: ; 0x60ef6 (size=42) db $0 ; signs +IF DEF(_YELLOW) + db 3 ; people + db SPRITE_JESSIE, 8 + 4, $a + 4, $ff, $d0, 1 + db SPRITE_JAMES, 8 + 4, $b + 4, $ff, $d0, 2 + db SPRITE_MR_FUJI, 3 + 4, $a + 4, $ff, $d0, 3 +ELSE db $4 ; people db SPRITE_ROCKET, $b + 4, $9 + 4, $ff, $d3, TRAINER | $1, ROCKET + $C8, $13 db SPRITE_ROCKET, $9 + 4, $c + 4, $ff, $d2, TRAINER | $2, ROCKET + $C8, $14 db SPRITE_ROCKET, $7 + 4, $9 + 4, $ff, $d3, TRAINER | $3, ROCKET + $C8, $15 db SPRITE_MR_FUJI, $3 + 4, $a + 4, $ff, $d0, $4 ; person +ENDC ; warp-to EVENT_DISP POKEMONTOWER_7_WIDTH, $10, $9 ; POKEMONTOWER_6 diff --git a/scripts/pokemontower7.asm b/scripts/pokemontower7.asm index 5f0ed52105..4d1012b71b 100755 --- a/scripts/pokemontower7.asm +++ b/scripts/pokemontower7.asm @@ -14,7 +14,7 @@ PokemonTower7Script_60d18: ; 60d18 (18:4d18) ld [W_CURMAPSCRIPT], a ret -PokemonTower7ScriptPointers: ; 60d23 (18:4d23) +PokemonTower7ScriptPointers: dw CheckFightingMapTrainers dw DisplayEnemyTrainerTextAndStartBattle dw PokemonTower7Script2 @@ -164,7 +164,7 @@ PokemonTower7TextPointers: ; 60e3f (18:4e3f) dw PokemonTower7Text1 dw PokemonTower7Text2 dw PokemonTower7Text3 - dw PokemonTower7Text4 + dw PokemonTower7FujiText PokemonTower7TrainerHeaders: ; 60e47 (18:4e47) PokemonTower7TrainerHeader0: ; 60e47 (18:4e47) @@ -214,9 +214,9 @@ PokemonTower7Text3: ; 60e80 (18:4e80) call TalkToTrainer jp TextScriptEnd -PokemonTower7Text4: ; 60e8a (18:4e8a) - db $08 ; asm - ld hl, PokemonTower7Text_60ec4 +PokemonTower7FujiText: + db 8 ; asm + ld hl, TowerRescueFujiText call PrintText ld hl, wd7e0 set 7, [hl] @@ -236,8 +236,8 @@ PokemonTower7Text4: ; 60e8a (18:4e8a) ld [W_CURMAPSCRIPT], a jp TextScriptEnd -PokemonTower7Text_60ec4: ; 60ec4 (18:4ec4) - TX_FAR _PokemonTower7Text_60ec4 +TowerRescueFujiText: + TX_FAR _TowerRescueFujiText db "@" PokemonTower7BattleText1: ; 60ec9 (18:4ec9) diff --git a/text/maps/pokemon_tower_7f.asm b/text/maps/pokemon_tower_7f.asm index c049dce1fe..2c1449b107 100644 --- a/text/maps/pokemon_tower_7f.asm +++ b/text/maps/pokemon_tower_7f.asm @@ -24,7 +24,7 @@ _PokemonTowerJessieJamesText4:: cont "off again!@@" ENDC -_PokemonTower7Text_60ec4:: ; 99c1a (26:5c1a) +_TowerRescueFujiText:: ; 99c1a (26:5c1a) text "MR.FUJI: Heh? You" line "came to save me?" From b08a0b860ae7b666e3fd526de1f78809368d1bf6 Mon Sep 17 00:00:00 2001 From: stag019 Date: Tue, 4 Nov 2014 20:22:18 -0500 Subject: [PATCH 056/100] Fix unclosed quotes. --- text.asm | 2 +- text/maps/copycats_house_1f.asm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/text.asm b/text.asm index 2c15004c26..1e4e1c49fd 100644 --- a/text.asm +++ b/text.asm @@ -169,7 +169,7 @@ _OaksAideNoRoomText:: ; 802ec (20:42ec) IF DEF(_YELLOW) _NurseChanseyText:: text "CHANSEY: Chaaan" - line "sey! + line "sey!" done ENDC diff --git a/text/maps/copycats_house_1f.asm b/text/maps/copycats_house_1f.asm index 419fa250e7..da99566bb7 100644 --- a/text/maps/copycats_house_1f.asm +++ b/text/maps/copycats_house_1f.asm @@ -17,7 +17,7 @@ _CopycatsHouse1FText2:: ; a1535 (28:5535) _CopycatsHouse1FText3:: ; a1596 (28:5596) IF DEF(_YELLOW) - text "CHANSEY: Chaan + text "CHANSEY: Chaan" line "sey!@@" ELSE text "CHANSEY: Chaan!" From cf29441457029c4ead96180057cd3c81d6d69786 Mon Sep 17 00:00:00 2001 From: stag019 Date: Tue, 4 Nov 2014 20:22:55 -0500 Subject: [PATCH 057/100] Uncomment useful macros. --- macros.asm | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/macros.asm b/macros.asm index 27d7c37465..6dd239da25 100644 --- a/macros.asm +++ b/macros.asm @@ -466,17 +466,17 @@ dutycycle: MACRO ENDM ;format: callchannel address -;callchannel: MACRO -; db $FD -; dw \1 -;ENDM +callchannel: MACRO + db $FD + dw \1 +ENDM ;format: loopchannel count, address -;loopchannel: MACRO -; db $FE -; db \1 -; dw \2 -;ENDM +loopchannel: MACRO + db $FE + db \1 + dw \2 +ENDM endchannel: MACRO db $FF From d8aa1f0d86caecd4077bcbf8b7ad9f226274fb72 Mon Sep 17 00:00:00 2001 From: stag019 Date: Tue, 4 Nov 2014 20:25:33 -0500 Subject: [PATCH 058/100] Stop preprocessing files. --- .gitignore | 3 --- Makefile | 16 ++++------------ 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index d60a2fb243..dd1b5a9d20 100644 --- a/.gitignore +++ b/.gitignore @@ -15,9 +15,6 @@ *.map *.sym -# generated -*.tx - # converted image data *.2bpp *.1bpp diff --git a/Makefile b/Makefile index 20e86bb2b1..d840e9f1e9 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,7 @@ compare: # Clear the default suffixes. .SUFFIXES: -.SUFFIXES: .asm .tx .o .gbc .png .2bpp .1bpp .pic +.SUFFIXES: .asm .o .gbc .png .2bpp .1bpp .pic # Secondary expansion is required for dependency variables in object rules. .SECONDEXPANSION: @@ -73,22 +73,14 @@ $(foreach obj, $(all_obj), \ %.1bpp: %.png ; $(eval 1bppq += $<) @rm -f $@ %.pic: %.2bpp ; $(eval picq += $<) @rm -f $@ -# Source files are not fed directly into rgbasm. -# A python preprocessor runs over them first, replacing ascii strings with correct character codes. -# It spits out the new file with extension .tx. -# The text preprocessor also uses a queue. -%.asm: ; -%.tx: %.asm ; $(eval txq += $<) @rm -f $@ - # Assemble source files into objects. # Queue payloads are here. These are made silent since there may be hundreds of targets. # Use rgbasm -h to use halts without nops. -$(all_obj): $$*.tx $$(patsubst %.asm, %.tx, $$($$*_dep)) - @$(pre) $(txq); $(eval txq :=) +$(all_obj): $$*.asm $$($$*_dep) @$(gfx) 2bpp $(2bppq); $(eval 2bppq :=) @$(gfx) 1bpp $(1bppq); $(eval 1bppq :=) @$(pic) compress $(picq); $(eval picq :=) - rgbasm -h -o $@ $*.tx + rgbasm -h -o $@ $*.asm # Link objects together to build a rom. @@ -103,4 +95,4 @@ poke%.gbc: $$(%_obj) clean: rm -f $(roms) $(all_obj) - find . \( -iname '*.tx' -o -iname '*.1bpp' -o -iname '*.2bpp' -o -iname '*.pic' \) -exec rm {} + + find . \( -iname '*.1bpp' -o -iname '*.2bpp' -o -iname '*.pic' \) -exec rm {} + From 6a322227fdd1e08a1cc6ae8f02682a3e5bb62673 Mon Sep 17 00:00:00 2001 From: stag019 Date: Tue, 4 Nov 2014 20:29:26 -0500 Subject: [PATCH 059/100] Added charmaps. --- blue.asm | 1 + charmap.asm | 252 ++++++++++++++++++++++++++++++++++++++++++++++++++++ red.asm | 1 + yellow.asm | 1 + 4 files changed, 255 insertions(+) create mode 100644 charmap.asm diff --git a/blue.asm b/blue.asm index fe2d945272..c8c50a5d5e 100644 --- a/blue.asm +++ b/blue.asm @@ -1 +1,2 @@ _BLUE EQU 1 +INCLUDE "charmap.asm" diff --git a/charmap.asm b/charmap.asm new file mode 100644 index 0000000000..980c79a3c4 --- /dev/null +++ b/charmap.asm @@ -0,0 +1,252 @@ +charmap "ガ", $05 +charmap "ギ", $06 +charmap "グ", $07 +charmap "ゲ", $08 +charmap "ゴ", $09 +charmap "ザ", $0A +charmap "ジ", $0B +charmap "ズ", $0C +charmap "ゼ", $0D +charmap "ゾ", $0E +charmap "ダ", $0F +charmap "ヂ", $10 +charmap "ヅ", $11 +charmap "デ", $12 +charmap "ド", $13 +charmap "バ", $19 +charmap "ビ", $1A +charmap "ブ", $1B +charmap "ボ", $1C +charmap "が", $26 +charmap "ぎ", $27 +charmap "ぐ", $28 +charmap "げ", $29 +charmap "ご", $2A +charmap "ざ", $2B +charmap "じ", $2C +charmap "ず", $2D +charmap "ぜ", $2E +charmap "ぞ", $2F +charmap "だ", $30 +charmap "ぢ", $31 +charmap "づ", $32 +charmap "で", $33 +charmap "ど", $34 +charmap "ば", $3A +charmap "び", $3B +charmap "ぶ", $3C +charmap "べ", $3D +charmap "ぼ", $3E +charmap "パ", $40 +charmap "ピ", $41 +charmap "プ", $42 +charmap "ポ", $43 +charmap "ぱ", $44 +charmap "ぴ", $45 +charmap "ぷ", $46 +charmap "ぺ", $47 +charmap "ぽ", $48 +charmap "ア", $80 +charmap "イ", $81 +charmap "ウ", $82 +charmap "エ", $83 +charmap "ォ", $84 +charmap "カ", $85 +charmap "キ", $86 +charmap "ク", $87 +charmap "ケ", $88 +charmap "コ", $89 +charmap "サ", $8A +charmap "シ", $8B +charmap "ス", $8C +charmap "セ", $8D +charmap "ソ", $8E +charmap "タ", $8F +charmap "チ", $90 +charmap "ツ", $91 +charmap "テ", $92 +charmap "ト", $93 +charmap "ナ", $94 +charmap "ニ", $95 +charmap "ヌ", $96 +charmap "ネ", $97 +charmap "ノ", $98 +charmap "ハ", $99 +charmap "ヒ", $9A +charmap "フ", $9B +charmap "ホ", $9C +charmap "マ", $9D +charmap "ミ", $9E +charmap "ム", $9F +charmap "メ", $A0 +charmap "モ", $A1 +charmap "ヤ", $A2 +charmap "ユ", $A3 +charmap "ヨ", $A4 +charmap "ラ", $A5 +charmap "ル", $A6 +charmap "レ", $A7 +charmap "ロ", $A8 +charmap "ワ", $A9 +charmap "ヲ", $AA +charmap "ン", $AB +charmap "ッ", $AC +charmap "ャ", $AD +charmap "ュ", $AE +charmap "ョ", $AF +charmap "ィ", $B0 +charmap "あ", $B1 +charmap "い", $B2 +charmap "う", $B3 +charmap "え", $B4 +charmap "お", $B5 +charmap "か", $B6 +charmap "き", $B7 +charmap "く", $B8 +charmap "け", $B9 +charmap "こ", $BA +charmap "さ", $BB +charmap "し", $BC +charmap "す", $BD +charmap "せ", $BE +charmap "そ", $BF +charmap "た", $C0 +charmap "ち", $C1 +charmap "つ", $C2 +charmap "て", $C3 +charmap "と", $C4 +charmap "な", $C5 +charmap "に", $C6 +charmap "ぬ", $C7 +charmap "ね", $C8 +charmap "の", $C9 +charmap "は", $CA +charmap "ひ", $CB +charmap "ふ", $CC +charmap "へ", $CD +charmap "ほ", $CE +charmap "ま", $CF +charmap "み", $D0 +charmap "む", $D1 +charmap "め", $D2 +charmap "も", $D3 +charmap "や", $D4 +charmap "ゆ", $D5 +charmap "よ", $D6 +charmap "ら", $D7 +charmap "り", $D8 +charmap "る", $D9 +charmap "れ", $DA +charmap "ろ", $DB +charmap "わ", $DC +charmap "を", $DD +charmap "ん", $DE +charmap "っ", $DF +charmap "ゃ", $E0 +charmap "ゅ", $E1 +charmap "ょ", $E2 +charmap "ー", $E3 + +charmap "@", $50 +charmap "#", $54 +;charmap "POKé", $54 +charmap "…", $75 + +charmap "┌", $79 +charmap "─", $7A +charmap "┐", $7B +charmap "│", $7C +charmap "└", $7D +charmap "┘", $7E + +charmap "№", $74 + +charmap " ", $7F +charmap "A", $80 +charmap "B", $81 +charmap "C", $82 +charmap "D", $83 +charmap "E", $84 +charmap "F", $85 +charmap "G", $86 +charmap "H", $87 +charmap "I", $88 +charmap "J", $89 +charmap "K", $8A +charmap "L", $8B +charmap "M", $8C +charmap "N", $8D +charmap "O", $8E +charmap "P", $8F +charmap "Q", $90 +charmap "R", $91 +charmap "S", $92 +charmap "T", $93 +charmap "U", $94 +charmap "V", $95 +charmap "W", $96 +charmap "X", $97 +charmap "Y", $98 +charmap "Z", $99 +charmap "(", $9A +charmap ")", $9B +charmap ":", $9C +charmap ";", $9D +charmap "[", $9E +charmap "]", $9F +charmap "a", $A0 +charmap "b", $A1 +charmap "c", $A2 +charmap "d", $A3 +charmap "e", $A4 +charmap "f", $A5 +charmap "g", $A6 +charmap "h", $A7 +charmap "i", $A8 +charmap "j", $A9 +charmap "k", $AA +charmap "l", $AB +charmap "m", $AC +charmap "n", $AD +charmap "o", $AE +charmap "p", $AF +charmap "q", $B0 +charmap "r", $B1 +charmap "s", $B2 +charmap "t", $B3 +charmap "u", $B4 +charmap "v", $B5 +charmap "w", $B6 +charmap "x", $B7 +charmap "y", $B8 +charmap "z", $B9 +charmap "é", $BA +charmap "'d", $BB +charmap "'l", $BC +charmap "'s", $BD +charmap "'t", $BE +charmap "'v", $BF +charmap "'", $E0 +charmap "-", $E3 +charmap "'r", $E4 +charmap "'m", $E5 +charmap "?", $E6 +charmap "!", $E7 +charmap ".", $E8 +charmap "▶", $ED +charmap "♂", $EF +charmap "¥", $F0 +charmap "×", $F1 +charmap "/", $F3 +charmap ",", $F4 +charmap "♀", $F5 +charmap "0", $F6 +charmap "1", $F7 +charmap "2", $F8 +charmap "3", $F9 +charmap "4", $FA +charmap "5", $FB +charmap "6", $FC +charmap "7", $FD +charmap "8", $FE +charmap "9", $FF diff --git a/red.asm b/red.asm index 571f24e063..901a611a80 100644 --- a/red.asm +++ b/red.asm @@ -1 +1,2 @@ _RED EQU 1 +INCLUDE "charmap.asm" diff --git a/yellow.asm b/yellow.asm index b1417eff24..3edffe013e 100644 --- a/yellow.asm +++ b/yellow.asm @@ -1,3 +1,4 @@ _YELLOW EQU 1 _OPTION_BEACH_HOUSE EQU 1 _OPTION_LOWCOST_SAFARI EQU 1 +INCLUDE "charmap.asm" From 5b443a5adeec63522f27cad3b177550c7df0650f Mon Sep 17 00:00:00 2001 From: IIMarckus Date: Wed, 5 Nov 2014 01:32:11 -0700 Subject: [PATCH 060/100] Remove prequeue and preprocessor (now unused). --- Makefile | 1 - preprocessor.py | 289 ------------------------------------------------ prequeue.py | 38 ------- 3 files changed, 328 deletions(-) delete mode 100644 preprocessor.py delete mode 100644 prequeue.py diff --git a/Makefile b/Makefile index d840e9f1e9..ddb9d88ea2 100644 --- a/Makefile +++ b/Makefile @@ -51,7 +51,6 @@ poketools := extras/pokemontools gfx := $(PYTHON) $(poketools)/gfx.py pic := $(PYTHON) $(poketools)/pic.py includes := $(PYTHON) $(poketools)/scan_includes.py -pre := $(PYTHON) prequeue.py diff --git a/preprocessor.py b/preprocessor.py deleted file mode 100644 index 6cd6ab05a7..0000000000 --- a/preprocessor.py +++ /dev/null @@ -1,289 +0,0 @@ -# -*- coding: utf-8 -*- - -import extras.pokemontools.preprocessor as preprocessor - -import extras.pokemontools.configuration as configuration -config = configuration.Config() - -import sys - -from extras.pokemontools.crystal import ( - callchannel, - loopchannel, -) - -chars = { -"ガ": 0x05, -"ギ": 0x06, -"グ": 0x07, -"ゲ": 0x08, -"ゴ": 0x09, -"ザ": 0x0A, -"ジ": 0x0B, -"ズ": 0x0C, -"ゼ": 0x0D, -"ゾ": 0x0E, -"ダ": 0x0F, -"ヂ": 0x10, -"ヅ": 0x11, -"デ": 0x12, -"ド": 0x13, -"バ": 0x19, -"ビ": 0x1A, -"ブ": 0x1B, -"ボ": 0x1C, -"が": 0x26, -"ぎ": 0x27, -"ぐ": 0x28, -"げ": 0x29, -"ご": 0x2A, -"ざ": 0x2B, -"じ": 0x2C, -"ず": 0x2D, -"ぜ": 0x2E, -"ぞ": 0x2F, -"だ": 0x30, -"ぢ": 0x31, -"づ": 0x32, -"で": 0x33, -"ど": 0x34, -"ば": 0x3A, -"び": 0x3B, -"ぶ": 0x3C, -"べ": 0x3D, -"ぼ": 0x3E, -"パ": 0x40, -"ピ": 0x41, -"プ": 0x42, -"ポ": 0x43, -"ぱ": 0x44, -"ぴ": 0x45, -"ぷ": 0x46, -"ぺ": 0x47, -"ぽ": 0x48, -"ア": 0x80, -"イ": 0x81, -"ウ": 0x82, -"エ": 0x83, -"ォ": 0x84, -"カ": 0x85, -"キ": 0x86, -"ク": 0x87, -"ケ": 0x88, -"コ": 0x89, -"サ": 0x8A, -"シ": 0x8B, -"ス": 0x8C, -"セ": 0x8D, -"ソ": 0x8E, -"タ": 0x8F, -"チ": 0x90, -"ツ": 0x91, -"テ": 0x92, -"ト": 0x93, -"ナ": 0x94, -"ニ": 0x95, -"ヌ": 0x96, -"ネ": 0x97, -"ノ": 0x98, -"ハ": 0x99, -"ヒ": 0x9A, -"フ": 0x9B, -"ホ": 0x9C, -"マ": 0x9D, -"ミ": 0x9E, -"ム": 0x9F, -"メ": 0xA0, -"モ": 0xA1, -"ヤ": 0xA2, -"ユ": 0xA3, -"ヨ": 0xA4, -"ラ": 0xA5, -"ル": 0xA6, -"レ": 0xA7, -"ロ": 0xA8, -"ワ": 0xA9, -"ヲ": 0xAA, -"ン": 0xAB, -"ッ": 0xAC, -"ャ": 0xAD, -"ュ": 0xAE, -"ョ": 0xAF, -"ィ": 0xB0, -"あ": 0xB1, -"い": 0xB2, -"う": 0xB3, -"え": 0xB4, -"お": 0xB5, -"か": 0xB6, -"き": 0xB7, -"く": 0xB8, -"け": 0xB9, -"こ": 0xBA, -"さ": 0xBB, -"し": 0xBC, -"す": 0xBD, -"せ": 0xBE, -"そ": 0xBF, -"た": 0xC0, -"ち": 0xC1, -"つ": 0xC2, -"て": 0xC3, -"と": 0xC4, -"な": 0xC5, -"に": 0xC6, -"ぬ": 0xC7, -"ね": 0xC8, -"の": 0xC9, -"は": 0xCA, -"ひ": 0xCB, -"ふ": 0xCC, -"へ": 0xCD, -"ほ": 0xCE, -"ま": 0xCF, -"み": 0xD0, -"む": 0xD1, -"め": 0xD2, -"も": 0xD3, -"や": 0xD4, -"ゆ": 0xD5, -"よ": 0xD6, -"ら": 0xD7, -"り": 0xD8, -"る": 0xD9, -"れ": 0xDA, -"ろ": 0xDB, -"わ": 0xDC, -"を": 0xDD, -"ん": 0xDE, -"っ": 0xDF, -"ゃ": 0xE0, -"ゅ": 0xE1, -"ょ": 0xE2, -"ー": 0xE3, - - -"@": 0x50, -"#": 0x54, -"…": 0x75, - -"┌": 0x79, -"─": 0x7A, -"┐": 0x7B, -"│": 0x7C, -"└": 0x7D, -"┘": 0x7E, - -"№": 0x74, - -"′": 0x71, -"″": 0x73, - -" ": 0x7F, -"A": 0x80, -"B": 0x81, -"C": 0x82, -"D": 0x83, -"E": 0x84, -"F": 0x85, -"G": 0x86, -"H": 0x87, -"I": 0x88, -"J": 0x89, -"K": 0x8A, -"L": 0x8B, -"M": 0x8C, -"N": 0x8D, -"O": 0x8E, -"P": 0x8F, -"Q": 0x90, -"R": 0x91, -"S": 0x92, -"T": 0x93, -"U": 0x94, -"V": 0x95, -"W": 0x96, -"X": 0x97, -"Y": 0x98, -"Z": 0x99, -"(": 0x9A, -")": 0x9B, -":": 0x9C, -";": 0x9D, -"[": 0x9E, -"]": 0x9F, -"a": 0xA0, -"b": 0xA1, -"c": 0xA2, -"d": 0xA3, -"e": 0xA4, -"f": 0xA5, -"g": 0xA6, -"h": 0xA7, -"i": 0xA8, -"j": 0xA9, -"k": 0xAA, -"l": 0xAB, -"m": 0xAC, -"n": 0xAD, -"o": 0xAE, -"p": 0xAF, -"q": 0xB0, -"r": 0xB1, -"s": 0xB2, -"t": 0xB3, -"u": 0xB4, -"v": 0xB5, -"w": 0xB6, -"x": 0xB7, -"y": 0xB8, -"z": 0xB9, -"é": 0xBA, -"'d": 0xBB, -"'l": 0xBC, -"'s": 0xBD, -"'t": 0xBE, -"'v": 0xBF, -"'": 0xE0, -"-": 0xE3, -"'r": 0xE4, -"'m": 0xE5, -"?": 0xE6, -"!": 0xE7, -".": 0xE8, -"▶": 0xED, -"♂": 0xEF, -"¥": 0xF0, -"×": 0xF1, -"/": 0xF3, -",": 0xF4, -"♀": 0xF5, -"0": 0xF6, -"1": 0xF7, -"2": 0xF8, -"3": 0xF9, -"4": 0xFA, -"5": 0xFB, -"6": 0xFC, -"7": 0xFD, -"8": 0xFE, -"9": 0xFF, -} - -def load_pokered_macros(): - macros = [callchannel, loopchannel] - return macros - -def setup_processor(): - preprocessor.chars = chars - macros = load_pokered_macros() - processor = preprocessor.Preprocessor(config, macros) - return processor - -def main(): - processor = setup_processor() - output = processor.preprocess() - return output - -if __name__ == '__main__': - main() diff --git a/prequeue.py b/prequeue.py deleted file mode 100644 index 85549c373c..0000000000 --- a/prequeue.py +++ /dev/null @@ -1,38 +0,0 @@ -# coding: utf-8 -""" -Starting a new python process to preprocess each source file creates too much -overhead. Instead, a list of files to preprocess is fed into a script run from -a single process. -""" - -import os -import sys - -import preprocessor - -def preprocess_queue(filenames=sys.argv[1:]): - - stdin = sys.stdin - stdout = sys.stdout - - processor = preprocessor.setup_processor() - - for source in filenames: - dest = os.path.splitext(source)[0] + '.tx' - sys.stdin = open(source, 'r') - sys.stdout = open(dest, 'w') - processor.preprocess() - - sys.stdin = stdin - sys.stdout = stdout - -def main(): - filenames = list(set(sys.argv[1:])) - if filenames: - num_files = len(filenames) - s = '' if num_files == 1 else 's' - sys.stdout.write('Preprocessing {0} file{1}...\n'.format(num_files, s)) - preprocess_queue(filenames) - -if __name__ == '__main__': - main() From 6ed876eeb3b81a88787aef4eeb955cfeb6602efb Mon Sep 17 00:00:00 2001 From: yenatch Date: Thu, 6 Nov 2014 13:21:44 -0800 Subject: [PATCH 061/100] Link to a charmap-compatible rgbds. --- INSTALL.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index a1527ab8c7..e2d9e8c56a 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -54,9 +54,7 @@ Select the following packages: * python * python-setuptools -To install rgbds, extract the contents of -**http://iimarck.us/etc/rgbds.zip** -and put them in `C:\cygwin\usr\local\bin`. +The latest version of **rgbds** is [**0.2.0**](https://github.com/bentley/rgbds/releases/download/v0.2.0/rgbds-0.2.0-win32.zip). To install, put `rgbasm.exe`, `rgblink.exe` and `rgbfix.exe` in `C:\cygwin\usr\local\bin`. Then set up the repository. In the **Cygwin terminal**: From a496b4d2f77a039b54c4e23f379d48043e8cdd79 Mon Sep 17 00:00:00 2001 From: yenatch Date: Thu, 6 Nov 2014 13:24:32 -0800 Subject: [PATCH 062/100] Less verbose reference to pypng. --- INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index e2d9e8c56a..7ebe2cf80a 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -62,7 +62,7 @@ Then set up the repository. In the **Cygwin terminal**: cd pokered git submodule init git submodule update - easy_install git://github.com/drj11/pypng.git@master#egg=pypng + easy_install pypng To build: From da8c79360998241443a6c51c3a487fbcd7dfcde4 Mon Sep 17 00:00:00 2001 From: yenatch Date: Thu, 6 Nov 2014 23:13:35 -0800 Subject: [PATCH 063/100] Better OS X install instructions. --- INSTALL.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 7ebe2cf80a..e440ef330f 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -36,8 +36,11 @@ To build them individually: # OS X -Download and install **Command Line Tools for Xcode**. -Then open a terminal and follow the Linux instructions. +In the shell, run: + + xcode-select --install + +Then follow the Linux instructions. # Windows From 72cf53fcd3e56c2fcaf7157135eec5e65d1c1735 Mon Sep 17 00:00:00 2001 From: IIMarckus Date: Sat, 15 Nov 2014 23:35:54 -0700 Subject: [PATCH 064/100] Update IRC links. --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0b29e40947..abaaa65302 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,7 @@ To set up the repository, see [**INSTALL.md**](INSTALL.md). ## See also * Disassembly of [**Pokémon Crystal**][pokecrystal] -* irc: **nucleus.kafuka.org** [**#skeetendo**][irc] +* irc: **irc.freenode.net** [**#pret**][irc] [pokecrystal]: https://github.com/kanzure/pokecrystal -[irc]: https://kiwiirc.com/client/irc.nolimitzone.com/?#skeetendo - +[irc]: https://kiwiirc.com/client/irc.freenode.net/?#pret From 26227cc45f0242a26b711bbf8711f4dc3aff6380 Mon Sep 17 00:00:00 2001 From: yenatch Date: Wed, 10 Dec 2014 20:07:01 -0800 Subject: [PATCH 065/100] Clean up type names. --- engine/battle/9.asm | 2 +- text/type_names.asm | 107 +++++++++++++++++++------------------------- 2 files changed, 48 insertions(+), 61 deletions(-) diff --git a/engine/battle/9.asm b/engine/battle/9.asm index dc72825ccc..26f65317b1 100755 --- a/engine/battle/9.asm +++ b/engine/battle/9.asm @@ -31,7 +31,7 @@ Func_27d98: ; 27d98 (9:7d98) ld a, [W_PLAYERMOVETYPE] ; wcfd5 asm_27d9f: ; 27d9f (9:7d9f) add a - ld hl, TypeNamePointers ; $7dae + ld hl, TypeNames ld e, a ld d, $0 add hl, de diff --git a/text/type_names.asm b/text/type_names.asm index 63d9566940..d94675b8ab 100755 --- a/text/type_names.asm +++ b/text/type_names.asm @@ -1,61 +1,48 @@ -TypeNamePointers: ; 27dae (9:7dae) - dw Type00Name - dw Type01Name - dw Type02Name - dw Type03Name - dw Type04Name - dw Type05Name - dw Type06Name - dw Type07Name - dw Type08Name - dw Type00Name - dw Type00Name - dw Type00Name - dw Type00Name - dw Type00Name - dw Type00Name - dw Type00Name - dw Type00Name - dw Type00Name - dw Type00Name - dw Type00Name - dw Type14Name - dw Type15Name - dw Type16Name - dw Type17Name - dw Type18Name - dw Type19Name - dw Type1AName +TypeNames: -Type00Name: ; 27de4 (9:7de4) - db "NORMAL@" -Type01Name: ; 27deb (9:7deb) - db "FIGHTING@" -Type02Name: ; 27df4 (9:7df4) - db "FLYING@" -Type03Name: ; 27dfb (9:7dfb) - db "POISON@" -Type14Name: ; 27e02 (9:7e02) - db "FIRE@" -Type15Name: ; 27e07 (9:7e07) - db "WATER@" -Type16Name: ; 27e0d (9:7e0d) - db "GRASS@" -Type17Name: ; 27e13 (9:7e13) - db "ELECTRIC@" -Type18Name: ; 27e1c (9:7e1c) - db "PSYCHIC@" -Type19Name: ; 27e24 (9:7e24) - db "ICE@" -Type04Name: ; 27e28 (9:7e28) - db "GROUND@" -Type05Name: ; 27e2f (9:7e2f) - db "ROCK@" -Type06Name: ; 27e34 (9:7e34) - db "BIRD@" -Type07Name: ; 27e39 (9:7e39) - db "BUG@" -Type08Name: ; 27e3d (9:7e3d) - db "GHOST@" -Type1AName: ; 27e43 (9:7e43) - db "DRAGON@" + dw .Normal + dw .Fighting + dw .Flying + dw .Poison + dw .Ground + dw .Rock + dw .Bird + dw .Bug + dw .Ghost + + dw .Normal + dw .Normal + dw .Normal + dw .Normal + dw .Normal + dw .Normal + dw .Normal + dw .Normal + dw .Normal + dw .Normal + dw .Normal + + dw .Fire + dw .Water + dw .Grass + dw .Electric + dw .Psychic + dw .Ice + dw .Dragon + +.Normal: db "NORMAL@" +.Fighting: db "FIGHTING@" +.Flying: db "FLYING@" +.Poison: db "POISON@" +.Fire: db "FIRE@" +.Water: db "WATER@" +.Grass: db "GRASS@" +.Electric: db "ELECTRIC@" +.Psychic: db "PSYCHIC@" +.Ice: db "ICE@" +.Ground: db "GROUND@" +.Rock: db "ROCK@" +.Bird: db "BIRD@" +.Bug: db "BUG@" +.Ghost: db "GHOST@" +.Dragon: db "DRAGON@" From ca6b4348c2486a09b92023e9b9f10cfd4d3bdd06 Mon Sep 17 00:00:00 2001 From: xCrystal Date: Sun, 4 Jan 2015 17:47:21 +0100 Subject: [PATCH 066/100] add commentary --- engine/battle/core.asm | 230 ++++++++++++++++++++++++----------------- 1 file changed, 135 insertions(+), 95 deletions(-) diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 43373fdd08..8f516def21 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -26,7 +26,7 @@ EffectsArray2: ; 3c011 (f:4011) db SPECIAL_DAMAGE_EFFECT db -1 EffectsArray3: ; 3c014 (f:4014) -; non-damaging, stat‐affecting or status‐causing moves? +; stat-affecting moves, sleep-inflicting moves, and Bide ; e.g., Meditate, Bide, Hypnosis db $01 db ATTACK_UP1_EFFECT @@ -70,6 +70,9 @@ EffectsArray4: ; 3c030 (f:4030) db RAGE_EFFECT db -1 EffectsArray5: ; 3c03b (f:403b) +; Effects from arrays 2, 4, and 5B, minus Twineedle and Rage. +; Includes all effects that do not need to be called at the end of +; ExecutePlayerMove (or ExecuteEnemyMove), because they have already been handled db DRAIN_HP_EFFECT db EXPLODE_EFFECT db DREAM_EATER_EFFECT @@ -86,7 +89,7 @@ EffectsArray5: ; 3c03b (f:403b) db RECOIL_EFFECT ; fallthrough to Next EffectsArray EffectsArray5B: ; 3c049 (f:4049) -; moves that prevent the player from switching moves? +; damaging moves whose effect is executed prior to damage calculation db THRASH_PETAL_DANCE_EFFECT db TRAPPING_EFFECT db -1 @@ -405,7 +408,7 @@ MainInBattleLoop: ; 3c233 (f:4233) ld a, [W_ENEMYBATTSTATUS1] bit 5, a ; check if enemy is using a multi-turn attack like wrap jr z, .selectPlayerMove ; if not, jump -; enemy is using a mult-turn attack like wrap, so player is trapped and cannot select a move +; enemy is using a mult-turn attack like wrap, so player is trapped and cannot execute a move ld a, $ff ld [wPlayerSelectedMove], a jr .selectEnemyMove @@ -449,7 +452,7 @@ MainInBattleLoop: ; 3c233 (f:4233) ld b, 0 add hl, bc ld a, [hl] - cp METRONOME + cp METRONOME ; a MIRROR MOVE check is missing, might lead to a desync in link battles when combined with multi-turn moves jr nz, .asm_3c2dd ld [wPlayerSelectedMove], a .asm_3c2dd @@ -485,7 +488,7 @@ MainInBattleLoop: ; 3c233 (f:4233) jr z, .speedEqual jr nc, .playerMovesFirst ; if player is faster jr .enemyMovesFirst ; if enemy is faster -.speedEqual +.speedEqual ; 50/50 chance for both players ld a, [$ffaa] cp $2 jr z, .invertOutcome @@ -509,7 +512,7 @@ MainInBattleLoop: ; 3c233 (f:4233) ret nz ; if so, return ld a, b and a - jp z, HandlePlayerMonFainted + jp z, HandlePlayerMonFainted .AIActionUsedEnemyFirst call HandlePoisonBurnLeechSeed jp z, HandleEnemyMonFainted @@ -702,6 +705,7 @@ HandlePoisonBurnLeechSeed_DecreaseOwnHP: ; 3c43d (f:443d) ret ; adds bc to enemy HP +; bc isn't updated if HP substracted was capped to prevent overkill HandlePoisonBurnLeechSeed_IncreaseEnemyHP: ; 3c4a3 (f:44a3) push hl ld hl, wEnemyMonMaxHP @@ -833,7 +837,7 @@ FaintEnemyPokemon ; 0x3c567 res 2, [hl] xor a ld [W_NUMHITS], a - ld hl, wd065 ; enemy statuses + ld hl, wd065 ; clear enemy statuses ld [hli], a ld [hli], a ld [hli], a @@ -1358,7 +1362,7 @@ EnemySendOut: ; 3c90e (f:490e) ; don't change wPartyGainExpFlags or wPartyFoughtCurrentEnemyFlags EnemySendOutFirstMon: ; 3c92a (f:492a) xor a - ld hl,wd065 + ld hl,wd065 ; clear enemy statuses ld [hli],a ld [hli],a ld [hli],a @@ -3105,10 +3109,10 @@ LinkBattleExchangeData: ; 3d605 (f:5605) ExecutePlayerMove: ; 3d65e (f:565e) xor a - ld [H_WHOSETURN], a + ld [H_WHOSETURN], a ; set player's turn ld a, [wPlayerSelectedMove] inc a - jp z, Func_3d80a + jp z, Func_3d80a ; for selected move = FF, skip most of player's turn xor a ld [W_MOVEMISSED], a ld [wcced], a @@ -3126,7 +3130,7 @@ ExecutePlayerMove: ; 3d65e (f:565e) .asm_3d68a call GetCurrentMove ld hl, W_PLAYERBATTSTATUS1 - bit 4, [hl] + bit 4, [hl] ; charging up for attack jr nz, asm_3d6a9 call CheckForDisobedience jp z, Func_3d80a @@ -3142,7 +3146,9 @@ Func_3d69a: ; 3d69a (f:569a) ; in-battle stuff asm_3d6a9: ; 3d6a9 (f:56a9) ld hl,W_PLAYERBATTSTATUS1 - res 4,[hl] + res 4,[hl] ; reset charging up and invulnerability statuses if mon was charging up for an attack + ; being fully paralyzed or hurting oneself in confusion removes charging up status + ; resulting in the Pokemon being invulnerable for the whole battle res 6,[hl] asm_3d6b0: ; 3d6b0 (f:56b0) call PrintMonName1Text @@ -3154,24 +3160,26 @@ asm_3d6b0: ; 3d6b0 (f:56b0) ld hl,EffectsArray1 ld de,1 call IsInArray - jp c,JumpMoveEffect + jp c,JumpMoveEffect ; EffectsArray1 moves skip damage calculation and accuracy tests + ; unless executed as part of their exclusive effect functions ld a,[W_PLAYERMOVEEFFECT] ld hl,EffectsArray5B ld de,1 call IsInArray - call c,JumpMoveEffect + call c,JumpMoveEffect ; execute the effects of EffectsArray5B moves (e.g. Wrap, Thrash) but don't skip anything asm_3d6dc: ; 3d6dc (f:56dc) ld a,[W_PLAYERMOVEEFFECT] ld hl,EffectsArray2 ld de,1 - call IsInArray - jp c,.asm_3d702 + call IsInArray + jp c,.asm_3d702 ; EffectsArray2 moves (e.g. Seismic Toss and Super Fang) skip damage calculation call CriticalHitTest call HandleCounterMove jr z,asm_3d705 call GetDamageVarsForPlayerAttack call CalculateDamage - jp z,asm_3d74b + jp z,asm_3d74b ; for moves with 0 BP, skip any further damage calculation and, for now, skip MoveHitTest + ; for these moves, accuracy tests will only occur if they are called as part of the effect itself call AdjustDamageForMoveType call RandomizeDamage .asm_3d702 @@ -3181,16 +3189,16 @@ asm_3d705 and a jr z,asm_3d714 ld a,[W_PLAYERMOVEEFFECT] - sub a,7 - jr z,asm_3d71e - jr asm_3d74b + sub a,7 ; Explosion effect + jr z,asm_3d71e ; don't play any animation if the move missed, unless it was EXPLODE_EFFECT + jr asm_3d74b asm_3d714 ld a,[W_PLAYERMOVEEFFECT] and a ld a,4 jr z,asm_3d71e ld a,5 -asm_3d71e +asm_3d71e push af ld a,[W_PLAYERBATTSTATUS2] bit 4,a @@ -3231,26 +3239,26 @@ asm_3d766 jp z,Func_3d80a xor a ld [wcced],a - jp Func_3d69a + jp Func_3d69a ; if Mirror Move was successful go back to damage calculation for copied move .next6 cp a,METRONOME_EFFECT jr nz,.next7 call MetronomePickMove - jp Func_3d69a + jp Func_3d69a ; Go back to damage calculation for the move picked by Metronome .next7 ld a,[W_PLAYERMOVEEFFECT] ld hl,EffectsArray3 ld de,1 call IsInArray - jp c,JumpMoveEffect + jp c,JumpMoveEffect ; done here after executing effects of EffectsArray3 ld a,[W_MOVEMISSED] and a jr z,.next8 call PrintMoveFailureText ld a,[W_PLAYERMOVEEFFECT] - cp a,EXPLODE_EFFECT + cp a,EXPLODE_EFFECT ; even if Explosion or Selfdestruct missed, its effect still needs to be activated jr z,.next9 - jp Func_3d80a + jp Func_3d80a ; otherwise, we're done if the move missed .next8 call ApplyAttackToEnemyPokemon call PrintCriticalOHKOText @@ -3262,12 +3270,12 @@ asm_3d766 ld hl,EffectsArray4 ld de,1 call IsInArray - call c,JumpMoveEffect + call c,JumpMoveEffect ; not done after executing effects of EffectsArray4 ld hl,wEnemyMonHP ld a,[hli] ld b,[hl] or b - ret z + ret z ; don't do anything else if the enemy fainted call HandleBuildingRage ld hl,W_PLAYERBATTSTATUS1 @@ -3276,13 +3284,13 @@ asm_3d766 ld a,[wPlayerNumAttacksLeft] dec a ld [wPlayerNumAttacksLeft],a - jp nz,asm_3d714 - + jp nz,asm_3d714 ; for multi-hit moves, apply attack until PlayerNumAttacksLeft hits 0 or the enemy faints. + ; damage calculation and accuracy tests only happen for the first hit res 2,[hl] ld hl,MultiHitText call PrintText xor a - ld [W_NUMHITS],a ; reset + ld [W_NUMHITS],a .next10 ld a,[W_PLAYERMOVEEFFECT] and a @@ -3290,7 +3298,10 @@ asm_3d766 ld hl,EffectsArray5 ld de,1 call IsInArray - call nc,JumpMoveEffect + call nc,JumpMoveEffect ; move effects not included in EffectsArray5, which are the effects not covered yet. + ; the only exception is Rage, whose effect will be executed for a second time (although it's irrelevant) + ; includes some side effects and all non-volatile status effects but sleep. + ; responsible for executing Twineedle's second effect (poison) jp Func_3d80a MultiHitText: ; 3d805 (f:5805) @@ -3375,7 +3386,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) .sleepDone xor a ld [wccf1],a - ld hl,Func_3d80a + ld hl,Func_3d80a ; player can't move this turn jp .CannotUseMove .FrozenCheck @@ -3385,36 +3396,36 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) call PrintText xor a ld [wccf1],a - ld hl,Func_3d80a + ld hl,Func_3d80a ; player can't move this turn jp .CannotUseMove .HeldInPlaceCheck ld a,[W_ENEMYBATTSTATUS1] - bit 5,a + bit 5,a ; is enemy using a mult-turn move like wrap? jp z,.FlinchedCheck ld hl,CantMoveText call PrintText - ld hl,Func_3d80a + ld hl,Func_3d80a ; player can't move this turn jp .CannotUseMove .FlinchedCheck ld hl,W_PLAYERBATTSTATUS1 bit 3,[hl] jp z,.HyperBeamCheck - res 3,[hl] + res 3,[hl] ; reset player's flinch status ld hl,FlinchedText call PrintText - ld hl,Func_3d80a + ld hl,Func_3d80a ; player can't move this turn jp .CannotUseMove .HyperBeamCheck ld hl,W_PLAYERBATTSTATUS2 bit 5,[hl] jr z,.AnyMoveDisabledCheck - res 5,[hl] + res 5,[hl] ; reset player's recharge status ld hl,MustRechargeText call PrintText - ld hl,Func_3d80a + ld hl,Func_3d80a ; player can't move this turn jp .CannotUseMove .AnyMoveDisabledCheck @@ -3424,7 +3435,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) jr z,.ConfusedCheck dec a ld [hl],a - and a,$F + and a,$F ; did Disable counter hit 0? jr nz,.ConfusedCheck ld [hl],a ld [wccee],a @@ -3433,13 +3444,13 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) .ConfusedCheck ld a,[W_PLAYERBATTSTATUS1] - add a + add a ; is player confused? jr nc,.TriedToUseDisabledMoveCheck ld hl,wd06b dec [hl] jr nz,.IsConfused ld hl,W_PLAYERBATTSTATUS1 - res 7,[hl] + res 7,[hl] ; if confused counter hit 0, reset confusion status ld hl,ConfusedNoMoreText call PrintText jr .TriedToUseDisabledMoveCheck @@ -3451,13 +3462,13 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) ld a,CONF_ANIM - 1 call PlayMoveAnimation call BattleRandom - cp a,$80 + cp a,$80 ; 50% chance to hurt itself jr c,.TriedToUseDisabledMoveCheck ld hl,W_PLAYERBATTSTATUS1 ld a,[hl] - and a,$80 ; confused + and a,$80 ; if mon hurts itself, clear every other status from W_PLAYERBATTSTATUS1 ld [hl],a - call PrintHurtItselfText + call HandleSelfConfusionDamage jr .MonHurtItselfOrFullyParalysed .TriedToUseDisabledMoveCheck @@ -3468,7 +3479,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) cp [hl] jr nz,.ParalysisCheck call PrintMoveIsDisabledText - ld hl,Func_3d80a + ld hl,Func_3d80a ; if a disabled move was somehow selected, player can't move this turn jp .CannotUseMove .ParalysisCheck @@ -3476,7 +3487,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) bit PAR,[hl] jr z,.BideCheck call BattleRandom - cp a,$3F + cp a,$3F ; 25% to be fully paralyzed jr nc,.BideCheck ld hl,FullyParalyzedText call PrintText @@ -3484,7 +3495,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) .MonHurtItselfOrFullyParalysed ld hl,W_PLAYERBATTSTATUS1 ld a,[hl] - and a,$CC ; clear bide, thrashing, charging up, and multi-turn moves such as warp + and a,$CC ; clear bide, thrashing, charging up, and multi-turn moves such as warp (redundant, already cleared) ld [hl],a ld a,[W_PLAYERMOVEEFFECT] cp a,FLY_EFFECT @@ -3500,7 +3511,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) call PlayMoveAnimation .NotFlyOrChargeEffect ld hl,Func_3d80a - jp .CannotUseMove + jp .CannotUseMove ; if using a two-turn move, we need to recharge the first turn .BideCheck ld hl,W_PLAYERBATTSTATUS1 @@ -3514,16 +3525,16 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) ld c,[hl] ld hl,wd075 ld a,[hl] - add c + add c ; acumulate damage taken ld [hld],a ld a,[hl] adc b ld [hl],a ld hl,wPlayerNumAttacksLeft - dec [hl] + dec [hl] ; did Bide counter hit 0? jr z,.UnleashEnergy ld hl,Func_3d80a - jp .CannotUseMove + jp .CannotUseMove ; unless mon unleashes energy, can't move this turn .UnleashEnergy ld hl,W_PLAYERBATTSTATUS1 res 0,[hl] ; not using bide any more @@ -3537,7 +3548,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) ld b,a ld [wd0d8],a ld a,[hl] - rl a + rl a ; double the damage ld [W_DAMAGE],a or b jr nz,.next @@ -3549,7 +3560,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) ld [hl],a ld a,BIDE ld [W_PLAYERMOVENUM],a - ld hl,asm_3d705 + ld hl,asm_3d705 ; skip damage calculation, DecrementPP and MoveHitTest jp .CannotUseMove .ThrashingAboutCheck @@ -3560,19 +3571,19 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) ld hl,ThrashingAboutText call PrintText ld hl,wPlayerNumAttacksLeft - dec [hl] - ld hl,asm_3d6dc - jp nz,.CannotUseMove + dec [hl] ; did Trashing About counter hit 0? + ld hl,asm_3d6dc ; skip DecrementPP + jp nz,.CannotUseMove push hl ld hl,W_PLAYERBATTSTATUS1 - res 1,[hl] - set 7,[hl] + res 1,[hl] ; no longer trashing about + set 7,[hl] ; confused call BattleRandom and a,3 inc a - inc a + inc a ; confused for 2-5 turns ld [wd06b],a - pop hl + pop hl ; skip DecrementPP jp .CannotUseMove .MultiturnMoveCheck @@ -3581,16 +3592,16 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) ld hl,AttackContinuesText call PrintText ld a,[wPlayerNumAttacksLeft] - dec a + dec a ; did multi-turn move end? ld [wPlayerNumAttacksLeft],a - ld hl,asm_3d714 + ld hl,asm_3d714 ; if it didn't, skip damage calculation (deal damage equal to last hit), DecrementPP and MoveHitTest jp nz,.CannotUseMove jp .CannotUseMove .RageCheck ld a, [W_PLAYERBATTSTATUS2] bit 6, a ; is mon using rage? - jp z, .CanUseMove + jp z, .CanUseMove ; if we made it this far, mon can move normally this turn ld a, RAGE ld [wd11e], a call GetMoveName @@ -3691,7 +3702,7 @@ MoveIsDisabledText: ; 3daa8 (f:5aa8) TX_FAR _MoveIsDisabledText db "@" -PrintHurtItselfText: ; 3daad (f:5aad) +HandleSelfConfusionDamage: ; 3daad (f:5aad) ld hl, HurtItselfText call PrintText ld hl, wEnemyMonDefense @@ -3709,13 +3720,13 @@ PrintHurtItselfText: ; 3daad (f:5aad) push af xor a ld [hli], a - ld [wCriticalHitOrOHKO], a - ld a, $28 + ld [wCriticalHitOrOHKO], a ; self-inflicted confusion damage can't be a Critical Hit + ld a, $28 ; 40 base power ld [hli], a xor a ld [hl], a call GetDamageVarsForPlayerAttack - call CalculateDamage + call CalculateDamage ; ignores AdjustDamageForMoveType (type-less damage), RandomizeDamage, and MoveHitTest (always hits) pop af pop hl ld [hl], a @@ -3893,8 +3904,9 @@ PrintMoveFailureText: ; 3dbe2 (f:5be2) cp JUMP_KICK_EFFECT ret nz - ; if you get here, the mon used hi jump kick and missed - ld hl, W_DAMAGE + ; if you get here, the mon used jump kick or hi jump kick and missed + ld hl, W_DAMAGE ; since the move missed, W_DAMAGE will always contain 0 at this point. + ; Thus, recoil damage will always be equal to 1 even if it was intended to be potential damage/8. ld a, [hli] ld b, [hl] srl a @@ -4053,7 +4065,7 @@ CheckForDisobedience: ; 3dc88 (f:5c88) jr nc, .monDoesNothing ld hl, WontObeyText call PrintText - call PrintHurtItselfText + call HandleSelfConfusionDamage jp .cannotUseMove .monNaps call BattleRandom @@ -4200,7 +4212,7 @@ GetDamageVarsForPlayerAttack: ; 3ddcf (f:5dcf) jr z, .physicalAttackCritCheck ; if the enemy has used Reflect, double the enemy's defense sla c - rl b + rl b .physicalAttackCritCheck ld hl, wBattleMonAttack ld a, [wCriticalHitOrOHKO] @@ -4231,6 +4243,8 @@ GetDamageVarsForPlayerAttack: ; 3ddcf (f:5dcf) ; if the enemy has used Light Screen, double the enemy's special sla c rl b +; reflect and light screen boosts do not cap the stat at 999, so weird things will happen during stats scaling if +; a Pokemon with 512 or more Defense has ued Reflect, or if a Pokemon with 512 or more Special has used Light Screen .specialAttackCritCheck ld hl, wBattleMonSpecial ld a, [wCriticalHitOrOHKO] @@ -4258,12 +4272,13 @@ GetDamageVarsForPlayerAttack: ; 3ddcf (f:5dcf) ld h, a ; hl = player's offensive stat or b ; is either high byte nonzero? jr z, .next ; if not, we don't need to scale - ; bc /= 4 (scale enemy's defensive stat) +; bc /= 4 (scale enemy's defensive stat) srl b rr c srl b rr c - ; hl /= 4 (scale player's offensive stat) +; defensive stat can actually end up as 0, leading to a division by 0 freeze during damage calculation +; hl /= 4 (scale player's offensive stat) srl h rr l srl h @@ -4340,6 +4355,8 @@ GetDamageVarsForEnemyAttack: ; 3de75 (f:5e75) ; if the player has used Light Screen, double the player's special sla c rl b +; reflect and light screen boosts do not cap the stat at 999, so weird things will happen during stats scaling if +; a Pokemon with 512 or more Defense has ued Reflect, or if a Pokemon with 512 or more Special has used Light Screen .specialAttackCritCheck ld hl, wEnemyMonSpecial ld a, [wCriticalHitOrOHKO] @@ -4372,6 +4389,7 @@ GetDamageVarsForEnemyAttack: ; 3de75 (f:5e75) rr c srl b rr c +; defensive stat can actually end up as 0, leading to a division by 0 freeze during damage calculation ; hl /= 4 (scale enemy's offensive stat) srl h rr l @@ -4579,20 +4597,23 @@ CalculateDamage: ; 3df65 (f:5f65) jr c, .asm_3e00a .asm_3e004 +; cap at 997 ld a, 997 / $100 ld [hli], a ld a, 997 % $100 ld [hld], a .asm_3e00a +; add 2 inc hl ld a, [hl] add 2 ld [hld], a jr nc, .done inc [hl] + .done - +; minimum damage is 1 ld a, 1 and a ret @@ -4653,7 +4674,7 @@ CriticalHitTest: ; 3e023 (f:6023) .focusEnergyUsed srl b .noFocusEnergyUsed - ld hl, HighCriticalMoves ; table of high critical hit moves + ld hl, HighCriticalMoves ; table of high critical hit moves .Loop ld a, [hli] ; read move from move table cp c ; does it match the move about to be used? @@ -4671,14 +4692,14 @@ CriticalHitTest: ; 3e023 (f:6023) jr nc, .SkipHighCritical ld b, $ff .SkipHighCritical - call BattleRandom ; generates a random value, in "a" + call BattleRandom ; generates a random value, in "a" rlc a rlc a rlc a cp b ; check a against calculated crit rate ret nc ; no critical hit if no borrow ld a, $1 - ld [wCriticalHitOrOHKO], a ; set critical hit flag + ld [wCriticalHitOrOHKO], a ; set critical hit flag ret ; high critical hit moves @@ -4692,6 +4713,12 @@ HighCriticalMoves: ; 3e08e (f:608e) ; function to determine if Counter hits and if so, how much damage it does HandleCounterMove: ; 3e093 (f:6093) +; The variables checked by Counter are updated whenever the cursor points to a new move in the battle selection menu. +; This is irrelevant for the opponent's side outside of link battles, since the move selection is controlled by the AI. +; However, in the scenario where the player switches out and the opponent uses Counter, +; the outcome may be affected by the player's actions in the move selection menu prior to switching the Pokemon. +; This might also lead to desync glitches in link battles. + ld a,[H_WHOSETURN] ; whose turn and a ; player's turn @@ -4710,11 +4737,11 @@ HandleCounterMove: ; 3e093 (f:6093) ld [W_MOVEMISSED],a ; initialize the move missed variable to true (it is set to false below if the move hits) ld a,[hl] cp a,COUNTER - ret z ; if the target also used Counter, miss + ret z ; miss if the opponent's last selected move is Counter. ld a,[de] and a - ret z ; if the move the target used has 0 power, miss -; check if the move the target used was Normal or Fighting type + ret z ; miss if the opponent's last selected move's Base Power is 0. +; check if the move the target last selected was Normal or Fighting type inc de ld a,[de] and a ; normal type @@ -4728,8 +4755,10 @@ HandleCounterMove: ; 3e093 (f:6093) ld hl,W_DAMAGE ld a,[hli] or [hl] - ret z ; Counter misses if the target did no damage to the Counter user -; double the damage that the target did to the Counter user + ret z ; If we made it here, Counter still misses if the last move used in battle did no damage to its target. + ; W_DAMAGE is shared by both players, so Counter may strike back damage dealt by the Counter user itself + ; if the conditions meet, even though 99% of the times damage will come from the target. +; if it did damage, double it ld a,[hl] add a ldd [hl],a @@ -4758,7 +4787,7 @@ ApplyAttackToEnemyPokemon: ; 3e0df (f:60df) jr z,.specialDamage ld a,[W_PLAYERMOVEPOWER] and a - jp z,ApplyAttackToEnemyPokemonDone + jp z,ApplyAttackToEnemyPokemonDone ; no attack to apply if base power is 0 jr ApplyDamageToEnemyPokemon .superFangEffect ; set the damage to half the target's HP @@ -4781,16 +4810,16 @@ ApplyAttackToEnemyPokemon: ; 3e0df (f:60df) .specialDamage ld hl,wBattleMonLevel ld a,[hl] - ld b,a + ld b,a ; Seismic Toss deals damage equal to the user's level ld a,[W_PLAYERMOVENUM] - cp a,SEISMIC_TOSS + cp a,SEISMIC_TOSS jr z,.storeDamage cp a,NIGHT_SHADE jr z,.storeDamage - ld b,SONICBOOM_DAMAGE + ld b,SONICBOOM_DAMAGE ; 20 cp a,SONICBOOM jr z,.storeDamage - ld b,DRAGON_RAGE_DAMAGE + ld b,DRAGON_RAGE_DAMAGE ; 40 cp a,DRAGON_RAGE jr z,.storeDamage ; Psywave @@ -4807,7 +4836,7 @@ ApplyAttackToEnemyPokemon: ; 3e0df (f:60df) cp b jr nc,.loop ld b,a -.storeDamage +.storeDamage ; store damage value at b ld hl,W_DAMAGE xor a ld [hli],a @@ -4839,7 +4868,7 @@ ApplyDamageToEnemyPokemon: ; 3e142 (f:6142) sbc b ld [wEnemyMonHP],a jr nc,.animateHpBar -; if more damage was done than the current HP, zero the HP and set the damage +; if more damage was done than the current HP, zero the HP and set the damage (W_DAMAGE) ; equal to how much HP the pokemon had before the attack ld a,[wHPBarOldHP+1] ld [hli],a @@ -4959,7 +4988,7 @@ ApplyDamageToPlayerPokemon: ; 3e200 (f:6200) ld [wBattleMonHP],a ld [wHPBarNewHP+1],a jr nc,.animateHpBar -; if more damage was done than the current HP, zero the HP and set the damage +; if more damage was done than the current HP, zero the HP and set the damage (W_DAMAGE) ; equal to how much HP the pokemon had before the attack ld a,[wHPBarOldHP+1] ld [hli],a @@ -4986,6 +5015,11 @@ ApplyAttackToPlayerPokemonDone jp DrawHUDsAndHPBars AttackSubstitute: ; 3e25e (f:625e) +; Unlike the two ApplyAttackToPokemon functions, Attack Substitute is shared by player and enemy. +; Self-confusion damage as well as Hi-Jump Kick and Jump Kick recoil cause a momentary turn swap before being applied. +; If the user has a Substitute up and would take damage because of that, damage will be applied to the other player's Substitute. +; Normal recoil such as from Double-Edge isn't affected by this glitch, because this function is never called in that case. + ld hl,SubstituteTookDamageText call PrintText ; values for player turn @@ -5008,6 +5042,7 @@ AttackSubstitute: ; 3e25e (f:625e) ld [de],a ret nc .substituteBroke +; If the target's Substitute breaks, W_DAMAGE isn't updated with the amount of HP the Substitute had before being attacked. ld h,b ld l,c res 4,[hl] ; unset the substitute bit @@ -5089,6 +5124,11 @@ BuildingRageText: ; 3e2f8 (f:62f8) ; copy last move for Mirror Move ; sets zero flag on failure and unsets zero flag on success MirrorMoveCopyMove: ; 3e2fd (f:62fd) +; Mirror Move makes use of ccf1 and ccf2 addresses, which are mainly used to print the "[Pokemon] used [Move]" text. +; Both are set to 0 whenever a new Pokemon is sent out +; ccf1 is also set to 0 whenever the player is fast asleep or frozen solid. +; ccf2 is also set to 0 whenever the enemy is fast asleep or frozen solid. + ld a,[H_WHOSETURN] and a ; values for player turn @@ -5102,12 +5142,11 @@ MirrorMoveCopyMove: ; 3e2fd (f:62fd) ld hl,wEnemySelectedMove .next ld [hl],a - cp a,MIRROR_MOVE ; did the target pokemon also use Mirror Move? + cp a,MIRROR_MOVE ; did the target Pokemon last use Mirror Move, and miss? jr z,.mirrorMoveFailed and a ; null move? jr nz,ReloadMoveData .mirrorMoveFailed -; Mirror Move fails on itself and null moves ld hl,MirrorMoveFailedText call PrintText xor a @@ -5296,6 +5335,7 @@ AdjustDamageForMoveType: ; 3e3a5 (f:63a5) jr nz,.skipTypeImmunity .typeImmunity ; if damage is 0, make the move miss +; this only occurs if a move that would do 2 or 3 damage is 0.25x effective against the target inc a ld [W_MOVEMISSED],a .skipTypeImmunity @@ -5546,7 +5586,7 @@ RandomizeDamage: ; 3e687 (f:6687) jr nz, .DamageGreaterThanOne ld a, [hl] cp 2 - ret c + ret c ; return if damage is equal to 0 or 1 .DamageGreaterThanOne xor a ld [H_MULTIPLICAND], a From 21f306d6532843172b133ab407ccd1da7a37c6bb Mon Sep 17 00:00:00 2001 From: stag019 Date: Wed, 7 Jan 2015 21:30:48 -0500 Subject: [PATCH 067/100] Fix PNG files to have bit depth match the bit depth used in the game. --- gfx/ED_tile.png | Bin 82 -> 79 bytes gfx/battle_hud1.png | Bin 100 -> 94 bytes gfx/battle_hud2.png | Bin 82 -> 79 bytes gfx/battle_hud3.png | Bin 92 -> 88 bytes gfx/blue/blueversion.png | Bin 136 -> 116 bytes gfx/font.png | Bin 719 -> 625 bytes gfx/gamefreak_intro.png | Bin 297 -> 180 bytes gfx/ledge_hopping_shadow.png | Bin 81 -> 77 bytes gfx/minimized_mon_sprite.png | Bin 78 -> 74 bytes gfx/mon_nest_icon.png | Bin 86 -> 80 bytes gfx/p_tile.png | Bin 80 -> 77 bytes gfx/red/redgreenversion.png | Bin 145 -> 126 bytes gfx/town_map_cursor.png | Bin 87 -> 82 bytes gfx/up_arrow.png | Bin 86 -> 80 bytes 14 files changed, 0 insertions(+), 0 deletions(-) diff --git a/gfx/ED_tile.png b/gfx/ED_tile.png index c8e132b927be8d31f1d68c2c3c032a8be3b3c455..352489d60ba13d66872b65e168cabe62f95f19f9 100644 GIT binary patch delta 60 zcmWIYpCDn*$N&UyN}APxl$fWBV+hCfF!$v=|MGdP+husr|wpWn&hm}IrYNgmNZ{~I6L hGaqJW6KLrA!_J@`C%?ti;gKFlyQiz4%Q~loCID(890C9U diff --git a/gfx/battle_hud2.png b/gfx/battle_hud2.png index ef120166dc1abc64082976f3cceef2fbeda58189..a5df75c8c3ded4a496ee5437de93be46e4bac78c 100644 GIT binary patch delta 60 zcmWIYpCDn*$N&WI7d7q$QevJijv*Y^lPk_O@Y*H(IPgK9^_f!!1Am8@qUh>Zu^^S6 Lu6{1-oD!MF!$v=|MJ1`g;{9#}8KVrh!bPH*QIVV&Wr00oz P1S$4(^>bP0l+XkKfI}5p diff --git a/gfx/battle_hud3.png b/gfx/battle_hud3.png index e4c452b1a45eabd1361e5b28d5646e7fd4b48a70..00643de7b57dae50c0e1d053f1a620410654449d 100644 GIT binary patch delta 69 zcma!vm>}W6$N&WI7d7q$Qu3ZIjv*Y^lYg9NXi{KEv}JcLW2@8nZ{KV?;VjQ&c7`cc V0s<$uw7Y_|c)I$ztaD0e0s!Q570mzu delta 73 zcma!unIPf9!~g^O=$B>F!$v^(jXKYenIQKW1-<8MVi@YMA%b)*_N<4o~ ZykgvFs_^MEet A6#xJL delta 118 zcmXTvV4NUPz{CIqYCHEW0#g2-E{-7;w_3Xoaxyq_FthG=iV}RMo%6bhHAY)Zq2jgO z_u@(w1D_S^FW4`b!&r7zN{q{TI U5%cr3Z-cDxboFyt=akR{07dpH2LJ#7 diff --git a/gfx/font.png b/gfx/font.png index d5548c09f29af148632ec67f9b5d0f5b921b49f8..34e86b4a683cb214b92f71e462ed372b19bfb984 100644 GIT binary patch delta 612 zcmV-q0-OEM1@Q!s7=Hl(0002`twPcO00KBkL_t(I%jJ@>i_}0A#$QOWe}IkMmeyi% z3~~hj0;|L7kShg))e>ZR3}K2bx3IKGX<>1Q#c~Y85C%z^?o!ARL}ZZTc*r8-vc%_P zZx2uX6P#km{PMl;`(OrW;wDMrP?d9u*rd?S&0I=@6bdO0HGf7RQA!!X3wd;m2s)LR zrY8x7$1=|`1%;ymk%|L}Gn9b1_bB4*OC3QPQ)En8ViHp%@Lvm>bP@lcz+{s#|CoZt zIU(j+Z$t0>wvVQgP#<+&Ai4&r8Uc-qIf7X+5O$)YK7vu9=SZd#n(W@=11hQs1;rE} zV#*&Sq6@I)fq&O=XG^?l)wTA~;mcezuab;#@R~G7bPHBw~b?LA; zd2|fs)RNYDr?;jKeYgNqxe<`|r3s%RsO>^JjN=;B=Y11v@MF^8CKzNzbc= z%7JHj>Ce6AFj;EVG{EaGOy_aFEBe)fH1PMY5qMv<)SoVS1Xs~6j@W8aRouYNzPVNG zBgc2D8(pu;k30;hS)`h6qTF3W@v(03fT5&m2ADoxi)z>=6M5`M9Hun}IAQPK95 ydhMqo5uz0vSnAgH)Rc)@E7eBRo>^M@9s3J!_%2T_a^GzL0000G*emRO=U`8# z6C4N-JyBTRQP5#KQ2>xXT*6p~of#H7IXkDG(a};EtNAX19g(}I<0rRmk~$ zR@p-qhM_Ko87jj}oB0BO_|>3a*ztD@aIxB;w?-ZEwm=R9!1}umqgHvn^!WEet<+G{ zYyfI#G6|4o`qcY5_w~uxqig=WM1b={-aYs=Xt|<2a05hrL0r0zx zl3`!90+hTpfK0)bTN+8>vi9M2LF^1qZ!0s&q0t4NnI^T+uUgoby!bJ3{saCgz|5Av zEGq}9E`2E?09<()a|l}x8~!;oapQorWtD|6w@25qAj}A4 z)v%#GK!4J%&gy_lT%`{kVgoxIS#NN`RNNQoL_fZfb+ADTOaub1Jr95ukY{Wchx`M$ zbK|&h@;63-LSXXAd)c=_#i@L(k-lJo2kTaz0D|Jg8ikTjwT77q-a475Rb3`;2o)6? zU7(a(LcOUxMHBM@80TzA)svEVraPb58b)6(wEF zO0IL9Z|iYz|53Jh&@v(4?ec|B_ZR;vT-#N5idWw}NP4a;!*P-CyYt@n=XGed{ycDo Q{UFFap00i_>zopr03Rkol>h($ delta 282 zcmV+#0pQ000SaNLh0L01FcU01FcV0GgZ_00007bV*G` z2i^n)6b&)i;q=x30078IL_t(I%e_=d62mYElRWwVm(@e#g|#P_Ljr`@0?DQX5YzO& zxqPntuEJ4I6QPKAop9I21g~N%Id49d#5D0a7W?;2d*Y@5A%74&wx{EQ2|PA%>8hD> zY?$Au{JL*CJk7285&mERvdxC(6%0I<%rVa0%WJ4Qj7?KRnun1n)TUw zxdLW>WXHWeQ5`@vQO3O-12lOR1MAlT#$1d?rzb~D`1|H*V*mZOOsj?`hMcw7lB?9k gi-&)?*Q|X27!$N&2pTfL^Z)<=07*qoM6N<$f;Lrl1poj5 diff --git a/gfx/ledge_hopping_shadow.png b/gfx/ledge_hopping_shadow.png index cad35624f34427d38356c7ba14ca2eec52cd8de7..8e76005658ea19db53f5bb75ff2078117f1c25d3 100644 GIT binary patch delta 58 zcmWIaogiV#$N&UyN}APxl!&K`V+hCf`tc59t5^ delta 62 zcmeYboFHMz!~g`Vul)Q5q$E6D978H@CI9$8pRtk8;7?-0j{^q^8WI@cFTo>AVr?8elF{r G5}E+VfDvE- delta 59 zcmebBn;>Dv!~g{1UavHOl&GhRV@SoV^-n$N&UyN}APxl(?shV+hCf{R6S&`aIH%OG`*x&BUQ{Z)`s MPgg&ebxsLQ05awiZ2$lO delta 67 zcmWFtn;>Dw!~g`Vul)Q5q+~r^978H@C0qQT`S3#`n}WfE#0?u64bMp!*VyqhguG?j TSO1|$7o@?{)z4*}Q$iB}EgKjf diff --git a/gfx/p_tile.png b/gfx/p_tile.png index 309fb7636533cd06b8a0e5fe59c921393b34d9ca..3df11133d89e650eb6ffb323e9b8b2464a6c0750 100644 GIT binary patch delta 58 zcmWIWogiV#$N&UyN}APxl!&K`V+hCf^-n!~g`Vul)Q5q{Ka4978H@CI9$8zp-(C<9`E@#vA_|IT%71*w!1?E$Rm; N^>p=fS?83{1OT`57Lxz~ diff --git a/gfx/red/redgreenversion.png b/gfx/red/redgreenversion.png index 8b34ec095b5af067b0a6603a73eac359e96691dc..e41b4295cffcd85ab8d48d7df341108983b520f8 100644 GIT binary patch delta 108 zcmbQpST{i;jgbKe+_t;U0#dG?E{-7_*OPznv-8}T`KSKY|NrLy{;&UM-#n|achiE6 z2Ob{(#AD+f;>Rk<`n~d%@rorYWQ?sV4&Np7(bv(mpaZ4E!ewIHKc(#fhaC;i`$dCYWT&gxF44A{HY2XH4 OkYZ0)KbLh*2~7Y!3KFdV delta 68 zcmWFvpCDn+!~g^Z8arfwl$@uFV@SoV^-n$N&UyN}APxl(?shV+hCfp=fS?83{1ORD16;S{H delta 67 zcmWFtn;>Dw!~g`Vul)Q5q+~r^978H@CI9$8pRwcLpY$II=L;I Date: Sun, 18 Jan 2015 19:39:16 -0500 Subject: [PATCH 068/100] No longer need to make a mapfile with the newest RGBDS source. This RGBDS doesn't have a release yet. --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index ddb9d88ea2..938860f32a 100644 --- a/Makefile +++ b/Makefile @@ -84,8 +84,8 @@ $(all_obj): $$*.asm $$($$*_dep) # Link objects together to build a rom. -# Make a symfile for debugging. rgblink will segfault if a mapfile isn't made too. -link = rgblink -n poke$*.sym -m poke$*.map +# Make a symfile for debugging. +link = rgblink -n poke$*.sym poke%.gbc: $$(%_obj) $(link) -o $@ $^ From 4a8f7d3dd2c8413a88af4cf4f2f42ba0ccf044af Mon Sep 17 00:00:00 2001 From: stag019 Date: Sun, 18 Jan 2015 19:41:59 -0500 Subject: [PATCH 069/100] Remove symfiles on clean. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 938860f32a..8cdbe2d638 100644 --- a/Makefile +++ b/Makefile @@ -93,5 +93,5 @@ poke%.gbc: $$(%_obj) clean: - rm -f $(roms) $(all_obj) + rm -f $(roms) $(all_obj) poke*.sym find . \( -iname '*.1bpp' -o -iname '*.2bpp' -o -iname '*.pic' \) -exec rm {} + From 6e8f6f66c111927160364be937ddbd3f9894fd67 Mon Sep 17 00:00:00 2001 From: stag019 Date: Sun, 18 Jan 2015 19:43:45 -0500 Subject: [PATCH 070/100] make compare depends on red and blue being built. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 8cdbe2d638..5cc485c118 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ MD5 := md5sum -c --quiet # The compare target is a shortcut to check that the build matches the original roms exactly. # This is for contributors to make sure a change didn't affect the contents of the rom. # More thorough comparison can be made by diffing the output of hexdump -C against both roms. -compare: +compare: red blue @$(MD5) roms.md5 From 1b62ca0555333f82d52d98c630d0af1f2fb0b3df Mon Sep 17 00:00:00 2001 From: xCrystal Date: Tue, 20 Jan 2015 12:12:30 +0100 Subject: [PATCH 071/100] add commentary to move effects --- engine/battle/core.asm | 199 ++++++++++++++++++++++------------------- 1 file changed, 106 insertions(+), 93 deletions(-) diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 8f516def21..2c8bbd9dbe 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -7182,29 +7182,31 @@ SleepEffect: ; 3f1fc (f:71fc) .asm_3f20e ld a, [bc] - bit 5, a ; does the mon need to recharge? (hyper beam) - res 5, a ; mon no longer needs to recharge + bit 5, a ; does the target need to recharge? (hyper beam) + res 5, a ; target no longer needs to recharge ld [bc], a - jr nz, .asm_3f231 + jr nz, .asm_3f231 ; if the target had to recharge, all hit tests will be skipped + ; including the event where the target already has another status ld a, [de] ld b, a and $7 - jr z, .asm_3f222 + jr z, .asm_3f222 ; can't affect a mon that is already asleep ld hl, AlreadyAsleepText jp PrintText .asm_3f222 ld a, b and a - jr nz, .asm_3f242 + jr nz, .asm_3f242 ; can't affect a mon that is already statused push de - call MoveHitTest + call MoveHitTest ; apply accuracy tests pop de ld a, [W_MOVEMISSED] and a jr nz, .asm_3f242 .asm_3f231 +; set target's sleep counter to a random number between 1 and 7 call BattleRandom - and $7 + and $7 jr z, .asm_3f231 ld [de], a call Func_3fb89 @@ -7231,16 +7233,16 @@ PoisonEffect: ; 3f24f (f:724f) ld de, W_ENEMYMOVEEFFECT .asm_3f260 call CheckTargetSubstitute - jr nz, .asm_3f2d3 + jr nz, .asm_3f2d3 ; can't posion a substitute target ld a, [hli] ld b, a and a - jr nz, .asm_3f2d3 + jr nz, .asm_3f2d3 ; miss if target is already statused ld a, [hli] - cp $3 + cp $3 ; can't posion a poison-type target jr z, .asm_3f2d3 ld a, [hld] - cp $3 + cp $3 ; can't posion a poison-type target jr z, .asm_3f2d3 ld a, [de] cp POISON_SIDE_EFFECT1 @@ -7251,7 +7253,7 @@ PoisonEffect: ; 3f24f (f:724f) jr z, .asm_3f290 push hl push de - call MoveHitTest + call MoveHitTest ; apply accuracy tests pop de pop hl ld a, [W_MOVEMISSED] @@ -7259,12 +7261,12 @@ PoisonEffect: ; 3f24f (f:724f) jr nz, .asm_3f2d7 jr .asm_3f295 .asm_3f290 - call BattleRandom - cp b + call BattleRandom + cp b ; was side effect successful? ret nc .asm_3f295 dec hl - set 3, [hl] + set 3, [hl] ; mon is now poisoned push de dec de ld a, [H_WHOSETURN] @@ -7279,8 +7281,8 @@ PoisonEffect: ; 3f24f (f:724f) ld de, W_ENEMYTOXICCOUNTER .asm_3f2b0 cp TOXIC - jr nz, .asm_3f2bd - set 0, [hl] + jr nz, .asm_3f2bd ; done if move is not Toxic + set 0, [hl] ; else set Toxic battstatus xor a ld [de], a ld hl, BadlyPoisonedText @@ -7342,65 +7344,64 @@ ExplodeEffect: ; 3f2f1 (f:72f1) FreezeBurnParalyzeEffect: ; 3f30c (f:730c) xor a ld [wcc5b], a - call CheckTargetSubstitute ;test bit 4 of d063/d068 flags [target has substitute flag] - ret nz ;return if they have a substitute, can't effect them - ld a, [$fff3] ;whose turn? + call CheckTargetSubstitute ; test bit 4 of d063/d068 flags [target has substitute flag] + ret nz ; return if they have a substitute, can't effect them + ld a, [$fff3] and a jp nz, opponentAttacker ld a, [wEnemyMonStatus] and a - jp nz, CheckDefrost - ;opponent has no existing status + jp nz, CheckDefrost ; can't inflict status if opponent is already statused ld a, [W_PLAYERMOVETYPE] ld b, a ld a, [wEnemyMonType1] - cp b - ret z ;return if they match [can't freeze an ice type etc.] + cp b ; do target type 1 and move type match? + ret z ; return if they match (an ice move can't freeze an ice-type, body slam can't paralyze a normal-type, etc.) ld a, [wEnemyMonType2] - cp b - ret z ;return.. + cp b ; do target type 2 and move type match? + ret z ; return if they match ld a, [W_PLAYERMOVEEFFECT] - cp a, 7 ;10% status effects are 04, 05, 06 so 07 will set carry for those - ld b, $1a ;[1A-1]/100 or [26-1]/256 = 9.8%~ chance - jr c, .next1 ;branch ahead if this is a 10% chance effect.. - ld b, $4d ;..or use [4D-1]/100 or [76-1]/256 = 29.7%~ chance - sub a, $1e ;subtract $1E to map to equivalent 10% chance effects + cp a, 7 ; 10% status effects are 04, 05, 06 so 07 will set carry for those + ld b, $1a ; 0x1A/0x100 or 26/256 = 10.2%~ chance + jr c, .next1 ; branch ahead if this is a 10% chance effect.. + ld b, $4d ; else use 0x4D/0x100 or 77/256 = 30.1%~ chance + sub a, $1e ; subtract $1E to map to equivalent 10% chance effects .next1 - push af ;push effect... - call BattleRandom ;get random 8bit value for probability test - cp b ;success? - pop bc ;...pop effect into C - ret nc ;do nothing if random value is >= 1A or 4D [no status applied] - ;the test passed - ld a, b ;what type of effect is this? + push af + call BattleRandom ; get random 8bit value for probability test + cp b + pop bc + ret nc ; do nothing if random value is >= 1A or 4D [no status applied] + ld a, b ; what type of effect is this? cp a, BURN_SIDE_EFFECT1 jr z, .burn cp a, FREEZE_SIDE_EFFECT jr z, .freeze +; .paralyze ld a, 1 << PAR ld [wEnemyMonStatus], a - call QuarterSpeedDueToParalysis ;quarter speed of affected monster + call QuarterSpeedDueToParalysis ; quarter speed of affected mon ld a, ANIM_A9 - call Func_3fbb9 ;animation - jp PrintMayNotAttackText ;print paralysis text + call Func_3fbb9 ; play animation + jp PrintMayNotAttackText ; print paralysis text .burn ld a, 1 << BRN ld [wEnemyMonStatus], a - call HalveAttackDueToBurn + call HalveAttackDueToBurn ; halve attack of affected mon ld a, ANIM_A9 - call Func_3fbb9 ;animation + call Func_3fbb9 ; animation ld hl, BurnedText jp PrintText .freeze - call Func_3f9cf ;resets bit 5 of the D063/D068 flags + call Func_3f9cf ; resets hyper beam (recharge) condition from both players ld a, 1 << FRZ ld [wEnemyMonStatus], a ld a, ANIM_A9 - call Func_3fbb9 ;animation + call Func_3fbb9 ; animation ld hl, FrozenText jp PrintText opponentAttacker: ; 3f382 (f:7382) - ld a, [wBattleMonStatus] ;this appears to the same as above with addresses swapped for opponent + ld a, [wBattleMonStatus] ; mostly same as above with addresses swapped for opponent and a jp nz, CheckDefrost ld a, [W_ENEMYMOVETYPE] @@ -7439,6 +7440,7 @@ opponentAttacker: ; 3f382 (f:7382) ld hl, BurnedText jp PrintText .freeze +; hyper beam bits aren't reseted for opponent's side ld a, 1 << FRZ ld [wBattleMonStatus], a ld hl, FrozenText @@ -7453,28 +7455,27 @@ FrozenText: ; 3f3dd (f:73dd) db "@" CheckDefrost: ; 3f3e2 (f:73e2) - and a, 1 << FRZ ;are they frozen? - ret z ;return if so - ;not frozen - ld a, [$fff3] ;whose turn? +; any fire-type move that has a chance inflict burn (all but Fire Spin) will defrost a frozen target + and a, 1 << FRZ ; are they frozen? + ret z ; return if so + ld a, [$fff3] and a jr nz, .opponent ;player [attacker] ld a, [W_PLAYERMOVETYPE] sub a, FIRE - ret nz ;return if it isn't fire - ;type is fire - ld [wEnemyMonStatus], a ;set opponent status to 00 ["defrost" a frozen monster] + ret nz ; return if type of move used isn't fire + ld [wEnemyMonStatus], a ; set opponent status to 00 ["defrost" a frozen monster] ld hl, wEnemyMon1Status ld a, [wEnemyMonPartyPos] ld bc, wEnemyMon2 - wEnemyMon1 call AddNTimes xor a - ld [hl], a ;clear status in roster + ld [hl], a ; clear status in roster ld hl, FireDefrostedText jr .common .opponent - ld a, [W_ENEMYMOVETYPE] ;same as above with addresses swapped + ld a, [W_ENEMYMOVETYPE] ; same as above with addresses swapped sub a, FIRE ret nz ld [wBattleMonStatus], a @@ -7505,29 +7506,29 @@ StatModifierUpEffect: ; 3f428 (f:7428) sub $a cp $8 jr c, .asm_3f442 - sub $28 + sub $28 ; map +2 effects to equivalent +1 effect .asm_3f442 ld c, a ld b, $0 add hl, bc ld b, [hl] - inc b + inc b ; increment corresponding stat mod ld a, $d - cp b + cp b ; can't raise stat past +6 ($d or 13) jp c, Func_3f522 ld a, [de] - cp $12 + cp $12 ; is it a +2 effect? jr c, .asm_3f45a - inc b + inc b ; if so, increment stat mod again ld a, $d - cp b + cp b ; unless it's already +6 jr nc, .asm_3f45a ld b, a .asm_3f45a ld [hl], b ld a, c cp $4 - jr nc, asm_3f4ca + jr nc, asm_3f4ca ; jump if mod affected is evasion/accuracy push hl ld hl, wBattleMonAttack + 1 ld de, wcd12 @@ -7540,21 +7541,22 @@ StatModifierUpEffect: ; 3f428 (f:7428) push bc sla c ld b, $0 - add hl, bc + add hl, bc ; hl = modified stat ld a, c add e ld e, a jr nc, .asm_3f47e - inc d + inc d ; de = unmodified (original) stat .asm_3f47e pop bc ld a, [hld] - sub $e7 + sub $e7 ; check if stat is already 999 jr nz, .asm_3f48a ld a, [hl] sbc $3 jp z, Func_3f520 -.asm_3f48a +.asm_3f48a ; recalculate affected stat + ; paralysis and burn penalties, as well as badge boosts are ignored push hl push bc ld hl, StatModifierRatios @@ -7579,6 +7581,7 @@ StatModifierUpEffect: ; 3f428 (f:7428) ld b, $4 call Divide pop hl +; cap at 999 ld a, [$ff98] sub $e7 ld a, [$ff97] @@ -7612,13 +7615,13 @@ asm_3f4ca: ; 3f4ca (f:74ca) ld a, [de] cp MINIMIZE jr nz, .asm_3f4f9 - bit 4, [hl] + bit 4, [hl] ; substitute push af push bc ld hl, Func_79747 ld b, BANK(Func_79747) push de - call nz, Bankswitch + call nz, Bankswitch ; play Minimize animation unless there's Substitute involved pop de .asm_3f4f9 call Func_3fba8 @@ -7635,11 +7638,14 @@ asm_3f4ca: ; 3f4ca (f:74ca) .asm_3f50e ld a, [H_WHOSETURN] and a - call z, ApplyBadgeStatBoosts + call z, ApplyBadgeStatBoosts ; whenever the player uses a stat-up move, badge boosts get reapplied again to every stat, + ; even to those not affected by the stat-up move (will be boosted further) ld hl, MonsStatsRoseText call PrintText - call QuarterSpeedDueToParalysis - jp HalveAttackDueToBurn + +; these shouldn't be here + call QuarterSpeedDueToParalysis ; apply speed penalty to the player whose turn is not, if it's paralyzed + jp HalveAttackDueToBurn ; apply attack penalty to the player whose turn is not, if it's burned Func_3f520: ; 3f520 (f:7520) pop hl @@ -7686,25 +7692,25 @@ StatModifierDownEffect: ; 3f54c (f:754c) cp $4 jr z, .asm_3f572 call BattleRandom - cp $40 + cp $40 ; 1/4 chance to miss by wildmon jp c, Func_3f65a .asm_3f572 - call CheckTargetSubstitute + call CheckTargetSubstitute ; can't hit through substitute jp nz, Func_3f65a ld a, [de] cp ATTACK_DOWN_SIDE_EFFECT jr c, .asm_3f58a call BattleRandom - cp SPLASH_EFFECT + cp $55 ; 85/256 chance for side effects jp nc, Func_3f650 ld a, [de] - sub ATTACK_DOWN_SIDE_EFFECT + sub ATTACK_DOWN_SIDE_EFFECT ; map each stat to 0-3 jr .asm_3f5a9 -.asm_3f58a +.asm_3f58a ; non-side effects only push hl push de push bc - call MoveHitTest + call MoveHitTest ; apply accuracy tests pop bc pop de pop hl @@ -7712,33 +7718,33 @@ StatModifierDownEffect: ; 3f54c (f:754c) and a jp nz, Func_3f65a ld a, [bc] - bit 6, a + bit 6, a ; fly/dig jp nz, Func_3f65a ld a, [de] sub $12 cp $8 jr c, .asm_3f5a9 - sub $28 + sub $28 ; map +2 effects to corresponding +1 effect .asm_3f5a9 ld c, a ld b, $0 add hl, bc ld b, [hl] - dec b - jp z, Func_3f650 + dec b ; dec corresponding stat mod + jp z, Func_3f650 ; if stat mod is 1 (-6), can't lower anymore ld a, [de] cp $24 jr c, .asm_3f5bf cp $44 jr nc, .asm_3f5bf - dec b + dec b ; stat down 2 effects only (dec mod again) jr nz, .asm_3f5bf - inc b + inc b ; increment mod to 1 (-6) if it would become 0 (-7) .asm_3f5bf - ld [hl], b + ld [hl], b ; save modified mod ld a, c - cp $4 - jr nc, asm_3f62c + cp $4 + jr nc, asm_3f62c ; jump for evasion/accuracy push hl push de ld hl, wEnemyMonAttack + 1 @@ -7752,21 +7758,23 @@ StatModifierDownEffect: ; 3f54c (f:754c) push bc sla c ld b, $0 - add hl, bc + add hl, bc ; hl = modified stat ld a, c add e ld e, a jr nc, .asm_3f5e4 - inc d + inc d ; de = unmodified stat .asm_3f5e4 pop bc ld a, [hld] - sub $1 + sub $1 ; can't lower stat below 1 (-6) jr nz, .asm_3f5ef ld a, [hl] and a jp z, Func_3f64d .asm_3f5ef +; recalculate affected stat +; paralysis and burn penalties, as well as badge boosts are ignored push hl push bc ld hl, StatModifierRatios @@ -7820,9 +7828,14 @@ asm_3f62c: ; 3f62c (f:762c) .asm_3f63b ld a, [H_WHOSETURN] and a - call nz, ApplyBadgeStatBoosts + call nz, ApplyBadgeStatBoosts ; whenever the player uses a stat-down move, badge boosts get reapplied again to every stat, + ; even to those not affected by the stat-up move (will be boosted further) ld hl, MonsStatsFellText call PrintText + +; These where probably added given that a stat-down move affecting speed or attack will override +; the stat penalties from paralysis and burn respectively. +; But they are always called regardless of the stat affected by the stat-down move. call QuarterSpeedDueToParalysis jp HalveAttackDueToBurn @@ -7931,7 +7944,7 @@ BideEffect: ; 3f6e5 (f:76e5) and $1 inc a inc a - ld [bc], a + ld [bc], a ; set Bide counter to 2 or 3 at random ld a, [H_WHOSETURN] add XSTATITEM_ANIM jp Func_3fb96 @@ -7947,10 +7960,10 @@ ThrashPetalDanceEffect: ; 3f717 (f:7717) .asm_3f728 set 1, [hl] ; mon is now using thrash/petal dance call BattleRandom - and $1 + and $1 inc a inc a - ld [de], a + ld [de], a ; set thrash/petal dance counter to 2 or 3 at random ld a, [H_WHOSETURN] add ANIM_B0 jp Func_3fb96 From 61aaa15205d7a36a3f00cc16f893aa62a3a5bee9 Mon Sep 17 00:00:00 2001 From: xCrystal Date: Tue, 20 Jan 2015 20:21:16 +0100 Subject: [PATCH 072/100] rename some labels --- engine/battle/core.asm | 415 +++++++++++++++++++++-------------------- 1 file changed, 208 insertions(+), 207 deletions(-) diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 2c8bbd9dbe..f51ce52607 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -1,7 +1,7 @@ BattleCore: ; These are move effects (second value from the Moves table in bank $E). -EffectsArray1: ; 3c000 (f:4000) +ResidualEffects1: ; 3c000 (f:4000) db CONVERSION_EFFECT db HAZE_EFFECT db SWITCH_AND_TELEPORT_EFFECT @@ -19,13 +19,13 @@ EffectsArray1: ; 3c000 (f:4000) db LEECH_SEED_EFFECT db SPLASH_EFFECT db -1 -EffectsArray2: ; 3c011 (f:4011) +SetDamageEffects: ; 3c011 (f:4011) ; moves that do damage but not through normal calculations ; e.g., Super Fang, Psywave db SUPER_FANG_EFFECT db SPECIAL_DAMAGE_EFFECT db -1 -EffectsArray3: ; 3c014 (f:4014) +ResidualEffects2: ; 3c014 (f:4014) ; stat-affecting moves, sleep-inflicting moves, and Bide ; e.g., Meditate, Bide, Hypnosis db $01 @@ -56,7 +56,7 @@ EffectsArray3: ; 3c014 (f:4014) db ACCURACY_DOWN2_EFFECT db EVASION_DOWN2_EFFECT db -1 -EffectsArray4: ; 3c030 (f:4030) +AlwaysHappenSideEffects: ; 3c030 (f:4030) ; Attacks that aren't finished after they faint the opponent. db DRAIN_HP_EFFECT db EXPLODE_EFFECT @@ -69,7 +69,7 @@ EffectsArray4: ; 3c030 (f:4030) db TWINEEDLE_EFFECT db RAGE_EFFECT db -1 -EffectsArray5: ; 3c03b (f:403b) +SpecialEffects: ; 3c03b (f:403b) ; Effects from arrays 2, 4, and 5B, minus Twineedle and Rage. ; Includes all effects that do not need to be called at the end of ; ExecutePlayerMove (or ExecuteEnemyMove), because they have already been handled @@ -88,7 +88,7 @@ EffectsArray5: ; 3c03b (f:403b) db JUMP_KICK_EFFECT db RECOIL_EFFECT ; fallthrough to Next EffectsArray -EffectsArray5B: ; 3c049 (f:4049) +SpecialEffectsCont: ; 3c049 (f:4049) ; damaging moves whose effect is executed prior to damage calculation db THRASH_PETAL_DANCE_EFFECT db TRAPPING_EFFECT @@ -3112,7 +3112,7 @@ ExecutePlayerMove: ; 3d65e (f:565e) ld [H_WHOSETURN], a ; set player's turn ld a, [wPlayerSelectedMove] inc a - jp z, Func_3d80a ; for selected move = FF, skip most of player's turn + jp z, ExecutePlayerMoveDone ; for selected move = FF, skip most of player's turn xor a ld [W_MOVEMISSED], a ld [wcced], a @@ -3121,9 +3121,9 @@ ExecutePlayerMove: ; 3d65e (f:565e) ld [wd05b], a ld a, [wcd6a] and a - jp nz, Func_3d80a + jp nz, ExecutePlayerMoveDone call PrintGhostText - jp z, Func_3d80a + jp z, ExecutePlayerMoveDone call CheckPlayerStatusConditions jr nz, .asm_3d68a jp [hl] @@ -3131,9 +3131,9 @@ ExecutePlayerMove: ; 3d65e (f:565e) call GetCurrentMove ld hl, W_PLAYERBATTSTATUS1 bit 4, [hl] ; charging up for attack - jr nz, asm_3d6a9 + jr nz, PlayerCanExecuteChargingMove call CheckForDisobedience - jp z, Func_3d80a + jp z, ExecutePlayerMoveDone Func_3d69a: ; 3d69a (f:569a) ld a, [W_PLAYERMOVEEFFECT] @@ -3141,38 +3141,38 @@ Func_3d69a: ; 3d69a (f:569a) jp z, JumpMoveEffect cp FLY_EFFECT jp z, JumpMoveEffect - jr asm_3d6b0 + jr PlayerCanExecuteMove ; in-battle stuff -asm_3d6a9: ; 3d6a9 (f:56a9) +PlayerCanExecuteChargingMove: ; 3d6a9 (f:56a9) ld hl,W_PLAYERBATTSTATUS1 res 4,[hl] ; reset charging up and invulnerability statuses if mon was charging up for an attack ; being fully paralyzed or hurting oneself in confusion removes charging up status ; resulting in the Pokemon being invulnerable for the whole battle res 6,[hl] -asm_3d6b0: ; 3d6b0 (f:56b0) +PlayerCanExecuteMove: ; 3d6b0 (f:56b0) call PrintMonName1Text ld hl,DecrementPP ld de,wPlayerSelectedMove ; pointer to the move just used ld b,BANK(DecrementPP) call Bankswitch ld a,[W_PLAYERMOVEEFFECT] ; effect of the move just used - ld hl,EffectsArray1 + ld hl,ResidualEffects1 ld de,1 call IsInArray - jp c,JumpMoveEffect ; EffectsArray1 moves skip damage calculation and accuracy tests + jp c,JumpMoveEffect ; ResidualEffects1 moves skip damage calculation and accuracy tests ; unless executed as part of their exclusive effect functions ld a,[W_PLAYERMOVEEFFECT] - ld hl,EffectsArray5B + ld hl,SpecialEffectsCont ld de,1 call IsInArray - call c,JumpMoveEffect ; execute the effects of EffectsArray5B moves (e.g. Wrap, Thrash) but don't skip anything -asm_3d6dc: ; 3d6dc (f:56dc) + call c,JumpMoveEffect ; execute the effects of SpecialEffectsCont moves (e.g. Wrap, Thrash) but don't skip anything +CalcMoveDamage: ; 3d6dc (f:56dc) ld a,[W_PLAYERMOVEEFFECT] - ld hl,EffectsArray2 + ld hl,SetDamageEffects ld de,1 call IsInArray - jp c,.asm_3d702 ; EffectsArray2 moves (e.g. Seismic Toss and Super Fang) skip damage calculation + jp c,.moveHitTest ; SetDamageEffects moves (e.g. Seismic Toss and Super Fang) skip damage calculation call CriticalHitTest call HandleCounterMove jr z,asm_3d705 @@ -3182,7 +3182,7 @@ asm_3d6dc: ; 3d6dc (f:56dc) ; for these moves, accuracy tests will only occur if they are called as part of the effect itself call AdjustDamageForMoveType call RandomizeDamage -.asm_3d702 +.moveHitTest call MoveHitTest asm_3d705 ld a,[W_MOVEMISSED] @@ -3209,68 +3209,68 @@ asm_3d71e ld [wcc5b],a ld a,[W_PLAYERMOVENUM] call PlayMoveAnimation - call Func_3eed3 + call HandleExplodingAnimation call DrawPlayerHUDAndHPBar ld a,[W_PLAYERBATTSTATUS2] bit 4,a ld hl,Func_79771 ld b,BANK(Func_79771) call nz,Bankswitch - jr asm_3d766 + jr MirrorMoveCheck asm_3d74b ld c,$1E call DelayFrames ld a,[W_PLAYERMOVEEFFECT] cp a,FLY_EFFECT - jr z,.next5 + jr z,.playAnim cp a,CHARGE_EFFECT - jr z,.next5 - jr asm_3d766 -.next5 + jr z,.playAnim + jr MirrorMoveCheck +.playAnim xor a ld [wcc5b],a ld a,STATUS_AFFECTED_ANIM call PlayMoveAnimation -asm_3d766 +MirrorMoveCheck ld a,[W_PLAYERMOVEEFFECT] cp a,MIRROR_MOVE_EFFECT - jr nz,.next6 + jr nz,.metronomeCheck call MirrorMoveCopyMove - jp z,Func_3d80a + jp z,ExecutePlayerMoveDone xor a ld [wcced],a jp Func_3d69a ; if Mirror Move was successful go back to damage calculation for copied move -.next6 +.metronomeCheck cp a,METRONOME_EFFECT - jr nz,.next7 + jr nz,.next call MetronomePickMove jp Func_3d69a ; Go back to damage calculation for the move picked by Metronome -.next7 +.next ld a,[W_PLAYERMOVEEFFECT] - ld hl,EffectsArray3 + ld hl,ResidualEffects2 ld de,1 call IsInArray - jp c,JumpMoveEffect ; done here after executing effects of EffectsArray3 + jp c,JumpMoveEffect ; done here after executing effects of ResidualEffects2 ld a,[W_MOVEMISSED] and a - jr z,.next8 + jr z,.moveDidNotMiss call PrintMoveFailureText ld a,[W_PLAYERMOVEEFFECT] cp a,EXPLODE_EFFECT ; even if Explosion or Selfdestruct missed, its effect still needs to be activated - jr z,.next9 - jp Func_3d80a ; otherwise, we're done if the move missed -.next8 + jr z,.notDone + jp ExecutePlayerMoveDone ; otherwise, we're done if the move missed +.moveDidNotMiss call ApplyAttackToEnemyPokemon call PrintCriticalOHKOText callab DisplayEffectiveness ld a,1 ld [wccf4],a -.next9 +.notDone ld a,[W_PLAYERMOVEEFFECT] - ld hl,EffectsArray4 + ld hl,AlwaysHappenSideEffects ld de,1 call IsInArray - call c,JumpMoveEffect ; not done after executing effects of EffectsArray4 + call c,JumpMoveEffect ; not done after executing effects of AlwaysHappenSideEffects ld hl,wEnemyMonHP ld a,[hli] ld b,[hl] @@ -3280,7 +3280,7 @@ asm_3d766 ld hl,W_PLAYERBATTSTATUS1 bit 2,[hl] - jr z,.next10 + jr z,.executeOtherEffects ld a,[wPlayerNumAttacksLeft] dec a ld [wPlayerNumAttacksLeft],a @@ -3291,24 +3291,24 @@ asm_3d766 call PrintText xor a ld [W_NUMHITS],a -.next10 +.executeOtherEffects ld a,[W_PLAYERMOVEEFFECT] and a - jp z,Func_3d80a - ld hl,EffectsArray5 + jp z,ExecutePlayerMoveDone + ld hl,SpecialEffects ld de,1 call IsInArray - call nc,JumpMoveEffect ; move effects not included in EffectsArray5, which are the effects not covered yet. + call nc,JumpMoveEffect ; move effects not included in SpecialEffects, which are the effects not covered yet. ; the only exception is Rage, whose effect will be executed for a second time (although it's irrelevant) ; includes some side effects and all non-volatile status effects but sleep. ; responsible for executing Twineedle's second effect (poison) - jp Func_3d80a + jp ExecutePlayerMoveDone MultiHitText: ; 3d805 (f:5805) TX_FAR _MultiHitText db "@" -Func_3d80a: ; 3d80a (f:580a) +ExecutePlayerMoveDone: ; 3d80a (f:580a) xor a ld [wcd6a],a ld b,1 @@ -3386,8 +3386,8 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) .sleepDone xor a ld [wccf1],a - ld hl,Func_3d80a ; player can't move this turn - jp .CannotUseMove + ld hl,ExecutePlayerMoveDone ; player can't move this turn + jp .returnToHL .FrozenCheck bit FRZ,[hl] ; frozen? @@ -3396,8 +3396,8 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) call PrintText xor a ld [wccf1],a - ld hl,Func_3d80a ; player can't move this turn - jp .CannotUseMove + ld hl,ExecutePlayerMoveDone ; player can't move this turn + jp .returnToHL .HeldInPlaceCheck ld a,[W_ENEMYBATTSTATUS1] @@ -3405,8 +3405,8 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) jp z,.FlinchedCheck ld hl,CantMoveText call PrintText - ld hl,Func_3d80a ; player can't move this turn - jp .CannotUseMove + ld hl,ExecutePlayerMoveDone ; player can't move this turn + jp .returnToHL .FlinchedCheck ld hl,W_PLAYERBATTSTATUS1 @@ -3415,8 +3415,8 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) res 3,[hl] ; reset player's flinch status ld hl,FlinchedText call PrintText - ld hl,Func_3d80a ; player can't move this turn - jp .CannotUseMove + ld hl,ExecutePlayerMoveDone ; player can't move this turn + jp .returnToHL .HyperBeamCheck ld hl,W_PLAYERBATTSTATUS2 @@ -3425,8 +3425,8 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) res 5,[hl] ; reset player's recharge status ld hl,MustRechargeText call PrintText - ld hl,Func_3d80a ; player can't move this turn - jp .CannotUseMove + ld hl,ExecutePlayerMoveDone ; player can't move this turn + jp .returnToHL .AnyMoveDisabledCheck ld hl,W_PLAYERDISABLEDMOVE @@ -3479,8 +3479,8 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) cp [hl] jr nz,.ParalysisCheck call PrintMoveIsDisabledText - ld hl,Func_3d80a ; if a disabled move was somehow selected, player can't move this turn - jp .CannotUseMove + ld hl,ExecutePlayerMoveDone ; if a disabled move was somehow selected, player can't move this turn + jp .returnToHL .ParalysisCheck ld hl,wBattleMonStatus @@ -3495,7 +3495,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) .MonHurtItselfOrFullyParalysed ld hl,W_PLAYERBATTSTATUS1 ld a,[hl] - and a,$CC ; clear bide, thrashing, charging up, and multi-turn moves such as warp (redundant, already cleared) + and a, %11001100 ; clear bide, thrashing, charging up, and multi-turn moves such as warp (redundant, already cleared) ld [hl],a ld a,[W_PLAYERMOVEEFFECT] cp a,FLY_EFFECT @@ -3510,8 +3510,8 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) ld a,STATUS_AFFECTED_ANIM call PlayMoveAnimation .NotFlyOrChargeEffect - ld hl,Func_3d80a - jp .CannotUseMove ; if using a two-turn move, we need to recharge the first turn + ld hl,ExecutePlayerMoveDone + jp .returnToHL ; if using a two-turn move, we need to recharge the first turn .BideCheck ld hl,W_PLAYERBATTSTATUS1 @@ -3533,8 +3533,8 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) ld hl,wPlayerNumAttacksLeft dec [hl] ; did Bide counter hit 0? jr z,.UnleashEnergy - ld hl,Func_3d80a - jp .CannotUseMove ; unless mon unleashes energy, can't move this turn + ld hl,ExecutePlayerMoveDone + jp .returnToHL ; unless mon unleashes energy, can't move this turn .UnleashEnergy ld hl,W_PLAYERBATTSTATUS1 res 0,[hl] ; not using bide any more @@ -3561,7 +3561,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) ld a,BIDE ld [W_PLAYERMOVENUM],a ld hl,asm_3d705 ; skip damage calculation, DecrementPP and MoveHitTest - jp .CannotUseMove + jp .returnToHL .ThrashingAboutCheck bit 1,[hl] ; is mon using thrash or petal dance? @@ -3572,8 +3572,8 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) call PrintText ld hl,wPlayerNumAttacksLeft dec [hl] ; did Trashing About counter hit 0? - ld hl,asm_3d6dc ; skip DecrementPP - jp nz,.CannotUseMove + ld hl,CalcMoveDamage ; skip DecrementPP + jp nz,.returnToHL push hl ld hl,W_PLAYERBATTSTATUS1 res 1,[hl] ; no longer trashing about @@ -3584,7 +3584,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) inc a ; confused for 2-5 turns ld [wd06b],a pop hl ; skip DecrementPP - jp .CannotUseMove + jp .returnToHL .MultiturnMoveCheck bit 5,[hl] ; is mon using multi-turn move? @@ -3595,8 +3595,8 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) dec a ; did multi-turn move end? ld [wPlayerNumAttacksLeft],a ld hl,asm_3d714 ; if it didn't, skip damage calculation (deal damage equal to last hit), DecrementPP and MoveHitTest - jp nz,.CannotUseMove - jp .CannotUseMove + jp nz,.returnToHL + jp .returnToHL .RageCheck ld a, [W_PLAYERBATTSTATUS2] @@ -3608,10 +3608,10 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) call CopyStringToCF4B xor a ld [W_PLAYERMOVEEFFECT], a - ld hl, asm_3d6b0 - jp .CannotUseMove + ld hl, PlayerCanExecuteMove + jp .returnToHL -.CannotUseMove +.returnToHL xor a ret @@ -3919,19 +3919,19 @@ PrintMoveFailureText: ; 3dbe2 (f:5be2) dec hl ld [hli], a or b - jr nz, .asm_3dc2a + jr nz, .applyRecoil inc a ld [hl], a -.asm_3dc2a +.applyRecoil ld hl, KeptGoingAndCrashedText call PrintText ld b, $4 predef Func_48125 ld a, [H_WHOSETURN] and a - jr nz, .asm_3dc3f + jr nz, .enemyTurn jp ApplyDamageToPlayerPokemon -.asm_3dc3f +.enemyTurn jp ApplyDamageToEnemyPokemon AttackMissedText: ; 3dc42 (f:5c42) @@ -4420,7 +4420,7 @@ GetEnemyMonStat: ; 3df1c (f:5f1c) push bc ld a, [W_ISLINKBATTLE] cp $4 - jr nz, .asm_3df40 + jr nz, .notLinkBattle ld hl, wEnemyMon1Stats dec c sla c @@ -4436,7 +4436,7 @@ GetEnemyMonStat: ; 3df1c (f:5f1c) pop bc pop de ret -.asm_3df40 +.notLinkBattle ld a, [wEnemyMonLevel] ld [W_CURENEMYLVL], a ld a, [wEnemyMonSpecies] @@ -5226,9 +5226,9 @@ IncrementMovePP: ; 3e373 (f:6373) ld a,[H_WHOSETURN] and a ld a,[wPlayerMonNumber] ; value for player turn - jr z,.next2 + jr z,.updatePP ld a,[wEnemyMonPartyPos] ; value for enemy turn -.next2 +.updatePP ld bc,wEnemyMon2 - wEnemyMon1 call AddNTimes inc [hl] ; increment PP in the party memory location @@ -5672,19 +5672,19 @@ asm_3e72b: ; 3e72b (f:672b) ld [wcced], a call PrintMonName1Text ld a, [W_ENEMYMOVEEFFECT] - ld hl, EffectsArray1 + ld hl, ResidualEffects1 ld de, $1 call IsInArray jp c, JumpMoveEffect ld a, [W_ENEMYMOVEEFFECT] - ld hl, EffectsArray5B + ld hl, SpecialEffectsCont ld de, $1 call IsInArray call c, JumpMoveEffect asm_3e750: ; 3e750 (f:6750) call SwapPlayerAndEnemyLevels ld a, [W_ENEMYMOVEEFFECT] - ld hl, EffectsArray2 + ld hl, SetDamageEffects ld de, $1 call IsInArray jp c, Func_3e77f @@ -5733,7 +5733,7 @@ asm_3e7a4: ; 3e7a4 (f:67a4) ld [wcc5b], a ld a, [W_ENEMYMOVENUM] call PlayMoveAnimation - call Func_3eed3 + call HandleExplodingAnimation call DrawEnemyHUDAndHPBar ld a, [W_ENEMYBATTSTATUS2] bit 4, a ; does mon have a substitute? @@ -5771,7 +5771,7 @@ asm_3e7ef: ; 3e7ef (f:67ef) jp Func_3e6fc .notMetronomeEffect ld a, [W_ENEMYMOVEEFFECT] - ld hl, EffectsArray3 + ld hl, ResidualEffects2 ld de, $1 call IsInArray jp c, JumpMoveEffect @@ -5791,7 +5791,7 @@ asm_3e7ef: ; 3e7ef (f:67ef) ld [wccf4], a .asm_3e83e ld a, [W_ENEMYMOVEEFFECT] - ld hl, EffectsArray4 + ld hl, AlwaysHappenSideEffects ld de, $1 call IsInArray call c, JumpMoveEffect @@ -5818,7 +5818,7 @@ asm_3e7ef: ; 3e7ef (f:67ef) ld a, [W_ENEMYMOVEEFFECT] and a jr z, Func_3e88c - ld hl, EffectsArray5 + ld hl, SpecialEffects ld de, $1 call IsInArray call nc, JumpMoveEffect @@ -6744,14 +6744,14 @@ BattleRandom: ret -Func_3eed3: ; 3eed3 (f:6ed3) +HandleExplodingAnimation: ; 3eed3 (f:6ed3) ld a, [H_WHOSETURN] and a - ld hl, wEnemyMonType1 ; wcfea (aliases: wEnemyMonType) + ld hl, wEnemyMonType1 ; wcfea ld de, W_ENEMYBATTSTATUS1 ld a, [W_PLAYERMOVENUM] jr z, .asm_3eeea - ld hl, wBattleMonType1 ; wd019 (aliases: wBattleMonType) + ld hl, wBattleMonType1 ; wd019 ld de, W_ENEMYBATTSTATUS1 ld a, [W_ENEMYMOVENUM] .asm_3eeea @@ -6772,7 +6772,7 @@ Func_3eed3: ; 3eed3 (f:6ed3) ld a, [W_MOVEMISSED] and a ret nz - ld a, MEGA_PUNCH + ld a, 5 ld [wcc5b], a PlayMoveAnimation: ; 3ef07 (f:6f07) @@ -7176,43 +7176,43 @@ SleepEffect: ; 3f1fc (f:71fc) ld bc, W_ENEMYBATTSTATUS2 ld a, [H_WHOSETURN] and a - jp z, .asm_3f20e + jp z, .sleepEffect ld de, wBattleMonStatus ld bc, W_PLAYERBATTSTATUS2 -.asm_3f20e +.sleepEffect ld a, [bc] bit 5, a ; does the target need to recharge? (hyper beam) res 5, a ; target no longer needs to recharge ld [bc], a - jr nz, .asm_3f231 ; if the target had to recharge, all hit tests will be skipped + jr nz, .setSleepCounter ; if the target had to recharge, all hit tests will be skipped ; including the event where the target already has another status ld a, [de] ld b, a and $7 - jr z, .asm_3f222 ; can't affect a mon that is already asleep + jr z, .notAlreadySleeping ; can't affect a mon that is already asleep ld hl, AlreadyAsleepText jp PrintText -.asm_3f222 +.notAlreadySleeping ld a, b and a - jr nz, .asm_3f242 ; can't affect a mon that is already statused + jr nz, .didntAffect ; can't affect a mon that is already statused push de call MoveHitTest ; apply accuracy tests pop de ld a, [W_MOVEMISSED] and a - jr nz, .asm_3f242 -.asm_3f231 + jr nz, .didntAffect +.setSleepCounter ; set target's sleep counter to a random number between 1 and 7 call BattleRandom and $7 - jr z, .asm_3f231 + jr z, .setSleepCounter ld [de], a call Func_3fb89 ld hl, FellAsleepText jp PrintText -.asm_3f242 +.didntAffect jp PrintDidntAffectText FellAsleepText: ; 3f245 (f:7245) @@ -7228,29 +7228,29 @@ PoisonEffect: ; 3f24f (f:724f) ld de, W_PLAYERMOVEEFFECT ld a, [H_WHOSETURN] and a - jr z, .asm_3f260 + jr z, .poisonEffect ld hl, wBattleMonStatus ld de, W_ENEMYMOVEEFFECT -.asm_3f260 +.poisonEffect call CheckTargetSubstitute - jr nz, .asm_3f2d3 ; can't posion a substitute target + jr nz, .noEffect ; can't posion a substitute target ld a, [hli] ld b, a and a - jr nz, .asm_3f2d3 ; miss if target is already statused + jr nz, .noEffect ; miss if target is already statused ld a, [hli] - cp $3 ; can't posion a poison-type target - jr z, .asm_3f2d3 + cp POISON ; can't posion a poison-type target + jr z, .noEffect ld a, [hld] - cp $3 ; can't posion a poison-type target - jr z, .asm_3f2d3 + cp POISON ; can't posion a poison-type target + jr z, .noEffect ld a, [de] cp POISON_SIDE_EFFECT1 ld b, $34 ; ~20% chance of poisoning - jr z, .asm_3f290 + jr z, .sideEffectTest cp POISON_SIDE_EFFECT2 ld b, $67 ; ~40% chance of poisoning - jr z, .asm_3f290 + jr z, .sideEffectTest push hl push de call MoveHitTest ; apply accuracy tests @@ -7258,13 +7258,13 @@ PoisonEffect: ; 3f24f (f:724f) pop hl ld a, [W_MOVEMISSED] and a - jr nz, .asm_3f2d7 - jr .asm_3f295 -.asm_3f290 + jr nz, .didntAffect + jr .inflictPoison +.sideEffectTest call BattleRandom cp b ; was side effect successful? ret nc -.asm_3f295 +.inflictPoison dec hl set 3, [hl] ; mon is now poisoned push de @@ -7275,19 +7275,19 @@ PoisonEffect: ; 3f24f (f:724f) ld hl, W_PLAYERBATTSTATUS3 ld a, [de] ld de, W_PLAYERTOXICCOUNTER - jr nz, .asm_3f2b0 + jr nz, .ok ld b, ANIM_A9 ld hl, W_ENEMYBATTSTATUS3 ld de, W_ENEMYTOXICCOUNTER -.asm_3f2b0 +.ok cp TOXIC - jr nz, .asm_3f2bd ; done if move is not Toxic + jr nz, .normalPoison ; done if move is not Toxic set 0, [hl] ; else set Toxic battstatus xor a ld [de], a ld hl, BadlyPoisonedText jr .asm_3f2c0 -.asm_3f2bd +.normalPoison ld hl, PoisonedText .asm_3f2c0 pop de @@ -7300,11 +7300,11 @@ PoisonEffect: ; 3f24f (f:724f) .asm_3f2cd call Func_3fb89 jp PrintText -.asm_3f2d3 +.noEffect ld a, [de] cp POISON_EFFECT ret nz -.asm_3f2d7 +.didntAffect ld c, $32 call DelayFrames jp PrintDidntAffectText @@ -7327,10 +7327,10 @@ ExplodeEffect: ; 3f2f1 (f:72f1) ld de, W_PLAYERBATTSTATUS2 ld a, [H_WHOSETURN] and a - jr z, .asm_3f302 + jr z, .faintUser ld hl, wEnemyMonHP ld de, W_ENEMYBATTSTATUS2 -.asm_3f302 +.faintUser xor a ld [hli], a ; set the mon's HP to 0 ld [hli], a @@ -7361,7 +7361,7 @@ FreezeBurnParalyzeEffect: ; 3f30c (f:730c) cp b ; do target type 2 and move type match? ret z ; return if they match ld a, [W_PLAYERMOVEEFFECT] - cp a, 7 ; 10% status effects are 04, 05, 06 so 07 will set carry for those + cp a, PARALYZE_SIDE_EFFECT1 + 1 ; 10% status effects are 04, 05, 06 so 07 will set carry for those ld b, $1a ; 0x1A/0x100 or 26/256 = 10.2%~ chance jr c, .next1 ; branch ahead if this is a 10% chance effect.. ld b, $4d ; else use 0x4D/0x100 or 77/256 = 30.1%~ chance @@ -7382,22 +7382,22 @@ FreezeBurnParalyzeEffect: ; 3f30c (f:730c) ld [wEnemyMonStatus], a call QuarterSpeedDueToParalysis ; quarter speed of affected mon ld a, ANIM_A9 - call Func_3fbb9 ; play animation + call PlayAnimation jp PrintMayNotAttackText ; print paralysis text .burn ld a, 1 << BRN ld [wEnemyMonStatus], a call HalveAttackDueToBurn ; halve attack of affected mon ld a, ANIM_A9 - call Func_3fbb9 ; animation + call PlayAnimation ld hl, BurnedText jp PrintText .freeze - call Func_3f9cf ; resets hyper beam (recharge) condition from both players + call ClearHyperBeam ; resets hyper beam (recharge) condition from both players ld a, 1 << FRZ ld [wEnemyMonStatus], a ld a, ANIM_A9 - call Func_3fbb9 ; animation + call PlayAnimation ld hl, FrozenText jp PrintText opponentAttacker: ; 3f382 (f:7382) @@ -7498,16 +7498,16 @@ StatModifierUpEffect: ; 3f428 (f:7428) ld de, W_PLAYERMOVEEFFECT ld a, [H_WHOSETURN] and a - jr z, .asm_3f439 + jr z, .statModifierUpEffect ld hl, wEnemyMonStatMods ld de, W_ENEMYMOVEEFFECT -.asm_3f439 +.statModifierUpEffect ld a, [de] sub $a cp $8 - jr c, .asm_3f442 + jr c, .incrementStatMod sub $28 ; map +2 effects to equivalent +1 effect -.asm_3f442 +.incrementStatMod ld c, a ld b, $0 add hl, bc @@ -7518,26 +7518,26 @@ StatModifierUpEffect: ; 3f428 (f:7428) jp c, Func_3f522 ld a, [de] cp $12 ; is it a +2 effect? - jr c, .asm_3f45a + jr c, .ok inc b ; if so, increment stat mod again ld a, $d cp b ; unless it's already +6 - jr nc, .asm_3f45a + jr nc, .ok ld b, a -.asm_3f45a +.ok ld [hl], b ld a, c cp $4 - jr nc, asm_3f4ca ; jump if mod affected is evasion/accuracy + jr nc, UpdateStatDone ; jump if mod affected is evasion/accuracy push hl ld hl, wBattleMonAttack + 1 ld de, wcd12 ld a, [H_WHOSETURN] and a - jr z, .asm_3f472 + jr z, .pointToStats ld hl, wEnemyMonAttack + 1 ld de, wEnemyMonUnmodifiedAttack -.asm_3f472 +.pointToStats push bc sla c ld b, $0 @@ -7545,17 +7545,17 @@ StatModifierUpEffect: ; 3f428 (f:7428) ld a, c add e ld e, a - jr nc, .asm_3f47e + jr nc, .checkIf999 inc d ; de = unmodified (original) stat -.asm_3f47e +.checkIf999 pop bc ld a, [hld] sub $e7 ; check if stat is already 999 - jr nz, .asm_3f48a + jr nz, .recalculateStat ld a, [hl] sbc $3 jp z, Func_3f520 -.asm_3f48a ; recalculate affected stat +.recalculateStat ; recalculate affected stat ; paralysis and burn penalties, as well as badge boosts are ignored push hl push bc @@ -7586,19 +7586,19 @@ StatModifierUpEffect: ; 3f428 (f:7428) sub $e7 ld a, [$ff97] sbc $3 - jp c, Func_3f4c3 + jp c, UpdateStat ld a, 999 / $100 ld [$ff97], a ld a, 999 % $100 ld [$ff98], a -Func_3f4c3: ; 3f4c3 (f:74c3) +UpdateStat: ; 3f4c3 (f:74c3) ld a, [$ff97] ld [hli], a ld a, [$ff98] ld [hl], a pop hl -asm_3f4ca: ; 3f4ca (f:74ca) +UpdateStatDone: ; 3f4ca (f:74ca) ld b, c inc b call Func_3f688 @@ -7627,7 +7627,7 @@ asm_3f4ca: ; 3f4ca (f:74ca) call Func_3fba8 ld a, [de] cp MINIMIZE - jr nz, .asm_3f50e + jr nz, .applyBadgeBoostsAndStatusPenalties pop bc ld a, $1 ld [bc], a @@ -7635,7 +7635,7 @@ asm_3f4ca: ; 3f4ca (f:74ca) ld b, BANK(Func_79771) pop af call nz, Bankswitch -.asm_3f50e +.applyBadgeBoostsAndStatusPenalties ld a, [H_WHOSETURN] and a call z, ApplyBadgeStatBoosts ; whenever the player uses a stat-up move, badge boosts get reapplied again to every stat, @@ -7684,29 +7684,29 @@ StatModifierDownEffect: ; 3f54c (f:754c) ld bc, W_ENEMYBATTSTATUS1 ld a, [H_WHOSETURN] and a - jr z, .asm_3f572 + jr z, .statModifierDownEffect ld hl, wPlayerMonStatMods ld de, W_ENEMYMOVEEFFECT ld bc, W_PLAYERBATTSTATUS1 ld a, [W_ISLINKBATTLE] cp $4 - jr z, .asm_3f572 + jr z, .statModifierDownEffect call BattleRandom cp $40 ; 1/4 chance to miss by wildmon - jp c, Func_3f65a -.asm_3f572 + jp c, MoveMissed +.statModifierDownEffect call CheckTargetSubstitute ; can't hit through substitute - jp nz, Func_3f65a + jp nz, MoveMissed ld a, [de] cp ATTACK_DOWN_SIDE_EFFECT - jr c, .asm_3f58a + jr c, .nonSideEffect call BattleRandom cp $55 ; 85/256 chance for side effects - jp nc, Func_3f650 + jp nc, CantLowerAnymore ld a, [de] sub ATTACK_DOWN_SIDE_EFFECT ; map each stat to 0-3 - jr .asm_3f5a9 -.asm_3f58a ; non-side effects only + jr .decrementStatMod +.nonSideEffect ; non-side effects only push hl push de push bc @@ -7716,45 +7716,45 @@ StatModifierDownEffect: ; 3f54c (f:754c) pop hl ld a, [W_MOVEMISSED] and a - jp nz, Func_3f65a + jp nz, MoveMissed ld a, [bc] bit 6, a ; fly/dig - jp nz, Func_3f65a + jp nz, MoveMissed ld a, [de] sub $12 cp $8 - jr c, .asm_3f5a9 + jr c, .decrementStatMod sub $28 ; map +2 effects to corresponding +1 effect -.asm_3f5a9 +.decrementStatMod ld c, a ld b, $0 add hl, bc ld b, [hl] dec b ; dec corresponding stat mod - jp z, Func_3f650 ; if stat mod is 1 (-6), can't lower anymore + jp z, CantLowerAnymore ; if stat mod is 1 (-6), can't lower anymore ld a, [de] cp $24 - jr c, .asm_3f5bf + jr c, .ok cp $44 - jr nc, .asm_3f5bf + jr nc, .ok dec b ; stat down 2 effects only (dec mod again) - jr nz, .asm_3f5bf + jr nz, .ok inc b ; increment mod to 1 (-6) if it would become 0 (-7) -.asm_3f5bf +.ok ld [hl], b ; save modified mod ld a, c cp $4 - jr nc, asm_3f62c ; jump for evasion/accuracy + jr nc, UpdateStatDone ; jump for evasion/accuracy push hl push de ld hl, wEnemyMonAttack + 1 ld de, wEnemyMonUnmodifiedAttack ld a, [H_WHOSETURN] and a - jr z, .asm_3f5d8 + jr z, .pointToStat ld hl, wBattleMonAttack + 1 ld de, wcd12 -.asm_3f5d8 +.pointToStat push bc sla c ld b, $0 @@ -7768,11 +7768,11 @@ StatModifierDownEffect: ; 3f54c (f:754c) pop bc ld a, [hld] sub $1 ; can't lower stat below 1 (-6) - jr nz, .asm_3f5ef + jr nz, .recalculateStat ld a, [hl] and a jp z, Func_3f64d -.asm_3f5ef +.recalculateStat ; recalculate affected stat ; paralysis and burn penalties, as well as badge boosts are ignored push hl @@ -7803,19 +7803,19 @@ StatModifierDownEffect: ; 3f54c (f:754c) ld b, a ld a, [$ff97] or b - jp nz, Func_3f624 + jp nz, UpdateStat ld [$ff97], a ld a, $1 ld [$ff98], a -Func_3f624: ; 3f624 (f:7624) +UpdateStat: ; 3f624 (f:7624) ld a, [$ff97] ld [hli], a ld a, [$ff98] ld [hl], a pop de pop hl -asm_3f62c: ; 3f62c (f:762c) +UpdateStatDone: ; 3f62c (f:762c) ld b, c inc b push de @@ -7823,9 +7823,9 @@ asm_3f62c: ; 3f62c (f:762c) pop de ld a, [de] cp $44 - jr nc, .asm_3f63b + jr nc, .ApplyBadgeBoostsAndStatusPenalties call Func_3fb89 -.asm_3f63b +.ApplyBadgeBoostsAndStatusPenalties ld a, [H_WHOSETURN] and a call nz, ApplyBadgeStatBoosts ; whenever the player uses a stat-down move, badge boosts get reapplied again to every stat, @@ -7844,14 +7844,14 @@ Func_3f64d: ; 3f64d (f:764d) pop hl inc [hl] -Func_3f650: ; 3f650 (f:7650) +CantLowerAnymore: ; 3f650 (f:7650) ld a, [de] cp ATTACK_DOWN_SIDE_EFFECT ret nc ld hl, NothingHappenedText jp PrintText -Func_3f65a: ; 3f65a (f:765a) +MoveMissed: ; 3f65a (f:765a) ld a, [de] cp $44 ret nc @@ -7928,11 +7928,11 @@ BideEffect: ; 3f6e5 (f:76e5) ld bc, wPlayerNumAttacksLeft ld a, [H_WHOSETURN] and a - jr z, .asm_3f6fc + jr z, .bideEffect ld hl, W_ENEMYBATTSTATUS1 ld de, wcd05 ld bc, wEnemyNumAttacksLeft -.asm_3f6fc +.bideEffect set 0, [hl] ; mon is now using bide xor a ld [de], a @@ -7954,10 +7954,10 @@ ThrashPetalDanceEffect: ; 3f717 (f:7717) ld de, wPlayerNumAttacksLeft ld a, [H_WHOSETURN] and a - jr z, .asm_3f728 + jr z, .thrashPetalDanceEffect ld hl, W_ENEMYBATTSTATUS1 ld de, wEnemyNumAttacksLeft -.asm_3f728 +.thrashPetalDanceEffect set 1, [hl] ; mon is now using thrash/petal dance call BattleRandom and $1 @@ -8057,7 +8057,7 @@ SwitchAndTeleportEffect: ; 3f739 (f:7739) jp Func_3fb4e .asm_3f7e4 push af - call Func_3fbb9 + call PlayAnimation ld c, $14 call DelayFrames pop af @@ -8089,43 +8089,44 @@ TwoToFiveAttacksEffect: ; 3f811 (f:7811) ld bc, W_NUMHITS ld a, [H_WHOSETURN] and a - jr z, .asm_3f828 + jr z, .twoToFiveAttacksEffect ld hl, W_ENEMYBATTSTATUS1 ld de, wEnemyNumAttacksLeft ld bc, wcd05 -.asm_3f828 +.twoToFiveAttacksEffect bit 2, [hl] ; is mon attacking multiple times? ret nz set 2, [hl] ; mon is now attacking multiple times ld hl, W_PLAYERMOVEEFFECT ld a, [H_WHOSETURN] and a - jr z, .asm_3f838 + jr z, .setNumberOfHits ld hl, W_ENEMYMOVEEFFECT -.asm_3f838 +.setNumberOfHits ld a, [hl] cp TWINEEDLE_EFFECT - jr z, .asm_3f856 + jr z, .twineedle cp ATTACK_TWICE_EFFECT - ld a, $2 - jr z, .asm_3f853 + ld a, $2 ; number of hits it's always 2 for ATTACK_TWICE_EFFECT + jr z, .saveNumberOfHits +; for TWO_TO_FIVE_ATTACKS_EFFECT 3/8 chance for 2 and 3 hits, and 1/8 chance for 4 and 5 hits call BattleRandom - and $3 - cp $2 - jr c, .asm_3f851 + and $3 + cp $2 + jr c, .asm_3f851 call BattleRandom and $3 -.asm_3f851 +.asm_3f851 inc a inc a -.asm_3f853 +.saveNumberOfHits ld [de], a ld [bc], a ret -.asm_3f856 - ld a, $2 - ld [hl], a - jr .asm_3f853 +.twineedle + ld a, POISON_SIDE_EFFECT1 + ld [hl], a ; set Twineedle's effect to poison effect + jr .saveNumberOfHits FlichSideEffect: ; 3f85b (f:785b) call CheckTargetSubstitute @@ -8148,7 +8149,7 @@ FlichSideEffect: ; 3f85b (f:785b) cp b ret nc set 3, [hl] ; set mon's status to flinching - call Func_3f9cf + call ClearHyperBeam ret OneHitKOEffect: ; 3f884 (f:7884) @@ -8184,7 +8185,7 @@ ChargeEffect: ; 3f88c (f:788c) xor a ld [wcc5b], a ld a, b - call Func_3fbb9 + call PlayAnimation ld a, [de] ld [wWhichTrade], a ld hl, ChargeMoveEffectText @@ -8249,7 +8250,7 @@ TrappingEffect: ; 3f917 (f:7917) .asm_3f928 bit 5, [hl] ret nz - call Func_3f9cf + call ClearHyperBeam set 5, [hl] call BattleRandom and $3 @@ -8348,7 +8349,7 @@ HyperBeamEffect: ; 3f9c1 (f:79c1) set 5, [hl] ; mon now needs to recharge ret -Func_3f9cf: ; 3f9cf (f:79cf) +ClearHyperBeam: ; 3f9cf (f:79cf) push hl ld hl, W_ENEMYBATTSTATUS2 ld a, [H_WHOSETURN] @@ -8659,7 +8660,7 @@ Func_3fba8: ; 3fba8 (f:7ba8) and a ret z -Func_3fbb9: ; 3fbb9 (f:7bb9) +PlayAnimation: ; 3fbb9 (f:7bb9) ld [W_ANIMATIONID], a Func_3fbbc: ; 3fbbc (f:7bbc) From e6499cd505754008f219a2f038245062d6291181 Mon Sep 17 00:00:00 2001 From: xCrystal Date: Tue, 20 Jan 2015 20:34:56 +0100 Subject: [PATCH 073/100] some constants in stat up/down effects --- engine/battle/core.asm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/engine/battle/core.asm b/engine/battle/core.asm index f51ce52607..98a89e4a35 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -7503,10 +7503,10 @@ StatModifierUpEffect: ; 3f428 (f:7428) ld de, W_ENEMYMOVEEFFECT .statModifierUpEffect ld a, [de] - sub $a + sub ATTACK_UP1_EFFECT cp $8 jr c, .incrementStatMod - sub $28 ; map +2 effects to equivalent +1 effect + sub ATTACK_UP2_EFFECT - ATTACK_UP1_EFFECT ; map +2 effects to equivalent +1 effect .incrementStatMod ld c, a ld b, $0 @@ -7517,7 +7517,7 @@ StatModifierUpEffect: ; 3f428 (f:7428) cp b ; can't raise stat past +6 ($d or 13) jp c, Func_3f522 ld a, [de] - cp $12 ; is it a +2 effect? + cp ATTACK_UP1_EFFECT + $8 ; is it a +2 effect? jr c, .ok inc b ; if so, increment stat mod again ld a, $d @@ -7721,10 +7721,10 @@ StatModifierDownEffect: ; 3f54c (f:754c) bit 6, a ; fly/dig jp nz, MoveMissed ld a, [de] - sub $12 + sub ATTACK_DOWN1_EFFECT cp $8 jr c, .decrementStatMod - sub $28 ; map +2 effects to corresponding +1 effect + sub ATTACK_DOWN2_EFFECT - ATTACK_DOWN1_EFFECT ; map +2 effects to corresponding +1 effect .decrementStatMod ld c, a ld b, $0 From d3bf8bca5e7e6e2ccf98241bee950d9cccf2994e Mon Sep 17 00:00:00 2001 From: xCrystal Date: Wed, 21 Jan 2015 11:24:55 +0100 Subject: [PATCH 074/100] fix duplicate labels --- engine/battle/core.asm | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 98a89e4a35..cfcfa9db33 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -7382,14 +7382,14 @@ FreezeBurnParalyzeEffect: ; 3f30c (f:730c) ld [wEnemyMonStatus], a call QuarterSpeedDueToParalysis ; quarter speed of affected mon ld a, ANIM_A9 - call PlayAnimation + call PlayBattleAnimatiom jp PrintMayNotAttackText ; print paralysis text .burn ld a, 1 << BRN ld [wEnemyMonStatus], a call HalveAttackDueToBurn ; halve attack of affected mon ld a, ANIM_A9 - call PlayAnimation + call PlayBattleAnimatiom ld hl, BurnedText jp PrintText .freeze @@ -7397,7 +7397,7 @@ FreezeBurnParalyzeEffect: ; 3f30c (f:730c) ld a, 1 << FRZ ld [wEnemyMonStatus], a ld a, ANIM_A9 - call PlayAnimation + call PlayBattleAnimatiom ld hl, FrozenText jp PrintText opponentAttacker: ; 3f382 (f:7382) @@ -7744,7 +7744,7 @@ StatModifierDownEffect: ; 3f54c (f:754c) ld [hl], b ; save modified mod ld a, c cp $4 - jr nc, UpdateStatDone ; jump for evasion/accuracy + jr nc, UpdateStat2Done ; jump for evasion/accuracy push hl push de ld hl, wEnemyMonAttack + 1 @@ -7803,19 +7803,19 @@ StatModifierDownEffect: ; 3f54c (f:754c) ld b, a ld a, [$ff97] or b - jp nz, UpdateStat + jp nz, UpdateStat2 ld [$ff97], a ld a, $1 ld [$ff98], a -UpdateStat: ; 3f624 (f:7624) +UpdateStat2: ; 3f624 (f:7624) ld a, [$ff97] ld [hli], a ld a, [$ff98] ld [hl], a pop de pop hl -UpdateStatDone: ; 3f62c (f:762c) +UpdateStat2Done: ; 3f62c (f:762c) ld b, c inc b push de @@ -8057,7 +8057,7 @@ SwitchAndTeleportEffect: ; 3f739 (f:7739) jp Func_3fb4e .asm_3f7e4 push af - call PlayAnimation + call PlayBattleAnimatiom ld c, $14 call DelayFrames pop af @@ -8185,7 +8185,7 @@ ChargeEffect: ; 3f88c (f:788c) xor a ld [wcc5b], a ld a, b - call PlayAnimation + call PlayBattleAnimatiom ld a, [de] ld [wWhichTrade], a ld hl, ChargeMoveEffectText @@ -8660,7 +8660,7 @@ Func_3fba8: ; 3fba8 (f:7ba8) and a ret z -PlayAnimation: ; 3fbb9 (f:7bb9) +PlayBattleAnimatiom: ; 3fbb9 (f:7bb9) ld [W_ANIMATIONID], a Func_3fbbc: ; 3fbbc (f:7bbc) From 49a25618ea7316741b7838f111da311ba66a381c Mon Sep 17 00:00:00 2001 From: "U-Daniel-PC\\Daniel" Date: Thu, 22 Jan 2015 22:05:13 -0500 Subject: [PATCH 075/100] Clean up white space, fix label typo --- data/mapHeaders/beach_house.asm | 2 +- data/wildPokemon/viridianforest.asm | 2 +- engine/battle/core.asm | 112 +++++++++++----------- engine/overworld/hidden_items.asm | 2 +- home.asm | 2 +- scripts/celadonmartroof.asm | 2 +- scripts/ceruleanhouse1.asm | 2 +- scripts/ceruleanhousetrashed.asm | 2 +- scripts/lab2.asm | 2 +- scripts/lab4.asm | 4 +- scripts/route11gateupstairs.asm | 2 +- scripts/route18gateupstairs.asm | 2 +- scripts/route2house.asm | 2 +- scripts/undergroundpathentranceroute5.asm | 2 +- scripts/vermilioncity.asm | 4 +- scripts/vermilionhouse3.asm | 2 +- wram.asm | 2 +- 17 files changed, 74 insertions(+), 74 deletions(-) diff --git a/data/mapHeaders/beach_house.asm b/data/mapHeaders/beach_house.asm index 11579ef1e2..99d237f669 100644 --- a/data/mapHeaders/beach_house.asm +++ b/data/mapHeaders/beach_house.asm @@ -1,4 +1,4 @@ -BeachHouse_h: +BeachHouse_h: db BEACH_HOUSE_TILESET db BEACH_HOUSE_HEIGHT, BEACH_HOUSE_WIDTH ; dimensions (y, x) diff --git a/data/wildPokemon/viridianforest.asm b/data/wildPokemon/viridianforest.asm index bac991c5ed..f6e00ac343 100755 --- a/data/wildPokemon/viridianforest.asm +++ b/data/wildPokemon/viridianforest.asm @@ -33,7 +33,7 @@ ForestMons: db 4,KAKUNA db 3,WEEDLE ENDC - + db 3,PIKACHU db 5,PIKACHU ENDC diff --git a/engine/battle/core.asm b/engine/battle/core.asm index cfcfa9db33..25471ea53d 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -71,7 +71,7 @@ AlwaysHappenSideEffects: ; 3c030 (f:4030) db -1 SpecialEffects: ; 3c03b (f:403b) ; Effects from arrays 2, 4, and 5B, minus Twineedle and Rage. -; Includes all effects that do not need to be called at the end of +; Includes all effects that do not need to be called at the end of ; ExecutePlayerMove (or ExecuteEnemyMove), because they have already been handled db DRAIN_HP_EFFECT db EXPLODE_EFFECT @@ -512,7 +512,7 @@ MainInBattleLoop: ; 3c233 (f:4233) ret nz ; if so, return ld a, b and a - jp z, HandlePlayerMonFainted + jp z, HandlePlayerMonFainted .AIActionUsedEnemyFirst call HandlePoisonBurnLeechSeed jp z, HandleEnemyMonFainted @@ -1595,7 +1595,7 @@ TryRunningFromBattle: ; 3cab9 (f:4ab9) call StringCmp jr nc, .canEscape ; jump if player speed greater than enemy speed xor a - ld [H_MULTIPLICAND], a + ld [H_MULTIPLICAND], a ld a, 32 ld [H_MULTIPLIER], a call Multiply ; multiply player speed by 32 @@ -1914,7 +1914,7 @@ DrawPlayerHUDAndHPBar: ; 3cd60 (f:4d60) ld a, [wcf98] ld [wcf91], a hlCoord 10, 9 - predef DrawHP + predef DrawHP ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a ld hl, wcf1d @@ -3160,19 +3160,19 @@ PlayerCanExecuteMove: ; 3d6b0 (f:56b0) ld hl,ResidualEffects1 ld de,1 call IsInArray - jp c,JumpMoveEffect ; ResidualEffects1 moves skip damage calculation and accuracy tests - ; unless executed as part of their exclusive effect functions + jp c,JumpMoveEffect ; ResidualEffects1 moves skip damage calculation and accuracy tests + ; unless executed as part of their exclusive effect functions ld a,[W_PLAYERMOVEEFFECT] ld hl,SpecialEffectsCont ld de,1 call IsInArray - call c,JumpMoveEffect ; execute the effects of SpecialEffectsCont moves (e.g. Wrap, Thrash) but don't skip anything + call c,JumpMoveEffect ; execute the effects of SpecialEffectsCont moves (e.g. Wrap, Thrash) but don't skip anything CalcMoveDamage: ; 3d6dc (f:56dc) ld a,[W_PLAYERMOVEEFFECT] ld hl,SetDamageEffects ld de,1 - call IsInArray - jp c,.moveHitTest ; SetDamageEffects moves (e.g. Seismic Toss and Super Fang) skip damage calculation + call IsInArray + jp c,.moveHitTest ; SetDamageEffects moves (e.g. Seismic Toss and Super Fang) skip damage calculation call CriticalHitTest call HandleCounterMove jr z,asm_3d705 @@ -3191,14 +3191,14 @@ asm_3d705 ld a,[W_PLAYERMOVEEFFECT] sub a,7 ; Explosion effect jr z,asm_3d71e ; don't play any animation if the move missed, unless it was EXPLODE_EFFECT - jr asm_3d74b + jr asm_3d74b asm_3d714 ld a,[W_PLAYERMOVEEFFECT] and a ld a,4 jr z,asm_3d71e ld a,5 -asm_3d71e +asm_3d71e push af ld a,[W_PLAYERBATTSTATUS2] bit 4,a @@ -3258,7 +3258,7 @@ MirrorMoveCheck ld a,[W_PLAYERMOVEEFFECT] cp a,EXPLODE_EFFECT ; even if Explosion or Selfdestruct missed, its effect still needs to be activated jr z,.notDone - jp ExecutePlayerMoveDone ; otherwise, we're done if the move missed + jp ExecutePlayerMoveDone ; otherwise, we're done if the move missed .moveDidNotMiss call ApplyAttackToEnemyPokemon call PrintCriticalOHKOText @@ -3284,13 +3284,13 @@ MirrorMoveCheck ld a,[wPlayerNumAttacksLeft] dec a ld [wPlayerNumAttacksLeft],a - jp nz,asm_3d714 ; for multi-hit moves, apply attack until PlayerNumAttacksLeft hits 0 or the enemy faints. + jp nz,asm_3d714 ; for multi-hit moves, apply attack until PlayerNumAttacksLeft hits 0 or the enemy faints. ; damage calculation and accuracy tests only happen for the first hit res 2,[hl] ld hl,MultiHitText call PrintText xor a - ld [W_NUMHITS],a + ld [W_NUMHITS],a .executeOtherEffects ld a,[W_PLAYERMOVEEFFECT] and a @@ -3573,7 +3573,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) ld hl,wPlayerNumAttacksLeft dec [hl] ; did Trashing About counter hit 0? ld hl,CalcMoveDamage ; skip DecrementPP - jp nz,.returnToHL + jp nz,.returnToHL push hl ld hl,W_PLAYERBATTSTATUS1 res 1,[hl] ; no longer trashing about @@ -4212,7 +4212,7 @@ GetDamageVarsForPlayerAttack: ; 3ddcf (f:5dcf) jr z, .physicalAttackCritCheck ; if the enemy has used Reflect, double the enemy's defense sla c - rl b + rl b .physicalAttackCritCheck ld hl, wBattleMonAttack ld a, [wCriticalHitOrOHKO] @@ -4244,7 +4244,7 @@ GetDamageVarsForPlayerAttack: ; 3ddcf (f:5dcf) sla c rl b ; reflect and light screen boosts do not cap the stat at 999, so weird things will happen during stats scaling if -; a Pokemon with 512 or more Defense has ued Reflect, or if a Pokemon with 512 or more Special has used Light Screen +; a Pokemon with 512 or more Defense has ued Reflect, or if a Pokemon with 512 or more Special has used Light Screen .specialAttackCritCheck ld hl, wBattleMonSpecial ld a, [wCriticalHitOrOHKO] @@ -4277,7 +4277,7 @@ GetDamageVarsForPlayerAttack: ; 3ddcf (f:5dcf) rr c srl b rr c -; defensive stat can actually end up as 0, leading to a division by 0 freeze during damage calculation +; defensive stat can actually end up as 0, leading to a division by 0 freeze during damage calculation ; hl /= 4 (scale player's offensive stat) srl h rr l @@ -4356,7 +4356,7 @@ GetDamageVarsForEnemyAttack: ; 3de75 (f:5e75) sla c rl b ; reflect and light screen boosts do not cap the stat at 999, so weird things will happen during stats scaling if -; a Pokemon with 512 or more Defense has ued Reflect, or if a Pokemon with 512 or more Special has used Light Screen +; a Pokemon with 512 or more Defense has ued Reflect, or if a Pokemon with 512 or more Special has used Light Screen .specialAttackCritCheck ld hl, wEnemyMonSpecial ld a, [wCriticalHitOrOHKO] @@ -4389,7 +4389,7 @@ GetDamageVarsForEnemyAttack: ; 3de75 (f:5e75) rr c srl b rr c -; defensive stat can actually end up as 0, leading to a division by 0 freeze during damage calculation +; defensive stat can actually end up as 0, leading to a division by 0 freeze during damage calculation ; hl /= 4 (scale enemy's offensive stat) srl h rr l @@ -4611,7 +4611,7 @@ CalculateDamage: ; 3df65 (f:5f65) ld [hld], a jr nc, .done inc [hl] - + .done ; minimum damage is 1 ld a, 1 @@ -4713,9 +4713,9 @@ HighCriticalMoves: ; 3e08e (f:608e) ; function to determine if Counter hits and if so, how much damage it does HandleCounterMove: ; 3e093 (f:6093) -; The variables checked by Counter are updated whenever the cursor points to a new move in the battle selection menu. -; This is irrelevant for the opponent's side outside of link battles, since the move selection is controlled by the AI. -; However, in the scenario where the player switches out and the opponent uses Counter, +; The variables checked by Counter are updated whenever the cursor points to a new move in the battle selection menu. +; This is irrelevant for the opponent's side outside of link battles, since the move selection is controlled by the AI. +; However, in the scenario where the player switches out and the opponent uses Counter, ; the outcome may be affected by the player's actions in the move selection menu prior to switching the Pokemon. ; This might also lead to desync glitches in link battles. @@ -4756,7 +4756,7 @@ HandleCounterMove: ; 3e093 (f:6093) ld a,[hli] or [hl] ret z ; If we made it here, Counter still misses if the last move used in battle did no damage to its target. - ; W_DAMAGE is shared by both players, so Counter may strike back damage dealt by the Counter user itself + ; W_DAMAGE is shared by both players, so Counter may strike back damage dealt by the Counter user itself ; if the conditions meet, even though 99% of the times damage will come from the target. ; if it did damage, double it ld a,[hl] @@ -4812,7 +4812,7 @@ ApplyAttackToEnemyPokemon: ; 3e0df (f:60df) ld a,[hl] ld b,a ; Seismic Toss deals damage equal to the user's level ld a,[W_PLAYERMOVENUM] - cp a,SEISMIC_TOSS + cp a,SEISMIC_TOSS jr z,.storeDamage cp a,NIGHT_SHADE jr z,.storeDamage @@ -6747,11 +6747,11 @@ BattleRandom: HandleExplodingAnimation: ; 3eed3 (f:6ed3) ld a, [H_WHOSETURN] and a - ld hl, wEnemyMonType1 ; wcfea + ld hl, wEnemyMonType1 ; wcfea ld de, W_ENEMYBATTSTATUS1 ld a, [W_PLAYERMOVENUM] jr z, .asm_3eeea - ld hl, wBattleMonType1 ; wd019 + ld hl, wBattleMonType1 ; wd019 ld de, W_ENEMYBATTSTATUS1 ld a, [W_ENEMYMOVENUM] .asm_3eeea @@ -7206,7 +7206,7 @@ SleepEffect: ; 3f1fc (f:71fc) .setSleepCounter ; set target's sleep counter to a random number between 1 and 7 call BattleRandom - and $7 + and $7 jr z, .setSleepCounter ld [de], a call Func_3fb89 @@ -7261,7 +7261,7 @@ PoisonEffect: ; 3f24f (f:724f) jr nz, .didntAffect jr .inflictPoison .sideEffectTest - call BattleRandom + call BattleRandom cp b ; was side effect successful? ret nc .inflictPoison @@ -7346,7 +7346,7 @@ FreezeBurnParalyzeEffect: ; 3f30c (f:730c) ld [wcc5b], a call CheckTargetSubstitute ; test bit 4 of d063/d068 flags [target has substitute flag] ret nz ; return if they have a substitute, can't effect them - ld a, [$fff3] + ld a, [$fff3] and a jp nz, opponentAttacker ld a, [wEnemyMonStatus] @@ -7367,29 +7367,29 @@ FreezeBurnParalyzeEffect: ; 3f30c (f:730c) ld b, $4d ; else use 0x4D/0x100 or 77/256 = 30.1%~ chance sub a, $1e ; subtract $1E to map to equivalent 10% chance effects .next1 - push af + push af call BattleRandom ; get random 8bit value for probability test cp b - pop bc + pop bc ret nc ; do nothing if random value is >= 1A or 4D [no status applied] ld a, b ; what type of effect is this? cp a, BURN_SIDE_EFFECT1 jr z, .burn cp a, FREEZE_SIDE_EFFECT jr z, .freeze -; .paralyze +; .paralyze ld a, 1 << PAR ld [wEnemyMonStatus], a call QuarterSpeedDueToParalysis ; quarter speed of affected mon ld a, ANIM_A9 - call PlayBattleAnimatiom + call PlayBattleAnimation jp PrintMayNotAttackText ; print paralysis text .burn ld a, 1 << BRN ld [wEnemyMonStatus], a call HalveAttackDueToBurn ; halve attack of affected mon ld a, ANIM_A9 - call PlayBattleAnimatiom + call PlayBattleAnimation ld hl, BurnedText jp PrintText .freeze @@ -7397,7 +7397,7 @@ FreezeBurnParalyzeEffect: ; 3f30c (f:730c) ld a, 1 << FRZ ld [wEnemyMonStatus], a ld a, ANIM_A9 - call PlayBattleAnimatiom + call PlayBattleAnimation ld hl, FrozenText jp PrintText opponentAttacker: ; 3f382 (f:7382) @@ -7458,7 +7458,7 @@ CheckDefrost: ; 3f3e2 (f:73e2) ; any fire-type move that has a chance inflict burn (all but Fire Spin) will defrost a frozen target and a, 1 << FRZ ; are they frozen? ret z ; return if so - ld a, [$fff3] + ld a, [$fff3] and a jr nz, .opponent ;player [attacker] @@ -7503,7 +7503,7 @@ StatModifierUpEffect: ; 3f428 (f:7428) ld de, W_ENEMYMOVEEFFECT .statModifierUpEffect ld a, [de] - sub ATTACK_UP1_EFFECT + sub ATTACK_UP1_EFFECT cp $8 jr c, .incrementStatMod sub ATTACK_UP2_EFFECT - ATTACK_UP1_EFFECT ; map +2 effects to equivalent +1 effect @@ -7581,7 +7581,7 @@ StatModifierUpEffect: ; 3f428 (f:7428) ld b, $4 call Divide pop hl -; cap at 999 +; cap at 999 ld a, [$ff98] sub $e7 ld a, [$ff97] @@ -7643,7 +7643,7 @@ UpdateStatDone: ; 3f4ca (f:74ca) ld hl, MonsStatsRoseText call PrintText -; these shouldn't be here +; these shouldn't be here call QuarterSpeedDueToParalysis ; apply speed penalty to the player whose turn is not, if it's paralyzed jp HalveAttackDueToBurn ; apply attack penalty to the player whose turn is not, if it's burned @@ -7721,7 +7721,7 @@ StatModifierDownEffect: ; 3f54c (f:754c) bit 6, a ; fly/dig jp nz, MoveMissed ld a, [de] - sub ATTACK_DOWN1_EFFECT + sub ATTACK_DOWN1_EFFECT cp $8 jr c, .decrementStatMod sub ATTACK_DOWN2_EFFECT - ATTACK_DOWN1_EFFECT ; map +2 effects to corresponding +1 effect @@ -7741,9 +7741,9 @@ StatModifierDownEffect: ; 3f54c (f:754c) jr nz, .ok inc b ; increment mod to 1 (-6) if it would become 0 (-7) .ok - ld [hl], b ; save modified mod + ld [hl], b ; save modified mod ld a, c - cp $4 + cp $4 jr nc, UpdateStat2Done ; jump for evasion/accuracy push hl push de @@ -7832,10 +7832,10 @@ UpdateStat2Done: ; 3f62c (f:762c) ; even to those not affected by the stat-up move (will be boosted further) ld hl, MonsStatsFellText call PrintText - -; These where probably added given that a stat-down move affecting speed or attack will override + +; These where probably added given that a stat-down move affecting speed or attack will override ; the stat penalties from paralysis and burn respectively. -; But they are always called regardless of the stat affected by the stat-down move. +; But they are always called regardless of the stat affected by the stat-down move. call QuarterSpeedDueToParalysis jp HalveAttackDueToBurn @@ -7960,7 +7960,7 @@ ThrashPetalDanceEffect: ; 3f717 (f:7717) .thrashPetalDanceEffect set 1, [hl] ; mon is now using thrash/petal dance call BattleRandom - and $1 + and $1 inc a inc a ld [de], a ; set thrash/petal dance counter to 2 or 3 at random @@ -8057,7 +8057,7 @@ SwitchAndTeleportEffect: ; 3f739 (f:7739) jp Func_3fb4e .asm_3f7e4 push af - call PlayBattleAnimatiom + call PlayBattleAnimation ld c, $14 call DelayFrames pop af @@ -8109,14 +8109,14 @@ TwoToFiveAttacksEffect: ; 3f811 (f:7811) cp ATTACK_TWICE_EFFECT ld a, $2 ; number of hits it's always 2 for ATTACK_TWICE_EFFECT jr z, .saveNumberOfHits -; for TWO_TO_FIVE_ATTACKS_EFFECT 3/8 chance for 2 and 3 hits, and 1/8 chance for 4 and 5 hits +; for TWO_TO_FIVE_ATTACKS_EFFECT 3/8 chance for 2 and 3 hits, and 1/8 chance for 4 and 5 hits call BattleRandom - and $3 - cp $2 - jr c, .asm_3f851 + and $3 + cp $2 + jr c, .asm_3f851 call BattleRandom and $3 -.asm_3f851 +.asm_3f851 inc a inc a .saveNumberOfHits @@ -8185,7 +8185,7 @@ ChargeEffect: ; 3f88c (f:788c) xor a ld [wcc5b], a ld a, b - call PlayBattleAnimatiom + call PlayBattleAnimation ld a, [de] ld [wWhichTrade], a ld hl, ChargeMoveEffectText @@ -8660,7 +8660,7 @@ Func_3fba8: ; 3fba8 (f:7ba8) and a ret z -PlayBattleAnimatiom: ; 3fbb9 (f:7bb9) +PlayBattleAnimation: ; 3fbb9 (f:7bb9) ld [W_ANIMATIONID], a Func_3fbbc: ; 3fbbc (f:7bbc) diff --git a/engine/overworld/hidden_items.asm b/engine/overworld/hidden_items.asm index befe293574..17288a1754 100755 --- a/engine/overworld/hidden_items.asm +++ b/engine/overworld/hidden_items.asm @@ -53,7 +53,7 @@ HiddenItemBagFullText: ; 76794 (1d:6794) HiddenCoins: ; 76799 (1d:6799) ld b, COIN_CASE - predef IsItemInBag_ + predef IsItemInBag_ ld a, b and a ret z diff --git a/home.asm b/home.asm index a4882007d5..133eb83bab 100644 --- a/home.asm +++ b/home.asm @@ -2712,7 +2712,7 @@ IsItemInBag:: ; 3493 (0:3493) ; set zero flag if item isn't in player's bag ; else reset zero flag ; related to Pokémon Tower and ghosts - predef IsItemInBag_ + predef IsItemInBag_ ld a,b and a ret diff --git a/scripts/celadonmartroof.asm b/scripts/celadonmartroof.asm index fa34b8cd2f..d4bb431981 100755 --- a/scripts/celadonmartroof.asm +++ b/scripts/celadonmartroof.asm @@ -14,7 +14,7 @@ CeladonMartRoofScript_483d8: ; 483d8 (12:43d8) push de ld [wd11e], a ld b, a - predef IsItemInBag_ + predef IsItemInBag_ pop de pop hl ld a, b diff --git a/scripts/ceruleanhouse1.asm b/scripts/ceruleanhouse1.asm index 27a91ab596..ffc8656eb2 100755 --- a/scripts/ceruleanhouse1.asm +++ b/scripts/ceruleanhouse1.asm @@ -13,5 +13,5 @@ CeruleanHouse1Text2: ; 1d702 (7:5702) db $08 ; asm ld a, $6 ld [wWhichTrade], a - predef Predef54 + predef Predef54 jp TextScriptEnd diff --git a/scripts/ceruleanhousetrashed.asm b/scripts/ceruleanhousetrashed.asm index 02b40dcb2d..ee60cda73c 100755 --- a/scripts/ceruleanhousetrashed.asm +++ b/scripts/ceruleanhousetrashed.asm @@ -10,7 +10,7 @@ CeruleanHouseTrashedTextPointers: ; 1d689 (7:5689) CeruleanHouseTrashedText1: ; 1d68f (7:568f) db $08 ; asm ld b, $e4 - predef IsItemInBag_ + predef IsItemInBag_ and b jr z, .asm_f8734 ; 0x1d698 ld hl, CeruleanHouseTrashedText_1d6b0 diff --git a/scripts/lab2.asm b/scripts/lab2.asm index 4075f73797..583ef4e454 100755 --- a/scripts/lab2.asm +++ b/scripts/lab2.asm @@ -21,5 +21,5 @@ Lab2Text3: ; 75c37 (1d:5c37) ld a, $8 ld [wWhichTrade], a asm_78552: ; 75c3d (1d:5c3d) - predef Predef54 + predef Predef54 jp TextScriptEnd diff --git a/scripts/lab4.asm b/scripts/lab4.asm index c2d8d3048e..924a6637b2 100755 --- a/scripts/lab4.asm +++ b/scripts/lab4.asm @@ -20,7 +20,7 @@ Lab4Script_75d38: ; 75d38 (1d:5d38) push de ld [wd11e], a ld b, a - predef IsItemInBag_ + predef IsItemInBag_ pop de pop hl ld a, b @@ -108,7 +108,7 @@ Lab4Text2: ; 75dda (1d:5dda) db $08 ; asm ld a, $3 ld [wWhichTrade], a - predef Predef54 + predef Predef54 jp TextScriptEnd LoadFossilItemAndMonNameBank1D: ; 75de8 (1d:5de8) diff --git a/scripts/route11gateupstairs.asm b/scripts/route11gateupstairs.asm index 5c0cc574e0..8b75668145 100755 --- a/scripts/route11gateupstairs.asm +++ b/scripts/route11gateupstairs.asm @@ -11,7 +11,7 @@ Route11GateUpstairsText1: ; 4945f (12:545f) db $08 ; asm xor a ld [wWhichTrade], a - predef Predef54 + predef Predef54 asm_49469: ; 49469 (12:5469) jp TextScriptEnd diff --git a/scripts/route18gateupstairs.asm b/scripts/route18gateupstairs.asm index 9db16aeb72..7ef0461dd0 100755 --- a/scripts/route18gateupstairs.asm +++ b/scripts/route18gateupstairs.asm @@ -10,7 +10,7 @@ Route18GateUpstairsText1: ; 4997e (12:597e) db $08 ; asm ld a, $5 ld [wWhichTrade], a - predef Predef54 + predef Predef54 jp TextScriptEnd Route18GateUpstairsText2: ; 4998c (12:598c) diff --git a/scripts/route2house.asm b/scripts/route2house.asm index 75da399b65..e9b30b0712 100755 --- a/scripts/route2house.asm +++ b/scripts/route2house.asm @@ -13,5 +13,5 @@ Route2HouseText2: ; 1def9 (7:5ef9) db $08 ; asm ld a, $1 ld [wWhichTrade], a - predef Predef54 + predef Predef54 jp TextScriptEnd diff --git a/scripts/undergroundpathentranceroute5.asm b/scripts/undergroundpathentranceroute5.asm index 1fb62f4881..dc1748f2a7 100755 --- a/scripts/undergroundpathentranceroute5.asm +++ b/scripts/undergroundpathentranceroute5.asm @@ -13,6 +13,6 @@ UndergroundPathEntranceRoute5Text1: ; 5d6b2 (17:56b2) db $08 ; asm ld a, $9 ld [wWhichTrade], a - predef Predef54 + predef Predef54 ld hl, UndergroundPathEntranceRoute5_5d6af ret diff --git a/scripts/vermilioncity.asm b/scripts/vermilioncity.asm index 5309c7f6be..1214b27c31 100755 --- a/scripts/vermilioncity.asm +++ b/scripts/vermilioncity.asm @@ -55,7 +55,7 @@ VermilionCityScript0: ; 197e6 (6:57e6) bit 2, a jr nz, .asm_19810 ; 0x19804 $a ld b, $3f - predef IsItemInBag_ + predef IsItemInBag_ ld a, b and a ret nz @@ -175,7 +175,7 @@ VermilionCityText3: ; 198b1 (6:58b1) ld hl, SSAnneWelcomeText9 call PrintText ld b, S_S__TICKET - predef IsItemInBag_ + predef IsItemInBag_ ld a, b and a jr nz, .asm_0419b ; 0x198df diff --git a/scripts/vermilionhouse3.asm b/scripts/vermilionhouse3.asm index 7b4e95fdcf..af9d2430bd 100755 --- a/scripts/vermilionhouse3.asm +++ b/scripts/vermilionhouse3.asm @@ -8,5 +8,5 @@ VermilionHouse3Text1: ; 19c17 (6:5c17) db $08 ; asm ld a, $4 ld [wWhichTrade], a - predef Predef54 + predef Predef54 jp TextScriptEnd diff --git a/wram.asm b/wram.asm index 86d1015281..f0e06a0e92 100755 --- a/wram.asm +++ b/wram.asm @@ -393,7 +393,7 @@ wccf7:: ds 14 wcd05:: ds 1 wcd06:: ds 9 -wPlayerMonUnmodifiedLevel:: ; cd0f +wPlayerMonUnmodifiedLevel:: ; cd0f ds 0 wcd0f:: ; overload, used in in-game trade code ds 1 From 00bafbec659ff03fdb5cf0897f4be0df0261c1cf Mon Sep 17 00:00:00 2001 From: "U-Daniel-PC\\Daniel" Date: Sat, 24 Jan 2015 09:14:23 -0500 Subject: [PATCH 076/100] Update INSTALL.md --- INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index e440ef330f..124e9408f9 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -57,7 +57,7 @@ Select the following packages: * python * python-setuptools -The latest version of **rgbds** is [**0.2.0**](https://github.com/bentley/rgbds/releases/download/v0.2.0/rgbds-0.2.0-win32.zip). To install, put `rgbasm.exe`, `rgblink.exe` and `rgbfix.exe` in `C:\cygwin\usr\local\bin`. +The latest version of **rgbds** is [**0.2.2**](https://github.com/bentley/rgbds/releases/download/v0.2.2/rgbds-0.2.2-win32.zip). To install, put `rgbasm.exe`, `rgblink.exe` and `rgbfix.exe` in `C:\cygwin\usr\local\bin`. Then set up the repository. In the **Cygwin terminal**: From b3324b175e58ce9a8e2f49d1df64ec71f02e9605 Mon Sep 17 00:00:00 2001 From: "U-Daniel-PC\\Daniel" Date: Sat, 24 Jan 2015 09:15:09 -0500 Subject: [PATCH 077/100] Don't ignore .map files it makes it confusing to edit/move the tilemaps in gfx/ --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index dd1b5a9d20..e2a884db38 100644 --- a/.gitignore +++ b/.gitignore @@ -12,7 +12,6 @@ *.gb # rgbds extras -*.map *.sym # converted image data From 3cf945bad4fdf40c528147a8d1fd9c5565425232 Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Sat, 24 Jan 2015 12:41:20 -0800 Subject: [PATCH 078/100] Better documenting for GetMachinePrice and TechnicalMachinePrices. --- data/tm_prices.asm | 30 +++++++++++++++++++++++++----- engine/items/tm_prices.asm | 11 +++++++---- home.asm | 8 +++++--- 3 files changed, 37 insertions(+), 12 deletions(-) diff --git a/data/tm_prices.asm b/data/tm_prices.asm index 4fce3f6080..89fdb8e929 100755 --- a/data/tm_prices.asm +++ b/data/tm_prices.asm @@ -1,7 +1,27 @@ TechnicalMachinePrices: ; 7bfa7 (1e:7fa7) ; In thousands (nybbles). - db $32, $21, $34, $24, $34 - db $21, $45, $55, $32, $32 - db $55, $52, $54, $52, $41 - db $21, $12, $42, $25, $24 - db $22, $52, $24, $34, $42 + dn 3, 2 ; TM_01, TM_02 + dn 2, 1 ; TM_03, TM_04 + dn 3, 4 ; TM_05, TM_06 + dn 2, 4 ; TM_07, TM_08 + dn 3, 4 ; TM_09, TM_10 + dn 2, 1 ; TM_11, TM_12 + dn 4, 5 ; TM_13, TM_14 + dn 5, 5 ; TM_15, TM_16 + dn 3, 2 ; TM_17, TM_18 + dn 3, 2 ; TM_19, TM_20 + dn 5, 5 ; TM_21, TM_22 + dn 5, 2 ; TM_23, TM_24 + dn 5, 4 ; TM_25, TM_26 + dn 5, 2 ; TM_27, TM_28 + dn 4, 1 ; TM_29, TM_30 + dn 2, 1 ; TM_31, TM_32 + dn 1, 2 ; TM_33, TM_34 + dn 4, 2 ; TM_35, TM_36 + dn 2, 5 ; TM_37, TM_38 + dn 2, 4 ; TM_39, TM_40 + dn 2, 2 ; TM_41, TM_42 + dn 5, 2 ; TM_43, TM_44 + dn 2, 4 ; TM_45, TM_46 + dn 3, 4 ; TM_47, TM_48 + dn 4, 2 ; TM_49, TM_50 diff --git a/engine/items/tm_prices.asm b/engine/items/tm_prices.asm index c55a25b4ce..7c5c56fa49 100755 --- a/engine/items/tm_prices.asm +++ b/engine/items/tm_prices.asm @@ -1,5 +1,8 @@ GetMachinePrice: ; 7bf86 (1e:7f86) - ld a, [wcf91] +; Input: [wcf91] = Item Id of a TM +; Output: Stores the 2-byte TM price in [H_DOWNARROWBLINKCNT1] and [H_DOWNARROWBLINKCNT2] +; as a BCD + ld a, [wcf91] ; a contains TM item id sub TM_01 ret c ld d, a @@ -8,11 +11,11 @@ GetMachinePrice: ; 7bf86 (1e:7f86) ld c, a ld b, 0 add hl, bc - ld a, [hl] + ld a, [hl] ; a contains byte whose high or low nybble is the TM price (in thousands) srl d - jr nc, .asm_7bf9d + jr nc, .highNybbleIsPrice ; is TM id odd? swap a -.asm_7bf9d +.highNybbleIsPrice and $f0 ld [H_DOWNARROWBLINKCNT2], a ; $ff8c xor a diff --git a/home.asm b/home.asm index 133eb83bab..3f6cbd3419 100644 --- a/home.asm +++ b/home.asm @@ -3335,6 +3335,8 @@ GetName:: ; 376b (0:376b) ret GetItemPrice:: ; 37df (0:37df) +; Stores item's price as BCD in [H_DOWNARROWBLINKCNT1] and [[H_DOWNARROWBLINKCNT2] +; Input: [wcf91] = item id ld a, [H_LOADEDROMBANK] push af ld a, [wListMenuID] ; wListMenuID @@ -3349,9 +3351,9 @@ GetItemPrice:: ; 37df (0:37df) ld a, [hli] ld h, [hl] ld l, a - ld a, [wcf91] + ld a, [wcf91] ; a contains item id cp HM_01 - jr nc, .asm_3812 + jr nc, .getTMPrice ld bc, $3 .asm_3802 add hl, bc @@ -3365,7 +3367,7 @@ GetItemPrice:: ; 37df (0:37df) ld a, [hl] ld [H_DOWNARROWBLINKCNT1], a ; $ff8b jr .asm_381c -.asm_3812 +.getTMPrice ld a, Bank(GetMachinePrice) ld [H_LOADEDROMBANK], a ld [$2000], a From 95f4f7b41fbb45f6e8efb42b19a5535e52c1dbb7 Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Sat, 24 Jan 2015 12:52:11 -0800 Subject: [PATCH 079/100] Clean up prizes data. --- data/prizes.asm | 25 ++++++++++++++----------- engine/menu/prize_menu.asm | 2 +- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/data/prizes.asm b/data/prizes.asm index 92736715da..c88767d64e 100755 --- a/data/prizes.asm +++ b/data/prizes.asm @@ -21,16 +21,17 @@ IF DEF(_BLUE) db NIDORINO ENDC db "@" + PrizeMenuMon1Cost: ; 5285d (14:685d) IF DEF(_RED) - db $01,$80 - db $05,$00 + db $01,$80 ; 180 Coins + db $05,$00 ; 500 Coins ENDC IF DEF(_BLUE) - db $01,$20 - db $07,$50 + db $01,$20 ; 120 Coins + db $07,$50 ; 750 Coins ENDC - db $12,$00 + db $12,$00 ; 1200 Coins db "@" PrizeMenuMon2Entries: ; 52864 (14:6864) @@ -44,16 +45,17 @@ IF DEF(_BLUE) ENDC db PORYGON db "@" + PrizeMenuMon2Cost: ; 52868 (14:6868) IF DEF(_RED) - db $28,$00 - db $55,$00 - db $99,$99 + db $28,$00 ; 2800 Coins + db $55,$00 ; 5500 Coins + db $99,$99 ; 9999 Coins ENDC IF DEF(_BLUE) - db $25,$00 - db $46,$00 - db $65,$00 + db $25,$00 ; 2500 Coins + db $46,$00 ; 4600 Coins + db $65,$00 ; 6500 Coins ENDC db "@" @@ -62,6 +64,7 @@ PrizeMenuTMsEntries: ; 5286f (14:686f) db TM_15 db TM_50 db "@" + PrizeMenuTMsCost: ; 52873 (14:6873) db $33,$00 ; 3300 Coins db $55,$00 ; 5500 Coins diff --git a/engine/menu/prize_menu.asm b/engine/menu/prize_menu.asm index 141b9bebdf..0e90420051 100755 --- a/engine/menu/prize_menu.asm +++ b/engine/menu/prize_menu.asm @@ -6,7 +6,7 @@ CeladonPrizeMenu: ; 5271b (14:671b) jp PrintText .havingCoinCase ld hl,wd730 - set 6,[hl] + set 6,[hl] ; disable letter-printing delay ld hl,ExchangeCoinsForPrizesTextPtr call PrintText ; the following are the menu settings From 8744b3bf8b4f49741041f11ee60c70f2bcc76813 Mon Sep 17 00:00:00 2001 From: "U-Daniel-PC\\Daniel" Date: Tue, 27 Jan 2015 01:29:10 -0500 Subject: [PATCH 080/100] Fix some sfx ids --- engine/overworld/player_animations.asm | 2 +- home/text.asm | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/engine/overworld/player_animations.asm b/engine/overworld/player_animations.asm index 473b0d5ada..be3d79e413 100755 --- a/engine/overworld/player_animations.asm +++ b/engine/overworld/player_animations.asm @@ -133,7 +133,7 @@ _LeaveMapAnim: ; 705ba (1c:45ba) ld [hli], a ; wPlayerSpinInPlaceAnimFrameDelayDelta xor a ld [hli], a ; wPlayerSpinInPlaceAnimFrameDelayEndValue - ld [hl], $a1 ; wPlayerSpinInPlaceAnimSoundID + ld [hl], (SFX_02_4d - SFX_Headers_02) / 3 ; wPlayerSpinInPlaceAnimSoundID ld hl, wcd48 call PlayerSpinInPlace jr .spinWhileMovingUp diff --git a/home/text.asm b/home/text.asm index abcac9fd91..aed89c3381 100644 --- a/home/text.asm +++ b/home/text.asm @@ -627,12 +627,12 @@ TextCommand0B:: ; 1c31 (0:1c31) ; format: text command ID, sound ID or cry ID TextCommandSounds:: ; 1c64 (0:1c64) db $0B,(SFX_02_3a - SFX_Headers_02) / 3 - db $12,(SFX_02_46 - SFX_Headers_02) / 3 + db $12,(SFX_08_46 - SFX_Headers_08) / 3 db $0E,(SFX_02_41 - SFX_Headers_02) / 3 db $0F,(SFX_02_3a - SFX_Headers_02) / 3 db $10,(SFX_02_3b - SFX_Headers_02) / 3 db $11,(SFX_02_42 - SFX_Headers_02) / 3 - db $13,(SFX_02_44 - SFX_Headers_02) / 3 + db $13,(SFX_08_45 - SFX_Headers_08) / 3 db $14,NIDORINA ; used in OakSpeech db $15,PIDGEOT ; used in SaffronCityText12 db $16,DEWGONG ; unused? From a53b3ca5614855ab9be5991230a73f1f3d6cc442 Mon Sep 17 00:00:00 2001 From: "U-Daniel-PC\\Daniel" Date: Tue, 27 Jan 2015 03:27:34 -0500 Subject: [PATCH 081/100] More battle sfx ids --- engine/battle/animations.asm | 332 +++++++++++++++++------------------ 1 file changed, 166 insertions(+), 166 deletions(-) diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm index 9c15a98dc1..d84edeb896 100755 --- a/engine/battle/animations.asm +++ b/engine/battle/animations.asm @@ -2318,172 +2318,172 @@ IsCryMove: ; 798ad (1e:58ad) ret MoveSoundTable: ; 798bc (1e:58bc) - db $a0,$00,$80 - db $a2,$10,$80 - db $b3,$00,$80 - db $a1,$01,$80 - db $a3,$00,$40 - db $e9,$00,$ff - db $a3,$10,$60 - db $a3,$20,$80 - db $a3,$00,$a0 - db $a6,$00,$80 - db $a5,$20,$40 - db $a5,$00,$80 - db $a4,$00,$a0 - db $a7,$10,$c0 - db $a7,$00,$a0 - db $a8,$00,$c0 - db $a8,$10,$a0 - db $a9,$00,$e0 - db $a7,$20,$c0 - db $aa,$00,$80 - db $b9,$00,$80 - db $ab,$01,$80 - db $b7,$00,$80 - db $ad,$f0,$40 - db $b0,$00,$80 - db $ad,$00,$80 - db $b8,$10,$80 - db $b1,$01,$a0 - db $ae,$00,$80 - db $b4,$00,$60 - db $b4,$01,$40 - db $b6,$00,$a0 - db $b0,$10,$a0 - db $b7,$00,$c0 - db $aa,$10,$60 - db $b0,$00,$a0 - db $b9,$11,$c0 - db $b0,$20,$c0 - db $b8,$00,$80 - db $b1,$00,$80 - db $b1,$20,$c0 - db $af,$00,$80 - db $db,$ff,$40 - db $b4,$00,$80 - db $a1,$00,$c0 - db $a1,$00,$40 - db $e4,$00,$80 - db $bf,$40,$60 - db $bf,$00,$80 - db $bf,$ff,$40 - db $c7,$80,$c0 - db $af,$10,$a0 - db $af,$21,$e0 - db $c5,$00,$80 - db $bb,$20,$60 - db $c7,$00,$80 - db $cc,$00,$80 - db $c2,$40,$80 - db $c5,$f0,$e0 - db $cf,$00,$80 - db $c7,$f0,$60 - db $c2,$00,$80 - db $e6,$00,$80 - db $9d,$01,$a0 - db $a9,$f0,$20 - db $ba,$01,$c0 - db $ba,$00,$80 - db $b0,$00,$e0 - db $be,$01,$60 - db $be,$20,$40 - db $bb,$00,$80 - db $bb,$40,$c0 - db $b1,$03,$60 - db $bd,$11,$e0 - db $a8,$20,$e0 - db $d2,$00,$80 - db $b2,$00,$80 - db $b2,$11,$a0 - db $b2,$01,$c0 - db $a9,$14,$c0 - db $b1,$02,$a0 - db $c5,$f0,$80 - db $c5,$20,$c0 - db $d5,$00,$20 - db $d5,$20,$80 - db $d2,$12,$60 - db $be,$00,$80 - db $aa,$01,$e0 - db $c5,$0f,$e0 - db $c5,$11,$20 - db $a6,$10,$40 - db $a5,$10,$c0 - db $aa,$00,$20 - db $d8,$00,$80 - db $e4,$11,$18 - db $9f,$20,$c0 - db $9e,$20,$c0 - db $bd,$00,$10 - db $be,$f0,$20 - db $df,$f0,$c0 - db $a7,$f0,$e0 - db $9f,$f0,$40 - db $db,$00,$80 - db $df,$80,$40 - db $df,$00,$80 - db $aa,$11,$20 - db $aa,$22,$10 - db $b1,$f1,$ff - db $a9,$f1,$ff - db $aa,$33,$30 - db $dd,$40,$c0 - db $a4,$20,$20 - db $a4,$f0,$10 - db $a5,$f8,$10 - db $a7,$f0,$10 - db $bd,$00,$80 - db $ae,$00,$c0 - db $dd,$c0,$ff - db $9f,$f2,$20 - db $e1,$00,$80 - db $e1,$00,$40 - db $9f,$00,$40 - db $a7,$10,$ff - db $c7,$20,$20 - db $dd,$00,$80 - db $c5,$1f,$20 - db $bd,$2f,$80 - db $a5,$1f,$ff - db $ca,$1f,$60 - db $be,$1e,$20 - db $be,$1f,$18 - db $aa,$0f,$80 - db $9f,$f8,$10 - db $9e,$18,$20 - db $dd,$08,$40 - db $ad,$01,$e0 - db $a7,$09,$ff - db $e4,$42,$01 - db $b2,$00,$ff - db $dd,$08,$e0 - db $bb,$00,$80 - db $9f,$88,$10 - db $bd,$48,$ff - db $9e,$ff,$ff - db $bb,$ff,$10 - db $9e,$ff,$04 - db $b2,$01,$ff - db $a9,$f8,$ff - db $a2,$f0,$f0 - db $a5,$08,$10 - db $a3,$f0,$ff - db $b0,$f0,$ff - db $e1,$10,$ff - db $a4,$f0,$20 - db $ca,$f0,$60 - db $b8,$12,$10 - db $e6,$f0,$20 - db $b4,$12,$ff - db $db,$80,$04 - db $df,$f0,$10 - db $c5,$f8,$ff - db $be,$f0,$ff - db $a7,$01,$ff - db $cc,$d8,$04 - db $a1,$00,$80 - db $a1,$00,$80 + db (SFX_08_4a - SFX_Headers_08) / 3,$00,$80 + db (SFX_08_4c - SFX_Headers_08) / 3,$10,$80 + db (SFX_08_5d - SFX_Headers_08) / 3,$00,$80 + db (SFX_08_4b - SFX_Headers_08) / 3,$01,$80 + db (SFX_08_4d - SFX_Headers_08) / 3,$00,$40 + db (SFX_08_77 - SFX_Headers_08) / 3,$00,$ff + db (SFX_08_4d - SFX_Headers_08) / 3,$10,$60 + db (SFX_08_4d - SFX_Headers_08) / 3,$20,$80 + db (SFX_08_4d - SFX_Headers_08) / 3,$00,$a0 + db (SFX_08_50 - SFX_Headers_08) / 3,$00,$80 + db (SFX_08_4f - SFX_Headers_08) / 3,$20,$40 + db (SFX_08_4f - SFX_Headers_08) / 3,$00,$80 + db (SFX_08_4e - SFX_Headers_08) / 3,$00,$a0 + db (SFX_08_51 - SFX_Headers_08) / 3,$10,$c0 + db (SFX_08_51 - SFX_Headers_08) / 3,$00,$a0 + db (SFX_08_52 - SFX_Headers_08) / 3,$00,$c0 + db (SFX_08_52 - SFX_Headers_08) / 3,$10,$a0 + db (SFX_08_53 - SFX_Headers_08) / 3,$00,$e0 + db (SFX_08_51 - SFX_Headers_08) / 3,$20,$c0 + db (SFX_08_54 - SFX_Headers_08) / 3,$00,$80 + db (SFX_08_62 - SFX_Headers_08) / 3,$00,$80 + db (SFX_08_55 - SFX_Headers_08) / 3,$01,$80 + db (SFX_08_60 - SFX_Headers_08) / 3,$00,$80 + db (SFX_08_57 - SFX_Headers_08) / 3,$f0,$40 + db (SFX_08_5a - SFX_Headers_08) / 3,$00,$80 + db (SFX_08_57 - SFX_Headers_08) / 3,$00,$80 + db (SFX_08_61 - SFX_Headers_08) / 3,$10,$80 + db (SFX_08_5b - SFX_Headers_08) / 3,$01,$a0 + db (SFX_08_58 - SFX_Headers_08) / 3,$00,$80 + db (SFX_08_5e - SFX_Headers_08) / 3,$00,$60 + db (SFX_08_5e - SFX_Headers_08) / 3,$01,$40 + db (SFX_08_5f - SFX_Headers_08) / 3,$00,$a0 + db (SFX_08_5a - SFX_Headers_08) / 3,$10,$a0 + db (SFX_08_60 - SFX_Headers_08) / 3,$00,$c0 + db (SFX_08_54 - SFX_Headers_08) / 3,$10,$60 + db (SFX_08_5a - SFX_Headers_08) / 3,$00,$a0 + db (SFX_08_62 - SFX_Headers_08) / 3,$11,$c0 + db (SFX_08_5a - SFX_Headers_08) / 3,$20,$c0 + db (SFX_08_61 - SFX_Headers_08) / 3,$00,$80 + db (SFX_08_5b - SFX_Headers_08) / 3,$00,$80 + db (SFX_08_5b - SFX_Headers_08) / 3,$20,$c0 + db (SFX_08_59 - SFX_Headers_08) / 3,$00,$80 + db (SFX_08_71 - SFX_Headers_08) / 3,$ff,$40 + db (SFX_08_5e - SFX_Headers_08) / 3,$00,$80 + db (SFX_08_4b - SFX_Headers_08) / 3,$00,$c0 + db (SFX_08_4b - SFX_Headers_08) / 3,$00,$40 + db (SFX_08_75 - SFX_Headers_08) / 3,$00,$80 + db (SFX_08_67 - SFX_Headers_08) / 3,$40,$60 + db (SFX_08_67 - SFX_Headers_08) / 3,$00,$80 + db (SFX_08_67 - SFX_Headers_08) / 3,$ff,$40 + db (SFX_08_6a - SFX_Headers_08) / 3,$80,$c0 + db (SFX_08_59 - SFX_Headers_08) / 3,$10,$a0 + db (SFX_08_59 - SFX_Headers_08) / 3,$21,$e0 + db (SFX_08_69 - SFX_Headers_08) / 3,$00,$80 + db (SFX_08_64 - SFX_Headers_08) / 3,$20,$60 + db (SFX_08_6a - SFX_Headers_08) / 3,$00,$80 + db (SFX_08_6c - SFX_Headers_08) / 3,$00,$80 + db (SFX_08_68 - SFX_Headers_08) / 3,$40,$80 + db (SFX_08_69 - SFX_Headers_08) / 3,$f0,$e0 + db (SFX_08_6d - SFX_Headers_08) / 3,$00,$80 + db (SFX_08_6a - SFX_Headers_08) / 3,$f0,$60 + db (SFX_08_68 - SFX_Headers_08) / 3,$00,$80 + db (SFX_08_76 - SFX_Headers_08) / 3,$00,$80 + db (SFX_08_47 - SFX_Headers_08) / 3,$01,$a0 + db (SFX_08_53 - SFX_Headers_08) / 3,$f0,$20 + db (SFX_08_63 - SFX_Headers_08) / 3,$01,$c0 + db (SFX_08_63 - SFX_Headers_08) / 3,$00,$80 + db (SFX_08_5a - SFX_Headers_08) / 3,$00,$e0 + db (SFX_08_66 - SFX_Headers_08) / 3,$01,$60 + db (SFX_08_66 - SFX_Headers_08) / 3,$20,$40 + db (SFX_08_64 - SFX_Headers_08) / 3,$00,$80 + db (SFX_08_64 - SFX_Headers_08) / 3,$40,$c0 + db (SFX_08_5b - SFX_Headers_08) / 3,$03,$60 + db (SFX_08_65 - SFX_Headers_08) / 3,$11,$e0 + db (SFX_08_52 - SFX_Headers_08) / 3,$20,$e0 + db (SFX_08_6e - SFX_Headers_08) / 3,$00,$80 + db (SFX_08_5c - SFX_Headers_08) / 3,$00,$80 + db (SFX_08_5c - SFX_Headers_08) / 3,$11,$a0 + db (SFX_08_5c - SFX_Headers_08) / 3,$01,$c0 + db (SFX_08_53 - SFX_Headers_08) / 3,$14,$c0 + db (SFX_08_5b - SFX_Headers_08) / 3,$02,$a0 + db (SFX_08_69 - SFX_Headers_08) / 3,$f0,$80 + db (SFX_08_69 - SFX_Headers_08) / 3,$20,$c0 + db (SFX_08_6f - SFX_Headers_08) / 3,$00,$20 + db (SFX_08_6f - SFX_Headers_08) / 3,$20,$80 + db (SFX_08_6e - SFX_Headers_08) / 3,$12,$60 + db (SFX_08_66 - SFX_Headers_08) / 3,$00,$80 + db (SFX_08_54 - SFX_Headers_08) / 3,$01,$e0 + db (SFX_08_69 - SFX_Headers_08) / 3,$0f,$e0 + db (SFX_08_69 - SFX_Headers_08) / 3,$11,$20 + db (SFX_08_50 - SFX_Headers_08) / 3,$10,$40 + db (SFX_08_4f - SFX_Headers_08) / 3,$10,$c0 + db (SFX_08_54 - SFX_Headers_08) / 3,$00,$20 + db (SFX_08_70 - SFX_Headers_08) / 3,$00,$80 + db (SFX_08_75 - SFX_Headers_08) / 3,$11,$18 + db (SFX_08_49 - SFX_Headers_08) / 3,$20,$c0 + db (SFX_08_48 - SFX_Headers_08) / 3,$20,$c0 + db (SFX_08_65 - SFX_Headers_08) / 3,$00,$10 + db (SFX_08_66 - SFX_Headers_08) / 3,$f0,$20 + db (SFX_08_73 - SFX_Headers_08) / 3,$f0,$c0 + db (SFX_08_51 - SFX_Headers_08) / 3,$f0,$e0 + db (SFX_08_49 - SFX_Headers_08) / 3,$f0,$40 + db (SFX_08_71 - SFX_Headers_08) / 3,$00,$80 + db (SFX_08_73 - SFX_Headers_08) / 3,$80,$40 + db (SFX_08_73 - SFX_Headers_08) / 3,$00,$80 + db (SFX_08_54 - SFX_Headers_08) / 3,$11,$20 + db (SFX_08_54 - SFX_Headers_08) / 3,$22,$10 + db (SFX_08_5b - SFX_Headers_08) / 3,$f1,$ff + db (SFX_08_53 - SFX_Headers_08) / 3,$f1,$ff + db (SFX_08_54 - SFX_Headers_08) / 3,$33,$30 + db (SFX_08_72 - SFX_Headers_08) / 3,$40,$c0 + db (SFX_08_4e - SFX_Headers_08) / 3,$20,$20 + db (SFX_08_4e - SFX_Headers_08) / 3,$f0,$10 + db (SFX_08_4f - SFX_Headers_08) / 3,$f8,$10 + db (SFX_08_51 - SFX_Headers_08) / 3,$f0,$10 + db (SFX_08_65 - SFX_Headers_08) / 3,$00,$80 + db (SFX_08_58 - SFX_Headers_08) / 3,$00,$c0 + db (SFX_08_72 - SFX_Headers_08) / 3,$c0,$ff + db (SFX_08_49 - SFX_Headers_08) / 3,$f2,$20 + db (SFX_08_74 - SFX_Headers_08) / 3,$00,$80 + db (SFX_08_74 - SFX_Headers_08) / 3,$00,$40 + db (SFX_08_49 - SFX_Headers_08) / 3,$00,$40 + db (SFX_08_51 - SFX_Headers_08) / 3,$10,$ff + db (SFX_08_6a - SFX_Headers_08) / 3,$20,$20 + db (SFX_08_72 - SFX_Headers_08) / 3,$00,$80 + db (SFX_08_69 - SFX_Headers_08) / 3,$1f,$20 + db (SFX_08_65 - SFX_Headers_08) / 3,$2f,$80 + db (SFX_08_4f - SFX_Headers_08) / 3,$1f,$ff + db (SFX_08_6b - SFX_Headers_08) / 3,$1f,$60 + db (SFX_08_66 - SFX_Headers_08) / 3,$1e,$20 + db (SFX_08_66 - SFX_Headers_08) / 3,$1f,$18 + db (SFX_08_54 - SFX_Headers_08) / 3,$0f,$80 + db (SFX_08_49 - SFX_Headers_08) / 3,$f8,$10 + db (SFX_08_48 - SFX_Headers_08) / 3,$18,$20 + db (SFX_08_72 - SFX_Headers_08) / 3,$08,$40 + db (SFX_08_57 - SFX_Headers_08) / 3,$01,$e0 + db (SFX_08_51 - SFX_Headers_08) / 3,$09,$ff + db (SFX_08_75 - SFX_Headers_08) / 3,$42,$01 + db (SFX_08_5c - SFX_Headers_08) / 3,$00,$ff + db (SFX_08_72 - SFX_Headers_08) / 3,$08,$e0 + db (SFX_08_64 - SFX_Headers_08) / 3,$00,$80 + db (SFX_08_49 - SFX_Headers_08) / 3,$88,$10 + db (SFX_08_65 - SFX_Headers_08) / 3,$48,$ff + db (SFX_08_48 - SFX_Headers_08) / 3,$ff,$ff + db (SFX_08_64 - SFX_Headers_08) / 3,$ff,$10 + db (SFX_08_48 - SFX_Headers_08) / 3,$ff,$04 + db (SFX_08_5c - SFX_Headers_08) / 3,$01,$ff + db (SFX_08_53 - SFX_Headers_08) / 3,$f8,$ff + db (SFX_08_4c - SFX_Headers_08) / 3,$f0,$f0 + db (SFX_08_4f - SFX_Headers_08) / 3,$08,$10 + db (SFX_08_4d - SFX_Headers_08) / 3,$f0,$ff + db (SFX_08_5a - SFX_Headers_08) / 3,$f0,$ff + db (SFX_08_74 - SFX_Headers_08) / 3,$10,$ff + db (SFX_08_4e - SFX_Headers_08) / 3,$f0,$20 + db (SFX_08_6b - SFX_Headers_08) / 3,$f0,$60 + db (SFX_08_61 - SFX_Headers_08) / 3,$12,$10 + db (SFX_08_76 - SFX_Headers_08) / 3,$f0,$20 + db (SFX_08_5e - SFX_Headers_08) / 3,$12,$ff + db (SFX_08_71 - SFX_Headers_08) / 3,$80,$04 + db (SFX_08_73 - SFX_Headers_08) / 3,$f0,$10 + db (SFX_08_69 - SFX_Headers_08) / 3,$f8,$ff + db (SFX_08_66 - SFX_Headers_08) / 3,$f0,$ff + db (SFX_08_51 - SFX_Headers_08) / 3,$01,$ff + db (SFX_08_6c - SFX_Headers_08) / 3,$d8,$04 + db (SFX_08_4b - SFX_Headers_08) / 3,$00,$80 + db (SFX_08_4b - SFX_Headers_08) / 3,$00,$80 Func_79aae: ; 79aae (1e:5aae) ld a, [H_WHOSETURN] ; $fff3 From 6143848c7e7569021978bed733375c97d24f8ac4 Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Tue, 3 Feb 2015 19:45:55 -0800 Subject: [PATCH 082/100] Added bcd macros with coins and money aliases. --- data/item_prices.asm | 194 +++++++++++++++++++++---------------------- data/prizes.asm | 28 +++---- macros.asm | 14 ++++ 3 files changed, 125 insertions(+), 111 deletions(-) diff --git a/data/item_prices.asm b/data/item_prices.asm index 45537dedf9..f6882fd0c6 100755 --- a/data/item_prices.asm +++ b/data/item_prices.asm @@ -1,98 +1,98 @@ ItemPrices: ; 4608 (1:4608) - db $00,$00,$00 - db $00,$12,$00 - db $00,$06,$00 - db $00,$02,$00 - db $00,$00,$00 - db $00,$00,$00 - db $00,$00,$00 - db $00,$10,$00 - db $00,$00,$00 - db $00,$00,$00 - db $00,$01,$00 - db $00,$02,$50 - db $00,$02,$50 - db $00,$02,$00 - db $00,$02,$00 - db $00,$30,$00 - db $00,$25,$00 - db $00,$15,$00 - db $00,$07,$00 - db $00,$03,$00 - db $00,$00,$00 - db $00,$00,$00 - db $00,$00,$00 - db $00,$00,$00 - db $00,$00,$00 - db $00,$00,$00 - db $00,$00,$00 - db $00,$00,$00 - db $00,$05,$50 - db $00,$03,$50 - db $00,$00,$00 - db $00,$21,$00 - db $00,$21,$00 - db $00,$21,$00 - db $00,$98,$00 - db $00,$98,$00 - db $00,$98,$00 - db $00,$98,$00 - db $00,$98,$00 - db $00,$48,$00 - db $00,$00,$00 - db $00,$00,$00 - db $00,$00,$00 - db $00,$00,$00 - db $00,$00,$00 - db $00,$09,$50 - db $00,$21,$00 - db $00,$00,$00 - db $01,$00,$00 - db $00,$98,$00 - db $00,$10,$00 - db $00,$06,$00 - db $00,$15,$00 - db $00,$40,$00 - db $00,$07,$00 - db $00,$05,$00 - db $00,$07,$00 - db $00,$06,$50 - db $00,$00,$10 - db $00,$02,$00 - db $00,$03,$00 - db $00,$03,$50 - db $00,$00,$00 - db $00,$00,$00 - db $00,$05,$00 - db $00,$05,$50 - db $00,$03,$50 - db $00,$03,$50 - db $00,$00,$00 - db $00,$00,$00 - db $00,$00,$00 - db $00,$00,$00 - db $00,$00,$00 - db $00,$00,$00 - db $00,$00,$00 - db $00,$00,$00 - db $00,$00,$00 - db $00,$00,$00 - db $00,$00,$00 - db $00,$00,$00 - db $00,$00,$00 - db $00,$00,$00 - db $00,$00,$00 - db $00,$00,$00 - db $00,$00,$00 - db $00,$00,$00 - db $00,$00,$00 - db $00,$00,$00 - db $00,$00,$00 - db $00,$00,$00 - db $00,$00,$00 - db $00,$00,$00 - db $00,$00,$00 - db $00,$00,$00 - db $00,$00,$00 - db $00,$00,$00 - db $00,$00,$00 + money 0 ; MASTER_BALL + money 1200 ; ULTRA_BALL + money 600 ; GREAT_BALL + money 200 ; POKE_BALL + money 0 ; TOWN_MAP + money 0 ; BICYCLE + money 0 ; SURFBOARD + money 1000 ; SAFARI_BALL + money 0 ; POKEDEX + money 0 ; MOON_STONE + money 100 ; ANTIDOTE + money 250 ; BURN_HEAL + money 250 ; ICE_HEAL + money 200 ; AWAKENING + money 200 ; PARLYZ_HEAL + money 3000 ; FULL_RESTORE + money 2500 ; MAX_POTION + money 1500 ; HYPER_POTION + money 700 ; SUPER_POTION + money 300 ; POTION + money 0 ; BOULDERBADGE + money 0 ; CASCADEBADGE + money 0 ; THUNDERBADGE + money 0 ; RAINBOWBADGE + money 0 ; SOULBADGE + money 0 ; MARSHBADGE + money 0 ; VOLCANOBADGE + money 0 ; EARTHBADGE + money 550 ; ESCAPE_ROPE + money 350 ; REPEL + money 0 ; OLD_AMBER + money 2100 ; FIRE_STONE + money 2100 ; THUNDER_STONE + money 2100 ; WATER_STONE + money 9800 ; HP_UP + money 9800 ; PROTEIN + money 9800 ; IRON + money 9800 ; CARBOS + money 9800 ; CALCIUM + money 4800 ; RARE_CANDY + money 0 ; DOME_FOSSIL + money 0 ; HELIX_FOSSIL + money 0 ; SECRET_KEY + money 0 ; XXX + money 0 ; BIKE_VOUCHER + money 950 ; X_ACCURACY + money 2100 ; LEAF_STONE + money 0 ; CARD_KEY + money 10000 ; NUGGET + money 9800 ; XXX PP_UP + money 1000 ; POKE_DOLL + money 600 ; FULL_HEAL + money 1500 ; REVIVE + money 4000 ; MAX_REVIVE + money 700 ; GUARD_SPEC_ + money 500 ; SUPER_REPEL + money 700 ; MAX_REPEL + money 650 ; DIRE_HIT + money 10 ; COIN + money 200 ; FRESH_WATER + money 300 ; SODA_POP + money 350 ; LEMONADE + money 0 ; S_S__TICKET + money 0 ; GOLD_TEETH + money 500 ; X_ATTACK + money 550 ; X_DEFEND + money 350 ; X_SPEED + money 350 ; X_SPECIAL + money 0 ; COIN_CASE + money 0 ; OAKS_PARCEL + money 0 ; ITEMFINDER + money 0 ; SILPH_SCOPE + money 0 ; POKE_FLUTE + money 0 ; LIFT_KEY + money 0 ; EXP__ALL + money 0 ; OLD_ROD + money 0 ; GOOD_ROD + money 0 ; SUPER_ROD + money 0 ; PP_UP + money 0 ; ETHER + money 0 ; MAX_ETHER + money 0 ; ELIXER + money 0 ; MAX_ELIXER + money 0 ; B2F + money 0 ; B1F + money 0 ; 1F + money 0 ; 2F + money 0 ; 3F + money 0 ; 4F + money 0 ; 5F + money 0 ; 6F + money 0 ; 7F + money 0 ; 8F + money 0 ; 9F + money 0 ; 10F + money 0 ; 11F + money 0 ; B4F diff --git a/data/prizes.asm b/data/prizes.asm index c88767d64e..3d4102b6c9 100755 --- a/data/prizes.asm +++ b/data/prizes.asm @@ -24,14 +24,14 @@ ENDC PrizeMenuMon1Cost: ; 5285d (14:685d) IF DEF(_RED) - db $01,$80 ; 180 Coins - db $05,$00 ; 500 Coins + coins 180 + coins 500 ENDC IF DEF(_BLUE) - db $01,$20 ; 120 Coins - db $07,$50 ; 750 Coins + coins 120 + coins 750 ENDC - db $12,$00 ; 1200 Coins + coins 1200 db "@" PrizeMenuMon2Entries: ; 52864 (14:6864) @@ -48,14 +48,14 @@ ENDC PrizeMenuMon2Cost: ; 52868 (14:6868) IF DEF(_RED) - db $28,$00 ; 2800 Coins - db $55,$00 ; 5500 Coins - db $99,$99 ; 9999 Coins + coins 2800 + coins 5500 + coins 9999 ENDC IF DEF(_BLUE) - db $25,$00 ; 2500 Coins - db $46,$00 ; 4600 Coins - db $65,$00 ; 6500 Coins + coins 2500 + coins 4600 + coins 6500 ENDC db "@" @@ -66,7 +66,7 @@ PrizeMenuTMsEntries: ; 5286f (14:686f) db "@" PrizeMenuTMsCost: ; 52873 (14:6873) - db $33,$00 ; 3300 Coins - db $55,$00 ; 5500 Coins - db $77,$00 ; 7700 Coins + coins 3300 + coins 5500 + coins 7700 db "@" diff --git a/macros.asm b/macros.asm index 6dd239da25..b80f14425c 100644 --- a/macros.asm +++ b/macros.asm @@ -49,6 +49,20 @@ callab: MACRO call Bankswitch ENDM +bcd2: MACRO + dn ((\1) / 1000) % 10, ((\1) / 100) % 10 + dn ((\1) / 10) % 10, (\1) % 10 + ENDM + +bcd3: MACRO + dn ((\1) / 100000) % 10, ((\1) / 10000) % 10 + dn ((\1) / 1000) % 10, ((\1) / 100) % 10 + dn ((\1) / 10) % 10, (\1) % 10 + ENDM + +coins equs "bcd2" +money equs "bcd3" + ;\1 = X ;\2 = Y hlCoord: MACRO From c3a5bb70d2c65b7fe6033ee9bfb8fe89b6a3e431 Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Tue, 3 Feb 2015 19:54:47 -0800 Subject: [PATCH 083/100] Use money macro for TrainerPicAndMoneyPointers. --- engine/battle/e.asm | 94 ++++++++++++++++++++++----------------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/engine/battle/e.asm b/engine/battle/e.asm index 072aca49ab..dd227be73a 100755 --- a/engine/battle/e.asm +++ b/engine/battle/e.asm @@ -435,145 +435,145 @@ TrainerPicAndMoneyPointers: ; 39914 (e:5914) ; trainer pic pointers and base money. ; money received after battle = base money × level of highest-level enemy mon dw YoungsterPic - db 0,$15,0 + money 1500 dw BugCatcherPic - db 0,$10,0 + money 1000 dw LassPic - db 0,$15,0 + money 1500 dw SailorPic - db 0,$30,0 + money 3000 dw JrTrainerMPic - db 0,$20,0 + money 2000 dw JrTrainerFPic - db 0,$20,0 + money 2000 dw PokemaniacPic - db 0,$50,0 + money 5000 dw SuperNerdPic - db 0,$25,0 + money 2500 dw HikerPic - db 0,$35,0 + money 3500 dw BikerPic - db 0,$20,0 + money 2000 dw BurglarPic - db 0,$90,0 + money 9000 dw EngineerPic - db 0,$50,0 + money 5000 dw JugglerPic - db 0,$35,0 + money 3500 dw FisherPic - db 0,$35,0 + money 3500 dw SwimmerPic - db 0,$05,0 + money 500 dw CueBallPic - db 0,$25,0 + money 2500 dw GamblerPic - db 0,$70,0 + money 7000 dw BeautyPic - db 0,$70,0 + money 7000 dw PsychicPic - db 0,$10,0 + money 1000 dw RockerPic - db 0,$25,0 + money 2500 dw JugglerPic - db 0,$35,0 + money 3500 dw TamerPic - db 0,$40,0 + money 4000 dw BirdKeeperPic - db 0,$25,0 + money 2500 dw BlackbeltPic - db 0,$25,0 + money 2500 dw Rival1Pic - db 0,$35,0 + money 3500 dw ProfOakPic - db 0,$99,0 + money 9900 dw ChiefPic - db 0,$30,0 + money 3000 dw ScientistPic - db 0,$50,0 + money 5000 dw GiovanniPic - db 0,$99,0 + money 9900 dw RocketPic - db 0,$30,0 + money 3000 dw CooltrainerMPic - db 0,$35,0 + money 3500 dw CooltrainerFPic - db 0,$35,0 + money 3500 dw BrunoPic - db 0,$99,0 + money 9900 dw BrockPic - db 0,$99,0 + money 9900 dw MistyPic - db 0,$99,0 + money 9900 dw LtSurgePic - db 0,$99,0 + money 9900 dw ErikaPic - db 0,$99,0 + money 9900 dw KogaPic - db 0,$99,0 + money 9900 dw BlainePic - db 0,$99,0 + money 9900 dw SabrinaPic - db 0,$99,0 + money 9900 dw GentlemanPic - db 0,$70,0 + money 7000 dw Rival2Pic - db 0,$65,0 + money 6500 dw Rival3Pic - db 0,$99,0 + money 9900 dw LoreleiPic - db 0,$99,0 + money 9900 dw ChannelerPic - db 0,$30,0 + money 3000 dw AgathaPic - db 0,$99,0 + money 9900 dw LancePic - db 0,$99,0 + money 9900 INCLUDE "text/trainer_names.asm" From 97637e7ce7110c9a20e5fa9222e445700857a9cb Mon Sep 17 00:00:00 2001 From: xCrystal Date: Sat, 31 Jan 2015 18:26:05 +0100 Subject: [PATCH 084/100] More battle commentary/labels/constans and fix some spacing issues Conflicts: engine/battle/core.asm --- engine/battle/core.asm | 297 +++++++++++++++++++++-------------------- wram.asm | 12 +- 2 files changed, 160 insertions(+), 149 deletions(-) diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 25471ea53d..90c296e4d9 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -2,6 +2,7 @@ BattleCore: ; These are move effects (second value from the Moves table in bank $E). ResidualEffects1: ; 3c000 (f:4000) +; most non-side effects db CONVERSION_EFFECT db HAZE_EFFECT db SWITCH_AND_TELEPORT_EFFECT @@ -26,6 +27,7 @@ SetDamageEffects: ; 3c011 (f:4011) db SPECIAL_DAMAGE_EFFECT db -1 ResidualEffects2: ; 3c014 (f:4014) +; non-side effects not included in ResidualEffects1 ; stat-affecting moves, sleep-inflicting moves, and Bide ; e.g., Meditate, Bide, Hypnosis db $01 @@ -846,7 +848,7 @@ FaintEnemyPokemon ; 0x3c567 ld [W_ENEMYDISABLEDMOVE], a ld [wccef], a ld [wccf3], a - ld hl, wccf1 + ld hl, wPlayerUsedMove ld [hli], a ld [hl], a hlCoord 12, 5 @@ -1371,7 +1373,7 @@ EnemySendOutFirstMon: ; 3c92a (f:492a) ld [W_ENEMYDISABLEDMOVE],a ld [wccef],a ld [wccf3],a - ld hl,wccf1 + ld hl,wPlayerUsedMove ld [hli],a ld [hl],a dec a @@ -1808,7 +1810,7 @@ SendOutMon: ; 3cc91 (f:4c91) ld [wcc5b], a ld [wd05b], a ld [W_PLAYERMOVENUM], a - ld hl, wccf1 + ld hl, wPlayerUsedMove ld [hli], a ld [hl], a ld hl, wd060 @@ -2547,7 +2549,7 @@ MoveSelectionMenu: ; 3d219 (f:5219) ret .regularmenu - call Func_3d3f5 + call AnyMoveToSelect ret z ld hl, wBattleMonMoves call .loadmoves @@ -2636,8 +2638,9 @@ MoveSelectionMenu: ; 3d219 (f:5219) inc a .movelistindex1 ld [hl], a +; fallthrough -Func_3d2fe: ; 3d2fe (f:52fe) +SelectMenuItem: ; 3d2fe (f:52fe) ld a, [wMoveMenuType] and a jr z, .battleselect @@ -2651,7 +2654,7 @@ Func_3d2fe: ; 3d2fe (f:52fe) ld a, [W_FLAGS_D733] bit 0, a jr nz, .select - call Func_3d4b6 + call PrintMenuItem ld a, [wMenuItemToSwap] and a jr z, .select @@ -2667,9 +2670,9 @@ Func_3d2fe: ; 3d2fe (f:52fe) ld hl, $fff6 res 1, [hl] bit 6, a - jp nz, Func_3d3c9 ; up + jp nz, CursorUp ; up bit 7, a - jp nz, Func_3d3dd ; down + jp nz, CursorDown ; down bit 2, a jp nz, SwapMovesInMenu ; select bit 1, a ; B, but was it reset above? @@ -2743,30 +2746,32 @@ MoveDisabledText: ; 3d3b3 (f:53b3) WhichTechniqueString: ; 3d3b8 (f:53b8) db "WHICH TECHNIQUE?@" -Func_3d3c9: ; 3d3c9 (f:53c9) +CursorUp: ; 3d3c9 (f:53c9) ld a, [wCurrentMenuItem] and a - jp nz, Func_3d2fe + jp nz, SelectMenuItem call EraseMenuCursor ld a, [wcd6c] inc a ld [wCurrentMenuItem], a - jp Func_3d2fe + jp SelectMenuItem -Func_3d3dd: ; 3d3dd (f:53dd) +CursorDown: ; 3d3dd (f:53dd) ld a, [wCurrentMenuItem] ld b, a ld a, [wcd6c] inc a inc a cp b - jp nz, Func_3d2fe + jp nz, SelectMenuItem call EraseMenuCursor ld a, $1 ld [wCurrentMenuItem], a - jp Func_3d2fe + jp SelectMenuItem + +AnyMoveToSelect: ; 3d3f5 (f:53f5) +; return z and Struggle as the selected move if all moves have 0 PP and/or are disabled -Func_3d3f5: ; 3d3f5 (f:53f5) ld a, STRUGGLE ld [wPlayerSelectedMove], a ld a, [W_PLAYERDISABLEDMOVE] @@ -2888,7 +2893,7 @@ SwapMovesInMenu: ; 3d435 (f:5435) ld [wMenuItemToSwap], a ; select the current menu item for swapping jp MoveSelectionMenu -Func_3d4b6: ; 3d4b6 (f:54b6) +PrintMenuItem: ; 3d4b6 (f:54b6) xor a ld [H_AUTOBGTRANSFERENABLED], a hlCoord 0, 8 @@ -2897,18 +2902,18 @@ Func_3d4b6: ; 3d4b6 (f:54b6) call TextBoxBorder ld a, [W_PLAYERDISABLEDMOVE] and a - jr z, .asm_3d4df + jr z, .notDisabled swap a and $f ld b, a ld a, [wCurrentMenuItem] cp b - jr nz, .asm_3d4df + jr nz, .notDisabled hlCoord 1, 10 ld de, DisabledText call PlaceString - jr .asm_3d54e -.asm_3d4df + jr .moveDisabled +.notDisabled ld hl, wCurrentMenuItem dec [hl] xor a @@ -2916,10 +2921,11 @@ Func_3d4b6: ; 3d4b6 (f:54b6) ld hl, wBattleMonMoves ld a, [wCurrentMenuItem] ld c, a - ld b, $0 - add hl, bc - ld a, [hl] - ld [wPlayerSelectedMove], a + ld b, $0 ; which item in the menu is the cursor pointing to? (0-3) + add hl, bc ; point to the item (move) in memory + ld a, [hl] + ld [wPlayerSelectedMove], a ; update wPlayerSelectedMove even if the move + ; isn't actually selected (just pointed to by the cursor) ld a, [wPlayerMonNumber] ld [wWhichPokemon], a ld a, $4 @@ -2934,6 +2940,7 @@ Func_3d4b6: ; 3d4b6 (f:54b6) ld a, [hl] and $3f ld [wcd6d], a +; print TYPE/ and / hlCoord 1, 9 ld de, TypeText call PlaceString @@ -2949,10 +2956,10 @@ Func_3d4b6: ; 3d4b6 (f:54b6) ld de, wd11e ld bc, $102 call PrintNumber - call GetCurrentMove + call GetCurrentMove hlCoord 2, 10 predef Func_27d98 -.asm_3d54e +.moveDisabled ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a jp Delay3 @@ -3125,9 +3132,9 @@ ExecutePlayerMove: ; 3d65e (f:565e) call PrintGhostText jp z, ExecutePlayerMoveDone call CheckPlayerStatusConditions - jr nz, .asm_3d68a + jr nz, .playerHasNoSpecialCondition jp [hl] -.asm_3d68a +.playerHasNoSpecialCondition call GetCurrentMove ld hl, W_PLAYERBATTSTATUS1 bit 4, [hl] ; charging up for attack @@ -3147,8 +3154,8 @@ Func_3d69a: ; 3d69a (f:569a) PlayerCanExecuteChargingMove: ; 3d6a9 (f:56a9) ld hl,W_PLAYERBATTSTATUS1 res 4,[hl] ; reset charging up and invulnerability statuses if mon was charging up for an attack - ; being fully paralyzed or hurting oneself in confusion removes charging up status - ; resulting in the Pokemon being invulnerable for the whole battle + ; being fully paralyzed or hurting oneself in confusion removes charging up status + ; resulting in the Pokemon being invulnerable for the whole battle res 6,[hl] PlayerCanExecuteMove: ; 3d6b0 (f:56b0) call PrintMonName1Text @@ -3160,14 +3167,14 @@ PlayerCanExecuteMove: ; 3d6b0 (f:56b0) ld hl,ResidualEffects1 ld de,1 call IsInArray - jp c,JumpMoveEffect ; ResidualEffects1 moves skip damage calculation and accuracy tests - ; unless executed as part of their exclusive effect functions + jp c,JumpMoveEffect ; ResidualEffects1 moves skip damage calculation and accuracy tests + ; unless executed as part of their exclusive effect functions ld a,[W_PLAYERMOVEEFFECT] ld hl,SpecialEffectsCont ld de,1 call IsInArray - call c,JumpMoveEffect ; execute the effects of SpecialEffectsCont moves (e.g. Wrap, Thrash) but don't skip anything -CalcMoveDamage: ; 3d6dc (f:56dc) + call c,JumpMoveEffect ; execute the effects of SpecialEffectsCont moves (e.g. Wrap, Thrash) but don't skip anything +PlayerCalcMoveDamage: ; 3d6dc (f:56dc) ld a,[W_PLAYERMOVEEFFECT] ld hl,SetDamageEffects ld de,1 @@ -3179,7 +3186,7 @@ CalcMoveDamage: ; 3d6dc (f:56dc) call GetDamageVarsForPlayerAttack call CalculateDamage jp z,asm_3d74b ; for moves with 0 BP, skip any further damage calculation and, for now, skip MoveHitTest - ; for these moves, accuracy tests will only occur if they are called as part of the effect itself + ; for these moves, accuracy tests will only occur if they are called as part of the effect itself call AdjustDamageForMoveType call RandomizeDamage .moveHitTest @@ -3189,7 +3196,7 @@ asm_3d705 and a jr z,asm_3d714 ld a,[W_PLAYERMOVEEFFECT] - sub a,7 ; Explosion effect + sub a,EXPLODE_EFFECT jr z,asm_3d71e ; don't play any animation if the move missed, unless it was EXPLODE_EFFECT jr asm_3d74b asm_3d714 @@ -3284,8 +3291,8 @@ MirrorMoveCheck ld a,[wPlayerNumAttacksLeft] dec a ld [wPlayerNumAttacksLeft],a - jp nz,asm_3d714 ; for multi-hit moves, apply attack until PlayerNumAttacksLeft hits 0 or the enemy faints. - ; damage calculation and accuracy tests only happen for the first hit + jp nz,asm_3d714 ; for multi-hit moves, apply attack until PlayerNumAttacksLeft hits 0 or the enemy faints. + ; damage calculation and accuracy tests only happen for the first hit res 2,[hl] ld hl,MultiHitText call PrintText @@ -3298,10 +3305,10 @@ MirrorMoveCheck ld hl,SpecialEffects ld de,1 call IsInArray - call nc,JumpMoveEffect ; move effects not included in SpecialEffects, which are the effects not covered yet. - ; the only exception is Rage, whose effect will be executed for a second time (although it's irrelevant) - ; includes some side effects and all non-volatile status effects but sleep. - ; responsible for executing Twineedle's second effect (poison) + call nc,JumpMoveEffect ; move effects not included in SpecialEffects or in either of the ResidualEffect arrays, + ; which are the effects not covered yet. Rage's effect will be executed for a second time (although it's irrelevant). + ; Includes side effects that only need to be called if the target didn't faint. + ; Responsible for executing Twineedle's second effect (poison) jp ExecutePlayerMoveDone MultiHitText: ; 3d805 (f:5805) @@ -3385,7 +3392,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) call PrintText .sleepDone xor a - ld [wccf1],a + ld [wPlayerUsedMove],a ld hl,ExecutePlayerMoveDone ; player can't move this turn jp .returnToHL @@ -3395,7 +3402,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) ld hl,IsFrozenText call PrintText xor a - ld [wccf1],a + ld [wPlayerUsedMove],a ld hl,ExecutePlayerMoveDone ; player can't move this turn jp .returnToHL @@ -3446,7 +3453,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) ld a,[W_PLAYERBATTSTATUS1] add a ; is player confused? jr nc,.TriedToUseDisabledMoveCheck - ld hl,wd06b + ld hl,W_PLAYERCONFUSEDCOUNTER dec [hl] jr nz,.IsConfused ld hl,W_PLAYERBATTSTATUS1 @@ -3572,8 +3579,8 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) call PrintText ld hl,wPlayerNumAttacksLeft dec [hl] ; did Trashing About counter hit 0? - ld hl,CalcMoveDamage ; skip DecrementPP - jp nz,.returnToHL + ld hl,PlayerCalcMoveDamage ; skip DecrementPP + jp nz,.returnToHL push hl ld hl,W_PLAYERBATTSTATUS1 res 1,[hl] ; no longer trashing about @@ -3582,7 +3589,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) and a,3 inc a inc a ; confused for 2-5 turns - ld [wd06b],a + ld [W_PLAYERCONFUSEDCOUNTER],a pop hl ; skip DecrementPP jp .returnToHL @@ -3601,7 +3608,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) .RageCheck ld a, [W_PLAYERBATTSTATUS2] bit 6, a ; is mon using rage? - jp z, .CanUseMove ; if we made it this far, mon can move normally this turn + jp z, .checkPlayerStatusConditionsDone ; if we made it this far, mon can move normally this turn ld a, RAGE ld [wd11e], a call GetMoveName @@ -3615,7 +3622,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) xor a ret -.CanUseMove +.checkPlayerStatusConditionsDone ld a, $1 and a ret @@ -3755,10 +3762,10 @@ MonName1Text: ; 3dafb (f:5afb) ld a, [H_WHOSETURN] and a ld a, [W_PLAYERMOVENUM] - ld hl, wccf1 + ld hl, wPlayerUsedMove jr z, .asm_3db11 ld a, [W_ENEMYMOVENUM] - ld hl, wccf2 + ld hl, wEnemyUsedMove .asm_3db11 ld [hl], a ld [wd11e], a @@ -3906,7 +3913,7 @@ PrintMoveFailureText: ; 3dbe2 (f:5be2) ; if you get here, the mon used jump kick or hi jump kick and missed ld hl, W_DAMAGE ; since the move missed, W_DAMAGE will always contain 0 at this point. - ; Thus, recoil damage will always be equal to 1 even if it was intended to be potential damage/8. + ; Thus, recoil damage will always be equal to 1 even if it was intended to be potential damage/8. ld a, [hli] ld b, [hl] srl a @@ -4756,8 +4763,8 @@ HandleCounterMove: ; 3e093 (f:6093) ld a,[hli] or [hl] ret z ; If we made it here, Counter still misses if the last move used in battle did no damage to its target. - ; W_DAMAGE is shared by both players, so Counter may strike back damage dealt by the Counter user itself - ; if the conditions meet, even though 99% of the times damage will come from the target. + ; W_DAMAGE is shared by both players, so Counter may strike back damage dealt by the Counter user itself + ; if the conditions meet, even though 99% of the times damage will come from the target. ; if it did damage, double it ld a,[hl] add a @@ -5124,7 +5131,8 @@ BuildingRageText: ; 3e2f8 (f:62f8) ; copy last move for Mirror Move ; sets zero flag on failure and unsets zero flag on success MirrorMoveCopyMove: ; 3e2fd (f:62fd) -; Mirror Move makes use of ccf1 and ccf2 addresses, which are mainly used to print the "[Pokemon] used [Move]" text. +; Mirror Move makes use of ccf1 (wPlayerUsedMove) and ccf2 (wEnemyUsedMove) addresses, +; which are mainly used to print the "[Pokemon] used [Move]" text. ; Both are set to 0 whenever a new Pokemon is sent out ; ccf1 is also set to 0 whenever the player is fast asleep or frozen solid. ; ccf2 is also set to 0 whenever the enemy is fast asleep or frozen solid. @@ -5132,19 +5140,19 @@ MirrorMoveCopyMove: ; 3e2fd (f:62fd) ld a,[H_WHOSETURN] and a ; values for player turn - ld a,[wccf2] + ld a,[wEnemyUsedMove] ld hl,wPlayerSelectedMove ld de,W_PLAYERMOVENUM jr z,.next ; values for enemy turn - ld a,[wccf1] + ld a,[wPlayerUsedMove] ld de,W_ENEMYMOVENUM ld hl,wEnemySelectedMove .next ld [hl],a cp a,MIRROR_MOVE ; did the target Pokemon last use Mirror Move, and miss? jr z,.mirrorMoveFailed - and a ; null move? + and a ; has the target selected any move yet? jr nz,ReloadMoveData .mirrorMoveFailed ld hl,MirrorMoveFailedText @@ -5618,9 +5626,9 @@ RandomizeDamage: ; 3e687 (f:6687) ExecuteEnemyMove: ; 3e6bc (f:66bc) ld a, [wEnemySelectedMove] inc a - jp z, Func_3e88c + jp z, ExecuteEnemyMoveDone call PrintGhostText - jp z, Func_3e88c + jp z, ExecuteEnemyMoveDone ld a, [W_ISLINKBATTLE] cp $4 jr nz, .asm_3e6dc @@ -5639,12 +5647,12 @@ ExecuteEnemyMove: ; 3e6bc (f:66bc) ld a, $a ld [wd05b], a call CheckEnemyStatusConditions - jr nz, .canUseMove + jr nz, .enemyHasNoSpecialConditions jp [hl] -.canUseMove +.enemyHasNoSpecialConditions ld hl, W_ENEMYBATTSTATUS1 bit 4, [hl] ; is the enemy charging up for attack? - jr nz, asm_3e70b ; if so, jump + jr nz, enemyCanExecuteChargingMove ; if so, jump call GetCurrentMove Func_3e6fc: ; 3e6fc (f:66fc) @@ -5653,8 +5661,8 @@ Func_3e6fc: ; 3e6fc (f:66fc) jp z, JumpMoveEffect cp FLY_EFFECT jp z, JumpMoveEffect - jr asm_3e72b -asm_3e70b: ; 3e70b (f:670b) + jr enemyCanExecuteMove +enemyCanExecuteChargingMove: ; 3e70b (f:670b) ld hl, W_ENEMYBATTSTATUS1 res 4, [hl] ; no longer charging up for attack res 6, [hl] ; no longer invulnerable to typical attacks @@ -5667,7 +5675,7 @@ asm_3e70b: ; 3e70b (f:670b) call GetName ld de, wcd6d call CopyStringToCF4B -asm_3e72b: ; 3e72b (f:672b) +enemyCanExecuteMove: ; 3e72b (f:672b) xor a ld [wcced], a call PrintMonName1Text @@ -5681,7 +5689,7 @@ asm_3e72b: ; 3e72b (f:672b) ld de, $1 call IsInArray call c, JumpMoveEffect -asm_3e750: ; 3e750 (f:6750) +EnemyCalcMoveDamage: ; 3e750 (f:6750) call SwapPlayerAndEnemyLevels ld a, [W_ENEMYMOVEEFFECT] ld hl, SetDamageEffects @@ -5762,7 +5770,7 @@ asm_3e7ef: ; 3e7ef (f:67ef) cp MIRROR_MOVE_EFFECT jr nz, .notMirrorMoveEffect call MirrorMoveCopyMove - jp z, Func_3e88c + jp z, ExecuteEnemyMoveDone jp Func_3e6fc .notMirrorMoveEffect cp METRONOME_EFFECT @@ -5782,7 +5790,7 @@ asm_3e7ef: ; 3e7ef (f:67ef) ld a, [W_ENEMYMOVEEFFECT] cp EXPLODE_EFFECT jr z, .asm_3e83e - jp Func_3e88c + jp ExecuteEnemyMoveDone .asm_3e82b call ApplyAttackToPlayerPokemon call PrintCriticalOHKOText @@ -5817,18 +5825,18 @@ asm_3e7ef: ; 3e7ef (f:67ef) .asm_3e873 ld a, [W_ENEMYMOVEEFFECT] and a - jr z, Func_3e88c + jr z, ExecuteEnemyMoveDone ld hl, SpecialEffects ld de, $1 call IsInArray call nc, JumpMoveEffect - jr Func_3e88c + jr ExecuteEnemyMoveDone HitXTimesText: ; 3e887 (f:6887) TX_FAR _HitXTimesText db "@" -Func_3e88c: ; 3e88c (f:688c) +ExecuteEnemyMoveDone: ; 3e88c (f:688c) ld b, $1 ret @@ -5855,26 +5863,26 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) call PrintText .next1 xor a - ld [wccf2], a - ld hl, Func_3e88c - jp .cannotUseMove + ld [wEnemyUsedMove], a + ld hl, ExecuteEnemyMoveDone + jp .enemyReturnToHL .checkIfFrozen bit FRZ, [hl] jr z, .checkIfTrapped ld hl, IsFrozenText call PrintText xor a - ld [wccf2], a - ld hl, Func_3e88c - jp .cannotUseMove + ld [wEnemyUsedMove], a + ld hl, ExecuteEnemyMoveDone + jp .enemyReturnToHL .checkIfTrapped ld a, [W_PLAYERBATTSTATUS1] bit 5, a ; is the player using a multi-turn attack like warp jp z, .checkIfFlinched ld hl, CantMoveText call PrintText - ld hl, Func_3e88c - jp .cannotUseMove + ld hl, ExecuteEnemyMoveDone + jp .enemyReturnToHL .checkIfFlinched ld hl, W_ENEMYBATTSTATUS1 bit 3, [hl] ; check if enemy mon flinched @@ -5882,8 +5890,8 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) res 3, [hl] ld hl, FlinchedText call PrintText - ld hl, Func_3e88c - jp .cannotUseMove + ld hl, ExecuteEnemyMoveDone + jp .enemyReturnToHL .checkIfMustRecharge ld hl, W_ENEMYBATTSTATUS2 bit 5, [hl] ; check if enemy mon has to recharge after using a move @@ -5891,8 +5899,8 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) res 5, [hl] ld hl, MustRechargeText call PrintText - ld hl, Func_3e88c - jp .cannotUseMove + ld hl, ExecuteEnemyMoveDone + jp .enemyReturnToHL .checkIfAnyMoveDisabled ld hl, W_ENEMYDISABLEDMOVE ld a, [hl] @@ -5910,7 +5918,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) ld a, [W_ENEMYBATTSTATUS1] add a ; check if enemy mon is confused jp nc, .checkIfTriedToUseDisabledMove - ld hl, wd070 + ld hl, W_ENEMYCONFUSEDCOUNTER dec [hl] jr nz, .isConfused ld hl, W_ENEMYBATTSTATUS1 @@ -5981,8 +5989,8 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) cp [hl] jr nz, .checkIfParalysed call PrintMoveIsDisabledText - ld hl, Func_3e88c - jp .cannotUseMove + ld hl, ExecuteEnemyMoveDone + jp .enemyReturnToHL .checkIfParalysed ld hl, wEnemyMonStatus bit PAR, [hl] @@ -6009,8 +6017,8 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) ld a, STATUS_AFFECTED_ANIM call PlayMoveAnimation .notFlyOrChargeEffect - ld hl, Func_3e88c - jp .cannotUseMove + ld hl, ExecuteEnemyMoveDone + jp .enemyReturnToHL .checkIfUsingBide ld hl, W_ENEMYBATTSTATUS1 bit 0, [hl] ; is mon using bide? @@ -6031,8 +6039,8 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) ld hl, wEnemyNumAttacksLeft dec [hl] jr z, .unleashEnergy - ld hl, Func_3e88c - jp .cannotUseMove + ld hl, ExecuteEnemyMoveDone + jp .enemyReturnToHL .unleashEnergy ld hl, W_ENEMYBATTSTATUS1 res 0, [hl] ; not using bide any more @@ -6060,7 +6068,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) ld [W_ENEMYMOVENUM], a call SwapPlayerAndEnemyLevels ld hl, asm_3e782 - jp .cannotUseMove + jp .enemyReturnToHL .checkIfThrashingAbout bit 1, [hl] ; is mon using thrash or petal dance? jr z, .checkIfUsingMultiturnMove @@ -6070,8 +6078,8 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) call PrintText ld hl, wEnemyNumAttacksLeft dec [hl] - ld hl, asm_3e750 - jp nz, .cannotUseMove + ld hl, EnemyCalcMoveDamage + jp nz, .enemyReturnToHL push hl ld hl, W_ENEMYBATTSTATUS1 res 1, [hl] ; mon is no longer using thrash or petal dance @@ -6080,9 +6088,9 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) and $3 inc a inc a - ld [wd070], a + ld [W_ENEMYCONFUSEDCOUNTER], a pop hl - jp .cannotUseMove + jp .enemyReturnToHL .checkIfUsingMultiturnMove bit 5, [hl] ; is mon using multi-turn move? jp z, .checkIfUsingRage @@ -6091,24 +6099,24 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) ld hl, wEnemyNumAttacksLeft dec [hl] ld hl, Func_3e794 - jp nz, .cannotUseMove - jp .cannotUseMove + jp nz, .enemyReturnToHL + jp .enemyReturnToHL .checkIfUsingRage ld a, [W_ENEMYBATTSTATUS2] bit 6, a ; is mon using rage? - jp z, .canUseMove + jp z, .checkEnemyStatusConditionsDone ld a, RAGE ld [wd11e], a call GetMoveName call CopyStringToCF4B xor a ld [W_ENEMYMOVEEFFECT], a - ld hl, asm_3e72b - jp .cannotUseMove -.cannotUseMove + ld hl, enemyCanExecuteMove + jp .enemyReturnToHL +.enemyReturnToHL xor a ; set Z flag ret -.canUseMove +.checkEnemyStatusConditionsDone ld a, $1 and a ; clear Z flag ret @@ -7114,13 +7122,13 @@ MoveEffectPointerTable: ; 3f150 (f:7150) dw SwitchAndTeleportEffect ; SWITCH_AND_TELEPORT_EFFECT dw TwoToFiveAttacksEffect ; TWO_TO_FIVE_ATTACKS_EFFECT dw TwoToFiveAttacksEffect ; unused effect - dw FlichSideEffect ; FLINCH_SIDE_EFFECT1 + dw FlinchSideEffect ; FLINCH_SIDE_EFFECT1 dw SleepEffect ; SLEEP_EFFECT dw PoisonEffect ; POISON_SIDE_EFFECT2 dw FreezeBurnParalyzeEffect ; BURN_SIDE_EFFECT2 dw FreezeBurnParalyzeEffect ; unused effect dw FreezeBurnParalyzeEffect ; PARALYZE_SIDE_EFFECT2 - dw FlichSideEffect ; FLINCH_SIDE_EFFECT2 + dw FlinchSideEffect ; FLINCH_SIDE_EFFECT2 dw OneHitKOEffect ; OHKO_EFFECT dw ChargeEffect ; CHARGE_EFFECT dw $0000 ; SUPER_FANG_EFFECT @@ -7186,7 +7194,7 @@ SleepEffect: ; 3f1fc (f:71fc) res 5, a ; target no longer needs to recharge ld [bc], a jr nz, .setSleepCounter ; if the target had to recharge, all hit tests will be skipped - ; including the event where the target already has another status + ; including the event where the target already has another status ld a, [de] ld b, a and $7 @@ -7393,7 +7401,7 @@ FreezeBurnParalyzeEffect: ; 3f30c (f:730c) ld hl, BurnedText jp PrintText .freeze - call ClearHyperBeam ; resets hyper beam (recharge) condition from both players + call ClearHyperBeam ; resets hyper beam (recharge) condition from target ld a, 1 << FRZ ld [wEnemyMonStatus], a ld a, ANIM_A9 @@ -7556,7 +7564,7 @@ StatModifierUpEffect: ; 3f428 (f:7428) sbc $3 jp z, Func_3f520 .recalculateStat ; recalculate affected stat - ; paralysis and burn penalties, as well as badge boosts are ignored + ; paralysis and burn penalties, as well as badge boosts are ignored push hl push bc ld hl, StatModifierRatios @@ -7639,7 +7647,7 @@ UpdateStatDone: ; 3f4ca (f:74ca) ld a, [H_WHOSETURN] and a call z, ApplyBadgeStatBoosts ; whenever the player uses a stat-up move, badge boosts get reapplied again to every stat, - ; even to those not affected by the stat-up move (will be boosted further) + ; even to those not affected by the stat-up move (will be boosted further) ld hl, MonsStatsRoseText call PrintText @@ -7829,7 +7837,7 @@ UpdateStat2Done: ; 3f62c (f:762c) ld a, [H_WHOSETURN] and a call nz, ApplyBadgeStatBoosts ; whenever the player uses a stat-down move, badge boosts get reapplied again to every stat, - ; even to those not affected by the stat-up move (will be boosted further) + ; even to those not affected by the stat-up move (will be boosted further) ld hl, MonsStatsFellText call PrintText @@ -8128,23 +8136,23 @@ TwoToFiveAttacksEffect: ; 3f811 (f:7811) ld [hl], a ; set Twineedle's effect to poison effect jr .saveNumberOfHits -FlichSideEffect: ; 3f85b (f:785b) +FlinchSideEffect: ; 3f85b (f:785b) call CheckTargetSubstitute ret nz ld hl, W_ENEMYBATTSTATUS1 ld de, W_PLAYERMOVEEFFECT ld a, [H_WHOSETURN] and a - jr z, .asm_3f870 + jr z, .flinchSideEffect ld hl, W_PLAYERBATTSTATUS1 ld de, W_ENEMYMOVEEFFECT -.asm_3f870 +.flinchSideEffect ld a, [de] cp FLINCH_SIDE_EFFECT1 ld b, $1a ; ~10% chance of flinch - jr z, .asm_3f879 + jr z, .gotEffectChance ld b, $4d ; ~30% chance of flinch -.asm_3f879 +.gotEffectChance call BattleRandom cp b ret nc @@ -8163,25 +8171,25 @@ ChargeEffect: ; 3f88c (f:788c) ld a, [H_WHOSETURN] and a ld b, XSTATITEM_ANIM - jr z, .asm_3f8a1 + jr z, .chargeEffect ld hl, W_ENEMYBATTSTATUS1 ld de, W_ENEMYMOVEEFFECT ld b, ANIM_AF -.asm_3f8a1 +.chargeEffect set 4, [hl] ld a, [de] dec de ; de contains enemy or player MOVENUM cp FLY_EFFECT - jr nz, .asm_3f8ad + jr nz, .notFly set 6, [hl] ; mon is now invulnerable to typical attacks (fly/dig) - ld b, TELEPORT -.asm_3f8ad + ld b, TELEPORT ; load Teleport's animation +.notFly ld a, [de] cp DIG - jr nz, .asm_3f8b6 + jr nz, .notDigOrFly set 6, [hl] ; mon is now invulnerable to typical attacks (fly/dig) ld b, ANIM_C0 -.asm_3f8b6 +.notDigOrFly xor a ld [wcc5b], a ld a, b @@ -8244,21 +8252,22 @@ TrappingEffect: ; 3f917 (f:7917) ld de, wPlayerNumAttacksLeft ld a, [H_WHOSETURN] and a - jr z, .asm_3f928 + jr z, .trappingEffect ld hl, W_ENEMYBATTSTATUS1 ld de, wEnemyNumAttacksLeft -.asm_3f928 +.trappingEffect bit 5, [hl] ret nz - call ClearHyperBeam - set 5, [hl] - call BattleRandom + call ClearHyperBeam ; since this effect is called before testing whether the move will hit, + ; the target won't need to recharge even if the trapping move missed + set 5, [hl] ; mon is now using a trapping move + call BattleRandom ; 3/8 chance for 2 and 3 attacks, and 1/8 chance for 4 and 5 attacks and $3 cp $2 - jr c, .asm_3f93e + jr c, .setTrappingCounter call BattleRandom and $3 -.asm_3f93e +.setTrappingCounter inc a ld [de], a ret @@ -8282,36 +8291,36 @@ ConfusionSideEffect: ; 3f959 (f:7959) call BattleRandom cp $19 ret nc - jr Func_3f96f + jr ConfusionSideEffectSuccess ConfusionEffect: ; 3f961 (f:7961) call CheckTargetSubstitute - jr nz, Func_3f9a6 + jr nz, ConfusionEffectFailed call MoveHitTest ld a, [W_MOVEMISSED] and a - jr nz, Func_3f9a6 + jr nz, ConfusionEffectFailed -Func_3f96f: ; 3f96f (f:796f) +ConfusionSideEffectSuccess: ; 3f96f (f:796f) ld a, [H_WHOSETURN] and a ld hl, W_ENEMYBATTSTATUS1 - ld bc, wd070 + ld bc, W_ENEMYCONFUSEDCOUNTER ld a, [W_PLAYERMOVEEFFECT] - jr z, .asm_3f986 + jr z, .confuseTarget ld hl, W_PLAYERBATTSTATUS1 - ld bc, wd06b + ld bc, W_PLAYERCONFUSEDCOUNTER ld a, [W_ENEMYMOVEEFFECT] -.asm_3f986 +.confuseTarget bit 7, [hl] ; is mon confused? - jr nz, Func_3f9a6 + jr nz, ConfusionEffectFailed set 7, [hl] ; mon is now confused push af call BattleRandom - and $3 + and $3 inc a inc a - ld [bc], a + ld [bc], a ; confusion status will last 2-5 turns pop af cp CONFUSION_SIDE_EFFECT call nz, Func_3fb89 @@ -8322,7 +8331,7 @@ BecameConfusedText: ; 3f9a1 (f:79a1) TX_FAR _BecameConfusedText db "@" -Func_3f9a6: ; 3f9a6 (f:79a6) +ConfusionEffectFailed: ; 3f9a6 (f:79a6) cp CONFUSION_SIDE_EFFECT ret z ld c, $32 @@ -8343,9 +8352,9 @@ HyperBeamEffect: ; 3f9c1 (f:79c1) ld hl, W_PLAYERBATTSTATUS2 ld a, [H_WHOSETURN] and a - jr z, .asm_3f9cc + jr z, .hyperBeamEffect ld hl, W_ENEMYBATTSTATUS2 -.asm_3f9cc +.hyperBeamEffect set 5, [hl] ; mon now needs to recharge ret diff --git a/wram.asm b/wram.asm index f0e06a0e92..1ff0a6a971 100755 --- a/wram.asm +++ b/wram.asm @@ -379,8 +379,8 @@ wcced:: ds 1 wccee:: ds 1 wccef:: ds 1 wccf0:: ds 1 -wccf1:: ds 1 -wccf2:: ds 1 +wPlayerUsedMove:: ds 1 +wEnemyUsedMove:: ds 1 wccf3:: ds 1 wccf4:: ds 1 @@ -935,7 +935,8 @@ wPlayerNumAttacksLeft:: ; when the player is attacking multiple times, the number of attacks left ds 1 -wd06b:: ds 1 +W_PLAYERCONFUSEDCOUNTER:: ; wd06b + ds 1 W_PLAYERTOXICCOUNTER:: ; d06c ds 1 @@ -945,10 +946,11 @@ W_PLAYERDISABLEDMOVE:: ; d06d ds 1 wEnemyNumAttacksLeft:: -; when the player is attacking multiple times, the number of attacks left +; when the enemy is attacking multiple times, the number of attacks left ds 1 -wd070:: ds 1 +W_ENEMYCONFUSEDCOUNTER:: ; wd070 + ds 1 W_ENEMYTOXICCOUNTER:: ; d071 ds 1 From 9de54645c896cc57a79679aecd6174afc59762c8 Mon Sep 17 00:00:00 2001 From: xCrystal Date: Tue, 3 Feb 2015 20:51:53 +0100 Subject: [PATCH 085/100] add constants for volatile statuses and more battle labels/commentary/constants --- constants/status_constants.asm | 30 ++- engine/battle/1.asm | 10 +- engine/battle/14.asm | 10 +- engine/battle/1a.asm | 27 ++- engine/battle/4_2.asm | 64 ++--- engine/battle/5.asm | 12 +- engine/battle/9.asm | 4 +- engine/battle/a.asm | 4 +- engine/battle/b_2.asm | 22 +- engine/battle/c.asm | 10 +- engine/battle/core.asm | 414 +++++++++++++++++---------------- engine/battle/e_2.asm | 14 +- engine/items/items.asm | 14 +- wram.asm | 8 +- 14 files changed, 341 insertions(+), 302 deletions(-) diff --git a/constants/status_constants.asm b/constants/status_constants.asm index 866ea03c17..3b5aee0686 100755 --- a/constants/status_constants.asm +++ b/constants/status_constants.asm @@ -1,6 +1,32 @@ -; status ailments -SLP EQU %111 ; mask +; non-volatile statuses +SLP EQU %111 ; sleep counter PSN EQU 3 BRN EQU 4 FRZ EQU 5 PAR EQU 6 + +; volatile statuses 1 +StoringEnergy EQU 0 ; Bide +ThrashingAbout EQU 1 ; e.g. Thrash +AttackingMultipleTimes EQU 2 ; e.g. Double Kick, Fury Attack +Flinched EQU 3 +ChargingUp EQU 4 ; e.g. Solar Beam, Fly +UsingTrappingMove EQU 5 ; e.g. Wrap +Invulnerable EQU 6 ; charging up Fly/Dig +Confused EQU 7 + +; volatile statuses 2 +UsingXAccuracy EQU 0 +ProtectedByMist EQU 1 +GettingPumped EQU 2 ; Focus Energy +; EQU 3 ; unused? +HasSubstituteUp EQU 4 +NeedsToRecharge EQU 5 ; Hyper Beam +UsingRage EQU 6 +Seeded EQU 7 + +; volatile statuses 3 +BadlyPoisoned EQU 0 +HasLightScreenUp EQU 1 +HasReflectUp EQU 2 +Transformed EQU 3 diff --git a/engine/battle/1.asm b/engine/battle/1.asm index fdf2841dcc..e28cd0568b 100755 --- a/engine/battle/1.asm +++ b/engine/battle/1.asm @@ -1,5 +1,5 @@ DrainHPEffect_: ; 783f (1:783f) - ld hl, W_DAMAGE ; W_DAMAGE + ld hl, W_DAMAGE ld a, [hl] srl a ; divide damage by 2 ld [hli], a @@ -16,8 +16,8 @@ DrainHPEffect_: ; 783f (1:783f) ld a, [H_WHOSETURN] ; $fff3 and a jp z, Func_7861 - ld hl, wEnemyMonHP ; wEnemyMonHP - ld de, wEnemyMonMaxHP ; wEnemyMonMaxHP + ld hl, wEnemyMonHP + ld de, wEnemyMonMaxHP Func_7861: ; 7861 (1:7861) ld bc, wHPBarOldHP+1 @@ -38,7 +38,7 @@ Func_7861: ; 7861 (1:7861) add b ld [hld], a ld [wHPBarNewHP], a - ld a, [W_DAMAGE] ; W_DAMAGE + ld a, [W_DAMAGE] ld b, [hl] adc b ld [hli], a @@ -83,7 +83,7 @@ Func_7861: ; 7861 (1:7861) and a ld a, [W_PLAYERMOVEEFFECT] ; wcfd3 jr z, .asm_78d2 - ld a, [W_ENEMYMOVEEFFECT] ; W_ENEMYMOVEEFFECT + ld a, [W_ENEMYMOVEEFFECT] .asm_78d2 cp DREAM_EATER_EFFECT jr nz, .asm_78d9 diff --git a/engine/battle/14.asm b/engine/battle/14.asm index 18aaa5e1b8..cabaae071f 100755 --- a/engine/battle/14.asm +++ b/engine/battle/14.asm @@ -13,7 +13,7 @@ Func_525af: ; 525af (14:65af) ld [wCriticalHitOrOHKO], a ld [wBattleMonSpecies], a ld [wPartyGainExpFlags], a - ld [wPlayerMonNumber], a ; wPlayerMonNumber + ld [wPlayerMonNumber], a ld [wEscapedFromBattle], a ld [wMapPalOffset], a ld hl, wcf1d @@ -27,7 +27,7 @@ Func_525af: ; 525af (14:65af) jr nz, .asm_525e1 inc a ld [wccd9], a - ld a, [W_CURMAP] ; W_CURMAP + ld a, [W_CURMAP] cp SAFARI_ZONE_EAST jr c, .asm_525f9 cp SAFARI_ZONE_REST_HOUSE_1 @@ -45,7 +45,7 @@ ParalyzeEffect_: ; 52601 (14:6601) ld a, [H_WHOSETURN] ; $fff3 and a jp z, .asm_52613 - ld hl, wBattleMonStatus ; wBattleMonStatus + ld hl, wBattleMonStatus ld de, W_ENEMYMOVETYPE ; wcfcf .asm_52613 @@ -69,10 +69,10 @@ ParalyzeEffect_: ; 52601 (14:6601) push hl callab MoveHitTest pop hl - ld a, [W_MOVEMISSED] ; W_MOVEMISSED + ld a, [W_MOVEMISSED] and a jr nz, .asm_52659 - set 6, [hl] + set PAR, [hl] callab QuarterSpeedDueToParalysis ld c, $1e call DelayFrames diff --git a/engine/battle/1a.asm b/engine/battle/1a.asm index 6b502a3197..ecf5040b24 100755 --- a/engine/battle/1a.asm +++ b/engine/battle/1a.asm @@ -7,16 +7,19 @@ DecrementPP: ; 68000 (1a:4000) ld hl, W_PLAYERBATTSTATUS1 ld a, [hli] ; load the W_PLAYERBATTSTATUS1 pokemon status flags and increment hl to load the ; W_PLAYERBATTSTATUS2 status flags later - and a, 7 ; check to see if bits 0, 1, or 2 are set + and a, (1 << StoringEnergy) | (1 << ThrashingAbout) | (1 << AttackingMultipleTimes) ret nz ; if any of these statuses are true, don't decrement PP - bit 6, [hl] ; check 6th bit status flag on W_PLAYERBATTSTATUS2 - ret nz ; and return if it is set + bit UsingRage, [hl] + ret nz ; don't decrement PP either if Pokemon is using Rage ld hl, wBattleMonPP ; PP of first move (in battle) - call .DecrementPP - - ld a, [W_PLAYERBATTSTATUS3] ; load pokemon status bits? - bit 3, a ; XXX transform status? - ret nz ; If it is, return. Pokemon Red stores the "current pokemon's" PP + +; decrement PP in the battle struct + call .DecrementPP + +; decrement PP in the party struct + ld a, [W_PLAYERBATTSTATUS3] + bit Transformed, a + ret nz ; Return if transformed. Pokemon Red stores the "current pokemon's" PP ; separately from the "Pokemon in your party's" PP. This is ; duplication -- in all cases *other* than Pokemon with Transform. ; Normally, this means we have to go on and make the same @@ -26,12 +29,12 @@ DecrementPP: ; 68000 (1a:4000) ; its opponent, which is *not* the same as its real PP as part of your ; party. So we return, and don't do that part. - ld hl, wPartyMon1PP ; PP of first move (in party) - ld a, [wPlayerMonNumber] ; which mon in party is active - ld bc, $2C ; XXX probably size of party pokemon's data structure + ld hl, wPartyMon1PP ; PP of first move (in party) + ld a, [wPlayerMonNumber] ; which mon in party is active + ld bc, wPartyMon2 - wPartyMon1 call AddNTimes ; calculate address of the mon to modify .DecrementPP - ld a, [wPlayerMoveListIndex] ; which move (0, 1, 2, 3) did we use? + ld a, [wPlayerMoveListIndex] ; which move (0, 1, 2, 3) did we use? ld c, a ld b, 0 add hl ,bc ; calculate the address in memory of the PP we need to decrement diff --git a/engine/battle/4_2.asm b/engine/battle/4_2.asm index ef4798bd95..6ab5c00494 100755 --- a/engine/battle/4_2.asm +++ b/engine/battle/4_2.asm @@ -103,15 +103,15 @@ Func_13870: ; 13870 (4:7870) .asm_13888 callab Func_128d8 jr z, .asm_13884 - ld a, [wd0db] + ld a, [wRepelRemainingSteps] and a jr z, .asm_1389e dec a - jr z, .asm_13905 - ld [wd0db], a + jr z, .lastRepelStep + ld [wRepelRemainingSteps], a .asm_1389e -; determine if wild pokémon can appear where we’re standing. -; are we standing in grass/water? +; determine if wild pokémon can appear in the half-block we’re standing +; is the bottom right tile (9,9) of the half-block are we standing a grass/water tile? hlCoord 9, 9 ld c, [hl] ld a, [W_GRASSTILE] @@ -133,6 +133,7 @@ Func_13870: ; 13870 (4:7870) jr z, .CantEncounter ld a, [W_GRASSRATE] .CanEncounter +; weigh encounter chance to a random number to determine if there will be an encounter ld b, a ld a, [hRandomAdd] cp b @@ -140,20 +141,23 @@ Func_13870: ; 13870 (4:7870) ld a, [hRandomSub] ld b, a ld hl, WildMonEncounterSlotChances -.asm_138d0 +.determineEncounterSlot ld a, [hli] cp b - jr nc, .asm_138d7 + jr nc, .gotEncounterSlot inc hl - jr .asm_138d0 -.asm_138d7 + jr .determineEncounterSlot +.gotEncounterSlot +; determine which wild pokémon (grass or water) can appear in the half-block we’re standing ld c, [hl] ld hl, W_GRASSMONS - aCoord 8, 9 - cp $14 - jr nz, .asm_138e5 + aCoord 8, 9 + cp $14 ; is the bottom left tile (8,9) of the half-block are we standing a water tile? + jr nz, .gotWildEncounterType ; else, it's treated as a grass tile by default ld hl, W_WATERMONS -.asm_138e5 +; since the bottom right tile of a "left shore" half-block is $14 but the bottom left tile is not, +; "left shore" half-blocks (such as the one in the east coast of Cinnabar), load grass encounters. +.gotWildEncounterType ld b, $0 add hl, bc ld a, [hli] @@ -161,17 +165,17 @@ Func_13870: ; 13870 (4:7870) ld a, [hl] ld [wcf91], a ld [wEnemyMonSpecies2], a - ld a, [wd0db] + ld a, [wRepelRemainingSteps] and a - jr z, .asm_13916 + jr z, .willEncounter ld a, [wPartyMon1Level] ld b, a ld a, [W_CURENEMYLVL] cp b jr c, .CantEncounter - jr .asm_13916 -.asm_13905 - ld [wd0db], a + jr .willEncounter +.lastRepelStep + ld [wRepelRemainingSteps], a ld a, $d2 ld [H_DOWNARROWBLINKCNT2], a ; $ff8c call EnableAutoTextBoxDrawing @@ -180,7 +184,7 @@ Func_13870: ; 13870 (4:7870) ld a, $1 and a ret -.asm_13916 +.willEncounter xor a ret @@ -282,7 +286,7 @@ ConversionEffect_: ; 139a3 (4:79a3) pop de ld a, [W_PLAYERBATTSTATUS1] .asm_139b8 - bit 6, a ; is mon immune to typical attacks (dig/fly) + bit Invulnerable, a ; is mon immune to typical attacks (dig/fly) jr nz, PrintButItFailedText ld a, [hli] ld [de], a @@ -340,22 +344,22 @@ HazeEffect_: ; 139da (4:79da) ld [hli], a ld [hl], a ld hl, W_PLAYERBATTSTATUS1 - call Func_13a37 + call CureStatuses ld hl, W_ENEMYBATTSTATUS1 - call Func_13a37 + call CureStatuses ld hl, Func_3fba8 call Func_139d5 ld hl, StatusChangesEliminatedText jp PrintText -Func_13a37: ; 13a37 (4:7a37) - res 7, [hl] - inc hl +CureStatuses: ; 13a37 (4:7a37) + res Confused, [hl] + inc hl ; BATTSTATUS2 ld a, [hl] - and $78 - ld [hli], a + and (1 << UsingRage) | (1 << NeedsToRecharge) | (1 << HasSubstituteUp) | (1 << 3) ; clear all but these from BATTSTATUS2 + ld [hli], a ; BATTSTATUS3 ld a, [hl] - and $f8 + and %11110000 | (1 << Transformed) ; clear Bad Poison, Reflect and Light Screen statuses ld [hl], a ret @@ -382,8 +386,8 @@ StatusChangesEliminatedText: ; 13a53 (4:7a53) db "@" GetTrainerName_: ; 13a58 (4:7a58) - ld hl, W_GRASSRATE ; W_GRASSRATE - ld a, [W_ISLINKBATTLE] ; W_ISLINKBATTLE + ld hl, W_GRASSRATE + ld a, [W_ISLINKBATTLE] and a jr nz, .rival ld hl, W_RIVALNAME ; wd34a diff --git a/engine/battle/5.asm b/engine/battle/5.asm index 82518052a9..e534470d99 100755 --- a/engine/battle/5.asm +++ b/engine/battle/5.asm @@ -12,7 +12,7 @@ SubstituteEffectHandler: ; 17dad (5:7dad) ld bc, W_ENEMYBATTSTATUS2 .notEnemy ld a, [bc] ;load flags - bit 4, a ;user already has substitute? + bit HasSubstituteUp, a ;user already has substitute? jr nz, .alreadyHasSubstitute ;skip this code if so ;user doesn't have a substitute [yet] push bc @@ -41,13 +41,13 @@ SubstituteEffectHandler: ; 17dad (5:7dad) ld [hl], d ;store low byte HP ld h, b ld l, c - set 4, [hl] ;set bit 4 of flags, user now has substitute - ld a, [W_OPTIONS] ;load options - bit 7, a ;battle animation is enabled? - ld hl, Func_3fba8 ; $7ba8 ;animation enabled: 0F:7BA8 + set HasSubstituteUp, [hl] ;set bit 4 of flags, user now has substitute + ld a, [W_OPTIONS] ;load options + bit 7, a ;battle animation is enabled? + ld hl, Func_3fba8 ;animation enabled: 0F:7BA8 ld b, BANK(Func_3fba8) jr z, .animationEnabled - ld hl, AnimationSubstitute ;animation disabled: 1E:56E0 + ld hl, AnimationSubstitute ;animation disabled: 1E:56E0 ld b, BANK(AnimationSubstitute) .animationEnabled call Bankswitch ;jump to routine depending on animation setting diff --git a/engine/battle/9.asm b/engine/battle/9.asm index 26f65317b1..eb86cce058 100755 --- a/engine/battle/9.asm +++ b/engine/battle/9.asm @@ -163,9 +163,9 @@ FocusEnergyEffect_: ; 27f86 (9:7f86) jr z, .asm_27f91 ld hl, W_ENEMYBATTSTATUS2 ; W_ENEMYBATTSTATUS2 .asm_27f91 - bit 2, [hl] ; is mon already using focus energy? + bit GettingPumped, [hl] ; is mon already using focus energy? jr nz, .asm_27fa5 - set 2, [hl] ; mon is now using focus energy + set GettingPumped, [hl] ; mon is now using focus energy callab Func_3fba8 ld hl, GettingPumpedText ; $7fb2 jp PrintText diff --git a/engine/battle/a.asm b/engine/battle/a.asm index fd3ef40b0f..917a462b6a 100755 --- a/engine/battle/a.asm +++ b/engine/battle/a.asm @@ -18,9 +18,9 @@ LeechSeedEffect_: ; 2bea9 (a:7ea9) ld a, [de] cp GRASS jr z, .asm_2bee7 - bit 7, [hl] + bit Seeded, [hl] jr nz, .asm_2bee7 - set 7, [hl] + set Seeded, [hl] callab Func_3fba8 ld hl, WasSeededText ; $7ef2 jp PrintText diff --git a/engine/battle/b_2.asm b/engine/battle/b_2.asm index 4ff8b66b46..4a49bb1054 100755 --- a/engine/battle/b_2.asm +++ b/engine/battle/b_2.asm @@ -95,27 +95,27 @@ PayDayEffect_ ; 2feb8 (b:7eb8) ld a, [wEnemyMonLevel] .asm_2fec8 add a - ld [$ff98], a + ld [H_DIVIDEND + 3], a xor a - ld [$ff95], a - ld [$ff96], a - ld [$ff97], a + ld [H_DIVIDEND], a + ld [H_DIVIDEND + 1], a + ld [H_DIVIDEND + 2], a ld a, $64 - ld [$ff99], a + ld [H_DIVISOR], a ld b, $4 call Divide - ld a, [$ff98] + ld a, [H_QUOTIENT + 3] ld [hli], a - ld a, [$ff99] - ld [$ff98], a + ld a, [H_REMAINDER] + ld [H_DIVIDEND + 3], a ld a, $a - ld [$ff99], a + ld [H_DIVISOR], a ld b, $4 call Divide - ld a, [$ff98] + ld a, [H_QUOTIENT + 3] swap a ld b, a - ld a, [$ff99] + ld a, [H_REMAINDER] add b ld [hl], a ld de, wTotalPayDayMoney + 2 diff --git a/engine/battle/c.asm b/engine/battle/c.asm index e31b1fce98..07369375ed 100755 --- a/engine/battle/c.asm +++ b/engine/battle/c.asm @@ -5,9 +5,9 @@ MistEffect_: ; 33f2b (c:7f2b) jr z, .asm_33f36 ld hl, W_ENEMYBATTSTATUS2 .asm_33f36 - bit 1, [hl] ; is mon protected by mist? + bit ProtectedByMist, [hl] ; is mon protected by mist? jr nz, .asm_33f4a - set 1, [hl] ; mon is now protected by mist + set ProtectedByMist, [hl] ; mon is now protected by mist callab Func_3fba8 ld hl, ShroudedInMistText jp PrintText @@ -21,7 +21,7 @@ ShroudedInMistText: ; 33f52 (c:7f52) db "@" OneHitKOEffect_: ; 33f57 (c:7f57) - ld hl, W_DAMAGE ; W_DAMAGE + ld hl, W_DAMAGE xor a ld [hli], a ld [hl], a ; set the damage output to zero @@ -45,7 +45,7 @@ OneHitKOEffect_: ; 33f57 (c:7f57) ld a, [hl] sbc b jr c, .asm_33f8a - ld hl, W_DAMAGE ; W_DAMAGE + ld hl, W_DAMAGE ld a, $ff ld [hli], a ld [hl], a @@ -54,5 +54,5 @@ OneHitKOEffect_: ; 33f57 (c:7f57) ret .asm_33f8a ld a, $1 - ld [W_MOVEMISSED], a ; W_MOVEMISSED + ld [W_MOVEMISSED], a ret diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 90c296e4d9..381c82b151 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -385,15 +385,15 @@ MainInBattleLoop: ; 3c233 (f:4233) xor a ld [wd11d], a ld a, [W_PLAYERBATTSTATUS2] - and %01100000 ; check if the player is using Rage or needs to recharge + and (1 << NeedsToRecharge) | (1 << UsingRage) ; check if the player is using Rage or needs to recharge jr nz, .selectEnemyMove ; the player is not using Rage and doesn't need to recharge ld hl, W_ENEMYBATTSTATUS1 - res 3, [hl] ; reset flinch bit + res Flinched, [hl] ; reset flinch bit ld hl, W_PLAYERBATTSTATUS1 - res 3, [hl] ; reset flinch bit + res Flinched, [hl] ; reset flinch bit ld a, [hl] - and %00010010 ; check if the player is thrashing about or charging for an attack + and (1 << ThrashingAbout) | (1 << ChargingUp) ; check if the player is thrashing about or charging for an attack jr nz, .selectEnemyMove ; if so, jump ; the player is neither thrashing about nor charging for an attack call DisplayBattleMenu ; show battle menu @@ -405,10 +405,10 @@ MainInBattleLoop: ; 3c233 (f:4233) and (1 << FRZ) | SLP ; is mon frozen or asleep? jr nz, .selectEnemyMove ; if so, jump ld a, [W_PLAYERBATTSTATUS1] - and %00100001 ; check player is using Bide or using a multi-turn attack like wrap + and (1 << StoringEnergy) | (1 << UsingTrappingMove) ; check player is using Bide or using a multi-turn attack like wrap jr nz, .selectEnemyMove ; if so, jump ld a, [W_ENEMYBATTSTATUS1] - bit 5, a ; check if enemy is using a multi-turn attack like wrap + bit UsingTrappingMove, a ; check if enemy is using a multi-turn attack like wrap jr z, .selectPlayerMove ; if not, jump ; enemy is using a mult-turn attack like wrap, so player is trapped and cannot execute a move ld a, $ff @@ -446,7 +446,7 @@ MainInBattleLoop: ; 3c233 (f:4233) jr c, .noLinkBattle ; the link battle enemy has switched mons ld a, [W_PLAYERBATTSTATUS1] - bit 5, a ; check if using multi-turn move like Wrap + bit UsingTrappingMove, a ; check if using multi-turn move like Wrap jr z, .asm_3c2dd ld a, [wPlayerMoveListIndex] ld hl, wBattleMonMoves @@ -670,7 +670,7 @@ HandlePoisonBurnLeechSeed_DecreaseOwnHP: ; 3c43d (f:443d) ld hl, W_ENEMYBATTSTATUS3 ld de, W_ENEMYTOXICCOUNTER .playersTurn - bit 0, [hl] + bit BadlyPoisoned, [hl] jr z, .noToxic ld a, [de] ; increment toxic counter inc a @@ -779,14 +779,14 @@ CheckNumAttacksLeft: ; 3c50f (f:450f) jr nz, .checkEnemy ; player has 0 attacks left ld hl, W_PLAYERBATTSTATUS1 - res 5, [hl] ; player not using multi-turn attack like wrap any more + res UsingTrappingMove, [hl] ; player not using multi-turn attack like wrap any more .checkEnemy ld a, [wEnemyNumAttacksLeft] and a ret nz ; enemy has 0 attacks left ld hl, W_ENEMYBATTSTATUS1 - res 5, [hl] ; enemy not using multi-turn attack like wrap any more + res UsingTrappingMove, [hl] ; enemy not using multi-turn attack like wrap any more ret HandleEnemyMonFainted: ; 3c525 (f:4525) @@ -836,7 +836,7 @@ FaintEnemyPokemon ; 0x3c567 ld [hl], a .wild ld hl, W_PLAYERBATTSTATUS1 - res 2, [hl] + res AttackingMultipleTimes, [hl] xor a ld [W_NUMHITS], a ld hl, wd065 ; clear enemy statuses @@ -958,15 +958,15 @@ AnyEnemyPokemonAliveCheck: ; 3c64f (f:464f) ld b, a xor a ld hl, wEnemyMon1HP - ld de, $2c -.asm_3c65a + ld de, wEnemyMon2 - wEnemyMon1 +.nextPokemon or [hl] inc hl or [hl] dec hl add hl, de dec b - jr nz, .asm_3c65a + jr nz, .nextPokemon and a ret @@ -978,14 +978,14 @@ ReplaceFaintedEnemyMon: ; 3c664 (f:4664) callab DrawEnemyPokeballs ld a, [W_ISLINKBATTLE] cp $4 - jr nz, .asm_3c687 + jr nz, .notLinkBattle ; link battle call LinkBattleExchangeData ld a, [wcc3e] cp $f ret z call LoadScreenTilesFromBuffer1 -.asm_3c687 +.notLinkBattle call EnemySendOut xor a ld [W_ENEMYMOVENUM], a @@ -1171,11 +1171,11 @@ ChooseNextMon: ; 3c7d8 (f:47d8) jr z, .goBackToPartyMenu ; if mon fainted, you have to choose another ld a, [W_ISLINKBATTLE] cp $4 - jr nz, .asm_3c7fa + jr nz, .notLinkBattle inc a ld [wcd6a], a call LinkBattleExchangeData -.asm_3c7fa +.notLinkBattle xor a ld [wcd6a], a call ClearSprites @@ -1825,7 +1825,7 @@ SendOutMon: ; 3cc91 (f:4c91) ld b, $1 call GoPAL_SET ld hl, W_ENEMYBATTSTATUS1 - res 5, [hl] + res UsingTrappingMove, [hl] ld a, $1 ld [H_WHOSETURN], a ld a, POOF_ANIM @@ -2093,14 +2093,14 @@ DisplayBattleMenu: ; 3ceb3 (f:4eb3) ld bc, $b call CopyData ; temporarily save the player name in unused space, ; which is supposed to get overwritten when entering a - ; map with wild pokémon. due to an oversight, the data + ; map with wild Pokémon. Due to an oversight, the data ; may not get overwritten (cinnabar) and the infamous - ; missingno. glitch can show up. + ; Missingno. glitch can show up. ld hl, .oldManName ld de, wPlayerName ld bc, $b call CopyData - ; the following simulates the keystrokes by drawing menus on screen +; the following simulates the keystrokes by drawing menus on screen hlCoord 9, 14 ld [hl], "▶" ld c, $50 @@ -2323,13 +2323,13 @@ UseBagItem: jp z, BagWasSelected ; if not, go back to the bag menu ld a, [W_PLAYERBATTSTATUS1] - bit 5, a ; is the player using a multi-turn move like wrap? + bit UsingTrappingMove, a ; is the player using a multi-turn move like wrap? jr z, .checkIfMonCaptured ld hl, wPlayerNumAttacksLeft dec [hl] jr nz, .checkIfMonCaptured ld hl, W_PLAYERBATTSTATUS1 - res 5, [hl] ; not using multi-turn move any more + res UsingTrappingMove, [hl] ; not using multi-turn move any more .checkIfMonCaptured ld a, [wd11c] @@ -2436,7 +2436,7 @@ PartyMenuOrRockOrRun: predef StatusScreen2 ; now we need to reload the enemy mon pic ld a, [W_ENEMYBATTSTATUS2] - bit 4, a ; does the enemy mon have a substitute? + bit HasSubstituteUp, a ; does the enemy mon have a substitute? ld hl, AnimationSubstitute jr nz, .doEnemyMonAnimation ; enemy mon doesn't have substitute @@ -2771,7 +2771,6 @@ CursorDown: ; 3d3dd (f:53dd) AnyMoveToSelect: ; 3d3f5 (f:53f5) ; return z and Struggle as the selected move if all moves have 0 PP and/or are disabled - ld a, STRUGGLE ld [wPlayerSelectedMove], a ld a, [W_PLAYERDISABLEDMOVE] @@ -2986,7 +2985,7 @@ SelectEnemyMove: ; 3d564 (f:5564) cp $e jp z, .asm_3d601 cp $d - jr z, .unableToMove + jr z, .unableToSelectMove cp $4 ret nc ld [wEnemyMoveListIndex], a @@ -2998,25 +2997,25 @@ SelectEnemyMove: ; 3d564 (f:5564) jr .done .noLinkBattle ld a, [W_ENEMYBATTSTATUS2] - and $60 ; need to recharge or using rage + and (1 << NeedsToRecharge) | (1 << UsingRage) ; need to recharge or using rage ret nz ld hl, W_ENEMYBATTSTATUS1 ld a, [hl] - and $12 ; using multi-turn move or bide + and (1 << ChargingUp) | (1 << ThrashingAbout) ; using a charging move or thrash/petal dance ret nz ld a, [wEnemyMonStatus] and SLP | 1 << FRZ ; sleeping or frozen ret nz ld a, [W_ENEMYBATTSTATUS1] - and $21 ; using fly/dig or thrash/petal dance + and (1 << UsingTrappingMove) | (1 << StoringEnergy) ; using a trapping move like wrap or bide ret nz ld a, [W_PLAYERBATTSTATUS1] - bit 5, a ; caught in player's multi-turn move (e.g. wrap) - jr z, .notCaughtInWrap -.unableToMove + bit UsingTrappingMove, a ; caught in player's trapping move (e.g. wrap) + jr z, .canSelectMove +.unableToSelectMove ld a, $ff jr .done -.notCaughtInWrap +.canSelectMove ld hl, wEnemyMonMoves+1 ; 2nd enemy move ld a, [hld] and a @@ -3137,12 +3136,12 @@ ExecutePlayerMove: ; 3d65e (f:565e) .playerHasNoSpecialCondition call GetCurrentMove ld hl, W_PLAYERBATTSTATUS1 - bit 4, [hl] ; charging up for attack + bit ChargingUp, [hl] ; charging up for attack jr nz, PlayerCanExecuteChargingMove call CheckForDisobedience jp z, ExecutePlayerMoveDone -Func_3d69a: ; 3d69a (f:569a) +CheckIfPlayerNeedsToChargeUp: ; 3d69a (f:569a) ld a, [W_PLAYERMOVEEFFECT] cp CHARGE_EFFECT jp z, JumpMoveEffect @@ -3153,10 +3152,10 @@ Func_3d69a: ; 3d69a (f:569a) ; in-battle stuff PlayerCanExecuteChargingMove: ; 3d6a9 (f:56a9) ld hl,W_PLAYERBATTSTATUS1 - res 4,[hl] ; reset charging up and invulnerability statuses if mon was charging up for an attack + res ChargingUp,[hl] ; reset charging up and invulnerability statuses if mon was charging up for an attack ; being fully paralyzed or hurting oneself in confusion removes charging up status ; resulting in the Pokemon being invulnerable for the whole battle - res 6,[hl] + res Invulnerable,[hl] PlayerCanExecuteMove: ; 3d6b0 (f:56b0) call PrintMonName1Text ld hl,DecrementPP @@ -3246,12 +3245,12 @@ MirrorMoveCheck jp z,ExecutePlayerMoveDone xor a ld [wcced],a - jp Func_3d69a ; if Mirror Move was successful go back to damage calculation for copied move + jp CheckIfPlayerNeedsToChargeUp ; if Mirror Move was successful go back to damage calculation for copied move .metronomeCheck cp a,METRONOME_EFFECT jr nz,.next call MetronomePickMove - jp Func_3d69a ; Go back to damage calculation for the move picked by Metronome + jp CheckIfPlayerNeedsToChargeUp ; Go back to damage calculation for the move picked by Metronome .next ld a,[W_PLAYERMOVEEFFECT] ld hl,ResidualEffects2 @@ -3286,14 +3285,14 @@ MirrorMoveCheck call HandleBuildingRage ld hl,W_PLAYERBATTSTATUS1 - bit 2,[hl] + bit AttackingMultipleTimes,[hl] jr z,.executeOtherEffects ld a,[wPlayerNumAttacksLeft] dec a ld [wPlayerNumAttacksLeft],a jp nz,asm_3d714 ; for multi-hit moves, apply attack until PlayerNumAttacksLeft hits 0 or the enemy faints. ; damage calculation and accuracy tests only happen for the first hit - res 2,[hl] + res AttackingMultipleTimes,[hl] ; clear attacking multiple times status when all attacks are over ld hl,MultiHitText call PrintText xor a @@ -3373,7 +3372,6 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) ld a,[hl] and a,SLP ; sleep mask jr z,.FrozenCheck - ; sleeping dec a ld [wBattleMonStatus],a ; decrement number of turns left @@ -3408,7 +3406,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) .HeldInPlaceCheck ld a,[W_ENEMYBATTSTATUS1] - bit 5,a ; is enemy using a mult-turn move like wrap? + bit UsingTrappingMove,a ; is enemy using a mult-turn move like wrap? jp z,.FlinchedCheck ld hl,CantMoveText call PrintText @@ -3417,9 +3415,9 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) .FlinchedCheck ld hl,W_PLAYERBATTSTATUS1 - bit 3,[hl] + bit Flinched,[hl] jp z,.HyperBeamCheck - res 3,[hl] ; reset player's flinch status + res Flinched,[hl] ; reset player's flinch status ld hl,FlinchedText call PrintText ld hl,ExecutePlayerMoveDone ; player can't move this turn @@ -3427,9 +3425,9 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) .HyperBeamCheck ld hl,W_PLAYERBATTSTATUS2 - bit 5,[hl] + bit NeedsToRecharge,[hl] jr z,.AnyMoveDisabledCheck - res 5,[hl] ; reset player's recharge status + res NeedsToRecharge,[hl] ; reset player's recharge status ld hl,MustRechargeText call PrintText ld hl,ExecutePlayerMoveDone ; player can't move this turn @@ -3457,7 +3455,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) dec [hl] jr nz,.IsConfused ld hl,W_PLAYERBATTSTATUS1 - res 7,[hl] ; if confused counter hit 0, reset confusion status + res Confused,[hl] ; if confused counter hit 0, reset confusion status ld hl,ConfusedNoMoreText call PrintText jr .TriedToUseDisabledMoveCheck @@ -3473,7 +3471,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) jr c,.TriedToUseDisabledMoveCheck ld hl,W_PLAYERBATTSTATUS1 ld a,[hl] - and a,$80 ; if mon hurts itself, clear every other status from W_PLAYERBATTSTATUS1 + and a, 1 << Confused ; if mon hurts itself, clear every other status from W_PLAYERBATTSTATUS1 ld [hl],a call HandleSelfConfusionDamage jr .MonHurtItselfOrFullyParalysed @@ -3502,7 +3500,8 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) .MonHurtItselfOrFullyParalysed ld hl,W_PLAYERBATTSTATUS1 ld a,[hl] - and a, %11001100 ; clear bide, thrashing, charging up, and multi-turn moves such as warp (redundant, already cleared) + ; clear bide, thrashing, charging up, and trapping moves such as warp (already cleared for confusion damage) + and a, (1 << AttackingMultipleTimes) | (1 << Flinched) | (1 << Invulnerable) | (1 << Confused) ld [hl],a ld a,[W_PLAYERMOVEEFFECT] cp a,FLY_EFFECT @@ -3522,7 +3521,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) .BideCheck ld hl,W_PLAYERBATTSTATUS1 - bit 0,[hl] ; is mon using bide? + bit StoringEnergy,[hl] ; is mon using bide? jr z,.ThrashingAboutCheck xor a ld [W_PLAYERMOVENUM],a @@ -3544,7 +3543,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) jp .returnToHL ; unless mon unleashes energy, can't move this turn .UnleashEnergy ld hl,W_PLAYERBATTSTATUS1 - res 0,[hl] ; not using bide any more + res StoringEnergy,[hl] ; not using bide any more ld hl,UnleashedEnergyText call PrintText ld a,1 @@ -3571,7 +3570,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) jp .returnToHL .ThrashingAboutCheck - bit 1,[hl] ; is mon using thrash or petal dance? + bit ThrashingAbout,[hl] ; is mon using thrash or petal dance? jr z,.MultiturnMoveCheck ld a,THRASH ld [W_PLAYERMOVENUM],a @@ -3583,8 +3582,8 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) jp nz,.returnToHL push hl ld hl,W_PLAYERBATTSTATUS1 - res 1,[hl] ; no longer trashing about - set 7,[hl] ; confused + res ThrashingAbout,[hl] ; no longer trashing about + set Confused,[hl] ; confused call BattleRandom and a,3 inc a @@ -3594,7 +3593,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) jp .returnToHL .MultiturnMoveCheck - bit 5,[hl] ; is mon using multi-turn move? + bit UsingTrappingMove,[hl] ; is mon using multi-turn move? jp z,.RageCheck ld hl,AttackContinuesText call PrintText @@ -3607,7 +3606,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) .RageCheck ld a, [W_PLAYERBATTSTATUS2] - bit 6, a ; is mon using rage? + bit UsingRage, a ; is mon using rage? jp z, .checkPlayerStatusConditionsDone ; if we made it this far, mon can move normally this turn ld a, RAGE ld [wd11e], a @@ -3692,12 +3691,12 @@ PrintMoveIsDisabledText: ; 3da88 (f:5a88) ld de, W_PLAYERBATTSTATUS1 ld a, [H_WHOSETURN] and a - jr z, .asm_3da97 + jr z, .removeChargingUp inc hl ld de, W_ENEMYBATTSTATUS1 -.asm_3da97 +.removeChargingUp ld a, [de] - res 4, a + res ChargingUp, a ; end the pokemon's ld [de], a ld a, [hl] ld [wd11e], a @@ -3728,7 +3727,7 @@ HandleSelfConfusionDamage: ; 3daad (f:5aad) xor a ld [hli], a ld [wCriticalHitOrOHKO], a ; self-inflicted confusion damage can't be a Critical Hit - ld a, $28 ; 40 base power + ld a, 40 ; 40 base power ld [hli], a xor a ld [hl], a @@ -3895,13 +3894,13 @@ PrintMoveFailureText: ; 3dbe2 (f:5be2) ld hl, DoesntAffectMonText ld a, [wd05b] and $7f - jr z, .asm_3dc04 + jr z, .gotTextToPrint ld hl, AttackMissedText ld a, [wCriticalHitOrOHKO] cp $ff - jr nz, .asm_3dc04 + jr nz, .gotTextToPrint ld hl, UnaffectedText -.asm_3dc04 +.gotTextToPrint push de call PrintText xor a @@ -4215,7 +4214,7 @@ GetDamageVarsForPlayerAttack: ; 3ddcf (f:5dcf) ld b, a ld c, [hl] ; bc = enemy defense ld a, [W_ENEMYBATTSTATUS3] - bit 2, a ; check for Reflect + bit HasReflectUp, a ; check for Reflect jr z, .physicalAttackCritCheck ; if the enemy has used Reflect, double the enemy's defense sla c @@ -4228,9 +4227,9 @@ GetDamageVarsForPlayerAttack: ; 3ddcf (f:5dcf) ; in the case of a critical hit, reset the player's attack and the enemy's defense to their base values ld c, 3 ; defense stat call GetEnemyMonStat - ld a, [$ff97] + ld a, [H_PRODUCT + 2] ld b, a - ld a, [$ff98] + ld a, [H_PRODUCT + 3] ld c, a push bc ld hl, wPartyMon1Attack @@ -4245,7 +4244,7 @@ GetDamageVarsForPlayerAttack: ; 3ddcf (f:5dcf) ld b, a ld c, [hl] ; bc = enemy special ld a, [W_ENEMYBATTSTATUS3] - bit 1, a ; check for Light Screen + bit HasLightScreenUp, a ; check for Light Screen jr z, .specialAttackCritCheck ; if the enemy has used Light Screen, double the enemy's special sla c @@ -4260,9 +4259,9 @@ GetDamageVarsForPlayerAttack: ; 3ddcf (f:5dcf) ; in the case of a critical hit, reset the player's and enemy's specials to their base values ld c, 5 ; special stat call GetEnemyMonStat - ld a, [$ff97] + ld a, [H_PRODUCT + 2] ld b, a - ld a, [$ff98] + ld a, [H_PRODUCT + 3] ld c, a push bc ld hl, wPartyMon1Special @@ -4327,7 +4326,7 @@ GetDamageVarsForEnemyAttack: ; 3de75 (f:5e75) ld b, a ld c, [hl] ; bc = player defense ld a, [W_PLAYERBATTSTATUS3] - bit 2, a ; check for Reflect + bit HasReflectUp, a ; check for Reflect jr z, .physicalAttackCritCheck ; if the player has used Reflect, double the player's defense sla c @@ -4348,7 +4347,7 @@ GetDamageVarsForEnemyAttack: ; 3de75 (f:5e75) push bc ld c, 2 ; attack stat call GetEnemyMonStat - ld hl, $ff97 + ld hl, H_PRODUCT + 2 pop bc jr .scaleStats .specialAttack @@ -4357,7 +4356,7 @@ GetDamageVarsForEnemyAttack: ; 3de75 (f:5e75) ld b, a ld c, [hl] ld a, [W_PLAYERBATTSTATUS3] - bit 1, a ; check for Light Screen + bit HasLightScreenUp, a ; check for Light Screen jr z, .specialAttackCritCheck ; if the player has used Light Screen, double the player's special sla c @@ -4380,7 +4379,7 @@ GetDamageVarsForEnemyAttack: ; 3de75 (f:5e75) push bc ld c, 5 ; special stat call GetEnemyMonStat - ld hl, $ff97 + ld hl, H_PRODUCT + 2 pop bc ; if either the offensive or defensive stat is too large to store in a byte, scale both stats by dividing them by 4 ; this allows values with up to 10 bits (values up to 1023) to be handled @@ -4437,9 +4436,9 @@ GetEnemyMonStat: ; 3df1c (f:5f1c) ld bc, wEnemyMon2 - wEnemyMon1 call AddNTimes ld a, [hli] - ld [$ff97], a + ld [H_MULTIPLICAND + 1], a ld a, [hl] - ld [$ff98], a + ld [H_MULTIPLICAND + 2], a pop bc pop de ret @@ -4671,7 +4670,7 @@ CriticalHitTest: ; 3e023 (f:6023) dec hl ld c, [hl] ; read move id ld a, [de] - bit 2, a ; test for focus energy + bit GettingPumped, a ; test for focus energy jr nz, .focusEnergyUsed ; bug: using focus energy causes a shift to the right instead of left, ; resulting in 1/4 the usual crit chance sla b ; (effective (base speed/2)*2) @@ -4858,7 +4857,7 @@ ApplyDamageToEnemyPokemon: ; 3e142 (f:6142) or b jr z,ApplyAttackToEnemyPokemonDone ; we're done if damage is 0 ld a,[W_ENEMYBATTSTATUS2] - bit 4,a ; does the enemy have a substitute? + bit HasSubstituteUp,a ; does the enemy have a substitute? jp nz,AttackSubstitute ; subtract the damage from the pokemon's current HP ; also, save the current HP at wHPBarOldHP @@ -4977,7 +4976,7 @@ ApplyDamageToPlayerPokemon: ; 3e200 (f:6200) or b jr z,ApplyAttackToPlayerPokemonDone ; we're done if damage is 0 ld a,[W_PLAYERBATTSTATUS2] - bit 4,a ; does the player have a substitute? + bit HasSubstituteUp,a ; does the player have a substitute? jp nz,AttackSubstitute ; subtract the damage from the pokemon's current HP ; also, save the current HP at wHPBarOldHP and the new HP at wHPBarNewHP @@ -5095,7 +5094,7 @@ HandleBuildingRage: ; 3e2b6 (f:62b6) ld de,wPlayerMonStatMods ld bc,W_PLAYERMOVENUM .next - bit 6,[hl] ; is the pokemon being attacked under the effect of Rage? + bit UsingRage,[hl] ; is the pokemon being attacked under the effect of Rage? ret z ; return if not ld a,[de] cp a,$0d ; maximum stat modifier value @@ -5103,7 +5102,7 @@ HandleBuildingRage: ; 3e2b6 (f:62b6) ld a,[H_WHOSETURN] xor a,$01 ; flip turn for the stat modifier raising function ld [H_WHOSETURN],a -; change the target pokemon's move to $00 and the effect to the one +; temporarily change the target pokemon's move to $00 and the effect to the one ; that causes the attack modifier to go up one stage ld h,b ld l,c @@ -5414,7 +5413,7 @@ MoveHitTest: ; 3e56b (f:656b) cp a,DREAM_EATER_EFFECT jr nz,.swiftCheck ld a,[bc] - and a,$07 ; is the target pokemon sleeping? + and a,SLP ; is the target pokemon sleeping? jp z,.moveMissed .swiftCheck ld a,[de] @@ -5429,7 +5428,7 @@ MoveHitTest: ; 3e56b (f:656b) cp a,DREAM_EATER_EFFECT jp z,.moveMissed .checkForDigOrFlyStatus - bit 6,[hl] + bit Invulnerable,[hl] jp nz,.moveMissed ld a,[H_WHOSETURN] and a @@ -5439,48 +5438,47 @@ MoveHitTest: ; 3e56b (f:656b) ld a,[W_PLAYERMOVEEFFECT] cp a,ATTACK_DOWN1_EFFECT jr c,.skipEnemyMistCheck - cp a,BIDE_EFFECT + cp a,HAZE_EFFECT + 1 jr c,.enemyMistCheck - cp a,$3a + cp a,ATTACK_DOWN2_EFFECT jr c,.skipEnemyMistCheck - cp a,POISON_EFFECT + cp a,REFLECT_EFFECT + 1 jr c,.enemyMistCheck jr .skipEnemyMistCheck .enemyMistCheck ; if move effect is from $12 to $19 inclusive or $3a to $41 inclusive ; i.e. the following moves ; GROWL, TAIL WHIP, LEER, STRING SHOT, SAND-ATTACK, SMOKESCREEN, KINESIS, -; FLASH, CONVERSION, HAZE*, SCREECH, LIGHT SCREEN*, REFLECT* +; FLASH, CONVERSION*, HAZE*, SCREECH, LIGHT SCREEN*, REFLECT* ; the moves that are marked with an asterisk are not affected since this ; function is not called when those moves are used -; XXX are there are any others like those three? ld a,[W_ENEMYBATTSTATUS2] - bit 1,a ; is mon protected by mist? + bit ProtectedByMist,a ; is mon protected by mist? jp nz,.moveMissed .skipEnemyMistCheck ld a,[W_PLAYERBATTSTATUS2] - bit 0,a ; is the player using X Accuracy? + bit UsingXAccuracy,a ; is the player using X Accuracy? ret nz ; if so, always hit regardless of accuracy/evasion jr .calcHitChance .enemyTurn ld a,[W_ENEMYMOVEEFFECT] cp a,ATTACK_DOWN1_EFFECT jr c,.skipPlayerMistCheck - cp a,BIDE_EFFECT + cp a,HAZE_EFFECT + 1 jr c,.playerMistCheck - cp a,$3a + cp a,ATTACK_DOWN2_EFFECT jr c,.skipPlayerMistCheck - cp a,POISON_EFFECT + cp a,REFLECT_EFFECT + 1 jr c,.playerMistCheck jr .skipPlayerMistCheck .playerMistCheck ; similar to enemy mist check ld a,[W_PLAYERBATTSTATUS2] - bit 1,a ; is mon protected by mist? + bit ProtectedByMist,a ; is mon protected by mist? jp nz,.moveMissed .skipPlayerMistCheck ld a,[W_ENEMYBATTSTATUS2] - bit 0,a ; is the enemy using X Accuracy? + bit UsingXAccuracy,a ; is the enemy using X Accuracy? ret nz ; if so, always hit regardless of accuracy/evasion .calcHitChance call CalcHitChance ; scale the move accuracy according to attacker's accuracy and target's evasion @@ -5510,11 +5508,11 @@ MoveHitTest: ; 3e56b (f:656b) jr z,.playerTurn2 .enemyTurn2 ld hl,W_ENEMYBATTSTATUS1 - res 5,[hl] ; end multi-turn attack e.g. wrap + res UsingTrappingMove,[hl] ; end multi-turn attack e.g. wrap ret .playerTurn2 ld hl,W_PLAYERBATTSTATUS1 - res 5,[hl] ; end multi-turn attack e.g. wrap + res UsingTrappingMove,[hl] ; end multi-turn attack e.g. wrap ret ; values for player turn @@ -5631,14 +5629,14 @@ ExecuteEnemyMove: ; 3e6bc (f:66bc) jp z, ExecuteEnemyMoveDone ld a, [W_ISLINKBATTLE] cp $4 - jr nz, .asm_3e6dc + jr nz, .executeEnemyMove ld b, $1 ld a, [wcc3e] cp $e - jr z, .asm_3e6dc + jr z, .executeEnemyMove cp $4 ret nc -.asm_3e6dc +.executeEnemyMove ld hl, wccd5 inc [hl] xor a @@ -5651,21 +5649,21 @@ ExecuteEnemyMove: ; 3e6bc (f:66bc) jp [hl] .enemyHasNoSpecialConditions ld hl, W_ENEMYBATTSTATUS1 - bit 4, [hl] ; is the enemy charging up for attack? - jr nz, enemyCanExecuteChargingMove ; if so, jump + bit ChargingUp, [hl] ; is the enemy charging up for attack? + jr nz, EnemyCanExecuteChargingMove ; if so, jump call GetCurrentMove -Func_3e6fc: ; 3e6fc (f:66fc) +CheckIfEnemyNeedsToChargeUp: ; 3e6fc (f:66fc) ld a, [W_ENEMYMOVEEFFECT] cp CHARGE_EFFECT jp z, JumpMoveEffect cp FLY_EFFECT jp z, JumpMoveEffect - jr enemyCanExecuteMove -enemyCanExecuteChargingMove: ; 3e70b (f:670b) + jr EnemyCanExecuteMove +EnemyCanExecuteChargingMove: ; 3e70b (f:670b) ld hl, W_ENEMYBATTSTATUS1 - res 4, [hl] ; no longer charging up for attack - res 6, [hl] ; no longer invulnerable to typical attacks + res ChargingUp, [hl] ; no longer charging up for attack + res Invulnerable, [hl] ; no longer invulnerable to typical attacks ld a, [W_ENEMYMOVENUM] ld [wd0b5], a ld a, BANK(MoveNames) @@ -5675,7 +5673,7 @@ enemyCanExecuteChargingMove: ; 3e70b (f:670b) call GetName ld de, wcd6d call CopyStringToCF4B -enemyCanExecuteMove: ; 3e72b (f:672b) +EnemyCanExecuteMove: ; 3e72b (f:672b) xor a ld [wcced], a call PrintMonName1Text @@ -5733,7 +5731,7 @@ asm_3e7a0: ; 3e7a0 (f:67a0) asm_3e7a4: ; 3e7a4 (f:67a4) push af ld a, [W_ENEMYBATTSTATUS2] - bit 4, a ; does mon have a substitute? + bit HasSubstituteUp, a ; does mon have a substitute? ld hl, Func_79747 ld b, BANK(Func_79747) call nz, Bankswitch @@ -5744,7 +5742,7 @@ asm_3e7a4: ; 3e7a4 (f:67a4) call HandleExplodingAnimation call DrawEnemyHUDAndHPBar ld a, [W_ENEMYBATTSTATUS2] - bit 4, a ; does mon have a substitute? + bit HasSubstituteUp, a ; does mon have a substitute? ld hl, Func_79771 ld b, BANK(Func_79771) call nz, Bankswitch ; slide the substitute's sprite out @@ -5771,12 +5769,12 @@ asm_3e7ef: ; 3e7ef (f:67ef) jr nz, .notMirrorMoveEffect call MirrorMoveCopyMove jp z, ExecuteEnemyMoveDone - jp Func_3e6fc + jp CheckIfEnemyNeedsToChargeUp .notMirrorMoveEffect cp METRONOME_EFFECT jr nz, .notMetronomeEffect call MetronomePickMove - jp Func_3e6fc + jp CheckIfEnemyNeedsToChargeUp .notMetronomeEffect ld a, [W_ENEMYMOVEEFFECT] ld hl, ResidualEffects2 @@ -5810,14 +5808,14 @@ asm_3e7ef: ; 3e7ef (f:67ef) ret z call HandleBuildingRage ld hl, W_ENEMYBATTSTATUS1 - bit 2, [hl] ; is mon hitting multiple times? (example: double kick) + bit AttackingMultipleTimes, [hl] ; is mon hitting multiple times? (example: double kick) jr z, .asm_3e873 push hl ld hl, wEnemyNumAttacksLeft dec [hl] pop hl jp nz, Func_3e794 - res 2, [hl] ; mon is no longer hitting multiple times + res AttackingMultipleTimes, [hl] ; mon is no longer hitting multiple times ld hl, HitXTimesText call PrintText xor a @@ -5877,7 +5875,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) jp .enemyReturnToHL .checkIfTrapped ld a, [W_PLAYERBATTSTATUS1] - bit 5, a ; is the player using a multi-turn attack like warp + bit UsingTrappingMove, a ; is the player using a multi-turn attack like warp jp z, .checkIfFlinched ld hl, CantMoveText call PrintText @@ -5885,18 +5883,18 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) jp .enemyReturnToHL .checkIfFlinched ld hl, W_ENEMYBATTSTATUS1 - bit 3, [hl] ; check if enemy mon flinched + bit Flinched, [hl] ; check if enemy mon flinched jp z, .checkIfMustRecharge - res 3, [hl] + res Flinched, [hl] ld hl, FlinchedText call PrintText ld hl, ExecuteEnemyMoveDone jp .enemyReturnToHL .checkIfMustRecharge ld hl, W_ENEMYBATTSTATUS2 - bit 5, [hl] ; check if enemy mon has to recharge after using a move + bit NeedsToRecharge, [hl] ; check if enemy mon has to recharge after using a move jr z, .checkIfAnyMoveDisabled - res 5, [hl] + res NeedsToRecharge, [hl] ld hl, MustRechargeText call PrintText ld hl, ExecuteEnemyMoveDone @@ -5922,7 +5920,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) dec [hl] jr nz, .isConfused ld hl, W_ENEMYBATTSTATUS1 - res 7, [hl] + res Confused, [hl] ld hl, ConfusedNoMoreText call PrintText jp .checkIfTriedToUseDisabledMove @@ -5938,7 +5936,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) jr c, .checkIfTriedToUseDisabledMove ld hl, W_ENEMYBATTSTATUS1 ld a, [hl] - and $80 + and 1 << Confused ld [hl], a ld hl, HurtItselfText call PrintText @@ -5958,7 +5956,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) xor a ld [hli], a ld [wCriticalHitOrOHKO], a - ld a, $28 + ld a, 40 ld [hli], a xor a ld [hl], a @@ -6003,7 +6001,8 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) .monHurtItselfOrFullyParalysed ld hl, W_ENEMYBATTSTATUS1 ld a, [hl] - and $cc ; clear bide, thrashing, charging up, and multi-turn moves such as warp + ; clear bide, thrashing about, charging up, and multi-turn moves such as warp + and (1 << AttackingMultipleTimes) | (1 << Flinched) | (1 << Invulnerable) | (1 << Confused) ld [hl], a ld a, [W_ENEMYMOVEEFFECT] cp FLY_EFFECT @@ -6021,7 +6020,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) jp .enemyReturnToHL .checkIfUsingBide ld hl, W_ENEMYBATTSTATUS1 - bit 0, [hl] ; is mon using bide? + bit StoringEnergy, [hl] ; is mon using bide? jr z, .checkIfThrashingAbout xor a ld [W_ENEMYMOVENUM], a @@ -6043,7 +6042,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) jp .enemyReturnToHL .unleashEnergy ld hl, W_ENEMYBATTSTATUS1 - res 0, [hl] ; not using bide any more + res StoringEnergy, [hl] ; not using bide any more ld hl, UnleashedEnergyText call PrintText ld a, $1 @@ -6070,7 +6069,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) ld hl, asm_3e782 jp .enemyReturnToHL .checkIfThrashingAbout - bit 1, [hl] ; is mon using thrash or petal dance? + bit ThrashingAbout, [hl] ; is mon using thrash or petal dance? jr z, .checkIfUsingMultiturnMove ld a, THRASH ld [W_ENEMYMOVENUM], a @@ -6082,8 +6081,8 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) jp nz, .enemyReturnToHL push hl ld hl, W_ENEMYBATTSTATUS1 - res 1, [hl] ; mon is no longer using thrash or petal dance - set 7, [hl] ; mon is now confused + res ThrashingAbout, [hl] ; mon is no longer using thrash or petal dance + set Confused, [hl] ; mon is now confused call BattleRandom and $3 inc a @@ -6092,7 +6091,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) pop hl jp .enemyReturnToHL .checkIfUsingMultiturnMove - bit 5, [hl] ; is mon using multi-turn move? + bit UsingTrappingMove, [hl] ; is mon using multi-turn move? jp z, .checkIfUsingRage ld hl, AttackContinuesText call PrintText @@ -6103,7 +6102,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) jp .enemyReturnToHL .checkIfUsingRage ld a, [W_ENEMYBATTSTATUS2] - bit 6, a ; is mon using rage? + bit UsingRage, a ; is mon using rage? jp z, .checkEnemyStatusConditionsDone ld a, RAGE ld [wd11e], a @@ -6111,7 +6110,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) call CopyStringToCF4B xor a ld [W_ENEMYMOVEEFFECT], a - ld hl, enemyCanExecuteMove + ld hl, EnemyCanExecuteMove jp .enemyReturnToHL .enemyReturnToHL xor a ; set Z flag @@ -6161,7 +6160,7 @@ LoadEnemyMonData: ; 3eb01 (f:6b01) ld [wd0b5], a call GetMonHeader ld a, [W_ENEMYBATTSTATUS3] - bit 3, a ; is enemy mon transformed? + bit Transformed, a ; is enemy mon transformed? ld hl, wcceb ; copied DVs from when it used Transform ld a, [hli] ld b, [hl] @@ -6193,7 +6192,7 @@ LoadEnemyMonData: ; 3eb01 (f:6b01) cp $2 ; is it a trainer battle? jr z, .copyHPAndStatusFromPartyData ld a, [W_ENEMYBATTSTATUS3] - bit 3, a ; is enemy mon transformed? + bit Transformed, a ; is enemy mon transformed? jr nz, .copyTypes ; if transformed, jump ; if it's a wild mon and not transformed, init the current HP to max HP and the status to 0 ld a, [wEnemyMonMaxHP] @@ -6713,34 +6712,37 @@ BattleRandom: push hl push bc - ld a, [wccde] + ld a, [wLinkBattleRNCount] ld c, a ld b, 0 ld hl, wd148 add hl, bc inc a - ld [wccde], a + ld [wLinkBattleRNCount], a cp 9 ld a, [hl] pop bc pop hl ret c +; if we picked the last seed, we need to recalculate the nine seeds push hl push bc push af - + +; point to seed 0 so we pick the first number the next time xor a - ld [wccde], a - + ld [wLinkBattleRNCount], a ld hl, wd148 ld b, 9 .loop ld a, [hl] ld c, a +; multiply by 5 add a add a add c +; add 1 inc a ld [hli], a dec b @@ -6769,7 +6771,7 @@ HandleExplodingAnimation: ; 3eed3 (f:6ed3) ret nz .asm_3eef1 ld a, [de] - bit 6, a ; fly/dig + bit Invulnerable, a ; fly/dig ret nz ld a, [hli] cp GHOST @@ -7190,8 +7192,8 @@ SleepEffect: ; 3f1fc (f:71fc) .sleepEffect ld a, [bc] - bit 5, a ; does the target need to recharge? (hyper beam) - res 5, a ; target no longer needs to recharge + bit NeedsToRecharge, a ; does the target need to recharge? (hyper beam) + res NeedsToRecharge, a ; target no longer needs to recharge ld [bc], a jr nz, .setSleepCounter ; if the target had to recharge, all hit tests will be skipped ; including the event where the target already has another status @@ -7290,7 +7292,7 @@ PoisonEffect: ; 3f24f (f:724f) .ok cp TOXIC jr nz, .normalPoison ; done if move is not Toxic - set 0, [hl] ; else set Toxic battstatus + set BadlyPoisoned, [hl] ; else set Toxic battstatus xor a ld [de], a ld hl, BadlyPoisonedText @@ -7345,7 +7347,7 @@ ExplodeEffect: ; 3f2f1 (f:72f1) inc hl ld [hl], a ; set mon's status to 0 ld a, [de] - res 7, a ; clear mon's leech seed status + res Seeded, a ; clear mon's leech seed status ld [de], a ret @@ -7421,7 +7423,7 @@ opponentAttacker: ; 3f382 (f:7382) cp b ret z ld a, [W_ENEMYMOVEEFFECT] - cp a, 7 + cp a, PARALYZE_SIDE_EFFECT1 + 1 ld b, $1a jr c, .next1 ld b, $4d @@ -7512,7 +7514,7 @@ StatModifierUpEffect: ; 3f428 (f:7428) .statModifierUpEffect ld a, [de] sub ATTACK_UP1_EFFECT - cp $8 + cp EVASION_UP1_EFFECT + $3 - ATTACK_UP1_EFFECT ; covers all +1 effects jr c, .incrementStatMod sub ATTACK_UP2_EFFECT - ATTACK_UP1_EFFECT ; map +2 effects to equivalent +1 effect .incrementStatMod @@ -7523,7 +7525,7 @@ StatModifierUpEffect: ; 3f428 (f:7428) inc b ; increment corresponding stat mod ld a, $d cp b ; can't raise stat past +6 ($d or 13) - jp c, Func_3f522 + jp c, PrintNothingHappenedText ld a, [de] cp ATTACK_UP1_EFFECT + $8 ; is it a +2 effect? jr c, .ok @@ -7539,7 +7541,7 @@ StatModifierUpEffect: ; 3f428 (f:7428) jr nc, UpdateStatDone ; jump if mod affected is evasion/accuracy push hl ld hl, wBattleMonAttack + 1 - ld de, wcd12 + ld de, wPlayerMonUnmodifiedAttack ld a, [H_WHOSETURN] and a jr z, .pointToStats @@ -7558,10 +7560,10 @@ StatModifierUpEffect: ; 3f428 (f:7428) .checkIf999 pop bc ld a, [hld] - sub $e7 ; check if stat is already 999 + sub 999 % $100 ; check if stat is already 999 jr nz, .recalculateStat ld a, [hl] - sbc $3 + sbc 999 / $100 jp z, Func_3f520 .recalculateStat ; recalculate affected stat ; paralysis and burn penalties, as well as badge boosts are ignored @@ -7575,35 +7577,35 @@ StatModifierUpEffect: ; 3f428 (f:7428) add hl, bc pop bc xor a - ld [H_NUMTOPRINT], a ; $ff96 (aliases: H_MULTIPLICAND) + ld [H_MULTIPLICAND], a ld a, [de] - ld [$ff97], a + ld [H_MULTIPLICAND + 1], a inc de ld a, [de] - ld [$ff98], a + ld [H_MULTIPLICAND + 2], a ld a, [hli] - ld [H_REMAINDER], a ; $ff99 (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) + ld [H_MULTIPLIER], a call Multiply ld a, [hl] - ld [H_REMAINDER], a ; $ff99 (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) + ld [H_DIVISOR], a ld b, $4 call Divide pop hl ; cap at 999 - ld a, [$ff98] - sub $e7 - ld a, [$ff97] - sbc $3 + ld a, [H_PRODUCT + 3] + sub 999 % $100 + ld a, [H_PRODUCT + 2] + sbc 999 / $100 jp c, UpdateStat ld a, 999 / $100 - ld [$ff97], a + ld [H_MULTIPLICAND + 1], a ld a, 999 % $100 - ld [$ff98], a + ld [H_MULTIPLICAND + 2], a UpdateStat: ; 3f4c3 (f:74c3) - ld a, [$ff97] + ld a, [H_PRODUCT + 2] ld [hli], a - ld a, [$ff98] + ld a, [H_PRODUCT + 3] ld [hl], a pop hl UpdateStatDone: ; 3f4ca (f:74ca) @@ -7623,7 +7625,7 @@ UpdateStatDone: ; 3f4ca (f:74ca) ld a, [de] cp MINIMIZE jr nz, .asm_3f4f9 - bit 4, [hl] ; substitute + bit HasSubstituteUp, [hl] ; substitute push af push bc ld hl, Func_79747 @@ -7659,7 +7661,7 @@ Func_3f520: ; 3f520 (f:7520) pop hl dec [hl] -Func_3f522: ; 3f522 (f:7522) +PrintNothingHappenedText: ; 3f522 (f:7522) ld hl, NothingHappenedText jp PrintText @@ -7700,7 +7702,7 @@ StatModifierDownEffect: ; 3f54c (f:754c) cp $4 jr z, .statModifierDownEffect call BattleRandom - cp $40 ; 1/4 chance to miss by wildmon + cp $40 ; 1/4 chance to miss by in regular battle jp c, MoveMissed .statModifierDownEffect call CheckTargetSubstitute ; can't hit through substitute @@ -7726,13 +7728,13 @@ StatModifierDownEffect: ; 3f54c (f:754c) and a jp nz, MoveMissed ld a, [bc] - bit 6, a ; fly/dig + bit Invulnerable, a ; fly/dig jp nz, MoveMissed ld a, [de] sub ATTACK_DOWN1_EFFECT - cp $8 + cp EVASION_DOWN1_EFFECT + $3 - ATTACK_DOWN1_EFFECT ; covers al -1 effects jr c, .decrementStatMod - sub ATTACK_DOWN2_EFFECT - ATTACK_DOWN1_EFFECT ; map +2 effects to corresponding +1 effect + sub ATTACK_DOWN2_EFFECT - ATTACK_DOWN1_EFFECT ; map -2 effects to corresponding -1 effect .decrementStatMod ld c, a ld b, $0 @@ -7741,9 +7743,9 @@ StatModifierDownEffect: ; 3f54c (f:754c) dec b ; dec corresponding stat mod jp z, CantLowerAnymore ; if stat mod is 1 (-6), can't lower anymore ld a, [de] - cp $24 + cp ATTACK_DOWN2_EFFECT - $16 ; $24 jr c, .ok - cp $44 + cp EVASION_DOWN2_EFFECT + $5 ; $44 jr nc, .ok dec b ; stat down 2 effects only (dec mod again) jr nz, .ok @@ -7752,7 +7754,7 @@ StatModifierDownEffect: ; 3f54c (f:754c) ld [hl], b ; save modified mod ld a, c cp $4 - jr nc, UpdateStat2Done ; jump for evasion/accuracy + jr nc, UpdateLoweredStatDone ; jump for evasion/accuracy push hl push de ld hl, wEnemyMonAttack + 1 @@ -7761,7 +7763,7 @@ StatModifierDownEffect: ; 3f54c (f:754c) and a jr z, .pointToStat ld hl, wBattleMonAttack + 1 - ld de, wcd12 + ld de, wPlayerMonUnmodifiedAttack .pointToStat push bc sla c @@ -7793,37 +7795,37 @@ StatModifierDownEffect: ; 3f54c (f:754c) add hl, bc pop bc xor a - ld [H_NUMTOPRINT], a ; $ff96 (aliases: H_MULTIPLICAND) + ld [H_MULTIPLICAND], a ld a, [de] - ld [$ff97], a + ld [H_MULTIPLICAND + 1], a inc de ld a, [de] - ld [$ff98], a + ld [H_MULTIPLICAND + 2], a ld a, [hli] - ld [H_REMAINDER], a ; $ff99 (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) + ld [H_MULTIPLIER], a call Multiply ld a, [hl] - ld [H_REMAINDER], a ; $ff99 (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) + ld [H_DIVISOR], a ld b, $4 call Divide pop hl - ld a, [$ff98] + ld a, [H_PRODUCT + 3] ld b, a - ld a, [$ff97] + ld a, [H_PRODUCT + 2] or b - jp nz, UpdateStat2 - ld [$ff97], a + jp nz, UpdateLoweredStat + ld [H_MULTIPLICAND + 1], a ld a, $1 - ld [$ff98], a + ld [H_MULTIPLICAND + 2], a -UpdateStat2: ; 3f624 (f:7624) - ld a, [$ff97] +UpdateLoweredStat: ; 3f624 (f:7624) + ld a, [H_PRODUCT + 2] ld [hli], a - ld a, [$ff98] + ld a, [H_PRODUCT + 3] ld [hl], a pop de pop hl -UpdateStat2Done: ; 3f62c (f:762c) +UpdateLoweredStatDone: ; 3f62c (f:762c) ld b, c inc b push de @@ -7941,7 +7943,7 @@ BideEffect: ; 3f6e5 (f:76e5) ld de, wcd05 ld bc, wEnemyNumAttacksLeft .bideEffect - set 0, [hl] ; mon is now using bide + set StoringEnergy, [hl] ; mon is now using bide xor a ld [de], a inc de @@ -7966,7 +7968,7 @@ ThrashPetalDanceEffect: ; 3f717 (f:7717) ld hl, W_ENEMYBATTSTATUS1 ld de, wEnemyNumAttacksLeft .thrashPetalDanceEffect - set 1, [hl] ; mon is now using thrash/petal dance + set ThrashingAbout, [hl] ; mon is now using thrash/petal dance call BattleRandom and $1 inc a @@ -8102,9 +8104,9 @@ TwoToFiveAttacksEffect: ; 3f811 (f:7811) ld de, wEnemyNumAttacksLeft ld bc, wcd05 .twoToFiveAttacksEffect - bit 2, [hl] ; is mon attacking multiple times? + bit AttackingMultipleTimes, [hl] ; is mon attacking multiple times? ret nz - set 2, [hl] ; mon is now attacking multiple times + set AttackingMultipleTimes, [hl] ; mon is now attacking multiple times ld hl, W_PLAYERMOVEEFFECT ld a, [H_WHOSETURN] and a @@ -8156,7 +8158,7 @@ FlinchSideEffect: ; 3f85b (f:785b) call BattleRandom cp b ret nc - set 3, [hl] ; set mon's status to flinching + set Flinched, [hl] ; set mon's status to flinching call ClearHyperBeam ret @@ -8176,18 +8178,18 @@ ChargeEffect: ; 3f88c (f:788c) ld de, W_ENEMYMOVEEFFECT ld b, ANIM_AF .chargeEffect - set 4, [hl] + set ChargingUp, [hl] ld a, [de] dec de ; de contains enemy or player MOVENUM cp FLY_EFFECT jr nz, .notFly - set 6, [hl] ; mon is now invulnerable to typical attacks (fly/dig) + set Invulnerable, [hl] ; mon is now invulnerable to typical attacks (fly/dig) ld b, TELEPORT ; load Teleport's animation .notFly ld a, [de] cp DIG jr nz, .notDigOrFly - set 6, [hl] ; mon is now invulnerable to typical attacks (fly/dig) + set Invulnerable, [hl] ; mon is now invulnerable to typical attacks (fly/dig) ld b, ANIM_C0 .notDigOrFly xor a @@ -8256,11 +8258,11 @@ TrappingEffect: ; 3f917 (f:7917) ld hl, W_ENEMYBATTSTATUS1 ld de, wEnemyNumAttacksLeft .trappingEffect - bit 5, [hl] + bit UsingTrappingMove, [hl] ret nz call ClearHyperBeam ; since this effect is called before testing whether the move will hit, ; the target won't need to recharge even if the trapping move missed - set 5, [hl] ; mon is now using a trapping move + set UsingTrappingMove, [hl] ; mon is now using a trapping move call BattleRandom ; 3/8 chance for 2 and 3 attacks, and 1/8 chance for 4 and 5 attacks and $3 cp $2 @@ -8312,9 +8314,9 @@ ConfusionSideEffectSuccess: ; 3f96f (f:796f) ld bc, W_PLAYERCONFUSEDCOUNTER ld a, [W_ENEMYMOVEEFFECT] .confuseTarget - bit 7, [hl] ; is mon confused? + bit Confused, [hl] ; is mon confused? jr nz, ConfusionEffectFailed - set 7, [hl] ; mon is now confused + set Confused, [hl] ; mon is now confused push af call BattleRandom and $3 @@ -8355,7 +8357,7 @@ HyperBeamEffect: ; 3f9c1 (f:79c1) jr z, .hyperBeamEffect ld hl, W_ENEMYBATTSTATUS2 .hyperBeamEffect - set 5, [hl] ; mon now needs to recharge + set NeedsToRecharge, [hl] ; mon now needs to recharge ret ClearHyperBeam: ; 3f9cf (f:79cf) @@ -8366,7 +8368,7 @@ ClearHyperBeam: ; 3f9cf (f:79cf) jr z, .asm_3f9db ld hl, W_PLAYERBATTSTATUS2 .asm_3f9db - res 5, [hl] ; mon no longer needs to recharge + res NeedsToRecharge, [hl] ; mon no longer needs to recharge pop hl ret @@ -8377,7 +8379,7 @@ RageEffect: ; 3f9df (f:79df) jr z, .player ld hl, W_ENEMYBATTSTATUS2 .player - set 6, [hl] ; mon is now in "rage" mode + set UsingRage, [hl] ; mon is now in "rage" mode ret MimicEffect: ; 3f9ed (f:79ed) @@ -8398,7 +8400,7 @@ MimicEffect: ; 3f9ed (f:79ed) ld hl, wEnemyMonMoves ld a, [W_ENEMYBATTSTATUS1] .asm_3fa13 - bit 6, a + bit Invulnerable, a jr nz, .asm_3fa74 .asm_3fa17 push hl @@ -8422,7 +8424,7 @@ MimicEffect: ; 3f9ed (f:79ed) jr .asm_3fa5f .asm_3fa3a ld a, [W_ENEMYBATTSTATUS1] - bit 6, a + bit Invulnerable, a jr nz, .asm_3fa74 ld a, [wCurrentMenuItem] push af @@ -8627,12 +8629,12 @@ ParalyzedMayNotAttackText: ; 3fb74 (f:7b74) CheckTargetSubstitute: ; 3fb79 (f:7b79) push hl ld hl, W_ENEMYBATTSTATUS2 - ld a, [$fff3] ;whose turn? + ld a, [$fff3] and a jr z, .next1 ld hl, W_PLAYERBATTSTATUS2 .next1 - bit 4, [hl] ;test bit 4 in d063/d068 flags + bit HasSubstituteUp, [hl] pop hl ret diff --git a/engine/battle/e_2.asm b/engine/battle/e_2.asm index b0e08982b4..6c159c568e 100755 --- a/engine/battle/e_2.asm +++ b/engine/battle/e_2.asm @@ -130,7 +130,7 @@ TransformEffect_: ; 3bab1 (e:7ab1) ld [wPlayerMoveListIndex], a ; wPlayerMoveListIndex ld a, [W_PLAYERBATTSTATUS1] ; W_PLAYERBATTSTATUS1 .asm_3bad1 - bit 6, a ; is mon invulnerable to typical attacks? (fly/dig) + bit Invulnerable, a ; is mon invulnerable to typical attacks? (fly/dig) jp nz, Func_3bb8c push hl push de @@ -141,7 +141,7 @@ TransformEffect_: ; 3bab1 (e:7ab1) jr z, .asm_3bae4 ld hl, W_ENEMYBATTSTATUS2 ; W_ENEMYBATTSTATUS2 .asm_3bae4 - bit 4, [hl] + bit HasSubstituteUp, [hl] push af ld hl, Func_79747 ld b, BANK(Func_79747) @@ -161,7 +161,7 @@ TransformEffect_: ; 3bab1 (e:7ab1) call nz, Bankswitch pop bc ld a, [bc] - set 3, a + set Transformed, a ld [bc], a pop de pop hl @@ -267,15 +267,15 @@ ReflectLightScreenEffect_: ; 3bb97 (e:7b97) ld a, [de] cp LIGHT_SCREEN_EFFECT jr nz, .reflect - bit 1, [hl] ; is mon already protected by light screen? + bit HasLightScreenUp, [hl] ; is mon already protected by light screen? jr nz, .moveFailed - set 1, [hl] ; mon is now protected by light screen + set HasLightScreenUp, [hl] ; mon is now protected by light screen ld hl, LightScreenProtectedText ; $7bd7 jr .asm_3bbc1 .reflect - bit 2, [hl] ; is mon already protected by reflect? + bit HasReflectUp, [hl] ; is mon already protected by reflect? jr nz, .moveFailed - set 2, [hl] ; mon is now protected by reflect + set HasReflectUp, [hl] ; mon is now protected by reflect ld hl, ReflectGainedArmorText ; $7bdc .asm_3bbc1 push hl diff --git a/engine/items/items.asm b/engine/items/items.asm index af6c9552ad..029c659b01 100755 --- a/engine/items/items.asm +++ b/engine/items/items.asm @@ -357,13 +357,13 @@ ItemUseBall: ; d687 (3:5687) push af ;...and status ailments push hl ld hl,W_ENEMYBATTSTATUS3 - bit 3,[hl] + bit Transformed,[hl] jr z,.next15 ld a,$4c ld [wEnemyMonSpecies2],a jr .next16 .next15 ;$5871 - set 3,[hl] + set Transformed,[hl] ld hl,wcceb ld a,[wEnemyMonDVs] ld [hli],a @@ -770,7 +770,7 @@ ItemUseMedicine: ; dabb (3:5abb) ld [wBattleMonStatus],a ; remove the status ailment in the in-battle pokemon data push hl ld hl,W_PLAYERBATTSTATUS3 - res 0,[hl] ; heal Toxic status + res BadlyPoisoned,[hl] ; heal Toxic status pop hl ld bc,30 add hl,bc ; hl now points to party stats @@ -1407,7 +1407,7 @@ ItemUseRepelCommon: ; e005 (3:6005) and a jp nz,ItemUseNotTime ld a,b - ld [wd0db],a + ld [wRepelRemainingSteps],a jp PrintItemUseTextAndRemoveItem ; handles X Accuracy item @@ -1416,7 +1416,7 @@ ItemUseXAccuracy: ; e013 (3:6013) and a jp z,ItemUseNotTime ld hl,W_PLAYERBATTSTATUS2 - set 0,[hl] ; X Accuracy bit + set UsingXAccuracy,[hl] ; X Accuracy bit jp PrintItemUseTextAndRemoveItem ; This function is bugged and never works. It always jumps to ItemUseNotTime. @@ -1525,7 +1525,7 @@ ItemUseGuardSpec: ; e0dc (3:60dc) and a jp z,ItemUseNotTime ld hl,W_PLAYERBATTSTATUS2 - set 1,[hl] ; Mist bit + set ProtectedByMist,[hl] ; Mist bit jp PrintItemUseTextAndRemoveItem ItemUseSuperRepel: ; e0eb (3:60eb) @@ -1541,7 +1541,7 @@ ItemUseDireHit: ; e0f5 (3:60f5) and a jp z,ItemUseNotTime ld hl,W_PLAYERBATTSTATUS2 - set 2,[hl] ; Focus Energy bit + set GettingPumped,[hl] ; Focus Energy bit jp PrintItemUseTextAndRemoveItem ItemUseXStat: ; e104 (3:6104) diff --git a/wram.asm b/wram.asm index 1ff0a6a971..6a7e2763c7 100755 --- a/wram.asm +++ b/wram.asm @@ -348,7 +348,8 @@ wPlayerSelectedMove:: ; ccdc wEnemySelectedMove:: ; ccdd ds 1 -wccde:: ds 1 +wLinkBattleRNCount:: ; ccde + ds 1 wAICount:: ; ccdf ; number of times remaining that AI action can occur @@ -1178,7 +1179,10 @@ W_DAMAGE:: ; d0d7 ds 1 wd0d8:: ds 3 -wd0db:: ds 1 + +wRepelRemainingSteps:: ; wd0db + ds 1 + wd0dc:: ds 4 wd0e0:: ds 1 wd0e1:: ds 56 From 3fdb8a0d8995746d5605136ece384516338489b0 Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Sat, 7 Feb 2015 02:43:08 -0800 Subject: [PATCH 086/100] serial/trade/misc --- constants/hardware_constants.asm | 3 + constants/misc_constants.asm | 38 +- constants/move_constants.asm | 8 +- constants/wram_constants.asm | 6 +- data/hidden_objects.asm | 16 +- engine/battle/15.asm | 8 +- engine/battle/1c.asm | 4 +- engine/battle/4_2.asm | 20 +- engine/battle/animations.asm | 197 +++-- engine/battle/core.asm | 173 ++-- engine/battle/d.asm | 2 +- engine/battle/e.asm | 10 +- engine/cable_club.asm | 937 +++++++++++----------- engine/clear_save.asm | 6 +- engine/evolve_trade.asm | 12 +- engine/evos_moves.asm | 22 +- engine/game_corner_slots.asm | 2 +- engine/hall_of_fame.asm | 12 +- engine/hidden_object_functions17.asm | 2 +- engine/in_game_trades.asm | 164 ++-- engine/intro.asm | 14 +- engine/items/items.asm | 4 +- engine/learn_move.asm | 4 +- engine/menu/bills_pc.asm | 40 +- engine/menu/diploma.asm | 2 +- engine/menu/main_menu.asm | 126 +-- engine/menu/naming_screen.asm | 2 +- engine/menu/start_sub_menus.asm | 12 +- engine/menu/vending_machine.asm | 4 +- engine/mon_party_sprites.asm | 2 +- engine/overworld/cable_club_npc.asm | 138 ++-- engine/overworld/elevator.asm | 6 +- engine/overworld/pokemart.asm | 14 +- engine/predefs.asm | 10 +- engine/save.asm | 2 +- engine/slot_machine.asm | 6 +- engine/titlescreen.asm | 4 +- engine/trade.asm | 371 ++++----- engine/trade2.asm | 22 +- extras | 2 +- home.asm | 32 +- home/init.asm | 10 +- home/overworld.asm | 12 +- home/serial.asm | 617 +++++++------- home/text.asm | 8 +- hram.asm | 15 + main.asm | 157 ++-- scripts/celadongamecorner.asm | 2 +- scripts/celadonpokecenter.asm | 2 +- scripts/ceruleanhouse1.asm | 2 +- scripts/ceruleanpokecenter.asm | 2 +- scripts/cinnabarpokecenter.asm | 2 +- scripts/daycarem.asm | 4 +- scripts/fuchsiapokecenter.asm | 2 +- scripts/indigoplateaulobby.asm | 2 +- scripts/lab2.asm | 2 +- scripts/lab4.asm | 2 +- scripts/lavenderpokecenter.asm | 2 +- scripts/mtmoonpokecenter.asm | 6 +- scripts/museum1f.asm | 4 +- scripts/pewterpokecenter.asm | 2 +- scripts/rocktunnelpokecenter.asm | 2 +- scripts/route11gateupstairs.asm | 2 +- scripts/route18gateupstairs.asm | 2 +- scripts/route2house.asm | 2 +- scripts/safarizoneentrance-yellow.asm | 4 +- scripts/safarizoneentrance.asm | 4 +- scripts/saffronpokecenter.asm | 2 +- scripts/undergroundpathentranceroute5.asm | 2 +- scripts/vermilionhouse3.asm | 2 +- scripts/vermilionpokecenter.asm | 2 +- scripts/viridianpokecenter.asm | 2 +- text.asm | 50 +- wram.asm | 192 ++++- 74 files changed, 1934 insertions(+), 1648 deletions(-) diff --git a/constants/hardware_constants.asm b/constants/hardware_constants.asm index e875622dfc..f9e3fe19b7 100644 --- a/constants/hardware_constants.asm +++ b/constants/hardware_constants.asm @@ -30,6 +30,9 @@ OAM_X_FLIP EQU 5 OAM_Y_FLIP EQU 6 OAM_PRIORITY EQU 7 ; 0: OBJ above BG, 1: OBJ behind BG (colors 1-3) +; serial +START_TRANSFER_EXTERNAL_CLOCK EQU $80 +START_TRANSFER_INTERNAL_CLOCK EQU $81 ; Hardware registers rJOYP EQU $ff00 ; Joypad (R/W) diff --git a/constants/misc_constants.asm b/constants/misc_constants.asm index b864ab8592..fd80eab2a6 100644 --- a/constants/misc_constants.asm +++ b/constants/misc_constants.asm @@ -26,4 +26,40 @@ SCREEN_HEIGHT EQU 18 NPC_MOVEMENT_DOWN EQU $00 NPC_MOVEMENT_UP EQU $40 NPC_MOVEMENT_LEFT EQU $80 -NPC_MOVEMENT_RIGHT EQU $C0 \ No newline at end of file +NPC_MOVEMENT_RIGHT EQU $C0 + +; two option menu constants +YES_NO_MENU EQU 0 +NORTH_WEST_MENU EQU 1 +SOUTH_EAST_MENU EQU 2 +WIDE_YES_NO_MENU EQU 3 +NORTH_EAST_MENU EQU 4 +TRADE_CANCEL_MENU EQU 5 +HEAL_CANCEL_MENU EQU 6 +NO_YES_MENU EQU 7 + +; serial + +ESTABLISH_CONNECTION_WITH_INTERNAL_CLOCK EQU $01 +ESTABLISH_CONNECTION_WITH_EXTERNAL_CLOCK EQU $02 + +USING_EXTERNAL_CLOCK EQU $01 +USING_INTERNAL_CLOCK EQU $02 +CONNECTION_NOT_ESTABLISHED EQU $ff + +; signals the start of an array of bytes transferred over the link cable +SERIAL_PREAMBLE_BYTE EQU $FD + +; this byte is used when there is no data to send +SERIAL_NO_DATA_BYTE EQU $FE + +; signals the end of one part of a patch list (there are two parts) for player/enemy party data +SERIAL_PATCH_LIST_PART_TERMINATOR EQU $FF + +LINK_STATE_NONE EQU $00 ; not using link +LINK_STATE_IN_CABLE_CLUB EQU $01 ; in a cable club room (Colosseum or Trade Centre) +LINK_STATE_START_TRADE EQU $02 ; pre-trade selection screen initialisation +LINK_STATE_START_BATTLE EQU $03 ; pre-battle initialisation +LINK_STATE_BATTLING EQU $04 ; in a link battle +LINK_STATE_RESET EQU $05 ; reset game (unused) +LINK_STATE_TRADING EQU $32 ; in a link trade \ No newline at end of file diff --git a/constants/move_constants.asm b/constants/move_constants.asm index 676f06f2a9..dfbb500e8e 100644 --- a/constants/move_constants.asm +++ b/constants/move_constants.asm @@ -175,10 +175,10 @@ NUM_ATTACKS EQU const_value + -1 const STATUS_AFFECTED_ANIM const ANIM_A8 const ANIM_A9 - const ANIM_AA - const ANIM_AB - const ANIM_AC - const ANIM_AD + const TRADE_BALL_DROP_ANIM + const TRADE_BALL_SHAKE_ANIM + const TRADE_BALL_TILT_ANIM + const TRADE_BALL_POOF_ANIM const XSTATITEM_ANIM ; use X Attack/Defense/Speed/Special const ANIM_AF const ANIM_B0 diff --git a/constants/wram_constants.asm b/constants/wram_constants.asm index e06ca2ce2c..067c8707ac 100644 --- a/constants/wram_constants.asm +++ b/constants/wram_constants.asm @@ -2,13 +2,9 @@ SPRITEBUFFERSIZE EQU 7*7 * 8 ; 7 * 7 (tiles) * 8 (bytes per tile) ; Overload W_GRASSMONS -wd893 EQU $d893 ; W_GRASSMONS + 11 -wd896 EQU $d896 ; W_GRASSMONS + 14 +wSerialEnemyDataBlock EQU $d893 ; W_GRASSMONS + 11 ; Overload enemy party data W_WATERRATE EQU $d8a4 ; wEnemyMon1Species W_WATERMONS EQU $d8a5 ; wEnemyMon1Species + 1 -; Overload enemy stat modifiers -wTradeMonNick EQU $cd1e ; wPlayerMonAccuracyMod - diff --git a/data/hidden_objects.asm b/data/hidden_objects.asm index b67f5c43e1..74d053bb39 100755 --- a/data/hidden_objects.asm +++ b/data/hidden_objects.asm @@ -177,19 +177,19 @@ HiddenObjectPointers: ; 46a96 (11:6a96) ; format: y-coord, x-coord, text id/item id, object routine BattleCenterHiddenObjects: ; 46b40 (11:6b40) db $04,$05,$d0 - db BANK(PrintJustAMomentText2) - dw PrintJustAMomentText2 + db BANK(CableClubRightGameboy) + dw CableClubRightGameboy db $04,$04,$d0 - db BANK(PrintJustAMomentText1) - dw PrintJustAMomentText1 + db BANK(CableClubLeftGameboy) + dw CableClubLeftGameboy db $FF TradeCenterHiddenObjects: ; 46b4d (11:6b4d) db $04,$05,$d0 - db BANK(PrintJustAMomentText2) - dw PrintJustAMomentText2 + db BANK(CableClubRightGameboy) + dw CableClubRightGameboy db $04,$04,$d0 - db BANK(PrintJustAMomentText1) - dw PrintJustAMomentText1 + db BANK(CableClubLeftGameboy) + dw CableClubLeftGameboy db $FF RedsHouse2FHiddenObjects: ; 46b5a (11:6b5a) db $01,$00,$04 diff --git a/engine/battle/15.asm b/engine/battle/15.asm index 2fb3b108cd..0acf351475 100755 --- a/engine/battle/15.asm +++ b/engine/battle/15.asm @@ -1,6 +1,6 @@ GainExperience: ; 5524f (15:524f) - ld a, [W_ISLINKBATTLE] - cp $4 + ld a, [wLinkState] + cp LINK_STATE_BATTLING ret z ; return if link battle call DivideExpDataByNumMonsGainingExp ld hl, wPartyMon1 @@ -226,8 +226,8 @@ GainExperience: ; 5524f (15:524f) ld a, [W_PLAYERBATTSTATUS3] bit 3, a ; is the mon transformed? jr nz, .recalcStatChanges -; the mon is transformed, so copy transformed data - ld de, wcd0f +; the mon is not transformed, so update the unmodified stats + ld de, wPlayerMonUnmodifiedLevel ld bc, $b call CopyData .recalcStatChanges diff --git a/engine/battle/1c.asm b/engine/battle/1c.asm index bceeac2be1..b905777b3a 100755 --- a/engine/battle/1c.asm +++ b/engine/battle/1c.asm @@ -127,8 +127,8 @@ BattleTransition: ; 7096d (1c:496d) call Delay3 call LoadBattleTransitionTile ld bc, $0 - ld a, [W_ISLINKBATTLE] - cp $4 + ld a, [wLinkState] + cp LINK_STATE_BATTLING jr z, .linkBattle call GetBattleTransitionID_WildOrTrainer call GetBattleTransitionID_CompareLevels diff --git a/engine/battle/4_2.asm b/engine/battle/4_2.asm index 6ab5c00494..a3ef126406 100755 --- a/engine/battle/4_2.asm +++ b/engine/battle/4_2.asm @@ -1,6 +1,6 @@ EndOfBattle: ; 137aa (4:77aa) - ld a, [W_ISLINKBATTLE] - cp $4 + ld a, [wLinkState] + cp LINK_STATE_BATTLING jr nz, .notLinkBattle ; link battle ld a, [wEnemyMonPartyPos] @@ -110,7 +110,7 @@ Func_13870: ; 13870 (4:7870) jr z, .lastRepelStep ld [wRepelRemainingSteps], a .asm_1389e -; determine if wild pokémon can appear in the half-block we’re standing +; determine if wild pokmon can appear in the half-block were standing ; is the bottom right tile (9,9) of the half-block are we standing a grass/water tile? hlCoord 9, 9 ld c, [hl] @@ -122,9 +122,9 @@ Func_13870: ; 13870 (4:7870) cp c ld a, [W_WATERRATE] jr z, .CanEncounter -; even if not in grass/water, standing anywhere we can encounter pokémon -; so long as the map is “indoor” and has wild pokémon defined. -; …as long as it’s not Viridian Forest or Safari Zone. +; even if not in grass/water, standing anywhere we can encounter pokmon +; so long as the map is indoor and has wild pokmon defined. +; as long as its not Viridian Forest or Safari Zone. ld a, [W_CURMAP] cp REDS_HOUSE_1F ; is this an indoor map? jr c, .CantEncounter @@ -148,7 +148,7 @@ Func_13870: ; 13870 (4:7870) inc hl jr .determineEncounterSlot .gotEncounterSlot -; determine which wild pokémon (grass or water) can appear in the half-block we’re standing +; determine which wild pokmon (grass or water) can appear in the half-block were standing ld c, [hl] ld hl, W_GRASSMONS aCoord 8, 9 @@ -314,7 +314,7 @@ HazeEffect_: ; 139da (4:79da) call Func_13a43 ld hl, wEnemyMonAttackMod call Func_13a43 - ld hl, wcd12 + ld hl, wPlayerMonUnmodifiedAttack ld de, wBattleMonAttack call Func_13a4a ld hl, wEnemyMonUnmodifiedAttack @@ -386,8 +386,8 @@ StatusChangesEliminatedText: ; 13a53 (4:7a53) db "@" GetTrainerName_: ; 13a58 (4:7a58) - ld hl, W_GRASSRATE - ld a, [W_ISLINKBATTLE] + ld hl, W_GRASSRATE + ld a, [wLinkState] and a jr nz, .rival ld hl, W_RIVALNAME ; wd34a diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm index d84edeb896..d4cebb4489 100755 --- a/engine/battle/animations.asm +++ b/engine/battle/animations.asm @@ -528,9 +528,9 @@ Func_78e23: ; 78e23 (1e:4e23) ld [wcc79], a ld b, $e4 ld a, [W_ANIMATIONID] ; W_ANIMATIONID - cp ANIM_AA + cp TRADE_BALL_DROP_ANIM jr c, .asm_78e3f - cp ANIM_AD + 1 + cp TRADE_BALL_POOF_ANIM + 1 jr nc, .asm_78e3f ld b, $f0 .asm_78e3f @@ -700,13 +700,13 @@ AnimationIdSpecialEffects: ; 78ef5 (1e:4ef5) db ROCK_SLIDE dw DoRockSlideSpecialEffects - db ANIM_AA + db TRADE_BALL_DROP_ANIM dw Func_79041 - db ANIM_AB + db TRADE_BALL_SHAKE_ANIM dw Func_7904c - db ANIM_AC + db TRADE_BALL_TILT_ANIM dw Func_7907c db TOSS_ANIM @@ -960,9 +960,9 @@ Func_7907c ; 507C ld c,5 call DelayFrames pop bc - ld a,[$ffae] ; background scroll X + ld a,[hSCX] ; background scroll X sub a,8 ; scroll to the left - ld [$ffae],a + ld [hSCX],a pop de jr .loop @@ -1307,9 +1307,9 @@ AnimationSlideMonUp: ; 7927a (1e:527a) AnimationSlideMonDown: ; 79297 (1e:5297) ; Slides the mon's sprite down out of the screen. xor a - call Func_79842 + call GetTileIDList .asm_7929b - call Func_79820 + call GetMonSpriteTileMapPointerFromRowCount push bc push de call Func_79aae @@ -1498,8 +1498,8 @@ AnimationFlashEnemyMonPic: ; 79398 (1e:5398) AnimationShowMonPic: ; 7939e (1e:539e) xor a - call Func_79842 - call Func_79820 + call GetTileIDList + call GetMonSpriteTileMapPointerFromRowCount call Func_79aae jp Delay3 @@ -1533,7 +1533,7 @@ AnimationShakeBackAndForth: ; 793b1 (1e:53b1) push af push hl push hl - call Func_79842 + call GetTileIDList pop hl call Func_79aae call Delay3 @@ -1541,7 +1541,7 @@ AnimationShakeBackAndForth: ; 793b1 (1e:53b1) ld bc, $0709 call ClearScreenArea pop af - call Func_79842 + call GetTileIDList pop hl call Func_79aae call Delay3 @@ -1568,7 +1568,7 @@ AnimationMoveMonHorizontally: ; 793f9 (1e:53f9) .asm_79407 xor a push hl - call Func_79842 + call GetTileIDList pop hl call Func_79aae ld c, $3 @@ -1863,8 +1863,8 @@ AnimationSlideMonDownAndHide: ; 795c9 (1e:55c9) call AnimationHideMonPic pop af push af - call Func_79842 - call Func_79820 + call GetTileIDList + call GetMonSpriteTileMapPointerFromRowCount call Func_79aae ld c, $8 call DelayFrames @@ -2133,8 +2133,8 @@ Func_79793: ; 79793 (1e:5793) call GetMonHeader predef LoadMonBackPic xor a - call Func_79842 - call Func_79820 + call GetTileIDList + call GetMonSpriteTileMapPointerFromRowCount call Func_79aae pop af ld [wBattleMonSpecies2], a @@ -2194,37 +2194,46 @@ Func_7980c: ; 7980c (1e:580c) pop hl ret -Func_79820: ; 79820 (1e:5820) +; puts the tile map destination address of a mon sprite in hl, given the row count in b +; The usual row count is 7, but it may be smaller when sliding a mon sprite in/out, +; in order to show only a portion of the mon sprite. +GetMonSpriteTileMapPointerFromRowCount: ; 79820 (1e:5820) push de - ld a, [H_WHOSETURN] ; $fff3 + ld a, [H_WHOSETURN] and a - jr nz, .asm_7982a - ld a, $65 - jr .asm_7982c -.asm_7982a - ld a, $c -.asm_7982c + jr nz, .enemyTurn + ld a, 20 * 5 + 1 + jr .next +.enemyTurn + ld a, 12 +.next ld hl, wTileMap ld e, a - ld d, $0 + ld d, 0 add hl, de - ld a, $7 + ld a, 7 sub b and a - jr z, .asm_79840 - ld de, $14 -.asm_7983c + jr z, .done + ld de, 20 +.loop add hl, de dec a - jr nz, .asm_7983c -.asm_79840 + jr nz, .loop +.done pop de ret -Func_79842: ; 79842 (1e:5842) - ld hl, PointerTable_79aea ; $5aea +; Input: +; a = tile ID list index +; Output: +; de = tile ID list pointer +; b = number of rows +; c = number of columns +GetTileIDList: ; 79842 (1e:5842) + ld hl, TileIDListPointerTable ld e, a - ld d, $0 + ld d, 0 add hl, de add hl, de add hl, de @@ -2486,13 +2495,14 @@ MoveSoundTable: ; 798bc (1e:58bc) db (SFX_08_4b - SFX_Headers_08) / 3,$00,$80 Func_79aae: ; 79aae (1e:5aae) - ld a, [H_WHOSETURN] ; $fff3 + ld a, [H_WHOSETURN] and a - ld a, $31 + ld a, $31 ; base tile ID of player mon sprite jr z, .asm_79ab6 - xor a +; enemy turn + xor a ; base tile ID of enemy mon sprite .asm_79ab6 - ld [H_DOWNARROWBLINKCNT1], a ; $ff8b + ld [hBaseTileID], a jr asm_79acb Func_79aba: ; 79aba (1e:5aba) @@ -2506,34 +2516,36 @@ Func_79aba: ; 79aba (1e:5aba) ld de, Unknown_79b1b ; $5b1b asm_79acb: ; 79acb (1e:5acb) xor a - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba + ld [H_AUTOBGTRANSFERENABLED], a -Func_79ace: ; 79ace (1e:5ace) +; b = number of rows +; c = number of columns +CopyTileIDs: ; 79ace (1e:5ace) push hl -.asm_79acf +.rowLoop push bc push hl - ld a, [H_DOWNARROWBLINKCNT1] ; $ff8b + ld a, [hBaseTileID] ld b, a -.asm_79ad4 +.columnLoop ld a, [de] add b inc de ld [hli], a dec c - jr nz, .asm_79ad4 + jr nz, .columnLoop pop hl - ld bc, $14 + ld bc, 20 add hl, bc pop bc dec b - jr nz, .asm_79acf + jr nz, .rowLoop ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba + ld [H_AUTOBGTRANSFERENABLED], a pop hl ret -PointerTable_79aea: ; 79aea (1e:5aea) +TileIDListPointerTable: ; 79aea (1e:5aea) dw Unknown_79b24 db $77 dw Unknown_79b55 @@ -2552,34 +2564,79 @@ PointerTable_79aea: ; 79aea (1e:5aea) db $3C Unknown_79b02: ; 79b02 (1e:5b02) - db $31,$38,$46,$54,$5B,$32,$39,$47,$55,$5C,$34,$3B,$49,$57,$5E,$36,$3D,$4B,$59,$60,$37,$3E,$4C,$5A,$61 + db $31,$38,$46,$54,$5B + db $32,$39,$47,$55,$5C + db $34,$3B,$49,$57,$5E + db $36,$3D,$4B,$59,$60 + db $37,$3E,$4C,$5A,$61 Unknown_79b1b: ; 79b1b (1e:5b1b) - db $31,$46,$5B,$34,$49,$5E,$37,$4C,$61 + db $31,$46,$5B + db $34,$49,$5E + db $37,$4C,$61 Unknown_79b24: ; 79b24 (1e:5b24) - db $00,$07,$0E,$15,$1C,$23,$2A,$01,$08,$0F,$16,$1D,$24,$2B,$02,$09,$10,$17,$1E,$25,$2C,$03,$0A,$11,$18,$1F,$26,$2D,$04,$0B,$12,$19,$20,$27,$2E,$05,$0C,$13,$1A,$21,$28,$2F,$06,$0D,$14,$1B,$22,$29,$30 + db $00,$07,$0E,$15,$1C,$23,$2A + db $01,$08,$0F,$16,$1D,$24,$2B + db $02,$09,$10,$17,$1E,$25,$2C + db $03,$0A,$11,$18,$1F,$26,$2D + db $04,$0B,$12,$19,$20,$27,$2E + db $05,$0C,$13,$1A,$21,$28,$2F + db $06,$0D,$14,$1B,$22,$29,$30 Unknown_79b55: ; 79b55 (1e:5b55) - db $00,$07,$0E,$15,$1C,$23,$2A,$01,$08,$0F,$16,$1D,$24,$2B,$03,$0A,$11,$18,$1F,$26,$2D,$04,$0B,$12,$19,$20,$27,$2E,$05,$0C,$13,$1A,$21,$28,$2F + db $00,$07,$0E,$15,$1C,$23,$2A + db $01,$08,$0F,$16,$1D,$24,$2B + db $03,$0A,$11,$18,$1F,$26,$2D + db $04,$0B,$12,$19,$20,$27,$2E + db $05,$0C,$13,$1A,$21,$28,$2F Unknown_79b78: ; 79b78 (1e:5b78) - db $00,$07,$0E,$15,$1C,$23,$2A,$02,$09,$10,$17,$1E,$25,$2C,$04,$0B,$12,$19,$20,$27,$2E + db $00,$07,$0E,$15,$1C,$23,$2A + db $02,$09,$10,$17,$1E,$25,$2C + db $04,$0B,$12,$19,$20,$27,$2E Unknown_79b8d: ; 79b8d (1e:5b8d) - db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$19,$00,$02,$06,$0B,$10,$14,$1A,$00,$00,$07,$0C,$11,$15,$1B,$00,$03,$08,$0D,$12,$16,$1C,$00,$04,$09,$0E,$13,$17,$1D,$1F,$05,$0A,$0F,$01,$18,$1E,$20 + db $00,$00,$00,$00,$00,$00,$00 + db $00,$00,$00,$00,$00,$19,$00 + db $02,$06,$0B,$10,$14,$1A,$00 + db $00,$07,$0C,$11,$15,$1B,$00 + db $03,$08,$0D,$12,$16,$1C,$00 + db $04,$09,$0E,$13,$17,$1D,$1F + db $05,$0A,$0F,$01,$18,$1E,$20 Unknown_79bbe: ; 79bbe (1e:5bbe) - db $00,$00,$00,$30,$00,$37,$00,$00,$00,$2B,$31,$34,$38,$3D,$21,$26,$2C,$01,$35,$39,$3E,$22,$27,$2D,$32,$36,$01,$00,$23,$28,$2E,$33,$01,$3A,$00,$24,$29,$2F,$01,$01,$3B,$00,$25,$2A,$01,$01,$01,$3C,$00 + db $00,$00,$00,$30,$00,$37,$00 + db $00,$00,$2B,$31,$34,$38,$3D + db $21,$26,$2C,$01,$35,$39,$3E + db $22,$27,$2D,$32,$36,$01,$00 + db $23,$28,$2E,$33,$01,$3A,$00 + db $24,$29,$2F,$01,$01,$3B,$00 + db $25,$2A,$01,$01,$01,$3C,$00 Unknown_79bef: ; 79bef (1e:5bef) - db $00,$00,$00,$00,$00,$00,$00,$00,$00,$47,$4D,$00,$00,$00,$00,$00,$48,$4E,$52,$56,$5B,$3F,$43,$49,$4F,$53,$57,$5C,$40,$44,$4A,$50,$54,$58,$00,$41,$45,$4B,$51,$4C,$59,$5D,$42,$46,$4C,$4C,$55,$5A,$5E + db $00,$00,$00,$00,$00,$00,$00 + db $00,$00,$47,$4D,$00,$00,$00 + db $00,$00,$48,$4E,$52,$56,$5B + db $3F,$43,$49,$4F,$53,$57,$5C + db $40,$44,$4A,$50,$54,$58,$00 + db $41,$45,$4B,$51,$4C,$59,$5D + db $42,$46,$4C,$4C,$55,$5A,$5E Unknown_79c20: ; 79c20 (1e:5c20) - db $31,$32,$32,$32,$32,$33,$34,$35,$36,$36,$37,$38,$34,$39,$3A,$3A,$3B,$38,$3C,$3D,$3E,$3E,$3F,$40,$41,$42,$43,$43,$44,$45,$46,$47,$43,$48,$49,$4A,$41,$43,$4B,$4C,$4D,$4E,$4F,$50,$50,$50,$51,$52 + db $31,$32,$32,$32,$32,$33 + db $34,$35,$36,$36,$37,$38 + db $34,$39,$3A,$3A,$3B,$38 + db $3C,$3D,$3E,$3E,$3F,$40 + db $41,$42,$43,$43,$44,$45 + db $46,$47,$43,$48,$49,$4A + db $41,$43,$4B,$4C,$4D,$4E + db $4F,$50,$50,$50,$51,$52 Unknown_79c50: ; 79c50 (1e:5c50) - db $43,$55,$56,$53,$53,$53,$53,$53,$53,$53,$53,$53,$43,$57,$58,$54,$54,$54,$54,$54,$54,$54,$54,$54,$43,$59,$5A,$43,$43,$43,$43,$43,$43,$43,$43,$43 + db $43,$55,$56,$53,$53,$53,$53,$53,$53,$53,$53,$53 + db $43,$57,$58,$54,$54,$54,$54,$54,$54,$54,$54,$54 + db $43,$59,$5A,$43,$43,$43,$43,$43,$43,$43,$43,$43 AnimationLeavesFalling: ; 79c74 (1e:5c74) ; Makes leaves float down from the top of the screen. This is used @@ -2743,7 +2800,7 @@ AnimationShakeEnemyHUD: ; 79d77 (1e:5d77) ld bc, 7 * 7 call CopyVideoData xor a - ld [$ffae], a + ld [hSCX], a ld hl, vBGMap0 call Func_79e0d ld a, $90 @@ -2776,34 +2833,36 @@ AnimationShakeEnemyHUD: ; 79d77 (1e:5d77) ld hl, vBGMap1 jp Func_79e0d -Func_79dda: ; 79dda (1e:5dda) +; b = tile ID list index +; c = base tile ID +CopyTileIDsFromList: ; 79dda (1e:5dda) call GetPredefRegisters ld a, c - ld [H_DOWNARROWBLINKCNT1], a ; $ff8b + ld [hBaseTileID], a ld a, b push hl - call Func_79842 + call GetTileIDList pop hl - jp Func_79ace + jp CopyTileIDs Func_79de9: ; 79de9 (1e:5de9) - ld a, [$ffae] + ld a, [hSCX] ld [wTrainerSpriteOffset], a .asm_79dee ld a, [wTrainerSpriteOffset] add d - ld [$ffae], a + ld [hSCX], a ld c, $2 call DelayFrames ld a, [wTrainerSpriteOffset] sub d - ld [$ffae], a + ld [hSCX], a ld c, $2 call DelayFrames dec e jr nz, .asm_79dee ld a, [wTrainerSpriteOffset] - ld [$ffae], a + ld [hSCX], a ret Func_79e0d: ; 79e0d (1e:5e0d) diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 381c82b151..0c506e2bc8 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -99,7 +99,7 @@ SpecialEffectsCont: ; 3c049 (f:4049) SlidePlayerAndEnemySilhouettesOnScreen: ; 3c04c (f:404c) call LoadPlayerBackPic ld a, $1 ; the usual text box at the bottom of the screen - ld [wd125], a + ld [wTextBoxID], a call DisplayTextBoxID hlCoord 1, 5 ld bc, $307 @@ -240,7 +240,7 @@ StartBattle: ; 3c11e (f:411e) jr .findFirstAliveEnemyMonLoop .foundFirstAliveEnemyMon ld a, d - ld [wcc3e], a + ld [wSerialExchangeNybbleReceiveData], a ld a, [W_ISINBATTLE] dec a ; is it a trainer battle? call nz, EnemySendOutFirstMon ; if it is a trainer battle, send out enemy mon @@ -345,8 +345,8 @@ StartBattle: ; 3c11e (f:411e) ; wild mon or link battle enemy ran from battle EnemyRan: ; 3c202 (f:4202) call LoadScreenTilesFromBuffer1 - ld a, [W_ISLINKBATTLE] - cp $4 + ld a, [wLinkState] + cp LINK_STATE_BATTLING ld hl, WildRanText jr nz, .printText ; link battle @@ -431,11 +431,11 @@ MainInBattleLoop: ; 3c233 (f:4233) jr nz, MainInBattleLoop ; if the player didn't select a move, jump .selectEnemyMove call SelectEnemyMove - ld a, [W_ISLINKBATTLE] - cp $4 + ld a, [wLinkState] + cp LINK_STATE_BATTLING jr nz, .noLinkBattle ; link battle - ld a, [wcc3e] + ld a, [wSerialExchangeNybbleReceiveData] cp $f jp z, EnemyRan cp $e @@ -838,7 +838,7 @@ FaintEnemyPokemon ; 0x3c567 ld hl, W_PLAYERBATTSTATUS1 res AttackingMultipleTimes, [hl] xor a - ld [W_NUMHITS], a + ld [wPlayerNumHits], a ld hl, wd065 ; clear enemy statuses ld [hli], a ld [hli], a @@ -976,12 +976,12 @@ ReplaceFaintedEnemyMon: ; 3c664 (f:4664) ld e, $30 call GetBattleHealthBarColor callab DrawEnemyPokeballs - ld a, [W_ISLINKBATTLE] - cp $4 + ld a, [wLinkState] + cp LINK_STATE_BATTLING jr nz, .notLinkBattle ; link battle call LinkBattleExchangeData - ld a, [wcc3e] + ld a, [wSerialExchangeNybbleReceiveData] cp $f ret z call LoadScreenTilesFromBuffer1 @@ -1009,14 +1009,14 @@ TrainerBattleVictory: ; 3c696 (f:4696) ld hl, W_FLAGS_D733 set 1, [hl] .notrival - ld a, [W_ISLINKBATTLE] - cp $4 + ld a, [wLinkState] + cp LINK_STATE_BATTLING ld a, b call nz, PlayBattleVictoryMusic ld hl, TrainerDefeatedText call PrintText - ld a, [W_ISLINKBATTLE] - cp $4 + ld a, [wLinkState] + cp LINK_STATE_BATTLING ret z call ScrollTrainerPicAfterBattle ld c, $28 @@ -1096,7 +1096,7 @@ RemoveFaintedPlayerMon: ; 3c741 (f:4741) ld [wd083], a call WaitForSoundToFinish .skipWaitForSound - ld hl, wcd05 + ld hl, wEnemyNumHits ld [hli], a ld [hl], a ld [wBattleMonStatus], a @@ -1136,7 +1136,7 @@ DoUseNextMonDialogue: ; 3c79b (f:479b) hlCoord 13, 9 ld bc, $a0e ld a, $14 ; yes/no text box - ld [wd125], a + ld [wTextBoxID], a call DisplayTextBoxID ld a, [wd12e] cp $2 ; did the player choose NO? @@ -1169,8 +1169,8 @@ ChooseNextMon: ; 3c7d8 (f:47d8) .monChosen call HasMonFainted jr z, .goBackToPartyMenu ; if mon fainted, you have to choose another - ld a, [W_ISLINKBATTLE] - cp $4 + ld a, [wLinkState] + cp LINK_STATE_BATTLING jr nz, .notLinkBattle inc a ld [wcd6a], a @@ -1204,8 +1204,8 @@ ChooseNextMon: ; 3c7d8 (f:47d8) ; called when player is out of usable mons. ; prints approriate lose message, sets carry flag if player blacked out (special case for initial rival fight) HandlePlayerBlackOut: ; 3c837 (f:4837) - ld a, [W_ISLINKBATTLE] - cp $4 + ld a, [wLinkState] + cp LINK_STATE_BATTLING jr z, .notSony1Battle ld a, [W_CUROPPONENT] cp $c8 + SONY1 @@ -1225,8 +1225,8 @@ HandlePlayerBlackOut: ; 3c837 (f:4837) ld b, $0 call GoPAL_SET ld hl, PlayerBlackedOutText2 - ld a, [W_ISLINKBATTLE] - cp $4 + ld a, [wLinkState] + cp LINK_STATE_BATTLING jr nz, .noLinkBattle ld hl, LinkBattleLostText .noLinkBattle @@ -1385,10 +1385,10 @@ EnemySendOutFirstMon: ; 3c92a (f:492a) call SlideTrainerPicOffScreen call PrintEmptyString call SaveScreenTilesToBuffer1 - ld a,[W_ISLINKBATTLE] - cp 4 + ld a,[wLinkState] + cp LINK_STATE_BATTLING jr nz,.next - ld a,[wcc3e] + ld a,[wSerialExchangeNybbleReceiveData] sub 4 ld [wWhichPokemon],a jr .next3 @@ -1442,8 +1442,8 @@ EnemySendOutFirstMon: ; 3c92a (f:492a) ld a,[wPartyCount] dec a jr z,.next4 - ld a,[W_ISLINKBATTLE] - cp 4 + ld a,[wLinkState] + cp LINK_STATE_BATTLING jr z,.next4 ld a,[W_OPTIONS] bit 6,a @@ -1453,7 +1453,7 @@ EnemySendOutFirstMon: ; 3c92a (f:492a) hlCoord 0, 7 ld bc,$0801 ld a,$14 - ld [wd125],a + ld [wTextBoxID],a call DisplayTextBoxID ld a,[wCurrentMenuItem] and a @@ -1572,8 +1572,8 @@ TryRunningFromBattle: ; 3cab9 (f:4ab9) ld a, [W_BATTLETYPE] cp $2 jp z, .canEscape ; jump if it's a safari battle - ld a, [W_ISLINKBATTLE] - cp $4 + ld a, [wLinkState] + cp LINK_STATE_BATTLING jp z, .canEscape ld a, [W_ISINBATTLE] dec a @@ -1654,8 +1654,8 @@ TryRunningFromBattle: ; 3cab9 (f:4ab9) and a ; reset carry ret .canEscape - ld a, [W_ISLINKBATTLE] - cp $4 + ld a, [wLinkState] + cp LINK_STATE_BATTLING ld a, $2 jr nz, .playSound ; link battle @@ -1666,7 +1666,7 @@ TryRunningFromBattle: ; 3cab9 (f:4ab9) ld [wPlayerMoveListIndex], a call LinkBattleExchangeData call LoadScreenTilesFromBuffer1 - ld a, [wcc3e] + ld a, [wSerialExchangeNybbleReceiveData] cp $f ld a, $2 jr z, .playSound @@ -2082,7 +2082,7 @@ DisplayBattleMenu: ; 3ceb3 (f:4eb3) jr nz, .menuselected ld a, $1b ; regular menu id .menuselected - ld [wd125], a + ld [wTextBoxID], a call DisplayTextBoxID ld a, [W_BATTLETYPE] dec a @@ -2234,8 +2234,8 @@ DisplayBattleMenu: ; 3ceb3 (f:4eb3) jp nz, PartyMenuOrRockOrRun ; either the bag (normal battle) or bait (safari battle) was selected - ld a, [W_ISLINKBATTLE] - cp $4 + ld a, [wLinkState] + cp LINK_STATE_BATTLING jr nz, .notLinkBattle ; can't use items in link battles @@ -2401,7 +2401,7 @@ PartyMenuOrRockOrRun: jr .checkIfPartyMonWasSelected .partyMonWasSelected ld a, $c ; switch/stats/cancel menu - ld [wd125], a + ld [wTextBoxID], a call DisplayTextBoxID ld hl, wTopMenuItemY ld a, $c @@ -2620,8 +2620,8 @@ MoveSelectionMenu: ; 3d219 (f:5219) dec a ld b, $c3 jr z, .matchedkeyspicked - ld a, [W_ISLINKBATTLE] - cp $4 + ld a, [wLinkState] + cp LINK_STATE_BATTLING jr z, .matchedkeyspicked ld a, [W_FLAGS_D733] bit 0, a @@ -2974,14 +2974,14 @@ TypeText: ; 3d55f (f:555f) db "TYPE@" SelectEnemyMove: ; 3d564 (f:5564) - ld a, [W_ISLINKBATTLE] + ld a, [wLinkState] sub $4 jr nz, .noLinkBattle ; link battle call SaveScreenTilesToBuffer1 call LinkBattleExchangeData call LoadScreenTilesFromBuffer1 - ld a, [wcc3e] + ld a, [wSerialExchangeNybbleReceiveData] cp $e jp z, .asm_3d601 cp $d @@ -3068,7 +3068,7 @@ SelectEnemyMove: ; 3d564 (f:5564) ; this appears to exchange data with the other gameboy during link battles LinkBattleExchangeData: ; 3d605 (f:5605) ld a, $ff - ld [wcc3e], a + ld [wSerialExchangeNybbleReceiveData], a ld a, [wPlayerMoveListIndex] cp $f ; is the player running from battle? jr z, .asm_3d630 @@ -3091,24 +3091,24 @@ LinkBattleExchangeData: ; 3d605 (f:5605) .asm_3d62f ld a, b .asm_3d630 - ld [wcc42], a + ld [wSerialExchangeNybbleSendData], a callab PrintWaitingText .asm_3d63b - call Func_22c3 + call Serial_ExchangeNybble call DelayFrame - ld a, [wcc3e] + ld a, [wSerialExchangeNybbleReceiveData] inc a jr z, .asm_3d63b ld b, $a .asm_3d649 call DelayFrame - call Func_22c3 + call Serial_ExchangeNybble dec b jr nz, .asm_3d649 ld b, $a .asm_3d654 call DelayFrame - call Func_22ed + call Serial_SendZeroByte dec b jr nz, .asm_3d654 ret @@ -3296,7 +3296,7 @@ MirrorMoveCheck ld hl,MultiHitText call PrintText xor a - ld [W_NUMHITS],a + ld [wPlayerNumHits],a .executeOtherEffects ld a,[W_PLAYERMOVEEFFECT] and a @@ -3529,7 +3529,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) ld a,[hli] ld b,a ld c,[hl] - ld hl,wd075 + ld hl,wPlayerBideAccumulatedDamage + 1 ld a,[hl] add c ; acumulate damage taken ld [hld],a @@ -3548,7 +3548,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) call PrintText ld a,1 ld [W_PLAYERMOVEPOWER],a - ld hl,wd075 + ld hl,wPlayerBideAccumulatedDamage + 1 ld a,[hld] add a ld b,a @@ -3998,8 +3998,8 @@ OHKOText: ; 3dc83 (f:5c83) CheckForDisobedience: ; 3dc88 (f:5c88) xor a ld [wcced], a - ld a, [W_ISLINKBATTLE] - cp $4 + ld a, [wLinkState] + cp LINK_STATE_BATTLING jr nz, .checkIfMonIsTraded ld a, $1 and a @@ -4424,8 +4424,8 @@ GetDamageVarsForEnemyAttack: ; 3de75 (f:5e75) GetEnemyMonStat: ; 3df1c (f:5f1c) push de push bc - ld a, [W_ISLINKBATTLE] - cp $4 + ld a, [wLinkState] + cp LINK_STATE_BATTLING jr nz, .notLinkBattle ld hl, wEnemyMon1Stats dec c @@ -5627,11 +5627,11 @@ ExecuteEnemyMove: ; 3e6bc (f:66bc) jp z, ExecuteEnemyMoveDone call PrintGhostText jp z, ExecuteEnemyMoveDone - ld a, [W_ISLINKBATTLE] - cp $4 + ld a, [wLinkState] + cp LINK_STATE_BATTLING jr nz, .executeEnemyMove ld b, $1 - ld a, [wcc3e] + ld a, [wSerialExchangeNybbleReceiveData] cp $e jr z, .executeEnemyMove cp $4 @@ -5819,7 +5819,7 @@ asm_3e7ef: ; 3e7ef (f:67ef) ld hl, HitXTimesText call PrintText xor a - ld [wcd05], a + ld [wEnemyNumHits], a .asm_3e873 ld a, [W_ENEMYMOVEEFFECT] and a @@ -6028,7 +6028,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) ld a, [hli] ld b, a ld c, [hl] - ld hl, wcd06 + ld hl, wEnemyBideAccumulatedDamage + 1 ld a, [hl] add c ld [hld], a @@ -6047,7 +6047,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) call PrintText ld a, $1 ld [W_ENEMYMOVEPOWER], a - ld hl, wcd06 + ld hl, wEnemyBideAccumulatedDamage + 1 ld a, [hld] add a ld b, a @@ -6152,8 +6152,8 @@ GetCurrentMove: ; 3eabe (f:6abe) jp CopyStringToCF4B LoadEnemyMonData: ; 3eb01 (f:6b01) - ld a, [W_ISLINKBATTLE] - cp $4 + ld a, [wLinkState] + cp LINK_STATE_BATTLING jp z, LoadEnemyMonFromParty ld a, [wEnemyMonSpecies2] ld [wEnemyMonSpecies], a @@ -6312,8 +6312,8 @@ LoadEnemyMonData: ; 3eb01 (f:6b01) ; calls BattleTransition to show the battle transition animation and initializes some battle variables DoBattleTransitionAndInitBattleVariables: ; 3ec32 (f:6c32) - ld a, [W_ISLINKBATTLE] - cp $4 + ld a, [wLinkState] + cp LINK_STATE_BATTLING jr nz, .next ; link battle xor a @@ -6616,8 +6616,8 @@ CalculateModifiedStat: ; 3eda5 (f:6da5) ret ApplyBadgeStatBoosts: ; 3ee19 (f:6e19) - ld a, [W_ISLINKBATTLE] - cp $4 + ld a, [wLinkState] + cp LINK_STATE_BATTLING ret z ; return if link battle ld a, [W_OBTAINEDBADGES] ld b, a @@ -6706,19 +6706,19 @@ PrintEmptyString: ; 3ee94 (f:6e94) BattleRandom: ; Link battles use a shared PRNG. - ld a, [W_ISLINKBATTLE] - cp $4 + ld a, [wLinkState] + cp LINK_STATE_BATTLING jp nz, Random push hl push bc - ld a, [wLinkBattleRNCount] + ld a, [wLinkBattleRandomNumberListIndex] ld c, a ld b, 0 - ld hl, wd148 + ld hl, wLinkBattleRandomNumberList add hl, bc inc a - ld [wLinkBattleRNCount], a + ld [wLinkBattleRandomNumberListIndex], a cp 9 ld a, [hl] pop bc @@ -6732,8 +6732,9 @@ BattleRandom: ; point to seed 0 so we pick the first number the next time xor a - ld [wLinkBattleRNCount], a - ld hl, wd148 + ld [wLinkBattleRandomNumberListIndex], a + + ld hl, wLinkBattleRandomNumberList ld b, 9 .loop ld a, [hl] @@ -6939,7 +6940,7 @@ _LoadTrainerPic: ; 3f04b (f:704b) ld e, a ld a, [wd034] ld d, a ; de contains pointer to trainer pic - ld a, [W_ISLINKBATTLE] + ld a, [wLinkState] and a ld a, Bank(TrainerPics) ; this is where all the trainer pics are (not counting Red's) jr z, .loadSprite @@ -7698,8 +7699,8 @@ StatModifierDownEffect: ; 3f54c (f:754c) ld hl, wPlayerMonStatMods ld de, W_ENEMYMOVEEFFECT ld bc, W_PLAYERBATTSTATUS1 - ld a, [W_ISLINKBATTLE] - cp $4 + ld a, [wLinkState] + cp LINK_STATE_BATTLING jr z, .statModifierDownEffect call BattleRandom cp $40 ; 1/4 chance to miss by in regular battle @@ -7934,13 +7935,13 @@ StatModifierRatios: ; 3f6cb (f:76cb) BideEffect: ; 3f6e5 (f:76e5) ld hl, W_PLAYERBATTSTATUS1 - ld de, W_NUMHITS + ld de, wPlayerBideAccumulatedDamage ld bc, wPlayerNumAttacksLeft ld a, [H_WHOSETURN] and a jr z, .bideEffect ld hl, W_ENEMYBATTSTATUS1 - ld de, wcd05 + ld de, wEnemyBideAccumulatedDamage ld bc, wEnemyNumAttacksLeft .bideEffect set StoringEnergy, [hl] ; mon is now using bide @@ -8096,13 +8097,13 @@ WasBlownAwayText: ; 3f80c (f:780c) TwoToFiveAttacksEffect: ; 3f811 (f:7811) ld hl, W_PLAYERBATTSTATUS1 ld de, wPlayerNumAttacksLeft - ld bc, W_NUMHITS + ld bc, wPlayerNumHits ld a, [H_WHOSETURN] and a jr z, .twoToFiveAttacksEffect ld hl, W_ENEMYBATTSTATUS1 ld de, wEnemyNumAttacksLeft - ld bc, wcd05 + ld bc, wEnemyNumHits .twoToFiveAttacksEffect bit AttackingMultipleTimes, [hl] ; is mon attacking multiple times? ret nz @@ -8394,8 +8395,8 @@ MimicEffect: ; 3f9ed (f:79ed) ld hl, wBattleMonMoves ld a, [W_PLAYERBATTSTATUS1] jr nz, .asm_3fa13 - ld a, [W_ISLINKBATTLE] - cp $4 + ld a, [wLinkState] + cp LINK_STATE_BATTLING jr nz, .asm_3fa3a ld hl, wEnemyMonMoves ld a, [W_ENEMYBATTSTATUS1] @@ -8500,8 +8501,8 @@ DisableEffect: ; 3fa8a (f:7a8a) and a ld hl, wBattleMonPP jr nz, .asm_3facf - ld a, [W_ISLINKBATTLE] - cp $4 + ld a, [wLinkState] + cp LINK_STATE_BATTLING pop hl jr nz, .asm_3fae1 push hl @@ -8629,7 +8630,7 @@ ParalyzedMayNotAttackText: ; 3fb74 (f:7b74) CheckTargetSubstitute: ; 3fb79 (f:7b79) push hl ld hl, W_ENEMYBATTSTATUS2 - ld a, [$fff3] + ld a, [H_WHOSETURN] and a jr z, .next1 ld hl, W_PLAYERBATTSTATUS2 diff --git a/engine/battle/d.asm b/engine/battle/d.asm index 94a07eb655..7320da2947 100755 --- a/engine/battle/d.asm +++ b/engine/battle/d.asm @@ -9,7 +9,7 @@ DisplayLinkBattleVersusTextBox: ; 372d6 (d:72d6) ld de, wPlayerName call PlaceString hlCoord 4, 10 - ld de, W_GRASSRATE ; enemy name + ld de, wLinkEnemyTrainerName call PlaceString ; place bold "VS" tiles between the names hlCoord 9, 8 diff --git a/engine/battle/e.asm b/engine/battle/e.asm index dd227be73a..9f93baa617 100755 --- a/engine/battle/e.asm +++ b/engine/battle/e.asm @@ -700,7 +700,7 @@ Func_39c37: ; 39c37 (e:5c37) ReadTrainer: ; 39c53 (e:5c53) ; don't change any moves in a link battle - ld a,[W_ISLINKBATTLE] + ld a,[wLinkState] and a ret nz @@ -872,8 +872,8 @@ TrainerAI: ; 3a52e (e:652e) ld a,[W_ISINBATTLE] dec a ret z ; if not a trainer, we're done here - ld a,[W_ISLINKBATTLE] - cp 4 + ld a,[wLinkState] + cp LINK_STATE_BATTLING ret z ld a,[W_TRAINERCLASS] ; what trainer class is this? dec a @@ -1230,8 +1230,8 @@ SwitchEnemyMon: ; 3a74b (e:674b) xor a ld [wd11d],a - ld a,[W_ISLINKBATTLE] - cp 4 + ld a,[wLinkState] + cp LINK_STATE_BATTLING ret z scf ret diff --git a/engine/cable_club.asm b/engine/cable_club.asm index a8a1f90ff2..4390069469 100755 --- a/engine/cable_club.asm +++ b/engine/cable_club.asm @@ -1,4 +1,7 @@ -Func_5317: ; 5317 (1:5317) +; performs the appropriate action when the player uses the gameboy on the table in the Colosseum or Trade Centre +; In the Colosseum, it starts a battle. In the Trade Centre, it displays the trade selection screen. +; Before doing either action, it swaps random numbers, trainer names and party data with the other gameboy. +CableClub_DoBattleOrTrade: ; 5317 (1:5317) ld c, $50 call DelayFrames call ClearScreen @@ -7,286 +10,292 @@ Func_5317: ; 5317 (1:5317) call LoadHpBarAndStatusTilePatterns call LoadTrainerInfoTextBoxTiles hlCoord 3, 8 - ld b, $2 - ld c, $c - call Func_5ab3 + ld b, 2 + ld c, 12 + call CableClub_TextBoxBorder hlCoord 4, 10 - ld de, PleaseWaitString ; $550f + ld de, PleaseWaitString call PlaceString - ld hl, W_NUMHITS ; wd074 + ld hl, wPlayerNumHits xor a ld [hli], a ld [hl], $50 + ; fall through -Func_5345: ; 5345 - ld hl, wd152 - ld a, $fd - ld b, $6 -.asm_534c +; This is called after completing a trade. +CableClub_DoBattleOrTradeAgain: ; 5345 + ld hl, wSerialPlayerDataBlock + ld a, SERIAL_PREAMBLE_BYTE + ld b, 6 +.writePlayeDataBlockPreambleLoop ld [hli], a dec b - jr nz, .asm_534c - ld hl, wd141 - ld a, $fd - ld b, $7 -.asm_5357 + jr nz, .writePlayeDataBlockPreambleLoop + ld hl, wSerialRandomNumberListBlock + ld a, SERIAL_PREAMBLE_BYTE + ld b, 7 +.writeRandomNumberListPreambleLoop ld [hli], a dec b - jr nz, .asm_5357 - ld b, $a -.asm_535d + jr nz, .writeRandomNumberListPreambleLoop + ld b, 10 +.generateRandomNumberListLoop call Random - cp $fd - jr nc, .asm_535d + cp SERIAL_PREAMBLE_BYTE ; all the random numbers have to be less than the preamble byte + jr nc, .generateRandomNumberListLoop ld [hli], a dec b - jr nz, .asm_535d - ld hl, wTileMapBackup - ld a, $fd + jr nz, .generateRandomNumberListLoop + ld hl, wSerialPartyMonsPatchList + ld a, SERIAL_PREAMBLE_BYTE ld [hli], a ld [hli], a ld [hli], a ld b, $c8 xor a -.asm_5373 +.zeroPlayerDataPatchListLoop ld [hli], a dec b - jr nz, .asm_5373 - ld hl, W_GRASSRATE ; W_GRASSRATE - ld bc, $1a9 -.asm_537d + jr nz, .zeroPlayerDataPatchListLoop + ld hl, W_GRASSRATE + ld bc, W_TRAINERHEADERPTR - W_GRASSRATE +.zeroEnemyPartyLoop xor a ld [hli], a dec bc ld a, b or c - jr nz, .asm_537d + jr nz, .zeroEnemyPartyLoop ld hl, wPartyMons - 1 - ld de, wTileMapBackup + 10 - ld bc, $0 -.asm_538d + ld de, wSerialPartyMonsPatchList + 10 + ld bc, 0 +.patchPartyMonsLoop inc c ld a, c - cp $fd - jr z, .asm_53a9 + cp SERIAL_PREAMBLE_BYTE + jr z, .startPatchListPart2 ld a, b - dec a - jr nz, .asm_539c + dec a ; are we in part 2 of the patch list? + jr nz, .checkPlayerDataByte ; jump if in part 1 +; if we're in part 2 ld a, c - cp $d - jr z, .asm_53b2 -.asm_539c + cp (wPartyMonOT - (wPartyMons - 1)) - (SERIAL_PREAMBLE_BYTE - 1) + jr z, .finishedPatchingPlayerData +.checkPlayerDataByte inc hl ld a, [hl] - cp $fe - jr nz, .asm_538d + cp SERIAL_NO_DATA_BYTE + jr nz, .patchPartyMonsLoop +; if the player data byte matches SERIAL_NO_DATA_BYTE, patch it with $FF and record the offset in the patch list ld a, c ld [de], a inc de ld [hl], $ff - jr .asm_538d -.asm_53a9 - ld a, $ff - ld [de], a + jr .patchPartyMonsLoop +.startPatchListPart2 + ld a, SERIAL_PATCH_LIST_PART_TERMINATOR + ld [de], a ; end of part 1 inc de ld bc, $100 - jr .asm_538d -.asm_53b2 - ld a, $ff - ld [de], a - call Func_227f - ld a, [$ffaa] - cp $2 - jr nz, .asm_53d2 + jr .patchPartyMonsLoop +.finishedPatchingPlayerData + ld a, SERIAL_PATCH_LIST_PART_TERMINATOR + ld [de], a ; end of part 2 + call Serial_SyncAndExchangeNybble + ld a, [hSerialConnectionStatus] + cp USING_INTERNAL_CLOCK + jr nz, .skipSendingTwoZeroBytes +; if using internal clock +; send two zero bytes for syncing purposes? call Delay3 xor a - ld [$ffac], a - ld a, $81 - ld [$ff02], a + ld [hSerialSendData], a + ld a, START_TRANSFER_INTERNAL_CLOCK + ld [rSC], a call DelayFrame xor a - ld [$ffac], a - ld a, $81 - ld [$ff02], a -.asm_53d2 + ld [hSerialSendData], a + ld a, START_TRANSFER_INTERNAL_CLOCK + ld [rSC], a +.skipSendingTwoZeroBytes call Delay3 - ld a, $8 - ld [rIE], a ; $ffff - ld hl, wd141 - ld de, wTileMapBackup2 + ld a, (1 << SERIAL) + ld [rIE], a + ld hl, wSerialRandomNumberListBlock + ld de, wSerialOtherGameboyRandomNumberListBlock ld bc, $11 - call Func_216f - ld a, $fe + call Serial_ExchangeBytes + ld a, SERIAL_NO_DATA_BYTE ld [de], a - ld hl, wd152 - ld de, wd893 + ld hl, wSerialPlayerDataBlock + ld de, wSerialEnemyDataBlock ld bc, $1a8 - call Func_216f - ld a, $fe + call Serial_ExchangeBytes + ld a, SERIAL_NO_DATA_BYTE ld [de], a - ld hl, wTileMapBackup - ld de, wTileMapBackup + 200 + ld hl, wSerialPartyMonsPatchList + ld de, wSerialEnemyMonsPatchList ld bc, $c8 - call Func_216f - ld a, $d - ld [rIE], a ; $ffff + call Serial_ExchangeBytes + ld a, (1 << SERIAL) | (1 << TIMER) | (1 << VBLANK) + ld [rIE], a ld a, $ff call PlaySound - ld a, [$ffaa] - cp $2 - jr z, .asm_5431 - ld hl, wTileMapBackup2 -.asm_5415 + ld a, [hSerialConnectionStatus] + cp USING_INTERNAL_CLOCK + jr z, .skipCopyingRandomNumberList ; the list generated by the gameboy clocking the connection is used by both gameboys + ld hl, wSerialOtherGameboyRandomNumberListBlock +.findStartOfRandomNumberListLoop ld a, [hli] and a - jr z, .asm_5415 - cp $fd - jr z, .asm_5415 - cp $fe - jr z, .asm_5415 + jr z, .findStartOfRandomNumberListLoop + cp SERIAL_PREAMBLE_BYTE + jr z, .findStartOfRandomNumberListLoop + cp SERIAL_NO_DATA_BYTE + jr z, .findStartOfRandomNumberListLoop dec hl - ld de, wd148 - ld c, $a -.asm_5427 + ld de, wLinkBattleRandomNumberList + ld c, 10 +.copyRandomNumberListLoop ld a, [hli] - cp $fe - jr z, .asm_5427 + cp SERIAL_NO_DATA_BYTE + jr z, .copyRandomNumberListLoop ld [de], a inc de dec c - jr nz, .asm_5427 -.asm_5431 - ld hl, wd896 -.asm_5434 + jr nz, .copyRandomNumberListLoop +.skipCopyingRandomNumberList + ld hl, wSerialEnemyDataBlock + 3 +.findStartOfEnemyNameLoop ld a, [hli] and a - jr z, .asm_5434 - cp $fd - jr z, .asm_5434 - cp $fe - jr z, .asm_5434 + jr z, .findStartOfEnemyNameLoop + cp SERIAL_PREAMBLE_BYTE + jr z, .findStartOfEnemyNameLoop + cp SERIAL_NO_DATA_BYTE + jr z, .findStartOfEnemyNameLoop dec hl - ld de, W_GRASSRATE ; W_GRASSRATE - ld c, $b -.asm_5446 + ld de, wLinkEnemyTrainerName + ld c, 11 +.copyEnemyNameLoop ld a, [hli] - cp $fe - jr z, .asm_5446 + cp SERIAL_NO_DATA_BYTE + jr z, .copyEnemyNameLoop ld [de], a inc de dec c - jr nz, .asm_5446 - ld de, wEnemyPartyCount ; wEnemyPartyCount - ld bc, $194 -.asm_5456 + jr nz, .copyEnemyNameLoop + ld de, wEnemyPartyCount + ld bc, W_TRAINERHEADERPTR - wEnemyPartyCount +.copyEnemyPartyLoop ld a, [hli] - cp $fe - jr z, .asm_5456 + cp SERIAL_NO_DATA_BYTE + jr z, .copyEnemyPartyLoop ld [de], a inc de dec bc ld a, b or c - jr nz, .asm_5456 - ld de, wTileMapBackup + jr nz, .copyEnemyPartyLoop + ld de, wSerialPartyMonsPatchList ld hl, wPartyMons - ld c, $2 -.asm_546a + ld c, 2 ; patch list has 2 parts +.unpatchPartyMonsLoop ld a, [de] inc de and a - jr z, .asm_546a - cp $fd - jr z, .asm_546a - cp $fe - jr z, .asm_546a - cp $ff - jr z, .asm_5489 + jr z, .unpatchPartyMonsLoop + cp SERIAL_PREAMBLE_BYTE + jr z, .unpatchPartyMonsLoop + cp SERIAL_NO_DATA_BYTE + jr z, .unpatchPartyMonsLoop + cp SERIAL_PATCH_LIST_PART_TERMINATOR + jr z, .finishedPartyMonsPatchListPart push hl push bc ld b, 0 dec a ld c, a add hl, bc - ld a, $fe + ld a, SERIAL_NO_DATA_BYTE ld [hl], a pop bc pop hl - jr .asm_546a -.asm_5489 - ld hl, wPartyMons + $fc ; wd267 - dec c - jr nz, .asm_546a - ld de, wTileMapBackup + 200 + jr .unpatchPartyMonsLoop +.finishedPartyMonsPatchListPart + ld hl, wPartyMons + (SERIAL_PREAMBLE_BYTE - 1) + dec c ; is there another part? + jr nz, .unpatchPartyMonsLoop + ld de, wSerialEnemyMonsPatchList ld hl, wEnemyMons - ld c, $2 -.asm_5497 + ld c, 2 ; patch list has 2 parts +.unpatchEnemyMonsLoop ld a, [de] inc de and a - jr z, .asm_5497 - cp $fd - jr z, .asm_5497 - cp $fe - jr z, .asm_5497 - cp $ff - jr z, .asm_54b6 + jr z, .unpatchEnemyMonsLoop + cp SERIAL_PREAMBLE_BYTE + jr z, .unpatchEnemyMonsLoop + cp SERIAL_NO_DATA_BYTE + jr z, .unpatchEnemyMonsLoop + cp SERIAL_PATCH_LIST_PART_TERMINATOR + jr z, .finishedEnemyMonsPatchListPart push hl push bc - ld b, $0 + ld b, 0 dec a ld c, a add hl, bc - ld a, $fe + ld a, SERIAL_NO_DATA_BYTE ld [hl], a pop bc pop hl - jr .asm_5497 -.asm_54b6 - ld hl, wEnemyMons + $fc + jr .unpatchEnemyMonsLoop +.finishedEnemyMonsPatchListPart + ld hl, wEnemyMons + (SERIAL_PREAMBLE_BYTE - 1) dec c - jr nz, .asm_5497 - ld a, $ac + jr nz, .unpatchEnemyMonsLoop + ld a, wEnemyMonOT % $100 ld [wcf8d], a - ld a, $d9 + ld a, wEnemyMonOT / $100 ld [wcf8e], a xor a - ld [wcc38], a + ld [wTradeCenterPointerTableIndex], a ld a, $ff call PlaySound - ld a, [$ffaa] - cp $2 - ld c, $42 - call z, DelayFrames - ld a, [W_ISLINKBATTLE] ; W_ISLINKBATTLE - cp $3 - ld a, $32 - ld [W_ISLINKBATTLE], a ; W_ISLINKBATTLE + ld a, [hSerialConnectionStatus] + cp USING_INTERNAL_CLOCK + ld c, 66 + call z, DelayFrames ; delay if using internal clock + ld a, [wLinkState] + cp LINK_STATE_START_BATTLE + ld a, LINK_STATE_TRADING + ld [wLinkState], a jr nz, .asm_5506 - ld a, $4 - ld [W_ISLINKBATTLE], a ; W_ISLINKBATTLE + ld a, LINK_STATE_BATTLING + ld [wLinkState], a ld a, SONY1 + $c8 - ld [W_CUROPPONENT], a ; wd059 + ld [W_CUROPPONENT], a call ClearScreen call Delay3 - ld hl, W_OPTIONS ; W_OPTIONS + ld hl, W_OPTIONS res 7, [hl] predef InitOpponent predef HealParty - jp Func_577d + jp ReturnToCableClubRoom .asm_5506 ld c, BANK(Music_GameCorner) ld a, MUSIC_GAME_CORNER call PlayMusic - jr Func_551c + jr CallCurrentTradeCenterFunction PleaseWaitString: ; 550f (1:550f) db "PLEASE WAIT!@" -Func_551c: - ld hl, PointerTable_5a5b ; $5a5b - ld b, $0 - ld a, [wcc38] +CallCurrentTradeCenterFunction: + ld hl, TradeCenterPointerTable + ld b, 0 + ld a, [wTradeCenterPointerTableIndex] cp $ff jp z, LoadTitlescreenGraphics add a @@ -300,10 +309,10 @@ Func_551c: TradeCenter_SelectMon: call ClearScreen call LoadTrainerInfoTextBoxTiles - call Func_57f2 - call Func_57a2 + call TradeCenter_DrawPartyLists + call TradeCenter_DrawCancelBox xor a - ld hl, wcc3d + ld hl, wSerialSyncAndExchangeNybbleReceiveData ld [hli], a ld [hli], a ld [hli], a @@ -313,51 +322,53 @@ TradeCenter_SelectMon: ld [wLastMenuItem], a ld [wMenuJoypadPollCount], a inc a - ld [wcc42], a - jp .asm_55dc -.asm_5557 + ld [wSerialExchangeNybbleSendData], a + jp .playerMonMenu +.enemyMonMenu xor a ld [wcc37], a inc a - ld [wcc49], a - ld a, $a1 + ld [wWhichTradeMonSelectionMenu], a + ld a, D_DOWN | D_LEFT | A_BUTTON ld [wMenuWatchedKeys], a ld a, [wEnemyPartyCount] ld [wMaxMenuItem], a - ld a, $9 + ld a, 9 ld [wTopMenuItemY], a - ld a, $1 + ld a, 1 ld [wTopMenuItemX], a -.asm_5574 +.enemyMonMenu_HandleInput ld hl, $fff6 set 1, [hl] call HandleMenuInput ld hl, $fff6 res 1, [hl] and a - jp z, .asm_565b - bit 0, a - jr z, .asm_55b0 ; 0x5587 $27 + jp z, .getNewInput + bit 0, a ; A button pressed? + jr z, .enemyMonMenu_ANotPressed +; if A button pressed ld a, [wMaxMenuItem] ld c, a ld a, [wCurrentMenuItem] cp c - jr c, .asm_559a ; 0x5591 $7 + jr c, .displayEnemyMonStats ld a, [wMaxMenuItem] dec a ld [wCurrentMenuItem], a -.asm_559a +.displayEnemyMonStats ld a, $1 ld [wd11b], a callab Func_39bd5 ld hl, wEnemyMons - call Func_57d6 - jp .asm_565b -.asm_55b0 - bit 5, a - jr z, .asm_55d4 ; 0x55b2 $20 - xor a - ld [wcc49], a + call TradeCenter_DisplayStats + jp .getNewInput +.enemyMonMenu_ANotPressed + bit 5, a ; Left pressed? + jr z, .enemyMonMenu_LeftNotPressed +; if Left pressed, switch back to the player mon menu + xor a ; player mon menu + ld [wWhichTradeMonSelectionMenu], a ld a, [wMenuCursorLocation] ld l, a ld a, [wMenuCursorLocation + 1] @@ -369,51 +380,53 @@ TradeCenter_SelectMon: ld a, [wPartyCount] dec a cp b - jr nc, .asm_55dc ; 0x55cd $d + jr nc, .playerMonMenu ld [wCurrentMenuItem], a - jr .asm_55dc ; 0x55d2 $8 -.asm_55d4 - bit 7, a - jp z, .asm_565b - jp .asm_572f -.asm_55dc - xor a - ld [wcc49], a + jr .playerMonMenu +.enemyMonMenu_LeftNotPressed + bit 7, a ; Down pressed? + jp z, .getNewInput + jp .selectedCancelMenuItem ; jump if Down pressed +.playerMonMenu + xor a ; player mon menu + ld [wWhichTradeMonSelectionMenu], a ld [wcc37], a - ld a, $91 + ld a, D_DOWN | D_RIGHT | A_BUTTON ld [wMenuWatchedKeys], a ld a, [wPartyCount] ld [wMaxMenuItem], a - ld a, $1 + ld a, 1 ld [wTopMenuItemY], a - ld a, $1 + ld a, 1 ld [wTopMenuItemX], a - ld hl, wTileMap + $15 + hlCoord 1, 1 ld bc, $0601 call ClearScreenArea -.asm_5601 +.playerMonMenu_HandleInput ld hl, $fff6 set 1, [hl] call HandleMenuInput ld hl, $fff6 res 1, [hl] - and a - jr nz, .asm_5614 ; 0x560f $3 - jp .asm_565b -.asm_5614 - bit 0, a - jr z, .asm_562e ; 0x5616 $16 - jp .asm_5665 + and a ; was anything pressed? + jr nz, .playerMonMenu_SomethingPressed + jp .getNewInput +.playerMonMenu_SomethingPressed + bit 0, a ; A button pressed? + jr z, .playerMonMenu_ANotPressed + jp .chosePlayerMon ; jump if A button pressed +; unreachable code ld a, $4 ld [wd11b], a callab Func_39bd5 - call Func_57d6 - jp .asm_565b -.asm_562e - bit 4, a - jr z, .asm_5654 ; 0x5630 $22 - ld a, $1 - ld [wcc49], a + call TradeCenter_DisplayStats + jp .getNewInput +.playerMonMenu_ANotPressed + bit 4, a ; Right pressed? + jr z, .playerMonMenu_RightNotPressed +; if Right pressed, switch to the enemy mon menu + ld a, $1 ; enemy mon menu + ld [wWhichTradeMonSelectionMenu], a ld a, [wMenuCursorLocation] ld l, a ld a, [wMenuCursorLocation + 1] @@ -425,36 +438,37 @@ TradeCenter_SelectMon: ld a, [wEnemyPartyCount] dec a cp b - jr nc, .asm_5651 ; 0x564c $3 + jr nc, .notPastLastEnemyMon +; when switching to the enemy mon menu, if the menu selection would be past the last enemy mon, select the last enemy mon ld [wCurrentMenuItem], a -.asm_5651 - jp .asm_5557 -.asm_5654 - bit 7, a - jr z, .asm_565b ; 0x5656 $3 - jp .asm_572f -.asm_565b - ld a, [wcc49] +.notPastLastEnemyMon + jp .enemyMonMenu +.playerMonMenu_RightNotPressed + bit 7, a ; Down pressed? + jr z, .getNewInput + jp .selectedCancelMenuItem ; jump if Down pressed +.getNewInput + ld a, [wWhichTradeMonSelectionMenu] and a - jp z, .asm_5601 - jp .asm_5574 -.asm_5665 + jp z, .playerMonMenu_HandleInput + jp .enemyMonMenu_HandleInput +.chosePlayerMon call SaveScreenTilesToBuffer1 call PlaceUnfilledArrowMenuCursor ld a, [wMaxMenuItem] ld c, a ld a, [wCurrentMenuItem] cp c - jr c, .asm_5679 ; 0x5673 $4 + jr c, .displayStatsTradeMenu ld a, [wMaxMenuItem] dec a -.asm_5679 +.displayStatsTradeMenu push af - ld hl, wTileMap + $118 - ld b, $2 - ld c, $12 - call Func_5ab3 - ld hl, wTileMap + $142 + hlCoord 0, 14 + ld b, 2 + ld c, 18 + call CableClub_TextBoxBorder + hlCoord 2, 16 ld de, .statsTrade call PlaceString xor a @@ -462,105 +476,107 @@ TradeCenter_SelectMon: ld [wLastMenuItem], a ld [wMenuJoypadPollCount], a ld [wMaxMenuItem], a - ld a, $10 + ld a, 16 ld [wTopMenuItemY], a -.asm_569f - ld a, $7f - ld [wTileMap + $14b], a - ld a, $13 +.selectStatsMenuItem + ld a, " " + Coorda 11, 16 + ld a, D_RIGHT | B_BUTTON | A_BUTTON ld [wMenuWatchedKeys], a - ld a, $1 + ld a, 1 ld [wTopMenuItemX], a call HandleMenuInput - bit 4, a - jr nz, .asm_56c3 ; 0x56b3 $e - bit 1, a - jr z, .asm_56df ; 0x56b7 $26 -.asm_56b9 + bit 4, a ; Right pressed? + jr nz, .selectTradeMenuItem + bit 1, a ; B button pressed? + jr z, .displayPlayerMonStats +.cancelPlayerMonChoice pop af ld [wCurrentMenuItem], a call LoadScreenTilesFromBuffer1 - jp .asm_55dc -.asm_56c3 - ld a, $7f - ld [wTileMap + $141], a - ld a, $23 + jp .playerMonMenu +.selectTradeMenuItem + ld a, " " + Coorda 1, 16 + ld a, D_LEFT | B_BUTTON | A_BUTTON ld [wMenuWatchedKeys], a - ld a, $b + ld a, 11 ld [wTopMenuItemX], a call HandleMenuInput - bit 5, a - jr nz, .asm_569f ; 0x56d7 $c6 - bit 1, a - jr nz, .asm_56b9 ; 0x56db $dc - jr .asm_56f9 ; 0x56dd $1a -.asm_56df + bit 5, a ; Left pressed? + jr nz, .selectStatsMenuItem + bit 1, a ; B button pressed? + jr nz, .cancelPlayerMonChoice + jr .choseTrade +.displayPlayerMonStats pop af ld [wCurrentMenuItem], a ld a, $4 ld [wd11b], a callab Func_39bd5 - call Func_57d6 + call TradeCenter_DisplayStats call LoadScreenTilesFromBuffer1 - jp .asm_55dc -.asm_56f9 + jp .playerMonMenu +.choseTrade call PlaceUnfilledArrowMenuCursor pop af ld [wCurrentMenuItem], a - ld [wWhichTrade], a - ld [wcc42], a - call Func_226e - ld a, [wcc3d] + ld [wTradingWhichPlayerMon], a + ld [wSerialExchangeNybbleSendData], a + call Serial_PrintWaitingTextAndSyncAndExchangeByte + ld a, [wSerialSyncAndExchangeNybbleReceiveData] cp $f - jp z, Func_551c - ld [wTrainerEngageDistance], a - call Func_57c7 - ld a, $1 - ld [wcc38], a - jp Func_551c + jp z, CallCurrentTradeCenterFunction ; go back to the beginning of the trade selection menu if the other person cancelled + ld [wTradingWhichEnemyMon], a + call TradeCenter_PlaceSelectedEnemyMonMenuCursor + ld a, $1 ; TradeCenter_Trade + ld [wTradeCenterPointerTableIndex], a + jp CallCurrentTradeCenterFunction .statsTrade db "STATS TRADE@" -.asm_572f +.selectedCancelMenuItem ld a, [wCurrentMenuItem] ld b, a ld a, [wMaxMenuItem] cp b - jp nz, .asm_565b + jp nz, .getNewInput ld a, [wMenuCursorLocation] ld l, a ld a, [wMenuCursorLocation + 1] ld h, a - ld a, $7f + ld a, " " ld [hl], a -.asm_5745 - ld a, $ed - ld [wTileMap + $141], a -.asm_574a +.cancelMenuItem_Loop + ld a, $ed ; filled arrow cursor + Coorda 1, 16 +.cancelMenuItem_JoypadLoop call JoypadLowSensitivity - ld a, [hJoy5] - and a - jr z, .asm_574a ; 0x5750 $f8 - bit 0, a - jr nz, .asm_5769 ; 0x5754 $13 - bit 6, a - jr z, .asm_574a ; 0x5758 $f0 - ld a, $7f - ld [wTileMap + $141], a + ld a, [$ffb5] + and a ; pressed anything? + jr z, .cancelMenuItem_JoypadLoop + bit 0, a ; A button pressed? + jr nz, .cancelMenuItem_APressed + bit 6, a ; Up pressed? + jr z, .cancelMenuItem_JoypadLoop +; if Up pressed + ld a, " " + Coorda 1, 16 ld a, [wPartyCount] dec a ld [wCurrentMenuItem], a - jp .asm_55dc -.asm_5769 - ld a, $ec - ld [wTileMap + $141], a + jp .playerMonMenu +.cancelMenuItem_APressed + ld a, $ec ; unfilled arrow cursor + Coorda 1, 16 ld a, $f - ld [wcc42], a - call Func_226e - ld a, [wcc3d] - cp $f - jr nz, .asm_5745 ; 0x577b $c8 + ld [wSerialExchangeNybbleSendData], a + call Serial_PrintWaitingTextAndSyncAndExchangeByte + ld a, [wSerialSyncAndExchangeNybbleReceiveData] + cp $f ; did the other person choose Cancel too? + jr nz, .cancelMenuItem_Loop + ; fall through -Func_577d: ; 577d (1:577d) +ReturnToCableClubRoom: ; 577d (1:577d) call GBPalWhiteOutWithDelay3 ld hl, wcfc4 ld a, [hl] @@ -579,64 +595,65 @@ Func_577d: ; 577d (1:577d) call GBFadeInFromWhite ret -Func_57a2: - ld hl, wTileMap + $137 +TradeCenter_DrawCancelBox: + hlCoord 11, 15 ld a, $7e - ld bc, $0031 + ld bc, 2 * 20 + 9 call FillMemory - ld hl, wTileMap + $12c - ld b, $1 - ld c, $9 - call Func_5ab3 - ld hl, wTileMap + $142 + hlCoord 0, 15 + ld b, 1 + ld c, 9 + call CableClub_TextBoxBorder + hlCoord 2, 16 ld de, CancelTextString jp PlaceString CancelTextString: db "CANCEL@" -Func_57c7: - ld a, [wcc3d] - ld hl, wTileMap + $b5 - ld bc, $0014 +TradeCenter_PlaceSelectedEnemyMonMenuCursor: + ld a, [wSerialSyncAndExchangeNybbleReceiveData] + hlCoord 1, 9 + ld bc, 20 call AddNTimes - ld [hl], $ec + ld [hl], $ec ; cursor ret -Func_57d6: +TradeCenter_DisplayStats: ld a, [wCurrentMenuItem] ld [wWhichPokemon], a predef StatusScreen predef StatusScreen2 call GBPalNormal call LoadTrainerInfoTextBoxTiles - call Func_57f2 - jp Func_57a2 + call TradeCenter_DrawPartyLists + jp TradeCenter_DrawCancelBox -Func_57f2: - ld hl, wTileMap - ld b, $6 - ld c, $12 - call Func_5ab3 - ld hl, wTileMap + $a0 - ld b, $6 - ld c, $12 - call Func_5ab3 - ld hl, wTileMap + $5 +TradeCenter_DrawPartyLists: + hlCoord 0, 0 + ld b, 6 + ld c, 18 + call CableClub_TextBoxBorder + hlCoord 0, 8 + ld b, 6 + ld c, 18 + call CableClub_TextBoxBorder + hlCoord 5, 0 ld de, wPlayerName call PlaceString - ld hl, wTileMap + $a5 - ld de, W_GRASSRATE + hlCoord 5, 8 + ld de, wLinkEnemyTrainerName call PlaceString - ld hl, wTileMap + $16 + hlCoord 2, 1 ld de, wPartySpecies - call Func_5827 - ld hl, wTileMap + $b6 + call TradeCenter_PrintPartyListNames + hlCoord 2, 9 ld de, wEnemyPartyMons + ; fall through -Func_5827: +TradeCenter_PrintPartyListNames: ld c, $0 -.asm_5829 +.loop ld a, [de] cp $ff ret z @@ -653,144 +670,146 @@ Func_5827: pop de inc de pop hl - ld bc, $0014 + ld bc, 20 add hl, bc pop bc inc c - jr .asm_5829 ; 0x5847 $e0 + jr .loop TradeCenter_Trade: - ld c, $64 + ld c, 100 call DelayFrames xor a - ld [wcc43], a - ld [wcc3e], a + ld [wSerialExchangeNybbleSendData + 1], a ; unnecessary + ld [wSerialExchangeNybbleReceiveData], a ld [wcc37], a ld [wMenuJoypadPollCount], a - ld hl, wTileMap + $f0 - ld b, $4 - ld c, $12 - call Func_5ab3 - ld a, [wWhichTrade] + hlCoord 0, 12 + ld b, 4 + ld c, 18 + call CableClub_TextBoxBorder + ld a, [wTradingWhichPlayerMon] ld hl, wPartySpecies ld c, a - ld b, $0 + ld b, 0 add hl, bc ld a, [hl] ld [wd11e], a call GetMonName ld hl, wcd6d - ld de, wTrainerFacingDirection - ld bc, $000b + ld de, wNameOfPlayerMonToBeTraded + ld bc, 11 call CopyData - ld a, [wTrainerEngageDistance] + ld a, [wTradingWhichEnemyMon] ld hl, wEnemyPartyMons ld c, a - ld b, $0 + ld b, 0 add hl, bc ld a, [hl] ld [wd11e], a call GetMonName ld hl, WillBeTradedText - ld bc, wTileMap + $119 + bcCoord 1, 14 call TextCommandProcessor call SaveScreenTilesToBuffer1 - ld hl, wTileMap + $96 + hlCoord 10, 7 ld bc, $080b - ld a, $5 - ld [wd12c], a + ld a, TRADE_CANCEL_MENU + ld [wTwoOptionMenuID], a ld a, $14 - ld [wd125], a + ld [wTextBoxID], a call DisplayTextBoxID call LoadScreenTilesFromBuffer1 ld a, [wCurrentMenuItem] and a - jr z, .asm_58d9 ; 0x58b9 $1e + jr z, .tradeConfirmed +; if trade cancelled ld a, $1 - ld [wcc42], a - ld hl, wTileMap + $f0 - ld b, $4 - ld c, $12 - call Func_5ab3 - ld hl, wTileMap + $119 + ld [wSerialExchangeNybbleSendData], a + hlCoord 0, 12 + ld b, 4 + ld c, 18 + call CableClub_TextBoxBorder + hlCoord 1, 14 ld de, TradeCanceled call PlaceString - call Func_226e - jp Func_5a18 -.asm_58d9 + call Serial_PrintWaitingTextAndSyncAndExchangeByte + jp .tradeCancelled +.tradeConfirmed ld a, $2 - ld [wcc42], a - call Func_226e - ld a, [wcc3d] - dec a - jr nz, .asm_58fd ; 0x58e5 $16 - ld hl, wTileMap + $f0 - ld b, $4 - ld c, $12 - call Func_5ab3 - ld hl, wTileMap + $119 + ld [wSerialExchangeNybbleSendData], a + call Serial_PrintWaitingTextAndSyncAndExchangeByte + ld a, [wSerialSyncAndExchangeNybbleReceiveData] + dec a ; did the other person cancel? + jr nz, .doTrade +; if the other person cancelled + hlCoord 0, 12 + ld b, 4 + ld c, 18 + call CableClub_TextBoxBorder + hlCoord 1, 14 ld de, TradeCanceled call PlaceString - jp Func_5a18 -.asm_58fd - ld a, [wWhichTrade] - ld hl, wPartyMonOT ; OT names of player + jp .tradeCancelled +.doTrade + ld a, [wTradingWhichPlayerMon] + ld hl, wPartyMonOT call SkipFixedLengthTextEntries - ld de, wTrainerScreenX - ld bc, $000b + ld de, wTradedPlayerMonOT + ld bc, 11 call CopyData ld hl, wPartyMon1Species - ld a, [wWhichTrade] - ld bc, $002c + ld a, [wTradingWhichPlayerMon] + ld bc, wPartyMon2 - wPartyMon1 call AddNTimes - ld bc, $000c + ld bc, wPartyMon1OTID - wPartyMon1 add hl, bc ld a, [hli] - ld [wcd4c], a + ld [wTradedPlayerMonOTID], a ld a, [hl] - ld [wcd4d], a - ld a, [wTrainerEngageDistance] - ld hl, wEnemyMonOT ; OT names of other player + ld [wTradedPlayerMonOTID + 1], a + ld a, [wTradingWhichEnemyMon] + ld hl, wEnemyMonOT call SkipFixedLengthTextEntries - ld de, wcd4e - ld bc, $000b + ld de, wTradedEnemyMonOT + ld bc, 11 call CopyData ld hl, wEnemyMons - ld a, [wTrainerEngageDistance] - ld bc, $002c + ld a, [wTradingWhichEnemyMon] + ld bc, wEnemyMon2 - wEnemyMon1 call AddNTimes - ld bc, $000c + ld bc, wEnemyMon1OTID - wEnemyMon1 add hl, bc ld a, [hli] - ld [wcd59], a + ld [wTradedEnemyMonOTID], a ld a, [hl] - ld [wcd5a], a - ld a, [wWhichTrade] + ld [wTradedEnemyMonOTID + 1], a + ld a, [wTradingWhichPlayerMon] ld [wWhichPokemon], a ld hl, wPartySpecies - ld b, $0 + ld b, 0 ld c, a add hl, bc ld a, [hl] - ld [wWhichTrade], a + ld [wTradedPlayerMonSpecies], a xor a ld [wcf95], a call RemovePokemon - ld a, [wTrainerEngageDistance] + ld a, [wTradingWhichEnemyMon] ld c, a ld [wWhichPokemon], a ld hl, wEnemyPartyMons - ld d, $0 + ld d, 0 ld e, a add hl, de ld a, [hl] ld [wcf91], a ld hl, wEnemyMons ld a, c - ld bc, $002c + ld bc, wEnemyMon2 - wEnemyMon1 call AddNTimes ld de, wcf98 - ld bc, $002c + ld bc, wEnemyMon2 - wEnemyMon1 call CopyData call AddEnemyMonToPlayerParty ld a, [wPartyCount] @@ -798,13 +817,13 @@ TradeCenter_Trade: ld [wWhichPokemon], a ld a, $1 ld [wccd4], a - ld a, [wTrainerEngageDistance] + ld a, [wTradingWhichEnemyMon] ld hl, wEnemyPartyMons - ld b, $0 + ld b, 0 ld c, a add hl, bc ld a, [hl] - ld [wTrainerEngageDistance], a + ld [wTradedEnemyMonSpecies], a ld a, $a ld [wMusicHeaderPointer], a ld a, $2 @@ -812,46 +831,45 @@ TradeCenter_Trade: ld a, MUSIC_SAFARI_ZONE ld [wc0ee], a call PlaySound - ld c, $64 + ld c, 100 call DelayFrames call ClearScreen call LoadHpBarAndStatusTilePatterns xor a ld [wcc5b], a - ld a, [$ffaa] - cp $1 - jr z, .asm_59d9 ; 0x59d0 $7 + ld a, [hSerialConnectionStatus] + cp USING_EXTERNAL_CLOCK + jr z, .usingExternalClock predef Func_410e2 - jr .asm_59de ; 0x59d7 $5 -.asm_59d9 + jr .tradeCompleted +.usingExternalClock predef Func_410f3 -.asm_59de +.tradeCompleted callab TryEvolvingMon call ClearScreen call LoadTrainerInfoTextBoxTiles - call Func_226e - ld c, $28 + call Serial_PrintWaitingTextAndSyncAndExchangeByte + ld c, 40 call DelayFrames - ld hl, wTileMap + $f0 - ld b, $4 - ld c, $12 - call Func_5ab3 - ld hl, wTileMap + $119 + hlCoord 0, 12 + ld b, 4 + ld c, 18 + call CableClub_TextBoxBorder + hlCoord 1, 14 ld de, TradeCompleted call PlaceString predef SaveSAVtoSRAM2 - ld c, $32 + ld c, 50 call DelayFrames xor a - ld [wcc38], a - jp Func_5345 - -Func_5a18: - ld c, $64 + ld [wTradeCenterPointerTableIndex], a + jp CableClub_DoBattleOrTradeAgain +.tradeCancelled + ld c, 100 call DelayFrames - xor a - ld [wcc38], a - jp Func_551c + xor a ; TradeCenter_SelectMon + ld [wTradeCenterPointerTableIndex], a + jp CallCurrentTradeCenterFunction WillBeTradedText: ; 5a24 (1:5a24) TX_FAR _WillBeTradedText @@ -864,22 +882,22 @@ TradeCanceled: db "Too bad! The trade" next "was canceled!@" -PointerTable_5a5b: ; 5a5b (1:5a5b) +TradeCenterPointerTable: ; 5a5b (1:5a5b) dw TradeCenter_SelectMon dw TradeCenter_Trade -Func_5a5f: ; 5a5f (1:5a5f) - ld a, [W_ISLINKBATTLE] ; W_ISLINKBATTLE - cp $2 - jr z, .asm_5a75 - cp $3 - jr z, .asm_5a75 - cp $5 +CableClub_Run: ; 5a5f (1:5a5f) + ld a, [wLinkState] + cp LINK_STATE_START_TRADE + jr z, .doBattleOrTrade + cp LINK_STATE_START_BATTLE + jr z, .doBattleOrTrade + cp LINK_STATE_RESET ; this is never used ret nz - predef Func_5aaf + predef EmptyFunc3 jp Init -.asm_5a75 - call Func_5317 +.doBattleOrTrade + call CableClub_DoBattleOrTrade ld hl, Club_GFX ld a, h ld [W_TILESETGFXPTR + 1], a @@ -893,10 +911,10 @@ Func_5a5f: ; 5a5f (1:5a5f) ld a, l ld [W_TILESETCOLLISIONPTR], a xor a - ld [W_GRASSRATE], a ; W_GRASSRATE - inc a - ld [W_ISLINKBATTLE], a ; W_ISLINKBATTLE - ld [hJoy5], a + ld [W_GRASSRATE], a + inc a ; LINK_STATE_IN_CABLE_CLUB + ld [wLinkState], a + ld [$ffb5], a ld a, $a ld [wMusicHeaderPointer], a ld a, BANK(Music_Celadon) @@ -905,43 +923,46 @@ Func_5a5f: ; 5a5f (1:5a5f) ld [wc0ee], a jp PlaySound -Func_5aaf: ; 5aaf (1:5aaf) +EmptyFunc3: ; 5aaf (1:5aaf) ret -Func_5ab0: +Diploma_TextBoxBorder: ; 5ab0 (1:5ab0) call GetPredefRegisters -Func_5ab3: ; 5ab3 (1:5ab3) +; b = height +; c = width +CableClub_TextBoxBorder: ; 5ab3 (1:5ab3) push hl - ld a, $78 + ld a, $78 ; border upper left corner tile ld [hli], a - inc a - call Func_5ae0 - inc a + inc a ; border top horizontal line tile + call CableClub_DrawHorizontalLine + inc a ; border upper right corner tile ld [hl], a pop hl - ld de, $14 + ld de, 20 add hl, de -.asm_5ac2 +.loop push hl - ld a, $7b + ld a, $7b ; border left vertical line tile ld [hli], a - ld a, $7f - call Func_5ae0 - ld [hl], $77 + ld a, " " + call CableClub_DrawHorizontalLine + ld [hl], $77 ; border right vertical line tile pop hl - ld de, $14 + ld de, 20 add hl, de dec b - jr nz, .asm_5ac2 - ld a, $7c + jr nz, .loop + ld a, $7c ; border lower left corner tile ld [hli], a - ld a, $76 - call Func_5ae0 - ld [hl], $7d + ld a, $76 ; border bottom horizontal line tile + call CableClub_DrawHorizontalLine + ld [hl], $7d ; border lower right corner tile ret -Func_5ae0: ; 5ae0 (1:5ae0) +; c = width +CableClub_DrawHorizontalLine: ; 5ae0 (1:5ae0) ld d, c .asm_5ae1 ld [hli], a diff --git a/engine/clear_save.asm b/engine/clear_save.asm index 5ef0d4757f..8fde1f0caa 100755 --- a/engine/clear_save.asm +++ b/engine/clear_save.asm @@ -7,10 +7,10 @@ Func_1c98a: ; 1c98a (7:498a) call PrintText hlCoord 14, 7 ld bc, $80f - ld a, $7 - ld [wd12c], a + ld a, NO_YES_MENU + ld [wTwoOptionMenuID], a ld a, $14 - ld [wd125], a + ld [wTextBoxID], a call DisplayTextBoxID ld a, [wCurrentMenuItem] ; wCurrentMenuItem and a diff --git a/engine/evolve_trade.asm b/engine/evolve_trade.asm index 7fbd4607b9..ec230677f3 100755 --- a/engine/evolve_trade.asm +++ b/engine/evolve_trade.asm @@ -17,7 +17,7 @@ EvolveTradeMon: ; 17d7d (5:7d7d) ; This was fixed in Yellow. - ld a, [wTradeMonNick] + ld a, [wInGameTradeReceiveMonName] ; GRAVELER cp "G" @@ -26,7 +26,7 @@ EvolveTradeMon: ; 17d7d (5:7d7d) ; "SPECTRE" (HAUNTER) cp "S" ret nz - ld a, [wTradeMonNick + 1] + ld a, [wInGameTradeReceiveMonName + 1] cp "P" ret nz @@ -36,9 +36,9 @@ EvolveTradeMon: ; 17d7d (5:7d7d) ld [wWhichPokemon], a ; wWhichPokemon ld a, $1 ld [wccd4], a - ld a, $32 - ld [W_ISLINKBATTLE], a ; W_ISLINKBATTLE + ld a, LINK_STATE_TRADING + ld [wLinkState], a callab TryEvolvingMon - xor a - ld [W_ISLINKBATTLE], a ; W_ISLINKBATTLE + xor a ; LINK_STATE_NONE + ld [wLinkState], a jp PlayDefaultMusic diff --git a/engine/evos_moves.asm b/engine/evos_moves.asm index 3a7dda43d0..2c504104d0 100755 --- a/engine/evos_moves.asm +++ b/engine/evos_moves.asm @@ -70,9 +70,9 @@ Evolution_PartyMonLoop: ; loop over party mons cp EV_TRADE jr z, .checkTradeEvo ; not trade evolution - ld a, [W_ISLINKBATTLE] - cp $32 ; in a trade? - jr z, Evolution_PartyMonLoop ; if so, go the next mon + ld a, [wLinkState] + cp LINK_STATE_TRADING + jr z, Evolution_PartyMonLoop ; if trading, go the next mon ld a, b cp EV_ITEM jr z, .checkItemEvo @@ -83,9 +83,9 @@ Evolution_PartyMonLoop: ; loop over party mons cp EV_LEVEL jr z, .checkLevel .checkTradeEvo - ld a, [W_ISLINKBATTLE] - cp $32 ; in a trade? - jp nz, .nextEvoEntry1 ; if not, go to the next evolution entry + ld a, [wLinkState] + cp LINK_STATE_TRADING + jp nz, .nextEvoEntry1 ; if not trading, go to the next evolution entry ld a, [hli] ; level requirement ld b, a ld a, [wcfb9] @@ -246,8 +246,8 @@ Evolution_PartyMonLoop: ; loop over party mons pop hl pop af ld [hTilesetType], a - ld a, [W_ISLINKBATTLE] - cp $32 + ld a, [wLinkState] + cp LINK_STATE_TRADING ret z ld a, [W_ISINBATTLE] and a @@ -312,9 +312,9 @@ IsEvolvingText: ; 3af4d (e:6f4d) db "@" Evolution_ReloadTilesetTilePatterns: ; 3af52 (e:6f52) - ld a, [W_ISLINKBATTLE] ; W_ISLINKBATTLE - cp $32 ; in a trade? - ret z ; if so, return + ld a, [wLinkState] + cp LINK_STATE_TRADING + ret z jp ReloadTilesetTilePatterns LearnMoveFromLevelUp: ; 3af5b (e:6f5b) diff --git a/engine/game_corner_slots.asm b/engine/game_corner_slots.asm index 0ab7492793..52f61daf94 100755 --- a/engine/game_corner_slots.asm +++ b/engine/game_corner_slots.asm @@ -10,7 +10,7 @@ StartSlotMachine: ; 37e2d (d:7e2d) ld a, [wTrainerSpriteOffset] and a ret z - ld a, [wcd05] + ld a, [wUnknownSlotVar] ld b, a ld a, [wTrainerFacingDirection] inc a diff --git a/engine/hall_of_fame.asm b/engine/hall_of_fame.asm index 4b7e66db17..80acfeeb4d 100755 --- a/engine/hall_of_fame.asm +++ b/engine/hall_of_fame.asm @@ -97,9 +97,9 @@ HallOfFameText: ; 7026b (1c:426b) Func_70278: ; 70278 (1c:4278) call ClearScreen ld a, $d0 - ld [$ffaf], a + ld [hSCY], a ld a, $c0 - ld [$ffae], a + ld [hSCX], a ld a, [wWhichTrade] ; wWhichTrade ld [wcf91], a ld [wd0b5], a @@ -132,16 +132,16 @@ Func_70278: ; 70278 (1c:4278) .asm_702c7 call .asm_702d5 xor a - ld [$ffaf], a + ld [hSCY], a ld c, a call Func_7036d ld d, $0 ld e, $fc .asm_702d5 call DelayFrame - ld a, [$ffae] + ld a, [hSCX] add e - ld [$ffae], a + ld [hSCX], a cp d jr nz, .asm_702d5 ret @@ -200,7 +200,7 @@ Func_7033e: ; 7033e (1c:433e) Func_7036d: ; 7036d (1c:436d) ld b, $0 hlCoord 12, 5 - predef_jump Func_79dda + predef_jump CopyTileIDsFromList Func_70377: ; 70377 (1c:4377) ld hl, wd747 diff --git a/engine/hidden_object_functions17.asm b/engine/hidden_object_functions17.asm index d966b7209d..e0e38a2af1 100755 --- a/engine/hidden_object_functions17.asm +++ b/engine/hidden_object_functions17.asm @@ -67,7 +67,7 @@ DisplayMonFrontSpriteInBox: ; 5dbd9 (17:5bd9) ld [hWY], a call SaveScreenTilesToBuffer1 ld a, $11 - ld [wd125], a + ld [wTextBoxID], a call DisplayTextBoxID call UpdateSprites ld a, [wcf91] diff --git a/engine/in_game_trades.asm b/engine/in_game_trades.asm index 7464edb373..f308a8e629 100755 --- a/engine/in_game_trades.asm +++ b/engine/in_game_trades.asm @@ -1,4 +1,4 @@ -Predef54: ; 71ad9 (1c:5ad9) +DoInGameTradeDialogue: ; 71ad9 (1c:5ad9) ; trigger the trade offer/action specified by wWhichTrade call SaveScreenTilesToBuffer2 ld hl,TradeMons @@ -8,15 +8,15 @@ Predef54: ; 71ad9 (1c:5ad9) sub b sub b ld c,a - ld b,$0 + ld b,0 add hl,bc ld a,[hli] - ld [wcd0f],a + ld [wInGameTradeGiveMonSpecies],a ld a,[hli] - ld [wcd34],a + ld [wInGameTradeReceiveMonSpecies],a ld a,[hli] push af - ld de,wcd29 + ld de,wInGameTradeMonNick ld bc,$000b call CopyData pop af @@ -26,16 +26,16 @@ Predef54: ; 71ad9 (1c:5ad9) add hl,hl add hl,de ld a,[hli] - ld [wcd10],a + ld [wInGameTradeTextPointerTablePointer],a ld a,[hl] - ld [wcd11],a - ld a,[wcd0f] - ld de,wcd13 - call Func_71b6a - ld a,[wcd34] - ld de,wPlayerMonAccuracyMod - call Func_71b6a - ld hl,wd737 + ld [wInGameTradeTextPointerTablePointer + 1],a + ld a,[wInGameTradeGiveMonSpecies] + ld de,wInGameTradeGiveMonName + call InGameTrade_GetMonName + ld a,[wInGameTradeReceiveMonSpecies] + ld de,wInGameTradeReceiveMonName + call InGameTrade_GetMonName + ld hl,wCompletedInGameTradeFlags ld a,[wWhichTrade] ld c,a ld b,$2 @@ -43,28 +43,29 @@ Predef54: ; 71ad9 (1c:5ad9) ld a,c and a ld a,$4 - ld [wcd12],a - jr nz,.asm_99bca ; 0x71b36 $20 + ld [wInGameTradeTextPointerTableIndex],a + jr nz,.printText +; if the trade hasn't been done yet xor a - ld [wcd12],a - call .asm_99bca + ld [wInGameTradeTextPointerTableIndex],a + call .printText ld a,$1 - ld [wcd12],a + ld [wInGameTradeTextPointerTableIndex],a call YesNoChoice ld a,[wCurrentMenuItem] and a - jr nz,.asm_99bca ; 0x71b4b $b - call Func_71c07 - jr c,.asm_99bca ; 0x71b50 $6 + jr nz,.printText + call InGameTrade_DoTrade + jr c,.printText ld hl, TradedForText call PrintText -.asm_99bca ; 0x71b58 - ld hl,wcd12 - ld a,[hld] +.printText + ld hl,wInGameTradeTextPointerTableIndex + ld a,[hld] ; wInGameTradeTextPointerTableIndex ld e,a - ld d,$0 - ld a,[hld] - ld l,[hl] + ld d,0 + ld a,[hld] ; wInGameTradeTextPointerTablePointer + 1 + ld l,[hl] ; wInGameTradeTextPointerTablePointer ld h,a add hl,de add hl,de @@ -73,7 +74,8 @@ Predef54: ; 71ad9 (1c:5ad9) ld l,a jp PrintText -Func_71b6a: ; 71b6a (1c:5b6a) +; copies name of species a to hl +InGameTrade_GetMonName: ; 71b6a (1c:5b6a) push de ld [wd11e],a call GetMonName @@ -84,30 +86,30 @@ Func_71b6a: ; 71b6a (1c:5b6a) INCLUDE "data/trades.asm" -Func_71c07: ; 71c07 (1c:5c07) +InGameTrade_DoTrade: ; 71c07 (1c:5c07) xor a ld [wd07d],a dec a ld [wUpdateSpritesEnabled],a call DisplayPartyMenu push af - call Func_71ca2 + call InGameTrade_RestoreScreen pop af ld a,$1 - jp c,.asm_c4bc2 - ld a,[wcd0f] + jp c,.tradeFailed ; jump if the player didn't select a pokemon + ld a,[wInGameTradeGiveMonSpecies] ld b,a ld a,[wcf91] cp b ld a,$2 - jr nz,.asm_c4bc2 ; 0x71c26 $75 + jr nz,.tradeFailed ; jump if the selected mon's species is not the required one ld a,[wWhichPokemon] ld hl,wPartyMon1Level ld bc,$002c call AddNTimes ld a,[hl] ld [W_CURENEMYLVL],a - ld hl,wd737 + ld hl,wCompletedInGameTradeFlags ld a,[wWhichTrade] ld c,a ld b,$1 @@ -119,13 +121,13 @@ Func_71c07: ; 71c07 (1c:5c07) ld a,[W_CURENEMYLVL] push af call LoadHpBarAndStatusTilePatterns - call Func_71cc1 + call InGameTrade_PrepareTradeData predef Func_410e2 pop af ld [W_CURENEMYLVL],a pop af ld [wWhichPokemon],a - ld a,[wcd34] + ld a,[wInGameTradeReceiveMonSpecies] ld [wcf91],a xor a ld [wcc49],a @@ -134,64 +136,64 @@ Func_71c07: ; 71c07 (1c:5c07) ld a,$80 ld [wcc49],a call AddPartyMon - call Func_71d19 + call InGameTrade_CopyDataToReceivedMon callab EvolveTradeMon call ClearScreen - call Func_71ca2 + call InGameTrade_RestoreScreen callba RedrawMapView and a ld a,$3 - jr .asm_ee803 ; 0x71c9b $1 -.asm_c4bc2 ; 0x71c9d + jr .tradeSucceeded +.tradeFailed scf -.asm_ee803 ; 0x71c9e - ld [wcd12],a +.tradeSucceeded + ld [wInGameTradeTextPointerTableIndex],a ret -Func_71ca2: ; 71ca2 (1c:5ca2) +InGameTrade_RestoreScreen: ; 71ca2 (1c:5ca2) call GBPalWhiteOutWithDelay3 call RestoreScreenTilesAndReloadTilePatterns call ReloadTilesetTilePatterns call LoadScreenTilesFromBuffer2 call Delay3 call LoadGBPal - ld c, $a + ld c, 10 call DelayFrames ld b, BANK(LoadWildData) ld hl, LoadWildData jp Bankswitch -Func_71cc1: ; 71cc1 (1c:5cc1) - ld hl, wWhichTrade ; wWhichTrade - ld a, [wcd0f] - ld [hli], a - ld a, [wcd34] - ld [hl], a - ld hl, wPartyMonOT ; wd273 +InGameTrade_PrepareTradeData: ; 71cc1 (1c:5cc1) + ld hl, wTradedPlayerMonSpecies + ld a, [wInGameTradeGiveMonSpecies] + ld [hli], a ; wTradedPlayerMonSpecies + ld a, [wInGameTradeReceiveMonSpecies] + ld [hl], a ; wTradedEnemyMonSpecies + ld hl, wPartyMonOT ld bc, $b - ld a, [wWhichPokemon] ; wWhichPokemon + ld a, [wWhichPokemon] call AddNTimes - ld de, wTrainerScreenX + ld de, wTradedPlayerMonOT ld bc, $b - call Func_71d11 - ld hl, String_71d59 ; $5d59 + call InGameTrade_CopyData + ld hl, InGameTrade_TrainerString ld de, wcd4e - call Func_71d11 - ld de, W_GRASSRATE ; W_GRASSRATE - call Func_71d11 - ld hl, wPartyMon1OTID ; wPartyMon1OTID - ld bc, $2c - ld a, [wWhichPokemon] ; wWhichPokemon + call InGameTrade_CopyData + ld de, W_GRASSRATE + call InGameTrade_CopyData + ld hl, wPartyMon1OTID + ld bc, wPartyMon2 - wPartyMon1 + ld a, [wWhichPokemon] call AddNTimes - ld de, wcd4c + ld de, wTradedPlayerMonOTID ld bc, $2 - call Func_71d11 + call InGameTrade_CopyData call Random ld hl, hRandomAdd - ld de, wcd59 + ld de, wTradedEnemyMonOTID jp CopyData -Func_71d11: ; 71d11 (1c:5d11) +InGameTrade_CopyData: ; 71d11 (1c:5d11) push hl push bc call CopyData @@ -199,35 +201,37 @@ Func_71d11: ; 71d11 (1c:5d11) pop hl ret -Func_71d19: ; 71d19 (1c:5d19) - ld hl, wPartyMonNicks ; wPartyMonNicks +InGameTrade_CopyDataToReceivedMon: ; 71d19 (1c:5d19) + ld hl, wPartyMonNicks ld bc, $b - call Func_71d4f - ld hl, wcd29 + call InGameTrade_GetReceivedMonPointer + ld hl, wInGameTradeMonNick ld bc, $b call CopyData - ld hl, wPartyMonOT ; wd273 + ld hl, wPartyMonOT ld bc, $b - call Func_71d4f - ld hl, String_71d59 ; $5d59 + call InGameTrade_GetReceivedMonPointer + ld hl, InGameTrade_TrainerString ld bc, $b call CopyData - ld hl, wPartyMon1OTID ; wPartyMon1OTID - ld bc, $2c - call Func_71d4f - ld hl, wcd59 + ld hl, wPartyMon1OTID + ld bc, wPartyMon2 - wPartyMon1 + call InGameTrade_GetReceivedMonPointer + ld hl, wTradedEnemyMonOTID ld bc, $2 jp CopyData -Func_71d4f: ; 71d4f (1c:5d4f) - ld a, [wPartyCount] ; wPartyCount +; the received mon's index is (partyCount - 1), +; so this adds bc to hl (partyCount - 1) times and moves the result to de +InGameTrade_GetReceivedMonPointer: ; 71d4f (1c:5d4f) + ld a, [wPartyCount] dec a call AddNTimes ld e, l ld d, h ret -String_71d59: ; 71d59 (1c:5d59) +InGameTrade_TrainerString: ; 71d59 (1c:5d59) ; "TRAINER@@@@@@@@@@" db $5d, "@@@@@@@@@@" diff --git a/engine/intro.asm b/engine/intro.asm index ace43beb89..7c0464d35c 100755 --- a/engine/intro.asm +++ b/engine/intro.asm @@ -7,7 +7,7 @@ PlayIntro: ; 41682 (10:5682) call PlayIntroScene call GBFadeOutToWhite xor a - ld [$ffae], a + ld [hSCX], a ld [H_AUTOBGTRANSFERENABLED], a call ClearSprites call DelayFrame @@ -21,7 +21,7 @@ PlayIntroScene: ; 4169d (10:569d) ld [rOBP0], a ld [rOBP1], a xor a - ld [$ffae], a + ld [hSCX], a ld b, $3 call Func_4183f ld a, 0 @@ -229,7 +229,7 @@ Func_4180e: ; 4180e (10:580e) jr z, .asm_4181d cp $1 jr z, .asm_4182d - ld a, [$ffae] + ld a, [hSCX] dec a dec a jr .asm_41831 @@ -243,11 +243,11 @@ Func_4180e: ; 4180e (10:580e) call Func_417ae pop de .asm_4182d - ld a, [$ffae] + ld a, [hSCX] inc a inc a .asm_41831 - ld [$ffae], a + ld [hSCX], a push de ld c, $2 call CheckForUserInterruption @@ -260,9 +260,9 @@ Func_4180e: ; 4180e (10:580e) Func_4183f: ; 4183f (10:583f) hlCoord 13, 7 -Func_41842: ; 41842 (10:5842) +CopyTileIDsFromList_ZeroBaseTileID: ; 41842 (10:5842) ld c, $0 - predef_jump Func_79dda + predef_jump CopyTileIDsFromList Func_41849: ; 41849 (10:5849) predef Func_79869 diff --git a/engine/items/items.asm b/engine/items/items.asm index 029c659b01..d8b7f9e317 100755 --- a/engine/items/items.asm +++ b/engine/items/items.asm @@ -2098,7 +2098,7 @@ ItemUseTMHM: ; e479 (3:6479) hlCoord 14, 7 ld bc,$080f ld a,$14 - ld [wd125],a + ld [wTextBoxID],a call DisplayTextBoxID ; yes/no menu ld a,[wCurrentMenuItem] and a @@ -2489,7 +2489,7 @@ TossItem_: ; e6f1 (3:66f1) hlCoord 14, 7 ld bc,$080f ld a,$14 - ld [wd125],a + ld [wTextBoxID],a call DisplayTextBoxID ; yes/no menu ld a,[wd12e] cp a,2 diff --git a/engine/learn_move.asm b/engine/learn_move.asm index bbfb41a3c8..5dab57480f 100755 --- a/engine/learn_move.asm +++ b/engine/learn_move.asm @@ -79,7 +79,7 @@ AbandonLearning: ; 6eda (1:6eda) hlCoord 14, 7 ld bc, $80f ld a, $14 - ld [wd125], a + ld [wTextBoxID], a call DisplayTextBoxID ld a, [wCurrentMenuItem] ; wCurrentMenuItem and a @@ -102,7 +102,7 @@ TryingToLearn: ; 6f07 (1:6f07) hlCoord 14, 7 ld bc, $80f ld a, $14 - ld [wd125], a + ld [wTextBoxID], a call DisplayTextBoxID pop hl ld a, [wCurrentMenuItem] ; wCurrentMenuItem diff --git a/engine/menu/bills_pc.asm b/engine/menu/bills_pc.asm index 891ef6e80a..a26c5aed17 100644 --- a/engine/menu/bills_pc.asm +++ b/engine/menu/bills_pc.asm @@ -508,48 +508,48 @@ MonWasReleasedText: ; 0x21820 TX_FAR _MonWasReleasedText db "@" -PrintJustAMomentText1:: ; 5824 (8:5825) - ld a, [$ffaa] - cp $1 +CableClubLeftGameboy:: ; 5824 (8:5825) + ld a, [hSerialConnectionStatus] + cp USING_EXTERNAL_CLOCK ret z - ld a, [wSpriteStateData1 + 9] - cp $c + ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction + cp SPRITE_FACING_RIGHT ret nz ld a, [W_CURMAP] cp BATTLE_CENTER - ld a, $2 + ld a, LINK_STATE_START_TRADE jr z, .asm_2183a - inc a + inc a ; LINK_STATE_START_BATTLE .asm_2183a - ld [W_ISLINKBATTLE], a + ld [wLinkState], a call EnableAutoTextBoxDrawing - ld a, $22 + ld a, $22 ; JustAMomentText jp PrintPredefTextID -PrintJustAMomentText2:: ; 5845 (8:5845) - ld a, [$ffaa] - cp $2 +CableClubRightGameboy:: ; 5845 (8:5845) + ld a, [hSerialConnectionStatus] + cp USING_INTERNAL_CLOCK ret z - ld a, [wSpriteStateData1 + 9] - cp $8 + ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction + cp SPRITE_FACING_LEFT ret nz ld a, [W_CURMAP] cp BATTLE_CENTER - ld a, $2 + ld a, LINK_STATE_START_TRADE jr z, .asm_2185a - inc a + inc a ; LINK_STATE_START_BATTLE .asm_2185a - ld [W_ISLINKBATTLE], a + ld [wLinkState], a call EnableAutoTextBoxDrawing - ld a, $22 + ld a, $22 ; JustAMomentText jp PrintPredefTextID JustAMomentText:: ; 21865 (8:5865) TX_FAR _JustAMomentText db "@" - ld a, [wSpriteStateData1 + 9] - cp $4 + ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction + cp SPRITE_FACING_UP ret nz call EnableAutoTextBoxDrawing ld a, $23 diff --git a/engine/menu/diploma.asm b/engine/menu/diploma.asm index 95b2a87d6f..1624ed700b 100755 --- a/engine/menu/diploma.asm +++ b/engine/menu/diploma.asm @@ -14,7 +14,7 @@ DisplayDiploma: ; 566e2 (15:66e2) call FarCopyData2 ld hl, wTileMap ld bc, $1012 - predef Func_5ab0 + predef Diploma_TextBoxBorder ld hl, DiplomaTextPointersAndCoords ; $6784 ld c, $5 .asm_56715 diff --git a/engine/menu/main_menu.asm b/engine/menu/main_menu.asm index c6052f03b6..756c77557e 100755 --- a/engine/menu/main_menu.asm +++ b/engine/menu/main_menu.asm @@ -14,8 +14,8 @@ MainMenu: ; 5af2 (1:5af2) .next0 ld c,20 call DelayFrames - xor a - ld [W_ISLINKBATTLE],a + xor a ; LINK_STATE_NONE + ld [wLinkState],a ld hl,wcc2b ld [hli],a ld [hli],a @@ -133,7 +133,7 @@ LinkMenu: ; 5c0a (1:5c0a) ld [wd358], a ld hl, wd72e set 6, [hl] - ld hl, TextTerminator_6b20 ; $6b20 + ld hl, TextTerminator_6b20 call PrintText call SaveScreenTilesToBuffer1 ld hl, WhereWouldYouLikeText @@ -149,7 +149,7 @@ LinkMenu: ; 5c0a (1:5c0a) xor a ld [wcd37], a ld [wd72d], a - ld hl, wTopMenuItemY ; wTopMenuItemY + ld hl, wTopMenuItemY ld a, $7 ld [hli], a ld a, $6 @@ -163,97 +163,101 @@ LinkMenu: ; 5c0a (1:5c0a) ld [hli], a xor a ld [hl], a -.asm_5c52 +.waitForInputLoop call HandleMenuInput - and $3 + and A_BUTTON | B_BUTTON add a add a ld b, a - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + ld a, [wCurrentMenuItem] add b add $d0 - ld [wcc42], a - ld [wcc43], a -.asm_5c66 - call Func_2247 - ld a, [wcc3d] + ld [wLinkMenuSelectionSendBuffer], a + ld [wLinkMenuSelectionSendBuffer + 1], a +.exchangeMenuSelectionLoop + call Serial_ExchangeLinkMenuSelection + ld a, [wLinkMenuSelectionReceiveBuffer] ld b, a and $f0 cp $d0 jr z, .asm_5c7d - ld a, [wcc3e] + ld a, [wLinkMenuSelectionReceiveBuffer + 1] ld b, a and $f0 cp $d0 - jr nz, .asm_5c66 + jr nz, .exchangeMenuSelectionLoop .asm_5c7d ld a, b - and $c - jr nz, .asm_5c8b - ld a, [wcc42] - and $c - jr z, .asm_5c52 - jr .asm_5ca1 -.asm_5c8b - ld a, [wcc42] - and $c - jr z, .asm_5c98 - ld a, [$ffaa] - cp $2 - jr z, .asm_5ca1 -.asm_5c98 + and $c ; did the enemy press A or B? + jr nz, .enemyPressedAOrB +; the enemy didn't press A or B + ld a, [wLinkMenuSelectionSendBuffer] + and $c ; did the player press A or B? + jr z, .waitForInputLoop ; if neither the player nor the enemy pressed A or B, try again + jr .doneChoosingMenuSelection ; if the player pressed A or B but the enemy didn't, use the player's selection +.enemyPressedAOrB + ld a, [wLinkMenuSelectionSendBuffer] + and $c ; did the player press A or B? + jr z, .useEnemyMenuSelection ; if the enemy pressed A or B but the player didn't, use the enemy's selection +; the enemy and the player both pressed A or B +; The gameboy that is clocking the connection wins. + ld a, [hSerialConnectionStatus] + cp USING_INTERNAL_CLOCK + jr z, .doneChoosingMenuSelection +.useEnemyMenuSelection ld a, b - ld [wcc42], a + ld [wLinkMenuSelectionSendBuffer], a and $3 ld [wCurrentMenuItem], a ; wCurrentMenuItem -.asm_5ca1 - ld a, [$ffaa] - cp $2 - jr nz, .asm_5cb1 +.doneChoosingMenuSelection + ld a, [hSerialConnectionStatus] + cp USING_INTERNAL_CLOCK + jr nz, .skipStartingTransfer call DelayFrame call DelayFrame - ld a, $81 - ld [$ff02], a -.asm_5cb1 + ld a, START_TRANSFER_INTERNAL_CLOCK + ld [rSC], a +.skipStartingTransfer ld b, $7f ld c, $7f ld d, $ec - ld a, [wcc42] - and $8 - jr nz, .asm_5ccc - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + ld a, [wLinkMenuSelectionSendBuffer] + and (B_BUTTON << 2) ; was B button pressed? + jr nz, .updateCursorPosition +; A button was pressed + ld a, [wCurrentMenuItem] cp $2 - jr z, .asm_5ccc + jr z, .updateCursorPosition ld c, d ld d, b dec a - jr z, .asm_5ccc + jr z, .updateCursorPosition ld b, c ld c, d -.asm_5ccc +.updateCursorPosition ld a, b Coorda 6, 7 ld a, c Coorda 6, 9 ld a, d Coorda 6, 11 - ld c, $28 + ld c, 40 call DelayFrames call LoadScreenTilesFromBuffer1 - ld a, [wcc42] - and $8 - jr nz, .asm_5d2d - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + ld a, [wLinkMenuSelectionSendBuffer] + and (B_BUTTON << 2) ; was B button pressed? + jr nz, .choseCancel ; cancel if B pressed + ld a, [wCurrentMenuItem] cp $2 - jr z, .asm_5d2d + jr z, .choseCancel xor a - ld [wWalkBikeSurfState], a - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + ld [wWalkBikeSurfState], a ; start walking + ld a, [wCurrentMenuItem] and a ld a, TRADE_CENTER - jr nz, .asm_5cfc + jr nz, .next ld a, BATTLE_CENTER -.asm_5cfc +.next ld [wd72d], a ld hl, PleaseWaitText call PrintText @@ -261,23 +265,23 @@ LinkMenu: ; 5c0a (1:5c0a) call DelayFrames ld hl, wd732 res 1, [hl] - ld a, [W_ANIMATIONID] ; W_ANIMATIONID + ld a, [W_ANIMATIONID] ld [wDestinationMap], a call SpecialWarpIn ld c, $14 call DelayFrames xor a - ld [wMenuJoypadPollCount], a ; wMenuJoypadPollCount - ld [wcc42], a - inc a - ld [W_ISLINKBATTLE], a ; W_ISLINKBATTLE + ld [wMenuJoypadPollCount], a + ld [wSerialExchangeNybbleSendData], a + inc a ; LINK_STATE_IN_CABLE_CLUB + ld [wLinkState], a ld [wcc47], a jr SpecialEnterMap -.asm_5d2d +.choseCancel xor a - ld [wMenuJoypadPollCount], a ; wMenuJoypadPollCount + ld [wMenuJoypadPollCount], a call Delay3 - call Func_72d7 + call CloseLinkConnection ld hl, LinkCanceledText call PrintText ld hl, wd72e diff --git a/engine/menu/naming_screen.asm b/engine/menu/naming_screen.asm index b7db452ac1..5d33862846 100755 --- a/engine/menu/naming_screen.asm +++ b/engine/menu/naming_screen.asm @@ -16,7 +16,7 @@ AskName: ; 64eb (1:64eb) hlCoord 14, 7 ld bc, $80f ld a, $14 - ld [wd125], a + ld [wTextBoxID], a call DisplayTextBoxID pop hl ld a, [wCurrentMenuItem] ; wCurrentMenuItem diff --git a/engine/menu/start_sub_menus.asm b/engine/menu/start_sub_menus.asm index c6373e765f..cdd93875aa 100755 --- a/engine/menu/start_sub_menus.asm +++ b/engine/menu/start_sub_menus.asm @@ -31,7 +31,7 @@ StartMenu_Pokemon: ; 130a9 (4:70a9) .chosePokemon call SaveScreenTilesToBuffer1 ; save screen ld a,$04 - ld [wd125],a + ld [wTextBoxID],a call DisplayTextBoxID ; display pokemon menu options ld hl,wWhichTrade ld bc,$020c ; max menu item ID, top menu item Y @@ -300,13 +300,13 @@ ItemMenuLoop: ; 132fc (4:72fc) call GoPAL_SET_CF1C StartMenu_Item: ; 13302 (4:7302) - ld a,[W_ISLINKBATTLE] - dec a - jr nz,.notInLinkBattle + ld a,[wLinkState] + dec a ; is the player in the Colosseum or Trade Centre? + jr nz,.notInCableClubRoom ld hl,CannotUseItemsHereText call PrintText jr .exitMenu -.notInLinkBattle +.notInCableClubRoom ld bc,wNumBagItems ld hl,wcf8b ld a,c @@ -342,7 +342,7 @@ StartMenu_Item: ; 13302 (4:7302) jp z,.useOrTossItem .notBicycle1 ld a,$06 ; use/toss menu - ld [wd125],a + ld [wTextBoxID],a call DisplayTextBoxID ld hl,wTopMenuItemY ld a,11 diff --git a/engine/menu/vending_machine.asm b/engine/menu/vending_machine.asm index c2968e2fb9..1eba782be6 100755 --- a/engine/menu/vending_machine.asm +++ b/engine/menu/vending_machine.asm @@ -2,7 +2,7 @@ VendingMachineMenu: ; 74ee0 (1d:4ee0) ld hl, VendingMachineText1 call PrintText ld a, $13 - ld [wd125], a + ld [wTextBoxID], a call DisplayTextBoxID xor a ld [wCurrentMenuItem], a ; wCurrentMenuItem @@ -70,7 +70,7 @@ VendingMachineMenu: ; 74ee0 (1d:4ee0) ld c, $3 predef SubBCDPredef ld a, $13 - ld [wd125], a + ld [wTextBoxID], a jp DisplayTextBoxID .BagFull ld hl, VendingMachineText6 diff --git a/engine/mon_party_sprites.asm b/engine/mon_party_sprites.asm index 5fa5c3bc74..52bd0fd4c7 100755 --- a/engine/mon_party_sprites.asm +++ b/engine/mon_party_sprites.asm @@ -382,7 +382,7 @@ GetPartyMonSpriteID: ; 718e9 (1c:58e9) ld c, a dec a srl a - ld hl, MonPartyData ; $590d + ld hl, MonPartyData ld e, a ld d, $0 add hl, de diff --git a/engine/overworld/cable_club_npc.asm b/engine/overworld/cable_club_npc.asm index d071eee5b4..bdab41a655 100755 --- a/engine/overworld/cable_club_npc.asm +++ b/engine/overworld/cable_club_npc.asm @@ -1,51 +1,51 @@ CableClubNPC: ; 71c5 (1:71c5) - ld hl, CableClubNPCText1 + ld hl, CableClubNPCWelcomeText call PrintText ld a, [wd74b] - bit 5, a - jp nz, Func_71e1 + bit 5, a ; received pokedex? + jp nz, .receivedPokedex +; if the player hasn't received the pokedex ld c, $3c call DelayFrames - ld hl, CableClubNPCText6 + ld hl, CableClubNPCMakingPreparationsText call PrintText jp Func_7298 - -Func_71e1: ; 71e1 (1:71e1) +.receivedPokedex ld a, $1 ld [wMenuJoypadPollCount], a - ld a, $5a - ld [wcc47], a -.asm_71eb - ld a, [$ffaa] - cp $2 - jr z, .asm_721a ; 0x71ef $29 - cp $1 - jr z, .asm_721a ; 0x71f3 $25 - ld a, $ff - ld [$ffaa], a - ld a, $2 + ld a, 90 + ld [wLinkTimeoutCounter], a +.establishConnectionLoop + ld a, [hSerialConnectionStatus] + cp USING_INTERNAL_CLOCK + jr z, .establishedConnection + cp USING_EXTERNAL_CLOCK + jr z, .establishedConnection + ld a, CONNECTION_NOT_ESTABLISHED + ld [hSerialConnectionStatus], a + ld a, ESTABLISH_CONNECTION_WITH_EXTERNAL_CLOCK ld [rSB], a xor a - ld [$ffad], a - ld a, $80 - ld [$ff02], a - ld a, [wcc47] + ld [hSerialReceiveData], a + ld a, START_TRANSFER_EXTERNAL_CLOCK + ld [rSC], a + ld a, [wLinkTimeoutCounter] dec a - ld [wcc47], a - jr z, .asm_7287 ; 0x720b $7a - ld a, $1 + ld [wLinkTimeoutCounter], a + jr z, .failedToEstablishConnection + ld a, ESTABLISH_CONNECTION_WITH_INTERNAL_CLOCK ld [rSB], a - ld a, $81 - ld [$ff02], a + ld a, START_TRANSFER_INTERNAL_CLOCK + ld [rSC], a call DelayFrame - jr .asm_71eb ; 0x7218 $d1 -.asm_721a - call Func_22ed + jr .establishConnectionLoop +.establishedConnection + call Serial_SendZeroByte call DelayFrame - call Func_22ed - ld c, $32 + call Serial_SendZeroByte + ld c, 50 call DelayFrames - ld hl, CableClubNPCText2 + ld hl, CableClubNPCPleaseApplyHereHaveToSaveText call PrintText xor a ld [wMenuJoypadPollCount], a @@ -54,22 +54,22 @@ Func_71e1: ; 71e1 (1:71e1) ld [wMenuJoypadPollCount], a ld a, [wCurrentMenuItem] and a - jr nz, .asm_728f ; 0x723e $4f + jr nz, .choseNo callab SaveSAVtoSRAM call WaitForSoundToFinish ld a, (SFX_02_5d - SFX_Headers_02) / 3 call PlaySoundWaitForCurrent - ld hl, CableClubNPCText3 + ld hl, CableClubNPCPleaseWaitText call PrintText - ld hl, wcc47 + ld hl, wUnknownSerialCounter ld a, $3 ld [hli], a xor a ld [hl], a - ld [$ffa9], a - ld [wcc42], a - call Func_227f - ld hl, wcc47 + ld [hSerialReceivedNewData], a + ld [wSerialExchangeNybbleSendData], a + call Serial_SyncAndExchangeNybble + ld hl, wUnknownSerialCounter ld a, [hli] inc a jr nz, Func_72a8 ; 0x726b $3b @@ -79,26 +79,26 @@ Func_71e1: ; 71e1 (1:71e1) ld b, $a .asm_7273 call DelayFrame - call Func_22ed + call Serial_SendZeroByte dec b jr nz, .asm_7273 ; 0x727a $f7 - call Func_72d7 - ld hl, CableClubNPCText4 + call CloseLinkConnection + ld hl, CableClubNPCLinkClosedBecauseOfInactivityText call PrintText jr Func_7298 ; 0x7285 $11 -.asm_7287 - ld hl, CableClubNPCText7 +.failedToEstablishConnection + ld hl, CableClubNPCAreaReservedFor2FriendsLinkedByCableText call PrintText jr Func_7298 ; 0x728d $9 -.asm_728f - call Func_72d7 - ld hl, CableClubNPCText5 +.choseNo + call CloseLinkConnection + ld hl, CableClubNPCPleaseComeAgainText call PrintText ; fall through Func_7298: ; 7298 (1:7298) xor a - ld hl, wcc47 + ld hl, wUnknownSerialCounter ld [hli], a ld [hl], a ld hl, wd72e @@ -115,42 +115,42 @@ Func_72a8: ; 72a8 (1:72a8) ld b, BANK(LinkMenu) jp Bankswitch -CableClubNPCText7: ; 72b3 (1:72b3) - TX_FAR _CableClubNPCText7 +CableClubNPCAreaReservedFor2FriendsLinkedByCableText: ; 72b3 (1:72b3) + TX_FAR _CableClubNPCAreaReservedFor2FriendsLinkedByCableText db "@" -CableClubNPCText1: ; 72b8 (1:72b8) - TX_FAR _CableClubNPCText1 +CableClubNPCWelcomeText: ; 72b8 (1:72b8) + TX_FAR _CableClubNPCWelcomeText db "@" -CableClubNPCText2: ; 72bd (1:72bd) - TX_FAR _CableClubNPCText2 +CableClubNPCPleaseApplyHereHaveToSaveText: ; 72bd (1:72bd) + TX_FAR _CableClubNPCPleaseApplyHereHaveToSaveText db "@" -CableClubNPCText3: ; 72c2 (1:72c2) - TX_FAR _CableClubNPCText3 +CableClubNPCPleaseWaitText: ; 72c2 (1:72c2) + TX_FAR _CableClubNPCPleaseWaitText db $a, "@" -CableClubNPCText4: ; 72c8 (1:72c8) - TX_FAR _CableClubNPCText4 +CableClubNPCLinkClosedBecauseOfInactivityText: ; 72c8 (1:72c8) + TX_FAR _CableClubNPCLinkClosedBecauseOfInactivityText db "@" -CableClubNPCText5: ; 72cd (1:72cd) - TX_FAR _CableClubNPCText5 +CableClubNPCPleaseComeAgainText: ; 72cd (1:72cd) + TX_FAR _CableClubNPCPleaseComeAgainText db "@" -CableClubNPCText6: ; 72d2 (1:72d2) - TX_FAR _CableClubNPCText6 +CableClubNPCMakingPreparationsText: ; 72d2 (1:72d2) + TX_FAR _CableClubNPCMakingPreparationsText db "@" -Func_72d7: ; 72d7 (1:72d7) +CloseLinkConnection: ; 72d7 (1:72d7) call Delay3 - ld a, $ff - ld [$ffaa], a - ld a, $2 + ld a, CONNECTION_NOT_ESTABLISHED + ld [hSerialConnectionStatus], a + ld a, ESTABLISH_CONNECTION_WITH_EXTERNAL_CLOCK ld [rSB], a xor a - ld [$ffad], a - ld a, $80 - ld [$ff02], a + ld [hSerialReceiveData], a + ld a, START_TRANSFER_EXTERNAL_CLOCK + ld [rSC], a ret diff --git a/engine/overworld/elevator.asm b/engine/overworld/elevator.asm index c2191b919d..3a23d410b4 100755 --- a/engine/overworld/elevator.asm +++ b/engine/overworld/elevator.asm @@ -6,7 +6,7 @@ ShakeElevator: ; 7bf15 (1e:7f15) call Delay3 ld a, $ff call PlaySound - ld a, [$ffaf] + ld a, [hSCY] ld d, a ld e, $1 ; number of times to play collision sfx @@ -16,7 +16,7 @@ ShakeElevator: ; 7bf15 (1e:7f15) xor $fe ld e, a add d - ld [$ffaf], a + ld [hSCY], a push bc ld c, BANK(SFX_02_5b) ld a, (SFX_02_5b - SFX_Headers_02) / 3 @@ -27,7 +27,7 @@ ShakeElevator: ; 7bf15 (1e:7f15) dec b jr nz, .asm_7bf30 ld a, d - ld [$ffaf], a + ld [hSCY], a ld a, $ff call PlaySound ld c, BANK(SFX_02_5f) diff --git a/engine/overworld/pokemart.asm b/engine/overworld/pokemart.asm index a27f6b0a48..644c155b03 100755 --- a/engine/overworld/pokemart.asm +++ b/engine/overworld/pokemart.asm @@ -12,10 +12,10 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20) inc a ld [wcf93],a ld a,$13 - ld [wd125],a + ld [wTextBoxID],a call DisplayTextBoxID ; draw money text box ld a,$15 - ld [wd125],a + ld [wTextBoxID],a call DisplayTextBoxID ; do buy/sell/quit menu ld hl,wd128 ; pointer to this pokemart's inventory ld a,[hli] @@ -46,7 +46,7 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20) .sellMenuLoop call LoadScreenTilesFromBuffer1 ; restore saved screen ld a,$13 - ld [wd125],a + ld [wTextBoxID],a call DisplayTextBoxID ; draw money text box ld hl,wNumBagItems ld a,l @@ -80,7 +80,7 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20) hlCoord 14, 7 ld bc,$080f ld a,$14 - ld [wd125],a + ld [wTextBoxID],a call DisplayTextBoxID ; yes/no menu ld a,[wd12e] cp a,$02 @@ -120,7 +120,7 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20) .buyMenuLoop call LoadScreenTilesFromBuffer1 ; restore saved screen ld a,$13 - ld [wd125],a + ld [wTextBoxID],a call DisplayTextBoxID ; draw money text box ld hl,wStringBuffer2 + 11 ld a,l @@ -151,7 +151,7 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20) hlCoord 14, 7 ld bc,$080f ld a,$14 - ld [wd125],a + ld [wTextBoxID],a call DisplayTextBoxID ; yes/no menu ld a,[wd12e] cp a,$02 @@ -181,7 +181,7 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20) .returnToMainPokemartMenu call LoadScreenTilesFromBuffer1 ld a,$13 - ld [wd125],a + ld [wTextBoxID],a call DisplayTextBoxID ; draw money text box ld hl,PokemartAnythingElseText call PrintText diff --git a/engine/predefs.asm b/engine/predefs.asm index b21ff8842d..8a98bd3d34 100755 --- a/engine/predefs.asm +++ b/engine/predefs.asm @@ -91,17 +91,17 @@ PredefPointers:: ; 4fe79 (13:7e79) add_predef Func_48125 add_predef UpdateHPBar add_predef HPBarLength - add_predef Func_5ab0 + add_predef Diploma_TextBoxBorder add_predef Func_3ed02 add_predef ShowPokedexMenu add_predef EvolutionAfterBattle add_predef SaveSAVtoSRAM0 add_predef InitOpponent - add_predef Func_5a5f + add_predef CableClub_Run add_predef DrawBadges add_predef Func_410f3 add_predef BattleTransition - add_predef Func_79dda + add_predef CopyTileIDsFromList add_predef PlayIntro add_predef Func_79869 add_predef FlashScreen @@ -129,14 +129,14 @@ PredefPointers:: ; 4fe79 (13:7e79) add_predef LoadTownMap_Nest add_predef Func_27d6b add_predef EmotionBubble; 4C player exclamation - add_predef Func_5aaf; return immediately + add_predef EmptyFunc3; return immediately add_predef AskName add_predef PewterGuys add_predef SaveSAVtoSRAM2 add_predef LoadSAVCheckSum2 add_predef LoadSAV add_predef SaveSAVtoSRAM1 - add_predef Predef54 ; 54 initiate trade + add_predef DoInGameTradeDialogue ; 54 initiate trade add_predef HallOfFamePC add_predef DisplayDexRating dbw $1E, _LeaveMapAnim ; wrong bank diff --git a/engine/save.asm b/engine/save.asm index e6b1bd9435..7b1db4c7dc 100755 --- a/engine/save.asm +++ b/engine/save.asm @@ -175,7 +175,7 @@ SaveSAVConfirm: ; 73768 (1c:7768) hlCoord 0, 7 ld bc,$0801 ;arrow's coordinates |b = Y|c = X| ld a,$14 ;one line shifting ($28 = 2 lines) - ld [wd125],a + ld [wTextBoxID],a call DisplayTextBoxID ;handle Yes/No KeyPress ld a,[wCurrentMenuItem] ret diff --git a/engine/slot_machine.asm b/engine/slot_machine.asm index a8b978f88d..2444155c06 100755 --- a/engine/slot_machine.asm +++ b/engine/slot_machine.asm @@ -135,10 +135,10 @@ MainSlotMachineLoop: ; 37395 (d:7395) call PrintText ld hl, wTileMap + $fe ld bc, $0d0f - xor a - ld [wd12c], a + xor a ; YES_NO_MENU + ld [wTwoOptionMenuID], a ld a, $14 - ld [wd125], a + ld [wTextBoxID], a call DisplayTextBoxID ld a, [wCurrentMenuItem] and a diff --git a/engine/titlescreen.asm b/engine/titlescreen.asm index e13b7da6e7..5e8a15d512 100755 --- a/engine/titlescreen.asm +++ b/engine/titlescreen.asm @@ -27,9 +27,9 @@ LoadTitlescreenGraphics: ; 42dd (1:42dd) ld [H_AUTOBGTRANSFERENABLED], a ; $ffba xor a ld [hTilesetType], a - ld [$ffae], a + ld [hSCX], a ld a, $40 - ld [$ffaf], a + ld [hSCY], a ld a, $90 ld [hWY], a call ClearScreen diff --git a/engine/trade.asm b/engine/trade.asm index 4a8f865ad3..5afca8093c 100755 --- a/engine/trade.asm +++ b/engine/trade.asm @@ -1,29 +1,29 @@ Func_410e2: ; 410e2 (10:50e2) - ld a, [wWhichTrade] ; wWhichTrade + ld a, [wTradedPlayerMonSpecies] ld [wcd5e], a - ld a, [wTrainerEngageDistance] + ld a, [wTradedEnemyMonSpecies] ld [wcd5f], a - ld de, PointerIDs_41138 ; $5138 + ld de, PointerIDs_41138 jr Func_41102 Func_410f3: ; 410f3 (10:50f3) - ld a, [wTrainerEngageDistance] + ld a, [wTradedEnemyMonSpecies] ld [wcd5e], a ld a, [wTrainerSpriteOffset] ld [wcd5f], a ld de, PointerIDs_41149 Func_41102: ; 41102 (10:5102) - ld a, [W_OPTIONS] ; W_OPTIONS + ld a, [W_OPTIONS] push af - ld a, [$ffaf] + ld a, [hSCY] push af - ld a, [$ffae] + ld a, [hSCX] push af xor a - ld [W_OPTIONS], a ; W_OPTIONS - ld [$ffaf], a - ld [$ffae], a + ld [W_OPTIONS], a + ld [hSCY], a + ld [hSCX], a push de .asm_41115 pop de @@ -32,7 +32,7 @@ Func_41102: ; 41102 (10:5102) jr z, .asm_4112d inc de push de - ld hl, PointerTable_4115f ; $515f + ld hl, PointerTable_4115f add a ld c, a ld b, $0 @@ -40,16 +40,16 @@ Func_41102: ; 41102 (10:5102) ld a, [hli] ld h, [hl] ld l, a - ld de, .asm_41115 ; $5115 + ld de, .asm_41115 push de jp [hl] .asm_4112d pop af - ld [$ffae], a + ld [hSCX], a pop af - ld [$ffaf], a + ld [hSCY], a pop af - ld [W_OPTIONS], a ; W_OPTIONS + ld [W_OPTIONS], a ret ; these bytes refer to the $00th through $10th pointer of PointerTable_4115f @@ -61,13 +61,13 @@ PointerIDs_41149: ; 41149 (10:5149) PointerTable_4115f: ; 4115f (10:515f) dw LoadTradingGFXAndMonNames - dw Func_41245 - dw Func_41298 - dw Func_412d2 - dw Func_41336 + dw Trade_ShowPlayerMon + dw Trade_DrawOpenEndOfLinkCable + dw Trade_AnimateBallEnteringLinkCable + dw Trade_ShowEnemyMon dw Func_41376 dw Func_413c6 - dw Func_41181 + dw Trade_Delay100 dw Func_415c8 dw PrintTradeWentToText dw PrintTradeForSendsText @@ -76,46 +76,46 @@ PointerTable_4115f: ; 4115f (10:515f) dw PrintTradeWillTradeText dw Func_4123b dw Func_415df - dw Func_41217 + dw Trade_SwapNames -Func_41181: ; 41181 (10:5181) - ld c, $64 +Trade_Delay100: ; 41181 (10:5181) + ld c, 100 jp DelayFrames -Func_41186: ; 41186 (10:5186) +Trade_CopyTileMapToVRAM: ; 41186 (10:5186) ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba + ld [H_AUTOBGTRANSFERENABLED], a call Delay3 xor a - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba + ld [H_AUTOBGTRANSFERENABLED], a ret -Delay50: ; 41191 (10:5191) - ld c, $50 +Trade_Delay80: ; 41191 (10:5191) + ld c, 80 jp DelayFrames -Func_41196: ; 41196 (10:5196) +Trade_ClearTileMap: ; 41196 (10:5196) ld hl, wTileMap - ld bc, $168 - ld a, $7f + ld bc, 20 * 18 + ld a, " " jp FillMemory LoadTradingGFXAndMonNames: ; 411a1 (10:51a1) - call Func_41196 + call Trade_ClearTileMap call DisableLCD - ld hl, TradingAnimationGraphics ; $69be + ld hl, TradingAnimationGraphics ld de, vChars2 + $310 ld bc, $310 ld a, BANK(TradingAnimationGraphics) call FarCopyData2 - ld hl, TradingAnimationGraphics2 ; $6cce + ld hl, TradingAnimationGraphics2 ld de, vSprites + $7c0 ld bc, $40 ld a, BANK(TradingAnimationGraphics2) call FarCopyData2 ld hl, vBGMap0 ld bc, $800 - ld a, $7f + ld a, " " call FillMemory call ClearSprites ld a, $ff @@ -128,40 +128,40 @@ LoadTradingGFXAndMonNames: ; 411a1 (10:51a1) jr z, .asm_411e5 ld a, $f0 .asm_411e5 - ld [rOBP0], a ; $ff48 + ld [rOBP0], a call EnableLCD xor a - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba - ld a, [wWhichTrade] ; wWhichTrade + ld [H_AUTOBGTRANSFERENABLED], a + ld a, [wTradedPlayerMonSpecies] ld [wd11e], a call GetMonName ld hl, wcd6d ld de, wcf4b ld bc, $b call CopyData - ld a, [wTrainerEngageDistance] + ld a, [wTradedEnemyMonSpecies] ld [wd11e], a jp GetMonName Func_4120b: ; 4120b (10:520b) - ld a, $d0 - ld [rOBP1], a ; $ff49 + ld a, %11010000 + ld [rOBP1], a ld b, BANK(Func_7176c) ld hl, Func_7176c jp Bankswitch -Func_41217: ; 41217 (10:5217) +Trade_SwapNames: ; 41217 (10:5217) ld hl, wPlayerName - ld de, wHPBarMaxHP - ld bc, $000b + ld de, wBuffer + ld bc, 11 call CopyData - ld hl, W_GRASSRATE + ld hl, wLinkEnemyTrainerName ld de, wPlayerName - ld bc, $000b + ld bc, 11 call CopyData - ld hl, wHPBarMaxHP - ld de, W_GRASSRATE - ld bc, $000b + ld hl, wBuffer + ld de, wLinkEnemyTrainerName + ld bc, 11 jp CopyData Func_4123b: ; 4123b (10:523b) @@ -171,90 +171,90 @@ Func_4123b: ; 4123b (10:523b) res 6, [hl] ret -Func_41245: ; 41245 (10:5245) - ld a, $ab - ld [rLCDC], a ; $ff40 +Trade_ShowPlayerMon: ; 41245 (10:5245) + ld a, %10101011 + ld [rLCDC], a ld a, $50 ld [hWY], a ld a, $86 - ld [rWX], a ; $ff4b - ld [$ffae], a + ld [rWX], a + ld [hSCX], a xor a - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba + ld [H_AUTOBGTRANSFERENABLED], a hlCoord 4, 0 - ld b, $6 - ld c, $a + ld b, 6 + ld c, 10 call TextBoxBorder - call Func_42769 + call Trade_PrintPlayerMonInfoText ld b, $98 call CopyScreenTileBufferToVRAM call ClearScreen - ld a, [wWhichTrade] ; wWhichTrade - call Func_415a4 + ld a, [wTradedPlayerMonSpecies] + call Trade_LoadMonSprite ld a, $7e -.asm_41273 +.slideScreenLoop push af call DelayFrame pop af - ld [rWX], a ; $ff4b - ld [$ffae], a + ld [rWX], a + ld [hSCX], a dec a dec a and a - jr nz, .asm_41273 - call Delay50 - ld a, ANIM_AD - call Func_41676 - ld a, ANIM_AA - call Func_41676 - ld a, [wWhichTrade] ; wWhichTrade + jr nz, .slideScreenLoop + call Trade_Delay80 + ld a, TRADE_BALL_POOF_ANIM + call Trade_ShowAnimation + ld a, TRADE_BALL_DROP_ANIM + call Trade_ShowAnimation + ld a, [wTradedPlayerMonSpecies] call PlayCry xor a - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba + ld [H_AUTOBGTRANSFERENABLED], a ret -Func_41298: ; 41298 (10:5298) - call Func_41196 +Trade_DrawOpenEndOfLinkCable: ; 41298 (10:5298) + call Trade_ClearTileMap ld b, $98 call CopyScreenTileBufferToVRAM ld b, $8 call GoPAL_SET ld hl, vBGMap1 + $8c - call Func_414ae + call Trade_RedrawRows4And5 ld a, $a0 - ld [$ffae], a + ld [hSCX], a call DelayFrame - ld a, $8b - ld [rLCDC], a ; $ff40 + ld a, %10001011 + ld [rLCDC], a hlCoord 6, 2 - ld b, $7 - call Func_41842 - call Func_41186 + ld b, $7 ; open end of link cable tile ID list index + call CopyTileIDsFromList_ZeroBaseTileID + call Trade_CopyTileMapToVRAM ld a, (SFX_02_3d - SFX_Headers_02) / 3 call PlaySound - ld c, $14 -.asm_412c8 - ld a, [$ffae] - add $4 - ld [$ffae], a + ld c, 20 +.loop + ld a, [hSCX] + add 4 + ld [hSCX], a dec c - jr nz, .asm_412c8 + jr nz, .loop ret -Func_412d2: ; 412d2 (10:52d2) - ld a, ANIM_AB - call Func_41676 +Trade_AnimateBallEnteringLinkCable: ; 412d2 (10:52d2) + ld a, TRADE_BALL_SHAKE_ANIM + call Trade_ShowAnimation ld c, 10 call DelayFrames - ld a, $e4 - ld [rOBP0], a ; $ff48 + ld a, %11100100 + ld [rOBP0], a xor a ld [wd09f], a ld bc, $2060 -.asm_412e7 +.moveBallInsideLinkCableLoop push bc xor a - ld de, UnknownOAM_4132e ; $532e + ld de, Trade_BallInsideLinkCableOAM call WriteOAMBlock ld a, [wd09f] xor $1 @@ -263,58 +263,58 @@ Func_412d2: ; 412d2 (10:52d2) ld hl, wOAMBuffer + $02 ld de, $4 ld c, e -.asm_41300 +.cycleSpriteFramesLoop ld [hl], a add hl, de dec c - jr nz, .asm_41300 + jr nz, .cycleSpriteFramesLoop call Delay3 pop bc ld a, c add $4 ld c, a cp $a0 - jr nc, .asm_41318 + jr nc, .ballSpriteReachedEdgeOfScreen ld a, (SFX_02_3c - SFX_Headers_02) / 3 call PlaySound - jr .asm_412e7 -.asm_41318 + jr .moveBallInsideLinkCableLoop +.ballSpriteReachedEdgeOfScreen call ClearSprites ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba + ld [H_AUTOBGTRANSFERENABLED], a call ClearScreen ld b, $98 call CopyScreenTileBufferToVRAM call Delay3 xor a - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba + ld [H_AUTOBGTRANSFERENABLED], a ret -UnknownOAM_4132e: ; 4132e (10:532e) +Trade_BallInsideLinkCableOAM: ; 4132e (10:532e) db $7E,$00,$7E,$20 db $7E,$40,$7E,$60 -Func_41336: ; 41336 (10:5336) - ld a, ANIM_AC - call Func_41676 +Trade_ShowEnemyMon: ; 41336 (10:5336) + ld a, TRADE_BALL_TILT_ANIM + call Trade_ShowAnimation call Func_415c8 hlCoord 4, 10 - ld b, $6 - ld c, $a + ld b, 6 + ld c, 10 call TextBoxBorder - call Func_427a7 - call Func_41186 + call Trade_PrintEnemyMonInfoText + call Trade_CopyTileMapToVRAM ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba - ld a, [wTrainerEngageDistance] - call Func_415a4 - ld a, ANIM_AD - call Func_41676 + ld [H_AUTOBGTRANSFERENABLED], a + ld a, [wTradedEnemyMonSpecies] + call Trade_LoadMonSprite + ld a, TRADE_BALL_POOF_ANIM + call Trade_ShowAnimation ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba - ld a, [wTrainerEngageDistance] + ld [H_AUTOBGTRANSFERENABLED], a + ld a, [wTradedEnemyMonSpecies] call PlayCry - call Func_41181 + call Trade_Delay100 hlCoord 4, 10 ld bc, $80c call ClearScreenArea @@ -325,23 +325,23 @@ Func_41376: ; 41376 (10:5376) ld a, $1 ld [wd08a], a ld a, $e4 - ld [rOBP0], a ; $ff48 + ld [rOBP0], a ld a, $54 - ld [W_BASECOORDX], a ; wd081 + ld [W_BASECOORDX], a ld a, $1c - ld [W_BASECOORDY], a ; wd082 + ld [W_BASECOORDY], a ld a, [wcd5e] ld [wcd5d], a call Func_41505 call Func_4142d - call Func_41186 + call Trade_CopyTileMapToVRAM call Func_4149f ld hl, vBGMap1 + $8c - call Func_414ae + call Trade_RedrawRows4And5 ld b, $6 call Func_414c5 ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba + ld [H_AUTOBGTRANSFERENABLED], a call Func_4149f ld b, $4 call Func_414c5 @@ -349,7 +349,7 @@ Func_41376: ; 41376 (10:5376) ld b, $6 call Func_414c5 xor a - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba + ld [H_AUTOBGTRANSFERENABLED], a call Func_41525 jp ClearSprites @@ -358,22 +358,22 @@ Func_413c6: ; 413c6 (10:53c6) xor a ld [wd08a], a ld a, $64 - ld [W_BASECOORDX], a ; wd081 + ld [W_BASECOORDX], a ld a, $44 - ld [W_BASECOORDY], a ; wd082 + ld [W_BASECOORDY], a ld a, [wcd5f] ld [wcd5d], a call Func_41505 call Func_4145c - call Func_41186 + call Trade_CopyTileMapToVRAM call Func_4149f ld hl, vBGMap1 + $94 - call Func_414ae + call Trade_RedrawRows4And5 call Func_41525 ld b, $6 call Func_414c5 ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba + ld [H_AUTOBGTRANSFERENABLED], a call Func_4149f ld b, $4 call Func_414c5 @@ -381,27 +381,27 @@ Func_413c6: ; 413c6 (10:53c6) ld b, $6 call Func_414c5 xor a - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba + ld [H_AUTOBGTRANSFERENABLED], a jp ClearSprites Func_41411: ; 41411 (10:5411) ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba + ld [H_AUTOBGTRANSFERENABLED], a call ClearScreen xor a - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba + ld [H_AUTOBGTRANSFERENABLED], a call Func_4120b call DelayFrame - ld a, $ab - ld [rLCDC], a ; $ff40 + ld a, %10101011 + ld [rLCDC], a xor a - ld [$ffae], a + ld [hSCX], a ld a, $90 ld [hWY], a ret Func_4142d: ; 4142d (10:542d) - call Func_41196 + call Trade_ClearTileMap hlCoord 11, 4 ld a, $5d ld [hli], a @@ -413,18 +413,18 @@ Func_4142d: ; 4142d (10:542d) jr nz, .asm_4143a hlCoord 5, 3 ld b, $6 - call Func_41842 + call CopyTileIDsFromList_ZeroBaseTileID hlCoord 4, 12 - ld b, $2 - ld c, $7 + ld b, 2 + ld c, 7 call TextBoxBorder hlCoord 5, 14 - ld de, wPlayerName ; wd158 + ld de, wPlayerName call PlaceString jp DelayFrame Func_4145c: ; 4145c (10:545c) - call Func_41196 + call Trade_ClearTileMap hlCoord 0, 4 ld a, $5e ld c, $e @@ -451,18 +451,18 @@ Func_4145c: ; 4145c (10:545c) ld [hl], a hlCoord 7, 8 ld b, $6 - call Func_41842 + call CopyTileIDsFromList_ZeroBaseTileID hlCoord 6, 0 ld b, $2 ld c, $7 call TextBoxBorder hlCoord 7, 2 - ld de, W_GRASSRATE ; W_GRASSRATE + ld de, wLinkEnemyTrainerName call PlaceString jp DelayFrame Func_4149f: ; 4149f (10:549f) - call Func_41196 + call Trade_ClearTileMap hlCoord 0, 4 ld a, $5e ld c, $14 @@ -472,7 +472,7 @@ Func_4149f: ; 4149f (10:549f) jr nz, .asm_414a9 ret -Func_414ae: ; 414ae (10:54ae) +Trade_RedrawRows4And5: ; 414ae (10:54ae) push hl hlCoord 0, 4 call CopyToScreenEdgeTiles @@ -480,10 +480,10 @@ Func_414ae: ; 414ae (10:54ae) ld a, h ld [H_SCREENEDGEREDRAWADDR + 1], a ld a, l - ld [H_SCREENEDGEREDRAWADDR], a ; $ffd1 - ld a, $2 - ld [H_SCREENEDGEREDRAW], a ; $ffd0 - ld c, $a + ld [H_SCREENEDGEREDRAWADDR], a + ld a, REDRAWROW + ld [H_SCREENEDGEREDRAW], a + ld c, 10 jp DelayFrames Func_414c5: ; 414c5 (10:54c5) @@ -494,14 +494,14 @@ Func_414c5: ; 414c5 (10:54c5) ld a, e dec a jr z, .asm_414d5 - ld a, [$ffae] + ld a, [hSCX] sub $2 jr .asm_414d9 .asm_414d5 - ld a, [$ffae] + ld a, [hSCX] add $2 .asm_414d9 - ld [$ffae], a + ld [hSCX], a call DelayFrame dec d jr nz, .asm_414cb @@ -514,9 +514,9 @@ Func_414e8: ; 414e8 (10:54e8) push de push bc push hl - ld a, [rBGP] ; $ff47 + ld a, [rBGP] xor $3c - ld [rBGP], a ; $ff47 + ld [rBGP], a ld hl, wOAMBuffer + $02 ld de, $4 ld c, $14 @@ -540,10 +540,10 @@ Func_41510: ; 41510 (10:5510) ld hl, wOAMBuffer ld c, $14 .asm_41515 - ld a, [W_BASECOORDY] ; wd082 + ld a, [W_BASECOORDY] add [hl] ld [hli], a - ld a, [W_BASECOORDX] ; wd081 + ld a, [W_BASECOORDX] add [hl] ld [hli], a inc hl @@ -566,9 +566,9 @@ Func_41525: ; 41525 (10:5525) ld bc, $fc00 .asm_4153f ld a, b - ld [W_BASECOORDX], a ; wd081 + ld [W_BASECOORDX], a ld a, c - ld [W_BASECOORDY], a ; wd082 + ld [W_BASECOORDY], a ld d, $4 .asm_41549 call Func_41510 @@ -580,7 +580,7 @@ Func_41525: ; 41525 (10:5525) ret Func_41558: ; 41558 (10:5558) - ld hl, OAMPointers_41574 ; $5574 + ld hl, OAMPointers_41574 ld c, $4 xor a .asm_4155e @@ -630,58 +630,59 @@ UnknownOAM_4159c: ; 4159c (10:559c) db $3B,$70,$3A,$70 db $39,$70,$38,$70 -Func_415a4: ; 415a4 (10:55a4) +; a = species +Trade_LoadMonSprite: ; 415a4 (10:55a4) ld [wcf91], a ld [wd0b5], a ld [wcf1d], a ld b, $b ld c, $0 call GoPAL_SET - ld a, [H_AUTOBGTRANSFERENABLED] ; $ffba + ld a, [H_AUTOBGTRANSFERENABLED] xor $1 - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba + ld [H_AUTOBGTRANSFERENABLED], a call GetMonHeader hlCoord 7, 2 call LoadFlippedFrontSpriteByMonIndex - ld c, $a + ld c, 10 jp DelayFrames Func_415c8: ; 415c8 (10:55c8) ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba + ld [H_AUTOBGTRANSFERENABLED], a call ClearScreen - ld a, $e3 - ld [rLCDC], a ; $ff40 + ld a, %11100011 + ld [rLCDC], a ld a, $7 - ld [rWX], a ; $ff4b + ld [rWX], a xor a ld [hWY], a ld a, $90 - ld [$ffae], a + ld [hSCX], a ret Func_415df: ; 415df (10:55df) - ld c, $32 + ld c, 50 call DelayFrames -.asm_415e4 +.loop call DelayFrame - ld a, [rWX] ; $ff4b + ld a, [rWX] inc a inc a - ld [rWX], a ; $ff4b + ld [rWX], a cp $a1 - jr nz, .asm_415e4 - call Func_41196 - ld c, $a + jr nz, .loop + call Trade_ClearTileMap + ld c, 10 call DelayFrames ld a, $7 - ld [rWX], a ; $ff4b + ld [rWX], a ret PrintTradeWentToText: ; 415fe (10:55fe) ld hl, TradeWentToText call PrintText - ld c, $c8 + ld c, 200 call DelayFrames jp Func_415df @@ -692,10 +693,10 @@ TradeWentToText: ; 4160c (10:560c) PrintTradeForSendsText: ; 41611 (10:5611) ld hl, TradeForText call PrintText - call Delay50 + call Trade_Delay80 ld hl, TradeSendsText call PrintText - jp Delay50 + jp Trade_Delay80 TradeForText: ; 41623 (10:5623) TX_FAR _TradeForText @@ -708,10 +709,10 @@ TradeSendsText: ; 41628 (10:5628) PrintTradeFarewellText: ; 4162d (10:562d) ld hl, TradeWavesFarewellText call PrintText - call Delay50 + call Trade_Delay80 ld hl, TradeTransferredText call PrintText - call Delay50 + call Trade_Delay80 jp Func_415df TradeWavesFarewellText: ; 41642 (10:5642) @@ -725,7 +726,7 @@ TradeTransferredText: ; 41647 (10:5647) PrintTradeTakeCareText: ; 4164c (10:564c) ld hl, TradeTakeCareText call PrintText - jp Delay50 + jp Trade_Delay80 TradeTakeCareText: ; 41655 (10:5655) TX_FAR _TradeTakeCareText @@ -734,10 +735,10 @@ TradeTakeCareText: ; 41655 (10:5655) PrintTradeWillTradeText: ; 4165a (10:565a) ld hl, TradeWillTradeText call PrintText - call Delay50 + call Trade_Delay80 ld hl, TradeforText call PrintText - jp Delay50 + jp Trade_Delay80 TradeWillTradeText: ; 4166c (10:566c) TX_FAR _TradeWillTradeText @@ -747,8 +748,8 @@ TradeforText: ; 41671 (10:5671) TX_FAR _TradeforText db "@" -Func_41676: ; 41676 (10:5676) - ld [W_ANIMATIONID], a ; W_ANIMATIONID +Trade_ShowAnimation: ; 41676 (10:5676) + ld [W_ANIMATIONID], a xor a ld [wcc5b], a predef_jump MoveAnimation diff --git a/engine/trade2.asm b/engine/trade2.asm index b13a18b66b..da199e77a2 100755 --- a/engine/trade2.asm +++ b/engine/trade2.asm @@ -1,8 +1,8 @@ -Func_42769: ; 42769 (10:6769) +Trade_PrintPlayerMonInfoText: ; 42769 (10:6769) hlCoord 5, 0 - ld de,OTString67E5 + ld de,Trade_MonInfoText call PlaceString - ld a,[wWhichTrade] + ld a,[wTradedPlayerMonSpecies] ld [wd11e],a predef IndexToPokedex hlCoord 9, 0 @@ -13,18 +13,18 @@ Func_42769: ; 42769 (10:6769) ld de,wcf4b call PlaceString hlCoord 8, 4 - ld de,wTrainerScreenX + ld de,wTradedPlayerMonOT call PlaceString hlCoord 8, 6 - ld de,wcd4c + ld de,wTradedPlayerMonOTID ld bc,$8205 jp PrintNumber -Func_427a7: ; 427a7 (10:67a7) +Trade_PrintEnemyMonInfoText: ; 427a7 (10:67a7) hlCoord 5, 10 - ld de,OTString67E5 + ld de,Trade_MonInfoText call PlaceString - ld a,[wTrainerEngageDistance] + ld a,[wTradedEnemyMonSpecies] ld [wd11e],a predef IndexToPokedex hlCoord 9, 10 @@ -35,14 +35,14 @@ Func_427a7: ; 427a7 (10:67a7) ld de,wcd6d call PlaceString hlCoord 8, 14 - ld de,wcd4e + ld de,wTradedEnemyMonOT call PlaceString hlCoord 8, 16 - ld de,wcd59 + ld de,wTradedEnemyMonOTID ld bc,$8205 jp PrintNumber -OTString67E5: ; 427e5 (10:67e5) +Trade_MonInfoText: ; 427e5 (10:67e5) db "──",$74,$F2,$4E db $4E db "OT/",$4E diff --git a/extras b/extras index a87f66964c..698b0fc7e6 160000 --- a/extras +++ b/extras @@ -1 +1 @@ -Subproject commit a87f66964cc602ff5575efebf27c388ef03fa94d +Subproject commit 698b0fc7e63d3dadf07247015e230bce145cc500 diff --git a/home.asm b/home.asm index 3f6cbd3419..20ea8550a7 100644 --- a/home.asm +++ b/home.asm @@ -1326,7 +1326,7 @@ AddAmountSoldToMoney:: ; 2b9e (0:2b9e) ld c,3 ; length of money in bytes predef AddBCDPredef ; add total price to money ld a,$13 - ld [wd125],a + ld [wTextBoxID],a call DisplayTextBoxID ; redraw money text box ld a, (SFX_02_5a - SFX_Headers_02) / 3 call PlaySoundWaitForCurrent ; play sound @@ -1399,7 +1399,7 @@ DisplayListMenuID:: ; 2be6 (0:2be6) ld a,[hl] ld [wd12a],a ; [wd12a] = number of list entries ld a,$0d ; list menu text box ID - ld [wd125],a + ld [wTextBoxID],a call DisplayTextBoxID ; draw the menu text box call UpdateSprites ; disable sprites behind the text box ; the code up to .skipMovingSprites appears to be useless @@ -2136,7 +2136,7 @@ IsKeyItem:: ; 30d9 (0:30d9) ; function to draw various text boxes ; INPUT: -; [wd125] = text box ID +; [wTextBoxID] = text box ID DisplayTextBoxID:: ; 30e8 (0:30e8) ld a,[H_LOADEDROMBANK] push af @@ -2898,7 +2898,7 @@ GetSpriteMovementByte2Pointer:: ; 3558 (0:3558) GetTrainerInformation:: ; 3566 (0:3566) call GetTrainerName - ld a, [W_ISLINKBATTLE] ; W_ISLINKBATTLE + ld a, [wLinkState] and a jr nz, .linkBattle ld a, Bank(TrainerPicAndMoneyPointers) @@ -2997,34 +2997,34 @@ YesNoChoice:: ; 35ec (0:35ec) Func_35f4:: ; 35f4 (0:35f4) ld a, $14 - ld [wd125], a + ld [wTextBoxID], a call InitYesNoTextBoxParameters jp DisplayTextBoxID InitYesNoTextBoxParameters:: ; 35ff (0:35ff) - xor a - ld [wd12c], a + xor a ; YES_NO_MENU + ld [wTwoOptionMenuID], a hlCoord 14, 7 ld bc, $80f ret YesNoChoicePokeCenter:: ; 360a (0:360a) call SaveScreenTilesToBuffer1 - ld a, $6 - ld [wd12c], a + ld a, HEAL_CANCEL_MENU + ld [wTwoOptionMenuID], a hlCoord 11, 6 ld bc, $80c jr DisplayYesNoChoice Func_361a:: ; 361a (0:361a) call SaveScreenTilesToBuffer1 - ld a, $3 - ld [wd12c], a + ld a, WIDE_YES_NO_MENU + ld [wTwoOptionMenuID], a hlCoord 12, 7 ld bc, $080d DisplayYesNoChoice:: ; 3628 (0:3628) ld a, $14 - ld [wd125], a + ld [wTextBoxID], a call DisplayTextBoxID jp LoadScreenTilesFromBuffer1 @@ -3467,7 +3467,7 @@ WaitForTextScrollButtonPress:: ; 3865 (0:3865) call HandleDownArrowBlinkTiming pop hl call JoypadLowSensitivity - predef Func_5a5f + predef CableClub_Run ld a, [hJoy5] and A_BUTTON | B_BUTTON jr z, .loop @@ -3479,8 +3479,8 @@ WaitForTextScrollButtonPress:: ; 3865 (0:3865) ; (unless in link battle) waits for A or B being pressed and outputs the scrolling sound effect ManualTextScroll:: ; 3898 (0:3898) - ld a, [W_ISLINKBATTLE] - cp $4 + ld a, [wLinkState] + cp LINK_STATE_BATTLING jr z, .inLinkBattle call WaitForTextScrollButtonPress ld a, (SFX_02_40 - SFX_Headers_02) / 3 @@ -4194,7 +4194,7 @@ PrintText:: ; 3c49 (0:3c49) ; Print text hl at (1, 14). push hl ld a,1 - ld [wd125],a + ld [wTextBoxID],a call DisplayTextBoxID call UpdateSprites call Delay3 diff --git a/home/init.asm b/home/init.asm index e4c2400192..cc89ad34b1 100644 --- a/home/init.asm +++ b/home/init.asm @@ -26,7 +26,7 @@ rLCDC_DEFAULT EQU %11100011 ld [$ff43], a ld [$ff42], a ld [rSB], a - ld [$ff02], a + ld [rSC], a ld [$ff4b], a ld [$ff4a], a ld [$ff06], a @@ -67,8 +67,8 @@ rLCDC_DEFAULT EQU %11100011 xor a ld [hTilesetType], a ld [$ff41], a - ld [$ffae], a - ld [$ffaf], a + ld [hSCX], a + ld [hSCY], a ld [$ff0f], a ld a, 1 << VBLANK + 1 << TIMER + 1 << SERIAL ld [rIE], a @@ -79,8 +79,8 @@ rLCDC_DEFAULT EQU %11100011 ld a, 7 ld [rWX], a - ld a, $ff - ld [$ffaa], a + ld a, CONNECTION_NOT_ESTABLISHED + ld [hSerialConnectionStatus], a ld h, vBGMap0 / $100 call ClearBgMap diff --git a/home/overworld.asm b/home/overworld.asm index 5079118426..c5c180c787 100644 --- a/home/overworld.asm +++ b/home/overworld.asm @@ -1609,12 +1609,12 @@ AdvancePlayerSprite:: ; 0d27 (0:0d27) ld c,a sla b sla c - ld a,[$ffaf] + ld a,[hSCY] add b - ld [$ffaf],a ; update background scroll Y - ld a,[$ffae] + ld [hSCY],a ; update background scroll Y + ld a,[hSCX] add c - ld [$ffae],a ; update background scroll X + ld [hSCX],a ; update background scroll X ; shift all the sprites in the direction opposite of the player's motion ; so that the player appears to move relative to them ld hl,wSpriteStateData1 + $14 @@ -2310,8 +2310,8 @@ LoadMapData:: ; 1241 (0:1241) ld [wMapViewVRAMPointer + 1],a xor a ld [wMapViewVRAMPointer],a - ld [$ffaf],a - ld [$ffae],a + ld [hSCY],a + ld [hSCX],a ld [wWalkCounter],a ld [wd119],a ld [wWalkBikeSurfStateCopy],a diff --git a/home/serial.asm b/home/serial.asm index 02eb35347e..fa3d4c8aec 100644 --- a/home/serial.asm +++ b/home/serial.asm @@ -1,304 +1,313 @@ -Serial:: ; 2125 (0:2125) - push af - push bc - push de - push hl - ld a, [$ffaa] - inc a - jr z, .asm_2142 - ld a, [$ff01] - ld [$ffad], a - ld a, [$ffac] - ld [$ff01], a - ld a, [$ffaa] - cp $2 - jr z, .asm_2162 - ld a, $80 - ld [$ff02], a - jr .asm_2162 -.asm_2142 - ld a, [$ff01] - ld [$ffad], a - ld [$ffaa], a - cp $2 - jr z, .asm_215f - xor a - ld [$ff01], a - ld a, $3 - ld [rDIV], a ; $ff04 -.asm_2153 - ld a, [rDIV] ; $ff04 - bit 7, a - jr nz, .asm_2153 - ld a, $80 - ld [$ff02], a - jr .asm_2162 -.asm_215f - xor a - ld [$ff01], a -.asm_2162 - ld a, $1 - ld [$ffa9], a - ld a, $fe - ld [$ffac], a - pop hl - pop de - pop bc - pop af - reti - -Func_216f:: ; 216f (0:216f) - ld a, $1 - ld [$ffab], a -.asm_2173 - ld a, [hl] - ld [$ffac], a - call Func_219a - push bc - ld b, a - inc hl - ld a, $30 -.asm_217e - dec a - jr nz, .asm_217e - ld a, [$ffab] - and a - ld a, b - pop bc - jr z, .asm_2192 - dec hl - cp $fd - jr nz, .asm_2173 - xor a - ld [$ffab], a - jr .asm_2173 -.asm_2192 - ld [de], a - inc de - dec bc - ld a, b - or c - jr nz, .asm_2173 - ret - -Func_219a:: ; 219a (0:219a) - xor a - ld [$ffa9], a - ld a, [$ffaa] - cp $2 - jr nz, .asm_21a7 - ld a, $81 - ld [$ff02], a -.asm_21a7 - ld a, [$ffa9] - and a - jr nz, .asm_21f1 - ld a, [$ffaa] - cp $1 - jr nz, .asm_21cc - call Func_2237 - jr z, .asm_21cc - call Func_2231 - push hl - ld hl, wcc48 - inc [hl] - jr nz, .asm_21c3 - dec hl - inc [hl] -.asm_21c3 - pop hl - call Func_2237 - jr nz, .asm_21a7 - jp Func_223f -.asm_21cc - ld a, [rIE] ; $ffff - and $f - cp $8 - jr nz, .asm_21a7 - ld a, [W_NUMHITS] ; wd074 - dec a - ld [W_NUMHITS], a ; wd074 - jr nz, .asm_21a7 - ld a, [wd075] - dec a - ld [wd075], a - jr nz, .asm_21a7 - ld a, [$ffaa] - cp $1 - jr z, .asm_21f1 - ld a, $ff -.asm_21ee - dec a - jr nz, .asm_21ee -.asm_21f1 - xor a - ld [$ffa9], a - ld a, [rIE] ; $ffff - and $f - sub $8 - jr nz, .asm_2204 - ld [W_NUMHITS], a ; wd074 - ld a, $50 - ld [wd075], a -.asm_2204 - ld a, [$ffad] - cp $fe - ret nz - call Func_2237 - jr z, .asm_221f - push hl - ld hl, wcc48 - ld a, [hl] - dec a - ld [hld], a - inc a - jr nz, .asm_2219 - dec [hl] -.asm_2219 - pop hl - call Func_2237 - jr z, Func_223f -.asm_221f - ld a, [rIE] ; $ffff - and $f - cp $8 - ld a, $fe - ret z - ld a, [hl] - ld [$ffac], a - call DelayFrame - jp Func_219a - -Func_2231:: ; 2231 (0:2231) - ld a, $f -.asm_2233 - dec a - jr nz, .asm_2233 - ret - -Func_2237:: ; 2237 (0:2237) - push hl - ld hl, wcc47 - ld a, [hli] - or [hl] - pop hl - ret - -Func_223f:: ; 223f (0:223f) - dec a - ld [wcc47], a - ld [wcc48], a - ret - -Func_2247:: ; 2247 (0:2247) - ld hl, wcc42 - ld de, wcc3d - ld c, $2 - ld a, $1 - ld [$ffab], a -.asm_2253 - call DelayFrame - ld a, [hl] - ld [$ffac], a - call Func_219a - ld b, a - inc hl - ld a, [$ffab] - and a - ld a, $0 - ld [$ffab], a - jr nz, .asm_2253 - ld a, b - ld [de], a - inc de - dec c - jr nz, .asm_2253 - ret - -Func_226e:: ; 226e (0:226e) - call SaveScreenTilesToBuffer1 - callab PrintWaitingText - call Func_227f - jp LoadScreenTilesFromBuffer1 - -Func_227f:: ; 227f (0:227f) - ld a, $ff - ld [wcc3e], a -.asm_2284 - call Func_22c3 - call DelayFrame - call Func_2237 - jr z, .asm_22a0 - push hl - ld hl, wcc48 - dec [hl] - jr nz, .asm_229f - dec hl - dec [hl] - jr nz, .asm_229f - pop hl - xor a - jp Func_223f -.asm_229f - pop hl -.asm_22a0 - ld a, [wcc3e] - inc a - jr z, .asm_2284 - ld b, $a -.asm_22a8 - call DelayFrame - call Func_22c3 - dec b - jr nz, .asm_22a8 - ld b, $a -.asm_22b3 - call DelayFrame - call Func_22ed - dec b - jr nz, .asm_22b3 - ld a, [wcc3e] - ld [wcc3d], a - ret - -Func_22c3:: ; 22c3 (0:22c3) - call asm_22d7 - ld a, [wcc42] - add $60 - ld [$ffac], a - ld a, [$ffaa] - cp $2 - jr nz, asm_22d7 - ld a, $81 - ld [$ff02], a -asm_22d7:: ; 22d7 (0:22d7) - ld a, [$ffad] - ld [wcc3d], a - and $f0 - cp $60 - ret nz - xor a - ld [$ffad], a - ld a, [wcc3d] - and $f - ld [wcc3e], a - ret - -Func_22ed:: ; 22ed (0:22ed) - xor a - ld [$ffac], a - ld a, [$ffaa] - cp $2 - ret nz - ld a, $81 - ld [$ff02], a - ret - -Func_22fa:: ; 22fa (0:22fa) - ld a, $2 - ld [$ff01], a - xor a - ld [$ffad], a - ld a, $80 - ld [$ff02], a - ret +Serial:: ; 2125 (0:2125) + push af + push bc + push de + push hl + ld a, [hSerialConnectionStatus] + inc a + jr z, .connectionNotYetEstablished + ld a, [rSB] + ld [hSerialReceiveData], a + ld a, [hSerialSendData] + ld [rSB], a + ld a, [hSerialConnectionStatus] + cp USING_INTERNAL_CLOCK + jr z, .done +; using external clock + ld a, START_TRANSFER_EXTERNAL_CLOCK + ld [rSC], a + jr .done +.connectionNotYetEstablished + ld a, [rSB] + ld [hSerialReceiveData], a + ld [hSerialConnectionStatus], a + cp USING_INTERNAL_CLOCK + jr z, .usingInternalClock +; using external clock + xor a + ld [rSB], a + ld a, $3 + ld [rDIV], a +.waitLoop + ld a, [rDIV] + bit 7, a + jr nz, .waitLoop + ld a, START_TRANSFER_EXTERNAL_CLOCK + ld [rSC], a + jr .done +.usingInternalClock + xor a + ld [rSB], a +.done + ld a, $1 + ld [hSerialReceivedNewData], a + ld a, SERIAL_NO_DATA_BYTE + ld [hSerialSendData], a + pop hl + pop de + pop bc + pop af + reti + +; hl = send data +; de = receive data +; bc = length of data +Serial_ExchangeBytes:: ; 216f (0:216f) + ld a, 1 + ld [hSerialIgnoringInitialData], a +.loop + ld a, [hl] + ld [hSerialSendData], a + call Serial_ExchangeByte + push bc + ld b, a + inc hl + ld a, 48 +.waitLoop + dec a + jr nz, .waitLoop + ld a, [hSerialIgnoringInitialData] + and a + ld a, b + pop bc + jr z, .storeReceivedByte + dec hl + cp SERIAL_PREAMBLE_BYTE + jr nz, .loop + xor a + ld [hSerialIgnoringInitialData], a + jr .loop +.storeReceivedByte + ld [de], a + inc de + dec bc + ld a, b + or c + jr nz, .loop + ret + +Serial_ExchangeByte:: ; 219a (0:219a) + xor a + ld [hSerialReceivedNewData], a + ld a, [hSerialConnectionStatus] + cp USING_INTERNAL_CLOCK + jr nz, .asm_21a7 + ld a, START_TRANSFER_INTERNAL_CLOCK + ld [rSC], a +.asm_21a7 + ld a, [hSerialReceivedNewData] + and a + jr nz, .asm_21f1 + ld a, [hSerialConnectionStatus] + cp USING_EXTERNAL_CLOCK + jr nz, .asm_21cc + call IsUnknownCounterZero + jr z, .asm_21cc + call WaitLoop_15Iterations + push hl + ld hl, wUnknownSerialCounter + 1 + inc [hl] + jr nz, .asm_21c3 + dec hl + inc [hl] +.asm_21c3 + pop hl + call IsUnknownCounterZero + jr nz, .asm_21a7 + jp SetUnknownCounterToFFFF +.asm_21cc + ld a, [rIE] + and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK) + cp (1 << SERIAL) + jr nz, .asm_21a7 + ld a, [wUnknownSerialCounter2] + dec a + ld [wUnknownSerialCounter2], a + jr nz, .asm_21a7 + ld a, [wUnknownSerialCounter2 + 1] + dec a + ld [wUnknownSerialCounter2 + 1], a + jr nz, .asm_21a7 + ld a, [hSerialConnectionStatus] + cp USING_EXTERNAL_CLOCK + jr z, .asm_21f1 + ld a, 255 +.waitLoop + dec a + jr nz, .waitLoop +.asm_21f1 + xor a + ld [hSerialReceivedNewData], a + ld a, [rIE] + and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK) + sub (1 << SERIAL) + jr nz, .asm_2204 + ld [wUnknownSerialCounter2], a + ld a, $50 + ld [wUnknownSerialCounter2 + 1], a +.asm_2204 + ld a, [hSerialReceiveData] + cp SERIAL_NO_DATA_BYTE + ret nz + call IsUnknownCounterZero + jr z, .asm_221f + push hl + ld hl, wUnknownSerialCounter + 1 + ld a, [hl] + dec a + ld [hld], a + inc a + jr nz, .asm_2219 + dec [hl] +.asm_2219 + pop hl + call IsUnknownCounterZero + jr z, SetUnknownCounterToFFFF +.asm_221f + ld a, [rIE] + and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK) + cp (1 << SERIAL) + ld a, SERIAL_NO_DATA_BYTE + ret z + ld a, [hl] + ld [hSerialSendData], a + call DelayFrame + jp Serial_ExchangeByte + +WaitLoop_15Iterations:: ; 2231 (0:2231) + ld a, 15 +.waitLoop + dec a + jr nz, .waitLoop + ret + +IsUnknownCounterZero:: ; 2237 (0:2237) + push hl + ld hl, wUnknownSerialCounter + ld a, [hli] + or [hl] + pop hl + ret + +; a is always 0 when this is called +SetUnknownCounterToFFFF:: ; 223f (0:223f) + dec a + ld [wUnknownSerialCounter], a + ld [wUnknownSerialCounter + 1], a + ret + +; This is used to exchange the button press and selected menu item on the link menu. +; The data is sent thrice and read twice to increase reliability. +Serial_ExchangeLinkMenuSelection:: ; 2247 (0:2247) + ld hl, wLinkMenuSelectionSendBuffer + ld de, wLinkMenuSelectionReceiveBuffer + ld c, 2 ; number of bytes to save + ld a, 1 + ld [hSerialIgnoringInitialData], a +.loop + call DelayFrame + ld a, [hl] + ld [hSerialSendData], a + call Serial_ExchangeByte + ld b, a + inc hl + ld a, [hSerialIgnoringInitialData] + and a + ld a, 0 + ld [hSerialIgnoringInitialData], a + jr nz, .loop + ld a, b + ld [de], a + inc de + dec c + jr nz, .loop + ret + +Serial_PrintWaitingTextAndSyncAndExchangeByte:: ; 226e (0:226e) + call SaveScreenTilesToBuffer1 + callab PrintWaitingText + call Serial_SyncAndExchangeNybble + jp LoadScreenTilesFromBuffer1 + +Serial_SyncAndExchangeNybble:: ; 227f (0:227f) + ld a, $ff + ld [wSerialExchangeNybbleReceiveData], a +.loop1 + call Serial_ExchangeNybble + call DelayFrame + call IsUnknownCounterZero + jr z, .next1 + push hl + ld hl, wUnknownSerialCounter + 1 + dec [hl] + jr nz, .next2 + dec hl + dec [hl] + jr nz, .next2 + pop hl + xor a + jp SetUnknownCounterToFFFF +.next2 + pop hl +.next1 + ld a, [wSerialExchangeNybbleReceiveData] + inc a + jr z, .loop1 + ld b, 10 +.loop2 + call DelayFrame + call Serial_ExchangeNybble + dec b + jr nz, .loop2 + ld b, 10 +.loop3 + call DelayFrame + call Serial_SendZeroByte + dec b + jr nz, .loop3 + ld a, [wSerialExchangeNybbleReceiveData] + ld [wSerialSyncAndExchangeNybbleReceiveData], a + ret + +; exchange one byte with value of $f or less +Serial_ExchangeNybble:: ; 22c3 (0:22c3) + call .doExchange + ld a, [wSerialExchangeNybbleSendData] + add $60 + ld [hSerialSendData], a + ld a, [hSerialConnectionStatus] + cp USING_INTERNAL_CLOCK + jr nz, .doExchange + ld a, START_TRANSFER_INTERNAL_CLOCK + ld [rSC], a +.doExchange + ld a, [hSerialReceiveData] + ld [wSerialExchangeNybbleTempReceiveData], a + and $f0 + cp $60 + ret nz + xor a + ld [hSerialReceiveData], a + ld a, [wSerialExchangeNybbleTempReceiveData] + and $f + ld [wSerialExchangeNybbleReceiveData], a + ret + +Serial_SendZeroByte:: ; 22ed (0:22ed) + xor a + ld [hSerialSendData], a + ld a, [hSerialConnectionStatus] + cp USING_INTERNAL_CLOCK + ret nz + ld a, START_TRANSFER_INTERNAL_CLOCK + ld [rSC], a + ret + +Serial_TryEstablishingExternallyClockedConnection:: ; 22fa (0:22fa) + ld a, ESTABLISH_CONNECTION_WITH_EXTERNAL_CLOCK + ld [rSB], a + xor a + ld [hSerialReceiveData], a + ld a, START_TRANSFER_EXTERNAL_CLOCK + ld [rSC], a + ret \ No newline at end of file diff --git a/home/text.asm b/home/text.asm index aed89c3381..362347cc13 100644 --- a/home/text.asm +++ b/home/text.asm @@ -265,8 +265,8 @@ Char5F:: ; 1a91 (0:1a91) ret Char58:: ; 1a95 (0:1a95) - ld a,[W_ISLINKBATTLE] - cp 4 + ld a,[wLinkState] + cp LINK_STATE_BATTLING jp z,Next1AA2 ld a,$EE Coorda 18, 16 @@ -506,8 +506,8 @@ TextCommand05:: ; 1bc5 (0:1bc5) ; 06 ; (no arguments) TextCommand06:: ; 1bcc (0:1bcc) - ld a,[W_ISLINKBATTLE] - cp a,$04 + ld a,[wLinkState] + cp a,LINK_STATE_BATTLING jp z,TextCommand0D ld a,$ee ; down arrow Coorda 18, 16 ; place down arrow in lower right corner of dialogue text box diff --git a/hram.asm b/hram.asm index 644315ec3a..dfe14d6613 100644 --- a/hram.asm +++ b/hram.asm @@ -10,6 +10,8 @@ hSoftReset EQU $FF8A ; presses the reset sequence (A+B+SEL+START). ; Soft reset when 0 is reached. +hBaseTileID EQU $FF8B + ; counters for blinking down arrow H_DOWNARROWBLINKCNT1 EQU $FF8B H_DOWNARROWBLINKCNT2 EQU $FF8C @@ -38,6 +40,19 @@ H_NUMTOPRINT EQU $FF96 ; 3 bytes H_POWEROFTEN EQU $FF99 ; 3 bytes H_SAVEDNUMTOPRINT EQU $FF9C ; 3 bytes +hSerialReceivedNewData EQU $FFA9 + +; $01 = using external clock +; $02 = using internal clock +; $ff = establishing connection +hSerialConnectionStatus EQU $FFAA + +hSerialIgnoringInitialData EQU $FFAB + +hSerialSendData EQU $FFAC + +hSerialReceiveData EQU $FFAD + ; these values are copied to SCX, SCY, and WY during V-blank hSCX EQU $FFAE hSCY EQU $FFAF diff --git a/main.asm b/main.asm index 400c6806c4..dc8b8fa024 100755 --- a/main.asm +++ b/main.asm @@ -167,7 +167,7 @@ PrintWaitingText: call TextBoxBorder jr .asm_4c1a .asm_4c17 - call Func_5ab3 + call CableClub_TextBoxBorder .asm_4c1a hlCoord 4, 11 ld de, WaitingText @@ -633,8 +633,8 @@ LoadSpecialWarpData: ; 62ff (1:62ff) cp BATTLE_CENTER jr nz, .notBattleCenter ld hl, BattleCenterSpec1 - ld a, [$ffaa] - cp $2 + ld a, [hSerialConnectionStatus] + cp USING_INTERNAL_CLOCK ; which gameboy is clocking determines who is on the left and who is on the right jr z, .copyWarpData ld hl, BattleCenterSpec2 jr .copyWarpData @@ -642,8 +642,8 @@ LoadSpecialWarpData: ; 62ff (1:62ff) cp TRADE_CENTER jr nz, .notTradeCenter ld hl, TradeCenterSpec1 - ld a, [$ffaa] - cp $2 + ld a, [hSerialConnectionStatus] + cp USING_INTERNAL_CLOCK jr z, .copyWarpData ld hl, TradeCenterSpec2 jr .copyWarpData @@ -798,7 +798,7 @@ SubtractAmountPaidFromMoney_: ; 6b21 (1:6b21) ld c,3 ; length of money in bytes predef SubBCDPredef ; subtract total price from money ld a,$13 - ld [wd125],a + ld [wTextBoxID],a call DisplayTextBoxID ; redraw money text box and a ret @@ -1164,12 +1164,10 @@ PrintStartMenuItem: ; 71bb (1:71bb) INCLUDE "engine/overworld/cable_club_npc.asm" ; function to draw various text boxes -; INPUT: -; [wd125] = text box ID DisplayTextBoxID_: ; 72ea (1:72ea) - ld a,[wd125] ; a = text box ID + ld a,[wTextBoxID] cp a,$14 - jp z,DisplayYesNoTextBox + jp z,DisplayTwoOptionMenu ld c,a ld hl,TextBoxFunctionTable ld de,3 @@ -1437,7 +1435,7 @@ Func_74ba: ; 74ba (1:74ba) ld hl, wd730 set 6, [hl] ld a, $f - ld [wd125], a + ld [wTextBoxID], a call DisplayTextBoxID hlCoord 13, 1 ld b, $1 @@ -1456,12 +1454,12 @@ CurrencyString: ; 74e2 (1:74e2) Func_74ea: ; 74ea (1:74ea) ld a, [wd730] - set 6, a + set 6, a ; no printing delay ld [wd730], a xor a ld [wd12d], a ld a, $e - ld [wd125], a + ld [wTextBoxID], a call DisplayTextBoxID ld a, $3 ld [wMenuWatchedKeys], a ; wMenuWatchedKeys @@ -1476,7 +1474,7 @@ Func_74ea: ; 74ea (1:74ea) ld [wLastMenuItem], a ; wLastMenuItem ld [wcc37], a ld a, [wd730] - res 6, a + res 6, a ; turn on the printing delay ld [wd730], a call HandleMenuInput call PlaceUnfilledArrowMenuCursor @@ -1505,46 +1503,50 @@ Func_74ea: ; 74ea (1:74ea) scf ret -DisplayYesNoTextBox: ; 7559 (1:7559) +; displays a menu with two options to choose from +; b = Y of upper left corner of text region +; c = X of upper left corner of text region +; hl = address where the text box border should be drawn +DisplayTwoOptionMenu: ; 7559 (1:7559) push hl ld a, [wd730] - set 6, a + set 6, a ; no printing delay ld [wd730], a xor a ld [wd12d], a ld [wd12e], a - ld a, $3 - ld [wMenuWatchedKeys], a ; wMenuWatchedKeys + ld a, A_BUTTON | B_BUTTON + ld [wMenuWatchedKeys], a ld a, $1 - ld [wMaxMenuItem], a ; wMaxMenuItem + ld [wMaxMenuItem], a ld a, b - ld [wTopMenuItemY], a ; wTopMenuItemY + ld [wTopMenuItemY], a ld a, c - ld [wTopMenuItemX], a ; wTopMenuItemX + ld [wTopMenuItemX], a xor a - ld [wLastMenuItem], a ; wLastMenuItem + ld [wLastMenuItem], a ld [wcc37], a push hl - ld hl, wd12c - bit 7, [hl] + ld hl, wTwoOptionMenuID + bit 7, [hl] ; select second menu item by default? res 7, [hl] - jr z, .asm_758d + jr z, .storeCurrentMenuItem inc a -.asm_758d - ld [wCurrentMenuItem], a ; wCurrentMenuItem +.storeCurrentMenuItem + ld [wCurrentMenuItem], a pop hl push hl push hl - call Func_763e - ld a, [wd12c] - ld hl, MenuStrings ; $7671 + call TwoOptionMenu_SaveScreenTiles + ld a, [wTwoOptionMenuID] + ld hl, TwoOptionMenuStrings ld e, a ld d, $0 ld a, $5 -.loop +.menuStringLoop add hl, de dec a - jr nz, .loop + jr nz, .menuStringLoop ld a, [hli] ld c, a ld a, [hli] @@ -1553,22 +1555,22 @@ DisplayYesNoTextBox: ; 7559 (1:7559) ld d, h pop hl push de - ld a, [wd12c] - cp $5 - jr nz, .asm_75b9 - call Func_5ab3 - jr .asm_75bc -.asm_75b9 + ld a, [wTwoOptionMenuID] + cp TRADE_CANCEL_MENU + jr nz, .notTradeCancelMenu + call CableClub_TextBoxBorder + jr .afterTextBoxBorder +.notTradeCancelMenu call TextBoxBorder -.asm_75bc +.afterTextBoxBorder call UpdateSprites pop hl ld a, [hli] - and a - ld bc, $16 - jr z, .asm_75ca - ld bc, $2a -.asm_75ca + and a ; put blank line before first menu item? + ld bc, 20 + 2 + jr z, .noBlankLine + ld bc, 2 * 20 + 2 +.noBlankLine ld a, [hli] ld e, a ld a, [hli] @@ -1577,61 +1579,69 @@ DisplayYesNoTextBox: ; 7559 (1:7559) add hl, bc call PlaceString ld hl, wd730 - res 6, [hl] - ld a, [wd12c] - cp $7 - jr nz, .asm_7603 + res 6, [hl] ; turn on the printing delay + ld a, [wTwoOptionMenuID] + cp NO_YES_MENU + jr nz, .notNoYesMenu +; No/Yes menu +; this menu type ignores the B button +; it only seems to be used when confirming the deletion of a save file xor a - ld [wd12c], a + ld [wTwoOptionMenuID], a ld a, [wFlags_0xcd60] push af push hl ld hl, wFlags_0xcd60 bit 5, [hl] - set 5, [hl] + set 5, [hl] ; don't play sound when A or B is pressed in menu pop hl -.asm_75f0 +.noYesMenuInputLoop call HandleMenuInput - bit 1, a - jr nz, .asm_75f0 + bit 1, a ; A button pressed? + jr nz, .noYesMenuInputLoop ; try again if A was not pressed pop af pop hl ld [wFlags_0xcd60], a ld a, (SFX_02_40 - SFX_Headers_02) / 3 call PlaySound - jr .asm_760f -.asm_7603 + jr .pressedAButton +.notNoYesMenu xor a - ld [wd12c], a + ld [wTwoOptionMenuID], a call HandleMenuInput pop hl - bit 1, a - jr nz, .asm_7627 -.asm_760f - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + bit 1, a ; A button pressed? + jr nz, .choseSecondMenuItem ; automatically choose the second option if B is pressed +.pressedAButton + ld a, [wCurrentMenuItem] ld [wd12d], a and a - jr nz, .asm_7627 + jr nz, .choseSecondMenuItem +; chose first menu item ld a, $1 ld [wd12e], a - ld c, $f + ld c, 15 call DelayFrames - call Func_7656 + call TwoOptionMenu_RestoreScreenTiles and a ret -.asm_7627 +.choseSecondMenuItem ld a, $1 - ld [wCurrentMenuItem], a ; wCurrentMenuItem + ld [wCurrentMenuItem], a ld [wd12d], a ld a, $2 ld [wd12e], a - ld c, $f + ld c, 15 call DelayFrames - call Func_7656 + call TwoOptionMenu_RestoreScreenTiles scf ret -Func_763e: ; 763e (1:763e) +; Some of the wider/taller two option menus will not have the screen areas +; they cover be fully saved/restored by the two functions below. +; The bottom and right edges of the menu may remain after the function returns. + +TwoOptionMenu_SaveScreenTiles: ; 763e (1:763e) ld de, wHPBarMaxHP ld bc, $506 .asm_7644 @@ -1641,7 +1651,7 @@ Func_763e: ; 763e (1:763e) dec c jr nz, .asm_7644 push bc - ld bc, $e + ld bc, 14 add hl, bc pop bc ld c, $6 @@ -1649,7 +1659,7 @@ Func_763e: ; 763e (1:763e) jr nz, .asm_7644 ret -Func_7656: ; 7656 (1:7656) +TwoOptionMenu_RestoreScreenTiles: ; 7656 (1:7656) ld de, wHPBarMaxHP ld bc, $506 .asm_765c @@ -1668,7 +1678,12 @@ Func_7656: ; 7656 (1:7656) call UpdateSprites ret -MenuStrings: ; 7671 (1:7671) +; Format: +; 00: byte width +; 01: byte height +; 02: byte put blank line before first menu item +; 03: word text pointer +TwoOptionMenuStrings: ; 7671 (1:7671) db 4,3,0 dw .YesNoMenu db 6,3,0 diff --git a/scripts/celadongamecorner.asm b/scripts/celadongamecorner.asm index 3e7b994e9c..91d6742df9 100755 --- a/scripts/celadongamecorner.asm +++ b/scripts/celadongamecorner.asm @@ -20,7 +20,7 @@ CeladonGameCornerScript_48bcf: ; 48bcf (12:4bcf) srl a srl a srl a - ld [wcd05], a + ld [wUnknownSlotVar], a ret CeladonGameCornerScript_48bec: ; 48bec (12:4bec) diff --git a/scripts/celadonpokecenter.asm b/scripts/celadonpokecenter.asm index e7bfd1d2c9..1b8d3a1bbd 100755 --- a/scripts/celadonpokecenter.asm +++ b/scripts/celadonpokecenter.asm @@ -1,5 +1,5 @@ CeladonPokecenterScript: ; 488b8 (12:48b8) - call Func_22fa + call Serial_TryEstablishingExternallyClockedConnection jp EnableAutoTextBoxDrawing CeladonPokecenterTextPointers: ; 488be (12:48be) diff --git a/scripts/ceruleanhouse1.asm b/scripts/ceruleanhouse1.asm index ffc8656eb2..4b6a240a54 100755 --- a/scripts/ceruleanhouse1.asm +++ b/scripts/ceruleanhouse1.asm @@ -13,5 +13,5 @@ CeruleanHouse1Text2: ; 1d702 (7:5702) db $08 ; asm ld a, $6 ld [wWhichTrade], a - predef Predef54 + predef DoInGameTradeDialogue jp TextScriptEnd diff --git a/scripts/ceruleanpokecenter.asm b/scripts/ceruleanpokecenter.asm index b6f88b418b..5d88831786 100755 --- a/scripts/ceruleanpokecenter.asm +++ b/scripts/ceruleanpokecenter.asm @@ -1,5 +1,5 @@ CeruleanPokecenterScript: ; 5c645 (17:4645) - call Func_22fa + call Serial_TryEstablishingExternallyClockedConnection jp EnableAutoTextBoxDrawing CeruleanPokecenterTextPointers: ; 5c64b (17:464b) diff --git a/scripts/cinnabarpokecenter.asm b/scripts/cinnabarpokecenter.asm index a2a4159254..abae9d8d38 100755 --- a/scripts/cinnabarpokecenter.asm +++ b/scripts/cinnabarpokecenter.asm @@ -1,5 +1,5 @@ CinnabarPokecenterScript: ; 75e2c (1d:5e2c) - call Func_22fa + call Serial_TryEstablishingExternallyClockedConnection jp EnableAutoTextBoxDrawing CinnabarPokecenterTextPointers: ; 75e32 (1d:5e32) diff --git a/scripts/daycarem.asm b/scripts/daycarem.asm index 3190ba0a7f..1830d2c059 100755 --- a/scripts/daycarem.asm +++ b/scripts/daycarem.asm @@ -129,7 +129,7 @@ DayCareMScript_562e1: ; 562e1 (15:62e1) ld hl, DayCareMText_56428 call PrintText ld a, $13 - ld [wd125], a + ld [wTextBoxID], a call DisplayTextBoxID call YesNoChoice ld hl, DayCareMText_56437 @@ -159,7 +159,7 @@ DayCareMScript_562e1: ; 562e1 (15:62e1) ld a, (SFX_02_5a - SFX_Headers_02) / 3 call PlaySoundWaitForCurrent ld a, $13 - ld [wd125], a + ld [wTextBoxID], a call DisplayTextBoxID ld hl, DayCareMText_5644f call PrintText diff --git a/scripts/fuchsiapokecenter.asm b/scripts/fuchsiapokecenter.asm index 621a483f83..26f88844cd 100755 --- a/scripts/fuchsiapokecenter.asm +++ b/scripts/fuchsiapokecenter.asm @@ -1,5 +1,5 @@ FuchsiaPokecenterScript: ; 75063 (1d:5063) - call Func_22fa + call Serial_TryEstablishingExternallyClockedConnection jp EnableAutoTextBoxDrawing FuchsiaPokecenterTextPointers: ; 75069 (1d:5069) diff --git a/scripts/indigoplateaulobby.asm b/scripts/indigoplateaulobby.asm index 96221c9793..1b09a61d28 100755 --- a/scripts/indigoplateaulobby.asm +++ b/scripts/indigoplateaulobby.asm @@ -1,5 +1,5 @@ IndigoPlateauLobbyScript: ; 19c5b (6:5c5b) - call Func_22fa + call Serial_TryEstablishingExternallyClockedConnection call EnableAutoTextBoxDrawing ld hl, wd126 bit 6, [hl] diff --git a/scripts/lab2.asm b/scripts/lab2.asm index 583ef4e454..9839a56359 100755 --- a/scripts/lab2.asm +++ b/scripts/lab2.asm @@ -21,5 +21,5 @@ Lab2Text3: ; 75c37 (1d:5c37) ld a, $8 ld [wWhichTrade], a asm_78552: ; 75c3d (1d:5c3d) - predef Predef54 + predef DoInGameTradeDialogue jp TextScriptEnd diff --git a/scripts/lab4.asm b/scripts/lab4.asm index 924a6637b2..1e81867610 100755 --- a/scripts/lab4.asm +++ b/scripts/lab4.asm @@ -108,7 +108,7 @@ Lab4Text2: ; 75dda (1d:5dda) db $08 ; asm ld a, $3 ld [wWhichTrade], a - predef Predef54 + predef DoInGameTradeDialogue jp TextScriptEnd LoadFossilItemAndMonNameBank1D: ; 75de8 (1d:5de8) diff --git a/scripts/lavenderpokecenter.asm b/scripts/lavenderpokecenter.asm index 31a50aef58..452cc8a463 100755 --- a/scripts/lavenderpokecenter.asm +++ b/scripts/lavenderpokecenter.asm @@ -1,5 +1,5 @@ LavenderPokecenterScript: ; 5c8da (17:48da) - call Func_22fa + call Serial_TryEstablishingExternallyClockedConnection jp EnableAutoTextBoxDrawing LavenderPokecenterTextPointers: ; 5c8e0 (17:48e0) diff --git a/scripts/mtmoonpokecenter.asm b/scripts/mtmoonpokecenter.asm index 94054561ba..bfe9add885 100755 --- a/scripts/mtmoonpokecenter.asm +++ b/scripts/mtmoonpokecenter.asm @@ -1,5 +1,5 @@ MtMoonPokecenterScript: ; 492cf (12:52cf) - call Func_22fa + call Serial_TryEstablishingExternallyClockedConnection jp EnableAutoTextBoxDrawing MtMoonPokecenterTextPointers: ; 492d5 (12:52d5) @@ -29,7 +29,7 @@ MtMoonPokecenterText4: ; 492ec (12:52ec) ld hl, MtMoonPokecenterText_4935c call PrintText ld a, $13 - ld [wd125], a + ld [wTextBoxID], a call DisplayTextBoxID call YesNoChoice ld a, [wCurrentMenuItem] @@ -57,7 +57,7 @@ MtMoonPokecenterText4: ; 492ec (12:52ec) ld c, $3 predef SubBCDPredef ld a, $13 - ld [wd125], a + ld [wTextBoxID], a call DisplayTextBoxID ld hl, wd7c6 set 7, [hl] diff --git a/scripts/museum1f.asm b/scripts/museum1f.asm index cbb3bb6709..cd2b3c29e0 100755 --- a/scripts/museum1f.asm +++ b/scripts/museum1f.asm @@ -70,7 +70,7 @@ Museum1FText1: ; 5c135 (17:4135) jp asm_d1145 .asm_3ded4 ld a, $13 - ld [wd125], a + ld [wTextBoxID], a call DisplayTextBoxID xor a ld [hJoyHeld], a @@ -105,7 +105,7 @@ Museum1FText1: ; 5c135 (17:4135) ld c, $3 predef SubBCDPredef ld a, $13 - ld [wd125], a + ld [wTextBoxID], a call DisplayTextBoxID ld a, (SFX_02_5a - SFX_Headers_02) / 3 call PlaySoundWaitForCurrent diff --git a/scripts/pewterpokecenter.asm b/scripts/pewterpokecenter.asm index 2f4fd7afae..1f3cabe0d0 100755 --- a/scripts/pewterpokecenter.asm +++ b/scripts/pewterpokecenter.asm @@ -1,5 +1,5 @@ PewterPokecenterScript: ; 5c587 (17:4587) - call Func_22fa + call Serial_TryEstablishingExternallyClockedConnection jp EnableAutoTextBoxDrawing PewterPokecenterTextPointers: ; 5c58d (17:458d) diff --git a/scripts/rocktunnelpokecenter.asm b/scripts/rocktunnelpokecenter.asm index 62336edcae..5e822bca8e 100755 --- a/scripts/rocktunnelpokecenter.asm +++ b/scripts/rocktunnelpokecenter.asm @@ -1,5 +1,5 @@ RockTunnelPokecenterScript: ; 493ba (12:53ba) - call Func_22fa + call Serial_TryEstablishingExternallyClockedConnection jp EnableAutoTextBoxDrawing RockTunnelPokecenterTextPointers: ; 493c0 (12:53c0) diff --git a/scripts/route11gateupstairs.asm b/scripts/route11gateupstairs.asm index 8b75668145..d87409867f 100755 --- a/scripts/route11gateupstairs.asm +++ b/scripts/route11gateupstairs.asm @@ -11,7 +11,7 @@ Route11GateUpstairsText1: ; 4945f (12:545f) db $08 ; asm xor a ld [wWhichTrade], a - predef Predef54 + predef DoInGameTradeDialogue asm_49469: ; 49469 (12:5469) jp TextScriptEnd diff --git a/scripts/route18gateupstairs.asm b/scripts/route18gateupstairs.asm index 7ef0461dd0..aaa1b34ea3 100755 --- a/scripts/route18gateupstairs.asm +++ b/scripts/route18gateupstairs.asm @@ -10,7 +10,7 @@ Route18GateUpstairsText1: ; 4997e (12:597e) db $08 ; asm ld a, $5 ld [wWhichTrade], a - predef Predef54 + predef DoInGameTradeDialogue jp TextScriptEnd Route18GateUpstairsText2: ; 4998c (12:598c) diff --git a/scripts/route2house.asm b/scripts/route2house.asm index e9b30b0712..ba13605bef 100755 --- a/scripts/route2house.asm +++ b/scripts/route2house.asm @@ -13,5 +13,5 @@ Route2HouseText2: ; 1def9 (7:5ef9) db $08 ; asm ld a, $1 ld [wWhichTrade], a - predef Predef54 + predef DoInGameTradeDialogue jp TextScriptEnd diff --git a/scripts/safarizoneentrance-yellow.asm b/scripts/safarizoneentrance-yellow.asm index 1f1b6c23a9..c43430953b 100644 --- a/scripts/safarizoneentrance-yellow.asm +++ b/scripts/safarizoneentrance-yellow.asm @@ -2,7 +2,7 @@ ld hl,.ForJust500Text call PrintText ld a,$13 - ld [wd125],a + ld [wTextBoxID],a call DisplayTextBoxID call YesNoChoice ld a,[wCurrentMenuItem] @@ -49,7 +49,7 @@ call $3736 call $373e ld a,$13 - ld [wd125],a + ld [wTextBoxID],a call DisplayTextBoxID ld hl,.MakePaymentText call PrintText diff --git a/scripts/safarizoneentrance.asm b/scripts/safarizoneentrance.asm index e5653ff1b8..294dcf58b5 100755 --- a/scripts/safarizoneentrance.asm +++ b/scripts/safarizoneentrance.asm @@ -148,7 +148,7 @@ SafariZoneEntranceTextPointers: ; 752b9 (1d:52b9) TX_FAR SafariZoneEntranceText_9e6e4 ; 0x9e6e4 db $8 ld a, $13 - ld [wd125],a + ld [wTextBoxID],a call DisplayTextBoxID call YesNoChoice ld a,[wCurrentMenuItem] @@ -178,7 +178,7 @@ SafariZoneEntranceTextPointers: ; 752b9 (1d:52b9) ld c,3 predef SubBCDPredef ld a,$13 - ld [wd125],a + ld [wTextBoxID],a call DisplayTextBoxID ld hl,.MakePaymentText call PrintText diff --git a/scripts/saffronpokecenter.asm b/scripts/saffronpokecenter.asm index 7f3a656ad6..8f569a8ea1 100755 --- a/scripts/saffronpokecenter.asm +++ b/scripts/saffronpokecenter.asm @@ -1,5 +1,5 @@ SaffronPokecenterScript: ; 5d535 (17:5535) - call Func_22fa + call Serial_TryEstablishingExternallyClockedConnection jp EnableAutoTextBoxDrawing SaffronPokecenterTextPointers: ; 5d53b (17:553b) diff --git a/scripts/undergroundpathentranceroute5.asm b/scripts/undergroundpathentranceroute5.asm index dc1748f2a7..03f1c35dc7 100755 --- a/scripts/undergroundpathentranceroute5.asm +++ b/scripts/undergroundpathentranceroute5.asm @@ -13,6 +13,6 @@ UndergroundPathEntranceRoute5Text1: ; 5d6b2 (17:56b2) db $08 ; asm ld a, $9 ld [wWhichTrade], a - predef Predef54 + predef DoInGameTradeDialogue ld hl, UndergroundPathEntranceRoute5_5d6af ret diff --git a/scripts/vermilionhouse3.asm b/scripts/vermilionhouse3.asm index af9d2430bd..08e2e39581 100755 --- a/scripts/vermilionhouse3.asm +++ b/scripts/vermilionhouse3.asm @@ -8,5 +8,5 @@ VermilionHouse3Text1: ; 19c17 (6:5c17) db $08 ; asm ld a, $4 ld [wWhichTrade], a - predef Predef54 + predef DoInGameTradeDialogue jp TextScriptEnd diff --git a/scripts/vermilionpokecenter.asm b/scripts/vermilionpokecenter.asm index 00d139f5b1..6e85b3e3c1 100755 --- a/scripts/vermilionpokecenter.asm +++ b/scripts/vermilionpokecenter.asm @@ -1,5 +1,5 @@ VermilionPokecenterScript: ; 5c98f (17:498f) - call Func_22fa + call Serial_TryEstablishingExternallyClockedConnection jp EnableAutoTextBoxDrawing VermilionPokecenterTextPointers: ; 5c995 (17:4995) diff --git a/scripts/viridianpokecenter.asm b/scripts/viridianpokecenter.asm index 08371ce353..ae5e32c84e 100755 --- a/scripts/viridianpokecenter.asm +++ b/scripts/viridianpokecenter.asm @@ -1,5 +1,5 @@ ViridianPokeCenterScript: ; 4425d (11:425d) - call Func_22fa + call Serial_TryEstablishingExternallyClockedConnection jp EnableAutoTextBoxDrawing ViridianPokecenterTextPointers: ; 44263 (11:4263) diff --git a/text.asm b/text.asm index 1e4e1c49fd..7eac7b5a7f 100644 --- a/text.asm +++ b/text.asm @@ -1231,7 +1231,7 @@ _NoMovesLeftText:: ; 89892 (22:5892) _MultiHitText:: ; 898aa (22:58aa) text "Hit the enemy" line "@" - TX_NUM W_NUMHITS,1,1 + TX_NUM wPlayerNumHits,1,1 text " times!" prompt @@ -1450,7 +1450,7 @@ _MirrorMoveFailedText:: ; 89b96 (22:5b96) _HitXTimesText:: ; 89baf (22:5baf) text "Hit @" - TX_NUM wcd05, 1, 1 + TX_NUM wEnemyNumHits, 1, 1 text " times!" prompt @@ -1973,7 +1973,7 @@ _HisNameIsText:: ; 8a64a (22:664a) prompt _WillBeTradedText:: ; 8a677 (22:6677) - TX_RAM wTrainerFacingDirection + TX_RAM wNameOfPlayerMonToBeTraded text " and" line "@" TX_RAM wcd6d @@ -2787,19 +2787,19 @@ _PokemonCenterFarewellText:: ; a2910 (28:6910) line "you again!" done -_CableClubNPCText7:: ; a292b (28:692b) +_CableClubNPCAreaReservedFor2FriendsLinkedByCableText:: ; a292b (28:692b) text "This area is" line "reserved for 2" cont "friends who are" cont "linked by cable." done -_CableClubNPCText1:: ; a2969 (28:6969) +_CableClubNPCWelcomeText:: ; a2969 (28:6969) text "Welcome to the" line "Cable Club!" done -_CableClubNPCText2:: ; a2985 (28:6985) +_CableClubNPCPleaseApplyHereHaveToSaveText:: ; a2985 (28:6985) text "Please apply here." para "Before opening" @@ -2807,10 +2807,10 @@ _CableClubNPCText2:: ; a2985 (28:6985) cont "to save the game." done -_CableClubNPCText3:: ; a29cc (28:69cc) +_CableClubNPCPleaseWaitText:: ; a29cc (28:69cc) text "Please wait.@@" -_CableClubNPCText4:: ; a29db (28:69db) +_CableClubNPCLinkClosedBecauseOfInactivityText:: ; a29db (28:69db) text "The link has been" line "closed because of" cont "inactivity." @@ -2823,11 +2823,11 @@ _CableClubNPCText4:: ; a29db (28:69db) SECTION "Text 10", ROMX, BANK[TEXT_10] -_CableClubNPCText5:: ; a4000 (29:4000) +_CableClubNPCPleaseComeAgainText:: ; a4000 (29:4000) text "Please come again!" done -_CableClubNPCText6:: ; a4014 (29:4014) +_CableClubNPCMakingPreparationsText:: ; a4014 (29:4014) text "We're making" line "preparations." cont "Please wait." @@ -3229,21 +3229,21 @@ _ConnectCableText:: ; a809a (2a:409a) _TradedForText:: ; a80bc (2a:40bc) text $52, " traded" line "@" - TX_RAM wcd13 + TX_RAM wInGameTradeGiveMonName text " for" cont "@" - TX_RAM wPlayerMonAccuracyMod + TX_RAM wInGameTradeReceiveMonName text "!@@" _WannaTrade1Text:: ; a80d8 (2a:40d8) text "I'm looking for" line "@" - TX_RAM wcd13 + TX_RAM wInGameTradeGiveMonName text "! Wanna" para "trade one for" line "@" - TX_RAM wPlayerMonAccuracyMod + TX_RAM wInGameTradeReceiveMonName text "? " done @@ -3255,7 +3255,7 @@ _NoTrade1Text:: ; a810b (2a:410b) _WrongMon1Text:: ; a811d (2a:411d) text "What? That's not" line "@" - TX_RAM wcd13 + TX_RAM wInGameTradeGiveMonName text "!" para "If you get one," @@ -3269,7 +3269,7 @@ _Thanks1Text:: ; a8155 (2a:4155) _AfterTrade1Text:: ; a8162 (2a:4162) text "Isn't my old" line "@" - TX_RAM wPlayerMonAccuracyMod + TX_RAM wInGameTradeReceiveMonName text " great?" done @@ -3278,10 +3278,10 @@ _WannaTrade2Text:: ; a817c (2a:417c) line "you want to trade" para "your @" - TX_RAM wcd13 + TX_RAM wInGameTradeGiveMonName db $0 line "for @" - TX_RAM wPlayerMonAccuracyMod + TX_RAM wInGameTradeReceiveMonName text "?" done @@ -3293,7 +3293,7 @@ _NoTrade2Text:: ; a81b5 (2a:41b5) _WrongMon2Text:: ; a81d3 (2a:41d3) text "Hmmm? This isn't" line "@" - TX_RAM wcd13 + TX_RAM wInGameTradeGiveMonName text "." para "Think of me when" @@ -3313,7 +3313,7 @@ IF DEF(_YELLOW) cont "magnificent!" ELSE text "The @" - TX_RAM wcd13 + TX_RAM wInGameTradeGiveMonName text " you" line "traded to me" @@ -3324,12 +3324,12 @@ ENDC _WannaTrade3Text:: ; a8240 (2a:4240) text "Hi! Do you have" line "@" - TX_RAM wcd13 + TX_RAM wInGameTradeGiveMonName text "?" para "Want to trade it" line "for @" - TX_RAM wPlayerMonAccuracyMod + TX_RAM wInGameTradeReceiveMonName text "?" done @@ -3340,7 +3340,7 @@ _NoTrade3Text:: ; a8274 (2a:4274) _WrongMon3Text:: ; a8284 (2a:4284) text "...This is no" line "@" - TX_RAM wcd13 + TX_RAM wInGameTradeGiveMonName text "." para "If you get one," @@ -3358,11 +3358,11 @@ ENDC _AfterTrade3Text:: ; a82c9 (2a:42c9) text "How is my old" line "@" - TX_RAM wPlayerMonAccuracyMod + TX_RAM wInGameTradeReceiveMonName text "?" para "My @" - TX_RAM wcd13 + TX_RAM wInGameTradeGiveMonName text " is" line "doing great!" done diff --git a/wram.asm b/wram.asm index 6a7e2763c7..d0bc78aef9 100755 --- a/wram.asm +++ b/wram.asm @@ -183,12 +183,21 @@ wTileMap:: ; c3a0 ; buffer for tiles that are visible on screen (20 columns by 18 rows) ds 20 * 18 +wSerialPartyMonsPatchList:: ; c508 +; list of indexes to patch with SERIAL_NO_DATA_BYTE after transfer + wTileMapBackup:: ; c508 ; buffer for temporarily saving and restoring current screen's tiles ; (e.g. if menus are drawn on top) - ds 20 * 18 +; ds 20 * 18 + + ds 200 - ds 120 +wSerialEnemyMonsPatchList:: ; c5d0 +; list of indexes to patch with SERIAL_NO_DATA_BYTE after transfer + ds 200 + + ds 80 wTempPic:: wOverworldMap:: ; c6e8 @@ -257,7 +266,12 @@ wListScrollOffset:: ; cc36 ds 1 wcc37:: ds 1 -wcc38:: ds 2 + +wTradeCenterPointerTableIndex:: ; cc38 + ds 1 + + ds 1 + wcc3a:: ds 1 wcc3b:: ds 1 @@ -265,12 +279,46 @@ wDoNotWaitForButtonPressAfterDisplayingText:: ; cc3c ; if non-zero, skip waiting for a button press after displaying text in DisplayTextID ds 1 +wSerialSyncAndExchangeNybbleReceiveData:: ; cc3d +; the final received nybble is stored here by Serial_SyncAndExchangeNybble + +wSerialExchangeNybbleTempReceiveData:: ; cc3d +; temporary nybble used by Serial_ExchangeNybble + +wLinkMenuSelectionReceiveBuffer:: ; cc3d +; two byte buffer +; the received menu selection is stored twice + wcc3d:: ds 1 -wcc3e:: ds 4 -wcc42:: ds 1 -wcc43:: ds 4 + +wSerialExchangeNybbleReceiveData:: ; cc3e +; the final received nybble is stored here by Serial_ExchangeNybble + ds 1 + + ds 3 + +wSerialExchangeNybbleSendData:: ; cc42 +; this nybble is sent when using Serial_SyncAndExchangeNybble or Serial_ExchangeNybble + +wLinkMenuSelectionSendBuffer:: ; cc42 +; two byte buffer +; the menu selection byte is stored twice before sending + + ds 5 + +wLinkTimeoutCounter:: ; cc47 +; 1 byte + +wUnknownSerialCounter:: ; cc47 +; 2 bytes + wcc47:: ds 1 wcc48:: ds 1 + +wWhichTradeMonSelectionMenu:: ; cc49 +; $00 = player mons +; $01 = enemy mons + wcc49:: ds 1 wMenuWrappingEnabled:: ; cc4a @@ -348,7 +396,7 @@ wPlayerSelectedMove:: ; ccdc wEnemySelectedMove:: ; ccdd ds 1 -wLinkBattleRNCount:: ; ccde +wLinkBattleRandomNumberListIndex:: ; ccde ds 1 wAICount:: ; ccdf @@ -391,24 +439,32 @@ wPartyFoughtCurrentEnemyFlags:: wccf6:: ds 1 wccf7:: ds 14 -wcd05:: ds 1 -wcd06:: ds 9 -wPlayerMonUnmodifiedLevel:: ; cd0f - ds 0 -wcd0f:: ; overload, used in in-game trade code +wUnknownSlotVar:: ; cd05 + +wEnemyNumHits:: ; cd05 +; number of hits by enemy in attacks like Double Slap, etc. + +wEnemyBideAccumulatedDamage:: ; cd05 +; the amount of damage accumulated by the enemy while biding (2 bytes) + +ds 10 + +wInGameTradeGiveMonSpecies:: ; cd0f + +wPlayerMonUnmodifiedLevel:: ; cd0f ds 1 + +wInGameTradeTextPointerTablePointer:: ; cd10 + wPlayerMonUnmodifiedMaxHP:: ; cd10 - ds 0 -wcd10:: ; overload, used in in-game trade code - ds 1 -wcd11:: ; overload, used in in-game trade code - ds 1 + ds 2 + +wInGameTradeTextPointerTableIndex:: ; cd12 + wPlayerMonUnmodifiedAttack:: ; cd12 - ds 0 -wcd12:: ; overload, used in in-game trade code ds 1 -wcd13:: ; overload, used in in-game trade code (to store name string) +wInGameTradeGiveMonName:: ; cd13 ds 1 wPlayerMonUnmodifiedDefense:: ; cd14 ds 2 @@ -430,6 +486,9 @@ wPlayerMonSpeedMod:: ; cd1c ds 1 wPlayerMonSpecialMod:: ; cd1d ds 1 + +wInGameTradeReceiveMonName:: ; cd1e + wPlayerMonAccuracyMod:: ; cd1e ds 1 wPlayerMonEvasionMod:: ; cd1f @@ -445,8 +504,10 @@ wEnemyMonUnmodifiedAttack:: ; cd26 ds 2 wEnemyMonUnmodifiedDefense:: ; cd28 ds 1 -wcd29:: ; overload, used in in-game trade code + +wInGameTradeMonNick:: ; cd29 ds 1 + wEnemyMonUnmodifiedSpeed:: ; cd2a ds 2 wEnemyMonUnmodifiedSpecial:: ; cd2c @@ -475,7 +536,10 @@ wEnemyMonAccuracyMod:: ; cd32 wEnemyMonEvasionMod:: ; cd33 ds 1 -wcd34:: ds 3 +wInGameTradeReceiveMonSpecies:: + ds 1 + + ds 2 wNPCMovementDirections2Index:: ; cd37 @@ -501,6 +565,10 @@ wOverrideSimulatedJoypadStatesMask:: ; cd3b ds 1 +wTradedPlayerMonSpecies:: ; cd3d + +wTradingWhichPlayerMon:: ; cd3d + wChangeBoxSavedMapTextPointer:: ; cd3d wFlyAnimUsingCoordList:: ; cd3d @@ -520,6 +588,10 @@ wWhichTrade:: ; cd3d wTrainerSpriteOffset:: ; cd3d ds 1 +wTradedEnemyMonSpecies:: ; cd3e + +wTradingWhichEnemyMon:: ; cd3e + wFlyAnimCounter:: ; cd3e wPlayerSpinInPlaceAnimFrameDelayDelta:: ; cd3e @@ -531,6 +603,8 @@ wHiddenObjectFunctionRomBank:: ; cd3e wTrainerEngageDistance:: ; cd3e ds 1 +wNameOfPlayerMonToBeTraded:: ; cd3f + wFlyAnimBirdSpriteImageIndex:: ; cd3f wPlayerSpinInPlaceAnimFrameDelayEndValue:: ; cd3f @@ -550,7 +624,9 @@ wHiddenObjectY:: ; cd40 wTrainerScreenY:: ; cd40 ds 1 -wHiddenObjectX:: ; cd40 +wTradedPlayerMonOT:: ; cd41 + +wHiddenObjectX:: ; cd41 wTrainerScreenX:: ; cd41 ds 1 @@ -565,13 +641,21 @@ wcd48:: ds 1 wcd49:: ds 1 wcd4a:: ds 1 wcd4b:: ds 1 + +wTradedPlayerMonOTID:: ; cd4c + wcd4c:: ds 1 wcd4d:: ds 1 + +wTradedEnemyMonOT:: ; cd4e + wcd4e:: ds 1 wcd4f:: ds 1 wcd50:: ds 9 -wcd59:: ds 1 -wcd5a:: ds 1 + +wTradedEnemyMonOTID:: ; cd59 + ds 2 + wcd5b:: ds 1 wcd5c:: ds 1 wcd5d:: ds 1 @@ -581,6 +665,7 @@ wcd5f:: ds 1 wFlags_0xcd60:: ; cd60 ; bit 0: is player engaged by trainer (to avoid being engaged by multiple trainers simultaneously) ; bit 1: boulder dust animation (from using Strength) pending +; bit 5: don't play sound when A or B is pressed in menu ; bit 6: tried pushing against boulder once (you need to push twice before it will move) ds 1 @@ -599,6 +684,9 @@ wcd72:: ds 5 wcd77:: ds 1 wcd78:: ds 9 +wSerialOtherGameboyRandomNumberListBlock:: ; cd81 +; buffer for transferring the random number list generated by the other gameboy + wTileMapBackup2:: ; cd81 ; second buffer for temporarily saving and restoring current screen's tiles (e.g. if menus are drawn on top) ds 20 * 18 @@ -960,11 +1048,16 @@ W_ENEMYDISABLEDMOVE:: ; d072 ds 1 -W_NUMHITS:: ; d074 -; number of hits in attacks like Doubleslap, etc. - ds 1 +wPlayerNumHits:: ; d074 +; number of hits by player in attacks like Double Slap, etc. + +wPlayerBideAccumulatedDamage:: ; d074 +; the amount of damage accumulated by the player while biding (2 bytes) + +wUnknownSerialCounter2:: ; d075 +; 2 bytes -wd075:: ds 3 +ds 4 wEscapedFromBattle:: ; non-zero when an item or move that allows escape from battle was used @@ -1205,7 +1298,10 @@ wNumRunAttempts:: wd121:: ds 1 wd122:: ds 2 wd124:: ds 1 -wd125:: ds 1 + +wTextBoxID:: ; d125 + ds 1 + wd126:: ds 1 W_CURENEMYLVL:: ; d127 @@ -1215,10 +1311,10 @@ wd128:: ds 1 wd129:: ds 1 wd12a:: ds 1 -W_ISLINKBATTLE:: ; d12b +wLinkState:: ; d12b ds 1 -wd12c:: ds 1 +wTwoOptionMenuID:: ds 1 wd12d:: ds 1 wd12e:: ds 1 wd12f:: ds 1 @@ -1250,10 +1346,20 @@ W_PRIZE3:: ; d13f ds 1 +wSerialRandomNumberListBlock:: ; d141 +; the first 7 bytes are the preamble + wd141:: ds 2 wd143:: ds 2 wd145:: ds 3 -wd148:: ds 10 + +wLinkBattleRandomNumberList:: ; d148 +; shared list of 9 random numbers, indexed by wLinkBattleRandomNumberListIndex + ds 10 + +wSerialPlayerDataBlock:: ; d152 +; the first 6 bytes are the preamble + wd152:: ds 1 wd153:: ds 3 wd156:: ds 1 @@ -1886,7 +1992,11 @@ wd736:: ; d736 ; bit 6: jumping down a ledge ds 1 -wd737:: ds 4 +wCompletedInGameTradeFlags:: ; d737 + ds 2 + + ds 2 + wd73b:: ds 1 wd73c:: ds 3 @@ -1902,7 +2012,16 @@ wd743:: ds 1 wd744:: ds 3 wd747:: ds 3 wd74a:: ds 1 -wd74b:: ds 1 + +wd74b:: ; d74b +; bit 0: Prof. Oak has lead the player to the north end of his lab +; bit 1: Prof. Oak has asked the player to choose a pokemon +; bit 2: the player and the rival have received their pokemon +; bit 3: the player has battled the rival in Oak's lab +; bit 4: Prof. Oak has given the player 5 pokeballs +; bit 5: received pokedex + ds 1 + wd74c:: ds 2 wd74e:: ds 3 wd751:: ds 1 @@ -2028,6 +2147,9 @@ wd880:: ds 1 wd881:: ds 1 wd882:: ds 5 +wLinkEnemyTrainerName:: ; d887 +; linked game's trainer name + W_GRASSRATE:: ; d887 ds 1 From 507fcbd26979cb79fcb9b75a18b85f4c20487a63 Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Sat, 7 Feb 2015 03:04:50 -0800 Subject: [PATCH 087/100] Fix typo in name --- engine/cable_club.asm | 10 +++++----- home/serial.asm | 3 +-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/engine/cable_club.asm b/engine/cable_club.asm index 4390069469..f1278c83d5 100755 --- a/engine/cable_club.asm +++ b/engine/cable_club.asm @@ -523,7 +523,7 @@ TradeCenter_SelectMon: ld [wCurrentMenuItem], a ld [wTradingWhichPlayerMon], a ld [wSerialExchangeNybbleSendData], a - call Serial_PrintWaitingTextAndSyncAndExchangeByte + call Serial_PrintWaitingTextAndSyncAndExchangeNybble ld a, [wSerialSyncAndExchangeNybbleReceiveData] cp $f jp z, CallCurrentTradeCenterFunction ; go back to the beginning of the trade selection menu if the other person cancelled @@ -570,7 +570,7 @@ TradeCenter_SelectMon: Coorda 1, 16 ld a, $f ld [wSerialExchangeNybbleSendData], a - call Serial_PrintWaitingTextAndSyncAndExchangeByte + call Serial_PrintWaitingTextAndSyncAndExchangeNybble ld a, [wSerialSyncAndExchangeNybbleReceiveData] cp $f ; did the other person choose Cancel too? jr nz, .cancelMenuItem_Loop @@ -733,12 +733,12 @@ TradeCenter_Trade: hlCoord 1, 14 ld de, TradeCanceled call PlaceString - call Serial_PrintWaitingTextAndSyncAndExchangeByte + call Serial_PrintWaitingTextAndSyncAndExchangeNybble jp .tradeCancelled .tradeConfirmed ld a, $2 ld [wSerialExchangeNybbleSendData], a - call Serial_PrintWaitingTextAndSyncAndExchangeByte + call Serial_PrintWaitingTextAndSyncAndExchangeNybble ld a, [wSerialSyncAndExchangeNybbleReceiveData] dec a ; did the other person cancel? jr nz, .doTrade @@ -848,7 +848,7 @@ TradeCenter_Trade: callab TryEvolvingMon call ClearScreen call LoadTrainerInfoTextBoxTiles - call Serial_PrintWaitingTextAndSyncAndExchangeByte + call Serial_PrintWaitingTextAndSyncAndExchangeNybble ld c, 40 call DelayFrames hlCoord 0, 12 diff --git a/home/serial.asm b/home/serial.asm index fa3d4c8aec..86d7404042 100644 --- a/home/serial.asm +++ b/home/serial.asm @@ -223,7 +223,7 @@ Serial_ExchangeLinkMenuSelection:: ; 2247 (0:2247) jr nz, .loop ret -Serial_PrintWaitingTextAndSyncAndExchangeByte:: ; 226e (0:226e) +Serial_PrintWaitingTextAndSyncAndExchangeNybble:: ; 226e (0:226e) call SaveScreenTilesToBuffer1 callab PrintWaitingText call Serial_SyncAndExchangeNybble @@ -269,7 +269,6 @@ Serial_SyncAndExchangeNybble:: ; 227f (0:227f) ld [wSerialSyncAndExchangeNybbleReceiveData], a ret -; exchange one byte with value of $f or less Serial_ExchangeNybble:: ; 22c3 (0:22c3) call .doExchange ld a, [wSerialExchangeNybbleSendData] From c9b778fb008ebc845219a2b787ea6beb04ae29f8 Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Sat, 7 Feb 2015 04:23:34 -0800 Subject: [PATCH 088/100] documented bide bug --- engine/battle/core.asm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 0c506e2bc8..64a8d44eb4 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -1096,7 +1096,9 @@ RemoveFaintedPlayerMon: ; 3c741 (f:4741) ld [wd083], a call WaitForSoundToFinish .skipWaitForSound - ld hl, wEnemyNumHits +; bug? if the player mon faints while the enemy mon is using bide, +; the accumulated damage is overwritten. xxx what values can [wd083] have here? + ld hl, wEnemyBideAccumulatedDamage ld [hli], a ld [hl], a ld [wBattleMonStatus], a From 451f7fce291cf038240f7b5cd4ce404b8222b6c7 Mon Sep 17 00:00:00 2001 From: yenatch Date: Sat, 7 Feb 2015 11:16:00 -0800 Subject: [PATCH 089/100] Pick off some more static map ids. --- data/super_rod.asm | 15 +++++++-------- engine/hidden_object_functions7.asm | 2 +- scripts/pokemontower7.asm | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/data/super_rod.asm b/data/super_rod.asm index ead970d836..2b0646fcf8 100755 --- a/data/super_rod.asm +++ b/data/super_rod.asm @@ -25,16 +25,15 @@ SuperRodData: ; e919 (3:6919) dbw ROUTE_25, FishingGroup3 dbw CERULEAN_GYM, FishingGroup3 dbw VERMILION_DOCK, FishingGroup4 -;XXX syntax errors on the rest? - dbw $A1, FishingGroup8 ; SEAFOAM_ISLANDS_4 - dbw $A2, FishingGroup8 ; SEAFOAM_ISLANDS_5 + dbw SEAFOAM_ISLANDS_4, FishingGroup8 + dbw SEAFOAM_ISLANDS_5, FishingGroup8 dbw SAFARI_ZONE_EAST, FishingGroup6 - dbw $DA, FishingGroup6 ; SAFARI_ZONE_NORTH + dbw SAFARI_ZONE_NORTH, FishingGroup6 dbw SAFARI_ZONE_WEST, FishingGroup6 - dbw $DC, FishingGroup6 ; SAFARI_ZONE_CENTER - dbw $E2, FishingGroup9 ; UNKNOWN_DUNGEON_2 - dbw $E3, FishingGroup9 ; UNKNOWN_DUNGEON_3 - dbw $E4, FishingGroup9 ; UNKNOWN_DUNGEON_1 + dbw SAFARI_ZONE_CENTER, FishingGroup6 + dbw UNKNOWN_DUNGEON_2, FishingGroup9 + dbw UNKNOWN_DUNGEON_3, FishingGroup9 + dbw UNKNOWN_DUNGEON_1, FishingGroup9 db $FF ; fishing groups diff --git a/engine/hidden_object_functions7.asm b/engine/hidden_object_functions7.asm index 012e941d92..f97190defd 100755 --- a/engine/hidden_object_functions7.asm +++ b/engine/hidden_object_functions7.asm @@ -80,7 +80,7 @@ asm_1e9b0: ; 1e9b0 (7:69b0) call DisplayTextID xor a ld [wd528], a - ld a, $9c + ld a, SAFARI_ZONE_ENTRANCE ld [H_DOWNARROWBLINKCNT1], a ; $ff8b ld a, $3 ld [wDestinationWarpID], a diff --git a/scripts/pokemontower7.asm b/scripts/pokemontower7.asm index 4d1012b71b..ab42121d88 100755 --- a/scripts/pokemontower7.asm +++ b/scripts/pokemontower7.asm @@ -71,7 +71,7 @@ PokemonTower7Script4: ; 60d86 (18:4d86) predef HideObject ld a, $4 ld [wSpriteStateData1 + 9], a - ld a, $95 + ld a, LAVENDER_HOUSE_1 ld [H_DOWNARROWBLINKCNT1], a ; $ff8b ld a, $1 ld [wDestinationWarpID], a From f94af3e2d6effcaf94c8912a17542b99c1e7e9f8 Mon Sep 17 00:00:00 2001 From: yenatch Date: Sat, 7 Feb 2015 11:20:25 -0800 Subject: [PATCH 090/100] INSTALL: git clone --recursive --- INSTALL.md | 56 +++++++++++++++++++----------------------------------- 1 file changed, 20 insertions(+), 36 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 124e9408f9..11450d93d4 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -1,73 +1,57 @@ # Linux -Dependencies: - sudo apt-get install make gcc bison git python python-setuptools - sudo easy_install pip - -The assembler used is [**rgbds**](https://github.com/bentley/rgbds). + sudo easy_install pypng git clone git://github.com/bentley/rgbds.git cd rgbds - sudo mkdir -p /usr/local/man/man{1,7} sudo make install cd .. - rm -rf rgbds - -Set up the repository. - git clone git://github.com/iimarckus/pokered.git + git clone --recursive git://github.com/iimarckus/pokered.git cd pokered - git submodule init - git submodule update - sudo pip install -r extras/requirements.txt To build **pokered.gbc** and **pokeblue.gbc**: make -This should take about 10 seconds. Subsequent builds are faster. - To build them individually: make red make blue -# OS X +# Mac In the shell, run: xcode-select --install + sudo easy_install pypng -Then follow the Linux instructions. + git clone git://github.com/bentley/rgbds.git + cd rgbds + sudo make install + cd .. + git clone --recursive git://github.com/iimarckus/pokered.git + cd pokered -# Windows + make -It's recommended that you use a virtual machine running Linux or OS X. -If you insist on Windows, use [**Cygwin**](http://cygwin.com/install.html) (32-bit). +# Windows -Dependencies are downloaded in the installer rather than the command line. -Select the following packages: -* make -* git -* gettext -* python -* python-setuptools +To build on Windows, use [**Cygwin**](http://cygwin.com/install.html) (32-bit). -The latest version of **rgbds** is [**0.2.2**](https://github.com/bentley/rgbds/releases/download/v0.2.2/rgbds-0.2.2-win32.zip). To install, put `rgbasm.exe`, `rgblink.exe` and `rgbfix.exe` in `C:\cygwin\usr\local\bin`. +In the installer, select the following packages: `make` `git` `gettext` `python` `python-setuptools` -Then set up the repository. In the **Cygwin terminal**: +Then get the most recent version of [**rgbds**](https://github.com/bentley/rgbds/releases/). +Put `rgbasm.exe`, `rgblink.exe` and `rgbfix.exe` in `C:\cygwin\usr\local\bin`. - git clone git://github.com/iimarckus/pokered.git - cd pokered - git submodule init - git submodule update - easy_install pypng +In the **Cygwin terminal**: -To build: + easy_install pypng + git clone --recursive git://github.com/iimarckus/pokered.git + cd pokered make - From b35294752c55b5df88ccfc785279c36f30a43fd6 Mon Sep 17 00:00:00 2001 From: yenatch Date: Fri, 23 Jan 2015 09:48:14 -0800 Subject: [PATCH 091/100] rename hJoyHeldLast -> hJoyLast --- engine/joypad.asm | 20 +++++++++++++++----- engine/palettes.asm | 7 +++---- hram.asm | 2 +- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/engine/joypad.asm b/engine/joypad.asm index d2ad1c3191..31e197e294 100644 --- a/engine/joypad.asm +++ b/engine/joypad.asm @@ -1,9 +1,13 @@ _Joypad:: +; hJoyReleased: (hJoyLast ^ hJoyInput) & hJoyLast +; hJoyPressed: (hJoyLast ^ hJoyInput) & hJoyInput + ld a, [hJoyInput] cp A_BUTTON + B_BUTTON + SELECT + START ; soft reset jp z, TrySoftReset + ld b, a - ld a, [hJoyHeldLast] + ld a, [hJoyLast] ld e, a xor b ld d, a @@ -13,15 +17,19 @@ _Joypad:: and b ld [hJoyPressed], a ld a, b - ld [hJoyHeldLast], a + ld [hJoyLast], a + ld a, [wd730] bit 5, a jr nz, DiscardButtonPresses - ld a, [hJoyHeldLast] + + ld a, [hJoyLast] ld [hJoyHeld], a + ld a, [wJoyIgnore] and a ret z + cpl ld b, a ld a, [hJoyHeld] @@ -41,11 +49,13 @@ DiscardButtonPresses: TrySoftReset: call DelayFrame - ; reset joypad (to make sure the - ; player is really trying to reset) + + ; deselect (redundant) ld a, $30 ld [rJOYP], a + ld hl, hSoftReset dec [hl] jp z, SoftReset + jp Joypad diff --git a/engine/palettes.asm b/engine/palettes.asm index 67afc12d77..ed06cf4e40 100755 --- a/engine/palettes.asm +++ b/engine/palettes.asm @@ -381,7 +381,7 @@ SendSGBPacket: ; 71feb (1c:5feb) LoadSGB: ; 7202b (1c:602b) xor a ld [wOnSGB], a - call Func_7209b + call CheckSGB ret nc ld a, $1 ld [wOnSGB], a @@ -440,7 +440,7 @@ PointerTable_72089: ; 72089 (1c:6089) dw DataSnd_725a8 dw DataSnd_725b8 -Func_7209b: ; 7209b (1c:609b) +CheckSGB: ; 7209b (1c:609b) ld hl, MltReq2Packet di call SendSGBPacket @@ -536,8 +536,7 @@ Func_7210b: ; 7210b (1c:610b) ret Wait7000: ; 7214a (1c:614a) -; each loop takes about 10 cycles so this routine actually loops through 70000 -; cycles. +; Each loop takes 9 cycles so this routine actually waits 63000 cycles. ld de, 7000 .loop nop diff --git a/hram.asm b/hram.asm index dfe14d6613..0e6d91e4c1 100644 --- a/hram.asm +++ b/hram.asm @@ -58,7 +58,7 @@ hSCX EQU $FFAE hSCY EQU $FFAF hWY EQU $FFB0 -hJoyHeldLast EQU $FFB1 +hJoyLast EQU $FFB1 hJoyReleased EQU $FFB2 hJoyPressed EQU $FFB3 hJoyHeld EQU $FFB4 From 83023cda1927525d942f53f87a11b642b979ea96 Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Sat, 7 Feb 2015 12:27:36 -0800 Subject: [PATCH 092/100] commented menu stuff --- constants/misc_constants.asm | 20 +++++ engine/battle/core.asm | 12 +-- engine/cable_club.asm | 2 +- engine/clear_save.asm | 4 +- engine/hidden_object_functions17.asm | 2 +- engine/items/items.asm | 4 +- engine/learn_move.asm | 34 ++++----- engine/menu/naming_screen.asm | 80 +++++++++---------- engine/menu/start_sub_menus.asm | 6 +- engine/menu/vending_machine.asm | 20 ++--- engine/overworld/pokemart.asm | 14 ++-- engine/save.asm | 6 +- engine/slot_machine.asm | 2 +- home.asm | 10 +-- main.asm | 110 +++++++++++++-------------- 15 files changed, 173 insertions(+), 153 deletions(-) diff --git a/constants/misc_constants.asm b/constants/misc_constants.asm index fd80eab2a6..d2270b6c3c 100644 --- a/constants/misc_constants.asm +++ b/constants/misc_constants.asm @@ -28,6 +28,26 @@ NPC_MOVEMENT_UP EQU $40 NPC_MOVEMENT_LEFT EQU $80 NPC_MOVEMENT_RIGHT EQU $C0 +; text box IDs +MESSAGE_BOX EQU $01 +FIELD_MOVE_MON_MENU EQU $04 +JP_MOCHIMONO_MENU_TEMPLATE EQU $05 +USE_TOSS_MENU_TEMPLATE EQU $06 +JP_SAVE_MESSAGE_MENU_TEMPLATE EQU $08 +JP_SPEED_OPTIONS_MENU_TEMPLATE EQU $09 +BATTLE_MENU_TEMPLATE EQU $0b +SWITCH_STATS_CANCEL_MENU_TEMPLATE EQU $0c +LIST_MENU_BOX EQU $0d +BUY_SELL_QUIT_MENU_TEMPLATE EQU $0e +MONEY_BOX_TEMPLATE EQU $0f +MON_SPRITE_POPUP EQU $11 +JP_AH_MENU_TEMPLATE EQU $12 +MONEY_BOX EQU $13 +TWO_OPTION_MENU EQU $14 +BUY_SELL_QUIT_MENU EQU $15 +JP_POKEDEX_MENU_TEMPLATE EQU $1a +SAFARI_BATTLE_MENU_TEMPLATE EQU $1b + ; two option menu constants YES_NO_MENU EQU 0 NORTH_WEST_MENU EQU 1 diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 64a8d44eb4..c6cc5734b4 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -98,7 +98,7 @@ SpecialEffectsCont: ; 3c049 (f:4049) SlidePlayerAndEnemySilhouettesOnScreen: ; 3c04c (f:404c) call LoadPlayerBackPic - ld a, $1 ; the usual text box at the bottom of the screen + ld a, MESSAGE_BOX ; the usual text box at the bottom of the screen ld [wTextBoxID], a call DisplayTextBoxID hlCoord 1, 5 @@ -1137,7 +1137,7 @@ DoUseNextMonDialogue: ; 3c79b (f:479b) .displayYesNoBox hlCoord 13, 9 ld bc, $a0e - ld a, $14 ; yes/no text box + ld a, TWO_OPTION_MENU ld [wTextBoxID], a call DisplayTextBoxID ld a, [wd12e] @@ -1454,7 +1454,7 @@ EnemySendOutFirstMon: ; 3c92a (f:492a) call PrintText hlCoord 0, 7 ld bc,$0801 - ld a,$14 + ld a,TWO_OPTION_MENU ld [wTextBoxID],a call DisplayTextBoxID ld a,[wCurrentMenuItem] @@ -2080,9 +2080,9 @@ DisplayBattleMenu: ; 3ceb3 (f:4eb3) .nonstandardbattle ld a, [W_BATTLETYPE] cp $2 ; safari - ld a, $b ; safari menu id + ld a, BATTLE_MENU_TEMPLATE jr nz, .menuselected - ld a, $1b ; regular menu id + ld a, SAFARI_BATTLE_MENU_TEMPLATE .menuselected ld [wTextBoxID], a call DisplayTextBoxID @@ -2402,7 +2402,7 @@ PartyMenuOrRockOrRun: call GoBackToPartyMenu jr .checkIfPartyMonWasSelected .partyMonWasSelected - ld a, $c ; switch/stats/cancel menu + ld a, SWITCH_STATS_CANCEL_MENU_TEMPLATE ld [wTextBoxID], a call DisplayTextBoxID ld hl, wTopMenuItemY diff --git a/engine/cable_club.asm b/engine/cable_club.asm index f1278c83d5..92a4e33b7a 100755 --- a/engine/cable_club.asm +++ b/engine/cable_club.asm @@ -716,7 +716,7 @@ TradeCenter_Trade: ld bc, $080b ld a, TRADE_CANCEL_MENU ld [wTwoOptionMenuID], a - ld a, $14 + ld a, TWO_OPTION_MENU ld [wTextBoxID], a call DisplayTextBoxID call LoadScreenTilesFromBuffer1 diff --git a/engine/clear_save.asm b/engine/clear_save.asm index 8fde1f0caa..c11405316b 100755 --- a/engine/clear_save.asm +++ b/engine/clear_save.asm @@ -9,10 +9,10 @@ Func_1c98a: ; 1c98a (7:498a) ld bc, $80f ld a, NO_YES_MENU ld [wTwoOptionMenuID], a - ld a, $14 + ld a, TWO_OPTION_MENU ld [wTextBoxID], a call DisplayTextBoxID - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + ld a, [wCurrentMenuItem] and a jp z, Init callba Func_73b6a diff --git a/engine/hidden_object_functions17.asm b/engine/hidden_object_functions17.asm index e0e38a2af1..9dbcbf98e8 100755 --- a/engine/hidden_object_functions17.asm +++ b/engine/hidden_object_functions17.asm @@ -66,7 +66,7 @@ DisplayMonFrontSpriteInBox: ; 5dbd9 (17:5bd9) xor a ld [hWY], a call SaveScreenTilesToBuffer1 - ld a, $11 + ld a, MON_SPRITE_POPUP ld [wTextBoxID], a call DisplayTextBoxID call UpdateSprites diff --git a/engine/items/items.asm b/engine/items/items.asm index d8b7f9e317..05f77175cf 100755 --- a/engine/items/items.asm +++ b/engine/items/items.asm @@ -2097,7 +2097,7 @@ ItemUseTMHM: ; e479 (3:6479) call PrintText hlCoord 14, 7 ld bc,$080f - ld a,$14 + ld a,TWO_OPTION_MENU ld [wTextBoxID],a call DisplayTextBoxID ; yes/no menu ld a,[wCurrentMenuItem] @@ -2488,7 +2488,7 @@ TossItem_: ; e6f1 (3:66f1) call PrintText hlCoord 14, 7 ld bc,$080f - ld a,$14 + ld a,TWO_OPTION_MENU ld [wTextBoxID],a call DisplayTextBoxID ; yes/no menu ld a,[wd12e] diff --git a/engine/learn_move.asm b/engine/learn_move.asm index 5dab57480f..f96c1aeb18 100755 --- a/engine/learn_move.asm +++ b/engine/learn_move.asm @@ -1,7 +1,7 @@ LearnMove: ; 6e43 (1:6e43) call SaveScreenTilesToBuffer1 - ld a, [wWhichPokemon] ; wWhichPokemon - ld hl, wPartyMonNicks ; wPartyMonNicks + ld a, [wWhichPokemon] + ld hl, wPartyMonNicks call GetPartyMonName ld hl, wcd6d ld de, wd036 @@ -9,9 +9,9 @@ LearnMove: ; 6e43 (1:6e43) call CopyData DontAbandonLearning: ; 6e5b (1:6e5b) - ld hl, wPartyMon1Moves ; wPartyMon1Moves + ld hl, wPartyMon1Moves ld bc, $2c - ld a, [wWhichPokemon] ; wWhichPokemon + ld a, [wWhichPokemon] call AddNTimes ld d, h ld e, l @@ -43,7 +43,7 @@ DontAbandonLearning: ; 6e5b (1:6e5b) push hl push de dec a - ld hl, Moves ; $4000 + ld hl, Moves ld bc, $6 call AddNTimes ld de, wHPBarMaxHP @@ -53,12 +53,12 @@ DontAbandonLearning: ; 6e5b (1:6e5b) pop de pop hl ld [hl], a - ld a, [W_ISINBATTLE] ; W_ISINBATTLE + ld a, [W_ISINBATTLE] and a jp z, PrintLearnedMove - ld a, [wWhichPokemon] ; wWhichPokemon + ld a, [wWhichPokemon] ld b, a - ld a, [wPlayerMonNumber] ; wPlayerMonNumber + ld a, [wPlayerMonNumber] cp b jp nz, PrintLearnedMove ld h, d @@ -68,7 +68,7 @@ DontAbandonLearning: ; 6e5b (1:6e5b) call CopyData ld bc, $11 add hl, bc - ld de, wBattleMonPP ; wBattleMonPP + ld de, wBattleMonPP ld bc, $4 call CopyData jp PrintLearnedMove @@ -78,10 +78,10 @@ AbandonLearning: ; 6eda (1:6eda) call PrintText hlCoord 14, 7 ld bc, $80f - ld a, $14 + ld a, TWO_OPTION_MENU ld [wTextBoxID], a - call DisplayTextBoxID - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + call DisplayTextBoxID ; yes/no menu + ld a, [wCurrentMenuItem] and a jp nz, DontAbandonLearning ld hl, DidNotLearnText @@ -101,11 +101,11 @@ TryingToLearn: ; 6f07 (1:6f07) call PrintText hlCoord 14, 7 ld bc, $80f - ld a, $14 + ld a, TWO_OPTION_MENU ld [wTextBoxID], a - call DisplayTextBoxID + call DisplayTextBoxID ; yes/no menu pop hl - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + ld a, [wCurrentMenuItem] rra ret c ld bc, $fffc @@ -133,7 +133,7 @@ TryingToLearn: ; 6f07 (1:6f07) ld a, [$fff6] res 2, a ld [$fff6], a - ld hl, wTopMenuItemY ; wTopMenuItemY + ld hl, wTopMenuItemY ld a, $8 ld [hli], a ld a, $5 @@ -158,7 +158,7 @@ TryingToLearn: ; 6f07 (1:6f07) bit 1, a jr nz, .asm_6fab push hl - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + ld a, [wCurrentMenuItem] ld c, a ld b, $0 add hl, bc diff --git a/engine/menu/naming_screen.asm b/engine/menu/naming_screen.asm index 5d33862846..7506c84982 100755 --- a/engine/menu/naming_screen.asm +++ b/engine/menu/naming_screen.asm @@ -2,7 +2,7 @@ AskName: ; 64eb (1:64eb) call SaveScreenTilesToBuffer1 call GetPredefRegisters push hl - ld a, [W_ISINBATTLE] ; W_ISINBATTLE + ld a, [W_ISINBATTLE] dec a ld hl, wTileMap ld b, $4 @@ -15,11 +15,11 @@ AskName: ; 64eb (1:64eb) call PrintText hlCoord 14, 7 ld bc, $80f - ld a, $14 + ld a, TWO_OPTION_MENU ld [wTextBoxID], a call DisplayTextBoxID pop hl - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + ld a, [wCurrentMenuItem] and a jr nz, .asm_654c ld a, [wUpdateSpritesEnabled] @@ -30,7 +30,7 @@ AskName: ; 64eb (1:64eb) ld a, $2 ld [wd07d], a call DisplayNamingScreen - ld a, [W_ISINBATTLE] ; W_ISINBATTLE + ld a, [W_ISINBATTLE] and a jr nz, .asm_653e call ReloadMapSpriteTilePatterns @@ -66,9 +66,9 @@ Func_655c: ; 655c (1:655c) ld a, [wcf4b] cp $50 jr z, .asm_6594 - ld hl, wPartyMonNicks ; wPartyMonNicks + ld hl, wPartyMonNicks ld bc, $b - ld a, [wWhichPokemon] ; wWhichPokemon + ld a, [wWhichPokemon] call AddNTimes ld e, l ld d, h @@ -99,22 +99,22 @@ DisplayNamingScreen: ; 6596 (1:6596) call TextBoxBorder call PrintNamingText ld a, $3 - ld [wTopMenuItemY], a ; wTopMenuItemY + ld [wTopMenuItemY], a ld a, $1 - ld [wTopMenuItemX], a ; wTopMenuItemX - ld [wLastMenuItem], a ; wLastMenuItem - ld [wCurrentMenuItem], a ; wCurrentMenuItem + ld [wTopMenuItemX], a + ld [wLastMenuItem], a + ld [wCurrentMenuItem], a ld a, $ff - ld [wMenuWatchedKeys], a ; wMenuWatchedKeys + ld [wMenuWatchedKeys], a ld a, $7 - ld [wMaxMenuItem], a ; wMaxMenuItem + ld [wMaxMenuItem], a ld a, $50 ld [wcf4b], a xor a ld hl, wHPBarMaxHP + 1 ld [hli], a ld [hli], a - ld [W_SUBANIMTRANSFORM], a ; W_SUBANIMTRANSFORM + ld [W_SUBANIMTRANSFORM], a .asm_65ed call PrintAlphabet call GBPalNormal @@ -126,16 +126,16 @@ DisplayNamingScreen: ; 6596 (1:6596) .asm_65fc call PlaceMenuCursor .asm_65ff - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + ld a, [wCurrentMenuItem] push af callba AnimatePartyMon_ForceSpeed1 pop af - ld [wCurrentMenuItem], a ; wCurrentMenuItem + ld [wCurrentMenuItem], a call JoypadLowSensitivity ld a, [hJoyPressed] and a jr z, .asm_65ff - ld hl, .unknownPointerTable_665e ; $665e + ld hl, .unknownPointerTable_665e .asm_661a sla a jr c, .asm_6624 @@ -165,10 +165,10 @@ DisplayNamingScreen: ; 6596 (1:6596) call GoPAL_SET_CF1C call GBPalNormal xor a - ld [W_SUBANIMTRANSFORM], a ; W_SUBANIMTRANSFORM + ld [W_SUBANIMTRANSFORM], a ld hl, wd730 res 6, [hl] - ld a, [W_ISINBATTLE] ; W_ISINBATTLE + ld a, [W_ISINBATTLE] and a jp z, LoadTextBoxTilePatterns ld hl, LoadHudTilePatterns @@ -207,21 +207,21 @@ DisplayNamingScreen: ; 6596 (1:6596) ld [wHPBarMaxHP + 1], a ret .asm_6692 - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + ld a, [wCurrentMenuItem] cp $5 jr nz, .asm_66a0 - ld a, [wTopMenuItemX] ; wTopMenuItemX + ld a, [wTopMenuItemX] cp $11 jr z, .asm_668c .asm_66a0 - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + ld a, [wCurrentMenuItem] cp $6 jr nz, .asm_66ae - ld a, [wTopMenuItemX] ; wTopMenuItemX + ld a, [wTopMenuItemX] cp $1 jr z, .asm_667e .asm_66ae - ld hl, wMenuCursorLocation ; wMenuCursorLocation + ld hl, wMenuCursorLocation ld a, [hli] ld h, [hl] ld l, a @@ -270,10 +270,10 @@ DisplayNamingScreen: ; 6596 (1:6596) ld [hl], $50 ret .asm_6702 - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + ld a, [wCurrentMenuItem] cp $6 ret z - ld a, [wTopMenuItemX] ; wTopMenuItemX + ld a, [wTopMenuItemX] cp $11 jp z, .asm_6714 inc a @@ -283,10 +283,10 @@ DisplayNamingScreen: ; 6596 (1:6596) ld a, $1 jr .asm_6755 .asm_6718 - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + ld a, [wCurrentMenuItem] cp $6 ret z - ld a, [wTopMenuItemX] ; wTopMenuItemX + ld a, [wTopMenuItemX] dec a jp z, .asm_6728 dec a @@ -295,30 +295,30 @@ DisplayNamingScreen: ; 6596 (1:6596) ld a, $11 jr .asm_6755 .asm_672c - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + ld a, [wCurrentMenuItem] dec a - ld [wCurrentMenuItem], a ; wCurrentMenuItem + ld [wCurrentMenuItem], a and a ret nz ld a, $6 - ld [wCurrentMenuItem], a ; wCurrentMenuItem + ld [wCurrentMenuItem], a ld a, $1 jr .asm_6755 .asm_673e - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + ld a, [wCurrentMenuItem] inc a - ld [wCurrentMenuItem], a ; wCurrentMenuItem + ld [wCurrentMenuItem], a cp $7 jr nz, .asm_6750 ld a, $1 - ld [wCurrentMenuItem], a ; wCurrentMenuItem + ld [wCurrentMenuItem], a jr .asm_6755 .asm_6750 cp $6 ret nz ld a, $1 .asm_6755 - ld [wTopMenuItemX], a ; wTopMenuItemX + ld [wTopMenuItemX], a jp EraseMenuCursor LoadEDTile: ; 675b (1:675b) @@ -402,9 +402,9 @@ Func_680e: ; 680e (1:680e) jr nz, .asm_6867 call EraseMenuCursor ld a, $11 - ld [wTopMenuItemX], a ; wTopMenuItemX + ld [wTopMenuItemX], a ld a, $5 - ld [wCurrentMenuItem], a ; wCurrentMenuItem + ld [wCurrentMenuItem], a ld a, [wd07d] cp $2 ld a, $9 @@ -463,10 +463,10 @@ CalcStringLength: ; 68eb (1:68eb) PrintNamingText: ; 68f8 (1:68f8) hlCoord 0, 1 ld a, [wd07d] - ld de, YourTextString ; $693f + ld de, YourTextString and a jr z, .notNickname - ld de, RivalsTextString ; $6945 + ld de, RivalsTextString dec a jr z, .notNickname ld a, [wcf91] @@ -482,13 +482,13 @@ PrintNamingText: ; 68f8 (1:68f8) add hl, bc ld [hl], $c9 hlCoord 1, 3 - ld de, NicknameTextString ; $6953 + ld de, NicknameTextString jr .placeString .notNickname call PlaceString ld l, c ld h, b - ld de, NameTextString ; $694d + ld de, NameTextString .placeString jp PlaceString diff --git a/engine/menu/start_sub_menus.asm b/engine/menu/start_sub_menus.asm index cdd93875aa..1bedb0ea5b 100755 --- a/engine/menu/start_sub_menus.asm +++ b/engine/menu/start_sub_menus.asm @@ -29,8 +29,8 @@ StartMenu_Pokemon: ; 130a9 (4:70a9) call LoadGBPal jp RedisplayStartMenu .chosePokemon - call SaveScreenTilesToBuffer1 ; save screen - ld a,$04 + call SaveScreenTilesToBuffer1 + ld a,FIELD_MOVE_MON_MENU ld [wTextBoxID],a call DisplayTextBoxID ; display pokemon menu options ld hl,wWhichTrade @@ -341,7 +341,7 @@ StartMenu_Item: ; 13302 (4:7302) cp a,BICYCLE jp z,.useOrTossItem .notBicycle1 - ld a,$06 ; use/toss menu + ld a,USE_TOSS_MENU_TEMPLATE ld [wTextBoxID],a call DisplayTextBoxID ld hl,wTopMenuItemY diff --git a/engine/menu/vending_machine.asm b/engine/menu/vending_machine.asm index 1eba782be6..88cfcf6564 100755 --- a/engine/menu/vending_machine.asm +++ b/engine/menu/vending_machine.asm @@ -1,20 +1,20 @@ VendingMachineMenu: ; 74ee0 (1d:4ee0) ld hl, VendingMachineText1 call PrintText - ld a, $13 + ld a, MONEY_BOX ld [wTextBoxID], a call DisplayTextBoxID xor a - ld [wCurrentMenuItem], a ; wCurrentMenuItem - ld [wLastMenuItem], a ; wLastMenuItem + ld [wCurrentMenuItem], a + ld [wLastMenuItem], a ld a, $3 - ld [wMenuWatchedKeys], a ; wMenuWatchedKeys + ld [wMenuWatchedKeys], a ld a, $3 - ld [wMaxMenuItem], a ; wMaxMenuItem + ld [wMaxMenuItem], a ld a, $5 - ld [wTopMenuItemY], a ; wTopMenuItemY + ld [wTopMenuItemY], a ld a, $1 - ld [wTopMenuItemX], a ; wTopMenuItemX + ld [wTopMenuItemX], a ld hl, wd730 set 6, [hl] hlCoord 0, 3 @@ -33,7 +33,7 @@ VendingMachineMenu: ; 74ee0 (1d:4ee0) call HandleMenuInput bit 1, a jr nz, .asm_74f93 - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + ld a, [wCurrentMenuItem] cp $3 jr z, .asm_74f93 xor a @@ -66,10 +66,10 @@ VendingMachineMenu: ; 74ee0 (1d:4ee0) ld hl, VendingMachineText5 call PrintText ld hl, $ffde - ld de, wPlayerMoney + 2 ; wd349 + ld de, wPlayerMoney + 2 ld c, $3 predef SubBCDPredef - ld a, $13 + ld a, MONEY_BOX ld [wTextBoxID], a jp DisplayTextBoxID .BagFull diff --git a/engine/overworld/pokemart.asm b/engine/overworld/pokemart.asm index 644c155b03..4bc4c34156 100755 --- a/engine/overworld/pokemart.asm +++ b/engine/overworld/pokemart.asm @@ -11,10 +11,10 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20) ld [wPlayerMonNumber],a inc a ld [wcf93],a - ld a,$13 + ld a,MONEY_BOX ld [wTextBoxID],a call DisplayTextBoxID ; draw money text box - ld a,$15 + ld a,BUY_SELL_QUIT_MENU ld [wTextBoxID],a call DisplayTextBoxID ; do buy/sell/quit menu ld hl,wd128 ; pointer to this pokemart's inventory @@ -45,7 +45,7 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20) call SaveScreenTilesToBuffer1 ; save screen .sellMenuLoop call LoadScreenTilesFromBuffer1 ; restore saved screen - ld a,$13 + ld a,MONEY_BOX ld [wTextBoxID],a call DisplayTextBoxID ; draw money text box ld hl,wNumBagItems @@ -79,7 +79,7 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20) call PrintText hlCoord 14, 7 ld bc,$080f - ld a,$14 + ld a,TWO_OPTION_MENU ld [wTextBoxID],a call DisplayTextBoxID ; yes/no menu ld a,[wd12e] @@ -119,7 +119,7 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20) call SaveScreenTilesToBuffer1 ; save screen .buyMenuLoop call LoadScreenTilesFromBuffer1 ; restore saved screen - ld a,$13 + ld a,MONEY_BOX ld [wTextBoxID],a call DisplayTextBoxID ; draw money text box ld hl,wStringBuffer2 + 11 @@ -150,7 +150,7 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20) call PrintText hlCoord 14, 7 ld bc,$080f - ld a,$14 + ld a,TWO_OPTION_MENU ld [wTextBoxID],a call DisplayTextBoxID ; yes/no menu ld a,[wd12e] @@ -180,7 +180,7 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20) jp .buyMenuLoop .returnToMainPokemartMenu call LoadScreenTilesFromBuffer1 - ld a,$13 + ld a,MONEY_BOX ld [wTextBoxID],a call DisplayTextBoxID ; draw money text box ld hl,PokemartAnythingElseText diff --git a/engine/save.asm b/engine/save.asm index 7b1db4c7dc..29c839f39c 100755 --- a/engine/save.asm +++ b/engine/save.asm @@ -173,10 +173,10 @@ NowSavingString: SaveSAVConfirm: ; 73768 (1c:7768) call PrintText hlCoord 0, 7 - ld bc,$0801 ;arrow's coordinates |b = Y|c = X| - ld a,$14 ;one line shifting ($28 = 2 lines) + ld bc,$0801 + ld a,TWO_OPTION_MENU ld [wTextBoxID],a - call DisplayTextBoxID ;handle Yes/No KeyPress + call DisplayTextBoxID ; yes/no menu ld a,[wCurrentMenuItem] ret diff --git a/engine/slot_machine.asm b/engine/slot_machine.asm index 2444155c06..e3e452f3b6 100755 --- a/engine/slot_machine.asm +++ b/engine/slot_machine.asm @@ -137,7 +137,7 @@ MainSlotMachineLoop: ; 37395 (d:7395) ld bc, $0d0f xor a ; YES_NO_MENU ld [wTwoOptionMenuID], a - ld a, $14 + ld a, TWO_OPTION_MENU ld [wTextBoxID], a call DisplayTextBoxID ld a, [wCurrentMenuItem] diff --git a/home.asm b/home.asm index 20ea8550a7..00da859a4d 100644 --- a/home.asm +++ b/home.asm @@ -1325,7 +1325,7 @@ AddAmountSoldToMoney:: ; 2b9e (0:2b9e) ld hl,$ffa1 ; total price of items ld c,3 ; length of money in bytes predef AddBCDPredef ; add total price to money - ld a,$13 + ld a,MONEY_BOX ld [wTextBoxID],a call DisplayTextBoxID ; redraw money text box ld a, (SFX_02_5a - SFX_Headers_02) / 3 @@ -1398,7 +1398,7 @@ DisplayListMenuID:: ; 2be6 (0:2be6) ld h,a ; hl = address of the list ld a,[hl] ld [wd12a],a ; [wd12a] = number of list entries - ld a,$0d ; list menu text box ID + ld a,LIST_MENU_BOX ld [wTextBoxID],a call DisplayTextBoxID ; draw the menu text box call UpdateSprites ; disable sprites behind the text box @@ -2996,7 +2996,7 @@ YesNoChoice:: ; 35ec (0:35ec) jr DisplayYesNoChoice Func_35f4:: ; 35f4 (0:35f4) - ld a, $14 + ld a, TWO_OPTION_MENU ld [wTextBoxID], a call InitYesNoTextBoxParameters jp DisplayTextBoxID @@ -3023,7 +3023,7 @@ Func_361a:: ; 361a (0:361a) hlCoord 12, 7 ld bc, $080d DisplayYesNoChoice:: ; 3628 (0:3628) - ld a, $14 + ld a, TWO_OPTION_MENU ld [wTextBoxID], a call DisplayTextBoxID jp LoadScreenTilesFromBuffer1 @@ -4193,7 +4193,7 @@ AutoTextBoxDrawingCommon:: ; 3c41 (0:3c41) PrintText:: ; 3c49 (0:3c49) ; Print text hl at (1, 14). push hl - ld a,1 + ld a,MESSAGE_BOX ld [wTextBoxID],a call DisplayTextBoxID call UpdateSprites diff --git a/main.asm b/main.asm index dc8b8fa024..b40093aaf6 100755 --- a/main.asm +++ b/main.asm @@ -797,7 +797,7 @@ SubtractAmountPaidFromMoney_: ; 6b21 (1:6b21) ld hl,$ffa1 ; total price of items ld c,3 ; length of money in bytes predef SubBCDPredef ; subtract total price from money - ld a,$13 + ld a,MONEY_BOX ld [wTextBoxID],a call DisplayTextBoxID ; redraw money text box and a @@ -1166,7 +1166,7 @@ INCLUDE "engine/overworld/cable_club_npc.asm" ; function to draw various text boxes DisplayTextBoxID_: ; 72ea (1:72ea) ld a,[wTextBoxID] - cp a,$14 + cp a,TWO_OPTION_MENU jp z,DisplayTwoOptionMenu ld c,a ld hl,TextBoxFunctionTable @@ -1294,9 +1294,9 @@ GetAddressOfScreenCoords: ; 7375 (1:7375) ; 00: text box ID ; 01-02: function address TextBoxFunctionTable: ; 7387 (1:7387) - dbw $13, Func_74ba - dbw $15, Func_74ea - dbw $04, Func_76e1 + dbw MONEY_BOX, DisplayMoneyBox + dbw BUY_SELL_QUIT_MENU, DoBuySellQuitMenu + dbw FIELD_MOVE_MON_MENU, DisplayFieldMoveMonMenu db $ff ; terminator ; Format: @@ -1306,12 +1306,12 @@ TextBoxFunctionTable: ; 7387 (1:7387) ; 03: column of lower right corner ; 04: row of lower right corner TextBoxCoordTable: ; 7391 (1:7391) - db $01, 0, 12, 19, 17 - db $03, 0, 0, 19, 14 - db $07, 0, 0, 11, 6 - db $0d, 4, 2, 19, 12 - db $10, 7, 0, 19, 17 - db $11, 6, 4, 14, 13 + db MESSAGE_BOX, 0, 12, 19, 17 + db $03, 0, 0, 19, 14 + db $07, 0, 0, 11, 6 + db LIST_MENU_BOX, 4, 2, 19, 12 + db $10, 7, 0, 19, 17 + db MON_SPRITE_POPUP, 6, 4, 14, 13 db $ff ; terminator ; Format: @@ -1325,57 +1325,57 @@ TextBoxCoordTable: ; 7391 (1:7391) ; 08: row of beginning of text ; table of window positions and corresponding text [key, start column, start row, end column, end row, text pointer [2 bytes], text column, text row] TextBoxTextAndCoordTable: ; 73b0 (1:73b0) - db $05 ; text box ID + db JP_MOCHIMONO_MENU_TEMPLATE db 0,0,14,17 ; text box coordinates dw JapaneseMochimonoText db 3,0 ; text coordinates - db $06 ; text box ID + db USE_TOSS_MENU_TEMPLATE db 13,10,19,14 ; text box coordinates dw UseTossText db 15,11 ; text coordinates - db $08 ; text box ID + db JP_SAVE_MESSAGE_MENU_TEMPLATE db 0,0,7,5 ; text box coordinates dw JapaneseSaveMessageText db 2,2 ; text coordinates - db $09 ; text box ID + db JP_SPEED_OPTIONS_MENU_TEMPLATE db 0,6,5,10 ; text box coordinates dw JapaneseSpeedOptionsText db 2,7 ; text coordinates - db $0b ; text box ID + db BATTLE_MENU_TEMPLATE db 8,12,19,17 ; text box coordinates dw BattleMenuText db 10,14 ; text coordinates - db $1b ; text box ID + db SAFARI_BATTLE_MENU_TEMPLATE db 0,12,19,17 ; text box coordinates dw SafariZoneBattleMenuText db 2,14 ; text coordinates - db $0c ; text box ID + db SWITCH_STATS_CANCEL_MENU_TEMPLATE db 11,11,19,17 ; text box coordinates dw SwitchStatsCancelText db 13,12 ; text coordinates - db $0e ; text box ID + db BUY_SELL_QUIT_MENU_TEMPLATE db 0,0,10,6 ; text box coordinates dw BuySellQuitText db 2,1 ; text coordinates - db $0f ; text box ID + db MONEY_BOX_TEMPLATE db 11,0,19,2 ; text box coordinates dw MoneyText db 13,0 ; text coordinates - db $12 ; text box ID + db JP_AH_MENU_TEMPLATE db 7,6,11,10 ; text box coordinates dw JapaneseAhText db 8,8 ; text coordinates - db $1a ; text box ID + db JP_POKEDEX_MENU_TEMPLATE db 11,8,19,17 ; text box coordinates dw JapanesePokedexMenu db 12,10 ; text coordinates @@ -1431,10 +1431,10 @@ JapanesePokedexMenu: ; 74a1 (1:74a1) next "ぶんぷをみる" next "キャンセル@" -Func_74ba: ; 74ba (1:74ba) +DisplayMoneyBox: ; 74ba (1:74ba) ld hl, wd730 set 6, [hl] - ld a, $f + ld a, MONEY_BOX_TEMPLATE ld [wTextBoxID], a call DisplayTextBoxID hlCoord 13, 1 @@ -1442,7 +1442,7 @@ Func_74ba: ; 74ba (1:74ba) ld c, $6 call ClearScreenArea hlCoord 12, 1 - ld de, wPlayerMoney ; wPlayerMoney + ld de, wPlayerMoney ld c, $a3 call PrintBCDNumber ld hl, wd730 @@ -1452,53 +1452,53 @@ Func_74ba: ; 74ba (1:74ba) CurrencyString: ; 74e2 (1:74e2) db " ¥@" -Func_74ea: ; 74ea (1:74ea) +DoBuySellQuitMenu: ; 74ea (1:74ea) ld a, [wd730] set 6, a ; no printing delay ld [wd730], a xor a ld [wd12d], a - ld a, $e + ld a, BUY_SELL_QUIT_MENU_TEMPLATE ld [wTextBoxID], a call DisplayTextBoxID - ld a, $3 - ld [wMenuWatchedKeys], a ; wMenuWatchedKeys + ld a, A_BUTTON | B_BUTTON + ld [wMenuWatchedKeys], a ld a, $2 - ld [wMaxMenuItem], a ; wMaxMenuItem + ld [wMaxMenuItem], a ld a, $1 - ld [wTopMenuItemY], a ; wTopMenuItemY + ld [wTopMenuItemY], a ld a, $1 - ld [wTopMenuItemX], a ; wTopMenuItemX + ld [wTopMenuItemX], a xor a - ld [wCurrentMenuItem], a ; wCurrentMenuItem - ld [wLastMenuItem], a ; wLastMenuItem + ld [wCurrentMenuItem], a + ld [wLastMenuItem], a ld [wcc37], a ld a, [wd730] res 6, a ; turn on the printing delay ld [wd730], a call HandleMenuInput call PlaceUnfilledArrowMenuCursor - bit 0, a - jr nz, .asm_7539 - bit 1, a - jr z, .asm_7539 + bit 0, a ; was A pressed? + jr nz, .pressedA + bit 1, a ; was B pressed? (always true since only A/B are watched) + jr z, .pressedA ld a, $2 ld [wd12e], a - jr .asm_754c -.asm_7539 + jr .quit +.pressedA ld a, $1 ld [wd12e], a - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + ld a, [wCurrentMenuItem] ld [wd12d], a ld b, a - ld a, [wMaxMenuItem] ; wMaxMenuItem + ld a, [wMaxMenuItem] cp b - jr z, .asm_754c + jr z, .quit ret -.asm_754c +.quit ld a, $2 ld [wd12e], a - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + ld a, [wCurrentMenuItem] ld [wd12d], a scf ret @@ -1716,9 +1716,9 @@ TwoOptionMenuStrings: ; 7671 (1:7671) .HealCancelMenu ; 76d5 (1:36d5) db "HEAL",$4E,"CANCEL@" -Func_76e1: ; 76e1 (1:36e1) +DisplayFieldMoveMonMenu: ; 76e1 (1:36e1) xor a - ld hl, wWhichTrade ; wWhichTrade + ld hl, wWhichTrade ld [hli], a ld [hli], a ld [hli], a @@ -1737,7 +1737,7 @@ Func_76e1: ; 76e1 (1:36e1) ld a, $c ld [$fff7], a hlCoord 13, 12 - ld de, PokemonMenuEntries ; $77c2 + ld de, PokemonMenuEntries jp PlaceString .asm_770f push af @@ -1778,10 +1778,10 @@ Func_76e1: ; 76e1 (1:36e1) jr nz, .asm_7747 xor a ld [wTrainerScreenX], a - ld de, wWhichTrade ; wWhichTrade + ld de, wWhichTrade .asm_7752 push hl - ld hl, FieldMoveNames ; $778d + ld hl, FieldMoveNames ld a, [de] and a jr z, .asm_7776 @@ -1817,7 +1817,7 @@ Func_76e1: ; 76e1 (1:36e1) ld e, a ld d, $0 add hl, de - ld de, PokemonMenuEntries ; $77c2 + ld de, PokemonMenuEntries jp PlaceString FieldMoveNames: ; 778d (1:778d) @@ -1837,14 +1837,14 @@ PokemonMenuEntries: ; 77c2 (1:77c2) next "CANCEL@" GetMonFieldMoves: ; 77d6 (1:77d6) - ld a, [wWhichPokemon] ; wWhichPokemon - ld hl, wPartyMon1Moves ; wPartyMon1Moves + ld a, [wWhichPokemon] + ld hl, wPartyMon1Moves ld bc, $2c call AddNTimes ld d, h ld e, l ld c, $5 - ld hl, wWhichTrade ; wWhichTrade + ld hl, wWhichTrade .asm_77e9 push hl .asm_77ea @@ -1855,7 +1855,7 @@ GetMonFieldMoves: ; 77d6 (1:77d6) jr z, .asm_7821 ld b, a inc de ; go to next move - ld hl, FieldMoveDisplayData ; $7823 + ld hl, FieldMoveDisplayData .asm_77f6 ld a, [hli] cp $ff From 72265ab92abd235c2af6d26ae76dd0dcaecfd6ac Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Sat, 7 Feb 2015 13:40:14 -0800 Subject: [PATCH 093/100] comment drain HP effect --- engine/battle/1.asm | 54 +++++++++++++++++++++++------------------- engine/battle/core.asm | 4 ++-- wram.asm | 4 ++-- 3 files changed, 33 insertions(+), 29 deletions(-) diff --git a/engine/battle/1.asm b/engine/battle/1.asm index e28cd0568b..ccc82c5591 100755 --- a/engine/battle/1.asm +++ b/engine/battle/1.asm @@ -6,26 +6,28 @@ DrainHPEffect_: ; 783f (1:783f) ld a, [hl] rr a ld [hld], a - or [hl] - jr nz, .asm_784f + or [hl] ; is damage 0? + jr nz, .getAttackerHP +; if damage is 0, increase to 1 so that the attacker gains at least 1 HP inc hl inc [hl] -.asm_784f - ld hl, wBattleMonHP ; wd015 - ld de, wBattleMonMaxHP ; wd023 - ld a, [H_WHOSETURN] ; $fff3 +.getAttackerHP + ld hl, wBattleMonHP + ld de, wBattleMonMaxHP + ld a, [H_WHOSETURN] and a - jp z, Func_7861 + jp z, .addDamageToAttackerHP ld hl, wEnemyMonHP ld de, wEnemyMonMaxHP - -Func_7861: ; 7861 (1:7861) +.addDamageToAttackerHP ld bc, wHPBarOldHP+1 +; copy current HP to wHPBarOldHP ld a, [hli] ld [bc], a ld a, [hl] dec bc ld [bc], a +; copy max HP to wHPBarMaxHP ld a, [de] dec bc ld [bc], a @@ -33,7 +35,8 @@ Func_7861: ; 7861 (1:7861) ld a, [de] dec bc ld [bc], a - ld a, [wd0d8] +; add damage to attacker's HP and copy new HP to wHPBarNewHP + ld a, [W_DAMAGE + 1] ld b, [hl] add b ld [hld], a @@ -43,7 +46,8 @@ Func_7861: ; 7861 (1:7861) adc b ld [hli], a ld [wHPBarNewHP+1], a - jr c, .asm_7890 + jr c, .capToMaxHP ; if HP > 65,535, cap to max HP +; compare HP with max HP ld a, [hld] ld b, a ld a, [de] @@ -54,8 +58,8 @@ Func_7861: ; 7861 (1:7861) ld a, [de] inc de sbc b - jr nc, .asm_789c -.asm_7890 + jr nc, .next +.capToMaxHP ld a, [de] ld [hld], a ld [wHPBarNewHP], a @@ -64,31 +68,31 @@ Func_7861: ; 7861 (1:7861) ld [hli], a ld [wHPBarNewHP+1], a inc de -.asm_789c - ld a, [H_WHOSETURN] ; $fff3 +.next + ld a, [H_WHOSETURN] and a hlCoord 10, 9 ld a, $1 - jr z, .asm_78aa + jr z, .next2 hlCoord 2, 2 xor a -.asm_78aa - ld [wListMenuID], a ; wListMenuID +.next2 + ld [wListMenuID], a predef UpdateHPBar2 predef DrawPlayerHUDAndHPBar predef DrawEnemyHUDAndHPBar callab ReadPlayerMonCurHPAndStatus - ld hl, SuckedHealthText ; $78dc - ld a, [H_WHOSETURN] ; $fff3 + ld hl, SuckedHealthText + ld a, [H_WHOSETURN] and a - ld a, [W_PLAYERMOVEEFFECT] ; wcfd3 - jr z, .asm_78d2 + ld a, [W_PLAYERMOVEEFFECT] + jr z, .next3 ld a, [W_ENEMYMOVEEFFECT] -.asm_78d2 +.next3 cp DREAM_EATER_EFFECT - jr nz, .asm_78d9 + jr nz, .printText ld hl, DreamWasEatenText -.asm_78d9 +.printText jp PrintText SuckedHealthText: ; 78dc (1:78dc) diff --git a/engine/battle/core.asm b/engine/battle/core.asm index c6cc5734b4..de6bc2e34c 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -3554,7 +3554,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) ld a,[hld] add a ld b,a - ld [wd0d8],a + ld [W_DAMAGE + 1],a ld a,[hl] rl a ; double the damage ld [W_DAMAGE],a @@ -6053,7 +6053,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) ld a, [hld] add a ld b, a - ld [wd0d8], a + ld [W_DAMAGE + 1], a ld a, [hl] rl a ld [W_DAMAGE], a diff --git a/wram.asm b/wram.asm index d0bc78aef9..f55b383a25 100755 --- a/wram.asm +++ b/wram.asm @@ -1269,9 +1269,9 @@ W_MONHPADDING:: ; d0d7 W_DAMAGE:: ; d0d7 - ds 1 + ds 2 -wd0d8:: ds 3 +ds 2 wRepelRemainingSteps:: ; wd0db ds 1 From 4fd7a42b235b68ffc11d4f02305b695c2ed05549 Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Sat, 7 Feb 2015 16:24:16 -0800 Subject: [PATCH 094/100] commented battle stuff --- engine/battle/14.asm | 64 ++++++++-------- engine/battle/16.asm | 2 +- engine/battle/1c.asm | 73 +++++++++--------- engine/battle/4.asm | 36 ++++----- engine/battle/4_2.asm | 60 +++++++-------- engine/battle/5.asm | 10 +-- engine/battle/9.asm | 48 +++++++----- engine/battle/a.asm | 2 +- engine/battle/c.asm | 2 +- engine/battle/core.asm | 30 ++++---- engine/battle/e_2.asm | 107 +++++++++++++-------------- engine/cable_club.asm | 8 +- engine/hall_of_fame.asm | 2 +- engine/hp_bar.asm | 2 +- engine/items/items.asm | 16 ++-- engine/learn_move.asm | 12 +-- engine/menu/party_menu.asm | 8 +- engine/menu/status_screen.asm | 2 +- engine/overworld/healing_machine.asm | 17 +++-- engine/predefs.asm | 4 +- engine/save.asm | 8 +- home.asm | 4 +- home/text.asm | 2 +- hram.asm | 3 + main.asm | 2 +- wram.asm | 1 + 26 files changed, 272 insertions(+), 253 deletions(-) diff --git a/engine/battle/14.asm b/engine/battle/14.asm index cabaae071f..1b2d7462f0 100755 --- a/engine/battle/14.asm +++ b/engine/battle/14.asm @@ -1,4 +1,4 @@ -Func_525af: ; 525af (14:65af) +InitBattleVariables: ; 525af (14:65af) ld a, [hTilesetType] ld [wd0d4], a xor a @@ -9,7 +9,7 @@ Func_525af: ; 525af (14:65af) ld [hli], a ld [hli], a ld [hl], a - ld [wListScrollOffset], a ; wcc36 + ld [wListScrollOffset], a ld [wCriticalHitOrOHKO], a ld [wBattleMonSpecies], a ld [wPartyGainExpFlags], a @@ -21,73 +21,73 @@ Func_525af: ; 525af (14:65af) ld [hl], a ld hl, wccd3 ld b, $3c -.asm_525e1 +.loop ld [hli], a dec b - jr nz, .asm_525e1 + jr nz, .loop inc a ld [wccd9], a ld a, [W_CURMAP] cp SAFARI_ZONE_EAST - jr c, .asm_525f9 + jr c, .notSafariBattle cp SAFARI_ZONE_REST_HOUSE_1 - jr nc, .asm_525f9 - ld a, $2 - ld [W_BATTLETYPE], a ; wd05a -.asm_525f9 + jr nc, .notSafariBattle + ld a, $2 ; safari battle + ld [W_BATTLETYPE], a +.notSafariBattle ld hl, PlayBattleMusic ld b, BANK(PlayBattleMusic) jp Bankswitch ParalyzeEffect_: ; 52601 (14:6601) - ld hl, wEnemyMonStatus ; wcfe9 - ld de, W_PLAYERMOVETYPE ; wcfd5 - ld a, [H_WHOSETURN] ; $fff3 + ld hl, wEnemyMonStatus + ld de, W_PLAYERMOVETYPE + ld a, [H_WHOSETURN] and a - jp z, .asm_52613 + jp z, .next ld hl, wBattleMonStatus - ld de, W_ENEMYMOVETYPE ; wcfcf - -.asm_52613 + ld de, W_ENEMYMOVETYPE +.next ld a, [hl] - and a - jr nz, .asm_52659 + and a ; does the target already have a status ailment? + jr nz, .didntAffect +; check if the target is immune due to types ld a, [de] - cp EVASION_DOWN1_EFFECT - jr nz, .asm_5262a + cp ELECTRIC + jr nz, .hitTest ld b, h ld c, l inc bc ld a, [bc] - cp $4 - jr z, .asm_52666 + cp GROUND + jr z, .doesntAffect inc bc ld a, [bc] - cp $4 - jr z, .asm_52666 -.asm_5262a + cp GROUND + jr z, .doesntAffect +.hitTest push hl callab MoveHitTest pop hl ld a, [W_MOVEMISSED] and a - jr nz, .asm_52659 + jr nz, .didntAffect set PAR, [hl] callab QuarterSpeedDueToParalysis - ld c, $1e + ld c, 30 call DelayFrames - callab Func_3fba8 + callab PlayCurrentMoveAnimation ld hl, PrintMayNotAttackText ld b, BANK(PrintMayNotAttackText) jp Bankswitch -.asm_52659 - ld c, $32 +.didntAffect + ld c, 50 call DelayFrames ld hl, PrintDidntAffectText ld b, BANK(PrintDidntAffectText) jp Bankswitch -.asm_52666 - ld c, $32 +.doesntAffect + ld c, 50 call DelayFrames ld hl, PrintDoesntAffectText ld b, BANK(PrintDoesntAffectText) diff --git a/engine/battle/16.asm b/engine/battle/16.asm index d1cecbbe5b..4a215a3791 100755 --- a/engine/battle/16.asm +++ b/engine/battle/16.asm @@ -55,7 +55,7 @@ PrintBeginningBattleText: ; 58d99 (16:4d99) ld hl, UnveiledGhostText call PrintText callab LoadEnemyMonData - callab Func_708ca + callab DoGhostMarowakRevelationAnimation ld hl, WildMonAppearedText call PrintText diff --git a/engine/battle/1c.asm b/engine/battle/1c.asm index b905777b3a..2e360e65c0 100755 --- a/engine/battle/1c.asm +++ b/engine/battle/1c.asm @@ -1,85 +1,90 @@ -Func_708ca: ; 708ca (1c:48ca) +DoGhostMarowakRevelationAnimation: ; 708ca (1c:48ca) ld a, $e4 - ld [rOBP1], a ; $ff49 - call Func_7092a + ld [rOBP1], a + call CopyMonPicFromBGToSpriteVRAM ; cover the BG ghost pic with a sprite ghost pic that looks the same +; now that the ghost pic is being displayed using sprites, clear the ghost pic from the BG tilemap hlCoord 12, 0 ld bc, $707 call ClearScreenArea call Delay3 xor a - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba - ld a, $91 + ld [H_AUTOBGTRANSFERENABLED], a ; disable BG transfer so we don't see the Marowak too soon +; replace ghost pic with Marowak in BG + ld a, MAROWAK ld [wHPBarMaxHP], a ld a, $1 - ld [H_WHOSETURN], a ; $fff3 + ld [H_WHOSETURN], a callab Func_79793 + ; alternate between black and light grey 8 times. + ; this makes the ghost's body appear to flash ld d, $80 - call Func_704f3 -.asm_708f6 - ld c, $a + call FlashSprite8Times +.fadeOutGhostLoop + ld c, 10 call DelayFrames - ld a, [rOBP1] ; $ff49 + ld a, [rOBP1] sla a sla a - ld [rOBP1], a ; $ff49 - jr nz, .asm_708f6 + ld [rOBP1], a + jr nz, .fadeOutGhostLoop call ClearSprites - call Func_7092a + call CopyMonPicFromBGToSpriteVRAM ; copy Marowak pic from BG to sprite VRAM ld b, $e4 -.asm_7090d - ld c, $a +.fadeInMarowakLoop + ld c, 10 call DelayFrames - ld a, [rOBP1] ; $ff49 + ld a, [rOBP1] srl b rra srl b rra - ld [rOBP1], a ; $ff49 + ld [rOBP1], a ld a, b and a - jr nz, .asm_7090d + jr nz, .fadeInMarowakLoop ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba + ld [H_AUTOBGTRANSFERENABLED], a ; enable BG transfer so the BG Marowak pic will be visible after the sprite one is cleared call Delay3 jp ClearSprites -Func_7092a: ; 7092a (1c:492a) +; copies a mon pic's from background VRAM to sprite VRAM and sets up OAM +CopyMonPicFromBGToSpriteVRAM: ; 7092a (1c:492a) ld de, vFrontPic ld hl, vSprites ld bc, 7 * 7 call CopyVideoData ld a, $10 - ld [W_BASECOORDY], a ; wd082 + ld [W_BASECOORDY], a ld a, $70 - ld [W_BASECOORDX], a ; wd081 + ld [W_BASECOORDX], a ld hl, wOAMBuffer ld bc, $606 ld d, $8 -.asm_70948 +.oamLoop push bc - ld a, [W_BASECOORDY] ; wd082 + ld a, [W_BASECOORDY] ld e, a -.asm_7094d +.oamInnerLoop ld a, e add $8 ld e, a ld [hli], a - ld a, [W_BASECOORDX] ; wd081 + ld a, [W_BASECOORDX] ld [hli], a ld a, d ld [hli], a - ld a, $10 + ld a, $10 ; use OBP1 ld [hli], a inc d dec c - jr nz, .asm_7094d + jr nz, .oamInnerLoop inc d - ld a, [W_BASECOORDX] ; wd081 + ld a, [W_BASECOORDX] add $8 - ld [W_BASECOORDX], a ; wd081 + ld [W_BASECOORDX], a pop bc dec b - jr nz, .asm_70948 + jr nz, .oamLoop ret BattleTransition: ; 7096d (1c:496d) @@ -270,9 +275,9 @@ BattleTransitionTile: ; 70a59 (1c:4a59) BattleTransition_BlackScreen: ; 70a69 (1c:4a69) ld a, $ff - ld [rBGP], a ; $ff47 - ld [rOBP0], a ; $ff48 - ld [rOBP1], a ; $ff49 + ld [rBGP], a + ld [rOBP0], a + ld [rOBP1], a ret ; for non-dungeon trainer battles diff --git a/engine/battle/4.asm b/engine/battle/4.asm index db6614cc79..37ffaa05a2 100755 --- a/engine/battle/4.asm +++ b/engine/battle/4.asm @@ -1,14 +1,14 @@ -Func_128d8: ; 128d8 (4:68d8) - ld a, [W_YCOORD] ; wd361 +; returns whether the player is one tile outside the map in Z +IsPlayerJustOutsideMap: ; 128d8 (4:68d8) + ld a, [W_YCOORD] ld b, a - ld a, [W_CURMAPHEIGHT] ; wd368 - call Func_128ea + ld a, [W_CURMAPHEIGHT] + call .compareCoordWithMapDimension ret z - ld a, [W_XCOORD] ; wd362 + ld a, [W_XCOORD] ld b, a - ld a, [W_CURMAPWIDTH] ; wd369 - -Func_128ea: ; 128ea (4:68ea) + ld a, [W_CURMAPWIDTH] +.compareCoordWithMapDimension add a cp b ret z @@ -24,7 +24,7 @@ Func_128f6: ; 128f6 (4:68f6) call GetPredefRegisters ld a, $2 asm_128fb: ; 128fb (4:68fb) - ld [wListMenuID], a ; wListMenuID + ld [wListMenuID], a push hl ld a, [wcf99] ld b, a @@ -37,7 +37,7 @@ asm_128fb: ; 128fb (4:68fb) ld e, a ld a, $6 ld d, a - jp Func_12924 + jp DrawHPBarAndFraction .asm_12913 ld a, [wcfba] ld d, a @@ -48,21 +48,21 @@ asm_128fb: ; 128fb (4:68fb) ld d, a ld c, a -Func_12924: ; 12924 (4:6924) +DrawHPBarAndFraction: ; 12924 (4:6924) pop hl push de push hl push hl call DrawHPBar pop hl - ld a, [$fff6] + ld a, [hFlags_0xFFF6] bit 0, a - jr z, .asm_12937 - ld bc, $9 - jr .asm_1293a -.asm_12937 - ld bc, $15 -.asm_1293a + jr z, .printFractionBelowBar + ld bc, $9 ; right of bar + jr .printHPFraction +.printFractionBelowBar + ld bc, SCREEN_WIDTH + 1 ; below bar +.printHPFraction add hl, bc ld de, wcf99 ld bc, $203 diff --git a/engine/battle/4_2.asm b/engine/battle/4_2.asm index a3ef126406..287c8eae7c 100755 --- a/engine/battle/4_2.asm +++ b/engine/battle/4_2.asm @@ -87,7 +87,9 @@ PickUpPayDayMoneyText: ; 1386b (4:786b) TX_FAR _PickUpPayDayMoneyText db "@" -Func_13870: ; 13870 (4:7870) +; try to initiate a wild pokemon encounter +; returns success in Z +TryDoWildEncounter: ; 13870 (4:7870) ld a, [wNPCMovementScriptPointerTableNum] and a ret nz @@ -95,14 +97,14 @@ Func_13870: ; 13870 (4:7870) and a ret nz callab IsPlayerStandingOnDoorTileOrWarpTile - jr nc, .asm_13888 -.asm_13884 + jr nc, .notStandingOnDoorOrWarpTile +.CantEncounter ld a, $1 and a ret -.asm_13888 - callab Func_128d8 - jr z, .asm_13884 +.notStandingOnDoorOrWarpTile + callab IsPlayerJustOutsideMap + jr z, .CantEncounter ld a, [wRepelRemainingSteps] and a jr z, .asm_1389e @@ -110,8 +112,8 @@ Func_13870: ; 13870 (4:7870) jr z, .lastRepelStep ld [wRepelRemainingSteps], a .asm_1389e -; determine if wild pokmon can appear in the half-block were standing -; is the bottom right tile (9,9) of the half-block are we standing a grass/water tile? +; determine if wild pokmon can appear in the half-block were standing in +; is the bottom right tile (9,9) of the half-block we're standing in a grass/water tile? hlCoord 9, 9 ld c, [hl] ld a, [W_GRASSTILE] @@ -127,17 +129,17 @@ Func_13870: ; 13870 (4:7870) ; as long as its not Viridian Forest or Safari Zone. ld a, [W_CURMAP] cp REDS_HOUSE_1F ; is this an indoor map? - jr c, .CantEncounter + jr c, .CantEncounter2 ld a, [W_CURMAPTILESET] cp FOREST ; Viridian Forest/Safari Zone - jr z, .CantEncounter + jr z, .CantEncounter2 ld a, [W_GRASSRATE] .CanEncounter -; weigh encounter chance to a random number to determine if there will be an encounter +; compare encounter chance with a random number to determine if there will be an encounter ld b, a ld a, [hRandomAdd] cp b - jr nc, .CantEncounter + jr nc, .CantEncounter2 ld a, [hRandomSub] ld b, a ld hl, WildMonEncounterSlotChances @@ -148,15 +150,15 @@ Func_13870: ; 13870 (4:7870) inc hl jr .determineEncounterSlot .gotEncounterSlot -; determine which wild pokmon (grass or water) can appear in the half-block were standing +; determine which wild pokmon (grass or water) can appear in the half-block were standing in ld c, [hl] ld hl, W_GRASSMONS aCoord 8, 9 - cp $14 ; is the bottom left tile (8,9) of the half-block are we standing a water tile? + cp $14 ; is the bottom left tile (8,9) of the half-block we're standing in a water tile? jr nz, .gotWildEncounterType ; else, it's treated as a grass tile by default ld hl, W_WATERMONS ; since the bottom right tile of a "left shore" half-block is $14 but the bottom left tile is not, -; "left shore" half-blocks (such as the one in the east coast of Cinnabar), load grass encounters. +; "left shore" half-blocks (such as the one in the east coast of Cinnabar) load grass encounters. .gotWildEncounterType ld b, $0 add hl, bc @@ -172,15 +174,15 @@ Func_13870: ; 13870 (4:7870) ld b, a ld a, [W_CURENEMYLVL] cp b - jr c, .CantEncounter + jr c, .CantEncounter2 ; repel prevents encounters if the leading party mon's level is higher than the wild mon jr .willEncounter .lastRepelStep ld [wRepelRemainingSteps], a ld a, $d2 - ld [H_DOWNARROWBLINKCNT2], a ; $ff8c + ld [H_DOWNARROWBLINKCNT2], a call EnableAutoTextBoxDrawing call DisplayTextID -.CantEncounter +.CantEncounter2 ld a, $1 and a ret @@ -293,8 +295,8 @@ ConversionEffect_: ; 139a3 (4:79a3) inc de ld a, [hl] ld [de], a - ld hl, Func_3fba8 - call Func_139d5 + ld hl, PlayCurrentMoveAnimation + call CallBankF ld hl, ConvertedTypeText jp PrintText @@ -304,22 +306,22 @@ ConvertedTypeText: ; 139cd (4:79cd) PrintButItFailedText: ; 139d2 (4:79d2) ld hl, PrintButItFailedText_ -Func_139d5: ; 139d5 (4:79d5) +CallBankF: ; 139d5 (4:79d5) ld b, BANK(PrintButItFailedText_) jp Bankswitch HazeEffect_: ; 139da (4:79da) ld a, $7 ld hl, wPlayerMonAttackMod - call Func_13a43 + call ResetStatMods ld hl, wEnemyMonAttackMod - call Func_13a43 + call ResetStatMods ld hl, wPlayerMonUnmodifiedAttack ld de, wBattleMonAttack - call Func_13a4a + call ResetStats ld hl, wEnemyMonUnmodifiedAttack ld de, wEnemyMonAttack - call Func_13a4a + call ResetStats ld hl, wEnemyMonStatus ld de, wEnemySelectedMove ld a, [H_WHOSETURN] @@ -347,8 +349,8 @@ HazeEffect_: ; 139da (4:79da) call CureStatuses ld hl, W_ENEMYBATTSTATUS1 call CureStatuses - ld hl, Func_3fba8 - call Func_139d5 + ld hl, PlayCurrentMoveAnimation + call CallBankF ld hl, StatusChangesEliminatedText jp PrintText @@ -363,7 +365,7 @@ CureStatuses: ; 13a37 (4:7a37) ld [hl], a ret -Func_13a43: ; 13a43 (4:7a43) +ResetStatMods: ; 13a43 (4:7a43) ld b, $8 .loop ld [hli], a @@ -371,7 +373,7 @@ Func_13a43: ; 13a43 (4:7a43) jr nz, .loop ret -Func_13a4a: ; 13a4a (4:7a4a) +ResetStats: ; 13a4a (4:7a4a) ld b, $8 .loop ld a, [hli] diff --git a/engine/battle/5.asm b/engine/battle/5.asm index e534470d99..ef3e136298 100755 --- a/engine/battle/5.asm +++ b/engine/battle/5.asm @@ -4,7 +4,7 @@ SubstituteEffectHandler: ; 17dad (5:7dad) ld hl, wBattleMonMaxHP ld de, wPlayerSubstituteHP ld bc, W_PLAYERBATTSTATUS2 - ld a, [$fff3] ;whose turn? + ld a, [H_WHOSETURN] and a jr z, .notEnemy ld hl, wEnemyMonMaxHP @@ -23,8 +23,8 @@ SubstituteEffectHandler: ; 17dad (5:7dad) srl a rr b push de - ld de, $fff2 ;subtract 8 to point to [current hp] instead of [max hp] - add hl, de ;HL -= 8 + ld de, wBattleMonHP - wBattleMonMaxHP + add hl, de ; point hl to current HP pop de ld a, b ld [de], a ;save copy of HP to subtract in ccd7/ccd8 [how much HP substitute has] @@ -44,8 +44,8 @@ SubstituteEffectHandler: ; 17dad (5:7dad) set HasSubstituteUp, [hl] ;set bit 4 of flags, user now has substitute ld a, [W_OPTIONS] ;load options bit 7, a ;battle animation is enabled? - ld hl, Func_3fba8 ;animation enabled: 0F:7BA8 - ld b, BANK(Func_3fba8) + ld hl, PlayCurrentMoveAnimation ;animation enabled: 0F:7BA8 + ld b, BANK(PlayCurrentMoveAnimation) jr z, .animationEnabled ld hl, AnimationSubstitute ;animation disabled: 1E:56E0 ld b, BANK(AnimationSubstitute) diff --git a/engine/battle/9.asm b/engine/battle/9.asm index eb86cce058..e7265f4165 100755 --- a/engine/battle/9.asm +++ b/engine/battle/9.asm @@ -1,35 +1,43 @@ -Func_27d6b: ; 27d6b (9:7d6b) +; [wd0b5] = pokemon ID +; hl = dest addr +PrintMonType: ; 27d6b (9:7d6b) call GetPredefRegisters push hl call GetMonHeader pop hl push hl ld a, [W_MONHTYPE1] - call Func_27d89 + call PrintType ld a, [W_MONHTYPE1] ld b, a ld a, [W_MONHTYPE2] cp b pop hl - jr z, asm_27d8c - ld bc, $28 + jr z, EraseType2Text + ld bc, SCREEN_WIDTH * 2 add hl, bc -Func_27d89: ; 27d89 (9:7d89) +; a = type +; hl = dest addr +PrintType: ; 27d89 (9:7d89) push hl - jr asm_27d9f -asm_27d8c: ; 27d8c (9:7d8c) - ld a, $7f + jr PrintType_ + +; erase "TYPE2/" if the mon only has 1 type +EraseType2Text: ; 27d8c (9:7d8c) + ld a, " " ld bc, $13 add hl, bc ld bc, $6 jp FillMemory -Func_27d98: ; 27d98 (9:7d98) +PrintMoveType: ; 27d98 (9:7d98) call GetPredefRegisters push hl - ld a, [W_PLAYERMOVETYPE] ; wcfd5 -asm_27d9f: ; 27d9f (9:7d9f) + ld a, [W_PLAYERMOVETYPE] +; fall through + +PrintType_: ; 27d9f (9:7d9f) add a ld hl, TypeNames ld e, a @@ -157,19 +165,19 @@ CooltrainerFName: ; 27f79 (9:7f79) db "COOLTRAINER♀@" FocusEnergyEffect_: ; 27f86 (9:7f86) - ld hl, W_PLAYERBATTSTATUS2 ; W_PLAYERBATTSTATUS2 - ld a, [H_WHOSETURN] ; $fff3 + ld hl, W_PLAYERBATTSTATUS2 + ld a, [H_WHOSETURN] and a - jr z, .asm_27f91 - ld hl, W_ENEMYBATTSTATUS2 ; W_ENEMYBATTSTATUS2 -.asm_27f91 + jr z, .notEnemy + ld hl, W_ENEMYBATTSTATUS2 +.notEnemy bit GettingPumped, [hl] ; is mon already using focus energy? - jr nz, .asm_27fa5 + jr nz, .alreadyUsing set GettingPumped, [hl] ; mon is now using focus energy - callab Func_3fba8 - ld hl, GettingPumpedText ; $7fb2 + callab PlayCurrentMoveAnimation + ld hl, GettingPumpedText jp PrintText -.asm_27fa5 +.alreadyUsing ld c, $32 call DelayFrames ld hl, PrintButItFailedText_ diff --git a/engine/battle/a.asm b/engine/battle/a.asm index 917a462b6a..a257d1434a 100755 --- a/engine/battle/a.asm +++ b/engine/battle/a.asm @@ -21,7 +21,7 @@ LeechSeedEffect_: ; 2bea9 (a:7ea9) bit Seeded, [hl] jr nz, .asm_2bee7 set Seeded, [hl] - callab Func_3fba8 + callab PlayCurrentMoveAnimation ld hl, WasSeededText ; $7ef2 jp PrintText .asm_2bee7 diff --git a/engine/battle/c.asm b/engine/battle/c.asm index 07369375ed..b7c20ef6bf 100755 --- a/engine/battle/c.asm +++ b/engine/battle/c.asm @@ -8,7 +8,7 @@ MistEffect_: ; 33f2b (c:7f2b) bit ProtectedByMist, [hl] ; is mon protected by mist? jr nz, .asm_33f4a set ProtectedByMist, [hl] ; mon is now protected by mist - callab Func_3fba8 + callab PlayCurrentMoveAnimation ld hl, ShroudedInMistText jp PrintText .asm_33f4a diff --git a/engine/battle/core.asm b/engine/battle/core.asm index de6bc2e34c..6ea2c55bb1 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -2541,13 +2541,13 @@ MoveSelectionMenu: ; 3d219 (f:5219) .writemoves ld de, wd0e1 - ld a, [$fff6] + ld a, [hFlags_0xFFF6] set 2, a - ld [$fff6], a + ld [hFlags_0xFFF6], a call PlaceString - ld a, [$fff6] + ld a, [hFlags_0xFFF6] res 2, a - ld [$fff6], a + ld [hFlags_0xFFF6], a ret .regularmenu @@ -2666,10 +2666,10 @@ SelectMenuItem: ; 3d2fe (f:52fe) call AddNTimes ld [hl], $ec .select - ld hl, $fff6 + ld hl, hFlags_0xFFF6 set 1, [hl] call HandleMenuInput - ld hl, $fff6 + ld hl, hFlags_0xFFF6 res 1, [hl] bit 6, a jp nz, CursorUp ; up @@ -2959,7 +2959,7 @@ PrintMenuItem: ; 3d4b6 (f:54b6) call PrintNumber call GetCurrentMove hlCoord 2, 10 - predef Func_27d98 + predef PrintMoveType .moveDisabled ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a @@ -6814,7 +6814,7 @@ asm_3ef23: ; 3ef23 (f:6f23) ld a, [wNumberOfNoRandomBattleStepsLeft] and a ret nz - callab Func_13870 + callab TryDoWildEncounter ret nz asm_3ef3d: ; 3ef3d (f:6f3d) ld a, [wMapPalOffset] @@ -6823,7 +6823,7 @@ asm_3ef3d: ; 3ef3d (f:6f3d) ld a, [hl] push af res 1, [hl] - callab Func_525af + callab InitBattleVariables ld a, [wEnemyMonSpecies2] sub $c8 jp c, InitWildBattle @@ -7637,7 +7637,7 @@ UpdateStatDone: ; 3f4ca (f:74ca) call nz, Bankswitch ; play Minimize animation unless there's Substitute involved pop de .asm_3f4f9 - call Func_3fba8 + call PlayCurrentMoveAnimation ld a, [de] cp MINIMIZE jr nz, .applyBadgeBoostsAndStatusPenalties @@ -8451,7 +8451,7 @@ MimicEffect: ; 3f9ed (f:79ed) ld [hl], a ld [wd11e], a call GetMoveName - call Func_3fba8 + call PlayCurrentMoveAnimation ld hl, MimicLearnedMoveText jp PrintText .asm_3fa74 @@ -8467,7 +8467,7 @@ LeechSeedEffect: ; 3fa7c (f:7a7c) jp Bankswitch SplashEffect: ; 3fa84 (f:7a84) - call Func_3fba8 + call PlayCurrentMoveAnimation jp PrintNoEffectText DisableEffect: ; 3fa8a (f:7a8a) @@ -8662,15 +8662,15 @@ Func_3fb96: ; 3fb96 (f:7b96) ld [wcc5b], a jp Func_3fbbc -Func_3fba8: ; 3fba8 (f:7ba8) +PlayCurrentMoveAnimation: ; 3fba8 (f:7ba8) xor a ld [wcc5b], a ld a, [H_WHOSETURN] and a ld a, [W_PLAYERMOVENUM] - jr z, .asm_3fbb7 + jr z, .notEnemyTurn ld a, [W_ENEMYMOVENUM] -.asm_3fbb7 +.notEnemyTurn and a ret z diff --git a/engine/battle/e_2.asm b/engine/battle/e_2.asm index 6c159c568e..1106f531ec 100755 --- a/engine/battle/e_2.asm +++ b/engine/battle/e_2.asm @@ -1,13 +1,13 @@ HealEffect_: ; 3b9ec (e:79ec) - ld a, [H_WHOSETURN] ; $fff3 + ld a, [H_WHOSETURN] and a - ld de, wBattleMonHP ; wd015 - ld hl, wBattleMonMaxHP ; wd023 - ld a, [W_PLAYERMOVENUM] ; wcfd2 + ld de, wBattleMonHP + ld hl, wBattleMonMaxHP + ld a, [W_PLAYERMOVENUM] jr z, .asm_3ba03 - ld de, wEnemyMonHP ; wEnemyMonHP - ld hl, wEnemyMonMaxHP ; wEnemyMonMaxHP - ld a, [W_ENEMYMOVENUM] ; W_ENEMYMOVENUM + ld de, wEnemyMonHP + ld hl, wEnemyMonMaxHP + ld a, [W_ENEMYMOVENUM] .asm_3ba03 ld b, a ld a, [de] @@ -16,27 +16,27 @@ HealEffect_: ; 3b9ec (e:79ec) inc hl ld a, [de] sbc [hl] - jp z, Func_3ba97 + jp z, .failed ld a, b cp REST jr nz, .asm_3ba37 push hl push de push af - ld c, $32 + ld c, 50 call DelayFrames - ld hl, wBattleMonStatus ; wBattleMonStatus - ld a, [H_WHOSETURN] ; $fff3 + ld hl, wBattleMonStatus + ld a, [H_WHOSETURN] and a jr z, .asm_3ba25 - ld hl, wEnemyMonStatus ; wcfe9 + ld hl, wEnemyMonStatus .asm_3ba25 ld a, [hl] and a ld [hl], 2 ; Number of turns from Rest - ld hl, StartedSleepingEffect ; $7aa2 + ld hl, StartedSleepingEffect jr z, .asm_3ba31 - ld hl, FellAsleepBecameHealthyText ; $7aa7 + ld hl, FellAsleepBecameHealthyText .asm_3ba31 call PrintText pop af @@ -81,9 +81,9 @@ HealEffect_: ; 3b9ec (e:79ec) ld [de], a ld [wHPBarNewHP], a .asm_3ba6f - ld hl, Func_3fba8 ; $7ba8 + ld hl, PlayCurrentMoveAnimation call BankswitchEtoF - ld a, [H_WHOSETURN] ; $fff3 + ld a, [H_WHOSETURN] and a hlCoord 10, 9 ld a, $1 @@ -91,15 +91,14 @@ HealEffect_: ; 3b9ec (e:79ec) hlCoord 2, 2 xor a .asm_3ba83 - ld [wListMenuID], a ; wListMenuID + ld [wListMenuID], a predef UpdateHPBar2 - ld hl, DrawHUDsAndHPBars ; $4d5a + ld hl, DrawHUDsAndHPBars call BankswitchEtoF - ld hl, RegainedHealthText ; $7aac + ld hl, RegainedHealthText jp PrintText - -Func_3ba97: ; 3ba97 (e:7a97) - ld c, $32 +.failed + ld c, 50 call DelayFrames ld hl, PrintButItFailedText_ jp BankswitchEtoF @@ -119,37 +118,37 @@ RegainedHealthText: ; 3baac (e:7aac) TransformEffect_: ; 3bab1 (e:7ab1) ld hl, wBattleMonSpecies ld de, wEnemyMonSpecies - ld bc, W_ENEMYBATTSTATUS3 ; W_ENEMYBATTSTATUS3 - ld a, [W_ENEMYBATTSTATUS1] ; W_ENEMYBATTSTATUS1 - ld a, [H_WHOSETURN] ; $fff3 + ld bc, W_ENEMYBATTSTATUS3 + ld a, [W_ENEMYBATTSTATUS1] + ld a, [H_WHOSETURN] and a jr nz, .asm_3bad1 ld hl, wEnemyMonSpecies ld de, wBattleMonSpecies - ld bc, W_PLAYERBATTSTATUS3 ; W_PLAYERBATTSTATUS3 - ld [wPlayerMoveListIndex], a ; wPlayerMoveListIndex - ld a, [W_PLAYERBATTSTATUS1] ; W_PLAYERBATTSTATUS1 + ld bc, W_PLAYERBATTSTATUS3 + ld [wPlayerMoveListIndex], a + ld a, [W_PLAYERBATTSTATUS1] .asm_3bad1 bit Invulnerable, a ; is mon invulnerable to typical attacks? (fly/dig) - jp nz, Func_3bb8c + jp nz, .failed push hl push de push bc - ld hl, W_PLAYERBATTSTATUS2 ; W_PLAYERBATTSTATUS2 - ld a, [H_WHOSETURN] ; $fff3 + ld hl, W_PLAYERBATTSTATUS2 + ld a, [H_WHOSETURN] and a jr z, .asm_3bae4 - ld hl, W_ENEMYBATTSTATUS2 ; W_ENEMYBATTSTATUS2 + ld hl, W_ENEMYBATTSTATUS2 .asm_3bae4 bit HasSubstituteUp, [hl] push af ld hl, Func_79747 ld b, BANK(Func_79747) call nz, Bankswitch - ld a, [W_OPTIONS] ; W_OPTIONS + ld a, [W_OPTIONS] add a - ld hl, Func_3fba8 ; $7ba8 - ld b, BANK(Func_3fba8) + ld hl, PlayCurrentMoveAnimation + ld b, BANK(PlayCurrentMoveAnimation) jr nc, .asm_3baff ld hl, AnimationTransformMon ld b, BANK(AnimationTransformMon) @@ -178,7 +177,7 @@ TransformEffect_: ; 3bab1 (e:7ab1) inc bc inc bc call CopyData - ld a, [H_WHOSETURN] ; $fff3 + ld a, [H_WHOSETURN] and a jr z, .asm_3bb32 ld a, [de] @@ -228,15 +227,15 @@ TransformEffect_: ; 3bab1 (e:7ab1) call GetMonName ld hl, wEnemyMonUnmodifiedAttack ld de, wPlayerMonUnmodifiedAttack - call Func_3bb7d - ld hl, wEnemyMonStatMods ; wcd2e - ld de, wPlayerMonStatMods ; wcd1a - call Func_3bb7d - ld hl, TransformedText ; $7b92 + call .copyBasedOnTurn + ld hl, wEnemyMonStatMods + ld de, wPlayerMonStatMods + call .copyBasedOnTurn + ld hl, TransformedText jp PrintText -Func_3bb7d: ; 3bb7d (e:7b7d) - ld a, [H_WHOSETURN] ; $fff3 +.copyBasedOnTurn + ld a, [H_WHOSETURN] and a jr z, .asm_3bb86 push hl @@ -247,8 +246,8 @@ Func_3bb7d: ; 3bb7d (e:7b7d) ld bc, $8 jp CopyData -Func_3bb8c: ; 3bb8c (e:7b8c) - ld hl, PrintButItFailedText_ ; $7b53 +.failed + ld hl, PrintButItFailedText_ jp BankswitchEtoF TransformedText: ; 3bb92 (e:7b92) @@ -256,13 +255,13 @@ TransformedText: ; 3bb92 (e:7b92) db "@" ReflectLightScreenEffect_: ; 3bb97 (e:7b97) - ld hl, W_PLAYERBATTSTATUS3 ; W_PLAYERBATTSTATUS3 - ld de, W_PLAYERMOVEEFFECT ; wcfd3 - ld a, [H_WHOSETURN] ; $fff3 + ld hl, W_PLAYERBATTSTATUS3 + ld de, W_PLAYERMOVEEFFECT + ld a, [H_WHOSETURN] and a jr z, .asm_3bba8 - ld hl, W_ENEMYBATTSTATUS3 ; W_ENEMYBATTSTATUS3 - ld de, W_ENEMYMOVEEFFECT ; W_ENEMYMOVEEFFECT + ld hl, W_ENEMYBATTSTATUS3 + ld de, W_ENEMYMOVEEFFECT .asm_3bba8 ld a, [de] cp LIGHT_SCREEN_EFFECT @@ -270,23 +269,23 @@ ReflectLightScreenEffect_: ; 3bb97 (e:7b97) bit HasLightScreenUp, [hl] ; is mon already protected by light screen? jr nz, .moveFailed set HasLightScreenUp, [hl] ; mon is now protected by light screen - ld hl, LightScreenProtectedText ; $7bd7 + ld hl, LightScreenProtectedText jr .asm_3bbc1 .reflect bit HasReflectUp, [hl] ; is mon already protected by reflect? jr nz, .moveFailed set HasReflectUp, [hl] ; mon is now protected by reflect - ld hl, ReflectGainedArmorText ; $7bdc + ld hl, ReflectGainedArmorText .asm_3bbc1 push hl - ld hl, Func_3fba8 ; $7ba8 + ld hl, PlayCurrentMoveAnimation call BankswitchEtoF pop hl jp PrintText .moveFailed ld c, $32 call DelayFrames - ld hl, PrintButItFailedText_ ; $7b53 + ld hl, PrintButItFailedText_ jp BankswitchEtoF LightScreenProtectedText: ; 3bbd7 (e:7bd7) diff --git a/engine/cable_club.asm b/engine/cable_club.asm index 92a4e33b7a..68c6a8dcbd 100755 --- a/engine/cable_club.asm +++ b/engine/cable_club.asm @@ -338,10 +338,10 @@ TradeCenter_SelectMon: ld a, 1 ld [wTopMenuItemX], a .enemyMonMenu_HandleInput - ld hl, $fff6 + ld hl, hFlags_0xFFF6 set 1, [hl] call HandleMenuInput - ld hl, $fff6 + ld hl, hFlags_0xFFF6 res 1, [hl] and a jp z, .getNewInput @@ -403,10 +403,10 @@ TradeCenter_SelectMon: ld bc, $0601 call ClearScreenArea .playerMonMenu_HandleInput - ld hl, $fff6 + ld hl, hFlags_0xFFF6 set 1, [hl] call HandleMenuInput - ld hl, $fff6 + ld hl, hFlags_0xFFF6 res 1, [hl] and a ; was anything pressed? jr nz, .playerMonMenu_SomethingPressed diff --git a/engine/hall_of_fame.asm b/engine/hall_of_fame.asm index 80acfeeb4d..3097911863 100755 --- a/engine/hall_of_fame.asm +++ b/engine/hall_of_fame.asm @@ -170,7 +170,7 @@ Func_702f0: ; 702f0 (1c:42f0) ld a, [wWhichTrade] ; wWhichTrade ld [wd0b5], a hlCoord 3, 9 - predef Func_27d6b + predef PrintMonType ld a, [wWhichTrade] ; wWhichTrade jp PlayCry diff --git a/engine/hp_bar.asm b/engine/hp_bar.asm index 9ff9e3cf3b..a53511c765 100755 --- a/engine/hp_bar.asm +++ b/engine/hp_bar.asm @@ -211,7 +211,7 @@ UpdateHPBar_PrintHPNumber: ; faf5 (3:7af5) ld a, [wHPBarOldHP+1] ld [wcef0], a push hl - ld a, [$fff6] + ld a, [hFlags_0xFFF6] bit 0, a jr z, .asm_fb15 ld de, $9 diff --git a/engine/items/items.asm b/engine/items/items.asm index 05f77175cf..99c97feffc 100755 --- a/engine/items/items.asm +++ b/engine/items/items.asm @@ -919,15 +919,15 @@ ItemUseMedicine: ; dabb (3:5abb) call AddNTimes ; calculate coordinates of HP bar of pokemon that used Softboiled ld a,(SFX_02_3d - SFX_Headers_02) / 3 call PlaySoundWaitForCurrent ; play sound - ld a,[$fff6] + ld a,[hFlags_0xFFF6] set 0,a - ld [$fff6],a + ld [hFlags_0xFFF6],a ld a,$02 ld [wListMenuID],a predef UpdateHPBar2 ; animate HP bar decrease of pokemon that used Softboiled - ld a,[$fff6] + ld a,[hFlags_0xFFF6] res 0,a - ld [$fff6],a + ld [hFlags_0xFFF6],a pop af ld b,a ; store heal amount (1/5 of max HP) ld hl,wHPBarOldHP + 1 @@ -1069,15 +1069,15 @@ ItemUseMedicine: ; dabb (3:5abb) jr z,.playStatusAilmentCuringSound ld a,(SFX_02_3d - SFX_Headers_02) / 3 ; HP healing sound call PlaySoundWaitForCurrent ; play sound - ld a,[$fff6] + ld a,[hFlags_0xFFF6] set 0,a - ld [$fff6],a + ld [hFlags_0xFFF6],a ld a,$02 ld [wListMenuID],a predef UpdateHPBar2 ; animate the HP bar lengthening - ld a,[$fff6] + ld a,[hFlags_0xFFF6] res 0,a - ld [$fff6],a + ld [hFlags_0xFFF6],a ld a,$f7 ; revived message ld [wd07d],a ld a,[wcf91] diff --git a/engine/learn_move.asm b/engine/learn_move.asm index f96c1aeb18..c991058d40 100755 --- a/engine/learn_move.asm +++ b/engine/learn_move.asm @@ -126,13 +126,13 @@ TryingToLearn: ; 6f07 (1:6f07) call TextBoxBorder hlCoord 6, 8 ld de, wd0e1 - ld a, [$fff6] + ld a, [hFlags_0xFFF6] set 2, a - ld [$fff6], a + ld [hFlags_0xFFF6], a call PlaceString - ld a, [$fff6] + ld a, [hFlags_0xFFF6] res 2, a - ld [$fff6], a + ld [hFlags_0xFFF6], a ld hl, wTopMenuItemY ld a, $8 ld [hli], a @@ -146,10 +146,10 @@ TryingToLearn: ; 6f07 (1:6f07) ld a, $3 ld [hli], a ld [hl], $0 - ld hl, $fff6 + ld hl, hFlags_0xFFF6 set 1, [hl] call HandleMenuInput - ld hl, $fff6 + ld hl, hFlags_0xFFF6 res 1, [hl] push af call LoadScreenTilesFromBuffer1 diff --git a/engine/menu/party_menu.asm b/engine/menu/party_menu.asm index 10fc4182ec..a2c02481bf 100755 --- a/engine/menu/party_menu.asm +++ b/engine/menu/party_menu.asm @@ -88,14 +88,14 @@ RedrawPartyMenu_: ; 12ce3 (4:6ce3) pop hl push hl ld bc,20 + 1 ; down 1 row and right 1 column - ld a,[$FFF6] + ld a,[hFlags_0xFFF6] set 0,a - ld [$FFF6],a + ld [hFlags_0xFFF6],a add hl,bc predef Func_128f6 ; draw HP bar and prints current / max HP - ld a,[$FFF6] + ld a,[hFlags_0xFFF6] res 0,a - ld [$FFF6],a + ld [hFlags_0xFFF6],a call SetPartyMenuHealthBarColor ; color the HP bar (on SGB) pop hl jr .printLevel diff --git a/engine/menu/status_screen.asm b/engine/menu/status_screen.asm index f215fd0e81..2fc5e7132e 100755 --- a/engine/menu/status_screen.asm +++ b/engine/menu/status_screen.asm @@ -82,7 +82,7 @@ StatusScreen: ; 12953 (4:6953) ld bc, $8103 ; Zero-padded, 3 call PrintNumber ; Pokémon no. hlCoord 11, 10 - predef Func_27d6b ; Prints the type (?) + predef PrintMonType ld hl, NamePointers2 ; $6a9d call .unk_12a7e ld d, h diff --git a/engine/overworld/healing_machine.asm b/engine/overworld/healing_machine.asm index 5317463010..90d306c323 100755 --- a/engine/overworld/healing_machine.asm +++ b/engine/overworld/healing_machine.asm @@ -48,7 +48,7 @@ AnimateHealingMachine: ; 70433 (1c:4433) ld [wc0ee], a call PlaySound ld d, $28 - call Func_704f3 + call FlashSprite8Times .asm_704a2 ld a, [wc026] cp MUSIC_PKMN_HEALED @@ -74,16 +74,17 @@ PokeCenterOAMData: ; 704d7 (1c:44d7) db $35,$30,$7D,$10 db $35,$38,$7D,$30 -Func_704f3: ; 704f3 (1c:44f3) - ld b, $8 -.asm_704f5 - ld a, [rOBP1] ; $ff49 +; d = value to xor with palette +FlashSprite8Times: ; 704f3 (1c:44f3) + ld b, 8 +.loop + ld a, [rOBP1] xor d - ld [rOBP1], a ; $ff49 - ld c, $a + ld [rOBP1], a + ld c, 10 call DelayFrames dec b - jr nz, .asm_704f5 + jr nz, .loop ret Func_70503: ; 70503 (1c:4503) diff --git a/engine/predefs.asm b/engine/predefs.asm index 8a98bd3d34..f2bedf962e 100755 --- a/engine/predefs.asm +++ b/engine/predefs.asm @@ -127,7 +127,7 @@ PredefPointers:: ; 4fe79 (13:7e79) add_predef UpdateHPBar2 add_predef DrawEnemyHUDAndHPBar add_predef LoadTownMap_Nest - add_predef Func_27d6b + add_predef PrintMonType add_predef EmotionBubble; 4C player exclamation add_predef EmptyFunc3; return immediately add_predef AskName @@ -145,7 +145,7 @@ PredefPointers:: ; 4fe79 (13:7e79) add_predef CheckForCollisionWhenPushingBoulder add_predef PrintStrengthTxt add_predef PickupItem - add_predef Func_27d98 + add_predef PrintMoveType add_predef LoadMovePPs add_predef DrawHP ; 5F add_predef Func_128f6 diff --git a/engine/save.asm b/engine/save.asm index 29c839f39c..c123187183 100755 --- a/engine/save.asm +++ b/engine/save.asm @@ -346,10 +346,10 @@ ChangeBox:: ; 738a1 (1c:78a1) call z, Func_73a29 call Func_7393f call UpdateSprites - ld hl, $fff6 + ld hl, hFlags_0xFFF6 set 1, [hl] call HandleMenuInput - ld hl, $fff6 + ld hl, hFlags_0xFFF6 res 1, [hl] bit 1, a ret nz @@ -436,12 +436,12 @@ Func_7393f: ; 7393f (1c:793f) ld b, $c ld c, $7 call TextBoxBorder - ld hl, $fff6 + ld hl, hFlags_0xFFF6 set 2, [hl] ld de, BoxNames ; $79d9 hlCoord 13, 1 call PlaceString - ld hl, $fff6 + ld hl, hFlags_0xFFF6 res 2, [hl] ld a, [wd5a0] and $7f diff --git a/home.asm b/home.asm index 00da859a4d..be56a70afa 100644 --- a/home.asm +++ b/home.asm @@ -4046,7 +4046,7 @@ PlaceMenuCursor:: ; 3b7c (0:3b7c) and a ; was the previous menu id 0? jr z,.checkForArrow1 push af - ld a,[$fff6] + ld a,[hFlags_0xFFF6] bit 1,a ; is the menu double spaced? jr z,.doubleSpaced1 ld bc,20 @@ -4072,7 +4072,7 @@ PlaceMenuCursor:: ; 3b7c (0:3b7c) and a jr z,.checkForArrow2 push af - ld a,[$fff6] + ld a,[hFlags_0xFFF6] bit 1,a ; is the menu double spaced? jr z,.doubleSpaced2 ld bc,20 diff --git a/home/text.asm b/home/text.asm index 362347cc13..276b652e22 100644 --- a/home/text.asm +++ b/home/text.asm @@ -62,7 +62,7 @@ PlaceNextChar:: ; 1956 (0:1956) cp $4E jr nz,.next ld bc,$0028 - ld a,[$FFF6] + ld a,[hFlags_0xFFF6] bit 2,a jr z,.next2 ld bc,$14 diff --git a/hram.asm b/hram.asm index dfe14d6613..29eb435336 100644 --- a/hram.asm +++ b/hram.asm @@ -151,5 +151,8 @@ H_CURRENTSPRITEOFFSET EQU $FFDA ; multiple of $10 H_WHOSETURN EQU $FFF3 ; 0 on player’s turn, 1 on enemy’s turn +; bit 0: draw HP fraction to the right of bar instead of below (for party menu) +hFlags_0xFFF6 EQU $FFF6 + hJoyInput EQU $FFF8 diff --git a/main.asm b/main.asm index b40093aaf6..6f5b532474 100755 --- a/main.asm +++ b/main.asm @@ -126,7 +126,7 @@ LoadMonData_: .copyMonData ld de, wcf98 - ld bc, 44 + ld bc, wPartyMon2 - wPartyMon1 jp CopyData diff --git a/wram.asm b/wram.asm index f55b383a25..389b4cc4c2 100755 --- a/wram.asm +++ b/wram.asm @@ -824,6 +824,7 @@ wcfbc:: ds 2 wcfbe:: ds 2 wcfc0:: ds 2 wcfc2:: ds 2 + wcfc4:: ds 1 wWalkCounter:: ; cfc5 From 32f7cf12de9f841f76a3f2010caf6d7a80d47bcc Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Sat, 7 Feb 2015 18:37:40 -0800 Subject: [PATCH 095/100] Named wram symbols --- engine/battle/4.asm | 12 +++---- engine/battle/core.asm | 22 ++++++------- engine/battle/e.asm | 10 +++--- engine/cable_club.asm | 4 +-- engine/evos_moves.asm | 16 +++++----- engine/experience.asm | 4 +-- engine/menu/bills_pc.asm | 4 +-- engine/menu/party_menu.asm | 4 +-- engine/menu/players_pc.asm | 12 +++---- engine/menu/start_sub_menus.asm | 4 +-- engine/menu/status_screen.asm | 40 +++++++++++------------ engine/overworld/map_sprites.asm | 6 ++-- engine/overworld/movement.asm | 4 +-- engine/overworld/pokemart.asm | 8 ++--- engine/predefs7.asm | 4 +-- home.asm | 54 ++++++++++++++++---------------- hram.asm | 3 ++ main.asm | 16 +++++----- scripts/ceruleanhouse2.asm | 4 +-- wram.asm | 39 ++++++++++------------- 20 files changed, 133 insertions(+), 137 deletions(-) diff --git a/engine/battle/4.asm b/engine/battle/4.asm index 37ffaa05a2..97db1ba313 100755 --- a/engine/battle/4.asm +++ b/engine/battle/4.asm @@ -26,9 +26,9 @@ Func_128f6: ; 128f6 (4:68f6) asm_128fb: ; 128fb (4:68fb) ld [wListMenuID], a push hl - ld a, [wcf99] + ld a, [wLoadedMonHP] ld b, a - ld a, [wcf9a] + ld a, [wLoadedMonHP + 1] ld c, a or b jr nz, .asm_12913 @@ -39,9 +39,9 @@ asm_128fb: ; 128fb (4:68fb) ld d, a jp DrawHPBarAndFraction .asm_12913 - ld a, [wcfba] + ld a, [wLoadedMonMaxHP] ld d, a - ld a, [wcfbb] + ld a, [wLoadedMonMaxHP + 1] ld e, a predef HPBarLength ld a, $6 @@ -64,12 +64,12 @@ DrawHPBarAndFraction: ; 12924 (4:6924) ld bc, SCREEN_WIDTH + 1 ; below bar .printHPFraction add hl, bc - ld de, wcf99 + ld de, wLoadedMonHP ld bc, $203 call PrintNumber ld a, "/" ld [hli], a - ld de, wcfba + ld de, wLoadedMonMaxHP ld bc, $203 call PrintNumber pop hl diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 6ea2c55bb1..a502ed7c97 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -1899,23 +1899,23 @@ DrawPlayerHUDAndHPBar: ; 3cd60 (f:4d60) call CenterMonName call PlaceString ld hl, wBattleMonSpecies - ld de, wcf98 + ld de, wLoadedMon ld bc, $c call CopyData ld hl, wBattleMonLevel - ld de, wcfb9 + ld de, wLoadedMonLevel ld bc, $b call CopyData hlCoord 14, 8 push hl inc hl - ld de, wcf9c + ld de, wLoadedMonStatus call PrintStatusConditionNotFainted pop hl jr nz, .asm_3cdae call PrintLevel .asm_3cdae - ld a, [wcf98] + ld a, [wLoadedMonSpecies] ld [wcf91], a hlCoord 10, 9 predef DrawHP @@ -1965,7 +1965,7 @@ DrawEnemyHUDAndHPBar: ; 3cdec (f:4dec) pop hl jr nz, .skipPrintLevel ; if the mon has a status condition, skip printing the level ld a, [wEnemyMonLevel] - ld [wcfb9], a + ld [wLoadedMonLevel], a call PrintLevel .skipPrintLevel ld hl, wEnemyMonHP @@ -2270,9 +2270,9 @@ BagWasSelected: jr nz, DisplayPlayerBag ; no, it is a normal battle ld hl, OldManItemList ld a, l - ld [wcf8b], a + ld [wList], a ld a, h - ld [wcf8c], a + ld [wList + 1], a jr DisplayBagMenu OldManItemList: @@ -2284,9 +2284,9 @@ DisplayPlayerBag: ; get the pointer to player's bag when in a normal battle ld hl, wNumBagItems ld a, l - ld [wcf8b], a + ld [wList], a ld a, h - ld [wcf8c], a + ld [wList + 1], a DisplayBagMenu: xor a @@ -4451,7 +4451,7 @@ GetEnemyMonStat: ; 3df1c (f:5f1c) ld [wd0b5], a call GetMonHeader ld hl, wEnemyMonDVs - ld de, wcfaf + ld de, wLoadedMonSpeedExp ld a, [hli] ld [de], a inc de @@ -4459,7 +4459,7 @@ GetEnemyMonStat: ; 3df1c (f:5f1c) ld [de], a pop bc ld b, $0 - ld hl, wcfa4 + ld hl, wLoadedMonSpeedExp - $b ; this base address makes CalcStat look in [wLoadedMonSpeedExp] for DVs call CalcStat pop de ret diff --git a/engine/battle/e.asm b/engine/battle/e.asm index 9f93baa617..ff3ac83962 100755 --- a/engine/battle/e.asm +++ b/engine/battle/e.asm @@ -665,18 +665,18 @@ Func_39bd5: ; 39bd5 (e:5bd5) .asm_39c18 ld [W_LISTTYPE], a ld a, l - ld [wcf8b], a + ld [wList], a ld a, h - ld [wcf8c], a + ld [wList + 1], a ld a, e ld [wcf8d], a ld a, d ld [wcf8e], a - ld bc, ItemPrices ; $4608 + ld bc, ItemPrices ld a, c - ld [wcf8f], a + ld [wItemPrices], a ld a, b - ld [wcf90], a + ld [wItemPrices + 1], a ret Func_39c37: ; 39c37 (e:5c37) diff --git a/engine/cable_club.asm b/engine/cable_club.asm index 68c6a8dcbd..ff25fd5ef0 100755 --- a/engine/cable_club.asm +++ b/engine/cable_club.asm @@ -578,7 +578,7 @@ TradeCenter_SelectMon: ReturnToCableClubRoom: ; 577d (1:577d) call GBPalWhiteOutWithDelay3 - ld hl, wcfc4 + ld hl, wCharRAMInUseForText ld a, [hl] push af push hl @@ -808,7 +808,7 @@ TradeCenter_Trade: ld a, c ld bc, wEnemyMon2 - wEnemyMon1 call AddNTimes - ld de, wcf98 + ld de, wLoadedMon ld bc, wEnemyMon2 - wEnemyMon1 call CopyData call AddEnemyMonToPlayerParty diff --git a/engine/evos_moves.asm b/engine/evos_moves.asm index 2c504104d0..2eef7ba76f 100755 --- a/engine/evos_moves.asm +++ b/engine/evos_moves.asm @@ -88,7 +88,7 @@ Evolution_PartyMonLoop: ; loop over party mons jp nz, .nextEvoEntry1 ; if not trading, go to the next evolution entry ld a, [hli] ; level requirement ld b, a - ld a, [wcfb9] + ld a, [wLoadedMonLevel] cp b ; is the mon's level greater than the evolution requirement? jp c, Evolution_PartyMonLoop ; if so, go the next mon jr .asm_3adb6 @@ -101,7 +101,7 @@ Evolution_PartyMonLoop: ; loop over party mons .checkLevel ld a, [hli] ; level requirement ld b, a - ld a, [wcfb9] + ld a, [wLoadedMonLevel] cp b ; is the mon's level greater than the evolution requirement? jp c, .nextEvoEntry2 ; if so, go the next evolution entry .asm_3adb6 @@ -136,7 +136,7 @@ Evolution_PartyMonLoop: ; loop over party mons pop hl ld a, [hl] ld [wd0b5], a - ld [wcf98], a + ld [wLoadedMonSpecies], a ld [wHPBarMaxHP + 1], a ld a, MONSTER_NAME ld [W_LISTTYPE], a @@ -169,8 +169,8 @@ Evolution_PartyMonLoop: ; loop over party mons ld [W_MONHDEXNUM], a pop af ld [wd11e], a - ld hl, wcfa8 - ld de, wcfba + ld hl, wLoadedMonHPExp - 1 + ld de, wLoadedMonStats ld b, $1 call CalcStats ld a, [wWhichPokemon] @@ -186,14 +186,14 @@ Evolution_PartyMonLoop: ; loop over party mons ld a, [hli] ld b, a ld c, [hl] - ld hl, wcfbb + ld hl, wLoadedMonMaxHP + 1 ld a, [hld] sub c ld c, a ld a, [hl] sbc b ld b, a - ld hl, wcf9a + ld hl, wLoadedMonHP + 1 ld a, [hl] add c ld [hld], a @@ -226,7 +226,7 @@ Evolution_PartyMonLoop: ; loop over party mons call Evolution_FlagAction pop de pop hl - ld a, [wcf98] + ld a, [wLoadedMonSpecies] ld [hl], a push hl ld l, e diff --git a/engine/experience.asm b/engine/experience.asm index 91f1dd5d7b..68d22843e6 100755 --- a/engine/experience.asm +++ b/engine/experience.asm @@ -1,6 +1,6 @@ ; calculates the level a mon should be based on its current exp CalcLevelFromExperience: ; 58f43 (16:4f43) - ld a, [wcf98] + ld a, [wLoadedMonSpecies] ld [wd0b5], a call GetMonHeader ld d, $1 ; init level to 1 @@ -8,7 +8,7 @@ CalcLevelFromExperience: ; 58f43 (16:4f43) inc d ; increment level call CalcExperience push hl - ld hl, wcfa8 ; current exp + ld hl, wLoadedMonExp + 2 ; current exp ; compare exp needed for level d with current exp ld a, [H_MULTIPLICAND + 2] ld c, a diff --git a/engine/menu/bills_pc.asm b/engine/menu/bills_pc.asm index a26c5aed17..9e8422c05f 100644 --- a/engine/menu/bills_pc.asm +++ b/engine/menu/bills_pc.asm @@ -325,9 +325,9 @@ Func_216b3: ; 216b3 (8:56b3) Func_216be: ; 216be (8:56be) ld a, l - ld [wcf8b], a + ld [wList], a ld a, h - ld [wcf8c], a + ld [wList + 1], a xor a ld [wcf93], a ld [wListMenuID], a ; wListMenuID diff --git a/engine/menu/party_menu.asm b/engine/menu/party_menu.asm index a2c02481bf..86474be9c0 100755 --- a/engine/menu/party_menu.asm +++ b/engine/menu/party_menu.asm @@ -83,7 +83,7 @@ RedrawPartyMenu_: ; 12ce3 (4:6ce3) push hl ld bc,14 ; 14 columns to the right add hl,bc - ld de,wcf9c + ld de,wLoadedMonStatus call PrintStatusCondition pop hl push hl @@ -134,7 +134,7 @@ RedrawPartyMenu_: ; 12ce3 (4:6ce3) push hl ld hl,EvosMovesPointerTable ld b,0 - ld a,[wcf98] ; pokemon ID + ld a,[wLoadedMonSpecies] dec a add a rl b diff --git a/engine/menu/players_pc.asm b/engine/menu/players_pc.asm index 5f1175eb0e..5217befa08 100755 --- a/engine/menu/players_pc.asm +++ b/engine/menu/players_pc.asm @@ -97,9 +97,9 @@ Func_79ab: ; 79ab (1:79ab) call PrintText ld hl, wNumBagItems ; wNumBagItems ld a, l - ld [wcf8b], a + ld [wList], a ld a, h - ld [wcf8c], a + ld [wList + 1], a xor a ld [wcf93], a ld a, $3 @@ -151,9 +151,9 @@ Func_7a28: ; 7a28 (1:7a28) call PrintText ld hl, wNumBoxItems ; wNumBoxItems ld a, l - ld [wcf8b], a + ld [wList], a ld a, h - ld [wcf8c], a + ld [wList + 1], a xor a ld [wcf93], a ld a, $3 @@ -205,9 +205,9 @@ Func_7aa5: ; 7aa5 (1:7aa5) call PrintText ld hl, wNumBoxItems ; wNumBoxItems ld a, l - ld [wcf8b], a + ld [wList], a ld a, h - ld [wcf8c], a + ld [wList + 1], a xor a ld [wcf93], a ld a, $3 diff --git a/engine/menu/start_sub_menus.asm b/engine/menu/start_sub_menus.asm index 1bedb0ea5b..589224ab1c 100755 --- a/engine/menu/start_sub_menus.asm +++ b/engine/menu/start_sub_menus.asm @@ -308,10 +308,10 @@ StartMenu_Item: ; 13302 (4:7302) jr .exitMenu .notInCableClubRoom ld bc,wNumBagItems - ld hl,wcf8b + ld hl,wList ld a,c ld [hli],a - ld [hl],b ; store item bag pointer at wcf8b (for DisplayListMenuID) + ld [hl],b ; store item bag pointer at wList (for DisplayListMenuID) xor a ld [wcf93],a ld a,ITEMLISTMENU diff --git a/engine/menu/status_screen.asm b/engine/menu/status_screen.asm index 2fc5e7132e..79daa0c08a 100755 --- a/engine/menu/status_screen.asm +++ b/engine/menu/status_screen.asm @@ -4,11 +4,11 @@ StatusScreen: ; 12953 (4:6953) ld a, [wcc49] cp $2 ; 2 means we're in a PC box jr c, .DontRecalculate ; 0x1295b $14 - ld a, [wcf9b] - ld [wcfb9], a + ld a, [wLoadedMonBoxLevel] + ld [wLoadedMonLevel], a ld [W_CURENEMYLVL], a - ld hl, wcfa8 - ld de, wcfba + ld hl, wLoadedMonHPExp - 1 + ld de, wLoadedMonStats ld b, $1 call CalcStats ; Recalculate stats .DontRecalculate @@ -61,7 +61,7 @@ StatusScreen: ; 12953 (4:6953) ld b, $3 call GoPAL_SET ; SGB palette hlCoord 16, 6 - ld de, wcf9c + ld de, wLoadedMonStatus call PrintStatusCondition jr nz, .StatusWritten ; 0x129fc $9 hlCoord 16, 6 @@ -96,7 +96,7 @@ StatusScreen: ; 12953 (4:6953) hlCoord 12, 16 call PlaceString ; OT hlCoord 12, 14 - ld de, wcfa4 + ld de, wLoadedMonOTID ld bc, $8205 ; 5 call PrintNumber ; ID Number ld d, $0 @@ -203,14 +203,14 @@ PrintStatsBox: ; 12ae4 (4:6ae4) pop hl pop bc add hl, bc - ld de, wcfbc + ld de, wLoadedMonAttack ld bc, $0203 ; three digits call PrintStat - ld de, wcfbe + ld de, wLoadedMonDefense call PrintStat - ld de, wcfc0 + ld de, wLoadedMonSpeed call PrintStat - ld de, wcfc2 + ld de, wLoadedMonSpecial jp PrintNumber PrintStat push hl @@ -235,7 +235,7 @@ StatusScreen2: ; 12b57 (4:6b57) ld bc, $0005 ld hl, wd0dc call FillMemory - ld hl, wcfa0 + ld hl, wLoadedMonMoves ld de, wd0dc ld bc, $0004 call CopyData @@ -269,7 +269,7 @@ StatusScreen2: ; 12b57 (4:6b57) ld a, "-" call Func_12ccb ; Fill the rest with -- .InitPP ; 12bbb - ld hl, wcfa0 + ld hl, wLoadedMonMoves deCoord 14, 10 ld b, $0 .PrintPP ; 12bc3 @@ -323,12 +323,12 @@ StatusScreen2: ; 12b57 (4:6b57) hlCoord 9, 3 ld de, EXPPointsText call PlaceString - ld a, [wcfb9] ; level + ld a, [wLoadedMonLevel] ; level push af cp MAX_LEVEL jr z, .Level100 ; 0x12c20 $4 inc a - ld [wcfb9], a ; Increase temporarily if not 100 + ld [wLoadedMonLevel], a ; Increase temporarily if not 100 .Level100 hlCoord 14, 6 ld [hl], $70 ; 1-tile "to" @@ -336,13 +336,13 @@ StatusScreen2: ; 12b57 (4:6b57) inc hl call PrintLevel pop af - ld [wcfb9], a - ld de, wcfa6 + ld [wLoadedMonLevel], a + ld de, wLoadedMonExp hlCoord 12, 4 ld bc, $0307 call PrintNumber ; exp call .asm_12c86 - ld de, wcfa6 + ld de, wLoadedMonExp hlCoord 7, 6 ld bc, $0307 call PrintNumber @@ -368,13 +368,13 @@ StatusScreen2: ; 12b57 (4:6b57) call GBPalWhiteOut jp ClearScreen .asm_12c86 ; This does some magic with lvl/exp? - ld a, [wcfb9] ; Load level + ld a, [wLoadedMonLevel] ; Load level cp MAX_LEVEL jr z, .asm_12ca7 ; 0x12c8b $1a ; If 100 inc a ld d, a callab CalcExperience - ld hl, wcfa8 + ld hl, wLoadedMonExp + 2 ld a, [$ff98] sub [hl] ld [hld], a @@ -386,7 +386,7 @@ StatusScreen2: ; 12b57 (4:6b57) ld [hld], a ret .asm_12ca7 - ld hl, wcfa6 + ld hl, wLoadedMonExp xor a ld [hli], a ld [hli], a diff --git a/engine/overworld/map_sprites.asm b/engine/overworld/map_sprites.asm index 81443c9ff1..1640375980 100755 --- a/engine/overworld/map_sprites.asm +++ b/engine/overworld/map_sprites.asm @@ -159,7 +159,7 @@ LoadMapSpriteTilePatterns: ; 17871 (5:7871) ld l,e pop de ld b,a - ld a,[wcfc4] + ld a,[wCharRAMInUseForText] bit 0,a ; reloading upper half of tile patterns after displaying text? jr nz,.skipFirstLoad ; if so, skip loading data into the lower half ld a,b @@ -180,7 +180,7 @@ LoadMapSpriteTilePatterns: ; 17871 (5:7871) jr nc,.noCarry3 inc d .noCarry3 - ld a,[wcfc4] + ld a,[wCharRAMInUseForText] bit 0,a ; reloading upper half of tile patterns after displaying text? jr nz,.loadWhileLCDOn pop af @@ -264,7 +264,7 @@ InitOutsideMapSprites: ; 1797b (5:797b) cp a,$f0 ; does the map have 2 sprite sets? call nc,GetSplitMapSpriteSetID ; if so, choose the appropriate one ld b,a ; b = spriteSetID - ld a,[wcfc4] + ld a,[wCharRAMInUseForText] bit 0,a ; reloading upper half of tile patterns after displaying text? jr nz,.loadSpriteSet ; if so, forcibly reload the sprite set ld a,[W_SPRITESETID] diff --git a/engine/overworld/movement.asm b/engine/overworld/movement.asm index 3b9cac7db8..1658b0e9b2 100644 --- a/engine/overworld/movement.asm +++ b/engine/overworld/movement.asm @@ -52,7 +52,7 @@ UpdatePlayerSprite: ; 4e31 (1:4e31) jr .asm_4eab .asm_4e86 ld [wSpriteStateData1 + 9], a - ld a, [wcfc4] + ld a, [wCharRAMInUseForText] bit 0, a jr nz, .asm_4e7d .asm_4e90 @@ -130,7 +130,7 @@ Func_4ed1: ; 4ed1 (1:4ed1) bit 7, a jp nz, InitializeSpriteFacingDirection ; c1x1 >= $80 ld b, a - ld a, [wcfc4] + ld a, [wCharRAMInUseForText] bit 0, a jp nz, notYetMoving ld a, b diff --git a/engine/overworld/pokemart.asm b/engine/overworld/pokemart.asm index 4bc4c34156..8325b93f84 100755 --- a/engine/overworld/pokemart.asm +++ b/engine/overworld/pokemart.asm @@ -50,9 +50,9 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20) call DisplayTextBoxID ; draw money text box ld hl,wNumBagItems ld a,l - ld [wcf8b],a + ld [wList],a ld a,h - ld [wcf8c],a + ld [wList + 1],a xor a ld [wcf93],a ld [wCurrentMenuItem],a @@ -124,9 +124,9 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20) call DisplayTextBoxID ; draw money text box ld hl,wStringBuffer2 + 11 ld a,l - ld [wcf8b],a + ld [wList],a ld a,h - ld [wcf8c],a + ld [wList + 1],a xor a ld [wCurrentMenuItem],a inc a diff --git a/engine/predefs7.asm b/engine/predefs7.asm index b6c3bbbc79..e2f58ca8b4 100755 --- a/engine/predefs7.asm +++ b/engine/predefs7.asm @@ -3,9 +3,9 @@ Func_1c9c6: ; 1c9c6 (7:49c6) call PrintText ld hl, wStringBuffer2 + 11 ld a, l - ld [wcf8b], a + ld [wList], a ld a, h - ld [wcf8c], a + ld [wList + 1], a ld a, [wListScrollOffset] ; wcc36 push af xor a diff --git a/home.asm b/home.asm index be56a70afa..ef7d35bb10 100644 --- a/home.asm +++ b/home.asm @@ -239,7 +239,7 @@ DrawHPBar:: ; 1336 (0:1336) ret -; loads pokemon data from one of multiple sources to wcf98 +; loads pokemon data from one of multiple sources to wLoadedMon ; loads base stats to W_MONHDEXNUM ; INPUT: ; [wWhichPokemon] = index of pokemon within party/box @@ -250,7 +250,7 @@ DrawHPBar:: ; 1336 (0:1336) ; 03: daycare ; OUTPUT: ; [wcf91] = pokemon ID -; wcf98 = base address of pokemon data +; wLoadedMon = base address of pokemon data ; W_MONHDEXNUM = base address of base stats LoadMonData:: ; 1372 (0:1372) ld hl, LoadMonData_ @@ -515,12 +515,12 @@ PrintStatusConditionNotFainted ; 14f6 ; function to print pokemon level, leaving off the ":L" if the level is at least 100 ; INPUT: ; hl = destination address -; [wcfb9] = level +; [wLoadedMonLevel] = level PrintLevel:: ; 150b (0:150b) ld a,$6e ; ":L" tile ID ld [hli],a ld c,2 ; number of digits - ld a,[wcfb9] ; level + ld a,[wLoadedMonLevel] ; level cp a,100 jr c,PrintLevelCommon ; if level at least 100, write over the ":L" tile @@ -531,12 +531,12 @@ PrintLevel:: ; 150b (0:150b) ; prints the level without leaving off ":L" regardless of level ; INPUT: ; hl = destination address -; [wcfb9] = level +; [wLoadedMonLevel] = level PrintLevelFull:: ; 151b (0:151b) ld a,$6e ; ":L" tile ID ld [hli],a ld c,3 ; number of digits - ld a,[wcfb9] ; level + ld a,[wLoadedMonLevel] ; level PrintLevelCommon:: ; 1523 (0:1523) ld [wd11e],a @@ -1183,7 +1183,7 @@ CloseTextDisplay:: ; 29e8 (0:29e8) ld [H_LOADEDROMBANK],a ld [$2000],a call InitMapSprites ; reload sprite tile pattern data (since it was partially overwritten by text tile patterns) - ld hl,wcfc4 + ld hl,wCharRAMInUseForText res 0,[hl] ld a,[wd732] bit 3,a ; used fly warp @@ -1372,7 +1372,7 @@ AddItemToInventory:: ; 2bcf (0:2bcf) ; INPUT: ; [wListMenuID] = list menu ID -; [wcf8b] = address of the list (2 bytes) +; [wList] = address of the list (2 bytes) DisplayListMenuID:: ; 2be6 (0:2be6) xor a ld [H_AUTOBGTRANSFERENABLED],a ; disable auto-transfer @@ -1392,9 +1392,9 @@ DisplayListMenuID:: ; 2be6 (0:2be6) xor a ld [wMenuItemToSwap],a ; 0 means no item is currently being swapped ld [wd12a],a - ld a,[wcf8b] + ld a,[wList] ld l,a - ld a,[wcf8c] + ld a,[wList + 1] ld h,a ; hl = address of the list ld a,[hl] ld [wd12a],a ; [wd12a] = number of list entries @@ -1485,9 +1485,9 @@ DisplayListMenuIDLoop:: ; 2c53 (0:2c53) ; if it's an item menu sla c ; item entries are 2 bytes long, so multiply by 2 .skipMultiplying - ld a,[wcf8b] + ld a,[wList] ld l,a - ld a,[wcf8c] + ld a,[wList + 1] ld h,a inc hl ; hl = beginning of list entries ld b,0 @@ -1516,7 +1516,7 @@ DisplayListMenuIDLoop:: ; 2c53 (0:2c53) jr .storeChosenEntry .pokemonList ld hl,wPartyCount - ld a,[wcf8b] + ld a,[wList] cp l ; is it a list of party pokemon or box pokemon? ld hl,wPartyMonNicks jr z,.getPokemonName @@ -1707,9 +1707,9 @@ PrintListMenuEntries:: ; 2e5a (0:2e5a) ld b,$09 ld c,$0e call ClearScreenArea - ld a,[wcf8b] + ld a,[wList] ld e,a - ld a,[wcf8c] + ld a,[wList + 1] ld d,a inc de ; de = beginning of list entries ld a,[wListScrollOffset] @@ -1753,7 +1753,7 @@ PrintListMenuEntries:: ; 2e5a (0:2e5a) .pokemonPCMenu push hl ld hl,wPartyCount - ld a,[wcf8b] + ld a,[wList] cp l ; is it a list of party pokemon or box pokemon? ld hl,wPartyMonNicks jr z,.getPokemonName @@ -1798,7 +1798,7 @@ PrintListMenuEntries:: ; 2e5a (0:2e5a) push af push hl ld hl,wPartyCount - ld a,[wcf8b] + ld a,[wList] cp l ; is it a list of party pokemon or box pokemon? ld a,$00 jr z,.next @@ -1819,8 +1819,8 @@ PrintListMenuEntries:: ; 2e5a (0:2e5a) and a ; is it a list of party pokemon or box pokemon? jr z,.skipCopyingLevel .copyLevel - ld a,[wcf9b] - ld [wcfb9],a + ld a,[wLoadedMonBoxLevel] + ld [wLoadedMonLevel],a .skipCopyingLevel pop hl ld bc,$001c @@ -3335,11 +3335,11 @@ GetName:: ; 376b (0:376b) ret GetItemPrice:: ; 37df (0:37df) -; Stores item's price as BCD in [H_DOWNARROWBLINKCNT1] and [[H_DOWNARROWBLINKCNT2] +; Stores item's price as BCD at hItemPrice (3 bytes) ; Input: [wcf91] = item id ld a, [H_LOADEDROMBANK] push af - ld a, [wListMenuID] ; wListMenuID + ld a, [wListMenuID] cp MOVESLISTMENU ld a, BANK(ItemPrices) jr nz, .asm_37ed @@ -3347,7 +3347,7 @@ GetItemPrice:: ; 37df (0:37df) .asm_37ed ld [H_LOADEDROMBANK], a ld [$2000], a - ld hl, wcf8f + ld hl, wItemPrices ld a, [hli] ld h, [hl] ld l, a @@ -3361,11 +3361,11 @@ GetItemPrice:: ; 37df (0:37df) jr nz, .asm_3802 dec hl ld a, [hld] - ld [$ff8d], a + ld [hItemPrice + 2], a ld a, [hld] - ld [H_DOWNARROWBLINKCNT2], a ; $ff8c + ld [hItemPrice + 1], a ld a, [hl] - ld [H_DOWNARROWBLINKCNT1], a ; $ff8b + ld [hItemPrice], a jr .asm_381c .getTMPrice ld a, Bank(GetMachinePrice) @@ -3373,7 +3373,7 @@ GetItemPrice:: ; 37df (0:37df) ld [$2000], a call GetMachinePrice .asm_381c - ld de, H_DOWNARROWBLINKCNT1 ; $ff8b + ld de, hItemPrice pop af ld [H_LOADEDROMBANK], a ld [$2000], a @@ -4540,7 +4540,7 @@ GetHealthBarColor:: ; Copy the current map's sprites' tile patterns to VRAM again after they have ; been overwritten by other tile patterns. ReloadMapSpriteTilePatterns:: ; 3e08 (0:3e08) - ld hl, wcfc4 + ld hl, wCharRAMInUseForText ld a, [hl] push af res 0, [hl] diff --git a/hram.asm b/hram.asm index 29eb435336..da56997ecb 100644 --- a/hram.asm +++ b/hram.asm @@ -12,6 +12,8 @@ hSoftReset EQU $FF8A hBaseTileID EQU $FF8B +hItemPrice EQU $FF8B + ; counters for blinking down arrow H_DOWNARROWBLINKCNT1 EQU $FF8B H_DOWNARROWBLINKCNT2 EQU $FF8C @@ -152,6 +154,7 @@ H_CURRENTSPRITEOFFSET EQU $FFDA ; multiple of $10 H_WHOSETURN EQU $FFF3 ; 0 on player’s turn, 1 on enemy’s turn ; bit 0: draw HP fraction to the right of bar instead of below (for party menu) +; bit 1: menu is double spaced hFlags_0xFFF6 EQU $FFF6 hJoyInput EQU $FFF8 diff --git a/main.asm b/main.asm index 6f5b532474..a342b2b94c 100755 --- a/main.asm +++ b/main.asm @@ -85,7 +85,7 @@ LoadMonData_: ; 1: enemymon ; 2: boxmon ; 3: daycaremon -; Return monster id at wcf91 and its data at wcf98. +; Return monster id at wcf91 and its data at wLoadedMon. ; Also load base stats at W_MONHDEXNUM for convenience. ld a, [wDayCareMonSpecies] @@ -125,7 +125,7 @@ LoadMonData_: call AddNTimes .copyMonData - ld de, wcf98 + ld de, wLoadedMon ld bc, wPartyMon2 - wPartyMon1 jp CopyData @@ -808,7 +808,7 @@ HandleItemListSwapping: ; 6b44 (1:6b44) cp a,ITEMLISTMENU jp nz,DisplayListMenuIDLoop ; only rearrange item list menus push hl - ld hl,wcf8b + ld hl,wList ld a,[hli] ld h,[hl] ld l,a @@ -854,7 +854,7 @@ HandleItemListSwapping: ; 6b44 (1:6b44) call DelayFrames push hl push de - ld hl,wcf8b + ld hl,wList ld a,[hli] ld h,[hl] ld l,a @@ -916,7 +916,7 @@ HandleItemListSwapping: ; 6b44 (1:6b44) jr .done .combineItemSlots ld [hl],a ; put the sum in the second item slot - ld hl,wcf8b + ld hl,wList ld a,[hli] ld h,[hl] ld l,a @@ -1022,7 +1022,7 @@ DisplayTextIDInit: ; 7096 (1:7096) .drawTextBoxBorder call TextBoxBorder .skipDrawingTextBoxBorder - ld hl,wcfc4 + ld hl,wCharRAMInUseForText set 0,[hl] ld hl,wFlags_0xcd60 bit 4,[hl] @@ -3823,8 +3823,8 @@ _AddEnemyMonToPlayerParty: ; f49d (3:749d) call AddNTimes ld e, l ld d, h - ld hl, wcf98 - call CopyData ; write new mon's data (from wcf98) + ld hl, wLoadedMon + call CopyData ; write new mon's data (from wLoadedMon) ld hl, wPartyMonOT ld a, [wPartyCount] dec a diff --git a/scripts/ceruleanhouse2.asm b/scripts/ceruleanhouse2.asm index 3fa7218394..a40d922478 100755 --- a/scripts/ceruleanhouse2.asm +++ b/scripts/ceruleanhouse2.asm @@ -22,9 +22,9 @@ CeruleanHouse2Text1: ; 74e15 (1d:4e15) call LoadItemList ld hl, wStringBuffer2 + 11 ld a, l - ld [wcf8b], a + ld [wList], a ld a, h - ld [wcf8c], a + ld [wList + 1], a xor a ld [wcf93], a ld [wMenuItemToSwap], a diff --git a/wram.asm b/wram.asm index 389b4cc4c2..2cde6d126d 100755 --- a/wram.asm +++ b/wram.asm @@ -786,12 +786,15 @@ wStringBuffer2:: ; cf70 wStringBuffer3:: ; cf81 ds 9 + 1 -wcf8b:: ds 1 -wcf8c:: ds 1 +wList:: ; cf8b + ds 2 + wcf8d:: ds 1 wcf8e:: ds 1 -wcf8f:: ds 1 -wcf90:: ds 1 + +wItemPrices:: ; cf8f + ds 2 + wcf91:: ds 1 wWhichPokemon:: ; cf92 @@ -807,25 +810,15 @@ wListMenuID:: ; cf94 wcf95:: ds 1 wcf96:: ds 1 wcf97:: ds 1 -wcf98:: ds 1 -wcf99:: ds 1 -wcf9a:: ds 1 -wcf9b:: ds 1 -wcf9c:: ds 4 -wcfa0:: ds 4 -wcfa4:: ds 2 -wcfa6:: ds 2 -wcfa8:: ds 7 -wcfaf:: ds 10 -wcfb9:: ds 1 -wcfba:: ds 1 -wcfbb:: ds 1 -wcfbc:: ds 2 -wcfbe:: ds 2 -wcfc0:: ds 2 -wcfc2:: ds 2 - -wcfc4:: ds 1 + +; LoadMonData copies mon data here +wLoadedMon:: party_struct wLoadedMon ; cf98 + +wCharRAMInUseForText:: ; cfc4 +; bit 0: the space in VRAM that is used to store walking tile patterns for +; the player and NPCs is in use for text tile patterns. this means +; that movement must be disabled. + ds 1 wWalkCounter:: ; cfc5 ; walk animation counter From 72bbaed99f725b2b8b0d2653968042ce1625354c Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Sat, 7 Feb 2015 22:18:42 -0800 Subject: [PATCH 096/100] fixed hp bar wram label and misc --- engine/battle/1.asm | 2 +- engine/battle/4.asm | 22 +++---- engine/battle/4_2.asm | 22 +++---- engine/battle/core.asm | 8 +-- engine/battle/e.asm | 2 +- engine/battle/e_2.asm | 2 +- engine/clear_save.asm | 4 +- engine/give_pokemon.asm | 2 +- engine/hp_bar.asm | 2 +- engine/items/items.asm | 46 ++++++------- engine/menu/bills_pc.asm | 120 +++++++++++++++++----------------- engine/menu/party_menu.asm | 2 +- engine/menu/players_pc.asm | 52 +++++++-------- engine/menu/status_screen.asm | 2 +- engine/predefs.asm | 2 +- engine/predefs7.asm | 12 ++-- engine/save.asm | 2 +- engine/titlescreen.asm | 12 ++-- engine/town_map.asm | 4 +- home.asm | 4 +- wram.asm | 6 ++ 21 files changed, 169 insertions(+), 161 deletions(-) diff --git a/engine/battle/1.asm b/engine/battle/1.asm index ccc82c5591..517d53d1ec 100755 --- a/engine/battle/1.asm +++ b/engine/battle/1.asm @@ -77,7 +77,7 @@ DrainHPEffect_: ; 783f (1:783f) hlCoord 2, 2 xor a .next2 - ld [wListMenuID], a + ld [wHPBarType], a predef UpdateHPBar2 predef DrawPlayerHUDAndHPBar predef DrawEnemyHUDAndHPBar diff --git a/engine/battle/4.asm b/engine/battle/4.asm index 97db1ba313..e96267c476 100755 --- a/engine/battle/4.asm +++ b/engine/battle/4.asm @@ -18,27 +18,28 @@ IsPlayerJustOutsideMap: ; 128d8 (4:68d8) DrawHP: ; 128ef (4:68ef) call GetPredefRegisters ld a, $1 - jr asm_128fb + jr DrawHP_ -Func_128f6: ; 128f6 (4:68f6) +DrawHP2: ; 128f6 (4:68f6) call GetPredefRegisters ld a, $2 -asm_128fb: ; 128fb (4:68fb) - ld [wListMenuID], a + +DrawHP_: ; 128fb (4:68fb) + ld [wHPBarType], a push hl ld a, [wLoadedMonHP] ld b, a ld a, [wLoadedMonHP + 1] ld c, a or b - jr nz, .asm_12913 + jr nz, .nonzeroHP xor a ld c, a ld e, a ld a, $6 ld d, a - jp DrawHPBarAndFraction -.asm_12913 + jp .drawHPBarAndPrintFraction +.nonzeroHP ld a, [wLoadedMonMaxHP] ld d, a ld a, [wLoadedMonMaxHP + 1] @@ -47,8 +48,7 @@ asm_128fb: ; 128fb (4:68fb) ld a, $6 ld d, a ld c, a - -DrawHPBarAndFraction: ; 12924 (4:6924) +.drawHPBarAndPrintFraction pop hl push de push hl @@ -59,10 +59,10 @@ DrawHPBarAndFraction: ; 12924 (4:6924) bit 0, a jr z, .printFractionBelowBar ld bc, $9 ; right of bar - jr .printHPFraction + jr .printFraction .printFractionBelowBar ld bc, SCREEN_WIDTH + 1 ; below bar -.printHPFraction +.printFraction add hl, bc ld de, wLoadedMonHP ld bc, $203 diff --git a/engine/battle/4_2.asm b/engine/battle/4_2.asm index 287c8eae7c..8d8c6077bd 100755 --- a/engine/battle/4_2.asm +++ b/engine/battle/4_2.asm @@ -207,16 +207,16 @@ WildMonEncounterSlotChances: ; 13918 (4:7918) db $FF, $12 ; 3/256 = 1.2% chance of slot 9 RecoilEffect_: ; 1392c (4:792c) - ld a, [H_WHOSETURN] ; $fff3 + ld a, [H_WHOSETURN] and a - ld a, [W_PLAYERMOVENUM] ; wcfd2 - ld hl, wBattleMonMaxHP ; wd023 + ld a, [W_PLAYERMOVENUM] + ld hl, wBattleMonMaxHP jr z, .asm_1393d - ld a, [W_ENEMYMOVENUM] ; W_ENEMYMOVENUM - ld hl, wEnemyMonMaxHP ; wEnemyMonMaxHP + ld a, [W_ENEMYMOVENUM] + ld hl, wEnemyMonMaxHP .asm_1393d ld d, a - ld a, [W_DAMAGE] ; W_DAMAGE + ld a, [W_DAMAGE] ld b, a ld a, [W_DAMAGE + 1] ld c, a @@ -260,16 +260,16 @@ RecoilEffect_: ; 1392c (4:792c) ld [hl], a .asm_13982 hlCoord 10, 9 - ld a, [H_WHOSETURN] ; $fff3 + ld a, [H_WHOSETURN] and a ld a, $1 jr z, .asm_13990 hlCoord 2, 2 xor a .asm_13990 - ld [wListMenuID], a ; wListMenuID + ld [wHPBarType], a predef UpdateHPBar2 - ld hl, HitWithRecoilText ; $799e + ld hl, HitWithRecoilText jp PrintText HitWithRecoilText: ; 1399e (4:799e) TX_FAR _HitWithRecoilText @@ -392,8 +392,8 @@ GetTrainerName_: ; 13a58 (4:7a58) ld a, [wLinkState] and a jr nz, .rival - ld hl, W_RIVALNAME ; wd34a - ld a, [W_TRAINERCLASS] ; wd031 + ld hl, W_RIVALNAME + ld a, [W_TRAINERCLASS] cp SONY1 jr z, .rival cp SONY2 diff --git a/engine/battle/core.asm b/engine/battle/core.asm index a502ed7c97..d51abb43c2 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -768,7 +768,7 @@ UpdateCurMonHPBar: ; 3c4f6 (f:44f6) xor a .playersTurn push bc - ld [wListMenuID], a + ld [wHPBarType], a predef UpdateHPBar2 pop bc ret @@ -2029,7 +2029,7 @@ DrawEnemyHUDAndHPBar: ; 3cdec (f:4dec) ld c, a .drawHPBar xor a - ld [wListMenuID], a + ld [wHPBarType], a hlCoord 2, 2 call DrawHPBar ld a, $1 @@ -4899,7 +4899,7 @@ ApplyDamageToEnemyPokemon: ; 3e142 (f:6142) ld [wHPBarNewHP],a hlCoord 2, 2 xor a - ld [wListMenuID],a + ld [wHPBarType],a predef UpdateHPBar2 ; animate the HP bar shortening ApplyAttackToEnemyPokemonDone: ; 3e19d (f:619d) jp DrawHUDsAndHPBars @@ -5017,7 +5017,7 @@ ApplyDamageToPlayerPokemon: ; 3e200 (f:6200) ld [wHPBarMaxHP],a hlCoord 10, 9 ld a,$01 - ld [wListMenuID],a + ld [wHPBarType],a predef UpdateHPBar2 ; animate the HP bar shortening ApplyAttackToPlayerPokemonDone jp DrawHUDsAndHPBars diff --git a/engine/battle/e.asm b/engine/battle/e.asm index ff3ac83962..5592702aa6 100755 --- a/engine/battle/e.asm +++ b/engine/battle/e.asm @@ -1174,7 +1174,7 @@ Func_3a718: ; 3a718 (e:6718) call AIPrintItemUse_ hlCoord 2, 2 xor a - ld [wListMenuID],a + ld [wHPBarType],a predef UpdateHPBar2 jp DecrementAICount diff --git a/engine/battle/e_2.asm b/engine/battle/e_2.asm index 1106f531ec..9400282d19 100755 --- a/engine/battle/e_2.asm +++ b/engine/battle/e_2.asm @@ -91,7 +91,7 @@ HealEffect_: ; 3b9ec (e:79ec) hlCoord 2, 2 xor a .asm_3ba83 - ld [wListMenuID], a + ld [wHPBarType], a predef UpdateHPBar2 ld hl, DrawHUDsAndHPBars call BankswitchEtoF diff --git a/engine/clear_save.asm b/engine/clear_save.asm index c11405316b..66d7e9202c 100755 --- a/engine/clear_save.asm +++ b/engine/clear_save.asm @@ -1,4 +1,4 @@ -Func_1c98a: ; 1c98a (7:498a) +DoClearSaveDialogue: ; 1c98a (7:498a) call ClearScreen call GoPAL_SET_CF1C call LoadFontTilePatterns @@ -15,7 +15,7 @@ Func_1c98a: ; 1c98a (7:498a) ld a, [wCurrentMenuItem] and a jp z, Init - callba Func_73b6a + callba ClearSAV jp Init ClearSaveDataText: ; 1c9c1 (7:49c1) diff --git a/engine/give_pokemon.asm b/engine/give_pokemon.asm index d4d58d33c9..64876d22ca 100755 --- a/engine/give_pokemon.asm +++ b/engine/give_pokemon.asm @@ -14,7 +14,7 @@ _GivePokemon: ; 4fda5 (13:7da5) ld [wEnemyMonSpecies2], a callab LoadEnemyMonData call SetPokedexOwnedFlag - callab Func_e7a4 + callab SendNewMonToBox ld hl, wcf4b ld a, [wd5a0] and $7f diff --git a/engine/hp_bar.asm b/engine/hp_bar.asm index a53511c765..333b0b90f7 100755 --- a/engine/hp_bar.asm +++ b/engine/hp_bar.asm @@ -203,7 +203,7 @@ UpdateHPBar_CalcHPDifference: ; fad7 (3:7ad7) UpdateHPBar_PrintHPNumber: ; faf5 (3:7af5) push af push de - ld a, [wListMenuID] ; wListMenuID + ld a, [wHPBarType] and a jr z, .asm_fb2d ld a, [wHPBarOldHP] diff --git a/engine/items/items.asm b/engine/items/items.asm index 99c97feffc..aaee94032f 100755 --- a/engine/items/items.asm +++ b/engine/items/items.asm @@ -430,7 +430,7 @@ ItemUseBall: ; d687 (3:5687) jr .End .sendToBox ;$5907 call ClearSprites - call Func_e7a4 + call SendNewMonToBox ld hl,ItemUseBallText07 ld a,[wd7f1] bit 0,a ;already met Bill? @@ -923,7 +923,7 @@ ItemUseMedicine: ; dabb (3:5abb) set 0,a ld [hFlags_0xFFF6],a ld a,$02 - ld [wListMenuID],a + ld [wHPBarType],a predef UpdateHPBar2 ; animate HP bar decrease of pokemon that used Softboiled ld a,[hFlags_0xFFF6] res 0,a @@ -1073,7 +1073,7 @@ ItemUseMedicine: ; dabb (3:5abb) set 0,a ld [hFlags_0xFFF6],a ld a,$02 - ld [wListMenuID],a + ld [wHPBarType],a predef UpdateHPBar2 ; animate the HP bar lengthening ld a,[hFlags_0xFFF6] res 0,a @@ -1090,7 +1090,7 @@ ItemUseMedicine: ; dabb (3:5abb) jr .showHealingItemMessage .playStatusAilmentCuringSound ld a,(SFX_02_3e - SFX_Headers_02) / 3 ; status ailment curing sound - call PlaySoundWaitForCurrent ; play sound + call PlaySoundWaitForCurrent .showHealingItemMessage xor a ld [H_AUTOBGTRANSFERENABLED],a @@ -1102,7 +1102,7 @@ ItemUseMedicine: ; dabb (3:5abb) ld [H_AUTOBGTRANSFERENABLED],a ld c,50 call DelayFrames - call WaitForTextScrollButtonPress ; wait for a button press + call WaitForTextScrollButtonPress jr .done .canceledItemUse xor a @@ -1118,7 +1118,7 @@ ItemUseMedicine: ; dabb (3:5abb) ld a,[W_ISINBATTLE] and a ret nz - jp ReloadMapData ; restore saved screen + jp ReloadMapData .useVitamin push hl ld a,[hl] @@ -2567,7 +2567,7 @@ IsKeyItem_: ; e764 (3:6764) INCLUDE "data/key_items.asm" -Func_e7a4: ; e7a4 (3:67a4) +SendNewMonToBox: ; e7a4 (3:67a4) ld de, W_NUMINBOX ; wda80 ld a, [de] inc a @@ -2818,49 +2818,51 @@ ItemUseReloadOverworldData: ; e9c5 (3:69c5) call LoadCurrentMapView jp UpdateSprites -Func_e9cb: ; e9cb (3:69cb) - ld hl, WildDataPointers ; $4eeb - ld de, wHPBarMaxHP +; creates a list at wBuffer of maps where the mon in [wd11e] can be found. +; this is used by the pokedex to display locations the mon can be found on the map. +FindWildLocationsOfMon: ; e9cb (3:69cb) + ld hl, WildDataPointers + ld de, wBuffer ld c, $0 -.asm_e9d3 +.loop inc hl ld a, [hld] inc a - jr z, .asm_e9ec + jr z, .done push hl ld a, [hli] ld h, [hl] ld l, a ld a, [hli] and a - call nz, Func_e9f0 + call nz, CheckMapForMon ; land ld a, [hli] and a - call nz, Func_e9f0 + call nz, CheckMapForMon ; water pop hl inc hl inc hl inc c - jr .asm_e9d3 -.asm_e9ec - ld a, $ff + jr .loop +.done + ld a, $ff ; list terminator ld [de], a ret -Func_e9f0: ; e9f0 (3:69f0) +CheckMapForMon: ; e9f0 (3:69f0) inc hl ld b, $a -.asm_e9f3 +.loop ld a, [wd11e] cp [hl] - jr nz, .asm_e9fc + jr nz, .nextEntry ld a, c ld [de], a inc de -.asm_e9fc +.nextEntry inc hl inc hl dec b - jr nz, .asm_e9f3 + jr nz, .loop dec hl ret diff --git a/engine/menu/bills_pc.asm b/engine/menu/bills_pc.asm index 9e8422c05f..f4a40cf9b4 100644 --- a/engine/menu/bills_pc.asm +++ b/engine/menu/bills_pc.asm @@ -1,6 +1,6 @@ Func_213c8:: ; 213c8 (8:53c8) xor a - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba + ld [H_AUTOBGTRANSFERENABLED], a call SaveScreenTilesToBuffer2 ld a, [wd5a2] and a @@ -28,64 +28,64 @@ Func_213c8:: ; 213c8 (8:53c8) call TextBoxBorder call UpdateSprites ld a, $3 - ld [wMaxMenuItem], a ; wMaxMenuItem + ld [wMaxMenuItem], a ld a, [wd7f1] bit 0, a jr nz, .asm_21414 hlCoord 2, 2 - ld de, SomeonesPCText ; $548b + ld de, SomeonesPCText jr .asm_2141a .asm_21414 hlCoord 2, 2 - ld de, BillsPCText ; $5497 + ld de, BillsPCText .asm_2141a call PlaceString hlCoord 2, 4 - ld de, wPlayerName ; wd158 + ld de, wPlayerName call PlaceString ld l, c ld h, b - ld de, PlayersPCText ; $54a0 + ld de, PlayersPCText call PlaceString ld a, [wd74b] bit 5, a jr z, .asm_21462 hlCoord 2, 6 - ld de, OaksPCText ; $54a5 + ld de, OaksPCText call PlaceString ld a, [wd5a2] and a jr z, .asm_2145a ld a, $4 - ld [wMaxMenuItem], a ; wMaxMenuItem + ld [wMaxMenuItem], a hlCoord 2, 8 - ld de, PKMNLeaguePCText ; $54b2 + ld de, PKMNLeaguePCText call PlaceString hlCoord 2, 10 - ld de, LogOffPCText ; $54ba + ld de, LogOffPCText jr .asm_2146d .asm_2145a hlCoord 2, 8 - ld de, LogOffPCText ; $54ba + ld de, LogOffPCText jr .asm_2146d .asm_21462 ld a, $2 - ld [wMaxMenuItem], a ; wMaxMenuItem + ld [wMaxMenuItem], a hlCoord 2, 6 - ld de, LogOffPCText ; $54ba + ld de, LogOffPCText .asm_2146d call PlaceString ld a, $3 - ld [wMenuWatchedKeys], a ; wMenuWatchedKeys + ld [wMenuWatchedKeys], a ld a, $2 - ld [wTopMenuItemY], a ; wTopMenuItemY + ld [wTopMenuItemY], a ld a, $1 - ld [wTopMenuItemX], a ; wTopMenuItemX + ld [wTopMenuItemX], a xor a - ld [wCurrentMenuItem], a ; wCurrentMenuItem - ld [wLastMenuItem], a ; wLastMenuItem + ld [wCurrentMenuItem], a + ld [wLastMenuItem], a ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba + ld [H_AUTOBGTRANSFERENABLED], a ret SomeonesPCText: db "SOMEONE's PC@" @@ -103,7 +103,7 @@ BillsPC_:: ; 0x214c2 inc a ; MONSTER_NAME ld [W_LISTTYPE], a call LoadHpBarAndStatusTilePatterns - ld a, [wListScrollOffset] ; wcc36 + ld a, [wListScrollOffset] push af ld a, [wFlags_0xcd60] bit 3, a @@ -116,9 +116,9 @@ BillsPC_:: ; 0x214c2 Func_214e8: ; 214e8 (8:54e8) BillsPCMenu: ld a, [wccd3] - ld [wCurrentMenuItem], a ; wCurrentMenuItem + ld [wCurrentMenuItem], a ld hl, vChars2 + $780 - ld de, PokeballTileGraphics ; $697e + ld de, PokeballTileGraphics ld bc, (BANK(PokeballTileGraphics) << 8) + $01 call CopyVideoData call LoadScreenTilesFromBuffer2DisableBGTransfer @@ -127,9 +127,9 @@ BillsPCMenu: ld c, $c call TextBoxBorder hlCoord 2, 2 - ld de, BillsPCMenuText ; $56e1 + ld de, BillsPCMenuText call PlaceString - ld hl, wTopMenuItemY ; wTopMenuItemY + ld hl, wTopMenuItemY ld a, $2 ld [hli], a dec a @@ -143,10 +143,10 @@ BillsPCMenu: xor a ld [hli], a ld [hli], a - ld hl, wListScrollOffset ; wcc36 + ld hl, wListScrollOffset ld [hli], a ld [hl], a - ld [wPlayerMonNumber], a ; wPlayerMonNumber + ld [wPlayerMonNumber], a ld hl, WhatText call PrintText hlCoord 9, 14 @@ -167,16 +167,16 @@ BillsPCMenu: .asm_21551 Coorda 18, 16 hlCoord 10, 16 - ld de, BoxNoPCText ; $5713 + ld de, BoxNoPCText call PlaceString ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba + ld [H_AUTOBGTRANSFERENABLED], a call Delay3 call HandleMenuInput bit 1, a jp nz, Func_21588 ; b button call PlaceUnfilledArrowMenuCursor - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + ld a, [wCurrentMenuItem] ld [wccd3], a and a jp z, Func_21618 ; withdraw @@ -200,28 +200,28 @@ Func_21588: ; 21588 (8:5588) res 5, [hl] call LoadScreenTilesFromBuffer2 pop af - ld [wListScrollOffset], a ; wcc36 + ld [wListScrollOffset], a ld hl, wd730 res 6, [hl] ret Func_215ac: ; 215ac (8:55ac) BillsPCDeposit: - ld a, [wPartyCount] ; wPartyCount + ld a, [wPartyCount] dec a jr nz, .asm_215bb ld hl, CantDepositLastMonText call PrintText jp BillsPCMenu .asm_215bb - ld a, [W_NUMINBOX] ; wda80 + ld a, [W_NUMINBOX] cp MONS_PER_BOX jr nz, .asm_215cb - ld hl, BoxFullText ; $5802 + ld hl, BoxFullText call PrintText jp BillsPCMenu .asm_215cb - ld hl, wPartyCount ; wPartyCount + ld hl, wPartyCount call Func_216be jp c, BillsPCMenu call Func_2174b @@ -236,7 +236,7 @@ BillsPCDeposit: ld [wcf95], a call RemovePokemon call WaitForSoundToFinish - ld hl, wWhichTrade ; wWhichTrade + ld hl, wWhichTrade ld a, [wd5a0] and $7f cp 9 @@ -251,31 +251,31 @@ BillsPCDeposit: .asm_2160c ld [hli], a ld [hl], $50 - ld hl, MonWasStoredText ; $57f8 + ld hl, MonWasStoredText call PrintText jp BillsPCMenu Func_21618: ; 21618 (8:5618) - ld a, [W_NUMINBOX] ; wda80 + ld a, [W_NUMINBOX] and a jr nz, .asm_21627 - ld hl, NoMonText ; $580c + ld hl, NoMonText call PrintText jp Func_214e8 .asm_21627 - ld a, [wPartyCount] ; wPartyCount + ld a, [wPartyCount] cp PARTY_LENGTH jr nz, .asm_21637 - ld hl, CantTakeMonText ; $5811 + ld hl, CantTakeMonText call PrintText jp Func_214e8 .asm_21637 - ld hl, W_NUMINBOX ; wda80 + ld hl, W_NUMINBOX call Func_216be jp c, Func_214e8 call Func_2174b jp nc, Func_214e8 - ld a, [wWhichPokemon] ; wWhichPokemon + ld a, [wWhichPokemon] ld hl, wBoxMonNicks call GetPartyMonName ld a, [wcf91] @@ -288,25 +288,25 @@ Func_21618: ; 21618 (8:5618) ld [wcf95], a call RemovePokemon call WaitForSoundToFinish - ld hl, MonIsTakenOutText ; $5807 + ld hl, MonIsTakenOutText call PrintText jp Func_214e8 Func_21673: ; 21673 (8:5673) - ld a, [W_NUMINBOX] ; wda80 + ld a, [W_NUMINBOX] and a jr nz, .asm_21682 - ld hl, NoMonText ; $580c + ld hl, NoMonText call PrintText jp Func_214e8 .asm_21682 - ld hl, W_NUMINBOX ; wda80 + ld hl, W_NUMINBOX call Func_216be jp c, Func_214e8 - ld hl, OnceReleasedText ; $581b + ld hl, OnceReleasedText call PrintText call YesNoChoice - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + ld a, [wCurrentMenuItem] and a jr nz, .asm_21682 inc a @@ -315,7 +315,7 @@ Func_21673: ; 21673 (8:5673) call WaitForSoundToFinish ld a, [wcf91] call PlayCry - ld hl, MonWasReleasedText ; $5820 + ld hl, MonWasReleasedText call PrintText jp Func_214e8 @@ -330,13 +330,13 @@ Func_216be: ; 216be (8:56be) ld [wList + 1], a xor a ld [wcf93], a - ld [wListMenuID], a ; wListMenuID + ld [wListMenuID], a inc a ; MONSTER_NAME ld [W_LISTTYPE], a ld a, [wcc2b] - ld [wCurrentMenuItem], a ; wCurrentMenuItem + ld [wCurrentMenuItem], a call DisplayListMenuID - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + ld a, [wCurrentMenuItem] ld [wcc2b], a ret @@ -368,7 +368,7 @@ Func_2171b:: ; 2171b (8:571b) ld a, [hli] push hl push bc - ld hl, HMMoveArray ; $5745 + ld hl, HMMoveArray ld de, 1 call IsInArray pop bc @@ -394,16 +394,16 @@ Func_2174b: ; 2174b (8:574b) call TextBoxBorder ld a, [wccd3] and a - ld de, DepositPCText ; $57cb + ld de, DepositPCText jr nz, .asm_21761 - ld de, WithdrawPCText ; $57d3 + ld de, WithdrawPCText .asm_21761 hlCoord 11, 12 call PlaceString hlCoord 11, 14 - ld de, StatsCancelPCText ; $57dc + ld de, StatsCancelPCText call PlaceString - ld hl, wTopMenuItemY ; wTopMenuItemY + ld hl, wTopMenuItemY ld a, $c ld [hli], a ld a, $a @@ -417,16 +417,16 @@ Func_2174b: ; 2174b (8:574b) ld [hli], a xor a ld [hl], a - ld hl, wListScrollOffset ; wcc36 + ld hl, wListScrollOffset ld [hli], a ld [hl], a - ld [wPlayerMonNumber], a ; wPlayerMonNumber + ld [wPlayerMonNumber], a ld [wcc2b], a .asm_2178f call HandleMenuInput bit 1, a jr nz, .asm_2179f - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + ld a, [wCurrentMenuItem] and a jr z, .asm_217a1 dec a diff --git a/engine/menu/party_menu.asm b/engine/menu/party_menu.asm index 86474be9c0..97e520c211 100755 --- a/engine/menu/party_menu.asm +++ b/engine/menu/party_menu.asm @@ -92,7 +92,7 @@ RedrawPartyMenu_: ; 12ce3 (4:6ce3) set 0,a ld [hFlags_0xFFF6],a add hl,bc - predef Func_128f6 ; draw HP bar and prints current / max HP + predef DrawHP2 ; draw HP bar and prints current / max HP ld a,[hFlags_0xFFF6] res 0,a ld [hFlags_0xFFF6],a diff --git a/engine/menu/players_pc.asm b/engine/menu/players_pc.asm index 5217befa08..ad6c814059 100755 --- a/engine/menu/players_pc.asm +++ b/engine/menu/players_pc.asm @@ -17,7 +17,7 @@ PlayerPC: ; 78e6 (1:78e6) Func_790c: ; 790c (1:790c) ld a, [wccd3] - ld [wCurrentMenuItem], a ; wCurrentMenuItem + ld [wCurrentMenuItem], a ld hl, wFlags_0xcd60 set 5, [hl] call LoadScreenTilesFromBuffer2 @@ -27,9 +27,9 @@ Func_790c: ; 790c (1:790c) call TextBoxBorder call UpdateSprites hlCoord 2, 2 - ld de, PlayersPCMenuEntries ; $7af5 + ld de, PlayersPCMenuEntries call PlaceString - ld hl, wTopMenuItemY ; wTopMenuItemY + ld hl, wTopMenuItemY ld a, $2 ld [hli], a dec a @@ -42,17 +42,17 @@ Func_790c: ; 790c (1:790c) ld [hli], a xor a ld [hl], a - ld hl, wListScrollOffset ; wcc36 + ld hl, wListScrollOffset ld [hli], a ld [hl], a - ld [wPlayerMonNumber], a ; wPlayerMonNumber + ld [wPlayerMonNumber], a ld hl, WhatDoYouWantText call PrintText call HandleMenuInput bit 1, a jp nz, Func_796d call PlaceUnfilledArrowMenuCursor - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + ld a, [wCurrentMenuItem] ld [wccd3], a and a jp z, Func_7a12 @@ -73,7 +73,7 @@ Func_796d: ; 796d (1:796d) res 5, [hl] call LoadScreenTilesFromBuffer2 xor a - ld [wListScrollOffset], a ; wcc36 + ld [wListScrollOffset], a ld [wcc2c], a ld hl, wd730 res 6, [hl] @@ -83,9 +83,9 @@ Func_796d: ; 796d (1:796d) Func_7995: ; 7995 (1:7995) xor a - ld [wCurrentMenuItem], a ; wCurrentMenuItem - ld [wListScrollOffset], a ; wcc36 - ld a, [wNumBagItems] ; wNumBagItems + ld [wCurrentMenuItem], a + ld [wListScrollOffset], a + ld a, [wNumBagItems] and a jr nz, Func_79ab ld hl, NothingToDepositText @@ -95,7 +95,7 @@ Func_7995: ; 7995 (1:7995) Func_79ab: ; 79ab (1:79ab) ld hl, WhatToDepositText call PrintText - ld hl, wNumBagItems ; wNumBagItems + ld hl, wNumBagItems ld a, l ld [wList], a ld a, h @@ -103,7 +103,7 @@ Func_79ab: ; 79ab (1:79ab) xor a ld [wcf93], a ld a, $3 - ld [wListMenuID], a ; wListMenuID + ld [wListMenuID], a call DisplayListMenuID jp c, Func_790c call IsKeyItem @@ -118,14 +118,14 @@ Func_79ab: ; 79ab (1:79ab) cp $ff jp z, Func_79ab .asm_79e7 - ld hl, wNumBoxItems ; wNumBoxItems + ld hl, wNumBoxItems call AddItemToInventory jr c, .asm_79f8 ld hl, NoRoomToStoreText call PrintText jp Func_79ab .asm_79f8 - ld hl, wNumBagItems ; wNumBagItems + ld hl, wNumBagItems call RemoveItemFromInventory call WaitForSoundToFinish ld a, (SFX_02_55 - SFX_Headers_02) / 3 @@ -137,9 +137,9 @@ Func_79ab: ; 79ab (1:79ab) Func_7a12: ; 7a12 (1:7a12) xor a - ld [wCurrentMenuItem], a ; wCurrentMenuItem - ld [wListScrollOffset], a ; wcc36 - ld a, [wNumBoxItems] ; wNumBoxItems + ld [wCurrentMenuItem], a + ld [wListScrollOffset], a + ld a, [wNumBoxItems] and a jr nz, Func_7a28 ld hl, NothingStoredText @@ -149,7 +149,7 @@ Func_7a12: ; 7a12 (1:7a12) Func_7a28: ; 7a28 (1:7a28) ld hl, WhatToWithdrawText call PrintText - ld hl, wNumBoxItems ; wNumBoxItems + ld hl, wNumBoxItems ld a, l ld [wList], a ld a, h @@ -157,7 +157,7 @@ Func_7a28: ; 7a28 (1:7a28) xor a ld [wcf93], a ld a, $3 - ld [wListMenuID], a ; wListMenuID + ld [wListMenuID], a call DisplayListMenuID jp c, Func_790c call IsKeyItem @@ -172,14 +172,14 @@ Func_7a28: ; 7a28 (1:7a28) cp $ff jp z, Func_7a28 .asm_7a64 - ld hl, wNumBagItems ; wNumBagItems + ld hl, wNumBagItems call AddItemToInventory jr c, .asm_7a75 ld hl, CantCarryMoreText call PrintText jp Func_7a28 .asm_7a75 - ld hl, wNumBoxItems ; wNumBoxItems + ld hl, wNumBoxItems call RemoveItemFromInventory call WaitForSoundToFinish ld a, (SFX_02_55 - SFX_Headers_02) / 3 @@ -191,9 +191,9 @@ Func_7a28: ; 7a28 (1:7a28) Func_7a8f: ; 7a8f (1:7a8f) xor a - ld [wCurrentMenuItem], a ; wCurrentMenuItem - ld [wListScrollOffset], a ; wcc36 - ld a, [wNumBoxItems] ; wNumBoxItems + ld [wCurrentMenuItem], a + ld [wListScrollOffset], a + ld a, [wNumBoxItems] and a jr nz, Func_7aa5 ld hl, NothingStoredText @@ -203,7 +203,7 @@ Func_7a8f: ; 7a8f (1:7a8f) Func_7aa5: ; 7aa5 (1:7aa5) ld hl, WhatToTossText call PrintText - ld hl, wNumBoxItems ; wNumBoxItems + ld hl, wNumBoxItems ld a, l ld [wList], a ld a, h @@ -211,7 +211,7 @@ Func_7aa5: ; 7aa5 (1:7aa5) xor a ld [wcf93], a ld a, $3 - ld [wListMenuID], a ; wListMenuID + ld [wListMenuID], a push hl call DisplayListMenuID pop hl diff --git a/engine/menu/status_screen.asm b/engine/menu/status_screen.asm index 79daa0c08a..685839cb2d 100755 --- a/engine/menu/status_screen.asm +++ b/engine/menu/status_screen.asm @@ -55,7 +55,7 @@ StatusScreen: ; 12953 (4:6953) ld de, Type1Text call PlaceString ; "TYPE1/" hlCoord 11, 3 - predef DrawHP ; predef $5f + predef DrawHP ld hl, wcf25 call GetHealthBarColor ld b, $3 diff --git a/engine/predefs.asm b/engine/predefs.asm index f2bedf962e..23eb8cd164 100755 --- a/engine/predefs.asm +++ b/engine/predefs.asm @@ -148,6 +148,6 @@ PredefPointers:: ; 4fe79 (13:7e79) add_predef PrintMoveType add_predef LoadMovePPs add_predef DrawHP ; 5F - add_predef Func_128f6 + add_predef DrawHP2 add_predef Func_1c9c6 add_predef OaksAideScript diff --git a/engine/predefs7.asm b/engine/predefs7.asm index e2f58ca8b4..9786c097cb 100755 --- a/engine/predefs7.asm +++ b/engine/predefs7.asm @@ -6,23 +6,23 @@ Func_1c9c6: ; 1c9c6 (7:49c6) ld [wList], a ld a, h ld [wList + 1], a - ld a, [wListScrollOffset] ; wcc36 + ld a, [wListScrollOffset] push af xor a - ld [wCurrentMenuItem], a ; wCurrentMenuItem - ld [wListScrollOffset], a ; wcc36 + ld [wCurrentMenuItem], a + ld [wListScrollOffset], a ld [wcf93], a ld a, $4 - ld [wListMenuID], a ; wListMenuID + ld [wListMenuID], a call DisplayListMenuID pop bc ld a, b - ld [wListScrollOffset], a ; wcc36 + ld [wListScrollOffset], a ret c ld hl, wd126 set 7, [hl] ld hl, wcc5b - ld a, [wWhichPokemon] ; wWhichPokemon + ld a, [wWhichPokemon] add a ld d, $0 ld e, a diff --git a/engine/save.asm b/engine/save.asm index c123187183..d3127f046e 100755 --- a/engine/save.asm +++ b/engine/save.asm @@ -665,7 +665,7 @@ HallOfFame_Copy: ; 73b51 (1c:7b51) ld [MBC1SRamEnable], a ret -Func_73b6a: ; 73b6a (1c:7b6a) +ClearSAV: ; 73b6a (1c:7b6a) ld a, SRAM_ENABLE ld [MBC1SRamEnable], a ld a, $1 diff --git a/engine/titlescreen.asm b/engine/titlescreen.asm index 5e8a15d512..ed23fbc459 100755 --- a/engine/titlescreen.asm +++ b/engine/titlescreen.asm @@ -237,14 +237,14 @@ ENDC call LoadGBPal ld a, [hJoyHeld] ld b, a - and $46 - cp $46 - jp z, Func_448e + and D_UP | SELECT | B_BUTTON + cp D_UP | SELECT | B_BUTTON + jp z, .doClearSaveDialogue jp MainMenu -Func_448e: ; 448e (1:448e) - ld b, BANK(Func_1c98a) - ld hl, Func_1c98a +.doClearSaveDialogue + ld b, BANK(DoClearSaveDialogue) + ld hl, DoClearSaveDialogue jp Bankswitch Func_4496: ; 4496 (1:4496) diff --git a/engine/town_map.asm b/engine/town_map.asm index dece8d1ff8..7974cf1a22 100755 --- a/engine/town_map.asm +++ b/engine/town_map.asm @@ -364,10 +364,10 @@ Func_711c4: ; 711c4 (1c:51c4) jp CopyData Func_711ef: ; 711ef (1c:51ef) - callba Func_e9cb + callba FindWildLocationsOfMon call Func_712d9 ld hl, wOAMBuffer - ld de, wHPBarMaxHP + ld de, wBuffer .asm_71200 ld a, [de] cp $ff diff --git a/home.asm b/home.asm index ef7d35bb10..1557755aa9 100644 --- a/home.asm +++ b/home.asm @@ -173,7 +173,7 @@ LoadDestinationWarpPosition:: ; 1313 (0:1313) DrawHPBar:: ; 1336 (0:1336) ; Draw an HP bar d tiles long, and fill it to e pixels. ; If c is nonzero, show at least a sliver regardless. -; The right end of the bar changes with [wListMenuID]. +; The right end of the bar changes with [wHPBarType]. push hl push de @@ -195,7 +195,7 @@ DrawHPBar:: ; 1336 (0:1336) jr nz, .draw ; Right - ld a,[wListMenuID] + ld a,[wHPBarType] dec a ld a, $6d ; status screen and battle jr z, .ok diff --git a/wram.asm b/wram.asm index 2cde6d126d..b2fd4eb881 100755 --- a/wram.asm +++ b/wram.asm @@ -803,6 +803,12 @@ wWhichPokemon:: ; cf92 wcf93:: ds 1 +wHPBarType:: ; cf94 +; type of HP bar +; $00 = enemy HUD in battle +; $01 = player HUD in battle / status screen +; $02 = party menu + wListMenuID:: ; cf94 ; ID used by DisplayListMenuID ds 1 From 1347023128e141dc4cfc71ee6bc689f909e96919 Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Sun, 8 Feb 2015 00:17:03 -0800 Subject: [PATCH 097/100] move-related things --- engine/battle/core.asm | 8 +++---- engine/battle/e.asm | 41 ++++++++++++++++++----------------- engine/evos_moves.asm | 2 +- engine/items/items.asm | 2 +- engine/items/tmhm.asm | 8 +++---- engine/items/tms.asm | 4 ++-- engine/learn_move.asm | 12 +++++----- engine/menu/status_screen.asm | 10 ++++----- home.asm | 6 ++--- wram.asm | 15 +++++++++---- 10 files changed, 58 insertions(+), 50 deletions(-) diff --git a/engine/battle/core.asm b/engine/battle/core.asm index d51abb43c2..5c25e5b0d0 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -2533,14 +2533,14 @@ MoveSelectionMenu: ; 3d219 (f:5219) jr .regularmenu .loadmoves - ld de, wd0dc - ld bc, $4 + ld de, wMoves + ld bc, NUM_MOVES call CopyData - callab Func_39b87 + callab FormatMovesString ret .writemoves - ld de, wd0e1 + ld de, wMovesString ld a, [hFlags_0xFFF6] set 2, a ld [hFlags_0xFFF6], a diff --git a/engine/battle/e.asm b/engine/battle/e.asm index 5592702aa6..d60718cc52 100755 --- a/engine/battle/e.asm +++ b/engine/battle/e.asm @@ -577,14 +577,15 @@ TrainerPicAndMoneyPointers: ; 39914 (e:5914) INCLUDE "text/trainer_names.asm" -Func_39b87: ; 39b87 (e:5b87) - ld hl, wd0dc - ld de, wd0e1 +; formats a string at wMovesString that lists the moves at wMoves +FormatMovesString: ; 39b87 (e:5b87) + ld hl, wMoves + ld de, wMovesString ld b, $0 -.asm_39b8f +.printMoveNameLoop ld a, [hli] - and a - jr z, .asm_39bc1 + and a ; end of move list? + jr z, .printDashLoop ; print dashes when no moves are left push hl ld [wd0b5], a ld a, BANK(MoveNames) @@ -593,38 +594,38 @@ Func_39b87: ; 39b87 (e:5b87) ld [W_LISTTYPE], a call GetName ld hl, wcd6d -.asm_39ba7 +.copyNameLoop ld a, [hli] cp $50 - jr z, .asm_39bb0 + jr z, .doneCopyingName ld [de], a inc de - jr .asm_39ba7 -.asm_39bb0 + jr .copyNameLoop +.doneCopyingName ld a, b ld [wcd6c], a inc b - ld a, $4e + ld a, $4e ; line break ld [de], a inc de pop hl ld a, b - cp $4 - jr z, .asm_39bd1 - jr .asm_39b8f -.asm_39bc1 + cp NUM_MOVES + jr z, .done + jr .printMoveNameLoop +.printDashLoop ld a, "-" ld [de], a inc de inc b ld a, b - cp $4 - jr z, .asm_39bd1 - ld a, $4e + cp NUM_MOVES + jr z, .done + ld a, $4e ; line break ld [de], a inc de - jr .asm_39bc1 -.asm_39bd1 + jr .printDashLoop +.done ld a, "@" ld [de], a ret diff --git a/engine/evos_moves.asm b/engine/evos_moves.asm index 2eef7ba76f..86b49d309c 100755 --- a/engine/evos_moves.asm +++ b/engine/evos_moves.asm @@ -364,7 +364,7 @@ LearnMoveFromLevelUp: ; 3af5b (e:6f5b) dec b jr nz, .checkCurrentMovesLoop ld a, d - ld [wd0e0], a + ld [wMoveNum], a ld [wd11e], a call GetMoveName call CopyStringToCF4B diff --git a/engine/items/items.asm b/engine/items/items.asm index aaee94032f..c9b1aead52 100755 --- a/engine/items/items.asm +++ b/engine/items/items.asm @@ -2084,7 +2084,7 @@ ItemUseTMHM: ; e479 (3:6479) ld [wd11e],a predef TMToMove ; get move ID from TM/HM ID ld a,[wd11e] - ld [wd0e0],a + ld [wMoveNum],a call GetMoveName call CopyStringToCF4B ; copy name to wcf4b pop af diff --git a/engine/items/tmhm.asm b/engine/items/tmhm.asm index 01a48ebb4c..0fcc5710fc 100755 --- a/engine/items/tmhm.asm +++ b/engine/items/tmhm.asm @@ -1,12 +1,12 @@ -; checks if the mon in wWhichPokemon already knows the move in wd0e0 +; checks if the mon in [wWhichPokemon] already knows the move in [wMoveNum] CheckIfMoveIsKnown: ; 2fe18 (b:7e18) ld a, [wWhichPokemon] ld hl, wPartyMon1Moves - ld bc, $2c + ld bc, wPartyMon2 - wPartyMon1 call AddNTimes - ld a, [wd0e0] + ld a, [wMoveNum] ld b, a - ld c, $4 ; nubmer of moves + ld c, NUM_MOVES .loop ld a, [hli] cp b diff --git a/engine/items/tms.asm b/engine/items/tms.asm index ef42786095..511aab5b17 100755 --- a/engine/items/tms.asm +++ b/engine/items/tms.asm @@ -1,11 +1,11 @@ -; tests if mon [wcf91] can learn move [wd0e0] +; tests if mon [wcf91] can learn move [wMoveNum] CanLearnTM: ; 1373e (4:773e) ld a, [wcf91] ld [wd0b5], a call GetMonHeader ld hl, W_MONHLEARNSET push hl - ld a, [wd0e0] + ld a, [wMoveNum] ld b, a ld c, $0 ld hl, TechnicalMachines diff --git a/engine/learn_move.asm b/engine/learn_move.asm index c991058d40..75056edba3 100755 --- a/engine/learn_move.asm +++ b/engine/learn_move.asm @@ -36,7 +36,7 @@ DontAbandonLearning: ; 6e5b (1:6e5b) pop de pop hl .asm_6e8b - ld a, [wd0e0] + ld a, [wMoveNum] ld [hl], a ld bc, $15 add hl, bc @@ -64,7 +64,7 @@ DontAbandonLearning: ; 6e5b (1:6e5b) ld h, d ld l, e ld de, wBattleMonMoves - ld bc, $4 + ld bc, NUM_MOVES call CopyData ld bc, $11 add hl, bc @@ -111,10 +111,10 @@ TryingToLearn: ; 6f07 (1:6f07) ld bc, $fffc add hl, bc push hl - ld de, wd0dc - ld bc, $4 + ld de, wMoves + ld bc, NUM_MOVES call CopyData - callab Func_39b87 + callab FormatMovesString pop hl .asm_6f39 push hl @@ -125,7 +125,7 @@ TryingToLearn: ; 6f07 (1:6f07) ld c, $e call TextBoxBorder hlCoord 6, 8 - ld de, wd0e1 + ld de, wMovesString ld a, [hFlags_0xFFF6] set 2, a ld [hFlags_0xFFF6], a diff --git a/engine/menu/status_screen.asm b/engine/menu/status_screen.asm index 685839cb2d..f95a071059 100755 --- a/engine/menu/status_screen.asm +++ b/engine/menu/status_screen.asm @@ -233,13 +233,13 @@ StatusScreen2: ; 12b57 (4:6b57) ld [hTilesetType], a ld [$ffba], a ld bc, $0005 - ld hl, wd0dc + ld hl, wMoves call FillMemory ld hl, wLoadedMonMoves - ld de, wd0dc - ld bc, $0004 + ld de, wMoves + ld bc, NUM_MOVES call CopyData - callab Func_39b87 + callab FormatMovesString hlCoord 9, 2 ld bc, $050a call ClearScreenArea ; Clear under name @@ -250,7 +250,7 @@ StatusScreen2: ; 12b57 (4:6b57) ld c, $12 call TextBoxBorder ; Draw move container hlCoord 2, 9 - ld de, wd0e1 + ld de, wMovesString call PlaceString ; Print moves ld a, [wcd6c] inc a diff --git a/home.asm b/home.asm index 1557755aa9..e9f37763dc 100644 --- a/home.asm +++ b/home.asm @@ -259,8 +259,8 @@ LoadMonData:: ; 1372 (0:1372) Func_137a:: ; 137a (0:137a) -; Write c to [wd0dc + b]. Unused. - ld hl, wd0dc +; Write c to [wMoves + b]. Unused. + ld hl, wMoves ld e, b ld d, 0 add hl, de @@ -546,7 +546,7 @@ PrintLevelCommon:: ; 1523 (0:1523) Func_152e:: ; 152e (0:152e) ; Unused. - ld hl,wd0dc + ld hl,wMoves ld c,a ld b,0 add hl,bc diff --git a/wram.asm b/wram.asm index b2fd4eb881..ba641ec32d 100755 --- a/wram.asm +++ b/wram.asm @@ -1275,10 +1275,17 @@ ds 2 wRepelRemainingSteps:: ; wd0db ds 1 - -wd0dc:: ds 4 -wd0e0:: ds 1 -wd0e1:: ds 56 + +wMoves:: ; wd0dc +; list of moves for FormatMovesString + ds 4 + +wMoveNum:: ; d0e0 + ds 1 + +wMovesString:: ; d0e1 + ds 56 + wd119:: ds 1 wWalkBikeSurfStateCopy:: ; d11a From 3870f5e10a1e17f35c78b176272df6b1f516f24e Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Sun, 8 Feb 2015 01:44:41 -0800 Subject: [PATCH 098/100] named misc functions --- constants/misc_constants.asm | 2 +- engine/battle/4_2.asm | 4 +- engine/battle/core.asm | 21 +++-- engine/battle/e.asm | 177 ++++++++++++++++++----------------- engine/evos_moves.asm | 2 +- engine/items/items.asm | 2 +- engine/menu/bills_pc.asm | 4 +- engine/menu/players_pc.asm | 2 +- engine/predefs.asm | 2 +- home.asm | 10 +- main.asm | 2 +- wram.asm | 20 +++- 12 files changed, 133 insertions(+), 115 deletions(-) diff --git a/constants/misc_constants.asm b/constants/misc_constants.asm index d2270b6c3c..3452a393dd 100644 --- a/constants/misc_constants.asm +++ b/constants/misc_constants.asm @@ -82,4 +82,4 @@ LINK_STATE_START_TRADE EQU $02 ; pre-trade selection screen initialisation LINK_STATE_START_BATTLE EQU $03 ; pre-battle initialisation LINK_STATE_BATTLING EQU $04 ; in a link battle LINK_STATE_RESET EQU $05 ; reset game (unused) -LINK_STATE_TRADING EQU $32 ; in a link trade \ No newline at end of file +LINK_STATE_TRADING EQU $32 ; in a link trade diff --git a/engine/battle/4_2.asm b/engine/battle/4_2.asm index 8d8c6077bd..bac0a2d13c 100755 --- a/engine/battle/4_2.asm +++ b/engine/battle/4_2.asm @@ -60,7 +60,7 @@ EndOfBattle: ; 137aa (4:77aa) ld [hli], a ld [hl], a ld [wListScrollOffset], a - ld hl, wd060 + ld hl, wPlayerStatsToDouble ld b, $18 .loop ld [hli], a @@ -402,7 +402,7 @@ GetTrainerName_: ; 13a58 (4:7a58) jr z, .rival ld [wd0b5], a ld a, TRAINER_NAME - ld [W_LISTTYPE], a + ld [wNameListType], a ld a, BANK(TrainerNames) ld [wPredefBank], a call GetName diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 5c25e5b0d0..63be567636 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -839,7 +839,7 @@ FaintEnemyPokemon ; 0x3c567 res AttackingMultipleTimes, [hl] xor a ld [wPlayerNumHits], a - ld hl, wd065 ; clear enemy statuses + ld hl, wEnemyStatsToDouble ; clear enemy statuses ld [hli], a ld [hli], a ld [hli], a @@ -1366,7 +1366,7 @@ EnemySendOut: ; 3c90e (f:490e) ; don't change wPartyGainExpFlags or wPartyFoughtCurrentEnemyFlags EnemySendOutFirstMon: ; 3c92a (f:492a) xor a - ld hl,wd065 ; clear enemy statuses + ld hl,wEnemyStatsToDouble ; clear enemy statuses ld [hli],a ld [hli],a ld [hli],a @@ -1815,7 +1815,7 @@ SendOutMon: ; 3cc91 (f:4c91) ld hl, wPlayerUsedMove ld [hli], a ld [hl], a - ld hl, wd060 + ld hl, wPlayerStatsToDouble ld [hli], a ld [hli], a ld [hli], a @@ -5671,7 +5671,7 @@ EnemyCanExecuteChargingMove: ; 3e70b (f:670b) ld a, BANK(MoveNames) ld [wPredefBank], a ld a, MOVE_NAME - ld [W_LISTTYPE], a + ld [wNameListType], a call GetName ld de, wcd6d call CopyStringToCF4B @@ -6148,7 +6148,7 @@ GetCurrentMove: ; 3eabe (f:6abe) ld a, BANK(MoveNames) ld [wPredefBank], a ld a, MOVE_NAME - ld [W_LISTTYPE], a + ld [wNameListType], a call GetName ld de, wcd6d jp CopyStringToCF4B @@ -6339,7 +6339,7 @@ DoBattleTransitionAndInitBattleVariables: ; 3ec32 (f:6c32) ld [hWY], a ld [rWY], a ld [hTilesetType], a - ld hl, wd060 + ld hl, wPlayerStatsToDouble ld [hli], a ld [hli], a ld [hli], a @@ -6423,10 +6423,11 @@ LoadPlayerBackPic: ; 3ec92 (f:6c92) hlCoord 1, 5 predef_jump Func_3f0c6 -Func_3ed02: ; 3ed02 (f:6d02) - callab Func_39680 - ld hl, Func_396a7 - ld b, BANK(Func_396a7) +; does nothing since no stats are ever selected (barring glitches) +DoubleOrHalveSelectedStats: ; 3ed02 (f:6d02) + callab DoubleSelectedStats + ld hl, HalveSelectedStats + ld b, BANK(HalveSelectedStats) jp Bankswitch ScrollTrainerPicAfterBattle: ; 3ed12 (f:6d12) diff --git a/engine/battle/e.asm b/engine/battle/e.asm index d60718cc52..d124b77ab3 100755 --- a/engine/battle/e.asm +++ b/engine/battle/e.asm @@ -1,24 +1,25 @@ -Func_39680: ; 39680 (e:5680) - ld a, [H_WHOSETURN] ; $fff3 +; does nothing since no stats are ever selected (barring glitches) +DoubleSelectedStats: ; 39680 (e:5680) + ld a, [H_WHOSETURN] and a - ld a, [wd060] + ld a, [wPlayerStatsToDouble] ld hl, wBattleMonAttack + 1 - jr z, .asm_39691 - ld a, [wd065] + jr z, .notEnemyTurn + ld a, [wEnemyStatsToDouble] ld hl, wEnemyMonAttack + 1 -.asm_39691 - ld c, $4 +.notEnemyTurn + ld c, 4 ld b, a -.asm_39694 +.loop srl b - call c, Func_3969f + call c, .doubleStat inc hl inc hl dec c ret z - jr .asm_39694 + jr .loop -Func_3969f: ; 3969f (e:569f) +.doubleStat ld a, [hl] add a ld [hld], a @@ -27,35 +28,36 @@ Func_3969f: ; 3969f (e:569f) ld [hli], a ret -Func_396a7: ; 396a7 (e:56a7) - ld a, [H_WHOSETURN] ; $fff3 +; does nothing since no stats are ever selected (barring glitches) +HalveSelectedStats: ; 396a7 (e:56a7) + ld a, [H_WHOSETURN] and a - ld a, [wd061] + ld a, [wPlayerStatsToHalve] ld hl, wBattleMonAttack - jr z, .asm_396b8 - ld a, [wd066] + jr z, .notEnemyTurn + ld a, [wEnemyStatsToHalve] ld hl, wEnemyMonAttack -.asm_396b8 - ld c, $4 +.notEnemyTurn + ld c, 4 ld b, a -.asm_396bb +.loop srl b - call c, Func_396c6 + call c, .halveStat inc hl inc hl dec c ret z - jr .asm_396bb + jr .loop -Func_396c6: ; 396c6 (e:56c6) +.halveStat ld a, [hl] srl a ld [hli], a rr [hl] or [hl] - jr nz, .asm_396d1 - ld [hl], $1 -.asm_396d1 + jr nz, .nonzeroStat + ld [hl], 1 +.nonzeroStat dec hl ret @@ -69,41 +71,42 @@ _ScrollTrainerPicAfterBattle: ; 396d3 (e:56d3) callab _LoadTrainerPic hlCoord 19, 0 ld c, $0 -.asm_396e9 +.scrollLoop inc c ld a, c - cp $7 + cp 7 ret z ld d, $0 push bc push hl -.asm_396f2 - call Func_39707 +.drawTrainerPicLoop + call DrawTrainerPicColumn inc hl - ld a, $7 + ld a, 7 add d ld d, a dec c - jr nz, .asm_396f2 - ld c, $4 + jr nz, .drawTrainerPicLoop + ld c, 4 call DelayFrames pop hl pop bc dec hl - jr .asm_396e9 + jr .scrollLoop -Func_39707: ; 39707 (e:5707) +; write one 7-tile column of the trainer pic to the tilemap +DrawTrainerPicColumn: ; 39707 (e:5707) push hl push de push bc - ld e, $7 -.asm_3970c + ld e, 7 +.loop ld [hl], d - ld bc, $14 + ld bc, SCREEN_WIDTH add hl, bc inc d dec e - jr nz, .asm_3970c + jr nz, .loop pop bc pop de pop hl @@ -591,7 +594,7 @@ FormatMovesString: ; 39b87 (e:5b87) ld a, BANK(MoveNames) ld [wPredefBank], a ld a, MOVE_NAME - ld [W_LISTTYPE], a + ld [wNameListType], a call GetName ld hl, wcd6d .copyNameLoop @@ -630,41 +633,42 @@ FormatMovesString: ; 39b87 (e:5b87) ld [de], a ret +; XXX this is called in a few places, but it doesn't appear to do anything useful Func_39bd5: ; 39bd5 (e:5bd5) ld a, [wd11b] cp $1 jr nz, .asm_39be6 - ld hl, wEnemyPartyCount ; wEnemyPartyCount - ld de, wEnemyMonOT ; wd9ac OT names of other player - ld a, $6 + ld hl, wEnemyPartyCount + ld de, wEnemyMonOT + ld a, ENEMYOT_NAME jr .asm_39c18 .asm_39be6 cp $4 jr nz, .calcAttackStat4 - ld hl, wPartyCount ; wPartyCount - ld de, wPartyMonOT ; wd273 - ld a, $5 + ld hl, wPartyCount + ld de, wPartyMonOT + ld a, PLAYEROT_NAME jr .asm_39c18 .calcAttackStat4 cp $5 jr nz, .asm_39c02 ld hl, wStringBuffer2 + 11 - ld de, MonsterNames ; $421e - ld a, $1 + ld de, MonsterNames + ld a, MONSTER_NAME jr .asm_39c18 .asm_39c02 cp $2 jr nz, .asm_39c10 - ld hl, wNumBagItems ; wNumBagItems - ld de, ItemNames ; $472b - ld a, $4 + ld hl, wNumBagItems + ld de, ItemNames + ld a, ITEM_NAME jr .asm_39c18 .asm_39c10 ld hl, wStringBuffer2 + 11 - ld de, ItemNames ; $472b + ld de, ItemNames ld a, ITEM_NAME .asm_39c18 - ld [W_LISTTYPE], a + ld [wNameListType], a ld a, l ld [wList], a ld a, h @@ -680,19 +684,20 @@ Func_39bd5: ; 39bd5 (e:5bd5) ld [wItemPrices + 1], a ret -Func_39c37: ; 39c37 (e:5c37) +; get species of mon e in list [wcc49] for LoadMonData +GetMonSpecies: ; 39c37 (e:5c37) ld hl, wPartySpecies ld a, [wcc49] and a - jr z, .asm_39c4b + jr z, .getSpecies dec a - jr z, .asm_39c48 + jr z, .enemyParty ld hl, wBoxSpecies - jr .asm_39c4b -.asm_39c48 + jr .getSpecies +.enemyParty ld hl, wEnemyPartyMons -.asm_39c4b - ld d, $0 +.getSpecies + ld d, 0 add hl, de ld a, [hl] ld [wcf91], a @@ -955,7 +960,7 @@ TrainerAIPointers: ; 3a55c (e:655c) JugglerAI: ; 3a5e9 (e:65e9) cp $40 ret nc - jp Func_3a72a + jp AISwitchIfEnoughMons BlackbeltAI: ; 3a5ef (e:65ef) cp $20 @@ -975,12 +980,12 @@ CooltrainerMAI: ; 3a5fb (e:65fb) CooltrainerFAI: ; 3a601 (e:6601) cp $40 ld a,$A - call Func_3a7cf + call AICheckIfHPBelowFraction jp c,AIUseHyperPotion ld a,5 - call Func_3a7cf + call AICheckIfHPBelowFraction ret nc - jp Func_3a72a + jp AISwitchIfEnoughMons BrockAI: ; 3a614 (e:6614) ; if his active monster has a status condition, use a full heal @@ -1003,7 +1008,7 @@ ErikaAI: ; 3a628 (e:6628) cp $80 ret nc ld a,$A - call Func_3a7cf + call AICheckIfHPBelowFraction ret nc jp AIUseSuperPotion @@ -1021,7 +1026,7 @@ SabrinaAI: ; 3a640 (e:6640) cp $40 ret nc ld a,$A - call Func_3a7cf + call AICheckIfHPBelowFraction ret nc jp AIUseHyperPotion @@ -1029,7 +1034,7 @@ Sony2AI: ; 3a64c (e:664c) cp $20 ret nc ld a,5 - call Func_3a7cf + call AICheckIfHPBelowFraction ret nc jp AIUsePotion @@ -1037,7 +1042,7 @@ Sony3AI: ; 3a658 (e:6658) cp $20 ret nc ld a,5 - call Func_3a7cf + call AICheckIfHPBelowFraction ret nc jp AIUseFullRestore @@ -1045,7 +1050,7 @@ LoreleiAI: ; 3a664 (e:6664) cp $80 ret nc ld a,5 - call Func_3a7cf + call AICheckIfHPBelowFraction ret nc jp AIUseSuperPotion @@ -1056,11 +1061,11 @@ BrunoAI: ; 3a670 (e:6670) AgathaAI: ; 3a676 (e:6676) cp $14 - jp c,Func_3a72a + jp c,AISwitchIfEnoughMons cp $80 ret nc ld a,4 - call Func_3a7cf + call AICheckIfHPBelowFraction ret nc jp AIUseSuperPotion @@ -1068,7 +1073,7 @@ LanceAI: ; 3a687 (e:6687) cp $80 ret nc ld a,5 - call Func_3a7cf + call AICheckIfHPBelowFraction ret nc jp AIUseHyperPotion @@ -1110,7 +1115,7 @@ AIUseFullRestore: ; 3a6a0 (e:66a0) ld [de],a ld [wHPBarMaxHP+1],a ld [wEnemyMonHP],a - jr Func_3a718 + jr AIPrintItemUseAndUpdateHPBar AIUsePotion: ; 3a6ca (e:66ca) ; enemy trainer heals his monster with a potion @@ -1160,7 +1165,7 @@ AIRecoverHP: ; 3a6da (e:66da) ld a,[de] ld [wHPBarMaxHP+1],a sbc b - jr nc,Func_3a718 + jr nc,AIPrintItemUseAndUpdateHPBar inc de ld a,[de] dec de @@ -1171,7 +1176,7 @@ AIRecoverHP: ; 3a6da (e:66da) ld [wHPBarNewHP+1],a ; fallthrough -Func_3a718: ; 3a718 (e:6718) +AIPrintItemUseAndUpdateHPBar: ; 3a718 (e:6718) call AIPrintItemUse_ hlCoord 2, 2 xor a @@ -1179,7 +1184,8 @@ Func_3a718: ; 3a718 (e:6718) predef UpdateHPBar2 jp DecrementAICount -Func_3a72a: ; 3a72a (e:672a) +AISwitchIfEnoughMons: ; 3a72a (e:672a) +; enemy trainer switches if there are 3 or more unfainted mons in party ld a,[wEnemyPartyCount] ld c,a ld hl,wEnemyMon1HP @@ -1281,7 +1287,8 @@ AIUseDireHit: ; 0x3a7c2 unused ld a,DIRE_HIT jp AIPrintItemUse -Func_3a7cf: ; 3a7cf (e:67cf) +AICheckIfHPBelowFraction: ; 3a7cf (e:67cf) +; return carry if enemy trainer's current HP is below 1 / a of the maximum ld [H_DIVISOR],a ld hl,wEnemyMonMaxHP ld a,[hli] @@ -1395,7 +1402,7 @@ SetupOwnPartyPokeballs: ; 3a869 (e:6869) ld a, $8 ld [wTrainerEngageDistance], a ld hl, wOAMBuffer - jp Func_3a8e1 + jp WritePokeballOAMData SetupEnemyPartyPokeballs: ; 3a887 (e:6887) call PlaceEnemyHUDTiles @@ -1409,7 +1416,7 @@ SetupEnemyPartyPokeballs: ; 3a887 (e:6887) ld a, $f8 ld [wTrainerEngageDistance], a ld hl, wOAMBuffer + PARTY_LENGTH * 4 - jp Func_3a8e1 + jp WritePokeballOAMData SetupPokeballs: ; 0x3a8a6 ld a, [de] @@ -1421,7 +1428,7 @@ SetupPokeballs: ; 0x3a8a6 ld [de], a inc de dec c - jr nz, .emptyloop ; 0x3a8b2 $fb + jr nz, .emptyloop pop af ld de, wBuffer .monloop @@ -1461,10 +1468,10 @@ PickPokeball: ; 3a8c2 (e:68c2) add hl, bc ret -Func_3a8e1: ; 3a8e1 (e:68e1) - ld de, wHPBarMaxHP +WritePokeballOAMData: ; 3a8e1 (e:68e1) + ld de, wBuffer ld c, PARTY_LENGTH -.asm_3a8e6 +.loop ld a, [W_BASECOORDY] ; wd082 ld [hli], a ld a, [W_BASECOORDX] ; wd081 @@ -1480,7 +1487,7 @@ Func_3a8e1: ; 3a8e1 (e:68e1) ld [W_BASECOORDX], a ; wd081 inc de dec c - jr nz, .asm_3a8e6 + jr nz, .loop ret PlacePlayerHUDTiles: ; 3a902 (e:6902) @@ -1542,7 +1549,7 @@ SetupPlayerAndEnemyPokeballs: ; 3a948 (e:6948) ld a, $8 ld [wTrainerEngageDistance], a ld hl, wOAMBuffer - call Func_3a8e1 + call WritePokeballOAMData ld hl, wEnemyMons ; wEnemyMon1Species ld de, wEnemyPartyCount ; wEnemyPartyCount call SetupPokeballs @@ -1551,7 +1558,7 @@ SetupPlayerAndEnemyPokeballs: ; 3a948 (e:6948) ld [hli], a ld [hl], $68 ld hl, wOAMBuffer + $18 - jp Func_3a8e1 + jp WritePokeballOAMData ; four tiles: pokeball, black pokeball (status ailment), crossed out pokeball (faited) and pokeball slot (no mon) PokeballTileGraphics:: ; 3a97e (e:697e) diff --git a/engine/evos_moves.asm b/engine/evos_moves.asm index 86b49d309c..23bffa8dc0 100755 --- a/engine/evos_moves.asm +++ b/engine/evos_moves.asm @@ -139,7 +139,7 @@ Evolution_PartyMonLoop: ; loop over party mons ld [wLoadedMonSpecies], a ld [wHPBarMaxHP + 1], a ld a, MONSTER_NAME - ld [W_LISTTYPE], a + ld [wNameListType], a ld a, BANK(TrainerNames) ; bank is not used for monster names ld [wPredefBank], a call GetName diff --git a/engine/items/items.asm b/engine/items/items.asm index c9b1aead52..c1268cd52f 100755 --- a/engine/items/items.asm +++ b/engine/items/items.asm @@ -777,7 +777,7 @@ ItemUseMedicine: ; dabb (3:5abb) ld de,wBattleMonMaxHP ld bc,10 call CopyData ; copy party stats to in-battle stat data - predef Func_3ed02 + predef DoubleOrHalveSelectedStats jp .doneHealing .healHP inc hl ; hl = address of current HP diff --git a/engine/menu/bills_pc.asm b/engine/menu/bills_pc.asm index f4a40cf9b4..61e6204ebf 100644 --- a/engine/menu/bills_pc.asm +++ b/engine/menu/bills_pc.asm @@ -101,7 +101,7 @@ BillsPC_:: ; 0x214c2 xor a ld [wccd3], a inc a ; MONSTER_NAME - ld [W_LISTTYPE], a + ld [wNameListType], a call LoadHpBarAndStatusTilePatterns ld a, [wListScrollOffset] push af @@ -332,7 +332,7 @@ Func_216be: ; 216be (8:56be) ld [wcf93], a ld [wListMenuID], a inc a ; MONSTER_NAME - ld [W_LISTTYPE], a + ld [wNameListType], a ld a, [wcc2b] ld [wCurrentMenuItem], a call DisplayListMenuID diff --git a/engine/menu/players_pc.asm b/engine/menu/players_pc.asm index ad6c814059..147a27a46a 100755 --- a/engine/menu/players_pc.asm +++ b/engine/menu/players_pc.asm @@ -2,7 +2,7 @@ PlayerPC: ; 78e6 (1:78e6) ld hl, wd730 set 6, [hl] ld a, ITEM_NAME - ld [W_LISTTYPE], a + ld [wNameListType], a call SaveScreenTilesToBuffer1 xor a ld [wcc2c], a diff --git a/engine/predefs.asm b/engine/predefs.asm index 23eb8cd164..bb8866da41 100755 --- a/engine/predefs.asm +++ b/engine/predefs.asm @@ -92,7 +92,7 @@ PredefPointers:: ; 4fe79 (13:7e79) add_predef UpdateHPBar add_predef HPBarLength add_predef Diploma_TextBoxBorder - add_predef Func_3ed02 + add_predef DoubleOrHalveSelectedStats add_predef ShowPokedexMenu add_predef EvolutionAfterBattle add_predef SaveSAVtoSRAM0 diff --git a/home.asm b/home.asm index e9f37763dc..7a908f78ad 100644 --- a/home.asm +++ b/home.asm @@ -1931,7 +1931,7 @@ GetItemName:: ; 2fcf (0:2fcf) ld [wd0b5],a ld a,ITEM_NAME - ld [W_LISTTYPE],a + ld [wNameListType],a ld a,BANK(ItemNames) ld [wPredefBank],a call GetName @@ -2028,7 +2028,7 @@ HMMoves:: ; 3052 (0:3052) GetMoveName:: ; 3058 (0:3058) push hl ld a,MOVE_NAME - ld [W_LISTTYPE],a + ld [wNameListType],a ld a,[wd11e] ld [wd0b5],a ld a,BANK(MoveNames) @@ -3252,7 +3252,7 @@ NamePointers:: ; 375d (0:375d) GetName:: ; 376b (0:376b) ; arguments: ; [wd0b5] = which name -; [wd0b6] = which list (W_LISTTYPE) +; [wNameListType] = which list ; [wPredefBank] = bank of list ; ; returns pointer to name in de @@ -3269,7 +3269,7 @@ GetName:: ; 376b (0:376b) push hl push bc push de - ld a,[W_LISTTYPE] ;List3759_entrySelector + ld a,[wNameListType] ;List3759_entrySelector dec a jr nz,.otherEntries ;1 = MON_NAMES @@ -3284,7 +3284,7 @@ GetName:: ; 376b (0:376b) ld a,[wPredefBank] ld [H_LOADEDROMBANK],a ld [$2000],a - ld a,[W_LISTTYPE] ;VariousNames' entryID + ld a,[wNameListType] ;VariousNames' entryID dec a add a ld d,0 diff --git a/main.asm b/main.asm index a342b2b94c..1b59a5d02b 100755 --- a/main.asm +++ b/main.asm @@ -96,7 +96,7 @@ LoadMonData_: ld a, [wWhichPokemon] ld e, a - callab Func_39c37 ; get pokemon ID + callab GetMonSpecies .GetMonHeader ld a, [wcf91] diff --git a/wram.asm b/wram.asm index ba641ec32d..6aabd27a44 100755 --- a/wram.asm +++ b/wram.asm @@ -979,8 +979,13 @@ wCriticalHitOrOHKO:: ; d05e W_MOVEMISSED:: ; d05f ds 1 -wd060:: ds 1 -wd061:: ds 1 +wPlayerStatsToDouble:: ; d060 +; always 0 + ds 1 + +wPlayerStatsToHalve:: ; d061 +; always 0 + ds 1 W_PLAYERBATTSTATUS1:: ; d062 ; bit 0 - bide @@ -1010,8 +1015,13 @@ W_PLAYERBATTSTATUS3:: ; d064 ; bit 3 - tranformed ds 1 -wd065:: ds 1 -wd066:: ds 1 +wEnemyStatsToDouble:: ; d065 +; always 0 + ds 1 + +wEnemyStatsToHalve:: ; d066 +; always 0 + ds 1 W_ENEMYBATTSTATUS1:: ; d067 ds 1 @@ -1213,7 +1223,7 @@ W_SPRITEDECODETABLE1PTR:: ; d0b3 wd0b5:: ds 1 -W_LISTTYPE:: ; d0b6 +wNameListType:: ; d0b6 ds 1 wPredefBank:: ; d0b7 From 7b7c563c93155e121e05149779cfb78b0bf9d259 Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Sun, 8 Feb 2015 18:40:08 -0800 Subject: [PATCH 099/100] Rename some labels --- engine/battle/16.asm | 2 +- engine/battle/1c.asm | 3 ++- engine/cable_club.asm | 2 +- engine/overworld/map_sprites.asm | 6 +++--- engine/overworld/movement.asm | 4 ++-- home.asm | 4 ++-- main.asm | 2 +- wram.asm | 9 +++++---- 8 files changed, 17 insertions(+), 15 deletions(-) diff --git a/engine/battle/16.asm b/engine/battle/16.asm index 4a215a3791..9a00bd9886 100755 --- a/engine/battle/16.asm +++ b/engine/battle/16.asm @@ -55,7 +55,7 @@ PrintBeginningBattleText: ; 58d99 (16:4d99) ld hl, UnveiledGhostText call PrintText callab LoadEnemyMonData - callab DoGhostMarowakRevelationAnimation + callab MarowakAnim ld hl, WildMonAppearedText call PrintText diff --git a/engine/battle/1c.asm b/engine/battle/1c.asm index 2e360e65c0..ce0296f728 100755 --- a/engine/battle/1c.asm +++ b/engine/battle/1c.asm @@ -1,4 +1,5 @@ -DoGhostMarowakRevelationAnimation: ; 708ca (1c:48ca) +MarowakAnim: ; 708ca (1c:48ca) +; animate the ghost being unveiled as a Marowak ld a, $e4 ld [rOBP1], a call CopyMonPicFromBGToSpriteVRAM ; cover the BG ghost pic with a sprite ghost pic that looks the same diff --git a/engine/cable_club.asm b/engine/cable_club.asm index ff25fd5ef0..4fbb13d974 100755 --- a/engine/cable_club.asm +++ b/engine/cable_club.asm @@ -578,7 +578,7 @@ TradeCenter_SelectMon: ReturnToCableClubRoom: ; 577d (1:577d) call GBPalWhiteOutWithDelay3 - ld hl, wCharRAMInUseForText + ld hl, wFontLoaded ld a, [hl] push af push hl diff --git a/engine/overworld/map_sprites.asm b/engine/overworld/map_sprites.asm index 1640375980..df39d112d1 100755 --- a/engine/overworld/map_sprites.asm +++ b/engine/overworld/map_sprites.asm @@ -159,7 +159,7 @@ LoadMapSpriteTilePatterns: ; 17871 (5:7871) ld l,e pop de ld b,a - ld a,[wCharRAMInUseForText] + ld a,[wFontLoaded] bit 0,a ; reloading upper half of tile patterns after displaying text? jr nz,.skipFirstLoad ; if so, skip loading data into the lower half ld a,b @@ -180,7 +180,7 @@ LoadMapSpriteTilePatterns: ; 17871 (5:7871) jr nc,.noCarry3 inc d .noCarry3 - ld a,[wCharRAMInUseForText] + ld a,[wFontLoaded] bit 0,a ; reloading upper half of tile patterns after displaying text? jr nz,.loadWhileLCDOn pop af @@ -264,7 +264,7 @@ InitOutsideMapSprites: ; 1797b (5:797b) cp a,$f0 ; does the map have 2 sprite sets? call nc,GetSplitMapSpriteSetID ; if so, choose the appropriate one ld b,a ; b = spriteSetID - ld a,[wCharRAMInUseForText] + ld a,[wFontLoaded] bit 0,a ; reloading upper half of tile patterns after displaying text? jr nz,.loadSpriteSet ; if so, forcibly reload the sprite set ld a,[W_SPRITESETID] diff --git a/engine/overworld/movement.asm b/engine/overworld/movement.asm index 1658b0e9b2..c44827004f 100644 --- a/engine/overworld/movement.asm +++ b/engine/overworld/movement.asm @@ -52,7 +52,7 @@ UpdatePlayerSprite: ; 4e31 (1:4e31) jr .asm_4eab .asm_4e86 ld [wSpriteStateData1 + 9], a - ld a, [wCharRAMInUseForText] + ld a, [wFontLoaded] bit 0, a jr nz, .asm_4e7d .asm_4e90 @@ -130,7 +130,7 @@ Func_4ed1: ; 4ed1 (1:4ed1) bit 7, a jp nz, InitializeSpriteFacingDirection ; c1x1 >= $80 ld b, a - ld a, [wCharRAMInUseForText] + ld a, [wFontLoaded] bit 0, a jp nz, notYetMoving ld a, b diff --git a/home.asm b/home.asm index 7a908f78ad..37e128f07f 100644 --- a/home.asm +++ b/home.asm @@ -1183,7 +1183,7 @@ CloseTextDisplay:: ; 29e8 (0:29e8) ld [H_LOADEDROMBANK],a ld [$2000],a call InitMapSprites ; reload sprite tile pattern data (since it was partially overwritten by text tile patterns) - ld hl,wCharRAMInUseForText + ld hl,wFontLoaded res 0,[hl] ld a,[wd732] bit 3,a ; used fly warp @@ -4540,7 +4540,7 @@ GetHealthBarColor:: ; Copy the current map's sprites' tile patterns to VRAM again after they have ; been overwritten by other tile patterns. ReloadMapSpriteTilePatterns:: ; 3e08 (0:3e08) - ld hl, wCharRAMInUseForText + ld hl, wFontLoaded ld a, [hl] push af res 0, [hl] diff --git a/main.asm b/main.asm index 1b59a5d02b..cb77e5a3d3 100755 --- a/main.asm +++ b/main.asm @@ -1022,7 +1022,7 @@ DisplayTextIDInit: ; 7096 (1:7096) .drawTextBoxBorder call TextBoxBorder .skipDrawingTextBoxBorder - ld hl,wCharRAMInUseForText + ld hl,wFontLoaded set 0,[hl] ld hl,wFlags_0xcd60 bit 4,[hl] diff --git a/wram.asm b/wram.asm index 6aabd27a44..7091bd4c73 100755 --- a/wram.asm +++ b/wram.asm @@ -820,10 +820,11 @@ wcf97:: ds 1 ; LoadMonData copies mon data here wLoadedMon:: party_struct wLoadedMon ; cf98 -wCharRAMInUseForText:: ; cfc4 -; bit 0: the space in VRAM that is used to store walking tile patterns for -; the player and NPCs is in use for text tile patterns. this means -; that movement must be disabled. +wFontLoaded:: ; cfc4 +; bit 0: The space in VRAM that is used to store walk animation tile patterns +; for the player and NPCs is in use for font tile patterns. +; This means that NPC movement must be disabled. +; The other bits are unused. ds 1 wWalkCounter:: ; cfc5 From 084c8407d879e114453147b737528da46f3b1cb5 Mon Sep 17 00:00:00 2001 From: "U-Daniel-PC\\Daniel" Date: Fri, 20 Feb 2015 00:56:30 -0500 Subject: [PATCH 100/100] Remove hard-coded wPokedexOwned/wPokedexSeen array size --- engine/menu/pokedex.asm | 2 +- scripts/oakslab.asm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/engine/menu/pokedex.asm b/engine/menu/pokedex.asm index e636e59dec..4351ae4cd7 100755 --- a/engine/menu/pokedex.asm +++ b/engine/menu/pokedex.asm @@ -194,7 +194,7 @@ HandlePokedexListMenu: ; 40111 (10:4111) call PlaceString ; find the highest pokedex number among the pokemon the player has seen ld hl,wPokedexSeenEnd - 1 - ld b,153 + ld b,(wPokedexSeenEnd - wPokedexSeen) * 8 + 1 .maxSeenPokemonLoop ld a,[hld] ld c,8 diff --git a/scripts/oakslab.asm b/scripts/oakslab.asm index 6b7d5e1e73..8f23cd3e14 100755 --- a/scripts/oakslab.asm +++ b/scripts/oakslab.asm @@ -944,7 +944,7 @@ OaksLabText5: ; 1d248 (7:5248) bit 6, a jr nz, .asm_50e81 ; 0x1d24e ld hl, wPokedexOwned - ld b, $13 + ld b, wPokedexOwnedEnd - wPokedexOwned call CountSetBits ld a, [wd11e] cp $2