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 st /= (double)(524288/65536); // pre-multiply with 65536
slot->step = (UINT64)st; slot->step = (UINT32)st;
} }
else // internal waveform (FM) else // internal waveform (FM)
{ {
@ -293,7 +293,7 @@ void ymf271_device::calculate_step(YMF271Slot *slot)
st /= (double)(536870912/65536); // pre-multiply with 65536 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); calculate_step(slot);
} }
int ymf271_device::calculate_slot_volume(YMF271Slot *slot) INT64 ymf271_device::calculate_slot_volume(YMF271Slot *slot)
{ {
UINT64 volume; INT64 volume;
UINT64 env_volume; INT64 env_volume;
UINT64 lfo_volume = 65536; INT64 lfo_volume = 65536;
switch (slot->ams) switch (slot->ams)
{ {
case 0: lfo_volume = 65536; break; // 0dB case 0: lfo_volume = 65536; break; // 0dB
case 1: lfo_volume = 65536 - (((UINT64)slot->lfo_amplitude * 33124) >> 16); break; // 5.90625dB case 1: lfo_volume = 65536 - ((slot->lfo_amplitude * 33124) >> 16); break; // 5.90625dB
case 2: lfo_volume = 65536 - (((UINT64)slot->lfo_amplitude * 16742) >> 16); break; // 11.8125dB case 2: lfo_volume = 65536 - ((slot->lfo_amplitude * 16742) >> 16); break; // 11.8125dB
case 3: lfo_volume = 65536 - (((UINT64)slot->lfo_amplitude * 4277) >> 16); break; // 23.625dB 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; 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) void ymf271_device::update_pcm(int slotnum, INT32 *mixp, int length)
{ {
int i; int i;
int final_volume; INT64 final_volume;
INT16 sample; INT16 sample;
INT64 ch0_vol, ch1_vol; //, ch2_vol, ch3_vol; 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); final_volume = calculate_slot_volume(slot);
ch0_vol = ((UINT64)final_volume * (UINT64)channel_attenuation[slot->ch0_level]) >> 16; ch0_vol = (final_volume * channel_attenuation[slot->ch0_level]) >> 16;
ch1_vol = ((UINT64)final_volume * (UINT64)channel_attenuation[slot->ch1_level]) >> 16; ch1_vol = (final_volume * channel_attenuation[slot->ch1_level]) >> 16;
// ch2_vol = ((UINT64)final_volume * (UINT64)channel_attenuation[slot->ch2_level]) >> 16; // ch2_vol = (final_volume * channel_attenuation[slot->ch2_level]) >> 16;
// ch3_vol = ((UINT64)final_volume * (UINT64)channel_attenuation[slot->ch3_level]) >> 16; // ch3_vol = (final_volume * channel_attenuation[slot->ch3_level]) >> 16;
if (ch0_vol > 65536) ch0_vol = 65536; if (ch0_vol > 65536) ch0_vol = 65536;
if (ch1_vol > 65536) ch1_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 // calculates 2 operator FM using algorithm 0
// <--------| // <--------|
// +--[S1]--+--[S3]--> // +--[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 *slot1 = &m_slots[slotnum1];
YMF271Slot *slot2 = &m_slots[slotnum2]; 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 // calculates 2 operator FM using algorithm 1
// <-----------------| // <-----------------|
// +--[S1]--+--[S3]--|--> // +--[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 *slot1 = &m_slots[slotnum1];
YMF271Slot *slot2 = &m_slots[slotnum2]; 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 // 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]; YMF271Slot *slot = &m_slots[slotnum];
INT64 env; 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 // calculates the output of one FM operator with feedback modulation
// <--------| // <--------|
// +--[S1]--| // +--[S1]--|
INT32 ymf271_device::calculate_1op_fm_1(int slotnum) INT64 ymf271_device::calculate_1op_fm_1(int slotnum)
{ {
YMF271Slot *slot = &m_slots[slotnum]; YMF271Slot *slot = &m_slots[slotnum];
INT64 env; 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]; 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]; int groupnum = fm_tab[address & 0xf];
if (groupnum == -1) 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]; int slotnum = pcm_tab[m_pcmreg & 0xf];
if (slotnum == -1) if (slotnum == -1)
@ -1337,7 +1337,7 @@ UINT8 ymf271_device::ymf271_read_memory(UINT32 offset)
return m_ext_read_handler(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) if ((m_timerreg & 0xf0) == 0)
{ {

View File

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