From 1c4efad6d313718ed86c3302230c62507b635d08 Mon Sep 17 00:00:00 2001 From: Banjo Kazooie Date: Sun, 17 Jul 2022 19:13:20 -0500 Subject: [PATCH] core2/gczoombox.c done --- progress/progress_core1.svg | 6 +- progress/progress_core2.svg | 6 +- progress/progress_total.svg | 6 +- src/core1/code_8C50.c | 2 +- src/core1/code_9D30.c | 114 ++++++++++++++++++++++++++++++++---- src/core2/code_5BEB0.c | 6 +- src/core2/gc/zoombox.c | 98 ++++++++++--------------------- subyaml/core2.us.v10.yaml | 7 +-- 8 files changed, 148 insertions(+), 97 deletions(-) diff --git a/progress/progress_core1.svg b/progress/progress_core1.svg index d43aa0fe..106b7921 100644 --- a/progress/progress_core1.svg +++ b/progress/progress_core1.svg @@ -9,7 +9,7 @@ - + @@ -17,7 +17,7 @@ core1 - 69.9776% - 69.9776% + 70.3700% + 70.3700% \ No newline at end of file diff --git a/progress/progress_core2.svg b/progress/progress_core2.svg index 06f9bc16..f101bca5 100644 --- a/progress/progress_core2.svg +++ b/progress/progress_core2.svg @@ -9,7 +9,7 @@ - + @@ -17,7 +17,7 @@ core2 - 73.1304% - 73.1304% + 73.6289% + 73.6289% \ No newline at end of file diff --git a/progress/progress_total.svg b/progress/progress_total.svg index e9e4269f..4366ac35 100644 --- a/progress/progress_total.svg +++ b/progress/progress_total.svg @@ -9,7 +9,7 @@ - + @@ -17,7 +17,7 @@ Banjo-Kazooie (us.v10) - 79.1959% - 79.1959% + 79.5388% + 79.5388% \ No newline at end of file diff --git a/src/core1/code_8C50.c b/src/core1/code_8C50.c index 493742e7..b422e55a 100644 --- a/src/core1/code_8C50.c +++ b/src/core1/code_8C50.c @@ -217,8 +217,8 @@ void func_80246C2C(void){ #ifndef NONMATCHING //MATCHES but requires .data defined for local static variable #pragma GLOBAL_ASM("asm/nonmatchings/core1/code_8C50/func_80246D78.s") #else -static s32 D_802759A4; void func_80246D78(void){ + static s32 D_802759A4; s32 sp2C = (D_8027FC0C != 0) && (D_8028062C == D_80280628) && (D_8027FC18 == 2) && (D_8027FC1C == 0x10); volatile s32 sp30; diff --git a/src/core1/code_9D30.c b/src/core1/code_9D30.c index e28f5c3a..0447826b 100644 --- a/src/core1/code_9D30.c +++ b/src/core1/code_9D30.c @@ -2,8 +2,13 @@ #include "functions.h" #include "variables.h" -void func_8024A840(s32 arg0, s32 arg1, s32 arg2); -void func_8024A85C(s32 arg0); +void func_8024A3C8(s32 x, s32 y); +void func_8024A840(s32 r, s32 g, s32 b); +void func_8024A85C(s32 buffer_indx); + + +extern s32 D_80276588; //framebuffer width +extern s16 D_803A5D00[2][0xF660]; //framebuffer extern s16 D_80275BBC; @@ -143,29 +148,114 @@ s32 func_802485BC(void){ #pragma GLOBAL_ASM("asm/nonmatchings/core1/code_9D30/func_80249F34.s") -#pragma GLOBAL_ASM("asm/nonmatchings/core1/code_9D30/func_8024A284.s") +//fill framebuffer with vert and horz lines +void func_8024A284(s32 x, s32 y, s32 arg2, s32 arg3, s32 horz_spacing, s32 vert_spacing) { + s32 var_s2; + s32 var_s3; -#pragma GLOBAL_ASM("asm/nonmatchings/core1/code_9D30/func_8024A3C8.s") + for(var_s2 = 0; var_s2 < D_80276588; var_s2 += horz_spacing){ + for(var_s3 = 0; var_s3 < D_8027658C; var_s3++){ + func_8024A3C8(x + var_s2, y + var_s3); -#pragma GLOBAL_ASM("asm/nonmatchings/core1/code_9D30/func_8024A490.s") + } + } + for(var_s3 = 0; var_s3 < D_8027658C; var_s3 += vert_spacing) { + for(var_s2 = 0; var_s2 < D_80276588; var_s2++){ + func_8024A3C8(x + var_s2, y + var_s3); + } + } +} +//fills in pixel in frame buffer with D_802806E0 color +void func_8024A3C8(s32 x, s32 y) { + s32 temp_v0; + + if (x >= 0) { + if ((x < D_80276588) && (y >= 0) && (y < D_8027658C)) { + D_803A5D00[D_802806EC][x + y * D_80276588] = _SHIFTL(D_802806E0 >> 3, 11, 5) | _SHIFTL(D_802806E4 >> 3, 6, 5) | _SHIFTL(D_802806E8 >> 3, 1, 5) | _SHIFTL(1, 0, 1); + } + } +} + +//draw rectangular outline +void func_8024A490(s32 x, s32 y, s32 w, s32 h) { + s32 var_s1; + + for(var_s1 = 0; var_s1 < w; var_s1++){ + func_8024A3C8(x + var_s1, y); + func_8024A3C8(x + var_s1, y + h - 1); + } + for(var_s1 = 1; var_s1 < h - 1; var_s1++){ + func_8024A3C8(x, y + var_s1); + func_8024A3C8(x + w - 1, y + var_s1); + } +} + +#ifndef NONMATCHING #pragma GLOBAL_ASM("asm/nonmatchings/core1/code_9D30/func_8024A564.s") +#else +void func_8024A564(s32 x, s32 y, u16 *arg2, s32 arg3, s32 arg4, f32 arg5, f32 arg6) { + s32 temp_a2; + s32 temp_a2_2; + s32 temp_a2_3; + s32 temp_f6; + s32 temp_f6_2; + s32 temp_lo; + s32 temp_t5; + s32 var_a0; + s32 var_a2; + s32 var_t1; + s32 var_t3; + s32 var_v0; + s32 var_v1; + u16 temp_t8; + s16 *var_t0; + s16 *var_t2; -#pragma GLOBAL_ASM("asm/nonmatchings/core1/code_9D30/func_8024A770.s") + var_v0 = 0; + var_v1 = D_80276588; + var_t0 = &D_803A5D00[D_802806EC][x + y * D_80276588]; + for( var_t1 = (arg4 * arg6) + 0.5; var_t1 != 0; var_t1--){ + var_a2 = ((var_v0 >> 8) * arg3) << 8; + var_t2 = var_t0; + var_v0 += (s32) ((f64) (256.0f / arg6) + 0.5); + for(var_t3 = (arg3 * arg5) + 0.5; var_t3 != 0; var_t3--){ + *var_t2 = arg2[var_a2 >> 8]; + var_a2 += (s32) ((f64) (256.0f / arg5) + 0.5); + var_t2++; + } + var_t0 += D_80276588; + } +} +#endif + +//fills in rectangle in frame buffer with D_802806E0 color +void func_8024A770(s32 x, s32 y, s32 w, s32 h) { + s32 var_s0; + s32 var_s1; + s32 var_s4; + + var_s4 = 0; + for(var_s4 = 0; var_s4 < w; var_s4++) { + for(var_s0 = 0; var_s0 < h; var_s0++){ + func_8024A3C8(x + var_s4, y + var_s0); + } + } +} void func_8024A810(void){ func_8024A840(0, 0x80, 0); func_8024A85C(0); } -void func_8024A840(s32 arg0, s32 arg1, s32 arg2){ - D_802806E0 = arg0; - D_802806E4 = arg1; - D_802806E8 = arg2; +void func_8024A840(s32 r, s32 g, s32 b){ + D_802806E0 = r; + D_802806E4 = g; + D_802806E8 = b; } -void func_8024A85C(s32 arg0){ - D_802806EC = arg0; +void func_8024A85C(s32 buffer_indx){ + D_802806EC = buffer_indx; } s32 func_8024A868(void){ diff --git a/src/core2/code_5BEB0.c b/src/core2/code_5BEB0.c index 2c077857..67dc0987 100644 --- a/src/core2/code_5BEB0.c +++ b/src/core2/code_5BEB0.c @@ -46,7 +46,7 @@ typedef struct map_savestate_s{ extern MapSavestate *D_8037E650[]; -void func_802E3BD0(s32 arg0); +void func_802E3BD0(s32 frame_buffer_indx); int func_802E49F0(void); /* .code */ @@ -268,8 +268,8 @@ void func_802E39D0(Gfx **gdl, Mtx **mptr, Vtx **vptr, s32 arg3, s32 arg4){ osWritebackDCache(v_start, sizeof(Vtx)*( *vptr - v_start)); } -void func_802E3BD0(s32 arg0){ - func_8024A85C(arg0); +void func_802E3BD0(s32 frame_buffer_indx){ + func_8024A85C(frame_buffer_indx); } void func_802E3BF0(void){ diff --git a/src/core2/gc/zoombox.c b/src/core2/gc/zoombox.c index a548bf17..442338d7 100644 --- a/src/core2/gc/zoombox.c +++ b/src/core2/gc/zoombox.c @@ -578,8 +578,7 @@ void func_80316764(gczoombox_t *this, s32 arg1) { if (this->unk186 > 0) { this->unk186--; } else { - // if (randf() < 0.01) { /* USE ONCE .RODATA DEFINED */ - if (randf() < D_803788F0) { + if (randf() < 0.01) { this->unk1A4_22 = TRUE; this->unk186 = this->unk188 - 4; } @@ -670,9 +669,6 @@ s32 func_80316ED4(u8 *arg0){ return strlen(arg0); } -#ifndef NONMATCHING //matches requires .rodata which requires gczoombox_new() matching -#pragma GLOBAL_ASM("asm/nonmatchings/core2/gc/zoombox/func_80316EF4.s") -#else void func_80316EF4(gczoombox_t *this){ s32 sp58[6]; s32 sp4C[3]; @@ -956,7 +952,6 @@ void func_80316EF4(gczoombox_t *this){ break; } } -#endif //_gczoombox_loadSprite void func_80317C90(gczoombox_t *this, s32 portrait_id){ @@ -998,11 +993,10 @@ void func_80317D10(gczoombox_t *this, s32 portrait_id){ } } -#ifdef NONMATCHING gczoombox_t *gczoombox_new(s32 arg0, s32 portrait_id, s32 arg2, s32 arg3, void (*arg4)(s32, s32)){ gczoombox_t *this; s32 i; - s32 temp_v1_2; + s32 temp_v1; this = (gczoombox_t *)malloc(sizeof(gczoombox_t)); this->unk130 = arg4; @@ -1032,67 +1026,38 @@ gczoombox_t *gczoombox_new(s32 arg0, s32 portrait_id, s32 arg2, s32 arg3, void ( this->unk174 = 0x25; this->unk170 = -0x66; } - this->unk18A = 0; - this->unk189 = 0; - this->unk187 = 0; - this->unk186 = 0; - this->unk185 = 0; - this->unk181 = 0; - this->unk180 = 0; this->unk172 = this->unk164; + this->unk181 =\ + this->unk185 =\ + this->unk186 =\ + this->unk187 =\ + this->unk189 =\ + this->unk18A = 0; + this->unk180 = 0; this->unk18C = 0.0f; this->unk194 = 0.999f; - // this->unk194 = D_80378938; this->unk198 = 1.0f; this->unk19C = 0.0f; - this->unk1A0 = 0.0333333f; - // this->unk1A0 = D_8037893C; - - // this->unk1A4_31 = \ - // this->unk1A4_30 = \ - // this->unk1A4_29 = \ - // this->unk1A4_28 = \ - // this->unk1A4_27 = \ - // this->unk1A4_26 = \ - // this->unk1A4_25 = \ - // this->unk1A4_23 = \ - // this->unk1A4_22 = \ - // this->unk1A4_21 = \ - // this->unk1A4_20 = \ - // this->unk1A4_17 = \ - // this->unk1A4_16 = \ - // this->unk1A4_15 = \ - // this->unk1A4_14 = \ - // this->unk1A4_13 = \ - // 0; - - // this->unk1A4_11 = this->unk1A4_18 = 1; - - - this->unk1A4_25 = \ - this->unk1A4_23 = \ - this->unk1A4_22 = \ - this->unk1A4_21 = \ - this->unk1A4_20 = \ - this->unk1A4_17 = \ - this->unk1A4_16 = \ - this->unk1A4_15 = \ - this->unk1A4_14 = \ - this->unk1A4_13 = FALSE; - - temp_v1_2 = this->unk1A4_13; - - - - this->unk1A4_31 = \ - this->unk1A4_30 = \ - this->unk1A4_29 = \ - this->unk1A4_28 = \ - this->unk1A4_27 = \ - this->unk1A4_26 = temp_v1_2; - - this->unk1A4_18 = TRUE; - this->unk1A4_11 = this->unk1A4_18; + this->unk1A0 = 0.0333333351f; + + this->unk1A4_31 =\ + this->unk1A4_30 =\ + this->unk1A4_29 =\ + this->unk1A4_28 =\ + this->unk1A4_27 =\ + this->unk1A4_26 =\ + this->unk1A4_25 =\ + this->unk1A4_23 =\ + this->unk1A4_22 =\ + this->unk1A4_21 =\ + this->unk1A4_20 =\ + this->unk1A4_17 =\ + this->unk1A4_16 =\ + this->unk1A4_15 =\ + this->unk1A4_14 =\ + this->unk1A4_13 = 0; + + this->unk1A4_11 = this->unk1A4_18 = 1; this->unkF0 = assetcache_get(0x89d); func_80317C90(this, portrait_id); @@ -1116,11 +1081,8 @@ gczoombox_t *gczoombox_new(s32 arg0, s32 portrait_id, s32 arg2, s32 arg3, void ( _gczoombox_memClear( &this->unk60, 0x30); _gczoombox_memClear( &this->unk90, 0x20); _gczoombox_memClear( &this->unkB0, 0x40); - return this; + return this; } -#else -#pragma GLOBAL_ASM("asm/nonmatchings/core2/gc/zoombox/gczoombox_new.s") -#endif bool func_80318284(gczoombox_t *this, s32 arg1, u8 **arg2) { s32 phi_v0; diff --git a/subyaml/core2.us.v10.yaml b/subyaml/core2.us.v10.yaml index 25dc50bf..f040ff39 100644 --- a/subyaml/core2.us.v10.yaml +++ b/subyaml/core2.us.v10.yaml @@ -290,7 +290,7 @@ segments: - [0x87E30, c, code_87E30] - [0x8A7B0, c, gc/pauseMenu] - [0x8DC20, c, code_8DC20] - - [0x8E270, c, gc/zoombox] + - [0x8E270, c, gc/zoombox] #DONE - [0x91E10, c, code_91E10] - [0x935F0, c, code_935F0] - [0x93C10, c, code_93C10] @@ -733,9 +733,8 @@ segments: - [0xF14C0, .rodata, gc/transition] - [0xF1520, .rodata, code_85800] - [0xF1540, bin, data_F1540] - # - [0xF18F0, .rodata, gc/zoombox] - - [0xF1900, .rodata, gc/zoombox] - - [0xF1960, bin, data_F1960] + - [0xF18F0, .rodata, gc/zoombox] + # - [0xF1960, bin, data_F1960] - [0xF19C0, .rodata, code_91E10] - [0xF1A00, bin, data_F1A00] - [0xF1DC0, .rodata, code_9A9D0]