From de163badea585aaa7a55f7d7bd7d4f7ec9ad8bda Mon Sep 17 00:00:00 2001 From: Ziemas Date: Wed, 1 May 2024 23:55:00 +0200 Subject: [PATCH] wip --- game/common/dgo_rpc_types.h | 4 +- game/overlord/jak3/basefile.h | 1 - game/overlord/jak3/iso.cpp | 106 +++++++++++++++++++++++++------ game/overlord/jak3/iso.h | 24 ++++--- game/overlord/jak3/iso_structs.h | 5 ++ 5 files changed, 110 insertions(+), 30 deletions(-) diff --git a/game/common/dgo_rpc_types.h b/game/common/dgo_rpc_types.h index 14e7523e335..f4b6709f43e 100644 --- a/game/common/dgo_rpc_types.h +++ b/game/common/dgo_rpc_types.h @@ -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 diff --git a/game/overlord/jak3/basefile.h b/game/overlord/jak3/basefile.h index 1c0225b4452..b5ec389955b 100644 --- a/game/overlord/jak3/basefile.h +++ b/game/overlord/jak3/basefile.h @@ -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" diff --git a/game/overlord/jak3/iso.cpp b/game/overlord/jak3/iso.cpp index 4448c09acad..bf8c1d50474 100644 --- a/game/overlord/jak3/iso.cpp +++ b/game/overlord/jak3/iso.cpp @@ -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() { @@ -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; @@ -100,6 +105,7 @@ 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); @@ -107,6 +113,68 @@ int InitISOFS(const char* fs_mode, const char* loading_sceeen) { 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(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); diff --git a/game/overlord/jak3/iso.h b/game/overlord/jak3/iso.h index 4e03d677f4c..d8fd39abab7 100644 --- a/game/overlord/jak3/iso.h +++ b/game/overlord/jak3/iso.h @@ -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 diff --git a/game/overlord/jak3/iso_structs.h b/game/overlord/jak3/iso_structs.h index 68cb5d2fd19..2c66fdcaea6 100644 --- a/game/overlord/jak3/iso_structs.h +++ b/game/overlord/jak3/iso_structs.h @@ -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;