mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-22 12:33:29 +00:00
Switched to forcing all processing onto a common queue and piping the completed frame over into the Objective-C class.
This commit is contained in:
parent
d72287a776
commit
e7237c7bd5
@ -9,9 +9,23 @@
|
||||
#import "Atari2600.h"
|
||||
#import "Atari2600.hpp"
|
||||
|
||||
class Atari2600CRTDelegate: public Outputs::CRT::CRTDelegate {
|
||||
void crt_did_end_frame(Outputs::CRT *crt, Outputs::CRTFrame *frame)
|
||||
{
|
||||
@interface CSAtari2600 (Callbacks)
|
||||
- (void)crtDidEndFrame:(Outputs::CRTFrame *)frame;
|
||||
@end
|
||||
|
||||
struct Atari2600CRTDelegate: public Outputs::CRT::CRTDelegate {
|
||||
CSAtari2600 *atari;
|
||||
void crt_did_end_frame(Outputs::CRT *crt, Outputs::CRTFrame *frame) { [atari crtDidEndFrame:frame]; }
|
||||
};
|
||||
|
||||
@implementation CSAtari2600 {
|
||||
Atari2600::Machine _atari2600;
|
||||
Atari2600CRTDelegate _crtDelegate;
|
||||
|
||||
dispatch_queue_t _serialDispatchQueue;
|
||||
}
|
||||
|
||||
- (void)crtDidEndFrame:(Outputs::CRTFrame *)frame {
|
||||
printf("\n\n===\n\n");
|
||||
int c = 0;
|
||||
for(int run = 0; run < frame->number_of_runs; run++)
|
||||
@ -41,29 +55,28 @@ class Atari2600CRTDelegate: public Outputs::CRT::CRTDelegate {
|
||||
}
|
||||
|
||||
printf("\n\n[%d]\n\n", c);
|
||||
crt->return_frame();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@implementation CSAtari2600 {
|
||||
Atari2600::Machine _atari2600;
|
||||
Atari2600CRTDelegate _crtDelegate;
|
||||
_atari2600.get_crt()->return_frame();
|
||||
}
|
||||
|
||||
- (void)runForNumberOfCycles:(int)cycles {
|
||||
dispatch_async(_serialDispatchQueue, ^{
|
||||
_atari2600.run_for_cycles(cycles);
|
||||
});
|
||||
}
|
||||
|
||||
- (void)setROM:(NSData *)rom {
|
||||
dispatch_async(_serialDispatchQueue, ^{
|
||||
_atari2600.set_rom(rom.length, (const uint8_t *)rom.bytes);
|
||||
});
|
||||
}
|
||||
|
||||
- (instancetype)init {
|
||||
self = [super init];
|
||||
|
||||
if (self) {
|
||||
_crtDelegate.atari = self;
|
||||
_atari2600.get_crt()->set_delegate(&_crtDelegate);
|
||||
_serialDispatchQueue = dispatch_queue_create("Atari 2600 quuue", DISPATCH_QUEUE_SERIAL);
|
||||
}
|
||||
|
||||
return self;
|
||||
|
Loading…
Reference in New Issue
Block a user