#ifndef _EMU68_STRUCT68_H_
#define _EMU68_STRUCT68_H_
#include "type68.h"
#define IO68_NO_INT (0x80000000)
#define REG68 (emu68->reg)
#define MEMMSK68 (emu68->memmsk)
typedef void (*memwfunc68_t)(emu68_t * const);
typedef void (*iomemfunc68_t)(io68_t * const);
typedef void (linefunc68_t)(emu68_t * const, int, int);
#ifndef EMU68_MONOLITIC
# define DECL_LINE68(N) \
void N(emu68_t * const emu68, int reg9, int reg0)
# define DECL_STATIC_LINE68(N) static DECL_LINE68(N)
#else
# define DECL_LINE68(N) \
static void N(emu68_t * const emu68, int reg9, int reg0)
# define DECL_STATIC_LINE68(N) DECL_LINE68(N)
#endif
typedef struct
{
int vector;
int level;
cycle68_t cycle;
} interrupt68_t;
struct io68_s
{
struct io68_s * next;
char name[32];
addr68_t addr_lo;
addr68_t addr_hi;
iomemfunc68_t r_byte;
iomemfunc68_t r_word;
iomemfunc68_t r_long;
iomemfunc68_t w_byte;
iomemfunc68_t w_word;
iomemfunc68_t w_long;
interrupt68_t* (*interrupt)(io68_t * const, const cycle68_t);
cycle68_t (*next_interrupt)(io68_t * const, const cycle68_t);
void (*adjust_cycle)(io68_t * const, const cycle68_t);
int (*reset)(io68_t * const);
void (*destroy)(io68_t * const);
emu68_t * emu68;
};
typedef struct
{
s32 d[8];
s32 a[8];
s32 usp;
s32 pc;
int sr;
} reg68_t;
#define REG68_D0_IDX 000
#define REG68_D1_IDX 001
#define REG68_D2_IDX 002
#define REG68_D3_IDX 003
#define REG68_D4_IDX 004
#define REG68_D5_IDX 005
#define REG68_D6_IDX 006
#define REG68_D7_IDX 007
#define REG68_DN_IDX(N) (N&7)
#define REG68_A0_IDX 010
#define REG68_A1_IDX 011
#define REG68_A2_IDX 012
#define REG68_A3_IDX 013
#define REG68_A4_IDX 014
#define REG68_A5_IDX 015
#define REG68_A6_IDX 016
#define REG68_A7_IDX 017
#define REG68_AN_IDX(N) (8+(N&7))
#define REG68_US_IDX 020
#define REG68_PC_IDX 021
#define REG68_SR_IDX 022
typedef int (*emu68_handler_t)(emu68_t* const emu68, int vector, void * cookie);
typedef struct {
addr68_t addr;
uint68_t count;
uint68_t reset;
} emu68_bp_t;
struct emu68_s {
char name[32];
char err[128][4];
int nerr;
reg68_t reg;
cycle68_t cycle;
uint68_t clock;
emu68_handler_t handler;
void * cookie;
int status;
uint68_t instructions;
addr68_t finish_sp;
int nio;
io68_t * iohead;
io68_t * interrupt_io;
io68_t * mapped_io[256];
addr68_t bus_addr;
int68_t bus_data;
int framechk;
u8 * chk;
emu68_bp_t breakpoints[16];
addr68_t memmsk;
int log2mem;
u8 mem[32];
};
static inline
void inl_setcycle68(emu68_t * const emu68, const cycle68_t n)
{
#ifdef EMU68CYCLE
emu68->cycle = n;
#endif
}
static inline
void inl_addcycle68(emu68_t * const emu68, const cycle68_t n)
{
#ifdef EMU68CYCLE
emu68->cycle += n;
#endif
}
#ifndef CUSTOM_ALLOC
# include <stdlib.h>
# define emu68_alloc(size) malloc(size)
# define emu68_free(size) free(size)
#endif
#endif