helloWorld.pp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. program hello_world;
  2. {$mode objfpc}
  3. uses
  4. ctypes, nds9;
  5. var
  6. frame: integer;
  7. touchXY: touchPosition;
  8. REG_DIVPCNT : pcuint8 = pointer($4000280);
  9. DIV_NUMER : pcuint32 = pointer($4000290);
  10. DIV_DENOM : pcuint32 = pointer($4000298);
  11. DIV_RESULT : pcuint32 = pointer($40002A0);
  12. DIVREM_RESULT : pcuint32 = pointer($40002A8);
  13. procedure Vblank();
  14. begin
  15. inc(frame);
  16. end;
  17. begin
  18. irqSet(IRQ_VBLANK, @Vblank);
  19. consoleDemoInit();
  20. iprintf('%i div %i'#10, DIV_NUMER^, DIV_DENOM^ );
  21. iprintf('%i, %i'#10, DIV_RESULT^, DIVREM_RESULT^);
  22. DIV_NUMER^ := 5;
  23. DIV_DENOM^ := 0;
  24. iprintf('%i div %i'#10, DIV_NUMER^, DIV_DENOM^ );
  25. iprintf('%i'#10,DIV_RESULT^ );
  26. iprintf('%i'#10,DIVREM_RESULT^ );
  27. iprintf(' Hello DS dev''rs'#10);
  28. iprintf(#27'[32m' + 'www.devkitpro.org'#10);
  29. iprintf(#27'[32;1m' + 'www.drunkencoders.com'#27'[39m');
  30. while true do
  31. begin
  32. swiWaitForVBlank();
  33. touchRead(touchXY);
  34. // print at using ansi escape sequence \x1b[line;columnH
  35. iprintf(#27'[10;0H' + 'Frame = %d', frame);
  36. iprintf(#27'[16;0H' + 'Touch x = %04X, %04X'#10, touchXY.rawx, touchXY.px);
  37. iprintf('Touch y = %04X, %04X'#10, touchXY.rawy, touchXY.py);
  38. end;
  39. end.