From 84c4fa197b18d8ffebb16240a72252400f791ed6 Mon Sep 17 00:00:00 2001
From: Thomas Harte <thomas.harte@gmail.com>
Date: Wed, 7 Oct 2020 18:48:03 -0400
Subject: [PATCH] Corrects DEX mapping, notes new Dormann failure case.

---
 OSBindings/Mac/Clock SignalTests/KlausDormannTests.swift | 1 +
 Processors/65816/Implementation/65816Implementation.hpp  | 2 +-
 Processors/65816/Implementation/65816Storage.cpp         | 2 +-
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/OSBindings/Mac/Clock SignalTests/KlausDormannTests.swift b/OSBindings/Mac/Clock SignalTests/KlausDormannTests.swift
index 94b45a3c4..497104d4c 100644
--- a/OSBindings/Mac/Clock SignalTests/KlausDormannTests.swift	
+++ b/OSBindings/Mac/Clock SignalTests/KlausDormannTests.swift	
@@ -44,6 +44,7 @@ class KlausDormannTests: XCTestCase {
 			switch address {
 				case 0x3399: return nil // success!
 
+				case 0x052a: return "DEX did not correctly set zero flag"
 				case 0x33a7: return "Decimal ADC result has wrong value"
 				case 0x3502: return "Binary SBC result has wrong value"
 				case 0x33b9: return "Decimal SBC result has wrong value"
diff --git a/Processors/65816/Implementation/65816Implementation.hpp b/Processors/65816/Implementation/65816Implementation.hpp
index 35a559e23..4c23bdb2e 100644
--- a/Processors/65816/Implementation/65816Implementation.hpp
+++ b/Processors/65816/Implementation/65816Implementation.hpp
@@ -51,7 +51,7 @@ template <typename BusHandler> void Processor<BusHandler>::run_for(const Cycles
 
 			case OperationDecode: {
 				// A VERY TEMPORARY piece of logging.
-				printf("[%04x] %02x\n", pc_ - 2, instruction_buffer_.value);	// pc_ - 1 would be correct but this matches a log I made of the 6502.
+				printf("[%04x] %02x a:%04x x:%04x y:%04x p:%02x\n", pc_ - 1, instruction_buffer_.value, a_.full, x_.full, y_.full, flags_.get());	// pc_ - 1 would be correct but this matches a log I made of the 6502.
 				active_instruction_ = &instructions[instruction_buffer_.value];
 
 				const auto size_flag = mx_flags_[active_instruction_->size_field];
diff --git a/Processors/65816/Implementation/65816Storage.cpp b/Processors/65816/Implementation/65816Storage.cpp
index e20e162e2..58dc50a03 100644
--- a/Processors/65816/Implementation/65816Storage.cpp
+++ b/Processors/65816/Implementation/65816Storage.cpp
@@ -926,7 +926,7 @@ ProcessorStorage::ProcessorStorage() {
 	/* 0xc7 CMP [d] */			op(direct_indirect_long, CMP);
 	/* 0xc8 INY i */			op(implied, INY);
 	/* 0xc9 CMP # */			op(immediate, CMP);
-	/* 0xca DEX i */			op(implied, DEC);
+	/* 0xca DEX i */			op(implied, DEX);
 	/* 0xcb WAI i */			op(wai, WAI);
 	/* 0xcc CPY a */			op(absolute, CPY);
 	/* 0xcd CMP a */			op(absolute, CMP);