summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/drivers/snesb51.cpp
blob: cb9f054f26da9d54e5e887a12395fb7f9ee77e72 (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
// license: BSD-3-Clause
// copyright-holders: Dirk Best
/***************************************************************************

    SNES bootlegs controlled by an MCS-51 core

	Skeleton driver

	Currently there are dumps for a Mortal Kombat 3 board and a board with
	4 slots that supports various games directly and also has a generic
	timer based mode.

	Hardware (for the 4 slot switcher):
	- MCS-51 based CPU 44-pin (markings removed)
	- WD1016D-PL (?)
	- TC5565PL-15 (8k SRAM)
	- 12 MHz XTAL
	- 4 Position Dipswitch

	Connector pinout:

                 JAMMA                      P1 (from SNES)
    GND          A | 1           GND         1 - GND
    GND          B | 2           GND         2 -
    +5v          C | 3           +5v         3 -
    +5v          D | 4           +5v         4 -
    -5v          E | 5           -5v         5 -
    +12v         F | 6          +12v         6 -
                 H | 7                       7 -
                 J | 8                       8 -
                 K | 9                       9 -
    SND-         L | 10         SND+        10 -
    P2 Button R  M | 11  P1 Button R        11 -
    Video GREEN  N | 12    Video RED        12 -
    Video SYNC   P | 13   Video BLUE
                 R | 14    Video GND        P2 (unknown)
    P2 Button L  S | 15  P2 Button L        1 -
                 T | 16      Coin #1        2 -
    P2 Start     U | 17     P1 Start        3 -
    P2 Up        V | 18        P1 Up
    P2 Down      W | 19      P1 Down        P3 (unknown)
    P2 Left      X | 20      P1 Left        1 - +5v
    P2 Right     Y | 21     P1 Right        2 - GND
    P2 Button X  Z | 22  P1 Button X
    P2 Button Y  a | 23  P1 Button Y        P4 (unknown)
    P2 Button A  b | 24  P1 Button A        1 - +5v
    P2 Button B  c | 25  P1 Button B        2 -
    P2 Select    d | 26    P1 Select        3 -
    GND          e | 27          GND        4 -
    GND          f | 28          GND        5 - N/C
                                            6 -
    * Note - P5 ribbon to SNES controls     7 - GND

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

#include "emu.h"
#include "cpu/mcs51/mcs51.h"
#include "emupal.h"

class snesb51_state : public driver_device
{
public:
	snesb51_state(const machine_config &mconfig, device_type type, const char *tag) :
		driver_device(mconfig, type, tag),
		m_mcu(*this, "mcu")
		{ }

	void mk3snes(machine_config &config);
	void snes4sl(machine_config &config);

protected:
	void machine_start() override;

private:
	required_device<mcs51_cpu_device> m_mcu;

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

	void mcu_p1_w(uint8_t data);
	uint8_t mcu_p3_r();
	void mcu_p3_w(uint8_t data);

	void ram_address_high_w(uint8_t data);
	void ram_address_low_w(uint8_t data);
	void ram_w(uint8_t data);

	std::unique_ptr<uint8_t[]> m_ram;
	uint16_t m_ram_address;
};

void snesb51_state::mem_map(address_map &map)
{
	map(0x0000, 0x7fff).rom().region("mcu", 0);
}

void snesb51_state::io_map(address_map &map)
{
//	map(0x8000, 0x8000).r
//	map(0x8200, 0x8200).r
//	map(0x8401, 0x8401).w
	map(0x8c00, 0x8c00).w(FUNC(snesb51_state::ram_address_high_w));
	map(0x8e00, 0x8e00).w(FUNC(snesb51_state::ram_address_low_w));
//	map(0x9000, 0xafff).ram();
	map(0xa000, 0xa000).w(FUNC(snesb51_state::ram_w));
//	map(0xb000, 0xb000).w
//	map(0xd000, 0xd000).w
//	map(0xd400, 0xd400).w
//	map(0xd800, 0xd800).r
}

static INPUT_PORTS_START( mk3snes )
INPUT_PORTS_END

static INPUT_PORTS_START( snes4sl )
	PORT_START("S1")
	PORT_DIPNAME(0x03, 0x00, "Game Time")    PORT_DIPLOCATION("S1:1,2")
	PORT_DIPSETTING(   0x00, "5 Minutes")
	PORT_DIPSETTING(   0x01, "15 Minutes")
	PORT_DIPSETTING(   0x02, "20 Minutes")
	PORT_DIPSETTING(   0x03, "10 Minutes")
	PORT_DIPUNKNOWN(0x04, 0x00)              PORT_DIPLOCATION("S1:3")
	PORT_DIPNAME(0x08, 0x00, "Mode")         PORT_DIPLOCATION("S1:4")
	PORT_DIPSETTING(   0x00, "Credit/Timer")
	PORT_DIPSETTING(   0x08, "Timer")
INPUT_PORTS_END

const gfx_layout char_layout =
{
	8,16,
	38,
	1,
	{ RGN_FRAC(0,1) },
	{ STEP8(0,1) },
	{ STEP16(0,8) },
	8*16
};

static GFXDECODE_START(chars)
	GFXDECODE_ENTRY("mcu", 0x3ec8, char_layout, 0, 1)
GFXDECODE_END

void snesb51_state::mcu_p1_w(uint8_t data)
{
	logerror("mcu_p1_w: %02x\n", data);
}

uint8_t snesb51_state::mcu_p3_r()
{
	logerror("mcu_p3_r\n");
	return machine().rand();
}

void snesb51_state::mcu_p3_w(uint8_t data)
{
	logerror("mcu_p3_w: %02x\n", data);
}

void snesb51_state::ram_address_high_w(uint8_t data)
{
	data &= 0x1f;
	m_ram_address = (data << 8) | (m_ram_address & 0x00ff);
}

void snesb51_state::ram_address_low_w(uint8_t data)
{
	m_ram_address = (m_ram_address & 0xff00) | data;
}

void snesb51_state::ram_w(uint8_t data)
{
	m_ram[m_ram_address] = data;
}

void snesb51_state::machine_start()
{
	m_ram = std::make_unique<uint8_t[]>(0x2000);
	save_pointer(NAME(m_ram), 0x2000);
}

void snesb51_state::mk3snes(machine_config &config)
{
	I8751(config, m_mcu, 12_MHz_XTAL / 6);
	m_mcu->set_addrmap(AS_IO, &snesb51_state::io_map);
	m_mcu->port_out_cb<1>().set(FUNC(snesb51_state::mcu_p1_w));
	m_mcu->port_in_cb<3>().set(FUNC(snesb51_state::mcu_p3_r));
	m_mcu->port_out_cb<3>().set(FUNC(snesb51_state::mcu_p3_w));
}

void snesb51_state::snes4sl(machine_config &config)
{
	// exact type and clock unknown
	I8031(config, m_mcu, 12_MHz_XTAL / 6);
	m_mcu->set_addrmap(AS_PROGRAM, &snesb51_state::mem_map);
	m_mcu->set_addrmap(AS_IO, &snesb51_state::io_map);
	m_mcu->port_out_cb<1>().set(FUNC(snesb51_state::mcu_p1_w));
	m_mcu->port_in_cb<3>().set(FUNC(snesb51_state::mcu_p3_r));
	m_mcu->port_out_cb<3>().set(FUNC(snesb51_state::mcu_p3_w));

	PALETTE(config, "palette", palette_device::MONOCHROME);

	GFXDECODE(config, "gfxdecode", "palette", chars);
}

// this is identical to the snes release apart from a single byte
ROM_START( mk3snes )
	ROM_REGION(0x400000, "game", 0)
	ROM_LOAD("5.u5", 0x000000, 0x080000, CRC(c21ee1ac) SHA1(12fc526e39b0b998b39d558fbe5660e72c7fad14))
	ROM_LOAD("6.u6", 0x080000, 0x080000, CRC(0e064323) SHA1(a11175516892beb862c7cc1e186034ef1b55ee8f))
	ROM_LOAD("7.u7", 0x100000, 0x080000, CRC(7db6b7be) SHA1(a7653c04f5321fd83062425a492c7ed0a4f1fdb0))
	ROM_LOAD("8.u8", 0x180000, 0x080000, CRC(28771750) SHA1(d6c469ca2640935b6687f5bf5f6e85275157abb0))
	ROM_LOAD("1.u1", 0x200000, 0x080000, CRC(4cab6332) SHA1(3c417ba6d35532b4e2ca9ae4a3b730c589d26aee))
	ROM_LOAD("2.u2", 0x280000, 0x080000, CRC(0327999b) SHA1(dc6bb11a925e893453e0e5e5d88b8ace8d6cf859))
	ROM_LOAD("3.u3", 0x300000, 0x080000, CRC(229af2de) SHA1(1bbb02aec08afab979ffbe4b68a48dc4cc923f73))
	// this rom has 1 byte changed compared to sns-a3me-0.u1 (mk3u in snes softlist)
	ROM_LOAD("4.u4", 0x380000, 0x080000, CRC(b51930d9) SHA1(220f00d64809a6218015a738e53f11d8dc81578f))

	ROM_REGION(0x1000, "mcu", 0)
	ROM_LOAD("d87c51.u9", 0x0000, 0x1000, CRC(f447620a) SHA1(ac0d78c7b339f13d5f96a6727a0f2147158697f9))

	ROM_REGION(0x100, "audiocpu", 0)
	ROM_LOAD("spc700.rom", 0x00, 0x40, CRC(44bb3a40) SHA1(97e352553e94242ae823547cd853eecda55c20f0))
ROM_END

ROM_START( snes4sl )
	ROM_REGION(0x8000, "mcu", 0)
	ROM_LOAD("27c256_11-03.bin", 0x0000, 0x8000, CRC(4e471581) SHA1(0f23ad065d448097f56ab45c3850d53cf85f3670))
ROM_END

//    YEAR  NAME     PARENT   MACHINE  INPUT    CLASS          INIT        ROT   COMPANY    FULLNAME                          FLAGS
GAME( 199?, mk3snes, 0,       mk3snes, mk3snes, snesb51_state, empty_init, ROT0, "bootleg", "Mortal Kombat 3 (SNES bootleg)", MACHINE_IS_SKELETON )
GAME( 1993, snes4sl, 0,       snes4sl, snes4sl, snesb51_state, empty_init, ROT0, "bootleg", "SNES 4 Slot arcade switcher",    MACHINE_IS_SKELETON )