1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-04 18:29:40 +00:00

Sets sensible 'reset' values.

This commit is contained in:
Thomas Harte 2021-02-07 21:53:57 -05:00
parent acfab1dfb3
commit 77b1efd176
3 changed files with 11 additions and 9 deletions

View File

@ -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;
}

View File

@ -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];

View File

@ -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) {