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

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: 
1.1.1.5 ! root       16: #if defined(linux)
        !            17:   #include <byteswap.h>
        !            18:   #define SWAP16(x) bswap_16((x))
        !            19:   #define SWAP32(x) bswap_32((x))
        !            20: #elif defined(__OpenBSD__)
        !            21:   #include <machine/endian.h>
        !            22:   #define SWAP16(x) bswap_16((x))
        !            23:   #define SWAP32(x) bswap_32((x))
        !            24: #else
        !            25:   #define SWAP16(y) (( ((y)>>8) & 0x00ff) | (( ((y)<<8) & 0xff00)))
        !            26:   #define SWAP32(y) (( ((y)>>24) & 0x000000ff) | \
        !            27:                    (((y) >> 8)  & 0x0000ff00) | \
        !            28:                    (((y) << 8)  & 0x00ff0000) | \
        !            29:           (((y) << 24) & 0xff000000) )
        !            30:   #warning "No native byte conversion"
        !            31: #endif
        !            32: 
        !            33: /*
        !            34:  * LOCENDIANxx takes data that came from a big endian source and converts it
        !            35:  * into the local endian.  On a big endian machine the data will already be
        !            36:  * loaded correctly, however on a little endian machine the processor will
        !            37:  * have loaded the data assuming little endian data, so we need to swap the
        !            38:  * byte ordering.
        !            39:  *
        !            40:  * LOCENDIANxxL takes data that came from a little endian source and
        !            41:  * converts it into the local endian.  This means that on a little endian
        !            42:  * machine the data will already be loaded correctly, however on a big
        !            43:  * endian machine the processor will have loaded the data assuming big endian
        !            44:  * data, so we need to swap the byte ordering.
        !            45:  *
        !            46:  * Both LOCENDIANxx and LOCENDIANxxL can be used in reverse - i.e. when
        !            47:  * you have data in local endian that you need to write in big (LOCENDIANxx)
        !            48:  * or little (LOCENDIANxxL) endian.
        !            49:  *
        !            50:  */
        !            51: 
1.1       root       52: #ifdef WORDS_BIGENDIAN
                     53: #define LOCENDIAN16(y) (y)
                     54: #define LOCENDIAN32(y) (y)
1.1.1.5 ! root       55: #define LOCENDIAN16L(y) SWAP16(y)
        !            56: #define LOCENDIAN32L(y) SWAP32(y)
        !            57: #define BYTES_HIGHFIRST 1
1.1       root       58: #else
1.1.1.5 ! root       59: #define LOCENDIAN16(y) SWAP16(y)
        !            60: #define LOCENDIAN32(y) SWAP32(y)
        !            61: #define LOCENDIAN16L(y) (y)
        !            62: #define LOCENDIAN32L(y) (y)
1.1       root       63: #endif
                     64: 
                     65: typedef enum {
                     66:   tp_src, tp_dst
                     67: } t_type;
                     68: 
                     69: typedef enum {
                     70:   sz_none, sz_byte, sz_word, sz_long
                     71: } t_size;
                     72: 
                     73: typedef enum {
                     74:   dt_Dreg, dt_Areg, dt_Aind, dt_Ainc, dt_Adec, dt_Adis, dt_Aidx,
                     75:   dt_AbsW, dt_AbsL, dt_Pdis, dt_Pidx,
                     76:   dt_ImmB, dt_ImmW, dt_ImmL, dt_ImmS,
                     77:   dt_Imm3, dt_Imm4, dt_Imm8, dt_Imm8s, dt_ImmV,
                     78:   dt_Ill
                     79: } t_datatype;
                     80: 
                     81: typedef enum {
                     82:   ea_Dreg, ea_Areg, ea_Aind, ea_Ainc, ea_Adec, ea_Adis, ea_Aidx,
                     83:   ea_AbsW, ea_AbsL, ea_Pdis, ea_Pidx, ea_Imm
                     84: } t_eatypes;
                     85: 
                     86: typedef enum {
                     87:   i_ILLG,
                     88:   i_OR, i_ORSR,
                     89:   i_AND, i_ANDSR,
                     90:   i_EOR, i_EORSR,
                     91:   i_SUB, i_SUBA, i_SUBX,
                     92:   i_ADD, i_ADDA, i_ADDX,
                     93:   i_MULU, i_MULS,
                     94:   i_CMP, i_CMPA,
                     95:   i_BTST, i_BCHG, i_BCLR, i_BSET,
                     96:   i_MOVE, i_MOVEA,
                     97:   i_MOVEPMR, i_MOVEPRM,
                     98:   i_MOVEFSR, i_MOVETSR,
                     99:   i_MOVEMRM, i_MOVEMMR,
                    100:   i_MOVETUSP, i_MOVEFUSP,
                    101:   i_NEG, i_NEGX, i_CLR, i_NOT,
                    102:   i_ABCD, i_SBCD, i_NBCD,
                    103:   i_SWAP,
                    104:   i_PEA, i_LEA,
                    105:   i_EXT, i_EXG,
                    106:   i_TST, i_TAS, i_CHK,
                    107:   i_TRAPV, i_TRAP, i_RESET, i_NOP, i_STOP,
                    108:   i_LINK, i_UNLK,
                    109:   i_RTE, i_RTS, i_RTR,
                    110:   i_JSR, i_JMP, i_Scc, i_SF, i_DBcc, i_DBRA, i_Bcc, i_BSR,
                    111:   i_DIVU, i_DIVS,
                    112:   i_ASR, i_LSR, i_ROXR, i_ROR,
                    113:   i_ASL, i_LSL, i_ROXL, i_ROL,
                    114:   i_LINE10, i_LINE15
                    115: } t_mnemonic;
                    116: 
                    117: typedef struct {
                    118:   uint16 mask;              /* mask of bits that are static */
                    119:   uint16 bits;              /* bit values corresponding to bits in mask */
                    120:   t_mnemonic mnemonic;      /* instruction mnemonic */
                    121:   struct {
                    122:     int priv:1;             /* instruction is privileged if set */
                    123:     int endblk:1;           /* instruction ends a block if set */
                    124:     int imm_notzero:1;      /* immediate data cannot be 0 (if applicable) */
                    125:     int used:5;             /* bitmap of XNZVC flags inspected */
                    126:     int set:5;              /* bitmap of XNZVC flags altered */
                    127:   } flags;
                    128:   t_size size;              /* size of instruction */
                    129:   t_datatype stype;         /* type of source */
                    130:   t_datatype dtype;         /* type of destination */
                    131:   unsigned int sbitpos:4;   /* bit pos of imm data or reg part of EA */
                    132:   unsigned int dbitpos:4;   /* reg part of EA */
                    133:   unsigned int immvalue;    /* if stype is ImmS this is the value */
                    134:   unsigned int cc;          /* condition code if mnemonic is Scc/Dbcc/Bcc */
                    135:   unsigned int funcnum;     /* function number for this instruction */
                    136:   unsigned int wordlen;     /* length in words of this instruction */
                    137:   unsigned int clocks;      /* number of external clock periods */
                    138: } t_iib;                    /* instruction information block */
                    139: 
                    140: #define IIB_FLAG_X 1<<0
                    141: #define IIB_FLAG_N 1<<1
                    142: #define IIB_FLAG_Z 1<<2
                    143: #define IIB_FLAG_V 1<<3
                    144: #define IIB_FLAG_C 1<<4
                    145: 
                    146: typedef struct {
                    147:   t_mnemonic mnemonic;
                    148:   const char *name;
                    149: } t_mnemonic_table;
                    150: 
                    151: extern t_mnemonic_table mnemonic_table[];
                    152: 
                    153: extern char *condition_table[];
                    154: 
                    155: typedef union {
                    156:   struct {
                    157: #ifndef BYTES_HIGHFIRST
                    158:     unsigned int c:1;
                    159:     unsigned int v:1;
                    160:     unsigned int z:1;
                    161:     unsigned int n:1;
                    162:     unsigned int x:1;
                    163:     unsigned int :3;
                    164:     unsigned int i0:1;
                    165:     unsigned int i1:1;
                    166:     unsigned int i2:1;
                    167:     unsigned int :2;
                    168:     unsigned int s:1;
                    169:     unsigned int :1;
                    170:     unsigned int t:1;
                    171: #else
                    172:     unsigned int t:1;
                    173:     unsigned int :1;
                    174:     unsigned int s:1;
                    175:     unsigned int :2;
                    176:     unsigned int i2:1;
                    177:     unsigned int i1:1;
                    178:     unsigned int i0:1;
                    179:     unsigned int :3;
                    180:     unsigned int x:1;
                    181:     unsigned int n:1;
                    182:     unsigned int z:1;
                    183:     unsigned int v:1;
                    184:     unsigned int c:1;
                    185: #endif
                    186:   } sr_struct;
                    187:   uint16 sr_int;
                    188: } t_sr;
                    189: 
                    190: typedef struct {
                    191:   uint32 pc;
                    192:   uint32 sp;
                    193:   t_sr sr;
                    194:   uint16 stop;
                    195:   uint32 regs[16];
1.1.1.2   root      196:   uint16 pending;
1.1       root      197: } t_regs;
                    198: 
                    199: #define SR_CFLAG (1<<0)
                    200: #define SR_VFLAG (1<<1)
                    201: #define SR_ZFLAG (1<<2)
                    202: #define SR_NFLAG (1<<3)
                    203: #define SR_XFLAG (1<<4)
                    204: #define SR_SFLAG (1<<13)
                    205: #define SR_TFLAG (1<<15)
                    206: 
1.1.1.5 ! root      207: /* Steve Snake / Charles MacDonald (msgid <[email protected]>) -
        !           208:  * TAS on Genesis 1 and 2 (but not 3) do not write back with TAS */
        !           209: #define BROKEN_TAS
        !           210: 
1.1.1.4   root      211: #ifdef NOLOGGING
                    212: #  define LOG_DEBUG3(x)   /* */
                    213: #  define LOG_DEBUG2(x)   /* */
                    214: #  define LOG_DEBUG1(x)   /* */
                    215: #  define LOG_USER(x)     /* */
                    216: #  define LOG_VERBOSE(x)  /* */
                    217: #  define LOG_NORMAL(x)   /* */
                    218: #  define LOG_CRITICAL(x) /* */
                    219: #  define LOG_REQUEST(x)  /* */
                    220: #else
                    221: #  define LOG_DEBUG3(x)   /* ui_log_debug3 ## x */
                    222: #  define LOG_DEBUG2(x)   /* ui_log_debug2 ## x */
                    223: #  define LOG_DEBUG1(x)   /* ui_log_debug1 ## x */
                    224: #  define LOG_USER(x)     ui_log_user ## x
                    225: #  define LOG_VERBOSE(x)  ui_log_verbose ## x
                    226: #  define LOG_NORMAL(x)   ui_log_normal ## x
                    227: #  define LOG_CRITICAL(x) ui_log_critical ## x
                    228: #  define LOG_REQUEST(x)  ui_log_request ## x
                    229: #endif
1.1       root      230: 
                    231: typedef struct {
                    232:   uint8 *sprite;       /* pointer to sprite data or NULL for end of list */
                    233:   uint8 hplot;         /* number of cells to plot */
                    234:   sint16 hpos, vpos;   /* -128 upwards, top left position */
                    235:   uint16 hsize, vsize; /* 1 to 4 for 8 to 32 pixels */
                    236:   sint16 hmax, vmax;   /* bottom right position */
                    237: } t_spriteinfo;
                    238: 
                    239: typedef enum {
                    240:   pt_unknown, pt_game, pt_education
                    241: } t_prodtype;
                    242: 
                    243: typedef struct {
                    244:   char console[17];
                    245:   char copyright[17];
                    246:   char name_domestic[49];
                    247:   char name_overseas[49];
                    248:   t_prodtype prodtype;
                    249:   char version[13];
                    250:   uint16 checksum;
                    251:   char memo[29];
                    252:   char country[17];
                    253:   uint8 flag_japan;  /* old style JUE flags */
                    254:   uint8 flag_usa;
                    255:   uint8 flag_europe;
                    256:   uint8 hardware;    /* new style 4-bit bitmap, 0=japan,2=us,3=europe */
                    257: } t_cartinfo;
                    258: 
1.1.1.4   root      259: typedef enum {
                    260:   musiclog_off, musiclog_gym, musiclog_gnm
                    261: } t_musiclog;
                    262: 
1.1       root      263: extern t_cartinfo gen_cartinfo;
1.1.1.4   root      264: 
                    265: extern unsigned int gen_quit;
                    266: extern unsigned int gen_debugmode;
                    267: extern unsigned int gen_loglevel;
                    268: extern unsigned int gen_autodetect;
1.1.1.5 ! root      269: extern unsigned int gen_modifiedrom;
1.1.1.4   root      270: extern t_musiclog gen_musiclog;
                    271: extern char gen_leafname[];

unix.superglobalmegacorp.com

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