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