News: 11 March 2016 - Forum Rules

Author Topic: NDS text positioning help  (Read 11591 times)

matthewn4444

  • Jr. Member
  • **
  • Posts: 26
    • View Profile
NDS text positioning help
« on: November 27, 2011, 02:43:25 pm »
Hello, I have been working on a translation hack for 7th Dragon for over about 2 months and I got the basis of variable width font almost complete. I am placing fixing up and inserting font bitmaps currently but I hit a problem.

The image above shows a screenshot of the skills menu. Because each font tile is 10px X 10px, my font would appear to be 2px higher than everything else (not that the end result would keep the Japanese text) but the English font (in this case "POW") seems way to high in the image. I was wondering if there was a way to move the text down. I do know basic assembly (as I did implement variable width font) but I do not know how text can be placed on the screen at an x and y position (that I am assuming is somewhere in memory). no$gba shows that the top screen is rendered through 3D (so I guess that is for translating and rotating the images/text easier).

Ryusui

  • Hero Member
  • *****
  • Posts: 4989
  • It's the greatest day.
    • View Profile
    • Tumblr
Re: NDS text positioning help
« Reply #1 on: November 27, 2011, 02:52:10 pm »
Okay, quick question. Does the game use a standard NFTR for its font? If so, it might have an English font already built in. If you've confirmed that it doesn't, you might be able to copy the NFTR from another game that does have an English font.

At any rate, if your English font is the same size as the Japanese font, just move it down a couple of pixels so it shares the same baseline as the Japanese font.
In the event of a firestorm, the salad bar will remain open.

matthewn4444

  • Jr. Member
  • **
  • Posts: 26
    • View Profile
Re: NDS text positioning help
« Reply #2 on: November 27, 2011, 03:18:51 pm »
The game does not support NFTR fonts or has an English font inside (or else someone would have translated it already). I already placed in some font bitmaps and implemented variable width font (as mentioned earlier) because those don't exist.

The image above is the same image but shows if I replaced the "W" with a "g". You can see that I made the capital letters that high (eg. "P" and "O") because the "g". "p", "q", "j", "y" characters need to be below the baseline so that the characters look "normal" since the font tile is 10px by 10px, the font has to look like that. I am sure that there is a pointer or some sort of value that specifies the font x and y position. I was wondering if that is hardcoded in the files or any common standard place that devs put it to point me in the right direction to bring the font down.

Ryusui

  • Hero Member
  • *****
  • Posts: 4989
  • It's the greatest day.
    • View Profile
    • Tumblr
Re: NDS text positioning help
« Reply #3 on: November 27, 2011, 04:15:04 pm »
If you've implemented a VWF already, then you're halfway there. Just trace the code and find out how the start address for the printing routine is calculated.
In the event of a firestorm, the salad bar will remain open.

matthewn4444

  • Jr. Member
  • **
  • Posts: 26
    • View Profile
Re: NDS text positioning help
« Reply #4 on: November 27, 2011, 04:36:38 pm »
I am not sure what you mean by printing routine. I know that there is a place in the code where the font tiles are drawn to (this is where my WVF works in). These areas are tailored to 10px height (so trying to draw below or above this limit is ignored). Do you think that there could be another drawing routine that specifies where these bunch of font characters gets placed to?

It does some funky stuff with it after, I am sure, probably to redraw it in another location (I have to do more investigation). However I believe if the text is being drawn, it should be drawn to some location larger than 0x400000 or something? I looked around a few weeks ago and found my self nowhere :\

Ryusui

  • Hero Member
  • *****
  • Posts: 4989
  • It's the greatest day.
    • View Profile
    • Tumblr
Re: NDS text positioning help
« Reply #5 on: November 27, 2011, 05:05:29 pm »
I mean, how is the text put together on screen? If the text is sprite-based, it's possible you might be able to reposition it by changing the OAM data.
In the event of a firestorm, the salad bar will remain open.

matthewn4444

  • Jr. Member
  • **
  • Posts: 26
    • View Profile
Re: NDS text positioning help
« Reply #6 on: November 27, 2011, 05:22:19 pm »
I think it is sprite based.

Above is a screenshot of no$gba and it shows the location for that text. I think because it is displayed like this, it is a sprite (and I guess 3D?). How does one reposition the sprite by changing the OAM data? Oh and by the way, I have no idea how to use this window in no$gba, I mainly use the dissembly tools and memory, if this window helps me with the addresses and repositioning, I would love to have more detail of this.

Edit:

I took a screenshot of the OAM (don't know if this is correct) but it looks like there nothing there. I also have the memory starting at the 0x700000h address showing the OAM contents. Are those images based off sprites?

Image: http://imageshack.us/photo/my-images/573/captureoh.jpg/

« Last Edit: November 27, 2011, 06:03:28 pm by matthewn4444 »

Ryusui

  • Hero Member
  • *****
  • Posts: 4989
  • It's the greatest day.
    • View Profile
    • Tumblr
Re: NDS text positioning help
« Reply #7 on: November 27, 2011, 06:08:42 pm »
Okay. It is being drawn to screen using the 3D functions - which means much the same as if it were sprite-based; i.e. we can change the x-y position on screen. I don't know the specifics of how it's done, but you should be able to figure it out with a little research - no$gba itself comes with extensive documentation.

But I have to ask: are you absolutely sure you want to? Don't forget, any "hangers" will run the risk of brushing up against whatever's below the text - like the inventory counter, or even the bottom edge of the text box.
In the event of a firestorm, the salad bar will remain open.

matthewn4444

  • Jr. Member
  • **
  • Posts: 26
    • View Profile
Re: NDS text positioning help
« Reply #8 on: November 27, 2011, 06:13:28 pm »
Hmm... I see, I guess I will have to look that up (hopefully not too hard to find XD) or if anyone else on this board knows how to do it that would be great. XD
Thanks for your help Ryusui. I am doing this because I think it looks kind of wierd being too high in that box surrounding the text. I mean I will probably do this after I finish inserting the font and the fully implementing vwf (on all fonts, there are a few in this game).

Auryn

  • Hero Member
  • *****
  • Posts: 650
    • View Profile
Re: NDS text positioning help
« Reply #9 on: November 28, 2011, 09:39:39 am »
If I am not wrong. if you press the + on the right plane of No$GBA, and click the item that will appear there, your left plane will contain the X and Y coordinates... that Y coordinate is the one you are looking for.

Maybe try to make a memory dump with Desmume and search if you can find that screen in the memory...that could help you as well.

If you have asm basic, you could maybe try to cheat the game to believe it has an 10x12 font and not a 10x10.

matthewn4444

  • Jr. Member
  • **
  • Posts: 26
    • View Profile
Re: NDS text positioning help
« Reply #10 on: November 28, 2011, 03:04:02 pm »
If I am not wrong. if you press the + on the right plane of No$GBA, and click the item that will appear there, your left plane will contain the X and Y coordinates... that Y coordinate is the one you are looking for.

Maybe try to make a memory dump with Desmume and search if you can find that screen in the memory...that could help you as well.

If you have asm basic, you could maybe try to cheat the game to believe it has an 10x12 font and not a 10x10.

How would you search for the screen in memory?
Also I am guessing I have to find the routine to change the height from 10->12?

Auryn

  • Hero Member
  • *****
  • Posts: 650
    • View Profile
Re: NDS text positioning help
« Reply #11 on: November 29, 2011, 12:43:07 pm »
Using Tilemolester, CristalTile or some other graphics viewer.

Yes, you have to find the routine and maybe change the font as well...depends on the game.
Anyway even if you have to change the font, it will be faster than edit all the coordinates of all places where the text will appear.

Normmatt

  • Full Member
  • ***
  • Posts: 141
    • View Profile
Re: NDS text positioning help
« Reply #12 on: November 29, 2011, 09:06:22 pm »
Assuming you actually implemented a VWF and not just used a built in one you should have more than enough skill to fix this most simple of problems.

matthewn4444

  • Jr. Member
  • **
  • Posts: 26
    • View Profile
Re: NDS text positioning help
« Reply #13 on: November 29, 2011, 09:14:39 pm »
Assuming you actually implemented a VWF and not just used a built in one you should have more than enough skill to fix this most simple of problems.

That's what you think. :P I am still learning the ways of asm and nds hacking. This is my first vwf (probably this game is easier than others). I am slowly learning how to fix this. However I am looking into the memory dump and seeing if I can find the x, y positions of those sprites and start working backwards.

Normmatt

  • Full Member
  • ***
  • Posts: 141
    • View Profile
Re: NDS text positioning help
« Reply #14 on: November 29, 2011, 11:10:22 pm »
Can you post more details on what functions your VWF patchs/hooks so that we can help trace it back to where its actually drawn to the screen.

matthewn4444

  • Jr. Member
  • **
  • Posts: 26
    • View Profile
Re: NDS text positioning help
« Reply #15 on: November 29, 2011, 11:35:04 pm »
I hook at a few locations. For this font set, I analyze the character at 0x203BA78 and jump to my code here; this gets the character (eg. 81FA = a) and looks it up in a table i have in the assembly file. Places that width in memory for later use. The character drawing routine starts at 0x203B1DA.

In this game, each hex digit represents 2 pixels (backwards, forgot the technical term) horizontally. The character tile is 10px X 10px, so then then in memory, it has 5 hex digits making that 3 bytes of hex (or 3 pairs of digits; probably using the wrong terminology). Anyways, my routine essentially reads the x-offset or current length and redraws the character into memory after finding the correct address to draw to. Then add to make the new current length and move on to the next character. I recently found that (when inside the skills menu) the skills are presented in text at location around 0x2B12300. That is the location where the x and y locations are kept I believe (did some random number changing and stuff happened). Right now I am busy with school so I come back to this once in a while.

I open sourced it to keep track of the changes: http://code.google.com/p/7th-dragon-translation/
It's probably horrible asm code since this is my first project using arm asm. (Don't worry, I have comments).

Normmatt

  • Full Member
  • ***
  • Posts: 141
    • View Profile
Re: NDS text positioning help
« Reply #16 on: November 30, 2011, 12:13:46 am »
Just a note storing your code at 0x23fa000 will be overwritten by all flashcarts.

matthewn4444

  • Jr. Member
  • **
  • Posts: 26
    • View Profile
Re: NDS text positioning help
« Reply #17 on: November 30, 2011, 12:15:34 am »
Really? I only test on Acekard so I am not sure. I can't find another place in memory to put it in, any suggestions? (I had this trouble 2 months ago =___=).

Normmatt

  • Full Member
  • ***
  • Posts: 141
    • View Profile
Re: NDS text positioning help
« Reply #18 on: November 30, 2011, 12:21:34 am »
Really? I only test on Acekard so I am not sure. I can't find another place in memory to put it in, any suggestions? (I had this trouble 2 months ago =___=).

Thats because there is no safe place to put in memory that flashcarts dont already use for cheats/patches etc. The only other way is to remove any useless code in the arm9 binary itself and use that but seeing as your code is quite large I doubt you'll be able to find enough free space :(

matthewn4444

  • Jr. Member
  • **
  • Posts: 26
    • View Profile
Re: NDS text positioning help
« Reply #19 on: November 30, 2011, 12:26:03 am »
How are many line does vwf usually take? (I have absolutely no idea). I'm not sure about how other games draw characters but I found that 7th dragon somewhat compresses pixels (which is guess is normal). So all flashcards won't work or just if they enable cheats? I know I placed the code near the end of memory.