Skip to content

Commit

Permalink
jak3: subtitle3, vag-player (#3758)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hat-Kid authored Nov 12, 2024
1 parent b55a918 commit af5cb9b
Show file tree
Hide file tree
Showing 48 changed files with 12,292 additions and 126 deletions.
8 changes: 6 additions & 2 deletions common/serialization/subtitles/subtitles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ const std::unordered_map<GameVersion, std::vector<std::string>> locale_lookup =
{GameVersion::Jak1,
{"en-US", "fr-FR", "de-DE", "es-ES", "it-IT", "jp-JP", "en-GB", "pt-PT", "fi-FI", "sv-SE",
"da-DK", "no-NO", "nl-NL", "pt-BR", "hu-HU", "ca-ES", "is-IS"}},
{GameVersion::Jak2, {"en-US", "fr-FR", "de-DE", "es-ES", "it-IT", "jp-JP", "ko-KR", "en-GB"}}};
{GameVersion::Jak2, {"en-US", "fr-FR", "de-DE", "es-ES", "it-IT", "jp-JP", "ko-KR", "en-GB"}},
{GameVersion::Jak3,
{"en-US", "fr-FR", "de-DE", "es-ES", "it-IT", "cm-CM", "jp-JP", "ko-KR", "ru-RU", "pt-PT",
"nl-NL", "en-GB"}}};

std::string lookup_locale_code(const GameVersion game_version, const int language_id) {
if (locale_lookup.find(game_version) == locale_lookup.end() ||
Expand All @@ -73,7 +76,8 @@ std::string lookup_locale_code(const GameVersion game_version, const int languag

const std::unordered_map<GameVersion, std::vector<int>> language_ids_with_audio = {
{GameVersion::Jak1, {0, 1, 2, 3, 4, 5, 6}},
{GameVersion::Jak2, {0, 1, 2, 3, 4, 5, 6, 7}}};
{GameVersion::Jak2, {0, 1, 2, 3, 4, 5, 6, 7}},
{GameVersion::Jak3, {0, 1, 2, 3, 4, 5, 11}}};

bool dump_language_with_duplicates_from_base(const GameVersion game_version,
const int language_id) {
Expand Down
81 changes: 76 additions & 5 deletions common/serialization/subtitles/subtitles_v2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,55 @@ const std::unordered_map<std::string, u16> jak2_speaker_name_to_enum_val = {
{"metalkor-before-consite", 35},
{"metalkor-intro", 36}};

// matches enum in `subtitle3-h.gc` with "none" (first) and "max" (last and removed)
const std::unordered_map<std::string, u16> jak3_speaker_name_to_enum_val = {
{"none", 0},
{"jak", 1},
{"darkjak", 2},
{"daxter", 3},
{"pecker", 4},
{"ashelin", 5},
{"veger", 6},
{"samos", 7},
{"damas", 8},
{"kleiver", 9},
{"seem", 10},
{"errol", 11},
{"errol-hologram", 12},
{"sig", 13},
{"torn", 14},
{"tess", 15},
{"guard", 16},
{"guard-a", 17},
{"guard-b", 18},
{"keira", 19},
{"vin", 20},
{"onin", 21},
{"jinx", 22},
{"wastelander-male", 23},
{"wastelander-female", 24},
{"citizen-male", 25},
{"citizen-female", 26},
{"marauder", 27},
{"oracle", 28},
{"precursor", 29},
{"ottsel-leader", 30},
{"ottsel-surfer", 31},
{"ottsel-dummy", 32},
{"ottsel-veger", 33},
{"ottsel-tess", 34},
{"computer", 35},
{"krew", 36},
{"baron", 37},
{"scherr", 38},
{"arey", 39},
{"baldwin", 40},
{"schimpf", 41},
{"martinsen", 42},
{"phillips", 43},
{"yates", 44},
};

GameSubtitlePackage read_json_files_v2(const GameSubtitleDefinitionFile& file_info) {
GameSubtitlePackage package;
SubtitleFile lang_lines;
Expand Down Expand Up @@ -256,11 +305,21 @@ void GameSubtitleBank::add_scenes_from_files(const GameSubtitlePackage& package)
}
}

// TODO - for jak 3+, this needs some game version context info (could infer from text version)
std::vector<std::string> GameSubtitleBank::speaker_names_ordered_by_enum_value() {
// Create a temporary vector of pairs (key, value)
std::vector<std::pair<std::string, u16>> temp_vec(jak2_speaker_name_to_enum_val.begin(),
jak2_speaker_name_to_enum_val.end());
std::vector<std::pair<std::string, u16>> temp_vec;
switch (m_text_version) {
case GameTextVersion::JAK2:
temp_vec = {jak2_speaker_name_to_enum_val.begin(), jak2_speaker_name_to_enum_val.end()};
break;
case GameTextVersion::JAK3:
temp_vec = {jak3_speaker_name_to_enum_val.begin(), jak3_speaker_name_to_enum_val.end()};
break;
default:
throw std::runtime_error(fmt::format("GameSubtitleBank: invalid game text version {} ({})",
(int)m_text_version,
get_text_version_name(m_text_version)));
}
// Sort the temporary vector based on the enum value in ascending order
std::sort(temp_vec.begin(), temp_vec.end(),
[](const auto& a, const auto& b) { return a.second < b.second; });
Expand All @@ -279,13 +338,25 @@ std::vector<std::string> GameSubtitleBank::speaker_names_ordered_by_enum_value()
}

u16 GameSubtitleBank::speaker_enum_value_from_name(const std::string& speaker_id) {
if (jak2_speaker_name_to_enum_val.find(speaker_id) == jak2_speaker_name_to_enum_val.end()) {
std::unordered_map<std::string, u16> enum_map;
switch (m_text_version) {
case GameTextVersion::JAK2:
enum_map = jak2_speaker_name_to_enum_val;
break;
case GameTextVersion::JAK3:
enum_map = jak3_speaker_name_to_enum_val;
break;
default:
throw std::runtime_error(fmt::format("GameSubtitleBank: invalid game text version {}",
get_text_version_name(m_text_version)));
}
if (enum_map.find(speaker_id) == enum_map.end()) {
throw std::runtime_error(
fmt::format("'{}' speaker could not be found in the enum value mapping, update it or fix "
"the invalid speaker!",
speaker_id));
}
return u16(jak2_speaker_name_to_enum_val.at(speaker_id));
return u16(enum_map.at(speaker_id));
}

SubtitleMetadataFile dump_bank_meta_v2(const GameVersion game_version,
Expand Down
2 changes: 1 addition & 1 deletion decompiler/config/jak3/all-types.gc
Original file line number Diff line number Diff line change
Expand Up @@ -8306,7 +8306,7 @@
(define-extern *font-default-matrix* matrix)
(define-extern *font-work* font-work)
(define-extern font-set-tex0 (function (pointer gs-tex0) texture int int int none))
(define-extern set-font-color (function font-color int rgba rgba rgba int))
(define-extern set-font-color (function font-color rgba rgba rgba rgba int))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; decomp-h ;;
Expand Down
2 changes: 1 addition & 1 deletion decompiler/config/jak3/jak3_config.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"write_hex_near_instructions": false,

// to write out "scripts", which are currently just all the linked lists found. mostly a jak 2/3 thing
"write_scripts": true,
"write_scripts": false,

// hex dump of code/data files.
"hexdump_code": false,
Expand Down
235 changes: 234 additions & 1 deletion decompiler/config/jak3/ntsc_v1/inputs.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,240 @@
"str_texture_file_names": ["STR/PRMINIMA.STR"],

// some objects are part of STR files (streaming data).
"str_file_names": [],
"str_file_names": [
"STR/ARF1INTR.STR",
"STR/ARF1RES.STR",
"STR/ARF2INTR.STR",
"STR/ARF2RES.STR",
"STR/ARF3INTR.STR",
"STR/ARF3RES.STR",
"STR/AROUTRO.STR",
"STR/ART1INTR.STR",
"STR/CAGSHIEL.STR",
"STR/CATRES.STR",
"STR/CAWRRES.STR",
"STR/CIATIDES.STR",
"STR/CIATOUT.STR",
"STR/CIBBINTR.STR",
"STR/CIBBRES.STR",
"STR/CIBTINTR.STR",
"STR/CIDGRES.STR",
"STR/CIFCEINT.STR",
"STR/CIGC1RES.STR",
"STR/CIGC2INT.STR",
"STR/CIGC2RES.STR",
"STR/CIGCINTR.STR",
"STR/CIGDPUNC.STR",
"STR/CIGTCINT.STR",
"STR/CIHVRES.STR",
"STR/CIPAIB.STR",
"STR/CIPAINTR.STR",
"STR/CIPARES.STR",
"STR/CIPFINTR.STR",
"STR/CIPGINTR.STR",
"STR/CIPGRES.STR",
"STR/CIPHINTR.STR",
"STR/CIPHRES.STR",
"STR/CISFINTR.STR",
"STR/COETEMPL.STR",
"STR/COEXIT.STR",
"STR/DAD06.STR",
"STR/DAD07.STR",
"STR/DAD10.STR",
"STR/DAD12.STR",
"STR/DAD13.STR",
"STR/DAD14.STR",
"STR/DAD16.STR",
"STR/DAD17.STR",
"STR/DAD18.STR",
"STR/DAD20.STR",
"STR/DAD21.STR",
"STR/DAD24.STR",
"STR/DAD31.STR",
"STR/DAD35.STR",
"STR/DAD38.STR",
"STR/DAD57.STR",
"STR/DAD58.STR",
"STR/DAD61.STR",
"STR/DAMOLE.STR",
"STR/DEAR1INT.STR",
"STR/DEAR1RES.STR",
"STR/DEAR2INT.STR",
"STR/DEATIN.STR",
"STR/DEATOUT.STR",
"STR/DEBBINTR.STR",
"STR/DECLINTR.STR",
"STR/DECRINTR.STR",
"STR/DECWIN.STR",
"STR/DEFBIA.STR",
"STR/DEFBINTR.STR",
"STR/DEFBRB.STR",
"STR/DEFBRES.STR",
"STR/DEGRES.STR",
"STR/DEHINTRO.STR",
"STR/DEHRES.STR",
"STR/DEJGOTA.STR",
"STR/DEJGOTB.STR",
"STR/DEJGOTC.STR",
"STR/DEJMINTR.STR",
"STR/DELC2.STR",
"STR/DELC3.STR",
"STR/DELCATCH.STR",
"STR/DEODRB.STR",
"STR/DEODRES.STR",
"STR/DERINTRO.STR",
"STR/DERRA.STR",
// "STR/DESCREEN.STR",
"STR/DPBTURRE.STR",
"STR/FABINTRO.STR",
"STR/FABRES.STR",
"STR/FAI1INTR.STR",
"STR/FAI2INTR.STR",
"STR/FAI3INTR.STR",
"STR/FAI4INTR.STR",
"STR/FASBIB.STR",
"STR/FASBINTR.STR",
"STR/FASBRES.STR",
"STR/FORB.STR",
"STR/FORCRES.STR",
"STR/FOTOMRES.STR",
"STR/FOTOWER.STR",
"STR/GRMANIMS.STR",
"STR/INDROP.STR",
"STR/INFFHQ.STR",
"STR/INLOST.STR",
"STR/INPALACE.STR",
"STR/INRESCUE.STR",
"STR/INTIRED.STR",
"STR/INTRAINI.STR",
"STR/JAA1.STR",
"STR/JAA2.STR",
"STR/JAA3.STR",
"STR/JAA4.STR",
"STR/JAA5.STR",
"STR/JAA6.STR",
"STR/JAA7.STR",
"STR/JABOARD.STR",
"STR/JACARRY.STR",
"STR/JAD1.STR",
"STR/JAD2.STR",
"STR/JAD3.STR",
"STR/JAD4.STR",
"STR/JAD5.STR",
"STR/JADARK.STR",
"STR/JADON.STR",
"STR/JADUMMY.STR",
"STR/JAEBOARD.STR",
"STR/JAEDARK.STR",
"STR/JAEGC.STR",
"STR/JAEGNORM.STR",
"STR/JAEGOLD.STR",
"STR/JAELIGHT.STR",
"STR/JAENORMA.STR",
// "STR/JAEXTERN.STR",
"STR/JAFLDAX.STR",
"STR/JAFLUT.STR",
"STR/JAGUN.STR",
"STR/JAICE.STR",
"STR/JAINDAX.STR",
"STR/JAKANGA.STR",
"STR/JALADDER.STR",
"STR/JALIGHT.STR",
"STR/JAMECH.STR",
"STR/JAPEGASU.STR",
"STR/JAPGLIDE.STR",
"STR/JAPGUN.STR",
"STR/JAPHCAR.STR",
"STR/JAPIDAX.STR",
"STR/JAPILOT.STR",
"STR/JAPOLE.STR",
"STR/JAPWCAR.STR",
"STR/JARACER.STR",
"STR/JASWIM.STR",
"STR/JATENTAC.STR",
"STR/JATUBE.STR",
"STR/JATURRET.STR",
"STR/KRWB1.STR",
"STR/KRWB2.STR",
"STR/KRWB3.STR",
"STR/MIBINTRO.STR",
"STR/MIBRES.STR",
"STR/MIERES.STR",
"STR/MIGEXIT.STR",
"STR/MITINTRO.STR",
"STR/MITRES.STR",
"STR/MU2ANIMS.STR",
"STR/MU3ANIMS.STR",
"STR/MU4ANIMS.STR",
"STR/MUANIMS.STR",
"STR/NEDBARRI.STR",
"STR/NEEINTRO.STR",
"STR/NEHINTRO.STR",
"STR/NEHRES.STR",
"STR/NSB1BREA.STR",
"STR/NSB2BREA.STR",
"STR/PARAINTR.STR",
"STR/PARARA.STR",
"STR/PARARES.STR",
"STR/PARPINTR.STR",
"STR/PEFLY.STR",
"STR/POAINTRO.STR",
"STR/PRDSERES.STR",
"STR/PRDSLOSE.STR",
"STR/PRDSRES.STR",
"STR/PRHA.STR",
"STR/PRHB.STR",
"STR/PRHC.STR",
"STR/PRHFINAL.STR",
// "STR/PRMINIMA.STR",
"STR/PRTRES.STR",
"STR/RATA1INT.STR",
"STR/RATA2INT.STR",
// "STR/SCBOOK.STR",
"STR/SEEINTRO.STR",
"STR/SEGENTRA.STR",
"STR/SEHKENTR.STR",
"STR/SEHKRES.STR",
"STR/SEKENTRA.STR",
"STR/SEKEXIT.STR",
"STR/SEKMINTR.STR",
"STR/SEMEXIT.STR",
"STR/SEMHINTR.STR",
"STR/SEPEXIT.STR",
"STR/SESGRUNT.STR",
"STR/SEWATERS.STR",
"STR/TECINTRO.STR",
"STR/TECRES.STR",
"STR/TEDINTRO.STR",
"STR/TEDRES.STR",
"STR/TEEANIMS.STR",
"STR/TEELAANI.STR",
"STR/TEELODS.STR",
"STR/TEJGLGLI.STR",
"STR/TEOINTRO.STR",
"STR/TEORES.STR",
"STR/TETINTRO.STR",
"STR/TETRA.STR",
"STR/TETRB.STR",
"STR/TEWDESER.STR",
"STR/TODINTRO.STR",
"STR/TODRB.STR",
"STR/TODRES.STR",
"STR/VODRES.STR",
"STR/VOI1INTR.STR",
"STR/VOI1RES.STR",
"STR/VOI2INTR.STR",
"STR/VOI2RES.STR",
"STR/WACINTRO.STR",
"STR/WADRES.STR",
"STR/WAGINTRO.STR",
"STR/WAGRES.STR",
"STR/WALRINTR.STR",
"STR/WALRRES.STR",
"STR/WAPGINTR.STR",
"STR/WAPGRES.STR"
// "STR/WOMAP.STR"
],

// streaming "art" that should be added to GAME.FR3.
"str_art_file_names": ["STR/JAEXTERN.STR"],
Expand Down
3 changes: 3 additions & 0 deletions decompiler/config/jak3/ntsc_v1/var_names.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -2141,5 +2141,8 @@
"a2-1": ["a2-1", "uint"],
"a3-0": ["a3-0", "uint"]
}
},
"set-font-color": {
"args": ["idx", "clr0", "clr1", "clr2", "clr3"]
}
}
Loading

0 comments on commit af5cb9b

Please sign in to comment.