Highly Complete / USF: Preliminary overload HLE

Include preliminary overload effect for MP3 and CBFD HLE operations,
based on a pull request from upstream. This should make the HLE pretty
much sound for general use once again.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
CQTexperiment
Christopher Snowhill 2022-03-05 20:43:41 -08:00
parent 5622e92899
commit d570cf346d
3 changed files with 36 additions and 4 deletions

View File

@ -1031,3 +1031,17 @@ void alist_iirf(
dram_store_u16(hle, (uint16_t*)&ibuf[(index-1)&3], address+10, 1);
}
/* Perform a clamped gain, then attenuate it back by an amount */
void alist_overload(struct hle_t* hle, uint16_t dmem, int16_t count, int16_t gain, int16_t attenuation)
{
int16_t accu;
int16_t * sample = (int16_t*)(hle->alist_buffer + dmem);
while (count != 0)
{
accu = clamp_s16(*sample * gain);
*sample = (accu * attenuation) >> 16;
sample++;
count --;
}
}

View File

@ -154,6 +154,13 @@ void alist_iirf(
int16_t* table,
uint32_t address);
void alist_overload(
struct hle_t* hle,
uint16_t dmem,
int16_t count,
int16_t gain,
int16_t attenuation);
/*
* Audio flags
*/

View File

@ -263,6 +263,17 @@ static void MP3(struct hle_t* hle, uint32_t w1, uint32_t w2)
mp3_task(hle, index, address);
}
static void OVERLOAD(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
/* Overload distortion effect for Conker's Bad Fur Day */
/* Also included in Jet Force Gemini microcode */
uint16_t dmem = (w1 & 0xfff) + NAUDIO_MAIN;
int16_t gain = w2 & 0x7fff;
int16_t attenuation = w2 >> 16;
alist_overload(hle, dmem, NAUDIO_COUNT, gain, attenuation);
}
/* global functions */
void alist_process_naudio(struct hle_t* hle)
{
@ -341,7 +352,7 @@ void alist_process_naudio_dk(struct hle_t* hle)
void alist_process_naudio_mp3(struct hle_t* hle)
{
static const acmd_callback_t ABI[0x10] = {
UNKNOWN, ADPCM, CLEARBUFF, ENVMIXER,
OVERLOAD, ADPCM, CLEARBUFF, ENVMIXER,
LOADBUFF, RESAMPLE, SAVEBUFF, MP3,
MP3ADDY, SETVOL, DMEMMOVE, LOADADPCM,
MIXER, INTERLEAVE, NAUDIO_14, SETLOOP
@ -349,7 +360,7 @@ void alist_process_naudio_mp3(struct hle_t* hle)
#ifdef DEBUG_INFO
static const char * ABI_names[0x10] = {
"UNKNOWN", "ADPCM", "CLEARBUFF", "ENVMIXER",
"OVERLOAD", "ADPCM", "CLEARBUFF", "ENVMIXER",
"LOADBUFF", "RESAMPLE", "SAVEBUFF", "MP3",
"MP3ADDY", "SETVOL", "DMEMMOVE", "LOADADPCM",
"MIXER", "INTERLEAVE", "NAUDIO_14", "SETLOOP"
@ -366,7 +377,7 @@ void alist_process_naudio_cbfd(struct hle_t* hle)
{
/* TODO: see what differs from alist_process_naudio_mp3 */
static const acmd_callback_t ABI[0x10] = {
UNKNOWN, ADPCM, CLEARBUFF, ENVMIXER,
OVERLOAD, ADPCM, CLEARBUFF, ENVMIXER,
LOADBUFF, RESAMPLE, SAVEBUFF, MP3,
MP3ADDY, SETVOL, DMEMMOVE, LOADADPCM,
MIXER, INTERLEAVE, NAUDIO_14, SETLOOP
@ -374,7 +385,7 @@ void alist_process_naudio_cbfd(struct hle_t* hle)
#ifdef DEBUG_INFO
static const char * ABI_names[0x10] = {
"UNKNOWN", "ADPCM", "CLEARBUFF", "ENVMIXER",
"OVERLOAD", "ADPCM", "CLEARBUFF", "ENVMIXER",
"LOADBUFF", "RESAMPLE", "SAVEBUFF", "MP3",
"MP3ADDY", "SETVOL", "DMEMMOVE", "LOADADPCM",
"MIXER", "INTERLEAVE", "NAUDIO_14", "SETLOOP"