#ifndef Z8K_H

#include "cpuintrf.h"

enum {
	Z8001_PC=1, Z8001_UNUSED,
        Z8001_FCW, Z8001_PSAP, Z8001_REFRESH, Z8001_IRQ_REQ, 
	Z8001_R0, Z8001_R1, Z8001_R2, Z8001_R3,
	Z8001_R4, Z8001_R5, Z8001_R6, Z8001_R7,
	Z8001_R8, Z8001_R9, Z8001_R10, Z8001_R11,
	Z8001_R12, Z8001_R13, Z8001_R14, Z8001_R15,
        Z8001_R14N, Z8001_R14S, Z8001_R15N, Z8001_R15S
     };

/* Interrupt Types that can be generated by outside sources */
#define Z8001_EXTTRAP		0x8000	/* external instruction trap */
#define Z8001_SYSCALL		0x4000	/* system call (lsb is vector) */
#define Z8001_PRIVTRAP		0x2000	/* privileged instruction trap */
#define Z8001_NMI		0x1000	/* non maskable interrupt */
#define Z8001_SEGTRAP		0x0800	/* segment trap (Z8001) */
#define Z8001_VI		0x0400	/* vectored interrupt (LSB is vector)  */
#define Z8001_NVI		0x0200	/* non vectored interrupt */
#define Z8001_HALT		0x0100	/* halted flag  */

/* PUBLIC FUNCTIONS */
extern void z8001_get_info(UINT32 state, cpuinfo *info);

#ifdef ENABLE_DEBUGGER
offs_t z8001_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram);
#endif

////////////////////////////// Z8001 memory accessors to control MMU access and fast context dependent memory access /////
typedef struct {
     UINT16 (*nseg_sys_code)(UINT32 addr);                // Fetch Read Accessor - nonseg, system mode
     UINT16 (*nseg_usr_code)(UINT32 addr);                // Fetch Read Accessor - nonseg, user   mode
     UINT16 (*seg_sys_code)(UINT32 addr);                 // Fetch Read Accessor - segmented, system mode
     UINT16 (*seg_usr_code)(UINT32 addr);                 // Fetch Read Accessor - segmented, user   mode

     //////////////////////////////////////////////////////////////////////////////////////////////////////////////

     UINT8  (*nseg_sys_data_Br)(UINT32 addr);             // Data Byte Read Accessor - nonseg, system mode
     UINT8  (*nseg_usr_data_Br)(UINT32 addr);             // Data Byte Read Accessor - nonseg, user   mode
     UINT8  (*seg_sys_data_Br)(UINT32 addr);              // Data Byte Read Accessor - segmented, system mode
     UINT8  (*seg_usr_data_Br)(UINT32 addr);              // Data Byte Read Accessor - segmented, user   mode

     void (*nseg_sys_data_Bw)(UINT32 addr, UINT8 data);   // Data Byte Write Accessor - nonseg, system mode
     void (*nseg_usr_data_Bw)(UINT32 addr, UINT8 data);   // Data Byte Write Accessor - nonseg, user   mode
     void (*seg_sys_data_Bw)(UINT32 addr,  UINT8 data);   // Data Byte Write Accessor - segmented, system mode
     void (*seg_usr_data_Bw)(UINT32 addr,  UINT8 data);   // Data Byte Write Accessor - segmented, user   mode

     //////////////////////////////////////////////////////////////////////////////////////////////////////////////

     UINT16 (*nseg_sys_data_Wr)(UINT32 addr);             // Data Word Read Accessor - nonseg, system mode
     UINT16 (*nseg_usr_data_Wr)(UINT32 addr);             // Data Word Read Accessor - nonseg, user   mode
     UINT16 (*seg_sys_data_Wr)(UINT32 addr);              // Data Word Read Accessor - segmented, system mode
     UINT16 (*seg_usr_data_Wr)(UINT32 addr);              // Data Word Read Accessor - segmented, user   mode

     void (*nseg_sys_data_Ww)(UINT32 addr, UINT16 data);  // Data Word Write Accessor - nonseg, system mode
     void (*nseg_usr_data_Ww)(UINT32 addr, UINT16 data);  // Data Word Write Accessor - nonseg, user   mode
     void (*seg_sys_data_Ww)(UINT32 addr, UINT16 data);   // Data Word Write Accessor - segmented, system mode
     void (*seg_usr_data_Ww)(UINT32 addr, UINT16 data);   // Data Word Write Accessor - segmented, user   mode

     //////////////////////////////////////////////////////////////////////////////////////////////////////////////

     UINT32 (*nseg_sys_data_Lr)(UINT32 addr);             // Data DWord Read Accessor - nonseg, system mode
     UINT32 (*nseg_usr_data_Lr)(UINT32 addr);             // Data DWord Read Accessor - nonseg, user   mode
     UINT32 (*seg_sys_data_Lr)(UINT32 addr);              // Data DWord Read Accessor - segmented, system mode
     UINT32 (*seg_usr_data_Lr)(UINT32 addr);              // Data DWord Read Accessor - segmented, user   mode

     void (*nseg_sys_data_Lw)(UINT32 addr, UINT32 data);  // Data DWord Write Accessor - nonseg, system mode
     void (*nseg_usr_data_Lw)(UINT32 addr, UINT32 data);  // Data DWord Write Accessor - nonseg, user   mode
     void (*seg_sys_data_Lw)(UINT32 addr, UINT32 data);   // Data DWord Write Accessor - segmented, system mode
     void (*seg_usr_data_Lw)(UINT32 addr, UINT32 data);   // Data DWord Write Accessor - segmented, user   mode

} Z8001_accessors;

typedef struct {
    const cpufunc_translate translate;         /* Memory translate callback       */
} z8001_interface;

#define Z8001_MEM_ACCESSOR    0
#define Z8001_FCW_CHANGE_PTR  1

#endif /* Z8K_H */
