--- np2/font/font.c 2003/10/18 01:21:58 1.2 +++ np2/font/font.c 2011/02/23 10:11:44 1.10 @@ -1,31 +1,50 @@ +/** + * @file font.c + * @brief CGROM and font loader + * + * @author $Author: yui $ + * @date $Date: 2011/02/23 10:11:44 $ + */ + #include "compiler.h" #include "strres.h" #include "dosio.h" -#include "memory.h" +#include "cpucore.h" #include "font.h" #include "fontdata.h" #include "fontmake.h" - #ifndef FONTMEMORYBIND - BYTE __font[0x84000]; + UINT8 __font[0x84000]; #endif -static const char fonttmpname[] = "font.tmp"; +static const OEMCHAR fonttmpname[] = OEMTEXT("font.tmp"); +/** + * Initializes CGROM + */ +void font_initialize(void) { + + ZeroMemory(fontrom, sizeof(fontrom)); + font_setchargraph(FALSE); +} -void font_init(void) { +/** + * Builds charactor graphics + * @param[in] epson If this parameter is FALSE, patched NEC charactor + */ +void font_setchargraph(BOOL epson) { - BYTE *p; - BYTE *q; + UINT8 *p; + UINT8 *q; UINT i; UINT j; UINT32 dbit; - ZeroMemory(font, sizeof(font)); - p = font + 0x81000; - q = font + 0x82800; + p = fontrom + 0x81000; + q = fontrom + 0x82000; for (i=0; i<256; i++) { + q += 8; for (j=0; j<4; j++) { dbit = 0; if (i & (0x01 << j)) { @@ -40,17 +59,27 @@ void font_init(void) { q += 2; } } + + if (!epson) { + *(UINT16 *)(fontrom + 0x81000 + (0xf2 * 16)) = 0; + fontrom[0x82000 + (0xf2 * 8)] = 0; + } } -static BYTE fonttypecheck(const char *fname) { +/** + * Retrieves the font type of the specified file. + * @param[in] fname The name of the font file + * @return font type + */ +static UINT8 fonttypecheck(const OEMCHAR *fname) { -const char *p; +const OEMCHAR *p; - p = file_getext((char *)fname); + p = file_getext(fname); if (!file_cmpname(p, str_bmp)) { return(FONTTYPE_PC98); } - p = file_getname((char *)fname); + p = file_getname(fname); if (!file_cmpname(p, v98fontname)) { return(FONTTYPE_V98); } @@ -74,18 +103,25 @@ const char *p; return(FONTTYPE_NONE); } -BYTE font_load(const char *filename, BOOL force) { +/** + * Loads font files + * @param[in] filename The name of the font file + * @param[in] force If this parameter is TRUE, load file always + * If this parameter is FALSE, load when font is not ready + * @return font type + */ +UINT8 font_load(const OEMCHAR *filename, BOOL force) { UINT i; - BYTE *q; -const BYTE *p; +const UINT8 *p; + UINT8 *q; UINT j; - char fname[MAX_PATH]; - BYTE type; - BYTE loading; + OEMCHAR fname[MAX_PATH]; + UINT8 type; + UINT8 loading; if (filename) { - file_cpyname(fname, filename, sizeof(fname)); + file_cpyname(fname, filename, NELEMENTS(fname)); } else { fname[0] = '\0'; @@ -97,15 +133,15 @@ const BYTE *p; // 外字: font[??560-??57f], font[??d60-??d7f] は削らないように… for (i=0; i<0x80; i++) { - q = font + (i << 12); + q = fontrom + (i << 12); ZeroMemory(q + 0x000, 0x0560 - 0x000); ZeroMemory(q + 0x580, 0x0d60 - 0x580); ZeroMemory(q + 0xd80, 0x1000 - 0xd80); } - CopyMemory(font + 0x82000, fontdata_8, 0x800); + fontdata_ank8store(fontdata_8, 0, 256); p = fontdata_8; - q = font + 0x80000; + q = fontrom + 0x80000; for (i=0; i<256; i++) { for (j=0; j<8; j++) { q[0] = p[0]; @@ -145,12 +181,11 @@ const BYTE *p; loading = fontv98_read(file_getcd(v98fontname), loading); loading = fontpc88_read(file_getcd(pc88ankname), loading); if (loading & FONTLOAD_16) { - file_cpyname(fname, file_getcd(fonttmpname), sizeof(fname)); - if (file_attr_c(fname) == -1) { + file_cpyname(fname, file_getcd(fonttmpname), NELEMENTS(fname)); + if (file_attr(fname) == -1) { makepc98bmp(fname); } loading = fontpc98_read(fname, loading); } return(type); } -