home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1997 March
/
VPR9703A.ISO
/
VPR_DATA
/
DOGA
/
SOURCES
/
REND.LZH
/
REND
/
CRTM500.C
< prev
next >
Wrap
C/C++ Source or Header
|
1989-11-30
|
5KB
|
213 lines
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
#include <FIF.H>
static int vline ;
#define LINE1 80
#define LINE2 160
#define setval0(c0, c1, c2, c3) \
(char)( ((c0) > tiletable[0] ? 0x80 : 0) \
| ((c0) > tiletable[1] ? 0x40 : 0) \
| ((c1) > tiletable[2] ? 0x20 : 0) \
| ((c1) > tiletable[3] ? 0x10 : 0) \
| ((c2) > tiletable[0] ? 0x08 : 0) \
| ((c2) > tiletable[1] ? 0x04 : 0) \
| ((c3) > tiletable[2] ? 0x02 : 0) \
| ((c3) > tiletable[3] ? 0x01 : 0) )
#define setval1(c0,c1,c2,c3) \
(char)( ((c0) > tiletable[4] ? 0x80 : 0) \
| ((c0) > tiletable[5] ? 0x40 : 0) \
| ((c1) > tiletable[6] ? 0x20 : 0) \
| ((c1) > tiletable[7] ? 0x10 : 0) \
| ((c2) > tiletable[4] ? 0x08 : 0) \
| ((c2) > tiletable[5] ? 0x04 : 0) \
| ((c3) > tiletable[6] ? 0x02 : 0) \
| ((c3) > tiletable[7] ? 0x01 : 0) )
#define setval2(c0,c1,c2,c3) \
(char)( ((c0) > tiletable[ 8] ? 0x80 : 0) \
| ((c0) > tiletable[ 9] ? 0x40 : 0) \
| ((c1) > tiletable[10] ? 0x20 : 0) \
| ((c1) > tiletable[11] ? 0x10 : 0) \
| ((c2) > tiletable[ 8] ? 0x08 : 0) \
| ((c2) > tiletable[ 9] ? 0x04 : 0) \
| ((c3) > tiletable[10] ? 0x02 : 0) \
| ((c3) > tiletable[11] ? 0x01 : 0) )
int tiletable[] = {
7 * 32 / 12, 4 * 32 / 12, 10 * 32 / 12, 1 * 32 / 12,
3 * 32 / 12, 0 * 32 / 12, 6 * 32 / 12, 9 * 32 / 12,
11 * 32 / 12, 8 * 32 / 12, 2 * 32 / 12, 5 * 32 / 12
};
#define gc(c) ((c) >> 11) /* (((c) >> 11) & 0x1f) */
#define rc(c) (((c) >> 6) & 0x1f)
#define bc(c) (((c) >> 1) & 0x1f)
static GraphData data ;
int GDS_open();
int GDS_setcompat();
int GDS_setplane();
int GDS_resolution();
void GDS_clearScreen();
int GDS_initData();
int GDS_resetData();
int GDS_lineColor();
int GDS_chainFirst();
int GDS_outputGraph();
void crtclr( void );
char *program = "Do-GA C.G.A System Rendering Program for Panacom M500" ;
/* CRTの初期化 */
void crtinit( line )
int line ;
{
static int openflag = 0 ;
/* 縦ライン数 */
vline = line ;
/* グラフィックの初期化 */
if ( ! openflag )
{
openflag = 1 ;
if ( GDS_initData( &data , 1000 ) != 0 )
{
fprintf( stderr,
"正常に 図形データ列格納領域を初期化できませんでした。\n");
exit(1);
}
if ( GDS_open( 1000 ) )
{
fprintf( stderr , "正常に 初期化できませんでした。\n");
exit(1);
}
GDS_resolution( 640, 400 );
GDS_setplane( 3 );
GDS_setcompat( 0 );
}
}
/* CRTのクリア */
void crtclr()
{
fprintf( stderr, "\x1B[2J" );
GDS_clearScreen();
}
/* CRT出力 */
void crtout( framebuf, xlen, y )
short *framebuf ;
int xlen ;
int y ;
{
int i, n ;
unsigned short cl0, cl1, cl2, cl3 ;
unsigned short c0, c1, c2, c3 ;
unsigned char far *p_vram;
union REGS regs;
if ( y == 0 )
{
regs.h.ah = 0x80; /* initialize */
int86(0x92, ®s, ®s);
regs.h.ah = 0xfa; /* max plane */
regs.h.al = 0x03;
int86(0x92, ®s, ®s);
regs.h.ah = 0xf9; /* 8 color */
regs.h.al = 0x00;
int86(0x92, ®s, ®s);
}
if ( vline == 256 ) {
if (y % 2 != 0)
return;
p_vram = (unsigned char far *)0xc0000000 + (y / 2) * 80 * 3;
n = xlen / 4 ;
} else {
if (y % 4 != 0)
return;
p_vram = (unsigned char far *)0xc0000000 + (y / 4) * 80 * 3;
n = xlen / 8 ;
}
for (i = 0; i < n; i++, p_vram++) {
if ( vline == 256 ) {
cl0 = *framebuf++;
cl1 = *framebuf++;
cl2 = *framebuf++;
cl3 = *framebuf++;
} else {
cl0 = *framebuf;
cl1 = *(framebuf + 2);
cl2 = *(framebuf + 4);
cl3 = *(framebuf + 6);
framebuf += 8;
}
*(char far *)0xc000ff81 = 4;
c0 = gc(cl0); /* green */
c1 = gc(cl1);
c2 = gc(cl2);
c3 = gc(cl3);
*(p_vram ) = setval0(c0, c1, c2, c3);
*(p_vram + LINE1) = setval1(c0, c1, c2, c3);
*(p_vram + LINE2) = setval2(c0, c1, c2, c3);
*(char far *)0xc000ff81 = 2;
c0 = rc(cl0); /* red */
c1 = rc(cl1);
c2 = rc(cl2);
c3 = rc(cl3);
*(p_vram ) = setval1(c0, c1, c2, c3);
*(p_vram + LINE1) = setval2(c0, c1, c2, c3);
*(p_vram + LINE2) = setval0(c0, c1, c2, c3);
*(char far *)0xc000ff81 = 1;
c0 = bc(cl0); /* blue */
c1 = bc(cl1);
c2 = bc(cl2);
c3 = bc(cl3);
*(p_vram ) = setval2(c0, c1, c2, c3);
*(p_vram + LINE1) = setval0(c0, c1, c2, c3);
*(p_vram + LINE2) = setval1(c0, c1, c2, c3);
}
}
/* ライン */
void crtline( x1, y1, x2, y2 )
int x1, y1, x2, y2 ;
{
int ret;
unsigned n, offset;
if ( vline == 256 )
{
x1 *= 2 ;
y1 *= 2 ;
x2 *= 2 ;
y2 *= 2 ;
}
y1 = y1 * 3 / 4 ;
y2 = y2 * 3 / 4 ;
GDS_lineColor( &data , 7 );
GDS_chainFirst( &data , x1 , y1 , x2 , y2 );
GDS_outputGraph( &data , &n ,&offset );
GDS_resetData( &data );
}