From 7b09063fbcaf50c56b476a744f9f3d9634777740 Mon Sep 17 00:00:00 2001
From: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
Date: Mon, 24 Sep 2012 21:46:09 +0300
Subject: [PATCH 08/10] Add needed support for detecting true polls as opposed
 to just autopolling

---
 snes/cpu/cpu.hpp       |  1 +
 snes/cpu/mmio/mmio.cpp | 18 ++++++++++--------
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/snes/cpu/cpu.hpp b/snes/cpu/cpu.hpp
index 67a56d1..976a4a6 100755
--- a/snes/cpu/cpu.hpp
+++ b/snes/cpu/cpu.hpp
@@ -25,6 +25,7 @@ struct CPU : public Processor, public CPUcore, public PPUcounter {
   CPU();
   ~CPU();
 
+  bool controller_flag;
 private:
   #include "dma/dma.hpp"
   #include "memory/memory.hpp"
diff --git a/snes/cpu/mmio/mmio.cpp b/snes/cpu/mmio/mmio.cpp
index 8b6aaa6..c5ee930 100755
--- a/snes/cpu/mmio/mmio.cpp
+++ b/snes/cpu/mmio/mmio.cpp
@@ -42,6 +42,7 @@ void CPU::mmio_w4016(uint8 data) {
 //1-0 = Joypad serial data
 uint8 CPU::mmio_r4016() {
   uint8 r = regs.mdr & 0xfc;
+  controller_flag = true;
   r |= input.port1->data();
   return r;
 }
@@ -52,6 +53,7 @@ uint8 CPU::mmio_r4016() {
 //1-0 = Joypad serial data
 uint8 CPU::mmio_r4017() {
   uint8 r = (regs.mdr & 0xe0) | 0x1c;
+  controller_flag = true;
   r |= input.port2->data();
   return r;
 }
@@ -204,14 +206,14 @@ uint8 CPU::mmio_r4217() {
   return status.rdmpy >> 8;
 }
 
-uint8 CPU::mmio_r4218() { return status.joy1 >> 0; }  //JOY1L
-uint8 CPU::mmio_r4219() { return status.joy1 >> 8; }  //JOY1H
-uint8 CPU::mmio_r421a() { return status.joy2 >> 0; }  //JOY2L
-uint8 CPU::mmio_r421b() { return status.joy2 >> 8; }  //JOY2H
-uint8 CPU::mmio_r421c() { return status.joy3 >> 0; }  //JOY3L
-uint8 CPU::mmio_r421d() { return status.joy3 >> 8; }  //JOY3H
-uint8 CPU::mmio_r421e() { return status.joy4 >> 0; }  //JOY4L
-uint8 CPU::mmio_r421f() { return status.joy4 >> 8; }  //JOY4H
+uint8 CPU::mmio_r4218() { controller_flag = true; return status.joy1 >> 0; }  //JOY1L
+uint8 CPU::mmio_r4219() { controller_flag = true; return status.joy1 >> 8; }  //JOY1H
+uint8 CPU::mmio_r421a() { controller_flag = true; return status.joy2 >> 0; }  //JOY2L
+uint8 CPU::mmio_r421b() { controller_flag = true; return status.joy2 >> 8; }  //JOY2H
+uint8 CPU::mmio_r421c() { controller_flag = true; return status.joy3 >> 0; }  //JOY3L
+uint8 CPU::mmio_r421d() { controller_flag = true; return status.joy3 >> 8; }  //JOY3H
+uint8 CPU::mmio_r421e() { controller_flag = true; return status.joy4 >> 0; }  //JOY4L
+uint8 CPU::mmio_r421f() { controller_flag = true; return status.joy4 >> 8; }  //JOY4H
 
 //DMAPx
 uint8 CPU::mmio_r43x0(uint8 i) {
-- 
1.8.4.4

