Bus fixes: Reading of CPU MMIO registers does not update MDR
[lsnes.git] / bsnes-patches / v085 / 0011-Support-notifying-latches.patch
blobf9f285d73ff2f056e52c8bf068d580229b70c225
1 From e047aa8eb9883f60e4141effba8128a4a555d8be Mon Sep 17 00:00:00 2001
2 From: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
3 Date: Sun, 27 Oct 2013 10:52:45 +0200
4 Subject: [PATCH 11/27] Support notifying latches
6 ---
7 snes/cpu/mmio/mmio.cpp | 1 +
8 snes/cpu/timing/joypad.cpp | 1 +
9 snes/interface/interface.cpp | 5 +++++
10 snes/interface/interface.hpp | 1 +
11 4 files changed, 8 insertions(+)
13 diff --git a/snes/cpu/mmio/mmio.cpp b/snes/cpu/mmio/mmio.cpp
14 index c5ee930f..b7afff00 100755
15 --- a/snes/cpu/mmio/mmio.cpp
16 +++ b/snes/cpu/mmio/mmio.cpp
17 @@ -33,6 +33,7 @@ void CPU::mmio_w2183(uint8 data) {
18 //strobing $4016.d0 affects both controller port latches.
19 //$4017 bit 0 writes are ignored.
20 void CPU::mmio_w4016(uint8 data) {
21 + if(data&1) interface->notifyLatched();
22 input.port1->latch(data & 1);
23 input.port2->latch(data & 1);
25 diff --git a/snes/cpu/timing/joypad.cpp b/snes/cpu/timing/joypad.cpp
26 index 179df27d..6a98de00 100755
27 --- a/snes/cpu/timing/joypad.cpp
28 +++ b/snes/cpu/timing/joypad.cpp
29 @@ -9,6 +9,7 @@ void CPU::step_auto_joypad_poll() {
31 if(status.auto_joypad_active && status.auto_joypad_latch) {
32 if(status.auto_joypad_counter == 0) {
33 + interface->notifyLatched();
34 input.port1->latch(1);
35 input.port2->latch(1);
36 input.port1->latch(0);
37 diff --git a/snes/interface/interface.cpp b/snes/interface/interface.cpp
38 index 0a21a132..6685556c 100755
39 --- a/snes/interface/interface.cpp
40 +++ b/snes/interface/interface.cpp
41 @@ -28,4 +28,9 @@ time_t Interface::randomSeed()
42 return time(0);
45 +void Interface::notifyLatched()
47 + //Nothing.
51 diff --git a/snes/interface/interface.hpp b/snes/interface/interface.hpp
52 index 30ee7fde..203f7b0c 100755
53 --- a/snes/interface/interface.hpp
54 +++ b/snes/interface/interface.hpp
55 @@ -7,6 +7,7 @@ struct Interface {
56 virtual void message(const string &text);
57 virtual time_t currentTime();
58 virtual time_t randomSeed();
59 + virtual void notifyLatched();
62 extern Interface *interface;
63 --
64 2.15.0.rc1