Code: Select all
include <gba_console.h>
#include <gba_video.h>
#include <gba_interrupt.h>
#include <gba_systemcalls.h>
#include <gba_input.h>
#include <stdio.h>
#include <stdlib.h>
typedef u16 COLOR;
inline void plot(int xPos, int yPos, COLOR clr)
{
((u16*)(VRAM))[yPos*SCREEN_WIDTH+xPos] = clr;
}
int main(void) {
irqInit();
irqEnable(IRQ_VBLANK);
u16 keysDownRepeatValue;
REG_DISPCNT= MODE_3 | BG2_ON;
while (1) {
scanKeys();
keysDownRepeatValue = keysDownRepeat();
//Left and Right
if(keysDownRepeatValue == KEY_LEFT)
{
plot (20, 20, RGB5(0, 10, 0));
}
if (keysDownRepeatValue == KEY_RIGHT)
{
plot (10, 10, RGB5(10, 0, 0));
}
//Up and Down
if(keysDownRepeatValue == KEY_UP)
{
plot (30, 30, RGB5(0, 0, 10));
}
if (keysDownRepeatValue == KEY_DOWN)
{
plot (40, 40, RGB5(0, 0, 10));
}
VBlankIntrWait();
}
}