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.4 by cebix, 1999-10-19T17:41:13Z vs.
Revision 1.23 by cebix, 2001-02-02T20:52:57Z

# 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 42 | Line 42
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 64 | 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 + #ifdef ENABLE_MON
72 +                        char *arg[4] = {"mon", "-m", "-r", NULL};
73 +                        mon(3, arg);
74 + #endif
75                          QuitEmulator();
76                          break;
77                  }
# Line 76 | Line 84 | void EmulOp(uint16 opcode, M68kRegisters
84                          D(bug("*** RESET ***\n"));
85                          TimerReset();
86                          EtherReset();
87 +                        AudioReset();
88  
89                          // Create BootGlobs at top of memory
90 <                        memset((void *)(RAMBaseHost + RAMSize - 4096), 0, 4096);
90 >                        Mac_memset(RAMBaseMac + RAMSize - 4096, 0, 4096);
91                          uint32 boot_globs = RAMBaseMac + RAMSize - 0x1c;
92                          WriteMacInt32(boot_globs + 0x00, RAMBaseMac);   // First RAM bank
93                          WriteMacInt32(boot_globs + 0x04, RAMSize);
# Line 187 | Line 196 | void EmulOp(uint16 opcode, M68kRegisters
196                          break;
197  
198                  case M68K_EMUL_OP_FIX_BOOTSTACK:        // Set boot stack to 3/4 of RAM (7.5)
190                        D(bug("Fix boot stack\n"));
199                          r->a[1] = RAMBaseMac + RAMSize * 3 / 4;
200 +                        D(bug("Fix boot stack %08x\n", r->a[1]));
201                          break;
202  
203                  case M68K_EMUL_OP_FIX_MEMSIZE: {        // Set correct logical and physical memory size
# Line 239 | Line 248 | void EmulOp(uint16 opcode, M68kRegisters
248                                  WriteMacInt8(asc_regs + 0x800, 0x0f);   // Set ASC version number
249                                  WriteMacInt32(0xcc0, asc_regs);                 // Set ASCBase
250                          }
251 +                        
252 + #if (REAL_ADDRESSING || DIRECT_ADDRESSING) && defined(USE_SCRATCHMEM_SUBTERFUGE)
253 +                        extern uint8 *ScratchMem;
254 +                        
255 +                        // Set VIA base address to scratch memory area
256 +                        D(bug("Patch VIA base address [0x%x] to ScratchMem\n", ReadMacInt32(0x1d4)));
257 +                        WriteMacInt32(0x1d4, Host2MacAddr(ScratchMem));
258 +                        
259 +                        // Set SCCRd base address to scratch memory area
260 +                        D(bug("Patch SCCRd base address [0x%x] to ScratchMem\n", ReadMacInt32(0x1d8)));
261 +                        WriteMacInt32(0x1d8, Host2MacAddr(ScratchMem));
262 +                        
263 +                        // Set SCCWr base address to scratch memory area
264 +                        D(bug("Patch SCCWr base address [0x%x] to ScratchMem\n", ReadMacInt32(0x1dc)));
265 +                        WriteMacInt32(0x1dc, Host2MacAddr(ScratchMem));
266 + #endif
267                          break;
268                  }
269  
# Line 296 | Line 321 | void EmulOp(uint16 opcode, M68kRegisters
321                          break;
322  
323                  case M68K_EMUL_OP_VIDEO_OPEN:           // Video driver functions
324 <                        r->d[0] = VideoOpen(r->a[0], r->a[1]);
324 >                        r->d[0] = VideoDriverOpen(r->a[0], r->a[1]);
325                          break;
326  
327                  case M68K_EMUL_OP_VIDEO_CONTROL:
328 <                        r->d[0] = VideoControl(r->a[0], r->a[1]);
328 >                        r->d[0] = VideoDriverControl(r->a[0], r->a[1]);
329                          break;
330  
331                  case M68K_EMUL_OP_VIDEO_STATUS:
332 <                        r->d[0] = VideoStatus(r->a[0], r->a[1]);
332 >                        r->d[0] = VideoDriverStatus(r->a[0], r->a[1]);
333                          break;
334  
335                  case M68K_EMUL_OP_SERIAL_OPEN:          // Serial driver functions
# Line 339 | Line 364 | void EmulOp(uint16 opcode, M68kRegisters
364                          EtherReadPacket((uint8 **)&r->a[0], r->a[3], r->d[3], r->d[1]);
365                          break;
366  
367 +                case M68K_EMUL_OP_SOUNDIN_OPEN:         // Sound input driver functions
368 +                        r->d[0] = SoundInOpen(r->a[0], r->a[1]);
369 +                        break;
370 +
371 +                case M68K_EMUL_OP_SOUNDIN_PRIME:
372 +                        r->d[0] = SoundInPrime(r->a[0], r->a[1]);
373 +                        break;
374 +
375 +                case M68K_EMUL_OP_SOUNDIN_CONTROL:
376 +                        r->d[0] = SoundInControl(r->a[0], r->a[1]);
377 +                        break;
378 +
379 +                case M68K_EMUL_OP_SOUNDIN_STATUS:
380 +                        r->d[0] = SoundInStatus(r->a[0], r->a[1]);
381 +                        break;
382 +
383 +                case M68K_EMUL_OP_SOUNDIN_CLOSE:
384 +                        r->d[0] = SoundInClose(r->a[0], r->a[1]);
385 +                        break;
386 +
387                  case M68K_EMUL_OP_SCSI_DISPATCH: {      // SCSIDispatch() replacement
388                          uint32 ret = ReadMacInt32(r->a[7]);             // Get return address
389                          uint16 sel = ReadMacInt16(r->a[7] + 4); // Get selector
# Line 402 | Line 447 | void EmulOp(uint16 opcode, M68kRegisters
447                          break;
448                  }
449  
405                case M68K_EMUL_OP_MEMORY_DISPATCH: {    // MemoryDispatch() replacement routine
406                        int16 sel = r->d[0];
407                        D(bug("MemoryDispatch(%d)\n", sel));
408                        switch (sel) {
409                                case -6:        // GetLogicalRAMSize
410                                        r->d[0] = RAMSize;
411                                        break;
412                                case -3:
413                                        r->d[0] = 0x1000;
414                                        break;
415                                case 0:         // HoldMemory
416                                case 1:         // UnholdMemory
417                                case 2:         // LockMemory
418                                case 3:         // UnlockMemory
419                                case 4:         // LockMemoryContiguous
420                                case 6:         // ProtectMemory
421                                case 7:         // UnprotectMemory
422                                        r->d[0] = 0;
423                                        break;
424                                default:
425                                        printf("FATAL: MemoryDispatch(%d): illegal selector\n", sel);
426                                        r->d[0] = (uint32)-502;
427                                        break;
428                        }
429                        break;
430                }
431
450                  case M68K_EMUL_OP_IRQ:                  // Level 1 interrupt
451                          r->d[0] = 0;
452 +
453                          if (InterruptFlags & INTFLAG_60HZ) {
454                                  ClearInterruptFlag(INTFLAG_60HZ);
455                                  if (HasMacStarted()) {
# Line 439 | Line 458 | void EmulOp(uint16 opcode, M68kRegisters
458                                          ADBInterrupt();
459                                          TimerInterrupt();
460                                          VideoInterrupt();
442                                        SonyInterrupt();
443                                        DiskInterrupt();
444                                        CDROMInterrupt();
461  
462                                          // Call DoVBLTask(0)
463                                          if (ROMVersion == ROM_VERSION_32) {
# Line 453 | Line 469 | void EmulOp(uint16 opcode, M68kRegisters
469                                          r->d[0] = 1;                    // Flag: 68k interrupt routine executes VBLTasks etc.
470                                  }
471                          }
472 +
473 +                        if (InterruptFlags & INTFLAG_1HZ) {
474 +                                ClearInterruptFlag(INTFLAG_1HZ);
475 +
476 +                                if (HasMacStarted()) {
477 +                                        SonyInterrupt();
478 +                                        DiskInterrupt();
479 +                                        CDROMInterrupt();
480 +                                }
481 +                        }
482 +
483                          if (InterruptFlags & INTFLAG_SERIAL) {
484                                  ClearInterruptFlag(INTFLAG_SERIAL);
485                                  SerialInterrupt();
486                          }
487 +
488                          if (InterruptFlags & INTFLAG_ETHER) {
489                                  ClearInterruptFlag(INTFLAG_ETHER);
490                                  EtherInterrupt();
491                          }
492 +
493                          if (InterruptFlags & INTFLAG_AUDIO) {
494                                  ClearInterruptFlag(INTFLAG_AUDIO);
495                                  AudioInterrupt();
496                          }
497 +
498 +                        if (InterruptFlags & INTFLAG_NMI) {
499 +                                ClearInterruptFlag(INTFLAG_NMI);
500 +                                if (HasMacStarted()) {
501 +                                        TriggerNMI();
502 +                                }
503 +                        }
504                          break;
505  
506                  case M68K_EMUL_OP_PUT_SCRAP: {          // PutScrap() patch
# Line 493 | Line 529 | void EmulOp(uint16 opcode, M68kRegisters
529                          r->d[0] = AudioDispatch(r->a[3], r->a[4]);
530                          break;
531  
532 + #if SUPPORTS_EXTFS
533                  case M68K_EMUL_OP_EXTFS_COMM:           // External file system routines
534                          WriteMacInt16(r->a[7] + 14, ExtFSComm(ReadMacInt16(r->a[7] + 12), ReadMacInt32(r->a[7] + 8), ReadMacInt32(r->a[7] + 4)));
535                          break;
# Line 500 | Line 537 | void EmulOp(uint16 opcode, M68kRegisters
537                  case M68K_EMUL_OP_EXTFS_HFS:
538                          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)));
539                          break;
540 + #endif
541 +
542 +                case M68K_EMUL_OP_BLOCK_MOVE:           // BlockMove() cache flushing
543 +                        FlushCodeCache(Mac2HostAddr(r->a[0]), r->a[1]);
544 +                        break;
545 +
546 +                case M68K_EMUL_OP_DEBUGUTIL:
547 +                //      printf("DebugUtil d0=%08lx  a5=%08lx\n", r->d[0], r->a[5]);
548 +                        r->d[0] = DebugUtil(r->d[0]);
549 +                        break;
550  
551                  default:
552                          printf("FATAL: EMUL_OP called with bogus opcode %08x\n", opcode);
# Line 511 | Line 558 | void EmulOp(uint16 opcode, M68kRegisters
558                                     r->d[0], r->d[1], r->d[2], r->d[3], r->d[4], r->d[5], r->d[6], r->d[7],
559                                     r->a[0], r->a[1], r->a[2], r->a[3], r->a[4], r->a[5], r->a[6], r->a[7],
560                                     r->sr);
561 + #ifdef ENABLE_MON
562 +                        char *arg[4] = {"mon", "-m", "-r", NULL};
563 +                        mon(3, arg);
564 + #endif
565                          QuitEmulator();
566                          break;
567          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines