1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-26 09:29:45 +00:00

Started reviving the Atari 2600 emulation. Put new startup sequence into place.

This commit is contained in:
Thomas Harte 2016-04-24 06:56:08 -04:00
parent bdaf4cee43
commit 80a3169674
6 changed files with 37 additions and 17 deletions

View File

@ -24,20 +24,25 @@ Machine::Machine() :
_piaDataValue{0xff, 0xff},
_tiaInputValue{0xff, 0xff}
{
_crt = new Outputs::CRT::CRT(228, 1, Outputs::CRT::DisplayType::NTSC60, 2);
_crt->set_composite_sampling_function(
"float composite_sample(vec2 coordinate, float phase)\n"
"{\n"
"vec2 c = texture(texID, coordinate).rg;"
"float y = 0.1 + c.x * 0.91071428571429;\n"
"float aOffset = 6.283185308 * (c.y - 3.0 / 16.0) * 1.14285714285714;\n"
"return y + step(0.03125, c.y) * 0.1 * cos((coordinate.x * 2.0 * 3.141592654) - aOffset);\n"
"}");
_crt->set_output_device(Outputs::CRT::Television);
memset(_collisions, 0xff, sizeof(_collisions));
set_reset_line(true);
}
void Machine::setup_output(float aspect_ratio)
{
_crt = new Outputs::CRT::CRT(228, 1, Outputs::CRT::DisplayType::NTSC60, 2);
_crt->set_composite_sampling_function(
"float composite_sample(usampler2D texID, vec2 coordinate, vec2 iCoordinate, float phase, float amplitude)\n"
"{\n"
"return 0.9;"
// "vec2 c = vec2(1.0);"//vec2(texture(texID, coordinate).rg) / vec2(255.0);"
// "float y = 0.1 + c.x * 0.91071428571429;\n"
// "float aOffset = 6.283185308 * (c.y - 3.0 / 16.0) * 1.14285714285714;\n"
// "return y + step(0.03125, c.y) * 0.1 * cos((coordinate.x * 2.0 * 3.141592654) - aOffset);\n"
"}");
_crt->set_output_device(Outputs::CRT::Television);
}
Machine::~Machine()
{
delete[] _rom;

View File

@ -30,6 +30,7 @@ class Machine: public CPU6502::Processor<Machine> {
void set_digital_input(Atari2600DigitalInput input, bool state);
Outputs::CRT::CRT *get_crt() { return _crt; }
void setup_output(float aspect_ratio);
private:
uint8_t *_rom, *_romPages[4], _ram[128];

View File

@ -43,8 +43,10 @@
[super crt:crt didEndFrame:frame didDetectVSync:didDetectVSync];
}*/
- (void)doRunForNumberOfCycles:(int)numberOfCycles {
_atari2600.run_for_cycles(numberOfCycles);
- (void)runForNumberOfCycles:(int)numberOfCycles {
@synchronized(self) {
_atari2600.run_for_cycles(numberOfCycles);
}
}
- (void)drawViewForPixelSize:(CGSize)pixelSize onlyIfDirty:(BOOL)onlyIfDirty {
@ -52,15 +54,27 @@
}
- (void)setROM:(NSData *)rom {
@synchronized(self) {
_atari2600.set_rom(rom.length, (const uint8_t *)rom.bytes);
}
}
- (void)setState:(BOOL)state forDigitalInput:(Atari2600DigitalInput)digitalInput {
@synchronized(self) {
_atari2600.set_digital_input(digitalInput, state ? true : false);
}
}
- (void)setResetLineEnabled:(BOOL)enabled {
@synchronized(self) {
_atari2600.set_reset_line(enabled ? true : false);
}
}
- (void)setupOutputWithAspectRatio:(float)aspectRatio {
@synchronized(self) {
_atari2600.setup_output(aspectRatio);
}
}
@end

View File

@ -60,7 +60,6 @@
- (BOOL)setSpeakerDelegate:(Outputs::Speaker::Delegate *)delegate sampleRate:(int)sampleRate {
@synchronized(self) {
_electron.get_speaker()->set_output_rate(sampleRate, 256);
// _electron.get_speaker()->set_output_quality(47);
_electron.get_speaker()->set_delegate(delegate);
return YES;
}

View File

@ -202,9 +202,9 @@ class CRT {
/*! Sets a function that will map from whatever data the machine provided to a composite signal.
@param shader A GLSL fragment including a function with the signature
`float composite_sample(vec2 coordinate, float phase)` that evaluates to the composite signal
level as a function of a source buffer sampling location and the provided colour carrier phase.
The shader may assume a uniform array of sampler2Ds named `buffers` provides access to all input data.
`float composite_sample(usampler2D texID, vec2 coordinate, vec2 iCoordinate, float phase, float amplitude)`
that evaluates to the composite signal level as a function of a source buffer, sampling location, colour
carrier phase and amplitude.
*/
inline void set_composite_sampling_function(const char *shader)
{

View File

@ -861,7 +861,8 @@ std::unique_ptr<OpenGL::Shader> OpenGLOutputBuilder::prepare_output_shader(char
void OpenGLOutputBuilder::prepare_rgb_output_shader()
{
rgb_shader_program = prepare_output_shader(get_rgb_output_vertex_shader(), get_rgb_output_fragment_shader(), source_data_texture_unit);
if(_rgb_shader)
rgb_shader_program = prepare_output_shader(get_rgb_output_vertex_shader(), get_rgb_output_fragment_shader(), source_data_texture_unit);
}
void OpenGLOutputBuilder::prepare_composite_output_shader()