26 |
|
#include <intuition/intuition.h> |
27 |
|
#include <devices/timer.h> |
28 |
|
#include <devices/ahi.h> |
29 |
+ |
#define __USE_SYSBASE |
30 |
|
#include <proto/exec.h> |
31 |
|
#include <proto/dos.h> |
32 |
|
#include <proto/intuition.h> |
33 |
+ |
#include <inline/exec.h> |
34 |
+ |
#include <inline/dos.h> |
35 |
+ |
#include <inline/intuition.h> |
36 |
|
|
37 |
|
#include "sysdeps.h" |
38 |
|
#include "cpu_emulation.h" |
162 |
|
printf(" %s\n", GetString(STR_ABOUT_TEXT2)); |
163 |
|
|
164 |
|
// Open libraries |
165 |
< |
GfxBase = OpenLibrary((UBYTE *)"graphics.library", 39); |
165 |
> |
GfxBase = OpenLibrary((UBYTE *) "graphics.library", 39); |
166 |
|
if (GfxBase == NULL) { |
167 |
|
printf("Cannot open graphics.library V39.\n"); |
168 |
|
exit(1); |
169 |
|
} |
170 |
< |
IntuitionBase = (struct IntuitionBase *)OpenLibrary((UBYTE *)"intuition.library", 39); |
170 |
> |
IntuitionBase = (struct IntuitionBase *)OpenLibrary((UBYTE *) "intuition.library", 39); |
171 |
|
if (IntuitionBase == NULL) { |
172 |
|
printf("Cannot open intuition.library V39.\n"); |
173 |
|
CloseLibrary(GfxBase); |
174 |
|
exit(1); |
175 |
|
} |
176 |
< |
DiskBase = (struct Library *)OpenResource((UBYTE *)"disk.resource"); |
176 |
> |
DiskBase = (struct Library *)OpenResource((UBYTE *) "disk.resource"); |
177 |
|
if (DiskBase == NULL) |
178 |
|
QuitEmulator(); |
179 |
< |
GadToolsBase = OpenLibrary((UBYTE *)"gadtools.library", 39); |
179 |
> |
GadToolsBase = OpenLibrary((UBYTE *) "gadtools.library", 39); |
180 |
|
if (GadToolsBase == NULL) { |
181 |
|
ErrorAlert(STR_NO_GADTOOLS_LIB_ERR); |
182 |
|
QuitEmulator(); |
183 |
|
} |
184 |
< |
IFFParseBase = OpenLibrary((UBYTE *)"iffparse.library", 39); |
184 |
> |
IFFParseBase = OpenLibrary((UBYTE *) "iffparse.library", 39); |
185 |
|
if (IFFParseBase == NULL) { |
186 |
|
ErrorAlert(STR_NO_IFFPARSE_LIB_ERR); |
187 |
|
QuitEmulator(); |
188 |
|
} |
189 |
< |
AslBase = OpenLibrary((UBYTE *)"asl.library", 36); |
189 |
> |
AslBase = OpenLibrary((UBYTE *) "asl.library", 36); |
190 |
|
if (AslBase == NULL) { |
191 |
|
ErrorAlert(STR_NO_ASL_LIB_ERR); |
192 |
|
QuitEmulator(); |
193 |
|
} |
194 |
|
|
195 |
+ |
if (FindTask((UBYTE *) "« Enforcer »")) |
196 |
+ |
{ |
197 |
+ |
ErrorAlert(STR_ENFORCER_RUNNING_ERR); |
198 |
+ |
QuitEmulator(); |
199 |
+ |
} |
200 |
+ |
|
201 |
|
// These two can fail (the respective gfx support won't be available, then) |
202 |
< |
P96Base = OpenLibrary((UBYTE *)"Picasso96API.library", 2); |
203 |
< |
CyberGfxBase = OpenLibrary((UBYTE *)"cybergraphics.library", 2); |
202 |
> |
P96Base = OpenLibrary((UBYTE *) "Picasso96API.library", 2); |
203 |
> |
CyberGfxBase = OpenLibrary((UBYTE *) "cybergraphics.library", 2); |
204 |
|
|
205 |
|
// Read preferences |
206 |
|
PrefsInit(argc, argv); |
211 |
|
ahi_io = (struct AHIRequest *)CreateIORequest(ahi_port, sizeof(struct AHIRequest)); |
212 |
|
if (ahi_io) { |
213 |
|
ahi_io->ahir_Version = 2; |
214 |
< |
if (OpenDevice((UBYTE *)AHINAME, AHI_NO_UNIT, (struct IORequest *)ahi_io, 0) == 0) { |
214 |
> |
if (OpenDevice((UBYTE *) AHINAME, AHI_NO_UNIT, (struct IORequest *)ahi_io, 0) == 0) { |
215 |
|
AHIBase = (struct Library *)ahi_io->ahir_Std.io_Device; |
216 |
|
} |
217 |
|
} |
226 |
|
QuitEmulator(); |
227 |
|
|
228 |
|
// Check start of Chip memory (because we need access to 0x0000..0x2000) |
229 |
< |
if ((uint32)FindName(&SysBase->MemList, (UBYTE *)"chip memory") < 0x2000) { |
229 |
> |
if ((uint32)FindName(&SysBase->MemList, (UBYTE *) "chip memory") < 0x2000) { |
230 |
|
ErrorAlert(STR_NO_PREPARE_EMUL_ERR); |
231 |
|
QuitEmulator(); |
232 |
|
} |
237 |
|
ErrorAlert(STR_NO_MEM_ERR); |
238 |
|
QuitEmulator(); |
239 |
|
} |
240 |
< |
if (OpenDevice((UBYTE *)TIMERNAME, UNIT_MICROHZ, (struct IORequest *)timereq, 0)) { |
240 |
> |
if (OpenDevice((UBYTE *) TIMERNAME, UNIT_MICROHZ, (struct IORequest *)timereq, 0)) { |
241 |
|
ErrorAlert(STR_NO_TIMER_DEV_ERR); |
242 |
|
QuitEmulator(); |
243 |
|
} |
269 |
|
QuitEmulator(); |
270 |
|
|
271 |
|
RAMSize = newRAMSize; |
272 |
< |
RAMBaseHost = (uint8 *)AllocVec(RAMSize + 0x100000, MEMF_PUBLIC); |
272 |
> |
RAMBaseHost = (uint8 *)AllocVec(RAMSize - 0x100000, MEMF_PUBLIC); |
273 |
|
if (RAMBaseHost == NULL) { |
274 |
|
ErrorAlert(STR_NO_MEM_ERR); |
275 |
|
QuitEmulator(); |
322 |
|
if (CPUIs68060) |
323 |
|
DisableSuperBypass(); |
324 |
|
|
325 |
+ |
memset((UBYTE *) 8, 0, 0x2000-8); |
326 |
+ |
|
327 |
|
// Install trap handler |
328 |
|
EmulatedSR = 0x2700; |
329 |
|
OldTrapHandler = MainTask->tc_TrapCode; |
484 |
|
|
485 |
|
|
486 |
|
/* |
487 |
+ |
* Mutexes |
488 |
+ |
*/ |
489 |
+ |
|
490 |
+ |
struct B2_mutex { |
491 |
+ |
int dummy; //!! |
492 |
+ |
}; |
493 |
+ |
|
494 |
+ |
B2_mutex *B2_create_mutex(void) |
495 |
+ |
{ |
496 |
+ |
return new B2_mutex; |
497 |
+ |
} |
498 |
+ |
|
499 |
+ |
void B2_lock_mutex(B2_mutex *mutex) |
500 |
+ |
{ |
501 |
+ |
} |
502 |
+ |
|
503 |
+ |
void B2_unlock_mutex(B2_mutex *mutex) |
504 |
+ |
{ |
505 |
+ |
} |
506 |
+ |
|
507 |
+ |
void B2_delete_mutex(B2_mutex *mutex) |
508 |
+ |
{ |
509 |
+ |
delete mutex; |
510 |
+ |
} |
511 |
+ |
|
512 |
+ |
|
513 |
+ |
/* |
514 |
|
* Interrupt flags (must be handled atomically!) |
515 |
|
*/ |
516 |
|
|
553 |
|
if (timer_port) { |
554 |
|
timer_io = (struct timerequest *)CreateIORequest(timer_port, sizeof(struct timerequest)); |
555 |
|
if (timer_io) { |
556 |
< |
if (!OpenDevice((UBYTE *)TIMERNAME, UNIT_MICROHZ, (struct IORequest *)timer_io, 0)) { |
556 |
> |
if (!OpenDevice((UBYTE *) TIMERNAME, UNIT_MICROHZ, (struct IORequest *)timer_io, 0)) { |
557 |
|
timer_mask = 1 << timer_port->mp_SigBit; |
558 |
|
timer_io->tr_node.io_Command = TR_ADDREQUEST; |
559 |
|
timer_io->tr_time.tv_secs = 0; |
610 |
|
|
611 |
|
static __saveds void xpram_func(void) |
612 |
|
{ |
613 |
< |
uint8 last_xpram[256]; |
614 |
< |
memcpy(last_xpram, XPRAM, 256); |
613 |
> |
uint8 last_xpram[XPRAM_SIZE]; |
614 |
> |
memcpy(last_xpram, XPRAM, XPRAM_SIZE); |
615 |
|
|
616 |
|
while (xpram_proc_active) { |
617 |
|
for (int i=0; i<60 && xpram_proc_active; i++) |
618 |
|
Delay(50); // Only wait 1 second so we quit promptly when xpram_proc_active becomes false |
619 |
< |
if (memcmp(last_xpram, XPRAM, 256)) { |
620 |
< |
memcpy(last_xpram, XPRAM, 256); |
619 |
> |
if (memcmp(last_xpram, XPRAM, XPRAM_SIZE)) { |
620 |
> |
memcpy(last_xpram, XPRAM, XPRAM_SIZE); |
621 |
|
SaveXPRAM(); |
622 |
|
} |
623 |
|
} |
699 |
|
|
700 |
|
void __saveds IllInstrHandler(trap_regs *r) |
701 |
|
{ |
702 |
+ |
// D(bug("IllInstrHandler/%ld\n", __LINE__)); |
703 |
+ |
|
704 |
|
uint16 opcode = *(uint16 *)(r->pc); |
705 |
|
if ((opcode & 0xff00) != 0x7100) { |
706 |
|
printf("Illegal Instruction %04x at %08lx\n", *(uint16 *)(r->pc), r->pc); |