1 // license:BSD-3-Clause
2 // copyright-holders:Curt Coder
3 /**********************************************************************
4
5 Wersi Wersiboard Music 64 / Siel CMK 49 Keyboard emulation
6
7 **********************************************************************/
8
9 /*
10 5 PRINT "MUSIC 64 & CMK 49 TEST"
11 6 PRINT " BY CARLO MERLANO"
12 7 PRINT "PLAY THE MUSIC KEYBOARD!"
13 8 F1=65.4:POKE 54296,15
14 9 POKE 54277,25:POKE 54278,68
15 10 IF PE=255 THEN POKE 54276,0
16 20 FOR I=1 TO 8
17 30 PO=57087+I:PE=PEEK(PO)
18 40 IF PE<255 THEN GOSUB 100
19 50 NEXT I
20 60 GOTO 10
21 100 KK=LOG(255-PE)/LOG(2)+8*I-7
22 110 FKK=(2^(1/12))^(KK-1)*F1
23 120 N=FKK*16.3835
24 130 NHI=INT(N/256):NLO=N-NHI*256
25 140 POKE 54276,17
26 150 POKE 54273,NHI:POKE 54272,NLO
27 160 I=0
28 170 RETURN
29 */
30
31 #include "emu.h"
32 #include "music64.h"
33
34
35
36 //**************************************************************************
37 // DEVICE DEFINITIONS
38 //**************************************************************************
39
40 DEFINE_DEVICE_TYPE(C64_MUSIC64, c64_music64_cartridge_device, "c64_music64", "C64 Music 64 cartridge")
41
42
43 //-------------------------------------------------
44 // device_add_mconfig - add device configuration
45 //-------------------------------------------------
46
device_add_mconfig(machine_config & config)47 void c64_music64_cartridge_device::device_add_mconfig(machine_config &config)
48 {
49 C64_EXPANSION_SLOT(config, m_exp, DERIVED_CLOCK(1, 1), c64_expansion_cards, nullptr);
50 m_exp->set_passthrough();
51 }
52
53
54 //-------------------------------------------------
55 // INPUT_PORTS( c64_music64 )
56 //-------------------------------------------------
57
58 static INPUT_PORTS_START( c64_music64 )
59 PORT_START("KB0")
60 PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("C2")
61 PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("C#2")
62 PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("D")
63 PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("D#2")
64 PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("E2")
65 PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("F2")
66 PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("F#2")
67 PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("G2")
68
69 PORT_START("KB1")
70 PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("G#2")
71 PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("A3")
72 PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("A#3")
73 PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("B3")
74 PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("C3")
75 PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("C#3")
76 PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("D3")
77 PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("D#3")
78
79 PORT_START("KB2")
80 PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("E3")
81 PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("F3")
82 PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("F#3")
83 PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("G3")
84 PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("G#3")
85 PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("A4")
86 PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("A#4")
87 PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("B4")
88
89 PORT_START("KB3")
90 PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("C4")
91 PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("C#4")
92 PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("D4")
93 PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("D#4")
94 PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("E4")
95 PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("F4")
96 PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("F#4")
97 PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("G4")
98
99 PORT_START("KB4")
100 PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("G#4")
101 PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("A5")
102 PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("A#5")
103 PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("B5")
104 PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("C5")
105 PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("C#5")
106 PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("D5")
107 PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("D#5")
108
109 PORT_START("KB5")
110 PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("E5")
111 PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("F5")
112 PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("F#5")
113 PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("G5")
114 PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("G#5")
115 PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("A6")
116 PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("A#6")
117 PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("B6")
118
119 PORT_START("KB6")
120 PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("C6")
121 PORT_BIT( 0xfe, IP_ACTIVE_LOW, IPT_UNUSED )
122 INPUT_PORTS_END
123
124
125 //-------------------------------------------------
126 // input_ports - device-specific input ports
127 //-------------------------------------------------
128
device_input_ports() const129 ioport_constructor c64_music64_cartridge_device::device_input_ports() const
130 {
131 return INPUT_PORTS_NAME( c64_music64 );
132 }
133
134
135
136 //**************************************************************************
137 // LIVE DEVICE
138 //**************************************************************************
139
140 //-------------------------------------------------
141 // c64_music64_cartridge_device - constructor
142 //-------------------------------------------------
143
c64_music64_cartridge_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)144 c64_music64_cartridge_device::c64_music64_cartridge_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
145 device_t(mconfig, C64_MUSIC64, tag, owner, clock),
146 device_c64_expansion_card_interface(mconfig, *this),
147 m_exp(*this, "exp"),
148 m_kb(*this, "KB%u", 0)
149 {
150 }
151
152
153 //-------------------------------------------------
154 // device_start - device-specific startup
155 //-------------------------------------------------
156
device_start()157 void c64_music64_cartridge_device::device_start()
158 {
159 }
160
161
162 //-------------------------------------------------
163 // device_reset - device-specific reset
164 //-------------------------------------------------
165
device_reset()166 void c64_music64_cartridge_device::device_reset()
167 {
168 }
169
170
171 //-------------------------------------------------
172 // c64_cd_r - cartridge data read
173 //-------------------------------------------------
174
c64_cd_r(offs_t offset,uint8_t data,int sphi2,int ba,int roml,int romh,int io1,int io2)175 uint8_t c64_music64_cartridge_device::c64_cd_r(offs_t offset, uint8_t data, int sphi2, int ba, int roml, int romh, int io1, int io2)
176 {
177 data = m_exp->cd_r(offset, data, sphi2, ba, roml, romh, io1, io2);
178
179 if (!io2)
180 {
181 int kb = offset & 0x07;
182
183 if (kb < 7)
184 {
185 data = m_kb[kb]->read();
186 }
187 }
188
189 return data;
190 }
191
192
193 //-------------------------------------------------
194 // c64_cd_w - cartridge data write
195 //-------------------------------------------------
196
c64_cd_w(offs_t offset,uint8_t data,int sphi2,int ba,int roml,int romh,int io1,int io2)197 void c64_music64_cartridge_device::c64_cd_w(offs_t offset, uint8_t data, int sphi2, int ba, int roml, int romh, int io1, int io2)
198 {
199 m_exp->cd_w(offset, data, sphi2, ba, roml, romh, io1, io2);
200 }
201
202
203 //-------------------------------------------------
204 // c64_game_r - GAME read
205 //-------------------------------------------------
206
c64_game_r(offs_t offset,int sphi2,int ba,int rw)207 int c64_music64_cartridge_device::c64_game_r(offs_t offset, int sphi2, int ba, int rw)
208 {
209 return m_exp->game_r(offset, sphi2, ba, rw, m_slot->loram(), m_slot->hiram());
210 }
211
212
213 //-------------------------------------------------
214 // c64_exrom_r - EXROM read
215 //-------------------------------------------------
216
c64_exrom_r(offs_t offset,int sphi2,int ba,int rw)217 int c64_music64_cartridge_device::c64_exrom_r(offs_t offset, int sphi2, int ba, int rw)
218 {
219 return m_exp->exrom_r(offset, sphi2, ba, rw, m_slot->loram(), m_slot->hiram());
220 }
221