#23481 - analogbinary - Tue Jul 13, 2004 9:51 pm
Hi,
Ive just got started in writing code for the GBA. Ive got a few examples of writing text to the screen and i understand how it works. Im slightly confused about a few things however.
1.) Im using mode 3 (bg2 with 16bit image), and i need a big easy to read font 16x16 would be good, can i still use 128 sprites on screen at once if they are 16x16 rather than 8x8?
2.) Whats the easiest free way to make a font? I just need some characters in 16x16 in a easy to read font (arial etc). Any tools recommened? (im not to hot in graphics so im stuggling here)
I think thats it, Ive been searching forums + web for about 2 days now, and ive not got much closer. I would like the font to be converted into a header file that i can include as an array in C please.
Incase anybodies interested, im making a front end for an incar mp3 player, that will control a hacked about laptop/pc, via rs232 (in theroy), and obviously you need quite big bold fonts if you glance down when driving.
Thanks!!
#23499 - sajiimori - Wed Jul 14, 2004 6:40 am
1) yes
2) I typed a string with all the font characters in it (seperated by spaces), pasted them into a very wide photoshop image using the TrueType font I wanted, and then wrote a program to extract the characters (by looking for the spaces between letters).
Edit: If you're doing a fixed-width font, it's easier to extract the letters of course.
#23504 - analogbinary - Wed Jul 14, 2004 11:50 am
Thanks for the reply!
Is there a program that you could recommend that will turn a bmp of some characters into a C array? Most work, but they dont allways seem to accept an image that isnt 240x160 etc.
In mode 3 and BG2, is there any special things i need to take into account when converting the bmp of char's?
Cheers!
#23537 - johnny_north - Wed Jul 14, 2004 8:22 pm
I settled on gfx2gba 0.13 years ago and have done well with it since. It will convert the graphics the way you need and in a C array as well. It should also take a true color bitmap and convert it into 16 bit color data as well (read the readme.txt to confirm this).
I've also been able to meet all of my text requirements with a fixed width font - which as sajiimori indicates simplifies things.
And although you didn't specifically ask, I like to take the approach of making a 62 character tall (assuming numeral, lower and upper case english characters only of course) bitmap where all of the fixed width fonts are neatly stacked one on top of the other like so:
This way you can get at single character bits with a minimum of math - just use the ascii code of the character you need and adjust for its position in the array times the number of bytes in a single character:
Code: |
&CharGfxArray[('1' - 48)*512] |
will get you the address of the first pixel of '1' in a 16x16 16bit map of characters.
#23568 - analogbinary - Thu Jul 15, 2004 12:17 pm
Ok, that cleared up a few issues , thanks!
I made a bitmap, 16 wide and 416 down i think (just alphabet), convereted from bmp to C array with pallete. This all appears good, (im using mode 3 and bg 2).
When i run the .bin, the font is corrupted (unlike the previous 8x8). Is there anything dramtically different which needs to be changed in the code?
I suppose what im asking is, how is the code different for 16x16 than it was for 8x8 converted arrays? I dont have the code with me at the moment, so cant post it, but is there anything obvious that comes to mind?
Basically, ive got some 8x8 code that works, but when i use a 16x16 converetd font bmp to c array , its corrupted, do i need to totaly rewrite, or do i just need to edit some bits to allow for the 16x16 rather than 8x8. (as you can tell, im clueless in this)
#23572 - johnny_north - Thu Jul 15, 2004 2:43 pm
Just remember to calculate your memory strides correctly when writing the bitmap to the screen. If you're writing a single character to the screen and it seems to stretch and garble in either the horizontal or vertical, then you're not calculating the strides correctly (the correct place to start writing each horizonal line of the font to the correct vertaical and horizontal position on the screen).
On the other hand, if the font is scrambled but is contained within its original 16x16 boundaries, suspect (actually inspect) the data array and see if it seems to have converted properly.
#23575 - tepples - Thu Jul 15, 2004 4:08 pm
If you have VisualBoyAdvance, open the Tile Viewer and see what exactly is wrong.
I'm writing a tile converter that will allow for, say, 16x16 pixel metatiles stored in 1D order, making it somewhat easier to implement a text or sprite engine in that the artist will not have to maintain a tall and skinny source bitmap.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.