noticed some inconsistencies with variable types (helps with big endian?)

This commit is contained in:
Michaël Banaan Ananas 2013-06-28 04:11:14 +00:00
parent cb71ef0446
commit d9060b615e
2 changed files with 73 additions and 73 deletions

View File

@ -281,7 +281,7 @@ void ymf271_device::calculate_step(YMF271Slot *slot)
st /= (double)(524288/65536); // pre-multiply with 65536
slot->step = (UINT64)st;
slot->step = (UINT32)st;
}
else // internal waveform (FM)
{
@ -293,7 +293,7 @@ void ymf271_device::calculate_step(YMF271Slot *slot)
st /= (double)(536870912/65536); // pre-multiply with 65536
slot->step = (UINT64)st;
slot->step = (UINT32)st;
}
}
@ -420,23 +420,23 @@ void ymf271_device::update_lfo(YMF271Slot *slot)
calculate_step(slot);
}
int ymf271_device::calculate_slot_volume(YMF271Slot *slot)
INT64 ymf271_device::calculate_slot_volume(YMF271Slot *slot)
{
UINT64 volume;
UINT64 env_volume;
UINT64 lfo_volume = 65536;
INT64 volume;
INT64 env_volume;
INT64 lfo_volume = 65536;
switch (slot->ams)
{
case 0: lfo_volume = 65536; break; // 0dB
case 1: lfo_volume = 65536 - (((UINT64)slot->lfo_amplitude * 33124) >> 16); break; // 5.90625dB
case 2: lfo_volume = 65536 - (((UINT64)slot->lfo_amplitude * 16742) >> 16); break; // 11.8125dB
case 3: lfo_volume = 65536 - (((UINT64)slot->lfo_amplitude * 4277) >> 16); break; // 23.625dB
case 1: lfo_volume = 65536 - ((slot->lfo_amplitude * 33124) >> 16); break; // 5.90625dB
case 2: lfo_volume = 65536 - ((slot->lfo_amplitude * 16742) >> 16); break; // 11.8125dB
case 3: lfo_volume = 65536 - ((slot->lfo_amplitude * 4277) >> 16); break; // 23.625dB
}
env_volume = ((UINT64)env_volume_table[255 - (slot->volume >> ENV_VOLUME_SHIFT)] * (UINT64)lfo_volume) >> 16;
env_volume = (env_volume_table[255 - (slot->volume >> ENV_VOLUME_SHIFT)] * lfo_volume) >> 16;
volume = ((UINT64)env_volume * (UINT64)total_level[slot->tl]) >> 16;
volume = (env_volume * total_level[slot->tl]) >> 16;
return volume;
}
@ -444,7 +444,7 @@ int ymf271_device::calculate_slot_volume(YMF271Slot *slot)
void ymf271_device::update_pcm(int slotnum, INT32 *mixp, int length)
{
int i;
int final_volume;
INT64 final_volume;
INT16 sample;
INT64 ch0_vol, ch1_vol; //, ch2_vol, ch3_vol;
@ -481,10 +481,10 @@ void ymf271_device::update_pcm(int slotnum, INT32 *mixp, int length)
final_volume = calculate_slot_volume(slot);
ch0_vol = ((UINT64)final_volume * (UINT64)channel_attenuation[slot->ch0_level]) >> 16;
ch1_vol = ((UINT64)final_volume * (UINT64)channel_attenuation[slot->ch1_level]) >> 16;
// ch2_vol = ((UINT64)final_volume * (UINT64)channel_attenuation[slot->ch2_level]) >> 16;
// ch3_vol = ((UINT64)final_volume * (UINT64)channel_attenuation[slot->ch3_level]) >> 16;
ch0_vol = (final_volume * channel_attenuation[slot->ch0_level]) >> 16;
ch1_vol = (final_volume * channel_attenuation[slot->ch1_level]) >> 16;
// ch2_vol = (final_volume * channel_attenuation[slot->ch2_level]) >> 16;
// ch3_vol = (final_volume * channel_attenuation[slot->ch3_level]) >> 16;
if (ch0_vol > 65536) ch0_vol = 65536;
if (ch1_vol > 65536) ch1_vol = 65536;
@ -505,7 +505,7 @@ void ymf271_device::update_pcm(int slotnum, INT32 *mixp, int length)
// calculates 2 operator FM using algorithm 0
// <--------|
// +--[S1]--+--[S3]-->
INT32 ymf271_device::calculate_2op_fm_0(int slotnum1, int slotnum2)
INT64 ymf271_device::calculate_2op_fm_0(int slotnum1, int slotnum2)
{
YMF271Slot *slot1 = &m_slots[slotnum1];
YMF271Slot *slot2 = &m_slots[slotnum2];
@ -542,7 +542,7 @@ INT32 ymf271_device::calculate_2op_fm_0(int slotnum1, int slotnum2)
// calculates 2 operator FM using algorithm 1
// <-----------------|
// +--[S1]--+--[S3]--|-->
INT32 ymf271_device::calculate_2op_fm_1(int slotnum1, int slotnum2)
INT64 ymf271_device::calculate_2op_fm_1(int slotnum1, int slotnum2)
{
YMF271Slot *slot1 = &m_slots[slotnum1];
YMF271Slot *slot2 = &m_slots[slotnum2];
@ -577,7 +577,7 @@ INT32 ymf271_device::calculate_2op_fm_1(int slotnum1, int slotnum2)
}
// calculates the output of one FM operator
INT32 ymf271_device::calculate_1op_fm_0(int slotnum, int phase_modulation)
INT64 ymf271_device::calculate_1op_fm_0(int slotnum, INT64 phase_modulation)
{
YMF271Slot *slot = &m_slots[slotnum];
INT64 env;
@ -601,7 +601,7 @@ INT32 ymf271_device::calculate_1op_fm_0(int slotnum, int phase_modulation)
// calculates the output of one FM operator with feedback modulation
// <--------|
// +--[S1]--|
INT32 ymf271_device::calculate_1op_fm_1(int slotnum)
INT64 ymf271_device::calculate_1op_fm_1(int slotnum)
{
YMF271Slot *slot = &m_slots[slotnum];
INT64 env;
@ -1004,7 +1004,7 @@ void ymf271_device::sound_stream_update(sound_stream &stream, stream_sample_t **
}
}
void ymf271_device::write_register(int slotnum, int reg, int data)
void ymf271_device::write_register(int slotnum, int reg, UINT8 data)
{
YMF271Slot *slot = &m_slots[slotnum];
@ -1110,7 +1110,7 @@ void ymf271_device::write_register(int slotnum, int reg, int data)
}
}
void ymf271_device::ymf271_write_fm(int bank, int address, int data)
void ymf271_device::ymf271_write_fm(int bank, UINT8 address, UINT8 data)
{
int groupnum = fm_tab[address & 0xf];
if (groupnum == -1)
@ -1207,7 +1207,7 @@ void ymf271_device::ymf271_write_fm(int bank, int address, int data)
}
}
void ymf271_device::ymf271_write_pcm(int data)
void ymf271_device::ymf271_write_pcm(UINT8 data)
{
int slotnum = pcm_tab[m_pcmreg & 0xf];
if (slotnum == -1)
@ -1337,7 +1337,7 @@ UINT8 ymf271_device::ymf271_read_memory(UINT32 offset)
return m_ext_read_handler(offset);
}
void ymf271_device::ymf271_write_timer(int data)
void ymf271_device::ymf271_write_timer(UINT8 data)
{
if ((m_timerreg & 0xf0) == 0)
{

View File

@ -40,39 +40,39 @@ protected:
private:
struct YMF271Slot
{
INT8 ext_en;
INT8 ext_out;
UINT8 ext_en;
UINT8 ext_out;
UINT8 lfoFreq;
INT8 lfowave;
INT8 pms, ams;
INT8 detune;
INT8 multiple;
INT8 tl;
INT8 keyscale;
INT8 ar;
INT8 decay1rate, decay2rate;
INT8 decay1lvl;
INT8 relrate;
INT32 fns;
INT8 block;
INT8 feedback;
INT8 waveform;
INT8 accon;
INT8 algorithm;
INT8 ch0_level, ch1_level, ch2_level, ch3_level;
UINT8 lfowave;
UINT8 pms, ams;
UINT8 detune;
UINT8 multiple;
UINT8 tl;
UINT8 keyscale;
UINT8 ar;
UINT8 decay1rate, decay2rate;
UINT8 decay1lvl;
UINT8 relrate;
UINT32 fns;
UINT8 block;
UINT8 feedback;
UINT8 waveform;
UINT8 accon;
UINT8 algorithm;
UINT8 ch0_level, ch1_level, ch2_level, ch3_level;
UINT32 startaddr;
UINT32 loopaddr;
UINT32 endaddr;
INT8 altloop;
INT8 fs;
INT8 srcnote, srcb;
UINT8 altloop;
UINT8 fs;
UINT8 srcnote, srcb;
INT64 step;
INT64 stepptr;
UINT32 step;
UINT32 stepptr;
INT8 active;
INT8 bits;
UINT8 active;
UINT8 bits;
// envelope generator
INT32 volume;
@ -85,14 +85,14 @@ private:
INT64 feedback_modulation0;
INT64 feedback_modulation1;
INT32 lfo_phase, lfo_step;
INT32 lfo_amplitude;
int lfo_phase, lfo_step;
int lfo_amplitude;
double lfo_phasemod;
};
struct YMF271Group
{
INT8 sync, pfm;
UINT8 sync, pfm;
};
void init_state();
@ -101,34 +101,34 @@ private:
void init_envelope(YMF271Slot *slot);
void init_lfo(YMF271Slot *slot);
void update_lfo(YMF271Slot *slot);
int calculate_slot_volume(YMF271Slot *slot);
INT64 calculate_slot_volume(YMF271Slot *slot);
void update_pcm(int slotnum, INT32 *mixp, int length);
INT32 calculate_2op_fm_0(int slotnum1, int slotnum2);
INT32 calculate_2op_fm_1(int slotnum1, int slotnum2);
INT32 calculate_1op_fm_0(int slotnum, int phase_modulation);
INT32 calculate_1op_fm_1(int slotnum);
void write_register(int slotnum, int reg, int data);
void ymf271_write_fm(int grp, int adr, int data);
void ymf271_write_pcm(int data);
INT64 calculate_2op_fm_0(int slotnum1, int slotnum2);
INT64 calculate_2op_fm_1(int slotnum1, int slotnum2);
INT64 calculate_1op_fm_0(int slotnum, INT64 phase_modulation);
INT64 calculate_1op_fm_1(int slotnum);
void write_register(int slotnum, int reg, UINT8 data);
void ymf271_write_fm(int bank, UINT8 address, UINT8 data);
void ymf271_write_pcm(UINT8 data);
UINT8 ymf271_read_memory(UINT32 offset);
void ymf271_write_timer(int data);
void ymf271_write_timer(UINT8 data);
// internal state
YMF271Slot m_slots[48];
YMF271Group m_groups[12];
INT32 m_timerA;
INT32 m_timerB;
INT32 m_irqstate;
INT8 m_status;
INT8 m_enable;
UINT32 m_timerA;
UINT32 m_timerB;
UINT8 m_irqstate;
UINT8 m_status;
UINT8 m_enable;
INT8 m_reg0;
INT8 m_reg1;
INT8 m_reg2;
INT8 m_reg3;
INT8 m_pcmreg;
INT8 m_timerreg;
UINT8 m_reg0;
UINT8 m_reg1;
UINT8 m_reg2;
UINT8 m_reg3;
UINT8 m_pcmreg;
UINT8 m_timerreg;
UINT32 m_ext_address;
UINT8 m_ext_rw;
UINT8 m_ext_readlatch;