summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/drivers/lms46.cpp
blob: 718f5d2e28de94bee78181f6cceb7f26beb57d89 (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
// license:BSD-3-Clause
// copyright-holders:AJR
/******************************************************************************

    Skeleton driver for Litek LMS46 SBC.

    No additional information is known about this system.

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

#include "emu.h"
#include "cpu/z80/z80.h"
#include "machine/msm5832.h"

class lms46_state : public driver_device
{
public:
	lms46_state(const machine_config &mconfig, device_type type, const char *tag)
		: driver_device(mconfig, type, tag)
		, m_maincpu(*this, "maincpu")
		, m_rtc(*this, "rtc")
	{
	}

	void lms46(machine_config &mconfig);

private:
	u8 rtc_r(offs_t offset);
	void rtc_w(offs_t offset, u8 data);
	u8 busy_r();
	void misc_control_w(u8 data);

	void mem_map(address_map &map);
	void io_map(address_map &map);

	required_device<cpu_device> m_maincpu;
	required_device<msm5832_device> m_rtc;
};


u8 lms46_state::rtc_r(offs_t offset)
{
	m_rtc->cs_w(1);
	m_rtc->read_w(1);
	m_rtc->address_w(offset);
	u8 data = m_rtc->data_r();
	m_rtc->read_w(0);
	m_rtc->cs_w(0);
	return data;
}

void lms46_state::rtc_w(offs_t offset, u8 data)
{
	m_rtc->cs_w(1);
	m_rtc->address_w(offset);
	m_rtc->data_w(data & 0x0f);
	m_rtc->write_w(1);
	m_rtc->write_w(0);
	m_rtc->cs_w(0);
}

u8 lms46_state::busy_r()
{
	// Code loops endlessly until bit 0 clears
	return 0;
}

void lms46_state::misc_control_w(u8 data)
{
	m_rtc->hold_w(BIT(data, 5));
}

void lms46_state::mem_map(address_map &map)
{
	map(0x0000, 0x3fff).rom().region("bios", 0).nopw();
	map(0x8000, 0x87ff).ram(); // possibly NVRAM
	map(0x8800, 0x8fff).ram();
}

void lms46_state::io_map(address_map &map)
{
	map.global_mask(0xff);
	map(0x00, 0x0f).rw(FUNC(lms46_state::rtc_r), FUNC(lms46_state::rtc_w));
	map(0x10, 0x10).r(FUNC(lms46_state::busy_r));
	map(0x20, 0x20).w(FUNC(lms46_state::misc_control_w));
	map(0x30, 0x30).nopr(); // Watchdog reset? (value unused)
}


static INPUT_PORTS_START(lms46)
INPUT_PORTS_END

void lms46_state::lms46(machine_config &config)
{
	Z80(config, m_maincpu, 4000000);
	m_maincpu->set_addrmap(AS_PROGRAM, &lms46_state::mem_map);
	m_maincpu->set_addrmap(AS_IO, &lms46_state::io_map);

	MSM5832(config, m_rtc, 32768);
}


ROM_START(lms46)
	ROM_REGION(0x4000, "bios", 0)
	// Original dump has been extensively hand-patched between 0000 and 00EB where bit 3 was stuck high.
	// More single-bit errors in this area are likely, and some current guesses might be wrong.
	// Code organization also suggests the use of two separate 8K ROMs rather than one 16K ROM.
	ROM_LOAD("lms4002.rom", 0x0000, 0x4000, CRC(d9bc2384) SHA1(979038c53f5611bb9078d6a44e1c521093207881) BAD_DUMP)
ROM_END


COMP(1988, lms46, 0, 0, lms46, lms46, lms46_state, empty_init, "Litek Information Systems", "LMS46-V9", MACHINE_IS_SKELETON)