Anyone interested in Stretch Panic pnaches
?
Background:
A little while ago, sergx12 created ISO HEX codes for this game and mentioned its field of views (FOVs) are stored in binary files. That put Stretch Panic in a weird situation, in that it became the only game in Devina's widescreen hacks archive that lacked a pnach variant.
I decided to give creating a pnach a shot. So I checked out the game. At first I tried comparing PCSX2 save states of the original ISO against a fully patched HEX-edited ISO in the hopes of finding an static X FOV address in live memory. No luck.
Then I created 9 copies of a vanilla ISO, applied one "part" of sergx12's HEX edits to each one and tried running them all. I was hoping to find a single, specific "part" that covers the whole game, look for its HEX representation in live memory and go from there. That didn't pan out.
I paid special attention to my 3rd hacked ISO - which makes the hub level (MUSIUM.BIN) widescreen. I reviewed changes in the before and after HEX patterns for it (from sergx12's ISO hacks). I compared non-widescreen and widescreen PCSX2 save states to seek out the before and after HEX patterns for my level in live memory. Then I setup a write breakpoint in PCSX2's debugger to see what writes to those addresses (I assumed the HEX patterns were data that gets interpreted by the game's ELF file). No luck. Then I accidently switched one of my breakpoints into an execute one and had an "ahah!" moment. It stopped at the execute breakpoint and MIPS instructions were showing in surrounding addresses within the debugger.
This irritated me a lot. If each of the game's 21 BIN files are like "distinct" mini ELF files that handle all of their game logic independently, it'd make for very long and complicated live memory-only hacks, full of E-type conditions. I looked around at the registers involved in the MIPS instructions sergx12's ISO hacks changed for my level, and sought out the store word (sw) instructions that store those registers' values into live memory addresses. This lead me to finding the "active" X FOV addresses for my level. Both contain positive and negative versions of the same float number. All playable levels seem to use the same FOV values, but store them at dynamic addresses (lame...).
Furthermore, the FOV values aren't the same for all situations. They're different during the in-game cutscenes (like the intro) compared to playable levels. So there was a need to create a MIPS injection hack to multiply the FOVs (whatever they happen to be) by 1.333333373 on-the-fly while the game is running. To do that, I'd need a good spot to insert a jump (j) instruction to run the MIPS injection hack. A spot that'll always be at the same address and run after the MIPS instructions in the BIN files. So it had to be somewhere in the game's main ELF file. In IDA Pro, I looked for j/jr/jal instructions in my level's BIN file and found a jal that pointed to the address of a function situated in the game's main ELF file. That function ran occasionally, but not at the right points in time (it ran before the BIN files).
So I tried something else. I set read breakpoints on the X FOV addresses in PCSX2, hoping that maybe a function in the game's main ELF is what reads the FOV addresses to render the graphics (as opposed to MIPS instructions in those stupid individual BIN files). Luckily, it was the game's main ELF that does it. So I was able to inject my ELF hacks' jump instruction at the point in time the game attempts to read X FOV values from live memory. That means that every time the game reads the FOV addresses, my hack will kick in and multiply what got read by 1.333333373 (or something else for Y FOVs). If the BIN files had been responsible for reading the FOV values they wrote earlier to render graphics, I would've been stuck in a horrible situation where the read instructions are at different addresses in each level. Since the read instructions are in the game's main ELF file, they'll always be at the exact same addresses at all times.
I came very close to making this post over the past week or so, but kept running into last-minute snags with the hacks. The first time around, while taking comparison screenshots I realized the hacks weren't working properly for in-game cutscenes. They panned out the viewport in all directions. So instead of becoming widescreen, the cutscenes just looked zoomed-out. I wasn't able to come up with a fix. As a result, that left me with hacks that messed up cutscenes but worked when playing... To address that, I reworked the hacks to skip the widescreen calculations if a cutscene is playing. On my next release attempt, I noticed full booting PCSX2 with the hacks enabled caused the game to crash due to a bug in PCSX2 (game pnaches getting injected into BIOS memory), so I added conditional E-type codes to prevent the hacks from taking effect until the game's ELF file has loaded.
TL;DR All of this game's levels are stored in BIN files, which are like "mini" ELFs. The BIN files write FOVs to dynamic addresses... but the game's "main" ELF reads them to render graphics. My ELF hacks intercept the reads to manipulate the FOVs. Cutscenes are a no-go.
Pnaches:
Changelog (compared to sergx12's ISO HEX codes):- Created pnach widescreen patches, via ELF hacks.
- Ported the hacks to other regions' versions of the game:
- Freak Out (PAL)
- Hippa Linda (NTSC-J)
- Added two 16:10 modes:
- 16:10 (Normal) - Uses a wider X field of view (FOV) than 4:3, but isn't as wide as 16:9.
- 16:10 (Ultra) - Uses the same X FOV as 16:9, with a taller Y FOV to account for 16:10's increased height.
What's missing (sorry - forgot to include this in my last few release posts):- Company logos (FMVs?) need to be thinned-out.
- In-game cutscenes (like the intro) need FOV hacks. Might look strange though since it's really obvious they were designed with a 4:3 aspect ratio in mind.
- HUDs need to be thinned-out and repositioned to the far left/right edges of the screen.
- 2D text needs to be thinned-out.
Note:- To enable one of the 16:10 hacks, comment-out the 16:9 hack and uncomment your desired 16:10 one.
Other:- @monsterjamp I'll try to follow up on post #4.642 at some point.
- @Devina I'll also follow-up if I notice any other requested games or WIP/incomplete hacks missing from the widescreen archive post.
Screenshot descriptions:
- 4:3
- 16:10 (normal)
- 16:9
- 16:10 (ultra)