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
src/game/card.c
src/game/fault.c
src/game/frand.c
src/game/main.c

View file

@ -2,8 +2,13 @@
#define _GAME_PROCESS_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_UPAUSE 0x2

View file

@ -79,12 +79,12 @@ void HuSysInit(GXRenderModeObj *mode)
HuDvdErrDispInit(RenderMode, DemoFrameBuffer1, DemoFrameBuffer2);
rnd_temp = frand();
HuMemInitAll();
// HuAudInit();
//HuARInit();
// minimumVcount = minimumVcountf = 1.0f;
// worstVcount = 0;
// OSInitFastCast();
// HuCardInit();
HuAudInit();
HuARInit();
minimumVcount = minimumVcountf = 1.0f;
worstVcount = 0;
OSInitFastCast();
HuCardInit();
}
static void InitRenderMode(GXRenderModeObj *mode)
@ -199,44 +199,44 @@ void HuSysBeforeRender()
void HuSysDoneRender(s32 retrace_count)
{
// s32 retrace_dist;
// if(DemoStatEnable) {
// GXDrawDone();
// DEMOUpdateStats(1);
// DEMOPrintStats();
// GXDrawDone();
// DEMOUpdateStats(0);
// }
// GXSetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE);
// GXSetColorUpdate(GX_TRUE);
// GXDrawDone();
// GXCopyDisp(DemoCurrentBuffer, GX_TRUE);
// if(minimumVcount != 0) {
// retrace_dist = VIGetRetraceCount()-retrace_count;
// if(worstVcount < retrace_dist) {
// worstVcount = retrace_dist;
// }
// while(VIGetRetraceCount()-retrace_count < minimumVcount-1) {
// VIWaitForRetrace();
// }
// }
// SwapBuffers();
s32 retrace_dist;
if(DemoStatEnable) {
GXDrawDone();
DEMOUpdateStats(1);
DEMOPrintStats();
GXDrawDone();
DEMOUpdateStats(0);
}
GXSetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE);
GXSetColorUpdate(GX_TRUE);
GXDrawDone();
GXCopyDisp(DemoCurrentBuffer, GX_TRUE);
if(minimumVcount != 0) {
retrace_dist = VIGetRetraceCount()-retrace_count;
if(worstVcount < retrace_dist) {
worstVcount = retrace_dist;
}
while(VIGetRetraceCount()-retrace_count < minimumVcount-1) {
VIWaitForRetrace();
}
}
SwapBuffers();
}
static void SwapBuffers()
{
// VISetNextFrameBuffer(DemoCurrentBuffer);
// if(FirstFrame) {
// VISetBlack(GX_FALSE);
// FirstFrame = FALSE;
// }
// VIFlush();
// VIWaitForRetrace();
// if(DemoCurrentBuffer == DemoFrameBuffer1) {
// DemoCurrentBuffer = DemoFrameBuffer2;
// } else {
// DemoCurrentBuffer = DemoFrameBuffer1;
// }
VISetNextFrameBuffer(DemoCurrentBuffer);
if(FirstFrame) {
VISetBlack(GX_FALSE);
FirstFrame = FALSE;
}
VIFlush();
VIWaitForRetrace();
if(DemoCurrentBuffer == DemoFrameBuffer1) {
DemoCurrentBuffer = DemoFrameBuffer2;
} else {
DemoCurrentBuffer = DemoFrameBuffer1;
}
}
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/sprite.h"
#include "game/dvd.h"
#include "game/gamework.h"
#include "game/gamework_data.h"
#include "game/hsfformat.h"
#include "game/hsfman.h"
#include "game/init.h"
#include "game/minigame_seq.h"
#include "game/msm.h"
#include "game/object.h"
#include "game/pad.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/wipe.h"
#ifdef TARGET_PC
#include "port/imgui.h"
@ -53,8 +53,7 @@ void aurora_log_callback(AuroraLogLevel level, const char *message, unsigned int
{
const char *levelStr = "??";
FILE *out = stdout;
switch (level)
{
switch (level) {
case LOG_DEBUG:
levelStr = "DEBUG";
break;
@ -74,8 +73,7 @@ void aurora_log_callback(AuroraLogLevel level, const char *message, unsigned int
break;
}
fprintf(out, "[%s: %s]\n", levelStr, message);
if (level == LOG_FATAL)
{
if (level == LOG_FATAL) {
fflush(out);
abort();
}
@ -83,14 +81,14 @@ void aurora_log_callback(AuroraLogLevel level, const char *message, unsigned int
#endif
#ifdef TARGET_PC
int main(int argc, char* argv[])
int main(int argc, char *argv[])
#else
void main(void)
#endif
{
#ifdef TARGET_PC
const AuroraInfo auroraInfo = aurora_initialize(argc, argv,
&(AuroraConfig){
&(AuroraConfig) {
.appName = "Mario Party 4",
.logCallback = &aurora_log_callback,
});
@ -99,56 +97,53 @@ void main(void)
u32 met1;
s16 i;
s32 retrace;
#if VERSION_PAL
#if VERSION_PAL
s16 temp = 0;
#endif
#endif
HuDvdErrWait = 0;
SystemInitF = 0;
#if VERSION_NTSC
#if VERSION_NTSC
HuSysInit(&GXNtsc480IntDf);
#else
#else
HuSysInit(&GXPal528IntDf);
#endif
/*HuPrcInit();
HuPadInit();
GWInit();
pfInit();
GlobalCounter = 0;
HuSprInit();
Hu3DInit();
HuDataInit();
HuPerfInit();
HuPerfCreate("USR0", 0xFF, 0xFF, 0xFF, 0xFF);
HuPerfCreate("USR1", 0, 0xFF, 0xFF, 0xFF);
WipeInit(RenderMode);
#endif
//HuPrcInit();
// HuPadInit();
// GWInit();
// pfInit();
// GlobalCounter = 0;
// HuSprInit();
// Hu3DInit();
// HuDataInit();
// HuPerfInit();
// HuPerfCreate("USR0", 0xFF, 0xFF, 0xFF, 0xFF);
// HuPerfCreate("USR1", 0, 0xFF, 0xFF, 0xFF);
// WipeInit(RenderMode);
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();
if (VIGetNextField() == 0) {
OSReport("VI_FIELD_BELOW\n");
VIWaitForRetrace();
}*/
}
while (1) {
#ifdef TARGET_PC
const AuroraEvent *event = aurora_update();
bool exiting = false;
while (event != NULL && event->type != AURORA_NONE)
{
if (event->type == AURORA_EXIT)
{
while (event != NULL && event->type != AURORA_NONE) {
if (event->type == AURORA_EXIT) {
exiting = true;
break;
}
++event;
}
if (exiting)
{
if (exiting) {
break;
}
#endif
@ -156,9 +151,9 @@ void main(void)
if (HuSoftResetButtonCheck() != 0 || HuDvdErrWait != 0) {
continue;
}*/
//HuPerfZero();
// HuPerfZero();
//HuPerfBegin(2);
// HuPerfBegin(2);
#ifdef TARGET_PC
aurora_begin_frame();
#endif
@ -210,16 +205,16 @@ void main(void)
#endif
}
//void HuSysVWaitSet(s16 vcount)
// void HuSysVWaitSet(s16 vcount)
//{
// minimumVcount = vcount;
// minimumVcountf = vcount;
//}
// }
//
//s16 HuSysVWaitGet(s16 param)
// s16 HuSysVWaitGet(s16 param)
//{
// return (s16) minimumVcount;
//}
// }
s32 rnd_seed = 0x0000D9ED;

View file

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

View file

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