1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
|
// license:BSD-3-Clause
// copyright-holders:hap
/***************************************************************************
Midway's Submarine, game number 760
TODO:
- needs extensive interactive artwork
- discrete sound
- identify sensors
***************************************************************************/
#include "emu.h"
#include "cpu/z80/z80.h"
#include "machine/watchdog.h"
#include "submar.lh"
class submar_state : public driver_device
{
public:
submar_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag)
, m_maincpu(*this, "maincpu")
, m_motors(*this, "motor%u", 0U)
, m_lamps(*this, "lamp%u", 0U)
, m_solenoids(*this, "solenoid%u", 0U)
, m_digits(*this, "digit%u", 0U)
{ }
void submar(machine_config &config);
private:
virtual void machine_start() override;
uint8_t submar_sensor0_r();
uint8_t submar_sensor1_r();
void submar_motor_w(uint8_t data);
void submar_lamp_w(uint8_t data);
void submar_solenoid_w(uint8_t data);
void submar_sound_w(uint8_t data);
void submar_led_w(offs_t offset, uint8_t data);
void submar_irq_clear_w(uint8_t data);
void submar_map(address_map &map);
void submar_portmap(address_map &map);
required_device<cpu_device> m_maincpu;
output_finder<8> m_motors;
output_finder<8> m_lamps;
output_finder<8> m_solenoids;
output_finder<4> m_digits;
};
/***************************************************************************
I/O, Memorymap
***************************************************************************/
void submar_state::machine_start()
{
m_motors.resolve();
m_lamps.resolve();
m_solenoids.resolve();
m_digits.resolve();
}
uint8_t submar_state::submar_sensor0_r()
{
// ?
return 0;
}
uint8_t submar_state::submar_sensor1_r()
{
// ?
return (ioport("IN1")->read() & 0x70) | 0x8f;
}
void submar_state::submar_motor_w(uint8_t data)
{
// d0: torpedo follow
// d1: ship movement
// d2: n/c
// d3: torpedo timing
// d4: torpedo timing
// d5: target shipsink
// d6: stir water
// d7: n/c
for (int i = 0; i < 8; i++)
m_motors[i] = BIT(data, i);
}
void submar_state::submar_lamp_w(uint8_t data)
{
// d0: torpedo
// d1: target ship on water
// d2: target ship under water
// d3: explosion
// d4: extended play
// d5: game over
// d6: front ship hit
// d7: scenery
for (int i = 0; i < 8; i++)
m_lamps[i] = BIT(data, i);
}
void submar_state::submar_solenoid_w(uint8_t data)
{
// d0-d4: ship1-5
// d5-d7: n/c
for (int i = 0; i < 8; i++)
m_solenoids[i] = BIT(data, i);
}
void submar_state::submar_sound_w(uint8_t data)
{
// d0: torpedo
// d1: "summer"
// d2: ship hit
// d3: target ship hit
// d4: sonar circuit
// d5: sonar circuit
// d6: n/c
// d7: n/c
}
void submar_state::submar_led_w(offs_t offset, uint8_t data)
{
// 7447 (BCD to LED segment)
static constexpr uint8_t _7447_map[16] =
{ 0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7c,0x07,0x7f,0x67,0x58,0x4c,0x62,0x69,0x78,0x00 };
// 2 digits per write. port 4: time, port 5: score
m_digits[((offset << 1) & 2) | 0] = _7447_map[data >> 4];
m_digits[((offset << 1) & 2) | 1] = _7447_map[data & 0x0f];
}
void submar_state::submar_irq_clear_w(uint8_t data)
{
m_maincpu->set_input_line(0, CLEAR_LINE);
}
void submar_state::submar_map(address_map &map)
{
map.global_mask(0x7fff);
map(0x0000, 0x1fff).rom();
map(0x2000, 0x207f).ram();
}
void submar_state::submar_portmap(address_map &map)
{
map.global_mask(0xff);
map(0x00, 0x00).rw(FUNC(submar_state::submar_sensor0_r), FUNC(submar_state::submar_motor_w));
map(0x01, 0x01).rw(FUNC(submar_state::submar_sensor1_r), FUNC(submar_state::submar_lamp_w));
map(0x02, 0x02).w(FUNC(submar_state::submar_solenoid_w));
map(0x03, 0x03).portr("DSW").w(FUNC(submar_state::submar_sound_w));
map(0x04, 0x05).w(FUNC(submar_state::submar_led_w));
map(0x06, 0x06).w("watchdog", FUNC(watchdog_timer_device::reset_w));
map(0x07, 0x07).w(FUNC(submar_state::submar_irq_clear_w));
}
/***************************************************************************
Inputs
***************************************************************************/
static INPUT_PORTS_START( submar )
PORT_START("IN1")
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN1 )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_TILT )
PORT_START("DSW")
PORT_DIPNAME( 0x01, 0x01, DEF_STR( Coinage ) ) PORT_DIPLOCATION("SW:1")
PORT_DIPSETTING( 0x01, DEF_STR( 1C_1C ) )
PORT_DIPSETTING( 0x00, DEF_STR( 1C_2C ) )
PORT_DIPNAME( 0x02, 0x00, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("SW:2")
PORT_DIPSETTING( 0x02, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x0c, 0x00, "Extended Time" ) PORT_DIPLOCATION("SW:3,4")
PORT_DIPSETTING( 0x00, "15 seconds at 1000" ) PORT_CONDITION("DSW", 0x30, EQUALS, 0x00) // @ 60 seconds
PORT_DIPSETTING( 0x04, "15 seconds at 2000" ) PORT_CONDITION("DSW", 0x30, EQUALS, 0x00)
PORT_DIPSETTING( 0x08, "30 seconds at 2000" ) PORT_CONDITION("DSW", 0x30, EQUALS, 0x00)
PORT_DIPSETTING( 0x0c, "30 seconds at 3000" ) PORT_CONDITION("DSW", 0x30, EQUALS, 0x00)
PORT_DIPSETTING( 0x00, "15 seconds at 2000" ) PORT_CONDITION("DSW", 0x30, EQUALS, 0x10) // @ 70 seconds
PORT_DIPSETTING( 0x04, "15 seconds at 3000" ) PORT_CONDITION("DSW", 0x30, EQUALS, 0x10)
PORT_DIPSETTING( 0x08, "30 seconds at 3000" ) PORT_CONDITION("DSW", 0x30, EQUALS, 0x10)
PORT_DIPSETTING( 0x0c, "30 seconds at 4000" ) PORT_CONDITION("DSW", 0x30, EQUALS, 0x10)
PORT_DIPSETTING( 0x00, "15 seconds at 3000" ) PORT_CONDITION("DSW", 0x30, EQUALS, 0x20) // @ 80 seconds
PORT_DIPSETTING( 0x04, "15 seconds at 4000" ) PORT_CONDITION("DSW", 0x30, EQUALS, 0x20)
PORT_DIPSETTING( 0x08, "30 seconds at 4000" ) PORT_CONDITION("DSW", 0x30, EQUALS, 0x20)
PORT_DIPSETTING( 0x0c, "30 seconds at 5000" ) PORT_CONDITION("DSW", 0x30, EQUALS, 0x20)
PORT_DIPSETTING( 0x00, "15 seconds at 4000" ) PORT_CONDITION("DSW", 0x30, EQUALS, 0x30) // @ 90 seconds
PORT_DIPSETTING( 0x04, "15 seconds at 5000" ) PORT_CONDITION("DSW", 0x30, EQUALS, 0x30)
PORT_DIPSETTING( 0x08, "30 seconds at 5000" ) PORT_CONDITION("DSW", 0x30, EQUALS, 0x30)
PORT_DIPSETTING( 0x0c, "30 seconds at 6000" ) PORT_CONDITION("DSW", 0x30, EQUALS, 0x30)
PORT_DIPNAME( 0x30, 0x00, DEF_STR( Game_Time ) ) PORT_DIPLOCATION("SW:5,6")
PORT_DIPSETTING( 0x00, "60 seconds" )
PORT_DIPSETTING( 0x10, "70 seconds" )
PORT_DIPSETTING( 0x20, "80 seconds" )
PORT_DIPSETTING( 0x30, "90 seconds" )
PORT_DIPNAME( 0x40, 0x00, "Alignment Mode" ) PORT_DIPLOCATION("SW:7")
PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
PORT_DIPSETTING( 0x40, DEF_STR( On ) )
PORT_SERVICE_DIPLOC(0x80, IP_ACTIVE_HIGH, "SW:8" )
INPUT_PORTS_END
/***************************************************************************
Machine Config
***************************************************************************/
void submar_state::submar(machine_config &config)
{
/* basic machine hardware */
Z80(config, m_maincpu, XTAL(19'968'000)/8);
m_maincpu->set_periodic_int(FUNC(submar_state::irq0_line_assert), attotime::from_hz(124.675)); // 555 IC
m_maincpu->set_addrmap(AS_PROGRAM, &submar_state::submar_map);
m_maincpu->set_addrmap(AS_IO, &submar_state::submar_portmap);
WATCHDOG_TIMER(config, "watchdog");
/* no video! */
/* sound hardware */
//...
}
/***************************************************************************
Game drivers
***************************************************************************/
ROM_START( submar )
ROM_REGION( 0x10000, "maincpu", 0 )
ROM_LOAD( "sub.a1", 0x0000, 0x0800, CRC(bcef5db4) SHA1(8ae5099672fbdb7bcdc617e1f8cbc5435fbb738a) )
ROM_LOAD( "sub.a2", 0x0800, 0x0800, CRC(f5780dd0) SHA1(f775dd6f64a730a2fb6c9baf5787698434150bc5) )
ROM_END
GAMEL( 1979, submar, 0, submar, submar, submar_state, empty_init, ROT0, "Midway", "Submarine (Midway)", MACHINE_NO_SOUND | MACHINE_NOT_WORKING | MACHINE_MECHANICAL, layout_submar )
|