From 09ea3c57f59725ffb512c208794c1f2d8ae9aaa0 Mon Sep 17 00:00:00 2001 From: madeline Date: Mon, 6 Apr 2026 07:53:46 -0700 Subject: [PATCH 01/16] runtime data asset loader --- files.cmake | 2 + include/dusk/dvd_asset.hpp | 22 ++++++++ src/d/actor/d_a_mant.cpp | 22 ++++++++ src/d/actor/d_a_player.cpp | 6 +++ src/d/actor/d_flower.inc | 35 ++++++++++++ src/d/actor/d_grass.inc | 29 ++++++++-- src/d/d_error_msg.cpp | 17 ++++++ src/dusk/dvd_asset.cpp | 106 +++++++++++++++++++++++++++++++++++++ src/m_Do/m_Do_ext.cpp | 3 ++ 9 files changed, 239 insertions(+), 3 deletions(-) create mode 100644 include/dusk/dvd_asset.hpp create mode 100644 src/dusk/dvd_asset.cpp diff --git a/files.cmake b/files.cmake index 7d07408613..e9149a1777 100644 --- a/files.cmake +++ b/files.cmake @@ -1333,6 +1333,8 @@ set(DOLPHIN_FILES set(DUSK_FILES include/dusk/endian_gx.hpp include/dusk/config.hpp + include/dusk/dvd_asset.hpp + src/dusk/dvd_asset.cpp src/d/actor/d_a_alink_dusk.cpp src/dusk/asserts.cpp src/dusk/config.cpp diff --git a/include/dusk/dvd_asset.hpp b/include/dusk/dvd_asset.hpp new file mode 100644 index 0000000000..3c36b75195 --- /dev/null +++ b/include/dusk/dvd_asset.hpp @@ -0,0 +1,22 @@ +#pragma once + +#include "dolphin/types.h" + +namespace dusk { + +/** + * Load bytes from the main DOL by GameCube virtual address + */ +bool LoadDolAsset(void* dst, u32 virtualAddress, s32 size); + +/** + * Load bytes from a REL file in the ISO filesystem + */ +void* LoadRelAsset(const char* dvdPath, s32 offset, s32 size); + +/** + * Load bytes from a REL inside RELS.arc + */ +bool LoadArchivedRelAsset(void* dst, u32 memType, const char* relFileName, s32 offset, s32 size); + +} // namespace dusk diff --git a/src/d/actor/d_a_mant.cpp b/src/d/actor/d_a_mant.cpp index a3b48f1098..1760db60fa 100644 --- a/src/d/actor/d_a_mant.cpp +++ b/src/d/actor/d_a_mant.cpp @@ -10,11 +10,21 @@ #include "d/actor/d_a_b_gnd.h" #include "d/d_com_inf_game.h" +#if TARGET_PC +#include "dusk/dvd_asset.hpp" +static u8* l_Egnd_mantTEX_get() { static u8* p = (u8*)dusk::LoadRelAsset("/rel/Final/Release/d_a_mant.rel", 0x1C00, 0x4000); return p; } +static u8* l_Egnd_mantTEX_U_get() { static u8* p = (u8*)dusk::LoadRelAsset("/rel/Final/Release/d_a_mant.rel", 0x5C00, 0x4000); return p; } +static u8* l_Egnd_mantPAL_get() { static u8* p = (u8*)dusk::LoadRelAsset("/rel/Final/Release/d_a_mant.rel", 0x9C00, 0x60); return p; } +#define l_Egnd_mantTEX (l_Egnd_mantTEX_get()) +#define l_Egnd_mantTEX_U (l_Egnd_mantTEX_U_get()) +#define l_Egnd_mantPAL (l_Egnd_mantPAL_get()) +#else #include "assets/l_Egnd_mantTEX.h" #include "assets/l_Egnd_mantTEX_U.h" #include "assets/l_Egnd_mantPAL.h" +#endif #include "d/d_s_play.h" static u32 l_pos[507] = { @@ -239,20 +249,32 @@ static u32 l_texCoord[338] = { 0x3F800000, 0x00000000, }; +#if TARGET_PC +static u8* l_Egnd_mantDL_get() { static u8* p = (u8*)dusk::LoadRelAsset("/rel/Final/Release/d_a_mant.rel", 0xA9A0, 0x3EC); return p; } +#define l_Egnd_mantDL (l_Egnd_mantDL_get()) +#else #include "assets/l_Egnd_mantDL.h" +#endif +#if !TARGET_PC static void* pal_d = (void*)&l_Egnd_mantPAL; static void* tex_d[2] = { (void*)&l_Egnd_mantTEX, (void*)&l_Egnd_mantTEX_U, }; +#endif static char lbl_277_bss_0; void daMant_packet_c::draw() { +#if TARGET_PC + void* image = l_Egnd_mantTEX; + void* lut = l_Egnd_mantPAL; +#else void* image = tex_d[0]; void* lut = pal_d; +#endif j3dSys.reinitGX(); GXSetNumIndStages(0); diff --git a/src/d/actor/d_a_player.cpp b/src/d/actor/d_a_player.cpp index f38fe15a3b..697635d69d 100644 --- a/src/d/actor/d_a_player.cpp +++ b/src/d/actor/d_a_player.cpp @@ -368,7 +368,13 @@ JKRHeap* daPy_anmHeap_c::setAnimeHeap() { } #if !PLATFORM_WII +#if TARGET_PC +#include "dusk/dvd_asset.hpp" +static const u8* l_sightDL_get() { static u8 buf[0x89]; static bool _ = (dusk::LoadDolAsset(buf, 0x803BA0C0, 0x89), true); return buf; } +#define l_sightDL (l_sightDL_get()) +#else #include "assets/l_sightDL__d_a_player.h" +#endif void daPy_sightPacket_c::draw() { TGXTexObj texObj; diff --git a/src/d/actor/d_flower.inc b/src/d/actor/d_flower.inc index 762b1e02e9..93a7e35097 100644 --- a/src/d/actor/d_flower.inc +++ b/src/d/actor/d_flower.inc @@ -13,7 +13,13 @@ const u16 l_J_Ohana00_64TEX__width = 63; const u16 l_J_Ohana00_64TEX__height = 63; #endif +#if TARGET_PC +#include "dusk/dvd_asset.hpp" +static u8* l_J_Ohana00_64TEX_get() { static u8 buf[0x800]; static bool _ = (dusk::LoadArchivedRelAsset(buf, 'AMEM', "d_a_grass.rel", 0x9060, 0x800), true); return buf; } +#define l_J_Ohana00_64TEX (l_J_Ohana00_64TEX_get()) +#else #include "assets/l_J_Ohana00_64TEX.h" +#endif static u8 l_flowerPos[708] = { 0xC0, 0x8C, 0x2C, 0xF7, 0x42, 0x05, 0xBC, 0xDF, 0xC1, 0xA1, 0x00, 0x70, 0xBF, 0x50, 0x51, 0xB9, @@ -104,6 +110,16 @@ static u8 l_flowerTexCoord[] = { 0x3E, 0xA7, 0x67, 0x4D, 0x3C, 0x14, 0x46, 0x74, 0x3E, 0xA7, 0x73, 0xE2, 0xBC, 0x2F, 0x46, 0xAA, 0x3E, 0xA7, 0x72, 0xD6, 0xBD, 0x2F, 0x46, 0xAA}; +#if TARGET_PC +static u8* l_J_hana00DL_get() { static u8 buf[0x150]; static bool _ = (dusk::LoadArchivedRelAsset(buf, 'AMEM', "d_a_grass.rel", 0x9D20, 0x150), true); return buf; } +static u8* l_J_hana00_cDL_get() { static u8 buf[0xDE]; static bool _ = (dusk::LoadArchivedRelAsset(buf, 'AMEM', "d_a_grass.rel", 0x9E80, 0xDE), true); return buf; } +static u8* l_matDL_get() { static u8 buf[0x99]; static bool _ = (dusk::LoadArchivedRelAsset(buf, 'AMEM', "d_a_grass.rel", 0x9F60, 0x99), true); return buf; } +static u8* l_matLight4DL_get() { static u8 buf[0x99]; static bool _ = (dusk::LoadArchivedRelAsset(buf, 'AMEM', "d_a_grass.rel", 0xA000, 0x99), true); return buf; } +#define l_J_hana00DL (l_J_hana00DL_get()) +#define l_J_hana00_cDL (l_J_hana00_cDL_get()) +#define l_matDL (l_matDL_get()) +#define l_matLight4DL (l_matLight4DL_get()) +#else #include "assets/l_J_hana00DL.h" #include "assets/l_J_hana00_cDL.h" @@ -113,6 +129,7 @@ l_matDL__d_a_grass(l_J_Ohana00_64TEX) #include "assets/l_matLight4DL.h" l_matLight4DL(l_J_Ohana00_64TEX) +#endif #if TARGET_PC const u16 l_J_Ohana01_64128_0419TEX__width = 64; @@ -122,7 +139,12 @@ const u16 l_J_Ohana01_64128_0419TEX__width = 63; const u16 l_J_Ohana01_64128_0419TEX__height = 127; #endif +#if TARGET_PC +static u8* l_J_Ohana01_64128_0419TEX_get() { static u8 buf[0x1000]; static bool _ = (dusk::LoadArchivedRelAsset(buf, 'AMEM', "d_a_grass.rel", 0xA0A0, 0x1000), true); return buf; } +#define l_J_Ohana01_64128_0419TEX (l_J_Ohana01_64128_0419TEX_get()) +#else #include "assets/l_J_Ohana01_64128_0419TEX.h" +#endif static u8 l_flowerPos2[1224] = { 0x40, 0x25, 0x9F, 0x34, 0x42, 0xC2, 0x95, 0x72, 0xC1, 0x22, 0x34, 0x78, 0x41, 0x4D, 0xF9, 0x63, @@ -249,6 +271,18 @@ static u8 l_flowerTexCoord2[] = { 0x40, 0x1B, 0x7D, 0x52, 0x3F, 0x97, 0xF6, 0xBA, 0x40, 0x04, 0x26, 0x74, 0x3F, 0x80, 0x3F, 0x79, 0x40, 0x1B, 0x7D, 0x52, 0x3F, 0x80, 0x3F, 0x79, 0x40, 0x1B, 0x7D, 0x52, 0x3F, 0x51, 0x10, 0x6F}; +#if TARGET_PC +static u8* l_J_hana01DL_get() { static u8 buf[0x138]; static bool _ = (dusk::LoadArchivedRelAsset(buf, 'AMEM', "d_a_grass.rel", 0xB7C0, 0x138), true); return buf; } +static u8* l_J_hana01_c_00DL_get() { static u8 buf[0xDE]; static bool _ = (dusk::LoadArchivedRelAsset(buf, 'AMEM', "d_a_grass.rel", 0xB900, 0xDE), true); return buf; } +static u8* l_J_hana01_c_01DL_get() { static u8 buf[0x128]; static bool _ = (dusk::LoadArchivedRelAsset(buf, 'AMEM', "d_a_grass.rel", 0xB9E0, 0x128), true); return buf; } +static u8* l_mat2DL_get() { static u8 buf[0x99]; static bool _ = (dusk::LoadArchivedRelAsset(buf, 'AMEM', "d_a_grass.rel", 0xBB20, 0x99), true); return buf; } +static u8* l_mat2Light4DL_get() { static u8 buf[0x99]; static bool _ = (dusk::LoadArchivedRelAsset(buf, 'AMEM', "d_a_grass.rel", 0xBBC0, 0x99), true); return buf; } +#define l_J_hana01DL (l_J_hana01DL_get()) +#define l_J_hana01_c_00DL (l_J_hana01_c_00DL_get()) +#define l_J_hana01_c_01DL (l_J_hana01_c_01DL_get()) +#define l_mat2DL (l_mat2DL_get()) +#define l_mat2Light4DL (l_mat2Light4DL_get()) +#else #include "assets/l_J_hana01DL.h" #include "assets/l_J_hana01_c_00DL.h" @@ -260,6 +294,7 @@ l_mat2DL__d_a_grass(l_J_Ohana01_64128_0419TEX) #include "assets/l_mat2Light4DL.h" l_mat2Light4DL(l_J_Ohana01_64128_0419TEX) +#endif void dFlower_data_c::WorkCo(fopAc_ac_c* i_hitActor, u32 i_massFlg, int i_roomNo) { cXyz sp8; diff --git a/src/d/actor/d_grass.inc b/src/d/actor/d_grass.inc index 6351cc75fc..3645488b0f 100644 --- a/src/d/actor/d_grass.inc +++ b/src/d/actor/d_grass.inc @@ -13,11 +13,19 @@ const u16 l_M_Hijiki00TEX__width = 31; const u16 l_M_Hijiki00TEX__height = 31; -#include "assets/l_M_kusa05_RGBATEX.h" // ALIGN 32 - const u16 l_M_kusa05_RGBATEX__width = 31; const u16 l_M_kusa05_RGBATEX__height = 31; -#include "assets/l_M_Hijiki00TEX.h" // ALIGN 32 + +#if TARGET_PC +#include "dusk/dvd_asset.hpp" +static u8* l_M_kusa05_RGBATEX_get() { static u8 buf[0x800]; static bool _ = (dusk::LoadArchivedRelAsset(buf, 'AMEM', "d_a_grass.rel", 0x7680, 0x800), true); return buf; } +static u8* l_M_Hijiki00TEX_get() { static u8 buf[0x800]; static bool _ = (dusk::LoadArchivedRelAsset(buf, 'AMEM', "d_a_grass.rel", 0x7E80, 0x800), true); return buf; } +#define l_M_kusa05_RGBATEX (l_M_kusa05_RGBATEX_get()) +#define l_M_Hijiki00TEX (l_M_Hijiki00TEX_get()) +#else +#include "assets/l_M_kusa05_RGBATEX.h" // ALIGN 32 +#include "assets/l_M_Hijiki00TEX.h" // ALIGN 32 +#endif static u8 l_pos[960] = { 0x3F, 0x4A, 0x56, 0xEF, 0xC2, 0x20, 0x00, 0x00, 0x41, 0xFB, 0x17, 0xE4, 0x41, 0xAA, 0xBB, 0xEA, @@ -102,6 +110,20 @@ static u8 l_texCoord[160] = { 0x3F, 0x94, 0x00, 0x00, 0x3F, 0x80, 0x00, 0x00, 0xBD, 0xC0, 0x00, 0x00, 0x3F, 0x80, 0x00, 0x00, }; +#if TARGET_PC +static u8* l_M_Kusa_9qDL_get() { static u8 buf[0xCB]; static bool _ = (dusk::LoadArchivedRelAsset(buf, 'AMEM', "d_a_grass.rel", 0x8B00, 0xCB), true); return buf; } +static u8* l_M_Kusa_9q_cDL_get() { static u8 buf[0xCB]; static bool _ = (dusk::LoadArchivedRelAsset(buf, 'AMEM', "d_a_grass.rel", 0x8BE0, 0xCB), true); return buf; } +static u8* l_M_TenGusaDL_get() { static u8 buf[0xD4]; static bool _ = (dusk::LoadArchivedRelAsset(buf, 'AMEM', "d_a_grass.rel", 0x8CC0, 0xD4), true); return buf; } +static u8* l_Tengusa_matDL_get() { static u8 buf[0xA8]; static bool _ = (dusk::LoadArchivedRelAsset(buf, 'AMEM', "d_a_grass.rel", 0x8DA0, 0xA8), true); return buf; } +static u8* l_kusa9q_matDL_get() { static u8 buf[0xA8]; static bool _ = (dusk::LoadArchivedRelAsset(buf, 'AMEM', "d_a_grass.rel", 0x8E60, 0xA8), true); return buf; } +static u8* l_kusa9q_l4_matDL_get() { static u8 buf[0xA8]; static bool _ = (dusk::LoadArchivedRelAsset(buf, 'AMEM', "d_a_grass.rel", 0x8F20, 0xA8), true); return buf; } +#define l_M_Kusa_9qDL (l_M_Kusa_9qDL_get()) +#define l_M_Kusa_9q_cDL (l_M_Kusa_9q_cDL_get()) +#define l_M_TenGusaDL (l_M_TenGusaDL_get()) +#define l_Tengusa_matDL (l_Tengusa_matDL_get()) +#define l_kusa9q_matDL (l_kusa9q_matDL_get()) +#define l_kusa9q_l4_matDL (l_kusa9q_l4_matDL_get()) +#else #include "assets/l_M_Kusa_9qDL.h" #include "assets/l_M_Kusa_9q_cDL.h" @@ -117,6 +139,7 @@ l_kusa9q_matDL(l_M_kusa05_RGBATEX) #include "assets/l_kusa9q_l4_matDL.h" l_kusa9q_l4_matDL(l_M_kusa05_RGBATEX) +#endif void dGrass_data_c::WorkCo(fopAc_ac_c* i_hitActor, u32 i_massFlg, int i_roomNo) { cXyz sp18; diff --git a/src/d/d_error_msg.cpp b/src/d/d_error_msg.cpp index faa40ae543..f1d63b5a1f 100644 --- a/src/d/d_error_msg.cpp +++ b/src/d/d_error_msg.cpp @@ -15,6 +15,22 @@ #include "m_Do/m_Do_Reset.h" #include "m_Do/m_Do_graphic.h" +#if TARGET_PC +#include "dusk/dvd_asset.hpp" +static const u8* black_tex_get() { static u8 buf[0x40]; static bool _ = (dusk::LoadDolAsset(buf, 0x8037B140, 0x40), true); return buf; } +static const u8* msg_data_get() { static u8 buf[0x260]; static bool _ = (dusk::LoadDolAsset(buf, 0x8037B180, 0x260), true); return buf; } +static const u8* font_data_get() { static u8 buf[0x12260]; static bool _ = (dusk::LoadDolAsset(buf, 0x8037B3E0, 0x12260), true); return buf; } +#define black_tex (black_tex_get()) +#define msg_data (msg_data_get()) +#define font_data (font_data_get()) +#if VERSION == VERSION_GCN_PAL +// TODO: find addreses for pal languages +#define msg_data_ge ((const u8*)nullptr) +#define msg_data_fr ((const u8*)nullptr) +#define msg_data_sp ((const u8*)nullptr) +#define msg_data_it ((const u8*)nullptr) +#endif +#else #include "assets/black_tex.h" #include "assets/msg_data.h" #if VERSION == VERSION_GCN_PAL @@ -24,6 +40,7 @@ #include "assets/msg_data_it.h" #endif #include "assets/font_data.h" +#endif #define MSG_READING_DISC 0 #define MSG_COVER_OPEN 1 diff --git a/src/dusk/dvd_asset.cpp b/src/dusk/dvd_asset.cpp new file mode 100644 index 0000000000..bfa30cc941 --- /dev/null +++ b/src/dusk/dvd_asset.cpp @@ -0,0 +1,106 @@ +#include "dusk/dvd_asset.hpp" +#include "dusk/logging.h" +#include "dusk/endian.h" +#include "aurora/dvd.h" +#include "DynamicLink.h" +#include "JSystem/JKernel/JKRArchive.h" +#include "JSystem/JKernel/JKRDvdRipper.h" + +#include + +namespace dusk { + +static const u8* s_dolData = nullptr; // pointer to dol data +static size_t s_dolSize = 0; +struct DolSection { u32 fileOffset, vaddr, size; }; +static DolSection s_dolSections[18]; // 7 text + 11 data +static int s_dolSectionCount = 0; + +static bool EnsureDolParsed() { + if (s_dolData) return true; + + s32 sz = 0; + const u8* p = aurora_dvd_get_dol(sz); + if (!p || sz < 256) { + DuskLog.fatal("dvd_asset: aurora_dvd_get_dol failed (size={})", sz); return false; + } + + s_dolData = p; + s_dolSize = sz; + + const BE(u32)* hdr = (const BE(u32)*)s_dolData; + s_dolSectionCount = 0; + + // 0x00: text file offsets 0x12: text vaddrs 0x24: text sizes + for (int i = 0; i < 7; i++) { + u32 off = hdr[0x00+i], addr = hdr[0x12+i], sz = hdr[0x24+i]; + if (sz > 0 && off > 0) { + s_dolSections[s_dolSectionCount++] = {off, addr, sz}; + } + } + // 0x07: data file offsets 0x19: data vaddrs 0x2B: data sizes + for (int i = 0; i < 11; i++) { + u32 off = hdr[0x07+i], addr = hdr[0x19+i], sz = hdr[0x2B+i]; + if (sz > 0 && off > 0) { + s_dolSections[s_dolSectionCount++] = {off, addr, sz}; + } + } + + return true; +} + +static s32 DolVaToFileOffset(u32 va) { + if (!EnsureDolParsed()) return -1; + for (int i = 0; i < s_dolSectionCount; i++) { + const auto& sec = s_dolSections[i]; + if (va >= sec.vaddr && va < sec.vaddr + sec.size) { + return static_cast(sec.fileOffset + (va - sec.vaddr)); + } + } + DuskLog.fatal("dvd_asset: VA 0x{:08X} not found in any DOL section", va); + return -1; +} + +bool LoadDolAsset(void* dst, u32 virtualAddress, s32 size) { + s32 fileOffset = DolVaToFileOffset(virtualAddress); + if (fileOffset < 0) { + return false; + } + + if (size <= 0 || (size_t)(fileOffset + size) > s_dolSize) { + DuskLog.fatal("dvd_asset: DOL read out of range (offset={:#x} size={:#x} dolSize={})", fileOffset, size, s_dolSize); + return false; + } + + std::memcpy(dst, s_dolData + fileOffset, size); + return true; +} + +void* LoadRelAsset(const char* dvdPath, s32 offset, s32 size) { + void* p = JKRDvdRipper::loadToMainRAM(dvdPath, nullptr, EXPAND_SWITCH_UNKNOWN1, (u32)size, nullptr, JKRDvdRipper::ALLOC_DIRECTION_FORWARD, (u32)offset, nullptr, nullptr); + if (!p) DuskLog.fatal("dvd_asset: failed to load {} (offset={:#x} size={:#x})", dvdPath, offset, size); + return p; +} + +bool LoadArchivedRelAsset(void* dst, u32 memType, const char* relFileName, s32 offset, s32 size) { + // On TARGET_PC, cDyl_InitCallback skips DynamicModuleControl::initialize() due to static linking + // Mount RELS.arc on first use so sArchive is available + static bool s_mountAttempted = false; + if (!DynamicModuleControl::sArchive && !s_mountAttempted) { + s_mountAttempted = true; DynamicModuleControl::initialize(); + } + + if (!DynamicModuleControl::sArchive) { + DuskLog.fatal("dvd_asset: RELS archive not mounted"); return false; + } + + const u8* rel = static_cast(DynamicModuleControl::sArchive->getResource(memType, relFileName)); + if (!rel) { + DuskLog.fatal("dvd_asset: {} not found in RELS archive", relFileName); return false; + } + + std::memcpy(dst, rel + offset, size); + return true; +} + +} // namespace dusk diff --git a/src/m_Do/m_Do_ext.cpp b/src/m_Do/m_Do_ext.cpp index d744d048ba..0593815b1d 100644 --- a/src/m_Do/m_Do_ext.cpp +++ b/src/m_Do/m_Do_ext.cpp @@ -2873,7 +2873,10 @@ void mDoExt_3DlineMat1_c::update(int param_0, f32 param_1, GXColor& param_2, u16 sp_38++; } } + +#if !TARGET_PC #include "assets/l_mat2DL__d_a_grass.h" +#endif void mDoExt_3DlineMat2_c::setMaterial() { j3dSys.reinitGX(); From 7af15e98bc04bbab767ad32865c27b7fa8198e4f Mon Sep 17 00:00:00 2001 From: madeline Date: Mon, 6 Apr 2026 07:55:10 -0700 Subject: [PATCH 02/16] remove includes --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a074ea869..448a58a45e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -100,7 +100,6 @@ set(GAME_COMPILE_DEFS TARGET_PC AVOID_UB=1 VERSION=0 set(GAME_INCLUDE_DIRS include src - assets/${DUSK_TP_VERSION} libs/JSystem/include libs extern/aurora/include/dolphin From 31ccc912b7a99bada7671bcb7e6f05102b611dd7 Mon Sep 17 00:00:00 2001 From: madeline Date: Mon, 6 Apr 2026 07:57:00 -0700 Subject: [PATCH 03/16] walk that one on back --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 448a58a45e..3a074ea869 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -100,6 +100,7 @@ set(GAME_COMPILE_DEFS TARGET_PC AVOID_UB=1 VERSION=0 set(GAME_INCLUDE_DIRS include src + assets/${DUSK_TP_VERSION} libs/JSystem/include libs extern/aurora/include/dolphin From ad8d35ee5e9ababcc193da3c586fe47708435892 Mon Sep 17 00:00:00 2001 From: madeline Date: Mon, 6 Apr 2026 08:49:24 -0700 Subject: [PATCH 04/16] address review --- include/dusk/dvd_asset.hpp | 4 ++-- src/d/actor/d_a_mant.cpp | 8 ++++---- src/d/actor/d_flower.inc | 10 +++++----- src/dusk/dvd_asset.cpp | 39 ++++++++++++++++++++++++++++---------- 4 files changed, 40 insertions(+), 21 deletions(-) diff --git a/include/dusk/dvd_asset.hpp b/include/dusk/dvd_asset.hpp index 3c36b75195..014c683d44 100644 --- a/include/dusk/dvd_asset.hpp +++ b/include/dusk/dvd_asset.hpp @@ -10,9 +10,9 @@ namespace dusk { bool LoadDolAsset(void* dst, u32 virtualAddress, s32 size); /** - * Load bytes from a REL file in the ISO filesystem + * Load bytes from a REL file in the ISO filesystem, dst must be 32-byte aligned */ -void* LoadRelAsset(const char* dvdPath, s32 offset, s32 size); +bool LoadRelAsset(void* dst, const char* dvdPath, s32 offset, s32 size); /** * Load bytes from a REL inside RELS.arc diff --git a/src/d/actor/d_a_mant.cpp b/src/d/actor/d_a_mant.cpp index 1760db60fa..bcd7f05986 100644 --- a/src/d/actor/d_a_mant.cpp +++ b/src/d/actor/d_a_mant.cpp @@ -12,9 +12,9 @@ #if TARGET_PC #include "dusk/dvd_asset.hpp" -static u8* l_Egnd_mantTEX_get() { static u8* p = (u8*)dusk::LoadRelAsset("/rel/Final/Release/d_a_mant.rel", 0x1C00, 0x4000); return p; } -static u8* l_Egnd_mantTEX_U_get() { static u8* p = (u8*)dusk::LoadRelAsset("/rel/Final/Release/d_a_mant.rel", 0x5C00, 0x4000); return p; } -static u8* l_Egnd_mantPAL_get() { static u8* p = (u8*)dusk::LoadRelAsset("/rel/Final/Release/d_a_mant.rel", 0x9C00, 0x60); return p; } +static u8* l_Egnd_mantTEX_get() { alignas(32) static u8 buf[0x4000]; static bool _ = (dusk::LoadRelAsset(buf, "/rel/Final/Release/d_a_mant.rel", 0x1C00, 0x4000), true); return buf; } +static u8* l_Egnd_mantTEX_U_get() { alignas(32) static u8 buf[0x4000]; static bool _ = (dusk::LoadRelAsset(buf, "/rel/Final/Release/d_a_mant.rel", 0x5C00, 0x4000), true); return buf; } +static u8* l_Egnd_mantPAL_get() { alignas(32) static u8 buf[0x60]; static bool _ = (dusk::LoadRelAsset(buf, "/rel/Final/Release/d_a_mant.rel", 0x9C00, 0x60), true); return buf; } #define l_Egnd_mantTEX (l_Egnd_mantTEX_get()) #define l_Egnd_mantTEX_U (l_Egnd_mantTEX_U_get()) #define l_Egnd_mantPAL (l_Egnd_mantPAL_get()) @@ -250,7 +250,7 @@ static u32 l_texCoord[338] = { }; #if TARGET_PC -static u8* l_Egnd_mantDL_get() { static u8* p = (u8*)dusk::LoadRelAsset("/rel/Final/Release/d_a_mant.rel", 0xA9A0, 0x3EC); return p; } +static u8* l_Egnd_mantDL_get() { alignas(32) static u8 buf[0x3EC]; static bool _ = (dusk::LoadRelAsset(buf, "/rel/Final/Release/d_a_mant.rel", 0xA9A0, 0x3EC), true); return buf; } #define l_Egnd_mantDL (l_Egnd_mantDL_get()) #else #include "assets/l_Egnd_mantDL.h" diff --git a/src/d/actor/d_flower.inc b/src/d/actor/d_flower.inc index 93a7e35097..de6ac7c1dc 100644 --- a/src/d/actor/d_flower.inc +++ b/src/d/actor/d_flower.inc @@ -619,9 +619,9 @@ void dFlower_packet_c::draw() { } if (sp4C <= 2) { - GXCallDisplayList(&l_matLight4DL, 0x80); + GXCallDisplayList(l_matLight4DL, 0x80); } else { - GXCallDisplayList(&l_matDL, 0x80); + GXCallDisplayList(l_matDL, 0x80); } GXSetTevColorS10(GX_TEVREG0, sp80); @@ -677,9 +677,9 @@ void dFlower_packet_c::draw() { #endif if (!cLib_checkBit(sp44->m_state, 8)) { - GXCallDisplayList(&l_J_hana00DL, 0x140); + GXCallDisplayList(l_J_hana00DL, 0x140); } else { - GXCallDisplayList(&l_J_hana00_cDL, 0xC0); + GXCallDisplayList(l_J_hana00_cDL, 0xC0); } } } @@ -826,7 +826,7 @@ void dFlower_packet_c::draw() { if (!cLib_checkBit(sp34->m_state, 0x10)) { GXCallDisplayList(mp_Jhana01DL, m_Jhana01DL_size); } else { - GXCallDisplayList(&l_J_hana01_c_00DL, 0xC0); + GXCallDisplayList(l_J_hana01_c_00DL, 0xC0); } } else { GXCallDisplayList(mp_Jhana01_cDL, m_Jhana01_cDL_size); diff --git a/src/dusk/dvd_asset.cpp b/src/dusk/dvd_asset.cpp index bfa30cc941..9bcea14077 100644 --- a/src/dusk/dvd_asset.cpp +++ b/src/dusk/dvd_asset.cpp @@ -12,7 +12,22 @@ namespace dusk { static const u8* s_dolData = nullptr; // pointer to dol data static size_t s_dolSize = 0; -struct DolSection { u32 fileOffset, vaddr, size; }; + +struct DolHeader { + BE(u32) textOffset[7]; + BE(u32) dataOffset[11]; + BE(u32) textAddr[7]; + BE(u32) dataAddr[11]; + BE(u32) textSize[7]; + BE(u32) dataSize[11]; +}; + +struct DolSection { + u32 fileOffset; + u32 vaddr; + u32 size; +}; + static DolSection s_dolSections[18]; // 7 text + 11 data static int s_dolSectionCount = 0; @@ -22,25 +37,29 @@ static bool EnsureDolParsed() { s32 sz = 0; const u8* p = aurora_dvd_get_dol(sz); if (!p || sz < 256) { - DuskLog.fatal("dvd_asset: aurora_dvd_get_dol failed (size={})", sz); return false; + DuskLog.fatal("dvd_asset: aurora_dvd_get_dol failed (size={})", sz); + return false; } s_dolData = p; s_dolSize = sz; - const BE(u32)* hdr = (const BE(u32)*)s_dolData; + const auto* hdr = (const DolHeader*)s_dolData; s_dolSectionCount = 0; - // 0x00: text file offsets 0x12: text vaddrs 0x24: text sizes for (int i = 0; i < 7; i++) { - u32 off = hdr[0x00+i], addr = hdr[0x12+i], sz = hdr[0x24+i]; + u32 off = hdr->textOffset[i]; + u32 addr = hdr->textAddr[i]; + u32 sz = hdr->textSize[i]; if (sz > 0 && off > 0) { s_dolSections[s_dolSectionCount++] = {off, addr, sz}; } } - // 0x07: data file offsets 0x19: data vaddrs 0x2B: data sizes + for (int i = 0; i < 11; i++) { - u32 off = hdr[0x07+i], addr = hdr[0x19+i], sz = hdr[0x2B+i]; + u32 off = hdr->dataOffset[i]; + u32 addr = hdr->dataAddr[i]; + u32 sz = hdr->dataSize[i]; if (sz > 0 && off > 0) { s_dolSections[s_dolSectionCount++] = {off, addr, sz}; } @@ -76,10 +95,10 @@ bool LoadDolAsset(void* dst, u32 virtualAddress, s32 size) { return true; } -void* LoadRelAsset(const char* dvdPath, s32 offset, s32 size) { - void* p = JKRDvdRipper::loadToMainRAM(dvdPath, nullptr, EXPAND_SWITCH_UNKNOWN1, (u32)size, nullptr, JKRDvdRipper::ALLOC_DIRECTION_FORWARD, (u32)offset, nullptr, nullptr); +bool LoadRelAsset(void* dst, const char* dvdPath, s32 offset, s32 size) { + void* p = JKRDvdRipper::loadToMainRAM(dvdPath, (u8*)dst, EXPAND_SWITCH_UNKNOWN1, (u32)size, nullptr, JKRDvdRipper::ALLOC_DIRECTION_FORWARD, (u32)offset, nullptr, nullptr); if (!p) DuskLog.fatal("dvd_asset: failed to load {} (offset={:#x} size={:#x})", dvdPath, offset, size); - return p; + return p != nullptr; } bool LoadArchivedRelAsset(void* dst, u32 memType, const char* relFileName, s32 offset, s32 size) { From fa978591c11867971ee41afcc7261681ba68942c Mon Sep 17 00:00:00 2001 From: madeline Date: Mon, 6 Apr 2026 08:58:52 -0700 Subject: [PATCH 05/16] update include directories --- CMakeLists.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a074ea869..a237daaacc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,9 +104,7 @@ set(GAME_INCLUDE_DIRS libs/JSystem/include libs extern/aurora/include/dolphin - extern - ${CMAKE_SOURCE_DIR}/build/${DUSK_TP_VERSION}/include - build/${DUSK_TP_VERSION}/include) + extern) set(GAME_LIBS aurora::core aurora::gx aurora::gd aurora::si aurora::vi aurora::pad aurora::mtx aurora::os aurora::dvd aurora::card freeverb cxxopts::cxxopts absl::flat_hash_map nlohmann_json::nlohmann_json) From 9a158720441d569c96fbf78330d6e2c842eb939b Mon Sep 17 00:00:00 2001 From: madeline Date: Mon, 6 Apr 2026 07:53:46 -0700 Subject: [PATCH 06/16] runtime data asset loader --- files.cmake | 2 + include/dusk/dvd_asset.hpp | 22 ++++++++ src/d/actor/d_a_mant.cpp | 22 ++++++++ src/d/actor/d_a_player.cpp | 6 +++ src/d/actor/d_flower.inc | 35 ++++++++++++ src/d/actor/d_grass.inc | 29 ++++++++-- src/d/d_error_msg.cpp | 17 ++++++ src/dusk/dvd_asset.cpp | 106 +++++++++++++++++++++++++++++++++++++ src/m_Do/m_Do_ext.cpp | 3 ++ 9 files changed, 239 insertions(+), 3 deletions(-) create mode 100644 include/dusk/dvd_asset.hpp create mode 100644 src/dusk/dvd_asset.cpp diff --git a/files.cmake b/files.cmake index 7d07408613..e9149a1777 100644 --- a/files.cmake +++ b/files.cmake @@ -1333,6 +1333,8 @@ set(DOLPHIN_FILES set(DUSK_FILES include/dusk/endian_gx.hpp include/dusk/config.hpp + include/dusk/dvd_asset.hpp + src/dusk/dvd_asset.cpp src/d/actor/d_a_alink_dusk.cpp src/dusk/asserts.cpp src/dusk/config.cpp diff --git a/include/dusk/dvd_asset.hpp b/include/dusk/dvd_asset.hpp new file mode 100644 index 0000000000..3c36b75195 --- /dev/null +++ b/include/dusk/dvd_asset.hpp @@ -0,0 +1,22 @@ +#pragma once + +#include "dolphin/types.h" + +namespace dusk { + +/** + * Load bytes from the main DOL by GameCube virtual address + */ +bool LoadDolAsset(void* dst, u32 virtualAddress, s32 size); + +/** + * Load bytes from a REL file in the ISO filesystem + */ +void* LoadRelAsset(const char* dvdPath, s32 offset, s32 size); + +/** + * Load bytes from a REL inside RELS.arc + */ +bool LoadArchivedRelAsset(void* dst, u32 memType, const char* relFileName, s32 offset, s32 size); + +} // namespace dusk diff --git a/src/d/actor/d_a_mant.cpp b/src/d/actor/d_a_mant.cpp index a3b48f1098..1760db60fa 100644 --- a/src/d/actor/d_a_mant.cpp +++ b/src/d/actor/d_a_mant.cpp @@ -10,11 +10,21 @@ #include "d/actor/d_a_b_gnd.h" #include "d/d_com_inf_game.h" +#if TARGET_PC +#include "dusk/dvd_asset.hpp" +static u8* l_Egnd_mantTEX_get() { static u8* p = (u8*)dusk::LoadRelAsset("/rel/Final/Release/d_a_mant.rel", 0x1C00, 0x4000); return p; } +static u8* l_Egnd_mantTEX_U_get() { static u8* p = (u8*)dusk::LoadRelAsset("/rel/Final/Release/d_a_mant.rel", 0x5C00, 0x4000); return p; } +static u8* l_Egnd_mantPAL_get() { static u8* p = (u8*)dusk::LoadRelAsset("/rel/Final/Release/d_a_mant.rel", 0x9C00, 0x60); return p; } +#define l_Egnd_mantTEX (l_Egnd_mantTEX_get()) +#define l_Egnd_mantTEX_U (l_Egnd_mantTEX_U_get()) +#define l_Egnd_mantPAL (l_Egnd_mantPAL_get()) +#else #include "assets/l_Egnd_mantTEX.h" #include "assets/l_Egnd_mantTEX_U.h" #include "assets/l_Egnd_mantPAL.h" +#endif #include "d/d_s_play.h" static u32 l_pos[507] = { @@ -239,20 +249,32 @@ static u32 l_texCoord[338] = { 0x3F800000, 0x00000000, }; +#if TARGET_PC +static u8* l_Egnd_mantDL_get() { static u8* p = (u8*)dusk::LoadRelAsset("/rel/Final/Release/d_a_mant.rel", 0xA9A0, 0x3EC); return p; } +#define l_Egnd_mantDL (l_Egnd_mantDL_get()) +#else #include "assets/l_Egnd_mantDL.h" +#endif +#if !TARGET_PC static void* pal_d = (void*)&l_Egnd_mantPAL; static void* tex_d[2] = { (void*)&l_Egnd_mantTEX, (void*)&l_Egnd_mantTEX_U, }; +#endif static char lbl_277_bss_0; void daMant_packet_c::draw() { +#if TARGET_PC + void* image = l_Egnd_mantTEX; + void* lut = l_Egnd_mantPAL; +#else void* image = tex_d[0]; void* lut = pal_d; +#endif j3dSys.reinitGX(); GXSetNumIndStages(0); diff --git a/src/d/actor/d_a_player.cpp b/src/d/actor/d_a_player.cpp index 43646380b3..d6f7c54a49 100644 --- a/src/d/actor/d_a_player.cpp +++ b/src/d/actor/d_a_player.cpp @@ -367,7 +367,13 @@ JKRHeap* daPy_anmHeap_c::setAnimeHeap() { } #if !PLATFORM_WII +#if TARGET_PC +#include "dusk/dvd_asset.hpp" +static const u8* l_sightDL_get() { static u8 buf[0x89]; static bool _ = (dusk::LoadDolAsset(buf, 0x803BA0C0, 0x89), true); return buf; } +#define l_sightDL (l_sightDL_get()) +#else #include "assets/l_sightDL__d_a_player.h" +#endif void daPy_sightPacket_c::draw() { TGXTexObj texObj; diff --git a/src/d/actor/d_flower.inc b/src/d/actor/d_flower.inc index 762b1e02e9..93a7e35097 100644 --- a/src/d/actor/d_flower.inc +++ b/src/d/actor/d_flower.inc @@ -13,7 +13,13 @@ const u16 l_J_Ohana00_64TEX__width = 63; const u16 l_J_Ohana00_64TEX__height = 63; #endif +#if TARGET_PC +#include "dusk/dvd_asset.hpp" +static u8* l_J_Ohana00_64TEX_get() { static u8 buf[0x800]; static bool _ = (dusk::LoadArchivedRelAsset(buf, 'AMEM', "d_a_grass.rel", 0x9060, 0x800), true); return buf; } +#define l_J_Ohana00_64TEX (l_J_Ohana00_64TEX_get()) +#else #include "assets/l_J_Ohana00_64TEX.h" +#endif static u8 l_flowerPos[708] = { 0xC0, 0x8C, 0x2C, 0xF7, 0x42, 0x05, 0xBC, 0xDF, 0xC1, 0xA1, 0x00, 0x70, 0xBF, 0x50, 0x51, 0xB9, @@ -104,6 +110,16 @@ static u8 l_flowerTexCoord[] = { 0x3E, 0xA7, 0x67, 0x4D, 0x3C, 0x14, 0x46, 0x74, 0x3E, 0xA7, 0x73, 0xE2, 0xBC, 0x2F, 0x46, 0xAA, 0x3E, 0xA7, 0x72, 0xD6, 0xBD, 0x2F, 0x46, 0xAA}; +#if TARGET_PC +static u8* l_J_hana00DL_get() { static u8 buf[0x150]; static bool _ = (dusk::LoadArchivedRelAsset(buf, 'AMEM', "d_a_grass.rel", 0x9D20, 0x150), true); return buf; } +static u8* l_J_hana00_cDL_get() { static u8 buf[0xDE]; static bool _ = (dusk::LoadArchivedRelAsset(buf, 'AMEM', "d_a_grass.rel", 0x9E80, 0xDE), true); return buf; } +static u8* l_matDL_get() { static u8 buf[0x99]; static bool _ = (dusk::LoadArchivedRelAsset(buf, 'AMEM', "d_a_grass.rel", 0x9F60, 0x99), true); return buf; } +static u8* l_matLight4DL_get() { static u8 buf[0x99]; static bool _ = (dusk::LoadArchivedRelAsset(buf, 'AMEM', "d_a_grass.rel", 0xA000, 0x99), true); return buf; } +#define l_J_hana00DL (l_J_hana00DL_get()) +#define l_J_hana00_cDL (l_J_hana00_cDL_get()) +#define l_matDL (l_matDL_get()) +#define l_matLight4DL (l_matLight4DL_get()) +#else #include "assets/l_J_hana00DL.h" #include "assets/l_J_hana00_cDL.h" @@ -113,6 +129,7 @@ l_matDL__d_a_grass(l_J_Ohana00_64TEX) #include "assets/l_matLight4DL.h" l_matLight4DL(l_J_Ohana00_64TEX) +#endif #if TARGET_PC const u16 l_J_Ohana01_64128_0419TEX__width = 64; @@ -122,7 +139,12 @@ const u16 l_J_Ohana01_64128_0419TEX__width = 63; const u16 l_J_Ohana01_64128_0419TEX__height = 127; #endif +#if TARGET_PC +static u8* l_J_Ohana01_64128_0419TEX_get() { static u8 buf[0x1000]; static bool _ = (dusk::LoadArchivedRelAsset(buf, 'AMEM', "d_a_grass.rel", 0xA0A0, 0x1000), true); return buf; } +#define l_J_Ohana01_64128_0419TEX (l_J_Ohana01_64128_0419TEX_get()) +#else #include "assets/l_J_Ohana01_64128_0419TEX.h" +#endif static u8 l_flowerPos2[1224] = { 0x40, 0x25, 0x9F, 0x34, 0x42, 0xC2, 0x95, 0x72, 0xC1, 0x22, 0x34, 0x78, 0x41, 0x4D, 0xF9, 0x63, @@ -249,6 +271,18 @@ static u8 l_flowerTexCoord2[] = { 0x40, 0x1B, 0x7D, 0x52, 0x3F, 0x97, 0xF6, 0xBA, 0x40, 0x04, 0x26, 0x74, 0x3F, 0x80, 0x3F, 0x79, 0x40, 0x1B, 0x7D, 0x52, 0x3F, 0x80, 0x3F, 0x79, 0x40, 0x1B, 0x7D, 0x52, 0x3F, 0x51, 0x10, 0x6F}; +#if TARGET_PC +static u8* l_J_hana01DL_get() { static u8 buf[0x138]; static bool _ = (dusk::LoadArchivedRelAsset(buf, 'AMEM', "d_a_grass.rel", 0xB7C0, 0x138), true); return buf; } +static u8* l_J_hana01_c_00DL_get() { static u8 buf[0xDE]; static bool _ = (dusk::LoadArchivedRelAsset(buf, 'AMEM', "d_a_grass.rel", 0xB900, 0xDE), true); return buf; } +static u8* l_J_hana01_c_01DL_get() { static u8 buf[0x128]; static bool _ = (dusk::LoadArchivedRelAsset(buf, 'AMEM', "d_a_grass.rel", 0xB9E0, 0x128), true); return buf; } +static u8* l_mat2DL_get() { static u8 buf[0x99]; static bool _ = (dusk::LoadArchivedRelAsset(buf, 'AMEM', "d_a_grass.rel", 0xBB20, 0x99), true); return buf; } +static u8* l_mat2Light4DL_get() { static u8 buf[0x99]; static bool _ = (dusk::LoadArchivedRelAsset(buf, 'AMEM', "d_a_grass.rel", 0xBBC0, 0x99), true); return buf; } +#define l_J_hana01DL (l_J_hana01DL_get()) +#define l_J_hana01_c_00DL (l_J_hana01_c_00DL_get()) +#define l_J_hana01_c_01DL (l_J_hana01_c_01DL_get()) +#define l_mat2DL (l_mat2DL_get()) +#define l_mat2Light4DL (l_mat2Light4DL_get()) +#else #include "assets/l_J_hana01DL.h" #include "assets/l_J_hana01_c_00DL.h" @@ -260,6 +294,7 @@ l_mat2DL__d_a_grass(l_J_Ohana01_64128_0419TEX) #include "assets/l_mat2Light4DL.h" l_mat2Light4DL(l_J_Ohana01_64128_0419TEX) +#endif void dFlower_data_c::WorkCo(fopAc_ac_c* i_hitActor, u32 i_massFlg, int i_roomNo) { cXyz sp8; diff --git a/src/d/actor/d_grass.inc b/src/d/actor/d_grass.inc index 6351cc75fc..3645488b0f 100644 --- a/src/d/actor/d_grass.inc +++ b/src/d/actor/d_grass.inc @@ -13,11 +13,19 @@ const u16 l_M_Hijiki00TEX__width = 31; const u16 l_M_Hijiki00TEX__height = 31; -#include "assets/l_M_kusa05_RGBATEX.h" // ALIGN 32 - const u16 l_M_kusa05_RGBATEX__width = 31; const u16 l_M_kusa05_RGBATEX__height = 31; -#include "assets/l_M_Hijiki00TEX.h" // ALIGN 32 + +#if TARGET_PC +#include "dusk/dvd_asset.hpp" +static u8* l_M_kusa05_RGBATEX_get() { static u8 buf[0x800]; static bool _ = (dusk::LoadArchivedRelAsset(buf, 'AMEM', "d_a_grass.rel", 0x7680, 0x800), true); return buf; } +static u8* l_M_Hijiki00TEX_get() { static u8 buf[0x800]; static bool _ = (dusk::LoadArchivedRelAsset(buf, 'AMEM', "d_a_grass.rel", 0x7E80, 0x800), true); return buf; } +#define l_M_kusa05_RGBATEX (l_M_kusa05_RGBATEX_get()) +#define l_M_Hijiki00TEX (l_M_Hijiki00TEX_get()) +#else +#include "assets/l_M_kusa05_RGBATEX.h" // ALIGN 32 +#include "assets/l_M_Hijiki00TEX.h" // ALIGN 32 +#endif static u8 l_pos[960] = { 0x3F, 0x4A, 0x56, 0xEF, 0xC2, 0x20, 0x00, 0x00, 0x41, 0xFB, 0x17, 0xE4, 0x41, 0xAA, 0xBB, 0xEA, @@ -102,6 +110,20 @@ static u8 l_texCoord[160] = { 0x3F, 0x94, 0x00, 0x00, 0x3F, 0x80, 0x00, 0x00, 0xBD, 0xC0, 0x00, 0x00, 0x3F, 0x80, 0x00, 0x00, }; +#if TARGET_PC +static u8* l_M_Kusa_9qDL_get() { static u8 buf[0xCB]; static bool _ = (dusk::LoadArchivedRelAsset(buf, 'AMEM', "d_a_grass.rel", 0x8B00, 0xCB), true); return buf; } +static u8* l_M_Kusa_9q_cDL_get() { static u8 buf[0xCB]; static bool _ = (dusk::LoadArchivedRelAsset(buf, 'AMEM', "d_a_grass.rel", 0x8BE0, 0xCB), true); return buf; } +static u8* l_M_TenGusaDL_get() { static u8 buf[0xD4]; static bool _ = (dusk::LoadArchivedRelAsset(buf, 'AMEM', "d_a_grass.rel", 0x8CC0, 0xD4), true); return buf; } +static u8* l_Tengusa_matDL_get() { static u8 buf[0xA8]; static bool _ = (dusk::LoadArchivedRelAsset(buf, 'AMEM', "d_a_grass.rel", 0x8DA0, 0xA8), true); return buf; } +static u8* l_kusa9q_matDL_get() { static u8 buf[0xA8]; static bool _ = (dusk::LoadArchivedRelAsset(buf, 'AMEM', "d_a_grass.rel", 0x8E60, 0xA8), true); return buf; } +static u8* l_kusa9q_l4_matDL_get() { static u8 buf[0xA8]; static bool _ = (dusk::LoadArchivedRelAsset(buf, 'AMEM', "d_a_grass.rel", 0x8F20, 0xA8), true); return buf; } +#define l_M_Kusa_9qDL (l_M_Kusa_9qDL_get()) +#define l_M_Kusa_9q_cDL (l_M_Kusa_9q_cDL_get()) +#define l_M_TenGusaDL (l_M_TenGusaDL_get()) +#define l_Tengusa_matDL (l_Tengusa_matDL_get()) +#define l_kusa9q_matDL (l_kusa9q_matDL_get()) +#define l_kusa9q_l4_matDL (l_kusa9q_l4_matDL_get()) +#else #include "assets/l_M_Kusa_9qDL.h" #include "assets/l_M_Kusa_9q_cDL.h" @@ -117,6 +139,7 @@ l_kusa9q_matDL(l_M_kusa05_RGBATEX) #include "assets/l_kusa9q_l4_matDL.h" l_kusa9q_l4_matDL(l_M_kusa05_RGBATEX) +#endif void dGrass_data_c::WorkCo(fopAc_ac_c* i_hitActor, u32 i_massFlg, int i_roomNo) { cXyz sp18; diff --git a/src/d/d_error_msg.cpp b/src/d/d_error_msg.cpp index faa40ae543..f1d63b5a1f 100644 --- a/src/d/d_error_msg.cpp +++ b/src/d/d_error_msg.cpp @@ -15,6 +15,22 @@ #include "m_Do/m_Do_Reset.h" #include "m_Do/m_Do_graphic.h" +#if TARGET_PC +#include "dusk/dvd_asset.hpp" +static const u8* black_tex_get() { static u8 buf[0x40]; static bool _ = (dusk::LoadDolAsset(buf, 0x8037B140, 0x40), true); return buf; } +static const u8* msg_data_get() { static u8 buf[0x260]; static bool _ = (dusk::LoadDolAsset(buf, 0x8037B180, 0x260), true); return buf; } +static const u8* font_data_get() { static u8 buf[0x12260]; static bool _ = (dusk::LoadDolAsset(buf, 0x8037B3E0, 0x12260), true); return buf; } +#define black_tex (black_tex_get()) +#define msg_data (msg_data_get()) +#define font_data (font_data_get()) +#if VERSION == VERSION_GCN_PAL +// TODO: find addreses for pal languages +#define msg_data_ge ((const u8*)nullptr) +#define msg_data_fr ((const u8*)nullptr) +#define msg_data_sp ((const u8*)nullptr) +#define msg_data_it ((const u8*)nullptr) +#endif +#else #include "assets/black_tex.h" #include "assets/msg_data.h" #if VERSION == VERSION_GCN_PAL @@ -24,6 +40,7 @@ #include "assets/msg_data_it.h" #endif #include "assets/font_data.h" +#endif #define MSG_READING_DISC 0 #define MSG_COVER_OPEN 1 diff --git a/src/dusk/dvd_asset.cpp b/src/dusk/dvd_asset.cpp new file mode 100644 index 0000000000..bfa30cc941 --- /dev/null +++ b/src/dusk/dvd_asset.cpp @@ -0,0 +1,106 @@ +#include "dusk/dvd_asset.hpp" +#include "dusk/logging.h" +#include "dusk/endian.h" +#include "aurora/dvd.h" +#include "DynamicLink.h" +#include "JSystem/JKernel/JKRArchive.h" +#include "JSystem/JKernel/JKRDvdRipper.h" + +#include + +namespace dusk { + +static const u8* s_dolData = nullptr; // pointer to dol data +static size_t s_dolSize = 0; +struct DolSection { u32 fileOffset, vaddr, size; }; +static DolSection s_dolSections[18]; // 7 text + 11 data +static int s_dolSectionCount = 0; + +static bool EnsureDolParsed() { + if (s_dolData) return true; + + s32 sz = 0; + const u8* p = aurora_dvd_get_dol(sz); + if (!p || sz < 256) { + DuskLog.fatal("dvd_asset: aurora_dvd_get_dol failed (size={})", sz); return false; + } + + s_dolData = p; + s_dolSize = sz; + + const BE(u32)* hdr = (const BE(u32)*)s_dolData; + s_dolSectionCount = 0; + + // 0x00: text file offsets 0x12: text vaddrs 0x24: text sizes + for (int i = 0; i < 7; i++) { + u32 off = hdr[0x00+i], addr = hdr[0x12+i], sz = hdr[0x24+i]; + if (sz > 0 && off > 0) { + s_dolSections[s_dolSectionCount++] = {off, addr, sz}; + } + } + // 0x07: data file offsets 0x19: data vaddrs 0x2B: data sizes + for (int i = 0; i < 11; i++) { + u32 off = hdr[0x07+i], addr = hdr[0x19+i], sz = hdr[0x2B+i]; + if (sz > 0 && off > 0) { + s_dolSections[s_dolSectionCount++] = {off, addr, sz}; + } + } + + return true; +} + +static s32 DolVaToFileOffset(u32 va) { + if (!EnsureDolParsed()) return -1; + for (int i = 0; i < s_dolSectionCount; i++) { + const auto& sec = s_dolSections[i]; + if (va >= sec.vaddr && va < sec.vaddr + sec.size) { + return static_cast(sec.fileOffset + (va - sec.vaddr)); + } + } + DuskLog.fatal("dvd_asset: VA 0x{:08X} not found in any DOL section", va); + return -1; +} + +bool LoadDolAsset(void* dst, u32 virtualAddress, s32 size) { + s32 fileOffset = DolVaToFileOffset(virtualAddress); + if (fileOffset < 0) { + return false; + } + + if (size <= 0 || (size_t)(fileOffset + size) > s_dolSize) { + DuskLog.fatal("dvd_asset: DOL read out of range (offset={:#x} size={:#x} dolSize={})", fileOffset, size, s_dolSize); + return false; + } + + std::memcpy(dst, s_dolData + fileOffset, size); + return true; +} + +void* LoadRelAsset(const char* dvdPath, s32 offset, s32 size) { + void* p = JKRDvdRipper::loadToMainRAM(dvdPath, nullptr, EXPAND_SWITCH_UNKNOWN1, (u32)size, nullptr, JKRDvdRipper::ALLOC_DIRECTION_FORWARD, (u32)offset, nullptr, nullptr); + if (!p) DuskLog.fatal("dvd_asset: failed to load {} (offset={:#x} size={:#x})", dvdPath, offset, size); + return p; +} + +bool LoadArchivedRelAsset(void* dst, u32 memType, const char* relFileName, s32 offset, s32 size) { + // On TARGET_PC, cDyl_InitCallback skips DynamicModuleControl::initialize() due to static linking + // Mount RELS.arc on first use so sArchive is available + static bool s_mountAttempted = false; + if (!DynamicModuleControl::sArchive && !s_mountAttempted) { + s_mountAttempted = true; DynamicModuleControl::initialize(); + } + + if (!DynamicModuleControl::sArchive) { + DuskLog.fatal("dvd_asset: RELS archive not mounted"); return false; + } + + const u8* rel = static_cast(DynamicModuleControl::sArchive->getResource(memType, relFileName)); + if (!rel) { + DuskLog.fatal("dvd_asset: {} not found in RELS archive", relFileName); return false; + } + + std::memcpy(dst, rel + offset, size); + return true; +} + +} // namespace dusk diff --git a/src/m_Do/m_Do_ext.cpp b/src/m_Do/m_Do_ext.cpp index d744d048ba..0593815b1d 100644 --- a/src/m_Do/m_Do_ext.cpp +++ b/src/m_Do/m_Do_ext.cpp @@ -2873,7 +2873,10 @@ void mDoExt_3DlineMat1_c::update(int param_0, f32 param_1, GXColor& param_2, u16 sp_38++; } } + +#if !TARGET_PC #include "assets/l_mat2DL__d_a_grass.h" +#endif void mDoExt_3DlineMat2_c::setMaterial() { j3dSys.reinitGX(); From 28cb1be2f5205849a7bf15243122dbda03e67a5f Mon Sep 17 00:00:00 2001 From: madeline Date: Mon, 6 Apr 2026 07:55:10 -0700 Subject: [PATCH 07/16] remove includes --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a9d283dfa..e50a0b8cbb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -100,7 +100,6 @@ set(GAME_COMPILE_DEFS TARGET_PC WIDESCREEN_SUPPORT=1 AVOID_UB=1 VERSION=0 set(GAME_INCLUDE_DIRS include src - assets/${DUSK_TP_VERSION} libs/JSystem/include libs extern/aurora/include/dolphin From c7caf8a5ad76e2ea0453b8b82a7b36af25489e73 Mon Sep 17 00:00:00 2001 From: madeline Date: Mon, 6 Apr 2026 07:57:00 -0700 Subject: [PATCH 08/16] walk that one on back --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index e50a0b8cbb..3a9d283dfa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -100,6 +100,7 @@ set(GAME_COMPILE_DEFS TARGET_PC WIDESCREEN_SUPPORT=1 AVOID_UB=1 VERSION=0 set(GAME_INCLUDE_DIRS include src + assets/${DUSK_TP_VERSION} libs/JSystem/include libs extern/aurora/include/dolphin From 4f1d0f19e05eccb824fd315114dadcdf67fb8ec9 Mon Sep 17 00:00:00 2001 From: madeline Date: Mon, 6 Apr 2026 08:49:24 -0700 Subject: [PATCH 09/16] address review --- include/dusk/dvd_asset.hpp | 4 ++-- src/d/actor/d_a_mant.cpp | 8 ++++---- src/d/actor/d_flower.inc | 10 +++++----- src/dusk/dvd_asset.cpp | 39 ++++++++++++++++++++++++++++---------- 4 files changed, 40 insertions(+), 21 deletions(-) diff --git a/include/dusk/dvd_asset.hpp b/include/dusk/dvd_asset.hpp index 3c36b75195..014c683d44 100644 --- a/include/dusk/dvd_asset.hpp +++ b/include/dusk/dvd_asset.hpp @@ -10,9 +10,9 @@ namespace dusk { bool LoadDolAsset(void* dst, u32 virtualAddress, s32 size); /** - * Load bytes from a REL file in the ISO filesystem + * Load bytes from a REL file in the ISO filesystem, dst must be 32-byte aligned */ -void* LoadRelAsset(const char* dvdPath, s32 offset, s32 size); +bool LoadRelAsset(void* dst, const char* dvdPath, s32 offset, s32 size); /** * Load bytes from a REL inside RELS.arc diff --git a/src/d/actor/d_a_mant.cpp b/src/d/actor/d_a_mant.cpp index 1760db60fa..bcd7f05986 100644 --- a/src/d/actor/d_a_mant.cpp +++ b/src/d/actor/d_a_mant.cpp @@ -12,9 +12,9 @@ #if TARGET_PC #include "dusk/dvd_asset.hpp" -static u8* l_Egnd_mantTEX_get() { static u8* p = (u8*)dusk::LoadRelAsset("/rel/Final/Release/d_a_mant.rel", 0x1C00, 0x4000); return p; } -static u8* l_Egnd_mantTEX_U_get() { static u8* p = (u8*)dusk::LoadRelAsset("/rel/Final/Release/d_a_mant.rel", 0x5C00, 0x4000); return p; } -static u8* l_Egnd_mantPAL_get() { static u8* p = (u8*)dusk::LoadRelAsset("/rel/Final/Release/d_a_mant.rel", 0x9C00, 0x60); return p; } +static u8* l_Egnd_mantTEX_get() { alignas(32) static u8 buf[0x4000]; static bool _ = (dusk::LoadRelAsset(buf, "/rel/Final/Release/d_a_mant.rel", 0x1C00, 0x4000), true); return buf; } +static u8* l_Egnd_mantTEX_U_get() { alignas(32) static u8 buf[0x4000]; static bool _ = (dusk::LoadRelAsset(buf, "/rel/Final/Release/d_a_mant.rel", 0x5C00, 0x4000), true); return buf; } +static u8* l_Egnd_mantPAL_get() { alignas(32) static u8 buf[0x60]; static bool _ = (dusk::LoadRelAsset(buf, "/rel/Final/Release/d_a_mant.rel", 0x9C00, 0x60), true); return buf; } #define l_Egnd_mantTEX (l_Egnd_mantTEX_get()) #define l_Egnd_mantTEX_U (l_Egnd_mantTEX_U_get()) #define l_Egnd_mantPAL (l_Egnd_mantPAL_get()) @@ -250,7 +250,7 @@ static u32 l_texCoord[338] = { }; #if TARGET_PC -static u8* l_Egnd_mantDL_get() { static u8* p = (u8*)dusk::LoadRelAsset("/rel/Final/Release/d_a_mant.rel", 0xA9A0, 0x3EC); return p; } +static u8* l_Egnd_mantDL_get() { alignas(32) static u8 buf[0x3EC]; static bool _ = (dusk::LoadRelAsset(buf, "/rel/Final/Release/d_a_mant.rel", 0xA9A0, 0x3EC), true); return buf; } #define l_Egnd_mantDL (l_Egnd_mantDL_get()) #else #include "assets/l_Egnd_mantDL.h" diff --git a/src/d/actor/d_flower.inc b/src/d/actor/d_flower.inc index 93a7e35097..de6ac7c1dc 100644 --- a/src/d/actor/d_flower.inc +++ b/src/d/actor/d_flower.inc @@ -619,9 +619,9 @@ void dFlower_packet_c::draw() { } if (sp4C <= 2) { - GXCallDisplayList(&l_matLight4DL, 0x80); + GXCallDisplayList(l_matLight4DL, 0x80); } else { - GXCallDisplayList(&l_matDL, 0x80); + GXCallDisplayList(l_matDL, 0x80); } GXSetTevColorS10(GX_TEVREG0, sp80); @@ -677,9 +677,9 @@ void dFlower_packet_c::draw() { #endif if (!cLib_checkBit(sp44->m_state, 8)) { - GXCallDisplayList(&l_J_hana00DL, 0x140); + GXCallDisplayList(l_J_hana00DL, 0x140); } else { - GXCallDisplayList(&l_J_hana00_cDL, 0xC0); + GXCallDisplayList(l_J_hana00_cDL, 0xC0); } } } @@ -826,7 +826,7 @@ void dFlower_packet_c::draw() { if (!cLib_checkBit(sp34->m_state, 0x10)) { GXCallDisplayList(mp_Jhana01DL, m_Jhana01DL_size); } else { - GXCallDisplayList(&l_J_hana01_c_00DL, 0xC0); + GXCallDisplayList(l_J_hana01_c_00DL, 0xC0); } } else { GXCallDisplayList(mp_Jhana01_cDL, m_Jhana01_cDL_size); diff --git a/src/dusk/dvd_asset.cpp b/src/dusk/dvd_asset.cpp index bfa30cc941..9bcea14077 100644 --- a/src/dusk/dvd_asset.cpp +++ b/src/dusk/dvd_asset.cpp @@ -12,7 +12,22 @@ namespace dusk { static const u8* s_dolData = nullptr; // pointer to dol data static size_t s_dolSize = 0; -struct DolSection { u32 fileOffset, vaddr, size; }; + +struct DolHeader { + BE(u32) textOffset[7]; + BE(u32) dataOffset[11]; + BE(u32) textAddr[7]; + BE(u32) dataAddr[11]; + BE(u32) textSize[7]; + BE(u32) dataSize[11]; +}; + +struct DolSection { + u32 fileOffset; + u32 vaddr; + u32 size; +}; + static DolSection s_dolSections[18]; // 7 text + 11 data static int s_dolSectionCount = 0; @@ -22,25 +37,29 @@ static bool EnsureDolParsed() { s32 sz = 0; const u8* p = aurora_dvd_get_dol(sz); if (!p || sz < 256) { - DuskLog.fatal("dvd_asset: aurora_dvd_get_dol failed (size={})", sz); return false; + DuskLog.fatal("dvd_asset: aurora_dvd_get_dol failed (size={})", sz); + return false; } s_dolData = p; s_dolSize = sz; - const BE(u32)* hdr = (const BE(u32)*)s_dolData; + const auto* hdr = (const DolHeader*)s_dolData; s_dolSectionCount = 0; - // 0x00: text file offsets 0x12: text vaddrs 0x24: text sizes for (int i = 0; i < 7; i++) { - u32 off = hdr[0x00+i], addr = hdr[0x12+i], sz = hdr[0x24+i]; + u32 off = hdr->textOffset[i]; + u32 addr = hdr->textAddr[i]; + u32 sz = hdr->textSize[i]; if (sz > 0 && off > 0) { s_dolSections[s_dolSectionCount++] = {off, addr, sz}; } } - // 0x07: data file offsets 0x19: data vaddrs 0x2B: data sizes + for (int i = 0; i < 11; i++) { - u32 off = hdr[0x07+i], addr = hdr[0x19+i], sz = hdr[0x2B+i]; + u32 off = hdr->dataOffset[i]; + u32 addr = hdr->dataAddr[i]; + u32 sz = hdr->dataSize[i]; if (sz > 0 && off > 0) { s_dolSections[s_dolSectionCount++] = {off, addr, sz}; } @@ -76,10 +95,10 @@ bool LoadDolAsset(void* dst, u32 virtualAddress, s32 size) { return true; } -void* LoadRelAsset(const char* dvdPath, s32 offset, s32 size) { - void* p = JKRDvdRipper::loadToMainRAM(dvdPath, nullptr, EXPAND_SWITCH_UNKNOWN1, (u32)size, nullptr, JKRDvdRipper::ALLOC_DIRECTION_FORWARD, (u32)offset, nullptr, nullptr); +bool LoadRelAsset(void* dst, const char* dvdPath, s32 offset, s32 size) { + void* p = JKRDvdRipper::loadToMainRAM(dvdPath, (u8*)dst, EXPAND_SWITCH_UNKNOWN1, (u32)size, nullptr, JKRDvdRipper::ALLOC_DIRECTION_FORWARD, (u32)offset, nullptr, nullptr); if (!p) DuskLog.fatal("dvd_asset: failed to load {} (offset={:#x} size={:#x})", dvdPath, offset, size); - return p; + return p != nullptr; } bool LoadArchivedRelAsset(void* dst, u32 memType, const char* relFileName, s32 offset, s32 size) { From 530aa48a8f0fb1ab0d721a03d1b3074adfb6269f Mon Sep 17 00:00:00 2001 From: madeline Date: Mon, 6 Apr 2026 08:58:52 -0700 Subject: [PATCH 10/16] update include directories --- CMakeLists.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a9d283dfa..164d5aa893 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,9 +104,7 @@ set(GAME_INCLUDE_DIRS libs/JSystem/include libs extern/aurora/include/dolphin - extern - ${CMAKE_SOURCE_DIR}/build/${DUSK_TP_VERSION}/include - build/${DUSK_TP_VERSION}/include) + extern) set(GAME_LIBS aurora::core aurora::gx aurora::gd aurora::si aurora::vi aurora::pad aurora::mtx aurora::os aurora::dvd aurora::card freeverb cxxopts::cxxopts absl::flat_hash_map nlohmann_json::nlohmann_json) From 6a537ab90d13b3f81c1f380415af383716a9de14 Mon Sep 17 00:00:00 2001 From: madeline Date: Mon, 6 Apr 2026 20:52:38 -0700 Subject: [PATCH 11/16] use the new thing in aurora --- src/dusk/dvd_asset.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/dusk/dvd_asset.cpp b/src/dusk/dvd_asset.cpp index 9bcea14077..3aa25be94b 100644 --- a/src/dusk/dvd_asset.cpp +++ b/src/dusk/dvd_asset.cpp @@ -1,7 +1,7 @@ #include "dusk/dvd_asset.hpp" #include "dusk/logging.h" #include "dusk/endian.h" -#include "aurora/dvd.h" +#include "dolphin/dvd.h" #include "DynamicLink.h" #include "JSystem/JKernel/JKRArchive.h" #include "JSystem/JKernel/JKRDvdRipper.h" @@ -35,9 +35,9 @@ static bool EnsureDolParsed() { if (s_dolData) return true; s32 sz = 0; - const u8* p = aurora_dvd_get_dol(sz); + const u8* p = DVDGetDOLLocation(sz); if (!p || sz < 256) { - DuskLog.fatal("dvd_asset: aurora_dvd_get_dol failed (size={})", sz); + DuskLog.fatal("dvd_asset: DVDGetDOLLocation failed (size={})", sz); return false; } From aa3b16323046201dcf6d31e2a418fe2cac4be623 Mon Sep 17 00:00:00 2001 From: madeline Date: Mon, 6 Apr 2026 21:06:04 -0700 Subject: [PATCH 12/16] use updated aurora signature --- src/dusk/dvd_asset.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dusk/dvd_asset.cpp b/src/dusk/dvd_asset.cpp index 3aa25be94b..b9e0729be9 100644 --- a/src/dusk/dvd_asset.cpp +++ b/src/dusk/dvd_asset.cpp @@ -35,7 +35,7 @@ static bool EnsureDolParsed() { if (s_dolData) return true; s32 sz = 0; - const u8* p = DVDGetDOLLocation(sz); + const u8* p = DVDGetDOLLocation(&sz); if (!p || sz < 256) { DuskLog.fatal("dvd_asset: DVDGetDOLLocation failed (size={})", sz); return false; From e7254fc7929828017461748523906186301f90ef Mon Sep 17 00:00:00 2001 From: madeline Date: Mon, 6 Apr 2026 21:31:29 -0700 Subject: [PATCH 13/16] update readme --- README.md | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 200913770a..59f12abc2a 100644 --- a/README.md +++ b/README.md @@ -37,25 +37,24 @@ sudo dnf groupinstall "Development Tools" "Development Libraries" ``` #### Setup -1. Clone and initialize the Dusk repository +Clone and initialize the Dusk repository ```sh git clone --recursive https://github.com/TakaRikka/dusk.git cd dusk git pull git submodule update --recursive ``` -2. Generate assets -```sh -cp /path/to/GZ2E01.iso orig/GZ2E01/. -python3 ./configure.py -ninja -``` #### Building **Visual Studio (Recommended for Windows)** ```sh cmake -B build/dusk -G "Visual Studio 17 2022" -A x64 # Win32 for 32bit ``` + +**Visual Studio Code with ninja** + +Project has support for the CMakeTools extension with variants and has a debug launch target + **ninja (Windows/macOS/Linux)** ```sh cmake -B build/dusk -GNinja From 1ec2357b7df2fc261a4507a5016c85748282ed40 Mon Sep 17 00:00:00 2001 From: madeline Date: Mon, 6 Apr 2026 21:51:40 -0700 Subject: [PATCH 14/16] disable all drawing in d_error_msg and remove need for assets --- src/d/d_error_msg.cpp | 32 +++++++------------------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/src/d/d_error_msg.cpp b/src/d/d_error_msg.cpp index f1d63b5a1f..efd2512c11 100644 --- a/src/d/d_error_msg.cpp +++ b/src/d/d_error_msg.cpp @@ -15,22 +15,7 @@ #include "m_Do/m_Do_Reset.h" #include "m_Do/m_Do_graphic.h" -#if TARGET_PC -#include "dusk/dvd_asset.hpp" -static const u8* black_tex_get() { static u8 buf[0x40]; static bool _ = (dusk::LoadDolAsset(buf, 0x8037B140, 0x40), true); return buf; } -static const u8* msg_data_get() { static u8 buf[0x260]; static bool _ = (dusk::LoadDolAsset(buf, 0x8037B180, 0x260), true); return buf; } -static const u8* font_data_get() { static u8 buf[0x12260]; static bool _ = (dusk::LoadDolAsset(buf, 0x8037B3E0, 0x12260), true); return buf; } -#define black_tex (black_tex_get()) -#define msg_data (msg_data_get()) -#define font_data (font_data_get()) -#if VERSION == VERSION_GCN_PAL -// TODO: find addreses for pal languages -#define msg_data_ge ((const u8*)nullptr) -#define msg_data_fr ((const u8*)nullptr) -#define msg_data_sp ((const u8*)nullptr) -#define msg_data_it ((const u8*)nullptr) -#endif -#else +#if !TARGET_PC #include "assets/black_tex.h" #include "assets/msg_data.h" #if VERSION == VERSION_GCN_PAL @@ -66,6 +51,7 @@ struct BMG_INF1 : JUTDataBlockHeader { #endif static void messageSet(u32 status, bool i_drawBg) { + #if !TARGET_PC BMG_INF1* inf1; const char* msg_p; @@ -194,9 +180,11 @@ static void messageSet(u32 status, bool i_drawBg) { tpane.draw(x, y + 10.0f, FB_WIDTH, HBIND_LEFT); #endif #endif + #endif } void dDvdErrorMsg_c::draw(s32 status) { + #if !TARGET_PC JUtility::TColor backColor = g_clearColor; JFWDisplay::getManager()->setClearColor(backColor); mDoGph_gInf_c::beginRender(); @@ -224,6 +212,7 @@ void dDvdErrorMsg_c::draw(s32 status) { mDoGph_gInf_c::endRender(); JFWDisplay::getManager()->resetFader(); + #endif } bool dDvdErrorMsg_c::execute() { @@ -254,16 +243,12 @@ bool dDvdErrorMsg_c::execute() { static u8 l_captureAlpha = 0xFF; static void drawCapture(u8 alpha) { + #if !TARGET_PC static bool l_texCopied = false; if (!l_texCopied) { -#if TARGET_PC - GXSetTexCopySrc(0, 0, mDoGph_gInf_c::getWidth(), mDoGph_gInf_c::getHeight()); - GXSetTexCopyDst(mDoGph_gInf_c::getWidth(), mDoGph_gInf_c::getHeight(), (GXTexFmt)mDoGph_gInf_c::getFrameBufferTimg()->format, GX_TRUE); -#else GXSetTexCopySrc(0, 0, FB_WIDTH, FB_HEIGHT); GXSetTexCopyDst(FB_WIDTH / 2, FB_HEIGHT / 2, (GXTexFmt)mDoGph_gInf_c::getFrameBufferTimg()->format, GX_TRUE); -#endif GXCopyTex(mDoGph_gInf_c::getFrameBufferTex(), GX_FALSE); l_texCopied = true; } @@ -273,9 +258,6 @@ static void drawCapture(u8 alpha) { GXSetAlphaUpdate(GX_FALSE); j3dSys.drawInit(); -#ifdef TARGET_PC - mDoGph_gInf_c::getFrameBufferTexObj()->reset(); -#endif GXInitTexObj(mDoGph_gInf_c::getFrameBufferTexObj(), mDoGph_gInf_c::getFrameBufferTex(), FB_WIDTH / 2, FB_HEIGHT / 2, (GXTexFmt)mDoGph_gInf_c::getFrameBufferTimg()->format, GX_CLAMP, GX_CLAMP, GX_FALSE); GXInitTexObjLOD(mDoGph_gInf_c::getFrameBufferTexObj(), GX_LINEAR, GX_LINEAR, 0.0f, 0.0f, 0.0f, GX_FALSE, GX_FALSE, GX_ANISO_1); GXLoadTexObj(mDoGph_gInf_c::getFrameBufferTexObj(), GX_TEXMAP0); @@ -315,6 +297,7 @@ static void drawCapture(u8 alpha) { mDoGph_drawFilterQuad(1, 1); mDoGph_gInf_c::endRender(); JFWDisplay::getManager()->resetFader(); + #endif } bool dShutdownErrorMsg_c::execute() { @@ -342,6 +325,5 @@ bool dShutdownErrorMsg_c::execute() { mDoRst_reset(1, 1, 1); } } - return true; } From fd244d268c103cdf7f87357499db8a2d0461d928 Mon Sep 17 00:00:00 2001 From: madeline Date: Mon, 6 Apr 2026 23:20:58 -0700 Subject: [PATCH 15/16] adjust dol sightDL address based on version --- src/d/actor/d_a_player.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/d/actor/d_a_player.cpp b/src/d/actor/d_a_player.cpp index d6f7c54a49..f56a8399cd 100644 --- a/src/d/actor/d_a_player.cpp +++ b/src/d/actor/d_a_player.cpp @@ -369,7 +369,24 @@ JKRHeap* daPy_anmHeap_c::setAnimeHeap() { #if !PLATFORM_WII #if TARGET_PC #include "dusk/dvd_asset.hpp" -static const u8* l_sightDL_get() { static u8 buf[0x89]; static bool _ = (dusk::LoadDolAsset(buf, 0x803BA0C0, 0x89), true); return buf; } +static const u8* l_sightDL_get() { + static u8 buf[0x89]; + static bool _ = ( + dusk::LoadDolAsset( + buf, + #if VERSION_GCN_PAL + 0x803BBDA0, + #elif VERSION_GCN_JPN + 0x803B4220, + #elif VERSION_GCN_USA + 0x803BA0C0, + #endif + 0x89 + ), + true + ); + return buf; +} #define l_sightDL (l_sightDL_get()) #else #include "assets/l_sightDL__d_a_player.h" From 6063b366086f16dc00b3a93b1c2c151ee9556db7 Mon Sep 17 00:00:00 2001 From: madeline Date: Mon, 6 Apr 2026 23:21:29 -0700 Subject: [PATCH 16/16] correctly this time --- src/d/actor/d_a_player.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/d/actor/d_a_player.cpp b/src/d/actor/d_a_player.cpp index f56a8399cd..4c8b31c4c6 100644 --- a/src/d/actor/d_a_player.cpp +++ b/src/d/actor/d_a_player.cpp @@ -374,11 +374,11 @@ static const u8* l_sightDL_get() { static bool _ = ( dusk::LoadDolAsset( buf, - #if VERSION_GCN_PAL + #if VERSION == VERSION_GCN_PAL 0x803BBDA0, - #elif VERSION_GCN_JPN + #elif VERSION == VERSION_GCN_JPN 0x803B4220, - #elif VERSION_GCN_USA + #elif VERSION == VERSION_GCN_USA 0x803BA0C0, #endif 0x89