summaryrefslogtreecommitdiff
path: root/packages/libndsfpc/examples/graphics/Printing/custom_font/CustomFont.pp
blob: f6806873fa9189f8a3848b651f0ea5695d406ba1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
program custom_font;
{$L build/font.o}

{$mode objfpc}

uses
  ctypes, nds9;

const
  fontPalLen = 32;
  fontTilesLen = 3072;
  tile_base = 0;
  map_base = 20;

var
  fontTiles: array [0..767] of cushort; cvar; external;
  fontPal: array [0..255] of cushort; cvar; external;

  console: pPrintConsole;
  font: ConsoleFont;
  keys: integer;

begin
  videoSetModeSub(MODE_0_2D);
  vramSetBankC(VRAM_C_SUB_BG);

  console := consoleInit(nil, 0, BgType_Text4bpp, BgSize_T_256x256, map_base, tile_base, false, false);

  font.gfx := pcuint16(fontTiles);
  font.pal := pcuint16(fontPal);
  font.numChars := 95;
  font.numColors :=  fontPalLen div 2;
  font.bpp := 4;
  font.asciiOffset := 32;
  font.convertSingleColor := false;

  consoleSetFont(console, @font);

  printf('Custom Font Demo'#10);
  printf('   by Poffy'#10);
  printf('modified by WinterMute'#10);
  printf('for libnds examples'#10);

  while true do
  begin
    swiWaitForVBlank();
    scanKeys();
		keys := keysDown();
		if (keys and KEY_START) <> 0 then break;
  end;
end.