abrash-black-book/29-05.md
2013-12-30 20:26:41 +11:00

109 lines
5.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

### Overscan {#Heading5}
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.
------------------- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
![](images/i.jpg) *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.*
------------------- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
### A Bonus Blanker {#Heading6}
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.
**LISTING 29.4 L29-4.ASM**
; 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