1 /***************************************************************************
2  *
3  * Retrocade - Video game emulator
4  * Copyright 1998, The Retrocade group
5  *
6  * Permission to distribute the Retrocade executable *WITHOUT GAME ROMS* is
7  * granted to all. It may not be sold without the express written permission
8  * of the Retrocade development team or appointed representative.
9  *
10  * Source code is *NOT* distributable without the express written
11  * permission of the Retrocade group.
12  *
13  * Cinematronics CPU header file
14  *
15  ***************************************************************************/
16 
17 #ifndef _C_CPU_H_
18 #define	_C_CPU_H_
19 
20 
21 /*============================================================================================*
22 
23 	HERE BEGINS THE MAME-SPECIFIC ADDITIONS TO THE CCPU INTERFACE.
24 
25  *============================================================================================*/
26 
27 /* added these includes */
28 #include "osd_cpu.h"
29 #include "memory.h"
30 
31 enum {
32 	CCPU_PC=1, CCPU_ACC, CCPU_CMP, CCPU_PA0, CCPU_CFLAG,
33 	CCPU_A, CCPU_B, CCPU_I, CCPU_J, CCPU_P, CCPU_CSTATE };
34 
35 #ifndef FALSE
36 #define FALSE	0
37 #endif
38 #ifndef TRUE
39 #define TRUE	(!FALSE)
40 #endif
41 
42 /* an ICount variable (mostly irrelevant) */
43 extern int ccpu_ICount;
44 
45 /* MAME interface functions */
46 void ccpu_reset(void *param);
47 void ccpu_exit(void);
48 int ccpu_execute(int cycles);
49 unsigned ccpu_get_context(void *dst);
50 void ccpu_set_context(void *src);
51 unsigned ccpu_get_pc(void);
52 void ccpu_set_pc(unsigned val);
53 unsigned ccpu_get_sp(void);
54 void ccpu_set_sp(unsigned val);
55 unsigned ccpu_get_reg(int regnum);
56 void ccpu_set_reg(int regnum, unsigned val);
57 void ccpu_set_nmi_line(int state);
58 void ccpu_set_irq_line(int irqline, int state);
59 void ccpu_set_irq_callback(int (*callback)(int irqline));
60 const char *ccpu_info(void *context, int regnum);
61 unsigned ccpu_dasm(char *buffer, unsigned pc);
62 
63 /* I/O routine */
64 void ccpu_SetInputs(int inputs, int switches);
65 
66 /* constants for configuring the system */
67 #define CCPU_PORT_IOSWITCHES   	0
68 #define CCPU_PORT_IOINPUTS     	1
69 #define CCPU_PORT_IOOUTPUTS    	2
70 #define CCPU_PORT_IN_JOYSTICKX 	3
71 #define CCPU_PORT_IN_JOYSTICKY 	4
72 #define CCPU_PORT_MAX          	5
73 
74 #define CCPU_MEMSIZE_4K        	0
75 #define CCPU_MEMSIZE_8K        	1
76 #define CCPU_MEMSIZE_16K       	2
77 #define CCPU_MEMSIZE_32K       	3
78 
79 #define CCPU_MONITOR_BILEV  	0
80 #define CCPU_MONITOR_16LEV  	1
81 #define CCPU_MONITOR_64LEV  	2
82 #define CCPU_MONITOR_WOWCOL 	3
83 
84 /* nicer config function */
85 void ccpu_Config (int jmi, int msize, int monitor);
86 
87 /*============================================================================================*
88 
89 	BELOW LIES THE CORE OF THE CCPU. THE CODE WAS KINDLY GIVEN TO MAME BY ZONN MOORE,
90 	JEFF MITCHELL, AND NEIL BRADLEY. I HAVE PRETTY HEAVILY CLEANED IT UP.
91 
92  *============================================================================================*/
93 
94 
95 /* Define new types for the c-cpu emulator */
96 typedef short unsigned int CINEWORD;      /* 12bits on the C-CPU */
97 typedef unsigned char      CINEBYTE;      /* 8 (or less) bits on the C-CPU */
98 typedef short signed int   CINESWORD;     /* 12bits on the C-CPU */
99 typedef signed char        CINESBYTE;     /* 8 (or less) bits on the C-CPU */
100 
101 typedef unsigned long int  CINELONG;
102 
103 typedef enum
104 {
105 	state_A = 0,
106 	state_AA,
107 	state_B,
108 	state_BB
109 } CINESTATE;                              /* current state */
110 
111 /* NOTE: These MUST be in this order! */
112 
113 struct scCpuStruct
114 {
115 	CINEWORD	accVal;				/* CCPU Accumulator value */
116 	CINEWORD	cmpVal;				/* Comparison value */
117 	CINEBYTE	pa0;
118 	CINEBYTE	cFlag;
119 	CINEWORD	eRegPC;
120 	CINEWORD	eRegA;
121 	CINEWORD	eRegB;
122 	CINEWORD	eRegI;
123 	CINEWORD	eRegJ;
124 	CINEBYTE	eRegP;
125 	CINESTATE	eCState;
126 };
127 
128 typedef struct scCpuStruct CONTEXTCCPU;
129 
130 extern CINELONG cineExec(CINELONG);
131 extern void cineReset(void);
132 extern void cineSetJMI(int);
133 extern void cineSetMSize(int);
134 extern void cineSetMonitor(int);
135 extern void cSetContext(CONTEXTCCPU *);
136 extern void cGetContext(CONTEXTCCPU *);
137 extern CINELONG cineGetElapsedTicks(int);
138 extern void cineReleaseTimeslice(void);
139 extern CINELONG cGetContextSize(void);
140 
141 extern int bNewFrame;
142 
143 #endif
144