main.pp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. program main;
  2. {$apptype arm9}
  3. {$define ARM9}
  4. {$mode objfpc}
  5. uses
  6. ctypes, nds9;
  7. var
  8. frame: integer;
  9. touchXY: touchPosition;
  10. function Vblank(): pointer;
  11. begin
  12. inc(frame);
  13. end;
  14. begin
  15. irqInit();
  16. irqSet(IRQ_VBLANK, @Vblank);
  17. irqEnable(IRQ_VBLANK);
  18. videoSetMode(0); //not using the main screen
  19. videoSetModeSub(MODE_0_2D or DISPLAY_BG0_ACTIVE); //sub bg 0 will be used to print text
  20. vramSetBankC(VRAM_C_SUB_BG);
  21. SUB_BG0_CR^ := BG_MAP_BASE(31);
  22. BG_PALETTE_SUB[255] := u32(RGB15(31,31,31)); //by default font will be rendered with color 255
  23. //consoleInit() is a lot more flexible but this gets you up and running quick
  24. consoleInitDefault(pu16(SCREEN_BASE_BLOCK_SUB(31)), pu16(CHAR_BASE_BLOCK_SUB(0)), 16);
  25. printf(' Hello DS dev''rs' + #10);
  26. printf(' www.devkitpro.org' + #10);
  27. printf(' www.drunkencoders.com');
  28. while true do
  29. begin
  30. swiWaitForVBlank();
  31. touchXY := touchReadXY();
  32. // print at using ansi escape sequence #27 + [line;columnH
  33. iprintf(#27 + '[10;0H' + 'Frame = %d',[frame]);
  34. iprintf(#27 + '[16;0H' + 'Touch x = %04X, %04X' + #10, [touchXY.x, touchXY.px]);
  35. iprintf('Touch y = %04X, %04X' + #10, [touchXY.y, touchXY.py]);
  36. end;
  37. end.