home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Kyūkyoku!! X68000 Emulator
/
X68000Book.dat
/
mac
/
OLS
/
X68000
/
Ko-Window
/
kow142s.lzh
/
wsrv
/
vram.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-11-22
|
10KB
|
438 lines
#define WINDOW WinDow
#include "iocslib.h"
#undef WINDOW
#define VRAM
#define DRAW
#define AUTOGPOS 1
#define FILLIOCS 1
#define WIDE256 0
#include "clip.h"
#include "window.h"
#include "vram.h"
#include "sheet.h"
#include "screen.h"
#include "super.h"
ClipClass *VramClipPtr;
static Sheet Vram= { 1024, 1024, 64,
(unsigned short*)0xe00000,
(unsigned short*)0xe20000 };
static ClipClass VramClip= { 0, 0, 1023, 1023 };
static ClipClass GraphicClip= { 0, 0, 511, 1023 };
/*
proto -s vram.c > temp
*/
static void GramFill( int, int, int, int, int );
static void GramBox( int, int, int, int, int );
static void GramLine( int, int, int, int, int );
static void GramDot( int, int, int );
static void GramCircle( int, int, int, int, int, int );
extern void GramPut( ClipClass*, int, int, int, int, short* );
void
VramRegion( x1, y1, x2, y2 )
int x1, y1, x2, y2;
{
VramClip.clip.x1= x1;
VramClip.clip.y1= y1;
VramClip.clip.x2= x2;
VramClip.clip.y2= y2;
}
#if AUTOGPOS
void
GVramRegion( x1, y1, x2, y2 )
int x1, y1, x2, y2;
{
# if WIDE256
GraphicClip.clip.x1= x1;
GraphicClip.clip.x2= x2;
# else
GraphicClip.clip.x1= x1;
GraphicClip.clip.y1= y1;
GraphicClip.clip.x2= x2;
GraphicClip.clip.y2= y2;
# endif
}
#endif
#if 0
/****************************************** from clip.c ***************/
#define min( a, b ) (a) < (b) ? (a) : (b)
#define max( a, b ) (a) > (b) ? (a) : (b)
static inline int
XClipOverlap( ret, v1, v2 )
ClipClass *ret, *v1, *v2;
{
ret->clip.x1= max( v1->clip.x1, v2->clip.x1 );
ret->clip.y1= max( v1->clip.y1, v2->clip.y1 );
ret->clip.x2= min( v1->clip.x2, v2->clip.x2 );
ret->clip.y2= min( v1->clip.y2, v2->clip.y2 );
if( ret->clip.x1 > ret->clip.x2 || ret->clip.y1 > ret->clip.y2 )
return FALSE;
return TRUE;
}
/**********************************************************************/
#endif
void
VramDraw( bufp, n, clipptr, ox, oy )
DrawBuf *bufp;
int n;
ClipClass *clipptr;
int ox, oy;
{
ClipClass clip, gclip;
int Gclip= FALSE, Gbreak;
if( ClipOverlap( &clip, VramClipPtr, clipptr ) == FALSE )
return;
if( ClipOverlap( &clip, &clip, &VramClip ) == FALSE )
return;
X_InSuper(); /* +14 COR. */
for(; n-- ; bufp++ ){
switch( bufp->type ){
case DrawClear:
SheetLine( &Vram, &clip,
clip.clip.x1, clip.clip.y1,
clip.clip.x2, clip.clip.y2,
bufp->option.clear.code, OptionFill );
break;
case DrawLine:
SheetLine( &Vram, &clip,
bufp->option.line.x1 + ox,
bufp->option.line.y1 + oy,
bufp->option.line.x2 + ox,
bufp->option.line.y2 + oy,
bufp->option.line.code,
bufp->option.line.option );
break;
case DrawPut:
SheetCopy( &Vram, &clip,
bufp->option.put.x + ox,
bufp->option.put.y + oy,
bufp->option.put.sp );
break;
case DrawSymbol:
SheetSymbol( &Vram, &clip,
bufp->option.symbol.x + ox,
bufp->option.symbol.y + oy,
bufp->option.symbol.str,
bufp->option.symbol.attr,
bufp->option.symbol.font );
break;
case DrawPattern:
SheetPutPattern( &Vram, &clip, bufp->option.pattern.sp );
break;
case DrawGraphicClear:
if( GraphicMode != WindowAttrGraphic16 ){
if( !Gclip ){
Gclip= TRUE;
if( Gbreak= !ClipOverlap( &gclip, &clip, &GraphicClip ) )
break;
}else if( Gbreak )
break;
#if AUTOGPOS
WINDOW( gclip.clip.x1-GraphicClip.clip.x1,
gclip.clip.y1-GraphicClip.clip.y1,
gclip.clip.x2-GraphicClip.clip.x1,
gclip.clip.y2-GraphicClip.clip.y1 );
GramFill( gclip.clip.x1, gclip.clip.y1,
gclip.clip.x2, gclip.clip.y2,
bufp->option.clear.code );
#endif
}else{
WINDOW( clip );
GramFill( clip.clip.x1, clip.clip.y1,
clip.clip.x2, clip.clip.y2,
bufp->option.clear.code );
}
break;
case DrawGraphicLine:
if( GraphicMode != WindowAttrGraphic16 ){
if( !Gclip ){
Gclip= TRUE;
if( Gbreak= !ClipOverlap( &gclip, &clip, &GraphicClip ) )
break;
}else if( Gbreak )
break;
#if AUTOGPOS
WINDOW( gclip.clip.x1-GraphicClip.clip.x1,
gclip.clip.y1-GraphicClip.clip.y1,
gclip.clip.x2-GraphicClip.clip.x1,
gclip.clip.y2-GraphicClip.clip.y1 );
#endif
}else
WINDOW( clip );
{
int x, y, x2, y2;
x = bufp->option.line.x1 + ox;
y = bufp->option.line.y1 + oy;
x2= bufp->option.line.x2 + ox;
y2= bufp->option.line.y2 + oy;
switch( bufp->option.line.option ){
case OptionLine:
GramLine( x, y, x2, y2, bufp->option.line.code );
break;
case OptionFill:
GramFill( x, y, x2, y2, bufp->option.line.code );
break;
case OptionBox:
GramBox( x, y, x2, y2, bufp->option.line.code );
break;
}
}
break;
case DrawGraphicPut:
if( GraphicMode != WindowAttrGraphic16 ){
if( !Gclip ){
Gclip= TRUE;
if( Gbreak= !ClipOverlap(&gclip,&clip,&GraphicClip) )
break;
}else if( Gbreak )
break;
GramPut( &gclip, bufp->option.gput.x1 + ox,
bufp->option.gput.y1 + oy,
bufp->option.gput.x2 + ox,
bufp->option.gput.y2 + oy,
bufp->option.gput.gbuf );
}else{
GramPut( &clip, bufp->option.gput.x1 + ox,
bufp->option.gput.y1 + oy,
bufp->option.gput.x2 + ox,
bufp->option.gput.y2 + oy,
bufp->option.gput.gbuf );
}
break;
case DrawDot : /* ZARU2 */
SheetDot( &Vram, &clip,
bufp->option.dot.x + ox,
bufp->option.dot.y + oy,
bufp->option.dot.code );
break;
case DrawGraphicDot : /* COR.*/
if( GraphicMode != WindowAttrGraphic16 ){
if( !Gclip ){
Gclip= TRUE;
if( Gbreak= !ClipOverlap(&gclip,&clip,&GraphicClip) )
break;
}else if( Gbreak )
break;
#if AUTOGPOS
WINDOW( gclip.clip.x1-GraphicClip.clip.x1,
gclip.clip.y1-GraphicClip.clip.y1,
gclip.clip.x2-GraphicClip.clip.x1,
gclip.clip.y2-GraphicClip.clip.y1 );
#endif
}else
WINDOW( clip );
GramDot( bufp->option.dot.x+ox, bufp->option.dot.y+oy,
bufp->option.dot.code );
break;
case DrawCircle : /* ZARU2 */
SheetCircle( &Vram, &clip,
bufp->option.circle.x + ox,
bufp->option.circle.y + oy,
bufp->option.circle.rx,
bufp->option.circle.ry, bufp->option.circle.code,
bufp->option.circle.option );
break;
case DrawGraphicCircle : /* COR.*/
if( GraphicMode != WindowAttrGraphic16 ){
if( !Gclip ){
Gclip= TRUE;
if( Gbreak= !ClipOverlap( &gclip,&clip,&GraphicClip) )
break;
}else if( Gbreak )
break;
#if AUTOGPOS
WINDOW( gclip.clip.x1-GraphicClip.clip.x1,
gclip.clip.y1-GraphicClip.clip.y1,
gclip.clip.x2-GraphicClip.clip.x1,
gclip.clip.y2-GraphicClip.clip.y1 );
#endif
}else
WINDOW( clip );
GramCircle(
bufp->option.circle.x + ox,
bufp->option.circle.y + oy,
bufp->option.circle.rx,
bufp->option.circle.ry, bufp->option.circle.code,
bufp->option.circle.option );
break;
default:{
X_OutSuper();
ErrorCheck( FALSE, "VramDraw" );
return;
}
}
}
X_OutSuper(); /* +14 COR. */
}
/* ê┌ô« */
void
VramMove( x, y, clipptr )
int x, y;
ClipClass *clipptr ;
{
X_InSuper(); /* +14 */
SheetMove( &Vram, &VramClip, x, y, clipptr );
X_OutSuper(); /* +14 */
}
/* âXâNâìü[âï */
void
VramScroll( clipptr, dx, dy )
ClipClass *clipptr;
int dx, dy ;
{
ClipClass clip;
if( ClipOverlap( &clip, VramClipPtr, clipptr ) == FALSE )
return;
if( ClipOverlap( &clip, &clip, &VramClip ) == FALSE )
return;
X_InSuper(); /* +14 */
dx&= -16;
SheetScroll( &Vram, &clip, dx, dy );
X_OutSuper(); /* +14 */
}
/* âOâëâtâBâbâNé╠âtâBâï */
static void
GramFill( x1, y1, x2, y2, code )
int x1, y1, x2, y2, code;
{
#if FILLIOCS
struct FILLPTR fill;
# if AUTOGPOS
x1-= GraphicClip.clip.x1;
x2-= GraphicClip.clip.x1;
y1-= GraphicClip.clip.y1;
y2-= GraphicClip.clip.y1;
# endif
fill.x1= x1;
fill.y1= y1;
fill.x2= x2;
fill.y2= y2;
fill.color= code;
FILL( &fill );
#else /* FILLIOCS */
int Xlen= x2-x1+1,
Ylen= y2-y1+1,
adrH, adr;
if( GraphicMode == 4 /* WindowAttrGraphic16 */ ){
adrH= 1024*2;
}else{
adrH= 512*2;
}
adr= 0xc00000+ x1*2 + adrH * y1;
InSuper();
GramFill1( Xlen, Ylen, code, adrH, adr );
OutSuper();
#endif /* FILLIOCS */
}
/* âOâëâtâBâbâNé╠â{âbâNâX */
static void
GramBox( x1, y1, x2, y2, code )
int x1, y1, x2, y2, code ;
{
struct BOXPTR box ;
#if AUTOGPOS
x1-= GraphicClip.clip.x1;
x2-= GraphicClip.clip.x1;
y1-= GraphicClip.clip.y1;
y2-= GraphicClip.clip.y1;
#endif
box.x1 = x1 ;
box.y1 = y1 ;
box.x2 = x2 ;
box.y2 = y2 ;
box.color = code ;
box.linestyle = 0xFFFF ; /* 1992 COR.*/
BOX( &box );
}
/* âOâëâtâBâbâNé╠âëâCâô */
static void
GramLine( x1, y1, x2, y2, code )
int x1, y1, x2, y2, code ;
{
struct LINEPTR line ;
#if AUTOGPOS
x1-= GraphicClip.clip.x1;
x2-= GraphicClip.clip.x1;
y1-= GraphicClip.clip.y1;
y2-= GraphicClip.clip.y1;
#endif
line.x1 = x1 ;
line.y1 = y1 ;
line.x2 = x2 ;
line.y2 = y2 ;
line.color = code ;
line.linestyle = 0xFFFF ;
LINE( &line );
}
/* âOâëâtâBâbâNé╠âhâbâg 1992 12/9 COR. */
static void
GramDot( x1, y1, code )
int x1, y1, code ;
{
struct PSETPTR pset ;
#if AUTOGPOS
x1-= GraphicClip.clip.x1;
y1-= GraphicClip.clip.y1;
#endif
pset.x = x1 ;
pset.y = y1 ;
pset.color = code ;
PSET( &pset );
}
/* âOâëâtâBâbâNé╠âTü[âNâï 1992 12/9 COR. */
static void
GramCircle( x1, y1, rx, ry, code, option )
int x1, y1, rx, ry, code, option ;
{
struct CIRCLEPTR circle ;
#if AUTOGPOS
x1-= GraphicClip.clip.x1;
y1-= GraphicClip.clip.y1;
#endif
circle.x = x1 ;
circle.y = y1 ;
circle.color = code ;
circle.start= 0;
circle.end= 360;
circle.radius = rx > ry ? rx : ry;
circle.ratio= (ry<<8)/rx;
CIRCLE( &circle );
}