1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-23 20:29:42 +00:00

Implements proper test for ADC/SBC 65C02 NZ, though not yet the proper timing.

This gets Klaus Dorman's test to pass.
This commit is contained in:
Thomas Harte 2018-08-10 22:42:35 -04:00
parent b63e0cff72
commit 261fb3d4f8
2 changed files with 10 additions and 0 deletions

View File

@ -70,6 +70,8 @@ class KlausDormannTests: XCTestCase {
func test65C02() {
func errorForTrapAddress(_ address: UInt16) -> String? {
switch address {
case 0x24f1: return nil // success!
case 0x0423: return "PHX: value of X not on stack page"
case 0x0428: return "PHX: stack pointer not decremented"
case 0x042d: return "PLY: didn't acquire value 0xaa from stack"

View File

@ -285,6 +285,10 @@ if(number_of_cycles <= Cycles(0)) break;
carry_flag_ = (temp16 > 0xff) ? 0 : Flag::Carry;
a_ = static_cast<uint8_t>(temp16);
if(personality_ != P6502) {
negative_result_ = zero_result_ = a_;
}
continue;
} else {
operand_ = ~operand_;
@ -305,6 +309,10 @@ if(number_of_cycles <= Cycles(0)) break;
carry_flag_ = (result >> 8) ? 1 : 0;
a_ = static_cast<uint8_t>(result);
zero_result_ = static_cast<uint8_t>(decimalResult);
if(personality_ != P6502) {
negative_result_ = zero_result_ = a_;
}
} else {
const uint16_t result = static_cast<uint16_t>(a_) + static_cast<uint16_t>(operand_) + static_cast<uint16_t>(carry_flag_);
overflow_flag_ = (( (result^a_)&(result^operand_) )&0x80) >> 1;