RotscaleText.pp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. program RotscaleText;
  2. {$L build/font.o}
  3. {$mode objfpc}
  4. uses
  5. ctypes, nds9;
  6. const
  7. fontPalLen = 32;
  8. fontTilesLen = 3072;
  9. tile_base = 0;
  10. map_base = 20;
  11. var
  12. fontTiles: array [0..767] of cushort; cvar; external;
  13. fontPal: array [0..255] of cushort; cvar; external;
  14. scaleX, scaleY: cint16;
  15. scrollX, scrollY: cint16;
  16. angle: cuint = 0;
  17. keys: cuint32;
  18. console: pPrintConsole;
  19. font: ConsoleFont;
  20. bg3: cint;
  21. begin
  22. videoSetMode(0);
  23. videoSetModeSub(MODE_5_2D);
  24. vramSetBankC(VRAM_C_SUB_BG);
  25. console := consoleInit(nil, 3, BgType_ExRotation, BgSize_ER_256x256, map_base, tile_base, false, false);
  26. font.gfx := pcuint16(fontTiles);
  27. font.pal := pcuint16(fontPal);
  28. font.numChars := 95;
  29. font.numColors := fontPalLen div 2;
  30. font.bpp := 8;
  31. font.asciiOffset := 32;
  32. font.convertSingleColor := false;
  33. consoleSetFont(console, @font);
  34. bg3 := console^.bgId;
  35. printf('Custom Font Demo'#10);
  36. printf(' by Poffy'#10);
  37. printf('modified by WinterMute and Dovoto'#10);
  38. printf('for libnds examples'#10);
  39. angle := 0;
  40. scrollX := 0;
  41. scrollY := 0;
  42. scaleX := intToFixed(1,8);
  43. scaleY := intToFixed(1,8);
  44. while true do
  45. begin
  46. scanKeys();
  47. keys := keysHeld();
  48. if ( keys and KEY_L ) <> 0 then angle := angle + 64;
  49. if ( keys and KEY_R ) <> 0 then angle := angle - 64;
  50. if ( keys and KEY_LEFT ) <> 0 then scrollX := scrollX + 1;
  51. if ( keys and KEY_RIGHT ) <> 0 then scrollX := scrollX - 1;
  52. if ( keys and KEY_UP ) <> 0 then scrollY := scrollY + 1;
  53. if ( keys and KEY_DOWN ) <> 0 then scrollY := scrollY - 1;
  54. if ( keys and KEY_A ) <> 0 then scaleX := scaleX + 1;
  55. if ( keys and KEY_B ) <> 0 then scaleX := scaleX - 1;
  56. if( keys and KEY_X ) <> 0 then scaleY := scaleY + 1;
  57. if( keys and KEY_Y ) <> 0 then scaleY := scaleY - 1;
  58. swiWaitForVBlank();
  59. bgSetRotateScale(bg3, angle, scaleX, scaleY);
  60. bgSetScroll(bg3, scrollX, scrollY);
  61. bgUpdate();
  62. end;
  63. end.