home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Kyūkyoku!! X68000 Emulator
/
X68000Book.dat
/
mac
/
OLS
/
X68000
/
Ko-Window
/
gvto6511.lzh
/
gv_to65.c
next >
Wrap
C/C++ Source or Header
|
1995-02-16
|
4KB
|
172 lines
/*
Copyright 1995 Ogasawara Hiroyuki(COR.)
*/
#include <corlib.h>
#include <sys_doslib.h>
#include "Sesse.inc"
#define PROG "GV_to65 v1.10"
#define GVIEWWIN "gview.win"
#define XSIZE 86
#define YSIZE 16
int WindowHeapSize= 1024*0;
static void
WaitMark()
{
MouseSetPattern( 1, &SessePattern, 7, 3 );
MS_SEL( 1 );
}
static void
MakeNewGWin( ng, gp )
UGraphic *ng, *gp;
{
EventInfo info;
info.option= EventUser;
info.ComBuffer= ng;
info.ComData= UserGraphic;
PidSendEvent( GVIEWWIN, &info, TRUE );
MFREE( ng->buf );
}
GV_Small( gp )
UGraphic *gp;
{
UGraphic ng;
unsigned short *str= MALLOC( gp->h*gp->v*2/4 ),
*ptr= (void*)gp->buf;
int y;
WaitMark();
if( (int)(ng.buf= str) < 0 )
return FALSE;
for( y= gp->v/2-1 ; y >= 0 ; y-- ){
int x;
for( x= gp->h/2-1 ; x-- >= 0 ;){
unsigned int a= *ptr++,
b= *ptr++,
c= ptr[gp->h-2],
d= ptr[gp->h-1];
*str++=
((((a&0xf800)+(b&0xf800)+(c&0xf800)+(d&0xf800))>>2)&0xf800)+
((((a&0x07c0)+(b&0x07c0)+(c&0x07c0)+(d&0x07c0))>>2)&0x07c0)+
((((a&0x003e)+(b&0x003e)+(c&0x003e)+(d&0x003e))>>2)&0x003e);
}
ptr+= gp->h;
}
ng.h= gp->h/2;
ng.v= gp->v/2;
ng.palet= NULL;
ng.color= WindowAttrGraphic65536;
MakeNewGWin( &ng, gp );
MS_SEL( 0 );
return TRUE;
}
GV_to65( gp )
UGraphic *gp;
{
if( gp->color == WindowAttrGraphic65536 && !gp->palet )
return GV_Small( gp );
WaitMark();
{
UGraphic ng;
unsigned short *str= MALLOC( gp->h*gp->v*2/4 );
unsigned char *ptr= (void*)gp->buf;
int x, y;
if( (int)(ng.buf= str) < 0 )
return FALSE;
for( y= 0 ; y< gp->v/2 ; y++, ptr+= gp->h ){
for( x= 0 ; x< gp->h/2 ; x++, ptr+= 2 ){
unsigned int a= gp->palet[ptr[0]],
b= gp->palet[ptr[1]],
c= gp->palet[ptr[gp->h]],
d= gp->palet[ptr[gp->h+1]];
*str++=
((((a&0xf800)+(b&0xf800)+(c&0xf800)+(d&0xf800))>>2)&0xf800)+
((((a&0x07c0)+(b&0x07c0)+(c&0x07c0)+(d&0x07c0))>>2)&0x07c0)+
((((a&0x003e)+(b&0x003e)+(c&0x003e)+(d&0x003e))>>2)&0x003e);
}
}
ng.h= gp->h/2;
ng.v= gp->v/2;
ng.palet= NULL;
ng.color= WindowAttrGraphic65536;
MakeNewGWin( &ng, gp );
}
MS_SEL( 0 );
return TRUE;
}
static int
EventExec( wp, info )
WindowID wp;
EventInfo *info;
{
DrawBuf dbuf[4];
switch( info->option ){
case EventOpen:
WindowSetEventAttr( wp, EventOpenON|EventRedrawON
|EventCloseON|EventMouseSwitchON|EventIconifyON
|EventUserON );
WindowRedraw( wp );
return TRUE;
case EventIconify:
IconEnt( wp, PROG, AttrDefault, 12 );
return TRUE;
case EventRedraw:
DrawSetClear( dbuf, ColorGray );
DrawSetSymbol( dbuf+1, 3, 1, PROG, AttrDefault|4, 12 );
WindowDraw( wp, dbuf, 2 );
return TRUE;
case EventClose:
WindowClose( wp );
WindowConnectionClose();
return TRUE;
case EventUser:
switch( info->ComData ){
case UserGraphic:
GV_to65( info->ComBuffer );
return TRUE;
case UserString:
case UserPaste:
case UserStrings:
break;
}
return FALSE;
case EventMouseSwitch:
if( info->LeftON ){
ConsoleOpen();
ConsolePrint(
"\r\n" PROG " 1995 COR.\r\n"
"------------------------------------------------------------------------\r\n"
"16/256/65536ÉFëµæ£âfü[â^é≡1/4é╔Åkżò╧è╖é╡üA65536ÉFëµæ£é┼Åoù═é╡é▄é╖üBôⁿÅo\r\n"
"ù═é═ EventUser é╠ UserGraphic é┼ìséóé▄é╖üBÅoù═é╠é╜é▀é╔ gview é¬òKùvé┼é╖üB\r\n"
"------------------------------------------------------------------------\r\n"
);
return TRUE;
}
return FALSE;
}
return FALSE;
}
void
WindowMain( argc, argv )
char **argv;
{
int x= 300, y= 0;
argc= AnalyzeArgs( argc, argv, &x, &y, NULL, NULL );
WindowTitleOpen( x, y, XSIZE, YSIZE, NULL, " ",
Close|Push|Icon, EventExec );
}