|
|
| version 1.1, 2003/11/16 16:43:45 | version 1.16, 2007/01/12 16:41:25 |
|---|---|
| Line 7 | Line 7 |
| #include "profile.h" | #include "profile.h" |
| #include "strres.h" | #include "strres.h" |
| #include "commng.h" | |
| #include "joymng.h" | |
| #include "kbdmng.h" | #include "kbdmng.h" |
| #include "soundmng.h" | #include "soundmng.h" |
| Line 19 typedef struct { | Line 21 typedef struct { |
| } _INIARG, *INIARG; | } _INIARG, *INIARG; |
| static BOOL | |
| inigetbmp(const BYTE *ptr, UINT pos) | |
| { | |
| return ((ptr[pos >> 3] >> (pos & 7)) & 1); | |
| } | |
| static void | |
| inisetbmp(BYTE *ptr, UINT pos, BOOL set) | |
| { | |
| UINT8 bit; | |
| ptr += (pos >> 3); | |
| bit = 1 << (pos & 7); | |
| if (set) { | |
| *ptr |= bit; | |
| } else { | |
| *ptr &= ~bit; | |
| } | |
| } | |
| static void | static void |
| inirdargs16(const char *src, const INITBL *ini) | inirdargs16(const char *src, const INITBL *ini) |
| { | { |
| Line 186 inireadcb(void *arg, const char *para, c | Line 209 inireadcb(void *arg, const char *para, c |
| *((BYTE *)p->value) = (!milstr_cmp(data, str_true))?1:0; | *((BYTE *)p->value) = (!milstr_cmp(data, str_true))?1:0; |
| break; | break; |
| case INITYPE_BITMAP: | |
| inisetbmp((BYTE *)p->value, p->arg, milstr_cmp(data, str_true) == 0); | |
| break; | |
| case INITYPE_ARGS16: | case INITYPE_ARGS16: |
| milstr_ncpy(work, data, 512); | milstr_ncpy(work, data, 512); |
| inirdargs16(work, p); | inirdargs16(work, p); |
| Line 315 iwss_extend: | Line 342 iwss_extend: |
| static BOOL read_iniread_flag(const INITBL *p); | static BOOL read_iniread_flag(const INITBL *p); |
| void | void |
| ini_write(const char *path, const char *title, const INITBL *tbl, UINT count) | ini_write(const char *path, const char *title, const INITBL *tbl, UINT count, BOOL create) |
| { | { |
| char work[512]; | char work[512]; |
| const INITBL *p; | const INITBL *p; |
| Line 323 ini_write(const char *path, const char * | Line 350 ini_write(const char *path, const char * |
| FILEH fh; | FILEH fh; |
| BOOL set; | BOOL set; |
| fh = file_create(path); | fh = FILEH_INVALID; |
| if (fh == FILEH_INVALID) | if (!create) { |
| return; | fh = file_open(path); |
| if (fh != FILEH_INVALID) | |
| file_seek(fh, 0L, FSEEK_END); | |
| } | |
| if (fh == FILEH_INVALID) { | |
| fh = file_create(path); | |
| if (fh == FILEH_INVALID) | |
| return; | |
| } | |
| milstr_ncpy(work, "[", sizeof(work)); | milstr_ncpy(work, "[", sizeof(work)); |
| milstr_ncat(work, title, sizeof(work)); | milstr_ncat(work, title, sizeof(work)); |
| Line 347 ini_write(const char *path, const char * | Line 382 ini_write(const char *path, const char * |
| milstr_ncpy(work, (*((BYTE *)p->value)) ? str_true : str_false, sizeof(work)); | milstr_ncpy(work, (*((BYTE *)p->value)) ? str_true : str_false, sizeof(work)); |
| break; | break; |
| case INITYPE_BITMAP: | |
| milstr_ncpy(work, inigetbmp((BYTE *)p->value, p->arg) ? str_true : str_false, sizeof(work)); | |
| break; | |
| case INITYPE_ARGH8: | case INITYPE_ARGH8: |
| iniwrsetargh8(work, sizeof(work), p); | iniwrsetargh8(work, sizeof(work), p); |
| break; | break; |
| Line 421 static const char ini_title[] = "NekoPro | Line 460 static const char ini_title[] = "NekoPro |
| enum { | enum { |
| INIRO_STR = INIFLAG_RO | INITYPE_STR, | INIRO_STR = INIFLAG_RO | INITYPE_STR, |
| INIRO_BOOL = INIFLAG_RO | INITYPE_BOOL, | INIRO_BOOL = INIFLAG_RO | INITYPE_BOOL, |
| INIRO_BITMAP = INIFLAG_RO | INITYPE_BITMAP, | |
| INIRO_UINT8 = INIFLAG_RO | INITYPE_UINT8, | |
| INIMAX_UINT8 = INIFLAG_MAX | INITYPE_UINT8, | INIMAX_UINT8 = INIFLAG_MAX | INITYPE_UINT8, |
| INIAND_UINT8 = INIFLAG_AND | INITYPE_UINT8, | INIAND_UINT8 = INIFLAG_AND | INITYPE_UINT8, |
| INIROMAX_SINT32 = INIFLAG_RO | INIFLAG_MAX | INITYPE_SINT32, | INIROMAX_SINT32 = INIFLAG_RO | INIFLAG_MAX | INITYPE_SINT32, |
| Line 439 static const INITBL iniitem[] = { | Line 480 static const INITBL iniitem[] = { |
| {"HDfolder", INITYPE_STR, hddfolder, MAX_PATH}, | {"HDfolder", INITYPE_STR, hddfolder, MAX_PATH}, |
| {"bmap_Dir", INITYPE_STR, bmpfilefolder, MAX_PATH}, | {"bmap_Dir", INITYPE_STR, bmpfilefolder, MAX_PATH}, |
| {"fontfile", INITYPE_STR, np2cfg.fontfile, MAX_PATH}, | {"fontfile", INITYPE_STR, np2cfg.fontfile, MAX_PATH}, |
| {"biospath", INITYPE_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)}, | {"pc_model", INITYPE_STR, np2cfg.model, sizeof(np2cfg.model)}, |
| {"clk_base", INITYPE_UINT32, &np2cfg.baseclock, 0}, | {"clk_base", INITYPE_UINT32, &np2cfg.baseclock, 0}, |
| {"clk_mult", INITYPE_UINT32, &np2cfg.multiple, 0}, | {"clk_mult", INITYPE_UINT32, &np2cfg.multiple, 0}, |
| Line 450 static const INITBL iniitem[] = { | Line 494 static const INITBL iniitem[] = { |
| {"ExMemory", INIMAX_UINT8, &np2cfg.EXTMEM, 13}, | {"ExMemory", INIMAX_UINT8, &np2cfg.EXTMEM, 13}, |
| {"ITF_WORK", INIRO_BOOL, &np2cfg.ITF_WORK, 0}, | {"ITF_WORK", INIRO_BOOL, &np2cfg.ITF_WORK, 0}, |
| {"HDD1FILE", INITYPE_STR, np2cfg.hddfile[0], MAX_PATH}, | {"HDD1FILE", INITYPE_STR, np2cfg.sasihdd[0], MAX_PATH}, |
| {"HDD2FILE", INITYPE_STR, np2cfg.hddfile[1], MAX_PATH}, | {"HDD2FILE", INITYPE_STR, np2cfg.sasihdd[1], 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 505 static const INITBL iniitem[] = { | Line 549 static const INITBL iniitem[] = { |
| {"calendar", INITYPE_BOOL, &np2cfg.calendar, 0}, | {"calendar", INITYPE_BOOL, &np2cfg.calendar, 0}, |
| {"USE144FD", INITYPE_BOOL, &np2cfg.usefd144, 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}, | |
| {"keyboard", INIRO_KB, &np2oscfg.KEYBOARD, 0}, | {"keyboard", INIRO_KB, &np2oscfg.KEYBOARD, 0}, |
| {"F12_COPY", INITYPE_UINT8, &np2oscfg.F12COPY, 0}, | {"F12_COPY", INITYPE_UINT8, &np2oscfg.F12KEY, 0}, |
| {"Joystick", INITYPE_BOOL, &np2oscfg.JOYPAD1, 0}, | {"Joystick", INITYPE_BOOL, &np2oscfg.JOYPAD1, 0}, |
| {"Joy1_btn", INITYPE_ARGH8, np2oscfg.JOY1BTN, 4}, | {"Joy1_btn", INITYPE_ARGH8, np2oscfg.JOY1BTN, JOY_NBUTTON}, |
| {"Joy1_dev", INITYPE_STR, &np2oscfg.JOYDEV[0], MAX_PATH}, | |
| {"Joy1amap", INITYPE_ARGH8, np2oscfg.JOYAXISMAP[0], JOY_NAXIS}, | |
| {"Joy1bmap", INITYPE_ARGH8, np2oscfg.JOYBTNMAP[0], JOY_NBUTTON}, | |
| {"comfirm_", INITYPE_BOOL, &np2oscfg.comfirm, 0}, | {"confirm_", INITYPE_BOOL, &np2oscfg.confirm, 0}, |
| {"mpu98map", INITYPE_STR, np2oscfg.mpu.mout, MAX_PATH}, | {"mpu98map", INITYPE_STR, np2oscfg.mpu.mout, MAX_PATH}, |
| {"mpu98min", INITYPE_STR, np2oscfg.mpu.min, MAX_PATH}, | {"mpu98min", INITYPE_STR, np2oscfg.mpu.min, MAX_PATH}, |
| {"mpu98mdl", INITYPE_STR, np2oscfg.mpu.mdl, 64}, | {"mpu98mdl", INITYPE_STR, np2oscfg.mpu.mdl, 64}, |
| {"mpu98def", INITYPE_STR, np2oscfg.mpu.def, MAX_PATH}, | {"mpu98def", INITYPE_STR, np2oscfg.mpu.def, MAX_PATH}, |
| {"com1port", INIMAX_UINT8, &np2oscfg.com[0].port, COMPORT_MIDI}, | |
| {"com1para", INITYPE_UINT8, &np2oscfg.com[0].param, 0}, | |
| {"com1_bps", INITYPE_UINT32, &np2oscfg.com[0].speed, 0}, | |
| {"com1mmap", INITYPE_STR, np2oscfg.com[0].mout, MAX_PATH}, | |
| {"com1mmdl", INITYPE_STR, np2oscfg.com[0].mdl, 64}, | |
| {"com1mdef", INITYPE_STR, np2oscfg.com[0].def, MAX_PATH}, | |
| {"com2port", INIMAX_UINT8, &np2oscfg.com[1].port, COMPORT_MIDI}, | |
| {"com2para", INITYPE_UINT8, &np2oscfg.com[1].param, 0}, | |
| {"com2_bps", INITYPE_UINT32, &np2oscfg.com[1].speed, 0}, | |
| {"com2mmap", INITYPE_STR, np2oscfg.com[1].mout, MAX_PATH}, | |
| {"com2mmdl", INITYPE_STR, np2oscfg.com[1].mdl, 64}, | |
| {"com2mdef", INITYPE_STR, np2oscfg.com[1].def, MAX_PATH}, | |
| {"com3port", INIMAX_UINT8, &np2oscfg.com[2].port, COMPORT_MIDI}, | |
| {"com3para", INITYPE_UINT8, &np2oscfg.com[2].param, 0}, | |
| {"com3_bps", INITYPE_UINT32, &np2oscfg.com[2].speed, 0}, | |
| {"com3mmap", INITYPE_STR, np2oscfg.com[2].mout, MAX_PATH}, | |
| {"com3mmdl", INITYPE_STR, np2oscfg.com[2].mdl, 64}, | |
| {"com3mdef", INITYPE_STR, np2oscfg.com[2].def, MAX_PATH}, | |
| {"e_resume", INITYPE_BOOL, &np2oscfg.resume, 0}, | {"e_resume", INITYPE_BOOL, &np2oscfg.resume, 0}, |
| {"STATSAVE", INIRO_BOOL, &np2oscfg.statsave, 0}, | {"STATSAVE", INIRO_BOOL, &np2oscfg.statsave, 0}, |
| #if defined(__GNUC__) && (defined(i386) || defined(__i386__)) | #if defined(GCC_CPU_ARCH_IA32) |
| {"nousemmx", INITYPE_BOOL, &np2oscfg.disablemmx, 0}, | {"nousemmx", INITYPE_BOOL, &np2oscfg.disablemmx, 0}, |
| #endif | #endif |
| {"toolwind", INITYPE_BOOL, &np2oscfg.toolwin, 0}, | {"toolwind", INITYPE_BOOL, &np2oscfg.toolwin, 0}, |
| {"keydispl", INITYPE_BOOL, &np2oscfg.keydisp, 0}, | {"keydispl", INITYPE_BOOL, &np2oscfg.keydisp, 0}, |
| {"soft_kbd", INITYPE_BOOL, &np2oscfg.softkbd, 0}, | |
| {"jast_snd", INITYPE_BOOL, &np2oscfg.jastsnd, 0}, | |
| {"sounddrv", INITYPE_SNDDRV, &np2oscfg.snddrv, 0}, | {"sounddrv", INITYPE_SNDDRV, &np2oscfg.snddrv, 0}, |
| {"audiodev", INITYPE_STR, &np2oscfg.audiodev, MAX_PATH}, | {"audiodev", INITYPE_STR, &np2oscfg.audiodev, MAX_PATH}, |
| Line 532 static const INITBL iniitem[] = { | Line 606 static const INITBL iniitem[] = { |
| {"MIDIIN_d", INITYPE_STR, &np2oscfg.MIDIDEV[1], MAX_PATH}, | {"MIDIIN_d", INITYPE_STR, &np2oscfg.MIDIDEV[1], MAX_PATH}, |
| {"MIDIWAIT", INITYPE_UINT32, &np2oscfg.MIDIWAIT, 0}, | {"MIDIWAIT", INITYPE_UINT32, &np2oscfg.MIDIWAIT, 0}, |
| {"toolkit_", INIRO_STR, &np2oscfg.toolkit, sizeof(np2oscfg.toolkit)}, | |
| {"I286SAVE", INIRO_BOOL, &np2oscfg.I286SAVE, 0} | {"I286SAVE", INIRO_BOOL, &np2oscfg.I286SAVE, 0} |
| }; | }; |
| #define INIITEMS (sizeof(iniitem) / sizeof(iniitem[0])) | #define INIITEMS (sizeof(iniitem) / sizeof(iniitem[0])) |
| Line 582 read_iniread_flag(const INITBL *p) | Line 654 read_iniread_flag(const INITBL *p) |
| return FALSE; | return FALSE; |
| } | } |
| NP2CFG np2cfg_default; | |
| NP2OSCFG np2oscfg_default; | |
| void | void |
| initload(void) | initload(void) |
| { | { |
| char path[MAX_PATH]; | char path[MAX_PATH]; |
| np2cfg_default = np2cfg; | |
| np2oscfg_default = np2oscfg; | |
| milstr_ncpy(path, modulefile, sizeof(path)); | milstr_ncpy(path, modulefile, sizeof(path)); |
| ini_read(path, ini_title, iniitem, INIITEMS); | ini_read(path, ini_title, iniitem, INIITEMS); |
| } | } |
| Line 597 initsave(void) | Line 675 initsave(void) |
| char path[MAX_PATH]; | char path[MAX_PATH]; |
| milstr_ncpy(path, modulefile, sizeof(path)); | milstr_ncpy(path, modulefile, sizeof(path)); |
| ini_write(path, ini_title, iniitem, INIITEMS); | ini_write(path, ini_title, iniitem, INIITEMS, TRUE); |
| } | } |