mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-26 23:52:26 +00:00
Corrected TIA's WSYNC lookahead to accept Cycles
.
This commit is contained in:
parent
1c2f68f129
commit
d9c6b3bcf7
@ -24,7 +24,7 @@ template<class T> class Cartridge:
|
|||||||
|
|
||||||
void run_for(const Cycles &cycles) { CPU::MOS6502::Processor<Cartridge<T>>::run_for(cycles); }
|
void run_for(const Cycles &cycles) { CPU::MOS6502::Processor<Cartridge<T>>::run_for(cycles); }
|
||||||
void set_reset_line(bool state) { CPU::MOS6502::Processor<Cartridge<T>>::set_reset_line(state); }
|
void set_reset_line(bool state) { CPU::MOS6502::Processor<Cartridge<T>>::set_reset_line(state); }
|
||||||
void advance_cycles(unsigned int cycles) {}
|
void advance_cycles(int cycles) {}
|
||||||
|
|
||||||
// to satisfy CPU::MOS6502::Processor
|
// to satisfy CPU::MOS6502::Processor
|
||||||
unsigned int perform_bus_operation(CPU::MOS6502::BusOperation operation, uint16_t address, uint8_t *value) {
|
unsigned int perform_bus_operation(CPU::MOS6502::BusOperation operation, uint16_t address, uint8_t *value) {
|
||||||
@ -41,7 +41,7 @@ template<class T> class Cartridge:
|
|||||||
cycles_since_speaker_update_ += Cycles(cycles_run_for);
|
cycles_since_speaker_update_ += Cycles(cycles_run_for);
|
||||||
cycles_since_video_update_ += Cycles(cycles_run_for);
|
cycles_since_video_update_ += Cycles(cycles_run_for);
|
||||||
cycles_since_6532_update_ += Cycles(cycles_run_for / 3);
|
cycles_since_6532_update_ += Cycles(cycles_run_for / 3);
|
||||||
static_cast<T *>(this)->advance_cycles((unsigned int)cycles_run_for / 3);
|
static_cast<T *>(this)->advance_cycles(cycles_run_for / 3);
|
||||||
|
|
||||||
if(operation != CPU::MOS6502::BusOperation::Ready) {
|
if(operation != CPU::MOS6502::BusOperation::Ready) {
|
||||||
// give the cartridge a chance to respond to the bus access
|
// give the cartridge a chance to respond to the bus access
|
||||||
|
@ -22,7 +22,7 @@ class CartridgePitfall2: public Cartridge<CartridgePitfall2> {
|
|||||||
rom_ptr_ = rom_.data();
|
rom_ptr_ = rom_.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
void advance_cycles(unsigned int cycles) {
|
void advance_cycles(int cycles) {
|
||||||
cycles_since_audio_update_ += cycles;
|
cycles_since_audio_update_ += cycles;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,8 +105,7 @@ class CartridgePitfall2: public Cartridge<CartridgePitfall2> {
|
|||||||
|
|
||||||
inline uint8_t update_audio() {
|
inline uint8_t update_audio() {
|
||||||
const unsigned int clock_divisor = 57;
|
const unsigned int clock_divisor = 57;
|
||||||
unsigned int cycles_to_run_for = cycles_since_audio_update_ / clock_divisor;
|
int cycles_to_run_for = cycles_since_audio_update_.divide(clock_divisor).as_int();
|
||||||
cycles_since_audio_update_ %= clock_divisor;
|
|
||||||
|
|
||||||
int table_position = 0;
|
int table_position = 0;
|
||||||
for(int c = 0; c < 3; c++) {
|
for(int c = 0; c < 3; c++) {
|
||||||
@ -126,7 +125,7 @@ class CartridgePitfall2: public Cartridge<CartridgePitfall2> {
|
|||||||
uint8_t random_number_generator_;
|
uint8_t random_number_generator_;
|
||||||
uint8_t *rom_ptr_;
|
uint8_t *rom_ptr_;
|
||||||
uint8_t audio_channel_[3];
|
uint8_t audio_channel_[3];
|
||||||
unsigned int cycles_since_audio_update_;
|
Cycles cycles_since_audio_update_;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -198,8 +198,8 @@ void TIA::set_blank(bool blank) {
|
|||||||
void TIA::reset_horizontal_counter() {
|
void TIA::reset_horizontal_counter() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int TIA::get_cycles_until_horizontal_blank(unsigned int from_offset) {
|
int TIA::get_cycles_until_horizontal_blank(const Cycles &from_offset) {
|
||||||
return (cycles_per_line - (horizontal_counter_ + (int)from_offset) % cycles_per_line) % cycles_per_line;
|
return (cycles_per_line - (horizontal_counter_ + from_offset.as_int()) % cycles_per_line) % cycles_per_line;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TIA::set_background_colour(uint8_t colour) {
|
void TIA::set_background_colour(uint8_t colour) {
|
||||||
|
@ -43,7 +43,7 @@ class TIA: public ClockReceiver<TIA> {
|
|||||||
@returns the number of cycles between (current TIA time) + from_offset to the current or
|
@returns the number of cycles between (current TIA time) + from_offset to the current or
|
||||||
next horizontal blanking period. Returns numbers in the range [0, 227].
|
next horizontal blanking period. Returns numbers in the range [0, 227].
|
||||||
*/
|
*/
|
||||||
int get_cycles_until_horizontal_blank(unsigned int from_offset);
|
int get_cycles_until_horizontal_blank(const Cycles &from_offset);
|
||||||
|
|
||||||
void set_background_colour(uint8_t colour);
|
void set_background_colour(uint8_t colour);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user