From 7b25afa697e79aceb30176c68c1c45abc48ea8fc Mon Sep 17 00:00:00 2001 From: ManDude <7569514+ManDude@users.noreply.github.com> Date: Sat, 20 Aug 2022 15:30:37 +0100 Subject: [PATCH] add a bunch of new cheat codes & re-do all pc cheat codes (#1770) * redo cheat encodings * fix error * add no texture cheat * tiny cleanup + add sidekick stats button * crappy implementation of big/small head mode * more correct bone scaling * redo bone manip code a bit * jp text fixes * improved matrix math! * add big fist cheat, minor type cleanup, add some debug toggles * move all this mess to a new file * slightly rework joint scaling function * add big head npc cheat * subtitles typo * WIP mirror mode * fix mirrored hud sprites * fix mirror mode sound pan * add cheats to menu! * split some subtitles --- decompiler/config/all-types.gc | 25 ++-- game/assets/game_text.gp | 2 - game/assets/jak1/subtitle/game_subtitle_en.gd | 47 ++++--- game/assets/jak1/text/game_text_en.gs | 20 ++- game/assets/jak1/text/game_text_ja.gs | 8 +- game/assets/jak1/text/text_patch_ja.gs | 10 -- game/graphics/gfx.h | 12 +- .../opengl_renderer/OpenGLRenderer.cpp | 4 +- game/graphics/opengl_renderer/Shader.cpp | 4 +- game/graphics/opengl_renderer/Shader.h | 2 +- .../background/background_common.cpp | 21 +-- .../opengl_renderer/foreground/Generic2.h | 1 + .../foreground/Generic2_OpenGL.cpp | 26 ++-- .../opengl_renderer/foreground/Merc2.cpp | 40 +++--- .../opengl_renderer/foreground/Merc2.h | 2 + .../opengl_renderer/shaders/generic.frag | 72 +++++++---- .../opengl_renderer/shaders/merc2.frag | 18 ++- .../opengl_renderer/shaders/shrub.frag | 10 +- .../opengl_renderer/shaders/shrub.vert | 1 + .../opengl_renderer/shaders/tfrag3.frag | 12 +- game/kernel/common/kmachine.cpp | 8 ++ game/kernel/common/kmachine.h | 1 + game/kernel/jak1/kmachine.cpp | 1 + goal_src/jak1/dgos/engine.gd | 1 + goal_src/jak1/dgos/game.gd | 1 + goal_src/jak1/engine/anim/joint-mod-h.gc | 40 +++--- goal_src/jak1/engine/anim/mspace-h.gc | 2 +- .../jak1/engine/common-obs/generic-obs.gc | 2 + .../engine/common-obs/process-drawable.gc | 22 +++- .../engine/common-obs/process-taskable.gc | 2 + goal_src/jak1/engine/debug/default-menu.gc | 19 +-- goal_src/jak1/engine/game/main.gc | 3 +- goal_src/jak1/engine/gfx/hw/display.gc | 4 +- goal_src/jak1/engine/gfx/math-camera.gc | 17 +-- goal_src/jak1/engine/gfx/sprite/sprite.gc | 11 +- goal_src/jak1/engine/math/matrix.gc | 2 +- goal_src/jak1/engine/ps2/pad.gc | 12 +- goal_src/jak1/engine/sound/gsound.gc | 7 + goal_src/jak1/engine/ui/text-h.gc | 7 + goal_src/jak1/game.gp | 3 +- goal_src/jak1/kernel-defs.gc | 4 + goal_src/jak1/pc/pckernel-h.gc | 95 ++++++++------ goal_src/jak1/pc/pckernel.gc | 71 ++++++---- goal_src/jak1/pc/progress-pc.gc | 42 +++--- goal_src/jak1/pc/util/pc-anim-util.gc | 122 ++++++++++++++++++ .../jak1/engine/anim/mspace-h_REF.gc | 2 +- .../jak1/engine/target/joint-mod-h_REF.gc | 29 ++--- 47 files changed, 587 insertions(+), 280 deletions(-) delete mode 100644 game/assets/jak1/text/text_patch_ja.gs create mode 100644 goal_src/jak1/pc/util/pc-anim-util.gc diff --git a/decompiler/config/all-types.gc b/decompiler/config/all-types.gc index d4ff86ae9..d9295e4f4 100644 --- a/decompiler/config/all-types.gc +++ b/decompiler/config/all-types.gc @@ -1530,6 +1530,13 @@ (cheat-sky #x1097) (cheat-req-100-percent #x1098) (cheat-req-beat-game #x1099) + (cheat-big-head #x109a) + (cheat-small-head #x109b) + (cheat-big-fist #x109c) + (cheat-big-head-npc #x109d) + (cheat-no-tex #x109e) + (cheat-mirror #x109f) + (cheat-huge-head #x10a0) (music-player #x10c0) (scene-player #x10c1) (play-credits #x10c2) @@ -6579,7 +6586,7 @@ ;; - Types (deftype joint (basic) - ((name basic :offset-assert 4) + ((name string :offset-assert 4) (number int32 :offset-assert 8) (parent joint :offset-assert 12) (bind-pose matrix :inline :offset-assert 16) @@ -11422,8 +11429,8 @@ (up uint8 :offset-assert 136) (nose uint8 :offset-assert 137) (ear uint8 :offset-assert 138) - (shutting-down? basic :offset-assert 140) - (parented-scale? basic :offset 128) + (shutting-down? symbol :offset-assert 140) + (parented-scale? symbol :offset 128) ) :method-count-assert 16 :size-assert #x90 @@ -11436,7 +11443,7 @@ (reset-blend! (_type_) _type_ 12) (set-twist! (_type_ float float float) vector 13) (set-trs! (_type_ vector quaternion vector) none 14) - (shut-down! (_type_) float 15) + (shut-down! (_type_) none 15) ) ) @@ -11467,13 +11474,13 @@ (deftype joint-mod-set-local (basic) ((transform transformq :inline :offset-assert 16) - (set-rotation basic :offset-assert 64) - (set-scale basic :offset-assert 68) - (set-translation basic :offset-assert 72) - (enable basic :offset-assert 76) + (set-rotation symbol :offset-assert 64) + (set-scale symbol :offset-assert 68) + (set-translation symbol :offset-assert 72) + (enable symbol :offset-assert 76) ) (:methods - (new (symbol type process-drawable int basic basic basic) _type_) + (new (symbol type process-drawable int symbol symbol symbol) _type_) ) :method-count-assert 9 :size-assert #x50 diff --git a/game/assets/game_text.gp b/game/assets/game_text.gp index e671bb2ef..9b48590ca 100644 --- a/game/assets/game_text.gp +++ b/game/assets/game_text.gp @@ -6,8 +6,6 @@ (text ;; NOTE : we compile using the fixed v2 encoding because it's what we use. (file "$DECOMP/assets/game_text.txt") ;; this is the decompiler-generated file! - ;; "patch" files so we can fix some errors and perhaps maintain consistency - (file "game/assets/jak1/text/text_patch_ja.gs") ;; add custom files down here (file "game/assets/jak1/text/game_text_en.gs") (file "game/assets/jak1/text/game_text_de.gs") diff --git a/game/assets/jak1/subtitle/game_subtitle_en.gd b/game/assets/jak1/subtitle/game_subtitle_en.gd index b3312ae43..aa78cb1d2 100644 --- a/game/assets/jak1/subtitle/game_subtitle_en.gd +++ b/game/assets/jak1/subtitle/game_subtitle_en.gd @@ -56,7 +56,7 @@ (1329 "SAGE" "TO HAVE A CHANCE AT RETURNING YOU TO YOUR PREVIOUS FORM:") (1431 "SAGE" "GOL ACHERON, THE SAGE.") (1493) - (1496 :offscreen "SAGE" "BUT HE LIVES FAR TO THE NORTH. FAR, FAR TO NORTH.") + (1496 :offscreen "SAGE" "BUT HE LIVES FAR TO THE NORTH. FAR, FAR TO THE NORTH.") (1639 :offscreen "SAGE" "NOBODY HAS SPOKEN TO HIM IN AGES.") (1718 "SAGE" "I WOULD TELEPORT YOU THERE, BUT I CAN'T DO THAT EITHER.") (1831 "SAGE" "NONE OF THE THREE SAGES THAT MAINTAIN THE OTHER TELEPORTER GATES") @@ -918,13 +918,15 @@ ) ("sagevb01" :hint #x288 - (0 "SAGE" "WELL, I SEE THAT YOU TWO HAVE FINALLY DECIDED TO UNBLOCK MY COLLECTORS.") + (0 "SAGE" "WELL, I SEE THAT YOU TWO HAVE FINALLY") + (163 "SAGE" "DECIDED TO UNBLOCK MY COLLECTORS.") (347) - (352 "SAGE" "I WOULD OFFER MY CONGRATULATIONS, BUT YOU HAVE SO MUCH TO DO I WON'T WASTE YOUR TIME.") + (352 "SAGE" "I WOULD OFFER MY CONGRATULATIONS") + (493 "SAGE" "BUT YOU HAVE SO MUCH TO DO I WON'T WASTE YOUR TIME.") (705) (712 "SAGE" "BY THE WAY, IF THINGS DON'T WORK OUT,") (884 "SAGE" "DAXTER COULD ALWAYS GET A JOB CONTROLLING THE VILLAGE RAT PROBLEM.") - (1116 "SAGE" "NYEH HA HA HA HA.") + (1116 "SAGE" "NYEH HA HA HA HA HA.") ) ("sksp0443" :hint #x2af (0 "DAXTER" "PUNCH THOSE POLES UP FROM BELOW!")) @@ -1602,7 +1604,7 @@ ("asstvb20" :hint #x327 (40 "KEIRA" "GOOD FLYING! THOSE LURKERS WERE NO MATCH FOR YOUR ZOOMER!") - (298 "KEIRA" "THAT'S ONE MORE POWER CELL!") + (295 "KEIRA" "THAT'S ONE MORE POWER CELL!") ) ("asstvb21" :hint #x328 @@ -1613,8 +1615,11 @@ ) ("sagevb03" :hint #x36a - (0 "SAGE" "YOU KEEP ON IMPRESSING ME. BUT THEN MAYBE IT'S JUST BECAUSE I'VE GOT LOW EXPECTATIONS.") - (420 "SAGE" "OKAY, YOUR MOMENT OF GLOATING IS OVER. GET ON WITH IT!") + (0 "SAGE" "YOU KEEP ON IMPRESSING ME. BUT THEN MAYBE IT'S JUST BECAUSE") + (226 "SAGE" "I'VE GOT LOW EXPECTATIONS.") + (420 "SAGE" "OKAY, YOUR MOMENT OF GLOATING IS OVER.") + (598) + (613 "SAGE" "GET ON WITH IT!") ) ("sagevb04" :hint #x36b @@ -1792,7 +1797,12 @@ ("sksp0113" :hint #x339 (0 "DAXTER" "THOSE MUST BE THE INFESTED PLANTS OL' LOG-NOGGIN WAS TALKIN' ABOUT.")) ("sksp0114" :hint #x33a (0 "DAXTER" "WE HAVE TO USE GREEN ECO TO CURE THOSE PLANTS.")) ("sksp0115" :hint #x33b (0 "DAXTER" "JAK, DRIVE THROUGH THE GREEN ECO VENT.")) -("sksp0116" :hint #x33c (0 "DAXTER" "THAT'S ONE OF THOSE FLYING LURKERS! HE MIGHT HAVE A POWER CELL!")) + +("sksp0116" :hint #x33c + (0 "DAXTER" "THAT'S ONE OF THOSE FLYING LURKERS!") + (103 "DAXTER" "HE MIGHT HAVE A POWER CELL!") + ) + ("sksp0117" :hint #x33d (0 "DAXTER" "THERE'S THE MOLE HOLE!")) ("sksp0118" :hint #x33e (0 "DAXTER" "NOW, LET'S FLY OVER THE INFECTED PLANTS!")) ("sksp0119" :hint #x33f (0 "DAXTER" "ONE RING DOWN, A BUNCH TO GO!")) @@ -1999,10 +2009,11 @@ (418) (441 "OLD MAN" "HA HA HA HA HA!") (500) - (528 "OLD MAN" "I'D HARDLY CALL IT \"STRUGGLE.\" WOULD YOU, DEAR SISTER?") + (528 "OLD MAN" "I'D HARDLY CALL IT \"STRUGGLE.\"") + (618 "OLD MAN" "WOULD YOU, DEAR SISTER?") (672 "WOMAN" "CERTAINLY NOT. THE RED SAGE GAVE UP WITH SO LITTLE EFFORT.") - (799) - (806 "WOMAN" "NO FUN AT ALL.") + (800) + (805 "WOMAN" "NO FUN AT ALL.") (860) (884 "SAGE" "GOL? IS THAT YOU?") (965) @@ -2021,7 +2032,7 @@ (2212) (2223 "SAGE" "YOU CAN'T CONTROL DARK ECO BY ITSELF! EVEN THE PRECURSORS COULDN'T-") (2357 "MAIA" "UNTIL NOW, WE'VE HAD TO SCRAPE BY WITH WHAT LITTLE DARK ECO") - (2457 "MAIA" "WE COULD FIND NEAR THE SURFACE.") + (2452 "MAIA" "WE COULD FIND NEAR THE SURFACE.") (2508) (2520 "MAIA" "BUT SOON, WE WILL HAVE ACCESS TO THE VAST STORES") (2611 "MAIA" "OF DARK ECO HIDDEN DEEP UNDERGROUND.") @@ -2031,9 +2042,10 @@ (2841 "GOL" "THEY WILL BE OPENED, AND ALL THE DARK ECO IN THE WORLD WILL BE OURS!") (3028) (3034 "SAGE" "BUT THAT'S IMPOSSIBLE! ONLY A PRECURSOR ROBOT-") - (3128 "MAIA" "OH, DON'T LOOK SO UPSET, SAMOS. WE'VE GOT BIG PLANS FOR YOU.") + (3128 "MAIA" "OH, DON'T LOOK SO UPSET, SAMOS.") + (3210 "MAIA" "WE'VE GOT BIG PLANS FOR YOU.") (3300) - (3303 :offscreen "MAIA" "AH HA HA HA HA HA HA! AH...") + (3303 :offscreen "MAIA" "AH HA HA HA HA HA HA! AHH...") (3460) (3495 "DAXTER" "WAIT A MINUTE!") (3538) @@ -2050,7 +2062,8 @@ (3995 "SAGE" "TWIST AND DESTROY EVERYTHING IT TOUCHES!") (4080 "SAGE" "WE SIMPLY MUST GET TO THEIR CITADEL, TO STOP THEM!") (4189) - (4192 "KEIRA" "THE FASTEST WAY THERE IS THROUGH THE LAVA TUBE AT THE BOTTOM OF THIS CRATER.") + (4192 "KEIRA" "THE FASTEST WAY THERE IS THROUGH THE LAVA TUBE") + (4276 "KEIRA" "AT THE BOTTOM OF THIS CRATER.") (4316) (4324 "KEIRA" "A FEW MORE POWER CELLS, AND YOUR ZOOMER'S HEAT SHIELD") (4398 "KEIRA" "SHOULD GET YOU ACROSS THE LAVA SAFELY.") @@ -2087,8 +2100,8 @@ (158 :offscreen "SAGE" "APPARENTLY THEY'VE DISCOVERED, AND ARE NOW TRYING TO REMOVE,") (270 :offscreen "SAGE" "SOME DARK ECO STORES FROZEN IN THE GLACIERS.") (378) - (381 "SAGE" "WHILE YOU'RE UP THERE POKING AROUND FOR POWER CELLS, STOP THOSE LURKERS,") - (537 "SAGE" "AND KEEP A LITTLE MORE DARK ECO OUT OF GOL'S HANDS.") + (381 "SAGE" "WHILE YOU'RE UP THERE POKING AROUND FOR POWER CELLS") + (490 "SAGE" "STOP THOSE LURKERS, AND KEEP A LITTLE MORE DARK ECO OUT OF GOL'S HANDS.") (660) ) diff --git a/game/assets/jak1/text/game_text_en.gs b/game/assets/jak1/text/game_text_en.gs index 40a036461..063361e54 100644 --- a/game/assets/jak1/text/game_text_en.gs +++ b/game/assets/jak1/text/game_text_en.gs @@ -167,8 +167,8 @@ "CHEATS") (#x1081 "SECRETS" "SECRETS") -(#x1082 "SELECT LEVEL" - "SELECT LEVEL") +(#x1082 "SELECT TRACK" + "SELECT TRACK") (#x1083 "SELECT FLAVOR" "SELECT FLAVOUR") (#x1084 "FINAL BOSS" @@ -204,6 +204,20 @@ "REACH 100% COMPLETION") (#x1099 "BEAT THE GAME" "BEAT THE GAME") +(#x109a "BIG HEAD JAK" + "BIG HEAD JAK") +(#x109b "SMALL HEAD JAK" + "SMALL HEAD JAK") +(#x109c "BIG FIST JAK" + "BIG FIST JAK") +(#x109d "BIG HEAD CHARACTERS" + "BIG HEAD CHARACTERS") +(#x109e "NO TEXTURES MODE" + "NO TEXTURES MODE") +(#x109f "MIRRORED WORLD" + "MIRRORED WORLD") +(#x10a0 "HUGE HEAD JAK" + "HUGE HEAD JAK") (#x10c0 "MUSIC PLAYER" "MUSIC PLAYER") @@ -343,7 +357,7 @@ "NORSK") ;; ----------------- -;; test +;; test (DO NOT TRANSLATE) (#x7fff "ARMOR" diff --git a/game/assets/jak1/text/game_text_ja.gs b/game/assets/jak1/text/game_text_ja.gs index 358e76b16..3c3acae46 100644 --- a/game/assets/jak1/text/game_text_ja.gs +++ b/game/assets/jak1/text/game_text_ja.gs @@ -12,9 +12,9 @@ (#x107f "ヒントロッグ") (#x1080 "チート") (#x1081 "シークレット") -(#x1082 "レベルをセレクトください") +(#x1082 "きょくをセレクトください") (#x1083 "へんかをセレクトください") -(#x1084 "ラスボス") +(#x1084 "チューンドプリカーソルロボット") (#x1085 "スタッフロール") (#x1086 "?????") (#x1087 "ハイブリッドラーカー クロウ") @@ -68,8 +68,8 @@ (#x1101 "赤の賢者") (#x1102 "青の賢者") (#x1103 "城のハブ") -(#x1104 "ラスボスの中かん") -(#x1105 "ラスボスのけつまつ") +(#x1104 "プリカーソルロボットの中かん") +(#x1105 "プリカーソルロボットのけつまつ") diff --git a/game/assets/jak1/text/text_patch_ja.gs b/game/assets/jak1/text/text_patch_ja.gs deleted file mode 100644 index f09aae93f..000000000 --- a/game/assets/jak1/text/text_patch_ja.gs +++ /dev/null @@ -1,10 +0,0 @@ -(group-name "common") -(language-id 5) -(text-version jak1-v2) - -;; ----------------- -;; fixes - - ; 闇の眷者 ゴルとマイアの城 -(#x122 "闇の賢者 ゴルとマイアの城") -(#x801 "闇の賢者 ゴルとマイアの城") diff --git a/game/graphics/gfx.h b/game/graphics/gfx.h index 5d61f7806..4ec8f72ce 100644 --- a/game/graphics/gfx.h +++ b/game/graphics/gfx.h @@ -90,10 +90,6 @@ struct GfxGlobalSettings { int lod_tfrag = 0; int lod_tie = 0; - // collision renderer settings - bool collision_enable = false; - bool collision_wireframe = true; - // vsync enable bool vsync = true; bool old_vsync = false; @@ -102,9 +98,17 @@ struct GfxGlobalSettings { // use custom frame limiter bool framelimiter = true; + // frame timing things bool experimental_accurate_lag = false; bool sleep_in_frame_limiter = true; + // fancy effect things + bool hack_no_tex = false; + + // collision renderer settings + bool collision_enable = false; + bool collision_wireframe = true; + // matching enum in kernel-defs.gc !! enum CollisionRendererMode { None, Mode, Event, Material, Skip } collision_mode = Mode; std::array collision_mode_mask = {UINT32_MAX}; diff --git a/game/graphics/opengl_renderer/OpenGLRenderer.cpp b/game/graphics/opengl_renderer/OpenGLRenderer.cpp index d1119571c..5fe616472 100644 --- a/game/graphics/opengl_renderer/OpenGLRenderer.cpp +++ b/game/graphics/opengl_renderer/OpenGLRenderer.cpp @@ -614,8 +614,8 @@ void OpenGLRenderer::setup_frame(const RenderOptions& settings) { if (m_render_state.draw_region_w <= 0 || m_render_state.draw_region_h <= 0) { // trying to draw to 0 size region... opengl doesn't like this. - m_render_state.draw_region_w = 640; - m_render_state.draw_region_h = 480; + m_render_state.draw_region_w = 320; + m_render_state.draw_region_h = 240; } if (m_fbo_state.render_fbo->is_window) { diff --git a/game/graphics/opengl_renderer/Shader.cpp b/game/graphics/opengl_renderer/Shader.cpp index 044429994..9c1990e6f 100644 --- a/game/graphics/opengl_renderer/Shader.cpp +++ b/game/graphics/opengl_renderer/Shader.cpp @@ -61,7 +61,7 @@ Shader::Shader(const std::string& shader_name) { m_is_okay = true; } -void Shader::activate() { +void Shader::activate() const { ASSERT(m_is_okay); glUseProgram(m_program); } @@ -93,6 +93,6 @@ ShaderLibrary::ShaderLibrary() { at(ShaderId::DEPTH_CUE) = {"depth_cue"}; for (auto& shader : m_shaders) { - ASSERT_MSG(shader.okay(), "Shader compiled"); + ASSERT_MSG(shader.okay(), "error compiling shader"); } } diff --git a/game/graphics/opengl_renderer/Shader.h b/game/graphics/opengl_renderer/Shader.h index 7e1fdbeda..f48f62966 100644 --- a/game/graphics/opengl_renderer/Shader.h +++ b/game/graphics/opengl_renderer/Shader.h @@ -9,7 +9,7 @@ class Shader { static constexpr char shader_folder[] = "game/graphics/opengl_renderer/shaders/"; Shader(const std::string& shader_name); Shader() = default; - void activate(); + void activate() const; bool okay() const { return m_is_okay; } u64 id() const { return m_program; } diff --git a/game/graphics/opengl_renderer/background/background_common.cpp b/game/graphics/opengl_renderer/background/background_common.cpp index 02a983c1a..168badf27 100644 --- a/game/graphics/opengl_renderer/background/background_common.cpp +++ b/game/graphics/opengl_renderer/background/background_common.cpp @@ -149,17 +149,18 @@ DoubleDraw setup_tfrag_shader(SharedRenderState* render_state, DrawMode mode, Sh void first_tfrag_draw_setup(const TfragRenderSettings& settings, SharedRenderState* render_state, ShaderId shader) { - render_state->shaders[shader].activate(); - auto shid = render_state->shaders[shader].id(); - glUniform1i(glGetUniformLocation(shid, "tex_T0"), 0); - glUniformMatrix4fv(glGetUniformLocation(shid, "camera"), 1, GL_FALSE, - settings.math_camera.data()); - glUniform4f(glGetUniformLocation(shid, "hvdf_offset"), settings.hvdf_offset[0], + const auto& sh = render_state->shaders[shader]; + sh.activate(); + auto id = sh.id(); + glUniform1i(glGetUniformLocation(id, "gfx_hack_no_tex"), Gfx::g_global_settings.hack_no_tex); + glUniform1i(glGetUniformLocation(id, "tex_T0"), 0); + glUniformMatrix4fv(glGetUniformLocation(id, "camera"), 1, GL_FALSE, settings.math_camera.data()); + glUniform4f(glGetUniformLocation(id, "hvdf_offset"), settings.hvdf_offset[0], settings.hvdf_offset[1], settings.hvdf_offset[2], settings.hvdf_offset[3]); - glUniform1f(glGetUniformLocation(shid, "fog_constant"), settings.fog.x()); - glUniform1f(glGetUniformLocation(shid, "fog_min"), settings.fog.y()); - glUniform1f(glGetUniformLocation(shid, "fog_max"), settings.fog.z()); - glUniform4f(glGetUniformLocation(shid, "fog_color"), render_state->fog_color[0] / 255.f, + glUniform1f(glGetUniformLocation(id, "fog_constant"), settings.fog.x()); + glUniform1f(glGetUniformLocation(id, "fog_min"), settings.fog.y()); + glUniform1f(glGetUniformLocation(id, "fog_max"), settings.fog.z()); + glUniform4f(glGetUniformLocation(id, "fog_color"), render_state->fog_color[0] / 255.f, render_state->fog_color[1] / 255.f, render_state->fog_color[2] / 255.f, render_state->fog_intensity / 255); } diff --git a/game/graphics/opengl_renderer/foreground/Generic2.h b/game/graphics/opengl_renderer/foreground/Generic2.h index 59a747150..76e1d5da3 100644 --- a/game/graphics/opengl_renderer/foreground/Generic2.h +++ b/game/graphics/opengl_renderer/foreground/Generic2.h @@ -198,5 +198,6 @@ class Generic2 : public BucketRenderer { GLuint index_buffer; GLuint alpha_reject, color_mult, fog_color, scale, mat_23, mat_32, mat_33, fog_consts, hvdf_offset; + GLuint gfx_hack_no_tex; } m_ogl; }; diff --git a/game/graphics/opengl_renderer/foreground/Generic2_OpenGL.cpp b/game/graphics/opengl_renderer/foreground/Generic2_OpenGL.cpp index 21382011f..e76a39868 100644 --- a/game/graphics/opengl_renderer/foreground/Generic2_OpenGL.cpp +++ b/game/graphics/opengl_renderer/foreground/Generic2_OpenGL.cpp @@ -63,17 +63,21 @@ void Generic2::opengl_cleanup() { } void Generic2::init_shaders(ShaderLibrary& shaders) { - shaders[ShaderId::GENERIC].activate(); - m_ogl.alpha_reject = glGetUniformLocation(shaders[ShaderId::GENERIC].id(), "alpha_reject"); - m_ogl.color_mult = glGetUniformLocation(shaders[ShaderId::GENERIC].id(), "color_mult"); - m_ogl.fog_color = glGetUniformLocation(shaders[ShaderId::GENERIC].id(), "fog_color"); + const auto& shader = shaders[ShaderId::GENERIC]; + auto id = shader.id(); - m_ogl.scale = glGetUniformLocation(shaders[ShaderId::GENERIC].id(), "scale"); - m_ogl.mat_23 = glGetUniformLocation(shaders[ShaderId::GENERIC].id(), "mat_23"); - m_ogl.mat_32 = glGetUniformLocation(shaders[ShaderId::GENERIC].id(), "mat_32"); - m_ogl.mat_33 = glGetUniformLocation(shaders[ShaderId::GENERIC].id(), "mat_33"); - m_ogl.fog_consts = glGetUniformLocation(shaders[ShaderId::GENERIC].id(), "fog_constants"); - m_ogl.hvdf_offset = glGetUniformLocation(shaders[ShaderId::GENERIC].id(), "hvdf_offset"); + shader.activate(); + m_ogl.alpha_reject = glGetUniformLocation(id, "alpha_reject"); + m_ogl.color_mult = glGetUniformLocation(id, "color_mult"); + m_ogl.fog_color = glGetUniformLocation(id, "fog_color"); + + m_ogl.scale = glGetUniformLocation(id, "scale"); + m_ogl.mat_23 = glGetUniformLocation(id, "mat_23"); + m_ogl.mat_32 = glGetUniformLocation(id, "mat_32"); + m_ogl.mat_33 = glGetUniformLocation(id, "mat_33"); + m_ogl.fog_consts = glGetUniformLocation(id, "fog_constants"); + m_ogl.hvdf_offset = glGetUniformLocation(id, "hvdf_offset"); + m_ogl.gfx_hack_no_tex = glGetUniformLocation(id, "gfx_hack_no_tex"); } void Generic2::opengl_bind_and_setup_proj(SharedRenderState* render_state) { @@ -90,6 +94,7 @@ void Generic2::opengl_bind_and_setup_proj(SharedRenderState* render_state) { m_drawing_config.fog_max); glUniform4f(m_ogl.hvdf_offset, m_drawing_config.hvdf_offset[0], m_drawing_config.hvdf_offset[1], m_drawing_config.hvdf_offset[2], m_drawing_config.hvdf_offset[3]); + glUniform1i(m_ogl.gfx_hack_no_tex, Gfx::g_global_settings.hack_no_tex); } void Generic2::setup_opengl_for_draw_mode(const DrawMode& draw_mode, @@ -317,6 +322,7 @@ void Generic2::do_draws(SharedRenderState* render_state, ScopedProfilerNode& pro glUniform1f(m_ogl.mat_23, m_drawing_config.hud_mat_23); glUniform1f(m_ogl.mat_32, m_drawing_config.hud_mat_32); glUniform1f(m_ogl.mat_33, m_drawing_config.hud_mat_33); + glUniform1i(m_ogl.gfx_hack_no_tex, false); do_hud_draws(render_state, prof); } diff --git a/game/graphics/opengl_renderer/foreground/Merc2.cpp b/game/graphics/opengl_renderer/foreground/Merc2.cpp index 3ba76b632..0af7fc6a7 100644 --- a/game/graphics/opengl_renderer/foreground/Merc2.cpp +++ b/game/graphics/opengl_renderer/foreground/Merc2.cpp @@ -73,6 +73,7 @@ void Merc2::init_for_frame(SharedRenderState* render_state) { glUniform4f(m_uniforms.fog_color, render_state->fog_color[0] / 255.f, render_state->fog_color[1] / 255.f, render_state->fog_color[2] / 255.f, render_state->fog_intensity / 255); + glUniform1i(m_uniforms.gfx_hack_no_tex, Gfx::g_global_settings.hack_no_tex); } void Merc2::draw_debug_window() { @@ -86,28 +87,31 @@ void Merc2::draw_debug_window() { } void Merc2::init_shaders(ShaderLibrary& shaders) { + const auto& shader = shaders[ShaderId::MERC2]; + auto id = shader.id(); shaders[ShaderId::MERC2].activate(); - m_uniforms.light_direction[0] = glGetUniformLocation(shaders[ShaderId::MERC2].id(), "light_dir0"); - m_uniforms.light_direction[1] = glGetUniformLocation(shaders[ShaderId::MERC2].id(), "light_dir1"); - m_uniforms.light_direction[2] = glGetUniformLocation(shaders[ShaderId::MERC2].id(), "light_dir2"); - m_uniforms.light_color[0] = glGetUniformLocation(shaders[ShaderId::MERC2].id(), "light_col0"); - m_uniforms.light_color[1] = glGetUniformLocation(shaders[ShaderId::MERC2].id(), "light_col1"); - m_uniforms.light_color[2] = glGetUniformLocation(shaders[ShaderId::MERC2].id(), "light_col2"); - m_uniforms.light_ambient = glGetUniformLocation(shaders[ShaderId::MERC2].id(), "light_ambient"); + m_uniforms.light_direction[0] = glGetUniformLocation(id, "light_dir0"); + m_uniforms.light_direction[1] = glGetUniformLocation(id, "light_dir1"); + m_uniforms.light_direction[2] = glGetUniformLocation(id, "light_dir2"); + m_uniforms.light_color[0] = glGetUniformLocation(id, "light_col0"); + m_uniforms.light_color[1] = glGetUniformLocation(id, "light_col1"); + m_uniforms.light_color[2] = glGetUniformLocation(id, "light_col2"); + m_uniforms.light_ambient = glGetUniformLocation(id, "light_ambient"); - m_uniforms.hvdf_offset = glGetUniformLocation(shaders[ShaderId::MERC2].id(), "hvdf_offset"); - m_uniforms.perspective[0] = glGetUniformLocation(shaders[ShaderId::MERC2].id(), "perspective0"); - m_uniforms.perspective[1] = glGetUniformLocation(shaders[ShaderId::MERC2].id(), "perspective1"); - m_uniforms.perspective[2] = glGetUniformLocation(shaders[ShaderId::MERC2].id(), "perspective2"); - m_uniforms.perspective[3] = glGetUniformLocation(shaders[ShaderId::MERC2].id(), "perspective3"); + m_uniforms.hvdf_offset = glGetUniformLocation(id, "hvdf_offset"); + m_uniforms.perspective[0] = glGetUniformLocation(id, "perspective0"); + m_uniforms.perspective[1] = glGetUniformLocation(id, "perspective1"); + m_uniforms.perspective[2] = glGetUniformLocation(id, "perspective2"); + m_uniforms.perspective[3] = glGetUniformLocation(id, "perspective3"); - m_uniforms.fog = glGetUniformLocation(shaders[ShaderId::MERC2].id(), "fog_constants"); - m_uniforms.decal = glGetUniformLocation(shaders[ShaderId::MERC2].id(), "decal_enable"); + m_uniforms.fog = glGetUniformLocation(id, "fog_constants"); + m_uniforms.decal = glGetUniformLocation(id, "decal_enable"); - m_uniforms.fog_color = glGetUniformLocation(shaders[ShaderId::MERC2].id(), "fog_color"); - m_uniforms.perspective_matrix = - glGetUniformLocation(shaders[ShaderId::MERC2].id(), "perspective_matrix"); - m_uniforms.ignore_alpha = glGetUniformLocation(shaders[ShaderId::MERC2].id(), "ignore_alpha"); + m_uniforms.fog_color = glGetUniformLocation(id, "fog_color"); + m_uniforms.perspective_matrix = glGetUniformLocation(id, "perspective_matrix"); + m_uniforms.ignore_alpha = glGetUniformLocation(id, "ignore_alpha"); + + m_uniforms.gfx_hack_no_tex = glGetUniformLocation(id, "gfx_hack_no_tex"); } /*! diff --git a/game/graphics/opengl_renderer/foreground/Merc2.h b/game/graphics/opengl_renderer/foreground/Merc2.h index 27f926543..8b1dbeb09 100644 --- a/game/graphics/opengl_renderer/foreground/Merc2.h +++ b/game/graphics/opengl_renderer/foreground/Merc2.h @@ -98,6 +98,8 @@ class Merc2 : public BucketRenderer { GLuint ignore_alpha; GLuint decal; + + GLuint gfx_hack_no_tex; } m_uniforms; GLuint m_vao; diff --git a/game/graphics/opengl_renderer/shaders/generic.frag b/game/graphics/opengl_renderer/shaders/generic.frag index 8642942de..8fc81f16d 100644 --- a/game/graphics/opengl_renderer/shaders/generic.frag +++ b/game/graphics/opengl_renderer/shaders/generic.frag @@ -12,6 +12,8 @@ in vec4 fragment_color; in flat uvec2 tex_info; +uniform int gfx_hack_no_tex; + layout (binding = 0) uniform sampler2D tex_T0; layout (binding = 1) uniform sampler2D tex_T1; layout (binding = 2) uniform sampler2D tex_T2; @@ -42,32 +44,56 @@ vec4 sample_tex(vec2 coord, uint unit) { } void main() { - vec4 T0 = sample_tex(tex_coord.xy, tex_info.x); - // y is tcc - // z is decal + // 0x1 is tcc + // 0x2 is decal + // 0x4 is fog - if ((tex_info.y & 1u) == 0) { - if ((tex_info.y & 2u) == 0) { - // modulate + no tcc - color.xyz = fragment_color.xyz * T0.xyz; - color.w = fragment_color.w; - } else { - // decal + no tcc - color.xyz = T0.xyz * 0.5; - color.w = fragment_color.w; - } + if (gfx_hack_no_tex == 0) { + vec4 T0 = sample_tex(tex_coord.xy, tex_info.x); + if ((tex_info.y & 1u) == 0) { + if ((tex_info.y & 2u) == 0) { + // modulate + no tcc + color.rgb = fragment_color.rgb * T0.rgb; + color.a = fragment_color.a; + } else { + // decal + no tcc + color.rgb = T0.rgb * 0.5; + color.a = fragment_color.a; + } + } else { + if ((tex_info.y & 2u) == 0) { + // modulate + tcc + color = fragment_color * T0; + } else { + // decal + tcc + color.rgb = T0.rgb * 0.5; + color.a = T0.a; + } + } + color *= 2; } else { - if ((tex_info.y & 2u) == 0) { - // modulate + tcc - color = fragment_color * T0; - } else { - // decal + tcc - color.xyz = T0.xyz * 0.5; - color.w = T0.w; - } + if ((tex_info.y & 1u) == 0) { + if ((tex_info.y & 2u) == 0) { + // modulate + no tcc + color.rgb = fragment_color.rgb; + color.a = fragment_color.a * 2; + } else { + // decal + no tcc + color.rgb = vec3(1); + color.a = fragment_color.a * 2; + } + } else { + if ((tex_info.y & 2u) == 0) { + // modulate + tcc + color = fragment_color; + } else { + // decal + tcc + color.rgb = vec3(0.5); + color.a = 1.0; + } + } } - color *= 2; - color.xyz *= color_mult; + color.rgb *= color_mult; if (color.a < alpha_reject) { discard; diff --git a/game/graphics/opengl_renderer/shaders/merc2.frag b/game/graphics/opengl_renderer/shaders/merc2.frag index ab461cbba..1a261ae13 100644 --- a/game/graphics/opengl_renderer/shaders/merc2.frag +++ b/game/graphics/opengl_renderer/shaders/merc2.frag @@ -13,17 +13,23 @@ uniform int ignore_alpha; uniform int decal_enable; +uniform int gfx_hack_no_tex; void main() { - vec4 T0 = texture(tex_T0, vtx_st); + if (gfx_hack_no_tex == 0) { + vec4 T0 = texture(tex_T0, vtx_st); - if (decal_enable == 0) { - color.xyz = vtx_color * T0.xyz; + if (decal_enable == 0) { + color.rgb = vtx_color * T0.rgb; + } else { + color.rgb = T0.rgb * 0.5; + } + color.a = T0.a; + color *= 2; } else { - color.xyz = T0.xyz * 0.5; + color.rgb = vtx_color; + color.a = 1; } - color.w = T0.w; - color *= 2; if (ignore_alpha == 0 && color.w < 0.128) { diff --git a/game/graphics/opengl_renderer/shaders/shrub.frag b/game/graphics/opengl_renderer/shaders/shrub.frag index aafd4e9e6..3fda31011 100644 --- a/game/graphics/opengl_renderer/shaders/shrub.frag +++ b/game/graphics/opengl_renderer/shaders/shrub.frag @@ -11,9 +11,15 @@ uniform float alpha_min; uniform float alpha_max; uniform vec4 fog_color; +uniform int gfx_hack_no_tex; + void main() { - vec4 T0 = texture(tex_T0, tex_coord.xy / 4096.f); - color = fragment_color * T0; + if (gfx_hack_no_tex == 0) { + vec4 T0 = texture(tex_T0, tex_coord.xy); + color = fragment_color * T0; + } else { + color = fragment_color; + } if (color.a < alpha_min || color.a > alpha_max) { discard; diff --git a/game/graphics/opengl_renderer/shaders/shrub.vert b/game/graphics/opengl_renderer/shaders/shrub.vert index b84897eda..368fdf08b 100644 --- a/game/graphics/opengl_renderer/shaders/shrub.vert +++ b/game/graphics/opengl_renderer/shaders/shrub.vert @@ -75,4 +75,5 @@ void main() { fragment_color.a *= 2; tex_coord = tex_coord_in; + tex_coord.xy /= 4096; } diff --git a/game/graphics/opengl_renderer/shaders/tfrag3.frag b/game/graphics/opengl_renderer/shaders/tfrag3.frag index 379482da8..a0e25d8c5 100644 --- a/game/graphics/opengl_renderer/shaders/tfrag3.frag +++ b/game/graphics/opengl_renderer/shaders/tfrag3.frag @@ -11,10 +11,16 @@ uniform float alpha_min; uniform float alpha_max; uniform vec4 fog_color; +uniform int gfx_hack_no_tex; + void main() { - //vec4 T0 = texture(tex_T0, tex_coord); - vec4 T0 = texture(tex_T0, tex_coord.xy); - color = fragment_color * T0; + if (gfx_hack_no_tex == 0) { + //vec4 T0 = texture(tex_T0, tex_coord); + vec4 T0 = texture(tex_T0, tex_coord.xy); + color = fragment_color * T0; + } else { + color = fragment_color/2; + } if (color.a < alpha_min || color.a > alpha_max) { discard; diff --git a/game/kernel/common/kmachine.cpp b/game/kernel/common/kmachine.cpp index 83a8da9a8..e665602ec 100644 --- a/game/kernel/common/kmachine.cpp +++ b/game/kernel/common/kmachine.cpp @@ -461,6 +461,14 @@ u32 get_collision_mask(GfxGlobalSettings::CollisionRendererMode mode, int mask) : s7.offset; } +void set_gfx_hack(u64 which, u32 symptr) { + switch (which) { + case 0: // no tex + Gfx::g_global_settings.hack_no_tex = symptr != s7.offset; + break; + } +} + /*! * PC PORT FUNCTIONS END */ diff --git a/game/kernel/common/kmachine.h b/game/kernel/common/kmachine.h index 1eb1229f7..d84dbeaa8 100644 --- a/game/kernel/common/kmachine.h +++ b/game/kernel/common/kmachine.h @@ -74,5 +74,6 @@ void set_collision(u32 symptr); void set_collision_wireframe(u32 symptr); void set_collision_mask(GfxGlobalSettings::CollisionRendererMode mode, int mask, u32 symptr); u32 get_collision_mask(GfxGlobalSettings::CollisionRendererMode mode, int mask); +void set_gfx_hack(u64 which, u32 symptr); u32 offset_of_s7(); void vif_interrupt_callback(); diff --git a/game/kernel/jak1/kmachine.cpp b/game/kernel/jak1/kmachine.cpp index 019733fce..6bf3c6f78 100644 --- a/game/kernel/jak1/kmachine.cpp +++ b/game/kernel/jak1/kmachine.cpp @@ -639,6 +639,7 @@ void InitMachine_PCPort() { make_function_symbol_from_c("pc-get-collision-mask", (void*)get_collision_mask); make_function_symbol_from_c("pc-set-collision-wireframe", (void*)set_collision_wireframe); make_function_symbol_from_c("pc-set-collision", (void*)set_collision); + make_function_symbol_from_c("pc-set-gfx-hack", (void*)set_gfx_hack); // file related functions make_function_symbol_from_c("pc-filepath-exists?", (void*)filepath_exists); diff --git a/goal_src/jak1/dgos/engine.gd b/goal_src/jak1/dgos/engine.gd index bdcb90496..4a0bc6228 100644 --- a/goal_src/jak1/dgos/engine.gd +++ b/goal_src/jak1/dgos/engine.gd @@ -196,6 +196,7 @@ ("game-info.o" "game-info") ("game-save.o" "game-save") ("settings.o" "settings") + ("pc-anim-util.o" "pc-anim-util") ;; added ("pckernel.o" "pckernel") ;; added ("mood-tables.o" "mood-tables") ("mood.o" "mood") diff --git a/goal_src/jak1/dgos/game.gd b/goal_src/jak1/dgos/game.gd index 15c245e5d..3b6b83adf 100644 --- a/goal_src/jak1/dgos/game.gd +++ b/goal_src/jak1/dgos/game.gd @@ -192,6 +192,7 @@ ("game-info.o" "game-info") ("game-save.o" "game-save") ("settings.o" "settings") + ("pc-anim-util.o" "pc-anim-util") ;; added ("pckernel.o" "pckernel") ;; added ("mood-tables.o" "mood-tables") ("mood.o" "mood") diff --git a/goal_src/jak1/engine/anim/joint-mod-h.gc b/goal_src/jak1/engine/anim/joint-mod-h.gc index bf53db9d3..087f10ab5 100644 --- a/goal_src/jak1/engine/anim/joint-mod-h.gc +++ b/goal_src/jak1/engine/anim/joint-mod-h.gc @@ -49,8 +49,8 @@ (up uint8 :offset-assert 136) (nose uint8 :offset-assert 137) (ear uint8 :offset-assert 138) - (shutting-down? basic :offset-assert 140) - (parented-scale? basic :offset 128) + (shutting-down? symbol :offset-assert 140) + (parented-scale? symbol :offset 128) ) :method-count-assert 16 :size-assert #x90 @@ -63,7 +63,7 @@ (reset-blend! (_type_) _type_ 12) (set-twist! (_type_ float float float) vector 13) (set-trs! (_type_ vector quaternion vector) none 14) - (shut-down! (_type_) float 15) + (shut-down! (_type_) none 15) ) ) @@ -161,10 +161,8 @@ (defmethod shut-down! joint-mod ((obj joint-mod)) "Shut down and set the blend to zero." (set! (-> obj shutting-down?) #t) - (let ((f0-0 0.0)) - (set! (-> obj blend) f0-0) - f0-0 - ) + (set! (-> obj blend) 0.0) + (none) ) (defmethod set-twist! joint-mod ((obj joint-mod) (x float) (y float) (z float)) @@ -178,14 +176,14 @@ (defmethod set-trs! joint-mod ((obj joint-mod) (trans vector) (rot quaternion) (scale vector)) "Set the translation, rotation, and scale." (if trans - (set! (-> obj trans quad) (-> trans quad)) - ) + (set! (-> obj trans quad) (-> trans quad)) + ) (if rot - (quaternion-copy! (-> obj quat) rot) - ) + (quaternion-copy! (-> obj quat) rot) + ) (if scale - (set! (-> obj scale quad) (-> scale quad)) - ) + (set! (-> obj scale quad) (-> scale quad)) + ) (none) ) @@ -225,8 +223,8 @@ (defmethod look-at-enemy! joint-mod ((obj joint-mod) (target-trans vector) (option symbol) (proc process)) "Set up animation for Jak looking at an enemy. If option is 'attacking, remember when this happened. - Will only override an existing look-at if this one is closer, or option is 'force. - " + Will only override an existing look-at if this one is closer, or option is 'force." + (when (= option 'attacking) ;; make sure we got a process-drawable (let* ((s3-0 proc) @@ -725,16 +723,16 @@ (deftype joint-mod-set-local (basic) ((transform transformq :inline :offset-assert 16) - (set-rotation basic :offset-assert 64) - (set-scale basic :offset-assert 68) - (set-translation basic :offset-assert 72) - (enable basic :offset-assert 76) + (set-rotation symbol :offset-assert 64) + (set-scale symbol :offset-assert 68) + (set-translation symbol :offset-assert 72) + (enable symbol :offset-assert 76) ) :method-count-assert 9 :size-assert #x50 :flag-assert #x900000050 (:methods - (new (symbol type process-drawable int basic basic basic) _type_ 0) + (new (symbol type process-drawable int symbol symbol symbol) _type_ 0) ) ) @@ -762,7 +760,7 @@ (none) ) -(defmethod new joint-mod-set-local ((allocation symbol) (type-to-make type) (arg0 process-drawable) (arg1 int) (arg2 basic) (arg3 basic) (arg4 basic)) +(defmethod new joint-mod-set-local ((allocation symbol) (type-to-make type) (arg0 process-drawable) (arg1 int) (arg2 symbol) (arg3 symbol) (arg4 symbol)) (let ((v0-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) (set! (-> v0-0 set-translation) arg2) (set! (-> v0-0 set-rotation) arg3) diff --git a/goal_src/jak1/engine/anim/mspace-h.gc b/goal_src/jak1/engine/anim/mspace-h.gc index c9251ee67..3339980db 100644 --- a/goal_src/jak1/engine/anim/mspace-h.gc +++ b/goal_src/jak1/engine/anim/mspace-h.gc @@ -18,7 +18,7 @@ ;; First, the joint. This type just describes how the skeleton is connected and the bind pose. (deftype joint (basic) - ((name basic :offset-assert 4) ;; the joint's name (neckA, neckB, Rtoes, etc) + ((name string :offset-assert 4) ;; the joint's name (neckA, neckB, Rtoes, etc) (number int32 :offset-assert 8) ;; the joint's number in the cspace-array (parent joint :offset-assert 12) ;; the parent joint (ex, Lshould has parent of chest) (bind-pose matrix :inline :offset-assert 16) ;; the bind pose, as a matrix. diff --git a/goal_src/jak1/engine/common-obs/generic-obs.gc b/goal_src/jak1/engine/common-obs/generic-obs.gc index a15a87c52..b9d43ffab 100644 --- a/goal_src/jak1/engine/common-obs/generic-obs.gc +++ b/goal_src/jak1/engine/common-obs/generic-obs.gc @@ -541,6 +541,8 @@ ((nonzero? (-> self skel)) (set! (-> self new-joint-anim) (ja-group)) (set! (-> self anim-mode) 'loop) + (#when PC_PORT + (set! (-> self skel postbind-function) process-drawable-joint-callback-pc)) ) (else (set! (-> self anim-mode) 'still) diff --git a/goal_src/jak1/engine/common-obs/process-drawable.gc b/goal_src/jak1/engine/common-obs/process-drawable.gc index e7edd79d9..3f1492c7e 100644 --- a/goal_src/jak1/engine/common-obs/process-drawable.gc +++ b/goal_src/jak1/engine/common-obs/process-drawable.gc @@ -295,6 +295,11 @@ (define-extern draw-joint-spheres (function process-drawable symbol)) +(#when PC_PORT + +(define *display-bones* #f) +(define *display-joint-names* #f) + (defun-debug draw-bone-lines ((obj process-drawable)) "Added in PC port to debug bones" (dotimes (i (-> obj node-list length)) @@ -307,7 +312,7 @@ ) ) ) - ) + )) (defmethod do-joint-math! process-drawable ((obj process-drawable)) (cond @@ -383,8 +388,14 @@ ) ) ) - ; (draw-bone-lines obj) - ;; (draw-joint-spheres obj) + + (#when PC_PORT + (when *debug-segment* + (if *display-bones* + (draw-bone-lines obj)) + (if *display-joint-names* + (draw-joint-spheres obj)) + )) 0 (none) @@ -404,8 +415,9 @@ (defun draw-joint-spheres ((arg0 process-drawable)) (dotimes (s5-0 (-> arg0 node-list length)) (let ((a2-0 (vector<-cspace! (new-stack-vector0) (-> arg0 node-list data s5-0)))) - (add-debug-sphere #t (bucket-id debug) a2-0 819.2 (new 'static 'rgba :g #xff :a #x40)) - ;;(add-debug-text-sphere #t (bucket-id debug) a2-0 819.2 (the string (-> arg0 node-list data s5-0 joint name)) (new 'static 'rgba :g #xff :a #x40)) + (add-debug-sphere #t (bucket-id debug) a2-0 (meters 0.1) (static-rgba 0 #xff 0 #x40)) + (#when PC_PORT + (add-debug-text-sphere (!= (-> arg0 node-list data s5-0 joint) #f) (bucket-id debug) a2-0 (meters 0.1) (-> arg0 node-list data s5-0 joint name) (static-rgba 0 #xff 0 #x40))) ) ) #f diff --git a/goal_src/jak1/engine/common-obs/process-taskable.gc b/goal_src/jak1/engine/common-obs/process-taskable.gc index 2d7f8bff9..c5b27ed11 100644 --- a/goal_src/jak1/engine/common-obs/process-taskable.gc +++ b/goal_src/jak1/engine/common-obs/process-taskable.gc @@ -1023,6 +1023,8 @@ (initialize-skeleton obj arg1 '()) (set! (-> obj shadow-backup) (-> obj draw shadow)) (logior! (-> obj skel status) (janim-status eye)) + (#when PC_PORT + (set! (-> obj skel postbind-function) process-drawable-joint-callback-pc)) (set! (-> obj root-override pause-adjust-distance) -122880.0) (set! (-> obj fuel-cell-anim) (fuel-cell-pick-anim obj)) (set! (-> obj draw origin-joint-index) (the-as uint arg2)) diff --git a/goal_src/jak1/engine/debug/default-menu.gc b/goal_src/jak1/engine/debug/default-menu.gc index fb1b0008c..57198902d 100644 --- a/goal_src/jak1/engine/debug/default-menu.gc +++ b/goal_src/jak1/engine/debug/default-menu.gc @@ -4599,45 +4599,45 @@ (flag "Blue eco" #f (lambda (arg (msg debug-menu-msg)) (when (= msg (debug-menu-msg press)) (logclear! (-> *pc-settings* cheats) (pc-cheats eco-red eco-yellow eco-green)) - (pc-cheat-toggle-and-tune *pc-settings* eco-blue) + (pc-cheat-toggle-and-tune (-> *pc-settings* cheats) eco-blue) ) (pc-cheats? (-> *pc-settings* cheats) eco-blue))) (flag "Red eco" #f (lambda (arg (msg debug-menu-msg)) (when (= msg (debug-menu-msg press)) (logclear! (-> *pc-settings* cheats) (pc-cheats eco-blue eco-yellow eco-green)) - (pc-cheat-toggle-and-tune *pc-settings* eco-red) + (pc-cheat-toggle-and-tune (-> *pc-settings* cheats) eco-red) ) (pc-cheats? (-> *pc-settings* cheats) eco-red))) (flag "Green eco" #f (lambda (arg (msg debug-menu-msg)) (when (= msg (debug-menu-msg press)) (logclear! (-> *pc-settings* cheats) (pc-cheats eco-red eco-yellow eco-blue)) - (pc-cheat-toggle-and-tune *pc-settings* eco-green) + (pc-cheat-toggle-and-tune (-> *pc-settings* cheats) eco-green) ) (pc-cheats? (-> *pc-settings* cheats) eco-green))) (flag "Yellow eco" #f (lambda (arg (msg debug-menu-msg)) (when (= msg (debug-menu-msg press)) (logclear! (-> *pc-settings* cheats) (pc-cheats eco-red eco-blue eco-green)) - (pc-cheat-toggle-and-tune *pc-settings* eco-yellow) + (pc-cheat-toggle-and-tune (-> *pc-settings* cheats) eco-yellow) ) (pc-cheats? (-> *pc-settings* cheats) eco-yellow))) (flag "Invincibility" #f (lambda (arg (msg debug-menu-msg)) (when (= msg (debug-menu-msg press)) - (pc-cheat-toggle-and-tune *pc-settings* invinc) + (pc-cheat-toggle-and-tune (-> *pc-settings* cheats) invinc) ) (pc-cheats? (-> *pc-settings* cheats) invinc))) (flag "Blue sidekick" #f (lambda (arg (msg debug-menu-msg)) (when (= msg (debug-menu-msg press)) - (pc-cheat-toggle-and-tune *pc-settings* sidekick-blue) + (pc-cheat-toggle-and-tune (-> *pc-settings* cheats) sidekick-blue) ) (pc-cheats? (-> *pc-settings* cheats) sidekick-blue))) (flag "All flavas" #f (lambda (arg (msg debug-menu-msg)) (when (= msg (debug-menu-msg press)) - (pc-cheat-toggle-and-tune *pc-settings* tunes) + (pc-cheat-toggle-and-tune (-> *pc-settings* cheats) tunes) ) (pc-cheats? (-> *pc-settings* cheats) tunes))) (flag "Real time tod" #f (lambda (arg (msg debug-menu-msg)) (when (= msg (debug-menu-msg press)) - (pc-cheat-toggle-and-tune *pc-settings* sky) + (pc-cheat-toggle-and-tune (-> *pc-settings* cheats) sky) ) (pc-cheats? (-> *pc-settings* cheats) sky))) ) @@ -4740,6 +4740,7 @@ (flag "Heap status" #f ,(dm-lambda-boolean-flag (-> *pc-settings* display-heap-status))) (flag "Bug report" #f ,(dm-lambda-boolean-flag (-> *pc-settings* display-bug-report))) (flag "Text boxes" #f ,(dm-lambda-boolean-flag (-> *pc-settings* display-text-box))) + (flag "Sidekick stats" *display-sidekick-stats* dm-boolean-toggle-pick-func) (float-var "Actor birth dist" #f ,(dm-lambda-meters-var (-> *ACTOR-bank* birth-dist)) 20 1 #t 0 10000 1) (float-var "Actor pause dist" #f ,(dm-lambda-meters-var (-> *ACTOR-bank* pause-dist)) 20 1 #t 0 10000 1) (menu "Mood override" @@ -4765,6 +4766,8 @@ (float-fixed-var "Palette 7 Amt" 7 dm-mood-palette-float 0 10 #t 0 1000 3) ) ) + (flag "Joint names" *display-joint-names* dm-boolean-toggle-pick-func) + (flag "Bone lines" *display-bones* dm-boolean-toggle-pick-func) ) )) (other-menu (-> (the-as debug-menu-item-submenu other-menu-node) submenu)) diff --git a/goal_src/jak1/engine/game/main.gc b/goal_src/jak1/engine/game/main.gc index f6b7a16c9..cbb445fc8 100644 --- a/goal_src/jak1/engine/game/main.gc +++ b/goal_src/jak1/engine/game/main.gc @@ -938,8 +938,7 @@ (with-profiler "process-particles" (process-particles)) ;; vif0 collide - ;; swap sound - ;; str play + (with-profiler "sound-update" (swap-sound-buffers (ear-trans) (camera-pos) (camera-angle)) (str-play-kick) diff --git a/goal_src/jak1/engine/gfx/hw/display.gc b/goal_src/jak1/engine/gfx/hw/display.gc index 71763deaf..fca8182c2 100644 --- a/goal_src/jak1/engine/gfx/hw/display.gc +++ b/goal_src/jak1/engine/gfx/hw/display.gc @@ -9,7 +9,9 @@ (defconstant DMA_BUFFER_GLOBAL_SIZE (#if (not PC_PORT) (* 1712 1024) ;; 1712K (* PROCESS_HEAP_MULT 2664 1024))) ;; 2600K x actor heap increase (usually 3x) -(defconstant DMA_BUFFER_DEBUG_SIZE (* 8 1024 1024)) ;; 8M +(defconstant DMA_BUFFER_DEBUG_SIZE (#if (not PC_PORT) + (* 8 1024 1024) ;; 8M + (* 16 1024 1024))) ;; 16M ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; TIME diff --git a/goal_src/jak1/engine/gfx/math-camera.gc b/goal_src/jak1/engine/gfx/math-camera.gc index b7728d28b..11a776eac 100644 --- a/goal_src/jak1/engine/gfx/math-camera.gc +++ b/goal_src/jak1/engine/gfx/math-camera.gc @@ -62,10 +62,8 @@ (set! (-> math-cam y-ratio) (* (1/ ASPECT_4X3) (-> math-cam x-ratio))) (set! (-> math-cam y-ratio) (* (1/ ASPECT_16X9) (-> math-cam x-ratio))) ) - (#when PC_PORT + (with-pc (cond - ((not *pc-settings*) - ) ((-> *pc-settings* use-vis?) ;; using game vis, cannot allow seeing more of the view ;; crops excess aspect ratio at the top and bottom @@ -228,14 +226,17 @@ (set! (-> math-cam guard w) 1.0) (set! (-> math-cam isometric vector 3 z) (- 16777215.0 hvdf-z)) ;; PC HACK! - ;; for whatever reason, the font render ends up computing a depth #x1000000 instead of + ;; for whatever reason, the font renderer ends up computing a depth #x1000000 instead of ;; #xffffffff, which overflows the 24-bit z buffer. ;; cheating this by 1 bit seems to fix it. (#when PC_PORT - ;; #x4b002032 -> #x4b002031 - (set! (-> math-cam isometric vector 3 z) (the-as float (- (the-as int (-> math-cam isometric vector 3 z)) 1))) - ) - + ;; #x4b002032 -> #x4b002031 + (set! (-> math-cam isometric vector 3 z) (the-as float (1- (the-as int (-> math-cam isometric vector 3 z))))) + ;; also do mirror game check here. + (when (pc-cheats? (-> *pc-settings* cheats) mirror) + (*! (-> math-cam perspective vector 0 x) -1.) + ) + ) ) (set! (-> math-cam isometric vector 3 w) fog-slope) diff --git a/goal_src/jak1/engine/gfx/sprite/sprite.gc b/goal_src/jak1/engine/gfx/sprite/sprite.gc index 1195ddbc4..7c0df7a51 100644 --- a/goal_src/jak1/engine/gfx/sprite/sprite.gc +++ b/goal_src/jak1/engine/gfx/sprite/sprite.gc @@ -340,6 +340,9 @@ ;; math camera stuff (set! (-> data basis-x quad) (the-as uint128 0)) (set! (-> data basis-x x) (- (-> *math-camera* perspective vector 0 x))) + (with-pc + (when (pc-cheats? (-> *pc-settings* cheats) mirror) + (*! (-> data basis-x x) -1.0))) (set! (-> data basis-y quad) (the-as uint128 0)) (set! (-> data basis-y y) (- (-> *math-camera* perspective vector 1 y))) (set! (-> data min-scale) (sqrtf (* (/ 1.0 (-> data basis-x x)) (/ 1.0 (-> data basis-y y))))) @@ -551,13 +554,17 @@ (f2-0 (-> *math-camera* perspective vector 1 y)) (f0-1 (* -1.9996 (-> *math-camera* perspective vector 0 x))) ) - (#when PC_PORT - (when (and *pc-settings* (not (-> *pc-settings* use-vis?))) + (with-pc + (when (not (-> *pc-settings* use-vis?)) ;; when the game is in widescreen, HUD sprites are generally enlarged, which looks terrible. ;; this reverts that. (*! f1-0 (-> *pc-settings* aspect-ratio-scale)) (*! f0-1 (-> *pc-settings* aspect-ratio-scale)) ) + (when (pc-cheats? (-> *pc-settings* cheats) mirror) + (*! f1-0 -1.0) + (*! f0-1 -1.0) + ) ) (set-vector! (-> mtx2 vector 0) f0-1 0.0 0.0 0.0) (set-vector! (-> mtx2 vector 1) 0.0 (- (* (/ f2-0 f1-0) f0-1)) 0.0 0.0) diff --git a/goal_src/jak1/engine/math/matrix.gc b/goal_src/jak1/engine/math/matrix.gc index f0908102a..13e38886a 100644 --- a/goal_src/jak1/engine/math/matrix.gc +++ b/goal_src/jak1/engine/math/matrix.gc @@ -607,7 +607,7 @@ (defun scale-matrix! ((dst matrix) (scale vector) (src matrix)) "Scale an existing matrix. Okay for dst = src. The scaling is applied per row. This means the x component of scale is used to scale the first row of src. - The w component of scale is used." + The w component of scale IS USED!!" (rlet ((vf4 :class vf) (vf5 :class vf) (vf6 :class vf) diff --git a/goal_src/jak1/engine/ps2/pad.gc b/goal_src/jak1/engine/ps2/pad.gc index 07f0ff845..ca4372ca1 100644 --- a/goal_src/jak1/engine/ps2/pad.gc +++ b/goal_src/jak1/engine/ps2/pad.gc @@ -316,14 +316,14 @@ (set! (-> pad button0-abs 1) (-> pad button0-shadow-abs 0)) (set! (-> pad button0-rel 2) (-> pad button0-rel 1)) (set! (-> pad button0-rel 1) (-> pad button0-rel 0)) - ;; we might want to clear a button so we back it up in a "shadow" field + ;; we might want to clear a button after it is pressed, so we back it up in a "shadow" field (let ((current-button0 (-> pad button0))) (set! (-> pad button0-shadow-abs 0) (the-as pad-buttons current-button0)) (set! (-> pad button0-abs 0) (the-as pad-buttons current-button0)) ) ;; buttons going down (set! (-> pad button0-rel 0) (logclear (-> pad button0-abs 0) (-> pad button0-abs 1))) - ;; ?? + ;; some debugging thing they wrote at some point (when *cpad-debug* (set! (-> pad leftx) (the-as uint 255)) (set! (-> pad rightx) (the-as uint 255)) @@ -332,8 +332,14 @@ ;; compute a speed and direction for stick0 (set! (-> pad stick0-speed) 1.0) (cond - ;; check if analog is valid? + ;; check if controller is a valid dualshock 2 ((= (shr (-> pad status) 4) 7) + ;; invert analogs if mirrored mode. trust me, you'll need this. + (#when PC_PORT + (when (pc-cheats? (-> *pc-settings* cheats) mirror) + (set! (-> pad leftx) (- 255 (-> pad leftx))) + (set! (-> pad rightx) (- 255 (-> pad rightx))) + )) ;; compute speed and direction, with deadband. (let ((f30-0 (* 0.0078125 (the float (+ (-> pad leftx) -128)))) (f28-0 (* 0.0078125 (the float (- 127 (the-as int (-> pad lefty)))))) diff --git a/goal_src/jak1/engine/sound/gsound.gc b/goal_src/jak1/engine/sound/gsound.gc index 57625ddde..cf5ceee1b 100644 --- a/goal_src/jak1/engine/sound/gsound.gc +++ b/goal_src/jak1/engine/sound/gsound.gc @@ -335,6 +335,13 @@ (sound-trans-convert (-> cmd ear-trans) ear-trans) (sound-trans-convert (-> cmd cam-trans) cam-trans) (set! (-> cmd cam-angle) (sound-angle-convert cam-angle)) + (#when PC_PORT + (when (pc-cheats? (-> *pc-settings* cheats) mirror) + ;; flip sound pan. + ;; this isn't really appropriate if there's front-back panning (surround)... + (+! (-> cmd cam-angle) 180) + ) + ) ) 0 ) diff --git a/goal_src/jak1/engine/ui/text-h.gc b/goal_src/jak1/engine/ui/text-h.gc index 1b650ad45..4a5f613bf 100644 --- a/goal_src/jak1/engine/ui/text-h.gc +++ b/goal_src/jak1/engine/ui/text-h.gc @@ -680,6 +680,13 @@ (cheat-sky #x1097) (cheat-req-100-percent #x1098) (cheat-req-beat-game #x1099) + (cheat-big-head #x109a) + (cheat-small-head #x109b) + (cheat-big-fist #x109c) + (cheat-big-head-npc #x109d) + (cheat-no-tex #x109e) + (cheat-mirror #x109f) + (cheat-huge-head #x10a0) (music-player #x10c0) (scene-player #x10c1) (play-credits #x10c2) diff --git a/goal_src/jak1/game.gp b/goal_src/jak1/game.gp index c32ebe329..d8ef1ef29 100644 --- a/goal_src/jak1/game.gp +++ b/goal_src/jak1/game.gp @@ -2036,7 +2036,8 @@ ;; Custom or Modified Code (goal-src "pc/pckernel-h.gc" "dma-buffer") -(goal-src "pc/pckernel.gc" "settings" "video") +(goal-src "pc/util/pc-anim-util.gc" "target-h") +(goal-src "pc/pckernel.gc" "pc-anim-util" "settings" "video" "target-h") (goal-src "pc/subtitle.gc" "text" "pckernel" "hint-control" "loader-h" "gsound" "ambient") (goal-src "pc/progress-pc.gc" "progress" "pckernel") (goal-src "pc/util/anim-tester-x.gc" "pckernel" "gstring" "joint" "process-drawable" "art-h" "effect-control") diff --git a/goal_src/jak1/kernel-defs.gc b/goal_src/jak1/kernel-defs.gc index d45a355ff..0ff6d8511 100644 --- a/goal_src/jak1/kernel-defs.gc +++ b/goal_src/jak1/kernel-defs.gc @@ -319,6 +319,9 @@ (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)) @@ -361,6 +364,7 @@ (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)) (defenum pc-prof-event (begin 0) diff --git a/goal_src/jak1/pc/pckernel-h.gc b/goal_src/jak1/pc/pckernel-h.gc index 52e67cd4e..2559eab64 100644 --- a/goal_src/jak1/pc/pckernel-h.gc +++ b/goal_src/jak1/pc/pckernel-h.gc @@ -103,7 +103,7 @@ (korean 98) ;; future-proofing here (russian 97) ;; same thing - (custom 500) ;; temp + (custom 100) ;; temp ) @@ -115,6 +115,7 @@ ) ;; cheats +(defconstant PC_CHEAT_MAX 18) ;; number of cheats (defenum pc-cheats :bitfield #t :type uint64 @@ -126,6 +127,16 @@ (sidekick-blue) (tunes) (sky) + (mirror) + (big-head) + (small-head) + (big-fist) + (no-tex) + (hard-rats) + (hero-mode) + (huge-head) + (big-head-npc) + (oh-my-goodness) ) (defmacro pc-cheats? (obj &rest cheats) @@ -531,55 +542,53 @@ ) (seval (define *pc-cheat-map* - '((a (triangle triangle)) - (b (square square)) - (c (circle circle)) - (d (x x)) - (e (right right)) - (f (right up)) - (g (right down)) - (h (left right)) - (i (up right)) - (j (down left)) - (k (square right)) - (l (left down)) - (m (up circle)) - (n (up up)) - (o (circle square)) - (p (down circle)) - (q (dowm square)) - (r (circle x)) - (s (down x)) - (t (triangle square)) - (u (square x)) - (v (x triangle)) - (w (left left)) - (x (up down)) - (y (up x)) - (z (up circle)) + '((#\a (circle triangle)) + (#\b (square x)) + (#\c (circle)) + (#\d (down)) + (#\e (right right)) + ;; #\f + ;; #\g + ;; #\h + (#\i (up)) + ;; #\j + (#\k (circle)) + (#\l (left)) + (#\m (triangle)) + (#\n (up up)) + (#\o (square)) + (#\p (square circle)) + ;; #\q + (#\r (right)) + (#\s (down down)) + (#\t (triangle)) + (#\u (up)) + (#\v (down)) + (#\w (left left)) + (#\x (x)) + (#\y (triangle)) + (#\z (x x)) )) ) -(desfun pc-cheat-encode (letters extra) +(desfun pc-cheat-encode (word extra) "turn a cheat word into input names." - (let ((out '())) + (let ((out '()) + (word-str (symbol->string word))) - (dolist (in letters) - - (let ((buttons (cadr (assoc (car in) *pc-cheat-map*)))) - (dolist (button buttons) - - (set! out (cons (car button) out)) - ) - ) - ) + (dotimes (i (string-length word-str)) + (let ((char-to-inputs (assoc (string-ref word-str i) *pc-cheat-map*))) + (if (null? char-to-inputs) + (ferror "bad input for pc cheat name: {}" (string-ref word-str i)) + (dolist (button (cadr char-to-inputs)) + (set! out (cons (car button) out)) + )) + )) (dolist (ex extra) - - (set! out (cons (car ex) out)) - ) - (reverse out) - ) + (set! out (cons (car ex) out))) + + out) ) (defmacro pc-check-cheat-code (cheat-var pad-idx input &key (extra ()) &rest body) diff --git a/goal_src/jak1/pc/pckernel.gc b/goal_src/jak1/pc/pckernel.gc index 8b61d429d..135f563d6 100644 --- a/goal_src/jak1/pc/pckernel.gc +++ b/goal_src/jak1/pc/pckernel.gc @@ -249,12 +249,15 @@ (none)) -(define *pc-cheat-temp* (the-as (pointer int32) (malloc 'global (* 4 8)))) -(defmacro pc-cheat-toggle-and-tune (obj cheat) +;; 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! (-> ,obj cheats) (pc-cheats ,cheat)) - (cheats-sound-play (logtest? (-> ,obj cheats) (pc-cheats ,cheat))) + (logxor! ,cheats-var (pc-cheats ,cheat)) + (cheats-sound-play (logtest? ,cheats-var (pc-cheats ,cheat))) ) ) @@ -369,38 +372,49 @@ (defmethod update-cheats pc-settings ((obj pc-settings)) "run cheats." + ;; first check for cheat inputs. (when (and (cpad-hold? 0 l2) (cpad-hold? 0 l1) (cpad-hold? 0 r2) (cpad-hold? 0 r1)) - (pc-check-cheat-code (-> *pc-cheat-temp* 0) 0 (s p i r i t) :extra (x) + (pc-check-cheat-code (-> *pc-cheat-temp* 0) 0 spirit :extra (x) (logclear! (-> obj cheats) (pc-cheats eco-red eco-yellow eco-green)) - (pc-cheat-toggle-and-tune obj eco-blue)) + (pc-cheat-toggle-and-tune (-> obj cheats) eco-blue)) - (pc-check-cheat-code (-> *pc-cheat-temp* 1) 0 (s p i r i t) :extra (circle) + (pc-check-cheat-code (-> *pc-cheat-temp* 1) 0 spirit :extra (circle) (logclear! (-> obj cheats) (pc-cheats eco-blue eco-yellow eco-green)) - (pc-cheat-toggle-and-tune obj eco-red)) + (pc-cheat-toggle-and-tune (-> obj cheats) eco-red)) - (pc-check-cheat-code (-> *pc-cheat-temp* 2) 0 (s p i r i t) :extra (triangle) + (pc-check-cheat-code (-> *pc-cheat-temp* 2) 0 spirit :extra (triangle) (logclear! (-> obj cheats) (pc-cheats eco-red eco-yellow eco-blue)) - (pc-cheat-toggle-and-tune obj eco-green)) + (pc-cheat-toggle-and-tune (-> obj cheats) eco-green)) - (pc-check-cheat-code (-> *pc-cheat-temp* 3) 0 (s p i r i t) :extra (square) + (pc-check-cheat-code (-> *pc-cheat-temp* 3) 0 spirit :extra (square) (logclear! (-> obj cheats) (pc-cheats eco-red eco-blue eco-green)) - (pc-cheat-toggle-and-tune obj eco-yellow)) + (pc-cheat-toggle-and-tune (-> obj cheats) eco-yellow)) - (pc-check-cheat-code (-> *pc-cheat-temp* 4) 0 (s t e e l) + (pc-check-cheat-code (-> *pc-cheat-temp* 4) 0 undead (logclear! (-> *target* state-flags) 16) - (pc-cheat-toggle-and-tune obj invinc)) + (pc-cheat-toggle-and-tune (-> obj cheats) invinc)) - (pc-check-cheat-code (-> *pc-cheat-temp* 5) 0 (l e a d s) - (pc-cheat-toggle-and-tune obj sidekick-blue)) - - (pc-check-cheat-code (-> *pc-cheat-temp* 6) 0 (t u n e s) - (pc-cheat-toggle-and-tune obj tunes)) - - (pc-check-cheat-code (-> *pc-cheat-temp* 7) 0 (s k y) - (pc-cheat-toggle-and-tune obj sky)) + (pc-check-cheat-code (-> *pc-cheat-temp* 5) 0 bluemoon (pc-cheat-toggle-and-tune (-> obj cheats) sidekick-blue)) + (pc-check-cheat-code (-> *pc-cheat-temp* 6) 0 boombox (pc-cheat-toggle-and-tune (-> obj cheats) tunes)) + (pc-check-cheat-code (-> *pc-cheat-temp* 7) 0 skies (pc-cheat-toggle-and-tune (-> obj cheats) sky)) + (pc-check-cheat-code (-> *pc-cheat-temp* 8) 0 speclum (pc-cheat-toggle-and-tune (-> obj cheats) mirror)) + (pc-check-cheat-code (-> *pc-cheat-temp* 9) 0 brains (pc-cheat-toggle-and-tune (-> obj cheats) big-head)) + (pc-check-cheat-code (-> *pc-cheat-temp* 10) 0 driedup (pc-cheat-toggle-and-tune (-> obj cheats) small-head)) + (pc-check-cheat-code (-> *pc-cheat-temp* 11) 0 yourpalm (pc-cheat-toggle-and-tune (-> obj cheats) big-fist)) + (pc-check-cheat-code (-> *pc-cheat-temp* 12) 0 bakeonly (pc-cheat-toggle-and-tune (-> obj cheats) no-tex)) + ;(pc-check-cheat-code (-> *pc-cheat-temp* 13) 0 rodent (pc-cheat-toggle-and-tune (-> obj cheats) hard-rats)) + ;(pc-check-cheat-code (-> *pc-cheat-temp* 14) 0 lunatic (pc-cheat-toggle-and-tune (-> obj cheats) hero-mode)) + (pc-check-cheat-code (-> *pc-cheat-temp* 15) 0 plzstop (pc-cheat-toggle-and-tune (-> obj cheats) huge-head)) + (pc-check-cheat-code (-> *pc-cheat-temp* 16) 0 evilbabe (pc-cheat-toggle-and-tune (-> obj cheats) oh-my-goodness)) + (pc-check-cheat-code (-> *pc-cheat-temp* 17) 0 smart (pc-cheat-toggle-and-tune (-> obj cheats) big-head-npc)) ) + ;; run cheats here. + ;;;;;;;;;;;;;;;;;;; (when *target* + ;; hook custom animation callback + (if (nonzero? (-> *target* skel)) + (set! (-> *target* skel postbind-function) target-joint-callback-pc)) (with-pp (protect ((-> *target* fact-info-target eco-source) *sound-player-enable*) ;; act as if this isnt a new source of eco to prevent spamming sounds. then restore the old source! @@ -461,13 +475,16 @@ ) (if (pc-cheats? (-> obj cheats) sky) - (let ((date (new 'stack 'scf-time))) + (let ((date (new 'stack-no-clear 'scf-time))) (scf-get-time date) (when (zero? (-> date stat)) - (set-time-of-day (+ (the float (bcd->dec (-> date hour))) (/ (the float (bcd->dec (-> date minute))) 60))) - ) - ) - ) + (set-time-of-day (+ (the float (bcd->dec (-> date hour))) (/ (the float (bcd->dec (-> date minute))) 60)))) + )) + + (pc-set-gfx-hack (pc-gfx-hack no-tex) (logtest? (-> obj cheats) (pc-cheats no-tex))) + + ;; run cheats end!!! + ;;;;;;;;;;;;;;;;;;;; (logior! (-> obj cheats-known) (-> obj cheats)) 0) diff --git a/goal_src/jak1/pc/progress-pc.gc b/goal_src/jak1/pc/progress-pc.gc index 8125f067f..5a7eb5656 100644 --- a/goal_src/jak1/pc/progress-pc.gc +++ b/goal_src/jak1/pc/progress-pc.gc @@ -238,14 +238,21 @@ ) (define *cheats* (new 'static 'boxed-array :type game-option + (new 'static 'game-option :option-type (game-option-type cheat-toggle) :name (game-text-id cheat-sidekick-alt) :scale #t :param1 5.0) + (new 'static 'game-option :option-type (game-option-type cheat-toggle) :name (game-text-id cheat-big-head) :scale #t :param1 9.0) + (new 'static 'game-option :option-type (game-option-type cheat-toggle) :name (game-text-id cheat-small-head) :scale #t :param1 10.0) + (new 'static 'game-option :option-type (game-option-type cheat-toggle) :name (game-text-id cheat-big-fist) :scale #t :param1 11.0) + (new 'static 'game-option :option-type (game-option-type cheat-toggle) :name (game-text-id cheat-big-head-npc) :scale #t :param1 16.0) + (new 'static 'game-option :option-type (game-option-type cheat-toggle) :name (game-text-id cheat-tunes) :scale #t :param1 6.0) + (new 'static 'game-option :option-type (game-option-type cheat-toggle) :name (game-text-id cheat-sky) :scale #t :param1 7.0) + (new 'static 'game-option :option-type (game-option-type cheat-toggle) :name (game-text-id cheat-huge-head) :scale #t :param1 15.0) + (new 'static 'game-option :option-type (game-option-type cheat-toggle) :name (game-text-id cheat-mirror) :scale #t :param1 8.0) (new 'static 'game-option :option-type (game-option-type cheat-toggle) :name (game-text-id cheat-eco-yellow) :scale #t :param1 3.0) (new 'static 'game-option :option-type (game-option-type cheat-toggle) :name (game-text-id cheat-eco-blue) :scale #t :param1 2.0) (new 'static 'game-option :option-type (game-option-type cheat-toggle) :name (game-text-id cheat-eco-red) :scale #t :param1 1.0) (new 'static 'game-option :option-type (game-option-type cheat-toggle) :name (game-text-id cheat-eco-green) :scale #t :param1 0.0) (new 'static 'game-option :option-type (game-option-type cheat-toggle) :name (game-text-id cheat-invinc) :scale #t :param1 4.0) - (new 'static 'game-option :option-type (game-option-type cheat-toggle) :name (game-text-id cheat-sidekick-alt) :scale #t :param1 5.0) - (new 'static 'game-option :option-type (game-option-type cheat-toggle) :name (game-text-id cheat-tunes) :scale #t :param1 6.0) - (new 'static 'game-option :option-type (game-option-type cheat-toggle) :name (game-text-id cheat-sky) :scale #t :param1 7.0) + (new 'static 'game-option :option-type (game-option-type cheat-toggle) :name (game-text-id cheat-no-tex) :scale #t :param1 12.0) (new 'static 'game-option :option-type (game-option-type button) :name (game-text-id back) :scale #t) ) ) @@ -640,9 +647,9 @@ ;; give cheats (when (task-closed? (game-task finalboss-movies) (task-status need-reminder)) - (logior! (-> *pc-settings* cheats-known) (pc-cheats sidekick-blue tunes sky)) + (logior! (-> *pc-settings* cheats-known) (pc-cheats sidekick-blue tunes sky big-head small-head big-fist big-head-npc)) (when (>= (calculate-completion (the progress #f)) 100.0) - (logior! (-> *pc-settings* cheats-known) (pc-cheats invinc eco-blue eco-red eco-green eco-yellow)))) + (logior! (-> *pc-settings* cheats-known) (pc-cheats invinc eco-blue eco-red eco-green eco-yellow huge-head mirror no-tex)))) ;; set up options for each screen (set! (-> *options-remap* (progress-screen settings)) (if (or *cheat-mode* (nonzero? (-> *pc-settings* cheats-known))) @@ -756,14 +763,9 @@ (set! (-> *sound-options-pc* 0 value-to-modify) (&-> *setting-control* default sfx-volume)) (set! (-> *sound-options-pc* 1 value-to-modify) (&-> *setting-control* default music-volume)) (set! (-> *sound-options-pc* 2 value-to-modify) (&-> *setting-control* default dialog-volume)) - (set! (-> *cheats* 0 value-to-modify) (&-> *progress-carousell* symbol-backup)) - (set! (-> *cheats* 1 value-to-modify) (&-> *progress-carousell* symbol-backup)) - (set! (-> *cheats* 2 value-to-modify) (&-> *progress-carousell* symbol-backup)) - (set! (-> *cheats* 3 value-to-modify) (&-> *progress-carousell* symbol-backup)) - (set! (-> *cheats* 4 value-to-modify) (&-> *progress-carousell* symbol-backup)) - (set! (-> *cheats* 5 value-to-modify) (&-> *progress-carousell* symbol-backup)) - (set! (-> *cheats* 6 value-to-modify) (&-> *progress-carousell* symbol-backup)) - (set! (-> *cheats* 7 value-to-modify) (&-> *progress-carousell* symbol-backup)) + (dotimes (i (1- (-> *cheats* length))) + (set! (-> *cheats* i value-to-modify) (&-> *progress-carousell* symbol-backup)) + ) ;(set! (-> *sound-options-pc* 3 value-to-modify) (&-> *pc-settings* music-fadein?)) (set! (-> *progress-carousell* aspect-native-choice) (-> *pc-settings* use-vis?)) @@ -1947,13 +1949,23 @@ (pc-cheats eco-green) (pc-cheats eco-red) (pc-cheats eco-yellow) - (pc-cheats invinc)) + (pc-cheats invinc) + (pc-cheats huge-head) + (pc-cheats mirror) + (pc-cheats no-tex) + ) (set! option-str (lookup-text! *common-text* (game-text-id cheat-req-100-percent) #f))) (((pc-cheats sky) (pc-cheats sidekick-blue) - (pc-cheats tunes)) + (pc-cheats tunes) + (pc-cheats big-head) + (pc-cheats small-head) + (pc-cheats big-fist) + (pc-cheats big-head-npc) + ) (set! option-str (lookup-text! *common-text* (game-text-id cheat-req-beat-game) #f))) (else + ;; (format 0 "weird case ~f #x~x~%" (-> options index param1) (ash 1 (the int (-> options index param1)))) (set! option-str locked-str)) ) ) diff --git a/goal_src/jak1/pc/util/pc-anim-util.gc b/goal_src/jak1/pc/util/pc-anim-util.gc new file mode 100644 index 000000000..52f206535 --- /dev/null +++ b/goal_src/jak1/pc/util/pc-anim-util.gc @@ -0,0 +1,122 @@ +;;-*-Lisp-*- +(in-package goal) + +#| +A random assortment of functions used for manipulating various animations and skeletons in the pc port. + +This is used for funny cheat codes and the like. +|# + + +(define *cheat-big-head-scale* (new 'static 'vector :x 1.5 :y 1.5 :z 1.5 :w 1.0)) +(define *cheat-huge-head-scale* (new 'static 'vector :x 2.5 :y 2.5 :z 2.5 :w 1.0)) +(define *cheat-small-head-scale* (new 'static 'vector :x 0.667 :y 0.667 :z 0.667 :w 1.0)) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; callbacks for joint scaling ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defun matrix-diagonal! ((out matrix) (value float)) + "clear matrix and set its diagonal to a value." + (set! (-> out vector 0 quad) (the-as uint128 0)) + (set! (-> out vector 1 quad) (the-as uint128 0)) + (set! (-> out vector 2 quad) (the-as uint128 0)) + (set! (-> out vector 3 quad) (the-as uint128 0)) + (set! (-> out vector 0 data 0) value) + (set! (-> out vector 1 data 1) value) + (set! (-> out vector 2 data 2) value) + (set! (-> out vector 3 data 3) value) + out + ) + +(defun matrix*!-bone-callback ((the-bone bone) (is-parent? symbol) (mtx matrix) a) + "apply a transform matrix to a bone." + (matrix*! (-> the-bone transform) (-> the-bone transform) mtx) + ) + +(defun cspace-map-joints ((proc process-drawable) (cspace-idx int) (include-parent? symbol) (func (function bone symbol object object object)) p0 p1) + "run func on all joints' bones that are children of cspace-idx + if include-parent? = #t then also apply to that joint." + ;; iterate through all cspaces in the process + (let ((parent-joint (-> proc node-list data cspace-idx joint))) + (dotimes (i (-> proc node-list length)) + ;; see if it's a joint and keep that for later + (awhen (-> proc node-list data i joint) + (cond + ;; run func if we ARE the parent! + ((= it parent-joint) + ;;(format #t "running map on parent ~A~%" it) + (if include-parent? + (func (-> proc node-list data i bone) #t p0 p1))) + ;; otherwise go up our parents until we hit what we want (yay!) or nothing (nay...) + (else + (let ((cur-parent it)) + (until (or (not cur-parent) (= cur-parent parent-joint)) + (set! cur-parent (-> cur-parent parent)) + ) + (when (= cur-parent parent-joint) + ;;(format #t "running map on child ~A~%" it) + (func (-> proc node-list data i bone) #f p0 p1)) + ) + ) + ) + ) + )) + ) + +(defun scale-joints ((obj process-drawable) (cspace-idx int) (scale-children? symbol) (scale vector)) + "scale a joint (cspace-idx) in an actor. if scale-children? = #t, also scales all child joints." + (if (= cspace-idx -1) + (return #f)) + (let* ((parent-mtx (-> obj node-list data cspace-idx bone transform)) + (unscale-q (matrix-diagonal! (new-stack-matrix0) (/ 1.0 (-> parent-mtx data 15)))) + (scale-q (matrix-diagonal! (new-stack-matrix0) (-> parent-mtx data 15))) + + (scale-mat (matrix-scale! (new-stack-matrix0) scale)) + (parent-fixed (matrix*! (new-stack-matrix0) parent-mtx unscale-q)) + + (inv-parent (matrix-4x4-inverse! (new-stack-matrix0) parent-fixed)) + ;; bone * inverse(parent * unscale-q) * scale * parent * scale-q + + (matrix1 (matrix*! (new-stack-matrix0) inv-parent scale-mat)) + (matrix2 (matrix*! (new-stack-matrix0) matrix1 parent-mtx)) + (matrix3 (matrix*! (new-stack-matrix0) matrix2 scale-q)) + ) + (if scale-children? + (cspace-map-joints obj cspace-idx #t matrix*!-bone-callback matrix3 scale) + (matrix*!-bone-callback (-> obj node-list data cspace-idx bone) #t matrix3 scale) + ) + ) + ) + +(defun target-joint-callback-pc ((obj target)) + "custom animation callback for *target*" + + (let ((neckA-idx (cspace-index-by-name obj "neckA"))) + (cond + ((pc-cheats? (-> *pc-settings* cheats) small-head) (scale-joints obj neckA-idx #t *cheat-small-head-scale*)) + ((pc-cheats? (-> *pc-settings* cheats) huge-head) (scale-joints obj neckA-idx #t *cheat-huge-head-scale*)) + ((pc-cheats? (-> *pc-settings* cheats) big-head) (scale-joints obj neckA-idx #t *cheat-big-head-scale*)) + )) + (when (and (pc-cheats? (-> *pc-settings* cheats) big-fist) (!= 'target-edge-grab (-> obj next-state name))) + (scale-joints obj (cspace-index-by-name obj "sk_lhand") #t *cheat-huge-head-scale*) + (scale-joints obj (cspace-index-by-name obj "sk_rhand") #t *cheat-huge-head-scale*) + ) + 0 (none) + ) + +(defun process-drawable-joint-callback-pc ((obj process-drawable)) + "custom animation callback for any process drawable" + + (when (pc-cheats? (-> *pc-settings* cheats) oh-my-goodness) + ;; don't ask. + (scale-joints obj (cspace-index-by-name obj "lbood") #t (new 'static 'vector :x 2.0 :y 2.0 :z 2.0 :w 1.0)) + (scale-joints obj (cspace-index-by-name obj "rboob") #t (new 'static 'vector :x 2.0 :y 2.0 :z 2.0 :w 1.0)) + ) + (when (pc-cheats? (-> *pc-settings* cheats) big-head-npc) + (scale-joints obj (cspace-index-by-name obj "head") #t *cheat-big-head-scale*) + ) + 0 (none) + ) + + diff --git a/test/decompiler/reference/jak1/engine/anim/mspace-h_REF.gc b/test/decompiler/reference/jak1/engine/anim/mspace-h_REF.gc index 4131ebd75..32ac8f68d 100644 --- a/test/decompiler/reference/jak1/engine/anim/mspace-h_REF.gc +++ b/test/decompiler/reference/jak1/engine/anim/mspace-h_REF.gc @@ -3,7 +3,7 @@ ;; definition of type joint (deftype joint (basic) - ((name basic :offset-assert 4) + ((name string :offset-assert 4) (number int32 :offset-assert 8) (parent joint :offset-assert 12) (bind-pose matrix :inline :offset-assert 16) diff --git a/test/decompiler/reference/jak1/engine/target/joint-mod-h_REF.gc b/test/decompiler/reference/jak1/engine/target/joint-mod-h_REF.gc index e0585c948..e11905012 100644 --- a/test/decompiler/reference/jak1/engine/target/joint-mod-h_REF.gc +++ b/test/decompiler/reference/jak1/engine/target/joint-mod-h_REF.gc @@ -20,8 +20,8 @@ (up uint8 :offset-assert 136) (nose uint8 :offset-assert 137) (ear uint8 :offset-assert 138) - (shutting-down? basic :offset-assert 140) - (parented-scale? basic :offset 128) + (shutting-down? symbol :offset-assert 140) + (parented-scale? symbol :offset 128) ) :method-count-assert 16 :size-assert #x90 @@ -34,7 +34,7 @@ (reset-blend! (_type_) _type_ 12) (set-twist! (_type_ float float float) vector 13) (set-trs! (_type_ vector quaternion vector) none 14) - (shut-down! (_type_) float 15) + (shut-down! (_type_) none 15) ) ) @@ -159,12 +159,11 @@ ) ;; definition for method 15 of type joint-mod +;; INFO: Return type mismatch float vs none. (defmethod shut-down! joint-mod ((obj joint-mod)) (set! (-> obj shutting-down?) #t) - (let ((f0-0 0.0)) - (set! (-> obj blend) f0-0) - f0-0 - ) + (set! (-> obj blend) 0.0) + (none) ) ;; definition for method 13 of type joint-mod @@ -667,16 +666,16 @@ ;; definition of type joint-mod-set-local (deftype joint-mod-set-local (basic) ((transform transformq :inline :offset-assert 16) - (set-rotation basic :offset-assert 64) - (set-scale basic :offset-assert 68) - (set-translation basic :offset-assert 72) - (enable basic :offset-assert 76) + (set-rotation symbol :offset-assert 64) + (set-scale symbol :offset-assert 68) + (set-translation symbol :offset-assert 72) + (enable symbol :offset-assert 76) ) :method-count-assert 9 :size-assert #x50 :flag-assert #x900000050 (:methods - (new (symbol type process-drawable int basic basic basic) _type_ 0) + (new (symbol type process-drawable int symbol symbol symbol) _type_ 0) ) ) @@ -722,9 +721,9 @@ (type-to-make type) (arg0 process-drawable) (arg1 int) - (arg2 basic) - (arg3 basic) - (arg4 basic) + (arg2 symbol) + (arg3 symbol) + (arg4 symbol) ) (let ((v0-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) (set! (-> v0-0 set-translation) arg2)