News:

11 March 2016 - Forum Rules

Main Menu

NDS text positioning help

Started by matthewn4444, November 27, 2011, 02:43:25 PM

Previous topic - Next topic

Normmatt

Quote from: matthewn4444 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.

Well I know for certain acekard shouldn't work along with the major players, scsd1/scds2/r4/ez5i/cyclods/edge/etc all use that memory for the patches to do to commercial games to make them run from the sd. Is it not possible to tweak the original font drawing code to take in a width? or was it coded by retards?

matthewn4444

Quote from: Normmatt on November 30, 2011, 12:30:38 AM
Well I know for certain acekard shouldn't work along with the major players, scsd1/scds2/r4/ez5i/cyclods/edge/etc all use that memory for the patches to do to commercial games to make them run from the sd. Is it not possible to tweak the original font drawing code to take in a width? or was it coded by retards?

Another person ahead of me (that has given up translating this game) had trouble with the font so he tried doing dual encoding (which I thought of in the past but probably not the best idea). The font in 7th Dragon has no "width counter". Anyways, it calculates the offset from the start at each time it draws a character (so it may have a counter?). Another issue I had was if the character has an odd width (like letter 'a' has 7px), you cant just copy source to destination directly, this causes me to decode 2 digits into 4 pixels, append it to the last set, then push 4 out, encode it and write etc. This made me do another 100 lines of code. I do have a supercard micro sd (not with me right now) but haven't tested with that.

Though 2 months ago I was thinking of overwriting over 0x2380000 after the game is initialized but have no idea if that parts gets recalled later on.

Auryn

I was wondering why you write that the font is a 10x10 when the font I see in the game is a 16x8  :o



matthewn4444

Quote from: Auryn on November 30, 2011, 07:28:02 PM
I was wondering why you write that the font is a 10x10 when the font I see in the game is a 16x8  :o


This game has tons of fonts (haven't found that one yet, thanks, leaves me with less work now) so I have to write vwf to accommodate all of them. Anyways the font I am talking about is 10X10 (in the game, it is drawn 12X10)


12X12 font (which is for story and system text) is:


These fonts are nice looking because they are the ones I put in the game.

Normmatt

Have you tried the simple solution of simply moving your font tiles down 2 pixels?

matthewn4444


Quote from: Normmatt on December 01, 2011, 05:52:26 AM
Have you tried the simple solution of simply moving your font tiles down 2 pixels?

As mentioned before, the text is 10px by 10px and so when the game copies text, moving it 2px down will get clipped off. If you meant to move each character 2px down in its bounding box, then 'g' would be cut off.

Auryn

Well, it's the first font you find in that file.
What is sure is that the first of your font you posted in the pics is not a 12x12 and both should not be NGP (neo geo pocket) format.
I can't tell you more because I don't stay at home to check.
Anyway it's strange you are able to make a VWF but not find the coordinates of that font.
You said that the text is created somewhere in memory and then transfered somewhere else meaning that you have at least 3 points where you can move the font.

matthewn4444

I am still new to rom hacking as I am still learning but I discovered the font through the debugger looking at addresses and such changing the tile format till the image is shown (2bpp). Anyways the main process that I can see so far is that it first copies character's pixels to an area of memory until the word or phrase is finished. Once the phrase is complete, the entire section of pixels is then copied to another place in memory as a sprite (probably when looking at the memory dump) and then gets composed to the screen (which I still have not yet found, might not be necessary).

The first location is held at width X 10px (in this instance) so when it copies (have not found yet) it only copies 10 px of height (I may have to find where it copies). After that I am unsure about the other 2.

Again, this is my first time doing vwf so I have no idea how it was done for other games but the x and y positions are not inside these routines (as far as I know of).

On a side note, how do you guys use CrystalTile2 so fast to find images? Usually it takes me a while and random configurations to see images (especially finding the palettes :S)

Gemini

The screen coordinates are probably defined though OpenGL-like commands to the GPU ports, which means you've got to find out what values they use first (they might not be pixel-precise values considering how OpenGL works with 2D). I'm not entirely sure if write breakpoints can be set on GPU ports, but you should give it a try and check what it stores when it defines vertex coordinates. Look for port 0x4000500 (BEGIN_VTXS) and 0x400048C (VTX_16), they should lead you somewhere.

Auryn

Quote from: matthewn4444 on December 02, 2011, 06:35:29 PM
it first copies character's pixels to an area of memory until the word or phrase is finished.

This is probably your first chance to make it copy 2 pxl lower.

QuoteOnce the phrase is complete, the entire section of pixels is then copied to another place in memory as a sprite (probably when looking at the memory dump)
And this is your second chance.

Find the images quickly is a matter of fantasy first (while reading the names of the files), logic (analizing the (tree) structure of the game), observation (a menu graphic will probably be 2/4 bpp but not 8 opposite to a "complex" background image will probably be 4/8 bpp and not 2bpp), observation 2 (depending of the bpp, you have another size of palette), knowledge ( being capable to use CT2 well and understand what each command means), knowledge 2 (know the image formats used by the NDS), intelligence (try to view a graphic when CT2 have a book icon in front of that file with the letters "LZ" is very stupid) and experience (by the look at the hex code, already have an idea of what you are looking at).

matthewn4444

Thanks Auryn, I will look into it more later (exams are coming up :D ).

On a side note to what Normmatt said earlier, I just tried it out on my sc rumble microsd and (obviously) it did not work. I haven't looked into it yet, but how do most flashcards patch games? The game runs up to a point and freezes at the time text is shown (up to where I start to jump to my code). Before that it would copy my code to a place in memory (0x23fa000) and I am assuming it's not copying my code that was appended to the arm7.bin file. Any suggestions how I can avoid this?

Normmatt

Quote from: matthewn4444 on December 02, 2011, 08:51:44 PM
Thanks Auryn, I will look into it more later (exams are coming up :D ).

On a side note to what Normmatt said earlier, I just tried it out on my sc rumble microsd and (obviously) it did not work. I haven't looked into it yet, but how do most flashcards patch games? The game runs up to a point and freezes at the time text is shown (up to where I start to jump to my code). Before that it would copy my code to a place in memory (0x23fa000) and I am assuming it's not copying my code that was appended to the arm7.bin file. Any suggestions how I can avoid this?

Flashcarts generally load their own code into 0x23fe000 - 0x23ff600 or atleast AKAIO does before launching the game. Generally 0x23fa000 - 0x23fe000 is handled by the game itself and isn't always free (on a per game basis). I'm not sure how slot2 carts work but they patch alot more than slot1 does but they generally dont load in any extra code into ram as they overwrite the games code to use slot2 from what I remember. So as long as your dont go over 0x23fe000 in memory you shouldn't have any problems with slot1 flashcarts except maybe woodr4/woodrpg/AKAIO where we patch out the first two opcodes of the arm7 and arm9 binaries to remove the annoying intros some releases have on them.