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

Comparing BasiliskII/src/emul_op.cpp (file contents):
Revision 1.2 by cebix, 1999-10-05T14:59:43Z vs.
Revision 1.26 by cebix, 2001-07-09T11:21:59Z

# Line 1 | Line 1
1   /*
2   *  emul_op.cpp - 68k opcodes for ROM patches
3   *
4 < *  Basilisk II (C) 1997-1999 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
# Line 39 | Line 39
39   #include "video.h"
40   #include "audio.h"
41   #include "ether.h"
42 + #include "extfs.h"
43   #include "emul_op.h"
44  
45 + #ifdef ENABLE_MON
46 + #include "mon.h"
47 + #endif
48 +
49   #define DEBUG 0
50   #include "debug.h"
51  
# Line 63 | Line 68 | void EmulOp(uint16 opcode, M68kRegisters
68                                     r->d[0], r->d[1], r->d[2], r->d[3], r->d[4], r->d[5], r->d[6], r->d[7],
69                                     r->a[0], r->a[1], r->a[2], r->a[3], r->a[4], r->a[5], r->a[6], r->a[7],
70                                     r->sr);
71 +                        VideoQuitFullScreen();
72 + #ifdef ENABLE_MON
73 +                        char *arg[4] = {"mon", "-m", "-r", NULL};
74 +                        mon(3, arg);
75 + #endif
76                          QuitEmulator();
77                          break;
78                  }
# Line 75 | Line 85 | void EmulOp(uint16 opcode, M68kRegisters
85                          D(bug("*** RESET ***\n"));
86                          TimerReset();
87                          EtherReset();
88 +                        AudioReset();
89  
90                          // Create BootGlobs at top of memory
91 <                        memset((void *)(RAMBaseHost + RAMSize - 4096), 0, 4096);
91 >                        Mac_memset(RAMBaseMac + RAMSize - 4096, 0, 4096);
92                          uint32 boot_globs = RAMBaseMac + RAMSize - 0x1c;
93                          WriteMacInt32(boot_globs + 0x00, RAMBaseMac);   // First RAM bank
94                          WriteMacInt32(boot_globs + 0x04, RAMSize);
# Line 186 | Line 197 | void EmulOp(uint16 opcode, M68kRegisters
197                          break;
198  
199                  case M68K_EMUL_OP_FIX_BOOTSTACK:        // Set boot stack to 3/4 of RAM (7.5)
189                        D(bug("Fix boot stack\n"));
200                          r->a[1] = RAMBaseMac + RAMSize * 3 / 4;
201 +                        D(bug("Fix boot stack %08x\n", r->a[1]));
202                          break;
203  
204                  case M68K_EMUL_OP_FIX_MEMSIZE: {        // Set correct logical and physical memory size
# Line 295 | Line 306 | void EmulOp(uint16 opcode, M68kRegisters
306                          break;
307  
308                  case M68K_EMUL_OP_VIDEO_OPEN:           // Video driver functions
309 <                        r->d[0] = VideoOpen(r->a[0], r->a[1]);
309 >                        r->d[0] = VideoDriverOpen(r->a[0], r->a[1]);
310                          break;
311  
312                  case M68K_EMUL_OP_VIDEO_CONTROL:
313 <                        r->d[0] = VideoControl(r->a[0], r->a[1]);
313 >                        r->d[0] = VideoDriverControl(r->a[0], r->a[1]);
314                          break;
315  
316                  case M68K_EMUL_OP_VIDEO_STATUS:
317 <                        r->d[0] = VideoStatus(r->a[0], r->a[1]);
317 >                        r->d[0] = VideoDriverStatus(r->a[0], r->a[1]);
318                          break;
319  
320                  case M68K_EMUL_OP_SERIAL_OPEN:          // Serial driver functions
# Line 338 | Line 349 | void EmulOp(uint16 opcode, M68kRegisters
349                          EtherReadPacket((uint8 **)&r->a[0], r->a[3], r->d[3], r->d[1]);
350                          break;
351  
352 +                case M68K_EMUL_OP_SOUNDIN_OPEN:         // Sound input driver functions
353 +                        r->d[0] = SoundInOpen(r->a[0], r->a[1]);
354 +                        break;
355 +
356 +                case M68K_EMUL_OP_SOUNDIN_PRIME:
357 +                        r->d[0] = SoundInPrime(r->a[0], r->a[1]);
358 +                        break;
359 +
360 +                case M68K_EMUL_OP_SOUNDIN_CONTROL:
361 +                        r->d[0] = SoundInControl(r->a[0], r->a[1]);
362 +                        break;
363 +
364 +                case M68K_EMUL_OP_SOUNDIN_STATUS:
365 +                        r->d[0] = SoundInStatus(r->a[0], r->a[1]);
366 +                        break;
367 +
368 +                case M68K_EMUL_OP_SOUNDIN_CLOSE:
369 +                        r->d[0] = SoundInClose(r->a[0], r->a[1]);
370 +                        break;
371 +
372                  case M68K_EMUL_OP_SCSI_DISPATCH: {      // SCSIDispatch() replacement
373                          uint32 ret = ReadMacInt32(r->a[7]);             // Get return address
374                          uint16 sel = ReadMacInt16(r->a[7] + 4); // Get selector
# Line 401 | Line 432 | void EmulOp(uint16 opcode, M68kRegisters
432                          break;
433                  }
434  
404                case M68K_EMUL_OP_MEMORY_DISPATCH: {    // MemoryDispatch() replacement routine
405                        int16 sel = r->d[0];
406                        D(bug("MemoryDispatch(%d)\n", sel));
407                        switch (sel) {
408                                case -6:        // GetLogicalRAMSize
409                                        r->d[0] = RAMSize;
410                                        break;
411                                case -3:
412                                        r->d[0] = 0x1000;
413                                        break;
414                                case 0:         // HoldMemory
415                                case 1:         // UnholdMemory
416                                case 2:         // LockMemory
417                                case 3:         // UnlockMemory
418                                case 4:         // LockMemoryContiguous
419                                case 6:         // ProtectMemory
420                                case 7:         // UnprotectMemory
421                                        r->d[0] = 0;
422                                        break;
423                                default:
424                                        printf("FATAL: MemoryDispatch(%d): illegal selector\n", sel);
425                                        r->d[0] = (uint32)-502;
426                                        break;
427                        }
428                        break;
429                }
430
435                  case M68K_EMUL_OP_IRQ:                  // Level 1 interrupt
436                          r->d[0] = 0;
437 +
438                          if (InterruptFlags & INTFLAG_60HZ) {
439                                  ClearInterruptFlag(INTFLAG_60HZ);
440                                  if (HasMacStarted()) {
441  
442 <                                        // Mac has started, execute video, ADB and Time Manager interrupt functions
438 <                                        ADBInterrupt();
442 >                                        // Mac has started, execute all 60Hz interrupt functions
443                                          TimerInterrupt();
444                                          VideoInterrupt();
445  
# Line 449 | Line 453 | void EmulOp(uint16 opcode, M68kRegisters
453                                          r->d[0] = 1;                    // Flag: 68k interrupt routine executes VBLTasks etc.
454                                  }
455                          }
456 +
457 +                        if (InterruptFlags & INTFLAG_1HZ) {
458 +                                ClearInterruptFlag(INTFLAG_1HZ);
459 +                                if (HasMacStarted()) {
460 +                                        SonyInterrupt();
461 +                                        DiskInterrupt();
462 +                                        CDROMInterrupt();
463 +                                }
464 +                        }
465 +
466                          if (InterruptFlags & INTFLAG_SERIAL) {
467                                  ClearInterruptFlag(INTFLAG_SERIAL);
468                                  SerialInterrupt();
469                          }
470 +
471                          if (InterruptFlags & INTFLAG_ETHER) {
472                                  ClearInterruptFlag(INTFLAG_ETHER);
473                                  EtherInterrupt();
474                          }
475 +
476                          if (InterruptFlags & INTFLAG_AUDIO) {
477                                  ClearInterruptFlag(INTFLAG_AUDIO);
478                                  AudioInterrupt();
479                          }
480 +
481 +                        if (InterruptFlags & INTFLAG_ADB) {
482 +                                ClearInterruptFlag(INTFLAG_ADB);
483 +                                if (HasMacStarted())
484 +                                        ADBInterrupt();
485 +                        }
486 +
487 +                        if (InterruptFlags & INTFLAG_NMI) {
488 +                                ClearInterruptFlag(INTFLAG_NMI);
489 +                                if (HasMacStarted())
490 +                                        TriggerNMI();
491 +                        }
492                          break;
493  
494                  case M68K_EMUL_OP_PUT_SCRAP: {          // PutScrap() patch
# Line 489 | Line 517 | void EmulOp(uint16 opcode, M68kRegisters
517                          r->d[0] = AudioDispatch(r->a[3], r->a[4]);
518                          break;
519  
520 + #if SUPPORTS_EXTFS
521 +                case M68K_EMUL_OP_EXTFS_COMM:           // External file system routines
522 +                        WriteMacInt16(r->a[7] + 14, ExtFSComm(ReadMacInt16(r->a[7] + 12), ReadMacInt32(r->a[7] + 8), ReadMacInt32(r->a[7] + 4)));
523 +                        break;
524 +
525 +                case M68K_EMUL_OP_EXTFS_HFS:
526 +                        WriteMacInt16(r->a[7] + 20, ExtFSHFS(ReadMacInt32(r->a[7] + 16), ReadMacInt16(r->a[7] + 14), ReadMacInt32(r->a[7] + 10), ReadMacInt32(r->a[7] + 6), ReadMacInt16(r->a[7] + 4)));
527 +                        break;
528 + #endif
529 +
530 +                case M68K_EMUL_OP_BLOCK_MOVE:           // BlockMove() cache flushing
531 +                        FlushCodeCache(Mac2HostAddr(r->a[0]), r->a[1]);
532 +                        break;
533 +
534 +                case M68K_EMUL_OP_DEBUGUTIL:
535 +                //      printf("DebugUtil d0=%08lx  a5=%08lx\n", r->d[0], r->a[5]);
536 +                        r->d[0] = DebugUtil(r->d[0]);
537 +                        break;
538 +
539                  default:
540                          printf("FATAL: EMUL_OP called with bogus opcode %08x\n", opcode);
541                          printf("d0 %08lx d1 %08lx d2 %08lx d3 %08lx\n"
# Line 499 | Line 546 | void EmulOp(uint16 opcode, M68kRegisters
546                                     r->d[0], r->d[1], r->d[2], r->d[3], r->d[4], r->d[5], r->d[6], r->d[7],
547                                     r->a[0], r->a[1], r->a[2], r->a[3], r->a[4], r->a[5], r->a[6], r->a[7],
548                                     r->sr);
549 + #ifdef ENABLE_MON
550 +                        char *arg[4] = {"mon", "-m", "-r", NULL};
551 +                        mon(3, arg);
552 + #endif
553                          QuitEmulator();
554                          break;
555          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines