Normal quotes

This commit is contained in:
James Gregory 2013-12-30 18:34:31 +11:00
commit 18011c595a
352 changed files with 6040 additions and 6040 deletions

View file

@ -8,32 +8,32 @@ Chapter 29\
### Useful Nuggets from the VGA Zen File {#Heading2}
There are a number of VGA graphics topics that aren’t quite involved
There are a number of VGA graphics topics that aren't quite involved
enough to warrant their own chapters, yet still cause a fair amount of
programmer headscratching—and thus deserve treatment somewhere in this
book. This is the place, and during the course of this chapter we’ll
book. This is the place, and during the course of this chapter we'll
touch on saving and restoring 16-color EGA and VGA screens, the
16-out-of-64 colors issue, and techniques involved in reading and
writing VGA control registers.
That’s a lot of ground to cover, so let’s get started!
That's a lot of ground to cover, so let's get started!
### Saving and Restoring EGA and VGA Screens {#Heading3}
The memory architectures of EGAs and VGAs are similar enough to treat
both together in this regard. The basic principle for saving EGA and VGA
16-color graphics screens is astonishingly simple: Write each plane to
disk separately. Let’s take a look at how this works in the EGA’s hi-res
disk separately. Let's take a look at how this works in the EGA's hi-res
mode 10H, which provides 16 colors at 640x350.
All we need do is enable reads from plane 0 and write the 28,000 bytes
of plane 0 that are displayed in mode 10H to disk, then enable reads
from plane 1 and write the displayed portion of that plane to disk, and
so on for planes 2 and 3. The result is a file that’s 112,000 (28,000 \*
so on for planes 2 and 3. The result is a file that's 112,000 (28,000 \*
4) bytes long, with the planes stored as four distinct 28,000-byte
blocks, as shown in Figure 29.1.
The program shown later on in Listing 29.1 does just what I’ve described
The program shown later on in Listing 29.1 does just what I've described
here, putting the screen into mode 10H, putting up some bittext so there
is something to save, and creating the 112K file SNAPSHOT.SCR, which
contains the visible portion of the mode 10H frame buffer.
@ -41,7 +41,7 @@ contains the visible portion of the mode 10H frame buffer.
![](images/29-01.jpg)\
**Figure 29.1**  *Saving EGA/VGA display memory.*
The only part of Listing 29.1 that’s even remotely tricky is the use of
The only part of Listing 29.1 that's even remotely tricky is the use of
the Read Map register (Graphics Controller register 4) to make each of
the four planes of display memory readable in turn. The same code is
used to write 28,000 bytes of display memory to disk four times, and
@ -52,7 +52,7 @@ back to Figure 29.1; you may also want to reread Chapter 28 to brush up
on the operation of the Read Map register in particular and reading EGA
and VGA memory in general.)
Of course, we’ll want the ability to restore what we’ve saved, and
Of course, we'll want the ability to restore what we've saved, and
Listing 29.2 does this. Listing 29.2 reverses the action of Listing
29.1, selecting mode 10H and then loading 28,000 bytes from SNAPSHOT.SCR
into each plane of display memory. The Map Mask register (Sequence
@ -73,20 +73,20 @@ by Listing 29.1 back into the mode 10H frame buffer.
DISPLAYED_SCREEN_SIZE equ (640/8)*350 ;# of displayed bytes per plane in a
; hi-res graphics screen
;
stack segment para stack ‘STACK’
stack segment para stack ‘STACK'
db 512 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 ‘Saving the screen (including this text)...’
db 0dh, 0ah, ‘$’
Filename db ‘SNAPSHOT.SCR’,0 ;name of file we’re saving to
ErrMsg1 db ‘*** Couldn’t open SNAPSHOT.SCR ***’,0dh,0ah,‘$’
ErrMsg2 db ‘*** Error writing to SNAPSHOT.SCR ***’,0dh,0ah,‘$’
WaitKeyMsg db 0dh, 0ah, ‘Done. Press any key to end...’,0dh,0ah,‘$’
Handle dw ? ;handle of file we’re saving to
Data segment word ‘DATA'
SampleText db ‘This is bit-mapped text, drawn in hi-res '
db ‘EGA graphics mode 10h.', 0dh, 0ah, 0ah
db ‘Saving the screen (including this text)...'
db 0dh, 0ah, ‘$'
Filename db ‘SNAPSHOT.SCR',0 ;name of file we're saving to
ErrMsg1 db ‘*** Couldn't open SNAPSHOT.SCR ***',0dh,0ah,‘$'
ErrMsg2 db ‘*** Error writing to SNAPSHOT.SCR ***',0dh,0ah,‘$'
WaitKeyMsg db 0dh, 0ah, ‘Done. Press any key to end...',0dh,0ah,‘$'
Handle dw ? ;handle of file we're saving to
Plane db ? ;plane being read
Data ends
;
@ -102,7 +102,7 @@ by Listing 29.1 back into the mode 10H frame buffer.
; hi-res graphics mode
int 10h ;BIOS video interrupt
;
; Put up some text, so the screen isn’t empty.
; Put up some text, so the screen isn't empty.
;
mov ah,9 ;DOS print string function
mov dx,offset SampleText
@ -121,7 +121,7 @@ by Listing 29.1 back into the mode 10H frame buffer.
sub cx,cx ;make it a normal file
int 21h
mov [Handle],ax ;save the handle
jnc SaveTheScreen ;we’re ready to save if no error
jnc SaveTheScreen ;we're ready to save if no error
mov ah,9 ;DOS print string function
mov dx,offset ErrMsg1
int 21h ;notify of the error