Compare commits

...

5 Commits

Author SHA1 Message Date
refractionpcsx2 a704046dae
Merge 01bd6f56ea into fbe0c8b9cc 2025-01-17 10:51:45 -05:00
shockdude fbe0c8b9cc USB: Fix DJ Hero Turntable automatic mapping & turntable multiplier 2025-01-17 10:44:52 -05:00
Ziemas 2e3501366f iR3000A/iR5900: Partial revert of 8c98f5d928 ("Remove mid block jumping") 2025-01-17 10:42:48 -05:00
Ziemas ef7169dbbf host: fix gcc build 2025-01-17 10:42:13 -05:00
refractionpcsx2 01bd6f56ea GS: Add Pre-Round Sprite hack
This attempts to preproduce hardware behaviour, but falls down in a bunch of cases, hence the hack.
2024-12-02 23:29:34 +01:00
11 changed files with 169 additions and 15 deletions

View File

@ -101,6 +101,7 @@ GraphicsSettingsWidget::GraphicsSettingsWidget(SettingsWindow* dialog, QWidget*
SettingWidgetBinder::BindWidgetToIntSetting( SettingWidgetBinder::BindWidgetToIntSetting(
sif, m_ui.screenshotFormat, "EmuCore/GS", "ScreenshotFormat", static_cast<int>(GSScreenshotFormat::PNG)); sif, m_ui.screenshotFormat, "EmuCore/GS", "ScreenshotFormat", static_cast<int>(GSScreenshotFormat::PNG));
SettingWidgetBinder::BindWidgetToIntSetting(sif, m_ui.screenshotQuality, "EmuCore/GS", "ScreenshotQuality", 50); SettingWidgetBinder::BindWidgetToIntSetting(sif, m_ui.screenshotQuality, "EmuCore/GS", "ScreenshotQuality", 50);
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.PreRoundSprites, "EmuCore/GS", "preround_sprites", false);
SettingWidgetBinder::BindWidgetToFloatSetting(sif, m_ui.stretchY, "EmuCore/GS", "StretchY", 100.0f); SettingWidgetBinder::BindWidgetToFloatSetting(sif, m_ui.stretchY, "EmuCore/GS", "StretchY", 100.0f);
SettingWidgetBinder::BindWidgetToIntSetting(sif, m_ui.cropLeft, "EmuCore/GS", "CropLeft", 0); SettingWidgetBinder::BindWidgetToIntSetting(sif, m_ui.cropLeft, "EmuCore/GS", "CropLeft", 0);
SettingWidgetBinder::BindWidgetToIntSetting(sif, m_ui.cropTop, "EmuCore/GS", "CropTop", 0); SettingWidgetBinder::BindWidgetToIntSetting(sif, m_ui.cropTop, "EmuCore/GS", "CropTop", 0);

View File

@ -456,6 +456,16 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1">
<widget class="QCheckBox" name="PreRoundSprites">
<property name="toolTip">
<string>Attempts to pre-round sprite texel coordinates to resolve rounding issues. Helpful for games such as Beyond Good and Evil, and Manhunt</string>
</property>
<property name="text">
<string>Pre-Round Sprites</string>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>

View File

@ -726,6 +726,7 @@ struct Pcsx2Config
PreloadFrameWithGSData : 1, PreloadFrameWithGSData : 1,
Mipmap : 1, Mipmap : 1,
HWMipmap : 1, HWMipmap : 1,
PreRoundSprites : 1,
ManualUserHacks : 1, ManualUserHacks : 1,
UserHacks_AlignSpriteX : 1, UserHacks_AlignSpriteX : 1,
UserHacks_CPUFBConversion : 1, UserHacks_CPUFBConversion : 1,

View File

@ -1683,7 +1683,96 @@ void GSState::FlushPrim()
// Sometimes hardware doesn't get affected, likely due to the difference in how GPU's handle textures (Persona minimap). // Sometimes hardware doesn't get affected, likely due to the difference in how GPU's handle textures (Persona minimap).
if (PRIM->TME && (GSUtil::GetPrimClass(PRIM->PRIM) == GS_PRIM_CLASS::GS_SPRITE_CLASS || m_vt.m_eq.z)) if (PRIM->TME && (GSUtil::GetPrimClass(PRIM->PRIM) == GS_PRIM_CLASS::GS_SPRITE_CLASS || m_vt.m_eq.z))
{ {
if (!PRIM->FST) // STQ's if (PRIM->FST && GSConfig.PreRoundSprites) // UV's
{
// UV's on sprites only alter the final UV, I believe the problem is we're drawing too much (drawing stops earlier than we do)
// But this fixes Beyond Good adn Evil water and Dark Cloud 2's UI
if (GSUtil::GetPrimClass(PRIM->PRIM) == GS_PRIM_CLASS::GS_SPRITE_CLASS)
{
for (u32 i = 0; i < m_index.tail; i += 2)
{
GSVertex* v1 = &m_vertex.buff[m_index.buff[i]];
GSVertex* v2 = &m_vertex.buff[m_index.buff[i + 1]];
GSVertex* vu1;
GSVertex* vu2;
GSVertex* vv1;
GSVertex* vv2;
if (v1->U > v2->U)
{
vu2 = v1;
vu1 = v2;
}
else
{
vu2 = v2;
vu1 = v1;
}
if (v1->V > v2->V)
{
vv2 = v1;
vv1 = v2;
}
else
{
vv2 = v2;
vv1 = v1;
}
GSVector2 pos_range(vu2->XYZ.X - vu1->XYZ.X, vv2->XYZ.Y - vv1->XYZ.Y);
const GSVector2 uv_range(vu2->U - vu1->U, vv2->V - vv1->V);
if (pos_range.x == 0)
pos_range.x = 1;
if (pos_range.y == 0)
pos_range.y = 1;
const GSVector2 grad(uv_range / pos_range);
bool isclamp_w = m_context->CLAMP.WMS > 0 && m_context->CLAMP.WMS < 3;
bool isclamp_h = m_context->CLAMP.WMT > 0 && m_context->CLAMP.WMT < 3;
int max_w = (m_context->CLAMP.WMS == 2) ? m_context->CLAMP.MAXU : ((1 << m_context->TEX0.TW) - 1);
int max_h = (m_context->CLAMP.WMT == 2) ? m_context->CLAMP.MAXV : ((1 << m_context->TEX0.TH) - 1);
int width = vu2->U >> 4;
int height = vv2->V >> 4;
if (m_context->CLAMP.WMS == 3)
width = (width & m_context->CLAMP.MINU) | m_context->CLAMP.MAXU;
if (m_context->CLAMP.WMT == 3)
height = (height & m_context->CLAMP.MINV) | m_context->CLAMP.MAXV;
if ((isclamp_w && width <= max_w && grad.x != 1.0f) || !isclamp_w)
{
if (vu2->U >= 0x1 && (!(vu2->U & 0xf) || grad.x <= 1.0f))
{
vu2->U = (vu2->U - 1);
/*if (!isclamp_w && ((vu2->XYZ.X - m_context->XYOFFSET.OFX) >> 4) < m_context->scissor.in.z)
vu2->XYZ.X -= 1;*/
}
}
else
vu2->U &= ~0xf;
// Dark Cloud 2 tries to address wider than the TBW when in CLAMP mode (maybe some weird behaviour in HW?)
if ((vu2->U >> 4) > (int)(m_context->TEX0.TBW * 64) && isclamp_w && (vu2->U >> 4) - 8 <= (int)(m_context->TEX0.TBW * 64))
{
vu2->U = (m_context->TEX0.TBW * 64) << 4;
}
if ((isclamp_h && height <= max_h && grad.y != 1.0f) || !isclamp_h)
{
if (vv2->V >= 0x1 && (!(vv2->V & 0xf) || grad.y <= 1.0f))
{
vv2->V = (vv2->V - 1);
/*if (!isclamp_h && ((vv2->XYZ.Y - m_context->XYOFFSET.OFY) >> 4) < m_context->scissor.in.w)
vv2->XYZ.Y -= 1;*/
}
}
else
vv2->V &= ~0xf;
}
}
}
else if (!PRIM->FST) // STQ's
{ {
const bool is_sprite = GSUtil::GetPrimClass(PRIM->PRIM) == GS_PRIM_CLASS::GS_SPRITE_CLASS; const bool is_sprite = GSUtil::GetPrimClass(PRIM->PRIM) == GS_PRIM_CLASS::GS_SPRITE_CLASS;
// ST's have the lowest 9 bits (or greater depending on exponent difference) rounding down (from hardware tests). // ST's have the lowest 9 bits (or greater depending on exponent difference) rounding down (from hardware tests).
@ -1736,7 +1825,6 @@ void GSState::FlushPrim()
if (unused > 0) if (unused > 0)
{ {
memcpy(m_vertex.buff, buff, sizeof(GSVertex) * unused); memcpy(m_vertex.buff, buff, sizeof(GSVertex) * unused);
m_vertex.tail = unused; m_vertex.tail = unused;
m_vertex.next = next > head ? next - head : 0; m_vertex.next = next > head ? next - head : 0;
@ -3486,7 +3574,6 @@ __forceinline void GSState::VertexKick(u32 skip)
const GSVector4i new_v1(m_v.m[1]); const GSVector4i new_v1(m_v.m[1]);
GSVector4i* RESTRICT tailptr = (GSVector4i*)&m_vertex.buff[tail]; GSVector4i* RESTRICT tailptr = (GSVector4i*)&m_vertex.buff[tail];
tailptr[0] = new_v0; tailptr[0] = new_v0;
tailptr[1] = new_v1; tailptr[1] = new_v1;

View File

@ -377,6 +377,7 @@ static const char* s_gs_hw_fix_names[] = {
"estimateTextureRegion", "estimateTextureRegion",
"PCRTCOffsets", "PCRTCOffsets",
"PCRTCOverscan", "PCRTCOverscan",
"preRoundSprites",
"trilinearFiltering", "trilinearFiltering",
"skipDrawStart", "skipDrawStart",
"skipDrawEnd", "skipDrawEnd",
@ -423,6 +424,7 @@ bool GameDatabaseSchema::isUserHackHWFix(GSHWFixId id)
case GSHWFixId::Deinterlace: case GSHWFixId::Deinterlace:
case GSHWFixId::Mipmap: case GSHWFixId::Mipmap:
case GSHWFixId::TexturePreloading: case GSHWFixId::TexturePreloading:
case GSHWFixId::PreRoundSprites:
case GSHWFixId::TrilinearFiltering: case GSHWFixId::TrilinearFiltering:
case GSHWFixId::MinimumBlendingLevel: case GSHWFixId::MinimumBlendingLevel:
case GSHWFixId::MaximumBlendingLevel: case GSHWFixId::MaximumBlendingLevel:
@ -779,6 +781,10 @@ void GameDatabaseSchema::GameEntry::applyGSHardwareFixes(Pcsx2Config::GSOptions&
config.PCRTCOverscan = (value > 0); config.PCRTCOverscan = (value > 0);
break; break;
case GSHWFixId::PreRoundSprites:
config.PreRoundSprites = (value > 0);
break;
case GSHWFixId::Mipmap: case GSHWFixId::Mipmap:
config.HWMipmap = (value > 0); config.HWMipmap = (value > 0);
break; break;

View File

@ -60,6 +60,7 @@ namespace GameDatabaseSchema
EstimateTextureRegion, EstimateTextureRegion,
PCRTCOffsets, PCRTCOffsets,
PCRTCOverscan, PCRTCOverscan,
PreRoundSprites,
// integer settings // integer settings
TrilinearFiltering, TrilinearFiltering,

View File

@ -10,6 +10,7 @@
#include <ctime> #include <ctime>
#include <functional> #include <functional>
#include <memory>
#include <mutex> #include <mutex>
#include <optional> #include <optional>
#include <string> #include <string>

View File

@ -735,6 +735,7 @@ Pcsx2Config::GSOptions::GSOptions()
PreloadFrameWithGSData = false; PreloadFrameWithGSData = false;
Mipmap = true; Mipmap = true;
HWMipmap = true; HWMipmap = true;
PreRoundSprites = false;
ManualUserHacks = false; ManualUserHacks = false;
UserHacks_AlignSpriteX = false; UserHacks_AlignSpriteX = false;
@ -938,6 +939,7 @@ void Pcsx2Config::GSOptions::LoadSave(SettingsWrapper& wrap)
SettingsWrapBitBool(OsdShowVideoCapture); SettingsWrapBitBool(OsdShowVideoCapture);
SettingsWrapBitBool(OsdShowInputRec); SettingsWrapBitBool(OsdShowInputRec);
SettingsWrapBitBoolEx(PreRoundSprites, "preround_sprites");
SettingsWrapBitBool(HWSpinGPUForReadbacks); SettingsWrapBitBool(HWSpinGPUForReadbacks);
SettingsWrapBitBool(HWSpinCPUForReadbacks); SettingsWrapBitBool(HWSpinCPUForReadbacks);
SettingsWrapBitBoolEx(GPUPaletteConversion, "paltex"); SettingsWrapBitBoolEx(GPUPaletteConversion, "paltex");

View File

@ -93,19 +93,19 @@ namespace usb_pad
u8 right_turntable = 0x80; u8 right_turntable = 0x80;
if (data.left_turntable_ccw > 0) if (data.left_turntable_ccw > 0)
{ {
left_turntable -= static_cast<u8>(std::min<int>(data.left_turntable_ccw * turntable_multiplier, 0x7F)); left_turntable -= static_cast<u8>(std::min<int>(data.left_turntable_ccw, 0x7F));
} }
else else
{ {
left_turntable += static_cast<u8>(std::min<int>(data.left_turntable_cw * turntable_multiplier, 0x7F)); left_turntable += static_cast<u8>(std::min<int>(data.left_turntable_cw, 0x7F));
} }
if (data.right_turntable_ccw > 0) if (data.right_turntable_ccw > 0)
{ {
right_turntable -= static_cast<u8>(std::min<int>(data.right_turntable_ccw * turntable_multiplier, 0x7F)); right_turntable -= static_cast<u8>(std::min<int>(data.right_turntable_ccw, 0x7F));
} }
else else
{ {
right_turntable += static_cast<u8>(std::min<int>(data.right_turntable_cw * turntable_multiplier, 0x7F)); right_turntable += static_cast<u8>(std::min<int>(data.right_turntable_cw, 0x7F));
} }
buf[3] = 0x80; buf[3] = 0x80;
buf[4] = 0x80; buf[4] = 0x80;
@ -369,19 +369,19 @@ namespace usb_pad
break; break;
case CID_DJ_LEFT_TURNTABLE_CW: case CID_DJ_LEFT_TURNTABLE_CW:
s->data.left_turntable_cw = static_cast<u32>(std::clamp<long>(std::lroundf(value * 128.0f), 0, 128)); s->data.left_turntable_cw = static_cast<u32>(std::clamp<long>(std::lroundf(value * s->turntable_multiplier * 128.0f), 0, 128));
break; break;
case CID_DJ_LEFT_TURNTABLE_CCW: case CID_DJ_LEFT_TURNTABLE_CCW:
s->data.left_turntable_ccw = static_cast<u32>(std::clamp<long>(std::lroundf(value * 128.0f), 0, 128)); s->data.left_turntable_ccw = static_cast<u32>(std::clamp<long>(std::lroundf(value * s->turntable_multiplier * 128.0f), 0, 128));
break; break;
case CID_DJ_RIGHT_TURNTABLE_CW: case CID_DJ_RIGHT_TURNTABLE_CW:
s->data.right_turntable_cw = static_cast<u32>(std::clamp<long>(std::lroundf(value * 128.0f), 0, 128)); s->data.right_turntable_cw = static_cast<u32>(std::clamp<long>(std::lroundf(value * s->turntable_multiplier * 128.0f), 0, 128));
break; break;
case CID_DJ_RIGHT_TURNTABLE_CCW: case CID_DJ_RIGHT_TURNTABLE_CCW:
s->data.right_turntable_ccw = static_cast<u32>(std::clamp<long>(std::lroundf(value * 128.0f), 0, 128)); s->data.right_turntable_ccw = static_cast<u32>(std::clamp<long>(std::lroundf(value * s->turntable_multiplier * 128.0f), 0, 128));
break; break;
case CID_DJ_DPAD_UP: case CID_DJ_DPAD_UP:
@ -446,8 +446,8 @@ namespace usb_pad
{"EffectsKnobRight", TRANSLATE_NOOP("USB", "Effects Knob Right"), nullptr, InputBindingInfo::Type::HalfAxis, CID_DJ_EFFECTSKNOB_RIGHT, GenericInputBinding::RightStickRight}, {"EffectsKnobRight", TRANSLATE_NOOP("USB", "Effects Knob Right"), nullptr, InputBindingInfo::Type::HalfAxis, CID_DJ_EFFECTSKNOB_RIGHT, GenericInputBinding::RightStickRight},
{"LeftTurntableCW", TRANSLATE_NOOP("USB", "Left Turntable Clockwise"), nullptr, InputBindingInfo::Type::HalfAxis, CID_DJ_LEFT_TURNTABLE_CW, GenericInputBinding::LeftStickRight}, {"LeftTurntableCW", TRANSLATE_NOOP("USB", "Left Turntable Clockwise"), nullptr, InputBindingInfo::Type::HalfAxis, CID_DJ_LEFT_TURNTABLE_CW, GenericInputBinding::LeftStickRight},
{"LeftTurntableCCW", TRANSLATE_NOOP("USB", "Left Turntable Counterclockwise"), nullptr, InputBindingInfo::Type::HalfAxis, CID_DJ_LEFT_TURNTABLE_CCW, GenericInputBinding::LeftStickLeft}, {"LeftTurntableCCW", TRANSLATE_NOOP("USB", "Left Turntable Counterclockwise"), nullptr, InputBindingInfo::Type::HalfAxis, CID_DJ_LEFT_TURNTABLE_CCW, GenericInputBinding::LeftStickLeft},
{"RightTurntableCW", TRANSLATE_NOOP("USB", "Right Turntable Clockwise"), nullptr, InputBindingInfo::Type::HalfAxis, CID_DJ_RIGHT_TURNTABLE_CW, GenericInputBinding::LeftStickDown}, {"RightTurntableCW", TRANSLATE_NOOP("USB", "Right Turntable Clockwise"), nullptr, InputBindingInfo::Type::HalfAxis, CID_DJ_RIGHT_TURNTABLE_CW, GenericInputBinding::LeftStickUp},
{"RightTurntableCCW", TRANSLATE_NOOP("USB", "Right Turntable Counterclockwise"), nullptr, InputBindingInfo::Type::HalfAxis, CID_DJ_RIGHT_TURNTABLE_CCW, GenericInputBinding::LeftStickUp}, {"RightTurntableCCW", TRANSLATE_NOOP("USB", "Right Turntable Counterclockwise"), nullptr, InputBindingInfo::Type::HalfAxis, CID_DJ_RIGHT_TURNTABLE_CCW, GenericInputBinding::LeftStickDown},
{"LeftTurntableGreen", TRANSLATE_NOOP("USB", "Left Turntable Green"), nullptr, InputBindingInfo::Type::Button, CID_DJ_LEFT_GREEN, GenericInputBinding::Unknown}, {"LeftTurntableGreen", TRANSLATE_NOOP("USB", "Left Turntable Green"), nullptr, InputBindingInfo::Type::Button, CID_DJ_LEFT_GREEN, GenericInputBinding::Unknown},
{"LeftTurntableRed", TRANSLATE_NOOP("USB", "Left Turntable Red"), nullptr, InputBindingInfo::Type::Button, CID_DJ_LEFT_RED, GenericInputBinding::Unknown}, {"LeftTurntableRed", TRANSLATE_NOOP("USB", "Left Turntable Red"), nullptr, InputBindingInfo::Type::Button, CID_DJ_LEFT_RED, GenericInputBinding::Unknown},
{"LeftTurntableBlue", TRANSLATE_NOOP("USB", "Left Turntable Blue"), nullptr, InputBindingInfo::Type::Button, CID_DJ_LEFT_BLUE, GenericInputBinding::Unknown}, {"LeftTurntableBlue", TRANSLATE_NOOP("USB", "Left Turntable Blue"), nullptr, InputBindingInfo::Type::Button, CID_DJ_LEFT_BLUE, GenericInputBinding::Unknown},
@ -464,8 +464,8 @@ namespace usb_pad
{ {
static constexpr const SettingInfo info[] = { static constexpr const SettingInfo info[] = {
{SettingInfo::Type::Float, "TurntableMultiplier", TRANSLATE_NOOP("USB", "Turntable Multiplier"), {SettingInfo::Type::Float, "TurntableMultiplier", TRANSLATE_NOOP("USB", "Turntable Multiplier"),
TRANSLATE_NOOP("USB", "Apply a multiplier to the turntable"), TRANSLATE_NOOP("USB", "Apply a sensitivity multiplier to turntable rotation.\nXbox 360 turntables require a 256x multiplier, most other turntables can use the default 1x multiplier."),
"1.00", "0.00", "100.0", "1.0", "%.0fx", nullptr, nullptr, 1.0f}}; "1.00", "0.00", "512.0", "1.0", "%.0fx", nullptr, nullptr, 1.0f}};
return info; return info;
} }

View File

@ -1595,6 +1595,14 @@ static void iopRecRecompile(const u32 startpc)
while (1) while (1)
{ {
BASEBLOCK* pblock = PSX_GETBLOCK(i);
if (i != startpc && pblock->GetFnptr() != (uptr)iopJITCompile)
{
// branch = 3
willbranch3 = 1;
s_nEndBlock = i;
break;
}
psxRegs.code = iopMemRead32(i); psxRegs.code = iopMemRead32(i);

View File

@ -2294,6 +2294,8 @@ static void recRecompile(const u32 startpc)
while (1) while (1)
{ {
BASEBLOCK* pblock = PC_GETBLOCK(i);
// stop before breakpoints // stop before breakpoints
if (isBreakpointNeeded(i) != 0 || isMemcheckNeeded(i) != 0) if (isBreakpointNeeded(i) != 0 || isMemcheckNeeded(i) != 0)
{ {
@ -2311,6 +2313,13 @@ static void recRecompile(const u32 startpc)
eeRecPerfLog.Write("Pagesplit @ %08X : size=%d insts", startpc, (i - startpc) / 4); eeRecPerfLog.Write("Pagesplit @ %08X : size=%d insts", startpc, (i - startpc) / 4);
break; break;
} }
if (pblock->GetFnptr() != (uptr)JITCompile)
{
willbranch3 = 1;
s_nEndBlock = i;
break;
}
} }
//HUH ? PSM ? whut ? THIS IS VIRTUAL ACCESS GOD DAMMIT //HUH ? PSM ? whut ? THIS IS VIRTUAL ACCESS GOD DAMMIT
@ -2614,6 +2623,34 @@ StartRecomp:
pxAssert((pc - startpc) >> 2 <= 0xffff); pxAssert((pc - startpc) >> 2 <= 0xffff);
s_pCurBlockEx->size = (pc - startpc) >> 2; s_pCurBlockEx->size = (pc - startpc) >> 2;
if (HWADDR(pc) <= Ps2MemSize::ExposedRam)
{
BASEBLOCKEX* oldBlock;
int i;
i = recBlocks.LastIndex(HWADDR(pc) - 4);
while ((oldBlock = recBlocks[i--]))
{
if (oldBlock == s_pCurBlockEx)
continue;
if (oldBlock->startpc >= HWADDR(pc))
continue;
if ((oldBlock->startpc + oldBlock->size * 4) <= HWADDR(startpc))
break;
if (memcmp(&recRAMCopy[oldBlock->startpc / 4], PSM(oldBlock->startpc),
oldBlock->size * 4))
{
recClear(startpc, (pc - startpc) / 4);
s_pCurBlockEx = recBlocks.Get(HWADDR(startpc));
pxAssert(s_pCurBlockEx->startpc == HWADDR(startpc));
break;
}
}
memcpy(&recRAMCopy[HWADDR(startpc) / 4], PSM(startpc), pc - startpc);
}
s_pCurBlock->SetFnptr((uptr)recPtr); s_pCurBlock->SetFnptr((uptr)recPtr);
if (!(pc & 0x10000000)) if (!(pc & 0x10000000))