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

« back to all changes in this revision

Viewing changes to src/mame/audio/cps3.c

  • Committer: Bazaar Package Importer
  • Author(s): Jordi Mallach, Emmanuel Kasper, Félix Arreola Rodríguez, Jordi Mallach
  • Date: 2011-05-11 21:06:50 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20110511210650-jizvh8a6x117y9hr
Tags: 0.142-1
[ Emmanuel Kasper ]
* New upstream release
* Set NOWERROR=1 to allow compiling with gcc-4.6
* Remove fix_powerpc_build.patch, as upstream has taken it in this release
* Add gnome-video-arcade front end as a suggested package

[ Félix Arreola Rodríguez ]
* Add kfreebsd-build.patch to quilt series, to fix build on kfreebsd

[ Jordi Mallach ]
* Remove unneeded and bogus addition of --with-quilt to the dh invocation.
* Add Cesare Falco (long time Ubuntu maintainer) to Uploaders, and wrap
  them into multiple lines.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 
5
5
***************************************************************************/
6
6
#include "emu.h"
7
 
#include "streams.h"
8
7
#include "includes/cps3.h"
9
8
 
10
9
#define CPS3_VOICES             16
20
19
typedef struct _cps3_sound_state cps3_sound_state;
21
20
struct _cps3_sound_state
22
21
{
23
 
        sound_stream *stream;
24
 
        cps3_voice voice[CPS3_VOICES];
25
 
        UINT16     key;
26
 
        INT8*      base;
 
22
        sound_stream *m_stream;
 
23
        cps3_voice m_voice[CPS3_VOICES];
 
24
        UINT16     m_key;
 
25
        INT8*      m_base;
27
26
};
28
27
 
29
28
INLINE cps3_sound_state *get_safe_token(device_t *device)
41
40
 
42
41
        // the actual 'user5' region only exists on the nocd sets, on the others it's allocated in the initialization.
43
42
        // it's a shared gfx/sound region, so can't be allocated as part of the sound device.
44
 
        state->base = (INT8*)cps3_user5region;
 
43
        state->m_base = (INT8*)device->machine().driver_data<cps3_state>()->m_user5region;
45
44
 
46
45
        /* Clear the buffers */
47
46
        memset(outputs[0], 0, samples*sizeof(*outputs[0]));
49
48
 
50
49
        for (i = 0; i < CPS3_VOICES; i ++)
51
50
        {
52
 
                if (state->key & (1 << i))
 
51
                if (state->m_key & (1 << i))
53
52
                {
54
53
                        int j;
55
54
 
56
55
                        /* TODO */
57
56
                        #define SWAP(a) ((a >> 16) | ((a & 0xffff) << 16))
58
57
 
59
 
                        cps3_voice *vptr = &state->voice[i];
 
58
                        cps3_voice *vptr = &state->m_voice[i];
60
59
 
61
60
                        UINT32 start = vptr->regs[1];
62
61
                        UINT32 end   = vptr->regs[5];
91
90
                                        }
92
91
                                        else
93
92
                                        {
94
 
                                                state->key &= ~(1 << i);
 
93
                                                state->m_key &= ~(1 << i);
95
94
                                                break;
96
95
                                        }
97
96
                                }
98
97
 
99
 
                                sample = state->base[BYTE4_XOR_LE(start + pos)];
 
98
                                sample = state->m_base[BYTE4_XOR_LE(start + pos)];
100
99
                                frac += step;
101
100
 
102
101
                                outputs[0][j] += (sample * (vol_l >> 8));
115
114
        cps3_sound_state *state = get_safe_token(device);
116
115
 
117
116
        /* Allocate the stream */
118
 
        state->stream = stream_create(device, 0, 2, device->clock() / 384, NULL, cps3_stream_update);
 
117
        state->m_stream = device->machine().sound().stream_alloc(*device, 0, 2, device->clock() / 384, NULL, cps3_stream_update);
119
118
}
120
119
 
121
120
DEVICE_GET_INFO( cps3_sound )
139
138
{
140
139
        cps3_sound_state *state = get_safe_token(device);
141
140
 
142
 
        stream_update(state->stream);
 
141
        state->m_stream->update();
143
142
 
144
143
        if (offset < 0x80)
145
144
        {
146
 
                COMBINE_DATA(&state->voice[offset / 8].regs[offset & 7]);
 
145
                COMBINE_DATA(&state->m_voice[offset / 8].regs[offset & 7]);
147
146
        }
148
147
        else if (offset == 0x80)
149
148
        {
153
152
                for (i = 0; i < CPS3_VOICES; i++)
154
153
                {
155
154
                        // Key off -> Key on
156
 
                        if ((key & (1 << i)) && !(state->key & (1 << i)))
 
155
                        if ((key & (1 << i)) && !(state->m_key & (1 << i)))
157
156
                        {
158
 
                                state->voice[i].frac = 0;
159
 
                                state->voice[i].pos = 0;
 
157
                                state->m_voice[i].frac = 0;
 
158
                                state->m_voice[i].pos = 0;
160
159
                        }
161
160
                }
162
 
                state->key = key;
 
161
                state->m_key = key;
163
162
        }
164
163
        else
165
164
        {
170
169
READ32_DEVICE_HANDLER( cps3_sound_r )
171
170
{
172
171
        cps3_sound_state *state = get_safe_token(device);
173
 
        stream_update(state->stream);
 
172
        state->m_stream->update();
174
173
 
175
174
        if (offset < 0x80)
176
175
        {
177
 
                return state->voice[offset / 8].regs[offset & 7] & mem_mask;
 
176
                return state->m_voice[offset / 8].regs[offset & 7] & mem_mask;
178
177
        }
179
178
        else if (offset == 0x80)
180
179
        {
181
 
                return state->key << 16;
 
180
                return state->m_key << 16;
182
181
        }
183
182
        else
184
183
        {