Previous 199869 Revisions Next

r23985 Friday 28th June, 2013 at 04:11:14 UTC by hap
noticed some inconsistencies with variable types (helps with big endian?)
[src/emu/sound]ymf271.c ymf271.h

trunk/src/emu/sound/ymf271.c
r23984r23985
281281
282282      st /= (double)(524288/65536);       // pre-multiply with 65536
283283
284      slot->step = (UINT64)st;
284      slot->step = (UINT32)st;
285285   }
286286   else                        // internal waveform (FM)
287287   {
r23984r23985
293293
294294      st /= (double)(536870912/65536);    // pre-multiply with 65536
295295
296      slot->step = (UINT64)st;
296      slot->step = (UINT32)st;
297297   }
298298}
299299
r23984r23985
420420   calculate_step(slot);
421421}
422422
423int ymf271_device::calculate_slot_volume(YMF271Slot *slot)
423INT64 ymf271_device::calculate_slot_volume(YMF271Slot *slot)
424424{
425   UINT64 volume;
426   UINT64 env_volume;
427   UINT64 lfo_volume = 65536;
425   INT64 volume;
426   INT64 env_volume;
427   INT64 lfo_volume = 65536;
428428
429429   switch (slot->ams)
430430   {
431431      case 0: lfo_volume = 65536; break;  // 0dB
432      case 1: lfo_volume = 65536 - (((UINT64)slot->lfo_amplitude * 33124) >> 16); break;  // 5.90625dB
433      case 2: lfo_volume = 65536 - (((UINT64)slot->lfo_amplitude * 16742) >> 16); break;  // 11.8125dB
434      case 3: lfo_volume = 65536 - (((UINT64)slot->lfo_amplitude * 4277) >> 16); break;   // 23.625dB
432      case 1: lfo_volume = 65536 - ((slot->lfo_amplitude * 33124) >> 16); break;  // 5.90625dB
433      case 2: lfo_volume = 65536 - ((slot->lfo_amplitude * 16742) >> 16); break;  // 11.8125dB
434      case 3: lfo_volume = 65536 - ((slot->lfo_amplitude * 4277) >> 16); break;   // 23.625dB
435435   }
436436
437   env_volume = ((UINT64)env_volume_table[255 - (slot->volume >> ENV_VOLUME_SHIFT)] * (UINT64)lfo_volume) >> 16;
437   env_volume = (env_volume_table[255 - (slot->volume >> ENV_VOLUME_SHIFT)] * lfo_volume) >> 16;
438438
439   volume = ((UINT64)env_volume * (UINT64)total_level[slot->tl]) >> 16;
439   volume = (env_volume * total_level[slot->tl]) >> 16;
440440
441441   return volume;
442442}
r23984r23985
444444void ymf271_device::update_pcm(int slotnum, INT32 *mixp, int length)
445445{
446446   int i;
447   int final_volume;
447   INT64 final_volume;
448448   INT16 sample;
449449   INT64 ch0_vol, ch1_vol; //, ch2_vol, ch3_vol;
450450
r23984r23985
481481
482482      final_volume = calculate_slot_volume(slot);
483483
484      ch0_vol = ((UINT64)final_volume * (UINT64)channel_attenuation[slot->ch0_level]) >> 16;
485      ch1_vol = ((UINT64)final_volume * (UINT64)channel_attenuation[slot->ch1_level]) >> 16;
486//      ch2_vol = ((UINT64)final_volume * (UINT64)channel_attenuation[slot->ch2_level]) >> 16;
487//      ch3_vol = ((UINT64)final_volume * (UINT64)channel_attenuation[slot->ch3_level]) >> 16;
484      ch0_vol = (final_volume * channel_attenuation[slot->ch0_level]) >> 16;
485      ch1_vol = (final_volume * channel_attenuation[slot->ch1_level]) >> 16;
486//      ch2_vol = (final_volume * channel_attenuation[slot->ch2_level]) >> 16;
487//      ch3_vol = (final_volume * channel_attenuation[slot->ch3_level]) >> 16;
488488
489489      if (ch0_vol > 65536) ch0_vol = 65536;
490490      if (ch1_vol > 65536) ch1_vol = 65536;
r23984r23985
505505// calculates 2 operator FM using algorithm 0
506506// <--------|
507507// +--[S1]--+--[S3]-->
508INT32 ymf271_device::calculate_2op_fm_0(int slotnum1, int slotnum2)
508INT64 ymf271_device::calculate_2op_fm_0(int slotnum1, int slotnum2)
509509{
510510   YMF271Slot *slot1 = &m_slots[slotnum1];
511511   YMF271Slot *slot2 = &m_slots[slotnum2];
r23984r23985
542542// calculates 2 operator FM using algorithm 1
543543// <-----------------|
544544// +--[S1]--+--[S3]--|-->
545INT32 ymf271_device::calculate_2op_fm_1(int slotnum1, int slotnum2)
545INT64 ymf271_device::calculate_2op_fm_1(int slotnum1, int slotnum2)
546546{
547547   YMF271Slot *slot1 = &m_slots[slotnum1];
548548   YMF271Slot *slot2 = &m_slots[slotnum2];
r23984r23985
577577}
578578
579579// calculates the output of one FM operator
580INT32 ymf271_device::calculate_1op_fm_0(int slotnum, int phase_modulation)
580INT64 ymf271_device::calculate_1op_fm_0(int slotnum, INT64 phase_modulation)
581581{
582582   YMF271Slot *slot = &m_slots[slotnum];
583583   INT64 env;
r23984r23985
601601// calculates the output of one FM operator with feedback modulation
602602// <--------|
603603// +--[S1]--|
604INT32 ymf271_device::calculate_1op_fm_1(int slotnum)
604INT64 ymf271_device::calculate_1op_fm_1(int slotnum)
605605{
606606   YMF271Slot *slot = &m_slots[slotnum];
607607   INT64 env;
r23984r23985
10041004   }
10051005}
10061006
1007void ymf271_device::write_register(int slotnum, int reg, int data)
1007void ymf271_device::write_register(int slotnum, int reg, UINT8 data)
10081008{
10091009   YMF271Slot *slot = &m_slots[slotnum];
10101010
r23984r23985
11101110   }
11111111}
11121112
1113void ymf271_device::ymf271_write_fm(int bank, int address, int data)
1113void ymf271_device::ymf271_write_fm(int bank, UINT8 address, UINT8 data)
11141114{
11151115   int groupnum = fm_tab[address & 0xf];
11161116   if (groupnum == -1)
r23984r23985
12071207   }
12081208}
12091209
1210void ymf271_device::ymf271_write_pcm(int data)
1210void ymf271_device::ymf271_write_pcm(UINT8 data)
12111211{
12121212   int slotnum = pcm_tab[m_pcmreg & 0xf];
12131213   if (slotnum == -1)
r23984r23985
13371337      return m_ext_read_handler(offset);
13381338}
13391339
1340void ymf271_device::ymf271_write_timer(int data)
1340void ymf271_device::ymf271_write_timer(UINT8 data)
13411341{
13421342   if ((m_timerreg & 0xf0) == 0)
13431343   {
trunk/src/emu/sound/ymf271.h
r23984r23985
4040private:
4141   struct YMF271Slot
4242   {
43      INT8  ext_en;
44      INT8  ext_out;
43      UINT8 ext_en;
44      UINT8 ext_out;
4545      UINT8 lfoFreq;
46      INT8  lfowave;
47      INT8  pms, ams;
48      INT8  detune;
49      INT8  multiple;
50      INT8  tl;
51      INT8  keyscale;
52      INT8  ar;
53      INT8  decay1rate, decay2rate;
54      INT8  decay1lvl;
55      INT8  relrate;
56      INT32 fns;
57      INT8  block;
58      INT8  feedback;
59      INT8  waveform;
60      INT8  accon;
61      INT8  algorithm;
62      INT8  ch0_level, ch1_level, ch2_level, ch3_level;
46      UINT8 lfowave;
47      UINT8 pms, ams;
48      UINT8 detune;
49      UINT8 multiple;
50      UINT8 tl;
51      UINT8 keyscale;
52      UINT8 ar;
53      UINT8 decay1rate, decay2rate;
54      UINT8 decay1lvl;
55      UINT8 relrate;
56      UINT32 fns;
57      UINT8 block;
58      UINT8 feedback;
59      UINT8 waveform;
60      UINT8 accon;
61      UINT8 algorithm;
62      UINT8 ch0_level, ch1_level, ch2_level, ch3_level;
6363
6464      UINT32 startaddr;
6565      UINT32 loopaddr;
6666      UINT32 endaddr;
67      INT8   altloop;
68      INT8   fs;
69      INT8   srcnote, srcb;
67      UINT8 altloop;
68      UINT8 fs;
69      UINT8 srcnote, srcb;
7070
71      INT64 step;
72      INT64 stepptr;
71      UINT32 step;
72      UINT32 stepptr;
7373
74      INT8 active;
75      INT8 bits;
74      UINT8 active;
75      UINT8 bits;
7676
7777      // envelope generator
7878      INT32 volume;
r23984r23985
8585      INT64 feedback_modulation0;
8686      INT64 feedback_modulation1;
8787
88      INT32 lfo_phase, lfo_step;
89      INT32 lfo_amplitude;
88      int lfo_phase, lfo_step;
89      int lfo_amplitude;
9090      double lfo_phasemod;
9191   };
9292
9393   struct YMF271Group
9494   {
95      INT8 sync, pfm;
95      UINT8 sync, pfm;
9696   };
9797
9898   void init_state();
r23984r23985
101101   void init_envelope(YMF271Slot *slot);
102102   void init_lfo(YMF271Slot *slot);
103103   void update_lfo(YMF271Slot *slot);
104   int calculate_slot_volume(YMF271Slot *slot);
104   INT64 calculate_slot_volume(YMF271Slot *slot);
105105   void update_pcm(int slotnum, INT32 *mixp, int length);
106   INT32 calculate_2op_fm_0(int slotnum1, int slotnum2);
107   INT32 calculate_2op_fm_1(int slotnum1, int slotnum2);
108   INT32 calculate_1op_fm_0(int slotnum, int phase_modulation);
109   INT32 calculate_1op_fm_1(int slotnum);
110   void write_register(int slotnum, int reg, int data);
111   void ymf271_write_fm(int grp, int adr, int data);
112   void ymf271_write_pcm(int data);
106   INT64 calculate_2op_fm_0(int slotnum1, int slotnum2);
107   INT64 calculate_2op_fm_1(int slotnum1, int slotnum2);
108   INT64 calculate_1op_fm_0(int slotnum, INT64 phase_modulation);
109   INT64 calculate_1op_fm_1(int slotnum);
110   void write_register(int slotnum, int reg, UINT8 data);
111   void ymf271_write_fm(int bank, UINT8 address, UINT8 data);
112   void ymf271_write_pcm(UINT8 data);
113113   UINT8 ymf271_read_memory(UINT32 offset);
114   void ymf271_write_timer(int data);
114   void ymf271_write_timer(UINT8 data);
115115
116116   // internal state
117117   YMF271Slot m_slots[48];
118118   YMF271Group m_groups[12];
119119
120   INT32 m_timerA;
121   INT32 m_timerB;
122   INT32 m_irqstate;
123   INT8  m_status;
124   INT8  m_enable;
120   UINT32 m_timerA;
121   UINT32 m_timerB;
122   UINT8 m_irqstate;
123   UINT8 m_status;
124   UINT8 m_enable;
125125
126   INT8  m_reg0;
127   INT8  m_reg1;
128   INT8  m_reg2;
129   INT8  m_reg3;
130   INT8  m_pcmreg;
131   INT8  m_timerreg;
126   UINT8 m_reg0;
127   UINT8 m_reg1;
128   UINT8 m_reg2;
129   UINT8 m_reg3;
130   UINT8 m_pcmreg;
131   UINT8 m_timerreg;
132132   UINT32 m_ext_address;
133133   UINT8 m_ext_rw;
134134   UINT8 m_ext_readlatch;

Previous 199869 Revisions Next


© 1997-2024 The MAME Team