/* * images.c * this program demonstrates image files */ /* the width and height of the screen */ #define WIDTH 240 #define HEIGHT 160 /* include the actual image file data */ #include "image.h" /* the screen is simply a pointer into memory at a specific address this * * pointer points to 16-bit colors of which there are 240x160 */ volatile unsigned short* screen = (volatile unsigned short*) 0x6000000; /* the display control pointer points to the gba graphics register */ volatile unsigned long* display_control = (volatile unsigned long*) 0x4000000; /* these identifiers define different bit positions of the display control */ #define MODE3 0x0003 #define BG2 0x0400 /* place a pixel of a given color on the screen */ void put_pixel(int row, int col, unsigned short color) { /* set the screen location to this color */ screen[row * WIDTH + col] = color; } /* the main function */ int main() { /* we set the mode to mode 3 with bg2 on */ *display_control = MODE3 | BG2; /* loop through each column of the screen */ for (int row = 0; row < HEIGHT; row++) { for (int col = 0; col < WIDTH; col++) { put_pixel(row, col, image_data[row * WIDTH + col]); } } /* we now loop forever displaying the image */ while (1) { /* do nothing */ } }