Skip to content

Commit

Permalink
Add custom build rule for material display lists with image addresses…
Browse files Browse the repository at this point in the history
… in them
  • Loading branch information
LagoLunatic committed Nov 1, 2024
1 parent a16d8ce commit e9f82ff
Show file tree
Hide file tree
Showing 9 changed files with 543 additions and 114 deletions.
26 changes: 20 additions & 6 deletions config/GZLE01/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2201,29 +2201,43 @@ extract:
- symbol: l_Oba_swood_a_mikiDL
binary: assets/l_Oba_swood_a_mikiDL.bin
header: assets/l_Oba_swood_a_mikiDL.h
- symbol: l_matDL!.data:0x8037ad40
binary: assets/l_matDL__d_tree.bin
header: assets/l_matDL__d_tree.h
header_type: none
custom_type: matDL
- symbol: l_Txa_kage_32TEX
binary: assets/l_Txa_kage_32TEX.bin
header: assets/l_Txa_kage_32TEX.h
- symbol: g_dTree_Oba_kage_32DL
binary: assets/g_dTree_Oba_kage_32DL.bin
header: assets/g_dTree_Oba_kage_32DL.h
- symbol: g_dTree_shadowMatDL
binary: assets/g_dTree_shadowMatDL.bin
header: assets/g_dTree_shadowMatDL.h
header_type: none
custom_type: matDL

- symbol: l_chainS3TCTEX!.data:0x803769e0
binary: assets/l_chainS3TCTEX__d_chain.bin
header: assets/l_chainS3TCTEX__d_chain.h
- symbol: l_chainDL!.data:0x80376ce0
binary: assets/l_chainDL__d_chain.bin
header: assets/l_chainDL__d_chain.h
# - symbol: l_matDL!.data:0x80376d60
# binary: assets/l_matDL__d_chain.bin
# header: assets/l_matDL__d_chain.h
- symbol: l_matDL!.data:0x80376d60
binary: assets/l_matDL__d_chain.bin
header: assets/l_matDL__d_chain.h
header_type: none
custom_type: matDL

- symbol: l_chainS3TCTEX!.data:0x8038bd40
binary: assets/l_chainS3TCTEX__d_hookshot.bin
header: assets/l_chainS3TCTEX__d_hookshot.h
- symbol: l_chainDL!.data:0x8038c040
binary: assets/l_chainDL__d_hookshot.bin
header: assets/l_chainDL__d_hookshot.h
# - symbol: l_matDL!.data:0x8038c0c0
# binary: assets/l_matDL__d_hookshot.bin
# header: assets/l_matDL__d_hookshot.h
- symbol: l_matDL!.data:0x8038c0c0
binary: assets/l_matDL__d_hookshot.bin
header: assets/l_matDL__d_hookshot.h
header_type: none
custom_type: matDL
26 changes: 20 additions & 6 deletions config/GZLJ01/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1785,29 +1785,43 @@ extract:
- symbol: l_Oba_swood_a_mikiDL
binary: assets/l_Oba_swood_a_mikiDL.bin
header: assets/l_Oba_swood_a_mikiDL.h
- symbol: l_matDL!.data:0x8036e1e0
binary: assets/l_matDL__d_tree.bin
header: assets/l_matDL__d_tree.h
header_type: none
custom_type: matDL
- symbol: l_Txa_kage_32TEX
binary: assets/l_Txa_kage_32TEX.bin
header: assets/l_Txa_kage_32TEX.h
- symbol: g_dTree_Oba_kage_32DL
binary: assets/g_dTree_Oba_kage_32DL.bin
header: assets/g_dTree_Oba_kage_32DL.h
- symbol: g_dTree_shadowMatDL
binary: assets/g_dTree_shadowMatDL.bin
header: assets/g_dTree_shadowMatDL.h
header_type: none
custom_type: matDL

- symbol: l_chainS3TCTEX!.data:0x80369e80
binary: assets/l_chainS3TCTEX__d_chain.bin
header: assets/l_chainS3TCTEX__d_chain.h
- symbol: l_chainDL!.data:0x8036a180
binary: assets/l_chainDL__d_chain.bin
header: assets/l_chainDL__d_chain.h
# - symbol: l_matDL!.data:0x8036a200
# binary: assets/l_matDL__d_chain.bin
# header: assets/l_matDL__d_chain.h
- symbol: l_matDL!.data:0x8036a200
binary: assets/l_matDL__d_chain.bin
header: assets/l_matDL__d_chain.h
header_type: none
custom_type: matDL

- symbol: l_chainS3TCTEX!.data:0x8037f3e0
binary: assets/l_chainS3TCTEX__d_hookshot.bin
header: assets/l_chainS3TCTEX__d_hookshot.h
- symbol: l_chainDL!.data:0x8037f6e0
binary: assets/l_chainDL__d_hookshot.bin
header: assets/l_chainDL__d_hookshot.h
# - symbol: l_matDL!.data:0x8037f760
# binary: assets/l_matDL__d_hookshot.bin
# header: assets/l_matDL__d_hookshot.h
- symbol: l_matDL!.data:0x8037f760
binary: assets/l_matDL__d_hookshot.bin
header: assets/l_matDL__d_hookshot.h
header_type: none
custom_type: matDL
26 changes: 20 additions & 6 deletions config/GZLP01/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1797,29 +1797,43 @@ extract:
- symbol: l_Oba_swood_a_mikiDL
binary: assets/l_Oba_swood_a_mikiDL.bin
header: assets/l_Oba_swood_a_mikiDL.h
- symbol: l_matDL!.data:0x80381a20
binary: assets/l_matDL__d_tree.bin
header: assets/l_matDL__d_tree.h
header_type: none
custom_type: matDL
- symbol: l_Txa_kage_32TEX
binary: assets/l_Txa_kage_32TEX.bin
header: assets/l_Txa_kage_32TEX.h
- symbol: g_dTree_Oba_kage_32DL
binary: assets/g_dTree_Oba_kage_32DL.bin
header: assets/g_dTree_Oba_kage_32DL.h
- symbol: g_dTree_shadowMatDL
binary: assets/g_dTree_shadowMatDL.bin
header: assets/g_dTree_shadowMatDL.h
header_type: none
custom_type: matDL

- symbol: l_chainS3TCTEX!.data:0x8037d6c0
binary: assets/l_chainS3TCTEX__d_chain.bin
header: assets/l_chainS3TCTEX__d_chain.h
- symbol: l_chainDL!.data:0x8037d9c0
binary: assets/l_chainDL__d_chain.bin
header: assets/l_chainDL__d_chain.h
# - symbol: l_matDL!.data:0x8037da40
# binary: assets/l_matDL__d_chain.bin
# header: assets/l_matDL__d_chain.h
- symbol: l_matDL!.data:0x8037da40
binary: assets/l_matDL__d_chain.bin
header: assets/l_matDL__d_chain.h
header_type: none
custom_type: matDL

- symbol: l_chainS3TCTEX!.data:0x80392a20
binary: assets/l_chainS3TCTEX__d_hookshot.bin
header: assets/l_chainS3TCTEX__d_hookshot.h
- symbol: l_chainDL!.data:0x80392d20
binary: assets/l_chainDL__d_hookshot.bin
header: assets/l_chainDL__d_hookshot.h
# - symbol: l_matDL!.data:0x80392da0
# binary: assets/l_matDL__d_hookshot.bin
# header: assets/l_matDL__d_hookshot.h
- symbol: l_matDL!.data:0x80392da0
binary: assets/l_matDL__d_hookshot.bin
header: assets/l_matDL__d_hookshot.h
header_type: none
custom_type: matDL
53 changes: 53 additions & 0 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
###

import argparse
import json
import sys
from pathlib import Path
from typing import Any, Dict, List
Expand Down Expand Up @@ -1735,6 +1736,58 @@ def MatchingFor(*versions):
ActorRel(NonMatching, "d_a_movie_player", extra_cflags=["-O3,p"]),
]


# Define our custom asset processing scripts
config.custom_build_rules = [
{
"name": "convert_matDL",
"command": "$python tools/converters/matDL_dis.py $in $out --symbol $symbol",
"description": "CONVERT $symbol",
},
]
config.custom_build_steps = {}

# Grab the specific GameID so we can format our strings properly
version = VERSIONS[version_num]
out_dir = config.build_dir / version


# This generates the build steps needed for preprocessing
def emit_build_rule(asset):
steps = config.custom_build_steps.setdefault("pre-compile", [])

match asset.get("custom_type"):
case None:
return

case "matDL":
steps.append(
{
"rule": "convert_matDL",
"inputs": out_dir / "bin" / asset["binary"],
"outputs": out_dir / "include" / asset["header"],
"variables": {
"symbol": asset["symbol"],
},
"implicit": Path("tools/converters/matDL_dis.py"),
}
)

case _:
print("Unknown asset type: " + asset["custom_type"])


# Parse the config and create the build rules for all our assets
config_path = out_dir / "config.json"
if config_path.exists():
config_data = json.load(open(config_path))
for asset in config_data.get("extract", []):
emit_build_rule(asset)
for module in config_data.get("modules", []):
for asset in module.get("extract", []):
emit_build_rule(asset)


# Optional extra categories for progress tracking
config.progress_categories = [
ProgressCategory("game", "TWW Game Code"),
Expand Down
2 changes: 1 addition & 1 deletion include/JSystem/JUtility/JUTAssert.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define JUTASSERT_H

#include "dolphin/types.h"
#include "dolphin/os/OS.h"
#include "dolphin/os/OS.h" // IWYU pragma: export // Used by the JUT_ASSERT macro.

#define JUT_SHOW_ASSERT(LINE, COND) JUTAssertion::showAssert(JUTAssertion::getSDevice(), __FILE__, LINE, #COND)

Expand Down
41 changes: 4 additions & 37 deletions src/d/actor/d_a_hookshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,14 @@
#include "SSystem/SComponent/c_counter.h"
#include "d/actor/d_a_player_main.h"
#include "d/d_procname.h"
#include "global.h"

#include "weak_data_2100_2080.h" // IWYU pragma: keep

#define CONST_U32(v) ((u8)((v) >> 16)), ((u8)((v) >> 8)), ((u8)((v) >> 0))
#define IMAGE_ADDR(addr) CONST_U32((u32)(addr) >> 5)

#include "assets/l_chainS3TCTEX__d_hookshot.h"
const u16 l_chainS3TCTEX__width = 32;
const u16 l_chainS3TCTEX__height = 32;

static Vec l_pos[0xC] = {
static Vec l_pos[] = {
{-2.0f, 1.522254f, -0.0f},
{-2.0f, 1.522254f, 7.0f},
{2.0f, 1.522254f, -0.0f},
Expand All @@ -35,7 +31,7 @@ static Vec l_pos[0xC] = {
{2.0f, -1.522254f, 7.0f},
};

static cXy l_texCoord[0xC] = {
static cXy l_texCoord[] = {
{0.02736f, 0.041406f},
{0.97264f, 0.041406f},
{0.830848f, 0.40324f},
Expand All @@ -52,37 +48,8 @@ static cXy l_texCoord[0xC] = {

#include "assets/l_chainDL__d_hookshot.h"

static u8 l_matDL[] ALIGN_DECL(32) = {
0x61, 0x80, 0x00, 0x01, 0x3A,
0x61, 0x84, 0x00, 0x00, 0x00,
0x61, 0x88, 0xE0, 0x7C, 0x1F,
// TX_SETIMAGE3_I0 BP command. Statically insert the pointer to the chain texture into the display list array by extracting each byte.
0x61, 0x94, IMAGE_ADDR(&l_chainS3TCTEX),
0x61, 0x30, 0x00, (l_chainS3TCTEX__width >> 0x08), (l_chainS3TCTEX__width >> 0x00),
0x61, 0x31, 0x00, (l_chainS3TCTEX__height >> 0x08), (l_chainS3TCTEX__height >> 0x00),
0x10, 0x00, 0x00, 0x10, 0x40, 0xFF, 0xFF, 0x42, 0x80,
0x08, 0x30, 0x3C, 0xF3, 0xCF, 0x00,
0x10, 0x00, 0x00, 0x10, 0x18, 0x3C, 0xF3, 0xCF, 0x00,
0x10, 0x00, 0x00, 0x10, 0x0E, 0x00, 0x00, 0x05, 0x43,
0x61, 0x28, 0x3C, 0x00, 0x00,
0x61, 0xC0, 0x08, 0x24, 0xAF,
0x61, 0xC1, 0x08, 0xFF, 0xF0,
0x61, 0x28, 0x3C, 0x00, 0x00,
0x61, 0xC2, 0x08, 0xF0, 0x8F,
0x61, 0xC3, 0x08, 0xFF, 0xC0,
0x61, 0x43, 0x00, 0x00, 0x01,
0x61, 0x40, 0x00, 0x00, 0x17,
0x61, 0x41, 0x00, 0x01, 0x0C,
0x61, 0xF3, 0x64, 0x00, 0x00,
0x10, 0x00, 0x00, 0x10, 0x3F, 0x00, 0x00, 0x00, 0x01,
0x10, 0x00, 0x00, 0x10, 0x09, 0x00, 0x00, 0x00, 0x01,
0x61, 0x00, 0x00, 0x04, 0x11,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
#include "assets/l_matDL__d_hookshot.h"
l_matDL__d_hookshot(l_chainS3TCTEX);

/* 800F104C-800F12C8 .text draw__16daHookshot_shapeFv */
void daHookshot_shape::draw() {
Expand Down
23 changes: 2 additions & 21 deletions src/d/d_chain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@

#include "weak_data_2100_2080.h" // IWYU pragma: keep

#define CONST_U32(v) ((u8)((v) >> 16)), ((u8)((v) >> 8)), ((u8)((v) >> 0))
#define IMAGE_ADDR(addr) CONST_U32((u32)(addr) >> 5)

#include "assets/l_chainS3TCTEX__d_chain.h"
const u16 l_chainS3TCTEX__width = 32;
const u16 l_chainS3TCTEX__height = 32;
Expand Down Expand Up @@ -49,24 +46,8 @@ static cXy l_texCoord[] = {

#include "assets/l_chainDL__d_chain.h"

static u8 l_matDL[0xa8] ALIGN_DECL(32) = {
0x61, 0x80, 0x00, 0x01, 0x3A,
0x61, 0x84, 0x00, 0x00, 0x00,
0x61, 0x88, 0xE0, 0x7C, 0x1F,
0x61, 0x94, IMAGE_ADDR(&l_chainS3TCTEX),
0x61, 0x30, 0x00, (l_chainS3TCTEX__width >> 0x08), (l_chainS3TCTEX__width >> 0x00),
0x61, 0x31, 0x00, (l_chainS3TCTEX__height >> 0x08), (l_chainS3TCTEX__height >> 0x00),
0x10, 0x00, 0x00, 0x10, 0x40, 0xFF, 0xFF, 0x42, 0x80,
0x08, 0x30, 0x3C, 0xF3, 0xCF, 0x00, 0x10, 0x00, 0x00,
0x10, 0x18, 0x3C, 0xF3, 0xCF, 0x00, 0x10, 0x00, 0x00, 0x10, 0x0E, 0x00, 0x00, 0x05, 0x43, 0x61,
0x28, 0x3C, 0x00, 0x00, 0x61, 0xC0, 0x08, 0x24, 0xAF, 0x61, 0xC1, 0x08, 0xFF, 0xF0, 0x61, 0x28,
0x3C, 0x00, 0x00, 0x61, 0xC2, 0x08, 0xF0, 0x8F, 0x61, 0xC3, 0x08, 0xFF, 0xC0, 0x61, 0x43, 0x00,
0x00, 0x01, 0x61, 0x40, 0x00, 0x00, 0x17, 0x61, 0x41, 0x00, 0x01, 0x0C, 0x61, 0xF3, 0x64, 0x00,
0x00, 0x10, 0x00, 0x00, 0x10, 0x3F, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x10, 0x09, 0x00,
0x00, 0x00, 0x01, 0x61, 0x00, 0x00, 0x04, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
#include "assets/l_matDL__d_chain.h"
l_matDL__d_chain(l_chainS3TCTEX);

/* 800628B4-80062954 .text __ct__15dChain_packet_cFiP12dKy_tevstr_cf */
dChain_packet_c::dChain_packet_c(int num, dKy_tevstr_c* tevstr, f32 scale) {
Expand Down
41 changes: 4 additions & 37 deletions src/d/d_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@

#include "weak_data_2100_2080.h" // IWYU pragma: keep

#define CONST_U32(v) ((u8)((v) >> 16)), ((u8)((v) >> 8)), ((u8)((v) >> 0))
#define IMAGE_ADDR(addr) CONST_U32((u32)(addr) >> 5)

#include "assets/l_Txa_swood_aTEX.h"
const u16 l_Txa_swood_aTEX__width = 64;
const u16 l_Txa_swood_aTEX__height = 64;
Expand Down Expand Up @@ -137,24 +134,8 @@ cXy l_texCoord[] = {
#include "assets/l_Oba_swood_a_hapaDL.h"
#include "assets/l_Oba_swood_a_mikiDL.h"

u8 l_matDL[] ALIGN_DECL(32) = {
0x61, 0x80, 0x00, 0x01, 0x3A,
0x61, 0x84, 0x00, 0x00, 0x00,
0x61, 0x88, 0xE0, 0xFC, 0x3F,
0x61, 0x94, IMAGE_ADDR(&l_Txa_swood_aTEX),
0x61, 0x30, 0x00, (l_Txa_swood_aTEX__width >> 0x08), (l_Txa_swood_aTEX__width >> 0x00),
0x61, 0x31, 0x00, (l_Txa_swood_aTEX__height >> 0x08), (l_Txa_swood_aTEX__height >> 0x00),
0x10, 0x00, 0x00, 0x10, 0x40, 0xFF, 0xFF, 0x42, 0x80,
0x08, 0x30, 0x3C, 0xF3, 0xCF, 0x00, 0x10, 0x00, 0x00,
0x10, 0x18, 0x3C, 0xF3, 0xCF, 0x00, 0x10, 0x00, 0x00, 0x10, 0x0E, 0x00, 0x00, 0x05, 0x43, 0x61,
0x28, 0x3C, 0x00, 0x00, 0x61, 0xC0, 0x08, 0x24, 0xAF, 0x61, 0xC1, 0x08, 0xFF, 0xF0, 0x61, 0x28,
0x3C, 0x00, 0x00, 0x61, 0xC2, 0x08, 0xF0, 0x8F, 0x61, 0xC3, 0x08, 0xEE, 0x70, 0x61, 0x40, 0x00,
0x00, 0x17, 0x61, 0x41, 0x00, 0x01, 0x0C, 0x61, 0xF3, 0x64, 0x00, 0x00, 0x10, 0x00, 0x00, 0x10,
0x3F, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x10, 0x09, 0x00, 0x00, 0x00, 0x01, 0x61, 0x00,
0x00, 0x04, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
};
#include "assets/l_matDL__d_tree.h"
l_matDL__d_tree(l_Txa_swood_aTEX);

#include "assets/l_Txa_kage_32TEX.h"
const u16 l_Txa_kage_32TEX__width = 32;
Expand All @@ -176,22 +157,8 @@ u8 g_dTree_shadowTexCoord[][2] = {

#include "assets/g_dTree_Oba_kage_32DL.h"

u8 g_dTree_shadowMatDL[] ALIGN_DECL(32) = {
0x61, 0x80, 0x00, 0x01, 0x35,
0x61, 0x84, 0x00, 0x00, 0x00,
0x61, 0x88, 0x00, 0x7C, 0x1F,
0x61, 0x94, IMAGE_ADDR(&l_Txa_kage_32TEX),
0x61, 0x30, 0x00, (l_Txa_kage_32TEX__width >> 0x08), (l_Txa_kage_32TEX__width >> 0x00),
0x61, 0x31, 0x00, (l_Txa_kage_32TEX__height >> 0x08), (l_Txa_kage_32TEX__height >> 0x00),
0x10, 0x00, 0x00, 0x10, 0x40, 0xFF, 0xFF, 0x42, 0x80,
0x08, 0x30, 0x3C, 0xF3, 0xCF, 0x00, 0x10, 0x00, 0x00,
0x10, 0x18, 0x3C, 0xF3, 0xCF, 0x00, 0x61, 0x28, 0x38, 0x03, 0xC0, 0x61, 0xC0, 0x08, 0xFF, 0xFF,
0x61, 0xC1, 0x08, 0xE6, 0x70, 0x61, 0x43, 0x00, 0x00, 0x01, 0x61, 0x40, 0x00, 0x00, 0x07, 0x61,
0x41, 0x00, 0x04, 0xAD, 0x61, 0xF3, 0x64, 0x00, 0x00, 0x10, 0x00, 0x00, 0x10, 0x3F, 0x00, 0x00,
0x00, 0x01, 0x10, 0x00, 0x00, 0x10, 0x09, 0x00, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x40, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
#include "assets/g_dTree_shadowMatDL.h"
g_dTree_shadowMatDL(l_Txa_kage_32TEX);

const u32 g_dTree_Oba_kage_32DL_SIZE = sizeof(g_dTree_Oba_kage_32DL);
const u32 g_dTree_shadowMatDL_SIZE = sizeof(g_dTree_shadowMatDL);
Expand Down
Loading

0 comments on commit e9f82ff

Please sign in to comment.