[extractor] fix territory being set to wrong value (#2946)

Also fixes a minor issue where the JP sound bank wouldn't work (Jak 1).

Fixes #2793
This commit is contained in:
ManDude 2023-08-30 18:36:10 +01:00 committed by GitHub
parent f85ed7457d
commit 6e8b0e57c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 61 additions and 37 deletions

View file

@ -240,6 +240,10 @@ void Interpreter::set_global_variable_to_symbol(const std::string& name, const s
set_global_variable_by_name(name, sym);
}
void Interpreter::set_global_variable_to_int(const std::string& name, int value) {
set_global_variable_by_name(name, Object::make_integer(value));
}
/*!
* Get arguments being passed to a form. Don't evaluate them. There are two modes, "varargs" and
* "not varargs". With varargs enabled, any number of unnamed and named arguments can be given.

View file

@ -22,6 +22,7 @@ class Interpreter {
bool get_global_variable_by_name(const std::string& name, Object* dest);
void set_global_variable_by_name(const std::string& name, const Object& value);
void set_global_variable_to_symbol(const std::string& name, const std::string& value);
void set_global_variable_to_int(const std::string& name, int value);
Object eval(Object obj, const std::shared_ptr<EnvironmentObject>& env);
Object intern(const std::string& name);
HeapObject* intern_ptr(const std::string& name);

View file

@ -39,7 +39,8 @@ static const std::unordered_map<std::string, GameIsoFlags> sGameIsoFlagNames = {
static const std::unordered_map<int, std::string> sGameIsoTerritoryMap = {
{GAME_TERRITORY_SCEA, "NTSC-U"},
{GAME_TERRITORY_SCEE, "PAL"},
{GAME_TERRITORY_SCEI, "NTSC-J"}};
{GAME_TERRITORY_SCEI, "NTSC-J"},
{GAME_TERRITORY_SCEK, "NTSC-K"}};
std::string get_territory_name(int territory) {
ASSERT_MSG(sGameIsoTerritoryMap.count(territory),
@ -100,8 +101,6 @@ static const ISOMetadata jak1_ntsc_black_label_info = {
"jak1",
{"jak1-black-label"}};
// TODO - we don't detect or handle ntsc_v2?
// { SERIAL : { ELF_HASH : ISOMetadataDatabase } }
static const std::unordered_map<std::string, std::unordered_map<uint64_t, ISOMetadata>> isoDatabase{
{"SCUS-97124",
@ -155,7 +154,7 @@ ISOMetadata get_version_info_or_default(const fs::path& iso_data_path) {
const auto build_info = get_buildinfo_from_path(iso_data_path);
if (!build_info) {
lg::warn(
"unable locate buildinfo.json file in iso data path, defaulting to Jak 1 - NTSC-U Black "
"unable to locate buildinfo.json file in iso data path, defaulting to Jak 1 - NTSC-U Black "
"Label");
} else {
auto maybe_version_info = get_version_info_from_build_info(build_info.value());

View file

@ -208,9 +208,11 @@ ExtractorErrorCode compile(const fs::path& iso_data_path, const std::string& dat
}
}
compiler.get_goos().set_global_variable_to_int("*default-territory*", version_info.region);
if (version_info.game_name == "jak1") {
compiler.make_system().set_constant("*jak1-full-game*", !(flags & FLAG_JAK1_BLACK_LABEL));
compiler.make_system().set_constant("*jak1-territory*", version_info.region);
compiler.get_goos().set_global_variable_to_symbol(
"*jak1-full-game*", (flags & FLAG_JAK1_BLACK_LABEL) ? "#t" : "#f");
}
auto project_path = file_util::get_jak_project_dir() / "goal_src" / data_subfolder / "game.gp";

View file

@ -4,6 +4,7 @@
#define GAME_TERRITORY_SCEA 0 // sony america
#define GAME_TERRITORY_SCEE 1 // sony europe
#define GAME_TERRITORY_SCEI 2 // sony inc. (japan)
#define GAME_TERRITORY_SCEK 3 // sony korea
enum class RuntimeExitStatus {
RUNNING = 0,
@ -57,4 +58,4 @@ extern MasterConfig masterConfig;
/*!
* Initialize global variables for kboot
*/
void kboot_init_globals_common();
void kboot_init_globals_common();

View file

@ -917,6 +917,11 @@
`(make-group "text")
)
;; the default territory the game was built for. overriden in extractor.
;; this just fetches the goos constant with the same name (TODO fix this)
(defmacro __get_default_territory () *default-territory*)
(defconstant *default-territory* (__get_default_territory))
;;;;;;;;;;;;;;;;;;;
;; enum stuff
;;;;;;;;;;;;;;;;;;;

View file

@ -499,9 +499,10 @@
(define GAME_TERRITORY_SCEA 0)
(define GAME_TERRITORY_SCEE 1)
(define GAME_TERRITORY_SCEI 2)
(define GAME_TERRITORY_SCEK 3)
(define *jak1-full-game* (if (user? dass) #t #f))
(define *jak1-territory* GAME_TERRITORY_SCEA)
(define *default-territory* GAME_TERRITORY_SCEA)
;; whether to enable ps3 test levels for jak 2
(define USE_PS3_LEVELS #f)

View file

@ -13,8 +13,6 @@
(defmacro __get_jak1_full_game () *jak1-full-game*)
(defconstant *jak1-full-game* (__get_jak1_full_game))
(defmacro __get_jak1_territory () *jak1-territory*)
(defconstant *jak1-territory* (__get_jak1_territory))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; TYPE STUFF

View file

@ -350,25 +350,6 @@
(none)
)
;;;;;;;;;;;;;;;;;;;;;;
;; opengoal territory override
;;;;;;;;;;;;;;;;;;;;;;
(defun scf-get-territory ()
"this overrides the kernel version which usually has a hardcoded value."
(if (not *debug-segment*)
(return *jak1-territory*))
(case (-> *setting-control* default language)
(((language-enum japanese))
GAME_TERRITORY_SCEI)
(((language-enum english))
GAME_TERRITORY_SCEA)
(else
GAME_TERRITORY_SCEE)
)
)
;;;;;;;;;;;;;;;;;;;;;;
;; Cheat Codes
;;;;;;;;;;;;;;;;;;;;;;

View file

@ -488,5 +488,28 @@
(#when PC_PORT
;;;;;;;;;;;;;;;;;;;;;;
;; opengoal territory override
;;;;;;;;;;;;;;;;;;;;;;
(defun scf-get-territory ()
"this overrides the kernel version which usually has a hardcoded value."
(if (not *debug-segment*)
(return *default-territory*))
(case (-> *setting-control* default language)
(((language-enum japanese))
GAME_TERRITORY_SCEI)
(((language-enum english))
GAME_TERRITORY_SCEA)
(else
GAME_TERRITORY_SCEE)
)
)
)

View file

@ -196,8 +196,10 @@
(first-camera-v-inverted? symbol) ;; first-person vertical camera inverted
(third-camera-h-inverted? symbol) ;; third-person horizontal camera inverted
(third-camera-v-inverted? symbol) ;; third-person vertical camera inverted
(music-fadeout? symbol) ;; music fadeout toggle.
(music-fadein? symbol) ;; music fadein toggle.
(music-fadeout? symbol) ;; music fadeout toggle.
(music-fadein? symbol) ;; music fadein toggle.
(territory int16)
(bingo pc-bingo-info :inline) ;; bingo integration. does nothing for now.
@ -401,6 +403,8 @@
(set! (-> obj hinttitles?) #t)
(set! (-> obj subtitle-speaker?) 'auto)
(reset-camera obj call-handlers)
(set! (-> obj territory) *default-territory*)
0)
(defmethod reset-camera pc-settings ((obj pc-settings) (call-handlers symbol))

View file

@ -161,11 +161,11 @@
(set! (-> obj skip-movies?) #t)
(set! (-> obj subtitles?) *debug-segment*)
(cond
((and (= *jak1-territory* GAME_TERRITORY_SCEE) (= (-> obj text-language) (pc-language english)))
((and (= *default-territory* GAME_TERRITORY_SCEE) (= (-> obj text-language) (pc-language english)))
(set! (-> obj text-language) (pc-language uk-english))
;(set! (-> obj subtitle-language) (pc-language uk-english))
)
((= *jak1-territory* GAME_TERRITORY_SCEI)
((= *default-territory* GAME_TERRITORY_SCEI)
(set! (-> obj text-language) (pc-language japanese))
;(set! (-> obj subtitle-language) (pc-language japanese))
)

View file

@ -71,12 +71,12 @@ The cpad-set-buzz! function can be used for vibration.
(#when PC_PORT
;; redefined from C kernel
(define *scf-territory-debug* GAME_TERRITORY_SCEA)
(define *debug-territory* GAME_TERRITORY_SCEA)
(defun scf-get-territory ()
"redefined from C kernel for convenience"
(if *debug-segment*
*scf-territory-debug*
*scf-territory-debug*)
*debug-territory*
*default-territory*)
)
)

View file

@ -765,8 +765,8 @@
(defun dm-territory-pick-func ((bterr int) (msg debug-menu-msg))
(let ((terr (/ bterr 8)))
(when (= msg (debug-menu-msg press))
(set! *scf-territory-debug* terr))
(= *scf-territory-debug* terr)))
(set! *debug-territory* terr))
(= *debug-territory* terr)))
(when (-> *debug-menu-context* root-menu)
;; (debug-menu-append-item (-> *debug-menu-context* root-menu) (debug-menu-make-load-menu *debug-menu-context*))

View file

@ -511,3 +511,7 @@ void MakeSystem::set_constant(const std::string& name, const std::string& value)
void MakeSystem::set_constant(const std::string& name, bool value) {
m_goos.set_global_variable_to_symbol(name, value ? "#t" : "#f");
}
void MakeSystem::set_constant(const std::string& name, int value) {
m_goos.set_global_variable_to_int(name, value);
}

View file

@ -62,6 +62,7 @@ class MakeSystem {
void add_tool(std::shared_ptr<Tool> tool);
void set_constant(const std::string& name, const std::string& value);
void set_constant(const std::string& name, bool value);
void set_constant(const std::string& name, int value);
template <typename T>
void add_tool() {