From 4627f6a410b1434f54ea9bf472c08881f2142806 Mon Sep 17 00:00:00 2001 From: Damian Yerrick Date: Wed, 27 Mar 2024 16:46:03 -0400 Subject: [PATCH] Wonderful port, working this time --- .gitignore | 7 +- gba/CHANGES.txt | 4 + gba/README.md | 2 +- gba/src/help.c | 68 ++++++------ gba/src/placeholder.c | 31 +++--- gba/src/vwflabels.c | 6 +- gba/tonc_migration.txt | 3 - gba/tools/paginate_help.py | 3 + gba/tools/vwfbuild.py | 3 +- gba/wfMakefile | 210 +++++++++++++++++++++++++++++++++++++ gba/wfconfig.toml | 5 + 11 files changed, 279 insertions(+), 63 deletions(-) delete mode 100644 gba/tonc_migration.txt create mode 100644 gba/wfMakefile create mode 100644 gba/wfconfig.toml diff --git a/.gitignore b/.gitignore index bb41f75..d43c51a 100644 --- a/.gitignore +++ b/.gitignore @@ -38,10 +38,11 @@ __pycache__/ # these are unrelated to NES savtool's image format /gameboy/gb240p.sav /gba/build -/gba/240pee_mb.elf -/gba/240pee_mb.gba -/gba/240pee_mb.sav +/gba/240p*.elf +/gba/240p*.gba +/gba/*.sav /gba/.map +/gba/compile_commands.json /nes/obj/nes/*.s /nes/obj/nes/*.sav /nes/obj/nes/last-commit* diff --git a/gba/CHANGES.txt b/gba/CHANGES.txt index 5891508..16c4918 100644 --- a/gba/CHANGES.txt +++ b/gba/CHANGES.txt @@ -1,6 +1,10 @@ 0.24 (future) * Replace Grid and Linearity with Monoscope (thanks Lorenzoone) * Sound test: add surround option +* Hill zone: scroll the top scanline too (thanks Lorenzoone) +* Shadow sprite: fix sprite when changing background + (thanks Lorenzoone) +* Port from libgba to libtonc * Reflect rebranding of Twitter to X 0.23 (2023-03-03) diff --git a/gba/README.md b/gba/README.md index f50b13a..83356c8 100644 --- a/gba/README.md +++ b/gba/README.md @@ -109,7 +109,7 @@ Limits Building -------- Build requirements: GNU Coreutils and Make (use devkitPro MSYS on -Windows), devkitARM, libgba, Python 3, and Pillow. +Windows), devkitARM, libtonc, Python 3, and Pillow. Under Windows, open a devkitPro MSYS and type `make`. Under Linux or macOS, once you have installed `gba-dev` using pacman, type these: diff --git a/gba/src/help.c b/gba/src/help.c index 21c7a62..66b904b 100644 --- a/gba/src/help.c +++ b/gba/src/help.c @@ -94,48 +94,48 @@ The window static void load_help_bg(void) { // Load pattern table - LZ77UnCompVram(helpbgtiles_chrTiles, PATRAM4(3, 272)); - LZ77UnCompVram(helpsprites_chrTiles, SPR_VRAM(CHARACTER_VRAM_BASE)); + LZ77UnCompVram(helpbgtiles_chrTiles, tile_mem[3][272].data); + LZ77UnCompVram(helpsprites_chrTiles, tile_mem_obj[0][CHARACTER_VRAM_BASE].data); // Clear VWF canvas - dma_memset16(PATRAM4(3, 0), 0x1111 * FG_BGCOLOR, 32*WINDOW_WIDTH*17); + memset16(tile_mem[3][0].data, 0x1111 * FG_BGCOLOR, 16*WINDOW_WIDTH*17); // Load background SCREENMAT - dma_memset16(MAP[BGMAP][0], TILE_BACK_WALL, 64*(BACK_WALL_HT - 1)); - dma_memset16(MAP[BGMAP][BACK_WALL_HT - 1], TILE_BACK_WALL_BOTTOM, 30*2); - dma_memset16(MAP[BGMAP][BACK_WALL_HT], TILE_FLOOR_TOP, 30*2); - dma_memset16(MAP[BGMAP][BACK_WALL_HT + 1], TILE_FLOOR, 64*(19 - BACK_WALL_HT)); + memset16(se_mat[BGMAP][0], TILE_BACK_WALL, 32*(BACK_WALL_HT - 1)); + memset16(se_mat[BGMAP][BACK_WALL_HT - 1], TILE_BACK_WALL_BOTTOM, 30); + memset16(se_mat[BGMAP][BACK_WALL_HT], TILE_FLOOR_TOP, 30); + memset16(se_mat[BGMAP][BACK_WALL_HT + 1], TILE_FLOOR, 32*(19 - BACK_WALL_HT)); for (unsigned int x = 0; x < 4; ++x) { // ccccvhtt tttttttt - MAP[BGMAP][SHADOW_Y][SHADOW_X + x] = TILE_FLOOR_SHADOW + x; - MAP[BGMAP][SHADOW_Y][SHADOW_X + 4 + x] = TILE_FLOOR_SHADOW + 0x0403 - x; - MAP[BGMAP][SHADOW_Y + 1][SHADOW_X + x] = TILE_FLOOR_SHADOW + 0x0800 + x; - MAP[BGMAP][SHADOW_Y + 1][SHADOW_X + 4 + x] = TILE_FLOOR_SHADOW + 0x0C03 - x; + se_mat[BGMAP][SHADOW_Y][SHADOW_X + x] = TILE_FLOOR_SHADOW + x; + se_mat[BGMAP][SHADOW_Y][SHADOW_X + 4 + x] = TILE_FLOOR_SHADOW + 0x0403 - x; + se_mat[BGMAP][SHADOW_Y + 1][SHADOW_X + x] = TILE_FLOOR_SHADOW + 0x0800 + x; + se_mat[BGMAP][SHADOW_Y + 1][SHADOW_X + 4 + x] = TILE_FLOOR_SHADOW + 0x0C03 - x; } // Clear window SCREENMAT - dma_memset16(MAP[FGMAP], TILE_FG_BLANK, 32*21*2); - dma_memset16(MAP[FGMAP + 1], TILE_FG_XPARENT, 32*21*2); + memset16(se_mat[FGMAP], TILE_FG_BLANK, 32*21); + memset16(se_mat[FGMAP + 1], TILE_FG_XPARENT, 32*21); // Left border - MAP[FGMAP][0][0] = TILE_FG_CORNER1; - MAP[FGMAP][1][0] = TILE_FG_CORNER2; + se_mat[FGMAP][0][0] = TILE_FG_CORNER1; + se_mat[FGMAP][1][0] = TILE_FG_CORNER2; for (unsigned int i = 2; i < 19; ++i) { - MAP[FGMAP][i][0] = TILE_FG_LEFT; + se_mat[FGMAP][i][0] = TILE_FG_LEFT; } - MAP[FGMAP][19][0] = TILE_FG_CORNER2 + 0x0800; - MAP[FGMAP][20][0] = TILE_FG_CORNER1 + 0x0800; + se_mat[FGMAP][19][0] = TILE_FG_CORNER2 + 0x0800; + se_mat[FGMAP][20][0] = TILE_FG_CORNER1 + 0x0800; // Divider lines - dma_memset16(&(MAP[FGMAP][2][1]), TILE_FG_DIVIDER, 16*2); - dma_memset16(&(MAP[FGMAP][18][1]), TILE_FG_DIVIDER, 16*2); + memset16(&(se_mat[FGMAP][2][1]), TILE_FG_DIVIDER, 16); + memset16(&(se_mat[FGMAP][18][1]), TILE_FG_DIVIDER, 16); // Make the frame - loadMapRowMajor(&(MAP[FGMAP][1][1]), 0*WINDOW_WIDTH, + loadMapRowMajor(&(se_mat[FGMAP][1][1]), 0*WINDOW_WIDTH, WINDOW_WIDTH, 1); - loadMapRowMajor(&(MAP[FGMAP][3][1]), 1*WINDOW_WIDTH, + loadMapRowMajor(&(se_mat[FGMAP][3][1]), 1*WINDOW_WIDTH, WINDOW_WIDTH, PAGE_MAX_LINES); - loadMapRowMajor(&(MAP[FGMAP][4+PAGE_MAX_LINES][1]), (PAGE_MAX_LINES + 1)*WINDOW_WIDTH, + loadMapRowMajor(&(se_mat[FGMAP][4+PAGE_MAX_LINES][1]), (PAGE_MAX_LINES + 1)*WINDOW_WIDTH, WINDOW_WIDTH, 1); help_bg_loaded = 1; @@ -186,8 +186,8 @@ static void help_draw_cursor(unsigned int objx) { static void help_draw_page(helpdoc_kind doc_num, unsigned int left, unsigned int keymask) { // Draw document title - dma_memset16(PATRAM4(3, 0), FG_BGCOLOR*0x1111, WINDOW_WIDTH * 32); - vwf8Puts(PATRAM4(3, 0), helptitles[doc_num], 0, FG_FGCOLOR); + memset16(tile_mem[3][0].data, FG_BGCOLOR*0x1111, WINDOW_WIDTH * 16); + vwf8Puts(tile_mem[3][0].data, helptitles[doc_num], 0, FG_FGCOLOR); // Look up the address of the start of this page's text help_cur_page = help_wanted_page; @@ -196,9 +196,9 @@ static void help_draw_page(helpdoc_kind doc_num, unsigned int left, unsigned int // Draw lines of text to the screen while (y < PAGE_MAX_LINES) { - u32 *dst = PATRAM4(3, (y + 1)*WINDOW_WIDTH); + u32 *dst = tile_mem[3][(y + 1)*WINDOW_WIDTH].data; ++y; - dma_memset16(dst, FG_BGCOLOR*0x1111, WINDOW_WIDTH * 32); + memset16(dst, FG_BGCOLOR*0x1111, WINDOW_WIDTH * 16); src = vwf8Puts(dst, src, left, FG_FGCOLOR); // Break on NUL terminator or skip others @@ -208,8 +208,8 @@ static void help_draw_page(helpdoc_kind doc_num, unsigned int left, unsigned int // Clear unused lines that had been used for (unsigned int clear_y = y; clear_y < help_height; ++clear_y) { - u32 *dst = PATRAM4(3, (clear_y + 1)*WINDOW_WIDTH); - dma_memset16(dst, FG_BGCOLOR*0x1111, WINDOW_WIDTH * 32); + u32 *dst = tile_mem[3][(clear_y + 1)*WINDOW_WIDTH].data; + memset16(dst, FG_BGCOLOR*0x1111, WINDOW_WIDTH * 16); } // Save how many lines are used and move the cursor up if needed @@ -220,22 +220,22 @@ static void help_draw_page(helpdoc_kind doc_num, unsigned int left, unsigned int // Draw status line depending on size of document and which // keys are enabled - u32 *dst = PATRAM4(3, (PAGE_MAX_LINES + 1)*WINDOW_WIDTH); - dma_memset16(dst, FG_BGCOLOR*0x1111, WINDOW_WIDTH * 32); + u32 *dst = tile_mem[3][(PAGE_MAX_LINES + 1)*WINDOW_WIDTH].data; + memset16(dst, FG_BGCOLOR*0x1111, WINDOW_WIDTH * 16); if (help_cumul_pages[doc_num + 1] - help_cumul_pages[doc_num] > 1) { posprintf(help_line_buffer, "\x1D %d/%d \x1C", help_wanted_page - help_cumul_pages[doc_num] + 1, help_cumul_pages[doc_num + 1] - help_cumul_pages[doc_num]); - vwf8Puts(PATRAM4(3, (PAGE_MAX_LINES + 1)*WINDOW_WIDTH), + vwf8Puts(tile_mem[3][(PAGE_MAX_LINES + 1)*WINDOW_WIDTH].data, help_line_buffer, 0, FG_FGCOLOR); } if (keymask & KEY_UP) { - vwf8Puts(PATRAM4(3, (PAGE_MAX_LINES + 1)*WINDOW_WIDTH), + vwf8Puts(tile_mem[3][(PAGE_MAX_LINES + 1)*WINDOW_WIDTH].data, "\x1E\x1F""A: Select", 40, FG_FGCOLOR); } if (keymask & KEY_B) { - vwf8Puts(PATRAM4(3, (PAGE_MAX_LINES + 1)*WINDOW_WIDTH), + vwf8Puts(tile_mem[3][(PAGE_MAX_LINES + 1)*WINDOW_WIDTH].data, "B: Exit", WINDOW_WIDTH * 8 - 28, FG_FGCOLOR); } } diff --git a/gba/src/placeholder.c b/gba/src/placeholder.c index 20de40e..0611d34 100644 --- a/gba/src/placeholder.c +++ b/gba/src/placeholder.c @@ -22,10 +22,7 @@ it freely, subject to the following restrictions: "Source" is the preferred form of a work for making changes to it. */ -#include -#include #include "global.h" - #include "bggfx_chr.h" #include "spritegfx_chr.h" @@ -43,7 +40,7 @@ unsigned short player_facing = 0; #define OBJ_VRAM_BASE 16 static void load_player(void) { - LZ77UnCompVram(spritegfx_chrTiles, SPR_VRAM(16)); + LZ77UnCompVram(spritegfx_chrTiles, &(tile_mem_obj[0][16].data)); player_x = 56 << 8; player_dx = player_frame = player_facing = 0; } @@ -131,41 +128,39 @@ static const unsigned short bgcolors10[16] = { }; static void put1block(unsigned int x, unsigned int y) { - MAP[PFMAP][y][x] = 12 | 0x0000; - MAP[PFMAP][y][x+1] = 13 | 0x0000; - MAP[PFMAP][y+1][x] = 14 | 0x0000; - MAP[PFMAP][y+1][x+1] = 15 | 0x0000; + se_mat[PFMAP][y][x] = 12 | 0x0000; + se_mat[PFMAP][y][x+1] = 13 | 0x0000; + se_mat[PFMAP][y+1][x] = 14 | 0x0000; + se_mat[PFMAP][y+1][x+1] = 15 | 0x0000; } void load_common_bg_tiles(void) { - bitunpack2(PATRAM4(0, 0), bggfx_chrTiles, sizeof(bggfx_chrTiles)); + bitunpack2(&(tile_mem[0][0].data), bggfx_chrTiles, sizeof(bggfx_chrTiles)); } void load_common_obj_tiles(void) { - bitunpack2(SPR_VRAM(0), bggfx_chrTiles, sizeof(bggfx_chrTiles)); + bitunpack2(&(tile_mem_obj[0][0].data), bggfx_chrTiles, sizeof(bggfx_chrTiles)); } static void draw_bg(void) { load_common_bg_tiles(); // Draw background map: sky, top row of floor, bottom row of floor - dma_memset16(MAP[PFMAP][0], 0x0004, 2*32*18); - dma_memset16(MAP[PFMAP][18], 11 | 0x1000, 2*30); - dma_memset16(MAP[PFMAP][19], 1 | 0x1000, 2*30); + memset16(se_mat[PFMAP][0], 0x0004, 32*18); + memset16(se_mat[PFMAP][18], 11 | 0x1000, 30); + memset16(se_mat[PFMAP][19], 1 | 0x1000, 30); put1block(2, 14); put1block(2, 16); put1block(26, 14); put1block(26, 16); - // sorry I was gone const char return_msg[] = - "\x08""\x08""In May 2018,\n" - "\x22""\x10""Pino returned to the GBA scene."; - + "\x08""\x08""In March 2024,\n" + "\x22""\x10""Pino switched to Wonderful Toolchain."; vwfDrawLabels(return_msg, PFMAP, 0x1000 + 32); } -void lame_boy_demo() { +void lame_boy_demo(void) { // Forced blanking REG_DISPCNT = DCNT_BLANK; draw_bg(); diff --git a/gba/src/vwflabels.c b/gba/src/vwflabels.c index ab71d07..55228e9 100644 --- a/gba/src/vwflabels.c +++ b/gba/src/vwflabels.c @@ -49,12 +49,12 @@ void vwfDrawLabels(const char *labelset, unsigned int sbb, unsigned int tilenum) txtw = (((txtw - 1) | 0x07) + 1) >> 3; // Round up to whole tile // Clear this many tiles to color 0 and draw into them using color 1 - void *chrdst = PATRAM4(0, tilenum & 0x07FF); - dma_memset16(chrdst, 0x0000, 32 * txtw); + void *chrdst = &(tile_mem[0][tilenum & 0x07FF].data); + memset16(chrdst, 0x0000, 16 * txtw); const char *strend = vwf8Puts(chrdst, labelset + 2, x & 0x07, 1); // Fill the SCREENMAT - loadMapRowMajor(&(MAP[sbb][y >> 3][x >> 3]), tilenum & 0xF3FF, txtw, 1); + loadMapRowMajor(&(se_mat[sbb][y >> 3][x >> 3]), tilenum & 0xF3FF, txtw, 1); tilenum += txtw; if (*strend == 0) break; diff --git a/gba/tonc_migration.txt b/gba/tonc_migration.txt deleted file mode 100644 index 62fce0e..0000000 --- a/gba/tonc_migration.txt +++ /dev/null @@ -1,3 +0,0 @@ -libgba to libtonc migration -https://github.com/devkitPro/libtonc/blob/master/include/tonc_libgba.h -https://github.com/devkitPro/libtonc/blob/master/include/tonc_legacy.h diff --git a/gba/tools/paginate_help.py b/gba/tools/paginate_help.py index 5ed5fb5..40edca0 100755 --- a/gba/tools/paginate_help.py +++ b/gba/tools/paginate_help.py @@ -66,6 +66,9 @@ def render_help(docs, defines=None): lines.append('helptitles:') lines.extend(' .word helptitle_%s' % doc[1] for doc in docs) + # ensure files end with newline + lines.extend("") + lines_header.extend("") return ["\n".join(lines), "\n".join(lines_header)] def parse_define(s): diff --git a/gba/tools/vwfbuild.py b/gba/tools/vwfbuild.py index 55d2c60..979330b 100644 --- a/gba/tools/vwfbuild.py +++ b/gba/tools/vwfbuild.py @@ -64,7 +64,8 @@ def main(argv=None): "#define VWFCHR_H__", "extern const unsigned char vwfChrData[" + str(int(len(tiledata) / 8)) + "][8];\n" "extern const unsigned char vwfChrWidths[" + str(len(widths)) + "];\n" - "#endif"] + "#endif", + ''] with open(argv[3], 'w') as outfp: outfp.write('\n'.join(out)) diff --git a/gba/wfMakefile b/gba/wfMakefile new file mode 100644 index 0000000..ac08dc4 --- /dev/null +++ b/gba/wfMakefile @@ -0,0 +1,210 @@ +# SPDX-License-Identifier: CC0-1.0 +# +# SPDX-FileContributor: Adrian "asie" Siekierka, 2023 +# SPDX-FileContributor: Damian Yerrick, 2023 + +export WONDERFUL_TOOLCHAIN ?= /opt/wonderful +TARGET = gba/multiboot +include $(WONDERFUL_TOOLCHAIN)/target/$(TARGET)/makedefs.mk + +# Metadata +# -------- + +NAME := 240pwf + +# Source code paths +# ----------------- + +INCLUDEDIRS := include +SOURCEDIRS := src +ASSETDIRS := tilesets +CBINDIRS := + +# Preprocessing tools +# ------------------- + +# If BlocksDS was installed via wf-pacman, use its grit. +# Otherwise use grit installed via dkp-pacman. +GRIT := $(WONDERFUL_TOOLCHAIN)/thirdparty/blocksds/core/tools/grit/grit +ifeq (,$(wildcard $(GRIT))) + export DEVKITPRO ?= /opt/devkitpro + GRIT := $(DEVKITPRO)/tools/bin/grit +endif + +# Under Windows, COMSPEC variable specifies a shell. If set, +# launch Python via the PEP 397 launcher. Otherwise, assume UNIX +# and do not assume python-is-python3 or pythonpy is installed. +ifdef COMSPEC + PY := py -3 +else + PY := python3 +endif + +# Defines passed to all files +# --------------------------- + +DEFINES := + +# Libraries +# --------- + +LIBS := -ltonc -lgba +LIBDIRS := $(WF_EXTLIB_DIR)/libtonc + +# Build artifacts +# --------------- + +BUILDDIR := build +ELF := build/$(NAME).elf +MAP := build/$(NAME).map +ROM := $(NAME).gba + +# Verbose flag +# ------------ + +ifeq ($(V),1) +_V := +else +_V := @ +endif + +# Source files +# ------------ + +ifneq ($(ASSETDIRS),) + SOURCES_WFPROCESS := $(shell find -L $(ASSETDIRS) -name "*.lua") + SOURCES_GRIT := $(shell find -L $(ASSETDIRS) -name "*.grit") + INCLUDEDIRS += $(addprefix $(BUILDDIR)/,$(ASSETDIRS)) +endif +ifneq ($(CBINDIRS),) + SOURCES_CBIN := $(shell find -L $(CBINDIRS) -name "*.bin") + INCLUDEDIRS += $(addprefix $(BUILDDIR)/,$(CBINDIRS)) +endif +SOURCES_S := $(shell find -L $(SOURCEDIRS) -name "*.s") +SOURCES_C := $(shell find -L $(SOURCEDIRS) -name "*.c") +SOURCES_PAGES := $(shell find -L $(SOURCEDIRS) -name "*pages.txt") +INCLUDEDIRS += $(addprefix $(BUILDDIR)/,$(SOURCEDIRS)) + +# Compiler and linker flags +# ------------------------- + +WARNFLAGS := -Wall + +INCLUDEFLAGS := $(foreach path,$(INCLUDEDIRS),-I$(path)) \ + $(foreach path,$(LIBDIRS),-isystem $(path)/include) + +LIBDIRSFLAGS := $(foreach path,$(LIBDIRS),-L$(path)/lib) + +ASFLAGS += -x assembler-with-cpp $(DEFINES) $(WF_ARCH_CFLAGS) \ + $(INCLUDEFLAGS) -ffunction-sections -fdata-sections + +CFLAGS += -std=gnu2x $(WARNFLAGS) $(DEFINES) $(WF_ARCH_CFLAGS) \ + $(INCLUDEFLAGS) -ffunction-sections -fdata-sections -O2 + +LDFLAGS := $(LIBDIRSFLAGS) -Wl,-Map,$(MAP) -Wl,--gc-sections \ + $(WF_ARCH_LDFLAGS) $(LIBS) + +BUILDROMFLAGS := + +# Intermediate build files +# ------------------------ + +OBJS_ASSETS := $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_CBIN))) \ + $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_WFPROCESS))) \ + $(addprefix $(BUILDDIR)/,$(SOURCES_GRIT:.grit=_chr.o)) \ + $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_PAGES))) \ + $(BUILDDIR)/tilesets/vwf7_cp144p.o + +OBJS_SOURCES := $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_S))) \ + $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_C))) + +OBJS := $(OBJS_ASSETS) $(OBJS_SOURCES) + +DEPS := $(OBJS:.o=.d) + +# Targets +# ------- + +.PHONY: all clean + +all: $(ROM) compile_commands.json + +$(ROM) $(ELF): $(OBJS) + @echo " ROM $@" + $(_V)$(ROMLINK) -o $(ROM) --output-elf $(ELF) $(ROMLINKFLAGS) -- $(OBJS) $(LDFLAGS) + +clean: + @echo " CLEAN" + $(_V)$(RM) $(ELF) $(ROM) $(BUILDDIR) compile_commands.json + +compile_commands.json: $(OBJS) | Makefile + @echo " MERGE compile_commands.json" + $(_V)$(WF)/bin/wf-compile-commands-merge $@ $(patsubst %.o,%.cc.json,$^) + +# Rules +# ----- + +$(BUILDDIR)/%.s.o : %.s | $(OBJS_ASSETS) + @echo " AS $<" + @$(MKDIR) -p $(@D) + $(_V)$(CC) $(ASFLAGS) -MMD -MP -MJ $(patsubst %.o,%.cc.json,$@) -c -o $@ $< + +$(BUILDDIR)/%.c.o : %.c | $(OBJS_ASSETS) + @echo " CC $<" + @$(MKDIR) -p $(@D) + $(_V)$(CC) $(CFLAGS) -MMD -MP -MJ $(patsubst %.o,%.cc.json,$@) -c -o $@ $< + +$(BUILDDIR)/%.bin.o $(BUILDDIR)/%_bin.h : %.bin + @echo " BIN2C $<" + @$(MKDIR) -p $(@D) + $(_V)$(WF)/bin/wf-bin2c -a 4 $(@D) $< + $(_V)$(CC) $(CFLAGS) -MMD -MP -c -o $(BUILDDIR)/$*.bin.o $(BUILDDIR)/$*_bin.c + +$(BUILDDIR)/%.lua.o : %.lua + @echo " PROCESS $<" + @$(MKDIR) -p $(@D) + $(_V)$(WF)/bin/wf-process -o $(BUILDDIR)/$*.c -t $(TARGET) --depfile $(BUILDDIR)/$*.lua.d --depfile-target $(BUILDDIR)/$*.lua.o $< + $(_V)$(CC) $(CFLAGS) -c -o $(BUILDDIR)/$*.lua.o $(BUILDDIR)/$*.c + +# local gritfile, local image +$(BUILDDIR)/%_chr.o $(BUILDDIR)/%_chr.h : %.png %.grit + @echo " GRIT $<" + @$(MKDIR) -p $(@D) + $(_V)$(GRIT) $< -ff$(word 2,$^) -fts -o$(BUILDDIR)/$*_chr + $(_V)$(CC) $(CFLAGS) -c -o $(BUILDDIR)/$*_chr.o $(BUILDDIR)/$*_chr.s + +# local gritfile, common image +$(BUILDDIR)/%_chr.o $(BUILDDIR)/%_chr.h : ../common/%.png %.grit + @echo " GRIT $<" + @$(MKDIR) -p $(@D) + $(_V)$(GRIT) $< -ff$(word 2,$^) -fts -o$(BUILDDIR)/$*_chr + $(_V)$(CC) $(CFLAGS) -c -o $(BUILDDIR)/$*_chr.o $(BUILDDIR)/$*_chr.s + +$(BUILDDIR)/%pages.txt.o $(BUILDDIR)/%pages.h : %pages.txt $(BUILDDIR)/last-commit tools/paginate_help.py + @echo " PAGES $<" + @$(MKDIR) -p $(@D) + $(_V)$(PY) tools/paginate_help.py -DCOMMIT="$$(cat $(word 2,$^))" $< -o $(BUILDDIR)/$*pages.txt.s -oh $(BUILDDIR)/$*pages.h + $(_V)$(CC) $(CFLAGS) -c -o $(BUILDDIR)/$*pages.txt.o $(BUILDDIR)/$*pages.txt.s + +# One-off rules +# ------------- + +# The targets ending with `&:` are grouped targets, a feature +# introduced in GNU Make 4.3. This blocks running the rule multiple +# times in separate processes, once for each output file. +# If using old Make, change `&:` to `:` and use `make -j1`. + +$(BUILDDIR)/last-commit: + echo -n "non-Git" >> $@ + +# Convert a proportional font +$(BUILDDIR)/tilesets/vwf7_cp144p.o $(BUILDDIR)/tilesets/vwf7.h &: ../common/tilesets/vwf7_cp144p.png tools/vwfbuild.py + @echo " FONT $<" + @$(MKDIR) -p $(@D) + $(_V)$(PY) tools/vwfbuild.py $< $(BUILDDIR)/tilesets/vwf7_cp144p.s $(BUILDDIR)/tilesets/vwf7.h + $(_V)$(CC) $(CFLAGS) -c -o $(BUILDDIR)/tilesets/vwf7_cp144p.o $(BUILDDIR)/tilesets/vwf7_cp144p.s + +# Include dependency files if they exist +# -------------------------------------- + +-include $(DEPS) diff --git a/gba/wfconfig.toml b/gba/wfconfig.toml new file mode 100644 index 0000000..b9c6c34 --- /dev/null +++ b/gba/wfconfig.toml @@ -0,0 +1,5 @@ +[cartridge] +logo = "official" +title = "160P TEST" +code = "H24A" +maker = "P8"