Allow bsnes tracelogger to trace execution in controller registers
[lsnes.git] / bsnes-patches / v085 / 0015-Fix-mouse-speed-support.patch
blob3fc3b1b14d2da36bb17821501194d81e3757858f
1 From 863bde899b53ae31e854096ac5258208c848a293 Mon Sep 17 00:00:00 2001
2 From: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
3 Date: Thu, 6 Mar 2014 21:07:54 +0200
4 Subject: [PATCH 15/16] Fix mouse speed support
6 ---
7 snes/config/config.cpp | 1 +
8 snes/config/config.hpp | 3 +++
9 snes/controller/mouse/mouse.cpp | 11 +++++++++--
10 snes/controller/mouse/mouse.hpp | 1 +
11 4 files changed, 14 insertions(+), 2 deletions(-)
13 diff --git a/snes/config/config.cpp b/snes/config/config.cpp
14 index 206daae..1983137 100755
15 --- a/snes/config/config.cpp
16 +++ b/snes/config/config.cpp
17 @@ -8,6 +8,7 @@ Configuration::Configuration() {
18 expansion_port = System::ExpansionPortDevice::BSX;
19 region = System::Region::Autodetect;
20 random = true;
21 + mouse_speed_fix = false;
23 cpu.version = 2;
24 cpu.ntsc_frequency = 21477272; //315 / 88 * 6000000
25 diff --git a/snes/config/config.hpp b/snes/config/config.hpp
26 index dabde59..68fe0bd 100755
27 --- a/snes/config/config.hpp
28 +++ b/snes/config/config.hpp
29 @@ -1,9 +1,12 @@
30 +#define BSNES_SUPPORTS_MOUSE_SPEED_FIX
32 struct Configuration {
33 Input::Device controller_port1;
34 Input::Device controller_port2;
35 System::ExpansionPortDevice expansion_port;
36 System::Region region;
37 bool random;
38 + bool mouse_speed_fix;
40 struct CPU {
41 unsigned version;
42 diff --git a/snes/controller/mouse/mouse.cpp b/snes/controller/mouse/mouse.cpp
43 index 1a066b9..caa7a35 100755
44 --- a/snes/controller/mouse/mouse.cpp
45 +++ b/snes/controller/mouse/mouse.cpp
46 @@ -1,6 +1,10 @@
47 #ifdef CONTROLLER_CPP
49 uint2 Mouse::data() {
50 + if(config.mouse_speed_fix && latched) {
51 + speed = (speed + 1) % 3;
52 + return 0;
53 + }
54 if(counter >= 32) return 1;
56 if(counter == 0) {
57 @@ -31,8 +35,8 @@ uint2 Mouse::data() {
59 case 8: return interface->inputPoll(port, Input::Device::Mouse, 0, (unsigned)Input::MouseID::Right);
60 case 9: return interface->inputPoll(port, Input::Device::Mouse, 0, (unsigned)Input::MouseID::Left);
61 - case 10: return 0; //speed (0 = slow, 1 = normal, 2 = fast, 3 = unused)
62 - case 11: return 0; // ||
63 + case 10: return speed >> 1; //speed (0 = slow, 1 = normal, 2 = fast, 3 = unused)
64 + case 11: return speed & 1; // ||
66 case 12: return 0; //signature
67 case 13: return 0; // ||
68 @@ -75,10 +79,12 @@ void Mouse::serialize(serializer& s) {
69 block[3] = (unsigned short)_position_x;
70 block[4] = (unsigned short)_position_y >> 8;
71 block[5] = (unsigned short)_position_y;
72 + block[6] = speed;
73 s.array(block, Controller::SaveSize);
74 if(s.mode() == nall::serializer::Load) {
75 latched = (block[0] != 0);
76 counter = block[1];
77 + speed = block[6];
78 _position_x = (short)(((unsigned short)block[2] << 8) | (unsigned short)block[3]);
79 _position_y = (short)(((unsigned short)block[4] << 8) | (unsigned short)block[5]);
81 @@ -87,6 +93,7 @@ void Mouse::serialize(serializer& s) {
82 Mouse::Mouse(bool port) : Controller(port) {
83 latched = 0;
84 counter = 0;
85 + speed = 0;
88 #endif
89 diff --git a/snes/controller/mouse/mouse.hpp b/snes/controller/mouse/mouse.hpp
90 index b07c8ab..13a9313 100755
91 --- a/snes/controller/mouse/mouse.hpp
92 +++ b/snes/controller/mouse/mouse.hpp
93 @@ -6,6 +6,7 @@ struct Mouse : Controller {
94 private:
95 bool latched;
96 unsigned counter;
97 + unsigned speed;
98 int _position_x;
99 int _position_y;
102 1.9.0