/***************************************************************************

	memintrf.c

	Memory interace

***************************************************************************/

#ifndef	MEMINTRF_H
#define MEMINTRF_H

#define READ8_HANDLER(name) 	u8 name(u32 offset)
#define WRITE8_HANDLER(name) 	void name(u32 offset, u8 data)
#define READ16_HANDLER(name)	u16 name(u32 offset, u16 mem_mask)
#define WRITE16_HANDLER(name)	void name(u32 offset, u16 data, u16 mem_mask)
#define READ32_HANDLER(name)	u32 name(u32 offset)
#define WRITE32_HANDLER(name)	void name(u32 offset, u32 data)

/* ----- 16/32-bit memory accessing ----- */
#define COMBINE_DATA(varptr)		(*(varptr) = (*(varptr) & mem_mask) | (data & ~mem_mask))
#define COMBINE_SWABDATA(varptr)	(*(varptr) = (*(varptr) & (mem_mask << 8)) | (data & ~(mem_mask >> 8)))

/* ----- 16-bit memory accessing ----- */
#define ACCESSING_LSB			((mem_mask & 0x00ff) == 0)
#define ACCESSING_MSB			((mem_mask & 0xff00) == 0)


extern u8 *neogeo_prg_memory;
extern u8 *neogeo_z80_memory;
extern u8 *neogeo_fix_memory;
extern u8 *neogeo_spr_memory;
extern u8 *neogeo_pcm_memory;
extern u8 *neogeo_rom_memory;
extern u8 neogeo_memorycard[0x2000];

int memory_init(void);
void memory_shutdown(void);

u32 m68k_read_memory_8(u32 address);
u32 m68k_read_memory_16(u32 address);
u32 m68k_read_memory_32(u32 address);
void m68k_write_memory_8(u32 address, u32 value);
void m68k_write_memory_16(u32 address, u32 value);
void m68k_write_memory_32(u32 address, u32 value);

#ifndef MAME_Z80
u32 z80_read_memory_8(u32 address);
void z80_write_memory_8(u32 address, u32 data);
#endif

#endif /* MEMINTRF_H */
