diff --git a/decompiler/config/jak2/all-types.gc b/decompiler/config/jak2/all-types.gc index b95d2159ce..2326238fc2 100644 --- a/decompiler/config/jak2/all-types.gc +++ b/decompiler/config/jak2/all-types.gc @@ -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) ) ) diff --git a/game/assets/game_subtitle.gp b/game/assets/jak1/game_subtitle.gp similarity index 100% rename from game/assets/game_subtitle.gp rename to game/assets/jak1/game_subtitle.gp diff --git a/game/assets/game_text.gp b/game/assets/jak1/game_text.gp similarity index 100% rename from game/assets/game_text.gp rename to game/assets/jak1/game_text.gp diff --git a/game/assets/jak2/game_text.gp b/game/assets/jak2/game_text.gp new file mode 100644 index 0000000000..978f13e157 --- /dev/null +++ b/game/assets/jak2/game_text.gp @@ -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 + ) + + diff --git a/game/common/str_rpc_types.h b/game/common/str_rpc_types.h index d461176cd5..3481689aab 100644 --- a/game/common/str_rpc_types.h +++ b/game/common/str_rpc_types.h @@ -8,7 +8,22 @@ constexpr PerGameVersion 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; diff --git a/game/overlord/stream.cpp b/game/overlord/stream.cpp index b7055d32bf..237630deda 100644 --- a/game/overlord/stream.cpp +++ b/game/overlord/stream.cpp @@ -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]; diff --git a/goal_src/jak1/game.gp b/goal_src/jak1/game.gp index 9e08736160..980d66a168 100644 --- a/goal_src/jak1/game.gp +++ b/goal_src/jak1/game.gp @@ -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" diff --git a/goal_src/jak2/game.gp b/goal_src/jak2/game.gp index 87b2f067fa..aa1758f98d 100644 --- a/goal_src/jak2/game.gp +++ b/goal_src/jak2/game.gp @@ -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*))