summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/sound/rf5c400.cpp
diff options
context:
space:
mode:
author Firehawke <Firehawke@users.noreply.github.com>2017-12-13 21:01:10 -0700
committer Firehawke <Firehawke@users.noreply.github.com>2017-12-13 21:01:10 -0700
commit54155441e9ba9941e85d80c4834a66376a11e791 (patch)
treeaa44bdaf0035cbe188d64c447f225f10f7d76d8d /src/devices/sound/rf5c400.cpp
parentf537428e5a40ba6dde8ca9bf0fe9ae6b1f189ac4 (diff)
Revert "Merge branch 'master' of https://github.com/mamedev/mame"
This reverts commit f537428e5a40ba6dde8ca9bf0fe9ae6b1f189ac4, reversing changes made to 0d70d798107d4e4e8fb9f230410aeb1e888d65c5.
Diffstat (limited to 'src/devices/sound/rf5c400.cpp')
-rw-r--r--src/devices/sound/rf5c400.cpp82
1 files changed, 25 insertions, 57 deletions
diff --git a/src/devices/sound/rf5c400.cpp b/src/devices/sound/rf5c400.cpp
index 6c047935399..39440c66991 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)
- , device_rom_interface(mconfig, *this, 25, ENDIANNESS_LITTLE, 16)
+ , m_rom(*this, DEVICE_SELF)
, m_stream(nullptr)
, m_env_tables()
{
@@ -155,10 +155,6 @@ 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);
@@ -184,6 +180,8 @@ void rf5c400_device::device_start()
}
m_stream = stream_alloc(0, 2, clock() / 384);
+
+ m_rommask = m_rom.length() - 1;
}
//-------------------------------------------------
@@ -193,6 +191,7 @@ 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;
@@ -229,7 +228,7 @@ void rf5c400_device::sound_stream_update(sound_stream &stream, stream_sample_t *
if (env_phase == PHASE_NONE) break;
- tmp = read_word((pos>>16)<<1);
+ tmp = rom[(pos>>16) & m_rommask];
switch ( type )
{
case TYPE_16:
@@ -259,7 +258,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) || (channel->decay == 0x100))
+ if (channel->decay & 0x0080)
{
env_step = 0.0;
}
@@ -296,7 +295,7 @@ void rf5c400_device::sound_stream_update(sound_stream &stream, stream_sample_t *
*buf1++ += sample * pan_table[rvol];
pos += channel->step;
- if ((pos>>16) > end)
+ if ( (pos>>16) > m_rom.length() || (pos>>16) > end)
{
pos -= loop<<16;
pos &= 0xFFFFFF0000U;
@@ -311,57 +310,31 @@ 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 )
{
- if (offset < 0x400)
+ switch(offset)
{
- //osd_printf_debug("%s:rf5c400_r: %08X, %08X\n", machine().describe_context().c_str(), offset, mem_mask);
-
- switch(offset)
+ case 0x00:
{
- 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;
- }
+ return rf5c400_status;
}
- }
- else
- {
- //int ch = (offset >> 5) & 0x1f;
- int reg = (offset & 0x1f);
- switch (reg)
+ case 0x04:
{
- case 0x0F: // unknown read
return 0;
+ }
- default:
- return 0;
+ case 0x13: // memory read
+ {
+ return m_rom[m_ext_mem_address];
}
}
+
+ return 0;
}
WRITE16_MEMBER( rf5c400_device::rf5c400_w )
@@ -372,7 +345,7 @@ WRITE16_MEMBER( rf5c400_device::rf5c400_w )
{
case 0x00:
{
- m_rf5c400_status = data;
+ rf5c400_status = data;
break;
}
@@ -438,7 +411,7 @@ WRITE16_MEMBER( rf5c400_device::rf5c400_w )
{
if ((data & 0x3) == 3)
{
- this->space().write_word(m_ext_mem_address << 1, m_ext_mem_data);
+ m_rom[m_ext_mem_address] = m_ext_mem_data;
}
break;
}
@@ -458,11 +431,11 @@ WRITE16_MEMBER( rf5c400_device::rf5c400_w )
default:
{
- //osd_printf_debug("%s:rf5c400_w: %08X, %08X, %08X\n", machine().describe_context().c_str(), data, offset, mem_mask);
+ //osd_printf_debug("%s:rf5c400_w: %08X, %08X, %08X\n", machine().describe_context(), data, offset, mem_mask);
break;
}
}
- //osd_printf_debug("%s:rf5c400_w: %08X, %08X, %08X\n", machine().describe_context().c_str(), data, offset, mem_mask);
+ //osd_printf_debug("%s:rf5c400_w: %08X, %08X, %08X at %08X\n", machine().describe_context(), data, offset, mem_mask);
}
else
{
@@ -531,12 +504,12 @@ WRITE16_MEMBER( rf5c400_device::rf5c400_w )
}
case 0x0A: // relative to env attack ?
{
- // always 0x0100/0x140
+ // always 0x0100
break;
}
case 0x0B: // relative to env decay ?
{
- // always 0x0100/0x140/0x180
+ // always 0x0100
break;
}
case 0x0C: // env decay
@@ -548,7 +521,7 @@ WRITE16_MEMBER( rf5c400_device::rf5c400_w )
}
case 0x0D: // relative to env release ?
{
- // always 0x0100/0x140
+ // always 0x0100
break;
}
case 0x0E: // env release
@@ -557,11 +530,6 @@ 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