Mostly match dvd.c
This commit is contained in:
parent
40f2ed3759
commit
c831b27965
3 changed files with 184 additions and 6 deletions
178
src/game/dvd.c
Normal file
178
src/game/dvd.c
Normal file
|
|
@ -0,0 +1,178 @@
|
|||
#include "common.h"
|
||||
#include "dolphin/dvd.h"
|
||||
#include "dolphin/os.h"
|
||||
|
||||
extern u32 DirDataSize;
|
||||
|
||||
static DVDDiskID correctDiskID = {
|
||||
{ 'M', 'P', 'G', 'C' }, //gameName
|
||||
{ 'H', 'U' }, //company
|
||||
1, //diskNumber
|
||||
1, //gameVersion
|
||||
1, //streaming
|
||||
0, //streamingBufSize
|
||||
};
|
||||
|
||||
void HuDvdErrorWatch();
|
||||
|
||||
static s32 beforeDvdStatus;
|
||||
static int CallBackStatus;
|
||||
|
||||
static void HuDVDReadAsyncCallBack()
|
||||
{
|
||||
CallBackStatus = 1;
|
||||
}
|
||||
|
||||
static void *HuDvdDataReadWait(DVDFileInfo *file, int heap, int mode, int num, DVDCallback cb, BOOL skip_wait)
|
||||
{
|
||||
u32 len;
|
||||
void *buf;
|
||||
if(mode != 0 && mode != 1 && mode != 2) {
|
||||
OSReport("dvd.c: HuDvdDataReadWait Mode Error");
|
||||
}
|
||||
len = file->length;
|
||||
DirDataSize = len;
|
||||
if(mode == 1) {
|
||||
buf = HuMemDirectMallocNum(heap, OSRoundUp32B(len), num);
|
||||
} else {
|
||||
buf = HuMemDirectMalloc(heap, OSRoundUp32B(len));
|
||||
}
|
||||
if(!buf) {
|
||||
OSReport("dvd.c: Memory Allocation Error (Length %x) (mode %d)\n", len, mode);
|
||||
OSReport("Rest Memory %x\n", HuMemHeapSizeGet(3)-HuMemUsedMallocSizeGet(3));
|
||||
OSPanic("dvd.c", 75, "\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DCInvalidateRange(buf, OSRoundUp32B(len));
|
||||
OSReport("Rest Memory %x\n", HuMemHeapSizeGet(3)-HuMemUsedMallocSizeGet(3));
|
||||
CallBackStatus = 0;
|
||||
DVDReadAsync(file, buf, OSRoundUp32B(len), 0, cb);
|
||||
if(!skip_wait) {
|
||||
while(!CallBackStatus) {
|
||||
HuDvdErrorWatch();
|
||||
}
|
||||
HuDvdErrorWatch();
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
void *HuDvdDataRead(char *path)
|
||||
{
|
||||
DVDFileInfo file;
|
||||
void *data = NULL;
|
||||
if(!DVDOpen(path, &file)) {
|
||||
OSPanic("dvd.c", 146, "dvd.c: File Open Error");
|
||||
} else {
|
||||
data = HuDvdDataReadWait(&file, 3, 0, 0, HuDVDReadAsyncCallBack, FALSE);
|
||||
DVDClose(&file);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
void **HuDvdDataReadMulti(char **paths)
|
||||
{
|
||||
DVDFileInfo file;
|
||||
u32 count;
|
||||
int i;
|
||||
void **file_ptrs;
|
||||
count = 0;
|
||||
while(paths[count]) {
|
||||
count++;
|
||||
}
|
||||
file_ptrs = HuMemDirectMalloc(0, count*4);
|
||||
for(i=0; i<count; i++) {
|
||||
if(!DVDOpen(paths[i], &file)) {
|
||||
OSPanic("dvd.c", 183, "dvd.c: File Open Error");
|
||||
return NULL;
|
||||
} else {
|
||||
file_ptrs[i] = HuDvdDataReadWait(&file, 3, 0, 0, HuDVDReadAsyncCallBack, FALSE);
|
||||
DVDClose(&file);
|
||||
}
|
||||
}
|
||||
return file_ptrs;
|
||||
}
|
||||
|
||||
void *HuDvdDataReadDirect(char *path, int heap)
|
||||
{
|
||||
DVDFileInfo file;
|
||||
void *data = NULL;
|
||||
if(!DVDOpen(path, &file)) {
|
||||
OSPanic("dvd.c", 202, "dvd.c: File Open Error");
|
||||
} else {
|
||||
data = HuDvdDataReadWait(&file, heap, 2, 0, HuDVDReadAsyncCallBack, FALSE);
|
||||
DVDClose(&file);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
void *HuDvdDataFastRead(s32 entrynum)
|
||||
{
|
||||
DVDFileInfo file;
|
||||
void *data = NULL;
|
||||
if(!DVDFastOpen(entrynum, &file)) {
|
||||
OSPanic("dvd.c", 243, "dvd.c: File Open Error");
|
||||
} else {
|
||||
data = HuDvdDataReadWait(&file, 3, 0, 0, HuDVDReadAsyncCallBack, FALSE);
|
||||
DVDClose(&file);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
void *HuDvdDataFastReadNum(s32 entrynum, s32 num)
|
||||
{
|
||||
DVDFileInfo file;
|
||||
void *data = NULL;
|
||||
if(!DVDFastOpen(entrynum, &file)) {
|
||||
OSPanic("dvd.c", 258, "dvd.c: File Open Error");
|
||||
(void)num;
|
||||
(void)data;
|
||||
} else {
|
||||
data = HuDvdDataReadWait(&file, 3, 1, num, HuDVDReadAsyncCallBack, FALSE);
|
||||
DVDClose(&file);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
void HuDvdDataClose(void *ptr)
|
||||
{
|
||||
if(ptr) {
|
||||
HuMemDirectFree(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
void HuDvdErrorWatch()
|
||||
{
|
||||
int status = DVDGetDriveStatus();
|
||||
if(status == beforeDvdStatus) {
|
||||
return;
|
||||
}
|
||||
beforeDvdStatus = status;
|
||||
switch(status+1) {
|
||||
case 0:
|
||||
OSReport("DVD ERROR:Fatal error occurred\n***HALT***");
|
||||
while(1);
|
||||
break;
|
||||
|
||||
case 6:
|
||||
OSReport("DVD ERROR:No disk\n");
|
||||
break;
|
||||
|
||||
case 7:
|
||||
OSReport("DVD ERROR:Cover open\n");
|
||||
break;
|
||||
|
||||
case 8:
|
||||
OSReport("DVD ERROR:Wrong disk\n");
|
||||
break;
|
||||
|
||||
case 12:
|
||||
OSReport("DVD ERROR:Please retry\n");
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue