trunk/src/mess/drivers/merlin.c
r241711 | r241712 | |
13 | 13 | |
14 | 14 | TODO: |
15 | 15 | - accurate rc osc |
| 16 | - accurate speaker levels (tone pitch sounds good though) |
16 | 17 | - is the rom dump good? |
17 | 18 | |
18 | 19 | ***************************************************************************/ |
r241711 | r241712 | |
23 | 24 | |
24 | 25 | #include "merlin.lh" |
25 | 26 | |
26 | | // master clock is a single stage RC oscillator: R=?, C=? |
27 | | #define MERLIN_RC_CLOCK (500000) |
| 27 | // master clock is a single stage RC oscillator: R=27K, C=100pf |
| 28 | // this is an approximation compared with recordings |
| 29 | #define MERLIN_RC_CLOCK (355000) |
28 | 30 | |
29 | 31 | |
30 | 32 | class merlin_state : public driver_device |
r241711 | r241712 | |
37 | 39 | m_speaker(*this, "speaker") |
38 | 40 | { } |
39 | 41 | |
| 42 | DECLARE_READ8_MEMBER(read_k); |
| 43 | DECLARE_WRITE16_MEMBER(write_o); |
| 44 | DECLARE_WRITE16_MEMBER(write_r); |
| 45 | |
| 46 | virtual void machine_start(); |
| 47 | |
| 48 | protected: |
40 | 49 | required_device<cpu_device> m_maincpu; |
41 | 50 | required_ioport_array<4> m_button_matrix; |
42 | 51 | required_device<speaker_sound_device> m_speaker; |
43 | 52 | |
44 | 53 | UINT16 m_o; |
45 | | |
46 | | DECLARE_READ8_MEMBER(read_k); |
47 | | DECLARE_WRITE16_MEMBER(write_o); |
48 | | DECLARE_WRITE16_MEMBER(write_r); |
49 | | |
50 | | virtual void machine_start(); |
51 | 54 | }; |
52 | 55 | |
53 | 56 | |
r241711 | r241712 | |
94 | 97 | |
95 | 98 | WRITE16_MEMBER(merlin_state::write_o) |
96 | 99 | { |
97 | | // O0-O3: input mux |
98 | | m_o = data; |
99 | | |
100 | 100 | /* The speaker is connected to O4 through O6. The 3 outputs are paralleled for |
101 | 101 | increased current driving capability. They are passed thru a 220 ohm resistor |
102 | 102 | and then to the speaker, which has the other side grounded. The software then |
103 | 103 | toggles these lines to make sounds and noises. (There is no audio generator |
104 | 104 | other than toggling it with a software delay between to make tones). */ |
105 | | m_speaker->level_w(m_o & 0x70); |
| 105 | static const int count[8] = { 0, 1, 1, 2, 1, 2, 2, 3 }; |
| 106 | m_speaker->level_w(count[data >> 4 & 7]); |
| 107 | |
| 108 | // O0-O3: input mux |
| 109 | // O7: N/C |
| 110 | m_o = data; |
106 | 111 | } |
107 | 112 | |
108 | 113 | WRITE16_MEMBER(merlin_state::write_r) |
r241711 | r241712 | |
177 | 182 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 |
178 | 183 | }; |
179 | 184 | |
| 185 | static const INT16 speaker_levels[] = { 0, 32767, 0, 32767 }; // unknown too, due to output_pla being unknown |
180 | 186 | |
| 187 | |
181 | 188 | static MACHINE_CONFIG_START( merlin, merlin_state ) |
182 | 189 | |
183 | 190 | /* basic machine hardware */ |
r241711 | r241712 | |
194 | 201 | /* sound hardware */ |
195 | 202 | MCFG_SPEAKER_STANDARD_MONO("mono") |
196 | 203 | MCFG_SOUND_ADD("speaker", SPEAKER_SOUND, 0) |
| 204 | MCFG_SPEAKER_LEVELS(4, speaker_levels) |
197 | 205 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) |
198 | 206 | MACHINE_CONFIG_END |
199 | 207 | |