From f35e0858596befca2cfec668b2c441cd31d608bd Mon Sep 17 00:00:00 2001 From: Tony Wasserka Date: Tue, 23 Jul 2013 22:21:38 +0200 Subject: [PATCH] softgpu: Change framebuffer writes to act on actual 16 bit pixels if that's the framebuffer format. --- GPU/Software/Rasterizer.cpp | 15 +++++++-------- GPU/Software/SoftGpu.cpp | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/GPU/Software/Rasterizer.cpp b/GPU/Software/Rasterizer.cpp index 691f424dc3..52bd84bb28 100644 --- a/GPU/Software/Rasterizer.cpp +++ b/GPU/Software/Rasterizer.cpp @@ -183,13 +183,13 @@ static inline u32 GetPixelColor(int x, int y) { switch (gstate.FrameBufFormat()) { case GE_FORMAT_565: - return DecodeRGB565(*(u16*)&fb[4*x + 4*y*gstate.FrameBufStride()]); + return DecodeRGB565(*(u16*)&fb[2*x + 2*y*gstate.FrameBufStride()]); case GE_FORMAT_5551: - return DecodeRGBA5551(*(u16*)&fb[4*x + 4*y*gstate.FrameBufStride()]); + return DecodeRGBA5551(*(u16*)&fb[2*x + 2*y*gstate.FrameBufStride()]); case GE_FORMAT_4444: - return DecodeRGBA4444(*(u16*)&fb[4*x + 4*y*gstate.FrameBufStride()]); + return DecodeRGBA4444(*(u16*)&fb[2*x + 2*y*gstate.FrameBufStride()]); case GE_FORMAT_8888: return *(u32*)&fb[4*x + 4*y*gstate.FrameBufStride()]; @@ -201,15 +201,15 @@ static inline void SetPixelColor(int x, int y, u32 value) { switch (gstate.FrameBufFormat()) { case GE_FORMAT_565: - *(u16*)&fb[4*x + 4*y*gstate.FrameBufStride()] = RGBA8888To565(value); + *(u16*)&fb[2*x + 2*y*gstate.FrameBufStride()] = RGBA8888To565(value); break; case GE_FORMAT_5551: - *(u16*)&fb[4*x + 4*y*gstate.FrameBufStride()] = RGBA8888To5551(value); + *(u16*)&fb[2*x + 2*y*gstate.FrameBufStride()] = RGBA8888To5551(value); break; case GE_FORMAT_4444: - *(u16*)&fb[4*x + 4*y*gstate.FrameBufStride()] = RGBA8888To4444(value); + *(u16*)&fb[2*x + 2*y*gstate.FrameBufStride()] = RGBA8888To4444(value); break; case GE_FORMAT_8888: @@ -561,9 +561,8 @@ void DrawTriangle(const VertexData& v0, const VertexData& v1, const VertexData& if (gstate.isDepthWriteEnabled() || ((gstate.clearmode&0x40) && gstate.isModeClear())) SetPixelDepth(p.x, p.y, z); } - - Vec4 dst = Vec4::FromRGBA(GetPixelColor(p.x, p.y)); if (gstate.isAlphaBlendEnabled() && !gstate.isModeClear()) { + Vec4 dst = Vec4::FromRGBA(GetPixelColor(p.x, p.y)); Vec3 srccol(0, 0, 0); Vec3 dstcol(0, 0, 0); diff --git a/GPU/Software/SoftGpu.cpp b/GPU/Software/SoftGpu.cpp index 39d53f4b4a..e21957ff86 100644 --- a/GPU/Software/SoftGpu.cpp +++ b/GPU/Software/SoftGpu.cpp @@ -165,7 +165,7 @@ void CopyToCurrentFboFromRam(u8* data, int srcwidth, int srcheight, int dstwidth u32* buf = new u32[srcwidth*srcheight]; for (int y = 0; y < srcheight; ++y) { for (int x = 0; x < srcwidth; ++x) { - u16 src = *(u16*)&fb[4*x + 4*y*gstate.FrameBufStride()]; + u16 src = *(u16*)&fb[2*x + 2*y*gstate.FrameBufStride()]; if (gstate.FrameBufFormat() == GE_FORMAT_565) buf[x+y*srcwidth] = DecodeRGB565(src);