home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Kyūkyoku!! X68000 Emulator
/
X68000Book.dat
/
mac
/
OLS
/
X68000
/
Ko-Window
/
gvpsrt10.lzh
/
gv_psort.c
next >
Wrap
C/C++ Source or Header
|
1995-02-28
|
3KB
|
149 lines
/*
Copyright 1995 Ogasawara Hiroyuki(COR.)
*/
#include <corlib.h>
#include <sys_doslib.h>
#include "Sesse.inc"
#define PROG "GV_PSort 1.00"
#define GVIEWWIN "gview.win"
#define XSIZE (80+6)
#define YSIZE 14
int WindowHeapSize= 1024*0;
static void
WaitMark()
{
MouseSetPattern( 1, &SessePattern, 7, 3 );
MS_SEL( 1 );
}
static void
MakeNewGWin( ng )
UGraphic *ng;
{
EventInfo info;
info.option= EventUser;
info.ComBuffer= ng;
info.ComData= UserGraphic;
PidSendEvent( GVIEWWIN, &info, TRUE );
MFREE( ng->buf );
}
static
sort_exec( a, b )
unsigned short *a, *b;
{
return *a-*b;
}
GV_PSort( gp )
UGraphic *gp;
{
UGraphic ng;
WaitMark();
if( gp->color != WindowAttrGraphic65536 && gp->palet ){
unsigned char *str= MALLOC( gp->h*gp->v ),
*ptr= (void*)gp->buf,
new[256];
unsigned short Palet[256];
int len= gp->color == WindowAttrGraphic16 ? 16 : 256;
int x, y, i;
if( (int)(ng.buf= (void*)str) < 0 ){
MS_SEL( 0 );
ConsoleAutoPrint( "âüâéâèé¬æ½éΦé▄é╣é±\r\n" );
return FALSE;
}
memcpy( Palet, gp->palet, len*2 );
qsort( Palet, len, sizeof(short), sort_exec );
for( i= 0 ; i < len ; i++ ){
int j;
for( j= 0 ; j< len ; j++ ){
if( Palet[j] == gp->palet[i] ){
new[i]= j;
break;
}
}
}
for( i= 0 ; i < gp->h*gp->v ; i++ )
*str++= new[*ptr++];
ng.palet= Palet;
ng.color= gp->color;
ng.h= gp->h;
ng.v= gp->v;
MakeNewGWin( &ng );
}
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, 9|4, 12 );
WindowDraw( wp, dbuf, 2 );
return TRUE;
case EventClose:
WindowClose( wp );
WindowConnectionClose();
return TRUE;
case EventUser:
switch( info->ComData ){
case UserGraphic:
GV_PSort( 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ÉFëµæ£âfü[â^é╠âpâîâbâgé≡â\ü[âgé╡é▄é╖üBôⁿÅoù═é═ UserGraphic é┼ìséó\r\n\
é▄é╖üBÅoù═é╔ gview.win é¬ò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 );
}