Contents of /tags/mkinitrd-6_1_7/isolinux/font.inc
Parent Directory | Revision Log
Revision 909 -
(show annotations)
(download)
Fri Oct 16 13:40:14 2009 UTC (14 years, 11 months ago) by niro
File size: 3451 byte(s)
Fri Oct 16 13:40:14 2009 UTC (14 years, 11 months ago) by niro
File size: 3451 byte(s)
tagged 'mkinitrd-6_1_7'
1 | ;; $Id: font.inc,v 1.1 2007-09-01 22:44:04 niro Exp $ |
2 | ;; ----------------------------------------------------------------------- |
3 | ;; |
4 | ;; Copyright 1994-2004 H. Peter Anvin - All Rights Reserved |
5 | ;; |
6 | ;; This program is free software; you can redistribute it and/or modify |
7 | ;; it under the terms of the GNU General Public License as published by |
8 | ;; the Free Software Foundation, Inc., 53 Temple Place Ste 330, |
9 | ;; Boston MA 02111-1307, USA; either version 2 of the License, or |
10 | ;; (at your option) any later version; incorporated herein by reference. |
11 | ;; |
12 | ;; ----------------------------------------------------------------------- |
13 | |
14 | ;; |
15 | ;; font.inc |
16 | ;; |
17 | ;; VGA font handling code |
18 | ;; |
19 | |
20 | section .text |
21 | |
22 | ; |
23 | ; loadfont: Load a .psf font file and install it onto the VGA console |
24 | ; (if we're not on a VGA screen then ignore.) It is called with |
25 | ; SI and DX:AX set by routine searchdir |
26 | ; |
27 | loadfont: |
28 | mov bx,trackbuf ; The trackbuf is >= 16K; the part |
29 | mov cx,[BufSafe] ; of a PSF file we care about is no |
30 | call getfssec ; more than 8K+4 bytes |
31 | |
32 | mov ax,[trackbuf] ; Magic number |
33 | cmp ax,0436h |
34 | jne lf_ret |
35 | |
36 | mov al,[trackbuf+2] ; File mode |
37 | cmp al,5 ; Font modes 0-5 supported |
38 | ja lf_ret |
39 | |
40 | mov bh,byte [trackbuf+3] ; Height of font |
41 | cmp bh,2 ; VGA minimum |
42 | jb lf_ret |
43 | cmp bh,32 ; VGA maximum |
44 | ja lf_ret |
45 | |
46 | ; Copy to font buffer |
47 | mov si,trackbuf+4 ; Start of font data |
48 | mov [VGAFontSize],bh |
49 | mov di,vgafontbuf |
50 | mov cx,(32*256) >> 2 ; Maximum size |
51 | rep movsd |
52 | |
53 | mov [UserFont], byte 1 ; Set font flag |
54 | |
55 | ; Fall through to use_font |
56 | |
57 | ; |
58 | ; use_font: |
59 | ; This routine activates whatever font happens to be in the |
60 | ; vgafontbuf, and updates the adjust_screen data. |
61 | ; Must be called with CS = DS = ES |
62 | ; |
63 | use_font: |
64 | test [UserFont], byte 1 ; Are we using a user-specified font? |
65 | jz adjust_screen ; If not, just do the normal stuff |
66 | |
67 | mov bp,vgafontbuf |
68 | mov bh,[VGAFontSize] |
69 | |
70 | xor bl,bl ; Needed by both INT 10h calls |
71 | cmp [UsingVGA], byte 1 ; Are we in graphics mode? |
72 | jne .text |
73 | |
74 | .graphics: |
75 | xor cx,cx |
76 | mov cl,bh ; CX = bytes/character |
77 | mov ax,480 |
78 | div cl ; Compute char rows per screen |
79 | mov dl,al |
80 | dec al |
81 | mov [VidRows],al |
82 | mov ax,1121h ; Set user character table |
83 | int 10h |
84 | mov [VidCols], byte 79 ; Always 80 bytes/line |
85 | .lf_ret: ret ; No need to call adjust_screen |
86 | |
87 | .text: |
88 | mov cx,256 |
89 | xor dx,dx |
90 | mov ax,1110h |
91 | int 10h ; Load into VGA RAM |
92 | |
93 | xor bl,bl |
94 | mov ax,1103h ; Select page 0 |
95 | int 10h |
96 | |
97 | ; Fall through to adjust_screen |
98 | |
99 | lf_ret equ use_font.lf_ret |
100 | |
101 | ; |
102 | ; adjust_screen: Set the internal variables associated with the screen size. |
103 | ; This is a subroutine in case we're loading a custom font. |
104 | ; |
105 | adjust_screen: |
106 | pusha |
107 | mov al,[BIOS_vidrows] |
108 | and al,al |
109 | jnz vidrows_ok |
110 | mov al,24 ; No vidrows in BIOS, assume 25 |
111 | ; (Remember: vidrows == rows-1) |
112 | vidrows_ok: mov [VidRows],al |
113 | mov ah,0fh |
114 | int 10h ; Read video state |
115 | dec ah ; Store count-1 (same as rows) |
116 | mov [VidCols],ah |
117 | popa |
118 | ret |
119 | |
120 | |
121 | ; VGA font buffer at the end of memory (so loading a font works even |
122 | ; in graphics mode, but don't put too much pressure on the .bss) |
123 | section .latebss |
124 | vgafontbuf resb 8192 |
125 | |
126 | section .data |
127 | align 2, db 0 |
128 | VGAFontSize dw 16 ; Defaults to 16 byte font |
129 | UserFont db 0 ; Using a user-specified font |
130 | |
131 |