Previous 15994 Revisions Next

r4933 Thursday 4th June, 2009 at 08:13:57 UTC by Barry Rodewald
[FM7] Fixed PSG sound output.
[src/mess/drivers]fm7.c

src/mess/drivers/fm7.c
r4932r4933
6666static UINT8 break_flag;
6767static UINT8 fm7_pal[8];
6868static UINT8 fm7_psg_regsel;
69static UINT8 psg_data;
6970
7071/* key scancode conversion table
7172 * The FM-7 expects different scancodes when shift,ctrl or graph is held, or
r4932r4933
488489   palette_set_color(space->machine,offset,MAKE_RGB(r,g,b));
489490   fm7_pal[offset] = data & 0x07;
490491}
492static void fm7_update_psg(running_machine* machine)
493{
494   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
491495
496   switch(fm7_psg_regsel)
497   {
498      case 0x00:
499         // High impedance
500         break;
501      case 0x01:
502         // Data read
503         psg_data = ay8910_r(devtag_get_device(space->machine,"psg"),0);
504         break;
505      case 0x02:
506         // Data write
507         ay8910_data_w(devtag_get_device(space->machine,"psg"),0,psg_data);
508         break;
509      case 0x03:
510         // Address latch
511         ay8910_address_w(devtag_get_device(space->machine,"psg"),0,psg_data);
512         break;
513   }
514}
515
492516static READ8_HANDLER( fm7_psg_select_r )
493517{
494518   return 0xff;
r4932r4933
496520
497521static WRITE8_HANDLER( fm7_psg_select_w )
498522{
499   static UINT8 prev;
500523   /*
501524    * bit 0 = BC1
502525    * bit 1 = BDIR
503    *
504    * function is selected when both bits are set to 0
505526    */
506   if((data & 0x03) == 0x00)
507      fm7_psg_regsel = prev & 0x03;
508   prev = data;
527   fm7_psg_regsel = data & 0x03;
528   fm7_update_psg(space->machine);
509529}
510530
511531static READ8_HANDLER( fm7_psg_data_r )
512532{
513   switch(fm7_psg_regsel)
514   {
515      case 0x00:
516         // High impedance
517         return 0xff;
518      case 0x01:
519         // Data read
520         return ay8910_r(devtag_get_device(space->machine,"psg"),0);
521      case 0x02:
522         // Data write
523      case 0x03:
524         // Address latch
525         logerror("PSG: Read from data register when Data Read is not selected\n");
526   }
527   return 0xff;
533   fm7_update_psg(space->machine);
534   return psg_data;
528535}
529536
530537static WRITE8_HANDLER( fm7_psg_data_w )
531538{
532   switch(fm7_psg_regsel)
533   {
534      case 0x00:
535         // High impedance
536         break;
537      case 0x01:
538         // Data read
539         logerror("PSG: Read from data register when Data Read is not selected\n");
540         break;
541      case 0x02:
542         // Data write
543         ay8910_data_w(devtag_get_device(space->machine,"psg"),0,data);
544         break;
545      case 0x03:
546         // Address latch
547         ay8910_address_w(devtag_get_device(space->machine,"psg"),0,data);
548         break;
549   }
539   psg_data = data;
540   fm7_update_psg(space->machine);
550541}
551542
552543static TIMER_CALLBACK( fm7_timer_irq )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team