summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/drivers/getaway.cpp
blob: 7492a22657a1bb175937b45a01212114b95eb420 (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
// license:BSD-3-Clause
// copyright-holders:hap
/******************************************************************************

Universal Get A Way

Hardware notes:
- PCB label: UNIVERSAL 7812
- TMS9900 @ 3MHz
- 24KB ROM (6*TMM333P)
- 2KB SRAM(4*TMS4045), 24KB DRAM(48*TMS4030)
- discrete sound

TODO:
- roms have a lot of empty contents, but it's probably ok
- dipswitches and game inputs (reads from I/O, but don't know which is which yet),
  PCB has 12 dipswitches, game has a steering wheel and shifter
- video emulation, it looks like a custom blitter
- video timing is unknown, pixel clock XTAL is 10.816MHz
- sound emulation
- lamps and 7segs
- undumped proms?

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

#include "emu.h"

#include "cpu/tms9900/tms9900.h"

#include "emupal.h"
#include "screen.h"
//#include "speaker.h"


namespace {

class getaway_state : public driver_device
{
public:
	getaway_state(const machine_config &mconfig, device_type type, const char *tag) :
		driver_device(mconfig, type, tag),
		m_maincpu(*this, "maincpu"),
		m_gfxrom(*this, "gfx"),
		m_screen(*this, "screen"),
		m_inputs(*this, "IN.%u", 0)
	{ }

	// machine configs
	void getaway(machine_config &config);

protected:
	virtual void machine_start() override;

private:
	// devices/pointers
	required_device<tms9900_device> m_maincpu;
	required_region_ptr<u8> m_gfxrom;
	required_device<screen_device> m_screen;
	required_ioport_array<1> m_inputs;

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

	u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
	DECLARE_WRITE_LINE_MEMBER(vblank_irq);

	void io_w(offs_t offset, u8 data);
	u8 coin_r(offs_t offset);
	u8 busy_r();

	u8 m_regs[0x10];
	u8 m_vram[0x6000];
};

void getaway_state::machine_start()
{
	memset(m_regs, 0, sizeof(m_regs));
	memset(m_vram, 0, sizeof(m_vram));

	save_item(NAME(m_regs));
	save_item(NAME(m_vram));
}



/******************************************************************************
    Video
******************************************************************************/

uint32_t getaway_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
	for (int y = cliprect.min_y; y <= cliprect.max_y; y++)
	{
		for (int x = 0; x < 32; x++)
		{
			u8 r = m_vram[0x0000 | (x << 8 | y)];
			u8 g = m_vram[0x2000 | (x << 8 | y)];
			u8 b = m_vram[0x4000 | (x << 8 | y)];

			for (int i = 0; i < 8; i++)
				bitmap.pix(y, x << 3 | (i ^ 7)) = BIT(b, i) << 2 | BIT(g, i) << 1 | BIT(r, i);
		}
	}

	return 0;
}



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

WRITE_LINE_MEMBER(getaway_state::vblank_irq)
{
	if (state)
		m_maincpu->pulse_input_line(INT_9900_INTREQ, 2 * m_maincpu->minimum_quantum_time());
}

void getaway_state::io_w(offs_t offset, u8 data)
{
	u8 n = offset >> 3;
	u8 bit = offset & 7;
	u8 mask = 1 << bit;
	data = (m_regs[n] & ~mask) | ((data & 1) ? mask : 0);

	if (n == 1 && ~m_regs[n] & data & 0x80)
	{
		// start gfx rom->vram transfer?
		u16 src = m_regs[6] << 8 | m_regs[5];
		//u8 smask = src >> 13;
		src &= 0x1fff;

		u16 dest = m_regs[4] << 8 | m_regs[3];
		u8 dmask = dest >> 13;
		dest &= 0x1fff;

		u8 bytes = m_regs[8];

		for (int count = 0; count < bytes; count++)
		{
			for (int i = 0; i < 3; i++)
				m_vram[i * 0x2000 + dest] = BIT(dmask, i) ? m_gfxrom[src] : 0;

			src = (src + 1) & 0x1fff;
			dest = (dest + 1) & 0x1fff;
		}
	}

	m_regs[n] = data;
}

u8 getaway_state::coin_r(offs_t offset)
{
	return BIT(m_inputs[0]->read(), offset);
}

u8 getaway_state::busy_r()
{
	// blitter busy?
	return 0;
}



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

void getaway_state::main_map(address_map &map)
{
	map(0x0000, 0x2fff).rom();
	map(0x3800, 0x3fff).ram();
}

void getaway_state::io_map(address_map &map)
{
	map.global_mask(0xff);
	map.unmap_value_high();
	map(0x00, 0xff).w(FUNC(getaway_state::io_w));
	map(0x32, 0x35).r(FUNC(getaway_state::coin_r));
	map(0x36, 0x37).r(FUNC(getaway_state::busy_r));
}



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

static INPUT_PORTS_START( getaway )
	PORT_START("IN.0")
	PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_COIN1)
	PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_START1)
INPUT_PORTS_END



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

void getaway_state::getaway(machine_config &config)
{
	/* basic machine hardware */
	TMS9900(config, m_maincpu, 48_MHz_XTAL/16);
	m_maincpu->set_addrmap(AS_PROGRAM, &getaway_state::main_map);
	m_maincpu->set_addrmap(AS_IO, &getaway_state::io_map);
	m_maincpu->intlevel_cb().set_constant(2);

	/* video hardware */
	SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
	m_screen->set_refresh_hz(60);
	m_screen->set_size(32*8, 32*8);
	//m_screen->set_visarea(0*8, 32*8-1, 4*8, 28*8-1);
	m_screen->set_visarea_full();
	m_screen->set_screen_update(FUNC(getaway_state::screen_update));
	m_screen->screen_vblank().set(FUNC(getaway_state::vblank_irq));
	m_screen->set_palette("palette");
	PALETTE(config, "palette", palette_device::RGB_3BIT);

	/* sound hardware */
	// TODO
}



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

ROM_START( getaway )
	ROM_REGION16_BE(0x10000, "maincpu", 0)
	ROM_LOAD16_BYTE("3901.a16", 0x0000, 0x1000, CRC(d7596a61) SHA1(6afdfadc4f13f8dc2abcc967536f70a999dd00ef))
	ROM_LOAD16_BYTE("3902.a14", 0x0001, 0x1000, CRC(67e67b65) SHA1(3a1d82acc05318c52b9ce1d71df1a9471fb1ffe7))
	ROM_LOAD16_BYTE("3903.a15", 0x2000, 0x1000, CRC(ad43edff) SHA1(cd52bd1984d7d10bdda39fa850ee6c164cc4316c))
	ROM_LOAD16_BYTE("3904.a13", 0x2001, 0x1000, CRC(2728304f) SHA1(45f5485b4036a211bb6c16283c2710aa8b8a0212))

	ROM_REGION(0x2000, "gfx", 0)
	ROM_LOAD("3905.f6", 0x0000, 0x1000, CRC(90546543) SHA1(c52e4e59aebd4a37ce2cfd077f85c36d49878493))
	ROM_LOAD("3906.f8", 0x1000, 0x1000, CRC(fd878838) SHA1(b161791d505f79578102148934a9f11dd9c4f4fe))
ROM_END

} // anonymous namespace



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

//    YEAR  NAME     PARENT  MACHINE  INPUT    CLASS          INIT        SCREEN  COMPANY, FULLNAME, FLAGS
GAME( 1979, getaway, 0,      getaway, getaway, getaway_state, empty_init, ROT270, "Universal", "Get A Way", MACHINE_SUPPORTS_SAVE | MACHINE_IS_SKELETON )