GBA Development/Source
Appearance
This work is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This work is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
#include <mygba.h> // 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; }