From 42730a8315be6abceeb95bc1cd29f4c54077bd2e Mon Sep 17 00:00:00 2001 From: Kurausukun Date: Sat, 3 Jul 2021 17:39:33 -0400 Subject: [PATCH] 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"