1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-04-08 08:43:42 +00:00

Reduced back-and-forth between Cycles and ints within the Oric.

This commit is contained in:
Thomas Harte 2017-07-24 22:46:31 -04:00
parent a1a3aab115
commit c1527cc9e2
3 changed files with 26 additions and 8 deletions

View File

@ -29,6 +29,26 @@ template <class T> class WrappedInt {
return *static_cast<T *>(this);
}
inline T &operator ++() {
++ length_;
return *static_cast<T *>(this);
}
inline T &operator ++(int) {
length_ ++;
return *static_cast<T *>(this);
}
inline T &operator --() {
-- length_;
return *static_cast<T *>(this);
}
inline T &operator --(int) {
length_ --;
return *static_cast<T *>(this);
}
inline T &operator %=(const T &rhs) {
length_ %= rhs.length_;
return *static_cast<T *>(this);

View File

@ -12,7 +12,6 @@
using namespace Oric;
Machine::Machine() :
cycles_since_video_update_(0),
use_fast_tape_hack_(false),
typer_delay_(2500000),
keyboard_read_count_(0),
@ -142,7 +141,7 @@ void Machine::flush() {
}
void Machine::update_video() {
video_output_->run_for(Cycles(cycles_since_video_update_));
video_output_->run_for(cycles_since_video_update_);
cycles_since_video_update_ = 0;
}
@ -206,7 +205,6 @@ void Machine::run_for(const Cycles &cycles) {
Machine::VIA::VIA() :
MOS::MOS6522<Machine::VIA>(),
cycles_since_ay_update_(0),
tape(new TapePlayer) {}
void Machine::VIA::set_control_line_output(Port port, Line line, bool value) {
@ -235,19 +233,19 @@ uint8_t Machine::VIA::get_port_input(Port port) {
}
void Machine::VIA::flush() {
ay8910->run_for(Cycles(cycles_since_ay_update_));
ay8910->run_for(cycles_since_ay_update_);
ay8910->flush();
cycles_since_ay_update_ = 0;
}
void Machine::VIA::run_for(const Cycles &cycles) {
cycles_since_ay_update_ += cycles.as_int();
cycles_since_ay_update_ += cycles;
MOS::MOS6522<VIA>::run_for(cycles);
tape->run_for(cycles);
}
void Machine::VIA::update_ay() {
ay8910->run_for(Cycles((int)cycles_since_ay_update_));
ay8910->run_for(cycles_since_ay_update_);
cycles_since_ay_update_ = 0;
ay8910->set_control_lines( (GI::AY38910::ControlLines)((ay_bdir_ ? GI::AY38910::BCDIR : 0) | (ay_bc1_ ? GI::AY38910::BC1 : 0) | GI::AY38910::BC2));
}

View File

@ -104,7 +104,7 @@ class Machine:
// RAM and ROM
std::vector<uint8_t> basic11_rom_, basic10_rom_, microdisc_rom_, colour_rom_;
uint8_t ram_[65536], rom_[16384];
int cycles_since_video_update_;
Cycles cycles_since_video_update_;
inline void update_video();
// ROM bookkeeping
@ -154,7 +154,7 @@ class Machine:
private:
void update_ay();
bool ay_bdir_, ay_bc1_;
int cycles_since_ay_update_;
Cycles cycles_since_ay_update_;
};
VIA via_;
std::shared_ptr<Keyboard> keyboard_;