Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Ziemas committed May 1, 2024
1 parent 4cf0a1d commit de163ba
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 30 deletions.
4 changes: 2 additions & 2 deletions game/common/dgo_rpc_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ struct RPC_Dgo_Cmd {
uint32_t buffer2;
uint32_t buffer_heap_top;
char name[16];
uint16_t cgo_id;
uint8_t pad[30];
uint32_t cgo_id;
uint8_t pad[28];
};
static_assert(sizeof(RPC_Dgo_Cmd) == 0x40);
} // namespace jak3
Expand Down
1 change: 0 additions & 1 deletion game/overlord/jak3/basefile.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#pragma once

#include "game/overlord/jak3/iso.h"
#include "game/overlord/jak3/iso_structs.h"
#include "game/overlord/jak3/overlord.h"

Expand Down
106 changes: 87 additions & 19 deletions game/overlord/jak3/iso.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,21 @@ namespace jak3 {
using namespace iop;

CBaseFileSystem* g_pFileSystem;
int g_nISOThreadID;
int g_nDGOThreadID;
int g_nSTRThreadID;
int g_nPlayThreadID;
int g_nISOMbx;

static int s_nISOInitFlag;
static ISO_LoadDGO s_LoadDGO;
static int s_nSyncMbx;
static MsgPacket s_MsgPacket_NotOnStackSync[2];
static RPC_Dgo_Cmd s_aISO_RPCBuf[1];
static int s_nDGOMbx;

static void* RPC_DGO(u32 fno, void* data, int size) {
lg::error("RPC_DGO UNIMPLEMENTED");
return nullptr;
}

static u32 DGOThread() {
sceSifQueueData dq;
sceSifServeData serve;

CpuDisableIntr();
sceSifInitRpc(0);
sceSifSetRpcQueue(&dq, GetThreadId());
sceSifRegisterRpc(&serve, 0xfab3, RPC_DGO, s_aISO_RPCBuf, sizeof(s_aISO_RPCBuf), nullptr, nullptr,
&dq);
CpuEnableIntr();
sceSifRpcLoop(&dq);

return 0;
}
static u32 DGOThread();
u32 ISOThread();

/* COMPLETE */
void InitDriver() {
Expand Down Expand Up @@ -79,6 +65,25 @@ int InitISOFS(const char* fs_mode, const char* loading_sceeen) {
s_nISOInitFlag = 1;
g_pFileSystem = &g_FakeISOCDFileSystem;

mbx.attr = 0;
mbx.option = 0;
g_nISOMbx = CreateMbx(&mbx);

mbx.attr = 0;
mbx.option = 0;
s_nDGOMbx = CreateMbx(&mbx);

mbx.attr = 0;
mbx.option = 0;
s_nSyncMbx = CreateMbx(&mbx);

thp.attr = TH_C;
thp.entry = ISOThread;
thp.initPriority = 0x37;
thp.option = 0;
thp.stackSize = 0x1100;
g_nISOThreadID = CreateThread(&thp);

thp.attr = TH_C;
thp.entry = DGOThread;
thp.initPriority = 0x38;
Expand All @@ -100,13 +105,76 @@ int InitISOFS(const char* fs_mode, const char* loading_sceeen) {
thp.stackSize = 0x900;
g_nPlayThreadID = CreateThread(&thp);

StartThread(g_nISOThreadID, 0);
StartThread(g_nDGOThreadID, 0);
StartThread(g_nSTRThreadID, 0);
StartThread(g_nPlayThreadID, 0);

return s_nISOInitFlag;
}

u32 ISOThread() {
while (true) {
DelayThread(4000);
}

return 0;
}

static void ISO_LoadDGO(RPC_Dgo_Cmd* msg);
static void ISO_LoadNextDGO(RPC_Dgo_Cmd* msg);
static void ISO_CancelDGO(RPC_Dgo_Cmd* msg);

static void* RPC_DGO(u32 fno, void* data, int size) {
auto* msg = static_cast<RPC_Dgo_Cmd*>(data);

switch (fno) {
case 0:
ISO_LoadDGO(msg);
break;
case 1:
ISO_LoadNextDGO(msg);
break;
case 2:
ISO_CancelDGO(msg);
break;
default:
msg->result = 1;
break;
}
return data;
}

static u32 DGOThread() {
sceSifQueueData dq;
sceSifServeData serve;

CpuDisableIntr();
sceSifInitRpc(0);
sceSifSetRpcQueue(&dq, GetThreadId());
sceSifRegisterRpc(&serve, 0xfab3, RPC_DGO, s_aISO_RPCBuf, sizeof(s_aISO_RPCBuf), nullptr, nullptr,
&dq);
CpuEnableIntr();
sceSifRpcLoop(&dq);

return 0;
}

static void ISO_LoadDGO(RPC_Dgo_Cmd* msg) {
auto* def = g_pFileSystem->Find(msg->name);
if (def == nullptr) {
msg->result = 1;
return;
}

msg->buffer1 = msg->buffer_heap_top;
msg->result = 0;
}

static void ISO_LoadNextDGO(RPC_Dgo_Cmd* msg) {}

static void ISO_CancelDGO(RPC_Dgo_Cmd* msg) {}

/* COMPLETE */
const ISOFileDef* FindISOFile(char* name) {
return g_pFileSystem->Find(name);
Expand Down
24 changes: 16 additions & 8 deletions game/overlord/jak3/iso.h
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
#pragma once

#include "game/overlord/jak3/basefile.h"
#include "game/sce/iop.h"

namespace jak3 {

struct ISOBuffer {
void AdjustDataLength(int);
void AdvanceCurrentData(int);
};

struct ISO_Hdr {
iop::MsgPacket msg;
iop::MsgPacket m_Pkt;
int m_nStatus;
bool m_bActive;
bool unk1;
bool unk2;

void SetActive();
void SetUnk1();
void SetUnk2();
};

struct ISO_Msg : ISO_Hdr {};
struct ISO_Msg : ISO_Hdr {
u32 cmd_kind;
int mbx_to_reply;
int thread_id;
void* callback;
CBaseFile* file;
};

struct ISO_LoadDGO : ISO_Msg {};
struct ISO_LoadDGO : ISO_Msg {
ISOFileDef* fd;
};

int InitISOFS(const char* fs_mode, const char* loading_sceeen);
} // namespace jak3
5 changes: 5 additions & 0 deletions game/overlord/jak3/iso_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ namespace jak3 {
/* TODO check values */
enum class EFileComp { MODE0, MODE1, KNOWN_NOT_BLZO };

struct ISOBuffer {
void AdjustDataLength(int);
void AdvanceCurrentData(int);
};

struct VagDirEntryJak3 {
union {
u64 data;
Expand Down

0 comments on commit de163ba

Please sign in to comment.