1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-06 01:28:57 +00:00

Prevented unbounded CPU usage, albeit without yet deciding who has authority for the clock rate.

This commit is contained in:
Thomas Harte 2017-01-29 14:19:26 -05:00
parent 2432a3b4d7
commit 2390358c24
3 changed files with 13 additions and 4 deletions

View File

@ -12,7 +12,6 @@
using namespace Atari2600;
namespace {
static const unsigned int horizontalTimerPeriod = 228;
static const double NTSC_clock_rate = 1194720;
static const double PAL_clock_rate = 1182298;
}
@ -31,6 +30,7 @@ void Machine::setup_output(float aspect_ratio)
{
tia_.reset(new TIA);
speaker_.reset(new Speaker);
speaker_->set_input_rate((float)(get_clock_rate() / 38.0));
}
void Machine::close_output()
@ -56,6 +56,7 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin
// skips to the end of the line.
if(operation == CPU6502::BusOperation::Ready) {
cycles_run_for = (unsigned int)tia_->get_cycles_until_horizontal_blank(cycles_since_video_update_);
set_ready_line(false);
}
cycles_since_speaker_update_ += cycles_run_for;

View File

@ -11,16 +11,18 @@
using namespace Atari2600;
namespace {
const int cycles_per_line = 228;
const double NTSC_clock_rate = 1194720;
const double PAL_clock_rate = 1182298;
}
TIA::TIA() :
horizontal_counter_(0)
{
crt_.reset(new Outputs::CRT::CRT(228, 1, 263, Outputs::CRT::ColourSpace::YIQ, 228, 1, false, 1));
crt_.reset(new Outputs::CRT::CRT(cycles_per_line * 2 + 1, 1, Outputs::CRT::DisplayType::NTSC60, 1));
crt_->set_output_device(Outputs::CRT::Television);
set_output_mode(OutputMode::NTSC);
}
void TIA::set_output_mode(Atari2600::TIA::OutputMode output_mode)
{
// this is the NTSC phase offset function; see below for PAL
crt_->set_composite_sampling_function(
"float composite_sample(usampler2D texID, vec2 coordinate, vec2 iCoordinate, float phase, float amplitude)"

View File

@ -19,7 +19,12 @@ class TIA {
TIA();
~TIA();
enum class OutputMode {
NTSC, PAL
};
void run_for_cycles(int number_of_cycles);
void set_output_mode(OutputMode output_mode);
void set_vsync(bool vsync);
void set_vblank(bool vblank);
@ -63,6 +68,7 @@ class TIA {
std::shared_ptr<Outputs::CRT::CRT> crt_;
int horizontal_counter_;
void output_for_cycles(int number_of_cycles);
void output_line();
};