commit
ab717a1e4a
2 changed files with 151 additions and 6 deletions
|
|
@ -313,7 +313,7 @@ config.libs = [
|
||||||
Object(Matching, "game/main.c"),
|
Object(Matching, "game/main.c"),
|
||||||
Object(Matching, "game/pad.c"),
|
Object(Matching, "game/pad.c"),
|
||||||
Object(Matching, "game/dvd.c"),
|
Object(Matching, "game/dvd.c"),
|
||||||
Object(NonMatching, "game/data.c"),
|
Object(Matching, "game/data.c"),
|
||||||
Object(Matching, "game/decode.c"),
|
Object(Matching, "game/decode.c"),
|
||||||
Object(Matching, "game/font.c"),
|
Object(Matching, "game/font.c"),
|
||||||
Object(Matching, "game/init.c"),
|
Object(Matching, "game/init.c"),
|
||||||
|
|
|
||||||
155
src/game/data.c
155
src/game/data.c
|
|
@ -1,5 +1,6 @@
|
||||||
#include "game/data.h"
|
#include "game/data.h"
|
||||||
#include "game/armem.h"
|
#include "game/armem.h"
|
||||||
|
#include "game/process.h"
|
||||||
#include "dolphin/dvd.h"
|
#include "dolphin/dvd.h"
|
||||||
|
|
||||||
#define PTR_OFFSET(ptr, offset) (void *)(((u8 *)(ptr)+(u32)(offset)))
|
#define PTR_OFFSET(ptr, offset) (void *)(((u8 *)(ptr)+(u32)(offset)))
|
||||||
|
|
@ -11,7 +12,7 @@ static void **HuDataReadMultiSub(s32 *data_ids, BOOL use_num, s32 num);
|
||||||
|
|
||||||
#define DATADIR_DEFINE(name, path) { path, -1 },
|
#define DATADIR_DEFINE(name, path) { path, -1 },
|
||||||
|
|
||||||
static FileListEntry DataDirStat[DATADIR_ID_MAX+1] = {
|
static FileListEntry DataDirStat[] = {
|
||||||
#include "datadir_table.h"
|
#include "datadir_table.h"
|
||||||
{ NULL, -1 }
|
{ NULL, -1 }
|
||||||
};
|
};
|
||||||
|
|
@ -21,7 +22,7 @@ static FileListEntry DataDirStat[DATADIR_ID_MAX+1] = {
|
||||||
u32 DirDataSize;
|
u32 DirDataSize;
|
||||||
static u32 DataDirMax;
|
static u32 DataDirMax;
|
||||||
static s32 shortAccessSleep;
|
static s32 shortAccessSleep;
|
||||||
static DataReadStat ReadDataStat[DATA_MAX_READSTAT];
|
static DataReadStat ATTRIBUTE_ALIGN(32) ReadDataStat[DATA_MAX_READSTAT];
|
||||||
|
|
||||||
void HuDataInit(void)
|
void HuDataInit(void)
|
||||||
{
|
{
|
||||||
|
|
@ -131,7 +132,7 @@ DataReadStat *HuDataDirRead(s32 data_num)
|
||||||
return read_stat;
|
return read_stat;
|
||||||
}
|
}
|
||||||
|
|
||||||
DataReadStat *HuDataDirReadNum(s32 data_num, s32 num)
|
static DataReadStat *HuDataDirReadNum(s32 data_num, s32 num)
|
||||||
{
|
{
|
||||||
DataReadStat *read_stat;
|
DataReadStat *read_stat;
|
||||||
int status;
|
int status;
|
||||||
|
|
@ -544,8 +545,152 @@ void HuDataDirCloseNum(s32 num)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static s32 HuDataDVDdirDirectOpen(s32 data_id, DVDFileInfo *fileInfo)
|
||||||
|
{
|
||||||
|
s32 dir = data_id >> 16;
|
||||||
|
if(dir >= (s32)DataDirMax) {
|
||||||
|
OSReport("data.c: Data Number Error(0x%08x)\n", data_id);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if(!DVDFastOpen(DataDirStat[dir].file_id, fileInfo)) {
|
||||||
|
char panic_str[48];
|
||||||
|
sprintf(panic_str, "HuDataDVDdirDirectOpen: File Open Error(%08x)", data_id);
|
||||||
|
OSPanic("data.c", 895, panic_str);
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static s32 HuDataDVDdirDirectRead(DVDFileInfo *fileInfo, void *dest, s32 len, s32 offset)
|
||||||
|
{
|
||||||
|
s32 result = DVDReadAsync(fileInfo, dest, len, offset, NULL);
|
||||||
|
if(result != 1) {
|
||||||
|
OSPanic("data.c", 904, "HuDataDVDdirDirectRead: File Read Error");
|
||||||
|
}
|
||||||
|
while(DVDGetCommandBlockStatus(&fileInfo->cb)) {
|
||||||
|
if(shortAccessSleep) {
|
||||||
|
HuPrcVSleep();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *HuDataDecodeIt(void *buf_start, s32 buf_ofs, s32 num, HeapID heap)
|
||||||
|
{
|
||||||
|
void *data_start;
|
||||||
|
s32 *buf;
|
||||||
|
s32 raw_len, comp_type;
|
||||||
|
|
||||||
|
void *dest;
|
||||||
|
buf = (s32 *)((u8 *)buf_start+buf_ofs);
|
||||||
|
if((u32)buf & 0x3) {
|
||||||
|
u8 *data = (u8 *)buf;
|
||||||
|
raw_len = *data++ << 24;
|
||||||
|
raw_len += *data++ << 16;
|
||||||
|
raw_len += *data++ << 8;
|
||||||
|
raw_len += *data++;
|
||||||
|
comp_type = *data++ << 24;
|
||||||
|
comp_type += *data++ << 16;
|
||||||
|
comp_type += *data++ << 8;
|
||||||
|
comp_type += *data++;
|
||||||
|
data_start = data;
|
||||||
|
} else {
|
||||||
|
s32 *data = buf;
|
||||||
|
raw_len = *data++;
|
||||||
|
comp_type = *data++;
|
||||||
|
data_start = data;
|
||||||
|
}
|
||||||
|
switch(heap) {
|
||||||
|
case HEAP_MUSIC:
|
||||||
|
dest = HuMemDirectMalloc(HEAP_MUSIC, DATA_EFF_SIZE(raw_len));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HEAP_DATA:
|
||||||
|
dest = HuMemDirectMallocNum(HEAP_DATA, DATA_EFF_SIZE(raw_len), num);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HEAP_DVD:
|
||||||
|
dest = HuMemDirectMallocNum(HEAP_DVD, DATA_EFF_SIZE(raw_len), num);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
dest = HuMemDirectMallocNum(HEAP_SYSTEM, DATA_EFF_SIZE(raw_len), num);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(dest) {
|
||||||
|
HuDecodeData(data_start, dest, raw_len, comp_type);
|
||||||
|
}
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//Still to be decompiled
|
//Still to be decompiled
|
||||||
void *HuDataReadNumHeapShortForce(s32 data_id, s32 num, HeapID heap)
|
void *HuDataReadNumHeapShortForce(s32 data_id, s32 num, HeapID heap)
|
||||||
{
|
{
|
||||||
return NULL;
|
DVDFileInfo fileInfo;
|
||||||
}
|
s32 *data_hdr;
|
||||||
|
s32 *file_data;
|
||||||
|
void *file_raw_buf;
|
||||||
|
s32 read_len;
|
||||||
|
s32 file_id;
|
||||||
|
s32 file_ofs;
|
||||||
|
s32 read_ofs;
|
||||||
|
s32 data_ofs;
|
||||||
|
void *ret;
|
||||||
|
s32 dir;
|
||||||
|
s32 data_len;
|
||||||
|
s32 file_max;
|
||||||
|
|
||||||
|
if(!HuDataDVDdirDirectOpen(data_id, &fileInfo)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
dir = (data_id >> 16) & 0xFFFF0000;
|
||||||
|
file_id = data_id & 0xFFFF;
|
||||||
|
file_ofs = (file_id*4)+4;
|
||||||
|
data_len = OSRoundUp32B(file_ofs+8);
|
||||||
|
file_data = HuMemDirectMalloc(HEAP_SYSTEM, data_len);
|
||||||
|
if(!HuDataDVDdirDirectRead(&fileInfo, file_data, data_len, 0)) {
|
||||||
|
HuMemDirectFree(file_data);
|
||||||
|
DVDClose(&fileInfo);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
file_max = *file_data;
|
||||||
|
if(file_max <= file_id) {
|
||||||
|
HuMemDirectFree(file_data);
|
||||||
|
OSReport("data.c%d: Data Number Error(0x%08x)\n", 1005, data_id);
|
||||||
|
DVDClose(&fileInfo);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
data_hdr = file_data;
|
||||||
|
data_hdr += file_id+1;
|
||||||
|
file_ofs = *data_hdr;
|
||||||
|
read_ofs = OSRoundDown32B(file_ofs);
|
||||||
|
if(file_max <= file_id+1) {
|
||||||
|
read_len = fileInfo.length;
|
||||||
|
data_ofs = read_len-read_ofs;
|
||||||
|
} else {
|
||||||
|
data_hdr++;
|
||||||
|
data_ofs = (*data_hdr)-read_ofs;
|
||||||
|
read_len = fileInfo.length;
|
||||||
|
}
|
||||||
|
read_len = OSRoundUp32B(data_ofs);
|
||||||
|
HuMemDirectFree(file_data);
|
||||||
|
file_raw_buf = HuMemDirectMalloc(HEAP_SYSTEM, (read_len+4) & ~0x3);
|
||||||
|
if(file_raw_buf == NULL) {
|
||||||
|
OSReport("data.c: couldn't allocate read buffer(0x%08x)\n", data_id);
|
||||||
|
DVDClose(&fileInfo);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if(!HuDataDVDdirDirectRead(&fileInfo, file_raw_buf, read_len, read_ofs)) {
|
||||||
|
HuMemDirectFree(file_raw_buf);
|
||||||
|
DVDClose(&fileInfo);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
DVDClose(&fileInfo);
|
||||||
|
data_ofs = file_ofs-read_ofs;
|
||||||
|
ret = HuDataDecodeIt(file_raw_buf, data_ofs, num, heap);
|
||||||
|
HuMemDirectFree(file_raw_buf);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
char lbl_8011FDA6[] = "** dcnt %d tmp %08x sp1 %08x\n";
|
||||||
|
char lbl_8011FDC4[] = "** dcnt %d lastNum %08x\n";
|
||||||
Loading…
Add table
Add a link
Reference in a new issue