diff options
| author | MegaMech <MegaMech@users.noreply.github.com> | 2024-05-05 13:51:12 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-05 13:51:12 -0600 |
| commit | 9195394e7a7ca94943230e1e1a136c84453dbd5c (patch) | |
| tree | b0d25940643b61771ac284d1f73e25b8bc5873ec | |
| parent | 95079ffd232dc8835678a73b5bbc2f015e662658 (diff) | |
Fix tkmk00 textures (#13)
* Updated Torch
* Fixes
| -rw-r--r-- | src/code_80091750.c | 55 | ||||
| -rw-r--r-- | src/data/data_segment2.c | 1 | ||||
| m--------- | tools/torch | 0 |
3 files changed, 33 insertions, 23 deletions
diff --git a/src/code_80091750.c b/src/code_80091750.c index 43a0fe2ed..47a71b659 100644 --- a/src/code_80091750.c +++ b/src/code_80091750.c @@ -2556,10 +2556,10 @@ void func_80094C60(void) { case START_MENU: // todo: figure this out. add_8018D9E0_entry(2, 0, 0, 4); - //add_8018D9E0_entry(1, 0, 0, 0); + add_8018D9E0_entry(1, 0, 0, 0); add_8018D9E0_entry(0x000000FB, 0, 0, 0); if (gControllerBits & 1) { - //add_8018D9E0_entry(3, 0, 0, 2); + add_8018D9E0_entry(3, 0, 0, 2); } else { add_8018D9E0_entry(4, 0, 0, 2); } @@ -3406,7 +3406,7 @@ Gfx *func_800987D0(Gfx *displayListHead, u32 arg1, u32 arg2, u32 width, u32 heig G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 5, 5, G_TX_NOLOD, G_TX_NOLOD); temp_f6 = (temp_f18 * ((temp_f0 * (column - 0xA0)) + (temp_f24 * (row - 0x78)))) + 160.0f; temp_f4_2 = (temp_f18 * ((-temp_f24 * (column - 0xA0)) + (temp_f0 * (row - 0x78)))) + 120.0f; - gSPTextureRectangle(displayListHead++, temp_f6 * 4, temp_f4_2 * 4, ((temp_f6 + 0x20)^0) * 4, ((temp_f4_2 + 0x20)^0) * 4, 0, 0, 0, 1024, 1024); + gSPTextureRectangle(displayListHead++, temp_f6 * 4, temp_f4_2 * 4, ((temp_f6 + 0x20)^0) * 4, ((temp_f4_2 + 0x20)) * 4, 0, 0, 0, 1024, 1024); column += 0x20; } column = columnCopy; @@ -3544,7 +3544,6 @@ void func_80099184(MkTexture *arg0) { UNUSED s32 temp_s3; MkTexture *texture = arg0; UNUSED struct_8018E118_entry *thing; - while (texture->textureData != NULL) { var_a1 = 0; for (var_v0 = 0; var_v0 < gNumD_8018E118Entries; var_v0++) { @@ -3566,15 +3565,14 @@ void func_80099184(MkTexture *arg0) { } //dma_copy_base_729a30(texture->textureData, var_a1_2, D_8018D9B4); //mio0decode(D_8018D9B4, (u8*)&D_8018D9B0[gD_8018E118TotalSize]); - // * 2 here is just a guess + // * 2 here is just a guess memcpy(&D_8018D9B0[gD_8018E118TotalSize], texture->textureData, texture->height * texture->width * 2); } else { //dma_copy_base_729a30(texture->textureData, texture->height * texture->width * 2, &D_8018D9B0[gD_8018E118TotalSize]); - // * 2 here is just a guess + // * 2 here is just a guess memcpy(&D_8018D9B0[gD_8018E118TotalSize], texture->textureData, texture->height * texture->width * 2); } - thing = &D_8018E118[gNumD_8018E118Entries]; thing->textureData = texture->textureData; thing = &D_8018E118[gNumD_8018E118Entries]; @@ -3587,7 +3585,6 @@ void func_80099184(MkTexture *arg0) { //texture++; break; } - printf("DID IT FAIL HERE?!?!?!?\n"); } #else GLOBAL_ASM("asm/non_matchings/code_80091750/func_80099184.s") @@ -3651,7 +3648,7 @@ void func_8009952C(MkTexture *arg0) { var_a1 = 0; for (var_v0 = 0; var_v0 < gNumD_8018E118Entries; var_v0++) { // wtf is going on here? - if (D_8018E118[var_v0^0].textureData == (*var_s1).textureData) { + if (D_8018E118[var_v0].textureData == (*var_s1).textureData) { var_a1 = 1; break; } @@ -3659,7 +3656,7 @@ void func_8009952C(MkTexture *arg0) { if (var_a1 == 0) { //dma_copy_base_729a30(var_s1->textureData, 0x00008000U, D_8018D9B4); //mio0decode(D_8018D9B4, (u8*)&D_8018D9B0[gD_8018E118TotalSize]); - memcpy(&D_8018D9B0[gD_8018E118TotalSize], D_8018D9B4, var_s1->width * var_s1->height); + memcpy(&D_8018D9B0[gD_8018E118TotalSize], var_s1->textureData, var_s1->width * var_s1->height * 2); thing = &D_8018E118[gNumD_8018E118Entries]; thing->textureData = var_s1->textureData; @@ -3693,6 +3690,13 @@ void func_800996BC(MkTexture *arg0, s32 arg1) { struct_8018E118_entry *thing; texture = segmented_to_virtual_dupe(arg0); + + size_t siz = texture->width * texture->height; + // for (size_t i = 0; i < siz; i++) { + // printf(" 0x%llX", texture->textureData[i]); + // } + + // Because it's loading an mkTexture. The second element in the array is usually all zeros. // Despite this loop, it's usually only ran once. while (texture->textureData != NULL) { @@ -3713,6 +3717,7 @@ void func_800996BC(MkTexture *arg0, s32 arg1) { if ((var_a1_2 % 8)) { var_a1_2 = (((var_a1_2 / 8) * 8) + 8); } + printf("a1: %d\n",var_a1_2); switch (arg1) { /* irregular */ case -1: case 1: @@ -3727,6 +3732,8 @@ void func_800996BC(MkTexture *arg0, s32 arg1) { case -1: /* switch 1 */ case 1: /* switch 1 */ //mio0decode(D_8018D9B4, (u8*)&D_8018D9B0[gD_8018E118TotalSize]); + //printf("w: %d, h: %d", texture->width, texture->height); + memcpy(&D_8018D9B0[gD_8018E118TotalSize], texture->textureData, texture->width * texture->height*2); break; case 0: /* switch 1 */ case 2: /* switch 1 */ @@ -3738,11 +3745,10 @@ void func_800996BC(MkTexture *arg0, s32 arg1) { if (1) {} //D_8018D9B0[gD_8018E118TotalSize] = &gTextureBackgroundBlueSky; //tkmk00decode(D_8018D9B4, texture->textureData, (u8*)&D_8018D9B0[gD_8018E118TotalSize], var_v0_2); + memcpy(&D_8018D9B0[gD_8018E118TotalSize], texture->textureData, texture->width * texture->height * 2); break; } - memcpy(&D_8018D9B0[gD_8018E118TotalSize], texture->textureData, texture->height * texture->width); - thing = &D_8018E118[gNumD_8018E118Entries]; thing->textureData = texture->textureData; thing = &D_8018E118[gNumD_8018E118Entries]; @@ -3776,7 +3782,7 @@ void func_80099958(MkTexture *arg0, s32 arg1, s32 arg2) { } //dma_copy_base_729a30(temp_v0->textureData, var_a1, D_8018D9B4); //mio0decode(D_8018D9B4, D_802BFB80.arraySize4[arg2][arg1 / 2][(arg1 % 2) + 2].pixel_index_array); - memcpy(D_802BFB80.arraySize4[arg2][arg1 / 2][(arg1 % 2) + 2].pixel_index_array, D_8018D9B4, temp_v0->width * temp_v0->height); + memcpy(D_802BFB80.arraySize4[arg2][arg1 / 2][(arg1 % 2) + 2].pixel_index_array, temp_v0->textureData, temp_v0->width * temp_v0->height * 2); temp_v0++; } } @@ -3857,7 +3863,7 @@ void func_80099AEC(void) { //osPiStartDma(&sp68, 0, 0, (uintptr_t)&_textures_0aSegmentRomStart[SEGMENT_OFFSET(temp_s2->textureData)], D_8018D9B4 + sp60*4, var_s0, &gDmaMesgQueue); } //mio0decode(D_8018D9B4, (u8*)&D_8018D9B0[D_8018E118[var_s1->unk_4].offset]); - memcpy(&D_8018D9B0[D_8018E118[var_s1->unk_4].offset], temp_s2->textureData, temp_s2->width * temp_s2->height); + memcpy(&D_8018D9B0[D_8018E118[var_s1->unk_4].offset], temp_s2->textureData, temp_s2->width * temp_s2->height * 2); var_s1->texture = NULL; var_s1++; @@ -3879,9 +3885,8 @@ void func_80099AEC(void) { osInvalDCache(D_8018D9B4, var_s0); //osPiStartDma(&sp68, 0, 0, (uintptr_t)&_textures_0aSegmentRomStart[SEGMENT_OFFSET(temp_s2->textureData)], D_8018D9B4, var_s0, &gDmaMesgQueue); } - mio0decode(D_8018D9B4 + sp60*4, (u8*)&D_8018D9B0[D_8018E118[var_s1->unk_4].offset]); - // todo: memcpy can't figure out width/height for now. - //memcpy(&D_8018D9B0[D_8018E118[var_s1->unk_4].offset], D_8018D9B4 + sp60 * 4, var_s1->width * var_s1->height, ); + //mio0decode(D_8018D9B4 + sp60*4, (u8*)&D_8018D9B0[D_8018E118[var_s1->unk_4].offset]); + memcpy(&D_8018D9B0[D_8018E118[var_s1->unk_4].offset], temp_s2->textureData, temp_s2->width * temp_s2->height * 2); var_s1->texture = NULL; var_s1++; if (var_s4 != 0) break; @@ -3962,7 +3967,9 @@ void func_80099EC4(void) { osInvalDCache(D_8018D9B4 + 0x1400, var_s0); //osPiStartDma(&sp68, 0, 0, (uintptr_t)&_textures_0aSegmentRomStart[SEGMENT_OFFSET(temp_s2->textureData)], D_8018D9B4 + 0x1400, var_s0, &gDmaMesgQueue); } - mio0decode(D_8018D9B4, D_802BFB80.arraySize4[var_s1->unk6][var_s1->unk4 / 2][(var_s1->unk4 % 2) + 2].pixel_index_array); + //mio0decode(D_8018D9B4, D_802BFB80.arraySize4[var_s1->unk6][var_s1->unk4 / 2][(var_s1->unk4 % 2) + 2].pixel_index_array); + //! todo: Confirm if temp_s2->textureData should be ++temp_s2->textureData + memcpy(D_802BFB80.arraySize4[var_s1->unk6][var_s1->unk4 / 2][(var_s1->unk4 % 2) + 2].pixel_index_array, temp_s2->textureData, temp_s2->width * temp_s2->height * 2); var_s1->mk64Texture = NULL; var_s1++; if (var_s4 != 0) break; @@ -3983,7 +3990,9 @@ void func_80099EC4(void) { osInvalDCache(D_8018D9B4, var_s0); //osPiStartDma(&sp68, 0, 0, (uintptr_t)&_textures_0aSegmentRomStart[SEGMENT_OFFSET(temp_s2->textureData)], D_8018D9B4, var_s0, &gDmaMesgQueue); } - mio0decode(D_8018D9B4 + 0x1400, D_802BFB80.arraySize4[var_s1->unk6][var_s1->unk4 / 2][(var_s1->unk4 % 2) + 2].pixel_index_array); + //! todo: Confirm if temp_s2->textureData should be ++temp_s2->textureData + //mio0decode(D_8018D9B4 + 0x1400, D_802BFB80.arraySize4[var_s1->unk6][var_s1->unk4 / 2][(var_s1->unk4 % 2) + 2].pixel_index_array); + memcpy(D_802BFB80.arraySize4[var_s1->unk6][var_s1->unk4 / 2][(var_s1->unk4 % 2) + 2].pixel_index_array, temp_s2->textureData, temp_s2->width * temp_s2->height * 2); var_s1->mk64Texture = NULL; var_s1++; if (var_s4 != 0) break; @@ -4008,8 +4017,8 @@ void func_8009A238(MkTexture *arg0, s32 arg1) { } //dma_copy_base_7fa3c0(sp24, var_a3, D_8018D9B4); //tkmk00decode(D_8018D9B4, D_8018D9B8, (u8*) &D_8018D9B0[temp_v1], 1); - memcpy(&D_8018D9B0[temp_v1], sp24, arg0->height * arg0->width); - D_8018E118[arg1].textureData = sp24; + memcpy(&D_8018D9B0[temp_v1], arg0->textureData, arg0->height * arg0->width * 2); + D_8018E118[arg1].textureData = arg0->textureData; } void func_8009A2F0(struct_8018E0E8_entry *arg0) { @@ -5514,7 +5523,7 @@ void add_8018D9E0_entry(s32 type, s32 column, s32 row, s8 priority) { // ???????? // Credit to Vetri for the idea to mess around with this loop // to fix the issue near the 0xD4 case - while (1 & 0xFFFFFFFFFFFFFFFF) { + while (1) { var_v0++; if (var_ra->type == 0) break; @@ -5618,7 +5627,7 @@ void add_8018D9E0_entry(s32 type, s32 column, s32 row, s8 priority) { case 0x2: func_8006EE44(); gD_8018E118TotalSize += 0x10000; - //func_80099184(D_020045E8); + func_80099184(D_020045E8); break; case 0x3: func_80099184(D_02004610); diff --git a/src/data/data_segment2.c b/src/data/data_segment2.c index 54e98c666..602a05a86 100644 --- a/src/data/data_segment2.c +++ b/src/data/data_segment2.c @@ -3,6 +3,7 @@ #include <libultra/gbi.h> #include "data_segment2.h" #include <assets/startup_logo.h> +#include <assets/common_data.h> Gfx D_02007650[] = { gsDPPipeSync(), diff --git a/tools/torch b/tools/torch -Subproject d24b5b3193e170b1e1153d5568827e00dfde556 +Subproject 45e6853e315933d57a0e7213a2d5590fb74f628 |
