mirror of
https://github.com/libretro/libretro-meowPC98.git
synced 2024-11-27 02:20:32 +00:00
143 lines
2.9 KiB
C
143 lines
2.9 KiB
C
|
#include "compiler.h"
|
|||
|
#include "bmpdata.h"
|
|||
|
#include "dosio.h"
|
|||
|
#include "cpucore.h"
|
|||
|
#include "font.h"
|
|||
|
#include "fontdata.h"
|
|||
|
|
|||
|
|
|||
|
#define FONTYSIZE 16
|
|||
|
|
|||
|
#define BMPWIDTH 2048L
|
|||
|
#define BMPHEIGHT 2048L
|
|||
|
|
|||
|
#define BMPLINESIZE (BMPWIDTH / 8) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><D882><EFBFBD>^^;
|
|||
|
|
|||
|
#define BMPDATASIZE (BMPLINESIZE * BMPHEIGHT)
|
|||
|
|
|||
|
|
|||
|
static void pc98ankcpy(UINT8 *dst, const UINT8 *src, int from, int to) {
|
|||
|
|
|||
|
int y;
|
|||
|
const UINT8 *p;
|
|||
|
int ank;
|
|||
|
|
|||
|
for (ank=from; ank<to; ank++) {
|
|||
|
|
|||
|
// ANK<4E>t<EFBFBD>H<EFBFBD><48><EFBFBD>g<EFBFBD>̃X<CC83>^<5E>[<5B>g<EFBFBD>ʒu
|
|||
|
p = src + BMPDATASIZE + ank + (0 * FONTYSIZE * BMPLINESIZE);
|
|||
|
for (y=0; y<FONTYSIZE; y++) {
|
|||
|
p -= BMPLINESIZE; // BMP<4D>Ȃ̂Ń|<7C>C<EFBFBD><43><EFBFBD>^<5E>͈<EFBFBD><CD88><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*dst++ = ~(*p);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
static void pc98knjcpy(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 + BMPDATASIZE + (i << 1) - (FONTYSIZE * BMPLINESIZE);
|
|||
|
q = dst + 0x1000 + (i << 4);
|
|||
|
for (j=1; j<0x80; j++) {
|
|||
|
for (k=0; k<16; k++) {
|
|||
|
p -= BMPLINESIZE;
|
|||
|
*(q + 0x800) = ~(*(p+1));
|
|||
|
*q++ = ~(*p);
|
|||
|
}
|
|||
|
q += 0x1000 - 16;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
UINT8 fontpc98_read(const OEMCHAR *filename, UINT8 loading) {
|
|||
|
|
|||
|
FILEH fh;
|
|||
|
BMPFILE bf;
|
|||
|
BMPINFO bi;
|
|||
|
UINT8 *bmpdata;
|
|||
|
BMPDATA bd;
|
|||
|
long fptr;
|
|||
|
|
|||
|
if (!(loading & FONTLOAD_16)) {
|
|||
|
goto fr98_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 fr98_err1;
|
|||
|
}
|
|||
|
|
|||
|
// BITMAPFILEHEADER <20>̓ǂݍ<C782><DD8D><EFBFBD>
|
|||
|
if ((file_read(fh, &bf, sizeof(bf)) != sizeof(bf)) ||
|
|||
|
(bf.bfType[0] != 'B') || (bf.bfType[1] != 'M')) {
|
|||
|
goto fr98_err2;
|
|||
|
}
|
|||
|
|
|||
|
// BITMAPINFOHEADER <20>̓ǂݍ<C782><DD8D><EFBFBD>
|
|||
|
if ((file_read(fh, &bi, sizeof(bi)) != sizeof(bi)) ||
|
|||
|
(bmpdata_getinfo(&bi, &bd) != SUCCESS) ||
|
|||
|
(bd.width != BMPWIDTH) || (bd.height != BMPHEIGHT) || (bd.bpp != 1) ||
|
|||
|
(LOADINTELDWORD(bi.biSizeImage) != BMPDATASIZE)) {
|
|||
|
goto fr98_err2;
|
|||
|
}
|
|||
|
|
|||
|
// BITMAP<41>f<EFBFBD>[<5B>^<5E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
fptr = LOADINTELDWORD(bf.bfOffBits);
|
|||
|
if (file_seek(fh, fptr, FSEEK_SET) != fptr) {
|
|||
|
goto fr98_err2;
|
|||
|
}
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>A<EFBFBD><41><EFBFBD>P<EFBFBD>[<5B>g
|
|||
|
bmpdata = (UINT8 *)_MALLOC(BMPDATASIZE, "pc98font");
|
|||
|
if (bmpdata == NULL) {
|
|||
|
goto fr98_err2;
|
|||
|
}
|
|||
|
|
|||
|
// BITMAP<41>f<EFBFBD>[<5B>^<5E>̓ǂ݂<C782><DD82><EFBFBD>
|
|||
|
if (file_read(fh, bmpdata, BMPDATASIZE) != BMPDATASIZE) {
|
|||
|
goto fr98_err3;
|
|||
|
}
|
|||
|
|
|||
|
// 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;
|
|||
|
pc98ankcpy(fontrom + 0x80000, bmpdata, 0x000, 0x080);
|
|||
|
}
|
|||
|
// 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;
|
|||
|
pc98ankcpy(fontrom + 0x80800, bmpdata, 0x080, 0x100);
|
|||
|
}
|
|||
|
|
|||
|
// <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;
|
|||
|
pc98knjcpy(fontrom, bmpdata, 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;
|
|||
|
pc98knjcpy(fontrom, bmpdata, 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;
|
|||
|
pc98knjcpy(fontrom, bmpdata, 0x58, 0x60);
|
|||
|
}
|
|||
|
|
|||
|
fr98_err3:
|
|||
|
_MFREE(bmpdata);
|
|||
|
|
|||
|
fr98_err2:
|
|||
|
file_close(fh);
|
|||
|
|
|||
|
fr98_err1:
|
|||
|
return(loading);
|
|||
|
}
|
|||
|
|