home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1997 March
/
VPR9703A.ISO
/
VPR_DATA
/
DOGA
/
SOURCES
/
REND.LZH
/
REND
/
CRTVGA.C
< prev
next >
Wrap
C/C++ Source or Header
|
1996-07-24
|
3KB
|
159 lines
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
#include <stdarg.h>
#include "reader.h"
#include "glib.h"
#include "rend.h"
#include <grdriver.h>
#include <grx20.h>
char *program = "Do-GA C.G.A System Rendering Program for AT/VGA+go32" ;
#define TOPLINE 64
int width, height;
static int textx, texty;
static int video_mode = 0;
static int initflag = FALSE;
static int cBlack, cWhite;
void crtexit(void)
{
if (initflag != FALSE) {
union REGS regs ;
/* GrSetMode(GR_default_text);*/
regs.h.ah = 0 ;
regs.h.al = video_mode ;
int86( 0x10, ®s, ®s );
initflag = FALSE;
}
}
/* CRTの初期化 */
void crtinit( line )
int line ;
{
#if 0
video_mode = *(char*)( 0xE0000000 | 0x449 );
GrSetMode(GR_width_height_color_graphics, 640, 480, 256);
GrSetRGBcolorMode();
/*
width = GrScreenX();
height = GrScreenY();
*/
width = 640;
height = 480;
GrFilledBox(0, 0, width-1, height-1, 0);
#else
union REGS regs;
regs.h.ah = 0x0f;
int86(0x10, ®s, ®s);
video_mode = regs.h.al;
atexit(crtexit);
regs.h.ah = 0;
regs.h.al = 0x01;
int86(0x10,®s,®s);
#ifdef COLOR256
GrSetMode(GR_width_height_color_graphics, 640, 480, 256);
#else
GrSetMode(GR_width_height_color_graphics, 640, 480, 32768);
#endif
GrSetRGBcolorMode();
width = GrScreenX();
height = GrScreenY();
GrClearScreen(GrBlack());
/* atexit(crtexit);*/
#endif
initflag = TRUE;
}
void crtmessage(char *str)
{
extern int uflag;
if (uflag) {
fputs(str, stderr);
fputc('\n', stderr);
} else {
GrTextXY(textx, texty, str, GrWhite(), 0);
texty+=16;
}
}
/* CRTのクリア */
void crtclr()
{
GrClearScreen(GrBlack());
textx = texty = 0;
}
static inline int X68tobyte(unsigned short c)
{
return ((c & 0xe000) >> 11) | ((c & 0x0700) >> 3) | ((c & 0x0030) >> 4);
}
static inline int X68toshort(unsigned short c)
{
return ((c & 0xf800) >> 6) | ((c & 0x07c0) << 4) | ((c & 0x003e) >> 1);
}
/* CRT出力 */
void crtout( framebuf, xlen, y )
unsigned short *framebuf ;
int xlen ;
int y ;
{
int x;
for (x = 0; x < xlen; ++x) {
#ifdef COLOR256
GrPlot(x, y+TOPLINE, X68tobyte(*framebuf++));
#else
GrPlotNC(x, y+TOPLINE, X68toshort(*framebuf++));
#endif
}
}
void crtline( x1, y1, x2, y2 )
int x1, y1, x2, y2 ;
{
GrLineNC(x1, y1+TOPLINE, x2, y2+TOPLINE, GrWhite());
}
static char buf[1024];
int fprintf(FILE * fp, const char * format, ...)
{
int l;
va_list arglist;
va_start(arglist, format);
l = vsprintf(buf, format, arglist);
va_end(arglist);
if (initflag && (fp == stderr || fp == stdout)) {
crtmessage(buf);
} else {
fputs(buf, fp);
}
return l;
}