The Opponent

A literal barrel of sunshine. *Contents may vary.

Using Demul and Cheat Engine for Memory Searching and Editing


This is a mirror of a page on the wiki for the Sakura Taisen 3 translation project with minor edits.

For the purpose of hacking Sakura Taisen 3, Demul is currently the only suitable emulator. Despite the lack of updates and known issues with performance, it is the only known emulator that supports this game and maps its emulated memory in a straightforward, 1:1 fashion. (As of July 2022, it is not compatible in MAME, which has a superior integrated debugger.) Where the Dreamcast maps memory in the range of 8c000000-8cffffff, Demul's own memory reserves the addresses 2c000000-2cffffff, exactly 0x60000000 bytes apart. This makes testing memory changes and replacements easy in a way that is not possible with other emulators. For all operations on memory, simply subtract 0x60000000 from any Dreamcast memory address to find the equivalent address in Cheat Engine.

As Demul has no debugging functions of its own, Cheat Engine is used as an ad-hoc debugger, memory viewer, and RAM dumping tool.

As both of these programs are only available for Windows, this guide assumes the use of Windows 10 or a similar version. Wine has not been tested.

This is a summary of information found in this Dreamcast-Talk thread, and practical examples of using Demul and Cheat Engine to change font widths, including the use of breakpoints, can be found there. That thread should be consulted for further instructions on the use of Cheat Engine for ROM hacking purposes.

Requirements


  1. Set up Demul according to your preferences and acquire the Dreamcast Japan BIOS files. Ensure that buttons are mapped for loading and saving states.
  2. Install the newest version of Cheat Engine.
  3. Load the game to be examined in Demul, then open the Demul process in Cheat Engine.
  4. In the Memory Scan Options in Cheat Engine, set the Start and Stop fields to 2c000000 and 2cffffff respectively before searching for values.

In the Demul settings, toggle Config > Pause when Focus is Lost as needed.

Memory Viewer Tips

  • Open a second window in the Memory Viewer using File > New window. This will allow for easier searching for addresses referenced by pointers while keeping the original position.
  • The keyboard keys - and + change the selected byte by 1.
  • Memory can be edited by directly pasting bytes into the Memory Viewer with Ctrl-V. This can be done for such tasks as testing custom assembly code before committing it in Ghidra, patching modified strings into a region containing script files, or—for Sakura Taisen 3—testing edited font tiles by pasting bitmap data into the SKFONT.CG region. Keep in mind that all such edits will be lost after loading a save state.
  • You may need to first Change page protection to Read/write in the right-click menu to make edits to the region of memory that contains the executable.
  • To save a RAM dump, open File > Save memory region (Ctrl-S). The Demul option Config > Pause when Focus is Lost should be enabled before doing this. In the From and To fields, enter 2c000000 and 2cffffff, and check the Don't include Cheat Engine header in file option. Save the file, dismissing the warning that Cheat Engine raises regarding the header. The saved memory region file should be exactly 16,777,216 bytes.