1 ;; -----------------------------------------------------------------------
3 ;; Copyright 1994-2008 H. Peter Anvin - All Rights Reserved
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.
11 ;; -----------------------------------------------------------------------
13 ; ----------------------------------------------------------------------------
14 ; VGA splash screen code
15 ; ----------------------------------------------------------------------------
19 ; Display a graphical splash screen.
20 ; The file is already opened on the top of the getc stack.
22 ; Assumes CS == DS == ES.
27 ; This is a cheap and easy way to make sure the screen is
28 ; cleared in case we were in graphics mode already
43 ; The header WILL be in the first chunk.
44 cmp dword [LSSMagic],0x1413f33d ; Magic number
47 mov dx,GraphColorMap ; Color map offset
48 mov ax,1012h ; Set RGB registers
49 xor bx,bx ; First register number
50 mov cx,16 ; 16 registers
54 mov ax,[GraphYSize] ; Number of pixel rows
59 xor dx,dx ; Set column to 0
68 int 10h ; Set cursor below image
70 mov cx,[GraphYSize] ; Number of graphics rows
76 ; Pre-clear the row buffer
84 call rledecode ; Decode one row
87 mov di,0A000h ; VGA segment
102 ; Decode a pixel row in RLE16 format.
104 ; getc stack -> input
106 ; ES:DI -> output (packed pixel)
109 xor dx,dx ; DL = last pixel, DH = nybble buffer
113 je .run ; Start of run sequence
153 or dh,10h ; Nybble already read
159 ; Convert packed-pixel to VGA bitplanes
161 ; DS:SI -> packed pixel string
162 ; BP -> pixel count (multiple of 8)
166 mov dx,3C4h ; VGA Sequencer Register select port
167 mov al,2 ; Sequencer mask
168 out dx,al ; Select the sequencer mask
169 inc dx ; VGA Sequencer Register data port
181 rcl ch,1 ; VGA is bigendian. Sigh.
197 ; Enable VGA graphics, if possible; return ZF=1 on success
198 ; DS must be set to the base segment; ES is set to DS.
205 je .success ; Nothing to do...
208 ; We're in a VESA mode, which means VGA; use VESA call
209 ; to revert the mode, and then call the conventional
210 ; mode-setting for good measure...
216 mov ax,1A00h ; Get video card and monitor
219 sub bl, 7 ; BL=07h and BL=08h OK
222 ; mov bx,TextColorReg
223 ; mov dx,1009h ; Read color registers
226 mov ax,0012h ; Set mode = 640x480 VGA 16 colors
229 mov ax,1002h ; Write color registers
231 mov [UsingVGA], byte 1
233 ; Set GXPixCols and GXPixRows
234 mov dword [GXPixCols],640+(480 << 16)
236 call use_font ; Set graphics font/data
237 mov byte [ScrollAttribute], 00h
246 ; Disable VGA graphics. It is not safe to assume any value
257 and al,al ; Already in text mode?
261 mov ax,4F02h ; VESA return to normal video mode
265 mov ax,0003h ; Return to normal video mode
267 ; mov dx,TextColorReg ; Restore color registers
270 mov [UsingVGA], byte 0
272 mov byte [ScrollAttribute], 07h
273 call use_font ; Restore text font/data
281 ; vgashowcursor/vgahidecursor:
282 ; If VGA graphics is enabled, draw a cursor/clear a cursor
287 jmp short vgacursorcommon
292 cmp [UsingVGA], byte 1
304 ; Map colors to consecutive DAC registers
305 linear_color db 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0
307 ; See comboot.doc, INT 22h AX=0017h for the semantics
314 LSSMagic resd 1 ; Magic number
315 GraphXSize resw 1 ; Width of splash screen file
316 GraphYSize resw 1 ; Height of splash screen file
317 GraphColorMap resb 3*16
318 VGAPos resw 1 ; Pointer into VGA memory
319 VGAFilePtr resw 1 ; Pointer into VGAFileBuf
320 ; TextColorReg resb 17 ; VGA color registers for text mode
322 VGAFileBuf resb FILENAME_MAX+2 ; Unmangled VGA image name
324 VGAFileBuf resb FILENAME_MAX ; Unmangled VGA image name
327 VGAFileMBuf resb FILENAME_MAX ; Mangled VGA image name
329 ; We need a buffer of 640+80 bytes. At this point, command_line should
330 ; not be in use, so use that buffer.
331 VGARowBuffer equ command_line