Displaying full-screen images

From GbdevWiki
Jump to: navigation, search

Software needed

Step 1

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

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

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

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

Save the image as a pcx file.

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

     // 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)

     // Show the background

     // Turn the display on

Compile and done

After compiling and running my output looked like:

Your compiler may give the error "abnormal program termination". To fix this, modify your .c and .map files so that the data is an "unsigned const char" instead of "unsigned char". This will keep this data in ROM, as opposed to loading it in memory.