diff --git a/Makefile b/Makefile index 8c6bed6d..bc39450e 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ OUTPUT_DIR = output include $(N64_INST)/include/n64.mk -N64_CFLAGS += -iquote $(SOURCE_DIR) -I $(SOURCE_DIR)/libs -flto=auto $(FLAGS) +N64_CFLAGS += -iquote $(SOURCE_DIR) -iquote $(ASSETS_DIR) -I $(SOURCE_DIR)/libs -flto=auto $(FLAGS) SRCS = \ main.c \ @@ -56,7 +56,7 @@ SRCS = \ utils/fs.c ASSETS = \ - FiraMono-Bold.ttf + FiraMonoBold.ttf OBJS = $(addprefix $(BUILD_DIR)/, $(addsuffix .o,$(basename $(SRCS) $(ASSETS)))) MINIZ_OBJS = $(filter $(BUILD_DIR)/libs/miniz/%.o,$(OBJS)) @@ -65,13 +65,16 @@ DEPS = $(OBJS:.o=.d) $(MINIZ_OBJS): N64_CFLAGS+=-DMINIZ_NO_TIME -fcompare-debug-second $(SPNG_OBJS): N64_CFLAGS+=-isystem $(SOURCE_DIR)/libs/miniz -DSPNG_USE_MINIZ -fcompare-debug-second -$(BUILD_DIR)/FiraMono-Bold.o: MKFONT_FLAGS+=-c 0 --size 16 -r 20-7F -r 2026-2026 --ellipsis 2026,1 +$(BUILD_DIR)/FiraMonoBold.asset: MKFONT_FLAGS+=-c 0 --size 16 -r 20-7F -r 2026-2026 --ellipsis 2026,1 -$(BUILD_DIR)/%.o: $(ASSETS_DIR)/%.ttf - @echo " [FONT] $@" - @$(N64_MKFONT) $(MKFONT_FLAGS) -o $(ASSETS_DIR) "$<" - @$(N64_OBJCOPY) -I binary -O elf32-bigmips -B mips4300 $(basename $<).font64 $@ - @rm $(basename $<).font64 +$(BUILD_DIR)/%.asset: $(ASSETS_DIR)/%.ttf + @echo " [FONT] $(basename $@).font64" + @$(N64_MKFONT) $(MKFONT_FLAGS) -o $(BUILD_DIR) "$<" + @$(shell mv $(basename $@).font64 $@) + +$(BUILD_DIR)/%.o: $(BUILD_DIR)/%.asset $(ASSETS_DIR)/assets.S + @sed -e "s,@sym@,$*,g" -e "s,@file@,$(basename $<).asset," < $(ASSETS_DIR)/assets.S | \ + $(CC) -x assembler-with-cpp $(ASFLAGS) -c - -o $@ $(BUILD_DIR)/$(PROJECT_NAME).elf: $(OBJS) diff --git a/assets/FiraMono-Bold.ttf b/assets/FiraMonoBold.ttf similarity index 100% rename from assets/FiraMono-Bold.ttf rename to assets/FiraMonoBold.ttf diff --git a/assets/assets.S b/assets/assets.S new file mode 100644 index 00000000..a1c1eef7 --- /dev/null +++ b/assets/assets.S @@ -0,0 +1,11 @@ +.section .data.@sym@, "a", %progbits +.type assets_@sym@, %object + +.balign 16 + +.global assets_@sym@ +assets_@sym@: + .incbin "@file@" + +.global assets_@sym@_size + .set assets_@sym@_size, . - assets_@sym@ diff --git a/assets/assets.h b/assets/assets.h new file mode 100644 index 00000000..efc35a82 --- /dev/null +++ b/assets/assets.h @@ -0,0 +1,16 @@ +#ifndef ASSETS_H__ +#define ASSETS_H__ + + +#include + + +#define ASSET(n) \ + extern uint8_t assets_##n[] __attribute__((section(".data"))); \ + extern int assets_##n##_size[] __attribute__((section(".data"))) + + +ASSET(FiraMonoBold); + + +#endif diff --git a/src/menu/fonts.c b/src/menu/fonts.c index fc743441..b51972bd 100644 --- a/src/menu/fonts.c +++ b/src/menu/fonts.c @@ -1,19 +1,11 @@ #include +#include "assets.h" #include "fonts.h" -#define FONT_IMPORT(f) \ - extern void *_binary_assets_##f##_start __attribute__((section(".data"))); \ - extern int _binary_assets_##f##_size __attribute__((section(".data"))); -#define FONT_LOAD(f) rdpq_font_load_buf((void *) (&_binary_assets_##f##_start), (size_t) (&_binary_assets_##f##_size)) - - -FONT_IMPORT(FiraMono_Bold_font64); - - static void load_default_font (void) { - rdpq_font_t *default_font = FONT_LOAD(FiraMono_Bold_font64); + rdpq_font_t *default_font = rdpq_font_load_buf(assets_FiraMonoBold, (int) (assets_FiraMonoBold_size)); rdpq_font_style(default_font, STL_DEFAULT, &((rdpq_fontstyle_t) { .color = RGBA32(0xFF, 0xFF, 0xFF, 0xFF) })); rdpq_font_style(default_font, STL_DIRECTORY, &((rdpq_fontstyle_t) { .color = RGBA32(0xFF, 0xFF, 0x70, 0xFF) })); diff --git a/src/menu/views/browser.c b/src/menu/views/browser.c index 37375400..c29917fa 100644 --- a/src/menu/views/browser.c +++ b/src/menu/views/browser.c @@ -9,7 +9,7 @@ #include "views.h" -static const char *rom_extensions[] = { "z64", "n64", "v64", NULL }; +static const char *rom_extensions[] = { "z64", "n64", "v64", "rom", NULL }; static const char *emulator_extensions[] = { "nes", "gb", "gbc", "smc", "gen", "smd", NULL }; static const char *save_extensions[] = { "sav", NULL }; // TODO: "eep", "sra", "srm", "fla" could be used if transfered from different flashcarts. static const char *image_extensions[] = { "png", NULL }; diff --git a/src/menu/views/file_info.c b/src/menu/views/file_info.c index ec73119a..83506caa 100644 --- a/src/menu/views/file_info.c +++ b/src/menu/views/file_info.c @@ -4,7 +4,7 @@ #include "views.h" -static const char *n64_rom_extensions[] = { "z64", "n64", "v64", NULL }; +static const char *n64_rom_extensions[] = { "z64", "n64", "v64", "rom", NULL }; static const char *text_extensions[] = { "txt", NULL }; static const char *config_extensions[] = { "ini", "cfg", "yml", "yaml", "toml", NULL }; static const char *save_extensions[] = { "sav", "eep", "eeprom", "sra", "srm", "ram", "fla", "flashram", NULL };