2
{ FontDemo.pas, by Marco van de Voort (C) 2000-2001
4
Compiler: 1.0.5 or 1.1 after 20-01-2001
5
Target : FreeBSD 4.x+ with 16x8 font. 3.x untested (syscons driver)
7
Demonstrate font modification with the console driver "syscons".
8
This program doesn't work under X or over telnet.
10
The purpose of the program is to demonstrate the procedures that change the
11
font. The demonstration assume a 80x25 console. Framebuffer devices or 80x50
12
displays (80x50 use 8x8 fonts) require a trivial modification.
14
The example of mirroring is absurd, but is very visible, so good for
15
demonstration. The real use is to load the font, change a few characters
16
(linedrawing, (C) characters, force existance of umlaute or tremas for the
17
duration of the application.
19
Note that if you switch to a different vty while the font is mirrored, that
22
Root can restore the font via a network device with:
24
vidcontrol -f 8x16 "fontname in /usr/share/syscons/fonts" < /dev/ttyv1
26
The program saves the font, and will terminate and restore the font when
27
SIGUSR2 is received, unless -n is specified.
29
killall -USR2 fontdemo
34
Uses Console,{$ifdef ver1_0}Linux{$else}Baseunix{$endif},GetOpts;
43
procedure MirrorFont8(var Data;Count:longint); assembler;
44
{Mirrors on a bit level "Count" bytes in typeless variable "Data"}
49
.LLoop1: movb (%esi),%bl
58
end['EAX','EBX','ECX','EDX','ESI'];
61
procedure GoLeft(var Data;Count:longint;shcnt:longint); assembler;
62
{Mirrors on a bit level "Count" bytes in typeless variable "Data"}
77
end['EAX','EBX','ECX','EDX','ESI'];
79
procedure GoRight(var Data;Count:longint;shcnt:longint); assembler;
80
{Mirrors on a bit level "Count" bytes in typeless variable "Data"}
95
end['EAX','EBX','ECX','EDX','ESI'];
97
procedure DoAlt(var Data;Count:longint;shcnt:longint;alt:integer); assembler;
98
{Mirrors on a bit level "Count" bytes in typeless variable "Data"}
125
end['EAX','EBX','ECX','EDX','ESI'];
127
procedure stripbits (var Data;Count:longint); assembler;
128
{ "Compresses" a byte. 76543210 -> x764310x where x=0 (but 0 was already
129
used to indicate bit number :-)
131
Needed for a rotating effect. (Character rotating round vertical axis)
132
Does this for "Count" bytes in "Data".
138
.LLoop1: movb (%esi),%cl
156
end['EAX','EBX','ECX','EDX','ESI'];
158
procedure silloute (var Data;Count:longint); assembler;
159
{Iterates through "Count" bytes of "Data" and sets a byte to $48 if it is
160
not zero. If you would rotate a character round vertical axis through 90
161
degrees, this is about how it looks like}
166
.LLoop1: movb (%esi),%al
176
end['EAX','EBX','ECX','EDX','ESI'];
178
var Originalfont : Fnt16; {Font on startup, to be saved for restore}
179
StopIt : BOOLEAN; {Becomes TRUE when SIGUSR2 is received}
180
RestoreOnExit : Boolean; {Should font be restored on exit?}
182
procedure OkThatsEnough(sig:longint);cdecl;
190
{ The animation order of the 5 distinctive states, -> 8 changes is one
192
Type RotStatesType = array[0..7] of longint;
194
const RotStates : RotStatesType=(0,1,4,3,2,3,4,1);
198
- 1 mirrored "compressed"
200
- 3 normal "compressed",
203
var fnts : array[0..4] of fnt16;
208
iin.tv_nsec:=250000000;
210
fnts[2]:=OriginalFont;
211
fnts[0]:=fnts[2]; // Keep a copy.
212
MirrorFont8(fnts[0],sizeof(fnt16)); // Mirror every byte at bitlevel
214
stripbits(fnts[1],sizeof(fnt16));
216
stripbits(fnts[3],sizeof(fnt16));
218
silloute(fnts[4],sizeof(fnt16));
221
PIO_FONT8x16(0,fnts[RotStates[I and 7]]); // Activate the mirrored set
222
fpnanosleep(@iin,@oout);
227
procedure upanddown(Mini:BOOLEAN);
230
fnts : array[1..4] OF fnt16;
236
fnts[2]:=OriginalFont;
237
inn.tv_nsec:=50000000;
239
fnts[4]:=fnts[2]; {Make three copies}
243
{Move one of them one byte up in memory. Font is one bit lower}
245
move (fnts[1],fnts[1].fnt8x16[1],SIZEOF(Fnt16)-1);
247
{Move another of them one byte down in memory. Font is one bit higher}
251
move (fnts[2].fnt8x16[1],fnts[2],SIZEOF(Fnt16)-1);
255
move (fnts[3].fnt8x16[1],fnts[3],SIZEOF(Fnt16)-1);
260
fpnanosleep(@inn,@outn);
261
pIO_FONT8x16(0,fnts[1 + (I and Mask)]);
266
procedure LeftAndRight;
269
fnts : array[1..4] OF fnt16;
275
fnts[2]:=OriginalFont;
276
inn.tv_nsec:=50000000;
278
fnts[4]:=fnts[2]; {Make three copies}
282
{Move one of them one byte up in memory. Font is one bit lower}
284
Goright(Fnts[1],SIZEOF(FNT16),2);
285
GoLeft( Fnts[3],SIZEOF(FNT16),2);
287
fpnanosleep(@inn,@outn);
288
pIO_FONT8x16(0,fnts[1 + (I and 3)]);
293
procedure doalternate;
296
fnts : array[0..5] OF fnt16;
302
fnts[2]:=OriginalFont;
303
inn.tv_nsec:=500000000;
305
fnts[4]:=fnts[2]; {Make three copies}
309
{Move one of them one byte up in memory. Font is one bit lower}
310
doalt(fnts[1],SIZEOF(FNT16) div 2,2,1);
311
doalt(fnts[3],SIZEOF(FNT16) div 2,2,0);
313
fpnanosleep(@inn,@outn);
314
writeln(1 + (I and 3));
315
pIO_FONT8x16(0,fnts[1 + (I and 3)]);
320
procedure JustMirror;
326
MirrorFont8(fnt,sizeof(fnt16));
328
IF RestoreOnExit THEN
333
var DoThis : Longint;
338
RestoreOnExit := TRUE;
339
if PhysicalConsole(0) then // a vty?
342
c:=GetOpt('n012345'); // Commandline processing
343
IF c IN ['0'..'5'] Then
346
RestoreOnExit:=FALSE;
347
UNTIL C=EndOfOptions;
349
StopIt:=false; // Turns true on signal USR2
350
GIO_FONT8x16(0,OriginalFont); // Get font from videocard.
351
fpSignal(SIGUSR2,@OkThatsEnough); // Install handler for sigusr2.
353
CASE DoThis OF // Call the font routines
357
3 : UpAndDown(FALSE);
362
IF RestoreOnExit THEN // clean up if required.
363
PIO_FONT8x16(0,OriginalFont);
b'\\ No newline at end of file'