56 |
|
#include "debug.h" |
57 |
|
|
58 |
|
|
59 |
+ |
// Our minimum stack requirement |
60 |
+ |
unsigned long __stack = 0x4000; |
61 |
+ |
|
62 |
+ |
|
63 |
|
// Constants |
64 |
|
static const char ROM_FILE_NAME[] = "ROM"; |
65 |
< |
static const char __ver[] = "$VER: " VERSION_STRING " " __AMIGADATE__; |
65 |
> |
static const char __ver[] = "$VER: " VERSION_STRING " " __DATE__; |
66 |
|
static const int SCRATCH_MEM_SIZE = 65536; |
67 |
|
|
68 |
|
|
84 |
|
|
85 |
|
// Global variables |
86 |
|
extern ExecBase *SysBase; |
87 |
+ |
struct Library *GfxBase = NULL; |
88 |
+ |
struct IntuitionBase *IntuitionBase = NULL; |
89 |
|
struct Library *GadToolsBase = NULL; |
90 |
+ |
struct Library *IFFParseBase = NULL; |
91 |
|
struct Library *AslBase = NULL; |
92 |
|
struct Library *P96Base = NULL; |
93 |
|
struct Library *TimerBase = NULL; |
113 |
|
static StackSwapStruct stack_swap; |
114 |
|
|
115 |
|
|
109 |
– |
// Prototypes |
110 |
– |
static void jump_to_rom(void); |
111 |
– |
static void tick_func(void); |
112 |
– |
|
113 |
– |
|
116 |
|
// Assembly functions |
117 |
|
struct trap_regs; |
118 |
|
extern "C" void AtomicAnd(uint32 *p, uint32 val); |
122 |
|
extern "C" void ExceptionHandlerAsm(void); |
123 |
|
extern "C" void IllInstrHandler(trap_regs *regs); |
124 |
|
extern "C" void PrivViolHandler(trap_regs *regs); |
125 |
+ |
extern "C" void quit_emulator(void); |
126 |
|
uint16 EmulatedSR; // Emulated SR (supervisor bit and interrupt mask) |
127 |
|
|
128 |
|
|
129 |
+ |
// Prototypes |
130 |
+ |
static void jump_to_rom(void); |
131 |
+ |
static void tick_func(void); |
132 |
+ |
|
133 |
+ |
|
134 |
|
/* |
135 |
|
* Main program |
136 |
|
*/ |
149 |
|
printf(GetString(STR_ABOUT_TEXT1), VERSION_MAJOR, VERSION_MINOR); |
150 |
|
printf(" %s\n", GetString(STR_ABOUT_TEXT2)); |
151 |
|
|
144 |
– |
// Read preferences |
145 |
– |
PrefsInit(); |
146 |
– |
|
152 |
|
// Open libraries |
153 |
+ |
GfxBase = OpenLibrary((UBYTE *)"graphics.library", 39); |
154 |
+ |
if (GfxBase == NULL) { |
155 |
+ |
printf("Cannot open graphics.library V39.\n"); |
156 |
+ |
exit(1); |
157 |
+ |
} |
158 |
+ |
IntuitionBase = (struct IntuitionBase *)OpenLibrary((UBYTE *)"intuition.library", 39); |
159 |
+ |
if (IntuitionBase == NULL) { |
160 |
+ |
printf("Cannot open intuition.library V39.\n"); |
161 |
+ |
CloseLibrary(GfxBase); |
162 |
+ |
exit(1); |
163 |
+ |
} |
164 |
|
DiskBase = (struct Library *)OpenResource((UBYTE *)"disk.resource"); |
165 |
|
if (DiskBase == NULL) |
166 |
|
QuitEmulator(); |
169 |
|
ErrorAlert(GetString(STR_NO_GADTOOLS_LIB_ERR)); |
170 |
|
QuitEmulator(); |
171 |
|
} |
172 |
+ |
IFFParseBase = OpenLibrary((UBYTE *)"iffparse.library", 39); |
173 |
+ |
if (IFFParseBase == NULL) { |
174 |
+ |
ErrorAlert(GetString(STR_NO_IFFPARSE_LIB_ERR)); |
175 |
+ |
QuitEmulator(); |
176 |
+ |
} |
177 |
|
AslBase = OpenLibrary((UBYTE *)"asl.library", 36); |
178 |
|
if (AslBase == NULL) { |
179 |
|
ErrorAlert(GetString(STR_NO_ASL_LIB_ERR)); |
181 |
|
} |
182 |
|
P96Base = OpenLibrary((UBYTE *)"Picasso96API.library", 2); |
183 |
|
|
184 |
+ |
// Read preferences |
185 |
+ |
PrefsInit(); |
186 |
+ |
|
187 |
|
// Open AHI |
188 |
|
ahi_port = CreateMsgPort(); |
189 |
|
if (ahi_port) { |
252 |
|
const char *rom_path = PrefsFindString("rom"); |
253 |
|
|
254 |
|
// Load Mac ROM |
255 |
< |
BPTR rom_fh = Open(rom_path ? (char *)rom_path : ROM_FILE_NAME, MODE_OLDFILE); |
255 |
> |
BPTR rom_fh = Open(rom_path ? (char *)rom_path : (char *)ROM_FILE_NAME, MODE_OLDFILE); |
256 |
|
if (rom_fh == NULL) { |
257 |
|
ErrorAlert(GetString(STR_NO_ROM_FILE_ERR)); |
258 |
|
QuitEmulator(); |
299 |
|
|
300 |
|
// Start 60Hz process |
301 |
|
tick_proc = CreateNewProcTags( |
302 |
< |
NP_Entry, tick_func, |
303 |
< |
NP_Name, "Basilisk II 60Hz", |
302 |
> |
NP_Entry, (ULONG)tick_func, |
303 |
> |
NP_Name, (ULONG)"Basilisk II 60Hz", |
304 |
|
NP_Priority, 5, |
305 |
|
TAG_END |
306 |
|
); |
334 |
|
* Quit emulator (__saveds because it might be called from an exception) |
335 |
|
*/ |
336 |
|
|
337 |
< |
void __saveds QuitEmulator(void) |
337 |
> |
// Assembly entry point |
338 |
> |
void __saveds quit_emulator(void) |
339 |
> |
{ |
340 |
> |
QuitEmulator(); |
341 |
> |
} |
342 |
> |
|
343 |
> |
void QuitEmulator(void) |
344 |
|
{ |
345 |
|
// Restore stack |
346 |
|
if (stack_swapped) { |
401 |
|
CloseLibrary(P96Base); |
402 |
|
if (AslBase) |
403 |
|
CloseLibrary(AslBase); |
404 |
+ |
if (IFFParseBase) |
405 |
+ |
CloseLibrary(IFFParseBase); |
406 |
|
if (GadToolsBase) |
407 |
|
CloseLibrary(GadToolsBase); |
408 |
+ |
if (IntuitionBase) |
409 |
+ |
CloseLibrary((struct Library *)IntuitionBase); |
410 |
+ |
if (GfxBase) |
411 |
+ |
CloseLibrary(GfxBase); |
412 |
|
|
413 |
|
exit(0); |
414 |
|
} |
528 |
|
req.es_Title = (UBYTE *)GetString(STR_ERROR_ALERT_TITLE); |
529 |
|
req.es_TextFormat = (UBYTE *)GetString(STR_GUI_ERROR_PREFIX); |
530 |
|
req.es_GadgetFormat = (UBYTE *)GetString(STR_QUIT_BUTTON); |
531 |
< |
EasyRequest(NULL, &req, NULL, text); |
531 |
> |
EasyRequest(NULL, &req, NULL, (ULONG)text); |
532 |
|
} |
533 |
|
|
534 |
|
|
548 |
|
req.es_Title = (UBYTE *)GetString(STR_WARNING_ALERT_TITLE); |
549 |
|
req.es_TextFormat = (UBYTE *)GetString(STR_GUI_WARNING_PREFIX); |
550 |
|
req.es_GadgetFormat = (UBYTE *)GetString(STR_OK_BUTTON); |
551 |
< |
EasyRequest(NULL, &req, NULL, text); |
551 |
> |
EasyRequest(NULL, &req, NULL, (ULONG)text); |
552 |
|
} |
553 |
|
|
554 |
|
|
566 |
|
req.es_Title = (UBYTE *)GetString(STR_WARNING_ALERT_TITLE); |
567 |
|
req.es_TextFormat = (UBYTE *)GetString(STR_GUI_WARNING_PREFIX); |
568 |
|
req.es_GadgetFormat = (UBYTE *)str; |
569 |
< |
return EasyRequest(NULL, &req, NULL, text); |
569 |
> |
return EasyRequest(NULL, &req, NULL, (ULONG)text); |
570 |
|
} |
571 |
|
|
572 |
|
|