Previous 15994 Revisions Next

r9093 Saturday 11th September, 2010 at 12:53:34 UTC by Angelo Salese
[PCE]: Added ADPCM basic flags handling
[src/mess/machine]pce.c

src/mess/machine/pce.c
r9092r9093
6666#define PCE_CD_IRQ_TRANSFER_READY   0x40
6767#define PCE_CD_IRQ_TRANSFER_DONE   0x20
6868
69#define PCE_CD_SAMPLE_FULL_PLAY      0x08
70#define PCE_CD_SAMPLE_HALF_PLAY      0x04
71#define PCE_CD_SAMPLE_STOP_PLAY      0x00
72
73#define PCE_CD_ADPCM_PLAY_FLAG      0x08
74#define PCE_CD_ADPCM_STOP_FLAG      0x01
75
6976#define PCE_CD_DATA_FRAMES_PER_SECOND   75
7077
7178enum {
r9092r9093
9097   int      adpcm_write_ptr;
9198   UINT8   adpcm_write_buf;
9299   int      adpcm_length;
100   int      adpcm_clock_count;
101   int      adpcm_clock_divider;
93102   UINT16  msm_start_addr;
94103   UINT16   msm_end_addr;
95104   UINT8   msm_nibble;
96   int      adpcm_clock_count;
97   int      adpcm_clock_divider;
105   UINT8   msm_idle;
98106   /* SCSI signals */
99107   int      scsi_BSY;   /* Busy. Bus in use */
100108   int      scsi_SEL;   /* Select. Initiator has won arbitration and has selected a target */
r9092r9093
342350   pce_cd.adpcm_write_buf = 0;
343351
344352   // TODO: add CD-DA stop command here
353
354   pce_cd.regs[0x0c] |= PCE_CD_ADPCM_STOP_FLAG;
355   pce_cd.regs[0x0c] &= ~PCE_CD_ADPCM_PLAY_FLAG;
356   pce_cd.regs[0x03] = (pce_cd.regs[0x03] & ~0x0c) | (PCE_CD_SAMPLE_STOP_PLAY);
345357}
346358
347359/* todo: how many input ports does the PCE have? */
r9092r9093
418430   memory_set_bankptr( machine, "bank10", pce_cd.bram + ( pce_cd.bram_locked ? PCE_BRAM_SIZE : 0 ) );
419431}
420432
433static void adpcm_stop(void)
434{
435   pce_cd.regs[0x0c] |= PCE_CD_ADPCM_STOP_FLAG;
436   pce_cd.regs[0x0c] &= ~PCE_CD_ADPCM_PLAY_FLAG;
437   pce_cd.regs[0x03] = (pce_cd.regs[0x03] & ~0x0c) | (PCE_CD_SAMPLE_STOP_PLAY);
438   pce_cd.msm_idle = 1;
439}
440
441static void adpcm_play(void)
442{
443   pce_cd.regs[0x0c] &= ~PCE_CD_ADPCM_STOP_FLAG;
444   pce_cd.regs[0x0c] |= PCE_CD_ADPCM_PLAY_FLAG;
445   pce_cd.regs[0x03] = (pce_cd.regs[0x03] & ~0x0c) | (PCE_CD_SAMPLE_STOP_PLAY);
446   pce_cd.msm_idle = 0;
447}
448
449
421450/* Callback for new data from the MSM5205.
422451  The PCE cd unit actually divides the clock signal supplied to
423452  the MSM5205. Currently we can only use static clocks for the
r9092r9093
427456{
428457   static UINT8 msm_data;
429458
459   if ( pce_cd.msm_idle )
460      return;
461
462   //popmessage("%08x %08x %02x %02x",pce_cd.msm_start_addr,pce_cd.msm_end_addr,pce_cd.regs[0x0c],pce_cd.regs[0x0d]);
463
430464   if ( ! pce_cd.adpcm_clock_count )
431465   {
432466      /* Supply new ADPCM data */
433467      msm_data = (pce_cd.msm_nibble) ? (pce_cd.adpcm_ram[pce_cd.msm_start_addr] & 0x0f) : ((pce_cd.adpcm_ram[pce_cd.msm_start_addr] & 0xf0) >> 4);
434468
469      msm5205_data_w(device, msm_data);
435470      pce_cd.msm_nibble ^= 1;
436471
437472      if(pce_cd.msm_nibble == 0)
438473      {
439474         pce_cd.msm_start_addr++;
475
476         if(pce_cd.msm_start_addr >= ((pce_cd.msm_end_addr-pce_cd.msm_start_addr) / 2))
477            pce_cd.regs[0x03] = (pce_cd.regs[0x03] & ~0x0c) | (PCE_CD_SAMPLE_HALF_PLAY);
478
479         if(pce_cd.msm_start_addr == pce_cd.msm_end_addr)
480            pce_cd.regs[0x03] = (pce_cd.regs[0x03] & ~0x0c) | (PCE_CD_SAMPLE_FULL_PLAY);
481
440482         if(pce_cd.msm_start_addr > pce_cd.msm_end_addr)
483         {
484            adpcm_stop();
441485            msm5205_reset_w(device, 1);
486         }
442487      }
443488   }
444489   else
r9092r9093
11921237         /* Reset ADPCM hardware */
11931238         pce_cd.adpcm_read_ptr = 0;
11941239         pce_cd.adpcm_write_ptr = 0;
1240         pce_cd.msm_start_addr = 0;
1241         pce_cd.msm_end_addr = 0;
1242         pce_cd.msm_nibble = 0;
1243         adpcm_stop();
11951244         msm5205_reset_w( space->machine->device( "msm5205"), 1 );
11961245      }
11971246
r9092r9093
12001249         pce_cd.msm_start_addr = (pce_cd.adpcm_read_ptr);
12011250         pce_cd.msm_end_addr = (pce_cd.adpcm_read_ptr + pce_cd.adpcm_length) & 0xffff;
12021251         pce_cd.msm_nibble = 0;
1252         adpcm_play();
12031253         msm5205_reset_w( space->machine->device( "msm5205"), 0 );
12041254
12051255         //popmessage("%08x %08x",pce_cd.adpcm_read_ptr,pce_cd.adpcm_length);
12061256      }
1257      else
1258      {
1259         /* used by Buster Bros to cancel an in-flight sample */
1260         adpcm_stop();
1261         msm5205_reset_w( space->machine->device( "msm5205"), 1 );
1262      }
12071263
12081264      if ( data & 0x10 ) //ADPCM set length
12091265      {

Previous 15994 Revisions Next


© 1998-2018 The MESS Team