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