Previous 15994 Revisions Next

r4337 Monday 23rd February, 2009 at 13:42:22 UTC by Nathan Woods
[GMASTER] Sound cleanups
[src/mess/audio]gmaster.c

src/mess/audio/gmaster.c
r4336r4337
1313
1414#include "includes/gmaster.h"
1515
16static /*bool*/int level;
17static sound_stream *mixer_channel;
16typedef struct _gmaster_sound gmaster_sound;
17struct _gmaster_sound
18{
19   /*bool*/int level;
20   sound_stream *mixer_channel;
21};
1822
1923
24static gmaster_sound *get_token(const device_config *device)
25{
26   assert(device != NULL);
27   assert(sound_get_type(device) == SOUND_GMASTER);
28   return (gmaster_sound *) device->token;
29}
2030
31
2132int gmaster_io_callback(const device_config *device, int ioline, int state)
2233{
34   gmaster_sound *token = get_token(device);
35
2336    switch (ioline)
2437   {
2538      case UPD7810_TO:
26         stream_update(mixer_channel);
27         level = state;
39         stream_update(token->mixer_channel);
40         token->level = state;
2841         break;
2942      default:
3043         logerror("io changed %d %.2x\n",ioline, state);
r4336r4337
4053static STREAM_UPDATE( gmaster_update )
4154{
4255   int i;
56   gmaster_sound *token = get_token(device);
4357   stream_sample_t *buffer = outputs[0];
4458
4559   for (i = 0; i < samples; i++, buffer++)
4660   {
47      *buffer = level?0x4000:0;
61      *buffer = token->level ? 0x4000 : 0;
4862   }
4963}
5064
r4336r4337
5468
5569static DEVICE_START( gmaster_sound )
5670{
57   mixer_channel = stream_create(device, 0, 1, device->machine->sample_rate, 0, gmaster_update);
71   gmaster_sound *token = get_token(device);
72   token->mixer_channel = stream_create(device, 0, 1, device->machine->sample_rate, 0, gmaster_update);
5873}
5974
6075
r4336r4337
6277{
6378   switch (state)
6479   {
80      /* --- the following bits of info are returned as 64-bit signed integers --- */
81      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(gmaster_sound);         break;
82
6583      /* --- the following bits of info are returned as pointers to data or functions --- */
6684      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(gmaster_sound);   break;
6785

Previous 15994 Revisions Next


© 1998-2018 The MESS Team