From a6934f720596023ef5e33eada705803fc11a18dd Mon Sep 17 00:00:00 2001 From: Banjo Kazooie Date: Tue, 25 Oct 2022 21:12:12 -0500 Subject: [PATCH] core2/code_CD6E0.C done --- README.md | 2 +- progress/progress_core2.svg | 4 +- progress/progress_total.svg | 4 +- remaining | 2 + src/core1/code_9D30.c | 63 +++++++++++++ src/core2/code_50490.c | 4 - src/core2/code_5DBC0.c | 2 +- src/core2/code_B6EA0.h | 8 +- src/core2/code_CD6E0.c | 178 +++++++++++++++++++++++++----------- subyaml/core2.us.v10.yaml | 2 +- 10 files changed, 200 insertions(+), 69 deletions(-) create mode 100644 remaining diff --git a/README.md b/README.md index 8339813c..3921868e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# banjo (91.7705%) +# banjo (91.8246%) diff --git a/progress/progress_core2.svg b/progress/progress_core2.svg index 39230ed1..c9add18d 100644 --- a/progress/progress_core2.svg +++ b/progress/progress_core2.svg @@ -17,7 +17,7 @@ core2 - 89.8876% - 89.8876% + 89.9820% + 89.9820% \ No newline at end of file diff --git a/progress/progress_total.svg b/progress/progress_total.svg index 5fcd66e6..7ea7f956 100644 --- a/progress/progress_total.svg +++ b/progress/progress_total.svg @@ -17,7 +17,7 @@ Banjo-Kazooie (us.v10) - 91.7705% - 91.7705% + 91.8246% + 91.8246% \ No newline at end of file diff --git a/remaining b/remaining new file mode 100644 index 00000000..f4298921 --- /dev/null +++ b/remaining @@ -0,0 +1,2 @@ + +./src/FP/code_5CC0.c:#pragma GLOBAL_ASM("asm/nonmatchings/FP/code_5CC0/func_8038C428.s") diff --git a/src/core1/code_9D30.c b/src/core1/code_9D30.c index b58a957a..1736f26e 100644 --- a/src/core1/code_9D30.c +++ b/src/core1/code_9D30.c @@ -362,7 +362,70 @@ void func_802485C8(UNK_TYPE(s32) arg0){ } //BREAK? +#ifndef NONMATCHING #pragma GLOBAL_ASM("asm/nonmatchings/core1/code_9D30/draw_sprite_ci4.s") +#else +void draw_sprite_ci4(s32 x, s32 y, BKSprite *sprite, s32 frame, s32 alpha_enabled) { + BKSpriteFrame *sprite_frame; + u16 *palette; + s32 fb_y; + s32 fb_x; + s32 iy; + s32 i_chunk; + s32 ix; + u8 *tmem; + BKSpriteTextureBlock *chunk; + u16 *pxl_ptr; + u16 *framebuffer; + s32 indx1; + s32 indx2; + s32 color1; + s32 color2; + + framebuffer = D_803A5D00[D_802806EC]; + sprite_frame = spriteGetFramePtr(sprite, (u32) frame); + if (alpha_enabled == 0) { + set_prim_color(0, 0, 0x80); + draw_prim_rect(x, y, sprite_frame->w, sprite_frame->h); + } + + palette = (u16 *)(sprite_frame + 1); + for(tmem = palette; (s32)tmem % 8; tmem++); + palette = tmem; + chunk = (BKSpriteTextureBlock *)(palette + 0x10); + for(i_chunk = 0; i_chunk < sprite_frame->chunkCnt; i_chunk++){ + for(tmem = (u16 *)(chunk + 1); (s32)tmem % 8; tmem++); + + for(iy = 0; iy < chunk->h; iy++){ + for(ix = 0; ix < chunk->w; ix += 2){ + indx1 = (*tmem >> 4) & 0xF; + indx2 = (*tmem >> 0) & 0xF; + fb_x = chunk->x + x + ix; + if (0 <= fb_x && fb_x < D_80276588) { + fb_y = chunk->y + y + iy; + if ((fb_y >= 0) && (fb_y < D_8027658C)) { + pxl_ptr = framebuffer + fb_x + (fb_y * D_80276588); + color1 = palette[indx1]; + if (color1 & 1) { + *pxl_ptr = color1; + } else if (!alpha_enabled) { + *pxl_ptr = 1U; + } + color2 = palette[indx2]; + if (color2 & 1) { + *(pxl_ptr + 1) = color2; + } else if (!alpha_enabled) { + *(pxl_ptr + 1) = 1U; + } + } + } + tmem++; + } + } + chunk = (BKSpriteTextureBlock *) tmem; + } +} +#endif #pragma GLOBAL_ASM("asm/nonmatchings/core1/code_9D30/draw_sprite_ci8.s") diff --git a/src/core2/code_50490.c b/src/core2/code_50490.c index f9b574e5..cbe76148 100644 --- a/src/core2/code_50490.c +++ b/src/core2/code_50490.c @@ -54,9 +54,6 @@ Actor *func_802D745C(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx){ return marker_getActor(marker); } -#ifdef NONMATCHING -#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_50490/func_802D7484.s") -#else Actor *func_802D7484(s32 position[3], s32 yaw, ActorInfo *arg2, u32 arg3) { s32 sp3C; ActorLocal_core2_50490 * local; @@ -70,7 +67,6 @@ Actor *func_802D7484(s32 position[3], s32 yaw, ActorInfo *arg2, u32 arg3) { sp34->marker->collidable = FALSE; return sp34; } -#endif Actor * func_802D7558(s32 *arg0, s32 arg1, ActorInfo *arg2, u32 arg3) { D_80367A80 = 1.2f; diff --git a/src/core2/code_5DBC0.c b/src/core2/code_5DBC0.c index 1e06d175..9275a3b7 100644 --- a/src/core2/code_5DBC0.c +++ b/src/core2/code_5DBC0.c @@ -80,7 +80,7 @@ struct5DBC0s *func_802E4B50(void){ void func_802E4C0C(struct5DBC0_2s * arg0, u32 arg1){ // u32 i, v0; u32 v0; - while(--arg1 != 0){ + while(--arg1 > 0){ // arg1--; assetcache_release(arg0[arg1].font_bin); free(arg0[arg1].letter_texture); diff --git a/src/core2/code_B6EA0.h b/src/core2/code_B6EA0.h index a7d48f25..f4e30811 100644 --- a/src/core2/code_B6EA0.h +++ b/src/core2/code_B6EA0.h @@ -8,12 +8,8 @@ typedef s32 (*FuncUnk40)(ActorMarker *, s32, f32[3]); typedef struct particle_struct_0_s{ - f32 unk0; - f32 unk4; - f32 unk8; - f32 unkC; - f32 unk10; - f32 unk14; + f32 unk0[3]; + f32 unkC[3]; u8 pad18[8]; s32 unk20; s32 unk24; diff --git a/src/core2/code_CD6E0.c b/src/core2/code_CD6E0.c index d205cb32..545e8c3a 100644 --- a/src/core2/code_CD6E0.c +++ b/src/core2/code_CD6E0.c @@ -39,14 +39,14 @@ void func_803546E8(void) { sp47 = func_8033E93C(); temp_s0 = func_8033E960(); player_getPosition(sp34); - temp_s0->unk0 = randf2(-10.0f, 10.0f); - temp_s0->unk4 = (randf() * 35.0f) + 50.0f; - temp_s0->unk8 = randf2(-10.0f, 10.0f); + temp_s0->unk0[0] = randf2(-10.0f, 10.0f); + temp_s0->unk0[1] = (randf() * 35.0f) + 50.0f; + temp_s0->unk0[2] = randf2(-10.0f, 10.0f); func_802589E4(sp28, func_8028EBA4(), 48.0f); sp28[1] = 0.0f; - temp_s0->unk0 += sp28[0]; - temp_s0->unk4 += sp28[1]; - temp_s0->unk8 += sp28[2]; + temp_s0->unk0[0] += sp28[0]; + temp_s0->unk0[1] += sp28[1]; + temp_s0->unk0[2] += sp28[2]; projectile_setSprite(sp4F, ASSET_713_SPRITE_SPARKLE_YELLOW); projectile_setPosition(sp4F, sp34); func_8033FCD8(sp4F, 0xC); @@ -84,16 +84,90 @@ void func_8035489C(void) { playerVelocity[1] = 0.0f; playerPosition[0] += playerVelocity[0] * time_getDelta(); playerPosition[2] += playerVelocity[2] * time_getDelta(); - playerPosition[0] += temp_s0->unk0; - playerPosition[1] += temp_s0->unk4; - playerPosition[2] += temp_s0->unk8; + playerPosition[0] += temp_s0->unk0[0]; + playerPosition[1] += temp_s0->unk0[1]; + playerPosition[2] += temp_s0->unk0[2]; projectile_setPosition(temp_v0, playerPosition); } } void func_80354990(void){} -#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_CD6E0/func_80354998.s") +void func_80354998(void) { + u8 sp57; + ActorMarker *sp50; + struct54s *sp4C; + u8 sp4B; + ParticleStruct0s *temp_s0; + f32 sp38[3]; + f32 sp2C[3]; + s32 sp28; + + sp57 = func_8033E8D0(); + sp50 = func_8033E864(); + sp4C = func_8033E8F4(); + sp4B = func_8033E93C(); + temp_s0 = func_8033E960(); + ml_vec3f_clear(sp38); + temp_s0->unk0[0] = randf2(-2.0f, 2.0f); + temp_s0->unk0[1] = 0.0f; + randf2(-10.0f, 10.0f); + temp_s0->unk0[2] = randf2(-2.0f, 2.0f); + temp_s0->unkC[0] = 0.0f; + temp_s0->unkC[1] = -0.05f; + temp_s0->unkC[2] = 0.0f; + func_80287E9C(sp4C); + func_80287FD0(sp4C, 3.0f); + func_80287F7C(sp4C, 3); + switch (sp50->modelId) { /* irregular */ + case 0x3BB: + sp28 = 7; + break; + case 0x3BC: + sp28 = 0xB; + break; + case 0x3C0: + case 0x551: + sp28 = 8; + break; + case 0x3C1: + sp28 = 0xA; + break; + case 0x3C2: + sp28 = 9; + break; + case 0x548: + sp28 = 5; + ml_vec3f_clear(temp_s0->unk0); + ml_vec3f_clear(temp_s0->unkC); + break; + case 0x549: + sp28 = 3; + ml_vec3f_clear(temp_s0->unk0); + ml_vec3f_clear(temp_s0->unkC); + break; + case 0x547: + sp28 = 1; + ml_vec3f_clear(temp_s0->unk0); + ml_vec3f_clear(temp_s0->unkC); + break; + default: + sp28 = 3; + ml_vec3f_clear(temp_s0->unk0); + ml_vec3f_clear(temp_s0->unkC); + break; + } + projectile_setSprite(sp57, sp28 + 0x710); + projectile_setPosition(sp57, sp38); + func_80344E18(sp4B, 3); + sp2C[0] = 0.0f; + sp2C[1] = 0.0f; + sp2C[2] = 0.0f; + func_80344E3C(sp4B, sp2C); + func_80344D94(sp4B, sp38); + temp_s0->unk20 = 0x14; + func_80354670(sp57, 0x14); +} void func_80354C18(void) { ParticleStruct0s* temp_s0; @@ -128,16 +202,16 @@ void func_80354C18(void) { projectile_getPosition(temp_s1, sp34); } func_80344E7C(sp4B, sp28); - sp28[0] += temp_s0->unkC; - sp28[1] += temp_s0->unk10; - sp28[2] += temp_s0->unk14; + sp28[0] += temp_s0->unkC[0]; + sp28[1] += temp_s0->unkC[1]; + sp28[2] += temp_s0->unkC[2]; func_80344E3C(sp4B, sp28); - temp_s0->unk0 += sp28[0]; - temp_s0->unk4 += sp28[1]; - temp_s0->unk8 += sp28[2]; - sp34[0] += temp_s0->unk0; - sp34[1] += temp_s0->unk4; - sp34[2] += temp_s0->unk8; + temp_s0->unk0[0] += sp28[0]; + temp_s0->unk0[1] += sp28[1]; + temp_s0->unk0[2] += sp28[2]; + sp34[0] += temp_s0->unk0[0]; + sp34[1] += temp_s0->unk0[1]; + sp34[2] += temp_s0->unk0[2]; projectile_setPosition(temp_s1, sp34); } func_8033FC34(temp_s1, 0xB4); @@ -160,9 +234,9 @@ void func_80354DD0(void) { sp3F = func_8033E93C(); temp_s0 = func_8033E960(); ml_vec3f_clear(sp2C); - temp_s0->unk0 = randf2(-50.0f, 50.0f); - temp_s0->unk4 = randf2(-65.0f, -65.0f); - temp_s0->unk8 = randf2(-50.0f, 50.0f); + temp_s0->unk0[0] = randf2(-50.0f, 50.0f); + temp_s0->unk0[1] = randf2(-65.0f, -65.0f); + temp_s0->unk0[2] = randf2(-50.0f, 50.0f); projectile_setSprite(temp_s1, ASSET_710_SPRITE_SPARKLE_PURPLE); func_8033FC60(temp_s1, 0xE1, 0xFF, 0); projectile_setPosition(temp_s1, sp2C); @@ -203,9 +277,9 @@ void func_80354EEC(void) { } else { func_8033FC98(temp_s1, 1); } - sp28[0] += temp_s0->unk0; - sp28[1] += temp_s0->unk4; - sp28[2] += temp_s0->unk8; + sp28[0] += temp_s0->unk0[0]; + sp28[1] += temp_s0->unk0[1]; + sp28[2] += temp_s0->unk0[2]; projectile_setPosition(temp_s1, sp28); } } @@ -228,9 +302,9 @@ void func_8035500C(void) { sp3F = func_8033E93C(); temp_s0 = func_8033E960(); ml_vec3f_clear(sp2C); - temp_s0->unk0 = randf2(-40.0f, 40.0f); - temp_s0->unk4 = randf2(-40.0f, 40.0f); - temp_s0->unk8 = randf2(-40.0f, 40.0f); + temp_s0->unk0[0] = randf2(-40.0f, 40.0f); + temp_s0->unk0[1] = randf2(-40.0f, 40.0f); + temp_s0->unk0[2] = randf2(-40.0f, 40.0f); projectile_setSprite(sp47, 0x70F); func_8033FC60(sp47, 0xFF, 0xE6, 0xF5); projectile_setPosition(sp47, sp2C); @@ -269,10 +343,10 @@ void func_80355134(void) { func_80354670(temp_s1, temp_s0->unk20); if (temp_s0->unk20 >= 0x13) { sp38(sp3C, sp34, sp28); - temp_s0->unk4 -= time_getDelta() * 200.0f; - sp28[0] += temp_s0->unk0; - sp28[1] += temp_s0->unk4; - sp28[2] += temp_s0->unk8; + temp_s0->unk0[1] -= time_getDelta() * 200.0f; + sp28[0] += temp_s0->unk0[0]; + sp28[1] += temp_s0->unk0[1]; + sp28[2] += temp_s0->unk0[2]; projectile_setPosition(temp_s1, sp28); } else { projectile_getPosition(temp_s1, sp28); @@ -299,9 +373,9 @@ void func_8035529C(void) { sp47 = func_8033E93C(); sp40 = func_8033E960(); ml_vec3f_clear(sp34); - sp40->unk0 = randf2(-40.0f, 40.0f); - sp40->unk4 = 0.0f; - sp40->unk8 = randf2(-40.0f, 40.0f); + sp40->unk0[0] = randf2(-40.0f, 40.0f); + sp40->unk0[1] = 0.0f; + sp40->unk0[2] = randf2(-40.0f, 40.0f); projectile_setSprite(sp4F, 0x70F); func_8033FC60(sp4F, randi2(0xD2, 0xFF), randi2(0xBE, 0xFF), randi2(0xC8, 0xFF)); projectile_setPosition(sp4F, sp34); @@ -340,10 +414,10 @@ void func_803553E8(void) { func_80354670(temp_s1, temp_s0->unk20); if (temp_s0->unk20 >= 0xD) { sp38(sp3C, sp34, sp28); - temp_s0->unk4 -= time_getDelta() * 40.0f; - sp28[0] += temp_s0->unk0; - sp28[1] += temp_s0->unk4; - sp28[2] += temp_s0->unk8; + temp_s0->unk0[1] -= time_getDelta() * 40.0f; + sp28[0] += temp_s0->unk0[0]; + sp28[1] += temp_s0->unk0[1]; + sp28[2] += temp_s0->unk0[2]; projectile_setPosition(temp_s1, sp28); } else { projectile_getPosition(temp_s1, sp28); @@ -371,9 +445,9 @@ void func_80355550(void) { sp37 = func_8033E93C(); sp30 = func_8033E960(); ml_vec3f_clear(sp24); - sp30->unk0 = randf2(-30.0f, 30.0f); - sp30->unk4 = randf2(-30.0f, 30.0f); - sp30->unk8 = randf2(-30.0f, 30.0f); + sp30->unk0[0] = randf2(-30.0f, 30.0f); + sp30->unk0[1] = randf2(-30.0f, 30.0f); + sp30->unk0[2] = randf2(-30.0f, 30.0f); if ((f64) randf() < 0.25) { projectile_setSprite(sp3F, ASSET_711_SPRITE_SPARKLE_DARK_BLUE); } else if ((f64) randf() < 0.5) { @@ -419,10 +493,10 @@ void func_8035570C(void) { func_80354670(temp_s1, temp_s0->unk20); if (temp_s0->unk20 >= 0x13) { sp38(sp3C, sp34, sp28); - temp_s0->unk4 -= time_getDelta() * 80.0f; - sp28[0] += temp_s0->unk0; - sp28[1] += temp_s0->unk4; - sp28[2] += temp_s0->unk8; + temp_s0->unk0[1] -= time_getDelta() * 80.0f; + sp28[0] += temp_s0->unk0[0]; + sp28[1] += temp_s0->unk0[1]; + sp28[2] += temp_s0->unk0[2]; projectile_setPosition(temp_s1, sp28); } else { projectile_getPosition(temp_s1, sp28); @@ -459,9 +533,9 @@ void func_80355864(void) { sp38[0] = sp4C->position[0]; sp38[1] = sp4C->position[1]; sp38[2] = sp4C->position[2]; - sp48->unk0 = randf2(-10.0f, 10.0f); - sp48->unk4 = (f32) ((randf() * 45.0f) + 10.0f); - sp48->unk8 = randf2(-10.0f, 10.0f); + sp48->unk0[0] = randf2(-10.0f, 10.0f); + sp48->unk0[1] = (f32) ((randf() * 45.0f) + 10.0f); + sp48->unk0[2] = randf2(-10.0f, 10.0f); projectile_setSprite(sp5F, 0x713); projectile_setPosition(sp5F, &sp38); func_8033FCD8(sp5F, 0xC); @@ -517,9 +591,9 @@ void func_80355B00(void) { sp28[0] += sp34[0] * time_getDelta(); sp28[2] += sp34[2] * time_getDelta(); - sp28[0] += sp44->unk0; - sp28[1] += sp44->unk4; - sp28[2] += sp44->unk8; + sp28[0] += sp44->unk0[0]; + sp28[1] += sp44->unk0[1]; + sp28[2] += sp44->unk0[2]; projectile_setPosition(sp43, sp28); } } diff --git a/subyaml/core2.us.v10.yaml b/subyaml/core2.us.v10.yaml index 2ffd22c5..90799fac 100644 --- a/subyaml/core2.us.v10.yaml +++ b/subyaml/core2.us.v10.yaml @@ -147,7 +147,7 @@ segments: - [0x33D40, c, code_33D40] #DONE - [0x33F90, c, code_33F90] #DONE - [0x34310, c, code_34310] #DONE - - [0x34790, c, code_34790] #DONE + - [0x34790, c, code_34790] - [0x35520, c, code_35520] #DONE - [0x356B0, c, code_356B0] #DONE - [0x379B0, c, code_379B0]