libretro-meowPC98/font/fontv98.c

97 lines
1.9 KiB
C
Raw Normal View History

2016-03-06 11:11:17 +00:00
#include "compiler.h"
#include "dosio.h"
#include "cpucore.h"
#include "font.h"
#include "fontdata.h"
#define V98FILESIZE 0x46800
static void v98knjcpy(UINT8 *dst, const UINT8 *src, int from, int to) {
int i, j, k;
const UINT8 *p;
UINT8 *q;
for (i=from; i<to; i++) {
p = src + 0x1800 + (0x60 * 32 * (i - 1));
q = dst + 0x20000 + (i << 4);
for (j=0x20; j<0x80; j++) {
for (k=0; k<16; k++) {
*(q + 0x800) = *(p+16);
*q++ = *p++;
}
p += 16;
q += 0x1000 - 16;
}
}
}
UINT8 fontv98_read(const OEMCHAR *filename, UINT8 loading) {
FILEH fh;
UINT8 *v98fnt;
if (!(loading & FONTLOAD_ALL)) {
goto frv_err1;
}
// <20>t<EFBFBD>@<40>C<EFBFBD><43><EFBFBD><EFBFBD><EFBFBD>I<EFBFBD>[<5B>v<EFBFBD><76>
fh = file_open_rb(filename);
if (fh == FILEH_INVALID) {
goto frv_err1;
}
v98fnt = (UINT8 *)_MALLOC(V98FILESIZE, "v98font");
if (v98fnt == NULL) {
goto frv_err2;
}
// FONT.ROM <20>̓ǂݍ<C782><DD8D><EFBFBD>
if (file_read(fh, v98fnt, V98FILESIZE) != V98FILESIZE) {
goto frv_err3;
}
// 8x8 <20>t<EFBFBD>H<EFBFBD><48><EFBFBD>g<EFBFBD><67><EFBFBD>ǂޕK<DE95>v<EFBFBD><76><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>H
if (loading & FONT_ANK8) {
loading &= ~FONT_ANK8;
fontdata_ank8store(v98fnt, 0, 256);
}
// 8x16 <20>t<EFBFBD>H<EFBFBD><48><EFBFBD>g(<28>`0x7f)<29><><EFBFBD>ǂޕK<DE95>v<EFBFBD><76><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>H
if (loading & FONT_ANK16a) {
loading &= ~FONT_ANK16a;
CopyMemory(fontrom + 0x80000, v98fnt + 0x0800, 16*128);
}
// 8x16 <20>t<EFBFBD>H<EFBFBD><48><EFBFBD>g(0x80<38>`)<29><><EFBFBD>ǂޕK<DE95>v<EFBFBD><76><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>H
if (loading & FONT_ANK16b) {
loading &= ~FONT_ANK16b;
CopyMemory(fontrom + 0x80800, v98fnt + 0x1000, 16*128);
}
// <20><><EFBFBD><EFBFBD><EA9085><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǂޕK<DE95>v<EFBFBD><76><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>H
if (loading & FONT_KNJ1) {
loading &= ~FONT_KNJ1;
v98knjcpy(fontrom, v98fnt, 0x01, 0x30);
}
// <20><><EFBFBD>񐅏<EFBFBD><F190858F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǂޕK<DE95>v<EFBFBD><76><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>H
if (loading & FONT_KNJ2) {
loading &= ~FONT_KNJ2;
v98knjcpy(fontrom, v98fnt, 0x30, 0x56);
}
// <20>g<EFBFBD><67><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǂޕK<DE95>v<EFBFBD><76><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>H
if (loading & FONT_KNJ3) {
loading &= ~FONT_KNJ3;
v98knjcpy(fontrom, v98fnt, 0x58, 0x5d);
}
frv_err3:
_MFREE(v98fnt);
frv_err2:
file_close(fh); // <20><><EFBFBD>n<EFBFBD><6E>
frv_err1:
return(loading);
}