summaryrefslogtreecommitdiff
path: root/src/engine
diff options
context:
space:
mode:
authorKiritoDv <kiritodev01@gmail.com>2024-03-24 02:01:28 -0600
committerKiritoDv <kiritodev01@gmail.com>2024-04-06 04:32:13 -0600
commit641a43cbf9b4f4c4f545218e201fb58bbe15fcd7 (patch)
tree50ecef61c66e171580ef1a09c2d3a9fc32591768 /src/engine
parent126a55aa0eadaf8b2ed8f370cbba63368be7a964 (diff)
First compilation, we just need more stupid assets
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/fox_360.c6
-rw-r--r--src/engine/fox_load.c35
-rw-r--r--src/engine/fox_load_inits.c9
-rw-r--r--src/engine/fox_save.c12
-rw-r--r--src/engine/guPerspectiveF.c40
-rw-r--r--src/engine/lookat.c73
6 files changed, 142 insertions, 33 deletions
diff --git a/src/engine/fox_360.c b/src/engine/fox_360.c
index 9dbdfa93..2adec923 100644
--- a/src/engine/fox_360.c
+++ b/src/engine/fox_360.c
@@ -2272,10 +2272,12 @@ void ActorAllRange_Draw(Actor* actor) {
break;
}
} else if (gCurrentLevel == LEVEL_SECTOR_Z) {
- gSPDisplayList(gMasterDisp++, D_SZ_6004FE0) Matrix_Translate(gGfxMatrix, 0.0f, 0.0f, -60.0f, 1);
+ gSPDisplayList(gMasterDisp++, D_SZ_6004FE0);
+ Matrix_Translate(gGfxMatrix, 0.0f, 0.0f, -60.0f, 1);
func_edisplay_8005B1E8(actor, 2);
} else if (gCurrentLevel == LEVEL_BOLSE) {
- gSPDisplayList(gMasterDisp++, D_BO_6008770) Matrix_Push(&gGfxMatrix);
+ gSPDisplayList(gMasterDisp++, D_BO_6008770);
+ Matrix_Push(&gGfxMatrix);
Matrix_Translate(gGfxMatrix, 0.0f, 0.0f, -60.0f, 1);
func_edisplay_8005B1E8(actor, 2);
Matrix_Pop(&gGfxMatrix);
diff --git a/src/engine/fox_load.c b/src/engine/fox_load.c
index 556a6c50..5ad54e8c 100644
--- a/src/engine/fox_load.c
+++ b/src/engine/fox_load.c
@@ -27,22 +27,21 @@ OverlayInit sCurrentOverlay = {
};
void Overlay_LoadSegment(void* vRomAddress, void* dest, ptrdiff_t size) {
- s32 i;
-
- for (i = 0; gDmaTable[i].pRom.end != NULL; i++) {
- if (gDmaTable[i].vRomAddress == vRomAddress) {
- if (gDmaTable[i].compFlag == 0) {
- Lib_DmaRead(gDmaTable[i].pRom.start, dest, size);
- } else {
- Lib_FillScreen(true);
- sFillTimer = 3;
- D_game_80161A39 = true;
- Lib_DmaRead(gDmaTable[i].pRom.start, gFrameBuffers, SEGMENT_SIZE(gDmaTable[i].pRom));
- Mio0_Decompress(gFrameBuffers, dest);
- }
- break;
- }
- }
+ // s32 i;
+ // for (i = 0; gDmaTable[i].pRom.end != NULL; i++) {
+ // if (gDmaTable[i].vRomAddress == vRomAddress) {
+ // if (gDmaTable[i].compFlag == 0) {
+ // Lib_DmaRead(gDmaTable[i].pRom.start, dest, size);
+ // } else {
+ // Lib_FillScreen(true);
+ // sFillTimer = 3;
+ // D_80161A39 = true;
+ // Lib_DmaRead(gDmaTable[i].pRom.start, gFrameBuffers, SEGMENT_SIZE(gDmaTable[i].pRom));
+ // Mio0_Decompress(gFrameBuffers, dest);
+ // }
+ // break;
+ // }
+ // }
}
u8 Overlay_Init(OverlayInit* ovlInit) {
@@ -196,6 +195,6 @@ u8 Overlay_Load(u8 ovlSetup, u8 ovlStage) {
}
void Overlay_InitDma(void) {
- Lib_DmaRead(SEGMENT_ROM_START(dma_table), SEGMENT_VRAM_START(dma_table), SEGMENT_ROM_SIZE(dma_table));
- Overlay_LoadSegment(SEGMENT_ROM_START(ast_radio), SEGMENT_VRAM_START(ast_radio), SEGMENT_ROM_SIZE(ast_radio));
+ // Lib_DmaRead(SEGMENT_ROM_START(dma_table), SEGMENT_VRAM_START(dma_table), SEGMENT_ROM_SIZE(dma_table));
+ // Overlay_LoadSegment(SEGMENT_ROM_START(ast_radio), SEGMENT_VRAM_START(ast_radio), SEGMENT_ROM_SIZE(ast_radio));
}
diff --git a/src/engine/fox_load_inits.c b/src/engine/fox_load_inits.c
index 621f718b..580a27c8 100644
--- a/src/engine/fox_load_inits.c
+++ b/src/engine/fox_load_inits.c
@@ -4,12 +4,7 @@
{ NULL, NULL }
#define OVERLAY_OFFSETS(file) \
- { \
- { SEGMENT_ROM_START(file), SEGMENT_ROM_END(file) }, { SEGMENT_BSS_START(file), SEGMENT_BSS_END(file) }, \
- { SEGMENT_TEXT_START(file), SEGMENT_TEXT_END(file) }, { \
- SEGMENT_DATA_START(file), SEGMENT_RODATA_END(file) \
- } \
- }
+ NO_OVERLAY
#define NO_OVERLAY \
{ \
@@ -19,7 +14,7 @@
}
#define ROM_SEGMENT(file) \
- { SEGMENT_ROM_START(file), SEGMENT_ROM_END(file) }
+ NO_SEGMENT
OverlayInit sNoOvl_Logo[1] = {
{ NO_OVERLAY,
diff --git a/src/engine/fox_save.c b/src/engine/fox_save.c
index beb3357e..554ab310 100644
--- a/src/engine/fox_save.c
+++ b/src/engine/fox_save.c
@@ -39,26 +39,26 @@ u16 Save_Checksum(Save* arg0) {
}
s32 Save_Write(void) {
- void* sp1C;
+ OSMesg sp1C;
gSaveFile.save.checksum = Save_Checksum(&gSaveFile.save);
gSaveFile.backup = gSaveFile.save;
gSaveIOBuffer = gSaveFile;
- osSendMesg(&gSerialThreadMsgQueue, (OSMesg) SI_WRITE_SAVE, OS_MESG_PRI_NORMAL);
+ osSendMesg(&gSerialThreadMsgQueue, OS_MESG_32(SI_WRITE_SAVE), OS_MESG_PRI_NORMAL);
osRecvMesg(&gSaveMsgQueue, &sp1C, OS_MESG_BLOCK);
- if (sp1C != (OSMesg) SI_SAVE_SUCCESS) {
+ if (sp1C.data32 != SI_SAVE_SUCCESS) {
return -1;
}
return 0;
}
s32 Save_Read(void) {
- void* sp24;
+ OSMesg* sp24;
s32 i;
- osSendMesg(&gSerialThreadMsgQueue, (OSMesg) SI_READ_SAVE, OS_MESG_PRI_NORMAL);
+ osSendMesg(&gSerialThreadMsgQueue, OS_MESG_32(SI_READ_SAVE), OS_MESG_PRI_NORMAL);
osRecvMesg(&gSaveMsgQueue, &sp24, OS_MESG_BLOCK);
- if ((s32) sp24 != SI_SAVE_SUCCESS) {
+ if (sp24->data32 != SI_SAVE_SUCCESS) {
return -1;
}
diff --git a/src/engine/guPerspectiveF.c b/src/engine/guPerspectiveF.c
new file mode 100644
index 00000000..a7247534
--- /dev/null
+++ b/src/engine/guPerspectiveF.c
@@ -0,0 +1,40 @@
+#include <libultraship.h>
+#include <math.h>
+
+void guPerspectiveF(float mf[4][4], u16 *perspNorm, float fovy, float aspect, float near, float far,
+ float scale) {
+ float yscale;
+ int row;
+ int col;
+ guMtxIdentF(mf);
+ fovy *= GU_PI / 180.0;
+ yscale = cosf(fovy / 2) / sinf(fovy / 2);
+ mf[0][0] = yscale / aspect;
+ mf[1][1] = yscale;
+ mf[2][2] = (near + far) / (near - far);
+ mf[2][3] = -1;
+ mf[3][2] = 2 * near * far / (near - far);
+ mf[3][3] = 0.0f;
+ for (row = 0; row < 4; row++) {
+ for (col = 0; col < 4; col++) {
+ mf[row][col] *= scale;
+ }
+ }
+ if (perspNorm != NULL) {
+ if (near + far <= 2.0) {
+ *perspNorm = 65535;
+ } else {
+ *perspNorm = (double) (1 << 17) / (near + far);
+ if (*perspNorm <= 0) {
+ *perspNorm = 1;
+ }
+ }
+ }
+}
+
+void guPerspective(Mtx *m, u16 *perspNorm, float fovy, float aspect, float near, float far,
+ float scale) {
+ float mat[4][4];
+ guPerspectiveF(mat, perspNorm, fovy, aspect, near, far, scale);
+ guMtxF2L(mat, m);
+}
diff --git a/src/engine/lookat.c b/src/engine/lookat.c
new file mode 100644
index 00000000..e5060d24
--- /dev/null
+++ b/src/engine/lookat.c
@@ -0,0 +1,73 @@
+#include <libultraship.h>
+
+void guLookAtF(float mf[4][4], float xEye, float yEye, float zEye, float xAt, float yAt, float zAt, float xUp,
+ float yUp, float zUp) {
+ float len;
+ float xLook;
+ float yLook;
+ float zLook;
+ float xRight;
+ float yRight;
+ float zRight;
+
+ guMtxIdentF(mf);
+
+ xLook = xAt - xEye;
+ yLook = yAt - yEye;
+ zLook = zAt - zEye;
+
+ /* Negate because positive Z is behind us: */
+ len = -1.0 / guSqrtf(xLook * xLook + yLook * yLook + zLook * zLook);
+ xLook *= len;
+ yLook *= len;
+ zLook *= len;
+
+ /* Right = Up x Look */
+
+ xRight = yUp * zLook - zUp * yLook;
+ yRight = zUp * xLook - xUp * zLook;
+ zRight = xUp * yLook - yUp * xLook;
+ len = 1.0 / guSqrtf(xRight * xRight + yRight * yRight + zRight * zRight);
+ xRight *= len;
+ yRight *= len;
+ zRight *= len;
+
+ /* Up = Look x Right */
+
+ xUp = yLook * zRight - zLook * yRight;
+ yUp = zLook * xRight - xLook * zRight;
+ zUp = xLook * yRight - yLook * xRight;
+ len = 1.0 / guSqrtf(xUp * xUp + yUp * yUp + zUp * zUp);
+ xUp *= len;
+ yUp *= len;
+ zUp *= len;
+
+ mf[0][0] = xRight;
+ mf[1][0] = yRight;
+ mf[2][0] = zRight;
+ mf[3][0] = -(xEye * xRight + yEye * yRight + zEye * zRight);
+
+ mf[0][1] = xUp;
+ mf[1][1] = yUp;
+ mf[2][1] = zUp;
+ mf[3][1] = -(xEye * xUp + yEye * yUp + zEye * zUp);
+
+ mf[0][2] = xLook;
+ mf[1][2] = yLook;
+ mf[2][2] = zLook;
+ mf[3][2] = -(xEye * xLook + yEye * yLook + zEye * zLook);
+
+ mf[0][3] = 0;
+ mf[1][3] = 0;
+ mf[2][3] = 0;
+ mf[3][3] = 1;
+}
+
+void guLookAt(Mtx* m, float xEye, float yEye, float zEye, float xAt, float yAt, float zAt, float xUp, float yUp,
+ float zUp) {
+ float mf[4][4];
+
+ guLookAtF(mf, xEye, yEye, zEye, xAt, yAt, zAt, xUp, yUp, zUp);
+
+ guMtxF2L(mf, m);
+}