summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/drivers/mephisto_montec.cpp
blob: bc2d7faf3901e0da805c4640289ee7d9bb24eac4 (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
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
// license:BSD-3-Clause
// copyright-holders:Sandro Ronco
// thanks-to:yoyo_chessboard
/**************************************************************************************************

    Mephisto Monte Carlo
    Mephisto Mega IV
    Mephisto Monte Carlo IV LE
    Mephisto Mondial II
    Mephisto Super Mondial
    Mephisto Super Mondial II

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


#include "emu.h"
#include "cpu/m6502/m65c02.h"
#include "machine/nvram.h"
#include "machine/mmboard.h"
#include "screen.h"
#include "speaker.h"
#include "softlist.h"

#include "bus/generic/slot.h"
#include "bus/generic/carts.h"

#include "mephisto_montec.lh"
#include "mephisto_megaiv.lh"
#include "mephisto_mondial2.lh"
#include "mephisto_smondial2.lh"


class mephisto_montec_state : public driver_device
{
public:
	mephisto_montec_state(const machine_config &mconfig, device_type type, const char *tag)
		: driver_device(mconfig, type, tag)
		, m_maincpu(*this, "maincpu")
		, m_board(*this, "board")
		, m_beeper(*this, "beeper")
		, m_keys(*this, "KEY.%u", 0)
	{ }


	DECLARE_READ8_MEMBER(montec_input_r);
	DECLARE_READ8_MEMBER(montec_nmi_ack_r);
	DECLARE_WRITE8_MEMBER(montec_nmi_ack_w);
	DECLARE_WRITE8_MEMBER(montec_mux_w);
	DECLARE_WRITE8_MEMBER(montec_led_w);
	DECLARE_WRITE8_MEMBER(montec_beeper_w);
	DECLARE_WRITE8_MEMBER(montec_lcd_data_w);
	DECLARE_WRITE8_MEMBER(montec_ldc_cs0_w);
	DECLARE_WRITE8_MEMBER(montec_ldc_cs1_w);
	DECLARE_WRITE8_MEMBER(montec_lcd_clk_w);

	DECLARE_READ8_MEMBER(megaiv_input_r);
	DECLARE_WRITE8_MEMBER(megaiv_led_w);

	DECLARE_WRITE8_MEMBER(smondial_board_mux_w);
	DECLARE_WRITE8_MEMBER(smondial_led_data_w);

	DECLARE_WRITE8_MEMBER(mondial2_input_mux_w);
	TIMER_DEVICE_CALLBACK_MEMBER(refresh_leds);

protected:
	virtual void machine_start() override;
	virtual void machine_reset() override;

private:
	required_device<cpu_device> m_maincpu;
	required_device<mephisto_board_device> m_board;
	required_device<beep_device> m_beeper;
	optional_ioport_array<2> m_keys;

	uint8_t m_lcd_mux;
	uint8_t m_input_mux;
	uint8_t m_leds_mux;
	uint8_t m_smondial_board_mux;

	struct display_t
	{
		uint8_t pos;
		int8_t  shift;
		uint8_t data;
		uint8_t bit;
	} m_display;
};


void mephisto_montec_state::machine_start()
{
	save_item(NAME(m_lcd_mux));
	save_item(NAME(m_input_mux));
	save_item(NAME(m_leds_mux));
	save_item(NAME(m_smondial_board_mux));
	save_item(NAME(m_display.pos));
	save_item(NAME(m_display.shift));
	save_item(NAME(m_display.data));
	save_item(NAME(m_display.bit));
}

void mephisto_montec_state::machine_reset()
{
	m_lcd_mux = 0x00;
	m_input_mux = 0x00;
	m_leds_mux = 0x00;
	m_smondial_board_mux = 0xff;

	m_display.pos = 0;
	m_display.shift = 0;
	m_display.data = 0;
	m_display.bit = 0;
}

WRITE8_MEMBER(mephisto_montec_state::montec_led_w)
{
	for(int i=0; i<4; i++)
		for(int j=0; j<4; j++)
			if (BIT(data, i))
				output().set_led_value(100 + i * 4 + j, BIT(data, 4 + j) ? 0 : 1);
}


WRITE8_MEMBER(mephisto_montec_state::montec_lcd_data_w)
{
	m_display.bit = BIT(data, 7);
}

WRITE8_MEMBER(mephisto_montec_state::montec_ldc_cs0_w)
{
	if (data)
		m_lcd_mux |= 0x01;
	else
		m_lcd_mux &= ~0x01;

	m_display.pos = 0;
	m_display.shift = -1;
	m_display.data = 0;
}

WRITE8_MEMBER(mephisto_montec_state::montec_ldc_cs1_w)
{
	if (data)
		m_lcd_mux |= 0x02;
	else
		m_lcd_mux &= ~0x02;

	m_display.pos = 0;
	m_display.shift = -1;
	m_display.data = 0;
}

WRITE8_MEMBER(mephisto_montec_state::montec_lcd_clk_w)
{
	if (data)
	{
		m_display.data <<= 1;
		m_display.data |= m_display.bit;
		m_display.shift++;
	}

	if (m_display.shift == 8)
	{
		if (m_lcd_mux & 0x01)   output().set_digit_value(0 + m_display.pos, BITSWAP8(m_display.data, 0,3,2,7,6,5,4,1));
		if (m_lcd_mux & 0x02)   output().set_digit_value(4 + m_display.pos, BITSWAP8(m_display.data, 0,3,2,7,6,5,4,1));

		m_display.shift = 0;
		m_display.pos = (m_display.pos + 1) & 3;
		m_display.data = 0;
	}
}


WRITE8_MEMBER(mephisto_montec_state::montec_mux_w)
{
	if (data)
		m_input_mux &= ~(1 << offset);
	else
		m_input_mux |= (1 << offset);
}

READ8_MEMBER(mephisto_montec_state::montec_input_r)
{
	if      (m_input_mux & 0x01)    return m_keys[1]->read();
	else if (m_input_mux & 0x02)    return m_keys[0]->read();

	return m_board->input_r(space, offset) ^ 0xff;
}

READ8_MEMBER(mephisto_montec_state::montec_nmi_ack_r)
{
	m_maincpu->set_input_line(INPUT_LINE_NMI, CLEAR_LINE);
	return 0;
}

WRITE8_MEMBER(mephisto_montec_state::montec_nmi_ack_w)
{
	m_maincpu->set_input_line(INPUT_LINE_NMI, CLEAR_LINE);
}

WRITE8_MEMBER(mephisto_montec_state::montec_beeper_w)
{
	m_beeper->set_state(BIT(data, 7) ? 0 : 1);
}

WRITE8_MEMBER(mephisto_montec_state::megaiv_led_w)
{
	if (m_leds_mux != m_board->mux_r(space, offset))
	{
		m_leds_mux = m_board->mux_r(space, offset);
		for (int i=0; i<8; i++)
		{
			if (!BIT(m_leds_mux, i))
			{
				output().set_led_value(100 + i, BIT(data, 0) | BIT(data, 1));
				output().set_led_value(0 + i, BIT(data, 2) | BIT(data, 3));
				output().set_led_value(8 + i, BIT(data, 4) | BIT(data, 5));
			}
		}
	}

	m_beeper->set_state(BIT(data, 7));
}

READ8_MEMBER(mephisto_montec_state::megaiv_input_r)
{
	if      (m_input_mux & 0x01)    return BIT(m_keys[1]->read(), 0 + offset) << 7;
	else if (m_input_mux & 0x02)    return BIT(m_keys[1]->read(), 4 + offset) << 7;
	else if (m_input_mux & 0x04)    return BIT(m_keys[0]->read(), 0 + offset) << 7;
	else if (m_input_mux & 0x08)    return BIT(m_keys[0]->read(), 4 + offset) << 7;

	return BIT(m_board->input_r(space, offset), offset) << 7;
}


static ADDRESS_MAP_START(montec_mem , AS_PROGRAM, 8, mephisto_montec_state )
	AM_RANGE( 0x0000, 0x1fff ) AM_RAM AM_SHARE("nvram")
	AM_RANGE( 0x2400, 0x2400 ) AM_READ(montec_input_r)
	AM_RANGE( 0x2800, 0x2800 ) AM_DEVWRITE("board", mephisto_board_device, mux_w)
	AM_RANGE( 0x2c00, 0x2c00 ) AM_DEVWRITE("board", mephisto_board_device, led_w)
	AM_RANGE( 0x3400, 0x3400 ) AM_WRITE(montec_led_w)
	AM_RANGE( 0x3000, 0x3001 ) AM_WRITE(montec_mux_w)
	AM_RANGE( 0x3002, 0x3002 ) AM_WRITE(montec_beeper_w)
	AM_RANGE( 0x3004, 0x3004 ) AM_WRITE(montec_lcd_data_w)
	AM_RANGE( 0x3005, 0x3005 ) AM_WRITE(montec_ldc_cs1_w)
	AM_RANGE( 0x3006, 0x3006 ) AM_WRITE(montec_lcd_clk_w)
	AM_RANGE( 0x3007, 0x3007 ) AM_WRITE(montec_ldc_cs0_w)
	AM_RANGE( 0x2000, 0x2000 ) AM_READWRITE(montec_nmi_ack_r, montec_nmi_ack_w)
	AM_RANGE( 0x8000, 0xffff ) AM_ROM
ADDRESS_MAP_END

static ADDRESS_MAP_START(megaiv_mem , AS_PROGRAM, 8, mephisto_montec_state )
	AM_RANGE( 0x0000, 0x1fff ) AM_RAM AM_SHARE("nvram")
	AM_RANGE( 0x2400, 0x2400 ) AM_WRITE(megaiv_led_w)
	AM_RANGE( 0x2800, 0x2800 ) AM_DEVWRITE("board", mephisto_board_device, mux_w)
	AM_RANGE( 0x2c00, 0x2c03 ) AM_WRITE(montec_mux_w) AM_READNOP
	AM_RANGE( 0x2c04, 0x2c04 ) AM_WRITE(montec_lcd_data_w)
	AM_RANGE( 0x2c05, 0x2c05 ) AM_WRITE(montec_ldc_cs1_w)
	AM_RANGE( 0x2c06, 0x2c06 ) AM_WRITE(montec_lcd_clk_w)
	AM_RANGE( 0x2c07, 0x2c07 ) AM_WRITE(montec_ldc_cs0_w)
	AM_RANGE( 0x3000, 0x3007 ) AM_READ(megaiv_input_r)
	AM_RANGE( 0x8000, 0xffff ) AM_ROM
ADDRESS_MAP_END


static ADDRESS_MAP_START(smondial2_mem , AS_PROGRAM, 8, mephisto_montec_state )
	AM_IMPORT_FROM(megaiv_mem)
	AM_RANGE( 0x4000, 0x7fff ) AM_DEVREAD("cartslot", generic_slot_device, read_rom)
ADDRESS_MAP_END


WRITE8_MEMBER(mephisto_montec_state::smondial_board_mux_w)
{
	if (data)
		m_smondial_board_mux &= ~(1 << offset);
	else
		m_smondial_board_mux |= (1 << offset);

	m_board->mux_w(space, offset, m_smondial_board_mux);

	for (int i=0; i<8; i++)
	{
		if (m_leds_mux & 0x03)      output().set_led_value(100 + i, BIT(m_smondial_board_mux, i) ? 0 : 1);
		if (m_leds_mux & 0x0c)      output().set_led_value(  8 + i, BIT(m_smondial_board_mux, i) ? 0 : 1);
		if (m_leds_mux & 0x30)      output().set_led_value(  0 + i, BIT(m_smondial_board_mux, i) ? 0 : 1);
	}
}

WRITE8_MEMBER(mephisto_montec_state::smondial_led_data_w)
{
	if (data & 0x80)
		m_leds_mux &= ~(1 << offset);
	else
		m_leds_mux |= (1 << offset);

	m_beeper->set_state(BIT(m_leds_mux, 7));
}

static ADDRESS_MAP_START(smondial_mem , AS_PROGRAM, 8, mephisto_montec_state )
	AM_RANGE( 0x0000, 0x1fff ) AM_RAM AM_SHARE("nvram")
	AM_RANGE( 0x4000, 0x4007 ) AM_READ(megaiv_input_r)
	AM_RANGE( 0x6400, 0x6407 ) AM_WRITE(smondial_led_data_w)
	AM_RANGE( 0x6800, 0x6807 ) AM_WRITE(smondial_board_mux_w)
	AM_RANGE( 0x6c00, 0x6c03 ) AM_WRITE(montec_mux_w)
	AM_RANGE( 0x6c04, 0x6c04 ) AM_WRITE(montec_lcd_data_w)
	AM_RANGE( 0x6c05, 0x6c05 ) AM_WRITE(montec_ldc_cs1_w)
	AM_RANGE( 0x6c06, 0x6c06 ) AM_WRITE(montec_lcd_clk_w)
	AM_RANGE( 0x6c07, 0x6c07 ) AM_WRITE(montec_ldc_cs0_w)
	AM_RANGE( 0x8000, 0xffff ) AM_ROM
ADDRESS_MAP_END

WRITE8_MEMBER(mephisto_montec_state::mondial2_input_mux_w)
{
	uint8_t leds_data = m_board->mux_r(space, offset);
	for (int i=0; i<8; i++)
	{
		if (!BIT(leds_data, i))
		{
			if (data & 0x10)	output().set_led_value(100 + i, 1);
			if (data & 0x20)	output().set_led_value(  8 + i, 1);
			if (data & 0x40)	output().set_led_value(  0 + i, 1);
		}
	}	

	m_input_mux = data ^ 0xff;
	m_beeper->set_state(BIT(data, 7));
}


static ADDRESS_MAP_START(mondial2_mem , AS_PROGRAM, 8, mephisto_montec_state )
	AM_RANGE( 0x0000, 0x07ff ) AM_RAM AM_SHARE("nvram")
	AM_RANGE( 0x2000, 0x2000 ) AM_WRITE(mondial2_input_mux_w)
	AM_RANGE( 0x2800, 0x2800 ) AM_DEVWRITE("board", mephisto_board_device, mux_w)
	AM_RANGE( 0x3000, 0x3007 ) AM_READ(megaiv_input_r)
	AM_RANGE( 0x8000, 0xffff ) AM_ROM
ADDRESS_MAP_END

TIMER_DEVICE_CALLBACK_MEMBER(mephisto_montec_state::refresh_leds)
{
	for (int i=0; i<8; i++)
	{
		output().set_led_value(0 + i, 0);
		output().set_led_value(8 + i, 0);
		output().set_led_value(100 + i, 0);
	}
}

static INPUT_PORTS_START( montec )
	PORT_START("KEY.0")
	PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD)        PORT_NAME("1 Pawn")   PORT_CODE(KEYCODE_1)
	PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD)        PORT_NAME("2 Knight") PORT_CODE(KEYCODE_2)
	PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYPAD)        PORT_NAME("3 Bishop") PORT_CODE(KEYCODE_3)
	PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYPAD)        PORT_NAME("4 Rook")   PORT_CODE(KEYCODE_4)
	PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYPAD)        PORT_NAME("5 Queen")  PORT_CODE(KEYCODE_5)
	PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYPAD)        PORT_NAME("6 King")   PORT_CODE(KEYCODE_6)
	PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYPAD)        PORT_NAME("7 Black")  PORT_CODE(KEYCODE_7)
	PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYPAD)        PORT_NAME("8 White")  PORT_CODE(KEYCODE_8)

	PORT_START("KEY.1")
	PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD)        PORT_NAME("9 Book")   PORT_CODE(KEYCODE_9) PORT_CODE(KEYCODE_B)
	PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD)        PORT_NAME("0 Pos")    PORT_CODE(KEYCODE_0) PORT_CODE(KEYCODE_O)
	PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYPAD)        PORT_NAME("Mem")      PORT_CODE(KEYCODE_M)
	PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYPAD)        PORT_NAME("Info")     PORT_CODE(KEYCODE_I)
	PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYPAD)        PORT_NAME("Clear")    PORT_CODE(KEYCODE_BACKSPACE)
	PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYPAD)        PORT_NAME("Level")    PORT_CODE(KEYCODE_L)
	PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYPAD)        PORT_NAME("Enter")    PORT_CODE(KEYCODE_ENTER)
	PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYPAD)        PORT_NAME("Reset")    PORT_CODE(KEYCODE_DEL)
INPUT_PORTS_END

static INPUT_PORTS_START( megaiv )
	PORT_START("KEY.0")
	PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("3 Bishop") PORT_CODE(KEYCODE_3)
	PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("7 Black")  PORT_CODE(KEYCODE_7)
	PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("Mem")      PORT_CODE(KEYCODE_M)
	PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("Enter")    PORT_CODE(KEYCODE_ENTER)
	PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("4 Rook")   PORT_CODE(KEYCODE_4)
	PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("8 White")  PORT_CODE(KEYCODE_8)
	PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("Info")     PORT_CODE(KEYCODE_I)
	PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("Reset")    PORT_CODE(KEYCODE_DEL)

	PORT_START("KEY.1")
	PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("1 Pawn")   PORT_CODE(KEYCODE_1)
	PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("5 Queen")  PORT_CODE(KEYCODE_5)
	PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("9 Book")   PORT_CODE(KEYCODE_9) PORT_CODE(KEYCODE_B)
	PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("Clear")    PORT_CODE(KEYCODE_BACKSPACE)
	PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("2 Knight") PORT_CODE(KEYCODE_2)
	PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("6 King")   PORT_CODE(KEYCODE_6)
	PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("0 Pos")    PORT_CODE(KEYCODE_0) PORT_CODE(KEYCODE_O)
	PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("Level")    PORT_CODE(KEYCODE_L)
INPUT_PORTS_END

static INPUT_PORTS_START( mondial2 )
	PORT_START("KEY.0")
	PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("Play")     PORT_CODE(KEYCODE_Y)
	PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("Pos")      PORT_CODE(KEYCODE_O)
	PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("Mem")      PORT_CODE(KEYCODE_M)
	PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("Info")     PORT_CODE(KEYCODE_I)
	PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("Clear")    PORT_CODE(KEYCODE_BACKSPACE)
	PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("Level")    PORT_CODE(KEYCODE_L)
	PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("Enter")    PORT_CODE(KEYCODE_ENTER)
	PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("Reset")    PORT_CODE(KEYCODE_DEL)

	PORT_START("KEY.1")
	PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("1 Pawn")   PORT_CODE(KEYCODE_1)
	PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("2 Knight") PORT_CODE(KEYCODE_2)
	PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("3 Bishop") PORT_CODE(KEYCODE_3)
	PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("4 Rook")   PORT_CODE(KEYCODE_4)
	PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("5 Queen")  PORT_CODE(KEYCODE_5)
	PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("6 King")   PORT_CODE(KEYCODE_6)
	PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("7 Black")  PORT_CODE(KEYCODE_7)
	PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("8 White")  PORT_CODE(KEYCODE_8)
INPUT_PORTS_END

static INPUT_PORTS_START( smondial2 )
	PORT_START("KEY.0")
	PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("3 Bishop") PORT_CODE(KEYCODE_3)
	PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("7 Black")  PORT_CODE(KEYCODE_7)
	PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("Pos")      PORT_CODE(KEYCODE_O)
	PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("Enter")    PORT_CODE(KEYCODE_ENTER)
	PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("4 Rook")   PORT_CODE(KEYCODE_4)
	PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("8 White")  PORT_CODE(KEYCODE_8)
	PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("Mem")      PORT_CODE(KEYCODE_M)
	PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("Reset")    PORT_CODE(KEYCODE_DEL)

	PORT_START("KEY.1")
	PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("1 Pawn")   PORT_CODE(KEYCODE_1)
	PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("5 Queen")  PORT_CODE(KEYCODE_5)
	PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("9 Help")   PORT_CODE(KEYCODE_9) PORT_CODE(KEYCODE_H)
	PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("Level")    PORT_CODE(KEYCODE_L)
	PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("2 Knight") PORT_CODE(KEYCODE_2)
	PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("6 King")   PORT_CODE(KEYCODE_6)
	PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("0 Info")   PORT_CODE(KEYCODE_0) PORT_CODE(KEYCODE_I)
	PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYPAD)        PORT_NAME("Clear")    PORT_CODE(KEYCODE_BACKSPACE)
INPUT_PORTS_END

static MACHINE_CONFIG_START( montec )
	MCFG_CPU_ADD("maincpu", M65C02, XTAL_4MHz)
	MCFG_CPU_PROGRAM_MAP( montec_mem )
	MCFG_CPU_PERIODIC_INT_DRIVER(mephisto_montec_state, nmi_line_assert, (double)XTAL_4MHz / (1 << 13))

	MCFG_NVRAM_ADD_0FILL("nvram")

	MCFG_SPEAKER_STANDARD_MONO("mono")
	MCFG_SOUND_ADD("beeper", BEEP, 3250)
	MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)

	MCFG_MEPHISTO_SENSORS_BOARD_ADD("board")

	MCFG_DEFAULT_LAYOUT(layout_mephisto_montec)
MACHINE_CONFIG_END

static MACHINE_CONFIG_DERIVED( monteciv, montec )
	MCFG_CPU_MODIFY("maincpu")
	MCFG_CPU_CLOCK( XTAL_8MHz )
MACHINE_CONFIG_END

static MACHINE_CONFIG_DERIVED( megaiv, montec )
	MCFG_CPU_MODIFY("maincpu")
	MCFG_CPU_CLOCK( XTAL_4_9152MHz )
	MCFG_CPU_PROGRAM_MAP(megaiv_mem)
	MCFG_CPU_PERIODIC_INT_DRIVER(mephisto_montec_state, nmi_line_pulse, (double)XTAL_4_9152MHz / (1 << 13))

	MCFG_DEVICE_REMOVE("board")
	MCFG_MEPHISTO_BUTTONS_BOARD_ADD("board")
	MCFG_MEPHISTO_BOARD_DISABLE_LEDS(true)
	MCFG_DEFAULT_LAYOUT(layout_mephisto_megaiv)
MACHINE_CONFIG_END

static MACHINE_CONFIG_DERIVED( mondial2, megaiv )
	MCFG_CPU_MODIFY("maincpu")
	MCFG_CPU_CLOCK( XTAL_2MHz )
	MCFG_CPU_PROGRAM_MAP(mondial2_mem)
	MCFG_CPU_PERIODIC_INT_DRIVER(mephisto_montec_state, nmi_line_pulse, (double)XTAL_2MHz / (1 << 12))

	MCFG_TIMER_DRIVER_ADD_PERIODIC("refresh_leds", mephisto_montec_state, refresh_leds, attotime::from_hz(10))
	MCFG_DEFAULT_LAYOUT(layout_mephisto_mondial2)
MACHINE_CONFIG_END

static MACHINE_CONFIG_DERIVED( smondial, megaiv )
	MCFG_CPU_MODIFY("maincpu")
	MCFG_CPU_CLOCK( XTAL_4MHz )
	MCFG_CPU_PROGRAM_MAP(smondial_mem)
	MCFG_CPU_PERIODIC_INT_DRIVER(mephisto_montec_state, nmi_line_pulse, (double)XTAL_4MHz / (1 << 13))
MACHINE_CONFIG_END

static MACHINE_CONFIG_DERIVED( smondial2, smondial )
	MCFG_CPU_MODIFY("maincpu")
	MCFG_CPU_PROGRAM_MAP(smondial2_mem)

	MCFG_GENERIC_CARTSLOT_ADD("cartslot", generic_plain_slot, "smondial2_cart")
	MCFG_SOFTWARE_LIST_ADD("cart_list", "smondial2")

	MCFG_DEFAULT_LAYOUT(layout_mephisto_smondial2)
MACHINE_CONFIG_END


ROM_START(megaiv)
	ROM_REGION(0x10000, "maincpu", 0)
	ROM_LOAD("megaiv.bin", 0x8000, 0x8000, CRC(dee355d2) SHA1(6bc79c0fb169020f017412f5f9696b9ecafbf99f))
ROM_END

ROM_START(monteciv)
	ROM_REGION(0x10000, "maincpu", 0)
	ROM_LOAD("mciv.bin", 0x8000, 0x8000, CRC(c4887694) SHA1(7f482d2a40fcb3125266e7a5407da315b4f9b49c))
ROM_END

ROM_START(montec)
	ROM_REGION(0x10000, "maincpu", 0)
	ROM_LOAD("mc.bin", 0x08000, 0x08000, CRC(05524da9) SHA1(bee2ffe09a27095f733584e0fb1203b95c23e17e))
ROM_END

ROM_START(smondial)
	ROM_REGION(0x10000, "maincpu", 0)
	ROM_LOAD("mephisto super mondial I.bin", 0x8000, 0x8000, CRC(c1d7d0a5) SHA1(d7f0da6938458c06925f0936e63915319144d7e0))
ROM_END

ROM_START(smondial2)
	ROM_REGION(0x10000, "maincpu", 0)
	ROM_LOAD("supermondial_II.bin", 0x8000, 0x8000, CRC(cd73df4a) SHA1(bad786074be613d7f48bf98b6fdf8178a4a85f5b))
ROM_END

ROM_START(mondial2)
	ROM_REGION(0x10000, "maincpu", 0)
	ROM_LOAD("mondial II 01 08 87 Morsch.bin", 0x8000, 0x8000, CRC(e5945ce6) SHA1(e75bbf9d54087271d9d46fb1de7634eb957f8db0))
ROM_END


/*    YEAR  NAME      PARENT   COMPAT  MACHINE    INPUT     CLASS                   INIT COMPANY             FULLNAME                      FLAGS */
CONS( 1986, smondial, 0,       0,      smondial,  megaiv,   mephisto_montec_state,  0,   "Hegener & Glaser", "Mephisto Super Mondial",     MACHINE_SUPPORTS_SAVE | MACHINE_CLICKABLE_ARTWORK )
CONS( 1987, montec,   0,       0,      montec,    montec,   mephisto_montec_state,  0,   "Hegener & Glaser", "Mephisto Monte Carlo",       MACHINE_SUPPORTS_SAVE | MACHINE_CLICKABLE_ARTWORK )
CONS( 1987, mondial2, 0,       0,      mondial2,  mondial2, mephisto_montec_state,  0,   "Hegener & Glaser", "Mephisto Mondial II",        MACHINE_SUPPORTS_SAVE | MACHINE_CLICKABLE_ARTWORK )
CONS( 1989, smondial2,0,       0,      smondial2, smondial2,mephisto_montec_state,  0,   "Hegener & Glaser", "Mephisto Super Mondial II",  MACHINE_SUPPORTS_SAVE | MACHINE_CLICKABLE_ARTWORK )
CONS( 1989, megaiv,   0,       0,      megaiv,    megaiv,   mephisto_montec_state,  0,   "Hegener & Glaser", "Mephisto Mega IV",           MACHINE_SUPPORTS_SAVE | MACHINE_CLICKABLE_ARTWORK )
CONS( 1990, monteciv, montec,  0,      monteciv,  montec,   mephisto_montec_state,  0,   "Hegener & Glaser", "Mephisto Monte Carlo IV LE", MACHINE_SUPPORTS_SAVE | MACHINE_CLICKABLE_ARTWORK )