158 lines
6.2 KiB
HTML
158 lines
6.2 KiB
HTML
<HTML>
|
|
<HEAD>
|
|
<META name=vsisbn content="1576101746">
|
|
<META name=vstitle content="Michael Abrash's Graphics Programming Black Book, Special Edition">
|
|
<META name=vsauthor content="Michael Abrash">
|
|
<META name=vspublisher content="The Coriolis Group">
|
|
<META name=vspubdate content="07/01/97">
|
|
<META name=vscategory content="Web and Software Development: Game Development,Web and Software Development: Graphics and Multimedia Development">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<TITLE>Michael Abrash's Graphics Programming Black Book Special Edition: Saving Screens and Other VGA Mysteries</TITLE>
|
|
|
|
<!-- HEADER -->
|
|
<!-- Empty Reference Subhead -->
|
|
|
|
<!--ISBN=1576101746//-->
|
|
<!--TITLE=Michael Abrash's Graphics Programming Black Book Special Edition//-->
|
|
<!--AUTHOR=Michael Abrash//-->
|
|
<!--PUBLISHER=The Coriolis Group, Inc.//-->
|
|
<!--CHAPTER=29//-->
|
|
<!--PAGES=555-557//-->
|
|
<!--UNASSIGNED1//-->
|
|
<!--UNASSIGNED2//--></HEAD><BODY LINK=#0000FF ALINK=#000099 VLINK=#0000FF BGCOLOR=#FFFFFF>
|
|
|
|
<CENTER>
|
|
<TABLE BORDER>
|
|
<TR>
|
|
<TD><A HREF="29-04.html">Previous</A></TD>
|
|
<TD><A HREF="index.html">Table of Contents</A></TD>
|
|
<TD><A HREF="29-06.html">Next</A></TD>
|
|
</TR>
|
|
</TABLE>
|
|
</CENTER>
|
|
<P><BR></P>
|
|
<H3><A NAME="Heading5"></A><FONT COLOR="#000077">Overscan</FONT></H3>
|
|
<P>While we’re at it, I’m going to touch on overscan. Overscan is the color of the border of the display, the rectangular area around the edge of the monitor that’s outside the region displaying active video data but inside the blanking area. The overscan (or border) color can be programmed to any of the 64 possible colors by either setting Attribute Controller register 11H directly or calling video function 10H, subfunction 1.
|
|
</P>
|
|
<TABLE WIDTH="100%"><TD WIDTH="5%" VALIGN="TOP"><IMG SRC="images/29-03i.jpg"><TD WIDTH="95%"><SMALL><I>On ECD-compatible monitors, however, there’s too little scan time to display a proper border when the EGA is in 350-scan-line mode, so overscan should always be 0 (black) unless you’re in 200-scanmode. Note, though, that a VGA can easily display a border on a VGA-compatible monitor, and VGAs are in fact programmed at mode set for an 8-pixel-wide border in all modes; all you need do is set the overscan color on any VGA to see the border.</I></SMALL>
|
|
</TABLE>
|
|
<H3><A NAME="Heading6"></A><FONT COLOR="#000077">A Bonus Blanker</FONT></H3>
|
|
<P>An interesting bonus: The Attribute Controller provides a very convenient way to blank the screen, in the form of the aforementioned bit 5 of the Attribute Controller Index register (at address 3C0H after the Input Status 1 register—3DAH in color, 3BAH in monochrome—has been read and on every other write to 3C0H thereafter). Whenever bit 5 of the AC Index register is 0, video data is cut off, effectively blanking the screen. Setting bit 5 of the AC Index back to 1 restores video data immediately. Listing 29.4 illustrates this simple but effective form of screen blanking.
|
|
</P>
|
|
<P><B>LISTING 29.4 L29-4.ASM</B></P>
|
|
<!-- CODE //-->
|
|
<PRE>
|
|
; Program to demonstrate screen blanking via bit 5 of the
|
|
; Attribute Controller Index register.
|
|
;
|
|
AC_INDEX equ 3c0h ;Attribute Controller Index register
|
|
INPUT_STATUS_1 equ 3dah ;color-mode address of the Input
|
|
; Status 1 register
|
|
;
|
|
; Macro to wait for and clear the next keypress.
|
|
;
|
|
WAIT_KEY macro
|
|
mov ah,8 ;DOS input without echo function
|
|
int 21h
|
|
endm
|
|
;
|
|
stack segment para stack ‘STACK’
|
|
db512 dup (?)
|
|
stack ends
|
|
;
|
|
Data segment word ‘DATA’
|
|
SampleText db ‘This is bit-mapped text, drawn in hi-res ’
|
|
db ‘EGA graphics mode 10h.’, 0dh, 0ah, 0ah
|
|
db ‘Press any key to blank the screen, then ’
|
|
db ‘any key to unblank it,’, 0dh, 0ah
|
|
db ‘then any key to end.$’
|
|
Data ends
|
|
;
|
|
Code segment
|
|
assume cs:Code, ds:Data
|
|
Start proc near
|
|
mov ax,Data
|
|
mov ds,ax
|
|
;
|
|
; Go to hi-res graphics mode.
|
|
;
|
|
mov ax,10h ;AH = 0 means mode set, AL = 10h selects
|
|
; hi-res graphics mode
|
|
int 10h ;BIOS video interrupt
|
|
;
|
|
; Put up some text, so the screen isn’t empty.
|
|
;
|
|
mov ah,9 ;DOS print string function
|
|
mov dx,offset SampleText
|
|
int 21h
|
|
;
|
|
WAIT_KEY
|
|
;
|
|
; Blank the screen.
|
|
;
|
|
mov dx,INPUT_STATUS_1
|
|
in al,dx ;reset port 3c0h to index (rather than data)
|
|
; mode
|
|
mov dx,AC_INDEX
|
|
sub al,al ;make bit 5 zero...
|
|
out dx,al ;...which blanks the screen
|
|
;
|
|
WAIT_KEY
|
|
;
|
|
; Unblank the screen.
|
|
;
|
|
mov dx,INPUT_STATUS_1
|
|
in al,dx ;reset port 3c0h to Index (rather than data)
|
|
; mode
|
|
mov dx,AC_INDEX
|
|
mov al,20h ;make bit 5 one...
|
|
out dx,al ;...which unblanks the screen
|
|
;
|
|
WAIT_KEY
|
|
;
|
|
; Restore text mode.
|
|
;
|
|
mov ax,2
|
|
int 10h
|
|
;
|
|
; Done.
|
|
;
|
|
Done:
|
|
mov ah,4ch ;DOS terminate function
|
|
int 21h
|
|
Start endp
|
|
Code ends
|
|
end Start
|
|
</PRE>
|
|
<!-- END CODE //-->
|
|
<P><BR></P>
|
|
<CENTER>
|
|
<TABLE BORDER>
|
|
<TR>
|
|
<TD><A HREF="29-04.html">Previous</A></TD>
|
|
<TD><A HREF="index.html">Table of Contents</A></TD>
|
|
<TD><A HREF="29-06.html">Next</A></TD>
|
|
</TR>
|
|
</TABLE>
|
|
</CENTER>
|
|
|
|
<hr width="90%" size="1" noshade>
|
|
<div align="center">
|
|
<font face="Verdana,sans-serif" size="1">Graphics Programming Black Book © 2001 Michael Abrash</font>
|
|
</div>
|
|
<!-- all of the reference materials (books) have the footer and subfoot reveresed -->
|
|
<!-- reference_subfoot = footer -->
|
|
<!-- reference_footer = subfoot -->
|
|
|
|
<!-- BEGIN SUB FOOTER -->
|
|
</BODY>
|
|
</HTML>
|
|
|
|
<!-- END FOOTER -->
|
|
|
|
|