Various fixes to get Mac build compiling

This commit is contained in:
Aaron Culliney
2015-11-13 23:13:21 -08:00
parent dc1845afe9
commit a61fd339a6
9 changed files with 46 additions and 32 deletions

View File

@@ -59,7 +59,7 @@
BOOL readOnlyA = [defaults boolForKey:kApple2PrefStartupDiskAProtected]; BOOL readOnlyA = [defaults boolForKey:kApple2PrefStartupDiskAProtected];
if (startupDiskA) if (startupDiskA)
{ {
const char *err = c_new_diskette_6(0, [[NSString stringWithFormat:@"%@.gz", startupDiskA] UTF8String], readOnlyA); const char *err = disk6_insert(0, [[NSString stringWithFormat:@"%@.gz", startupDiskA] UTF8String], readOnlyA);
if (!err) if (!err)
{ {
[self.diskInA setStringValue:[[startupDiskA pathComponents] lastObject]]; [self.diskInA setStringValue:[[startupDiskA pathComponents] lastObject]];
@@ -73,7 +73,7 @@
BOOL readOnlyB = [defaults boolForKey:kApple2PrefStartupDiskBProtected]; BOOL readOnlyB = [defaults boolForKey:kApple2PrefStartupDiskBProtected];
if (startupDiskB) if (startupDiskB)
{ {
const char *err = c_new_diskette_6(1, [[NSString stringWithFormat:@"%@.gz", startupDiskB] UTF8String], readOnlyB); const char *err = disk6_insert(1, [[NSString stringWithFormat:@"%@.gz", startupDiskB] UTF8String], readOnlyB);
if (!err) if (!err)
{ {
[self.diskInB setStringValue:[[startupDiskB pathComponents] lastObject]]; [self.diskInB setStringValue:[[startupDiskB pathComponents] lastObject]];
@@ -95,22 +95,22 @@
if ([self.startupLoadDiskA state] == NSOnState) if ([self.startupLoadDiskA state] == NSOnState)
{ {
if (disk6.disk[0].fp) if (disk6.disk[0].fd >= 0)
{ {
NSString *diskA = [NSString stringWithUTF8String:disk6.disk[0].file_name]; NSString *diskA = [NSString stringWithUTF8String:disk6.disk[0].file_name];
[defaults setObject:diskA forKey:kApple2PrefStartupDiskA]; [defaults setObject:diskA forKey:kApple2PrefStartupDiskA];
NSButtonCell *readOnlyChoice = [[[self diskAProtection] cells] firstObject]; NSButtonCell *readOnlyChoice = (NSButtonCell *)[[[self diskAProtection] cells] firstObject];
[defaults setBool:([readOnlyChoice state] == NSOnState) forKey:kApple2PrefStartupDiskAProtected]; [defaults setBool:([readOnlyChoice state] == NSOnState) forKey:kApple2PrefStartupDiskAProtected];
} }
} }
if ([self.startupLoadDiskB state] == NSOnState) if ([self.startupLoadDiskB state] == NSOnState)
{ {
if (disk6.disk[1].fp) if (disk6.disk[1].fd >= 0)
{ {
NSString *diskB = [NSString stringWithUTF8String:disk6.disk[1].file_name]; NSString *diskB = [NSString stringWithUTF8String:disk6.disk[1].file_name];
[defaults setObject:diskB forKey:kApple2PrefStartupDiskB]; [defaults setObject:diskB forKey:kApple2PrefStartupDiskB];
NSButtonCell *readOnlyChoice = [[[self diskBProtection] cells] firstObject]; NSButtonCell *readOnlyChoice = (NSButtonCell *)[[[self diskBProtection] cells] firstObject];
[defaults setBool:([readOnlyChoice state] == NSOnState) forKey:kApple2PrefStartupDiskBProtected]; [defaults setBool:([readOnlyChoice state] == NSOnState) forKey:kApple2PrefStartupDiskBProtected];
} }
} }
@@ -118,13 +118,13 @@
- (void)_protectionChangedForDrive:(int)drive - (void)_protectionChangedForDrive:(int)drive
{ {
if (disk6.disk[drive].fp == NULL) if (disk6.disk[drive].fd < 0)
{ {
return; return;
} }
// HACK NOTE : dispatch so that state of outlet property is set properly // HACK NOTE : dispatch so that state of outlet property is set properly
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
NSButtonCell *readOnlyChoice = [[(drive == 0 ? [self diskAProtection] : [self diskBProtection]) cells] firstObject]; NSButtonCell *readOnlyChoice = (NSButtonCell *)[[(drive == 0 ? [self diskAProtection] : [self diskBProtection]) cells] firstObject];
NSString *path = [NSString stringWithUTF8String:disk6.disk[drive].file_name]; NSString *path = [NSString stringWithUTF8String:disk6.disk[drive].file_name];
[self _insertDisketteInDrive:drive path:path type:[EmulatorDiskController extensionForPath:path] readOnly:([readOnlyChoice state] == NSOnState)]; [self _insertDisketteInDrive:drive path:path type:[EmulatorDiskController extensionForPath:path] readOnly:([readOnlyChoice state] == NSOnState)];
[self _savePrefs]; [self _savePrefs];
@@ -143,13 +143,13 @@
- (BOOL)_insertDisketteInDrive:(int)drive path:(NSString *)path type:(NSString *)type readOnly:(BOOL)readOnly - (BOOL)_insertDisketteInDrive:(int)drive path:(NSString *)path type:(NSString *)type readOnly:(BOOL)readOnly
{ {
c_eject_6(drive); disk6_eject(drive);
const char *errMsg = c_new_diskette_6(drive, [path UTF8String], readOnly); const char *errMsg = disk6_insert(drive, [path UTF8String], readOnly);
if (errMsg) if (errMsg)
{ {
path = [NSString stringWithFormat:@"%@.gz", path]; path = [NSString stringWithFormat:@"%@.gz", path];
errMsg = c_new_diskette_6(drive, [path UTF8String], readOnly); errMsg = disk6_insert(drive, [path UTF8String], readOnly);
if (errMsg) if (errMsg)
{ {
NSAlert *alert = [NSAlert alertWithError:[NSError errorWithDomain:[NSString stringWithUTF8String:errMsg] code:-1 userInfo:nil]]; NSAlert *alert = [NSAlert alertWithError:[NSError errorWithDomain:[NSString stringWithUTF8String:errMsg] code:-1 userInfo:nil]];
@@ -296,13 +296,13 @@
- (IBAction)chooseDriveA:(id)sender - (IBAction)chooseDriveA:(id)sender
{ {
NSButtonCell *readOnlyChoice = [[[self diskAProtection] cells] firstObject]; NSButtonCell *readOnlyChoice = (NSButtonCell *)[[[self diskAProtection] cells] firstObject];
[self _chooseDisk:0 readOnly:([readOnlyChoice state] == NSOnState)]; [self _chooseDisk:0 readOnly:([readOnlyChoice state] == NSOnState)];
} }
- (IBAction)chooseDriveB:(id)sender - (IBAction)chooseDriveB:(id)sender
{ {
NSButtonCell *readOnlyChoice = [[[self diskBProtection] cells] firstObject]; NSButtonCell *readOnlyChoice = (NSButtonCell *)[[[self diskBProtection] cells] firstObject];
[self _chooseDisk:1 readOnly:([readOnlyChoice state] == NSOnState)]; [self _chooseDisk:1 readOnly:([readOnlyChoice state] == NSOnState)];
} }

View File

@@ -189,7 +189,7 @@ static CVReturn displayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
// to [self openGLContext]) // to [self openGLContext])
[[self openGLContext] makeCurrentContext]; [[self openGLContext] makeCurrentContext];
timing_startCPU(); emulator_start();
// Synchronize buffer swaps with vertical refresh rate // Synchronize buffer swaps with vertical refresh rate
GLint swapInt = 1; GLint swapInt = 1;
@@ -313,8 +313,8 @@ static CVReturn displayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)application - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)application
{ {
c_eject_6(0); disk6_eject(0);
c_eject_6(1); disk6_eject(1);
return NSTerminateNow; return NSTerminateNow;
} }

View File

@@ -215,7 +215,7 @@
[self _savePrefs]; [self _savePrefs];
#warning HACK TODO FIXME need to refactor video resetting procedure #warning HACK TODO FIXME need to refactor video resetting procedure
video_set(0); video_reset();
video_setpage(!!(softswitches & SS_SCREEN)); video_setpage(!!(softswitches & SS_SCREEN));
video_redraw(); video_redraw();
} }

View File

@@ -123,16 +123,10 @@
{ {
[[self pauseMenuItem] setTitle:@"Resume Emulation"]; [[self pauseMenuItem] setTitle:@"Resume Emulation"];
cpu_pause(); cpu_pause();
#ifdef AUDIO_ENABLED
SoundSystemPause();
#endif
} }
else else
{ {
[[self pauseMenuItem] setTitle:@"Pause Emulation"]; [[self pauseMenuItem] setTitle:@"Pause Emulation"];
#ifdef AUDIO_ENABLED
SoundSystemUnpause();
#endif
cpu_resume(); cpu_resume();
} }
} }

View File

@@ -13,7 +13,22 @@
#define _COMMON_H_ #define _COMMON_H_
#if defined(__GNUC__) && !defined(_GNU_SOURCE) #if defined(__GNUC__) && !defined(_GNU_SOURCE)
# define _GNU_SOURCE # define _GNU_SOURCE 1
#endif
#if !defined(TEMP_FAILURE_RETRY)
# warning DEFINING CUSTOM TEMP_FAILURE_RETRY(x) macro
# define TEMP_FAILURE_RETRY(exp) ({ \
typeof (exp) _rc; \
do { \
_rc = (exp); \
if (_rc == -1 && (errno == EINTR || errno == EAGAIN) ) { \
usleep(10); \
} else { \
break; \
} \
} while (1); \
_rc; })
#endif #endif
// custom annotations // custom annotations
@@ -158,7 +173,13 @@ static const char *log_end = "";
extern FILE *error_log; extern FILE *error_log;
static const char *log_end = "\n"; static const char *log_end = "\n";
# define QUIT_FUNCTION(x) exit(x) # define QUIT_FUNCTION(x) exit(x)
# define _LOG_CMD(str) fprintf(error_log, "%s", str) # define _LOG_CMD(str) \
do { \
if (UNLIKELY(!error_log)) { \
error_log = stderr; \
} \
fprintf(error_log, "%s", str); \
} while (0);
#endif #endif
#define _MYFILE_ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) #define _MYFILE_ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)

View File

@@ -449,7 +449,7 @@ static size_t load_track_data(int drive) {
return expected; return expected;
} }
static bool save_track_data(int drive) { static void save_track_data(int drive) {
SCOPE_TRACE_DISK("save_track_data"); SCOPE_TRACE_DISK("save_track_data");
unsigned int trk = (disk6.disk[drive].phase >> 1); unsigned int trk = (disk6.disk[drive].phase >> 1);

View File

@@ -25,8 +25,7 @@ int argc = 0;
CrashHandler_s *crashHandler = NULL; CrashHandler_s *crashHandler = NULL;
__attribute__((constructor(CTOR_PRIORITY_FIRST))) __attribute__((constructor(CTOR_PRIORITY_FIRST)))
static void _init_common() { static void _init_common(void) {
error_log = stderr;
#if defined(CONFIG_DATADIR) #if defined(CONFIG_DATADIR)
data_dir = strdup(CONFIG_DATADIR PATH_SEPARATOR PACKAGE_NAME); data_dir = strdup(CONFIG_DATADIR PATH_SEPARATOR PACKAGE_NAME);
#elif defined(ANDROID) #elif defined(ANDROID)
@@ -69,8 +68,8 @@ static void _shutdown_threads(void) {
static struct timespec ts = { .tv_sec=0, .tv_nsec=33333333 }; static struct timespec ts = { .tv_sec=0, .tv_nsec=33333333 };
nanosleep(&ts, NULL); // 30Hz framerate nanosleep(&ts, NULL); // 30Hz framerate
} while (1); } while (1);
# elif defined(__APPLE__) # elif !defined(__APPLE__)
# error TODO FIXME ... verify leaks-n-things with instruments on Darwin # error TODO FIXME ... verify leaks-n-things with Valgrind on unknown platform
# endif # endif
#endif #endif
} }

View File

@@ -1,4 +1,4 @@
#ifdef __APPLE__ #ifdef __APPLE__
// include non-free components generated by genrom // include non-free components generated by genrom
#include "rom/rom.c" #include "rom.c"
#endif #endif

View File

@@ -119,7 +119,7 @@ int64_t glnode_onTouchEvent(interface_touch_event_t action, int pointer_count, i
#endif #endif
__attribute__((destructor(255))) __attribute__((destructor(255)))
static void *_destroy_glnodes(void) { static void _destroy_glnodes(void) {
LOG("..."); LOG("...");
glnode_array_node_s *p = head; glnode_array_node_s *p = head;