mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-23 20:29:42 +00:00
Reduced int/Cycle conversions in the Electron and on the Atari 2600, where the current framework makes it possible to do so.
This commit is contained in:
parent
9be9bd9106
commit
90bf6565d0
@ -21,9 +21,7 @@ class Bus {
|
||||
public:
|
||||
Bus() :
|
||||
tia_input_value_{0xff, 0xff},
|
||||
cycles_since_speaker_update_(0),
|
||||
cycles_since_video_update_(0),
|
||||
cycles_since_6532_update_(0) {}
|
||||
cycles_since_speaker_update_(0) {}
|
||||
|
||||
virtual void run_for(const Cycles &cycles) = 0;
|
||||
virtual void set_reset_line(bool state) = 0;
|
||||
@ -46,16 +44,16 @@ class Bus {
|
||||
}
|
||||
|
||||
// video backlog accumulation counter
|
||||
unsigned int cycles_since_video_update_;
|
||||
Cycles cycles_since_video_update_;
|
||||
inline void update_video() {
|
||||
tia_->run_for(Cycles((int)cycles_since_video_update_));
|
||||
tia_->run_for(cycles_since_video_update_);
|
||||
cycles_since_video_update_ = 0;
|
||||
}
|
||||
|
||||
// RIOT backlog accumulation counter
|
||||
unsigned int cycles_since_6532_update_;
|
||||
Cycles cycles_since_6532_update_;
|
||||
inline void update_6532() {
|
||||
mos6532_.run_for(Cycles((int)cycles_since_6532_update_));
|
||||
mos6532_.run_for(cycles_since_6532_update_);
|
||||
cycles_since_6532_update_ = 0;
|
||||
}
|
||||
};
|
||||
|
@ -39,8 +39,8 @@ template<class T> class Cartridge:
|
||||
cycles_run_for = (unsigned int)tia_->get_cycles_until_horizontal_blank(cycles_since_video_update_);
|
||||
|
||||
cycles_since_speaker_update_ += cycles_run_for;
|
||||
cycles_since_video_update_ += cycles_run_for;
|
||||
cycles_since_6532_update_ += (cycles_run_for / 3);
|
||||
cycles_since_video_update_ += (int)cycles_run_for;
|
||||
cycles_since_6532_update_ += (int)(cycles_run_for / 3);
|
||||
static_cast<T *>(this)->advance_cycles(cycles_run_for / 3);
|
||||
|
||||
if(operation != CPU::MOS6502::BusOperation::Ready) {
|
||||
|
@ -15,7 +15,6 @@ using namespace Electron;
|
||||
Machine::Machine() :
|
||||
interrupt_control_(0),
|
||||
interrupt_status_(Interrupt::PowerOnReset | Interrupt::TransmitDataEmpty | 0x80),
|
||||
cycles_since_display_update_(0),
|
||||
cycles_since_audio_update_(0),
|
||||
use_fast_tape_hack_(false),
|
||||
cycles_until_display_interrupt_(0) {
|
||||
@ -136,7 +135,7 @@ unsigned int Machine::perform_bus_operation(CPU::MOS6502::BusOperation operation
|
||||
|
||||
// for the entire frame, RAM is accessible only on odd cycles; in modes below 4
|
||||
// it's also accessible only outside of the pixel regions
|
||||
cycles += video_output_->get_cycles_until_next_ram_availability((int)(cycles_since_display_update_ + 1));
|
||||
cycles += video_output_->get_cycles_until_next_ram_availability(cycles_since_display_update_.as_int() + 1);
|
||||
} else {
|
||||
switch(address & 0xff0f) {
|
||||
case 0xfe00:
|
||||
@ -316,7 +315,7 @@ unsigned int Machine::perform_bus_operation(CPU::MOS6502::BusOperation operation
|
||||
}
|
||||
}
|
||||
|
||||
cycles_since_display_update_ += cycles;
|
||||
cycles_since_display_update_ += Cycles((int)cycles);
|
||||
cycles_since_audio_update_ += cycles;
|
||||
if(cycles_since_audio_update_ > 16384) update_audio();
|
||||
tape_.run_for(Cycles((int)cycles));
|
||||
@ -353,7 +352,7 @@ void Machine::flush() {
|
||||
|
||||
inline void Machine::update_display() {
|
||||
if(cycles_since_display_update_) {
|
||||
video_output_->run_for(Cycles((int)cycles_since_display_update_));
|
||||
video_output_->run_for(cycles_since_display_update_);
|
||||
cycles_since_display_update_ = 0;
|
||||
}
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ class Machine:
|
||||
uint8_t key_states_[14];
|
||||
|
||||
// Counters related to simultaneous subsystems
|
||||
unsigned int cycles_since_display_update_;
|
||||
Cycles cycles_since_display_update_;
|
||||
unsigned int cycles_since_audio_update_;
|
||||
int cycles_until_display_interrupt_;
|
||||
Interrupt next_display_interrupt_;
|
||||
|
Loading…
Reference in New Issue
Block a user