Annotation of generator/hdr/generator.h, revision 1.1.1.2

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.