From 77b1efd1763373c2095e44b581751fa30d0eea29 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 7 Feb 2021 21:53:57 -0500 Subject: [PATCH] Sets sensible 'reset' values. --- InstructionSets/M50740/Executor.cpp | 12 +++++++----- InstructionSets/M50740/Executor.hpp | 6 +++--- Machines/Apple/AppleIIgs/ADB.cpp | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/InstructionSets/M50740/Executor.cpp b/InstructionSets/M50740/Executor.cpp index caaa79cc2..5a330cf89 100644 --- a/InstructionSets/M50740/Executor.cpp +++ b/InstructionSets/M50740/Executor.cpp @@ -760,9 +760,11 @@ inline void Executor::subtract_duration(int duration) { // Update count for potential port accesses. cycles_since_port_handler_ += Cycles(duration); - // Update timer 1/2 prescaler. - constexpr int t12_divider = 1; // TODO: should be 4, I think. - timer_divider_ += duration; + // Update timer 1 and 2 prescaler. + constexpr int t12_divider = 4; // TODO: should be 4, I think. + constexpr int t12_multiplier = 16; + + timer_divider_ += duration * t12_multiplier; const int t12_ticks = update_timer(prescalers_[0], timer_divider_ / t12_divider); timer_divider_ &= (t12_divider-1); @@ -778,11 +780,11 @@ inline void Executor::subtract_duration(int duration) { } inline int Executor::update_timer(Timer &timer, int count) { - int next_value = timer.value - count; + const int next_value = timer.value - count; if(next_value < 0) { // Determine how many reloads were required to get above zero. const int reload_value = timer.reload_value ? timer.reload_value : 256; - const int underflow_count = 1 + (-next_value) / reload_value; + const int underflow_count = 1 - next_value / reload_value; timer.value = uint8_t((next_value % reload_value) + timer.reload_value); return underflow_count; } diff --git a/InstructionSets/M50740/Executor.hpp b/InstructionSets/M50740/Executor.hpp index 729be67c2..e34b94885 100644 --- a/InstructionSets/M50740/Executor.hpp +++ b/InstructionSets/M50740/Executor.hpp @@ -130,19 +130,19 @@ class Executor: public CachingExecutor { uint8_t negative_result_ = 0; uint8_t zero_result_ = 0; - uint8_t interrupt_disable_ = 0; + uint8_t interrupt_disable_ = 0x04; uint8_t carry_flag_ = 0; uint8_t overflow_result_; bool index_mode_ = false; bool decimal_mode_ = false; // IO ports. - uint8_t port_directions_[4] = {0xff, 0xff, 0xff, 0xff}; + uint8_t port_directions_[4] = {0x00, 0x00, 0x00, 0x00}; uint8_t port_outputs_[4] = {0xff, 0xff, 0xff, 0xff}; // Timers. struct Timer { - uint8_t value = 0, reload_value = 0; + uint8_t value = 0xff, reload_value = 0xff; }; int timer_divider_ = 0; Timer timers_[3], prescalers_[2]; diff --git a/Machines/Apple/AppleIIgs/ADB.cpp b/Machines/Apple/AppleIIgs/ADB.cpp index 5db8d4441..6f69bd60f 100644 --- a/Machines/Apple/AppleIIgs/ADB.cpp +++ b/Machines/Apple/AppleIIgs/ADB.cpp @@ -173,7 +173,7 @@ void GLU::set_port_output(int port, uint8_t value) { // printf("IIe KWS: %d\n", (value >> 6)&3); // printf("ADB data line output: %d\n", (value >> 3)&1); - const bool new_adb_level = !(value & 0x08); + const bool new_adb_level = value & 0x08; if(new_adb_level != adb_level_) { printf("."); if(!new_adb_level) {