Annotation of /tags/mkinitrd-6_3_2/isolinux/font.inc
Parent Directory | Revision Log
Revision 1164 -
(hide annotations)
(download)
Tue Sep 14 20:33:28 2010 UTC (14 years ago) by niro
File size: 3544 byte(s)
Tue Sep 14 20:33:28 2010 UTC (14 years ago) by niro
File size: 3544 byte(s)
tagged 'mkinitrd-6_3_2'
1 | niro | 532 | ;; ----------------------------------------------------------------------- |
2 | ;; | ||
3 | niro | 1133 | ;; Copyright 1994-2008 H. Peter Anvin - All Rights Reserved |
4 | ;; | ||
5 | niro | 532 | ;; 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. | ||
10 | ;; | ||
11 | ;; ----------------------------------------------------------------------- | ||
12 | |||
13 | ;; | ||
14 | ;; font.inc | ||
15 | ;; | ||
16 | ;; VGA font handling code | ||
17 | ;; | ||
18 | |||
19 | section .text | ||
20 | |||
21 | ; | ||
22 | ; loadfont: Load a .psf font file and install it onto the VGA console | ||
23 | niro | 1133 | ; (if we're not on a VGA screen then ignore.) |
24 | ; The font is on top of the getc stack. | ||
25 | niro | 532 | ; |
26 | niro | 1133 | loadfont.err: jmp close ; Tailcall the close routine |
27 | |||
28 | niro | 532 | loadfont: |
29 | niro | 1133 | mov di,trackbuf |
30 | mov cx,4 | ||
31 | call readc ; Read header | ||
32 | jc .err | ||
33 | niro | 532 | |
34 | mov ax,[trackbuf] ; Magic number | ||
35 | cmp ax,0436h | ||
36 | niro | 1133 | jne .err |
37 | niro | 532 | |
38 | mov al,[trackbuf+2] ; File mode | ||
39 | cmp al,5 ; Font modes 0-5 supported | ||
40 | niro | 1133 | ja .err |
41 | niro | 532 | |
42 | niro | 1133 | xor bx,bx |
43 | mov bh,[trackbuf+3] ; Height of font | ||
44 | niro | 532 | cmp bh,2 ; VGA minimum |
45 | niro | 1133 | jb .err |
46 | niro | 532 | cmp bh,32 ; VGA maximum |
47 | niro | 1133 | ja .err |
48 | niro | 532 | |
49 | niro | 1133 | ; Load the actual font |
50 | mov di,trackbuf | ||
51 | mov cx,bx ; Bytes = font height * 256 | ||
52 | call readc | ||
53 | jc .err | ||
54 | |||
55 | call close | ||
56 | |||
57 | niro | 532 | ; Copy to font buffer |
58 | niro | 1133 | mov si,trackbuf ; Start of font data |
59 | niro | 532 | mov [VGAFontSize],bh |
60 | niro | 1133 | push es |
61 | mov cx,aux_seg | ||
62 | mov es,cx | ||
63 | mov di,aux.fontbuf | ||
64 | mov cx,bx | ||
65 | shr cx,2 | ||
66 | niro | 532 | rep movsd |
67 | niro | 1133 | pop es |
68 | niro | 532 | |
69 | mov [UserFont], byte 1 ; Set font flag | ||
70 | |||
71 | ; | ||
72 | ; use_font: | ||
73 | niro | 1133 | ; This routine activates whatever font happens to be in the |
74 | niro | 532 | ; vgafontbuf, and updates the adjust_screen data. |
75 | niro | 1133 | ; Must be called with CS = DS |
76 | niro | 532 | ; |
77 | use_font: | ||
78 | niro | 1133 | test byte [UsingVGA], ~03h ; Nonstandard mode? |
79 | jz .modeok | ||
80 | call vgaclearmode | ||
81 | |||
82 | .modeok: | ||
83 | niro | 532 | test [UserFont], byte 1 ; Are we using a user-specified font? |
84 | jz adjust_screen ; If not, just do the normal stuff | ||
85 | |||
86 | niro | 1133 | push es |
87 | mov bp,aux_seg | ||
88 | mov es,bp | ||
89 | |||
90 | mov bp,aux.fontbuf ; ES:BP -> font | ||
91 | niro | 532 | mov bh,[VGAFontSize] |
92 | xor bl,bl ; Needed by both INT 10h calls | ||
93 | |||
94 | niro | 1133 | test byte [UsingVGA], 01h ; Are we in graphics mode? |
95 | jz .text | ||
96 | |||
97 | niro | 532 | .graphics: |
98 | xor cx,cx | ||
99 | mov cl,bh ; CX = bytes/character | ||
100 | niro | 1133 | mov ax,[GXPixRows] |
101 | niro | 532 | div cl ; Compute char rows per screen |
102 | mov dl,al | ||
103 | niro | 1133 | dec ax |
104 | niro | 532 | mov [VidRows],al |
105 | mov ax,1121h ; Set user character table | ||
106 | int 10h | ||
107 | niro | 1133 | mov ax,[GXPixCols] |
108 | shr ax,3 ; 8 pixels/character | ||
109 | dec ax | ||
110 | mov [VidCols],al | ||
111 | pop es | ||
112 | ret ; No need to call adjust_screen | ||
113 | niro | 532 | |
114 | .text: | ||
115 | mov cx,256 | ||
116 | xor dx,dx | ||
117 | mov ax,1110h | ||
118 | int 10h ; Load into VGA RAM | ||
119 | niro | 1133 | pop es |
120 | niro | 532 | |
121 | xor bl,bl | ||
122 | mov ax,1103h ; Select page 0 | ||
123 | int 10h | ||
124 | |||
125 | ; | ||
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. | ||
128 | ; | ||
129 | adjust_screen: | ||
130 | pusha | ||
131 | mov al,[BIOS_vidrows] | ||
132 | and al,al | ||
133 | jnz vidrows_ok | ||
134 | mov al,24 ; No vidrows in BIOS, assume 25 | ||
135 | ; (Remember: vidrows == rows-1) | ||
136 | vidrows_ok: mov [VidRows],al | ||
137 | mov ah,0fh | ||
138 | int 10h ; Read video state | ||
139 | dec ah ; Store count-1 (same as rows) | ||
140 | mov [VidCols],ah | ||
141 | popa | ||
142 | ret | ||
143 | |||
144 | section .data | ||
145 | niro | 1133 | alignz 2 |
146 | niro | 532 | VGAFontSize dw 16 ; Defaults to 16 byte font |
147 | UserFont db 0 ; Using a user-specified font | ||
148 | |||
149 | niro | 1133 | section .bss1 |
150 | alignb 4 | ||
151 | GXPixCols resw 1 ; Graphics mode pixel columns | ||
152 | GXPixRows resw 1 ; Graphics mode pixel rows |