1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-25 16:31:42 +00:00

This then is what the serial dispatch queue and the triple buffer achieve together: I can post the runs over to the main thread for processing while emulation continues separately.

This commit is contained in:
Thomas Harte 2015-07-23 20:16:48 -04:00
parent e7237c7bd5
commit 0611646181

View File

@ -26,36 +26,43 @@ struct Atari2600CRTDelegate: public Outputs::CRT::CRTDelegate {
} }
- (void)crtDidEndFrame:(Outputs::CRTFrame *)frame { - (void)crtDidEndFrame:(Outputs::CRTFrame *)frame {
printf("\n\n===\n\n");
int c = 0; dispatch_async(dispatch_get_main_queue(), ^{
for(int run = 0; run < frame->number_of_runs; run++)
{ printf("\n\n===\n\n");
char character = ' '; int c = 0;
switch(frame->runs[run].type) for(int run = 0; run < frame->number_of_runs; run++)
{ {
case Outputs::CRTRun::Type::Sync: character = '<'; break; char character = ' ';
case Outputs::CRTRun::Type::Level: character = '_'; break; switch(frame->runs[run].type)
case Outputs::CRTRun::Type::Data: character = '-'; break; {
case Outputs::CRTRun::Type::Blank: character = ' '; break; 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\n[%d]\n\n", c);
{
printf("\n[%0.2f]: ", frame->runs[run].start_point.dst_y);
c++;
}
printf("(%0.2f): ", frame->runs[run].start_point.dst_x); dispatch_async(_serialDispatchQueue, ^{
float length = fabsf(frame->runs[run].end_point.dst_x - frame->runs[run].start_point.dst_x); _atari2600.get_crt()->return_frame();
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();
} }
- (void)runForNumberOfCycles:(int)cycles { - (void)runForNumberOfCycles:(int)cycles {
@ -76,7 +83,7 @@ struct Atari2600CRTDelegate: public Outputs::CRT::CRTDelegate {
if (self) { if (self) {
_crtDelegate.atari = self; _crtDelegate.atari = self;
_atari2600.get_crt()->set_delegate(&_crtDelegate); _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; return self;