15eb0001 |
1 | \r |
4abeeb4b |
2 | // This file is part of the PicoDrive Megadrive Emulator\r |
3 | \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 |
6 | \r |
7 | // SVN repository can be found at http://code.google.com/p/cyclone68000/\r |
8 | \r |
15eb0001 |
9 | #include <stdio.h>\r |
10 | #include <stdlib.h>\r |
11 | #include <string.h>\r |
12 | #include "Pico.h"\r |
13 | \r |
14 | #if defined(__GNUC__) || defined(_WIN32_WCE)\r |
15 | #define EMU_C68K // Use the Cyclone 68000 emulator\r |
16 | #else\r |
17 | #define EMU_A68K // Use the 'A68K' (Make68K) Assembler 68000 emulator\r |
18 | #endif\r |
19 | \r |
20 | //#define MSOUND\r |
21 | \r |
22 | // Disa.h also defines CPU_CALL to be fastcall or normal call\r |
23 | #include "Disa.h"\r |
24 | \r |
25 | \r |
26 | // ----------------------- 68000 CPU -----------------------\r |
27 | #ifdef EMU_A68K\r |
28 | // The format of the data in a68k.asm (at the _M68000_regs location)\r |
29 | struct A68KContext\r |
30 | {\r |
31 | unsigned int d[8],a[8];\r |
32 | unsigned int isp,srh,ccr,xc,pc,irq,sr;\r |
33 | int (*IrqCallback) (int nIrq);\r |
34 | unsigned int ppc;\r |
35 | void *pResetCallback;\r |
36 | unsigned int sfc,dfc,usp,vbr;\r |
37 | unsigned int AsmBank,CpuVersion;\r |
38 | };\r |
39 | extern "C" struct A68KContext M68000_regs;\r |
40 | #endif\r |
41 | \r |
42 | #ifdef EMU_C68K\r |
43 | #include "../Cyclone/Cyclone.h"\r |
44 | extern struct Cyclone PicoCpu;\r |
45 | #endif\r |
46 | \r |
47 | #ifdef MSOUND\r |
48 | extern "C" {\r |
49 | #include "ym2612.h"\r |
50 | }\r |
51 | #endif\r |
52 | \r |
53 | // ---------------------------------------------------------\r |
54 | \r |
55 | struct PicoVideo\r |
56 | {\r |
57 | unsigned char reg[0x20];\r |
58 | unsigned int command; // 32-bit Command\r |
59 | unsigned char pending; // 1 if waiting for second half of 32-bit command\r |
60 | unsigned char type; // Command type (v/c/vsram read/write)\r |
61 | unsigned short addr; // Read/Write address\r |
62 | int status; // Status bits\r |
63 | unsigned char pad[0x14];\r |
64 | };\r |
65 | \r |
66 | struct PicoMisc\r |
67 | {\r |
68 | unsigned char rotate;\r |
69 | unsigned char z80Run;\r |
70 | unsigned char padSelect[2]; // Select high or low bit from joypad\r |
71 | short scanline; // -38 to 223\r |
72 | char dirtyPal; // Is the palette dirty\r |
73 | unsigned char hardware; // Hardware value for country\r |
74 | unsigned char pal; // 1=PAL 0=NTSC\r |
75 | unsigned char pad[0x16];\r |
76 | };\r |
77 | \r |
78 | struct PicoSound\r |
79 | {\r |
80 | unsigned char fmsel[2]; // FM selected register\r |
81 | unsigned char reg[0x100];\r |
82 | unsigned char pad[0x3e];\r |
83 | };\r |
84 | \r |
85 | struct Pico\r |
86 | {\r |
87 | unsigned char ram[0x10000]; // scratch ram\r |
88 | unsigned short vram[0x8000];\r |
89 | unsigned char zram[0x2000]; // Z80 ram\r |
90 | unsigned int highpal[0x40];\r |
91 | unsigned short cram[0x40];\r |
92 | unsigned short vsram[0x40];\r |
93 | \r |
94 | unsigned char *rom;\r |
95 | unsigned int romsize;\r |
96 | \r |
97 | struct PicoMisc m;\r |
98 | struct PicoVideo video;\r |
99 | struct PicoSound s;\r |
100 | };\r |
101 | \r |
102 | // Draw.cpp\r |
103 | int PicoLine(int scan);\r |
104 | \r |
105 | // Draw2.cpp\r |
106 | int PicoDraw2();\r |
107 | \r |
108 | // Memory.cpp\r |
109 | int PicoInitPc(unsigned int pc);\r |
110 | unsigned short CPU_CALL PicoRead16(unsigned int a);\r |
111 | unsigned int CPU_CALL PicoRead32(unsigned int a);\r |
112 | int PicoMemInit();\r |
113 | void PicoDasm(int start,int len);\r |
114 | \r |
115 | // Pico.cpp\r |
116 | extern struct Pico Pico;\r |
117 | \r |
118 | // Sek.cpp\r |
119 | int SekInit();\r |
120 | int SekReset();\r |
121 | int SekRun(int cyc);\r |
122 | int SekInterrupt(int irq);\r |
123 | int SekPc();\r |
124 | void SekState(unsigned char *data);\r |
125 | \r |
126 | // Sine.cpp\r |
127 | extern short Sine[];\r |
128 | \r |
129 | // Psnd.cpp\r |
130 | int PsndReset();\r |
131 | int PsndFm(int a,int d);\r |
132 | int PsndRender();\r |
133 | \r |
134 | // VideoPort.cpp\r |
135 | void PicoVideoWrite(unsigned int a,unsigned int d);\r |
136 | unsigned int PicoVideoRead(unsigned int a);\r |
137 | \r |
138 | // External:\r |
139 | extern "C" int dprintf(char *Format, ...);\r |