#6702 - akrocks - Mon Jun 02, 2003 2:49 am
I'm just trying to learn how to program for gba so I'm going to start out with some thing pretty simple. What I want to do i write text on to the screen and be able to scroll through it. I've never used text so I need to know how to create a font load it and use it.. thanks.
_________________
Projects: Learning all this jazz...
#6704 - niltsair - Mon Jun 02, 2003 3:41 am
Well, the easier method would be to :
1. Create a 768x8 bitmap that contains the 32-128 ascii characters, in the rigth order. Each character should takes 8x8pixels.
2. Store this bitmap in your rom, using the methofd you want (usually as a header)
3. Create a function that copy to the screen every character, one by one, pixel per pixel. To find where each pixel is, you only need to calculate the index in your Ascii bitmap:
- (Char value-32) * 64 + CurrentPixel
As to how it's written to the screen, it depends on the screen mode you are in, and you don't have to create 8x8 character.
#6732 - Sweex - Mon Jun 02, 2003 12:30 pm
Instead of drawing the sprite pixel by pixel, you can also copy the entire bitmap (8x8 pixels, 256 characters, exactly like ASCII) into video RAM to the right position. Now you can simlpy fill the tilemap with ascii codes and you will have text! This will work in all bitmap modes.
I can pass you a pcx with the full ASCII character set (8x8) if you want.
You will have to know a little bit more about how backgrounds work than Niltsair's way but you can now scroll the text and put it on top of other backgrounds...
#6743 - niltsair - Mon Jun 02, 2003 2:37 pm
This does not work in mode 3,4,5 where the screen is used as a bitmap and not a tilemap. I wanted to be mroe general.
Sweex's solution is fine, given you're willing to lose the use of 1 layer. If not then your alternative are :
-Copy each character's pixels over what's currently displayed (mode 3,4,5).
-Copy each character's pixels in sprites tiles memory, and use 6 64x64 sprites to display text (covers 240x128 pixels).
Sweex's solution is way easier to start with though. So give it a try if you're using one of the display 0,1,2 mode.
#6759 - akrocks - Mon Jun 02, 2003 4:14 pm
is there any examples on this? i learn best if i see the code... thanks.
_________________
Projects: Learning all this jazz...
#6769 - akrocks - Mon Jun 02, 2003 5:50 pm
I found an example http://www.gbadev.org/download.php?section=demos&filename=text.zip
but when i try to compile it i get this:
Quote: |
--[++++++++++++++++staringmonkey's Auto-Compiler++++++++++++++]
------[++++++++++++++++++Assembling boot.asm++++++++++++++++++]
'armasm' is not recognized as an internal or external command,
operable program or batch file.
------[++++++++++++++++++Assembling data.asm++++++++++++++++++]
'armasm' is not recognized as an internal or external command,
operable program or batch file.
------[++++++++++++Compiling C Source (Errors.txt)++++++++++++]
'zarmcc' is not recognized as an internal or external command,
operable program or batch file.
------[++++++++++++++++++Linking and Exporting++++++++++++++++]
'armlink' is not recognized as an internal or external command,
operable program or batch file.
Could Not Find C:\devkitadv\prog\text\*.o
|
_________________
Projects: Learning all this jazz...
#6771 - niltsair - Mon Jun 02, 2003 5:57 pm
Those compiler don't come with DevKitAdv, they're official dev tools (meaning you have to pay a max for them) You'll have to create another makefile, for DevKitAdv.
#6779 - tepples - Mon Jun 02, 2003 6:21 pm
Two scrolling text demos that work with DevKit Advance can be found at my GBA page. Look for "GBFS" and "AGBTTY".
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#6780 - akrocks - Mon Jun 02, 2003 6:37 pm
no, i mean scrolling by using the arrow keys.
_________________
Projects: Learning all this jazz...
#6790 - Sweex - Mon Jun 02, 2003 10:20 pm
akrocks, download this file: http://www.sweex.dsl.pipex.com/GBAText.zip
Contains a very basic piece of code for putting some text on the screen...
(Oh, the file won't be there forever...)
#6795 - akrocks - Mon Jun 02, 2003 10:45 pm
im sure its a good one... but im having problems compiling it.. can you give me a make.bat file?
_________________
Projects: Learning all this jazz...
#6838 - Sweex - Tue Jun 03, 2003 10:13 am
I'm not using batchfiles but makefiles for building my projects. And as they are pointing to various locations on my harddrive I didn't supply mine as it would not work anyway.
Make your own batch- or makefile. If you don't know how yet then I suggest you figure this out first.
Good luck!