Fixes#3997: The script for the orb that is spawned when getting a medal
in the satellite game was using the wrong entity name.
Fixes#3998: The `spider-manager` process was invalid for one frame,
causing the score to be set to the value of `#f`, winning the game
instantly.
Also doubled the PC port texture count, which should hopefully fix the
crash that happens when playing the game all the way through to the end
of the Destroy Dark Eco Tanks mission in one sitting.
Resolves#3075
TODO before merge:
- [x] Properly draw non-korean strings while in korean mode (language
selection)
- [x] Check jak 3
- [x] Translation scaffolding (allow korean characters, add to Crowdin,
fix japanese locale, etc)
- [x] Check translation of text lines
- [x] Check translation of subtitle lines
- [x] Cleanup PR / some performance optimization (it's take a bit too
long to build the text and it shouldn't since the information is in a
giant lookup table)
- [x] Wait until release is cut
I confirmed the font textures are identical between Jak 2 and Jak 3, so
thank god for that.
Some examples of converting the korean encoding to utf-8. These show off
all scenarios, pure korean / korean with ascii and japanese / korean
with replacements (flags):
<img width="316" height="611" alt="Screenshot 2025-07-26 191511"
src="https://github.com/user-attachments/assets/614383ba-8049-4bf4-937e-24ad3e605d41"
/>
<img width="254" height="220" alt="Screenshot 2025-07-26 191529"
src="https://github.com/user-attachments/assets/1f6e5a6c-8527-4f98-a988-925ec66e437d"
/>
And it working in game. `Input Options` is a custom not-yet-translated
string. It now shows up properly instead of a disgusting block of
glyphs, and all the original strings are hopefully the same
semantically!:
<img width="550" height="493" alt="Screenshot 2025-07-26 202838"
src="https://github.com/user-attachments/assets/9ebdf6c0-f5a3-4a30-84a1-e5840809a1a2"
/>
Quite the challenge. The crux of the problem is -- Naughty Dog came up
with their own encoding for representing korean syllable blocks, and
that source information is lost so it has to be reverse engineered.
Instead of trying to figure out their encoding from the text -- I went
at it from the angle of just "how do i draw every single korean
character using their glyph set".
One might think this is way too time consuming but it's important to
remember:
- Korean letters are designed to be composable from a relatively small
number of glyphs (more on this later)
- Someone at naughty dog did basically this exact process
- There is no other way! While there are loose patterns, there isn't an
overarching rhyme or reason, they just picked the right glyph for the
writing context (more on this later). And there are even situations
where there IS NO good looking glyph, or the one ND chose looks awful
and unreadable (we could technically fix this by adjusting the
positioning of the glyphs but....no more)!
Information on their encoding that gets passed to `convert-korean-text`:
- It's a raw stream of bytes
- It can contain normal font letters
- Every syllable block begins with: `0x04 <num_glyphs> <...the glyph
bytes...>`
- DO NOT confuse `num_glyphs` with num jamo, because some glyphs can
have multiple jamo!
- Every section of normal text starts with `0x03`. For example a space
would be `0x03 0x20`
- There are a very select few number of jamo glyphs on a secondary
texture page, these glyph bytes are preceeded with a `0x05`. These jamo
are a variant of some of the final vowels, moving them as low down as
possible.
Crash course on korean writing:
- Nice resource as this is basically what we are doing -
https://glyphsapp.com/learn/creating-a-hangeul-font
- Korean syllable blocks have either 2 or 3 jamo. Jamo are basically
letters and are the individual pieces that make up the syllable blocks.
- The jamo are split up into "initial", "medial" and "final" categories.
Within the "medial" category there are obvious visual variants:
- Horizontal
- Vertical
- Combination (horizontal + a vertical)
- These jamo are laid out in 6 main pre-defined "orientations":
- initial + vertical medial
- initial + horizontal medial
- initial + combination
- initial + vertical medial + final
- initial + horizontal medial + final
- initial + combination + final
- Sometimes, for stylistic reasons, jamo will be written in different
ways (ie. if there is nothing below a vertical vowel will be extended).
- Annoying, and ND's glyph set supports this stylistic choice!
- There are some combination of jamo that are never used, and some that
are only used for a single word in the entire language!
With all that in mind, my basic process was:
- Scan the game's entire corpus of korean text, that includes subtitles.
It's very easy to look at the font texture's glyphs and assign them to
their respective jamo
- This let me construct a mapping and see which glyphs were used under
which context
- I then shoved this information into a 2-D matrix in excel, and created
an in-game tool to check every single jamo permutation to fill in the
gaps / change them if naughty dogs was bad. Most of the time, ND's
encoding was fine.
-
https://docs.google.com/spreadsheets/d/e/2PACX-1vTtyMeb5-mL5rXseS9YllVj32BGCISOGZFic6nkRV5Er5aLZ9CLq1Hj_rTY7pRCn-wrQDH1rvTqUHwB/pubhtml?gid=886895534&single=true
anything in red is an addition / modification on my part.
- This was the most lengthy part but not as long as you may think, you
can do a lot of pruning. For example if you are checking a 3-jamo
variant (the ones with the most permutations) and you've verified that
the medial jamo is as far up vertically as it can be, and you are using
the lowest final jamo that are available -- there is nothing to check or
improve -- for better or worse! So those end up being the permutations
between the initial and medial instead of a three-way permutation
nightmare.
- Also, while it is a 2d matrix, there's a lot of pruning even within
that. For example, for the first 3 orientations, you dont have to care
about final vowels at all.
- At the end, I'm left with a lookup table that I can use the encode the
best looking korean syllable blocks possible given the context of the
jamo combination.
Similar issue to the orbs-per-level counts, while loading a save (in
blackout) these values are reset to 0 briefly. This can cause extra
autosplits (see https://github.com/open-goal/speedrunning/pull/25)
The context for this is that i was symlinking files from a mod
installation that were identical to the unmodded game, for space
considerations, because i remembered having success with that in the
past, before the project made the switch to ghc's filesystem library, it
seems. <sub>(I was also much more pressed for space back then, but well,
i thought writing a small program to check for matches and link them for
me would be a good, not-so-difficult exercise...)</sub>
However i quickly started getting weird errors that it couldn't find
GAME.CGO or KERNEL.CGO even when i hadn't touched them. Initially since
i found that it occurred only when symlinking any files that were
earlier alphabetically, i assumed it was some kind of index mismatch,
but it was actually caused by a bug in an older version of
filesystem.hpp causing the `directory_iterator` to read everything after
a symlink as also a symlink, making them fail to be read properly:
https://github.com/gulrak/filesystem/pull/162
Adding `f.is_symlink()` is not as much of a change to the loop's
condition from the previous behavior as it might first appear. It seems
that even without that condition the iterator *was* reading symlinks
before, just incorrectly (and before ghc::filesystem, they were being
read just fine, iirc). With the new version, though, symlinks do have to
be accounted for explicitly.
Given that the library's major and minor version are both the same, i
don't expect there should be any breaking changes to the API, and i
didn't find any when i was testing but there might need to be more
investigation into that before merging. Also, without the added check
for `f.exists()`, the behavior is exactly the same as if, for some
reason, a fakeiso file the game needs just doesn't exist in the first
place (which has no real reason to happen in a normal installation of
the game): there's a decent chance it will either crash at some point
later during runtime, or something will happen like a level failing to
load causing Jak to trip infinitely. I thought it might be helpful to
have it fail right away in the case that, say, someone moved their
vanilla installation and staled their symlinks, but i'll defer to
maintainers' judgement on that point.
Taking the suggestion from @Calinou
(https://github.com/open-goal/jak-project/pull/3943#issuecomment-3017359144),
this replaces the resolve/render framebuffer -> window framebuffer blit
with an actual drawn tri-strip which covers the entire viewport, which
the PCRTC blackout already does.
It appears we have no guarantee what state the internal window
framebuffer will be in, so drawing an actual primitive and letting the
fragment shader do all the work seems to be the more
compatible/functional solution here.
Thanks for the suggestion!
Some monitors are very specific about their reported refresh rates:
```
[54:37] [debug] [DISPLAY]: Skipping 640x480 as it requires 360.11hz but the monitor is currently set to 360hz
```
The current code truncated the display mode, but would compare against
the reported refresh rate. As per the log, they are obviously not equal.
- Retain the float component and only round it off when sending the
value to GOAL
- Make the comparison more generous, +/- 1.0hz
The main bug this fixes is not being able to use level select when your
language isn't translated. Why? Because they use the result from
`lookup-text!` to determine if a menu item should be drawn or not. No
text found, no menu item.
However this uncovered a long-standing bug in my fallback extension to
this code. If you call this function with a text-id that doesnt even
have an english string, it will recursively keep calling itself until it
crashes. Of course the first few tasks in the game are dummies and have
no valid text-id so this had to be fixed.
Should be fixed for all 3 games.
Compilation with the NO_ASSERT flag set results in errors.
This happens because some the macros are not defined in the else branch
of #ifndef NO_ASSERT.
If long_name is too long, it will result in the level being invisible
but the collide loading, lets detect this and point the user in correct
direction to solve it with a clear error message.
---------
Co-authored-by: Hat Kid <6624576+Hat-Kid@users.noreply.github.com>
Fixes#3151 by applying the same fix as #2686 to another Mips2C
function.
Tested by mashing Jak's body into the bad collision walls for 30 minutes
without a single crash.
Fixes a small bug introduced in #3902.
Without this change, whenever you load a save it is treated as if you
started a new game and resets the autosplitter back to 0s.
When building the eye texture, the background is first set to the top
corner of the iris texture.
A long, long time ago, I implemented this by peeking at the data in the
texture itself. This doesn't work if the iris texture is animated since
the texture will only on the GPU.
To fix this, this PR changes the eye renderer to draw a square over the
entire eye texture using iris texture's top corner, avoiding the need
for getting the texture data on the CPU. I don't remember why I didn't
do this in the first place, but this seems better in every way.
Also `input_data` in TexturePool not being initialized, which was
leading to hard-to-debug crashes when it was randomly initialized to a
sometimes invalid but non-null pointer.
Co-authored-by: water111 <awaterford1111445@gmail.com>
I discovered that `yakow`s are kinda broken if you try to use them in
custom levels in jak 2/3.
It's due to the missing `yakow-lod0` texture and associated fix,
replacing it with `yak-medfur-end`. This solution works fine for the
decompiler on vanilla levels.
But for building custom levels, the requested art-groups were being
handled before the textures were, and so it was impossible to have
`yak-medfur-end` on hand to do the replacement. You'd hit an exception
here because `idx_in_level_texture` would still be `INT32_MAX`:
https://github.com/open-goal/jak-project/blob/c08118509b84feba002bd9e208f49162b4218556/decompiler/level_extractor/extract_merc.cpp#L806
My fix was just to swap the order when building custom levels, and
handle the textures first. I only made the changes for jak2/3, because I
see @Hat-Kid has a slightly different implementation for jak1.
There's one other small change relating to the `combo_id` /
`pc_combo_tex_id` short-circtuiting - I think `pc_combo_tex_id` is
always 0 for vanilla textures? So initially `yakow-lod0` actually ended
up matching the `combo_id` of the checkerboard texture from the
test-zone GLB. I just added another sanity check here that the texture
names match too.
(I also added yakows in the test-zone.jsonc files 🐄)
Two changes that fix some Jak 3 audio bugs.
In some areas, sound effects would seem to cut off randomly. This was
caused by the sound code reusing IDs, but overlord didn't realize. It
would try to kill a sound effect by ID that had already died, and the ID
was reassigned to a new sound. To fix this, I made the handle IDs always
increment. I also tested starting the ID at large numbers and confirmed
that worked.
I also added support for the BRANCH grain. This makes the
`wastelander-shot` and possibly other sound effects work. It doesn't
support all the features, but this is probably enough.
Fun fact: the wastelander shot is supposed to have 7 variations, but you
always get the same one because they set the sound mask wrong.
I added a line you can uncomment if you want to experience the other 6
variations.
---------
Co-authored-by: water111 <awaterford1111445@gmail.com>
There's a suspicion that MSAA might be what causes the black screen
problem for some users, additionally this can cause perf issues for
people with really bad PCs so this is probably a better default.
Needs testing before merging, i think this is all inclusive though.
This needs a parameter, otherwise it was reading some uninitialized
value. In some cases, the uninitialized value would leave the nav stuff
on, and the marauders would go crazy trying to avoid each other.
This should solve the issue where buttons are held down until you push
them the same time. This would cause the cars in jak 3 to not move until
you pushed square/circle and "released" the brake.
Co-authored-by: water111 <awaterford1111445@gmail.com>
When the `dp-bipedal`s get blown up by the nuke gun, their bones go to
NaNs on the last frame. The shadow renderer doesn't handle this well and
draws all possible triangles as single tris. This overflows the vif
`unpack` field and triggered an assert when sizes inside the shadow
renderer weren't consistent.
My guess is that this works on the real game either because:
- their shadow renderer draws garbage data, but you can't tell because
the screen is white from the nuke
- no NaN on PS2 means that the shadow renderer behaved differently, not
using all single tris.
As a workaround, if the bones are NaN, the shadow renderer treats them
as 0, meaning there is no shadow drawn.
---------
Co-authored-by: water111 <awaterford1111445@gmail.com>
Fixes both interval and animation speed. (jak1 previously only had a fix
for the former.)
This should close#3518, and one of the issues of #1499.
The solution is not the cleanest. The results are going to be wrong in
case the FPS doesn't reach the maximum set.
A better solution would be to make `random-time` a float, so that it can
be subtracted by `time-adjust-ratio`, but I don't know if changing a
type for this purpose is allowed here. Tell me if I should do that
instead.
Tested only on jak2.
Co-authored-by: Tyler Wilding <xtvaser@gmail.com>
Fixes the pillars being transparent (but is a bit of a hack), the desert
sand not having texture filtering, and the "No memory card" on the title
screen with debug mode off.
---------
Co-authored-by: water111 <awaterford1111445@gmail.com>
Prior to SDL3, borderless windows were kinda a hack, they cleaned all of
that up. The side-effect of that is that the C++ code keeps track of the
current window size (it does this for framebuffer sizing, but also to
set the size of the window).
This is now an issue because SDL is properly firing events when you
change to borderless mode, so our window size gets updated to the size
of the entire monitor. When you switch to windowed mode from borderless,
it now seems like it didn't work (it did, its just still taking up the
entire screen).
This could be better cleaned up if more settings are extracted out of
GOAL and put into C++ so they can be managed and accessed where they
belong. But for now, this is a minimally invasive fix.
Fixes#3917
This is a simple multiplier to the gamepad axis input value received
from SDL events. Normally the values it provides cannot satisfy the
square range of the stick input. This is usually fine but it might play
differently with different controllers and compared to consoles,
especially considering the DualShock 1/2 have automatic calibration
which works in mysterious ways. The setting is there so any user can
adjust it for their controllers.
Saved to and loaded from the input-settings.json file.
133% matches PCSX2's default setting and is generally a good value to
map the square stick range within most modern(ish) controllers' circular
stick motion.
Progress menu option added to Jak 1 and 2. Setting can be changed from
50% all the way to 200%.
~~Renamed the analog deadzone options to stick deadzone since they don't
apply to the other analog buttons and only the (analog, yes) sticks.~~
libidn2 which is a potential part of libcurl seemingly slipped into the
latest release (0.2.25) and it was dynamically linked.
This causes issues:
```
dyld[95648]: Library not loaded: /usr/local/opt/libidn2/lib/libidn2.0.dylib
Referenced from: <9DA6EC1D-F99A-3233-8264-AAEA87F07743> /Users/tyler/Downloads/opengoal-macos-arm-v0.2.25/gk
Reason: tried: '/usr/local/opt/libidn2/lib/libidn2.0.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/libidn2/lib/libidn2.0.dylib' (no such file), '/usr/local/opt/libidn2/lib/libidn2.0.dylib' (no such file)
zsh: abort ./g
```
My theory for why is that the underlying image changed (now has this
library) and so the cmake detected that and started building with it.
The simple fix is to just disable it, as we don't need it. If we do
eventually, I can figure out how to ensure it's properly compiled.
For dualsense controllers, when the game exits we explicitly clear any
trigger effects. This was happening after SDL was already terminated, so
the hardware handles were already lost.
From a practical standpoint though, this mostly just cleans up logs.