Magellan Linux

Diff of /trunk/mkinitrd-magellan/isolinux/font.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1132 by niro, Sat Sep 1 22:45:15 2007 UTC revision 1133 by niro, Thu Aug 19 09:50:43 2010 UTC
# Line 1  Line 1 
 ;; $Id: font.inc,v 1.1 2007-09-01 22:44:04 niro Exp $  
1  ;; -----------------------------------------------------------------------  ;; -----------------------------------------------------------------------
2  ;;    ;;
3  ;;   Copyright 1994-2004 H. Peter Anvin - All Rights Reserved  ;;   Copyright 1994-2008 H. Peter Anvin - All Rights Reserved
4  ;;  ;;
5  ;;   This program is free software; you can redistribute it and/or modify  ;;   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  ;;   it under the terms of the GNU General Public License as published by
# Line 21  Line 20 
20    
21  ;  ;
22  ; loadfont: Load a .psf font file and install it onto the VGA console  ; 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  ; (if we're not on a VGA screen then ignore.)
24  ; SI and DX:AX set by routine searchdir  ; The font is on top of the getc stack.
25  ;  ;
26    loadfont.err: jmp close ; Tailcall the close routine
27    
28  loadfont:  loadfont:
29   mov bx,trackbuf ; The trackbuf is >= 16K; the part   mov di,trackbuf
30   mov cx,[BufSafe] ; of a PSF file we care about is no   mov cx,4
31   call getfssec ; more than 8K+4 bytes   call readc ; Read header
32     jc .err
33    
34   mov ax,[trackbuf] ; Magic number   mov ax,[trackbuf] ; Magic number
35   cmp ax,0436h   cmp ax,0436h
36   jne lf_ret   jne .err
37    
38   mov al,[trackbuf+2] ; File mode   mov al,[trackbuf+2] ; File mode
39   cmp al,5 ; Font modes 0-5 supported   cmp al,5 ; Font modes 0-5 supported
40   ja lf_ret   ja .err
41    
42   mov bh,byte [trackbuf+3] ; Height of font   xor bx,bx
43     mov bh,[trackbuf+3] ; Height of font
44   cmp bh,2 ; VGA minimum   cmp bh,2 ; VGA minimum
45   jb lf_ret   jb .err
46   cmp bh,32 ; VGA maximum   cmp bh,32 ; VGA maximum
47   ja lf_ret   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   ; Copy to font buffer
58   mov si,trackbuf+4 ; Start of font data   mov si,trackbuf ; Start of font data
59   mov [VGAFontSize],bh   mov [VGAFontSize],bh
60   mov di,vgafontbuf   push es
61   mov cx,(32*256) >> 2 ; Maximum size   mov cx,aux_seg
62     mov es,cx
63     mov di,aux.fontbuf
64     mov cx,bx
65     shr cx,2
66   rep movsd   rep movsd
67     pop es
68    
69   mov [UserFont], byte 1 ; Set font flag   mov [UserFont], byte 1 ; Set font flag
70    
  ; Fall through to use_font  
   
71  ;  ;
72  ; use_font:  ; use_font:
73  ; This routine activates whatever font happens to be in the  ; This routine activates whatever font happens to be in the
74  ; vgafontbuf, and updates the adjust_screen data.  ; vgafontbuf, and updates the adjust_screen data.
75  ;       Must be called with CS = DS = ES  ;       Must be called with CS = DS
76  ;  ;
77  use_font:  use_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?   test [UserFont], byte 1 ; Are we using a user-specified font?
84   jz adjust_screen ; If not, just do the normal stuff   jz adjust_screen ; If not, just do the normal stuff
85    
86   mov bp,vgafontbuf   push es
87   mov bh,[VGAFontSize]   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   xor bl,bl ; Needed by both INT 10h calls
93   cmp [UsingVGA], byte 1 ; Are we in graphics mode?  
94   jne .text   test byte [UsingVGA], 01h ; Are we in graphics mode?
95     jz .text
96    
97  .graphics:  .graphics:
98   xor cx,cx   xor cx,cx
99   mov cl,bh ; CX = bytes/character   mov cl,bh ; CX = bytes/character
100   mov ax,480   mov ax,[GXPixRows]
101   div cl ; Compute char rows per screen   div cl ; Compute char rows per screen
102   mov dl,al   mov dl,al
103   dec al   dec ax
104   mov [VidRows],al   mov [VidRows],al
105   mov ax,1121h ; Set user character table   mov ax,1121h ; Set user character table
106   int 10h   int 10h
107   mov [VidCols], byte 79 ; Always 80 bytes/line   mov ax,[GXPixCols]
108  .lf_ret: ret ; No need to call adjust_screen   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:  .text:
115   mov cx,256   mov cx,256
116   xor dx,dx   xor dx,dx
117   mov ax,1110h   mov ax,1110h
118   int 10h ; Load into VGA RAM   int 10h ; Load into VGA RAM
119     pop es
120    
121   xor bl,bl   xor bl,bl
122   mov ax,1103h ; Select page 0   mov ax,1103h ; Select page 0
123   int 10h   int 10h
124    
  ; Fall through to adjust_screen  
   
 lf_ret equ use_font.lf_ret  
   
125  ;  ;
126  ; adjust_screen: Set the internal variables associated with the screen size.  ; adjust_screen: Set the internal variables associated with the screen size.
127  ; This is a subroutine in case we're loading a custom font.  ; This is a subroutine in case we're loading a custom font.
# Line 117  vidrows_ok: mov [VidRows],al Line 141  vidrows_ok: mov [VidRows],al
141   popa   popa
142   ret   ret
143    
   
 ; VGA font buffer at the end of memory (so loading a font works even  
 ; in graphics mode, but don't put too much pressure on the .bss)  
  section .latebss  
 vgafontbuf resb 8192  
   
144   section .data   section .data
145   align 2, db 0   alignz 2
146  VGAFontSize dw 16 ; Defaults to 16 byte font  VGAFontSize dw 16 ; Defaults to 16 byte font
147  UserFont db 0 ; Using a user-specified font  UserFont db 0 ; Using a user-specified font
148    
149     section .bss1
150     alignb 4
151    GXPixCols resw 1 ; Graphics mode pixel columns
152    GXPixRows resw 1 ; Graphics mode pixel rows

Legend:
Removed from v.1132  
changed lines
  Added in v.1133