|Rangerous the Second
|Verfasst am: So 12.02.2017 - 05:06 Titel: Using WinUAE's debugger for simple memory reads and writes
|WinUAE has a built-in debugger. If you've ever wanted to try hex editing your character, and if you're using WinUAE, you already have the basic tools you need.
This simple walk-through applies to Fate v1.6 (English version) running Psygore's WHDLoad on the WinUAE emulator.
Each new release, like Fate v1.7, changes the memory structure a little bit, so while the general techniques are relevant, the specific addresses that I list for v1.6 will likely be wrong for v1.7. Let's continue, then, with Fate v1.6.
Shift-F12 launches the debugger, and if you're not very familiar with the 68000 family of processors, the first thing you see is a lot of intimidating and unnecessary complexity.
First: Hit F2 to clean up the mess a bit. Now the screen is mostly an empty workspace, with registers across the top and right, and the command line at the very bottom.
Within this command line, you can type ? and hit enter to see a list of valid WinUAE commands and their syntax. Still, this list is a bit disorganized and can be confusing.
It's important to notice that WinUAE debugger commands are case sensitive: "m" is not the same as "M".
The commands we use the most are:
m <address> [<lines>] List Amiga memory starting at <address>.
W <address> <hex formatted bytes> Write into Amiga memory starting at <address>.
Here's a quick example of how we can use these commands. At the command line, type the following, followed by enter:
m $50E74 $20
This says, show me the memory starting at address (hexidecimal) 50E74, and display (hexidecimal) 20 rows, which is 32 rows to us decimal people.
In WinUAE v1.6 WHDLoad, this will show you all 500 bytes that define Winwood's character. Because your characters are defined by 500 bytes, but each row holds 16 bytes, the last line also includes the first 12 bytes of the next character's name, or is blank if you haven't recruited anyone else yet.
What is all this hexidecimal stuff? Well, there is no need to really learn hexidecimal, since you can easily convert between decimal and hexidecimal on the debugger command line. Simply type ? followed by a number. The debugger will display hex, binary, and decimal equivalents of that number. Hex numbers will be preceeded by 0x or $, like this: 0xE or $E. Binary numbers will be preceeded by %, like this: %1110. Decimal numbers look just the way you type them, like this: 14. If you type in any of the following:
you will see the ways you can represent this number:
0x0000000E = %00000000000000000000000000001110 = 14
Once you know how these numbers look and how to convert them to and from decimal, there's no need to worry about the details. You'll learn by doing.
So, we know how to display Winwood's 500 defining bytes. What can we do with that?
The [UBER] link at www.fategatesofdawn.com will display Character-Uber-Paste.txt. Copy and paste these bytes starting at $50EA1 to increase Winwood's cash, maximize his statistics, and give him ability to cast all of the spells in all 20 schools of magic.
Let's do that with WinUAE's debugger. Unfortunately, WinUAE's write command can only accept 30 bytes at a time, so we have to break those memory writes into six different write commands.
Using the command prompt, we want to write those uber bytes to Winwood's memory starting at $50EA1, using these commands, followed by enter:
W $50EA1 00 01 ff ff 00 ff 00 ff 00 ff 00 ff 00 ff 00 ff 00 ff 00 ff 00 ff 00 ff 00 ff 00 ff 00 ff
W $50EBF 00 ff 00 ff 00 ff 00 ff 00 ff 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a
W $50EDD 7F FF 7F FF 7F FF 7F FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4A 00 00 00 00
W $50EFB 00 00 00 00 38 37 00 00 00 00 00 00 00 26 00 00 00 00 00 00 00 00 1D 00 00 00 00 00 00 00
W $50F19 00 21 00 00 00 00 00 00 00 00 20 27 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
W $50F37 00 00 00 02 01 01 00 00 7F FF 7F FF
That should have been a simple exercise in copy-paste-enter, and now you're uber-Winwood!
Summarizing, I think you can see how to access the debugger, how to get a clear and useable screen, how to read memory, and how to write memory. When you're done, just close the debugger window.
With these tools that are built right into WinUAE, we can start correlating WinUAE memory to in-game events, which begins to break the code of how Fate was put together.
By interesting coincidence, on my display, the maximum number of memory rows that the debugger buffer can hold is 248 rows, which equals 0xF8 in hexdecimal. That's humorous, because when you're examining great swaths of memory, you often find yourself typing into the command line:
m <address> F8 - that is, F8=Fate, right? Get it? Hahahaha.
...Ok... (pouting) another nerd joke that cannot cross the language barrier.
Wishing you the best of luck and happy hexadecimal hunting,
Rangerous the Second