mirror of
https://github.com/izzy2lost/Diddy-Kong-Racing.git
synced 2026-06-19 01:16:26 -07:00
DKR Assets Tool v0.5 (#577)
* Saving files before attempting to integrate custom crash screen * Put code under DkrAssetsTool namespace * More progress * Lots of work done. * Forgot to revert back to v77 in the makefile * Included cstdint in bytes_view.hpp * Hopefully fixed issue with CEnum::tostring(), removed asset_enums from tracking, and modified gitignore to allow obj files from the mods folder * .mtl file and the textures should now check if the path is absolute or relative. * Fixed compile_all.sh * Doing a thing that is technically not valid. * Removed 'make assets', now assets are built in the normal 'make' setting.
This commit is contained in:
@@ -24,12 +24,18 @@ bin/
|
||||
bin/*
|
||||
ucode/*
|
||||
|
||||
# Asset enums, since it is auto-generated.
|
||||
include/asset_enums.h
|
||||
|
||||
#compiled object files
|
||||
*.slo
|
||||
*.lo
|
||||
*.o
|
||||
*.obj
|
||||
|
||||
# Do not ignore .obj files in the mods/ directory
|
||||
!mods/**/*.obj
|
||||
|
||||
#Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
@@ -3,6 +3,11 @@ REGION := us
|
||||
VERSION := v77
|
||||
NON_MATCHING ?= 0
|
||||
|
||||
# NM is shorthand for NON_MATCHING
|
||||
ifneq ($(NM),)
|
||||
NON_MATCHING := 1
|
||||
endif
|
||||
|
||||
# Experimental option for nonmatching builds. GCC may not function identically to ido.
|
||||
COMPILER ?= ido
|
||||
$(eval $(call validate-option,NON_MATCHING,ido gcc))
|
||||
@@ -327,6 +332,7 @@ no_verify: $(TARGET).z64
|
||||
|
||||
extract:
|
||||
$(SPLAT) ver/splat/$(BASENAME).$(REGION).$(VERSION).yaml
|
||||
$(TOOLS_DIR)/dkr_assets_tool extract -dkrv $(REGION).$(VERSION) >&2 || echo FAIL
|
||||
#These are the only 4 jpn region functions that match elsewhere, but not for this region. As a temp hack for progress script reasons, just delete these for other regions.
|
||||
ifneq ($(REGION),jpn)
|
||||
@$(RM) asm/nonmatchings/menu/savemenu_render_element.s asm/nonmatchings/menu/pakmenu_render.s asm/nonmatchings/menu/results_render.s asm/nonmatchings/menu/menu_credits_loop.s
|
||||
@@ -395,114 +401,80 @@ expected: verify
|
||||
#Run this to use the asset builder to customize assets
|
||||
assets: all
|
||||
|
||||
# Only compile the assets when running `make assets` or if we're making a NON_MATCHING build
|
||||
ifeq ($(MAKECMDGOALS),assets)
|
||||
|
||||
ASSETS_VERSION := us_1.0
|
||||
ASSETS := assets/$(ASSETS_VERSION)
|
||||
ASSETS_BUILD_DIR := $(BUILD_DIR)/assets
|
||||
BUILDER = $(TOOLS_DIR)/dkr_assets_tool -dkrv $(ASSETS_VERSION) build
|
||||
|
||||
######## Extract Assets & Microcode ########
|
||||
DUMMY != $(PYTHON) $(TOOLS_DIR)/python/check_if_need_to_extract.py $(ASSETS_VERSION) >&2 || echo FAIL
|
||||
|
||||
######## Prebuild step (Compile assets, generate linker file, etc.) ########
|
||||
DUMMY != $(TOOLS_DIR)/dkr_assets_tool -dkrv $(ASSETS_VERSION) prebuild >&2 || echo FAIL
|
||||
|
||||
# Helps fix an issue with parallel jobs.
|
||||
$(ALL_ASSETS_BUILT): | $(BUILD_DIR)
|
||||
|
||||
# This is here to prevent make from deleting all the asset files after the build completes/fails.
|
||||
dont_remove_asset_files: $(ALL_ASSETS_BUILT)
|
||||
|
||||
# Add .json files
|
||||
JSON_FILES := $(shell find $(ASSETS) -type f -name '*.json')
|
||||
|
||||
# Ignore .meta.json files
|
||||
IGNORE_JSON_FILES := $(shell find $(ASSETS) -type f -name '*.meta.json')
|
||||
JSON_FILES := $(filter-out $(IGNORE_JSON_FILES),$(JSON_FILES))
|
||||
|
||||
# $1 = asset path (e.g. assets/levels/models/...), $2 = cmd to run
|
||||
define DEFINE_ASSET_TARGET
|
||||
$(eval BASE_PATH := $(subst $(ASSETS),$(ASSETS_BUILD_DIR),$(basename $1)))
|
||||
$$(BASE_PATH).bin: $1
|
||||
$2
|
||||
$(eval ALL_ASSETS_BUILT+=$(BASE_PATH).bin)
|
||||
endef
|
||||
|
||||
# $1 = Print message
|
||||
define JSON_FILE_ACTION
|
||||
$$(call print,$1:,$$<,$$@)
|
||||
$$(V)$$(BUILDER) -i $$< -o $$@
|
||||
endef
|
||||
|
||||
$(foreach FILE,$(JSON_FILES),$(eval $(call DEFINE_ASSET_TARGET,$(FILE),$(call JSON_FILE_ACTION,Building))))
|
||||
ASSETS_OUTPUT := assets/assets.bin
|
||||
|
||||
ifeq ($(NON_MATCHING),1)
|
||||
# The -m flag will attempt to compile assets. Only want to do this on non-matching builds.
|
||||
MODDED_ARG := -m
|
||||
endif
|
||||
|
||||
build_assets:
|
||||
$(info Building Assets...)
|
||||
$(TOOLS_DIR)/dkr_assets_tool build -o $(ASSETS_OUTPUT) -dkrv $(REGION).$(VERSION) $(MODDED_ARG) >&2 || echo FAIL
|
||||
|
||||
###############################
|
||||
|
||||
$(GLOBAL_ASM_O_FILES): CC := $(ASM_PROCESSOR) $(CC) -- $(AS) $(ASFLAGS) --
|
||||
|
||||
$(TARGET).elf: dirs $(LD_SCRIPT) $(O_FILES) | $(ALL_ASSETS_BUILT)
|
||||
$(TARGET).elf: dirs $(LD_SCRIPT) $(O_FILES) | build_assets
|
||||
@$(PRINT) "$(GREEN)Linking: $(BLUE)$@$(NO_COL)\n"
|
||||
$(V)$(LD) $(LD_FLAGS) -o $@
|
||||
|
||||
ifndef PERMUTER
|
||||
$(GLOBAL_ASM_O_FILES): $(BUILD_DIR)/%.c.o: %.c | $(ALL_ASSETS_BUILT)
|
||||
$(GLOBAL_ASM_O_FILES): $(BUILD_DIR)/%.c.o: %.c | build_assets
|
||||
$(call print,Compiling:,$<,$@)
|
||||
$(V)$(CC_CHECK) -MMD -MP -MT $@ -MF $(BUILD_DIR)/$*.d $<
|
||||
$(V)$(CC) -c $(CFLAGS) $(CC_WARNINGS) $(OPT_FLAGS) $(MIPSISET) -o $@ $<
|
||||
endif
|
||||
|
||||
# non asm-processor recipe
|
||||
$(BUILD_DIR)/%.c.o: %.c | $(ALL_ASSETS_BUILT)
|
||||
$(BUILD_DIR)/%.c.o: %.c | build_assets
|
||||
$(call print,Compiling:,$<,$@)
|
||||
$(V)$(CC_CHECK) -MMD -MP -MT $@ -MF $(BUILD_DIR)/$*.d $<
|
||||
$(V)$(CC) -c $(CFLAGS) $(CC_WARNINGS) $(OPT_FLAGS) $(MIPSISET) -o $@ $<
|
||||
|
||||
$(BUILD_DIR)/$(LIBULTRA_DIR)/src/libc/llcvt.c.o: $(LIBULTRA_DIR)/src/libc/llcvt.c | $(ALL_ASSETS_BUILT)
|
||||
$(BUILD_DIR)/$(LIBULTRA_DIR)/src/libc/llcvt.c.o: $(LIBULTRA_DIR)/src/libc/llcvt.c | build_assets
|
||||
$(call print,Compiling mips3:,$<,$@)
|
||||
@$(CC) -c $(CFLAGS) $(CC_WARNINGS) $(OPT_FLAGS) $(MIPSISET) -o $@ $<
|
||||
$(V)$(PYTHON) $(TOOLS_DIR)/python/patchmips3.py $@ || rm $@
|
||||
|
||||
$(BUILD_DIR)/$(LIBULTRA_DIR)/src/libc/ll.c.o: $(LIBULTRA_DIR)/src/libc/ll.c | $(ALL_ASSETS_BUILT)
|
||||
$(BUILD_DIR)/$(LIBULTRA_DIR)/src/libc/ll.c.o: $(LIBULTRA_DIR)/src/libc/ll.c | build_assets
|
||||
$(call print,Compiling mips3:,$<,$@)
|
||||
@$(CC) -c $(CFLAGS) $(CC_WARNINGS) $(OPT_FLAGS) $(MIPSISET) -o $@ $<
|
||||
$(V)$(PYTHON) $(TOOLS_DIR)/python/patchmips3.py $@ || rm $@
|
||||
|
||||
$(BUILD_DIR)/%.s.o: %.s | $(ALL_ASSETS_BUILT)
|
||||
$(BUILD_DIR)/%.s.o: %.s | build_assets
|
||||
$(call print,Assembling:,$<,$@)
|
||||
$(V)$(AS) $(ASFLAGS) -MD $(BUILD_DIR)/$*.d -o $@ $<
|
||||
|
||||
# Specifically override the assets bin output location to match what splat output to the ld file.
|
||||
$(BUILD_DIR)/asm/assets/assets.s.o: asm/assets/assets.s | $(ALL_ASSETS_BUILT)
|
||||
$(BUILD_DIR)/asm/assets/assets.s.o: asm/assets/assets.s | build_assets
|
||||
$(call print,Assembling Assets:,$<,$@)
|
||||
$(V)$(AS) $(ASFLAGS) -o $(BUILD_DIR)/assets/assets.bin.o $<
|
||||
|
||||
# Specifically override the header file from what splat extracted to be replaced by what we have in the hasm folder
|
||||
$(BUILD_DIR)/asm/header.s.o: src/hasm/header.s | $(ALL_ASSETS_BUILT)
|
||||
$(BUILD_DIR)/asm/header.s.o: src/hasm/header.s | build_assets
|
||||
$(call print,Assembling Header:,$<,$@)
|
||||
$(V)$(AS) $(ASFLAGS) -o $(BUILD_DIR)/asm/header.s.o $<
|
||||
|
||||
ifeq ($(NON_MATCHING),1)
|
||||
# If doing a NON_MATCHING build, and the custom boot file exists, use that.
|
||||
ifneq ("$(wildcard $(BOOT_CUSTOM))","")
|
||||
$(BUILD_DIR)/assets/boot.bin.o: $(BOOT_CUSTOM) | $(ALL_ASSETS_BUILT)
|
||||
$(BUILD_DIR)/assets/boot.bin.o: $(BOOT_CUSTOM) | build_assets
|
||||
$(call print,Linking Custom Boot:,$<,$@)
|
||||
$(V)$(LD) -r -b binary -o $@ $<
|
||||
endif
|
||||
endif
|
||||
|
||||
$(BUILD_DIR)/%.bin.o: %.bin | $(ALL_ASSETS_BUILT)
|
||||
$(BUILD_DIR)/%.bin.o: %.bin | build_assets
|
||||
$(call print,Linking Binary:,$<,$@)
|
||||
$(V)$(LD) -r -b binary -o $@ $<
|
||||
|
||||
$(TARGET).bin: $(TARGET).elf | $(ALL_ASSETS_BUILT)
|
||||
$(TARGET).bin: $(TARGET).elf | build_assets
|
||||
$(call print,Objcopy:,$<,$@)
|
||||
$(V)$(OBJCOPY) $(OBJCOPYFLAGS) $< $@
|
||||
|
||||
$(TARGET).z64: $(TARGET).bin | $(ALL_ASSETS_BUILT)
|
||||
$(TARGET).z64: $(TARGET).bin | build_assets
|
||||
$(call print,CopyRom:,$<,$@)
|
||||
$(V)$(PYTHON) $(TOOLS_DIR)/python/CopyRom.py $< $@
|
||||
|
||||
|
||||
+1
-1
@@ -8,6 +8,6 @@ for i in ${!regions[@]}; do
|
||||
region=${regions[$i]}
|
||||
version=${versions[$i]}
|
||||
echo "Compiling $region.$version"
|
||||
make REGION=$region VERSION=$version cleanextract && make REGION=$region VERSION=$version -j12
|
||||
make REGION=$region VERSION=$version cleanextract && make assets REGION=$region VERSION=$version -j12
|
||||
if [[ $(sha1sum -c --quiet ver/verification/dkr.$region.$version.sha1) = "" ]]; then echo "$region.$version OK"; else echo "Failed $region.$version"; exit 1; fi
|
||||
done
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore all the md5 files
|
||||
*.md5
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"files": {
|
||||
"order": [
|
||||
"ASSET_CUSTOM_TESTCUBE"
|
||||
],
|
||||
"sections": {
|
||||
"ASSET_CUSTOM_TESTCUBE": {
|
||||
"filename": "okCube.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"name": "Custom Model Test",
|
||||
"authors" : ["Example"],
|
||||
"description": "A simple cube model with a custom texture that replaces the N64 logo on the bootup screen."
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"models": [
|
||||
"ASSET_CUSTOM_TESTCUBE"
|
||||
],
|
||||
"merge-type": "patch"
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"model": "okCube.obj",
|
||||
"type": "ObjectModel"
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
# Blender 4.2.3 LTS MTL File: 'okCube.blend'
|
||||
# www.blender.org
|
||||
|
||||
newmtl OK
|
||||
Ns 250.000000
|
||||
Ka 1.000000 1.000000 1.000000
|
||||
Ks 0.500000 0.500000 0.500000
|
||||
Ke 0.000000 0.000000 0.000000
|
||||
Ni 1.500000
|
||||
d 1.000000
|
||||
illum 2
|
||||
map_Kd ok.png
|
||||
@@ -0,0 +1,50 @@
|
||||
# Blender 4.2.3 LTS
|
||||
# www.blender.org
|
||||
mtllib okCube.mtl
|
||||
o Cube
|
||||
v -1.000000 -1.000000 1.000000
|
||||
v -1.000000 1.000000 1.000000
|
||||
v -1.000000 -1.000000 -1.000000
|
||||
v -1.000000 1.000000 -1.000000
|
||||
v 1.000000 -1.000000 1.000000
|
||||
v 1.000000 1.000000 1.000000
|
||||
v 1.000000 -1.000000 -1.000000
|
||||
v 1.000000 1.000000 -1.000000
|
||||
vt 0.997037 0.999800
|
||||
vt 0.001401 0.004664
|
||||
vt 0.996713 0.004264
|
||||
vt 1.000502 1.001801
|
||||
vt -0.000438 -0.001309
|
||||
vt 0.999901 0.006264
|
||||
vt 0.998942 0.999685
|
||||
vt -0.000837 0.000692
|
||||
vt 1.001076 0.004442
|
||||
vt 1.001248 1.009469
|
||||
vt 0.001877 -0.005005
|
||||
vt 1.001871 -0.004697
|
||||
vt 0.995394 0.004395
|
||||
vt -0.000019 0.996097
|
||||
vt 0.003106 0.005796
|
||||
vt 0.999416 0.002147
|
||||
vt -0.002540 1.000085
|
||||
vt -0.002540 0.002147
|
||||
vt 0.001724 1.000200
|
||||
vt 0.000501 1.003068
|
||||
vt -0.002671 0.999511
|
||||
vt 0.001254 1.009161
|
||||
vt 0.998585 0.993865
|
||||
vt 0.999416 1.000085
|
||||
s 0
|
||||
usemtl OK
|
||||
f 2/1 3/2 1/3
|
||||
f 4/4 7/5 3/6
|
||||
f 8/7 5/8 7/9
|
||||
f 6/10 1/11 5/12
|
||||
f 7/13 1/14 3/15
|
||||
f 4/16 6/17 8/18
|
||||
f 2/1 4/19 3/2
|
||||
f 4/4 8/20 7/5
|
||||
f 8/7 6/21 5/8
|
||||
f 6/10 2/22 1/11
|
||||
f 7/13 5/23 1/14
|
||||
f 4/16 2/24 6/17
|
||||
+3
-3
@@ -1344,7 +1344,7 @@ void func_800C6464_C7064(void) {
|
||||
}
|
||||
}
|
||||
|
||||
D_8012C2A4_EE5E4 = (FontData_JP *) load_asset_section_from_rom(ASSET_BINARY_45);
|
||||
D_8012C2A4_EE5E4 = (FontData_JP *) load_asset_section_from_rom(ASSET_JAPANESE_FONTS_TABLE);
|
||||
|
||||
// Init the 4 pointers in D_8012C2A8_EE5E8 (table for spacing of each character in every font)
|
||||
D_8012C2A8_EE5E8[0] = mempool_alloc_safe(NUMBER_OF_JP_FONTS * JP_FONT_ARRAY_SIZE, COLOUR_TAG_RED);
|
||||
@@ -1356,7 +1356,7 @@ void func_800C6464_C7064(void) {
|
||||
for (i = 0; i < 4; i++) {
|
||||
jpFontHeader = &D_8012C2A4_EE5E4[i];
|
||||
for (charIndex = 0; charIndex < JP_FONT_ARRAY_SIZE; charIndex++) {
|
||||
load_asset_to_address(ASSET_BINARY_46, (u32) jpFontData,
|
||||
load_asset_to_address(ASSET_JAPANESE_FONTS, (u32) jpFontData,
|
||||
jpFontHeader->offsetToData + (charIndex * jpFontHeader->bytesPerCharacter), 0x40);
|
||||
D_8012C2A8_EE5E8[i]->spacing[charIndex] = jpFontData->spacing;
|
||||
}
|
||||
@@ -1473,7 +1473,7 @@ s32 func_800C68CC_C74CC(u16 arg0) {
|
||||
}
|
||||
}
|
||||
asset = &D_8012C2C0_EE600[curIndex];
|
||||
load_asset_to_address(ASSET_BINARY_46, (u32) asset,
|
||||
load_asset_to_address(ASSET_JAPANESE_FONTS, (u32) asset,
|
||||
D_8012C2A4_EE5E4[fontInUse].offsetToData +
|
||||
(D_8012C2A4_EE5E4[fontInUse].bytesPerCharacter * arg0),
|
||||
D_8012C2A4_EE5E4[fontInUse].bytesPerCharacter);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,14 +1,16 @@
|
||||
{
|
||||
"default_dkr_version": "us_1.0",
|
||||
"baseroms_subpath" : "baseroms/",
|
||||
"assets_subpath" : "assets/",
|
||||
"configs_subpath" : "extract-ver/",
|
||||
"include_subpath" : "include/",
|
||||
"asm_subpath" : "asm/",
|
||||
"build_subpath" : "build/",
|
||||
"data_subpath" : "data/",
|
||||
"model_scale": 0.001,
|
||||
"extract-config" : "tools/dkr_assets_tool_extract.json",
|
||||
"baseroms-subpath" : "baseroms/",
|
||||
"assets-subpath" : "assets/",
|
||||
"configs-subpath" : "extract-ver/",
|
||||
"include-subpath" : "include/",
|
||||
"asm-subpath" : "asm/",
|
||||
"build-subpath" : "build/",
|
||||
"data-subpath" : "data/",
|
||||
"model-scale": 0.001,
|
||||
"threads" : 0,
|
||||
"debug": {
|
||||
"keep-uncompressed": true
|
||||
"keep-uncompressed": true,
|
||||
"write-assets-map": false
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user