--- generator/hdr/generator.h 2020/03/04 04:47:02 1.1.1.4 +++ generator/hdr/generator.h 2020/03/04 04:47:14 1.1.1.5 @@ -13,23 +13,55 @@ void gen_reset(void); void gen_softreset(void); void gen_loadmemrom(const char *rom, int romlen); +#if defined(linux) + #include + #define SWAP16(x) bswap_16((x)) + #define SWAP32(x) bswap_32((x)) +#elif defined(__OpenBSD__) + #include + #define SWAP16(x) bswap_16((x)) + #define SWAP32(x) bswap_32((x)) +#else + #define SWAP16(y) (( ((y)>>8) & 0x00ff) | (( ((y)<<8) & 0xff00))) + #define SWAP32(y) (( ((y)>>24) & 0x000000ff) | \ + (((y) >> 8) & 0x0000ff00) | \ + (((y) << 8) & 0x00ff0000) | \ + (((y) << 24) & 0xff000000) ) + #warning "No native byte conversion" +#endif + +/* + * LOCENDIANxx takes data that came from a big endian source and converts it + * into the local endian. On a big endian machine the data will already be + * loaded correctly, however on a little endian machine the processor will + * have loaded the data assuming little endian data, so we need to swap the + * byte ordering. + * + * LOCENDIANxxL takes data that came from a little endian source and + * converts it into the local endian. This means that on a little endian + * machine the data will already be loaded correctly, however on a big + * endian machine the processor will have loaded the data assuming big endian + * data, so we need to swap the byte ordering. + * + * Both LOCENDIANxx and LOCENDIANxxL can be used in reverse - i.e. when + * you have data in local endian that you need to write in big (LOCENDIANxx) + * or little (LOCENDIANxxL) endian. + * + */ + #ifdef WORDS_BIGENDIAN #define LOCENDIAN16(y) (y) #define LOCENDIAN32(y) (y) +#define LOCENDIAN16L(y) SWAP16(y) +#define LOCENDIAN32L(y) SWAP32(y) +#define BYTES_HIGHFIRST 1 #else -#define LOCENDIAN16(y) ((((y)>>8)&0x00FF)+((((y)<<8)&0xFF00))) -#define LOCENDIAN32(y) ( (((y)>>24) & 0x000000FF) + \ - (((y)>>8) & 0x0000FF00) + \ - (((y)<<8) & 0x00FF0000) + \ - (((y)<<24) & 0xFF000000) ) +#define LOCENDIAN16(y) SWAP16(y) +#define LOCENDIAN32(y) SWAP32(y) +#define LOCENDIAN16L(y) (y) +#define LOCENDIAN32L(y) (y) #endif -#define SWAP16(y) ((((y)>>8)&0x00FF)+((((y)<<8)&0xFF00))) -#define SWAP32(y) ( (((y)>>24) & 0x000000FF) + \ - (((y)>>8) & 0x0000FF00) + \ - (((y)<<8) & 0x00FF0000) + \ - (((y)<<24) & 0xFF000000) ) - typedef enum { tp_src, tp_dst } t_type; @@ -172,6 +204,10 @@ typedef struct { #define SR_SFLAG (1<<13) #define SR_TFLAG (1<<15) +/* Steve Snake / Charles MacDonald (msgid <3C427237.3CEC@value.net>) - + * TAS on Genesis 1 and 2 (but not 3) do not write back with TAS */ +#define BROKEN_TAS + #ifdef NOLOGGING # define LOG_DEBUG3(x) /* */ # define LOG_DEBUG2(x) /* */ @@ -230,5 +266,6 @@ extern unsigned int gen_quit; extern unsigned int gen_debugmode; extern unsigned int gen_loglevel; extern unsigned int gen_autodetect; +extern unsigned int gen_modifiedrom; extern t_musiclog gen_musiclog; extern char gen_leafname[];