time/timercallback/source/main.c

#include <nds.h>

void waitfor(int keys)
{
    scanKeys();
    while((keysDown() & keys) == 0)
    {
        swiWaitForVBlank();
        scanKeys();
    }
}


int channel = 0;
bool play = true;

//this function will be called by the timer.
void timerCallBack()
{
    if(play)
        soundPause(channel);
    else
        soundResume(channel);

    play = !play;
}

int main()
{
    soundEnable();
    channel = soundPlayPSG(DutyCycle_50, 10000, 127, 64);

    //calls the timerCallBack function 5 times per second.
    timerStart(0, ClockDivider_1024, TIMER_FREQ_1024(5), timerCallBack);

    waitfor(KEY_A);

    return 0;
}
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines
Generated on Sat Oct 2 12:55:12 2010 for libnds by  doxygen 1.6.3