mirror of
https://github.com/zeldaret/oot.git
synced 2025-07-05 07:24:34 +00:00
Match more z_fbdemo functions (#370)
* Match some and improve nonmatchings * Remove pads in TransitionFade_Update, no effect towards matching * Remove pragma comments, ran formatter * Remove unused asm
This commit is contained in:
parent
48f2e10bef
commit
18775320f8
6 changed files with 130 additions and 231 deletions
|
@ -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) {
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue