diff --git a/common/type_system/TypeSpec.cpp b/common/type_system/TypeSpec.cpp index c20bda33de..fa64b41509 100644 --- a/common/type_system/TypeSpec.cpp +++ b/common/type_system/TypeSpec.cpp @@ -67,15 +67,20 @@ TypeSpec TypeSpec::substitute_for_method_call(const std::string& method_type) co } bool TypeSpec::is_compatible_child_method(const TypeSpec& implementation, - const std::string& child_type) const { + const std::string& child_type, + int* bad_arg_idx_out) const { bool ok = implementation.m_type == m_type || (m_type == "_type_" && implementation.m_type == child_type); if (!ok || implementation.arg_count() != arg_count()) { + if (bad_arg_idx_out) + *bad_arg_idx_out = -1; return false; } for (size_t i = 0; i < arg_count(); i++) { if (!get_arg(i).is_compatible_child_method(implementation.get_arg(i), child_type)) { + if (bad_arg_idx_out) + *bad_arg_idx_out = i; return false; } } diff --git a/common/type_system/TypeSpec.h b/common/type_system/TypeSpec.h index 79c696f37b..4e117dc58d 100644 --- a/common/type_system/TypeSpec.h +++ b/common/type_system/TypeSpec.h @@ -79,7 +79,8 @@ class TypeSpec { bool operator!=(const TypeSpec& other) const; bool operator==(const TypeSpec& other) const; bool is_compatible_child_method(const TypeSpec& implementation, - const std::string& child_type) const; + const std::string& child_type, + int* bad_arg_idx_out = nullptr) const; std::string print() const; void add_arg(const TypeSpec& ts) { diff --git a/common/type_system/TypeSystem.cpp b/common/type_system/TypeSystem.cpp index a90fd4c9be..dbf31b8e00 100644 --- a/common/type_system/TypeSystem.cpp +++ b/common/type_system/TypeSystem.cpp @@ -645,12 +645,21 @@ MethodInfo TypeSystem::define_method(Type* type, bool got_existing = try_lookup_method(type, method_name, &existing_info); if (got_existing) { - // make sure we aren't changing anything. - if (!existing_info.type.is_compatible_child_method(ts, type->get_name())) { + int bad_arg_idx = -99; + // make sure we aren't changing anything that isn't the return type. + if (!existing_info.type.is_compatible_child_method(ts, type->get_name(), &bad_arg_idx) && + bad_arg_idx != ts.arg_count() - 1) { throw_typesystem_error( "The method {} of type {} was originally defined as {}, but has been " - "redefined as {}\n", - method_name, type->get_name(), existing_info.type.print(), ts.print()); + "redefined as {} (see argument index {})\n", + method_name, type->get_name(), existing_info.type.print(), ts.print(), bad_arg_idx); + } else if (bad_arg_idx == ts.arg_count() - 1 && + !tc(existing_info.type.last_arg(), ts.last_arg())) { + throw_typesystem_error( + "The method {} of type {} was originally defined as returning {}, but has been redefined " + "and returns {}\n", + method_name, type->get_name(), existing_info.type.last_arg().print(), + ts.last_arg().print()); } return existing_info; diff --git a/decompiler/config/jak2/all-types.gc b/decompiler/config/jak2/all-types.gc index 9b35cb3df0..4cd137475a 100644 --- a/decompiler/config/jak2/all-types.gc +++ b/decompiler/config/jak2/all-types.gc @@ -6304,10 +6304,10 @@ ;; +++font-h:font-color (defenum font-color :type uint32 - (default-#cddbcd 0) + (default 0) (#dadada 1) (#ededed 2) - (precursor-#ec3b00 3) + (red 3) (gold-#ba9200 4) (yellow-#f3f300 5) (green-#3df23d 6) @@ -6324,7 +6324,7 @@ (#a6b5a6 17) (#757f75 18) (#5e3f5e 19) - (#f0e387 20) + (flat-yellow 20) (#3fbaed 21) (#3a3a3a 22) (#5c5c5c 23) diff --git a/game/graphics/pipelines/opengl.cpp b/game/graphics/pipelines/opengl.cpp index 79b4590429..1ee600d743 100644 --- a/game/graphics/pipelines/opengl.cpp +++ b/game/graphics/pipelines/opengl.cpp @@ -466,22 +466,6 @@ void render_game_frame(int game_width, options.gpu_sync = g_gfx_data->debug_gui.should_gl_finish(); options.borderless_windows_hacks = windows_borderless_hack; - // hack for jak 2 resize - if (g_game_version == GameVersion::Jak2) { - float ratio = 0.75 * (float)window_fb_width / (float)window_fb_height; - if (ratio > 1) { - window_fb_width /= ratio; - } else { - window_fb_height *= ratio; - } - options.game_res_w = window_fb_width; - options.game_res_h = window_fb_height; - options.window_framebuffer_width = window_fb_width; - options.window_framebuffer_height = window_fb_height; - options.draw_region_width = window_fb_width; - options.draw_region_height = window_fb_height; - } - if (want_hotkey_screenshot && g_gfx_data->debug_gui.screenshot_hotkey_enabled) { options.save_screenshot = true; std::string screenshot_file_name = make_hotkey_screenshot_file_name(); diff --git a/game/kernel/common/Symbol4.h b/game/kernel/common/Symbol4.h index c423f5bab1..57b95e7545 100644 --- a/game/kernel/common/Symbol4.h +++ b/game/kernel/common/Symbol4.h @@ -1,6 +1,7 @@ #pragma once #include "common/common_types.h" +#include "common/goal_constants.h" #include "common/util/Assert.h" #include "game/kernel/common/Ptr.h" @@ -11,7 +12,7 @@ struct Symbol4 { T& value() { return *reinterpret_cast(&foo - 1); } const T& value() const { return *reinterpret_cast(&foo - 1); } const char* name_cstr() const { - ASSERT_MSG(false, "nyi"); - return nullptr; + return (const char*)(g_ee_main_mem + 4 + + *reinterpret_cast(&foo + jak2::SYM_TO_STRING_OFFSET)); } }; diff --git a/game/kernel/common/kmachine.cpp b/game/kernel/common/kmachine.cpp index 912d5cb98c..a17cfcc44b 100644 --- a/game/kernel/common/kmachine.cpp +++ b/game/kernel/common/kmachine.cpp @@ -367,6 +367,14 @@ void c_memmove(u32 dst, u32 src, u32 size) { memmove(Ptr(dst).c(), Ptr(src).c(), size); } +void set_game_resolution(s64 w, s64 h) { + Gfx::set_game_resolution(w, h); +} + +void set_msaa(s64 samples) { + Gfx::set_msaa(samples); +} + /*! * Returns size of window. Called from game thread */ @@ -540,7 +548,7 @@ u64 pc_filter_debug_string(u32 str_ptr, u32 dist_ptr) { // Check distance first if (Gfx::g_debug_settings.debug_text_check_range) { - if (dist / 4096.0 > Gfx::g_debug_settings.debug_text_max_range) { + if (dist / 4096.F > Gfx::g_debug_settings.debug_text_max_range) { return s7.offset + true_symbol_offset(g_game_version); } } diff --git a/game/kernel/common/kmachine.h b/game/kernel/common/kmachine.h index da26e8230d..6d942c4cc9 100644 --- a/game/kernel/common/kmachine.h +++ b/game/kernel/common/kmachine.h @@ -59,6 +59,8 @@ u64 DecodeInactiveTimeout(); void DecodeTime(u32 ptr); u64 read_ee_timer(); void c_memmove(u32 dst, u32 src, u32 size); +void set_game_resolution(s64 w, s64 h); +void set_msaa(s64 samples); void get_window_size(u32 w_ptr, u32 h_ptr); void get_window_scale(u32 x_ptr, u32 y_ptr); void get_screen_size(s64 vmode_idx, u32 w_ptr, u32 h_ptr); diff --git a/game/kernel/jak1/kmachine.cpp b/game/kernel/jak1/kmachine.cpp index 30122bc0f0..e1b3a47452 100644 --- a/game/kernel/jak1/kmachine.cpp +++ b/game/kernel/jak1/kmachine.cpp @@ -579,14 +579,6 @@ void set_fullscreen(u32 symptr, s64 screen) { } } -void set_game_resolution(s64 w, s64 h) { - Gfx::set_game_resolution(w, h); -} - -void set_msaa(s64 samples) { - Gfx::set_msaa(samples); -} - void InitMachine_PCPort() { // PC Port added functions diff --git a/game/kernel/jak2/kmachine.cpp b/game/kernel/jak2/kmachine.cpp index e4cf9e8eb0..2f3ce8b563 100644 --- a/game/kernel/jak2/kmachine.cpp +++ b/game/kernel/jak2/kmachine.cpp @@ -490,6 +490,23 @@ u64 kopen(u64 fs, u64 name, u64 mode) { return fs; } +/*! + * PC port functions START + */ + +/*! + * Return the current OS as a symbol. Actually returns what it was compiled for! + */ +u64 get_os() { +#ifdef _WIN32 + return intern_from_c("windows").offset; +#elif __linux__ + return intern_from_c("linux").offset; +#else + return s7.offset; +#endif +} + void pc_set_levels(u32 lev_list) { std::vector levels; for (int i = 0; i < 6; i++) { @@ -576,6 +593,28 @@ void update_discord_rpc(u32 discord_info) { } } +u32 get_fullscreen() { + switch (Gfx::get_fullscreen()) { + default: + case GfxDisplayMode::Windowed: + return intern_from_c("windowed").offset; + case GfxDisplayMode::Borderless: + return intern_from_c("borderless").offset; + case GfxDisplayMode::Fullscreen: + return intern_from_c("fullscreen").offset; + } +} + +void set_fullscreen(u32 symptr, s64 screen) { + if (symptr == intern_from_c("windowed").offset || symptr == s7.offset) { + Gfx::set_fullscreen(GfxDisplayMode::Windowed, screen); + } else if (symptr == intern_from_c("borderless").offset) { + Gfx::set_fullscreen(GfxDisplayMode::Borderless, screen); + } else if (symptr == intern_from_c("fullscreen").offset) { + Gfx::set_fullscreen(GfxDisplayMode::Fullscreen, screen); + } +} + void InitMachine_PCPort() { // PC Port added functions @@ -597,18 +636,22 @@ void InitMachine_PCPort() { make_function_symbol_from_c("pc-pad-input-index-get", (void*)Pad::input_mode_get_index); // os stuff - // make_function_symbol_from_c("pc-get-os", (void*)get_os); + make_function_symbol_from_c("pc-get-os", (void*)get_os); make_function_symbol_from_c("pc-get-window-size", (void*)get_window_size); make_function_symbol_from_c("pc-get-window-scale", (void*)get_window_scale); - // make_function_symbol_from_c("pc-get-fullscreen", (void*)get_fullscreen); + make_function_symbol_from_c("pc-get-fullscreen", (void*)get_fullscreen); make_function_symbol_from_c("pc-get-screen-size", (void*)get_screen_size); make_function_symbol_from_c("pc-get-screen-rate", (void*)get_screen_rate); make_function_symbol_from_c("pc-get-screen-vmode-count", (void*)get_screen_vmode_count); + make_function_symbol_from_c("pc-get-monitor-count", (void*)get_monitor_count); make_function_symbol_from_c("pc-set-window-size", (void*)Gfx::set_window_size); - // make_function_symbol_from_c("pc-set-fullscreen", (void*)set_fullscreen); + make_function_symbol_from_c("pc-set-fullscreen", (void*)set_fullscreen); make_function_symbol_from_c("pc-set-frame-rate", (void*)set_frame_rate); make_function_symbol_from_c("pc-set-vsync", (void*)set_vsync); make_function_symbol_from_c("pc-set-window-lock", (void*)set_window_lock); + make_function_symbol_from_c("pc-set-game-resolution", (void*)set_game_resolution); + make_function_symbol_from_c("pc-set-msaa", (void*)set_msaa); + make_function_symbol_from_c("pc-get-unix-timestamp", (void*)get_unix_timestamp); // graphics things make_function_symbol_from_c("pc-set-letterbox", (void*)Gfx::set_letterbox); @@ -649,6 +692,10 @@ void InitMachine_PCPort() { intern_from_c("*pc-settings-built-sha*")->value() = make_string_from_c(GIT_VERSION); } +/*! + * PC port functions END + */ + void PutDisplayEnv(u32 /*ptr*/) { ASSERT(false); } diff --git a/goal_src/jak1/dgos/engine.gd b/goal_src/jak1/dgos/engine.gd index ad5fd1d5a6..7909ac63dd 100644 --- a/goal_src/jak1/dgos/engine.gd +++ b/goal_src/jak1/dgos/engine.gd @@ -35,6 +35,9 @@ "dma-bucket.o" "dma-disasm.o" "pckernel-h.o" ;; added + "pckernel-impl.o" ;; added + "pc-debug-common.o" ;; added + "pc-debug-methods.o" ;; added "pad.o" "gs.o" "display-h.o" @@ -193,14 +196,15 @@ "entity-table.o" "loader.o" "task-control-h.o" + "speedruns-h.o" ;; added "game-info.o" "game-save.o" "settings.o" "pc-anim-util.o" ;; added "autosplit-h.o" ;; added "autosplit.o" ;; added - "speedruns-h.o" ;; added "speedruns.o" ;; added + "pckernel-common.o" ;; added "pckernel.o" ;; added "mood-tables.o" "mood.o" diff --git a/goal_src/jak1/dgos/game.gd b/goal_src/jak1/dgos/game.gd index 7ca7df2099..c852163954 100644 --- a/goal_src/jak1/dgos/game.gd +++ b/goal_src/jak1/dgos/game.gd @@ -31,6 +31,9 @@ "dma-bucket.o" "dma-disasm.o" "pckernel-h.o" ;; added + "pckernel-impl.o" ;; added + "pc-debug-common.o" ;; added + "pc-debug-methods.o" ;; added "pad.o" "gs.o" "display-h.o" @@ -197,6 +200,7 @@ "autosplit-h.o" ;; added "autosplit.o" ;; added "speedruns.o" ;; added + "pckernel-common.o" ;; added "pckernel.o" ;; added "mood-tables.o" "mood.o" diff --git a/goal_src/jak1/engine/game/main.gc b/goal_src/jak1/engine/game/main.gc index 612cb69ecf..8e9ba90a19 100644 --- a/goal_src/jak1/engine/game/main.gc +++ b/goal_src/jak1/engine/game/main.gc @@ -565,50 +565,8 @@ 0 ) -(defconstant MEM_BAR_WIDTH 152) -(defconstant MEM_BAR_HEIGHT 8) -(defconstant MEM_BAR_NUM 7) -(defconstant MEM_BAR_BG_COL (static-rgba 64 64 64 64)) -(defconstant MEM_BAR_X (- 480 MEM_BAR_WIDTH)) -(defconstant MEM_BAR_Y (- 224 4 (* MEM_BAR_HEIGHT MEM_BAR_NUM))) -(defmacro draw-memory-bar-generic (buf &key remain &key total &key name &key idx &key color) - `(let* ( - (total (the float ,total)) - (remain (the float ,remain)) - (used-p (/ (- total remain) total)) - (used-x (the int (* used-p MEM_BAR_WIDTH))) - (used-y (+ MEM_BAR_Y (* ,idx MEM_BAR_HEIGHT))) - ) - (draw-sprite2d-xy ,buf MEM_BAR_X used-y used-x MEM_BAR_HEIGHT ,color) - (draw-sprite2d-xy ,buf (+ MEM_BAR_X used-x) used-y (- MEM_BAR_WIDTH used-x) MEM_BAR_HEIGHT MEM_BAR_BG_COL) - (draw-string-xy ,name ,buf MEM_BAR_X used-y (font-color red) (font-flags shadow kerning right)) - (draw-string-xy (string-format "~,,2f%" (* used-p 100)) ,buf (+ MEM_BAR_X used-x) used-y (font-color red) (font-flags shadow kerning middle)) - (draw-string-xy (string-format "~,,1fM" (/ total (* 1024 1024))) ,buf (+ MEM_BAR_X MEM_BAR_WIDTH) used-y (font-color red) (font-flags shadow kerning left)) - ) - ) -(defmacro draw-memory-bar-kheap (buf heap &key (name #f) &key idx &key color) - `(let ((heap ,heap)) - (draw-memory-bar-generic ,buf - :remain (&- (-> heap top) (-> heap current)) - :total (&- (-> heap top) (-> heap base)) - :name ,(if name name (symbol->string heap)) - :idx ,idx - :color ,color) - ) - ) -(defmacro draw-memory-bar-dead-pool-heap (buf heap &key (name #f) &key idx &key color) - `(let* ((heap ,heap) (pool-total (memory-total heap))) - (draw-memory-bar-generic ,buf - :remain (- pool-total (memory-used heap)) - :total pool-total - :name ,(if name name (symbol->string heap)) - :idx ,idx - :color ,color) - ) - ) - (defbehavior display-loop process () - "This is in progress..." + "the main 'display loop' in GOAL. v-sync is done in this function, so all frames start and end here." ;; increase our stack size. (stack-size-set! (-> self main-thread) 512) @@ -705,8 +663,7 @@ (with-profiler "menu" (with-pc - (if - (and (-> *pc-settings* display-sha) *debug-segment*) + (if (and (-> *pc-settings* display-sha) *debug-segment*) (draw-build-revision))) (*menu-hook*) (add-ee-profile-frame 'draw :g #x40) @@ -747,7 +704,7 @@ ) (if (#if (not PC_PORT) (= (-> *setting-control* current aspect-ratio) 'aspect4x3) - (or (not (-> *pc-settings* use-vis?)) (and (-> *pc-settings* use-vis?) (= (-> *setting-control* current aspect-ratio) 'aspect4x3)))) + (or (= (-> *setting-control* current aspect-ratio) 'aspect4x3) (not (-> *pc-settings* use-vis?)))) (letterbox) ) ) @@ -818,67 +775,11 @@ ;; added (#when PC_PORT - (when (-> *pc-settings* debug?) - (draw *pc-settings* debug-buf) - ) - (when (-> *pc-settings* display-actor-bank) - (draw-string-xy (string-format "Actor Bank: ~,,1m/~,,1m (~D)" (-> *ACTOR-bank* pause-dist) (-> *ACTOR-bank* birth-dist) (-> *ACTOR-bank* birth-max)) debug-buf 512 (- 224 8) (font-color default) (font-flags shadow kerning right)) - ) - (when (-> *pc-settings* display-bug-report) - (format *stdcon* "~0kbug-report ~A~%" *user*) - (format *stdcon* "nick ~A continue ~S~%" (-> *load-state* vis-nick) (-> *game-info* current-continue name)) - (dotimes (i LEVEL_COUNT) - (format *stdcon* "level ~D ~12A ~A~%" i (-> *level* level i name) (-> *level* level i display?)) - ) - (format *stdcon* "music ~A (f: ~D/~S)~%" (-> *setting-control* current music) (-> *setting-control* current sound-flava) (music-flava->string (the-as music-flava (-> *setting-control* default sound-flava)))) - (format *stdcon* "sound ~A ~A~%" *sound-bank-1* *sound-bank-2*) - (let ((pos (target-pos 0))) - (format *stdcon* "target ~m ~m ~m~%" (-> pos x) (-> pos y) (-> pos z)) - ) - (let ((pos (camera-pos))) - (format *stdcon* "cam-trans ~m ~m ~m~%" (-> pos x) (-> pos y) (-> pos z)) - ) - (let ((rot (new 'stack 'quaternion))) - (matrix->quaternion rot (-> *math-camera* camera-rot)) - (format *stdcon* "cam-rot ~f ~f ~f ~f~%" (-> rot x) (-> rot y) (-> rot z) (-> rot w)) - ) - (format *stdcon* "~1k") - ) - (when (-> *pc-settings* display-heap-status) - (draw-memory-bar-kheap debug-buf global :idx 0 :color (static-rgba 32 32 255 64)) - (draw-memory-bar-kheap debug-buf debug :idx 1 :color (static-rgba 255 32 32 64)) - (draw-memory-bar-kheap debug-buf (-> *level* level 0 heap) :name "l0" :idx 2 :color (static-rgba 32 255 255 64)) - (draw-memory-bar-kheap debug-buf (-> *level* level 1 heap) :name "l1" :idx 3 :color (static-rgba 255 32 255 64)) - (draw-memory-bar-dead-pool-heap debug-buf *nk-dead-pool* :name "actor" :idx 4 :color (static-rgba 32 255 32 64)) - (draw-memory-bar-generic debug-buf - :remain (* 16 (dma-buffer-free (-> disp frames (-> disp on-screen) frame global-buf))) - :total (length (-> disp frames (-> disp on-screen) frame global-buf)) - :name "dma-global" :idx 5 :color (static-rgba 32 32 255 64)) - (draw-memory-bar-generic debug-buf - :remain (* 16 (dma-buffer-free (-> disp frames (-> disp on-screen) frame debug-buf))) - :total (length (-> disp frames (-> disp on-screen) frame debug-buf)) - :name "dma-debug" :idx 6 :color (static-rgba 255 32 32 64)) - ) + (draw *pc-settings* debug-buf) + (draw-memory *pc-settings* debug-buf) + (print-debug-misc *pc-settings*) ) - #| - (format *stdcon* "~3Lfree DMA global: ~d debug: ~d~0L~%" - (dma-buffer-free (-> disp frames (-> disp on-screen) frame global-buf)) - (dma-buffer-free (-> disp frames (-> disp on-screen) frame debug-buf)) - ) - ;; added, prints some level status. - (dotimes (i 2) - (let ((level-heap (-> *level* level i heap))) - (format *stdcon* "~17Llevel ~d: ~A ~A ~,,2fK remaining~0L~%" - i - (-> *level* level i name) - (-> *level* level i status) - (* (1/ 1024) (&- (-> level-heap top) (-> level-heap current))) - ) - ) - ) - |# - (display-file-info) ) ;; end dma let ) ;; end debug-segment diff --git a/goal_src/jak1/game.gp b/goal_src/jak1/game.gp index 7231ea8b69..d548cf1b1b 100644 --- a/goal_src/jak1/game.gp +++ b/goal_src/jak1/game.gp @@ -1915,7 +1915,16 @@ "game/task/hint-control.gc" "entity/ambient.gc" "debug/assert.gc" - "common-obs/generic-obs.gc" + ) + +(goal-src "engine/common-obs/generic-obs.gc" "pc-anim-util" "assert") + +(goal-src-sequence + ;; prefix + "engine/" + + :deps + ("$OUT/obj/generic-obs.o") "target/target-util.gc" "target/target-part.gc" "target/collide-reaction-target.gc" @@ -2045,14 +2054,18 @@ (goal-src "pc/features/autosplit.gc" "autosplit-h" "task-control-h" "progress-static") (goal-src "pc/features/speedruns.gc" "speedruns-h" "autosplit-h") (goal-src "pc/pckernel-h.gc" "dma-buffer") +(goal-src "pc/pckernel-impl.gc" "pckernel-h") (goal-src "pc/util/pc-anim-util.gc" "target-h") -(goal-src "pc/pckernel.gc" "pc-anim-util" "settings" "video" "target-h" "autosplit-h" "speedruns-h") +(goal-src "pc/pckernel-common.gc" "pckernel-impl" "pc-anim-util" "settings" "video" "target-h" "autosplit-h" "speedruns-h") +(goal-src "pc/pckernel.gc" "pckernel-common") (goal-src "pc/subtitle.gc" "text" "pckernel" "hint-control" "loader-h" "gsound" "ambient") (goal-src "pc/progress-pc.gc" "progress" "pckernel") (goal-src "pc/hud-classes-pc.gc" "pckernel" "hud" "battlecontroller" "generic-obs") (goal-src "pc/debug/anim-tester-x.gc" "pckernel" "gstring" "joint" "process-drawable" "art-h" "effect-control") (goal-src "pc/debug/entity-debug.gc" "debug" "main-h" "entity" "pckernel" "font") (goal-src "pc/debug/default-menu-pc.gc" "anim-tester-x" "part-tester" "entity-debug") +(goal-src "pc/debug/pc-debug-common.gc" "pckernel-impl" "entity-h" "game-info-h" "level-h" "settings-h" "gsound-h" "target-util") +(goal-src "pc/debug/pc-debug-methods.gc" "pc-debug-common") (group-list "all-code" `(,@(reverse *all-gc*)) diff --git a/goal_src/jak1/pc/debug/anim-tester-x.gc b/goal_src/jak1/pc/debug/anim-tester-x.gc index 75ab693624..b199f9e571 100644 --- a/goal_src/jak1/pc/debug/anim-tester-x.gc +++ b/goal_src/jak1/pc/debug/anim-tester-x.gc @@ -664,12 +664,13 @@ (if (not *atx*) (atx-start)) (do-atx-list (item (-> *ATX-settings* list-ctrl)) - (if (or (and (>= (-> item group) (-> *level* level 0 heap base)) (< (-> item group) (-> *level* level 0 heap top))) - (and (>= (-> item group) (-> *level* level 1 heap base)) (< (-> item group) (-> *level* level 1 heap top)))) + (dotimes (i (-> *level* length)) + (when (and (>= (-> item group) (-> *level* level i heap base)) (< (-> item group) (-> *level* level i heap top))) (atx-list-remove (-> *ATX-settings* list-ctrl) item) - ) + (set! i (-> *level* length)) + )) ) - (dotimes (i 2) + (dotimes (i (-> *level* length)) (doarray (ag (-> *level* level i art-group data-array)) (atx-add-new-art-group (the art-group ag)) ) @@ -679,7 +680,7 @@ (defun atx-add-common-group () (if (not *atx*) (atx-start)) - (doarray (ag (-> *level* level 2 art-group data-array)) + (doarray (ag (-> *level* level (-> *level* length) art-group data-array)) (atx-add-new-art-group (the art-group ag)) ) ) diff --git a/goal_src/jak1/pc/debug/entity-debug.gc b/goal_src/jak1/pc/debug/entity-debug.gc index 6eb6a1ee6f..c7cec38104 100644 --- a/goal_src/jak1/pc/debug/entity-debug.gc +++ b/goal_src/jak1/pc/debug/entity-debug.gc @@ -9,6 +9,17 @@ (define *debug-temp-string* (new 'debug 'string 4096 (the string #f))) +(defmethod set-entity! entity-debug-inspect ((obj entity-debug-inspect) (e entity)) + "set the entity to inspect" + + (set! (-> obj entity) e) + (unless e + (set! *display-actor-anim* (the string #f))) + (set! (-> obj scroll-y) 0) + + e + ) + ;; custom entity functions for pc port (defun-debug entity-inspect-draw ((inspect-info entity-debug-inspect)) "draw text about an entity on screen" diff --git a/goal_src/jak1/pc/debug/pc-debug-common.gc b/goal_src/jak1/pc/debug/pc-debug-common.gc new file mode 100644 index 0000000000..14bef0f6a1 --- /dev/null +++ b/goal_src/jak1/pc/debug/pc-debug-common.gc @@ -0,0 +1,59 @@ +;;-*-Lisp-*- +(in-package goal) + +#| + Various debugging displays made for the pc port. This file is shared for all games. + |# + +;; debug-only file! +(declare-file (debug)) + +;; ---------------------- +;; memory usage bars! +;; ---------------------- + +(defconstant MEM_BAR_WIDTH 152) ;; total width of the bar +(defconstant MEM_BAR_HEIGHT 8) ;; total height of the bar +(defconstant MEM_BAR_NUM 7) ;; amount of bars (override later if wanted) +(defconstant MEM_BAR_BG_COL (static-rgba 64 64 64 64)) ;; color for the empty part of the bar +(defconstant MEM_BAR_X (- 480 MEM_BAR_WIDTH)) ;; x coord for left side of the bar list +(defconstant MEM_BAR_Y (- 224 4 (* MEM_BAR_HEIGHT MEM_BAR_NUM))) ;; y coord for top side of the bar list + +(defmacro draw-memory-bar-generic (buf &key remain &key total &key name &key idx &key color) + "draw a memory usage bar" + `(let* ( + (total (the float ,total)) + (remain (the float ,remain)) + (used-p (/ (- total remain) total)) + (used-x (the int (* used-p MEM_BAR_WIDTH))) + (used-y (+ MEM_BAR_Y (* ,idx MEM_BAR_HEIGHT))) + ) + (draw-sprite2d-xy ,buf MEM_BAR_X used-y used-x MEM_BAR_HEIGHT ,color) + (draw-sprite2d-xy ,buf (+ MEM_BAR_X used-x) used-y (- MEM_BAR_WIDTH used-x) MEM_BAR_HEIGHT MEM_BAR_BG_COL) + (draw-string-xy ,name ,buf MEM_BAR_X used-y (font-color red) (font-flags shadow kerning right)) + (draw-string-xy (string-format "~,,2f%" (* used-p 100)) ,buf (+ MEM_BAR_X used-x) used-y (font-color red) (font-flags shadow kerning middle)) + (draw-string-xy (string-format "~,,1fM" (/ total (* 1024 1024))) ,buf (+ MEM_BAR_X MEM_BAR_WIDTH) used-y (font-color red) (font-flags shadow kerning left)) + ) + ) +(defmacro draw-memory-bar-kheap (buf heap &key (name #f) &key idx &key color) + "draw a memory usage bar for a kheap" + `(let ((heap ,heap)) + (draw-memory-bar-generic ,buf + :remain (&- (-> heap top) (-> heap current)) + :total (&- (-> heap top) (-> heap base)) + :name ,(if name name (symbol->string heap)) + :idx ,idx + :color ,color) + ) + ) +(defmacro draw-memory-bar-dead-pool-heap (buf heap &key (name #f) &key idx &key color) + "draw a memory usage bar for a dead-pool-heap (actor heap)" + `(let* ((heap ,heap) (pool-total (memory-total heap))) + (draw-memory-bar-generic ,buf + :remain (- pool-total (memory-used heap)) + :total pool-total + :name ,(if name name (symbol->string heap)) + :idx ,idx + :color ,color) + ) + ) diff --git a/goal_src/jak1/pc/debug/pc-debug-methods.gc b/goal_src/jak1/pc/debug/pc-debug-methods.gc new file mode 100644 index 0000000000..f4d28521c9 --- /dev/null +++ b/goal_src/jak1/pc/debug/pc-debug-methods.gc @@ -0,0 +1,59 @@ +;;-*-Lisp-*- +(in-package goal) + +#| + Various debugging displays made for the pc port. This file includes overrides or game-specific implementations. + |# + +;; debug-only file! +(declare-file (debug)) + + +(defmethod print-debug-misc pc-settings-jak1 ((obj pc-settings-jak1)) + "prints various miscellaneous debug text to the game console, according to what's enabled in this object." + + (when (-> obj display-bug-report) + (format *stdcon* "~0kbug-report ~A~%" *user*) + (format *stdcon* "nick ~A continue ~S~%" (-> *load-state* vis-nick) (-> *game-info* current-continue name)) + (dotimes (i (-> *level* length)) + (format *stdcon* "level ~D ~12A ~A~%" i (-> *level* level i name) (-> *level* level i display?)) + ) + (format *stdcon* "music ~A (f: ~D/~S)~%" (-> *setting-control* current music) (-> *setting-control* current sound-flava) (music-flava->string (the-as music-flava (-> *setting-control* default sound-flava)))) + (format *stdcon* "sound ~A ~A~%" *sound-bank-1* *sound-bank-2*) + (let ((pos (target-pos 0))) + (format *stdcon* "target ~m ~m ~m~%" (-> pos x) (-> pos y) (-> pos z)) + ) + (let ((pos (camera-pos))) + (format *stdcon* "cam-trans ~m ~m ~m~%" (-> pos x) (-> pos y) (-> pos z)) + ) + (let ((rot (new 'stack 'quaternion))) + (matrix->quaternion rot (-> *math-camera* camera-rot)) + (format *stdcon* "cam-rot ~f ~f ~f ~f~%" (-> rot x) (-> rot y) (-> rot z) (-> rot w)) + ) + (format *stdcon* "~1k") + ) + ) + + +(defconstant MEM_BAR_NUM 7) ;; amount of memory usage bars (override later if wanted) +(defmethod draw-memory pc-settings ((obj pc-settings) (buf dma-buffer)) + "draw the memory heap status in the bottom right corner" + + (when (-> obj display-heap-status) + (draw-memory-bar-kheap buf global :idx 0 :color (static-rgba 32 32 255 64)) + (draw-memory-bar-kheap buf debug :idx 1 :color (static-rgba 255 32 32 64)) + (draw-memory-bar-kheap buf (-> *level* level 0 heap) :name "l0" :idx 2 :color (static-rgba 32 255 255 64)) + (draw-memory-bar-kheap buf (-> *level* level 1 heap) :name "l1" :idx 3 :color (static-rgba 255 32 255 64)) + (draw-memory-bar-dead-pool-heap buf *nk-dead-pool* :name "actor" :idx 4 :color (static-rgba 32 255 32 64)) + (draw-memory-bar-generic buf + :remain (* 16 (dma-buffer-free (-> (current-frame) global-buf))) + :total (length (-> (current-frame) global-buf)) + :name "dma-global" :idx 5 :color (static-rgba 32 32 255 64)) + (draw-memory-bar-generic buf + :remain (* 16 (dma-buffer-free (-> (current-frame) debug-buf))) + :total (length (-> (current-frame) debug-buf)) + :name "dma-debug" :idx 6 :color (static-rgba 255 32 32 64)) + #t) + ) + + diff --git a/goal_src/jak1/pc/pckernel-common.gc b/goal_src/jak1/pc/pckernel-common.gc new file mode 100644 index 0000000000..751df8ad35 --- /dev/null +++ b/goal_src/jak1/pc/pckernel-common.gc @@ -0,0 +1,918 @@ +;;-*-Lisp-*- +(in-package goal) + +#| + + This file contains new code that we need for the PC port of the game specifically. + It should be included as part of the game engine package (engine.cgo). + + This file contains various types and functions to store PC-specific information + and also to communicate between the game (GOAL) and the operating system. + This way we can poll, change and display information about the system the game + is running on, such as: + - display devices and their settings, such as fullscreen, DPI, refresh rate, etc. + - audio devices and their settings, such as audio latency, channel number, etc. + - graphics devices and their settings, such as resolution, FPS, anisotropy, shaders, etc. + - input devices and their settings, such as controllers, keyboards, mice, etc. + - information about the game window (position, size) + - PC-specific goodies, enhancements, fixes and settings. + - whatever else. + + If you do not want to include these PC things, you should exclude it from the build system. + + |# + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; global variables +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + +;; collision renderer things. debug only. +(define *collision-renderer* #f) +(define *collision-wireframe* #f) +(define *collision-mode* (pc-collision-mode mode)) + +;; todo +(defenum pc-pat-skip-hack + :bitfield #t + (noentity 0) + (nocamera 1) + (noedge 2) + (nolineofsight 12) + (unknowncamera 13) + (unknown 15) + ) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; updates +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defmethod set-display-mode! pc-settings ((obj pc-settings) (mode symbol)) + "sets the game's display mode" + ;; change the display mode. + (set! (-> obj display-mode) mode) + ;; if windowed mode, set the size properly + (when (= (-> obj display-mode) 'windowed) + (pc-set-window-size (max PC_MIN_WIDTH (-> obj win-width)) (max PC_MIN_HEIGHT (-> obj win-height)))) + 0) + +(defmethod set-size! pc-settings ((obj pc-settings) (width int) (height int)) + "sets the size of the display window" + (format 0 "Setting ~A size to ~D x ~D~%" (-> obj display-mode) width height) + (cond + ((= 'windowed (-> obj display-mode)) + (set! (-> obj win-width) width) + (set! (-> obj win-height) height) + (pc-set-window-size (max PC_MIN_WIDTH (-> obj win-width)) (max PC_MIN_HEIGHT (-> obj win-height))) + ) + (else + (set! (-> obj width) width) + (set! (-> obj height) height) + ) + ) + (none)) + +(defmethod set-aspect! pc-settings ((obj pc-settings) (aw int) (ah int)) + "set the aspect ratio used for rendering. this forces native widescreen and takes width and height ratios." + (let ((aspect (/ (the float aw) (the float ah)))) + (set-aspect-ratio! obj aspect) + (set! (-> obj aspect-custom-x) aw) + (set! (-> obj aspect-custom-y) ah) + (set! (-> obj aspect-ratio-auto?) #f) + (set! (-> obj use-vis?) #f) + ) + (none)) + +(defmethod set-aspect-ratio! pc-settings ((obj pc-settings) (aspect float)) + "set the aspect ratio used for rendering." + (set! (-> obj aspect-ratio) aspect) + (set! (-> obj aspect-ratio-scale) (/ aspect ASPECT_4X3)) + (set! (-> obj aspect-ratio-reciprocal) (/ ASPECT_4X3 aspect)) + (none)) + +(defmethod set-window-lock! pc-settings ((obj pc-settings) (lock symbol)) + "set the aspect ratio used for rendering." + (pc-set-window-lock lock) + (set! (-> obj window-lock?) lock)) + +(defmethod set-frame-rate! pc-settings ((obj pc-settings) (rate int)) + "set the target framerate." + (pc-set-frame-rate rate) + (if (and (!= 'fullscreen (-> obj display-mode)) + (!= (pc-get-screen-rate -1) rate)) + (set! (-> obj vsync?) #f)) + (case rate + ((50) + (set! (-> obj target-fps) rate) + (set-game-setting! obj 'video-mode 'pal) + ) + ((60) + (set! (-> obj target-fps) rate) + (set-game-setting! obj 'video-mode 'ntsc) + ) + (else + (set! (-> obj target-fps) rate) + (set-game-setting! obj 'video-mode 'custom) + ) + ) + + rate) + +(defmethod set-monitor! pc-settings ((obj pc-settings) (monitor int)) + "set the monitor to use when in fullscreen/borderless" + (set! (-> obj monitor) monitor) + (none)) + +(defmethod commit-to-file pc-settings ((obj pc-settings)) + "commits the current settings to the file" + ;; auto load settings if available + + (format (clear *pc-temp-string-1*) "~S/pc-settings.gc" *pc-settings-folder*) + (pc-mkdir-file-path *pc-temp-string-1*) + (write-to-file obj *pc-temp-string-1*) + (none)) + +(defmethod update-from-os pc-settings ((obj pc-settings)) + "Update settings from the C kernel to GOAL." + + (set! (-> obj os) (pc-get-os)) + (pc-get-window-size (&-> obj real-width) (&-> obj real-height)) + (pc-get-window-scale (&-> obj dpi-x) (&-> obj dpi-y)) + + (when (-> obj use-vis?) + (if (= (get-game-setting! obj 'aspect-ratio) 'aspect4x3) + (set-aspect-ratio! obj ASPECT_4X3) + (set-aspect-ratio! obj ASPECT_16X9) + ) + ) + + (unless (or (zero? (-> obj real-width)) (zero? (-> obj real-height))) + (let ((win-aspect (/ (the float (-> obj real-width)) (the float (-> obj real-height))))) + (cond + ((and (not (-> obj use-vis?)) (-> obj aspect-ratio-auto?)) + ;; the window determines the resolution + (set-aspect-ratio! obj win-aspect) + (set! (-> obj lbox-width) (-> obj real-width)) + (set! (-> obj lbox-height) (-> obj real-height)) + ) + ((> win-aspect (-> obj aspect-ratio)) + ;; too wide + (set! (-> obj lbox-width) (the int (* (the float (-> obj real-height)) (-> obj aspect-ratio)))) + (set! (-> obj lbox-height) (-> obj real-height)) + ) + ((< win-aspect (-> obj aspect-ratio)) + ;; too tall + (set! (-> obj lbox-width) (-> obj real-width)) + (set! (-> obj lbox-height) (the int (/ (the float (-> obj real-width)) (-> obj aspect-ratio)))) + ) + (else + ;; just right + (set! (-> obj lbox-width) (-> obj real-width)) + (set! (-> obj lbox-height) (-> obj real-height)) + ) + ) + )) + + + (none)) + +(defmethod update-to-os pc-settings ((obj pc-settings)) + "Update settings from GOAL to the C kernel." + + (cond + ((-> obj letterbox?) + (pc-set-letterbox (-> obj lbox-width) (-> obj lbox-height)) + ) + (else + (pc-set-letterbox (-> obj real-width) (-> obj real-height)) + ) + ) + + ;; if monitor selection is out of bounds (e.g. if a monitor got disconnected), + ;; then default to the primary monitor + (when (>= (-> obj monitor) (pc-get-monitor-count)) + (format 0 "Monitor selection out of bounds, defaulting to primary monitor.~%") + (set! (-> obj monitor) 0) + ) + + ;; set fullscreen to what we want + (pc-set-fullscreen (-> obj display-mode) (-> obj monitor)) + + ;; set window size and fps automatically if the window lock is enabled. + (when (-> obj window-lock?) + (pc-set-vsync (-> obj vsync?)) + + (when (!= 'fullscreen (-> obj display-mode)) + (if (< (pc-get-screen-rate -1) (-> obj target-fps)) + (pc-set-vsync #f)) + (pc-set-frame-rate (-> obj target-fps))) + ) + ;; do game resolution + (if (= (-> obj display-mode) 'windowed) + (pc-set-game-resolution (-> obj real-width) (-> obj real-height)) + (pc-set-game-resolution (-> obj width) (-> obj height))) + + ;; set msaa sample rate. if invalid, just reset to 4. + (let ((valid? #f)) + (dotimes (i 31) + (if (= (-> obj gfx-msaa) (ash 1 i)) + (true! valid?)) + ) + + (if (not valid?) (set! (-> obj gfx-msaa) 4)) + (pc-set-msaa (-> obj gfx-msaa)) + ) + + (pc-discord-rpc-set (if (-> obj discord-rpc?) 1 0)) + + (when #t ;; (not (-> obj ps2-lod-dist?)) + (pc-renderer-tree-set-lod (pc-renderer-tree-type tfrag3) (-> obj lod-force-tfrag)) + (pc-renderer-tree-set-lod (pc-renderer-tree-type tie3) (-> obj lod-force-tie)) + ) + + (when *debug-segment* + (pc-set-collision *collision-renderer*) + (pc-set-collision-wireframe *collision-wireframe*) + (pc-set-collision-mode *collision-mode*) + ) + + (pc-sound-set-flava-hack (-> obj flava-hack)) + (let ((fade-hack 0)) + (unless (-> obj music-fadein?) (logior! fade-hack 1)) + (unless (-> obj music-fadeout?) (logior! fade-hack 2)) + (pc-sound-set-fade-hack fade-hack) + ) + + (none)) + +;; where we store the input progress for the cheat codes. make sure there's enough space for all cheats. +(define *pc-cheat-temp* (new 'global 'inline-array 'uint8 PC_CHEAT_MAX)) + +(defmacro pc-cheat-toggle-and-tune (cheats-var cheat) + "quickly toggle a cheat code and play an appropriate sound" + `(begin + (cpad-clear! 0 r1) + (logxor! ,cheats-var (pc-cheats ,cheat)) + (cheats-sound-play (logtest? ,cheats-var (pc-cheats ,cheat))) + ) + ) + +(defun bcd->dec ((bcd uint)) + "Convert a number encoded in BCD to its decimal equivalent" + (+ (* (shr (logand bcd #xf0) 4) 10) (logand bcd #x0f)) + ) + +(defmethod update pc-settings ((obj pc-settings)) + "Update settings to/from PC kernel. Call this at the start of every frame. + This will update things like the aspect-ratio, which will be used for graphics code later." + + (update-from-os obj) + (update-to-os obj) + + (set! (-> obj movie?) (movie?)) + + (update-discord-rpc obj) + + ;; update auto-splitter info + (when (-> *pc-settings* speedrunner-mode?) + (update-speedrun obj)) + + (when (not (-> obj use-vis?)) + (set! (-> (get-video-params) relative-x-scale) (-> obj aspect-ratio-reciprocal)) + (set! (-> (get-video-params) relative-x-scale-reciprical) (-> obj aspect-ratio-scale)) + (set! (-> *font-default-matrix* vector 0 x) (-> (get-video-params) relative-x-scale)) + ) + (when (not (-> obj use-vis?)) + (update-progress-video-hacks obj) + ) + (cond + ((-> obj force-actors?) + ;; kinda overkill. + (set! (-> *ACTOR-bank* birth-dist) (meters 10000)) + (set! (-> *ACTOR-bank* pause-dist) (meters 10000)) + (set! (-> *ACTOR-bank* birth-max) 1000) + ) + ((> (-> *ACTOR-bank* birth-dist) (meters 220)) ;; the original caps at 220m, exceeding that means it was using our hacks + (set! (-> *ACTOR-bank* birth-dist) (meters 220)) + (set! (-> *ACTOR-bank* pause-dist) (meters 220)) + )) + + ;; cheats. + (update-cheats obj) + ;; music. + (update-music-log obj) + + (none)) + +(defmethod update-cheats pc-settings ((obj pc-settings)) + "run cheats." + 0) + + +(defmethod add-to-music-log pc-settings ((obj pc-settings) (music symbol) (flava int)) + "add music and flava information to the music log. + if music already exists, adds flava. if flava already exists, nothing happens." + + ;; go through our music log + (dotimes (i PC_MUSIC_LOG_LENGTH) + (cond + ;; an empty log entry! place the currently playing music there, and fill flava. + ((not (-> obj secrets music i name)) + (set! (-> obj secrets music i name) music) + (set! (-> obj secrets music i flava-mask) (ash 1 flava)) + (return 0) + ) + ;; an existing log entry for the current music. fill flava. + ((= music (-> obj secrets music i name)) + (logior! (-> obj secrets music i flava-mask) (ash 1 flava)) + (return 0) + ) + ;; something else. maybe the wrong entry, in which case nothing to do. + ) + ) + + 0) + +(defmethod update-music-log pc-settings ((obj pc-settings)) + "update music log settings." + 0) + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; functions +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + +(when *debug-segment* + +(defmethod draw pc-settings ((obj pc-settings) (buf dma-buffer)) + "debug draw some things on-screen" + + (when (-> obj debug?) + (clear *pc-temp-string*) + (format *pc-temp-string* "game resolution: ~D x ~D~%" (-> obj width) (-> obj height)) + (format *pc-temp-string* "window size: ~D x ~D (~,,1f x ~,,1f)~%" (-> obj real-width) (-> obj real-height) (-> obj dpi-x) (-> obj dpi-y)) + (format *pc-temp-string* "target aspect: ~,,3f/~,,3f A: ~A/~A L: ~A~%" (-> obj aspect-ratio) (/ (the float (-> obj real-width)) (the float (-> obj real-height))) (-> obj aspect-ratio-auto?) (-> obj use-vis?) (-> obj letterbox?)) + (format *pc-temp-string* "display-type: ~A ~A~%" (-> obj display-mode) (-> obj vsync?)) + + (draw-string-xy *pc-temp-string* buf 0 (- 224 (* 8 4)) (font-color default) (font-flags shadow kerning)) + ) + (when (-> obj display-actor-bank) + (draw-string-xy (string-format "Actor Bank: ~,,1m/~,,1m (~D)" (-> *ACTOR-bank* pause-dist) (-> *ACTOR-bank* birth-dist) (-> *ACTOR-bank* birth-max)) buf 512 (- 224 8) (font-color default) (font-flags shadow kerning right)) + ) + ) + +) + + +(defun find-music-log ((music symbol)) + "return #t if the given music is logged into the *pc-settings*, #f otherwise." + (dotimes (i PC_MUSIC_LOG_LENGTH) + (if (= music (-> *pc-settings* secrets music i name)) + (return #t))) + #f) + +(defun find-flava-log ((music symbol) (flava-idx int)) + "return #t if the given music's flava is logged into the *pc-settings*, #f otherwise." + (dotimes (i PC_MUSIC_LOG_LENGTH) + (if (= music (-> *pc-settings* secrets music i name)) + (return (logtest? (-> *pc-settings* secrets music i flava-mask) (ash 1 flava-idx))))) + #f) + +(defun-debug print-music-log ((out object)) + "prints the *pc-settings* music log." + + (dotimes (i PC_MUSIC_LOG_LENGTH) + (if (-> *pc-settings* secrets music i name) + (format out "music log ~D: ~A (f #x~x)~%" i (-> *pc-settings* secrets music i name) (-> *pc-settings* secrets music i flava-mask))) + ) + + 0) + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; file IO +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + + +(defmacro file-stream-seek-until (fs func-name) + `(let ((done? #f) + (tell -1)) + + (until done? + + (let ((read (file-stream-read ,fs (-> *pc-temp-string* data) PC_TEMP_STRING_LEN))) + (cond + ((zero? read) + (set! (-> *pc-temp-string* data read) 0) + (true! done?) + ) + (else + (dotimes (i read) + (when (,func-name (-> *pc-temp-string* data i)) + (true! done?) + (set! tell (+ i (- (file-stream-tell ,fs) read))) + (set! i read) + ) + ) + ) + ) + + + ) + + ) + (if (!= tell -1) + (file-stream-seek ,fs tell SCE_SEEK_SET) + tell + ) + ) + ) + +(defmacro file-stream-read-until (fs func-name) + `(let ((read (file-stream-read ,fs (-> *pc-temp-string* data) PC_TEMP_STRING_LEN))) + (dotimes (i read) + (when (,func-name (-> *pc-temp-string* data i)) + (set! (-> *pc-temp-string* data i) 0) + (file-stream-seek ,fs (+ i (- (file-stream-tell ,fs) read)) SCE_SEEK_SET) + (set! i read) + ) + ) + *pc-temp-string* + ) + ) + +(defmacro is-whitespace-or-bracket? (c) + `(or (is-whitespace-char? ,c) (= #x28 ,c) (= #x29 ,c)) + ) + +(defun file-stream-seek-past-whitespace ((file file-stream)) + (file-stream-seek-until file not-whitespace-char?) + ) + +(defun file-stream-read-word ((file file-stream)) + (file-stream-read-until file is-whitespace-or-bracket?) + ;(format 0 "word ~A~%" *pc-temp-string*) + ) + +(defmacro file-stream-getc (fs) + `(let ((buf 255)) + (file-stream-read ,fs (& buf) 1) + ;(format 0 "getc got #x~X~%" buf) + buf + ) + ) + +(defun file-stream-read-int ((file file-stream)) + (file-stream-seek-past-whitespace file) + (file-stream-read-word file) + (string->int *pc-temp-string*) + ) + +(defun file-stream-read-float ((file file-stream)) + (file-stream-seek-past-whitespace file) + (file-stream-read-word file) + (string->float *pc-temp-string*) + ) + +(defun file-stream-read-symbol ((file file-stream)) + (file-stream-seek-past-whitespace file) + (file-stream-read-word file) + (string->symbol *pc-temp-string*) + ) + +(defmacro pc-settings-read-throw-error (fs msg) + "not an actual throw..." + `(begin + (format 0 "pc settings read error: ~S~%" ,msg) + (file-stream-close ,fs) + (return #f) + ) + ) + +(defmacro with-settings-scope (bindings &rest body) + (let ((fs (first bindings))) + `(begin + (file-stream-seek-past-whitespace ,fs) + (when (!= #x28 (file-stream-getc ,fs)) + (pc-settings-read-throw-error ,fs "invalid char, ( not found") + ) + + ,@body + + (file-stream-seek-past-whitespace ,fs) + (when (!= #x29 (file-stream-getc ,fs)) + (pc-settings-read-throw-error ,fs "invalid char, ) not found") + ) + ) + ) + ) + +(defmacro file-stream-get-next-char-ret (fs) + `(begin + (file-stream-seek-past-whitespace ,fs) + (let ((c (file-stream-getc ,fs))) + (file-stream-seek ,fs -1 SCE_SEEK_CUR) + c)) + ) + +(defmacro file-stream-get-next-char (fs) + `(begin + (file-stream-seek-past-whitespace ,fs) + (file-stream-getc ,fs) + ) + ) + +(defmacro dosettings (bindings &rest body) + "iterate over a list of key-value pairs like so: ( ) ( ) ... + the name of key is stored in *pc-temp-string*" + (let ((fs (first bindings))) + `(let ((c -1)) + (while (begin (file-stream-seek-past-whitespace ,fs) (set! c (file-stream-getc ,fs)) (= #x28 c)) + (file-stream-read-word ,fs) + + ,@body + + (set! c (file-stream-get-next-char ,fs)) + (when (!= #x29 c) + (pc-settings-read-throw-error ,fs (string-format "invalid char, ) not found, got #x~X ~A" c *pc-temp-string*)) + ) + ) + (file-stream-seek ,fs -1 SCE_SEEK_CUR) + ) + ) + ) + +(defmethod read-from-file pc-settings ((obj pc-settings) (filename string)) + "read settings from a file" + + (if (not filename) + (return #f)) + + (let ((file (new 'stack 'file-stream filename 'read))) + (when (not (file-stream-valid? file)) + (return #f)) + + (let ((version PC_KERNEL_VERSION)) + (with-settings-scope (file) + (case-str (file-stream-read-word file) + (("settings") + (set! version (the pckernel-version (file-stream-read-int file))) + (cond + ((and (= (-> version major) PC_KERNEL_VER_MAJOR) + (= (-> version minor) PC_KERNEL_VER_MINOR)) + ;; minor or no difference + ) + (else + ;; major difference + (format 0 "PC kernel version mismatch! Got ~D.~D vs ~D.~D~%" PC_KERNEL_VER_MAJOR PC_KERNEL_VER_MINOR (-> version major) (-> version minor)) + (file-stream-close file) + (return #f) + ) + ) + (dosettings (file) + (handle-input-settings obj file) + ) + ;; upgrade settings if minor changes + ;; remember to delete this when major changes to the version number are made + (when (and (= PC_KERNEL_VER_MAJOR 1) + (= PC_KERNEL_VER_MINOR 10) + (or (!= PC_KERNEL_VER_BUILD (-> version build)) + (!= PC_KERNEL_VER_REVISION (-> version revision)))) + ;; 1.10 upgrade: turn envmap on + (set! (-> obj force-envmap?) #t) + ) + ) + ) + ) + + ) + + (file-stream-close file) + ) + + (format 0 "pc settings file read: ~A~%" filename) + + ;; restore the windowed mode resolution properly + (when (= (-> obj display-mode) 'windowed) + (pc-set-window-size (max PC_MIN_WIDTH (-> obj win-width)) (max PC_MIN_HEIGHT (-> obj win-height)))) + + #t + ) + +(defmethod handle-input-settings pc-settings ((obj pc-settings) (file file-stream)) + "handle the text parsing input for the 'settings' group" + + (case-str *pc-temp-string* + (("fps") (set-frame-rate! obj (file-stream-read-int file))) + (("window-size") + (set! (-> obj win-width) (file-stream-read-int file)) + (set! (-> obj win-height) (file-stream-read-int file)) + ) + (("game-size") + (set! (-> obj width) (file-stream-read-int file)) + (set! (-> obj height) (file-stream-read-int file)) + ) + (("msaa") (set! (-> obj gfx-msaa) (file-stream-read-int file))) + (("aspect-state") + ;; game aspect + (set-game-setting! obj 'aspect-ratio (file-stream-read-symbol file)) + ;; aspect ratio + (set! (-> obj aspect-custom-x) (file-stream-read-int file)) + (set! (-> obj aspect-custom-y) (file-stream-read-int file)) + ;; aspect auto + (set! (-> obj aspect-ratio-auto?) (file-stream-read-symbol file)) + + (unless (-> obj aspect-ratio-auto?) + (set-aspect! obj (-> obj aspect-custom-x) (-> obj aspect-custom-y)) + ) + ) + (("display-mode") (set-display-mode! obj (file-stream-read-symbol file))) + (("monitor") (set-monitor! obj (file-stream-read-int file))) + (("letterbox") (set! (-> obj letterbox?) (file-stream-read-symbol file))) + (("vsync") (set! (-> obj vsync?) (file-stream-read-symbol file))) + (("font-scale") (set! (-> obj font-scale) (file-stream-read-float file))) + (("audio-latency-ms") (set! (-> obj audio-latency-ms) (file-stream-read-int file))) + (("audio-pan-override") (set! (-> obj audio-pan-override) (file-stream-read-float file))) + (("audio-volume-override") (set! (-> obj audio-volume-override) (file-stream-read-float file))) + (("audio-channel-nb") (set! (-> obj audio-channel-nb) (file-stream-read-int file))) + (("gfx-renderer") (set! (-> obj gfx-renderer) (the-as pc-gfx-renderer (file-stream-read-int file)))) + (("gfx-resolution") (set! (-> obj gfx-resolution) (file-stream-read-float file))) + (("gfx-anisotropy") (set! (-> obj gfx-anisotropy) (file-stream-read-float file))) + (("shrub-dist-mod") (set! (-> obj shrub-dist-mod) (file-stream-read-float file))) + (("lod-dist-mod") (set! (-> obj lod-dist-mod) (file-stream-read-float file))) + (("lod-force-tfrag") (set! (-> obj lod-force-tfrag) (file-stream-read-int file))) + (("lod-force-tie") (set! (-> obj lod-force-tie) (file-stream-read-int file))) + (("lod-force-ocean") (set! (-> obj lod-force-ocean) (file-stream-read-int file))) + (("lod-force-actor") (set! (-> obj lod-force-actor) (file-stream-read-int file))) + (("game-language") (set-game-language! obj (the-as language-enum (file-stream-read-int file)))) + (("text-language") (set! (-> obj text-language) (the-as pc-subtitle-lang (file-stream-read-int file)))) + (("subtitle-speaker") (set! (-> obj subtitle-speaker?) (file-stream-read-symbol file))) + (("stick-deadzone") (set! (-> obj stick-deadzone) (file-stream-read-float file))) + (("ps2-read-speed?") (set! (-> obj ps2-read-speed?) (file-stream-read-symbol file))) + (("ps2-parts?") (set! (-> obj ps2-parts?) (file-stream-read-symbol file))) + (("ps2-music?") (set! (-> obj ps2-music?) (file-stream-read-symbol file))) + (("ps2-se?") (set! (-> obj ps2-se?) (file-stream-read-symbol file))) + (("ps2-hints?") (set! (-> obj ps2-hints?) (file-stream-read-symbol file))) + (("ps2-lod-dist?") (set! (-> obj ps2-lod-dist?) (file-stream-read-symbol file))) + (("force-envmap?") (set! (-> obj force-envmap?) (file-stream-read-symbol file))) + (("force-actors?") (set! (-> obj force-actors?) (file-stream-read-symbol file))) + (("music-fade?") (file-stream-read-symbol file)) ;; TODO remove + (("use-vis?") (set! (-> obj use-vis?) (file-stream-read-symbol file))) + (("hinttitles?") (set! (-> obj hinttitles?) (file-stream-read-symbol file))) + (("discord-rpc?") (set! (-> obj discord-rpc?) (file-stream-read-symbol file))) + (("speedrunner-mode?") (set! (-> obj speedrunner-mode?) (file-stream-read-symbol file))) + (("cutscene-skips?") (file-stream-read-symbol file)) ;; TODO remove + (("first-camera-h-inverted?") (set! (-> obj first-camera-h-inverted?) (file-stream-read-symbol file))) + (("first-camera-v-inverted?") (set! (-> obj first-camera-v-inverted?) (file-stream-read-symbol file))) + (("third-camera-h-inverted?") (set! (-> obj third-camera-h-inverted?) (file-stream-read-symbol file))) + (("third-camera-v-inverted?") (set! (-> obj third-camera-v-inverted?) (file-stream-read-symbol file))) + (("music-fadein?") (set! (-> obj music-fadein?) (file-stream-read-symbol file))) + (("music-fadeout?") (set! (-> obj music-fadeout?) (file-stream-read-symbol file))) + (("scenes-seen") + (dotimes (i PC_SPOOL_LOG_LENGTH) + (set! (-> obj scenes-seen i) (file-stream-read-int file)) + ) + ) + (("secrets") + (dosettings (file) + (case-str *pc-temp-string* + (("hard-rats?") (set! (-> obj secrets hard-rats?) (file-stream-read-symbol file))) + (("hero-mode?") (set! (-> obj secrets hero-mode?) (file-stream-read-symbol file))) + (("hud-map?") (set! (-> obj secrets hud-map?) (file-stream-read-symbol file))) + (("hud-counters?") (set! (-> obj secrets hud-counters?) (file-stream-read-symbol file))) + (("hud-watch?") (set! (-> obj secrets hud-watch?) (file-stream-read-symbol file))) + (("watch-12hr?") (set! (-> obj secrets watch-12hr?) (file-stream-read-symbol file))) + (("art") (set! (-> obj secrets art) (the-as pc-jak1-concept-art (file-stream-read-int file)))) + (("hard-fish-hiscore") (set! (-> obj secrets hard-fish-hiscore) (file-stream-read-int file))) + (("hard-rats-hiscore") (set! (-> obj secrets hard-rats-hiscore) (file-stream-read-int file))) + (("hard-rats-hiwave") (set! (-> obj secrets hard-rats-hiwave) (file-stream-read-int file))) + (("cheats") + (set! (-> obj cheats-known) (the pc-cheats (file-stream-read-int file))) + (set! (-> obj cheats) (logand (-> obj cheats-known) (file-stream-read-int file))) + ) + (("music") + (dotimes (i PC_MUSIC_LOG_LENGTH) + (when (!= #x29 (file-stream-get-next-char-ret file)) + (with-settings-scope (file) + (set! (-> obj secrets music i name) (file-stream-read-symbol file)) + (set! (-> obj secrets music i flava-mask) (file-stream-read-int file)) + ) + ) + ) + ) + ) + ) + ) + (("panic") + (when (file-stream-read-symbol file) + (reset obj) + (set-display-mode! obj #f) + (return #f) + ) + ) + ) + 0) + +(defmethod handle-output-settings pc-settings ((obj pc-settings) (file file-stream)) + "handle the text writing output for the 'settings' group" + + (format file " (fps ~D)~%" (-> obj target-fps)) + (format file " (msaa ~D)~%" (-> obj gfx-msaa)) + (format file " (aspect-state ~A ~D ~D ~A)~%" (get-game-setting! obj 'aspect-ratio) + (-> obj aspect-custom-x) (-> obj aspect-custom-y) + (-> obj aspect-ratio-auto?)) + (format file " (display-mode ~A)~%" (-> obj display-mode)) + (format file " (window-size ~D ~D)~%" (-> obj win-width) (-> obj win-height)) + (format file " (game-size ~D ~D)~%" (-> obj width) (-> obj height)) + (format file " (monitor ~D)~%" (-> obj monitor)) + (format file " (letterbox ~A)~%" (-> obj letterbox?)) + (format file " (vsync ~A)~%" (-> obj vsync?)) + (format file " (font-scale ~f)~%" (-> obj font-scale)) + + (format file " (audio-latency-ms ~D)~%" (-> obj audio-latency-ms)) + (format file " (audio-pan-override ~f)~%" (-> obj audio-pan-override)) + (format file " (audio-volume-override ~f)~%" (-> obj audio-volume-override)) + (format file " (audio-channel-nb ~D)~%" (-> obj audio-channel-nb)) + + (format file " (gfx-renderer ~D)~%" (-> obj gfx-renderer)) + (format file " (gfx-resolution ~f)~%" (-> obj gfx-resolution)) + (format file " (gfx-anisotropy ~f)~%" (-> obj gfx-anisotropy)) + (format file " (shrub-dist-mod ~f)~%" (-> obj shrub-dist-mod)) + (format file " (lod-dist-mod ~f)~%" (-> obj lod-dist-mod)) + (format file " (lod-force-tfrag ~D)~%" (-> obj lod-force-tfrag)) + (format file " (lod-force-tie ~D)~%" (-> obj lod-force-tie)) + (format file " (lod-force-ocean ~D)~%" (-> obj lod-force-ocean)) + (format file " (lod-force-actor ~D)~%" (-> obj lod-force-actor)) + + (format file " (stick-deadzone ~f)~%" (-> obj stick-deadzone)) + + (format file " (ps2-read-speed? ~A)~%" (-> obj ps2-read-speed?)) + (format file " (ps2-parts? ~A)~%" (-> obj ps2-parts?)) + (format file " (ps2-music? ~A)~%" (-> obj ps2-music?)) + (format file " (ps2-se? ~A)~%" (-> obj ps2-se?)) + (format file " (ps2-hints? ~A)~%" (-> obj ps2-hints?)) + (format file " (ps2-lod-dist? ~A)~%" (-> obj ps2-lod-dist?)) + (format file " (force-envmap? ~A)~%" (-> obj force-envmap?)) + (format file " (use-vis? ~A)~%" (-> obj use-vis?)) + (format file " (discord-rpc? ~A)~%" (-> obj discord-rpc?)) + (format file " (speedrunner-mode? ~A)~%" (-> obj speedrunner-mode?)) + (format file " (first-camera-h-inverted? ~A)~%" (-> obj first-camera-h-inverted?)) + (format file " (first-camera-v-inverted? ~A)~%" (-> obj first-camera-v-inverted?)) + (format file " (third-camera-h-inverted? ~A)~%" (-> obj third-camera-h-inverted?)) + (format file " (third-camera-v-inverted? ~A)~%" (-> obj third-camera-v-inverted?)) + (format file " (force-actors? ~A)~%" (-> obj force-actors?)) + (format file " (music-fadein? ~A)~%" (-> obj music-fadein?)) + (format file " (music-fadeout? ~A)~%" (-> obj music-fadeout?)) + (format file " (hinttitles? ~A)~%" (-> obj hinttitles?)) + (format file " (game-language ~D)~%" (get-game-language! obj)) + (format file " (text-language ~D)~%" (-> obj text-language)) + (format file " (subtitle-speaker ~A)~%" (-> obj subtitle-speaker?)) + + #| + (format file " (scenes-seen") + (dotimes (i PC_SPOOL_LOG_LENGTH) + (if (zero? (mod i 16)) + (format file "~% ") + ) + (format file " ~D" (-> obj scenes-seen i)) + ) + (format file "~% )~%") + |# + + (format file " (secrets~%") + #| + (format file " (art #x~X)~%" (-> obj secrets art)) + (format file " (hard-rats? ~A)~%" (-> obj secrets hard-rats?)) + (format file " (hero-mode? ~A)~%" (-> obj secrets hero-mode?)) + (format file " (hud-map? ~A)~%" (-> obj secrets hud-map?)) + (format file " (hud-counters? ~A)~%" (-> obj secrets hud-counters?)) + (format file " (hard-fish-hiscore ~D)~%" (-> obj secrets hard-fish-hiscore)) + (format file " (hard-rats-hiscore ~D)~%" (-> obj secrets hard-rats-hiscore)) + (format file " (hard-rats-hiwave ~D)~%" (-> obj secrets hard-rats-hiwave)) + |# + (format file " (cheats #x~x #x~x)~%" (-> obj cheats-known) (-> obj cheats)) + + (format file " (music~%") + (dotimes (i PC_MUSIC_LOG_LENGTH) + (if (-> obj secrets music i name) + (format file " (~A #x~X)~%" (-> obj secrets music i name) (-> obj secrets music i flava-mask)) + ) + ) + + (format file " )~%") + + (format file " )~%") + 0) + +(defmethod write-to-file pc-settings ((obj pc-settings) (filename string)) + "write settings to a file" + + (if (not filename) + (return #f)) + + (let ((file (new 'stack 'file-stream filename 'write))) + (if (not (file-stream-valid? file)) + (return #f)) + + (format file "(settings #x~X~%" PC_KERNEL_VERSION) + + (handle-output-settings obj file) + + (format file " )~%") + (file-stream-close file) + ) + + (format 0 "pc settings file write: ~A~%" filename) + + #t + ) + +(defmethod load-settings pc-settings ((obj pc-settings)) + "load" + + (format (clear *pc-temp-string-1*) "~S/pc-settings.gc" *pc-settings-folder*) + (if (pc-filepath-exists? *pc-temp-string-1*) + (begin + (format 0 "[PC] PC Settings found at '~S'...loading!~%" *pc-temp-string-1*) + (unless (read-from-file obj *pc-temp-string-1*) + (format 0 "[PC] PC Settings found at '~S' but could not be loaded, using defaults!~%" *pc-temp-string-1*) + (reset obj))) + (format 0 "[PC] PC Settings not found at '~S'...initializing with defaults!~%" *pc-temp-string-1*)) + 0) + +(defmethod new pc-settings ((allocation symbol) (type-to-make type)) + "make a new pc-settings" + (let ((obj (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (reset obj) + ;; auto load settings if available + ;; if saved settings are corrupted or not found, use defaults + + (load-settings obj) + + obj)) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; entity debugging +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(when *debug-segment* + +(deftype entity-debug-inspect (basic) + ( + (scroll-y int16) + (scroll-y-max int16) + (entity entity) + (show-actor-info symbol) + ) + (:methods + (new (symbol type) _type_) + (set-entity! (_type_ entity) entity) + (update-pad (_type_ int) none) + ) + ) + +(defmethod new entity-debug-inspect ((allocation symbol) (type-to-make type)) + "make a new entity-debug-inspect object" + + (let ((obj (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + + (set! (-> obj scroll-y) 0) + (set! (-> obj scroll-y-max) 0) + (set! (-> obj entity) (the entity #f)) + (set! (-> obj show-actor-info) #f) + obj + ) + ) + +(defmethod update-pad entity-debug-inspect ((obj entity-debug-inspect) (pad-idx int)) + "respond to pad inputs" + + ;; scroll up + (if (cpad-pressed? pad-idx l1) + (1-! (-> obj scroll-y))) + ;; scroll down + (if (cpad-pressed? pad-idx r1) + (1+! (-> obj scroll-y))) + ;; toggle actor info + (if (cpad-pressed? pad-idx l3) + (not! (-> obj show-actor-info))) + + (minmax! (-> obj scroll-y) 0 (-> obj scroll-y-max)) + + (none)) + + +(define *entity-debug-inspect* (new 'debug 'entity-debug-inspect)) + +) ;; when debug_segment + + + + + diff --git a/goal_src/jak1/pc/pckernel-h.gc b/goal_src/jak1/pc/pckernel-h.gc index 65be28b9fb..1c624be66a 100644 --- a/goal_src/jak1/pc/pckernel-h.gc +++ b/goal_src/jak1/pc/pckernel-h.gc @@ -38,8 +38,9 @@ (defmacro static-pckernel-version (major minor rev build) `(new 'static 'pckernel-version :major ,major :minor ,minor :revision ,rev :build ,build)) - ;; version: 1.10.3.1 -(defglobalconstant PC_KERNEL_VERSION (static-pckernel-version 1 10 3 1)) +(defconstant PC_KERNEL_INVALID_VERSION (static-pckernel-version #xffff #xffff #xffff #xffff)) + ;; version: invalid +(defconstant PC_KERNEL_VERSION PC_KERNEL_INVALID_VERSION) (defconstant PC_KERNEL_VER_MAJOR (-> PC_KERNEL_VERSION major)) (defconstant PC_KERNEL_VER_MINOR (-> PC_KERNEL_VERSION minor)) (defconstant PC_KERNEL_VER_REVISION (-> PC_KERNEL_VERSION revision)) @@ -64,8 +65,6 @@ (defconstant PC_SPOOL_LOG_LENGTH 170) -(defconstant PC_SETTINGS_FILE_NAME "game_config/pc-settings.txt") - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; types and enums ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -296,20 +295,14 @@ ;; misc settings (force-actors? symbol) ;; skips vis check for actor entity - (music-fade? symbol) ;; if off, music has no fade in (use-vis? symbol) ;; if off, don't use vis trees. this MUST be off for custom (non-cropping) aspect ratios. - (skip-movies? symbol) ;; if on, enable cutscene skipping - (subtitles? symbol) ;; if on, cutscene subtitles will show up (hinttitles? symbol) ;; if on, non-cutscene subtitles will show up (text-language pc-subtitle-lang) ;; language for game text - (subtitle-language pc-subtitle-lang) ;; language for subtitles (subtitle-speaker? symbol) ;; #f (force off), #t (force on), auto (on for offscreen) (first-camera-h-inverted? symbol) ;; first-person horizontal camera inverted (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 - (money-starburst? symbol) ;; add a starburst to the money - (extra-hud? symbol) ;; extra hud elements. (music-fadeout? symbol) ;; music fadeout toggle. (music-fadein? symbol) ;; music fadein toggle. @@ -335,6 +328,9 @@ (update (_type_) none) (update-from-os (_type_) none) (update-to-os (_type_) none) + (update-discord-rpc (_type_) object) + (update-speedrun (_type_) object) + (update-progress-video-hacks (_type_) object) (reset (_type_) none) (reset-audio (_type_) none) (reset-input (_type_) none) @@ -343,7 +339,9 @@ (reset-misc (_type_) none) (reset-original-camera (_type_) none) (reset-extra (_type_) none) - (draw (_type_ dma-buffer) none) + (print-debug-misc (_type_) object) + (draw (_type_ dma-buffer) object) + (draw-memory (_type_ dma-buffer) symbol) (set-display-mode! (_type_ symbol) int) (set-size! (_type_ int int) none) (set-aspect! (_type_ int int) none) @@ -351,8 +349,14 @@ (set-window-lock! (_type_ symbol) symbol) (set-frame-rate! (_type_ int) int) (set-monitor! (_type_ int) none) + (set-game-setting! (_type_ symbol symbol) object) + (get-game-setting! (_type_ symbol) symbol) + (set-game-language! (_type_ language-enum) language-enum) + (get-game-language! (_type_) language-enum) (read-from-file (_type_ string) symbol) (write-to-file (_type_ string) symbol) + (handle-input-settings (_type_ file-stream) object) + (handle-output-settings (_type_ file-stream) object) (update-cheats (_type_) int) (update-music-log (_type_) int) (add-to-music-log (_type_ symbol int) int) @@ -361,37 +365,10 @@ ) ) -;; information about a cutscene. placeholder. TODO look at jak 2 -(deftype pc-scene-info (structure) - ((name string) - (commands pair) - (level0 symbol) - (level1 symbol) - (level0-disp symbol) - (level1-disp symbol) - ) - ) - -(deftype discord-info (structure) - ((fuel (pointer float)) - (money-total (pointer float)) - (buzzer-total (pointer float)) - (deaths (pointer int32)) - (status string) - (level string) - (cutscene? symbol) - (ogreboss? symbol) - (plant-boss? symbol) - (racer? symbol) - (flutflut? symbol) - (time-of-day (pointer float)) - ) - ) - (defconstant PC_TEMP_STRING_LEN 512) (define *pc-temp-string* (new 'global 'string PC_TEMP_STRING_LEN (the string #f))) -(define *pc-settings* (the pc-settings #f)) -(format 0 "PC kernel version: ~D.~D~%" PC_KERNEL_VER_MAJOR PC_KERNEL_VER_MINOR) + +(format 0 "pckernel version: ~D.~D~%" PC_KERNEL_VER_MAJOR PC_KERNEL_VER_MINOR) (define *pc-temp-string-1* (new 'global 'string 2048 (the string #f))) @@ -450,7 +427,7 @@ (set! (-> obj letterbox?) #t) (pc-get-screen-size -1 (&-> obj width) (&-> obj height)) - (set-display-mode! obj 'fullscreen) + (set-display-mode! obj 'borderless) (set! (-> obj gfx-msaa) 2) ;; 2x msaa (none)) @@ -497,20 +474,10 @@ "Set the default misc settings" (set! (-> obj force-actors?) #f) - (set! (-> obj music-fade?) #f) - (set! (-> obj skip-movies?) #t) - (set! (-> obj text-language) (case *jak1-territory* - ((GAME_TERRITORY_SCEE) (pc-subtitle-lang uk-english)) - (else (pc-subtitle-lang english)))) - (set! (-> obj subtitles?) *debug-segment*) + (set! (-> obj text-language) (pc-subtitle-lang english)) (set! (-> obj hinttitles?) #t) (set! (-> obj subtitle-speaker?) 'auto) - (set! (-> obj subtitle-language) (case *jak1-territory* - ((GAME_TERRITORY_SCEE) (pc-subtitle-lang uk-english)) - (else (pc-subtitle-lang english)))) (reset-original-camera obj) - (set! (-> obj money-starburst?) #f) - (set! (-> obj extra-hud?) #f) (none)) (defmethod reset-original-camera pc-settings ((obj pc-settings)) diff --git a/goal_src/jak1/pc/pckernel-impl.gc b/goal_src/jak1/pc/pckernel-impl.gc new file mode 100644 index 0000000000..0e124fad94 --- /dev/null +++ b/goal_src/jak1/pc/pckernel-impl.gc @@ -0,0 +1,81 @@ +;;-*-Lisp-*- +(in-package goal) + +#| + This file has the game-specific implementation of the pckernel (see pckernel-h.gc and pckernel.gc). + |# + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; constants +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + + ;; version: 1.10.3.1 +(defconstant PC_KERNEL_VERSION (static-pckernel-version 1 10 3 1)) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; types and enums +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + +;; The Jak 1 version of the pc-settings object. +(deftype pc-settings-jak1 (pc-settings) + ( + (skip-movies? symbol) ;; if on, enable cutscene skipping + (subtitles? symbol) ;; if on, cutscene subtitles will show up + (subtitle-language pc-subtitle-lang) ;; language for subtitles + (money-starburst? symbol) ;; add a starburst to the money + (extra-hud? symbol) ;; extra hud elements. + ) + ) + +(define *pc-settings* (the pc-settings-jak1 #f)) + + +;; jak 1 discord rpc structure +(deftype discord-info (structure) + ((fuel (pointer float)) + (money-total (pointer float)) + (buzzer-total (pointer float)) + (deaths (pointer int32)) + (status string) + (level string) + (cutscene? symbol) + (ogreboss? symbol) + (plant-boss? symbol) + (racer? symbol) + (flutflut? symbol) + (time-of-day (pointer float)) + ) + ) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; resets +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + +(defmethod reset-misc pc-settings-jak1 ((obj pc-settings-jak1)) + "Set the default misc settings" + + ((method-of-type pc-settings reset-misc) obj) + (set! (-> obj text-language) (case *jak1-territory* + ((GAME_TERRITORY_SCEE) (pc-subtitle-lang uk-english)) + (else (pc-subtitle-lang english)))) + (set! (-> obj skip-movies?) #t) + (set! (-> obj subtitles?) *debug-segment*) + (set! (-> obj subtitle-language) (case *jak1-territory* + ((GAME_TERRITORY_SCEE) (pc-subtitle-lang uk-english)) + (else (pc-subtitle-lang english)))) + (set! (-> obj money-starburst?) #f) + (set! (-> obj extra-hud?) #f) + (none)) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; other +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + +(defun get-video-params () *video-parms*) + + diff --git a/goal_src/jak1/pc/pckernel.gc b/goal_src/jak1/pc/pckernel.gc index 89c7b9485e..11b49548df 100644 --- a/goal_src/jak1/pc/pckernel.gc +++ b/goal_src/jak1/pc/pckernel.gc @@ -3,380 +3,55 @@ #| - This file contains new code that we need for the PC port of the game specifically. - It should be included as part of the game engine package (engine.cgo). - - This file contains various types and functions to store PC-specific information - and also to communicate between the game (GOAL) and the operating system. - This way we can poll, change and display information about the system the game - is running on, such as: - - display devices and their settings, such as fullscreen, DPI, refresh rate, etc. - - audio devices and their settings, such as audio latency, channel number, etc. - - graphics devices and their settings, such as resolution, FPS, anisotropy, shaders, etc. - - input devices and their settings, such as controllers, keyboards, mice, etc. - - information about the game window (position, size) - - PC-specific goodies, enhancements, fixes and settings. - - whatever else. - - If you do not want to include these PC things, you should exclude it from the build system. + This file runs the game-specific version of the pckernel. + See pckernel-common.gc for the bulk of the pckernel. |# + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;; global variables +;;;; methods ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; collision renderer things. debug only. -(define *collision-renderer* #f) -(define *collision-wireframe* #f) -(define *collision-mode* (pc-collision-mode mode)) - -;; todo -(defenum pc-pat-skip-hack - :bitfield #t - (noentity 0) - (nocamera 1) - (noedge 2) - (nolineofsight 12) - (unknowncamera 13) - (unknown 15) - ) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;; updates -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defmethod set-display-mode! pc-settings ((obj pc-settings) (mode symbol)) - "sets the game's display mode" - ;; change the display mode. - (set! (-> obj display-mode) mode) - ;; if windowed mode, set the size properly - (when (= (-> obj display-mode) 'windowed) - (pc-set-window-size (max PC_MIN_WIDTH (-> obj win-width)) (max PC_MIN_HEIGHT (-> obj win-height)))) - 0) - -(defmethod set-size! pc-settings ((obj pc-settings) (width int) (height int)) - "sets the size of the display window" - (format 0 "Setting ~A size to ~D x ~D~%" (-> obj display-mode) width height) - (cond - ((= 'windowed (-> obj display-mode)) - (set! (-> obj win-width) width) - (set! (-> obj win-height) height) - (pc-set-window-size (max PC_MIN_WIDTH (-> obj win-width)) (max PC_MIN_HEIGHT (-> obj win-height))) +(defmethod set-game-setting! pc-settings-jak1 ((obj pc-settings-jak1) (setting symbol) (value symbol)) + (case setting + (('video-mode) + (set! (-> *setting-control* current video-mode) #f) + (set! (-> *setting-control* default video-mode) value) + ) + (('aspect-ratio) + (set! (-> *setting-control* default aspect-ratio) value) ) (else - (set! (-> obj width) width) - (set! (-> obj height) height) - ) - ) - (none)) - -(defmethod set-aspect! pc-settings ((obj pc-settings) (aw int) (ah int)) - "set the aspect ratio used for rendering. this forces native widescreen and takes width and height ratios." - (let ((aspect (/ (the float aw) (the float ah)))) - (set-aspect-ratio! obj aspect) - (set! (-> obj aspect-custom-x) aw) - (set! (-> obj aspect-custom-y) ah) - (set! (-> obj aspect-ratio-auto?) #f) - (set! (-> obj use-vis?) #f) - ) - (none)) - -(defmethod set-aspect-ratio! pc-settings ((obj pc-settings) (aspect float)) - "set the aspect ratio used for rendering." - (set! (-> obj aspect-ratio) aspect) - (set! (-> obj aspect-ratio-scale) (/ aspect ASPECT_4X3)) - (set! (-> obj aspect-ratio-reciprocal) (/ ASPECT_4X3 aspect)) - (none)) - -(defmethod set-window-lock! pc-settings ((obj pc-settings) (lock symbol)) - "set the aspect ratio used for rendering." - (pc-set-window-lock lock) - (set! (-> obj window-lock?) lock)) - -(defmethod set-frame-rate! pc-settings ((obj pc-settings) (rate int)) - "set the target framerate." - (pc-set-frame-rate rate) - (if (and (!= 'fullscreen (-> obj display-mode)) - (!= (pc-get-screen-rate -1) rate)) - (set! (-> obj vsync?) #f)) - (case rate - ((50) - (set! (-> obj target-fps) rate) - (set! (-> *setting-control* default video-mode) 'pal) - ) - ((60) - (set! (-> obj target-fps) rate) - (set! (-> *setting-control* default video-mode) 'ntsc) - ) - (else - (set! (-> obj target-fps) rate) - (set! (-> *setting-control* default video-mode) 'custom) - ) - ) - (set! (-> *setting-control* current video-mode) #f) - - rate) - -(defmethod set-monitor! pc-settings ((obj pc-settings) (monitor int)) - "set the monitor to use when in fullscreen/borderless" - (set! (-> obj monitor) monitor) - (none)) - -(defmethod commit-to-file pc-settings ((obj pc-settings)) - "commits the current settings to the file" - ;; auto load settings if available - - (format (clear *pc-temp-string-1*) "~S/pc-settings.gc" *pc-settings-folder*) - (pc-mkdir-file-path *pc-temp-string-1*) - (write-to-file obj *pc-temp-string-1*) - (none)) - -(defmethod update-from-os pc-settings ((obj pc-settings)) - "Update settings from the C kernel to GOAL." - - (set! (-> obj os) (pc-get-os)) - (pc-get-window-size (&-> obj real-width) (&-> obj real-height)) - (pc-get-window-scale (&-> obj dpi-x) (&-> obj dpi-y)) - - (when (-> obj use-vis?) - (if (= (-> *setting-control* default aspect-ratio) 'aspect4x3) - (set-aspect-ratio! obj ASPECT_4X3) - (set-aspect-ratio! obj ASPECT_16X9) - ) - ) - - (unless (or (zero? (-> obj real-width)) (zero? (-> obj real-height))) - (let ((win-aspect (/ (the float (-> obj real-width)) (the float (-> obj real-height))))) - (cond - ((and (not (-> obj use-vis?)) (-> obj aspect-ratio-auto?)) - ;; the window determines the resolution - (set-aspect-ratio! obj win-aspect) - (set! (-> obj lbox-width) (-> obj real-width)) - (set! (-> obj lbox-height) (-> obj real-height)) - ) - ((> win-aspect (-> obj aspect-ratio)) - ;; too wide - (set! (-> obj lbox-width) (the int (* (the float (-> obj real-height)) (-> obj aspect-ratio)))) - (set! (-> obj lbox-height) (-> obj real-height)) - ) - ((< win-aspect (-> obj aspect-ratio)) - ;; too tall - (set! (-> obj lbox-width) (-> obj real-width)) - (set! (-> obj lbox-height) (the int (/ (the float (-> obj real-width)) (-> obj aspect-ratio)))) - ) - (else - ;; just right - (set! (-> obj lbox-width) (-> obj real-width)) - (set! (-> obj lbox-height) (-> obj real-height)) - ) - ) - )) - - - (none)) - -(defmethod update-to-os pc-settings ((obj pc-settings)) - "Update settings from GOAL to the C kernel." - - (cond - ((-> obj letterbox?) - (pc-set-letterbox (-> obj lbox-width) (-> obj lbox-height)) - ) - (else - (pc-set-letterbox (-> obj real-width) (-> obj real-height)) - ) - ) - - ;; if monitor selection is out of bounds (e.g. if a monitor got disconnected), - ;; then default to the primary monitor - (when (>= (-> obj monitor) (pc-get-monitor-count)) - (format 0 "Monitor selection out of bounds, defaulting to primary monitor.~%") - (set! (-> obj monitor) 0) - ) - - ;; set fullscreen to what we want - (pc-set-fullscreen (-> obj display-mode) (-> obj monitor)) - - ;; set window size and fps automatically if the window lock is enabled. - (when (-> obj window-lock?) - (pc-set-vsync (-> obj vsync?)) - - (when (!= 'fullscreen (-> obj display-mode)) - (if (< (pc-get-screen-rate -1) (-> obj target-fps)) - (pc-set-vsync #f)) - (pc-set-frame-rate (-> obj target-fps))) - ) - ;; do game resolution - (if (= (-> obj display-mode) 'windowed) - (pc-set-game-resolution (-> obj real-width) (-> obj real-height)) - (pc-set-game-resolution (-> obj width) (-> obj height))) - - ;; set msaa sample rate. if invalid, just reset to 4. - (let ((valid? #f)) - (dotimes (i 31) - (if (= (-> obj gfx-msaa) (ash 1 i)) - (true! valid?)) - ) - - (if (not valid?) (set! (-> obj gfx-msaa) 4)) - (pc-set-msaa (-> obj gfx-msaa)) - ) - - (pc-discord-rpc-set (if (-> obj discord-rpc?) 1 0)) - - (when #t ;; (not (-> obj ps2-lod-dist?)) - (pc-renderer-tree-set-lod (pc-renderer-tree-type tfrag3) (-> obj lod-force-tfrag)) - (pc-renderer-tree-set-lod (pc-renderer-tree-type tie3) (-> obj lod-force-tie)) - ) - - (when *debug-segment* - (pc-set-collision *collision-renderer*) - (pc-set-collision-wireframe *collision-wireframe*) - (pc-set-collision-mode *collision-mode*) - ) - - (pc-sound-set-flava-hack (-> obj flava-hack)) - (let ((fade-hack 0)) - (unless (-> obj music-fadein?) (logior! fade-hack 1)) - (unless (-> obj music-fadeout?) (logior! fade-hack 2)) - (pc-sound-set-fade-hack fade-hack) - ) - - (if (pc-cheats? (-> obj cheats) mirror) - (sound-set-mirror-mode (sound-mirror-mode mirrored)) - (sound-set-mirror-mode (sound-mirror-mode normal))) - - (none)) - -;; where we store the input progress for the cheat codes. make sure there's enough space for all cheats. -(define *pc-cheat-temp* (new 'global 'inline-array 'uint8 PC_CHEAT_MAX)) - -(defmacro pc-cheat-toggle-and-tune (cheats-var cheat) - "quickly toggle a cheat code and play an appropriate sound" - `(begin - (cpad-clear! 0 r1) - (logxor! ,cheats-var (pc-cheats ,cheat)) - (cheats-sound-play (logtest? ,cheats-var (pc-cheats ,cheat))) + (format #t "unknown setting ~A (~A) to set-game-setting!" setting value)) ) ) -(defun bcd->dec ((bcd uint)) - "Convert a number encoded in BCD to its decimal equivalent" - (+ (* (shr (logand bcd #xf0) 4) 10) (logand bcd #x0f)) +(defmethod get-game-setting! pc-settings-jak1 ((obj pc-settings-jak1) (setting symbol)) + (case setting + (('video-mode) + (-> *setting-control* default video-mode) + ) + (('aspect-ratio) + (-> *setting-control* default aspect-ratio) + ) + (else + (format #t "unknown setting ~A to get-game-setting!" setting) + #f) + ) ) -(defmethod update pc-settings ((obj pc-settings)) - "Update settings to/from PC kernel. Call this at the start of every frame. - This will update things like the aspect-ratio, which will be used for graphics code later." +(defmethod set-game-language! pc-settings-jak1 ((obj pc-settings-jak1) (lang language-enum)) + (set! (-> *setting-control* default language) lang) + ) - (update-from-os obj) - (update-to-os obj) +(defmethod get-game-language! pc-settings-jak1 ((obj pc-settings-jak1)) + (-> *setting-control* default language) + ) - (set! (-> obj movie?) (movie?)) - - (let ((info (new 'stack 'discord-info))) - (set! (-> info fuel) (&-> *game-info* fuel)) - (set! (-> info money-total) (&-> *game-info* money-total)) - (set! (-> info buzzer-total) (&-> *game-info* buzzer-total)) - (set! (-> info deaths) (&-> *game-info* total-deaths)) - (set! (-> info status) "Playing Jak and Daxter: The Precursor Legacy™") - (set! (-> info level) (symbol->string (-> (level-get-target-inside *level*) name))) ;; grab the name of level we're in - (set! (-> info cutscene?) (-> obj movie?)) - (set! (-> info ogreboss?) (aif (process-by-ename "ogreboss-1") (case (-> it next-state name) ( - ('ogreboss-die - 'ogreboss-idle - 'ogreboss-stage1 - 'ogreboss-stage2 - 'ogreboss-stage3-hit - 'ogreboss-stage3-shuffle - 'ogreboss-stage3-throw - 'ogreboss-wait-for-player) #t)))) - (set! (-> info plant-boss?) (aif (process-by-ename "plant-boss-3") (case (-> it next-state name) ( - ('plant-boss-idle - 'plant-boss-hit - 'plant-boss-vulnerable - 'plant-boss-spawn - 'plant-boss-reset - 'plant-boss-attack) #t)))) - (set! (-> info racer?) (aif *target* (case (-> it next-state name) ( - ('target-racing - 'target-racing-bounce - 'target-racing-death - 'target-racing-falling - 'target-racing-grab - 'target-racing-hit - 'target-racing-jump - 'target-racing-smack - 'target-racing-start) #t)))) - (set! (-> info flutflut?) (aif *target* (case (-> it next-state name) ( - ('target-flut-air-attack - 'target-flut-air-attack-hit-ground - 'target-flut-double-jump - 'target-flut-falling - 'target-flut-grab - 'target-flut-hit - 'target-flut-hit-ground - 'target-flut-jump - 'target-flut-running-attack - 'target-flut-stance - 'target-flut-start - 'target-flut-walk) #t)))) - (set! (-> info time-of-day) (&-> *time-of-day-context* time)) - - (with-profiler "discord-update" (pc-discord-rpc-update info)) - ) - - ;; update auto-splitter info - (when (-> *pc-settings* speedrunner-mode?) - (with-profiler "speedrun-update-jak1" - (speedrun-mode-update))) - - (when (not (-> obj use-vis?)) - (set! (-> *video-parms* relative-x-scale) (-> obj aspect-ratio-reciprocal)) - (set! (-> *video-parms* relative-x-scale-reciprical) (-> obj aspect-ratio-scale)) - (set! (-> *font-default-matrix* vector 0 x) (-> *video-parms* relative-x-scale)) - ) - (when (not (-> obj use-vis?)) - (set-hud-aspect-ratio 'aspect4x3 'ntsc) ;; set hud aspect ratios every frame because why not? - - (when *progress-process* - ;; adjust sizes for progress. - ;; video.gc sets the sizes in the normal game. - ;; this is a complete hack and i'm losing it - (let ((pr (-> *progress-process*)) - ;(wide-adjust (* 4.0 (- (/ (-> obj aspect-ratio-scale) ASPECT_16X9_SCALE) (1/ ASPECT_16X9_SCALE)))) - ) - (set! (-> pr sides-x-scale) 1.0) - (set! (-> pr sides-y-scale) 13.0) - ;(set! (-> pr left-x-offset) (+ 59 (the int (* (-> obj aspect-ratio-scale) -59)))) - ;(set! (-> pr right-x-offset) 26) - ;(set! (-> pr button-scale) (+ 1.0 (* wide-adjust 0.1))) - ) - ) - ) - (cond - ((-> obj force-actors?) - ;; kinda overkill. - (set! (-> *ACTOR-bank* birth-dist) (meters 10000)) - (set! (-> *ACTOR-bank* pause-dist) (meters 10000)) - (set! (-> *ACTOR-bank* birth-max) 1000) - ) - ((> (-> *ACTOR-bank* birth-dist) (meters 220)) ;; the original caps at 220m, exceeding that means it was using our hacks - (set! (-> *ACTOR-bank* birth-dist) (meters 220)) - (set! (-> *ACTOR-bank* pause-dist) (meters 220)) - )) - - ;; cheats. - (update-cheats obj) - ;; music. - (update-music-log obj) - - (none)) - -(defmethod update-cheats pc-settings ((obj pc-settings)) +(defmethod update-cheats pc-settings-jak1 ((obj pc-settings-jak1)) "run cheats." ;; first check for cheat inputs. @@ -490,38 +165,17 @@ (pc-set-gfx-hack (pc-gfx-hack no-tex) (logtest? (-> obj cheats) (pc-cheats no-tex))) + (if (pc-cheats? (-> obj cheats) mirror) + (sound-set-mirror-mode (sound-mirror-mode mirrored)) + (sound-set-mirror-mode (sound-mirror-mode normal))) + ;; run cheats end!!! ;;;;;;;;;;;;;;;;;;;; (logior! (-> obj cheats-known) (-> obj cheats)) 0) - -(defmethod add-to-music-log pc-settings ((obj pc-settings) (music symbol) (flava int)) - "add music and flava information to the music log. - if music already exists, adds flava. if flava already exists, nothing happens." - - ;; go through our music log - (dotimes (i PC_MUSIC_LOG_LENGTH) - (cond - ;; an empty log entry! place the currently playing music there, and fill flava. - ((not (-> obj secrets music i name)) - (set! (-> obj secrets music i name) music) - (set! (-> obj secrets music i flava-mask) (ash 1 flava)) - (return 0) - ) - ;; an existing log entry for the current music. fill flava. - ((= music (-> obj secrets music i name)) - (logior! (-> obj secrets music i flava-mask) (ash 1 flava)) - (return 0) - ) - ;; something else. maybe the wrong entry, in which case nothing to do. - ) - ) - - 0) - -(defmethod update-music-log pc-settings ((obj pc-settings)) +(defmethod update-music-log pc-settings-jak1 ((obj pc-settings-jak1)) "update music log settings." ;; add whatever is playing to the music log. @@ -582,607 +236,143 @@ 0) +(defmethod update-discord-rpc pc-settings-jak1 ((obj pc-settings-jak1)) + "update discord rpc module" + (let ((info (new 'stack 'discord-info))) + (set! (-> info fuel) (&-> *game-info* fuel)) + (set! (-> info money-total) (&-> *game-info* money-total)) + (set! (-> info buzzer-total) (&-> *game-info* buzzer-total)) + (set! (-> info deaths) (&-> *game-info* total-deaths)) + (set! (-> info status) "Playing Jak and Daxter: The Precursor Legacy™") + (set! (-> info level) (symbol->string (-> (level-get-target-inside *level*) name))) ;; grab the name of level we're in + (set! (-> info cutscene?) (-> obj movie?)) + (set! (-> info ogreboss?) (aif (process-by-ename "ogreboss-1") (case (-> it next-state name) ( + ('ogreboss-die + 'ogreboss-idle + 'ogreboss-stage1 + 'ogreboss-stage2 + 'ogreboss-stage3-hit + 'ogreboss-stage3-shuffle + 'ogreboss-stage3-throw + 'ogreboss-wait-for-player) #t)))) + (set! (-> info plant-boss?) (aif (process-by-ename "plant-boss-3") (case (-> it next-state name) ( + ('plant-boss-idle + 'plant-boss-hit + 'plant-boss-vulnerable + 'plant-boss-spawn + 'plant-boss-reset + 'plant-boss-attack) #t)))) + (set! (-> info racer?) (aif *target* (case (-> it next-state name) ( + ('target-racing + 'target-racing-bounce + 'target-racing-death + 'target-racing-falling + 'target-racing-grab + 'target-racing-hit + 'target-racing-jump + 'target-racing-smack + 'target-racing-start) #t)))) + (set! (-> info flutflut?) (aif *target* (case (-> it next-state name) ( + ('target-flut-air-attack + 'target-flut-air-attack-hit-ground + 'target-flut-double-jump + 'target-flut-falling + 'target-flut-grab + 'target-flut-hit + 'target-flut-hit-ground + 'target-flut-jump + 'target-flut-running-attack + 'target-flut-stance + 'target-flut-start + 'target-flut-walk) #t)))) + (set! (-> info time-of-day) (&-> *time-of-day-context* time)) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;; functions -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - - -(when *debug-segment* - -(defmethod draw pc-settings ((obj pc-settings) (buf dma-buffer)) - "debug draw" - - (clear *pc-temp-string*) - (format *pc-temp-string* "game resolution: ~D x ~D~%" (-> obj width) (-> obj height)) - (format *pc-temp-string* "window size: ~D x ~D (~,,1f x ~,,1f)~%" (-> obj real-width) (-> obj real-height) (-> obj dpi-x) (-> obj dpi-y)) - (format *pc-temp-string* "target aspect: ~,,3f/~,,3f A: ~A/~A L: ~A~%" (-> obj aspect-ratio) (/ (the float (-> obj real-width)) (the float (-> obj real-height))) (-> obj aspect-ratio-auto?) (-> obj use-vis?) (-> obj letterbox?)) - (format *pc-temp-string* "display-type: ~A ~A~%" (-> obj display-mode) (-> obj vsync?)) - - (draw-string-xy *pc-temp-string* buf 0 (- 224 (* 8 4)) (font-color default) (font-flags shadow kerning)) - - (none)) - -) - - -(defun find-music-log ((music symbol)) - "return #t if the given music is logged into the *pc-settings*, #f otherwise." - (dotimes (i PC_MUSIC_LOG_LENGTH) - (if (= music (-> *pc-settings* secrets music i name)) - (return #t))) - #f) - -(defun find-flava-log ((music symbol) (flava-idx int)) - "return #t if the given music's flava is logged into the *pc-settings*, #f otherwise." - (dotimes (i PC_MUSIC_LOG_LENGTH) - (if (= music (-> *pc-settings* secrets music i name)) - (return (logtest? (-> *pc-settings* secrets music i flava-mask) (ash 1 flava-idx))))) - #f) - -(defun-debug print-music-log ((out object)) - "prints the *pc-settings* music log." - - (dotimes (i PC_MUSIC_LOG_LENGTH) - (if (-> *pc-settings* secrets music i name) - (format out "music log ~D: ~A (f #x~x)~%" i (-> *pc-settings* secrets music i name) (-> *pc-settings* secrets music i flava-mask))) + (with-profiler "discord-update" (pc-discord-rpc-update info)) ) - 0) +(defmethod update-speedrun pc-settings-jak1 ((obj pc-settings-jak1)) + "update speedrun module" - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;; file IO -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - - - -(defmacro file-stream-seek-until (fs func-name) - `(let ((done? #f) - (tell -1)) - - (until done? - - (let ((read (file-stream-read ,fs (-> *pc-temp-string* data) PC_TEMP_STRING_LEN))) - (cond - ((zero? read) - (set! (-> *pc-temp-string* data read) 0) - (true! done?) - ) - (else - (dotimes (i read) - (when (,func-name (-> *pc-temp-string* data i)) - (true! done?) - (set! tell (+ i (- (file-stream-tell ,fs) read))) - (set! i read) - ) - ) - ) - ) - - - ) - - ) - (if (!= tell -1) - (file-stream-seek ,fs tell SCE_SEEK_SET) - tell - ) - ) - ) - -(defmacro file-stream-read-until (fs func-name) - `(let ((read (file-stream-read ,fs (-> *pc-temp-string* data) PC_TEMP_STRING_LEN))) - (dotimes (i read) - (when (,func-name (-> *pc-temp-string* data i)) - (set! (-> *pc-temp-string* data i) 0) - (file-stream-seek ,fs (+ i (- (file-stream-tell ,fs) read)) SCE_SEEK_SET) - (set! i read) - ) - ) - *pc-temp-string* - ) - ) - -(defmacro is-whitespace-or-bracket? (c) - `(or (is-whitespace-char? ,c) (= #x28 ,c) (= #x29 ,c)) - ) - -(defun file-stream-seek-past-whitespace ((file file-stream)) - (file-stream-seek-until file not-whitespace-char?) - ) - -(defun file-stream-read-word ((file file-stream)) - (file-stream-read-until file is-whitespace-or-bracket?) - ;(format 0 "word ~A~%" *pc-temp-string*) - ) - -(defmacro file-stream-getc (fs) - `(let ((buf 255)) - (file-stream-read ,fs (& buf) 1) - ;(format 0 "getc got #x~X~%" buf) - buf - ) - ) - -(defun file-stream-read-int ((file file-stream)) - (file-stream-seek-past-whitespace file) - (file-stream-read-word file) - (string->int *pc-temp-string*) - ) - -(defun file-stream-read-float ((file file-stream)) - (file-stream-seek-past-whitespace file) - (file-stream-read-word file) - (string->float *pc-temp-string*) - ) - -(defun file-stream-read-symbol ((file file-stream)) - (file-stream-seek-past-whitespace file) - (file-stream-read-word file) - (string->symbol *pc-temp-string*) - ) - -(defmacro pc-settings-read-throw-error (fs msg) - "not an actual throw..." - `(begin - (format 0 "pc settings read error: ~S~%" ,msg) - (file-stream-close ,fs) - (return #f) - ) - ) - -(defmacro with-settings-scope (bindings &rest body) - (let ((fs (first bindings))) - `(begin - (file-stream-seek-past-whitespace ,fs) - (when (!= #x28 (file-stream-getc ,fs)) - (pc-settings-read-throw-error ,fs "invalid char, ( not found") - ) - - ,@body - - (file-stream-seek-past-whitespace ,fs) - (when (!= #x29 (file-stream-getc ,fs)) - (pc-settings-read-throw-error ,fs "invalid char, ) not found") - ) - ) - ) - ) - -(defmacro file-stream-get-next-char-ret (fs) - `(begin - (file-stream-seek-past-whitespace ,fs) - (let ((c (file-stream-getc ,fs))) - (file-stream-seek ,fs -1 SCE_SEEK_CUR) - c)) - ) - -(defmacro file-stream-get-next-char (fs) - `(begin - (file-stream-seek-past-whitespace ,fs) - (file-stream-getc ,fs) - ) - ) - -(defmacro dosettings (bindings &rest body) - "iterate over a list of key-value pairs like so: ( ) ( ) ... - the name of key is stored in *pc-temp-string*" - (let ((fs (first bindings))) - `(let ((c -1)) - (while (begin (file-stream-seek-past-whitespace ,fs) (set! c (file-stream-getc ,fs)) (= #x28 c)) - (file-stream-read-word ,fs) - - ,@body - - (set! c (file-stream-get-next-char ,fs)) - (when (!= #x29 c) - (pc-settings-read-throw-error ,fs (string-format "invalid char, ) not found, got #x~X ~A" c *pc-temp-string*)) - ) - ) - (file-stream-seek ,fs -1 SCE_SEEK_CUR) - ) - ) - ) - -(defmethod read-from-file pc-settings ((obj pc-settings) (filename string)) - "read settings from a file" - - (if (not filename) - (return #f)) - - (let ((file (new 'stack 'file-stream filename 'read))) - (when (not (file-stream-valid? file)) - (return #f)) - - (let ((version PC_KERNEL_VERSION)) - (with-settings-scope (file) - (case-str (file-stream-read-word file) - (("settings") - (set! version (the pckernel-version (file-stream-read-int file))) - (cond - ((and (= (-> version major) PC_KERNEL_VER_MAJOR) - (= (-> version minor) PC_KERNEL_VER_MINOR)) - ;; minor or no difference - ) - (else - ;; major difference - (format 0 "PC kernel version mismatch! Got ~D.~D vs ~D.~D~%" PC_KERNEL_VER_MAJOR PC_KERNEL_VER_MINOR (-> version major) (-> version minor)) - (file-stream-close file) - (return #f) - ) - ) - (dosettings (file) - (case-str *pc-temp-string* - (("fps") (set-frame-rate! obj (file-stream-read-int file))) - (("window-size") - (set! (-> obj win-width) (file-stream-read-int file)) - (set! (-> obj win-height) (file-stream-read-int file)) - ) - (("game-size") - (set! (-> obj width) (file-stream-read-int file)) - (set! (-> obj height) (file-stream-read-int file)) - ) - (("msaa") (set! (-> obj gfx-msaa) (file-stream-read-int file))) - (("aspect-state") - ;; game aspect - (set! (-> *setting-control* default aspect-ratio) (file-stream-read-symbol file)) - ;; aspect ratio - (set! (-> obj aspect-custom-x) (file-stream-read-int file)) - (set! (-> obj aspect-custom-y) (file-stream-read-int file)) - ;; aspect auto - (set! (-> obj aspect-ratio-auto?) (file-stream-read-symbol file)) - - (unless (-> obj aspect-ratio-auto?) - (set-aspect! obj (-> obj aspect-custom-x) (-> obj aspect-custom-y)) - ) - ) - (("display-mode") (set-display-mode! obj (file-stream-read-symbol file))) - (("monitor") (set-monitor! obj (file-stream-read-int file))) - (("letterbox") (set! (-> obj letterbox?) (file-stream-read-symbol file))) - (("vsync") (set! (-> obj vsync?) (file-stream-read-symbol file))) - (("font-scale") (set! (-> obj font-scale) (file-stream-read-float file))) - (("audio-latency-ms") (set! (-> obj audio-latency-ms) (file-stream-read-int file))) - (("audio-pan-override") (set! (-> obj audio-pan-override) (file-stream-read-float file))) - (("audio-volume-override") (set! (-> obj audio-volume-override) (file-stream-read-float file))) - (("audio-channel-nb") (set! (-> obj audio-channel-nb) (file-stream-read-int file))) - (("gfx-renderer") (set! (-> obj gfx-renderer) (the-as pc-gfx-renderer (file-stream-read-int file)))) - (("gfx-resolution") (set! (-> obj gfx-resolution) (file-stream-read-float file))) - (("gfx-anisotropy") (set! (-> obj gfx-anisotropy) (file-stream-read-float file))) - (("shrub-dist-mod") (set! (-> obj shrub-dist-mod) (file-stream-read-float file))) - (("lod-dist-mod") (set! (-> obj lod-dist-mod) (file-stream-read-float file))) - (("lod-force-tfrag") (set! (-> obj lod-force-tfrag) (file-stream-read-int file))) - (("lod-force-tie") (set! (-> obj lod-force-tie) (file-stream-read-int file))) - (("lod-force-ocean") (set! (-> obj lod-force-ocean) (file-stream-read-int file))) - (("lod-force-actor") (set! (-> obj lod-force-actor) (file-stream-read-int file))) - (("game-language") (set! (-> *setting-control* default language) (the-as language-enum (file-stream-read-int file)))) - (("text-language") (set! (-> obj text-language) (the-as pc-subtitle-lang (file-stream-read-int file)))) - (("subtitle-language") (set! (-> obj subtitle-language) (the-as pc-subtitle-lang (file-stream-read-int file)))) - (("subtitle-speaker") (set! (-> obj subtitle-speaker?) (file-stream-read-symbol file))) - (("stick-deadzone") (set! (-> obj stick-deadzone) (file-stream-read-float file))) - (("ps2-read-speed?") (set! (-> obj ps2-read-speed?) (file-stream-read-symbol file))) - (("ps2-parts?") (set! (-> obj ps2-parts?) (file-stream-read-symbol file))) - (("ps2-music?") (set! (-> obj ps2-music?) (file-stream-read-symbol file))) - (("ps2-se?") (set! (-> obj ps2-se?) (file-stream-read-symbol file))) - (("ps2-hints?") (set! (-> obj ps2-hints?) (file-stream-read-symbol file))) - (("ps2-lod-dist?") (set! (-> obj ps2-lod-dist?) (file-stream-read-symbol file))) - (("force-envmap?") (set! (-> obj force-envmap?) (file-stream-read-symbol file))) - (("force-actors?") (set! (-> obj force-actors?) (file-stream-read-symbol file))) - (("music-fade?") (set! (-> obj music-fade?) (file-stream-read-symbol file))) - (("use-vis?") (set! (-> obj use-vis?) (file-stream-read-symbol file))) - (("skip-movies?") (set! (-> obj skip-movies?) (file-stream-read-symbol file))) - (("subtitles?") (set! (-> obj subtitles?) (file-stream-read-symbol file))) - (("hinttitles?") (set! (-> obj hinttitles?) (file-stream-read-symbol file))) - (("discord-rpc?") (set! (-> obj discord-rpc?) (file-stream-read-symbol file))) - (("speedrunner-mode?") (set! (-> obj speedrunner-mode?) (file-stream-read-symbol file))) - (("cutscene-skips?") (file-stream-read-symbol file)) - (("first-camera-h-inverted?") (set! (-> obj first-camera-h-inverted?) (file-stream-read-symbol file))) - (("first-camera-v-inverted?") (set! (-> obj first-camera-v-inverted?) (file-stream-read-symbol file))) - (("third-camera-h-inverted?") (set! (-> obj third-camera-h-inverted?) (file-stream-read-symbol file))) - (("third-camera-v-inverted?") (set! (-> obj third-camera-v-inverted?) (file-stream-read-symbol file))) - (("money-starburst?") (set! (-> obj money-starburst?) (file-stream-read-symbol file))) - (("extra-hud?") (set! (-> obj extra-hud?) (file-stream-read-symbol file))) - (("music-fadein?") (set! (-> obj music-fadein?) (file-stream-read-symbol file))) - (("music-fadeout?") (set! (-> obj music-fadeout?) (file-stream-read-symbol file))) - (("scenes-seen") - (dotimes (i PC_SPOOL_LOG_LENGTH) - (set! (-> obj scenes-seen i) (file-stream-read-int file)) - ) - ) - (("secrets") - (dosettings (file) - (case-str *pc-temp-string* - (("hard-rats?") (set! (-> obj secrets hard-rats?) (file-stream-read-symbol file))) - (("hero-mode?") (set! (-> obj secrets hero-mode?) (file-stream-read-symbol file))) - (("hud-map?") (set! (-> obj secrets hud-map?) (file-stream-read-symbol file))) - (("hud-counters?") (set! (-> obj secrets hud-counters?) (file-stream-read-symbol file))) - (("hud-watch?") (set! (-> obj secrets hud-watch?) (file-stream-read-symbol file))) - (("watch-12hr?") (set! (-> obj secrets watch-12hr?) (file-stream-read-symbol file))) - (("art") (set! (-> obj secrets art) (the-as pc-jak1-concept-art (file-stream-read-int file)))) - (("hard-fish-hiscore") (set! (-> obj secrets hard-fish-hiscore) (file-stream-read-int file))) - (("hard-rats-hiscore") (set! (-> obj secrets hard-rats-hiscore) (file-stream-read-int file))) - (("hard-rats-hiwave") (set! (-> obj secrets hard-rats-hiwave) (file-stream-read-int file))) - (("cheats") - (set! (-> obj cheats-known) (the pc-cheats (file-stream-read-int file))) - (set! (-> obj cheats) (logand (-> obj cheats-known) (file-stream-read-int file))) - ) - (("music") - (dotimes (i PC_MUSIC_LOG_LENGTH) - (when (!= #x29 (file-stream-get-next-char-ret file)) - (with-settings-scope (file) - (set! (-> obj secrets music i name) (file-stream-read-symbol file)) - (set! (-> obj secrets music i flava-mask) (file-stream-read-int file)) - ) - ) - ) - ) - ) - ) - ) - (("panic") - (when (file-stream-read-symbol file) - (file-stream-close file) - (reset obj) - (write-to-file obj filename) - (set-display-mode! obj #f) - (return #f) - ) - ) - ) - ) - ;; upgrade settings if minor changes - ;; remember to delete this when major changes to the version number are made - (when (and (= PC_KERNEL_VER_MAJOR 1) - (= PC_KERNEL_VER_MINOR 10) - (or (!= PC_KERNEL_VER_BUILD (-> version build)) - (!= PC_KERNEL_VER_REVISION (-> version revision)))) - ;; 1.10 upgrade: turn envmap on - (set! (-> obj force-envmap?) #t) - ) - ) - ) - ) - - ) - - (file-stream-close file) - ) - - (format 0 "pc settings file read: ~A~%" filename) - - ;; restore the windowed mode resolution properly - (when (= (-> obj display-mode) 'windowed) - (pc-set-window-size (max PC_MIN_WIDTH (-> obj win-width)) (max PC_MIN_HEIGHT (-> obj win-height)))) - - #t - ) - -(defmethod write-to-file pc-settings ((obj pc-settings) (filename string)) - "write settings to a file" - - (if (not filename) - (return #f)) - - (let ((file (new 'stack 'file-stream filename 'write))) - (if (not (file-stream-valid? file)) - (return #f)) - - (format file "(settings #x~X~%" (-> obj version)) - - (format file " (fps ~D)~%" (-> obj target-fps)) - (format file " (msaa ~D)~%" (-> obj gfx-msaa)) - (format file " (aspect-state ~A ~D ~D ~A)~%" (-> *setting-control* default aspect-ratio) - (-> obj aspect-custom-x) (-> obj aspect-custom-y) - (-> obj aspect-ratio-auto?)) - (format file " (display-mode ~A)~%" (-> obj display-mode)) - (format file " (window-size ~D ~D)~%" (-> obj win-width) (-> obj win-height)) - (format file " (game-size ~D ~D)~%" (-> obj width) (-> obj height)) - (format file " (monitor ~D)~%" (-> obj monitor)) - (format file " (letterbox ~A)~%" (-> obj letterbox?)) - (format file " (vsync ~A)~%" (-> obj vsync?)) - (format file " (font-scale ~f)~%" (-> obj font-scale)) - - (format file " (audio-latency-ms ~D)~%" (-> obj audio-latency-ms)) - (format file " (audio-pan-override ~f)~%" (-> obj audio-pan-override)) - (format file " (audio-volume-override ~f)~%" (-> obj audio-volume-override)) - (format file " (audio-channel-nb ~D)~%" (-> obj audio-channel-nb)) - - (format file " (gfx-renderer ~D)~%" (-> obj gfx-renderer)) - (format file " (gfx-resolution ~f)~%" (-> obj gfx-resolution)) - (format file " (gfx-anisotropy ~f)~%" (-> obj gfx-anisotropy)) - (format file " (shrub-dist-mod ~f)~%" (-> obj shrub-dist-mod)) - (format file " (lod-dist-mod ~f)~%" (-> obj lod-dist-mod)) - (format file " (lod-force-tfrag ~D)~%" (-> obj lod-force-tfrag)) - (format file " (lod-force-tie ~D)~%" (-> obj lod-force-tie)) - (format file " (lod-force-ocean ~D)~%" (-> obj lod-force-ocean)) - (format file " (lod-force-actor ~D)~%" (-> obj lod-force-actor)) - - (format file " (stick-deadzone ~f)~%" (-> obj stick-deadzone)) - - (format file " (ps2-read-speed? ~A)~%" (-> obj ps2-read-speed?)) - (format file " (ps2-parts? ~A)~%" (-> obj ps2-parts?)) - (format file " (ps2-music? ~A)~%" (-> obj ps2-music?)) - (format file " (ps2-se? ~A)~%" (-> obj ps2-se?)) - (format file " (ps2-hints? ~A)~%" (-> obj ps2-hints?)) - (format file " (ps2-lod-dist? ~A)~%" (-> obj ps2-lod-dist?)) - (format file " (force-envmap? ~A)~%" (-> obj force-envmap?)) - (format file " (music-fade? ~A)~%" (-> obj music-fade?)) - (format file " (use-vis? ~A)~%" (-> obj use-vis?)) - (format file " (skip-movies? ~A)~%" (-> obj skip-movies?)) - (format file " (discord-rpc? ~A)~%" (-> obj discord-rpc?)) - (format file " (speedrunner-mode? ~A)~%" (-> obj speedrunner-mode?)) - (format file " (first-camera-h-inverted? ~A)~%" (-> obj first-camera-h-inverted?)) - (format file " (first-camera-v-inverted? ~A)~%" (-> obj first-camera-v-inverted?)) - (format file " (third-camera-h-inverted? ~A)~%" (-> obj third-camera-h-inverted?)) - (format file " (third-camera-v-inverted? ~A)~%" (-> obj third-camera-v-inverted?)) - (format file " (money-starburst? ~A)~%" (-> obj money-starburst?)) - (format file " (force-actors? ~A)~%" (-> obj force-actors?)) - (format file " (extra-hud? ~A)~%" (-> obj extra-hud?)) - (format file " (music-fadein? ~A)~%" (-> obj music-fadein?)) - (format file " (music-fadeout? ~A)~%" (-> obj music-fadeout?)) - (format file " (subtitles? ~A)~%" (-> obj subtitles?)) - (format file " (hinttitles? ~A)~%" (-> obj hinttitles?)) - (format file " (game-language ~D)~%" (-> *setting-control* default language)) - (format file " (text-language ~D)~%" (-> obj text-language)) - (format file " (subtitle-language ~D)~%" (-> obj subtitle-language)) - (format file " (subtitle-speaker ~A)~%" (-> obj subtitle-speaker?)) - - #| - (format file " (scenes-seen") - (dotimes (i PC_SPOOL_LOG_LENGTH) - (if (zero? (mod i 16)) - (format file "~% ") - ) - (format file " ~D" (-> obj scenes-seen i)) - ) - (format file "~% )~%") - |# - - (format file " (secrets~%") - #| - (format file " (art #x~X)~%" (-> obj secrets art)) - (format file " (hard-rats? ~A)~%" (-> obj secrets hard-rats?)) - (format file " (hero-mode? ~A)~%" (-> obj secrets hero-mode?)) - (format file " (hud-map? ~A)~%" (-> obj secrets hud-map?)) - (format file " (hud-counters? ~A)~%" (-> obj secrets hud-counters?)) - (format file " (hard-fish-hiscore ~D)~%" (-> obj secrets hard-fish-hiscore)) - (format file " (hard-rats-hiscore ~D)~%" (-> obj secrets hard-rats-hiscore)) - (format file " (hard-rats-hiwave ~D)~%" (-> obj secrets hard-rats-hiwave)) - |# - (format file " (cheats #x~x #x~x)~%" (-> obj cheats-known) (-> obj cheats)) - - (format file " (music~%") - (dotimes (i PC_MUSIC_LOG_LENGTH) - (if (-> obj secrets music i name) - (format file " (~A #x~X)~%" (-> obj secrets music i name) (-> obj secrets music i flava-mask)) - ) - ) - - (format file " )~%") - - (format file " )~%") - - (format file " )~%") - (file-stream-close file) - ) - - (format 0 "pc settings file write: ~A~%" filename) - - #t - ) - -(defmethod load-settings pc-settings ((obj pc-settings)) - "load" - - (format (clear *pc-temp-string-1*) "~S/pc-settings.gc" *pc-settings-folder*) - (if (pc-filepath-exists? *pc-temp-string-1*) - (begin - (format 0 "[PC] PC Settings found at '~S'...loading!~%" *pc-temp-string-1*) - (unless (read-from-file obj *pc-temp-string-1*) - (format 0 "[PC] PC Settings found at '~S' but could not be loaded, using defaults!~%" *pc-temp-string-1*) - (reset obj))) - (format 0 "[PC] PC Settings not found at '~S'...initializing with defaults!~%" *pc-temp-string-1*)) + (with-profiler "speedrun-update-jak1" + (speedrun-mode-update)) 0) -(defmethod new pc-settings ((allocation symbol) (type-to-make type)) - "make a new pc-settings" - (let ((obj (object-new allocation type-to-make (the-as int (-> type-to-make size))))) - (reset obj) - ;; auto load settings if available - ;; if saved settings are corrupted or not found, use defaults +(defmethod update-progress-video-hacks pc-settings-jak1 ((obj pc-settings-jak1)) + "update the graphics hacks used for the progress menu. ugh." - (load-settings obj) + (set-hud-aspect-ratio 'aspect4x3 'ntsc) ;; set hud aspect ratios every frame because why not? - obj)) + (when *progress-process* + ;; adjust sizes for progress. + ;; video.gc sets the sizes in the normal game. + ;; this is a complete hack and i'm losing it + (let ((pr (-> *progress-process*)) + ;(wide-adjust (* 4.0 (- (/ (-> obj aspect-ratio-scale) ASPECT_16X9_SCALE) (1/ ASPECT_16X9_SCALE)))) + ) + (set! (-> pr sides-x-scale) 1.0) + (set! (-> pr sides-y-scale) 13.0) + ;(set! (-> pr left-x-offset) (+ 59 (the int (* (-> obj aspect-ratio-scale) -59)))) + ;(set! (-> pr right-x-offset) 26) + ;(set! (-> pr button-scale) (+ 1.0 (* wide-adjust 0.1))) + ) + ) + ) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; file I/O +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + +(defmethod handle-input-settings pc-settings-jak1 ((obj pc-settings-jak1) (file file-stream)) + "handle the text parsing input for the 'settings' group" + + ((method-of-type pc-settings handle-input-settings) obj file) + (case-str *pc-temp-string* + (("money-starburst?") (set! (-> obj money-starburst?) (file-stream-read-symbol file))) + (("extra-hud?") (set! (-> obj extra-hud?) (file-stream-read-symbol file))) + (("skip-movies?") (set! (-> obj skip-movies?) (file-stream-read-symbol file))) + (("subtitles?") (set! (-> obj subtitles?) (file-stream-read-symbol file))) + (("subtitle-language") (set! (-> obj subtitle-language) (the-as pc-subtitle-lang (file-stream-read-int file)))) + ) + 0) + +(defmethod handle-output-settings pc-settings-jak1 ((obj pc-settings-jak1) (file file-stream)) + "handle the text writing output for the 'settings' group" + + ((method-of-type pc-settings handle-output-settings) obj file) + (format file " (money-starburst? ~A)~%" (-> obj money-starburst?)) + (format file " (extra-hud? ~A)~%" (-> obj extra-hud?)) + (format file " (skip-movies? ~A)~%" (-> obj skip-movies?)) + (format file " (subtitles? ~A)~%" (-> obj subtitles?)) + (format file " (subtitle-language ~D)~%" (-> obj subtitle-language)) + 0) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; PC settings ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(define *pc-settings* (new 'global 'pc-settings)) +(define *pc-settings* (new 'global 'pc-settings-jak1)) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;; entity debugging +;;;; other ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(when *debug-segment* - -(deftype entity-debug-inspect (basic) - ( - (scroll-y int16) - (scroll-y-max int16) - (entity entity) - (show-actor-info symbol) - ) - (:methods - (new (symbol type) _type_) - (set-entity! (_type_ entity) entity) - (update-pad (_type_ int) none) - ) - ) - -(defmethod new entity-debug-inspect ((allocation symbol) (type-to-make type)) - "make a new entity-debug-inspect object" - - (let ((obj (object-new allocation type-to-make (the-as int (-> type-to-make size))))) - - (set! (-> obj scroll-y) 0) - (set! (-> obj scroll-y-max) 0) - (set! (-> obj entity) (the entity #f)) - (set! (-> obj show-actor-info) #f) - obj - ) - ) - -(defmethod set-entity! entity-debug-inspect ((obj entity-debug-inspect) (e entity)) - "set the entity to inspect" - - (set! (-> obj entity) e) - (unless e - (set! *display-actor-anim* (the string #f))) - (set! (-> obj scroll-y) 0) - - e - ) - -(defmethod update-pad entity-debug-inspect ((obj entity-debug-inspect) (pad-idx int)) - "respond to pad inputs" - - ;; scroll up - (if (cpad-pressed? pad-idx l1) - (1-! (-> obj scroll-y))) - ;; scroll down - (if (cpad-pressed? pad-idx r1) - (1+! (-> obj scroll-y))) - ;; toggle actor info - (if (cpad-pressed? pad-idx l3) - (not! (-> obj show-actor-info))) - - (minmax! (-> obj scroll-y) 0 (-> obj scroll-y-max)) - - (none)) - - -(define *entity-debug-inspect* (new 'debug 'entity-debug-inspect)) - -) ;; when debug_segment - (defun draw-build-revision () (with-dma-buffer-add-bucket ((buf (-> (current-frame) global-buf)) (bucket-id debug-no-zbuf)) (draw-string-xy *pc-settings-built-sha* buf - 0 - (* 10 (-> *video-parms* relative-y-scale)) + 0 (* 10 (-> (get-video-params) relative-y-scale)) (font-color flat-yellow) (font-flags shadow kerning)))) - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; process pools ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -1191,6 +381,3 @@ ;; the actor pool for PC processes! it has space for 4 processes, with 16K of space. (define *pc-dead-pool* (new 'global 'dead-pool 4 (* 16 1024) '*pc-dead-pool*)) - - - diff --git a/goal_src/jak2/dgos/engine.gd b/goal_src/jak2/dgos/engine.gd index c52491aeef..12a79059cf 100644 --- a/goal_src/jak2/dgos/engine.gd +++ b/goal_src/jak2/dgos/engine.gd @@ -29,8 +29,10 @@ "dma-buffer.o" "dma-bucket.o" "dma-disasm.o" - "pad.o" "pckernel-h.o" ;; added + "pckernel-impl.o" ;; added + "pc-debug-common.o" ;; added + "pad.o" "gs.o" "display-h.o" "geometry.o" @@ -242,6 +244,7 @@ "sky-data.o" "sky-tng.o" "load-state.o" + "pc-debug-methods.o" ;; added "level-info.o" "level.o" "text.o" @@ -325,6 +328,7 @@ "prototype.o" "main-collide.o" "video.o" + "pckernel-common.o" ;; added "pckernel.o" ;; added "main.o" "collide-cache.o" diff --git a/goal_src/jak2/dgos/game.gd b/goal_src/jak2/dgos/game.gd index 88358e1ac1..e5d648e5cd 100644 --- a/goal_src/jak2/dgos/game.gd +++ b/goal_src/jak2/dgos/game.gd @@ -29,8 +29,10 @@ "dma-buffer.o" "dma-bucket.o" "dma-disasm.o" - "pad.o" "pckernel-h.o" ;; added + "pckernel-impl.o" ;; added + "pc-debug-common.o" ;; added + "pad.o" "gs.o" "display-h.o" "geometry.o" @@ -242,6 +244,7 @@ "sky-data.o" "sky-tng.o" "load-state.o" + "pc-debug-methods.o" ;; added "level-info.o" "level.o" "text.o" @@ -325,6 +328,7 @@ "prototype.o" "main-collide.o" "video.o" + "pckernel-common.o" ;; added "pckernel.o" ;; added "main.o" "collide-cache.o" diff --git a/goal_src/jak2/engine/ambient/ambient.gc b/goal_src/jak2/engine/ambient/ambient.gc index 86d9438ca8..7aa6c7ffd7 100644 --- a/goal_src/jak2/engine/ambient/ambient.gc +++ b/goal_src/jak2/engine/ambient/ambient.gc @@ -268,7 +268,7 @@ 36 310 0.0 - (font-color default-#cddbcd) + (font-color default) (font-flags shadow kerning) ) ) diff --git a/goal_src/jak2/engine/debug/debug.gc b/goal_src/jak2/engine/debug/debug.gc index 25ae63d077..69b9481227 100644 --- a/goal_src/jak2/engine/debug/debug.gc +++ b/goal_src/jak2/engine/debug/debug.gc @@ -983,7 +983,7 @@ (defun-debug add-debug-text-sphere ((enable symbol) (bucket bucket-id) (position vector) (radius meters) (text string) (color rgba)) "Add a debug sphere at the given point, with some text. The color is for the sphere - the text is color 0." (add-debug-sphere enable bucket position radius color) - (add-debug-text-3d enable bucket text position (font-color default-#cddbcd) (the-as vector2h #f)) + (add-debug-text-3d enable bucket text position (font-color default) (the-as vector2h #f)) #f ) @@ -1618,7 +1618,7 @@ (+ y -4) (cond ((= v1-7 1) - (font-color precursor-#ec3b00) + (font-color red) ) ((= v1-7 2) (font-color yellow-#f3f300) @@ -1627,7 +1627,7 @@ (font-color green-#3df23d) ) (else - (font-color default-#cddbcd) + (font-color default) ) ) (font-flags shadow) diff --git a/goal_src/jak2/engine/debug/menu.gc b/goal_src/jak2/engine/debug/menu.gc index 07c95dd6da..1018e7ed30 100644 --- a/goal_src/jak2/engine/debug/menu.gc +++ b/goal_src/jak2/engine/debug/menu.gc @@ -63,7 +63,7 @@ 0 0 0.0 - (font-color default-#cddbcd) + (font-color default) (font-flags shadow kerning) ) ) @@ -289,7 +289,7 @@ (let ((v0-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) (set! (-> v0-0 name) arg0) (set! (-> v0-0 parent) #f) - (set! (-> v0-0 refresh-delay) 23) + (set! (-> v0-0 refresh-delay) (#if PC_PORT 1 23)) (set! (-> v0-0 refresh-ctr) (-> v0-0 refresh-delay)) (set! (-> v0-0 id) (the-as int arg1)) (set! (-> v0-0 activate-func) arg2) @@ -484,7 +484,7 @@ (let ((v1-2 (/ arg2 8))) (set! (-> gp-0 name) arg0) (set! (-> gp-0 parent) #f) - (set! (-> gp-0 refresh-delay) 31) + (set! (-> gp-0 refresh-delay) (#if PC_PORT 1 31)) (set! (-> gp-0 refresh-ctr) (-> gp-0 refresh-delay)) (set! (-> gp-0 id) arg1) (set! v1-2 (cond diff --git a/goal_src/jak2/engine/entity/entity.gc b/goal_src/jak2/engine/entity/entity.gc index 3acf4f2fa4..78bfa8ff38 100644 --- a/goal_src/jak2/engine/entity/entity.gc +++ b/goal_src/jak2/engine/entity/entity.gc @@ -1106,7 +1106,7 @@ (res-lump-struct sv-16 'name string) (-> (the-as process-drawable arg0) root trans) (if (logtest? (-> sv-16 extra perm status) (entity-perm-status bit-0 bit-1)) - (font-color precursor-#ec3b00) + (font-color red) (font-color #dadada) ) (new 'static 'vector2h :data (new 'static 'array int16 2 0 8)) diff --git a/goal_src/jak2/engine/game/game-save.gc b/goal_src/jak2/engine/game/game-save.gc index 757a561ba3..0d66fc576b 100644 --- a/goal_src/jak2/engine/game/game-save.gc +++ b/goal_src/jak2/engine/game/game-save.gc @@ -1655,7 +1655,7 @@ 32 320 0.0 - (font-color default-#cddbcd) + (font-color default) (font-flags shadow kerning) ) ) @@ -1679,7 +1679,7 @@ 20 80 0.0 - (font-color default-#cddbcd) + (font-color default) (font-flags shadow kerning) ) ) diff --git a/goal_src/jak2/engine/game/main.gc b/goal_src/jak2/engine/game/main.gc index 9e3b2ae6b4..f4860f178f 100644 --- a/goal_src/jak2/engine/game/main.gc +++ b/goal_src/jak2/engine/game/main.gc @@ -23,23 +23,39 @@ (defun letterbox () "Draw letterbox bars." - (let* ((s5-0 (-> *display* frames (-> *display* on-screen) global-buf)) - (gp-0 (-> s5-0 base)) - ) - (draw-sprite2d-xy-absolute s5-0 0 0 512 46 (new 'static 'rgba :a #x80)) - (draw-sprite2d-xy-absolute s5-0 0 370 512 47 (new 'static 'rgba :a #x80)) - (let ((a3-2 (-> s5-0 base))) - (let ((v1-7 (the-as dma-packet (-> s5-0 base)))) - (set! (-> v1-7 dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> v1-7 vif0) (new 'static 'vif-tag)) - (set! (-> v1-7 vif1) (new 'static 'vif-tag)) - (set! (-> s5-0 base) (the-as pointer (&+ v1-7 16))) + (with-dma-buffer-add-bucket ((dma-buf (-> (current-frame) global-buf)) + (bucket-id screen-filter)) + (#cond + ((not PC_PORT) + (draw-sprite2d-xy-absolute dma-buf 0 0 512 46 (new 'static 'rgba :a #x80)) + (draw-sprite2d-xy-absolute dma-buf 0 370 512 47 (new 'static 'rgba :a #x80)) ) - (dma-bucket-insert-tag - (-> *display* frames (-> *display* on-screen) bucket-group) - (bucket-id screen-filter) - gp-0 - (the-as (pointer dma-tag) a3-2) + (#t + (if (-> *pc-settings* use-vis?) + ;; original game mode. dont do anything. + (begin + (draw-sprite2d-xy-absolute dma-buf 0 0 512 46 (new 'static 'rgba :a #x80)) + (draw-sprite2d-xy-absolute dma-buf 0 370 512 47 (new 'static 'rgba :a #x80))) + ;; native mode. force 16x9 letterboxing always. + (begin + (cond + ((< (-> *pc-settings* aspect-ratio) ASPECT_16X9) + ;; too tall. needs vertical letterboxing. + (let ((lbx-h (the int (* 112.0 (- 1.0 (/ (-> *pc-settings* aspect-ratio) ASPECT_16X9)))))) + (draw-sprite2d-xy dma-buf 0 0 512 lbx-h (new 'static 'rgba :a #x80)) + (draw-sprite2d-xy dma-buf 0 (- 448 lbx-h) 512 lbx-h (new 'static 'rgba :a #x80)) + ) + ) + ((> (-> *pc-settings* aspect-ratio) ASPECT_16X9) + ;; too wide. needs horizontal letterboxing. + (let ((lbx-w (the int (* 256.0 (- 1.0 (/ ASPECT_16X9 (-> *pc-settings* aspect-ratio))))))) + (draw-sprite2d-xy dma-buf 0 0 lbx-w 448 (new 'static 'rgba :a #x80)) + (draw-sprite2d-xy dma-buf (- 512 lbx-w) 0 lbx-w 448 (new 'static 'rgba :a #x80)) + ) + ) + ) + ) + ) ) ) ) @@ -1276,48 +1292,6 @@ ;; - display-frame-start ;; ) -(defconstant MEM_BAR_WIDTH 152) -(defconstant MEM_BAR_HEIGHT 15) -(defconstant MEM_BAR_NUM 11) -(defconstant MEM_BAR_BG_COL (static-rgba 64 64 64 64)) -(defconstant MEM_BAR_X (- 475 MEM_BAR_WIDTH)) -(defconstant MEM_BAR_Y (- 424 4 (* MEM_BAR_HEIGHT MEM_BAR_NUM))) -(defmacro draw-memory-bar-generic (buf &key remain &key total &key name &key idx &key color) - `(let* ( - (total (the float ,total)) - (remain (the float ,remain)) - (used-p (/ (- total remain) total)) - (used-x (the int (* used-p MEM_BAR_WIDTH))) - (used-y (+ MEM_BAR_Y (* ,idx MEM_BAR_HEIGHT))) - ) - (draw-sprite2d-xy ,buf MEM_BAR_X used-y used-x MEM_BAR_HEIGHT ,color) - (draw-sprite2d-xy ,buf (+ MEM_BAR_X used-x) used-y (- MEM_BAR_WIDTH used-x) MEM_BAR_HEIGHT MEM_BAR_BG_COL) - (draw-string-xy ,name ,buf MEM_BAR_X used-y (font-color precursor-#ec3b00) (font-flags shadow kerning right)) - (draw-string-xy (string-format "~,,2f%" (* used-p 100)) ,buf (+ MEM_BAR_X used-x) used-y (font-color precursor-#ec3b00) (font-flags shadow kerning middle)) - (draw-string-xy (string-format "~,,1fM" (/ total (* 1024 1024))) ,buf (+ MEM_BAR_X MEM_BAR_WIDTH) used-y (font-color precursor-#ec3b00) (font-flags shadow kerning left)) - ) - ) -(defmacro draw-memory-bar-kheap (buf heap &key (name #f) &key idx &key color) - `(let ((heap ,heap)) - (draw-memory-bar-generic ,buf - :remain (&- (-> heap top) (-> heap current)) - :total (&- (-> heap top) (-> heap base)) - :name ,(if name name (symbol->string heap)) - :idx ,idx - :color ,color) - ) - ) -(defmacro draw-memory-bar-dead-pool-heap (buf heap &key (name #f) &key idx &key color) - `(let* ((heap ,heap) (pool-total (memory-total heap))) - (draw-memory-bar-generic ,buf - :remain (- pool-total (memory-used heap)) - :total pool-total - :name ,(if name name (symbol->string heap)) - :idx ,idx - :color ,color) - ) - ) - (defun end-display ((arg0 display)) "Update debug drawing: - debug draws (triangles, spheres, etc) @@ -1368,44 +1342,14 @@ (when *display-deci-count* (let ((s2-0 draw-string-xy)) (format (clear *temp-string*) "~D" *deci-count*) - (s2-0 *temp-string* s3-0 448 210 (font-color default-#cddbcd) (font-flags shadow)) + (s2-0 *temp-string* s3-0 448 210 (font-color default) (font-flags shadow)) ) ) (#when PC_PORT - (when (-> *pc-settings* display-heap-status) - (let ((idx 0)) - (draw-memory-bar-kheap s3-0 global :idx idx :color (static-rgba 32 32 255 64)) - (draw-memory-bar-kheap s3-0 debug :idx (+! idx 1) :color (static-rgba 255 32 32 64)) - (if (!= (-> *level* level 0 status) 'inactive) - (draw-memory-bar-kheap s3-0 (-> *level* level 0 heap) :name "l0" :idx (+! idx 1) :color (static-rgba 32 255 255 64)) - ) - (if (!= (-> *level* level 1 status) 'inactive) - (draw-memory-bar-kheap s3-0 (-> *level* level 1 heap) :name "l1" :idx (+! idx 1) :color (static-rgba 255 32 255 64)) - ) - (if (!= (-> *level* level 2 status) 'inactive) - (draw-memory-bar-kheap s3-0 (-> *level* level 2 heap) :name "l2" :idx (+! idx 1) :color (static-rgba 255 255 32 64)) - ) - (if (!= (-> *level* level 3 status) 'inactive) - (draw-memory-bar-kheap s3-0 (-> *level* level 3 heap) :name "l3" :idx (+! idx 1) :color (static-rgba 32 255 255 64)) - ) - (if (!= (-> *level* level 4 status) 'inactive) - (draw-memory-bar-kheap s3-0 (-> *level* level 4 heap) :name "l4" :idx (+! idx 1) :color (static-rgba 255 32 255 64)) - ) - (if (!= (-> *level* level 5 status) 'inactive) - (draw-memory-bar-kheap s3-0 (-> *level* level 5 heap) :name "l5" :idx (+! idx 1) :color (static-rgba 255 255 32 64)) - ) - (draw-memory-bar-dead-pool-heap s3-0 *nk-dead-pool* :name "actor" :idx (+! idx 1) :color (static-rgba 32 255 32 64)) - (draw-memory-bar-generic s3-0 - :remain (* 16 (dma-buffer-free (-> *display* frames (-> *display* on-screen) global-buf))) - :total (length (-> *display* frames (-> *display* on-screen) global-buf)) - :name "dma-global" :idx (+! idx 1) :color (static-rgba 32 32 255 64)) - (draw-memory-bar-generic s3-0 - :remain (* 16 (dma-buffer-free (-> *display* frames (-> *display* on-screen) debug-buf))) - :total (length (-> *display* frames (-> *display* on-screen) debug-buf)) - :name "dma-debug" :idx (+! idx 1) :color (static-rgba 255 32 32 64)) - ) - ) + (draw *pc-settings* s3-0) + (draw-memory *pc-settings* s3-0) + (print-debug-misc *pc-settings*) ) (display-file-info) ) @@ -1430,7 +1374,7 @@ 352 320 ) - (font-color precursor-#ec3b00) + (font-color red) (font-flags shadow kerning middle large) ) ) @@ -1450,7 +1394,7 @@ buf (the int (-> *font-context* origin x)) s2-2 - (font-color default-#cddbcd) + (font-color default) (font-flags shadow) ) ) @@ -1461,7 +1405,7 @@ buf (the int (-> *font-context* origin x)) a3-6 - (font-color default-#cddbcd) + (font-color default) (font-flags shadow) ) ) @@ -1589,6 +1533,16 @@ ) (letterbox) ) + (if (#if (not PC_PORT) + (and (= (-> *setting-control* user-current aspect-ratio) 'aspect4x3) + (or (zero? *screen-shot-work*) (= (-> *screen-shot-work* count) -1)) + ) + (or (and (= (-> *setting-control* user-current aspect-ratio) 'aspect4x3) + (or (zero? *screen-shot-work*) (= (-> *screen-shot-work* count) -1)) + ) + (not (-> *pc-settings* use-vis?)))) + (letterbox) + ) ) ;; blackout drawing diff --git a/goal_src/jak2/engine/geometry/path.gc b/goal_src/jak2/engine/geometry/path.gc index cfa8734d7d..94d1a73cf3 100644 --- a/goal_src/jak2/engine/geometry/path.gc +++ b/goal_src/jak2/engine/geometry/path.gc @@ -21,7 +21,7 @@ (the-as bucket-id s3-0) *temp-string* (-> obj process root trans) - (font-color precursor-#ec3b00) + (font-color red) (the-as vector2h #f) ) ) @@ -407,7 +407,7 @@ using the fractional component of `idx` as the interpolant, return this result (the-as bucket-id s3-0) *temp-string* (-> obj process root trans) - (font-color precursor-#ec3b00) + (font-color red) (the-as vector2h #f) ) ) diff --git a/goal_src/jak2/engine/gfx/font-h.gc b/goal_src/jak2/engine/gfx/font-h.gc index ca553f6e23..0312747463 100644 --- a/goal_src/jak2/engine/gfx/font-h.gc +++ b/goal_src/jak2/engine/gfx/font-h.gc @@ -12,10 +12,10 @@ ;; +++font-color (defenum font-color :type uint32 - (default-#cddbcd 0) + (default 0) (#dadada 1) (#ededed 2) - (precursor-#ec3b00 3) + (red 3) (gold-#ba9200 4) (yellow-#f3f300 5) (green-#3df23d 6) @@ -32,7 +32,7 @@ (#a6b5a6 17) (#757f75 18) (#5e3f5e 19) - (#f0e387 20) + (flat-yellow 20) (#3fbaed 21) (#3a3a3a 22) (#5c5c5c 23) diff --git a/goal_src/jak2/engine/gfx/hw/display-h.gc b/goal_src/jak2/engine/gfx/hw/display-h.gc index 9f207122d4..369f646889 100644 --- a/goal_src/jak2/engine/gfx/hw/display-h.gc +++ b/goal_src/jak2/engine/gfx/hw/display-h.gc @@ -129,3 +129,23 @@ (defmacro current-frame () `(-> *display* frames (-> *display* on-screen)) ) + +(defmacro current-time () + `(-> *display* base-frame-counter) + ) + +(defmacro integral-current-time () + `(-> *display* integral-frame-counter) + ) + +(defmacro real-current-time () + `(-> *display* real-frame-counter) + ) + + +;; debug stuff really +(defmacro get-screen-x (frac) + `(the int (* ,frac 512))) + +(defmacro get-screen-y (frac) + `(the int (* ,frac 224))) diff --git a/goal_src/jak2/engine/gfx/hw/display.gc b/goal_src/jak2/engine/gfx/hw/display.gc index b737bc0e44..c92f46c915 100644 --- a/goal_src/jak2/engine/gfx/hw/display.gc +++ b/goal_src/jak2/engine/gfx/hw/display.gc @@ -80,7 +80,7 @@ ) (define *font-context* - (new 'global 'font-context *font-default-matrix* 0 0 0.0 (font-color default-#cddbcd) (font-flags shadow kerning)) + (new 'global 'font-context *font-default-matrix* 0 0 0.0 (font-color default) (font-flags shadow kerning)) ) (defun draw-sprite2d-xy ((arg0 dma-buffer) (arg1 int) (arg2 int) (arg3 int) (arg4 int) (arg5 rgba)) diff --git a/goal_src/jak2/engine/gfx/math-camera.gc b/goal_src/jak2/engine/gfx/math-camera.gc index a593244f68..97c473fd7c 100644 --- a/goal_src/jak2/engine/gfx/math-camera.gc +++ b/goal_src/jak2/engine/gfx/math-camera.gc @@ -67,6 +67,31 @@ (set! (-> arg0 y-ratio) (* 0.75 (-> arg0 x-ratio))) (set! (-> arg0 y-ratio) (* 0.5625 (-> arg0 x-ratio))) ) + (with-pc + (cond + ((-> *pc-settings* use-vis?) + ;; using game vis, cannot allow seeing more of the view + ;; crops excess aspect ratio at the top and bottom + ;(set! (-> arg0 y-ratio) (* (1/ (-> *pc-settings* aspect-ratio)) (-> arg0 x-ratio))) + ) + ((-> *pc-settings* movie?) + ;; this mess is just so that we can force the original 16x9 cropping during cutscenes. + (if (<= (-> *pc-settings* aspect-ratio) ASPECT_16X9) + (set! (-> arg0 y-ratio) (* (1/ (-> *pc-settings* aspect-ratio)) (-> arg0 x-ratio))) + (begin + (set! (-> arg0 y-ratio) (* (1/ ASPECT_16X9) (-> arg0 x-ratio))) + (*! (-> arg0 x-ratio) (/ (-> *pc-settings* aspect-ratio) ASPECT_16X9)) + ) + ) + ) + (else + ;; not using game vis, allow *extended* aspect ratios + ;; there is no vertical cropping, and you can see more of the sides + (set! (-> arg0 y-ratio) (* (1/ ASPECT_4X3) (-> arg0 x-ratio))) ;; same cropping as 4x3 + (*! (-> arg0 x-ratio) (/ (-> *pc-settings* aspect-ratio) ASPECT_4X3)) ;; extend fov! shows more on the sides. + ) + ) + ) ;; compute culling constants. these seem unused... (let ((f1-3 (-> arg0 x-ratio)) diff --git a/goal_src/jak2/engine/process-drawable/process-drawable.gc b/goal_src/jak2/engine/process-drawable/process-drawable.gc index 28744141e2..8483373053 100644 --- a/goal_src/jak2/engine/process-drawable/process-drawable.gc +++ b/goal_src/jak2/engine/process-drawable/process-drawable.gc @@ -633,7 +633,7 @@ (the-as bucket-id s2-0) *temp-string* (the-as vector s5-1) - (font-color precursor-#ec3b00) + (font-color red) (the-as vector2h #f) ) ) diff --git a/goal_src/jak2/engine/process-drawable/process-taskable.gc b/goal_src/jak2/engine/process-drawable/process-taskable.gc index 8093a44330..c2fbdb6be1 100644 --- a/goal_src/jak2/engine/process-drawable/process-taskable.gc +++ b/goal_src/jak2/engine/process-drawable/process-taskable.gc @@ -261,7 +261,7 @@ Seen take in - `true-func` which takes no args TODO - seems fishy 32 280 0.0 - (font-color default-#cddbcd) + (font-color default) (font-flags shadow kerning) ) ) diff --git a/goal_src/jak2/engine/ps2/memcard-h.gc b/goal_src/jak2/engine/ps2/memcard-h.gc index 8aabe2e9ab..ce49f6ca08 100644 --- a/goal_src/jak2/engine/ps2/memcard-h.gc +++ b/goal_src/jak2/engine/ps2/memcard-h.gc @@ -134,7 +134,7 @@ ) ) ) - (draw-string-xy *temp-string* arg0 32 (+ (* 12 s4-0) 8) (font-color precursor-#ec3b00) (font-flags shadow)) + (draw-string-xy *temp-string* arg0 32 (+ (* 12 s4-0) 8) (font-color red) (font-flags shadow)) ) ) 0 diff --git a/goal_src/jak2/engine/scene/scene.gc b/goal_src/jak2/engine/scene/scene.gc index 12848f37de..f50f184c0d 100644 --- a/goal_src/jak2/engine/scene/scene.gc +++ b/goal_src/jak2/engine/scene/scene.gc @@ -799,7 +799,7 @@ 20 290 0.0 - (font-color default-#cddbcd) + (font-color default) (font-flags shadow kerning) ) ) @@ -828,7 +828,7 @@ (set! (-> s2-0 color) (font-color #000000)) (set! (-> s2-0 origin x) (+ 1.0 (-> s2-0 origin x))) (set! (-> s2-0 origin y) (+ 1.0 (-> s2-0 origin y))) - (set! (-> s2-0 color) (font-color default-#cddbcd)) + (set! (-> s2-0 color) (font-color default)) (set! (-> s2-0 flags) (font-flags shadow kerning middle left large)) (print-game-text (the-as string s3-0) s2-0 #f 44 (bucket-id bucket-322)) (gui-control-method-12 @@ -1452,7 +1452,7 @@ 36 60 0.0 - (font-color default-#cddbcd) + (font-color default) (font-flags shadow kerning) ) ) diff --git a/goal_src/jak2/engine/sound/gsound.gc b/goal_src/jak2/engine/sound/gsound.gc index 24c2ba2ef7..ed014058a2 100644 --- a/goal_src/jak2/engine/sound/gsound.gc +++ b/goal_src/jak2/engine/sound/gsound.gc @@ -846,7 +846,7 @@ arg0 (+ (* s5-0 16) 16) 48 - (font-color default-#cddbcd) + (font-color default) (font-flags shadow) ) ) @@ -859,7 +859,7 @@ arg0 (+ (* s5-1 16) 16) 64 - (font-color default-#cddbcd) + (font-color default) (font-flags shadow) ) ) @@ -871,7 +871,7 @@ (-> *level* sound-bank 1) (-> *level* sound-bank 2) ) - (s5-2 *temp-string* arg0 16 88 (font-color default-#cddbcd) (font-flags shadow)) + (s5-2 *temp-string* arg0 16 88 (font-color default) (font-flags shadow)) ) (let ((s5-3 draw-string-xy)) (format @@ -884,7 +884,7 @@ (-> *setting-control* user-current sound-excitement) (-> *setting-control* user-current mode-sound-bank) ) - (s5-3 *temp-string* arg0 16 104 (font-color default-#cddbcd) (font-flags shadow)) + (s5-3 *temp-string* arg0 16 104 (font-color default) (font-flags shadow)) ) 0 ) @@ -897,7 +897,7 @@ (-> *sound-iop-info* freemem) (shr (-> *sound-iop-info* freemem) 10) ) - (s5-0 *temp-string* arg0 32 96 (font-color default-#cddbcd) (font-flags shadow)) + (s5-0 *temp-string* arg0 32 96 (font-color default) (font-flags shadow)) ) (let ((s5-1 draw-string-xy)) (format @@ -906,7 +906,7 @@ (-> *sound-iop-info* freemem2) (shr (-> *sound-iop-info* freemem2) 10) ) - (s5-1 *temp-string* arg0 32 64 (font-color default-#cddbcd) (font-flags shadow)) + (s5-1 *temp-string* arg0 32 64 (font-color default) (font-flags shadow)) ) 0 ) diff --git a/goal_src/jak2/engine/target/board/target-board.gc b/goal_src/jak2/engine/target/board/target-board.gc index 68be920af8..80305d4d69 100644 --- a/goal_src/jak2/engine/target/board/target-board.gc +++ b/goal_src/jak2/engine/target/board/target-board.gc @@ -174,7 +174,7 @@ (when (> (-> obj points-in-combo) 0.0) (format *temp-string* "~%~S~D" "~[~38L" (the int (-> obj points-in-combo)))) ;; Print it finally - (let ((font-ctx (new 'stack 'font-context *font-default-matrix* 0 325 0.0 (font-color default-#cddbcd) (font-flags shadow kerning middle)))) + (let ((font-ctx (new 'stack 'font-context *font-default-matrix* 0 325 0.0 (font-color default) (font-flags shadow kerning middle)))) (print-game-text-scaled *temp-string* 1.0 font-ctx 320)) (none)) diff --git a/goal_src/jak2/engine/target/mech_suit/mech.gc b/goal_src/jak2/engine/target/mech_suit/mech.gc index 3686f65a94..308ceee9fc 100644 --- a/goal_src/jak2/engine/target/mech_suit/mech.gc +++ b/goal_src/jak2/engine/target/mech_suit/mech.gc @@ -179,7 +179,7 @@ 32 320 0.0 - (font-color default-#cddbcd) + (font-color default) (font-flags shadow kerning) ) ) diff --git a/goal_src/jak2/engine/target/target-turret.gc b/goal_src/jak2/engine/target/target-turret.gc index 7d43897e61..c52d91b280 100644 --- a/goal_src/jak2/engine/target/target-turret.gc +++ b/goal_src/jak2/engine/target/target-turret.gc @@ -985,7 +985,7 @@ 32 320 0.0 - (font-color default-#cddbcd) + (font-color default) (font-flags shadow kerning) ) ) diff --git a/goal_src/jak2/engine/ui/credits.gc b/goal_src/jak2/engine/ui/credits.gc index d799d3468a..d7bf794ed7 100644 --- a/goal_src/jak2/engine/ui/credits.gc +++ b/goal_src/jak2/engine/ui/credits.gc @@ -19,7 +19,7 @@ 6 0 0.0 - (font-color default-#cddbcd) + (font-color default) (font-flags shadow kerning) ) ) diff --git a/goal_src/jak2/engine/ui/hud-classes.gc b/goal_src/jak2/engine/ui/hud-classes.gc index c9809abe14..5a1617bc96 100644 --- a/goal_src/jak2/engine/ui/hud-classes.gc +++ b/goal_src/jak2/engine/ui/hud-classes.gc @@ -594,7 +594,7 @@ (set! (-> obj sprites 0 flags) (the-as uint 4)) (alloc-string-if-needed obj 0) (set! (-> obj strings 0 flags) (font-flags kerning right large)) - (set! (-> obj strings 0 color) (font-color precursor-#ec3b00)) + (set! (-> obj strings 0 color) (font-color red)) 0 (none) ) @@ -739,11 +739,11 @@ (alloc-string-if-needed obj 0) (set! (-> obj strings 0 scale) 0.5) (set! (-> obj strings 0 flags) (font-flags kerning middle large)) - (set! (-> obj strings 0 color) (font-color precursor-#ec3b00)) + (set! (-> obj strings 0 color) (font-color red)) (alloc-string-if-needed obj 1) (set! (-> obj strings 1 scale) 0.75) (set! (-> obj strings 1 flags) (font-flags kerning middle large)) - (set! (-> obj strings 1 color) (font-color precursor-#ec3b00)) + (set! (-> obj strings 1 color) (font-color red)) (let ((s5-0 format) (gp-1 (clear (-> obj strings 1 text))) (s4-0 "~S") @@ -795,11 +795,11 @@ (alloc-string-if-needed obj 0) (set! (-> obj strings 0 scale) 0.5) (set! (-> obj strings 0 flags) (font-flags kerning middle large)) - (set! (-> obj strings 0 color) (font-color precursor-#ec3b00)) + (set! (-> obj strings 0 color) (font-color red)) (alloc-string-if-needed obj 1) (set! (-> obj strings 1 scale) 0.75) (set! (-> obj strings 1 flags) (font-flags kerning middle large)) - (set! (-> obj strings 1 color) (font-color precursor-#ec3b00)) + (set! (-> obj strings 1 color) (font-color red)) 0 (none) ) diff --git a/goal_src/jak2/engine/ui/hud.gc b/goal_src/jak2/engine/ui/hud.gc index 9ddaf14670..a8b76ba655 100644 --- a/goal_src/jak2/engine/ui/hud.gc +++ b/goal_src/jak2/engine/ui/hud.gc @@ -722,7 +722,7 @@ 0 0 0.0 - (font-color default-#cddbcd) + (font-color default) (font-flags shadow kerning) ) ) diff --git a/goal_src/jak2/engine/ui/progress/progress.gc b/goal_src/jak2/engine/ui/progress/progress.gc index 9bfe617204..d2779a0c8e 100644 --- a/goal_src/jak2/engine/ui/progress/progress.gc +++ b/goal_src/jak2/engine/ui/progress/progress.gc @@ -1318,7 +1318,7 @@ 0 0 0.0 - (font-color default-#cddbcd) + (font-color default) (font-flags shadow kerning) ) ) diff --git a/goal_src/jak2/engine/util/profile.gc b/goal_src/jak2/engine/util/profile.gc index db815efa6c..cda064aca8 100644 --- a/goal_src/jak2/engine/util/profile.gc +++ b/goal_src/jak2/engine/util/profile.gc @@ -671,8 +671,8 @@ 488 arg1 (if (>= f30-0 100.0) - (font-color precursor-#ec3b00) - (font-color default-#cddbcd) + (font-color red) + (font-color default) ) (font-flags shadow right) ) @@ -687,8 +687,8 @@ 488 arg1 (if (>= f30-0 100.0) - (font-color precursor-#ec3b00) - (font-color default-#cddbcd) + (font-color red) + (font-color default) ) (font-flags shadow right) ) @@ -722,8 +722,8 @@ 488 arg1 (if (>= f30-1 100.0) - (font-color precursor-#ec3b00) - (font-color default-#cddbcd) + (font-color red) + (font-color default) ) (font-flags shadow right) ) @@ -738,8 +738,8 @@ 488 arg1 (if (>= f30-1 100.0) - (font-color precursor-#ec3b00) - (font-color default-#cddbcd) + (font-color red) + (font-color default) ) (font-flags shadow right) ) diff --git a/goal_src/jak2/kernel-defs.gc b/goal_src/jak2/kernel-defs.gc index 4dbeafd7e2..5d209fabe8 100644 --- a/goal_src/jak2/kernel-defs.gc +++ b/goal_src/jak2/kernel-defs.gc @@ -124,9 +124,74 @@ (define-extern *boot-video-mode* "Defined in the kernel" int) (define-extern *kernel-boot-message* symbol) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; PC Port functions +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(defenum pc-renderer-tree-type + (none 0) + (tfrag3 1) + (tie3 2) + (invalid)) + +(defenum pc-collision-mode + (none 0) + (mode 1) + (event 2) + (material 3) + (skip 4)) + +(defenum pc-gfx-hack + (no-tex 0)) + (define-extern __read-ee-timer (function uint)) (define-extern __mem-move (function pointer pointer uint none)) (define-extern __send-gfx-dma-chain (function object object none)) +(define-extern __pc-texture-upload-now (function object object none)) +(define-extern __pc-texture-relocate (function object object object none)) +(define-extern __pc-get-mips2c (function string function)) +(define-extern __pc-set-levels (function (pointer string) none)) +(define-extern pc-pad-input-mode-set (function symbol none)) +(define-extern pc-pad-input-pad-set (function int none)) +(define-extern pc-pad-input-mode-get (function int)) +(define-extern pc-pad-input-key-get (function int)) +(define-extern pc-pad-input-index-get (function int)) +(define-extern pc-pad-input-map-save! (function none)) +(define-extern pc-pad-get-mapped-button (function int int int)) +(define-extern pc-get-fullscreen (function symbol)) +(define-extern pc-get-screen-size (function int (pointer int32) (pointer int32) none)) +(define-extern pc-get-screen-rate (function int int)) +(define-extern pc-get-screen-vmode-count (function int)) +(define-extern pc-get-monitor-count (function int)) +(define-extern pc-get-os (function symbol)) +(define-extern pc-get-window-size (function (pointer int32) (pointer int32) none)) +(define-extern pc-get-window-scale (function (pointer float) (pointer float) none)) +(define-extern pc-set-window-size (function int int none)) +(define-extern pc-set-fullscreen (function symbol int none)) +(define-extern pc-set-frame-rate (function int none)) +(define-extern pc-set-vsync (function symbol none)) +(define-extern pc-renderer-tree-set-lod (function pc-renderer-tree-type int none)) +(define-extern pc-set-letterbox (function int int none)) +(define-extern pc-set-collision (function symbol none)) +(define-extern pc-set-collision-wireframe (function symbol none)) +(define-extern pc-get-collision-mask (function pc-collision-mode int symbol)) +(define-extern pc-set-collision-mask (function pc-collision-mode int symbol none)) +(define-extern pc-set-collision-mode (function pc-collision-mode none)) +(define-extern pc-filepath-exists? (function string symbol)) +(define-extern pc-mkdir-file-path (function string none)) +(define-extern pc-filter-debug-string? (function string float symbol)) +(declare-type discord-info structure) +(define-extern pc-discord-rpc-update (function discord-info none)) +(define-extern pc-discord-rpc-set (function int none)) +(define-extern pc-filepath-exists? (function string symbol)) +(define-extern pc-mkdir-file-path (function string none)) +(define-extern pc-sound-set-flava-hack (function int none)) +(define-extern pc-sound-set-fade-hack (function int none)) +(define-extern pc-set-window-lock (function symbol none)) +(define-extern pc-set-game-resolution (function int int none)) +(define-extern pc-set-msaa (function int none)) +(define-extern pc-set-gfx-hack (function pc-gfx-hack symbol none)) + +(define-extern pc-get-unix-timestamp (function int)) (define-extern file-stream-open (function file-stream string symbol file-stream)) (define-extern file-stream-close (function file-stream file-stream)) @@ -207,7 +272,6 @@ (define-extern unload (function string none)) (define-extern reset-graph (function int int int int none)) -(define-extern __pc-set-levels (function (pointer string) none)) ;; PC stuff @@ -221,9 +285,3 @@ (define-extern *pc-settings-folder* string) (define-extern *pc-settings-built-sha* string) -(define-extern pc-filepath-exists? (function string symbol)) -(define-extern pc-mkdir-file-path (function string none)) -(define-extern pc-filter-debug-string? (function string float symbol)) -(declare-type discord-info structure) -(define-extern pc-discord-rpc-update (function discord-info none)) -(define-extern pc-discord-rpc-set (function int none)) diff --git a/goal_src/jak2/levels/city/common/nav-graph.gc b/goal_src/jak2/levels/city/common/nav-graph.gc index e9ef4b0951..fe24691b16 100644 --- a/goal_src/jak2/levels/city/common/nav-graph.gc +++ b/goal_src/jak2/levels/city/common/nav-graph.gc @@ -117,7 +117,7 @@ *temp-string* gp-0 (if (logtest? (-> obj flags) (nav-node-flag-byte blocked)) - (font-color precursor-#ec3b00) + (font-color red) (font-color cyan-#00fefe) ) (the-as vector2h #f) diff --git a/goal_src/jak2/levels/city/common/traffic-engine.gc b/goal_src/jak2/levels/city/common/traffic-engine.gc index b4765562f1..a8674e6349 100644 --- a/goal_src/jak2/levels/city/common/traffic-engine.gc +++ b/goal_src/jak2/levels/city/common/traffic-engine.gc @@ -1140,7 +1140,7 @@ Process is recycled and moved to reserved, if it deactivates." sv-84 (if (< (-> sv-20 user-count) (-> sv-20 max-user-count)) (font-color yellow-#f3f300) - (font-color precursor-#ec3b00) + (font-color red) ) (the-as vector2h #f) ) diff --git a/goal_src/jak2/levels/city/common/vehicle-util.gc b/goal_src/jak2/levels/city/common/vehicle-util.gc index ce846f14f3..90b6b35dc9 100644 --- a/goal_src/jak2/levels/city/common/vehicle-util.gc +++ b/goal_src/jak2/levels/city/common/vehicle-util.gc @@ -345,7 +345,7 @@ This commonly includes things such as: 32 320 0.0 - (font-color default-#cddbcd) + (font-color default) (font-flags shadow kerning) ) ) diff --git a/goal_src/jak2/levels/city/oracle/oracle-training.gc b/goal_src/jak2/levels/city/oracle/oracle-training.gc index a6ea881be5..514b216231 100644 --- a/goal_src/jak2/levels/city/oracle/oracle-training.gc +++ b/goal_src/jak2/levels/city/oracle/oracle-training.gc @@ -91,7 +91,7 @@ 32 280 0.0 - (font-color default-#cddbcd) + (font-color default) (font-flags shadow kerning) ) ) @@ -201,7 +201,7 @@ 32 280 0.0 - (font-color default-#cddbcd) + (font-color default) (font-flags shadow kerning) ) ) @@ -291,7 +291,7 @@ 32 280 0.0 - (font-color default-#cddbcd) + (font-color default) (font-flags shadow kerning) ) ) @@ -402,7 +402,7 @@ 32 280 0.0 - (font-color default-#cddbcd) + (font-color default) (font-flags shadow kerning) ) ) diff --git a/goal_src/jak2/levels/common/races/race-hud.gc b/goal_src/jak2/levels/common/races/race-hud.gc index d540958d49..18e16896cc 100644 --- a/goal_src/jak2/levels/common/races/race-hud.gc +++ b/goal_src/jak2/levels/common/races/race-hud.gc @@ -296,7 +296,7 @@ 0 0 0.0 - (font-color default-#cddbcd) + (font-color default) (font-flags shadow kerning) ) ) @@ -311,7 +311,7 @@ (set! (-> v1-16 height) (the float 80)) ) (let ((a0-12 s1-0)) - (set! (-> a0-12 color) (font-color precursor-#ec3b00)) + (set! (-> a0-12 color) (font-color red)) ) (let ((a0-13 s1-0)) (set! (-> a0-13 flags) (font-flags kerning middle left large)) @@ -448,7 +448,7 @@ (alloc-string-if-needed obj s5-0) ) (set! (-> obj strings 0 flags) (font-flags kerning middle large)) - (set! (-> obj strings 0 color) (font-color precursor-#ec3b00)) + (set! (-> obj strings 0 color) (font-color red)) (set! (-> obj strings 1 flags) (font-flags kerning large)) (set! (-> obj strings 1 color) (font-color #dadada)) (set! (-> obj strings 2 flags) (font-flags kerning large)) diff --git a/goal_src/jak2/levels/common/warp-gate.gc b/goal_src/jak2/levels/common/warp-gate.gc index b244aa9a26..84f190b2c4 100644 --- a/goal_src/jak2/levels/common/warp-gate.gc +++ b/goal_src/jak2/levels/common/warp-gate.gc @@ -581,7 +581,7 @@ 32 320 0.0 - (font-color default-#cddbcd) + (font-color default) (font-flags shadow kerning) ) ) diff --git a/goal_src/jak2/levels/demo/demo-obs.gc b/goal_src/jak2/levels/demo/demo-obs.gc index 22b48cc6fb..94895723d0 100644 --- a/goal_src/jak2/levels/demo/demo-obs.gc +++ b/goal_src/jak2/levels/demo/demo-obs.gc @@ -530,7 +530,7 @@ 64 312 0.0 - (font-color default-#cddbcd) + (font-color default) (font-flags shadow kerning) ) ) diff --git a/goal_src/jak2/levels/gungame/gungame-obs.gc b/goal_src/jak2/levels/gungame/gungame-obs.gc index 84b763bb89..3790ef5287 100644 --- a/goal_src/jak2/levels/gungame/gungame-obs.gc +++ b/goal_src/jak2/levels/gungame/gungame-obs.gc @@ -229,7 +229,7 @@ This commonly includes things such as: 32 290 0.0 - (font-color default-#cddbcd) + (font-color default) (font-flags shadow kerning) ) ) diff --git a/goal_src/jak2/levels/stadium/jetboard/skatea-obs.gc b/goal_src/jak2/levels/stadium/jetboard/skatea-obs.gc index 229a6b0d85..490b212058 100644 --- a/goal_src/jak2/levels/stadium/jetboard/skatea-obs.gc +++ b/goal_src/jak2/levels/stadium/jetboard/skatea-obs.gc @@ -70,7 +70,7 @@ 32 280 0.0 - (font-color default-#cddbcd) + (font-color default) (font-flags shadow kerning) ) ) diff --git a/goal_src/jak2/levels/title/title-obs.gc b/goal_src/jak2/levels/title/title-obs.gc index e38b1dec18..58c01214fc 100644 --- a/goal_src/jak2/levels/title/title-obs.gc +++ b/goal_src/jak2/levels/title/title-obs.gc @@ -535,7 +535,7 @@ 64 312 0.0 - (font-color default-#cddbcd) + (font-color default) (font-flags shadow kerning) ) ) diff --git a/goal_src/jak2/lib/project-lib.gp b/goal_src/jak2/lib/project-lib.gp index e16014b55f..99a5614dd0 100644 --- a/goal_src/jak2/lib/project-lib.gp +++ b/goal_src/jak2/lib/project-lib.gp @@ -38,6 +38,18 @@ ) ) +(defun make-src-sequence-elt-jak1 (current previous prefix) + "Helper for goal-src-sequence" + `(let ((output-file ,(gc-file->o-file current))) + (set! *all-gc* (cons output-file *all-gc*)) + (defstep :in ,(string-append "goal_src/jak1/" prefix current) + :tool 'goalc + :out (list output-file) + :dep '(,(gc-file->o-file previous)) + ) + ) + ) + ;; TODO - deps should probably just treated as a proper list to refactor duplication (defmacro goal-src-sequence (prefix &key (deps '()) &rest sequence) "Add a sequence of GOAL files (each depending on the previous) in the given directory, @@ -51,7 +63,13 @@ (while (not (null? in-iter)) ;; (fmt #t "{} dep on {}\n" (first in-iter) prev) - (let ((next (make-src-sequence-elt (first in-iter) prev prefix))) + (let* ((cur-src-file (first in-iter)) + ;; grotesque temp hack + (next (if (or (eq? "pc/pckernel-h.gc" cur-src-file) + (eq? "pc/pckernel-common.gc" cur-src-file) + (eq? "pc/debug/pc-debug-common.gc" cur-src-file)) + (make-src-sequence-elt-jak1 cur-src-file prev prefix) + (make-src-sequence-elt cur-src-file prev prefix)))) (set-cdr! iter (cons next '())) (set! iter (cdr iter)) ) @@ -170,8 +188,25 @@ (cond ((string-ends-with? file-name ".o") ;; build up a list of all gsrc files needing to be compiled - (let ((gsrc-path (get-gsrc-path (symbol->string (first (string-split file-name ".")))))) - (set! gsrc-seq-args (cons gsrc-path gsrc-seq-args)))) + (let ((base-name (symbol->string (first (string-split file-name "."))))) + (cond + ;; hardcoded cases to grab from jak1... really dont want to copy-paste these all the time! + ((or (eq? base-name "pckernel-h") + (eq? base-name "pckernel-common") + (eq? base-name "pc-debug-common")) + (let ((old-path (get-gsrc-folder)) + (gsrc-path (begin (set-gsrc-folder! "goal_src/jak1") + (get-gsrc-path base-name)))) + (set! gsrc-seq-args (cons gsrc-path gsrc-seq-args)) + (set-gsrc-folder! old-path) + ) + ) + (#t + (let ((gsrc-path (get-gsrc-path base-name))) + (set! gsrc-seq-args (cons gsrc-path gsrc-seq-args))) + ) + )) + ) ((string-starts-with? file-name "tpage-") ;; copy textures (let ((tpage-id (second (string-split (symbol->string (first (string-split file-name "."))) "-")))) diff --git a/goal_src/jak2/pc/debug/anim-tester-x.gc b/goal_src/jak2/pc/debug/anim-tester-x.gc index 451d5f2f9c..5b58b054a9 100644 --- a/goal_src/jak2/pc/debug/anim-tester-x.gc +++ b/goal_src/jak2/pc/debug/anim-tester-x.gc @@ -274,7 +274,7 @@ )) (when (not (-> lst head)) - (draw-string-xy warning buf 21 (+ 28 4 14) (font-color precursor-#ec3b00) (font-flags shadow kerning)) + (draw-string-xy warning buf 21 (+ 28 4 14) (font-color red) (font-flags shadow kerning)) (1+! items-drawn)) ) @@ -666,16 +666,13 @@ (if (not *atx*) (atx-start)) (do-atx-list (item (-> *ATX-settings* list-ctrl)) - (if (or (and (>= (-> item group) (-> *level* level 0 heap base)) (< (-> item group) (-> *level* level 0 heap top))) - (and (>= (-> item group) (-> *level* level 1 heap base)) (< (-> item group) (-> *level* level 1 heap top))) - (and (>= (-> item group) (-> *level* level 2 heap base)) (< (-> item group) (-> *level* level 2 heap top))) - (and (>= (-> item group) (-> *level* level 3 heap base)) (< (-> item group) (-> *level* level 3 heap top))) - (and (>= (-> item group) (-> *level* level 4 heap base)) (< (-> item group) (-> *level* level 4 heap top))) - (and (>= (-> item group) (-> *level* level 5 heap base)) (< (-> item group) (-> *level* level 5 heap top)))) + (dotimes (i (-> *level* length)) + (when (and (>= (-> item group) (-> *level* level i heap base)) (< (-> item group) (-> *level* level i heap top))) (atx-list-remove (-> *ATX-settings* list-ctrl) item) - ) + (set! i (-> *level* length)) + )) ) - (dotimes (i 6) + (dotimes (i (-> *level* length)) (doarray (ag (-> *level* level i art-group data-array)) (atx-add-new-art-group (the art-group ag)) ) @@ -685,7 +682,7 @@ (defun atx-add-common-group () (if (not *atx*) (atx-start)) - (doarray (ag (-> *level* level 2 art-group data-array)) + (doarray (ag (-> *level* level (-> *level* length) art-group data-array)) (atx-add-new-art-group (the art-group ag)) ) ) diff --git a/goal_src/jak2/pc/debug/default-menu-pc.gc b/goal_src/jak2/pc/debug/default-menu-pc.gc index 7608b8dccc..58e37e05a3 100644 --- a/goal_src/jak2/pc/debug/default-menu-pc.gc +++ b/goal_src/jak2/pc/debug/default-menu-pc.gc @@ -197,6 +197,7 @@ (= (-> *entity-debug-inspect* entity) e) ) +(define *entity-debug-display-part* #t) (defun build-entity-list () "Fill the entity pick menu" ;; clear old list @@ -438,11 +439,11 @@ ;; ) ;; ) ;; -;; (defun dm-subtitle-setting ((setting symbol) (msg debug-menu-msg)) -;; (when (= msg (debug-menu-msg press)) -;; (set! (-> *pc-settings* subtitle-speaker?) setting)) -;; (= (-> *pc-settings* subtitle-speaker?) setting) -;; ) +(defun dm-subtitle-setting ((setting symbol) (msg debug-menu-msg)) + (when (= msg (debug-menu-msg press)) + (set! (-> *pc-settings* subtitle-speaker?) setting)) + (= (-> *pc-settings* subtitle-speaker?) setting) + ) ;; (defun dm-mood-override-palette-pick-func ((bpal int) (msg debug-menu-msg)) ;; (let* ((pal (/ bpal 8)) @@ -592,83 +593,71 @@ ;; (debug-menu-append-item (-> *debug-menu-context* root-menu) (debug-menu-make-load-menu *debug-menu-context*)) (debug-menu-append-item (-> *debug-menu-context* root-menu) (debug-menu-make-part-menu *debug-menu-context*)) (debug-menu-append-item (-> *debug-menu-context* root-menu) (debug-menu-make-entity-menu *debug-menu-context*)) - ;; Scene menu TODO (debug-menu-append-item (-> *debug-menu-context* root-menu) (debug-menu-make-from-template *debug-menu-context* '(menu "PC Settings" - ;; (flag "Debug" #f ,(dm-lambda-boolean-flag (-> *pc-settings* debug?))) - ;; (flag "Use native vis" #f ,(dm-lambda-boolean-flag (-> *pc-settings* use-vis?))) - ;; (function "Toggle game aspect" #f ,(lambda () - ;; (cond - ;; ((= (-> *setting-control* default aspect-ratio) 'aspect4x3) - ;; (set! (-> *setting-control* default aspect-ratio) 'aspect16x9) - ;; ) - ;; (else - ;; (set! (-> *setting-control* default aspect-ratio) 'aspect4x3) - ;; ) - ;; ) - ;; (set-aspect-ratio (-> *setting-control* default aspect-ratio)) - ;; )) - ;; (flag "Auto aspect" #f ,(dm-lambda-boolean-flag (-> *pc-settings* aspect-ratio-auto?))) - ;; (menu "Aspect test" - ;; (function "4 x 3" #f ,(lambda () (set-aspect! *pc-settings* 4 3))) - ;; (function "16 x 9" #f ,(lambda () (set-aspect! *pc-settings* 16 9))) - ;; (function "64 x 27 (21:9)" #f ,(lambda () (set-aspect! *pc-settings* 64 27))) - ;; (function "16 x 10" #f ,(lambda () (set-aspect! *pc-settings* 16 10))) - ;; (function "2 x 1" #f ,(lambda () (set-aspect! *pc-settings* 2 1))) - ;; (function "37 x 20" #f ,(lambda () (set-aspect! *pc-settings* 37 20))) - ;; (function "21 x 9" #f ,(lambda () (set-aspect! *pc-settings* 21 9))) - ;; (function "64 x 18" #f ,(lambda () (set-aspect! *pc-settings* 64 18))) - ;; (int-var "Custom aspect X" #f ,(dm-lambda-int-var (-> *pc-settings* aspect-custom-x)) 20 1 #t 1 1000) - ;; (int-var "Custom aspect Y" #f ,(dm-lambda-int-var (-> *pc-settings* aspect-custom-y)) 20 1 #t 1 1000) - ;; (function "Custom" #f ,(lambda () (set-aspect! *pc-settings* (-> *pc-settings* aspect-custom-x) (-> *pc-settings* aspect-custom-y)))) - ;; ) - ;; (menu "Fullscreen" - ;; (function "Windowed" #f ,(lambda () (set-display-mode! *pc-settings* 'windowed))) - ;; (function "Fullscreen" #f ,(lambda () (set-display-mode! *pc-settings* 'fullscreen))) - ;; (function "Borderless" #f ,(lambda () (set-display-mode! *pc-settings* 'borderless))) - ;; ) - ;; (menu "Sizes" - ;; (function "640 x 480" #f ,(lambda () (set-size! *pc-settings* 640 480))) - ;; (function "640 x 360" #f ,(lambda () (set-size! *pc-settings* 640 360))) - ;; (function "720 x 540" #f ,(lambda () (set-size! *pc-settings* 720 540))) - ;; (function "960 x 540" #f ,(lambda () (set-size! *pc-settings* 960 540))) - ;; (function "800 x 600" #f ,(lambda () (set-size! *pc-settings* 800 600))) - ;; (function "960 x 720" #f ,(lambda () (set-size! *pc-settings* 960 720))) - ;; (function "1280 x 720" #f ,(lambda () (set-size! *pc-settings* 1280 720))) - ;; (function "1024 x 768" #f ,(lambda () (set-size! *pc-settings* 1024 768))) - ;; (function "1366 x 768" #f ,(lambda () (set-size! *pc-settings* 1366 768))) - ;; (function "1280 x 960" #f ,(lambda () (set-size! *pc-settings* 1280 960))) - ;; (function "1440 x 1080" #f ,(lambda () (set-size! *pc-settings* 1440 1080))) - ;; (function "1920 x 1080" #f ,(lambda () (set-size! *pc-settings* 1920 1080))) - ;; (function "1920 x 1440" #f ,(lambda () (set-size! *pc-settings* 1920 1440))) - ;; (function "2560 x 1440" #f ,(lambda () (set-size! *pc-settings* 2560 1440))) - ;; (function "2880 x 2160" #f ,(lambda () (set-size! *pc-settings* 2880 2160))) - ;; (function "3840 x 2160" #f ,(lambda () (set-size! *pc-settings* 3840 2160))) - ;; (function "512 x 224" #f ,(lambda () (set-size! *pc-settings* 512 224))) - ;; (function "512 x 256" #f ,(lambda () (set-size! *pc-settings* 512 256))) - ;; (function "512 x 448" #f ,(lambda () (set-size! *pc-settings* 512 448))) - ;; (function "512 x 512" #f ,(lambda () (set-size! *pc-settings* 512 512))) - ;; ) - ;; (flag "Letterbox" #f ,(dm-lambda-boolean-flag (-> *pc-settings* letterbox?))) - ;; (flag "Skip movies" #f ,(dm-lambda-boolean-flag (-> *pc-settings* skip-movies?))) - ;; (flag "Money starburst" #f ,(dm-lambda-boolean-flag (-> *pc-settings* money-starburst?))) - ;; (flag "Subtitles" #f ,(dm-lambda-boolean-flag (-> *pc-settings* subtitles?))) - ;; (flag "Hinttitles" #f ,(dm-lambda-boolean-flag (-> *pc-settings* hinttitles?))) - ;; (menu "Subtitle speaker" - ;; (flag "Off" #f dm-subtitle-setting) - ;; (flag "On" #t dm-subtitle-setting) - ;; (flag "Auto" auto dm-subtitle-setting) - ;; ) - ;; (menu "Subtitle language" - ;; (flag "english" 0 dm-subtitle-language) - ;; (flag "french" 1 dm-subtitle-language) - ;; (flag "german" 2 dm-subtitle-language) - ;; (flag "spanish" 3 dm-subtitle-language) - ;; (flag "uk-english" 6 dm-subtitle-language) - ;; (flag "br-portuguese" 13 dm-subtitle-language) - ;; ) + (flag "Debug" #f ,(dm-lambda-boolean-flag (-> *pc-settings* debug?))) + (flag "Use native vis" #f ,(dm-lambda-boolean-flag (-> *pc-settings* use-vis?))) + (function "Toggle game aspect" #f ,(lambda () + (cond + ((= (-> *setting-control* user-default aspect-ratio) 'aspect4x3) + (set! (-> *setting-control* user-default aspect-ratio) 'aspect16x9) + ) + (else + (set! (-> *setting-control* user-default aspect-ratio) 'aspect4x3) + ) + ) + (set-aspect-ratio (-> *setting-control* user-default aspect-ratio)) + )) + (flag "Auto aspect" #f ,(dm-lambda-boolean-flag (-> *pc-settings* aspect-ratio-auto?))) + (menu "Aspect test" + (function "4 x 3" #f ,(lambda () (set-aspect! *pc-settings* 4 3))) + (function "16 x 9" #f ,(lambda () (set-aspect! *pc-settings* 16 9))) + (function "64 x 27 (21:9)" #f ,(lambda () (set-aspect! *pc-settings* 64 27))) + (function "16 x 10" #f ,(lambda () (set-aspect! *pc-settings* 16 10))) + (function "2 x 1" #f ,(lambda () (set-aspect! *pc-settings* 2 1))) + (function "37 x 20" #f ,(lambda () (set-aspect! *pc-settings* 37 20))) + (function "21 x 9" #f ,(lambda () (set-aspect! *pc-settings* 21 9))) + (function "64 x 18" #f ,(lambda () (set-aspect! *pc-settings* 64 18))) + (int-var "Custom aspect X" #f ,(dm-lambda-int-var (-> *pc-settings* aspect-custom-x)) 20 1 #t 1 1000) + (int-var "Custom aspect Y" #f ,(dm-lambda-int-var (-> *pc-settings* aspect-custom-y)) 20 1 #t 1 1000) + (function "Custom" #f ,(lambda () (set-aspect! *pc-settings* (-> *pc-settings* aspect-custom-x) (-> *pc-settings* aspect-custom-y)))) + ) + (menu "Fullscreen" + (function "Windowed" #f ,(lambda () (set-display-mode! *pc-settings* 'windowed))) + (function "Fullscreen" #f ,(lambda () (set-display-mode! *pc-settings* 'fullscreen))) + (function "Borderless" #f ,(lambda () (set-display-mode! *pc-settings* 'borderless))) + ) + (menu "Sizes" + (function "640 x 480" #f ,(lambda () (set-size! *pc-settings* 640 480))) + (function "640 x 360" #f ,(lambda () (set-size! *pc-settings* 640 360))) + (function "720 x 540" #f ,(lambda () (set-size! *pc-settings* 720 540))) + (function "960 x 540" #f ,(lambda () (set-size! *pc-settings* 960 540))) + (function "800 x 600" #f ,(lambda () (set-size! *pc-settings* 800 600))) + (function "960 x 720" #f ,(lambda () (set-size! *pc-settings* 960 720))) + (function "1280 x 720" #f ,(lambda () (set-size! *pc-settings* 1280 720))) + (function "1024 x 768" #f ,(lambda () (set-size! *pc-settings* 1024 768))) + (function "1366 x 768" #f ,(lambda () (set-size! *pc-settings* 1366 768))) + (function "1280 x 960" #f ,(lambda () (set-size! *pc-settings* 1280 960))) + (function "1440 x 1080" #f ,(lambda () (set-size! *pc-settings* 1440 1080))) + (function "1920 x 1080" #f ,(lambda () (set-size! *pc-settings* 1920 1080))) + (function "1920 x 1440" #f ,(lambda () (set-size! *pc-settings* 1920 1440))) + (function "2560 x 1440" #f ,(lambda () (set-size! *pc-settings* 2560 1440))) + (function "2880 x 2160" #f ,(lambda () (set-size! *pc-settings* 2880 2160))) + (function "3840 x 2160" #f ,(lambda () (set-size! *pc-settings* 3840 2160))) + (function "512 x 224" #f ,(lambda () (set-size! *pc-settings* 512 224))) + (function "512 x 256" #f ,(lambda () (set-size! *pc-settings* 512 256))) + (function "512 x 448" #f ,(lambda () (set-size! *pc-settings* 512 448))) + (function "512 x 512" #f ,(lambda () (set-size! *pc-settings* 512 512))) + ) + (flag "Letterbox" #f ,(dm-lambda-boolean-flag (-> *pc-settings* letterbox?))) + (flag "Hinttitles" #f ,(dm-lambda-boolean-flag (-> *pc-settings* hinttitles?))) + (menu "Subtitle speaker" + (flag "Off" #f dm-subtitle-setting) + (flag "On" #t dm-subtitle-setting) + (flag "Auto" auto dm-subtitle-setting) + ) ;; (menu "Text language" ;; (flag "english" 0 dm-text-language) ;; (flag "french" 1 dm-text-language) @@ -716,29 +705,28 @@ ;; (flag "150" #f ,(lambda (arg (msg debug-menu-msg)) (when (= msg (debug-menu-msg press)) (set-frame-rate! *pc-settings* 150)) ;; (= (-> *pc-settings* target-fps) 150))) ;; ) - ;; (menu "MSAA" - ;; (flag "Off" #f ,(lambda (arg (msg debug-menu-msg)) (when (= msg (debug-menu-msg press)) (set! (-> *pc-settings* gfx-msaa) 1)) - ;; (= (-> *pc-settings* gfx-msaa) 1))) - ;; (flag "x2" #f ,(lambda (arg (msg debug-menu-msg)) (when (= msg (debug-menu-msg press)) (set! (-> *pc-settings* gfx-msaa) 2)) - ;; (= (-> *pc-settings* gfx-msaa) 2))) - ;; (flag "x4" #f ,(lambda (arg (msg debug-menu-msg)) (when (= msg (debug-menu-msg press)) (set! (-> *pc-settings* gfx-msaa) 4)) - ;; (= (-> *pc-settings* gfx-msaa) 4))) - ;; (flag "x8" #f ,(lambda (arg (msg debug-menu-msg)) (when (= msg (debug-menu-msg press)) (set! (-> *pc-settings* gfx-msaa) 8)) - ;; (= (-> *pc-settings* gfx-msaa) 8))) - ;; (flag "x16" #f ,(lambda (arg (msg debug-menu-msg)) (when (= msg (debug-menu-msg press)) (set! (-> *pc-settings* gfx-msaa) 16)) - ;; (= (-> *pc-settings* gfx-msaa) 16))) - ;; ) - ;; (flag "V-sync" #f ,(dm-lambda-boolean-flag (-> *pc-settings* vsync?))) - ;; ;(flag "Alt load boundaries" #f ,(dm-lambda-boolean-flag (-> *pc-settings* new-lb?))) - ;; (flag "All actors" #f ,(dm-lambda-boolean-flag (-> *pc-settings* force-actors?))) - ;; (flag "Display actor counts" #f ,(dm-lambda-boolean-flag (-> *pc-settings* display-actor-counts))) - ;; (flag "Display git commit" #f ,(dm-lambda-boolean-flag (-> *pc-settings* display-sha))) - ;; (flag "Extra hud elements" #f ,(dm-lambda-boolean-flag (-> *pc-settings* extra-hud?))) - ;; (flag "Music fadein" #f ,(dm-lambda-boolean-flag (-> *pc-settings* music-fadein?))) - ;; (flag "Music fadeout" #f ,(dm-lambda-boolean-flag (-> *pc-settings* music-fadeout?))) - ;; (function "Reset" #f ,(lambda () (reset *pc-settings*))) + (menu "MSAA" + (flag "Off" #f ,(lambda (arg (msg debug-menu-msg)) (when (= msg (debug-menu-msg press)) (set! (-> *pc-settings* gfx-msaa) 1)) + (= (-> *pc-settings* gfx-msaa) 1))) + (flag "x2" #f ,(lambda (arg (msg debug-menu-msg)) (when (= msg (debug-menu-msg press)) (set! (-> *pc-settings* gfx-msaa) 2)) + (= (-> *pc-settings* gfx-msaa) 2))) + (flag "x4" #f ,(lambda (arg (msg debug-menu-msg)) (when (= msg (debug-menu-msg press)) (set! (-> *pc-settings* gfx-msaa) 4)) + (= (-> *pc-settings* gfx-msaa) 4))) + (flag "x8" #f ,(lambda (arg (msg debug-menu-msg)) (when (= msg (debug-menu-msg press)) (set! (-> *pc-settings* gfx-msaa) 8)) + (= (-> *pc-settings* gfx-msaa) 8))) + (flag "x16" #f ,(lambda (arg (msg debug-menu-msg)) (when (= msg (debug-menu-msg press)) (set! (-> *pc-settings* gfx-msaa) 16)) + (= (-> *pc-settings* gfx-msaa) 16))) + ) + (flag "V-sync" #f ,(dm-lambda-boolean-flag (-> *pc-settings* vsync?))) + ;(flag "Alt load boundaries" #f ,(dm-lambda-boolean-flag (-> *pc-settings* new-lb?))) + (flag "All actors" #f ,(dm-lambda-boolean-flag (-> *pc-settings* force-actors?))) + (flag "Display actor counts" #f ,(dm-lambda-boolean-flag (-> *pc-settings* display-actor-counts))) + (flag "Display git commit" #f ,(dm-lambda-boolean-flag (-> *pc-settings* display-sha))) + (flag "Music fadein" #f ,(dm-lambda-boolean-flag (-> *pc-settings* music-fadein?))) + (flag "Music fadeout" #f ,(dm-lambda-boolean-flag (-> *pc-settings* music-fadeout?))) + (function "Reset" #f ,(lambda () (reset *pc-settings*))) (function "Save" #f ,(lambda () (commit-to-file *pc-settings*))) - ;; (function "Load" #f ,(lambda () (load-settings *pc-settings*))) + (function "Load" #f ,(lambda () (load-settings *pc-settings*))) ) ) ) @@ -785,10 +773,10 @@ ) ) - ;; (debug-menu-append-item (-> (the debug-menu-item-submenu (ref (-> *debug-menu-context* root-menu items) 4)) submenu) + ;; (debug-menu-append-item (debug-menu-find-from-template *debug-menu-context* '("Collision")) ;; (debug-menu-make-collision-renderer-menu *debug-menu-context*)) - (debug-menu-append-item (-> (the debug-menu-item-submenu (car (-> *debug-menu-context* root-menu items))) submenu) + (debug-menu-append-item (debug-menu-find-from-template *debug-menu-context* '("Artist")) (debug-menu-make-anim-tester-x-menu *debug-menu-context*)) ) diff --git a/goal_src/jak2/pc/debug/entity-debug.gc b/goal_src/jak2/pc/debug/entity-debug.gc index 8768c477ad..41896ccb4f 100644 --- a/goal_src/jak2/pc/debug/entity-debug.gc +++ b/goal_src/jak2/pc/debug/entity-debug.gc @@ -11,6 +11,15 @@ (define *debug-temp-string* (new 'debug 'string 4096 (the string #f))) +(defmethod set-entity! entity-debug-inspect ((obj entity-debug-inspect) (e entity)) + "set the entity to inspect" + + (set! (-> obj entity) e) + (set! (-> obj scroll-y) 0) + + e + ) + ;; custom entity functions for pc port (defun-debug entity-inspect-draw ((inspect-info entity-debug-inspect)) "draw text about an entity on screen" @@ -21,7 +30,7 @@ ;; draw trans (add-debug-x #t (bucket-id debug-no-zbuf1) (-> e trans) (static-rgba 255 255 0 128)) (if (or (not (-> inspect-info show-actor-info)) (!= (-> e type) entity-actor) (and (= (-> e type) entity-actor) (not (-> (the entity-actor e) extra process)))) - (add-debug-text-3d #t (bucket-id debug-no-zbuf1) name (-> e trans) (font-color precursor-#ec3b00) (new 'static 'vector2h :y 8))) + (add-debug-text-3d #t (bucket-id debug-no-zbuf1) name (-> e trans) (font-color red) (new 'static 'vector2h :y 8))) ;; start writing text (let* ((begin-y (- 16 (* (-> inspect-info scroll-y) 16))) (cur-y begin-y) (y-adv 16)) @@ -30,7 +39,7 @@ ;; basic info, actor id, etc (draw-string-xy (string-format "~3L~A~0L ~A~%tags: ~D size: ~D aid: #x~x~%R1/L1 scroll L3 toggle display-actor-info~%--------------------" (-> e type) name (length e) (asize-of e) (-> e aid)) - debug-buf 352 cur-y (font-color default-#cddbcd) (font-flags shadow kerning middle)) + debug-buf 352 cur-y (font-color default) (font-flags shadow kerning middle)) (+! cur-y (* 10 6)) (cond ((type-type? (-> e type) entity-actor) @@ -38,7 +47,7 @@ ;; print info for entity-actors (draw-string-xy (string-format "etype: ~A~%vis: ~D task: ~S" (-> actor etype) (-> actor vis-id) (game-task->string (-> actor task))) - debug-buf 352 cur-y (font-color default-#cddbcd) (font-flags shadow kerning middle)) + debug-buf 352 cur-y (font-color default) (font-flags shadow kerning middle)) (+! cur-y (* 10 3)) ) ) @@ -244,7 +253,7 @@ ) ;; draw a string for each tag instead of all at once. allows using smaller strings. - (draw-string-xy *debug-temp-string* debug-buf 352 cur-y (font-color default-#cddbcd) (font-flags shadow kerning middle)) + (draw-string-xy *debug-temp-string* debug-buf 352 cur-y (font-color default) (font-flags shadow kerning middle)) (+! cur-y y-adv) (set! y-adv 14) diff --git a/goal_src/jak2/pc/debug/pc-debug-methods.gc b/goal_src/jak2/pc/debug/pc-debug-methods.gc new file mode 100644 index 0000000000..2c7b7da3a4 --- /dev/null +++ b/goal_src/jak2/pc/debug/pc-debug-methods.gc @@ -0,0 +1,49 @@ +;;-*-Lisp-*- +(in-package goal) + +#| + Various debugging displays made for the pc port. This file includes overrides or game-specific implementations. + |# + +;; debug-only file! +(declare-file (debug)) + +(defmethod print-debug-misc pc-settings-jak2 ((obj pc-settings-jak2)) + "prints various miscellaneous debug text to the game console, according to what's enabled in this object." + + (when (-> obj display-bug-report) + #f) + ) + +(defconstant MEM_BAR_NUM 11) ;; amount of memory usage bars (override later if wanted) +(defmethod draw-memory pc-settings-jak2 ((obj pc-settings-jak2) (buf dma-buffer)) + "draw the memory heap status in the bottom right corner" + + (when (-> obj display-heap-status) + (let ((idx 0) + (level-heap-colors (new 'static 'array rgba 6 (static-rgba 32 255 255 64) + (static-rgba 255 32 255 64) + (static-rgba 255 255 32 64) + (static-rgba 32 255 255 64) + (static-rgba 255 32 255 64) + (static-rgba 255 255 32 64) + ))) + (draw-memory-bar-kheap buf global :idx idx :color (static-rgba 32 32 255 64)) + (draw-memory-bar-kheap buf debug :idx (1+! idx) :color (static-rgba 255 32 32 64)) + (dotimes (i (-> *level* length)) + (if (!= (-> *level* level i status) 'inactive) (draw-memory-bar-kheap buf (-> *level* level i heap) :name (string-format "l~D" i) :idx (1+! idx) :color (-> level-heap-colors i))) + ) + (draw-memory-bar-dead-pool-heap buf *nk-dead-pool* :name "actor" :idx (1+! idx) :color (static-rgba 32 255 32 64)) + (draw-memory-bar-generic buf + :remain (* 16 (dma-buffer-free (-> *display* frames (-> *display* on-screen) global-buf))) + :total (length (-> *display* frames (-> *display* on-screen) global-buf)) + :name "dma-global" :idx (1+! idx) :color (static-rgba 32 32 255 64)) + (draw-memory-bar-generic buf + :remain (* 16 (dma-buffer-free (-> *display* frames (-> *display* on-screen) debug-buf))) + :total (length (-> *display* frames (-> *display* on-screen) debug-buf)) + :name "dma-debug" :idx (1+! idx) :color (static-rgba 255 32 32 64)) + ) + #t) + ) + + diff --git a/goal_src/jak2/pc/pckernel-h.gc b/goal_src/jak2/pc/pckernel-h.gc deleted file mode 100644 index a56ab5d545..0000000000 --- a/goal_src/jak2/pc/pckernel-h.gc +++ /dev/null @@ -1,104 +0,0 @@ -;;-*-Lisp-*- -(in-package goal) - -#| - - This file contains code that we need for the PC port of the game specifically. - It should be included as part of the game engine package (engine.cgo). - - This file contains various types and functions to store PC-specific information - and also to communicate between the game (GOAL) and the operating system. - This way we can poll, change and display information about the system the game - is running on, such as: - - display devices and their settings, such as fullscreen, DPI, refresh rate, etc. - - audio devices and their settings, such as audio latency, channel number, etc. - - graphics devices and their settings, such as resolution, FPS, anisotropy, shaders, etc. - - input devices and their settings, such as controllers, keyboards, mice, etc. - - information about the game window (position, size) - - PC-specific goodies, enhancements, fixes and settings. - - whatever else. - - If you do not want to include these PC things, you should exclude it from the build system. - - |# - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;; constants -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - - -(deftype pckernel-version (int64) - ((build int16 :offset 0) - (revision int16 :offset 16) - (minor int16 :offset 32) - (major int16 :offset 48) - ) - ) - -(defmacro static-pckernel-version (major minor rev build) - `(new 'static 'pckernel-version :major ,major :minor ,minor :revision ,rev :build ,build)) - ;; version: 0.0.0.2 -(defglobalconstant PC_KERNEL_VERSION (static-pckernel-version 0 0 0 2)) -(defconstant PC_KERNEL_VER_MAJOR (-> PC_KERNEL_VERSION major)) -(defconstant PC_KERNEL_VER_MINOR (-> PC_KERNEL_VERSION minor)) - - -;; All of the configuration for the PC port in GOAL. Access things from here! -;; Includes some methods to change parameters. -(deftype pc-settings (basic) - ((version pckernel-version) ;; version of this settings - - (discord-rpc? symbol) ;; enable discord rich presence integration - (jetboard-trick-text? symbol) ;; enable rendering jetboard trick combo during minigame - (display-heap-status symbol) - ) - - (:methods - (new (symbol type) _type_) - (update (_type_) none) - (update-to-os (_type_) none) - (reset (_type_) none) - (read-from-file (_type_ string) symbol) - (load-settings (_type_) int) - (write-to-file (_type_ string) symbol) - (commit-to-file (_type_) none) - ) - ) - -(deftype discord-info (structure) - ((orb-count (pointer float)) - (gem-count (pointer float)) - (death-count (pointer int32)) - (status string) - (level string) - (cutscene? symbol) - (time-of-day (pointer float)) - (percent-complete float))) - -(defconstant PC_TEMP_STRING_LEN 512) -(define *pc-temp-string* (new 'global 'string PC_TEMP_STRING_LEN (the string #f))) -(define *pc-settings* (the pc-settings #f)) -(format 0 "PC kernel version: ~D.~D~%" PC_KERNEL_VER_MAJOR PC_KERNEL_VER_MINOR) - -(define *pc-temp-string-1* (new 'global 'string 2048 (the string #f))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;; resets -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - - -(defmethod reset pc-settings ((obj pc-settings)) - "Set the default settings" - (set! (-> obj version) PC_KERNEL_VERSION) - (set! (-> obj discord-rpc?) #t) - (set! (-> obj jetboard-trick-text?) #t) - (set! (-> obj display-heap-status) #f) - (none)) - -(defmacro with-pc (&rest body) - "encapsulates the code around PC-specific checks" - `(#when PC_PORT (when (and *pc-settings*) - ,@body - )) - ) diff --git a/goal_src/jak2/pc/pckernel-impl.gc b/goal_src/jak2/pc/pckernel-impl.gc new file mode 100644 index 0000000000..65cbe507f9 --- /dev/null +++ b/goal_src/jak2/pc/pckernel-impl.gc @@ -0,0 +1,65 @@ +;;-*-Lisp-*- +(in-package goal) + +#| + This file has the game-specific implementation of the pckernel (see pckernel-h.gc and pckernel.gc). + |# + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; constants +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + + ;; version: 0.1.0.2 +(defconstant PC_KERNEL_VERSION (static-pckernel-version 0 1 0 2)) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; types and enums +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + +;; The Jak 2 version of the pc-settings object. +(deftype pc-settings-jak2 (pc-settings) + ( + (jetboard-trick-text? symbol) ;; enable rendering jetboard trick combo during minigame + ) + ) + +(define *pc-settings* (the pc-settings-jak2 #f)) + + +;; jak 2 discord rpc structure +(deftype discord-info (structure) + ((orb-count (pointer float)) + (gem-count (pointer float)) + (death-count (pointer int32)) + (status string) + (level string) + (cutscene? symbol) + (time-of-day (pointer float)) + (percent-complete float) + ) + ) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; resets +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + +(defmethod reset-misc pc-settings-jak2 ((obj pc-settings-jak2)) + "Set the default misc settings" + + ((method-of-type pc-settings reset-misc) obj) + (set! (-> obj jetboard-trick-text?) #t) + (none)) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; other +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + +(defun get-video-params () *video-params*) + + + diff --git a/goal_src/jak2/pc/pckernel.gc b/goal_src/jak2/pc/pckernel.gc index 9160989c91..9100c9039b 100644 --- a/goal_src/jak2/pc/pckernel.gc +++ b/goal_src/jak2/pc/pckernel.gc @@ -3,42 +3,62 @@ #| - This file contains new code that we need for the PC port of the game specifically. - It should be included as part of the game engine package (engine.cgo). - - This file contains various types and functions to store PC-specific information - and also to communicate between the game (GOAL) and the operating system. - This way we can poll, change and display information about the system the game - is running on, such as: - - display devices and their settings, such as fullscreen, DPI, refresh rate, etc. - - audio devices and their settings, such as audio latency, channel number, etc. - - graphics devices and their settings, such as resolution, FPS, anisotropy, shaders, etc. - - input devices and their settings, such as controllers, keyboards, mice, etc. - - information about the game window (position, size) - - PC-specific goodies, enhancements, fixes and settings. - - whatever else. - - If you do not want to include these PC things, you should exclude it from the build system. + This file runs the game-specific version of the pckernel. + See pckernel-common.gc for the bulk of the pckernel. |# -(defmethod update-to-os pc-settings ((obj pc-settings)) - "Update settings from GOAL to the C kernel." - (pc-discord-rpc-set (if (-> obj discord-rpc?) 1 0)) - (none)) -(defmethod update pc-settings ((obj pc-settings)) - "Update settings to/from PC kernel. Call this at the start of every frame. - This will update things like the aspect-ratio, which will be used for graphics code later." +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; methods +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - (update-to-os obj) + +(defmethod set-game-setting! pc-settings-jak2 ((obj pc-settings-jak2) (setting symbol) (value symbol)) + (case setting + (('video-mode) + (set! (-> *setting-control* user-current video-mode) #f) + (set! (-> *setting-control* user-default video-mode) value) + ) + (('aspect-ratio) + (set! (-> *setting-control* user-default aspect-ratio) value) + ) + (else + (format #t "unknown setting ~A (~A) to set-game-setting!" setting value)) + ) + ) + +(defmethod get-game-setting! pc-settings-jak2 ((obj pc-settings-jak2) (setting symbol)) + (case setting + (('video-mode) + (-> *setting-control* user-default video-mode) + ) + (('aspect-ratio) + (-> *setting-control* user-default aspect-ratio) + ) + (else + (format #t "unknown setting ~A to get-game-setting!" setting) + #f) + ) + ) + +(defmethod set-game-language! pc-settings-jak2 ((obj pc-settings-jak2) (lang language-enum)) + (set! (-> *setting-control* user-default language) lang) + ) + +(defmethod get-game-language! pc-settings-jak2 ((obj pc-settings-jak2)) + (-> *setting-control* user-default language) + ) + +(defmethod update-discord-rpc pc-settings-jak2 ((obj pc-settings-jak2)) + "update discord rpc module" (let ((info (new 'stack 'discord-info))) (set! (-> info orb-count) (&-> *game-info* skill-total)) (set! (-> info gem-count) (&-> *game-info* gem-total)) (set! (-> info death-count) (&-> *game-info* total-deaths)) - (set! (-> info status) "Playing Jak 2™") + (set! (-> info status) "Playing Jak II™") ;; grab the name of the level we're in (if (and *level* (level-get-target-inside *level*)) (set! (-> info level) (symbol->string (-> (level-get-target-inside *level*) name))) @@ -50,343 +70,68 @@ ;; TODO - wrapping in `with-profiler` causes an error, fix it (pc-discord-rpc-update info) ) - - (none)) - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;; file IO -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - - - -(defmacro file-stream-seek-until (fs func-name) - `(let ((done? #f) - (tell -1)) - - (until done? - - (let ((read (file-stream-read ,fs (-> *pc-temp-string* data) PC_TEMP_STRING_LEN))) - (cond - ((zero? read) - (set! (-> *pc-temp-string* data read) 0) - (true! done?) - ) - (else - (dotimes (i read) - (when (,func-name (-> *pc-temp-string* data i)) - (true! done?) - (set! tell (+ i (- (file-stream-tell ,fs) read))) - (set! i read) - ) - ) - ) - ) - - - ) - - ) - (if (!= tell -1) - (file-stream-seek ,fs tell SCE_SEEK_SET) - tell - ) - ) - ) - -(defmacro file-stream-read-until (fs func-name) - `(let ((read (file-stream-read ,fs (-> *pc-temp-string* data) PC_TEMP_STRING_LEN))) - (dotimes (i read) - (when (,func-name (-> *pc-temp-string* data i)) - (set! (-> *pc-temp-string* data i) 0) - (file-stream-seek ,fs (+ i (- (file-stream-tell ,fs) read)) SCE_SEEK_SET) - (set! i read) - ) - ) - *pc-temp-string* - ) - ) - -(defmacro is-whitespace-or-bracket? (c) - `(or (is-whitespace-char? ,c) (= #x28 ,c) (= #x29 ,c)) - ) - -(defun file-stream-seek-past-whitespace ((file file-stream)) - (file-stream-seek-until file not-whitespace-char?) - ) - -(defun file-stream-read-word ((file file-stream)) - (file-stream-read-until file is-whitespace-or-bracket?) - ;(format 0 "word ~A~%" *pc-temp-string*) - ) - -(defmacro file-stream-getc (fs) - `(let ((buf 255)) - (file-stream-read ,fs (& buf) 1) - ;(format 0 "getc got #x~X~%" buf) - buf - ) - ) - -(defun file-stream-read-int ((file file-stream)) - (file-stream-seek-past-whitespace file) - (file-stream-read-word file) - (string->int *pc-temp-string*) - ) - -(defun file-stream-read-float ((file file-stream)) - (file-stream-seek-past-whitespace file) - (file-stream-read-word file) - (string->float *pc-temp-string*) - ) - -(defun file-stream-read-symbol ((file file-stream)) - (file-stream-seek-past-whitespace file) - (file-stream-read-word file) - (string->symbol *pc-temp-string*) - ) - -(defmacro pc-settings-read-throw-error (fs msg) - "not an actual throw..." - `(begin - (format 0 "pc settings read error: ~S~%" ,msg) - (file-stream-close ,fs) - (return #f) - ) - ) - -(defmacro with-settings-scope (bindings &rest body) - (let ((fs (first bindings))) - `(begin - (file-stream-seek-past-whitespace ,fs) - (when (!= #x28 (file-stream-getc ,fs)) - (pc-settings-read-throw-error ,fs "invalid char, ( not found") - ) - - ,@body - - (file-stream-seek-past-whitespace ,fs) - (when (!= #x29 (file-stream-getc ,fs)) - (pc-settings-read-throw-error ,fs "invalid char, ) not found") - ) - ) - ) - ) - -(defmacro file-stream-get-next-char-ret (fs) - `(begin - (file-stream-seek-past-whitespace ,fs) - (let ((c (file-stream-getc ,fs))) - (file-stream-seek ,fs -1 SCE_SEEK_CUR) - c)) - ) - -(defmacro file-stream-get-next-char (fs) - `(begin - (file-stream-seek-past-whitespace ,fs) - (file-stream-getc ,fs) - ) - ) - -(defmacro dosettings (bindings &rest body) - "iterate over a list of key-value pairs like so: ( ) ( ) ... - the name of key is stored in *pc-temp-string*" - (let ((fs (first bindings))) - `(let ((c -1)) - (while (begin (file-stream-seek-past-whitespace ,fs) (set! c (file-stream-getc ,fs)) (= #x28 c)) - (file-stream-read-word ,fs) - - ,@body - - (set! c (file-stream-get-next-char ,fs)) - (when (!= #x29 c) - (pc-settings-read-throw-error ,fs (string-format "invalid char, ) not found, got #x~X ~A" c *pc-temp-string*)) - ) - ) - (file-stream-seek ,fs -1 SCE_SEEK_CUR) - ) - ) - ) - -(defmethod read-from-file pc-settings ((obj pc-settings) (filename string)) - "read settings from a file" - - (if (not filename) - (return #f)) - - (let ((file (new 'stack 'file-stream filename 'read))) - (when (not (file-stream-valid? file)) - (return #f)) - - (let ((version PC_KERNEL_VERSION)) - (with-settings-scope (file) - (case-str (file-stream-read-word file) - (("settings") - (set! version (the pckernel-version (file-stream-read-int file))) - (cond - ((and (= (-> version major) PC_KERNEL_VER_MAJOR) - (= (-> version minor) PC_KERNEL_VER_MINOR)) - ;; minor difference - ) - (else - ;; major difference - (format 0 "PC kernel version mismatch! Got ~D.~D vs ~D.~D~%" PC_KERNEL_VER_MAJOR PC_KERNEL_VER_MINOR (-> version major) (-> version minor)) - (file-stream-close file) - (return #f) - ) - ) - (dosettings (file) - (case-str *pc-temp-string* - (("discord-rpc?") (set! (-> obj discord-rpc?) (file-stream-read-symbol file))) - (("jetboard-trick-text?") (set! (-> obj jetboard-trick-text?) (file-stream-read-symbol file))) - ) - ) - ) - ) - ) - - ) - - (file-stream-close file) - ) - - (format 0 "pc settings file read: ~A~%" filename) - - #t - ) - -(defmethod write-to-file pc-settings ((obj pc-settings) (filename string)) - "write settings to a file" - - (if (not filename) - (return #f)) - - (let ((file (new 'stack 'file-stream filename 'write))) - (if (not (file-stream-valid? file)) - (return #f)) - - (format file "(settings #x~X~%" (-> obj version)) - (format file " (discord-rpc? ~A)~%" (-> obj discord-rpc?)) - (format file " (jetboard-trick-text? ~A)~%" (-> obj jetboard-trick-text?)) - (format file " )~%") - (file-stream-close file) - ) - - (format 0 "pc settings file write: ~A~%" filename) - - #t - ) - -(defmethod commit-to-file pc-settings ((obj pc-settings)) - "commits the current settings to the file" - ;; auto load settings if available - - (format (clear *pc-temp-string-1*) "~S/pc-settings.gc" *pc-settings-folder*) - (pc-mkdir-file-path *pc-temp-string-1*) - ;; symbol -> string in C++ nyi for jak2 symbols - ;; (write-to-file obj *pc-temp-string-1*) - (none)) - -(defmethod load-settings pc-settings ((obj pc-settings)) - "load" - - (format (clear *pc-temp-string-1*) "~S/pc-settings.gc" *pc-settings-folder*) - (if (pc-filepath-exists? *pc-temp-string-1*) - (begin - (format 0 "[PC] PC Settings found at '~S'...loading!~%" *pc-temp-string-1*) - (unless (read-from-file obj *pc-temp-string-1*) - (format 0 "[PC] PC Settings found at '~S' but could not be loaded, using defaults!~%" *pc-temp-string-1*) - (reset obj))) - (format 0 "[PC] PC Settings not found at '~S'...initializing with defaults!~%" *pc-temp-string-1*)) 0) -(defmethod new pc-settings ((allocation symbol) (type-to-make type)) - "make a new pc-settings" - (let ((obj (object-new allocation type-to-make (the-as int (-> type-to-make size))))) - (reset obj) - ;; auto load settings if available - ;; if saved settings are corrupted or not found, use defaults +(defmethod update-speedrun pc-settings-jak2 ((obj pc-settings-jak2)) + "update speedrun module" - (load-settings obj) + #f + ) - obj)) +(defmethod update-progress-video-hacks pc-settings-jak2 ((obj pc-settings-jak2)) + "update the graphics hacks used for the progress menu. ugh." + #f + ) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; file I/O +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + +(defmethod handle-input-settings pc-settings-jak2 ((obj pc-settings-jak2) (file file-stream)) + "handle the text parsing input for the 'settings' group" + + ((method-of-type pc-settings handle-input-settings) obj file) + (case-str *pc-temp-string* + (("jetboard-trick-text?") (set! (-> obj jetboard-trick-text?) (file-stream-read-symbol file))) + ) + 0) + +(defmethod handle-output-settings pc-settings-jak2 ((obj pc-settings-jak2) (file file-stream)) + "handle the text writing output for the 'settings' group" + + ((method-of-type pc-settings handle-output-settings) obj file) + (format file " (jetboard-trick-text? ~A)~%" (-> obj jetboard-trick-text?)) + 0) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; PC settings ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(define *pc-settings* (new 'global 'pc-settings)) +(define *pc-settings* (new 'global 'pc-settings-jak2)) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;; entity debugging +;;;; other ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(when *debug-segment* - -(deftype entity-debug-inspect (basic) - ((scroll-y int16) - (scroll-y-max int16) - (entity entity) - (show-actor-info symbol) - ) - (:methods - (new (symbol type) _type_) - (set-entity! (_type_ entity) entity) - (update-pad (_type_ int) none) - ) - ) - -(defmethod new entity-debug-inspect ((allocation symbol) (type-to-make type)) - "make a new entity-debug-inspect object" - - (let ((obj (object-new allocation type-to-make (the-as int (-> type-to-make size))))) - - (set! (-> obj scroll-y) 0) - (set! (-> obj scroll-y-max) 0) - (set! (-> obj entity) (the entity #f)) - (set! (-> obj show-actor-info) #f) - obj - ) - ) - -(defmethod set-entity! entity-debug-inspect ((obj entity-debug-inspect) (e entity)) - "set the entity to inspect" - - (set! (-> obj entity) e) - (unless e - (set! *debug-actor* (the string #f))) - (set! (-> obj scroll-y) 0) - - e - ) - -(defmethod update-pad entity-debug-inspect ((obj entity-debug-inspect) (pad-idx int)) - "respond to pad inputs" - - ;; scroll up - (if (cpad-pressed? pad-idx l1) - (1-! (-> obj scroll-y))) - ;; scroll down - (if (cpad-pressed? pad-idx r1) - (1+! (-> obj scroll-y))) - ;; toggle actor info - (if (cpad-pressed? pad-idx l3) - (not! (-> obj show-actor-info))) - - (minmax! (-> obj scroll-y) 0 (-> obj scroll-y-max)) - - (none)) - -(define *entity-debug-display-part* #f) ;; toggle for displaying part ents in the entity list -(define *entity-debug-inspect* (new 'debug 'entity-debug-inspect)) - -) ;; when debug_segment +(defun draw-build-revision () + (with-dma-buffer-add-bucket ((buf (-> (current-frame) global-buf)) + (bucket-id debug-no-zbuf1)) + (draw-string-xy *pc-settings-built-sha* + buf + 0 10 + (font-color flat-yellow) + (font-flags shadow kerning)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; process pools ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; the actor pool for PC processes! it has space for 4 processes, with 16K of space. -(define *pc-dead-pool* (new 'global 'dead-pool 4 (* 16 1024) "*pc-dead-pool*")) \ No newline at end of file +(define *pc-dead-pool* (new 'global 'dead-pool 4 (* 16 1024) "*pc-dead-pool*")) + diff --git a/goalc/make/MakeSystem.cpp b/goalc/make/MakeSystem.cpp index 7602ffa65f..dba65adea4 100644 --- a/goalc/make/MakeSystem.cpp +++ b/goalc/make/MakeSystem.cpp @@ -76,6 +76,11 @@ MakeSystem::MakeSystem(const std::string& username) : m_goos(username) { return handle_set_gsrc_folder(obj, args, env); }); + m_goos.register_form("get-gsrc-folder", [=](const goos::Object& obj, goos::Arguments& args, + const std::shared_ptr& env) { + return handle_get_gsrc_folder(obj, args, env); + }); + m_goos.set_global_variable_to_symbol("ASSETS", "#t"); set_constant("*iso-data*", file_util::get_file_path({"iso_data"})); @@ -209,28 +214,13 @@ goos::Object MakeSystem::handle_get_gsrc_path(const goos::Object& form, goos::Arguments& args, const std::shared_ptr& env) { if (m_gsrc_folder.empty()) { - throw std::runtime_error("`set-gsrc-folder!` was not called before a `get-src-path`"); + throw std::runtime_error("`set-gsrc-folder!` was not called before a `get-gsrc-path`"); } m_goos.eval_args(&args, env); va_check(form, args, {goos::ObjectType::STRING}, {}); const auto& file_name = args.unnamed.at(0).as_string()->data; - // Keep things fast by scanning the gsrc directory _once_ on the first call - if (m_gsrc_files.empty()) { - auto folder = file_util::get_file_path(m_gsrc_folder); - auto src_files = file_util::find_files_recursively(folder, std::regex(".*\\.gc")); - - for (const auto& path : src_files) { - auto name = file_util::base_name_no_ext(path.u8string()); - auto gsrc_path = - file_util::convert_to_unix_path_separators(file_util::split_path_at(path, m_gsrc_folder)); - // TODO - this is only "safe" because the current OpenGOAL system requires globally unique - // file names - m_gsrc_files.emplace(name, gsrc_path); - } - } - if (m_gsrc_files.count(file_name) != 0) { return goos::StringObject::make_new(m_gsrc_files.at(file_name)); } else { @@ -271,7 +261,39 @@ goos::Object MakeSystem::handle_set_gsrc_folder( const auto& folder = args.unnamed.at(0).as_string()->data; m_gsrc_folder = str_util::split(folder, '/'); - return goos::Object::make_empty_list(); + m_gsrc_files.clear(); + + auto folder_scan = file_util::get_file_path(m_gsrc_folder); + auto src_files = file_util::find_files_recursively(folder_scan, std::regex(".*\\.gc")); + + for (const auto& path : src_files) { + auto name = file_util::base_name_no_ext(path.u8string()); + auto gsrc_path = + file_util::convert_to_unix_path_separators(file_util::split_path_at(path, m_gsrc_folder)); + // TODO - this is only "safe" because the current OpenGOAL system requires globally unique + // file names + m_gsrc_files.emplace(name, gsrc_path); + } + + return args.unnamed.at(0); +} + +goos::Object MakeSystem::handle_get_gsrc_folder( + const goos::Object& form, + goos::Arguments& args, + const std::shared_ptr& env) { + m_goos.eval_args(&args, env); + va_check(form, args, {}, {}); + + std::string out; + int idx = 0; + for (const auto& part : m_gsrc_folder) { + if (idx++ > 0) { + out += '/'; + } + out += part; + } + return goos::StringObject::make_new(out); } void MakeSystem::get_dependencies(const std::string& master_target, diff --git a/goalc/make/MakeSystem.h b/goalc/make/MakeSystem.h index 3886b4d7aa..1b36d413ed 100644 --- a/goalc/make/MakeSystem.h +++ b/goalc/make/MakeSystem.h @@ -46,6 +46,10 @@ class MakeSystem { goos::Arguments& args, const std::shared_ptr& env); + goos::Object handle_get_gsrc_folder(const goos::Object& obj, + goos::Arguments& args, + const std::shared_ptr& env); + std::vector get_dependencies(const std::string& target) const; std::vector filter_dependencies(const std::vector& all_deps); diff --git a/test/decompiler/reference/jak2/engine/ambient/ambient_REF.gc b/test/decompiler/reference/jak2/engine/ambient/ambient_REF.gc index 139e324241..e51801ebf4 100644 --- a/test/decompiler/reference/jak2/engine/ambient/ambient_REF.gc +++ b/test/decompiler/reference/jak2/engine/ambient/ambient_REF.gc @@ -276,17 +276,9 @@ ;; definition for method 17 of type talker ;; WARN: Return type mismatch int vs none. (defmethod talker-method-17 talker ((obj talker)) - (let ((gp-0 (new - 'stack - 'font-context - *font-default-matrix* - 36 - 310 - 0.0 - (font-color default-#cddbcd) - (font-flags shadow kerning) - ) - ) + (let ((gp-0 + (new 'stack 'font-context *font-default-matrix* 36 310 0.0 (font-color default) (font-flags shadow kerning)) + ) ) (let ((f0-0 320.0)) (let ((v1-2 gp-0)) diff --git a/test/decompiler/reference/jak2/engine/debug/debug_REF.gc b/test/decompiler/reference/jak2/engine/debug/debug_REF.gc index 44fb018560..d62277d06d 100644 --- a/test/decompiler/reference/jak2/engine/debug/debug_REF.gc +++ b/test/decompiler/reference/jak2/engine/debug/debug_REF.gc @@ -42,8 +42,7 @@ ;; definition (debug) for function add-debug-point ;; INFO: Used lq/sq -;; WARN: Failed store: (s.w! (+ a0-6 8) 0) at op 152 -;; WARN: Failed store: (s.w! (+ a0-6 12) 0) at op 153 +;; ERROR: Failed store: (s.w! (+ a0-6 8) 0) at op 152 (defun-debug add-debug-point ((enable-draw symbol) (bucket bucket-id) (pt vector)) (if (not enable-draw) (return #f) @@ -157,8 +156,7 @@ ;; definition (debug) for function internal-draw-debug-line ;; INFO: Used lq/sq -;; WARN: Failed store: (s.w! (+ a0-29 8) 0) at op 271 -;; WARN: Failed store: (s.w! (+ a0-29 12) 0) at op 272 +;; ERROR: Failed store: (s.w! (+ a0-29 8) 0) at op 271 (defun-debug internal-draw-debug-line ((bucket bucket-id) (start vector) (end vector) (start-color rgba) (mode symbol) (end-color rgba)) (local-vars (var-end vector) (sv-128 vector) (sv-144 vector)) (set! var-end end) @@ -292,8 +290,7 @@ ;; definition (debug) for function internal-draw-debug-text-3d ;; INFO: Used lq/sq -;; WARN: Failed store: (s.w! (+ v1-12 8) 0) at op 54 -;; WARN: Failed store: (s.w! (+ v1-12 12) 0) at op 55 +;; ERROR: Failed store: (s.w! (+ v1-12 8) 0) at op 54 (defun-debug internal-draw-debug-text-3d ((bucket bucket-id) (text string) (position vector) (color font-color) (screen-offset vector2h)) (let ((screen-pos (new 'stack-no-clear 'vector4w))) (set! (-> screen-pos quad) (the-as uint128 0)) @@ -352,8 +349,7 @@ ;; definition (debug) for function add-debug-flat-triangle ;; INFO: Used lq/sq -;; WARN: Failed store: (s.w! (+ a0-13 8) 0) at op 153 -;; WARN: Failed store: (s.w! (+ a0-13 12) 0) at op 154 +;; ERROR: Failed store: (s.w! (+ a0-13 8) 0) at op 153 (defun-debug add-debug-flat-triangle ((enable symbol) (bucket bucket-id) (p0 vector) (p1 vector) (p2 vector) (color rgba)) (local-vars (sv-160 vector) (sv-176 vector)) (set! sv-160 p0) @@ -660,8 +656,7 @@ ;; definition (debug) for function add-debug-line2d ;; INFO: Used lq/sq -;; WARN: Failed store: (s.w! (+ v1-12 8) 0) at op 115 -;; WARN: Failed store: (s.w! (+ v1-12 12) 0) at op 116 +;; ERROR: Failed store: (s.w! (+ v1-12 8) 0) at op 115 (defun-debug add-debug-line2d ((enable symbol) (bucket bucket-id) (start vector4w) (end vector4w) (color vector4w)) (if (not enable) (return #f) @@ -1025,7 +1020,7 @@ ;; definition (debug) for function add-debug-text-sphere (defun-debug add-debug-text-sphere ((enable symbol) (bucket bucket-id) (position vector) (radius meters) (text string) (color rgba)) (add-debug-sphere enable bucket position radius color) - (add-debug-text-3d enable bucket text position (font-color default-#cddbcd) (the-as vector2h #f)) + (add-debug-text-3d enable bucket text position (font-color default) (the-as vector2h #f)) #f ) @@ -1443,8 +1438,7 @@ ;; INFO: Used lq/sq ;; WARN: Stack slot offset 32 signed mismatch ;; WARN: Stack slot offset 32 signed mismatch -;; WARN: Failed store: (s.w! (+ v1-9 8) 0) at op 47 -;; WARN: Failed store: (s.w! (+ v1-9 12) 0) at op 48 +;; ERROR: Failed store: (s.w! (+ v1-9 8) 0) at op 47 (defun-debug debug-percent-bar ((enable symbol) (bucket bucket-id) (x int) (y int) (percentage float) (color rgba) (width int) (height int)) (local-vars (sv-16 int) (sv-32 float)) (set! sv-16 y) @@ -1468,8 +1462,7 @@ ;; definition (debug) for function debug-pad-display ;; INFO: Used lq/sq -;; WARN: Failed store: (s.w! (+ v1-16 8) 0) at op 75 -;; WARN: Failed store: (s.w! (+ v1-16 12) 0) at op 76 +;; ERROR: Failed store: (s.w! (+ v1-16 8) 0) at op 75 (defun-debug debug-pad-display ((pad cpad-info)) (let ((stick-history (new 'static 'inline-array vector 32 (new 'static 'vector) @@ -1619,6 +1612,7 @@ ) ;; definition for method 3 of type debug-vertex-stats +;; INFO: this function exists in multiple non-identical object files (defmethod inspect debug-vertex-stats ((obj debug-vertex-stats)) (format #t "[~8x] ~A~%" obj (-> obj type)) (format #t "~Tlength: ~D~%" (-> obj length)) @@ -1741,8 +1735,7 @@ ;; definition (debug) for function add-debug-cursor ;; INFO: Used lq/sq ;; WARN: Return type mismatch int vs none. -;; WARN: Failed store: (s.w! (+ v1-9 8) 0) at op 38 -;; WARN: Failed store: (s.w! (+ v1-9 12) 0) at op 39 +;; ERROR: Failed store: (s.w! (+ v1-9 8) 0) at op 38 (defun-debug add-debug-cursor ((enable symbol) (bucket bucket-id) (x int) (y int) (arg4 int)) (when enable (with-dma-buffer-add-bucket ((buf (-> *display* frames (-> *display* on-screen) global-buf)) @@ -1757,7 +1750,7 @@ (+ y -4) (cond ((= v1-7 1) - (font-color precursor-#ec3b00) + (font-color red) ) ((= v1-7 2) (font-color yellow-#f3f300) @@ -1766,7 +1759,7 @@ (font-color green-#3df23d) ) (else - (font-color default-#cddbcd) + (font-color default) ) ) (font-flags shadow) @@ -1901,8 +1894,7 @@ ;; definition (debug) for function add-debug-bound ;; INFO: Used lq/sq ;; WARN: Return type mismatch int vs none. -;; WARN: Failed store: (s.w! (+ v1-29 8) 0) at op 110 -;; WARN: Failed store: (s.w! (+ v1-29 12) 0) at op 111 +;; ERROR: Failed store: (s.w! (+ v1-29 8) 0) at op 110 ;; WARN: Function add-debug-bound has a return type of none, but the expression builder found a return statement. (defun-debug add-debug-bound ((buf bucket-id) (pts (inline-array vector)) (c0 int) (c1 rgba) (flash rgba) (arg5 int)) (local-vars (sv-16 pointer) (sv-32 int)) diff --git a/test/decompiler/reference/jak2/engine/debug/menu_REF.gc b/test/decompiler/reference/jak2/engine/debug/menu_REF.gc index 17d7cc1cd2..c7c284a691 100644 --- a/test/decompiler/reference/jak2/engine/debug/menu_REF.gc +++ b/test/decompiler/reference/jak2/engine/debug/menu_REF.gc @@ -53,16 +53,8 @@ (set! (-> gp-0 root-menu) #f) (set! (-> gp-0 joypad-func) #f) (set! (-> gp-0 joypad-item) #f) - (set! (-> gp-0 font) (new - 'debug - 'font-context - *font-default-matrix* - 0 - 0 - 0.0 - (font-color default-#cddbcd) - (font-flags shadow kerning) - ) + (set! (-> gp-0 font) + (new 'debug 'font-context *font-default-matrix* 0 0 0.0 (font-color default) (font-flags shadow kerning)) ) (set! (-> gp-0 joypad-number) 0) gp-0 diff --git a/test/decompiler/reference/jak2/engine/entity/entity_REF.gc b/test/decompiler/reference/jak2/engine/entity/entity_REF.gc index 9d5eb987c9..a79a7b2269 100644 --- a/test/decompiler/reference/jak2/engine/entity/entity_REF.gc +++ b/test/decompiler/reference/jak2/engine/entity/entity_REF.gc @@ -71,6 +71,7 @@ ) ;; definition for method 3 of type actor-group +;; INFO: this function exists in multiple non-identical object files (defmethod inspect actor-group ((obj actor-group)) (format #t "[~8x] ~A~%" obj (-> obj type)) (format #t "~Tlength: ~D~%" (-> obj length)) @@ -530,6 +531,7 @@ ) ;; definition for method 2 of type process +;; INFO: this function exists in multiple non-identical object files (defmethod print process ((obj process)) (cond ((and (-> obj top-thread) (!= (-> obj status) 'dead)) @@ -1307,7 +1309,7 @@ (res-lump-struct sv-16 'name string) (-> (the-as process-drawable arg0) root trans) (if (logtest? (-> sv-16 extra perm status) (entity-perm-status bit-0 bit-1)) - (font-color precursor-#ec3b00) + (font-color red) (font-color #dadada) ) (new 'static 'vector2h :data (new 'static 'array int16 2 0 8)) diff --git a/test/decompiler/reference/jak2/engine/game/game-save_REF.gc b/test/decompiler/reference/jak2/engine/game/game-save_REF.gc index d188954970..b650ddd176 100644 --- a/test/decompiler/reference/jak2/engine/game/game-save_REF.gc +++ b/test/decompiler/reference/jak2/engine/game/game-save_REF.gc @@ -1878,21 +1878,12 @@ ) ;; definition for function auto-save-post -;; WARN: Failed store: (s.w! (+ v1-45 8) 0) at op 192 -;; WARN: Failed store: (s.w! (+ v1-45 12) 0) at op 193 +;; ERROR: Failed store: (s.w! (+ v1-45 8) 0) at op 192 (defbehavior auto-save-post auto-save () (when (and (= *cheat-mode* 'debug) (cpad-hold? 0 l3)) - (let ((gp-0 (new - 'stack - 'font-context - *font-default-matrix* - 32 - 320 - 0.0 - (font-color default-#cddbcd) - (font-flags shadow kerning) - ) - ) + (let ((gp-0 + (new 'stack 'font-context *font-default-matrix* 32 320 0.0 (font-color default) (font-flags shadow kerning)) + ) ) (let ((v1-5 gp-0)) (set! (-> v1-5 width) (the float 440)) @@ -1906,17 +1897,9 @@ ) ) (when (and (= (-> self mode) 'auto-save) (not (and (-> self next-state) (= (-> self next-state name) 'done)))) - (let ((gp-1 (new - 'stack - 'font-context - *font-default-matrix* - 20 - 80 - 0.0 - (font-color default-#cddbcd) - (font-flags shadow kerning) - ) - ) + (let ((gp-1 + (new 'stack 'font-context *font-default-matrix* 20 80 0.0 (font-color default) (font-flags shadow kerning)) + ) ) (let ((v1-17 gp-1)) (set! (-> v1-17 scale) 0.8) diff --git a/test/decompiler/reference/jak2/engine/game/main_REF.gc b/test/decompiler/reference/jak2/engine/game/main_REF.gc index a63808f8d7..0afbf81d52 100644 --- a/test/decompiler/reference/jak2/engine/game/main_REF.gc +++ b/test/decompiler/reference/jak2/engine/game/main_REF.gc @@ -1259,7 +1259,7 @@ (when *display-deci-count* (let ((s2-0 draw-string-xy)) (format (clear *temp-string*) "~D" *deci-count*) - (s2-0 *temp-string* s3-0 448 210 (font-color default-#cddbcd) (font-flags shadow)) + (s2-0 *temp-string* s3-0 448 210 (font-color default) (font-flags shadow)) ) ) (display-file-info) @@ -1283,7 +1283,7 @@ 352 320 ) - (font-color precursor-#ec3b00) + (font-color red) (font-flags shadow kerning middle large) ) ) @@ -1303,7 +1303,7 @@ s3-1 (the int (-> *font-context* origin x)) s2-2 - (font-color default-#cddbcd) + (font-color default) (font-flags shadow) ) ) @@ -1314,7 +1314,7 @@ s3-1 (the int (-> *font-context* origin x)) a3-6 - (font-color default-#cddbcd) + (font-color default) (font-flags shadow) ) ) diff --git a/test/decompiler/reference/jak2/engine/geometry/path_REF.gc b/test/decompiler/reference/jak2/engine/geometry/path_REF.gc index 2fff06ebba..9b18168882 100644 --- a/test/decompiler/reference/jak2/engine/geometry/path_REF.gc +++ b/test/decompiler/reference/jak2/engine/geometry/path_REF.gc @@ -17,7 +17,7 @@ (the-as bucket-id s3-0) *temp-string* (-> obj process root trans) - (font-color precursor-#ec3b00) + (font-color red) (the-as vector2h #f) ) ) @@ -424,7 +424,7 @@ using the fractional component of `idx` as the interpolant, return this result (the-as bucket-id s3-0) *temp-string* (-> obj process root trans) - (font-color precursor-#ec3b00) + (font-color red) (the-as vector2h #f) ) ) diff --git a/test/decompiler/reference/jak2/engine/gfx/hw/display_REF.gc b/test/decompiler/reference/jak2/engine/gfx/hw/display_REF.gc index ed7b7ea72d..3cefab6346 100644 --- a/test/decompiler/reference/jak2/engine/gfx/hw/display_REF.gc +++ b/test/decompiler/reference/jak2/engine/gfx/hw/display_REF.gc @@ -69,17 +69,9 @@ ) ;; definition for symbol *font-context*, type font-context -(define *font-context* (new - 'global - 'font-context - *font-default-matrix* - 0 - 0 - 0.0 - (font-color default-#cddbcd) - (font-flags shadow kerning) - ) - ) +(define *font-context* + (new 'global 'font-context *font-default-matrix* 0 0 0.0 (font-color default) (font-flags shadow kerning)) + ) ;; definition for function draw-sprite2d-xy ;; WARN: Return type mismatch pointer vs none. diff --git a/test/decompiler/reference/jak2/engine/process-drawable/process-drawable_REF.gc b/test/decompiler/reference/jak2/engine/process-drawable/process-drawable_REF.gc index 15859097ad..329eedafc2 100644 --- a/test/decompiler/reference/jak2/engine/process-drawable/process-drawable_REF.gc +++ b/test/decompiler/reference/jak2/engine/process-drawable/process-drawable_REF.gc @@ -615,14 +615,7 @@ (s2-0 318) ) (format (clear *temp-string*) "~2j~s error for ~s" arg0 (-> self name)) - (s4-0 - s3-0 - (the-as bucket-id s2-0) - *temp-string* - (the-as vector s5-1) - (font-color precursor-#ec3b00) - (the-as vector2h #f) - ) + (s4-0 s3-0 (the-as bucket-id s2-0) *temp-string* (the-as vector s5-1) (font-color red) (the-as vector2h #f)) ) ) ) diff --git a/test/decompiler/reference/jak2/engine/process-drawable/process-taskable_REF.gc b/test/decompiler/reference/jak2/engine/process-drawable/process-taskable_REF.gc index 7805429302..867000b31b 100644 --- a/test/decompiler/reference/jak2/engine/process-drawable/process-taskable_REF.gc +++ b/test/decompiler/reference/jak2/engine/process-drawable/process-taskable_REF.gc @@ -216,17 +216,9 @@ Seen take in - `true-func` which takes no args TODO - seems fishy (kill-current-talker (the-as symbol '()) '(daxter voicebox ambient) 'exit) (talker-surpress!) (when (can-display-query? self (the-as string #f) -99.0) - (let ((s5-1 (new - 'stack - 'font-context - *font-default-matrix* - 32 - 280 - 0.0 - (font-color default-#cddbcd) - (font-flags shadow kerning) - ) - ) + (let ((s5-1 + (new 'stack 'font-context *font-default-matrix* 32 280 0.0 (font-color default) (font-flags shadow kerning)) + ) ) (let ((v1-84 s5-1)) (set! (-> v1-84 width) (the float 340)) diff --git a/test/decompiler/reference/jak2/engine/ps2/memcard-h_REF.gc b/test/decompiler/reference/jak2/engine/ps2/memcard-h_REF.gc index 43a1843f4e..adb0febce8 100644 --- a/test/decompiler/reference/jak2/engine/ps2/memcard-h_REF.gc +++ b/test/decompiler/reference/jak2/engine/ps2/memcard-h_REF.gc @@ -154,7 +154,7 @@ ) ) ) - (draw-string-xy *temp-string* arg0 32 (+ (* 12 s4-0) 8) (font-color precursor-#ec3b00) (font-flags shadow)) + (draw-string-xy *temp-string* arg0 32 (+ (* 12 s4-0) 8) (font-color red) (font-flags shadow)) ) ) 0 diff --git a/test/decompiler/reference/jak2/engine/scene/scene_REF.gc b/test/decompiler/reference/jak2/engine/scene/scene_REF.gc index 53b8489200..9f8fbbd6b6 100644 --- a/test/decompiler/reference/jak2/engine/scene/scene_REF.gc +++ b/test/decompiler/reference/jak2/engine/scene/scene_REF.gc @@ -956,17 +956,9 @@ (when (and (>= f30-0 (-> v1-16 start-frame)) (< f30-0 (-> v1-16 end-frame))) (let ((s3-0 (-> v1-16 message s5-0))) (when (and s3-0 (nonzero? s3-0)) - (let ((s2-0 (new - 'stack - 'font-context - *font-default-matrix* - 20 - 290 - 0.0 - (font-color default-#cddbcd) - (font-flags shadow kerning) - ) - ) + (let ((s2-0 + (new 'stack 'font-context *font-default-matrix* 20 290 0.0 (font-color default) (font-flags shadow kerning)) + ) ) (let ((v1-20 s2-0)) (set! (-> v1-20 width) (the float 465)) @@ -992,7 +984,7 @@ (set! (-> s2-0 color) (font-color #000000)) (set! (-> s2-0 origin x) (+ 1.0 (-> s2-0 origin x))) (set! (-> s2-0 origin y) (+ 1.0 (-> s2-0 origin y))) - (set! (-> s2-0 color) (font-color default-#cddbcd)) + (set! (-> s2-0 color) (font-color default)) (set! (-> s2-0 flags) (font-flags shadow kerning middle left large)) (print-game-text (the-as string s3-0) s2-0 #f 44 (bucket-id bucket-322)) (gui-control-method-12 @@ -1611,17 +1603,9 @@ (when (and (< (- (-> self clock frame-counter) (-> self subtitle-change-time)) (seconds 2)) (< (mod (- (-> self clock frame-counter) (-> self subtitle-change-time)) 300) 210) ) - (let ((gp-6 (new - 'stack - 'font-context - *font-default-matrix* - 36 - 60 - 0.0 - (font-color default-#cddbcd) - (font-flags shadow kerning) - ) - ) + (let ((gp-6 + (new 'stack 'font-context *font-default-matrix* 36 60 0.0 (font-color default) (font-flags shadow kerning)) + ) ) (let ((v1-121 gp-6)) (set! (-> v1-121 width) (the float 440)) diff --git a/test/decompiler/reference/jak2/engine/sound/gsound_REF.gc b/test/decompiler/reference/jak2/engine/sound/gsound_REF.gc index 6cdde518c2..4e55404657 100644 --- a/test/decompiler/reference/jak2/engine/sound/gsound_REF.gc +++ b/test/decompiler/reference/jak2/engine/sound/gsound_REF.gc @@ -1147,7 +1147,7 @@ otherwise, an explicit [[vector]] can be provided" arg0 (+ (* s5-0 16) 16) 48 - (font-color default-#cddbcd) + (font-color default) (font-flags shadow) ) ) @@ -1160,7 +1160,7 @@ otherwise, an explicit [[vector]] can be provided" arg0 (+ (* s5-1 16) 16) 64 - (font-color default-#cddbcd) + (font-color default) (font-flags shadow) ) ) @@ -1172,7 +1172,7 @@ otherwise, an explicit [[vector]] can be provided" (-> *level* sound-bank 1) (-> *level* sound-bank 2) ) - (s5-2 *temp-string* arg0 16 88 (font-color default-#cddbcd) (font-flags shadow)) + (s5-2 *temp-string* arg0 16 88 (font-color default) (font-flags shadow)) ) (let ((s5-3 draw-string-xy)) (format @@ -1185,7 +1185,7 @@ otherwise, an explicit [[vector]] can be provided" (-> *setting-control* user-current sound-excitement) (-> *setting-control* user-current mode-sound-bank) ) - (s5-3 *temp-string* arg0 16 104 (font-color default-#cddbcd) (font-flags shadow)) + (s5-3 *temp-string* arg0 16 104 (font-color default) (font-flags shadow)) ) 0 ) @@ -1199,7 +1199,7 @@ otherwise, an explicit [[vector]] can be provided" (-> *sound-iop-info* freemem) (shr (-> *sound-iop-info* freemem) 10) ) - (s5-0 *temp-string* arg0 32 96 (font-color default-#cddbcd) (font-flags shadow)) + (s5-0 *temp-string* arg0 32 96 (font-color default) (font-flags shadow)) ) (let ((s5-1 draw-string-xy)) (format @@ -1208,7 +1208,7 @@ otherwise, an explicit [[vector]] can be provided" (-> *sound-iop-info* freemem2) (shr (-> *sound-iop-info* freemem2) 10) ) - (s5-1 *temp-string* arg0 32 64 (font-color default-#cddbcd) (font-flags shadow)) + (s5-1 *temp-string* arg0 32 64 (font-color default) (font-flags shadow)) ) 0 ) diff --git a/test/decompiler/reference/jak2/engine/target/mech_suit/mech_REF.gc b/test/decompiler/reference/jak2/engine/target/mech_suit/mech_REF.gc index 29963e78ab..e7a2478e3e 100644 --- a/test/decompiler/reference/jak2/engine/target/mech_suit/mech_REF.gc +++ b/test/decompiler/reference/jak2/engine/target/mech_suit/mech_REF.gc @@ -188,17 +188,9 @@ (can-display-query? self (the-as string #f) -99.0) (-> *setting-control* user-current pilot) ) - (let ((gp-0 (new - 'stack - 'font-context - *font-default-matrix* - 32 - 320 - 0.0 - (font-color default-#cddbcd) - (font-flags shadow kerning) - ) - ) + (let ((gp-0 + (new 'stack 'font-context *font-default-matrix* 32 320 0.0 (font-color default) (font-flags shadow kerning)) + ) ) (let ((v1-31 gp-0)) (set! (-> v1-31 width) (the float 340)) diff --git a/test/decompiler/reference/jak2/engine/target/target-turret_REF.gc b/test/decompiler/reference/jak2/engine/target/target-turret_REF.gc index 04013967bc..fea5756ac1 100644 --- a/test/decompiler/reference/jak2/engine/target/target-turret_REF.gc +++ b/test/decompiler/reference/jak2/engine/target/target-turret_REF.gc @@ -1165,17 +1165,9 @@ ) ) ) - (let ((gp-1 (new - 'stack - 'font-context - *font-default-matrix* - 32 - 320 - 0.0 - (font-color default-#cddbcd) - (font-flags shadow kerning) - ) - ) + (let ((gp-1 + (new 'stack 'font-context *font-default-matrix* 32 320 0.0 (font-color default) (font-flags shadow kerning)) + ) ) (let ((v1-21 gp-1)) (set! (-> v1-21 width) (the float 340)) @@ -2823,7 +2815,3 @@ This commonly includes things such as: (none) ) ) - - - - diff --git a/test/decompiler/reference/jak2/engine/ui/credits_REF.gc b/test/decompiler/reference/jak2/engine/ui/credits_REF.gc index 590f7c4480..1fac3935ee 100644 --- a/test/decompiler/reference/jak2/engine/ui/credits_REF.gc +++ b/test/decompiler/reference/jak2/engine/ui/credits_REF.gc @@ -7,17 +7,9 @@ (s5-0 3839) (f28-0 0.0) (s3-0 #t) - (s4-0 (new - 'stack - 'font-context - *font-default-matrix* - 6 - 0 - 0.0 - (font-color default-#cddbcd) - (font-flags shadow kerning) - ) - ) + (s4-0 + (new 'stack 'font-context *font-default-matrix* 6 0 0.0 (font-color default) (font-flags shadow kerning)) + ) ) (let ((v1-2 s4-0)) (set! (-> v1-2 width) (the float 500)) @@ -1064,7 +1056,3 @@ (sp-rnd-flt spt-conerot-z (degrees 0.0) (degrees 3600.0) 1.0) ) ) - - - - diff --git a/test/decompiler/reference/jak2/engine/ui/progress/progress_REF.gc b/test/decompiler/reference/jak2/engine/ui/progress/progress_REF.gc index 9a0432e1c5..e5c0266df9 100644 --- a/test/decompiler/reference/jak2/engine/ui/progress/progress_REF.gc +++ b/test/decompiler/reference/jak2/engine/ui/progress/progress_REF.gc @@ -1396,8 +1396,7 @@ ) ;; definition for function end-scan -;; WARN: Failed store: (s.w! (+ v1-8 8) 0) at op 19 -;; WARN: Failed store: (s.w! (+ v1-8 12) 0) at op 20 +;; ERROR: Failed store: (s.w! (+ v1-8 8) 0) at op 19 (defun end-scan ((arg0 hud-box) (arg1 float)) (with-dma-buffer-add-bucket ((s5-0 (-> *display* frames (-> *display* on-screen) global-buf)) (bucket-id progress) @@ -1432,16 +1431,8 @@ (s4-0 (-> self current-options y-center)) (s5-0 (-> self current-options y-space)) ) - (set! sv-144 (new - 'stack - 'font-context - *font-default-matrix* - 0 - 0 - 0.0 - (font-color default-#cddbcd) - (font-flags shadow kerning) - ) + (set! sv-144 + (new 'stack 'font-context *font-default-matrix* 0 0 0.0 (font-color default) (font-flags shadow kerning)) ) (set! sv-148 (- s4-0 (/ (* s5-0 (length gp-0)) 2))) (set! sv-152 (new 'stack-no-clear 'hud-box)) diff --git a/test/decompiler/reference/jak2/engine/util/profile_REF.gc b/test/decompiler/reference/jak2/engine/util/profile_REF.gc index eceaf9eefa..497a2d784d 100644 --- a/test/decompiler/reference/jak2/engine/util/profile_REF.gc +++ b/test/decompiler/reference/jak2/engine/util/profile_REF.gc @@ -681,8 +681,8 @@ 488 arg1 (if (>= f30-0 100.0) - (font-color precursor-#ec3b00) - (font-color default-#cddbcd) + (font-color red) + (font-color default) ) (font-flags shadow right) ) @@ -697,8 +697,8 @@ 488 arg1 (if (>= f30-0 100.0) - (font-color precursor-#ec3b00) - (font-color default-#cddbcd) + (font-color red) + (font-color default) ) (font-flags shadow right) ) @@ -732,8 +732,8 @@ 488 arg1 (if (>= f30-1 100.0) - (font-color precursor-#ec3b00) - (font-color default-#cddbcd) + (font-color red) + (font-color default) ) (font-flags shadow right) ) @@ -748,8 +748,8 @@ 488 arg1 (if (>= f30-1 100.0) - (font-color precursor-#ec3b00) - (font-color default-#cddbcd) + (font-color red) + (font-color default) ) (font-flags shadow right) ) diff --git a/test/decompiler/reference/jak2/levels/city/common/nav-graph_REF.gc b/test/decompiler/reference/jak2/levels/city/common/nav-graph_REF.gc index 773cd2bbff..433d5d6c95 100644 --- a/test/decompiler/reference/jak2/levels/city/common/nav-graph_REF.gc +++ b/test/decompiler/reference/jak2/levels/city/common/nav-graph_REF.gc @@ -126,7 +126,7 @@ *temp-string* gp-0 (if (logtest? (-> obj flags) (nav-node-flag-byte blocked)) - (font-color precursor-#ec3b00) + (font-color red) (font-color cyan-#00fefe) ) (the-as vector2h #f) @@ -1469,7 +1469,3 @@ and patched at runtime after loading." ) (none) ) - - - - diff --git a/test/decompiler/reference/jak2/levels/city/common/traffic-engine_REF.gc b/test/decompiler/reference/jak2/levels/city/common/traffic-engine_REF.gc index 6d7142ba90..049bff1c95 100644 --- a/test/decompiler/reference/jak2/levels/city/common/traffic-engine_REF.gc +++ b/test/decompiler/reference/jak2/levels/city/common/traffic-engine_REF.gc @@ -1224,7 +1224,7 @@ Process is recycled and moved to reserved, if it deactivates." sv-84 (if (< (-> sv-20 user-count) (-> sv-20 max-user-count)) (font-color yellow-#f3f300) - (font-color precursor-#ec3b00) + (font-color red) ) (the-as vector2h #f) ) diff --git a/test/decompiler/reference/jak2/levels/city/common/vehicle-util_REF.gc b/test/decompiler/reference/jak2/levels/city/common/vehicle-util_REF.gc index 3eb76a4c5d..2712fb2cbb 100644 --- a/test/decompiler/reference/jak2/levels/city/common/vehicle-util_REF.gc +++ b/test/decompiler/reference/jak2/levels/city/common/vehicle-util_REF.gc @@ -389,17 +389,9 @@ This commonly includes things such as: (can-display-query? obj (the-as string #f) (/ 1.0 (-> s5-0 floats 3))) ) ) - (let ((s3-1 (new - 'stack - 'font-context - *font-default-matrix* - 32 - 320 - 0.0 - (font-color default-#cddbcd) - (font-flags shadow kerning) - ) - ) + (let ((s3-1 + (new 'stack 'font-context *font-default-matrix* 32 320 0.0 (font-color default) (font-flags shadow kerning)) + ) ) (let ((v1-97 s3-1)) (set! (-> v1-97 width) (the float 340)) diff --git a/test/decompiler/reference/jak2/levels/city/oracle/oracle-training_REF.gc b/test/decompiler/reference/jak2/levels/city/oracle/oracle-training_REF.gc index 594b23543a..42972b025e 100644 --- a/test/decompiler/reference/jak2/levels/city/oracle/oracle-training_REF.gc +++ b/test/decompiler/reference/jak2/levels/city/oracle/oracle-training_REF.gc @@ -82,17 +82,9 @@ (send-event *target* 'change-mode 'darkjak #f 65) ) (when (= (get-status *gui-control* (-> self sound-id 0)) (gui-status active)) - (let ((gp-1 (new - 'stack - 'font-context - *font-default-matrix* - 32 - 280 - 0.0 - (font-color default-#cddbcd) - (font-flags shadow kerning) - ) - ) + (let ((gp-1 + (new 'stack 'font-context *font-default-matrix* 32 280 0.0 (font-color default) (font-flags shadow kerning)) + ) ) (set! (-> gp-1 flags) (font-flags shadow kerning large)) (let ((v1-14 gp-1)) @@ -196,17 +188,9 @@ (send-event *target* 'change-mode 'darkjak #f 65) ) (when (= (get-status *gui-control* (-> self sound-id 0)) (gui-status active)) - (let ((gp-1 (new - 'stack - 'font-context - *font-default-matrix* - 32 - 280 - 0.0 - (font-color default-#cddbcd) - (font-flags shadow kerning) - ) - ) + (let ((gp-1 + (new 'stack 'font-context *font-default-matrix* 32 280 0.0 (font-color default) (font-flags shadow kerning)) + ) ) (set! (-> gp-1 flags) (font-flags shadow kerning large)) (let ((v1-14 gp-1)) @@ -289,17 +273,9 @@ (send-event *target* 'change-mode 'darkjak #f 65) ) (when (= (get-status *gui-control* (-> self sound-id 0)) (gui-status active)) - (let ((gp-1 (new - 'stack - 'font-context - *font-default-matrix* - 32 - 280 - 0.0 - (font-color default-#cddbcd) - (font-flags shadow kerning) - ) - ) + (let ((gp-1 + (new 'stack 'font-context *font-default-matrix* 32 280 0.0 (font-color default) (font-flags shadow kerning)) + ) ) (set! (-> gp-1 flags) (font-flags shadow kerning large)) (let ((v1-14 gp-1)) @@ -404,17 +380,9 @@ (send-event *target* 'change-mode 'darkjak #f 65) ) (when (= (get-status *gui-control* (-> self sound-id 0)) (gui-status active)) - (let ((gp-1 (new - 'stack - 'font-context - *font-default-matrix* - 32 - 280 - 0.0 - (font-color default-#cddbcd) - (font-flags shadow kerning) - ) - ) + (let ((gp-1 + (new 'stack 'font-context *font-default-matrix* 32 280 0.0 (font-color default) (font-flags shadow kerning)) + ) ) (set! (-> gp-1 flags) (font-flags shadow kerning large)) (let ((v1-14 gp-1)) diff --git a/test/decompiler/reference/jak2/levels/common/races/race-hud_REF.gc b/test/decompiler/reference/jak2/levels/common/races/race-hud_REF.gc index 33b78d8c98..387bff400c 100644 --- a/test/decompiler/reference/jak2/levels/common/races/race-hud_REF.gc +++ b/test/decompiler/reference/jak2/levels/common/races/race-hud_REF.gc @@ -313,16 +313,7 @@ (s3-0 (+ s4-0 3)) ) (let ((s1-0 - (new - 'stack - 'font-context - *font-default-matrix* - 0 - 0 - 0.0 - (font-color default-#cddbcd) - (font-flags shadow kerning) - ) + (new 'stack 'font-context *font-default-matrix* 0 0 0.0 (font-color default) (font-flags shadow kerning)) ) ) (set! (-> obj strings 0 scale) 0.0) @@ -335,7 +326,7 @@ (set! (-> v1-16 height) (the float 80)) ) (let ((a0-12 s1-0)) - (set! (-> a0-12 color) (font-color precursor-#ec3b00)) + (set! (-> a0-12 color) (font-color red)) ) (let ((a0-13 s1-0)) (set! (-> a0-13 flags) (font-flags kerning middle left large)) @@ -476,7 +467,7 @@ (alloc-string-if-needed obj s5-0) ) (set! (-> obj strings 0 flags) (font-flags kerning middle large)) - (set! (-> obj strings 0 color) (font-color precursor-#ec3b00)) + (set! (-> obj strings 0 color) (font-color red)) (set! (-> obj strings 1 flags) (font-flags kerning large)) (set! (-> obj strings 1 color) (font-color #dadada)) (set! (-> obj strings 2 flags) (font-flags kerning large)) @@ -484,7 +475,3 @@ 0 (none) ) - - - - diff --git a/test/decompiler/reference/jak2/levels/common/warp-gate_REF.gc b/test/decompiler/reference/jak2/levels/common/warp-gate_REF.gc index ce09fe8eb3..ee704d3d2d 100644 --- a/test/decompiler/reference/jak2/levels/common/warp-gate_REF.gc +++ b/test/decompiler/reference/jak2/levels/common/warp-gate_REF.gc @@ -621,17 +621,9 @@ (new 'stack 'script-context (the-as basic (process->ppointer self)) self (the-as vector #f)) (-> self on-close) ) - (let ((gp-0 (new - 'stack - 'font-context - *font-default-matrix* - 32 - 320 - 0.0 - (font-color default-#cddbcd) - (font-flags shadow kerning) - ) - ) + (let ((gp-0 + (new 'stack 'font-context *font-default-matrix* 32 320 0.0 (font-color default) (font-flags shadow kerning)) + ) ) (let ((v1-51 gp-0)) (set! (-> v1-51 width) (the float 340)) diff --git a/test/decompiler/reference/jak2/levels/demo/demo-obs_REF.gc b/test/decompiler/reference/jak2/levels/demo/demo-obs_REF.gc index 3018a5360b..abd59443fc 100644 --- a/test/decompiler/reference/jak2/levels/demo/demo-obs_REF.gc +++ b/test/decompiler/reference/jak2/levels/demo/demo-obs_REF.gc @@ -552,16 +552,8 @@ (return (the-as object (-> self selected))) ) ) - (set! sv-112 (new - 'stack - 'font-context - *font-default-matrix* - 64 - 312 - 0.0 - (font-color default-#cddbcd) - (font-flags shadow kerning) - ) + (set! sv-112 + (new 'stack 'font-context *font-default-matrix* 64 312 0.0 (font-color default) (font-flags shadow kerning)) ) (let ((v1-25 sv-112)) (set! (-> v1-25 width) (the float 384)) diff --git a/test/decompiler/reference/jak2/levels/gungame/gungame-obs_REF.gc b/test/decompiler/reference/jak2/levels/gungame/gungame-obs_REF.gc index 5867d570fc..b9041ea2b1 100644 --- a/test/decompiler/reference/jak2/levels/gungame/gungame-obs_REF.gc +++ b/test/decompiler/reference/jak2/levels/gungame/gungame-obs_REF.gc @@ -286,17 +286,9 @@ This commonly includes things such as: ;; definition for method 30 of type training-manager (defmethod render-text training-manager ((obj training-manager) (arg0 game-text-id)) (when (= (get-status *gui-control* (-> obj gui-id)) (gui-status active)) - (let ((s5-1 (new - 'stack - 'font-context - *font-default-matrix* - 32 - 290 - 0.0 - (font-color default-#cddbcd) - (font-flags shadow kerning) - ) - ) + (let ((s5-1 + (new 'stack 'font-context *font-default-matrix* 32 290 0.0 (font-color default) (font-flags shadow kerning)) + ) ) (set! (-> s5-1 flags) (font-flags shadow kerning left large)) (let ((v1-4 s5-1)) diff --git a/test/decompiler/reference/jak2/levels/stadium/jetboard/skatea-obs_REF.gc b/test/decompiler/reference/jak2/levels/stadium/jetboard/skatea-obs_REF.gc index ae08c46097..9dce4f8a11 100644 --- a/test/decompiler/reference/jak2/levels/stadium/jetboard/skatea-obs_REF.gc +++ b/test/decompiler/reference/jak2/levels/stadium/jetboard/skatea-obs_REF.gc @@ -100,17 +100,9 @@ ;; definition for method 28 of type hoverboard-training-manager (defmethod render-text hoverboard-training-manager ((obj hoverboard-training-manager) (arg0 game-text-id)) (when (= (get-status *gui-control* (-> obj gui-id)) (gui-status active)) - (let ((s5-1 (new - 'stack - 'font-context - *font-default-matrix* - 32 - 280 - 0.0 - (font-color default-#cddbcd) - (font-flags shadow kerning) - ) - ) + (let ((s5-1 + (new 'stack 'font-context *font-default-matrix* 32 280 0.0 (font-color default) (font-flags shadow kerning)) + ) ) (set! (-> s5-1 flags) (font-flags shadow kerning large)) (let ((v1-4 s5-1)) diff --git a/test/decompiler/reference/jak2/levels/title/title-obs_REF.gc b/test/decompiler/reference/jak2/levels/title/title-obs_REF.gc index 1452583c9f..c17439f5c3 100644 --- a/test/decompiler/reference/jak2/levels/title/title-obs_REF.gc +++ b/test/decompiler/reference/jak2/levels/title/title-obs_REF.gc @@ -560,16 +560,8 @@ ) ) (when (< (mod (-> self clock frame-counter) 300) 210) - (set! sv-112 (new - 'stack - 'font-context - *font-default-matrix* - 64 - 312 - 0.0 - (font-color default-#cddbcd) - (font-flags shadow kerning) - ) + (set! sv-112 + (new 'stack 'font-context *font-default-matrix* 64 312 0.0 (font-color default) (font-flags shadow kerning)) ) (let ((v1-35 sv-112)) (set! (-> v1-35 width) (the float 384))