1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-06-30 22:29:56 +00:00

Switched to two-phase setup to deal with OpenGL scheduling.

This commit is contained in:
Thomas Harte 2016-03-20 13:50:13 -04:00
parent eabc382540
commit fb6fb5d948
6 changed files with 30 additions and 9 deletions

View File

@ -46,6 +46,16 @@ Machine::Machine() :
_current_pixel_line(-1),
_use_fast_tape_hack(false),
_crt(std::unique_ptr<Outputs::CRT::CRT>(new Outputs::CRT::CRT(crt_cycles_per_line, 8, Outputs::CRT::DisplayType::PAL50, 1)))
{
memset(_key_states, 0, sizeof(_key_states));
memset(_palette, 0xf, sizeof(_palette));
for(int c = 0; c < 16; c++)
memset(_roms[c], 0xff, 16384);
_tape.set_delegate(this);
}
void Machine::setup_output()
{
_crt->set_rgb_sampling_function(
"vec4 rgb_sample(vec2 coordinate)"
@ -56,13 +66,7 @@ Machine::Machine() :
_crt->set_output_device(Outputs::CRT::Monitor);
// _crt->set_visible_area(Outputs::Rect(0.23108f, 0.0f, 0.8125f, 0.98f)); //1875
memset(_key_states, 0, sizeof(_key_states));
memset(_palette, 0xf, sizeof(_palette));
for(int c = 0; c < 16; c++)
memset(_roms[c], 0xff, 16384);
_speaker.set_input_rate(125000);
_tape.set_delegate(this);
}
unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uint16_t address, uint8_t *value)

View File

@ -152,6 +152,7 @@ class Machine: public CPU6502::Processor<Machine>, Tape::Delegate {
void set_key_state(Key key, bool isPressed);
void setup_output();
Outputs::CRT::CRT *get_crt() { return _crt.get(); }
Outputs::Speaker *get_speaker() { return &_speaker; }

View File

@ -11,6 +11,8 @@
@interface CSElectron : CSMachine
- (void)setupOutput;
- (void)setOSROM:(nonnull NSData *)rom;
- (void)setBASICROM:(nonnull NSData *)rom;
- (void)setROM:(nonnull NSData *)rom slot:(int)slot;

View File

@ -42,9 +42,7 @@
}
- (void)drawViewForPixelSize:(CGSize)pixelSize onlyIfDirty:(BOOL)onlyIfDirty {
@synchronized(self) {
_electron.get_crt()->draw_frame((unsigned int)pixelSize.width, (unsigned int)pixelSize.height, onlyIfDirty ? true : false);
}
_electron.get_crt()->draw_frame((unsigned int)pixelSize.width, (unsigned int)pixelSize.height, onlyIfDirty ? true : false);
}
- (BOOL)openUEFAtURL:(NSURL *)URL {
@ -154,4 +152,10 @@
}
}
- (void)setupOutput {
@synchronized(self) {
_electron.setup_output();
}
}
@end

View File

@ -16,5 +16,6 @@
- (void)speaker:(Outputs::Speaker *)speaker didCompleteSamples:(const int16_t *)samples length:(int)length;
- (void)performAsync:(dispatch_block_t)action;
- (void)performSync:(dispatch_block_t)action;
- (void)setupOutput;
@end

View File

@ -51,4 +51,13 @@ struct SpeakerDelegate: public Outputs::Speaker::Delegate {
dispatch_async(_serialDispatchQueue, action);
}
- (void)setupOutput {}
- (void)setView:(CSOpenGLView *)view {
_view = view;
[view performWithGLContext:^{
[self setupOutput];
}];
}
@end