Add <functional> to files that use std::function
[lsnes.git] / bsnes-patches / v085 / 0023-Add-autopoller-and-IRQ-NMI-tracing.patch
blob39b4386f9bb93accc623c938ecb15c14e7910675
1 From 9682df9e33c366dfe047a99c8bcefc2c8ab29620 Mon Sep 17 00:00:00 2001
2 From: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
3 Date: Sat, 24 Jan 2015 16:46:18 +0200
4 Subject: [PATCH 23/27] Add autopoller and IRQ/NMI tracing
6 ---
7 snes/cpu/cpu.cpp | 3 +++
8 snes/cpu/timing/joypad.cpp | 16 ++++++++++++++--
9 2 files changed, 17 insertions(+), 2 deletions(-)
11 diff --git a/snes/cpu/cpu.cpp b/snes/cpu/cpu.cpp
12 index ce112afa..e11fc882 100755
13 --- a/snes/cpu/cpu.cpp
14 +++ b/snes/cpu/cpu.cpp
15 @@ -69,14 +69,17 @@ void CPU::enter() {
16 if(status.interrupt_pending) {
17 status.interrupt_pending = false;
18 if(status.nmi_pending) {
19 + if(dma_trace_fn) dma_trace_fn("-- NMI occured --");
20 status.nmi_pending = false;
21 regs.vector = (regs.e == false ? 0xffea : 0xfffa);
22 op_irq();
23 } else if(status.irq_pending) {
24 + if(dma_trace_fn) dma_trace_fn("-- IRQ occured --");
25 status.irq_pending = false;
26 regs.vector = (regs.e == false ? 0xffee : 0xfffe);
27 op_irq();
28 } else if(status.reset_pending) {
29 + if(dma_trace_fn) dma_trace_fn("-- RESET occured --");
30 status.reset_pending = false;
31 add_clocks(186);
32 regs.pc.l = bus.read(0xfffc, false);
33 diff --git a/snes/cpu/timing/joypad.cpp b/snes/cpu/timing/joypad.cpp
34 index 3fd4d23e..afca7504 100755
35 --- a/snes/cpu/timing/joypad.cpp
36 +++ b/snes/cpu/timing/joypad.cpp
37 @@ -6,9 +6,9 @@ void CPU::step_auto_joypad_poll() {
38 //cache enable state at first iteration
39 if(status.auto_joypad_counter == 0) status.auto_joypad_latch = status.auto_joypad_poll;
40 status.auto_joypad_active = status.auto_joypad_counter <= 15;
42 if(status.auto_joypad_active && status.auto_joypad_latch) {
43 if(status.auto_joypad_counter == 0) {
44 + if(dma_trace_fn) dma_trace_fn("-- Start automatic polling --");
45 interface->notifyLatched();
46 input.port1->latch(1);
47 input.port2->latch(1);
48 @@ -23,6 +23,12 @@ void CPU::step_auto_joypad_poll() {
49 status.joy2 = (status.joy2 << 1) | (bool)(port1 & 1);
50 status.joy3 = (status.joy3 << 1) | (bool)(port0 & 2);
51 status.joy4 = (status.joy4 << 1) | (bool)(port1 & 2);
52 + if(status.auto_joypad_counter == 15) {
53 + char buf[512];
54 + sprintf(buf, "-- End automatic polling [%04x %04x %04x %04x] --",
55 + status.joy1, status.joy2, status.joy3, status.joy4);
56 + if(dma_trace_fn) dma_trace_fn(buf);
57 + }
60 status.auto_joypad_counter++;
61 @@ -40,6 +46,7 @@ void CPU::step_auto_joypad_poll_NEW(bool polarity) {
62 status.auto_joypad_active = false;
63 } else {
64 if(status.auto_joypad_counter == 1) {
65 + if(dma_trace_fn) dma_trace_fn("-- Start automatic polling --");
66 status.auto_joypad_active = true;
67 interface->notifyLatched();
68 input.port1->latch(1);
69 @@ -58,8 +65,13 @@ void CPU::step_auto_joypad_poll_NEW(bool polarity) {
70 status.joy3 = (status.joy3 << 1) | (bool)(port0 & 2);
71 status.joy4 = (status.joy4 << 1) | (bool)(port1 & 2);
73 - if(status.auto_joypad_counter == 34)
74 + if(status.auto_joypad_counter == 34) {
75 status.auto_joypad_active = false;
76 + char buf[512];
77 + sprintf(buf, "-- End automatic polling [%04x %04x %04x %04x] --",
78 + status.joy1, status.joy2, status.joy3, status.joy4);
79 + if(dma_trace_fn) dma_trace_fn(buf);
80 + }
82 status.auto_joypad_counter++;
84 --
85 2.15.0.rc1