Normal quotes
This commit is contained in:
parent
5e10794a24
commit
18011c595a
352 changed files with 6040 additions and 6040 deletions
16
35-03.md
16
35-03.md
|
|
@ -4,15 +4,15 @@
|
|||
|
||||
### An Implementation in C {#Heading6}
|
||||
|
||||
It’s time to get down and look at some actual working code. Listing 35.1
|
||||
is a C implementation of Bresenham’s line-drawing algorithm for modes
|
||||
It's time to get down and look at some actual working code. Listing 35.1
|
||||
is a C implementation of Bresenham's line-drawing algorithm for modes
|
||||
0EH, 0FH, 10H, and 12H of the VGA, called as function **EVGALine**.
|
||||
Listing 35.2 is a sample program to demonstrate the use of **EVGALine**.
|
||||
|
||||
**LISTING 35.1 L35-1.C**
|
||||
|
||||
/*
|
||||
* C implementation of Bresenham’s line drawing algorithm
|
||||
* C implementation of Bresenham's line drawing algorithm
|
||||
* for the EGA and VGA. Works in modes 0xE, 0xF, 0x10, and 0x12.
|
||||
*
|
||||
* Compiled with Borland C++
|
||||
|
|
@ -54,18 +54,18 @@ Listing 35.2 is a sample program to demonstrate the use of **EVGALine**.
|
|||
PixelBytePtr = MK_FP(EVGA_SCREEN_SEGMENT,
|
||||
( Y0 * EVGA_SCREEN_WIDTH_IN_BYTES ) + ( X0 / 8 ));
|
||||
|
||||
/* Generate a mask with a 1 bit in the pixel’s position within the
|
||||
/* Generate a mask with a 1 bit in the pixel's position within the
|
||||
screen byte */
|
||||
PixelMask = 0x80 >> ( X0 & 0x07 );
|
||||
|
||||
/* Set up the Graphics Controller’s Bit Mask register to allow
|
||||
/* Set up the Graphics Controller's Bit Mask register to allow
|
||||
only the bit corresponding to the pixel being drawn to
|
||||
be modified */
|
||||
outportb(GC_INDEX, BIT_MASK_INDEX);
|
||||
outportb(GC_DATA, PixelMask);
|
||||
|
||||
/* Draw the pixel. Because of the operation of the set/reset
|
||||
feature of the EGA/VGA, the value written doesn’t matter.
|
||||
feature of the EGA/VGA, the value written doesn't matter.
|
||||
The screen byte is ORed in order to perform a read to latch the
|
||||
display memory, then perform a write in order to modify it. */
|
||||
*PixelBytePtr |= 0xFE;
|
||||
|
|
@ -92,7 +92,7 @@ Listing 35.2 is a sample program to demonstrate the use of **EVGALine**.
|
|||
/* Draw the line */
|
||||
EVGADot(X0, Y0); /* draw the first pixel */
|
||||
while ( DeltaX— ) {
|
||||
/* See if it’s time to advance the Y coordinate */
|
||||
/* See if it's time to advance the Y coordinate */
|
||||
if ( ErrorTerm >= 0 ) {
|
||||
/* Advance the Y coordinate & adjust the error term
|
||||
back down */
|
||||
|
|
@ -127,7 +127,7 @@ Listing 35.2 is a sample program to demonstrate the use of **EVGALine**.
|
|||
|
||||
EVGADot(X0, Y0); /* draw the first pixel */
|
||||
while ( DeltaY— ) {
|
||||
/* See if it’s time to advance the X coordinate */
|
||||
/* See if it's time to advance the X coordinate */
|
||||
if ( ErrorTerm >= 0 ) {
|
||||
/* Advance the X coordinate & adjust the error term
|
||||
back down */
|
||||
|
|
|
|||
Loading…
Reference in a new issue