From 5a29612c4a75fc89d773f9ebeb8a930608d2fd1a Mon Sep 17 00:00:00 2001 From: Banjo Kazooie Date: Fri, 29 Jul 2022 23:16:01 -0500 Subject: [PATCH] core2/code_C0CF0.c done --- progress/progress_core2.svg | 6 +- progress/progress_total.svg | 4 +- src/core2/code_C0CF0.c | 278 +++--------------------------------- src/core2/code_C0E60.c | 261 +++++++++++++++++++++++++++++++++ subyaml/core2.us.v10.yaml | 3 +- 5 files changed, 291 insertions(+), 261 deletions(-) create mode 100644 src/core2/code_C0E60.c diff --git a/progress/progress_core2.svg b/progress/progress_core2.svg index aefdcc8c..ace5963a 100644 --- a/progress/progress_core2.svg +++ b/progress/progress_core2.svg @@ -9,7 +9,7 @@ - + @@ -17,7 +17,7 @@ core2 - 75.5318% - 75.5318% + 75.5725% + 75.5725% \ No newline at end of file diff --git a/progress/progress_total.svg b/progress/progress_total.svg index 680502b8..2577081f 100644 --- a/progress/progress_total.svg +++ b/progress/progress_total.svg @@ -17,7 +17,7 @@ Banjo-Kazooie (us.v10) - 80.7531% - 80.7531% + 80.7765% + 80.7765% \ No newline at end of file diff --git a/src/core2/code_C0CF0.c b/src/core2/code_C0CF0.c index f3c67932..26ef4624 100644 --- a/src/core2/code_C0CF0.c +++ b/src/core2/code_C0CF0.c @@ -2,269 +2,37 @@ #include "functions.h" #include "variables.h" -#define rare_gDPLoadMultiBlock(pkt, timg, tmem, rtile, fmt, siz, width, height, \ - uls, ult, \ - pal, cms, cmt, masks, maskt, shifts, shiftt) \ -{ \ - gDPSetTextureImage(pkt, fmt, siz##_LOAD_BLOCK, 1, timg); \ - gDPSetTile(pkt, fmt, siz##_LOAD_BLOCK, 0, tmem, G_TX_LOADTILE, 0,\ - cmt, maskt, shiftt, cms, masks, shifts); \ - gDPLoadSync(pkt); \ - gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, \ - (((width)*(height) + siz##_INCR) >> siz##_SHIFT)-1, \ - CALC_DXT(width, siz##_BYTES)); \ - gDPPipeSync(pkt); \ - gDPSetTile(pkt, fmt, siz, (((width) * siz##_LINE_BYTES)+7)>>3, \ - tmem, rtile, pal, cmt, \ - maskt, shiftt, cms, masks, shifts); \ - gDPSetTileSize(pkt, rtile, \ - (uls)<>2)-1, \ - CALC_DXT_4b(width)); \ - gDPPipeSync(pkt); \ - gDPSetTile(pkt, fmt, G_IM_SIZ_4b, ((((width)>>1)+7)>>3), tmem, \ - rtile, pal, cmt, maskt, shiftt, cms, masks, \ - shifts); \ - gDPSetTileSize(pkt, rtile, \ - (uls)<position, 0); + actor->unk54 = 3.0f; + func_803333DC(arg0, actor); +} -#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_C0CF0/func_80347CC8.s") +void func_80347CC8(Struct81s *arg0){ + func_802C3C88((GenMethod_1)func_80347C80, reinterpret_cast(s32, arg0)); +} -#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_C0CF0/func_80347CF4.s") +void func_80347CF4(Struct81s *arg0) { + Actor *sp1C; + Actor *temp_v0; -#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_C0CF0/func_80347DD0.s") - -#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_C0CF0/func_80347DE4.s") - -#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_C0CF0/func_80347DF0.s") - -#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_C0CF0/func_80347E34.s") - -#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_C0CF0/func_80347E60.s") - -void func_80347FA4(s32 arg0, s32 arg1, s32 arg2, s32 tmem){} - -void func_80347FB8(s32 arg0){} - -#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_C0CF0/func_80347FC0.s") - -#ifndef NONMATCHING -#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_C0CF0/func_80348044.s") -#else -void func_80348044(Gfx **gfx, BKSprite* sprite, s32 frame, s32 tmem, s32 rtile, s32 arg5, s32 arg6, s32 cms, s32 cmt, s32 *width, s32 *height, s32 *argB, s32 *argC, s32 *argD, s32 *argE, s32 *argF) { - s32 sp144; - s32 temp_a2; - BKSpriteFrame *temp_v0; - s32 palette_addr; - BKSpriteTextureBlock *var_v1; - s32 timg; - s32 var_a0; - s32 chunk_count; - s32 masks; - s32 var_v0; - s32 maskt; - - temp_v0 = spriteGetFramePtr(sprite, frame); - *argB = (s32) temp_v0->w; - *argC = (s32) temp_v0->h; - if (*argF == -1) { - *argF = (s32) temp_v0->chunkCnt; - } - (*argF)--; - chunk_count = *argF; - if (sprite->type & SPRITE_TYPE_CI4) { - for(palette_addr = (s32)(temp_v0 + 1); palette_addr % 8; palette_addr++); - gDPSetTextureLUT((*gfx)++, G_TT_RGBA16); - gDPLoadTLUT_pal16((*gfx)++, 0, palette_addr); - D_803860B0 = TRUE; - D_803860B4 = 0; - D_80386074 = NULL; - D_8038607C = 0; - D_80386098 = 0; - } else if (sprite->type & SPRITE_TYPE_CI8) { - gDPPipelineMode((*gfx)++, G_PM_1PRIMITIVE); - for(palette_addr = (s32)(temp_v0 + 1); palette_addr % 8; palette_addr++); - D_803860B0 = TRUE; - D_803860B4 = 1; - D_80386074 = NULL; - D_8038607C = 0; - var_v1 = palette_addr + 0x200; - D_80386098 = 0; - for(var_a0 = 0; var_a0 < chunk_count; var_a0++) { - var_v1 = (s32)var_v1 + (var_v1->w * var_v1->h) + sizeof(BKSpriteTextureBlock); + sp1C = marker_getActor(arg0->marker); + if (sp1C->unk54 > 0.0) { + if (randf() < ((sp1C->unk54 / 3.0) * 2)) { + func_8033E73C(arg0->marker, 5, func_80329904); + func_8033E3F0(0xF, ((ActorMarker *)arg0->marker)->unk14_21); } - *argD = var_v1->x; - *argE = var_v1->y; - gDPSetTextureLUT((*gfx)++, G_TT_RGBA16); - gDPLoadTLUT_pal256((*gfx)++, palette_addr); - } else { - D_803860B0 = FALSE; - var_v1 = temp_v0 + 0x14; - } - - if ((D_8038607C == 0) || (tmem == D_80386078)) { - D_80386078 = tmem; - D_80386070 = temp_v0; - D_80386080 = arg5; - D_80386084 = arg6; - sp144 = 0; - D_80386088 = rtile; - } else { - D_80386094 = tmem; - D_80386074 = temp_v0; - D_8038609C = arg5; - D_803860A0 = arg6; - sp144 = 1; - D_803860A4 = rtile; - } - - *width = (s32) var_v1->w; - *height = (s32) var_v1->h; - for(timg = (s32)(var_v1 + 1); timg % 8; timg++); - - if (sp144 == 0) { - D_8038608C = *width; - D_80386090 = *height; - D_8038607C = D_8038608C * D_80386090; - } else { - D_803860A8 = *width; - D_803860AC = *height; - D_80386098 = D_803860A8 * D_803860AC; - } - - var_v0 = *width - 1; - if ((*width & 7) == 0) { - masks = 0; - while (var_v0 != 0) { - masks++; - var_v0 >>= 1; - } - } else { - masks = 0; - } - - var_v0 = *height - 1; - if ((*height & 7) == 0) { - maskt = 0; - while (var_v0 != 0) { - maskt++; - var_v0 >>= 1; - } - } else { - maskt = 0; - } - - if ( sprite->type & SPRITE_TYPE_I4) { - rare_gDPLoadMultiBlock_4b((*gfx)++, timg, tmem, rtile, G_IM_FMT_I, *width, *height, arg5, arg6, 0, cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); - if (sp144 == 0) { - D_8038607C = (s32) D_8038607C >> 4; - } else { - D_80386098 = (s32) D_80386098 >> 4; - } - } else if (sprite->type & SPRITE_TYPE_IA4) { - rare_gDPLoadMultiBlock_4b((*gfx)++, timg, tmem, rtile, G_IM_FMT_IA, *width, *height, arg5, arg6, 0, cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); - if (sp144 == 0) { - D_8038607C = (s32) D_8038607C >> 4; - } else { - D_80386098 = (s32) D_80386098 >> 4; - } - } else if (sprite->type & SPRITE_TYPE_I8) { - rare_gDPLoadMultiBlock((*gfx)++, timg, tmem, rtile, G_IM_FMT_I, G_IM_SIZ_8b, *width, *height, arg5, arg6, 0, cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); - if (sp144 == 0) { - D_8038607C = (s32) D_8038607C >> 3; - } else { - D_80386098 = (s32) D_80386098 >> 3; - } - } else if (sprite->type & SPRITE_TYPE_IA8) { - rare_gDPLoadMultiBlock((*gfx)++, timg, tmem, rtile, G_IM_FMT_IA, G_IM_SIZ_8b, *width, *height, arg5, arg6, 0, cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); - if (sp144 == 0) { - D_8038607C = (s32) D_8038607C >> 3; - } else { - D_80386098 = (s32) D_80386098 >> 3; - } - } else if (sprite->type & SPRITE_TYPE_RGBA16) { - rare_gDPLoadMultiBlock((*gfx)++, timg, tmem, rtile, G_IM_FMT_RGBA, G_IM_SIZ_16b, *width, *height, arg5, arg6, 0, cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); - if (sp144 == 0) { - D_8038607C = (s32) D_8038607C >> 2; - } else { - D_80386098 = (s32) D_80386098 >> 2; - } - } else if (sprite->type & SPRITE_TYPE_RGBA32) { - rare_gDPLoadMultiBlock((*gfx)++, timg, tmem, rtile, G_IM_FMT_RGBA, G_IM_SIZ_32b, *width, *height, arg5, arg6, 0, cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); - if (sp144 == 0) { - D_8038607C = (s32) D_8038607C >> 1; - } else { - D_80386098 = (s32) D_80386098 >> 1; - } - } else if (sprite->type & SPRITE_TYPE_CI4) { - rare_gDPLoadMultiBlock((*gfx)++, timg, tmem, rtile, G_IM_FMT_CI, G_IM_SIZ_4b, *width, *height, arg5, arg6, 0, cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); - D_8038607C = D_8038607C >> 4; - } else if (sprite->type & SPRITE_TYPE_CI8) { - rare_gDPLoadMultiBlock((*gfx)++, timg, tmem, rtile, G_IM_FMT_CI, G_IM_SIZ_8b, *width, *height, arg5, arg6, 0, cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); - D_8038607C = (s32) D_8038607C >> 3; - } - - if ((D_8038607C != 0) && (D_80386098 != 0) && (D_80386094 < (D_80386078 + D_8038607C))) { - D_80386074 = NULL; - D_80386098 = 0; + sp1C->unk54 -= time_getDelta(); } } -#endif -#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_C0CF0/func_80349AD0.s") +void func_80347DD0(Struct81s * arg0, Gfx **gfx, Mtx** mtx, Vtx **vtx) +{} -void func_80349B1C(Gfx **gfx) { - void *temp_v1; - void *temp_v1_2; - void *temp_v1_3; - - if (D_803860B0) { - gDPPipeSync((*gfx)++); - gDPSetTextureLUT((*gfx)++, G_TT_NONE); - D_803860B0 = FALSE; - if (D_803860B4) { - gDPPipelineMode((*gfx)++, G_PM_NPRIMITIVE); - D_803860B4 = FALSE; - } - } -} +void func_80347DE4(Struct81s * arg0) +{} diff --git a/src/core2/code_C0E60.c b/src/core2/code_C0E60.c new file mode 100644 index 00000000..1eb9283f --- /dev/null +++ b/src/core2/code_C0E60.c @@ -0,0 +1,261 @@ +#include +#include "functions.h" +#include "variables.h" + + +#define rare_gDPLoadMultiBlock(pkt, timg, tmem, rtile, fmt, siz, width, height, \ + uls, ult, \ + pal, cms, cmt, masks, maskt, shifts, shiftt) \ +{ \ + gDPSetTextureImage(pkt, fmt, siz##_LOAD_BLOCK, 1, timg); \ + gDPSetTile(pkt, fmt, siz##_LOAD_BLOCK, 0, tmem, G_TX_LOADTILE, 0,\ + cmt, maskt, shiftt, cms, masks, shifts); \ + gDPLoadSync(pkt); \ + gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, \ + (((width)*(height) + siz##_INCR) >> siz##_SHIFT)-1, \ + CALC_DXT(width, siz##_BYTES)); \ + gDPPipeSync(pkt); \ + gDPSetTile(pkt, fmt, siz, (((width) * siz##_LINE_BYTES)+7)>>3, \ + tmem, rtile, pal, cmt, \ + maskt, shiftt, cms, masks, shifts); \ + gDPSetTileSize(pkt, rtile, \ + (uls)<>2)-1, \ + CALC_DXT_4b(width)); \ + gDPPipeSync(pkt); \ + gDPSetTile(pkt, fmt, G_IM_SIZ_4b, ((((width)>>1)+7)>>3), tmem, \ + rtile, pal, cmt, maskt, shiftt, cms, masks, \ + shifts); \ + gDPSetTileSize(pkt, rtile, \ + (uls)<w; + *argC = (s32) temp_v0->h; + if (*argF == -1) { + *argF = (s32) temp_v0->chunkCnt; + } + (*argF)--; + chunk_count = *argF; + if (sprite->type & SPRITE_TYPE_CI4) { + for(palette_addr = (s32)(temp_v0 + 1); palette_addr % 8; palette_addr++); + gDPSetTextureLUT((*gfx)++, G_TT_RGBA16); + gDPLoadTLUT_pal16((*gfx)++, 0, palette_addr); + D_803860B0 = TRUE; + D_803860B4 = 0; + D_80386074 = NULL; + D_8038607C = 0; + D_80386098 = 0; + } else if (sprite->type & SPRITE_TYPE_CI8) { + gDPPipelineMode((*gfx)++, G_PM_1PRIMITIVE); + for(palette_addr = (s32)(temp_v0 + 1); palette_addr % 8; palette_addr++); + D_803860B0 = TRUE; + D_803860B4 = 1; + D_80386074 = NULL; + D_8038607C = 0; + var_v1 = palette_addr + 0x200; + D_80386098 = 0; + for(var_a0 = 0; var_a0 < chunk_count; var_a0++) { + var_v1 = (s32)var_v1 + (var_v1->w * var_v1->h) + sizeof(BKSpriteTextureBlock); + } + *argD = var_v1->x; + *argE = var_v1->y; + gDPSetTextureLUT((*gfx)++, G_TT_RGBA16); + gDPLoadTLUT_pal256((*gfx)++, palette_addr); + } else { + D_803860B0 = FALSE; + var_v1 = temp_v0 + 0x14; + } + + if ((D_8038607C == 0) || (tmem == D_80386078)) { + D_80386078 = tmem; + D_80386070 = temp_v0; + D_80386080 = arg5; + D_80386084 = arg6; + sp144 = 0; + D_80386088 = rtile; + } else { + D_80386094 = tmem; + D_80386074 = temp_v0; + D_8038609C = arg5; + D_803860A0 = arg6; + sp144 = 1; + D_803860A4 = rtile; + } + + *width = (s32) var_v1->w; + *height = (s32) var_v1->h; + for(timg = (s32)(var_v1 + 1); timg % 8; timg++); + + if (sp144 == 0) { + D_8038608C = *width; + D_80386090 = *height; + D_8038607C = D_8038608C * D_80386090; + } else { + D_803860A8 = *width; + D_803860AC = *height; + D_80386098 = D_803860A8 * D_803860AC; + } + + var_v0 = *width - 1; + if ((*width & 7) == 0) { + masks = 0; + while (var_v0 != 0) { + masks++; + var_v0 >>= 1; + } + } else { + masks = 0; + } + + var_v0 = *height - 1; + if ((*height & 7) == 0) { + maskt = 0; + while (var_v0 != 0) { + maskt++; + var_v0 >>= 1; + } + } else { + maskt = 0; + } + + if ( sprite->type & SPRITE_TYPE_I4) { + rare_gDPLoadMultiBlock_4b((*gfx)++, timg, tmem, rtile, G_IM_FMT_I, *width, *height, arg5, arg6, 0, cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); + if (sp144 == 0) { + D_8038607C = (s32) D_8038607C >> 4; + } else { + D_80386098 = (s32) D_80386098 >> 4; + } + } else if (sprite->type & SPRITE_TYPE_IA4) { + rare_gDPLoadMultiBlock_4b((*gfx)++, timg, tmem, rtile, G_IM_FMT_IA, *width, *height, arg5, arg6, 0, cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); + if (sp144 == 0) { + D_8038607C = (s32) D_8038607C >> 4; + } else { + D_80386098 = (s32) D_80386098 >> 4; + } + } else if (sprite->type & SPRITE_TYPE_I8) { + rare_gDPLoadMultiBlock((*gfx)++, timg, tmem, rtile, G_IM_FMT_I, G_IM_SIZ_8b, *width, *height, arg5, arg6, 0, cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); + if (sp144 == 0) { + D_8038607C = (s32) D_8038607C >> 3; + } else { + D_80386098 = (s32) D_80386098 >> 3; + } + } else if (sprite->type & SPRITE_TYPE_IA8) { + rare_gDPLoadMultiBlock((*gfx)++, timg, tmem, rtile, G_IM_FMT_IA, G_IM_SIZ_8b, *width, *height, arg5, arg6, 0, cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); + if (sp144 == 0) { + D_8038607C = (s32) D_8038607C >> 3; + } else { + D_80386098 = (s32) D_80386098 >> 3; + } + } else if (sprite->type & SPRITE_TYPE_RGBA16) { + rare_gDPLoadMultiBlock((*gfx)++, timg, tmem, rtile, G_IM_FMT_RGBA, G_IM_SIZ_16b, *width, *height, arg5, arg6, 0, cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); + if (sp144 == 0) { + D_8038607C = (s32) D_8038607C >> 2; + } else { + D_80386098 = (s32) D_80386098 >> 2; + } + } else if (sprite->type & SPRITE_TYPE_RGBA32) { + rare_gDPLoadMultiBlock((*gfx)++, timg, tmem, rtile, G_IM_FMT_RGBA, G_IM_SIZ_32b, *width, *height, arg5, arg6, 0, cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); + if (sp144 == 0) { + D_8038607C = (s32) D_8038607C >> 1; + } else { + D_80386098 = (s32) D_80386098 >> 1; + } + } else if (sprite->type & SPRITE_TYPE_CI4) { + rare_gDPLoadMultiBlock((*gfx)++, timg, tmem, rtile, G_IM_FMT_CI, G_IM_SIZ_4b, *width, *height, arg5, arg6, 0, cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); + D_8038607C = D_8038607C >> 4; + } else if (sprite->type & SPRITE_TYPE_CI8) { + rare_gDPLoadMultiBlock((*gfx)++, timg, tmem, rtile, G_IM_FMT_CI, G_IM_SIZ_8b, *width, *height, arg5, arg6, 0, cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); + D_8038607C = (s32) D_8038607C >> 3; + } + + if ((D_8038607C != 0) && (D_80386098 != 0) && (D_80386094 < (D_80386078 + D_8038607C))) { + D_80386074 = NULL; + D_80386098 = 0; + } +} +#endif + +#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_C0E60/func_80349AD0.s") + +void func_80349B1C(Gfx **gfx) { + void *temp_v1; + void *temp_v1_2; + void *temp_v1_3; + + if (D_803860B0) { + gDPPipeSync((*gfx)++); + gDPSetTextureLUT((*gfx)++, G_TT_NONE); + D_803860B0 = FALSE; + if (D_803860B4) { + gDPPipelineMode((*gfx)++, G_PM_NPRIMITIVE); + D_803860B4 = FALSE; + } + } +} diff --git a/subyaml/core2.us.v10.yaml b/subyaml/core2.us.v10.yaml index 25656203..77623b3a 100644 --- a/subyaml/core2.us.v10.yaml +++ b/subyaml/core2.us.v10.yaml @@ -341,7 +341,8 @@ segments: - [0xBDCC0, c, code_BDCC0] #DONE - [0xBE2C0, c, code_BE2C0] - [0xBEF20, c, code_BEF20] - - [0xC0CF0, c, code_C0CF0] + - [0xC0CF0, c, code_C0CF0] #DONE + - [0xC0E60, c, code_C0E60] - [0xC2C20, c, code_C2C20] #DONE - [0xC2F30, c, code_C2F30] #DONE - [0xC31A0, c, code_C31A0] #DONE