Previous 15994 Revisions Next

r9158 Friday 17th September, 2010 at 10:22:23 UTC by Angelo Salese
[PCE]: Added a CD-DA set volume function, and implemented a minimal fade out function in the driver
[src/emu/sound]cdda.c cdda.h
[src/mess/machine]pce.c

src/emu/sound/cdda.c
r9157r9158
290290   get_audio_data(info, bufL, bufR, remaining);
291291}
292292
293/*-------------------------------------------------
294    cdda_set_volume - sets CD-DA volume level
295    for both speakers, used for fade in/out effects
296-------------------------------------------------*/
293297
298void cdda_set_volume(running_device *device,int volume)
299{
300   cdda_info *cdda = get_safe_token(device);
294301
302   stream_set_output_gain(cdda->stream,0,volume / 100.0);
303   stream_set_output_gain(cdda->stream,1,volume / 100.0);
304}
305
295306/**************************************************************************
296307 * Generic get_info
297308 **************************************************************************/
src/emu/sound/cdda.h
r9157r9158
1111void cdda_start_audio(running_device *device, UINT32 startlba, UINT32 numblocks);
1212void cdda_stop_audio(running_device *device);
1313void cdda_pause_audio(running_device *device, int pause);
14void cdda_set_volume(running_device *device,int volume);
1415
1516UINT32 cdda_get_audio_lba(running_device *device);
1617int cdda_audio_active(running_device *device);
src/mess/machine/pce.c
r9157r9158
151151   const cdrom_toc*   toc;
152152   emu_timer   *data_timer;
153153   emu_timer   *adpcm_dma_timer;
154
155   emu_timer   *cdda_fadeout_timer;
156   double   cdda_volume;
157//   emu_timer   *cdda_fadeout_timer;
154158} pce_cd;
155159
156160/* MSM5205 ADPCM decoder definition */
r9157r9158
176180static void pce_cd_init( running_machine *machine );
177181static void pce_cd_set_irq_line( running_machine *machine, int num, int state );
178182static TIMER_CALLBACK( pce_cd_adpcm_dma_timer_callback );
183static TIMER_CALLBACK( pce_cd_cdda_fadeout_callback );
179184
180185
181186static WRITE8_HANDLER( pce_sf2_banking_w )
r9157r9158
12391244   timer_adjust_oneshot(pce_cd.data_timer, attotime_never, 0);
12401245   pce_cd.adpcm_dma_timer = timer_alloc(machine,  pce_cd_adpcm_dma_timer_callback , NULL);
12411246   timer_adjust_oneshot(pce_cd.adpcm_dma_timer, attotime_never, 0);
1247   pce_cd.cdda_fadeout_timer = timer_alloc(machine,  pce_cd_cdda_fadeout_callback , NULL);
1248   timer_adjust_oneshot(pce_cd.cdda_fadeout_timer, attotime_never, 0);
12421249}
12431250
12441251WRITE8_HANDLER( pce_cd_bram_w )
r9157r9158
12631270   }
12641271}
12651272
1273static TIMER_CALLBACK( pce_cd_cdda_fadeout_callback )
1274{
1275   pce_cd.cdda_volume-= 1.0; //TODO: step here could be wrong
1276   cdda_set_volume(machine->device("cdda"), pce_cd.cdda_volume);
1277
1278   if(pce_cd.cdda_volume <= 0)
1279      timer_adjust_oneshot(pce_cd.cdda_fadeout_timer, attotime_never, NULL);
1280   else
1281      timer_adjust_oneshot(pce_cd.cdda_fadeout_timer, ATTOTIME_IN_USEC(param), param);
1282}
1283
12661284WRITE8_HANDLER( pce_cd_intf_w )
12671285{
12681286   pce_cd_update(space->machine);
r9157r9158
13831401      msm5205_change_clock_w(space->machine->device("msm5205"), (PCE_CD_CLOCK / 6) / pce_cd.adpcm_clock_divider);
13841402      break;
13851403   case 0x0F:   /* ADPCM and CD audio fade timer */
1404      printf("%02x FADE\n",data);
1405
1406      if(data == 0x0c) //CD-DA short step (2500 msecs) fade out
1407      {
1408         pce_cd.cdda_volume = 100.0;
1409         timer_adjust_oneshot(pce_cd.cdda_fadeout_timer, ATTOTIME_IN_USEC(2500), 2500);
1410      }
1411
1412      if(data == 0x00) //CD-DA fade in (TODO)
1413      {
1414         pce_cd.cdda_volume = 100.0;
1415         cdda_set_volume(space->machine->device("cdda"), 100.0);
1416      }
13861417      break;
13871418   default:
13881419      return;
13891420   }
1390   pce_cd.regs[offset] = data;
1421   pce_cd.regs[offset & 0xf] = data;
13911422   pce_cd_update(space->machine);
13921423}
13931424

Previous 15994 Revisions Next


© 1998-2018 The MESS Team