mirror of
https://github.com/zeldaret/oot
synced 2026-06-26 02:14:31 -04:00
Make func_800C213C match original ROM (#678)
* Make func_800C213C match original ROM
The C code for this function was very close to done, and was
functionally equivalent to the ROM. This commit uses a few tricks
to convince the compiler to allocate the same registers as the original
ROM. The two tricks used are:
1. Introduced a new temporary variable "yinc".
2. Added a "do while(0) {}" line in two places.
Both of these ideas came from the decomp-permuter tool. I took the
do/while idea and guess as to what it might have been in the original
code. I imagined that the "do while(0) {}" was probably left over from
a standard multi-line macro, which for some reason had an empty body.
I further suggest that maybe the empty body is because it was a feature
compiled out during RELEASE builds - perhaps a debug logging macro.
* Use simpler code for func_800C213C
Replaced dummy LOG macro with "do {} while(0);". This version makes
less assumptions about what the original code looked like.
This commit is contained in:
@@ -308,14 +308,13 @@ void func_800C2118(PreRenderContext* this, Gfx** gfxp) {
|
||||
func_800C0F28(this, gfxp, this->zbufSave, this->zbuf);
|
||||
}
|
||||
|
||||
#ifdef NON_MATCHING
|
||||
// regalloc differences in gDPLoadMultiTile
|
||||
void func_800C213C(PreRenderContext* this, Gfx** gfxp) {
|
||||
Gfx* gfx;
|
||||
s32 y;
|
||||
s32 y2;
|
||||
s32 add;
|
||||
s32 uls;
|
||||
s32 yinc; // vertical increment amount
|
||||
s32 ult;
|
||||
s32 lrx;
|
||||
s32 lry;
|
||||
@@ -350,20 +349,23 @@ void func_800C213C(PreRenderContext* this, Gfx** gfxp) {
|
||||
}
|
||||
|
||||
uls = 0;
|
||||
yinc = 1;
|
||||
ult = y2;
|
||||
lry = (y2 + add - 1);
|
||||
lry = (y2 + add - yinc);
|
||||
|
||||
gDPLoadMultiTile(gfx++, this->fbufSave, 0x0000, G_TX_RENDERTILE, G_IM_FMT_RGBA, G_IM_SIZ_16b, this->width,
|
||||
this->height, uls, ult, lrx, lry, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP,
|
||||
G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
|
||||
gDPLoadMultiTile(gfx++, this->cvgSave, 0x0160, 1, G_IM_FMT_I, G_IM_SIZ_8b, this->width, this->height, uls, ult,
|
||||
|
||||
do {} while(0); // force register allocation behavior
|
||||
gDPLoadMultiTile(gfx++, this->cvgSave, 0x0160, yinc, G_IM_FMT_I, G_IM_SIZ_8b, this->width, this->height, uls, ult,
|
||||
lrx, lry, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK,
|
||||
G_TX_NOLOD, G_TX_NOLOD);
|
||||
|
||||
gSPTextureRectangle(gfx++, uls << 2, ult << 2, (lrx + 1) << 2, (lry + 1) << 2, G_TX_RENDERTILE, uls << 5,
|
||||
do {} while(0); // force register allocation behavior
|
||||
gSPTextureRectangle(gfx++, uls << 2, ult << 2, (lrx + yinc) << 2, (lry + yinc) << 2, G_TX_RENDERTILE, uls << 5,
|
||||
ult << 5, 1 << 10, 1 << 10);
|
||||
|
||||
if (1) {}
|
||||
y -= add;
|
||||
y2 += add;
|
||||
}
|
||||
@@ -371,9 +373,6 @@ void func_800C213C(PreRenderContext* this, Gfx** gfxp) {
|
||||
gDPPipeSync(gfx++);
|
||||
*gfxp = gfx;
|
||||
}
|
||||
#else
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/PreRender/func_800C213C.s")
|
||||
#endif
|
||||
|
||||
void func_800C24BC(PreRenderContext* this, Gfx** gfxp) {
|
||||
func_800C0F28(this, gfxp, this->fbufSave, this->fbuf);
|
||||
|
||||
Reference in New Issue
Block a user