diff --git a/OSBindings/Mac/Clock Signal/Base.lproj/Atari2600Options.xib b/OSBindings/Mac/Clock Signal/Base.lproj/Atari2600Options.xib
index c05cc35cd..50926faf4 100644
--- a/OSBindings/Mac/Clock Signal/Base.lproj/Atari2600Options.xib
+++ b/OSBindings/Mac/Clock Signal/Base.lproj/Atari2600Options.xib
@@ -12,7 +12,7 @@
-
+
diff --git a/OSBindings/Mac/Clock Signal/Base.lproj/ElectronOptions.xib b/OSBindings/Mac/Clock Signal/Base.lproj/ElectronOptions.xib
index 39521bbd1..20ebefd9a 100644
--- a/OSBindings/Mac/Clock Signal/Base.lproj/ElectronOptions.xib
+++ b/OSBindings/Mac/Clock Signal/Base.lproj/ElectronOptions.xib
@@ -12,7 +12,7 @@
-
+
diff --git a/OSBindings/Mac/Clock Signal/Base.lproj/Vic20Options.xib b/OSBindings/Mac/Clock Signal/Base.lproj/Vic20Options.xib
index 4c477e080..2284abe76 100644
--- a/OSBindings/Mac/Clock Signal/Base.lproj/Vic20Options.xib
+++ b/OSBindings/Mac/Clock Signal/Base.lproj/Vic20Options.xib
@@ -12,7 +12,7 @@
-
+
diff --git a/OSBindings/Mac/Clock SignalTests/DPLLTests.swift b/OSBindings/Mac/Clock SignalTests/DPLLTests.swift
index 366b39da2..67113b928 100644
--- a/OSBindings/Mac/Clock SignalTests/DPLLTests.swift
+++ b/OSBindings/Mac/Clock SignalTests/DPLLTests.swift
@@ -56,6 +56,6 @@ class DPLLTests: XCTestCase {
}
let endOfStream = (pll?.stream)!&0xffffffff;
- XCTAssert(endOfStream == 0xaaaaaaaa || endOfStream == 0x55555555, "PLL should have synchronised and clocked repeating 0xa or 0x5 nibbles; got \(String(pll?.stream, radix: 16, uppercase: false))")
+ XCTAssert(endOfStream == 0xaaaaaaaa || endOfStream == 0x55555555, "PLL should have synchronised and clocked repeating 0xa or 0x5 nibbles; got \(String(pll!.stream, radix: 16, uppercase: false))")
}
}
diff --git a/OSBindings/Mac/Clock SignalTests/WolfgangLorenzTests.swift b/OSBindings/Mac/Clock SignalTests/WolfgangLorenzTests.swift
index 8bd25ecc3..e30dae422 100644
--- a/OSBindings/Mac/Clock SignalTests/WolfgangLorenzTests.swift
+++ b/OSBindings/Mac/Clock SignalTests/WolfgangLorenzTests.swift
@@ -208,7 +208,7 @@ class WolfgangLorenzTests: XCTestCase, CSTestMachineJamHandler {
let dataPointer = (testData as NSData).bytes.bindMemory(to: UInt8.self, capacity: testData.count)
let loadAddress = UInt16(dataPointer[0]) | (UInt16(dataPointer[1]) << 8)
- let contents = testData.subdata(in: NSMakeRange(2, testData.count - 2))
+ let contents = testData.subdata(in: 2..<(testData.count - 2))
machine.setData(contents, atAddress: loadAddress)
diff --git a/Processors/6502/CPU6502.hpp b/Processors/6502/CPU6502.hpp
index baa2a5882..1d2f3e977 100644
--- a/Processors/6502/CPU6502.hpp
+++ b/Processors/6502/CPU6502.hpp
@@ -833,25 +833,22 @@ template class Processor {
case OperationADC:
if(_decimalFlag) {
const uint16_t decimalResult = (uint16_t)_a + (uint16_t)_operand + (uint16_t)_carryFlag;
- uint16_t temp16;
- temp16 = (_a&0xf) + (_operand&0xf) + _carryFlag;
- if(temp16 > 0x9) temp16 += 0x6;
- temp16 = (temp16&0x0f) + ((temp16 > 0x0f) ? 0x10 : 0x00) + (_a&0xf0) + (_operand&0xf0);
+ uint8_t low_nibble = (_a & 0xf) + (_operand & 0xf) + _carryFlag;
+ if(low_nibble >= 0xa) low_nibble = ((low_nibble + 0x6) & 0xf) + 0x10;
+ uint16_t result = (uint16_t)(_a & 0xf0) + (uint16_t)(_operand & 0xf0) + (uint16_t)low_nibble;
+ _negativeResult = (uint8_t)result;
+ _overflowFlag = (( (result^_a)&(result^_operand) )&0x80) >> 1;
+ if(result >= 0xa0) result += 0x60;
- _overflowFlag = (( (decimalResult^_a)&(decimalResult^_operand) )&0x80) >> 1;
- _negativeResult = (uint8_t)temp16;
+ _carryFlag = (result >> 8) ? 1 : 0;
+ _a = (uint8_t)result;
_zeroResult = (uint8_t)decimalResult;
-
- if(temp16 > 0x9f) temp16 += 0x60;
-
- _carryFlag = (temp16 > 0xff) ? Flag::Carry : 0;
- _a = (uint8_t)temp16;
} else {
- const uint16_t decimalResult = (uint16_t)_a + (uint16_t)_operand + (uint16_t)_carryFlag;
- _overflowFlag = (( (decimalResult^_a)&(decimalResult^_operand) )&0x80) >> 1;
- _negativeResult = _zeroResult = _a = (uint8_t)decimalResult;
- _carryFlag = (decimalResult >> 8)&1;
+ const uint16_t result = (uint16_t)_a + (uint16_t)_operand + (uint16_t)_carryFlag;
+ _overflowFlag = (( (result^_a)&(result^_operand) )&0x80) >> 1;
+ _negativeResult = _zeroResult = _a = (uint8_t)result;
+ _carryFlag = (result >> 8)&1;
}
// fix up in case this was INS