|
|
1.1 root 1: #include "config.h"
2: #include "machine.h"
3:
4: #define VERSTRING "v0.15"
5: #define PROGNAME generator
6: #define FNAME_TCLSCRIPT SHAREDIR "/gen.tcl"
7: #define FNAME_GEN68K_CPU_OUT "out/cpu68k-%x.c"
8: #define GEN_RAMLENGTH 64*1024
9:
10: #define LEN_IPCLISTTABLE 16*1024
11:
12: char *gen_loadimage(const char *filename);
13: char *gen_loadsavepos(const char *filename);
14: void gen_reset(void);
15:
16: extern unsigned int gen_quit;
17: extern unsigned int gen_debugmode;
18: extern unsigned int gen_loglevel;
19:
20: #ifdef WORDS_BIGENDIAN
21: #define LOCENDIAN16(y) (y)
22: #define LOCENDIAN32(y) (y)
23: #else
24: #define LOCENDIAN16(y) ((((y)>>8)&0x00FF)+((((y)<<8)&0xFF00)))
25: #define LOCENDIAN32(y) ( (((y)>>24) & 0x000000FF) + \
26: (((y)>>8) & 0x0000FF00) + \
27: (((y)<<8) & 0x00FF0000) + \
28: (((y)<<24) & 0xFF000000) )
29: #endif
30:
31: #define SWAP16(y) ((((y)>>8)&0x00FF)+((((y)<<8)&0xFF00)))
32:
33: typedef enum {
34: tp_src, tp_dst
35: } t_type;
36:
37: typedef enum {
38: sz_none, sz_byte, sz_word, sz_long
39: } t_size;
40:
41: typedef enum {
42: dt_Dreg, dt_Areg, dt_Aind, dt_Ainc, dt_Adec, dt_Adis, dt_Aidx,
43: dt_AbsW, dt_AbsL, dt_Pdis, dt_Pidx,
44: dt_ImmB, dt_ImmW, dt_ImmL, dt_ImmS,
45: dt_Imm3, dt_Imm4, dt_Imm8, dt_Imm8s, dt_ImmV,
46: dt_Ill
47: } t_datatype;
48:
49: typedef enum {
50: ea_Dreg, ea_Areg, ea_Aind, ea_Ainc, ea_Adec, ea_Adis, ea_Aidx,
51: ea_AbsW, ea_AbsL, ea_Pdis, ea_Pidx, ea_Imm
52: } t_eatypes;
53:
54: typedef enum {
55: i_ILLG,
56: i_OR, i_ORSR,
57: i_AND, i_ANDSR,
58: i_EOR, i_EORSR,
59: i_SUB, i_SUBA, i_SUBX,
60: i_ADD, i_ADDA, i_ADDX,
61: i_MULU, i_MULS,
62: i_CMP, i_CMPA,
63: i_BTST, i_BCHG, i_BCLR, i_BSET,
64: i_MOVE, i_MOVEA,
65: i_MOVEPMR, i_MOVEPRM,
66: i_MOVEFSR, i_MOVETSR,
67: i_MOVEMRM, i_MOVEMMR,
68: i_MOVETUSP, i_MOVEFUSP,
69: i_NEG, i_NEGX, i_CLR, i_NOT,
70: i_ABCD, i_SBCD, i_NBCD,
71: i_SWAP,
72: i_PEA, i_LEA,
73: i_EXT, i_EXG,
74: i_TST, i_TAS, i_CHK,
75: i_TRAPV, i_TRAP, i_RESET, i_NOP, i_STOP,
76: i_LINK, i_UNLK,
77: i_RTE, i_RTS, i_RTR,
78: i_JSR, i_JMP, i_Scc, i_SF, i_DBcc, i_DBRA, i_Bcc, i_BSR,
79: i_DIVU, i_DIVS,
80: i_ASR, i_LSR, i_ROXR, i_ROR,
81: i_ASL, i_LSL, i_ROXL, i_ROL,
82: i_LINE10, i_LINE15
83: } t_mnemonic;
84:
85: typedef struct {
86: uint16 mask; /* mask of bits that are static */
87: uint16 bits; /* bit values corresponding to bits in mask */
88: t_mnemonic mnemonic; /* instruction mnemonic */
89: struct {
90: int priv:1; /* instruction is privileged if set */
91: int endblk:1; /* instruction ends a block if set */
92: int imm_notzero:1; /* immediate data cannot be 0 (if applicable) */
93: int used:5; /* bitmap of XNZVC flags inspected */
94: int set:5; /* bitmap of XNZVC flags altered */
95: } flags;
96: t_size size; /* size of instruction */
97: t_datatype stype; /* type of source */
98: t_datatype dtype; /* type of destination */
99: unsigned int sbitpos:4; /* bit pos of imm data or reg part of EA */
100: unsigned int dbitpos:4; /* reg part of EA */
101: unsigned int immvalue; /* if stype is ImmS this is the value */
102: unsigned int cc; /* condition code if mnemonic is Scc/Dbcc/Bcc */
103: unsigned int funcnum; /* function number for this instruction */
104: unsigned int wordlen; /* length in words of this instruction */
105: unsigned int clocks; /* number of external clock periods */
106: } t_iib; /* instruction information block */
107:
108: #define IIB_FLAG_X 1<<0
109: #define IIB_FLAG_N 1<<1
110: #define IIB_FLAG_Z 1<<2
111: #define IIB_FLAG_V 1<<3
112: #define IIB_FLAG_C 1<<4
113:
114: typedef struct {
115: t_mnemonic mnemonic;
116: const char *name;
117: } t_mnemonic_table;
118:
119: extern t_mnemonic_table mnemonic_table[];
120:
121: extern char *condition_table[];
122:
123: typedef union {
124: struct {
125: #ifndef BYTES_HIGHFIRST
126: unsigned int c:1;
127: unsigned int v:1;
128: unsigned int z:1;
129: unsigned int n:1;
130: unsigned int x:1;
131: unsigned int :3;
132: unsigned int i0:1;
133: unsigned int i1:1;
134: unsigned int i2:1;
135: unsigned int :2;
136: unsigned int s:1;
137: unsigned int :1;
138: unsigned int t:1;
139: #else
140: unsigned int t:1;
141: unsigned int :1;
142: unsigned int s:1;
143: unsigned int :2;
144: unsigned int i2:1;
145: unsigned int i1:1;
146: unsigned int i0:1;
147: unsigned int :3;
148: unsigned int x:1;
149: unsigned int n:1;
150: unsigned int z:1;
151: unsigned int v:1;
152: unsigned int c:1;
153: #endif
154: } sr_struct;
155: uint16 sr_int;
156: } t_sr;
157:
158: typedef struct {
159: uint32 pc;
160: uint32 sp;
161: t_sr sr;
162: uint16 stop;
163: uint32 regs[16];
164: } t_regs;
165:
166: #define SR_CFLAG (1<<0)
167: #define SR_VFLAG (1<<1)
168: #define SR_ZFLAG (1<<2)
169: #define SR_NFLAG (1<<3)
170: #define SR_XFLAG (1<<4)
171: #define SR_SFLAG (1<<13)
172: #define SR_TFLAG (1<<15)
173:
174: #define LOG_DEBUG3(x) /* */
175: #define LOG_DEBUG2(x) /* */
176: #define LOG_DEBUG1(x) /* */
177: #define LOG_USER(x) ui_log_user ## x
178: #define LOG_VERBOSE(x) ui_log_verbose ## x
179: #define LOG_NORMAL(x) ui_log_normal ## x
180: #define LOG_CRITICAL(x) ui_log_critical ## x
181: #define LOG_REQUEST(x) ui_log_request ## x
182:
183: typedef struct {
184: uint8 *sprite; /* pointer to sprite data or NULL for end of list */
185: uint8 hplot; /* number of cells to plot */
186: sint16 hpos, vpos; /* -128 upwards, top left position */
187: uint16 hsize, vsize; /* 1 to 4 for 8 to 32 pixels */
188: sint16 hmax, vmax; /* bottom right position */
189: } t_spriteinfo;
190:
191: typedef enum {
192: pt_unknown, pt_game, pt_education
193: } t_prodtype;
194:
195: typedef struct {
196: char console[17];
197: char copyright[17];
198: char name_domestic[49];
199: char name_overseas[49];
200: t_prodtype prodtype;
201: char version[13];
202: uint16 checksum;
203: char memo[29];
204: char country[17];
205: uint8 flag_japan; /* old style JUE flags */
206: uint8 flag_usa;
207: uint8 flag_europe;
208: uint8 hardware; /* new style 4-bit bitmap, 0=japan,2=us,3=europe */
209: } t_cartinfo;
210:
211: extern t_cartinfo gen_cartinfo;
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.