Displaying full-screen images

From GbdevWiki
Revision as of 01:00, 6 January 2013 by Paulc (Talk | contribs)

Jump to: navigation, search

Software needed

Step 1

Open the image you want to be displayed on the GB in the GIMP.
Burger1.png

Now we need to make this image an 8 bit pcx file.
Burger2.png

Go to Image -> Mode -> Indexed and change the max number of colors to 8.
Burger3.png

Resize the image to fit the GB's screen size.
Burger4.png

Save the image as a pcx file.
Burger5.png


Step 2

Now use this command with the image you saved in the same folder as pcx2gb:

 pcx2gb n d *imagenameyousaved*.pcx *tilesfilename*.c *mapfilename*.map

Press enter a few times and your tiles and map files will be generated.
Note: the screen may "glitch" up a few times and then turn black. This is normal. If you're stuck in the window, then CTRL+Tab out to return back. Also, the filename may need to be limited to 6 characters and not use hyphens. If the program doesn't work it's possible that the image was not in proper 4 color mode, but PCX2GB will not warn you of this.


Step 3

Now create your file to actually display the image on the GB.

 
#include <gb/gb.h>

#include "tiles.c"
#include "map.map"

void main()
{
     // Load up the tile data
     set_bkg_data(0,255,tiledata);

     // Switch to VRAM
     VBK_REG = 1;

     // Switch out of VRAM
     VBK_REG = 0;

     // Set screen x,y pos to 0,0 and draw the map 20,18(size of the screen)
     set_bkg_tiles(0,0,20,18,tilemap);

     // Show the background
     SHOW_BKG;

     // Turn the display on
     DISPLAY_ON; 
}


Compile and done

After compiling and running my output looked like:
Gbburger.PNG