#include "compiler.h"
#include "mkfnt.h"
// ---- JIS78
static const UINT8 jis78table[] = {
// del del del del del
0x0f, 0x5f, 0,
0x01, 0x10, 0x1a, 0x21, 0x3b, 0x41, 0x5b, 0x5f, 0,
0x54, 0x5f, 0,
0x57, 0x5f, 0,
0x19, 0x21, 0x39, 0x5f, 0,
0x22, 0x31, 0x52, 0x5f, 0,
0x01, 0x5f, 0,
0x01, 0x5f, 0,
0x01, 0x5f, 0,
0x01, 0x5f, 0,
0x01, 0x5f, 0,
0x1f, 0x20, 0x37, 0x3f, 0x5d, 0x5f, 0};
BOOL isjis78(UINT16 jis) {
const UINT8 *p;
UINT tmp;
switch(jis >> 8) {
case 0x22:
case 0x23:
case 0x24:
case 0x25:
case 0x26:
case 0x27:
case 0x28:
case 0x29:
case 0x2a:
case 0x2b:
case 0x2c:
case 0x2d:
p = jis78table;
tmp = (jis >> 8) - 0x22;
while(tmp) {
tmp--;
while(*p++) { }
}
tmp = (jis & 0xff) - 0x20;
while(*p) {
if ((tmp >= (UINT)p[0]) && (tmp < (UINT)p[1])) {
return(FALSE);
}
p += 2;
}
break;
case 0x4f:
tmp = jis & 0xff;
if (tmp >= 0x54) {
return(FALSE);
}
break;
case 0x7c:
tmp = jis & 0xff;
if ((tmp == 0x6f) || (tmp == 0x70)) {
return(FALSE);
}
break;
case 0x2e:
case 0x2f:
case 0x74:
case 0x75:
case 0x76:
case 0x77:
case 0x78:
case 0x7d:
case 0x7e:
case 0x7f:
return(FALSE);
}
return(TRUE);
}
// ---- JIS83
static const UINT8 jis83table[] = {
// del del del del del
0x0f, 0x1a, 0x22, 0x2a, 0x31, 0x3c, 0x4b, 0x52, 0x5a, 0x5e, 0,
0x01, 0x10, 0x1a, 0x21, 0x3b, 0x41, 0x5b, 0x5f, 0,
0x54, 0x5f, 0,
0x57, 0x5f, 0,
0x19, 0x21, 0x39, 0x5f, 0,
0x22, 0x31, 0x52, 0x5f, 0,
0x01, 0x5f, 0,
0x01, 0x5f, 0,
0x01, 0x5f, 0,
0x01, 0x5f, 0,
0x01, 0x5f, 0,
0x1f, 0x20, 0x37, 0x3f, 0x5d, 0x5f, 0};
BOOL isjis83(UINT16 jis) {
const UINT8 *p;
UINT tmp;
switch(jis >> 8) {
case 0x22:
case 0x23:
case 0x24:
case 0x25:
case 0x26:
case 0x27:
case 0x28:
case 0x29:
case 0x2a:
case 0x2b:
case 0x2c:
case 0x2d:
p = jis83table;
tmp = (jis >> 8) - 0x22;
while(tmp) {
tmp--;
while(*p++) { }
}
tmp = (jis & 0xff) - 0x20;
while(*p) {
if ((tmp >= (UINT)p[0]) && (tmp < (UINT)p[1])) {
return(FALSE);
}
p += 2;
}
break;
case 0x4f:
tmp = jis & 0xff;
if (tmp >= 0x54) {
return(FALSE);
}
break;
case 0x74:
tmp = jis & 0xff;
if ((tmp < 0x21) || (tmp > 0x24)) {
return(FALSE);
}
break;
case 0x7c:
tmp = jis & 0xff;
if ((tmp == 0x6f) || (tmp == 0x70)) {
return(FALSE);
}
break;
case 0x2e:
case 0x2f:
case 0x75:
case 0x76:
case 0x77:
case 0x78:
case 0x7d:
case 0x7e:
case 0x7f:
return(FALSE);
}
return(TRUE);
}
// ----
typedef struct {
UINT16 jis1;
UINT16 jis2;
} JISPAIR;
static const JISPAIR jis7883[] = {
{0x3646, 0x7421}, /* : */ {0x4b6a, 0x7422}, /* : */
{0x4d5a, 0x7423}, /* y: */ {0x596a, 0x7424}, /* : */ };
static const JISPAIR jis8390[] = {
{0x724d, 0x3033}, /* : */ {0x7274, 0x3229}, /* : */
{0x695a, 0x3342}, /* y:a */ {0x5978, 0x3349}, /* :h */
{0x635e, 0x3376}, /* }: */ {0x5e75, 0x3443}, /* : */
{0x6b5d, 0x3452}, /* |: */ {0x7074, 0x375b}, /* :z */
{0x6268, 0x395c}, /* :{ */ {0x6922, 0x3c49}, /* A: */
{0x7057, 0x3f59}, /* :x */ {0x6c4d, 0x4128}, /* :G */
{0x5464, 0x445b}, /* : */ {0x626a, 0x4557}, /* :v */
{0x5b6d, 0x456e}, /* : */ {0x5e39, 0x4573}, /* : */
{0x6d6e, 0x4676}, /* : */ {0x6a24, 0x4768}, /* : */
{0x5b58, 0x4930}, /* w:O */ {0x5056, 0x4b79}, /* : */
{0x692e, 0x4c79}, /* M: */ {0x6446, 0x4f36}, /* :U */ };
static UINT16 cnvjis(UINT16 jis, const JISPAIR *tbl, UINT tblsize) {
const JISPAIR *tblterm;
tblterm = (JISPAIR *)(((BYTE *)tbl) + tblsize);
while(tbl < tblterm) {
if (jis == tbl->jis1) {
return(tbl->jis2);
}
else if (jis == tbl->jis2) {
return(tbl->jis1);
}
tbl++;
}
return(jis);
}
UINT16 jiscnv7890(UINT16 jis) {
jis = cnvjis(jis, jis7883, sizeof(jis7883));
jis = cnvjis(jis, jis8390, sizeof(jis8390));
return(jis);
}
UINT16 jiscnv8390(UINT16 jis) {
return(cnvjis(jis, jis8390, sizeof(jis8390)));
}
RetroPC.NET-CVS <cvs@retropc.net>