| version 1.4, 2003/10/31 03:40:10 | version 1.8, 2005/02/09 20:11:36 | 
| Line 6 | Line 6 | 
 | #include        "sysmng.h" | #include        "sysmng.h" | 
 | #include        "dialog.h" | #include        "dialog.h" | 
 | #include        "dialogs.h" | #include        "dialogs.h" | 
 | #include        "bit2res.h" |  | 
 | #include        "pccore.h" | #include        "pccore.h" | 
 |  | #include        "dipswbmp.h" | 
 |  |  | 
 |  |  | 
 | #ifdef __cplusplus | #ifdef __cplusplus | 
| Line 20  extern COMMNG cm_mpu98; | Line 20  extern COMMNG cm_mpu98; | 
 | } | } | 
 | #endif | #endif | 
 |  |  | 
| static const char *mpuinterrupt[4] = {str_int0, str_int1, str_int2, str_int5}; | static const OEMCHAR *mpuinterrupt[4] = { | 
|  | str_int0, str_int1, str_int2, str_int5}; | 
 |  |  | 
| static  BYTE    mpu = 0; | static  UINT8   mpu = 0; | 
 |  |  | 
 |  |  | 
| static void setmpuiopara(HWND hWnd, WORD res, BYTE value) { | static void setmpuiopara(HWND hWnd, UINT16 res, UINT8 value) { | 
 |  |  | 
 | SendDlgItemMessage(hWnd, res, CB_SETCURSEL, | SendDlgItemMessage(hWnd, res, CB_SETCURSEL, | 
 | (WPARAM)((value >> 4) & 15), (LPARAM)0); | (WPARAM)((value >> 4) & 15), (LPARAM)0); | 
 | } | } | 
 |  |  | 
| static BYTE getmpuio(HWND hWnd, WORD res) { | static UINT8 getmpuio(HWND hWnd, UINT16 res) { | 
 |  |  | 
| char    work[8]; | OEMCHAR work[8]; | 
 |  |  | 
| GetDlgItemText(hWnd, res, work, sizeof(work)); | GetDlgItemText(hWnd, res, work, NELEMENTS(work)); | 
 | return((milstr_solveHEX(work) >> 6) & 0xf0); | return((milstr_solveHEX(work) >> 6) & 0xf0); | 
 | } | } | 
 |  |  | 
| static void setmpuintpara(HWND hWnd, WORD res, BYTE value) { | static void setmpuintpara(HWND hWnd, UINT16 res, UINT8 value) { | 
 |  |  | 
 | SendDlgItemMessage(hWnd, res, CB_SETCURSEL, | SendDlgItemMessage(hWnd, res, CB_SETCURSEL, | 
 | (WPARAM)(value & 3), (LPARAM)0); | (WPARAM)(value & 3), (LPARAM)0); | 
 | } | } | 
 |  |  | 
| static BYTE getmpuint(HWND hWnd, WORD res) { | static UINT8 getmpuint(HWND hWnd, UINT16 res) { | 
 |  |  | 
| char    work[8]; | OEMCHAR work[8]; | 
| BYTE    ret; | UINT8   ret; | 
 |  |  | 
| GetDlgItemText(hWnd, res, work, sizeof(work)); | GetDlgItemText(hWnd, res, work, NELEMENTS(work)); | 
 | ret = work[3] - '0'; | ret = work[3] - '0'; | 
 | if (ret >= 3) { | if (ret >= 3) { | 
 | ret = 3; | ret = 3; | 
| Line 58  static BYTE getmpuint(HWND hWnd, WORD re | Line 59  static BYTE getmpuint(HWND hWnd, WORD re | 
 | return(ret); | return(ret); | 
 | } | } | 
 |  |  | 
| static void setmpujmp(HWND hWnd, BYTE value, BYTE bit) { | static void setmpujmp(HWND hWnd, UINT8 value, UINT8 bit) { | 
 |  |  | 
 | if ((mpu ^ value) & bit) { | if ((mpu ^ value) & bit) { | 
 | mpu &= ~bit; | mpu &= ~bit; | 
| Line 67  static void setmpujmp(HWND hWnd, BYTE va | Line 68  static void setmpujmp(HWND hWnd, BYTE va | 
 | } | } | 
 | } | } | 
 |  |  | 
 | static void setmpuiodip(BYTE *image, int px, int py, int align, BYTE v) { |  | 
 |  |  | 
 | int             i, j, y; |  | 
 |  |  | 
 | px *= 9; |  | 
 | px++; |  | 
 | py *= 9; |  | 
 | for (i=0; i<4; i++, px+=9, v<<=1) { |  | 
 | y = py + ((v&0x80)?5:9); |  | 
 | for (j=0; j<3; j++) { |  | 
 | dlgs_linex(image, px, y+j, 7, align, 2); |  | 
 | } |  | 
 | } |  | 
 | } |  | 
 |  |  | 
 | static void setmpuintdip(BYTE *image, int px, int py, int align, BYTE v) { |  | 
 |  |  | 
 | dlgs_setjumpery(image, px + 3 - (mpu & 3), py, align); |  | 
 | } |  | 
 |  |  | 
 |  |  | 
 | // ---- | // ---- | 
 |  |  | 
 | static void mpucreate(HWND hWnd) { | static void mpucreate(HWND hWnd) { | 
 |  |  | 
 | UINT    i; | UINT    i; | 
| char    buf[8]; | OEMCHAR buf[8]; | 
 | HWND    sub; | HWND    sub; | 
 |  |  | 
 | mpu = np2cfg.mpuopt; | mpu = np2cfg.mpuopt; | 
 | for (i=0; i<16; i++) { | for (i=0; i<16; i++) { | 
| wsprintf(buf, str_4X, 0xC0D0 + (i << 10)); | OEMSPRINTF(buf, str_4X, 0xC0D0 + (i << 10)); | 
 | SendDlgItemMessage(hWnd, IDC_MPUIO, | SendDlgItemMessage(hWnd, IDC_MPUIO, | 
 | CB_INSERTSTRING, (WPARAM)i, (LPARAM)buf); | CB_INSERTSTRING, (WPARAM)i, (LPARAM)buf); | 
 | } | } | 
| Line 124  static void mpucreate(HWND hWnd) { | Line 105  static void mpucreate(HWND hWnd) { | 
 | static void mpuupdate(HWND hWnd) { | static void mpuupdate(HWND hWnd) { | 
 |  |  | 
 | union { | union { | 
| char    mmap[MAXPNAMELEN]; | OEMCHAR mmap[MAXPNAMELEN]; | 
| char    mmdl[64]; | OEMCHAR mmdl[64]; | 
| char    mdef[MAX_PATH]; | OEMCHAR mdef[MAX_PATH]; | 
| char    mdin[MAXPNAMELEN]; | OEMCHAR mdin[MAXPNAMELEN]; | 
 | } s; | } s; | 
 | UINT    update; | UINT    update; | 
 |  |  | 
| Line 136  static void mpuupdate(HWND hWnd) { | Line 117  static void mpuupdate(HWND hWnd) { | 
 | np2cfg.mpuopt = mpu; | np2cfg.mpuopt = mpu; | 
 | update |= SYS_UPDATECFG | SYS_UPDATEMIDI; | 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)) { | 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; | 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)) { | 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; | 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)) { | 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; | update |= SYS_UPDATEOSCFG | SYS_UPDATEMIDI; | 
 | } | } | 
 |  |  | 
| Line 156  static void mpuupdate(HWND hWnd) { | Line 137  static void mpuupdate(HWND hWnd) { | 
 | if (cm_mpu98) { | if (cm_mpu98) { | 
 | cm_mpu98->msg(cm_mpu98, COMMSG_MIMPIDEFEN, np2oscfg.mpu.def_en); | 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)) { | 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) { | if (cm_mpu98) { | 
 | cm_mpu98->msg(cm_mpu98, COMMSG_MIMPIDEFFILE, (long)s.mdef); | cm_mpu98->msg(cm_mpu98, COMMSG_MIMPIDEFFILE, (long)s.mdef); | 
 | } | } | 
| Line 172  static void mpucmddipsw(HWND hWnd) { | Line 153  static void mpucmddipsw(HWND hWnd) { | 
 | RECT    rect1; | RECT    rect1; | 
 | RECT    rect2; | RECT    rect2; | 
 | POINT   p; | POINT   p; | 
| BYTE    bit; | BOOL    redraw; | 
|  | UINT8   bit; | 
 |  |  | 
 | GetWindowRect(GetDlgItem(hWnd, IDC_MPUDIP), &rect1); | GetWindowRect(GetDlgItem(hWnd, IDC_MPUDIP), &rect1); | 
 | GetClientRect(GetDlgItem(hWnd, IDC_MPUDIP), &rect2); | GetClientRect(GetDlgItem(hWnd, IDC_MPUDIP), &rect2); | 
 | GetCursorPos(&p); | GetCursorPos(&p); | 
 |  | redraw = FALSE; | 
 | p.x += rect2.left - rect1.left; | p.x += rect2.left - rect1.left; | 
 | p.y += rect2.top - rect1.top; | p.y += rect2.top - rect1.top; | 
 | p.x /= 9; | p.x /= 9; | 
| Line 188  static void mpucmddipsw(HWND hWnd) { | Line 171  static void mpucmddipsw(HWND hWnd) { | 
 | bit = 0x80 >> (p.x - 2); | bit = 0x80 >> (p.x - 2); | 
 | mpu ^= bit; | mpu ^= bit; | 
 | setmpuiopara(hWnd, IDC_MPUIO, mpu); | setmpuiopara(hWnd, IDC_MPUIO, mpu); | 
| InvalidateRect(GetDlgItem(hWnd, IDC_MPUDIP), NULL, TRUE); | redraw = TRUE; | 
 | } | } | 
 | else if ((p.x >= 9) && (p.x < 13)) { | else if ((p.x >= 9) && (p.x < 13)) { | 
| bit = (BYTE)(12 - p.x); | bit = (UINT8)(12 - p.x); | 
 | if ((mpu ^ bit) & 3) { | if ((mpu ^ bit) & 3) { | 
 | mpu &= ~0x3; | mpu &= ~0x3; | 
 | mpu |= bit; | mpu |= bit; | 
 | setmpuintpara(hWnd, IDC_MPUINT, mpu); | setmpuintpara(hWnd, IDC_MPUINT, mpu); | 
| InvalidateRect(GetDlgItem(hWnd, IDC_MPUDIP), NULL, TRUE); | redraw = TRUE; | 
 | } | } | 
 | } | } | 
| } | if (redraw) { | 
|  | InvalidateRect(GetDlgItem(hWnd, IDC_MPUDIP), NULL, TRUE); | 
| static void mpudrawdipsw(HWND hWnd, HDC hdc) { |  | 
|  |  | 
| BITMAPINFO      *bmi; |  | 
| HBITMAP         hbmp; |  | 
| BYTE            *image; |  | 
| int                     align; |  | 
| BYTE            *imgbtm; |  | 
| HDC                     hmdc; |  | 
|  |  | 
| bmi = (BITMAPINFO *)_MALLOC(bit2res_getsize(&mpudip), "bitmap"); |  | 
| if (bmi == NULL) { |  | 
| return; |  | 
 | } | } | 
 | bit2res_sethead(bmi, &mpudip); |  | 
 | hbmp = CreateDIBSection(hdc, bmi, DIB_RGB_COLORS, |  | 
 | (void **)&image, NULL, 0); |  | 
 | bit2res_setdata(image, &mpudip); |  | 
 | align = ((mpudip.x + 7) / 2) & ~3; |  | 
 | imgbtm = image + align * (mpudip.y - 1); |  | 
 | setmpuiodip(imgbtm, 2, 1, align, mpu); |  | 
 | setmpuintdip(imgbtm, 9, 1, align, mpu); |  | 
 | hmdc = CreateCompatibleDC(hdc); |  | 
 | SelectObject(hmdc, hbmp); |  | 
 | BitBlt(hdc, 0, 0, mpudip.x, mpudip.y, hmdc, 0, 0, SRCCOPY); |  | 
 | DeleteDC(hmdc); |  | 
 | DeleteObject(hbmp); |  | 
 | _MFREE(bmi); |  | 
 | } | } | 
 |  |  | 
 | LRESULT CALLBACK MidiDialogProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { | LRESULT CALLBACK MidiDialogProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { | 
| Line 275  LRESULT CALLBACK MidiDialogProc(HWND hWn | Line 232  LRESULT CALLBACK MidiDialogProc(HWND hWn | 
 |  |  | 
 | case WM_DRAWITEM: | case WM_DRAWITEM: | 
 | if (LOWORD(wp) == IDC_MPUDIP) { | if (LOWORD(wp) == IDC_MPUDIP) { | 
| mpudrawdipsw(hWnd, ((LPDRAWITEMSTRUCT)lp)->hDC); | dlgs_drawbmp(((LPDRAWITEMSTRUCT)lp)->hDC, | 
|  | dipswbmp_getmpu(mpu)); | 
 | } | } | 
 | return(FALSE); | return(FALSE); | 
 |  |  |