FidoNet Echomail Archive
c_echo

<<< Previous Index Next >>>

From: Kurt Kuzba
To: All
Date: 2004-11-04 09:36:56
Subject: [C] Primitives for Mode 12h [ 1 of 5 ]

From: "Kurt Kuzba" <kkuzba{at}centurytel.net>


    After much goofing around and goofing off, I did some work on my
 Bresenham routines.  This code includes getpixel and putpixel for
 standard VGA graphics mode 12h (640x480x16).  There are also line and
 oval routines.  Built on these are rectangle, square, box, circle,
 disc, and oval disc routines.  The oval routines work for ovals that
 are elongated in the vertical or horizontal axis, something I've been
 meaning to get around to for years.  My old routines didn't work too
 well for vertically elongated ovals.

/*_|_|  MODE12VH.C  PUBLIC DOMAIN by Kurt Kuzba (11/04/2004)
_|_|_|  This code is provided as is. No claim of suitability, _|_|_| 
warrantee, or guarantee is given or implied. _|_|_|  Part 1 of 5  */
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
/*_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|*/
int rnd(int low, int high)
{
 int temp = 0, difference = high - low + 1;
 if(low > high)
  { temp = low; low = high; high = temp; }
 if(high != low)
  temp = (rand() % difference) + low;
 return temp;
}
/*_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|*/
void vidmode(char mode)
{
 _asm{
  mov ah, 00h
  mov al, mode
  int 10h
 }
 return;
}
/*_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|*/
static int pix[8] = { 128,  64,  32,  16,   8,   4,   2,   1 };
static int pox[8] = { 127, 191, 223, 239, 247, 251, 253, 254 }; void
putpixel(int y, int x, int color)
 {
 unsigned char far *V = (unsigned char far*)0xa0000000l;
 int bit = pix[y & 7], bitmask = pox[y & 7];
 V += ((x * 80) + y / 8);
 if(y < 0 || x < 0 || y > 639 || x > 479)
  return;
 _asm {
  mov dx, 3ceh
  mov al, 04h
  out dx, al
  mov dx, 3c4h
  mov al, 02h
  out dx, al
  mov dx, 3cfh
  mov al, 00h
  out dx, al
  mov dx, 3c5h
  mov al, 01h
   out dx, al
 }
 if(color & 1) *V |= bit; else *V &= bitmask;
 _asm {
  mov dx, 3cfh
  mov al, 01h
  out dx, al
  mov dx, 3c5h
  mov al, 02h
  out dx, al
 }
 if(color & 2) *V |= bit; else *V &= bitmask;
 _asm {
  mov dx, 3cfh
  mov al, 02h
  out dx, al
   mov dx, 3c5h
  mov al, 04h
  out dx, al
 }
 if(color & 4) *V |= bit; else *V &= bitmask;
 _asm {
  mov dx, 3cfh
  mov al, 03h
  out dx, al
  mov dx, 3c5h
  mov al, 08h
  out dx, al
 }
 if(color & 8) *V |= bit; else *V &= bitmask;
}
/*_|_|  end Part 1 of 5  */

--- BBBS/LiI v4.01 Flag-5
 * Origin: Prism's_Point (1:261/38.1)
SEEN-BY: 633/267 270
@PATH: 261/38 123/500 106/2000 633/267


<<< Previous Index Next >>>