mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2024-05-20 05:10:27 -04:00
Compare commits
50 commits
49b3b916fd
...
d27ceec6fe
Author | SHA1 | Date | |
---|---|---|---|
d27ceec6fe | |||
1670c806f1 | |||
ea95460816 | |||
44e333af48 | |||
d4a02306bc | |||
e04644b3d2 | |||
ba451574ee | |||
0d3ca9fde1 | |||
a70887b553 | |||
4819602492 | |||
ee5fcf8edb | |||
04a2713e0b | |||
d2a1f9715a | |||
17ba3d1da0 | |||
420e91426a | |||
dbc6b76287 | |||
b7825b303f | |||
8a95377406 | |||
6acefec43c | |||
4648cd2219 | |||
07b3321b25 | |||
d25229d495 | |||
0d0b6534f4 | |||
a47c473738 | |||
f400e43d7f | |||
599d7eedbc | |||
c393d594a2 | |||
eaa4443c24 | |||
ba91493ffd | |||
c8fcdcdffd | |||
7ab97038a9 | |||
61682582c5 | |||
bd2e65668a | |||
514d48fea9 | |||
1a1dbdf85f | |||
fa7c4db7bd | |||
11b0ad2d7f | |||
f71f60dc4c | |||
e68009f583 | |||
ff5e823df2 | |||
80240d16e5 | |||
601c27af0c | |||
ffa6c50883 | |||
fe683c1250 | |||
a03aec13c1 | |||
cf0c697065 | |||
0ed21a68c7 | |||
1699dbec34 | |||
3890dd0165 | |||
cc9baf0bc1 |
|
@ -3173,4 +3173,9 @@ void DSi::ARM7IOWrite32(u32 addr, u32 val)
|
|||
return NDS::ARM7IOWrite32(addr, val);
|
||||
}
|
||||
|
||||
bool DSi::GetSCFGRasterBit() const
|
||||
{
|
||||
return SCFG_EXT[0] & (1<<2);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -129,6 +129,8 @@ public:
|
|||
void ARM7IOWrite16(u32 addr, u16 val) override;
|
||||
void ARM7IOWrite32(u32 addr, u32 val) override;
|
||||
|
||||
bool GetSCFGRasterBit() const override;
|
||||
|
||||
public:
|
||||
DSi(DSiArgs&& args) noexcept;
|
||||
~DSi() noexcept override;
|
||||
|
|
|
@ -182,6 +182,8 @@ void GPU3D::ResetRenderingState() noexcept
|
|||
|
||||
RenderClearAttr1 = 0x3F000000;
|
||||
RenderClearAttr2 = 0x00007FFF;
|
||||
|
||||
RenderRasterRev = false; // CHECKME: when should this be reset?
|
||||
}
|
||||
|
||||
void GPU3D::Reset() noexcept
|
||||
|
@ -354,6 +356,8 @@ void GPU3D::DoSavestate(Savestate* file) noexcept
|
|||
|
||||
file->Var32(&RenderClearAttr1);
|
||||
file->Var32(&RenderClearAttr2);
|
||||
|
||||
file->Bool32(&RenderRasterRev);
|
||||
|
||||
file->Var16(&RenderXPos);
|
||||
|
||||
|
@ -553,6 +557,7 @@ void GPU3D::DoSavestate(Savestate* file) noexcept
|
|||
file->Var32(&TexParam);
|
||||
file->Var32(&TexPalette);
|
||||
RenderFrameIdentical = false;
|
||||
ForceRerender = false;
|
||||
if (softRenderer && softRenderer->IsThreaded())
|
||||
{
|
||||
softRenderer->EnableRenderThread();
|
||||
|
@ -1216,7 +1221,7 @@ void GPU3D::SubmitPolygon() noexcept
|
|||
|
||||
u32 texfmt = (TexParam >> 26) & 0x7;
|
||||
u32 polyalpha = (CurPolygonAttr >> 16) & 0x1F;
|
||||
poly->Translucent = ((texfmt == 1 || texfmt == 6) && !(CurPolygonAttr & 0x10)) || (polyalpha > 0 && polyalpha < 31);
|
||||
poly->Translucent = (texfmt == 1 || texfmt == 6) || (polyalpha > 0 && polyalpha < 31);
|
||||
|
||||
poly->IsShadowMask = ((CurPolygonAttr & 0x3F000030) == 0x00000030);
|
||||
poly->IsShadow = ((CurPolygonAttr & 0x30) == 0x30) && !poly->IsShadowMask;
|
||||
|
@ -2459,18 +2464,30 @@ void GPU3D::VBlank() noexcept
|
|||
|
||||
RenderNumPolygons = NumPolygons;
|
||||
RenderFrameIdentical = false;
|
||||
ForceRerender = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderFrameIdentical = RenderDispCnt == DispCnt
|
||||
&& RenderAlphaRef == AlphaRef
|
||||
&& RenderClearAttr1 == ClearAttr1
|
||||
&& RenderClearAttr2 == ClearAttr2
|
||||
&& RenderFogColor == FogColor
|
||||
&& RenderFogOffset == FogOffset * 0x200
|
||||
&& memcmp(RenderEdgeTable, EdgeTable, 8*2) == 0
|
||||
&& memcmp(RenderFogDensityTable + 1, FogDensityTable, 32) == 0
|
||||
&& memcmp(RenderToonTable, ToonTable, 32*2) == 0;
|
||||
|
||||
if (ForceRerender == true)
|
||||
{
|
||||
RenderFrameIdentical = false;
|
||||
ForceRerender = false;
|
||||
DontRerenderLoop = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderFrameIdentical = RenderDispCnt == DispCnt
|
||||
&& RenderAlphaRef == AlphaRef
|
||||
&& RenderClearAttr1 == ClearAttr1
|
||||
&& RenderClearAttr2 == ClearAttr2
|
||||
&& RenderFogColor == FogColor
|
||||
&& RenderFogOffset == FogOffset * 0x200
|
||||
&& memcmp(RenderEdgeTable, EdgeTable, 8*2) == 0
|
||||
&& memcmp(RenderFogDensityTable + 1, FogDensityTable, 32) == 0
|
||||
&& memcmp(RenderToonTable, ToonTable, 32*2) == 0
|
||||
&& RenderRasterRev == NDS.GetSCFGRasterBit();
|
||||
}
|
||||
}
|
||||
|
||||
RenderDispCnt = DispCnt;
|
||||
|
@ -2488,6 +2505,9 @@ void GPU3D::VBlank() noexcept
|
|||
|
||||
RenderClearAttr1 = ClearAttr1;
|
||||
RenderClearAttr2 = ClearAttr2;
|
||||
// NOTE: this is not latched. it updates the *moment* you set it. it does not cancel the current scanline. it just causes pain and suffering.
|
||||
// in less dramatic terms: annoying to emulate properly, so we're just gonna pretend it's latched for now, ok?
|
||||
RenderRasterRev = NDS.GetSCFGRasterBit();
|
||||
}
|
||||
|
||||
if (FlushRequest)
|
||||
|
|
|
@ -271,6 +271,8 @@ public:
|
|||
u32 RenderClearAttr1 = 0;
|
||||
u32 RenderClearAttr2 = 0;
|
||||
|
||||
bool RenderRasterRev = false;
|
||||
|
||||
bool RenderFrameIdentical = false; // not part of the hardware state, don't serialize
|
||||
|
||||
bool AbortFrame = false;
|
||||
|
@ -323,6 +325,10 @@ public:
|
|||
std::array<Polygon*,2048> RenderPolygonRAM {};
|
||||
u32 RenderNumPolygons = 0;
|
||||
|
||||
// used to fix stencil buffer's frame-to-frame persistence not working properly under extreme misuse of shadow masks/shadows
|
||||
bool ForceRerender = false;
|
||||
bool DontRerenderLoop = false;
|
||||
|
||||
u32 FlushRequest = 0;
|
||||
u32 FlushAttributes = 0;
|
||||
u32 ScrolledLine[256]; // not part of the hardware state, don't serialize
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -26,6 +26,18 @@
|
|||
|
||||
namespace melonDS
|
||||
{
|
||||
|
||||
enum EdgeFlags
|
||||
{
|
||||
EF_None = (0),
|
||||
EF_AnyEdge = (0xF),
|
||||
|
||||
EF_TopXMajor = (1<<0),
|
||||
EF_BotXMajor = (1<<1),
|
||||
EF_LYMajor = (1<<2),
|
||||
EF_RYMajor = (1<<3),
|
||||
};
|
||||
|
||||
class SoftRenderer : public Renderer3D
|
||||
{
|
||||
public:
|
||||
|
@ -455,19 +467,20 @@ private:
|
|||
};
|
||||
|
||||
RendererPolygon PolygonList[2048];
|
||||
void TextureLookup(const GPU& gpu, u32 texparam, u32 texpal, s16 s, s16 t, u16* color, u8* alpha) const;
|
||||
template <bool colorcorrect> inline void ColorConv(const u16 color, u8* r, u8* g, u8* b) const;
|
||||
void TextureLookup(const GPU& gpu, u32 texparam, u32 texpal, s16 s, s16 t, u8* tr, u8* tg, u8* tb, u8* alpha) const;
|
||||
u32 RenderPixel(const GPU& gpu, const Polygon* polygon, u8 vr, u8 vg, u8 vb, s16 s, s16 t) const;
|
||||
void PlotTranslucentPixel(const GPU3D& gpu3d, u32 pixeladdr, u32 color, u32 z, u32 polyattr, u32 shadow);
|
||||
void SetupPolygonLeftEdge(RendererPolygon* rp, s32 y) const;
|
||||
void SetupPolygonRightEdge(RendererPolygon* rp, s32 y) const;
|
||||
void SetupPolygon(RendererPolygon* rp, Polygon* polygon) const;
|
||||
void RenderShadowMaskScanline(const GPU3D& gpu3d, RendererPolygon* rp, s32 y);
|
||||
void RenderPolygonScanline(const GPU& gpu, RendererPolygon* rp, s32 y);
|
||||
void RenderScanline(const GPU& gpu, s32 y, int npolys);
|
||||
void RenderPolygonScanline(GPU& gpu, RendererPolygon* rp, s32 y);
|
||||
void RenderScanline(GPU& gpu, s32 y, int npolys);
|
||||
u32 CalculateFogDensity(const GPU3D& gpu3d, u32 pixeladdr) const;
|
||||
void ScanlineFinalPass(const GPU3D& gpu3d, s32 y);
|
||||
void ClearBuffers(const GPU& gpu);
|
||||
void RenderPolygons(const GPU& gpu, bool threaded, Polygon** polygons, int npolys);
|
||||
void RenderPolygons(GPU& gpu, bool threaded, Polygon** polygons, int npolys);
|
||||
|
||||
void RenderThreadFunc(GPU& gpu);
|
||||
|
||||
|
@ -487,7 +500,7 @@ private:
|
|||
u32 AttrBuffer[BufferSize * 2];
|
||||
|
||||
// attribute buffer:
|
||||
// bit0-3: edge flags (left/right/top/bottom)
|
||||
// bit0-3: edge flags (top xmajor/bottom xmajor/left ymajor/right ymajor)
|
||||
// bit4: backfacing flag
|
||||
// bit8-12: antialiasing alpha
|
||||
// bit15: fog enable
|
||||
|
@ -496,7 +509,8 @@ private:
|
|||
// bit24-29: polygon ID for opaque pixels
|
||||
|
||||
u8 StencilBuffer[256*2];
|
||||
bool PrevIsShadowMask;
|
||||
bool ShadowRendered[2];
|
||||
bool StencilCleared;
|
||||
|
||||
bool Enabled;
|
||||
|
||||
|
|
|
@ -4334,4 +4334,9 @@ void NDS::ARM7IOWrite32(u32 addr, u32 val)
|
|||
Log(LogLevel::Debug, "unknown ARM7 IO write32 %08X %08X %08X\n", addr, val, ARM7.R[15]);
|
||||
}
|
||||
|
||||
bool NDS::GetSCFGRasterBit() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue