From 10c0566121cb923b7f4e6c1a97a1df8ad70cb327 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Tue, 19 Jan 2021 11:43:50 -0500 Subject: [PATCH 01/27] Don't keep temporary C build files by default. --- Makefile | 10 ++++++++ tools/preproc/c_file.cpp | 54 +++++++++++++++++++++++++++++---------- tools/preproc/c_file.h | 5 +++- tools/preproc/preproc.cpp | 22 +++++++++++----- 4 files changed, 70 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index 3bb5161e3..3383cb14d 100644 --- a/Makefile +++ b/Makefile @@ -283,10 +283,15 @@ override CFLAGS += -g endif $(C_BUILDDIR)/%.o : $(C_SUBDIR)/%.c $$(c_dep) +ifeq (,$(KEEP_TEMPS)) + @echo "$(CC1) -o $@ $<" + @$(CPP) $(CPPFLAGS) $< | $(PREPROC) $< charmap.txt -i | { $(CC1) $(CFLAGS) -o - -; echo -e ".text\n\t.align\t2, 0"; } | $(AS) $(ASFLAGS) -o $@ - +else @$(CPP) $(CPPFLAGS) $< -o $(C_BUILDDIR)/$*.i @$(PREPROC) $(C_BUILDDIR)/$*.i charmap.txt | $(CC1) $(CFLAGS) -o $(C_BUILDDIR)/$*.s @echo -e ".text\n\t.align\t2, 0\n" >> $(C_BUILDDIR)/$*.s $(AS) $(ASFLAGS) -o $@ $(C_BUILDDIR)/$*.s +endif ifeq ($(NODEP),1) $(GFLIB_BUILDDIR)/%.o: c_dep := @@ -295,10 +300,15 @@ $(GFLIB_BUILDDIR)/%.o: c_dep = $(shell [[ -f $(GFLIB_SUBDIR)/$*.c ]] && $(SCANIN endif $(GFLIB_BUILDDIR)/%.o : $(GFLIB_SUBDIR)/%.c $$(c_dep) +ifeq (,$(KEEP_TEMPS)) + @echo "$(CC1) -o $@ $<" + @$(CPP) $(CPPFLAGS) $< | $(PREPROC) $< charmap.txt -i | { $(CC1) $(CFLAGS) -o - -; echo -e ".text\n\t.align\t2, 0"; } | $(AS) $(ASFLAGS) -o $@ - +else @$(CPP) $(CPPFLAGS) $< -o $(GFLIB_BUILDDIR)/$*.i @$(PREPROC) $(GFLIB_BUILDDIR)/$*.i charmap.txt | $(CC1) $(CFLAGS) -o $(GFLIB_BUILDDIR)/$*.s @echo -e ".text\n\t.align\t2, 0\n" >> $(GFLIB_BUILDDIR)/$*.s $(AS) $(ASFLAGS) -o $@ $(GFLIB_BUILDDIR)/$*.s +endif ifeq ($(NODEP),1) $(C_BUILDDIR)/%.o: c_asm_dep := diff --git a/tools/preproc/c_file.cpp b/tools/preproc/c_file.cpp index b996a048c..f7ca4365c 100644 --- a/tools/preproc/c_file.cpp +++ b/tools/preproc/c_file.cpp @@ -23,32 +23,58 @@ #include #include #include +#include #include "preproc.h" #include "c_file.h" #include "char_util.h" #include "utf8.h" #include "string_parser.h" -CFile::CFile(std::string filename) : m_filename(filename) +CFile::CFile(const char * filenameCStr, bool isStdin) { - FILE *fp = std::fopen(filename.c_str(), "rb"); + FILE *fp; + + if (isStdin) { + fp = stdin; + m_filename = std::string{"/"}.append(filenameCStr); + } else { + fp = std::fopen(filenameCStr, "rb"); + m_filename = std::string(filenameCStr); + } + + std::string& filename = m_filename; if (fp == NULL) FATAL_ERROR("Failed to open \"%s\" for reading.\n", filename.c_str()); - std::fseek(fp, 0, SEEK_END); + m_size = 0; + m_buffer = (char *)malloc(CHUNK_SIZE + 1); + if (m_buffer == NULL) { + FATAL_ERROR("Failed to allocate memory to process file \"%s\"!", filename.c_str()); + } - m_size = std::ftell(fp); + std::size_t numAllocatedBytes = CHUNK_SIZE + 1; + std::size_t bufferOffset = 0; + std::size_t count; - if (m_size < 0) - FATAL_ERROR("File size of \"%s\" is less than zero.\n", filename.c_str()); + while ((count = std::fread(m_buffer + bufferOffset, 1, CHUNK_SIZE, fp)) != 0) { + if (!std::ferror(fp)) { + m_size += count; - m_buffer = new char[m_size + 1]; + if (std::feof(fp)) { + break; + } - std::rewind(fp); - - if (std::fread(m_buffer, m_size, 1, fp) != 1) - FATAL_ERROR("Failed to read \"%s\".\n", filename.c_str()); + numAllocatedBytes += CHUNK_SIZE; + bufferOffset += CHUNK_SIZE; + m_buffer = (char *)realloc(m_buffer, numAllocatedBytes); + if (m_buffer == NULL) { + FATAL_ERROR("Failed to allocate memory to process file \"%s\"!", filename.c_str()); + } + } else { + FATAL_ERROR("Failed to read \"%s\". (error: %s)", filename.c_str(), std::strerror(errno)); + } + } m_buffer[m_size] = 0; @@ -56,6 +82,7 @@ CFile::CFile(std::string filename) : m_filename(filename) m_pos = 0; m_lineNum = 1; + m_isStdin = isStdin; } CFile::CFile(CFile&& other) : m_filename(std::move(other.m_filename)) @@ -64,13 +91,14 @@ CFile::CFile(CFile&& other) : m_filename(std::move(other.m_filename)) m_pos = other.m_pos; m_size = other.m_size; m_lineNum = other.m_lineNum; + m_isStdin = other.m_isStdin; - other.m_buffer = nullptr; + other.m_buffer = NULL; } CFile::~CFile() { - delete[] m_buffer; + free(m_buffer); } void CFile::Preproc() diff --git a/tools/preproc/c_file.h b/tools/preproc/c_file.h index 7369aba85..49e633a18 100644 --- a/tools/preproc/c_file.h +++ b/tools/preproc/c_file.h @@ -30,7 +30,7 @@ class CFile { public: - CFile(std::string filename); + CFile(const char * filenameCStr, bool isStdin); CFile(CFile&& other); CFile(const CFile&) = delete; ~CFile(); @@ -42,6 +42,7 @@ private: long m_size; long m_lineNum; std::string m_filename; + bool m_isStdin; bool ConsumeHorizontalWhitespace(); bool ConsumeNewline(); @@ -55,4 +56,6 @@ private: void RaiseWarning(const char* format, ...); }; +#define CHUNK_SIZE 4096 + #endif // C_FILE_H diff --git a/tools/preproc/preproc.cpp b/tools/preproc/preproc.cpp index c9c6042df..02950a296 100644 --- a/tools/preproc/preproc.cpp +++ b/tools/preproc/preproc.cpp @@ -103,9 +103,9 @@ void PreprocAsmFile(std::string filename) } } -void PreprocCFile(std::string filename) +void PreprocCFile(const char * filename, bool isStdin) { - CFile cFile(filename); + CFile cFile(filename, isStdin); cFile.Preproc(); } @@ -132,9 +132,9 @@ char* GetFileExtension(char* filename) int main(int argc, char **argv) { - if (argc != 3) + if (argc < 3 || argc > 4) { - std::fprintf(stderr, "Usage: %s SRC_FILE CHARMAP_FILE", argv[0]); + std::fprintf(stderr, "Usage: %s SRC_FILE CHARMAP_FILE [-i]\nwhere -i denotes if input is from stdin", argv[0]); return 1; } @@ -147,9 +147,17 @@ int main(int argc, char **argv) if ((extension[0] == 's') && extension[1] == 0) PreprocAsmFile(argv[1]); - else if ((extension[0] == 'c' || extension[0] == 'i') && extension[1] == 0) - PreprocCFile(argv[1]); - else + else if ((extension[0] == 'c' || extension[0] == 'i') && extension[1] == 0) { + if (argc == 4) { + if (argv[3][0] == '-' && argv[3][1] == 'i' && argv[3][2] == '\0') { + PreprocCFile(argv[1], true); + } else { + FATAL_ERROR("unknown argument flag \"%s\".\n", argv[3]); + } + } else { + PreprocCFile(argv[1], false); + } + } else FATAL_ERROR("\"%s\" has an unknown file extension of \"%s\".\n", argv[1], extension); return 0; From 57bc32e300b7e23886337e244a3522e1e1bec04f Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Wed, 27 Jan 2021 09:57:50 -0500 Subject: [PATCH 02/27] Fix templess builds from not exiting on error. --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 3383cb14d..bb65aed74 100644 --- a/Makefile +++ b/Makefile @@ -285,7 +285,7 @@ endif $(C_BUILDDIR)/%.o : $(C_SUBDIR)/%.c $$(c_dep) ifeq (,$(KEEP_TEMPS)) @echo "$(CC1) -o $@ $<" - @$(CPP) $(CPPFLAGS) $< | $(PREPROC) $< charmap.txt -i | { $(CC1) $(CFLAGS) -o - -; echo -e ".text\n\t.align\t2, 0"; } | $(AS) $(ASFLAGS) -o $@ - + @$(CPP) $(CPPFLAGS) $< | $(PREPROC) $< charmap.txt -i | $(CC1) $(CFLAGS) -o - - | cat - <(echo -e ".text\n\t.align\t2, 0") | $(AS) $(ASFLAGS) -o $@ - else @$(CPP) $(CPPFLAGS) $< -o $(C_BUILDDIR)/$*.i @$(PREPROC) $(C_BUILDDIR)/$*.i charmap.txt | $(CC1) $(CFLAGS) -o $(C_BUILDDIR)/$*.s @@ -302,7 +302,7 @@ endif $(GFLIB_BUILDDIR)/%.o : $(GFLIB_SUBDIR)/%.c $$(c_dep) ifeq (,$(KEEP_TEMPS)) @echo "$(CC1) -o $@ $<" - @$(CPP) $(CPPFLAGS) $< | $(PREPROC) $< charmap.txt -i | { $(CC1) $(CFLAGS) -o - -; echo -e ".text\n\t.align\t2, 0"; } | $(AS) $(ASFLAGS) -o $@ - + @$(CPP) $(CPPFLAGS) $< | $(PREPROC) $< charmap.txt -i | $(CC1) $(CFLAGS) -o - - | cat - <(echo -e ".text\n\t.align\t2, 0") | $(AS) $(ASFLAGS) -o $@ - else @$(CPP) $(CPPFLAGS) $< -o $(GFLIB_BUILDDIR)/$*.i @$(PREPROC) $(GFLIB_BUILDDIR)/$*.i charmap.txt | $(CC1) $(CFLAGS) -o $(GFLIB_BUILDDIR)/$*.s From 9da2142a391d991490a7a9de9ada6f12868049a4 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Tue, 4 May 2021 10:08:54 -0400 Subject: [PATCH 03/27] Scan all deps of time, also prevent deps from being scanned twice for compare and modern. --- Makefile | 88 ++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 66 insertions(+), 22 deletions(-) diff --git a/Makefile b/Makefile index bb65aed74..6842d3fd7 100644 --- a/Makefile +++ b/Makefile @@ -143,12 +143,27 @@ infoshell = $(foreach line, $(shell $1 | sed "s/ /__SPACE__/g"), $(info $(subst # Build tools when building the rom # Disable dependency scanning for clean/tidy/tools -ifeq (,$(filter-out all rom compare modern berry_fix libagbsyscall,$(MAKECMDGOALS))) +# Don't build tools yet for modern because we perform a recursive make +ifeq (,$(filter-out all rom berry_fix libagbsyscall,$(MAKECMDGOALS))) $(call infoshell, $(MAKE) tools) else NODEP := 1 endif +# check if we need to scan dependencies based on the rule +ifeq (,$(MAKECMDGOALS)) + SCAN_DEPS := 1 +else + # compare and modern perform recursive calls, so don't scan dependencies yet + # clean, tidy, tools, mostlyclean, clean-tools, $(TOOLDIRS), tidymodern, tidynonmodern don't even build the ROM + # berry_fix and libagbsyscall do their own thing + ifeq (,$(filter-out clean compare tidy tools mostlyclean clean-tools $(TOOLDIRS) berry_fix libagbsyscall modern tidymodern tidynonmodern,$(MAKECMDGOALS))) + SCAN_DEPS := 0 + else + SCAN_DEPS := 1 + endif +endif + C_SRCS_IN := $(wildcard $(C_SUBDIR)/*.c $(C_SUBDIR)/*/*.c $(C_SUBDIR)/*/*/*.c) C_SRCS := $(foreach src,$(C_SRCS_IN),$(if $(findstring .inc.c,$(src)),,$(src))) C_OBJS := $(patsubst $(C_SUBDIR)/%.c,$(C_BUILDDIR)/%.o,$(C_SRCS)) @@ -272,17 +287,21 @@ else $(C_BUILDDIR)/librfu_intr.o: CFLAGS := -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -fno-toplevel-reorder -Wno-pointer-to-int-cast endif -ifeq ($(NODEP),1) -$(C_BUILDDIR)/%.o: c_dep := -else -$(C_BUILDDIR)/%.o: c_dep = $(shell [[ -f $(C_SUBDIR)/$*.c ]] && $(SCANINC) -I include -I tools/agbcc/include -I gflib $(C_SUBDIR)/$*.c) -endif - ifeq ($(DINFO),1) override CFLAGS += -g endif -$(C_BUILDDIR)/%.o : $(C_SUBDIR)/%.c $$(c_dep) +# The dep rules have to be explicit or else missing files won't be reported. +# As a side effect, they're evaluated immediately instead of when the rule is invoked. +# It doesn't look like $(shell) can be deferred so there might not be a better way. + +# ifeq (,$(filter-out all rom compare modern berry_fix libagbsyscall,$(MAKECMDGOALS))) + +#$(info MAKECMDGOALS - $(MAKECMDGOALS)) + +ifeq ($(SCAN_DEPS),1) +ifeq ($(NODEP),1) +$(C_BUILDDIR)/%.o : $(C_SUBDIR)/%.c ifeq (,$(KEEP_TEMPS)) @echo "$(CC1) -o $@ $<" @$(CPP) $(CPPFLAGS) $< | $(PREPROC) $< charmap.txt -i | $(CC1) $(CFLAGS) -o - - | cat - <(echo -e ".text\n\t.align\t2, 0") | $(AS) $(ASFLAGS) -o $@ - @@ -292,13 +311,25 @@ else @echo -e ".text\n\t.align\t2, 0\n" >> $(C_BUILDDIR)/$*.s $(AS) $(ASFLAGS) -o $@ $(C_BUILDDIR)/$*.s endif - -ifeq ($(NODEP),1) -$(GFLIB_BUILDDIR)/%.o: c_dep := else -$(GFLIB_BUILDDIR)/%.o: c_dep = $(shell [[ -f $(GFLIB_SUBDIR)/$*.c ]] && $(SCANINC) -I include -I tools/agbcc/include -I gflib $(GFLIB_SUBDIR)/$*.c) +define C_DEP +$1: $2 $$(shell $(SCANINC) -I include -I tools/agbcc/include -I gflib $2) +ifeq (,$$(KEEP_TEMPS)) + @echo "$$(CC1) -o $$@ $$<" + @$$(CPP) $$(CPPFLAGS) $$< | $$(PREPROC) $$< charmap.txt -i | $$(CC1) $$(CFLAGS) -o - - | cat - <(echo -e ".text\n\t.align\t2, 0") | $$(AS) $$(ASFLAGS) -o $$@ - +else + @$$(CPP) $$(CPPFLAGS) $$< -o $$(C_BUILDDIR)/$$*.i + @$$(PREPROC) $$(C_BUILDDIR)/$$*.i charmap.txt | $$(CC1) $$(CFLAGS) -o $$(C_BUILDDIR)/$$*.s + @echo -e ".text\n\t.align\t2, 0\n" >> $$(C_BUILDDIR)/$$*.s + $$(AS) $$(ASFLAGS) -o $$@ $$(C_BUILDDIR)/$$*.s +endif +endef +#$(info C_DEP) +$(foreach src, $(C_SRCS), $(eval $(call C_DEP,$(patsubst $(C_SUBDIR)/%.c,$(C_BUILDDIR)/%.o, $(src)),$(src)))) +#$(error done C_DEP) endif +ifeq ($(NODEP),1) $(GFLIB_BUILDDIR)/%.o : $(GFLIB_SUBDIR)/%.c $$(c_dep) ifeq (,$(KEEP_TEMPS)) @echo "$(CC1) -o $@ $<" @@ -309,20 +340,32 @@ else @echo -e ".text\n\t.align\t2, 0\n" >> $(GFLIB_BUILDDIR)/$*.s $(AS) $(ASFLAGS) -o $@ $(GFLIB_BUILDDIR)/$*.s endif - -ifeq ($(NODEP),1) -$(C_BUILDDIR)/%.o: c_asm_dep := else -$(C_BUILDDIR)/%.o: c_asm_dep = $(shell [[ -f $(C_SUBDIR)/$*.s ]] && $(SCANINC) -I "" $(C_SUBDIR)/$*.s) +define GFLIB_DEP +$1: $2 $$(shell $(SCANINC) -I include -I tools/agbcc/include -I gflib $2) +ifeq (,$$(KEEP_TEMPS)) + @echo "$$(CC1) -o $$@ $$<" + @$$(CPP) $$(CPPFLAGS) $$< | $$(PREPROC) $$< charmap.txt -i | $$(CC1) $$(CFLAGS) -o - - | cat - <(echo -e ".text\n\t.align\t2, 0") | $$(AS) $$(ASFLAGS) -o $$@ - +else + @$$(CPP) $$(CPPFLAGS) $$< -o $$(GFLIB_BUILDDIR)/$$*.i + @$$(PREPROC) $$(GFLIB_BUILDDIR)/$$*.i charmap.txt | $$(CC1) $$(CFLAGS) -o $$(GFLIB_BUILDDIR)/$$*.s + @echo -e ".text\n\t.align\t2, 0\n" >> $$(GFLIB_BUILDDIR)/$$*.s + $$(AS) $$(ASFLAGS) -o $$@ $$(GFLIB_BUILDDIR)/$$*.s +endif +endef +$(foreach src, $(GFLIB_SRCS), $(eval $(call GFLIB_DEP,$(patsubst $(GFLIB_SUBDIR)/%.c,$(GFLIB_BUILDDIR)/%.o, $(src)),$(src)))) endif -$(C_BUILDDIR)/%.o: $(C_SUBDIR)/%.s $$(c_asm_dep) +ifeq ($(NODEP),1) +$(C_BUILDDIR)/%.o: $(C_SUBDIR)/%.s $(AS) $(ASFLAGS) -o $@ $< - -# The dep rules have to be explicit or else missing files won't be reported. -# As a side effect, they're evaluated immediately instead of when the rule is invoked. -# It doesn't look like $(shell) can be deferred so there might not be a better way. - +else +define C_ASM_DEP +$1: $2 $$(shell $(SCANINC) -I "" $2) + $$(AS) $$(ASFLAGS) -o $$@ $$< +endef +$(foreach src, $(C_ASM_SRCS), $(eval $(call C_ASM_DEP,$(patsubst $(C_SUBDIR)/%.s,$(C_BUILDDIR)/%.o, $(src)),$(src)))) +endif ifeq ($(NODEP),1) $(ASM_BUILDDIR)/%.o: $(ASM_SUBDIR)/%.s @@ -345,6 +388,7 @@ $1: $2 $$(shell $(SCANINC) -I include -I "" $2) endef $(foreach src, $(REGULAR_DATA_ASM_SRCS), $(eval $(call DATA_ASM_DEP,$(patsubst $(DATA_ASM_SUBDIR)/%.s,$(DATA_ASM_BUILDDIR)/%.o, $(src)),$(src)))) endif +endif $(SONG_BUILDDIR)/%.o: $(SONG_SUBDIR)/%.s $(AS) $(ASFLAGS) -I sound -o $@ $< From 42021db743e898b2fe73ffe193446775e88ef121 Mon Sep 17 00:00:00 2001 From: Kurausukun Date: Tue, 25 May 2021 21:55:24 -0400 Subject: [PATCH 04/27] [LEAK-INFORMED] literal dumbest fakematch ever --- src/pokemon_animation.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pokemon_animation.c b/src/pokemon_animation.c index 14a17437c..e63862cd9 100644 --- a/src/pokemon_animation.c +++ b/src/pokemon_animation.c @@ -2604,9 +2604,9 @@ static void RotateUpSlamDown_0(struct Sprite *sprite) { TryFlipX(sprite); sprite->data[7]--; - sprite->pos2.x = Cos(sprite->data[7], sprite->data[6]) + sprite->data[6]; + sprite->pos2.x = sprite->data[6] + Cos(sprite->data[7], sprite->data[6]); - sprite->pos2.y = -(Sin(sprite->data[7], sprite->data[6] += 0)); // dummy += 0 is needed to match + sprite->pos2.y = -(Sin(sprite->data[7], sprite->data[6])); HandleSetAffineData(sprite, 256, 256, (sprite->data[7] - 128) << 8); if (sprite->data[7] <= 120) @@ -2634,9 +2634,9 @@ static void RotateUpSlamDown_2(struct Sprite *sprite) { TryFlipX(sprite); sprite->data[7] += 2; - sprite->pos2.x = Cos(sprite->data[7], sprite->data[6]) + sprite->data[6]; + sprite->pos2.x = sprite->data[6] + Cos(sprite->data[7], sprite->data[6]); - sprite->pos2.y = -(Sin(sprite->data[7], sprite->data[6] += 0)); // dummy += 0 is needed to match + sprite->pos2.y = -(Sin(sprite->data[7], sprite->data[6])); HandleSetAffineData(sprite, 256, 256, (sprite->data[7] - 128) << 8); if (sprite->data[7] >= 128) From 2705f2e5f44980f368d30845215e28ae5ea5c595 Mon Sep 17 00:00:00 2001 From: Kurausukun Date: Tue, 25 May 2021 22:13:31 -0400 Subject: [PATCH 05/27] [LEAK-INFORMED] also pretty dumb --- src/pokemon_animation.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/pokemon_animation.c b/src/pokemon_animation.c index e63862cd9..500916b0e 100644 --- a/src/pokemon_animation.c +++ b/src/pokemon_animation.c @@ -4066,16 +4066,15 @@ static void VerticalShakeLowTwice(struct Sprite *sprite) u8 var8 = sprite->data[2]; u8 var9 = sprite->data[6]; u8 var5 = sVerticalShakeData[sprite->data[5]][0]; - u8 var2 = var5; if (var5 != (u8)-1) var5 = sprite->data[7]; - else - var5 = (u8)-1; // needed to match var6 = sVerticalShakeData[sprite->data[5]][1]; var7 = 0; - if (var2 != (u8)-2) + if (sVerticalShakeData[sprite->data[5]][0] != (u8)-2) var7 = (var6 - var9) * var5 / var6; + else + var7 = 0; if (var5 == (u8)-1) { From 2bbaf71998337cba3c912143302f816b4116e851 Mon Sep 17 00:00:00 2001 From: Kurausukun Date: Mon, 31 May 2021 00:19:26 -0400 Subject: [PATCH 06/27] [LEAK-INFORMED] fix CreateShedinja fakematch info: the header change is required. accesses to the struct need to be treated as non-const, even though the array must be const. thanks to jiang for figuring this out. --- include/pokemon.h | 1 - src/daycare.c | 2 ++ src/evolution_scene.c | 12 ++++-------- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/include/pokemon.h b/include/pokemon.h index 82cdefeac..3565bd966 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -258,7 +258,6 @@ extern const u8 gFacilityClassToPicIndex[]; extern const u8 gFacilityClassToTrainerClass[]; extern const struct BaseStats gBaseStats[]; extern const u8 *const gItemEffectTable[]; -extern const struct Evolution gEvolutionTable[][EVOS_PER_MON]; extern const u32 gExperienceTables[][MAX_LEVEL + 1]; extern const u16 *const gLevelUpLearnsets[]; extern const u8 gPPUpGetMask[]; diff --git a/src/daycare.c b/src/daycare.c index 34b864981..14053217d 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -23,6 +23,8 @@ #include "constants/moves.h" #include "constants/region_map_sections.h" +extern struct Evolution gEvolutionTable[][EVOS_PER_MON]; + // this file's functions static void ClearDaycareMonMail(struct DaycareMail *mail); static void SetInitialEggData(struct Pokemon *mon, u16 species, struct DayCare *daycare); diff --git a/src/evolution_scene.c b/src/evolution_scene.c index 39e917161..08f816f4f 100644 --- a/src/evolution_scene.c +++ b/src/evolution_scene.c @@ -34,6 +34,8 @@ #include "constants/rgb.h" #include "constants/items.h" +extern struct Evolution gEvolutionTable[][EVOS_PER_MON]; + struct EvoInfo { u8 preEvoSpriteId; @@ -550,8 +552,6 @@ static void CreateShedinja(u16 preEvoSpecies, struct Pokemon* mon) { s32 i; struct Pokemon* shedinja = &gPlayerParty[gPlayerPartyCount]; - const struct Evolution *evos; - const struct Evolution *evos2; CopyMon(&gPlayerParty[gPlayerPartyCount], mon, sizeof(struct Pokemon)); SetMonData(&gPlayerParty[gPlayerPartyCount], MON_DATA_SPECIES, &gEvolutionTable[preEvoSpecies][1].targetSpecies); @@ -572,12 +572,8 @@ static void CreateShedinja(u16 preEvoSpecies, struct Pokemon* mon) CalculateMonStats(&gPlayerParty[gPlayerPartyCount]); CalculatePlayerPartyCount(); - // can't match it otherwise, ehh - evos2 = gEvolutionTable[0]; - evos = evos2 + EVOS_PER_MON * preEvoSpecies; - - GetSetPokedexFlag(SpeciesToNationalPokedexNum(evos[1].targetSpecies), FLAG_SET_SEEN); - GetSetPokedexFlag(SpeciesToNationalPokedexNum(evos[1].targetSpecies), FLAG_SET_CAUGHT); + GetSetPokedexFlag(SpeciesToNationalPokedexNum(gEvolutionTable[preEvoSpecies][1].targetSpecies), FLAG_SET_SEEN); + GetSetPokedexFlag(SpeciesToNationalPokedexNum(gEvolutionTable[preEvoSpecies][1].targetSpecies), FLAG_SET_CAUGHT); if (GetMonData(shedinja, MON_DATA_SPECIES) == SPECIES_SHEDINJA && GetMonData(shedinja, MON_DATA_LANGUAGE) == LANGUAGE_JAPANESE From 9f5bf65fb336cf7a3ba68d32267bf993f0f6a494 Mon Sep 17 00:00:00 2001 From: Kurausukun Date: Mon, 31 May 2021 19:01:20 -0400 Subject: [PATCH 07/27] [PROBABLY LEAK-INFORMED] fix battle_transition fakematch, make consistent use of SOME_VRAM_STORE --- src/battle_transition.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/battle_transition.c b/src/battle_transition.c index 479700e53..461c45e7d 100644 --- a/src/battle_transition.c +++ b/src/battle_transition.c @@ -1323,6 +1323,12 @@ static bool8 Phase2_BigPokeball_Func1(struct Task *task) return FALSE; } +#define SOME_VRAM_STORE(ptr, posY, posX, toStore) \ +{ \ + u32 index = (posY) * 32 + posX; \ + ptr[index] = toStore; \ +} + static bool8 Phase2_BigPokeball_Func2(struct Task *task) { s16 i, j; @@ -1335,7 +1341,7 @@ static bool8 Phase2_BigPokeball_Func2(struct Task *task) { for (j = 0; j < 30; j++, BigPokeballMap++) { - tilemap[i * 32 + j] = *BigPokeballMap | 0xF000; + SOME_VRAM_STORE(tilemap, i, j, *BigPokeballMap | 0xF000); } } sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5, 160); @@ -1675,12 +1681,6 @@ bool8 FldEff_Pokeball(void) return FALSE; } -#define SOME_VRAM_STORE(ptr, posY, posX, toStore) \ -{ \ - u32 index = (posY) * 32 + posX; \ - ptr[index] = toStore; \ -} - static void sub_814713C(struct Sprite *sprite) { s16 arr0[ARRAY_COUNT(sUnknown_085C8B96)]; @@ -2142,7 +2142,7 @@ static bool8 Phase2_Mugshot_Func2(struct Task *task) { for (j = 0; j < 32; j++, mugshotsMap++) { - tilemap[i * 32 + j] = *mugshotsMap | 0xF000; + SOME_VRAM_STORE(tilemap, i, j, *mugshotsMap | 0xF000); } } @@ -2960,17 +2960,15 @@ static bool8 Phase2_RectangularSpiral_Func2(struct Task *task) if (sub_8149048(gUnknown_085C8D38[j / 2], &sRectangularSpiralTransition[j])) { - u32 one; done = FALSE; var = sRectangularSpiralTransition[j].field_2; - one = 1; - if ((j & 1) == one) + if ((j % 2) == 1) var = 0x27D - var; var2 = var % 32; - var3 = var / 32 * 32; + var3 = var / 32; - tilemap[var3 + var2] = 0xF002; + SOME_VRAM_STORE(tilemap, var3, var2, 0xF002); } } } From 5c6b8ea8d67fb34b7f80b8856ee2d12caabff68f Mon Sep 17 00:00:00 2001 From: Kurausukun Date: Tue, 1 Jun 2021 17:14:45 -0400 Subject: [PATCH 08/27] re-add const to gEvolutionTable in daycare.c --- src/daycare.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/daycare.c b/src/daycare.c index 14053217d..4199bfda6 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -23,7 +23,7 @@ #include "constants/moves.h" #include "constants/region_map_sections.h" -extern struct Evolution gEvolutionTable[][EVOS_PER_MON]; +extern const struct Evolution gEvolutionTable[][EVOS_PER_MON]; // this file's functions static void ClearDaycareMonMail(struct DaycareMail *mail); From a839463c849679974c986bf9c9c260eff0e94cb7 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Tue, 1 Jun 2021 20:40:11 -0400 Subject: [PATCH 09/27] Optimize Makefile. Don't do recursive makes for COMPARE and MODERN, use minimal makefile for making tools. --- Makefile | 38 +++++++++++++++++++++++--------------- make_tools.mk | 12 ++++++++++++ 2 files changed, 35 insertions(+), 15 deletions(-) create mode 100644 make_tools.mk diff --git a/Makefile b/Makefile index 6842d3fd7..4b36feec8 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,11 @@ +$(info start $(shell date +%s%3N)) TOOLCHAIN := $(DEVKITARM) COMPARE ?= 0 +ifeq (compare,$(MAKECMDGOALS)) + COMPARE := 1 +endif + # don't use dkP's base_tools anymore # because the redefinition of $(CC) conflicts # with when we want to use $(CC) to preprocess files @@ -36,6 +41,10 @@ MAKER_CODE := 01 REVISION := 0 MODERN ?= 0 +ifeq (modern,$(MAKECMDGOALS)) + MODERN := 1 +endif + # use arm-none-eabi-cpp for macOS # as macOS's default compiler is clang # and clang's preprocessor will warn on \u @@ -143,9 +152,10 @@ infoshell = $(foreach line, $(shell $1 | sed "s/ /__SPACE__/g"), $(info $(subst # Build tools when building the rom # Disable dependency scanning for clean/tidy/tools -# Don't build tools yet for modern because we perform a recursive make -ifeq (,$(filter-out all rom berry_fix libagbsyscall,$(MAKECMDGOALS))) -$(call infoshell, $(MAKE) tools) +# Use a separate minimal makefile for speed +# Since we don't need to reload most of this makefile +ifeq (,$(filter-out all rom compare modern berry_fix libagbsyscall,$(MAKECMDGOALS))) +$(call infoshell, $(MAKE) -f make_tools.mk) else NODEP := 1 endif @@ -154,16 +164,17 @@ endif ifeq (,$(MAKECMDGOALS)) SCAN_DEPS := 1 else - # compare and modern perform recursive calls, so don't scan dependencies yet # clean, tidy, tools, mostlyclean, clean-tools, $(TOOLDIRS), tidymodern, tidynonmodern don't even build the ROM # berry_fix and libagbsyscall do their own thing - ifeq (,$(filter-out clean compare tidy tools mostlyclean clean-tools $(TOOLDIRS) berry_fix libagbsyscall modern tidymodern tidynonmodern,$(MAKECMDGOALS))) + ifeq (,$(filter-out clean tidy tools mostlyclean clean-tools $(TOOLDIRS) tidymodern tidynonmodern berry_fix libagbsyscall,$(MAKECMDGOALS))) SCAN_DEPS := 0 else SCAN_DEPS := 1 endif endif +$(info scanfiles $(shell date +%s%3N)) +ifeq ($(SCAN_DEPS),1) C_SRCS_IN := $(wildcard $(C_SUBDIR)/*.c $(C_SUBDIR)/*/*.c $(C_SUBDIR)/*/*/*.c) C_SRCS := $(foreach src,$(C_SRCS_IN),$(if $(findstring .inc.c,$(src)),,$(src))) C_OBJS := $(patsubst $(C_SUBDIR)/%.c,$(C_BUILDDIR)/%.o,$(C_SRCS)) @@ -193,11 +204,12 @@ OBJS := $(C_OBJS) $(GFLIB_OBJS) $(C_ASM_OBJS) $(ASM_OBJS) $(DATA_ASM_OBJS) $ OBJS_REL := $(patsubst $(OBJ_DIR)/%,%,$(OBJS)) SUBDIRS := $(sort $(dir $(OBJS))) +$(shell mkdir -p $(SUBDIRS)) +endif +$(info scanfiles done $(shell date +%s%3N)) AUTO_GEN_TARGETS := -$(shell mkdir -p $(SUBDIRS)) - all: rom tools: $(TOOLDIRS) @@ -211,7 +223,7 @@ ifeq ($(COMPARE),1) endif # For contributors to make sure a change didn't affect the contents of the ROM. -compare: ; @$(MAKE) COMPARE=1 +compare: all clean: mostlyclean clean-tools @@ -295,11 +307,8 @@ endif # As a side effect, they're evaluated immediately instead of when the rule is invoked. # It doesn't look like $(shell) can be deferred so there might not be a better way. -# ifeq (,$(filter-out all rom compare modern berry_fix libagbsyscall,$(MAKECMDGOALS))) - -#$(info MAKECMDGOALS - $(MAKECMDGOALS)) - ifeq ($(SCAN_DEPS),1) +$(info Scanning deps start $(shell date +%s%3N)) ifeq ($(NODEP),1) $(C_BUILDDIR)/%.o : $(C_SUBDIR)/%.c ifeq (,$(KEEP_TEMPS)) @@ -324,9 +333,7 @@ else $$(AS) $$(ASFLAGS) -o $$@ $$(C_BUILDDIR)/$$*.s endif endef -#$(info C_DEP) $(foreach src, $(C_SRCS), $(eval $(call C_DEP,$(patsubst $(C_SUBDIR)/%.c,$(C_BUILDDIR)/%.o, $(src)),$(src)))) -#$(error done C_DEP) endif ifeq ($(NODEP),1) @@ -388,6 +395,7 @@ $1: $2 $$(shell $(SCANINC) -I include -I "" $2) endef $(foreach src, $(REGULAR_DATA_ASM_SRCS), $(eval $(call DATA_ASM_DEP,$(patsubst $(DATA_ASM_SUBDIR)/%.s,$(DATA_ASM_BUILDDIR)/%.o, $(src)),$(src)))) endif +$(info Scanning deps end $(shell date +%s%3N)) endif $(SONG_BUILDDIR)/%.o: $(SONG_SUBDIR)/%.s @@ -422,7 +430,7 @@ $(ROM): $(ELF) $(OBJCOPY) -O binary $< $@ $(FIX) $@ -p --silent -modern: ; @$(MAKE) MODERN=1 +modern: all berry_fix/berry_fix.gba: berry_fix diff --git a/make_tools.mk b/make_tools.mk new file mode 100644 index 000000000..82a482bca --- /dev/null +++ b/make_tools.mk @@ -0,0 +1,12 @@ + +TOOLDIRS := $(filter-out tools/agbcc tools/binutils,$(wildcard tools/*)) +TOOLBASE = $(TOOLDIRS:tools/%=%) +TOOLS = $(foreach tool,$(TOOLBASE),tools/$(tool)/$(tool)$(EXE)) + +.PHONY: all $(TOOLDIRS) + +all: $(TOOLDIRS) + @: + +$(TOOLDIRS): + @$(MAKE) -C $@ From 92152e45e226b797a5ca10cff0e9e55d2a66a3d8 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Tue, 1 Jun 2021 23:22:15 -0400 Subject: [PATCH 10/27] Fixes to makefile. Merge C_ASM_DEP and DATA_ASM_DEP, NODEP and SCAN_DEPS can be overridden, add --no-print-directory to MAKEFLAGS in make_tools.mk (also removed some unused variables), add newline to help message in preproc. --- Makefile | 23 +++++++++-------------- make_tools.mk | 5 ++--- tools/preproc/preproc.cpp | 2 +- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index a2b013926..5741977ec 100644 --- a/Makefile +++ b/Makefile @@ -157,19 +157,19 @@ infoshell = $(foreach line, $(shell $1 | sed "s/ /__SPACE__/g"), $(info $(subst ifeq (,$(filter-out all rom compare modern berry_fix libagbsyscall,$(MAKECMDGOALS))) $(call infoshell, $(MAKE) -f make_tools.mk) else -NODEP := 1 +NODEP ?= 1 endif # check if we need to scan dependencies based on the rule ifeq (,$(MAKECMDGOALS)) - SCAN_DEPS := 1 + SCAN_DEPS ?= 1 else # clean, tidy, tools, mostlyclean, clean-tools, $(TOOLDIRS), tidymodern, tidynonmodern don't even build the ROM # berry_fix and libagbsyscall do their own thing ifeq (,$(filter-out clean tidy tools mostlyclean clean-tools $(TOOLDIRS) tidymodern tidynonmodern berry_fix libagbsyscall,$(MAKECMDGOALS))) - SCAN_DEPS := 0 + SCAN_DEPS ?= 0 else - SCAN_DEPS := 1 + SCAN_DEPS ?= 1 endif endif @@ -365,11 +365,11 @@ ifeq ($(NODEP),1) $(C_BUILDDIR)/%.o: $(C_SUBDIR)/%.s $(AS) $(ASFLAGS) -o $@ $< else -define C_ASM_DEP -$1: $2 $$(shell $(SCANINC) -I "" $2) - $$(AS) $$(ASFLAGS) -o $$@ $$< +define SRC_ASM_DATA_DEP +$1: $2 $$(shell $(SCANINC) -I include -I "" $2) + $$(PREPROC) $$< charmap.txt | $$(CPP) -I include - | $$(AS) $$(ASFLAGS) -o $$@ endef -$(foreach src, $(C_ASM_SRCS), $(eval $(call C_ASM_DEP,$(patsubst $(C_SUBDIR)/%.s,$(C_BUILDDIR)/%.o, $(src)),$(src)))) +$(foreach src, $(C_ASM_SRCS), $(eval $(call SRC_ASM_DATA_DEP,$(patsubst $(C_SUBDIR)/%.s,$(C_BUILDDIR)/%.o, $(src)),$(src)))) endif ifeq ($(NODEP),1) @@ -387,12 +387,7 @@ ifeq ($(NODEP),1) $(DATA_ASM_BUILDDIR)/%.o: $(DATA_ASM_SUBDIR)/%.s $(PREPROC) $< charmap.txt | $(CPP) -I include - | $(AS) $(ASFLAGS) -o $@ else -define DATA_ASM_DEP -$1: $2 $$(shell $(SCANINC) -I include -I "" $2) - $$(PREPROC) $$< charmap.txt | $$(CPP) -I include - | $$(AS) $$(ASFLAGS) -o $$@ -endef -$(foreach src, $(REGULAR_DATA_ASM_SRCS), $(eval $(call DATA_ASM_DEP,$(patsubst $(DATA_ASM_SUBDIR)/%.s,$(DATA_ASM_BUILDDIR)/%.o, $(src)),$(src)))) -$(foreach src, $(C_ASM_SRCS), $(eval $(call DATA_ASM_DEP,$(patsubst $(C_SUBDIR)/%.s,$(C_BUILDDIR)/%.o, $(src)),$(src)))) +$(foreach src, $(REGULAR_DATA_ASM_SRCS), $(eval $(call SRC_ASM_DATA_DEP,$(patsubst $(DATA_ASM_SUBDIR)/%.s,$(DATA_ASM_BUILDDIR)/%.o, $(src)),$(src)))) endif $(info Scanning deps end $(shell date +%s%3N)) endif diff --git a/make_tools.mk b/make_tools.mk index 82a482bca..697897a69 100644 --- a/make_tools.mk +++ b/make_tools.mk @@ -1,12 +1,11 @@ +MAKEFLAGS += --no-print-directory + TOOLDIRS := $(filter-out tools/agbcc tools/binutils,$(wildcard tools/*)) -TOOLBASE = $(TOOLDIRS:tools/%=%) -TOOLS = $(foreach tool,$(TOOLBASE),tools/$(tool)/$(tool)$(EXE)) .PHONY: all $(TOOLDIRS) all: $(TOOLDIRS) - @: $(TOOLDIRS): @$(MAKE) -C $@ diff --git a/tools/preproc/preproc.cpp b/tools/preproc/preproc.cpp index 02950a296..eb2d4c8a2 100644 --- a/tools/preproc/preproc.cpp +++ b/tools/preproc/preproc.cpp @@ -134,7 +134,7 @@ int main(int argc, char **argv) { if (argc < 3 || argc > 4) { - std::fprintf(stderr, "Usage: %s SRC_FILE CHARMAP_FILE [-i]\nwhere -i denotes if input is from stdin", argv[0]); + std::fprintf(stderr, "Usage: %s SRC_FILE CHARMAP_FILE [-i]\nwhere -i denotes if input is from stdin\n", argv[0]); return 1; } From 4687847acea342d34985c195a8e7463fdefc4cc4 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Thu, 3 Jun 2021 17:46:09 -0400 Subject: [PATCH 11/27] Fix building with KEEP_TEMPS=1, and NODEP=1. KEEP_TEMPS=1 not working was due to the pattern substitution in the old makefile rules for compiling C files ($*) not working with the explicit generation of dependencies. NODEP=1 not working was due to the NODEP rule for src/%.s not being updated to use preproc and cpp. --- Makefile | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 5741977ec..69173a556 100644 --- a/Makefile +++ b/Makefile @@ -308,7 +308,7 @@ endif ifeq ($(SCAN_DEPS),1) $(info Scanning deps start $(shell date +%s%3N)) ifeq ($(NODEP),1) -$(C_BUILDDIR)/%.o : $(C_SUBDIR)/%.c +$(C_BUILDDIR)/%.o: $(C_SUBDIR)/%.c ifeq (,$(KEEP_TEMPS)) @echo "$(CC1) -o $@ $<" @$(CPP) $(CPPFLAGS) $< | $(PREPROC) $< charmap.txt -i | $(CC1) $(CFLAGS) -o - - | cat - <(echo -e ".text\n\t.align\t2, 0") | $(AS) $(ASFLAGS) -o $@ - @@ -325,17 +325,17 @@ ifeq (,$$(KEEP_TEMPS)) @echo "$$(CC1) -o $$@ $$<" @$$(CPP) $$(CPPFLAGS) $$< | $$(PREPROC) $$< charmap.txt -i | $$(CC1) $$(CFLAGS) -o - - | cat - <(echo -e ".text\n\t.align\t2, 0") | $$(AS) $$(ASFLAGS) -o $$@ - else - @$$(CPP) $$(CPPFLAGS) $$< -o $$(C_BUILDDIR)/$$*.i - @$$(PREPROC) $$(C_BUILDDIR)/$$*.i charmap.txt | $$(CC1) $$(CFLAGS) -o $$(C_BUILDDIR)/$$*.s - @echo -e ".text\n\t.align\t2, 0\n" >> $$(C_BUILDDIR)/$$*.s - $$(AS) $$(ASFLAGS) -o $$@ $$(C_BUILDDIR)/$$*.s + @$$(CPP) $$(CPPFLAGS) $$< -o $$(C_BUILDDIR)/$3.i + @$$(PREPROC) $$(C_BUILDDIR)/$3.i charmap.txt | $$(CC1) $$(CFLAGS) -o $$(C_BUILDDIR)/$3.s + @echo -e ".text\n\t.align\t2, 0\n" >> $$(C_BUILDDIR)/$3.s + $$(AS) $$(ASFLAGS) -o $$@ $$(C_BUILDDIR)/$3.s endif endef -$(foreach src, $(C_SRCS), $(eval $(call C_DEP,$(patsubst $(C_SUBDIR)/%.c,$(C_BUILDDIR)/%.o, $(src)),$(src)))) +$(foreach src, $(C_SRCS), $(eval $(call C_DEP,$(patsubst $(C_SUBDIR)/%.c,$(C_BUILDDIR)/%.o,$(src)),$(src),$(patsubst $(C_SUBDIR)/%.c,%,$(src))))) endif ifeq ($(NODEP),1) -$(GFLIB_BUILDDIR)/%.o : $(GFLIB_SUBDIR)/%.c $$(c_dep) +$(GFLIB_BUILDDIR)/%.o: $(GFLIB_SUBDIR)/%.c $$(c_dep) ifeq (,$(KEEP_TEMPS)) @echo "$(CC1) -o $@ $<" @$(CPP) $(CPPFLAGS) $< | $(PREPROC) $< charmap.txt -i | $(CC1) $(CFLAGS) -o - - | cat - <(echo -e ".text\n\t.align\t2, 0") | $(AS) $(ASFLAGS) -o $@ - @@ -352,18 +352,18 @@ ifeq (,$$(KEEP_TEMPS)) @echo "$$(CC1) -o $$@ $$<" @$$(CPP) $$(CPPFLAGS) $$< | $$(PREPROC) $$< charmap.txt -i | $$(CC1) $$(CFLAGS) -o - - | cat - <(echo -e ".text\n\t.align\t2, 0") | $$(AS) $$(ASFLAGS) -o $$@ - else - @$$(CPP) $$(CPPFLAGS) $$< -o $$(GFLIB_BUILDDIR)/$$*.i - @$$(PREPROC) $$(GFLIB_BUILDDIR)/$$*.i charmap.txt | $$(CC1) $$(CFLAGS) -o $$(GFLIB_BUILDDIR)/$$*.s - @echo -e ".text\n\t.align\t2, 0\n" >> $$(GFLIB_BUILDDIR)/$$*.s - $$(AS) $$(ASFLAGS) -o $$@ $$(GFLIB_BUILDDIR)/$$*.s + @$$(CPP) $$(CPPFLAGS) $$< -o $$(GFLIB_BUILDDIR)/$3.i + @$$(PREPROC) $$(GFLIB_BUILDDIR)/$3.i charmap.txt | $$(CC1) $$(CFLAGS) -o $$(GFLIB_BUILDDIR)/$3.s + @echo -e ".text\n\t.align\t2, 0\n" >> $$(GFLIB_BUILDDIR)/$3.s + $$(AS) $$(ASFLAGS) -o $$@ $$(GFLIB_BUILDDIR)/$3.s endif endef -$(foreach src, $(GFLIB_SRCS), $(eval $(call GFLIB_DEP,$(patsubst $(GFLIB_SUBDIR)/%.c,$(GFLIB_BUILDDIR)/%.o, $(src)),$(src)))) +$(foreach src, $(GFLIB_SRCS), $(eval $(call GFLIB_DEP,$(patsubst $(GFLIB_SUBDIR)/%.c,$(GFLIB_BUILDDIR)/%.o, $(src)),$(src),$(patsubst $(GFLIB_SUBDIR)/%.c,%, $(src))))) endif ifeq ($(NODEP),1) $(C_BUILDDIR)/%.o: $(C_SUBDIR)/%.s - $(AS) $(ASFLAGS) -o $@ $< + $(PREPROC) $< charmap.txt | $(CPP) -I include - | $(AS) $(ASFLAGS) -o $@ else define SRC_ASM_DATA_DEP $1: $2 $$(shell $(SCANINC) -I include -I "" $2) From 7e1ae9f95d41f46abd5888a63fec09664ac89d5a Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Thu, 3 Jun 2021 18:22:49 -0400 Subject: [PATCH 12/27] Remove debug print statements in Makefile. --- Makefile | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Makefile b/Makefile index 69173a556..d7d4b9566 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,3 @@ -$(info start $(shell date +%s%3N)) TOOLCHAIN := $(DEVKITARM) COMPARE ?= 0 @@ -173,7 +172,6 @@ else endif endif -$(info scanfiles $(shell date +%s%3N)) ifeq ($(SCAN_DEPS),1) C_SRCS_IN := $(wildcard $(C_SUBDIR)/*.c $(C_SUBDIR)/*/*.c $(C_SUBDIR)/*/*/*.c) C_SRCS := $(foreach src,$(C_SRCS_IN),$(if $(findstring .inc.c,$(src)),,$(src))) @@ -206,7 +204,6 @@ OBJS_REL := $(patsubst $(OBJ_DIR)/%,%,$(OBJS)) SUBDIRS := $(sort $(dir $(OBJS))) $(shell mkdir -p $(SUBDIRS)) endif -$(info scanfiles done $(shell date +%s%3N)) AUTO_GEN_TARGETS := @@ -306,7 +303,6 @@ endif # It doesn't look like $(shell) can be deferred so there might not be a better way. ifeq ($(SCAN_DEPS),1) -$(info Scanning deps start $(shell date +%s%3N)) ifeq ($(NODEP),1) $(C_BUILDDIR)/%.o: $(C_SUBDIR)/%.c ifeq (,$(KEEP_TEMPS)) @@ -389,7 +385,6 @@ $(DATA_ASM_BUILDDIR)/%.o: $(DATA_ASM_SUBDIR)/%.s else $(foreach src, $(REGULAR_DATA_ASM_SRCS), $(eval $(call SRC_ASM_DATA_DEP,$(patsubst $(DATA_ASM_SUBDIR)/%.s,$(DATA_ASM_BUILDDIR)/%.o, $(src)),$(src)))) endif -$(info Scanning deps end $(shell date +%s%3N)) endif $(SONG_BUILDDIR)/%.o: $(SONG_SUBDIR)/%.s From 7189e4e26f3da36ed9d373f77a9f51a36fc8ddaf Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Thu, 3 Jun 2021 21:05:56 -0400 Subject: [PATCH 13/27] Fix build on macos. Needs include in tools/preproc/c_file.cpp --- tools/preproc/c_file.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/preproc/c_file.cpp b/tools/preproc/c_file.cpp index f7ca4365c..17a08cc9f 100644 --- a/tools/preproc/c_file.cpp +++ b/tools/preproc/c_file.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include "preproc.h" #include "c_file.h" #include "char_util.h" From 2fe7184d10ba183880fe6a6d09926f6286a96ace Mon Sep 17 00:00:00 2001 From: AJ Fontaine <36677462+Fontbane@users.noreply.github.com> Date: Fri, 4 Jun 2021 22:32:33 -0400 Subject: [PATCH 14/27] Rename sText_WildPkmnAppeared2 to reflect its use sText_WildPkmnAppeared2 is used for Legendary battles, so sText_LegendaryPkmnAppeared would be more informative. --- src/battle_message.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/battle_message.c b/src/battle_message.c index a30866410..7ef5fe321 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -383,7 +383,7 @@ static const u8 sText_ThrewPokeblockAtPkmn[] = _("{B_PLAYER_NAME} threw a {POKEB static const u8 sText_OutOfSafariBalls[] = _("{PLAY_SE SE_DING_DONG}ANNOUNCER: You're out of\nSAFARI BALLS! Game over!\p"); static const u8 sText_OpponentMon1Appeared[] = _("{B_OPPONENT_MON1_NAME} appeared!\p"); static const u8 sText_WildPkmnAppeared[] = _("Wild {B_OPPONENT_MON1_NAME} appeared!\p"); -static const u8 sText_WildPkmnAppeared2[] = _("Wild {B_OPPONENT_MON1_NAME} appeared!\p"); +static const u8 sText_LegendaryPkmnAppeared[] = _("Wild {B_OPPONENT_MON1_NAME} appeared!\p"); static const u8 sText_WildPkmnAppearedPause[] = _("Wild {B_OPPONENT_MON1_NAME} appeared!{PAUSE 127}"); static const u8 sText_TwoWildPkmnAppeared[] = _("Wild {B_OPPONENT_MON1_NAME} and\n{B_OPPONENT_MON2_NAME} appeared!\p"); static const u8 sText_Trainer1WantsToBattle[] = _("{B_TRAINER1_CLASS} {B_TRAINER1_NAME}\nwould like to battle!\p"); @@ -2125,7 +2125,7 @@ void BufferStringBattle(u16 stringID) else { if (gBattleTypeFlags & BATTLE_TYPE_LEGENDARY) - stringPtr = sText_WildPkmnAppeared2; + stringPtr = sText_LegendaryPkmnAppeared; else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) // interesting, looks like they had something planned for wild double battles stringPtr = sText_TwoWildPkmnAppeared; else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL) From 3ed06c2cc269c70c2d9a76bd4a063740de6688cd Mon Sep 17 00:00:00 2001 From: ExpoSeed <> Date: Thu, 10 Jun 2021 11:36:10 -0500 Subject: [PATCH 15/27] Remove remaining grey and replace with gray --- data/battle_anim_scripts.s | 30 +++++++++++++++--------------- include/battle_anim.h | 2 +- include/strings.h | 4 ++-- src/battle_anim_dark.c | 10 +++++----- src/battle_anim_effects_2.c | 16 ++++++++-------- src/battle_anim_mons.c | 2 +- src/battle_interface.c | 4 ++-- src/contest.c | 2 +- src/contest_util.c | 2 +- src/strings.c | 6 +++--- src/union_room_chat.c | 2 +- 11 files changed, 40 insertions(+), 40 deletions(-) diff --git a/data/battle_anim_scripts.s b/data/battle_anim_scripts.s index d1c9bc78b..e7aad6a93 100644 --- a/data/battle_anim_scripts.s +++ b/data/battle_anim_scripts.s @@ -1656,12 +1656,12 @@ Explosion1: Move_DEFENSE_CURL: loadspritegfx ANIM_TAG_ECLIPSING_ORB loopsewithpan SE_M_TRI_ATTACK, SOUND_PAN_ATTACKER, 18, 3 - createvisualtask AnimTask_SetGreyscaleOrOriginalPal, 5, ANIM_ATTACKER, 0 + createvisualtask AnimTask_SetGrayscaleOrOriginalPal, 5, ANIM_ATTACKER, 0 createvisualtask AnimTask_DefenseCurlDeformMon, 5 waitforvisualfinish createsprite gEclipsingOrbSpriteTemplate, ANIM_ATTACKER, 2, 0, 6, 0, 1 waitforvisualfinish - createvisualtask AnimTask_SetGreyscaleOrOriginalPal, 5, ANIM_ATTACKER, 1 + createvisualtask AnimTask_SetGrayscaleOrOriginalPal, 5, ANIM_ATTACKER, 1 waitforvisualfinish end @@ -7254,7 +7254,7 @@ Move_IRON_TAIL: createvisualtask AnimTask_ShakeMon, 2, ANIM_TARGET, 3, 0, 6, 1 playsewithpan SE_M_VITAL_THROW2, SOUND_PAN_TARGET waitforvisualfinish - createvisualtask AnimTask_SetGreyscaleOrOriginalPal, 5, ANIM_ATTACKER, 1 + createvisualtask AnimTask_SetGrayscaleOrOriginalPal, 5, ANIM_ATTACKER, 1 clearmonbg ANIM_TARGET blendoff waitforvisualfinish @@ -7274,7 +7274,7 @@ Move_POISON_TAIL: createvisualtask AnimTask_ShakeMon, 2, ANIM_TARGET, 3, 0, 6, 1 playsewithpan SE_M_VITAL_THROW2, SOUND_PAN_TARGET waitforvisualfinish - createvisualtask AnimTask_SetGreyscaleOrOriginalPal, 5, ANIM_ATTACKER, 1 + createvisualtask AnimTask_SetGrayscaleOrOriginalPal, 5, ANIM_ATTACKER, 1 clearmonbg ANIM_TARGET blendoff call PoisonBubblesEffect @@ -7551,7 +7551,7 @@ Move_DISABLE: playsewithpan SE_M_DETECT, SOUND_PAN_ATTACKER createsprite gSpinningSparkleSpriteTemplate, ANIM_ATTACKER, 13, 24, -16 waitforvisualfinish - createvisualtask AnimTask_GrowAndGreyscale, 5 + createvisualtask AnimTask_GrowAndGrayscale, 5 loopsewithpan SE_M_BIND, SOUND_PAN_TARGET, 15, 4 waitforvisualfinish delay 1 @@ -7946,16 +7946,16 @@ Move_PERISH_SONG: panse_1B SE_M_PERISH_SONG, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +2, 0 delay 80 createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 3, 0, 16, RGB_BLACK - createvisualtask AnimTask_SetGreyscaleOrOriginalPal, 5, 4, 0 - createvisualtask AnimTask_SetGreyscaleOrOriginalPal, 5, 5, 0 - createvisualtask AnimTask_SetGreyscaleOrOriginalPal, 5, 6, 0 - createvisualtask AnimTask_SetGreyscaleOrOriginalPal, 5, 7, 0 + createvisualtask AnimTask_SetGrayscaleOrOriginalPal, 5, 4, 0 + createvisualtask AnimTask_SetGrayscaleOrOriginalPal, 5, 5, 0 + createvisualtask AnimTask_SetGrayscaleOrOriginalPal, 5, 6, 0 + createvisualtask AnimTask_SetGrayscaleOrOriginalPal, 5, 7, 0 delay 100 createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 3, 16, 0, RGB_BLACK - createvisualtask AnimTask_SetGreyscaleOrOriginalPal, 5, 4, 1 - createvisualtask AnimTask_SetGreyscaleOrOriginalPal, 5, 5, 1 - createvisualtask AnimTask_SetGreyscaleOrOriginalPal, 5, 6, 1 - createvisualtask AnimTask_SetGreyscaleOrOriginalPal, 5, 7, 1 + createvisualtask AnimTask_SetGrayscaleOrOriginalPal, 5, 4, 1 + createvisualtask AnimTask_SetGrayscaleOrOriginalPal, 5, 5, 1 + createvisualtask AnimTask_SetGrayscaleOrOriginalPal, 5, 6, 1 + createvisualtask AnimTask_SetGrayscaleOrOriginalPal, 5, 7, 1 waitforvisualfinish end @@ -9573,7 +9573,7 @@ Move_DOOM_DESIRE: createvisualtask GetIsDoomDesireHitTurn, 2 delay 1 monbg ANIM_ATK_PARTNER - createvisualtask AnimTask_SetGreyscaleOrOriginalPal, 5, ANIM_TARGET, FALSE + createvisualtask AnimTask_SetGrayscaleOrOriginalPal, 5, ANIM_TARGET, FALSE createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 1, 0, 4, RGB_BLACK waitforvisualfinish setalpha 8, 8 @@ -9581,7 +9581,7 @@ Move_DOOM_DESIRE: createvisualtask AnimTask_ScaleMonAndRestore, 5, -4, -4, 15, ANIM_ATTACKER, 1 waitforvisualfinish delay 20 - createvisualtask AnimTask_SetGreyscaleOrOriginalPal, 5, ANIM_TARGET, TRUE + createvisualtask AnimTask_SetGrayscaleOrOriginalPal, 5, ANIM_TARGET, TRUE createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 1, 4, 0, RGB_BLACK waitforvisualfinish clearmonbg ANIM_ATK_PARTNER diff --git a/include/battle_anim.h b/include/battle_anim.h index 476480489..ad160e74d 100644 --- a/include/battle_anim.h +++ b/include/battle_anim.h @@ -143,7 +143,7 @@ void TranslateSpriteLinear(struct Sprite *sprite); void AnimSpriteOnMonPos(struct Sprite *sprite); void InitAnimLinearTranslationWithSpeedAndPos(struct Sprite *sprite); void TranslateSpriteInCircleOverDuration(struct Sprite *sprite); -void SetGreyscaleOrOriginalPalette(u16 palNum, bool8 restoreOriginal); +void SetGrayscaleOrOriginalPalette(u16 palNum, bool8 restoreOriginal); void PrepareAffineAnimInTaskData(struct Task *task, u8 spriteId, const union AffineAnimCmd *affineAnimCmds); bool8 RunAffineAnimFromTaskData(struct Task *task); void AnimThrowProjectile(struct Sprite *sprite); diff --git a/include/strings.h b/include/strings.h index 04283db0e..9b3be0538 100644 --- a/include/strings.h +++ b/include/strings.h @@ -596,7 +596,7 @@ extern const u8 gText_TooImportantToToss[]; extern const u8 gText_ConfirmTossItems[]; extern const u8 gText_MoveVar1Where[]; -extern const u8 gText_ColorLightShadowDarkGrey[]; +extern const u8 gText_ColorLightShadowDarkGray[]; extern const u8 gText_ColorBlue[]; extern const u8 gText_Friend[]; extern const u8 gText_Tristan[]; @@ -2512,7 +2512,7 @@ extern const u8 gText_MatchCallMay_Intro1[]; extern const u8 gText_MatchCallMay_Intro2[]; // Contest Link -extern const u8 gText_ColorDarkGrey[]; +extern const u8 gText_ColorDarkGray[]; extern const u8 gText_CommunicationStandby[]; extern const u8 gText_AnnouncingResults[]; extern const u8 gText_PreliminaryResults[]; diff --git a/src/battle_anim_dark.c b/src/battle_anim_dark.c index c2bfe269b..8000a648c 100644 --- a/src/battle_anim_dark.c +++ b/src/battle_anim_dark.c @@ -870,7 +870,7 @@ void AnimTask_MetallicShine(u8 taskId) paletteNum = 16 + gSprites[spriteId].oam.paletteNum; if (gBattleAnimArgs[1] == 0) - SetGreyscaleOrOriginalPalette(paletteNum, FALSE); + SetGrayscaleOrOriginalPalette(paletteNum, FALSE); else BlendPalette(paletteNum * 16, 16, 11, gBattleAnimArgs[2]); @@ -900,7 +900,7 @@ static void AnimTask_MetallicShine_Step(u8 taskId) spriteId = GetAnimBattlerSpriteId(ANIM_ATTACKER); paletteNum = 16 + gSprites[spriteId].oam.paletteNum; if (gTasks[taskId].data[1] == 0) - SetGreyscaleOrOriginalPalette(paletteNum, TRUE); + SetGrayscaleOrOriginalPalette(paletteNum, TRUE); DestroySprite(&gSprites[gTasks[taskId].data[0]]); GetBattleAnimBg1Data(&animBg); @@ -925,10 +925,10 @@ static void AnimTask_MetallicShine_Step(u8 taskId) } } -// Changes battler's palette to either greyscale or original. +// Changes battler's palette to either grayscale or original. // arg0: which battler // arg1: FALSE grayscale, TRUE original -void AnimTask_SetGreyscaleOrOriginalPal(u8 taskId) +void AnimTask_SetGrayscaleOrOriginalPal(u8 taskId) { u8 spriteId; u8 battler; @@ -974,7 +974,7 @@ void AnimTask_SetGreyscaleOrOriginalPal(u8 taskId) } if (spriteId != SPRITE_NONE) - SetGreyscaleOrOriginalPalette(gSprites[spriteId].oam.paletteNum + 16, gBattleAnimArgs[1]); + SetGrayscaleOrOriginalPalette(gSprites[spriteId].oam.paletteNum + 16, gBattleAnimArgs[1]); DestroyAnimVisualTask(taskId); } diff --git a/src/battle_anim_effects_2.c b/src/battle_anim_effects_2.c index 5dd584386..0ac5d384b 100755 --- a/src/battle_anim_effects_2.c +++ b/src/battle_anim_effects_2.c @@ -89,7 +89,7 @@ static void AnimPerishSongMusicNote_Step1(struct Sprite *); static void AnimPerishSongMusicNote_Step2(struct Sprite *); static void AnimGuardRing(struct Sprite *); static void AnimTask_Withdraw_Step(u8); -static void AnimTask_GrowAndGreyscale_Step(u8); +static void AnimTask_GrowAndGrayscale_Step(u8); static void AnimTask_Minimize_Step(u8); static void CreateMinimizeSprite(struct Task *, u8); static void ClonedMinizeSprite_Step(struct Sprite *); @@ -1996,26 +1996,26 @@ static void AnimGuillotinePincer_Step3(struct Sprite *sprite) DestroyAnimSprite(sprite); } -// Scales up the target mon sprite, and sets the palette to greyscale. +// Scales up the target mon sprite, and sets the palette to grayscale. // Used in MOVE_DISABLE. // No args. -void AnimTask_GrowAndGreyscale(u8 taskId) +void AnimTask_GrowAndGrayscale(u8 taskId) { u8 spriteId = GetAnimBattlerSpriteId(ANIM_TARGET); PrepareBattlerSpriteForRotScale(spriteId, ST_OAM_OBJ_BLEND); SetSpriteRotScale(spriteId, 0xD0, 0xD0, 0); - SetGreyscaleOrOriginalPalette(gSprites[spriteId].oam.paletteNum + 16, FALSE); + SetGrayscaleOrOriginalPalette(gSprites[spriteId].oam.paletteNum + 16, FALSE); gTasks[taskId].data[0] = 80; - gTasks[taskId].func = AnimTask_GrowAndGreyscale_Step; + gTasks[taskId].func = AnimTask_GrowAndGrayscale_Step; } -static void AnimTask_GrowAndGreyscale_Step(u8 taskId) +static void AnimTask_GrowAndGrayscale_Step(u8 taskId) { if (--gTasks[taskId].data[0] == -1) { u8 spriteId = GetAnimBattlerSpriteId(ANIM_TARGET); ResetSpriteRotScale(spriteId); - SetGreyscaleOrOriginalPalette(gSprites[spriteId].oam.paletteNum + 16, TRUE); + SetGrayscaleOrOriginalPalette(gSprites[spriteId].oam.paletteNum + 16, TRUE); DestroyAnimVisualTask(taskId); } } @@ -3710,7 +3710,7 @@ static void AnimPerishSongMusicNote2(struct Sprite *sprite) } if (++sprite->data[0] == sprite->data[1]) - SetGreyscaleOrOriginalPalette(sprite->oam.paletteNum + 16, 0); + SetGrayscaleOrOriginalPalette(sprite->oam.paletteNum + 16, 0); if (sprite->data[0] == sprite->data[1] + 80) DestroyAnimSprite(sprite); diff --git a/src/battle_anim_mons.c b/src/battle_anim_mons.c index 2082512ff..cf5ae6eb2 100644 --- a/src/battle_anim_mons.c +++ b/src/battle_anim_mons.c @@ -1310,7 +1310,7 @@ u16 ArcTan2Neg(s16 a, s16 b) return -var; } -void SetGreyscaleOrOriginalPalette(u16 paletteNum, bool8 restoreOriginalColor) +void SetGrayscaleOrOriginalPalette(u16 paletteNum, bool8 restoreOriginalColor) { int i; struct PlttData *originalColor; diff --git a/src/battle_interface.c b/src/battle_interface.c index ff376f6f1..50eb5373a 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -159,7 +159,7 @@ enum // strings extern const u8 gText_Slash[]; -extern const u8 gText_HighlightDarkGrey[]; +extern const u8 gText_HighlightDarkGray[]; extern const u8 gText_DynColor2[]; extern const u8 gText_DynColor2Male[]; extern const u8 gText_DynColor1Female[]; @@ -1895,7 +1895,7 @@ static void UpdateNickInHealthbox(u8 healthboxSpriteId, struct Pokemon *mon) u16 species; u8 gender; - StringCopy(gDisplayedStringBattle, gText_HighlightDarkGrey); + StringCopy(gDisplayedStringBattle, gText_HighlightDarkGray); GetMonData(mon, MON_DATA_NICKNAME, nickname); StringGetEnd10(nickname); ptr = StringAppend(gDisplayedStringBattle, nickname); diff --git a/src/contest.c b/src/contest.c index dbbd6ef63..720bea180 100644 --- a/src/contest.c +++ b/src/contest.c @@ -1526,7 +1526,7 @@ static void Task_ShowMoveSelectScreen(u8 taskId) && eContestantStatus[gContestPlayerMonIndex].hasJudgesAttention) { // Highlight the text because it's a combo move - moveNameBuffer = StringCopy(moveName, gText_ColorLightShadowDarkGrey); + moveNameBuffer = StringCopy(moveName, gText_ColorLightShadowDarkGray); } else if (move != MOVE_NONE && eContestantStatus[gContestPlayerMonIndex].prevMove == move diff --git a/src/contest_util.c b/src/contest_util.c index decbded2c..88ab4a7d2 100644 --- a/src/contest_util.c +++ b/src/contest_util.c @@ -497,7 +497,7 @@ static void LoadContestMonName(u8 monIndex) struct ContestPokemon *mon = &gContestMons[monIndex]; u8 *str = gDisplayedStringBattle; if (monIndex == gContestPlayerMonIndex) - str = StringCopy(gDisplayedStringBattle, gText_ColorDarkGrey); + str = StringCopy(gDisplayedStringBattle, gText_ColorDarkGray); StringCopy(str, mon->nickname); AddContestTextPrinter(monIndex, gDisplayedStringBattle, 0); diff --git a/src/strings.c b/src/strings.c index 18cf31fb7..4987e32d2 100644 --- a/src/strings.c +++ b/src/strings.c @@ -1229,7 +1229,7 @@ ALIGNED(4) const u8 gText_Facility[] = _("{STR_VAR_1}"); const u8 gText_Give[] = _("Give"); const u8 gText_NoNeed[] = _("No need"); -const u8 gText_ColorLightShadowDarkGrey[] = _("{COLOR LIGHT_GRAY}{SHADOW DARK_GRAY}"); +const u8 gText_ColorLightShadowDarkGray[] = _("{COLOR LIGHT_GRAY}{SHADOW DARK_GRAY}"); const u8 gText_ColorBlue[] = _("{COLOR BLUE}"); const u8 gText_ColorTransparent[] = _("{HIGHLIGHT TRANSPARENT}{COLOR TRANSPARENT}"); const u8 gText_CDot[] = _("C."); @@ -1239,9 +1239,9 @@ const u8 gText_PreliminaryResults[] = _("The preliminary results!"); const u8 gText_Round2Results[] = _("Round 2 results!"); const u8 gText_ContestantsMonWon[] = _("{STR_VAR_1}'s {STR_VAR_2} won!"); const u8 gText_CommunicationStandby[] = _("Communication standby…"); -const u8 gText_ColorDarkGrey[] = _("{COLOR DARK_GRAY}"); +const u8 gText_ColorDarkGray[] = _("{COLOR DARK_GRAY}"); const u8 gText_ColorDynamic6WhiteDynamic5[] = _("{COLOR_HIGHLIGHT_SHADOW DYNAMIC_COLOR6 WHITE DYNAMIC_COLOR5}"); // Unused -const u8 gText_HighlightDarkGrey[] = _("{HIGHLIGHT DARK_GRAY}"); +const u8 gText_HighlightDarkGray[] = _("{HIGHLIGHT DARK_GRAY}"); const u8 gText_EmptySpace2[] = _(" "); // Unused const u8 gText_DynColor2Male[] = _("{COLOR DYNAMIC_COLOR2}♂"); const u8 gText_DynColor1Female[] = _("{COLOR DYNAMIC_COLOR1}♀"); diff --git a/src/union_room_chat.c b/src/union_room_chat.c index fb875bbb4..8e9f78280 100755 --- a/src/union_room_chat.c +++ b/src/union_room_chat.c @@ -2984,7 +2984,7 @@ static void HideKeyboardSwapMenu(void) static void PrintChatMessage(u16 row, u8 *str, u8 colorIdx) { - // colorIdx: 0 = grey, 1 = red, 2 = green, 3 = blue + // colorIdx: 0 = gray, 1 = red, 2 = green, 3 = blue u8 color[3]; color[0] = TEXT_COLOR_WHITE; color[1] = colorIdx * 2 + 2; From 0a94dba4a7dab779937ba3afd29932aa8d5b535f Mon Sep 17 00:00:00 2001 From: SphericalIce Date: Sun, 13 Jun 2021 13:21:23 +0100 Subject: [PATCH 16/27] Rename item script labels to fit the established name scheme --- data/maps/MagmaHideout_2F_2R/map.json | 2 +- data/maps/MagmaHideout_4F/map.json | 2 +- data/scripts/item_ball_scripts.inc | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/data/maps/MagmaHideout_2F_2R/map.json b/data/maps/MagmaHideout_2F_2R/map.json index 4aa6896f6..968c07fb7 100644 --- a/data/maps/MagmaHideout_2F_2R/map.json +++ b/data/maps/MagmaHideout_2F_2R/map.json @@ -50,7 +50,7 @@ "movement_range_y": 1, "trainer_type": "TRAINER_TYPE_NONE", "trainer_sight_or_berry_tree_id": "0", - "script": "MagmaHideout_2F_2R_EventScript_MaxElixir", + "script": "MagmaHideout_2F_2R_EventScript_ItemMaxElixir", "flag": "FLAG_ITEM_MAGMA_HIDEOUT_2F_2R_MAX_ELIXIR" }, { diff --git a/data/maps/MagmaHideout_4F/map.json b/data/maps/MagmaHideout_4F/map.json index 94cf295e0..67c11481f 100644 --- a/data/maps/MagmaHideout_4F/map.json +++ b/data/maps/MagmaHideout_4F/map.json @@ -115,7 +115,7 @@ "movement_range_y": 1, "trainer_type": "TRAINER_TYPE_NONE", "trainer_sight_or_berry_tree_id": "0", - "script": "MagmaHideout_4F_EventScript_MaxRevive", + "script": "MagmaHideout_4F_EventScript_ItemMaxRevive", "flag": "FLAG_ITEM_MAGMA_HIDEOUT_4F_MAX_REVIVE" } ], diff --git a/data/scripts/item_ball_scripts.inc b/data/scripts/item_ball_scripts.inc index 82633f77c..f9228134c 100644 --- a/data/scripts/item_ball_scripts.inc +++ b/data/scripts/item_ball_scripts.inc @@ -634,7 +634,7 @@ MagmaHideout_1F_EventScript_ItemRareCandy:: @ 82914DE finditem ITEM_RARE_CANDY end -MagmaHideout_2F_2R_EventScript_MaxElixir:: @ 82914EB +MagmaHideout_2F_2R_EventScript_ItemMaxElixir:: @ 82914EB finditem ITEM_MAX_ELIXIR end @@ -650,7 +650,7 @@ MagmaHideout_3F_2R_EventScript_ItemPPMax:: @ 8291512 finditem ITEM_PP_MAX end -MagmaHideout_4F_EventScript_MaxRevive:: @ 829151F +MagmaHideout_4F_EventScript_ItemMaxRevive:: @ 829151F finditem ITEM_MAX_REVIVE end From b6b0062bd60eb57d66b6c79fc48bdbb55d8a5bf5 Mon Sep 17 00:00:00 2001 From: ExpoSeed <43502820+ExpoSeed@users.noreply.github.com> Date: Sun, 13 Jun 2021 16:32:00 -0500 Subject: [PATCH 17/27] Change map header flags to use a bitfield --- include/global.fieldmap.h | 16 ++++++---------- src/bike.c | 2 +- src/item_use.c | 2 +- src/overworld.c | 6 +++--- src/region_map.c | 2 +- 5 files changed, 12 insertions(+), 16 deletions(-) diff --git a/include/global.fieldmap.h b/include/global.fieldmap.h index a3d99ee21..6bafa9747 100644 --- a/include/global.fieldmap.h +++ b/include/global.fieldmap.h @@ -142,19 +142,15 @@ struct MapHeader /* 0x16 */ u8 weather; /* 0x17 */ u8 mapType; /* 0x18 */ u8 filler_18[2]; - /* 0x1A */ u8 flags; + // fields correspond to the arguments in the map_header_flags macro + /* 0x1A */ bool8 allowCycling:1; + bool8 allowEscaping:1; // Escape Rope and Dig + bool8 allowRunning:1; + bool8 showMapName:5; // the last 4 bits are unused + // but the 5 bit sized bitfield is required to match /* 0x1B */ u8 battleType; }; -// Flags for gMapHeader.flags, as defined in the map_header_flags macro -#define MAP_ALLOW_CYCLING (1 << 0) -#define MAP_ALLOW_ESCAPING (1 << 1) // Escape Rope and Dig -#define MAP_ALLOW_RUNNING (1 << 2) -#define MAP_SHOW_MAP_NAME (1 << 3) -#define UNUSED_MAP_FLAGS (1 << 4 | 1 << 5 | 1 << 6 | 1 << 7) - -#define SHOW_MAP_NAME_ENABLED ((gMapHeader.flags & (MAP_SHOW_MAP_NAME | UNUSED_MAP_FLAGS)) == MAP_SHOW_MAP_NAME) - struct ObjectEvent { diff --git a/src/bike.c b/src/bike.c index 62ce3cd44..e97a5e04e 100644 --- a/src/bike.c +++ b/src/bike.c @@ -1053,7 +1053,7 @@ void Bike_HandleBumpySlopeJump(void) bool32 IsRunningDisallowed(u8 metatile) { - if (!(gMapHeader.flags & MAP_ALLOW_RUNNING) || IsRunningDisallowedByMetatile(metatile) == TRUE) + if (!gMapHeader.allowRunning || IsRunningDisallowedByMetatile(metatile) == TRUE) return TRUE; else return FALSE; diff --git a/src/item_use.c b/src/item_use.c index 19f50549e..c9087e929 100755 --- a/src/item_use.c +++ b/src/item_use.c @@ -910,7 +910,7 @@ static void ItemUseOnFieldCB_EscapeRope(u8 taskId) bool8 CanUseDigOrEscapeRopeOnCurMap(void) { - if (gMapHeader.flags & MAP_ALLOW_ESCAPING) + if (gMapHeader.allowEscaping) return TRUE; else return FALSE; diff --git a/src/overworld.c b/src/overworld.c index 600333a47..979ebb74c 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -962,7 +962,7 @@ static u16 GetCenterScreenMetatileBehavior(void) bool32 Overworld_IsBikingAllowed(void) { - if (!(gMapHeader.flags & MAP_ALLOW_CYCLING)) + if (!gMapHeader.allowCycling) return FALSE; else return TRUE; @@ -1687,7 +1687,7 @@ void CB2_ReturnToFieldFadeFromBlack(void) static void FieldCB_FadeTryShowMapPopup(void) { - if (SHOW_MAP_NAME_ENABLED && SecretBaseMapPopupEnabled() == TRUE) + if (gMapHeader.showMapName == TRUE && SecretBaseMapPopupEnabled() == TRUE) ShowMapNamePopup(); FieldCB_WarpExitFadeFromBlack(); } @@ -1933,7 +1933,7 @@ static bool32 LoadMapInStepsLocal(u8 *state, bool32 a2) (*state)++; break; case 11: - if (SHOW_MAP_NAME_ENABLED && SecretBaseMapPopupEnabled() == TRUE) + if (gMapHeader.showMapName == TRUE && SecretBaseMapPopupEnabled() == TRUE) ShowMapNamePopup(); (*state)++; break; diff --git a/src/region_map.c b/src/region_map.c index bec51ebf0..27e035199 100644 --- a/src/region_map.c +++ b/src/region_map.c @@ -1007,7 +1007,7 @@ static void InitMapBasedOnPlayerLocation(void) break; case MAP_TYPE_UNDERGROUND: case MAP_TYPE_UNKNOWN: - if (gMapHeader.flags & MAP_ALLOW_ESCAPING) + if (gMapHeader.allowEscaping) { mapHeader = Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->escapeWarp.mapGroup, gSaveBlock1Ptr->escapeWarp.mapNum); gRegionMap->mapSecId = mapHeader->regionMapSectionId; From 5ccac26f2685aed0f0374d5999ce5506d5a69693 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 16 Jun 2021 11:03:23 -0400 Subject: [PATCH 18/27] Port symfile implementation from Ruby, FireRed --- .github/workflows/build.yml | 44 ++++++++++++++++++++++++++++++++----- Makefile | 13 ++++++++++- 2 files changed, 51 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 822b386ea..de3a35c40 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,11 +7,29 @@ on: jobs: build: - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest + env: + GAME_VERSION: EMERALD + GAME_REVISION: 0 + GAME_LANGUAGE: ENGLISH + MODERN: 0 + COMPARE: 1 steps: - name: Checkout uses: actions/checkout@master + - name: Checkout syms + uses: actions/checkout@master + with: + path: symbols + ref: symbols + + - name: Checkout agbcc + uses: actions/checkout@master + with: + path: agbcc + repository: pret/agbcc + - name: Install binutils run: sudo apt install gcc-arm-none-eabi binutils-arm-none-eabi # build-essential, git, and libpng-dev are already installed @@ -20,16 +38,18 @@ jobs: - name: Install agbcc run: | - git clone https://github.com/pret/agbcc.git - cd agbcc ./build.sh ./install.sh ../ + working-directory: agbcc - name: Compare - run: make -j${nproc} compare + run: make -j${nproc} all syms - name: Modern - run: make -j${nproc} modern + env: + MODERN: 1 + COMPARE: 0 + run: make -j${nproc} all - name: Webhook if: ${{ github.event_name == 'push' }} @@ -38,3 +58,17 @@ jobs: CALCROM_DISCORD_WEBHOOK_AVATAR_URL: https://i.imgur.com/38BQHdd.png CALCROM_DISCORD_WEBHOOK_URL: ${{ secrets.CALCROM_DISCORD_WEBHOOK_URL }} run: sh .github/calcrom/webhook.sh pokeemerald + + - name: Move symfiles + if: ${{ github.event_name == 'push' }} + run: | + cp -v *.sym symbols/ + + - name: Update symfiles + if: ${{ github.event_name == 'push' }} + uses: EndBug/add-and-commit@v7 + with: + branch: symbols + cwd: "./symbols" + add: "*.sym" + message: ${{ github.event.commits[0].message }} diff --git a/Makefile b/Makefile index d7d4b9566..89d4b7c94 100644 --- a/Makefile +++ b/Makefile @@ -20,6 +20,7 @@ endif PREFIX := arm-none-eabi- OBJCOPY := $(PREFIX)objcopy +OBJDUMP := $(PREFIX)objdump AS := $(PREFIX)as LD := $(PREFIX)ld @@ -75,6 +76,7 @@ SHELL := /bin/bash -o pipefail ELF = $(ROM:.gba=.elf) MAP = $(ROM:.gba=.map) +SYM = $(ROM:.gba=.sym) C_SUBDIR = src GFLIB_SUBDIR = gflib @@ -153,7 +155,7 @@ infoshell = $(foreach line, $(shell $1 | sed "s/ /__SPACE__/g"), $(info $(subst # Disable dependency scanning for clean/tidy/tools # Use a separate minimal makefile for speed # Since we don't need to reload most of this makefile -ifeq (,$(filter-out all rom compare modern berry_fix libagbsyscall,$(MAKECMDGOALS))) +ifeq (,$(filter-out all rom compare modern berry_fix libagbsyscall syms,$(MAKECMDGOALS))) $(call infoshell, $(MAKE) -f make_tools.mk) else NODEP ?= 1 @@ -211,6 +213,8 @@ all: rom tools: $(TOOLDIRS) +syms: $(SYM) + $(TOOLDIRS): @$(MAKE) -C $@ @@ -428,3 +432,10 @@ berry_fix: libagbsyscall: @$(MAKE) -C libagbsyscall TOOLCHAIN=$(TOOLCHAIN) MODERN=$(MODERN) + +################### +### Symbol file ### +################### + +$(SYM): $(ELF) + $(OBJDUMP) -t $< | sort -u | grep -E "^0[2389]" > $@ From ae8f6e29f8906d53172a05f7b7b497510fe7617c Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 16 Jun 2021 14:43:35 -0400 Subject: [PATCH 19/27] Symplifi symfiles --- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 89d4b7c94..384f012d1 100644 --- a/Makefile +++ b/Makefile @@ -131,6 +131,8 @@ FIX := tools/gbafix/gbafix$(EXE) MAPJSON := tools/mapjson/mapjson$(EXE) JSONPROC := tools/jsonproc/jsonproc$(EXE) +PERL := perl + TOOLDIRS := $(filter-out tools/agbcc tools/binutils,$(wildcard tools/*)) TOOLBASE = $(TOOLDIRS:tools/%=%) TOOLS = $(foreach tool,$(TOOLBASE),tools/$(tool)/$(tool)$(EXE)) @@ -438,4 +440,4 @@ libagbsyscall: ################### $(SYM): $(ELF) - $(OBJDUMP) -t $< | sort -u | grep -E "^0[2389]" > $@ + $(OBJDUMP) -t $< | sort -u | grep -E "^0[2389]" | $(PERL) -p -e 's/^(\w{8}) (\w).{6} \S+\t(\w{8}) (\w+)$$/\1 \2 \3 \4/g' > $@ From d02be421bcc22bb3aea82c23a687120359a0b357 Mon Sep 17 00:00:00 2001 From: Sewef Date: Thu, 17 Jun 2021 14:06:40 +0200 Subject: [PATCH 20/27] Fix sATypeMove_Table definition --- src/battle_message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_message.c b/src/battle_message.c index 7ef5fe321..ca87ced09 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -1328,7 +1328,7 @@ static const u8 sText_SpaceIs[] = _(" is"); static const u8 sText_ApostropheS[] = _("'s"); // For displaying names of invalid moves -static const u8 sATypeMove_Table[][NUMBER_OF_MON_TYPES - 1] = +static const u8 sATypeMove_Table[NUMBER_OF_MON_TYPES][17 = { [TYPE_NORMAL] = _("a NORMAL move"), [TYPE_FIGHTING] = _("a FIGHTING move"), From fd55a0d0154242f155afd2981d64f3156d92d53d Mon Sep 17 00:00:00 2001 From: Sewef Date: Thu, 17 Jun 2021 14:12:06 +0200 Subject: [PATCH 21/27] Update src/battle_message.c Nothing happened. Co-authored-by: LOuroboros --- src/battle_message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_message.c b/src/battle_message.c index ca87ced09..ae30a2a62 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -1328,7 +1328,7 @@ static const u8 sText_SpaceIs[] = _(" is"); static const u8 sText_ApostropheS[] = _("'s"); // For displaying names of invalid moves -static const u8 sATypeMove_Table[NUMBER_OF_MON_TYPES][17 = +static const u8 sATypeMove_Table[NUMBER_OF_MON_TYPES][17] = { [TYPE_NORMAL] = _("a NORMAL move"), [TYPE_FIGHTING] = _("a FIGHTING move"), From 6ca73737cf5142962e8c27d1b6750158c60676c6 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 18 Jun 2021 12:53:15 -0400 Subject: [PATCH 22/27] Fix regex error --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 384f012d1..2e5afdf0c 100644 --- a/Makefile +++ b/Makefile @@ -440,4 +440,4 @@ libagbsyscall: ################### $(SYM): $(ELF) - $(OBJDUMP) -t $< | sort -u | grep -E "^0[2389]" | $(PERL) -p -e 's/^(\w{8}) (\w).{6} \S+\t(\w{8}) (\w+)$$/\1 \2 \3 \4/g' > $@ + $(OBJDUMP) -t $< | sort -u | grep -E "^0[2389]" | $(PERL) -p -e 's/^(\w{8}) (\w).{6} \S+\t(\w{8}) (\S+)$$/\1 \2 \3 \4/g' > $@ From 9407a1ac76c03a09a91e204b3d8d40843f43be3b Mon Sep 17 00:00:00 2001 From: ultima-soul <33333039+ultima-soul@users.noreply.github.com> Date: Fri, 18 Jun 2021 19:20:05 -0700 Subject: [PATCH 23/27] Replace hardcoded number in MakeCaptureStars. --- src/battle_anim_throw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_anim_throw.c b/src/battle_anim_throw.c index 83768b476..4064e250c 100755 --- a/src/battle_anim_throw.c +++ b/src/battle_anim_throw.c @@ -1420,7 +1420,7 @@ static void MakeCaptureStars(struct Sprite *sprite) LoadBallParticleGfx(BALL_MASTER); for (i = 0; i < ARRAY_COUNT(sCaptureStars); i++) { - u8 spriteId = CreateSprite(&sBallParticleSpriteTemplates[4], sprite->pos1.x, sprite->pos1.y, subpriority); + u8 spriteId = CreateSprite(&sBallParticleSpriteTemplates[BALL_MASTER], sprite->pos1.x, sprite->pos1.y, subpriority); if (spriteId != MAX_SPRITES) { gSprites[spriteId].sDuration = 24; From 810b51f96c9f2043a726b782a4884a06430192f2 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Mon, 21 Jun 2021 13:48:03 -0400 Subject: [PATCH 24/27] Clarify contest heart tiles --- include/constants/contest.h | 1 + src/contest.c | 27 +++++++++++++++------------ src/pokemon_summary_screen.c | 20 +++++++++++++------- 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/include/constants/contest.h b/include/constants/contest.h index 28b02e9c0..775dcbe62 100644 --- a/include/constants/contest.h +++ b/include/constants/contest.h @@ -4,6 +4,7 @@ #define APPLAUSE_METER_SIZE 5 #define CONTEST_NUM_APPEALS 5 #define CONTEST_LAST_APPEAL (CONTEST_NUM_APPEALS - 1) +#define MAX_CONTEST_MOVE_HEARTS 8 #define LINK_CONTEST_FLAG_IS_LINK (1 << 0) #define LINK_CONTEST_FLAG_IS_WIRELESS (1 << 1) diff --git a/src/contest.c b/src/contest.c index dbbd6ef63..920c3bdd7 100644 --- a/src/contest.c +++ b/src/contest.c @@ -258,6 +258,11 @@ enum { #define TAG_BLINK_EFFECT_CONTESTANT2 0x80EA #define TAG_BLINK_EFFECT_CONTESTANT3 0x80EB +#define TILE_FILLED_APPEAL_HEART 0x5012 +#define TILE_FILLED_JAM_HEART 0x5014 +#define TILE_EMPTY_APPEAL_HEART 0x5035 +#define TILE_EMPTY_JAM_HEART 0x5036 + enum { SLIDER_HEART_ANIM_NORMAL, SLIDER_HEART_ANIM_DISAPPEAR, @@ -3203,27 +3208,25 @@ static void PrintContestMoveDescription(u16 a) ContestBG_FillBoxWithIncrementingTile(0, categoryTile, 0x0b, 0x1f, 0x05, 0x01, 0x11, 0x01); ContestBG_FillBoxWithIncrementingTile(0, categoryTile + 0x10, 0x0b, 0x20, 0x05, 0x01, 0x11, 0x01); + // Appeal hearts if (gContestEffects[gContestMoves[a].effect].appeal == 0xFF) numHearts = 0; else numHearts = gContestEffects[gContestMoves[a].effect].appeal / 10; - if (numHearts > 8) - numHearts = 8; - // Filled-in hearts - ContestBG_FillBoxWithTile(0, 0x5035, 0x15, 0x1f, 0x08, 0x01, 0x11); - // Empty hearts - ContestBG_FillBoxWithTile(0, 0x5012, 0x15, 0x1f, numHearts, 0x01, 0x11); + if (numHearts > MAX_CONTEST_MOVE_HEARTS) + numHearts = MAX_CONTEST_MOVE_HEARTS; + ContestBG_FillBoxWithTile(0, TILE_EMPTY_APPEAL_HEART, 0x15, 0x1f, MAX_CONTEST_MOVE_HEARTS, 0x01, 0x11); + ContestBG_FillBoxWithTile(0, TILE_FILLED_APPEAL_HEART, 0x15, 0x1f, numHearts, 0x01, 0x11); + // Jam hearts if (gContestEffects[gContestMoves[a].effect].jam == 0xFF) numHearts = 0; else numHearts = gContestEffects[gContestMoves[a].effect].jam / 10; - if (numHearts > 8) - numHearts = 8; - // Filled-in hearts - ContestBG_FillBoxWithTile(0, 0x5036, 0x15, 0x20, 0x08, 0x01, 0x11); - // Empty hearts - ContestBG_FillBoxWithTile(0, 0x5014, 0x15, 0x20, numHearts, 0x01, 0x11); + if (numHearts > MAX_CONTEST_MOVE_HEARTS) + numHearts = MAX_CONTEST_MOVE_HEARTS; + ContestBG_FillBoxWithTile(0, TILE_EMPTY_JAM_HEART, 0x15, 0x20, MAX_CONTEST_MOVE_HEARTS, 0x01, 0x11); + ContestBG_FillBoxWithTile(0, TILE_FILLED_JAM_HEART, 0x15, 0x20, numHearts, 0x01, 0x11); FillWindowPixelBuffer(WIN_MOVE_DESCRIPTION, PIXEL_FILL(0)); Contest_PrintTextToBg0WindowStd(WIN_MOVE_DESCRIPTION, gContestEffectDescriptionPointers[gContestMoves[a].effect]); diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c index 8f16321b2..31505b7c9 100644 --- a/src/pokemon_summary_screen.c +++ b/src/pokemon_summary_screen.c @@ -119,6 +119,11 @@ enum SPRITE_ARR_ID_COUNT = SPRITE_ARR_ID_MOVE_SELECTOR2 + MOVE_SELECTOR_SPRITES_COUNT }; +#define TILE_EMPTY_APPEAL_HEART 0x1039 +#define TILE_FILLED_APPEAL_HEART 0x103A +#define TILE_FILLED_JAM_HEART 0x103C +#define TILE_EMPTY_JAM_HEART 0x103D + static EWRAM_DATA struct PokemonSummaryScreenData { /*0x00*/ union { @@ -2645,29 +2650,30 @@ static void DrawContestMoveHearts(u16 move) if (move != MOVE_NONE) { + // Draw appeal hearts u8 effectValue = gContestEffects[gContestMoves[move].effect].appeal; if (effectValue != 0xFF) effectValue /= 10; - for (i = 0; i < 8; i++) + for (i = 0; i < MAX_CONTEST_MOVE_HEARTS; i++) { if (effectValue != 0xFF && i < effectValue) - tilemap[(i / 4 * 32) + (i & 3) + 0x1E6] = 0x103A; + tilemap[(i / 4 * 32) + (i & 3) + 0x1E6] = TILE_FILLED_APPEAL_HEART; else - tilemap[(i / 4 * 32) + (i & 3) + 0x1E6] = 0x1039; + tilemap[(i / 4 * 32) + (i & 3) + 0x1E6] = TILE_EMPTY_APPEAL_HEART; } + // Draw jam hearts effectValue = gContestEffects[gContestMoves[move].effect].jam; - if (effectValue != 0xFF) effectValue /= 10; - for (i = 0; i < 8; i++) + for (i = 0; i < MAX_CONTEST_MOVE_HEARTS; i++) { if (effectValue != 0xFF && i < effectValue) - tilemap[(i / 4 * 32) + (i & 3) + 0x226] = 0x103C; + tilemap[(i / 4 * 32) + (i & 3) + 0x226] = TILE_FILLED_JAM_HEART; else - tilemap[(i / 4 * 32) + (i & 3) + 0x226] = 0x103D; + tilemap[(i / 4 * 32) + (i & 3) + 0x226] = TILE_EMPTY_JAM_HEART; } } } From 6d92b466e75164fb025909bdd74d5071d5bf646b Mon Sep 17 00:00:00 2001 From: GriffinR Date: Fri, 25 Jun 2021 11:50:09 -0400 Subject: [PATCH 25/27] Add missing use of F_TRAINER_FEMALE --- src/battle_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/battle_main.c b/src/battle_main.c index 001e2ec17..977bcbd9c 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -1961,10 +1961,10 @@ static u8 CreateNPCTrainerParty(struct Pokemon *party, u16 trainerNum, bool8 fir if (gTrainers[trainerNum].doubleBattle == TRUE) personalityValue = 0x80; - else if (gTrainers[trainerNum].encounterMusic_gender & 0x80) - personalityValue = 0x78; + else if (gTrainers[trainerNum].encounterMusic_gender & F_TRAINER_FEMALE) + personalityValue = 0x78; // Use personality more likely to result in a female Pokémon else - personalityValue = 0x88; + personalityValue = 0x88; // Use personality more likely to result in a male Pokémon for (j = 0; gTrainers[trainerNum].trainerName[j] != EOS; j++) nameHash += gTrainers[trainerNum].trainerName[j]; From d391c136d81630c1e8a914c3251b528568633eb0 Mon Sep 17 00:00:00 2001 From: garakmon Date: Sun, 27 Jun 2021 21:14:21 -0400 Subject: [PATCH 26/27] fix encounter slot logic to accomodate changes --- src/wild_encounter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wild_encounter.c b/src/wild_encounter.c index 767fbe4e7..8bcb17605 100644 --- a/src/wild_encounter.c +++ b/src/wild_encounter.c @@ -162,7 +162,7 @@ static u8 ChooseWildMonIndex_Land(void) return 8; else if (rand >= ENCOUNTER_CHANCE_LAND_MONS_SLOT_8 && rand < ENCOUNTER_CHANCE_LAND_MONS_SLOT_9) return 9; - else if (rand == ENCOUNTER_CHANCE_LAND_MONS_SLOT_9) + else if (rand >= ENCOUNTER_CHANCE_LAND_MONS_SLOT_9 && rand < ENCOUNTER_CHANCE_LAND_MONS_SLOT_10) return 10; else return 11; @@ -215,7 +215,7 @@ static u8 ChooseWildMonIndex_Fishing(u8 rod) wildMonIndex = 7; if (rand >= ENCOUNTER_CHANCE_FISHING_MONS_SUPER_ROD_SLOT_7 && rand < ENCOUNTER_CHANCE_FISHING_MONS_SUPER_ROD_SLOT_8) wildMonIndex = 8; - if (rand == ENCOUNTER_CHANCE_FISHING_MONS_SUPER_ROD_SLOT_8) + if (rand >= ENCOUNTER_CHANCE_FISHING_MONS_SUPER_ROD_SLOT_8 && rand < ENCOUNTER_CHANCE_FISHING_MONS_SUPER_ROD_SLOT_9) wildMonIndex = 9; break; } From 93188ef0a8aac4855903543c3b059285baccebc2 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Thu, 1 Jul 2021 00:18:52 -0400 Subject: [PATCH 27/27] Fix divide by 0 in Cmd_getexp --- src/battle_script_commands.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 15e44dd75..d927ffb76 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3269,7 +3269,7 @@ static void Cmd_getexp(void) if (viaExpShare) // at least one mon is getting exp via exp share { - *exp = calculatedExp / 2 / viaSentIn; + *exp = SAFE_DIV(calculatedExp / 2, viaSentIn); if (*exp == 0) *exp = 1; @@ -3279,7 +3279,7 @@ static void Cmd_getexp(void) } else { - *exp = calculatedExp / viaSentIn; + *exp = SAFE_DIV(calculatedExp, viaSentIn); if (*exp == 0) *exp = 1; gExpShareExp = 0;