• Topic Archived
You're browsing the GameFAQs Message Boards as a guest. Sign Up for free (or Log In if you already have an account) to be able to post messages, change how messages are displayed, and view media in posts.
  1. Boards
  2. King's Field: The Ancient City
  3. BUG FIX for that bug where the door/area doesn't load!

User Info: wgarvin

1 year ago#1
KF4 is a great game, but there is an annoying bug that affects emulation in PCSX2 (and reportedly also affects the game when played on a PS3 ?)

The bug is that some areas won't load properly, as shown in this youtube video: https://www.youtube.com/watch?v=XQuTx-7PlwA

For PCSX2 users, the game plays best with EE/FPU Round Mode set to the default "Chop/Zero" (or "Nearest", which seems to behave similarly). But this bug will almost certainly bite you in those modes -- the only workaround I could find mentioned on the internet was to set EE/FPU Round Mode to "Negative" before going near the staircase, and switch it back when you reach the top of the stairs.

I found this annoying, so I spent a couple of Saturdays debugging the problem, and I believe I have a code fix that fixes the bug! My fix is for the US version (SLUS-20318) and so far I have only tested this fix in the immediate vicinity of the bug. My plan for now is to do an entire playthrough of the game with default settings for EE/FPU Round Mode ("Chop Zero") and with Clamping Mode set to either "Normal" or "Full", to make sure this fix doesn't cause breakage anywhere else. Assuming it holds up, I would like to adapt it for the European version too.

But in the meantime, if anyone else wants to test it on the US ISO, here is what you need to do:

(1) Open your PCSX2 install folder, and go into the subfolder named 'cheats'
(2) Create a blank file named "36E02E91.pnach" and put the following text in it:
gametitle=Kings Field 4: The Ancient City (SLUS-20318)
comment=Experimental fix for the bug where a door to central tower fails to load! (patch by wgarvin)

(3) Restart PCSX2 and load the game ISO. If you have the log window open, you should be able to spot something like this in it:
Elf entry point @ 0x00100008 about to get recompiled. Load patches first.
Found Cheats file: '36E02E91.pnach'
comment: Fixes that annoying bug where a door to central tower fails to load! (patch by wgarvin)
Loaded 1 Cheats from '36E02E91.pnach' at 'C:\games\emulators\ps2\pcsx2-v1.5.0-dev-2525\cheats'
Overall 1 Cheats loaded

Then just play the game as usual!

User Info: wgarvin

1 year ago#2
How does this patch work?
Later I will probably write a detailed post with all the gory technical details of how I found this. But basically: each area contains a bunch of 'objects' of some kind, and the game decides which one the player is standing on/in. This includes some things I call "trigger zones" which are used to load the next area of the game; in the room just before this bug happens, there is a "loading trigger" covering about one stair's area just in front of the bottom of the staircase, and when the game detects you walking on that area it starts loading the new stuff for the top of the stairs. And then there is an "activation trigger" at the top of the stairs that enables the newly-loaded stuff and connects it to the world. The player has to step on both of these triggers for the door & central tower area to load properly. The bug boiled down to a single comparison testing the player's Y coordinate against the Y coordinate of the top of the trigger box; for the "loading trigger" at the bottom of the stairs, these two values turn out to be bit-for-bit identical when running the game on PCSX2 in "Chop/Zero" rounding mode. (I guess on original PS2 they weren't bit-for-bit identical). There is a floating-point comparison operation testing if the player is inside the top of the box, but it is a comparison for "less than" instead of "less than or equal", and so it treats the player as not being in the box. The patch replaces this comparison instruction, changing "c.lt.s f00,f21" into "c.le.s f00,f21" which causes the game to consider you to be standing in the box when you are standing exactly on the top of it. So it recognizes you as standing on the trigger, and all of the necessary loading/activating happens as it should.

If you want to see the bad instruction in PCSX2, go to Debug menu and Open Debugger, then click in the assembly pane on the right hand side, and press Ctrl+G to open an "Expression" dialog box. Type 0x1BE42C in the box and press Enter. If you have the original game, you should see:
001BE42C c.lt.s f00,f21

And if you have my patch enabled, it should instead say:
001BE42C c.le.s f00,f21

Shortly below that, at 001BE440 is the store instruction that seems to writes the object index to the halfword that represents the "object the player is standing in/on". For most of the room before the bug, it writes 0x0002. With the patch enabled, the loading trigger at the bottom of the stairs will write object index 0x0019, and the activation trigger at the top of the stairs will write object index 0x0018. (Those familiar with CheatEngine can watch this halfword being changed at 0x204141D2 as they move around the world stepping on the various triggers. You can also see the state variable for the loading/enabling state machine in a word at 0x2038D620. 0 means "not loading anything yet". states 1-4 are used during loading, and state 5 means "loaded and waiting to be activated". states 6-8 are used during activation then it goes back to 0).

User Info: wgarvin

1 year ago#3
Oh -- you need to turn on "Enable Cheats" in the PCSX2 System menu, or PCSX2 won't load the pnach file. And if you load your game using a savestate, that seems to include the byte of memory that is modified by the patch. So loading a savestate from before you enabled this patch, won't include the patch.

The easiest way to fix this is to make an in-game save, then restart the system with System > Boot ISO and then load your in-game save and save it in a new savestate slot. You can test if its fixed using the debugger: Debug > Open Debugger. Click in the "Memory" tab at the bottom and press Ctrl+G and type 0x1BE42C in the box and press Enter. It should show a bunch of 2-digit hex bytes. If it begins with "001BE42C 34 00 15 46" then it does not have the fix applied. If it begins with "001BE42C 36 00 15 46" then it does have the fix applied.
(message deleted)
(message deleted)

User Info: wgarvin

1 year ago#6
To thoroughly test my patch, I'm playing the entire game on EE/FPU Round Mode "Chop Zero" and EE/FPU Clamping Mode "Normal" (these are the defaults). I'm following seorin's walkthrough, which goes into nearly all areas of the game.

So far I am maybe half way? I've made it past the forge, past engineer's quarters and into the hallway with the fire faces. Note that this is past the point in the game where the bug normally strikes; so far all areas have loaded perfectly and I've had no other problems either. I'm pretty sure my bugfix has no harmful side effects but I will try and finish the playthrough to make sure.

User Info: wgarvin

1 year ago#7
I also made a fix for pcsx2 users who are playing the European version.

Create a file named cheats\401F4726.pnach and put this in it:
gametitle=Kings Field 4 / Kings Field: The Ancient City (SLES-50920)
comment=Fix game-breaking bug where a door to central tower fails to load (patch by wgarvin)

Same caveats as before: Make sure System > Enable Cheats is checked and boot the game. If you had a savestate without the cheat, you might need to load your savestate and go make an in-game save, then reset the emulated PS2 with System > Boot ISO and load your in-game save and make a new savestate.

I've only tested it briefly, but its exactly analogous to the patch for the US version, and I'm pretty sure its solid. The two executables are similar enough that it took only about and hour with CheatEngine and 15mins with the debugger to find the bit of code that needed fixing.

User Info: Xethuminra

1 year ago#8
Thanks so much!

User Info: OutlawDino

1 year ago#9
Tagging this.
"What's he point of having nukes if I can't ever use them?" - Coop
Official Deadpool of CAGN.

User Info: MegaZzZeux

1 year ago#10
Good s***. ran into this on my playthrough over a year ago

Yep, I live in Idaho.
  1. Boards
  2. King's Field: The Ancient City
  3. BUG FIX for that bug where the door/area doesn't load!
  • Topic Archived

GameFAQs Q&A