diff --git a/common.py b/common.py index 7cc2744c..de18830a 100644 --- a/common.py +++ b/common.py @@ -328,7 +328,9 @@ COMMON_DEFINES = [ "-d DEBUG=0" ] DOL_DEFINES = COMMON_DEFINES + [] -REL_DEFINES = COMMON_DEFINES + [] +REL_DEFINES = COMMON_DEFINES + [ + "-d OPTIMIZED_SQRTF" +] BASE_DOL_CFLAGS = CFLAGS + [ "-inline on", "-sdata 8", diff --git a/config/assets.yml b/config/assets.yml index 8970727e..eac3e74e 100644 --- a/config/assets.yml +++ b/config/assets.yml @@ -1,90 +1,147 @@ config/dol.yml: - __Creator__: - 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" + __Creator__: + 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] + + # initial_menu.c + bootdata/gam_win_moji1_tex: + addrs: [0x800b9140, 0x800b93c0] + bootdata/gam_win_moji2_tex: + addrs: [0x800b93c0, 0x800b98c0] + bootdata/yes: + addrs: [0x800b98c0, 0x800b99c0] + bootdata/no: + addrs: [0x800b99c0, 0x800b9a40] + bootdata/att_win_waku1_tex: + addrs: [0x800b9a40, 0x800b9e40] + bootdata/att_win_waku2_tex: + addrs: [0x800b9e40, 0x800ba240] + bootdata/att_win_waku3_tex: + addrs: [0x800ba240, 0x800ba640] + bootdata/att_win_waku4_tex: + addrs: [0x800ba640, 0x800baa40] + bootdata/att_win_waku5_tex: + addrs: [0x800baa40, 0x800bae40] + bootdata/att_win_waku6_tex: + addrs: [0x800bae40, 0x800baec0] + bootdata/gam_win1_v: + addrs: [0x800baec0, 0x800bb2b0] + type: vtx + bootdata/gam_win_moji3_tex: + addrs: [0x800bb500, 0x800bba00] + bootdata/gam_win_moji4_tex: + addrs: [0x800bba00, 0x800bbf00] + bootdata/att_win_waku1_tex_1: + addrs: [0x800bbf00, 0x800bc300] + bootdata/att_win_waku2_tex_1: + addrs: [0x800bc300, 0x800bc700] + bootdata/att_win_waku3_tex_1: + addrs: [0x800bc700, 0x800bcb00] + bootdata/att_win_waku4_tex_1: + addrs: [0x800bcb00, 0x800bcf00] + bootdata/att_win_waku5_tex_1: + addrs: [0x800bcf00, 0x800bd300] + bootdata/att_win_waku6_tex_1: + addrs: [0x800bd300, 0x800bd380] + bootdata/gam_win2_v: + addrs: [0x800bd380, 0x800bd6c0] + type: vtx + bootdata/gam_win_moji3_tex_1: + addrs: [0x800bd820, 0x800bdd20] + bootdata/gam_win_moji5_tex: + addrs: [0x800bdd20, 0x800be0a0] + bootdata/gam_win3_v: + addrs: [0x800be0a0, 0x800be3e0] + type: vtx + bootdata/nintendo_376x104: + addrs: [0x800be460, 0x800c30c0] + bootdata/logo_nin_v: + addrs: [0x800c30c0, 0x800c3100] + type: vtx - nintendo_hi_0: - addrs: [0x800c3140, 0x800cca40] config/rel.yml: - wipe1_v: - addrs: [0x80652AD0, 0x80652C60] - type: "vtx" - g_wipe1_txt: - addrs: [0x80652C60, 0x80653460] + wipe1_v: + addrs: [0x80652AD0, 0x80652C60] + type: vtx + g_wipe1_txt: + addrs: [0x80652C60, 0x80653460] diff --git a/config/dol_slices.yml b/config/dol_slices.yml index 80666331..0cb6fec3 100644 --- a/config/dol_slices.yml +++ b/config/dol_slices.yml @@ -16,11 +16,26 @@ boot.c: .bss: [0x800e2280, 0x800e2318] version.c: .data: [0x800b05e8, 0x800b0608] +initial_menu.c: + .text: [0x80007188, 0x80007e58] + .rodata: [0x800a97e8, 0x800a97f8] + .data: [0x800b0608, 0x800b0a60] + .bss: [0x800e2640, 0x800e2790] dvderr.c: .text: [0x80007e58, 0x800083f8] .rodata: [0x800a97f8, 0x800a9838] .data: [0x800b0a60, 0x800b9140] .bss: [0x800e2790, 0x800e2b88] +bootdata/gam_win1.c: + .data: [0x800b9140, 0x800bb500] +bootdata/gam_win2.c: + .data: [0x800bb500, 0x800bd820] +bootdata/gam_win3.c: + .data: [0x800bd820, 0x800be460] +bootdata/logo_nin.c: + .data: [0x800be460, 0x800c3140] +nintendo_hi_0.c: + .data: [0x800c3140, 0x800cca40] jaudio_NES/dummyprobe.c: .text: [0x800083f8, 0x80008400] #jaudio_NES/verysimple.c: diff --git a/config/rel_slices.yml b/config/rel_slices.yml index 586ad7d1..f3eabf29 100644 --- a/config/rel_slices.yml +++ b/config/rel_slices.yml @@ -2,9 +2,9 @@ sys_vimgr.c: .text: [0x803703F8, 0x80370418] m_cockroach.c: .text: [0x80385430, 0x80385A80] -#m_controller.c: # TODO: uncomment when fsqrt's $localstatic$ issue is resolved -# .text: [0x80395BE8, 0x80396120] -# .rodata: [0x80641D20, 0x80641D50] +m_controller.c: # TODO: uncomment when fsqrt's $localstatic$ issue is resolved + .text: [0x80395BE8, 0x80396120] + .rodata: [0x80641D20, 0x80641D50] m_debug_hayakawa.c: .text: [0x803965E4, 0x803973E8] .rodata: [0x80641D50, 0x80641D90] diff --git a/config/symbols.yml b/config/symbols.yml index e62e1973..233b2cf0 100644 --- a/config/symbols.yml +++ b/config/symbols.yml @@ -11,7 +11,6 @@ global: 0x800034e0: TRK_memset 0x80003510: TRK_memcpy 0x80003534: gTRKInterruptVectorTable - 0x80003534: gTRKInterruptVectorTable 0x80005468: __TRK_reset 0x800056c0: soundArenaAlloc 0x800056c8: search_partial_address @@ -30,7 +29,6 @@ global: 0x80005dc0: fault_callback_scroll 0x80006004: adjustOSArena 0x800060f8: main - 0x800060f8: main 0x8000663c: ReportDiskID__Fv 0x8000665c: JW_UpdateVideoMode 0x800067b4: JW_SetProgressiveMode diff --git a/configure.py b/configure.py index 905b524c..56a38238 100644 --- a/configure.py +++ b/configure.py @@ -631,7 +631,7 @@ class CSource(Source): self.cflags = c.JSYSTEM_CFLAGS self.cc = c.CC self.frank = False - elif path == "src/boot.c": + elif path.startswith("src/bootdata/") or path == "src/boot.c" or path == "src/initial_menu.c": self.cflags = c.DOL_BOOT_CFLAGS self.cc = c.CC self.frank = False diff --git a/include/JSystem/JUtility/JUTEnum.h b/include/JSystem/JUtility/JUTEnum.h new file mode 100644 index 00000000..a5019ba0 --- /dev/null +++ b/include/JSystem/JUtility/JUTEnum.h @@ -0,0 +1,37 @@ +#ifndef JUTENUM_H +#define JUTENUM_H + +#include "types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +enum EButtons { + MAINSTICK_UP = 0x8000000, + MAINSTICK_DOWN = 0x4000000, + MAINSTICK_RIGHT = 0x2000000, + MAINSTICK_LEFT = 0x1000000, + CSTICK_UP = 0x80000, + CSTICK_DOWN = 0x40000, + CSTICK_RIGHT = 0x20000, + CSTICK_LEFT = 0x10000, + START = 0x1000, + Y = 0x800, + X = 0x400, + B = 0x200, + A = 0x100, + L = 0x40, + R = 0x20, + Z = 0x10, + DPAD_UP = 0x8, + DPAD_DOWN = 0x4, + DPAD_RIGHT = 0x2, + DPAD_LEFT = 0x1 +}; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/MSL_C/w_math.h b/include/MSL_C/w_math.h index 521d39b1..98efcecd 100644 --- a/include/MSL_C/w_math.h +++ b/include/MSL_C/w_math.h @@ -2,7 +2,9 @@ #define W_MATH_H #include "types.h" -inline float sqrtf(float x) +/* this is needed to keep $localstatic$ variables out of the rel */ +#ifndef OPTIMIZED_SQRTF +extern inline float sqrtf(float x) { static const double _half=.5; static const double _three=3.0; @@ -18,6 +20,22 @@ inline float sqrtf(float x) } return x; } +#else +extern inline float sqrtf(float x) +{ + volatile float y; + if(x > 0.0f) + { + double guess = __frsqrte((double)x); // returns an approximation to + guess = .5*guess*(3.0 - guess*guess*x); // now have 12 sig bits + guess = .5*guess*(3.0 - guess*guess*x); // now have 24 sig bits + guess = .5*guess*(3.0 - guess*guess*x); // now have 32 sig bits + y=(float)(x*guess); + return y; + } + return x; +} +#endif extern inline double fabs(double x) { diff --git a/include/bootdata.h b/include/bootdata.h new file mode 100644 index 00000000..7bdb1677 --- /dev/null +++ b/include/bootdata.h @@ -0,0 +1,35 @@ +#ifndef BOOTDATA_H +#define BOOTDATA_H + +#include "types.h" +#include "PR/mbi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define LOGO_COLOR_R 220 +#define LOGO_COLOR_G 0 +#define LOGO_COLOR_B 0 + +extern Gfx gam_win1_winT_model[]; +extern Gfx gam_win2_winT_model[]; + +extern Gfx gam_win1_cursor_model[]; + +extern Gfx gam_win1_moji_model[]; +extern Gfx gam_win1_moji2_model[]; +extern Gfx gam_win1_moji3_model[]; + +extern Gfx gam_win2_moji_model[]; +extern Gfx gam_win3_moji_model[]; + +extern u8 nintendo_376x104[]; +extern Vtx logo_nin_v[]; +extern Gfx logo_ninT_model[]; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/dolphin/os/OSFont.h b/include/dolphin/os/OSFont.h new file mode 100644 index 00000000..fb8471eb --- /dev/null +++ b/include/dolphin/os/OSFont.h @@ -0,0 +1,19 @@ +#ifndef OSFONT_H +#define OSFONT_H + +#include "types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define OS_FONT_ANSI 0u +#define OS_FONT_SJIS 1u + +u16 OSGetFontEncode(); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/dolphin/os/OSResetSW.h b/include/dolphin/os/OSResetSW.h new file mode 100644 index 00000000..fe9b4045 --- /dev/null +++ b/include/dolphin/os/OSResetSW.h @@ -0,0 +1,16 @@ +#ifndef OSRESETSW_H +#define OSRESETSW_H + +#include "types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +BOOL OSGetResetSwitchState(); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/dolphin/vi.h b/include/dolphin/vi.h index f80f35d3..7f065e0f 100644 --- a/include/dolphin/vi.h +++ b/include/dolphin/vi.h @@ -11,6 +11,7 @@ void VISetBlack(BOOL); void VIWaitForRetrace(); void VIConfigurePan(u16 x_origin, u16 y_origin, u16 width, u16 height); u32 VIGetRetraceCount(); +u32 VIGetDTVStatus(); #ifdef __cplusplus }; diff --git a/include/initial_menu.h b/include/initial_menu.h index 4003c8ce..da6c4c48 100644 --- a/include/initial_menu.h +++ b/include/initial_menu.h @@ -2,11 +2,22 @@ #define INITIAL_MENU_H #include "types.h" +#include "PR/mbi.h" #ifdef __cplusplus extern "C" { #endif +#define INITIAL_MENU_STACK_SIZE 0x2800 + +#define INITIAL_MENU_LIMIT_TIME (OSMicrosecondsToTicks(10000000ull)) +#define INITIAL_MENU_SELECT_WAIT_TIME (OSMicrosecondsToTicks(3000000ull)) + +#define INITIAL_MENU_OSMESG_INIT_DONE 0x1234 +#define INITIAL_MENU_OSMESG_FADEOUT_STEP 0x8888 +#define INITIAL_MENU_OSMESG_LOAD_GAME_DONE 0x9999 + +extern void make_dl_nintendo_logo(Gfx** gpp, u32 alpha); extern void initial_menu_init(); extern void initial_menu_cleanup(); diff --git a/include/libforest/gbi_extensions.h b/include/libforest/gbi_extensions.h index 7f38f95f..56ecc869 100644 --- a/include/libforest/gbi_extensions.h +++ b/include/libforest/gbi_extensions.h @@ -20,6 +20,8 @@ extern "C" { #define G_FIRST_CMD G_SETTEXEDGEALPHA +#define G_CC_BLENDPRIMDECALA 0, 0, 0, PRIMITIVE, 0, 0, 0, TEXEL0 + /* Triangle/Quad vertex bit size */ #define POLY_5b 0 /* 5 bits per vertex index (0 - 31) */ #define POLY_7b 1 /* 7 bits per vertex index (0 - 127) */ @@ -579,6 +581,12 @@ do { \ (u32)0 \ }} +#define G_DL_GXDL 2 + +/* Macro for calling GC formatted display lists from N64 lists */ +#define gGXCallDisplayList(pkt, dl, nbytes) gDma1p(pkt, G_DL, dl, nbytes, G_DL_GXDL) +#define gsGXCallDisplayList(dl, nbytes) gsDma1p(pkt, G_DL, dl, nbytes, G_DL_GXDL) + #ifdef __cplusplus } #endif diff --git a/include/libjsys/jsyswrapper.h b/include/libjsys/jsyswrapper.h index 344cc84a..692a487e 100644 --- a/include/libjsys/jsyswrapper.h +++ b/include/libjsys/jsyswrapper.h @@ -3,6 +3,7 @@ #include "types.h" #include "JSystem/JKernel/JKREnum.h" +#include "JSystem/JUtility/JUTEnum.h" #ifdef __cplusplus extern "C" { @@ -22,12 +23,17 @@ extern void JW_SetProgressiveMode(BOOL enable); extern u32 JW_GetAramAddress(int resource_no); extern u8* _JW_GetResourceAram(u32 aram_addr, u8* dst, size_t size); extern void JW_SetFamicomMode(int enabled); +extern void JW_SetLogoMode(int mode); extern void JW_Cleanup(); extern void* JC_JFWSystem_getSystemConsole(); extern void* JC_JFWSystem_getRootHeap(); extern void* JC_JFWSystem_getSystemHeap(); +extern void* JC_JFWDisplay_getManager(); +extern void JC_JFWDisplay_startFadeOut(void* manager, int len); +extern void JC_JFWDisplay_startFadeIn(void* manager, int len); + extern int JC_JKRHeap_dump(void* heap); extern s32 JC_JKRHeap_getTotalFreeSize(void* heap); @@ -73,6 +79,12 @@ extern void JC_JUTException_setMapFile(const char* path); extern void JC_JUTAssertion_changeDevice(int device); extern void JC_JUTAssertion_changeDisplayTime(int displayTime); +extern void JC_JUTGamePad_read(); + +extern u32 JW_JUTGamepad_getButton(); +extern u32 JW_JUTGamepad_getTrigger(); +extern u32 JW_JUTGamepad_getErrorStatus(); + #ifdef __cplusplus } #endif diff --git a/include/libultra/libultra.h b/include/libultra/libultra.h index a6e1d8d5..8e992a2f 100644 --- a/include/libultra/libultra.h +++ b/include/libultra/libultra.h @@ -5,6 +5,10 @@ #include "dolphin/os/OSTime.h" #include "dolphin/os/OSCache.h" #include "libultra/gu.h" +#include "libultra/osMesg.h" +#include "libultra/shutdown.h" +#include "libultra/os_timer.h" +#include "libultra/os_thread.h" #define N64_SCREEN_HEIGHT 240 #define N64_SCREEN_WIDTH 320 @@ -14,6 +18,8 @@ extern "C" { #endif +typedef u64 Z_OSTime; + int bcmp (void *v1, void *v2, u32 size); void bcopy(void *src, void *dst, size_t n); void bzero(void *ptr, size_t size); @@ -24,6 +30,7 @@ OSTime osGetTime(void); extern s32 osAppNMIBuffer[]; extern int osShutdown; +extern u8 __osResetSwitchPressed; #ifdef __cplusplus diff --git a/include/libultra/osMesg.h b/include/libultra/osMesg.h index d7241fa6..c54948e1 100644 --- a/include/libultra/osMesg.h +++ b/include/libultra/osMesg.h @@ -18,6 +18,6 @@ typedef struct OSMesgQueue { extern void osCreateMesgQueue(OSMessageQueue* mq ,OSMessage msg, int flags); extern int osSendMesg(OSMessageQueue* mq, OSMessage msg, int flags); -extern int osRecvMesg(OSMessageQueue* mq, OSMessage msg, int flags); +extern int osRecvMesg(OSMessageQueue* mq, OSMessage* msg, int flags); #endif diff --git a/include/libultra/os_thread.h b/include/libultra/os_thread.h index 3c21805f..e0226d24 100644 --- a/include/libultra/os_thread.h +++ b/include/libultra/os_thread.h @@ -10,6 +10,7 @@ extern "C" { extern void osCreateThread2(OSThread* t, int id, void(*entry)(void*), void* arg, void* stack_pointer, size_t stack_size, OSPriority priority); extern void osStartThread(OSThread* t); +extern void osDestroyThread(OSThread* t); #ifdef __cplusplus } diff --git a/rel/m_controller.c b/rel/m_controller.c index dbe93033..9c1cb8a7 100644 --- a/rel/m_controller.c +++ b/rel/m_controller.c @@ -3,6 +3,7 @@ #include "m_lib.h" #include "m_event.h" #include "MSL_C/w_math.h" +#include "sys_math.h" /** * @brief Constructor for MCON. diff --git a/src/bootdata/gam_win1.c b/src/bootdata/gam_win1.c new file mode 100644 index 00000000..e1549567 --- /dev/null +++ b/src/bootdata/gam_win1.c @@ -0,0 +1,203 @@ +#include "bootdata.h" +#include "libforest/gbi_extensions.h" + +static u8 gam_win_moji1_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/bootdata/gam_win_moji1_tex.inc" +}; + +static u8 gam_win_moji2_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/bootdata/gam_win_moji2_tex.inc" +}; + +static u8 yes[] = { +#include "assets/bootdata/yes.inc" +}; + +static u8 no[] = { +#include "assets/bootdata/no.inc" +}; + +static u8 att_win_waku1_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/bootdata/att_win_waku1_tex.inc" +}; + +static u8 att_win_waku2_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/bootdata/att_win_waku2_tex.inc" +}; + +static u8 att_win_waku3_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/bootdata/att_win_waku3_tex.inc" +}; + +static u8 att_win_waku4_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/bootdata/att_win_waku4_tex.inc" +}; + +static u8 att_win_waku5_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/bootdata/att_win_waku5_tex.inc" +}; + +static u8 att_win_waku6_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/bootdata/att_win_waku6_tex.inc" +}; + +static Vtx gam_win1_v[] = { +#include "assets/bootdata/gam_win1_v.inc" +}; + +Gfx gam_win1_cursor_model[] = { + gsSPTexture(0, 0, 0, 0, G_ON), + gsDPSetCombineMode(G_CC_PRIMITIVE, G_CC_PASS2), + gsDPSetPrimColor(0, 255, 145, 40, 40, 255), + gsDPSetRenderMode(G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2), + gsSPLoadGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BACK | G_FOG | G_SHADING_SMOOTH), + gsSPVertex(&gam_win1_v[0], 3, 0), + gsSPNTrianglesInit_5b( + 1, // tri count + 0, 1, 2, // tri0 + 0, 0, 0, // tri1 + 0, 0, 0 // tri2 + ), + gsSPEndDisplayList(), +}; + +Gfx gam_win1_moji_model[] = { + gsSPTexture(0, 0, 0, 0, G_ON), + gsDPSetCombineMode(G_CC_BLENDPRIMDECALA, G_CC_PASS2), + gsDPSetPrimColor(0, 255, 50, 50, 60, 255), + gsDPSetRenderMode(G_RM_FOG_SHADE_A, G_RM_ZB_XLU_SURF2), + gsDPLoadTextureBlock_4b_Dolphin(gam_win_moji2_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(&gam_win1_v[3], 8, 0), + gsSPNTrianglesInit_5b( + 2, // tri count + 0, 1, 2, // tri0 + 1, 3, 2, // tri1 + 0, 0, 0 // tri2 + ), + gsDPLoadTextureBlock_4b_Dolphin(gam_win_moji1_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 + ), + gsSPEndDisplayList(), +}; + +Gfx gam_win1_moji2_model[] = { + gsSPTexture(0, 0, 0, 0, G_ON), + gsDPSetCombineMode(G_CC_BLENDPRIMDECALA, G_CC_PASS2), + gsDPSetPrimColor(0, 255, 90, 90, 155, 255), + gsDPSetRenderMode(G_RM_FOG_SHADE_A, G_RM_ZB_XLU_SURF2), + gsDPLoadTextureBlock_4b_Dolphin(yes, G_IM_FMT_I, 32, 16, 15, GX_CLAMP, GX_CLAMP, 0, 0), + gsSPLoadGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BACK | G_FOG | G_SHADING_SMOOTH), + gsSPVertex(&gam_win1_v[11], 4, 0), + gsSPNTrianglesInit_5b( + 2, // tri count + 0, 1, 2, // tri0 + 1, 3, 2, // tri1 + 0, 0, 0 // tri2 + ), + gsSPEndDisplayList(), +}; + +Gfx gam_win1_moji3_model[] = { + gsSPTexture(0, 0, 0, 0, G_ON), + gsDPSetCombineMode(G_CC_BLENDPRIMDECALA, G_CC_PASS2), + gsDPSetPrimColor(0, 255, 90, 90, 155, 255), + gsDPSetRenderMode(G_RM_FOG_SHADE_A, G_RM_ZB_XLU_SURF2), + gsDPLoadTextureBlock_4b_Dolphin(no, G_IM_FMT_I, 16, 16, 15, GX_CLAMP, GX_CLAMP, 0, 0), + gsSPLoadGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BACK | G_FOG | G_SHADING_SMOOTH), + gsSPVertex(&gam_win1_v[15], 4, 0), + gsSPNTrianglesInit_5b( + 2, // tri count + 0, 1, 2, // tri0 + 1, 3, 2, // tri1 + 0, 0, 0 // tri2 + ), + gsSPEndDisplayList(), +}; + +Gfx gam_win1_winT_model[] = { + gsSPTexture(0, 0, 0, 0, G_ON), + gsDPSetCombineMode(G_CC_BLENDPRIMDECALA, G_CC_PASS2), + gsDPSetPrimColor(0, 255, 225, 255, 255, 255), + gsDPSetRenderMode(G_RM_FOG_SHADE_A, G_RM_ZB_XLU_SURF2), + gsDPLoadTextureBlock_4b_Dolphin(att_win_waku6_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(&gam_win1_v[19], 28, 0), + gsSPNTrianglesInit_5b( + 2, // tri count + 0, 1, 2, // tri0 + 1, 3, 2, // tri1 + 0, 0, 0 // tri2 + ), + gsDPLoadTextureBlock_4b_Dolphin(att_win_waku5_tex, G_IM_FMT_I, 64, 32, 15, GX_MIRROR, GX_MIRROR, 0, 0), + gsSPNTrianglesInit_5b( + 4, // tri count + 4, 5, 6, // tri0 + 7, 4, 6, // tri1 + 8, 9, 10 // tri2 + ), + gsSPNTriangles_5b( + 9, 11, 10, // tri0 + 0, 0, 0, // tri1 + 0, 0, 0, // tri2 + 0, 0, 0 // tri3 + ), + gsDPLoadTextureBlock_4b_Dolphin(att_win_waku4_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(att_win_waku3_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(att_win_waku2_tex, G_IM_FMT_I, 64, 32, 15, GX_MIRROR, GX_MIRROR, 0, 0), + gsSPVertex(&gam_win1_v[47], 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(att_win_waku1_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(), +}; diff --git a/src/bootdata/gam_win2.c b/src/bootdata/gam_win2.c new file mode 100644 index 00000000..f23bbce8 --- /dev/null +++ b/src/bootdata/gam_win2.c @@ -0,0 +1,145 @@ +#include "bootdata.h" +#include "libforest/gbi_extensions.h" + +static u8 gam_win_moji3_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/bootdata/gam_win_moji3_tex.inc" +}; + +static u8 gam_win_moji4_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/bootdata/gam_win_moji4_tex.inc" +}; + +static u8 att_win_waku1_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/bootdata/att_win_waku1_tex_1.inc" +}; + +static u8 att_win_waku2_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/bootdata/att_win_waku2_tex_1.inc" +}; + +static u8 att_win_waku3_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/bootdata/att_win_waku3_tex_1.inc" +}; + +static u8 att_win_waku4_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/bootdata/att_win_waku4_tex_1.inc" +}; + +static u8 att_win_waku5_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/bootdata/att_win_waku5_tex_1.inc" +}; + +static u8 att_win_waku6_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/bootdata/att_win_waku6_tex_1.inc" +}; + +static Vtx gam_win2_v[] = { +#include "assets/bootdata/gam_win2_v.inc" +}; + +Gfx gam_win2_moji_model[] = { + gsSPTexture(0, 0, 0, 0, G_ON), + gsDPSetCombineMode(G_CC_BLENDPRIMDECALA, G_CC_PASS2), + gsDPSetPrimColor(0, 255, 50, 50, 60, 255), + gsDPSetRenderMode(G_RM_FOG_SHADE_A, G_RM_ZB_XLU_SURF2), + gsDPLoadTextureBlock_4b_Dolphin(gam_win_moji4_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(&gam_win2_v[0], 8, 0), + gsSPNTrianglesInit_5b( + 2, // tri count + 0, 1, 2, // tri0 + 1, 3, 2, // tri1 + 0, 0, 0 // tri2 + ), + gsDPLoadTextureBlock_4b_Dolphin(gam_win_moji3_tex, G_IM_FMT_I, 160, 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 + ), + gsSPEndDisplayList(), +}; + +Gfx gam_win2_winT_model[] = { + gsSPTexture(0, 0, 0, 0, G_ON), + gsDPSetCombineMode(G_CC_BLENDPRIMDECALA, G_CC_PASS2), + gsDPSetPrimColor(0, 255, 225, 255, 255, 255), + gsDPSetRenderMode(G_RM_FOG_SHADE_A, G_RM_ZB_XLU_SURF2), + gsDPLoadTextureBlock_4b_Dolphin(att_win_waku6_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(&gam_win2_v[8], 28, 0), + gsSPNTrianglesInit_5b( + 2, // tri count + 0, 1, 2, // tri0 + 1, 3, 2, // tri1 + 0, 0, 0 // tri2 + ), + gsDPLoadTextureBlock_4b_Dolphin(att_win_waku5_tex, G_IM_FMT_I, 64, 32, 15, GX_MIRROR, GX_MIRROR, 0, 0), + gsSPNTrianglesInit_5b( + 4, // tri count + 4, 5, 6, // tri0 + 7, 4, 6, // tri1 + 8, 9, 10 // tri2 + ), + gsSPNTriangles_5b( + 9, 11, 10, // tri0 + 0, 0, 0, // tri1 + 0, 0, 0, // tri2 + 0, 0, 0 // tri3 + ), + gsDPLoadTextureBlock_4b_Dolphin(att_win_waku4_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(att_win_waku3_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(att_win_waku2_tex, G_IM_FMT_I, 64, 32, 15, GX_MIRROR, GX_MIRROR, 0, 0), + gsSPVertex(&gam_win2_v[36], 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(att_win_waku1_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(), +}; diff --git a/src/bootdata/gam_win3.c b/src/bootdata/gam_win3.c new file mode 100644 index 00000000..3e0821f6 --- /dev/null +++ b/src/bootdata/gam_win3.c @@ -0,0 +1,38 @@ +#include "bootdata.h" +#include "libforest/gbi_extensions.h" + +static u8 gam_win_moji3_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/bootdata/gam_win_moji3_tex_1.inc" +}; + +static u8 gam_win_moji5_tex[] ATTRIBUTE_ALIGN(32) = { +#include "assets/bootdata/gam_win_moji5_tex.inc" +}; + +static Vtx gam_win3_v[] = { +#include "assets/bootdata/gam_win3_v.inc" +}; + +Gfx gam_win3_moji_model[] = { + gsSPTexture(0, 0, 0, 0, G_ON), + gsDPSetCombineMode(G_CC_BLENDPRIMDECALA, G_CC_PASS2), + gsDPSetPrimColor(0, 255, 50, 50, 60, 255), + gsDPSetRenderMode(G_RM_FOG_SHADE_A, G_RM_ZB_XLU_SURF2), + gsDPLoadTextureBlock_4b_Dolphin(gam_win_moji5_tex, G_IM_FMT_I, 112, 16, 15, GX_CLAMP, GX_CLAMP, 0, 0), + gsSPLoadGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BACK | G_FOG | G_SHADING_SMOOTH), + gsSPVertex(&gam_win3_v[0], 8, 0), + gsSPNTrianglesInit_5b( + 2, // tri count + 0, 1, 2, // tri0 + 1, 3, 2, // tri1 + 0, 0, 0 // tri2 + ), + gsDPLoadTextureBlock_4b_Dolphin(gam_win_moji3_tex, G_IM_FMT_I, 160, 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 + ), + gsSPEndDisplayList(), +}; diff --git a/src/bootdata/logo_nin.c b/src/bootdata/logo_nin.c new file mode 100644 index 00000000..8a33db26 --- /dev/null +++ b/src/bootdata/logo_nin.c @@ -0,0 +1,22 @@ +#include "bootdata.h" +#include "libforest/gbi_extensions.h" + +u8 nintendo_376x104[] ATTRIBUTE_ALIGN(32) = { +#include "assets/bootdata/nintendo_376x104.inc" +}; + +Vtx logo_nin_v[] = { + #include "assets/bootdata/logo_nin_v.inc" +}; + +Gfx logo_ninT_model[] = { + gsDPLoadTextureBlock_4b_Dolphin(nintendo_376x104, G_IM_FMT_I, 376, 104, 15, GX_CLAMP, GX_CLAMP, 0, 0), + gsSPVertex(&logo_nin_v[0], 4, 0), + gsSPNTrianglesInit_5b( + 2, // tri count + 0, 1, 2, // tri0 + 1, 3, 2, // tri1 + 0, 0, 0 // tri2 + ), + gsSPEndDisplayList(), +}; diff --git a/src/dvderr.c b/src/dvderr.c index 41563077..2fe8547e 100644 --- a/src/dvderr.c +++ b/src/dvderr.c @@ -8,8 +8,6 @@ #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" @@ -49,7 +47,7 @@ static Vtx dvd_keikoku1_v[] = { static Gfx keikoku1_dvd_att_moji_model[] = { /* init */ gsSPTexture(0, 0, 0, G_TX_RENDERTILE, G_ON), - gsDPSetCombineMode(G_CC_DVDERR, G_CC_PASS2), + gsDPSetCombineMode(G_CC_BLENDPRIMDECALA, G_CC_PASS2), gsDPSetPrimColor(0, 255, 235, 235, 255, 255), gsDPSetRenderMode(G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_INTER2), @@ -89,7 +87,7 @@ static Gfx keikoku1_dvd_att_moji_model[] = { static Gfx keikoku1_dvd_att_winT_model[] = { gsSPTexture(0, 0, 0, G_TX_RENDERTILE, G_ON), - gsDPSetCombineMode(G_CC_DVDERR, G_CC_PASS2), + gsDPSetCombineMode(G_CC_BLENDPRIMDECALA, G_CC_PASS2), gsDPSetPrimColor(0, 255, 100, 0, 170, 255), gsDPSetRenderMode(G_RM_FOG_SHADE_A, G_RM_ZB_XLU_SURF2), @@ -192,7 +190,7 @@ static Vtx dvd_keikoku2_v[] = { }; static Gfx keikoku2_dvd_att_moji_model[] = { gsSPTexture(0, 0, 0, 0, G_ON), - gsDPSetCombineMode(G_CC_DVDERR, G_CC_PASS2), + gsDPSetCombineMode(G_CC_BLENDPRIMDECALA, 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), @@ -223,7 +221,7 @@ static Gfx keikoku2_dvd_att_moji_model[] = { static Gfx keikoku2_dvd_att_winT_model[] = { gsSPTexture(0, 0, 0, 0, G_ON), - gsDPSetCombineMode(G_CC_DVDERR, G_CC_PASS2), + gsDPSetCombineMode(G_CC_BLENDPRIMDECALA, 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), @@ -322,7 +320,7 @@ static Vtx dvd_keikoku3_v[] = { }; static Gfx keikoku3_dvd_att_moji_model[] = { gsSPTexture(0, 0, 0, 0, G_ON), - gsDPSetCombineMode(G_CC_DVDERR, G_CC_PASS2), + gsDPSetCombineMode(G_CC_BLENDPRIMDECALA, 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), @@ -372,7 +370,7 @@ static Gfx keikoku3_dvd_att_moji_model[] = { static Gfx keikoku3_dvd_att_winT_model[] = { gsSPTexture(0, 0, 0, 0, G_ON), - gsDPSetCombineMode(G_CC_DVDERR, G_CC_PASS2), + gsDPSetCombineMode(G_CC_BLENDPRIMDECALA, 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), @@ -480,7 +478,7 @@ static Vtx dvd_keikoku4_v[] = { }; static Gfx keikoku4_dvd_att_moji_model[] = { gsSPTexture(0, 0, 0, 0, G_ON), - gsDPSetCombineMode(G_CC_DVDERR, G_CC_PASS2), + gsDPSetCombineMode(G_CC_BLENDPRIMDECALA, 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), @@ -539,7 +537,7 @@ static Gfx keikoku4_dvd_att_moji_model[] = { static Gfx keikoku4_dvd_att_winT_model[] = { gsSPTexture(0, 0, 0, 0, G_ON), - gsDPSetCombineMode(G_CC_DVDERR, G_CC_PASS2), + gsDPSetCombineMode(G_CC_BLENDPRIMDECALA, 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), @@ -644,7 +642,7 @@ static Vtx dvd_keikoku5_v[] = { }; static Gfx keikoku5_dvd_att_moji_model[] = { gsSPTexture(0, 0, 0, 0, G_ON), - gsDPSetCombineMode(G_CC_DVDERR, G_CC_PASS2), + gsDPSetCombineMode(G_CC_BLENDPRIMDECALA, 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), @@ -696,7 +694,7 @@ static Gfx keikoku5_dvd_att_moji_model[] = { static Gfx keikoku5_dvd_att_winT_model[] = { gsSPTexture(0, 0, 0, 0, G_ON), - gsDPSetCombineMode(G_CC_DVDERR, G_CC_PASS2), + gsDPSetCombineMode(G_CC_BLENDPRIMDECALA, 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), diff --git a/src/initial_menu.c b/src/initial_menu.c new file mode 100644 index 00000000..31b177b0 --- /dev/null +++ b/src/initial_menu.c @@ -0,0 +1,453 @@ +#include "initial_menu.h" +#include "PR/mbi.h" +#include "libforest/gbi_extensions.h" +#include "m_nmibuf.h" +#include "dolphin/dvd.h" +#include "libjsys/jsyswrapper.h" +#include "boot.h" +#include "dolphin/os/OSFont.h" +#include "bootdata.h" +#include "libultra/libultra.h" +#include "libforest/emu64/emu64_wrapper.h" +#include "dolphin/vi.h" +#include "dolphin/os/OSRtc.h" +#include "dolphin/os/OSMessage.h" +#include "dolphin/os/OSResetSW.h" +#include "dolphin/os/OSReset.h" +#include "dolphin/os.h" +#include "m_controller.h" +#include "dvderr.h" + +#define G_CC_LOGO 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0 + +static Mtx model_cursor; +static u8 progressive_mode; + +static Gfx gam_win1_cursor_setup[] = { + gsSPTexture(0, 0, 0, 0, G_OFF), + gsDPSetCombineMode(G_CC_PRIMITIVE, G_CC_PRIMITIVE), + gsDPSetRenderMode(G_RM_AA_OPA_SURF, G_RM_AA_OPA_SURF2), + gsSPLoadGeometryMode(G_SHADE | G_SHADING_SMOOTH), + gsSPEndDisplayList(), +}; + +static Gfx gam_win1_moji_setup[] = { + gsSPTexture(0, 0, 0, 0, G_ON), + gsDPSetCombineMode(G_CC_BLENDPRIMDECALA, G_CC_BLENDPRIMDECALA), + gsDPSetRenderMode(G_RM_XLU_SURF, G_RM_XLU_SURF2), + gsSPLoadGeometryMode(G_SHADE | G_SHADING_SMOOTH), + gsSPEndDisplayList(), +}; + +static Vp viewport = { + 1280, 960, 511, 0, + 1280, 960, 511, 0 +}; + +static Mtx projection = { + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0xFFFF0000, 0x00000000, 0xFFFF0001, + 0x00CC0000, 0x00000000, 0x00000111, 0x00000000, + 0x00000000, 0xFFFF0000, 0x00000000, 0x00000000 +}; + +static Mtx lookat = { + 0x10000, 0x00000, 0x00001, 0x00000, + 0x00000, 0x10000, 0x00000, 0x00001, + 0x00000, 0x00000, 0x00000, 0x00000, + 0x00000, 0x00000, 0x00000, 0x00000 +}; + +static Mtx default_model_scale = { + 0x20000, 0x00000, 0x00002, 0x00000, + 0x00000, 0x10000, 0x00000, 0x00001, + 0x00000, 0x00000, 0x00000, 0x00000, + 0x00000, 0x00000, 0x00000, 0x00000 +}; + +static Mtx logo_projection = { + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0xFFFF0000, 0x00000000, 0x00000001, + 0x00CC0000, 0x00000000, 0x000000F9, 0x00000000, + 0x00000000, 0x00000000, 0x0000007C, 0x00000000 +}; + +static Mtx logo_model_scale = { + 0x10000, 0x00000, 0x00001, 0x00000, + 0x00000, 0x10000, 0x00000, 0x00001, + 0x00000, 0x00000, 0x00000, 0x00000, + 0x00000, 0x00000, 0x00000, 0x00000 +}; + +static Gfx initial_dl[] = { + gsDPSetScissor(G_SC_NON_INTERLACE, 0, 0, 640, 480), + gsSPClipRatio(FRUSTRATIO_2), + gsSPViewport(&viewport), + gsSPMatrix(&projection, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION), + gsSPMatrix(&lookat, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_PROJECTION), + gsSPMatrix(&default_model_scale, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW), + 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), + gsSPEndDisplayList(), +}; + +static Gfx logo_initial_dl[] = { + gsDPSetScissor(G_SC_NON_INTERLACE, 0, 0, 640, 480), + gsSPClipRatio(FRUSTRATIO_2), + gsSPViewport(&viewport), + gsSPMatrix(&logo_projection, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION), + gsSPMatrix(&lookat, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_PROJECTION), + gsSPMatrix(&default_model_scale, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW), + 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), + gsSPEndDisplayList(), +}; + +static Gfx logo_draw_dl[] = { + gsSPDisplayList(logo_initial_dl), + gsSPDisplayList(gam_win1_moji_setup), + gsDPSetPrimColor(0, 255, 220, 0, 0, 255), + gsSPMatrix(&logo_model_scale, G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW), + gsSPDisplayList(logo_ninT_model), + gsSPPopMatrix(G_MTX_MODELVIEW), + gsSPEndDisplayList(), +}; + +static Gfx step1_draw_dl[] = { + gsSPDisplayList(initial_dl), + gsSPDisplayList(gam_win1_moji_setup), + gsSPDisplayList(gam_win1_winT_model), + gsSPDisplayList(gam_win1_moji_model), + gsDPSetPrimColor(0, 255, 90, 90, 155, 255), + gsSPDisplayList(0x08000000), + gsDPSetPrimColor(0, 255, 50, 30, 150, 255), + gsSPDisplayList(0x09000000), + gsSPDisplayList(gam_win1_cursor_setup), + gsSPMatrix(&model_cursor, G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW), + gsSPDisplayList(gam_win1_cursor_model), + gsSPPopMatrix(G_MTX_MODELVIEW), + gsSPEndDisplayList(), +}; + +static Gfx step2_draw_dl[] = { + gsSPDisplayList(initial_dl), /* call initial dl */ + gsSPDisplayList(gam_win1_moji_setup), /* call gam_win1_moji_setup */ + gsDPSetPrimColor(0, 255, 225, 255, 255, 255), /* set primitive color to off-white */ + gsSPDisplayList(gam_win2_winT_model), /* call gam_win2_winT_model */ + gsDPSetPrimColor(0, 255, 50, 50, 60, 255), /* set primitive color to dark blue-gray */ + gsSPDisplayList(0x08000000), /* call progressive mode model set in step2_make_dl */ + gsSPEndDisplayList(), +}; + +static int pad_good_frame_count = -1; + +static void step0_make_dl(Gfx** gpp) { + Gfx* g = *gpp; + + if (APPNMI_TESTMODE_GET()) { + DVDDiskID* diskId = DVDGetCurrentDiskID(); + if (boot_copyDate != NULL) { + JW_JUTReport(150, 400, 1, "COPYDATE: %.17s", boot_copyDate); + } + + if (diskId != NULL) { + JW_JUTReport(150, 330, 1, ""); + JW_JUTReport(150, 342, 1, "GAMENAME: %.4s", diskId->gameName); + JW_JUTReport(150, 354, 1, " COMPANY: %.2s", diskId->company); + JW_JUTReport(150, 366, 1, " VERSION: 0x%02X(%d)", diskId->gameVersion, diskId->gameVersion); + } + + JW_JUTReport(150, 330, 1, ""); /* I belive the above is a 'bug', because this is the exact same print */ + JW_JUTReport(150, 50, 1, "SDK VERSION: 12Dec2001 Patch4"); + + if (OSGetFontEncode() == OS_FONT_SJIS) { + JW_JUTReport(150, 100, 1, " ****** WARNING ******"); + JW_JUTReport(150, 112, 1, "The DISP SW is JAPAN MODE now"); + JW_JUTReport(150, 124, 1, "but this GAME is NES version"); + } + } + + if (APPNMI_SHOPPROMOVERSION_GET()) { + JW_JUTReport(150, 410, 1, "SHOP PROMOTE VERSION"); + } + + gSPDisplayList(g++, logo_draw_dl); + *gpp = g; +} + +extern void make_dl_nintendo_logo(Gfx** gpp, u32 alpha) { + Gfx* g = *gpp; + + gSPSegment(g++, G_MWO_SEGMENT_8, logo_initial_dl); /* segment 8 = logo_initial_dl */ + gSPSegment(g++, G_MWO_SEGMENT_9, gam_win1_moji_setup); /* segment 9 = gam_win1_moji_setup */ + gSPDisplayList(g++, SEGMENT_ADDR(8, 0)); /* call to segment 8 (logo_initial_dl) */ + gSPDisplayList(g++, SEGMENT_ADDR(9, 0)); /* call to segment 9 (gam_win1_moji_setup) */ + gSPMatrix(g++, &logo_model_scale, G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW); /* set logo model scale */ + gDPSetCombineMode(g++, G_CC_LOGO, G_CC_LOGO); /* set color combiner for logo */ + gDPSetPrimColor(g++, 0, 255, LOGO_COLOR_R, LOGO_COLOR_G, LOGO_COLOR_B, alpha); /* set logo color */ + gSPDisplayList(g++, logo_ninT_model); /* call logo display list (logo_ninT_model) */ + gSPPopMatrix(g++, G_MTX_MODELVIEW); /* remove logo model scale */ + + *gpp = g; +} + +static void step1_make_dl(Gfx** gpp) { + static Gfx* yes_no_model[2] = { + gam_win1_moji2_model, + gam_win1_moji3_model + }; + + Gfx* g = *gpp; + + guTranslate(&model_cursor, progressive_mode != 0 ? -42 : 0, -86.0f, 0.0f); + + gSPSegment(g++, G_MWO_SEGMENT_8, yes_no_model[progressive_mode]); /* segment 8 is yes/no */ + gSPSegment(g++, G_MWO_SEGMENT_9, yes_no_model[progressive_mode ^ 1]); /* segment 9 is inverse yes/no */ + gSPDisplayList(g++, step1_draw_dl); /* call step1 display list */ + + *gpp = g; +} + +static void step2_make_dl(Gfx** gpp) { + Gfx* g = *gpp; + + gSPSegment(g++, G_MWO_SEGMENT_8, progressive_mode != 0 ? gam_win2_moji_model : gam_win3_moji_model); + gSPDisplayList(g++, step2_draw_dl); + + *gpp = g; +} + +static u8 menu_step; + +static void make_dl(Gfx* gfx, int size) { + Gfx* g = gfx; + + step0_make_dl(&g); + if (menu_step == 1 || menu_step == 11) { + step1_make_dl(&g); + } + else if (menu_step == 2) { + step2_make_dl(&g); + } + + gDPFullSync(g++); + gSPEndDisplayList(g++); +} + +extern void exec_dl(Gfx* gfx) { + emu64_init(); + emu64_taskstart(gfx); + emu64_cleanup(); +} + +static Z_OSTime start_time; +static u32 button; +static u32 trigger; +static int frame_count; +static Z_OSTime limit_time; +static int select_done; +static u8 menu_sub_frame; + +extern void keycheck() { + Z_OSTime now = osGetTime(); + Z_OSTime delta = now - start_time; + u32 t; + u32 error; + + JC_JUTGamePad_read(); + button = JW_JUTGamepad_getButton(); + t = JW_JUTGamepad_getTrigger(); + trigger = t; + trigger |= (((t >> 16) | (t >> 24)) & 0xF); + error = JW_JUTGamepad_getErrorStatus(); + + if (pad_good_frame_count < 0 && error == 0) { + pad_good_frame_count = frame_count; + } + + if (menu_step == 0) { + if ((button == B || OSGetProgressiveMode()) && VIGetDTVStatus()) { + progressive_mode = VIGetDTVStatus(); + menu_step = 1; + start_time = now; + limit_time = button == B ? INITIAL_MENU_LIMIT_TIME : INITIAL_MENU_LIMIT_TIME; // 10 second limit + } + else { + if (limit_time < delta) { + menu_step = 3; + select_done = TRUE; + start_time = now; + } + } + } + else if (menu_step == 1) { + if ((trigger & A) != 0 || limit_time < delta) { + OSSetProgressiveMode(progressive_mode); + start_time = now; + menu_step = 11; + menu_sub_frame = 0; + } + else { + if ((trigger & DPAD_LEFT)) { + progressive_mode = TRUE; + start_time = now; + limit_time = INITIAL_MENU_LIMIT_TIME; + } + else { + if ((trigger & DPAD_RIGHT)) { + progressive_mode = FALSE; + start_time = now; + limit_time = INITIAL_MENU_LIMIT_TIME; + } + } + } + } + else if (menu_step == 11) { + switch (menu_sub_frame) { + case 0: + { + JC_JFWDisplay_startFadeOut(JC_JFWDisplay_getManager(), 10); + break; + } + + case 5: + { + JW_SetProgressiveMode(progressive_mode); + break; + } + + case 105: + { + JC_JFWDisplay_startFadeIn(JC_JFWDisplay_getManager(), 15); + start_time = now; + menu_step = 2; + break; + } + } + + menu_sub_frame++; + } + else { + if (menu_step == 2 && INITIAL_MENU_SELECT_WAIT_TIME < delta) { + menu_step = 3; + select_done = TRUE; + start_time = now; + } + } +} + +static OSMessageQueue commandQ; +static int fadeout_step; +static int load_game_done; +static Gfx gfxbuf[16]; +static OSMessageQueue statusQ; +static OSThread* Thread_p; +static void* initialMenuStack; +static OSMessage commandMsgBuf[2]; +static OSMessage statusMsgBuf[1]; + +extern void proc(void* arg) { + u32 msg; + int proc_done; + OSTimer timer; + + osRecvMesg(&commandQ, (OSMessage*)&msg, OS_MESSAGE_BLOCK); + progressive_mode = FALSE; + fadeout_step = 0; + menu_step = 0; + select_done = FALSE; + load_game_done = FALSE; + start_time = osGetTime(); + limit_time = OSMicrosecondsToTicks(5000000ull); + pad_good_frame_count = -1; + frame_count = 0; + + do { + if (OSGetResetSwitchState()) { + __osResetSwitchPressed = TRUE; + } + else { + if (__osResetSwitchPressed) { + osShutdownStart(OS_RESET_RESTART); + } + } + + if (!osRecvMesg(&commandQ, (OSMessage*)&msg, OS_MESSAGE_NOBLOCK)) { + if (msg == INITIAL_MENU_OSMESG_FADEOUT_STEP) { + fadeout_step = 2; + } + + if (msg == INITIAL_MENU_OSMESG_LOAD_GAME_DONE) { + load_game_done = TRUE; + } + } + + if (fadeout_step == 0 && select_done && load_game_done) { + fadeout_step = 1; + osSetTimer(&timer, OSMicrosecondsToTicks(533312ull), 0, &commandQ, (OSMessage)INITIAL_MENU_OSMESG_FADEOUT_STEP); + JC_JFWDisplay_startFadeOut(JC_JFWDisplay_getManager(), 32); + } + + if ((menu_step != 0 && menu_step != 3) || dvderr_draw() == FALSE) { + JW_BeginFrame(); + keycheck(); + make_dl(gfxbuf, 16); + exec_dl(gfxbuf); + JW_EndFrame(); + frame_count++; + } + + proc_done = FALSE; + if (fadeout_step == 2 && select_done && load_game_done) { + proc_done = TRUE; + } + } while (!proc_done); + + osSendMesg(&statusQ, (OSMessage)msg, OS_MESSAGE_NOBLOCK); // signal done +} + +static void* my_alloc(size_t size) { + return JW_Alloc(size, 32); +} + +static void my_free(void* ptr) { + JW_Free(ptr); +} + +extern void initial_menu_init() { + Thread_p = (OSThread*)my_alloc(sizeof(OSThread)); + initialMenuStack = my_alloc(INITIAL_MENU_STACK_SIZE); + if (Thread_p == NULL || initialMenuStack == NULL) { + OSReport("initial_menu_init: Memory insufficiency.\n"); + my_free(Thread_p); + Thread_p = NULL; + my_free(initialMenuStack); + initialMenuStack = NULL; + } + else { + osCreateMesgQueue(&commandQ, commandMsgBuf, 2); + osCreateMesgQueue(&statusQ, statusMsgBuf, 1); + osCreateThread2(Thread_p, 1, &proc, NULL, (void*)((int)initialMenuStack + INITIAL_MENU_STACK_SIZE), INITIAL_MENU_STACK_SIZE, 1); + osStartThread(Thread_p); + JC_JFWDisplay_startFadeIn(JC_JFWDisplay_getManager(), 32); + osSendMesg(&commandQ, (OSMessage)INITIAL_MENU_OSMESG_INIT_DONE, OS_MESSAGE_NOBLOCK); + } +} + +extern void initial_menu_cleanup() { + int msg; + + if (Thread_p != NULL) { + if (!osRecvMesg(&commandQ, (OSMessage*)&msg, OS_MESSAGE_NOBLOCK)) { + osSendMesg(&commandQ, (OSMessage)INITIAL_MENU_OSMESG_LOAD_GAME_DONE, OS_MESSAGE_NOBLOCK); + osRecvMesg(&statusQ, (OSMessage*)&msg, OS_MESSAGE_BLOCK); + } + + osDestroyThread(Thread_p); + } + + JW_SetLogoMode(0); + JC_JFWDisplay_startFadeIn(JC_JFWDisplay_getManager(), 32); + my_free(Thread_p); + Thread_p = NULL; + my_free(initialMenuStack); + initialMenuStack = NULL; +} diff --git a/tools/prepareasset.py b/tools/prepareasset.py new file mode 100644 index 00000000..bff41f49 --- /dev/null +++ b/tools/prepareasset.py @@ -0,0 +1,71 @@ +# TODO: this program is slightly messed up. It can output the wrong end address for symbols. Will fix later. Use with caution until then. + +import argparse +from ruamel.yaml import YAML, comments + +class HexInt(int): + def __new__(cls, *args, **kwargs): + return super().__new__(cls, *args, **kwargs) + +def hexint_presenter(dumper, data): + return dumper.represent_scalar('tag:yaml.org,2002:int', hex(data)) + +def find_symbol_and_append(input_string, config_file_path, src_path="config/symbols.yml", dest_path="config/assets.yml"): + yaml = YAML() + yaml.representer.add_representer(HexInt, hexint_presenter) + + # Load the symbols file + with open(src_path, 'r') as symbols_file: + symbols_data = yaml.load(symbols_file) + + # Search for the input string and store its address along with the next address + address_pair = [] + found_symbol = False + for section, data in symbols_data.items(): + for address, name in data.items(): + if found_symbol: + address_pair.append(HexInt(address)) + break + if name == input_string: + found_symbol = True + address_pair.append(HexInt(address)) + if found_symbol: + break + + # If the input string was found, append it to the assets file + if address_pair: + # Make the pair yaml friendly + address_pair = comments.CommentedSeq(address_pair) + address_pair.fa.set_flow_style() + + # Load the assets file + with open(dest_path, 'r') as assets_file: + assets_data = yaml.load(assets_file) + + # If the file is empty, initialize a new dict + if assets_data is None: + assets_data = {} + + # Create entry or update existing entry under the config file path + if config_file_path not in assets_data: + assets_data[config_file_path] = {} + + if input_string in assets_data[config_file_path]: + assets_data[config_file_path][input_string]['addrs'] = address_pair + else: + assets_data[config_file_path][input_string] = {'addrs': address_pair} + + # Write back to the assets file + with open(dest_path, 'w') as assets_file: + yaml.dump(assets_data, assets_file) + +def main(): + parser = argparse.ArgumentParser(description='Search for a symbol in a YAML file and append to another YAML file.') + parser.add_argument('input_string', help='The symbol name to search for.') + parser.add_argument('config_file_path', help='The path of the configuration file.') + + args = parser.parse_args() + find_symbol_and_append(args.input_string, args.config_file_path) + +if __name__ == '__main__': + main()