Zophar's Message Domain

Go Back   Zophar's Message Domain > Emulation Talk > Rom Hack

Reply
 
Thread Tools Display Modes
Old 06-18-2005, 04:59 PM   #1
Ugly Joe
Senior Member
 
Ugly Joe's Avatar
 
Join Date: Dec 2003
Posts: 1,461
Default NES Text Hooker

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..)?
__________________
Ugly Joe is offline   Reply With Quote
Old 06-18-2005, 07:24 PM   #2
JadussD
Senior Member
 
Join Date: Jan 2003
Posts: 2,100
Default Re: NES Text Hooker

> 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>
JadussD is offline   Reply With Quote
Old 06-18-2005, 09:48 PM   #3
Ugly Joe
Senior Member
 
Ugly Joe's Avatar
 
Join Date: Dec 2003
Posts: 1,461
Default Re: NES Text Hooker

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.
__________________
Ugly Joe is offline   Reply With Quote
Old 06-18-2005, 10:15 PM   #4
JadussD
Senior Member
 
Join Date: Jan 2003
Posts: 2,100
Default Re: NES Text Hooker

> 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.
JadussD is offline   Reply With Quote
Old 06-18-2005, 10:40 PM   #5
Ugly Joe
Senior Member
 
Ugly Joe's Avatar
 
Join Date: Dec 2003
Posts: 1,461
Default Re: NES Text Hooker

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.
__________________
Ugly Joe is offline   Reply With Quote
Old 06-18-2005, 10:49 PM   #6
JadussD
Senior Member
 
Join Date: Jan 2003
Posts: 2,100
Default Re: NES Text Hooker

> 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.
JadussD is offline   Reply With Quote
Old 07-15-2005, 04:41 AM   #7
Ugly Joe
Senior Member
 
Ugly Joe's Avatar
 
Join Date: Dec 2003
Posts: 1,461
Default *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?
__________________
Ugly Joe is offline   Reply With Quote
Old 07-19-2005, 12:59 AM   #8
CROcOp
Senior Member
 
Join Date: Sep 2004
Posts: 196
Default Re: *bump*

Man, you're fast. I never thought this is possible...
CROcOp is offline   Reply With Quote
Old 07-25-2005, 06:13 AM   #9
Ugly Joe
Senior Member
 
Ugly Joe's Avatar
 
Join Date: Dec 2003
Posts: 1,461
Default getting closer

I've gotten it to actually translate the text now. Rather than continually spamming here, I put up a progress page located at:
http://www.ximwix.net/xb/texthooker.htmhttp://www.ximwix.net/xb/texthooker.htm</a>.

I would put the url in my signature, but, you know...
__________________
Ugly Joe is offline   Reply With Quote
Old 07-25-2005, 04:48 PM   #10
CROcOp
Senior Member
 
Join Date: Sep 2004
Posts: 196
Default Re: getting closer

This could be the best hacking tool ever, after Nesticle....
CROcOp is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:47 AM.

Contact Us - Zophar's Domain - Archive - Top

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.