|
|
| version 1.2, 2003/10/21 11:22:05 | version 1.17, 2007/01/08 08:52:22 |
|---|---|
| Line 6 | Line 6 |
| #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 "dialog.h" |
| #include "dialogs.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 "dipswbmp.h" | |
| static const char str_none[] = "NONE"; | static const TCHAR str_none[] = _T("NONE"); |
| static const char str_com1[] = "COM1"; | static const TCHAR str_com1[] = _T("COM1"); |
| static const char str_com2[] = "COM2"; | static const TCHAR str_com2[] = _T("COM2"); |
| static const char str_com3[] = "COM3"; | static const TCHAR str_com3[] = _T("COM3"); |
| static const char str_com4[] = "COM4"; | static const TCHAR str_com4[] = _T("COM4"); |
| static const char str_midi[] = "MIDI"; | static const TCHAR str_midi[] = _T("MIDI"); |
| static const char str_odd[] = "ODD"; | static const TCHAR str_odd[] = _T("ODD"); |
| static const char str_even[] = "EVEN"; | static const TCHAR str_even[] = _T("EVEN"); |
| static const char str_one[] = "1"; | static const TCHAR str_one[] = _T("1"); |
| static const char str_onehalf[] = "1.5"; | static const TCHAR str_onehalf[] = _T("1.5"); |
| static const char str_two[] = "2"; | static const TCHAR str_two[] = _T("2"); |
| static const char *rsport[] = {str_none, str_com1, str_com2, str_com3, | static const TCHAR *rsport[] = {str_none, str_com1, str_com2, str_com3, |
| str_com4, str_midi}; | str_com4, str_midi}; |
| static const UINT32 rscharsize[] = {5, 6, 7, 8}; | static const UINT32 rscharsize[] = {5, 6, 7, 8}; |
| static const char *rsparity[] = {str_none, str_odd, str_even}; | static const TCHAR *rsparity[] = {str_none, str_odd, str_even}; |
| static const char *rsstopbit[] = {str_one, str_onehalf, str_two}; | static const TCHAR *rsstopbit[] = {str_one, str_onehalf, str_two}; |
| static const char str_seropt[] = "Serial option"; | static const TCHAR str_seropt[] = _T("Serial option"); |
| #ifdef __cplusplus | #ifdef __cplusplus |
| Line 62 enum { | Line 63 enum { |
| }; | }; |
| typedef struct { | typedef struct { |
| WORD idc[ID_MAX]; | UINT16 idc[ID_MAX]; |
| COMMNG *cm; | COMMNG *cm; |
| COMCFG *cfg; | COMCFG *cfg; |
| const WORD *com_item; | const UINT16 *com_item; |
| const WORD *midi_item; | const UINT16 *midi_item; |
| UINT update; | UINT update; |
| } DLGCOM_P; | } DLGCOM_P; |
| static const WORD com1serial[8] = { | static const UINT16 com1serial[8] = { |
| IDC_COM1STR00, IDC_COM1STR01, IDC_COM1STR02, IDC_COM1STR03, | IDC_COM1STR00, IDC_COM1STR01, IDC_COM1STR02, IDC_COM1STR03, |
| IDC_COM1STR04, IDC_COM1STR05, IDC_COM1STR06, IDC_COM1STR07}; | IDC_COM1STR04, IDC_COM1STR05, IDC_COM1STR06, IDC_COM1STR07}; |
| static const WORD com1rsmidi[3] = { | static const UINT16 com1rsmidi[3] = { |
| IDC_COM1STR10, IDC_COM1STR11, IDC_COM1STR12}; | IDC_COM1STR10, IDC_COM1STR11, IDC_COM1STR12}; |
| static const DLGCOM_P res_com1 = | static const DLGCOM_P res_com1 = |
| Line 87 static const DLGCOM_P res_com1 = | Line 88 static const DLGCOM_P res_com1 = |
| com1serial, com1rsmidi, SYS_UPDATESERIAL1}; | com1serial, com1rsmidi, SYS_UPDATESERIAL1}; |
| static const WORD com2serial[8] = { | static const UINT16 com2serial[8] = { |
| IDC_COM2STR00, IDC_COM2STR01, IDC_COM2STR02, IDC_COM2STR03, | IDC_COM2STR00, IDC_COM2STR01, IDC_COM2STR02, IDC_COM2STR03, |
| IDC_COM2STR04, IDC_COM2STR05, IDC_COM2STR06, IDC_COM2STR07}; | IDC_COM2STR04, IDC_COM2STR05, IDC_COM2STR06, IDC_COM2STR07}; |
| static const WORD com2rsmidi[3] = { | static const UINT16 com2rsmidi[3] = { |
| IDC_COM2STR10, IDC_COM2STR11, IDC_COM2STR12}; | IDC_COM2STR10, IDC_COM2STR11, IDC_COM2STR12}; |
| static const DLGCOM_P res_com2 = | static const DLGCOM_P res_com2 = |
| Line 103 static const DLGCOM_P res_com2 = | Line 104 static const DLGCOM_P res_com2 = |
| com2serial, com2rsmidi, SYS_UPDATESERIAL1}; | com2serial, com2rsmidi, SYS_UPDATESERIAL1}; |
| static const WORD com3serial[8] = { | static const UINT16 com3serial[8] = { |
| IDC_COM3STR00, IDC_COM3STR01, IDC_COM3STR02, IDC_COM3STR03, | IDC_COM3STR00, IDC_COM3STR01, IDC_COM3STR02, IDC_COM3STR03, |
| IDC_COM3STR04, IDC_COM3STR05, IDC_COM3STR06, IDC_COM3STR07}; | IDC_COM3STR04, IDC_COM3STR05, IDC_COM3STR06, IDC_COM3STR07}; |
| static const WORD com3rsmidi[3] = { | static const UINT16 com3rsmidi[3] = { |
| IDC_COM3STR10, IDC_COM3STR11, IDC_COM3STR12}; | IDC_COM3STR10, IDC_COM3STR11, IDC_COM3STR12}; |
| static const DLGCOM_P res_com3 = | static const DLGCOM_P res_com3 = |
| Line 119 static const DLGCOM_P res_com3 = | Line 120 static const DLGCOM_P res_com3 = |
| com3serial, com3rsmidi, SYS_UPDATESERIAL1}; | com3serial, com3rsmidi, SYS_UPDATESERIAL1}; |
| static void dlgcom_show(HWND hWnd, int ncmd, const WORD *item, int items) { | static void dlgcom_show(HWND hWnd, int ncmd, const UINT16 *item, int items) { |
| while(items--) { | while(items--) { |
| ShowWindow(GetDlgItem(hWnd, *item++), ncmd); | ShowWindow(GetDlgItem(hWnd, *item++), ncmd); |
| Line 143 static void dlgcom_items(HWND hWnd, cons | Line 144 static void dlgcom_items(HWND hWnd, cons |
| 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) { |
| DWORD d; | UINT32 d; |
| BYTE 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; |
| COMMNG cm; | |
| switch (msg) { | switch (msg) { |
| case WM_INITDIALOG: | case WM_INITDIALOG: |
| Line 162 static LRESULT CALLBACK dlgitem_proc(HWN | Line 164 static LRESULT CALLBACK dlgitem_proc(HWN |
| SETLISTUINT32(hWnd, m->idc[ID_CHARS], rscharsize); | SETLISTUINT32(hWnd, m->idc[ID_CHARS], rscharsize); |
| SETLISTSTR(hWnd, m->idc[ID_PARITY], rsparity); | SETLISTSTR(hWnd, m->idc[ID_PARITY], rsparity); |
| SETLISTSTR(hWnd, m->idc[ID_SBIT], rsstopbit); | SETLISTSTR(hWnd, m->idc[ID_SBIT], rsstopbit); |
| for (d=0; d<(sizeof(cmserial_speed)/sizeof(UINT32))-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 196 static LRESULT CALLBACK dlgitem_proc(HWN | Line 198 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 >= (sizeof(rsport)/sizeof(char *))) { | if (d >= NELEMENTS(rsport)) { |
| d = 0; | d = 0; |
| } | } |
| SendDlgItemMessage(hWnd, m->idc[ID_PORT], | SendDlgItemMessage(hWnd, m->idc[ID_PORT], |
| Line 219 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], |
| CB_GETCURSEL, (WPARAM)0, (LPARAM)0); | CB_GETCURSEL, (WPARAM)0, (LPARAM)0); |
| if (r != CB_ERR) { | if (r != CB_ERR) { |
| if ((UINT)r >= (sizeof(rsport)/sizeof(char *))) { | if ((UINT)r >= NELEMENTS(rsport)) { |
| r = 0; | r = 0; |
| } | } |
| if (cfg->port != (BYTE)r) { | if (cfg->port != (UINT8)r) { |
| cfg->port = (BYTE)r; | cfg->port = (UINT8)r; |
| update |= SYS_UPDATEOSCFG; | update |= SYS_UPDATEOSCFG; |
| update |= m->update; | update |= m->update; |
| } | } |
| Line 237 static LRESULT CALLBACK dlgitem_proc(HWN | Line 239 static LRESULT CALLBACK dlgitem_proc(HWN |
| 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); |
| if (r != CB_ERR) { | if (r != CB_ERR) { |
| if ((UINT)r >= (sizeof(cmserial_speed)/sizeof(UINT32))) { | if ((UINT)r >= NELEMENTS(cmserial_speed)) { |
| r = 0; | r = 0; |
| } | } |
| if (cfg->speed != cmserial_speed[r]) { | if (cfg->speed != cmserial_speed[r]) { |
| Line 251 static LRESULT CALLBACK dlgitem_proc(HWN | Line 253 static LRESULT CALLBACK dlgitem_proc(HWN |
| r = SendDlgItemMessage(hWnd, m->idc[ID_CHARS], | r = SendDlgItemMessage(hWnd, m->idc[ID_CHARS], |
| CB_GETCURSEL, (WPARAM)0, (LPARAM)0); | CB_GETCURSEL, (WPARAM)0, (LPARAM)0); |
| if (r != CB_ERR) { | if (r != CB_ERR) { |
| b |= (BYTE)(((UINT)r & 3) << 2); | b |= (UINT8)(((UINT)r & 3) << 2); |
| } | } |
| r = SendDlgItemMessage(hWnd, m->idc[ID_PARITY], | r = SendDlgItemMessage(hWnd, m->idc[ID_PARITY], |
| CB_GETCURSEL, (WPARAM)0, (LPARAM)0); | CB_GETCURSEL, (WPARAM)0, (LPARAM)0); |
| if (r != CB_ERR) { | if (r != CB_ERR) { |
| if ((UINT)r) { | if ((UINT)r) { |
| b |= 0x10; | b |= 0x10; |
| b |= (BYTE)((((UINT)r - 1) & 1) << 5); | b |= (UINT8)((((UINT)r - 1) & 1) << 5); |
| } | } |
| } | } |
| r = SendDlgItemMessage(hWnd, m->idc[ID_SBIT], | r = SendDlgItemMessage(hWnd, m->idc[ID_SBIT], |
| CB_GETCURSEL, (WPARAM)0, (LPARAM)0); | CB_GETCURSEL, (WPARAM)0, (LPARAM)0); |
| if (r != CB_ERR) { | if (r != CB_ERR) { |
| b |= (BYTE)((((UINT)r + 1) & 3) << 6); | b |= (UINT8)((((UINT)r + 1) & 3) << 6); |
| } | } |
| if (cfg->param != b) { | if (cfg->param != b) { |
| cfg->param = b; | cfg->param = b; |
| Line 273 static LRESULT CALLBACK dlgitem_proc(HWN | Line 275 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; | |
| 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, 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; |
| // 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 325 static LRESULT CALLBACK Com3Proc(HWND hW | Line 333 static LRESULT CALLBACK Com3Proc(HWND hW |
| // -------------------------------------------------------------------- | // -------------------------------------------------------------------- |
| static BYTE pc9861_s[3]; | static UINT8 pc9861_s[3]; |
| static BYTE pc9861_j[6]; | static UINT8 pc9861_j[6]; |
| typedef struct { | typedef struct { |
| int idc_speed; | int idc_speed; |
| int idc_int; | int idc_int; |
| int idc_mode; | int idc_mode; |
| BYTE *dip_mode; | UINT8 *dip_mode; |
| BYTE *dip_int; | UINT8 *dip_int; |
| BYTE sft_int; | UINT8 sft_int; |
| } PC9861MODE_T; | } PC9861MODE_T; |
| static const PC9861MODE_T pc9861mode[2] = { | static const PC9861MODE_T pc9861mode[2] = { |
| Line 343 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}; |
| 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}; |
| static void setdip(BYTE *image, int px, int py, int align, BYTE v, BYTE c) { | |
| int i, y; | |
| px *= 9; | |
| px++; | |
| py *= 9; | |
| while(c--) { | |
| y = py + ((v&0x01)?5:9); | |
| for (i=0; i<3; i++) { | |
| dlgs_linex(image, px, y+i, 7, align, 0); | |
| } | |
| px+=9; | |
| v>>=1; | |
| } | |
| } | |
| static void setjmp(BYTE *image, int px, int py, int align, BYTE v, BYTE c) { | |
| while(c--) { | |
| if (v & 0x01) { | |
| dlgs_setjumpery(image, px, py, align); | |
| } | |
| px++; | |
| v >>= 1; | |
| } | |
| } | |
| static void pc9861getspeed(HWND hWnd, const PC9861MODE_T *m) { | static void pc9861getspeed(HWND hWnd, const PC9861MODE_T *m) { |
| LRESULT r; | LRESULT r; |
| BYTE mode; | UINT8 mode; |
| 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) { |
| DWORD speed = r; | UINT speed = (UINT)r; |
| if (speed > ((sizeof(pc9861k_speed) / sizeof(UINT32)) - 1)) { | if (speed > (NELEMENTS(pc9861k_speed) - 1)) { |
| speed = (sizeof(pc9861k_speed) / sizeof(UINT32)) - 1; | speed = NELEMENTS(pc9861k_speed) - 1; |
| } | } |
| if (mode & 2) { | if (mode & 2) { |
| speed += 3; | speed += 3; |
| Line 430 static void pc9861getspeed(HWND hWnd, co | Line 409 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) { |
| for (i=0; i<(sizeof(pc9861d2int)/sizeof(UINT)); i++) { | for (i=0; i<NELEMENTS(pc9861d2int); i++) { |
| if (pc9861d2int[i] == (UINT)(r & 3)) { | if (pc9861d2int[i] == (UINT)(r & 3)) { |
| *(m->dip_int) &= ~(0x03 << (m->sft_int)); | *(m->dip_int) &= ~(0x03 << (m->sft_int)); |
| *(m->dip_int) |= (BYTE)(i << (m->sft_int)); | *(m->dip_int) |= (UINT8)(i << (m->sft_int)); |
| break; | break; |
| } | } |
| } | } |
| } | } |
| } | } |
| static void pc9861getmode(HWND hWnd, const PC9861MODE_T *m) { | static void pc9861getmode(HWND hWnd, const PC9861MODE_T *m) { |
| LRESULT r; | LRESULT r; |
| BYTE i; | UINT8 i; |
| r = SendDlgItemMessage(hWnd, m->idc_mode, CB_GETCURSEL, 0, 0); | r = SendDlgItemMessage(hWnd, m->idc_mode, CB_GETCURSEL, 0, 0); |
| if (r != CB_ERR) { | if (r != CB_ERR) { |
| for (i=0; i<(sizeof(pc9861d2sync)/sizeof(UINT)); i++) { | for (i=0; i<NELEMENTS(pc9861d2sync); i++) { |
| if (pc9861d2sync[i] == (UINT)(r & 3)) { | if (pc9861d2sync[i] == (UINT)(r & 3)) { |
| *(m->dip_mode) &= (~3); | *(m->dip_mode) &= (~3); |
| *(m->dip_mode) |= i; | *(m->dip_mode) |= i; |
| Line 464 static void pc9861getmode(HWND hWnd, con | Line 442 static void pc9861getmode(HWND hWnd, con |
| static void pc9861setmode(HWND hWnd, const PC9861MODE_T *m) { | static void pc9861setmode(HWND hWnd, const PC9861MODE_T *m) { |
| DWORD speed; | UINT speed; |
| DWORD mode; | UINT mode; |
| DWORD intnum; | UINT intnum; |
| BYTE modedip; | UINT8 modedip; |
| modedip = *(m->dip_mode); | modedip = *(m->dip_mode); |
| speed = (((~modedip) >> 2) & 0x0f) + 1; | speed = (((~modedip) >> 2) & 0x0f) + 1; |
| Line 479 static void pc9861setmode(HWND hWnd, con | Line 457 static void pc9861setmode(HWND hWnd, con |
| speed = 0; | speed = 0; |
| } | } |
| } | } |
| if (speed > ((sizeof(pc9861k_speed) / sizeof(UINT32)) - 1)) { | if (speed > (NELEMENTS(pc9861k_speed) - 1)) { |
| speed = (sizeof(pc9861k_speed) / sizeof(UINT32)) - 1; | speed = NELEMENTS(pc9861k_speed) - 1; |
| } | } |
| SendDlgItemMessage(hWnd, m->idc_speed, | SendDlgItemMessage(hWnd, m->idc_speed, |
| Line 495 static void pc9861setmode(HWND hWnd, con | Line 473 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; | |
| UINT8 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; |
| BYTE *image; | p.y += rect2.top - rect1.top; |
| HANDLE hwork; | p.x /= 9; |
| BITMAPINFO *work; | p.y /= 9; |
| BYTE *imgbtm; | if ((p.y >= 1) && (p.y < 3)) { // 1段目 |
| int align; | if ((p.x >= 1) && (p.x < 7)) { // S1 |
| pc9861_s[0] ^= (1 << (p.x - 1)); | |
| switch(msg) { | pc9861setmode(hWnd, pc9861mode); |
| case WM_PAINT: | } |
| hdc = BeginPaint(hWnd, &ps); | else if ((p.x >= 10) && (p.x < 14)) { // S2 |
| if ((hwork = GlobalAlloc(GPTR, bit2res_getsize(&pc9861dip))) | pc9861_s[1] ^= (1 << (p.x - 10)); |
| == NULL) { | pc9861setmode(hWnd, pc9861mode); |
| break; | pc9861setmode(hWnd, pc9861mode+1); |
| } | } |
| if ((work = (BITMAPINFO *)GlobalLock(hwork)) == NULL) { | else if ((p.x >= 17) && (p.x < 23)) { // S3 |
| GlobalFree(hwork); | pc9861_s[2] ^= (1 << (p.x - 17)); |
| break; | 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; | |
| } | } |
| bit2res_sethead(work, &pc9861dip); | pc9861_j[3] = bit; |
| hBitmap = CreateDIBSection(hdc, work, DIB_RGB_COLORS, | } |
| (void **)&image, NULL, 0); | else if ((p.x >= 11) && (p.x < 17)) { // J5 |
| bit2res_setdata(image, &pc9861dip); | pc9861_j[4] ^= (1 << (p.x - 11)); |
| align = ((pc9861dip.x + 7) / 2) & ~3; | } |
| imgbtm = image + align * (pc9861dip.y - 1); | else if ((p.x >= 19) && (p.x < 25)) { // J6 |
| setdip(imgbtm, PC9861S1_X, PC9861S_Y, align, pc9861_s[0], 6); | pc9861_j[5] ^= (1 << (p.x - 19)); |
| 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); | |
| } | } |
| 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; | UINT8 r; |
| POINT p; | |
| BYTE r; | |
| UINT update; | UINT update; |
| switch (msg) { | switch (msg) { |
| Line 577 static LRESULT CALLBACK pc9861mainProc(H | Line 553 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 616 static LRESULT CALLBACK pc9861mainProc(H | Line 591 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 682 static LRESULT CALLBACK pc9861mainProc(H | Line 601 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 701 static LRESULT CALLBACK pc9861mainProc(H | Line 620 static LRESULT CALLBACK pc9861mainProc(H |
| return(TRUE); | return(TRUE); |
| } | } |
| break; | break; |
| case WM_DRAWITEM: | |
| if (LOWORD(wp) == IDC_PC9861DIP) { | |
| dlgs_drawbmp(((LPDRAWITEMSTRUCT)lp)->hDC, | |
| dipswbmp_get9861(pc9861_s, pc9861_j)); | |
| } | |
| return(FALSE); | |
| } | } |
| return(FALSE); | return(FALSE); |
| } | } |
| Line 715 void dialog_serial(HWND hWnd) { | Line 641 void dialog_serial(HWND hWnd) { |
| PROPSHEETHEADER psh; | PROPSHEETHEADER psh; |
| HPROPSHEETPAGE hpsp[4]; | HPROPSHEETPAGE hpsp[4]; |
| hinst = (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE); | hinst = (HINSTANCE)GetWindowLongPtr(hWnd, GWLP_HINSTANCE); |
| ZeroMemory(&psp, sizeof(psp)); | ZeroMemory(&psp, sizeof(psp)); |
| psp.dwSize = sizeof(PROPSHEETPAGE); | psp.dwSize = sizeof(PROPSHEETPAGE); |
| Line 740 void dialog_serial(HWND hWnd) { | Line 666 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); |
| } | } |