From 1f3df0e69ff8414106e55bd17f6933f945391207 Mon Sep 17 00:00:00 2001 From: Tyler Wilding Date: Sat, 8 Oct 2022 21:04:21 -0400 Subject: [PATCH] d/jak2: fix issues associated with loading text --- common/util/FontUtils.cpp | 141 +++++++++++++++++++++--------- game/kernel/jak2/klink.h | 1 + game/kernel/jak2/kscheme.cpp | 4 +- game/overlord/stream.cpp | 15 ++-- goal_src/jak2/engine/game/main.gc | 4 +- 5 files changed, 116 insertions(+), 49 deletions(-) diff --git a/common/util/FontUtils.cpp b/common/util/FontUtils.cpp index f613a6664b..429a0fd8c3 100644 --- a/common/util/FontUtils.cpp +++ b/common/util/FontUtils.cpp @@ -120,8 +120,8 @@ std::string GameTextFontBank::replace_to_utf8(std::string& str) const { } std::string GameTextFontBank::replace_to_game(std::string& str) const { for (auto& info : *m_replace_info) { - // TODO - THIS IS A TEMPORARY HACK!, can't replace with nothing as it's not unique! if (info.to.empty()) { + // Skip empty replacements, else it's an infinite loop continue; } auto pos = str.find(info.to); @@ -854,11 +854,12 @@ static std::vector s_replace_info_jak2 = { // tildes {"N~Y~-22H~-4V~Z", "Ñ"}, {"n~Y~-24H~-4V~Z", "ñ"}, - {"A~Y~-21H~-5V~Z", "Ã"}, // custom - {"O~Y~-22H~-4V~Z", "Õ"}, // custom + {"A~Y~-21H~-5V~Z", "Ã"}, + {"O~Y~-22H~-4V~Z", "Õ"}, // acute accents {"A~Y~-21H~-5V'~Z", "Á"}, + {"A~Y~-26H~-8V'~Z", "<Á_V2>"}, // unfortunate... {"a~Y~-25H~-5V'~Z", "á"}, {"E~Y~-23H~-9V'~Z", "É"}, {"e~Y~-26H~-5V'~Z", "é"}, @@ -870,13 +871,13 @@ static std::vector s_replace_info_jak2 = { {"u~Y~-24H~-3V'~Z", "ú"}, // circumflex - {"A~Y~-20H~-4V^~Z", "Â"}, // custom + {"A~Y~-20H~-4V^~Z", "Â"}, {"a~Y~-24H~-5V^~Z", "â"}, {"E~Y~-20H~-5V^~Z", "Ê"}, {"e~Y~-25H~-4V^~Zt", "ê"}, {"I~Y~-19H~-5V^~Z", "Î"}, {"i~Y~-19H~-8V^~Z", "î"}, - {"O~Y~-20H~-4V^~Z", "Ô"}, // custom + {"O~Y~-20H~-4V^~Z", "Ô"}, {"o~Y~-25H~-4V^~Z", "ô"}, {"U~Y~-24H~-3V^~Z", "Û"}, {"u~Y~-23H~-3V^~Z", "û"}, @@ -888,7 +889,8 @@ static std::vector s_replace_info_jak2 = { {"e~Y~-26H~-5V`~Z", "è"}, {"I~Y~-19H~-5V`~Z", "Ì"}, {"i~Y~-19H~-8V`~Z", "ì"}, - {"O~Y~-22H~-4V`~Z", "Ò"}, // custom + {"O~Y~-22H~-4V`~Z", "Ò"}, + {"o~Y~-26H~-4V`~Z", "ò"}, {"U~Y~-24H~-3V`~Z", "Ù"}, {"u~Y~-24H~-3V`~Z", "ù"}, @@ -896,7 +898,7 @@ static std::vector s_replace_info_jak2 = { {"A~Y~-26H~-8V¨~Z", "Ä"}, {"a~Y~-25H~-5V¨~Z", "ä"}, {"E~Y~-20H~-5V¨~Z", "Ë"}, - {"I~Y~-19H~-5V¨~Z", "Ï"}, // custom + {"I~Y~-19H~-5V¨~Z", "Ï"}, {"O~Y~-26H~-8V¨~Z", "Ö"}, {"o~Y~-26H~-4V¨~Z", "ö"}, {"U~Y~-25H~-8V¨~Z", "Ü"}, @@ -965,58 +967,69 @@ static std::vector s_replace_info_jak2 = { {"~~", "世"}, // playstation buttons + // - face {"~Y~22L<~Z~Y~27L*~Z~Y~1L>~Z~Y~23L[~Z~+26H", ""}, {"~Y~22L<~Z~Y~26L;~Z~Y~1L>~Z~Y~23L[~Z~+26H", ""}, {"~Y~22L<~Z~Y~25L@~Z~Y~1L>~Z~Y~23L[~Z~+26H", ""}, - {"~Y~22L<~Z~Y~24L#~Z~Y~1L>~Z~Y~23L[~Z~+26H", ""}, // custom - {"~Y~22L~-2H~-12V\\ca6\\ca7~Z~22L~-2H~+17V\\cb0\\cb1~Z~1L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, - {"~Y~1L\\c85~Z~39L\\c87~\\c5d~-1H~Y~1L\\c85~Z~39L\\c88~Z~-11H~7L\\c8a~Z~-11H~3L\\c89~Z~+26H", + {"~Y~6L~Z~+15H~1L~Z~+30H~3L~Z~+45H", ""}, + {"~Y~5L~Z~3L~~-1H~Y~5L~Z~3L~Z~+26H", ""}, + {"~Y~39L~~~Z~3L~Z~5L~~-1H~Y~39L~~~Z~3L~Z~5L~Z~+26H", + ""}, + {"~Y~7L~Z~+15H~1L~Z~+30H~3L~Z~+47H", ""}, + {"~Y~1L~Z~3L~Z~7L~~-1H~Y~1L~Z~3L~Z~7L~Z~+26H", + ""}, + {"~Y~1L~Z~3L~Z~7L~~-1H~Y~1L~Z~3L~Z~+26H", + ""}, + {"~Y~1L~Z~39L~~-1H~Y~1L~Z~39L~Z~-11H~7L~Z~-11H~3L<" + "SYM43>~Z~+26H", ""}, - {"~Y~1L\\c85~\\c5d~-1H~Y~1L\\c85~Z~-11H~3L\\c86~Z~+26H", ""}, + {"~Y~1L~~-1H~Y~1L~Z~-11H~3L~Z~+26H", ""}, // weird stuff - // - some sort of control character to adjust kerning, ie after `i` and `o`? - {"~+7V", ""}, - // - preceeding character has a descender? - {"~-7V", ""}, - // - i wonder if this is just a generic code to say "push the next character up or down - // vertically"? - {"~+1V", ""}, - {"~-1V", ""}, + // - descenders + {"~+7Vp~-7V", "p"}, + {"~+7Vy~-7V", "y"}, + {"~+7Vg~-7V", "g"}, + {"~+7Vq~-7V", "q"}, + {"~+1Vj~-1V", "j"}, + {"\\\\\\\\", "\\n"}, + + // - symbols and ligatures {"~-4H~-3V\\c19~+3V~-4H", ""}, // used for the 4<__> place in spanish. the 5th uses the same // character but looks different...? {"~Y~-6Hº~Z~+10H", "°"}, - {"\\c5e", "œ"}, // ligature o+e // Color / Emphasis {"~[~1L", ""}, @@ -1037,10 +1050,60 @@ static std::vector s_encode_info_jak2 = { {"ß", {0x1f}}, // eszett + {"œ", {0x5e}}, // ligature o+e + // Re-purposed japanese/korean symbols that are used as part of drawing icons/flags/pad buttons + // TODO - japanese and korean encodings + {"", {0x5d}}, + + {"", {0x7f}}, + {"", {0x80}}, + {"", {0x81}}, + + {"", {0x85}}, + {"", {0x86}}, + {"", {0x87}}, + {"", {0x88}}, + {"", {0x89}}, + {"", {0x8a}}, + {"", {0x8b}}, + {"", {0x8c}}, + {"", {0x8d}}, + {"", {0x8e}}, + {"", {0x8f}}, + {"", {0x90}}, + {"", {0x91}}, + + {"", {0x94}}, + {"", {0x95}}, + {"", {0x96}}, + {"", {0x97}}, + {"", {0x98}}, + {"", {0x99}}, + {"", {0x9a}}, + {"", {0x9b}}, + {"", {0x9c}}, + {"", {0x9d}}, + {"", {0x9e}}, + {"", {0x9f}}, + {"", {0xa0}}, + {"", {0xa1}}, + {"", {0xa2}}, + {"", {0xa3}}, + {"", {0xa4}}, + {"", {0xa5}}, + {"", {0xa6}}, + {"", {0xa7}}, + {"", {0xa8}}, + {"", {0xa9}}, + {"", {0xb0}}, + {"", {0xb1}}, + {"", {0xb3}}, + {"", {0xb2}}, }; GameTextFontBank g_font_bank_jak2(GameTextVersion::JAK2, &s_encode_info_jak2, + //&s_replace_info_null, &s_replace_info_jak2, &s_passthrus_jak2); diff --git a/game/kernel/jak2/klink.h b/game/kernel/jak2/klink.h index 5417d9cead..a7036956a2 100644 --- a/game/kernel/jak2/klink.h +++ b/game/kernel/jak2/klink.h @@ -13,6 +13,7 @@ Ptr link_and_exec(Ptr data, Ptr heap, uint32_t flags, bool jump_from_c_to_goal); +u64 link_and_exec_wrapper(u64* args); u32 link_busy(); void link_reset(); uint64_t link_begin(u64* args); diff --git a/game/kernel/jak2/kscheme.cpp b/game/kernel/jak2/kscheme.cpp index 35afc14031..0cbc3b5d67 100644 --- a/game/kernel/jak2/kscheme.cpp +++ b/game/kernel/jak2/kscheme.cpp @@ -1652,7 +1652,7 @@ int InitHeapAndSymbol() { make_function_symbol_from_c("kmemclose", (void*)kmemclose); make_function_symbol_from_c("new-dynamic-structure", (void*)new_dynamic_structure); make_function_symbol_from_c("method-set!", (void*)method_set); - make_stack_arg_function_symbol_from_c("link", (void*)link_and_exec); + make_stack_arg_function_symbol_from_c("link", (void*)link_and_exec_wrapper); make_function_symbol_from_c("link-busy?", (void*)link_busy); make_function_symbol_from_c("link-reset", (void*)link_reset); make_function_symbol_from_c("dgo-load", (void*)load_and_link_dgo); @@ -1770,4 +1770,4 @@ s64 load_and_link(const char* /*filename*/, ASSERT(false); return 0; } -} // namespace jak2 \ No newline at end of file +} // namespace jak2 diff --git a/game/overlord/stream.cpp b/game/overlord/stream.cpp index 21841704d7..ed4e7e5d26 100644 --- a/game/overlord/stream.cpp +++ b/game/overlord/stream.cpp @@ -8,6 +8,7 @@ #include +#include "common/log/log.h" #include "common/util/Assert.h" #include "game/common/play_rpc_types.h" @@ -66,12 +67,13 @@ u32 STRThread() { sceSifInitRpc(0); sceSifSetRpcQueue(&dq, GetThreadId()); if (g_game_version == GameVersion::Jak1) { - sceSifRegisterRpc(&serve, STR_RPC_ID[g_game_version], RPC_STR_jak1, &sSTRBufJak1, nullptr, nullptr, &dq); + sceSifRegisterRpc(&serve, STR_RPC_ID[g_game_version], RPC_STR_jak1, &sSTRBufJak1, nullptr, + nullptr, &dq); + } else if (g_game_version == GameVersion::Jak2) { + sceSifRegisterRpc(&serve, STR_RPC_ID[g_game_version], RPC_STR_jak2, &sSTRBufJak2, nullptr, + nullptr, &dq); } - else if (g_game_version == GameVersion::Jak2) { - sceSifRegisterRpc(&serve, STR_RPC_ID[g_game_version], RPC_STR_jak2, &sSTRBufJak2, nullptr, nullptr, &dq); - } - + CpuEnableIntr(); sceSifRpcLoop(&dq); return 0; @@ -199,7 +201,8 @@ void* RPC_STR_jak2(unsigned int fno, void* _cmd, int y) { } } } else { - // TODO - not ret implemented + // TODO - not yet implemented + lg::warn("this branch of RPC_STR has not yet been implemented!"); cmd->result = STR_RPC_RESULT_ERROR; } diff --git a/goal_src/jak2/engine/game/main.gc b/goal_src/jak2/engine/game/main.gc index 71f2cf4645..ad4024b029 100644 --- a/goal_src/jak2/engine/game/main.gc +++ b/goal_src/jak2/engine/game/main.gc @@ -390,7 +390,7 @@ (and (!= *cheat-mode* 'camera) (or (zero? *screen-shot-work*) (= (-> *screen-shot-work* count) -1))) ) (draw-string-xy - "pause or something like that" ;;(lookup-text! *common-text* (game-text-id pause) #f) + (lookup-text! *common-text* (game-text-id pause) #f) buf 256 (if (< (-> *display* base-clock frame-counter) (-> *game-info* letterbox-time)) @@ -539,7 +539,7 @@ ) ;; load text files as needed from the menu update - ; (load-level-text-files -1) + (load-level-text-files -1) ;; post-processing filter drawing ; (if (-> *screen-filter* draw?)