Post subject: event.onmemorywrite() Addresses
Blizihguh
He/Him
Joined: 9/27/2015
Posts: 1
Hi fora. I'm currently facing a bit of a dilemma: there's a game I like (Summon Night: Swordcraft Story 3), and it's translated, but nobody's put the text into the rom yet, because romhacking is hard. I sorta get the impression that nobody wants to actually deal with inserting the translated script in it, because it's such a pain. And I don't either, because I don't know how. But I do know how to write lua script, and I have a bunch of text files of the translation organized by pointers to where the matching script is in the rom, and suddenly the solution seems pretty clear: write a script to check what text is being output in the text box, then look up the matching translation and print it to the console (and then if I'm feeling fancy once I know it works, draw it on the screen). Shouldn't be too hard! ...if I can figure out what's being written onscreen. My initial inclination was to try RAM Searching for addresses that look like they contain either text (via the text table I found from the romhacking team that's been working on this for, like, five years now. Thanks guys! Sorry romhacking is so hard) or pointers to the text in the rom, since I have both of those. But I doubt the addresses will be there for more than a few frames, and as far as I know you can't really use breakpoints with RAM Search, so until I figure out what addresses to look at I can't really do that. So my current plan is to write a script that checks every memory write to see if the address looks like text, and if it does, log which address it was. But event.onmemorywrite() doesn't seem to give the address back as an argument, like the original feature request suggested. So basically my options are, write that script but manually include a hook for each address (so, one hook that says "if 0x0000 gets written to, check 0x0000", another that says "if 0x0004 gets written to..."), or figure out how to check the address that gets written to. Option one seems like a lot of work, though. So if anyone can point me towards how to do that other thing, or wants to share advice in determining what's being written onscreen in general, I'd be really appreciative. TL;DR: How do I determine what address is written to when event.onmemorywrite() fires, assuming I haven't specified one to it? Any other advice for determining what text is being displayed onscreen?
Editor, Emulator Coder
Joined: 8/7/2008
Posts: 1156
I think the right way to do this is to romhack it enough to find the program subroutine that processes or prints text, or is some part of the chain in preparing it for display. Put an execute breakpoint on that, and at that point youll know where the text parameters are being stored (on stack, in registers) If what you're asking about is how to _find_ that place to put the execute breakpoint, then: use a debugging emulator and reverse engineer the code. You can start by looking at the code that populates the VRAM containing the text; it's probably the final string printer (names and numbers will have been substituted). Youll have to go up some more steps to find the original raw string, if you need to. I think it's probably still about 2% as hard as a complete rom hack. You know what address is written to when event.onmemorywrite() fires by creating a unique function for each address. pseudocode:
for(int addr in 0x100 .. 0x120) event.onmemorywrite(function() mywritecb(addr) end)
brandaman has some useful ideas, but that's just not how it's gonna be for now.