summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/sound/aica.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/emu/sound/aica.c')
-rw-r--r--src/emu/sound/aica.c212
1 files changed, 105 insertions, 107 deletions
diff --git a/src/emu/sound/aica.c b/src/emu/sound/aica.c
index 78b9bd8e77d..3ef493af208 100644
--- a/src/emu/sound/aica.c
+++ b/src/emu/sound/aica.c
@@ -14,10 +14,10 @@
#define ICLIP16(x) (x<-32768)?-32768:((x>32767)?32767:x)
-#define SHIFT 12
-#define FIX(v) ((UINT32) ((float) (1<<SHIFT)*(v)))
+#define SHIFT 12
+#define FIX(v) ((UINT32) ((float) (1<<SHIFT)*(v)))
-#define EG_SHIFT 16
+#define EG_SHIFT 16
// include the LFO handling code
#include "aicalfo.c"
@@ -28,47 +28,47 @@
*/
//SLOT PARAMETERS
-#define KEYONEX(slot) ((slot->udata.data[0x0]>>0x0)&0x8000)
-#define KEYONB(slot) ((slot->udata.data[0x0]>>0x0)&0x4000)
-#define SSCTL(slot) ((slot->udata.data[0x0]>>0xA)&0x0001)
-#define LPCTL(slot) ((slot->udata.data[0x0]>>0x9)&0x0001)
-#define PCMS(slot) ((slot->udata.data[0x0]>>0x7)&0x0003)
+#define KEYONEX(slot) ((slot->udata.data[0x0]>>0x0)&0x8000)
+#define KEYONB(slot) ((slot->udata.data[0x0]>>0x0)&0x4000)
+#define SSCTL(slot) ((slot->udata.data[0x0]>>0xA)&0x0001)
+#define LPCTL(slot) ((slot->udata.data[0x0]>>0x9)&0x0001)
+#define PCMS(slot) ((slot->udata.data[0x0]>>0x7)&0x0003)
-#define SA(slot) (((slot->udata.data[0x0]&0x7F)<<16)|(slot->udata.data[0x4/2]))
+#define SA(slot) (((slot->udata.data[0x0]&0x7F)<<16)|(slot->udata.data[0x4/2]))
-#define LSA(slot) (slot->udata.data[0x8/2])
+#define LSA(slot) (slot->udata.data[0x8/2])
-#define LEA(slot) (slot->udata.data[0xc/2])
+#define LEA(slot) (slot->udata.data[0xc/2])
-#define D2R(slot) ((slot->udata.data[0x10/2]>>0xB)&0x001F)
-#define D1R(slot) ((slot->udata.data[0x10/2]>>0x6)&0x001F)
-#define AR(slot) ((slot->udata.data[0x10/2]>>0x0)&0x001F)
+#define D2R(slot) ((slot->udata.data[0x10/2]>>0xB)&0x001F)
+#define D1R(slot) ((slot->udata.data[0x10/2]>>0x6)&0x001F)
+#define AR(slot) ((slot->udata.data[0x10/2]>>0x0)&0x001F)
-#define LPSLNK(slot) ((slot->udata.data[0x14/2]>>0x0)&0x4000)
-#define KRS(slot) ((slot->udata.data[0x14/2]>>0xA)&0x000F)
-#define DL(slot) ((slot->udata.data[0x14/2]>>0x5)&0x001F)
-#define RR(slot) ((slot->udata.data[0x14/2]>>0x0)&0x001F)
+#define LPSLNK(slot) ((slot->udata.data[0x14/2]>>0x0)&0x4000)
+#define KRS(slot) ((slot->udata.data[0x14/2]>>0xA)&0x000F)
+#define DL(slot) ((slot->udata.data[0x14/2]>>0x5)&0x001F)
+#define RR(slot) ((slot->udata.data[0x14/2]>>0x0)&0x001F)
-#define TL(slot) ((slot->udata.data[0x28/2]>>0x8)&0x00FF)
+#define TL(slot) ((slot->udata.data[0x28/2]>>0x8)&0x00FF)
-#define OCT(slot) ((slot->udata.data[0x18/2]>>0xB)&0x000F)
-#define FNS(slot) ((slot->udata.data[0x18/2]>>0x0)&0x03FF)
+#define OCT(slot) ((slot->udata.data[0x18/2]>>0xB)&0x000F)
+#define FNS(slot) ((slot->udata.data[0x18/2]>>0x0)&0x03FF)
-#define LFORE(slot) ((slot->udata.data[0x1c/2]>>0x0)&0x8000)
-#define LFOF(slot) ((slot->udata.data[0x1c/2]>>0xA)&0x001F)
-#define PLFOWS(slot) ((slot->udata.data[0x1c/2]>>0x8)&0x0003)
-#define PLFOS(slot) ((slot->udata.data[0x1c/2]>>0x5)&0x0007)
-#define ALFOWS(slot) ((slot->udata.data[0x1c/2]>>0x3)&0x0003)
-#define ALFOS(slot) ((slot->udata.data[0x1c/2]>>0x0)&0x0007)
+#define LFORE(slot) ((slot->udata.data[0x1c/2]>>0x0)&0x8000)
+#define LFOF(slot) ((slot->udata.data[0x1c/2]>>0xA)&0x001F)
+#define PLFOWS(slot) ((slot->udata.data[0x1c/2]>>0x8)&0x0003)
+#define PLFOS(slot) ((slot->udata.data[0x1c/2]>>0x5)&0x0007)
+#define ALFOWS(slot) ((slot->udata.data[0x1c/2]>>0x3)&0x0003)
+#define ALFOS(slot) ((slot->udata.data[0x1c/2]>>0x0)&0x0007)
-#define ISEL(slot) ((slot->udata.data[0x20/2]>>0x0)&0x000F)
-#define IMXL(slot) ((slot->udata.data[0x20/2]>>0x4)&0x000F)
+#define ISEL(slot) ((slot->udata.data[0x20/2]>>0x0)&0x000F)
+#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 DISDL(slot) ((slot->udata.data[0x24/2]>>0x8)&0x000F)
+#define DIPAN(slot) ((slot->udata.data[0x24/2]>>0x0)&0x001F)
-#define EFSDL(slot) ((AICA->EFSPAN[slot*4]>>8)&0x000f)
-#define EFPAN(slot) ((AICA->EFSPAN[slot*4]>>0)&0x001f)
+#define EFSDL(slot) ((AICA->EFSPAN[slot*4]>>8)&0x000f)
+#define EFPAN(slot) ((AICA->EFSPAN[slot*4]>>0)&0x001f)
//Envelope times in ms
static const double ARTimes[64]={100000/*infinity*/,100000/*infinity*/,8100.0,6900.0,6000.0,4800.0,4000.0,3400.0,3000.0,2400.0,2000.0,1700.0,1500.0,
@@ -84,16 +84,16 @@ static INT32 EG_TABLE[0x400];
enum STATE {ATTACK,DECAY1,DECAY2,RELEASE};
struct EG_t
{
- int volume; //
+ int volume; //
STATE state;
int step;
//step vals
- int AR; //Attack
- int D1R; //Decay1
- int D2R; //Decay2
- int RR; //Release
+ int AR; //Attack
+ int D1R; //Decay1
+ int D2R; //Decay2
+ int RR; //Release
- int DL; //Decay level
+ int DL; //Decay level
UINT8 LPLINK;
};
@@ -101,19 +101,19 @@ struct SLOT
{
union
{
- UINT16 data[0x40]; //only 0x1a bytes used
+ UINT16 data[0x40]; //only 0x1a bytes used
UINT8 datab[0x80];
} udata;
- UINT8 active; //this slot is currently playing
- UINT8 *base; //samples base address
+ UINT8 active; //this slot is currently playing
+ UINT8 *base; //samples base address
UINT32 prv_addr; // previous play address (for ADPCM)
- UINT32 cur_addr; //current play address (24.8)
- UINT32 nxt_addr; //next play address
- UINT32 step; //pitch step (24.8)
- UINT8 Backwards; //the wave is playing backwards
- EG_t EG; //Envelope
- LFO_t PLFO; //Phase LFO
- LFO_t ALFO; //Amplitude LFO
+ UINT32 cur_addr; //current play address (24.8)
+ UINT32 nxt_addr; //next play address
+ UINT32 step; //pitch step (24.8)
+ UINT8 Backwards; //the wave is playing backwards
+ EG_t EG; //Envelope
+ LFO_t PLFO; //Phase LFO
+ LFO_t ALFO; //Amplitude LFO
int slot;
int cur_sample; //current ADPCM sample
int cur_quant; //current ADPCM step
@@ -124,36 +124,36 @@ struct SLOT
};
-#define MEM4B(aica) ((aica->udata.data[0]>>0x0)&0x0200)
-#define DAC18B(aica) ((aica->udata.data[0]>>0x0)&0x0100)
-#define MVOL(aica) ((aica->udata.data[0]>>0x0)&0x000F)
-#define RBL(aica) ((aica->udata.data[2]>>0xD)&0x0003)
-#define RBP(aica) ((aica->udata.data[2]>>0x0)&0x0fff)
-#define MOFULL(aica) ((aica->udata.data[4]>>0x0)&0x1000)
-#define MOEMPTY(aica) ((aica->udata.data[4]>>0x0)&0x0800)
-#define MIOVF(aica) ((aica->udata.data[4]>>0x0)&0x0400)
-#define MIFULL(aica) ((aica->udata.data[4]>>0x0)&0x0200)
-#define MIEMPTY(aica) ((aica->udata.data[4]>>0x0)&0x0100)
-
-#define AFSEL(aica) ((aica->udata.data[0xc/2]>>0x0)&0x4000)
-#define MSLC(aica) ((aica->udata.data[0xc/2]>>0x8)&0x3F)
-
-#define SCILV0(aica) ((aica->udata.data[0xa8/2]>>0x0)&0xff)
-#define SCILV1(aica) ((aica->udata.data[0xac/2]>>0x0)&0xff)
-#define SCILV2(aica) ((aica->udata.data[0xb0/2]>>0x0)&0xff)
-
-#define MCIEB(aica) ((aica->udata.data[0xb4/2]>>0x0)&0xff)
-#define MCIPD(aica) ((aica->udata.data[0xb8/2]>>0x0)&0xff)
-#define MCIRE(aica) ((aica->udata.data[0xbc/2]>>0x0)&0xff)
-
-#define SCIEX0 0
-#define SCIEX1 1
-#define SCIEX2 2
-#define SCIMID 3
-#define SCIDMA 4
-#define SCIIRQ 5
-#define SCITMA 6
-#define SCITMB 7
+#define MEM4B(aica) ((aica->udata.data[0]>>0x0)&0x0200)
+#define DAC18B(aica) ((aica->udata.data[0]>>0x0)&0x0100)
+#define MVOL(aica) ((aica->udata.data[0]>>0x0)&0x000F)
+#define RBL(aica) ((aica->udata.data[2]>>0xD)&0x0003)
+#define RBP(aica) ((aica->udata.data[2]>>0x0)&0x0fff)
+#define MOFULL(aica) ((aica->udata.data[4]>>0x0)&0x1000)
+#define MOEMPTY(aica) ((aica->udata.data[4]>>0x0)&0x0800)
+#define MIOVF(aica) ((aica->udata.data[4]>>0x0)&0x0400)
+#define MIFULL(aica) ((aica->udata.data[4]>>0x0)&0x0200)
+#define MIEMPTY(aica) ((aica->udata.data[4]>>0x0)&0x0100)
+
+#define AFSEL(aica) ((aica->udata.data[0xc/2]>>0x0)&0x4000)
+#define MSLC(aica) ((aica->udata.data[0xc/2]>>0x8)&0x3F)
+
+#define SCILV0(aica) ((aica->udata.data[0xa8/2]>>0x0)&0xff)
+#define SCILV1(aica) ((aica->udata.data[0xac/2]>>0x0)&0xff)
+#define SCILV2(aica) ((aica->udata.data[0xb0/2]>>0x0)&0xff)
+
+#define MCIEB(aica) ((aica->udata.data[0xb4/2]>>0x0)&0xff)
+#define MCIPD(aica) ((aica->udata.data[0xb8/2]>>0x0)&0xff)
+#define MCIRE(aica) ((aica->udata.data[0xbc/2]>>0x0)&0xff)
+
+#define SCIEX0 0
+#define SCIEX1 1
+#define SCIEX2 2
+#define SCIMID 3
+#define SCIDMA 4
+#define SCIIRQ 5
+#define SCITMA 6
+#define SCITMB 7
struct aica_state
{
@@ -210,7 +210,7 @@ static stream_sample_t *bufferr;
static int length;
-static signed short *RBUFDST; //this points to where the sample will be stored in the RingBuf
+static signed short *RBUFDST; //this points to where the sample will be stored in the RingBuf
INLINE aica_state *get_safe_token(device_t *device)
{
@@ -319,7 +319,7 @@ static TIMER_CALLBACK( timerC_cb )
static int Get_AR(aica_state *AICA,int base,int R)
{
int Rate=base+(R<<1);
- if(Rate>63) Rate=63;
+ if(Rate>63) Rate=63;
if(Rate<0) Rate=0;
return AICA->ARTABLE[Rate];
}
@@ -327,7 +327,7 @@ static int Get_AR(aica_state *AICA,int base,int R)
static int Get_DR(aica_state *AICA,int base,int R)
{
int Rate=base+(R<<1);
- if(Rate>63) Rate=63;
+ if(Rate>63) Rate=63;
if(Rate<0) Rate=0;
return AICA->DRTABLE[Rate];
}
@@ -335,7 +335,7 @@ static int Get_DR(aica_state *AICA,int base,int R)
static int Get_RR(aica_state *AICA,int base,int R)
{
int Rate=base+(R<<1);
- if(Rate>63) Rate=63;
+ if(Rate>63) Rate=63;
if(Rate<0) Rate=0;
return AICA->DRTABLE[Rate];
}
@@ -427,8 +427,8 @@ static void Compute_LFO(SLOT *slot)
AICALFO_ComputeStep(&(slot->ALFO),LFOF(slot),ALFOWS(slot),ALFOS(slot),1);
}
-#define ADPCMSHIFT 8
-#define ADFIX(f) (int) ((float) f*(float) (1<<ADPCMSHIFT))
+#define ADPCMSHIFT 8
+#define ADFIX(f) (int) ((float) f*(float) (1<<ADPCMSHIFT))
static const int TableQuant[8]={ADFIX(0.8984375),ADFIX(0.8984375),ADFIX(0.8984375),ADFIX(0.8984375),ADFIX(1.19921875),ADFIX(1.59765625),ADFIX(2.0),ADFIX(2.3984375)};
static const int quant_mul[16]= { 1, 3, 5, 7, 9, 11, 13, 15, -1, -3, -5, -7, -9, -11, -13, -15};
@@ -442,7 +442,7 @@ static void InitADPCM(int *PrevSignal, int *PrevQuant)
INLINE signed short DecodeADPCM(int *PrevSignal, unsigned char Delta, int *PrevQuant)
{
int x = *PrevQuant * quant_mul [Delta & 15];
- x = *PrevSignal + ((int)(x + ((UINT32)x >> 29)) >> 3);
+ x = *PrevSignal + ((int)(x + ((UINT32)x >> 29)) >> 3);
*PrevSignal=ICLIP16(x);
*PrevQuant=(*PrevQuant*TableQuant[Delta&7])>>ADPCMSHIFT;
*PrevQuant=(*PrevQuant<0x7f)?0x7f:((*PrevQuant>0x6000)?0x6000:*PrevQuant);
@@ -456,7 +456,7 @@ static void AICA_StartSlot(aica_state *AICA, SLOT *slot)
slot->active=1;
slot->Backwards=0;
slot->cur_addr=0; slot->nxt_addr=1<<SHIFT; slot->prv_addr=-1;
- start_offset = SA(slot); // AICA can play 16-bit samples from any boundry
+ start_offset = SA(slot); // AICA can play 16-bit samples from any boundry
slot->base=&AICA->AICARAM[start_offset];
slot->step=AICA_Step(slot);
Compute_EG(AICA,slot);
@@ -582,12 +582,12 @@ static void AICA_Init(device_t *device, aica_state *AICA, const aica_interface *
AICA->RPANTABLE[i]=FIX((4.0*RPAN*TL*fSDL));
}
- AICA->ARTABLE[0]=AICA->DRTABLE[0]=0; //Infinite time
- AICA->ARTABLE[1]=AICA->DRTABLE[1]=0; //Infinite time
+ AICA->ARTABLE[0]=AICA->DRTABLE[0]=0; //Infinite time
+ AICA->ARTABLE[1]=AICA->DRTABLE[1]=0; //Infinite time
for(i=2;i<64;++i)
{
double t,step,scale;
- t=ARTimes[i]; //In ms
+ t=ARTimes[i]; //In ms
if(t!=0.0)
{
step=(1023*1000.0)/((float) 44100.0f*t);
@@ -597,7 +597,7 @@ static void AICA_Init(device_t *device, aica_state *AICA, const aica_interface *
else
AICA->ARTABLE[i]=1024<<EG_SHIFT;
- t=DRTimes[i]; //In ms
+ t=DRTimes[i]; //In ms
step=(1023*1000.0)/((float) 44100.0f*t);
scale=(double) (1<<EG_SHIFT);
AICA->DRTABLE[i]=(int) (step*scale);
@@ -768,7 +768,7 @@ static void AICA_UpdateReg(aica_state *AICA, address_space &space, int reg)
}
}
break;
- case 0xa4: //SCIRE
+ case 0xa4: //SCIRE
case 0xa5:
if(AICA->Master)
@@ -833,7 +833,7 @@ static void AICA_UpdateRegR(aica_state *AICA, address_space &space, int reg)
unsigned short v=AICA->udata.data[0x8/2];
v&=0xff00;
v|=AICA->MidiStack[AICA->MidiR];
- AICA->IntARMCB(AICA->device, 0); // cancel the IRQ
+ AICA->IntARMCB(AICA->device, 0); // cancel the IRQ
if(AICA->MidiR!=AICA->MidiW)
{
++AICA->MidiR;
@@ -843,7 +843,7 @@ static void AICA_UpdateRegR(aica_state *AICA, address_space &space, int reg)
}
break;
- case 0x10: // LP check
+ case 0x10: // LP check
case 0x11:
{
int slotnum = MSLC(AICA);
@@ -872,18 +872,18 @@ static void AICA_UpdateRegR(aica_state *AICA, address_space &space, int reg)
}
break;
- case 0x14: // CA (slot address)
+ case 0x14: // CA (slot address)
case 0x15:
{
int slotnum = MSLC(AICA);
SLOT *slot=AICA->Slots+slotnum;
unsigned int CA = 0;
- if (PCMS(slot) == 0) // 16-bit samples
+ if (PCMS(slot) == 0) // 16-bit samples
{
CA = (slot->cur_addr>>(SHIFT-1))&AICA->RAM_MASK16;
}
- else // 8-bit PCM and 4-bit ADPCM
+ else // 8-bit PCM and 4-bit ADPCM
{
CA = (slot->cur_addr>>SHIFT)&AICA->RAM_MASK;
}
@@ -938,7 +938,7 @@ static void AICA_w16(aica_state *AICA,address_space &space,unsigned int addr,uns
else
{
//DSP
- if(addr<0x3200) //COEF
+ if(addr<0x3200) //COEF
*((unsigned short *) (AICA->DSP.COEF+(addr-0x3000)/2))=val;
else if(addr<0x3400)
*((unsigned short *) (AICA->DSP.MADRS+(addr-0x3200)/2))=val;
@@ -975,7 +975,7 @@ static unsigned short AICA_r16(aica_state *AICA, address_space &space, unsigned
{
AICA_UpdateRegR(AICA, space, addr&0xff);
v= *((unsigned short *) (AICA->udata.datab+((addr&0xff))));
- if((addr&0xfffe)==0x2810) AICA->udata.data[0x10/2] &= 0x7FFF; // reset LP on read
+ if((addr&0xfffe)==0x2810) AICA->udata.data[0x10/2] &= 0x7FFF; // reset LP on read
}
else if (addr == 0x2d00)
{
@@ -1043,7 +1043,7 @@ INLINE INT32 AICA_UpdateSlot(aica_state *AICA, SLOT *slot)
UINT32 *addr[2] = {&addr1, &addr2}; // used for linear interpolation
UINT32 *slot_addr[2] = {&(slot->cur_addr), &(slot->nxt_addr)}; //
- if(SSCTL(slot)!=0) //no FM or noise yet
+ if(SSCTL(slot)!=0) //no FM or noise yet
return 0;
if(PLFOS(slot)!=0)
@@ -1068,7 +1068,7 @@ INLINE INT32 AICA_UpdateSlot(aica_state *AICA, SLOT *slot)
addr2=slot->nxt_addr>>SHIFT;
}
- if(PCMS(slot) == 1) // 8-bit signed
+ if(PCMS(slot) == 1) // 8-bit signed
{
INT8 *p1=(signed char *) (AICA->AICARAM+(((SA(slot)+addr1))&AICA->RAM_MASK));
INT8 *p2=(signed char *) (AICA->AICARAM+(((SA(slot)+addr2))&AICA->RAM_MASK));
@@ -1077,7 +1077,7 @@ INLINE INT32 AICA_UpdateSlot(aica_state *AICA, SLOT *slot)
s=(int) (p1[0]<<8)*((1<<SHIFT)-fpart)+(int) (p2[0]<<8)*fpart;
sample=(s>>SHIFT);
}
- else if (PCMS(slot) == 0) //16 bit signed
+ else if (PCMS(slot) == 0) //16 bit signed
{
UINT8 *p1=(UINT8 *) (AICA->AICARAM+((SA(slot)+addr1)&AICA->RAM_MASK));
UINT8 *p2=(UINT8 *) (AICA->AICARAM+((SA(slot)+addr2)&AICA->RAM_MASK));
@@ -1086,7 +1086,7 @@ INLINE INT32 AICA_UpdateSlot(aica_state *AICA, SLOT *slot)
s=(int) ((INT16)(p1[0] | (p1[1]<<8)))*((1<<SHIFT)-fpart)+(int) ((INT16)(p2[0] | (p2[1]<<8)))*fpart;
sample=(s>>SHIFT);
}
- else // 4-bit ADPCM
+ else // 4-bit ADPCM
{
UINT8 *base= slot->adbase;
INT32 s;
@@ -1148,7 +1148,7 @@ INLINE INT32 AICA_UpdateSlot(aica_state *AICA, SLOT *slot)
INT32 rem_addr;
switch(LPCTL(slot))
{
- case 0: //no loop
+ case 0: //no loop
if(*addr[addr_select]>=LSA(slot) && *addr[addr_select]>=LEA(slot))
{
AICA_StopSlot(slot,0);
@@ -1357,7 +1357,7 @@ const device_type AICA = &device_creator<aica_device>;
aica_device::aica_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, AICA, "AICA", tag, owner, clock),
- device_sound_interface(mconfig, *this)
+ device_sound_interface(mconfig, *this)
{
m_token = global_alloc_clear(aica_state);
}
@@ -1399,5 +1399,3 @@ void aica_device::sound_stream_update(sound_stream &stream, stream_sample_t **in
// should never get here
fatalerror("sound_stream_update called; not applicable to legacy sound devices\n");
}
-
-