| version 1.12, 2005/02/07 15:39:27 | version 1.19, 2007/12/16 14:58:25 | 
| Line 15 | Line 15 | 
 | #include        "dipswbmp.h" | #include        "dipswbmp.h" | 
 |  |  | 
 |  |  | 
| static const char str_none[] = "NONE"; | static const CBPARAM cpPort[] = | 
| static const char str_com1[] = "COM1"; | { | 
| static const char str_com2[] = "COM2"; | {MAKEINTRESOURCE(IDS_NONCONNECT),       COMPORT_NONE}, | 
| static const char str_com3[] = "COM3"; | {MAKEINTRESOURCE(IDS_COM1),                     COMPORT_COM1}, | 
| static const char str_com4[] = "COM4"; | {MAKEINTRESOURCE(IDS_COM2),                     COMPORT_COM2}, | 
| static const char str_midi[] = "MIDI"; | {MAKEINTRESOURCE(IDS_COM3),                     COMPORT_COM3}, | 
| static const char str_odd[] = "ODD"; | {MAKEINTRESOURCE(IDS_COM4),                     COMPORT_COM4}, | 
| static const char str_even[] = "EVEN"; | {MAKEINTRESOURCE(IDS_MIDI),                     COMPORT_MIDI}, | 
| static const char str_one[] = "1"; | }; | 
| static const char str_onehalf[] = "1.5"; |  | 
| static const char str_two[] = "2"; |  | 
|  |  | 
| static const char *rsport[] = {str_none, str_com1, str_com2, str_com3, |  | 
| str_com4, str_midi}; |  | 
| static const UINT32 rscharsize[] = {5, 6, 7, 8}; |  | 
| static const char *rsparity[] = {str_none, str_odd, str_even}; |  | 
| static const char *rsstopbit[] = {str_one, str_onehalf, str_two}; |  | 
 |  |  | 
| static const char str_seropt[] = "Serial option"; | static const CBNPARAM cpChars[] = | 
|  | { | 
|  | {5,     0x00}, | 
|  | {6,     0x04}, | 
|  | {7,     0x08}, | 
|  | {8,     0x0c}, | 
|  | }; | 
|  |  | 
|  | static const CBPARAM cpParity[] = | 
|  | { | 
|  | {MAKEINTRESOURCE(IDS_PARITY_NONE),  0x00}, | 
|  | {MAKEINTRESOURCE(IDS_PARITY_ODD),   0x20}, | 
|  | {MAKEINTRESOURCE(IDS_PARITY_EVEN),      0x30}, | 
|  | }; | 
|  |  | 
|  | static const CBPARAM cpSBit[] = | 
|  | { | 
|  | {MAKEINTRESOURCE(IDS_1),                    0x40}, | 
|  | {MAKEINTRESOURCE(IDS_1HALF),                0x80}, | 
|  | {MAKEINTRESOURCE(IDS_2),                        0xc0}, | 
|  | }; | 
|  |  | 
|  | static const TCHAR str_seropt[] = _T("Serial option"); | 
 |  |  | 
 |  |  | 
 | #ifdef __cplusplus | #ifdef __cplusplus | 
| Line 49  extern COMMNG cm_pc9861ch2; | Line 63  extern COMMNG cm_pc9861ch2; | 
 |  |  | 
 | enum { | enum { | 
 | ID_PORT         = 0, | ID_PORT         = 0, | 
 |  |  | 
 | ID_SPEED, | ID_SPEED, | 
 | ID_CHARS, | ID_CHARS, | 
 | ID_PARITY, | ID_PARITY, | 
 | ID_SBIT, | ID_SBIT, | 
 |  |  | 
 | ID_MMAP, | ID_MMAP, | 
 | ID_MMDL, | ID_MMDL, | 
 | ID_DEFE, | ID_DEFE, | 
| Line 141  static void dlgcom_items(HWND hWnd, cons | Line 157  static void dlgcom_items(HWND hWnd, cons | 
 | } | } | 
 |  |  | 
 |  |  | 
 |  | static void setChars(HWND hWnd, UINT uID, UINT8 cValue) | 
 |  | { | 
 |  | dlgs_setcbcur(hWnd, uID, cValue & 0x0c); | 
 |  | } | 
 |  |  | 
 |  | static UINT8 getChars(HWND hWnd, UINT uID, UINT8 cDefault) | 
 |  | { | 
 |  | return dlgs_getcbcur(hWnd, uID, cDefault & 0x0c); | 
 |  | } | 
 |  |  | 
 |  |  | 
 |  | static void setParity(HWND hWnd, UINT uID, UINT8 cValue) | 
 |  | { | 
 |  | cValue = cValue & 0x30; | 
 |  | if (!(cValue & 0x20)) | 
 |  | { | 
 |  | cValue = 0; | 
 |  | } | 
 |  | dlgs_setcbcur(hWnd, uID, cValue); | 
 |  | } | 
 |  |  | 
 |  | static UINT8 getParity(HWND hWnd, UINT uID, UINT8 cDefault) | 
 |  | { | 
 |  | return dlgs_getcbcur(hWnd, uID, cDefault & 0x30); | 
 |  | } | 
 |  |  | 
 |  |  | 
 |  | static void setStopBit(HWND hWnd, UINT uID, UINT8 cValue) | 
 |  | { | 
 |  | cValue = cValue & 0xc0; | 
 |  | if (!cValue) | 
 |  | { | 
 |  | cValue = 0x40; | 
 |  | } | 
 |  | dlgs_setcbcur(hWnd, uID, cValue); | 
 |  | } | 
 |  |  | 
 |  | static UINT8 getStopBit(HWND hWnd, UINT uID, UINT8 cDefault) | 
 |  | { | 
 |  | return dlgs_getcbcur(hWnd, uID, cDefault & 0xc0); | 
 |  | } | 
 |  |  | 
 |  |  | 
 |  |  | 
 |  |  | 
 |  |  | 
 |  |  | 
 | static LRESULT CALLBACK dlgitem_proc(HWND hWnd, UINT msg, | static LRESULT CALLBACK dlgitem_proc(HWND hWnd, UINT msg, | 
 | WPARAM wp, LPARAM lp, const DLGCOM_P *m) { | WPARAM wp, LPARAM lp, const DLGCOM_P *m) { | 
 |  |  | 
| Line 148  static LRESULT CALLBACK dlgitem_proc(HWN | Line 211  static LRESULT CALLBACK dlgitem_proc(HWN | 
 | UINT8   b; | UINT8   b; | 
 | LRESULT r; | LRESULT r; | 
 | union { | union { | 
| char    mmap[MAXPNAMELEN]; | OEMCHAR mmap[MAXPNAMELEN]; | 
| char    mmdl[64]; | OEMCHAR mmdl[64]; | 
| char    mdef[MAX_PATH]; | OEMCHAR mdef[MAX_PATH]; | 
 | } str; | } str; | 
 | COMCFG  *cfg; | COMCFG  *cfg; | 
 | UINT    update; | UINT    update; | 
| Line 159  static LRESULT CALLBACK dlgitem_proc(HWN | Line 222  static LRESULT CALLBACK dlgitem_proc(HWN | 
 | switch (msg) { | switch (msg) { | 
 | case WM_INITDIALOG: | case WM_INITDIALOG: | 
 | cfg = m->cfg; | cfg = m->cfg; | 
| SETLISTSTR(hWnd, m->idc[ID_PORT], rsport); | dlgs_setcbitem(hWnd, m->idc[ID_PORT], cpPort, NELEMENTS(cpPort)); | 
 | SETLISTUINT32(hWnd, m->idc[ID_SPEED], cmserial_speed); | SETLISTUINT32(hWnd, m->idc[ID_SPEED], cmserial_speed); | 
| SETLISTUINT32(hWnd, m->idc[ID_CHARS], rscharsize); | dlgs_setcbnumber(hWnd, m->idc[ID_CHARS], | 
| SETLISTSTR(hWnd, m->idc[ID_PARITY], rsparity); | cpChars, NELEMENTS(cpChars)); | 
| SETLISTSTR(hWnd, m->idc[ID_SBIT], rsstopbit); | dlgs_setcbitem(hWnd, m->idc[ID_PARITY], | 
|  | cpParity, NELEMENTS(cpParity)); | 
|  | dlgs_setcbitem(hWnd, m->idc[ID_SBIT], cpSBit, NELEMENTS(cpSBit)); | 
 | for (d=0; d<(NELEMENTS(cmserial_speed) - 1); d++) { | for (d=0; d<(NELEMENTS(cmserial_speed) - 1); d++) { | 
 | if (cmserial_speed[d] >= cfg->speed) { | if (cmserial_speed[d] >= cfg->speed) { | 
 | break; | break; | 
| Line 174  static LRESULT CALLBACK dlgitem_proc(HWN | Line 239  static LRESULT CALLBACK dlgitem_proc(HWN | 
 |  |  | 
 | b = cfg->param; | b = cfg->param; | 
 | d = (b >> 2) & 3; | d = (b >> 2) & 3; | 
| SendDlgItemMessage(hWnd, m->idc[ID_CHARS], |  | 
| CB_SETCURSEL, (WPARAM)d, (LPARAM)0); | setChars(hWnd, m->idc[ID_CHARS], b); | 
| if (b & 0x10) { | setParity(hWnd, m->idc[ID_PARITY], b); | 
| d = ((b >> 5) & 1) + 1; | setStopBit(hWnd, m->idc[ID_SBIT], b); | 
| } |  | 
| else { |  | 
| d = 0; |  | 
| } |  | 
| SendDlgItemMessage(hWnd, m->idc[ID_PARITY], |  | 
| CB_SETCURSEL, (WPARAM)d, (LPARAM)0); |  | 
| d = (b >> 6) & 3; |  | 
| if (d) { |  | 
| d--; |  | 
| } |  | 
| SendDlgItemMessage(hWnd, m->idc[ID_SBIT], |  | 
| CB_SETCURSEL, (WPARAM)d, (LPARAM)0); |  | 
 |  |  | 
 | dlgs_setlistmidiout(hWnd, m->idc[ID_MMAP], cfg->mout); | dlgs_setlistmidiout(hWnd, m->idc[ID_MMAP], cfg->mout); | 
 | SETLISTSTR(hWnd, m->idc[ID_MMDL], cmmidi_mdlname); | SETLISTSTR(hWnd, m->idc[ID_MMDL], cmmidi_mdlname); | 
| Line 198  static LRESULT CALLBACK dlgitem_proc(HWN | Line 251  static LRESULT CALLBACK dlgitem_proc(HWN | 
 | SetDlgItemText(hWnd, m->idc[ID_DEFF], cfg->def); | SetDlgItemText(hWnd, m->idc[ID_DEFF], cfg->def); | 
 |  |  | 
 | d = cfg->port; | d = cfg->port; | 
| if (d >= NELEMENTS(rsport)) { | if (d >= NELEMENTS(cpPort)) | 
|  | { | 
 | d = 0; | d = 0; | 
 | } | } | 
| SendDlgItemMessage(hWnd, m->idc[ID_PORT], | dlgs_setcbcur(hWnd, m->idc[ID_PORT], d); | 
| CB_SETCURSEL, (WPARAM)d, (LPARAM)0); |  | 
|  |  | 
 | dlgcom_items(hWnd, m, d); | dlgcom_items(hWnd, m, d); | 
 | return(TRUE); | return(TRUE); | 
 |  |  | 
 | case WM_COMMAND: | case WM_COMMAND: | 
| if (LOWORD(wp) == m->idc[ID_PORT]) { | if (LOWORD(wp) == m->idc[ID_PORT]) | 
| r = SendDlgItemMessage(hWnd, m->idc[ID_PORT], | { | 
| CB_GETCURSEL, (WPARAM)0, (LPARAM)0); | dlgcom_items(hWnd, m, | 
| if (r != CB_ERR) { | dlgs_getcbcur(hWnd, m->idc[ID_PORT], COMPORT_NONE)); | 
| dlgcom_items(hWnd, m, (UINT)r); |  | 
| } |  | 
 | } | } | 
| else if (LOWORD(wp) == m->idc[ID_DEFB]) { | else if (LOWORD(wp) == m->idc[ID_DEFB]) | 
|  | { | 
 | dlgs_browsemimpidef(hWnd, m->idc[ID_DEFF]); | dlgs_browsemimpidef(hWnd, m->idc[ID_DEFF]); | 
 | } | } | 
 | break; | break; | 
 |  |  | 
 | case WM_NOTIFY: | case WM_NOTIFY: | 
| if ((((NMHDR *)lp)->code) == (UINT)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 = dlgs_getcbcur(hWnd, m->idc[ID_PORT], COMPORT_NONE); | 
| CB_GETCURSEL, (WPARAM)0, (LPARAM)0); | if (cfg->port != (UINT8)r) | 
| if (r != CB_ERR) { | { | 
| if ((UINT)r >= NELEMENTS(rsport)) { | cfg->port = (UINT8)r; | 
| r = 0; | update |= SYS_UPDATEOSCFG; | 
| } | update |= m->update; | 
| if (cfg->port != (UINT8)r) { |  | 
| cfg->port = (UINT8)r; |  | 
| update |= SYS_UPDATEOSCFG; |  | 
| update |= m->update; |  | 
| } |  | 
 | } | } | 
 | r = SendDlgItemMessage(hWnd, m->idc[ID_SPEED], | r = SendDlgItemMessage(hWnd, m->idc[ID_SPEED], | 
 | CB_GETCURSEL, (WPARAM)0, (LPARAM)0); | CB_GETCURSEL, (WPARAM)0, (LPARAM)0); | 
| Line 250  static LRESULT CALLBACK dlgitem_proc(HWN | Line 297  static LRESULT CALLBACK dlgitem_proc(HWN | 
 | } | } | 
 |  |  | 
 | b = 0; | b = 0; | 
| r = SendDlgItemMessage(hWnd, m->idc[ID_CHARS], | b |= getChars(hWnd, m->idc[ID_CHARS], cfg->param); | 
| CB_GETCURSEL, (WPARAM)0, (LPARAM)0); | b |= getParity(hWnd, m->idc[ID_PARITY], cfg->param); | 
| if (r != CB_ERR) { | b |= getStopBit(hWnd, m->idc[ID_SBIT], cfg->param); | 
| b |= (UINT8)(((UINT)r & 3) << 2); |  | 
| } |  | 
| r = SendDlgItemMessage(hWnd, m->idc[ID_PARITY], |  | 
| CB_GETCURSEL, (WPARAM)0, (LPARAM)0); |  | 
| if (r != CB_ERR) { |  | 
| if ((UINT)r) { |  | 
| b |= 0x10; |  | 
| b |= (UINT8)((((UINT)r - 1) & 1) << 5); |  | 
| } |  | 
| } |  | 
| r = SendDlgItemMessage(hWnd, m->idc[ID_SBIT], |  | 
| CB_GETCURSEL, (WPARAM)0, (LPARAM)0); |  | 
| if (r != CB_ERR) { |  | 
| b |= (UINT8)((((UINT)r + 1) & 3) << 6); |  | 
| } |  | 
 | if (cfg->param != b) { | if (cfg->param != b) { | 
 | cfg->param = b; | cfg->param = b; | 
 | update |= SYS_UPDATEOSCFG; | update |= SYS_UPDATEOSCFG; | 
| Line 275  static LRESULT CALLBACK dlgitem_proc(HWN | Line 308  static LRESULT CALLBACK dlgitem_proc(HWN | 
 | } | } | 
 |  |  | 
 | GetDlgItemText(hWnd, m->idc[ID_MMAP], | GetDlgItemText(hWnd, m->idc[ID_MMAP], | 
| str.mmap, sizeof(str.mmap)); | str.mmap, NELEMENTS(str.mmap)); | 
 | if (milstr_cmp(cfg->mout, str.mmap)) { | if (milstr_cmp(cfg->mout, str.mmap)) { | 
| milstr_ncpy(cfg->mout, str.mmap, sizeof(cfg->mout)); | milstr_ncpy(cfg->mout, str.mmap, NELEMENTS(cfg->mout)); | 
 | update |= SYS_UPDATEOSCFG; | update |= SYS_UPDATEOSCFG; | 
 | update |= m->update; | update |= m->update; | 
 | } | } | 
 | GetDlgItemText(hWnd, m->idc[ID_MMDL], | GetDlgItemText(hWnd, m->idc[ID_MMDL], | 
| str.mmdl, sizeof(str.mmdl)); | str.mmdl, NELEMENTS(str.mmdl)); | 
 | if (milstr_cmp(cfg->mdl, str.mmdl)) { | if (milstr_cmp(cfg->mdl, str.mmdl)) { | 
| milstr_ncpy(cfg->mdl, str.mmdl, sizeof(cfg->mdl)); | milstr_ncpy(cfg->mdl, str.mmdl, NELEMENTS(cfg->mdl)); | 
 | update |= SYS_UPDATEOSCFG; | update |= SYS_UPDATEOSCFG; | 
 | update |= m->update; | update |= m->update; | 
 | } | } | 
 |  |  | 
| cfg->def_en = GetDlgItemCheck(hWnd, m->idc[ID_DEFE]); | cfg->def_en = (UINT8)GetDlgItemCheck(hWnd, m->idc[ID_DEFE]); | 
 | cm = *m->cm; | cm = *m->cm; | 
 | if (cm) { | if (cm) { | 
 | cm->msg(cm, COMMSG_MIMPIDEFEN, cfg->def_en); | 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, NELEMENTS(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, NELEMENTS(cfg->def)); | 
 | update |= SYS_UPDATEOSCFG; | update |= SYS_UPDATEOSCFG; | 
 | if (cm) { | if (cm) { | 
 | cm->msg(cm, COMMSG_MIMPIDEFFILE, (long)str.mdef); | cm->msg(cm, COMMSG_MIMPIDEFFILE, (long)str.mdef); | 
| Line 367  enum { | Line 400  enum { | 
 | PC9861J4_Y              = 7 | PC9861J4_Y              = 7 | 
 | }; | }; | 
 |  |  | 
 |  | static const CBNPARAM cpInt1[] = | 
 |  | { | 
 |  | {0,     0x00}, | 
 |  | {1,     0x02}, | 
 |  | {2,     0x01}, | 
 |  | {3,     0x03}, | 
 |  | }; | 
 |  |  | 
 |  | static const CBNPARAM cpInt2[] = | 
 |  | { | 
 |  | {0,     0x00}, | 
 |  | {4,     0x08}, | 
 |  | {5,     0x04}, | 
 |  | {6,     0x0c}, | 
 |  | }; | 
 |  |  | 
 |  | static const CBPARAM cpSync[] = | 
 |  | { | 
 |  | {MAKEINTRESOURCE(IDS_SYNC),             0x00}, | 
 |  | {MAKEINTRESOURCE(IDS_ASYNC),    0x01}, | 
 |  | {MAKEINTRESOURCE(IDS_ASYNC16X), 0x02}, | 
 |  | {MAKEINTRESOURCE(IDS_ASYNC64X), 0x03}, | 
 |  | }; | 
 |  |  | 
 | 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}; | 
 |  |  | 
| static const char sync0[] = "Start-Stop"; | static const TCHAR sync0[] = _T("Start-Stop"); | 
| static const char sync1[] = "ST1"; | static const TCHAR sync1[] = _T("ST1"); | 
| static const char sync2[] = "ST2"; | static const TCHAR sync2[] = _T("ST2"); | 
| static const char sync3[] = "RD-Sync"; | static const TCHAR sync3[] = _T("RD-Sync"); | 
| static const char *pc9861sync[] = {sync0, sync1, sync2, sync3}; | static const TCHAR *pc9861sync[] = {sync0, sync1, sync2, sync3}; | 
 |  |  | 
 | static const UINT pc9861d2sync[] = {1, 2, 3, 0}; | static const UINT pc9861d2sync[] = {1, 2, 3, 0}; | 
 | static const UINT pc9861d2int[] = {0, 2, 1, 3}; | static const UINT pc9861d2int[] = {0, 2, 1, 3}; | 
| Line 388  static void pc9861getspeed(HWND hWnd, co | Line 445  static void pc9861getspeed(HWND hWnd, co | 
 | mode = *(m->dip_mode); | mode = *(m->dip_mode); | 
 | r = SendDlgItemMessage(hWnd, m->idc_speed, CB_GETCURSEL, 0, 0); | r = SendDlgItemMessage(hWnd, m->idc_speed, CB_GETCURSEL, 0, 0); | 
 | if (r != CB_ERR) { | if (r != CB_ERR) { | 
| UINT speed = r; | UINT speed = (UINT)r; | 
 | if (speed > (NELEMENTS(pc9861k_speed) - 1)) { | if (speed > (NELEMENTS(pc9861k_speed) - 1)) { | 
 | speed = NELEMENTS(pc9861k_speed) - 1; | speed = NELEMENTS(pc9861k_speed) - 1; | 
 | } | } | 
| Line 636  static LRESULT CALLBACK pc9861mainProc(H | Line 693  static LRESULT CALLBACK pc9861mainProc(H | 
 |  |  | 
 | void dialog_serial(HWND hWnd) { | void dialog_serial(HWND hWnd) { | 
 |  |  | 
| HINSTANCE               hinst; | HINSTANCE               hInstance; | 
 | PROPSHEETPAGE   psp; | PROPSHEETPAGE   psp; | 
 | PROPSHEETHEADER psh; | PROPSHEETHEADER psh; | 
 | HPROPSHEETPAGE  hpsp[4]; | HPROPSHEETPAGE  hpsp[4]; | 
 |  |  | 
| hinst = (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE); | hInstance = (HINSTANCE)GetWindowLongPtr(hWnd, GWLP_HINSTANCE); | 
 |  |  | 
 | ZeroMemory(&psp, sizeof(psp)); | ZeroMemory(&psp, sizeof(psp)); | 
 | psp.dwSize = sizeof(PROPSHEETPAGE); | psp.dwSize = sizeof(PROPSHEETPAGE); | 
 | psp.dwFlags = PSP_DEFAULT; | psp.dwFlags = PSP_DEFAULT; | 
| psp.hInstance = hinst; | psp.hInstance = hInstance; | 
 |  |  | 
 | psp.pszTemplate = MAKEINTRESOURCE(IDD_SERIAL1); | psp.pszTemplate = MAKEINTRESOURCE(IDD_SERIAL1); | 
 | psp.pfnDlgProc = (DLGPROC)Com1Proc; | psp.pfnDlgProc = (DLGPROC)Com1Proc; | 
| Line 668  void dialog_serial(HWND hWnd) { | Line 725  void dialog_serial(HWND hWnd) { | 
 | psh.dwSize = sizeof(PROPSHEETHEADER); | psh.dwSize = sizeof(PROPSHEETHEADER); | 
 | psh.dwFlags = PSH_NOAPPLYNOW | PSH_USEHICON | PSH_USECALLBACK; | psh.dwFlags = PSH_NOAPPLYNOW | PSH_USEHICON | PSH_USECALLBACK; | 
 | psh.hwndParent = hWnd; | psh.hwndParent = hWnd; | 
| psh.hInstance = hinst; | psh.hInstance = hInstance; | 
| psh.hIcon = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON2)); | psh.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON2)); | 
 | psh.nPages = 4; | psh.nPages = 4; | 
 | psh.phpage = hpsp; | psh.phpage = hpsp; | 
 | psh.pszCaption = str_seropt; | psh.pszCaption = str_seropt; |