1 // license:BSD-3-Clause
2 // copyright-holders:Curt Coder
3 /**********************************************************************
4
5 Timeworks PARTNER 64 cartridge emulation
6
7 **********************************************************************/
8
9 /*
10
11 PCB Layout
12 ----------
13
14 |===========================|
15 |=| |
16 |=|LS05 LS09 LS00 HC74 |
17 |=| |
18 |=| |
19 |=| ROM RAM |
20 |=| LS133 |
21 |=| LS156 |
22 |=| |
23 |===========================|
24
25 ROM - General Instrument 27C128-25 16Kx8 EPROM "TIMEWORKS C-64 VER 2-16-87"
26 RAM - Sony CXK5864PN-15L 8Kx8 SRAM
27
28 */
29
30 #include "emu.h"
31 #include "partner.h"
32
33
34
35 //**************************************************************************
36 // DEVICE DEFINITIONS
37 //**************************************************************************
38
39 DEFINE_DEVICE_TYPE(C64_PARTNER, c64_partner_cartridge_device, "c64_partner", "C64 PARTNER 64 cartridge")
40
41
42 //-------------------------------------------------
43 // INPUT_PORTS( c64_partner )
44 //-------------------------------------------------
45
WRITE_LINE_MEMBER(c64_partner_cartridge_device::nmi_w)46 WRITE_LINE_MEMBER( c64_partner_cartridge_device::nmi_w )
47 {
48 if (!state && !m_a6 && !m_nmi)
49 {
50 m_slot->nmi_w(ASSERT_LINE);
51 m_nmi = 1;
52 }
53 }
54
55 static INPUT_PORTS_START( c64_partner )
56 PORT_START("NMI")
PORT_CODE(KEYCODE_F11)57 PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("Menu") PORT_CODE(KEYCODE_F11) PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, c64_partner_cartridge_device, nmi_w)
58 INPUT_PORTS_END
59
60
61 //-------------------------------------------------
62 // input_ports - device-specific input ports
63 //-------------------------------------------------
64
65 ioport_constructor c64_partner_cartridge_device::device_input_ports() const
66 {
67 return INPUT_PORTS_NAME( c64_partner );
68 }
69
70
71
72 //**************************************************************************
73 // LIVE DEVICE
74 //**************************************************************************
75
76 //-------------------------------------------------
77 // c64_partner_cartridge_device - constructor
78 //-------------------------------------------------
79
c64_partner_cartridge_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)80 c64_partner_cartridge_device::c64_partner_cartridge_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
81 device_t(mconfig, C64_PARTNER, tag, owner, clock),
82 device_c64_expansion_card_interface(mconfig, *this),
83 m_ram(*this, "ram"),
84 m_a0(1),
85 m_a6(1),
86 m_nmi(0)
87 {
88 }
89
90
91 //-------------------------------------------------
92 // device_start - device-specific startup
93 //-------------------------------------------------
94
device_start()95 void c64_partner_cartridge_device::device_start()
96 {
97 // allocate memory
98 m_ram.allocate(0x2000);
99 }
100
101
102 //-------------------------------------------------
103 // device_reset - device-specific reset
104 //-------------------------------------------------
105
device_reset()106 void c64_partner_cartridge_device::device_reset()
107 {
108 m_a0 = 1;
109 m_a6 = 1;
110
111 if (m_nmi && m_a6)
112 {
113 m_slot->nmi_w(CLEAR_LINE);
114 m_nmi = 0;
115 }
116 }
117
118
119 //-------------------------------------------------
120 // c64_cd_r - cartridge data read
121 //-------------------------------------------------
122
c64_cd_r(offs_t offset,uint8_t data,int sphi2,int ba,int roml,int romh,int io1,int io2)123 uint8_t c64_partner_cartridge_device::c64_cd_r(offs_t offset, uint8_t data, int sphi2, int ba, int roml, int romh, int io1, int io2)
124 {
125 if (!io1)
126 {
127 data = m_romh[offset & 0x3fff];
128 }
129
130 if (m_nmi && (offset == 0xfffa || offset == 0xfffb))
131 {
132 m_a0 = 1;
133 }
134
135 if (m_a0 && BIT(offset, 15))
136 {
137 switch ((offset >> 13) & 0x03)
138 {
139 case 0: case 3:
140 data = m_romh[offset & 0x3fff];
141 break;
142
143 case 1:
144 data = m_ram[offset & 0x1fff];
145 break;
146 }
147 }
148
149 return data;
150 }
151
152
153 //-------------------------------------------------
154 // c64_cd_w - cartridge data write
155 //-------------------------------------------------
156
c64_cd_w(offs_t offset,uint8_t data,int sphi2,int ba,int roml,int romh,int io1,int io2)157 void c64_partner_cartridge_device::c64_cd_w(offs_t offset, uint8_t data, int sphi2, int ba, int roml, int romh, int io1, int io2)
158 {
159 if (!io1)
160 {
161 m_a0 = BIT(offset, 0);
162 m_a6 = BIT(offset, 6);
163
164 if (m_nmi && m_a6)
165 {
166 m_slot->nmi_w(CLEAR_LINE);
167 m_nmi = 0;
168 }
169 }
170
171 if (m_a0 && BIT(offset, 15))
172 {
173 switch ((offset >> 13) & 0x03)
174 {
175 case 1:
176 m_ram[offset & 0x1fff] = data;
177 break;
178 }
179 }
180
181 if (m_nmi && (offset == 0xfffa || offset == 0xfffb))
182 {
183 m_a0 = 1;
184 }
185 }
186
187
188 //-------------------------------------------------
189 // c64_game_r - GAME read
190 //-------------------------------------------------
191
c64_game_r(offs_t offset,int sphi2,int ba,int rw)192 int c64_partner_cartridge_device::c64_game_r(offs_t offset, int sphi2, int ba, int rw)
193 {
194 int game = 1;
195
196 if (m_a0 && BIT(offset, 15))
197 {
198 switch ((offset >> 13) & 0x03)
199 {
200 case 0: case 1: case 3:
201 game = 0;
202 break;
203 }
204 }
205
206 // TODO if I/O1=0, GAME=0
207
208 return game;
209 }
210