Simple.pp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. program Simple;
  2. {$mode objfpc}
  3. uses
  4. ctypes, nds9;
  5. var
  6. i: integer;
  7. touch: touchPosition;
  8. gfx, gfxSub: pcuint16;
  9. begin
  10. videoSetMode(MODE_0_2D);
  11. videoSetModeSub(MODE_0_2D);
  12. vramSetBankA(VRAM_A_MAIN_SPRITE);
  13. vramSetBankD(VRAM_D_SUB_SPRITE);
  14. oamInit(oamMain, SpriteMapping_1D_32, false);
  15. oamInit(oamSub, SpriteMapping_1D_32, false);
  16. gfx := oamAllocateGfx(oamMain, SpriteSize_16x16, SpriteColorFormat_256Color);
  17. gfxSub := oamAllocateGfx(oamSub, SpriteSize_16x16, SpriteColorFormat_256Color);
  18. for i := 0 to (16 * 16 div 2) - 1 do
  19. begin
  20. gfx[i] := 1 or (1 shl 8);
  21. gfxSub[i] := 1 or (1 shl 8);
  22. end;
  23. SPRITE_PALETTE[1] := RGB15(31,0,0);
  24. SPRITE_PALETTE_SUB[1] := RGB15(0,31,0);
  25. while true do
  26. begin
  27. scanKeys();
  28. if (keysHeld() and KEY_TOUCH) <> 0 then
  29. touchRead(touch);
  30. oamSet(oamMain, //main graphics engine context
  31. 0, //oam index (0 to 127)
  32. touch.px, touch.py, //x and y pixle location of the sprite
  33. 0, //priority, lower renders last (on top)
  34. 0, //this is the palette index if multiple palettes or the alpha value if bmp sprite
  35. SpriteSize_16x16,
  36. SpriteColorFormat_256Color,
  37. gfx, //pointer to the loaded graphics
  38. -1, //sprite rotation data
  39. false, //double the size when rotating?
  40. false, //hide the sprite?
  41. false, false, //vflip, hflip
  42. false //apply mosaic
  43. );
  44. oamSet(oamSub,
  45. 0,
  46. touch.px,
  47. touch.py,
  48. 0,
  49. 0,
  50. SpriteSize_16x16,
  51. SpriteColorFormat_256Color,
  52. gfxSub,
  53. -1,
  54. false,
  55. false,
  56. false, false,
  57. false
  58. );
  59. swiWaitForVBlank();
  60. oamUpdate(oamMain);
  61. oamUpdate(oamSub);
  62. end;
  63. end.