Displaying full-screen images

From GbdevWiki
Revision as of 19:24, 19 July 2011 by Nitro2k01 (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.


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