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.8 by cebix, 1999-10-25T08:07:45Z 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 < #if ENABLE_MON
45 > #ifdef ENABLE_MON
46   #include "mon.h"
47   #endif
48  
# Line 68 | 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 < #if ENABLE_MON
72 <                        char *arg[2];
73 <                        arg[0] = "rmon";
74 <                        arg[1] = NULL;
75 <                        mon(1, arg);
71 > #ifdef ENABLE_MON
72 >                        char *arg[4] = {"mon", "-m", "-r", NULL};
73 >                        mon(3, arg);
74   #endif
75                          QuitEmulator();
76                          break;
# Line 86 | 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 197 | 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)
200                        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 249 | 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 349 | 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 412 | Line 447 | void EmulOp(uint16 opcode, M68kRegisters
447                          break;
448                  }
449  
415                case M68K_EMUL_OP_MEMORY_DISPATCH: {    // MemoryDispatch() replacement routine
416                        int16 sel = r->d[0];
417                        D(bug("MemoryDispatch(%d)\n", sel));
418                        switch (sel) {
419                                case -6:        // GetLogicalRAMSize
420                                        r->d[0] = RAMSize;
421                                        break;
422                                case -3:
423                                        r->d[0] = 0x1000;
424                                        break;
425                                case 0:         // HoldMemory
426                                case 1:         // UnholdMemory
427                                case 2:         // LockMemory
428                                case 3:         // UnlockMemory
429                                case 4:         // LockMemoryContiguous
430                                case 6:         // ProtectMemory
431                                case 7:         // UnprotectMemory
432                                        r->d[0] = 0;
433                                        break;
434                                default:
435                                        printf("FATAL: MemoryDispatch(%d): illegal selector\n", sel);
436                                        r->d[0] = (uint32)-502;
437                                        break;
438                        }
439                        break;
440                }
441
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 449 | Line 458 | void EmulOp(uint16 opcode, M68kRegisters
458                                          ADBInterrupt();
459                                          TimerInterrupt();
460                                          VideoInterrupt();
452                                        SonyInterrupt();
453                                        DiskInterrupt();
454                                        CDROMInterrupt();
461  
462                                          // Call DoVBLTask(0)
463                                          if (ROMVersion == ROM_VERSION_32) {
# Line 463 | 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 513 | Line 539 | void EmulOp(uint16 opcode, M68kRegisters
539                          break;
540   #endif
541  
542 <                case M68K_EMUL_OP_BLOCK_MOVE:           // BlockMove() replacement
543 <                        memmove(Mac2HostAddr(r->a[1]), Mac2HostAddr(r->a[0]), r->d[0]);
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:
# Line 527 | 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