home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1994 #1
/
monster.zip
/
monster
/
PROG_C
/
VGAGRAPH.ZIP
/
GRAPH.C
< prev
next >
Wrap
C/C++ Source or Header
|
1994-02-26
|
8KB
|
295 lines
//*************************************************************
// Ivan Kostenko 1992
//*************************************************************
#include <dos.h>
#include <mem.h>
#include <string.h>
#include "allproc.h"
void (*setscrline)(unsigned int);
void (*putpixel)(int,int,char);
char (*getpixel)(int,int);
void (*clearscr)(char);
void (*line)(int,int,int,int,char);
void (*bar)(int,int,int,int,int);
void (*bars)(int,int,int,int,char);
void (*barpat)(int,int,int,int,char,char);
void (*displaychar)(int,int,char,char,char,char);
void (*lineh)(int,int,int,char,char);
void (*linev)(int,int,int,char,char);
void (*barpats)(int,int,int,int,char,char);
void (*setcol)(char,char,unsigned int);
void (*fasttext)(int,int,char *);
void (*windowshadow)(int,int,int,int);
void (*screentoscreen)(int,int,int,int,int,int);
char (*getimage)(unsigned int,unsigned int,unsigned int,unsigned int,Image *);
void (*putimage)(unsigned int,unsigned int,Image,char);
char byte_tabXL[4] = {0x0F,0x0E,0x0C,0x08};
char byte_tabXR[4] = {0x00,0x01,0x03,0x07};
char char_tab[16] = {0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15};
char byte_tab[8] = {0x0FF,0x7F,0x3F,0x1F,0x0F,0x07,0x03,0x01};
char pln_tab[4] = { 1 , 2 , 4 , 8 };
unsigned int BytesPerLine,FastPlace,MaxX,MaxY;
void Init10()
{
setscrline=setscrline10;
putpixel=putpixel10;
getpixel=getpixel10;
clearscr=clearscr10;
line=line10;
bar=bar10;
bars=bars10;
barpat=barpat10;
displaychar=displaychar10;
lineh=lineh10;
linev=linev10;
barpats=barpats10;
setcol=setcol10;
fasttext=fasttext10;
windowshadow=windowshadow10;
screentoscreen=screentoscreen10;
getimage=getimage10;
putimage=putimage10;
}
void InitX()
{
setscrline=setscrlinex;
putpixel=putpixelx;
getpixel=getpixelx;
clearscr=clearscrx;
line=linex;
bar=barx;
bars=barsx;
barpat=barpatx;
displaychar=displaycharx;
setcol=setcolx;
fasttext=fasttextx;
screentoscreen=screentoscreenx;
getimage=getimagex;
putimage=putimagex;
}
void SetMode(char mode)
{
asm {
mov ah,0
mov al,mode
int 10h
}
}
char VGA320x240()
{
int data[10]={0x0D06,0x3E07,0x4109,0xEA10,0xAC11,
0xDF12,0x0014,0xE715,0x0616,0xE317};
char j;
void far *Screen;
SetMode(0x13);
if (peekb(0x0,0x0449)!=0x13) return(1);
outport(0x03C4,0x0604);
outport(0x03C4,0x0100);
outportb(0x03C2,0xE3);
outport(0x03C4,0x0300);
outportb(0x03D4,0x11);outportb(0x03D5,inportb(0x03D5) & 0x7F);
Screen=MK_FP(0xA000, 0);
setmem(Screen,0xFFFF,0);
for (j=0;j<10;j++) outport(0x03D4,data[j]);
BytesPerLine=80;
MaxX=319;
MaxY=239;
InitX();
return(0);
}
char VGA320x400()
{
void far *Screen;
SetMode(0x13);
if (peekb(0x0,0x0449)!=0x13) return(1);
outportb(0x03C4,0x04);outportb(0x03C5,(inportb(0x03C5) & 0xF7) | 0x04);
outportb(0x03CE,0x05);outportb(0x03CF,inportb(0x03CF) & 0xEF);
outportb(0x03CE,0x06);outportb(0x03CF,inportb(0x03CF) & 0xFD);
outportb(0x03C4,0x02);outportb(0x03C5,0x0F);
Screen=MK_FP(0xA000, 0);
setmem(Screen,0xFFFF,0);
outportb(0x03D4,0x09);outportb(0x03D5,inportb(0x03D5) & 0xE0);
outportb(0x03D4,0x14);outportb(0x03D5,inportb(0x03D5) & 0xBF);
outportb(0x03D4,0x17);outportb(0x03D5,inportb(0x03D5) | 0x40);
BytesPerLine=80;
MaxX=319;
MaxY=399;
InitX();
return(0);
}
char VGA320x480()
{
int data[10]={0x0D06,0x3E07,0x4009,0xE010,0xAC11,
0xDF12,0x0014,0xE715,0x0616,0xE317};
char j;
void far *Screen;
SetMode(0x13);
if (peekb(0x0,0x0449)!=0x13) return(1);
outport(0x03C4,0x0604);
outport(0x03C4,0x0100);
outportb(0x03C2,0xE3);
outport(0x03C4,0x0300);
outportb(0x03D4,0x11);outportb(0x03D5,inportb(0x03D5) & 0x7F);
Screen=MK_FP(0xA000, 0);
setmem(Screen,0xFFFF,0);
for (j=0;j<10;j++) outport(0x03D4,data[j]);
BytesPerLine=80;
MaxX=319;
MaxY=479;
InitX();
return(0);
}
char VGA360x480()
{
int data[17]={0x6B00,0x5901,0x5A02,0x8E03,0x5E04,
0x8A05,0x0D06,0x3E07,0x4009,0xEA10,
0xAC11,0xDF12,0x2D13,0x0014,0xE715,
0x0616,0xE317};
char j;
void far *Screen;
SetMode(0x13);
if (peekb(0x0,0x0449)!=0x13) return(1);
outport(0x03C4,0x0604);
outport(0x03C4,0x0100);
outportb(0x03C2,0xE7);
outport(0x03C4,0x0300);
outportb(0x03D4,0x11);outportb(0x03D5,inportb(0x03D5) & 0x7F);
Screen=MK_FP(0xA000, 0);
setmem(Screen,0xFFFF,0);
for (j=0;j<17;j++) outport(0x03D4,data[j]);
BytesPerLine=90;
MaxX=359;
MaxY=479;
InitX();
return(0);
}
char EGA320x200()
{
SetMode(0x0D);
if (peekb(0x0,0x0449)!=0x0D) return(1);
BytesPerLine=40;
MaxX=319;
MaxY=199;
Init10();
return(0);
}
char EGA640x200()
{
SetMode(0x0E);
if (peekb(0x0,0x0449)!=0x0E) return(1);
BytesPerLine=80;
MaxX=639;
MaxY=199;
Init10();
return(0);
}
char EGA640x350()
{
SetMode(0x10);
if (peekb(0x0,0x0449)!=0x10) return(1);
BytesPerLine=80;
MaxX=639;
MaxY=349;
Init10();
return(0);
}
char EGA640x480()
{
SetMode(0x12);
if (peekb(0x0,0x0449)!=0x12) return(1);
BytesPerLine=80;
MaxX=639;
MaxY=479;
Init10();
return(0);
}
void TextMode()
{
SetMode(3);
}
void bar3d(int x,int y,int dx,int dy,int n,int col)
{
int i;
bars(x,y,dx,dy,col);
x=x+n;
dx=dx-(n*2);
y=y+n;
dy=dy-(n*2);
if (col<8)
{
for (i=0;i<=(n-1);i++) lineh(x-i,y-i-1,dx+(i << 1)-1,15,col+8);
for (i=0;i<=(n-1);i++) linev(x-i-1,y-i-1,dy+(i << 1)+1,15,col);
for (i=0;i<=(n-1);i++) lineh(x-i-1,y+dy+i+1,dx+(i << 1),0,col);
for (i=0;i<=(n-1);i++) linev(x+dx+i+1,y-i-1,dy+(i << 1)+2,8,col);
}
else
{
for (i=0;i<=(n-1);i++) lineh(x-i,y-i-1,dx+(i << 1)-1,7,col);
for (i=0;i<=(n-1);i++) linev(x-i-1,y-i-1,dy+(i << 1)+1,8,col);
for (i=0;i<=(n-1);i++) lineh(x-i-1,y+dy+i+1,dx+(i << 1),0,col);
for (i=0;i<=(n-1);i++) linev(x+dx+i+1,y-i-1,dy+(i << 1)+2,8,col);
}
}
void bar3dz(int x,int y,int dx,int dy,int n,int col)
{
int i;
bars(x,y,dx,dy,col);
x=x+n;
dx=dx-(n*2);
y=y+n;
dy=dy-(n*2);
if (col<8)
{
for (i=0;i<=(n-1);i++) lineh(x-i,y-i-1,dx+(i << 1)-1,0,col);
for (i=0;i<=(n-1);i++) linev(x-i-1,y-i-1,dy+(i << 1)+1,8,col);
for (i=0;i<=(n-1);i++) lineh(x-i-1,y+dy+i+1,dx+(i << 1),15,col+8);
for (i=0;i<=(n-1);i++) linev(x+dx+i+1,y-i-1,dy+(i << 1)+2,15,col);
}
else
{
for (i=0;i<=(n-1);i++) lineh(x-i,y-i-1,dx+(i << 1)-1,0,col);
for (i=0;i<=(n-1);i++) linev(x-i-1,y-i-1,dy+(i << 1)+1,8,col);
for (i=0;i<=(n-1);i++) lineh(x-i-1,y+dy+i+1,dx+(i << 1),7,col);
for (i=0;i<=(n-1);i++) linev(x+dx+i+1,y-i-1,dy+(i << 1)+2,8,col);
}
}
void displaystring(int x,int y,char *s,char colorf,char colorb,char flag)
{
char i;
for (i=0;i<strlen(s);i++)
{
displaychar(x,y,s[i],colorf,colorb,flag);
x+=8;
}
}
void teletext(int x,int y,char *s,char colorf,char colorb)
{
displaystring(x,y,s,colorf,colorb,1);
}
void xortext(int x,int y,char *s,char colorb)
{
displaystring(x,y,s,colorb,colorb,0);
}
void rectangle(int x,int y, int dx, int dy,char col)
{
line(x,y,x+dx,y,col);
line(x,y,x,y+dy,col);
line(x+dx,y+dy,x+dx,y,col);
line(x,y+dy,x+dx,y+dy,col);
}