1 |
|
/* |
2 |
|
* main_amiga.cpp - Startup code for AmigaOS |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-2000 Christian Bauer |
4 |
> |
* Basilisk II (C) 1997-2002 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 |
174 |
|
QuitEmulator(); |
175 |
|
GadToolsBase = OpenLibrary((UBYTE *)"gadtools.library", 39); |
176 |
|
if (GadToolsBase == NULL) { |
177 |
< |
ErrorAlert(GetString(STR_NO_GADTOOLS_LIB_ERR)); |
177 |
> |
ErrorAlert(STR_NO_GADTOOLS_LIB_ERR); |
178 |
|
QuitEmulator(); |
179 |
|
} |
180 |
|
IFFParseBase = OpenLibrary((UBYTE *)"iffparse.library", 39); |
181 |
|
if (IFFParseBase == NULL) { |
182 |
< |
ErrorAlert(GetString(STR_NO_IFFPARSE_LIB_ERR)); |
182 |
> |
ErrorAlert(STR_NO_IFFPARSE_LIB_ERR); |
183 |
|
QuitEmulator(); |
184 |
|
} |
185 |
|
AslBase = OpenLibrary((UBYTE *)"asl.library", 36); |
186 |
|
if (AslBase == NULL) { |
187 |
< |
ErrorAlert(GetString(STR_NO_ASL_LIB_ERR)); |
187 |
> |
ErrorAlert(STR_NO_ASL_LIB_ERR); |
188 |
|
QuitEmulator(); |
189 |
|
} |
190 |
|
|
191 |
+ |
if (FindTask((UBYTE *) "« Enforcer »")) |
192 |
+ |
{ |
193 |
+ |
ErrorAlert(STR_ENFORCER_RUNNING_ERR); |
194 |
+ |
QuitEmulator(); |
195 |
+ |
} |
196 |
+ |
|
197 |
|
// These two can fail (the respective gfx support won't be available, then) |
198 |
|
P96Base = OpenLibrary((UBYTE *)"Picasso96API.library", 2); |
199 |
|
CyberGfxBase = OpenLibrary((UBYTE *)"cybergraphics.library", 2); |
223 |
|
|
224 |
|
// Check start of Chip memory (because we need access to 0x0000..0x2000) |
225 |
|
if ((uint32)FindName(&SysBase->MemList, (UBYTE *)"chip memory") < 0x2000) { |
226 |
< |
ErrorAlert(GetString(STR_NO_PREPARE_EMUL_ERR)); |
226 |
> |
ErrorAlert(STR_NO_PREPARE_EMUL_ERR); |
227 |
|
QuitEmulator(); |
228 |
|
} |
229 |
|
|
230 |
|
// Open timer.device |
231 |
|
timereq = (struct timerequest *)AllocVec(sizeof(timerequest), MEMF_PUBLIC | MEMF_CLEAR); |
232 |
|
if (timereq == NULL) { |
233 |
< |
ErrorAlert(GetString(STR_NO_MEM_ERR)); |
233 |
> |
ErrorAlert(STR_NO_MEM_ERR); |
234 |
|
QuitEmulator(); |
235 |
|
} |
236 |
|
if (OpenDevice((UBYTE *)TIMERNAME, UNIT_MICROHZ, (struct IORequest *)timereq, 0)) { |
237 |
< |
ErrorAlert(GetString(STR_NO_TIMER_DEV_ERR)); |
237 |
> |
ErrorAlert(STR_NO_TIMER_DEV_ERR); |
238 |
|
QuitEmulator(); |
239 |
|
} |
240 |
|
TimerBase = (struct Library *)timereq->tr_node.io_Device; |
242 |
|
// Allocate scratch memory |
243 |
|
ScratchMem = (uint8 *)AllocMem(SCRATCH_MEM_SIZE, MEMF_PUBLIC); |
244 |
|
if (ScratchMem == NULL) { |
245 |
< |
ErrorAlert(GetString(STR_NO_MEM_ERR)); |
245 |
> |
ErrorAlert(STR_NO_MEM_ERR); |
246 |
|
QuitEmulator(); |
247 |
|
} |
248 |
|
ScratchMem += SCRATCH_MEM_SIZE/2; // ScratchMem points to middle of block |
267 |
|
RAMSize = newRAMSize; |
268 |
|
RAMBaseHost = (uint8 *)AllocVec(RAMSize + 0x100000, MEMF_PUBLIC); |
269 |
|
if (RAMBaseHost == NULL) { |
270 |
< |
ErrorAlert(GetString(STR_NO_MEM_ERR)); |
270 |
> |
ErrorAlert(STR_NO_MEM_ERR); |
271 |
|
QuitEmulator(); |
272 |
|
} |
273 |
|
} |
282 |
|
|
283 |
|
// Load Mac ROM |
284 |
|
BPTR rom_fh = Open(rom_path ? (char *)rom_path : (char *)ROM_FILE_NAME, MODE_OLDFILE); |
285 |
< |
if (rom_fh == NULL) { |
286 |
< |
ErrorAlert(GetString(STR_NO_ROM_FILE_ERR)); |
285 |
> |
if (rom_fh == 0) { |
286 |
> |
ErrorAlert(STR_NO_ROM_FILE_ERR); |
287 |
|
QuitEmulator(); |
288 |
|
} |
289 |
|
printf(GetString(STR_READING_ROM_FILE)); |
290 |
|
Seek(rom_fh, 0, OFFSET_END); |
291 |
|
ROMSize = Seek(rom_fh, 0, OFFSET_CURRENT); |
292 |
|
if (ROMSize != 512*1024 && ROMSize != 1024*1024) { |
293 |
< |
ErrorAlert(GetString(STR_ROM_SIZE_ERR)); |
293 |
> |
ErrorAlert(STR_ROM_SIZE_ERR); |
294 |
|
Close(rom_fh); |
295 |
|
QuitEmulator(); |
296 |
|
} |
297 |
|
Seek(rom_fh, 0, OFFSET_BEGINNING); |
298 |
|
if (Read(rom_fh, ROMBaseHost, ROMSize) != ROMSize) { |
299 |
< |
ErrorAlert(GetString(STR_ROM_FILE_READ_ERR)); |
299 |
> |
ErrorAlert(STR_ROM_FILE_READ_ERR); |
300 |
|
Close(rom_fh); |
301 |
|
QuitEmulator(); |
302 |
|
} |
478 |
|
|
479 |
|
|
480 |
|
/* |
481 |
+ |
* Mutexes |
482 |
+ |
*/ |
483 |
+ |
|
484 |
+ |
struct B2_mutex { |
485 |
+ |
int dummy; //!! |
486 |
+ |
}; |
487 |
+ |
|
488 |
+ |
B2_mutex *B2_create_mutex(void) |
489 |
+ |
{ |
490 |
+ |
return new B2_mutex; |
491 |
+ |
} |
492 |
+ |
|
493 |
+ |
void B2_lock_mutex(B2_mutex *mutex) |
494 |
+ |
{ |
495 |
+ |
} |
496 |
+ |
|
497 |
+ |
void B2_unlock_mutex(B2_mutex *mutex) |
498 |
+ |
{ |
499 |
+ |
} |
500 |
+ |
|
501 |
+ |
void B2_delete_mutex(B2_mutex *mutex) |
502 |
+ |
{ |
503 |
+ |
delete mutex; |
504 |
+ |
} |
505 |
+ |
|
506 |
+ |
|
507 |
+ |
/* |
508 |
|
* Interrupt flags (must be handled atomically!) |
509 |
|
*/ |
510 |
|
|
604 |
|
|
605 |
|
static __saveds void xpram_func(void) |
606 |
|
{ |
607 |
< |
uint8 last_xpram[256]; |
608 |
< |
memcpy(last_xpram, XPRAM, 256); |
607 |
> |
uint8 last_xpram[XPRAM_SIZE]; |
608 |
> |
memcpy(last_xpram, XPRAM, XPRAM_SIZE); |
609 |
|
|
610 |
|
while (xpram_proc_active) { |
611 |
|
for (int i=0; i<60 && xpram_proc_active; i++) |
612 |
|
Delay(50); // Only wait 1 second so we quit promptly when xpram_proc_active becomes false |
613 |
< |
if (memcmp(last_xpram, XPRAM, 256)) { |
614 |
< |
memcpy(last_xpram, XPRAM, 256); |
613 |
> |
if (memcmp(last_xpram, XPRAM, XPRAM_SIZE)) { |
614 |
> |
memcpy(last_xpram, XPRAM, XPRAM_SIZE); |
615 |
|
SaveXPRAM(); |
616 |
|
} |
617 |
|
} |