Skip to content

Commit 01d5fc2

Browse files
authored
[jak3] Decomp for gkernel, gkernel-h, gstate, gstring (#3326)
I ported the kernel test from jak1/jak2 to jak 3, and it's passing!
1 parent 638bf1d commit 01d5fc2

File tree

27 files changed

+8867
-386
lines changed

27 files changed

+8867
-386
lines changed

decompiler/config/jak3/all-types.gc

Lines changed: 316 additions & 246 deletions
Large diffs are not rendered by default.
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1-
{}
1+
{
2+
"gkernel": [
3+
[17, "(function process symbol)"],
4+
[24, "(function process symbol)"],
5+
[26, "(function process symbol)"],
6+
[29, "(function process symbol)"],
7+
[32, "(function process symbol)"],
8+
[34, "(function process symbol)"],
9+
[36, "(function process symbol)"]
10+
]
11+
}

decompiler/config/jak3/ntsc_v1/type_casts.jsonc

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,43 @@
3131
],
3232
"(method 0 cpu-thread)": [[[0, 35], "v0", "cpu-thread"]],
3333
"(method 0 process)": [
34-
// [11, "a0", "int"],
35-
// [[12, 45], "v0", "process"]
34+
[11, "a0", "int"],
35+
[[12, 52], "v0", "process"]
3636
],
37+
"inspect-process-heap": [
38+
[[4, 11], "s5", "basic"],
39+
[17, "s5", "pointer"]
40+
],
41+
"(method 14 dead-pool)": [
42+
[[24, 25], "v1", "(pointer process)"],
43+
[[30, 39], "s4", "(pointer process)"]
44+
],
45+
"(method 24 dead-pool-heap)": [
46+
[5, "v1", "pointer"],
47+
[13, "a0", "pointer"],
48+
[25, "v1", "pointer"]
49+
],
50+
"(method 14 dead-pool)": [
51+
[[24, 25], "v1", "(pointer process)"],
52+
[[30, 39], "s4", "(pointer process)"]
53+
],
54+
"method-state": [[12, "a2", "state"]],
55+
"(method 0 protect-frame)": [
56+
[0, "a0", "int"],
57+
[[1, 8], "v0", "protect-frame"]
58+
],
59+
"(method 9 process)": [[[58, 61], "s5", "process"]],
60+
"(method 10 process)": [[[24, 30], "s4", "protect-frame"]],
61+
"string-cat-to-last-char": [
62+
[3, "s5", "(pointer uint8)"],
63+
[4, "s5", "string"]
64+
],
65+
"enter-state": [
66+
[70, "s0", "protect-frame"],
67+
[103, "t9", "(function object object object object object object none)"]
68+
],
69+
"send-event-function": [[[7, 15], "a0", "process"]],
70+
3771
"logf": [
3872
[12, "f0", "float"],
3973
[12, "f1", "float"],

decompiler/config/jak3/ntsc_v1/var_names.jsonc

Lines changed: 236 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,173 @@
167167
"err-msg-dest"
168168
]
169169
},
170+
"(method 0 process-tree)": {
171+
"args": ["allocation", "type-to-make", "name"]
172+
},
173+
"(method 0 process)": {
174+
"args": ["allocation", "type-to-make", "name"]
175+
},
176+
"(method 9 process-tree)": {
177+
"args": ["this", "active-tree", "name", "stack-pointer"]
178+
},
179+
"(method 9 process)": {
180+
"args": ["this", "active-tree", "name", "stack-pointer"]
181+
},
182+
"(method 10 process-tree)": {
183+
"args": ["this", "ent"]
184+
},
185+
"(method 0 clock)": {
186+
"args": ["allocation", "type-to-make", "index"]
187+
},
188+
"(method 9 clock)": {
189+
"args": ["this", "rate"]
190+
},
191+
"(method 16 clock)": {
192+
"args": ["this", "xor-val"]
193+
},
194+
"(method 17 clock)": {
195+
"args": ["this", "xor-val"]
196+
},
197+
"(method 18 clock)": {
198+
"args": ["this", "xor-val"]
199+
},
200+
"(method 19 clock)": {
201+
"args": ["this", "xor-val"]
202+
},
203+
"(method 20 clock)": {
204+
"args": ["this", "xor-val"]
205+
},
206+
"(method 21 clock)": {
207+
"args": ["this", "xor-val"]
208+
},
209+
"(method 22 clock)": {
210+
"args": ["this", "xor-val"]
211+
},
212+
"(method 23 clock)": {
213+
"args": ["this", "xor-val"]
214+
},
215+
"(method 9 thread)": {
216+
"args": ["this", "size-bytes"]
217+
},
218+
"(method 0 cpu-thread)": {
219+
"args": [
220+
"allocation",
221+
"type-to-make",
222+
"proc",
223+
"name",
224+
"stack-size",
225+
"stack-top"
226+
]
227+
},
228+
"(method 0 dead-pool)": {
229+
"args": ["allocation", "type-to-make", "num-proc", "process-size", "name"]
230+
},
231+
"(method 14 dead-pool)": {
232+
"args": ["this", "proc-type", "proc-size", "unk"]
233+
},
234+
"(method 14 dead-pool-heap)": {
235+
"args": ["this", "proc-type", "proc-size", "unk"]
236+
},
237+
"(method 15 dead-pool)": {
238+
"args": ["this", "proc"]
239+
},
240+
"(method 15 dead-pool-heap)": {
241+
"args": ["this", "proc"]
242+
},
243+
"(method 0 dead-pool-heap)": {
244+
"args": ["allocation", "type-to-make", "name", "max-num-proc", "heap-size"]
245+
},
246+
"(method 16 dead-pool-heap)": {
247+
"args": ["this", "allocation", "heap-size"]
248+
},
249+
"(method 17 dead-pool-heap)": {
250+
"args": ["this", "compact-count"]
251+
},
252+
"(method 18 dead-pool-heap)": {
253+
"args": ["this", "proc"]
254+
},
255+
"(method 19 dead-pool-heap)": {
256+
"args": ["this", "count"]
257+
},
258+
"(method 24 dead-pool-heap)": {
259+
"args": ["this", "first-rec"]
260+
},
261+
"(method 25 dead-pool-heap)": {
262+
"args": ["this", "rec"]
263+
},
264+
"(method 26 dead-pool-heap)": {
265+
"args": ["this", "first-rec"]
266+
},
267+
"(method 27 dead-pool-heap)": {
268+
"args": ["this", "size"]
269+
},
270+
"(method 0 protect-frame)": {
271+
"args": ["stack-addr", "type-to-make", "exit-func"]
272+
},
273+
"(method 0 process)": {
274+
"args": ["allocation", "type-to-make", "name", "process-heap-size"]
275+
},
276+
"(method 0 sql-result)": {
277+
"args": ["allocation", "type-to-make", "num-elts"]
278+
},
279+
"load-package": {
280+
"args": ["package-name", "heap"]
281+
},
282+
"unload-package": {
283+
"args": ["package-name"]
284+
},
285+
"inspect-process-heap": {
286+
"args": ["proc"]
287+
},
288+
"method-state": {
289+
"args": ["typ", "state-name"]
290+
},
291+
"process-by-name": {
292+
"args": ["process-name", "tree"]
293+
},
294+
"process-not-name": {
295+
"args": ["name", "tree"]
296+
},
297+
"process-count": {
298+
"args": ["tree"]
299+
},
300+
"kill-by-name": {
301+
"args": ["name", "tree"]
302+
},
303+
"kill-by-type": {
304+
"args": ["typ", "tree"]
305+
},
306+
"kill-not-name": {
307+
"args": ["name", "tree"]
308+
},
309+
"kill-not-type": {
310+
"args": ["typ", "tree"]
311+
},
312+
"kill-by-type-inherited": {
313+
"args": ["typ", "tree"]
314+
},
315+
"iterate-process-tree": {
316+
"args": ["tree", "callback", "context"]
317+
},
318+
"execute-process-tree": {
319+
"args": ["tree", "callback", "context"]
320+
},
321+
"search-process-tree": {
322+
"args": ["tree", "callback"]
323+
},
324+
"inspect-process-tree": {
325+
"args": ["tree", "depth", "mask", "detail"]
326+
},
327+
"previous-brother": {
328+
"args": ["tree"]
329+
},
330+
"change-parent": {
331+
"args": ["proc-to-change", "new-parent"]
332+
},
333+
"change-to-last-brother": {
334+
"args": ["proc"]
335+
},
336+
170337
"matrix-transpose!": {
171338
"args": ["dst", "src"]
172339
},
@@ -178,5 +345,74 @@
178345
},
179346
"vector-rad<-vector-deg!": {
180347
"args": ["out", "in"]
348+
},
349+
"copy-string<-string": {
350+
"args": ["dst", "src"]
351+
},
352+
"string=": {
353+
"args": ["a", "b"]
354+
},
355+
"string-prefix=": {
356+
"args": ["prefix", "str"]
357+
},
358+
"charp-prefix=": {
359+
"args": ["prefix", "str"]
360+
},
361+
"string-suffix=": {
362+
"args": ["suffix", "str"]
363+
},
364+
"string-position": {
365+
"args": ["substr", "base-str"]
366+
},
367+
"string-charp=": {
368+
"args": ["a", "b"]
369+
},
370+
"name=": {
371+
"args": ["a", "b"]
372+
},
373+
"copyn-string<-charp": {
374+
"args": ["dst", "src", "num-chars"]
375+
},
376+
"string<-charp": {
377+
"args": ["dst", "src"]
378+
},
379+
"charp<-string": {
380+
"args": ["dst", "src"]
381+
},
382+
"copyn-charp<-string": {
383+
"args": ["dst", "src", "len"]
384+
},
385+
"copy-charp<-charp": {
386+
"args": ["dst", "src"]
387+
},
388+
"cat-string<-string": {
389+
"args": ["dst", "src"]
390+
},
391+
"catn-string<-charp": {
392+
"args": ["dst", "src", "num-chars"]
393+
},
394+
"cat-string<-string_to_charp": {
395+
"args": ["dst", "src", "stop-ptr"]
396+
},
397+
"append-character-to-string": {
398+
"args": ["str", "char"]
399+
},
400+
"charp-basename": {
401+
"args": ["str"]
402+
},
403+
"clear": {
404+
"args": ["str"]
405+
},
406+
"string<?": {
407+
"args": ["a", "b"]
408+
},
409+
"string>?": {
410+
"args": ["a", "b"]
411+
},
412+
"string<=?": {
413+
"args": ["a", "b"]
414+
},
415+
"string>=?": {
416+
"args": ["a", "b"]
181417
}
182418
}

game/common/dgo_rpc_types.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ struct RPC_Dgo_Cmd {
2626
uint32_t buffer2;
2727
uint32_t buffer_heap_top;
2828
char name[16];
29+
30+
// note: padding this a bit so the jak 3 commands can get sent to overlord without overflowing
31+
// a buffer.
32+
uint8_t pad[32];
2933
};
3034

3135
namespace jak3 {
@@ -40,4 +44,6 @@ struct RPC_Dgo_Cmd {
4044
uint8_t pad[30];
4145
};
4246
static_assert(sizeof(RPC_Dgo_Cmd) == 0x40);
43-
} // namespace jak3
47+
} // namespace jak3
48+
49+
static_assert(sizeof(RPC_Dgo_Cmd) == sizeof(jak3::RPC_Dgo_Cmd));

game/overlord/jak2/iso_cd.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,13 @@ uint32_t FS_LoadSoundBank(char* name, SoundBank* buffer);
8080
uint32_t FS_LoadMusic(char* name, snd::BankHandle* buffer);
8181
u32 FS_SyncRead();
8282

83+
struct FakeCd {
84+
int offset_into_file = 0;
85+
FILE* fp = nullptr;
86+
void (*callback)(int) = nullptr;
87+
FileRecord* last_fr = nullptr;
88+
} gFakeCd;
89+
8390
void iso_cd_init_globals() {
8491
ReadPagesCurrentPage = nullptr;
8592
DvdSema = -1;
@@ -110,6 +117,7 @@ void iso_cd_init_globals() {
110117
iso_cd.load_sound_bank = FS_LoadSoundBank;
111118
iso_cd.load_music = FS_LoadMusic;
112119
iso_cd.sync_read = FS_SyncRead;
120+
gFakeCd.last_fr = nullptr;
113121
}
114122

115123
static FILE* open_fr(FileRecord* fr, s32 thread_to_wake) {
@@ -124,13 +132,6 @@ static FILE* open_fr(FileRecord* fr, s32 thread_to_wake) {
124132
// Sony Fake CD Functions
125133
///////////////////////////
126134

127-
struct FakeCd {
128-
int offset_into_file = 0;
129-
FILE* fp = nullptr;
130-
void (*callback)(int) = nullptr;
131-
FileRecord* last_fr = nullptr;
132-
} gFakeCd;
133-
134135
auto sceCdCallback(void (*callback)(int)) {
135136
auto ret = gFakeCd.callback;
136137
gFakeCd.callback = callback;

game/runtime.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ void ee_runner(SystemThreadInterface& iface) {
229229
break;
230230
case GameVersion::Jak3:
231231
jak3::goal_main(g_argc, g_argv);
232+
break;
232233
default:
233234
ASSERT_MSG(false, "Unsupported game version");
234235
}

goal_src/jak3/kernel/dgo-h.gc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,24 @@
77

88
;; DECOMP BEGINS
99

10+
(deftype dgo-header (structure)
11+
((length uint32)
12+
(rootname uint8 60)
13+
)
14+
)
15+
16+
17+
(deftype dgo-entry (structure)
18+
((offset uint32)
19+
(length uint32)
20+
)
21+
)
22+
23+
24+
(deftype dgo-file (basic)
25+
((num-go-files uint32)
26+
(total-length uint32)
27+
(rsvd uint32)
28+
(data uint8 :dynamic)
29+
)
30+
)

0 commit comments

Comments
 (0)