|
|
| version 1.19, 2007/12/16 14:58:25 | version 1.20, 2007/12/17 14:52:55 |
|---|---|
| Line 47 static const CBPARAM cpSBit[] = | Line 47 static const CBPARAM cpSBit[] = |
| {MAKEINTRESOURCE(IDS_2), 0xc0}, | {MAKEINTRESOURCE(IDS_2), 0xc0}, |
| }; | }; |
| static const TCHAR str_seropt[] = _T("Serial option"); | |
| #ifdef __cplusplus | #ifdef __cplusplus |
| extern "C" { | extern "C" { |
| Line 418 static const CBNPARAM cpInt2[] = | Line 416 static const CBNPARAM cpInt2[] = |
| static const CBPARAM cpSync[] = | static const CBPARAM cpSync[] = |
| { | { |
| {MAKEINTRESOURCE(IDS_SYNC), 0x00}, | {MAKEINTRESOURCE(IDS_SYNC), 0x03}, |
| {MAKEINTRESOURCE(IDS_ASYNC), 0x01}, | {MAKEINTRESOURCE(IDS_ASYNC), 0x00}, |
| {MAKEINTRESOURCE(IDS_ASYNC16X), 0x02}, | {MAKEINTRESOURCE(IDS_ASYNC16X), 0x01}, |
| {MAKEINTRESOURCE(IDS_ASYNC64X), 0x03}, | {MAKEINTRESOURCE(IDS_ASYNC64X), 0x02}, |
| }; | }; |
| static const UINT32 pc9861kint1[] = {0, 1, 2, 3}; | static void pc9861setspeed(HWND hWnd, const PC9861MODE_T *m) |
| static const UINT32 pc9861kint2[] = {0, 4, 5, 6}; | { |
| UINT8 cMode; | |
| static const TCHAR sync0[] = _T("Start-Stop"); | UINT uSpeed; |
| static const TCHAR sync1[] = _T("ST1"); | |
| static const TCHAR sync2[] = _T("ST2"); | |
| static const TCHAR sync3[] = _T("RD-Sync"); | |
| static const TCHAR *pc9861sync[] = {sync0, sync1, sync2, sync3}; | |
| static const UINT pc9861d2sync[] = {1, 2, 3, 0}; | |
| static const UINT pc9861d2int[] = {0, 2, 1, 3}; | |
| cMode = *(m->dip_mode); | |
| uSpeed = (((~cMode) >> 2) & 0x0f) + 1; | |
| if (cMode) | |
| { | |
| if (uSpeed > 4) | |
| { | |
| uSpeed -= 4; | |
| } | |
| else | |
| { | |
| uSpeed = 0; | |
| } | |
| } | |
| if (uSpeed > (NELEMENTS(pc9861k_speed) - 1)) | |
| { | |
| uSpeed = NELEMENTS(pc9861k_speed) - 1; | |
| } | |
| static void pc9861getspeed(HWND hWnd, const PC9861MODE_T *m) { | SendDlgItemMessage(hWnd, m->idc_speed, |
| CB_SETCURSEL, (WPARAM)uSpeed, (LPARAM)0); | |
| } | |
| static void pc9861getspeed(HWND hWnd, const PC9861MODE_T *m) | |
| { | |
| UINT8 cMode; | |
| LRESULT r; | LRESULT r; |
| UINT8 mode; | UINT uSpeed; |
| mode = *(m->dip_mode); | cMode = *(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 = (UINT)r; | { |
| if (speed > (NELEMENTS(pc9861k_speed) - 1)) { | uSpeed = (UINT)r; |
| speed = NELEMENTS(pc9861k_speed) - 1; | if (uSpeed > (NELEMENTS(pc9861k_speed) - 1)) |
| } | { |
| if (mode & 2) { | uSpeed = NELEMENTS(pc9861k_speed) - 1; |
| speed += 3; | } |
| } | if (cMode & 2) |
| else { | { |
| if (speed) { | uSpeed += 3; |
| speed--; | } |
| else | |
| { | |
| if (uSpeed) | |
| { | |
| uSpeed--; | |
| } | } |
| } | } |
| mode &= 3; | cMode &= 3; |
| mode |= ((~speed) & 0x0f) << 2; | cMode |= ((~uSpeed) & 0x0f) << 2; |
| *(m->dip_mode) = mode; | *(m->dip_mode) = cMode; |
| } | } |
| } | } |
| static void pc9861getint(HWND hWnd, const PC9861MODE_T *m) { | static void pc9861setsync(HWND hWnd, const PC9861MODE_T *m) |
| { | |
| LRESULT r; | UINT8 cMode; |
| UINT i; | |
| r = SendDlgItemMessage(hWnd, m->idc_int, CB_GETCURSEL, 0, 0); | cMode = *(m->dip_mode); |
| if (r != CB_ERR) { | dlgs_setcbcur(hWnd, m->idc_mode, cMode & 0x03); |
| for (i=0; i<NELEMENTS(pc9861d2int); i++) { | |
| if (pc9861d2int[i] == (UINT)(r & 3)) { | |
| *(m->dip_int) &= ~(0x03 << (m->sft_int)); | |
| *(m->dip_int) |= (UINT8)(i << (m->sft_int)); | |
| break; | |
| } | |
| } | |
| } | |
| } | } |
| static void pc9861getmode(HWND hWnd, const PC9861MODE_T *m) { | static void pc9861getsync(HWND hWnd, const PC9861MODE_T *m) |
| { | |
| LRESULT r; | UINT8 cMode; |
| UINT8 i; | UINT8 cNewMode; |
| r = SendDlgItemMessage(hWnd, m->idc_mode, CB_GETCURSEL, 0, 0); | cMode = *(m->dip_mode); |
| if (r != CB_ERR) { | cNewMode = (UINT8)dlgs_getcbcur(hWnd, m->idc_mode, cMode & 0x03); |
| for (i=0; i<NELEMENTS(pc9861d2sync); i++) { | *(m->dip_mode) = (UINT8)((cMode & (~3)) | cNewMode); |
| if (pc9861d2sync[i] == (UINT)(r & 3)) { | |
| *(m->dip_mode) &= (~3); | |
| *(m->dip_mode) |= i; | |
| break; | |
| } | |
| } | |
| } | |
| } | } |
| static void pc9861setmode(HWND hWnd, const PC9861MODE_T *m) { | static void pc9861setint(HWND hWnd, const PC9861MODE_T *m) |
| { | |
| UINT8 cMask; | |
| UINT8 cMode; | |
| UINT speed; | cMask = 3 << (m->sft_int); |
| UINT mode; | cMode = *(m->dip_int); |
| UINT intnum; | dlgs_setcbcur(hWnd, m->idc_int, cMode & cMask); |
| UINT8 modedip; | } |
| modedip = *(m->dip_mode); | static void pc9861getint(HWND hWnd, const PC9861MODE_T *m) |
| speed = (((~modedip) >> 2) & 0x0f) + 1; | { |
| if (modedip & 0x02) { | UINT8 cMask; |
| if (speed > 4) { | UINT8 cMode; |
| speed -= 4; | UINT8 cNewMode; |
| } | |
| else { | |
| speed = 0; | |
| } | |
| } | |
| if (speed > (NELEMENTS(pc9861k_speed) - 1)) { | |
| speed = NELEMENTS(pc9861k_speed) - 1; | |
| } | |
| SendDlgItemMessage(hWnd, m->idc_speed, | cMask = 3 << (m->sft_int); |
| CB_SETCURSEL, (WPARAM)speed, (LPARAM)0); | cMode = *(m->dip_int); |
| cNewMode = (UINT8)dlgs_getcbcur(hWnd, m->idc_int, cMode & cMask); | |
| *(m->dip_int) = (cMode & (~cMask)) | cNewMode; | |
| } | |
| mode = pc9861d2sync[modedip & 3]; | static void pc9861setmode(HWND hWnd, const PC9861MODE_T *m) |
| SendDlgItemMessage(hWnd, m->idc_mode, | { |
| CB_SETCURSEL, (WPARAM)mode, (LPARAM)0); | pc9861setspeed(hWnd, m); |
| pc9861setint(hWnd, m); | |
| intnum = pc9861d2int[((*(m->dip_int)) >> (m->sft_int)) & 3]; | pc9861setsync(hWnd, m); |
| SendDlgItemMessage(hWnd, m->idc_int, | |
| CB_SETCURSEL, (WPARAM)intnum, (LPARAM)0); | |
| } | } |
| static void pc9861cmddipsw(HWND hWnd) { | static void pc9861cmddipsw(HWND hWnd) { |
| Line 551 static void pc9861cmddipsw(HWND hWnd) { | Line 549 static void pc9861cmddipsw(HWND hWnd) { |
| } | } |
| else if ((p.x >= 10) && (p.x < 14)) { // S2 | else if ((p.x >= 10) && (p.x < 14)) { // S2 |
| pc9861_s[1] ^= (1 << (p.x - 10)); | pc9861_s[1] ^= (1 << (p.x - 10)); |
| pc9861setmode(hWnd, pc9861mode); | pc9861setint(hWnd, pc9861mode); |
| pc9861setmode(hWnd, pc9861mode+1); | pc9861setint(hWnd, pc9861mode+1); |
| } | } |
| else if ((p.x >= 17) && (p.x < 23)) { // S3 | else if ((p.x >= 17) && (p.x < 23)) { // S3 |
| pc9861_s[2] ^= (1 << (p.x - 17)); | pc9861_s[2] ^= (1 << (p.x - 17)); |
| Line 600 static LRESULT CALLBACK pc9861mainProc(H | Line 598 static LRESULT CALLBACK pc9861mainProc(H |
| CopyMemory(pc9861_j, np2cfg.pc9861jmp, 6); | CopyMemory(pc9861_j, np2cfg.pc9861jmp, 6); |
| SETLISTUINT32(hWnd, IDC_CH1SPEED, pc9861k_speed); | SETLISTUINT32(hWnd, IDC_CH1SPEED, pc9861k_speed); |
| SETLISTUINT32(hWnd, IDC_CH2SPEED, pc9861k_speed); | SETLISTUINT32(hWnd, IDC_CH2SPEED, pc9861k_speed); |
| SETLISTUINT32(hWnd, IDC_CH1INT, pc9861kint1); | dlgs_setcbnumber(hWnd, IDC_CH1INT, cpInt1, NELEMENTS(cpInt1)); |
| SETLISTUINT32(hWnd, IDC_CH2INT, pc9861kint2); | dlgs_setcbnumber(hWnd, IDC_CH2INT, cpInt2, NELEMENTS(cpInt2)); |
| SETLISTSTR(hWnd, IDC_CH1MODE, pc9861sync); | dlgs_setcbitem(hWnd, IDC_CH1MODE, cpSync, NELEMENTS(cpSync)); |
| SETLISTSTR(hWnd, IDC_CH2MODE, pc9861sync); | dlgs_setcbitem(hWnd, IDC_CH2MODE, cpSync, NELEMENTS(cpSync)); |
| SendDlgItemMessage(hWnd, IDC_PC9861E, BM_GETCHECK, | SendDlgItemMessage(hWnd, IDC_PC9861E, BM_GETCHECK, |
| np2cfg.pc9861enable & 1, 0); | np2cfg.pc9861enable & 1, 0); |
| Line 619 static LRESULT CALLBACK pc9861mainProc(H | Line 617 static LRESULT CALLBACK pc9861mainProc(H |
| switch (LOWORD(wp)) { | switch (LOWORD(wp)) { |
| case IDC_CH1SPEED: | case IDC_CH1SPEED: |
| pc9861getspeed(hWnd, pc9861mode); | pc9861getspeed(hWnd, pc9861mode); |
| pc9861setmode(hWnd, pc9861mode); | pc9861setspeed(hWnd, pc9861mode); |
| break; | break; |
| case IDC_CH1INT: | case IDC_CH1INT: |
| pc9861getint(hWnd, pc9861mode); | pc9861getint(hWnd, pc9861mode); |
| pc9861setmode(hWnd, pc9861mode); | pc9861setint(hWnd, pc9861mode); |
| break; | break; |
| case IDC_CH1MODE: | case IDC_CH1MODE: |
| pc9861getmode(hWnd, pc9861mode); | pc9861getsync(hWnd, pc9861mode); |
| pc9861setmode(hWnd, pc9861mode); | pc9861setsync(hWnd, pc9861mode); |
| break; | break; |
| case IDC_CH2SPEED: | case IDC_CH2SPEED: |
| pc9861getspeed(hWnd, pc9861mode+1); | pc9861getspeed(hWnd, pc9861mode+1); |
| pc9861setmode(hWnd, pc9861mode+1); | pc9861setspeed(hWnd, pc9861mode+1); |
| break; | break; |
| case IDC_CH2INT: | case IDC_CH2INT: |
| pc9861getint(hWnd, pc9861mode+1); | pc9861getint(hWnd, pc9861mode+1); |
| pc9861setmode(hWnd, pc9861mode+1); | pc9861setint(hWnd, pc9861mode+1); |
| break; | break; |
| case IDC_CH2MODE: | case IDC_CH2MODE: |
| pc9861getmode(hWnd, pc9861mode+1); | pc9861getsync(hWnd, pc9861mode+1); |
| pc9861setmode(hWnd, pc9861mode+1); | pc9861setsync(hWnd, pc9861mode+1); |
| break; | break; |
| case IDC_PC9861DIP: | case IDC_PC9861DIP: |
| Line 691 static LRESULT CALLBACK pc9861mainProc(H | Line 689 static LRESULT CALLBACK pc9861mainProc(H |
| // -------------------------------------------------------------------------- | // -------------------------------------------------------------------------- |
| void dialog_serial(HWND hWnd) { | void dialog_serial(HWND hWnd) |
| { | |
| HINSTANCE hInstance; | HINSTANCE hInstance; |
| PROPSHEETPAGE psp; | PROPSHEETPAGE psp; |
| PROPSHEETHEADER psh; | PROPSHEETHEADER psh; |
| HPROPSHEETPAGE hpsp[4]; | HPROPSHEETPAGE hpsp[4]; |
| TCHAR szTitle[128]; | |
| hInstance = (HINSTANCE)GetWindowLongPtr(hWnd, GWLP_HINSTANCE); | hInstance = (HINSTANCE)GetWindowLongPtr(hWnd, GWLP_HINSTANCE); |
| Line 721 void dialog_serial(HWND hWnd) { | Line 720 void dialog_serial(HWND hWnd) { |
| psp.pfnDlgProc = (DLGPROC)Com3Proc; | psp.pfnDlgProc = (DLGPROC)Com3Proc; |
| hpsp[3] = CreatePropertySheetPage(&psp); | hpsp[3] = CreatePropertySheetPage(&psp); |
| loadstringresource(hInstance, IDS_SERIALOPTION, szTitle, NELEMENTS(szTitle)); | |
| ZeroMemory(&psh, sizeof(psh)); | ZeroMemory(&psh, sizeof(psh)); |
| psh.dwSize = sizeof(PROPSHEETHEADER); | psh.dwSize = sizeof(PROPSHEETHEADER); |
| psh.dwFlags = PSH_NOAPPLYNOW | PSH_USEHICON | PSH_USECALLBACK; | psh.dwFlags = PSH_NOAPPLYNOW | PSH_USEHICON | PSH_USECALLBACK; |
| Line 729 void dialog_serial(HWND hWnd) { | Line 730 void dialog_serial(HWND hWnd) { |
| psh.hIcon = LoadIcon(hInstance, 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 = szTitle; |
| psh.pfnCallback = np2class_propetysheet; | psh.pfnCallback = np2class_propetysheet; |
| PropertySheet(&psh); | PropertySheet(&psh); |
| InvalidateRect(hWnd, NULL, TRUE); | InvalidateRect(hWnd, NULL, TRUE); |