mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-20 14:29:11 +00:00
Edges towards offering the 65816 as another type of 6502 for testing.
This commit is contained in:
parent
1cd664ad85
commit
5449e90b34
@ -15,7 +15,7 @@ class MOS6502InterruptTests: XCTestCase {
|
|||||||
super.setUp()
|
super.setUp()
|
||||||
|
|
||||||
// create a machine full of NOPs
|
// create a machine full of NOPs
|
||||||
machine = CSTestMachine6502(is65C02: false)
|
machine = CSTestMachine6502(processor: .processor6502)
|
||||||
for c in 0...65535 {
|
for c in 0...65535 {
|
||||||
machine.setValue(0xea, forAddress: UInt16(c))
|
machine.setValue(0xea, forAddress: UInt16(c))
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ import XCTest
|
|||||||
class MOS6502TimingTests: XCTestCase, CSTestMachineTrapHandler {
|
class MOS6502TimingTests: XCTestCase, CSTestMachineTrapHandler {
|
||||||
|
|
||||||
private var endTime: UInt32 = 0
|
private var endTime: UInt32 = 0
|
||||||
private let machine = CSTestMachine6502(is65C02: false)
|
private let machine = CSTestMachine6502(processor: .processor6502)
|
||||||
|
|
||||||
func testImplied() {
|
func testImplied() {
|
||||||
let code: [UInt8] = [
|
let code: [UInt8] = [
|
||||||
|
@ -13,7 +13,7 @@ class AllSuiteATests: XCTestCase {
|
|||||||
func testAllSuiteA() {
|
func testAllSuiteA() {
|
||||||
if let filename = Bundle(for: type(of: self)).path(forResource: "AllSuiteA", ofType: "bin") {
|
if let filename = Bundle(for: type(of: self)).path(forResource: "AllSuiteA", ofType: "bin") {
|
||||||
if let allSuiteA = try? Data(contentsOf: URL(fileURLWithPath: filename)) {
|
if let allSuiteA = try? Data(contentsOf: URL(fileURLWithPath: filename)) {
|
||||||
let machine = CSTestMachine6502(is65C02: false)
|
let machine = CSTestMachine6502(processor: .processor6502)
|
||||||
|
|
||||||
machine.setData(allSuiteA, atAddress: 0x4000)
|
machine.setData(allSuiteA, atAddress: 0x4000)
|
||||||
machine.setValue(CSTestMachine6502JamOpcode, forAddress:0x45c0); // end
|
machine.setValue(CSTestMachine6502JamOpcode, forAddress:0x45c0); // end
|
||||||
|
@ -14,7 +14,7 @@ class BCDTest: XCTestCase, CSTestMachineTrapHandler {
|
|||||||
func testBCD() {
|
func testBCD() {
|
||||||
if let filename = Bundle(for: type(of: self)).path(forResource: "BCDTEST_beeb", ofType: nil) {
|
if let filename = Bundle(for: type(of: self)).path(forResource: "BCDTEST_beeb", ofType: nil) {
|
||||||
if let bcdTest = try? Data(contentsOf: URL(fileURLWithPath: filename)) {
|
if let bcdTest = try? Data(contentsOf: URL(fileURLWithPath: filename)) {
|
||||||
let machine = CSTestMachine6502(is65C02: false)
|
let machine = CSTestMachine6502(processor: .processor6502)
|
||||||
machine.trapHandler = self
|
machine.trapHandler = self
|
||||||
|
|
||||||
machine.setData(bcdTest, atAddress: 0x2900)
|
machine.setData(bcdTest, atAddress: 0x2900)
|
||||||
|
@ -19,13 +19,19 @@ typedef NS_ENUM(NSInteger, CSTestMachine6502Register) {
|
|||||||
CSTestMachine6502RegisterY,
|
CSTestMachine6502RegisterY,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef NS_ENUM(NSInteger, CSTestMachine6502Processor) {
|
||||||
|
CSTestMachine6502Processor6502,
|
||||||
|
CSTestMachine6502Processor65C02,
|
||||||
|
CSTestMachine6502Processor65816
|
||||||
|
};
|
||||||
|
|
||||||
extern const uint8_t CSTestMachine6502JamOpcode;
|
extern const uint8_t CSTestMachine6502JamOpcode;
|
||||||
|
|
||||||
@interface CSTestMachine6502 : CSTestMachine
|
@interface CSTestMachine6502 : CSTestMachine
|
||||||
|
|
||||||
- (nonnull instancetype)init NS_UNAVAILABLE;
|
- (nonnull instancetype)init NS_UNAVAILABLE;
|
||||||
|
|
||||||
- (nonnull instancetype)initIs65C02:(BOOL)is65C02;
|
- (nonnull instancetype)initWithProcessor:(CSTestMachine6502Processor)processor;
|
||||||
|
|
||||||
- (void)setData:(nonnull NSData *)data atAddress:(uint16_t)startAddress;
|
- (void)setData:(nonnull NSData *)data atAddress:(uint16_t)startAddress;
|
||||||
- (void)runForNumberOfCycles:(int)cycles;
|
- (void)runForNumberOfCycles:(int)cycles;
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#import "TestMachine6502.h"
|
#import "TestMachine6502.h"
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "../../../../Processors/6502/AllRAM/6502AllRAM.hpp"
|
#include "../../../../Processors/6502/AllRAM/6502AllRAM.hpp"
|
||||||
|
//#include "../../../../Processors/65816/AllRAM/65816AllRAM.hpp"
|
||||||
#import "TestMachine+ForSubclassEyesOnly.h"
|
#import "TestMachine+ForSubclassEyesOnly.h"
|
||||||
|
|
||||||
const uint8_t CSTestMachine6502JamOpcode = CPU::MOS6502::JamOpcode;
|
const uint8_t CSTestMachine6502JamOpcode = CPU::MOS6502::JamOpcode;
|
||||||
@ -35,12 +36,21 @@ static CPU::MOS6502::Register registerForRegister(CSTestMachine6502Register reg)
|
|||||||
|
|
||||||
#pragma mark - Lifecycle
|
#pragma mark - Lifecycle
|
||||||
|
|
||||||
- (instancetype)initIs65C02:(BOOL)is65C02 {
|
- (instancetype)initWithProcessor:(CSTestMachine6502Processor)processor {
|
||||||
self = [super init];
|
self = [super init];
|
||||||
|
|
||||||
if(self) {
|
if(self) {
|
||||||
_processor = CPU::MOS6502::AllRAMProcessor::Processor(
|
switch(processor) {
|
||||||
is65C02 ? CPU::MOS6502::Personality::PWDC65C02 : CPU::MOS6502::Personality::P6502);
|
case CSTestMachine6502Processor6502:
|
||||||
|
_processor = CPU::MOS6502::AllRAMProcessor::Processor(CPU::MOS6502::Personality::P6502);
|
||||||
|
break;
|
||||||
|
case CSTestMachine6502Processor65C02:
|
||||||
|
_processor = CPU::MOS6502::AllRAMProcessor::Processor(CPU::MOS6502::Personality::PWDC65C02);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert(false); // TODO
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
@ -23,7 +23,7 @@ class BusOperationHandler: public CPU::Z80::AllRAMProcessor::MemoryAccessDelegat
|
|||||||
public:
|
public:
|
||||||
BusOperationHandler(CSTestMachineZ80 *targetMachine) : target_(targetMachine) {}
|
BusOperationHandler(CSTestMachineZ80 *targetMachine) : target_(targetMachine) {}
|
||||||
|
|
||||||
void z80_all_ram_processor_did_perform_bus_operation(CPU::Z80::AllRAMProcessor &processor, CPU::Z80::PartialMachineCycle::Operation operation, uint16_t address, uint8_t value, HalfCycles time_stamp) {
|
void z80_all_ram_processor_did_perform_bus_operation(CPU::Z80::AllRAMProcessor &, CPU::Z80::PartialMachineCycle::Operation operation, uint16_t address, uint8_t value, HalfCycles time_stamp) {
|
||||||
[target_ testMachineDidPerformBusOperation:operation address:address value:value timeStamp:time_stamp];
|
[target_ testMachineDidPerformBusOperation:operation address:address value:value timeStamp:time_stamp];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ struct PortAccessDelegateTopByte: public CPU::Z80::AllRAMProcessor::PortAccessDe
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct PortAccessDelegate191: public CPU::Z80::AllRAMProcessor::PortAccessDelegate {
|
struct PortAccessDelegate191: public CPU::Z80::AllRAMProcessor::PortAccessDelegate {
|
||||||
uint8_t z80_all_ram_processor_input(uint16_t port) final { return 191; }
|
uint8_t z80_all_ram_processor_input(uint16_t) final { return 191; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#pragma mark - Capture class
|
#pragma mark - Capture class
|
||||||
|
@ -23,7 +23,7 @@ class ComparativeBusHandler: public CPU::MC68000::BusHandler {
|
|||||||
gzclose(trace);
|
gzclose(trace);
|
||||||
}
|
}
|
||||||
|
|
||||||
void will_perform(uint32_t address, uint16_t opcode) {
|
void will_perform(uint32_t address, uint16_t) {
|
||||||
// Obtain the next line from the trace file.
|
// Obtain the next line from the trace file.
|
||||||
char correct_state[300] = "\n";
|
char correct_state[300] = "\n";
|
||||||
gzgets(trace, correct_state, sizeof(correct_state));
|
gzgets(trace, correct_state, sizeof(correct_state));
|
||||||
@ -45,7 +45,7 @@ class ComparativeBusHandler: public CPU::MC68000::BusHandler {
|
|||||||
fprintf(stderr, "Diverges at line %d\n", line_count);
|
fprintf(stderr, "Diverges at line %d\n", line_count);
|
||||||
fprintf(stderr, "Good: %s", correct_state);
|
fprintf(stderr, "Good: %s", correct_state);
|
||||||
fprintf(stderr, "Bad: %s", local_state);
|
fprintf(stderr, "Bad: %s", local_state);
|
||||||
assert(false);
|
throw std::exception();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ class KlausDormannTests: XCTestCase {
|
|||||||
fileprivate func runTest(resource: String, is65C02: Bool) -> UInt16 {
|
fileprivate func runTest(resource: String, is65C02: Bool) -> UInt16 {
|
||||||
if let filename = Bundle(for: type(of: self)).path(forResource: resource, ofType: "bin") {
|
if let filename = Bundle(for: type(of: self)).path(forResource: resource, ofType: "bin") {
|
||||||
if let functionalTest = try? Data(contentsOf: URL(fileURLWithPath: filename)) {
|
if let functionalTest = try? Data(contentsOf: URL(fileURLWithPath: filename)) {
|
||||||
let machine = CSTestMachine6502(is65C02: is65C02)
|
let machine = CSTestMachine6502(processor: is65C02 ? .processor65C02 : .processor6502)
|
||||||
|
|
||||||
machine.setData(functionalTest, atAddress: 0)
|
machine.setData(functionalTest, atAddress: 0)
|
||||||
machine.setValue(0x400, for: .programCounter)
|
machine.setValue(0x400, for: .programCounter)
|
||||||
|
@ -200,7 +200,7 @@ class WolfgangLorenzTests: XCTestCase, CSTestMachineTrapHandler {
|
|||||||
if let filename = Bundle(for: type(of: self)).path(forResource: name, ofType: nil) {
|
if let filename = Bundle(for: type(of: self)).path(forResource: name, ofType: nil) {
|
||||||
if let testData = try? Data(contentsOf: URL(fileURLWithPath: filename)) {
|
if let testData = try? Data(contentsOf: URL(fileURLWithPath: filename)) {
|
||||||
|
|
||||||
machine = CSTestMachine6502(is65C02: false)
|
machine = CSTestMachine6502(processor: .processor6502)
|
||||||
machine.trapHandler = self
|
machine.trapHandler = self
|
||||||
// machine.logActivity = true
|
// machine.logActivity = true
|
||||||
output = ""
|
output = ""
|
||||||
|
@ -699,9 +699,6 @@ struct CPU::WDC65816::ProcessorStorageConstructor {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// TEMPORARY. Kneejerk way to get a step debug of 65816 storage construction.
|
|
||||||
ProcessorStorage TEMPORARY_test_instance;
|
|
||||||
|
|
||||||
ProcessorStorage::ProcessorStorage() {
|
ProcessorStorage::ProcessorStorage() {
|
||||||
ProcessorStorageConstructor constructor(*this);
|
ProcessorStorageConstructor constructor(*this);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user