DGen/SDL
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
starcpu.h
Go to the documentation of this file.
1 /*
2 ** Starscream 680x0 emulation library
3 ** Copyright 1997, 1998, 1999 Neill Corlett
4 **
5 ** Refer to STARDOC.TXT for terms of use, API reference, and directions on
6 ** how to compile.
7 */
8 
9 #ifndef __STARCPU_H__
10 #define __STARCPU_H__
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 /* Remember to byte-swap these regions. (read STARDOC.TXT for details) */
18  unsigned lowaddr;
19  unsigned highaddr;
20  unsigned offset;
21 };
22 
24  unsigned lowaddr;
25  unsigned highaddr;
26  unsigned (*memorycall)(unsigned, unsigned);
27  void *userdata;
28 };
29 
30 /* Memory structures for 16-bit data path */
31 #define STARSCREAM_CONTEXTINFO_MEM16 \
32  struct STARSCREAM_PROGRAMREGION *fetch; \
33  struct STARSCREAM_DATAREGION *readbyte; \
34  struct STARSCREAM_DATAREGION *readword; \
35  struct STARSCREAM_DATAREGION *writebyte; \
36  struct STARSCREAM_DATAREGION *writeword; \
37  struct STARSCREAM_PROGRAMREGION *s_fetch; \
38  struct STARSCREAM_DATAREGION *s_readbyte; \
39  struct STARSCREAM_DATAREGION *s_readword; \
40  struct STARSCREAM_DATAREGION *s_writebyte; \
41  struct STARSCREAM_DATAREGION *s_writeword; \
42  struct STARSCREAM_PROGRAMREGION *u_fetch; \
43  struct STARSCREAM_DATAREGION *u_readbyte; \
44  struct STARSCREAM_DATAREGION *u_readword; \
45  struct STARSCREAM_DATAREGION *u_writebyte; \
46  struct STARSCREAM_DATAREGION *u_writeword; \
47 
48 /* Memory structures for 16-bit data path with function code support */
49 #define STARSCREAM_CONTEXTINFO_MEM16FC \
50  unsigned (*f_readbyte) (unsigned f, unsigned a); \
51  unsigned (*f_readword) (unsigned f, unsigned a); \
52  unsigned (*f_writebyte)(unsigned f, unsigned a); \
53  unsigned (*f_writeword)(unsigned f, unsigned a); \
54 
55 /* Memory structures for 32-bit sizable data path */
56 #define STARSCREAM_CONTEXTINFO_MEM32 \
57  struct STARSCREAM_PROGRAMREGION *fetch; \
58  struct STARSCREAM_DATAREGION *readbus; \
59  struct STARSCREAM_DATAREGION *writebus; \
60  struct STARSCREAM_PROGRAMREGION *s_fetch; \
61  struct STARSCREAM_DATAREGION *s_readbus; \
62  struct STARSCREAM_DATAREGION *s_writebus; \
63  struct STARSCREAM_PROGRAMREGION *u_fetch; \
64  struct STARSCREAM_DATAREGION *u_readbus; \
65  struct STARSCREAM_DATAREGION *u_writebus; \
66  unsigned (*f_readbus) (unsigned f, unsigned a); \
67  unsigned (*f_writebus)(unsigned f, unsigned a); \
68 
69 /* Common context info for all 680x0 types */
70 #define STARSCREAM_CONTEXTINFO_COMMON \
71  void (*resethandler)(void); \
72  void (*inthandler)(void); \
73  unsigned dreg[8]; \
74  unsigned areg[8]; \
75  unsigned asp; \
76  unsigned pc; \
77  unsigned odometer; \
78  unsigned char interrupts[8]; \
79  unsigned short sr; \
80 
81 /* 68000-specific context info */
82 #define STARSCREAM_CONTEXTINFO_68000SPECIFIC \
83  unsigned short contextfiller00; \
84 
85 /* Context info for 68010 and higher */
86 #define STARSCREAM_CONTEXTINFO_68010 \
87  unsigned char sfc; \
88  unsigned char dfc; \
89  unsigned vbr; \
90  void (*bkpthandler)(void); \
91 
92 /* 68010-specific context info */
93 #define STARSCREAM_CONTEXTINFO_68010SPECIFIC \
94  unsigned char loopmode; \
95  unsigned char contextfiller10[3]; \
96 
97 /* Context info for 68020 and higher */
98 #define STARSCREAM_CONTEXTINFO_68020 \
99  unsigned asp2; \
100 
105 };
106 
113 };
114 
120 };
121 
122 #define STARSCREAM_IDENTIFIERS(SNC,SN) \
123  \
124 extern struct SNC##CONTEXT SN##context; \
125  \
126 int SN##init (void); \
127 unsigned SN##reset (void); \
128 unsigned SN##exec (int n); \
129 int SN##interrupt (int level, int vector); \
130 void SN##flushInterrupts (void); \
131 int SN##GetContextSize (void); \
132 void SN##GetContext (void *context); \
133 void SN##SetContext (void *context); \
134 int SN##fetch (unsigned address); \
135 unsigned SN##readOdometer (void); \
136 unsigned SN##tripOdometer (void); \
137 unsigned SN##controlOdometer (int n); \
138 void SN##releaseTimeslice (void); \
139 unsigned SN##readPC (void); \
140 
141 STARSCREAM_IDENTIFIERS(S68000,s68000)
142 STARSCREAM_IDENTIFIERS(S68010,s68010)
143 STARSCREAM_IDENTIFIERS(S68020,s68020)
144 
145 #ifdef __cplusplus
146 }
147 #endif
148 
149 #endif