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,7 +37,7 @@
</CENTER>
<P><BR></P>
<H3><A NAME="Heading5"></A><FONT COLOR="#000077">Designing from a Mode X Perspective</FONT></H3>
<P>Listing 47.4 shows Mode X rectangle fill code. The plane is selected for each pixel in turn, with drawing cycling from plane 0 to plane 3, then wrapping back to plane 0. This is the sort of code that stems from a write-pixel line of thinking; it reflects not a whit of the unique perspective that Mode X demands, and although it looks reasonably efficient, it is in fact some of the slowest graphics code you will ever see. I&#146;ve provided Listing 47.4 partly for illustrative purposes, but mostly so we&#146;ll have a point of reference for the substantial speed-up that&#146;s possible with code that&#146;s designed from a Mode X perspective.
<P>Listing 47.4 shows Mode X rectangle fill code. The plane is selected for each pixel in turn, with drawing cycling from plane 0 to plane 3, then wrapping back to plane 0. This is the sort of code that stems from a write-pixel line of thinking; it reflects not a whit of the unique perspective that Mode X demands, and although it looks reasonably efficient, it is in fact some of the slowest graphics code you will ever see. I&rsquo;ve provided Listing 47.4 partly for illustrative purposes, but mostly so we&rsquo;ll have a point of reference for the substantial speed-up that&rsquo;s possible with code that&rsquo;s designed from a Mode X perspective.
</P>
<P><B>LISTING 47.4 L47-4.ASM</B></P>
<!-- CODE //-->
@ -73,37 +73,37 @@ parms ends
.code
public _FillRectangleX
_FillRectangleX proc near
push bp ;preserve caller&#146;s stack frame
push bp ;preserve caller&rsquo;s stack frame
mov bp,sp ;point to local stack frame
push si ;preserve caller&#146;s register variables
push si ;preserve caller&rsquo;s register variables
push di
mov ax,SCREEN_WIDTH
mul [bp&#43;StartY] ;offset in page of top rectangle scan line
mov di,[bp&#43;StartX]
mul [bp+StartY] ;offset in page of top rectangle scan line
mov di,[bp+StartX]
shr di,1
shr di,1 ;X/4 = offset of first rectangle pixel in scan
; line
add di,ax ;offset of first rectangle pixel in page
add di,[bp&#43;PageBase] ;offset of first rectangle pixel in
add di,[bp+PageBase] ;offset of first rectangle pixel in
; display memory
mov ax,SCREEN_SEG
mov es,ax ;point ES:DI to the first rectangle pixel&#146;s
mov es,ax ;point ES:DI to the first rectangle pixel&rsquo;s
; address
mov dx,SC_INDEX ;set the Sequence Controller Index to
mov al,MAP_MASK ; point to the Map Mask register
out dx,al
inc dx ;point DX to the SC Data register
mov cl,byte ptr [bp&#43;StartX]
and cl,011b ;CL = first rectangle pixel&#146;s plane
mov cl,byte ptr [bp+StartX]
and cl,011b ;CL = first rectangle pixel&rsquo;s plane
mov al,01h
shl al,cl ;set only the bit for the pixel&#146;s plane to 1
mov ah,byte ptr [bp&#43;Color] ;color with which to fill
mov bx,[bp&#43;EndY]
sub bx,[bp&#43;StartY] ;BX = height of rectangle
shl al,cl ;set only the bit for the pixel&rsquo;s plane to 1
mov ah,byte ptr [bp+Color] ;color with which to fill
mov bx,[bp+EndY]
sub bx,[bp+StartY] ;BX = height of rectangle
jle FillDone ;skip if 0 or negative height
mov si,[bp&#43;EndX]
sub si,[bp&#43;StartX] ;CX = width of rectangle
mov si,[bp+EndX]
sub si,[bp+StartX] ;CX = width of rectangle
jle FillDone ;skip if 0 or negative width
FillRowsLoop:
push ax ;remember the plane mask for the left edge
@ -112,7 +112,7 @@ FillRowsLoop:
FillScanLineLoop:
out dx,al ;set the plane for this pixel
mov es:[di],ah ;draw the pixel
shl al,1 ;adjust the plane mask for the next pixel&#146;s
shl al,1 ;adjust the plane mask for the next pixel&rsquo;s
and al,01111b ; bit, modulo 4
jnz AddressSet ;advance address if we turned over from
inc di ; plane 3 to plane 0
@ -126,16 +126,16 @@ AddressSet:
dec bx ;count down scan lines
jnz FillRowsLoop
FillDone:
pop di ;restore caller&#146;s register variables
pop di ;restore caller&rsquo;s register variables
pop si
pop bp ;restore caller&#146;s stack frame
pop bp ;restore caller&rsquo;s stack frame
ret
_FillRectangleX endp
end
</PRE>
<!-- END CODE //-->
<P>The two major weaknesses of Listing 47.4 both result from selecting the plane on a pixel by pixel basis. First, endless <B>OUT</B>s (which are particularly slow on 386s, 486s, and Pentiums, much slower than accesses to display memory) must be performed, and, second, <B>REP STOS</B> can&#146;t be used. Listing 47.5 overcomes both these problems by tailoring the fill technique to the organization of display memory. Each plane is filled in its entirety in one burst before the next plane is processed, so only five <B>OUT</B>s are required in all, and <B>REP STOS</B> can indeed be used; I&#146;ve used <B>REP STOSB</B> in Listings 47.5 and 47.6. <B>REP STOSW</B> could be used and would improve performance on most VGAs; however, <B>REP STOSW</B> requires extra overhead to set up, so it can be slower for small rectangles, especially on 8-bit VGAs. Note that doing an entire plane at a time can produce a &#147;fading-in&#148; effect for large images, because all columns for one plane are drawn before any columns for the next. If this is a problem, the four planes can be cycled through once for each scan line, rather than once for the entire rectangle.</P>
<P>Listing 47.5 is 2.5 times faster than Listing 47.4 at clearing the screen on a 20-MHz cached 386 with a Paradise VGA. Although Listing 47.5 is slightly slower than an equivalent mode 13H fill routine would be, it&#146;s not grievously so.</P><P><BR></P>
<P>The two major weaknesses of Listing 47.4 both result from selecting the plane on a pixel by pixel basis. First, endless <B>OUT</B>s (which are particularly slow on 386s, 486s, and Pentiums, much slower than accesses to display memory) must be performed, and, second, <B>REP STOS</B> can&rsquo;t be used. Listing 47.5 overcomes both these problems by tailoring the fill technique to the organization of display memory. Each plane is filled in its entirety in one burst before the next plane is processed, so only five <B>OUT</B>s are required in all, and <B>REP STOS</B> can indeed be used; I&rsquo;ve used <B>REP STOSB</B> in Listings 47.5 and 47.6. <B>REP STOSW</B> could be used and would improve performance on most VGAs; however, <B>REP STOSW</B> requires extra overhead to set up, so it can be slower for small rectangles, especially on 8-bit VGAs. Note that doing an entire plane at a time can produce a &ldquo;fading-in&rdquo; effect for large images, because all columns for one plane are drawn before any columns for the next. If this is a problem, the four planes can be cycled through once for each scan line, rather than once for the entire rectangle.</P>
<P>Listing 47.5 is 2.5 times faster than Listing 47.4 at clearing the screen on a 20-MHz cached 386 with a Paradise VGA. Although Listing 47.5 is slightly slower than an equivalent mode 13H fill routine would be, it&rsquo;s not grievously so.</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>