diff --git a/OSBindings/Mac/Clock Signal/Atari2600.mm b/OSBindings/Mac/Clock Signal/Atari2600.mm index 975341e68..e9acd17fc 100644 --- a/OSBindings/Mac/Clock Signal/Atari2600.mm +++ b/OSBindings/Mac/Clock Signal/Atari2600.mm @@ -26,36 +26,43 @@ struct Atari2600CRTDelegate: public Outputs::CRT::CRTDelegate { } - (void)crtDidEndFrame:(Outputs::CRTFrame *)frame { - printf("\n\n===\n\n"); - int c = 0; - for(int run = 0; run < frame->number_of_runs; run++) - { - char character = ' '; - switch(frame->runs[run].type) + + dispatch_async(dispatch_get_main_queue(), ^{ + + printf("\n\n===\n\n"); + int c = 0; + for(int run = 0; run < frame->number_of_runs; run++) { - case Outputs::CRTRun::Type::Sync: character = '<'; break; - case Outputs::CRTRun::Type::Level: character = '_'; break; - case Outputs::CRTRun::Type::Data: character = '-'; break; - case Outputs::CRTRun::Type::Blank: character = ' '; break; + char character = ' '; + switch(frame->runs[run].type) + { + case Outputs::CRTRun::Type::Sync: character = '<'; break; + case Outputs::CRTRun::Type::Level: character = '_'; break; + case Outputs::CRTRun::Type::Data: character = '-'; break; + case Outputs::CRTRun::Type::Blank: character = ' '; break; + } + + if(frame->runs[run].start_point.dst_x < 1.0 / 224.0) + { + printf("\n[%0.2f]: ", frame->runs[run].start_point.dst_y); + c++; + } + + printf("(%0.2f): ", frame->runs[run].start_point.dst_x); + float length = fabsf(frame->runs[run].end_point.dst_x - frame->runs[run].start_point.dst_x); + int iLength = (int)(length * 64.0); + for(int c = 0; c < iLength; c++) + { + putc(character, stdout); + } } - if(frame->runs[run].start_point.dst_x < 1.0 / 224.0) - { - printf("\n[%0.2f]: ", frame->runs[run].start_point.dst_y); - c++; - } + printf("\n\n[%d]\n\n", c); - printf("(%0.2f): ", frame->runs[run].start_point.dst_x); - float length = fabsf(frame->runs[run].end_point.dst_x - frame->runs[run].start_point.dst_x); - int iLength = (int)(length * 64.0); - for(int c = 0; c < iLength; c++) - { - putc(character, stdout); - } - } - - printf("\n\n[%d]\n\n", c); - _atari2600.get_crt()->return_frame(); + dispatch_async(_serialDispatchQueue, ^{ + _atari2600.get_crt()->return_frame(); + }); + }); } - (void)runForNumberOfCycles:(int)cycles { @@ -76,7 +83,7 @@ struct Atari2600CRTDelegate: public Outputs::CRT::CRTDelegate { if (self) { _crtDelegate.atari = self; _atari2600.get_crt()->set_delegate(&_crtDelegate); - _serialDispatchQueue = dispatch_queue_create("Atari 2600 quuue", DISPATCH_QUEUE_SERIAL); + _serialDispatchQueue = dispatch_queue_create("Atari 2600 queue", DISPATCH_QUEUE_SERIAL); } return self;