From 8b59909ac5eb6e3540aeb78396943d57a9702e4d Mon Sep 17 00:00:00 2001 From: Kurausukun Date: Thu, 17 Jun 2021 22:09:48 -0400 Subject: [PATCH 1/3] remove gflib --- Makefile | 38 +++----------------------------- {gflib => include}/bg.h | 0 {gflib => include}/blit.h | 0 {gflib => include}/dma3.h | 0 {gflib => include}/gpu_regs.h | 0 {gflib => include}/io_reg.h | 0 {gflib => include}/malloc.h | 0 {gflib => include}/sprite.h | 0 {gflib => include}/string_util.h | 0 {gflib => include}/text.h | 0 {gflib => include}/window.h | 0 ld_script.txt | 30 ++++++++++++------------- ld_script_modern.txt | 5 ----- {gflib => src}/bg.c | 0 {gflib => src}/blit.c | 0 {gflib => src}/dma3_manager.c | 0 {gflib => src}/gpu_regs.c | 0 {gflib => src}/io_reg.c | 0 {gflib => src}/malloc.c | 0 {gflib => src}/sprite.c | 0 {gflib => src}/string_util.c | 0 {gflib => src}/text.c | 0 {gflib => src}/window.c | 0 sym_bss.txt | 12 +++++----- sym_common.txt | 8 +++---- sym_ewram.txt | 8 +++---- 26 files changed, 32 insertions(+), 69 deletions(-) rename {gflib => include}/bg.h (100%) rename {gflib => include}/blit.h (100%) rename {gflib => include}/dma3.h (100%) rename {gflib => include}/gpu_regs.h (100%) rename {gflib => include}/io_reg.h (100%) rename {gflib => include}/malloc.h (100%) rename {gflib => include}/sprite.h (100%) rename {gflib => include}/string_util.h (100%) rename {gflib => include}/text.h (100%) rename {gflib => include}/window.h (100%) rename {gflib => src}/bg.c (100%) rename {gflib => src}/blit.c (100%) rename {gflib => src}/dma3_manager.c (100%) rename {gflib => src}/gpu_regs.c (100%) rename {gflib => src}/io_reg.c (100%) rename {gflib => src}/malloc.c (100%) rename {gflib => src}/sprite.c (100%) rename {gflib => src}/string_util.c (100%) rename {gflib => src}/text.c (100%) rename {gflib => src}/window.c (100%) diff --git a/Makefile b/Makefile index d7d4b9566..95d6328ef 100644 --- a/Makefile +++ b/Makefile @@ -77,7 +77,6 @@ ELF = $(ROM:.gba=.elf) MAP = $(ROM:.gba=.map) C_SUBDIR = src -GFLIB_SUBDIR = gflib ASM_SUBDIR = asm DATA_SRC_SUBDIR = src/data DATA_ASM_SUBDIR = data @@ -87,7 +86,6 @@ SAMPLE_SUBDIR = sound/direct_sound_samples CRY_SUBDIR = sound/direct_sound_samples/cries C_BUILDDIR = $(OBJ_DIR)/$(C_SUBDIR) -GFLIB_BUILDDIR = $(OBJ_DIR)/$(GFLIB_SUBDIR) ASM_BUILDDIR = $(OBJ_DIR)/$(ASM_SUBDIR) DATA_ASM_BUILDDIR = $(OBJ_DIR)/$(DATA_ASM_SUBDIR) SONG_BUILDDIR = $(OBJ_DIR)/$(SONG_SUBDIR) @@ -111,7 +109,7 @@ LIBPATH := -L "$(dir $(shell $(MODERNCC) -mthumb -print-file-name=libgcc.a))" -L LIB := $(LIBPATH) -lc -lnosys -lgcc -L../../libagbsyscall -lagbsyscall endif -CPPFLAGS := -iquote include -iquote $(GFLIB_SUBDIR) -Wno-trigraphs -DMODERN=$(MODERN) +CPPFLAGS := -iquote include -Wno-trigraphs -DMODERN=$(MODERN) ifneq ($(MODERN),1) CPPFLAGS += -I tools/agbcc/include -I tools/agbcc -nostdinc -undef endif @@ -177,9 +175,6 @@ 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)) -GFLIB_SRCS := $(wildcard $(GFLIB_SUBDIR)/*.c) -GFLIB_OBJS := $(patsubst $(GFLIB_SUBDIR)/%.c,$(GFLIB_BUILDDIR)/%.o,$(GFLIB_SRCS)) - C_ASM_SRCS += $(wildcard $(C_SUBDIR)/*.s $(C_SUBDIR)/*/*.s $(C_SUBDIR)/*/*/*.s) C_ASM_OBJS := $(patsubst $(C_SUBDIR)/%.s,$(C_BUILDDIR)/%.o,$(C_ASM_SRCS)) @@ -198,7 +193,7 @@ SONG_OBJS := $(patsubst $(SONG_SUBDIR)/%.s,$(SONG_BUILDDIR)/%.o,$(SONG_SRCS)) MID_SRCS := $(wildcard $(MID_SUBDIR)/*.mid) MID_OBJS := $(patsubst $(MID_SUBDIR)/%.mid,$(MID_BUILDDIR)/%.o,$(MID_SRCS)) -OBJS := $(C_OBJS) $(GFLIB_OBJS) $(C_ASM_OBJS) $(ASM_OBJS) $(DATA_ASM_OBJS) $(SONG_OBJS) $(MID_OBJS) +OBJS := $(C_OBJS) $(C_ASM_OBJS) $(ASM_OBJS) $(DATA_ASM_OBJS) $(SONG_OBJS) $(MID_OBJS) OBJS_REL := $(patsubst $(OBJ_DIR)/%,%,$(OBJS)) SUBDIRS := $(sort $(dir $(OBJS))) @@ -316,7 +311,7 @@ else endif else define C_DEP -$1: $2 $$(shell $(SCANINC) -I include -I tools/agbcc/include -I gflib $2) +$1: $2 $$(shell $(SCANINC) -I include -I tools/agbcc/include $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 $$@ - @@ -330,33 +325,6 @@ endef $(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) -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 -else -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)/$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),$(patsubst $(GFLIB_SUBDIR)/%.c,%, $(src))))) -endif - ifeq ($(NODEP),1) $(C_BUILDDIR)/%.o: $(C_SUBDIR)/%.s $(PREPROC) $< charmap.txt | $(CPP) -I include - | $(AS) $(ASFLAGS) -o $@ diff --git a/gflib/bg.h b/include/bg.h similarity index 100% rename from gflib/bg.h rename to include/bg.h diff --git a/gflib/blit.h b/include/blit.h similarity index 100% rename from gflib/blit.h rename to include/blit.h diff --git a/gflib/dma3.h b/include/dma3.h similarity index 100% rename from gflib/dma3.h rename to include/dma3.h diff --git a/gflib/gpu_regs.h b/include/gpu_regs.h similarity index 100% rename from gflib/gpu_regs.h rename to include/gpu_regs.h diff --git a/gflib/io_reg.h b/include/io_reg.h similarity index 100% rename from gflib/io_reg.h rename to include/io_reg.h diff --git a/gflib/malloc.h b/include/malloc.h similarity index 100% rename from gflib/malloc.h rename to include/malloc.h diff --git a/gflib/sprite.h b/include/sprite.h similarity index 100% rename from gflib/sprite.h rename to include/sprite.h diff --git a/gflib/string_util.h b/include/string_util.h similarity index 100% rename from gflib/string_util.h rename to include/string_util.h diff --git a/gflib/text.h b/include/text.h similarity index 100% rename from gflib/text.h rename to include/text.h diff --git a/gflib/window.h b/include/window.h similarity index 100% rename from gflib/window.h rename to include/window.h diff --git a/ld_script.txt b/ld_script.txt index 8c8f19015..5770b2cea 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -49,15 +49,15 @@ SECTIONS { { src/crt0.o(.text); src/main.o(.text); - gflib/malloc.o(.text); - gflib/dma3_manager.o(.text); - gflib/gpu_regs.o(.text); - gflib/bg.o(.text); - gflib/blit.o(.text); - gflib/window.o(.text); - gflib/text.o(.text); - gflib/sprite.o(.text); - gflib/string_util.o(.text); + src/malloc.o(.text); + src/dma3_manager.o(.text); + src/gpu_regs.o(.text); + src/bg.o(.text); + src/blit.o(.text); + src/window.o(.text); + src/text.o(.text); + src/sprite.o(.text); + src/string_util.o(.text); src/link.o(.text); src/AgbRfu_LinkManager.o(.text); src/link_rfu_3.o(.text); @@ -436,12 +436,12 @@ SECTIONS { ALIGN(4) { src/main.o(.rodata); - gflib/bg.o(.rodata); - gflib/window.o(.rodata); - gflib/text.o(.rodata); - gflib/sprite.o(.rodata); - gflib/io_reg.o(.rodata); - gflib/string_util.o(.rodata); + src/bg.o(.rodata); + src/window.o(.rodata); + src/text.o(.rodata); + src/sprite.o(.rodata); + src/io_reg.o(.rodata); + src/string_util.o(.rodata); src/link.o(.rodata); src/link.o(.rodata.str1.4); src/AgbRfu_LinkManager.o(.rodata); diff --git a/ld_script_modern.txt b/ld_script_modern.txt index 59d032bb2..72fb4dbc5 100644 --- a/ld_script_modern.txt +++ b/ld_script_modern.txt @@ -14,7 +14,6 @@ SECTIONS { . = 0x1C000; src/*.o(ewram_data); - gflib/*.o(ewram_data); . = 0x40000; } @@ -26,7 +25,6 @@ SECTIONS { { /* .bss starts at 0x3000000 */ src/*.o(.bss); - gflib/*.o(.bss); *libc.a:*.o(.bss*); *libnosys.a:*.o(.bss*); @@ -35,7 +33,6 @@ SECTIONS { /* COMMON starts at 0x30022A8 */ src/*.o(COMMON); - gflib/*.o(COMMON); *libc.a:*.o(COMMON); *libnosys.a:*.o(COMMON); end = .; @@ -49,7 +46,6 @@ SECTIONS { { src/crt0.o(.text*); src/*.o(.text*); - gflib/*.o(.text*); asm/*.o(.text*); } =0 @@ -84,7 +80,6 @@ SECTIONS { ALIGN(4) { src/*.o(.rodata*); - gflib/*.o(.rodata*); data/*.o(.rodata*); } =0 diff --git a/gflib/bg.c b/src/bg.c similarity index 100% rename from gflib/bg.c rename to src/bg.c diff --git a/gflib/blit.c b/src/blit.c similarity index 100% rename from gflib/blit.c rename to src/blit.c diff --git a/gflib/dma3_manager.c b/src/dma3_manager.c similarity index 100% rename from gflib/dma3_manager.c rename to src/dma3_manager.c diff --git a/gflib/gpu_regs.c b/src/gpu_regs.c similarity index 100% rename from gflib/gpu_regs.c rename to src/gpu_regs.c diff --git a/gflib/io_reg.c b/src/io_reg.c similarity index 100% rename from gflib/io_reg.c rename to src/io_reg.c diff --git a/gflib/malloc.c b/src/malloc.c similarity index 100% rename from gflib/malloc.c rename to src/malloc.c diff --git a/gflib/sprite.c b/src/sprite.c similarity index 100% rename from gflib/sprite.c rename to src/sprite.c diff --git a/gflib/string_util.c b/src/string_util.c similarity index 100% rename from gflib/string_util.c rename to src/string_util.c diff --git a/gflib/text.c b/src/text.c similarity index 100% rename from gflib/text.c rename to src/text.c diff --git a/gflib/window.c b/src/window.c similarity index 100% rename from gflib/window.c rename to src/window.c diff --git a/sym_bss.txt b/sym_bss.txt index 3166aee45..7bdf99dd5 100644 --- a/sym_bss.txt +++ b/sym_bss.txt @@ -1,10 +1,10 @@ .include "src/main.o" - .include "gflib/malloc.o" - .include "gflib/dma3_manager.o" - .include "gflib/gpu_regs.o" - .include "gflib/bg.o" - .include "gflib/text.o" - .include "gflib/sprite.o" + .include "src/malloc.o" + .include "src/dma3_manager.o" + .include "src/gpu_regs.o" + .include "src/bg.o" + .include "src/text.o" + .include "src/sprite.o" .include "src/link.o" .include "src/AgbRfu_LinkManager.o" .include "src/link_rfu_3.o" diff --git a/sym_common.txt b/sym_common.txt index 1525d8aec..23a185e6f 100644 --- a/sym_common.txt +++ b/sym_common.txt @@ -1,17 +1,17 @@ .space 0x8 .include "main.o" - @ ../gflib/bg.o + @ bg.o .align 2 gUnneededFireRedVariable: .space 4 - @ ../gflib/window.o + @ window.o .align 4 gTransparentTileNumber: .space 1 .align 4 gWindowBgTilemapBuffers: .space 16 - @ ../gflib/text.o + @ text.o .align 4 gFonts: .space 4 @@ -24,7 +24,7 @@ gCurGlyph: .align 2 gTextFlags: .space 4 - @ ../gflib/sprite.o + @ sprite.o .align 2 gOamMatrixAllocBitmap: .space 4 diff --git a/sym_ewram.txt b/sym_ewram.txt index 88c4461cb..f461cfa10 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -1,9 +1,9 @@ .include "src/decompress.o" .include "src/main.o" - .include "gflib/window.o" - .include "gflib/text.o" - .include "gflib/sprite.o" - .include "gflib/string_util.o" + .include "src/window.o" + .include "src/text.o" + .include "src/sprite.o" + .include "src/string_util.o" .include "src/link.o" .include "src/AgbRfu_LinkManager.o" .include "src/link_rfu_3.o" From 10c80230c4b24074a8a9e46661db91fa8d465780 Mon Sep 17 00:00:00 2001 From: Kurausukun Date: Fri, 18 Jun 2021 00:15:45 -0400 Subject: [PATCH 2/3] change printItemFunc to use u32 instead of s32 also change a use of -2 to LIST_CANCEL --- include/list_menu.h | 2 +- src/battle_pyramid_bag.c | 4 ++-- src/daycare.c | 4 ++-- src/decoration.c | 6 +++--- src/item_menu.c | 4 ++-- src/menu_specialized.c | 2 +- src/player_pc.c | 8 ++++---- src/shop.c | 10 +++++----- src/union_room.c | 17 ++++++++--------- 9 files changed, 28 insertions(+), 29 deletions(-) diff --git a/include/list_menu.h b/include/list_menu.h index 0a54a069a..1c18f3dff 100644 --- a/include/list_menu.h +++ b/include/list_menu.h @@ -31,7 +31,7 @@ struct ListMenuTemplate { const struct ListMenuItem *items; void (* moveCursorFunc)(s32 itemIndex, bool8 onInit, struct ListMenu *list); - void (* itemPrintFunc)(u8 windowId, s32 itemId, u8 y); + void (* itemPrintFunc)(u8 windowId, u32 itemId, u8 y); u16 totalItems; u16 maxShowed; u8 windowId; diff --git a/src/battle_pyramid_bag.c b/src/battle_pyramid_bag.c index 0b13512ec..095cd2bdf 100644 --- a/src/battle_pyramid_bag.c +++ b/src/battle_pyramid_bag.c @@ -106,7 +106,7 @@ static void BagAction_Give(u8); static void BagAction_Cancel(u8); static void BagAction_UseInBattle(u8); static void BagCursorMoved(s32, bool8, struct ListMenu *); -static void PrintItemQuantity(u8, s32, u8); +static void PrintItemQuantity(u8 windowId, u32 itemId, u8 y); static void TossItem(u8); static void DontTossItem(u8); @@ -651,7 +651,7 @@ static void BagCursorMoved(s32 itemIndex, bool8 onInit, struct ListMenu *list) } } -static void PrintItemQuantity(u8 windowId, s32 itemIndex, u8 y) +static void PrintItemQuantity(u8 windowId, u32 itemIndex, u8 y) { s32 xAlign; if (itemIndex == LIST_CANCEL) diff --git a/src/daycare.c b/src/daycare.c index 4199bfda6..6a1715049 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -29,7 +29,7 @@ extern const struct Evolution gEvolutionTable[][EVOS_PER_MON]; static void ClearDaycareMonMail(struct DaycareMail *mail); static void SetInitialEggData(struct Pokemon *mon, u16 species, struct DayCare *daycare); static u8 GetDaycareCompatibilityScore(struct DayCare *daycare); -static void DaycarePrintMonInfo(u8 windowId, s32 daycareSlotId, u8 y); +static void DaycarePrintMonInfo(u8 windowId, u32 daycareSlotId, u8 y); // RAM buffers used to assist with BuildEggMoveset() EWRAM_DATA static u16 sHatchedEggLevelUpMoves[EGG_LVL_UP_MOVES_ARRAY_COUNT] = {0}; @@ -1226,7 +1226,7 @@ static void DaycarePrintMonLvl(struct DayCare *daycare, u8 windowId, u32 daycare DaycareAddTextPrinter(windowId, lvlText, x, y); } -static void DaycarePrintMonInfo(u8 windowId, s32 daycareSlotId, u8 y) +static void DaycarePrintMonInfo(u8 windowId, u32 daycareSlotId, u8 y) { if (daycareSlotId < (unsigned) DAYCARE_MON_COUNT) { diff --git a/src/decoration.c b/src/decoration.c index 6b6cf21e8..ebd7eb26c 100644 --- a/src/decoration.c +++ b/src/decoration.c @@ -147,7 +147,7 @@ static void ReturnToActionsMenuFromCategories(u8 taskId); static void ExitTraderDecorationMenu(u8 taskId); static void CopyDecorationMenuItemName(u8 *dest, u16 decoration); static void DecorationItemsMenu_OnCursorMove(s32 itemIndex, bool8 flag, struct ListMenu *menu); -static void DecorationItemsMenu_PrintDecorationInUse(u8 windowId, s32 itemIndex, u8 y); +static void DecorationItemsMenu_PrintDecorationInUse(u8 windowId, u32 itemIndex, u8 y); static void ShowDecorationItemsWindow(u8 taskId); static void HandleDecorationItemsMenuInput(u8 taskId); static void PrintDecorationItemDescription(s32 itemIndex); @@ -912,9 +912,9 @@ static void DecorationItemsMenu_OnCursorMove(s32 itemIndex, bool8 flag, struct L PrintDecorationItemDescription(itemIndex); } -static void DecorationItemsMenu_PrintDecorationInUse(u8 windowId, s32 itemIndex, u8 y) +static void DecorationItemsMenu_PrintDecorationInUse(u8 windowId, u32 itemIndex, u8 y) { - if (itemIndex != -2) + if (itemIndex != LIST_CANCEL) { if (IsDecorationIndexInSecretBase(itemIndex + 1) == TRUE) BlitMenuInfoIcon(windowId, MENU_INFO_ICON_BALL_RED, 92, y + 2); diff --git a/src/item_menu.c b/src/item_menu.c index de4d82e9b..39abf883a 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -133,7 +133,7 @@ void UpdatePocketScrollPositions(void); u8 CreateBagInputHandlerTask(u8); void sub_81AC23C(u8); void BagMenu_MoveCursorCallback(s32 a, bool8 b, struct ListMenu*); -void BagMenu_ItemPrintCallback(u8 windowId, s32 itemIndex, u8 a); +void BagMenu_ItemPrintCallback(u8 windowId, u32 itemIndex, u8 a); void ItemMenu_UseOutOfBattle(u8 taskId); void ItemMenu_Toss(u8 taskId); void ItemMenu_Register(u8 taskId); @@ -893,7 +893,7 @@ void BagMenu_MoveCursorCallback(s32 itemIndex, bool8 onInit, struct ListMenu *li } } -void BagMenu_ItemPrintCallback(u8 windowId, s32 itemIndex, u8 y) +void BagMenu_ItemPrintCallback(u8 windowId, u32 itemIndex, u8 y) { u16 itemId; u16 itemQuantity; diff --git a/src/menu_specialized.c b/src/menu_specialized.c index 4c4be57f0..2afcf51ca 100644 --- a/src/menu_specialized.c +++ b/src/menu_specialized.c @@ -253,7 +253,7 @@ static u8 sub_81D1D34(u8 a0) return sUnknown_0203CF48[a0]; } -static void sub_81D1D44(u8 windowId, s32 itemId, u8 y) +static void sub_81D1D44(u8 windowId, u32 itemId, u8 y) { u8 buffer[30]; u16 length; diff --git a/src/player_pc.c b/src/player_pc.c index a040ba5b6..946f0645c 100644 --- a/src/player_pc.c +++ b/src/player_pc.c @@ -119,7 +119,7 @@ static void sub_816C060(u16 itemId); static void sub_816BEF0(s32 id); static void sub_816B4DC(u8 taskId); static void ItemStorage_MoveCursor(s32 id, bool8 b, struct ListMenu * thisMenu); -static void fish4_goto_x5_or_x6(u8 windowId, s32 id, u8 yOffset); +static void fish4_goto_x5_or_x6(u8 windowId, u32 id, u8 yOffset); // EWRAM static EWRAM_DATA const u8 *gPcItemMenuOptionOrder = NULL; @@ -943,7 +943,7 @@ static void ItemStorage_MoveCursor(s32 id, bool8 b, struct ListMenu *thisMenu) if (gUnknown_0203BCC4->unk666 == 0xFF) { sub_816C0C8(); - if (id != -2) + if (id != LIST_CANCEL) sub_816C060(gSaveBlock1Ptr->pcItems[id].itemId); else sub_816C060(ITEMPC_GO_BACK_TO_PREV); @@ -951,9 +951,9 @@ static void ItemStorage_MoveCursor(s32 id, bool8 b, struct ListMenu *thisMenu) } } -static void fish4_goto_x5_or_x6(u8 windowId, s32 id, u8 yOffset) +static void fish4_goto_x5_or_x6(u8 windowId, u32 id, u8 yOffset) { - if (id != -2) + if (id != LIST_CANCEL) { if (gUnknown_0203BCC4->unk666 != 0xFF) { diff --git a/src/shop.c b/src/shop.c index 55b421928..2a30bea22 100755 --- a/src/shop.c +++ b/src/shop.c @@ -91,7 +91,7 @@ static void Task_ReturnToItemListAfterDecorationPurchase(u8 taskId); static void Task_HandleShopMenuBuy(u8 taskId); static void Task_HandleShopMenuSell(u8 taskId); static void BuyMenuPrintItemDescriptionAndShowItemIcon(s32 item, bool8 onInit, struct ListMenu *list); -static void BuyMenuPrintPriceInList(u8 windowId, s32 item, u8 y); +static void BuyMenuPrintPriceInList(u8 windowId, u32 itemId, u8 y); static const struct YesNoFuncTable sShopPurchaseYesNoFuncs = { @@ -552,17 +552,17 @@ static void BuyMenuPrintItemDescriptionAndShowItemIcon(s32 item, bool8 onInit, s BuyMenuPrint(2, description, 3, 1, 0, 0); } -static void BuyMenuPrintPriceInList(u8 windowId, s32 item, u8 y) +static void BuyMenuPrintPriceInList(u8 windowId, u32 itemId, u8 y) { u8 x; - if (item != LIST_CANCEL) + if (itemId != LIST_CANCEL) { if (sMartInfo.martType == MART_TYPE_NORMAL) { ConvertIntToDecimalStringN( gStringVar1, - ItemId_GetPrice(item) >> GetPriceReduction(POKENEWS_SLATEPORT), + ItemId_GetPrice(itemId) >> GetPriceReduction(POKENEWS_SLATEPORT), STR_CONV_MODE_LEFT_ALIGN, 5); } @@ -570,7 +570,7 @@ static void BuyMenuPrintPriceInList(u8 windowId, s32 item, u8 y) { ConvertIntToDecimalStringN( gStringVar1, - gDecorations[item].price, + gDecorations[itemId].price, STR_CONV_MODE_LEFT_ALIGN, 5); } diff --git a/src/union_room.c b/src/union_room.c index bd6b303b9..372792a13 100644 --- a/src/union_room.c +++ b/src/union_room.c @@ -253,10 +253,10 @@ static bool32 UR_PrintFieldMessage(const u8 *); static s32 GetChatLeaderActionRequestMessage(u8 *, u32, u16 *, struct WirelessLink_URoom *); static void Task_InitUnionRoom(u8 taskId); static bool8 AreGnameUnameDifferent(struct WirelessGnameUnamePair*, const struct WirelessGnameUnamePair*); -static void ItemPrintFunc_PossibleGroupMembers(u8, s32, u8); -static void ListMenuItemPrintFunc_UnionRoomGroups(u8, s32, u8); -static void TradeBoardListMenuItemPrintFunc(u8, s32, u8); -static void nullsub_14(u8, s32, u8); +static void ItemPrintFunc_PossibleGroupMembers(u8 windowId, u32 id, u8 y); +static void ListMenuItemPrintFunc_UnionRoomGroups(u8 windowId, u32 id, u8 y); +static void TradeBoardListMenuItemPrintFunc(u8 windowId, u32 id, u8 y); +static void nullsub_14(u8 windowId, u32 id, u8 y); #include "data/union_room.h" @@ -835,7 +835,7 @@ static bool8 Leader_SetStateIfMemberListChanged(struct WirelessLink_Leader *data return FALSE; } -static void ItemPrintFunc_PossibleGroupMembers(u8 windowId, s32 id, u8 y) +static void ItemPrintFunc_PossibleGroupMembers(u8 windowId, u32 id, u8 y) { struct WirelessLink_Leader *data = sWirelessLinkMain.leader; u8 colorIdx = UR_COLOR_DKE_WHT_LTE; @@ -1363,7 +1363,7 @@ static u8 URoomGroupListGetTextColor(struct WirelessLink_Group *data, u32 id) return UR_COLOR_DKE_WHT_LTE; } -static void ListMenuItemPrintFunc_UnionRoomGroups(u8 windowId, s32 id, u8 y) +static void ListMenuItemPrintFunc_UnionRoomGroups(u8 windowId, u32 id, u8 y) { struct WirelessLink_Group *data = sWirelessLinkMain.group; u8 colorId = URoomGroupListGetTextColor(data, id); @@ -4074,9 +4074,8 @@ static s32 UnionRoomGetPlayerInteractionResponse(struct UnkStruct_Main0 *main0, } } -void nullsub_14(u8 windowId, s32 itemId, u8 y) +void nullsub_14(u8 windowId, u32 itemId, u8 y) { - } static void TradeBoardPrintItemInfo(u8 windowId, u8 y, struct GFtgtGname * gname, const u8 * uname, u8 colorIdx) @@ -4100,7 +4099,7 @@ static void TradeBoardPrintItemInfo(u8 windowId, u8 y, struct GFtgtGname * gname } } -static void TradeBoardListMenuItemPrintFunc(u8 windowId, s32 itemId, u8 y) +static void TradeBoardListMenuItemPrintFunc(u8 windowId, u32 itemId, u8 y) { struct WirelessLink_Leader *data = sWirelessLinkMain.leader; struct GFtgtGname *rfu; From 42730a8315be6abceeb95bc1cd29f4c54077bd2e Mon Sep 17 00:00:00 2001 From: Kurausukun Date: Sat, 3 Jul 2021 17:39:33 -0400 Subject: [PATCH 3/3] Revert "remove gflib" This reverts commit 8b59909ac5eb6e3540aeb78396943d57a9702e4d. --- Makefile | 38 +++++++++++++++++++++++++++++--- {src => gflib}/bg.c | 0 {include => gflib}/bg.h | 0 {src => gflib}/blit.c | 0 {include => gflib}/blit.h | 0 {include => gflib}/dma3.h | 0 {src => gflib}/dma3_manager.c | 0 {src => gflib}/gpu_regs.c | 0 {include => gflib}/gpu_regs.h | 0 {src => gflib}/io_reg.c | 0 {include => gflib}/io_reg.h | 0 {src => gflib}/malloc.c | 0 {include => gflib}/malloc.h | 0 {src => gflib}/sprite.c | 0 {include => gflib}/sprite.h | 0 {src => gflib}/string_util.c | 0 {include => gflib}/string_util.h | 0 {src => gflib}/text.c | 0 {include => gflib}/text.h | 0 {src => gflib}/window.c | 0 {include => gflib}/window.h | 0 ld_script.txt | 30 ++++++++++++------------- ld_script_modern.txt | 5 +++++ sym_bss.txt | 12 +++++----- sym_common.txt | 8 +++---- sym_ewram.txt | 8 +++---- 26 files changed, 69 insertions(+), 32 deletions(-) rename {src => gflib}/bg.c (100%) rename {include => gflib}/bg.h (100%) rename {src => gflib}/blit.c (100%) rename {include => gflib}/blit.h (100%) rename {include => gflib}/dma3.h (100%) rename {src => gflib}/dma3_manager.c (100%) rename {src => gflib}/gpu_regs.c (100%) rename {include => gflib}/gpu_regs.h (100%) rename {src => gflib}/io_reg.c (100%) rename {include => gflib}/io_reg.h (100%) rename {src => gflib}/malloc.c (100%) rename {include => gflib}/malloc.h (100%) rename {src => gflib}/sprite.c (100%) rename {include => gflib}/sprite.h (100%) rename {src => gflib}/string_util.c (100%) rename {include => gflib}/string_util.h (100%) rename {src => gflib}/text.c (100%) rename {include => gflib}/text.h (100%) rename {src => gflib}/window.c (100%) rename {include => gflib}/window.h (100%) diff --git a/Makefile b/Makefile index 95d6328ef..d7d4b9566 100644 --- a/Makefile +++ b/Makefile @@ -77,6 +77,7 @@ ELF = $(ROM:.gba=.elf) MAP = $(ROM:.gba=.map) C_SUBDIR = src +GFLIB_SUBDIR = gflib ASM_SUBDIR = asm DATA_SRC_SUBDIR = src/data DATA_ASM_SUBDIR = data @@ -86,6 +87,7 @@ SAMPLE_SUBDIR = sound/direct_sound_samples CRY_SUBDIR = sound/direct_sound_samples/cries C_BUILDDIR = $(OBJ_DIR)/$(C_SUBDIR) +GFLIB_BUILDDIR = $(OBJ_DIR)/$(GFLIB_SUBDIR) ASM_BUILDDIR = $(OBJ_DIR)/$(ASM_SUBDIR) DATA_ASM_BUILDDIR = $(OBJ_DIR)/$(DATA_ASM_SUBDIR) SONG_BUILDDIR = $(OBJ_DIR)/$(SONG_SUBDIR) @@ -109,7 +111,7 @@ LIBPATH := -L "$(dir $(shell $(MODERNCC) -mthumb -print-file-name=libgcc.a))" -L LIB := $(LIBPATH) -lc -lnosys -lgcc -L../../libagbsyscall -lagbsyscall endif -CPPFLAGS := -iquote include -Wno-trigraphs -DMODERN=$(MODERN) +CPPFLAGS := -iquote include -iquote $(GFLIB_SUBDIR) -Wno-trigraphs -DMODERN=$(MODERN) ifneq ($(MODERN),1) CPPFLAGS += -I tools/agbcc/include -I tools/agbcc -nostdinc -undef endif @@ -175,6 +177,9 @@ 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)) +GFLIB_SRCS := $(wildcard $(GFLIB_SUBDIR)/*.c) +GFLIB_OBJS := $(patsubst $(GFLIB_SUBDIR)/%.c,$(GFLIB_BUILDDIR)/%.o,$(GFLIB_SRCS)) + C_ASM_SRCS += $(wildcard $(C_SUBDIR)/*.s $(C_SUBDIR)/*/*.s $(C_SUBDIR)/*/*/*.s) C_ASM_OBJS := $(patsubst $(C_SUBDIR)/%.s,$(C_BUILDDIR)/%.o,$(C_ASM_SRCS)) @@ -193,7 +198,7 @@ SONG_OBJS := $(patsubst $(SONG_SUBDIR)/%.s,$(SONG_BUILDDIR)/%.o,$(SONG_SRCS)) MID_SRCS := $(wildcard $(MID_SUBDIR)/*.mid) MID_OBJS := $(patsubst $(MID_SUBDIR)/%.mid,$(MID_BUILDDIR)/%.o,$(MID_SRCS)) -OBJS := $(C_OBJS) $(C_ASM_OBJS) $(ASM_OBJS) $(DATA_ASM_OBJS) $(SONG_OBJS) $(MID_OBJS) +OBJS := $(C_OBJS) $(GFLIB_OBJS) $(C_ASM_OBJS) $(ASM_OBJS) $(DATA_ASM_OBJS) $(SONG_OBJS) $(MID_OBJS) OBJS_REL := $(patsubst $(OBJ_DIR)/%,%,$(OBJS)) SUBDIRS := $(sort $(dir $(OBJS))) @@ -311,7 +316,7 @@ else endif else define C_DEP -$1: $2 $$(shell $(SCANINC) -I include -I tools/agbcc/include $2) +$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 $$@ - @@ -325,6 +330,33 @@ endef $(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) +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 +else +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)/$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),$(patsubst $(GFLIB_SUBDIR)/%.c,%, $(src))))) +endif + ifeq ($(NODEP),1) $(C_BUILDDIR)/%.o: $(C_SUBDIR)/%.s $(PREPROC) $< charmap.txt | $(CPP) -I include - | $(AS) $(ASFLAGS) -o $@ diff --git a/src/bg.c b/gflib/bg.c similarity index 100% rename from src/bg.c rename to gflib/bg.c diff --git a/include/bg.h b/gflib/bg.h similarity index 100% rename from include/bg.h rename to gflib/bg.h diff --git a/src/blit.c b/gflib/blit.c similarity index 100% rename from src/blit.c rename to gflib/blit.c diff --git a/include/blit.h b/gflib/blit.h similarity index 100% rename from include/blit.h rename to gflib/blit.h diff --git a/include/dma3.h b/gflib/dma3.h similarity index 100% rename from include/dma3.h rename to gflib/dma3.h diff --git a/src/dma3_manager.c b/gflib/dma3_manager.c similarity index 100% rename from src/dma3_manager.c rename to gflib/dma3_manager.c diff --git a/src/gpu_regs.c b/gflib/gpu_regs.c similarity index 100% rename from src/gpu_regs.c rename to gflib/gpu_regs.c diff --git a/include/gpu_regs.h b/gflib/gpu_regs.h similarity index 100% rename from include/gpu_regs.h rename to gflib/gpu_regs.h diff --git a/src/io_reg.c b/gflib/io_reg.c similarity index 100% rename from src/io_reg.c rename to gflib/io_reg.c diff --git a/include/io_reg.h b/gflib/io_reg.h similarity index 100% rename from include/io_reg.h rename to gflib/io_reg.h diff --git a/src/malloc.c b/gflib/malloc.c similarity index 100% rename from src/malloc.c rename to gflib/malloc.c diff --git a/include/malloc.h b/gflib/malloc.h similarity index 100% rename from include/malloc.h rename to gflib/malloc.h diff --git a/src/sprite.c b/gflib/sprite.c similarity index 100% rename from src/sprite.c rename to gflib/sprite.c diff --git a/include/sprite.h b/gflib/sprite.h similarity index 100% rename from include/sprite.h rename to gflib/sprite.h diff --git a/src/string_util.c b/gflib/string_util.c similarity index 100% rename from src/string_util.c rename to gflib/string_util.c diff --git a/include/string_util.h b/gflib/string_util.h similarity index 100% rename from include/string_util.h rename to gflib/string_util.h diff --git a/src/text.c b/gflib/text.c similarity index 100% rename from src/text.c rename to gflib/text.c diff --git a/include/text.h b/gflib/text.h similarity index 100% rename from include/text.h rename to gflib/text.h diff --git a/src/window.c b/gflib/window.c similarity index 100% rename from src/window.c rename to gflib/window.c diff --git a/include/window.h b/gflib/window.h similarity index 100% rename from include/window.h rename to gflib/window.h diff --git a/ld_script.txt b/ld_script.txt index 5770b2cea..8c8f19015 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -49,15 +49,15 @@ SECTIONS { { src/crt0.o(.text); src/main.o(.text); - src/malloc.o(.text); - src/dma3_manager.o(.text); - src/gpu_regs.o(.text); - src/bg.o(.text); - src/blit.o(.text); - src/window.o(.text); - src/text.o(.text); - src/sprite.o(.text); - src/string_util.o(.text); + gflib/malloc.o(.text); + gflib/dma3_manager.o(.text); + gflib/gpu_regs.o(.text); + gflib/bg.o(.text); + gflib/blit.o(.text); + gflib/window.o(.text); + gflib/text.o(.text); + gflib/sprite.o(.text); + gflib/string_util.o(.text); src/link.o(.text); src/AgbRfu_LinkManager.o(.text); src/link_rfu_3.o(.text); @@ -436,12 +436,12 @@ SECTIONS { ALIGN(4) { src/main.o(.rodata); - src/bg.o(.rodata); - src/window.o(.rodata); - src/text.o(.rodata); - src/sprite.o(.rodata); - src/io_reg.o(.rodata); - src/string_util.o(.rodata); + gflib/bg.o(.rodata); + gflib/window.o(.rodata); + gflib/text.o(.rodata); + gflib/sprite.o(.rodata); + gflib/io_reg.o(.rodata); + gflib/string_util.o(.rodata); src/link.o(.rodata); src/link.o(.rodata.str1.4); src/AgbRfu_LinkManager.o(.rodata); diff --git a/ld_script_modern.txt b/ld_script_modern.txt index 72fb4dbc5..59d032bb2 100644 --- a/ld_script_modern.txt +++ b/ld_script_modern.txt @@ -14,6 +14,7 @@ SECTIONS { . = 0x1C000; src/*.o(ewram_data); + gflib/*.o(ewram_data); . = 0x40000; } @@ -25,6 +26,7 @@ SECTIONS { { /* .bss starts at 0x3000000 */ src/*.o(.bss); + gflib/*.o(.bss); *libc.a:*.o(.bss*); *libnosys.a:*.o(.bss*); @@ -33,6 +35,7 @@ SECTIONS { /* COMMON starts at 0x30022A8 */ src/*.o(COMMON); + gflib/*.o(COMMON); *libc.a:*.o(COMMON); *libnosys.a:*.o(COMMON); end = .; @@ -46,6 +49,7 @@ SECTIONS { { src/crt0.o(.text*); src/*.o(.text*); + gflib/*.o(.text*); asm/*.o(.text*); } =0 @@ -80,6 +84,7 @@ SECTIONS { ALIGN(4) { src/*.o(.rodata*); + gflib/*.o(.rodata*); data/*.o(.rodata*); } =0 diff --git a/sym_bss.txt b/sym_bss.txt index 7bdf99dd5..3166aee45 100644 --- a/sym_bss.txt +++ b/sym_bss.txt @@ -1,10 +1,10 @@ .include "src/main.o" - .include "src/malloc.o" - .include "src/dma3_manager.o" - .include "src/gpu_regs.o" - .include "src/bg.o" - .include "src/text.o" - .include "src/sprite.o" + .include "gflib/malloc.o" + .include "gflib/dma3_manager.o" + .include "gflib/gpu_regs.o" + .include "gflib/bg.o" + .include "gflib/text.o" + .include "gflib/sprite.o" .include "src/link.o" .include "src/AgbRfu_LinkManager.o" .include "src/link_rfu_3.o" diff --git a/sym_common.txt b/sym_common.txt index 23a185e6f..1525d8aec 100644 --- a/sym_common.txt +++ b/sym_common.txt @@ -1,17 +1,17 @@ .space 0x8 .include "main.o" - @ bg.o + @ ../gflib/bg.o .align 2 gUnneededFireRedVariable: .space 4 - @ window.o + @ ../gflib/window.o .align 4 gTransparentTileNumber: .space 1 .align 4 gWindowBgTilemapBuffers: .space 16 - @ text.o + @ ../gflib/text.o .align 4 gFonts: .space 4 @@ -24,7 +24,7 @@ gCurGlyph: .align 2 gTextFlags: .space 4 - @ sprite.o + @ ../gflib/sprite.o .align 2 gOamMatrixAllocBitmap: .space 4 diff --git a/sym_ewram.txt b/sym_ewram.txt index f461cfa10..88c4461cb 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -1,9 +1,9 @@ .include "src/decompress.o" .include "src/main.o" - .include "src/window.o" - .include "src/text.o" - .include "src/sprite.o" - .include "src/string_util.o" + .include "gflib/window.o" + .include "gflib/text.o" + .include "gflib/sprite.o" + .include "gflib/string_util.o" .include "src/link.o" .include "src/AgbRfu_LinkManager.o" .include "src/link_rfu_3.o"