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 #define CCPU_DATA_OFFSET 0x0000 46 #define CCPU_PGM_OFFSET 0x8000 47 48 /* MAME interface functions */ 49 void ccpu_init(void); 50 void ccpu_reset(void *param); 51 void ccpu_exit(void); 52 int ccpu_execute(int cycles); 53 unsigned ccpu_get_context(void *dst); 54 void ccpu_set_context(void *src); 55 unsigned ccpu_get_reg(int regnum); 56 void ccpu_set_reg(int regnum, unsigned val); 57 void ccpu_set_irq_line(int irqline, int state); 58 void ccpu_set_irq_callback(int (*callback)(int irqline)); 59 const char *ccpu_info(void *context, int regnum); 60 unsigned ccpu_dasm(char *buffer, unsigned pc); 61 62 /* I/O routine */ 63 void ccpu_SetInputs(int inputs, int switches); 64 65 /* constants for configuring the system */ 66 #define CCPU_PORT_IOSWITCHES (0<<1) 67 #define CCPU_PORT_IOINPUTS (1<<1) 68 #define CCPU_PORT_IOOUTPUTS (2<<1) 69 #define CCPU_PORT_IN_JOYSTICKX (3<<1) 70 #define CCPU_PORT_IN_JOYSTICKY (4<<1) 71 #define CCPU_PORT_MAX (5<<1) 72 73 #define CCPU_MEMSIZE_4K 0 74 #define CCPU_MEMSIZE_8K 1 75 #define CCPU_MEMSIZE_16K 2 76 #define CCPU_MEMSIZE_32K 3 77 78 #define CCPU_MONITOR_BILEV 0 79 #define CCPU_MONITOR_16LEV 1 80 #define CCPU_MONITOR_64LEV 2 81 #define CCPU_MONITOR_WOWCOL 3 82 83 /* nicer config function */ 84 void ccpu_Config (int jmi, int msize, int monitor); 85 86 #ifdef MAME_DEBUG 87 extern unsigned DasmCCPU(char *buffer, unsigned pc); 88 #endif 89 90 /*============================================================================================* 91 92 BELOW LIES THE CORE OF THE CCPU. THE CODE WAS KINDLY GIVEN TO MAME BY ZONN MOORE, 93 JEFF MITCHELL, AND NEIL BRADLEY. I HAVE PRETTY HEAVILY CLEANED IT UP. 94 95 *============================================================================================*/ 96 97 98 /* Define new types for the c-cpu emulator */ 99 typedef short unsigned int CINEWORD; /* 12bits on the C-CPU */ 100 typedef unsigned char CINEBYTE; /* 8 (or less) bits on the C-CPU */ 101 typedef short signed int CINESWORD; /* 12bits on the C-CPU */ 102 typedef signed char CINESBYTE; /* 8 (or less) bits on the C-CPU */ 103 104 typedef unsigned long int CINELONG; 105 106 typedef enum 107 { 108 state_A = 0, 109 state_AA, 110 state_B, 111 state_BB 112 } CINESTATE; /* current state */ 113 114 /* NOTE: These MUST be in this order! */ 115 116 struct scCpuStruct 117 { 118 CINEWORD accVal; /* CCPU Accumulator value */ 119 CINEWORD cmpVal; /* Comparison value */ 120 CINEBYTE pa0; 121 CINEBYTE cFlag; 122 CINEWORD eRegPC; 123 CINEWORD eRegA; 124 CINEWORD eRegB; 125 CINEWORD eRegI; 126 CINEWORD eRegJ; 127 CINEBYTE eRegP; 128 CINESTATE eCState; 129 }; 130 131 typedef struct scCpuStruct CONTEXTCCPU; 132 133 extern CINELONG cineExec(CINELONG); 134 extern void cineReset(void); 135 extern void cineSetJMI(int); 136 extern void cineSetMSize(int); 137 extern void cineSetMonitor(int); 138 extern void cSetContext(CONTEXTCCPU *); 139 extern void cGetContext(CONTEXTCCPU *); 140 extern CINELONG cineGetElapsedTicks(int); 141 extern void cineReleaseTimeslice(void); 142 extern CINELONG cGetContextSize(void); 143 144 extern int bNewFrame; 145 146 #endif 147