summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/drivers/30test.cpp
blob: d71a001498a5222c9420d8871a6172ab66979133 (plain) (blame)
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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
// license:BSD-3-Clause
// copyright-holders:Angelo Salese, hap
/***************************************************************************

30 Test (サーティテスト) (c) 1997 Namco, game code M125
This is a remake, the original version was from 1970 and didn't have a CPU.

driver by Angelo Salese

Hardware notes:
- MC68HC11K1
- M6295
- X1 1.056MHz
- OSC1 16.000MHz

TODO:
- inputs are annoying to map (just use the clickable artwork)
- EEPROM in MCU

============================================================================

cheats:
- [0xb0-0xb3] timer

lamps:
- [0x81] really OK! (91+) - 超OKっすよ!!
- [0x82] pretty good (80+) - かなりィ⤴っすヨ
- [0x84] not bad (70+) - あっい〜じゃん
- [0x88] normal (55+) - ふつう
- [0x90] pretty bad (40+) - ちょいたり
- [0xa0] worst (39 or less) - サイテ〜
- [0xe0] game over - ゲームオーバー

settings stored in EEPROM:
- [0xd90] coins per credit (default 0x01)
- [0xd91] games per credit (default 0x02)
- [0xd99] time per game (default 0x0c, 12 seconds)
- [0xda9] language (default 0x03) - 0 = English, 1 = Chinese, 2 = Korean, 3 = Japanese

0xd90-0xda8 can also be changed in-game by holding service coin and then entering
testmode (hold 9, press F2). Voice language cannot be changed here though.

***************************************************************************/

#include "emu.h"
#include "cpu/mc68hc11/mc68hc11.h"
#include "sound/okim6295.h"
#include "speaker.h"

#include "30test.lh"


class namco_30test_state : public driver_device
{
public:
	namco_30test_state(const machine_config &mconfig, device_type type, const char *tag) :
		driver_device(mconfig, type, tag),
		m_maincpu(*this, "maincpu"),
		m_oki(*this, "oki"),
		m_inputs(*this, "IN%u", 0),
		m_digits(*this, "digit%u", 0U),
		m_lamps(*this, "lamp%u", 0U)
	{ }

	void namco_30test(machine_config &config);

protected:
	virtual void machine_start() override;

private:
	required_device<mc68hc11_cpu_device> m_maincpu;
	required_device<okim6295_device> m_oki;
	required_ioport_array<4> m_inputs;
	output_finder<72> m_digits;
	output_finder<8> m_lamps;

	void main_map(address_map &map);

	void output_digit(int i, u8 data);
	void led_w(offs_t offset, u8 data);
	void led_rank_w(offs_t offset, u8 data);
	void lamps_w(u8 data);
	u8 mux_r();
	void coin_w(u8 data);
	void mux_w(u8 data);
	void okibank_w(u8 data);

	u8 m_mux_data = 0;
};

void namco_30test_state::machine_start()
{
	m_digits.resolve();
	m_lamps.resolve();

	save_item(NAME(m_mux_data));
}



/******************************************************************************
    I/O
******************************************************************************/

void namco_30test_state::output_digit(int i, u8 data)
{
	// assume it's using a 7448
	static const u8 led_map[16] =
		{ 0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7c,0x07,0x7f,0x67,0x58,0x4c,0x62,0x69,0x78,0x00 };

	m_digits[i] = led_map[data & 0xf];
}

void namco_30test_state::led_w(offs_t offset, u8 data)
{
	// 0-29: playfield
	// 30,31: time
	output_digit(offset * 2, data >> 4);
	output_digit(1 + offset * 2,  data & 0x0f);
}

void namco_30test_state::led_rank_w(offs_t offset, u8 data)
{
	// 0: 1st place
	// 1: 2nd place
	// 2: 3rd place
	// 3: current / last play score
	output_digit(64 + offset * 2, data >> 4);
	output_digit(65 + offset * 2, data & 0x0f);
}

void namco_30test_state::lamps_w(u8 data)
{
	// d0-d5: ranking, d6: game over, d7: assume marquee lamp
	for (int i = 0; i < 8; i++)
		m_lamps[i] = BIT(data, i);
}

void namco_30test_state::coin_w(u8 data)
{
	// d2: coincounter
	machine().bookkeeping().coin_counter_w(0, BIT(data, 2));

	// d3/d4: ticket dispenser
	// other: ?
}

u8 namco_30test_state::mux_r()
{
	u8 data = 0xff;

	for (int i = 0; i < 4; i++)
	{
		if (BIT(m_mux_data, i))
			data &= m_inputs[i]->read();
	}

	return data;
}

void namco_30test_state::mux_w(u8 data)
{
	m_mux_data = data;
}

void namco_30test_state::okibank_w(u8 data)
{
	m_oki->set_rom_bank(data & 1);
}



/******************************************************************************
    Address Maps
******************************************************************************/

void namco_30test_state::main_map(address_map &map)
{
	map(0x0d80, 0x0dbf).ram(); // EEPROM read-back data goes there
	map(0x2000, 0x2000).rw(m_oki, FUNC(okim6295_device::read), FUNC(okim6295_device::write));
	map(0x4000, 0x401f).w(FUNC(namco_30test_state::led_w));
	map(0x6000, 0x6003).w(FUNC(namco_30test_state::led_rank_w));
	map(0x6004, 0x6004).w(FUNC(namco_30test_state::lamps_w));
	map(0x8000, 0xffff).rom();
}



/******************************************************************************
    Input Ports
******************************************************************************/

static INPUT_PORTS_START( 30test )
	PORT_START("IN0")
	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Button 1-1")
	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Button 1-2")
	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Button 1-3")
	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Button 1-4")
	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Button 1-5")
	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Button 1-6")
	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Button 2-1")
	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Button 2-2")

	PORT_START("IN1")
	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Button 2-3")
	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Button 2-4")
	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Button 2-5")
	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Button 2-6")
	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Button 3-1")
	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Button 3-2")
	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Button 3-3")
	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Button 3-4")

	PORT_START("IN2")
	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Button 3-5")
	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Button 3-6")
	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Button 4-1")
	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Button 4-2")
	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Button 4-3")
	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Button 4-4")
	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Button 4-5")
	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Button 4-6")

	PORT_START("IN3")
	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Button 5-1")
	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Button 5-2")
	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Button 5-3")
	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Button 5-4")
	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Button 5-5")
	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Button 5-6")
	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )

	PORT_START("SYSTEM")
	PORT_SERVICE( 0x01, IP_ACTIVE_LOW )
	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SERVICE1 ) // service coin + also used in testmode
	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN1 )
	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_SERVICE2 ) // ticket dispenser
	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE3 ) // used in testmode to advance test
	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
INPUT_PORTS_END



/******************************************************************************
    Machine Configs
******************************************************************************/

void namco_30test_state::namco_30test(machine_config &config)
{
	/* basic machine hardware */
	MC68HC11K1(config, m_maincpu, 16_MHz_XTAL);
	m_maincpu->set_addrmap(AS_PROGRAM, &namco_30test_state::main_map);
	m_maincpu->in_pa_callback().set(FUNC(namco_30test_state::mux_r));
	m_maincpu->out_pd_callback().set(FUNC(namco_30test_state::coin_w));
	m_maincpu->in_pe_callback().set_ioport("SYSTEM");
	m_maincpu->out_pg_callback().set(FUNC(namco_30test_state::okibank_w));
	m_maincpu->out_ph_callback().set(FUNC(namco_30test_state::mux_w));

	/* no video hardware */

	/* sound hardware */
	SPEAKER(config, "mono").front_center();

	OKIM6295(config, m_oki, 1.056_MHz_XTAL, okim6295_device::PIN7_HIGH);
	m_oki->add_route(ALL_OUTPUTS, "mono", 1.0);
}



/******************************************************************************
    ROM Definitions
******************************************************************************/

ROM_START( 30test )
	ROM_REGION( 0x10000, "maincpu", 0 )
	ROM_LOAD( "tt1-mpr0b.8p",   0x0000, 0x10000, CRC(455043d5) SHA1(46b15324d193ee621beabce92c0dc493b608b8dd) )

	ROM_REGION( 0x80000, "oki", 0 )
	ROM_LOAD( "tt1-voi0.7p",   0x0000, 0x80000, CRC(b4fc5921) SHA1(92a88d5adb50dae48715847f12e88a35e37ef78c) )
ROM_END



/******************************************************************************
    Drivers
******************************************************************************/

/*     YEAR  NAME    PARENT  MACHINE       INPUT   CLASS               INIT        MONITOR  COMPANY, FULLNAME, FLAGS */
GAMEL( 1997, 30test, 0,      namco_30test, 30test, namco_30test_state, empty_init, ROT0,    "Namco", "30 Test (remake)", MACHINE_SUPPORTS_SAVE | MACHINE_CLICKABLE_ARTWORK, layout_30test )