1 // license:BSD-3-Clause
2 // copyright-holders:Curt Coder
3 /**********************************************************************
4 
5     Ross cartridge emulation
6 
7 **********************************************************************/
8 
9 #include "emu.h"
10 #include "ross.h"
11 
12 
13 
14 //**************************************************************************
15 //  DEVICE DEFINITIONS
16 //**************************************************************************
17 
18 DEFINE_DEVICE_TYPE(C64_ROSS, c64_ross_cartridge_device, "c64_ross", "C64 Ross cartridge")
19 
20 
21 
22 //**************************************************************************
23 //  LIVE DEVICE
24 //**************************************************************************
25 
26 //-------------------------------------------------
27 //  c64_ross_cartridge_device - constructor
28 //-------------------------------------------------
29 
c64_ross_cartridge_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)30 c64_ross_cartridge_device::c64_ross_cartridge_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
31 	device_t(mconfig, C64_ROSS, tag, owner, clock),
32 	device_c64_expansion_card_interface(mconfig, *this), m_bank(0)
33 {
34 }
35 
36 
37 //-------------------------------------------------
38 //  device_start - device-specific startup
39 //-------------------------------------------------
40 
device_start()41 void c64_ross_cartridge_device::device_start()
42 {
43 	// state saving
44 	save_item(NAME(m_bank));
45 }
46 
47 
48 //-------------------------------------------------
49 //  device_reset - device-specific reset
50 //-------------------------------------------------
51 
device_reset()52 void c64_ross_cartridge_device::device_reset()
53 {
54 	m_exrom = 0;
55 	m_game = 0;
56 
57 	m_bank = 0;
58 }
59 
60 
61 //-------------------------------------------------
62 //  c64_cd_r - cartridge data read
63 //-------------------------------------------------
64 
c64_cd_r(offs_t offset,uint8_t data,int sphi2,int ba,int roml,int romh,int io1,int io2)65 uint8_t c64_ross_cartridge_device::c64_cd_r(offs_t offset, uint8_t data, int sphi2, int ba, int roml, int romh, int io1, int io2)
66 {
67 	if (!roml || !romh)
68 	{
69 		offs_t addr = (m_bank << 14) | (offset & 0x3fff);
70 
71 		data = m_roml[addr & m_roml.mask()];
72 	}
73 
74 	return data;
75 }
76 
77 
78 //-------------------------------------------------
79 //  c64_cd_w - cartridge data write
80 //-------------------------------------------------
81 
c64_cd_w(offs_t offset,uint8_t data,int sphi2,int ba,int roml,int romh,int io1,int io2)82 void c64_ross_cartridge_device::c64_cd_w(offs_t offset, uint8_t data, int sphi2, int ba, int roml, int romh, int io1, int io2)
83 {
84 	if (!io1)
85 	{
86 		m_bank = 1;
87 	}
88 	else if (!io2)
89 	{
90 		m_exrom = 1;
91 		m_game = 1;
92 	}
93 }
94