From 9a6f6212b2751b2b66b86d3cdaf13a034201371d Mon Sep 17 00:00:00 2001 From: Ariel Antonitis Date: Tue, 15 Jun 2021 18:05:38 -0400 Subject: [PATCH] Fixed bug where selling items freed sprite palettes too early. --- Makefile | 5 +++++ gflib/sprite.c | 15 ++++++++++----- remote_build.sh | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 64ed041d48..23d0a8d524 100644 --- a/Makefile +++ b/Makefile @@ -280,6 +280,11 @@ ifeq ($(DINFO),1) override CFLAGS += -g endif +ifeq ($(DDEBUG),1) +override ASFLAGS += --defsym DEBUG=1 +override CPPFLAGS += -D DEBUG=1 +endif + $(C_BUILDDIR)/%.o : $(C_SUBDIR)/%.c $$(c_dep) @$(CPP) $(CPPFLAGS) $< -o $(C_BUILDDIR)/$*.i @$(PREPROC) $(C_BUILDDIR)/$*.i charmap.txt | $(CC1) $(CFLAGS) -o $(C_BUILDDIR)/$*.s diff --git a/gflib/sprite.c b/gflib/sprite.c index 36675535b5..92c01b7294 100644 --- a/gflib/sprite.c +++ b/gflib/sprite.c @@ -1673,11 +1673,16 @@ u16 GetSpritePaletteTagByPaletteNum(u8 paletteNum) void FreeSpritePaletteByTag(u16 tag) { u8 index = IndexOfSpritePaletteTag(tag); - u16 emptyPalette[16] = {0}; - if (index != 0xFF) { - sSpritePaletteTags[index] = 0xFFFF; - LoadPalette(emptyPalette, index * 16 + 0x100, 32); // TODO: For debugging only - } + #if DEBUG + u16 emptyPalette[16] = {0}; + if (index != 0xFF) { + sSpritePaletteTags[index] = 0xFFFF; + LoadPalette(emptyPalette, index * 16 + 0x100, 32); + } + #else + if (index != 0xFF) + sSpritePaletteTags[index] = 0xFFFF; + #endif } void SetSubspriteTables(struct Sprite *sprite, const struct SubspriteTable *subspriteTables) diff --git a/remote_build.sh b/remote_build.sh index 1f6dbd1f46..1d603ddc89 100644 --- a/remote_build.sh +++ b/remote_build.sh @@ -11,5 +11,5 @@ set -x git push build --force # `nproc` must be escaped so that it executes on the remote machine ssh $remote_host "cd $remote_path && git reset --hard && git checkout $git_branch && \ - echo \"Using \`nproc\` job(s)\" && make -j\`nproc\`" + echo \"Using \`nproc\` job(s)\" && make DDEBUG=1 -j\`nproc\`" scp "$remote_host:$remote_path/pokeemerald.gba" romhack.gba