diff --git a/decompiler/config/jak2/var_names.jsonc b/decompiler/config/jak2/var_names.jsonc index 8e28499706..fd515cf1e7 100644 --- a/decompiler/config/jak2/var_names.jsonc +++ b/decompiler/config/jak2/var_names.jsonc @@ -2279,5 +2279,8 @@ }, "(method 181 gator)": { "vars": { "s4-0": ["s4-0", "art-joint-anim"] } + }, + "(code target-running-attack)": { + "vars": {"t1-6": ["t1-6", "sound-name"]} } } diff --git a/game/graphics/pipelines/opengl.cpp b/game/graphics/pipelines/opengl.cpp index feb1bebbf4..ef435b56dc 100644 --- a/game/graphics/pipelines/opengl.cpp +++ b/game/graphics/pipelines/opengl.cpp @@ -465,6 +465,22 @@ 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; + } + want_hotkey_screenshot = want_hotkey_screenshot && g_gfx_data->debug_gui.screenshot_hotkey_enabled; if (want_hotkey_screenshot) { diff --git a/game/mips2c/mips2c_private.h b/game/mips2c/mips2c_private.h index d20bed0aff..4412cebb86 100644 --- a/game/mips2c/mips2c_private.h +++ b/game/mips2c/mips2c_private.h @@ -999,7 +999,7 @@ struct ExecutionContext { void vsqrt(int src, BC bc) { Q = std::sqrt(std::abs(vf_src(src).f[(int)bc])); } - void sqrts(int src, int dst) { fprs[dst] = std::sqrt(std::abs(fprs[src])); } + void sqrts(int dst, int src) { fprs[dst] = std::sqrt(std::abs(fprs[src])); } void vmulq(DEST mask, int dst, int src) { auto s0 = vf_src(src); diff --git a/goal_src/jak2/engine/target/target.gc b/goal_src/jak2/engine/target/target.gc index c6bfe341db..a2934f9ec5 100644 --- a/goal_src/jak2/engine/target/target.gc +++ b/goal_src/jak2/engine/target/target.gc @@ -2733,8 +2733,8 @@ ) ) (let ((t1-6 (if (using-gun? self) - (make-u128 (the-as uint #x7469682d772d68) (the-as uint #x636e75702d6e7567)) - (make-u128 #x746968 (the-as uint #x2d772d68636e7570)) + (static-sound-name "gun-punch-w-hit") + (static-sound-name "punch-w-hit") ) ) ) diff --git a/goal_src/jak2/kernel/gcommon.gc b/goal_src/jak2/kernel/gcommon.gc index 74bc655f35..dd55569e26 100644 --- a/goal_src/jak2/kernel/gcommon.gc +++ b/goal_src/jak2/kernel/gcommon.gc @@ -1320,7 +1320,7 @@ ) ) -(defmacro with-profiler (name &rest body) +(defmacro with-pc-profiler (name &rest body) "Execute the body in a named profiler block. Do not `return` or `go` from inside this block, otherwise the end will be skipped." diff --git a/goal_src/jak2/kernel/gkernel.gc b/goal_src/jak2/kernel/gkernel.gc index 302443e255..f8c5f38b33 100644 --- a/goal_src/jak2/kernel/gkernel.gc +++ b/goal_src/jak2/kernel/gkernel.gc @@ -1589,7 +1589,9 @@ ;; (format 0 "Trans | Proc '~A' | C1: ~X C2: ~X C3: ~X~%" arg0 (-> *canary-1*) (-> *canary-2*) (-> *canary-3*)) (when (-> arg0 trans-hook) (let ((s4-0 (new 'process 'cpu-thread arg0 'trans 256 (-> arg0 main-thread stack-top)))) - (reset-and-call s4-0 (-> arg0 trans-hook)) + (with-pc-profiler "trans" + (reset-and-call s4-0 (-> arg0 trans-hook)) + ) (delete s4-0) ) (when (= (-> arg0 status) 'dead) ;; handle deactivates in trans @@ -1603,7 +1605,9 @@ ;; (format 0 "Code | Proc '~A' | C1: ~X C2: ~X C3: ~X~%" arg0 (-> *canary-1*) (-> *canary-2*) (-> *canary-3*)) (if (logtest? (-> arg0 mask) (process-mask sleep-code)) (set! (-> arg0 status) 'suspended) - ((-> arg0 main-thread resume-hook) (-> arg0 main-thread)) + (with-pc-profiler "code" + ((-> arg0 main-thread resume-hook) (-> arg0 main-thread)) + ) ) ;; (format 0 "Finished Code | Proc '~A' | C1: ~X C2: ~X C3: ~X~%" arg0 (-> *canary-1*) (-> *canary-2*) (-> *canary-3*)) @@ -1620,7 +1624,9 @@ ;; (format 0 "Post | Proc '~A' | C1: ~X C2: ~X C3: ~X~%" arg0 (-> *canary-1*) (-> *canary-2*) (-> *canary-3*)) (when (-> arg0 post-hook) (let ((s4-1 (new 'process 'cpu-thread arg0 'post 256 *kernel-dram-stack*))) - (reset-and-call s4-1 (-> arg0 post-hook)) + (with-pc-profiler "post" + (reset-and-call s4-1 (-> arg0 post-hook)) + ) (delete s4-1) ) (when (= (-> arg0 status) 'dead) ;; handle death in post diff --git a/goalc/compiler/IR.cpp b/goalc/compiler/IR.cpp index 9d88b966e2..70c4c6dca0 100644 --- a/goalc/compiler/IR.cpp +++ b/goalc/compiler/IR.cpp @@ -240,7 +240,11 @@ void IR_LoadSymbolPointer::do_codegen(emitter::ObjectGenerator* gen, auto dest_reg = get_reg(m_dest, allocs, irec); if (m_name == "#f") { static_assert(false_symbol_offset() == 0, "false symbol location"); - gen->add_instr(IGen::mov_gpr64_gpr64(dest_reg, gRegInfo.get_st_reg()), irec); + if (dest_reg.is_xmm()) { + gen->add_instr(IGen::movq_xmm64_gpr64(dest_reg, gRegInfo.get_st_reg()), irec); + } else { + gen->add_instr(IGen::mov_gpr64_gpr64(dest_reg, gRegInfo.get_st_reg()), irec); + } } else if (m_name == "#t") { gen->add_instr(IGen::lea_reg_plus_off8(dest_reg, gRegInfo.get_st_reg(), true_symbol_offset(gen->version())), diff --git a/goalc/compiler/compilation/ControlFlow.cpp b/goalc/compiler/compilation/ControlFlow.cpp index 4a122667d8..ca576f2c46 100644 --- a/goalc/compiler/compilation/ControlFlow.cpp +++ b/goalc/compiler/compilation/ControlFlow.cpp @@ -213,7 +213,7 @@ Val* Compiler::compile_cond(const goos::Object& form, const goos::Object& rest, // optimization - if we get junk, don't bother moving it, just leave junk in return. if (!is_none(case_result)) { // todo, what does GOAL do here? does it matter? - env->emit(o, std::make_unique(result, case_result->to_gpr(o, env))); + env->emit(o, std::make_unique(result, case_result->to_reg(o, env))); } } else { @@ -238,7 +238,7 @@ Val* Compiler::compile_cond(const goos::Object& form, const goos::Object& rest, case_result_types.push_back(case_result->type()); if (!is_none(case_result)) { // todo, what does GOAL do here? - env->emit(o, std::make_unique(result, case_result->to_gpr(o, env))); + env->emit(o, std::make_unique(result, case_result->to_reg(o, env))); } // GO TO END @@ -262,6 +262,12 @@ Val* Compiler::compile_cond(const goos::Object& form, const goos::Object& rest, result->set_type(coerce_to_reg_type(m_ts.lowest_common_ancestor(case_result_types))); } + // maybe use 128-bit register + if (result->type().base_type() != "none" && + m_ts.lookup_type_allow_partial_def(result->type())->get_load_size() == 16) { + result->change_class(RegClass::INT_128); + } + // PATCH END end_label->idx = fenv->code().size(); diff --git a/test/decompiler/reference/jak2/engine/target/target_REF.gc b/test/decompiler/reference/jak2/engine/target/target_REF.gc index 93a073b49a..c175500dcd 100644 --- a/test/decompiler/reference/jak2/engine/target/target_REF.gc +++ b/test/decompiler/reference/jak2/engine/target/target_REF.gc @@ -2759,8 +2759,8 @@ ) ) (let ((t1-6 (if (using-gun? self) - (make-u128 (the-as uint #x7469682d772d68) (the-as uint #x636e75702d6e7567)) - (make-u128 #x746968 (the-as uint #x2d772d68636e7570)) + (the-as sound-name (static-sound-name "gun-punch-w-hit")) + (the-as sound-name (static-sound-name "punch-w-hit")) ) ) ) @@ -2770,7 +2770,7 @@ -1.0 (-> self control impact-ctrl joint) (the-as basic #f) - (the-as sound-name t1-6) + t1-6 ) ) (activate! *camera-smush-control* 819.2 15 75 1.0 0.9 (-> *display* camera-clock))