summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/sound/aica.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/sound/aica.cpp')
-rw-r--r--src/devices/sound/aica.cpp88
1 files changed, 53 insertions, 35 deletions
diff --git a/src/devices/sound/aica.cpp b/src/devices/sound/aica.cpp
index ad7d5467c3d..3c66130fb77 100644
--- a/src/devices/sound/aica.cpp
+++ b/src/devices/sound/aica.cpp
@@ -72,10 +72,10 @@
#define IMXL(slot) ((slot->udata.data[0x20/2]>>0x4)&0x000F)
#define DISDL(slot) ((slot->udata.data[0x24/2]>>0x8)&0x000F)
-#define DIPAN(slot) ((slot->udata.data[0x24/2]>>0x0)&0x001F)
+#define DIPAN(slot) (MONO() ? 0 : ((slot->udata.data[0x24/2]>>0x0)&0x001F))
#define EFSDL(slot) ((m_EFSPAN[slot*4]>>8)&0x000f)
-#define EFPAN(slot) ((m_EFSPAN[slot*4]>>0)&0x001f)
+#define EFPAN(slot) (MONO() ? 0 : ((m_EFSPAN[slot*4]>>0)&0x001f))
//Unimplemented
#define Q(slot) ((slot->udata.data[0x28/2]>>0x0)&0x001F) // (0.75 × register value - 3)
@@ -99,6 +99,7 @@ static constexpr double DRTimes[64]={100000/*infinity*/,100000/*infinity*/,11820
920.0,790.0,690.0,550.0,460.0,390.0,340.0,270.0,230.0,200.0,170.0,140.0,110.0,98.0,85.0,68.0,57.0,49.0,43.0,34.0,
28.0,25.0,22.0,18.0,14.0,12.0,11.0,8.5,7.1,6.1,5.4,4.3,3.6,3.1};
+#define MONO(aica) ((m_udata.data[0]>>0x0)&0x8000)
#define MEM8MB(aica) ((m_udata.data[0]>>0x0)&0x0200)
#define DAC18B(aica) ((m_udata.data[0]>>0x0)&0x0100)
#define MVOL(aica) ((m_udata.data[0]>>0x0)&0x000F)
@@ -505,24 +506,7 @@ void aica_device::Init()
m_ARTABLE[0]=m_DRTABLE[0]=0; //Infinite time
m_ARTABLE[1]=m_DRTABLE[1]=0; //Infinite time
- for(i=2;i<64;++i)
- {
- double t,step,scale;
- t=ARTimes[i]; //In ms
- if(t!=0.0)
- {
- step=(1023*1000.0)/(44100.0*t);
- scale=(double) (1<<EG_SHIFT);
- m_ARTABLE[i]=(int) (step*scale);
- }
- else
- m_ARTABLE[i]=1024<<EG_SHIFT;
-
- t=DRTimes[i]; //In ms
- step=(1023*1000.0)/(44100.0*t);
- scale=(double) (1<<EG_SHIFT);
- m_DRTABLE[i]=(int) (step*scale);
- }
+ ClockChange();
// make sure all the slots are off
for(i=0;i<64;++i)
@@ -535,8 +519,6 @@ void aica_device::Init()
}
AICALFO_Init();
- m_buffertmpl=make_unique_clear<int32_t[]>(44100);
- m_buffertmpr=make_unique_clear<int32_t[]>(44100);
// no "pend"
m_udata.data[0xa0/2] = 0;
@@ -546,6 +528,32 @@ void aica_device::Init()
m_TimCnt[2] = 0xffff;
}
+void aica_device::ClockChange()
+{
+ m_rate = ((double)clock()) / 512.0;
+ for(int i=2;i<64;++i)
+ {
+ double t,step,scale;
+ t=ARTimes[i]; //In ms
+ if(t!=0.0)
+ {
+ step=(1023*1000.0)/(m_rate*t);
+ scale=(double) (1<<EG_SHIFT);
+ m_ARTABLE[i]=(int) (step*scale);
+ }
+ else
+ m_ARTABLE[i]=1024<<EG_SHIFT;
+
+ t=DRTimes[i]; //In ms
+ step=(1023*1000.0)/(m_rate*t);
+ scale=(double) (1<<EG_SHIFT);
+ m_DRTABLE[i]=(int) (step*scale);
+ }
+
+ m_buffertmpl.resize((int)m_rate, 0);
+ m_buffertmpr.resize((int)m_rate, 0);
+}
+
void aica_device::UpdateSlotReg(int s,int r)
{
AICA_SLOT *slot=m_Slots+s;
@@ -675,10 +683,10 @@ void aica_device::UpdateReg(address_space &space, int reg)
if ((m_udata.data[0x90/2]&0xff) != 255)
{
- time = (44100 / m_TimPris[0]) / (255-(m_udata.data[0x90/2]&0xff));
+ time = (clock() / m_TimPris[0]) / (255-(m_udata.data[0x90/2]&0xff));
if (time)
{
- m_timerA->adjust(attotime::from_hz(time));
+ m_timerA->adjust(attotime::from_ticks(512, time));
}
}
}
@@ -694,10 +702,10 @@ void aica_device::UpdateReg(address_space &space, int reg)
if ((m_udata.data[0x94/2]&0xff) != 255)
{
- time = (44100 / m_TimPris[1]) / (255-(m_udata.data[0x94/2]&0xff));
+ time = (clock() / m_TimPris[1]) / (255-(m_udata.data[0x94/2]&0xff));
if (time)
{
- m_timerB->adjust(attotime::from_hz(time));
+ m_timerB->adjust(attotime::from_ticks(512, time));
}
}
}
@@ -713,10 +721,10 @@ void aica_device::UpdateReg(address_space &space, int reg)
if ((m_udata.data[0x98/2]&0xff) != 255)
{
- time = (44100 / m_TimPris[2]) / (255-(m_udata.data[0x98/2]&0xff));
+ time = (clock() / m_TimPris[2]) / (255-(m_udata.data[0x98/2]&0xff));
if (time)
{
- m_timerC->adjust(attotime::from_hz(time));
+ m_timerC->adjust(attotime::from_ticks(512, time));
}
}
}
@@ -1305,8 +1313,8 @@ void aica_device::DoMasterSamples(int nsamples)
}
}
- *bufl++ = ICLIP16(smpl>>3);
- *bufr++ = ICLIP16(smpr>>3);
+ *bufl++ = (ICLIP16(smpl>>3)*m_LPANTABLE[MVOL()<<0xd])>>SHIFT;
+ *bufr++ = (ICLIP16(smpr>>3)*m_LPANTABLE[MVOL()<<0xd])>>SHIFT;
}
}
@@ -1425,7 +1433,7 @@ void aica_device::device_start()
m_irq_cb.resolve_safe();
m_main_irq_cb.resolve_safe();
- m_stream = machine().sound().stream_alloc(*this, 0, 2, 44100);
+ m_stream = machine().sound().stream_alloc(*this, 0, 2, (int)m_rate);
// save state
save_item(NAME(m_IrqTimA));
@@ -1442,6 +1450,17 @@ void aica_device::device_start()
save_item(NAME(m_TimCnt),3);
}
+//-------------------------------------------------
+// device_clock_changed - called if the clock
+// changes
+//-------------------------------------------------
+
+void aica_device::device_clock_changed()
+{
+ ClockChange();
+ m_stream->set_sample_rate((int)m_rate);
+}
+
void aica_device::set_ram_base(void *base, int size)
{
m_AICARAM = (unsigned char *)base;
@@ -1481,12 +1500,13 @@ READ16_MEMBER( aica_device::midi_out_r )
return val;
}
-DEFINE_DEVICE_TYPE(AICA, aica_device, "aica", "AICA")
+DEFINE_DEVICE_TYPE(AICA, aica_device, "aica", "Yamaha AICA")
aica_device::aica_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, AICA, tag, owner, clock),
device_sound_interface(mconfig, *this),
m_master(false),
+ m_rate(44100.0),
m_roffset(0),
m_irq_cb(*this),
m_main_irq_cb(*this),
@@ -1498,8 +1518,6 @@ aica_device::aica_device(const machine_config &mconfig, const char *tag, device_
m_AICARAM_LENGTH(0),
m_RAM_MASK(0),
m_RAM_MASK16(0),
- m_buffertmpl(nullptr),
- m_buffertmpr(nullptr),
m_IrqTimA(0),
m_IrqTimBC(0),
m_IrqMidi(0),
@@ -1651,7 +1669,7 @@ signed int aica_device::AICAALFO_Step(AICA_LFO_t *LFO)
void aica_device::AICALFO_ComputeStep(AICA_LFO_t *LFO,uint32_t LFOF,uint32_t LFOWS,uint32_t LFOS,int ALFO)
{
- float step=(float) LFOFreq[LFOF]*256.0f/(float)44100.0f;
+ float step=(float) LFOFreq[LFOF]*256.0f/(float)m_rate;
LFO->phase_step=(unsigned int) ((float) (1<<LFO_SHIFT)*step);
if(ALFO)
{