mirror of
https://github.com/mauiaaron/apple2.git
synced 2025-01-06 10:29:59 +00:00
Various fixes to get Mac build compiling
This commit is contained in:
parent
dc1845afe9
commit
a61fd339a6
@ -59,7 +59,7 @@
|
||||
BOOL readOnlyA = [defaults boolForKey:kApple2PrefStartupDiskAProtected];
|
||||
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)
|
||||
{
|
||||
[self.diskInA setStringValue:[[startupDiskA pathComponents] lastObject]];
|
||||
@ -73,7 +73,7 @@
|
||||
BOOL readOnlyB = [defaults boolForKey:kApple2PrefStartupDiskBProtected];
|
||||
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)
|
||||
{
|
||||
[self.diskInB setStringValue:[[startupDiskB pathComponents] lastObject]];
|
||||
@ -95,22 +95,22 @@
|
||||
|
||||
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];
|
||||
[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];
|
||||
}
|
||||
}
|
||||
|
||||
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];
|
||||
[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];
|
||||
}
|
||||
}
|
||||
@ -118,13 +118,13 @@
|
||||
|
||||
- (void)_protectionChangedForDrive:(int)drive
|
||||
{
|
||||
if (disk6.disk[drive].fp == NULL)
|
||||
if (disk6.disk[drive].fd < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// HACK NOTE : dispatch so that state of outlet property is set properly
|
||||
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];
|
||||
[self _insertDisketteInDrive:drive path:path type:[EmulatorDiskController extensionForPath:path] readOnly:([readOnlyChoice state] == NSOnState)];
|
||||
[self _savePrefs];
|
||||
@ -143,13 +143,13 @@
|
||||
|
||||
- (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)
|
||||
{
|
||||
path = [NSString stringWithFormat:@"%@.gz", path];
|
||||
errMsg = c_new_diskette_6(drive, [path UTF8String], readOnly);
|
||||
errMsg = disk6_insert(drive, [path UTF8String], readOnly);
|
||||
if (errMsg)
|
||||
{
|
||||
NSAlert *alert = [NSAlert alertWithError:[NSError errorWithDomain:[NSString stringWithUTF8String:errMsg] code:-1 userInfo:nil]];
|
||||
@ -296,13 +296,13 @@
|
||||
|
||||
- (IBAction)chooseDriveA:(id)sender
|
||||
{
|
||||
NSButtonCell *readOnlyChoice = [[[self diskAProtection] cells] firstObject];
|
||||
NSButtonCell *readOnlyChoice = (NSButtonCell *)[[[self diskAProtection] cells] firstObject];
|
||||
[self _chooseDisk:0 readOnly:([readOnlyChoice state] == NSOnState)];
|
||||
}
|
||||
|
||||
- (IBAction)chooseDriveB:(id)sender
|
||||
{
|
||||
NSButtonCell *readOnlyChoice = [[[self diskBProtection] cells] firstObject];
|
||||
NSButtonCell *readOnlyChoice = (NSButtonCell *)[[[self diskBProtection] cells] firstObject];
|
||||
[self _chooseDisk:1 readOnly:([readOnlyChoice state] == NSOnState)];
|
||||
}
|
||||
|
||||
|
@ -189,7 +189,7 @@ static CVReturn displayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
|
||||
// to [self openGLContext])
|
||||
[[self openGLContext] makeCurrentContext];
|
||||
|
||||
timing_startCPU();
|
||||
emulator_start();
|
||||
|
||||
// Synchronize buffer swaps with vertical refresh rate
|
||||
GLint swapInt = 1;
|
||||
@ -313,8 +313,8 @@ static CVReturn displayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
|
||||
|
||||
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)application
|
||||
{
|
||||
c_eject_6(0);
|
||||
c_eject_6(1);
|
||||
disk6_eject(0);
|
||||
disk6_eject(1);
|
||||
return NSTerminateNow;
|
||||
}
|
||||
|
||||
|
@ -215,7 +215,7 @@
|
||||
[self _savePrefs];
|
||||
|
||||
#warning HACK TODO FIXME need to refactor video resetting procedure
|
||||
video_set(0);
|
||||
video_reset();
|
||||
video_setpage(!!(softswitches & SS_SCREEN));
|
||||
video_redraw();
|
||||
}
|
||||
|
@ -123,16 +123,10 @@
|
||||
{
|
||||
[[self pauseMenuItem] setTitle:@"Resume Emulation"];
|
||||
cpu_pause();
|
||||
#ifdef AUDIO_ENABLED
|
||||
SoundSystemPause();
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
[[self pauseMenuItem] setTitle:@"Pause Emulation"];
|
||||
#ifdef AUDIO_ENABLED
|
||||
SoundSystemUnpause();
|
||||
#endif
|
||||
cpu_resume();
|
||||
}
|
||||
}
|
||||
|
25
src/common.h
25
src/common.h
@ -13,7 +13,22 @@
|
||||
#define _COMMON_H_
|
||||
|
||||
#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
|
||||
|
||||
// custom annotations
|
||||
@ -158,7 +173,13 @@ static const char *log_end = "";
|
||||
extern FILE *error_log;
|
||||
static const char *log_end = "\n";
|
||||
# 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
|
||||
|
||||
#define _MYFILE_ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
|
||||
|
@ -449,7 +449,7 @@ static size_t load_track_data(int drive) {
|
||||
return expected;
|
||||
}
|
||||
|
||||
static bool save_track_data(int drive) {
|
||||
static void save_track_data(int drive) {
|
||||
SCOPE_TRACE_DISK("save_track_data");
|
||||
|
||||
unsigned int trk = (disk6.disk[drive].phase >> 1);
|
||||
|
@ -25,8 +25,7 @@ int argc = 0;
|
||||
CrashHandler_s *crashHandler = NULL;
|
||||
|
||||
__attribute__((constructor(CTOR_PRIORITY_FIRST)))
|
||||
static void _init_common() {
|
||||
error_log = stderr;
|
||||
static void _init_common(void) {
|
||||
#if defined(CONFIG_DATADIR)
|
||||
data_dir = strdup(CONFIG_DATADIR PATH_SEPARATOR PACKAGE_NAME);
|
||||
#elif defined(ANDROID)
|
||||
@ -69,8 +68,8 @@ static void _shutdown_threads(void) {
|
||||
static struct timespec ts = { .tv_sec=0, .tv_nsec=33333333 };
|
||||
nanosleep(&ts, NULL); // 30Hz framerate
|
||||
} while (1);
|
||||
# elif defined(__APPLE__)
|
||||
# error TODO FIXME ... verify leaks-n-things with instruments on Darwin
|
||||
# elif !defined(__APPLE__)
|
||||
# error TODO FIXME ... verify leaks-n-things with Valgrind on unknown platform
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
#ifdef __APPLE__
|
||||
// include non-free components generated by genrom
|
||||
#include "rom/rom.c"
|
||||
#include "rom.c"
|
||||
#endif
|
||||
|
@ -119,7 +119,7 @@ int64_t glnode_onTouchEvent(interface_touch_event_t action, int pointer_count, i
|
||||
#endif
|
||||
|
||||
__attribute__((destructor(255)))
|
||||
static void *_destroy_glnodes(void) {
|
||||
static void _destroy_glnodes(void) {
|
||||
LOG("...");
|
||||
|
||||
glnode_array_node_s *p = head;
|
||||
|
Loading…
Reference in New Issue
Block a user