mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-26 08:49:37 +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.h"
|
||||||
#import "Atari2600.hpp"
|
#import "Atari2600.hpp"
|
||||||
|
|
||||||
class Atari2600CRTDelegate: public Outputs::CRT::CRTDelegate {
|
@interface CSAtari2600 (Callbacks)
|
||||||
void crt_did_end_frame(Outputs::CRT *crt, Outputs::CRTFrame *frame)
|
- (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");
|
printf("\n\n===\n\n");
|
||||||
int c = 0;
|
int c = 0;
|
||||||
for(int run = 0; run < frame->number_of_runs; run++)
|
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);
|
printf("\n\n[%d]\n\n", c);
|
||||||
crt->return_frame();
|
_atari2600.get_crt()->return_frame();
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
@implementation CSAtari2600 {
|
|
||||||
Atari2600::Machine _atari2600;
|
|
||||||
Atari2600CRTDelegate _crtDelegate;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)runForNumberOfCycles:(int)cycles {
|
- (void)runForNumberOfCycles:(int)cycles {
|
||||||
|
dispatch_async(_serialDispatchQueue, ^{
|
||||||
_atari2600.run_for_cycles(cycles);
|
_atari2600.run_for_cycles(cycles);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setROM:(NSData *)rom {
|
- (void)setROM:(NSData *)rom {
|
||||||
|
dispatch_async(_serialDispatchQueue, ^{
|
||||||
_atari2600.set_rom(rom.length, (const uint8_t *)rom.bytes);
|
_atari2600.set_rom(rom.length, (const uint8_t *)rom.bytes);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
- (instancetype)init {
|
- (instancetype)init {
|
||||||
self = [super init];
|
self = [super init];
|
||||||
|
|
||||||
if (self) {
|
if (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);
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
Loading…
Reference in New Issue
Block a user