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
92 mov di,0A000h ; VGA segment
97 add word [VGAPos],640/8
102 jmp close ; Tailcall!
106 ; Decode a pixel row in RLE16 format.
108 ; getc stack -> input
110 ; ES:DI -> output (packed pixel)
113 xor dx,dx ; DL = last pixel, DH = nybble buffer
117 je .run ; Start of run sequence
157 or dh,10h ; Nybble already read
163 ; Convert packed-pixel to VGA bitplanes
165 ; DS:SI -> packed pixel string
166 ; BP -> pixel count (multiple of 8)
167 ; DS:DI -> output (four planes)
180 rcl dl,1 ; VGA is bigendian. Sigh.
195 ; Output four subsequent lines of VGA data
197 ; DS:SI -> four planes @ 640/8=80 bytes
198 ; ES:DI -> pointer into VGA memory
201 mov dx,3C4h ; VGA Sequencer Register select port
202 mov al,2 ; Sequencer mask
203 out dx,al ; Select the sequencer mask
204 inc dx ; VGA Sequencer Register data port
207 out dx,al ; Select the bit plane to write
219 ; Enable VGA graphics, if possible; return ZF=1 on success
220 ; DS must be set to the base segment; ES is set to DS.
227 je .success ; Nothing to do...
230 ; We're in a VESA mode, which means VGA; use VESA call
231 ; to revert the mode, and then call the conventional
232 ; mode-setting for good measure...
238 mov ax,1A00h ; Get video card and monitor
241 sub bl, 7 ; BL=07h and BL=08h OK
244 ; mov bx,TextColorReg
245 ; mov dx,1009h ; Read color registers
248 mov ax,0012h ; Set mode = 640x480 VGA 16 colors
251 mov ax,1002h ; Write color registers
253 mov [UsingVGA], byte 1
255 ; Set GXPixCols and GXPixRows
256 mov dword [GXPixCols],640+(480 << 16)
258 call use_font ; Set graphics font/data
259 mov byte [ScrollAttribute], 00h
268 ; Disable VGA graphics. It is not safe to assume any value
279 and al,al ; Already in text mode?
283 mov ax,4F02h ; VESA return to normal video mode
287 mov ax,0003h ; Return to normal video mode
289 ; mov dx,TextColorReg ; Restore color registers
292 mov [UsingVGA], byte 0
294 mov byte [ScrollAttribute], 07h
295 call use_font ; Restore text font/data
303 ; vgashowcursor/vgahidecursor:
304 ; If VGA graphics is enabled, draw a cursor/clear a cursor
309 jmp short vgacursorcommon
314 cmp [UsingVGA], byte 1
326 ; Map colors to consecutive DAC registers
327 linear_color db 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0
329 ; See comboot.doc, INT 22h AX=0017h for the semantics
336 LSSMagic resd 1 ; Magic number
337 GraphXSize resw 1 ; Width of splash screen file
338 GraphYSize resw 1 ; Height of splash screen file
339 GraphColorMap resb 3*16
340 VGAPos resw 1 ; Pointer into VGA memory
341 VGAFilePtr resw 1 ; Pointer into VGAFileBuf
342 ; TextColorReg resb 17 ; VGA color registers for text mode
344 VGAFileBuf resb FILENAME_MAX+2 ; Unmangled VGA image name
346 VGAFileBuf resb FILENAME_MAX ; Unmangled VGA image name
349 VGAFileMBuf resb FILENAME_MAX ; Mangled VGA image name
352 VGARowBuffer resb 640+80 ; Decompression buffer
353 VGAPlaneBuffer resb (640/8)*4 ; Plane buffers