Normal quotes
This commit is contained in:
parent
5e10794a24
commit
18011c595a
352 changed files with 6040 additions and 6040 deletions
52
49-01.md
52
49-01.md
|
|
@ -9,27 +9,27 @@ Chapter 49\
|
|||
### How to Make the VGA Really Get up and Dance {#Heading2}
|
||||
|
||||
Okay—no amusing stories or informative anecdotes to kick off this
|
||||
chapter; lotta ground to cover, gotta hurry—you’re impatient, I can
|
||||
smell it. I won’t talk about the time a friend made the mistake of
|
||||
loudly saying “\$100 bill” during an animated discussion while walking
|
||||
chapter; lotta ground to cover, gotta hurry—you're impatient, I can
|
||||
smell it. I won't talk about the time a friend made the mistake of
|
||||
loudly saying "\$100 bill" during an animated discussion while walking
|
||||
among the bums on Market Street in San Francisco one night, thereby
|
||||
graphically illustrating that context is everything. I can’t spare a
|
||||
graphically illustrating that context is everything. I can't spare a
|
||||
word about how my daughter thinks my 11-year-old floppy-disk-based CP/M
|
||||
machine is more powerful than my 386 with its 100-MB hard disk because
|
||||
the CP/M machine’s word processor loads and runs twice as fast as the
|
||||
386’s Windows-based word processor, demonstrating that progress is not
|
||||
the neat exponential curve we’d like to think it is, and that features
|
||||
and performance are often conflicting notions. And, lord knows, I can’t
|
||||
the CP/M machine's word processor loads and runs twice as fast as the
|
||||
386's Windows-based word processor, demonstrating that progress is not
|
||||
the neat exponential curve we'd like to think it is, and that features
|
||||
and performance are often conflicting notions. And, lord knows, I can't
|
||||
take the time to discuss the habits of small white dogs, notwithstanding
|
||||
that such dogs seem to be relevant to just about every aspect of
|
||||
computing, as Jeff Duntemann’s writings make manifest. No lighthearted
|
||||
computing, as Jeff Duntemann's writings make manifest. No lighthearted
|
||||
fluff for us; we have real work to do, for today we animate with 256
|
||||
colors in Mode X.
|
||||
|
||||
### Masked Copying {#Heading3}
|
||||
|
||||
Over the past two chapters, we’ve put together most of the tools needed
|
||||
to implement animation in the VGA’s undocumented 320x240 256-color Mode
|
||||
Over the past two chapters, we've put together most of the tools needed
|
||||
to implement animation in the VGA's undocumented 320x240 256-color Mode
|
||||
X. We now have mode set code, solid and 4x4 pattern fills, system
|
||||
memory-to-display memory block copies, and display memory-to-display
|
||||
memory block copies. The final piece of the puzzle is the ability to
|
||||
|
|
@ -50,21 +50,21 @@ fact, masked copying even makes it possible to have transparent areas
|
|||
within images.
|
||||
|
||||
Note that another way to achieve this effect is to implement copying
|
||||
code that supports a transparent color; that is, a color that doesn’t
|
||||
code that supports a transparent color; that is, a color that doesn't
|
||||
get copied but rather leaves the destination unchanged. Transparent
|
||||
copying makes for more compact images, because no separate mask is
|
||||
needed, and is generally faster in a software-only implementation.
|
||||
However, Mode X supports masked copying but not transparent copying in
|
||||
hardware, so we’ll use masked copying in this chapter.
|
||||
hardware, so we'll use masked copying in this chapter.
|
||||
|
||||
The system memory to display memory masked copy routine in Listing 49.1
|
||||
implements masked copying in a straightforward fashion. In the main
|
||||
drawing loop, the corresponding mask byte is consulted as each image
|
||||
pixel is encountered, and the image pixel is copied only if the mask
|
||||
byte is nonzero. As with most of the system-to-display code I’ve
|
||||
presented, Listing 49.1 is not heavily optimized, because it’s
|
||||
inherently slow; there’s a better way to go when performance matters,
|
||||
and that’s to use the VGA’s hardware.
|
||||
byte is nonzero. As with most of the system-to-display code I've
|
||||
presented, Listing 49.1 is not heavily optimized, because it's
|
||||
inherently slow; there's a better way to go when performance matters,
|
||||
and that's to use the VGA's hardware.
|
||||
|
||||
**LISTING 49.1 L49-1.ASM**
|
||||
|
||||
|
|
@ -106,7 +106,7 @@ and that’s to use the VGA’s hardware.
|
|||
DestBitmapWidth dw ? ;# of pixels across dest bitmap (must be multiple of 4)
|
||||
MaskPtr dw ? ;pointer in DS to start of bitmap in which mask
|
||||
; resides (byte-per-pixel format, just like the source
|
||||
; image; 0-bytes mean don’t copy corresponding source
|
||||
; image; 0-bytes mean don't copy corresponding source
|
||||
; pixel, 1-bytes mean do copy)
|
||||
parms ends
|
||||
|
||||
|
|
@ -118,10 +118,10 @@ and that’s to use the VGA’s hardware.
|
|||
.code
|
||||
public _CopySystemToScreenMaskedX
|
||||
_CopySystemToScreenMaskedX proc near
|
||||
push bp ;preserve caller’s stack frame
|
||||
push bp ;preserve caller's stack frame
|
||||
mov bp,sp ;point to local stack frame
|
||||
sub sp,STACK_FRAME_SIZE ;allocate space for local vars
|
||||
push si ;preserve caller’s register variables
|
||||
push si ;preserve caller's register variables
|
||||
push di
|
||||
|
||||
mov ax,SCREEN_SEG ;point ES to display memory
|
||||
|
|
@ -146,10 +146,10 @@ and that’s to use the VGA’s hardware.
|
|||
add di,ax ;offset of first dest rect pixel in page
|
||||
add di,[bp+DestPageBase] ;offset of first dest rect pixel
|
||||
; in display memory
|
||||
and cl,011b ;CL = first dest pixel’s plane
|
||||
and cl,011b ;CL = first dest pixel's plane
|
||||
mov al,11h ;upper nibble comes into play when plane wraps
|
||||
; from 3 back to 0
|
||||
shl al,cl ;set the bit for the first dest pixel’s plane
|
||||
shl al,cl ;set the bit for the first dest pixel's plane
|
||||
mov [bp+LeftMask],al ; in each nibble to 1
|
||||
|
||||
mov ax,[bp+SourceEndX] ;calculate # of pixels across
|
||||
|
|
@ -173,7 +173,7 @@ and that’s to use the VGA’s hardware.
|
|||
push di ;remember the start offset in the dest
|
||||
CopyScanLineLoop:
|
||||
cmp byte ptr [bx],0 ;is this pixel mask-enabled?
|
||||
jz MaskOff ;no, so don’t draw it
|
||||
jz MaskOff ;no, so don't draw it
|
||||
;yes, draw the pixel
|
||||
out dx,al ;set the plane for this pixel
|
||||
mov ah,[si] ;get the pixel from the source
|
||||
|
|
@ -181,7 +181,7 @@ and that’s to use the VGA’s hardware.
|
|||
MaskOff:
|
||||
inc bx ;advance the mask pointer
|
||||
inc si ;advance the source pointer
|
||||
rol al,1 ;set mask for next pixel’s plane
|
||||
rol al,1 ;set mask for next pixel's plane
|
||||
adc di,0 ;advance destination address only when
|
||||
;wrapping from plane 3 to plane 0
|
||||
loop CopyScanLineLoop
|
||||
|
|
@ -195,10 +195,10 @@ and that’s to use the VGA’s hardware.
|
|||
dec word ptr [bp+RectHeight] ;count down scan lines
|
||||
jnz CopyRowsLoop
|
||||
CopyDone:
|
||||
pop di ;restore caller’s register variables
|
||||
pop di ;restore caller's register variables
|
||||
pop si
|
||||
mov sp,bp ;discard storage for local variables
|
||||
pop bp ;restore caller’s stack frame
|
||||
pop bp ;restore caller's stack frame
|
||||
ret
|
||||
_CopySystemToScreenMaskedX endp
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue