| version 1.12, 2004/06/16 12:50:49 | version 1.16, 2007/01/12 16:41:25 | 
| Line 8 | Line 8 | 
 | #include "strres.h" | #include "strres.h" | 
 |  |  | 
 | #include "commng.h" | #include "commng.h" | 
 |  | #include "joymng.h" | 
 | #include "kbdmng.h" | #include "kbdmng.h" | 
 | #include "soundmng.h" | #include "soundmng.h" | 
 |  |  | 
| Line 20  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 187  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 356  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 430  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, | 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, | 
| Line 453  static const INITBL iniitem[] = { | Line 484  static const INITBL iniitem[] = { | 
 | {"hdrvroot", INIRO_STR,         np2cfg.hdrvroot,        MAX_PATH}, | {"hdrvroot", INIRO_STR,         np2cfg.hdrvroot,        MAX_PATH}, | 
 | {"hdrv_acc", INIRO_UINT8,       &np2cfg.hdrvacc,        0}, | {"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 518  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.F12KEY,       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}, | 
 |  |  | 
 | {"confirm_", INITYPE_BOOL,      &np2oscfg.confirm,      0}, | {"confirm_", INITYPE_BOOL,      &np2oscfg.confirm,      0}, | 
 |  |  | 
| Line 568  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}, | 
 |  |  | 
 | {"sharepix", INIRO_BOOL,        &np2oscfg.shared_pixmap,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 620  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); | 
 | } | } |