1 ;; -----------------------------------------------------------------------
3 ;; Copyright 1994-2004 H. Peter Anvin - All Rights Reserved
5 ;; This program is free software; you can redistribute it and/or modify
6 ;; it under the terms of the GNU General Public License as published by
7 ;; the Free Software Foundation, Inc., 53 Temple Place Ste 330,
8 ;; Boston MA 02111-1307, USA; either version 2 of the License, or
9 ;; (at your option) any later version; incorporated herein by reference.
11 ;; -----------------------------------------------------------------------
16 ;; VGA font handling code
22 ; loadfont: Load a .psf font file and install it onto the VGA console
23 ; (if we're not on a VGA screen then ignore.) It is called with
24 ; SI and DX:AX set by routine searchdir
27 mov bx,trackbuf ; The trackbuf is >= 16K; the part
28 mov cx,[BufSafe] ; of a PSF file we care about is no
29 call getfssec ; more than 8K+4 bytes
31 mov ax,[trackbuf] ; Magic number
35 mov al,[trackbuf+2] ; File mode
36 cmp al,5 ; Font modes 0-5 supported
39 mov bh,byte [trackbuf+3] ; Height of font
40 cmp bh,2 ; VGA minimum
42 cmp bh,32 ; VGA maximum
46 mov si,trackbuf+4 ; Start of font data
49 mov cx,(32*256) >> 2 ; Maximum size
52 mov [UserFont], byte 1 ; Set font flag
54 ; Fall through to use_font
58 ; This routine activates whatever font happens to be in the
59 ; vgafontbuf, and updates the adjust_screen data.
60 ; Must be called with CS = DS = ES
63 test [UserFont], byte 1 ; Are we using a user-specified font?
64 jz adjust_screen ; If not, just do the normal stuff
69 xor bl,bl ; Needed by both INT 10h calls
70 cmp [UsingVGA], byte 1 ; Are we in graphics mode?
75 mov cl,bh ; CX = bytes/character
77 div cl ; Compute char rows per screen
81 mov ax,1121h ; Set user character table
83 mov [VidCols], byte 79 ; Always 80 bytes/line
84 .lf_ret: ret ; No need to call adjust_screen
90 int 10h ; Load into VGA RAM
93 mov ax,1103h ; Select page 0
96 ; Fall through to adjust_screen
98 lf_ret equ use_font.lf_ret
101 ; adjust_screen: Set the internal variables associated with the screen size.
102 ; This is a subroutine in case we're loading a custom font.
106 mov al,[BIOS_vidrows]
109 mov al,24 ; No vidrows in BIOS, assume 25
110 ; (Remember: vidrows == rows-1)
111 vidrows_ok: mov [VidRows],al
113 int 10h ; Read video state
114 dec ah ; Store count-1 (same as rows)
120 ; VGA font buffer at the end of memory (so loading a font works even
121 ; in graphics mode, but don't put too much pressure on the .bss)
127 VGAFontSize dw 16 ; Defaults to 16 byte font
128 UserFont db 0 ; Using a user-specified font