Previous 15994 Revisions Next

r4333 Monday 23rd February, 2009 at 11:16:38 UTC by Nathan Woods
[VC4000] Sound cleanups
[src/mess/audio]vc4000.c
[src/mess/includes]vc4000.h
[src/mess/video]vc4000.c

src/mess/audio/vc4000.c
r4332r4333
1010#include "includes/vc4000.h"
1111
1212
13static struct
13typedef struct _vc4000_sound vc4000_sound;
14struct _vc4000_sound
1415{
1516    sound_stream *channel;
1617    UINT8 reg[1];
1718    int size, pos;
1819    unsigned level;
19} vc4000_sound= { 0 };
20};
2021
2122
23static vc4000_sound *get_token(const device_config *device)
24{
25   assert(device != NULL);
26   assert(sound_get_type(device) == SOUND_VC4000);
27   return (vc4000_sound *) device->token;
28}
2229
23void vc4000_soundport_w (running_machine *machine, int offset, int data)
30
31void vc4000_soundport_w (const device_config *device, int offset, int data)
2432{
25   stream_update(vc4000_sound.channel);
26   vc4000_sound.reg[offset] = data;
33   vc4000_sound *token = get_token(device);
34
35   stream_update(token->channel);
36   token->reg[offset] = data;
2737   switch (offset)
2838   {
29   case 0:
30       vc4000_sound.pos = 0;
31       vc4000_sound.level = TRUE;
32       // frequency 7874/(data+1)
33       vc4000_sound.size=machine->sample_rate*(data+1)/7874;
34       break;
39      case 0:
40         token->pos = 0;
41         token->level = TRUE;
42         // frequency 7874/(data+1)
43         token->size = device->machine->sample_rate * (data + 1) /7874;
44         break;
3545   }
3646}
3747
r4332r4333
4454static STREAM_UPDATE( vc4000_update )
4555{
4656   int i;
57   vc4000_sound *token = get_token(device);
4758   stream_sample_t *buffer = outputs[0];
4859
4960   for (i = 0; i < samples; i++, buffer++)
5061   {
5162      *buffer = 0;
52      if (vc4000_sound.reg[0] && vc4000_sound.pos <= vc4000_sound.size/2)
63      if (token->reg[0] && token->pos <= token->size / 2)
5364      {
5465         *buffer = 0x7fff;
5566      }
56      if (vc4000_sound.pos <= vc4000_sound.size)
57         vc4000_sound.pos++;
58      if (vc4000_sound.pos > vc4000_sound.size)
59         vc4000_sound.pos = 0;
67      if (token->pos <= token->size)
68         token->pos++;
69      if (token->pos > token->size)
70         token->pos = 0;
6071   }
6172}
6273
r4332r4333
6879
6980static DEVICE_START(vc4000_sound)
7081{
71    vc4000_sound.channel = stream_create(device, 0, 1, device->machine->sample_rate, 0, vc4000_update);
82   vc4000_sound *token = get_token(device);
83   memset(token, 0, sizeof(*token));
84    token->channel = stream_create(device, 0, 1, device->machine->sample_rate, 0, vc4000_update);
7285}
7386
7487
r4332r4333
7689{
7790   switch (state)
7891   {
92      /* --- the following bits of info are returned as 64-bit signed integers --- */
93      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(vc4000_sound);         break;
94
7995      /* --- the following bits of info are returned as pointers to data or functions --- */
8096      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(vc4000_sound);   break;
8197
src/mess/video/vc4000.c
r4332r4333
368368      break;
369369
370370   case 0xc7:                  // Soundregister
371      vc4000_video.reg.data[offset]=data;
372      vc4000_soundport_w(space->machine, 0, data);
371      vc4000_video.reg.data[offset] = data;
372      vc4000_soundport_w(devtag_get_device(space->machine, SOUND, "custom"), 0, data);
373373      break;
374374
375375   case 0xc8:                  // Digits 1 and 2
src/mess/includes/vc4000.h
r4332r4333
3232
3333DEVICE_GET_INFO( vc4000_sound );
3434
35void vc4000_soundport_w (running_machine *machine, int mode, int data);
35void vc4000_soundport_w (const device_config *device, int mode, int data);
3636
3737
3838#endif /* VC4000_H_ */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team