2 // This file is part of the PicoDrive Megadrive Emulator
\r
4 // This code is licensed under the GNU General Public License version 2.0 and the MAME License.
\r
5 // You can choose the license that has the most advantages for you.
\r
7 // SVN repository can be found at http://code.google.com/p/cyclone68000/
\r
11 char PicoStatus[128]=""; // 68000 state for debug
\r
14 // ---------------------- Cyclone 68000 ----------------------
\r
16 struct Cyclone PicoCpu;
\r
20 memset(&PicoCpu,0,sizeof(PicoCpu));
\r
27 if (Pico.rom==NULL) return 1;
\r
29 PicoCpu.srh =0x27; // Supervisor mode
\r
30 PicoCpu.a[7]=PicoCpu.read32(0); // Stack Pointer
\r
32 PicoCpu.pc=PicoCpu.checkpc(PicoCpu.read32(4)); // Program Counter
\r
38 // Run the 68000 for 'cyc' number of cycles and return the number of cycles actually executed
\r
39 static inline int DoRun(int cyc)
\r
42 CycloneRun(&PicoCpu);
\r
43 return cyc-PicoCpu.cycles;
\r
46 int SekInterrupt(int irq)
\r
48 PicoCpu.irq=(unsigned char)irq;
\r
52 int SekPc() { return PicoCpu.pc-PicoCpu.membase; }
\r
54 void SekState(unsigned char *data)
\r
56 memcpy(data,PicoCpu.d,0x44);
\r
62 // ---------------------- A68K ----------------------
\r
64 extern "C" void __cdecl M68000_RUN();
\r
65 extern "C" void __cdecl M68000_RESET();
\r
66 extern "C" int m68k_ICount=0;
\r
67 extern "C" unsigned int mem_amask=0xffffff; // 24-bit bus
\r
68 extern "C" unsigned int mame_debug=0,cur_mrhard=0,m68k_illegal_opcode=0,illegal_op=0,illegal_pc=0,opcode_entry=0; // filler
\r
70 static int IrqCallback(int) { return -1; }
\r
71 static int DoReset() { return 0; }
\r
72 static int (*ResetCallback)()=DoReset;
\r
76 memset(&M68000_regs,0,sizeof(M68000_regs));
\r
77 M68000_regs.IrqCallback=IrqCallback;
\r
78 M68000_regs.pResetCallback=ResetCallback;
\r
79 M68000_RESET(); // Init cpu emulator
\r
85 // Reset CPU: fetch SP and PC
\r
86 M68000_regs.srh=0x27; // Supervisor mode
\r
87 M68000_regs.a[7]=PicoRead32(0);
\r
88 M68000_regs.pc =PicoRead32(4);
\r
89 PicoInitPc(M68000_regs.pc);
\r
94 static inline int DoRun(int cyc)
\r
98 return cyc-m68k_ICount;
\r
101 int SekInterrupt(int irq)
\r
103 M68000_regs.irq=irq; // raise irq (gets lowered after taken)
\r
107 int SekPc() { return M68000_regs.pc; }
\r
109 void SekState(unsigned char *data)
\r
111 memcpy(data, M68000_regs.d, 0x40);
\r
112 memcpy(data+0x40,&M68000_regs.pc,0x04);
\r
118 // -----------------------------------------------------------
\r
119 int SekInit() { return 0; }
\r
120 int SekReset() { return 0; }
\r
121 static inline int DoRun(int cyc) { return cyc; }
\r
122 int SekInterrupt(int) { return 0; }
\r
129 void SekState(unsigned char *) { }
\r
133 int SekRun(int cyc)
\r