--- generator/hdr/generator.h 2020/03/04 04:46:28 1.1 +++ generator/hdr/generator.h 2020/03/04 04:47:14 1.1.1.5 @@ -1,35 +1,67 @@ -#include "config.h" +#include "../config.h" #include "machine.h" -#define VERSTRING "v0.15" -#define PROGNAME generator -#define FNAME_TCLSCRIPT SHAREDIR "/gen.tcl" -#define FNAME_GEN68K_CPU_OUT "out/cpu68k-%x.c" +/* VERSION set by autoconf */ +/* PACKAGE set by autoconf */ + #define GEN_RAMLENGTH 64*1024 #define LEN_IPCLISTTABLE 16*1024 char *gen_loadimage(const char *filename); -char *gen_loadsavepos(const char *filename); void gen_reset(void); +void gen_softreset(void); +void gen_loadmemrom(const char *rom, int romlen); -extern unsigned int gen_quit; -extern unsigned int gen_debugmode; -extern unsigned int gen_loglevel; +#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))) - typedef enum { tp_src, tp_dst } t_type; @@ -161,6 +193,7 @@ typedef struct { t_sr sr; uint16 stop; uint32 regs[16]; + uint16 pending; } t_regs; #define SR_CFLAG (1<<0) @@ -171,14 +204,29 @@ typedef struct { #define SR_SFLAG (1<<13) #define SR_TFLAG (1<<15) -#define LOG_DEBUG3(x) /* */ -#define LOG_DEBUG2(x) /* */ -#define LOG_DEBUG1(x) /* */ -#define LOG_USER(x) ui_log_user ## x -#define LOG_VERBOSE(x) ui_log_verbose ## x -#define LOG_NORMAL(x) ui_log_normal ## x -#define LOG_CRITICAL(x) ui_log_critical ## x -#define LOG_REQUEST(x) ui_log_request ## x +/* 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) /* */ +# define LOG_DEBUG1(x) /* */ +# define LOG_USER(x) /* */ +# define LOG_VERBOSE(x) /* */ +# define LOG_NORMAL(x) /* */ +# define LOG_CRITICAL(x) /* */ +# define LOG_REQUEST(x) /* */ +#else +# define LOG_DEBUG3(x) /* ui_log_debug3 ## x */ +# define LOG_DEBUG2(x) /* ui_log_debug2 ## x */ +# define LOG_DEBUG1(x) /* ui_log_debug1 ## x */ +# define LOG_USER(x) ui_log_user ## x +# define LOG_VERBOSE(x) ui_log_verbose ## x +# define LOG_NORMAL(x) ui_log_normal ## x +# define LOG_CRITICAL(x) ui_log_critical ## x +# define LOG_REQUEST(x) ui_log_request ## x +#endif typedef struct { uint8 *sprite; /* pointer to sprite data or NULL for end of list */ @@ -208,4 +256,16 @@ typedef struct { uint8 hardware; /* new style 4-bit bitmap, 0=japan,2=us,3=europe */ } t_cartinfo; +typedef enum { + musiclog_off, musiclog_gym, musiclog_gnm +} t_musiclog; + extern t_cartinfo gen_cartinfo; + +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[];