mirror of
https://github.com/holub/mame
synced 2025-04-23 00:39:36 +03:00
k053260: add sample reverse flag
This commit is contained in:
parent
ba2ca8eb55
commit
9b84136e68
@ -49,7 +49,6 @@
|
||||
converting to fractional sample position; fixed ADPCM
|
||||
decoding bugs; added documentation.
|
||||
|
||||
|
||||
*********************************************************/
|
||||
|
||||
#include "emu.h"
|
||||
@ -70,7 +69,8 @@ DEFINE_DEVICE_TYPE(K053260, k053260_device, "k053260", "K053260 KDSC")
|
||||
// Pan multipliers. Set according to integer angles in degrees, amusingly.
|
||||
// Exact precision hard to know, the floating point-ish output format makes
|
||||
// comparisons iffy. So we used a 1.16 format.
|
||||
const int k053260_device::pan_mul[8][2] = {
|
||||
const int k053260_device::pan_mul[8][2] =
|
||||
{
|
||||
{ 0, 0 }, // No sound for pan 0
|
||||
{ 65536, 0 }, // 0 degrees
|
||||
{ 59870, 26656 }, // 24 degrees
|
||||
@ -170,11 +170,12 @@ void k053260_device::rom_bank_pre_change()
|
||||
|
||||
TIMER_CALLBACK_MEMBER(k053260_device::update_state_outputs)
|
||||
{
|
||||
switch(m_timer_state) {
|
||||
case 0: m_sh1_cb(ASSERT_LINE); break;
|
||||
case 1: m_sh1_cb(CLEAR_LINE); break;
|
||||
case 2: m_sh2_cb(ASSERT_LINE); break;
|
||||
case 3: m_sh2_cb(CLEAR_LINE); break;
|
||||
switch (m_timer_state)
|
||||
{
|
||||
case 0: m_sh1_cb(ASSERT_LINE); break;
|
||||
case 1: m_sh1_cb(CLEAR_LINE); break;
|
||||
case 2: m_sh2_cb(ASSERT_LINE); break;
|
||||
case 3: m_sh2_cb(CLEAR_LINE); break;
|
||||
}
|
||||
m_timer_state = (m_timer_state+1) & 3;
|
||||
}
|
||||
@ -255,9 +256,12 @@ void k053260_device::write(offs_t offset, u8 data)
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
if (rising_edge & (1 << i))
|
||||
if (BIT(rising_edge, i))
|
||||
{
|
||||
m_voice[i].set_reverse(BIT(data, 4 + i));
|
||||
m_voice[i].key_on();
|
||||
else if (!(data & (1 << i)))
|
||||
}
|
||||
else if (!BIT(data, i))
|
||||
m_voice[i].key_off();
|
||||
}
|
||||
m_keyon = data;
|
||||
@ -355,6 +359,7 @@ void k053260_device::KDSC_Voice::voice_start(int index)
|
||||
m_device.save_item(NAME(m_pan), index);
|
||||
m_device.save_item(NAME(m_loop), index);
|
||||
m_device.save_item(NAME(m_kadpcm), index);
|
||||
m_device.save_item(NAME(m_reverse), index);
|
||||
}
|
||||
|
||||
void k053260_device::KDSC_Voice::voice_reset()
|
||||
@ -370,6 +375,7 @@ void k053260_device::KDSC_Voice::voice_reset()
|
||||
m_pan = 0;
|
||||
m_loop = false;
|
||||
m_kadpcm = false;
|
||||
m_reverse = false;
|
||||
update_pan_volume();
|
||||
}
|
||||
|
||||
@ -406,8 +412,13 @@ void k053260_device::KDSC_Voice::set_register(offs_t offset, u8 data)
|
||||
|
||||
void k053260_device::KDSC_Voice::set_loop_kadpcm(u8 data)
|
||||
{
|
||||
m_loop = BIT(data, 0);
|
||||
m_kadpcm = BIT(data, 4);
|
||||
m_loop = bool(BIT(data, 0));
|
||||
m_kadpcm = bool(BIT(data, 4));
|
||||
}
|
||||
|
||||
void k053260_device::KDSC_Voice::set_reverse(u8 data)
|
||||
{
|
||||
m_reverse = bool(BIT(data, 0));
|
||||
}
|
||||
|
||||
void k053260_device::KDSC_Voice::set_pan(u8 data)
|
||||
@ -428,8 +439,15 @@ void k053260_device::KDSC_Voice::key_on()
|
||||
m_counter = 0x1000 - CLOCKS_PER_SAMPLE; // force update on next sound_stream_update
|
||||
m_output = 0;
|
||||
m_playing = true;
|
||||
if (LOG) m_device.logerror("K053260: start = %06x, length = %06x, pitch = %04x, vol = %02x:%x, loop = %s, %s\n",
|
||||
m_start, m_length, m_pitch, m_volume, m_pan, m_loop ? "yes" : "no", m_kadpcm ? "KADPCM" : "PCM" );
|
||||
|
||||
if (LOG)
|
||||
{
|
||||
m_device.logerror("K053260: start = %06x, length = %06x, pitch = %04x, vol = %02x:%x, loop = %s, reverse = %s, %s\n",
|
||||
m_start, m_length, m_pitch, m_volume, m_pan,
|
||||
m_loop ? "yes" : "no",
|
||||
m_reverse ? "yes" : "no",
|
||||
m_kadpcm ? "KADPCM" : "PCM" );
|
||||
}
|
||||
}
|
||||
|
||||
void k053260_device::KDSC_Voice::key_off()
|
||||
@ -447,7 +465,7 @@ void k053260_device::KDSC_Voice::play(s32 *outputs)
|
||||
{
|
||||
m_counter = m_counter - 0x1000 + m_pitch;
|
||||
|
||||
u32 bytepos = ++m_position >> ( m_kadpcm ? 1 : 0 );
|
||||
u32 bytepos = ++m_position >> (m_kadpcm ? 1 : 0);
|
||||
/*
|
||||
Yes, _pre_increment. Playback must start 1 byte position after the
|
||||
start address written to the register, or else ADPCM sounds will
|
||||
@ -471,7 +489,7 @@ void k053260_device::KDSC_Voice::play(s32 *outputs)
|
||||
}
|
||||
}
|
||||
|
||||
u8 romdata = m_device.read_byte(m_start + bytepos);
|
||||
u8 romdata = m_device.read_byte(m_start + (m_reverse ? -bytepos : +bytepos));
|
||||
|
||||
if (m_kadpcm)
|
||||
{
|
||||
|
@ -76,6 +76,7 @@ private:
|
||||
inline void voice_reset();
|
||||
inline void set_register(offs_t offset, u8 data);
|
||||
inline void set_loop_kadpcm(u8 data);
|
||||
inline void set_reverse(u8 data);
|
||||
inline void set_pan(u8 data);
|
||||
inline void update_pan_volume();
|
||||
inline void key_on();
|
||||
@ -89,22 +90,23 @@ private:
|
||||
k053260_device &m_device;
|
||||
|
||||
// live state
|
||||
u32 m_position = 0;
|
||||
u32 m_position;
|
||||
int m_pan_volume[2];
|
||||
u16 m_counter = 0;
|
||||
s8 m_output = 0;
|
||||
bool m_playing = false;
|
||||
u16 m_counter;
|
||||
s8 m_output;
|
||||
bool m_playing;
|
||||
|
||||
// per voice registers
|
||||
u32 m_start = 0;
|
||||
u16 m_length = 0;
|
||||
u16 m_pitch = 0;
|
||||
u8 m_volume = 0;
|
||||
u32 m_start;
|
||||
u16 m_length;
|
||||
u16 m_pitch;
|
||||
u8 m_volume;
|
||||
|
||||
// bit packed registers
|
||||
u8 m_pan = 0;
|
||||
bool m_loop = false;
|
||||
bool m_kadpcm = false;
|
||||
u8 m_pan;
|
||||
bool m_loop;
|
||||
bool m_kadpcm;
|
||||
bool m_reverse;
|
||||
} m_voice[4];
|
||||
};
|
||||
|
||||
|
@ -3368,7 +3368,7 @@ static INPUT_PORTS_START( litelrn )
|
||||
PORT_BIT( 0x200, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_0) PORT_CODE(KEYCODE_0_PAD) PORT_NAME("10")
|
||||
|
||||
PORT_START("IN.1") // O2
|
||||
PORT_CONFNAME( 0x0c, 0x04, "Mode" )
|
||||
PORT_CONFNAME( 0x0c, 0x00, "Mode" )
|
||||
PORT_CONFSETTING( 0x00, "Learn" )
|
||||
PORT_CONFSETTING( 0x0c, "Auto" )
|
||||
PORT_CONFSETTING( 0x04, "Manual" )
|
||||
|
Loading…
Reference in New Issue
Block a user