home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Phoenix Heaven Sunny 2
/
APPARE2.BIN
/
oh_towns
/
art2
/
src.lzh
/
ICONDAT.C
< prev
next >
Wrap
C/C++ Source or Header
|
1995-06-18
|
14KB
|
358 lines
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <winb.h>
#include <te.h>
#include <fntb.h>
#include <gui.h>
#include "art.h"
#include "icondat.h"
/* 自由点描、自由曲線、直線などの 24×24dot アイコン(ビットパターン) */
static unsigned char toolbox_icon[][24*24/8] =
{
/* 自由点描 */
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x01,0x98,0x00,0x01,0x80,
0x00,0x18,0x00,0x01,0x9b,0x00,0x01,0x83,0x00,0x00,0x30,0x00,
0x0c,0x31,0x80,0x0c,0x01,0x80,0x00,0x18,0x00,0x00,0x1b,0x00,
0x00,0x03,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
/* 自由曲線 */
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xf8,0x00,0x07,0x00,0x00,0x08,0x00,
0x00,0x7c,0x00,0x01,0x92,0x00,0x02,0x21,0x00,0x04,0x21,0x00,
0x08,0x21,0x00,0x08,0x21,0x00,0x10,0x11,0x00,0x10,0x0e,0x00,
0x10,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
/* 直線 */
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,
0x00,0x00,0x30,0x00,0x00,0xc0,0x00,0x03,0x00,0x00,0x0c,0x00,
0x00,0x30,0x00,0x00,0xc0,0x00,0x03,0x00,0x00,0x0c,0x00,0x00,
0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
/* 長方形フィル */
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0xff,0xf8,0x15,0x55,0x58,
0x1a,0xaa,0xa8,0x15,0x55,0x58,0x1a,0xaa,0xa8,0x15,0x55,0x58,
0x1a,0xaa,0xa8,0x15,0x55,0x58,0x1a,0xaa,0xa8,0x15,0x55,0x58,
0x1a,0xaa,0xa8,0x1f,0xff,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
// 楕円フィル
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xff,0x00,0x03,0x55,0xc0,0x06,0xaa,0xa0,
0x0d,0x55,0x50,0x0a,0xaa,0xb0,0x15,0x55,0x58,0x1a,0xaa,0xa8,
0x15,0x55,0x58,0x1a,0xaa,0xa8,0x0d,0x55,0x50,0x0a,0xaa,0xb0,
0x05,0x55,0x60,0x03,0xaa,0xc0,0x00,0xff,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
// 楕円枠線
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xff,0x00,0x03,0x00,0xc0,0x04,0x00,0x20,
0x08,0x00,0x10,0x08,0x00,0x10,0x10,0x00,0x08,0x10,0x00,0x08,
0x10,0x00,0x08,0x10,0x00,0x08,0x08,0x00,0x10,0x08,0x00,0x10,
0x04,0x00,0x20,0x03,0x00,0xc0,0x00,0xff,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
// 矩形枠線
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0xff,0xf8,0x10,0x00,0x08,
0x10,0x00,0x08,0x10,0x00,0x08,0x10,0x00,0x08,0x10,0x00,0x08,
0x10,0x00,0x08,0x10,0x00,0x08,0x10,0x00,0x08,0x10,0x00,0x08,
0x10,0x00,0x08,0x1f,0xff,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
// 擦りペン
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x1c,0x1e,0x00,0x1c,0x0e,0x78,
0x0d,0xff,0xfc,0x0d,0x80,0x08,0x0d,0xfd,0xf0,0x07,0x66,0x60,
0x06,0x5d,0x40,0x7f,0x59,0xe0,0x14,0x92,0x38,0x04,0x37,0x80,
0x06,0xcf,0x00,0x07,0x00,0x00,0x06,0x3f,0xe0,0x0c,0x3e,0x60,
0x3c,0x06,0x00,0x34,0x06,0x40,0x14,0x62,0x30,0x04,0x67,0x18,
0x00,0x0f,0x18,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
// 矩形コピー
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xf8,0x00,0x80,0x08,
0x00,0x80,0x08,0x00,0x80,0x08,0x00,0x80,0x08,0x1f,0xff,0x08,
0x10,0x01,0x08,0x10,0x01,0x08,0x10,0x00,0x88,0x10,0x01,0xc8,
0x10,0x0b,0x88,0x10,0x0f,0x08,0x10,0x0e,0x08,0x10,0x0f,0x08,
0x10,0x00,0xf8,0x10,0x01,0x00,0x10,0x01,0x00,0x10,0x01,0x00,
0x10,0x01,0x00,0x1f,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
// 領域塗りつぶし
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x14,0x00,
0x00,0x22,0x00,0x00,0x41,0x00,0x00,0x80,0x80,0x01,0x00,0x40,
0x02,0x00,0x20,0x04,0x00,0x10,0x07,0xff,0xf8,0x04,0xff,0xf8,
0x04,0x7f,0xf0,0x04,0x3f,0xe0,0x04,0x1f,0xc0,0x04,0x0f,0x80,
0x04,0x07,0x00,0x04,0x00,0x00,0x0e,0x00,0x00,0x3f,0xf0,0x00,
0x3f,0xff,0xe0,0x1f,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
// 滲
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0e,0x00,0x0e,0x0c,0x00,
0x0e,0x08,0x20,0x03,0x10,0x20,0x00,0x3f,0xf0,0x00,0x7a,0x30,
0x00,0x06,0x18,0x3c,0xff,0xfc,0x39,0xfe,0x80,0x20,0x18,0xc0,
0x00,0x11,0x60,0x00,0x37,0x70,0x01,0xee,0x3c,0x03,0xcc,0x9c,
0x06,0xc1,0x8c,0x1e,0x1f,0x20,0x1e,0x0e,0x40,0x1c,0x01,0x80,
0x0c,0x3f,0x00,0x04,0x1e,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
// 朦
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x11,0x80,0x0d,0x11,0x80,
0x0f,0x7d,0xf8,0x09,0x65,0x00,0x09,0x2d,0xfc,0x0f,0x29,0xec,
0x09,0xfc,0x0c,0x0d,0x00,0xfc,0x0f,0x7d,0x80,0x09,0x4d,0x80,
0x09,0x45,0x78,0x19,0x7d,0xe0,0x19,0x4d,0x40,0x19,0x7d,0xf0,
0x19,0x4d,0x00,0x19,0x45,0xf0,0x1b,0x45,0x84,0x3b,0x5d,0x0c,
0x3b,0x5d,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
// 砂
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x80,0x00,0x03,0x80,
0x00,0x01,0x80,0x00,0x01,0x80,0x0f,0xc0,0xd0,0x06,0x04,0xd8,
0x06,0x08,0xc8,0x06,0x1a,0xcc,0x0d,0xb9,0x8c,0x0f,0x99,0x8c,
0x0d,0x80,0xac,0x19,0x80,0x20,0x39,0x80,0x40,0x2f,0x80,0xc0,
0x01,0x81,0x80,0x00,0x03,0x80,0x00,0x07,0x00,0x00,0x1e,0x00,
0x00,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
// ポリゴンフィル
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,
0x00,0x06,0x80,0x00,0x3d,0x40,0x00,0xea,0xc0,0x07,0x55,0x40,
0x06,0xaa,0xa0,0x05,0x55,0x60,0x06,0xaa,0xa0,0x0d,0x55,0x50,
0x0a,0xaa,0xb0,0x0d,0x55,0x50,0x0a,0xaa,0xa8,0x0d,0x55,0x58,
0x0a,0xaa,0xa8,0x15,0x55,0x54,0x1a,0xaa,0xfc,0x15,0xff,0x80,
0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
// ポリゴンコピー
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x01,0xa0,
0x00,0x0e,0x20,0x00,0x30,0x10,0x00,0x20,0x10,0x00,0x0c,0x10,
0x00,0x34,0x10,0x01,0xc4,0x10,0x06,0x00,0x88,0x04,0x01,0xc8,
0x04,0x0b,0x88,0x08,0x0f,0x08,0x08,0x0e,0x04,0x08,0x0f,0x04,
0x10,0x00,0x7c,0x10,0x01,0x00,0x10,0x01,0x00,0x20,0x00,0x80,
0x20,0x00,0x80,0x3f,0xff,0x80,0x00,0x00,0x00,0x00,0x00,0x00 },
/* 終了マーク */
{ 0xff,0xff,0xff }
};
static unsigned char iconARTEMIS[] =
/* 56×12dot */
{
0x03,0x87,0xe7,0xfe,0x00,0x00,0x00, 0x03,0x86,0x10,0x60,0x00,0x00,0x00,
0x03,0x86,0x08,0x60,0x00,0x03,0x00, 0x04,0xc6,0x08,0x60,0x00,0x03,0x00,
0x04,0xc6,0x08,0x60,0x00,0x00,0x00, 0x04,0xc6,0x08,0x61,0xc7,0xb3,0x3e,
0x08,0x66,0x10,0x63,0x26,0x4b,0x60, 0x08,0x67,0xe0,0x66,0x16,0x4b,0x60,
0x0f,0xe6,0x20,0x67,0xf6,0x4b,0x3c, 0x10,0x36,0x30,0x66,0x06,0x4b,0x06,
0x10,0x36,0x10,0x63,0x06,0x4b,0x06, 0x10,0x36,0x18,0x61,0xe6,0x4b,0x7c
};
static unsigned char icon_pensel[] =
/* 38×38dot */
{
0xff,0xff,0xff,0xff,0xfc, 0xff,0xff,0xff,0xff,0xfc, 0xc0,0x00,0x00,0x00,0x0c,
0xc0,0x00,0x00,0x00,0x0c, 0xc0,0x00,0x00,0x00,0x0c, 0xc0,0x00,0x00,0x00,0x0c,
0xc0,0x00,0x00,0x00,0x0c, 0xc0,0x00,0x00,0x00,0x0c, 0xc0,0x00,0x00,0x00,0x0c,
0xc0,0x00,0x00,0x00,0x0c, 0xc0,0x00,0x00,0x00,0x0c, 0xc0,0x00,0x00,0x00,0x0c,
0xc0,0x00,0x00,0x00,0x0c, 0xc0,0x00,0x00,0x00,0x0c, 0xc0,0x00,0x00,0x00,0x0c,
0xc0,0x00,0x00,0x00,0x0c, 0xc0,0x00,0x00,0x00,0x0c, 0xc0,0x00,0x00,0x00,0x0c,
0xc0,0x00,0x00,0x00,0x0c, 0xc0,0x00,0x00,0x00,0x0c, 0xc0,0x00,0x00,0x00,0x0c,
0xc0,0x00,0x00,0x00,0x0c, 0xc0,0x00,0x00,0x00,0x0c, 0xc0,0x00,0x00,0x00,0x0c,
0xc0,0x00,0x00,0x00,0x0c, 0xc0,0x00,0x00,0x00,0x0c, 0xc0,0x00,0x00,0x00,0x0c,
0xc0,0x00,0x00,0x00,0x0c, 0xc0,0x00,0x00,0x00,0x0c, 0xc0,0x00,0x00,0x00,0x0c,
0xc0,0x00,0x00,0x00,0x0c, 0xc0,0x00,0x00,0x00,0x0c, 0xc0,0x00,0x00,0x00,0x0c,
0xc0,0x00,0x00,0x00,0x0c, 0xc0,0x00,0x00,0x00,0x0c, 0xc0,0x00,0x00,0x00,0x0c,
0xff,0xff,0xff,0xff,0xfc, 0xff,0xff,0xff,0xff,0xfc
};
static unsigned char icon_colsel_off[] =
/* 24×24dot */
{
0xff,0xff,0xff, 0x80,0x00,0x01, 0x80,0x00,0x01, 0x80,0x00,0x01,
0x80,0x00,0x01, 0x80,0x00,0x01, 0x80,0x00,0x01, 0x80,0x00,0x01,
0x80,0x00,0x01, 0x80,0x00,0x01, 0x80,0x00,0x01, 0x80,0x00,0x01,
0x80,0x00,0x01, 0x80,0x00,0x01, 0x80,0x00,0x01, 0x80,0x00,0x01,
0x80,0x00,0x01, 0x80,0x00,0x01, 0x80,0x00,0x01, 0x80,0x00,0x01,
0x80,0x00,0x01, 0x80,0x00,0x01, 0x80,0x00,0x01, 0xff,0xff,0xff
};
static unsigned char icon_colsel_on[] =
/* 24×24dot */
{
0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00,
0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00,
0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00,
0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00,
0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00,
0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00
};
static unsigned char icon_winzoomup[] =
{
0x00,0x00, 0x70,0xe0, 0x60,0x60, 0x50,0xa0, 0x09,0x00, 0x00,0x00,
0x00,0x00, 0x09,0x00, 0x50,0xa0, 0x60,0x60, 0x70,0xe0, 0x00,0x00
};
static unsigned char icon_winzoomdown[] =
{
0x00,0x00, 0x40,0x20, 0x29,0x40, 0x19,0x80, 0x39,0xc0, 0x00,0x00,
0x00,0x00, 0x39,0xc0, 0x19,0x80, 0x29,0x40, 0x40,0x20, 0x00,0x00
};
static unsigned char icon_erasebtn[] =
{
0x00,0x00, 0x00,0x00, 0x30,0xc0, 0x39,0xc0, 0x1f,0x80, 0x0f,0x00,
0x0f,0x00, 0x1f,0x80, 0x39,0xc0, 0x30,0xc0, 0x00,0x00, 0x00,0x00
};
#define ATR_UFRAME 0x000_0001
#define ATR_DFRAME 0x000_0002
#define ATR_EDGE 0x000_0004
#define ATR_ONLIGHT 0x000_0008
#define ATR_WHITE 0x000_0010
static void icon_setdot(int scr,char *buf,int wid,int ht,int x,int y,int col)
{
unsigned int *coltbl;
coltbl = MG_getColorTable(scr);
if (scr==2)
*(short*) &buf[4+wid*y*2+x*2] = coltbl[col] & 0x7fff;
else if (scr==0)
{
char *p = buf + 4 + ((wid+7)/8) * 4 * y + x / 2;
*p = ((x&1)==0 ? (*p & 0xf0) | ( col & 0x0f) :
(*p & 0x0f) | ((col << 4) & 0xf0));
}
else if (scr==3)
{
char *p = buf + 4 + (wid*y+x)*3;
uint c = coltbl[col] & 0xffffff;
p[0] = c & 0xff;
p[1] = (c >> 8) & 0xff;
p[2] = (c >> 16) & 0xff;
}
}
static int icon_chkbit(unsigned char *bitbuf,int wid,int ht,int x,int y)
{
int bitpat,mask;
bitpat = bitbuf[ ((wid+7)/8) * y + (x >> 3) ];
mask = 0x80U >> (x & 7);
if ((bitpat & mask) != 0 )
return 1;
else
return 0;
}
static char *icon_allocbuf(int scr,int wid, int ht)
{
int size = 1;
if (scr == 0)
size = 4 + ((wid+7)/8)*4*ht;
else if (scr == 2)
size = 4 + wid*ht*2;
else if (scr == 3)
size = 4 + wid*ht*3;
return TL_calloc(size,1);
}
static unsigned char *makeicondat(unsigned char *bitpat,int wid,int ht,int atr)
{
SCREEN scr;
char *buf;
int i,j;
int piccol;
/* 画面モード、カラー変換テーブルの取得 */
MMI_GetScreen(&scr);
/* グラフィックデータ領域の確保 */
if ((buf = icon_allocbuf(scr.mode, wid,ht)) == NULL)
return NULL;
/* パターンの大きさ、色数のパラメータ設定 */
buf[0] = wid;
buf[1] = ht;
buf[2] = 0;
buf[3] = (scr.mode == 0 ? 4 : scr.mode == 2 ? 16 : scr.mode == 3 ? 24 : 0);
/* パターンデータのビットをチェックするマクロ */
#define SETDOT(x,y,col) icon_setdot(scr.mode, buf, wid,ht,x,y,col)
#define CHKBIT(x,y) icon_chkbit(bitpat, wid,ht,x,y)
/* 全体を灰色(または白)に塗る */
for (i=0; i<ht; i++)
for (j=0; j<wid; j++)
{
int col;
if (atr & ATR_WHITE)
col = WHITE;
else if (atr & ATR_ONLIGHT)
col = DARKGRAY;
else
col = GRAY;
SETDOT(j,i,col);
}
/* 枠を描く */
if (atr & ATR_UFRAME)
{
for (i=0; i<wid; i++) SETDOT(i,0,LIGHT);
for (i=0; i<ht; i++) SETDOT(0,i,LIGHT);
for (i=1; i<wid; i++) SETDOT(i,ht-1,SHADOW);
for (i=1; i<ht; i++) SETDOT(wid-1,i,SHADOW);
}
if (atr & ATR_DFRAME)
{
for (i=0; i<wid-1; i++) SETDOT(i,0,SHADOW);
for (i=0; i<ht-1; i++) SETDOT(0,i,SHADOW);
for (i=0; i<wid; i++) SETDOT(i,ht-1,LIGHT);
for (i=0; i<ht; i++) SETDOT(wid-1,i,LIGHT);
}
if (atr & ATR_ONLIGHT)
piccol = 13;
else
piccol = 8;
/* 絵柄を描く */
if (bitpat != NULL)
{
for (i=0; i<ht; i++)
for (j=0; j<wid; j++)
{
if (CHKBIT(j,i))
SETDOT(j,i,piccol);
else if ((atr & ATR_EDGE) && j > 0 && CHKBIT(j-1,i))
SETDOT(j,i,LIGHT);
}
}
/* 終了 */
#undef CHKBIT
#undef SETDOT
return (unsigned char*)buf;
}
#define ICN_TBLNUM (ICN_MAXNUM+1-512)
static unsigned char *icon_table[ICN_TBLNUM];
int set_icontable(void)
{
int i,datcnt;
for (i=0; i<ICN_TBLNUM; i++)
icon_table[i] = NULL;
/* ARTemis アイコン */
icon_table[ICN_ARTEMIS-512] = makeicondat(iconARTEMIS,56,12,ATR_EDGE);
/* ツールボックスアイコン */
for (datcnt=0; ; datcnt++)
{
if (toolbox_icon[datcnt][0] == 0xff)
break;
icon_table[ICN_TOOLBOX-512 + datcnt * 2] =
makeicondat(toolbox_icon[datcnt],24,24,ATR_UFRAME);
icon_table[ICN_TOOLBOX-512 + datcnt * 2 + 1] =
makeicondat(toolbox_icon[datcnt],24,24,ATR_DFRAME | ATR_ONLIGHT);
}
/* ペン選択ボタン・仮イメージ */
for (i=0; i<ICN_PENSEL_N; i++)
{
icon_table[ICN_PENSEL-512+i*2 ] =
makeicondat(NULL,38,38,ATR_WHITE);
icon_table[ICN_PENSEL-512+i*2+1] =
makeicondat(icon_pensel,38,38,ATR_WHITE);
}
/* 色選択ボタン */
icon_table[ICN_COLSEL-512] = makeicondat(icon_colsel_off,24,24,ATR_WHITE);
icon_table[ICN_COLSEL-512+1]=makeicondat(icon_colsel_on,24,24,ATR_WHITE);
/* サイズボタン */
icon_table[ICN_WINZOOMUP -512] = makeicondat(icon_winzoomup, 12,12,0);
icon_table[ICN_WINZOOMDOWN-512] = makeicondat(icon_winzoomdown,12,12,0);
/* イレーズボタン */
icon_table[ICN_ERASEBTN-512]=makeicondat(icon_erasebtn,12,12,ATR_EDGE);
/* アイコンテーブルを設定 */
MMI_SetIconTable( icon_table, ICN_MAXNUM );
return 0;
ERROR:
return -1;
}