From 0b13c0edef088b17364711a5a329434ee7e8b061 Mon Sep 17 00:00:00 2001 From: Lywx Date: Sat, 17 Feb 2024 20:19:18 -0600 Subject: [PATCH] Asset extraction (#133) * Added torch and ast_logo yml * Added torch into makefile * Added torch into tools all rule * Fixed version and removed clang-format from c header * Reverted settings.json unrelated change * Bump version * Readded -s flag * Fixed Makefile indentation --- .gitignore | 2 ++ .gitmodules | 3 +++ Makefile | 10 ++++++++-- assets/yaml/us/ast_logo.yml | 14 ++++++++++++++ config.yml | 11 +++++++++++ include/assets/ast_logo.h | 6 +----- src/main/fox_game.c | 11 ++++++----- tools/Makefile | 11 +++++++++-- tools/Torch | 1 + yamls/us/assets.yaml | 14 +++++--------- 10 files changed, 60 insertions(+), 23 deletions(-) create mode 100644 assets/yaml/us/ast_logo.yml create mode 100644 config.yml create mode 160000 tools/Torch diff --git a/.gitignore b/.gitignore index 38c99622..0363660f 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,8 @@ ctx.c.m2c *.n64 *.z64 *.bin +src/assets/* +!src/assets/ast_radio.c /build tools/mio0 tools/ido-recomp diff --git a/.gitmodules b/.gitmodules index dfc22b60..6e602ae8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,3 +10,6 @@ [submodule "tools/m2c"] path = tools/m2c url = https://github.com/matt-kempster/m2c +[submodule "tools/Torch"] + path = tools/Torch + url = https://github.com/HarbourMasters/Torch diff --git a/Makefile b/Makefile index cba3cd9a..07626b4f 100644 --- a/Makefile +++ b/Makefile @@ -137,6 +137,7 @@ OBJDUMP := $(MIPS_BINUTILS_PREFIX)objdump ICONV := iconv ASM_PROC := $(PYTHON) $(TOOLS)/asm-processor/build.py CAT := cat +TORCH := tools/Torch/cmake-build-release/torch # Prefer clang as C preprocessor if installed on the system ifneq (,$(call find-command,clang)) @@ -231,6 +232,7 @@ ASM_DIRS := $(shell find asm/$(VERSION) -type d -not -path "asm/$(VERSION)/ BIN_DIRS := $(shell find bin -type d) C_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.c)) +C_FILES := $(filter-out %.inc.c,$(C_FILES)) S_FILES := $(foreach dir,$(ASM_DIRS) $(SRC_DIRS),$(wildcard $(dir)/*.s)) BIN_FILES := $(foreach dir,$(BIN_DIRS),$(wildcard $(dir)/*.bin)) O_FILES := $(foreach f,$(C_FILES:.c=.o),$(BUILD_DIR)/$f) \ @@ -390,6 +392,7 @@ init: @$(MAKE) clean @$(MAKE) decompress @$(MAKE) extract -j $(N_THREADS) + @$(MAKE) assets -j $(N_THREADS) @$(MAKE) uncompressed -j $(N_THREADS) @$(MAKE) compressed @@ -428,9 +431,12 @@ extract: @echo "Extracting..." @$(SPLAT) $(SPLAT_YAML) +assets: + @echo "Extracting assets..." + @$(TORCH) code $(BASEROM_UNCOMPRESSED) + clean: @git clean -fdx asm/ - @git clean -fdx assets/ @git clean -fdx bin/ @git clean -fdx build/ @git clean -fdx linker_scripts/*.ld @@ -516,4 +522,4 @@ build/src/libultra/libc/ll.o: src/libultra/libc/ll.c # Print target for debugging print-% : ; $(info $* is a $(flavor $*) variable set to [$($*)]) @true -.PHONY: all uncompressed compressed clean init extract expected format checkformat decompress context disasm toolchain +.PHONY: all uncompressed compressed clean init extract expected format checkformat decompress assets context disasm toolchain diff --git a/assets/yaml/us/ast_logo.yml b/assets/yaml/us/ast_logo.yml new file mode 100644 index 00000000..7d618310 --- /dev/null +++ b/assets/yaml/us/ast_logo.yml @@ -0,0 +1,14 @@ +:config: + segments: + seg15: 0xD25100 + header: + - '#include "assets/ast_logo.h"' + +nintendo_logo: + type: TEXTURE + offset: 0xF000000 + format: IA8 + width: 128 + height: 74 + ctype: u8 + symbol: gNintendoLogo \ No newline at end of file diff --git a/config.yml b/config.yml new file mode 100644 index 00000000..bc5df76d --- /dev/null +++ b/config.yml @@ -0,0 +1,11 @@ +# Supported Star Fox 64 Versions: US + +f7475fb11e7e6830f82883412638e8390791ab87: + name: Star Fox 64 (U) (V1.1) + path: assets/yaml/us + config: + gbi: F3DEX + sort: OFFSET + output: + binary: lylat.otr + code: src/assets \ No newline at end of file diff --git a/include/assets/ast_logo.h b/include/assets/ast_logo.h index 99df299c..e6588db4 100644 --- a/include/assets/ast_logo.h +++ b/include/assets/ast_logo.h @@ -5,10 +5,6 @@ #include "sf64object.h" #include "structs.h" -extern u16 D_F000000[]; -extern u16 D_F000800[]; -extern u16 D_F001000[]; -extern u16 D_F001800[]; -extern u16 D_F002000[]; +extern u8 gNintendoLogo[]; #endif diff --git a/src/main/fox_game.c b/src/main/fox_game.c index 676f879c..870c602e 100644 --- a/src/main/fox_game.c +++ b/src/main/fox_game.c @@ -1,6 +1,7 @@ #include "prevent_bss_reordering.h" #include "global.h" #include "sf64dma.h" +#include "assets/ast_logo.h" f32 D_80161A10; f32 D_80161A14; @@ -345,11 +346,11 @@ void Game_Update(void) { case GSTATE_SHOW_LOGO: RCP_SetupDL(&gMasterDisp, 0x4C); gDPSetPrimColor(gMasterDisp++, 0x00, 0x00, 255, 255, 255, 255); - TextureRect_8bIA(&gMasterDisp, D_F000000, 128, 16, 100.0f, 86.0f, 1.0f, 1.0f); - TextureRect_8bIA(&gMasterDisp, D_F000800, 128, 16, 100.0f, 102.0f, 1.0f, 1.0f); - TextureRect_8bIA(&gMasterDisp, D_F001000, 128, 16, 100.0f, 118.0f, 1.0f, 1.0f); - TextureRect_8bIA(&gMasterDisp, D_F001800, 128, 16, 100.0f, 134.0f, 1.0f, 1.0f); - TextureRect_8bIA(&gMasterDisp, D_F002000, 128, 10, 100.0f, 150.0f, 1.0f, 1.0f); + TextureRect_8bIA(&gMasterDisp, &gNintendoLogo[128 * 16 * 0], 128, 16, 100.0f, 86.0f, 1.0f, 1.0f); + TextureRect_8bIA(&gMasterDisp, &gNintendoLogo[128 * 16 * 1], 128, 16, 100.0f, 102.0f, 1.0f, 1.0f); + TextureRect_8bIA(&gMasterDisp, &gNintendoLogo[128 * 16 * 2], 128, 16, 100.0f, 118.0f, 1.0f, 1.0f); + TextureRect_8bIA(&gMasterDisp, &gNintendoLogo[128 * 16 * 3], 128, 16, 100.0f, 134.0f, 1.0f, 1.0f); + TextureRect_8bIA(&gMasterDisp, &gNintendoLogo[128 * 16 * 4], 128, 10, 100.0f, 150.0f, 1.0f, 1.0f); gGameState++; break; case GSTATE_CHECK_SAVE: diff --git a/tools/Makefile b/tools/Makefile index 9feee76a..487d3263 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -1,4 +1,6 @@ CC = gcc +MAKE = make +N_THREADS ?= $(shell nproc) UNAME_S := $(shell uname -s) ifeq ($(OS),Windows_NT) @@ -15,11 +17,12 @@ RECOMP_DIR := ido-recomp/$(DETECTED_OS) default: all -all: recomp mio0 +all: recomp mio0 torch clean: $(RM) -rf $(RECOMP_DIR) $(RM) mio0 + $(RM) -rf Torch/build distclean: clean @@ -34,4 +37,8 @@ mio0: @echo "Building mio0..." $(CC) -Wall -Wextra -Wno-format-overflow -O2 -ffunction-sections -fdata-sections -DMIO0_STANDALONE -s -Wl,${MIO0_FLAGS} -o mio0 mio0-decompressor/libmio0.c -.PHONY: all clean distclean default +torch: + @echo "Building torch..." + $(MAKE) -C Torch type=release -j$(N_THREADS) + +.PHONY: all clean distclean default torch diff --git a/tools/Torch b/tools/Torch new file mode 160000 index 00000000..5b1e5d63 --- /dev/null +++ b/tools/Torch @@ -0,0 +1 @@ +Subproject commit 5b1e5d632b44cd13282ce98d8dd3c11a5c86d598 diff --git a/yamls/us/assets.yaml b/yamls/us/assets.yaml index ec403fde..f62c9c90 100644 --- a/yamls/us/assets.yaml +++ b/yamls/us/assets.yaml @@ -179,16 +179,12 @@ start: 0xCE9E70 - name: ast_logo #F - type: bin + type: code + dir: assets start: 0xD25100 - # width: 128 - # height: 74 - # subsegments: - # - [0xD25100, ia8, nintendo_logo_0, 128, 16] - # - [0xD25900, ia8, nintendo_logo_1, 128, 16] - # - [0xD26100, ia8, nintendo_logo_2, 128, 16] - # - [0xD26900, ia8, nintendo_logo_3, 128, 16] - # - [0xD27100, ia8, nintendo_logo_4, 128, 10] + vram: 0x0F000000 + subsegments: + - [0xD25100, .data, ast_logo/bin] - name: ast_ending #7 type: bin