Backported EG hack. Courtesy of libretro.

See 13dacb0021
This commit is contained in:
Flyinghead 2018-06-29 17:04:07 +02:00
parent f18aa63a67
commit 17a34c079c
3 changed files with 82 additions and 7 deletions

View File

@ -3,6 +3,8 @@
#include "aica_mem.h"
#include "hw/aica/aica_if.h"
#include <math.h>
#include <algorithm>
using namespace std;
#undef FAR
//#define CLIP_WARN
@ -390,7 +392,7 @@ struct ChannelEx
return rv;
}
__forceinline bool Step(SampleType& oLeft, SampleType& oRight, SampleType& oDsp)
__forceinline bool Step(SampleType& oLeft, SampleType& oRight, SampleType& oDsp, int32_t mixl, int32_t mixr)
{
if (!enabled)
{
@ -409,12 +411,18 @@ struct ChannelEx
//logtable handles up to 1024, anything >=255 is mute
u32 ofsatt=lfo.alfo+(AEG.GetValue()>>2);
ofsatt = min(ofsatt, (u32)255); // make sure it never gets more 255 -- it can happen with some alfo/aeg combinations
u32 const max_att = ((16 << 4) - 1) - ofsatt;
s32* logtable=ofsatt+tl_lut;
s32* logtable = ofsatt + tl_lut;
oLeft=FPMul(sample,logtable[VolMix.DLAtt],15);
oRight=FPMul(sample,logtable[VolMix.DRAtt],15);
oDsp=FPMul(sample,logtable[VolMix.DSPAtt],15);
u32 dl = min(VolMix.DLAtt, max_att);
u32 dr = min(VolMix.DRAtt, max_att);
u32 ds = min(VolMix.DSPAtt, max_att);
oLeft = FPMul(sample, logtable[dl], 15);
oRight = FPMul(sample, logtable[dr], 15);
oDsp = FPMul(sample, logtable[ds], 15);
clip_verify(((s16)oLeft)==oLeft);
clip_verify(((s16)oRight)==oRight);
@ -423,6 +431,33 @@ struct ChannelEx
clip_verify(sample*oRight>=0);
clip_verify(sample*oDsp>=0);
if (settings.aica.EGHack)
{
if ((s64)(this->ccd->DL + mixl + mixr + *VolMix.DSPOut) == 0)
{
switch(this->AEG.state)
{
case EG_Decay1:
if(this->AEG.AttackRate > this->AEG.Decay1Rate)
{
//printf("Promote 1\n");
this->SetAegState(EG_Attack);
}
break;
case EG_Decay2:
if(this->AEG.AttackRate > this->AEG.Decay2Rate)
{
//printf("Promote 2\n");
this->SetAegState(EG_Attack);
}
break;
}
}
}
StepAEG(this);
StepFEG(this);
StepStream(this);
@ -435,7 +470,7 @@ struct ChannelEx
{
SampleType oLeft,oRight,oDsp;
Step(oLeft,oRight,oDsp);
Step(oLeft, oRight, oDsp, mixl, mixr);
*VolMix.DSPOut+=oDsp;
mixl+=oLeft;
@ -1191,7 +1226,7 @@ void AICA_Sample32()
{
SampleType oLeft,oRight,oDsp;
//stop working on this channel if its turned off ...
if (!Chans[ch].Step(oLeft, oRight, oDsp))
if (!Chans[ch].Step(oLeft, oRight, oDsp, mxlr[i * 2 + 0], mxlr[i * 2 + 1]))
break;
sg++;

View File

@ -129,6 +129,37 @@ void* webui_th(void* p)
cThread webui_thd(&webui_th,0);
#endif
const char *EGHackGamesList[] = {
"T46703M", /* Border Down (Japan) */
"RDC-0117", /* Border Down (Japan) */
"MK-51065", /* Bomberman Online (USA) */
"T47801M", /* Chaos Field (Japan) */
"T23202M", /* Death Crimson OX (Japan) */
"T2401N", /* Death Crimson OX (USA) */
"T3108M", /* Garou: Mark of the Wolves (Japan) */
"HDR-0078", /* Jet Set Radio (Japan) */
"MK-51058", /* Jet Grind Radio (USA, Europe) */
"HDR-0079", /* Napple Tale (Japan) */
"MK-5110050", /* Phantasy Star Online (Europe) */
"HDR-0129", /* Phantasy Star Online (Japan) */
"MK-51100", /* Phantasy Star Online (USA) */
"MK-5119350", /* Phantasy Star Online Ver. 2 (Europe) */
"HDR-0163", /* Phantasy Star Online Ver. 2 (Japan) */
"MK-51193", /* Phantasy Star Online Ver. 2 (USA) */
"T9907M", /* Psyvariar 2 (Japan) */
"HDR-0216", /* Puyo Puyo Fever (Japan) */
"T47802M", /* Radirgy (Japan) */
"HDR-0151", /* Segagaga (Japan) */
"HDR-0125", /* Sonic Shuffle (Japan) */
"MK-5106050", /* Sonic Shuffle (Europe) */
"MK-51060", /* Sonic Shuffle (USA) */
"T29102M", /* Trigger Heart Exelica (Japan) */
"T45101M", /* WWF Royal Rumble (Japan) */
"T10003D 50", /* WWF Royal Rumble (Europe) */
"T10005N", /* WWF Royal Rumble (USA) */
NULL
};
void LoadSpecialSettings()
{
if (!strncmp("T13008D", reios_product_number, 7) || !strncmp("T13006N", reios_product_number, 7))
@ -137,6 +168,13 @@ void LoadSpecialSettings()
if (!strncmp("RDC-0057", reios_product_number, 8))
// Cosmic Smash
settings.rend.TranslucentPolygonDepthMask = 1;
for (int i = 0; EGHackGamesList[i] != NULL; i++)
if (!strncmp(reios_product_number, EGHackGamesList[i], strlen(EGHackGamesList[i])))
{
printf("Enabling EG Hack\n");
settings.aica.EGHack = 1;
break;
}
}
int dc_init(int argc,wchar* argv[])
@ -258,6 +296,7 @@ void LoadSettings()
settings.aica.LimitFPS = cfgLoadInt("config","aica.LimitFPS",1);
settings.aica.NoBatch = cfgLoadInt("config","aica.NoBatch",0);
settings.aica.NoSound = cfgLoadInt("config","aica.NoSound",0);
settings.aica.EGHack = cfgLoadInt("config","aica.EGHack", 0);;
settings.rend.UseMipmaps = cfgLoadInt("config","rend.UseMipmaps",1);
settings.rend.WideScreen = cfgLoadInt("config","rend.WideScreen",0);
settings.rend.ShowFPS = cfgLoadInt("config", "rend.ShowFPS", 0);

View File

@ -653,6 +653,7 @@ struct settings_t
u32 DSPEnabled; //0 -> no, 1 -> yes
u32 NoBatch;
u32 NoSound; //0 ->sound, 1 -> no sound
u32 EGHack;
} aica;
#if USE_OMX