main.pp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. program main;
  2. {$apptype arm9}
  3. {$define ARM9}
  4. {$mode objfpc}
  5. uses
  6. ctypes, nds9;
  7. begin
  8. //---------------------------------------------------------------------------------
  9. // initialise the irq dispatcher
  10. irqInit();
  11. // a vblank interrupt is needed to use swiWaitForVBlank()
  12. // since the dispatcher handles the flags no handler is required
  13. irqEnable(IRQ_VBLANK);
  14. videoSetMode(0); //not using the main screen
  15. videoSetModeSub(MODE_0_2D or DISPLAY_BG0_ACTIVE); //sub bg 0 will be used to print text
  16. vramSetBankC(VRAM_C_SUB_BG);
  17. SUB_BG0_CR^ := BG_MAP_BASE(31);
  18. BG_PALETTE_SUB[255] := u32(RGB15(31,31,31)); //by default font will be rendered with color 255
  19. //consoleInit() is a lot more flexible but this gets you up and running quick
  20. consoleInitDefault(pu16(SCREEN_BASE_BLOCK_SUB(31)), pu16(CHAR_BASE_BLOCK_SUB(0)), 16);
  21. // ansi escape sequence to clear screen and home cursor
  22. // #27 + [line;columnH
  23. iprintf(#27 + '[2J');
  24. // ansi escape sequence to set print co-ordinates
  25. // #27 + [line;columnH
  26. iprintf(#27 + '[10;10H' + 'Hello World!');
  27. // ansi escape sequence to move cursor up
  28. // #27 + [linesA
  29. iprintf(#27 + '[10A' + 'Line 0');
  30. // ansi escape sequence to move cursor left
  31. // #27 + [columnsD
  32. iprintf(#27 + '[28D' + 'Column 0');
  33. // ansi escape sequence to move cursor down
  34. // #27 + [linesB
  35. iprintf(#27 + '[19B' + 'Line 19');
  36. // ansi escape sequence to move cursor right
  37. // #27 + [columnsC
  38. iprintf(#27 + '[5C' + 'Column 20');
  39. while true do
  40. swiWaitForVBlank();
  41. end.