Handle heap

This commit is contained in:
dbalatoni13 2025-04-02 10:19:16 +02:00
parent 14918e187e
commit 670a2c4c62
11 changed files with 746 additions and 161 deletions

View file

@ -16,22 +16,25 @@ add_subdirectory(extern/aurora EXCLUDE_FROM_ALL)
add_subdirectory(extern/musyx EXCLUDE_FROM_ALL)
set(DOLPHIN_FILES
# libraries/dolphin_pc/GX.c
# libraries/dolphin_pc/vi.c
# libraries/dolphin_pc/pad_evdev.c
# libraries/dolphin_pc/pad_dinput.c
src/dolphin/os/OSAlloc.c
src/dolphin/os/OSArena.c
)
set(GAME_FILES
src/game/fault.c
src/game/frand.c
src/game/main.c
src/game/malloc.c
src/game/memory.c
src/game/init.c
)
set(PORT_FILES
# src/port/byteswap.cpp
src/port/ar.c
src/port/arq.c
src/port/dvd.c
src/port/imgui.cpp
src/port/OS.c
src/port/stubs.c
)

View file

@ -19,14 +19,22 @@ extern char _db_stack_end[];
extern char *__OSResetSWInterruptHandler[];
#ifdef TARGET_PC
vu16 __OSDeviceCode;
#else
vu16 __OSDeviceCode : (OS_BASE_CACHED | 0x30E6);
#endif
static DVDDriveInfo DriveInfo ATTRIBUTE_ALIGN(32);
static DVDCommandBlock DriveBlock;
static OSBootInfo *BootInfo;
static u32 *BI2DebugFlag;
static u32 *BI2DebugFlagHolder;
#ifdef _MSC_VER
BOOL __OSIsGcam = FALSE;
#else
__declspec(weak) BOOL __OSIsGcam = FALSE;
#endif
static f64 ZeroF;
static f32 ZeroPS[2];
static BOOL AreWeInitialized = FALSE;
@ -56,6 +64,7 @@ void OSDefaultExceptionHandler(__OSException exception, OSContext *context);
extern BOOL __DBIsExceptionMarked(__OSException);
static void OSExceptionInit(void);
#ifdef __MWERKS__
/* clang-format off */
asm void __OSFPRInit(void)
{
@ -143,6 +152,7 @@ SkipPairedSingles:
blr
}
/* clang-format on */
#endif
u32 OSGetConsoleType()
{
@ -155,8 +165,8 @@ u32 OSGetConsoleType()
void *__OSSavedRegionStart;
void *__OSSavedRegionEnd;
extern u32 BOOT_REGION_START : 0x812FDFF0; //(*(u32 *)0x812fdff0)
extern u32 BOOT_REGION_END : 0x812FDFEC; //(*(u32 *)0x812fdfec)
extern u32 BOOT_REGION_START AT_ADDRESS(0x812FDFF0); //(*(u32 *)0x812fdff0)
extern u32 BOOT_REGION_END AT_ADDRESS(0x812FDFEC); //(*(u32 *)0x812fdfec)
void ClearArena(void)
{
@ -477,6 +487,7 @@ static void OSExceptionInit(void)
DBPrintf("Exceptions initialized...\n");
}
#ifdef __MWERKS__
static asm void __OSDBIntegrator(void)
{
/* clang-format off */
@ -505,6 +516,7 @@ entry __OSDBJUMPEND
/* clang-format on */
}
#endif
__OSExceptionHandler __OSSetExceptionHandler(__OSException exception, __OSExceptionHandler handler)
{
@ -519,6 +531,7 @@ __OSExceptionHandler __OSGetExceptionHandler(__OSException exception)
return OSExceptionTable[exception];
}
#ifdef __MWERKS__
static asm void OSExceptionVector(void)
{
/* clang-format off */
@ -603,8 +616,10 @@ entry __OSEVEnd
nop
/* clang-format on */
}
#endif
void __OSUnhandledException(__OSException exception, OSContext *context, u32 dsisr, u32 dar);
#ifdef __MWERKS__
asm void OSDefaultExceptionHandler(register __OSException exception, register OSContext *context)
{
/* clang-format off */
@ -631,6 +646,7 @@ void __OSPSInit(void)
}
// clang-format on
}
#endif
#define DI_CONFIG_IDX 0x9
#define DI_CONFIG_CONFIG_MASK 0xFF

View file

@ -166,7 +166,6 @@ void *OSAllocFromHeap(int heap, unsigned long size)
return NULL;
}
ASSERTMSG1(0x168, !((s32)cell & 0x1F), "OSAllocFromHeap(): heap is broken.");
ASSERTMSG1(0x169, cell->hd == NULL, "OSAllocFromHeap(): heap is broken.");
leftoverSize = cell->size - size;
if (leftoverSize < 0x40U) {
@ -312,7 +311,6 @@ void OSFreeToHeap(int heap, void *ptr)
ASSERTMSG1(0x241, HeapArray[heap].size >= 0, "OSFreeToHeap(): invalid heap handle.");
cell = (void *)((u32)ptr - 0x20);
hd = &HeapArray[heap];
ASSERTMSG1(0x246, cell->hd == hd, "OSFreeToHeap(): invalid pointer.");
ASSERTMSG1(0x247, DLLookup(hd->allocated, cell), "OSFreeToHeap(): invalid pointer.");
hd->allocated = DLExtract(hd->allocated, cell);
hd->free = DLInsert(hd->free, cell);
@ -488,12 +486,6 @@ unsigned long OSReferentSize(void *ptr)
ASSERTMSG1(0x3BD, InRange(ptr, ArenaStart + HEADERSIZE, ArenaEnd), "OSReferentSize(): invalid pointer.");
ASSERTMSG1(0x3BE, !OFFSET(ptr, 32), "OSReferentSize(): invalid pointer.");
cell = (void *)((u32)ptr - HEADERSIZE);
ASSERTMSG1(0x3C2, cell->hd, "OSReferentSize(): invalid pointer.");
ASSERTMSG1(0x3C4, !(((u32)cell->hd - (u32)HeapArray) % 24), "OSReferentSize(): invalid pointer.");
ASSERTMSG1(0x3C6, ((u32)HeapArray <= (u32)cell->hd) && ((u32)cell->hd < (u32)((u32)HeapArray + (NumHeaps * 0x18))),
"OSReferentSize(): invalid pointer.");
ASSERTMSG1(0x3C7, cell->hd->size >= 0, "OSReferentSize(): invalid pointer.");
ASSERTMSG1(0x3C9, DLLookup(cell->hd->allocated, cell), "OSReferentSize(): invalid pointer.");
return (long)((u32)cell->size - HEADERSIZE);
}

View file

@ -23,7 +23,11 @@ static RGBColor XFB_Colors[5] = {
{ 0x40, 0x80, 0x80 }
};
#ifdef TARGET_PC
u8 Ascii8x8_1bpp[0x800];
#else
#include "Ascii8x8_1bpp.inc"
#endif
static XFBGeometry XFB_Geometry;
@ -44,26 +48,29 @@ static void XFB_CR(s32 arg0, s32* arg1, s32* arg2);
void OSPanic(const char* file, int line, const char* msg, ...) {
static char* titleMes = "OSPanic encounterd:";
va_list sp78;
va_list args;
s32 sp74;
s32 sp70;
char sp84[1024];
char buffer[1024];
s32 puts;
sp74 = x_start = 0x10;
sp70 = y_start = 0x20;
puts = XFB_puts((s8*)titleMes, sp74, sp70);
XFB_CR(puts + 1, &sp74, &sp70);
sprintf(sp84, "%s:%d", file, line);
puts = XFB_puts((s8*)sp84, sp74, sp70);
sprintf(buffer, "%s:%d", file, line);
puts = XFB_puts((s8*)buffer, sp74, sp70);
XFB_CR(puts, &sp74, &sp70);
va_start(sp78, msg);
vsnprintf(sp84, 0x400U, msg, &sp78[0]);
puts = XFB_puts((s8*)sp84, sp74, sp70);
va_start(args, msg);
vsnprintf(buffer, 0x400U, msg, &args[0]);
#ifdef TARGET_PC
fputs(buffer, stderr);
#endif
puts = XFB_puts((s8*)buffer, sp74, sp70);
XFB_CR(puts, &sp74, &sp70);
XFB_WriteBackCache();
PPCHalt();
va_end(sp78);
va_end(args);
}
void HuFaultInitXfbDirectDraw(GXRenderModeObj *mode) {

View file

@ -50,11 +50,11 @@ void HuSysInit(GXRenderModeObj *mode)
OSInit();
DVDInit();
VIInit();
#if TARGET_PC
#ifdef TARGET_PC
VISetWindowTitle("Mario Party 4");
#endif
PADInit();
#if !TARGET_PC
#ifndef TARGET_PC
#if VERSION_NTSC
if(OSGetProgressiveMode() == 1 && VIGetDTVStatus() == 1) {
mode = &GXNtsc480Prog;
@ -64,23 +64,23 @@ void HuSysInit(GXRenderModeObj *mode)
#endif
#endif
InitRenderMode(mode);
InitMem();
// VIConfigure(RenderMode);
// #if VERSION_NTSC
// VIConfigurePan(0, 0, 640, 480);
// #endif
// DefaultFifo = OSAlloc(0x100000);
// DefaultFifoObj = GXInit(DefaultFifo, 0x100000);
// InitGX();
// InitVI();
// HuFaultInitXfbDirectDraw(RenderMode);
// HuFaultSetXfbAddress(0, DemoFrameBuffer1);
// HuFaultSetXfbAddress(1, DemoFrameBuffer2);
// HuDvdErrDispInit(RenderMode, DemoFrameBuffer1, DemoFrameBuffer2);
// rnd_temp = frand();
// HuMemInitAll();
InitMem();
VIConfigure(RenderMode);
#if VERSION_NTSC
VIConfigurePan(0, 0, 640, 480);
#endif
DefaultFifo = OSAlloc(0x100000);
DefaultFifoObj = GXInit(DefaultFifo, 0x100000);
InitGX();
InitVI();
HuFaultInitXfbDirectDraw(RenderMode);
HuFaultSetXfbAddress(0, DemoFrameBuffer1);
HuFaultSetXfbAddress(1, DemoFrameBuffer2);
HuDvdErrDispInit(RenderMode, DemoFrameBuffer1, DemoFrameBuffer2);
rnd_temp = frand();
HuMemInitAll();
// HuAudInit();
// HuARInit();
//HuARInit();
// minimumVcount = minimumVcountf = 1.0f;
// worstVcount = 0;
// OSInitFastCast();
@ -138,63 +138,63 @@ static void InitGX()
static void InitMem()
{
// void *arena_lo = OSGetArenaLo();
// void *arena_hi = OSGetArenaHi();
// u32 fb_size = (u16)(((u16)RenderMode->fbWidth+15) & ~15)*RenderMode->xfbHeight*2;
// u32 *fb1;
// u32 *fb2;
// u32 i;
// DemoFrameBuffer1 = (void *)OSRoundUp32B((u32)arena_lo);
// DemoFrameBuffer2 = (void *)OSRoundUp32B((u32)DemoFrameBuffer1+fb_size);
// DemoCurrentBuffer = DemoFrameBuffer2;
// #if VERSION_PAL
// fb1 = DemoFrameBuffer1;
// fb2 = DemoFrameBuffer2;
// for(i=0; i<fb_size/4; i++, fb1++, fb2++) {
// *fb1 = *fb2 = 0x800080;
// }
// DCStoreRangeNoSync(DemoFrameBuffer1, fb_size);
// DCStoreRangeNoSync(DemoFrameBuffer2, fb_size);
// #endif
// arena_lo = (void *)OSRoundUp32B((u32)DemoFrameBuffer2+fb_size);
// OSSetArenaLo(arena_lo);
// if(OSGetConsoleType() == OS_CONSOLE_DEVHW1 && OSGetPhysicalMemSize() != 0x400000 && OSGetConsoleSimulatedMemSize() < 0x1800000) {
// LoadMemInfo();
// } else {
// arena_lo = OSGetArenaLo();
// arena_hi = OSGetArenaHi();
// arena_lo = OSInitAlloc(arena_lo, arena_hi, 1);
// OSSetArenaLo(arena_lo);
// arena_lo = (void *)OSRoundUp32B((u32)arena_lo);
// arena_hi = (void *)OSRoundDown32B((u32)arena_hi);
// OSSetCurrentHeap(currentHeapHandle = OSCreateHeap(arena_lo, arena_hi));
// arena_lo = arena_hi;
// OSSetArenaLo(arena_lo);
// }
void *arena_lo = OSGetArenaLo();
void *arena_hi = OSGetArenaHi();
u32 fb_size = (u16)(((u16)RenderMode->fbWidth+15) & ~15)*RenderMode->xfbHeight*2;
u32 *fb1;
u32 *fb2;
u32 i;
DemoFrameBuffer1 = (void *)OSRoundUp32B((u32)arena_lo);
DemoFrameBuffer2 = (void *)OSRoundUp32B((u32)DemoFrameBuffer1+fb_size);
DemoCurrentBuffer = DemoFrameBuffer2;
#if VERSION_PAL
fb1 = DemoFrameBuffer1;
fb2 = DemoFrameBuffer2;
for(i=0; i<fb_size/4; i++, fb1++, fb2++) {
*fb1 = *fb2 = 0x800080;
}
DCStoreRangeNoSync(DemoFrameBuffer1, fb_size);
DCStoreRangeNoSync(DemoFrameBuffer2, fb_size);
#endif
arena_lo = (void *)OSRoundUp32B((u32)DemoFrameBuffer2+fb_size);
OSSetArenaLo(arena_lo);
if(OSGetConsoleType() == OS_CONSOLE_DEVHW1 && OSGetPhysicalMemSize() != 0x400000 && OSGetConsoleSimulatedMemSize() < 0x1800000) {
LoadMemInfo();
} else {
arena_lo = OSGetArenaLo();
arena_hi = OSGetArenaHi();
arena_lo = OSInitAlloc(arena_lo, arena_hi, 1);
OSSetArenaLo(arena_lo);
arena_lo = (void *)OSRoundUp32B((u32)arena_lo);
arena_hi = (void *)OSRoundDown32B((u32)arena_hi);
OSSetCurrentHeap(currentHeapHandle = OSCreateHeap(arena_lo, arena_hi));
arena_lo = arena_hi;
OSSetArenaLo(arena_lo);
}
}
static void InitVI()
{
// u32 interlace;
// VISetNextFrameBuffer(DemoFrameBuffer1);
// DemoCurrentBuffer = DemoFrameBuffer2;
// VIFlush();
// VIWaitForRetrace();
// interlace = RenderMode->viTVmode & 0x1;
// if(interlace) {
// VIWaitForRetrace();
// }
u32 interlace;
VISetNextFrameBuffer(DemoFrameBuffer1);
DemoCurrentBuffer = DemoFrameBuffer2;
VIFlush();
VIWaitForRetrace();
interlace = RenderMode->viTVmode & 0x1;
if(interlace) {
VIWaitForRetrace();
}
}
void HuSysBeforeRender()
{
// if(RenderMode->field_rendering) {
// GXSetViewportJitter(0, 0, RenderMode->fbWidth, RenderMode->xfbHeight, 0, 1, VIGetNextField());
// } else {
// GXSetViewport(0, 0, RenderMode->fbWidth, RenderMode->xfbHeight, 0, 1);
// }
// GXInvalidateVtxCache();
// GXInvalidateTexAll();
if(RenderMode->field_rendering) {
GXSetViewportJitter(0, 0, RenderMode->fbWidth, RenderMode->xfbHeight, 0, 1, VIGetNextField());
} else {
GXSetViewport(0, 0, RenderMode->fbWidth, RenderMode->xfbHeight, 0, 1);
}
GXInvalidateVtxCache();
GXInvalidateTexAll();
}
void HuSysDoneRender(s32 retrace_count)
@ -241,66 +241,66 @@ static void SwapBuffers()
static void LoadMemInfo()
{
// u32 size;
// u32 copy_size;
// u32 offset;
// u32 entries;
// u32 i;
// void *arena_lo;
// void *arena_hi;
// void *alloc_max;
// void *alloc_min;
//
// struct memory_info *buf_ptr;
// DVDFileInfo file;
// char buf[240];
//
// OSReport("\nNow, try to find memory info file...\n\n");
// if(!DVDOpen("/meminfo.bin", &file)) {
// OSReport("\nCan't find memory info file. Use /XXX toolname/ to maximize available\n");
// OSReport("memory space. For now, we only use the first %dMB.\n", (OSGetConsoleSimulatedMemSize()/1024)/1024);
// arena_lo = OSGetArenaLo();
// arena_hi = OSGetArenaHi();
// arena_lo = OSInitAlloc(arena_lo, arena_hi, 1);
// OSSetArenaLo(arena_lo);
// arena_lo = (void *)OSRoundUp32B((u32)arena_lo);
// arena_hi = (void *)OSRoundDown32B((u32)arena_hi);
// OSSetCurrentHeap(OSCreateHeap(arena_lo, arena_hi));
// arena_lo = arena_hi;
// OSSetArenaLo(arena_lo);
// } else {
// buf_ptr = (struct memory_info *)OSRoundUp32B((u32)buf);
// alloc_max = OSGetArenaHi();
// alloc_min = (void *)(OSGetConsoleSimulatedMemSize()+0x80000000);
// OSSetArenaHi((void *)(OSGetPhysicalMemSize()+0x80000000));
// arena_lo = OSGetArenaLo();
// arena_hi = OSGetArenaHi();
// arena_lo = OSInitAlloc(arena_lo, arena_hi, 1);
// OSSetArenaLo(arena_lo);
// arena_lo = (void *)OSRoundUp32B((u32)arena_lo);
// arena_hi = (void *)OSRoundDown32B((u32)arena_hi);
// OSSetCurrentHeap(OSCreateHeap(arena_lo, arena_hi));
// arena_lo = arena_hi;
// OSSetArenaLo(arena_lo);
// OSAllocFixed(&alloc_max, &alloc_min);
// size = file.length;
// offset = 0;
// while(size) {
// OSReport("loop\n");
// copy_size = (size < 32) ? size : 32;
// if(DVDRead(&file, buf_ptr, OSRoundUp32B(copy_size), offset) < 0) {
// OSPanic("init.c", ASSERT_LINE(576, 586), "An error occurred when issuing read to /meminfo.bin\n");
// }
// entries = copy_size/sizeof(struct memory_info);
// for(i=0; i<entries; i++) {
// OSReport("start: 0x%08x, end: 0x%08x\n", buf_ptr[i].start, buf_ptr[i].end);
// OSAllocFixed(&buf_ptr[i].start, &buf_ptr[i].end);
// OSReport("Removed 0x%08x - 0x%08x from the current heap\n", buf_ptr[i].start, (u32)buf_ptr[i].end-1);
// }
// size -= copy_size;
// offset += copy_size;
// }
// DVDClose(&file);
// OSDumpHeap(__OSCurrHeap);
// }
u32 size;
u32 copy_size;
u32 offset;
u32 entries;
u32 i;
void *arena_lo;
void *arena_hi;
void *alloc_max;
void *alloc_min;
struct memory_info *buf_ptr;
DVDFileInfo file;
char buf[240];
OSReport("\nNow, try to find memory info file...\n\n");
if(!DVDOpen("/meminfo.bin", &file)) {
OSReport("\nCan't find memory info file. Use /XXX toolname/ to maximize available\n");
OSReport("memory space. For now, we only use the first %dMB.\n", (OSGetConsoleSimulatedMemSize()/1024)/1024);
arena_lo = OSGetArenaLo();
arena_hi = OSGetArenaHi();
arena_lo = OSInitAlloc(arena_lo, arena_hi, 1);
OSSetArenaLo(arena_lo);
arena_lo = (void *)OSRoundUp32B((u32)arena_lo);
arena_hi = (void *)OSRoundDown32B((u32)arena_hi);
OSSetCurrentHeap(OSCreateHeap(arena_lo, arena_hi));
arena_lo = arena_hi;
OSSetArenaLo(arena_lo);
} else {
buf_ptr = (struct memory_info *)OSRoundUp32B((u32)buf);
alloc_max = OSGetArenaHi();
alloc_min = (void *)(OSGetConsoleSimulatedMemSize()+0x80000000);
OSSetArenaHi((void *)(OSGetPhysicalMemSize()+0x80000000));
arena_lo = OSGetArenaLo();
arena_hi = OSGetArenaHi();
arena_lo = OSInitAlloc(arena_lo, arena_hi, 1);
OSSetArenaLo(arena_lo);
arena_lo = (void *)OSRoundUp32B((u32)arena_lo);
arena_hi = (void *)OSRoundDown32B((u32)arena_hi);
OSSetCurrentHeap(OSCreateHeap(arena_lo, arena_hi));
arena_lo = arena_hi;
OSSetArenaLo(arena_lo);
OSAllocFixed(&alloc_max, &alloc_min);
size = file.length;
offset = 0;
while(size) {
OSReport("loop\n");
copy_size = (size < 32) ? size : 32;
if(DVDRead(&file, buf_ptr, OSRoundUp32B(copy_size), offset) < 0) {
OSPanic("init.c", ASSERT_LINE(576, 586), "An error occurred when issuing read to /meminfo.bin\n");
}
entries = copy_size/sizeof(struct memory_info);
for(i=0; i<entries; i++) {
OSReport("start: 0x%08x, end: 0x%08x\n", buf_ptr[i].start, buf_ptr[i].end);
OSAllocFixed(&buf_ptr[i].start, &buf_ptr[i].end);
OSReport("Removed 0x%08x - 0x%08x from the current heap\n", buf_ptr[i].start, (u32)buf_ptr[i].end-1);
}
size -= copy_size;
offset += copy_size;
}
DVDClose(&file);
OSDumpHeap(__OSCurrHeap);
}
}

View file

@ -47,39 +47,55 @@ void HuMemDCFlush(HeapID heap)
void *HuMemDirectMalloc(HeapID heap, s32 size)
{
#ifdef TARGET_PC
u32 retaddr = 0;
#else
register u32 retaddr;
asm {
mflr retaddr
}
#endif
size = (size+31) & 0xFFFFFFE0;
return HuMemMemoryAlloc(HeapTbl[heap], size, retaddr);
}
void *HuMemDirectMallocNum(HeapID heap, s32 size, u32 num)
{
#ifdef TARGET_PC
u32 retaddr = 0;
#else
register u32 retaddr;
asm {
mflr retaddr
}
#endif
size = (size+31) & 0xFFFFFFE0;
return HuMemMemoryAllocNum(HeapTbl[heap], size, num, retaddr);
}
void HuMemDirectFree(void *ptr)
{
#ifdef TARGET_PC
u32 retaddr = 0;
#else
register u32 retaddr;
asm {
mflr retaddr
}
#endif
HuMemMemoryFree(ptr, retaddr);
}
void HuMemDirectFreeNum(HeapID heap, u32 num)
{
#ifdef TARGET_PC
u32 retaddr = 0;
#else
register u32 retaddr;
asm {
mflr retaddr
}
#endif
HuMemMemoryFreeNum(HeapTbl[heap], num, retaddr);
}
@ -101,4 +117,4 @@ u32 HuMemHeapSizeGet(HeapID heap)
void *HuMemHeapPtrGet(HeapID heap)
{
return HeapTbl[heap];
}
}

41
src/port/OS.c Normal file
View file

@ -0,0 +1,41 @@
#include <stdio.h>
#include <stdlib.h>
#include <dolphin.h>
// Credits: Super Monkey Ball
#define MEM_SIZE (32 * 1024 * 1024)
u8 LC_CACHE_BASE[4096];
void OSInit()
{
puts("OSInit is a stub");
u8 *arena = malloc(MEM_SIZE);
OSSetArenaLo(arena);
OSSetArenaHi(arena + MEM_SIZE);
}
OSTime OSGetTime(void)
{
return 0;
}
OSTick OSGetTick(void)
{
return 0;
}
u32 OSGetPhysicalMemSize(void)
{
puts("OSGetPhysicalMemSize is a stub");
return MEM_SIZE;
}
u32 OSGetConsoleSimulatedMemSize(void)
{
puts("OSGetSimulatedMemSize is a stub");
return MEM_SIZE;
}

24
src/port/ar.c Normal file
View file

@ -0,0 +1,24 @@
#include <stdio.h>
#include <string.h>
#include <dolphin.h>
u8 ARAM[16 * 1024 * 1024];
void ARStartDMA(u32 type, u32 mainmem_addr, u32 aram_addr, u32 length)
{
switch (type)
{
case ARAM_DIR_MRAM_TO_ARAM:
memcpy(ARAM + aram_addr, (void *)mainmem_addr, length);
break;
case ARAM_DIR_ARAM_TO_MRAM:
memcpy((void *)mainmem_addr, ARAM + aram_addr, length);
break;
}
}
u32 ARGetDMAStatus(void)
{
puts("ARGetDMAStatus");
return 0;
}

23
src/port/arq.c Normal file
View file

@ -0,0 +1,23 @@
#include <stdio.h>
#include <string.h>
#include <dolphin.h>
extern u8 ARAM[16 * 1024 * 1024];
void ARQPostRequest(ARQRequest *task, u32 owner, u32 type, u32 priority,
u32 source, u32 dest, u32 length, ARQCallback callback)
{
printf("ARQPostRequest: 0x%X, 0x%X, 0x%X\n",
(unsigned int)source, (unsigned int)dest, (unsigned int)length);
switch (type)
{
case ARQ_TYPE_MRAM_TO_ARAM:
memcpy(ARAM + dest, (void *)source, length);
callback((u32)task);
break;
case ARQ_TYPE_ARAM_TO_MRAM:
memcpy((void *)dest, ARAM + source, length);
callback((u32)task);
break;
}
}

View file

@ -110,6 +110,19 @@ BOOL DVDClose(DVDFileInfo *fileInfo)
return TRUE;
}
BOOL DVDReadPrio(DVDFileInfo *fileInfo, void *addr, s32 length, s32 offset, s32 prio)
{
FILE *f = fileInfo->cb.addr;
BOOL success;
printf("DVDReadPrio: length %li, offset %li\n", length, offset);
fseek(f, offset, SEEK_SET);
success = (fread(addr, length, 1, f) == 1) || feof(f);
if (!success)
puts("read failed");
return TRUE;
}
BOOL DVDReadAsyncPrio(DVDFileInfo *fileInfo, void *addr, s32 length, s32 offset, DVDCallback callback, s32 prio)
{
FILE *f = fileInfo->cb.addr;

View file

@ -1,11 +1,9 @@
#include <stdio.h>
#include <dolphin.h>
#include <stdarg.h>
#include <stdio.h>
#include <types.h>
void OSInit()
{
printf("OSInit is a stub\n");
}
// Credits: Super Monkey Ball
void OSReport(const char *msg, ...)
{
@ -15,6 +13,458 @@ void OSReport(const char *msg, ...)
va_end(args);
}
void OSPanic(const char *file, int line, const char *msg, ...) {
printf("Panic in \"%s\" on line %d.\n", file, line);
u32 OSGetConsoleType()
{
return OS_CONSOLE_RETAIL1;
}
s32 CARDCancel(CARDFileInfo *fileInfo)
{
puts("CARDCancel is a stub");
return 0;
}
s32 CARDCheckAsync(s32 chan, CARDCallback callback)
{
puts("CARDCheckAsync is a stub");
return 0;
}
s32 CARDClose(CARDFileInfo *fileInfo)
{
puts("CARDClose is a stub");
return 0;
}
s32 CARDCreateAsync(s32 chan, const char *fileName, u32 size, CARDFileInfo *fileInfo, CARDCallback callback)
{
puts("CARDCreateAsync is a stub");
return 0;
}
s32 CARDDelete(s32 chan, const char *fileName)
{
puts("CARDDelete is a stub");
return 0;
}
s32 CARDDeleteAsync(s32 chan, const char *fileName, CARDCallback callback)
{
puts("CARDDeleteAsync is a stub");
return 0;
}
s32 CARDFastDeleteAsync(s32 chan, s32 fileNo, CARDCallback callback)
{
puts("CARDFastDeleteAsync is a stub");
return 0;
}
s32 CARDFastOpen(s32 chan, s32 fileNo, CARDFileInfo *fileInfo)
{
puts("CARDFastOpen is a stub");
return 0;
}
s32 CARDFreeBlocks(s32 chan, s32 *byteNotUsed, s32 *filesNotUsed)
{
puts("CARDFreeBlocks is a stub");
return 0;
}
s32 CARDGetResultCode(s32 chan)
{
puts("CARDGetResultCode is a stub");
return 0;
}
s32 CARDGetStatus(s32 chan, s32 fileNo, CARDStat *stat)
{
puts("CARDGetStatus is a stub");
return 0;
}
void CARDInit()
{
puts("CARDInit is a stub");
}
s32 CARDMount(s32 chan, void *workArea, CARDCallback detachCallback)
{
puts("CARDMount is a stub");
return 0;
}
s32 CARDMountAsync(s32 chan, void *workArea, CARDCallback detachCallback, CARDCallback attachCallback)
{
puts("CARDMountAsync is a stub");
return 0;
}
s32 CARDOpen(s32 chan, const char *fileName, CARDFileInfo *fileInfo)
{
puts("CARDOpen is a stub");
return 0;
}
s32 CARDProbeEx(s32 chan, s32 *memSize, s32 *sectorSize)
{
puts("CARDProbeEx is a stub");
return 0;
}
s32 CARDReadAsync(CARDFileInfo *fileInfo, void *addr, s32 length, s32 offset, CARDCallback callback)
{
puts("CARDReadAsync is a stub");
return 0;
}
s32 CARDRename(s32 chan, const char *oldName, const char *newName)
{
puts("CARDRename is a stub");
return 0;
}
s32 CARDRenameAsync(s32 chan, const char *oldName, const char *newName, CARDCallback callback)
{
puts("CARDRenameAsync is a stub");
return 0;
}
s32 CARDSetStatusAsync(s32 chan, s32 fileNo, CARDStat *stat, CARDCallback callback)
{
puts("CARDSetStatusAsync is a stub");
return 0;
}
s32 CARDUnmount(s32 chan)
{
puts("CARDUnmount is a stub");
return 0;
}
s32 CARDWriteAsync(CARDFileInfo *fileInfo, const void *addr, s32 length, s32 offset, CARDCallback callback)
{
puts("CARDWriteAsync is a stub");
return 0;
}
void C_MTXScale(Mtx m, f32 xS, f32 yS, f32 zS)
{
*(volatile int *)0 = 0;
puts("C_MTXScale is a stub");
}
void DCFlushRange(void *addr, u32 nBytes)
{
puts("DCFlushRange is a stub");
}
void DCFlushRangeNoSync(void *addr, u32 nBytes)
{
puts("DCFlushRangeNoSync is a stub");
}
void DCInvalidateRange(void *addr, u32 nBytes)
{
puts("DCInvalidateRange is a stub");
}
void DCStoreRange(void *addr, u32 nBytes)
{
puts("DCStoreRange is a stub");
}
s32 DVDCancel(DVDCommandBlock *block)
{
puts("DVDCancel is a stub");
return 0;
}
void DVDReadAbsAsyncForBS(void *a, struct bb2struct *b, int c, int d, void (*e)())
{
puts("DVDReadAbsAsyncForBS is a stub");
}
void DVDReadDiskID(void *a, DVDDiskID *b, void (*c)())
{
puts("DVDReadDiskID is a stub");
}
void DVDReset()
{
puts("DVDReset is a stub");
}
BOOL EXIDeselect(int chan)
{
puts("EXIDeselect is a stub");
return FALSE;
}
BOOL EXIDma(int chan, void *buffer, s32 size, int d, int e)
{
puts("EXIDma is a stub");
return FALSE;
}
BOOL EXIImm(int chan, u32 *b, int c, int d, int e)
{
puts("EXIImm is a stub");
return FALSE;
}
BOOL EXILock(int chan, int b, int c)
{
puts("EXILock is a stub");
return FALSE;
}
BOOL EXISelect(int chan, int b, int c)
{
puts("EXISelect is a stub");
return FALSE;
}
BOOL EXISync(int chan)
{
puts("EXISync is a stub");
return FALSE;
}
BOOL EXIUnlock(int chan)
{
puts("EXIUnlock is a stub");
return FALSE;
}
void LCEnable()
{
puts("LCEnable is a stub");
}
void OSClearContext(OSContext *context)
{
puts("OSClearContext is a stub");
}
BOOL OSDisableInterrupts()
{
puts("OSDisableInterrupts is a stub");
return FALSE;
}
void OSDumpContext(OSContext *context)
{
puts("OSDumpContext is a stub");
}
OSThread *OSGetCurrentThread()
{
puts("OSGetCurrentThread is a stub");
return 0;
}
u16 OSGetFontEncode()
{
puts("OSGetFontEncode is a stub");
return 0;
}
char *OSGetFontTexture(char *string, void **image, s32 *x, s32 *y, s32 *width)
{
puts("OSGetFontTexture is a stub");
return 0;
}
char *OSGetFontWidth(char *string, s32 *width)
{
puts("OSGetFontWidth is a stub");
return 0;
}
BOOL OSGetResetButtonState()
{
puts("OSGetResetButtonState is a stub");
return FALSE;
}
u32 OSGetStackPointer()
{
puts("OSGetStackPointer is a stub");
return 0;
}
BOOL OSInitFont(OSFontHeader *fontData)
{
puts("OSInitFont is a stub");
return FALSE;
}
BOOL OSLink(OSModuleInfo *newModule, void *bss)
{
puts("OSLink is a stub");
return FALSE;
}
void OSLoadContext(OSContext *context)
{
puts("OSLoadContext is a stub");
}
void OSResetSystem(int reset, u32 resetCode, BOOL forceMenu)
{
puts("OSResetSystem is a stub");
}
BOOL OSRestoreInterrupts(BOOL level)
{
puts("OSRestoreInterrupts is a stub");
return FALSE;
}
s32 OSResumeThread(OSThread *thread)
{
puts("OSResumeThread is a stub");
return 0;
}
void OSSetCurrentContext(OSContext *context)
{
puts("OSSetCurrentContext is a stub");
}
void OSSetStringTable(const void *stringTable)
{
puts("OSSetStringTable is a stub");
}
s32 OSSuspendThread(OSThread *thread)
{
puts("OSSuspendThread is a stub");
return 0;
}
void OSTicksToCalendarTime(OSTime ticks, OSCalendarTime *td)
{
puts("OSTicksToCalendarTime is a stub");
}
BOOL OSUnlink(OSModuleInfo *oldModule)
{
puts("OSUnlink is a stub");
return FALSE;
}
void OSWakeupThread(OSThreadQueue *queue)
{
puts("OSWakeupThread is a stub");
}
void PPCHalt()
{
puts("PPCHalt is a stub");
}
void PSMTXIdentity(Mtx m)
{
puts("PSMTXIdentity is a stub");
}
void SoundChoID(int a, int b)
{
puts("SoundChoID is a stub");
}
void SoundPan(int a, int b, int c)
{
puts("SoundPan is a stub");
}
void SoundPitch(u16 a, int b)
{
puts("SoundPitch is a stub");
}
void SoundRevID(int a, int b)
{
puts("SoundRevID is a stub");
}
void VIConfigure(const GXRenderModeObj *rm)
{
puts("VIConfigure is a stub");
}
void VIConfigurePan(u16 xOrg, u16 yOrg, u16 width, u16 height)
{
puts("VIConfigurePan is a stub");
}
u32 VIGetNextField()
{
puts("VIGetNextField is a stub");
return 0;
}
void VISetBlack(BOOL black)
{
puts("VISetBlack is a stub");
}
void VISetNextFrameBuffer(void *fb)
{
puts("VISetNextFrameBuffer is a stub");
}
void VIWaitForRetrace()
{
puts("VIWaitForRetrace is a stub");
}
s32 __CARDFormatRegionAsync(int a, int b)
{
puts("__CARDFormatRegionAsync is a stub");
return 0;
}
void __GXSetSUTexSize()
{
puts("__GXSetSUTexSize is a stub");
}
void __GXSetVAT()
{
puts("__GXSetVAT is a stub");
}
void __GXSetVCD()
{
puts("__GXSetVCD is a stub");
}
void __GXUpdateBPMask()
{
puts("__GXUpdateBPMask is a stub");
}
u32 __OSGetDIConfig()
{
puts("__OSGetDIConfig is a stub");
return 0;
}
__OSInterruptHandler __OSSetInterruptHandler(__OSInterrupt interrupt, __OSInterruptHandler handler)
{
puts("__OSSetInterruptHandler is a stub");
return 0;
}
OSInterruptMask __OSUnmaskInterrupts(OSInterruptMask mask)
{
puts("__OSUnmaskInterrupts is a stub");
return 0;
}
// Hudson
void HuDvdErrDispInit(GXRenderModeObj *rmode, void *xfb1, void *xfb2) { }