Skip to content

Commit de163ba

Browse files
committed
wip
1 parent 4cf0a1d commit de163ba

File tree

5 files changed

+110
-30
lines changed

5 files changed

+110
-30
lines changed

game/common/dgo_rpc_types.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ struct RPC_Dgo_Cmd {
4040
uint32_t buffer2;
4141
uint32_t buffer_heap_top;
4242
char name[16];
43-
uint16_t cgo_id;
44-
uint8_t pad[30];
43+
uint32_t cgo_id;
44+
uint8_t pad[28];
4545
};
4646
static_assert(sizeof(RPC_Dgo_Cmd) == 0x40);
4747
} // namespace jak3

game/overlord/jak3/basefile.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#pragma once
22

3-
#include "game/overlord/jak3/iso.h"
43
#include "game/overlord/jak3/iso_structs.h"
54
#include "game/overlord/jak3/overlord.h"
65

game/overlord/jak3/iso.cpp

Lines changed: 87 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,21 @@ namespace jak3 {
1313
using namespace iop;
1414

1515
CBaseFileSystem* g_pFileSystem;
16+
int g_nISOThreadID;
1617
int g_nDGOThreadID;
1718
int g_nSTRThreadID;
1819
int g_nPlayThreadID;
20+
int g_nISOMbx;
1921

2022
static int s_nISOInitFlag;
2123
static ISO_LoadDGO s_LoadDGO;
2224
static int s_nSyncMbx;
2325
static MsgPacket s_MsgPacket_NotOnStackSync[2];
2426
static RPC_Dgo_Cmd s_aISO_RPCBuf[1];
27+
static int s_nDGOMbx;
2528

26-
static void* RPC_DGO(u32 fno, void* data, int size) {
27-
lg::error("RPC_DGO UNIMPLEMENTED");
28-
return nullptr;
29-
}
30-
31-
static u32 DGOThread() {
32-
sceSifQueueData dq;
33-
sceSifServeData serve;
34-
35-
CpuDisableIntr();
36-
sceSifInitRpc(0);
37-
sceSifSetRpcQueue(&dq, GetThreadId());
38-
sceSifRegisterRpc(&serve, 0xfab3, RPC_DGO, s_aISO_RPCBuf, sizeof(s_aISO_RPCBuf), nullptr, nullptr,
39-
&dq);
40-
CpuEnableIntr();
41-
sceSifRpcLoop(&dq);
42-
43-
return 0;
44-
}
29+
static u32 DGOThread();
30+
u32 ISOThread();
4531

4632
/* COMPLETE */
4733
void InitDriver() {
@@ -79,6 +65,25 @@ int InitISOFS(const char* fs_mode, const char* loading_sceeen) {
7965
s_nISOInitFlag = 1;
8066
g_pFileSystem = &g_FakeISOCDFileSystem;
8167

68+
mbx.attr = 0;
69+
mbx.option = 0;
70+
g_nISOMbx = CreateMbx(&mbx);
71+
72+
mbx.attr = 0;
73+
mbx.option = 0;
74+
s_nDGOMbx = CreateMbx(&mbx);
75+
76+
mbx.attr = 0;
77+
mbx.option = 0;
78+
s_nSyncMbx = CreateMbx(&mbx);
79+
80+
thp.attr = TH_C;
81+
thp.entry = ISOThread;
82+
thp.initPriority = 0x37;
83+
thp.option = 0;
84+
thp.stackSize = 0x1100;
85+
g_nISOThreadID = CreateThread(&thp);
86+
8287
thp.attr = TH_C;
8388
thp.entry = DGOThread;
8489
thp.initPriority = 0x38;
@@ -100,13 +105,76 @@ int InitISOFS(const char* fs_mode, const char* loading_sceeen) {
100105
thp.stackSize = 0x900;
101106
g_nPlayThreadID = CreateThread(&thp);
102107

108+
StartThread(g_nISOThreadID, 0);
103109
StartThread(g_nDGOThreadID, 0);
104110
StartThread(g_nSTRThreadID, 0);
105111
StartThread(g_nPlayThreadID, 0);
106112

107113
return s_nISOInitFlag;
108114
}
109115

116+
u32 ISOThread() {
117+
while (true) {
118+
DelayThread(4000);
119+
}
120+
121+
return 0;
122+
}
123+
124+
static void ISO_LoadDGO(RPC_Dgo_Cmd* msg);
125+
static void ISO_LoadNextDGO(RPC_Dgo_Cmd* msg);
126+
static void ISO_CancelDGO(RPC_Dgo_Cmd* msg);
127+
128+
static void* RPC_DGO(u32 fno, void* data, int size) {
129+
auto* msg = static_cast<RPC_Dgo_Cmd*>(data);
130+
131+
switch (fno) {
132+
case 0:
133+
ISO_LoadDGO(msg);
134+
break;
135+
case 1:
136+
ISO_LoadNextDGO(msg);
137+
break;
138+
case 2:
139+
ISO_CancelDGO(msg);
140+
break;
141+
default:
142+
msg->result = 1;
143+
break;
144+
}
145+
return data;
146+
}
147+
148+
static u32 DGOThread() {
149+
sceSifQueueData dq;
150+
sceSifServeData serve;
151+
152+
CpuDisableIntr();
153+
sceSifInitRpc(0);
154+
sceSifSetRpcQueue(&dq, GetThreadId());
155+
sceSifRegisterRpc(&serve, 0xfab3, RPC_DGO, s_aISO_RPCBuf, sizeof(s_aISO_RPCBuf), nullptr, nullptr,
156+
&dq);
157+
CpuEnableIntr();
158+
sceSifRpcLoop(&dq);
159+
160+
return 0;
161+
}
162+
163+
static void ISO_LoadDGO(RPC_Dgo_Cmd* msg) {
164+
auto* def = g_pFileSystem->Find(msg->name);
165+
if (def == nullptr) {
166+
msg->result = 1;
167+
return;
168+
}
169+
170+
msg->buffer1 = msg->buffer_heap_top;
171+
msg->result = 0;
172+
}
173+
174+
static void ISO_LoadNextDGO(RPC_Dgo_Cmd* msg) {}
175+
176+
static void ISO_CancelDGO(RPC_Dgo_Cmd* msg) {}
177+
110178
/* COMPLETE */
111179
const ISOFileDef* FindISOFile(char* name) {
112180
return g_pFileSystem->Find(name);

game/overlord/jak3/iso.h

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
11
#pragma once
22

3+
#include "game/overlord/jak3/basefile.h"
34
#include "game/sce/iop.h"
45

56
namespace jak3 {
67

7-
struct ISOBuffer {
8-
void AdjustDataLength(int);
9-
void AdvanceCurrentData(int);
10-
};
11-
128
struct ISO_Hdr {
13-
iop::MsgPacket msg;
9+
iop::MsgPacket m_Pkt;
10+
int m_nStatus;
11+
bool m_bActive;
12+
bool unk1;
13+
bool unk2;
1414

1515
void SetActive();
1616
void SetUnk1();
1717
void SetUnk2();
1818
};
1919

20-
struct ISO_Msg : ISO_Hdr {};
20+
struct ISO_Msg : ISO_Hdr {
21+
u32 cmd_kind;
22+
int mbx_to_reply;
23+
int thread_id;
24+
void* callback;
25+
CBaseFile* file;
26+
};
2127

22-
struct ISO_LoadDGO : ISO_Msg {};
28+
struct ISO_LoadDGO : ISO_Msg {
29+
ISOFileDef* fd;
30+
};
2331

2432
int InitISOFS(const char* fs_mode, const char* loading_sceeen);
2533
} // namespace jak3

game/overlord/jak3/iso_structs.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ namespace jak3 {
66
/* TODO check values */
77
enum class EFileComp { MODE0, MODE1, KNOWN_NOT_BLZO };
88

9+
struct ISOBuffer {
10+
void AdjustDataLength(int);
11+
void AdvanceCurrentData(int);
12+
};
13+
914
struct VagDirEntryJak3 {
1015
union {
1116
u64 data;

0 commit comments

Comments
 (0)