| version 1.1.1.1, 2003/10/16 17:59:01 | version 1.9, 2003/11/04 19:23:03 | 
| Line 1 | Line 1 | 
 | #include        "compiler.h" | #include        "compiler.h" | 
| #include        "resource.h" | #include        <prsht.h> | 
 | #include        "strres.h" | #include        "strres.h" | 
 |  | #include        "resource.h" | 
 | #include        "np2.h" | #include        "np2.h" | 
 | #include        "dosio.h" | #include        "dosio.h" | 
 | #include        "commng.h" | #include        "commng.h" | 
 | #include        "sysmng.h" | #include        "sysmng.h" | 
 |  | #include        "np2class.h" | 
 |  | #include        "dialog.h" | 
 |  | #include        "dialogs.h" | 
 |  | #include        "bit2res.h" | 
 | #include        "pccore.h" | #include        "pccore.h" | 
 | #include        "iocore.h" | #include        "iocore.h" | 
 | #include        "pc9861k.h" | #include        "pc9861k.h" | 
 | #include        "bit2res.h" |  | 
 | #include        "dialog.h" |  | 
 | #include        "dialogs.h" |  | 
 |  |  | 
 |  |  | 
 | static const char str_none[] = "NONE"; | static const char str_none[] = "NONE"; | 
| Line 152  static LRESULT CALLBACK dlgitem_proc(HWN | Line 154  static LRESULT CALLBACK dlgitem_proc(HWN | 
 | } str; | } str; | 
 | COMCFG  *cfg; | COMCFG  *cfg; | 
 | UINT    update; | UINT    update; | 
 |  | COMMNG  cm; | 
 |  |  | 
 | switch (msg) { | switch (msg) { | 
 | case WM_INITDIALOG: | case WM_INITDIALOG: | 
| Line 218  static LRESULT CALLBACK dlgitem_proc(HWN | Line 221  static LRESULT CALLBACK dlgitem_proc(HWN | 
 | break; | break; | 
 |  |  | 
 | case WM_NOTIFY: | case WM_NOTIFY: | 
| if ((((NMHDR *)lp)->code) == PSN_APPLY) { | if ((((NMHDR *)lp)->code) == (UINT)PSN_APPLY) { | 
 | cfg = m->cfg; | cfg = m->cfg; | 
 | update = 0; | update = 0; | 
 | r = SendDlgItemMessage(hWnd, m->idc[ID_PORT], | r = SendDlgItemMessage(hWnd, m->idc[ID_PORT], | 
| Line 287  static LRESULT CALLBACK dlgitem_proc(HWN | Line 290  static LRESULT CALLBACK dlgitem_proc(HWN | 
 | } | } | 
 |  |  | 
 | cfg->def_en = GetDlgItemCheck(hWnd, m->idc[ID_DEFE]); | cfg->def_en = GetDlgItemCheck(hWnd, m->idc[ID_DEFE]); | 
 |  | cm = *m->cm; | 
 |  | if (cm) { | 
 |  | cm->msg(cm, COMMSG_MIMPIDEFEN, cfg->def_en); | 
 |  | } | 
 | GetDlgItemText(hWnd, m->idc[ID_DEFF], | GetDlgItemText(hWnd, m->idc[ID_DEFF], | 
 | str.mdef, sizeof(str.mdef)); | str.mdef, sizeof(str.mdef)); | 
 | if (milstr_cmp(cfg->def, str.mdef)) { | if (milstr_cmp(cfg->def, str.mdef)) { | 
 | milstr_ncpy(cfg->def, str.mdef, sizeof(cfg->def)); | milstr_ncpy(cfg->def, str.mdef, sizeof(cfg->def)); | 
 | update |= SYS_UPDATEOSCFG; | update |= SYS_UPDATEOSCFG; | 
| //                                      commsmidi_toneload(m->comm, str.mdef); | if (cm) { | 
|  | cm->msg(cm, COMMSG_MIMPIDEFFILE, (long)str.mdef); | 
|  | } | 
 | } | } | 
 | sysmng_update(update); | sysmng_update(update); | 
 | return(TRUE); | return(TRUE); | 
| Line 342  static const PC9861MODE_T pc9861mode[2] | Line 351  static const PC9861MODE_T pc9861mode[2] | 
 | {IDC_CH2SPEED, IDC_CH2INT, IDC_CH2MODE, | {IDC_CH2SPEED, IDC_CH2INT, IDC_CH2MODE, | 
 | &pc9861_s[2], &pc9861_s[1], 2}}; | &pc9861_s[2], &pc9861_s[1], 2}}; | 
 |  |  | 
|  | enum { | 
| #define PC9861S1_X      1 | PC9861S1_X              = 1, | 
| #define PC9861S2_X      10 | PC9861S2_X              = 10, | 
| #define PC9861S3_X      17 | PC9861S3_X              = 17, | 
| #define PC9861S_Y       1 | PC9861S_Y               = 1, | 
|  |  | 
| #define PC9861J1_X      1 | PC9861J1_X              = 1, | 
| #define PC9861J2_X      9 | PC9861J2_X              = 9, | 
| #define PC9861J3_X      17 | PC9861J3_X              = 17, | 
| #define PC9861J4_X      1 | PC9861J4_X              = 1, | 
| #define PC9861J5_X      11 | PC9861J5_X              = 11, | 
| #define PC9861J6_X      19 | PC9861J6_X              = 19, | 
| #define PC9861J1_Y      4 | PC9861J1_Y              = 4, | 
| #define PC9861J4_Y      7 | PC9861J4_Y              = 7 | 
|  | }; | 
| static  SUBCLASSPROC    oldidc_9861dip = NULL; |  | 
 |  |  | 
 | static const UINT32 pc9861kint1[] = {0, 1, 2, 3}; | static const UINT32 pc9861kint1[] = {0, 1, 2, 3}; | 
 | static const UINT32 pc9861kint2[] = {0, 4, 5, 6}; | static const UINT32 pc9861kint2[] = {0, 4, 5, 6}; | 
| Line 429  static void pc9861getspeed(HWND hWnd, co | Line 437  static void pc9861getspeed(HWND hWnd, co | 
 | static void pc9861getint(HWND hWnd, const PC9861MODE_T *m) { | static void pc9861getint(HWND hWnd, const PC9861MODE_T *m) { | 
 |  |  | 
 | LRESULT r; | LRESULT r; | 
| int             i; | UINT    i; | 
 |  |  | 
 | r = SendDlgItemMessage(hWnd, m->idc_int, CB_GETCURSEL, 0, 0); | r = SendDlgItemMessage(hWnd, m->idc_int, CB_GETCURSEL, 0, 0); | 
 | if (r != CB_ERR) { | if (r != CB_ERR) { | 
| Line 443  static void pc9861getint(HWND hWnd, cons | Line 451  static void pc9861getint(HWND hWnd, cons | 
 | } | } | 
 | } | } | 
 |  |  | 
 |  |  | 
 | static void pc9861getmode(HWND hWnd, const PC9861MODE_T *m) { | static void pc9861getmode(HWND hWnd, const PC9861MODE_T *m) { | 
 |  |  | 
 | LRESULT r; | LRESULT r; | 
| Line 494  static void pc9861setmode(HWND hWnd, con | Line 501  static void pc9861setmode(HWND hWnd, con | 
 | CB_SETCURSEL, (WPARAM)intnum, (LPARAM)0); | CB_SETCURSEL, (WPARAM)intnum, (LPARAM)0); | 
 | } | } | 
 |  |  | 
 |  | static void pc9861cmddipsw(HWND hWnd) { | 
 |  |  | 
| static LRESULT CALLBACK pc9861d(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { | RECT    rect1; | 
|  | RECT    rect2; | 
|  | POINT   p; | 
|  | BYTE    bit; | 
 |  |  | 
| PAINTSTRUCT     ps; | GetWindowRect(GetDlgItem(hWnd, IDC_PC9861DIP), &rect1); | 
| HDC                     hdc; | GetClientRect(GetDlgItem(hWnd, IDC_PC9861DIP), &rect2); | 
| HBITMAP         hBitmap; | GetCursorPos(&p); | 
| HDC                     hMemDC; | p.x += rect2.left - rect1.left; | 
|  | p.y += rect2.top - rect1.top; | 
|  | p.x /= 9; | 
|  | p.y /= 9; | 
|  | if ((p.y >= 1) && (p.y < 3)) {                                  // 1段目 | 
|  | if ((p.x >= 1) && (p.x < 7)) {                          // S1 | 
|  | pc9861_s[0] ^= (1 << (p.x - 1)); | 
|  | pc9861setmode(hWnd, pc9861mode); | 
|  | } | 
|  | else if ((p.x >= 10) && (p.x < 14)) {           // S2 | 
|  | pc9861_s[1] ^= (1 << (p.x - 10)); | 
|  | pc9861setmode(hWnd, pc9861mode); | 
|  | pc9861setmode(hWnd, pc9861mode+1); | 
|  | } | 
|  | else if ((p.x >= 17) && (p.x < 23)) {           // S3 | 
|  | pc9861_s[2] ^= (1 << (p.x - 17)); | 
|  | pc9861setmode(hWnd, pc9861mode+1); | 
|  | } | 
|  | } | 
|  | else if ((p.y >= 4) && (p.y < 6)) {                             // 2段目 | 
|  | if ((p.x >= 1) && (p.x < 7)) {                          // J1 | 
|  | pc9861_j[0] ^= (1 << (p.x - 1)); | 
|  | } | 
|  | else if ((p.x >= 9) && (p.x < 15)) {            // J2 | 
|  | pc9861_j[1] ^= (1 << (p.x - 9)); | 
|  | } | 
|  | else if ((p.x >= 17) && (p.x < 19)) {           // J3 | 
|  | pc9861_j[2] = (1 << (p.x - 17)); | 
|  | } | 
|  | } | 
|  | else if ((p.y >= 7) && (p.y < 9)) {                             // 3段目 | 
|  | if ((p.x >= 1) && (p.x < 9)) {                          // J4 | 
|  | bit = (1 << (p.x - 1)); | 
|  | if (pc9861_j[3] == bit) { | 
|  | bit = 0; | 
|  | } | 
|  | pc9861_j[3] = bit; | 
|  | } | 
|  | else if ((p.x >= 11) && (p.x < 17)) {           // J5 | 
|  | pc9861_j[4] ^= (1 << (p.x - 11)); | 
|  | } | 
|  | else if ((p.x >= 19) && (p.x < 25)) {           // J6 | 
|  | pc9861_j[5] ^= (1 << (p.x - 19)); | 
|  | } | 
|  | } | 
|  | } | 
|  |  | 
|  | static void pc9861drawdipsw(HWND hWnd, HDC hdc) { | 
|  |  | 
|  | BITMAPINFO      *bmi; | 
|  | HBITMAP         hbmp; | 
 | BYTE            *image; | BYTE            *image; | 
 | HANDLE          hwork; |  | 
 | BITMAPINFO      *work; |  | 
 | BYTE            *imgbtm; |  | 
 | int                     align; | int                     align; | 
 |  | BYTE            *imgbtm; | 
 |  | HDC                     hmdc; | 
 |  |  | 
| switch(msg) { | bmi = (BITMAPINFO *)_MALLOC(bit2res_getsize(&pc9861dip), "bitmap"); | 
| case WM_PAINT: | if (bmi == NULL) { | 
| hdc = BeginPaint(hWnd, &ps); | return; | 
| if ((hwork = GlobalAlloc(GPTR, bit2res_getsize(&pc9861dip))) |  | 
| == NULL) { |  | 
| break; |  | 
| } |  | 
| if ((work = (BITMAPINFO *)GlobalLock(hwork)) == NULL) { |  | 
| GlobalFree(hwork); |  | 
| break; |  | 
| } |  | 
| bit2res_sethead(work, &pc9861dip); |  | 
| hBitmap = CreateDIBSection(hdc, work, DIB_RGB_COLORS, |  | 
| (void **)&image, NULL, 0); |  | 
| bit2res_setdata(image, &pc9861dip); |  | 
| align = ((pc9861dip.x + 7) / 2) & ~3; |  | 
| imgbtm = image + align * (pc9861dip.y - 1); |  | 
| setdip(imgbtm, PC9861S1_X, PC9861S_Y, align, pc9861_s[0], 6); |  | 
| setdip(imgbtm, PC9861S2_X, PC9861S_Y, align, pc9861_s[1], 4); |  | 
| setdip(imgbtm, PC9861S3_X, PC9861S_Y, align, pc9861_s[2], 6); |  | 
| setjmp(imgbtm, PC9861J1_X, PC9861J1_Y, align, pc9861_j[0], 6); |  | 
| setjmp(imgbtm, PC9861J2_X, PC9861J1_Y, align, pc9861_j[1], 6); |  | 
| setjmp(imgbtm, PC9861J3_X, PC9861J1_Y, align, pc9861_j[2], 2); |  | 
| setjmp(imgbtm, PC9861J4_X, PC9861J4_Y, align, pc9861_j[3], 8); |  | 
| setjmp(imgbtm, PC9861J5_X, PC9861J4_Y, align, pc9861_j[4], 6); |  | 
| setjmp(imgbtm, PC9861J6_X, PC9861J4_Y, align, pc9861_j[5], 6); |  | 
| if ((hMemDC = CreateCompatibleDC(hdc)) != NULL) { |  | 
| SelectObject(hMemDC, hBitmap); |  | 
| StretchBlt(hdc, 0, 0, pc9861dip.x, pc9861dip.y, hMemDC, |  | 
| 0, 0, pc9861dip.x, pc9861dip.y, SRCCOPY); |  | 
| DeleteDC(hMemDC); |  | 
| } |  | 
| DeleteObject(hBitmap); |  | 
| EndPaint(hWnd, &ps); |  | 
| GlobalUnlock(hwork); |  | 
| GlobalFree(hwork); |  | 
| break; |  | 
| default: |  | 
| return(CallWindowProc(oldidc_9861dip, hWnd, msg, wp, lp)); |  | 
 | } | } | 
| return(FALSE); | bit2res_sethead(bmi, &pc9861dip); | 
|  | hbmp = CreateDIBSection(hdc, bmi, DIB_RGB_COLORS, | 
|  | (void **)&image, NULL, 0); | 
|  | bit2res_setdata(image, &pc9861dip); | 
|  | align = ((pc9861dip.x + 7) / 2) & ~3; | 
|  | imgbtm = image + align * (pc9861dip.y - 1); | 
|  | setdip(imgbtm, PC9861S1_X, PC9861S_Y, align, pc9861_s[0], 6); | 
|  | setdip(imgbtm, PC9861S2_X, PC9861S_Y, align, pc9861_s[1], 4); | 
|  | setdip(imgbtm, PC9861S3_X, PC9861S_Y, align, pc9861_s[2], 6); | 
|  | setjmp(imgbtm, PC9861J1_X, PC9861J1_Y, align, pc9861_j[0], 6); | 
|  | setjmp(imgbtm, PC9861J2_X, PC9861J1_Y, align, pc9861_j[1], 6); | 
|  | setjmp(imgbtm, PC9861J3_X, PC9861J1_Y, align, pc9861_j[2], 2); | 
|  | setjmp(imgbtm, PC9861J4_X, PC9861J4_Y, align, pc9861_j[3], 8); | 
|  | setjmp(imgbtm, PC9861J5_X, PC9861J4_Y, align, pc9861_j[4], 6); | 
|  | setjmp(imgbtm, PC9861J6_X, PC9861J4_Y, align, pc9861_j[5], 6); | 
|  | hmdc = CreateCompatibleDC(hdc); | 
|  | SelectObject(hmdc, hbmp); | 
|  | BitBlt(hdc, 0, 0, pc9861dip.x, pc9861dip.y, hmdc, 0, 0, SRCCOPY); | 
|  | DeleteDC(hmdc); | 
|  | DeleteObject(hbmp); | 
|  | _MFREE(bmi); | 
 | } | } | 
 |  |  | 
 |  |  | 
 | static LRESULT CALLBACK pc9861mainProc(HWND hWnd, UINT msg, | static LRESULT CALLBACK pc9861mainProc(HWND hWnd, UINT msg, | 
 | WPARAM wp, LPARAM lp) { | WPARAM wp, LPARAM lp) { | 
 |  |  | 
| RECT    rect1; | HWND    sub; | 
| RECT    rect2; |  | 
| POINT   p; |  | 
 | BYTE    r; | BYTE    r; | 
 | UINT    update; | UINT    update; | 
 |  |  | 
| Line 576  static LRESULT CALLBACK pc9861mainProc(H | Line 617  static LRESULT CALLBACK pc9861mainProc(H | 
 | pc9861setmode(hWnd, pc9861mode); | pc9861setmode(hWnd, pc9861mode); | 
 | pc9861setmode(hWnd, pc9861mode+1); | pc9861setmode(hWnd, pc9861mode+1); | 
 |  |  | 
| oldidc_9861dip = (SUBCLASSPROC)GetWindowLong(GetDlgItem(hWnd, | sub = GetDlgItem(hWnd, IDC_PC9861DIP); | 
| IDC_PC9861DIP), GWL_WNDPROC); | SetWindowLong(sub, GWL_STYLE, SS_OWNERDRAW + | 
| SetWindowLong(GetDlgItem(hWnd, IDC_PC9861DIP), GWL_WNDPROC, | (GetWindowLong(sub, GWL_STYLE) & (~SS_TYPEMASK))); | 
| (LONG)pc9861d); |  | 
 | return(TRUE); | return(TRUE); | 
 |  |  | 
 | case WM_COMMAND: | case WM_COMMAND: | 
| Line 615  static LRESULT CALLBACK pc9861mainProc(H | Line 655  static LRESULT CALLBACK pc9861mainProc(H | 
 | break; | break; | 
 |  |  | 
 | case IDC_PC9861DIP: | case IDC_PC9861DIP: | 
| GetWindowRect(GetDlgItem(hWnd, IDC_PC9861DIP), &rect1); | pc9861cmddipsw(hWnd); | 
| GetClientRect(GetDlgItem(hWnd, IDC_PC9861DIP), &rect2); | break; | 
| GetCursorPos(&p); |  | 
| p.x += rect2.left - rect1.left; |  | 
| p.y += rect2.top - rect1.top; |  | 
| p.x /= 9; |  | 
| p.y /= 9; |  | 
| if ((p.y >= 1) && (p.y < 3)) {                                  // 1段目 |  | 
| if ((p.x >= 1) && (p.x < 7)) {                          // S1 |  | 
| pc9861_s[0] ^= (1 << (p.x - 1)); |  | 
| pc9861setmode(hWnd, pc9861mode); |  | 
| break; |  | 
| } |  | 
| else if ((p.x >= 10) && (p.x < 14)) {           // S2 |  | 
| pc9861_s[1] ^= (1 << (p.x - 10)); |  | 
| pc9861setmode(hWnd, pc9861mode); |  | 
| pc9861setmode(hWnd, pc9861mode+1); |  | 
| break; |  | 
| } |  | 
| else if ((p.x >= 17) && (p.x < 23)) {           // S3 |  | 
| pc9861_s[2] ^= (1 << (p.x - 17)); |  | 
| pc9861setmode(hWnd, pc9861mode+1); |  | 
| break; |  | 
| } |  | 
| } |  | 
| else if ((p.y >= 4) && (p.y < 6)) {                             // 2段目 |  | 
| if ((p.x >= 1) && (p.x < 7)) {                          // J1 |  | 
| pc9861_j[0] ^= (1 << (p.x - 1)); |  | 
| break; |  | 
| } |  | 
| else if ((p.x >= 9) && (p.x < 15)) {            // J2 |  | 
| pc9861_j[1] ^= (1 << (p.x - 9)); |  | 
| break; |  | 
| } |  | 
| else if ((p.x >= 17) && (p.x < 19)) {           // J3 |  | 
| pc9861_j[2] = (1 << (p.x - 17)); |  | 
| break; |  | 
| } |  | 
| } |  | 
| else if ((p.y >= 7) && (p.y < 9)) {                             // 3段目 |  | 
| if ((p.x >= 1) && (p.x < 9)) {                          // J4 |  | 
| BYTE bit = (1 << (p.x - 1)); |  | 
| if (pc9861_j[3] == bit) { |  | 
| bit = 0; |  | 
| } |  | 
| pc9861_j[3] = bit; |  | 
| break; |  | 
| } |  | 
| else if ((p.x >= 11) && (p.x < 17)) {           // J5 |  | 
| pc9861_j[4] ^= (1 << (p.x - 11)); |  | 
| break; |  | 
| } |  | 
| else if ((p.x >= 19) && (p.x < 25)) {           // J6 |  | 
| pc9861_j[5] ^= (1 << (p.x - 19)); |  | 
| break; |  | 
| } |  | 
| } |  | 
| return(FALSE); |  | 
 |  |  | 
 | default: | default: | 
 | return(FALSE); | return(FALSE); | 
| Line 681  static LRESULT CALLBACK pc9861mainProc(H | Line 665  static LRESULT CALLBACK pc9861mainProc(H | 
 | break; | break; | 
 |  |  | 
 | case WM_NOTIFY: | case WM_NOTIFY: | 
| if ((((NMHDR *)lp)->code) == PSN_APPLY) { | if ((((NMHDR *)lp)->code) == (UINT)PSN_APPLY) { | 
 | update = 0; | update = 0; | 
 | r = GetDlgItemCheck(hWnd, IDC_PC9861E); | r = GetDlgItemCheck(hWnd, IDC_PC9861E); | 
 | if (np2cfg.pc9861enable != r) { | if (np2cfg.pc9861enable != r) { | 
| Line 700  static LRESULT CALLBACK pc9861mainProc(H | Line 684  static LRESULT CALLBACK pc9861mainProc(H | 
 | return(TRUE); | return(TRUE); | 
 | } | } | 
 | break; | break; | 
 |  |  | 
 |  | case WM_DRAWITEM: | 
 |  | if (LOWORD(wp) == IDC_PC9861DIP) { | 
 |  | pc9861drawdipsw(hWnd, ((LPDRAWITEMSTRUCT)lp)->hDC); | 
 |  | } | 
 |  | return(FALSE); | 
 | } | } | 
 | return(FALSE); | return(FALSE); | 
 | } | } | 
| Line 739  void dialog_serial(HWND hWnd) { | Line 729  void dialog_serial(HWND hWnd) { | 
 |  |  | 
 | ZeroMemory(&psh, sizeof(psh)); | ZeroMemory(&psh, sizeof(psh)); | 
 | psh.dwSize = sizeof(PROPSHEETHEADER); | psh.dwSize = sizeof(PROPSHEETHEADER); | 
| psh.dwFlags = PSH_NOAPPLYNOW; | psh.dwFlags = PSH_NOAPPLYNOW | PSH_USEHICON | PSH_USECALLBACK; | 
 | psh.hwndParent = hWnd; | psh.hwndParent = hWnd; | 
 | psh.hInstance = hinst; | psh.hInstance = hinst; | 
 |  | psh.hIcon = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON2)); | 
 | psh.nPages = 4; | psh.nPages = 4; | 
 | psh.phpage = hpsp; | psh.phpage = hpsp; | 
 | psh.pszCaption = str_seropt; | psh.pszCaption = str_seropt; | 
 |  | psh.pfnCallback = np2class_propetysheet; | 
 | PropertySheet(&psh); | PropertySheet(&psh); | 
| InvalidateRect(hWndMain, NULL, TRUE); | InvalidateRect(hWnd, NULL, TRUE); | 
 | } | } | 
 |  |  |