From 9309be229ca9b923f49eb29a720dab0bc1e4a465 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 30 Oct 2016 20:13:44 -0400 Subject: [PATCH 1/5] Moved cycle count test down to the only places where it may actually yield a different result. --- Processors/6502/CPU6502.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Processors/6502/CPU6502.hpp b/Processors/6502/CPU6502.hpp index 20f2888ea..4a169d344 100644 --- a/Processors/6502/CPU6502.hpp +++ b/Processors/6502/CPU6502.hpp @@ -620,7 +620,8 @@ template class Processor { _interrupt_requests = (_interrupt_requests & ~InterruptRequestFlags::IRQ) | _irq_request_history; \ _irq_request_history = _irq_line & _inverseInterruptFlag; \ number_of_cycles -= static_cast(this)->perform_bus_operation(nextBusOperation, busAddress, busValue); \ - nextBusOperation = BusOperation::None; + nextBusOperation = BusOperation::None; \ + if(number_of_cycles < 0) break; checkSchedule(); number_of_cycles += _cycles_left_to_run; @@ -639,7 +640,7 @@ template class Processor { bus_access(); } - while(number_of_cycles > 0) { + while(1) { const MicroOp cycle = program[scheduleProgramProgramCounter]; scheduleProgramProgramCounter++; From 95f54cb4b5f8689afdf4a9949f9a1447b1d3c76d Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 30 Oct 2016 20:15:47 -0400 Subject: [PATCH 2/5] Cut some dead state. --- Machines/Oric/Video.cpp | 1 - Machines/Oric/Video.hpp | 6 +----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/Machines/Oric/Video.cpp b/Machines/Oric/Video.cpp index ff7c22798..ea14c006d 100644 --- a/Machines/Oric/Video.cpp +++ b/Machines/Oric/Video.cpp @@ -22,7 +22,6 @@ namespace { VideoOutput::VideoOutput(uint8_t *memory) : _ram(memory), _frame_counter(0), _counter(0), - _state(Sync), _cycles_in_state(0), _is_graphics_mode(false), _character_set_base_address(0xb400), _phase(0), diff --git a/Machines/Oric/Video.hpp b/Machines/Oric/Video.hpp index 1a562347b..ec41a919a 100644 --- a/Machines/Oric/Video.hpp +++ b/Machines/Oric/Video.hpp @@ -27,11 +27,7 @@ class VideoOutput { int _counter, _frame_counter; int _v_sync_start_position, _v_sync_end_position, _counter_period; - // Output state - enum State { - Blank, Sync, Pixels, ColourBurst - } _state; - unsigned int _cycles_in_state; + // Output target uint8_t *_pixel_target; // Registers From 42fe9f29acce1ce23152ca7877270e379c02ad6b Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 30 Oct 2016 20:16:22 -0400 Subject: [PATCH 3/5] Moved code out of header. --- Machines/Oric/Video.cpp | 6 ++++++ Machines/Oric/Video.hpp | 6 +----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Machines/Oric/Video.cpp b/Machines/Oric/Video.cpp index ea14c006d..5176aeee0 100644 --- a/Machines/Oric/Video.cpp +++ b/Machines/Oric/Video.cpp @@ -210,3 +210,9 @@ void VideoOutput::run_for_cycles(int number_of_cycles) number_of_cycles -= cycles_run_for; } } + +void VideoOutput::set_character_set_base_address() +{ + if(_is_graphics_mode) _character_set_base_address = _use_alternative_character_set ? 0x9c00 : 0x9800; + else _character_set_base_address = _use_alternative_character_set ? 0xb800 : 0xb400; +} diff --git a/Machines/Oric/Video.hpp b/Machines/Oric/Video.hpp index ec41a919a..28d8661ec 100644 --- a/Machines/Oric/Video.hpp +++ b/Machines/Oric/Video.hpp @@ -34,11 +34,7 @@ class VideoOutput { uint8_t _ink, _paper; int _character_set_base_address; - inline void set_character_set_base_address() - { - if(_is_graphics_mode) _character_set_base_address = _use_alternative_character_set ? 0x9c00 : 0x9800; - else _character_set_base_address = _use_alternative_character_set ? 0xb800 : 0xb400; - } + inline void set_character_set_base_address(); bool _is_graphics_mode; bool _next_frame_is_sixty_hertz; From 2452a3104f3e70cb338a15c9a5d80b711087f126 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 30 Oct 2016 20:24:30 -0400 Subject: [PATCH 4/5] Corrected test: hitting zero is sufficient. No need to cross it. --- Processors/6502/CPU6502.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Processors/6502/CPU6502.hpp b/Processors/6502/CPU6502.hpp index 4a169d344..960921064 100644 --- a/Processors/6502/CPU6502.hpp +++ b/Processors/6502/CPU6502.hpp @@ -621,7 +621,7 @@ template class Processor { _irq_request_history = _irq_line & _inverseInterruptFlag; \ number_of_cycles -= static_cast(this)->perform_bus_operation(nextBusOperation, busAddress, busValue); \ nextBusOperation = BusOperation::None; \ - if(number_of_cycles < 0) break; + if(number_of_cycles <= 0) break; checkSchedule(); number_of_cycles += _cycles_left_to_run; From 4b347b9993c0516c657ce4b530ae3d8db593cb7d Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 30 Oct 2016 20:30:32 -0400 Subject: [PATCH 5/5] Made a trivial `XCTAssert` unit test substitution. --- OSBindings/Mac/Clock SignalTests/AllSuiteATests.swift | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/OSBindings/Mac/Clock SignalTests/AllSuiteATests.swift b/OSBindings/Mac/Clock SignalTests/AllSuiteATests.swift index 46e56546a..684641121 100644 --- a/OSBindings/Mac/Clock SignalTests/AllSuiteATests.swift +++ b/OSBindings/Mac/Clock SignalTests/AllSuiteATests.swift @@ -24,9 +24,7 @@ class AllSuiteATests: XCTestCase { machine.runForNumber(ofCycles: 1000) } - if machine.value(forAddress: 0x0210) != 0xff { - NSException(name: NSExceptionName(rawValue: "Failed AllSuiteA"), reason: "Failed test \(machine.value(forAddress: 0x0210))", userInfo: nil).raise() - } + XCTAssert(machine.value(forAddress: 0x0210) == 0xff, "Failed test \(machine.value(forAddress: 0x0210))") } } }