|
|
1.1.1.3 root 1: #include "../config.h"
1.1 root 2: #include "machine.h"
3:
1.1.1.4 ! root 4: /* VERSION set by autoconf */
! 5: /* PACKAGE set by autoconf */
! 6:
1.1 root 7: #define GEN_RAMLENGTH 64*1024
8:
9: #define LEN_IPCLISTTABLE 16*1024
10:
11: char *gen_loadimage(const char *filename);
12: void gen_reset(void);
1.1.1.2 root 13: void gen_softreset(void);
1.1.1.4 ! root 14: void gen_loadmemrom(const char *rom, int romlen);
1.1 root 15:
16: #ifdef WORDS_BIGENDIAN
17: #define LOCENDIAN16(y) (y)
18: #define LOCENDIAN32(y) (y)
19: #else
20: #define LOCENDIAN16(y) ((((y)>>8)&0x00FF)+((((y)<<8)&0xFF00)))
21: #define LOCENDIAN32(y) ( (((y)>>24) & 0x000000FF) + \
22: (((y)>>8) & 0x0000FF00) + \
23: (((y)<<8) & 0x00FF0000) + \
24: (((y)<<24) & 0xFF000000) )
25: #endif
26:
27: #define SWAP16(y) ((((y)>>8)&0x00FF)+((((y)<<8)&0xFF00)))
1.1.1.2 root 28: #define SWAP32(y) ( (((y)>>24) & 0x000000FF) + \
29: (((y)>>8) & 0x0000FF00) + \
30: (((y)<<8) & 0x00FF0000) + \
31: (((y)<<24) & 0xFF000000) )
1.1 root 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];
1.1.1.2 root 164: uint16 pending;
1.1 root 165: } t_regs;
166:
167: #define SR_CFLAG (1<<0)
168: #define SR_VFLAG (1<<1)
169: #define SR_ZFLAG (1<<2)
170: #define SR_NFLAG (1<<3)
171: #define SR_XFLAG (1<<4)
172: #define SR_SFLAG (1<<13)
173: #define SR_TFLAG (1<<15)
174:
1.1.1.4 ! root 175: #ifdef NOLOGGING
! 176: # define LOG_DEBUG3(x) /* */
! 177: # define LOG_DEBUG2(x) /* */
! 178: # define LOG_DEBUG1(x) /* */
! 179: # define LOG_USER(x) /* */
! 180: # define LOG_VERBOSE(x) /* */
! 181: # define LOG_NORMAL(x) /* */
! 182: # define LOG_CRITICAL(x) /* */
! 183: # define LOG_REQUEST(x) /* */
! 184: #else
! 185: # define LOG_DEBUG3(x) /* ui_log_debug3 ## x */
! 186: # define LOG_DEBUG2(x) /* ui_log_debug2 ## x */
! 187: # define LOG_DEBUG1(x) /* ui_log_debug1 ## x */
! 188: # define LOG_USER(x) ui_log_user ## x
! 189: # define LOG_VERBOSE(x) ui_log_verbose ## x
! 190: # define LOG_NORMAL(x) ui_log_normal ## x
! 191: # define LOG_CRITICAL(x) ui_log_critical ## x
! 192: # define LOG_REQUEST(x) ui_log_request ## x
! 193: #endif
1.1 root 194:
195: typedef struct {
196: uint8 *sprite; /* pointer to sprite data or NULL for end of list */
197: uint8 hplot; /* number of cells to plot */
198: sint16 hpos, vpos; /* -128 upwards, top left position */
199: uint16 hsize, vsize; /* 1 to 4 for 8 to 32 pixels */
200: sint16 hmax, vmax; /* bottom right position */
201: } t_spriteinfo;
202:
203: typedef enum {
204: pt_unknown, pt_game, pt_education
205: } t_prodtype;
206:
207: typedef struct {
208: char console[17];
209: char copyright[17];
210: char name_domestic[49];
211: char name_overseas[49];
212: t_prodtype prodtype;
213: char version[13];
214: uint16 checksum;
215: char memo[29];
216: char country[17];
217: uint8 flag_japan; /* old style JUE flags */
218: uint8 flag_usa;
219: uint8 flag_europe;
220: uint8 hardware; /* new style 4-bit bitmap, 0=japan,2=us,3=europe */
221: } t_cartinfo;
222:
1.1.1.4 ! root 223: typedef enum {
! 224: musiclog_off, musiclog_gym, musiclog_gnm
! 225: } t_musiclog;
! 226:
1.1 root 227: extern t_cartinfo gen_cartinfo;
1.1.1.4 ! root 228:
! 229: extern unsigned int gen_quit;
! 230: extern unsigned int gen_debugmode;
! 231: extern unsigned int gen_loglevel;
! 232: extern unsigned int gen_autodetect;
! 233: extern t_musiclog gen_musiclog;
! 234: extern char gen_leafname[];
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.