summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/audio/starwars.cpp
blob: 817749a5e10ad57aa0465fd4a54a889ee0edc58c (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
// license:BSD-3-Clause
// copyright-holders:Frank Palazzolo
/***************************************************************************

    Atari Star Wars hardware

    This file is Copyright Steve Baines.
    Modified by Frank Palazzolo for sound support

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

#include "emu.h"
#include "sound/tms5220.h"
#include "includes/starwars.h"


/*************************************
 *
 *  RIOT interfaces
 *
 *************************************/

READ8_MEMBER(starwars_state::r6532_porta_r)
{
	/* Configured as follows:           */
	/* d7 (in)  Main Ready Flag         */
	/* d6 (in)  Sound Ready Flag        */
	/* d5 (out) Mute Speech             */
	/* d4 (in)  Not Sound Self Test     */
	/* d3 (out) Hold Main CPU in Reset? */
	/*          + enable delay circuit? */
	/* d2 (in)  TMS5220 Not Ready       */
	/* d1 (out) TMS5220 Not Read        */
	/* d0 (out) TMS5220 Not Write       */
	/* Note: bit 4 is always set to avoid sound self test */
	uint8_t olddata = m_riot->porta_in_get();

	tms5220_device *tms5220 = machine().device<tms5220_device>("tms");
	return (olddata & 0xc0) | 0x10 | (tms5220->readyq_r() << 2);
}


WRITE8_MEMBER(starwars_state::r6532_porta_w)
{
	tms5220_device *tms5220 = machine().device<tms5220_device>("tms");
	/* handle 5220 read */
	tms5220->rsq_w((data & 2)>>1);
	/* handle 5220 write */
	tms5220->wsq_w((data & 1)>>0);
}


/*************************************
 *
 *  Sound CPU to/from main CPU
 *
 *************************************/

WRITE_LINE_MEMBER(starwars_state::boost_interleave_hack)
{
	if (state)
		machine().scheduler().boost_interleave(attotime::zero, attotime::from_usec(100));
}


READ8_MEMBER(starwars_state::starwars_main_ready_flag_r)
{
	return m_riot->porta_in_get() & 0xc0;    /* only upper two flag bits mapped */
}


WRITE8_MEMBER(starwars_state::starwars_soundrst_w)
{
	m_soundlatch->acknowledge_w(space, 0, 0);
	m_mainlatch->acknowledge_w(space, 0, 0);

	/* reset sound CPU here  */
	m_audiocpu->set_input_line(INPUT_LINE_RESET, PULSE_LINE);
}