1 ;; -----------------------------------------------------------------------
3 ;; Copyright 1994-2002 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.
23 ; SI = cluster/socket pointer
31 ; This is a cheap and easy way to make sure the screen is
32 ; cleared in case we were in graphics mode already
38 mov ax,xfer_buf_seg ; Use as temporary storage
42 call vgagetchunk ; Get the first chunk
44 ; The header WILL be in the first chunk.
45 cmp dword [es:xbs_vgabuf],0x1413f33d ; Magic number
47 mov ax,[es:xbs_vgabuf+4]
50 mov dx,xbs_vgabuf+8 ; Color map offset
51 mov ax,1012h ; Set RGB registers
52 xor bx,bx ; First register number
53 mov cx,16 ; 16 registers
57 mov ax,[es:xbs_vgabuf+6] ; Number of pixel rows
62 xor dx,dx ; Set column to 0
71 int 10h ; Set cursor below image
73 mov cx,[es:xbs_vgabuf+6] ; Number of graphics rows
75 mov si,xbs_vgabuf+8+3*16 ; Beginning of pixel data
81 mov di,xbs_vgatmpbuf ; Row buffer
82 call rledecode ; Decode one row
89 rep stosd ; Clear rest of row
90 mov di,0A000h ; VGA segment
95 add word [VGAPos],byte 80 ; Advance to next pixel row
108 ; Decode a pixel row in RLE16 format.
112 ; ES:DI -> output (packed pixel)
115 shl esi,1 ; Nybble pointer
116 xor dl,dl ; Last pixel
120 je .run ; Start of run sequence
164 cmp si,xbs_vgabuf+trackbufsize ; Chunk overrun
167 mov si,xbs_vgabuf ; Start at beginning of buffer
174 ; Get a new trackbufsize chunk of VGA image data
176 ; On input, ES is assumed to point to the buffer segment.
182 jz .eof ; EOF overrun, not much to do...
184 mov cx,[BufSafe] ; One trackbuf worth of data
190 .noteof: mov [VGACluster],si
197 ; Convert packed-pixel to VGA bitplanes
199 ; FS:SI -> packed pixel string
200 ; BP -> pixel count (multiple of 8)
204 mov dx,3C4h ; VGA Sequencer Register select port
205 mov al,2 ; Sequencer mask
206 out dx,al ; Select the sequencer mask
207 inc dx ; VGA Sequencer Register data port
219 rcl ch,1 ; VGA is bigendian. Sigh.
235 ; Enable VGA graphics, if possible; return ZF=1 on success
236 ; DS must be set to the base segment; ES is set to DS.
243 je .success ; Nothing to do...
246 ; We're in a VESA mode, which means VGA; use VESA call
247 ; to revert the mode, and then call the conventional
248 ; mode-setting for good measure...
254 mov ax,1A00h ; Get video card and monitor
257 sub bl, 7 ; BL=07h and BL=08h OK
260 ; mov bx,TextColorReg
261 ; mov dx,1009h ; Read color registers
264 mov ax,0012h ; Set mode = 640x480 VGA 16 colors
267 mov ax,1002h ; Write color registers
269 mov [UsingVGA], byte 1
271 ; Set GXPixCols and GXPixRows
272 mov dword [GXPixCols],640+(480 << 16)
274 call use_font ; Set graphics font/data
275 mov byte [ScrollAttribute], 00h
284 ; Disable VGA graphics. It is not safe to assume any value
295 and al,al ; Already in text mode?
299 mov ax,4F02h ; VESA return to normal video mode
303 mov ax,0003h ; Return to normal video mode
305 ; mov dx,TextColorReg ; Restore color registers
308 mov [UsingVGA], byte 0
310 mov byte [ScrollAttribute], 07h
311 call use_font ; Restore text font/data
319 ; vgashowcursor/vgahidecursor:
320 ; If VGA graphics is enabled, draw a cursor/clear a cursor
325 jmp short vgacursorcommon
330 cmp [UsingVGA], byte 1
342 ; Map colors to consecutive DAC registers
343 linear_color db 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0
345 ; See comboot.doc, INT 22h AX=0017h for the semantics
351 GraphXSize resw 1 ; Width of splash screen file
352 VGAPos resw 1 ; Pointer into VGA memory
353 VGACluster resw 1 ; Cluster pointer for VGA image file
354 VGAFilePtr resw 1 ; Pointer into VGAFileBuf
355 TextColorReg resb 17 ; VGA color registers for text mode
357 VGAFileBuf resb FILENAME_MAX+2 ; Unmangled VGA image name
359 VGAFileBuf resb FILENAME_MAX ; Unmangled VGA image name
362 VGAFileMBuf resb FILENAME_MAX ; Mangled VGA image name