2017-01-28 21:19:08 +00:00
|
|
|
//
|
|
|
|
// TIA.cpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 28/01/2017.
|
|
|
|
// Copyright © 2017 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "TIA.hpp"
|
2017-01-29 02:46:40 +00:00
|
|
|
|
|
|
|
using namespace Atari2600;
|
|
|
|
|
|
|
|
TIA::TIA()
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
crt_.reset(new Outputs::CRT::CRT(228, 1, 263, Outputs::CRT::ColourSpace::YIQ, 228, 1, false, 1));
|
|
|
|
crt_->set_output_device(Outputs::CRT::Television);
|
|
|
|
|
|
|
|
// 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)"
|
|
|
|
"{"
|
|
|
|
"uint c = texture(texID, coordinate).r;"
|
|
|
|
"uint y = c & 14u;"
|
|
|
|
"uint iPhase = (c >> 4);"
|
|
|
|
|
|
|
|
"float phaseOffset = 6.283185308 * float(iPhase) / 13.0 + 5.074880441076923;"
|
|
|
|
"return mix(float(y) / 14.0, step(1, iPhase) * cos(phase + phaseOffset), amplitude);"
|
|
|
|
"}");
|
|
|
|
speaker_->set_input_rate((float)(get_clock_rate() / 38.0));*/
|
|
|
|
}
|
|
|
|
|
|
|
|
/*void Machine::switch_region()
|
|
|
|
{
|
|
|
|
// the PAL function
|
|
|
|
crt_->set_composite_sampling_function(
|
|
|
|
"float composite_sample(usampler2D texID, vec2 coordinate, vec2 iCoordinate, float phase, float amplitude)"
|
|
|
|
"{"
|
|
|
|
"uint c = texture(texID, coordinate).r;"
|
|
|
|
"uint y = c & 14u;"
|
|
|
|
"uint iPhase = (c >> 4);"
|
|
|
|
|
|
|
|
"uint direction = iPhase & 1u;"
|
|
|
|
"float phaseOffset = float(7u - direction) + (float(direction) - 0.5) * 2.0 * float(iPhase >> 1);"
|
|
|
|
"phaseOffset *= 6.283185308 / 12.0;"
|
|
|
|
"return mix(float(y) / 14.0, step(4, (iPhase + 2u) & 15u) * cos(phase + phaseOffset), amplitude);"
|
|
|
|
"}");
|
|
|
|
|
|
|
|
crt_->set_new_timing(228, 312, Outputs::CRT::ColourSpace::YUV, 228, 1, true);
|
|
|
|
|
|
|
|
is_pal_region_ = true;
|
|
|
|
speaker_->set_input_rate((float)(get_clock_rate() / 38.0));
|
|
|
|
set_clock_rate(PAL_clock_rate);
|
|
|
|
}*/
|
|
|
|
|
|
|
|
// justification for +5: "we need to wait at least 71 [clocks] before the HMOVE operation is complete";
|
|
|
|
// which will take 16*4 + 2 = 66 cycles from the first compare, implying the first compare must be
|
|
|
|
// in five cycles from now
|