mirror of
https://github.com/zeldaret/mm.git
synced 2026-05-24 07:10:44 -04:00
8049dec339
* Import data and bss, add some name options * Decomp rest of stack functions, remove RSPMatrix, split header * sys_matrix OK (thanks Tharo) Co-authored-by: Tharo <17233964+Thar0@users.noreply.github.com> * pragma weaks in sinf and cosf, change documentation change mcros to use 0x8000 * Rename sinf and cosf * Correct initialisation of sMtxFClear * More minor cleanup * Rename stack functions * Matrix_InsertMatrix -> Matrix_Mult * The big transpose rename * Fix MirRay_DrawReflectedBeam * Matrix_InsertTranslation -> Matrix_Translate * Matrix_Insert.Rotation_s -> Matrix_Rotate$1S + RotateY -> RotateYS * Matrix_Insert(.)Rotation_f -> Matrix_Rotate$1F * Matrix_RotateStateAroundXAxis -> Matrix_RotateXFApply Matrix_SetStateXRotation -> Matrix_RotateXFNew * Matrix_MultiplyVector3fByState -> Matrix_MultVec3f * Matrix_MultiplyVector3fXZByCurrentState -> Matrix_MultVec3fXZ * Matrix_GetStateTranslation -> Matrix_MultZero * Matrix_GetStateTranslationAndScaled(.) -> Matrix_MultVec$1 * Matrix_FromRSPMatrix -> Matrix_MtxToMtxF * Matrix_MultiplyVector3fByMatrix -> Matrix_MultVec3fExt * Matrix_TransposeXYZ -> Matrix_Transpose * Matrix_ToRSPMatrix -> Matrix_MtxFToMtx * Matrix_AppendToPolyOpaDisp -> Matrix_MtxFToNewMtx and document the conversion functions * Matrix_NormalizeXYZ -> Matrix_ReplaceRotation * Matrix_InsertRotationAroundUnitVector_f -> Matrix_RotateAxisF and S * Matrix_InsertRotation -> Matrix_RotateZYX * Document the last functions * Small cleanup * Matrix_JointPosition -> Matrix_TranslateRotateZYX * Matrix_SetStateRotationAndTranslation -> Matrix_SetTranslateRotateYXZ * func_8018219C -> Matrix_MtxFToYXZRot * func_801822C4 -> Matrix_MtxFToZYXRot * Fix files * Format * Review 1 * Renames * Fix warning in EnDragon * Format * Convert `mode` to an actual enum * Add enums, typedefs, externs to sys_matrix header * Review * One more * More review * Fix function names * Format * Fix names * Format * Review * engineer's review * Fix build * Format * Fix again Co-authored-by: Tharo <17233964+Thar0@users.noreply.github.com>
68 lines
2.7 KiB
C
68 lines
2.7 KiB
C
#include "global.h"
|
|
|
|
Mtx* sSkyboxDrawMatrix;
|
|
|
|
Mtx* SkyboxDraw_UpdateMatrix(SkyboxContext* skyboxCtx, f32 x, f32 y, f32 z) {
|
|
Matrix_Translate(x, y, z, MTXMODE_NEW);
|
|
Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY);
|
|
Matrix_RotateXFApply(skyboxCtx->rotX);
|
|
Matrix_RotateYF(skyboxCtx->rotY, MTXMODE_APPLY);
|
|
Matrix_RotateZF(skyboxCtx->rotZ, MTXMODE_APPLY);
|
|
return Matrix_ToMtx(sSkyboxDrawMatrix);
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
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_Translate(x, y, z, MTXMODE_NEW);
|
|
Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY);
|
|
Matrix_RotateXFApply(skyboxCtx->rotX);
|
|
Matrix_RotateYF(skyboxCtx->rotY, MTXMODE_APPLY);
|
|
Matrix_RotateZF(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) {
|
|
}
|