| version 1.1, 2003/10/16 17:58:53 | version 1.11, 2003/11/04 15:44:59 | 
| Line 1 | Line 1 | 
 | #include        "compiler.h" | #include        "compiler.h" | 
 | #include        <windowsx.h> | #include        <windowsx.h> | 
 | #include        <io.h> | #include        <io.h> | 
 |  | #include        "strres.h" | 
 | #include        "np2.h" | #include        "np2.h" | 
 | #include        "dosio.h" |  | 
 | #include        "np2arg.h" | #include        "np2arg.h" | 
| #include        "pccore.h" | #include        "dosio.h" | 
| #include        "iocore.h" |  | 
 | #include        "ini.h" | #include        "ini.h" | 
 | #include        "winkbd.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"; |  | 
 |  |  | 
| typedef struct { | SINT16  *dst; | 
| char    item[9]; | int             dsize; | 
| BYTE    itemtype; | int             i; | 
| WORD    flag; | char    c; | 
| 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}, | dst = (SINT16 *)ini->value; | 
| {"HDD2FILE", INI_STR,   INIMAX, np2cfg.hddfile[1],              MAX_PATH}, | dsize = ini->arg; | 
| //      {"Removabl", INI_EX|1,  0,              &np2cfg.REMOVEHD,               0}, |  | 
 |  |  | 
| {"SampleHz", INI_WORD,  0,              &np2cfg.samplingrate,   0}, | for (i=0; i<dsize; i++) { | 
| {"Latencys", INI_WORD,  0,              &np2cfg.delayms,                0}, | while(*src == ' ') { | 
| {"SNDboard", INI_HEXB,  0,              &np2cfg.SOUND_SW,               0}, | src++; | 
| {"BEEP_vol", INI_BYTE,  INIAND, &np2cfg.BEEP_VOL,               0x03}, | } | 
| {"xspeaker", INI_BOOL,  INI_RO, &np2cfg.snd_x,                  0}, | if (*src == '\0') { | 
|  | break; | 
| {"SND14vol", INI_ARG,   INIA4,  np2cfg.vol14,                   6},             // ver0.27 | } | 
| //      {"opt14BRD", INI_ARG,   0,              np2cfg.snd14opt,                3}, | dst[i] = (SINT16)milstr_solveINT(src); | 
| {"opt26BRD", INI_HEXB,  0,              &np2cfg.snd26opt,               0}, | while(*src != '\0') { | 
| {"opt86BRD", INI_HEXB,  0,              &np2cfg.snd86opt,               0}, | c = *src++; | 
| {"optSPBRD", INI_HEXB,  0,              &np2cfg.spbopt,                 0}, | if (c == ',') { | 
| {"optSPBVR", INI_HEXB,  0,              &np2cfg.spb_vrc,                0},             // ver0.30 | break; | 
| {"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}}; |  | 
 |  |  | 
| #define INIITEMS        (sizeof(iniitem) / sizeof(INI_ITEM)) | static void inirdargh8(const char *src, const INITBL *ini) { | 
 |  |  | 
 |  | BYTE    *dst; | 
 |  | int             dsize; | 
 |  | int             i; | 
 |  | BYTE    val; | 
 |  | BOOL    set; | 
 |  | char    c; | 
 |  |  | 
 |  | dst = (BYTE *)ini->value; | 
 |  | dsize = ini->arg; | 
 |  |  | 
 |  | for (i=0; i<dsize; i++) { | 
 |  | val = 0; | 
 |  | set = FALSE; | 
 |  | while(*src == ' ') { | 
 |  | src++; | 
 |  | } | 
 |  | while(1) { | 
 |  | c = *src; | 
 |  | if ((c == '\0') || (c == ' ')) { | 
 |  | break; | 
 |  | } | 
 |  | else if ((c >= '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; i<arg; i++) { | 
|  | SPRINTF(tmp, " %.2x", ptr[i]); | 
|  | milstr_ncat(work, tmp, size); | 
|  | } | 
 | } | } | 
 |  |  | 
 | static char *makeBOOL(BYTE value) { |  | 
 |  |  | 
| if (value) { | // ---- user | 
| return("true"); |  | 
|  | static void inirdbyte3(const char *src, const INITBL *ini) { | 
|  |  | 
|  | UINT    i; | 
|  |  | 
|  | for (i=0; i<3; i++) { | 
|  | if (src[i] == '\0') { | 
|  | break; | 
|  | } | 
|  | if ((((src[i] - '0') & 0xff) < 9) || | 
|  | (((src[i] - 'A') & 0xdf) < 26)) { | 
|  | ((BYTE *)ini->value)[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")) || | if ((!milstr_extendcmp(src, "PC98")) || | 
| (!milstr_cmp(str, "+")) || (!milstr_cmp(str, "1")) || | (!milstr_cmp(src, "98"))) { | 
| (!milstr_cmp(str, "ENABLE"))) { | *(BYTE *)ini->value = KEY_PC98; | 
| return(1); | } | 
|  | 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); | const INITBL    *p; | 
| if (np2arg.ini) { | const INITBL    *pterm; | 
| if ((np2arg.ini[0] == '/') || (np2arg.ini[0] == '-')) { | char            work[512]; | 
| file_cutname(initfile); | UINT32          val; | 
| milstr_ncat(initfile, file_getname(np2arg.ini + 2), max); |  | 
| } | p = tbl; | 
| else { | pterm = tbl + count; | 
| milstr_ncpy(initfile, np2arg.ini, max); | 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; | 
 | } | } | 
| p = file_getext(initfile); | p++; | 
| if (!(*p)) { |  | 
| milstr_ncat(initfile, ".ini", max); |  | 
| } |  | 
| } |  | 
| else { |  | 
| file_cutext(initfile); |  | 
| milstr_ncat(initfile, ".ini", max); |  | 
 | } | } | 
 | } | } | 
 |  |  | 
 |  | 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]; | p = tbl; | 
| char            cfgstr[CFGLEN]; | pterm = tbl + count; | 
| DWORD           i; | while(p < pterm) { | 
| char            *arg[8]; | if (!(p->itemtype & INIFLAG_RO)) { | 
| DWORD           args; | work[0] = '\0'; | 
| INI_ITEM        *p; | set = work; | 
|  | switch(p->itemtype & INITYPE_MASK) { | 
| getinifile(initfile, MAX_PATH);                                                                 // ver0.29 | case INITYPE_STR: | 
| p = iniitem; | set = (char *)p->value; | 
| 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; i<args; i++) { |  | 
| ((BYTE *)p->value)[i] = (BYTE)solveHEX(arg[i]); |  | 
| if (p->flag & INIA4) { |  | 
| ((BYTE *)p->value)[i] &= 0x0f; |  | 
| } |  | 
| } |  | 
| } |  | 
 | break; | break; | 
| } |  | 
| } | case INITYPE_BOOL: | 
| else if (!(p->itemtype & INI_EX)) { | set = (*((BYTE *)p->value))?str_true:str_false; | 
| 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); |  | 
 | break; | break; | 
| } |  | 
| if (p->flag & INIMAX) { | case INITYPE_ARGH8: | 
| switch((p->itemtype) & 0x0f) { | iniwrsetargh8(work, sizeof(work), p); | 
| case 1: | break; | 
| if (*(BYTE *)p->value > (BYTE)p->arg) { |  | 
| *(BYTE *)p->value = (BYTE)p->arg; | case INITYPE_SINT8: | 
| } | SPRINTF(work, str_d, *((char *)p->value)); | 
| break; | break; | 
| case 2: |  | 
| if (*(WORD *)p->value > (WORD)p->arg) { | case INITYPE_SINT16: | 
| *(WORD *)p->value = (WORD)p->arg; | SPRINTF(work, str_d, *((SINT16 *)p->value)); | 
| } | break; | 
| break; |  | 
| case 4: | case INITYPE_SINT32: | 
| if (*(DWORD *)p->value > (DWORD)p->arg) { | SPRINTF(work, str_d, *((SINT32 *)p->value)); | 
| *(DWORD *)p->value = (DWORD)p->arg; | break; | 
| } |  | 
| break; | case INITYPE_UINT8: | 
| } | SPRINTF(work, str_u, *((BYTE *)p->value)); | 
| } | break; | 
| if (p->flag & INIAND) { |  | 
| switch((p->itemtype) & 0x0f) { | case INITYPE_UINT16: | 
| case 1: | SPRINTF(work, str_u, *((UINT16 *)p->value)); | 
| *(BYTE *)p->value &= (BYTE)p->arg; | break; | 
| break; |  | 
| case 2: | case INITYPE_UINT32: | 
| *(WORD *)p->value &= (WORD)p->arg; | SPRINTF(work, str_u, *((UINT32 *)p->value)); | 
| break; | break; | 
| case 4: |  | 
| *(DWORD *)p->value &= (DWORD)p->arg; | case INITYPE_HEX8: | 
| break; | SPRINTF(work, str_x, *((BYTE *)p->value)); | 
| } | break; | 
| } |  | 
| } | case INITYPE_HEX16: | 
| else { | SPRINTF(work, str_x, *((UINT16 *)p->value)); | 
| switch(p->itemtype) { | break; | 
| case INI_EX|0:                          // winid |  | 
| GetPrivateProfileString(ini_title, p->item, | case INITYPE_HEX32: | 
| (char *)p->value, cfgstr, CFGLEN, initfile); | SPRINTF(work, str_x, *((UINT32 *)p->value)); | 
| for (i=0; i<3; i++) { | break; | 
| if (((cfgstr[i] >= '0') && (cfgstr[i] < '9')) || |  | 
| ((cfgstr[i] >= 'A') && (cfgstr[i] < 'Z')) || | default: | 
| ((cfgstr[i] >= 'a') && (cfgstr[i] < 'z'))) { | set = NULL; | 
| ((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); |  | 
| 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; |  | 
| } |  | 
 | break; | break; | 
 | } | } | 
| } | if (set) { | 
| if (p->flag & INIEND) { | WritePrivateProfileString(title, p->item, set, path); | 
| break; | } | 
 | } | } | 
 | p++; | p++; | 
 | } | } | 
 | } | } | 
 |  |  | 
 | void initsave(void) { |  | 
 |  |  | 
| char            initfile[MAX_PATH]; | // ---- | 
| char            cfgstr[CFGLEN]; |  | 
| DWORD           i; | static const char ini_title[] = "NekoProjectII"; | 
| INI_ITEM        *p; |  | 
|  | enum { | 
| getinifile(initfile, MAX_PATH);                                                                 // ver0.29 | INIRO_STR                       = INITYPE_STR + INIFLAG_RO, | 
| p = iniitem; | INIRO_BOOL                      = INITYPE_BOOL + INIFLAG_RO, | 
| while(!(p->flag & INIEND)) { | INIMAX_UINT8            = INITYPE_UINT8 + INIFLAG_MAX, | 
| if (p->flag & INI_RO) { | INIAND_UINT8            = INITYPE_UINT8 + INIFLAG_AND, | 
| } | INIROMAX_SINT32         = INITYPE_SINT32 + INIFLAG_RO + INIFLAG_MAX, | 
| else if (!(p->itemtype & INI_EX)) { | INIROAND_HEX32          = INITYPE_HEX32 + INIFLAG_RO + INIFLAG_AND, | 
| switch(p->itemtype) { |  | 
| case INI_STR: | INIRO_BYTE3                     = INITYPE_BYTE3 + INIFLAG_RO, | 
| WritePrivateProfileString(ini_title, p->item, | INIRO_KB                        = INITYPE_KB + INIFLAG_RO | 
| (char *)p->value, initfile); | }; | 
| break; |  | 
| case INI_BOOL: | static const INITBL iniitem[] = { | 
| WritePrivateProfileString(ini_title, p->item, | {"np2title", INIRO_STR,                 np2oscfg.titles, | 
| makeBOOL(*((BYTE *)p->value) & 1), initfile); | sizeof(np2oscfg.titles)}, | 
| break; | {"np2winid", INIRO_BYTE3,               np2oscfg.winid,                 0}, | 
| case INI_ARG: | {"WindposX", INITYPE_SINT32,    &np2oscfg.winx,                 0}, | 
| for (i=0; i<p->arg; i++) { | {"WindposY", INITYPE_SINT32,    &np2oscfg.winy,                 0}, | 
| wsprintf(&cfgstr[i*3], "%02x ", | {"paddingx", INIROMAX_SINT32,   &np2oscfg.paddingx,             32}, | 
| ((BYTE *)p->value)[i]); | {"paddingy", INIROMAX_SINT32,   &np2oscfg.paddingy,             32}, | 
| } | {"Win_Snap", INITYPE_BOOL,              &np2oscfg.WINSNAP,              0}, | 
| cfgstr[i*3-1] = '\0'; |  | 
| WritePrivateProfileString(ini_title, p->item, | {"FDfolder", INITYPE_STR,               fddfolder,                              MAX_PATH}, | 
| cfgstr, initfile); | {"HDfolder", INITYPE_STR,               hddfolder,                              MAX_PATH}, | 
| break; | {"bmap_Dir", INITYPE_STR,               bmpfilefolder,                  MAX_PATH}, | 
| case INI_BYTE: | {"fontfile", INITYPE_STR,               np2cfg.fontfile,                MAX_PATH}, | 
| wsprintf(cfgstr, "%u", *(BYTE *)p->value); |  | 
| WritePrivateProfileString(ini_title, p->item, | {"clk_base", INITYPE_UINT32,    &np2cfg.baseclock,              0}, | 
| cfgstr, initfile); | {"clk_mult", INITYPE_UINT32,    &np2cfg.multiple,               0}, | 
| break; |  | 
| case INI_WORD: | {"DIPswtch", INITYPE_ARGH8,             np2cfg.dipsw,                   3}, | 
| wsprintf(cfgstr, "%u", *(WORD *)p->value); | {"MEMswtch", INITYPE_ARGH8,             np2cfg.memsw,                   8}, | 
| WritePrivateProfileString(ini_title, p->item, | {"ExMemory", INIMAX_UINT8,              &np2cfg.EXTMEM,                 13}, | 
| cfgstr, initfile); | {"ITF_WORK", INIRO_BOOL,                &np2cfg.ITF_WORK,               0}, | 
| break; |  | 
| case INI_DWORD: | {"HDD1FILE", INITYPE_STR,               np2cfg.hddfile[0],              MAX_PATH}, | 
| wsprintf(cfgstr, "%u", *(DWORD *)p->value); | {"HDD2FILE", INITYPE_STR,               np2cfg.hddfile[1],              MAX_PATH}, | 
| WritePrivateProfileString(ini_title, p->item, | //      {"Removabl", INI_EX|1,  0,              &np2cfg.REMOVEHD,               0}, | 
| cfgstr, initfile); |  | 
| break; | {"SampleHz", INITYPE_UINT16,    &np2cfg.samplingrate,   0}, | 
| case INI_HEXB: | {"Latencys", INITYPE_UINT16,    &np2cfg.delayms,                0}, | 
| wsprintf(cfgstr, "%x", *(BYTE *)p->value); | {"SNDboard", INITYPE_HEX8,              &np2cfg.SOUND_SW,               0}, | 
| WritePrivateProfileString(ini_title, p->item, | {"BEEP_vol", INIAND_UINT8,              &np2cfg.BEEP_VOL,               3}, | 
| cfgstr, initfile); | {"xspeaker", INIRO_BOOL,                &np2cfg.snd_x,                  0}, | 
| break; |  | 
| case INI_HEXD: | {"SND14vol", INITYPE_ARGH8,             np2cfg.vol14,                   6}, | 
| wsprintf(cfgstr, "%x", *(DWORD *)p->value); | //      {"opt14BRD", INITYPE_ARGH8,             np2cfg.snd14opt,                3}, | 
| WritePrivateProfileString(ini_title, p->item, | {"opt26BRD", INITYPE_HEX8,              &np2cfg.snd26opt,               0}, | 
| cfgstr, initfile); | {"opt86BRD", INITYPE_HEX8,              &np2cfg.snd86opt,               0}, | 
| break; | {"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", INITYPE_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}, | 
|  | {"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 { | else { | 
| switch(p->itemtype) { | file_cpyname(path, np2arg.ini, size); | 
| 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 |  | 
| } |  | 
 | } | } | 
| if (p->flag & INIEND) { | p = file_getext(path); | 
| break; | 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)); | 
 | } | } | 
 |  |  |