#include <nds.h>

int main(void) 
{
    touchPosition touch;

    //set the mode to allow for an extended rotation background
    videoSetMode(MODE_5_2D);
    videoSetModeSub(MODE_5_2D);

    lcdMainOnBottom();

    //allocate a vram bank for each display
    vramSetBankA(VRAM_A_MAIN_BG);
    vramSetBankC(VRAM_C_SUB_BG);

    //create a background on each display
    int bgMain = bgInit(3, BgType_Bmp16, BgSize_B16_256x256, 0,0);
    int bgSub = bgInitSub(3, BgType_Bmp16, BgSize_B16_256x256, 0,0);

    u16* videoMemoryMain = bgGetGfxPtr(bgMain);
    u16* videoMemorySub = bgGetGfxPtr(bgSub);


    while(1) 
    {
        swiWaitForVBlank();

        // read the button states
        scanKeys();

        // read the touchscreen coordinates
        touchRead(&touch);

        int pressed = keysDown();    // buttons pressed this loop
        int held = keysHeld();        // buttons currently held


        if(held & KEY_TOUCH) {
            videoMemoryMain[touch.px + touch.py * 256] = ARGB16(1, 31, 31, 31);
        }

    }

}