--- np2/win9x/dialog/d_mpu98.cpp 2005/02/07 15:39:27 1.7 +++ np2/win9x/dialog/d_mpu98.cpp 2007/12/29 12:56:22 1.12 @@ -2,6 +2,7 @@ #include "strres.h" #include "resource.h" #include "np2.h" +#include "oemtext.h" #include "commng.h" #include "sysmng.h" #include "dialog.h" @@ -20,49 +21,42 @@ extern COMMNG cm_mpu98; } #endif -static const char *mpuinterrupt[4] = {str_int0, str_int1, str_int2, str_int5}; +static const CBPARAM cpInt[] = +{ + {MAKEINTRESOURCE(IDS_INT0), 0}, + {MAKEINTRESOURCE(IDS_INT1), 1}, + {MAKEINTRESOURCE(IDS_INT2), 2}, + {MAKEINTRESOURCE(IDS_INT5), 3}, +}; static UINT8 mpu = 0; - -static void setmpuiopara(HWND hWnd, UINT16 res, UINT8 value) { - - SendDlgItemMessage(hWnd, res, CB_SETCURSEL, - (WPARAM)((value >> 4) & 15), (LPARAM)0); +static void setmpuio(HWND hWnd, UINT8 cValue) +{ + dlgs_setcbcur(hWnd, IDC_MPUIO, (cValue & 0xf0)); } -static UINT8 getmpuio(HWND hWnd, UINT16 res) { - - char work[8]; - - GetDlgItemText(hWnd, res, work, sizeof(work)); - return((milstr_solveHEX(work) >> 6) & 0xf0); +static UINT8 getmpuio(HWND hWnd) +{ + return dlgs_getcbcur(hWnd, IDC_MPUIO, 0x00); } -static void setmpuintpara(HWND hWnd, UINT16 res, UINT8 value) { - - SendDlgItemMessage(hWnd, res, CB_SETCURSEL, - (WPARAM)(value & 3), (LPARAM)0); +static void setmpuint(HWND hWnd, UINT8 cValue) +{ + dlgs_setcbcur(hWnd, IDC_MPUINT, (cValue & 0x03)); } -static UINT8 getmpuint(HWND hWnd, UINT16 res) { - - char work[8]; - UINT8 ret; - - GetDlgItemText(hWnd, res, work, sizeof(work)); - ret = work[3] - '0'; - if (ret >= 3) { - ret = 3; - } - return(ret); +static UINT8 getmpuint(HWND hWnd) +{ + return dlgs_getcbcur(hWnd, IDC_MPUINT, 0x00); } -static void setmpujmp(HWND hWnd, UINT8 value, UINT8 bit) { - - if ((mpu ^ value) & bit) { - mpu &= ~bit; - mpu |= value; +static void setmpujmp(HWND hWnd, UINT8 cValue, UINT8 cBit) +{ + if ((mpu ^ cValue) & cBit) + { + mpu &= ~cBit; + mpu |= cValue; InvalidateRect(GetDlgItem(hWnd, IDC_MPUDIP), NULL, TRUE); } } @@ -70,21 +64,29 @@ static void setmpujmp(HWND hWnd, UINT8 v // ---- -static void mpucreate(HWND hWnd) { - +static void mpucreate(HWND hWnd) +{ UINT i; - char buf[8]; + TCHAR szBuf[8]; + int nIndex; HWND sub; mpu = np2cfg.mpuopt; - for (i=0; i<16; i++) { - wsprintf(buf, str_4X, 0xC0D0 + (i << 10)); - SendDlgItemMessage(hWnd, IDC_MPUIO, - CB_INSERTSTRING, (WPARAM)i, (LPARAM)buf); - } - setmpuiopara(hWnd, IDC_MPUIO, mpu); - SETLISTSTR(hWnd, IDC_MPUINT, mpuinterrupt); - setmpuintpara(hWnd, IDC_MPUINT, mpu); + for (i=0; i<16; i++) + { + wsprintf(szBuf, tchar_4X, 0xC0D0 + (i << 10)); + nIndex = (int)SendDlgItemMessage(hWnd, IDC_MPUIO, CB_ADDSTRING, + 0, (LPARAM)szBuf); + if (nIndex >= 0) + { + SendDlgItemMessage(hWnd, IDC_MPUIO, CB_SETITEMDATA, + (WPARAM)nIndex, (LPARAM)(i << 4)); + } + } + setmpuio(hWnd, mpu); + + dlgs_setcbitem(hWnd, IDC_MPUINT, cpInt, NELEMENTS(cpInt)); + setmpuint(hWnd, mpu); dlgs_setlistmidiout(hWnd, IDC_MPU98MMAP, np2oscfg.mpu.mout); dlgs_setlistmidiin(hWnd, IDC_MPU98MDIN, np2oscfg.mpu.min); @@ -104,10 +106,10 @@ static void mpucreate(HWND hWnd) { static void mpuupdate(HWND hWnd) { union { - char mmap[MAXPNAMELEN]; - char mmdl[64]; - char mdef[MAX_PATH]; - char mdin[MAXPNAMELEN]; + OEMCHAR mmap[MAXPNAMELEN]; + OEMCHAR mmdl[64]; + OEMCHAR mdef[MAX_PATH]; + OEMCHAR mdin[MAXPNAMELEN]; } s; UINT update; @@ -116,19 +118,19 @@ static void mpuupdate(HWND hWnd) { np2cfg.mpuopt = mpu; update |= SYS_UPDATECFG | SYS_UPDATEMIDI; } - GetDlgItemText(hWnd, IDC_MPU98MMAP, s.mmap, sizeof(s.mmap)); + GetDlgItemText(hWnd, IDC_MPU98MMAP, s.mmap, NELEMENTS(s.mmap)); if (milstr_cmp(np2oscfg.mpu.mout, s.mmap)) { - milstr_ncpy(np2oscfg.mpu.mout, s.mmap, sizeof(np2oscfg.mpu.mout)); + milstr_ncpy(np2oscfg.mpu.mout, s.mmap, NELEMENTS(np2oscfg.mpu.mout)); update |= SYS_UPDATEOSCFG | SYS_UPDATEMIDI; } - GetDlgItemText(hWnd, IDC_MPU98MDIN, s.mdin, sizeof(s.mdin)); + GetDlgItemText(hWnd, IDC_MPU98MDIN, s.mdin, NELEMENTS(s.mdin)); if (milstr_cmp(np2oscfg.mpu.min, s.mdin)) { - milstr_ncpy(np2oscfg.mpu.min, s.mdin, sizeof(np2oscfg.mpu.min)); + milstr_ncpy(np2oscfg.mpu.min, s.mdin, NELEMENTS(np2oscfg.mpu.min)); update |= SYS_UPDATEOSCFG | SYS_UPDATEMIDI; } - GetDlgItemText(hWnd, IDC_MPU98MMDL, s.mmdl, sizeof(s.mmdl)); + GetDlgItemText(hWnd, IDC_MPU98MMDL, s.mmdl, NELEMENTS(s.mmdl)); if (milstr_cmp(np2oscfg.mpu.mdl, s.mmdl)) { - milstr_ncpy(np2oscfg.mpu.mdl, s.mmdl, sizeof(np2oscfg.mpu.mdl)); + milstr_ncpy(np2oscfg.mpu.mdl, s.mmdl, NELEMENTS(np2oscfg.mpu.mdl)); update |= SYS_UPDATEOSCFG | SYS_UPDATEMIDI; } @@ -136,9 +138,9 @@ static void mpuupdate(HWND hWnd) { if (cm_mpu98) { cm_mpu98->msg(cm_mpu98, COMMSG_MIMPIDEFEN, np2oscfg.mpu.def_en); } - GetDlgItemText(hWnd, IDC_MPU98DEFF, s.mdef, sizeof(s.mdef)); + GetDlgItemText(hWnd, IDC_MPU98DEFF, s.mdef, NELEMENTS(s.mdef)); if (milstr_cmp(np2oscfg.mpu.def, s.mdef)) { - milstr_ncpy(np2oscfg.mpu.def, s.mdef, sizeof(np2oscfg.mpu.def)); + milstr_ncpy(np2oscfg.mpu.def, s.mdef, NELEMENTS(np2oscfg.mpu.def)); if (cm_mpu98) { cm_mpu98->msg(cm_mpu98, COMMSG_MIMPIDEFFILE, (long)s.mdef); } @@ -169,7 +171,7 @@ static void mpucmddipsw(HWND hWnd) { if ((p.x >= 2) && (p.x < 6)) { bit = 0x80 >> (p.x - 2); mpu ^= bit; - setmpuiopara(hWnd, IDC_MPUIO, mpu); + setmpuio(hWnd, mpu); redraw = TRUE; } else if ((p.x >= 9) && (p.x < 13)) { @@ -177,7 +179,7 @@ static void mpucmddipsw(HWND hWnd) { if ((mpu ^ bit) & 3) { mpu &= ~0x3; mpu |= bit; - setmpuintpara(hWnd, IDC_MPUINT, mpu); + setmpuint(hWnd, mpu); redraw = TRUE; } } @@ -205,17 +207,17 @@ LRESULT CALLBACK MidiDialogProc(HWND hWn break; case IDC_MPUIO: - setmpujmp(hWnd, getmpuio(hWnd, IDC_MPUIO), 0xf0); + setmpujmp(hWnd, getmpuio(hWnd), 0xf0); return(FALSE); case IDC_MPUINT: - setmpujmp(hWnd, getmpuint(hWnd, IDC_MPUINT), 0x03); + setmpujmp(hWnd, getmpuint(hWnd), 0x03); return(FALSE); case IDC_MPUDEF: mpu = 0x82; - setmpuiopara(hWnd, IDC_MPUIO, mpu); - setmpuintpara(hWnd, IDC_MPUINT, mpu); + setmpuio(hWnd, mpu); + setmpuint(hWnd, mpu); InvalidateRect(GetDlgItem(hWnd, IDC_MPUDIP), NULL, TRUE); return(FALSE);