From e41d512f3e23b32c461115b03ecd376bc410a3ed Mon Sep 17 00:00:00 2001 From: hpa Date: Thu, 19 Apr 2001 00:50:29 +0000 Subject: [PATCH] Introduce a way to return to text mode. Clean up the handling of mode transitions. --- NEWS | 4 ++ isolinux.asm | 117 +++++++++++++++++++++++++++++++++-------------------------- ldlinux.asm | 117 +++++++++++++++++++++++++++++++++-------------------------- pxelinux.asm | 117 +++++++++++++++++++++++++++++++++-------------------------- syslinux.doc | 3 ++ 5 files changed, 202 insertions(+), 156 deletions(-) diff --git a/NEWS b/NEWS index 4e98967..45c838d 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,10 @@ Changes in 1.62: * PXELINUX: Documentation fixes. * PXELINUX: Fix the "ipappend" option; the last two values were reversed vs. what the kernel expected. + * Introduce a way to return to text mode once we are already + in graphics mode. This may be useful for F-key help + screens. + * Fix several bugs in the way return to text mode was handled. Changes in 1.61: * ISOLINUX: Support full pathname searches. Max length for a diff --git a/isolinux.asm b/isolinux.asm index d3b510a..56d740b 100644 --- a/isolinux.asm +++ b/isolinux.asm @@ -2994,25 +2994,7 @@ strcpy: push ax and al,al jnz .loop pop ax - ret - -; -; adjust_screen: Set the internal variables associated with the screen size. -; This is a subroutine in case we're loading a custom font. -; -adjust_screen: - mov al,[BIOS_vidrows] - and al,al - jnz vidrows_is_ok - mov al,24 ; No vidrows in BIOS, assume 25 - ; (Remember: vidrows == rows-1) -vidrows_is_ok: mov [VidRows],al - mov ah,0fh - int 10h ; Read video state - mov [TextPage],bh - dec ah ; Store count-1 (same as rows) - mov [VidCols],ah -bf_ret: ret +lf_ret: ret ; ; loadfont: Load a .psf font file and install it onto the VGA console @@ -3026,43 +3008,42 @@ loadfont: mov ax,[trackbuf] ; Magic number cmp ax,0436h - jne bf_ret + jne lf_ret mov al,[trackbuf+2] ; File mode cmp al,5 ; Font modes 0-5 supported - ja bf_ret + ja lf_ret mov bh,byte [trackbuf+3] ; Height of font cmp bh,2 ; VGA minimum - jb bf_ret + jb lf_ret cmp bh,32 ; VGA maximum - ja bf_ret + ja lf_ret ; Copy to font buffer mov si,trackbuf+4 ; Start of font data mov [VGAFontSize],bh mov di,vgafontbuf - mov bp,di ; Address of font data for INT 10h mov cx,(32*256) >> 2 ; Maximum size rep movsd - xor bl,bl ; Needed by both INT 10h calls - cmp [UsingVGA], byte 1 ; Are we in graphics mode? - je .graphics - - mov cx,256 - xor dx,dx - mov ax,1110h - int 10h ; Load into VGA RAM + ; Fall through to use_font - xor bl,bl - mov ax,1103h ; Select page 0 - int 10h +; +; use_font: +; This routine activates whatever font happens to be in the +; vgafontbuf, and updates the adjust_screen data. +; +use_font: + mov bp,vgafontbuf + mov bh,[VGAFontSize] - jmp short adjust_screen + xor bl,bl ; Needed by both INT 10h calls + cmp [UsingVGA], byte 1 ; Are we in graphics mode? + jne .text .graphics: - ; CX = 0 on entry + xor cx,bx mov cl,bh ; CX = bytes/character mov ax,480 div cl ; Compute char rows per screen @@ -3071,9 +3052,40 @@ loadfont: mov [VidRows],al mov ax,1121h ; Set user character table int 10h - ; VidCols = 80, TextPage = 0 set by graphics mode select + mov [VidRows], byte 79 ; Always 80 bytes/line + mov [TextPage], byte 0 ; Always page 0 ret ; No need to call adjust_screen +.text: + mov cx,256 + xor dx,dx + mov ax,1110h + int 10h ; Load into VGA RAM + + xor bl,bl + mov ax,1103h ; Select page 0 + int 10h + + ; Fall through to adjust_screen + +; +; adjust_screen: Set the internal variables associated with the screen size. +; This is a subroutine in case we're loading a custom font. +; +adjust_screen: + mov al,[BIOS_vidrows] + and al,al + jnz vidrows_is_ok + mov al,24 ; No vidrows in BIOS, assume 25 + ; (Remember: vidrows == rows-1) +vidrows_is_ok: mov [VidRows],al + mov ah,0fh + int 10h ; Read video state + mov [TextPage],bh + dec ah ; Store count-1 (same as rows) + mov [VidCols],ah + ret + ; ; loadkeys: Load a LILO-style keymap; SI and DX:AX set by searchdir ; @@ -3151,6 +3163,8 @@ msg_putchar: ; Normal character je msg_newline cmp al,0Ch ; = clear screen je msg_formfeed + cmp al,19h ; = return to text mode + je near msg_novga cmp al,18h ; = VGA filename follows je near msg_vga jnb .not_modectl @@ -3254,6 +3268,10 @@ msg_setvgafileptr: mov [VGAFilePtr],di msg_ret: ret +msg_novga: + call vgaclearmode + jmp short msg_initvars + msg_viewimage: push es push ds @@ -4115,19 +4133,7 @@ vgasetmode: int 10h mov [UsingVGA], byte 1 - mov [VidCols], byte 79 ; Always 80 chars/screen - mov [TextPage], byte 0 ; Always page 0 - - mov cx,[VGAFontSize] - mov ax,480 - div cl - mov dl,al - dec al ; VidRows is stored -1 - mov [VidRows],al - mov bp,vgafontbuf - xor bx,bx - mov ax,1121h ; Set graphics font - int 10h + call use_font ; Set graphics font/data mov byte [ScrollAttribute], 00h xor ax,ax ; Set ZF @@ -4139,17 +4145,24 @@ vgasetmode: ; Disable VGA graphics. It is not safe to assume any value for DS. ; vgaclearmode: + push ds + push cs + pop ds ; DS <- CS pushad - cmp [cs:UsingVGA], byte 1 + cmp [UsingVGA], byte 1 jne .done mov ax,0003h ; Return to normal video mode int 10h ; mov dx,TextColorReg ; Restore color registers ; mov ax,1002h ; int 10h + + + call use_font ; Restore text font/data mov byte [ScrollAttribute], 07h .done: popad + pop ds ret ; diff --git a/ldlinux.asm b/ldlinux.asm index d8c717c..78329f8 100644 --- a/ldlinux.asm +++ b/ldlinux.asm @@ -2940,25 +2940,7 @@ dir_success: mov bx,ax or bx,dx ; Sets ZF iff DX:AX is zero dir_return: - ret - -; -; adjust_screen: Set the internal variables associated with the screen size. -; This is a subroutine in case we're loading a custom font. -; -adjust_screen: - mov al,[BIOS_vidrows] - and al,al - jnz vidrows_is_ok - mov al,24 ; No vidrows in BIOS, assume 25 - ; (Remember: vidrows == rows-1) -vidrows_is_ok: mov [VidRows],al - mov ah,0fh - int 10h ; Read video state - mov [TextPage],bh - dec ah ; Store count-1 (same as rows) - mov [VidCols],ah -bf_ret: ret +lf_ret: ret ; ; loadfont: Load a .psf font file and install it onto the VGA console @@ -2972,43 +2954,42 @@ loadfont: mov ax,[trackbuf] ; Magic number cmp ax,0436h - jne bf_ret + jne lf_ret mov al,[trackbuf+2] ; File mode cmp al,5 ; Font modes 0-5 supported - ja bf_ret + ja lf_ret mov bh,byte [trackbuf+3] ; Height of font cmp bh,2 ; VGA minimum - jb bf_ret + jb lf_ret cmp bh,32 ; VGA maximum - ja bf_ret + ja lf_ret ; Copy to font buffer mov si,trackbuf+4 ; Start of font data mov [VGAFontSize],bh mov di,vgafontbuf - mov bp,di ; Address of font data for INT 10h mov cx,(32*256) >> 2 ; Maximum size rep movsd - xor bl,bl ; Needed by both INT 10h calls - cmp [UsingVGA], byte 1 ; Are we in graphics mode? - je .graphics - - mov cx,256 - xor dx,dx - mov ax,1110h - int 10h ; Load into VGA RAM + ; Fall through to use_font - xor bl,bl - mov ax,1103h ; Select page 0 - int 10h +; +; use_font: +; This routine activates whatever font happens to be in the +; vgafontbuf, and updates the adjust_screen data. +; +use_font: + mov bp,vgafontbuf + mov bh,[VGAFontSize] - jmp short adjust_screen + xor bl,bl ; Needed by both INT 10h calls + cmp [UsingVGA], byte 1 ; Are we in graphics mode? + jne .text .graphics: - ; CX = 0 on entry + xor cx,bx mov cl,bh ; CX = bytes/character mov ax,480 div cl ; Compute char rows per screen @@ -3017,9 +2998,40 @@ loadfont: mov [VidRows],al mov ax,1121h ; Set user character table int 10h - ; VidCols = 80, TextPage = 0 set by graphics mode select + mov [VidRows], byte 79 ; Always 80 bytes/line + mov [TextPage], byte 0 ; Always page 0 ret ; No need to call adjust_screen +.text: + mov cx,256 + xor dx,dx + mov ax,1110h + int 10h ; Load into VGA RAM + + xor bl,bl + mov ax,1103h ; Select page 0 + int 10h + + ; Fall through to adjust_screen + +; +; adjust_screen: Set the internal variables associated with the screen size. +; This is a subroutine in case we're loading a custom font. +; +adjust_screen: + mov al,[BIOS_vidrows] + and al,al + jnz vidrows_is_ok + mov al,24 ; No vidrows in BIOS, assume 25 + ; (Remember: vidrows == rows-1) +vidrows_is_ok: mov [VidRows],al + mov ah,0fh + int 10h ; Read video state + mov [TextPage],bh + dec ah ; Store count-1 (same as rows) + mov [VidCols],ah + ret + ; ; loadkeys: Load a LILO-style keymap; SI and DX:AX set by searchdir ; @@ -3097,6 +3109,8 @@ msg_putchar: ; Normal character je msg_newline cmp al,0Ch ; = clear screen je msg_formfeed + cmp al,19h ; = return to text mode + je near msg_novga cmp al,18h ; = VGA filename follows je near msg_vga jnb .not_modectl @@ -3200,6 +3214,10 @@ msg_setvgafileptr: mov [VGAFilePtr],di msg_ret: ret +msg_novga: + call vgaclearmode + jmp short msg_initvars + msg_viewimage: push es push ds @@ -4085,19 +4103,7 @@ vgasetmode: int 10h mov [UsingVGA], byte 1 - mov [VidCols], byte 79 ; Always 80 chars/screen - mov [TextPage], byte 0 ; Always page 0 - - mov cx,[VGAFontSize] - mov ax,480 - div cl - mov dl,al - dec al ; VidRows is stored -1 - mov [VidRows],al - mov bp,vgafontbuf - xor bx,bx - mov ax,1121h ; Set graphics font - int 10h + call use_font ; Set graphics font/data mov byte [ScrollAttribute], 00h xor ax,ax ; Set ZF @@ -4109,17 +4115,24 @@ vgasetmode: ; Disable VGA graphics. It is not safe to assume any value for DS. ; vgaclearmode: + push ds + push cs + pop ds ; DS <- CS pushad - cmp [cs:UsingVGA], byte 1 + cmp [UsingVGA], byte 1 jne .done mov ax,0003h ; Return to normal video mode int 10h ; mov dx,TextColorReg ; Restore color registers ; mov ax,1002h ; int 10h + + + call use_font ; Restore text font/data mov byte [ScrollAttribute], 07h .done: popad + pop ds ret ; diff --git a/pxelinux.asm b/pxelinux.asm index 99e0793..48696e3 100644 --- a/pxelinux.asm +++ b/pxelinux.asm @@ -3005,25 +3005,7 @@ strcpy: push ax and al,al jnz .loop pop ax - ret - -; -; adjust_screen: Set the internal variables associated with the screen size. -; This is a subroutine in case we're loading a custom font. -; -adjust_screen: - mov al,[BIOS_vidrows] - and al,al - jnz vidrows_is_ok - mov al,24 ; No vidrows in BIOS, assume 25 - ; (Remember: vidrows == rows-1) -vidrows_is_ok: mov [VidRows],al - mov ah,0fh - int 10h ; Read video state - mov [TextPage],bh - dec ah ; Store count-1 (same as rows) - mov [VidCols],ah -bf_ret: ret +lf_ret: ret ; ; loadfont: Load a .psf font file and install it onto the VGA console @@ -3037,43 +3019,42 @@ loadfont: mov ax,[trackbuf] ; Magic number cmp ax,0436h - jne bf_ret + jne lf_ret mov al,[trackbuf+2] ; File mode cmp al,5 ; Font modes 0-5 supported - ja bf_ret + ja lf_ret mov bh,byte [trackbuf+3] ; Height of font cmp bh,2 ; VGA minimum - jb bf_ret + jb lf_ret cmp bh,32 ; VGA maximum - ja bf_ret + ja lf_ret ; Copy to font buffer mov si,trackbuf+4 ; Start of font data mov [VGAFontSize],bh mov di,vgafontbuf - mov bp,di ; Address of font data for INT 10h mov cx,(32*256) >> 2 ; Maximum size rep movsd - xor bl,bl ; Needed by both INT 10h calls - cmp [UsingVGA], byte 1 ; Are we in graphics mode? - je .graphics - - mov cx,256 - xor dx,dx - mov ax,1110h - int 10h ; Load into VGA RAM + ; Fall through to use_font - xor bl,bl - mov ax,1103h ; Select page 0 - int 10h +; +; use_font: +; This routine activates whatever font happens to be in the +; vgafontbuf, and updates the adjust_screen data. +; +use_font: + mov bp,vgafontbuf + mov bh,[VGAFontSize] - jmp short adjust_screen + xor bl,bl ; Needed by both INT 10h calls + cmp [UsingVGA], byte 1 ; Are we in graphics mode? + jne .text .graphics: - ; CX = 0 on entry + xor cx,bx mov cl,bh ; CX = bytes/character mov ax,480 div cl ; Compute char rows per screen @@ -3082,9 +3063,40 @@ loadfont: mov [VidRows],al mov ax,1121h ; Set user character table int 10h - ; VidCols = 80, TextPage = 0 set by graphics mode select + mov [VidRows], byte 79 ; Always 80 bytes/line + mov [TextPage], byte 0 ; Always page 0 ret ; No need to call adjust_screen +.text: + mov cx,256 + xor dx,dx + mov ax,1110h + int 10h ; Load into VGA RAM + + xor bl,bl + mov ax,1103h ; Select page 0 + int 10h + + ; Fall through to adjust_screen + +; +; adjust_screen: Set the internal variables associated with the screen size. +; This is a subroutine in case we're loading a custom font. +; +adjust_screen: + mov al,[BIOS_vidrows] + and al,al + jnz .vidrows_ok + mov al,24 ; No vidrows in BIOS, assume 25 + ; (Remember: vidrows == rows-1) +.vidrows_ok: mov [VidRows],al + mov ah,0fh + int 10h ; Read video state + mov [TextPage],bh + dec ah ; Store count-1 (same as rows) + mov [VidCols],ah + ret + ; ; loadkeys: Load a LILO-style keymap; SI and DX:AX set by searchdir ; @@ -3162,6 +3174,8 @@ msg_putchar: ; Normal character je msg_newline cmp al,0Ch ; = clear screen je msg_formfeed + cmp al,19h ; = return to text mode + je near msg_novga cmp al,18h ; = VGA filename follows je near msg_vga jnb .not_modectl @@ -3265,6 +3279,10 @@ msg_setvgafileptr: mov [VGAFilePtr],di msg_ret: ret +msg_novga: + call vgaclearmode + jmp short msg_initvars + msg_viewimage: push es push ds @@ -4578,19 +4596,7 @@ vgasetmode: int 10h mov [UsingVGA], byte 1 - mov [VidCols], byte 79 ; Always 80 chars/screen - mov [TextPage], byte 0 ; Always page 0 - - mov cx,[VGAFontSize] - mov ax,480 - div cl - mov dl,al - dec al ; VidRows is stored -1 - mov [VidRows],al - mov bp,vgafontbuf - xor bx,bx - mov ax,1121h ; Set graphics font - int 10h + call use_font ; Set graphics font/data mov byte [ScrollAttribute], 00h xor ax,ax ; Set ZF @@ -4602,17 +4608,24 @@ vgasetmode: ; Disable VGA graphics. It is not safe to assume any value for DS. ; vgaclearmode: + push ds + push cs + pop ds ; DS <- CS pushad - cmp [cs:UsingVGA], byte 1 + cmp [UsingVGA], byte 1 jne .done mov ax,0003h ; Return to normal video mode int 10h ; mov dx,TextColorReg ; Restore color registers ; mov ax,1002h ; int 10h + + + call use_font ; Restore text font/data mov byte [ScrollAttribute], 07h .done: popad + pop ds ret ; diff --git a/syslinux.doc b/syslinux.doc index 2c274dc..bdf36d6 100644 --- a/syslinux.doc +++ b/syslinux.doc @@ -352,6 +352,9 @@ are interpreted: care: 0 is the background color, and 7 is the color used for the text printed by SYSLINUX itself. + = = ASCII 25 + If we are currently in graphics mode, return to text mode. + .. .. = ASCII 16-23 These codes can be used to select which modes to print a certain part of the message file in. Each of these control -- 2.7.4