mirror of
https://github.com/HarbourMasters/2ship2harkinian.git
synced 2024-11-27 16:20:34 +00:00
(Mostly) Decompile PreRender.c (#105)
* start prerender * match func_8016FDB8 * fix fake af match * actually add prerender * Delete ctx.c * test * lots of oot transfers * lots of new functions done * match even more functions * slowly thread functions * two prerender functions left * some docs * make names more consistent with oot * ready for pr? * Update PreRender.c
This commit is contained in:
parent
c377ffe4ac
commit
1ca8a9c24d
@ -3066,33 +3066,33 @@ void Play_Init(GlobalContext* ctxt);
|
||||
void func_8016F5A8(GlobalContext* ctxt, s8* pcParm2, Input* iParm3);
|
||||
// void func_8016FC78(void);
|
||||
// void func_8016FC98(void);
|
||||
// void func_8016FCF0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6);
|
||||
void func_8016FD2C(void* param_1);
|
||||
// void func_8016FD60(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5);
|
||||
// void func_8016FD94(void);
|
||||
// void func_8016FDB8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5);
|
||||
// void func_8016FF70(void);
|
||||
// void func_8016FF90(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8);
|
||||
// void func_80170200(void);
|
||||
// void func_8017023C(void);
|
||||
// void func_8017057C(void);
|
||||
// void func_801705B4(void);
|
||||
// void func_801705EC(void);
|
||||
// void func_80170730(void);
|
||||
// void func_80170774(void);
|
||||
// void func_80170798(void);
|
||||
// void func_80170AE0(void);
|
||||
// void func_80170B28(void);
|
||||
// void func_80170B4C(void);
|
||||
// void func_8017160C(void);
|
||||
// void func_801716C4(void);
|
||||
// void func_801717F8(void);
|
||||
void func_80171F4C(s32 param_1);
|
||||
// void func_80171FA8(void);
|
||||
// void func_80172078(void);
|
||||
// void func_801720C4(void);
|
||||
// void func_801720FC(void);
|
||||
// void func_80172758(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE1 param_6, UNK_TYPE1 param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9, UNK_TYPE4 param_10, UNK_TYPE4 param_11, UNK_TYPE4 param_12, UNK_TYPE4 param_13, UNK_TYPE4 param_14);
|
||||
void PreRender_SetValuesSave(PreRenderContext* this, u32 width, u32 height, void* fbuf, void* zbuf, void* cvg);
|
||||
void PreRender_Init(PreRenderContext* this);
|
||||
void PreRender_SetValues(PreRenderContext* this, u32 width, u32 height, void* fbuf, void* zbuf);
|
||||
void PreRender_Destroy(PreRenderContext* this);
|
||||
void func_8016FDB8(PreRenderContext* this, Gfx** gfxp, void* buf, void* bufSave, u32 arg4);
|
||||
void func_8016FF70(PreRenderContext* this, Gfx** gfxp, void* buf, void* bufSave);
|
||||
void func_8016FF90(PreRenderContext* this, Gfx** gfxp, void* buf, void* bufSave, s32 envR, s32 envG, s32 envB, s32 envA);
|
||||
void func_80170200(PreRenderContext* this, Gfx** gfxp, void* buf, void* bufSave);
|
||||
void func_8017023C(PreRenderContext* this, Gfx** gfxp, void* buf, void* bufSave);
|
||||
void func_8017057C(PreRenderContext* this, Gfx** gfxp);
|
||||
void func_801705B4(PreRenderContext* this, Gfx** gfxp);
|
||||
void func_801705EC(PreRenderContext* this, Gfx** gfxp);
|
||||
void func_80170730(PreRenderContext* this, Gfx** gfxp);
|
||||
void func_80170774(PreRenderContext* this, Gfx** gfxp);
|
||||
void func_80170798(PreRenderContext* this, Gfx** gfxp);
|
||||
void func_80170AE0(PreRenderContext* this, Gfx** gfxp, s32 alpha);
|
||||
void func_80170B28(PreRenderContext* this, Gfx** gfxp);
|
||||
void PreRender_AntiAliasAlgorithm(PreRenderContext* this, s32 x, s32 y);
|
||||
void PreRender_ApplyAntiAliasingFilter(PreRenderContext* this);
|
||||
u32 func_801716C4(u8* arg0, u8* arg1, u8* arg2);
|
||||
void func_801717F8(PreRenderContext* this);
|
||||
void PreRender_ApplyFilters(PreRenderContext* this);
|
||||
void PreRender_ApplyFiltersSlowlyInit(PreRenderContext* this);
|
||||
void PreRender_ApplyFiltersSlowlyDestroy(PreRenderContext* this);
|
||||
void func_801720C4(PreRenderContext* this);
|
||||
void func_801720FC(PreRenderParams* params, Gfx** gfxp);
|
||||
void func_80172758(Gfx** gfxp, void* timg, void* tlut, u16 width, u16 height, u8 fmt, u8 siz, u16 tt, u16 arg8, f32 x, f32 y, f32 xScale, f32 yScale, u32 flags);
|
||||
void THGA_Ct(TwoHeadGfxArena* thga, Gfx* start, u32 size);
|
||||
void THGA_Dt(TwoHeadGfxArena* thga);
|
||||
u32 THGA_IsCrash(TwoHeadGfxArena* thga);
|
||||
@ -3172,10 +3172,10 @@ void Graph_ThreadEntry(void* arg);
|
||||
Gfx* Graph_GfxPlusOne(Gfx* gfx);
|
||||
Gfx* Graph_BranchDlist(Gfx* gfx, Gfx* dst);
|
||||
void* Graph_DlistAlloc(Gfx** gfx, u32 size);
|
||||
// void func_80174AA0(void);
|
||||
void func_80174AA0(ListAlloc* alloc);
|
||||
// void func_80174AB4(void);
|
||||
// void func_80174B20(void);
|
||||
// void func_80174BA0(void);
|
||||
void func_80174BA0(ListAlloc* alloc);
|
||||
void main(void* arg);
|
||||
// u32 Padmgr_GetControllerBitmask(void);
|
||||
// void func_80174F24(void);
|
||||
|
@ -4097,10 +4097,10 @@ extern Color_RGBA8 D_801F6D30;
|
||||
extern u8 D_801F6DFC;
|
||||
// extern UNK_TYPE1 D_801F6DFD;
|
||||
extern SlowlyTask D_801F6E00;
|
||||
// extern UNK_TYPE1 D_801F6FC0;
|
||||
extern s32 D_801F6FC0;
|
||||
extern StackEntry slowlyStackEntry;
|
||||
extern u8 slowlyStack[4096];
|
||||
// extern UNK_TYPE1 D_801F7FE8;
|
||||
extern UNK_TYPE1 D_801F7FE8;
|
||||
extern UNK_TYPE1 D_801F7FF0;
|
||||
extern struct_801F8010 D_801F8010;
|
||||
extern struct_801F8020 D_801F8020;
|
||||
|
@ -992,6 +992,52 @@ typedef struct {
|
||||
/* 0x00227 */ u8 envB;
|
||||
} SkyboxContext; // size = 0x228
|
||||
|
||||
typedef struct ListAlloc {
|
||||
/* 0x00 */ struct ListAlloc* prev;
|
||||
/* 0x04 */ struct ListAlloc* next;
|
||||
} ListAlloc; // size = 0x8
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ u16 width;
|
||||
/* 0x02 */ u16 height;
|
||||
/* 0x04 */ u16 widthSave;
|
||||
/* 0x06 */ u16 heightSave;
|
||||
/* 0x08 */ char unk_8[8];
|
||||
/* 0x10 */ u16* fbuf;
|
||||
/* 0x14 */ u16* fbufSave;
|
||||
/* 0x18 */ u8* cvgSave;
|
||||
/* 0x1C */ u16* zbuf;
|
||||
/* 0x20 */ u16* zbufSave;
|
||||
/* 0x24 */ u16 ulxSave;
|
||||
/* 0x26 */ u16 ulySave;
|
||||
/* 0x28 */ u16 lrxSave;
|
||||
/* 0x2A */ u16 lrySave;
|
||||
/* 0x2C */ u16 ulx;
|
||||
/* 0x2E */ u16 uly;
|
||||
/* 0x30 */ u16 lrx;
|
||||
/* 0x32 */ u16 lry;
|
||||
/* 0x34 */ char unk_34[16];
|
||||
/* 0x44 */ ListAlloc alloc;
|
||||
/* 0x4C */ u8 unk_4C;
|
||||
/* 0x4D */ u8 unk_4D;
|
||||
/* 0x4E */ char unk_4E[2];
|
||||
} PreRenderContext; // size = 0x50
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ void* timg;
|
||||
/* 0x04 */ void* tlut;
|
||||
/* 0x08 */ u16 width;
|
||||
/* 0x0A */ u16 height;
|
||||
/* 0x0C */ u8 fmt;
|
||||
/* 0x0D */ u8 siz;
|
||||
/* 0x0E */ u16 tt;
|
||||
/* 0x10 */ u16 unk_10;
|
||||
/* 0x14 */ f32 x;
|
||||
/* 0x18 */ f32 y;
|
||||
/* 0x1C */ f32 xScale;
|
||||
/* 0x20 */ f32 yScale;
|
||||
/* 0x24 */ u32 flags;
|
||||
} PreRenderParams; // size = 0x28
|
||||
|
||||
typedef struct {
|
||||
/* 0x00000 */ View view;
|
||||
@ -1650,7 +1696,9 @@ struct GlobalContext {
|
||||
/* 0x18B48 */ u8 curSpawn;
|
||||
/* 0x18B49 */ UNK_TYPE1 pad18B49[0x1];
|
||||
/* 0x18B4A */ u8 unk18B4A;
|
||||
/* 0x18B4B */ UNK_TYPE1 pad18B4B[0x309];
|
||||
/* 0x18B4B */ char pad18B4B[1];
|
||||
/* 0x18B4C */ PreRenderContext preRenderCtx;
|
||||
/* 0x18B9C */ char unk_18B9C[0x2B8];
|
||||
/* 0x18E54 */ SceneTableEntry* currentSceneTableEntry;
|
||||
/* 0x18E58 */ UNK_TYPE1 pad18E58[0x400];
|
||||
}; // size = 0x19258
|
||||
|
@ -442,7 +442,7 @@ SECTIONS
|
||||
build/asm/code/z_overlay.o(.text)
|
||||
build/asm/code/z_play.o(.text)
|
||||
build/asm/code/z_play_hireso.o(.text)
|
||||
build/asm/code/PreRender.o(.text)
|
||||
build/src/code/PreRender.o(.text)
|
||||
build/src/code/TwoHeadGfxArena.o(.text)
|
||||
build/src/code/TwoHeadArena.o(.text)
|
||||
build/asm/code/code_0x80172BC0.o(.text)
|
||||
|
476
src/code/PreRender.c
Normal file
476
src/code/PreRender.c
Normal file
@ -0,0 +1,476 @@
|
||||
#include <ultra64.h>
|
||||
#include <global.h>
|
||||
|
||||
/**
|
||||
* Assigns the "save" values in PreRenderContext
|
||||
*/
|
||||
void PreRender_SetValuesSave(PreRenderContext* this, u32 width, u32 height, void* fbuf, void* zbuf, void* cvg) {
|
||||
this->widthSave = width;
|
||||
this->heightSave = height;
|
||||
this->fbufSave = fbuf;
|
||||
this->cvgSave = cvg;
|
||||
this->zbufSave = zbuf;
|
||||
this->ulxSave = 0;
|
||||
this->ulySave = 0;
|
||||
this->lrxSave = width - 1;
|
||||
this->lrySave = height - 1;
|
||||
}
|
||||
|
||||
void PreRender_Init(PreRenderContext* this) {
|
||||
bzero(this, sizeof(PreRenderContext));
|
||||
func_80174AA0(&this->alloc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigns the current values in PreRenderContext
|
||||
*/
|
||||
void PreRender_SetValues(PreRenderContext* this, u32 width, u32 height, void* fbuf, void* zbuf) {
|
||||
this->width = width;
|
||||
this->height = height;
|
||||
this->fbuf = fbuf;
|
||||
this->zbuf = zbuf;
|
||||
this->ulx = 0;
|
||||
this->uly = 0;
|
||||
this->lrx = width - 1;
|
||||
this->lry = height - 1;
|
||||
}
|
||||
|
||||
void PreRender_Destroy(PreRenderContext* this) {
|
||||
func_80174BA0(&this->alloc);
|
||||
}
|
||||
|
||||
void func_8016FDB8(PreRenderContext* this, Gfx** gfxp, void* buf, void* bufSave, u32 arg4) {
|
||||
Gfx* gfx = *gfxp;
|
||||
u32 flags;
|
||||
|
||||
gDPPipeSync(gfx++);
|
||||
gDPSetColorImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, this->width, bufSave);
|
||||
gDPSetScissor(gfx++, G_SC_NON_INTERLACE, 0, 0, this->width, this->height);
|
||||
|
||||
flags = 0x18;
|
||||
if (arg4 == true) {
|
||||
flags = 0x1C;
|
||||
}
|
||||
|
||||
func_80172758(&gfx, buf, NULL, this->width, this->height, G_IM_FMT_RGBA, G_IM_SIZ_16b, G_TT_NONE, 0, 0.0f, 0.0f,
|
||||
1.0f, 1.0f, flags);
|
||||
gDPPipeSync(gfx++);
|
||||
gDPSetColorImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, this->width, this->fbuf);
|
||||
|
||||
*gfxp = gfx;
|
||||
}
|
||||
|
||||
void func_8016FF70(PreRenderContext* this, Gfx** gfxp, void* buf, void* bufSave) {
|
||||
func_8016FDB8(this, gfxp, buf, bufSave, false);
|
||||
}
|
||||
|
||||
void func_8016FF90(PreRenderContext* this, Gfx** gfxp, void* buf, void* bufSave, s32 envR, s32 envG, s32 envB,
|
||||
s32 envA) {
|
||||
Gfx* gfx = *gfxp;
|
||||
|
||||
gDPPipeSync(gfx++);
|
||||
|
||||
if (envA == 255) {
|
||||
gDPSetOtherMode(gfx++,
|
||||
G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_POINT | G_TT_NONE | G_TL_TILE |
|
||||
G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE,
|
||||
G_AC_NONE | G_ZS_PRIM | G_RM_OPA_SURF | G_RM_OPA_SURF2);
|
||||
} else {
|
||||
gDPSetOtherMode(gfx++,
|
||||
G_AD_NOISE | G_CD_NOISE | G_CK_NONE | G_TC_FILT | G_TF_POINT | G_TT_NONE | G_TL_TILE |
|
||||
G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE,
|
||||
G_AC_NONE | G_ZS_PRIM | G_RM_CLD_SURF | G_RM_CLD_SURF2);
|
||||
}
|
||||
|
||||
gDPSetEnvColor(gfx++, envR, envG, envB, envA);
|
||||
gDPSetCombineLERP(gfx++, TEXEL0, 0, ENVIRONMENT, 0, 0, 0, 0, ENVIRONMENT, TEXEL0, 0, ENVIRONMENT, 0, 0, 0, 0,
|
||||
ENVIRONMENT);
|
||||
gDPSetColorImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, this->width, bufSave);
|
||||
|
||||
gDPSetScissor(gfx++, G_SC_NON_INTERLACE, 0, 0, this->width, this->height);
|
||||
|
||||
func_80172758(&gfx, buf, 0, this->width, this->height, G_IM_FMT_RGBA, G_IM_SIZ_16b, G_TT_NONE, 0, 0.0f, 0.0f, 1.0f,
|
||||
1.0f, 0xB);
|
||||
gDPPipeSync(gfx++);
|
||||
gDPSetColorImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, this->width, this->fbuf);
|
||||
|
||||
*gfxp = gfx;
|
||||
}
|
||||
|
||||
void func_80170200(PreRenderContext* this, Gfx** gfxp, void* buf, void* bufSave) {
|
||||
func_8016FF90(this, gfxp, buf, bufSave, 255, 255, 255, 255);
|
||||
}
|
||||
|
||||
#ifdef NON_MATCHING
|
||||
// just regalloc
|
||||
void func_8017023C(PreRenderContext* this, Gfx** gfxp, void* buf, void* bufSave) {
|
||||
Gfx* gfx = *gfxp;
|
||||
s32 x;
|
||||
s32 x2;
|
||||
s32 dx;
|
||||
|
||||
gDPPipeSync(gfx++);
|
||||
gDPSetOtherMode(gfx++,
|
||||
G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_POINT | G_TT_NONE | G_TL_TILE |
|
||||
G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE,
|
||||
G_AC_NONE | G_ZS_PRIM | G_RM_PASS | G_RM_OPA_CI2);
|
||||
gDPSetCombineLERP(gfx++, 0, 0, 0, TEXEL0, 0, 0, 0, 0, 0, 0, 0, TEXEL0, 0, 0, 0, 0);
|
||||
gDPSetColorImage(gfx++, G_IM_FMT_I, G_IM_SIZ_8b, this->width, bufSave);
|
||||
gDPSetScissor(gfx++, G_SC_NON_INTERLACE, 0, 0, this->width, this->height);
|
||||
|
||||
dx = 0x1000 / (this->width * 2);
|
||||
x = this->height;
|
||||
x2 = 0;
|
||||
|
||||
while (x > 0) {
|
||||
s32 uls = 0;
|
||||
s32 lrs = this->width - 1;
|
||||
s32 ult;
|
||||
s32 lrt;
|
||||
|
||||
dx = CLAMP_MAX(dx, x);
|
||||
ult = x2;
|
||||
lrt = x2 + dx - 1;
|
||||
|
||||
gDPLoadTextureTile(gfx++, buf, G_IM_FMT_IA, G_IM_SIZ_16b, this->width, this->height, uls, ult, lrs, lrt, 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, (lrs + 1) << 2, (lrt + 1) << 2, G_TX_RENDERTILE, uls << 5,
|
||||
ult << 5, 1 << 10, 1 << 10);
|
||||
|
||||
x2 += dx;
|
||||
x -= dx;
|
||||
}
|
||||
|
||||
gDPPipeSync(gfx++);
|
||||
gDPSetColorImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, this->width, this->fbuf);
|
||||
|
||||
*gfxp = gfx;
|
||||
}
|
||||
#else
|
||||
#pragma GLOBAL_ASM("./asm/non_matchings/code/PreRender/func_8017023C.asm")
|
||||
#endif
|
||||
|
||||
void func_8017057C(PreRenderContext* this, Gfx** gfxp) {
|
||||
if ((this->zbufSave != NULL) && (this->zbuf != NULL)) {
|
||||
func_8016FF70(this, gfxp, this->zbuf, this->zbufSave);
|
||||
}
|
||||
}
|
||||
|
||||
void func_801705B4(PreRenderContext* this, Gfx** gfxp) {
|
||||
if ((this->fbufSave != NULL) && (this->fbuf != NULL)) {
|
||||
func_80170200(this, gfxp, this->fbuf, this->fbufSave);
|
||||
}
|
||||
}
|
||||
|
||||
void func_801705EC(PreRenderContext* this, Gfx** gfxp) {
|
||||
Gfx* gfx = *gfxp;
|
||||
|
||||
gDPPipeSync(gfx++);
|
||||
gDPSetBlendColor(gfx++, 255, 255, 255, 8);
|
||||
gDPSetPrimDepth(gfx++, -1, -1);
|
||||
gDPSetOtherMode(gfx++,
|
||||
G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_POINT | G_TT_NONE | G_TL_TILE |
|
||||
G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE,
|
||||
G_AC_NONE | G_ZS_PRIM | G_RM_VISCVG | G_RM_VISCVG2);
|
||||
gDPSetScissor(gfx++, G_SC_NON_INTERLACE, 0, 0, this->width, this->height);
|
||||
gDPFillRectangle(gfx++, 0, 0, this->width, this->height);
|
||||
gDPPipeSync(gfx++);
|
||||
|
||||
*gfxp = gfx;
|
||||
}
|
||||
|
||||
void func_80170730(PreRenderContext* this, Gfx** gfxp) {
|
||||
func_801705EC(this, gfxp);
|
||||
|
||||
if (this->cvgSave != NULL) {
|
||||
func_8017023C(this, gfxp, this->fbuf, this->cvgSave);
|
||||
}
|
||||
}
|
||||
|
||||
void func_80170774(PreRenderContext* this, Gfx** gfxp) {
|
||||
func_8016FF70(this, gfxp, this->zbufSave, this->zbuf);
|
||||
}
|
||||
|
||||
#ifdef NON_MATCHING
|
||||
// just regalloc
|
||||
void func_80170798(PreRenderContext* this, Gfx** gfxp) {
|
||||
Gfx* gfx;
|
||||
s32 y;
|
||||
s32 y2;
|
||||
s32 dy;
|
||||
s32 rtile = 1;
|
||||
|
||||
if (this->cvgSave != NULL) {
|
||||
gfx = *gfxp;
|
||||
|
||||
gDPPipeSync(gfx++);
|
||||
gDPSetEnvColor(gfx++, 255, 255, 255, 32);
|
||||
gDPSetOtherMode(gfx++,
|
||||
G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_POINT | G_TT_NONE | G_TL_TILE |
|
||||
G_TD_CLAMP | G_TP_NONE | G_CYC_2CYCLE | G_PM_NPRIMITIVE,
|
||||
G_AC_NONE | G_ZS_PRIM | AA_EN | CVG_DST_CLAMP | ZMODE_OPA | CVG_X_ALPHA |
|
||||
GBL_c1(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1) |
|
||||
GBL_c2(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1));
|
||||
gDPSetCombineLERP(gfx++, 0, 0, 0, TEXEL0, 1, 0, TEXEL1, ENVIRONMENT, 0, 0, 0, COMBINED, 0, 0, 0, COMBINED);
|
||||
|
||||
dy = (this->width > 320) ? 2 : 4;
|
||||
y = this->height;
|
||||
y2 = 0;
|
||||
|
||||
while (y > 0) {
|
||||
s32 uls = 0;
|
||||
s32 lrs = this->width - 1;
|
||||
s32 ult;
|
||||
s32 lrt;
|
||||
|
||||
dy = CLAMP_MAX(dy, y);
|
||||
|
||||
ult = y2;
|
||||
lrt = (y2 + dy - 1);
|
||||
|
||||
gDPLoadMultiTile(gfx++, this->fbufSave, 0x0000, G_TX_RENDERTILE, G_IM_FMT_RGBA, G_IM_SIZ_16b, this->width,
|
||||
this->height, uls, ult, lrs, lrt, 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);
|
||||
if (1) {}
|
||||
gDPLoadMultiTile(gfx++, this->cvgSave, 0x0160, rtile, G_IM_FMT_I, G_IM_SIZ_8b, this->width, this->height,
|
||||
uls, ult, lrs, lrt, 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);
|
||||
if (1) {}
|
||||
gSPTextureRectangle(gfx++, uls << 2, ult << 2, (lrs + 1) << 2, (lrt + 1) << 2, G_TX_RENDERTILE, uls << 5,
|
||||
ult << 5, 1 << 10, 1 << 10);
|
||||
|
||||
y2 += dy;
|
||||
y -= dy;
|
||||
}
|
||||
|
||||
gDPPipeSync(gfx++);
|
||||
*gfxp = gfx;
|
||||
}
|
||||
}
|
||||
#else
|
||||
#pragma GLOBAL_ASM("./asm/non_matchings/code/PreRender/func_80170798.asm")
|
||||
#endif
|
||||
|
||||
void func_80170AE0(PreRenderContext* this, Gfx** gfxp, s32 alpha) {
|
||||
func_8016FF90(this, gfxp, this->fbufSave, this->fbuf, 255, 255, 255, alpha);
|
||||
}
|
||||
|
||||
void func_80170B28(PreRenderContext* this, Gfx** gfxp) {
|
||||
func_8016FF70(this, gfxp, this->fbufSave, this->fbuf);
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies an anti-alias filter where the middle pixel (index 7) correspond to (x, y) in this 3x5 rectangle
|
||||
* _ _ _ _ _
|
||||
* | 0 1 2 3 4 |
|
||||
* | 5 6 7 8 9 |
|
||||
* | A B C D E |
|
||||
* ‾ ‾ ‾ ‾ ‾
|
||||
*/
|
||||
void PreRender_AntiAliasAlgorithm(PreRenderContext* this, s32 x, s32 y) {
|
||||
s32 i;
|
||||
s32 j;
|
||||
s32 buffA[3 * 5];
|
||||
s32 buffR[3 * 5];
|
||||
s32 buffG[3 * 5];
|
||||
s32 buffB[3 * 5];
|
||||
s32 x1;
|
||||
s32 y1;
|
||||
s32 pad;
|
||||
s32 pxR;
|
||||
s32 pxG;
|
||||
s32 pxB;
|
||||
s32 pxR2;
|
||||
s32 pxG2;
|
||||
s32 pxB2;
|
||||
Color_RGB5A1 pxIn;
|
||||
Color_RGB5A1 pxOut;
|
||||
u32 pxR3;
|
||||
u32 pxG3;
|
||||
u32 pxB3;
|
||||
|
||||
for (i = 0; i < 3 * 5; i++) {
|
||||
x1 = (i % 5) + x - 2;
|
||||
y1 = (i / 5) + y - 1;
|
||||
|
||||
if (x1 < 0) {
|
||||
x1 = 0;
|
||||
} else if (x1 > (this->width - 1)) {
|
||||
x1 = this->width - 1;
|
||||
}
|
||||
if (y1 < 0) {
|
||||
y1 = 0;
|
||||
} else if (y1 > (this->height - 1)) {
|
||||
y1 = this->height - 1;
|
||||
}
|
||||
|
||||
pxIn.rgba = this->fbufSave[x1 + y1 * this->width];
|
||||
buffR[i] = (pxIn.r << 3) | (pxIn.r >> 2);
|
||||
buffG[i] = (pxIn.g << 3) | (pxIn.g >> 2);
|
||||
buffB[i] = (pxIn.b << 3) | (pxIn.b >> 2);
|
||||
buffA[i] = this->cvgSave[x1 + y1 * this->width] >> 5;
|
||||
}
|
||||
|
||||
pxR = pxR2 = buffR[7];
|
||||
pxG = pxG2 = buffG[7];
|
||||
pxB = pxB2 = buffB[7];
|
||||
|
||||
for (i = 1; i < 3 * 5; i += 2) {
|
||||
if (buffA[i] == 7) {
|
||||
if (pxR < buffR[i]) {
|
||||
for (j = 1; j < 15; j += 2) {
|
||||
if ((i != j) && (buffR[j] >= buffR[i]) && (buffA[j] == 7)) {
|
||||
pxR = buffR[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pxG < buffG[i]) {
|
||||
for (j = 1; j < 15; j += 2) {
|
||||
if ((i != j) && (buffG[j] >= buffG[i]) && (buffA[j] == 7)) {
|
||||
pxG = buffG[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pxB < buffB[i]) {
|
||||
for (j = 1; j < 15; j += 2) {
|
||||
if ((i != j) && (buffB[j] >= buffB[i]) && (buffA[j] == 7)) {
|
||||
pxB = buffB[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (1) {}
|
||||
if (pxR2 > buffR[i]) {
|
||||
for (j = 1; j < 15; j += 2) {
|
||||
if ((i != j) && (buffR[j] <= buffR[i]) && (buffA[j] == 7)) {
|
||||
pxR2 = buffR[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pxG2 > buffG[i]) {
|
||||
for (j = 1; j < 15; j += 2) {
|
||||
if ((i != j) && (buffG[j] <= buffG[i]) && (buffA[j] == 7)) {
|
||||
pxG2 = buffG[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pxB2 > buffB[i]) {
|
||||
for (j = 1; j < 15; j += 2) {
|
||||
if ((i != j) && (buffB[j] <= buffB[i]) && (buffA[j] == 7)) {
|
||||
pxB2 = buffB[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pad = 7 - buffA[7];
|
||||
pxR3 = buffR[7] + (((s32)((pad * ((pxR + pxR2) - (buffR[7] << 1))) + 4)) >> 3);
|
||||
pxG3 = buffG[7] + (((s32)((pad * ((pxG + pxG2) - (buffG[7] << 1))) + 4)) >> 3);
|
||||
pxB3 = buffB[7] + (((s32)((pad * ((pxB + pxB2) - (buffB[7] << 1))) + 4)) >> 3);
|
||||
|
||||
pxOut.r = pxR3 >> 3;
|
||||
pxOut.g = pxG3 >> 3;
|
||||
pxOut.b = pxB3 >> 3;
|
||||
pxOut.a = 1;
|
||||
this->fbufSave[x + y * this->width] = pxOut.rgba;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies an anti-alias filter to the current prerender
|
||||
*/
|
||||
void PreRender_ApplyAntiAliasingFilter(PreRenderContext* this) {
|
||||
s32 x;
|
||||
s32 y;
|
||||
s32 cvg;
|
||||
|
||||
for (y = 0; y < this->height; y++) {
|
||||
for (x = 0; x < this->width; x++) {
|
||||
cvg = this->cvgSave[x + y * this->width];
|
||||
cvg >>= 5;
|
||||
cvg++;
|
||||
|
||||
if (cvg != 8) {
|
||||
PreRender_AntiAliasAlgorithm(this, x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("./asm/non_matchings/code/PreRender/func_801716C4.asm")
|
||||
|
||||
#pragma GLOBAL_ASM("./asm/non_matchings/code/PreRender/func_801717F8.asm")
|
||||
|
||||
/**
|
||||
* Applies filters to the framebuffer prerender to make it look smoother
|
||||
*/
|
||||
void PreRender_ApplyFilters(PreRenderContext* this) {
|
||||
if (this->cvgSave == NULL || this->fbufSave == NULL) {
|
||||
this->unk_4D = 0;
|
||||
} else {
|
||||
this->unk_4D = 1;
|
||||
PreRender_ApplyAntiAliasingFilter(this);
|
||||
func_801717F8(this);
|
||||
this->unk_4D = 2;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes `PreRender_ApplyFilters` onto a new "slowly" thread
|
||||
*/
|
||||
void PreRender_ApplyFiltersSlowlyInit(PreRenderContext* this) {
|
||||
if ((this->cvgSave != NULL) && (this->fbufSave != NULL)) {
|
||||
if (D_801F6FC0) {
|
||||
StackCheck_Cleanup(&slowlyStackEntry);
|
||||
Slowly_Stop(&D_801F6E00);
|
||||
}
|
||||
|
||||
this->unk_4D = 1;
|
||||
StackCheck_Init(&slowlyStackEntry, slowlyStack, &slowlyStack[4096], 0, 0x100, D_801DFC60);
|
||||
Slowly_Start(&D_801F6E00, &D_801F7FE8, PreRender_ApplyFilters, this, NULL);
|
||||
D_801F6FC0 = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys the "slowly" thread
|
||||
*/
|
||||
void PreRender_ApplyFiltersSlowlyDestroy(PreRenderContext* this) {
|
||||
if (D_801F6FC0) {
|
||||
StackCheck_Cleanup(&slowlyStackEntry);
|
||||
Slowly_Stop(&D_801F6E00);
|
||||
D_801F6FC0 = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Unused, likely since `PreRender_ApplyFilters` already handles NULL checks
|
||||
void func_801720C4(PreRenderContext* this) {
|
||||
if ((this->cvgSave != NULL) && (this->fbufSave != NULL)) {
|
||||
PreRender_ApplyFilters(this);
|
||||
}
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("./asm/non_matchings/code/PreRender/func_801720FC.asm")
|
||||
|
||||
void func_80172758(Gfx** gfxp, void* timg, void* tlut, u16 width, u16 height, u8 fmt, u8 siz, u16 tt, u16 arg8, f32 x,
|
||||
f32 y, f32 xScale, f32 yScale, u32 flags) {
|
||||
PreRenderParams params;
|
||||
PreRenderParams* paramsp = ¶ms;
|
||||
|
||||
params.timg = timg;
|
||||
params.tlut = tlut;
|
||||
params.width = width;
|
||||
params.height = height;
|
||||
params.fmt = fmt;
|
||||
params.siz = siz;
|
||||
params.tt = tt;
|
||||
params.unk_10 = arg8;
|
||||
params.x = x;
|
||||
params.y = y;
|
||||
params.xScale = xScale;
|
||||
params.yScale = yScale;
|
||||
params.flags = flags;
|
||||
|
||||
func_801720FC(paramsp, gfxp);
|
||||
}
|
@ -3062,10 +3062,10 @@
|
||||
0x8016F5A8:("func_8016F5A8",),
|
||||
0x8016FC78:("func_8016FC78",),
|
||||
0x8016FC98:("func_8016FC98",),
|
||||
0x8016FCF0:("func_8016FCF0",),
|
||||
0x8016FD2C:("func_8016FD2C",),
|
||||
0x8016FD60:("func_8016FD60",),
|
||||
0x8016FD94:("func_8016FD94",),
|
||||
0x8016FCF0:("PreRender_SetValuesSave",),
|
||||
0x8016FD2C:("PreRender_Init",),
|
||||
0x8016FD60:("PreRender_SetValues",),
|
||||
0x8016FD94:("PreRender_Destroy",),
|
||||
0x8016FDB8:("func_8016FDB8",),
|
||||
0x8016FF70:("func_8016FF70",),
|
||||
0x8016FF90:("func_8016FF90",),
|
||||
@ -3079,13 +3079,13 @@
|
||||
0x80170798:("func_80170798",),
|
||||
0x80170AE0:("func_80170AE0",),
|
||||
0x80170B28:("func_80170B28",),
|
||||
0x80170B4C:("func_80170B4C",),
|
||||
0x8017160C:("func_8017160C",),
|
||||
0x80170B4C:("PreRender_AntiAliasAlgorithm",),
|
||||
0x8017160C:("PreRender_ApplyAntiAliasingFilter",),
|
||||
0x801716C4:("func_801716C4",),
|
||||
0x801717F8:("func_801717F8",),
|
||||
0x80171F4C:("func_80171F4C",),
|
||||
0x80171FA8:("func_80171FA8",),
|
||||
0x80172078:("func_80172078",),
|
||||
0x80171F4C:("PreRender_ApplyFilters",),
|
||||
0x80171FA8:("PreRender_ApplyFiltersSlowlyInit",),
|
||||
0x80172078:("PreRender_ApplyFiltersSlowlyDestroy",),
|
||||
0x801720C4:("func_801720C4",),
|
||||
0x801720FC:("func_801720FC",),
|
||||
0x80172758:("func_80172758",),
|
||||
|
Loading…
Reference in New Issue
Block a user