diff --git a/common/goos/Interpreter.cpp b/common/goos/Interpreter.cpp index 2d9ccdd70b..446704be11 100644 --- a/common/goos/Interpreter.cpp +++ b/common/goos/Interpreter.cpp @@ -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. diff --git a/common/goos/Interpreter.h b/common/goos/Interpreter.h index fb2c69ca6f..55ebfb83fa 100644 --- a/common/goos/Interpreter.h +++ b/common/goos/Interpreter.h @@ -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& env); Object intern(const std::string& name); HeapObject* intern_ptr(const std::string& name); diff --git a/decompiler/extractor/extractor_util.hpp b/decompiler/extractor/extractor_util.hpp index 7f15d0430d..3331601a5c 100644 --- a/decompiler/extractor/extractor_util.hpp +++ b/decompiler/extractor/extractor_util.hpp @@ -39,7 +39,8 @@ static const std::unordered_map sGameIsoFlagNames = { static const std::unordered_map 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> 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()); diff --git a/decompiler/extractor/main.cpp b/decompiler/extractor/main.cpp index 92dd4836a9..a1f553a059 100644 --- a/decompiler/extractor/main.cpp +++ b/decompiler/extractor/main.cpp @@ -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"; diff --git a/game/kernel/common/kboot.h b/game/kernel/common/kboot.h index 458a2680a4..56ee7ddbda 100644 --- a/game/kernel/common/kboot.h +++ b/game/kernel/common/kboot.h @@ -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(); \ No newline at end of file +void kboot_init_globals_common(); diff --git a/goal_src/goal-lib.gc b/goal_src/goal-lib.gc index 774683b3d1..a717eaf3d4 100644 --- a/goal_src/goal-lib.gc +++ b/goal_src/goal-lib.gc @@ -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 ;;;;;;;;;;;;;;;;;;; diff --git a/goal_src/goos-lib.gs b/goal_src/goos-lib.gs index 549db06b27..9e24c1da9f 100644 --- a/goal_src/goos-lib.gs +++ b/goal_src/goos-lib.gs @@ -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) \ No newline at end of file diff --git a/goal_src/jak1/compiler-setup.gc b/goal_src/jak1/compiler-setup.gc index 6c8ec31863..611421d1c0 100644 --- a/goal_src/jak1/compiler-setup.gc +++ b/goal_src/jak1/compiler-setup.gc @@ -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 diff --git a/goal_src/jak1/engine/game/main.gc b/goal_src/jak1/engine/game/main.gc index 028bd35bec..9ba802bd59 100644 --- a/goal_src/jak1/engine/game/main.gc +++ b/goal_src/jak1/engine/game/main.gc @@ -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 ;;;;;;;;;;;;;;;;;;;;;; diff --git a/goal_src/jak1/engine/game/settings.gc b/goal_src/jak1/engine/game/settings.gc index ea4135e63c..751c00d5d1 100644 --- a/goal_src/jak1/engine/game/settings.gc +++ b/goal_src/jak1/engine/game/settings.gc @@ -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) + ) + ) + +) + + diff --git a/goal_src/jak1/pc/pckernel-h.gc b/goal_src/jak1/pc/pckernel-h.gc index 63ff833245..5c366b0fb7 100644 --- a/goal_src/jak1/pc/pckernel-h.gc +++ b/goal_src/jak1/pc/pckernel-h.gc @@ -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)) diff --git a/goal_src/jak1/pc/pckernel-impl.gc b/goal_src/jak1/pc/pckernel-impl.gc index b33b659edd..1cc9cad236 100644 --- a/goal_src/jak1/pc/pckernel-impl.gc +++ b/goal_src/jak1/pc/pckernel-impl.gc @@ -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)) ) diff --git a/goal_src/jak2/engine/ps2/pad.gc b/goal_src/jak2/engine/ps2/pad.gc index 2b8ad86b89..a2efa9d36e 100644 --- a/goal_src/jak2/engine/ps2/pad.gc +++ b/goal_src/jak2/engine/ps2/pad.gc @@ -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*) ) ) diff --git a/goal_src/jak2/pc/debug/default-menu-pc.gc b/goal_src/jak2/pc/debug/default-menu-pc.gc index 7f305a576e..7b0d5e4359 100644 --- a/goal_src/jak2/pc/debug/default-menu-pc.gc +++ b/goal_src/jak2/pc/debug/default-menu-pc.gc @@ -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*)) diff --git a/goalc/make/MakeSystem.cpp b/goalc/make/MakeSystem.cpp index 40c42be099..98d92f282a 100644 --- a/goalc/make/MakeSystem.cpp +++ b/goalc/make/MakeSystem.cpp @@ -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); +} diff --git a/goalc/make/MakeSystem.h b/goalc/make/MakeSystem.h index b7c75b8252..99f168db58 100644 --- a/goalc/make/MakeSystem.h +++ b/goalc/make/MakeSystem.h @@ -62,6 +62,7 @@ class MakeSystem { void add_tool(std::shared_ptr 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 void add_tool() {