1 ;; -----------------------------------------------------------------------
3 ;; Copyright 1994-2008 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.)
24 ; The font is on top of the getc stack.
26 loadfont.err: jmp close ; Tailcall the close routine
31 call readc ; Read header
34 mov ax,[trackbuf] ; Magic number
38 mov al,[trackbuf+2] ; File mode
39 cmp al,5 ; Font modes 0-5 supported
43 mov bh,[trackbuf+3] ; Height of font
44 cmp bh,2 ; VGA minimum
46 cmp bh,32 ; VGA maximum
49 ; Load the actual font
51 mov cx,bx ; Bytes = font height * 256
58 mov si,trackbuf ; Start of font data
69 mov [UserFont], byte 1 ; Set font flag
73 ; This routine activates whatever font happens to be in the
74 ; vgafontbuf, and updates the adjust_screen data.
75 ; Must be called with CS = DS
78 test byte [UsingVGA], ~03h ; Nonstandard mode?
83 test [UserFont], byte 1 ; Are we using a user-specified font?
84 jz adjust_screen ; If not, just do the normal stuff
90 mov bp,aux.fontbuf ; ES:BP -> font
92 xor bl,bl ; Needed by both INT 10h calls
94 test byte [UsingVGA], 01h ; Are we in graphics mode?
99 mov cl,bh ; CX = bytes/character
101 div cl ; Compute char rows per screen
105 mov ax,1121h ; Set user character table
108 shr ax,3 ; 8 pixels/character
112 ret ; No need to call adjust_screen
118 int 10h ; Load into VGA RAM
122 mov ax,1103h ; Select page 0
126 ; adjust_screen: Set the internal variables associated with the screen size.
127 ; This is a subroutine in case we're loading a custom font.
131 mov al,[BIOS_vidrows]
134 mov al,24 ; No vidrows in BIOS, assume 25
135 ; (Remember: vidrows == rows-1)
136 vidrows_ok: mov [VidRows],al
138 int 10h ; Read video state
139 dec ah ; Store count-1 (same as rows)
146 VGAFontSize dw 16 ; Defaults to 16 byte font
147 UserFont db 0 ; Using a user-specified font
151 GXPixCols resw 1 ; Graphics mode pixel columns
152 GXPixRows resw 1 ; Graphics mode pixel rows