diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj index 06da8a234..711388af2 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj +++ b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj @@ -246,6 +246,7 @@ 4B83348A1F5DB94B0097E338 /* IRQDelegatePortHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B8334891F5DB94B0097E338 /* IRQDelegatePortHandler.cpp */; }; 4B83348C1F5DB99C0097E338 /* 6522Base.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B83348B1F5DB99C0097E338 /* 6522Base.cpp */; }; 4B8334951F5E25B60097E338 /* C1540.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B8334941F5E25B60097E338 /* C1540.cpp */; }; + 4B85322D227793CB00F26553 /* etos192uk.trace.txt.gz in Resources */ = {isa = PBXBuildFile; fileRef = 4B85322C227793CA00F26553 /* etos192uk.trace.txt.gz */; }; 4B86E25B1F8C628F006FAA45 /* Keyboard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B86E2591F8C628F006FAA45 /* Keyboard.cpp */; }; 4B8805F01DCFC99C003085B1 /* Acorn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B8805EE1DCFC99C003085B1 /* Acorn.cpp */; }; 4B8805F41DCFD22A003085B1 /* Commodore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B8805F21DCFD22A003085B1 /* Commodore.cpp */; }; @@ -964,6 +965,7 @@ 4B8334911F5E24FF0097E338 /* C1540Base.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = C1540Base.hpp; path = Implementation/C1540Base.hpp; sourceTree = ""; }; 4B8334941F5E25B60097E338 /* C1540.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = C1540.cpp; path = Implementation/C1540.cpp; sourceTree = ""; }; 4B85322922778E4200F26553 /* Comparative68000.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Comparative68000.hpp; sourceTree = ""; }; + 4B85322C227793CA00F26553 /* etos192uk.trace.txt.gz */ = {isa = PBXFileReference; lastKnownFileType = archive.gzip; path = etos192uk.trace.txt.gz; sourceTree = ""; }; 4B86E2591F8C628F006FAA45 /* Keyboard.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Keyboard.cpp; sourceTree = ""; }; 4B86E25A1F8C628F006FAA45 /* Keyboard.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Keyboard.hpp; sourceTree = ""; }; 4B8805EE1DCFC99C003085B1 /* Acorn.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Acorn.cpp; path = Parsers/Acorn.cpp; sourceTree = ""; }; @@ -1567,6 +1569,7 @@ 4B1414631B588A1100E04248 /* Test Binaries */ = { isa = PBXGroup; children = ( + 4B85322B227793CA00F26553 /* TOS Startup */, 4B9252CD1E74D28200B76AF1 /* Atari ROMs */, 4B44EBF81DC9898E00A7820C /* BCDTEST_beeb */, 4B98A1CD1FFADEC400ADF63B /* MSX ROMs */, @@ -2256,6 +2259,14 @@ name = Implementation; sourceTree = ""; }; + 4B85322B227793CA00F26553 /* TOS Startup */ = { + isa = PBXGroup; + children = ( + 4B85322C227793CA00F26553 /* etos192uk.trace.txt.gz */, + ); + path = "TOS Startup"; + sourceTree = ""; + }; 4B86E2581F8C628F006FAA45 /* Inputs */ = { isa = PBXGroup; children = ( @@ -3457,6 +3468,7 @@ 4BB298FB1B587D8400A49093 /* ancb in Resources */, 4BB299431B587D8400A49093 /* dcma in Resources */, 4BB298FD1B587D8400A49093 /* andax in Resources */, + 4B85322D227793CB00F26553 /* etos192uk.trace.txt.gz in Resources */, 4BB299401B587D8400A49093 /* cpya in Resources */, 4BB299BE1B587D8400A49093 /* rraix in Resources */, 4BB299E41B587D8400A49093 /* tayn in Resources */, diff --git a/OSBindings/Mac/Clock SignalTests/Comparative68000.hpp b/OSBindings/Mac/Clock SignalTests/Comparative68000.hpp index dd8ed7e82..b64ec0965 100644 --- a/OSBindings/Mac/Clock SignalTests/Comparative68000.hpp +++ b/OSBindings/Mac/Clock SignalTests/Comparative68000.hpp @@ -32,7 +32,7 @@ class ComparativeBusHandler: public CPU::MC68000::BusHandler { // Generate state locally. const auto state = get_state(); char local_state[300]; - sprintf(local_state, "%04x: %02x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x \n", + sprintf(local_state, "%04x: %02x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x\n", address, state.status, state.data[0], state.data[1], state.data[2], state.data[3], state.data[4], state.data[5], state.data[6], state.data[7], @@ -43,8 +43,8 @@ class ComparativeBusHandler: public CPU::MC68000::BusHandler { // Check that the two coincide. if(strcmp(correct_state, local_state)) { fprintf(stderr, "Diverges at line %d\n", line_count); - fprintf(stderr, "Good: %s\n", correct_state); - fprintf(stderr, "Bad: %s\n", local_state); + fprintf(stderr, "Good: %s", correct_state); + fprintf(stderr, "Bad: %s", local_state); assert(false); } } diff --git a/OSBindings/Mac/Clock SignalTests/EmuTOSTests.mm b/OSBindings/Mac/Clock SignalTests/EmuTOSTests.mm index 87dada896..d18c43dbd 100644 --- a/OSBindings/Mac/Clock SignalTests/EmuTOSTests.mm +++ b/OSBindings/Mac/Clock SignalTests/EmuTOSTests.mm @@ -12,11 +12,12 @@ #include #include "68000.hpp" +#include "Comparative68000.hpp" #include "CSROMFetcher.hpp" -class EmuTOS: public CPU::MC68000::BusHandler { +class EmuTOS: public ComparativeBusHandler { public: - EmuTOS(const std::vector &emuTOS) : m68000_(*this) { + EmuTOS(const std::vector &emuTOS, const char *trace_name) : ComparativeBusHandler(trace_name), m68000_(*this) { assert(!(emuTOS.size() & 1)); emuTOS_.resize(emuTOS.size() / 2); @@ -29,10 +30,18 @@ class EmuTOS: public CPU::MC68000::BusHandler { m68000_.run_for(cycles); } + CPU::MC68000::ProcessorState get_state() override { + return m68000_.get_state(); + } + HalfCycles perform_bus_operation(const CPU::MC68000::Microcycle &cycle, int is_supervisor) { const uint32_t address = cycle.word_address(); uint32_t word_address = address; + if(cycle.address) { + printf("%04x\n", *cycle.address); + } + // As much about the Atari ST's memory map as is relevant here: the ROM begins // at 0xfc0000, and the first eight bytes are mirrored to the first four memory // addresses in order for /RESET to work properly. RAM otherwise fills the first @@ -42,9 +51,9 @@ class EmuTOS: public CPU::MC68000::BusHandler { const bool is_rom = word_address > (0xfc0000 >> 1) || word_address < 4; uint16_t *const base = is_rom ? emuTOS_.data() : ram_.data(); if(is_rom) { - word_address &= 0xffff; + word_address %= emuTOS_.size(); } else { - word_address &= 0x3ffff; + word_address %= ram_.size(); } using Microcycle = CPU::MC68000::Microcycle; @@ -72,20 +81,14 @@ class EmuTOS: public CPU::MC68000::BusHandler { case Microcycle::SelectWord | Microcycle::Read: cycle.value->full = is_peripheral ? peripheral_result : base[word_address]; -// if(!(cycle.operation & Microcycle::IsProgram)) printf("[word r %08x -> %04x] ", *cycle.address, cycle.value->full); break; case Microcycle::SelectByte | Microcycle::Read: cycle.value->halves.low = (is_peripheral ? peripheral_result : base[word_address]) >> cycle.byte_shift(); -// if(!(cycle.operation & Microcycle::IsProgram)) printf("[byte r %08x -> %02x] ", *cycle.address, cycle.value->halves.low); break; case Microcycle::SelectWord: - assert(!(is_rom && !is_peripheral)); -// if(!(cycle.operation & Microcycle::IsProgram)) printf("[word w %04x -> %08x] ", cycle.value->full, *cycle.address); base[word_address] = cycle.value->full; break; case Microcycle::SelectByte: - assert(!(is_rom && !is_peripheral)); -// if(!(cycle.operation & Microcycle::IsProgram)) printf("[byte w %02x -> %08x] ", cycle.value->halves.low, *cycle.address); base[word_address] = (cycle.value->halves.low << cycle.byte_shift()) | (base[word_address] & (0xffff ^ cycle.byte_mask())); break; } @@ -95,7 +98,7 @@ class EmuTOS: public CPU::MC68000::BusHandler { } private: - CPU::MC68000::Processor m68000_; + CPU::MC68000::Processor m68000_; std::vector emuTOS_; std::array ram_; @@ -108,19 +111,10 @@ class EmuTOS: public CPU::MC68000::BusHandler { std::unique_ptr _machine; } -- (void)setUp { - // Put setup code here. This method is called before the invocation of each test method in the class. - const auto roms = CSROMFetcher()("AtariST", {"tos100.img"}); - _machine.reset(new EmuTOS(*roms[0])); -} - -- (void)tearDown { - // Put teardown code here. This method is called after the invocation of each test method in the class. -} - -- (void)testStartup { - // This is an example of a functional test case. - // Use XCTAssert and related functions to verify your tests produce the correct results. +- (void)testEmuTOSStartup { + const auto roms = CSROMFetcher()("AtariST", {"etos192uk.img"}); + NSString *const traceLocation = [[NSBundle bundleForClass:[self class]] pathForResource:@"etos192uk" ofType:@"trace.txt.gz"]; + _machine.reset(new EmuTOS(*roms[0], traceLocation.UTF8String)); _machine->run_for(HalfCycles(8000000)); } diff --git a/OSBindings/Mac/Clock SignalTests/QL Startup/qltrace.txt.gz b/OSBindings/Mac/Clock SignalTests/QL Startup/qltrace.txt.gz index fa886ae8d..6f06c2b0a 100644 Binary files a/OSBindings/Mac/Clock SignalTests/QL Startup/qltrace.txt.gz and b/OSBindings/Mac/Clock SignalTests/QL Startup/qltrace.txt.gz differ diff --git a/OSBindings/Mac/Clock SignalTests/QLTests.mm b/OSBindings/Mac/Clock SignalTests/QLTests.mm index 08b208311..ad6f0c389 100644 --- a/OSBindings/Mac/Clock SignalTests/QLTests.mm +++ b/OSBindings/Mac/Clock SignalTests/QLTests.mm @@ -107,8 +107,6 @@ class QL: public ComparativeBusHandler { // This is how many cycles it takes to exhaust the supplied trace file. _machine->run_for(HalfCycles(23923180)); - - _machine.reset(); } @end