1 |
|
/* |
2 |
|
* main_amiga.cpp - Startup code for AmigaOS |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-2000 Christian Bauer |
4 |
> |
* Basilisk II (C) 1997-2001 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 |
|
|
217 |
|
|
218 |
|
// Check start of Chip memory (because we need access to 0x0000..0x2000) |
219 |
|
if ((uint32)FindName(&SysBase->MemList, (UBYTE *)"chip memory") < 0x2000) { |
220 |
< |
ErrorAlert(GetString(STR_NO_PREPARE_EMUL_ERR)); |
220 |
> |
ErrorAlert(STR_NO_PREPARE_EMUL_ERR); |
221 |
|
QuitEmulator(); |
222 |
|
} |
223 |
|
|
224 |
|
// Open timer.device |
225 |
|
timereq = (struct timerequest *)AllocVec(sizeof(timerequest), MEMF_PUBLIC | MEMF_CLEAR); |
226 |
|
if (timereq == NULL) { |
227 |
< |
ErrorAlert(GetString(STR_NO_MEM_ERR)); |
227 |
> |
ErrorAlert(STR_NO_MEM_ERR); |
228 |
|
QuitEmulator(); |
229 |
|
} |
230 |
|
if (OpenDevice((UBYTE *)TIMERNAME, UNIT_MICROHZ, (struct IORequest *)timereq, 0)) { |
231 |
< |
ErrorAlert(GetString(STR_NO_TIMER_DEV_ERR)); |
231 |
> |
ErrorAlert(STR_NO_TIMER_DEV_ERR); |
232 |
|
QuitEmulator(); |
233 |
|
} |
234 |
|
TimerBase = (struct Library *)timereq->tr_node.io_Device; |
236 |
|
// Allocate scratch memory |
237 |
|
ScratchMem = (uint8 *)AllocMem(SCRATCH_MEM_SIZE, MEMF_PUBLIC); |
238 |
|
if (ScratchMem == NULL) { |
239 |
< |
ErrorAlert(GetString(STR_NO_MEM_ERR)); |
239 |
> |
ErrorAlert(STR_NO_MEM_ERR); |
240 |
|
QuitEmulator(); |
241 |
|
} |
242 |
|
ScratchMem += SCRATCH_MEM_SIZE/2; // ScratchMem points to middle of block |
261 |
|
RAMSize = newRAMSize; |
262 |
|
RAMBaseHost = (uint8 *)AllocVec(RAMSize + 0x100000, MEMF_PUBLIC); |
263 |
|
if (RAMBaseHost == NULL) { |
264 |
< |
ErrorAlert(GetString(STR_NO_MEM_ERR)); |
264 |
> |
ErrorAlert(STR_NO_MEM_ERR); |
265 |
|
QuitEmulator(); |
266 |
|
} |
267 |
|
} |
276 |
|
|
277 |
|
// Load Mac ROM |
278 |
|
BPTR rom_fh = Open(rom_path ? (char *)rom_path : (char *)ROM_FILE_NAME, MODE_OLDFILE); |
279 |
< |
if (rom_fh == NULL) { |
280 |
< |
ErrorAlert(GetString(STR_NO_ROM_FILE_ERR)); |
279 |
> |
if (rom_fh == 0) { |
280 |
> |
ErrorAlert(STR_NO_ROM_FILE_ERR); |
281 |
|
QuitEmulator(); |
282 |
|
} |
283 |
|
printf(GetString(STR_READING_ROM_FILE)); |
284 |
|
Seek(rom_fh, 0, OFFSET_END); |
285 |
|
ROMSize = Seek(rom_fh, 0, OFFSET_CURRENT); |
286 |
|
if (ROMSize != 512*1024 && ROMSize != 1024*1024) { |
287 |
< |
ErrorAlert(GetString(STR_ROM_SIZE_ERR)); |
287 |
> |
ErrorAlert(STR_ROM_SIZE_ERR); |
288 |
|
Close(rom_fh); |
289 |
|
QuitEmulator(); |
290 |
|
} |
291 |
|
Seek(rom_fh, 0, OFFSET_BEGINNING); |
292 |
|
if (Read(rom_fh, ROMBaseHost, ROMSize) != ROMSize) { |
293 |
< |
ErrorAlert(GetString(STR_ROM_FILE_READ_ERR)); |
293 |
> |
ErrorAlert(STR_ROM_FILE_READ_ERR); |
294 |
|
Close(rom_fh); |
295 |
|
QuitEmulator(); |
296 |
|
} |
472 |
|
|
473 |
|
|
474 |
|
/* |
475 |
+ |
* Mutexes |
476 |
+ |
*/ |
477 |
+ |
|
478 |
+ |
struct B2_mutex { |
479 |
+ |
int dummy; //!! |
480 |
+ |
}; |
481 |
+ |
|
482 |
+ |
B2_mutex *B2_create_mutex(void) |
483 |
+ |
{ |
484 |
+ |
return new B2_mutex; |
485 |
+ |
} |
486 |
+ |
|
487 |
+ |
void B2_lock_mutex(B2_mutex *mutex) |
488 |
+ |
{ |
489 |
+ |
} |
490 |
+ |
|
491 |
+ |
void B2_unlock_mutex(B2_mutex *mutex) |
492 |
+ |
{ |
493 |
+ |
} |
494 |
+ |
|
495 |
+ |
void B2_delete_mutex(B2_mutex *mutex) |
496 |
+ |
{ |
497 |
+ |
delete mutex; |
498 |
+ |
} |
499 |
+ |
|
500 |
+ |
|
501 |
+ |
/* |
502 |
|
* Interrupt flags (must be handled atomically!) |
503 |
|
*/ |
504 |
|
|
598 |
|
|
599 |
|
static __saveds void xpram_func(void) |
600 |
|
{ |
601 |
< |
uint8 last_xpram[256]; |
602 |
< |
memcpy(last_xpram, XPRAM, 256); |
601 |
> |
uint8 last_xpram[XPRAM_SIZE]; |
602 |
> |
memcpy(last_xpram, XPRAM, XPRAM_SIZE); |
603 |
|
|
604 |
|
while (xpram_proc_active) { |
605 |
|
for (int i=0; i<60 && xpram_proc_active; i++) |
606 |
|
Delay(50); // Only wait 1 second so we quit promptly when xpram_proc_active becomes false |
607 |
< |
if (memcmp(last_xpram, XPRAM, 256)) { |
608 |
< |
memcpy(last_xpram, XPRAM, 256); |
607 |
> |
if (memcmp(last_xpram, XPRAM, XPRAM_SIZE)) { |
608 |
> |
memcpy(last_xpram, XPRAM, XPRAM_SIZE); |
609 |
|
SaveXPRAM(); |
610 |
|
} |
611 |
|
} |