Add more stubs

This commit is contained in:
dbalatoni13 2025-04-02 18:45:58 +02:00
parent 670a2c4c62
commit 69ff202bae
6 changed files with 220 additions and 137 deletions

View file

@ -21,6 +21,7 @@ set(DOLPHIN_FILES
) )
set(GAME_FILES set(GAME_FILES
src/game/card.c
src/game/fault.c src/game/fault.c
src/game/frand.c src/game/frand.c
src/game/main.c src/game/main.c

View file

@ -2,8 +2,13 @@
#define _GAME_PROCESS_H #define _GAME_PROCESS_H
#include "dolphin/types.h" #include "dolphin/types.h"
#include "game/jmp.h"
#ifdef TARGET_PC
#include <setjmp.h>
typedef int JMPBUF;
#else
#include "game/jmp.h"
#endif
#define PROCESS_STAT_PAUSE 0x1 #define PROCESS_STAT_PAUSE 0x1
#define PROCESS_STAT_UPAUSE 0x2 #define PROCESS_STAT_UPAUSE 0x2

View file

@ -79,12 +79,12 @@ void HuSysInit(GXRenderModeObj *mode)
HuDvdErrDispInit(RenderMode, DemoFrameBuffer1, DemoFrameBuffer2); HuDvdErrDispInit(RenderMode, DemoFrameBuffer1, DemoFrameBuffer2);
rnd_temp = frand(); rnd_temp = frand();
HuMemInitAll(); HuMemInitAll();
// HuAudInit(); HuAudInit();
//HuARInit(); HuARInit();
// minimumVcount = minimumVcountf = 1.0f; minimumVcount = minimumVcountf = 1.0f;
// worstVcount = 0; worstVcount = 0;
// OSInitFastCast(); OSInitFastCast();
// HuCardInit(); HuCardInit();
} }
static void InitRenderMode(GXRenderModeObj *mode) static void InitRenderMode(GXRenderModeObj *mode)
@ -199,44 +199,44 @@ void HuSysBeforeRender()
void HuSysDoneRender(s32 retrace_count) void HuSysDoneRender(s32 retrace_count)
{ {
// s32 retrace_dist; s32 retrace_dist;
// if(DemoStatEnable) { if(DemoStatEnable) {
// GXDrawDone(); GXDrawDone();
// DEMOUpdateStats(1); DEMOUpdateStats(1);
// DEMOPrintStats(); DEMOPrintStats();
// GXDrawDone(); GXDrawDone();
// DEMOUpdateStats(0); DEMOUpdateStats(0);
// } }
// GXSetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE); GXSetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE);
// GXSetColorUpdate(GX_TRUE); GXSetColorUpdate(GX_TRUE);
// GXDrawDone(); GXDrawDone();
// GXCopyDisp(DemoCurrentBuffer, GX_TRUE); GXCopyDisp(DemoCurrentBuffer, GX_TRUE);
// if(minimumVcount != 0) { if(minimumVcount != 0) {
// retrace_dist = VIGetRetraceCount()-retrace_count; retrace_dist = VIGetRetraceCount()-retrace_count;
// if(worstVcount < retrace_dist) { if(worstVcount < retrace_dist) {
// worstVcount = retrace_dist; worstVcount = retrace_dist;
// } }
// while(VIGetRetraceCount()-retrace_count < minimumVcount-1) { while(VIGetRetraceCount()-retrace_count < minimumVcount-1) {
// VIWaitForRetrace(); VIWaitForRetrace();
// } }
// } }
// SwapBuffers(); SwapBuffers();
} }
static void SwapBuffers() static void SwapBuffers()
{ {
// VISetNextFrameBuffer(DemoCurrentBuffer); VISetNextFrameBuffer(DemoCurrentBuffer);
// if(FirstFrame) { if(FirstFrame) {
// VISetBlack(GX_FALSE); VISetBlack(GX_FALSE);
// FirstFrame = FALSE; FirstFrame = FALSE;
// } }
// VIFlush(); VIFlush();
// VIWaitForRetrace(); VIWaitForRetrace();
// if(DemoCurrentBuffer == DemoFrameBuffer1) { if(DemoCurrentBuffer == DemoFrameBuffer1) {
// DemoCurrentBuffer = DemoFrameBuffer2; DemoCurrentBuffer = DemoFrameBuffer2;
// } else { } else {
// DemoCurrentBuffer = DemoFrameBuffer1; DemoCurrentBuffer = DemoFrameBuffer1;
// } }
} }
static void LoadMemInfo() static void LoadMemInfo()

View file

@ -1,20 +1,20 @@
#include "game/gamework_data.h"
#include "game/dvd.h"
#include "game/printfunc.h"
#include "game/object.h"
#include "game/wipe.h"
#include "game/init.h"
#include "game/process.h"
#include "game/pad.h"
#include "game/data.h" #include "game/data.h"
#include "game/sprite.h" #include "game/dvd.h"
#include "game/gamework.h"
#include "game/gamework_data.h"
#include "game/hsfformat.h" #include "game/hsfformat.h"
#include "game/hsfman.h" #include "game/hsfman.h"
#include "game/init.h"
#include "game/minigame_seq.h" #include "game/minigame_seq.h"
#include "game/msm.h" #include "game/msm.h"
#include "game/object.h"
#include "game/pad.h"
#include "game/perf.h" #include "game/perf.h"
#include "game/gamework.h" #include "game/printfunc.h"
#include "game/process.h"
#include "game/sprite.h"
#include "game/sreset.h" #include "game/sreset.h"
#include "game/wipe.h"
#ifdef TARGET_PC #ifdef TARGET_PC
#include "port/imgui.h" #include "port/imgui.h"
@ -53,8 +53,7 @@ void aurora_log_callback(AuroraLogLevel level, const char *message, unsigned int
{ {
const char *levelStr = "??"; const char *levelStr = "??";
FILE *out = stdout; FILE *out = stdout;
switch (level) switch (level) {
{
case LOG_DEBUG: case LOG_DEBUG:
levelStr = "DEBUG"; levelStr = "DEBUG";
break; break;
@ -74,8 +73,7 @@ void aurora_log_callback(AuroraLogLevel level, const char *message, unsigned int
break; break;
} }
fprintf(out, "[%s: %s]\n", levelStr, message); fprintf(out, "[%s: %s]\n", levelStr, message);
if (level == LOG_FATAL) if (level == LOG_FATAL) {
{
fflush(out); fflush(out);
abort(); abort();
} }
@ -83,14 +81,14 @@ void aurora_log_callback(AuroraLogLevel level, const char *message, unsigned int
#endif #endif
#ifdef TARGET_PC #ifdef TARGET_PC
int main(int argc, char* argv[]) int main(int argc, char *argv[])
#else #else
void main(void) void main(void)
#endif #endif
{ {
#ifdef TARGET_PC #ifdef TARGET_PC
const AuroraInfo auroraInfo = aurora_initialize(argc, argv, const AuroraInfo auroraInfo = aurora_initialize(argc, argv,
&(AuroraConfig){ &(AuroraConfig) {
.appName = "Mario Party 4", .appName = "Mario Party 4",
.logCallback = &aurora_log_callback, .logCallback = &aurora_log_callback,
}); });
@ -99,56 +97,53 @@ void main(void)
u32 met1; u32 met1;
s16 i; s16 i;
s32 retrace; s32 retrace;
#if VERSION_PAL #if VERSION_PAL
s16 temp = 0; s16 temp = 0;
#endif #endif
HuDvdErrWait = 0; HuDvdErrWait = 0;
SystemInitF = 0; SystemInitF = 0;
#if VERSION_NTSC #if VERSION_NTSC
HuSysInit(&GXNtsc480IntDf); HuSysInit(&GXNtsc480IntDf);
#else #else
HuSysInit(&GXPal528IntDf); HuSysInit(&GXPal528IntDf);
#endif #endif
/*HuPrcInit(); //HuPrcInit();
HuPadInit(); // HuPadInit();
GWInit(); // GWInit();
pfInit(); // pfInit();
GlobalCounter = 0; // GlobalCounter = 0;
HuSprInit(); // HuSprInit();
Hu3DInit(); // Hu3DInit();
HuDataInit(); // HuDataInit();
HuPerfInit(); // HuPerfInit();
HuPerfCreate("USR0", 0xFF, 0xFF, 0xFF, 0xFF); // HuPerfCreate("USR0", 0xFF, 0xFF, 0xFF, 0xFF);
HuPerfCreate("USR1", 0, 0xFF, 0xFF, 0xFF); // HuPerfCreate("USR1", 0, 0xFF, 0xFF, 0xFF);
WipeInit(RenderMode); // WipeInit(RenderMode);
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
GWPlayerCfg[i].character = -1; // GWPlayerCfg[i].character = -1;
} }
omMasterInit(0, _ovltbl, OVL_COUNT, OVL_BOOT); //omMasterInit(0, _ovltbl, OVL_COUNT, OVL_BOOT);
VIWaitForRetrace(); VIWaitForRetrace();
if (VIGetNextField() == 0) { if (VIGetNextField() == 0) {
OSReport("VI_FIELD_BELOW\n"); OSReport("VI_FIELD_BELOW\n");
VIWaitForRetrace(); VIWaitForRetrace();
}*/ }
while (1) { while (1) {
#ifdef TARGET_PC #ifdef TARGET_PC
const AuroraEvent *event = aurora_update(); const AuroraEvent *event = aurora_update();
bool exiting = false; bool exiting = false;
while (event != NULL && event->type != AURORA_NONE) while (event != NULL && event->type != AURORA_NONE) {
{ if (event->type == AURORA_EXIT) {
if (event->type == AURORA_EXIT)
{
exiting = true; exiting = true;
break; break;
} }
++event; ++event;
} }
if (exiting) if (exiting) {
{
break; break;
} }
#endif #endif
@ -156,9 +151,9 @@ void main(void)
if (HuSoftResetButtonCheck() != 0 || HuDvdErrWait != 0) { if (HuSoftResetButtonCheck() != 0 || HuDvdErrWait != 0) {
continue; continue;
}*/ }*/
//HuPerfZero(); // HuPerfZero();
//HuPerfBegin(2); // HuPerfBegin(2);
#ifdef TARGET_PC #ifdef TARGET_PC
aurora_begin_frame(); aurora_begin_frame();
#endif #endif
@ -210,16 +205,16 @@ void main(void)
#endif #endif
} }
//void HuSysVWaitSet(s16 vcount) // void HuSysVWaitSet(s16 vcount)
//{ //{
// minimumVcount = vcount; // minimumVcount = vcount;
// minimumVcountf = vcount; // minimumVcountf = vcount;
//} // }
// //
//s16 HuSysVWaitGet(s16 param) // s16 HuSysVWaitGet(s16 param)
//{ //{
// return (s16) minimumVcount; // return (s16) minimumVcount;
//} // }
s32 rnd_seed = 0x0000D9ED; s32 rnd_seed = 0x0000D9ED;

View file

@ -1,10 +1,14 @@
#include "game/process.h" #include "game/process.h"
#include "dolphin/os.h" #include "dolphin/os.h"
#include "game/jmp.h"
#include "game/memory.h" #include "game/memory.h"
#define FAKE_RETADDR 0xA5A5A5A5 #define FAKE_RETADDR 0xA5A5A5A5
#ifdef TARGET_PC
#include <stdio.h>
#endif
#define EXEC_NORMAL 0 #define EXEC_NORMAL 0
#define EXEC_SLEEP 1 #define EXEC_SLEEP 1
#define EXEC_CHILDWATCH 2 #define EXEC_CHILDWATCH 2
@ -81,9 +85,12 @@ Process *HuPrcCreate(void (*func)(void), u16 prio, u32 stack_size, s32 extra_siz
process->prio = prio; process->prio = prio;
process->sleep_time = 0; process->sleep_time = 0;
process->base_sp = ((u32)HuMemMemoryAlloc(heap, stack_size, FAKE_RETADDR)) + stack_size - 8; process->base_sp = ((u32)HuMemMemoryAlloc(heap, stack_size, FAKE_RETADDR)) + stack_size - 8;
#ifdef TARGET_PC
#else
gcsetjmp(&process->jump); gcsetjmp(&process->jump);
process->jump.lr = (u32)func; process->jump.lr = (u32)func;
process->jump.sp = process->base_sp; process->jump.sp = process->base_sp;
#endif
process->dtor = NULL; process->dtor = NULL;
process->user_data = NULL; process->user_data = NULL;
LinkProcess(&processtop, process); LinkProcess(&processtop, process);
@ -133,9 +140,12 @@ void HuPrcChildWatch()
Process *curr = HuPrcCurrentGet(); Process *curr = HuPrcCurrentGet();
if (curr->child) { if (curr->child) {
curr->exec = EXEC_CHILDWATCH; curr->exec = EXEC_CHILDWATCH;
#ifdef TARGET_PC
#else
if (!gcsetjmp(&curr->jump)) { if (!gcsetjmp(&curr->jump)) {
gclongjmp(&processjmpbuf, 1); gclongjmp(&processjmpbuf, 1);
} }
#endif
} }
} }
@ -186,7 +196,10 @@ static void gcTerminateProcess(Process *process)
} }
UnlinkProcess(&processtop, process); UnlinkProcess(&processtop, process);
processcnt--; processcnt--;
#ifdef TARGET_PC
#else
gclongjmp(&processjmpbuf, 2); gclongjmp(&processjmpbuf, 2);
#endif
} }
void HuPrcEnd() void HuPrcEnd()
@ -204,9 +217,12 @@ void HuPrcSleep(s32 time)
process->exec = EXEC_SLEEP; process->exec = EXEC_SLEEP;
process->sleep_time = time; process->sleep_time = time;
} }
#ifdef TARGET_PC
#else
if (!gcsetjmp(&process->jump)) { if (!gcsetjmp(&process->jump)) {
gclongjmp(&processjmpbuf, 1); gclongjmp(&processjmpbuf, 1);
} }
#endif
} }
void HuPrcVSleep() void HuPrcVSleep()
@ -235,7 +251,10 @@ void HuPrcCall(s32 tick)
Process *process; Process *process;
s32 ret; s32 ret;
processcur = processtop; processcur = processtop;
#ifdef TARGET_PC
#else
ret = gcsetjmp(&processjmpbuf); ret = gcsetjmp(&processjmpbuf);
#endif
while (1) { while (1) {
switch (ret) { switch (ret) {
case 2: case 2:
@ -255,7 +274,10 @@ void HuPrcCall(s32 tick)
if (!process) { if (!process) {
return; return;
} }
#ifdef TARGET_PC
#else
procfunc = process->jump.lr; procfunc = process->jump.lr;
#endif
if ((process->stat & (PROCESS_STAT_PAUSE | PROCESS_STAT_UPAUSE)) && process->exec != EXEC_KILLED) { if ((process->stat & (PROCESS_STAT_PAUSE | PROCESS_STAT_UPAUSE)) && process->exec != EXEC_KILLED) {
ret = 1; ret = 1;
continue; continue;
@ -283,9 +305,15 @@ void HuPrcCall(s32 tick)
break; break;
case EXEC_KILLED: case EXEC_KILLED:
#ifdef TARGET_PC
#else
process->jump.lr = (u32)HuPrcEnd; process->jump.lr = (u32)HuPrcEnd;
#endif
case EXEC_NORMAL: case EXEC_NORMAL:
#ifdef TARGET_PC
#else
gclongjmp(&process->jump, 1); gclongjmp(&process->jump, 1);
#endif
break; break;
} }
} }

View file

@ -24,6 +24,12 @@ s32 CARDCancel(CARDFileInfo *fileInfo)
return 0; return 0;
} }
s32 CARDCheck(s32 chan)
{
puts("CARDCheck is a stub");
return 0;
}
s32 CARDCheckAsync(s32 chan, CARDCallback callback) s32 CARDCheckAsync(s32 chan, CARDCallback callback)
{ {
puts("CARDCheckAsync is a stub"); puts("CARDCheckAsync is a stub");
@ -36,6 +42,12 @@ s32 CARDClose(CARDFileInfo *fileInfo)
return 0; return 0;
} }
s32 CARDCreate(s32 chan, const char *fileName, u32 size, CARDFileInfo *fileInfo)
{
puts("CARDCreate is a stub");
return 0;
}
s32 CARDCreateAsync(s32 chan, const char *fileName, u32 size, CARDFileInfo *fileInfo, CARDCallback callback) s32 CARDCreateAsync(s32 chan, const char *fileName, u32 size, CARDFileInfo *fileInfo, CARDCallback callback)
{ {
puts("CARDCreateAsync is a stub"); puts("CARDCreateAsync is a stub");
@ -66,6 +78,12 @@ s32 CARDFastOpen(s32 chan, s32 fileNo, CARDFileInfo *fileInfo)
return 0; return 0;
} }
s32 CARDFormat(s32 chan)
{
puts("CARDFormat is a stub");
return 0;
}
s32 CARDFreeBlocks(s32 chan, s32 *byteNotUsed, s32 *filesNotUsed) s32 CARDFreeBlocks(s32 chan, s32 *byteNotUsed, s32 *filesNotUsed)
{ {
puts("CARDFreeBlocks is a stub"); puts("CARDFreeBlocks is a stub");
@ -84,6 +102,12 @@ s32 CARDGetStatus(s32 chan, s32 fileNo, CARDStat *stat)
return 0; return 0;
} }
s32 CARDGetSectorSize(s32 chan, u32 *size)
{
puts("CARDGetSectorSize is a stub");
return 0;
}
void CARDInit() void CARDInit()
{ {
puts("CARDInit is a stub"); puts("CARDInit is a stub");
@ -113,6 +137,12 @@ s32 CARDProbeEx(s32 chan, s32 *memSize, s32 *sectorSize)
return 0; return 0;
} }
s32 CARDRead(CARDFileInfo *fileInfo, void *addr, s32 length, s32 offset)
{
puts("CARDRead is a stub");
return 0;
}
s32 CARDReadAsync(CARDFileInfo *fileInfo, void *addr, s32 length, s32 offset, CARDCallback callback) s32 CARDReadAsync(CARDFileInfo *fileInfo, void *addr, s32 length, s32 offset, CARDCallback callback)
{ {
puts("CARDReadAsync is a stub"); puts("CARDReadAsync is a stub");
@ -143,6 +173,12 @@ s32 CARDUnmount(s32 chan)
return 0; return 0;
} }
s32 CARDWrite(CARDFileInfo *fileInfo, const void *addr, s32 length, s32 offset)
{
puts("CARDWrite is a stub");
return 0;
}
s32 CARDWriteAsync(CARDFileInfo *fileInfo, const void *addr, s32 length, s32 offset, CARDCallback callback) s32 CARDWriteAsync(CARDFileInfo *fileInfo, const void *addr, s32 length, s32 offset, CARDCallback callback)
{ {
puts("CARDWriteAsync is a stub"); puts("CARDWriteAsync is a stub");
@ -175,6 +211,16 @@ void DCStoreRange(void *addr, u32 nBytes)
puts("DCStoreRange is a stub"); puts("DCStoreRange is a stub");
} }
void DEMOUpdateStats(unsigned char inc)
{
puts("DEMOUpdateStats is a stub");
}
void DEMOPrintStats(void)
{
puts("DEMOPrintStats is a stub");
}
s32 DVDCancel(DVDCommandBlock *block) s32 DVDCancel(DVDCommandBlock *block)
{ {
puts("DVDCancel is a stub"); puts("DVDCancel is a stub");
@ -401,6 +447,12 @@ void VIConfigurePan(u16 xOrg, u16 yOrg, u16 width, u16 height)
puts("VIConfigurePan is a stub"); puts("VIConfigurePan is a stub");
} }
u32 VIGetRetraceCount()
{
puts("VIGetRetraceCount is a stub");
return 0; // TODO this might be important
}
u32 VIGetNextField() u32 VIGetNextField()
{ {
puts("VIGetNextField is a stub"); puts("VIGetNextField is a stub");
@ -468,3 +520,5 @@ OSInterruptMask __OSUnmaskInterrupts(OSInterruptMask mask)
// Hudson // Hudson
void HuDvdErrDispInit(GXRenderModeObj *rmode, void *xfb1, void *xfb2) { } void HuDvdErrDispInit(GXRenderModeObj *rmode, void *xfb1, void *xfb2) { }
void HuAudInit() { }
void HuARInit() { }