mirror of
https://github.com/zeldaret/oot.git
synced 2025-07-13 03:14:38 +00:00
Merge branch 'master' into doc_pause_menu
This commit is contained in:
commit
d43613694c
188 changed files with 4328 additions and 3791 deletions
|
@ -43,19 +43,19 @@ void PreRender_Destroy(PreRender* this) {
|
|||
/**
|
||||
* Copies RGBA16 image `img` to `imgDst`
|
||||
*
|
||||
* @param gfxp Display list pointer
|
||||
* @param gfxP Display list pointer
|
||||
* @param img Image to copy from
|
||||
* @param imgDst Buffer to copy to
|
||||
*/
|
||||
void PreRender_CopyImage(PreRender* this, Gfx** gfxp, void* img, void* imgDst) {
|
||||
void PreRender_CopyImage(PreRender* this, Gfx** gfxP, void* img, void* imgDst) {
|
||||
Gfx* gfx;
|
||||
s32 rowsRemaining;
|
||||
s32 curRow;
|
||||
s32 nRows;
|
||||
|
||||
LogUtils_CheckNullPointer("this", this, "../PreRender.c", 215);
|
||||
LogUtils_CheckNullPointer("glistpp", gfxp, "../PreRender.c", 216);
|
||||
gfx = *gfxp;
|
||||
LogUtils_CheckNullPointer("glistpp", gfxP, "../PreRender.c", 216);
|
||||
gfx = *gfxP;
|
||||
LogUtils_CheckNullPointer("glistp", gfx, "../PreRender.c", 218);
|
||||
|
||||
gDPPipeSync(gfx++);
|
||||
|
@ -101,22 +101,22 @@ void PreRender_CopyImage(PreRender* this, Gfx** gfxp, void* img, void* imgDst) {
|
|||
|
||||
gDPPipeSync(gfx++);
|
||||
gDPSetColorImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, this->width, this->fbuf);
|
||||
*gfxp = gfx;
|
||||
*gfxP = gfx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies part of `this->fbufSave` in the region (this->ulx, this->uly), (this->lrx, this->lry) to the same location in
|
||||
* `this->fbuf`.
|
||||
*/
|
||||
void PreRender_CopyImageRegionImpl(PreRender* this, Gfx** gfxp) {
|
||||
void PreRender_CopyImageRegionImpl(PreRender* this, Gfx** gfxP) {
|
||||
Gfx* gfx;
|
||||
s32 rowsRemaining;
|
||||
s32 curRow;
|
||||
s32 nRows;
|
||||
|
||||
LogUtils_CheckNullPointer("this", this, "../PreRender.c", 278);
|
||||
LogUtils_CheckNullPointer("glistpp", gfxp, "../PreRender.c", 279);
|
||||
gfx = *gfxp;
|
||||
LogUtils_CheckNullPointer("glistpp", gfxP, "../PreRender.c", 279);
|
||||
gfx = *gfxP;
|
||||
LogUtils_CheckNullPointer("glistp", gfx, "../PreRender.c", 281);
|
||||
|
||||
gDPPipeSync(gfx++);
|
||||
|
@ -164,22 +164,22 @@ void PreRender_CopyImageRegionImpl(PreRender* this, Gfx** gfxp) {
|
|||
gDPPipeSync(gfx++);
|
||||
gDPSetColorImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, this->width, this->fbuf);
|
||||
gDPSetScissor(gfx++, G_SC_NON_INTERLACE, 0, 0, this->width, this->height);
|
||||
*gfxp = gfx;
|
||||
*gfxP = gfx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies `buf` to `bufSave`, discarding the alpha channel and modulating the RGB channel by
|
||||
* the color ('r', 'g', 'b', 'a')
|
||||
*/
|
||||
void func_800C170C(PreRender* this, Gfx** gfxp, void* buf, void* bufSave, u32 r, u32 g, u32 b, u32 a) {
|
||||
void func_800C170C(PreRender* this, Gfx** gfxP, void* buf, void* bufSave, u32 r, u32 g, u32 b, u32 a) {
|
||||
Gfx* gfx;
|
||||
s32 rowsRemaining;
|
||||
s32 curRow;
|
||||
s32 nRows;
|
||||
|
||||
LogUtils_CheckNullPointer("this", this, "../PreRender.c", 343);
|
||||
LogUtils_CheckNullPointer("glistpp", gfxp, "../PreRender.c", 344);
|
||||
gfx = *gfxp;
|
||||
LogUtils_CheckNullPointer("glistpp", gfxP, "../PreRender.c", 344);
|
||||
gfx = *gfxP;
|
||||
LogUtils_CheckNullPointer("glistp", gfx, "../PreRender.c", 346);
|
||||
|
||||
gDPPipeSync(gfx++);
|
||||
|
@ -232,33 +232,33 @@ void func_800C170C(PreRender* this, Gfx** gfxp, void* buf, void* bufSave, u32 r,
|
|||
|
||||
gDPPipeSync(gfx++);
|
||||
gDPSetColorImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, this->width, this->fbuf);
|
||||
*gfxp = gfx;
|
||||
*gfxP = gfx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies `fbuf` to `fbufSave`, discarding the alpha channel and leaving the rgb channel unchanged
|
||||
*/
|
||||
void func_800C1AE8(PreRender* this, Gfx** gfxp, void* fbuf, void* fbufSave) {
|
||||
func_800C170C(this, gfxp, fbuf, fbufSave, 255, 255, 255, 255);
|
||||
void func_800C1AE8(PreRender* this, Gfx** gfxP, void* fbuf, void* fbufSave) {
|
||||
func_800C170C(this, gfxP, fbuf, fbufSave, 255, 255, 255, 255);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the coverage values stored in the RGBA16 format `img` with dimensions `this->width`, `this->height` and
|
||||
* converts it to an 8-bpp intensity image.
|
||||
*
|
||||
* @param gfxp Display list pointer
|
||||
* @param gfxP Display list pointer
|
||||
* @param img Image to read coverage from
|
||||
* @param cvgDst Buffer to store coverage into
|
||||
*/
|
||||
void PreRender_CoverageRgba16ToI8(PreRender* this, Gfx** gfxp, void* img, void* cvgDst) {
|
||||
void PreRender_CoverageRgba16ToI8(PreRender* this, Gfx** gfxP, void* img, void* cvgDst) {
|
||||
Gfx* gfx;
|
||||
s32 rowsRemaining;
|
||||
s32 curRow;
|
||||
s32 nRows;
|
||||
|
||||
LogUtils_CheckNullPointer("this", this, "../PreRender.c", 422);
|
||||
LogUtils_CheckNullPointer("glistpp", gfxp, "../PreRender.c", 423);
|
||||
gfx = *gfxp;
|
||||
LogUtils_CheckNullPointer("glistpp", gfxP, "../PreRender.c", 423);
|
||||
gfx = *gfxP;
|
||||
LogUtils_CheckNullPointer("glistp", gfx, "../PreRender.c", 425);
|
||||
|
||||
gDPPipeSync(gfx++);
|
||||
|
@ -326,30 +326,30 @@ void PreRender_CoverageRgba16ToI8(PreRender* this, Gfx** gfxp, void* img, void*
|
|||
// Reset the color image to the current framebuffer
|
||||
gDPPipeSync(gfx++);
|
||||
gDPSetColorImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, this->width, this->fbuf);
|
||||
*gfxp = gfx;
|
||||
*gfxP = gfx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves zbuf to zbufSave
|
||||
*/
|
||||
void PreRender_SaveZBuffer(PreRender* this, Gfx** gfxp) {
|
||||
void PreRender_SaveZBuffer(PreRender* this, Gfx** gfxP) {
|
||||
LogUtils_CheckNullPointer("this->zbuf_save", this->zbufSave, "../PreRender.c", 481);
|
||||
LogUtils_CheckNullPointer("this->zbuf", this->zbuf, "../PreRender.c", 482);
|
||||
|
||||
if ((this->zbufSave != NULL) && (this->zbuf != NULL)) {
|
||||
PreRender_CopyImage(this, gfxp, this->zbuf, this->zbufSave);
|
||||
PreRender_CopyImage(this, gfxP, this->zbuf, this->zbufSave);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves fbuf to fbufSave
|
||||
*/
|
||||
void PreRender_SaveFramebuffer(PreRender* this, Gfx** gfxp) {
|
||||
void PreRender_SaveFramebuffer(PreRender* this, Gfx** gfxP) {
|
||||
LogUtils_CheckNullPointer("this->fbuf_save", this->fbufSave, "../PreRender.c", 495);
|
||||
LogUtils_CheckNullPointer("this->fbuf", this->fbuf, "../PreRender.c", 496);
|
||||
|
||||
if ((this->fbufSave != NULL) && (this->fbuf != NULL)) {
|
||||
func_800C1AE8(this, gfxp, this->fbuf, this->fbufSave);
|
||||
func_800C1AE8(this, gfxP, this->fbuf, this->fbufSave);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -357,8 +357,8 @@ void PreRender_SaveFramebuffer(PreRender* this, Gfx** gfxp) {
|
|||
* Fetches the coverage of the current framebuffer into an image of the same format as the current color image, storing
|
||||
* it over the framebuffer in memory.
|
||||
*/
|
||||
void PreRender_FetchFbufCoverage(PreRender* this, Gfx** gfxp) {
|
||||
Gfx* gfx = *gfxp;
|
||||
void PreRender_FetchFbufCoverage(PreRender* this, Gfx** gfxP) {
|
||||
Gfx* gfx = *gfxP;
|
||||
|
||||
gDPPipeSync(gfx++);
|
||||
// Set the blend color to full white and set maximum depth.
|
||||
|
@ -392,33 +392,33 @@ void PreRender_FetchFbufCoverage(PreRender* this, Gfx** gfxp) {
|
|||
gDPFillRectangle(gfx++, 0, 0, this->width, this->height);
|
||||
gDPPipeSync(gfx++);
|
||||
|
||||
*gfxp = gfx;
|
||||
*gfxP = gfx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the coverage of the current framebuffer `this->fbuf` to an I8 image at `this->cvgSave`. Overwrites
|
||||
* `this->fbuf` in the process.
|
||||
*/
|
||||
void PreRender_DrawCoverage(PreRender* this, Gfx** gfxp) {
|
||||
PreRender_FetchFbufCoverage(this, gfxp);
|
||||
void PreRender_DrawCoverage(PreRender* this, Gfx** gfxP) {
|
||||
PreRender_FetchFbufCoverage(this, gfxP);
|
||||
LogUtils_CheckNullPointer("this->cvg_save", this->cvgSave, "../PreRender.c", 532);
|
||||
if (this->cvgSave != NULL) {
|
||||
PreRender_CoverageRgba16ToI8(this, gfxp, this->fbuf, this->cvgSave);
|
||||
PreRender_CoverageRgba16ToI8(this, gfxP, this->fbuf, this->cvgSave);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Restores zbufSave to zbuf
|
||||
*/
|
||||
void PreRender_RestoreZBuffer(PreRender* this, Gfx** gfxp) {
|
||||
PreRender_CopyImage(this, gfxp, this->zbufSave, this->zbuf);
|
||||
void PreRender_RestoreZBuffer(PreRender* this, Gfx** gfxP) {
|
||||
PreRender_CopyImage(this, gfxP, this->zbufSave, this->zbuf);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws a full-screen image to the current framebuffer, that sources the rgb channel from `this->fbufSave` and
|
||||
* the alpha channel from `this->cvgSave` modulated by environment color.
|
||||
*/
|
||||
void func_800C213C(PreRender* this, Gfx** gfxp) {
|
||||
void func_800C213C(PreRender* this, Gfx** gfxP) {
|
||||
Gfx* gfx;
|
||||
s32 rowsRemaining;
|
||||
s32 curRow;
|
||||
|
@ -427,8 +427,8 @@ void func_800C213C(PreRender* this, Gfx** gfxp) {
|
|||
|
||||
if (this->cvgSave != NULL) {
|
||||
LogUtils_CheckNullPointer("this", this, "../PreRender.c", 563);
|
||||
LogUtils_CheckNullPointer("glistpp", gfxp, "../PreRender.c", 564);
|
||||
gfx = *gfxp;
|
||||
LogUtils_CheckNullPointer("glistpp", gfxP, "../PreRender.c", 564);
|
||||
gfx = *gfxP;
|
||||
LogUtils_CheckNullPointer("glistp", gfx, "../PreRender.c", 566);
|
||||
|
||||
gDPPipeSync(gfx++);
|
||||
|
@ -482,23 +482,23 @@ void func_800C213C(PreRender* this, Gfx** gfxp) {
|
|||
}
|
||||
|
||||
gDPPipeSync(gfx++);
|
||||
*gfxp = gfx;
|
||||
*gfxP = gfx;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies fbufSave to fbuf
|
||||
*/
|
||||
void PreRender_RestoreFramebuffer(PreRender* this, Gfx** gfxp) {
|
||||
PreRender_CopyImage(this, gfxp, this->fbufSave, this->fbuf);
|
||||
void PreRender_RestoreFramebuffer(PreRender* this, Gfx** gfxP) {
|
||||
PreRender_CopyImage(this, gfxP, this->fbufSave, this->fbuf);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies part of `this->fbufSave` in the region (this->ulx, this->uly), (this->lrx, this->lry) to the same location in
|
||||
* `this->fbuf`.
|
||||
*/
|
||||
void PreRender_CopyImageRegion(PreRender* this, Gfx** gfxp) {
|
||||
PreRender_CopyImageRegionImpl(this, gfxp);
|
||||
void PreRender_CopyImageRegion(PreRender* this, Gfx** gfxP) {
|
||||
PreRender_CopyImageRegionImpl(this, gfxP);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,97 +0,0 @@
|
|||
#include "global.h"
|
||||
|
||||
// Note : This file is related to z_vismono, the original name was probably z_vis<something before "mono"
|
||||
// alphabetically>
|
||||
|
||||
Gfx D_8012AC00[] = {
|
||||
gsDPSetOtherMode(G_AD_PATTERN | G_CD_MAGICSQ | G_CK_NONE | G_TC_CONV | 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),
|
||||
gsDPFillRectangle(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1),
|
||||
gsDPPipeSync(),
|
||||
gsDPSetBlendColor(0, 0, 0, 8),
|
||||
gsSPEndDisplayList(),
|
||||
};
|
||||
|
||||
Gfx D_8012AC28[] = {
|
||||
gsDPSetOtherMode(G_AD_PATTERN | G_CD_MAGICSQ | G_CK_NONE | G_TC_CONV | 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 | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | FORCE_BL |
|
||||
GBL_c1(G_BL_CLR_FOG, G_BL_A_FOG, G_BL_CLR_MEM, G_BL_A_MEM) |
|
||||
GBL_c2(G_BL_CLR_FOG, G_BL_A_FOG, G_BL_CLR_MEM, G_BL_A_MEM)),
|
||||
gsDPFillRectangle(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1),
|
||||
gsSPEndDisplayList(),
|
||||
};
|
||||
|
||||
Gfx D_8012AC40[] = {
|
||||
gsDPSetOtherMode(G_AD_PATTERN | G_CD_MAGICSQ | G_CK_NONE | G_TC_CONV | 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 | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | FORCE_BL |
|
||||
GBL_c1(G_BL_CLR_IN, G_BL_0, G_BL_CLR_MEM, G_BL_A_MEM) |
|
||||
GBL_c2(G_BL_CLR_IN, G_BL_0, G_BL_CLR_MEM, G_BL_A_MEM)),
|
||||
|
||||
gsDPFillRectangle(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1),
|
||||
gsSPEndDisplayList(),
|
||||
};
|
||||
|
||||
Gfx D_8012AC58[] = {
|
||||
gsDPSetCombineMode(G_CC_PRIMITIVE, G_CC_PRIMITIVE),
|
||||
gsDPSetOtherMode(G_AD_NOTPATTERN | G_CD_DISABLE | G_CK_NONE | G_TC_CONV | 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),
|
||||
gsDPFillRectangle(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1),
|
||||
gsDPSetOtherMode(G_AD_PATTERN | G_CD_MAGICSQ | G_CK_NONE | G_TC_CONV | 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 | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | FORCE_BL |
|
||||
GBL_c1(G_BL_CLR_IN, G_BL_0, G_BL_CLR_MEM, G_BL_A_MEM) |
|
||||
GBL_c2(G_BL_CLR_IN, G_BL_0, G_BL_CLR_MEM, G_BL_A_MEM)),
|
||||
gsDPFillRectangle(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1),
|
||||
gsSPEndDisplayList(),
|
||||
};
|
||||
|
||||
// Init
|
||||
void func_800ACE70(struct_801664F0* this) {
|
||||
this->type = 0;
|
||||
this->setScissor = false;
|
||||
this->color.r = 255;
|
||||
this->color.g = 255;
|
||||
this->color.b = 255;
|
||||
this->color.a = 255;
|
||||
}
|
||||
|
||||
// Destroy
|
||||
void func_800ACE90(struct_801664F0* this) {
|
||||
}
|
||||
|
||||
// Draw
|
||||
void func_800ACE98(struct_801664F0* this, Gfx** gfxp) {
|
||||
Gfx* gfx = *gfxp;
|
||||
|
||||
gDPPipeSync(gfx++);
|
||||
gDPSetPrimDepth(gfx++, 0xFFFF, 0xFFFF);
|
||||
|
||||
if (this->setScissor == true) {
|
||||
gDPSetScissor(gfx++, G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
}
|
||||
|
||||
switch (this->type) {
|
||||
case 1:
|
||||
gSPDisplayList(gfx++, D_8012AC40);
|
||||
break;
|
||||
case 2:
|
||||
gDPSetColor(gfx++, G_SETPRIMCOLOR, this->color.rgba);
|
||||
gSPDisplayList(gfx++, D_8012AC58);
|
||||
break;
|
||||
case 3:
|
||||
gDPSetColor(gfx++, G_SETBLENDCOLOR, this->color.rgba);
|
||||
gSPDisplayList(gfx++, D_8012AC00);
|
||||
break;
|
||||
case 4:
|
||||
gDPSetColor(gfx++, G_SETFOGCOLOR, this->color.rgba);
|
||||
gSPDisplayList(gfx++, D_8012AC28);
|
||||
break;
|
||||
}
|
||||
|
||||
gDPPipeSync(gfx++);
|
||||
*gfxp = gfx;
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
#include "global.h"
|
||||
|
||||
// Note : This file is related to z_vismono, the original name was probably z_vis<something after "mono" alphabetically>
|
||||
|
||||
// z-buffer
|
||||
extern u16 D_0E000000[];
|
||||
|
||||
// Init
|
||||
void func_800AD920(struct_80166500* this) {
|
||||
this->useRgba = false;
|
||||
this->setScissor = false;
|
||||
this->primColor.r = 255;
|
||||
this->primColor.g = 255;
|
||||
this->primColor.b = 255;
|
||||
this->primColor.a = 255;
|
||||
this->envColor.a = 255;
|
||||
this->envColor.r = 0;
|
||||
this->envColor.g = 0;
|
||||
this->envColor.b = 0;
|
||||
}
|
||||
|
||||
// Destroy
|
||||
void func_800AD950(struct_80166500* this) {
|
||||
}
|
||||
|
||||
// Draw
|
||||
void func_800AD958(struct_80166500* this, Gfx** gfxp) {
|
||||
Gfx* gfx = *gfxp;
|
||||
u16* tex = D_0E000000;
|
||||
s32 fmt = !this->useRgba ? G_IM_FMT_IA : G_IM_FMT_RGBA;
|
||||
s32 y;
|
||||
s32 height = 6;
|
||||
|
||||
gDPPipeSync(gfx++);
|
||||
if (this->setScissor == true) {
|
||||
gDPSetScissor(gfx++, G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
}
|
||||
|
||||
gDPSetOtherMode(gfx++,
|
||||
G_AD_DISABLE | G_CD_MAGICSQ | 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);
|
||||
gDPSetCombineLERP(gfx++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT,
|
||||
PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT);
|
||||
|
||||
gDPSetColor(gfx++, G_SETPRIMCOLOR, this->primColor.rgba);
|
||||
gDPSetColor(gfx++, G_SETENVCOLOR, this->envColor.rgba);
|
||||
|
||||
for (y = 0; y <= SCREEN_HEIGHT - height; y += height) {
|
||||
gDPLoadTextureBlock(gfx++, tex, fmt, G_IM_SIZ_16b, SCREEN_WIDTH, height, 0, G_TX_NOMIRROR | G_TX_CLAMP,
|
||||
G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
|
||||
|
||||
gSPTextureRectangle(gfx++, 0, y << 2, SCREEN_WIDTH << 2, (y + height) << 2, G_TX_RENDERTILE, 0, 0, 1 << 10,
|
||||
1 << 10);
|
||||
tex += SCREEN_WIDTH * height;
|
||||
}
|
||||
|
||||
gDPPipeSync(gfx++);
|
||||
*gfxp = gfx;
|
||||
}
|
|
@ -61,7 +61,7 @@ s32 func_800BB2B4(Vec3f* pos, f32* roll, f32* fov, CutsceneCameraPoint* point, s
|
|||
}
|
||||
*curFrame += advance;
|
||||
if (*curFrame >= 1) {
|
||||
if (point[++*keyFrame + 3].continueFlag == CS_CMD_STOP) {
|
||||
if (point[++*keyFrame + 3].continueFlag == CS_CAM_STOP) {
|
||||
*keyFrame = 0;
|
||||
ret = true;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
u32 gIsCtrlr2Valid = false;
|
||||
|
||||
void func_800D31A0(void) {
|
||||
NORETURN void func_800D31A0(void) {
|
||||
osSyncPrintf(VT_FGCOL(RED) "\n**** Freeze!! ****\n" VT_RST);
|
||||
while (true) {
|
||||
Sleep_Msec(1000);
|
||||
|
|
|
@ -1304,19 +1304,25 @@ void Fault_HungupFaultClient(const char* exp1, const char* exp2) {
|
|||
* error occurs. The parameters specify two messages detailing the error, one
|
||||
* or both may be NULL.
|
||||
*/
|
||||
void Fault_AddHungupAndCrashImpl(const char* exp1, const char* exp2) {
|
||||
NORETURN void Fault_AddHungupAndCrashImpl(const char* exp1, const char* exp2) {
|
||||
FaultClient client;
|
||||
s32 pad;
|
||||
|
||||
Fault_AddClient(&client, Fault_HungupFaultClient, (void*)exp1, (void*)exp2);
|
||||
*(u32*)0x11111111 = 0; // trigger an exception via unaligned memory access
|
||||
|
||||
// Since the above line triggers an exception and transfers execution to the fault handler
|
||||
// this function does not return and the rest of the function is unreachable.
|
||||
#ifdef __GNUC__
|
||||
__builtin_unreachable();
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Like `Fault_AddHungupAndCrashImpl`, however provides a fixed message containing
|
||||
* filename and line number
|
||||
*/
|
||||
void Fault_AddHungupAndCrash(const char* file, s32 line) {
|
||||
NORETURN void Fault_AddHungupAndCrash(const char* file, s32 line) {
|
||||
char msg[256];
|
||||
|
||||
sprintf(msg, "HungUp %s:%d", file, line);
|
||||
|
|
101
src/code/game.c
101
src/code/game.c
|
@ -2,9 +2,9 @@
|
|||
#include "terminal.h"
|
||||
|
||||
SpeedMeter D_801664D0;
|
||||
struct_801664F0 D_801664F0;
|
||||
struct_80166500 D_80166500;
|
||||
VisMono sMonoColors;
|
||||
VisCvg sVisCvg;
|
||||
VisZBuf sVisZBuf;
|
||||
VisMono sVisMono;
|
||||
ViMode sViMode;
|
||||
FaultClient sGameFaultClient;
|
||||
u16 sLastButtonPressed;
|
||||
|
@ -22,40 +22,43 @@ void GameState_FaultPrint(void) {
|
|||
}
|
||||
}
|
||||
|
||||
void GameState_SetFBFilter(Gfx** gfx) {
|
||||
Gfx* gfxP = *gfx;
|
||||
void GameState_SetFBFilter(Gfx** gfxP) {
|
||||
Gfx* gfx = *gfxP;
|
||||
|
||||
if ((R_FB_FILTER_TYPE > 0) && (R_FB_FILTER_TYPE < 5)) {
|
||||
D_801664F0.type = R_FB_FILTER_TYPE;
|
||||
D_801664F0.color.r = R_FB_FILTER_PRIM_COLOR(0);
|
||||
D_801664F0.color.g = R_FB_FILTER_PRIM_COLOR(1);
|
||||
D_801664F0.color.b = R_FB_FILTER_PRIM_COLOR(2);
|
||||
D_801664F0.color.a = R_FB_FILTER_A;
|
||||
func_800ACE98(&D_801664F0, &gfxP);
|
||||
} else if ((R_FB_FILTER_TYPE == 5) || (R_FB_FILTER_TYPE == 6)) {
|
||||
D_80166500.useRgba = (R_FB_FILTER_TYPE == 6);
|
||||
D_80166500.primColor.r = R_FB_FILTER_PRIM_COLOR(0);
|
||||
D_80166500.primColor.g = R_FB_FILTER_PRIM_COLOR(1);
|
||||
D_80166500.primColor.b = R_FB_FILTER_PRIM_COLOR(2);
|
||||
D_80166500.primColor.a = R_FB_FILTER_A;
|
||||
D_80166500.envColor.r = R_FB_FILTER_ENV_COLOR(0);
|
||||
D_80166500.envColor.g = R_FB_FILTER_ENV_COLOR(1);
|
||||
D_80166500.envColor.b = R_FB_FILTER_ENV_COLOR(2);
|
||||
D_80166500.envColor.a = R_FB_FILTER_A;
|
||||
func_800AD958(&D_80166500, &gfxP);
|
||||
} else if (R_FB_FILTER_TYPE == 7) {
|
||||
sMonoColors.unk_00 = 0;
|
||||
sMonoColors.primColor.r = R_FB_FILTER_PRIM_COLOR(0);
|
||||
sMonoColors.primColor.g = R_FB_FILTER_PRIM_COLOR(1);
|
||||
sMonoColors.primColor.b = R_FB_FILTER_PRIM_COLOR(2);
|
||||
sMonoColors.primColor.a = R_FB_FILTER_A;
|
||||
sMonoColors.envColor.r = R_FB_FILTER_ENV_COLOR(0);
|
||||
sMonoColors.envColor.g = R_FB_FILTER_ENV_COLOR(1);
|
||||
sMonoColors.envColor.b = R_FB_FILTER_ENV_COLOR(2);
|
||||
sMonoColors.envColor.a = R_FB_FILTER_A;
|
||||
VisMono_Draw(&sMonoColors, &gfxP);
|
||||
if ((R_FB_FILTER_TYPE >= FB_FILTER_CVG_RGB) && (R_FB_FILTER_TYPE <= FB_FILTER_CVG_RGB_FOG)) {
|
||||
// Visualize coverage
|
||||
sVisCvg.vis.type = FB_FILTER_TO_CVG_TYPE(R_FB_FILTER_TYPE);
|
||||
sVisCvg.vis.primColor.r = R_FB_FILTER_PRIM_COLOR(0);
|
||||
sVisCvg.vis.primColor.g = R_FB_FILTER_PRIM_COLOR(1);
|
||||
sVisCvg.vis.primColor.b = R_FB_FILTER_PRIM_COLOR(2);
|
||||
sVisCvg.vis.primColor.a = R_FB_FILTER_A;
|
||||
VisCvg_Draw(&sVisCvg, &gfx);
|
||||
} else if ((R_FB_FILTER_TYPE == FB_FILTER_ZBUF_IA) || (R_FB_FILTER_TYPE == FB_FILTER_ZBUF_RGBA)) {
|
||||
// Visualize z-buffer
|
||||
sVisZBuf.vis.type = (R_FB_FILTER_TYPE == FB_FILTER_ZBUF_RGBA);
|
||||
sVisZBuf.vis.primColor.r = R_FB_FILTER_PRIM_COLOR(0);
|
||||
sVisZBuf.vis.primColor.g = R_FB_FILTER_PRIM_COLOR(1);
|
||||
sVisZBuf.vis.primColor.b = R_FB_FILTER_PRIM_COLOR(2);
|
||||
sVisZBuf.vis.primColor.a = R_FB_FILTER_A;
|
||||
sVisZBuf.vis.envColor.r = R_FB_FILTER_ENV_COLOR(0);
|
||||
sVisZBuf.vis.envColor.g = R_FB_FILTER_ENV_COLOR(1);
|
||||
sVisZBuf.vis.envColor.b = R_FB_FILTER_ENV_COLOR(2);
|
||||
sVisZBuf.vis.envColor.a = R_FB_FILTER_A;
|
||||
VisZBuf_Draw(&sVisZBuf, &gfx);
|
||||
} else if (R_FB_FILTER_TYPE == FB_FILTER_MONO) {
|
||||
// Monochrome filter
|
||||
sVisMono.vis.type = 0;
|
||||
sVisMono.vis.primColor.r = R_FB_FILTER_PRIM_COLOR(0);
|
||||
sVisMono.vis.primColor.g = R_FB_FILTER_PRIM_COLOR(1);
|
||||
sVisMono.vis.primColor.b = R_FB_FILTER_PRIM_COLOR(2);
|
||||
sVisMono.vis.primColor.a = R_FB_FILTER_A;
|
||||
sVisMono.vis.envColor.r = R_FB_FILTER_ENV_COLOR(0);
|
||||
sVisMono.vis.envColor.g = R_FB_FILTER_ENV_COLOR(1);
|
||||
sVisMono.vis.envColor.b = R_FB_FILTER_ENV_COLOR(2);
|
||||
sVisMono.vis.envColor.a = R_FB_FILTER_A;
|
||||
VisMono_Draw(&sVisMono, &gfx);
|
||||
}
|
||||
*gfx = gfxP;
|
||||
*gfxP = gfx;
|
||||
}
|
||||
|
||||
void func_800C4344(GameState* gameState) {
|
||||
|
@ -110,7 +113,7 @@ void func_800C4344(GameState* gameState) {
|
|||
}
|
||||
}
|
||||
|
||||
void GameState_DrawInputDisplay(u16 input, Gfx** gfx) {
|
||||
void GameState_DrawInputDisplay(u16 input, Gfx** gfxP) {
|
||||
static const u16 sInpDispBtnColors[] = {
|
||||
GPACK_RGBA5551(255, 255, 0, 1), GPACK_RGBA5551(255, 255, 0, 1), GPACK_RGBA5551(255, 255, 0, 1),
|
||||
GPACK_RGBA5551(255, 255, 0, 1), GPACK_RGBA5551(120, 120, 120, 1), GPACK_RGBA5551(120, 120, 120, 1),
|
||||
|
@ -120,10 +123,10 @@ void GameState_DrawInputDisplay(u16 input, Gfx** gfx) {
|
|||
GPACK_RGBA5551(0, 0, 255, 1),
|
||||
};
|
||||
s32 i, j, k;
|
||||
Gfx* gfxP = *gfx;
|
||||
Gfx* gfx = *gfxP;
|
||||
|
||||
gDPPipeSync(gfxP++);
|
||||
gDPSetOtherMode(gfxP++,
|
||||
gDPPipeSync(gfx++);
|
||||
gDPSetOtherMode(gfx++,
|
||||
G_AD_PATTERN | G_CD_MAGICSQ | G_CK_NONE | G_TC_CONV | G_TF_POINT | G_TT_NONE | G_TL_TILE |
|
||||
G_TD_CLAMP | G_TP_NONE | G_CYC_FILL | G_PM_NPRIMITIVE,
|
||||
G_AC_NONE | G_ZS_PIXEL | G_RM_NOOP | G_RM_NOOP2);
|
||||
|
@ -131,14 +134,14 @@ void GameState_DrawInputDisplay(u16 input, Gfx** gfx) {
|
|||
for (i = 0; i < 16; i++) {
|
||||
j = i;
|
||||
if (input & (1 << i)) {
|
||||
gDPSetFillColor(gfxP++, (sInpDispBtnColors[i] << 0x10) | sInpDispBtnColors[i]);
|
||||
gDPSetFillColor(gfx++, (sInpDispBtnColors[i] << 0x10) | sInpDispBtnColors[i]);
|
||||
k = i + 1;
|
||||
gDPFillRectangle(gfxP++, (j * 4) + 226, 220, (k * 4) + 225, 223);
|
||||
gDPPipeSync(gfxP++);
|
||||
gDPFillRectangle(gfx++, (j * 4) + 226, 220, (k * 4) + 225, 223);
|
||||
gDPPipeSync(gfx++);
|
||||
}
|
||||
}
|
||||
|
||||
*gfx = gfxP;
|
||||
*gfxP = gfx;
|
||||
}
|
||||
|
||||
void GameState_Draw(GameState* gameState, GraphicsContext* gfxCtx) {
|
||||
|
@ -413,9 +416,9 @@ void GameState_Init(GameState* gameState, GameStateFunc init, GraphicsContext* g
|
|||
|
||||
startTime = endTime;
|
||||
LogUtils_CheckNullPointer("this->cleanup", gameState->destroy, "../game.c", 1088);
|
||||
func_800ACE70(&D_801664F0);
|
||||
func_800AD920(&D_80166500);
|
||||
VisMono_Init(&sMonoColors);
|
||||
VisCvg_Init(&sVisCvg);
|
||||
VisZBuf_Init(&sVisZBuf);
|
||||
VisMono_Init(&sVisMono);
|
||||
if (R_VI_MODE_EDIT_STATE == VI_MODE_EDIT_STATE_INACTIVE) {
|
||||
ViMode_Init(&sViMode);
|
||||
}
|
||||
|
@ -443,9 +446,9 @@ void GameState_Destroy(GameState* gameState) {
|
|||
}
|
||||
Rumble_Destroy();
|
||||
SpeedMeter_Destroy(&D_801664D0);
|
||||
func_800ACE90(&D_801664F0);
|
||||
func_800AD950(&D_80166500);
|
||||
VisMono_Destroy(&sMonoColors);
|
||||
VisCvg_Destroy(&sVisCvg);
|
||||
VisZBuf_Destroy(&sVisZBuf);
|
||||
VisMono_Destroy(&sVisMono);
|
||||
if (R_VI_MODE_EDIT_STATE == VI_MODE_EDIT_STATE_INACTIVE) {
|
||||
ViMode_Destroy(&sViMode);
|
||||
}
|
||||
|
|
|
@ -513,17 +513,17 @@ Gfx* Graph_BranchDlist(Gfx* gfx, Gfx* dst) {
|
|||
return dst;
|
||||
}
|
||||
|
||||
void* Graph_DlistAlloc(Gfx** gfx, u32 size) {
|
||||
void* Graph_DlistAlloc(Gfx** gfxP, u32 size) {
|
||||
u8* ptr;
|
||||
Gfx* dst;
|
||||
|
||||
size = ALIGN8(size);
|
||||
|
||||
ptr = (u8*)(*gfx + 1);
|
||||
ptr = (u8*)(*gfxP + 1);
|
||||
|
||||
dst = (Gfx*)(ptr + size);
|
||||
gSPBranchList(*gfx, dst);
|
||||
gSPBranchList(*gfxP, dst);
|
||||
|
||||
*gfx = dst;
|
||||
*gfxP = dst;
|
||||
return ptr;
|
||||
}
|
||||
|
|
|
@ -799,7 +799,7 @@ void Actor_SetScale(Actor* actor, f32 scale) {
|
|||
}
|
||||
|
||||
void Actor_SetObjectDependency(PlayState* play, Actor* actor) {
|
||||
gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[actor->objBankIndex].segment);
|
||||
gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[actor->objectSlot].segment);
|
||||
}
|
||||
|
||||
void Actor_Init(Actor* actor, PlayState* play) {
|
||||
|
@ -818,7 +818,7 @@ void Actor_Init(Actor* actor, PlayState* play) {
|
|||
CollisionCheck_InitInfo(&actor->colChkInfo);
|
||||
actor->floorBgId = BGCHECK_SCENE;
|
||||
ActorShape_Init(&actor->shape, 0.0f, NULL, 0.0f);
|
||||
if (Object_IsLoaded(&play->objectCtx, actor->objBankIndex)) {
|
||||
if (Object_IsLoaded(&play->objectCtx, actor->objectSlot)) {
|
||||
Actor_SetObjectDependency(play, actor);
|
||||
actor->init(actor, play);
|
||||
actor->init = NULL;
|
||||
|
@ -2143,13 +2143,13 @@ void Actor_UpdateAll(PlayState* play, ActorContext* actorCtx) {
|
|||
actor->sfx = 0;
|
||||
|
||||
if (actor->init != NULL) {
|
||||
if (Object_IsLoaded(&play->objectCtx, actor->objBankIndex)) {
|
||||
if (Object_IsLoaded(&play->objectCtx, actor->objectSlot)) {
|
||||
Actor_SetObjectDependency(play, actor);
|
||||
actor->init(actor, play);
|
||||
actor->init = NULL;
|
||||
}
|
||||
actor = actor->next;
|
||||
} else if (!Object_IsLoaded(&play->objectCtx, actor->objBankIndex)) {
|
||||
} else if (!Object_IsLoaded(&play->objectCtx, actor->objectSlot)) {
|
||||
Actor_Kill(actor);
|
||||
actor = actor->next;
|
||||
} else if ((requiredActorFlag && !(actor->flags & requiredActorFlag)) ||
|
||||
|
@ -2272,8 +2272,8 @@ void Actor_Draw(PlayState* play, Actor* actor) {
|
|||
Matrix_Scale(actor->scale.x, actor->scale.y, actor->scale.z, MTXMODE_APPLY);
|
||||
Actor_SetObjectDependency(play, actor);
|
||||
|
||||
gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[actor->objBankIndex].segment);
|
||||
gSPSegment(POLY_XLU_DISP++, 0x06, play->objectCtx.status[actor->objBankIndex].segment);
|
||||
gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.slots[actor->objectSlot].segment);
|
||||
gSPSegment(POLY_XLU_DISP++, 0x06, play->objectCtx.slots[actor->objectSlot].segment);
|
||||
|
||||
if (actor->colorFilterTimer != 0) {
|
||||
Color_RGBA8 color = { 0, 0, 0, 255 };
|
||||
|
@ -2570,7 +2570,7 @@ void Actor_KillAllWithMissingObject(PlayState* play, ActorContext* actorCtx) {
|
|||
for (i = 0; i < ARRAY_COUNT(actorCtx->actorLists); i++) {
|
||||
actor = actorCtx->actorLists[i].head;
|
||||
while (actor != NULL) {
|
||||
if (!Object_IsLoaded(&play->objectCtx, actor->objBankIndex)) {
|
||||
if (!Object_IsLoaded(&play->objectCtx, actor->objectSlot)) {
|
||||
Actor_Kill(actor);
|
||||
}
|
||||
actor = actor->next;
|
||||
|
@ -2745,7 +2745,7 @@ Actor* Actor_Spawn(ActorContext* actorCtx, PlayState* play, s16 actorId, f32 pos
|
|||
s32 pad;
|
||||
Actor* actor;
|
||||
ActorInit* actorInit;
|
||||
s32 objBankIndex;
|
||||
s32 objectSlot;
|
||||
ActorOverlay* overlayEntry;
|
||||
uintptr_t temp;
|
||||
char* name;
|
||||
|
@ -2828,13 +2828,13 @@ Actor* Actor_Spawn(ActorContext* actorCtx, PlayState* play, s16 actorId, f32 pos
|
|||
: NULL);
|
||||
}
|
||||
|
||||
objBankIndex = Object_GetIndex(&play->objectCtx, actorInit->objectId);
|
||||
objectSlot = Object_GetSlot(&play->objectCtx, actorInit->objectId);
|
||||
|
||||
if ((objBankIndex < 0) ||
|
||||
if ((objectSlot < 0) ||
|
||||
((actorInit->category == ACTORCAT_ENEMY) && Flags_GetClear(play, play->roomCtx.curRoom.num))) {
|
||||
// "No data bank!! <data bank=%d> (profilep->bank=%d)"
|
||||
osSyncPrintf(VT_COL(RED, WHITE) "データバンク無し!!<データバンク=%d>(profilep->bank=%d)\n" VT_RST,
|
||||
objBankIndex, actorInit->objectId);
|
||||
objectSlot, actorInit->objectId);
|
||||
Actor_FreeOverlay(overlayEntry);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -2864,10 +2864,10 @@ Actor* Actor_Spawn(ActorContext* actorCtx, PlayState* play, s16 actorId, f32 pos
|
|||
actor->flags = actorInit->flags;
|
||||
|
||||
if (actorInit->id == ACTOR_EN_PART) {
|
||||
actor->objBankIndex = rotZ;
|
||||
actor->objectSlot = rotZ;
|
||||
rotZ = 0;
|
||||
} else {
|
||||
actor->objBankIndex = objBankIndex;
|
||||
actor->objectSlot = objectSlot;
|
||||
}
|
||||
|
||||
actor->init = actorInit->init;
|
||||
|
@ -3155,7 +3155,7 @@ s16 func_80032D60(s16* arg0, s16 arg1, s16 arg2, s16 arg3) {
|
|||
void BodyBreak_Alloc(BodyBreak* bodyBreak, s32 count, PlayState* play) {
|
||||
u32 matricesSize;
|
||||
u32 dListsSize;
|
||||
u32 objectIdsSize;
|
||||
u32 objectSlotsSize;
|
||||
|
||||
matricesSize = (count + 1) * sizeof(*bodyBreak->matrices);
|
||||
bodyBreak->matrices = ZeldaArena_MallocDebug(matricesSize, "../z_actor.c", 7540);
|
||||
|
@ -3165,13 +3165,13 @@ void BodyBreak_Alloc(BodyBreak* bodyBreak, s32 count, PlayState* play) {
|
|||
bodyBreak->dLists = ZeldaArena_MallocDebug(dListsSize, "../z_actor.c", 7543);
|
||||
|
||||
if (bodyBreak->dLists != NULL) {
|
||||
objectIdsSize = (count + 1) * sizeof(*bodyBreak->objectIds);
|
||||
bodyBreak->objectIds = ZeldaArena_MallocDebug(objectIdsSize, "../z_actor.c", 7546);
|
||||
objectSlotsSize = (count + 1) * sizeof(*bodyBreak->objectSlots);
|
||||
bodyBreak->objectSlots = ZeldaArena_MallocDebug(objectSlotsSize, "../z_actor.c", 7546);
|
||||
|
||||
if (bodyBreak->objectIds != NULL) {
|
||||
if (bodyBreak->objectSlots != NULL) {
|
||||
Lib_MemSet((u8*)bodyBreak->matrices, matricesSize, 0);
|
||||
Lib_MemSet((u8*)bodyBreak->dLists, dListsSize, 0);
|
||||
Lib_MemSet((u8*)bodyBreak->objectIds, objectIdsSize, 0);
|
||||
Lib_MemSet((u8*)bodyBreak->objectSlots, objectSlotsSize, 0);
|
||||
bodyBreak->val = 1;
|
||||
return;
|
||||
}
|
||||
|
@ -3186,20 +3186,20 @@ void BodyBreak_Alloc(BodyBreak* bodyBreak, s32 count, PlayState* play) {
|
|||
ZeldaArena_FreeDebug(bodyBreak->dLists, "../z_actor.c", 7561);
|
||||
}
|
||||
|
||||
if (bodyBreak->objectIds != NULL) {
|
||||
ZeldaArena_FreeDebug(bodyBreak->objectIds, "../z_actor.c", 7564);
|
||||
if (bodyBreak->objectSlots != NULL) {
|
||||
ZeldaArena_FreeDebug(bodyBreak->objectSlots, "../z_actor.c", 7564);
|
||||
}
|
||||
}
|
||||
|
||||
void BodyBreak_SetInfo(BodyBreak* bodyBreak, s32 limbIndex, s32 minLimbIndex, s32 maxLimbIndex, u32 count, Gfx** dList,
|
||||
s16 objectId) {
|
||||
s16 objectSlot) {
|
||||
PlayState* play = Effect_GetPlayState();
|
||||
|
||||
if ((play->actorCtx.freezeFlashTimer == 0) && (bodyBreak->val > 0)) {
|
||||
if ((limbIndex >= minLimbIndex) && (limbIndex <= maxLimbIndex) && (*dList != NULL)) {
|
||||
bodyBreak->dLists[bodyBreak->val] = *dList;
|
||||
Matrix_Get(&bodyBreak->matrices[bodyBreak->val]);
|
||||
bodyBreak->objectIds[bodyBreak->val] = objectId;
|
||||
bodyBreak->objectSlots[bodyBreak->val] = objectSlot;
|
||||
bodyBreak->val++;
|
||||
}
|
||||
|
||||
|
@ -3219,7 +3219,7 @@ void BodyBreak_SetInfo(BodyBreak* bodyBreak, s32 limbIndex, s32 minLimbIndex, s3
|
|||
s32 BodyBreak_SpawnParts(Actor* actor, BodyBreak* bodyBreak, PlayState* play, s16 type) {
|
||||
EnPart* spawnedEnPart;
|
||||
MtxF* mtx;
|
||||
s16 objBankIndex;
|
||||
s16 objectSlot;
|
||||
|
||||
if (bodyBreak->val != BODYBREAK_STATUS_READY) {
|
||||
return false;
|
||||
|
@ -3231,17 +3231,17 @@ s32 BodyBreak_SpawnParts(Actor* actor, BodyBreak* bodyBreak, PlayState* play, s1
|
|||
Matrix_Get(&bodyBreak->matrices[bodyBreak->count]);
|
||||
|
||||
if (1) {
|
||||
if (bodyBreak->objectIds[bodyBreak->count] >= 0) {
|
||||
objBankIndex = bodyBreak->objectIds[bodyBreak->count];
|
||||
if (bodyBreak->objectSlots[bodyBreak->count] > BODYBREAK_OBJECT_SLOT_DEFAULT) {
|
||||
objectSlot = bodyBreak->objectSlots[bodyBreak->count];
|
||||
} else {
|
||||
objBankIndex = actor->objBankIndex;
|
||||
objectSlot = actor->objectSlot;
|
||||
}
|
||||
}
|
||||
|
||||
mtx = &bodyBreak->matrices[bodyBreak->count];
|
||||
|
||||
spawnedEnPart = (EnPart*)Actor_SpawnAsChild(&play->actorCtx, actor, play, ACTOR_EN_PART, mtx->xw, mtx->yw,
|
||||
mtx->zw, 0, 0, objBankIndex, type);
|
||||
mtx->zw, 0, 0, objectSlot, type);
|
||||
|
||||
if (spawnedEnPart != NULL) {
|
||||
Matrix_MtxFToYXZRotS(&bodyBreak->matrices[bodyBreak->count], &spawnedEnPart->actor.shape.rot, 0);
|
||||
|
@ -3256,7 +3256,7 @@ s32 BodyBreak_SpawnParts(Actor* actor, BodyBreak* bodyBreak, PlayState* play, s1
|
|||
|
||||
ZeldaArena_FreeDebug(bodyBreak->matrices, "../z_actor.c", 7678);
|
||||
ZeldaArena_FreeDebug(bodyBreak->dLists, "../z_actor.c", 7679);
|
||||
ZeldaArena_FreeDebug(bodyBreak->objectIds, "../z_actor.c", 7680);
|
||||
ZeldaArena_FreeDebug(bodyBreak->objectSlots, "../z_actor.c", 7680);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -4329,7 +4329,7 @@ Actor* func_800358DC(Actor* actor, Vec3f* spawnPos, Vec3s* spawnRot, f32* arg3,
|
|||
EnPart* spawnedEnPart;
|
||||
|
||||
spawnedEnPart = (EnPart*)Actor_SpawnAsChild(&play->actorCtx, actor, play, ACTOR_EN_PART, spawnPos->x, spawnPos->y,
|
||||
spawnPos->z, spawnRot->x, spawnRot->y, actor->objBankIndex, params);
|
||||
spawnPos->z, spawnRot->x, spawnRot->y, actor->objectSlot, params);
|
||||
if (spawnedEnPart != NULL) {
|
||||
spawnedEnPart->actor.scale = actor->scale;
|
||||
spawnedEnPart->actor.speed = arg3[0];
|
||||
|
|
|
@ -6876,7 +6876,7 @@ s32 Camera_Special9(Camera* camera) {
|
|||
f32 playerYOffset;
|
||||
s32 pad3;
|
||||
PosRot* playerPosRot = &camera->playerPosRot;
|
||||
PosRot adjustedPlayerPosRot;
|
||||
PosRot referencePosRot;
|
||||
f32 yNormal;
|
||||
DoorParams* doorParams = &camera->paramData.doorParams;
|
||||
Special9ReadOnlyData* roData = &camera->paramData.spec9.roData;
|
||||
|
@ -6902,11 +6902,11 @@ s32 Camera_Special9(Camera* camera) {
|
|||
}
|
||||
|
||||
if (doorParams->doorActor != NULL) {
|
||||
Actor_GetWorldPosShapeRot(&adjustedPlayerPosRot, doorParams->doorActor);
|
||||
Actor_GetWorldPosShapeRot(&referencePosRot, doorParams->doorActor);
|
||||
} else {
|
||||
adjustedPlayerPosRot = *playerPosRot;
|
||||
adjustedPlayerPosRot.pos.y += playerYOffset + roData->yOffset;
|
||||
adjustedPlayerPosRot.rot.x = 0;
|
||||
referencePosRot = *playerPosRot;
|
||||
referencePosRot.pos.y += playerYOffset + roData->yOffset;
|
||||
referencePosRot.rot.x = 0;
|
||||
}
|
||||
|
||||
OLib_Vec3fDiffToVecGeo(&atEyeOffsetGeo, at, eye);
|
||||
|
@ -6919,9 +6919,15 @@ s32 Camera_Special9(Camera* camera) {
|
|||
case 0:
|
||||
camera->stateFlags &= ~(CAM_STATE_1 | CAM_STATE_2);
|
||||
camera->animState++;
|
||||
rwData->targetYaw = ABS(playerPosRot->rot.y - adjustedPlayerPosRot.rot.y) >= 0x4000
|
||||
? adjustedPlayerPosRot.rot.y - 0x7FFF
|
||||
: adjustedPlayerPosRot.rot.y;
|
||||
|
||||
//! @bug The angle passed to ABS should be cast to s16.
|
||||
//! The lack of a cast means that a door which has an angle of around 0x8000 will calculate an incorrect
|
||||
//! angle and use an incorrect `targetYaw`.
|
||||
//! In-game, this means if the player opens a susceptible door at a slanted angle, the camera will not
|
||||
//! appear correctly on the other side after the player has walked through the door.
|
||||
rwData->targetYaw = ABS(playerPosRot->rot.y - referencePosRot.rot.y) >= 0x4000
|
||||
? referencePosRot.rot.y - 0x7FFF
|
||||
: referencePosRot.rot.y;
|
||||
FALLTHROUGH;
|
||||
case 1:
|
||||
doorParams->timer1--;
|
||||
|
|
|
@ -49,7 +49,7 @@ void EffectSs_DrawGEffect(PlayState* play, EffectSs* this, void* texture) {
|
|||
MtxF mfTransBillboard;
|
||||
s32 pad1;
|
||||
Mtx* mtx;
|
||||
void* object = play->objectCtx.status[this->rgObjBankIdx].segment;
|
||||
void* objectPtr = play->objectCtx.slots[this->rgObjectSlot].segment;
|
||||
|
||||
OPEN_DISPS(gfxCtx, "../z_effect_soft_sprite_old_init.c", 196);
|
||||
|
||||
|
@ -58,8 +58,8 @@ void EffectSs_DrawGEffect(PlayState* play, EffectSs* this, void* texture) {
|
|||
SkinMatrix_SetScale(&mfScale, scale, scale, scale);
|
||||
SkinMatrix_MtxFMtxFMult(&mfTrans, &play->billboardMtxF, &mfTransBillboard);
|
||||
SkinMatrix_MtxFMtxFMult(&mfTransBillboard, &mfScale, &mfResult);
|
||||
gSegments[6] = VIRTUAL_TO_PHYSICAL(object);
|
||||
gSPSegment(POLY_XLU_DISP++, 0x06, object);
|
||||
gSegments[6] = VIRTUAL_TO_PHYSICAL(objectPtr);
|
||||
gSPSegment(POLY_XLU_DISP++, 0x06, objectPtr);
|
||||
|
||||
mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &mfResult);
|
||||
|
||||
|
|
|
@ -236,7 +236,7 @@ void EnItem00_Init(Actor* thisx, PlayState* play) {
|
|||
this->scale = 0.01f;
|
||||
break;
|
||||
case ITEM00_SHIELD_DEKU:
|
||||
this->actor.objBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_GI_SHIELD_1);
|
||||
this->actor.objectSlot = Object_GetSlot(&play->objectCtx, OBJECT_GI_SHIELD_1);
|
||||
Actor_SetObjectDependency(play, &this->actor);
|
||||
Actor_SetScale(&this->actor, 0.5f);
|
||||
this->scale = 0.5f;
|
||||
|
@ -245,7 +245,7 @@ void EnItem00_Init(Actor* thisx, PlayState* play) {
|
|||
this->actor.world.rot.x = 0x4000;
|
||||
break;
|
||||
case ITEM00_SHIELD_HYLIAN:
|
||||
this->actor.objBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_GI_SHIELD_2);
|
||||
this->actor.objectSlot = Object_GetSlot(&play->objectCtx, OBJECT_GI_SHIELD_2);
|
||||
Actor_SetObjectDependency(play, &this->actor);
|
||||
Actor_SetScale(&this->actor, 0.5f);
|
||||
this->scale = 0.5f;
|
||||
|
@ -255,7 +255,7 @@ void EnItem00_Init(Actor* thisx, PlayState* play) {
|
|||
break;
|
||||
case ITEM00_TUNIC_ZORA:
|
||||
case ITEM00_TUNIC_GORON:
|
||||
this->actor.objBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_GI_CLOTHES);
|
||||
this->actor.objectSlot = Object_GetSlot(&play->objectCtx, OBJECT_GI_CLOTHES);
|
||||
Actor_SetObjectDependency(play, &this->actor);
|
||||
Actor_SetScale(&this->actor, 0.5f);
|
||||
this->scale = 0.5f;
|
||||
|
@ -765,10 +765,10 @@ void EnItem00_Draw(Actor* thisx, PlayState* play) {
|
|||
case ITEM00_RECOVERY_HEART:
|
||||
if (this->despawnTimer < 0) {
|
||||
if (this->despawnTimer == -1) {
|
||||
s8 bankIndex = Object_GetIndex(&play->objectCtx, OBJECT_GI_HEART);
|
||||
s8 objectSlot = Object_GetSlot(&play->objectCtx, OBJECT_GI_HEART);
|
||||
|
||||
if (Object_IsLoaded(&play->objectCtx, bankIndex)) {
|
||||
this->actor.objBankIndex = bankIndex;
|
||||
if (Object_IsLoaded(&play->objectCtx, objectSlot)) {
|
||||
this->actor.objectSlot = objectSlot;
|
||||
Actor_SetObjectDependency(play, &this->actor);
|
||||
this->despawnTimer = -2;
|
||||
}
|
||||
|
|
|
@ -432,7 +432,7 @@ void Environment_Init(PlayState* play2, EnvironmentContext* envCtx, s32 unused)
|
|||
play->csCtx.actorCues[i] = NULL;
|
||||
}
|
||||
|
||||
if (Object_GetIndex(&play->objectCtx, OBJECT_GAMEPLAY_FIELD_KEEP) < 0 && !play->envCtx.sunMoonDisabled) {
|
||||
if (Object_GetSlot(&play->objectCtx, OBJECT_GAMEPLAY_FIELD_KEEP) < 0 && !play->envCtx.sunMoonDisabled) {
|
||||
play->envCtx.sunMoonDisabled = true;
|
||||
// "Sun setting other than field keep! So forced release!"
|
||||
osSyncPrintf(VT_COL(YELLOW, BLACK) "\n\nフィールド常駐以外、太陽設定!よって強制解除!\n" VT_RST);
|
||||
|
|
|
@ -219,14 +219,14 @@ s32 Math_AsymStepToF(f32* pValue, f32 target, f32 incrStep, f32 decrStep) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void func_80077D10(f32* arg0, s16* arg1, Input* input) {
|
||||
void Lib_GetControlStickData(f32* outMagnitude, s16* outAngle, Input* input) {
|
||||
f32 relX = input->rel.stick_x;
|
||||
f32 relY = input->rel.stick_y;
|
||||
|
||||
*arg0 = sqrtf(SQ(relX) + SQ(relY));
|
||||
*arg0 = (60.0f < *arg0) ? 60.0f : *arg0;
|
||||
*outMagnitude = sqrtf(SQ(relX) + SQ(relY));
|
||||
*outMagnitude = (60.0f < *outMagnitude) ? 60.0f : *outMagnitude;
|
||||
|
||||
*arg1 = Math_Atan2S(relY, -relX);
|
||||
*outAngle = Math_Atan2S(relY, -relX);
|
||||
}
|
||||
|
||||
s16 Rand_S16Offset(s16 base, s16 range) {
|
||||
|
|
|
@ -8,7 +8,7 @@ Input* D_8012D1F8 = NULL;
|
|||
|
||||
TransitionTile sTransitionTile;
|
||||
s32 gTransitionTileState;
|
||||
VisMono D_80161498;
|
||||
VisMono sPlayVisMono;
|
||||
Color_RGBA8_u32 gVisMonoColor;
|
||||
FaultClient D_801614B8;
|
||||
s16 sTransitionFillTimer;
|
||||
|
@ -199,7 +199,7 @@ void Play_Destroy(GameState* thisx) {
|
|||
|
||||
Letterbox_Destroy();
|
||||
TransitionFade_Destroy(&this->transitionFadeFlash);
|
||||
VisMono_Destroy(&D_80161498);
|
||||
VisMono_Destroy(&sPlayVisMono);
|
||||
|
||||
if (gSaveContext.save.linkAge != this->linkAgeOnLoad) {
|
||||
Inventory_SwapAgeEquipment();
|
||||
|
@ -390,7 +390,7 @@ void Play_Init(GameState* thisx) {
|
|||
TransitionFade_SetType(&this->transitionFadeFlash, TRANS_INSTANCE_TYPE_FADE_FLASH);
|
||||
TransitionFade_SetColor(&this->transitionFadeFlash, RGBA8(160, 160, 160, 255));
|
||||
TransitionFade_Start(&this->transitionFadeFlash);
|
||||
VisMono_Init(&D_80161498);
|
||||
VisMono_Init(&sPlayVisMono);
|
||||
gVisMonoColor.a = 0;
|
||||
CutsceneFlags_UnsetAll(this);
|
||||
|
||||
|
@ -482,8 +482,8 @@ void Play_Update(PlayState* this) {
|
|||
ActorOverlayTable_LogPrint();
|
||||
}
|
||||
|
||||
gSegments[4] = VIRTUAL_TO_PHYSICAL(this->objectCtx.status[this->objectCtx.mainKeepIndex].segment);
|
||||
gSegments[5] = VIRTUAL_TO_PHYSICAL(this->objectCtx.status[this->objectCtx.subKeepIndex].segment);
|
||||
gSegments[4] = VIRTUAL_TO_PHYSICAL(this->objectCtx.slots[this->objectCtx.mainKeepSlot].segment);
|
||||
gSegments[5] = VIRTUAL_TO_PHYSICAL(this->objectCtx.slots[this->objectCtx.subKeepSlot].segment);
|
||||
gSegments[2] = VIRTUAL_TO_PHYSICAL(this->sceneSegment);
|
||||
|
||||
if (FrameAdvance_Update(&this->frameAdvCtx, &input[1])) {
|
||||
|
@ -855,7 +855,7 @@ void Play_Update(PlayState* this) {
|
|||
AnimationContext_Reset(&this->animationCtx);
|
||||
|
||||
PLAY_LOG(3561);
|
||||
Object_UpdateBank(&this->objectCtx);
|
||||
Object_UpdateEntries(&this->objectCtx);
|
||||
|
||||
PLAY_LOG(3577);
|
||||
|
||||
|
@ -1035,21 +1035,21 @@ void Play_Draw(PlayState* this) {
|
|||
|
||||
OPEN_DISPS(gfxCtx, "../z_play.c", 3907);
|
||||
|
||||
gSegments[4] = VIRTUAL_TO_PHYSICAL(this->objectCtx.status[this->objectCtx.mainKeepIndex].segment);
|
||||
gSegments[5] = VIRTUAL_TO_PHYSICAL(this->objectCtx.status[this->objectCtx.subKeepIndex].segment);
|
||||
gSegments[4] = VIRTUAL_TO_PHYSICAL(this->objectCtx.slots[this->objectCtx.mainKeepSlot].segment);
|
||||
gSegments[5] = VIRTUAL_TO_PHYSICAL(this->objectCtx.slots[this->objectCtx.subKeepSlot].segment);
|
||||
gSegments[2] = VIRTUAL_TO_PHYSICAL(this->sceneSegment);
|
||||
|
||||
gSPSegment(POLY_OPA_DISP++, 0x00, NULL);
|
||||
gSPSegment(POLY_XLU_DISP++, 0x00, NULL);
|
||||
gSPSegment(OVERLAY_DISP++, 0x00, NULL);
|
||||
|
||||
gSPSegment(POLY_OPA_DISP++, 0x04, this->objectCtx.status[this->objectCtx.mainKeepIndex].segment);
|
||||
gSPSegment(POLY_XLU_DISP++, 0x04, this->objectCtx.status[this->objectCtx.mainKeepIndex].segment);
|
||||
gSPSegment(OVERLAY_DISP++, 0x04, this->objectCtx.status[this->objectCtx.mainKeepIndex].segment);
|
||||
gSPSegment(POLY_OPA_DISP++, 0x04, this->objectCtx.slots[this->objectCtx.mainKeepSlot].segment);
|
||||
gSPSegment(POLY_XLU_DISP++, 0x04, this->objectCtx.slots[this->objectCtx.mainKeepSlot].segment);
|
||||
gSPSegment(OVERLAY_DISP++, 0x04, this->objectCtx.slots[this->objectCtx.mainKeepSlot].segment);
|
||||
|
||||
gSPSegment(POLY_OPA_DISP++, 0x05, this->objectCtx.status[this->objectCtx.subKeepIndex].segment);
|
||||
gSPSegment(POLY_XLU_DISP++, 0x05, this->objectCtx.status[this->objectCtx.subKeepIndex].segment);
|
||||
gSPSegment(OVERLAY_DISP++, 0x05, this->objectCtx.status[this->objectCtx.subKeepIndex].segment);
|
||||
gSPSegment(POLY_OPA_DISP++, 0x05, this->objectCtx.slots[this->objectCtx.subKeepSlot].segment);
|
||||
gSPSegment(POLY_XLU_DISP++, 0x05, this->objectCtx.slots[this->objectCtx.subKeepSlot].segment);
|
||||
gSPSegment(OVERLAY_DISP++, 0x05, this->objectCtx.slots[this->objectCtx.subKeepSlot].segment);
|
||||
|
||||
gSPSegment(POLY_OPA_DISP++, 0x02, this->sceneSegment);
|
||||
gSPSegment(POLY_XLU_DISP++, 0x02, this->sceneSegment);
|
||||
|
@ -1103,8 +1103,8 @@ void Play_Draw(PlayState* this) {
|
|||
TransitionFade_Draw(&this->transitionFadeFlash, &gfxP);
|
||||
|
||||
if (gVisMonoColor.a > 0) {
|
||||
D_80161498.primColor.rgba = gVisMonoColor.rgba;
|
||||
VisMono_Draw(&D_80161498, &gfxP);
|
||||
sPlayVisMono.vis.primColor.rgba = gVisMonoColor.rgba;
|
||||
VisMono_Draw(&sPlayVisMono, &gfxP);
|
||||
}
|
||||
|
||||
gSPEndDisplayList(gfxP++);
|
||||
|
@ -1434,7 +1434,7 @@ void Play_InitScene(PlayState* this, s32 spawn) {
|
|||
|
||||
this->numActorEntries = 0;
|
||||
|
||||
Object_InitBank(this, &this->objectCtx);
|
||||
Object_InitContext(this, &this->objectCtx);
|
||||
LightContext_Init(this, &this->lightCtx);
|
||||
TransitionActor_InitContext(&this->state, &this->transiActorCtx);
|
||||
func_80096FD4(this, &this->roomCtx.curRoom);
|
||||
|
|
|
@ -1370,7 +1370,7 @@ void Player_DrawHookshotReticle(PlayState* play, Player* this, f32 arg2) {
|
|||
|
||||
gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_player_lib.c", 2587),
|
||||
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
gSPSegment(OVERLAY_DISP++, 0x06, play->objectCtx.status[this->actor.objBankIndex].segment);
|
||||
gSPSegment(OVERLAY_DISP++, 0x06, play->objectCtx.slots[this->actor.objectSlot].segment);
|
||||
gSPDisplayList(OVERLAY_DISP++, gLinkAdultHookshotReticleDL);
|
||||
|
||||
CLOSE_DISPS(play->state.gfxCtx, "../z_player_lib.c", 2592);
|
||||
|
|
|
@ -907,8 +907,8 @@ Gfx* Gfx_SetupDL(Gfx* gfx, u32 i) {
|
|||
return Gfx_SetupDLImpl(gfx, i);
|
||||
}
|
||||
|
||||
void Gfx_SetupDLAtPtr(Gfx** gfxp, u32 i) {
|
||||
*gfxp = Gfx_SetupDL(*gfxp, i);
|
||||
void Gfx_SetupDLAtPtr(Gfx** gfxP, u32 i) {
|
||||
*gfxP = Gfx_SetupDL(*gfxP, i);
|
||||
}
|
||||
|
||||
Gfx* Gfx_SetupDL_57(Gfx* gfx) {
|
||||
|
@ -1193,11 +1193,11 @@ void Gfx_SetupDL_39Overlay(GraphicsContext* gfxCtx) {
|
|||
CLOSE_DISPS(gfxCtx, "../z_rcp.c", 1811);
|
||||
}
|
||||
|
||||
void Gfx_SetupDL_39Ptr(Gfx** gfxp) {
|
||||
Gfx* gfx = *gfxp;
|
||||
void Gfx_SetupDL_39Ptr(Gfx** gfxP) {
|
||||
Gfx* gfx = *gfxP;
|
||||
|
||||
gSPDisplayList(gfx++, sSetupDL[SETUPDL_39]);
|
||||
*gfxp = gfx;
|
||||
*gfxP = gfx;
|
||||
}
|
||||
|
||||
void Gfx_SetupDL_40Opa(GraphicsContext* gfxCtx) {
|
||||
|
@ -1345,12 +1345,12 @@ void Gfx_SetupDL_56Opa(GraphicsContext* gfxCtx) {
|
|||
CLOSE_DISPS(gfxCtx, "../z_rcp.c", 2090);
|
||||
}
|
||||
|
||||
void Gfx_SetupDL_56Ptr(Gfx** gfxp) {
|
||||
Gfx* gfx = *gfxp;
|
||||
void Gfx_SetupDL_56Ptr(Gfx** gfxP) {
|
||||
Gfx* gfx = *gfxP;
|
||||
|
||||
gSPDisplayList(gfx++, sSetupDL[SETUPDL_56]);
|
||||
|
||||
*gfxp = gfx;
|
||||
*gfxP = gfx;
|
||||
}
|
||||
|
||||
void Gfx_SetupDL_59Opa(GraphicsContext* gfxCtx) {
|
||||
|
@ -1361,8 +1361,8 @@ void Gfx_SetupDL_59Opa(GraphicsContext* gfxCtx) {
|
|||
CLOSE_DISPS(gfxCtx, "../z_rcp.c", 2116);
|
||||
}
|
||||
|
||||
Gfx* Gfx_BranchTexScroll(Gfx** gfxp, u32 x, u32 y, s32 width, s32 height) {
|
||||
Gfx* displayList = Graph_DlistAlloc(gfxp, 3 * sizeof(Gfx));
|
||||
Gfx* Gfx_BranchTexScroll(Gfx** gfxP, u32 x, u32 y, s32 width, s32 height) {
|
||||
Gfx* displayList = Graph_DlistAlloc(gfxP, 3 * sizeof(Gfx));
|
||||
|
||||
gDPTileSync(displayList);
|
||||
gDPSetTileSize(displayList + 1, G_TX_RENDERTILE, x, y, x + ((width - 1) << 2), y + ((height - 1) << 2));
|
||||
|
@ -1371,8 +1371,8 @@ Gfx* Gfx_BranchTexScroll(Gfx** gfxp, u32 x, u32 y, s32 width, s32 height) {
|
|||
return displayList;
|
||||
}
|
||||
|
||||
Gfx* func_80094E54(Gfx** gfxp, u32 x, u32 y) {
|
||||
return Gfx_BranchTexScroll(gfxp, x, y, 0, 0);
|
||||
Gfx* func_80094E54(Gfx** gfxP, u32 x, u32 y) {
|
||||
return Gfx_BranchTexScroll(gfxP, x, y, 0, 0);
|
||||
}
|
||||
|
||||
Gfx* func_80094E78(GraphicsContext* gfxCtx, u32 x, u32 y) {
|
||||
|
|
|
@ -3,64 +3,77 @@
|
|||
|
||||
RomFile sNaviQuestHintFiles[];
|
||||
|
||||
s32 Object_Spawn(ObjectContext* objectCtx, s16 objectId) {
|
||||
/**
|
||||
* Spawn an object file of a specified ID that will persist through room changes.
|
||||
*
|
||||
* This waits for the file to be fully loaded, the data is available when the function returns.
|
||||
*
|
||||
* @return The new object slot corresponding to the requested object ID.
|
||||
*
|
||||
* @note This function is not meant to be called externally to spawn object files on the fly.
|
||||
* When an object is spawned with this function, all objects that come before it in the entry list will be treated as
|
||||
* persistent, which will likely cause either the amount of free slots or object space memory to run out.
|
||||
* This function is only meant to be called internally on scene load, before the object list from any room is processed.
|
||||
*/
|
||||
s32 Object_SpawnPersistent(ObjectContext* objectCtx, s16 objectId) {
|
||||
u32 size;
|
||||
|
||||
objectCtx->status[objectCtx->num].id = objectId;
|
||||
objectCtx->slots[objectCtx->numEntries].id = objectId;
|
||||
size = gObjectTable[objectId].vromEnd - gObjectTable[objectId].vromStart;
|
||||
|
||||
osSyncPrintf("OBJECT[%d] SIZE %fK SEG=%x\n", objectId, size / 1024.0f, objectCtx->status[objectCtx->num].segment);
|
||||
osSyncPrintf("OBJECT[%d] SIZE %fK SEG=%x\n", objectId, size / 1024.0f,
|
||||
objectCtx->slots[objectCtx->numEntries].segment);
|
||||
|
||||
osSyncPrintf("num=%d adrs=%x end=%x\n", objectCtx->num, (uintptr_t)objectCtx->status[objectCtx->num].segment + size,
|
||||
objectCtx->spaceEnd);
|
||||
osSyncPrintf("num=%d adrs=%x end=%x\n", objectCtx->numEntries,
|
||||
(uintptr_t)objectCtx->slots[objectCtx->numEntries].segment + size, objectCtx->spaceEnd);
|
||||
|
||||
ASSERT(((objectCtx->num < OBJECT_EXCHANGE_BANK_MAX) &&
|
||||
(((uintptr_t)objectCtx->status[objectCtx->num].segment + size) < (uintptr_t)objectCtx->spaceEnd)),
|
||||
ASSERT(((objectCtx->numEntries < ARRAY_COUNT(objectCtx->slots)) &&
|
||||
(((uintptr_t)objectCtx->slots[objectCtx->numEntries].segment + size) < (uintptr_t)objectCtx->spaceEnd)),
|
||||
"this->num < OBJECT_EXCHANGE_BANK_MAX && (this->status[this->num].Segment + size) < this->endSegment",
|
||||
"../z_scene.c", 142);
|
||||
|
||||
DmaMgr_RequestSyncDebug(objectCtx->status[objectCtx->num].segment, gObjectTable[objectId].vromStart, size,
|
||||
DmaMgr_RequestSyncDebug(objectCtx->slots[objectCtx->numEntries].segment, gObjectTable[objectId].vromStart, size,
|
||||
"../z_scene.c", 145);
|
||||
|
||||
if (objectCtx->num < OBJECT_EXCHANGE_BANK_MAX - 1) {
|
||||
objectCtx->status[objectCtx->num + 1].segment =
|
||||
(void*)ALIGN16((uintptr_t)objectCtx->status[objectCtx->num].segment + size);
|
||||
if (objectCtx->numEntries < (ARRAY_COUNT(objectCtx->slots) - 1)) {
|
||||
objectCtx->slots[objectCtx->numEntries + 1].segment =
|
||||
(void*)ALIGN16((uintptr_t)objectCtx->slots[objectCtx->numEntries].segment + size);
|
||||
}
|
||||
|
||||
objectCtx->num++;
|
||||
objectCtx->unk_09 = objectCtx->num;
|
||||
objectCtx->numEntries++;
|
||||
objectCtx->numPersistentEntries = objectCtx->numEntries;
|
||||
|
||||
return objectCtx->num - 1;
|
||||
return objectCtx->numEntries - 1;
|
||||
}
|
||||
|
||||
void Object_InitBank(PlayState* play, ObjectContext* objectCtx) {
|
||||
PlayState* play2 = play; // Needs to be a new variable to match (possibly a sub struct?)
|
||||
void Object_InitContext(PlayState* play, ObjectContext* objectCtx) {
|
||||
PlayState* play2 = play;
|
||||
u32 spaceSize;
|
||||
s32 i;
|
||||
|
||||
if (play2->sceneId == SCENE_HYRULE_FIELD) {
|
||||
spaceSize = 1024000;
|
||||
spaceSize = 1000 * 1024;
|
||||
} else if (play2->sceneId == SCENE_GANON_BOSS) {
|
||||
if (gSaveContext.sceneLayer != 4) {
|
||||
spaceSize = 1177600;
|
||||
spaceSize = 1150 * 1024;
|
||||
} else {
|
||||
spaceSize = 1024000;
|
||||
spaceSize = 1000 * 1024;
|
||||
}
|
||||
} else if (play2->sceneId == SCENE_SPIRIT_TEMPLE_BOSS) {
|
||||
spaceSize = 1075200;
|
||||
spaceSize = 1050 * 1024;
|
||||
} else if (play2->sceneId == SCENE_CHAMBER_OF_THE_SAGES) {
|
||||
spaceSize = 1075200;
|
||||
spaceSize = 1050 * 1024;
|
||||
} else if (play2->sceneId == SCENE_GANONDORF_BOSS) {
|
||||
spaceSize = 1075200;
|
||||
spaceSize = 1050 * 1024;
|
||||
} else {
|
||||
spaceSize = 1024000;
|
||||
spaceSize = 1000 * 1024;
|
||||
}
|
||||
|
||||
objectCtx->num = objectCtx->unk_09 = 0;
|
||||
objectCtx->mainKeepIndex = objectCtx->subKeepIndex = 0;
|
||||
objectCtx->numEntries = objectCtx->numPersistentEntries = 0;
|
||||
objectCtx->mainKeepSlot = objectCtx->subKeepSlot = 0;
|
||||
|
||||
for (i = 0; i < OBJECT_EXCHANGE_BANK_MAX; i++) {
|
||||
objectCtx->status[i].id = OBJECT_INVALID;
|
||||
for (i = 0; i < ARRAY_COUNT(objectCtx->slots); i++) {
|
||||
objectCtx->slots[i].id = OBJECT_INVALID;
|
||||
}
|
||||
|
||||
osSyncPrintf(VT_FGCOL(GREEN));
|
||||
|
@ -68,42 +81,43 @@ void Object_InitBank(PlayState* play, ObjectContext* objectCtx) {
|
|||
osSyncPrintf("オブジェクト入れ替えバンク情報 %8.3fKB\n", spaceSize / 1024.0f);
|
||||
osSyncPrintf(VT_RST);
|
||||
|
||||
objectCtx->spaceStart = objectCtx->status[0].segment =
|
||||
GameState_Alloc(&play->state, spaceSize, "../z_scene.c", 219);
|
||||
objectCtx->spaceStart = objectCtx->slots[0].segment = GameState_Alloc(&play->state, spaceSize, "../z_scene.c", 219);
|
||||
objectCtx->spaceEnd = (void*)((uintptr_t)objectCtx->spaceStart + spaceSize);
|
||||
|
||||
objectCtx->mainKeepIndex = Object_Spawn(objectCtx, OBJECT_GAMEPLAY_KEEP);
|
||||
gSegments[4] = VIRTUAL_TO_PHYSICAL(objectCtx->status[objectCtx->mainKeepIndex].segment);
|
||||
objectCtx->mainKeepSlot = Object_SpawnPersistent(objectCtx, OBJECT_GAMEPLAY_KEEP);
|
||||
gSegments[4] = VIRTUAL_TO_PHYSICAL(objectCtx->slots[objectCtx->mainKeepSlot].segment);
|
||||
}
|
||||
|
||||
void Object_UpdateBank(ObjectContext* objectCtx) {
|
||||
void Object_UpdateEntries(ObjectContext* objectCtx) {
|
||||
s32 i;
|
||||
ObjectStatus* status = &objectCtx->status[0];
|
||||
ObjectEntry* entry = &objectCtx->slots[0];
|
||||
RomFile* objectFile;
|
||||
u32 size;
|
||||
|
||||
for (i = 0; i < objectCtx->num; i++) {
|
||||
if (status->id < 0) {
|
||||
if (status->dmaRequest.vromAddr == 0) {
|
||||
osCreateMesgQueue(&status->loadQueue, &status->loadMsg, 1);
|
||||
objectFile = &gObjectTable[-status->id];
|
||||
for (i = 0; i < objectCtx->numEntries; i++) {
|
||||
if (entry->id < 0) {
|
||||
if (entry->dmaRequest.vromAddr == 0) {
|
||||
osCreateMesgQueue(&entry->loadQueue, &entry->loadMsg, 1);
|
||||
objectFile = &gObjectTable[-entry->id];
|
||||
size = objectFile->vromEnd - objectFile->vromStart;
|
||||
osSyncPrintf("OBJECT EXCHANGE BANK-%2d SIZE %8.3fK SEG=%08x\n", i, size / 1024.0f, status->segment);
|
||||
DmaMgr_RequestAsync(&status->dmaRequest, status->segment, objectFile->vromStart, size, 0,
|
||||
&status->loadQueue, NULL, "../z_scene.c", 266);
|
||||
} else if (osRecvMesg(&status->loadQueue, NULL, OS_MESG_NOBLOCK) == 0) {
|
||||
status->id = -status->id;
|
||||
|
||||
osSyncPrintf("OBJECT EXCHANGE BANK-%2d SIZE %8.3fK SEG=%08x\n", i, size / 1024.0f, entry->segment);
|
||||
|
||||
DmaMgr_RequestAsync(&entry->dmaRequest, entry->segment, objectFile->vromStart, size, 0,
|
||||
&entry->loadQueue, NULL, "../z_scene.c", 266);
|
||||
} else if (osRecvMesg(&entry->loadQueue, NULL, OS_MESG_NOBLOCK) == 0) {
|
||||
entry->id = -entry->id;
|
||||
}
|
||||
}
|
||||
status++;
|
||||
entry++;
|
||||
}
|
||||
}
|
||||
|
||||
s32 Object_GetIndex(ObjectContext* objectCtx, s16 objectId) {
|
||||
s32 Object_GetSlot(ObjectContext* objectCtx, s16 objectId) {
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < objectCtx->num; i++) {
|
||||
if (ABS(objectCtx->status[i].id) == objectId) {
|
||||
for (i = 0; i < objectCtx->numEntries; i++) {
|
||||
if (ABS(objectCtx->slots[i].id) == objectId) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
@ -111,8 +125,8 @@ s32 Object_GetIndex(ObjectContext* objectCtx, s16 objectId) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
s32 Object_IsLoaded(ObjectContext* objectCtx, s32 bankIndex) {
|
||||
if (objectCtx->status[bankIndex].id > 0) {
|
||||
s32 Object_IsLoaded(ObjectContext* objectCtx, s32 slot) {
|
||||
if (objectCtx->slots[slot].id > 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
@ -124,30 +138,30 @@ void func_800981B8(ObjectContext* objectCtx) {
|
|||
s32 id;
|
||||
u32 size;
|
||||
|
||||
for (i = 0; i < objectCtx->num; i++) {
|
||||
id = objectCtx->status[i].id;
|
||||
for (i = 0; i < objectCtx->numEntries; i++) {
|
||||
id = objectCtx->slots[i].id;
|
||||
size = gObjectTable[id].vromEnd - gObjectTable[id].vromStart;
|
||||
osSyncPrintf("OBJECT[%d] SIZE %fK SEG=%x\n", objectCtx->status[i].id, size / 1024.0f,
|
||||
objectCtx->status[i].segment);
|
||||
osSyncPrintf("num=%d adrs=%x end=%x\n", objectCtx->num, (uintptr_t)objectCtx->status[i].segment + size,
|
||||
osSyncPrintf("OBJECT[%d] SIZE %fK SEG=%x\n", objectCtx->slots[i].id, size / 1024.0f,
|
||||
objectCtx->slots[i].segment);
|
||||
osSyncPrintf("num=%d adrs=%x end=%x\n", objectCtx->numEntries, (uintptr_t)objectCtx->slots[i].segment + size,
|
||||
objectCtx->spaceEnd);
|
||||
DmaMgr_RequestSyncDebug(objectCtx->status[i].segment, gObjectTable[id].vromStart, size, "../z_scene.c", 342);
|
||||
DmaMgr_RequestSyncDebug(objectCtx->slots[i].segment, gObjectTable[id].vromStart, size, "../z_scene.c", 342);
|
||||
}
|
||||
}
|
||||
|
||||
void* func_800982FC(ObjectContext* objectCtx, s32 bankIndex, s16 objectId) {
|
||||
ObjectStatus* status = &objectCtx->status[bankIndex];
|
||||
void* func_800982FC(ObjectContext* objectCtx, s32 slot, s16 objectId) {
|
||||
ObjectEntry* entry = &objectCtx->slots[slot];
|
||||
RomFile* objectFile = &gObjectTable[objectId];
|
||||
u32 size;
|
||||
void* nextPtr;
|
||||
|
||||
status->id = -objectId;
|
||||
status->dmaRequest.vromAddr = 0;
|
||||
entry->id = -objectId;
|
||||
entry->dmaRequest.vromAddr = 0;
|
||||
|
||||
size = objectFile->vromEnd - objectFile->vromStart;
|
||||
osSyncPrintf("OBJECT EXCHANGE NO=%2d BANK=%3d SIZE=%8.3fK\n", bankIndex, objectId, size / 1024.0f);
|
||||
osSyncPrintf("OBJECT EXCHANGE NO=%2d BANK=%3d SIZE=%8.3fK\n", slot, objectId, size / 1024.0f);
|
||||
|
||||
nextPtr = (void*)ALIGN16((uintptr_t)status->segment + size);
|
||||
nextPtr = (void*)ALIGN16((uintptr_t)entry->segment + size);
|
||||
|
||||
ASSERT(nextPtr < objectCtx->spaceEnd, "nextptr < this->endSegment", "../z_scene.c", 381);
|
||||
|
||||
|
@ -191,7 +205,7 @@ void Scene_CommandPlayerEntryList(PlayState* play, SceneCmd* cmd) {
|
|||
linkObjectId = gLinkObjectIds[((void)0, gSaveContext.save.linkAge)];
|
||||
|
||||
gActorOverlayTable[playerEntry->id].initInfo->objectId = linkObjectId;
|
||||
Object_Spawn(&play->objectCtx, linkObjectId);
|
||||
Object_SpawnPersistent(&play->objectCtx, linkObjectId);
|
||||
}
|
||||
|
||||
void Scene_CommandActorEntryList(PlayState* play, SceneCmd* cmd) {
|
||||
|
@ -226,8 +240,8 @@ void Scene_CommandSpawnList(PlayState* play, SceneCmd* cmd) {
|
|||
|
||||
void Scene_CommandSpecialFiles(PlayState* play, SceneCmd* cmd) {
|
||||
if (cmd->specialFiles.keepObjectId != OBJECT_INVALID) {
|
||||
play->objectCtx.subKeepIndex = Object_Spawn(&play->objectCtx, cmd->specialFiles.keepObjectId);
|
||||
gSegments[5] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[play->objectCtx.subKeepIndex].segment);
|
||||
play->objectCtx.subKeepSlot = Object_SpawnPersistent(&play->objectCtx, cmd->specialFiles.keepObjectId);
|
||||
gSegments[5] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[play->objectCtx.subKeepSlot].segment);
|
||||
}
|
||||
|
||||
if (cmd->specialFiles.naviQuestHintFileId != NAVI_QUEST_HINTS_NONE) {
|
||||
|
@ -250,25 +264,27 @@ void Scene_CommandObjectList(PlayState* play, SceneCmd* cmd) {
|
|||
s32 i;
|
||||
s32 j;
|
||||
s32 k;
|
||||
ObjectStatus* status;
|
||||
ObjectStatus* status2;
|
||||
ObjectStatus* firstStatus;
|
||||
s16* objectEntry = SEGMENTED_TO_VIRTUAL(cmd->objectList.data);
|
||||
ObjectEntry* entry;
|
||||
ObjectEntry* invalidatedEntry;
|
||||
ObjectEntry* entries;
|
||||
s16* objectListEntry = SEGMENTED_TO_VIRTUAL(cmd->objectList.data);
|
||||
void* nextPtr;
|
||||
|
||||
k = 0;
|
||||
i = play->objectCtx.unk_09;
|
||||
firstStatus = &play->objectCtx.status[0];
|
||||
status = &play->objectCtx.status[i];
|
||||
i = play->objectCtx.numPersistentEntries;
|
||||
entries = play->objectCtx.slots;
|
||||
entry = &play->objectCtx.slots[i];
|
||||
|
||||
while (i < play->objectCtx.num) {
|
||||
if (status->id != *objectEntry) {
|
||||
status2 = &play->objectCtx.status[i];
|
||||
for (j = i; j < play->objectCtx.num; j++) {
|
||||
status2->id = OBJECT_INVALID;
|
||||
status2++;
|
||||
while (i < play->objectCtx.numEntries) {
|
||||
if (entry->id != *objectListEntry) {
|
||||
|
||||
invalidatedEntry = &play->objectCtx.slots[i];
|
||||
for (j = i; j < play->objectCtx.numEntries; j++) {
|
||||
invalidatedEntry->id = OBJECT_INVALID;
|
||||
invalidatedEntry++;
|
||||
}
|
||||
play->objectCtx.num = i;
|
||||
|
||||
play->objectCtx.numEntries = i;
|
||||
Actor_KillAllWithMissingObject(play, &play->actorCtx);
|
||||
|
||||
continue;
|
||||
|
@ -276,24 +292,24 @@ void Scene_CommandObjectList(PlayState* play, SceneCmd* cmd) {
|
|||
|
||||
i++;
|
||||
k++;
|
||||
objectEntry++;
|
||||
status++;
|
||||
objectListEntry++;
|
||||
entry++;
|
||||
}
|
||||
|
||||
ASSERT(cmd->objectList.length <= OBJECT_EXCHANGE_BANK_MAX,
|
||||
ASSERT(cmd->objectList.length <= ARRAY_COUNT(play->objectCtx.slots),
|
||||
"scene_info->object_bank.num <= OBJECT_EXCHANGE_BANK_MAX", "../z_scene.c", 705);
|
||||
|
||||
while (k < cmd->objectList.length) {
|
||||
nextPtr = func_800982FC(&play->objectCtx, i, *objectEntry);
|
||||
if (i < OBJECT_EXCHANGE_BANK_MAX - 1) {
|
||||
firstStatus[i + 1].segment = nextPtr;
|
||||
nextPtr = func_800982FC(&play->objectCtx, i, *objectListEntry);
|
||||
if (i < (ARRAY_COUNT(play->objectCtx.slots) - 1)) {
|
||||
entries[i + 1].segment = nextPtr;
|
||||
}
|
||||
i++;
|
||||
k++;
|
||||
objectEntry++;
|
||||
objectListEntry++;
|
||||
}
|
||||
|
||||
play->objectCtx.num = i;
|
||||
play->objectCtx.numEntries = i;
|
||||
}
|
||||
|
||||
void Scene_CommandLightList(PlayState* play, SceneCmd* cmd) {
|
||||
|
|
|
@ -539,8 +539,8 @@ s32 View_UpdateViewingMatrix(View* view) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
s32 View_ApplyTo(View* view, s32 mask, Gfx** gfxp) {
|
||||
Gfx* gfx = *gfxp;
|
||||
s32 View_ApplyTo(View* view, s32 mask, Gfx** gfxP) {
|
||||
Gfx* gfx = *gfxP;
|
||||
GraphicsContext* gfxCtx = view->gfxCtx;
|
||||
s32 width;
|
||||
s32 height;
|
||||
|
@ -606,7 +606,7 @@ s32 View_ApplyTo(View* view, s32 mask, Gfx** gfxp) {
|
|||
}
|
||||
|
||||
view->flags = 0;
|
||||
*gfxp = gfx;
|
||||
*gfxP = gfx;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
145
src/code/z_viscvg.c
Normal file
145
src/code/z_viscvg.c
Normal file
|
@ -0,0 +1,145 @@
|
|||
/**
|
||||
* @file z_viscvg.c
|
||||
*
|
||||
* This file implements full-screen frame buffer effects involving the visualization of Coverage in various ways.
|
||||
*
|
||||
* Coverage is roughly how much of a pixel is covered by a primitive; the final coverage for a frame is stored in the
|
||||
* color image alpha component where it is used for antialiasing, see PreRender.c and §15 of the programming manual for
|
||||
* details.
|
||||
*
|
||||
* To understand this file, it is helpful to remember that A_MEM is essentially synonymous with coverage, and that
|
||||
* `GBL_c1/2(p, a, m, b)` usually represents the RDP blender calculation `(p * a + m * b)`.
|
||||
* Note the division step that is often included in the blender calculation is omitted; the division is skipped if
|
||||
* force blending (FORCE_BL) is set, which is the case for all render modes used in this file.
|
||||
*
|
||||
* Coverage is full when not on an edge, while on an edge it is usually lower. Since coverage is treated as an alpha
|
||||
* value, edges of primitives where coverage is lower will show up darker than primitive interiors in all of the
|
||||
* available modes.
|
||||
*
|
||||
* Coverage is abbreviated to "cvg"; "FB RGB" ("framebuffer red/green/blue") is the color the pixel originally had
|
||||
* before the filter is applied.
|
||||
*/
|
||||
|
||||
#include "global.h"
|
||||
|
||||
/**
|
||||
* Draws only coverage: does not retain any of the original pixel RGB, primColor is used as background color.
|
||||
*/
|
||||
Gfx sCoverageOnlyDL[] = {
|
||||
gsDPSetOtherMode(G_AD_PATTERN | G_CD_MAGICSQ | G_CK_NONE | G_TC_CONV | 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),
|
||||
// (blendColor RGB) * (cvg)
|
||||
gsDPFillRectangle(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1),
|
||||
gsDPPipeSync(),
|
||||
gsDPSetBlendColor(0, 0, 0, 8),
|
||||
gsSPEndDisplayList(),
|
||||
};
|
||||
|
||||
/**
|
||||
* Draws fog + coverage * RGB of pixels
|
||||
*
|
||||
* @bug This easily overflows the blender because the fog value is added to the coverage value.
|
||||
*/
|
||||
Gfx sCoverageRGBFogDL[] = {
|
||||
gsDPSetOtherMode(G_AD_PATTERN | G_CD_MAGICSQ | G_CK_NONE | G_TC_CONV | 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 | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | FORCE_BL |
|
||||
GBL_c1(G_BL_CLR_FOG, G_BL_A_FOG, G_BL_CLR_MEM, G_BL_A_MEM) |
|
||||
GBL_c2(G_BL_CLR_FOG, G_BL_A_FOG, G_BL_CLR_MEM, G_BL_A_MEM)),
|
||||
// (fog RGB) * (fog alpha) + (FB RGB) * (cvg)
|
||||
gsDPFillRectangle(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1),
|
||||
gsSPEndDisplayList(),
|
||||
};
|
||||
|
||||
/**
|
||||
* Draws coverage and RGB of pixels
|
||||
*/
|
||||
Gfx sCoverageRGBDL[] = {
|
||||
gsDPSetOtherMode(G_AD_PATTERN | G_CD_MAGICSQ | G_CK_NONE | G_TC_CONV | 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 | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | FORCE_BL |
|
||||
GBL_c1(G_BL_CLR_IN, G_BL_0, G_BL_CLR_MEM, G_BL_A_MEM) |
|
||||
GBL_c2(G_BL_CLR_IN, G_BL_0, G_BL_CLR_MEM, G_BL_A_MEM)),
|
||||
// (FB RGB) * (cvg)
|
||||
gsDPFillRectangle(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1),
|
||||
gsSPEndDisplayList(),
|
||||
};
|
||||
|
||||
/**
|
||||
* Two stage filtering:
|
||||
*
|
||||
* 1. Apply a uniform color filter by transparently blending primColor with original frame. The "cloud surface"
|
||||
* RenderMode is used to preserve the coverage for the second stage.
|
||||
* 2. Second half is the same as `sCoverageRGBDL`'s, i.e. (RGB from stage 1) * cvg
|
||||
*/
|
||||
Gfx sCoverageRGBUniformDL[] = {
|
||||
gsDPSetCombineMode(G_CC_PRIMITIVE, G_CC_PRIMITIVE),
|
||||
gsDPSetOtherMode(G_AD_NOTPATTERN | G_CD_DISABLE | G_CK_NONE | G_TC_CONV | 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),
|
||||
// stage 1 color = (primColor RGB) * (primColor Alpha) + (FB RGB) * (1 - primColor Alpha)
|
||||
gsDPFillRectangle(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1),
|
||||
|
||||
gsDPSetOtherMode(G_AD_PATTERN | G_CD_MAGICSQ | G_CK_NONE | G_TC_CONV | 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 | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | FORCE_BL |
|
||||
GBL_c1(G_BL_CLR_IN, G_BL_0, G_BL_CLR_MEM, G_BL_A_MEM) |
|
||||
GBL_c2(G_BL_CLR_IN, G_BL_0, G_BL_CLR_MEM, G_BL_A_MEM)),
|
||||
// final color = (stage 1 RGB) * (cvg)
|
||||
gsDPFillRectangle(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1),
|
||||
gsSPEndDisplayList(),
|
||||
};
|
||||
|
||||
void VisCvg_Init(VisCvg* this) {
|
||||
this->vis.type = FB_FILTER_NONE;
|
||||
this->vis.scissorType = VIS_NO_SETSCISSOR;
|
||||
this->vis.primColor.r = 255;
|
||||
this->vis.primColor.g = 255;
|
||||
this->vis.primColor.b = 255;
|
||||
this->vis.primColor.a = 255;
|
||||
}
|
||||
|
||||
void VisCvg_Destroy(VisCvg* this) {
|
||||
}
|
||||
|
||||
void VisCvg_Draw(VisCvg* this, Gfx** gfxP) {
|
||||
Gfx* gfx = *gfxP;
|
||||
|
||||
gDPPipeSync(gfx++);
|
||||
gDPSetPrimDepth(gfx++, 0xFFFF, 0xFFFF);
|
||||
|
||||
if (this->vis.scissorType == VIS_SETSCISSOR) {
|
||||
gDPSetScissor(gfx++, G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
}
|
||||
|
||||
switch (this->vis.type) {
|
||||
case FB_FILTER_CVG_RGB:
|
||||
gSPDisplayList(gfx++, sCoverageRGBDL);
|
||||
break;
|
||||
|
||||
case FB_FILTER_CVG_RGB_UNIFORM:
|
||||
// Set primitive color for uniform color filter in custom RenderMode
|
||||
gDPSetColor(gfx++, G_SETPRIMCOLOR, this->vis.primColor.rgba);
|
||||
gSPDisplayList(gfx++, sCoverageRGBUniformDL);
|
||||
break;
|
||||
|
||||
case FB_FILTER_CVG_ONLY:
|
||||
// Set background color for G_RM_VISCVG
|
||||
gDPSetColor(gfx++, G_SETBLENDCOLOR, this->vis.primColor.rgba);
|
||||
gSPDisplayList(gfx++, sCoverageOnlyDL);
|
||||
break;
|
||||
|
||||
case FB_FILTER_CVG_RGB_FOG:
|
||||
// Set fog color for custom RenderMode, needs to be close to 0 to not overflow
|
||||
gDPSetColor(gfx++, G_SETFOGCOLOR, this->vis.primColor.rgba);
|
||||
gSPDisplayList(gfx++, sCoverageRGBFogDL);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
gDPPipeSync(gfx++);
|
||||
*gfxP = gfx;
|
||||
}
|
|
@ -1,13 +1,19 @@
|
|||
/**
|
||||
* Color frame buffer effect to desaturate the colors.
|
||||
* @file z_vismono.c
|
||||
*
|
||||
* This file implements a full-screen framebuffer effect for desaturating the contents of the framebuffer image.
|
||||
*
|
||||
* Broadly, this effect is achieved by reinterpreting the contents of the RGBA16 color image as indices into an IA16
|
||||
* color palette that converts each color into the desaturated equivalent. More precise details can be found in inline
|
||||
* comments.
|
||||
*/
|
||||
|
||||
#include "global.h"
|
||||
|
||||
// Height of the fragments the color frame buffer (CFB) is split into.
|
||||
// It is the maximum amount of lines such that all rgba16 SCREEN_WIDTH-long lines fit into
|
||||
// the half of tmem (0x800 bytes) dedicated to color-indexed data.
|
||||
#define VISMONO_CFBFRAG_HEIGHT (0x800 / (SCREEN_WIDTH * G_IM_SIZ_16b_BYTES))
|
||||
// the half of TMEM dedicated to color-indexed data.
|
||||
#define VISMONO_CFBFRAG_HEIGHT ((TMEM_SIZE / 2) / (SCREEN_WIDTH * G_IM_SIZ_16b_BYTES))
|
||||
|
||||
// Maximum size of the dlist written by `VisMono_DesaturateDList`.
|
||||
// `VisMono_DesaturateDList` consistently uses `VISMONO_DLSIZE - 2` double words, so this can be 2 less.
|
||||
|
@ -26,16 +32,16 @@ extern u16 D_0F000000[];
|
|||
|
||||
void VisMono_Init(VisMono* this) {
|
||||
bzero(this, sizeof(VisMono));
|
||||
this->unk_00 = 0;
|
||||
this->setScissor = false;
|
||||
this->primColor.r = 255;
|
||||
this->primColor.g = 255;
|
||||
this->primColor.b = 255;
|
||||
this->primColor.a = 255;
|
||||
this->envColor.r = 0;
|
||||
this->envColor.g = 0;
|
||||
this->envColor.b = 0;
|
||||
this->envColor.a = 0;
|
||||
this->vis.type = 0;
|
||||
this->vis.scissorType = VIS_NO_SETSCISSOR;
|
||||
this->vis.primColor.r = 255;
|
||||
this->vis.primColor.g = 255;
|
||||
this->vis.primColor.b = 255;
|
||||
this->vis.primColor.a = 255;
|
||||
this->vis.envColor.r = 0;
|
||||
this->vis.envColor.g = 0;
|
||||
this->vis.envColor.b = 0;
|
||||
this->vis.envColor.a = 0;
|
||||
}
|
||||
|
||||
void VisMono_Destroy(VisMono* this) {
|
||||
|
@ -95,6 +101,8 @@ Gfx* VisMono_DesaturateDList(VisMono* this, Gfx* gfx) {
|
|||
|
||||
// Set texel 1 to be a CI8 image with width `SCREEN_WIDTH * 2` and height `VISMONO_CFBFRAG_HEIGHT`
|
||||
// Its position in texture image space is shifted along +S by 1
|
||||
// Note the palette index for this tile has also been incremented from 0 to 1, however the palette index is
|
||||
// ignored for CI8 texture sampling.
|
||||
gDPSetTile(gfx++, G_IM_FMT_CI, G_IM_SIZ_8b, SCREEN_WIDTH * 2 * G_IM_SIZ_8b_LINE_BYTES / 8, 0x0, 1, 1,
|
||||
G_TX_NOMIRROR | G_TX_CLAMP, 0, 0, G_TX_NOMIRROR | G_TX_CLAMP, 0, 0);
|
||||
gDPSetTileSize(gfx++, 1, 1 << 2, 0, (SCREEN_WIDTH * 2) << 2, (VISMONO_CFBFRAG_HEIGHT - 1) << 2);
|
||||
|
@ -129,8 +137,8 @@ Gfx* VisMono_DesaturateDList(VisMono* this, Gfx* gfx) {
|
|||
return gfx;
|
||||
}
|
||||
|
||||
void VisMono_Draw(VisMono* this, Gfx** gfxp) {
|
||||
Gfx* gfx = *gfxp;
|
||||
void VisMono_Draw(VisMono* this, Gfx** gfxP) {
|
||||
Gfx* gfx = *gfxP;
|
||||
u16* tlut;
|
||||
Gfx* dList;
|
||||
Gfx* dListEnd;
|
||||
|
@ -159,12 +167,12 @@ void VisMono_Draw(VisMono* this, Gfx** gfxp) {
|
|||
|
||||
gDPPipeSync(gfx++);
|
||||
|
||||
if (this->setScissor == true) {
|
||||
if (this->vis.scissorType == VIS_SETSCISSOR) {
|
||||
gDPSetScissor(gfx++, G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
}
|
||||
|
||||
gDPSetColor(gfx++, G_SETPRIMCOLOR, this->primColor.rgba);
|
||||
gDPSetColor(gfx++, G_SETENVCOLOR, this->envColor.rgba);
|
||||
gDPSetColor(gfx++, G_SETPRIMCOLOR, this->vis.primColor.rgba);
|
||||
gDPSetColor(gfx++, G_SETENVCOLOR, this->vis.envColor.rgba);
|
||||
|
||||
gDPLoadTLUT_pal256(gfx++, tlut);
|
||||
|
||||
|
@ -172,7 +180,7 @@ void VisMono_Draw(VisMono* this, Gfx** gfxp) {
|
|||
|
||||
gDPPipeSync(gfx++);
|
||||
|
||||
*gfxp = gfx;
|
||||
*gfxP = gfx;
|
||||
}
|
||||
|
||||
void VisMono_DrawOld(VisMono* this) {
|
||||
|
|
111
src/code/z_viszbuf.c
Normal file
111
src/code/z_viszbuf.c
Normal file
|
@ -0,0 +1,111 @@
|
|||
/**
|
||||
* @file z_viszbuf.c
|
||||
*
|
||||
* This file implements a full-screen framebuffer effect for visualizing the z-buffer (AKA depth buffer), using either
|
||||
* cycling RGBA or a single fading color.
|
||||
*
|
||||
* This is done by reading the z-buffer as if it were a color image, the format of which is specified by the selected
|
||||
* vis type:
|
||||
* - VIS_ZBUF_TYPE_IA : Produces a monotonic fade from primColor to envColor as depth increases.
|
||||
* - VIS_ZBUF_TYPE_RGBA : Produces vibrant almost-periodic-looking bands.
|
||||
*
|
||||
* In both cases this occurs because of the format the depth information takes: it is 18-bit, and is a nonnegative
|
||||
* floating-point number with
|
||||
* bbb mmmmmmmmmmm dd|dd
|
||||
* exponent mantissa dz value (only first 16 bits visible to CPU, the least significant 2 bits of dz are ignored)
|
||||
*
|
||||
* Reading z-buffer as IA16:
|
||||
* bbbmmmmm mmmmmmdd
|
||||
* iiiiiiii aaaaaaaa
|
||||
*
|
||||
* Since floating-point numbers of this format have the same ordering as their binary/hex representation, increasing
|
||||
* the depth also increases the intensity in the IA16 representation and hence the interpolation parameter used to
|
||||
* combine primColor and envColor. The alpha is ignored by the RenderMode.
|
||||
*
|
||||
* Reading z-buffer as RGBA16:
|
||||
* bbbmm mmmmm mmmmd d
|
||||
* rrrrr ggggg bbbbb a
|
||||
*
|
||||
* The red increases monotonically with the depth. The significant visible oscillation is the green component, because
|
||||
* it rolls over every time the second-most-significant bit of the mantissa increments. The blue component oscillates
|
||||
* too rapidly to be particularly visible (it rolls over when the 7th-most-significant bit increments). The alpha is
|
||||
* again ignored by the RenderMode.
|
||||
*/
|
||||
|
||||
#include "global.h"
|
||||
|
||||
// Height of the fragments the z-buffer is split into.
|
||||
// It is the maximum amount of lines such that all rgba16 SCREEN_WIDTH-long lines fit into TMEM.
|
||||
#define VISZBUF_ZBUFFRAG_HEIGHT (TMEM_SIZE / (SCREEN_WIDTH * G_IM_SIZ_16b_BYTES))
|
||||
|
||||
// z-buffer
|
||||
extern u16 D_0E000000[];
|
||||
|
||||
/**
|
||||
* Initialise to IA type with white and black as default colors.
|
||||
*/
|
||||
void VisZBuf_Init(VisZBuf* this) {
|
||||
this->vis.type = VIS_ZBUF_TYPE_IA;
|
||||
this->vis.scissorType = VIS_NO_SETSCISSOR;
|
||||
this->vis.primColor.r = 255;
|
||||
this->vis.primColor.g = 255;
|
||||
this->vis.primColor.b = 255;
|
||||
this->vis.primColor.a = 255;
|
||||
this->vis.envColor.a = 255;
|
||||
this->vis.envColor.r = 0;
|
||||
this->vis.envColor.g = 0;
|
||||
this->vis.envColor.b = 0;
|
||||
}
|
||||
|
||||
void VisZBuf_Destroy(VisZBuf* this) {
|
||||
}
|
||||
|
||||
void VisZBuf_Draw(VisZBuf* this, Gfx** gfxP) {
|
||||
Gfx* gfx = *gfxP;
|
||||
u16* zbufFrag = D_0E000000;
|
||||
s32 fmt;
|
||||
s32 y;
|
||||
s32 height;
|
||||
|
||||
if (this->vis.type == VIS_ZBUF_TYPE_IA) {
|
||||
fmt = G_IM_FMT_IA;
|
||||
} else { // VIS_ZBUF_TYPE_RGBA
|
||||
fmt = G_IM_FMT_RGBA;
|
||||
}
|
||||
|
||||
height = VISZBUF_ZBUFFRAG_HEIGHT;
|
||||
|
||||
gDPPipeSync(gfx++);
|
||||
// Scissoring is only required if the scissor has not been set prior.
|
||||
if (this->vis.scissorType == VIS_SETSCISSOR) {
|
||||
gDPSetScissor(gfx++, G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
}
|
||||
|
||||
// No palette so can use all of TMEM.
|
||||
// G_RM_OPA_SURF discards all information previously in the pixel, and the current alpha, leaving only the color
|
||||
// from this filter.
|
||||
gDPSetOtherMode(gfx++,
|
||||
G_AD_DISABLE | G_CD_MAGICSQ | 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);
|
||||
|
||||
// LERP between primColor and envColor in 1-cycle mode using the z-buffer value.
|
||||
gDPSetCombineLERP(gfx++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT,
|
||||
PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT);
|
||||
gDPSetColor(gfx++, G_SETPRIMCOLOR, this->vis.primColor.rgba);
|
||||
gDPSetColor(gfx++, G_SETENVCOLOR, this->vis.envColor.rgba);
|
||||
|
||||
for (y = 0; y <= SCREEN_HEIGHT - height; y += height) {
|
||||
// Load a few lines of the z-buffer, as many as can fit in TMEM at once.
|
||||
gDPLoadTextureBlock(gfx++, zbufFrag, fmt, G_IM_SIZ_16b, SCREEN_WIDTH, height, 0, G_TX_NOMIRROR | G_TX_CLAMP,
|
||||
G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
|
||||
|
||||
// Overwrite them with the calculated colors.
|
||||
gSPTextureRectangle(gfx++, 0, y << 2, SCREEN_WIDTH << 2, (y + height) << 2, G_TX_RENDERTILE, 0, 0, 1 << 10,
|
||||
1 << 10);
|
||||
zbufFrag += SCREEN_WIDTH * height;
|
||||
}
|
||||
|
||||
gDPPipeSync(gfx++);
|
||||
*gfxP = gfx;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue