overlord: implement the branch needed to load text files

This commit is contained in:
Tyler Wilding
2022-10-06 23:13:43 -04:00
parent 2e45e11f41
commit f5d8fa2adb
8 changed files with 129 additions and 12 deletions
+4 -4
View File
@@ -17009,8 +17009,8 @@
(get-quat (_type_) quaternion 21)
(get-transv (_type_) vector 22)
(process-focusable-method-23 (_type_) none 23)
(process-focusable-method-24 (_type_) none 24)
(process-focusable-method-25 (_type_) int 25)
(process-focusable-method-24 (_type_) float 24)
(process-focusable-method-25 (_type_) time-frame 25)
(process-focusable-method-26 (_type_) none 26)
)
)
@@ -19986,7 +19986,7 @@
(tracking-spline-method-19 (_type_ float vector tracking-spline-sampler) vector 19)
(tracking-spline-method-20 (_type_ vector int) none 20)
(tracking-spline-method-21 (_type_ vector float float float) vector 21)
(tracking-spline-method-22 (_type_ float) none 22)
(tracking-spline-method-22 (_type_ float) symbol 22) ;; TODO - probably wrong!
(debug-draw-spline (_type_) none 23)
)
)
@@ -20204,7 +20204,7 @@
(:methods
(camera-master-method-14 (_type_ vector) vector 14)
(camera-master-method-15 (_type_ vector) vector 15)
(camera-master-method-16 (_type_ symbol) none 16)
(camera-master-method-16 (_type_ symbol) int 16)
)
)
+12
View File
@@ -0,0 +1,12 @@
;; "project file" for text make tool.
;; it's very simple... a list of (action args...)
;; currently the only action available is 'file'
;; and it takes 1 argument: input filename.
(text
;; NOTE : we compile using the fixed v2 encoding because it's what we use.
(file "$DECOMP/assets/game_text.txt") ;; this is the decompiler-generated file!
;; add custom files down here
)
+41 -1
View File
@@ -8,7 +8,22 @@
constexpr PerGameVersion<int> STR_RPC_ID(0xdeb5, 0xfab4);
constexpr int STR_RPC_CHANNEL = 4;
struct RPC_Str_Cmd {
/*
(deftype load-chunk-msg (structure)
((rsvd uint16 :offset-assert 0)
(result load-msg-result :offset-assert 2)
(address pointer :offset-assert 4)
(section uint32 :offset-assert 8)
(maxlen uint32 :offset-assert 12)
(id uint32 :offset 4)
(basename uint8 48 :offset-assert 16)
)
:method-count-assert 9
:size-assert #x40
:flag-assert #x900000040
)
*/
struct RPC_Str_Cmd_Jak1 {
u16 rsvd; // 0, seems unused
u16 result; // 2, return code. see STR_RPC_RESULT_XXX
u32 ee_addr; // 4, GOAL address to load to.
@@ -18,6 +33,31 @@ struct RPC_Str_Cmd {
char name[64]; // file name
};
/*
(deftype load-chunk-msg (structure)
((rsvd uint16 :offset-assert 0)
(result load-msg-result :offset-assert 2)
(address pointer :offset-assert 4)
(section uint32 :offset-assert 8)
(maxlen uint32 :offset-assert 12)
(dummy uint32 4 :offset-assert 16)
(basename sound-stream-name :inline :offset-assert 32)
)
:method-count-assert 9
:size-assert #x50
:flag-assert #x900000050
)
*/
struct RPC_Str_Cmd_Jak2 {
u16 rsvd;
u16 result; // 2
u32 address;
s32 section; // 8
u32 maxlen;
u32 dummy[4];
char basename[48]; // 32
};
struct RPC_Play_Cmd {
u16 rsvd;
u16 result;
+48 -4
View File
@@ -21,7 +21,7 @@
using namespace iop;
static RPC_Str_Cmd sSTRBuf;
static RPC_Str_Cmd_Jak2 sSTRBuf;
static RPC_Play_Cmd sPLAYBuf[2]; // todo type
void* RPC_STR(unsigned int fno, void* _cmd, int y);
void* RPC_PLAY(unsigned int fno, void* _cmd, int y);
@@ -48,7 +48,7 @@ constexpr int STR_INDEX_CACHE_SIZE = 4;
CacheEntry sCache[STR_INDEX_CACHE_SIZE];
void stream_init_globals() {
memset(&sSTRBuf, 0, sizeof(RPC_Str_Cmd));
memset(&sSTRBuf, 0, sizeof(RPC_Str_Cmd_Jak2));
memset(&sPLAYBuf, 0, sizeof(RPC_Play_Cmd));
}
@@ -84,10 +84,10 @@ u32 PLAYThread() {
/*!
* The STR RPC handler.
*/
void* RPC_STR(unsigned int fno, void* _cmd, int y) {
void* RPC_STR_jak1(unsigned int fno, void* _cmd, int y) {
(void)fno;
(void)y;
auto* cmd = (RPC_Str_Cmd*)_cmd;
auto* cmd = (RPC_Str_Cmd_Jak1*)_cmd;
if (cmd->chunk_id < 0) {
// it's _not_ a stream file. So we just treat it like a normal load.
@@ -162,6 +162,50 @@ void* RPC_STR(unsigned int fno, void* _cmd, int y) {
return cmd;
}
/*!
* The STR RPC handler.
*/
void* RPC_STR_jak2(unsigned int fno, void* _cmd, int y) {
(void)fno;
(void)y;
auto* cmd = (RPC_Str_Cmd_Jak2*)_cmd;
if (cmd->section < 0) {
// it's _not_ a stream file. So we just treat it like a normal load.
// find the file with the given name
auto file_record = isofs->find(cmd->basename);
if (file_record == nullptr) {
// file not found!
printf("[OVERLORD STR] Failed to find file %s for loading.\n", cmd->basename);
cmd->result = STR_RPC_RESULT_ERROR;
} else {
// load directly to the EE
cmd->maxlen = LoadISOFileToEE(file_record, cmd->address, cmd->maxlen);
if (cmd->maxlen) {
// successful load!
cmd->result = STR_RPC_RESULT_DONE;
} else {
// there was an error loading.
cmd->result = STR_RPC_RESULT_ERROR;
}
}
} else {
// TODO - not ret implemented
cmd->result = STR_RPC_RESULT_ERROR;
}
return cmd;
}
void* RPC_STR(unsigned int fno, void* _cmd, int y) {
if (g_game_version == GameVersion::Jak1) {
return RPC_STR_jak1(fno, _cmd, y);
}
else if (g_game_version == GameVersion::Jak2) {
return RPC_STR_jak2(fno, _cmd, y);
}
}
void* RPC_PLAY([[maybe_unused]] unsigned int fno, void* _cmd, int size) {
s32 n_messages = size / PLAY_MSG_SIZE;
char namebuf[16];
+2 -2
View File
@@ -380,7 +380,7 @@
;; Text
;;;;;;;;;;;;;;;;;;;;;
(defstep :in "game/assets/game_text.gp"
(defstep :in "game/assets/jak1/game_text.gp"
:tool 'text
:out '("$OUT/iso/0COMMON.TXT"
"$OUT/iso/1COMMON.TXT"
@@ -391,7 +391,7 @@
"$OUT/iso/6COMMON.TXT")
)
(defstep :in "game/assets/game_subtitle.gp"
(defstep :in "game/assets/jak1/game_subtitle.gp"
:tool 'subtitle
:out '("$OUT/iso/0SUBTIT.TXT"
"$OUT/iso/3SUBTIT.TXT"
+22 -1
View File
@@ -659,6 +659,22 @@
"blocking-plane-ag"
)
;;;;;;;;;;;;;;;;;;;;;
;; Text
;;;;;;;;;;;;;;;;;;;;;
(defstep :in "game/assets/jak2/game_text.gp"
:tool 'text
:out '("$OUT/iso/0COMMON.TXT"
"$OUT/iso/1COMMON.TXT"
"$OUT/iso/2COMMON.TXT"
"$OUT/iso/3COMMON.TXT"
"$OUT/iso/4COMMON.TXT"
"$OUT/iso/5COMMON.TXT"
"$OUT/iso/6COMMON.TXT"
"$OUT/iso/7COMMON.TXT")
)
;;;;;;;;;;;;;;;;;;;;;
;; COMMON CITY STUFF
;;;;;;;;;;;;;;;;;;;;;
@@ -797,7 +813,8 @@
;; the iso group is a group of files built by the "(mi)" command.
(group-list "iso"
`(,@(reverse *all-vis*)
`("$OUT/iso/0COMMON.TXT"
,@(reverse *all-vis*)
,@(reverse *all-str*)
,@(reverse *all-sbk*)
,@(reverse *all-mus*)
@@ -805,6 +822,10 @@
,@(reverse *all-cgos*))
)
(group-list "text"
`("$OUT/iso/0COMMON.TXT")
)
;; used for the type consistency test.
(group-list "all-code"
`(,@(reverse *all-gc*))