summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/sound/rf5c400.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/sound/rf5c400.cpp')
-rw-r--r--src/devices/sound/rf5c400.cpp82
1 files changed, 57 insertions, 25 deletions
diff --git a/src/devices/sound/rf5c400.cpp b/src/devices/sound/rf5c400.cpp
index 39440c66991..6c047935399 100644
--- a/src/devices/sound/rf5c400.cpp
+++ b/src/devices/sound/rf5c400.cpp
@@ -129,7 +129,7 @@ void rf5c400_device::envelope_tables::init(uint32_t clock)
rf5c400_device::rf5c400_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, RF5C400, tag, owner, clock)
, device_sound_interface(mconfig, *this)
- , m_rom(*this, DEVICE_SELF)
+ , device_rom_interface(mconfig, *this, 25, ENDIANNESS_LITTLE, 16)
, m_stream(nullptr)
, m_env_tables()
{
@@ -155,6 +155,10 @@ void rf5c400_device::device_start()
chan.env_scale = 1.0;
}
+ save_item(NAME(m_rf5c400_status));
+ save_item(NAME(m_ext_mem_address));
+ save_item(NAME(m_ext_mem_data));
+
for (int i = 0; i < ARRAY_LENGTH(m_channels); i++)
{
save_item(NAME(m_channels[i].startH), i);
@@ -180,8 +184,6 @@ void rf5c400_device::device_start()
}
m_stream = stream_alloc(0, 2, clock() / 384);
-
- m_rommask = m_rom.length() - 1;
}
//-------------------------------------------------
@@ -191,7 +193,6 @@ void rf5c400_device::device_start()
void rf5c400_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
{
int i, ch;
- int16_t *rom = m_rom;
uint32_t end, loop;
uint64_t pos;
uint8_t vol, lvol, rvol, type;
@@ -228,7 +229,7 @@ void rf5c400_device::sound_stream_update(sound_stream &stream, stream_sample_t *
if (env_phase == PHASE_NONE) break;
- tmp = rom[(pos>>16) & m_rommask];
+ tmp = read_word((pos>>16)<<1);
switch ( type )
{
case TYPE_16:
@@ -258,7 +259,7 @@ void rf5c400_device::sound_stream_update(sound_stream &stream, stream_sample_t *
{
env_phase = PHASE_DECAY;
env_level = 1.0;
- if (channel->decay & 0x0080)
+ if ((channel->decay & 0x0080) || (channel->decay == 0x100))
{
env_step = 0.0;
}
@@ -295,7 +296,7 @@ void rf5c400_device::sound_stream_update(sound_stream &stream, stream_sample_t *
*buf1++ += sample * pan_table[rvol];
pos += channel->step;
- if ( (pos>>16) > m_rom.length() || (pos>>16) > end)
+ if ((pos>>16) > end)
{
pos -= loop<<16;
pos &= 0xFFFFFF0000U;
@@ -310,31 +311,57 @@ void rf5c400_device::sound_stream_update(sound_stream &stream, stream_sample_t *
}
}
+void rf5c400_device::rom_bank_updated()
+{
+ m_stream->update();
+}
/*****************************************************************************/
-static uint16_t rf5c400_status = 0; // a static one of these for all instances of the chip? how does that work?
READ16_MEMBER( rf5c400_device::rf5c400_r )
{
- switch(offset)
+ if (offset < 0x400)
{
- case 0x00:
+ //osd_printf_debug("%s:rf5c400_r: %08X, %08X\n", machine().describe_context().c_str(), offset, mem_mask);
+
+ switch(offset)
{
- return rf5c400_status;
+ case 0x00:
+ {
+ return m_rf5c400_status;
+ }
+
+ case 0x04: // unknown read
+ {
+ return 0;
+ }
+
+ case 0x13: // memory read
+ {
+ return read_word(m_ext_mem_address<<1);
+ }
+
+ default:
+ {
+ //osd_printf_debug("%s:rf5c400_r: %08X, %08X\n", machine().describe_context().c_str(), offset, mem_mask);
+ return 0;
+ }
}
+ }
+ else
+ {
+ //int ch = (offset >> 5) & 0x1f;
+ int reg = (offset & 0x1f);
- case 0x04:
+ switch (reg)
{
+ case 0x0F: // unknown read
return 0;
- }
- case 0x13: // memory read
- {
- return m_rom[m_ext_mem_address];
+ default:
+ return 0;
}
}
-
- return 0;
}
WRITE16_MEMBER( rf5c400_device::rf5c400_w )
@@ -345,7 +372,7 @@ WRITE16_MEMBER( rf5c400_device::rf5c400_w )
{
case 0x00:
{
- rf5c400_status = data;
+ m_rf5c400_status = data;
break;
}
@@ -411,7 +438,7 @@ WRITE16_MEMBER( rf5c400_device::rf5c400_w )
{
if ((data & 0x3) == 3)
{
- m_rom[m_ext_mem_address] = m_ext_mem_data;
+ this->space().write_word(m_ext_mem_address << 1, m_ext_mem_data);
}
break;
}
@@ -431,11 +458,11 @@ WRITE16_MEMBER( rf5c400_device::rf5c400_w )
default:
{
- //osd_printf_debug("%s:rf5c400_w: %08X, %08X, %08X\n", machine().describe_context(), data, offset, mem_mask);
+ //osd_printf_debug("%s:rf5c400_w: %08X, %08X, %08X\n", machine().describe_context().c_str(), data, offset, mem_mask);
break;
}
}
- //osd_printf_debug("%s:rf5c400_w: %08X, %08X, %08X at %08X\n", machine().describe_context(), data, offset, mem_mask);
+ //osd_printf_debug("%s:rf5c400_w: %08X, %08X, %08X\n", machine().describe_context().c_str(), data, offset, mem_mask);
}
else
{
@@ -504,12 +531,12 @@ WRITE16_MEMBER( rf5c400_device::rf5c400_w )
}
case 0x0A: // relative to env attack ?
{
- // always 0x0100
+ // always 0x0100/0x140
break;
}
case 0x0B: // relative to env decay ?
{
- // always 0x0100
+ // always 0x0100/0x140/0x180
break;
}
case 0x0C: // env decay
@@ -521,7 +548,7 @@ WRITE16_MEMBER( rf5c400_device::rf5c400_w )
}
case 0x0D: // relative to env release ?
{
- // always 0x0100
+ // always 0x0100/0x140
break;
}
case 0x0E: // env release
@@ -530,6 +557,11 @@ WRITE16_MEMBER( rf5c400_device::rf5c400_w )
channel->release = data;
break;
}
+ case 0x0F: // unknown write
+ {
+ // always 0x0000
+ break;
+ }
case 0x10: // resonance, cutoff freq.
{
// bit 15-12: resonance