Forums  /  Suikoden  /  Suikoden RNG Manipulation for emulator

The above link is to a video I just recorded demonstrating how you can get a Celadon urn & Holy crystal drop at the start of the game when using an emulator.

I don't know if there has been a full emulator run of this game (I have made I the first? That's an exciting thought but I bet I'm not!), I wasn't able to find anything more than what's been mentioned on this forum so I set about doing it myself.
Just in case anyone's interested, here's what I've done / learnt about running this game on an emulator:

I'll start by saying that I'm not a particularly techy guy. I don't use Linux or anything like that and I'm certainly not a programmer, and I knew nothing about RNG before starting trying to run Suikoden. I watched z3r01337's RPG Limitbreak run (and then watched a couple of his actual record runs) and thought "Imma try dat". So I set about trying to figure out anything I could about the RNG in Suikoden.

The first emulator I used was inside RetroArch using a core called PCSX ReArmed with the BIOS file SCPH1001.BIN (I'm still using that same BIOS file, as mentioned in the video).

That emulator doesn't have the tools that Bizhawk does, namely the RAM watch that allows you to see the RNG values on screen. I didn't know about any of that. I found z3r01337's Suikoden RNG Tool and using that, was able to muddle my way through the entire game, using the item drop tool, and also a lot of trial and error to work out item drop manips and having to use the RNG finder tool to work out the new value for each in-game RNG reset etc.

After a couple months I had a full run (I just copied the route of the PSTV run, just working out my own RNG manips along the way) and my best time was something like 4hrs 45mins. During this time I had looked into different emulators with a view to testing if my run worked the same in all of them, as long as I used the same BIOS file. I saw that Bizhawk had been mentioned as one that runs games at a relatively accurate speed so I tried that one. The game started on the same value and I was able to use my usual strats for Holy rune / Celadon urn, huzzah! However, when I flew to Magician's Island, I got encounters that I didn't recognize at all (note: I think on PSTV, Magician's Island reset can be 1 of 2 values...not on an emulator it seems. I tested it many times and always got the same value). I also went to Marco and, as expected, his cup game was completely different. I then tested this on a 3rd emulator (ePSXe) with the same BIOS file and got the same result. Game started on the same value, but got reset to another completely different value at each in-game RNG reset point.

So it seemed my run was specific not only to this BIOS file, but to that particular emulator as well (once an in-game RNG reset point is reached) but I thought "oh well, let's carry on anyway". And by this point I had discovered how to use the RAM Watch function in Bizhawk to watch the RNG values change and tweak stats for easier testing etc. and let me tell you, the pure jubilation I felt in that moment of discovery was magical. Even though I was running the game in a different emulator at the time, it would reduce the amount of trial-and-error grind by a ton.

I carried on trying to improve my RetroArch-PCSX ReArmed run, and one day my computer told me that it needed to update to the latest version of Windows. "Ok, sure, that shouldn't be a problem," I thought, naively.

After the Windows update, I went to run the game and the Holy rune / Celadon urn strats worked as normal, but then I flew to Magician's Island and got fights I didn't recognize. I tried again and again and each time got these same new fights and Marco's cup game was different as well. I had lost my run. I even reverted the Windows update to "restore an earlier version of Windows" but it didn't bring my familiar run back, it was still giving me these same new in-game RNG resets.

I then tried Bizhawk again and discovered that it was running the game the same as it had before the Windows update and seemed unaffected by it. And with my discovery of Bizhawk's RAM tools, I thought "Well, let's make the run again then."

So that's what I did. I had a pretty good knowledge of how the game's RNG behaves by that point and I was able to make a much more efficient run. It seems that as long as someone is running Bizhawk with the BIOS file SCPH1001.BIN, my full run should be repeatable. My best time is currently 4hrs 3mins 57secs but there's definitely still room to improve.

Not sure if all of this will be of interest to anyone really, I just thought I'd share my discoveries with whatever Suikoden Speedrun community exists. I think I might stream my full run at some point. I've never streamed anything before so I'll have to figure out how all of that works but I think that's what I'd like to do if anyone would be interested in watching. And if anyone would like to see any specific bits of my run feel free to ask, I'm happy to make more little videos like the one above (but I'll try not to ramble as much!)

All the best,

Z3R01337Z3R01337 likes this. 

Hey, amazing work! Happy to see someone put so much work and passion into this. And glad that someone besides myself finally found my RNG tool useful lol.

So on the topic of BIOS, it only affects the RNG at the start of the game / off a hard reset. Sadly, all RNG resets are based on emulator / console. I actually found the code responsible for it fairly recently. The value it writes to RNG is attained at instruction `0x1475d8` wth this instruction: `lhu r2, 0x0000(r3 = 0x1f801110)`. Essentially, it's 2 bytes from address `0x1f801110`. According to this write up


That address corresponds to the horizontal retrace root counter. This is the relevant snippet from the write up

Root Counters

Root counters are timers in the PSX. There are 4 root counters.

Counter Base address Synced to
0 0x1f80_1100 pixelclock
1 0x1f80_1110 horizontal retrace
2 0x1f80_1120 1/8 system clock
3 vertical retrace

Each have three registers, one with the current value, one with the counter mode, and one with a target value.

0x11n0 Count [read]
31 16 15 0
Garbage Count

Count Current count value, 0x0000-0xffff
Upper word seems to contain only garbage.

This is where my techincal knowledge fails me, I have no idea what those counters are or how they're used. I'm pretty sure it corresponds to physical hardware & it is definitely the reason why it's different on each emu / console. The value is written to the RNG address at instruction `0xbfc02238`, which is BIOS code. That part is consistent across all BIOS.

I don't think any of this matters for your routing or run, just thought you might find it interesting 🙂

Going back to the topic of BIOS, your setup for Holy / Celadon will 100% work on any console / emulator running on that BIOS! You can also possibly go for a different, faster setup if you have a different BIOS. The PSTV BIOS is `PSP660.bin`, if you use that you'll have the same starting RNG as the PSTV. Don't think I'm allowed to link here, but it shouldn't be too hard to find or you can find/ask for it in the discord.

One other thing worth mentioning is that Bizhawk has Lua scripting support. And thanks to that recent RNG reset find, I was able to write a script that "makes" the RNG Resets behave like on PSTV. I can't emulate the whole root counter thing, so I tried my best to make it consistent to the PSTV in terms of consistency and randomness with the resets. I made it as more of a practice tool and it's not fully tested, but it might be something your interested in. I also made one to randomize the RNG on every RNG reset so you can't RNG manip the game. Besides that, you can just make a few useful routing tools such as an accurate RNG advancement counter (I'm sure you've noticed by now that the changes column in RAM watch isn't accurate.) The caveat is that it only works with a version of Bizhawk that support onmemory events for PSX games, which none of the publicly available ones do. Someone hooked me up with a modded version that works though! Once again, I'm pretty sure I can't link here but hit me up in discord and I'll send you a link if you're interested.

Anyways, think I've rambled on long enough. Really happy to see the work you've put in and I'd love to see more content! If there's anything I can help with or you have any questions, please let me know! I would love to have as many routes for as many consoles / emulators as possible so more people can run this game!