Previous 199869 Revisions Next

r33199 Tuesday 4th November, 2014 at 17:18:28 UTC by hap
small cleanup to merlin.c, it is very similar to simon.c
I want to redo the merlin layout later, make it more similar/appealing.
[src/mess/drivers]merlin.c simon.c
[src/mess/layout]merlin.lay simon.lay

trunk/src/mess/drivers/merlin.c
r241710r241711
1/*
1/***************************************************************************
22
3    Parker Bros Merlin handheld computer game
3  Parker Bros Merlin handheld computer game
4  * TMS1100NLL MP3404A-N2 (has internal ROM)
5 
6  Other games assumed to be on similar hardware:
7  - Dr. Smith - by Tomy, released in Japan (basically a white version of Merlin,
8    let's assume for now that the ROM contents is identical)
9  - Master Merlin
10 
11  Another sequel, called Split Second, looks like different hardware.
412
5*/
613
14  TODO:
15  - accurate rc osc
16  - is the rom dump good?
17
18***************************************************************************/
19
720#include "emu.h"
821#include "cpu/tms0980/tms0980.h"
922#include "sound/speaker.h"
1023
11/* Layout */
1224#include "merlin.lh"
1325
26// master clock is a single stage RC oscillator: R=?, C=?
27#define MERLIN_RC_CLOCK (500000)
1428
29
1530class merlin_state : public driver_device
1631{
1732public:
1833   merlin_state(const machine_config &mconfig, device_type type, const char *tag)
1934      : driver_device(mconfig, type, tag),
20         m_speaker(*this, "speaker") ,
21      m_maincpu(*this, "maincpu") { }
35      m_maincpu(*this, "maincpu"),
36      m_button_matrix(*this, "O"),
37      m_speaker(*this, "speaker")
38   { }
2239
23   virtual void machine_start();
24
40   required_device<cpu_device> m_maincpu;
41   required_ioport_array<4> m_button_matrix;
2542   required_device<speaker_sound_device> m_speaker;
2643
44   UINT16 m_o;
45
2746   DECLARE_READ8_MEMBER(read_k);
2847   DECLARE_WRITE16_MEMBER(write_o);
2948   DECLARE_WRITE16_MEMBER(write_r);
3049
31protected:
32   UINT16  m_o;
33   UINT16  m_r;
34   required_device<cpu_device> m_maincpu;
50   virtual void machine_start();
3551};
3652
3753
38#define LOG 0
54/***************************************************************************
3955
56  I/O
4057
41static INPUT_PORTS_START( merlin )
42   PORT_START("O0")
43   PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_CODE(KEYCODE_0)     PORT_NAME("R0")  // R0
44   PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_BUTTON2) PORT_CODE(KEYCODE_1)     PORT_NAME("R1")  // R1
45   PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_BUTTON4) PORT_CODE(KEYCODE_3)     PORT_NAME("R3")  // R3
46   PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_BUTTON3) PORT_CODE(KEYCODE_2)     PORT_NAME("R2")  // R2
58***************************************************************************/
4759
48   PORT_START("O1")
49   PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_BUTTON5) PORT_CODE(KEYCODE_4)     PORT_NAME("R4")  // R4
50   PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_BUTTON6) PORT_CODE(KEYCODE_5)     PORT_NAME("R5")  // R5
51   PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_BUTTON8) PORT_CODE(KEYCODE_7)     PORT_NAME("R7")  // R7
52   PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_BUTTON7) PORT_CODE(KEYCODE_6)     PORT_NAME("R6")  // R6
60/* The keypad is a 4*4 matrix, connected like so:
5361
54   PORT_START("O2")
55   PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_BUTTON9) PORT_CODE(KEYCODE_8)     PORT_NAME("R8")  // R8
56   PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_BUTTON10) PORT_CODE(KEYCODE_9)     PORT_NAME("R9")  // R9
57   PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_BUTTON13) PORT_CODE(KEYCODE_S)     PORT_NAME("Same Game")  // SG - same game
58   PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_BUTTON11) PORT_CODE(KEYCODE_MINUS) PORT_NAME("R10")  // R10
59
60   PORT_START("O3")
61   PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_UNUSED)
62   PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_BUTTON15) PORT_CODE(KEYCODE_C)     PORT_NAME("Comp Turn")  // Comp Turn
63   PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_BUTTON14) PORT_CODE(KEYCODE_H)     PORT_NAME("Hit Me")  // Hit me
64   PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_BUTTON12) PORT_CODE(KEYCODE_N)     PORT_NAME("New Game")  // NG - new game
65
66INPUT_PORTS_END
67
68
69/*
70The keypad is a 4*4 matrix, connected like so:
71
7262       +----+  +----+  +----+  +----+
7363O0 o---| R0 |--| R1 |--| R2 |--| R3 |
7464       +----+  +----+  +----+  +----+
r241710r241711
8878          o       o       o       o
8979         K1      K2      K8      K4
9080
91SG = same game, CT = comp turn, NG = new game, HM = hit me
92*/
81SG = same game, CT = comp turn, NG = new game, HM = hit me */
9382
9483READ8_MEMBER(merlin_state::read_k)
9584{
96   UINT8 data = 0;
85   UINT8 k = 0;
86   
87   // read selected button rows
88   for (int i = 0; i < 4; i++)
89      if (m_o & (1 << i))
90         k |= m_button_matrix[i]->read();
9791
98   if (LOG)
99      logerror( "read_k\n" );
92   return k;
93}
10094
101   if ( m_o & 0x01 )
102   {
103      data |= ioport("O0")->read();
104   }
95WRITE16_MEMBER(merlin_state::write_o)
96{
97   // O0-O3: input mux
98   m_o = data;
10599
106   if ( m_o & 0x02 )
107   {
108      data |= ioport("O1")->read();
109   }
100   /* The speaker is connected to O4 through O6.  The 3 outputs are paralleled for
101   increased current driving capability.  They are passed thru a 220 ohm resistor
102   and then to the speaker, which has the other side grounded.  The software then
103   toggles these lines to make sounds and noises. (There is no audio generator
104   other than toggling it with a software delay between to make tones). */
105   m_speaker->level_w(m_o & 0x70);
106}
110107
111   if ( m_o & 0x04 )
112   {
113      data |= ioport("O2")->read();
114   }
108WRITE16_MEMBER(merlin_state::write_r)
109{
110   /* LEDs:
115111
116   if ( m_o & 0x08 )
117   {
118      data |= ioport("O3")->read();
119   }
120
121   return data;
112        R0
113   R1   R2   R3
114   R4   R5   R6
115   R7   R8   R9
116        R10
117   */
118   for (int i = 0; i < 11; i++)
119      output_set_lamp_value(i, data >> i & 1);
122120}
123121
124122
125/*
126The speaker is connected to O4 through O6.  The 3 outputs are paralleled for
127increased current driving capability.  They are passed thru a 220 ohm resistor
128and then to the speaker, which has the other side grounded.  The software then
129toggles these lines to make sounds and noises. (There is no audio generator
130other than toggling it with a software delay between to make tones).
131*/
132123
133WRITE16_MEMBER(merlin_state::write_o)
134{
135   if (LOG)
136      logerror( "write_o: write %02x\n", data );
124/***************************************************************************
137125
138   m_o = data;
126  Inputs
139127
140   m_speaker->level_w(m_o & 0x70);
141}
128***************************************************************************/
142129
130static INPUT_PORTS_START( merlin )
131   PORT_START("O.0")
132   PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_CODE(KEYCODE_0) PORT_NAME("Button R0")
133   PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_BUTTON2) PORT_CODE(KEYCODE_1) PORT_NAME("Button R1")
134   PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_BUTTON4) PORT_CODE(KEYCODE_3) PORT_NAME("Button R3")
135   PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_BUTTON3) PORT_CODE(KEYCODE_2) PORT_NAME("Button R2")
143136
144/*
137   PORT_START("O.1")
138   PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_BUTTON5) PORT_CODE(KEYCODE_4) PORT_NAME("Button R4")
139   PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_BUTTON6) PORT_CODE(KEYCODE_5) PORT_NAME("Button R5")
140   PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_BUTTON8) PORT_CODE(KEYCODE_7) PORT_NAME("Button R7")
141   PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_BUTTON7) PORT_CODE(KEYCODE_6) PORT_NAME("Button R6")
145142
146  LEDs:
143   PORT_START("O.2")
144   PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_BUTTON9) PORT_CODE(KEYCODE_8) PORT_NAME("Button R8")
145   PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_BUTTON10) PORT_CODE(KEYCODE_9) PORT_NAME("Button R9")
146   PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_BUTTON13) PORT_CODE(KEYCODE_S) PORT_NAME("Same Game")
147   PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_BUTTON11) PORT_CODE(KEYCODE_MINUS) PORT_NAME("Button R10")
147148
148      R0
149 R1   R2   R3
150 R4   R5   R6
151 R7   R8   R9
152      R10
149   PORT_START("O.3")
150   PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_UNUSED)
151   PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_BUTTON15) PORT_CODE(KEYCODE_C) PORT_NAME("Comp Turn")
152   PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_BUTTON14) PORT_CODE(KEYCODE_H) PORT_NAME("Hit Me")
153   PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_BUTTON12) PORT_CODE(KEYCODE_N) PORT_NAME("New Game")
154INPUT_PORTS_END
153155
154When that particular R output is high, that LED is on.
155*/
156156
157WRITE16_MEMBER(merlin_state::write_r)
158{
159   if (LOG)
160      logerror( "write_r: write %04x\n", data );
161157
162   m_r = data;
158/***************************************************************************
163159
164   output_set_value( "led_0",  BIT( m_r,  0 ) );
165   output_set_value( "led_1",  BIT( m_r,  1 ) );
166   output_set_value( "led_2",  BIT( m_r,  2 ) );
167   output_set_value( "led_3",  BIT( m_r,  3 ) );
168   output_set_value( "led_4",  BIT( m_r,  4 ) );
169   output_set_value( "led_5",  BIT( m_r,  5 ) );
170   output_set_value( "led_6",  BIT( m_r,  6 ) );
171   output_set_value( "led_7",  BIT( m_r,  7 ) );
172   output_set_value( "led_8",  BIT( m_r,  8 ) );
173   output_set_value( "led_9",  BIT( m_r,  9 ) );
174   output_set_value( "led_10", BIT( m_r, 10 ) );
175}
160  Machine Config
176161
162***************************************************************************/
177163
178164void merlin_state::machine_start()
179165{
166   m_o = 0;
180167   save_item(NAME(m_o));
181   save_item(NAME(m_r));
182168}
183169
184170
r241710r241711
193179
194180
195181static MACHINE_CONFIG_START( merlin, merlin_state )
196   MCFG_CPU_ADD( "maincpu", TMS1100, 500000 )  /* Clock may be wrong */
197   MCFG_TMS1XXX_OUTPUT_PLA( merlin_output_pla )
198   MCFG_TMS1XXX_READ_K( READ8( merlin_state, read_k ) )
199   MCFG_TMS1XXX_WRITE_O( WRITE16( merlin_state, write_o ) )
200   MCFG_TMS1XXX_WRITE_R( WRITE16( merlin_state, write_r ) )
201182
183   /* basic machine hardware */
184   MCFG_CPU_ADD( "maincpu", TMS1100, MERLIN_RC_CLOCK )
185   MCFG_TMS1XXX_OUTPUT_PLA(merlin_output_pla)
186   MCFG_TMS1XXX_READ_K(READ8( merlin_state, read_k))
187   MCFG_TMS1XXX_WRITE_O(WRITE16( merlin_state, write_o))
188   MCFG_TMS1XXX_WRITE_R(WRITE16( merlin_state, write_r))
189
202190   MCFG_DEFAULT_LAYOUT(layout_merlin)
203191
192   /* no video! */
193
194   /* sound hardware */
204195   MCFG_SPEAKER_STANDARD_MONO("mono")
205196   MCFG_SOUND_ADD("speaker", SPEAKER_SOUND, 0)
206197   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
207198MACHINE_CONFIG_END
208199
209200
201
202/***************************************************************************
203
204  Game driver(s)
205
206***************************************************************************/
207
210208ROM_START( merlin )
211209   ROM_REGION( 0x800, "maincpu", 0 )
212210   // This rom needs verification, that's why it is marked as a bad dump
r241710r241711
216214   ROM_LOAD( "mp3404", 0x0000, 0x800, BAD_DUMP CRC(7515a75d) SHA1(76ca3605d3fde1df62f79b9bb1f534c2a2ae0229) )
217215ROM_END
218216
219/***************************************************************************
220217
221  Game driver(s)
222
223***************************************************************************/
224
225/*    YEAR  NAME        PARENT  COMPAT  MACHINE     INPUT   INIT    COMPANY            FULLNAME      FLAGS */
226CONS( 1978, merlin,     0,      0,      merlin,     merlin, driver_device,  0,      "Parker Brothers", "Merlin", 0 )
218CONS( 1978, merlin, 0, 0, merlin, merlin, driver_device, 0, "Parker Brothers", "Merlin", GAME_SUPPORTS_SAVE )
trunk/src/mess/drivers/simon.c
r241710r241711
88  * TMS1000 (has internal ROM), SN75494 lamp driver
99 
1010  Newer revisions have a smaller 16-pin MB4850 chip instead of the TMS1000.
11  It has been decapped, but we couldn't yet find the internal ROM.
11  This one has been decapped too, but we couldn't yet find the internal ROM.
1212 
13  Other games assumed to be on similar hardware:
14  - Pocket Simon
15  - Super Simon
16 
1317
1418  TODO:
19  - accurate rc osc
1520  - where's the skill switch?
1621
1722***************************************************************************/
r241710r241711
2227
2328#include "simon.lh"
2429
30// master clock is a single stage RC oscillator: R=?, C=?
31// this is an approximation compared with old recordings
32#define SIMON_RC_CLOCK (330000)
2533
34
2635class simon_state : public driver_device
2736{
2837public:
r241710r241711
3746   required_ioport_array<3> m_button_matrix;
3847   required_device<speaker_sound_device> m_speaker;
3948
40   UINT16 m_o;
4149   UINT16 m_r;
4250
4351   DECLARE_READ8_MEMBER(read_k);
r241710r241711
4553   DECLARE_WRITE16_MEMBER(write_r);
4654
4755   virtual void machine_start();
48   virtual void machine_reset();
4956};
5057
5158
r241710r241711
5764
5865READ8_MEMBER(simon_state::read_k)
5966{
60   UINT8 ret = 0;
67   UINT8 k = 0;
6168   
6269   // read selected button rows
6370   for (int i = 0; i < 3; i++)
6471      if (m_r & (1 << i))
65         ret |= m_button_matrix[i]->read();
72         k |= m_button_matrix[i]->read();
6673
67   return ret;
74   return k;
6875}
6976
7077WRITE16_MEMBER(simon_state::write_r)
r241710r241711
8592WRITE16_MEMBER(simon_state::write_o)
8693{
8794   // N/C
88   m_o = data;
8995}
9096
9197
r241710r241711
125131
126132***************************************************************************/
127133
128void simon_state::machine_reset()
129{
130}
131
132134void simon_state::machine_start()
133135{
134   m_o = 0;
135136   m_r = 0;
136   
137   save_item(NAME(m_o));
138137   save_item(NAME(m_r));
139138}
140139
r241710r241711
152151static MACHINE_CONFIG_START( simon, simon_state )
153152
154153   /* basic machine hardware */
155   MCFG_CPU_ADD( "maincpu", TMS1000, 330000 ) // RC osc, approximation compared with recordings
154   MCFG_CPU_ADD( "maincpu", TMS1000, SIMON_RC_CLOCK )
156155   MCFG_TMS1XXX_OUTPUT_PLA(simon_output_pla)
157156   MCFG_TMS1XXX_READ_K(READ8(simon_state, read_k))
158157   MCFG_TMS1XXX_WRITE_O(WRITE16(simon_state, write_o))
r241710r241711
172171
173172/***************************************************************************
174173
175  Game drivers
174  Game driver(s)
176175
177176***************************************************************************/
178177
trunk/src/mess/layout/merlin.lay
r241710r241711
370370
371371      <!-- LEDs and number buttons -->
372372
373      <bezel name="led_0" element="led">
373      <bezel name="lamp0" element="led">
374374         <bounds x="100" y="20" width="20" height="10" />
375375      </bezel>
376      <bezel element="0" inputtag="O0" inputmask="0x01">
376      <bezel element="0" inputtag="O.0" inputmask="0x01">
377377         <bounds x="100" y="32" width="20" height="10" />
378378      </bezel>
379379
380      <bezel name="led_1" element="led">
380      <bezel name="lamp1" element="led">
381381         <bounds x="50" y="50" width="20" height="10" />
382382      </bezel>
383      <bezel element="1" inputtag="O0" inputmask="0x02">
383      <bezel element="1" inputtag="O.0" inputmask="0x02">
384384         <bounds x="50" y="62" width="20" height="10" />
385385      </bezel>
386386
387      <bezel name="led_2" element="led">
387      <bezel name="lamp2" element="led">
388388         <bounds x="100" y="50" width="20" height="10" />
389389      </bezel>
390      <bezel element="2" inputtag="O0" inputmask="0x08">
390      <bezel element="2" inputtag="O.0" inputmask="0x08">
391391         <bounds x="100" y="62" width="20" height="10" />
392392      </bezel>
393393
394      <bezel name="led_3" element="led">
394      <bezel name="lamp3" element="led">
395395         <bounds x="150" y="50" width="20" height="10" />
396396      </bezel>
397      <bezel element="3" inputtag="O0" inputmask="0x04">
397      <bezel element="3" inputtag="O.0" inputmask="0x04">
398398         <bounds x="150" y="62" width="20" height="10" />
399399      </bezel>
400400
401401
402      <bezel name="led_4" element="led">
402      <bezel name="lamp4" element="led">
403403         <bounds x="50" y="80" width="20" height="10" />
404404      </bezel>
405      <bezel element="4" inputtag="O1" inputmask="0x01">
405      <bezel element="4" inputtag="O.1" inputmask="0x01">
406406         <bounds x="50" y="92" width="20" height="10" />
407407      </bezel>
408408
409      <bezel name="led_5" element="led">
409      <bezel name="lamp5" element="led">
410410         <bounds x="100" y="80" width="20" height="10" />
411411      </bezel>
412      <bezel element="5" inputtag="O1" inputmask="0x02">
412      <bezel element="5" inputtag="O.1" inputmask="0x02">
413413         <bounds x="100" y="92" width="20" height="10" />
414414      </bezel>
415415
416      <bezel name="led_6" element="led">
416      <bezel name="lamp6" element="led">
417417         <bounds x="150" y="80" width="20" height="10" />
418418      </bezel>
419      <bezel element="6" inputtag="O1" inputmask="0x08">
419      <bezel element="6" inputtag="O.1" inputmask="0x08">
420420         <bounds x="150" y="92" width="20" height="10" />
421421      </bezel>
422422
423423
424      <bezel name="led_7" element="led">
424      <bezel name="lamp7" element="led">
425425         <bounds x="50" y="110" width="20" height="10" />
426426      </bezel>
427      <bezel element="7" inputtag="O1" inputmask="0x04">
427      <bezel element="7" inputtag="O.1" inputmask="0x04">
428428         <bounds x="50" y="122" width="20" height="10" />
429429      </bezel>
430      <bezel name="led_8" element="led">
430      <bezel name="lamp8" element="led">
431431         <bounds x="100" y="110" width="20" height="10" />
432432      </bezel>
433      <bezel element="8" inputtag="O2" inputmask="0x01">
433      <bezel element="8" inputtag="O.2" inputmask="0x01">
434434         <bounds x="100" y="122" width="20" height="10" />
435435      </bezel>
436      <bezel name="led_9" element="led">
436      <bezel name="lamp9" element="led">
437437         <bounds x="150" y="110" width="20" height="10" />
438438      </bezel>
439      <bezel element="9" inputtag="O2" inputmask="0x02">
439      <bezel element="9" inputtag="O.2" inputmask="0x02">
440440         <bounds x="150" y="122" width="20" height="10" />
441441      </bezel>
442442
443443
444      <bezel name="led_10" element="led">
444      <bezel name="lamp10" element="led">
445445         <bounds x="100" y="140" width="20" height="10" />
446446      </bezel>
447      <bezel element="10" inputtag="O2" inputmask="0x08">
447      <bezel element="10" inputtag="O.2" inputmask="0x08">
448448         <bounds x="100" y="152" width="20" height="10" />
449449      </bezel>
450450
451451
452452      <!-- Other buttons -->
453453
454      <bezel element="new_game" inputtag="O3" inputmask="0x08">
454      <bezel element="new_game" inputtag="O.3" inputmask="0x08">
455455         <bounds x="75" y="170" width="30" height="30" />
456456      </bezel>
457      <bezel element="same_game" inputtag="O2" inputmask="0x04">
457      <bezel element="same_game" inputtag="O.2" inputmask="0x04">
458458         <bounds x="125" y="170" width="30" height="30" />
459459      </bezel>
460460
461      <bezel element="hit_me" inputtag="O3" inputmask="0x04">
461      <bezel element="hit_me" inputtag="O.3" inputmask="0x04">
462462         <bounds x="75" y="210" width="30" height="30" />
463463      </bezel>
464      <bezel element="comp_turn" inputtag="O3" inputmask="0x02">
464      <bezel element="comp_turn" inputtag="O.3" inputmask="0x02">
465465         <bounds x="125" y="210" width="30" height="30" />
466466      </bezel>
467467   </view>
trunk/src/mess/layout/simon.lay
r241710r241711
4949      </disk>
5050      <disk state="1">
5151         <color red="0.8" green="0.25" blue="0.1" />
52         <bounds x="0.30" y="0.30" width="0.4" height="0.4" />
52         <bounds x="0.28" y="0.28" width="0.44" height="0.44" />
5353      </disk>
5454   </element>
5555   <element name="button_y" defstate="0">
r241710r241711
6060      </disk>
6161      <disk state="1">
6262         <color red="0.8" green="0.78" blue="0.1" />
63         <bounds x="0.30" y="0.30" width="0.4" height="0.4" />
63         <bounds x="0.28" y="0.28" width="0.44" height="0.44" />
6464      </disk>
6565   </element>
6666


Previous 199869 Revisions Next


© 1997-2024 The MAME Team