summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/odyssey2/test.cpp
blob: 60141698f3c8da09ff6cedef86f4df0bb204ba79 (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
// license:BSD-3-Clause
// copyright-holders:hap
/******************************************************************************

Videopac Service Test cartridge emulation

It's a standard 2KB ROM, the difference is that the PCB has a 7seg LED on it.
The program will still work fine if the 7seg is not hooked up (eg. O2_ROM_STD).

Test 1: press all joystick inputs
Test 4: type "NAGEL137"
(the other initial tests are automatic)

Hold UP to advance to next test.

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

#include "emu.h"
#include "test.h"

DEFINE_DEVICE_TYPE(O2_ROM_TEST, o2_test_device, "o2_test", "Videopac Service Test Cartridge")


//-------------------------------------------------
//  o2_test_device - constructor
//-------------------------------------------------

o2_test_device::o2_test_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) :
	device_t(mconfig, O2_ROM_TEST, tag, owner, clock),
	device_o2_cart_interface(mconfig, *this),
	m_digit_out(*this, "tc_digit")
{ }

void o2_test_device::device_start()
{
	m_digit_out.resolve();

	save_item(NAME(m_control));
	save_item(NAME(m_bus_data));
}

void o2_test_device::cart_init()
{
	if (m_rom_size != 0x800)
		fatalerror("o2_test_device: ROM size must be 2KB\n");
}


//-------------------------------------------------
//  mapper specific handlers
//-------------------------------------------------

void o2_test_device::write_p1(u8 data)
{
	u8 output = m_digit_out;

	// P10: latch digit segments
	if (m_control & ~data & 1)
		output = ~m_bus_data;

	// P11: digit DP
	m_digit_out = (output & 0x7f) | (~data << 6 & 0x80);

	m_control = data;
}