--- np2/win9x/ini.cpp 2003/10/28 22:05:46 1.6 +++ np2/win9x/ini.cpp 2005/03/16 06:05:18 1.35 @@ -2,24 +2,75 @@ #include #include #include "strres.h" +#include "profile.h" #include "np2.h" #include "np2arg.h" +#if defined(OSLANG_UCS2) +#include "oemtext.h" +#endif #include "dosio.h" #include "ini.h" #include "winkbd.h" #include "pccore.h" -static void inirdarg8(const char *src, const INITBL *ini) { - BYTE *dst; +static BOOL inigetbmp(const UINT8 *ptr, UINT pos) { + + return((ptr[pos >> 3] >> (pos & 7)) & 1); +} + +static void inisetbmp(UINT8 *ptr, UINT pos, BOOL set) { + + UINT8 bit; + + ptr += (pos >> 3); + bit = 1 << (pos & 7); + if (set) { + *ptr |= bit; + } + else { + *ptr &= ~bit; + } +} + +static void inirdargs16(const OEMCHAR *src, const INITBL *ini) { + + SINT16 *dst; int dsize; int i; - BYTE val; + OEMCHAR c; + + dst = (SINT16 *)ini->value; + dsize = ini->arg; + + for (i=0; ivalue; + dst = (UINT8 *)ini->value; dsize = ini->arg; for (i=0; ivalue; + ptr = (UINT8 *)ini->value; arg = ini->arg; if (arg > 0) { - SPRINTF(tmp, "%.2x", ptr[0]); + OEMSPRINTF(tmp, OEMTEXT("%.2x"), ptr[0]); milstr_ncpy(work, tmp, size); } for (i=1; ivalue)[i] = src[i]; + ((UINT8 *)ini->value)[i] = (UINT8)src[i]; } } } -static void inirdkb(const char *src, const INITBL *ini) { +static void inirdkb(const OEMCHAR *src, const INITBL *ini) { - if ((!milstr_extendcmp(src, "PC98")) || - (!milstr_cmp(src, "98"))) { - *(BYTE *)ini->value = KEY_PC98; - } - else if ((!milstr_extendcmp(src, "DOS")) || - (!milstr_cmp(src, "PCAT")) || - (!milstr_cmp(src, "AT"))) { - *(BYTE *)ini->value = KEY_KEY106; - } - else if ((!milstr_extendcmp(src, "KEY101")) || - (!milstr_cmp(src, "101"))) { - *(BYTE *)ini->value = KEY_KEY101; + if ((!milstr_extendcmp(src, OEMTEXT("PC98"))) || + (!milstr_cmp(src, OEMTEXT("98")))) { + *(UINT8 *)ini->value = KEY_PC98; + } + else if ((!milstr_extendcmp(src, OEMTEXT("DOS"))) || + (!milstr_cmp(src, OEMTEXT("PCAT"))) || + (!milstr_cmp(src, OEMTEXT("AT")))) { + *(UINT8 *)ini->value = KEY_KEY106; + } + else if ((!milstr_extendcmp(src, OEMTEXT("KEY101"))) || + (!milstr_cmp(src, OEMTEXT("101")))) { + *(UINT8 *)ini->value = KEY_KEY101; } } // ---- -void ini_read(const char *path, const char *title, +void ini_read(const OEMCHAR *path, const OEMCHAR *title, const INITBL *tbl, UINT count) { const INITBL *p; const INITBL *pterm; - char work[512]; +#if defined(OSLANG_UCS2) + OEMCHAR item[10]; +#else +const OEMCHAR *item; +#endif + OEMCHAR work[512]; UINT32 val; p = tbl; pterm = tbl + count; while(p < pterm) { +#if defined(OSLANG_UCS2) + oemtext_sjistooem(item, NELEMENTS(item), p->item, (UINT)-1); +#else + item = p->item; +#endif switch(p->itemtype & INITYPE_MASK) { case INITYPE_STR: - GetPrivateProfileString(title, p->item, (char *)p->value, - (char *)p->value, p->arg, path); + GetPrivateProfileString(title, item, (OEMCHAR *)p->value, + (OEMCHAR *)p->value, p->arg, path); break; case INITYPE_BOOL: - GetPrivateProfileString(title, p->item, - (*((BYTE *)p->value))?str_true:str_false, - work, sizeof(work), path); - *((BYTE *)p->value) = (!milstr_cmp(work, str_true))?1:0; - break; - - case INITYPE_BYTEARG: - GetPrivateProfileString(title, p->item, str_null, - work, sizeof(work), path); - inirdarg8(work, p); + GetPrivateProfileString(title, item, + (*((UINT8 *)p->value))?str_true:str_false, + work, NELEMENTS(work), path); + *((UINT8 *)p->value) = (!milstr_cmp(work, str_true))?1:0; + break; + + case INITYPE_BITMAP: + GetPrivateProfileString(title, item, + (inigetbmp((UINT8 *)p->value, p->arg))?str_true:str_false, + work, NELEMENTS(work), path); + inisetbmp((UINT8 *)p->value, p->arg, + (milstr_cmp(work, str_true) == 0)); + break; + + case INITYPE_ARGS16: + GetPrivateProfileString(title, item, str_null, + work, NELEMENTS(work), path); + inirdargs16(work, p); + break; + + case INITYPE_ARGH8: + GetPrivateProfileString(title, item, str_null, + work, NELEMENTS(work), path); + inirdargh8(work, p); break; case INITYPE_SINT8: case INITYPE_UINT8: - val = (BYTE)GetPrivateProfileInt(title, p->item, - *(BYTE *)p->value, path); - *(BYTE *)p->value = (BYTE)val; + val = (UINT8)GetPrivateProfileInt(title, item, + *(UINT8 *)p->value, path); + *(UINT8 *)p->value = (UINT8)val; break; case INITYPE_SINT16: case INITYPE_UINT16: - val = (UINT16)GetPrivateProfileInt(title, p->item, + val = (UINT16)GetPrivateProfileInt(title, item, *(UINT16 *)p->value, path); *(UINT16 *)p->value = (UINT16)val; break; case INITYPE_SINT32: case INITYPE_UINT32: - val = (UINT32)GetPrivateProfileInt(title, p->item, + val = (UINT32)GetPrivateProfileInt(title, item, *(UINT32 *)p->value, path); *(UINT32 *)p->value = (UINT32)val; break; case INITYPE_HEX8: - SPRINTF(work, str_x, *(BYTE *)p->value), - GetPrivateProfileString(title, p->item, work, - work, sizeof(work), path); - val = (BYTE)milstr_solveHEX(work); - *(BYTE *)p->value = (BYTE)val; + OEMSPRINTF(work, str_x, *(UINT8 *)p->value), + GetPrivateProfileString(title, item, work, + work, NELEMENTS(work), path); + val = (UINT8)milstr_solveHEX(work); + *(UINT8 *)p->value = (UINT8)val; break; case INITYPE_HEX16: - SPRINTF(work, str_x, *(UINT16 *)p->value), - GetPrivateProfileString(title, p->item, work, - work, sizeof(work), path); + OEMSPRINTF(work, str_x, *(UINT16 *)p->value), + GetPrivateProfileString(title, item, work, + work, NELEMENTS(work), path); val = (UINT16)milstr_solveHEX(work); *(UINT16 *)p->value = (UINT16)val; break; case INITYPE_HEX32: - SPRINTF(work, str_x, *(UINT32 *)p->value), - GetPrivateProfileString(title, p->item, work, - work, sizeof(work), path); + OEMSPRINTF(work, str_x, *(UINT32 *)p->value), + GetPrivateProfileString(title, item, work, + work, NELEMENTS(work), path); val = (UINT32)milstr_solveHEX(work); - *(UINT16 *)p->value = (UINT32)val; + *(UINT32 *)p->value = (UINT32)val; break; case INITYPE_BYTE3: - GetPrivateProfileString(title, p->item, str_null, - work, sizeof(work), path); + GetPrivateProfileString(title, item, str_null, + work, NELEMENTS(work), path); inirdbyte3(work, p); break; case INITYPE_KB: - GetPrivateProfileString(title, p->item, str_null, - work, sizeof(work), path); + GetPrivateProfileString(title, item, str_null, + work, NELEMENTS(work), path); inirdkb(work, p); break; } @@ -203,13 +278,13 @@ const INITBL *pterm; } } -void ini_write(const char *path, const char *title, +void ini_write(const OEMCHAR *path, const OEMCHAR *title, const INITBL *tbl, UINT count) { const INITBL *p; const INITBL *pterm; -const char *set; - char work[512]; +const OEMCHAR *set; + OEMCHAR work[512]; p = tbl; pterm = tbl + count; @@ -219,51 +294,51 @@ const char *set; set = work; switch(p->itemtype & INITYPE_MASK) { case INITYPE_STR: - set = (char *)p->value; + set = (OEMCHAR *)p->value; break; case INITYPE_BOOL: - set = (*((BYTE *)p->value))?str_true:str_false; + set = (*((UINT8 *)p->value))?str_true:str_false; break; - case INITYPE_BYTEARG: - iniwrsetarg8(work, sizeof(work), p); + case INITYPE_ARGH8: + iniwrsetargh8(work, NELEMENTS(work), p); break; case INITYPE_SINT8: - SPRINTF(work, str_d, *((char *)p->value)); + OEMSPRINTF(work, str_d, *((SINT8 *)p->value)); break; case INITYPE_SINT16: - SPRINTF(work, str_d, *((SINT16 *)p->value)); + OEMSPRINTF(work, str_d, *((SINT16 *)p->value)); break; case INITYPE_SINT32: - SPRINTF(work, str_d, *((SINT32 *)p->value)); + OEMSPRINTF(work, str_d, *((SINT32 *)p->value)); break; case INITYPE_UINT8: - SPRINTF(work, str_u, *((BYTE *)p->value)); + OEMSPRINTF(work, str_u, *((UINT8 *)p->value)); break; case INITYPE_UINT16: - SPRINTF(work, str_u, *((UINT16 *)p->value)); + OEMSPRINTF(work, str_u, *((UINT16 *)p->value)); break; case INITYPE_UINT32: - SPRINTF(work, str_u, *((UINT32 *)p->value)); + OEMSPRINTF(work, str_u, *((UINT32 *)p->value)); break; case INITYPE_HEX8: - SPRINTF(work, str_x, *((BYTE *)p->value)); + OEMSPRINTF(work, str_x, *((UINT8 *)p->value)); break; case INITYPE_HEX16: - SPRINTF(work, str_x, *((UINT16 *)p->value)); + OEMSPRINTF(work, str_x, *((UINT16 *)p->value)); break; case INITYPE_HEX32: - SPRINTF(work, str_x, *((UINT32 *)p->value)); + OEMSPRINTF(work, str_x, *((UINT32 *)p->value)); break; default: @@ -271,7 +346,13 @@ const char *set; break; } if (set) { +#if defined(OSLANG_UCS2) + OEMCHAR item[10]; + oemtext_sjis2oem(item, NELEMENTS(item), p->item, (UINT)-1); + WritePrivateProfileString(title, item, set, path); +#else WritePrivateProfileString(title, p->item, set, path); +#endif } } p++; @@ -281,12 +362,18 @@ const char *set; // ---- -static const char ini_title[] = "NekoProjectII"; +#if !defined(SUPPORT_PC9821) +static const OEMCHAR ini_title[] = OEMTEXT("NekoProjectII"); +#else +static const OEMCHAR ini_title[] = OEMTEXT("NekoProject21"); +#endif enum { INIRO_STR = INITYPE_STR + INIFLAG_RO, INIRO_BOOL = INITYPE_BOOL + INIFLAG_RO, - INIMAX_UINT8 = INITYPE_UINT8 + INIFLAG_RO, + INIRO_BITMAP = INITYPE_BITMAP + INIFLAG_RO, + INIRO_UINT8 = INITYPE_UINT8 + INIFLAG_RO, + INIMAX_UINT8 = INITYPE_UINT8 + INIFLAG_MAX, INIAND_UINT8 = INITYPE_UINT8 + INIFLAG_AND, INIROMAX_SINT32 = INITYPE_SINT32 + INIFLAG_RO + INIFLAG_MAX, INIROAND_HEX32 = INITYPE_HEX32 + INIFLAG_RO + INIFLAG_AND, @@ -297,7 +384,7 @@ enum { static const INITBL iniitem[] = { {"np2title", INIRO_STR, np2oscfg.titles, - sizeof(np2oscfg.titles)}, + NELEMENTS(np2oscfg.titles)}, {"np2winid", INIRO_BYTE3, np2oscfg.winid, 0}, {"WindposX", INITYPE_SINT32, &np2oscfg.winx, 0}, {"WindposY", INITYPE_SINT32, &np2oscfg.winy, 0}, @@ -309,18 +396,28 @@ static const INITBL iniitem[] = { {"HDfolder", INITYPE_STR, hddfolder, MAX_PATH}, {"bmap_Dir", INITYPE_STR, bmpfilefolder, MAX_PATH}, {"fontfile", INITYPE_STR, np2cfg.fontfile, MAX_PATH}, + {"biospath", INIRO_STR, np2cfg.biospath, MAX_PATH}, + {"hdrvroot", INIRO_STR, np2cfg.hdrvroot, MAX_PATH}, + {"hdrv_acc", INIRO_UINT8, &np2cfg.hdrvacc, 0}, + {"pc_model", INITYPE_STR, &np2cfg.model, + NELEMENTS(np2cfg.model)}, {"clk_base", INITYPE_UINT32, &np2cfg.baseclock, 0}, {"clk_mult", INITYPE_UINT32, &np2cfg.multiple, 0}, - {"DIPswtch", INITYPE_BYTEARG, np2cfg.dipsw, 3}, - {"MEMswtch", INITYPE_BYTEARG, np2cfg.memsw, 8}, - {"ExMemory", INIMAX_UINT8, &np2cfg.EXTMEM, 13}, + {"DIPswtch", INITYPE_ARGH8, np2cfg.dipsw, 3}, + {"MEMswtch", INITYPE_ARGH8, np2cfg.memsw, 8}, + {"ExMemory", INIMAX_UINT8, &np2cfg.EXTMEM, 63}, {"ITF_WORK", INIRO_BOOL, &np2cfg.ITF_WORK, 0}, - {"HDD1FILE", INITYPE_STR, np2cfg.hddfile[0], MAX_PATH}, - {"HDD2FILE", INITYPE_STR, np2cfg.hddfile[1], MAX_PATH}, -// {"Removabl", INI_EX|1, 0, &np2cfg.REMOVEHD, 0}, + {"HDD1FILE", INITYPE_STR, np2cfg.sasihdd[0], MAX_PATH}, + {"HDD2FILE", INITYPE_STR, np2cfg.sasihdd[1], MAX_PATH}, +#if defined(SUPPORT_SCSI) + {"SCSIHDD0", INITYPE_STR, np2cfg.scsihdd[0], MAX_PATH}, + {"SCSIHDD1", INITYPE_STR, np2cfg.scsihdd[1], MAX_PATH}, + {"SCSIHDD2", INITYPE_STR, np2cfg.scsihdd[2], MAX_PATH}, + {"SCSIHDD3", INITYPE_STR, np2cfg.scsihdd[3], MAX_PATH}, +#endif {"SampleHz", INITYPE_UINT16, &np2cfg.samplingrate, 0}, {"Latencys", INITYPE_UINT16, &np2cfg.delayms, 0}, @@ -328,15 +425,15 @@ static const INITBL iniitem[] = { {"BEEP_vol", INIAND_UINT8, &np2cfg.BEEP_VOL, 3}, {"xspeaker", INIRO_BOOL, &np2cfg.snd_x, 0}, - {"SND14vol", INITYPE_BYTEARG, np2cfg.vol14, 6}, -// {"opt14BRD", INITYPE_BYTEARG, np2cfg.snd14opt, 3}, + {"SND14vol", INITYPE_ARGH8, np2cfg.vol14, 6}, +// {"opt14BRD", INITYPE_ARGH8, np2cfg.snd14opt, 3}, {"opt26BRD", INITYPE_HEX8, &np2cfg.snd26opt, 0}, {"opt86BRD", INITYPE_HEX8, &np2cfg.snd86opt, 0}, {"optSPBRD", INITYPE_HEX8, &np2cfg.spbopt, 0}, {"optSPBVR", INITYPE_HEX8, &np2cfg.spb_vrc, 0}, {"optSPBVL", INIMAX_UINT8, &np2cfg.spb_vrl, 24}, {"optSPB_X", INITYPE_BOOL, &np2cfg.spb_x, 0}, - {"optMPU98", INITYPE_HEX8 &np2cfg.mpuopt, 0}, + {"optMPU98", INITYPE_HEX8, &np2cfg.mpuopt, 0}, {"volume_F", INIMAX_UINT8, &np2cfg.vol_fm, 128}, {"volume_S", INIMAX_UINT8, &np2cfg.vol_ssg, 128}, @@ -353,7 +450,7 @@ static const INITBL iniitem[] = { {"MS_RAPID", INITYPE_BOOL, &np2cfg.MOUSERAPID, 0}, {"backgrnd", INIAND_UINT8, &np2oscfg.background, 3}, - {"VRAMwait", INITYPE_BYTEARG, np2cfg.wait, 6}, + {"VRAMwait", INITYPE_ARGH8, np2cfg.wait, 6}, {"DspClock", INIAND_UINT8, &np2oscfg.DISPCLK, 3}, {"DispSync", INITYPE_BOOL, &np2cfg.DISPSYNC, 0}, {"Real_Pal", INITYPE_BOOL, &np2cfg.RASTER, 0}, @@ -364,23 +461,28 @@ static const INITBL iniitem[] = { {"GRCG_EGC", INIAND_UINT8, &np2cfg.grcg, 3}, {"color16b", INITYPE_BOOL, &np2cfg.color16, 0}, {"skipline", INITYPE_BOOL, &np2cfg.skipline, 0}, - {"skplight", INITYPE_UINT16 &np2cfg.skiplight, 0}, + {"skplight", INITYPE_UINT16, &np2cfg.skiplight, 0}, {"LCD_MODE", INIAND_UINT8, &np2cfg.LCD_MODE, 0x03}, {"BG_COLOR", INIROAND_HEX32, &np2cfg.BG_COLOR, 0xffffff}, {"FG_COLOR", INIROAND_HEX32, &np2cfg.FG_COLOR, 0xffffff}, {"pc9861_e", INITYPE_BOOL, &np2cfg.pc9861enable, 0}, - {"pc9861_s", INITYPE_BYTEARG, np2cfg.pc9861sw, 3}, - {"pc9861_j", INITYPE_BYTEARG, np2cfg.pc9861jmp, 6}, + {"pc9861_s", INITYPE_ARGH8, np2cfg.pc9861sw, 3}, + {"pc9861_j", INITYPE_ARGH8, np2cfg.pc9861jmp, 6}, {"calendar", INITYPE_BOOL, &np2cfg.calendar, 0}, {"USE144FD", INITYPE_BOOL, &np2cfg.usefd144, 0}, + {"FDDRIVE1", INIRO_BITMAP, &np2cfg.fddequip, 0}, + {"FDDRIVE2", INIRO_BITMAP, &np2cfg.fddequip, 1}, + {"FDDRIVE3", INIRO_BITMAP, &np2cfg.fddequip, 2}, + {"FDDRIVE4", INIRO_BITMAP, &np2cfg.fddequip, 3}, + // OS°Í¸¡© {"keyboard", INIRO_KB, &np2oscfg.KEYBOARD, 0}, {"F12_COPY", INITYPE_UINT8, &np2oscfg.F12COPY, 0}, {"Joystick", INITYPE_BOOL, &np2oscfg.JOYPAD1, 0}, - {"Joy1_btn", INITYPE_BYTEARG, np2oscfg.JOY1BTN, 4}, + {"Joy1_btn", INITYPE_ARGH8, np2oscfg.JOY1BTN, 4}, {"clocknow", INITYPE_UINT8, &np2oscfg.clk_x, 0}, {"clockfnt", INITYPE_UINT8, &np2oscfg.clk_fnt, 0}, @@ -418,51 +520,58 @@ static const INITBL iniitem[] = { {"com3mmdl", INITYPE_STR, np2oscfg.com3.mdl, 64}, {"com3mdef", INITYPE_STR, np2oscfg.com3.def, MAX_PATH}, - {"force400", INITYPE_BOOL, &np2oscfg.force400, 0}, + {"force400", INIRO_BOOL, &np2oscfg.force400, 0}, {"e_resume", INITYPE_BOOL, &np2oscfg.resume, 0}, {"STATSAVE", INIRO_BOOL, &np2oscfg.statsave, 0}, {"nousemmx", INITYPE_BOOL, &np2oscfg.disablemmx, 0}, // ver0.36 + {"windtype", INITYPE_UINT8, &np2oscfg.wintype, 0}, {"toolwind", INITYPE_BOOL, &np2oscfg.toolwin, 0}, // ver0.38 + {"keydispl", INITYPE_BOOL, &np2oscfg.keydisp, 0}, + {"jast_snd", INITYPE_BOOL, &np2oscfg.jastsnd, 0}, // ver0.73 + {"useromeo", INITYPE_BOOL, &np2oscfg.useromeo, 0}, // ver0.74 + {"thickfrm", INITYPE_BOOL, &np2oscfg.thickframe, 0}, // ver0.77 + {"xrollkey", INIRO_BOOL, &np2oscfg.xrollkey, 0}, // ver0.78 + {"fscrnbpp", INIRO_UINT8, &np2oscfg.fscrnbpp, 0}, {"I286SAVE", INIRO_BOOL, &np2oscfg.I286SAVE, 0}}; -static void getinifile(char *initfile, int max) { +void initgetfile(OEMCHAR *path, UINT size) { - char *p; +const OEMCHAR *ext; - milstr_ncpy(initfile, modulefile, max); + file_cpyname(path, modulefile, size); if (np2arg.ini) { if ((np2arg.ini[0] == '/') || (np2arg.ini[0] == '-')) { - file_cutname(initfile); - milstr_ncat(initfile, file_getname(np2arg.ini + 2), max); + file_cutname(path); + file_catname(path, file_getname(np2arg.ini + 2), size); } else { - milstr_ncpy(initfile, np2arg.ini, max); + file_cpyname(path, np2arg.ini, size); } - p = file_getext(initfile); - if (!(*p)) { - milstr_ncat(initfile, ".ini", max); + ext = file_getext(path); + if (ext[0] != '\0') { + file_catname(path, OEMTEXT(".ini"), size); } } else { - file_cutext(initfile); - milstr_ncat(initfile, ".ini", max); + file_cutext(path); + file_catname(path, OEMTEXT(".ini"), size); } } void initload(void) { - char path[MAX_PATH]; + OEMCHAR path[MAX_PATH]; - getinifile(path, sizeof(path)); - ini_read(path, ini_title, iniitem, sizeof(iniitem)/sizeof(INITBL)); + initgetfile(path, NELEMENTS(path)); + ini_read(path, ini_title, iniitem, NELEMENTS(iniitem)); } void initsave(void) { - char path[MAX_PATH]; + OEMCHAR path[MAX_PATH]; - getinifile(path, sizeof(path)); - ini_write(path, ini_title, iniitem, sizeof(iniitem)/sizeof(INITBL)); + initgetfile(path, NELEMENTS(path)); + ini_write(path, ini_title, iniitem, NELEMENTS(iniitem)); }