Mouse type now configurable

This commit is contained in:
SarahW 2016-12-16 20:19:08 +00:00
commit 09dbd1dd65
21 changed files with 494 additions and 238 deletions

View file

@ -35,41 +35,72 @@ void amstrad_write(uint16_t port, uint8_t val, void *priv)
} }
} }
static uint8_t mousex,mousey; static uint8_t mousex, mousey;
static void amstrad_mouse_write(uint16_t addr, uint8_t val, void *p)
void amstrad_mouse_write(uint16_t addr, uint8_t val, void *priv)
{ {
// pclog("Write mouse %04X %02X %04X:%04X\n", addr, val, CS, pc); // pclog("Write mouse %04X %02X %04X:%04X\n", addr, val, CS, pc);
if (addr==0x78) mousex=0; if (addr == 0x78)
else mousey=0; 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); // 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; return mousey;
} }
static int oldb = 0; typedef struct mouse_amstrad_t
void amstrad_mouse_poll(int x, int y, int b)
{ {
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; mousex += x;
mousey -= y; mousey -= y;
if ((b & 1) && !(oldb & 1)) if ((b & 1) && !(mouse->oldb & 1))
keyboard_send(0x7e); keyboard_send(0x7e);
if ((b & 2) && !(oldb & 2)) if ((b & 2) && !(mouse->oldb & 2))
keyboard_send(0x7d); keyboard_send(0x7d);
if (!(b & 1) && (oldb & 1)) if (!(b & 1) && (mouse->oldb & 1))
keyboard_send(0xfe); keyboard_send(0xfe);
if (!(b & 2) && (oldb & 2)) if (!(b & 2) && (mouse->oldb & 2))
keyboard_send(0xfd); 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() void amstrad_init()
{ {
lpt2_remove_ams(); 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(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(0x0379, 0x0002, amstrad_read, NULL, NULL, NULL, NULL, NULL, NULL);
io_sethandler(0xdead, 0x0001, amstrad_read, NULL, NULL, amstrad_write, NULL, NULL, NULL); io_sethandler(0xdead, 0x0001, amstrad_read, NULL, NULL, amstrad_write, NULL, NULL, NULL);
mouse_poll = amstrad_mouse_poll;
} }

View file

@ -1,2 +1,3 @@
void amstrad_init(); void amstrad_init();
extern mouse_t mouse_amstrad;

View file

@ -38,6 +38,9 @@ struct
int key_wantdata; int key_wantdata;
int last_irq; int last_irq;
void (*mouse_write)(uint8_t val, void *p);
void *mouse_p;
} keyboard_at; } keyboard_at;
static uint8_t key_ctrl_queue[16]; static uint8_t key_ctrl_queue[16];
@ -199,8 +202,8 @@ void keyboard_at_write(uint16_t port, uint8_t val, void *priv)
break; break;
case 0xd4: /*Write to mouse*/ case 0xd4: /*Write to mouse*/
if (mouse_write) if (keyboard_at.mouse_write)
mouse_write(val); keyboard_at.mouse_write(val, keyboard_at.mouse_p);
break; break;
default: default:
@ -483,7 +486,14 @@ void keyboard_at_init()
keyboard_at_reset(); keyboard_at_reset();
keyboard_send = keyboard_at_adddata_keyboard; keyboard_send = keyboard_at_adddata_keyboard;
keyboard_poll = keyboard_at_poll; 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); 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;
}

View file

@ -1,7 +1,7 @@
void keyboard_at_init(); void keyboard_at_init();
void keyboard_at_reset(); void keyboard_at_reset();
void keyboard_at_poll(); 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_queue_start, mouse_queue_end;
extern int mouse_scan; extern int mouse_scan;

View file

@ -216,85 +216,124 @@ void keyboard_olim24_reset()
mouse_scancodes[6] = 0x50; mouse_scancodes[6] = 0x50;
} }
static int mouse_x = 0, mouse_y = 0, mouse_b = 0; typedef struct mouse_olim24_t
void mouse_olim24_poll(int x, int y, int b)
{ {
mouse_x += x; int x, y, b;
mouse_y += y; } 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; mouse->x += x;
if ((b & 1) && !(mouse_b & 1)) mouse->y += y;
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; // pclog("mouse_poll - %i, %i %i, %i\n", x, y, mouse->x, mouse->y);
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 (((key_queue_end - key_queue_start) & 0xf) > 14)
if ((b & 4) && !(mouse_b & 4)) return;
keyboard_olim24_adddata(mouse_scancodes[1]); if ((b & 1) && !(mouse->b & 1))
if (!(b & 4) && (mouse_b & 4)) keyboard_olim24_adddata(mouse_scancodes[0]);
keyboard_olim24_adddata(mouse_scancodes[1] | 0x80); if (!(b & 1) && (mouse->b & 1))
mouse_b = (mouse_b & ~4) | (b & 4); 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 & 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 (keyboard_olim24.mouse_mode)
{ {
if (((key_queue_end - key_queue_start) & 0xf) > 12) return; if (((key_queue_end - key_queue_start) & 0xf) > 12)
if (!mouse_x && !mouse_y) return; 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 = 127; if (mouse->x > 127) mouse->x = 127;
if (mouse_x < -127) mouse_x = 0x80 | ((-mouse_x) & 0x7f); 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 = 127; if (mouse->y > 127) mouse->y = 127;
if (mouse_y < -127) mouse_y = 0x80 | ((-mouse_y) & 0x7f); if (mouse->y < -127) mouse->y = 0x80 | ((-mouse->y) & 0x7f);
keyboard_olim24_adddata(0xfe); keyboard_olim24_adddata(0xfe);
keyboard_olim24_adddata(mouse_x); keyboard_olim24_adddata(mouse->x);
keyboard_olim24_adddata(mouse_y); keyboard_olim24_adddata(mouse->y);
mouse_x = mouse_y = 0; mouse->x = mouse->y = 0;
} }
else else
{ {
while (mouse_x < -4) while (mouse->x < -4)
{ {
if (((key_queue_end - key_queue_start) & 0xf) > 14) return; if (((key_queue_end - key_queue_start) & 0xf) > 14)
mouse_x+=4; return;
mouse->x += 4;
keyboard_olim24_adddata(mouse_scancodes[3]); keyboard_olim24_adddata(mouse_scancodes[3]);
} }
while (mouse_x > 4) while (mouse->x > 4)
{ {
if (((key_queue_end - key_queue_start) & 0xf) > 14) return; if (((key_queue_end - key_queue_start) & 0xf) > 14)
mouse_x-=4; return;
mouse->x -= 4;
keyboard_olim24_adddata(mouse_scancodes[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; if (((key_queue_end - key_queue_start) & 0xf) > 14)
mouse_y+=4; return;
mouse->y += 4;
keyboard_olim24_adddata(mouse_scancodes[5]); keyboard_olim24_adddata(mouse_scancodes[5]);
} }
while (mouse_y > 4) while (mouse->y > 4)
{ {
if (((key_queue_end - key_queue_start) & 0xf) > 14) return; if (((key_queue_end - key_queue_start) & 0xf) > 14)
mouse_y-=4; return;
mouse->y -= 4;
keyboard_olim24_adddata(mouse_scancodes[6]); 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() void keyboard_olim24_init()
{ {
//return; //return;
@ -303,7 +342,6 @@ void keyboard_olim24_init()
keyboard_olim24_reset(); keyboard_olim24_reset();
keyboard_send = keyboard_olim24_adddata; keyboard_send = keyboard_olim24_adddata;
keyboard_poll = keyboard_olim24_poll; keyboard_poll = keyboard_olim24_poll;
mouse_poll = mouse_olim24_poll;
timer_add(keyboard_olim24_poll, &keybsenddelay, TIMER_ALWAYS_ENABLED, NULL); timer_add(keyboard_olim24_poll, &keybsenddelay, TIMER_ALWAYS_ENABLED, NULL);
} }

View file

@ -1,3 +1,5 @@
void keyboard_olim24_init(); void keyboard_olim24_init();
void keyboard_olim24_reset(); void keyboard_olim24_reset();
void keyboard_olim24_poll(); void keyboard_olim24_poll();
extern mouse_t mouse_olim24;

View file

@ -2,6 +2,7 @@
#include "cpu.h" #include "cpu.h"
#include "model.h" #include "model.h"
#include "io.h" #include "io.h"
#include "mouse.h"
#include "acer386sx.h" #include "acer386sx.h"
#include "ali1429.h" #include "ali1429.h"
@ -26,8 +27,6 @@
#include "keyboard_pcjr.h" #include "keyboard_pcjr.h"
#include "keyboard_xt.h" #include "keyboard_xt.h"
#include "lpt.h" #include "lpt.h"
#include "mouse_ps2.h"
#include "mouse_serial.h"
#include "neat.h" #include "neat.h"
#include "nmi.h" #include "nmi.h"
#include "nvr.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", 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 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}, {"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}, {"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, 0, 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}, {"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}, {"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, 0, 640, 640, 0, ams_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, 0, 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, 0, 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, 1, 1, 16, 1, at_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, 1, 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, 1, 1, 16, 1, at_neat_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, 1, 1, 16, 1, at_scat_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, 1, 1, 16, 1, at_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, 1, 1, 16, 1, ps1_m2011_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, 1, 1, 16, 1, ps1_m2121_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, 1, 1, 15, 1, deskpro386_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, 1, 1, 16, 1, at_acer386sx_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, 1, 1, 16, 1, at_neat_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, 1, 1, 16, 1, at_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, 1, 1, 16, 1, at_wd76c10_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, 1, 1, 256, 1, at_headland_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, 1, 1, 256, 1, at_opti495_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, 1, 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, 1, 1, 256, 1, at_ali1429_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, 1, 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},*/ /* {"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}, {"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, 1, 1, 128, 1, at_batman_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, 1, 1, 128, 1, at_endeavor_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, 1, 1, 256, 1, at_i430vx_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} {"", -1, {"", 0, "", 0, "", 0}, 0,0,0, 0}
}; };
@ -179,7 +178,6 @@ void xt_init()
mem_add_bios(); mem_add_bios();
pit_set_out_func(1, pit_refresh_timer_xt); pit_set_out_func(1, pit_refresh_timer_xt);
keyboard_xt_init(); keyboard_xt_init();
mouse_serial_init();
xtide_init(); xtide_init();
nmi_init(); nmi_init();
device_add(&gameport_device); device_add(&gameport_device);
@ -204,7 +202,6 @@ void tandy1k_init()
common_init(); common_init();
mem_add_bios(); mem_add_bios();
keyboard_tandy_init(); keyboard_tandy_init();
mouse_serial_init();
if (romset == ROM_TANDY) if (romset == ROM_TANDY)
device_add(&sn76489_device); device_add(&sn76489_device);
else else
@ -221,7 +218,6 @@ void tandy1ksl2_init()
common_init(); common_init();
mem_add_bios(); mem_add_bios();
keyboard_tandy_init(); keyboard_tandy_init();
mouse_serial_init();
device_add(&pssj_device); device_add(&pssj_device);
xtide_init(); xtide_init();
nmi_init(); nmi_init();
@ -250,7 +246,6 @@ void europc_init()
mem_add_bios(); mem_add_bios();
jim_init(); jim_init();
keyboard_xt_init(); keyboard_xt_init();
mouse_serial_init();
xtide_init(); xtide_init();
nmi_init(); nmi_init();
device_add(&gameport_device); device_add(&gameport_device);
@ -277,8 +272,6 @@ void at_init()
dma16_init(); dma16_init();
ide_init(); ide_init();
keyboard_at_init(); keyboard_at_init();
if (models[model].init == at_init)
mouse_serial_init();
nvr_init(); nvr_init();
pic2_init(); pic2_init();
device_add(&gameport_device); device_add(&gameport_device);
@ -287,7 +280,6 @@ void at_init()
void deskpro386_init() void deskpro386_init()
{ {
at_init(); at_init();
mouse_serial_init();
compaq_init(); compaq_init();
} }
@ -300,7 +292,6 @@ void ps1_common_init()
dma16_init(); dma16_init();
ide_init(); ide_init();
keyboard_at_init(); keyboard_at_init();
mouse_ps2_init();
nvr_init(); nvr_init();
pic2_init(); pic2_init();
fdc_set_dskchg_activelow(); fdc_set_dskchg_activelow();
@ -325,28 +316,24 @@ void ps1_m2121_init()
void at_neat_init() void at_neat_init()
{ {
at_init(); at_init();
mouse_serial_init();
neat_init(); neat_init();
} }
void at_scat_init() void at_scat_init()
{ {
at_init(); at_init();
mouse_serial_init();
scat_init(); scat_init();
} }
void at_acer386sx_init() void at_acer386sx_init()
{ {
at_init(); at_init();
mouse_ps2_init();
acer386sx_init(); acer386sx_init();
} }
void at_wd76c10_init() void at_wd76c10_init()
{ {
at_init(); at_init();
mouse_ps2_init();
wd76c10_init(); wd76c10_init();
} }
@ -354,27 +341,23 @@ void at_headland_init()
{ {
at_init(); at_init();
headland_init(); headland_init();
mouse_serial_init();
} }
void at_opti495_init() void at_opti495_init()
{ {
at_init(); at_init();
opti495_init(); opti495_init();
mouse_serial_init();
} }
void at_ali1429_init() void at_ali1429_init()
{ {
at_init(); at_init();
ali1429_init(); ali1429_init();
mouse_serial_init();
} }
void at_um8881f_init() void at_um8881f_init()
{ {
at_init(); at_init();
mouse_serial_init();
pci_init(PCI_CONFIG_TYPE_1, 0, 31); pci_init(PCI_CONFIG_TYPE_1, 0, 31);
um8881f_init(); um8881f_init();
} }
@ -382,7 +365,6 @@ void at_um8881f_init()
void at_sis496_init() void at_sis496_init()
{ {
at_init(); at_init();
mouse_serial_init();
pci_init(PCI_CONFIG_TYPE_1, 0, 31); pci_init(PCI_CONFIG_TYPE_1, 0, 31);
device_add(&sis496_device); device_add(&sis496_device);
} }
@ -390,7 +372,6 @@ void at_sis496_init()
void at_batman_init() void at_batman_init()
{ {
at_init(); at_init();
mouse_ps2_init();
pci_init(PCI_CONFIG_TYPE_2, 0xd, 0x10); pci_init(PCI_CONFIG_TYPE_2, 0xd, 0x10);
i430lx_init(); i430lx_init();
fdc37c665_init(); fdc37c665_init();
@ -400,7 +381,6 @@ void at_batman_init()
void at_endeavor_init() void at_endeavor_init()
{ {
at_init(); at_init();
mouse_serial_init();
pci_init(PCI_CONFIG_TYPE_1, 0xd, 0x10); pci_init(PCI_CONFIG_TYPE_1, 0xd, 0x10);
i430fx_init(); i430fx_init();
piix_init(7); piix_init(7);
@ -412,7 +392,6 @@ void at_endeavor_init()
void at_i430vx_init() void at_i430vx_init()
{ {
at_init(); at_init();
mouse_serial_init();
pci_init(PCI_CONFIG_TYPE_1, 0, 31); pci_init(PCI_CONFIG_TYPE_1, 0, 31);
i430vx_init(); i430vx_init();
piix_init(7); piix_init(7);

View file

@ -1,3 +1,8 @@
#define MODEL_AT 1
#define MODEL_PS2 2
#define MODEL_AMSTRAD 4
#define MODEL_OLIM24 8
typedef struct typedef struct
{ {
char name[24]; char name[24];
@ -8,7 +13,7 @@ typedef struct
CPU *cpus; CPU *cpus;
} cpu[4]; } cpu[4];
int fixed_gfxcard; int fixed_gfxcard;
int is_at; int flags;
int min_ram, max_ram; int min_ram, max_ram;
int ram_granularity; int ram_granularity;
void (*init)(); void (*init)();

View file

@ -1,4 +1,49 @@
#include "ibm.h" #include "ibm.h"
#include "mouse.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;
}

View file

@ -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; char *mouse_get_name(int mouse);
extern int mousedelay; 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;

View file

@ -16,7 +16,7 @@ enum
#define MOUSE_ENABLE 0x20 #define MOUSE_ENABLE 0x20
#define MOUSE_SCALE 0x10 #define MOUSE_SCALE 0x10
static struct typedef struct mouse_ps2_t
{ {
int mode; int mode;
@ -27,54 +27,58 @@ static struct
uint8_t command; uint8_t command;
int cd; int cd;
} mouse_ps2;
void mouse_ps2_write(uint8_t val) int x, y, b;
} mouse_ps2_t;
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; mouse->cd = 0;
switch (mouse_ps2.command) switch (mouse->command)
{ {
case 0xe8: /*Set mouse resolution*/ case 0xe8: /*Set mouse resolution*/
mouse_ps2.resolution = val; mouse->resolution = val;
keyboard_at_adddata_mouse(0xfa); keyboard_at_adddata_mouse(0xfa);
break; break;
case 0xf3: /*Set sample rate*/ case 0xf3: /*Set sample rate*/
mouse_ps2.sample_rate = val; mouse->sample_rate = val;
keyboard_at_adddata_mouse(0xfa); keyboard_at_adddata_mouse(0xfa);
break; break;
// default: // 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 else
{ {
uint8_t temp; uint8_t temp;
mouse_ps2.command = val; mouse->command = val;
switch (mouse_ps2.command) switch (mouse->command)
{ {
case 0xe6: /*Set scaling to 1:1*/ case 0xe6: /*Set scaling to 1:1*/
mouse_ps2.flags &= ~MOUSE_SCALE; mouse->flags &= ~MOUSE_SCALE;
keyboard_at_adddata_mouse(0xfa); keyboard_at_adddata_mouse(0xfa);
break; break;
case 0xe7: /*Set scaling to 2:1*/ case 0xe7: /*Set scaling to 2:1*/
mouse_ps2.flags |= MOUSE_SCALE; mouse->flags |= MOUSE_SCALE;
keyboard_at_adddata_mouse(0xfa); keyboard_at_adddata_mouse(0xfa);
break; break;
case 0xe8: /*Set mouse resolution*/ case 0xe8: /*Set mouse resolution*/
mouse_ps2.cd = 1; mouse->cd = 1;
keyboard_at_adddata_mouse(0xfa); keyboard_at_adddata_mouse(0xfa);
break; break;
case 0xe9: /*Status request*/ case 0xe9: /*Status request*/
keyboard_at_adddata_mouse(0xfa); keyboard_at_adddata_mouse(0xfa);
temp = mouse_ps2.flags; temp = mouse->flags;
if (mouse_buttons & 1) if (mouse_buttons & 1)
temp |= 1; temp |= 1;
if (mouse_buttons & 2) if (mouse_buttons & 2)
@ -82,8 +86,8 @@ void mouse_ps2_write(uint8_t val)
if (mouse_buttons & 4) if (mouse_buttons & 4)
temp |= 3; temp |= 3;
keyboard_at_adddata_mouse(temp); keyboard_at_adddata_mouse(temp);
keyboard_at_adddata_mouse(mouse_ps2.resolution); keyboard_at_adddata_mouse(mouse->resolution);
keyboard_at_adddata_mouse(mouse_ps2.sample_rate); keyboard_at_adddata_mouse(mouse->sample_rate);
break; break;
case 0xf2: /*Read ID*/ case 0xf2: /*Read ID*/
@ -92,60 +96,63 @@ void mouse_ps2_write(uint8_t val)
break; break;
case 0xf3: /*Set sample rate*/ case 0xf3: /*Set sample rate*/
mouse_ps2.cd = 1; mouse->cd = 1;
keyboard_at_adddata_mouse(0xfa); keyboard_at_adddata_mouse(0xfa);
break; break;
case 0xf4: /*Enable*/ case 0xf4: /*Enable*/
mouse_ps2.flags |= MOUSE_ENABLE; mouse->flags |= MOUSE_ENABLE;
keyboard_at_adddata_mouse(0xfa); keyboard_at_adddata_mouse(0xfa);
break; break;
case 0xf5: /*Disable*/ case 0xf5: /*Disable*/
mouse_ps2.flags &= ~MOUSE_ENABLE; mouse->flags &= ~MOUSE_ENABLE;
keyboard_at_adddata_mouse(0xfa); keyboard_at_adddata_mouse(0xfa);
break; break;
case 0xff: /*Reset*/ case 0xff: /*Reset*/
mouse_ps2.mode = MOUSE_STREAM; mouse->mode = MOUSE_STREAM;
mouse_ps2.flags = 0; mouse->flags = 0;
keyboard_at_adddata_mouse(0xfa); keyboard_at_adddata_mouse(0xfa);
keyboard_at_adddata_mouse(0xaa); keyboard_at_adddata_mouse(0xaa);
keyboard_at_adddata_mouse(0x00); keyboard_at_adddata_mouse(0x00);
break; break;
// default: // 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 *p)
void mouse_ps2_poll(int x, int y, int b)
{ {
mouse_ps2_t *mouse = (mouse_ps2_t *)p;
uint8_t packet[3] = {0x08, 0, 0}; uint8_t packet[3] = {0x08, 0, 0};
if (!x && !y && b == ps2_b) return;
if (!x && !y && b == mouse->b)
return;
if (!mouse_scan) if (!mouse_scan)
return; return;
ps2_x += x;
ps2_y -= y; mouse->x += x;
if (mouse_ps2.mode == MOUSE_STREAM && (mouse_ps2.flags & MOUSE_ENABLE) && mouse->y -= y;
if (mouse->mode == MOUSE_STREAM && (mouse->flags & MOUSE_ENABLE) &&
((mouse_queue_end - mouse_queue_start) & 0xf) < 13) ((mouse_queue_end - mouse_queue_start) & 0xf) < 13)
{ {
ps2_b = b; mouse->b = b;
// pclog("Send packet : %i %i\n", ps2_x, ps2_y); // pclog("Send packet : %i %i\n", ps2_x, ps2_y);
if (ps2_x > 255) if (mouse->x > 255)
ps2_x = 255; mouse->x = 255;
if (ps2_x < -256) if (mouse->x < -256)
ps2_x = -256; mouse->x = -256;
if (ps2_y > 255) if (mouse->y > 255)
ps2_y = 255; mouse->y = 255;
if (ps2_y < -256) if (mouse->y < -256)
ps2_y = -256; mouse->y = -256;
if (ps2_x < 0) if (mouse->x < 0)
packet[0] |= 0x10; packet[0] |= 0x10;
if (ps2_y < 0) if (mouse->y < 0)
packet[0] |= 0x20; packet[0] |= 0x20;
if (mouse_buttons & 1) if (mouse_buttons & 1)
packet[0] |= 1; packet[0] |= 1;
@ -153,10 +160,10 @@ void mouse_ps2_poll(int x, int y, int b)
packet[0] |= 2; packet[0] |= 2;
if (mouse_buttons & 4) if (mouse_buttons & 4)
packet[0] |= 4; packet[0] |= 4;
packet[1] = ps2_x & 0xff; packet[1] = mouse->x & 0xff;
packet[2] = ps2_y & 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[0]);
keyboard_at_adddata_mouse(packet[1]); 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_ps2_t *mouse = (mouse_ps2_t *)malloc(sizeof(mouse_ps2_t));
mouse_write = mouse_ps2_write; memset(mouse, 0, sizeof(mouse_ps2_t));
mouse_ps2.cd = 0;
mouse_ps2.flags = 0; // mouse_poll = mouse_ps2_poll;
mouse_ps2.mode = MOUSE_STREAM; // 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
};

View file

@ -1 +1 @@
void mouse_ps2_init(); extern mouse_t mouse_ps2_2_button;

View file

@ -4,17 +4,25 @@
#include "serial.h" #include "serial.h"
#include "timer.h" #include "timer.h"
static int oldb=0; typedef struct mouse_serial_t
void mouse_serial_poll(int x, int y, int b)
{ {
int mousepos, mousedelay;
int oldb;
SERIAL *serial;
} mouse_serial_t;
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]; uint8_t mousedat[3];
if (!(serial1.ier & 1)) if (!(serial->ier & 1))
return;
if (!x && !y && b == mouse->oldb)
return; return;
if (!x && !y && b==oldb) return;
oldb=b; mouse->oldb = b;
if (x>127) x=127; if (x>127) x=127;
if (y>127) y=127; if (y>127) y=127;
if (x<-128) x=-128; if (x<-128) x=-128;
@ -29,44 +37,62 @@ void mouse_serial_poll(int x, int y, int b)
mousedat[1]=x&0x3F; mousedat[1]=x&0x3F;
mousedat[2]=y&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]); // pclog("Serial data %02X %02X %02X\n", mousedat[0], mousedat[1], mousedat[2]);
serial_write_fifo(&serial1, mousedat[0]); serial_write_fifo(mouse->serial, mousedat[0]);
serial_write_fifo(&serial1, mousedat[1]); serial_write_fifo(mouse->serial, mousedat[1]);
serial_write_fifo(&serial1, mousedat[2]); serial_write_fifo(mouse->serial, mousedat[2]);
} }
} }
void mouse_serial_rcr(void *p) void mouse_serial_rcr(SERIAL *serial, void *p)
{ {
mousepos=-1; mouse_serial_t *mouse = (mouse_serial_t *)p;
mousedelay=5000 * (1 << TIMER_SHIFT);
mouse->mousepos = -1;
mouse->mousedelay = 5000 * (1 << TIMER_SHIFT);
} }
void mousecallback(void *p) void mousecallback(void *p)
{ {
SERIAL *serial = (SERIAL *)p; mouse_serial_t *mouse = (mouse_serial_t *)p;
mousedelay = 0;
if (mousepos == -1) mouse->mousedelay = 0;
if (mouse->mousepos == -1)
{ {
mousepos = 0; mouse->mousepos = 0;
/* serial_fifo_read = serial_fifo_write = 0; serial_write_fifo(mouse->serial, 'M');
serial.lsr &= ~1;*/
serial_write_fifo(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; 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
};

View file

@ -1 +1 @@
void mouse_serial_init(); extern mouse_t mouse_serial_microsoft;

View file

@ -5,7 +5,6 @@
#include "device.h" #include "device.h"
#include "ali1429.h" #include "ali1429.h"
#include "amstrad.h"
#include "cdrom-ioctl.h" #include "cdrom-ioctl.h"
#include "cdrom-iso.h" #include "cdrom-iso.h"
#include "disc.h" #include "disc.h"
@ -38,6 +37,7 @@
#include "timer.h" #include "timer.h"
#include "vid_voodoo.h" #include "vid_voodoo.h"
#include "video.h" #include "video.h"
#include "amstrad.h"
int window_w, window_h, window_x, window_y, window_remember; int window_w, window_h, window_x, window_y, window_remember;
@ -346,6 +346,7 @@ void resetpc_cad()
void resetpchard() void resetpchard()
{ {
device_close_all(); device_close_all();
mouse_emu_close();
device_init(); device_init();
midi_close(); midi_close();
@ -358,6 +359,7 @@ void resetpchard()
disc_reset(); disc_reset();
model_init(); model_init();
mouse_emu_init();
video_init(); video_init();
speaker_init(); speaker_init();
sound_card_init(sound_card_current); sound_card_init(sound_card_current);
@ -542,6 +544,7 @@ void closepc()
disc_close(1); disc_close(1);
dumpregs(); dumpregs();
closevideo(); closevideo();
mouse_emu_close();
device_close_all(); device_close_all();
midi_close(); midi_close();
} }
@ -600,8 +603,8 @@ void loadconfig(char *fn)
else strcpy(discfns[1], ""); else strcpy(discfns[1], "");
mem_size = config_get_int(NULL, "mem_size", 4096); 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)) if (mem_size < ((models[model].flags & MODEL_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); 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_drive = config_get_int(NULL, "cdrom_drive", 0);
cdrom_enabled = config_get_int(NULL, "cdrom_enabled", 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); window_remember = config_get_int(NULL, "window_remember", 0);
joystick_type = config_get_int(NULL, "joystick_type", 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++) 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, "window_remember", window_remember);
config_set_int(NULL, "joystick_type", joystick_type); 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++) for (c = 0; c < joystick_get_max_joysticks(joystick_type); c++)
{ {

View file

@ -57,13 +57,13 @@ BEGIN
END END
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 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Configure PCem" CAPTION "Configure PCem"
FONT 8, "MS Sans Serif" FONT 8, "MS Sans Serif"
BEGIN BEGIN
DEFPUSHBUTTON "OK",IDOK,64,348,50,14, WS_TABSTOP DEFPUSHBUTTON "OK",IDOK,64,368,50,14, WS_TABSTOP
PUSHBUTTON "Cancel",IDCANCEL,128,348,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 COMBOBOX IDC_COMBO1,62,16,157,120,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "Configure", IDC_CONFIGUREMOD, 224, 16, 40, 14, 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 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 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 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 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 "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,288,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,304,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,320,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,336,118,10 CONTROL "Voodoo Graphics",IDC_CHECKVOODOO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,356,118,10
PUSHBUTTON "Configure", IDC_CONFIGUREVOODOO, 224, 336, 40, 14, WS_TABSTOP PUSHBUTTON "Configure", IDC_CONFIGUREVOODOO, 224, 356, 40, 14, WS_TABSTOP
LTEXT "Machine :",IDC_STATIC,15,16,40,10 LTEXT "Machine :",IDC_STATIC,15,16,40,10
LTEXT "Video :",IDC_STATIC,15,36,34,10 LTEXT "Video :",IDC_STATIC,15,36,34,10
LTEXT "CPU type :",IDC_STATIC,15,56,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 LTEXT "Drive B: :",IDC_STATIC,15,216,40,10
COMBOBOX IDC_COMBODRA,62,196,157,120,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP 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 COMBOBOX IDC_COMBODRB,62,216,157,120,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP
LTEXT "Joystick :",IDC_STATIC,15,236,40,10 LTEXT "Mouse :",IDC_STATIC,15,236,40,10
COMBOBOX IDC_COMBOJOY,62,236,157,120,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP COMBOBOX IDC_COMBOMOUSE,62,236,157,120,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP
DEFPUSHBUTTON "Joystick 1...",IDC_JOY1,16,252,50,14, WS_TABSTOP LTEXT "Joystick :",IDC_STATIC,15,256,40,10
PUSHBUTTON "Joystick 2...",IDC_JOY2,80,252,50,14, WS_TABSTOP COMBOBOX IDC_COMBOJOY,62,256,157,120,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP
DEFPUSHBUTTON "Joystick 3...",IDC_JOY3,144,252,50,14, WS_TABSTOP DEFPUSHBUTTON "Joystick 1...",IDC_JOY1,16,272,50,14, WS_TABSTOP
PUSHBUTTON "Joystick 4...",IDC_JOY4,208,252,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 END
HdConfDlg DIALOGEX 0, 0, 210, 312+4*16 HdConfDlg DIALOGEX 0, 0, 210, 312+4*16

View file

@ -38,6 +38,7 @@
#define IDC_COMBODRB 1063 #define IDC_COMBODRB 1063
#define IDC_COMBOJOY 1064 #define IDC_COMBOJOY 1064
#define IDC_COMBOWS 1065 #define IDC_COMBOWS 1065
#define IDC_COMBOMOUSE 1066
#define IDC_CHECK1 1010 #define IDC_CHECK1 1010
#define IDC_CHECK2 1011 #define IDC_CHECK2 1011
#define IDC_CHECK3 1012 #define IDC_CHECK3 1012

View file

@ -15,14 +15,11 @@ enum
SERIAL serial1, serial2; SERIAL serial1, serial2;
int mousepos=-1;
int mousedelay;
void serial_reset() void serial_reset()
{ {
serial1.iir = serial1.ier = serial1.lcr = 0; serial1.iir = serial1.ier = serial1.lcr = 0;
serial2.iir = serial2.ier = serial2.lcr = 0; serial2.iir = serial2.ier = serial2.lcr = 0;
mousedelay = 0;
serial1.fifo_read = serial1.fifo_write = 0; serial1.fifo_read = serial1.fifo_write = 0;
serial2.fifo_read = serial2.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 ((val & 2) && !(serial->mctrl & 2))
{ {
if (serial->rcr_callback) if (serial->rcr_callback)
serial->rcr_callback(serial); serial->rcr_callback(serial, serial->rcr_callback_p);
// pclog("RCR raised! sending M\n"); // pclog("RCR raised! sending M\n");
} }
serial->mctrl = val; serial->mctrl = val;

View file

@ -18,7 +18,8 @@ typedef struct
int irq; int irq;
void (*rcr_callback)(void *p); void (*rcr_callback)(struct SERIAL *serial, void *p);
void *rcr_callback_p;
uint8_t fifo[256]; uint8_t fifo[256];
int fifo_read, fifo_write; int fifo_read, fifo_write;

View file

@ -41,7 +41,6 @@ COM2 :
#include "fdc.h" #include "fdc.h"
#include "io.h" #include "io.h"
#include "lpt.h" #include "lpt.h"
#include "mouse_serial.h"
#include "serial.h" #include "serial.h"
#include "um8669f.h" #include "um8669f.h"
@ -103,8 +102,6 @@ void um8669f_write(uint16_t port, uint8_t val, void *priv)
} }
} }
mouse_serial_init();
lpt1_remove(); lpt1_remove();
lpt2_remove(); lpt2_remove();
temp = (um8669f_regs[0xc3] >> 4) & 3; temp = (um8669f_regs[0xc3] >> 4) & 3;

View file

@ -11,6 +11,7 @@
#include "fdd.h" #include "fdd.h"
#include "gameport.h" #include "gameport.h"
#include "model.h" #include "model.h"
#include "mouse.h"
#include "nvr.h" #include "nvr.h"
#include "resources.h" #include "resources.h"
#include "sound.h" #include "sound.h"
@ -21,6 +22,18 @@
extern int is486; extern int is486;
static int romstolist[ROM_MAX], listtomodel[ROM_MAX], romstomodel[ROM_MAX], modeltolist[ROM_MAX]; 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_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) 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_fda_type, temp_fdb_type;
int temp_joystick_type; int temp_joystick_type;
int cpu_type; int cpu_type;
int temp_mouse_type;
UDACCEL accel; UDACCEL accel;
// pclog("Dialog msg %i %08X\n",message,message); // 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); h = GetDlgItem(hdlg, IDC_MEMSPIN);
SendMessage(h, UDM_SETBUDDY, (WPARAM)GetDlgItem(hdlg, IDC_MEMTEXT), 0); 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); 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); SendMessage(h, UDM_SETPOS, 0, mem_size);
else else
SendMessage(h, UDM_SETPOS, 0, mem_size / 1024); 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); SendMessage(h, CB_SETCURSEL, fdd_get_type(1), 0);
h = GetDlgItem(hdlg, IDC_TEXT_MB); 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"); SendMessage(h, WM_SETTEXT, 0, (LPARAM)(LPCSTR)"MB");
else else
SendMessage(h, WM_SETTEXT, 0, (LPARAM)(LPCSTR)"KB"); 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); EnableWindow(h, TRUE);
else else
EnableWindow(h, FALSE); 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; return TRUE;
case WM_COMMAND: 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; mem = models[temp_model].min_ram;
else if (mem > models[temp_model].max_ram) else if (mem > models[temp_model].max_ram)
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; mem *= 1024;
h = GetDlgItem(hdlg, IDC_COMBOVID); 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); h = GetDlgItem(hdlg, IDC_COMBOJOY);
temp_joystick_type = SendMessage(h, CB_GETCURSEL, 0, 0); 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 || if (temp_model != model || gfx != gfxcard || mem != mem_size ||
fpu != hasfpu || temp_GAMEBLASTER != GAMEBLASTER || temp_GUS != GUS || fpu != hasfpu || temp_GAMEBLASTER != GAMEBLASTER || temp_GUS != GUS ||
temp_SSI2001 != SSI2001 || temp_sound_card_current != sound_card_current || temp_SSI2001 != SSI2001 || temp_sound_card_current != sound_card_current ||
temp_voodoo != voodoo_enabled || temp_dynarec != cpu_use_dynarec || 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) 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; sound_card_current = temp_sound_card_current;
voodoo_enabled = temp_voodoo; voodoo_enabled = temp_voodoo;
cpu_use_dynarec = temp_dynarec; cpu_use_dynarec = temp_dynarec;
mouse_type = temp_mouse_type;
fdd_set_type(0, temp_fda_type); fdd_set_type(0, temp_fda_type);
fdd_set_type(1, temp_fdb_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); SendMessage(h, BM_SETCHECK, ((cpu_flags & CPU_SUPPORTS_DYNAREC) && temp_dynarec) || (cpu_flags & CPU_REQUIRES_DYNAREC), 0);
h = GetDlgItem(hdlg, IDC_TEXT_MB); 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"); SendMessage(h, WM_SETTEXT, 0, (LPARAM)(LPCSTR)"MB");
else else
SendMessage(h, WM_SETTEXT, 0, (LPARAM)(LPCSTR)"KB"); 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); EnableWindow(h, TRUE);
else else
EnableWindow(h, FALSE); 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; break;
case IDC_COMBOCPUM: case IDC_COMBOCPUM: