--- np2/win9x/ini.cpp 2003/10/16 17:58:53 1.1 +++ np2/win9x/ini.cpp 2004/02/03 08:24:40 1.22 @@ -1,466 +1,516 @@ #include "compiler.h" #include #include +#include "strres.h" #include "np2.h" -#include "dosio.h" #include "np2arg.h" -#include "pccore.h" -#include "iocore.h" +#include "dosio.h" #include "ini.h" #include "winkbd.h" +#include "pccore.h" -#define CFGLEN (MAX_PATH + 32) +static void inirdargs16(const char *src, const INITBL *ini) { -static const char ini_title[] = "NekoProjectII"; + SINT16 *dst; + int dsize; + int i; + char c; + + dst = (SINT16 *)ini->value; + dsize = ini->arg; -typedef struct { - char item[9]; - BYTE itemtype; - WORD flag; - void *value; - DWORD arg; -} INI_ITEM; - -#define INI_RO 0x0001 -#define INIAND 0x0002 -#define INIMAX 0x0004 -#define INIA4 0x0008 -#define INIEND 0x8000 - -#define INI_STR 0x00 -#define INI_BOOL 0x01 -#define INI_ARG 0x02 -#define INI_BYTE 0x11 -#define INI_WORD 0x12 -#define INI_DWORD 0x14 -#define INI_HEXB 0x21 -#define INI_HEXD 0x24 -#define INI_EX 0x80 - - -static INI_ITEM iniitem[] = { - - {"np2title", INI_STR, INI_RO|INIMAX, - np2oscfg.titles, sizeof(np2oscfg.titles)}, - {"np2winid", INI_EX|0, INI_RO, np2oscfg.winid, 0}, - - {"WindposX", INI_DWORD, 0, &np2oscfg.winx, 0}, - {"WindposY", INI_DWORD, 0, &np2oscfg.winy, 0}, - {"paddingx", INI_DWORD, INI_RO|INIMAX, - &np2oscfg.paddingx, 32}, - {"paddingy", INI_DWORD, INI_RO|INIMAX, - &np2oscfg.paddingy, 32}, - {"Win_Snap", INI_BOOL, 0, &np2oscfg.WINSNAP, 0}, - - {"FDfolder", INI_STR, INIMAX, fddfolder, MAX_PATH}, - {"HDfolder", INI_STR, INIMAX, hddfolder, MAX_PATH}, - {"bmap_Dir", INI_STR, INIMAX, bmpfilefolder, MAX_PATH}, - - {"fontfile", INI_STR, INIMAX, np2cfg.fontfile, MAX_PATH}, - - {"clk_base", INI_DWORD, 0, &np2cfg.baseclock, 0}, - {"clk_mult", INI_DWORD, 0, &np2cfg.multiple, 0}, - - {"DIPswtch", INI_ARG, 0, np2cfg.dipsw, 3}, - {"MEMswtch", INI_ARG, 0, np2cfg.memsw, 8}, - {"ExMemory", INI_BYTE, INIMAX, &np2cfg.EXTMEM, 13}, - {"ITF_WORK", INI_BOOL, INI_RO, &np2cfg.ITF_WORK, 0}, - - {"HDD1FILE", INI_STR, INIMAX, np2cfg.hddfile[0], MAX_PATH}, - {"HDD2FILE", INI_STR, INIMAX, np2cfg.hddfile[1], MAX_PATH}, -// {"Removabl", INI_EX|1, 0, &np2cfg.REMOVEHD, 0}, - - {"SampleHz", INI_WORD, 0, &np2cfg.samplingrate, 0}, - {"Latencys", INI_WORD, 0, &np2cfg.delayms, 0}, - {"SNDboard", INI_HEXB, 0, &np2cfg.SOUND_SW, 0}, - {"BEEP_vol", INI_BYTE, INIAND, &np2cfg.BEEP_VOL, 0x03}, - {"xspeaker", INI_BOOL, INI_RO, &np2cfg.snd_x, 0}, - - {"SND14vol", INI_ARG, INIA4, np2cfg.vol14, 6}, // ver0.27 -// {"opt14BRD", INI_ARG, 0, np2cfg.snd14opt, 3}, - {"opt26BRD", INI_HEXB, 0, &np2cfg.snd26opt, 0}, - {"opt86BRD", INI_HEXB, 0, &np2cfg.snd86opt, 0}, - {"optSPBRD", INI_HEXB, 0, &np2cfg.spbopt, 0}, - {"optSPBVR", INI_HEXB, 0, &np2cfg.spb_vrc, 0}, // ver0.30 - {"optSPBVL", INI_BYTE, INIMAX, &np2cfg.spb_vrl, 24}, // ver0.30 - {"optSPB_X", INI_BOOL, 0, &np2cfg.spb_x, 0}, - {"optMPU98", INI_HEXB, 0, &np2cfg.mpuopt, 0}, - - {"volume_F", INI_BYTE, INIMAX, &np2cfg.vol_fm, 128}, // ver0.28 - {"volume_S", INI_BYTE, INIMAX, &np2cfg.vol_ssg, 128}, - {"volume_A", INI_BYTE, INIMAX, &np2cfg.vol_adpcm, 128}, - {"volume_P", INI_BYTE, INIMAX, &np2cfg.vol_pcm, 128}, - {"volume_R", INI_BYTE, INIMAX, &np2cfg.vol_rhythm, 128}, - - {"Seek_Snd", INI_BOOL, 0, &np2cfg.MOTOR, 0}, - {"Seek_Vol", INI_BYTE, INIMAX, &np2cfg.MOTORVOL, 100}, - - {"btnRAPID", INI_BOOL, 0, &np2cfg.BTN_RAPID, 0}, - {"btn_MODE", INI_BOOL, 0, &np2cfg.BTN_MODE, 0}, - {"Mouse_sw", INI_BOOL, 0, &np2oscfg.MOUSE_SW, 0}, - {"MS_RAPID", INI_BOOL, 0, &np2cfg.MOUSERAPID, 0}, - - {"backgrnd", INI_BYTE, INIAND, &np2oscfg.background, 0x03}, - {"VRAMwait", INI_ARG, 0, np2cfg.wait, 6}, - {"DspClock", INI_BYTE, INIAND, &np2oscfg.DISPCLK, 0x03}, - {"DispSync", INI_BOOL, 0, &np2cfg.DISPSYNC, 0}, - {"Real_Pal", INI_BOOL, 0, &np2cfg.RASTER, 0}, - {"RPal_tim", INI_BYTE, INIMAX, &np2cfg.realpal, 64}, - {"s_NOWAIT", INI_BOOL, 0, &np2oscfg.NOWAIT, 0}, - {"SkpFrame", INI_BYTE, 0, &np2oscfg.DRAW_SKIP, 0}, - {"uPD72020", INI_BOOL, 0, &np2cfg.uPD72020, 0}, - {"GRCG_EGC", INI_BYTE, INIAND, &np2cfg.grcg, 0x03}, - {"color16b", INI_BOOL, 0, &np2cfg.color16, 0}, - {"skipline", INI_BOOL, 0, &np2cfg.skipline, 0}, - {"skplight", INI_WORD, 0, &np2cfg.skiplight, 0}, - {"LCD_MODE", INI_BYTE, INIAND, &np2cfg.LCD_MODE, 0x03}, - {"BG_COLOR", INI_HEXD, INI_RO|INIAND, - &np2cfg.BG_COLOR, 0xffffff}, - {"FG_COLOR", INI_HEXD, INI_RO|INIAND, - &np2cfg.FG_COLOR, 0xffffff}, - - {"pc9861_e", INI_BOOL, 0, &np2cfg.pc9861enable, 0}, // ver0.29 - {"pc9861_s", INI_ARG, 0, np2cfg.pc9861sw, 3}, - {"pc9861_j", INI_ARG, 0, np2cfg.pc9861jmp, 6}, - - {"calendar", INI_BOOL, 0, &np2cfg.calendar, 0}, // ver0.34 - {"USE144FD", INI_BOOL, 0, &np2cfg.usefd144, 0}, // ver0.31 - - // OS°Í¸¡© // ver0.29 - {"keyboard", INI_EX|3, INI_RO, &np2oscfg.KEYBOARD, 0}, - {"F12_COPY", INI_BYTE, 0, &np2oscfg.F12COPY, 0}, - {"Joystick", INI_BOOL, 0, &np2oscfg.JOYPAD1, 0}, // ver0.28 - {"Joy1_btn", INI_ARG, 0, np2oscfg.JOY1BTN, 4}, - - {"clocknow", INI_BYTE, 0, &np2oscfg.clk_x, 0}, - {"clockfnt", INI_BYTE, 0, &np2oscfg.clk_fnt, 0}, - {"clock_up", INI_HEXD, INI_RO|INIAND, - &np2oscfg.clk_color1, 0xffffff}, - {"clock_dn", INI_HEXD, INI_RO|INIAND, - &np2oscfg.clk_color2, 0xffffff}, - - {"use_sstp", INI_BOOL, 0, &np2oscfg.sstp, 0}, - {"sstpport", INI_WORD, 0, &np2oscfg.sstpport, 0}, - {"comfirm_", INI_BOOL, 0, &np2oscfg.comfirm, 0}, - {"shortcut", INI_HEXB, 0, &np2oscfg.shortcut, 0}, // ver0.30 - - - {"mpu98map", INI_STR, INIMAX, np2oscfg.mpu.mout, MAXPNAMELEN}, - {"mpu98min", INI_STR, INIMAX, np2oscfg.mpu.min, MAXPNAMELEN}, - {"mpu98mdl", INI_STR, INIMAX, np2oscfg.mpu.mdl, 64}, - {"mpu98def", INI_STR, INIMAX, np2oscfg.mpu.def, MAX_PATH}, - - {"com1port", INI_BYTE, INIMAX, &np2oscfg.com1.port, 5}, // ver0.34 - {"com1para", INI_BYTE, 0, &np2oscfg.com1.param, 0}, - {"com1_bps", INI_DWORD, 0, &np2oscfg.com1.speed, 0}, - {"com1mmap", INI_STR, INIMAX, np2oscfg.com1.mout, MAXPNAMELEN}, - {"com1mmdl", INI_STR, INIMAX, np2oscfg.com1.mdl, 64}, - {"com1mdef", INI_STR, INIMAX, np2oscfg.com1.def, MAX_PATH}, - - {"com2port", INI_BYTE, INIMAX, &np2oscfg.com2.port, 5}, // ver0.34 - {"com2para", INI_BYTE, 0, &np2oscfg.com2.param, 0}, - {"com2_bps", INI_DWORD, 0, &np2oscfg.com2.speed, 0}, - {"com2mmap", INI_STR, INIMAX, np2oscfg.com2.mout, MAXPNAMELEN}, - {"com2mmdl", INI_STR, INIMAX, np2oscfg.com2.mdl, 64}, - {"com2mdef", INI_STR, INIMAX, np2oscfg.com2.def, MAX_PATH}, - - {"com3port", INI_BYTE, INIMAX, &np2oscfg.com3.port, 5}, // ver0.34 - {"com3para", INI_BYTE, 0, &np2oscfg.com3.param, 0}, - {"com3_bps", INI_DWORD, 0, &np2oscfg.com3.speed, 0}, - {"com3mmap", INI_STR, INIMAX, np2oscfg.com3.mout, MAXPNAMELEN}, - {"com3mmdl", INI_STR, INIMAX, np2oscfg.com3.mdl, 64}, - {"com3mdef", INI_STR, INIMAX, np2oscfg.com3.def, MAX_PATH}, - - {"force400", INI_BOOL, INI_RO, &np2oscfg.force400, 0}, - {"e_resume", INI_BOOL, 0, &np2oscfg.resume, 0}, // ver0.30 - {"STATSAVE", INI_BOOL, INI_RO, &np2oscfg.statsave, 0}, // ver0.30 - - {"I286SAVE", INI_BOOL, INI_RO|INIEND, - &np2oscfg.I286SAVE, 0}}; + for (i=0; ivalue; + dsize = ini->arg; + + for (i=0; i= '0') && (c <= '9')) { + val <<= 4; + val += c - '0'; + set = TRUE; + } + else { + c |= 0x20; + if ((c >= 'a') && (c <= 'f')) { + val <<= 4; + val += c - 'a' + 10; + set = TRUE; + } + } + src++; + } + if (set == FALSE) { + break; + } + dst[i] = val; + } +} -static long solveHEX(char *str) { +static void iniwrsetargh8(char *work, int size, const INITBL *ini) { - return(milstr_solveHEX(str)); + UINT i; +const BYTE *ptr; + UINT arg; + char tmp[8]; + + ptr = (BYTE *)ini->value; + arg = ini->arg; + if (arg > 0) { + SPRINTF(tmp, "%.2x", ptr[0]); + milstr_ncpy(work, tmp, size); + } + for (i=1; ivalue)[i] = src[i]; + } } - return("false"); } -static BYTE solveBOOL(LPSTR str) { +static void inirdkb(const char *src, const INITBL *ini) { - if ((!milstr_cmp(str, "TRUE")) || (!milstr_cmp(str, "ON")) || - (!milstr_cmp(str, "+")) || (!milstr_cmp(str, "1")) || - (!milstr_cmp(str, "ENABLE"))) { - return(1); + 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; } - return(0); } -static void getinifile(char *initfile, int max) { +// ---- - char *p; +void ini_read(const char *path, const char *title, + const INITBL *tbl, UINT count) { - milstr_ncpy(initfile, modulefile, max); - if (np2arg.ini) { - if ((np2arg.ini[0] == '/') || (np2arg.ini[0] == '-')) { - file_cutname(initfile); - milstr_ncat(initfile, file_getname(np2arg.ini + 2), max); +const INITBL *p; +const INITBL *pterm; + char work[512]; + UINT32 val; + + p = tbl; + pterm = tbl + count; + while(p < pterm) { + switch(p->itemtype & INITYPE_MASK) { + case INITYPE_STR: + GetPrivateProfileString(title, p->item, (char *)p->value, + (char *)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_ARGS16: + GetPrivateProfileString(title, p->item, str_null, + work, sizeof(work), path); + inirdargs16(work, p); + break; + + case INITYPE_ARGH8: + GetPrivateProfileString(title, p->item, str_null, + work, sizeof(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; + break; + + case INITYPE_SINT16: + case INITYPE_UINT16: + val = (UINT16)GetPrivateProfileInt(title, p->item, + *(UINT16 *)p->value, path); + *(UINT16 *)p->value = (UINT16)val; + break; + + case INITYPE_SINT32: + case INITYPE_UINT32: + val = (UINT32)GetPrivateProfileInt(title, p->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; + break; + + case INITYPE_HEX16: + SPRINTF(work, str_x, *(UINT16 *)p->value), + GetPrivateProfileString(title, p->item, work, + work, sizeof(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); + val = (UINT32)milstr_solveHEX(work); + *(UINT16 *)p->value = (UINT32)val; + break; + + case INITYPE_BYTE3: + GetPrivateProfileString(title, p->item, str_null, + work, sizeof(work), path); + inirdbyte3(work, p); + break; + + case INITYPE_KB: + GetPrivateProfileString(title, p->item, str_null, + work, sizeof(work), path); + inirdkb(work, p); + break; } - else { - milstr_ncpy(initfile, np2arg.ini, max); - } - p = file_getext(initfile); - if (!(*p)) { - milstr_ncat(initfile, ".ini", max); - } - } - else { - file_cutext(initfile); - milstr_ncat(initfile, ".ini", max); + p++; } } +void ini_write(const char *path, const char *title, + const INITBL *tbl, UINT count) { -void initload(void) { +const INITBL *p; +const INITBL *pterm; +const char *set; + char work[512]; - char initfile[MAX_PATH]; - char cfgstr[CFGLEN]; - DWORD i; - char *arg[8]; - DWORD args; - INI_ITEM *p; - - getinifile(initfile, MAX_PATH); // ver0.29 - p = iniitem; - while(1) { - if (!(p->itemtype & 0xf0)) { - switch(p->itemtype) { - case INI_STR: - GetPrivateProfileString(ini_title, p->item, - (char *)p->value, (char *)p->value, - p->arg, initfile); - break; - case INI_BOOL: - GetPrivateProfileString(ini_title, p->item, - makeBOOL(*((BYTE *)p->value) & 1), - cfgstr, CFGLEN, initfile); - *(BYTE *)(p->value) = solveBOOL(cfgstr); - break; - case INI_ARG: - GetPrivateProfileString(ini_title, p->item, "", - cfgstr, CFGLEN, initfile); - args = milstr_getarg(cfgstr, arg, p->arg); - if (args == p->arg) { - for (i=0; ivalue)[i] = (BYTE)solveHEX(arg[i]); - if (p->flag & INIA4) { - ((BYTE *)p->value)[i] &= 0x0f; - } - } - } + p = tbl; + pterm = tbl + count; + while(p < pterm) { + if (!(p->itemtype & INIFLAG_RO)) { + work[0] = '\0'; + set = work; + switch(p->itemtype & INITYPE_MASK) { + case INITYPE_STR: + set = (char *)p->value; break; - } - } - else if (!(p->itemtype & INI_EX)) { - switch(p->itemtype) { - case INI_BYTE: - *(BYTE *)p->value = (BYTE)GetPrivateProfileInt( - ini_title, p->item, *(BYTE *)p->value, initfile); - break; - case INI_WORD: - *(WORD *)p->value = (WORD)GetPrivateProfileInt( - ini_title, p->item, *(WORD *)p->value, initfile); - break; - case INI_DWORD: - *(DWORD *)p->value = (DWORD)GetPrivateProfileInt( - ini_title, p->item, *(DWORD *)p->value, initfile); - break; - case INI_HEXB: - wsprintf(cfgstr, "%x", *(BYTE *)p->value), - GetPrivateProfileString(ini_title, p->item, - cfgstr, cfgstr, CFGLEN, initfile); - *(BYTE *)p->value = (BYTE)solveHEX(cfgstr); - break; - case INI_HEXD: - wsprintf(cfgstr, "%x", *(DWORD *)p->value), - GetPrivateProfileString(ini_title, p->item, - cfgstr, cfgstr, CFGLEN, initfile); - *(DWORD *)p->value = solveHEX(cfgstr); + + case INITYPE_BOOL: + set = (*((BYTE *)p->value))?str_true:str_false; break; - } - if (p->flag & INIMAX) { - switch((p->itemtype) & 0x0f) { - case 1: - if (*(BYTE *)p->value > (BYTE)p->arg) { - *(BYTE *)p->value = (BYTE)p->arg; - } - break; - case 2: - if (*(WORD *)p->value > (WORD)p->arg) { - *(WORD *)p->value = (WORD)p->arg; - } - break; - case 4: - if (*(DWORD *)p->value > (DWORD)p->arg) { - *(DWORD *)p->value = (DWORD)p->arg; - } - break; - } - } - if (p->flag & INIAND) { - switch((p->itemtype) & 0x0f) { - case 1: - *(BYTE *)p->value &= (BYTE)p->arg; - break; - case 2: - *(WORD *)p->value &= (WORD)p->arg; - break; - case 4: - *(DWORD *)p->value &= (DWORD)p->arg; - break; - } - } - } - else { - switch(p->itemtype) { - case INI_EX|0: // winid - GetPrivateProfileString(ini_title, p->item, - (char *)p->value, cfgstr, CFGLEN, initfile); - for (i=0; i<3; i++) { - if (((cfgstr[i] >= '0') && (cfgstr[i] < '9')) || - ((cfgstr[i] >= 'A') && (cfgstr[i] < 'Z')) || - ((cfgstr[i] >= 'a') && (cfgstr[i] < 'z'))) { - ((BYTE *)p->value)[i] = cfgstr[i]; - } - } - break; - case INI_EX|1: // remove hdd - *(BYTE *)p->value = - (BYTE)((GetPrivateProfileInt(ini_title, p->item, - ((*(BYTE *)p->value) & 1) + 1, - initfile) - 1) & 1); - break; -#if 0 - case INI_EX|2: // midi module - GetPrivateProfileString(ini_title, p->item, - MIDI_num2module(*(BYTE *)p->value), - cfgstr, CFGLEN, initfile); - *(BYTE *)p->value = MIDI_module2num(cfgstr); + + case INITYPE_ARGH8: + iniwrsetargh8(work, sizeof(work), p); break; -#endif - case INI_EX|3: // keyboard - GetPrivateProfileString(ini_title, p->item, "unknown", - cfgstr, CFGLEN, initfile); - if ((!milstr_extendcmp(cfgstr, "PC98")) || - (!milstr_cmp(cfgstr, "98"))) { - *(BYTE *)p->value = KEY_PC98; - } - else if ((!milstr_extendcmp(cfgstr, "DOS")) || - (!milstr_cmp(cfgstr, "PCAT")) || - (!milstr_cmp(cfgstr, "AT"))) { - *(BYTE *)p->value = KEY_KEY106; - } - else if ((!milstr_extendcmp(cfgstr, "KEY101")) || - (!milstr_cmp(cfgstr, "101"))) { - *(BYTE *)p->value = KEY_KEY101; - } + + case INITYPE_SINT8: + SPRINTF(work, str_d, *((char *)p->value)); + break; + + case INITYPE_SINT16: + SPRINTF(work, str_d, *((SINT16 *)p->value)); + break; + + case INITYPE_SINT32: + SPRINTF(work, str_d, *((SINT32 *)p->value)); + break; + + case INITYPE_UINT8: + SPRINTF(work, str_u, *((BYTE *)p->value)); + break; + + case INITYPE_UINT16: + SPRINTF(work, str_u, *((UINT16 *)p->value)); + break; + + case INITYPE_UINT32: + SPRINTF(work, str_u, *((UINT32 *)p->value)); + break; + + case INITYPE_HEX8: + SPRINTF(work, str_x, *((BYTE *)p->value)); + break; + + case INITYPE_HEX16: + SPRINTF(work, str_x, *((UINT16 *)p->value)); + break; + + case INITYPE_HEX32: + SPRINTF(work, str_x, *((UINT32 *)p->value)); + break; + + default: + set = NULL; break; } - } - if (p->flag & INIEND) { - break; + if (set) { + WritePrivateProfileString(title, p->item, set, path); + } } p++; } } -void initsave(void) { - char initfile[MAX_PATH]; - char cfgstr[CFGLEN]; - DWORD i; - INI_ITEM *p; - - getinifile(initfile, MAX_PATH); // ver0.29 - p = iniitem; - while(!(p->flag & INIEND)) { - if (p->flag & INI_RO) { - } - else if (!(p->itemtype & INI_EX)) { - switch(p->itemtype) { - case INI_STR: - WritePrivateProfileString(ini_title, p->item, - (char *)p->value, initfile); - break; - case INI_BOOL: - WritePrivateProfileString(ini_title, p->item, - makeBOOL(*((BYTE *)p->value) & 1), initfile); - break; - case INI_ARG: - for (i=0; iarg; i++) { - wsprintf(&cfgstr[i*3], "%02x ", - ((BYTE *)p->value)[i]); - } - cfgstr[i*3-1] = '\0'; - WritePrivateProfileString(ini_title, p->item, - cfgstr, initfile); - break; - case INI_BYTE: - wsprintf(cfgstr, "%u", *(BYTE *)p->value); - WritePrivateProfileString(ini_title, p->item, - cfgstr, initfile); - break; - case INI_WORD: - wsprintf(cfgstr, "%u", *(WORD *)p->value); - WritePrivateProfileString(ini_title, p->item, - cfgstr, initfile); - break; - case INI_DWORD: - wsprintf(cfgstr, "%u", *(DWORD *)p->value); - WritePrivateProfileString(ini_title, p->item, - cfgstr, initfile); - break; - case INI_HEXB: - wsprintf(cfgstr, "%x", *(BYTE *)p->value); - WritePrivateProfileString(ini_title, p->item, - cfgstr, initfile); - break; - case INI_HEXD: - wsprintf(cfgstr, "%x", *(DWORD *)p->value); - WritePrivateProfileString(ini_title, p->item, - cfgstr, initfile); - break; - } +// ---- + +static const char ini_title[] = "NekoProjectII"; + +enum { + INIRO_STR = INITYPE_STR + INIFLAG_RO, + INIRO_BOOL = INITYPE_BOOL + 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, + + INIRO_BYTE3 = INITYPE_BYTE3 + INIFLAG_RO, + INIRO_KB = INITYPE_KB + INIFLAG_RO +}; + +static const INITBL iniitem[] = { + {"np2title", INIRO_STR, np2oscfg.titles, + sizeof(np2oscfg.titles)}, + {"np2winid", INIRO_BYTE3, np2oscfg.winid, 0}, + {"WindposX", INITYPE_SINT32, &np2oscfg.winx, 0}, + {"WindposY", INITYPE_SINT32, &np2oscfg.winy, 0}, + {"paddingx", INIROMAX_SINT32, &np2oscfg.paddingx, 32}, + {"paddingy", INIROMAX_SINT32, &np2oscfg.paddingy, 32}, + {"Win_Snap", INITYPE_BOOL, &np2oscfg.WINSNAP, 0}, + + {"FDfolder", INITYPE_STR, fddfolder, MAX_PATH}, + {"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, + sizeof(np2cfg.model)}, + {"clk_base", INITYPE_UINT32, &np2cfg.baseclock, 0}, + {"clk_mult", INITYPE_UINT32, &np2cfg.multiple, 0}, + + {"DIPswtch", INITYPE_ARGH8, np2cfg.dipsw, 3}, + {"MEMswtch", INITYPE_ARGH8, np2cfg.memsw, 8}, + {"ExMemory", INIMAX_UINT8, &np2cfg.EXTMEM, 13}, + {"ITF_WORK", INIRO_BOOL, &np2cfg.ITF_WORK, 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}, + {"SNDboard", INITYPE_HEX8, &np2cfg.SOUND_SW, 0}, + {"BEEP_vol", INIAND_UINT8, &np2cfg.BEEP_VOL, 3}, + {"xspeaker", INIRO_BOOL, &np2cfg.snd_x, 0}, + + {"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}, + + {"volume_F", INIMAX_UINT8, &np2cfg.vol_fm, 128}, + {"volume_S", INIMAX_UINT8, &np2cfg.vol_ssg, 128}, + {"volume_A", INIMAX_UINT8, &np2cfg.vol_adpcm, 128}, + {"volume_P", INIMAX_UINT8, &np2cfg.vol_pcm, 128}, + {"volume_R", INIMAX_UINT8, &np2cfg.vol_rhythm, 128}, + + {"Seek_Snd", INITYPE_BOOL, &np2cfg.MOTOR, 0}, + {"Seek_Vol", INIMAX_UINT8, &np2cfg.MOTORVOL, 100}, + + {"btnRAPID", INITYPE_BOOL, &np2cfg.BTN_RAPID, 0}, + {"btn_MODE", INITYPE_BOOL, &np2cfg.BTN_MODE, 0}, + {"Mouse_sw", INITYPE_BOOL, &np2oscfg.MOUSE_SW, 0}, + {"MS_RAPID", INITYPE_BOOL, &np2cfg.MOUSERAPID, 0}, + + {"backgrnd", INIAND_UINT8, &np2oscfg.background, 3}, + {"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}, + {"RPal_tim", INIMAX_UINT8, &np2cfg.realpal, 64}, + {"s_NOWAIT", INITYPE_BOOL, &np2oscfg.NOWAIT, 0}, + {"SkpFrame", INITYPE_UINT8, &np2oscfg.DRAW_SKIP, 0}, + {"uPD72020", INITYPE_BOOL, &np2cfg.uPD72020, 0}, + {"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}, + {"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_ARGH8, np2cfg.pc9861sw, 3}, + {"pc9861_j", INITYPE_ARGH8, np2cfg.pc9861jmp, 6}, + + {"calendar", INITYPE_BOOL, &np2cfg.calendar, 0}, + {"USE144FD", INITYPE_BOOL, &np2cfg.usefd144, 0}, + + // OS°Í¸¡© + {"keyboard", INIRO_KB, &np2oscfg.KEYBOARD, 0}, + {"F12_COPY", INITYPE_UINT8, &np2oscfg.F12COPY, 0}, + {"Joystick", INITYPE_BOOL, &np2oscfg.JOYPAD1, 0}, + {"Joy1_btn", INITYPE_ARGH8, np2oscfg.JOY1BTN, 4}, + + {"clocknow", INITYPE_UINT8, &np2oscfg.clk_x, 0}, + {"clockfnt", INITYPE_UINT8, &np2oscfg.clk_fnt, 0}, + {"clock_up", INIROAND_HEX32, &np2oscfg.clk_color1, 0xffffff}, + {"clock_dn", INIROAND_HEX32, &np2oscfg.clk_color2, 0xffffff}, + + {"use_sstp", INITYPE_BOOL, &np2oscfg.sstp, 0}, + {"sstpport", INITYPE_UINT16, &np2oscfg.sstpport, 0}, + {"comfirm_", INITYPE_BOOL, &np2oscfg.comfirm, 0}, + {"shortcut", INITYPE_HEX8, &np2oscfg.shortcut, 0}, // ver0.30 + + {"mpu98map", INITYPE_STR, np2oscfg.mpu.mout, MAXPNAMELEN}, + {"mpu98min", INITYPE_STR, np2oscfg.mpu.min, MAXPNAMELEN}, + {"mpu98mdl", INITYPE_STR, np2oscfg.mpu.mdl, 64}, + {"mpu98def", INITYPE_STR, np2oscfg.mpu.def, MAX_PATH}, + + {"com1port", INIMAX_UINT8, &np2oscfg.com1.port, 5}, // ver0.34 + {"com1para", INITYPE_UINT8, &np2oscfg.com1.param, 0}, + {"com1_bps", INITYPE_UINT32, &np2oscfg.com1.speed, 0}, + {"com1mmap", INITYPE_STR, np2oscfg.com1.mout, MAXPNAMELEN}, + {"com1mmdl", INITYPE_STR, np2oscfg.com1.mdl, 64}, + {"com1mdef", INITYPE_STR, np2oscfg.com1.def, MAX_PATH}, + + {"com2port", INIMAX_UINT8, &np2oscfg.com2.port, 5}, // ver0.34 + {"com2para", INITYPE_UINT8, &np2oscfg.com2.param, 0}, + {"com2_bps", INITYPE_UINT32, &np2oscfg.com2.speed, 0}, + {"com2mmap", INITYPE_STR, np2oscfg.com2.mout, MAXPNAMELEN}, + {"com2mmdl", INITYPE_STR, np2oscfg.com2.mdl, 64}, + {"com2mdef", INITYPE_STR, np2oscfg.com2.def, MAX_PATH}, + + {"com3port", INIMAX_UINT8, &np2oscfg.com3.port, 5}, // ver0.34 + {"com3para", INITYPE_UINT8, &np2oscfg.com3.param, 0}, + {"com3_bps", INITYPE_UINT32, &np2oscfg.com3.speed, 0}, + {"com3mmap", INITYPE_STR, np2oscfg.com3.mout, MAXPNAMELEN}, + {"com3mmdl", INITYPE_STR, np2oscfg.com3.mdl, 64}, + {"com3mdef", INITYPE_STR, np2oscfg.com3.def, MAX_PATH}, + + {"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 + {"I286SAVE", INIRO_BOOL, &np2oscfg.I286SAVE, 0}}; + + +void initgetfile(char *path, UINT size) { + + char *p; + + file_cpyname(path, modulefile, size); + if (np2arg.ini) { + if ((np2arg.ini[0] == '/') || (np2arg.ini[0] == '-')) { + file_cutname(path); + file_catname(path, file_getname(np2arg.ini + 2), size); } else { - switch(p->itemtype) { - case INI_EX|1: // remove hdd - wsprintf(cfgstr, "%u", (*(BYTE *)p->value) + 1); - WritePrivateProfileString(ini_title, p->item, - cfgstr, initfile); - break; -#if 0 - case INI_EX|2: // midi module - WritePrivateProfileString(ini_title, p->item, - MIDI_num2module(*(BYTE *)p->value), initfile); - break; -#endif - } + file_cpyname(path, np2arg.ini, size); } - if (p->flag & INIEND) { - break; + p = file_getext(path); + if (!(*p)) { + file_catname(path, ".ini", size); } - p++; } + else { + file_cutext(path); + file_catname(path, ".ini", size); + } +} + +void initload(void) { + + char path[MAX_PATH]; + + initgetfile(path, sizeof(path)); + ini_read(path, ini_title, iniitem, sizeof(iniitem)/sizeof(INITBL)); +} + +void initsave(void) { + + char path[MAX_PATH]; + + initgetfile(path, sizeof(path)); + ini_write(path, ini_title, iniitem, sizeof(iniitem)/sizeof(INITBL)); }