mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-27 01:31:42 +00:00
Started reviving the Atari 2600 emulation. Put new startup sequence into place.
This commit is contained in:
parent
bdaf4cee43
commit
80a3169674
@ -24,20 +24,25 @@ Machine::Machine() :
|
|||||||
_piaDataValue{0xff, 0xff},
|
_piaDataValue{0xff, 0xff},
|
||||||
_tiaInputValue{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));
|
memset(_collisions, 0xff, sizeof(_collisions));
|
||||||
set_reset_line(true);
|
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()
|
Machine::~Machine()
|
||||||
{
|
{
|
||||||
delete[] _rom;
|
delete[] _rom;
|
||||||
|
@ -30,6 +30,7 @@ class Machine: public CPU6502::Processor<Machine> {
|
|||||||
void set_digital_input(Atari2600DigitalInput input, bool state);
|
void set_digital_input(Atari2600DigitalInput input, bool state);
|
||||||
|
|
||||||
Outputs::CRT::CRT *get_crt() { return _crt; }
|
Outputs::CRT::CRT *get_crt() { return _crt; }
|
||||||
|
void setup_output(float aspect_ratio);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint8_t *_rom, *_romPages[4], _ram[128];
|
uint8_t *_rom, *_romPages[4], _ram[128];
|
||||||
|
@ -43,8 +43,10 @@
|
|||||||
[super crt:crt didEndFrame:frame didDetectVSync:didDetectVSync];
|
[super crt:crt didEndFrame:frame didDetectVSync:didDetectVSync];
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
- (void)doRunForNumberOfCycles:(int)numberOfCycles {
|
- (void)runForNumberOfCycles:(int)numberOfCycles {
|
||||||
_atari2600.run_for_cycles(numberOfCycles);
|
@synchronized(self) {
|
||||||
|
_atari2600.run_for_cycles(numberOfCycles);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)drawViewForPixelSize:(CGSize)pixelSize onlyIfDirty:(BOOL)onlyIfDirty {
|
- (void)drawViewForPixelSize:(CGSize)pixelSize onlyIfDirty:(BOOL)onlyIfDirty {
|
||||||
@ -52,15 +54,27 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)setROM:(NSData *)rom {
|
- (void)setROM:(NSData *)rom {
|
||||||
|
@synchronized(self) {
|
||||||
_atari2600.set_rom(rom.length, (const uint8_t *)rom.bytes);
|
_atari2600.set_rom(rom.length, (const uint8_t *)rom.bytes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setState:(BOOL)state forDigitalInput:(Atari2600DigitalInput)digitalInput {
|
- (void)setState:(BOOL)state forDigitalInput:(Atari2600DigitalInput)digitalInput {
|
||||||
|
@synchronized(self) {
|
||||||
_atari2600.set_digital_input(digitalInput, state ? true : false);
|
_atari2600.set_digital_input(digitalInput, state ? true : false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setResetLineEnabled:(BOOL)enabled {
|
- (void)setResetLineEnabled:(BOOL)enabled {
|
||||||
|
@synchronized(self) {
|
||||||
_atari2600.set_reset_line(enabled ? true : false);
|
_atari2600.set_reset_line(enabled ? true : false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setupOutputWithAspectRatio:(float)aspectRatio {
|
||||||
|
@synchronized(self) {
|
||||||
|
_atari2600.setup_output(aspectRatio);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -60,7 +60,6 @@
|
|||||||
- (BOOL)setSpeakerDelegate:(Outputs::Speaker::Delegate *)delegate sampleRate:(int)sampleRate {
|
- (BOOL)setSpeakerDelegate:(Outputs::Speaker::Delegate *)delegate sampleRate:(int)sampleRate {
|
||||||
@synchronized(self) {
|
@synchronized(self) {
|
||||||
_electron.get_speaker()->set_output_rate(sampleRate, 256);
|
_electron.get_speaker()->set_output_rate(sampleRate, 256);
|
||||||
// _electron.get_speaker()->set_output_quality(47);
|
|
||||||
_electron.get_speaker()->set_delegate(delegate);
|
_electron.get_speaker()->set_delegate(delegate);
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
@ -202,9 +202,9 @@ class CRT {
|
|||||||
/*! Sets a function that will map from whatever data the machine provided to a composite signal.
|
/*! 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
|
@param shader A GLSL fragment including a function with the signature
|
||||||
`float composite_sample(vec2 coordinate, float phase)` that evaluates to the composite signal
|
`float composite_sample(usampler2D texID, vec2 coordinate, vec2 iCoordinate, float phase, float amplitude)`
|
||||||
level as a function of a source buffer sampling location and the provided colour carrier phase.
|
that evaluates to the composite signal level as a function of a source buffer, sampling location, colour
|
||||||
The shader may assume a uniform array of sampler2Ds named `buffers` provides access to all input data.
|
carrier phase and amplitude.
|
||||||
*/
|
*/
|
||||||
inline void set_composite_sampling_function(const char *shader)
|
inline void set_composite_sampling_function(const char *shader)
|
||||||
{
|
{
|
||||||
|
@ -861,7 +861,8 @@ std::unique_ptr<OpenGL::Shader> OpenGLOutputBuilder::prepare_output_shader(char
|
|||||||
|
|
||||||
void OpenGLOutputBuilder::prepare_rgb_output_shader()
|
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()
|
void OpenGLOutputBuilder::prepare_composite_output_shader()
|
||||||
|
Loading…
Reference in New Issue
Block a user