From b744bde2e7cef250d1ec9ed7775ff013613ba722 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 26 Jul 2017 00:11:14 +0200 Subject: [PATCH] Merge remaining files --- core/input_hw/mouse.c | 36 ++++++++++++++++++------------------ core/input_hw/mouse.h | 4 ++-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/core/input_hw/mouse.c b/core/input_hw/mouse.c index c1db5d6..4fdda28 100644 --- a/core/input_hw/mouse.c +++ b/core/input_hw/mouse.c @@ -1,8 +1,8 @@ /*************************************************************************************** * Genesis Plus - * Sega Mouse support + * Sega/Mega Mouse support * - * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) + * Copyright (C) 2007-2017 Eke-Eke (Genesis Plus GX) * * Redistribution and use of this code or any derivative works are permitted * provided that the following conditions are met: @@ -113,15 +113,15 @@ unsigned char mouse_read() /* TL = busy status */ if (mouse.Wait) { - /* wait before ACK, fix some buggy mouse routine (Cannon Fodder, Shangai 2, Wack World,...) */ - mouse.Wait = 0; + /* wait before acknowledging handshake request */ + mouse.Wait--; - /* TL = !TR */ - temp |= (~mouse.State & 0x20) >> 1; + /* TL = !TR (handshake in progress) */ + temp |= (~mouse.State & 0x20) >> 1;; } else { - /* TL = TR (data is ready) */ + /* TL = TR (handshake completed) */ temp |= (mouse.State & 0x20) >> 1; } @@ -133,25 +133,25 @@ void mouse_write(unsigned char data, unsigned char mask) /* update bits set as output only */ data = (mouse.State & ~mask) | (data & mask); - /* TH transition */ - if ((mouse.State ^ data) & 0x40) - { - /* start (TH=0) or stop (TH=1) acquisition */ - mouse.Counter = 1 - ((data & 0x40) >> 6); - } - /* TR transition */ if ((mouse.State ^ data) & 0x20) { - /* acquisition in progress */ - if ((mouse.Counter > 0) && (mouse.Counter < 10)) + /* check if acquisition is started */ + if ((mouse.Counter > 0) && (mouse.Counter < 9)) { /* increment phase */ mouse.Counter++; } - /* TL handshake latency */ - mouse.Wait = 1; + /* TL handshake latency (fix buggy mouse routine in Cannon Fodder, Shangai 2, Wacky World, Star Blade, ...) */ + mouse.Wait = 2; + } + + /* TH transition */ + if ((mouse.State ^ data) & 0x40) + { + /* start (TH=1->0) or stop (TH=0->1) data acquisition */ + mouse.Counter = (mouse.State >> 6) & 1; } /* update internal state */ diff --git a/core/input_hw/mouse.h b/core/input_hw/mouse.h index 6657d2a..baff23c 100644 --- a/core/input_hw/mouse.h +++ b/core/input_hw/mouse.h @@ -1,8 +1,8 @@ /*************************************************************************************** * Genesis Plus - * Sega Mouse support + * Sega/Mega Mouse support * - * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) + * Copyright (C) 2007-2017 Eke-Eke (Genesis Plus GX) * * Redistribution and use of this code or any derivative works are permitted * provided that the following conditions are met: