added copyright line to top of source files next to license information
[cyclone68000.git] / Pico / Sek.cpp
CommitLineData
15eb0001 1\r
4abeeb4b 2// This file is part of the PicoDrive Megadrive Emulator\r
3\r
c41b9b97 4// Copyright (c) 2011 FinalDave (emudave (at) gmail.com)\r
5\r
4abeeb4b 6// This code is licensed under the GNU General Public License version 2.0 and the MAME License.\r
7// You can choose the license that has the most advantages for you.\r
8\r
9// SVN repository can be found at http://code.google.com/p/cyclone68000/\r
10\r
15eb0001 11#include "PicoInt.h"\r
12\r
13char PicoStatus[128]=""; // 68000 state for debug\r
14\r
15#ifdef EMU_C68K\r
16// ---------------------- Cyclone 68000 ----------------------\r
17\r
18struct Cyclone PicoCpu;\r
19\r
20int SekInit()\r
21{\r
22 memset(&PicoCpu,0,sizeof(PicoCpu));\r
23 return 0;\r
24}\r
25\r
26// Reset the 68000:\r
27int SekReset()\r
28{\r
29 if (Pico.rom==NULL) return 1;\r
30\r
31 PicoCpu.srh =0x27; // Supervisor mode\r
32 PicoCpu.a[7]=PicoCpu.read32(0); // Stack Pointer\r
33 PicoCpu.membase=0;\r
34 PicoCpu.pc=PicoCpu.checkpc(PicoCpu.read32(4)); // Program Counter\r
35\r
36 return 0;\r
37}\r
38\r
39\r
40// Run the 68000 for 'cyc' number of cycles and return the number of cycles actually executed\r
41static inline int DoRun(int cyc)\r
42{\r
43 PicoCpu.cycles=cyc;\r
44 CycloneRun(&PicoCpu);\r
45 return cyc-PicoCpu.cycles;\r
46}\r
47\r
48int SekInterrupt(int irq)\r
49{\r
50 PicoCpu.irq=(unsigned char)irq;\r
51 return 0;\r
52}\r
53\r
54int SekPc() { return PicoCpu.pc-PicoCpu.membase; }\r
55\r
56void SekState(unsigned char *data)\r
57{\r
58 memcpy(data,PicoCpu.d,0x44);\r
59}\r
60\r
61#endif\r
62\r
63#ifdef EMU_A68K\r
64// ---------------------- A68K ----------------------\r
65\r
66extern "C" void __cdecl M68000_RUN();\r
67extern "C" void __cdecl M68000_RESET();\r
68extern "C" int m68k_ICount=0;\r
69extern "C" unsigned int mem_amask=0xffffff; // 24-bit bus\r
70extern "C" unsigned int mame_debug=0,cur_mrhard=0,m68k_illegal_opcode=0,illegal_op=0,illegal_pc=0,opcode_entry=0; // filler\r
71\r
72static int IrqCallback(int) { return -1; }\r
73static int DoReset() { return 0; }\r
74static int (*ResetCallback)()=DoReset;\r
75\r
76int SekInit()\r
77{\r
78 memset(&M68000_regs,0,sizeof(M68000_regs));\r
79 M68000_regs.IrqCallback=IrqCallback;\r
80 M68000_regs.pResetCallback=ResetCallback;\r
81 M68000_RESET(); // Init cpu emulator\r
82 return 0;\r
83}\r
84\r
85int SekReset()\r
86{\r
87 // Reset CPU: fetch SP and PC\r
88 M68000_regs.srh=0x27; // Supervisor mode\r
89 M68000_regs.a[7]=PicoRead32(0);\r
90 M68000_regs.pc =PicoRead32(4);\r
91 PicoInitPc(M68000_regs.pc);\r
92\r
93 return 0;\r
94}\r
95\r
96static inline int DoRun(int cyc)\r
97{\r
98 m68k_ICount=cyc;\r
99 M68000_RUN();\r
100 return cyc-m68k_ICount;\r
101}\r
102\r
103int SekInterrupt(int irq)\r
104{\r
105 M68000_regs.irq=irq; // raise irq (gets lowered after taken)\r
106 return 0;\r
107}\r
108\r
109int SekPc() { return M68000_regs.pc; }\r
110\r
111void SekState(unsigned char *data)\r
112{\r
113 memcpy(data, M68000_regs.d, 0x40);\r
114 memcpy(data+0x40,&M68000_regs.pc,0x04);\r
115}\r
116\r
117#endif\r
118\r
119#ifdef EMU_NULL\r
120// -----------------------------------------------------------\r
121int SekInit() { return 0; }\r
122int SekReset() { return 0; }\r
123static inline int DoRun(int cyc) { return cyc; }\r
124int SekInterrupt(int) { return 0; }\r
125\r
126int SekPc()\r
127{\r
128 return 0;\r
129}\r
130\r
131void SekState(unsigned char *) { }\r
132\r
133#endif\r
134\r
135int SekRun(int cyc)\r
136{\r
137 int did=0;\r
138\r
139 did=DoRun(cyc);\r
140\r
141 return did;\r
142}\r