ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/AmigaOS/main_amiga.cpp
(Generate patch)

Comparing BasiliskII/src/AmigaOS/main_amiga.cpp (file contents):
Revision 1.15 by cebix, 2001-02-02T20:52:57Z vs.
Revision 1.23 by cebix, 2002-09-01T12:01:46Z

# Line 26 | Line 26
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"
# Line 158 | Line 162 | int main(int argc, char **argv)
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(GetString(STR_NO_GADTOOLS_LIB_ERR));
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(GetString(STR_NO_IFFPARSE_LIB_ERR));
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(GetString(STR_NO_ASL_LIB_ERR));
191 >                ErrorAlert(STR_NO_ASL_LIB_ERR);
192 >                QuitEmulator();
193 >        }
194 >
195 >        if (FindTask((UBYTE *) "« Enforcer »")) {
196 >                ErrorAlert(STR_ENFORCER_RUNNING_ERR);
197                  QuitEmulator();
198          }
199  
200          // These two can fail (the respective gfx support won't be available, then)
201 <        P96Base = OpenLibrary((UBYTE *)"Picasso96API.library", 2);
202 <        CyberGfxBase = OpenLibrary((UBYTE *)"cybergraphics.library", 2);
201 >        P96Base = OpenLibrary((UBYTE *) "Picasso96API.library", 2);
202 >        CyberGfxBase = OpenLibrary((UBYTE *) "cybergraphics.library", 2);
203  
204          // Read preferences
205          PrefsInit(argc, argv);
# Line 201 | Line 210 | int main(int argc, char **argv)
210                  ahi_io = (struct AHIRequest *)CreateIORequest(ahi_port, sizeof(struct AHIRequest));
211                  if (ahi_io) {
212                          ahi_io->ahir_Version = 2;
213 <                        if (OpenDevice((UBYTE *)AHINAME, AHI_NO_UNIT, (struct IORequest *)ahi_io, 0) == 0) {
213 >                        if (OpenDevice((UBYTE *) AHINAME, AHI_NO_UNIT, (struct IORequest *)ahi_io, 0) == 0) {
214                                  AHIBase = (struct Library *)ahi_io->ahir_Std.io_Device;
215                          }
216                  }
# Line 216 | Line 225 | int main(int argc, char **argv)
225                          QuitEmulator();
226  
227          // Check start of Chip memory (because we need access to 0x0000..0x2000)
228 <        if ((uint32)FindName(&SysBase->MemList, (UBYTE *)"chip memory") < 0x2000) {
229 <                ErrorAlert(GetString(STR_NO_PREPARE_EMUL_ERR));
228 >        if ((uint32)FindName(&SysBase->MemList, (UBYTE *) "chip memory") < 0x2000) {
229 >                ErrorAlert(STR_NO_PREPARE_EMUL_ERR);
230                  QuitEmulator();
231          }
232  
233          // Open timer.device
234          timereq = (struct timerequest *)AllocVec(sizeof(timerequest), MEMF_PUBLIC | MEMF_CLEAR);
235          if (timereq == NULL) {
236 <                ErrorAlert(GetString(STR_NO_MEM_ERR));
236 >                ErrorAlert(STR_NO_MEM_ERR);
237                  QuitEmulator();
238          }
239 <        if (OpenDevice((UBYTE *)TIMERNAME, UNIT_MICROHZ, (struct IORequest *)timereq, 0)) {
240 <                ErrorAlert(GetString(STR_NO_TIMER_DEV_ERR));
239 >        if (OpenDevice((UBYTE *) TIMERNAME, UNIT_MICROHZ, (struct IORequest *)timereq, 0)) {
240 >                ErrorAlert(STR_NO_TIMER_DEV_ERR);
241                  QuitEmulator();
242          }
243          TimerBase = (struct Library *)timereq->tr_node.io_Device;
# Line 236 | Line 245 | int main(int argc, char **argv)
245          // Allocate scratch memory
246          ScratchMem = (uint8 *)AllocMem(SCRATCH_MEM_SIZE, MEMF_PUBLIC);
247          if (ScratchMem == NULL) {
248 <                ErrorAlert(GetString(STR_NO_MEM_ERR));
248 >                ErrorAlert(STR_NO_MEM_ERR);
249                  QuitEmulator();
250          }
251          ScratchMem += SCRATCH_MEM_SIZE/2;       // ScratchMem points to middle of block
# Line 259 | Line 268 | int main(int argc, char **argv)
268                          QuitEmulator();
269  
270                  RAMSize = newRAMSize;
271 <                RAMBaseHost = (uint8 *)AllocVec(RAMSize + 0x100000, MEMF_PUBLIC);
271 >                RAMBaseHost = (uint8 *)AllocVec(RAMSize - 0x100000, MEMF_PUBLIC);
272                  if (RAMBaseHost == NULL) {
273 <                        ErrorAlert(GetString(STR_NO_MEM_ERR));
273 >                        ErrorAlert(STR_NO_MEM_ERR);
274                          QuitEmulator();
275                  }
276          }
# Line 276 | Line 285 | int main(int argc, char **argv)
285  
286          // Load Mac ROM
287          BPTR rom_fh = Open(rom_path ? (char *)rom_path : (char *)ROM_FILE_NAME, MODE_OLDFILE);
288 <        if (rom_fh == NULL) {
289 <                ErrorAlert(GetString(STR_NO_ROM_FILE_ERR));
288 >        if (rom_fh == 0) {
289 >                ErrorAlert(STR_NO_ROM_FILE_ERR);
290                  QuitEmulator();
291          }
292          printf(GetString(STR_READING_ROM_FILE));
293          Seek(rom_fh, 0, OFFSET_END);
294          ROMSize = Seek(rom_fh, 0, OFFSET_CURRENT);
295          if (ROMSize != 512*1024 && ROMSize != 1024*1024) {
296 <                ErrorAlert(GetString(STR_ROM_SIZE_ERR));
296 >                ErrorAlert(STR_ROM_SIZE_ERR);
297                  Close(rom_fh);
298                  QuitEmulator();
299          }
300          Seek(rom_fh, 0, OFFSET_BEGINNING);
301          if (Read(rom_fh, ROMBaseHost, ROMSize) != ROMSize) {
302 <                ErrorAlert(GetString(STR_ROM_FILE_READ_ERR));
302 >                ErrorAlert(STR_ROM_FILE_READ_ERR);
303                  Close(rom_fh);
304                  QuitEmulator();
305          }
# Line 312 | Line 321 | int main(int argc, char **argv)
321          if (CPUIs68060)
322                  DisableSuperBypass();
323  
324 +        memset((UBYTE *) 8, 0, 0x2000-8);
325 +
326          // Install trap handler
327          EmulatedSR = 0x2700;
328          OldTrapHandler = MainTask->tc_TrapCode;
# Line 472 | Line 483 | void FlushCodeCache(void *start, uint32
483  
484  
485   /*
486 + *  Mutexes
487 + */
488 +
489 + struct B2_mutex {
490 +        int dummy;      //!!
491 + };
492 +
493 + B2_mutex *B2_create_mutex(void)
494 + {
495 +        return new B2_mutex;
496 + }
497 +
498 + void B2_lock_mutex(B2_mutex *mutex)
499 + {
500 + }
501 +
502 + void B2_unlock_mutex(B2_mutex *mutex)
503 + {
504 + }
505 +
506 + void B2_delete_mutex(B2_mutex *mutex)
507 + {
508 +        delete mutex;
509 + }
510 +
511 +
512 + /*
513   *  Interrupt flags (must be handled atomically!)
514   */
515  
# Line 514 | Line 552 | static __saveds void tick_func(void)
552          if (timer_port) {
553                  timer_io = (struct timerequest *)CreateIORequest(timer_port, sizeof(struct timerequest));
554                  if (timer_io) {
555 <                        if (!OpenDevice((UBYTE *)TIMERNAME, UNIT_MICROHZ, (struct IORequest *)timer_io, 0)) {
555 >                        if (!OpenDevice((UBYTE *) TIMERNAME, UNIT_MICROHZ, (struct IORequest *)timer_io, 0)) {
556                                  timer_mask = 1 << timer_port->mp_SigBit;
557                                  timer_io->tr_node.io_Command = TR_ADDREQUEST;
558                                  timer_io->tr_time.tv_secs = 0;
# Line 571 | Line 609 | static __saveds void tick_func(void)
609  
610   static __saveds void xpram_func(void)
611   {
612 <        uint8 last_xpram[256];
613 <        memcpy(last_xpram, XPRAM, 256);
612 >        uint8 last_xpram[XPRAM_SIZE];
613 >        memcpy(last_xpram, XPRAM, XPRAM_SIZE);
614  
615          while (xpram_proc_active) {
616                  for (int i=0; i<60 && xpram_proc_active; i++)
617                          Delay(50);              // Only wait 1 second so we quit promptly when xpram_proc_active becomes false
618 <                if (memcmp(last_xpram, XPRAM, 256)) {
619 <                        memcpy(last_xpram, XPRAM, 256);
618 >                if (memcmp(last_xpram, XPRAM, XPRAM_SIZE)) {
619 >                        memcpy(last_xpram, XPRAM, XPRAM_SIZE);
620                          SaveXPRAM();
621                  }
622          }
# Line 660 | Line 698 | struct trap_regs {     // This must match th
698  
699   void __saveds IllInstrHandler(trap_regs *r)
700   {
701 + //      D(bug("IllInstrHandler/%ld\n", __LINE__));
702 +
703          uint16 opcode = *(uint16 *)(r->pc);
704          if ((opcode & 0xff00) != 0x7100) {
705                  printf("Illegal Instruction %04x at %08lx\n", *(uint16 *)(r->pc), r->pc);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines