Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. void OPM_DoLFO(ym2151_t *chip)
  2. {
  3. // LFO timer 1
  4. if ((chip->cycles & 0x0f) == 0x0c)
  5. {
  6. chip->lfo_timer1++;
  7. }
  8. chip->lfo_timer1_overflow <<= 1;
  9. chip->lfo_timer1_overflow |= chip->lfo_timer1 >> 4;
  10. chip->lfo_timer1 &= 0x0f;
  11. // LFO timer 2
  12. chip->lfo_timer2 += ((chip->lfo_timer1_overflow >> 2) & 0x01) | chip->mode_test[3];
  13. chip->lfo_timer2_reset <<= 1;
  14. chip->lfo_timer2_reset |= chip->lfo_timer2 >> 15;
  15. chip->lfo_counter_inc <<= 1;
  16. chip->lfo_counter_inc |= (chip->lfo_timer2 >> 15) | chip->lfo_counter_inc1 | chip->mode_test[2];
  17. if ((chip->cycles & 0x0f) == 0x0e)
  18. {
  19. chip->lfo_timer2_overflow |= chip->lfo_timer2 >> 15;
  20. }
  21. chip->lfo_timer2 &= 0x7fff;
  22. if (chip->lfo_timer2_reset & 0x04)
  23. {
  24. chip->lfo_timer2 = 0x8000 - (1 << chip->lfo_freq_hi);
  25. }
  26. }
  27.  
  28. void OPM_DoLFO2(ym2151_t *chip)
  29. {
  30. chip->lfo_counter_inc1 = 0;
  31. // LFO timer 3
  32. if ((chip->cycles & 0x0f) == 0x05)
  33. {
  34. chip->lfo_timer2_overflow <<= 1;
  35. }
  36. if ((chip->cycles & 0x0f) == 0x0d && (chip->lfo_timer2_overflow & 0x02) != 0)
  37. {
  38. if (((chip->lfo_timer3 & 0x01) == 0x00 && (chip->lfo_freq_lo & 0x01) != 0)
  39. || ((chip->lfo_timer3 & 0x03) == 0x01 && (chip->lfo_freq_lo & 0x02) != 0)
  40. || ((chip->lfo_timer3 & 0x07) == 0x03 && (chip->lfo_freq_lo & 0x04) != 0)
  41. || ((chip->lfo_timer3 & 0x0f) == 0x07 && (chip->lfo_freq_lo & 0x08) != 0))
  42. {
  43. chip->lfo_counter_inc1 = 1;
  44. }
  45. chip->lfo_timer3++;
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement