2010-04-25 00:31:27 +00:00
|
|
|
/*
|
2009-02-09 21:15:56 +00:00
|
|
|
* Copyright (C) 2007-2009 Gabest
|
|
|
|
* http://www.gabest.org
|
|
|
|
*
|
|
|
|
* This Program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
* any later version.
|
2010-04-25 00:31:27 +00:00
|
|
|
*
|
2009-02-09 21:15:56 +00:00
|
|
|
* This Program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2010-04-25 00:31:27 +00:00
|
|
|
*
|
2009-02-09 21:15:56 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with GNU Make; see the file COPYING. If not, write to
|
2012-09-09 18:16:11 +00:00
|
|
|
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA USA.
|
2009-02-09 21:15:56 +00:00
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2019-02-11 16:43:59 +00:00
|
|
|
#include "GSTextureCache.h"
|
2018-11-16 18:41:37 +00:00
|
|
|
#include "Renderers/Common/GSFunctionMap.h"
|
2015-05-13 18:00:25 +00:00
|
|
|
#include "GSState.h"
|
2009-07-12 13:46:05 +00:00
|
|
|
|
2012-01-05 02:40:24 +00:00
|
|
|
class GSRendererHW : public GSRenderer
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
2011-11-08 13:22:54 +00:00
|
|
|
private:
|
|
|
|
int m_width;
|
|
|
|
int m_height;
|
2016-06-26 06:03:16 +00:00
|
|
|
int m_custom_width;
|
|
|
|
int m_custom_height;
|
2011-11-08 13:22:54 +00:00
|
|
|
bool m_reset;
|
|
|
|
int m_upscale_multiplier;
|
2015-04-03 16:11:47 +00:00
|
|
|
|
2016-05-23 17:27:13 +00:00
|
|
|
bool m_large_framebuffer;
|
2019-04-22 20:57:39 +00:00
|
|
|
bool m_disable_ts_half_bottom;
|
2015-04-03 19:02:25 +00:00
|
|
|
bool m_userhacks_align_sprite_X;
|
2018-12-31 00:20:16 +00:00
|
|
|
bool m_userhacks_enabled_gs_mem_clear;
|
2017-03-18 13:19:48 +00:00
|
|
|
bool m_userHacks_merge_sprite;
|
2015-04-03 19:02:25 +00:00
|
|
|
|
2009-07-12 13:46:05 +00:00
|
|
|
#pragma region hacks
|
|
|
|
|
2009-07-22 14:28:14 +00:00
|
|
|
typedef bool (GSRendererHW::*OI_Ptr)(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* t);
|
2009-07-12 13:46:05 +00:00
|
|
|
typedef void (GSRendererHW::*OO_Ptr)();
|
|
|
|
typedef bool (GSRendererHW::*CU_Ptr)();
|
|
|
|
|
2016-03-19 12:35:23 +00:00
|
|
|
// Require special argument
|
2016-03-19 10:43:27 +00:00
|
|
|
bool OI_BlitFMV(GSTextureCache::Target* _rt, GSTextureCache::Source* t, const GSVector4i& r_draw);
|
2016-03-19 12:35:23 +00:00
|
|
|
void OI_GsMemClear(); // always on
|
2016-09-20 16:57:07 +00:00
|
|
|
void OI_DoubleHalfClear(GSTexture* rt, GSTexture* ds); // always on
|
2016-03-19 12:35:23 +00:00
|
|
|
|
2019-07-19 16:06:40 +00:00
|
|
|
bool OI_BigMuthaTruckers(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* t);
|
2012-01-05 02:40:24 +00:00
|
|
|
bool OI_FFXII(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* t);
|
|
|
|
bool OI_FFX(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* t);
|
|
|
|
bool OI_MetalSlug6(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* t);
|
|
|
|
bool OI_RozenMaidenGebetGarden(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* t);
|
2019-05-14 20:17:23 +00:00
|
|
|
bool OI_SonicUnleashed(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* t);
|
2012-01-05 02:40:24 +00:00
|
|
|
bool OI_StarWarsForceUnleashed(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* t);
|
|
|
|
bool OI_PointListPalette(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* t);
|
2015-07-05 15:32:57 +00:00
|
|
|
bool OI_SuperManReturns(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* t);
|
2016-05-16 08:55:02 +00:00
|
|
|
bool OI_ArTonelico2(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* t);
|
2016-09-04 17:41:31 +00:00
|
|
|
bool OI_ItadakiStreet(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* t);
|
2019-07-12 23:05:27 +00:00
|
|
|
bool OI_JakGames(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* t);
|
2016-09-04 17:41:31 +00:00
|
|
|
|
2012-01-05 02:40:24 +00:00
|
|
|
void OO_DBZBT2();
|
|
|
|
void OO_MajokkoALaMode2();
|
|
|
|
|
|
|
|
bool CU_DBZBT2();
|
|
|
|
bool CU_MajokkoALaMode2();
|
|
|
|
bool CU_TalesOfAbyss();
|
2009-07-12 13:46:05 +00:00
|
|
|
|
|
|
|
class Hacks
|
|
|
|
{
|
2011-11-08 13:12:54 +00:00
|
|
|
template<class T> class HackEntry
|
2009-07-12 13:46:05 +00:00
|
|
|
{
|
2011-11-08 13:12:54 +00:00
|
|
|
public:
|
2010-04-25 00:31:27 +00:00
|
|
|
CRC::Title title;
|
|
|
|
CRC::Region region;
|
2009-07-12 13:46:05 +00:00
|
|
|
T func;
|
|
|
|
|
2011-11-08 13:12:54 +00:00
|
|
|
HackEntry(CRC::Title t, CRC::Region r, T f)
|
2009-07-12 13:46:05 +00:00
|
|
|
{
|
|
|
|
title = t;
|
|
|
|
region = r;
|
|
|
|
func = f;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
template<class T> class FunctionMap : public GSFunctionMap<uint32, T>
|
2009-07-12 13:46:05 +00:00
|
|
|
{
|
2017-05-26 16:07:00 +00:00
|
|
|
std::list<HackEntry<T> >& m_tbl;
|
2009-07-12 13:46:05 +00:00
|
|
|
|
|
|
|
T GetDefaultFunction(uint32 key)
|
|
|
|
{
|
|
|
|
CRC::Title title = (CRC::Title)(key & 0xffffff);
|
|
|
|
CRC::Region region = (CRC::Region)(key >> 24);
|
|
|
|
|
2017-05-26 16:07:00 +00:00
|
|
|
for(const auto &entry : m_tbl)
|
2009-07-12 13:46:05 +00:00
|
|
|
{
|
2017-05-26 16:07:00 +00:00
|
|
|
if(entry.title == title && (entry.region == CRC::RegionCount || entry.region == region))
|
2009-07-12 13:46:05 +00:00
|
|
|
{
|
2017-05-26 16:07:00 +00:00
|
|
|
return entry.func;
|
2009-07-12 13:46:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2017-05-26 16:07:00 +00:00
|
|
|
FunctionMap(std::list<HackEntry<T> >& tbl) : m_tbl(tbl) {}
|
2009-07-12 13:46:05 +00:00
|
|
|
};
|
|
|
|
|
2017-05-26 16:07:00 +00:00
|
|
|
std::list<HackEntry<OI_Ptr> > m_oi_list;
|
|
|
|
std::list<HackEntry<OO_Ptr> > m_oo_list;
|
|
|
|
std::list<HackEntry<CU_Ptr> > m_cu_list;
|
2009-07-12 13:46:05 +00:00
|
|
|
|
|
|
|
FunctionMap<OI_Ptr> m_oi_map;
|
|
|
|
FunctionMap<OO_Ptr> m_oo_map;
|
|
|
|
FunctionMap<CU_Ptr> m_cu_map;
|
|
|
|
|
|
|
|
public:
|
|
|
|
OI_Ptr m_oi;
|
|
|
|
OO_Ptr m_oo;
|
|
|
|
CU_Ptr m_cu;
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2012-01-05 02:40:24 +00:00
|
|
|
Hacks();
|
2009-07-12 13:46:05 +00:00
|
|
|
|
2012-01-05 02:40:24 +00:00
|
|
|
void SetGameCRC(const CRC::Game& game);
|
2009-07-12 13:46:05 +00:00
|
|
|
|
|
|
|
} m_hacks;
|
|
|
|
|
2015-04-12 10:24:07 +00:00
|
|
|
#pragma endregion
|
|
|
|
|
2016-04-14 10:00:58 +00:00
|
|
|
uint16 Interpolate_UV(float alpha, int t0, int t1);
|
2015-04-12 15:10:45 +00:00
|
|
|
float alpha0(int L, int X0, int X1);
|
|
|
|
float alpha1(int L, int X0, int X1);
|
2019-07-12 23:05:27 +00:00
|
|
|
void SwSpriteRender();
|
2015-04-09 17:51:50 +00:00
|
|
|
|
2015-04-12 10:24:07 +00:00
|
|
|
template <bool linear> void RoundSpriteOffset();
|
2009-07-12 13:46:05 +00:00
|
|
|
|
2009-02-09 21:15:56 +00:00
|
|
|
protected:
|
2009-05-22 01:22:52 +00:00
|
|
|
GSTextureCache* m_tc;
|
2019-04-22 11:28:34 +00:00
|
|
|
GSVector4i m_r;
|
2019-04-24 12:27:59 +00:00
|
|
|
GSTextureCache::Source* m_src;
|
2009-05-22 01:22:52 +00:00
|
|
|
|
2012-01-05 02:40:24 +00:00
|
|
|
virtual void DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* tex) = 0;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2015-04-09 17:51:50 +00:00
|
|
|
int m_userhacks_round_sprite_offset;
|
2017-02-17 09:59:21 +00:00
|
|
|
int m_userHacks_HPO;
|
2018-12-31 00:20:16 +00:00
|
|
|
bool m_userHacks_enabled_unscale_ptln;
|
2015-04-03 16:11:47 +00:00
|
|
|
|
2018-09-10 20:13:34 +00:00
|
|
|
bool m_userhacks_tcoffset;
|
2018-09-10 16:22:27 +00:00
|
|
|
float m_userhacks_tcoffset_x;
|
|
|
|
float m_userhacks_tcoffset_y;
|
|
|
|
|
2018-11-28 19:33:15 +00:00
|
|
|
int m_accurate_date;
|
2019-04-17 20:14:17 +00:00
|
|
|
int m_sw_blending;
|
2018-11-28 19:33:15 +00:00
|
|
|
|
2016-04-28 17:39:57 +00:00
|
|
|
bool m_channel_shuffle;
|
|
|
|
|
2016-10-01 15:37:55 +00:00
|
|
|
GSVector2i m_lod; // Min & Max level of detail
|
2017-05-19 17:57:17 +00:00
|
|
|
void CustomResolutionScaling();
|
2016-10-01 15:37:55 +00:00
|
|
|
|
2009-02-09 21:15:56 +00:00
|
|
|
public:
|
2012-01-19 04:53:36 +00:00
|
|
|
GSRendererHW(GSTextureCache* tc);
|
2012-01-05 02:40:24 +00:00
|
|
|
virtual ~GSRendererHW();
|
|
|
|
|
|
|
|
void SetGameCRC(uint32 crc, int options);
|
|
|
|
bool CanUpscale();
|
|
|
|
int GetUpscaleMultiplier();
|
2016-06-26 06:03:16 +00:00
|
|
|
GSVector2i GetCustomResolution();
|
2015-05-13 18:00:25 +00:00
|
|
|
void SetScaling();
|
2017-03-03 21:18:49 +00:00
|
|
|
void Lines2Sprites();
|
2019-02-21 12:10:41 +00:00
|
|
|
void ConvertSpriteTextureShuffle(bool& write_ba, bool& read_ba);
|
2017-03-18 13:19:48 +00:00
|
|
|
GSVector4 RealignTargetTextureCoordinate(const GSTextureCache::Source* tex);
|
2019-01-12 06:37:37 +00:00
|
|
|
GSVector4i ComputeBoundingBox(const GSVector2& rtscale, const GSVector2i& rtsize);
|
2017-03-18 13:19:48 +00:00
|
|
|
void MergeSprite(GSTextureCache::Source* tex);
|
2012-01-05 02:40:24 +00:00
|
|
|
|
|
|
|
void Reset();
|
|
|
|
void VSync(int field);
|
|
|
|
void ResetDevice();
|
2016-03-19 11:37:25 +00:00
|
|
|
GSTexture* GetOutput(int i, int& y_offset);
|
2016-10-09 12:46:55 +00:00
|
|
|
GSTexture* GetFeedbackOutput();
|
2012-01-05 02:40:24 +00:00
|
|
|
void InvalidateVideoMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r);
|
|
|
|
void InvalidateLocalMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r, bool clut = false);
|
|
|
|
void Draw();
|
2019-04-10 10:21:21 +00:00
|
|
|
|
|
|
|
// Called by the texture cache to know if current texture is useful
|
|
|
|
virtual bool IsDummyTexture() const { return false;}
|
2010-04-25 00:31:27 +00:00
|
|
|
};
|