DG> Anyone know how to put a pixel in EGA (mode 10h) video?
dg>.....
This isn't really C++. You should get into the C echo.
/*_|_| HAPYTRLZ.C PUBLIC DOMAIN by Kurt Kuzba. (4/20/97)
_|_|_| EGA screen functions in C, with some ASM. ( 1 of 2)
_|_|*/
#include
#include
#include
#include
#define SCREEN_WIDTH 640
#define SCREEN_HEIGHT 350
typedef struct { int y, x; } LineEnd;
void vidmode(char mode)
{
_asm{
mov ah, 00h
mov al, mode
int 10h
}
return;
}
int rnd(int l, int h)
{return (int)((((long)rand()*(long)(h-l+2))-1)/(long)RAND_MAX)+l;}
void putpixel(int y, int x, int color)
{
static int pix[8] = { 128, 64, 32, 16, 8, 4, 2, 1 };
static int pox[8] = { 127, 191, 223, 239, 247, 251, 253, 254 };
unsigned char far *V = (unsigned char far*)0xa0000000l;
int bit = pix[y & 7], bitmask = pox[y & 7];
V += (((x > 3));
if(y = SCREEN_WIDTH || x >= SCREEN_HEIGHT)
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 HAPYTRLZ.C PUBLIC DOMAIN ( 1 of 2 )*/
> ] Promoting cynicism for 100 years! ( More like 10, really )
---
---------------
* Origin: *YOPS ]I[* 3.1 GIG * RA/FD/FE RADist * Milwaukee, WI (1:154/750)
|