2013-07-06 04:37:13 +00:00
|
|
|
/*
|
2015-10-22 05:13:26 +00:00
|
|
|
* Apple // emulator for *ix
|
|
|
|
*
|
|
|
|
* This software package is subject to the GNU General Public License
|
|
|
|
* version 3 or later (your choice) as published by the Free Software
|
|
|
|
* Foundation.
|
2013-06-11 07:08:15 +00:00
|
|
|
*
|
|
|
|
* Copyright 1994 Alexander Jean-Claude Bottema
|
|
|
|
* Copyright 1995 Stephen Lee
|
|
|
|
* Copyright 1997, 1998 Aaron Culliney
|
|
|
|
* Copyright 1998, 1999, 2000 Michael Deutschmann
|
2015-10-22 05:13:26 +00:00
|
|
|
* Copyright 2013-2015 Aaron Culliney
|
2013-06-11 07:08:15 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2015-09-11 07:00:04 +00:00
|
|
|
#ifndef _MISC_H_
|
|
|
|
#define _MISC_H_
|
2013-06-11 07:08:15 +00:00
|
|
|
|
2016-02-23 05:36:08 +00:00
|
|
|
enum {
|
|
|
|
CTOR_PRIORITY_FIRST = 101,
|
|
|
|
CTOR_PRIORITY_EARLY = 111,
|
|
|
|
CTOR_PRIORITY_LATE = 201,
|
|
|
|
};
|
|
|
|
|
2015-09-11 07:00:04 +00:00
|
|
|
// top installation directory
|
2015-02-23 19:19:41 +00:00
|
|
|
extern const char *data_dir;
|
|
|
|
|
2016-07-18 02:09:46 +00:00
|
|
|
#if MOBILE_DEVICE
|
|
|
|
# define HOMEDIR data_dir
|
|
|
|
#else
|
|
|
|
# define HOMEDIR getenv("HOME")
|
|
|
|
#endif
|
|
|
|
|
2015-09-11 07:00:04 +00:00
|
|
|
// global ref to CLI args
|
|
|
|
extern char **argv;
|
|
|
|
extern int argc;
|
2013-07-06 04:37:13 +00:00
|
|
|
|
2017-09-10 02:57:06 +00:00
|
|
|
// locale
|
|
|
|
extern const char *locale;
|
|
|
|
|
2016-04-17 19:08:11 +00:00
|
|
|
//
|
|
|
|
// Emulator lifecycle
|
|
|
|
//
|
|
|
|
|
|
|
|
typedef void (*startup_callback_f)(void);
|
|
|
|
|
2016-02-23 05:36:08 +00:00
|
|
|
// register a startup function
|
|
|
|
void emulator_registerStartupCallback(long order, startup_callback_f callback);
|
|
|
|
|
2015-09-11 07:00:04 +00:00
|
|
|
// start emulator (CPU, audio, and video)
|
|
|
|
void emulator_start(void);
|
2013-07-06 04:37:13 +00:00
|
|
|
|
2015-09-11 07:00:04 +00:00
|
|
|
// shutdown emulator in preparation for app exit
|
|
|
|
void emulator_shutdown(void);
|
2013-06-11 07:08:15 +00:00
|
|
|
|
2016-04-17 19:08:11 +00:00
|
|
|
// is emulator shutting down?
|
|
|
|
bool emulator_isShuttingDown(void);
|
|
|
|
|
2015-11-23 03:04:46 +00:00
|
|
|
//
|
|
|
|
// Emulator state save/restore
|
|
|
|
//
|
|
|
|
|
|
|
|
typedef struct StateHelper_s {
|
|
|
|
int fd;
|
2016-10-09 21:54:11 +00:00
|
|
|
int version;
|
2017-05-21 21:58:55 +00:00
|
|
|
int diskFdA;
|
|
|
|
int diskFdB;
|
2015-11-23 03:04:46 +00:00
|
|
|
bool (*save)(int fd, const uint8_t * outbuf, ssize_t outmax);
|
|
|
|
bool (*load)(int fd, uint8_t * inbuf, ssize_t inmax);
|
|
|
|
} StateHelper_s;
|
|
|
|
|
|
|
|
// save current emulator state
|
2017-06-30 05:42:28 +00:00
|
|
|
bool emulator_saveState(int fdState);
|
2015-11-23 03:04:46 +00:00
|
|
|
|
2017-06-30 05:42:28 +00:00
|
|
|
// load emulator state from save file descriptor
|
|
|
|
bool emulator_loadState(int fdState, int fdA, int fdB);
|
2017-05-21 21:58:55 +00:00
|
|
|
|
2017-06-30 05:42:28 +00:00
|
|
|
// extract path(s) and readonly status(es) from save state file into json
|
|
|
|
bool emulator_stateExtractDiskPaths(int fdState, JSON_ref json);
|
2015-11-23 03:04:46 +00:00
|
|
|
|
2015-09-26 22:20:54 +00:00
|
|
|
//
|
|
|
|
// Crash handling ...
|
|
|
|
//
|
|
|
|
|
|
|
|
typedef struct CrashHandler_s {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize crash handler (if available)
|
|
|
|
*/
|
|
|
|
void (*init)(const char *dumpDir);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shutdown crash handler (if available)
|
|
|
|
*/
|
|
|
|
void (*shutdown)(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Processes a crash dump (assuming this is a non-crashing contest).
|
|
|
|
* Returns success value. On failure, the outputFile may contain the reason processing failed
|
|
|
|
*/
|
|
|
|
bool (*processCrash)(const char *crash, const char *symbolsPath, const FILE *outputFile);
|
|
|
|
|
|
|
|
} CrashHandler_s;
|
|
|
|
|
|
|
|
extern CrashHandler_s *crashHandler;
|
2015-09-19 18:47:36 +00:00
|
|
|
|
2013-06-11 07:08:15 +00:00
|
|
|
#endif
|