Implemented lazyusf HLE audio IIR function, thanks to JoshW
parent
7115566476
commit
fb323d11e9
|
@ -85,7 +85,7 @@ static void alist_envmix_mix(size_t n, int16_t** dst, const int16_t* gains, int1
|
|||
static int16_t ramp_step(struct ramp_t* ramp)
|
||||
{
|
||||
bool target_reached;
|
||||
|
||||
|
||||
ramp->value += ramp->step;
|
||||
|
||||
target_reached = (ramp->step <= 0)
|
||||
|
@ -968,3 +968,64 @@ void alist_polef(
|
|||
|
||||
dram_store_u16(hle, (uint16_t*)(dst - 4), address, 4);
|
||||
}
|
||||
|
||||
void alist_iirf(
|
||||
struct hle_t* hle,
|
||||
bool init,
|
||||
uint16_t dmemo,
|
||||
uint16_t dmemi,
|
||||
uint16_t count,
|
||||
int16_t* table,
|
||||
uint32_t address)
|
||||
{
|
||||
int16_t *dst = (int16_t*)(hle->alist_buffer + dmemo);
|
||||
int32_t i, prev;
|
||||
int16_t frame[8];
|
||||
int16_t ibuf[4];
|
||||
uint16_t index = 7;
|
||||
|
||||
|
||||
count = align(count, 16);
|
||||
|
||||
#define vmulf(a, b) (((a)*(b)+0x4000)>>15)
|
||||
|
||||
if(init)
|
||||
{
|
||||
for(i = 0; i < 8; i++)
|
||||
frame[i] = 0;
|
||||
ibuf[1] = 0;
|
||||
ibuf[2] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
frame[6] = *dram_u16(hle, address + 4);
|
||||
frame[7] = *dram_u16(hle, address + 6);
|
||||
ibuf[1] = (int16_t)*dram_u16(hle, address + 8);
|
||||
ibuf[2] = (int16_t)*dram_u16(hle, address + 10);
|
||||
}
|
||||
|
||||
prev = vmulf(table[9], frame[6]) * 2;
|
||||
do
|
||||
{
|
||||
for(i = 0; i < 8; i++)
|
||||
{
|
||||
int32_t accu;
|
||||
ibuf[index&3] = *alist_s16(hle, dmemi);
|
||||
|
||||
accu = prev + vmulf(table[0], ibuf[index&3]) + vmulf(table[1], ibuf[(index-1)&3]) + vmulf(table[0], ibuf[(index-2)&3]);
|
||||
accu += vmulf(table[8], frame[index]) * 2;
|
||||
prev = vmulf(table[9], frame[index]) * 2;
|
||||
dst[i^S] = frame[i] = accu;
|
||||
|
||||
index=(index+1)&7;
|
||||
dmemi += 2;
|
||||
}
|
||||
dst += 8;
|
||||
count -= 0x10;
|
||||
} while (count > 0);
|
||||
|
||||
dram_store_u16(hle, &frame[6], address + 4, 4);
|
||||
dram_store_u16(hle, (int16_t*)&ibuf[(index-2)&3], address+8, 2);
|
||||
dram_store_u16(hle, (int16_t*)&ibuf[(index-1)&3], address+10, 2);
|
||||
}
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ void alist_adpcm(
|
|||
uint32_t last_frame_address);
|
||||
|
||||
void alist_resample(
|
||||
struct hle_t* hle,
|
||||
struct hle_t* hle,
|
||||
bool init,
|
||||
bool flag2,
|
||||
uint16_t dmemo, uint16_t dmemi, uint16_t count,
|
||||
|
@ -144,6 +144,16 @@ void alist_polef(
|
|||
uint16_t gain,
|
||||
int16_t* table,
|
||||
uint32_t address);
|
||||
|
||||
void alist_iirf(
|
||||
struct hle_t* hle,
|
||||
bool init,
|
||||
uint16_t dmemo,
|
||||
uint16_t dmemi,
|
||||
uint16_t count,
|
||||
int16_t* table,
|
||||
uint32_t address);
|
||||
|
||||
/*
|
||||
* Audio flags
|
||||
*/
|
||||
|
|
|
@ -77,15 +77,14 @@ static void NAUDIO_02B0(struct hle_t* hle, uint32_t UNUSED(w1), uint32_t w2)
|
|||
|
||||
static void NAUDIO_14(struct hle_t* hle, uint32_t w1, uint32_t w2)
|
||||
{
|
||||
uint8_t flags = (w1 >> 16);
|
||||
uint16_t gain = w1;
|
||||
uint8_t select_main = (w2 >> 24);
|
||||
uint32_t address = (w2 & 0xffffff);
|
||||
|
||||
uint16_t dmem = (select_main == 0) ? NAUDIO_MAIN : NAUDIO_MAIN2;
|
||||
|
||||
if (hle->alist_naudio.table[0] == 0 && hle->alist_naudio.table[1] == 0) {
|
||||
|
||||
uint8_t flags = (w1 >> 16);
|
||||
uint16_t gain = w1;
|
||||
uint8_t select_main = (w2 >> 24);
|
||||
uint32_t address = (w2 & 0xffffff);
|
||||
|
||||
uint16_t dmem = (select_main == 0) ? NAUDIO_MAIN : NAUDIO_MAIN2;
|
||||
|
||||
alist_polef(
|
||||
hle,
|
||||
flags & A_INIT,
|
||||
|
@ -97,8 +96,17 @@ static void NAUDIO_14(struct hle_t* hle, uint32_t w1, uint32_t w2)
|
|||
address);
|
||||
}
|
||||
else
|
||||
HleWarnMessage(hle->user_defined,
|
||||
"NAUDIO_14: non null codebook[0-3] case not implemented.");
|
||||
{
|
||||
alist_iirf(
|
||||
hle,
|
||||
flags & A_INIT,
|
||||
dmem,
|
||||
dmem,
|
||||
NAUDIO_COUNT,
|
||||
hle->alist_naudio.table,
|
||||
address);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void SETVOL(struct hle_t* hle, uint32_t w1, uint32_t w2)
|
||||
|
|
Loading…
Reference in New Issue