mirror of
https://github.com/holub/mame
synced 2025-06-06 04:43:45 +03:00
ics2115.cpp Updates (#3497)
* ics2115.cpp : Implement variable sample rate related actived voice/input clock(Datasheet says default clock is 33.8688MHz), Implement/Fix Interpolate of u-Law/8bit sample, Add device_rom_interface, Add IO Handler when 16 bit accessing, Add notes, Add imperfect_features() because Envelope/IRQ/Interpolation isn't perfectly emulated igs_fear.cpp : Add notes igs011.cpp : Move 16 bit ICS2115 Handler into ics2115.cpp pgm.cpp : Move CPU_VBLANK_INT_DRIVER into screen VBLANK callback * ics2115.cpp : Add notes of unimplemented registers * ics2115.cpp : Fix logerror
This commit is contained in:
parent
c1a437ba3f
commit
6d87b49e6b
@ -7,6 +7,15 @@
|
||||
//
|
||||
//Use tab size = 4 for your viewing pleasure.
|
||||
|
||||
/*
|
||||
TODO:
|
||||
Wavetable RAM support
|
||||
Verify 16 bit ROM accessing
|
||||
Timer is maybe input clock related
|
||||
MPU-401/6850 emulation registers
|
||||
DMA
|
||||
*/
|
||||
|
||||
#include "emu.h"
|
||||
#include "ics2115.h"
|
||||
#include <cmath>
|
||||
@ -18,10 +27,19 @@
|
||||
DEFINE_DEVICE_TYPE(ICS2115, ics2115_device, "ics2115", "ICS2115")
|
||||
|
||||
ics2115_device::ics2115_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
|
||||
: device_t(mconfig, ICS2115, tag, owner, clock),
|
||||
device_sound_interface(mconfig, *this), m_stream(nullptr),
|
||||
m_rom(*this, DEVICE_SELF),
|
||||
m_irq_cb(*this), m_active_osc(0), m_osc_select(0), m_reg_select(0), m_irq_enabled(0), m_irq_pending(0), m_irq_on(false), m_vmode(0)
|
||||
: device_t(mconfig, ICS2115, tag, owner, clock)
|
||||
, device_sound_interface(mconfig, *this)
|
||||
, device_rom_interface(mconfig, *this, 25) // 32MB(16MB with ROMEN pin for 16 bit ROM pair)
|
||||
, m_stream(nullptr)
|
||||
, m_irq_cb(*this)
|
||||
, m_sample_rate(0)
|
||||
, m_active_osc(0)
|
||||
, m_osc_select(0)
|
||||
, m_reg_select(0)
|
||||
, m_irq_enabled(0)
|
||||
, m_irq_pending(0)
|
||||
, m_irq_on(false)
|
||||
, m_vmode(0)
|
||||
{
|
||||
}
|
||||
|
||||
@ -29,7 +47,7 @@ void ics2115_device::device_start()
|
||||
{
|
||||
m_timer[0].timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(ics2115_device::timer_cb_0),this), this);
|
||||
m_timer[1].timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(ics2115_device::timer_cb_1),this), this);
|
||||
m_stream = machine().sound().stream_alloc(*this, 0, 2, 33075);
|
||||
m_stream = machine().sound().stream_alloc(*this, 0, 2, clock() / (16*32));
|
||||
|
||||
m_irq_cb.resolve_safe();
|
||||
|
||||
@ -103,6 +121,7 @@ void ics2115_device::device_reset()
|
||||
m_irq_pending = 0;
|
||||
//possible re-suss
|
||||
m_active_osc = 31;
|
||||
recalc_rate();
|
||||
m_osc_select = 0;
|
||||
m_reg_select = 0;
|
||||
m_vmode = 0;
|
||||
@ -134,6 +153,19 @@ void ics2115_device::device_reset()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ics2115_device::device_post_load()
|
||||
{
|
||||
recalc_rate();
|
||||
}
|
||||
|
||||
|
||||
void ics2115_device::device_clock_changed()
|
||||
{
|
||||
recalc_rate();
|
||||
}
|
||||
|
||||
|
||||
//TODO: improve using next-state logic from column 126 of patent 5809466
|
||||
int ics2115_device::ics2115_voice::update_volume_envelope()
|
||||
{
|
||||
@ -218,7 +250,7 @@ int ics2115_device::ics2115_voice::update_oscillator()
|
||||
if(osc_conf.bitflags.loop_bidir)
|
||||
osc_conf.bitflags.invert = !osc_conf.bitflags.invert;
|
||||
//else
|
||||
// printf("click!\n");
|
||||
// logerror("click!\n");
|
||||
|
||||
if(osc_conf.bitflags.invert) {
|
||||
osc.acc = osc.end + osc.left;
|
||||
@ -247,22 +279,26 @@ stream_sample_t ics2115_device::get_sample(ics2115_voice& voice)
|
||||
|
||||
if (voice.state.bitflags.on && voice.osc_conf.bitflags.loop && !voice.osc_conf.bitflags.loop_bidir &&
|
||||
(voice.osc.left < (voice.osc.fc <<2))) {
|
||||
//printf("C?[%x:%x]", voice.osc.left, voice.osc.acc);
|
||||
//logerror("C?[%x:%x]", voice.osc.left, voice.osc.acc);
|
||||
nextaddr = ((voice.osc.saddr << 20) & 0xffffff) | (voice.osc.start >> 12);
|
||||
}
|
||||
else
|
||||
nextaddr = curaddr + 2;
|
||||
nextaddr = curaddr + ((voice.osc_conf.bitflags.eightbit || voice.osc_conf.bitflags.ulaw) ? 1 : 2);
|
||||
|
||||
|
||||
int16_t sample1, sample2;
|
||||
if (voice.osc_conf.bitflags.eightbit) {
|
||||
sample1 = ((int8_t)m_rom[curaddr]) << 8;
|
||||
sample2 = ((int8_t)m_rom[curaddr + 1]) << 8;
|
||||
if(voice.osc_conf.bitflags.ulaw) {
|
||||
sample1 = m_ulaw[read_byte(curaddr)];
|
||||
sample2 = m_ulaw[read_byte(nextaddr)];
|
||||
}
|
||||
else if (voice.osc_conf.bitflags.eightbit) {
|
||||
sample1 = ((int8_t)read_byte(curaddr)) << 8;
|
||||
sample2 = ((int8_t)read_byte(nextaddr)) << 8;
|
||||
}
|
||||
else {
|
||||
sample1 = m_rom[curaddr + 0] | (((int8_t)m_rom[curaddr + 1]) << 8);
|
||||
sample2 = m_rom[nextaddr+ 0] | (((int8_t)m_rom[nextaddr+ 1]) << 8);
|
||||
//sample2 = m_rom[curaddr + 2] | (((int8_t)m_rom[curaddr + 3]) << 8);
|
||||
sample1 = read_byte(curaddr + 0) | (((int8_t)read_byte(curaddr + 1)) << 8);
|
||||
sample2 = read_byte(nextaddr+ 0) | (((int8_t)read_byte(nextaddr+ 1)) << 8);
|
||||
//sample2 = read_byte(curaddr + 2) | (((int8_t)read_byte(curaddr + 3)) << 8);
|
||||
}
|
||||
|
||||
//no need for interpolation since it's around 1 note a cycle?
|
||||
@ -319,12 +355,7 @@ int ics2115_device::fill_output(ics2115_voice& voice, stream_sample_t *outputs[2
|
||||
//that the voice is pointing at is contributing to the summation.
|
||||
//(austere note: this will of course fix some of the glitches due to multiple transition)
|
||||
stream_sample_t sample;
|
||||
if(voice.osc_conf.bitflags.ulaw) {
|
||||
uint32_t curaddr = ((voice.osc.saddr << 20) & 0xffffff) | (voice.osc.acc >> 12);
|
||||
sample = m_ulaw[m_rom[curaddr]];
|
||||
}
|
||||
else
|
||||
sample = get_sample(voice);
|
||||
sample = get_sample(voice);
|
||||
|
||||
//15-bit volume + (5-bit worth of 32 channel sum) + 16-bit samples = 4-bit extra
|
||||
if (!m_vmode || voice.playing()) {
|
||||
@ -361,11 +392,8 @@ void ics2115_device::sound_stream_update(sound_stream &stream, stream_sample_t *
|
||||
#ifdef ICS2115_DEBUG
|
||||
uint32_t curaddr = ((voice.osc.saddr << 20) & 0xffffff) | (voice.osc.acc >> 12);
|
||||
stream_sample_t sample;
|
||||
if(voice.osc_conf.bitflags.ulaw)
|
||||
sample = m_ulaw[m_rom[curaddr]];
|
||||
else
|
||||
sample = get_sample(voice);
|
||||
printf("[%06x=%04x]", curaddr, (int16_t)sample);
|
||||
sample = get_sample(voice);
|
||||
logerror("[%06x=%04x]", curaddr, (int16_t)sample);
|
||||
#endif
|
||||
*/
|
||||
if(fill_output(voice, outputs, samples))
|
||||
@ -373,12 +401,12 @@ void ics2115_device::sound_stream_update(sound_stream &stream, stream_sample_t *
|
||||
|
||||
#ifdef ICS2115_DEBUG
|
||||
if(voice.playing()) {
|
||||
printf("%d", osc);
|
||||
logerror("%d", osc);
|
||||
if (voice.osc_conf.bitflags.invert)
|
||||
printf("+");
|
||||
logerror("+");
|
||||
else if ((voice.osc.fc >> 1) > 0x1ff)
|
||||
printf("*");
|
||||
printf(" ");
|
||||
logerror("*");
|
||||
logerror(" ");
|
||||
|
||||
/*int min = 0x7fffffff, max = 0x80000000;
|
||||
double average = 0;
|
||||
@ -389,13 +417,13 @@ void ics2115_device::sound_stream_update(sound_stream &stream, stream_sample_t *
|
||||
}
|
||||
average /= samples;
|
||||
average /= 1 << 16;
|
||||
printf("<Mi:%d Mx:%d Av:%g>", min >> 16, max >> 16, average);*/
|
||||
logerror("<Mi:%d Mx:%d Av:%g>", min >> 16, max >> 16, average);*/
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef ICS2115_DEBUG
|
||||
printf("|");
|
||||
logerror("|\n");
|
||||
#endif
|
||||
|
||||
//rescale
|
||||
@ -421,7 +449,7 @@ uint16_t ics2115_device::reg_read() {
|
||||
break;
|
||||
|
||||
case 0x01: // [osc] Wavesample frequency
|
||||
// freq = fc*33075/1024 in 32 voices mode, fc*44100/1024 in 24 voices mode
|
||||
// freq = fc*33075/1024 in 32 voices mode, fc*44100/1024 in 24 voices mode (if input clock is 33.8688MHz)
|
||||
//ret = v->Osc.FC;
|
||||
ret = voice.osc.fc;
|
||||
break;
|
||||
@ -541,6 +569,10 @@ uint16_t ics2115_device::reg_read() {
|
||||
case 0x43: // Timer status
|
||||
ret = m_irq_pending & 3;
|
||||
break;
|
||||
|
||||
//case 0x47: break;// DMA Status
|
||||
//case 0x48: break;// Accumulator Monitor Status
|
||||
//case 0x49: break;// Accumulator Monitor Data
|
||||
|
||||
case 0x4A: // IRQ Pending
|
||||
ret = m_irq_pending;
|
||||
@ -553,10 +585,22 @@ uint16_t ics2115_device::reg_read() {
|
||||
case 0x4C: // Chip Revision
|
||||
ret = revision;
|
||||
break;
|
||||
|
||||
//case 0x4D: break;// System Control
|
||||
//case 0x4F: break;// Oscillator Address being Programmed
|
||||
|
||||
//case 0x50: break;// MIDI Data Register
|
||||
//case 0x51: break;// MIDI Control/Status Register
|
||||
//case 0x52: break;// Host Data Register
|
||||
//case 0x53: break;// Host Control/Status Register
|
||||
//case 0x54: break;// MIDI Emulation interrupt Control
|
||||
//case 0x55: break;// Host Emulation interrupt Control
|
||||
//case 0x56: break;// Host/MIDI Emulation Interrupt
|
||||
//case 0x57: break;// Emulation Mode
|
||||
|
||||
default:
|
||||
#ifdef ICS2115_DEBUG
|
||||
printf("ICS2115: Unhandled read %x\n", m_reg_select);
|
||||
logerror("ICS2115: Unhandled read %x\n", m_reg_select);
|
||||
#endif
|
||||
ret = 0;
|
||||
break;
|
||||
@ -576,7 +620,7 @@ void ics2115_device::reg_write(uint8_t data, bool msb) {
|
||||
break;
|
||||
|
||||
case 0x01: // [osc] Wavesample frequency
|
||||
// freq = fc*33075/1024 in 32 voices mode, fc*44100/1024 in 24 voices mode
|
||||
// freq = fc*33075/1024 in 32 voices mode, fc*44100/1024 in 24 voices mode (if input clock is 33.8688MHz)
|
||||
if(msb)
|
||||
voice.osc.fc = (voice.osc.fc & 0x00ff) | (data << 8);
|
||||
else
|
||||
@ -584,14 +628,14 @@ void ics2115_device::reg_write(uint8_t data, bool msb) {
|
||||
voice.osc.fc = (voice.osc.fc & 0xff00) | (data & 0xfe);
|
||||
break;
|
||||
|
||||
case 0x02: // [osc] Wavesample loop start high
|
||||
case 0x02: // [osc] Wavesample loop start high (16 Integer)
|
||||
if(msb)
|
||||
voice.osc.start = (voice.osc.start & 0x00ffffff) | (data << 24);
|
||||
else
|
||||
voice.osc.start = (voice.osc.start & 0xff00ffff) | (data << 16);
|
||||
break;
|
||||
|
||||
case 0x03: // [osc] Wavesample loop start low
|
||||
case 0x03: // [osc] Wavesample loop start low (4 Integer, 4 Fraction)
|
||||
if(msb)
|
||||
voice.osc.start = (voice.osc.start & 0xffff00ff) | (data << 8);
|
||||
// This is unused?
|
||||
@ -599,14 +643,14 @@ void ics2115_device::reg_write(uint8_t data, bool msb) {
|
||||
//voice.osc.start = (voice.osc.start & 0xffffff00) | (data & 0);
|
||||
break;
|
||||
|
||||
case 0x04: // [osc] Wavesample loop end high
|
||||
case 0x04: // [osc] Wavesample loop end high (16 Integer)
|
||||
if(msb)
|
||||
voice.osc.end = (voice.osc.end & 0x00ffffff) | (data << 24);
|
||||
else
|
||||
voice.osc.end = (voice.osc.end & 0xff00ffff) | (data << 16);
|
||||
break;
|
||||
|
||||
case 0x05: // [osc] Wavesample loop end low
|
||||
case 0x05: // [osc] Wavesample loop end low (4 Integer, 4 Fraction)
|
||||
if(msb)
|
||||
voice.osc.end = (voice.osc.end & 0xffff00ff) | (data << 8);
|
||||
// lsb is unused?
|
||||
@ -635,12 +679,12 @@ void ics2115_device::reg_write(uint8_t data, bool msb) {
|
||||
voice.vol.acc = voice.vol.regacc << 10;
|
||||
break;
|
||||
|
||||
case 0x0A: // [osc] Wavesample address high
|
||||
case 0x0A: // [osc] Wavesample address high (16 Integer)
|
||||
#ifdef ICS2115_DEBUG
|
||||
#ifdef ICS2115_ISOLATE
|
||||
if(m_osc_select == ICS2115_ISOLATE)
|
||||
#endif
|
||||
printf("<%d:oa:H[%d]=%x>", m_osc_select, msb, data);
|
||||
logerror("<%d:oa:H[%d]=%x>\n", m_osc_select, msb, data);
|
||||
#endif
|
||||
if(msb)
|
||||
voice.osc.acc = (voice.osc.acc & 0x00ffffff) | (data << 24);
|
||||
@ -648,12 +692,12 @@ void ics2115_device::reg_write(uint8_t data, bool msb) {
|
||||
voice.osc.acc = (voice.osc.acc & 0xff00ffff) | (data << 16);
|
||||
break;
|
||||
|
||||
case 0x0B: // [osc] Wavesample address low
|
||||
case 0x0B: // [osc] Wavesample address low (4 Integer, 9 Fraction)
|
||||
#ifdef ICS2115_DEBUG
|
||||
#ifdef ICS2115_ISOLATE
|
||||
if(m_osc_select == ICS2115_ISOLATE)
|
||||
#endif
|
||||
printf("<%d:oa:L[%d]=%x>", m_osc_select, msb, data);
|
||||
logerror("<%d:oa:L[%d]=%x>\n", m_osc_select, msb, data);
|
||||
#endif
|
||||
if(msb)
|
||||
voice.osc.acc = (voice.osc.acc & 0xffff00ff) | (data << 8);
|
||||
@ -677,6 +721,7 @@ void ics2115_device::reg_write(uint8_t data, bool msb) {
|
||||
//Does this value get added to 1? Not sure. Could trace for writes of 32.
|
||||
if(msb) {
|
||||
m_active_osc = data & 0x1F; // & 0x1F ? (Guessing)
|
||||
recalc_rate();
|
||||
}
|
||||
break;
|
||||
//2X8 ?
|
||||
@ -695,7 +740,7 @@ void ics2115_device::reg_write(uint8_t data, bool msb) {
|
||||
if (m_osc_select == ICS2115_ISOLATE)
|
||||
#endif
|
||||
if (!voice.osc_conf.bitflags.stop || !voice.vol_ctrl.bitflags.stop)
|
||||
printf("[%02d STOP]\n", m_osc_select);
|
||||
logerror("[%02d STOP]\n", m_osc_select);
|
||||
#endif
|
||||
if (!m_vmode) {
|
||||
voice.osc_conf.bitflags.stop = true;
|
||||
@ -706,7 +751,7 @@ void ics2115_device::reg_write(uint8_t data, bool msb) {
|
||||
}
|
||||
#ifdef ICS2115_DEBUG
|
||||
else
|
||||
printf("ICS2115: Unhandled* data write %d onto 0x10.\n", data);
|
||||
logerror("ICS2115: Unhandled* data write %d onto 0x10.\n", data);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
@ -736,6 +781,11 @@ void ics2115_device::reg_write(uint8_t data, bool msb) {
|
||||
recalc_timer(m_reg_select & 0x1);
|
||||
}
|
||||
break;
|
||||
|
||||
//case 0x44: break;// DMA Start Address Low
|
||||
//case 0x45: break;// DMA Start Address Medium
|
||||
//case 0x46: break;// DMA Start Address High
|
||||
//case 0x47: break;// DMA Control
|
||||
|
||||
case 0x4A: // IRQ Enable
|
||||
if(!msb) {
|
||||
@ -743,15 +793,28 @@ void ics2115_device::reg_write(uint8_t data, bool msb) {
|
||||
recalc_irq();
|
||||
}
|
||||
break;
|
||||
|
||||
//case 0x4C: break;// Memory Config
|
||||
//case 0x4D: break;// System Control
|
||||
|
||||
case 0x4F: // Oscillator Address being Programmed
|
||||
if(!msb) {
|
||||
m_osc_select = data % (1+m_active_osc);
|
||||
}
|
||||
break;
|
||||
|
||||
//case 0x50: break;// MIDI Data Register
|
||||
//case 0x51: break;// MIDI Control/Status Register
|
||||
//case 0x52: break;// Host Data Register
|
||||
//case 0x53: break;// Host Control/Status Register
|
||||
//case 0x54: break;// MIDI Emulation interrupt Control
|
||||
//case 0x55: break;// Host Emulation interrupt Control
|
||||
//case 0x56: break;// Host/MIDI Emulation Interrupt
|
||||
//case 0x57: break;// Emulation Mode
|
||||
|
||||
default:
|
||||
#ifdef ICS2115_DEBUG
|
||||
printf("ICS2115: Unhandled write %x onto %x(%d) [voice = %d]\n", data, m_reg_select, msb, m_osc_select);
|
||||
logerror("ICS2115: Unhandled write %x onto %x(%d) [voice = %d]\n", data, m_reg_select, msb, m_osc_select);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
@ -789,7 +852,7 @@ READ8_MEMBER(ics2115_device::read)
|
||||
break;
|
||||
default:
|
||||
#ifdef ICS2115_DEBUG
|
||||
printf("ICS2115: Unhandled memory read at %x\n", offset);
|
||||
logerror("ICS2115: Unhandled memory read at %x\n", offset);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
@ -810,7 +873,53 @@ WRITE8_MEMBER(ics2115_device::write)
|
||||
break;
|
||||
default:
|
||||
#ifdef ICS2115_DEBUG
|
||||
printf("ICS2115: Unhandled memory write %02x to %x\n", data, offset);
|
||||
logerror("ICS2115: Unhandled memory write %02x to %x\n", data, offset);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
READ16_MEMBER(ics2115_device::read16)
|
||||
{
|
||||
uint16_t ret = 0;
|
||||
|
||||
switch(offset) {
|
||||
case 0:
|
||||
case 1:
|
||||
ret = read(space,offset,mem_mask & 0xff);
|
||||
break;
|
||||
case 2:
|
||||
case 3: // TODO : Unknown/Unused at 16 bit accessing?
|
||||
ret = reg_read();
|
||||
break;
|
||||
default:
|
||||
#ifdef ICS2115_DEBUG
|
||||
logerror("ICS2115: Unhandled memory read at %x\n", offset);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
WRITE16_MEMBER(ics2115_device::write16)
|
||||
{
|
||||
switch(offset) {
|
||||
case 1:
|
||||
if (ACCESSING_BITS_0_7)
|
||||
write(space,offset,data & 0xff,mem_mask & 0xff);
|
||||
|
||||
break;
|
||||
case 2:
|
||||
case 3: // TODO : Unknown/Unused at 16 bit accessing?
|
||||
if (ACCESSING_BITS_0_7)
|
||||
reg_write(data & 0xff,0);
|
||||
if (ACCESSING_BITS_8_15)
|
||||
reg_write((data >> 8) & 0xff,1);
|
||||
|
||||
break;
|
||||
default:
|
||||
#ifdef ICS2115_DEBUG
|
||||
logerror("ICS2115: Unhandled memory write %02x to %x\n", data, offset);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
@ -828,7 +937,7 @@ void ics2115_device::keyon()
|
||||
m_voice[m_osc_select].state.bitflags.ramp = 0x40;
|
||||
|
||||
#ifdef ICS2115_DEBUG
|
||||
printf("[%02d vs:%04x ve:%04x va:%04x vi:%02x vc:%02x os:%06x oe:%06x oa:%06x of:%04x SA:%02x oc:%02x][%04x]\n", m_osc_select,
|
||||
logerror("[%02d vs:%04x ve:%04x va:%04x vi:%02x vc:%02x os:%06x oe:%06x oa:%06x of:%04x SA:%02x oc:%02x][%04x]\n", m_osc_select,
|
||||
m_voice[m_osc_select].vol.start >> 10,
|
||||
m_voice[m_osc_select].vol.end >> 10,
|
||||
m_voice[m_osc_select].vol.acc >> 10,
|
||||
@ -844,7 +953,7 @@ void ics2115_device::keyon()
|
||||
);
|
||||
#endif
|
||||
//testing memory corruption issue with mame stream
|
||||
//printf("m_volume[0x%x]=0x%x\n", mastervolume, m_volume[mastervolume]);
|
||||
//logerror("m_volume[0x%x]=0x%x\n", mastervolume, m_volume[mastervolume]);
|
||||
}
|
||||
|
||||
void ics2115_device::recalc_irq()
|
||||
@ -877,7 +986,7 @@ void ics2115_device::recalc_timer(int timer)
|
||||
|
||||
//New formula based on O.Galibert's reverse engineering of ICS2115 card firmware
|
||||
uint64_t period = ((m_timer[timer].scale & 0x1f) + 1) * (m_timer[timer].preset + 1);
|
||||
period = (period << (4 + (m_timer[timer].scale >> 5)))*78125/2646;
|
||||
period = (period << (4 + (m_timer[timer].scale >> 5)))*78125/2646; // TODO : it's maybe related by input clock
|
||||
|
||||
if(m_timer[timer].period != period) {
|
||||
m_timer[timer].period = period;
|
||||
@ -888,3 +997,9 @@ void ics2115_device::recalc_timer(int timer)
|
||||
m_timer[timer].timer->adjust(attotime::never);
|
||||
}
|
||||
}
|
||||
|
||||
void ics2115_device::recalc_rate()
|
||||
{
|
||||
m_sample_rate = clock() / (16 * (m_active_osc + 1));
|
||||
m_stream->set_sample_rate(m_sample_rate);
|
||||
}
|
||||
|
@ -10,9 +10,6 @@
|
||||
// INTERFACE CONFIGURATION MACROS
|
||||
//**************************************************************************
|
||||
|
||||
#define MCFG_ICS2115_ADD(_tag, _clock) \
|
||||
MCFG_DEVICE_ADD(_tag, ICS2115, _clock)
|
||||
|
||||
#define MCFG_ICS2115_IRQ_CB(_devcb) \
|
||||
devcb = &downcast<ics2115_device &>(*device).set_irq_callback(DEVCB_##_devcb);
|
||||
|
||||
@ -22,9 +19,11 @@
|
||||
|
||||
// ======================> ics2115_device
|
||||
|
||||
class ics2115_device : public device_t, public device_sound_interface
|
||||
class ics2115_device : public device_t, public device_sound_interface, public device_rom_interface
|
||||
{
|
||||
public:
|
||||
static constexpr feature_type imperfect_features() { return feature::SOUND; }
|
||||
|
||||
// construction/destruction
|
||||
ics2115_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
|
||||
|
||||
@ -32,6 +31,8 @@ public:
|
||||
|
||||
DECLARE_READ8_MEMBER(read);
|
||||
DECLARE_WRITE8_MEMBER(write);
|
||||
DECLARE_READ16_MEMBER(read16);
|
||||
DECLARE_WRITE16_MEMBER(write16);
|
||||
//uint8_t read(offs_t offset);
|
||||
//void write(offs_t offset, uint8_t data);
|
||||
TIMER_CALLBACK_MEMBER(timer_cb_0);
|
||||
@ -107,6 +108,8 @@ protected:
|
||||
// device-level overrides
|
||||
virtual void device_start() override;
|
||||
virtual void device_reset() override;
|
||||
virtual void device_post_load() override;
|
||||
virtual void device_clock_changed() override;
|
||||
|
||||
// internal callbacks
|
||||
virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) override;
|
||||
@ -117,6 +120,7 @@ protected:
|
||||
void recalc_timer(int timer);
|
||||
void keyon();
|
||||
void recalc_irq();
|
||||
void recalc_rate();
|
||||
|
||||
//stream helper functions
|
||||
int fill_output(ics2115_voice& voice, stream_sample_t *outputs[2], int samples);
|
||||
@ -125,9 +129,9 @@ protected:
|
||||
sound_stream *m_stream;
|
||||
|
||||
// internal state
|
||||
required_region_ptr<uint8_t> m_rom;
|
||||
devcb_write_line m_irq_cb;
|
||||
|
||||
uint32_t m_sample_rate;
|
||||
int16_t m_ulaw[256];
|
||||
uint16_t m_volume[4096];
|
||||
static const int volume_bits = 15;
|
||||
|
@ -208,8 +208,6 @@ public:
|
||||
uint16_t igs_dips_r(int NUM);
|
||||
DECLARE_CUSTOM_INPUT_MEMBER(igs_hopper_r);
|
||||
DECLARE_WRITE16_MEMBER(lhb_okibank_w);
|
||||
DECLARE_READ16_MEMBER(ics2115_word_r);
|
||||
DECLARE_WRITE16_MEMBER(ics2115_word_w);
|
||||
DECLARE_WRITE_LINE_MEMBER(sound_irq);
|
||||
DECLARE_DRIVER_INIT(lhbv33c);
|
||||
DECLARE_DRIVER_INIT(drgnwrldv21j);
|
||||
@ -2850,37 +2848,6 @@ void igs011_state::nkishusp(address_map &map)
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* trap15's note:
|
||||
* TODO: change this horrible device-> chain to be proper.
|
||||
*/
|
||||
READ16_MEMBER(igs011_state::ics2115_word_r)
|
||||
{
|
||||
ics2115_device* ics2115 = machine().device<ics2115_device>("ics");
|
||||
switch(offset)
|
||||
{
|
||||
case 0: return ics2115->read(space, (offs_t)0);
|
||||
case 1: return ics2115->read(space, (offs_t)1);
|
||||
case 2: return (ics2115->read(space, (offs_t)3) << 8) | ics2115->read(space, (offs_t)2);
|
||||
}
|
||||
return 0xff;
|
||||
}
|
||||
|
||||
WRITE16_MEMBER(igs011_state::ics2115_word_w)
|
||||
{
|
||||
ics2115_device* ics2115 = machine().device<ics2115_device>("ics");
|
||||
switch(offset)
|
||||
{
|
||||
case 1:
|
||||
if (ACCESSING_BITS_0_7) ics2115->write(space, 1,data);
|
||||
break;
|
||||
case 2:
|
||||
if (ACCESSING_BITS_0_7) ics2115->write(space, 2,data);
|
||||
if (ACCESSING_BITS_8_15) ics2115->write(space, 3,data>>8);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
READ16_MEMBER(igs011_state::vbowl_unk_r)
|
||||
{
|
||||
return 0xffff;
|
||||
@ -2948,7 +2915,7 @@ void igs011_state::vbowl(address_map &map)
|
||||
map(0x300000, 0x3fffff).rw(this, FUNC(igs011_state::igs011_layers_r), FUNC(igs011_state::igs011_layers_w));
|
||||
map(0x400000, 0x401fff).ram().w(this, FUNC(igs011_state::igs011_palette)).share("paletteram");
|
||||
map(0x520000, 0x520001).portr("COIN");
|
||||
map(0x600000, 0x600007).rw(this, FUNC(igs011_state::ics2115_word_r), FUNC(igs011_state::ics2115_word_w));
|
||||
map(0x600000, 0x600007).rw("ics", FUNC(ics2115_device::read16), FUNC(ics2115_device::write16));
|
||||
map(0x700000, 0x700003).ram().share("vbowl_trackball");
|
||||
map(0x700004, 0x700005).w(this, FUNC(igs011_state::vbowl_pen_hi_w));
|
||||
map(0x800000, 0x800003).w(this, FUNC(igs011_state::vbowl_igs003_w));
|
||||
@ -4324,7 +4291,8 @@ MACHINE_CONFIG_START(igs011_state::vbowl)
|
||||
// MCFG_GFXDECODE_ADD("gfxdecode", "palette", igs011_hi)
|
||||
|
||||
MCFG_DEVICE_REMOVE("oki")
|
||||
MCFG_ICS2115_ADD("ics", 0)
|
||||
|
||||
MCFG_DEVICE_ADD("ics", ICS2115, 33.8688_MHz_XTAL) // Unknown clock
|
||||
MCFG_ICS2115_IRQ_CB(WRITELINE(*this, igs011_state, sound_irq))
|
||||
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 5.0)
|
||||
MACHINE_CONFIG_END
|
||||
|
@ -15,11 +15,12 @@ class igs_fear_state : public driver_device
|
||||
{
|
||||
public:
|
||||
igs_fear_state(const machine_config &mconfig, device_type type, const char *tag)
|
||||
: driver_device(mconfig, type, tag),
|
||||
m_maincpu(*this, "maincpu"),
|
||||
m_gfxdecode(*this, "gfxdecode"),
|
||||
m_palette(*this, "palette") { }
|
||||
|
||||
: driver_device(mconfig, type, tag)
|
||||
, m_maincpu(*this, "maincpu")
|
||||
, m_gfxdecode(*this, "gfxdecode")
|
||||
, m_palette(*this, "palette")
|
||||
{
|
||||
}
|
||||
|
||||
DECLARE_WRITE_LINE_MEMBER(sound_irq);
|
||||
DECLARE_DRIVER_INIT(igs_fear);
|
||||
@ -98,10 +99,10 @@ MACHINE_CONFIG_START(igs_fear_state::igs_fear)
|
||||
|
||||
/* sound hardware */
|
||||
MCFG_SPEAKER_STANDARD_MONO("mono")
|
||||
MCFG_ICS2115_ADD("ics", 0)
|
||||
|
||||
MCFG_DEVICE_ADD("ics", ICS2115, 33.8688_MHz_XTAL) // Unknown clock
|
||||
MCFG_ICS2115_IRQ_CB(WRITELINE(*this, igs_fear_state, sound_irq))
|
||||
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 5.0)
|
||||
|
||||
MACHINE_CONFIG_END
|
||||
|
||||
|
||||
|
@ -490,7 +490,7 @@ TIMER_DEVICE_CALLBACK_MEMBER(pgm_state::pgm_interrupt)
|
||||
{
|
||||
int scanline = param;
|
||||
|
||||
// already being generated by MCFG_DEVICE_VBLANK_INT_DRIVER("screen", pgm_state, irq6_line_hold)
|
||||
// already being generated by MCFG_SCREEN_VBLANK_CALLBACK(WRITELINE(pgm_state, screen_vblank_pgm))
|
||||
// if(scanline == 224)
|
||||
// m_maincpu->set_input_line(6, HOLD_LINE);
|
||||
|
||||
@ -510,12 +510,11 @@ MACHINE_RESET_MEMBER(pgm_state,pgm)
|
||||
|
||||
MACHINE_CONFIG_START(pgm_state::pgmbase)
|
||||
/* basic machine hardware */
|
||||
MCFG_DEVICE_ADD("maincpu", M68000, 20000000) /* 20 mhz! verified on real board */
|
||||
MCFG_DEVICE_ADD("maincpu", M68000, 20_MHz_XTAL) /* 20 mhz! verified on real board */
|
||||
MCFG_DEVICE_PROGRAM_MAP(pgm_basic_mem)
|
||||
MCFG_DEVICE_VBLANK_INT_DRIVER("screen", pgm_state, irq6_line_hold)
|
||||
MCFG_TIMER_DRIVER_ADD_SCANLINE("scantimer", pgm_state, pgm_interrupt, "screen", 0, 1)
|
||||
|
||||
MCFG_DEVICE_ADD("soundcpu", Z80, 33868800/4)
|
||||
MCFG_DEVICE_ADD("soundcpu", Z80, 33.8688_MHz_XTAL/4)
|
||||
MCFG_DEVICE_PROGRAM_MAP(pgm_z80_mem)
|
||||
MCFG_DEVICE_IO_MAP(pgm_z80_io)
|
||||
|
||||
@ -548,7 +547,7 @@ MACHINE_CONFIG_START(pgm_state::pgmbase)
|
||||
MCFG_GENERIC_LATCH_8_ADD("soundlatch2")
|
||||
MCFG_GENERIC_LATCH_8_ADD("soundlatch3")
|
||||
|
||||
MCFG_ICS2115_ADD("ics", 0)
|
||||
MCFG_DEVICE_ADD("ics", ICS2115, 33.8688_MHz_XTAL)
|
||||
MCFG_ICS2115_IRQ_CB(INPUTLINE("soundcpu", 0))
|
||||
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 5.0)
|
||||
MACHINE_CONFIG_END
|
||||
|
@ -669,5 +669,6 @@ WRITE_LINE_MEMBER(pgm_state::screen_vblank_pgm)
|
||||
{
|
||||
/* first 0xa00 of main ram = sprites, seems to be buffered, DMA? */
|
||||
memcpy(m_spritebufferram.get(), m_mainram, 0xa00);
|
||||
m_maincpu->set_input_line(6, HOLD_LINE);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user