Replace invalid characters with HTML entities

— with —
’ with ’
+ with +
× with x
ç with ç
“ with “
” with ”
‘ with ‘
• with •
– with -
µ with µ
† with †
Fix C++
θ with θ
Yen symbol instead of times
Fix broken apos
Bullet again
E-circumflex
This commit is contained in:
James Gregory 2013-12-30 12:50:32 +11:00
commit 500e7f5654
353 changed files with 5091 additions and 5091 deletions

View file

@ -37,23 +37,23 @@
</CENTER>
<P><BR></P>
<H4 ALIGN="LEFT"><A NAME="Heading5"></A><FONT COLOR="#000077">Copying Chunky Bitmaps to VGA Memory Using Write Mode 2</FONT></H4>
<P>Let&#146;s take a look at two examples of write mode 2 in action. Listing 27.1 presents a program that uses write mode 2 to copy a graphics image in chunky format to the VGA. In chunky format adjacent bits in a single byte make up each pixel: mode 4 of the CGA, EGA, and VGA is a 2-bit-per-pixel chunky mode, and mode 13H of the VGA is an 8-bit-per-pixel chunky mode. Chunky format is convenient, since all the information about each pixel is contained in a single byte; consequently chunky format is often used to store bitmaps in system memory.
<P>Let&rsquo;s take a look at two examples of write mode 2 in action. Listing 27.1 presents a program that uses write mode 2 to copy a graphics image in chunky format to the VGA. In chunky format adjacent bits in a single byte make up each pixel: mode 4 of the CGA, EGA, and VGA is a 2-bit-per-pixel chunky mode, and mode 13H of the VGA is an 8-bit-per-pixel chunky mode. Chunky format is convenient, since all the information about each pixel is contained in a single byte; consequently chunky format is often used to store bitmaps in system memory.
</P>
<P>Unfortunately, VGA memory is organized as a planar rather than chunky bitmap in modes 0DH through 12H, with the bits that make up each pixel spread across four planes. The conversion from chunky to planar format in write mode 0 is quite a nuisance, requiring a good deal of bit manipulation. In write mode 2, however, the conversion becomes a snap, as shown in Listing 27.1. Once the VGA is placed in write mode 2, the lower four bits (the lower nibble) of the CPU byte (a single 4-bit chunky pixel) become eight planar pixels, all the same color. As discussed in Chapter 25, the bit mask makes it possible to narrow the effect of the CPU write down to a single pixel.</P>
<P>Given the above, conversion of a chunky 4-bit-per-pixel bitmap to the VGA&#146;s planar format in write mode 2 is trivial. First, the Bit Mask register is set to allow only the VGA display memory bits corresponding to the leftmost chunky pixel of the two stored in the first chunky bitmap byte to be modified. Next, the destination byte in display memory is read in order to load the latches. Then a byte containing two chunky pixels is read from the chunky bitmap in system memory, and the byte is rotated four bits to the right to get the leftmost chunky pixel in position. This rotated byte is written to the destination byte; since write mode 2 is active, each bit of the chunky pixel goes to its respective plane, and since the Bit Mask register is set up to allow only one bit in each plane to be modified, a single pixel in the color of the chunky pixel is written to VGA memory.</P>
<P>Given the above, conversion of a chunky 4-bit-per-pixel bitmap to the VGA&rsquo;s planar format in write mode 2 is trivial. First, the Bit Mask register is set to allow only the VGA display memory bits corresponding to the leftmost chunky pixel of the two stored in the first chunky bitmap byte to be modified. Next, the destination byte in display memory is read in order to load the latches. Then a byte containing two chunky pixels is read from the chunky bitmap in system memory, and the byte is rotated four bits to the right to get the leftmost chunky pixel in position. This rotated byte is written to the destination byte; since write mode 2 is active, each bit of the chunky pixel goes to its respective plane, and since the Bit Mask register is set up to allow only one bit in each plane to be modified, a single pixel in the color of the chunky pixel is written to VGA memory.</P>
<P>This process is then repeated for the rightmost chunky pixel, if necessary, and repeated again for as many pixels as there are in the image.</P>
<P><B>LISTING 27.1 L27-1.ASM</B></P>
<!-- CODE //-->
<PRE>
; Program to illustrate one use of write mode 2 of the VGA and EGA by
; animating the image of an &#147;A&#148; drawn by copying it from a chunky
; animating the image of an &ldquo;A&rdquo; drawn by copying it from a chunky
; bit-map in system memory to a planar bit-map in VGA or EGA memory.
;
; Assemble with MASM or TASM
;
; By Michael Abrash
;
Stack segment para stack &#145;STACK&#146;
Stack segment para stack &lsquo;STACK&rsquo;
db 512 dup(0)
Stack ends
@ -65,15 +65,15 @@ GC_INDEX equ 03ceh ;Graphics Controller I
GRAPHICS_MODE equ 5 ;index of Graphics Mode reg
BIT_MASKequ 8 ;index of Bit Mask reg
Data segment para common &#145;DATA&#146;
Data segment para common &lsquo;DATA&rsquo;
;
; Current location of &#147;A&#148; as it is animated across the screen.
; Current location of &ldquo;A&rdquo; as it is animated across the screen.
;
CurrentX dw ?
CurrentY dw ?
RemainingLength dw ?
;
; Chunky bit-map image of a yellow &#147;A&#148; on a bright blue background
; Chunky bit-map image of a yellow &ldquo;A&rdquo; on a bright blue background
;
AImage label byte
dw 13, 13 ;width, height in pixels
@ -92,13 +92,13 @@ AImage label byte
db 000h, 000h, 000h, 000h, 000h, 000h, 000h
Data ends
Code segment para public &#145;CODE&#146;
Code segment para public &lsquo;CODE&rsquo;
assume cs:Code, ds:Data
Start proc near
mov ax,Data
mov ds,ax
mov ax,10h
int 10h ;select video mode 10h (640&#215;350)
int 10h ;select video mode 10h (640x350)
;
; Prepare for animation.
;
@ -106,7 +106,7 @@ Start proc near
mov [CurrentY],200
mov [RemainingLength],600 ;move 600 times
;
; Animate, repeating RemainingLength times. It&#146;s unnecessary to erase
; Animate, repeating RemainingLength times. It&rsquo;s unnecessary to erase
; the old image, since the one pixel of blank fringe around the image
; erases the part of the old image not overlapped by the new image.
;
@ -114,10 +114,10 @@ AnimationLoop:
mov bx,[CurrentX]
mov cx,[CurrentY]
mov si,offset AImage
call DrawFromChunkyBitmap ;draw the &#147;A&#148; image
call DrawFromChunkyBitmap ;draw the &ldquo;A&rdquo; image
inc [CurrentX] ;move one pixel to the right
mov cx,0 ;delay so we don&#146;t move the
mov cx,0 ;delay so we don&rsquo;t move the
DelayLoop: ; image too fast; adjust as
; needed
loop DelayLoop
@ -208,7 +208,7 @@ DrawFromChunkyBitmap proc near
inc dx ; to the Bit Mask register
RowLoop:
push ax ;preserve the left column&#146;s bit mask
push ax ;preserve the left column&rsquo;s bit mask
push cx ;preserve the width
push di ;preserve the destination offset
@ -252,7 +252,7 @@ AdvanceToNextScanLine:
CheckMoreScanLines:
pop di ;get back the destination offset
pop cx ;get back the width
pop ax ;get back the left column&#146;s bit mask
pop ax ;get back the left column&rsquo;s bit mask
add di,SCREEN_WIDTH_IN_BYTES
;point to the start of the next scan
; line of the image