Arm7:
[pascal]
program toucharm7;

{$apptype arm7} //...or arm7
{$define ARM7} //...or arm7, according to apptype

{$mode objfpc} // required for some libc funcs implementation

uses
ctypes; // required by nds headers!

{$include nds.inc} // headers!

var
tempPos: touchPosition;
procedure CatchTheTouch();
begin
tempPos := touchReadXY();

IPC^.touchX := tempPos.x;
IPC^.touchY := tempPos.y;

end;

begin
// Reset the clock if needed
rtcReset();
irqInit();
irqSet(IRQ_VCOUNT, @CatchTheTouch);
irqEnable(IRQ_VCOUNT);

while true do
swiWaitForVBlank();
end.
[/pascal]

Arm9:
[pascal]
program toucharm9;

{$apptype arm9} //...or arm7
{$define ARM9} //...or arm7, according to apptype

{$mode objfpc} // required for some libc funcs implementation

uses
ctypes; // required by nds headers!

{$include nds.inc} // headers!
{$include dswifi9.inc} // headers!

var
i: integer;
touchXY: touchPosition;
X,Y:integer;
begin

consoleDemoInit();
videoSetMode(MODE_FB0);
vramSetBankA(VRAM_A_LCD);
irqInit();
irqEnable(IRQ_VBLANK);
printf('Teste de Teclas'+#10);

for i := 0 to (256 * 192) - 1 do
VRAM_A[i] := RGB15(15,25,1);

lcdSwap();

while true do
begin
touchXY:= touchReadXY();
if touchXY.x<>0 then
begin
X:=touchXY.x div 16;
Y:=touchXY.y div 16;
printf('%i / %i'+#10,[X,Y]);
VRAM_A[(Y*256)+X-1] := RGB15(25,0,0);
end;
end;

end.
[/pascal]

.bat code:
Code:
ppcarmnds -g --gc-sections -Tnds toucharm9.pas
ppcarmnds -g --gc-sections -Tnds toucharm7.pas
pause
ndstool -c toucharm9.nds -9 toucharm9.arm9.bin -7 toucharm7.arm7.bin
dsbuild toucharm9.nds -o toucharm9.nds.gba 
del *.bin
del *.o
del *.elf
pause
This code didn't work on nds[/code]