fpc/packages/libndsfpc/examples/time/timercallback/timercallback.pp
Legolas c3698c84be * Updated libndsfpc to 1.4.10:
+ Added support for Tetris paddle, Guitar Hero grip and easy piano controller
  + Added sdmmc support for reading DSi internal SD card
  + i2c communication functions for DSi
  + Added some time handling related examples 
  * Improved timing functions
  * Some small bug fixes and improvements, both in library and examples
  - Removed unused SVN macros from header and license infos to save space :)

git-svn-id: trunk@16879 -
2011-02-05 14:20:49 +00:00

45 lines
672 B
ObjectPascal

program timercallback;
{$mode objfpc}
uses
ctypes, nds9;
procedure waitfor(keys: cint);
begin
scanKeys();
while ((keysDown() and keys) = 0) do
begin
swiWaitForVBlank();
scanKeys();
end;
end;
var
channel: cuint = 0;
play: boolean = true;
//this function will be called by the timer.
procedure timerCallBack();
begin
if (play) then
soundPause(channel)
else
soundResume(channel);
play := not play;
end;
begin
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);
end.