1 // license:BSD-3-Clause
2 // copyright-holders:Fabio Priuli
3 /***********************************************************************************************************
4 
5 
6  M5 cart emulation
7 
8 
9  ***********************************************************************************************************/
10 
11 
12 #include "emu.h"
13 #include "rom.h"
14 
15 
16 //-------------------------------------------------
17 //  m5_rom_device - constructor
18 //-------------------------------------------------
19 
20 DEFINE_DEVICE_TYPE(M5_ROM_STD, m5_rom_device, "m5_rom", "M5 Standard ROM Carts")
21 DEFINE_DEVICE_TYPE(M5_ROM_RAM, m5_ram_device, "m5_ram", "M5 Expansion memory cart")
22 
23 
m5_rom_device(const machine_config & mconfig,device_type type,const char * tag,device_t * owner,uint32_t clock)24 m5_rom_device::m5_rom_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock)
25 	: device_t(mconfig, type, tag, owner, clock)
26 	, device_m5_cart_interface(mconfig, *this)
27 {
28 }
29 
m5_rom_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)30 m5_rom_device::m5_rom_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
31 	: m5_rom_device(mconfig, M5_ROM_STD, tag, owner, clock)
32 {
33 }
34 
35 
m5_ram_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)36 m5_ram_device::m5_ram_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
37 	: m5_rom_device(mconfig, M5_ROM_RAM, tag, owner, clock)
38 {
39 }
40 
41 
42 /*-------------------------------------------------
43  mapper specific handlers
44  -------------------------------------------------*/
45 
read_rom(offs_t offset)46 uint8_t m5_rom_device::read_rom(offs_t offset)
47 {
48 	if (offset < m_rom_size)
49 		return m_rom[offset];
50 	else
51 		return 0xff;
52 }
53 
read_ram(offs_t offset)54 uint8_t m5_ram_device::read_ram(offs_t offset)
55 {
56 	return m_ram[offset];
57 }
58 
write_ram(offs_t offset,uint8_t data)59 void m5_ram_device::write_ram(offs_t offset, uint8_t data)
60 {
61 	m_ram[offset] = data;
62 }
63