GBA 开发/源
外观
< GBA 开发
本作品是免费软件;根据自由软件基金会发布的GNU 通用公共许可证(该许可证的第 2 版或(由您选择)任何更新版本),您可以重新分发和/或修改本作品。本作品分发时,希望对您有帮助,但不对其提供任何保证,甚至不对其适销性或适用于特定目的提供任何暗示保证。有关更多详细信息,请参阅GNU 通用公共许可证。 |
#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; }