diff --git a/asm/non_matchings/code/z_fbdemo/TransitionUnk_InitData.s b/asm/non_matchings/code/z_fbdemo/TransitionUnk_InitData.s deleted file mode 100644 index c2e3126b2e..0000000000 --- a/asm/non_matchings/code/z_fbdemo/TransitionUnk_InitData.s +++ /dev/null @@ -1,54 +0,0 @@ -glabel TransitionUnk_InitData -/* B28E9C 800B1CFC 8C830004 */ lw $v1, 4($a0) -/* B28EA0 800B1D00 00001025 */ move $v0, $zero -/* B28EA4 800B1D04 24630001 */ addiu $v1, $v1, 1 -/* B28EA8 800B1D08 1860002A */ blez $v1, .L800B1DB4 -/* B28EAC 800B1D0C 00000000 */ nop -/* B28EB0 800B1D10 8C860000 */ lw $a2, ($a0) -/* B28EB4 800B1D14 24C60001 */ addiu $a2, $a2, 1 -.L800B1D18: -/* B28EB8 800B1D18 18C00022 */ blez $a2, .L800B1DA4 -/* B28EBC 800B1D1C 00002825 */ move $a1, $zero -/* B28EC0 800B1D20 00027140 */ sll $t6, $v0, 5 -/* B28EC4 800B1D24 448E2000 */ mtc1 $t6, $f4 -/* B28EC8 800B1D28 00001825 */ move $v1, $zero -/* B28ECC 800B1D2C 00003825 */ move $a3, $zero -/* B28ED0 800B1D30 46802020 */ cvt.s.w $f0, $f4 -.L800B1D34: -/* B28ED4 800B1D34 00460019 */ multu $v0, $a2 -/* B28ED8 800B1D38 44873000 */ mtc1 $a3, $f6 -/* B28EDC 800B1D3C 8C8F000C */ lw $t7, 0xc($a0) -/* B28EE0 800B1D40 24A50001 */ addiu $a1, $a1, 1 -/* B28EE4 800B1D44 46803220 */ cvt.s.w $f8, $f6 -/* B28EE8 800B1D48 01E3C021 */ addu $t8, $t7, $v1 -/* B28EEC 800B1D4C 24E70020 */ addiu $a3, $a3, 0x20 -/* B28EF0 800B1D50 0000C812 */ mflo $t9 -/* B28EF4 800B1D54 001940C0 */ sll $t0, $t9, 3 -/* B28EF8 800B1D58 03084821 */ addu $t1, $t8, $t0 -/* B28EFC 800B1D5C E5280000 */ swc1 $f8, ($t1) -/* B28F00 800B1D60 8C8C0000 */ lw $t4, ($a0) -/* B28F04 800B1D64 8C8A000C */ lw $t2, 0xc($a0) -/* B28F08 800B1D68 258D0001 */ addiu $t5, $t4, 1 -/* B28F0C 800B1D6C 004D0019 */ multu $v0, $t5 -/* B28F10 800B1D70 01435821 */ addu $t3, $t2, $v1 -/* B28F14 800B1D74 24630008 */ addiu $v1, $v1, 8 -/* B28F18 800B1D78 00007012 */ mflo $t6 -/* B28F1C 800B1D7C 000E78C0 */ sll $t7, $t6, 3 -/* B28F20 800B1D80 016FC821 */ addu $t9, $t3, $t7 -/* B28F24 800B1D84 E7200004 */ swc1 $f0, 4($t9) -/* B28F28 800B1D88 8C860000 */ lw $a2, ($a0) -/* B28F2C 800B1D8C 24C60001 */ addiu $a2, $a2, 1 -/* B28F30 800B1D90 00A6082A */ slt $at, $a1, $a2 -/* B28F34 800B1D94 1420FFE7 */ bnez $at, .L800B1D34 -/* B28F38 800B1D98 00000000 */ nop -/* B28F3C 800B1D9C 8C830004 */ lw $v1, 4($a0) -/* B28F40 800B1DA0 24630001 */ addiu $v1, $v1, 1 -.L800B1DA4: -/* B28F44 800B1DA4 24420001 */ addiu $v0, $v0, 1 -/* B28F48 800B1DA8 0043082A */ slt $at, $v0, $v1 -/* B28F4C 800B1DAC 1420FFDA */ bnez $at, .L800B1D18 -/* B28F50 800B1DB0 00000000 */ nop -.L800B1DB4: -/* B28F54 800B1DB4 03E00008 */ jr $ra -/* B28F58 800B1DB8 00000000 */ nop - diff --git a/asm/non_matchings/code/z_fbdemo/TransitionUnk_SetData.s b/asm/non_matchings/code/z_fbdemo/TransitionUnk_SetData.s deleted file mode 100644 index 4d95a62eb5..0000000000 --- a/asm/non_matchings/code/z_fbdemo/TransitionUnk_SetData.s +++ /dev/null @@ -1,76 +0,0 @@ -glabel TransitionUnk_SetData -/* B29214 800B2074 8C830004 */ lw $v1, 4($a0) -/* B29218 800B2078 00001025 */ move $v0, $zero -/* B2921C 800B207C 24630001 */ addiu $v1, $v1, 1 -/* B29220 800B2080 1860003F */ blez $v1, .L800B2180 -/* B29224 800B2084 00000000 */ nop -/* B29228 800B2088 8C860000 */ lw $a2, ($a0) -/* B2922C 800B208C 24C60001 */ addiu $a2, $a2, 1 -.L800B2090: -/* B29230 800B2090 18C00037 */ blez $a2, .L800B2170 -/* B29234 800B2094 00002825 */ move $a1, $zero -/* B29238 800B2098 00003825 */ move $a3, $zero -/* B2923C 800B209C 00004825 */ move $t1, $zero -/* B29240 800B20A0 8C8E0008 */ lw $t6, 8($a0) -.L800B20A4: -/* B29244 800B20A4 55C00004 */ bnezl $t6, .L800B20B8 -/* B29248 800B20A8 8C830014 */ lw $v1, 0x14($a0) -/* B2924C 800B20AC 10000002 */ b .L800B20B8 -/* B29250 800B20B0 8C830010 */ lw $v1, 0x10($a0) -/* B29254 800B20B4 8C830014 */ lw $v1, 0x14($a0) -.L800B20B8: -/* B29258 800B20B8 00460019 */ multu $v0, $a2 -/* B2925C 800B20BC 8C8F000C */ lw $t7, 0xc($a0) -/* B29260 800B20C0 00676821 */ addu $t5, $v1, $a3 -/* B29264 800B20C4 01E9C021 */ addu $t8, $t7, $t1 -/* B29268 800B20C8 00004012 */ mflo $t0 -/* B2926C 800B20CC 0008C8C0 */ sll $t9, $t0, 3 -/* B29270 800B20D0 03195021 */ addu $t2, $t8, $t9 -/* B29274 800B20D4 C5440000 */ lwc1 $f4, ($t2) -/* B29278 800B20D8 00087100 */ sll $t6, $t0, 4 -/* B2927C 800B20DC 01AE7821 */ addu $t7, $t5, $t6 -/* B29280 800B20E0 4600218D */ trunc.w.s $f6, $f4 -/* B29284 800B20E4 440C3000 */ mfc1 $t4, $f6 -/* B29288 800B20E8 00000000 */ nop -/* B2928C 800B20EC A5EC0000 */ sh $t4, ($t7) -/* B29290 800B20F0 8C980008 */ lw $t8, 8($a0) -/* B29294 800B20F4 57000004 */ bnezl $t8, .L800B2108 -/* B29298 800B20F8 8C830014 */ lw $v1, 0x14($a0) -/* B2929C 800B20FC 10000002 */ b .L800B2108 -/* B292A0 800B2100 8C830010 */ lw $v1, 0x10($a0) -/* B292A4 800B2104 8C830014 */ lw $v1, 0x14($a0) -.L800B2108: -/* B292A8 800B2108 8C990000 */ lw $t9, ($a0) -/* B292AC 800B210C 8C8B000C */ lw $t3, 0xc($a0) -/* B292B0 800B2110 24A50001 */ addiu $a1, $a1, 1 -/* B292B4 800B2114 272A0001 */ addiu $t2, $t9, 1 -/* B292B8 800B2118 004A0019 */ multu $v0, $t2 -/* B292BC 800B211C 01696821 */ addu $t5, $t3, $t1 -/* B292C0 800B2120 0067C821 */ addu $t9, $v1, $a3 -/* B292C4 800B2124 24E70010 */ addiu $a3, $a3, 0x10 -/* B292C8 800B2128 25290008 */ addiu $t1, $t1, 8 -/* B292CC 800B212C 00004012 */ mflo $t0 -/* B292D0 800B2130 000870C0 */ sll $t6, $t0, 3 -/* B292D4 800B2134 01AE6021 */ addu $t4, $t5, $t6 -/* B292D8 800B2138 C5880004 */ lwc1 $f8, 4($t4) -/* B292DC 800B213C 00085100 */ sll $t2, $t0, 4 -/* B292E0 800B2140 032A5821 */ addu $t3, $t9, $t2 -/* B292E4 800B2144 4600428D */ trunc.w.s $f10, $f8 -/* B292E8 800B2148 44185000 */ mfc1 $t8, $f10 -/* B292EC 800B214C 00000000 */ nop -/* B292F0 800B2150 A5780002 */ sh $t8, 2($t3) -/* B292F4 800B2154 8C860000 */ lw $a2, ($a0) -/* B292F8 800B2158 24C60001 */ addiu $a2, $a2, 1 -/* B292FC 800B215C 00A6082A */ slt $at, $a1, $a2 -/* B29300 800B2160 5420FFD0 */ bnezl $at, .L800B20A4 -/* B29304 800B2164 8C8E0008 */ lw $t6, 8($a0) -/* B29308 800B2168 8C830004 */ lw $v1, 4($a0) -/* B2930C 800B216C 24630001 */ addiu $v1, $v1, 1 -.L800B2170: -/* B29310 800B2170 24420001 */ addiu $v0, $v0, 1 -/* B29314 800B2174 0043082A */ slt $at, $v0, $v1 -/* B29318 800B2178 1420FFC5 */ bnez $at, .L800B2090 -/* B2931C 800B217C 00000000 */ nop -.L800B2180: -/* B29320 800B2180 03E00008 */ jr $ra -/* B29324 800B2184 00000000 */ nop diff --git a/asm/non_matchings/code/z_fbdemo/TransitionUnk_Update.s b/asm/non_matchings/code/z_fbdemo/TransitionUnk_Update.s deleted file mode 100644 index 2d5d8aa0a9..0000000000 --- a/asm/non_matchings/code/z_fbdemo/TransitionUnk_Update.s +++ /dev/null @@ -1,85 +0,0 @@ -glabel TransitionUnk_Update -/* B29454 800B22B4 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* B29458 800B22B8 F7B60010 */ sdc1 $f22, 0x10($sp) -/* B2945C 800B22BC F7B40008 */ sdc1 $f20, 8($sp) -/* B29460 800B22C0 8C830004 */ lw $v1, 4($a0) -/* B29464 800B22C4 00001025 */ move $v0, $zero -/* B29468 800B22C8 3C013F80 */ li $at, 0x3F800000 # 0.000000 -/* B2946C 800B22CC 24630001 */ addiu $v1, $v1, 1 -/* B29470 800B22D0 58600042 */ blezl $v1, .L800B23DC -/* B29474 800B22D4 D7B40008 */ ldc1 $f20, 8($sp) -/* B29478 800B22D8 8C860000 */ lw $a2, ($a0) -/* B2947C 800B22DC 4481B000 */ mtc1 $at, $f22 -/* B29480 800B22E0 3C0142C8 */ li $at, 0x42C80000 # 0.000000 -/* B29484 800B22E4 44819000 */ mtc1 $at, $f18 -/* B29488 800B22E8 4480A000 */ mtc1 $zero, $f20 -/* B2948C 800B22EC 24C70001 */ addiu $a3, $a2, 1 -.L800B22F0: -/* B29490 800B22F0 18E00035 */ blez $a3, .L800B23C8 -/* B29494 800B22F4 00002825 */ move $a1, $zero -/* B29498 800B22F8 00004025 */ move $t0, $zero -.L800B22FC: -/* B2949C 800B22FC 00470019 */ multu $v0, $a3 -/* B294A0 800B2300 8C83000C */ lw $v1, 0xc($a0) -/* B294A4 800B2304 0006C940 */ sll $t9, $a2, 5 -/* B294A8 800B2308 24A50001 */ addiu $a1, $a1, 1 -/* B294AC 800B230C 00687021 */ addu $t6, $v1, $t0 -/* B294B0 800B2310 00795021 */ addu $t2, $v1, $t9 -/* B294B4 800B2314 C5440048 */ lwc1 $f4, 0x48($t2) -/* B294B8 800B2318 C548004C */ lwc1 $f8, 0x4c($t2) -/* B294BC 800B231C 00007812 */ mflo $t7 -/* B294C0 800B2320 000FC0C0 */ sll $t8, $t7, 3 -/* B294C4 800B2324 01D84821 */ addu $t1, $t6, $t8 -/* B294C8 800B2328 C5220000 */ lwc1 $f2, ($t1) -/* B294CC 800B232C C5260004 */ lwc1 $f6, 4($t1) -/* B294D0 800B2330 46041001 */ sub.s $f0, $f2, $f4 -/* B294D4 800B2334 46083301 */ sub.s $f12, $f6, $f8 -/* B294D8 800B2338 46000282 */ mul.s $f10, $f0, $f0 -/* B294DC 800B233C 00000000 */ nop -/* B294E0 800B2340 460C6102 */ mul.s $f4, $f12, $f12 -/* B294E4 800B2344 46045180 */ add.s $f6, $f10, $f4 -/* B294E8 800B2348 46123403 */ div.s $f16, $f6, $f18 -/* B294EC 800B234C 4610A032 */ c.eq.s $f20, $f16 -/* B294F0 800B2350 46008386 */ mov.s $f14, $f16 -/* B294F4 800B2354 45010017 */ bc1t .L800B23B4 -/* B294F8 800B2358 00000000 */ nop -/* B294FC 800B235C 4616803C */ c.lt.s $f16, $f22 -/* B29500 800B2360 00000000 */ nop -/* B29504 800B2364 45020003 */ bc1fl .L800B2374 -/* B29508 800B2368 460E0203 */ div.s $f8, $f0, $f14 -/* B2950C 800B236C 4600B386 */ mov.s $f14, $f22 -/* B29510 800B2370 460E0203 */ div.s $f8, $f0, $f14 -.L800B2374: -/* B29514 800B2374 460E6183 */ div.s $f6, $f12, $f14 -/* B29518 800B2378 46081281 */ sub.s $f10, $f2, $f8 -/* B2951C 800B237C E52A0000 */ swc1 $f10, ($t1) -/* B29520 800B2380 8C8D0000 */ lw $t5, ($a0) -/* B29524 800B2384 8C8B000C */ lw $t3, 0xc($a0) -/* B29528 800B2388 25AF0001 */ addiu $t7, $t5, 1 -/* B2952C 800B238C 004F0019 */ multu $v0, $t7 -/* B29530 800B2390 01686021 */ addu $t4, $t3, $t0 -/* B29534 800B2394 00007012 */ mflo $t6 -/* B29538 800B2398 000EC0C0 */ sll $t8, $t6, 3 -/* B2953C 800B239C 01984821 */ addu $t1, $t4, $t8 -/* B29540 800B23A0 C5240004 */ lwc1 $f4, 4($t1) -/* B29544 800B23A4 46062201 */ sub.s $f8, $f4, $f6 -/* B29548 800B23A8 E5280004 */ swc1 $f8, 4($t1) -/* B2954C 800B23AC 8C860000 */ lw $a2, ($a0) -/* B29550 800B23B0 24C70001 */ addiu $a3, $a2, 1 -.L800B23B4: -/* B29554 800B23B4 00A7082A */ slt $at, $a1, $a3 -/* B29558 800B23B8 1420FFD0 */ bnez $at, .L800B22FC -/* B2955C 800B23BC 25080008 */ addiu $t0, $t0, 8 -/* B29560 800B23C0 8C830004 */ lw $v1, 4($a0) -/* B29564 800B23C4 24630001 */ addiu $v1, $v1, 1 -.L800B23C8: -/* B29568 800B23C8 24420001 */ addiu $v0, $v0, 1 -/* B2956C 800B23CC 0043082A */ slt $at, $v0, $v1 -/* B29570 800B23D0 1420FFC7 */ bnez $at, .L800B22F0 -/* B29574 800B23D4 00000000 */ nop -/* B29578 800B23D8 D7B40008 */ ldc1 $f20, 8($sp) -.L800B23DC: -/* B2957C 800B23DC D7B60010 */ ldc1 $f22, 0x10($sp) -/* B29580 800B23E0 03E00008 */ jr $ra -/* B29584 800B23E4 27BD0018 */ addiu $sp, $sp, 0x18 - diff --git a/include/z64transition.h b/include/z64transition.h index aa0c3779ad..45b9b12b14 100644 --- a/include/z64transition.h +++ b/include/z64transition.h @@ -4,11 +4,16 @@ #include #include +typedef struct { + f32 unk_0; + f32 unk_4; +} TransitionUnkData; + typedef struct { /* 0x00 */ s32 row; /* 0x04 */ s32 col; /* 0x08 */ s32 frame; - /* 0x0C */ f32* unk_0C; + /* 0x0C */ TransitionUnkData* unk_0C; /* 0x10 */ Vtx* vtxFrame1; /* 0x14 */ Vtx* vtxFrame2; /* 0x18 */ Mtx projection; diff --git a/src/code/z_fbdemo.c b/src/code/z_fbdemo.c index 1b7aa46176..f8409a7edb 100644 --- a/src/code/z_fbdemo.c +++ b/src/code/z_fbdemo.c @@ -26,9 +26,83 @@ Gfx D_8012B000[] = { gsSPEndDisplayList(), }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo/TransitionUnk_InitGraphics.s") +#ifdef NON_EQUIVALENT +// The general control flow is correct and nothing is especially out of order but there are +// many small reoderings and regalloc all over so functional equivalence cannot be verified +void TransitionUnk_InitGraphics(TransitionUnk* this) { + Vtx* vtx2; + s32 frame; + s32 rowTex; + s32 row; + Gfx* gfx; + Vtx* vtx; + s32 col; + s32 colTex; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo/TransitionUnk_InitData.s") + guMtxIdent(&this->modelView); + guMtxIdent(&this->unk_98); + guOrtho(&this->projection, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, -1000.0f, 1000.0f, 1.0f); + + for (frame = 0; frame < 2; frame++) { + this->frame = frame; + vtx = (frame == 0) ? this->vtxFrame1 : this->vtxFrame2; + for (col = 0, colTex = 0; col < this->col + 1; col++, colTex += 0x20) { + for (row = 0, rowTex = 0; row < this->row + 1; row++, rowTex += 0x20) { + vtx2 = vtx; + vtx2->v.tc[0] = rowTex * 0x40; + vtx2->v.ob[0] = rowTex; + vtx2->v.ob[1] = col * 0x20; + vtx2->v.ob[2] = -5; + vtx2->v.flag = 0; + vtx2->v.tc[1] = colTex * 0x40; + vtx2->v.cn[0] = 0; + vtx2->v.cn[1] = 0; + vtx2->v.cn[2] = 120; + vtx2->v.cn[3] = 255; + vtx++; + } + } + } + + gfx = this->gfx; + for (col = 0, colTex = 0; col < this->col; col++, colTex += 0x20) { + gSPVertex(gfx++, SEGMENT_ADDR(0xA, col * (this->row + 1) * sizeof(Vtx)), this->row + 1, 0); + for (row = 0, rowTex = 0; row < this->row; row++, rowTex += 0x20) { + gDPPipeSync(gfx++); + gDPSetTextureImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, SEGMENT_ADDR(0xB, 0)); + gDPSetTile(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 9, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, + G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD); + gDPLoadSync(gfx++); + gDPLoadTile(gfx++, G_TX_LOADTILE, rowTex, colTex, rowTex + 0x20, colTex + 0x20); + gDPPipeSync(gfx++); + gDPSetTile(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 9, 0x0000, G_TX_RENDERTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, + G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD); + gDPSetTileSize(gfx++, G_TX_RENDERTILE, rowTex, colTex, rowTex + 0x20, colTex + 0x20); + gSP1Quadrangle(gfx++, row, row + 1, row + this->row, row + this->row + 1, 0); + } + } + gDPPipeSync(gfx++); + gSPEndDisplayList(gfx++); + + LOG("this->col * (1 + this->row * (1 + 7 + 1)) + 1 + 1", this->col * (1 + this->row * 9) + 2, "%d", "../z_fbdemo.c", + 144); + LOG("gp - this->gfxtbl", gfx - this->gfx, "%d", "../z_fbdemo.c", 145); +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo/TransitionUnk_InitGraphics.s") +#endif + +void TransitionUnk_InitData(TransitionUnk* this) { + s32 col; + s32 row; + + for (col = 0; col < this->col + 1; col++) { + for (row = 0; row < this->row + 1; row++) { + (this->unk_0C + row + col * (this->row + 1))->unk_0 = row * 32; + (this->unk_0C + row + col * (this->row + 1))->unk_4 = col * 32; + } + } +} void TransitionUnk_Destroy(TransitionUnk* this) { osSyncPrintf("fbdemo_cleanup(%08x)\n", this); @@ -58,10 +132,10 @@ TransitionUnk* TransitionUnk_Init(TransitionUnk* this, s32 row, s32 col) { this->frame = 0; this->row = row; this->col = col; - this->unk_0C = SystemArena_MallocDebug(((row * 8) + 8) * (col + 1), "../z_fbdemo.c", 195); + this->unk_0C = SystemArena_MallocDebug((row + 1) * sizeof(TransitionUnkData) * (col + 1), "../z_fbdemo.c", 195); this->vtxFrame1 = SystemArena_MallocDebug((row + 1) * sizeof(Vtx) * (col + 1), "../z_fbdemo.c", 196); this->vtxFrame2 = SystemArena_MallocDebug((row + 1) * sizeof(Vtx) * (col + 1), "../z_fbdemo.c", 197); - this->gfx = SystemArena_MallocDebug(((this->col * ((this->row * 9) + 1)) + 2) * sizeof(Gfx), "../z_fbdemo.c", 198); + this->gfx = SystemArena_MallocDebug((this->col * (1 + this->row * 9) + 2) * sizeof(Gfx), "../z_fbdemo.c", 198); if (this->unk_0C == NULL || this->vtxFrame1 == NULL || this->vtxFrame2 == NULL || this->gfx == NULL) { osSyncPrintf("fbdemo_init allocation error\n"); if (this->unk_0C != NULL) { @@ -88,7 +162,20 @@ TransitionUnk* TransitionUnk_Init(TransitionUnk* this, s32 row, s32 col) { return this; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo/TransitionUnk_SetData.s") +void TransitionUnk_SetData(TransitionUnk* this) { + s32 col; + Vtx* vtx; + s32 row; + + for (col = 0; col < this->col + 1; col++) { + for (row = 0; row < this->row + 1; row++) { + vtx = (this->frame == 0) ? this->vtxFrame1 : this->vtxFrame2; + (vtx + row + col * (this->row + 1))->v.ob[0] = (this->unk_0C + row + col * (this->row + 1))->unk_0; + vtx = (this->frame == 0) ? this->vtxFrame1 : this->vtxFrame2; + (vtx + row + col * (this->row + 1))->v.ob[1] = (this->unk_0C + row + col * (this->row + 1))->unk_4; + } + } +} void TransitionUnk_Draw(TransitionUnk* this, Gfx** gfxP) { Gfx* gfx = *gfxP; @@ -97,8 +184,8 @@ void TransitionUnk_Draw(TransitionUnk* this, Gfx** gfxP) { TransitionUnk_SetData(this); gSPMatrix(gfx++, &this->projection, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); gSPMatrix(gfx++, &this->modelView, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPSegment(gfx++, 10, this->frame == 0 ? this->vtxFrame1 : this->vtxFrame2); - gSPSegment(gfx++, 11, this->zBuffer); + gSPSegment(gfx++, 0xA, this->frame == 0 ? this->vtxFrame1 : this->vtxFrame2); + gSPSegment(gfx++, 0xB, this->zBuffer); gSPDisplayList(gfx++, D_8012B000); gSPDisplayList(gfx++, this->gfx); gDPPipeSync(gfx++); @@ -106,7 +193,30 @@ void TransitionUnk_Draw(TransitionUnk* this, Gfx** gfxP) { *gfxP = gfx; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo/TransitionUnk_Update.s") +void TransitionUnk_Update(TransitionUnk* this) { + f32 temp_f00; + f32 temp_f12; + s32 col; + f32 phi_f14; + s32 row; + + for (col = 0; col < this->col + 1; col++) { + for (row = 0; row < this->row + 1; row++) { + temp_f00 = + (this->unk_0C + row + col * (this->row + 1))->unk_0 - (this->unk_0C + 5 + 4 * (this->row + 1))->unk_0; + temp_f12 = + (this->unk_0C + row + col * (this->row + 1))->unk_4 - (this->unk_0C + 5 + 4 * (this->row + 1))->unk_4; + phi_f14 = (SQ(temp_f00) + SQ(temp_f12)) / 100.0f; + if (phi_f14 != 0.0f) { + if (phi_f14 < 1.0f) { + phi_f14 = 1.0f; + } + (this->unk_0C + row + col * (this->row + 1))->unk_0 -= temp_f00 / phi_f14; + (this->unk_0C + row + col * (this->row + 1))->unk_4 -= temp_f12 / phi_f14; + } + } + } +} void func_800B23E8(TransitionUnk* this) { } diff --git a/src/code/z_fbdemo_fade.c b/src/code/z_fbdemo_fade.c index af45f429c1..f93719f20e 100644 --- a/src/code/z_fbdemo_fade.c +++ b/src/code/z_fbdemo_fade.c @@ -36,11 +36,10 @@ void TransitionFade_Destroy(TransitionFade* this) { } #ifdef NON_MATCHING -// ordering differences +// Ordering differences around alpha temp void TransitionFade_Update(TransitionFade* this, s32 updateRate) { - char pad[2]; - s16 newAlpha; s32 alpha; + s16 newAlpha; switch (this->fadeType) { case 0: @@ -56,17 +55,17 @@ void TransitionFade_Update(TransitionFade* this, s32 updateRate) { osSyncPrintf(VT_COL(RED, WHITE) "0除算! ZCommonGet fade_speed に0がはいってる" VT_RST); } alpha = (this->fadeTimer * 255.0f) / gSaveContext.fadeDuration; - this->fadeColor.a = this->fadeDirection != 0 ? 0xFF - alpha : alpha; + this->fadeColor.a = (this->fadeDirection != 0) ? 255 - alpha : alpha; break; case 2: newAlpha = this->fadeColor.a; if (iREG(50) != 0) { if (iREG(50) < 0) { - if (Math_ApproxS(&newAlpha, 0xFF, 0xFF) != 0) { - iREG(50) = 0x96; + if (Math_ApproxS(&newAlpha, 255, 255) != 0) { + iREG(50) = 150; } } else { - Math_ApproxS(&iREG(50), 0x14, 0x3C); + Math_ApproxS(&iREG(50), 20, 60); if (Math_ApproxS(&newAlpha, 0, iREG(50)) != 0) { iREG(50) = 0; this->isDone = 1;