~ubuntu-branches/debian/sid/mame/sid

« back to all changes in this revision

Viewing changes to mess/src/mame/audio/namco54.c

  • Committer: Package Import Robot
  • Author(s): Jordi Mallach, Jordi Mallach, Emmanuel Kasper
  • Date: 2011-12-19 22:56:27 UTC
  • mfrom: (0.1.2)
  • Revision ID: package-import@ubuntu.com-20111219225627-ub5oga1oys4ogqzm
Tags: 0.144-1
[ Jordi Mallach ]
* Fix syntax errors in DEP5 copyright file (lintian).
* Use a versioned copyright Format specification field.
* Update Vcs-* URLs.
* Move transitional packages to the new metapackages section, and make
  them priority extra.
* Remove references to GNU/Linux and MESS sources from copyright.
* Add build variables for s390x.
* Use .xz tarballs as it cuts 4MB for the upstream sources.
* Add nplayers.ini as a patch. Update copyright file to add CC-BY-SA-3.0.

[ Emmanuel Kasper ]
* New upstream release. Closes: #651538.
* Add Free Desktop compliant png icons of various sizes taken from
  the hydroxygen iconset
* Mess is now built from a new source package, to avoid possible source
  incompatibilities between mame and the mess overlay.
* Mame-tools are not built from the mame source package anymore, but
  from the mess source package

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
 
3
 
    Namco 54XX
4
 
 
5
 
    This custom chip is a Fujitsu MB8844 MCU programmed to act as a noise
6
 
    generator. It is used for explosions, the shoot sound in Bosconian,
7
 
    and the tire screech sound in Pole Position.
8
 
 
9
 
    CMD = command from main CPU
10
 
    OUTn = sound outputs (3 channels)
11
 
 
12
 
    The chip reads the command when the /IRQ is pulled down.
13
 
 
14
 
                       +------+
15
 
                     EX|1   28|Vcc
16
 
                      X|2   27|K3 (CMD7)
17
 
                 /RESET|3   26|K2 (CMD6)
18
 
            (OUT0.0) O0|4   25|K1 (CMD5)
19
 
            (OUT0.1) O1|5   24|K0 (CMD4)
20
 
            (OUT0.2) O2|6   23|R10/IRQ
21
 
            (OUT0.3) O3|7   22|R9/TC
22
 
            (OUT1.0) O4|8   21|R8
23
 
            (OUT1.1) O5|9   20|R7 (OUT2.3)
24
 
            (OUT1.2) O6|10  19|R6 (OUT2.2)
25
 
            (OUT1.3) O7|11  18|R5 (OUT2.1)
26
 
              (CMD0) R0|12  17|R4 (OUT2.0)
27
 
              (CMD1) R1|13  16|R3 (CMD3)
28
 
                    GND|14  15|R2 (CMD2)
29
 
                       +------+
30
 
 
31
 
    [1] The RNG that drives the type A output is output on pin 21, and
32
 
    the one that drives the type B output is output on pin 22, but those
33
 
    pins are not connected on the board.
34
 
 
35
 
 
36
 
    The command format is very simple:
37
 
 
38
 
    0x: nop
39
 
    1x: play sound type A
40
 
    2x: play sound type B
41
 
    3x: set parameters (type A) (followed by 4 bytes)
42
 
    4x: set parameters (type B) (followed by 4 bytes)
43
 
    5x: play sound type C
44
 
    6x: set parameters (type C) (followed by 5 bytes)
45
 
    7x: set volume for sound type C to x
46
 
    8x-Fx: nop
47
 
 
48
 
***************************************************************************/
49
 
 
50
 
#include "emu.h"
51
 
#include "namco54.h"
52
 
#include "cpu/mb88xx/mb88xx.h"
53
 
 
54
 
typedef struct _namco_54xx_state namco_54xx_state;
55
 
struct _namco_54xx_state
56
 
{
57
 
        device_t *m_cpu;
58
 
        device_t *m_discrete;
59
 
        int m_basenode;
60
 
        UINT8 m_latched_cmd;
61
 
};
62
 
 
63
 
INLINE namco_54xx_state *get_safe_token(device_t *device)
64
 
{
65
 
        assert(device != NULL);
66
 
        assert(device->type() == NAMCO_54XX);
67
 
 
68
 
        return (namco_54xx_state *)downcast<legacy_device_base *>(device)->token();
69
 
}
70
 
 
71
 
 
72
 
 
73
 
static TIMER_CALLBACK( namco_54xx_latch_callback )
74
 
{
75
 
        namco_54xx_state *state = get_safe_token((device_t *)ptr);
76
 
        state->m_latched_cmd = param;
77
 
}
78
 
 
79
 
static READ8_HANDLER( namco_54xx_K_r )
80
 
{
81
 
        namco_54xx_state *state = get_safe_token(space->device().owner());
82
 
        return state->m_latched_cmd >> 4;
83
 
}
84
 
 
85
 
static READ8_HANDLER( namco_54xx_R0_r )
86
 
{
87
 
        namco_54xx_state *state = get_safe_token(space->device().owner());
88
 
        return state->m_latched_cmd & 0x0f;
89
 
}
90
 
 
91
 
 
92
 
static WRITE8_HANDLER( namco_54xx_O_w )
93
 
{
94
 
        namco_54xx_state *state = get_safe_token(space->device().owner());
95
 
        UINT8 out = (data & 0x0f);
96
 
        if (data & 0x10)
97
 
                discrete_sound_w(state->m_discrete, NAMCO_54XX_1_DATA(state->m_basenode), out);
98
 
        else
99
 
                discrete_sound_w(state->m_discrete, NAMCO_54XX_0_DATA(state->m_basenode), out);
100
 
}
101
 
 
102
 
static WRITE8_HANDLER( namco_54xx_R1_w )
103
 
{
104
 
        namco_54xx_state *state = get_safe_token(space->device().owner());
105
 
        UINT8 out = (data & 0x0f);
106
 
 
107
 
        discrete_sound_w(state->m_discrete, NAMCO_54XX_2_DATA(state->m_basenode), out);
108
 
}
109
 
 
110
 
 
111
 
 
112
 
 
113
 
static TIMER_CALLBACK( namco_54xx_irq_clear )
114
 
{
115
 
        namco_54xx_state *state = get_safe_token((device_t *)ptr);
116
 
        device_set_input_line(state->m_cpu, 0, CLEAR_LINE);
117
 
}
118
 
 
119
 
WRITE8_DEVICE_HANDLER( namco_54xx_write )
120
 
{
121
 
        namco_54xx_state *state = get_safe_token(device);
122
 
 
123
 
        device->machine().scheduler().synchronize(FUNC(namco_54xx_latch_callback), data, (void *)device);
124
 
 
125
 
        device_set_input_line(state->m_cpu, 0, ASSERT_LINE);
126
 
 
127
 
        // The execution time of one instruction is ~4us, so we must make sure to
128
 
        // give the cpu time to poll the /IRQ input before we clear it.
129
 
        // The input clock to the 06XX interface chip is 64H, that is
130
 
        // 18432000/6/64 = 48kHz, so it makes sense for the irq line to be
131
 
        // asserted for one clock cycle ~= 21us.
132
 
        device->machine().scheduler().timer_set(attotime::from_usec(21), FUNC(namco_54xx_irq_clear), 0, (void *)device);
133
 
}
134
 
 
135
 
 
136
 
/***************************************************************************
137
 
    DEVICE INTERFACE
138
 
***************************************************************************/
139
 
 
140
 
static ADDRESS_MAP_START( namco_54xx_map_io, AS_IO, 8 )
141
 
        AM_RANGE(MB88_PORTK,  MB88_PORTK)  AM_READ(namco_54xx_K_r)
142
 
        AM_RANGE(MB88_PORTO,  MB88_PORTO)  AM_WRITE(namco_54xx_O_w)
143
 
        AM_RANGE(MB88_PORTR0, MB88_PORTR0) AM_READ(namco_54xx_R0_r)
144
 
        AM_RANGE(MB88_PORTR1, MB88_PORTR1) AM_WRITE(namco_54xx_R1_w)
145
 
        AM_RANGE(MB88_PORTR2, MB88_PORTR2) AM_NOP
146
 
ADDRESS_MAP_END
147
 
 
148
 
 
149
 
static MACHINE_CONFIG_FRAGMENT( namco_54xx )
150
 
        MCFG_CPU_ADD("mcu", MB8844, DERIVED_CLOCK(1,1))         /* parent clock, internally divided by 6 */
151
 
        MCFG_CPU_IO_MAP(namco_54xx_map_io)
152
 
MACHINE_CONFIG_END
153
 
 
154
 
 
155
 
ROM_START( namco_54xx )
156
 
        ROM_REGION( 0x400, "mcu", ROMREGION_LOADBYNAME )
157
 
        ROM_LOAD( "54xx.bin",     0x0000, 0x0400, CRC(ee7357e0) SHA1(01bdf984a49e8d0cc8761b2cc162fd6434d5afbe) )
158
 
ROM_END
159
 
 
160
 
 
161
 
/*-------------------------------------------------
162
 
    device start callback
163
 
-------------------------------------------------*/
164
 
 
165
 
static DEVICE_START( namco_54xx )
166
 
{
167
 
        namco_54xx_config *config = (namco_54xx_config *)downcast<const legacy_device_base *>(device)->inline_config();
168
 
        namco_54xx_state *state = get_safe_token(device);
169
 
        astring tempstring;
170
 
 
171
 
        /* find our CPU */
172
 
        state->m_cpu = device->subdevice("mcu");
173
 
        assert(state->m_cpu != NULL);
174
 
 
175
 
        /* find the attached discrete sound device */
176
 
        assert(config->discrete != NULL);
177
 
        state->m_discrete = device->machine().device(config->discrete);
178
 
        assert(state->m_discrete != NULL);
179
 
        state->m_basenode = config->firstnode;
180
 
}
181
 
 
182
 
 
183
 
/*-------------------------------------------------
184
 
    device definition
185
 
-------------------------------------------------*/
186
 
 
187
 
static const char DEVTEMPLATE_SOURCE[] = __FILE__;
188
 
 
189
 
#define DEVTEMPLATE_ID(p,s)             p##namco_54xx##s
190
 
#define DEVTEMPLATE_FEATURES    DT_HAS_START | DT_HAS_ROM_REGION | DT_HAS_MACHINE_CONFIG | DT_HAS_INLINE_CONFIG
191
 
#define DEVTEMPLATE_NAME                "Namco 54xx"
192
 
#define DEVTEMPLATE_SHORTNAME   "namco54"
193
 
#define DEVTEMPLATE_FAMILY              "Namco I/O"
194
 
#include "devtempl.h"
195
 
 
196
 
 
197
 
DEFINE_LEGACY_DEVICE(NAMCO_54XX, namco_54xx);