Previous 199869 Revisions Next

r18728 Friday 26th October, 2012 at 22:05:32 UTC by R. Belmont
YM2612: fix LFO AM waveform [Eke-Eke, R. Belmont]
[src/emu/sound]fm2612.c

trunk/src/emu/sound/fm2612.c
r18727r18728
2626**
2727**  - fixed LFO implementation:
2828**      .added support for CH3 special mode: fixes various sound effects (birds in Warlock, bug sound in Aladdin...)
29**      .modified LFO behavior when switched off (AM/PM current level is held) and on (LFO step is reseted): fixes intro in Spider-Man & Venom : Separation Anxiety
29**      .inverted LFO AM waveform: fixes Spider-Man & Venom : Separation Anxiety (intro), California Games (surfing event)
3030**      .improved LFO timing accuracy: now updated AFTER sample output, like EG/PG updates, and without any precision loss anymore.
3131**  - improved internal timers emulation
3232**  - adjusted lowest EG rates increment values
r18727r18728
146146
147147
148148#define TYPE_YM2203 (TYPE_SSG)
149#define TYPE_YM2608 (TYPE_SSG |TYPE_LFOPAN |TYPE_6CH |TYPE_ADPCM)
149#define TYPE_YM2608 (TYPE_SSG |TYPE_LFO= PAN |TYPE_6CH |TYPE_ADPCM)
150150#define TYPE_YM2610 (TYPE_SSG |TYPE_LFOPAN |TYPE_6CH |TYPE_ADPCM |TYPE_2610)
151151#define TYPE_YM2612 (TYPE_DAC |TYPE_LFOPAN |TYPE_6CH)
152152
r18727r18728
11441144      CH->SLOT[SLOT1].Incr=-1;
11451145   }
11461146
1147   /* Even if it seems unnecessary, in some odd case, KSR and KC are both modified   */
1147   /* Even if it seems unnecessary, in some odd case, KSR and KC are modified   */
11481148   /* and could result in SLOT->kc remaining unchanged.                              */
11491149   /* In such case, AR values would not be recalculated despite SLOT->ar has changed */
1150   /* This fixes the introduction music of Batman & Robin    (Eke-Eke)              */
1150   /* This actually fixes the intro of "The Adventures of Batman & Robin" (Eke-Eke) */
11511151   if ((SLOT->ar + SLOT->ksr) < 94 /*32+62*/)
11521152   {
11531153      SLOT->eg_sh_ar  = eg_rate_shift [SLOT->ar  + SLOT->ksr ];
r18727r18728
12091209         /* There are 128 LFO steps */
12101210         OPN->lfo_cnt = ( OPN->lfo_cnt + 1 ) & 127;
12111211
1212         /* triangle */
1213         /* AM: 0 to 126 step +2, 126 to 0 step -2 */
1212            /* triangle (inverted) */
1213            /* AM: from 126 to 0 step -2, 0 to 126 step +2 */
12141214         if (OPN->lfo_cnt<64)
1215            OPN->LFO_AM = OPN->lfo_cnt * 2;
1215            OPN->LFO_AM = (OPN->lfo_cnt ^ 63) << 1;
12161216         else
1217            OPN->LFO_AM = 126 - ((OPN->lfo_cnt&63) * 2);
1217            OPN->LFO_AM = (OPN->lfo_cnt & 63) << 1;
12181218
12191219         /* PM works with 4 times slower clock */
12201220         OPN->LFO_PM = OPN->lfo_cnt >> 2;
r18727r18728
15921592INLINE void chan_calc(YM2612 *F2612, FM_OPN *OPN, FM_CH *CH)
15931593{
15941594  UINT32 AM = OPN->LFO_AM >> CH->ams;
1595  unsigned int eg_out = volume_calc(&CH->SLOT[SLOT1]);
15951596
15961597  OPN->m2 = OPN->c1 = OPN->c2 = OPN->mem = 0;
15971598
15981599  *CH->mem_connect = CH->mem_value;  /* restore delayed sample (MEM) value to m2 or c2 */
15991600
1600  unsigned int eg_out = volume_calc(&CH->SLOT[SLOT1]);
16011601  {
16021602    INT32 out = CH->op1_out[0] + CH->op1_out[1];
16031603    CH->op1_out[0] = CH->op1_out[1];
r18727r18728
17371737   case 0x22:   /* LFO FREQ (YM2608/YM2610/YM2610B/YM2612) */
17381738      if (v&8) /* LFO enabled ? */
17391739      {
1740         if (!OPN->lfo_timer_overflow)
1741         {
1742            /* restart LFO */
1743            OPN->lfo_cnt   = 0;
1744            OPN->lfo_timer = 0;
1745            OPN->LFO_AM    = 0;
1746            OPN->LFO_PM    = 0;
1747         }
1748
17491740         OPN->lfo_timer_overflow = lfo_samples_per_step[v&7] << LFO_SH;
17501741      }
17511742      else
17521743      {
1744            /* hold LFO waveform in reset state */
17531745         OPN->lfo_timer_overflow = 0;
1746            OPN->lfo_timer = 0;
1747            OPN->lfo_cnt   = 0;
1748            OPN->LFO_PM    = 0;
1749            OPN->LFO_AM    = 126;
17541750      }
17551751      break;
17561752   case 0x24:   /* timer A High 8*/
r18727r18728
24182414
24192415   OPN->lfo_timer = 0;
24202416   OPN->lfo_cnt   = 0;
2421   OPN->LFO_AM    = 0;
2417   OPN->LFO_AM    = 126;
24222418   OPN->LFO_PM    = 0;
24232419
24242420   OPN->ST.status = 0;

Previous 199869 Revisions Next


© 1997-2024 The MAME Team