NES Text Hooker

Ugly Joe

New member
I was trying to put a DTE hack into a game yesterday (which turned into me figuring out how to expand a mapper 1 game to make room for a DTE hack...) when I got an idea for an text hooker. A text hooker, or at least what I'm calling a text hooker, is a program or function that hijacks the text output of a game (in realtime) and outputs somewhere else so that you can copy/paste or whatever you want with it. What I would want to do is hook the text out of a Japanese NES rom so that you could copy/paste it into a translator (or have the program do it automagically).

Whenever I try to put in a DTE hack, one of the first steps is finding the place in memory where the game stores the address of the next character to be outputted. This location is usually read by some function in the game that takes that byte and outputs the proper tile onto the screen. The DTE hack would change that address to what it wants the game to output. Hopefully that makes sense to anyone who's done it before.

How I figure the text hooker would work would be that you'd have to provide to it:
1) That memory address containing the address of the next character.
2) A table file (or files) for translating the byte at that address to a character.

The text hooker would moniter that address and, whenever it changes, look up the corresponding character in the table and output it to a textbox.

Before I start poking around with fceuxd's source code, I wanted to get some input from everyone else. Does it sound possible? Does it sound easy? Any potential problems (I'm sure there is..)?
 
> Before I start poking around with fceuxd's source code, I
> wanted to get some input from everyone else. Does it sound
> possible? Does it sound easy? Any potential problems (I'm
> sure there is..)?

Games do not have a RAM location for the next byte usually. It just loads it from ROM into the space alloted in RAM for text data one byte at a time (in the case of the NES...SNES could use MVN or even DMA). In Hanjuku Hero, the game has a routine for the dakuten marks, so that a one byte value is assigned to them. After a certain value (ie, higher thanl the highest byte value for normal characters), the game subtracts a number (#$C4 in the case of Hanjuku Hero) and checks to see if the carry flag is set (which means that the value is over #$C4), and starts putting dakuten marks above the characters if it is. #$C5 would be the value of the first character to have a dakuten mark above it, #$C6 would be the second, etc, the characters that have dakuten above them are determined by the order they appear in the font. There is no lookup table or anything.

The text is stored in RAM before being sent to the PPU. The game takes where in RAM the text data is currently being copied to and subtracts #$1A (the amount of bytes needed to get above the character, on line above it) and copies a dakuten mark.
Dakuten marks have their own separate line, so if you view the RAM it'll have a line of dakuten and a bunch of spaces, and then a line of text, then dakuten, then text

What I did, was make it so that if the game goes to the routine to put dakuten marks above letters, it jumps to my own routine I coded and put at the end of the game, which utilizes a table that also has to be inserted. In the table is two bytes, each one being which letter is used in a particular DTE value. The routine looks up the corresponding two bytes in the table, and copies them to RAM. Then, you have DTE once you input the table...<P ID="edit"><FONT class="small">Edited by JadussD on 06/18/05 02:26 PM.</FONT></P>
 
Um...I'm not quite seeing how this applies (you're talking snes, I'm talking nes). The nes games that I've looked at do have a location in ram where it writes the address of the next character byte. You do raise a good point regarding the dakuten marks, though.

Hanjuku Hero for nes handles them differently than how you mentioned. It actually has a character for the marks and when it reads the byte for it, it will place it in the row above the previous character. I would not doubt there are nes games that use the same method as the snes version. I've even seen some games where it will write full line of spaces and marks, followed by a line of kana. That would be a nightmare to parse.

Thanks for the input.
 
> Um...I'm not quite seeing how this applies (you're talking
> snes, I'm talking nes). The nes games that I've looked at
> do have a location in ram where it writes the address of the
> next character byte. You do raise a good point regarding
> the dakuten marks, though.

You know, to some extent I was talking out of my ass. I somehow misinterpeted what you meant by a byte that has the next value...There's definitely a byte that contains the location in RAM that text will be written to in any game that has text in it, yeah, sorry, I'm an idiot :)

In the game, can you see the text being written to the text box one letter at a time? If so, to get the that RAM address, does your emulator have a cheat search feature, as well as an advance one-frame-at-a-time feature? Just wait til text is being written, then pause the emulator, open cheat search, advance one frame, and search for values that are greater than, advance frame, search for greater values, ad nauseum until you have one value left, and that's your value.
 
Yeah, I can find the memory location without too much effort. Locate the text string in the rom (between $8000 and $ffff), put up a read breakpoint for that range, go talk to the person that says that text string. When it hits the breakpoint, it should be at an LDA ($##), Y instruction. $## is the address you want. Results may vary, but that'll work for almost all nes games.
 
> Yeah, I can find the memory location without too much
> effort.

You know, I have no idea why the hell I thought you wanted to know an easy way to find the location of the RAM address. Your first post asks absolutely nothing of the sort. In fact, you basically said that you've done it before. Wow. I need more sleep. That idea for your program is great though, I'd give it a shot for sure.
 
*bump*

I decided to try and make this thing afterall. Since I couldn't think of a way to handle dakuten and pointers using the method I explained before, I decided on a different one. This way lets the user select tiles off of the background (the background being the current screen minus the sprites) and then having the program scan those tiles against a table. Easier said than done, but I managed to get it to work.

Here's some screenshots:
http://www.ximwix.net/storage/texthooker3.gifSome names and dialogue.</a>
http://www.ximwix.net/storage/texthooker2.gifA small menu.</a>
http://www.ximwix.net/storage/texthooker1.gifA store menu.</a>

I'm not quite ready to release it, but I should have something ready by next week. I'm looking for a few people to test it out before I make it public, mostly to see how it acts on installations of Windows that are lacking support for Japanese text display and/or Japanese text input. If you can help me with testing, PM me and I'll get the files to you when they're ready.

Oh, one important question, since I'm building this on top of fceuxdsp, which is GNU, is it simply a matter of releasing the source code along with the binaries, or is there more to it than that?
 
*ultra bump*

Anyone remember this thread? <img src=smilies/magbiggrin.gif>

I finally got around to finishing this thing. You can download it http://ximwix.net/xb/texthooker.htm#downloadsfrom my website</a>. I started a fork of fceuxdsp called fceuxdsp championship edition (fceuxdspce) to distribute this any other emulation ideas that I get (I know what I'm working on next already). I tried to make the documentation as useful as possible, so I hope it's good enough.

Any questions or comments, feel free to let me know.
<P ID="signature">_______________________________________
</P>
 
Re: *ultra bump*

> Any questions or comments, feel free to let me know.

just one, why champion edition? it already has a "ce" in it, why not somehow encorperate all the letters in the english alphabet into it =)

anyway, this thing looks great, cant wait to test it. (after work tomorrow *falls over*)
<P ID="signature"><hr>
Ludvuck Foruk: Thats your first problem...thinking your a panda...
sephiroth111: and once again, i am totally confused as to whats going on.</P>
 
Re: *ultra bump*

> just one, why champion edition? it already has a "ce" in it,
> why not somehow encorperate all the letters in the english
> alphabet into it =)

The name was already rediculously long, so I was reminded of the Street Figher series. It honestly never occured to me that 'ce' was already in there.

> anyway, this thing looks great, cant wait to test it. (after
> work tomorrow *falls over*)

Ah, I hope it works. The interface is pretty ugly, so look out <img src=smilies/magbiggrin.gif>
<P ID="signature">_______________________________________
</P>
 
Re: *ultra bump*

> Ah, I hope it works. The interface is pretty ugly, so look out

Dont worry about it too much, you can improve it with time. its functional, and thats all that matters.
<P ID="signature"><hr>
Ludvuck Foruk: Thats your first problem...thinking your a panda...
sephiroth111: and once again, i am totally confused as to whats going on.</P>
 
Back
Top Bottom