main.pp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. program main;
  2. {$L font.o}
  3. {$apptype arm9}
  4. {$define ARM9}
  5. {$mode objfpc}
  6. uses
  7. ctypes, nds9;
  8. var
  9. i: integer;
  10. sub_tile: pu16;
  11. sub_map: pu16;
  12. const
  13. font_WIDTH = 8;
  14. font_HEIGHT = 768;
  15. fontPalLen = 512;
  16. fontBitmapLen = 6144;
  17. var
  18. //byte array representing the picture
  19. fontBitmap: array [0..1535] of cuint16; cvar; external;
  20. fontPal: array [0..255] of cuint16; cvar; external;
  21. const
  22. char_base = 0;
  23. screen_base = 20;
  24. begin
  25. irqInit();
  26. irqEnable(IRQ_VBLANK);
  27. videoSetMode(0);
  28. videoSetModeSub(MODE_0_2D or DISPLAY_BG0_ACTIVE);
  29. vramSetBankC(VRAM_C_SUB_BG);
  30. SUB_BG0_CR^ := BG_256_COLOR or BG_TILE_BASE(char_base) or BG_MAP_BASE(screen_base);
  31. sub_tile := pu16(CHAR_BASE_BLOCK_SUB(char_base));
  32. sub_map := pu16(SCREEN_BASE_BLOCK_SUB(screen_base));
  33. //95 and 32 show how many characters there are and 32 shows which ASCII character to start, respectively
  34. //95 is the smaller set of ACSII characters. It usually will start with 32
  35. consoleInit(pu16(fontBitmap), sub_tile, 95, 32, sub_map, CONSOLE_USE_COLOR255, 8);
  36. //Load the Font Data and Palette stuff here
  37. for i := 0 to fontBitmapLen - 1 do
  38. sub_tile[i] := u32(fontBitmap[i]);
  39. for i := 0 to fontPalLen - 1 do
  40. BG_PALETTE_SUB[i] := u32(fontPal[i]);
  41. printf('Custom Font Demo' + #10);
  42. printf(' by Poffy' + #10);
  43. printf('modified by WinterMute' + #10);
  44. printf('for libnds examples' + #10);
  45. while true do
  46. swiWaitForVBlank();
  47. end.