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 *CyberGfxBase = NULL; |
95 |
|
struct Library *TimerBase = NULL; |
96 |
|
struct Library *AHIBase = NULL; |
97 |
|
struct Library *DiskBase = NULL; |
115 |
|
static StackSwapStruct stack_swap; |
116 |
|
|
117 |
|
|
109 |
– |
// Prototypes |
110 |
– |
static void jump_to_rom(void); |
111 |
– |
static void tick_func(void); |
112 |
– |
|
113 |
– |
|
118 |
|
// Assembly functions |
119 |
|
struct trap_regs; |
120 |
|
extern "C" void AtomicAnd(uint32 *p, uint32 val); |
124 |
|
extern "C" void ExceptionHandlerAsm(void); |
125 |
|
extern "C" void IllInstrHandler(trap_regs *regs); |
126 |
|
extern "C" void PrivViolHandler(trap_regs *regs); |
127 |
+ |
extern "C" void quit_emulator(void); |
128 |
|
uint16 EmulatedSR; // Emulated SR (supervisor bit and interrupt mask) |
129 |
|
|
130 |
|
|
131 |
+ |
// Prototypes |
132 |
+ |
static void jump_to_rom(void); |
133 |
+ |
static void tick_func(void); |
134 |
+ |
|
135 |
+ |
|
136 |
|
/* |
137 |
|
* Main program |
138 |
|
*/ |
151 |
|
printf(GetString(STR_ABOUT_TEXT1), VERSION_MAJOR, VERSION_MINOR); |
152 |
|
printf(" %s\n", GetString(STR_ABOUT_TEXT2)); |
153 |
|
|
144 |
– |
// Read preferences |
145 |
– |
PrefsInit(); |
146 |
– |
|
154 |
|
// Open libraries |
155 |
+ |
GfxBase = OpenLibrary((UBYTE *)"graphics.library", 39); |
156 |
+ |
if (GfxBase == NULL) { |
157 |
+ |
printf("Cannot open graphics.library V39.\n"); |
158 |
+ |
exit(1); |
159 |
+ |
} |
160 |
+ |
IntuitionBase = (struct IntuitionBase *)OpenLibrary((UBYTE *)"intuition.library", 39); |
161 |
+ |
if (IntuitionBase == NULL) { |
162 |
+ |
printf("Cannot open intuition.library V39.\n"); |
163 |
+ |
CloseLibrary(GfxBase); |
164 |
+ |
exit(1); |
165 |
+ |
} |
166 |
|
DiskBase = (struct Library *)OpenResource((UBYTE *)"disk.resource"); |
167 |
|
if (DiskBase == NULL) |
168 |
|
QuitEmulator(); |
171 |
|
ErrorAlert(GetString(STR_NO_GADTOOLS_LIB_ERR)); |
172 |
|
QuitEmulator(); |
173 |
|
} |
174 |
+ |
IFFParseBase = OpenLibrary((UBYTE *)"iffparse.library", 39); |
175 |
+ |
if (IFFParseBase == NULL) { |
176 |
+ |
ErrorAlert(GetString(STR_NO_IFFPARSE_LIB_ERR)); |
177 |
+ |
QuitEmulator(); |
178 |
+ |
} |
179 |
|
AslBase = OpenLibrary((UBYTE *)"asl.library", 36); |
180 |
|
if (AslBase == NULL) { |
181 |
|
ErrorAlert(GetString(STR_NO_ASL_LIB_ERR)); |
182 |
|
QuitEmulator(); |
183 |
|
} |
184 |
+ |
|
185 |
+ |
// These two can fail (the respective gfx support won't be available, then) |
186 |
|
P96Base = OpenLibrary((UBYTE *)"Picasso96API.library", 2); |
187 |
+ |
CyberGfxBase = OpenLibrary((UBYTE *)"cybergraphics.library", 2); |
188 |
+ |
|
189 |
+ |
// Read preferences |
190 |
+ |
PrefsInit(); |
191 |
|
|
192 |
|
// Open AHI |
193 |
|
ahi_port = CreateMsgPort(); |
257 |
|
const char *rom_path = PrefsFindString("rom"); |
258 |
|
|
259 |
|
// Load Mac ROM |
260 |
< |
BPTR rom_fh = Open(rom_path ? (char *)rom_path : ROM_FILE_NAME, MODE_OLDFILE); |
260 |
> |
BPTR rom_fh = Open(rom_path ? (char *)rom_path : (char *)ROM_FILE_NAME, MODE_OLDFILE); |
261 |
|
if (rom_fh == NULL) { |
262 |
|
ErrorAlert(GetString(STR_NO_ROM_FILE_ERR)); |
263 |
|
QuitEmulator(); |
304 |
|
|
305 |
|
// Start 60Hz process |
306 |
|
tick_proc = CreateNewProcTags( |
307 |
< |
NP_Entry, tick_func, |
308 |
< |
NP_Name, "Basilisk II 60Hz", |
307 |
> |
NP_Entry, (ULONG)tick_func, |
308 |
> |
NP_Name, (ULONG)"Basilisk II 60Hz", |
309 |
|
NP_Priority, 5, |
310 |
|
TAG_END |
311 |
|
); |
339 |
|
* Quit emulator (__saveds because it might be called from an exception) |
340 |
|
*/ |
341 |
|
|
342 |
< |
void __saveds QuitEmulator(void) |
342 |
> |
// Assembly entry point |
343 |
> |
void __saveds quit_emulator(void) |
344 |
> |
{ |
345 |
> |
QuitEmulator(); |
346 |
> |
} |
347 |
> |
|
348 |
> |
void QuitEmulator(void) |
349 |
|
{ |
350 |
|
// Restore stack |
351 |
|
if (stack_swapped) { |
402 |
|
PrefsExit(); |
403 |
|
|
404 |
|
// Close libraries |
405 |
+ |
if (CyberGfxBase) |
406 |
+ |
CloseLibrary(CyberGfxBase); |
407 |
|
if (P96Base) |
408 |
|
CloseLibrary(P96Base); |
409 |
|
if (AslBase) |
410 |
|
CloseLibrary(AslBase); |
411 |
+ |
if (IFFParseBase) |
412 |
+ |
CloseLibrary(IFFParseBase); |
413 |
|
if (GadToolsBase) |
414 |
|
CloseLibrary(GadToolsBase); |
415 |
+ |
if (IntuitionBase) |
416 |
+ |
CloseLibrary((struct Library *)IntuitionBase); |
417 |
+ |
if (GfxBase) |
418 |
+ |
CloseLibrary(GfxBase); |
419 |
|
|
420 |
|
exit(0); |
421 |
|
} |
535 |
|
req.es_Title = (UBYTE *)GetString(STR_ERROR_ALERT_TITLE); |
536 |
|
req.es_TextFormat = (UBYTE *)GetString(STR_GUI_ERROR_PREFIX); |
537 |
|
req.es_GadgetFormat = (UBYTE *)GetString(STR_QUIT_BUTTON); |
538 |
< |
EasyRequest(NULL, &req, NULL, text); |
538 |
> |
EasyRequest(NULL, &req, NULL, (ULONG)text); |
539 |
|
} |
540 |
|
|
541 |
|
|
555 |
|
req.es_Title = (UBYTE *)GetString(STR_WARNING_ALERT_TITLE); |
556 |
|
req.es_TextFormat = (UBYTE *)GetString(STR_GUI_WARNING_PREFIX); |
557 |
|
req.es_GadgetFormat = (UBYTE *)GetString(STR_OK_BUTTON); |
558 |
< |
EasyRequest(NULL, &req, NULL, text); |
558 |
> |
EasyRequest(NULL, &req, NULL, (ULONG)text); |
559 |
|
} |
560 |
|
|
561 |
|
|
573 |
|
req.es_Title = (UBYTE *)GetString(STR_WARNING_ALERT_TITLE); |
574 |
|
req.es_TextFormat = (UBYTE *)GetString(STR_GUI_WARNING_PREFIX); |
575 |
|
req.es_GadgetFormat = (UBYTE *)str; |
576 |
< |
return EasyRequest(NULL, &req, NULL, text); |
576 |
> |
return EasyRequest(NULL, &req, NULL, (ULONG)text); |
577 |
|
} |
578 |
|
|
579 |
|
|