From 1d2def27177f02e3a3dd66b731a80f595d34b2ee Mon Sep 17 00:00:00 2001 From: Cuyler36 Date: Mon, 22 May 2023 06:15:38 -0400 Subject: [PATCH 1/2] Match & link dvderr.c --- common.py | 12 ++++- config/analysis_overrides.yml | 1 + config/assets.yml | 78 ++++++++++++++++++++++++++++++ config/disasm_overrides.yml | 1 + config/dol_slices.yml | 5 ++ configure.py | 32 +++++++++--- include/dolphin/gx.h | 4 +- include/dvderr.h | 33 +++++++++++-- include/libforest/gbi_extensions.h | 10 ++-- include/libultra/libultra.h | 1 + include/types.h | 2 + rel/m_fbdemo_wipe1.c | 4 +- src/boot.c | 2 +- src/libforest/fault.c | 6 ++- 14 files changed, 170 insertions(+), 21 deletions(-) diff --git a/common.py b/common.py index 0cb7f39c..7cc2744c 100644 --- a/common.py +++ b/common.py @@ -224,6 +224,9 @@ AS = os.path.join(DEVKITPPC, "bin", "powerpc-eabi-as") OBJDUMP = os.path.join(DEVKITPPC, "bin", "powerpc-eabi-objdump") CPP = os.path.join(DEVKITPPC, "bin", "powerpc-eabi-cpp") +# Asset Converters +VTXDIS = f"{PYTHON} {TOOLS}/converters/vtxdis.py" + ICONV = f"{PYTHON} tools/sjis.py" # TODO: get actual iconv working(?) # N64 SDK path for GBI @@ -336,6 +339,12 @@ BOOT_CFLAGS = CFLAGS + [ "-sdata 0", "-sdata2 0" ] + DOL_DEFINES +DVDERR_CFLAGS = CFLAGS + [ + "-inline on", + "-sdata 0", + "-sdata2 0", + "-pool off" +] + DOL_DEFINES BASE_REL_CFLAGS = CFLAGS + [ "-sdata 0", f"-sdata2 {REL_SDATA2_SIZE}", @@ -384,7 +393,8 @@ JSYSTEM_BASE = [ JSYSTEM_CFLAGS = ' '.join(JSYSTEM_BASE + LOCAL_CFLAGS) DOL_CFLAGS = ' '.join(BASE_DOL_CFLAGS + LOCAL_CFLAGS) -DOL_BOOT_CFLAGS = ' '.join(BOOT_CFLAGS + LOCAL_CFLAGS); # TODO: this uses C++ but there's some issues with ppcdis, real flags: ' '.join(CPLFLAGS + BOOT_CFLAGS + LOCAL_CFLAGS); +DOL_BOOT_CFLAGS = ' '.join(BOOT_CFLAGS + LOCAL_CFLAGS) # TODO: this uses C++ but there's some issues with ppcdis, real flags: ' '.join(CPLFLAGS + BOOT_CFLAGS + LOCAL_CFLAGS); +DOL_DVDERR_CFLAGS = ' '.join(DVDERR_CFLAGS + LOCAL_CFLAGS) SDK_FLAGS = ' '.join(SDK_CFLAG + LOCAL_CFLAGS) ALIGN16 = ' '.join(BASE_DOL_CFLAGS + LOCAL_CFLAGS + ALIGN16_CFLAG) DOL_CPPFLAGS = ' '.join(CPLFLAGS + BASE_DOL_CFLAGS + LOCAL_CFLAGS) diff --git a/config/analysis_overrides.yml b/config/analysis_overrides.yml index 3d09e5dc..13bf633d 100644 --- a/config/analysis_overrides.yml +++ b/config/analysis_overrides.yml @@ -3,6 +3,7 @@ blocked_pointers: - 0x800A8514 blocked_targets: - 0x800A97E0 # boot.c local static const tbl, also start of .rodata + - 0x80008000 forced_types: 0x80003534: FUNCTION 0x80005468: FUNCTION diff --git a/config/assets.yml b/config/assets.yml index 4d01fead..8970727e 100644 --- a/config/assets.yml +++ b/config/assets.yml @@ -3,10 +3,88 @@ config/dol.yml: addrs: [0x800b05e8, 0x800b05f4] __DateTime__: addrs: [0x800b05f4, 0x800b0608] + # dvderr.c + dvd_keikoku_moji1_1_tex: + addrs: [0x800b0a60, 0x800b0f60] + dvd_keikoku_moji1_2_tex: + addrs: [0x800b0f60, 0x800b1460] + dvd_keikoku_moji1_3_tex: + addrs: [0x800b1460, 0x800b1660] + dvd_keikoku_moji1_4_tex: + addrs: [0x800b1660, 0x800b1c60] + ctl_att_w1_tex: + addrs: [0x800b1c60, 0x800b2060] + ctl_att_w2_tex: + addrs: [0x800b2060, 0x800b2460] + ctl_att_w3_tex: + addrs: [0x800b2460, 0x800b2860] + ctl_att_w4_tex: + addrs: [0x800b2860, 0x800b2c60] + ctl_att_w5_tex: + addrs: [0x800b2c60, 0x800b3060] + ctl_att_w6_tex: + addrs: [0x800b3060, 0x800b30e0] + dvd_keikoku1_v: + addrs: [0x800b30e0, 0x800b34a0] + type: "vtx" + dvd_keikoku_moji2_tex: + addrs: [0x800b3640, 0x800b38c0] + dvd_keikoku_moji2_2_tex: + addrs: [0x800b38c0, 0x800b3ec0] + dvd_keikoku_moji2_3_tex: + addrs: [0x800b3ec0, 0x800b3f40] + dvd_keikoku2_v: + addrs: [0x800b3f40, 0x800b42c0] + type: "vtx" + dvd_keikoku_moji4_tex: + addrs: [0x800b4440, 0x800b46c0] + dvd_keikoku_moji3_1_tex: + addrs: [0x800b46c0, 0x800b4cc0] + dvd_keikoku_moji3_2_tex: + addrs: [0x800b4cc0, 0x800b4f40] + dvd_keikoku_moji3_3_tex: + addrs: [0x800b4f40, 0x800b4fc0] + dvd_keikoku3_v: + addrs: [0x800b4fc0, 0x800b5400] + type: "vtx" + dvd_keikoku_moji5_tex: + addrs: [0x800b55a0, 0x800b58a0] + dvd_keikoku_moji6_2_tex: + addrs: [0x800b58a0, 0x800b5d20] + dvd_keikoku_moji6_3_tex: + addrs: [0x800b5d20, 0x800b5fa0] + dvd_keikoku_moji6_tex: + addrs: [0x800b5fa0, 0x800b63a0] + dvd_keikoku_moji6_1_tex: + addrs: [0x800b63a0, 0x800b6920] + dvd_keikoku_moji6_new1_tex: + addrs: [0x800b6920, 0x800b6b20] + dvd_keikoku_moji6_new2_tex: + addrs: [0x800b6b20, 0x800b6d20] + dvd_keikoku4_v: + addrs: [0x800b6d20, 0x800b71a0] + type: "vtx" + dvd_keikoku_moji7_tex: + addrs: [0x800b7380, 0x800b7880] + dvd_keikoku_moji8_tex: + addrs: [0x800b7880, 0x800b7c80] + dvd_keikoku_moji10_tex: + addrs: [0x800b7c80, 0x800b7e80] + dvd_keikoku_moji11_tex: + addrs: [0x800b7e80, 0x800b8300] + dvd_keikoku_moji12_tex: + addrs: [0x800b8300, 0x800b8580] + dvd_keikoku_moji9_tex: + addrs: [0x800b8580, 0x800b8a80] + dvd_keikoku5_v: + addrs: [0x800b8a80, 0x800b8ec0] + type: "vtx" + nintendo_hi_0: addrs: [0x800c3140, 0x800cca40] config/rel.yml: wipe1_v: addrs: [0x80652AD0, 0x80652C60] + type: "vtx" g_wipe1_txt: addrs: [0x80652C60, 0x80653460] diff --git a/config/disasm_overrides.yml b/config/disasm_overrides.yml index 78dd3143..976ca27e 100644 --- a/config/disasm_overrides.yml +++ b/config/disasm_overrides.yml @@ -2,3 +2,4 @@ trim_ctors: true symbol_aligns: 0x80207458: 8 # align RunQueue to 0x001251d8 + 0x800b9140: 32 # align gam_win_moji1_tex to 32 bytes diff --git a/config/dol_slices.yml b/config/dol_slices.yml index 33737b2e..80666331 100644 --- a/config/dol_slices.yml +++ b/config/dol_slices.yml @@ -16,6 +16,11 @@ boot.c: .bss: [0x800e2280, 0x800e2318] version.c: .data: [0x800b05e8, 0x800b0608] +dvderr.c: + .text: [0x80007e58, 0x800083f8] + .rodata: [0x800a97f8, 0x800a9838] + .data: [0x800b0a60, 0x800b9140] + .bss: [0x800e2790, 0x800e2b88] jaudio_NES/dummyprobe.c: .text: [0x800083f8, 0x80008400] #jaudio_NES/verysimple.c: diff --git a/configure.py b/configure.py index 0385a56b..905b524c 100644 --- a/configure.py +++ b/configure.py @@ -92,6 +92,7 @@ n.variable("as", c.AS) n.variable("cpp", c.CPP) n.variable("iconv", c.ICONV) n.variable("forcefilesgen", c.FORCEFILESGEN) +n.variable("vtxdis", c.VTXDIS) n.newline() ############## @@ -257,6 +258,12 @@ n.rule( description = "LCF FORCEFILES generation $in" ) +n.rule( + "vtxdis", + command = "$vtxdis $in $out", + description = "vtxdis.py $in $out" +) + ########## # Assets # ########## @@ -265,12 +272,13 @@ n.rule( class Asset: binary: str path: str + convtype: str start: int end: int def load(yml_path: str): return { - asset : Asset(binary, asset, *adat["addrs"]) + asset : Asset(binary, asset, adat.get("type", "u8"), *adat["addrs"]) for binary, bdat in c.load_from_yaml(yml_path).items() for asset, adat in bdat.items() } @@ -496,11 +504,19 @@ class AssetInclude(GeneratedInclude): "addrs" : f"{inc.asset.start:x} {inc.asset.end:x}" } ) - n.build( - inc.path, - rule="assetinc", - inputs=inc.asset_path - ) + + if inc.asset.convtype == "vtx": + n.build( + inc.path, + rule="vtxdis", + inputs=inc.asset_path + ) + else: + n.build( + inc.path, + rule="assetinc", + inputs=inc.asset_path + ) def __repr__(self): return f"AssetInclude({self.asset})" @@ -619,6 +635,10 @@ class CSource(Source): self.cflags = c.DOL_BOOT_CFLAGS self.cc = c.CC self.frank = False + elif path == "src/dvderr.c": + self.cflags = c.DOL_DVDERR_CFLAGS + self.cc = c.CC + self.frank = False elif path.startswith("src/jaudio_NES"): self.cc = c.CC self.cflags = c.DOL_CPPFLAGS diff --git a/include/dolphin/gx.h b/include/dolphin/gx.h index 6b9feaba..02157995 100644 --- a/include/dolphin/gx.h +++ b/include/dolphin/gx.h @@ -7,7 +7,9 @@ extern "C" { #endif - +#define GX_CLAMP 0 +#define GX_REPEAT 1 +#define GX_MIRROR 2 #ifdef __cplusplus } diff --git a/include/dvderr.h b/include/dvderr.h index 733aede1..c3ced699 100644 --- a/include/dvderr.h +++ b/include/dvderr.h @@ -1,15 +1,42 @@ #ifndef DVDERR_H #define DVDERR_H -/* dvderr lives in dol, so dvderr.c is at src/dvderr.c */ - #include "types.h" +#include "PR/mbi.h" #ifdef __cplusplus extern "C" { #endif -extern BOOL dvderr_draw(); +enum dvderr_state { + DVDERR_NONE = -1, + + DVDERR_COVER_OPEN = 0, + DVDERR_NO_DISK, + DVDERR_WRONG_DISK, + DVDERR_RETRY, + DVDERR_FATAL, + + DVDERR_NUM +}; + +typedef void (*DVDERR_DRAW_PROC)(); + +/* sizeof(dvderr_work) == 0x3F8 */ +typedef struct dvderr_work_s { + /* 0x000 */ Gfx gfx[100]; // display list buffer + /* 0x320 */ Gfx* gfx_p; // current display list buffer write pointer + /* 0x328 */ Mtx ortho; // orthographic matrix + /* 0x368 */ Mtx projection; // projection matrix + /* 0x3A8 */ Mtx modelview; // modelview matrix + /* 0x3E8 */ f32 scale; // scale for modelview matrix + + /* 0x3EC */ DVDERR_DRAW_PROC draw_proc; // current draw routine + /* 0x3F0 */ int now_error; // current dvd error + /* 0x3F4 */ int next_error; // next dvd error +} dvderr_work; + +extern int dvderr_draw(); extern void dvderr_init(); #ifdef __cplusplus diff --git a/include/libforest/gbi_extensions.h b/include/libforest/gbi_extensions.h index 996e5376..7f38f95f 100644 --- a/include/libforest/gbi_extensions.h +++ b/include/libforest/gbi_extensions.h @@ -447,7 +447,7 @@ do { \ #define gsDPSetTextureImage_Dolphin(fmt, siz, h, w, img) \ {{ \ _SHIFTL(G_SETTIMG, 24, 8) | _SHIFTL(fmt, 21, 3) | _SHIFTL(siz, 19, 2) | _SHIFTL(1, 18, 1) | \ - _SHIFTL((h/4)-1, 10, 8) | _SHIFTL((w-1), 0, 10), img \ + _SHIFTL((h/4)-1, 10, 8) | _SHIFTL((w-1), 0, 10), (unsigned int)img \ }} #define gsDPSetTile_Dolphin(d_fmt, tile, tlut_name, wrap_s, wrap_t, shift_s, shift_t) \ @@ -531,14 +531,14 @@ do { \ #define gsSPNTriangles_5b(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) \ {{ \ - (unsigned long long)((gsSPNTriangleData1(v9, v10, v11) << 49) | (gsSPNTriangleData1(v6, v7, v8) << 34) | \ - (gsSPNTriangleData1(v3, v4, v5) << 19) | (gsSPNTriangleData1(v0, v1, v2) << 4)) | G_VTX_MODE_5bit \ + _SHIFTL(gsSPNTriangleData1(v9, v10, v11, 0), 17, 15) | _SHIFTL(gsSPNTriangleData1(v6, v7, v8, 0), 2, 15) | _SHIFTL(_SHIFTR(gsSPNTriangleData1(v3, v4, v5, 0), 13, 2), 0, 2), \ + _SHIFTL(gsSPNTriangleData1(v3, v4, v5, 0), 19, 13) | _SHIFTL(gsSPNTriangleData1(v0, v1, v2, 0), 4, 15) | _SHIFTL(G_VTX_MODE_5bit, 0, 1) \ }} #define gsSPNTrianglesInit_5b(n, v0, v1, v2, v3, v4, v5, v6, v7, v8) \ {{ \ - _SHIFTL(G_TRIN_INDEPEND, 24, 8) | _SHIFTL(n-1, 17, 7) | _SHIFTL(gsSPNTriangleData1(v6, v7, v8, 0), 2, 15) | _SHIFTL(_SHIFTR(gsSPNTriangleData1(v3, v4, v5, 0), 2, 13), 0, 2), \ - _SHIFTL(gsSPNTriangleData1(v3, v4, v5, 0), 19, 13) | _SHIFTL(gsSPNTriangleData1(v0, v1, v2, 0), 4, 15) | _SHIFTL(G_VTX_MODE_5bit, 0, 1) \ + _SHIFTL(G_TRIN_INDEPEND, 24, 8) | _SHIFTL(n-1, 17, 7) | _SHIFTL(gsSPNTriangleData1(v6, v7, v8, 0), 2, 15) | _SHIFTL(_SHIFTR(gsSPNTriangleData1(v3, v4, v5, 0), 13, 2), 0, 2), \ + _SHIFTL(gsSPNTriangleData1(v3, v4, v5, 0), 19, 13) | _SHIFTL(gsSPNTriangleData1(v0, v1, v2, 0), 4, 15) | _SHIFTL(G_VTX_MODE_5bit, 0, 1) \ }} #define gsSPNTriangles_7b(v0, v1, v2, v3, v4, v5, v6, v7, v8) \ diff --git a/include/libultra/libultra.h b/include/libultra/libultra.h index 47b42766..a6e1d8d5 100644 --- a/include/libultra/libultra.h +++ b/include/libultra/libultra.h @@ -4,6 +4,7 @@ #include "types.h" #include "dolphin/os/OSTime.h" #include "dolphin/os/OSCache.h" +#include "libultra/gu.h" #define N64_SCREEN_HEIGHT 240 #define N64_SCREEN_WIDTH 320 diff --git a/include/types.h b/include/types.h index 5ad9ed84..48bafdc7 100644 --- a/include/types.h +++ b/include/types.h @@ -62,4 +62,6 @@ typedef u32 unknown; /* Fully opaque, 5 bits per color channel */ (0x8000 | ((((argb8) >> 16) & 0xF8) << 7) | ((((argb8) >> 8) & 0xF8) << 2) | (((argb8) & 0xFF) >> 3)) : \ /* 3 bits of transparency, 4 bits per color channel */ (((((argb8) >> 24) & 0xE0) << 7) | ((((argb8) >> 16) & 0xF0) << 4) | (((argb8) >> 8) & 0xF0) | (((argb8) & 0xF0) >> 4)))) +#define GPACK_RGB5A3(r, g, b, a) ARGB8_to_RGB5A3((((a) & 0xFF) << 24) | (((r) & 0xFF) << 16) | (((g) & 0xFF) << 8) | ((b) & 0xFF)) + #endif \ No newline at end of file diff --git a/rel/m_fbdemo_wipe1.c b/rel/m_fbdemo_wipe1.c index abfe41a4..1ab4062f 100644 --- a/rel/m_fbdemo_wipe1.c +++ b/rel/m_fbdemo_wipe1.c @@ -5,7 +5,7 @@ #include "m_rcp.h" -u8 wipe1_v[] = { +Vtx wipe1_v[] = { #include "assets/wipe1_v.inc" }; @@ -26,7 +26,7 @@ Gfx wipe1_modelT[] = { gsDPSetTextureLUT(G_TT_NONE), gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON), gsSPDisplayList(0x08000000), - gsSPVertex(wipe1_v, 25, 0), + gsSPVertex(&wipe1_v[0], 25, 0), gsSP2Triangles(0, 1, 2, 0, 1, 3, 4, 0), gsSP2Triangles(5, 6, 7, 0, 6, 8, 9, 0), gsSP2Triangles(8, 10, 11, 0, 10, 12, 13, 0), diff --git a/src/boot.c b/src/boot.c index a93df866..d0414e93 100644 --- a/src/boot.c +++ b/src/boot.c @@ -666,4 +666,4 @@ int main(int argc, const char** argv) { OSReport("どうぶつの森ブートローダ終了\n"); /* Animal Crossing bootloader end */ JW_Cleanup(); return 0; -} \ No newline at end of file +} diff --git a/src/libforest/fault.c b/src/libforest/fault.c index d19a1678..720a2256 100644 --- a/src/libforest/fault.c +++ b/src/libforest/fault.c @@ -1,6 +1,8 @@ #include "fault.h" #include "terminal.h" -__declspec(section ".sdata") static fault* this; +#include "va_args.h" + +/*__declspec(section ".sdata")*/ static fault* this; static fault fault_class; extern void fault_AddClientEx(fault_client* client, FaultCallback callback, const char* msg, u32 param, u8 priority, u8 flags) { @@ -46,7 +48,7 @@ extern void fault_AddClientEx(fault_client* client, FaultCallback callback, cons exit: OSRestoreInterrupts(enable); if (client_exists != FALSE) { - OSReport(VTCOL(RED,WHITE)"fault_AddClient: %08x は既にリスト中にある\n%x",VT_RST, client); + OSReport(VT_COL(VT_COLOR_RED,VT_COLOR_WHITE) "fault_AddClient: %08x は既にリスト中にある\n%x" VT_RST, client); } } From fa6c4633eaf94cc6942c53e0bfb59da977c67ce2 Mon Sep 17 00:00:00 2001 From: Cuyler36 Date: Mon, 22 May 2023 06:15:50 -0400 Subject: [PATCH 2/2] Add files --- src/dvderr.c | 954 +++++++++++++++++++++++++++++++++++++ src/libultra/initialize.c | 3 + tools/converters/vtxdis.py | 29 ++ 3 files changed, 986 insertions(+) create mode 100644 src/dvderr.c create mode 100644 src/libultra/initialize.c create mode 100644 tools/converters/vtxdis.py diff --git a/src/dvderr.c b/src/dvderr.c new file mode 100644 index 00000000..41563077 --- /dev/null +++ b/src/dvderr.c @@ -0,0 +1,954 @@ +#include "dvderr.h" + +#include "libultra/libultra.h" +#include "dolphin/dvd.h" +#include "libforest/gbi_extensions.h" +#include "libforest/emu64/emu64_wrapper.h" +#include "libjsys/jsyswrapper.h" +#include "dolphin/vi.h" +#include "dolphin/gx.h" + +#define G_CC_DVDERR 0, 0, 0, PRIMITIVE, 0, 0, 0, TEXEL0 + +/* imports */ +static u8 dvd_keikoku_moji1_1_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/dvd_keikoku_moji1_1_tex.inc" +}; +static u8 dvd_keikoku_moji1_2_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/dvd_keikoku_moji1_2_tex.inc" +}; +static u8 dvd_keikoku_moji1_3_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/dvd_keikoku_moji1_3_tex.inc" +}; +static u8 dvd_keikoku_moji1_4_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/dvd_keikoku_moji1_4_tex.inc" +}; + +static u8 ctl_att_w1_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/ctl_att_w1_tex.inc" +}; +static u8 ctl_att_w2_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/ctl_att_w2_tex.inc" +}; +static u8 ctl_att_w3_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/ctl_att_w3_tex.inc" +}; +static u8 ctl_att_w4_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/ctl_att_w4_tex.inc" +}; +static u8 ctl_att_w5_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/ctl_att_w5_tex.inc" +}; +static u8 ctl_att_w6_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/ctl_att_w6_tex.inc" +}; + +static Vtx dvd_keikoku1_v[] = { +#include "assets/dvd_keikoku1_v.inc" +}; +static Gfx keikoku1_dvd_att_moji_model[] = { + /* init */ + gsSPTexture(0, 0, 0, G_TX_RENDERTILE, G_ON), + gsDPSetCombineMode(G_CC_DVDERR, G_CC_PASS2), + gsDPSetPrimColor(0, 255, 235, 235, 255, 255), + gsDPSetRenderMode(G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_INTER2), + + /* draw 1st text */ + gsDPLoadTextureBlock_4b_Dolphin(dvd_keikoku_moji1_4_tex, G_IM_FMT_I, 192, 16, 15, GX_CLAMP, GX_CLAMP, 0, 0), + gsSPLoadGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BACK | G_FOG | G_SHADING_SMOOTH), + gsSPVertex(&dvd_keikoku1_v[0], 16, 0), + gsSPNTrianglesInit_5b( + 2, // tri count + 0, 1, 2, // tri0 + 1, 3, 2, // tri1 + 0, 0, 0 // tri2 + ), + gsDPLoadTextureBlock_4b_Dolphin(dvd_keikoku_moji1_3_tex, G_IM_FMT_I, 64, 16, 15, GX_CLAMP, GX_CLAMP, 0, 0), + gsSPNTrianglesInit_5b( + 2, // tri count + 4, 5, 6, // tri0 + 5, 7, 6, // tri1 + 0, 0, 0 // tri2 + ), + gsDPLoadTextureBlock_4b_Dolphin(dvd_keikoku_moji1_2_tex, G_IM_FMT_I, 160, 16, 15, GX_CLAMP, GX_CLAMP, 0, 0), + gsSPNTrianglesInit_5b( + 2, // tri count + 8, 9, 10, // tri0 + 9, 11, 10, // tri1 + 0, 0, 0 // tri2 + ), + gsDPLoadTextureBlock_4b_Dolphin(dvd_keikoku_moji1_1_tex, G_IM_FMT_I, 160, 16, 15, GX_CLAMP, GX_CLAMP, 0, 0), + gsSPNTrianglesInit_5b( + 2, // tri count + 12, 13, 14, // tri0 + 13, 15, 14, // tri1 + 0, 0, 0 // tri2 + ), + gsSPEndDisplayList(), +}; + +static Gfx keikoku1_dvd_att_winT_model[] = { + gsSPTexture(0, 0, 0, G_TX_RENDERTILE, G_ON), + gsDPSetCombineMode(G_CC_DVDERR, G_CC_PASS2), + gsDPSetPrimColor(0, 255, 100, 0, 170, 255), + gsDPSetRenderMode(G_RM_FOG_SHADE_A, G_RM_ZB_XLU_SURF2), + + gsDPLoadTextureBlock_4b_Dolphin(ctl_att_w6_tex, G_IM_FMT_I, 16, 16, 15, GX_MIRROR, GX_MIRROR, 0, 0), + gsSPLoadGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BACK | G_FOG | G_SHADING_SMOOTH), + gsSPVertex(&dvd_keikoku1_v[16], 28, 0), + gsSPNTrianglesInit_5b( + 2, // tri count + 0, 1, 2, // tri0 + 1, 3, 2, // tri1 + 0, 0, 0 // tri2 + ), + + gsDPLoadTextureBlock_4b_Dolphin(ctl_att_w5_tex, G_IM_FMT_I, 64, 32, 15, GX_MIRROR, GX_MIRROR, 0, 0), + gsSPNTrianglesInit_5b( + 4, // tri count + 4, 5, 6, // tri0 + 5, 7, 6, // tri1 + 8, 9, 10 // tri2 + ), + gsSPNTriangles_5b( + 11, 8, 10, // tri0 + 0, 0, 0, // tri1 + 0, 0, 0, // tri2 + 0, 0, 0 // tri3 + ), + + gsDPLoadTextureBlock_4b_Dolphin(ctl_att_w4_tex, G_IM_FMT_I, 64, 32, 15, GX_MIRROR, GX_MIRROR, 0, 0), + gsSPNTrianglesInit_5b( + 4, // tri count + 12, 13, 14, // tri0 + 15, 12, 14, // tri1 + 16, 17, 18 // tri2 + ), + gsSPNTriangles_5b( + 17, 19, 18, // tri0 + 0, 0, 0, // tri1 + 0, 0, 0, // tri2 + 0, 0, 0 // tri3 + ), + + gsDPLoadTextureBlock_4b_Dolphin(ctl_att_w3_tex, G_IM_FMT_I, 32, 64, 15, GX_MIRROR, GX_MIRROR, 0, 0), + gsSPNTrianglesInit_5b( + 4, // tri count + 20, 21, 22, // tri0 + 23, 20, 22, // tri1 + 24, 25, 26 // tri2 + ), + gsSPNTriangles_5b( + 25, 27, 26, // tri0 + 0, 0, 0, // tri1 + 0, 0, 0, // tri2 + 0, 0, 0 // tri3 + ), + + gsDPLoadTextureBlock_4b_Dolphin(ctl_att_w2_tex, G_IM_FMT_I, 64, 32, 15, GX_MIRROR, GX_MIRROR, 0, 0), + gsSPVertex(&dvd_keikoku1_v[44], 16, 0), + gsSPNTrianglesInit_5b( + 4, // tri count + 0, 1, 2, // tri0 + 1, 3, 2, // tri1 + 4, 5, 6 // tri2 + ), + gsSPNTriangles_5b( + 7, 4, 6, // tri0 + 0, 0, 0, // tri1 + 0, 0, 0, // tri2 + 0, 0, 0 // tri3 + ), + + gsDPLoadTextureBlock_4b_Dolphin(ctl_att_w1_tex, G_IM_FMT_I, 64, 32, 15, GX_MIRROR, GX_MIRROR, 0, 0), + gsSPNTrianglesInit_5b( + 4, // tri count + 8, 9, 10, // tri0 + 11, 8, 10, // tri1 + 12, 13, 14 // tri2 + ), + gsSPNTriangles_5b( + 13, 15, 14, // tri0 + 0, 0, 0, // tri1 + 0, 0, 0, // tri2 + 0, 0, 0 // tri3 + ), + + gsSPEndDisplayList(), +}; + +static u8 dvd_keikoku_moji2_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/dvd_keikoku_moji2_tex.inc" +}; +static u8 dvd_keikoku_moji2_2_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/dvd_keikoku_moji2_2_tex.inc" +}; +static u8 dvd_keikoku_moji2_3_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/dvd_keikoku_moji2_3_tex.inc" +}; + +static Vtx dvd_keikoku2_v[] = { +#include "assets/dvd_keikoku2_v.inc" +}; +static Gfx keikoku2_dvd_att_moji_model[] = { + gsSPTexture(0, 0, 0, 0, G_ON), + gsDPSetCombineMode(G_CC_DVDERR, G_CC_PASS2), + gsDPSetPrimColor(0, 255, 235, 235, 255, 255), + gsDPSetRenderMode(G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_INTER2), + gsDPLoadTextureBlock_4b_Dolphin(dvd_keikoku_moji2_3_tex, G_IM_FMT_I, 16, 16, 15, GX_MIRROR, GX_MIRROR, 0, 0), + gsSPLoadGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BACK | G_FOG | G_SHADING_SMOOTH), + gsSPVertex(&dvd_keikoku2_v[0], 12, 0), + gsSPNTrianglesInit_5b( + 2, // tri count + 0, 1, 2, // tri0 + 1, 3, 2, // tri1 + 0, 0, 0 // tri2 + ), + gsDPLoadTextureBlock_4b_Dolphin(dvd_keikoku_moji2_2_tex, G_IM_FMT_I, 192, 16, 15, GX_CLAMP, GX_MIRROR, 0, 0), + gsSPNTrianglesInit_5b( + 2, // tri count + 4, 5, 6, // tri0 + 5, 7, 6, // tri1 + 0, 0, 0 // tri2 + ), + gsDPLoadTextureBlock_4b_Dolphin(dvd_keikoku_moji2_tex, G_IM_FMT_I, 80, 16, 15, GX_CLAMP, GX_CLAMP, 0, 0), + gsSPNTrianglesInit_5b( + 2, // tri count + 8, 9, 10, // tri0 + 9, 11, 10, // tri1 + 0, 0, 0 // tri2 + ), + gsSPEndDisplayList(), +}; + +static Gfx keikoku2_dvd_att_winT_model[] = { + gsSPTexture(0, 0, 0, 0, G_ON), + gsDPSetCombineMode(G_CC_DVDERR, G_CC_PASS2), + gsDPSetPrimColor(0, 255, 100, 0, 170, 255), + gsDPSetRenderMode(G_RM_FOG_SHADE_A, G_RM_ZB_XLU_SURF2), + gsDPLoadTextureBlock_4b_Dolphin(ctl_att_w6_tex, G_IM_FMT_I, 16, 16, 15, GX_MIRROR, GX_MIRROR, 0, 0), + gsSPLoadGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BACK | G_FOG | G_SHADING_SMOOTH), + gsSPVertex(&dvd_keikoku2_v[12], 28, 0), + gsSPNTrianglesInit_5b( + 2, // tri count + 0, 1, 2, // tri0 + 1, 3, 2, // tri1 + 0, 0, 0 // tri2 + ), + gsDPLoadTextureBlock_4b_Dolphin(ctl_att_w5_tex, G_IM_FMT_I, 64, 32, 15, GX_MIRROR, GX_MIRROR, 0, 0), + gsSPNTrianglesInit_5b( + 4, // tri count + 4, 5, 6, // tri0 + 5, 7, 6, // tri1 + 8, 9, 10 // tri2 + ), + gsSPNTriangles_5b( + 11, 8, 10, // tri0 + 0, 0, 0, // tri1 + 0, 0, 0, // tri2 + 0, 0, 0 // tri3 + ), + gsDPLoadTextureBlock_4b_Dolphin(ctl_att_w4_tex, G_IM_FMT_I, 64, 32, 15, GX_MIRROR, GX_MIRROR, 0, 0), + gsSPNTrianglesInit_5b( + 4, // tri count + 12, 13, 14, // tri0 + 15, 12, 14, // tri1 + 16, 17, 18 // tri2 + ), + gsSPNTriangles_5b( + 17, 19, 18, // tri0 + 0, 0, 0, // tri1 + 0, 0, 0, // tri2 + 0, 0, 0 // tri3 + ), + gsDPLoadTextureBlock_4b_Dolphin(ctl_att_w3_tex, G_IM_FMT_I, 32, 64, 15, GX_MIRROR, GX_MIRROR, 0, 0), + gsSPNTrianglesInit_5b( + 4, // tri count + 20, 21, 22, // tri0 + 23, 20, 22, // tri1 + 24, 25, 26 // tri2 + ), + gsSPNTriangles_5b( + 25, 27, 26, // tri0 + 0, 0, 0, // tri1 + 0, 0, 0, // tri2 + 0, 0, 0 // tri3 + ), + gsDPLoadTextureBlock_4b_Dolphin(ctl_att_w2_tex, G_IM_FMT_I, 64, 32, 15, GX_MIRROR, GX_MIRROR, 0, 0), + gsSPVertex(&dvd_keikoku2_v[40], 16, 0), + gsSPNTrianglesInit_5b( + 4, // tri count + 0, 1, 2, // tri0 + 1, 3, 2, // tri1 + 4, 5, 6 // tri2 + ), + gsSPNTriangles_5b( + 7, 4, 6, // tri0 + 0, 0, 0, // tri1 + 0, 0, 0, // tri2 + 0, 0, 0 // tri3 + ), + gsDPLoadTextureBlock_4b_Dolphin(ctl_att_w1_tex, G_IM_FMT_I, 64, 32, 15, GX_MIRROR, GX_MIRROR, 0, 0), + gsSPNTrianglesInit_5b( + 4, // tri count + 8, 9, 10, // tri0 + 11, 8, 10, // tri1 + 12, 13, 14 // tri2 + ), + gsSPNTriangles_5b( + 13, 15, 14, // tri0 + 0, 0, 0, // tri1 + 0, 0, 0, // tri2 + 0, 0, 0 // tri3 + ), + gsSPEndDisplayList(), +}; + +static u8 dvd_keikoku_moji4_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/dvd_keikoku_moji4_tex.inc" +}; +static u8 dvd_keikoku_moji3_1_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/dvd_keikoku_moji3_1_tex.inc" +}; +static u8 dvd_keikoku_moji3_2_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/dvd_keikoku_moji3_2_tex.inc" +}; +static u8 dvd_keikoku_moji3_3_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/dvd_keikoku_moji3_3_tex.inc" +}; + +static Vtx dvd_keikoku3_v[] = { +#include "assets/dvd_keikoku3_v.inc" +}; +static Gfx keikoku3_dvd_att_moji_model[] = { + gsSPTexture(0, 0, 0, 0, G_ON), + gsDPSetCombineMode(G_CC_DVDERR, G_CC_PASS2), + gsDPSetPrimColor(0, 255, 235, 235, 255, 255), + gsDPSetRenderMode(G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_INTER2), + gsDPLoadTextureBlock_4b_Dolphin(dvd_keikoku_moji3_3_tex, G_IM_FMT_I, 16, 16, 15, GX_MIRROR, GX_MIRROR, 0, 0), + gsSPLoadGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BACK | G_FOG | G_SHADING_SMOOTH), + gsSPVertex(&dvd_keikoku3_v[0], 24, 0), + gsSPNTrianglesInit_5b( + 4, // tri count + 0, 1, 2, // tri0 + 1, 3, 2, // tri1 + 4, 5, 6 // tri2 + ), + gsSPNTriangles_5b( + 7, 4, 6, // tri0 + 0, 0, 0, // tri1 + 0, 0, 0, // tri2 + 0, 0, 0 // tri3 + ), + gsDPLoadTextureBlock_4b_Dolphin(dvd_keikoku_moji3_2_tex, G_IM_FMT_I, 80, 16, 15, GX_CLAMP, GX_CLAMP, 0, 0), + gsSPNTrianglesInit_5b( + 2, // tri count + 8, 9, 10, // tri0 + 9, 11, 10, // tri1 + 0, 0, 0 // tri2 + ), + gsDPLoadTextureBlock_4b_Dolphin(dvd_keikoku_moji3_1_tex, G_IM_FMT_I, 192, 16, 15, GX_CLAMP, GX_MIRROR, 0, 0), + gsSPNTrianglesInit_5b( + 4, // tri count + 12, 13, 14, // tri0 + 13, 15, 14, // tri1 + 16, 17, 18 // tri2 + ), + gsSPNTriangles_5b( + 19, 16, 18, // tri0 + 0, 0, 0, // tri1 + 0, 0, 0, // tri2 + 0, 0, 0 // tri3 + ), + gsDPLoadTextureBlock_4b_Dolphin(dvd_keikoku_moji4_tex, G_IM_FMT_I, 80, 16, 15, GX_CLAMP, GX_CLAMP, 0, 0), + gsSPNTrianglesInit_5b( + 2, // tri count + 20, 21, 22, // tri0 + 21, 23, 22, // tri1 + 0, 0, 0 // tri2 + ), + gsSPEndDisplayList(), +}; + +static Gfx keikoku3_dvd_att_winT_model[] = { + gsSPTexture(0, 0, 0, 0, G_ON), + gsDPSetCombineMode(G_CC_DVDERR, G_CC_PASS2), + gsDPSetPrimColor(0, 255, 100, 0, 170, 255), + gsDPSetRenderMode(G_RM_FOG_SHADE_A, G_RM_ZB_XLU_SURF2), + gsDPLoadTextureBlock_4b_Dolphin(ctl_att_w6_tex, G_IM_FMT_I, 16, 16, 15, GX_MIRROR, GX_MIRROR, 0, 0), + gsSPLoadGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BACK | G_FOG | G_SHADING_SMOOTH), + gsSPVertex(&dvd_keikoku3_v[24], 28, 0), + gsSPNTrianglesInit_5b( + 2, // tri count + 0, 1, 2, // tri0 + 1, 3, 2, // tri1 + 0, 0, 0 // tri2 + ), + gsDPLoadTextureBlock_4b_Dolphin(ctl_att_w5_tex, G_IM_FMT_I, 64, 32, 15, GX_MIRROR, GX_MIRROR, 0, 0), + gsSPNTrianglesInit_5b( + 4, // tri count + 4, 5, 6, // tri0 + 5, 7, 6, // tri1 + 8, 9, 10 // tri2 + ), + gsSPNTriangles_5b( + 11, 8, 10, // tri0 + 0, 0, 0, // tri1 + 0, 0, 0, // tri2 + 0, 0, 0 // tri3 + ), + gsDPLoadTextureBlock_4b_Dolphin(ctl_att_w4_tex, G_IM_FMT_I, 64, 32, 15, GX_MIRROR, GX_MIRROR, 0, 0), + gsSPNTrianglesInit_5b( + 4, // tri count + 12, 13, 14, // tri0 + 15, 12, 14, // tri1 + 16, 17, 18 // tri2 + ), + gsSPNTriangles_5b( + 17, 19, 18, // tri0 + 0, 0, 0, // tri1 + 0, 0, 0, // tri2 + 0, 0, 0 // tri3 + ), + gsDPLoadTextureBlock_4b_Dolphin(ctl_att_w3_tex, G_IM_FMT_I, 32, 64, 15, GX_MIRROR, GX_MIRROR, 0, 0), + gsSPNTrianglesInit_5b( + 4, // tri count + 20, 21, 22, // tri0 + 23, 20, 22, // tri1 + 24, 25, 26 // tri2 + ), + gsSPNTriangles_5b( + 25, 27, 26, // tri0 + 0, 0, 0, // tri1 + 0, 0, 0, // tri2 + 0, 0, 0 // tri3 + ), + gsDPLoadTextureBlock_4b_Dolphin(ctl_att_w2_tex, G_IM_FMT_I, 64, 32, 15, GX_MIRROR, GX_MIRROR, 0, 0), + gsSPVertex(&dvd_keikoku3_v[52], 16, 0), + gsSPNTrianglesInit_5b( + 4, // tri count + 0, 1, 2, // tri0 + 1, 3, 2, // tri1 + 4, 5, 6 // tri2 + ), + gsSPNTriangles_5b( + 7, 4, 6, // tri0 + 0, 0, 0, // tri1 + 0, 0, 0, // tri2 + 0, 0, 0 // tri3 + ), + gsDPLoadTextureBlock_4b_Dolphin(ctl_att_w1_tex, G_IM_FMT_I, 64, 32, 15, GX_MIRROR, GX_MIRROR, 0, 0), + gsSPNTrianglesInit_5b( + 4, // tri count + 8, 9, 10, // tri0 + 11, 8, 10, // tri1 + 12, 13, 14 // tri2 + ), + gsSPNTriangles_5b( + 13, 15, 14, // tri0 + 0, 0, 0, // tri1 + 0, 0, 0, // tri2 + 0, 0, 0 // tri3 + ), + gsSPEndDisplayList(), +}; + +static u8 dvd_keikoku_moji5_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/dvd_keikoku_moji5_tex.inc" +}; +static u8 dvd_keikoku_moji6_2_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/dvd_keikoku_moji6_2_tex.inc" +}; +static u8 dvd_keikoku_moji6_3_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/dvd_keikoku_moji6_3_tex.inc" +}; +static u8 dvd_keikoku_moji6_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/dvd_keikoku_moji6_tex.inc" +}; +static u8 dvd_keikoku_moji6_1_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/dvd_keikoku_moji6_1_tex.inc" +}; +static u8 dvd_keikoku_moji6_new1_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/dvd_keikoku_moji6_new1_tex.inc" +}; +static u8 dvd_keikoku_moji6_new2_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/dvd_keikoku_moji6_new2_tex.inc" +}; + +static Vtx dvd_keikoku4_v[] = { +#include "assets/dvd_keikoku4_v.inc" +}; +static Gfx keikoku4_dvd_att_moji_model[] = { + gsSPTexture(0, 0, 0, 0, G_ON), + gsDPSetCombineMode(G_CC_DVDERR, G_CC_PASS2), + gsDPSetPrimColor(0, 255, 235, 235, 255, 255), + gsDPSetRenderMode(G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_INTER2), + gsDPLoadTextureBlock_4b_Dolphin(dvd_keikoku_moji6_new2_tex, G_IM_FMT_I, 64, 16, 15, GX_CLAMP, GX_CLAMP, 0, 0), + gsSPLoadGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BACK | G_FOG | G_SHADING_SMOOTH), + gsSPVertex(&dvd_keikoku4_v[0], 28, 0), + gsSPNTrianglesInit_5b( + 2, // tri count + 0, 1, 2, // tri0 + 1, 3, 2, // tri1 + 0, 0, 0 // tri2 + ), + gsDPLoadTextureBlock_4b_Dolphin(dvd_keikoku_moji6_new1_tex, G_IM_FMT_I, 64, 16, 15, GX_CLAMP, GX_CLAMP, 0, 0), + gsSPNTrianglesInit_5b( + 2, // tri count + 4, 5, 6, // tri0 + 5, 7, 6, // tri1 + 0, 0, 0 // tri2 + ), + gsDPLoadTextureBlock_4b_Dolphin(dvd_keikoku_moji6_1_tex, G_IM_FMT_I, 176, 16, 15, GX_CLAMP, GX_CLAMP, 0, 0), + gsSPNTrianglesInit_5b( + 2, // tri count + 8, 9, 10, // tri0 + 9, 11, 10, // tri1 + 0, 0, 0 // tri2 + ), + gsDPLoadTextureBlock_4b_Dolphin(dvd_keikoku_moji6_tex, G_IM_FMT_I, 128, 16, 15, GX_CLAMP, GX_CLAMP, 0, 0), + gsSPNTrianglesInit_5b( + 2, // tri count + 12, 13, 14, // tri0 + 13, 15, 14, // tri1 + 0, 0, 0 // tri2 + ), + gsDPLoadTextureBlock_4b_Dolphin(dvd_keikoku_moji6_3_tex, G_IM_FMT_I, 80, 16, 15, GX_CLAMP, GX_CLAMP, 0, 0), + gsSPNTrianglesInit_5b( + 2, // tri count + 16, 17, 18, // tri0 + 17, 19, 18, // tri1 + 0, 0, 0 // tri2 + ), + gsDPLoadTextureBlock_4b_Dolphin(dvd_keikoku_moji6_2_tex, G_IM_FMT_I, 144, 16, 15, GX_CLAMP, GX_CLAMP, 0, 0), + gsSPNTrianglesInit_5b( + 2, // tri count + 20, 21, 22, // tri0 + 21, 23, 22, // tri1 + 0, 0, 0 // tri2 + ), + gsDPLoadTextureBlock_4b_Dolphin(dvd_keikoku_moji5_tex, G_IM_FMT_I, 96, 16, 15, GX_CLAMP, GX_CLAMP, 0, 0), + gsSPNTrianglesInit_5b( + 2, // tri count + 24, 25, 26, // tri0 + 25, 27, 26, // tri1 + 0, 0, 0 // tri2 + ), + gsSPEndDisplayList(), +}; + +static Gfx keikoku4_dvd_att_winT_model[] = { + gsSPTexture(0, 0, 0, 0, G_ON), + gsDPSetCombineMode(G_CC_DVDERR, G_CC_PASS2), + gsDPSetPrimColor(0, 255, 100, 0, 170, 255), + gsDPSetRenderMode(G_RM_FOG_SHADE_A, G_RM_ZB_XLU_SURF2), + gsDPLoadTextureBlock_4b_Dolphin(ctl_att_w6_tex, G_IM_FMT_I, 16, 16, 15, GX_MIRROR, GX_MIRROR, 0, 0), + gsSPLoadGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BACK | G_FOG | G_SHADING_SMOOTH), + gsSPVertex(&dvd_keikoku4_v[28], 28, 0), + gsSPNTrianglesInit_5b( + 2, // tri count + 0, 1, 2, // tri0 + 1, 3, 2, // tri1 + 0, 0, 0 // tri2 + ), + gsDPLoadTextureBlock_4b_Dolphin(ctl_att_w5_tex, G_IM_FMT_I, 64, 32, 15, GX_MIRROR, GX_MIRROR, 0, 0), + gsSPNTrianglesInit_5b( + 4, // tri count + 4, 5, 6, // tri0 + 5, 7, 6, // tri1 + 8, 9, 10 // tri2 + ), + gsSPNTriangles_5b( + 11, 8, 10, // tri0 + 0, 0, 0, // tri1 + 0, 0, 0, // tri2 + 0, 0, 0 // tri3 + ), + gsDPLoadTextureBlock_4b_Dolphin(ctl_att_w4_tex, G_IM_FMT_I, 64, 32, 15, GX_MIRROR, GX_MIRROR, 0, 0), + gsSPNTrianglesInit_5b( + 4, // tri count + 12, 13, 14, // tri0 + 15, 12, 14, // tri1 + 16, 17, 18 // tri2 + ), + gsSPNTriangles_5b( + 17, 19, 18, // tri0 + 0, 0, 0, // tri1 + 0, 0, 0, // tri2 + 0, 0, 0 // tri3 + ), + gsDPLoadTextureBlock_4b_Dolphin(ctl_att_w3_tex, G_IM_FMT_I, 32, 64, 15, GX_MIRROR, GX_MIRROR, 0, 0), + gsSPNTrianglesInit_5b( + 4, // tri count + 20, 21, 22, // tri0 + 23, 20, 22, // tri1 + 24, 25, 26 // tri2 + ), + gsSPNTriangles_5b( + 25, 27, 26, // tri0 + 0, 0, 0, // tri1 + 0, 0, 0, // tri2 + 0, 0, 0 // tri3 + ), + gsDPLoadTextureBlock_4b_Dolphin(ctl_att_w2_tex, G_IM_FMT_I, 64, 32, 15, GX_MIRROR, GX_MIRROR, 0, 0), + gsSPVertex(&dvd_keikoku4_v[56], 16, 0), + gsSPNTrianglesInit_5b( + 4, // tri count + 0, 1, 2, // tri0 + 1, 3, 2, // tri1 + 4, 5, 6 // tri2 + ), + gsSPNTriangles_5b( + 7, 4, 6, // tri0 + 0, 0, 0, // tri1 + 0, 0, 0, // tri2 + 0, 0, 0 // tri3 + ), + gsDPLoadTextureBlock_4b_Dolphin(ctl_att_w1_tex, G_IM_FMT_I, 64, 32, 15, GX_MIRROR, GX_MIRROR, 0, 0), + gsSPNTrianglesInit_5b( + 4, // tri count + 8, 9, 10, // tri0 + 11, 8, 10, // tri1 + 12, 13, 14 // tri2 + ), + gsSPNTriangles_5b( + 13, 15, 14, // tri0 + 0, 0, 0, // tri1 + 0, 0, 0, // tri2 + 0, 0, 0 // tri3 + ), + gsSPEndDisplayList(), +}; + +static u8 dvd_keikoku_moji7_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/dvd_keikoku_moji7_tex.inc" +}; +static u8 dvd_keikoku_moji8_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/dvd_keikoku_moji8_tex.inc" +}; +static u8 dvd_keikoku_moji10_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/dvd_keikoku_moji10_tex.inc" +}; +static u8 dvd_keikoku_moji11_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/dvd_keikoku_moji11_tex.inc" +}; +static u8 dvd_keikoku_moji12_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/dvd_keikoku_moji12_tex.inc" +}; +static u8 dvd_keikoku_moji9_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/dvd_keikoku_moji9_tex.inc" +}; + +static Vtx dvd_keikoku5_v[] = { +#include "assets/dvd_keikoku5_v.inc" +}; +static Gfx keikoku5_dvd_att_moji_model[] = { + gsSPTexture(0, 0, 0, 0, G_ON), + gsDPSetCombineMode(G_CC_DVDERR, G_CC_PASS2), + gsDPSetPrimColor(0, 255, 235, 235, 255, 255), + gsDPSetRenderMode(G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_INTER2), + gsDPLoadTextureBlock_4b_Dolphin(dvd_keikoku_moji9_tex, G_IM_FMT_I, 160, 16, 15, GX_CLAMP, GX_CLAMP, 0, 0), + gsSPLoadGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BACK | G_FOG | G_SHADING_SMOOTH), + gsSPVertex(&dvd_keikoku5_v[0], 24, 0), + gsSPNTrianglesInit_5b( + 2, // tri count + 0, 1, 2, // tri0 + 1, 3, 2, // tri1 + 0, 0, 0 // tri2 + ), + gsDPLoadTextureBlock_4b_Dolphin(dvd_keikoku_moji12_tex, G_IM_FMT_I, 80, 16, 15, GX_CLAMP, GX_CLAMP, 0, 0), + gsSPNTrianglesInit_5b( + 2, // tri count + 4, 5, 6, // tri0 + 5, 7, 6, // tri1 + 0, 0, 0 // tri2 + ), + gsDPLoadTextureBlock_4b_Dolphin(dvd_keikoku_moji11_tex, G_IM_FMT_I, 144, 16, 15, GX_CLAMP, GX_CLAMP, 0, 0), + gsSPNTrianglesInit_5b( + 2, // tri count + 8, 9, 10, // tri0 + 9, 11, 10, // tri1 + 0, 0, 0 // tri2 + ), + gsDPLoadTextureBlock_4b_Dolphin(dvd_keikoku_moji10_tex, G_IM_FMT_I, 64, 16, 15, GX_CLAMP, GX_CLAMP, 0, 0), + gsSPNTrianglesInit_5b( + 2, // tri count + 12, 13, 14, // tri0 + 13, 15, 14, // tri1 + 0, 0, 0 // tri2 + ), + gsDPLoadTextureBlock_4b_Dolphin(dvd_keikoku_moji8_tex, G_IM_FMT_I, 128, 16, 15, GX_CLAMP, GX_CLAMP, 0, 0), + gsSPNTrianglesInit_5b( + 2, // tri count + 16, 17, 18, // tri0 + 17, 19, 18, // tri1 + 0, 0, 0 // tri2 + ), + gsDPLoadTextureBlock_4b_Dolphin(dvd_keikoku_moji7_tex, G_IM_FMT_I, 160, 16, 15, GX_CLAMP, GX_CLAMP, 0, 0), + gsSPNTrianglesInit_5b( + 2, // tri count + 20, 21, 22, // tri0 + 21, 23, 22, // tri1 + 0, 0, 0 // tri2 + ), + gsSPEndDisplayList(), +}; + +static Gfx keikoku5_dvd_att_winT_model[] = { + gsSPTexture(0, 0, 0, 0, G_ON), + gsDPSetCombineMode(G_CC_DVDERR, G_CC_PASS2), + gsDPSetPrimColor(0, 255, 100, 0, 170, 255), + gsDPSetRenderMode(G_RM_FOG_SHADE_A, G_RM_ZB_XLU_SURF2), + gsDPLoadTextureBlock_4b_Dolphin(ctl_att_w6_tex, G_IM_FMT_I, 16, 16, 15, GX_MIRROR, GX_MIRROR, 0, 0), + gsSPLoadGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BACK | G_FOG | G_SHADING_SMOOTH), + gsSPVertex(&dvd_keikoku5_v[24], 28, 0), + gsSPNTrianglesInit_5b( + 2, // tri count + 0, 1, 2, // tri0 + 1, 3, 2, // tri1 + 0, 0, 0 // tri2 + ), + gsDPLoadTextureBlock_4b_Dolphin(ctl_att_w5_tex, G_IM_FMT_I, 64, 32, 15, GX_MIRROR, GX_MIRROR, 0, 0), + gsSPNTrianglesInit_5b( + 4, // tri count + 4, 5, 6, // tri0 + 5, 7, 6, // tri1 + 8, 9, 10 // tri2 + ), + gsSPNTriangles_5b( + 11, 8, 10, // tri0 + 0, 0, 0, // tri1 + 0, 0, 0, // tri2 + 0, 0, 0 // tri3 + ), + gsDPLoadTextureBlock_4b_Dolphin(ctl_att_w4_tex, G_IM_FMT_I, 64, 32, 15, GX_MIRROR, GX_MIRROR, 0, 0), + gsSPNTrianglesInit_5b( + 4, // tri count + 12, 13, 14, // tri0 + 15, 12, 14, // tri1 + 16, 17, 18 // tri2 + ), + gsSPNTriangles_5b( + 17, 19, 18, // tri0 + 0, 0, 0, // tri1 + 0, 0, 0, // tri2 + 0, 0, 0 // tri3 + ), + gsDPLoadTextureBlock_4b_Dolphin(ctl_att_w3_tex, G_IM_FMT_I, 32, 64, 15, GX_MIRROR, GX_MIRROR, 0, 0), + gsSPNTrianglesInit_5b( + 4, // tri count + 20, 21, 22, // tri0 + 23, 20, 22, // tri1 + 24, 25, 26 // tri2 + ), + gsSPNTriangles_5b( + 25, 27, 26, // tri0 + 0, 0, 0, // tri1 + 0, 0, 0, // tri2 + 0, 0, 0 // tri3 + ), + gsDPLoadTextureBlock_4b_Dolphin(ctl_att_w2_tex, G_IM_FMT_I, 64, 32, 15, GX_MIRROR, GX_MIRROR, 0, 0), + gsSPVertex(&dvd_keikoku5_v[52], 16, 0), + gsSPNTrianglesInit_5b( + 4, // tri count + 0, 1, 2, // tri0 + 1, 3, 2, // tri1 + 4, 5, 6 // tri2 + ), + gsSPNTriangles_5b( + 7, 4, 6, // tri0 + 0, 0, 0, // tri1 + 0, 0, 0, // tri2 + 0, 0, 0 // tri3 + ), + gsDPLoadTextureBlock_4b_Dolphin(ctl_att_w1_tex, G_IM_FMT_I, 64, 32, 15, GX_MIRROR, GX_MIRROR, 0, 0), + gsSPNTrianglesInit_5b( + 4, // tri count + 8, 9, 10, // tri0 + 11, 8, 10, // tri1 + 12, 13, 14 // tri2 + ), + gsSPNTriangles_5b( + 13, 15, 14, // tri0 + 0, 0, 0, // tri1 + 0, 0, 0, // tri2 + 0, 0, 0 // tri3 + ), + gsSPEndDisplayList(), +}; + +static dvderr_work Dvderr_work; +static dvderr_work* const this = &Dvderr_work; + +static Vp Dvderr_viewport = {{ + { 1280, 960, 511, 0 }, + { 1280, 960, 511, 0 } +}}; + +static Gfx Dvderr_initial_dl[] = { + gsDPSetOtherMode(G_AD_PATTERN | G_CD_MAGICSQ | G_CK_NONE | G_TC_CONV | G_TF_POINT | G_TT_NONE | G_TL_TILE | G_TD_CLAMP | G_TP_NONE | G_CYC_FILL | G_PM_NPRIMITIVE, G_AC_NONE | G_ZS_PIXEL | G_RM_NOOP | G_RM_NOOP2), + gsDPSetFillColor(GPACK_RGBA5551(0, 0, 0, 1) << 16 | GPACK_RGBA5551(0, 0, 0, 1)), /* fill color to black */ + gsDPFillRectangle(0, 0, 639, 479), /* fill in rectangle which is the size of the screen */ + gsDPSetScissor(G_SC_NON_INTERLACE, 0, 0, 640, 480), /* set scissor to screen size, TODO: should probably be defintions */ + gsSPClipRatio(FRUSTRATIO_2), /* 2:1 clipping ratio */ + gsSPViewport(&Dvderr_viewport), + gsSPMatrix(&Dvderr_work.ortho, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION), + gsSPMatrix(&Dvderr_work.projection, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_PROJECTION), + gsDPSetOtherMode(G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE | G_TD_CLAMP | G_TP_PERSP | G_CYC_1CYCLE | G_PM_NPRIMITIVE, G_AC_NONE | G_ZS_PIXEL | G_RM_NOOP | G_RM_NOOP2), + gsSPMatrix(&Dvderr_work.modelview, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW), + gsSPEndDisplayList(), +}; + + +static void dvderr_exec_dl(Gfx* dl) { + emu64_init(); + emu64_taskstart(dl); + emu64_cleanup(); +} + +static int dvderr_check_drive() { + int err = DVDERR_NONE; + + if (osShutdown == FALSE) { + switch (DVDGetDriveStatus()) { + case DVD_STATE_FATAL_ERROR: + err = DVDERR_FATAL; + break; + + case DVD_STATE_BUSY: + err = this->next_error; + break; + + case DVD_STATE_NO_DISK: + err = DVDERR_NO_DISK; + break; + + case DVD_STATE_COVER_OPEN: + err = DVDERR_COVER_OPEN; + break; + + case DVD_STATE_WRONG_DISK: + err = DVDERR_WRONG_DISK; + break; + + case DVD_STATE_RETRY: + err = DVDERR_RETRY; + break; + } + } + + return err; +} + +static void dvderr_draw_CoverOpen() { + gSPDisplayList(this->gfx_p++, keikoku1_dvd_att_winT_model); + gSPDisplayList(this->gfx_p++, keikoku1_dvd_att_moji_model); +} + +static void dvderr_draw_NoDisk() { + gSPDisplayList(this->gfx_p++, keikoku2_dvd_att_winT_model); + gSPDisplayList(this->gfx_p++, keikoku2_dvd_att_moji_model); +} + +static void dvderr_draw_WrongDisk() { + gSPDisplayList(this->gfx_p++, keikoku3_dvd_att_winT_model); + gSPDisplayList(this->gfx_p++, keikoku3_dvd_att_moji_model); +} + +static void dvderr_draw_Retry() { + gSPDisplayList(this->gfx_p++, keikoku4_dvd_att_winT_model); + gSPDisplayList(this->gfx_p++, keikoku4_dvd_att_moji_model); +} + +static void dvderr_draw_Fatal() { + gSPDisplayList(this->gfx_p++, keikoku5_dvd_att_winT_model); + gSPDisplayList(this->gfx_p++, keikoku5_dvd_att_moji_model); +} + +static void dvderr_mtx_set() { + guScale(&this->modelview, this->scale, this->scale, 1.0f); +} + +#define DVDERR_MOVE_SPEED (1.0f/18.0f) + +static void dvderr_move_up(); +static void dvderr_move_down(); +static void dvderr_move_wait(); + +static void dvderr_move_up() { + this->scale += DVDERR_MOVE_SPEED; + if (this->scale >= 1.0f) { + this->scale = 1.0f; + } + + if (this->next_error != this->now_error) { + this->draw_proc = &dvderr_move_down; + } +} + +static void dvderr_move_down() { + this->scale -= DVDERR_MOVE_SPEED; + if (this->scale <= 0.0f) { + this->scale = 0.0f; + this->now_error = this->next_error; + this->draw_proc = &dvderr_move_wait; + } +} + +static void dvderr_move_wait() { + if (this->next_error == DVDERR_NONE) { + return; + } + + this->now_error = this->next_error; + this->draw_proc = &dvderr_move_up; +} + +static void dvderr_move() { + (*this->draw_proc)(); +} + +extern int dvderr_draw() { + static const DVDERR_DRAW_PROC draw_proc[DVDERR_NUM] = { + &dvderr_draw_CoverOpen, + &dvderr_draw_NoDisk, + &dvderr_draw_WrongDisk, + &dvderr_draw_Retry, + &dvderr_draw_Fatal + }; + + this->next_error = dvderr_check_drive(); + dvderr_move(); + + if (this->now_error >= DVDERR_COVER_OPEN) { + dvderr_mtx_set(); + JW_BeginFrame(); + this->gfx_p = this->gfx; + gSPDisplayList(this->gfx_p++, Dvderr_initial_dl); + + if (draw_proc[this->now_error] != NULL) { + (*draw_proc[this->now_error])(); + } + + gDPFullSync(this->gfx_p++); + gSPEndDisplayList(this->gfx_p++); + + dvderr_exec_dl(this->gfx); + JW_EndFrame(); + VISetBlack(FALSE); + return TRUE; + } + else { + return FALSE; + } +} + +extern void dvderr_init() { + bzero(this, sizeof(dvderr_work)); + this->draw_proc = &dvderr_move_wait; + this->now_error = DVDERR_NONE; + this->next_error = DVDERR_NONE; + + guOrtho(&this->ortho, -160.0f, 160.0f, -120.0f, 120.0f, -800.0f, 800.0f, 1.0f); /* TODO: N64 screen size macros (float) */ + guLookAt(&this->projection, 0.0f, 0.0f, 400.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f); +} diff --git a/src/libultra/initialize.c b/src/libultra/initialize.c new file mode 100644 index 00000000..9b5033ad --- /dev/null +++ b/src/libultra/initialize.c @@ -0,0 +1,3 @@ +#include "libultra/libultra.h" + +int osShutdown; diff --git a/tools/converters/vtxdis.py b/tools/converters/vtxdis.py new file mode 100644 index 00000000..1dcd6ca4 --- /dev/null +++ b/tools/converters/vtxdis.py @@ -0,0 +1,29 @@ +from argparse import ArgumentParser +import struct + +def convert_binary_to_vtx_c_source(src_path, dest_path): + # Load data + with open(src_path, "rb") as binary_file, open(dest_path, "w") as c_file: + while True: + chunk = binary_file.read(16) # 16 bytes for each Vtx struct + + if len(chunk) < 16: + break + + ob = struct.unpack(">hhh", chunk[0:6]) # 3 * 2 bytes + flag = struct.unpack(">H", chunk[6:8]) # 2 bytes + tc = struct.unpack(">hh", chunk[8:12]) # 2 * 2 bytes + cn = struct.unpack(">BBBB", chunk[12:16]) # 4 * 1 byte + + c_file.write(f" {{{ob[0]}, {ob[1]}, {ob[2]}, {flag[0]}, {tc[0]}, {tc[1]}, {cn[0]}, {cn[1]}, {cn[2]}, {cn[3]}}},\n") + +def main(): + parser = ArgumentParser(description="Converts a binary file to an array of N64 Vtx type") + parser.add_argument("src_path", type=str, help="Binary source file path") + parser.add_argument("dest_path", type=str, help="Destination C include file path") + + args = parser.parse_args() + convert_binary_to_vtx_c_source(args.src_path, args.dest_path) + +if __name__ == '__main__': + main()