mirror of
https://github.com/TomHarte/CLK.git
synced 2024-07-17 13:29:02 +00:00
Prevented unbounded CPU usage, albeit without yet deciding who has authority for the clock rate.
This commit is contained in:
parent
2432a3b4d7
commit
2390358c24
@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
using namespace Atari2600;
|
using namespace Atari2600;
|
||||||
namespace {
|
namespace {
|
||||||
static const unsigned int horizontalTimerPeriod = 228;
|
|
||||||
static const double NTSC_clock_rate = 1194720;
|
static const double NTSC_clock_rate = 1194720;
|
||||||
static const double PAL_clock_rate = 1182298;
|
static const double PAL_clock_rate = 1182298;
|
||||||
}
|
}
|
||||||
@ -31,6 +30,7 @@ void Machine::setup_output(float aspect_ratio)
|
|||||||
{
|
{
|
||||||
tia_.reset(new TIA);
|
tia_.reset(new TIA);
|
||||||
speaker_.reset(new Speaker);
|
speaker_.reset(new Speaker);
|
||||||
|
speaker_->set_input_rate((float)(get_clock_rate() / 38.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Machine::close_output()
|
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.
|
// skips to the end of the line.
|
||||||
if(operation == CPU6502::BusOperation::Ready) {
|
if(operation == CPU6502::BusOperation::Ready) {
|
||||||
cycles_run_for = (unsigned int)tia_->get_cycles_until_horizontal_blank(cycles_since_video_update_);
|
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;
|
cycles_since_speaker_update_ += cycles_run_for;
|
||||||
|
@ -11,16 +11,18 @@
|
|||||||
using namespace Atari2600;
|
using namespace Atari2600;
|
||||||
namespace {
|
namespace {
|
||||||
const int cycles_per_line = 228;
|
const int cycles_per_line = 228;
|
||||||
const double NTSC_clock_rate = 1194720;
|
|
||||||
const double PAL_clock_rate = 1182298;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TIA::TIA() :
|
TIA::TIA() :
|
||||||
horizontal_counter_(0)
|
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);
|
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
|
// this is the NTSC phase offset function; see below for PAL
|
||||||
crt_->set_composite_sampling_function(
|
crt_->set_composite_sampling_function(
|
||||||
"float composite_sample(usampler2D texID, vec2 coordinate, vec2 iCoordinate, float phase, float amplitude)"
|
"float composite_sample(usampler2D texID, vec2 coordinate, vec2 iCoordinate, float phase, float amplitude)"
|
||||||
|
@ -19,7 +19,12 @@ class TIA {
|
|||||||
TIA();
|
TIA();
|
||||||
~TIA();
|
~TIA();
|
||||||
|
|
||||||
|
enum class OutputMode {
|
||||||
|
NTSC, PAL
|
||||||
|
};
|
||||||
|
|
||||||
void run_for_cycles(int number_of_cycles);
|
void run_for_cycles(int number_of_cycles);
|
||||||
|
void set_output_mode(OutputMode output_mode);
|
||||||
|
|
||||||
void set_vsync(bool vsync);
|
void set_vsync(bool vsync);
|
||||||
void set_vblank(bool vblank);
|
void set_vblank(bool vblank);
|
||||||
@ -63,6 +68,7 @@ class TIA {
|
|||||||
std::shared_ptr<Outputs::CRT::CRT> crt_;
|
std::shared_ptr<Outputs::CRT::CRT> crt_;
|
||||||
|
|
||||||
int horizontal_counter_;
|
int horizontal_counter_;
|
||||||
|
|
||||||
void output_for_cycles(int number_of_cycles);
|
void output_for_cycles(int number_of_cycles);
|
||||||
void output_line();
|
void output_line();
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user