From bd00e0d1da2cf316d40654e4b5c743edd9532d06 Mon Sep 17 00:00:00 2001 From: Random <28494085+Random0666@users.noreply.github.com> Date: Sun, 22 Mar 2020 17:37:38 +0100 Subject: Decompiled z_sample.c `z_sample.c` : 1 non matching left --- src/code/z_sample.c | 114 ++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 107 insertions(+), 7 deletions(-) (limited to 'src/code/z_sample.c') diff --git a/src/code/z_sample.c b/src/code/z_sample.c index 441d8451a..3c8f31f69 100644 --- a/src/code/z_sample.c +++ b/src/code/z_sample.c @@ -1,17 +1,117 @@ #include #include +#include -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sample/func_800975D0.s") +void Sample_Calc(SampleContext* this) +{ + if (!~(this->state.input[0].padPressed | ~START_BUTTON)) + { + this->state.init = func_800BCA64; this->state.size = sizeof(GlobalContext); + this->state.running = false; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sample/func_80097604.s") +// very close from matching, the only difference is the place of "mtx" in the stack +#ifdef NON_MATCHING +void Sample_Draw(SampleContext* this) +{ + u32 pad; + GraphicsContext* gfxCtx = this->state.gfxCtx; + View* view = &this->view; + Gfx* gfxArr[4]; + Mtx* mtx; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sample/func_80097820.s") + func_800C6AC4(gfxArr, gfxCtx, "../z_sample.c", 62); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sample/func_80097848.s") + gSPSegment(gfxCtx->polyOpa.p++, 0, 0); + gSPSegment(gfxCtx->polyOpa.p++, 1, this->staticSegment); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sample/func_80097850.s") + func_80095248(gfxCtx, 0, 0, 0); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sample/func_80097904.s") + view->unk_120 = 7; + func_800AAA50(view, 15); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sample/func_80097974.s") + mtx = Graph_Alloc(gfxCtx, sizeof(Mtx)); + func_80103D58(mtx, SREG(37), SREG(38), SREG(39), 1.0f, SREG(40), SREG(41), SREG(42)); + gSPMatrix(gfxCtx->polyOpa.p++, mtx, G_MTX_LOAD); + gfxCtx->polyOpa.p = func_80093708(gfxCtx->polyOpa.p, 0xFF, 0xFF, 0xFF, 0, 0, 0); + func_80093D18(gfxCtx); + + gDPSetCycleType(gfxCtx->polyOpa.p++, G_CYC_1CYCLE); + gDPSetRenderMode(gfxCtx->polyOpa.p++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); + gDPSetCombineLERP(gfxCtx->polyOpa.p++, 0, 0, 0, PRIMITIVE, 0, 0, 0, PRIMITIVE, 0, 0, 0, PRIMITIVE, 0, 0, 0, PRIMITIVE); + gDPSetPrimColor(gfxCtx->polyOpa.p++, 0, 0, 0xFF, 0xFF, 0x00, 0x00); + + func_800C6B54(gfxArr, gfxCtx, "../z_sample.c", 111); +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/code/z_sample/Sample_Draw.s") +#endif + +void Sample_Update(SampleContext* this) +{ + Sample_Draw(this); + Sample_Calc(this); +} + +void Sample_Destroy(SampleContext* this) +{ + +} + +void Sample_SetupView(SampleContext* this) +{ + View* view; + GraphicsContext* gfxCtx; + u32 v0[4]; + Vec3f v1; + Vec3f v2; + Vec3f v3; + + view = &this->view; + gfxCtx = this->state.gfxCtx; + func_800AA278(view, gfxCtx); + + v0[1] = SCREEN_HEIGHT; v0[3] = SCREEN_WIDTH; + v0[0] = 0; + v0[2] = 0; + + func_800AA4FC(view, &v0); + func_800AA460(view, 60, 10, 12800); + + v1.x = 0; + v1.y = 0; + v2.x = 0; + v2.y = 0; + v2.z = 0; + v3.x = 0; + v3.z = 0; + v1.z = 3000; + v3.y = 1; + + func_800AA358(view, &v1, &v2, &v3); +} + +void Sample_LoadTitleStatic(SampleContext* this) +{ + u32 size = (u32)(_title_staticSegmentRomEnd - _title_staticSegmentRomStart); + + this->staticSegment = Game_Alloc(&this->state, size, "../z_sample.c", 163); + DmaMgr_SendRequest1(this->staticSegment, _title_staticSegmentRomStart, size, "../z_sample.c", 164); +} + +void Sample_Init(SampleContext* this) +{ + this->state.main = Sample_Update; + this->state.destroy = Sample_Destroy; + R_UPDATE_RATE = 1; + Sample_SetupView(this); + Sample_LoadTitleStatic(this); + SREG(37) = 0; + SREG(38) = 0; + SREG(39) = 0; + SREG(40) = 0; + SREG(41) = 0; + SREG(42) = 0; +} -- cgit v1.2.3 From 0db4629a63bca63a1cd913c2d07f887dcf974228 Mon Sep 17 00:00:00 2001 From: Random <28494085+Random0666@users.noreply.github.com> Date: Sun, 22 Mar 2020 19:32:44 +0100 Subject: Update PR #22 minor fixes --- src/code/z_sample.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/code/z_sample.c') diff --git a/src/code/z_sample.c b/src/code/z_sample.c index 3c8f31f69..eb29dc475 100644 --- a/src/code/z_sample.c +++ b/src/code/z_sample.c @@ -23,7 +23,7 @@ void Sample_Draw(SampleContext* this) func_800C6AC4(gfxArr, gfxCtx, "../z_sample.c", 62); - gSPSegment(gfxCtx->polyOpa.p++, 0, 0); + gSPSegment(gfxCtx->polyOpa.p++, 0, NULL; gSPSegment(gfxCtx->polyOpa.p++, 1, this->staticSegment); func_80095248(gfxCtx, 0, 0, 0); @@ -95,7 +95,7 @@ void Sample_SetupView(SampleContext* this) void Sample_LoadTitleStatic(SampleContext* this) { - u32 size = (u32)(_title_staticSegmentRomEnd - _title_staticSegmentRomStart); + u32 size = _title_staticSegmentRomEnd - _title_staticSegmentRomStart; this->staticSegment = Game_Alloc(&this->state, size, "../z_sample.c", 163); DmaMgr_SendRequest1(this->staticSegment, _title_staticSegmentRomStart, size, "../z_sample.c", 164); -- cgit v1.2.3 From 251aea64ab3e6e8cd6f1d9ed34f514e656724777 Mon Sep 17 00:00:00 2001 From: Roman971 Date: Wed, 18 Mar 2020 22:18:25 +0100 Subject: Add comments and macros to prevent match issues with formatting --- src/code/z_sample.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/code/z_sample.c') diff --git a/src/code/z_sample.c b/src/code/z_sample.c index eb29dc475..9aaf1db51 100644 --- a/src/code/z_sample.c +++ b/src/code/z_sample.c @@ -6,7 +6,7 @@ void Sample_Calc(SampleContext* this) { if (!~(this->state.input[0].padPressed | ~START_BUTTON)) { - this->state.init = func_800BCA64; this->state.size = sizeof(GlobalContext); + SET_NEXT_GAMESTATE(&this->state, func_800BCA64, GlobalContext); this->state.running = false; } } @@ -73,9 +73,10 @@ void Sample_SetupView(SampleContext* this) gfxCtx = this->state.gfxCtx; func_800AA278(view, gfxCtx); + // clang-format off v0[1] = SCREEN_HEIGHT; v0[3] = SCREEN_WIDTH; - v0[0] = 0; - v0[2] = 0; + v0[0] = 0; v0[2] = 0; + // clang-format on func_800AA4FC(view, &v0); func_800AA460(view, 60, 10, 12800); -- cgit v1.2.3 From 8cfe7cce9f8d8abea794e67510879e751d373a87 Mon Sep 17 00:00:00 2001 From: Roman971 Date: Sun, 22 Mar 2020 22:19:43 +0100 Subject: Format all src C files --- src/code/z_sample.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) (limited to 'src/code/z_sample.c') diff --git a/src/code/z_sample.c b/src/code/z_sample.c index 9aaf1db51..cbd934701 100644 --- a/src/code/z_sample.c +++ b/src/code/z_sample.c @@ -2,10 +2,8 @@ #include #include -void Sample_Calc(SampleContext* this) -{ - if (!~(this->state.input[0].padPressed | ~START_BUTTON)) - { +void Sample_Calc(SampleContext* this) { + if (!~(this->state.input[0].padPressed | ~START_BUTTON)) { SET_NEXT_GAMESTATE(&this->state, func_800BCA64, GlobalContext); this->state.running = false; } @@ -13,8 +11,7 @@ void Sample_Calc(SampleContext* this) // very close from matching, the only difference is the place of "mtx" in the stack #ifdef NON_MATCHING -void Sample_Draw(SampleContext* this) -{ +void Sample_Draw(SampleContext* this) { u32 pad; GraphicsContext* gfxCtx = this->state.gfxCtx; View* view = &this->view; @@ -49,19 +46,15 @@ void Sample_Draw(SampleContext* this) #pragma GLOBAL_ASM("asm/non_matchings/code/z_sample/Sample_Draw.s") #endif -void Sample_Update(SampleContext* this) -{ +void Sample_Update(SampleContext* this) { Sample_Draw(this); Sample_Calc(this); } -void Sample_Destroy(SampleContext* this) -{ - +void Sample_Destroy(SampleContext* this) { } -void Sample_SetupView(SampleContext* this) -{ +void Sample_SetupView(SampleContext* this) { View* view; GraphicsContext* gfxCtx; u32 v0[4]; @@ -94,16 +87,14 @@ void Sample_SetupView(SampleContext* this) func_800AA358(view, &v1, &v2, &v3); } -void Sample_LoadTitleStatic(SampleContext* this) -{ +void Sample_LoadTitleStatic(SampleContext* this) { u32 size = _title_staticSegmentRomEnd - _title_staticSegmentRomStart; - + this->staticSegment = Game_Alloc(&this->state, size, "../z_sample.c", 163); DmaMgr_SendRequest1(this->staticSegment, _title_staticSegmentRomStart, size, "../z_sample.c", 164); } -void Sample_Init(SampleContext* this) -{ +void Sample_Init(SampleContext* this) { this->state.main = Sample_Update; this->state.destroy = Sample_Destroy; R_UPDATE_RATE = 1; -- cgit v1.2.3