| version 1.1, 2003/10/16 17:59:40 | version 1.12, 2003/12/04 17:12:09 | 
| Line 14  const INITBL *tblterm; | Line 14  const INITBL *tblterm; | 
 | UINT            count; | UINT            count; | 
 | } _INIARG, *INIARG; | } _INIARG, *INIARG; | 
 |  |  | 
 |  | static void inirdargs16(const char *src, const INITBL *ini) { | 
 |  |  | 
 |  | SINT16  *dst; | 
 |  | int             dsize; | 
 |  | int             i; | 
 |  | char    c; | 
 |  |  | 
 |  | dst = (SINT16 *)ini->value; | 
 |  | dsize = ini->size; | 
 |  |  | 
 |  | for (i=0; i<dsize; i++) { | 
 |  | while(*src == ' ') { | 
 |  | src++; | 
 |  | } | 
 |  | if (*src == '\0') { | 
 |  | break; | 
 |  | } | 
 |  | dst[i] = (SINT16)milstr_solveINT(src); | 
 |  | while(*src != '\0') { | 
 |  | c = *src++; | 
 |  | if (c == ',') { | 
 |  | break; | 
 |  | } | 
 |  | } | 
 |  | } | 
 |  | } | 
 |  |  | 
 | static void inirdarg8(BYTE *dst, int dsize, const char *src) { | static void inirdarg8(BYTE *dst, int dsize, const char *src) { | 
 |  |  | 
 | int             i; | int             i; | 
| Line 58  static BOOL inireadcb(void *arg, const c | Line 85  static BOOL inireadcb(void *arg, const c | 
 | const char *key, const char *data) { | const char *key, const char *data) { | 
 |  |  | 
 | const INITBL    *p; | const INITBL    *p; | 
 |  | char              work[512]; | 
 |  |  | 
 | if (arg == NULL) { | if (arg == NULL) { | 
 | return(FAILURE); | return(FAILURE); | 
| Line 77  const INITBL *p; | Line 105  const INITBL *p; | 
 | *((BYTE *)p->value) = (!milstr_cmp(data, str_true))?1:0; | *((BYTE *)p->value) = (!milstr_cmp(data, str_true))?1:0; | 
 | break; | break; | 
 |  |  | 
 |  | case INITYPE_ARGS16: | 
 |  | milstr_ncpy(work, data, sizeof(work)); | 
 |  | inirdargs16(work, p); | 
 |  | break; | 
 |  |  | 
 | case INITYPE_BYTEARG: | case INITYPE_BYTEARG: | 
 | inirdarg8((BYTE *)p->value, p->size, data); | inirdarg8((BYTE *)p->value, p->size, data); | 
 | break; | break; | 
| Line 193  static void iniwrsetarg8(char *work, int | Line 226  static void iniwrsetarg8(char *work, int | 
 | } | } | 
 |  |  | 
 | void ini_write(const char *path, const char *title, | void ini_write(const char *path, const char *title, | 
| const INITBL *tbl, UINT count) { | const INITBL *tbl, UINT count, BOOL create) { | 
 |  |  | 
 | FILEH           fh; | FILEH           fh; | 
 | const INITBL    *p; | const INITBL    *p; | 
| Line 201  const INITBL *pterm; | Line 234  const INITBL *pterm; | 
 | BOOL            set; | BOOL            set; | 
 | char            work[512]; | char            work[512]; | 
 |  |  | 
| fh = file_create(path); | fh = FILEH_INVALID; | 
|  | if (!create) { | 
|  | fh = file_open(path); | 
|  | if (fh != FILEH_INVALID) { | 
|  | file_seek(fh, 0, FSEEK_END); | 
|  | } | 
|  | } | 
|  | if (fh == FILEH_INVALID) { | 
|  | fh = file_create(path); | 
|  | } | 
 | if (fh == FILEH_INVALID) { | if (fh == FILEH_INVALID) { | 
 | return; | return; | 
 | } | } | 
 | milstr_ncpy(work, "[", sizeof(work)); | milstr_ncpy(work, "[", sizeof(work)); | 
 | milstr_ncat(work, title, sizeof(work)); | milstr_ncat(work, title, sizeof(work)); | 
| milstr_ncat(work, "]\r\n", sizeof(work)); | milstr_ncat(work, "]\r", sizeof(work)); | 
 | file_write(fh, work, strlen(work)); | file_write(fh, work, strlen(work)); | 
 |  |  | 
 | p = tbl; | p = tbl; | 
| Line 273  const INITBL *pterm; | Line 315  const INITBL *pterm; | 
 | file_write(fh, p->item, strlen(p->item)); | file_write(fh, p->item, strlen(p->item)); | 
 | file_write(fh, " = ", 3); | file_write(fh, " = ", 3); | 
 | file_write(fh, work, strlen(work)); | file_write(fh, work, strlen(work)); | 
| file_write(fh, "\r\n", 2); | file_write(fh, "\r", 1); | 
 | } | } | 
 | p++; | p++; | 
 | } | } | 
| Line 290  static const char ini_title[] = "NekoPro | Line 332  static const char ini_title[] = "NekoPro | 
 | static const char inifile[] = "np2.cfg"; | static const char inifile[] = "np2.cfg"; | 
 |  |  | 
 | static const INITBL iniitem[] = { | static const INITBL iniitem[] = { | 
 |  | {"np2title", INITYPE_STR,                       np2oscfg.titles, | 
 |  | sizeof(np2oscfg.titles)}, | 
 |  | {"WindposX", INITYPE_SINT32,    &np2oscfg.winx,                 0}, | 
 |  | {"WindposY", INITYPE_SINT32,    &np2oscfg.winy,                 0}, | 
 |  |  | 
 |  | {"pc_model", INITYPE_STR,               &np2cfg.model, | 
 |  | sizeof(np2cfg.model)}, | 
 | {"clk_base", INITYPE_SINT32,    &np2cfg.baseclock,              0}, | {"clk_base", INITYPE_SINT32,    &np2cfg.baseclock,              0}, | 
 | {"clk_mult", INITYPE_SINT32,    &np2cfg.multiple,               0}, | {"clk_mult", INITYPE_SINT32,    &np2cfg.multiple,               0}, | 
 |  |  | 
| Line 301  static const INITBL iniitem[] = { | Line 350  static const INITBL iniitem[] = { | 
 | {"HDD1FILE", INITYPE_STR,               np2cfg.hddfile[0],              MAX_PATH}, | {"HDD1FILE", INITYPE_STR,               np2cfg.hddfile[0],              MAX_PATH}, | 
 | {"HDD2FILE", INITYPE_STR,               np2cfg.hddfile[1],              MAX_PATH}, | {"HDD2FILE", INITYPE_STR,               np2cfg.hddfile[1],              MAX_PATH}, | 
 | {"fontfile", INITYPE_STR,               np2cfg.fontfile,                MAX_PATH}, | {"fontfile", INITYPE_STR,               np2cfg.fontfile,                MAX_PATH}, | 
 |  | {"biospath", INITYPE_STR,               np2cfg.biospath,                MAX_PATH}, | 
 |  |  | 
 | {"SampleHz", INITYPE_UINT16,    &np2cfg.samplingrate,   0}, | {"SampleHz", INITYPE_UINT16,    &np2cfg.samplingrate,   0}, | 
 | {"Latencys", INITYPE_UINT16,    &np2cfg.delayms,                0}, | {"Latencys", INITYPE_UINT16,    &np2cfg.delayms,                0}, | 
| Line 327  static const INITBL iniitem[] = { | Line 377  static const INITBL iniitem[] = { | 
 | {"Seek_Snd", INITYPE_BOOL,              &np2cfg.MOTOR,                  0}, | {"Seek_Snd", INITYPE_BOOL,              &np2cfg.MOTOR,                  0}, | 
 | {"Seek_Vol", INITYPE_UINT8,             &np2cfg.MOTORVOL,               0}, | {"Seek_Vol", INITYPE_UINT8,             &np2cfg.MOTORVOL,               0}, | 
 |  |  | 
| {"F12_COPY", INITYPE_UINT8,             &np2oscfg.F12COPY,              0}, | {"F11_bind", INITYPE_UINT8,             &np2oscfg.F11KEY,               0}, | 
|  | {"F12_bind", INITYPE_UINT8,             &np2oscfg.F12KEY,               0}, | 
 | {"btnRAPID", INITYPE_BOOL,              &np2cfg.BTN_RAPID,              0}, | {"btnRAPID", INITYPE_BOOL,              &np2cfg.BTN_RAPID,              0}, | 
 | {"btn_MODE", INITYPE_BOOL,              &np2cfg.BTN_MODE,               0}, | {"btn_MODE", INITYPE_BOOL,              &np2cfg.BTN_MODE,               0}, | 
 | {"MS_RAPID", INITYPE_BOOL,              &np2cfg.MOUSERAPID,             0}, | {"MS_RAPID", INITYPE_BOOL,              &np2cfg.MOUSERAPID,             0}, | 
 |  |  | 
 | {"VRAMwait", INITYPE_BYTEARG,   np2cfg.wait,                    6}, | {"VRAMwait", INITYPE_BYTEARG,   np2cfg.wait,                    6}, | 
 |  | {"DspClock", INITYPE_UINT8,             &np2oscfg.DISPCLK,              0}, | 
 | {"DispSync", INITYPE_BOOL,              &np2cfg.DISPSYNC,               0}, | {"DispSync", INITYPE_BOOL,              &np2cfg.DISPSYNC,               0}, | 
 | {"Real_Pal", INITYPE_BOOL,              &np2cfg.RASTER,                 0}, | {"Real_Pal", INITYPE_BOOL,              &np2cfg.RASTER,                 0}, | 
 | {"RPal_tim", INITYPE_UINT8,             &np2cfg.realpal,                0}, | {"RPal_tim", INITYPE_UINT8,             &np2cfg.realpal,                0}, | 
| Line 351  static const INITBL iniitem[] = { | Line 403  static const INITBL iniitem[] = { | 
 | {"pc9861_j", INITYPE_BYTEARG,   np2cfg.pc9861jmp,               6}, | {"pc9861_j", INITYPE_BYTEARG,   np2cfg.pc9861jmp,               6}, | 
 | {"calendar", INITYPE_BOOL,              &np2cfg.calendar,               0}, | {"calendar", INITYPE_BOOL,              &np2cfg.calendar,               0}, | 
 | {"USE144FD", INITYPE_BOOL,              &np2cfg.usefd144,               0}, | {"USE144FD", INITYPE_BOOL,              &np2cfg.usefd144,               0}, | 
 |  | {"Mouse_sw", INITYPE_BOOL,              &np2oscfg.MOUSE_SW,             0}, | 
 |  | {"comfirm_", INITYPE_BOOL,              &np2oscfg.comfirm,              0}, | 
 |  | {"e_resume", INITYPE_BOOL,              &np2oscfg.resume,               0},             // ver0.30 | 
 |  | {"toolwind", INITYPE_BOOL,              &np2oscfg.toolwin,              0},             // ver0.38 | 
 | {"I286SAVE", INITYPE_BOOL,              &np2oscfg.I286SAVE,             0}}; | {"I286SAVE", INITYPE_BOOL,              &np2oscfg.I286SAVE,             0}}; | 
 |  |  | 
 | #define INIITEMS        (sizeof(iniitem) / sizeof(INITBL)) | #define INIITEMS        (sizeof(iniitem) / sizeof(INITBL)) | 
| Line 360  void initload(void) { | Line 416  void initload(void) { | 
 |  |  | 
 | char    path[MAX_PATH]; | char    path[MAX_PATH]; | 
 |  |  | 
| milstr_ncpy(path, file_getcd(inifile), sizeof(path)); | file_cpyname(path, file_getcd(inifile), sizeof(path)); | 
 | ini_read(path, ini_title, iniitem, INIITEMS); | ini_read(path, ini_title, iniitem, INIITEMS); | 
 | } | } | 
 |  |  | 
| Line 368  void initsave(void) { | Line 424  void initsave(void) { | 
 |  |  | 
 | char    path[MAX_PATH]; | char    path[MAX_PATH]; | 
 |  |  | 
| milstr_ncpy(path, file_getcd(inifile), sizeof(path)); | file_cpyname(path, file_getcd(inifile), sizeof(path)); | 
| ini_write(path, ini_title, iniitem, INIITEMS); | ini_write(path, ini_title, iniitem, INIITEMS, TRUE); | 
 | } | } | 
 |  |  |