1 From 13643c86bfff3871968cf6e8b4f991465d4e81e7 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 7/8] Support notifying latches
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 c5ee930..b7afff0 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 179df27..6a98de0 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 0a21a13..6685556 100755
39 --- a/snes/interface/interface.cpp
40 +++ b/snes/interface/interface.cpp
41 @@ -28,4 +28,9 @@ time_t Interface::randomSeed()
45 +void Interface::notifyLatched()
51 diff --git a/snes/interface/interface.hpp b/snes/interface/interface.hpp
52 index 30ee7fd..203f7b0 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;