root/core/font.inc

Revision 4cc0c3ab6541753b89cba58c345c0cae8c7d151d, 3.5 KB (checked in by H. Peter Anvin <hpa@…>, 3 years ago)

core: rename .text, .data and .bss to .text16, .data16, .bss16

Rename the .text, .data and .bss sections to .text16, .data16 and
.bss16, in anticipation of being linked with compiler-generated 32-bit
code, which presumably would like to use the standard section names.

Signed-off-by: H. Peter Anvin <hpa@…>

  • Property mode set to 100644
Line 
1;; -----------------------------------------------------------------------
2;;
3;;   Copyright 1994-2008 H. Peter Anvin - All Rights Reserved
4;;
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.
10;;
11;; -----------------------------------------------------------------------
12
13;;
14;; font.inc
15;;
16;; VGA font handling code
17;;
18
19                section .text16
20
21;
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.
25;
26loadfont.err:   jmp close                       ; Tailcall the close routine
27
28loadfont:
29                mov di,trackbuf
30                mov cx,4
31                call readc                      ; Read header
32                jc .err
33
34                mov ax,[trackbuf]               ; Magic number
35                cmp ax,0436h
36                jne .err
37
38                mov al,[trackbuf+2]             ; File mode
39                cmp al,5                        ; Font modes 0-5 supported
40                ja .err
41
42                xor bx,bx
43                mov bh,[trackbuf+3]             ; Height of font
44                cmp bh,2                        ; VGA minimum
45                jb .err
46                cmp bh,32                       ; VGA maximum
47                ja .err
48
49                ; 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                ; Copy to font buffer
58                mov si,trackbuf                 ; Start of font data
59                mov [VGAFontSize],bh
60                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                rep movsd
67                pop es
68
69                mov [UserFont], byte 1          ; Set font flag
70
71;
72; use_font:
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
76;
77use_font:
78                test byte [UsingVGA], ~03h      ; Nonstandard mode?
79                jz .modeok
80                call vgaclearmode
81
82.modeok:
83                test [UserFont], byte 1         ; Are we using a user-specified font?
84                jz adjust_screen                ; If not, just do the normal stuff
85
86                push es
87                mov bp,aux_seg
88                mov es,bp
89
90                mov bp,aux.fontbuf              ; ES:BP -> font
91                mov bh,[VGAFontSize]
92                xor bl,bl                       ; Needed by both INT 10h calls
93
94                test byte [UsingVGA], 01h       ; Are we in graphics mode?
95                jz .text
96
97.graphics:
98                xor cx,cx
99                mov cl,bh                       ; CX = bytes/character
100                mov ax,[GXPixRows]
101                div cl                          ; Compute char rows per screen
102                mov dl,al
103                dec ax
104                mov [VidRows],al
105                mov ax,1121h                    ; Set user character table
106                int 10h
107                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
114.text:
115                mov cx,256
116                xor dx,dx
117                mov ax,1110h
118                int 10h                         ; Load into VGA RAM
119                pop es
120
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;
129adjust_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)
136vidrows_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 .data16
145                alignz 2
146VGAFontSize     dw 16                   ; Defaults to 16 byte font
147UserFont        db 0                    ; Using a user-specified font
148
149                section .bss16
150                alignb 4
151GXPixCols       resw 1                  ; Graphics mode pixel columns
152GXPixRows       resw 1                  ; Graphics mode pixel rows
Note: See TracBrowser for help on using the browser.