src/mess/audio/gmaster.c
| r4336 | r4337 | |
| 13 | 13 | |
| 14 | 14 | #include "includes/gmaster.h" |
| 15 | 15 | |
| 16 | | static /*bool*/int level; |
| 17 | | static sound_stream *mixer_channel; |
| 16 | typedef struct _gmaster_sound gmaster_sound; |
| 17 | struct _gmaster_sound |
| 18 | { |
| 19 | /*bool*/int level; |
| 20 | sound_stream *mixer_channel; |
| 21 | }; |
| 18 | 22 | |
| 19 | 23 | |
| 24 | static 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 | } |
| 20 | 30 | |
| 31 | |
| 21 | 32 | int gmaster_io_callback(const device_config *device, int ioline, int state) |
| 22 | 33 | { |
| 34 | gmaster_sound *token = get_token(device); |
| 35 | |
| 23 | 36 | switch (ioline) |
| 24 | 37 | { |
| 25 | 38 | case UPD7810_TO: |
| 26 | | stream_update(mixer_channel); |
| 27 | | level = state; |
| 39 | stream_update(token->mixer_channel); |
| 40 | token->level = state; |
| 28 | 41 | break; |
| 29 | 42 | default: |
| 30 | 43 | logerror("io changed %d %.2x\n",ioline, state); |
| r4336 | r4337 | |
| 40 | 53 | static STREAM_UPDATE( gmaster_update ) |
| 41 | 54 | { |
| 42 | 55 | int i; |
| 56 | gmaster_sound *token = get_token(device); |
| 43 | 57 | stream_sample_t *buffer = outputs[0]; |
| 44 | 58 | |
| 45 | 59 | for (i = 0; i < samples; i++, buffer++) |
| 46 | 60 | { |
| 47 | | *buffer = level?0x4000:0; |
| 61 | *buffer = token->level ? 0x4000 : 0; |
| 48 | 62 | } |
| 49 | 63 | } |
| 50 | 64 | |
| r4336 | r4337 | |
| 54 | 68 | |
| 55 | 69 | static DEVICE_START( gmaster_sound ) |
| 56 | 70 | { |
| 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); |
| 58 | 73 | } |
| 59 | 74 | |
| 60 | 75 | |
| r4336 | r4337 | |
| 62 | 77 | { |
| 63 | 78 | switch (state) |
| 64 | 79 | { |
| 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 | |
| 65 | 83 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 66 | 84 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(gmaster_sound); break; |
| 67 | 85 | |