GBA Development/Source


 * 1) include 

// Global variables int curX, curY, curColor; u8 cR, cG, cB;

//Function that draws a single pixel to the screen void drawPix(int xPos, int yPos, int color) {  unsigned short* videoBuffer = (unsigned short*)0x6000000; videoBuffer[(yPos*240) + xPos] = color; }

//Gets input from the joypad void query_input {     if (F_CTRLINPUT_UP_PRESSED) curY--; if (F_CTRLINPUT_DOWN_PRESSED) curY++; if (F_CTRLINPUT_LEFT_PRESSED) curX--; if (F_CTRLINPUT_RIGHT_PRESSED) curX++; if (F_CTRLINPUT_B_PRESSED) curColor = RGB(++cR, cG, cB); if (F_CTRLINPUT_A_PRESSED) curColor = RGB(cR, ++cG, cB); if (F_CTRLINPUT_L_PRESSED) curColor = RGB(cR, cG, ++cB); if (F_CTRLINPUT_R_PRESSED) {        cR = 0xFF; cG = 0xFF; cB = 0xFF; curColor = RGB(cR, cG, cB); }

}

// Function called every screen refresh void vbl_func {     query_input; drawPix(curX,curY, curColor); }

//Program entrance int main(void) {

// Initializing HAM and background mode ham_Init; ham_SetBgMode(3);

// Initializing global variables curX = 0; curY = 0; cR = 0xFF; cG = 0xFF; cB = 0xFF; curColor = 0xFFFF;

//Starts running the vbl_func every screen refresh ham_StartIntHandler(INT_TYPE_VBL,(void*)&vbl_func);

while(true) {  }   return 0; }