summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLucas Shaw <49287729+shawlucas@users.noreply.github.com>2021-12-06 23:36:02 -0500
committerGitHub <noreply@github.com>2021-12-07 04:36:02 +0000
commitff231e093a2fb34ca85eff71115ff777719cdb6d (patch)
tree6330b3c899cd700af99e9d001d8ae314576ceefc /src
parentad02db9b8271184eaa30cc60c3897ea1ab930cde (diff)
z_vr_box_draw OK (#481)
* z_vr_box_draw OK * ok * Removed z_vr_box_draw.data.s, its actually z_sram_NES.data.s * Added enum SkyboxId
Diffstat (limited to 'src')
-rw-r--r--src/code/z_vr_box.c2
-rw-r--r--src/code/z_vr_box_draw.c66
2 files changed, 63 insertions, 5 deletions
diff --git a/src/code/z_vr_box.c b/src/code/z_vr_box.c
index 724bc5971..29d1a1aca 100644
--- a/src/code/z_vr_box.c
+++ b/src/code/z_vr_box.c
@@ -140,7 +140,7 @@ void func_801434E4(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyType)
func_801431E8(gameState, skyboxCtx, skyType);
if (skyType != 0) {
- skyboxCtx->unk17C = THA_AllocEndAlign16(&gameState->heap, 0x3840);
+ skyboxCtx->dListBuf = THA_AllocEndAlign16(&gameState->heap, 0x3840);
if (skyType == 5) {
// Allocate enough space for the vertices for a 6 sided skybox (cube)
diff --git a/src/code/z_vr_box_draw.c b/src/code/z_vr_box_draw.c
index 27142c944..d7f99eed9 100644
--- a/src/code/z_vr_box_draw.c
+++ b/src/code/z_vr_box_draw.c
@@ -1,9 +1,67 @@
#include "global.h"
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_vr_box_draw/func_801435A0.s")
+Mtx* sSkyboxDrawMatrix;
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_vr_box_draw/func_80143624.s")
+Mtx* SkyboxDraw_UpdateMatrix(SkyboxContext* skyboxCtx, f32 x, f32 y, f32 z) {
+ Matrix_InsertTranslation(x, y, z, MTXMODE_NEW);
+ Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY);
+ Matrix_RotateStateAroundXAxis(skyboxCtx->rotX);
+ Matrix_InsertYRotation_f(skyboxCtx->rotY, MTXMODE_APPLY);
+ Matrix_InsertZRotation_f(skyboxCtx->rotZ, MTXMODE_APPLY);
+ return Matrix_ToMtx(sSkyboxDrawMatrix);
+}
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_vr_box_draw/func_80143668.s")
+void SkyboxDraw_SetColors(SkyboxContext* skyboxCtx, u8 primR, u8 primG, u8 primB, u8 envR, u8 envG, u8 envB) {
+ skyboxCtx->primR = primR;
+ skyboxCtx->primG = primG;
+ skyboxCtx->primB = primB;
+ skyboxCtx->envR = envR;
+ skyboxCtx->envG = envG;
+ skyboxCtx->envB = envB;
+}
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_vr_box_draw/func_80143A04.s")
+void SkyboxDraw_Draw(SkyboxContext* skyboxCtx, GraphicsContext* gfxCtx, s16 skyboxId, s16 blend, f32 x, f32 y, f32 z) {
+ OPEN_DISPS(gfxCtx);
+
+ func_8012C6AC(gfxCtx);
+
+ gSPSegment(POLY_OPA_DISP++, 0x0B, skyboxCtx->skyboxPaletteStaticSegment);
+ gSPTexture(POLY_OPA_DISP++, 0x8000, 0x8000, 0, G_TX_RENDERTILE, G_ON);
+
+ sSkyboxDrawMatrix = GRAPH_ALLOC(gfxCtx, sizeof(Mtx));
+
+ Matrix_InsertTranslation(x, y, z, MTXMODE_NEW);
+ Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY);
+ Matrix_RotateStateAroundXAxis(skyboxCtx->rotX);
+ Matrix_InsertYRotation_f(skyboxCtx->rotY, MTXMODE_APPLY);
+ Matrix_InsertZRotation_f(skyboxCtx->rotZ, MTXMODE_APPLY);
+ Matrix_ToMtx(sSkyboxDrawMatrix);
+
+ gSPMatrix(POLY_OPA_DISP++, sSkyboxDrawMatrix, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
+ gDPSetColorDither(POLY_OPA_DISP++, G_CD_MAGICSQ);
+ gDPSetTextureFilter(POLY_OPA_DISP++, G_TF_BILERP);
+ gDPLoadTLUT_pal256(POLY_OPA_DISP++, skyboxCtx->skyboxPaletteStaticSegment);
+ gDPSetTextureLUT(POLY_OPA_DISP++, G_TT_RGBA16);
+ gDPSetTextureConvert(POLY_OPA_DISP++, G_TC_FILT);
+ gDPSetCombineLERP(POLY_OPA_DISP++, TEXEL1, TEXEL0, PRIMITIVE_ALPHA, TEXEL0, TEXEL1, TEXEL0, PRIMITIVE, TEXEL0,
+ PRIMITIVE, ENVIRONMENT, COMBINED, ENVIRONMENT, 0, 0, 0, COMBINED);
+ gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, skyboxCtx->primR, skyboxCtx->primG, skyboxCtx->primB, blend);
+ gDPSetEnvColor(POLY_OPA_DISP++, skyboxCtx->envR, skyboxCtx->envG, skyboxCtx->envB, 0);
+
+ gSPDisplayList(POLY_OPA_DISP++, &skyboxCtx->dListBuf[0]);
+ gSPDisplayList(POLY_OPA_DISP++, &skyboxCtx->dListBuf[300]);
+ gSPDisplayList(POLY_OPA_DISP++, &skyboxCtx->dListBuf[600]);
+ gSPDisplayList(POLY_OPA_DISP++, &skyboxCtx->dListBuf[900]);
+ gSPDisplayList(POLY_OPA_DISP++, &skyboxCtx->dListBuf[1200]);
+
+ if (skyboxId == SKYBOX_CUTSCENE_MAP) {
+ gSPDisplayList(POLY_OPA_DISP++, &skyboxCtx->dListBuf[1500]);
+ }
+
+ gDPPipeSync(POLY_OPA_DISP++);
+
+ CLOSE_DISPS(gfxCtx);
+}
+
+void SkyboxDraw_Noop(SkyboxContext* skyboxCtx) {
+}