Emulator protocol: add currentApplication

This commit is contained in:
Jesús A. Álvarez 2016-06-04 15:00:31 +02:00
parent ec5c1fb188
commit 8c3434740f
2 changed files with 20 additions and 0 deletions

View File

@ -22,7 +22,9 @@
@property (nonatomic, readonly) NSString *insertDiskNotification, *ejectDiskNotification;
@property (nonatomic, readonly) NSInteger initialSpeed;
@property (nonatomic, readonly) NSData *RAM;
@property (nonatomic, readonly) BOOL anyDiskInserted;
@property (nonatomic, readonly) NSString *currentApplication;
+ (instancetype)sharedEmulator;

View File

@ -31,8 +31,12 @@
#include "ENDIANAC.h"
#include "MYOSGLUE.h"
#include "STRCONST.h"
#include "EMCONFIG.h"
#import "EmulatorProtocol.h"
#define kRAM_Size (kRAMa_Size + kRAMb_Size)
EXPORTVAR(ui3p, RAM)
@interface Emulator : NSObject <Emulator>
- (void)updateScreen:(CGImageRef)screenImage;
@ -1752,6 +1756,20 @@ static dispatch_once_t onceToken;
WantMacReset = trueblnr;
}
- (NSData *)RAM {
return [NSData dataWithBytesNoCopy:RAM length:kRAM_Size freeWhenDone:NO];
}
- (NSString *)currentApplication {
NSData *curApName = [self.RAM subdataWithRange:NSMakeRange(0x910, 32)];
uint8_t curApNameLength = *(uint8_t*)curApName.bytes;
if (curApNameLength == 0 || curApNameLength > 31) {
return nil;
} else {
return [[NSString alloc] initWithBytes:curApName.bytes+1 length:curApNameLength encoding:NSMacOSRomanStringEncoding];
}
}
#pragma mark - Screen
@synthesize screenLayer;