diff --git a/src/amstrad.c b/src/amstrad.c index 2582f3d..bd70f05 100644 --- a/src/amstrad.c +++ b/src/amstrad.c @@ -35,41 +35,72 @@ void amstrad_write(uint16_t port, uint8_t val, void *priv) } } -static uint8_t mousex,mousey; - -void amstrad_mouse_write(uint16_t addr, uint8_t val, void *priv) +static uint8_t mousex, mousey; +static void amstrad_mouse_write(uint16_t addr, uint8_t val, void *p) { // pclog("Write mouse %04X %02X %04X:%04X\n", addr, val, CS, pc); - if (addr==0x78) mousex=0; - else mousey=0; + if (addr == 0x78) + mousex = 0; + else + mousey = 0; } -uint8_t amstrad_mouse_read(uint16_t addr, void *priv) +static uint8_t amstrad_mouse_read(uint16_t addr, void *p) { // printf("Read mouse %04X %04X:%04X %02X\n", addr, CS, pc, (addr == 0x78) ? mousex : mousey); - if (addr==0x78) return mousex; + if (addr == 0x78) + return mousex; return mousey; } -static int oldb = 0; - -void amstrad_mouse_poll(int x, int y, int b) +typedef struct mouse_amstrad_t { + int oldb; +} mouse_amstrad_t; + +static void mouse_amstrad_poll(int x, int y, int b, void *p) +{ + mouse_amstrad_t *mouse = (mouse_amstrad_t *)p; + mousex += x; mousey -= y; - if ((b & 1) && !(oldb & 1)) - keyboard_send(0x7e); - if ((b & 2) && !(oldb & 2)) - keyboard_send(0x7d); - if (!(b & 1) && (oldb & 1)) - keyboard_send(0xfe); - if (!(b & 2) && (oldb & 2)) - keyboard_send(0xfd); + if ((b & 1) && !(mouse->oldb & 1)) + keyboard_send(0x7e); + if ((b & 2) && !(mouse->oldb & 2)) + keyboard_send(0x7d); + if (!(b & 1) && (mouse->oldb & 1)) + keyboard_send(0xfe); + if (!(b & 2) && (mouse->oldb & 2)) + keyboard_send(0xfd); - oldb = b; + mouse->oldb = b; } +static void *mouse_amstrad_init() +{ + mouse_amstrad_t *mouse = (mouse_amstrad_t *)malloc(sizeof(mouse_amstrad_t)); + memset(mouse, 0, sizeof(mouse_amstrad_t)); + + return mouse; +} + +static void mouse_amstrad_close(void *p) +{ + mouse_amstrad_t *mouse = (mouse_amstrad_t *)p; + + free(mouse); +} + +mouse_t mouse_amstrad = +{ + "Amstrad mouse", + mouse_amstrad_init, + mouse_amstrad_close, + mouse_amstrad_poll, + MOUSE_TYPE_AMSTRAD +}; + void amstrad_init() { lpt2_remove_ams(); @@ -78,6 +109,4 @@ void amstrad_init() io_sethandler(0x007a, 0x0001, amstrad_mouse_read, NULL, NULL, amstrad_mouse_write, NULL, NULL, NULL); io_sethandler(0x0379, 0x0002, amstrad_read, NULL, NULL, NULL, NULL, NULL, NULL); io_sethandler(0xdead, 0x0001, amstrad_read, NULL, NULL, amstrad_write, NULL, NULL, NULL); - - mouse_poll = amstrad_mouse_poll; } diff --git a/src/amstrad.h b/src/amstrad.h index f6deaff..a4250d3 100644 --- a/src/amstrad.h +++ b/src/amstrad.h @@ -1,2 +1,3 @@ void amstrad_init(); +extern mouse_t mouse_amstrad; diff --git a/src/keyboard_at.c b/src/keyboard_at.c index 7b45166..24697e2 100644 --- a/src/keyboard_at.c +++ b/src/keyboard_at.c @@ -38,6 +38,9 @@ struct int key_wantdata; int last_irq; + + void (*mouse_write)(uint8_t val, void *p); + void *mouse_p; } keyboard_at; static uint8_t key_ctrl_queue[16]; @@ -199,8 +202,8 @@ void keyboard_at_write(uint16_t port, uint8_t val, void *priv) break; case 0xd4: /*Write to mouse*/ - if (mouse_write) - mouse_write(val); + if (keyboard_at.mouse_write) + keyboard_at.mouse_write(val, keyboard_at.mouse_p); break; default: @@ -483,7 +486,14 @@ void keyboard_at_init() keyboard_at_reset(); keyboard_send = keyboard_at_adddata_keyboard; keyboard_poll = keyboard_at_poll; - mouse_write = NULL; + keyboard_at.mouse_write = NULL; + keyboard_at.mouse_p = NULL; timer_add(keyboard_at_poll, &keybsenddelay, TIMER_ALWAYS_ENABLED, NULL); } + +void keyboard_at_set_mouse(void (*mouse_write)(uint8_t val, void *p), void *p) +{ + keyboard_at.mouse_write = mouse_write; + keyboard_at.mouse_p = p; +} diff --git a/src/keyboard_at.h b/src/keyboard_at.h index 9e51247..81ea50d 100644 --- a/src/keyboard_at.h +++ b/src/keyboard_at.h @@ -1,7 +1,7 @@ void keyboard_at_init(); void keyboard_at_reset(); void keyboard_at_poll(); +void keyboard_at_set_mouse(void (*mouse_write)(uint8_t val, void *p), void *p); -void (*mouse_write)(uint8_t val); extern int mouse_queue_start, mouse_queue_end; extern int mouse_scan; diff --git a/src/keyboard_olim24.c b/src/keyboard_olim24.c index 4986a65..22ac4d6 100644 --- a/src/keyboard_olim24.c +++ b/src/keyboard_olim24.c @@ -216,85 +216,124 @@ void keyboard_olim24_reset() mouse_scancodes[6] = 0x50; } -static int mouse_x = 0, mouse_y = 0, mouse_b = 0; -void mouse_olim24_poll(int x, int y, int b) +typedef struct mouse_olim24_t { - mouse_x += x; - mouse_y += y; + int x, y, b; +} mouse_olim24_t; - pclog("mouse_poll - %i, %i %i, %i\n", x, y, mouse_x, mouse_y); +void mouse_olim24_poll(int x, int y, int b, void *p) +{ + mouse_olim24_t *mouse = (mouse_olim24_t *)p; - if (((key_queue_end - key_queue_start) & 0xf) > 14) return; - if ((b & 1) && !(mouse_b & 1)) - keyboard_olim24_adddata(mouse_scancodes[0]); - if (!(b & 1) && (mouse_b & 1)) - keyboard_olim24_adddata(mouse_scancodes[0] | 0x80); - mouse_b = (mouse_b & ~1) | (b & 1); + mouse->x += x; + mouse->y += y; + +// pclog("mouse_poll - %i, %i %i, %i\n", x, y, mouse->x, mouse->y); - if (((key_queue_end - key_queue_start) & 0xf) > 14) return; - if ((b & 2) && !(mouse_b & 2)) - keyboard_olim24_adddata(mouse_scancodes[2]); - if (!(b & 2) && (mouse_b & 2)) - keyboard_olim24_adddata(mouse_scancodes[2] | 0x80); - mouse_b = (mouse_b & ~2) | (b & 2); + if (((key_queue_end - key_queue_start) & 0xf) > 14) + return; + if ((b & 1) && !(mouse->b & 1)) + keyboard_olim24_adddata(mouse_scancodes[0]); + if (!(b & 1) && (mouse->b & 1)) + keyboard_olim24_adddata(mouse_scancodes[0] | 0x80); + mouse->b = (mouse->b & ~1) | (b & 1); - if (((key_queue_end - key_queue_start) & 0xf) > 14) return; - if ((b & 4) && !(mouse_b & 4)) - keyboard_olim24_adddata(mouse_scancodes[1]); - if (!(b & 4) && (mouse_b & 4)) - keyboard_olim24_adddata(mouse_scancodes[1] | 0x80); - mouse_b = (mouse_b & ~4) | (b & 4); + if (((key_queue_end - key_queue_start) & 0xf) > 14) + return; + if ((b & 2) && !(mouse->b & 2)) + keyboard_olim24_adddata(mouse_scancodes[2]); + if (!(b & 2) && (mouse->b & 2)) + keyboard_olim24_adddata(mouse_scancodes[2] | 0x80); + mouse->b = (mouse->b & ~2) | (b & 2); + + if (((key_queue_end - key_queue_start) & 0xf) > 14) + return; + if ((b & 4) && !(mouse->b & 4)) + keyboard_olim24_adddata(mouse_scancodes[1]); + if (!(b & 4) && (mouse->b & 4)) + keyboard_olim24_adddata(mouse_scancodes[1] | 0x80); + mouse->b = (mouse->b & ~4) | (b & 4); if (keyboard_olim24.mouse_mode) { - if (((key_queue_end - key_queue_start) & 0xf) > 12) return; - if (!mouse_x && !mouse_y) return; + if (((key_queue_end - key_queue_start) & 0xf) > 12) + return; + if (!mouse->x && !mouse->y) + return; - mouse_y = -mouse_y; + mouse->y = -mouse->y; - if (mouse_x < -127) mouse_x = -127; - if (mouse_x > 127) mouse_x = 127; - if (mouse_x < -127) mouse_x = 0x80 | ((-mouse_x) & 0x7f); + if (mouse->x < -127) mouse->x = -127; + if (mouse->x > 127) mouse->x = 127; + if (mouse->x < -127) mouse->x = 0x80 | ((-mouse->x) & 0x7f); - if (mouse_y < -127) mouse_y = -127; - if (mouse_y > 127) mouse_y = 127; - if (mouse_y < -127) mouse_y = 0x80 | ((-mouse_y) & 0x7f); + if (mouse->y < -127) mouse->y = -127; + if (mouse->y > 127) mouse->y = 127; + if (mouse->y < -127) mouse->y = 0x80 | ((-mouse->y) & 0x7f); keyboard_olim24_adddata(0xfe); - keyboard_olim24_adddata(mouse_x); - keyboard_olim24_adddata(mouse_y); + keyboard_olim24_adddata(mouse->x); + keyboard_olim24_adddata(mouse->y); - mouse_x = mouse_y = 0; + mouse->x = mouse->y = 0; } else { - while (mouse_x < -4) + while (mouse->x < -4) { - if (((key_queue_end - key_queue_start) & 0xf) > 14) return; - mouse_x+=4; + if (((key_queue_end - key_queue_start) & 0xf) > 14) + return; + mouse->x += 4; keyboard_olim24_adddata(mouse_scancodes[3]); } - while (mouse_x > 4) + while (mouse->x > 4) { - if (((key_queue_end - key_queue_start) & 0xf) > 14) return; - mouse_x-=4; + if (((key_queue_end - key_queue_start) & 0xf) > 14) + return; + mouse->x -= 4; keyboard_olim24_adddata(mouse_scancodes[4]); } - while (mouse_y < -4) + while (mouse->y < -4) { - if (((key_queue_end - key_queue_start) & 0xf) > 14) return; - mouse_y+=4; + if (((key_queue_end - key_queue_start) & 0xf) > 14) + return; + mouse->y += 4; keyboard_olim24_adddata(mouse_scancodes[5]); } - while (mouse_y > 4) + while (mouse->y > 4) { - if (((key_queue_end - key_queue_start) & 0xf) > 14) return; - mouse_y-=4; + if (((key_queue_end - key_queue_start) & 0xf) > 14) + return; + mouse->y -= 4; keyboard_olim24_adddata(mouse_scancodes[6]); } } } +static void *mouse_olim24_init() +{ + mouse_olim24_t *mouse = (mouse_olim24_t *)malloc(sizeof(mouse_olim24_t)); + memset(mouse, 0, sizeof(mouse_olim24_t)); + + return mouse; +} + +static void mouse_olim24_close(void *p) +{ + mouse_olim24_t *mouse = (mouse_olim24_t *)p; + + free(mouse); +} + +mouse_t mouse_olim24 = +{ + "Olivetti M24 mouse", + mouse_olim24_init, + mouse_olim24_close, + mouse_olim24_poll, + MOUSE_TYPE_OLIM24 +}; + void keyboard_olim24_init() { //return; @@ -303,7 +342,6 @@ void keyboard_olim24_init() keyboard_olim24_reset(); keyboard_send = keyboard_olim24_adddata; keyboard_poll = keyboard_olim24_poll; - mouse_poll = mouse_olim24_poll; timer_add(keyboard_olim24_poll, &keybsenddelay, TIMER_ALWAYS_ENABLED, NULL); } diff --git a/src/keyboard_olim24.h b/src/keyboard_olim24.h index 5400713..dea40f9 100644 --- a/src/keyboard_olim24.h +++ b/src/keyboard_olim24.h @@ -1,3 +1,5 @@ void keyboard_olim24_init(); void keyboard_olim24_reset(); void keyboard_olim24_poll(); + +extern mouse_t mouse_olim24; diff --git a/src/model.c b/src/model.c index 8cb710e..9da2d28 100644 --- a/src/model.c +++ b/src/model.c @@ -2,6 +2,7 @@ #include "cpu.h" #include "model.h" #include "io.h" +#include "mouse.h" #include "acer386sx.h" #include "ali1429.h" @@ -26,8 +27,6 @@ #include "keyboard_pcjr.h" #include "keyboard_xt.h" #include "lpt.h" -#include "mouse_ps2.h" -#include "mouse_serial.h" #include "neat.h" #include "nmi.h" #include "nvr.h" @@ -96,35 +95,35 @@ MODEL models[] = {"Tandy 1000", ROM_TANDY, { "", cpus_8088, "", NULL, "", NULL}, 1, 0, 128, 640, 128, tandy1k_init, &tandy1000_device}, {"Tandy 1000 HX", ROM_TANDY1000HX, { "", cpus_8088, "", NULL, "", NULL}, 1, 0, 256, 640, 128, tandy1k_init, &tandy1000hx_device}, {"Tandy 1000 SL/2", ROM_TANDY1000SL2,{ "", cpus_8086, "", NULL, "", NULL}, 1, 0, 512, 768, 128, tandy1ksl2_init, NULL}, - {"Amstrad PC1512", ROM_PC1512, { "", cpus_pc1512, "", NULL, "", NULL}, 1, 0, 512, 640, 128, ams_init, NULL}, - {"Sinclair PC200", ROM_PC200, { "", cpus_8086, "", NULL, "", NULL}, 1, 0, 512, 640, 128, ams_init, NULL}, + {"Amstrad PC1512", ROM_PC1512, { "", cpus_pc1512, "", NULL, "", NULL}, 1, MODEL_AMSTRAD, 512, 640, 128, ams_init, NULL}, + {"Sinclair PC200", ROM_PC200, { "", cpus_8086, "", NULL, "", NULL}, 1, MODEL_AMSTRAD, 512, 640, 128, ams_init, NULL}, {"Euro PC", ROM_EUROPC, { "", cpus_8086, "", NULL, "", NULL}, 0, 0, 512, 640, 128, europc_init, NULL}, - {"Olivetti M24", ROM_OLIM24, { "", cpus_8086, "", NULL, "", NULL}, 1, 0, 128, 640, 128, olim24_init, NULL}, - {"Amstrad PC1640", ROM_PC1640, { "", cpus_8086, "", NULL, "", NULL}, 1, 0, 640, 640, 0, ams_init, NULL}, - {"Amstrad PC2086", ROM_PC2086, { "", cpus_8086, "", NULL, "", NULL}, 1, 0, 640, 640, 0, ams_init, NULL}, - {"Amstrad PC3086", ROM_PC3086, { "", cpus_8086, "", NULL, "", NULL}, 1, 0, 640, 640, 0, ams_init, NULL}, - {"IBM AT", ROM_IBMAT, { "", cpus_ibmat, "", NULL, "", NULL}, 0, 1, 1, 16, 1, at_init, NULL}, - {"Commodore PC 30 III", ROM_CMDPC30, { "", cpus_286, "", NULL, "", NULL}, 0, 1, 1, 16, 1, at_init, NULL}, - {"AMI 286 clone", ROM_AMI286, { "", cpus_286, "", NULL, "", NULL}, 0, 1, 1, 16, 1, at_neat_init, NULL}, - {"Award 286 clone", ROM_AWARD286, { "", cpus_286, "", NULL, "", NULL}, 0, 1, 1, 16, 1, at_scat_init, NULL}, - {"DELL System 200", ROM_DELL200, { "", cpus_286, "", NULL, "", NULL}, 0, 1, 1, 16, 1, at_init, NULL}, - {"IBM PS/1 model 2011", ROM_IBMPS1_2011, { "", cpus_ps1_m2011,"", NULL, "", NULL}, 1, 1, 1, 16, 1, ps1_m2011_init, NULL}, - {"IBM PS/1 model 2121", ROM_IBMPS1_2121, { "Intel", cpus_i386, "", NULL, "", NULL}, 1, 1, 1, 16, 1, ps1_m2121_init, NULL}, - {"Compaq Deskpro 386", ROM_DESKPRO_386, { "Intel", cpus_i386, "AMD", cpus_Am386, "Cyrix", cpus_486SDLC}, 0, 1, 1, 15, 1, deskpro386_init, NULL}, - {"Acer 386SX25/N", ROM_ACER386, { "Intel", cpus_acer, "", NULL, "", NULL}, 1, 1, 1, 16, 1, at_acer386sx_init, NULL}, - {"DTK 386SX clone", ROM_DTK386, { "Intel", cpus_i386, "AMD", cpus_Am386, "Cyrix", cpus_486SDLC}, 0, 1, 1, 16, 1, at_neat_init, NULL}, - {"Phoenix 386 clone", ROM_PX386, { "Intel", cpus_i386, "AMD", cpus_Am386, "Cyrix", cpus_486SDLC}, 0, 1, 1, 16, 1, at_init, NULL}, - {"Amstrad MegaPC", ROM_MEGAPC, { "Intel", cpus_i386, "AMD", cpus_Am386, "Cyrix", cpus_486SDLC}, 1, 1, 1, 16, 1, at_wd76c10_init, NULL}, - {"AMI 386SX clone", ROM_AMI386SX, { "Intel", cpus_i386, "AMD", cpus_Am386, "Cyrix", cpus_486SDLC}, 0, 1, 1, 256, 1, at_headland_init, NULL}, - {"MR 386DX clone", ROM_MR386DX_OPTI495, { "Intel", cpus_i386DX, "AMD", cpus_Am386DX, "Cyrix", cpus_486DLC}, 0, 1, 1, 256, 1, at_opti495_init, NULL}, - {"AMI 386DX clone", ROM_AMI386DX_OPTI495, { "Intel", cpus_i386DX, "AMD", cpus_Am386DX, "Cyrix", cpus_486DLC}, 0, 1, 1, 256, 1, at_opti495_init, NULL}, - {"AMI 486 clone", ROM_AMI486, { "Intel", cpus_i486, "AMD", cpus_Am486, "Cyrix", cpus_Cx486}, 0, 1, 1, 256, 1, at_ali1429_init, NULL}, - {"AMI WinBIOS 486", ROM_WIN486, { "Intel", cpus_i486, "AMD", cpus_Am486, "Cyrix", cpus_Cx486}, 0, 1, 1, 256, 1, at_ali1429_init, NULL}, + {"Olivetti M24", ROM_OLIM24, { "", cpus_8086, "", NULL, "", NULL}, 1, MODEL_OLIM24, 128, 640, 128, olim24_init, NULL}, + {"Amstrad PC1640", ROM_PC1640, { "", cpus_8086, "", NULL, "", NULL}, 1, MODEL_AMSTRAD, 640, 640, 0, ams_init, NULL}, + {"Amstrad PC2086", ROM_PC2086, { "", cpus_8086, "", NULL, "", NULL}, 1, MODEL_AMSTRAD, 640, 640, 0, ams_init, NULL}, + {"Amstrad PC3086", ROM_PC3086, { "", cpus_8086, "", NULL, "", NULL}, 1, MODEL_AMSTRAD, 640, 640, 0, ams_init, NULL}, + {"IBM AT", ROM_IBMAT, { "", cpus_ibmat, "", NULL, "", NULL}, 0, MODEL_AT, 1, 16, 1, at_init, NULL}, + {"Commodore PC 30 III", ROM_CMDPC30, { "", cpus_286, "", NULL, "", NULL}, 0, MODEL_AT, 1, 16, 1, at_init, NULL}, + {"AMI 286 clone", ROM_AMI286, { "", cpus_286, "", NULL, "", NULL}, 0, MODEL_AT, 1, 16, 1, at_neat_init, NULL}, + {"Award 286 clone", ROM_AWARD286, { "", cpus_286, "", NULL, "", NULL}, 0, MODEL_AT, 1, 16, 1, at_scat_init, NULL}, + {"DELL System 200", ROM_DELL200, { "", cpus_286, "", NULL, "", NULL}, 0, MODEL_AT, 1, 16, 1, at_init, NULL}, + {"IBM PS/1 model 2011", ROM_IBMPS1_2011, { "", cpus_ps1_m2011,"", NULL, "", NULL}, 1, MODEL_AT|MODEL_PS2, 1, 16, 1, ps1_m2011_init, NULL}, + {"IBM PS/1 model 2121", ROM_IBMPS1_2121, { "Intel", cpus_i386, "", NULL, "", NULL}, 1, MODEL_AT|MODEL_PS2, 1, 16, 1, ps1_m2121_init, NULL}, + {"Compaq Deskpro 386", ROM_DESKPRO_386, { "Intel", cpus_i386, "AMD", cpus_Am386, "Cyrix", cpus_486SDLC}, 0, MODEL_AT, 1, 15, 1, deskpro386_init, NULL}, + {"Acer 386SX25/N", ROM_ACER386, { "Intel", cpus_acer, "", NULL, "", NULL}, 1, MODEL_AT|MODEL_PS2, 1, 16, 1, at_acer386sx_init, NULL}, + {"DTK 386SX clone", ROM_DTK386, { "Intel", cpus_i386, "AMD", cpus_Am386, "Cyrix", cpus_486SDLC}, 0, MODEL_AT, 1, 16, 1, at_neat_init, NULL}, + {"Phoenix 386 clone", ROM_PX386, { "Intel", cpus_i386, "AMD", cpus_Am386, "Cyrix", cpus_486SDLC}, 0, MODEL_AT, 1, 16, 1, at_init, NULL}, + {"Amstrad MegaPC", ROM_MEGAPC, { "Intel", cpus_i386, "AMD", cpus_Am386, "Cyrix", cpus_486SDLC}, 1, MODEL_AT|MODEL_PS2, 1, 16, 1, at_wd76c10_init, NULL}, + {"AMI 386SX clone", ROM_AMI386SX, { "Intel", cpus_i386, "AMD", cpus_Am386, "Cyrix", cpus_486SDLC}, 0, MODEL_AT, 1, 256, 1, at_headland_init, NULL}, + {"MR 386DX clone", ROM_MR386DX_OPTI495, { "Intel", cpus_i386DX, "AMD", cpus_Am386DX, "Cyrix", cpus_486DLC}, 0, MODEL_AT, 1, 256, 1, at_opti495_init, NULL}, + {"AMI 386DX clone", ROM_AMI386DX_OPTI495, { "Intel", cpus_i386DX, "AMD", cpus_Am386DX, "Cyrix", cpus_486DLC}, 0, MODEL_AT, 1, 256, 1, at_opti495_init, NULL}, + {"AMI 486 clone", ROM_AMI486, { "Intel", cpus_i486, "AMD", cpus_Am486, "Cyrix", cpus_Cx486}, 0, MODEL_AT, 1, 256, 1, at_ali1429_init, NULL}, + {"AMI WinBIOS 486", ROM_WIN486, { "Intel", cpus_i486, "AMD", cpus_Am486, "Cyrix", cpus_Cx486}, 0, MODEL_AT, 1, 256, 1, at_ali1429_init, NULL}, /* {"AMI WinBIOS 486 PCI", ROM_PCI486, { "Intel", cpus_i486, "AMD", cpus_Am486, "Cyrix", cpus_Cx486}, 0, 1, 1, 256, 1, at_um8881f_init},*/ - {"Award SiS 496/497", ROM_SIS496, { "Intel", cpus_i486, "AMD", cpus_Am486, "Cyrix", cpus_Cx486}, 0, 1, 1, 256, 1, at_sis496_init, NULL}, - {"Intel Premiere/PCI", ROM_REVENGE, { "Intel", cpus_Pentium5V, "", NULL, "", NULL}, 0, 1, 1, 128, 1, at_batman_init, NULL}, - {"Intel Advanced/EV", ROM_ENDEAVOR, { "Intel", cpus_PentiumS5, "IDT", cpus_WinChip, "Cyrix", cpus_6x86, "", NULL}, 0, 1, 1, 128, 1, at_endeavor_init, NULL}, - {"Award 430VX PCI", ROM_430VX, { "Intel", cpus_Pentium, "IDT", cpus_WinChip, "Cyrix", cpus_6x86, "", NULL}, 0, 1, 1, 256, 1, at_i430vx_init, NULL}, + {"Award SiS 496/497", ROM_SIS496, { "Intel", cpus_i486, "AMD", cpus_Am486, "Cyrix", cpus_Cx486}, 0, MODEL_AT, 1, 256, 1, at_sis496_init, NULL}, + {"Intel Premiere/PCI", ROM_REVENGE, { "Intel", cpus_Pentium5V, "", NULL, "", NULL}, 0, MODEL_AT|MODEL_PS2, 1, 128, 1, at_batman_init, NULL}, + {"Intel Advanced/EV", ROM_ENDEAVOR, { "Intel", cpus_PentiumS5, "IDT", cpus_WinChip, "Cyrix", cpus_6x86, "", NULL}, 0, MODEL_AT|MODEL_PS2, 1, 128, 1, at_endeavor_init, NULL}, + {"Award 430VX PCI", ROM_430VX, { "Intel", cpus_Pentium, "IDT", cpus_WinChip, "Cyrix", cpus_6x86, "", NULL}, 0, MODEL_AT|MODEL_PS2, 1, 256, 1, at_i430vx_init, NULL}, {"", -1, {"", 0, "", 0, "", 0}, 0,0,0, 0} }; @@ -179,7 +178,6 @@ void xt_init() mem_add_bios(); pit_set_out_func(1, pit_refresh_timer_xt); keyboard_xt_init(); - mouse_serial_init(); xtide_init(); nmi_init(); device_add(&gameport_device); @@ -204,7 +202,6 @@ void tandy1k_init() common_init(); mem_add_bios(); keyboard_tandy_init(); - mouse_serial_init(); if (romset == ROM_TANDY) device_add(&sn76489_device); else @@ -221,7 +218,6 @@ void tandy1ksl2_init() common_init(); mem_add_bios(); keyboard_tandy_init(); - mouse_serial_init(); device_add(&pssj_device); xtide_init(); nmi_init(); @@ -250,7 +246,6 @@ void europc_init() mem_add_bios(); jim_init(); keyboard_xt_init(); - mouse_serial_init(); xtide_init(); nmi_init(); device_add(&gameport_device); @@ -277,8 +272,6 @@ void at_init() dma16_init(); ide_init(); keyboard_at_init(); - if (models[model].init == at_init) - mouse_serial_init(); nvr_init(); pic2_init(); device_add(&gameport_device); @@ -287,7 +280,6 @@ void at_init() void deskpro386_init() { at_init(); - mouse_serial_init(); compaq_init(); } @@ -300,7 +292,6 @@ void ps1_common_init() dma16_init(); ide_init(); keyboard_at_init(); - mouse_ps2_init(); nvr_init(); pic2_init(); fdc_set_dskchg_activelow(); @@ -325,28 +316,24 @@ void ps1_m2121_init() void at_neat_init() { at_init(); - mouse_serial_init(); neat_init(); } void at_scat_init() { at_init(); - mouse_serial_init(); scat_init(); } void at_acer386sx_init() { at_init(); - mouse_ps2_init(); acer386sx_init(); } void at_wd76c10_init() { at_init(); - mouse_ps2_init(); wd76c10_init(); } @@ -354,27 +341,23 @@ void at_headland_init() { at_init(); headland_init(); - mouse_serial_init(); } void at_opti495_init() { at_init(); opti495_init(); - mouse_serial_init(); } void at_ali1429_init() { at_init(); ali1429_init(); - mouse_serial_init(); } void at_um8881f_init() { at_init(); - mouse_serial_init(); pci_init(PCI_CONFIG_TYPE_1, 0, 31); um8881f_init(); } @@ -382,7 +365,6 @@ void at_um8881f_init() void at_sis496_init() { at_init(); - mouse_serial_init(); pci_init(PCI_CONFIG_TYPE_1, 0, 31); device_add(&sis496_device); } @@ -390,7 +372,6 @@ void at_sis496_init() void at_batman_init() { at_init(); - mouse_ps2_init(); pci_init(PCI_CONFIG_TYPE_2, 0xd, 0x10); i430lx_init(); fdc37c665_init(); @@ -400,7 +381,6 @@ void at_batman_init() void at_endeavor_init() { at_init(); - mouse_serial_init(); pci_init(PCI_CONFIG_TYPE_1, 0xd, 0x10); i430fx_init(); piix_init(7); @@ -412,7 +392,6 @@ void at_endeavor_init() void at_i430vx_init() { at_init(); - mouse_serial_init(); pci_init(PCI_CONFIG_TYPE_1, 0, 31); i430vx_init(); piix_init(7); diff --git a/src/model.h b/src/model.h index c5a3d26..78fd4c3 100644 --- a/src/model.h +++ b/src/model.h @@ -1,3 +1,8 @@ +#define MODEL_AT 1 +#define MODEL_PS2 2 +#define MODEL_AMSTRAD 4 +#define MODEL_OLIM24 8 + typedef struct { char name[24]; @@ -8,7 +13,7 @@ typedef struct CPU *cpus; } cpu[4]; int fixed_gfxcard; - int is_at; + int flags; int min_ram, max_ram; int ram_granularity; void (*init)(); diff --git a/src/mouse.c b/src/mouse.c index a9b45fe..75c08ca 100644 --- a/src/mouse.c +++ b/src/mouse.c @@ -1,4 +1,49 @@ #include "ibm.h" #include "mouse.h" +#include "amstrad.h" +#include "mouse_ps2.h" +#include "mouse_serial.h" +#include "keyboard_olim24.h" -void (*mouse_poll)(int x, int y, int b); +static mouse_t *mouse_list[] = +{ + &mouse_serial_microsoft, + &mouse_ps2_2_button, + &mouse_amstrad, + &mouse_olim24, + NULL +}; + +static mouse_t *cur_mouse; +static void *mouse_p; +int mouse_type = 0; + +void mouse_emu_init() +{ + cur_mouse = mouse_list[mouse_type]; + mouse_p = cur_mouse->init(); +} + +void mouse_emu_close() +{ + if (cur_mouse) + cur_mouse->close(mouse_p); + cur_mouse = NULL; +} + +void mouse_poll(int x, int y, int b) +{ + if (cur_mouse) + cur_mouse->poll(x, y, b, mouse_p); +} + +char *mouse_get_name(int mouse) +{ + if (!mouse_list[mouse]) + return NULL; + return mouse_list[mouse]->name; +} +int mouse_get_type(int mouse) +{ + return mouse_list[mouse]->type; +} diff --git a/src/mouse.h b/src/mouse.h index 44558be..6975369 100644 --- a/src/mouse.h +++ b/src/mouse.h @@ -1,5 +1,22 @@ -extern void (*mouse_poll)(int x, int y, int b); +void mouse_emu_init(); +void mouse_emu_close(); +void mouse_poll(int x, int y, int b); -extern int mousepos; -extern int mousedelay; +char *mouse_get_name(int mouse); +int mouse_get_type(int mouse); +#define MOUSE_TYPE_SERIAL 0 +#define MOUSE_TYPE_PS2 1 +#define MOUSE_TYPE_AMSTRAD 2 +#define MOUSE_TYPE_OLIM24 3 + +typedef struct +{ + char name[80]; + void *(*init)(); + void (*close)(void *p); + uint8_t (*poll)(int x, int y, int b, void *p); + int type; +} mouse_t; + +extern int mouse_type; diff --git a/src/mouse_ps2.c b/src/mouse_ps2.c index a0786c4..91cd0dc 100644 --- a/src/mouse_ps2.c +++ b/src/mouse_ps2.c @@ -16,7 +16,7 @@ enum #define MOUSE_ENABLE 0x20 #define MOUSE_SCALE 0x10 -static struct +typedef struct mouse_ps2_t { int mode; @@ -27,54 +27,58 @@ static struct uint8_t command; int cd; -} mouse_ps2; + + int x, y, b; +} mouse_ps2_t; -void mouse_ps2_write(uint8_t val) +void mouse_ps2_write(uint8_t val, void *p) { - if (mouse_ps2.cd) + mouse_ps2_t *mouse = (mouse_ps2_t *)p; + + if (mouse->cd) { - mouse_ps2.cd = 0; - switch (mouse_ps2.command) + mouse->cd = 0; + switch (mouse->command) { case 0xe8: /*Set mouse resolution*/ - mouse_ps2.resolution = val; + mouse->resolution = val; keyboard_at_adddata_mouse(0xfa); break; case 0xf3: /*Set sample rate*/ - mouse_ps2.sample_rate = val; + mouse->sample_rate = val; keyboard_at_adddata_mouse(0xfa); break; // default: -// fatal("mouse_ps2 : Bad data write %02X for command %02X\n", val, mouse_ps2.command); +// fatal("mouse_ps2 : Bad data write %02X for command %02X\n", val, mouse->command); } } else { uint8_t temp; - mouse_ps2.command = val; - switch (mouse_ps2.command) + mouse->command = val; + switch (mouse->command) { case 0xe6: /*Set scaling to 1:1*/ - mouse_ps2.flags &= ~MOUSE_SCALE; + mouse->flags &= ~MOUSE_SCALE; keyboard_at_adddata_mouse(0xfa); break; case 0xe7: /*Set scaling to 2:1*/ - mouse_ps2.flags |= MOUSE_SCALE; + mouse->flags |= MOUSE_SCALE; keyboard_at_adddata_mouse(0xfa); break; case 0xe8: /*Set mouse resolution*/ - mouse_ps2.cd = 1; + mouse->cd = 1; keyboard_at_adddata_mouse(0xfa); break; case 0xe9: /*Status request*/ keyboard_at_adddata_mouse(0xfa); - temp = mouse_ps2.flags; + temp = mouse->flags; if (mouse_buttons & 1) temp |= 1; if (mouse_buttons & 2) @@ -82,8 +86,8 @@ void mouse_ps2_write(uint8_t val) if (mouse_buttons & 4) temp |= 3; keyboard_at_adddata_mouse(temp); - keyboard_at_adddata_mouse(mouse_ps2.resolution); - keyboard_at_adddata_mouse(mouse_ps2.sample_rate); + keyboard_at_adddata_mouse(mouse->resolution); + keyboard_at_adddata_mouse(mouse->sample_rate); break; case 0xf2: /*Read ID*/ @@ -92,60 +96,63 @@ void mouse_ps2_write(uint8_t val) break; case 0xf3: /*Set sample rate*/ - mouse_ps2.cd = 1; + mouse->cd = 1; keyboard_at_adddata_mouse(0xfa); break; case 0xf4: /*Enable*/ - mouse_ps2.flags |= MOUSE_ENABLE; + mouse->flags |= MOUSE_ENABLE; keyboard_at_adddata_mouse(0xfa); break; case 0xf5: /*Disable*/ - mouse_ps2.flags &= ~MOUSE_ENABLE; + mouse->flags &= ~MOUSE_ENABLE; keyboard_at_adddata_mouse(0xfa); break; case 0xff: /*Reset*/ - mouse_ps2.mode = MOUSE_STREAM; - mouse_ps2.flags = 0; + mouse->mode = MOUSE_STREAM; + mouse->flags = 0; keyboard_at_adddata_mouse(0xfa); keyboard_at_adddata_mouse(0xaa); keyboard_at_adddata_mouse(0x00); break; // default: -// fatal("mouse_ps2 : Bad command %02X\n", val, mouse_ps2.command); +// fatal("mouse_ps2 : Bad command %02X\n", val, mouse->command); } } } -static int ps2_x = 0, ps2_y = 0, ps2_b = 0; -void mouse_ps2_poll(int x, int y, int b) +void mouse_ps2_poll(int x, int y, int b, void *p) { + mouse_ps2_t *mouse = (mouse_ps2_t *)p; uint8_t packet[3] = {0x08, 0, 0}; - if (!x && !y && b == ps2_b) return; + + if (!x && !y && b == mouse->b) + return; if (!mouse_scan) return; - ps2_x += x; - ps2_y -= y; - if (mouse_ps2.mode == MOUSE_STREAM && (mouse_ps2.flags & MOUSE_ENABLE) && + + mouse->x += x; + mouse->y -= y; + if (mouse->mode == MOUSE_STREAM && (mouse->flags & MOUSE_ENABLE) && ((mouse_queue_end - mouse_queue_start) & 0xf) < 13) { - ps2_b = b; + mouse->b = b; // pclog("Send packet : %i %i\n", ps2_x, ps2_y); - if (ps2_x > 255) - ps2_x = 255; - if (ps2_x < -256) - ps2_x = -256; - if (ps2_y > 255) - ps2_y = 255; - if (ps2_y < -256) - ps2_y = -256; - if (ps2_x < 0) + if (mouse->x > 255) + mouse->x = 255; + if (mouse->x < -256) + mouse->x = -256; + if (mouse->y > 255) + mouse->y = 255; + if (mouse->y < -256) + mouse->y = -256; + if (mouse->x < 0) packet[0] |= 0x10; - if (ps2_y < 0) + if (mouse->y < 0) packet[0] |= 0x20; if (mouse_buttons & 1) packet[0] |= 1; @@ -153,10 +160,10 @@ void mouse_ps2_poll(int x, int y, int b) packet[0] |= 2; if (mouse_buttons & 4) packet[0] |= 4; - packet[1] = ps2_x & 0xff; - packet[2] = ps2_y & 0xff; + packet[1] = mouse->x & 0xff; + packet[2] = mouse->y & 0xff; - ps2_x = ps2_y = 0; + mouse->x = mouse->y = 0; keyboard_at_adddata_mouse(packet[0]); keyboard_at_adddata_mouse(packet[1]); @@ -164,12 +171,34 @@ void mouse_ps2_poll(int x, int y, int b) } } - -void mouse_ps2_init() +void *mouse_ps2_init() { - mouse_poll = mouse_ps2_poll; - mouse_write = mouse_ps2_write; - mouse_ps2.cd = 0; - mouse_ps2.flags = 0; - mouse_ps2.mode = MOUSE_STREAM; + mouse_ps2_t *mouse = (mouse_ps2_t *)malloc(sizeof(mouse_ps2_t)); + memset(mouse, 0, sizeof(mouse_ps2_t)); + +// mouse_poll = mouse_ps2_poll; +// mouse_write = mouse_ps2_write; + mouse->cd = 0; + mouse->flags = 0; + mouse->mode = MOUSE_STREAM; + + keyboard_at_set_mouse(mouse_ps2_write, mouse); + + return mouse; } + +void mouse_ps2_close(void *p) +{ + mouse_ps2_t *mouse = (mouse_ps2_t *)p; + + free(mouse); +} + +mouse_t mouse_ps2_2_button = +{ + "2-button mouse (PS/2)", + mouse_ps2_init, + mouse_ps2_close, + mouse_ps2_poll, + MOUSE_TYPE_PS2 +}; diff --git a/src/mouse_ps2.h b/src/mouse_ps2.h index 6edfb1f..b74e1eb 100644 --- a/src/mouse_ps2.h +++ b/src/mouse_ps2.h @@ -1 +1 @@ -void mouse_ps2_init(); +extern mouse_t mouse_ps2_2_button; diff --git a/src/mouse_serial.c b/src/mouse_serial.c index 36221c1..2189d4e 100644 --- a/src/mouse_serial.c +++ b/src/mouse_serial.c @@ -4,17 +4,25 @@ #include "serial.h" #include "timer.h" -static int oldb=0; - -void mouse_serial_poll(int x, int y, int b) +typedef struct mouse_serial_t { - uint8_t mousedat[3]; - - if (!(serial1.ier & 1)) - return; - if (!x && !y && b==oldb) return; + int mousepos, mousedelay; + int oldb; + SERIAL *serial; +} mouse_serial_t; - oldb=b; +void mouse_serial_poll(int x, int y, int b, void *p) +{ + mouse_serial_t *mouse = (mouse_serial_t *)p; + SERIAL *serial = mouse->serial; + uint8_t mousedat[3]; + + if (!(serial->ier & 1)) + return; + if (!x && !y && b == mouse->oldb) + return; + + mouse->oldb = b; if (x>127) x=127; if (y>127) y=127; if (x<-128) x=-128; @@ -29,44 +37,62 @@ void mouse_serial_poll(int x, int y, int b) mousedat[1]=x&0x3F; mousedat[2]=y&0x3F; - if (!(serial1.mctrl&0x10)) + if (!(serial->mctrl & 0x10)) { - pclog("Serial data %02X %02X %02X\n", mousedat[0], mousedat[1], mousedat[2]); - serial_write_fifo(&serial1, mousedat[0]); - serial_write_fifo(&serial1, mousedat[1]); - serial_write_fifo(&serial1, mousedat[2]); +// pclog("Serial data %02X %02X %02X\n", mousedat[0], mousedat[1], mousedat[2]); + serial_write_fifo(mouse->serial, mousedat[0]); + serial_write_fifo(mouse->serial, mousedat[1]); + serial_write_fifo(mouse->serial, mousedat[2]); } } -void mouse_serial_rcr(void *p) +void mouse_serial_rcr(SERIAL *serial, void *p) { - mousepos=-1; - mousedelay=5000 * (1 << TIMER_SHIFT); + mouse_serial_t *mouse = (mouse_serial_t *)p; + + mouse->mousepos = -1; + mouse->mousedelay = 5000 * (1 << TIMER_SHIFT); } void mousecallback(void *p) { - SERIAL *serial = (SERIAL *)p; - mousedelay = 0; - if (mousepos == -1) + mouse_serial_t *mouse = (mouse_serial_t *)p; + + mouse->mousedelay = 0; + if (mouse->mousepos == -1) { - mousepos = 0; -/* serial_fifo_read = serial_fifo_write = 0; - serial.lsr &= ~1;*/ - serial_write_fifo(serial, 'M'); + mouse->mousepos = 0; + serial_write_fifo(mouse->serial, 'M'); } -/* else if (serial_fifo_read != serial_fifo_write) - { - serial.iir=4; - serial.lsr|=1; - if (serial.mctrl&8) picint(0x10); - }*/ } -void mouse_serial_init() +void *mouse_serial_init() { - mouse_poll = mouse_serial_poll; + mouse_serial_t *mouse = (mouse_t *)malloc(sizeof(mouse_serial_t)); + memset(mouse, 0, sizeof(mouse_serial_t)); + + mouse->serial = &serial1; serial1.rcr_callback = mouse_serial_rcr; - timer_add(mousecallback, &mousedelay, &mousedelay, &serial1); + serial1.rcr_callback_p = mouse; + timer_add(mousecallback, &mouse->mousedelay, &mouse->mousedelay, mouse); + + return mouse; } +void mouse_serial_close(void *p) +{ + mouse_serial_t *mouse = (mouse_serial_t *)p; + + free(mouse); + + serial1.rcr_callback = NULL; +} + +mouse_t mouse_serial_microsoft = +{ + "Microsoft 2-button mouse (serial)", + mouse_serial_init, + mouse_serial_close, + mouse_serial_poll, + MOUSE_TYPE_SERIAL +}; diff --git a/src/mouse_serial.h b/src/mouse_serial.h index c835602..4791d2c 100644 --- a/src/mouse_serial.h +++ b/src/mouse_serial.h @@ -1 +1 @@ -void mouse_serial_init(); +extern mouse_t mouse_serial_microsoft; diff --git a/src/pc.c b/src/pc.c index 90cd0cc..5a894b7 100644 --- a/src/pc.c +++ b/src/pc.c @@ -5,7 +5,6 @@ #include "device.h" #include "ali1429.h" -#include "amstrad.h" #include "cdrom-ioctl.h" #include "cdrom-iso.h" #include "disc.h" @@ -38,6 +37,7 @@ #include "timer.h" #include "vid_voodoo.h" #include "video.h" +#include "amstrad.h" int window_w, window_h, window_x, window_y, window_remember; @@ -346,6 +346,7 @@ void resetpc_cad() void resetpchard() { device_close_all(); + mouse_emu_close(); device_init(); midi_close(); @@ -358,6 +359,7 @@ void resetpchard() disc_reset(); model_init(); + mouse_emu_init(); video_init(); speaker_init(); sound_card_init(sound_card_current); @@ -542,6 +544,7 @@ void closepc() disc_close(1); dumpregs(); closevideo(); + mouse_emu_close(); device_close_all(); midi_close(); } @@ -600,8 +603,8 @@ void loadconfig(char *fn) else strcpy(discfns[1], ""); mem_size = config_get_int(NULL, "mem_size", 4096); - if (mem_size < (models[model].is_at ? models[model].min_ram*1024 : models[model].min_ram)) - mem_size = (models[model].is_at ? models[model].min_ram*1024 : models[model].min_ram); + if (mem_size < ((models[model].flags & MODEL_AT) ? models[model].min_ram*1024 : models[model].min_ram)) + mem_size = ((models[model].flags & MODEL_AT) ? models[model].min_ram*1024 : models[model].min_ram); cdrom_drive = config_get_int(NULL, "cdrom_drive", 0); cdrom_enabled = config_get_int(NULL, "cdrom_enabled", 0); @@ -651,6 +654,7 @@ void loadconfig(char *fn) window_remember = config_get_int(NULL, "window_remember", 0); joystick_type = config_get_int(NULL, "joystick_type", 0); + mouse_type = config_get_int(NULL, "mouse_type", 0); for (c = 0; c < joystick_get_max_joysticks(joystick_type); c++) { @@ -741,6 +745,7 @@ void saveconfig() config_set_int(NULL, "window_remember", window_remember); config_set_int(NULL, "joystick_type", joystick_type); + config_set_int(NULL, "mouse_type", mouse_type); for (c = 0; c < joystick_get_max_joysticks(joystick_type); c++) { diff --git a/src/pc.rc b/src/pc.rc index 07a13e5..e2dea61 100644 --- a/src/pc.rc +++ b/src/pc.rc @@ -57,13 +57,13 @@ BEGIN END END -ConfigureDlg DIALOGEX 0, 0, 232+40, 372 +ConfigureDlg DIALOGEX 0, 0, 232+40, 392 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Configure PCem" FONT 8, "MS Sans Serif" BEGIN - DEFPUSHBUTTON "OK",IDOK,64,348,50,14, WS_TABSTOP - PUSHBUTTON "Cancel",IDCANCEL,128,348,50,14, WS_TABSTOP + DEFPUSHBUTTON "OK",IDOK,64,368,50,14, WS_TABSTOP + PUSHBUTTON "Cancel",IDCANCEL,128,368,50,14, WS_TABSTOP COMBOBOX IDC_COMBO1,62,16,157,120,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP PUSHBUTTON "Configure", IDC_CONFIGUREMOD, 224, 16, 40, 14, WS_TABSTOP COMBOBOX IDC_COMBOVID,62,36,157,120,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP @@ -78,12 +78,12 @@ BEGIN EDITTEXT IDC_MEMTEXT, 62, 172, 36, 14, ES_AUTOHSCROLL | ES_NUMBER CONTROL "", IDC_MEMSPIN, UPDOWN_CLASS, UDS_ALIGNRIGHT | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_SETBUDDYINT, 98, 172, 12, 14 LTEXT "MB", IDC_TEXT_MB, 98, 172, 40, 10 - CONTROL "CMS / Game Blaster",IDC_CHECK3,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,272,118,10 - CONTROL "Gravis Ultrasound",IDC_CHECKGUS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,288,118,10 - CONTROL "Innovation SSI-2001",IDC_CHECKSSI,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,304,118,10 - CONTROL "Synchronise time to host clock",IDC_CHECKSYNC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,320,118,10 - CONTROL "Voodoo Graphics",IDC_CHECKVOODOO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,336,118,10 - PUSHBUTTON "Configure", IDC_CONFIGUREVOODOO, 224, 336, 40, 14, WS_TABSTOP + CONTROL "CMS / Game Blaster",IDC_CHECK3,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,292,118,10 + CONTROL "Gravis Ultrasound",IDC_CHECKGUS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,308,118,10 + CONTROL "Innovation SSI-2001",IDC_CHECKSSI,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,324,118,10 + CONTROL "Synchronise time to host clock",IDC_CHECKSYNC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,340,118,10 + CONTROL "Voodoo Graphics",IDC_CHECKVOODOO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,356,118,10 + PUSHBUTTON "Configure", IDC_CONFIGUREVOODOO, 224, 356, 40, 14, WS_TABSTOP LTEXT "Machine :",IDC_STATIC,15,16,40,10 LTEXT "Video :",IDC_STATIC,15,36,34,10 LTEXT "CPU type :",IDC_STATIC,15,56,34,10 @@ -96,12 +96,14 @@ BEGIN LTEXT "Drive B: :",IDC_STATIC,15,216,40,10 COMBOBOX IDC_COMBODRA,62,196,157,120,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP COMBOBOX IDC_COMBODRB,62,216,157,120,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP - LTEXT "Joystick :",IDC_STATIC,15,236,40,10 - COMBOBOX IDC_COMBOJOY,62,236,157,120,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP - DEFPUSHBUTTON "Joystick 1...",IDC_JOY1,16,252,50,14, WS_TABSTOP - PUSHBUTTON "Joystick 2...",IDC_JOY2,80,252,50,14, WS_TABSTOP - DEFPUSHBUTTON "Joystick 3...",IDC_JOY3,144,252,50,14, WS_TABSTOP - PUSHBUTTON "Joystick 4...",IDC_JOY4,208,252,50,14, WS_TABSTOP + LTEXT "Mouse :",IDC_STATIC,15,236,40,10 + COMBOBOX IDC_COMBOMOUSE,62,236,157,120,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP + LTEXT "Joystick :",IDC_STATIC,15,256,40,10 + COMBOBOX IDC_COMBOJOY,62,256,157,120,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP + DEFPUSHBUTTON "Joystick 1...",IDC_JOY1,16,272,50,14, WS_TABSTOP + PUSHBUTTON "Joystick 2...",IDC_JOY2,80,272,50,14, WS_TABSTOP + DEFPUSHBUTTON "Joystick 3...",IDC_JOY3,144,272,50,14, WS_TABSTOP + PUSHBUTTON "Joystick 4...",IDC_JOY4,208,272,50,14, WS_TABSTOP END HdConfDlg DIALOGEX 0, 0, 210, 312+4*16 diff --git a/src/resources.h b/src/resources.h index e27e573..ebe0bfe 100644 --- a/src/resources.h +++ b/src/resources.h @@ -38,6 +38,7 @@ #define IDC_COMBODRB 1063 #define IDC_COMBOJOY 1064 #define IDC_COMBOWS 1065 +#define IDC_COMBOMOUSE 1066 #define IDC_CHECK1 1010 #define IDC_CHECK2 1011 #define IDC_CHECK3 1012 diff --git a/src/serial.c b/src/serial.c index 1b8045d..30111e1 100644 --- a/src/serial.c +++ b/src/serial.c @@ -15,14 +15,11 @@ enum SERIAL serial1, serial2; -int mousepos=-1; -int mousedelay; void serial_reset() { serial1.iir = serial1.ier = serial1.lcr = 0; serial2.iir = serial2.ier = serial2.lcr = 0; - mousedelay = 0; serial1.fifo_read = serial1.fifo_write = 0; serial2.fifo_read = serial2.fifo_write = 0; } @@ -120,7 +117,7 @@ void serial_write(uint16_t addr, uint8_t val, void *p) if ((val & 2) && !(serial->mctrl & 2)) { if (serial->rcr_callback) - serial->rcr_callback(serial); + serial->rcr_callback(serial, serial->rcr_callback_p); // pclog("RCR raised! sending M\n"); } serial->mctrl = val; diff --git a/src/serial.h b/src/serial.h index 469c29b..88e57c7 100644 --- a/src/serial.h +++ b/src/serial.h @@ -18,7 +18,8 @@ typedef struct int irq; - void (*rcr_callback)(void *p); + void (*rcr_callback)(struct SERIAL *serial, void *p); + void *rcr_callback_p; uint8_t fifo[256]; int fifo_read, fifo_write; diff --git a/src/um8669f.c b/src/um8669f.c index 2f0120a..8132ff0 100644 --- a/src/um8669f.c +++ b/src/um8669f.c @@ -41,7 +41,6 @@ COM2 : #include "fdc.h" #include "io.h" #include "lpt.h" -#include "mouse_serial.h" #include "serial.h" #include "um8669f.h" @@ -103,8 +102,6 @@ void um8669f_write(uint16_t port, uint8_t val, void *priv) } } - mouse_serial_init(); - lpt1_remove(); lpt2_remove(); temp = (um8669f_regs[0xc3] >> 4) & 3; diff --git a/src/win-config.c b/src/win-config.c index a4c9c26..3a5c12f 100644 --- a/src/win-config.c +++ b/src/win-config.c @@ -11,6 +11,7 @@ #include "fdd.h" #include "gameport.h" #include "model.h" +#include "mouse.h" #include "nvr.h" #include "resources.h" #include "sound.h" @@ -21,6 +22,18 @@ extern int is486; static int romstolist[ROM_MAX], listtomodel[ROM_MAX], romstomodel[ROM_MAX], modeltolist[ROM_MAX]; static int settings_sound_to_list[20], settings_list_to_sound[20]; +static int settings_mouse_to_list[20], settings_list_to_mouse[20]; + +static int mouse_valid(int type, int model) +{ + if (type == MOUSE_TYPE_PS2 && !(models[model].flags & MODEL_PS2)) + return 0; + if (type == MOUSE_TYPE_AMSTRAD && !(models[model].flags & MODEL_AMSTRAD)) + return 0; + if (type == MOUSE_TYPE_OLIM24 && !(models[model].flags & MODEL_OLIM24)) + return 0; + return 1; +} static BOOL CALLBACK config_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) { @@ -35,6 +48,7 @@ static BOOL CALLBACK config_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR int temp_fda_type, temp_fdb_type; int temp_joystick_type; int cpu_type; + int temp_mouse_type; UDACCEL accel; // pclog("Dialog msg %i %08X\n",message,message); @@ -164,7 +178,7 @@ static BOOL CALLBACK config_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR h = GetDlgItem(hdlg, IDC_MEMSPIN); SendMessage(h, UDM_SETBUDDY, (WPARAM)GetDlgItem(hdlg, IDC_MEMTEXT), 0); SendMessage(h, UDM_SETRANGE, 0, (models[romstomodel[romset]].min_ram << 16) | models[romstomodel[romset]].max_ram); - if (!models[model].is_at) + if (!models[model].flags & MODEL_AT) SendMessage(h, UDM_SETPOS, 0, mem_size); else SendMessage(h, UDM_SETPOS, 0, mem_size / 1024); @@ -212,7 +226,7 @@ static BOOL CALLBACK config_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR SendMessage(h, CB_SETCURSEL, fdd_get_type(1), 0); h = GetDlgItem(hdlg, IDC_TEXT_MB); - if (models[model].is_at) + if (models[model].flags & MODEL_AT) SendMessage(h, WM_SETTEXT, 0, (LPARAM)(LPCSTR)"MB"); else SendMessage(h, WM_SETTEXT, 0, (LPARAM)(LPCSTR)"KB"); @@ -252,6 +266,30 @@ static BOOL CALLBACK config_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR EnableWindow(h, TRUE); else EnableWindow(h, FALSE); + + h = GetDlgItem(hdlg, IDC_COMBOMOUSE); + c = d = 0; + while (1) + { + char *s = mouse_get_name(c); + int type; + + if (!s) + break; + + type = mouse_get_type(c); + settings_mouse_to_list[c] = d; + + if (mouse_valid(type, model)) + { + SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)s); + + settings_list_to_mouse[d] = c; + d++; + } + c++; + } + SendMessage(h, CB_SETCURSEL, settings_mouse_to_list[mouse_type], 0); return TRUE; case WM_COMMAND: @@ -269,7 +307,7 @@ static BOOL CALLBACK config_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR mem = models[temp_model].min_ram; else if (mem > models[temp_model].max_ram) mem = models[temp_model].max_ram; - if (models[temp_model].is_at) + if (models[temp_model].flags & MODEL_AT) mem *= 1024; h = GetDlgItem(hdlg, IDC_COMBOVID); @@ -310,12 +348,15 @@ static BOOL CALLBACK config_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR h = GetDlgItem(hdlg, IDC_COMBOJOY); temp_joystick_type = SendMessage(h, CB_GETCURSEL, 0, 0); + h = GetDlgItem(hdlg, IDC_COMBOMOUSE); + temp_mouse_type = settings_list_to_mouse[SendMessage(h, CB_GETCURSEL, 0, 0)]; if (temp_model != model || gfx != gfxcard || mem != mem_size || fpu != hasfpu || temp_GAMEBLASTER != GAMEBLASTER || temp_GUS != GUS || temp_SSI2001 != SSI2001 || temp_sound_card_current != sound_card_current || temp_voodoo != voodoo_enabled || temp_dynarec != cpu_use_dynarec || - temp_fda_type != fdd_get_type(0) || temp_fdb_type != fdd_get_type(1)) + temp_fda_type != fdd_get_type(0) || temp_fdb_type != fdd_get_type(1) || + temp_mouse_type != mouse_type) { if (MessageBox(NULL,"This will reset PCem!\nOkay to continue?","PCem",MB_OKCANCEL)==IDOK) { @@ -332,6 +373,7 @@ static BOOL CALLBACK config_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR sound_card_current = temp_sound_card_current; voodoo_enabled = temp_voodoo; cpu_use_dynarec = temp_dynarec; + mouse_type = temp_mouse_type; fdd_set_type(0, temp_fda_type); fdd_set_type(1, temp_fdb_type); @@ -437,7 +479,7 @@ static BOOL CALLBACK config_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR SendMessage(h, BM_SETCHECK, ((cpu_flags & CPU_SUPPORTS_DYNAREC) && temp_dynarec) || (cpu_flags & CPU_REQUIRES_DYNAREC), 0); h = GetDlgItem(hdlg, IDC_TEXT_MB); - if (models[temp_model].is_at) + if (models[temp_model].flags & MODEL_AT) SendMessage(h, WM_SETTEXT, 0, (LPARAM)(LPCSTR)"MB"); else SendMessage(h, WM_SETTEXT, 0, (LPARAM)(LPCSTR)"KB"); @@ -470,6 +512,36 @@ static BOOL CALLBACK config_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR EnableWindow(h, TRUE); else EnableWindow(h, FALSE); + + h = GetDlgItem(hdlg, IDC_COMBOMOUSE); + temp_mouse_type = settings_list_to_mouse[SendMessage(h, CB_GETCURSEL, 0, 0)]; + SendMessage(h, CB_RESETCONTENT, 0, 0); + c = d = 0; + while (1) + { + char *s = mouse_get_name(c); + int type; + + if (!s) + break; + + type = mouse_get_type(c); + settings_mouse_to_list[c] = d; + + if (mouse_valid(type, temp_model)) + { + SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)s); + + settings_list_to_mouse[d] = c; + d++; + } + + c++; + } + if (mouse_valid(temp_mouse_type, temp_model)) + SendMessage(h, CB_SETCURSEL, settings_mouse_to_list[temp_mouse_type], 0); + else + SendMessage(h, CB_SETCURSEL, 0, 0); } break; case IDC_COMBOCPUM: