From 82daa5e89908e89e03147f42ad9226938576024f Mon Sep 17 00:00:00 2001 From: TC1995 Date: Sat, 8 Oct 2016 23:50:49 +0200 Subject: [PATCH] (nw) --- src/mouse_amstrad.c | 63 +++++++++++++++++++++++++++++++++++++++++++++ src/mouse_amstrad.h | 4 +++ 2 files changed, 67 insertions(+) create mode 100644 src/mouse_amstrad.c create mode 100644 src/mouse_amstrad.h diff --git a/src/mouse_amstrad.c b/src/mouse_amstrad.c new file mode 100644 index 000000000..e880f15c9 --- /dev/null +++ b/src/mouse_amstrad.c @@ -0,0 +1,63 @@ +/* Copyright holders: SA1988, Curt Coder + see COPYING for more details +*/ +#include "ibm.h" +#include "io.h" +#include "mouse.h" +#include "mouse_amstrad.h" + +static int amstrad_x = 0, amstrad_y = 0, amstrad_b = 0; + +uint8_t mouse_amstrad_read(uint16_t port, void *priv) +{ + switch (port) + { + case 0x78: + return amstrad_x; + + case 0x7a: + return amstrad_y; + } + return 0xff; +} + +void mouse_amstrad_write(uint16_t port, uint8_t val, void *priv) +{ + switch (port) + { + case 0x78: + amstrad_x = 0; + break; + + case 0x7a: + amstrad_y = 0; + break; + } +} + +void mouse_amstrad_poll(int x, int y, int b) +{ + if (!x && !y && b==amstrad_b) return; + + amstrad_b=b; + if (x > amstrad_x) + amstrad_x+=3; + else + amstrad_x-=3; + + amstrad_x = x; + + if (y > amstrad_y) + amstrad_y+=3; + else + amstrad_y-=3; + + amstrad_y = y; +} + +void mouse_amstrad_init() +{ + mouse_poll = mouse_amstrad_poll; + io_sethandler(0x0078, 0x0001, mouse_amstrad_read, NULL, NULL, mouse_amstrad_write, NULL, NULL, NULL); + io_sethandler(0x007a, 0x0001, mouse_amstrad_read, NULL, NULL, mouse_amstrad_write, NULL, NULL, NULL); +} diff --git a/src/mouse_amstrad.h b/src/mouse_amstrad.h new file mode 100644 index 000000000..922397d7b --- /dev/null +++ b/src/mouse_amstrad.h @@ -0,0 +1,4 @@ +/* Copyright holders: SA1988 + see COPYING for more details +*/ +void mouse_amstrad_init();