mirror of
https://github.com/izzy2lost/Starship.git
synced 2026-07-05 15:19:42 -07:00
The game is fucking running
This commit is contained in:
@@ -95,6 +95,7 @@ list(FILTER ALL_FILES EXCLUDE REGEX "src/main/fox_edata_1C.c")
|
||||
list(FILTER ALL_FILES EXCLUDE REGEX "src/main/fox_rcp_setup.c")
|
||||
list(FILTER ALL_FILES EXCLUDE REGEX "src/main/fox_load_inits.c")
|
||||
list(FILTER ALL_FILES EXCLUDE REGEX "src/overlays/ovl_ending/fox_end2_data.c")
|
||||
list(FILTER ALL_FILES EXCLUDE REGEX "src/main/sys_timer.c")
|
||||
|
||||
# list(FILTER ALL_FILES EXCLUDE REGEX "src/main/fox_hud.c")
|
||||
# list(FILTER ALL_FILES EXCLUDE REGEX "src/main/fox_360.c")
|
||||
|
||||
+2
-17
@@ -2,8 +2,9 @@
|
||||
#define LIBC_MATH_H
|
||||
|
||||
#include <libultra/types.h>
|
||||
#include <math.h>
|
||||
|
||||
#define M_PI 3.14159265358979323846f
|
||||
#define M_PI 3.14159265358979323846264338327950288
|
||||
#define M_DTOR (M_PI / 180.0f)
|
||||
#define M_RTOD (180.0f / M_PI)
|
||||
#define M_SQRT2 1.41421356237309504880f
|
||||
@@ -12,22 +13,6 @@
|
||||
#define SHT_MAX 32767.0f
|
||||
#define SHT_MINV (1.0f / SHT_MAX)
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
u32 hi;
|
||||
u32 lo;
|
||||
} word;
|
||||
|
||||
f64 d;
|
||||
} du;
|
||||
|
||||
typedef union {
|
||||
u32 i;
|
||||
f32 f;
|
||||
} fu;
|
||||
|
||||
extern f32 __libm_qnan_f;
|
||||
|
||||
#define __floorf floorf
|
||||
#define __floor floor
|
||||
#define __lfloorf lfloorf
|
||||
|
||||
+4
-4
@@ -21,7 +21,7 @@
|
||||
#define RAND_INT_SEEDED(max) ((s32)(Rand_ZeroOneSeeded()*(max)))
|
||||
#define RAND_FLOAT_CENTERED_SEEDED(width) ((Rand_ZeroOneSeeded()-0.5f)*(width))
|
||||
|
||||
#define SEGMENTED_TO_VIRTUAL(segment) ((void*)OS_PHYSICAL_TO_K0(gSegments[((uintptr_t)(segment)<<4)>>0x1C]+(((uintptr_t)(segment))&0xFFFFFF)))
|
||||
#define SEGMENTED_TO_VIRTUAL(segment) (segment)
|
||||
|
||||
#define ARRAY_COUNT(arr) (s32)(sizeof(arr) / sizeof(arr[0]))
|
||||
#define ARRAY_COUNTU(arr) (u32)(sizeof(arr) / sizeof(arr[0]))
|
||||
@@ -39,15 +39,15 @@
|
||||
#define RAD_TO_DEG(radians) (((radians) * 180.0f) / M_PI)
|
||||
#define DEG_TO_RAD(degrees) (((degrees) / 180.0f) * M_PI)
|
||||
|
||||
// TODO: Fix these
|
||||
#define SIN_DEG(angle) /*sinf*/(M_DTOR * angle)
|
||||
#define COS_DEG(angle) /*cosf*/(M_DTOR * angle)
|
||||
extern f32 SIN_DEG(f32 angle);
|
||||
extern f32 COS_DEG(f32 angle);
|
||||
|
||||
#define USEC_TO_CYCLES(n) (((u64)(n)*(OS_CLOCK_RATE/15625LL))/(1000000LL/15625LL))
|
||||
#define MSEC_TO_CYCLES(n) (USEC_TO_CYCLES((n) * 1000LL))
|
||||
|
||||
#define CYCLES_TO_USEC(c) (((u64)(c)*(1000000LL/15625LL))/(OS_CLOCK_RATE/15625LL))
|
||||
#define CYCLES_TO_MSEC(c) ((s32)CYCLES_TO_USEC(c)/1000)
|
||||
#define CYCLES_TO_MSEC_PC(c) (CYCLES_TO_USEC(c)/1000)
|
||||
|
||||
/*
|
||||
* Macros for libultra
|
||||
|
||||
+2
-2
@@ -49,9 +49,9 @@ extern Mtx gIdentityMtx; // 800C4620
|
||||
extern Matrix gIdentityMatrix; //800C4660
|
||||
|
||||
extern Matrix* gGfxMatrix;
|
||||
extern Matrix sGfxMatrixStack[0x20];
|
||||
extern Matrix sGfxMatrixStack[];
|
||||
extern Matrix* gCalcMatrix;
|
||||
extern Matrix sCalcMatrixStack[0x20];
|
||||
extern Matrix sCalcMatrixStack[];
|
||||
|
||||
f32 Math_ModF(f32 value, f32 mod);
|
||||
void Rand_Init(void);
|
||||
|
||||
@@ -28,7 +28,7 @@ typedef struct {
|
||||
/* 0x00 */ u8 active;
|
||||
/* 0x08 */ OSTimer timer;
|
||||
/* 0x28 */ TimerAction action;
|
||||
/* 0x2C */ s32* address;
|
||||
/* 0x2C */ uintptr_t address;
|
||||
/* 0x30 */ s32 value;
|
||||
} TimerTask; // size = 0x38, 0x8 aligned
|
||||
|
||||
|
||||
+1
-1
Submodule libultraship updated: 8cbc575218...f7c80fc8f7
@@ -1724,6 +1724,9 @@ void Audio_PlayActiveSfx(u8 bankId) {
|
||||
}
|
||||
|
||||
void Audio_KillSfxByBank(u8 bankId) {
|
||||
// LAudioTODO: Stub for now
|
||||
return;
|
||||
|
||||
SfxBankEntry* entry;
|
||||
u8 next = sSfxBanks[bankId][0].next;
|
||||
|
||||
@@ -1744,6 +1747,8 @@ void Audio_KillSfxByBank(u8 bankId) {
|
||||
}
|
||||
|
||||
void Audio_StopSfxByBankAndSource(u8 bankId, f32* sfxSource) {
|
||||
// LAudioTODO: Stub for now
|
||||
return;
|
||||
SfxBankEntry* entry;
|
||||
u8 curIndex = 0;
|
||||
u8 nextIndex = sSfxBanks[bankId][0].next;
|
||||
@@ -1765,6 +1770,8 @@ void Audio_StopSfxByBankAndSource(u8 bankId, f32* sfxSource) {
|
||||
}
|
||||
|
||||
void Audio_KillSfxByBankAndSource(u8 bankId, f32* sfxSource) {
|
||||
// LAudioTODO: Stub for now
|
||||
return;
|
||||
SfxBankEntry sp18;
|
||||
|
||||
Audio_StopSfxByBankAndSource(bankId, sfxSource);
|
||||
@@ -1774,6 +1781,8 @@ void Audio_KillSfxByBankAndSource(u8 bankId, f32* sfxSource) {
|
||||
}
|
||||
|
||||
void Audio_KillSfxBySource(f32* sfxSource) {
|
||||
// LAudioTODO: Stub for now
|
||||
return;
|
||||
u8 i;
|
||||
SfxBankEntry sp24;
|
||||
|
||||
@@ -1785,6 +1794,9 @@ void Audio_KillSfxBySource(f32* sfxSource) {
|
||||
}
|
||||
|
||||
void Audio_KillSfxBySourceAndId(f32* sfxSource, u32 sfxId) {
|
||||
// LAudioTODO: Stub for now
|
||||
return;
|
||||
|
||||
u32 bankId = SFX_BANK(sfxId);
|
||||
u8 next = sSfxBanks[bankId][0].next;
|
||||
u8 current = 0;
|
||||
@@ -1812,6 +1824,8 @@ void Audio_KillSfxBySourceAndId(f32* sfxSource, u32 sfxId) {
|
||||
}
|
||||
|
||||
void Audio_KillSfxByTokenAndId(u8 token, u32 sfxId) {
|
||||
// LAudioTODO: Stub for now
|
||||
return;
|
||||
u32 bankId = SFX_BANK(sfxId);
|
||||
u8 next = sSfxBanks[bankId][0].next;
|
||||
u8 current = 0;
|
||||
@@ -1838,6 +1852,8 @@ void Audio_KillSfxByTokenAndId(u8 token, u32 sfxId) {
|
||||
}
|
||||
|
||||
void Audio_KillSfxById(u32 sfxId) {
|
||||
// LAudioTODO: Stub for now
|
||||
return;
|
||||
u32 bankId = SFX_BANK(sfxId);
|
||||
u8 next = sSfxBanks[bankId][0].next;
|
||||
u8 current = 0;
|
||||
@@ -1991,6 +2007,8 @@ s32 Audio_GetCurrentVoice(void) {
|
||||
}
|
||||
|
||||
s32 Audio_GetCurrentVoiceStatus(void) {
|
||||
// LAudioTODO: Stub for now
|
||||
return 0;
|
||||
SequenceChannel* channel = gSeqPlayers[SEQ_PLAYER_VOICE].channels[15];
|
||||
SequenceLayer* layer = channel->layers[0];
|
||||
|
||||
|
||||
+21
-17
@@ -27,24 +27,28 @@ 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_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) {
|
||||
|
||||
sCurrentOverlay = *ovlInit;
|
||||
return true;
|
||||
|
||||
u8* ramPtr = SEGMENT_VRAM_START(ovl_i1);
|
||||
u8 segment;
|
||||
u8 changeOvl = false;
|
||||
@@ -174,13 +178,13 @@ u8 Overlay_Load(u8 ovlSetup, u8 ovlStage) {
|
||||
case OVL_SETUP_VERSUS:
|
||||
changeOvl = Overlay_Init(&sOvli2_Versus[ovlStage]);
|
||||
if (changeOvl == true) {
|
||||
Audio_SetAudioSpec(3, 0x310);
|
||||
// Audio_SetAudioSpec(3, 0x310);
|
||||
}
|
||||
break;
|
||||
case OVL_SETUP_LOGO:
|
||||
changeOvl = Overlay_Init(&sNoOvl_Logo[ovlStage]); // Logo does not load an overlay file
|
||||
if (changeOvl == true) {
|
||||
Audio_SetAudioSpec(0, 0xE);
|
||||
// Audio_SetAudioSpec(0, 0xE);
|
||||
}
|
||||
break;
|
||||
case OVL_SETUP_CREDITS:
|
||||
|
||||
@@ -53,6 +53,8 @@ s32 Save_Write(void) {
|
||||
}
|
||||
|
||||
s32 Save_Read(void) {
|
||||
|
||||
return 0;
|
||||
OSMesg* sp24;
|
||||
s32 i;
|
||||
|
||||
|
||||
+24
-28
@@ -13,54 +13,50 @@
|
||||
#include <libultraship.h>
|
||||
|
||||
void guMtxF2L(float mf[4][4], Mtx* m) {
|
||||
int i, j;
|
||||
int e1, e2;
|
||||
int *ai, *af;
|
||||
|
||||
ai = (int*) &m->m[0][0];
|
||||
af = (int*) &m->m[2][0];
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
for (j = 0; j < 2; j++) {
|
||||
e1 = FTOFIX32(mf[i][j * 2]);
|
||||
e2 = FTOFIX32(mf[i][j * 2 + 1]);
|
||||
*(ai++) = (e1 & 0xffff0000) | ((e2 >> 16) & 0xffff);
|
||||
*(af++) = ((e1 << 16) & 0xffff0000) | (e2 & 0xffff);
|
||||
unsigned int r, c;
|
||||
s32 tmp1;
|
||||
s32 tmp2;
|
||||
s32* m1 = &m->m[0][0];
|
||||
s32* m2 = &m->m[2][0];
|
||||
for (r = 0; r < 4; r++) {
|
||||
for (c = 0; c < 2; c++) {
|
||||
tmp1 = mf[r][2 * c] * 65536.0f;
|
||||
tmp2 = mf[r][2 * c + 1] * 65536.0f;
|
||||
*m1++ = (tmp1 & 0xffff0000) | ((tmp2 >> 0x10) & 0xffff);
|
||||
*m2++ = ((tmp1 << 0x10) & 0xffff0000) | (tmp2 & 0xffff);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This function seems to use the SM64 version of the guMtxF2L function
|
||||
void guMtxL2F(float mf[4][4], Mtx* m) {
|
||||
int r, c;
|
||||
unsigned int r, c;
|
||||
u32 tmp1;
|
||||
u32 tmp2;
|
||||
u32* m1;
|
||||
u32* m2;
|
||||
s32 stmp1, stmp2;
|
||||
m1 = (u32*) &m->m[0][0];
|
||||
m2 = (u32*) &m->m[2][0];
|
||||
m1 = (u32*)&m->m[0][0];
|
||||
m2 = (u32*)&m->m[2][0];
|
||||
for (r = 0; r < 4; r++) {
|
||||
for (c = 0; c < 2; c++) {
|
||||
tmp1 = (*m1 & 0xffff0000) | ((*m2 >> 0x10) & 0xffff);
|
||||
tmp2 = ((*m1++ << 0x10) & 0xffff0000) | (*m2++ & 0xffff);
|
||||
stmp1 = *(s32*) &tmp1;
|
||||
stmp2 = *(s32*) &tmp2;
|
||||
stmp1 = *(s32*)&tmp1;
|
||||
stmp2 = *(s32*)&tmp2;
|
||||
mf[r][c * 2 + 0] = stmp1 / 65536.0f;
|
||||
mf[r][c * 2 + 1] = stmp2 / 65536.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void guMtxIdentF(float mf[4][4]) {
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
for (j = 0; j < 4; j++) {
|
||||
if (i == j) {
|
||||
mf[i][j] = 1.0;
|
||||
void guMtxIdentF(f32 mf[4][4]) {
|
||||
unsigned int r, c;
|
||||
for (r = 0; r < 4; r++) {
|
||||
for (c = 0; c < 4; c++) {
|
||||
if (r == c) {
|
||||
mf[r][c] = 1.0f;
|
||||
} else {
|
||||
mf[i][j] = 0.0;
|
||||
mf[r][c] = 0.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -72,4 +68,4 @@ void guMtxIdent(Mtx* m) {
|
||||
guMtxIdentF(mf);
|
||||
|
||||
guMtxF2L(mf, m);
|
||||
}
|
||||
}
|
||||
+71
-1
@@ -11,9 +11,12 @@
|
||||
|
||||
extern "C" {
|
||||
float gInterpolationStep = 0.0f;
|
||||
#include <sf64thread.h>
|
||||
#include <macros.h>
|
||||
}
|
||||
|
||||
GameEngine* GameEngine::Instance;
|
||||
// TimerTask sTimerTasks[0x10];
|
||||
|
||||
GameEngine::GameEngine() {
|
||||
std::vector<std::string> OTRFiles;
|
||||
@@ -116,4 +119,71 @@ extern "C" uint32_t GameEngine_GetGameVersion() {
|
||||
extern "C" int GameEngine_OTRSigCheck(const char* data) {
|
||||
static const char* sOtrSignature = "__OTR__";
|
||||
return strncmp(data, sOtrSignature, strlen(sOtrSignature)) == 0;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" float SIN_DEG(float angle) {
|
||||
return sinf(M_DTOR * angle);
|
||||
}
|
||||
extern "C" float COS_DEG(float angle) {
|
||||
return cosf(M_DTOR * angle);
|
||||
}
|
||||
|
||||
struct TimedEntry {
|
||||
uint64_t duration;
|
||||
TimerAction action;
|
||||
int32_t* address;
|
||||
int32_t value;
|
||||
bool active;
|
||||
};
|
||||
|
||||
std::vector<TimedEntry> gTimerTasks;
|
||||
|
||||
|
||||
uint64_t Timer_GetCurrentMillis() {
|
||||
return SDL_GetTicks();
|
||||
}
|
||||
|
||||
extern "C" int32_t Timer_CreateTask(uint64_t time, TimerAction action, int32_t* address, int32_t value) {
|
||||
const auto millis = Timer_GetCurrentMillis();
|
||||
TimedEntry entry = {
|
||||
.duration = millis + CYCLES_TO_MSEC_PC(time),
|
||||
.action = action,
|
||||
.address = address,
|
||||
.value = value,
|
||||
.active = true,
|
||||
};
|
||||
|
||||
gTimerTasks.push_back(entry);
|
||||
|
||||
return gTimerTasks.size() - 1;
|
||||
}
|
||||
|
||||
extern "C" void Timer_Increment(int32_t* address, int32_t value) {
|
||||
*address += value;
|
||||
}
|
||||
|
||||
extern "C" void Timer_SetValue(int32_t* address, int32_t value) {
|
||||
*address = value;
|
||||
}
|
||||
|
||||
void Timer_CompleteTask(TimedEntry& task) {
|
||||
if (task.action != nullptr) {
|
||||
task.action(task.address, task.value);
|
||||
}
|
||||
task.active = false;
|
||||
}
|
||||
|
||||
extern "C" void Timer_Update() {
|
||||
|
||||
if(gTimerTasks.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto millis = Timer_GetCurrentMillis();
|
||||
|
||||
for (auto& task : gTimerTasks) {
|
||||
if (task.active && millis >= task.duration) {
|
||||
Timer_CompleteTask(task);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ class GameEngine {
|
||||
static void RunCommands(Gfx* Commands);
|
||||
void ProcessFrame(void (*run_one_game_iter)()) const;
|
||||
static void Destroy();
|
||||
void ProcessGfxCommands(Gfx* commands);
|
||||
static void ProcessGfxCommands(Gfx* commands);
|
||||
};
|
||||
#else
|
||||
void GameEngine_ProcessGfxCommands(Gfx* commands);
|
||||
|
||||
+19
-7
@@ -3,14 +3,26 @@
|
||||
#include <Fast3D/gfx_pc.h>
|
||||
#include "Engine.h"
|
||||
|
||||
extern "C" {
|
||||
void Main_SetVIMode(void);
|
||||
void Main_Initialize(void);
|
||||
void Main_ThreadEntry(void* arg);
|
||||
void Lib_FillScreen(u8 setFill);
|
||||
void Graphics_ThreadUpdate();
|
||||
}
|
||||
|
||||
extern "C"
|
||||
// void exec_display_list(SPTask *spTask) {
|
||||
// GameEngine::ProcessGfxCommands((Gfx *) spTask->task.t.data_ptr);
|
||||
// }
|
||||
void Graphics_PushFrame(Gfx* data) {
|
||||
GameEngine::ProcessGfxCommands(data);
|
||||
}
|
||||
|
||||
extern "C" void Timer_Update();
|
||||
|
||||
void push_frame() {
|
||||
// GameEngine::StartAudioFrame();
|
||||
GameEngine::Instance->StartFrame();
|
||||
Graphics_ThreadUpdate();
|
||||
Timer_Update();
|
||||
// thread5_iteration();
|
||||
// GameEngine::EndAudioFrame();
|
||||
}
|
||||
@@ -21,10 +33,10 @@ int SDL_main(int argc, char **argv) {
|
||||
int main(){
|
||||
#endif
|
||||
GameEngine::Create();
|
||||
// alloc_pool();
|
||||
// audio_init();
|
||||
// sound_init();
|
||||
// thread5_game_loop();
|
||||
Main_SetVIMode();
|
||||
Lib_FillScreen(1);
|
||||
Main_Initialize();
|
||||
Main_ThreadEntry(NULL);
|
||||
GameEngine::Instance->ProcessFrame(push_frame);
|
||||
GameEngine::Instance->Destroy();
|
||||
return 0;
|
||||
|
||||
+92
-72
@@ -224,10 +224,12 @@ void Timer_ThreadEntry(void* arg0) {
|
||||
|
||||
while (1) {
|
||||
osRecvMesg(&gTimerTaskMsgQueue, &sp24, OS_MESG_BLOCK);
|
||||
Timer_CompleteTask(sp24.ptr);
|
||||
// Timer_CompleteTask(sp24.ptr);
|
||||
}
|
||||
}
|
||||
|
||||
extern void Graphics_PushFrame(Gfx* masterDL);
|
||||
|
||||
void Graphics_ThreadEntry(void* arg0) {
|
||||
u8 i;
|
||||
u8 var_v1;
|
||||
@@ -247,44 +249,66 @@ void Graphics_ThreadEntry(void* arg0) {
|
||||
gSPEndDisplayList(gMasterDisp++);
|
||||
}
|
||||
Graphics_SetTask();
|
||||
while (1) {
|
||||
gSysFrameCount++;
|
||||
Graphics_InitializeTask(gSysFrameCount);
|
||||
osRecvMesg(&gControllerMsgQueue, NULL, OS_MESG_BLOCK);
|
||||
osSendMesg(&gSerialThreadMsgQueue, OS_MESG_32(SI_RUMBLE), OS_MESG_PRI_NORMAL);
|
||||
Controller_UpdateInput();
|
||||
osSendMesg(&gSerialThreadMsgQueue, OS_MESG_32(SI_READ_CONTROLLER), OS_MESG_PRI_NORMAL);
|
||||
if (gControllerPress[3].button & U_JPAD) {
|
||||
Main_SetVIMode();
|
||||
}
|
||||
{
|
||||
gSPSegment(gUnkDisp1++, 0, 0);
|
||||
gSPDisplayList(gMasterDisp++, gGfxPool->unkDL1);
|
||||
Game_Update();
|
||||
if (gStartNMI == 1) {
|
||||
Graphics_NMIWipe();
|
||||
}
|
||||
gSPEndDisplayList(gUnkDisp1++);
|
||||
gSPEndDisplayList(gUnkDisp2++);
|
||||
gSPDisplayList(gMasterDisp++, gGfxPool->unkDL2);
|
||||
gDPFullSync(gMasterDisp++);
|
||||
gSPEndDisplayList(gMasterDisp++);
|
||||
}
|
||||
osRecvMesg(&gGfxTaskMsgQueue, NULL, OS_MESG_BLOCK);
|
||||
Graphics_SetTask();
|
||||
if (gFillScreen == 0) {
|
||||
osViSwapBuffer(&gFrameBuffers[(gSysFrameCount - 1) % 3]);
|
||||
}
|
||||
// func_80007FE4(&gFrameBuffers[(gSysFrameCount - 1) % 3], SCREEN_WIDTH, 16);
|
||||
// while (1) {
|
||||
|
||||
var_v1 = MIN(D_80137E78, 4);
|
||||
var_v2 = MAX(var_v1, gGfxVImsgQueue.validCount + 1);
|
||||
for (i = 0; i < var_v2; i += 1) { // Can't be ++
|
||||
osRecvMesg(&gGfxVImsgQueue, NULL, OS_MESG_BLOCK);
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
Audio_Update();
|
||||
void Graphics_ThreadUpdate(){
|
||||
|
||||
if (GfxDebuggerIsDebugging()) {
|
||||
Graphics_PushFrame(gGfxPool->masterDL);
|
||||
return;
|
||||
}
|
||||
|
||||
gSysFrameCount++;
|
||||
Graphics_InitializeTask(gSysFrameCount);
|
||||
osRecvMesg(&gControllerMsgQueue, NULL, OS_MESG_BLOCK);
|
||||
osSendMesg(&gSerialThreadMsgQueue, OS_MESG_32(SI_RUMBLE), OS_MESG_PRI_NORMAL);
|
||||
Controller_UpdateInput();
|
||||
osSendMesg(&gSerialThreadMsgQueue, OS_MESG_32(SI_READ_CONTROLLER), OS_MESG_PRI_NORMAL);
|
||||
if (gControllerPress[3].button & U_JPAD) {
|
||||
Main_SetVIMode();
|
||||
}
|
||||
{
|
||||
gSPSegment(gUnkDisp1++, 0, 0);
|
||||
gSPDisplayList(gMasterDisp++, gGfxPool->unkDL1);
|
||||
Game_Update();
|
||||
if (gStartNMI == 1) {
|
||||
Graphics_NMIWipe();
|
||||
}
|
||||
gSPEndDisplayList(gUnkDisp1++);
|
||||
gSPEndDisplayList(gUnkDisp2++);
|
||||
gSPDisplayList(gMasterDisp++, gGfxPool->unkDL2);
|
||||
gDPFullSync(gMasterDisp++);
|
||||
gSPEndDisplayList(gMasterDisp++);
|
||||
}
|
||||
osRecvMesg(&gGfxTaskMsgQueue, NULL, OS_MESG_BLOCK);
|
||||
Graphics_SetTask();
|
||||
|
||||
if(GfxDebuggerIsDebuggingRequested()) {
|
||||
GfxDebuggerDebugDisplayList(gGfxPool->masterDL);
|
||||
}
|
||||
|
||||
Graphics_PushFrame(gGfxPool->masterDL);
|
||||
|
||||
if (gFillScreen == 0) {
|
||||
osViSwapBuffer(&gFrameBuffers[(gSysFrameCount - 1) % 3]);
|
||||
}
|
||||
|
||||
Controller_ReadData();
|
||||
// LTODO: FAULT_CRASH
|
||||
// func_80007FE4(&gFrameBuffers[(gSysFrameCount - 1) % 3], SCREEN_WIDTH, 16);
|
||||
|
||||
// LTODO: Figure out what this is
|
||||
// var_v1 = MIN(D_80137E78, 4);
|
||||
// var_v2 = MAX(var_v1, gGfxVImsgQueue.validCount + 1);
|
||||
// for (i = 0; i < var_v2; i += 1) { // Can't be ++
|
||||
// osRecvMesg(&gGfxVImsgQueue, NULL, OS_MESG_BLOCK);
|
||||
// }
|
||||
|
||||
// LTODO: There is no audio for now :P
|
||||
// Audio_Update();
|
||||
}
|
||||
|
||||
void Main_InitMesgQueues(void) {
|
||||
@@ -424,45 +448,41 @@ void Main_ThreadEntry(void* arg0) {
|
||||
OSMesg ogMsg;
|
||||
u32 mesg;
|
||||
|
||||
// osCreateThread(&gAudioThread, THREAD_ID_AUDIO, Audio_ThreadEntry, arg0,
|
||||
// gAudioThreadStack + sizeof(gAudioThreadStack), 80);
|
||||
// osStartThread(&gAudioThread);
|
||||
// osCreateThread(&gGraphicsThread, THREAD_ID_GRAPHICS, Graphics_ThreadEntry, arg0,
|
||||
// gGraphicsThreadStack + sizeof(gGraphicsThreadStack), 40);
|
||||
// osStartThread(&gGraphicsThread);
|
||||
// osCreateThread(&gTimerThread, THREAD_ID_TIMER, Timer_ThreadEntry, arg0,
|
||||
// gTimerThreadStack + sizeof(gTimerThreadStack), 60);
|
||||
// osStartThread(&gTimerThread);
|
||||
// osCreateThread(&gSerialThread, THREAD_ID_SERIAL, SerialInterface_ThreadEntry, arg0,
|
||||
// gSerialThreadStack + sizeof(gSerialThreadStack), 20);
|
||||
// osStartThread(&gSerialThread);
|
||||
// LTODO: Implement audio
|
||||
// Audio_ThreadEntry(NULL);
|
||||
Graphics_ThreadEntry(NULL);
|
||||
Controller_Init();
|
||||
|
||||
Main_InitMesgQueues();
|
||||
// LTODO: Implement timers
|
||||
// Timer_ThreadEntry(NULL);
|
||||
|
||||
while (true) {
|
||||
osRecvMesg(&gMainThreadMsgQueue, &ogMsg, OS_MESG_BLOCK);
|
||||
mesg = ogMsg.data32;
|
||||
|
||||
switch (mesg) {
|
||||
case EVENT_MESG_VI:
|
||||
osSendMesg(&gAudioVImsgQueue, OS_MESG_32(EVENT_MESG_VI), OS_MESG_PRI_NORMAL);
|
||||
osSendMesg(&gGfxVImsgQueue, OS_MESG_32(EVENT_MESG_VI), OS_MESG_PRI_NORMAL);
|
||||
Main_GetNewTasks();
|
||||
break;
|
||||
case EVENT_MESG_SP:
|
||||
Main_HandleRSP();
|
||||
break;
|
||||
case EVENT_MESG_DP:
|
||||
Main_HandleRDP();
|
||||
break;
|
||||
case EVENT_MESG_PRENMI:
|
||||
gStartNMI = 1;
|
||||
break;
|
||||
}
|
||||
if (gStopTasks == 0) {
|
||||
Main_StartNextTask();
|
||||
}
|
||||
}
|
||||
// N64 Stuff should not be needed
|
||||
// Main_InitMesgQueues();
|
||||
// while (true) {
|
||||
// osRecvMesg(&gMainThreadMsgQueue, &ogMsg, OS_MESG_BLOCK);
|
||||
// mesg = ogMsg.data32;
|
||||
|
||||
// switch (mesg) {
|
||||
// case EVENT_MESG_VI:
|
||||
// osSendMesg(&gAudioVImsgQueue, OS_MESG_32(EVENT_MESG_VI), OS_MESG_PRI_NORMAL);
|
||||
// osSendMesg(&gGfxVImsgQueue, OS_MESG_32(EVENT_MESG_VI), OS_MESG_PRI_NORMAL);
|
||||
// Main_GetNewTasks();
|
||||
// break;
|
||||
// case EVENT_MESG_SP:
|
||||
// Main_HandleRSP();
|
||||
// break;
|
||||
// case EVENT_MESG_DP:
|
||||
// Main_HandleRDP();
|
||||
// break;
|
||||
// case EVENT_MESG_PRENMI:
|
||||
// gStartNMI = 1;
|
||||
// break;
|
||||
// }
|
||||
// if (gStopTasks == 0) {
|
||||
// Main_StartNextTask();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
void Idle_ThreadEntry(void* arg0) {
|
||||
|
||||
+506
-313
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -19,7 +19,7 @@ s32 Save_WriteBlock(s32 arg0, u8* arg1) {
|
||||
(void) "EEPROM インターフェース回路反応なし (WRITE)\n";
|
||||
return -1;
|
||||
}
|
||||
Timer_Wait(MSEC_TO_CYCLES(15));
|
||||
// Timer_Wait(MSEC_TO_CYCLES(15));
|
||||
(void) "EEPROM WRITE %02X: %02X %02X %02X %02X %02X %02X %02X %02X\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
+2
-8
@@ -13,7 +13,7 @@ TimerTask* Timer_AllocateTask(void) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
s32 Timer_CreateTask(u64 time, TimerAction action, s32* address, s32 value) {
|
||||
int32_t Timer_CreateTask(uint64_t time, TimerAction action, s32* address, s32 value) {
|
||||
TimerTask* task = Timer_AllocateTask();
|
||||
|
||||
if (task == NULL) {
|
||||
@@ -41,10 +41,4 @@ void Timer_CompleteTask(TimerTask* task) {
|
||||
task->active = false;
|
||||
}
|
||||
|
||||
void Timer_Wait(u64 time) {
|
||||
OSTimer timer;
|
||||
OSMesg dummy;
|
||||
|
||||
osSetTimer(&timer, time, 0, &gTimerWaitMsgQueue, OS_MESG_PTR(NULL));
|
||||
osRecvMesg(&gTimerWaitMsgQueue, &dummy, OS_MESG_BLOCK);
|
||||
}
|
||||
void
|
||||
+1
-1
Submodule tools/Torch updated: ad667b705d...4d654e65a9
Reference in New Issue
Block a user