Dolphin, the GameCube and Wii emulator - Forums

Full Version: [SOLVED] Recompiling Dolphin to set memory read breakpoint
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

Dashman

Hi people, I'm part of a little team trying to translate Super Robot Wars GC. We've already located most of the text in the ISO's files and some hacking has been done. Now we're turning our attention to implementing a VWF routine to make the translated text look nice, which implies ASM hacking, and... we've run into some trouble.

The first step for making a VWF routine is finding the font in memory. That's done. After dumping the memory (MRAM), we found it going from 0x0081baa0 to 0x008b757f.

The second step is finding the routine that reads the characters from that location. We got our hands on a DebugFast build of Dolphin 4.0 and set some memory checks at the beginning of the font block and the beginning of a specific character, but the breakpoints were never triggered.

After some googling, we learned that Dolphin's debugger doesn't work very well with memory checks, and we found an old post where skid suggested a way around this issue: rebuild the emulator with a modified ReadFromHardware function that produces a break when the wanted memory address is accessed (here's that post: https://forums.dolphin-emu.org/Thread-ho...in-dolphin )

I've downloaded the project's files following the steps given without any issues, but the file MemoryFunctions.cpp is nowhere to be seen. Considering that post is 4 years old, I assume there's a lot of things that have changed in the code.

So, my question is: what do I have to add and where to trigger a break when a specific memory address is accessed?

Oh, also I'm a bit confused as to which address is the one I should be using. I used the disassembler VDAPPC (from this page: http://hitmen.c02.at/html/gc_tools.html ) on the memory dump and found that the character I was monitoring was present at a different address. In Dolphin's memory viewer it would be 0x008b0028, but in the disassembled memory dump it's located at 0x808b3128. Which one should I use?

Thank you for your time.
MemmapFunctions.cpp?

Dashman

(06-08-2014, 09:42 AM)RachelB Wrote: [ -> ]MemmapFunctions.cpp?

Oh, silly me, I tried looking for "Memory" and didn't find it. Thanks.

I've added this code at the beginning of ReadFromHardware:

// Alert when reading the S character in SRW GC:
if (em_address == 0x8081eba0 || em_address == 0x0081baa0) // Beginning of font block
CCPU::Break();
else if (em_address == 0x808b1ed4 || em_address == 0x008aedd4) // Beginning of font file
CCPU::Break();
else if (em_address == 0x808b3128 || em_address == 0x008b0028) // Beginning of character block
CCPU::Break();
else if (em_address == 0x808b312a || em_address == 0x008b002a) // Beginning of character tile
CCPU::Break();

But I don't get any breaks. I'm positive the font is being read from these addresses because corrupted data is shown on screen. What could I be doing wrong?


EDIT:
We figured it out. The breakpoints only activate if the emulator is running in interpreter mode (JIT -> Interpreter core). The previous addresses didin't trigger it for some reason though, this line did:

if (em_address == 0x80819782 || em_address == 0x00816682) // Beginning of first dialogue
CCPU::Break();

We ran the game until the part before the first dialogue was used in normal mode, turned on interpreter mode and the break was triggered when we entered the scene.

Hopefully somebody else finds this useful.
The breakpoints are not being triggered in JIT mode because of Dolphin's fastmem feature.

Using JIT with fastmem disabled will make the emulator a bit faster than running it in Interpreter.

To disable fastmem, look in dolphin.ini, and add/change this line under the [Core] section:
Code:
Fastmem = False

Dashman

(06-09-2014, 11:25 AM)skid Wrote: [ -> ]The breakpoints are not being triggered in JIT mode because of Dolphin's fastmem feature.

Using JIT with fastmem disabled will make the emulator a bit faster than running it in Interpreter.

To disable fastmem, look in dolphin.ini, and add/change this line under the [Core] section:
Code:
Fastmem = False

I just tried this and the breaks didn't happen, although I'm not sure if I did it right because I was getting pretty much full speed. If you meant the Dolphin.ini file inside User/Config, setting Fastmem to false (under [Core]) doesn't make programmed breaks work (or at least not the ones I programmed inside ReadFromHardware).
Yes, that is what I meant.

The only other thing I could think of was that the game is reading the address using a 16bit/32bit read which does not fall on the addresses you have added in the code. For example, the game may be using a 32bit read at 0x808b1ed2 to read the value at 0x808b1ed4. However, as the interpreter works, then this cannot be true.