Previous 15994 Revisions Next

r7162 Sunday 24th January, 2010 at 18:29:43 UTC by Wilbert Pol
[PV1000] Added sound support [plgDavid]. The speed of the sound is still incorrect due to incorrect irq triggering.
[docs]messnew.txt
[src/mess/drivers]pv1000.c

src/mess/drivers/pv1000.c
r7161r7162
1313#define SOUND_PV1000   DEVICE_GET_INFO_NAME(pv1000_sound)
1414
1515
16typedef struct _pvaudio_voice pvaudio_voice;
17struct _pvaudio_voice
18{
19   UINT32 count;
20   UINT16 period;   
21   UINT8  val;   
22};
23
24
25typedef struct _pvaudio_state pvaudio_state;
26struct _pvaudio_state
27{
28   sound_stream *pv1000_sh_channel;
29
30   pvaudio_voice voice[4];
31};
32
33
1634static UINT8 *pv1000_ram;
1735static UINT8 pv1000_io_regs[8];
1836static UINT8 pv1000_fd_data;
19static sound_stream *pv1000_sh_channel;
37static pvaudio_state g_audio;
2038
2139
40
2241static WRITE8_HANDLER( pv1000_io_w );
2342static READ8_HANDLER( pv1000_io_r );
2443static WRITE8_HANDLER( pv1000_gfxram_w );
r7161r7162
4867
4968static WRITE8_HANDLER( pv1000_io_w )
5069{
51//   logerror("pv1000_io_w offset=%02x, data=%02x\n", offset, data );
70   
5271   switch ( offset )
5372   {
5473   case 0x00:
5574   case 0x01:
5675   case 0x02:
76      //logerror("pv1000_io_w offset=%02x, data=%02x (%03d)\n", offset, data , data);   
77      g_audio.voice[offset].period=data;
78   break;
79   
5780   case 0x03:
58      /* Sound i/O ports */
59      break;
81      //currently unknown use
82   break;
6083
6184   case 0x05:
6285      pv1000_fd_data = 1;
r7161r7162
7699   switch ( offset )
77100   {
78101   case 0x04:
79      /* Bit 1 = 1 => to pass checks in Amidar? */
80      /* Bit 0 = 0 => done reading joystick interface? */
102      /* Bit 1 = 1 => Data is available in port FD */
103      /* Bit 0 = 1 => Buffer at port FD is empty */
81104      data = pv1000_fd_data ? 0x02 : 0x01;
82105      break;
83106   case 0x05:
r7161r7162
200223}
201224
202225
226/*
227 plgDavid's audio implementation/analysis notes:
228 
229 Sound appears to be 3 50/50 pulse voices made by cutting the main clock by 1024,
230 then by the value of the 6bit period registers.
231 This creates a surprisingly accurate pitch range.
232 
233 Note: the register periods are inverted.
234 */
235
203236static STREAM_UPDATE( pv1000_sound_update )
204237{
205238   stream_sample_t *buffer = outputs[0];
206239
207   while( samples > 0 )
240   while ( samples > 0 )
208241   {
209      *buffer = 0;
242
243      *buffer=0;
244
245      for (size_t i=0;i<3;i++)
246      {
247         pvaudio_voice *v = &g_audio.voice[i];
248         UINT32 per = (0x3F-(v->period & 0x3f));
249
250         if( per != 0)//OFF!
251            *buffer += v->val * 8192;
252
253         v->count++;
254
255         if (v->count >= per)
256         {
257            v->count = 0;
258            v->val = !v->val;
259         }
260      }
261     
210262      buffer++;
211263      samples--;
212264   }
265
213266}
214267
215268
216269static DEVICE_START( pv1000_sound )
217270{
218   pv1000_sh_channel = stream_create( device, 0, 1, device->clock, 0, pv1000_sound_update );
271   g_audio.pv1000_sh_channel = stream_create( device, 0, 1, device->clock/1024, 0, pv1000_sound_update );
219272}
220273
221274
r7161r7162
300353
301354
302355ROM_START( pv1000 )
303   ROM_REGION( 0x4000, "cart", ROMREGION_ERASE00 )
356   ROM_REGION( 0x4000, "cart", ROMREGION_ERASE00 )
304357   ROM_REGION( 0x400, "gfxram", ROMREGION_ERASE00 )
305358ROM_END
306359
docs/messnew.txt
r7161r7162
22
33New System Drivers Supported:
44-----------------------------
5- Casio PV-1000  [Wilbert Pol]
5- Casio PV-1000  [Wilbert Pol, plgDavid]
66- Research Machines Nimbus [Phill Harvey-Smith]
77
88

Previous 15994 Revisions Next


© 1998-2018 The MESS Team