Debugging tutorial (FF8 as example) You'll need: A PSX debugger (pSX has the best one, imo, but pcsx is a valid alternative) General ASM knowledge (any hardware, very helpful but not needed) Codehacking experience (again, very helpful but not needed) CheatEngine, Artmoney or similar Helpful links: PSX opcodes/instructions http://zodiac.ffhacktics.com/PSX-INST.txt CodeBreaker codes for FF8 http://cheats.codetwink.com/psx/view/1260/ You could find the RAM addresses for things you'd like to examine yourself, but it's easier to take CB codes or just codes for a cheating device that uses no encryption. -------------------------------------------------------------------------------- (I'll assume that you're using pSX as well) Now, start up the emulator and the game, go to Debug -> Monitor -> r3000 You should only need these windows: Breakpoints (shows breakpoints you've set) Registers (shows all registers and their current values) Disassembly (shows the instructions; if a bp is triggered, you'll see the instruction that triggered the bp as well as what follows) If there's a cheat code for what you want to examine, just take the address and set a breakpoint on read. E.g. there's a CB code for the second position which sets the STR (in battle) to 255, it'd look like this: 300ED2E7 00FF If you wanted to set a BP on it, you'd go to the Breakpoints window, right-click and select "Add". The address would be "0x000ED2E7" (basically, replace the first number with 0 of the code and add "0x" before it) Then check "Memory" and select "Read" only, leaving everything else as it is. This "Breakpoint on read" only triggers when the address is read from the RAM and loaded into a register. If you attack something with that character, the game will stop and the instruction after the one which triggered the bp will be highlighted. In this case, a part of the Disassembly windows would look like this: lbu r4, 0x00cd(r3) >nop mult r4, r4 Check out http://zodiac.ffhacktics.com/PSX-INST.txt if you're unsure what an instruction means. The lbu instruction triggered the bp, the next line to be executed is "nop" ("no operation", does nothing) and then "mult r4, r4", which is, in this case "STR^2" (you should recognize this from the P. Attack formula). You can step to the next instruction with F7 and run the game again with F9. Be careful when using addresses you've found with ArtMoney/CheatEngine/whatever. These are RAM addresses the emulator uses, you'll have to convert them to PSX RAM. E.g. Address found with ArtMoney (first item quantity): 06DF7EDD PSX RAM address: 00077EBD => Conversion offset: -6D80020 (cheat codes always use the PSX RAM addresses, so use them for reference) That's it, basically. You just have to step through the instructions while paying attention to what registers are used and where their values come from. Things to look out for: - r0 is hardwired to have the value 0 - the PSX uses pipelining to increase performance, the most apparent effect of this is that all operations dealing with branching/jumping are delayed. This means that even if the branching condition is true, the next operation is still executed before you jump away. - Registers 4-7 are the function's arguments, always keep an eye on them. - Registers 8-15, 24-25 are temporary registers. They're usually used when the function reads from memory. - Registers 16-23 are saved registers. If one of these is used in an algorithm, chances are, it was loaded before the function was even called, which can make them more difficult to track. Things to look for: - The RNG. If you're lucky, the RNG is called before anything else is calculated (FF8 in some cases) and if you're unlucky, it's called at the very end of the algorithm (Xenogears) - Somewhat obvious, but start with already known stuff and see if you get to the same result. In FF8, it would be something like the physical damage formula and for some simple exercise in floating point arithmetics, the Card formula. - If you have the RNG address, but can't reliably set a bp on it because it's called way too often, try nop'ing the intructions that do that, although this will have a negative effect most of the time if you do something specific (Xenogears crashes if the enemy gets his turn, Breath of Fire 4 crashes sometimes when you try to end the battle and FF8 doesn't periodically call the RNG apart from the card game, anyway)