trunk/src/emu/sound/fm2612.c
| r18727 | r18728 | |
| 26 | 26 | ** |
| 27 | 27 | ** - fixed LFO implementation: |
| 28 | 28 | ** .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) |
| 30 | 30 | ** .improved LFO timing accuracy: now updated AFTER sample output, like EG/PG updates, and without any precision loss anymore. |
| 31 | 31 | ** - improved internal timers emulation |
| 32 | 32 | ** - adjusted lowest EG rates increment values |
| r18727 | r18728 | |
| 146 | 146 | |
| 147 | 147 | |
| 148 | 148 | #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) |
| 150 | 150 | #define TYPE_YM2610 (TYPE_SSG |TYPE_LFOPAN |TYPE_6CH |TYPE_ADPCM |TYPE_2610) |
| 151 | 151 | #define TYPE_YM2612 (TYPE_DAC |TYPE_LFOPAN |TYPE_6CH) |
| 152 | 152 | |
| r18727 | r18728 | |
| 1144 | 1144 | CH->SLOT[SLOT1].Incr=-1; |
| 1145 | 1145 | } |
| 1146 | 1146 | |
| 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 */ |
| 1148 | 1148 | /* and could result in SLOT->kc remaining unchanged. */ |
| 1149 | 1149 | /* 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) */ |
| 1151 | 1151 | if ((SLOT->ar + SLOT->ksr) < 94 /*32+62*/) |
| 1152 | 1152 | { |
| 1153 | 1153 | SLOT->eg_sh_ar = eg_rate_shift [SLOT->ar + SLOT->ksr ]; |
| r18727 | r18728 | |
| 1209 | 1209 | /* There are 128 LFO steps */ |
| 1210 | 1210 | OPN->lfo_cnt = ( OPN->lfo_cnt + 1 ) & 127; |
| 1211 | 1211 | |
| 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 */ |
| 1214 | 1214 | if (OPN->lfo_cnt<64) |
| 1215 | | OPN->LFO_AM = OPN->lfo_cnt * 2; |
| 1215 | OPN->LFO_AM = (OPN->lfo_cnt ^ 63) << 1; |
| 1216 | 1216 | else |
| 1217 | | OPN->LFO_AM = 126 - ((OPN->lfo_cnt&63) * 2); |
| 1217 | OPN->LFO_AM = (OPN->lfo_cnt & 63) << 1; |
| 1218 | 1218 | |
| 1219 | 1219 | /* PM works with 4 times slower clock */ |
| 1220 | 1220 | OPN->LFO_PM = OPN->lfo_cnt >> 2; |
| r18727 | r18728 | |
| 1592 | 1592 | INLINE void chan_calc(YM2612 *F2612, FM_OPN *OPN, FM_CH *CH) |
| 1593 | 1593 | { |
| 1594 | 1594 | UINT32 AM = OPN->LFO_AM >> CH->ams; |
| 1595 | unsigned int eg_out = volume_calc(&CH->SLOT[SLOT1]); |
| 1595 | 1596 | |
| 1596 | 1597 | OPN->m2 = OPN->c1 = OPN->c2 = OPN->mem = 0; |
| 1597 | 1598 | |
| 1598 | 1599 | *CH->mem_connect = CH->mem_value; /* restore delayed sample (MEM) value to m2 or c2 */ |
| 1599 | 1600 | |
| 1600 | | unsigned int eg_out = volume_calc(&CH->SLOT[SLOT1]); |
| 1601 | 1601 | { |
| 1602 | 1602 | INT32 out = CH->op1_out[0] + CH->op1_out[1]; |
| 1603 | 1603 | CH->op1_out[0] = CH->op1_out[1]; |
| r18727 | r18728 | |
| 1737 | 1737 | case 0x22: /* LFO FREQ (YM2608/YM2610/YM2610B/YM2612) */ |
| 1738 | 1738 | if (v&8) /* LFO enabled ? */ |
| 1739 | 1739 | { |
| 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 | | |
| 1749 | 1740 | OPN->lfo_timer_overflow = lfo_samples_per_step[v&7] << LFO_SH; |
| 1750 | 1741 | } |
| 1751 | 1742 | else |
| 1752 | 1743 | { |
| 1744 | /* hold LFO waveform in reset state */ |
| 1753 | 1745 | 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; |
| 1754 | 1750 | } |
| 1755 | 1751 | break; |
| 1756 | 1752 | case 0x24: /* timer A High 8*/ |
| r18727 | r18728 | |
| 2418 | 2414 | |
| 2419 | 2415 | OPN->lfo_timer = 0; |
| 2420 | 2416 | OPN->lfo_cnt = 0; |
| 2421 | | OPN->LFO_AM = 0; |
| 2417 | OPN->LFO_AM = 126; |
| 2422 | 2418 | OPN->LFO_PM = 0; |
| 2423 | 2419 | |
| 2424 | 2420 | OPN->ST.status = 0; |