Skip to content
Permalink
Browse files
Merge pull request #450 from fzurita/GLideN64Update
video-gliden64: Update to commit 57e88cb.
  • Loading branch information
littleguy77 committed Aug 21, 2015
2 parents 2214151 + 31cf0f8 commit b8bc8a9
Show file tree
Hide file tree
Showing 25 changed files with 723 additions and 653 deletions.
@@ -33,11 +33,6 @@ EXPORT void CALL RomClosed (void)
api().RomClosed();
}

EXPORT void CALL RomOpen (void)
{
api().RomOpen();
}

EXPORT void CALL ShowCFB (void)
{
api().ShowCFB();
@@ -35,6 +35,11 @@ void Config::resetToDefaults()
generalEmulation.enableHWLighting = 0;
generalEmulation.enableCustomSettings = 1;
generalEmulation.hacks = 0;
#ifdef ANDROID
generalEmulation.forcePolygonOffset = 0;
generalEmulation.polygonOffsetFactor = 0.0f;
generalEmulation.polygonOffsetUnits = 0.0f;
#endif

frameBufferEmulation.enable = 1;
frameBufferEmulation.copyDepthToRDRAM = 1;
@@ -45,6 +45,11 @@ struct Config
u32 enableHWLighting;
u32 enableCustomSettings;
u32 hacks;
#ifdef ANDROID
u32 forcePolygonOffset;
f32 polygonOffsetFactor;
f32 polygonOffsetUnits;
#endif
} generalEmulation;

enum Aspect {
@@ -116,7 +121,7 @@ struct Config
#define hack_scoreboard (1<<3) //Copy data from RDRAM to auxilary frame buffer. Scoreboard in Mario Tennis.
#define hack_scoreboardJ (1<<4) //Copy data from RDRAM to auxilary frame buffer. Scoreboard in Mario Tennis (J).
#define hack_pilotWings (1<<5) //Special blend mode for PilotWings.
#define hack_subscreen (1<<6) //Fix subscreen delay in Zelda OOT
#define hack_subscreen (1<<6) //Fix subscreen delay in Zelda OOT and Doubutsu no Mori
#define hack_legoRacers (1<<7) //LEGO racers course map
#define hack_blastCorps (1<<8) //Blast Corps black polygons
#define hack_ignoreVIHeightChange (1<<9) //Do not reset FBO when VI height is changed. Space Invaders need it.
@@ -89,7 +89,7 @@ DepthBufferToRDRAM g_dbToRDRAM;
#endif
RDRAMtoFrameBuffer g_RDRAMtoFB;

FrameBuffer::FrameBuffer() : m_validityChecked(0), m_cleared(false), m_changed(false), m_isDepthBuffer(false),
FrameBuffer::FrameBuffer() : m_validityChecked(0), m_cleared(false), m_fingerprint(false), m_changed(false), m_isDepthBuffer(false),
m_needHeightCorrection(false), m_postProcessed(false), m_pLoadTile(NULL), m_pDepthBuffer(NULL),
m_pResolveTexture(NULL), m_resolveFBO(0), m_copiedToRdram(false), m_resolved(false)
{
@@ -191,6 +191,7 @@ void FrameBuffer::init(u32 _address, u32 _endAddress, u16 _format, u16 _size, u1
m_cfb = _cfb;
m_needHeightCorrection = _width != VI.width && _width != *REG.VI_WIDTH;
m_cleared = false;
m_fingerprint = false;

_initTexture(_format, _size, m_pTexture);
glBindFramebuffer(GL_FRAMEBUFFER, m_FBO);
@@ -264,12 +265,19 @@ void FrameBuffer::copyRdram()
// This is necessary for auxilary buffers: game can restore content of RDRAM when buffer is not needed anymore
// Thus content of RDRAM on moment of buffer creation will be the same as when buffer becomes obsolete.
// Validity check will see that the RDRAM is the same and thus the buffer is valid, which is false.
// It can be enough to write data just little more than treshold level, but more safe to write twice as much in case that some values in buffer match our fingerprint.
const u32 twoPercent = dataSize / 200;
u32 start = m_startAddress >> 2;
u32 * pData = (u32*)RDRAM;
for (u32 i = 0; i < twoPercent; ++i)
pData[start++] = m_startAddress;
{
if (i < 4)
pData[start++] = fingerprint[i];
else
pData[start++] = 0;
}
m_cleared = false;
m_fingerprint = true;
return;
}
}

@@ -294,6 +302,13 @@ bool FrameBuffer::isValid() const
++wrongPixels;
}
return wrongPixels < (m_endAddress - m_startAddress) / 400; // treshold level 1% of dwords
} else if (m_fingerprint) {
//check if our fingerprint is still there
u32 start = m_startAddress >> 2;
for (u32 i = 0; i < 4; ++i)
if ((pData[start++] & 0xFFFEFFFE) != (fingerprint[i] & 0xFFFEFFFE))
return false;
return true;
} else if (!m_RdramCopy.empty()) {
const u32 * const pCopy = (const u32*)m_RdramCopy.data();
const u32 size = m_RdramCopy.size();
@@ -582,13 +597,11 @@ void FrameBuffer_Init()

void FrameBuffer_Destroy()
{
if (config.frameBufferEmulation.enable != 0) {
g_RDRAMtoFB.Destroy();
#ifndef GLES2
g_dbToRDRAM.Destroy();
g_fbToRDRAM.Destroy();
#endif
}
frameBufferList().destroy();
}

@@ -1099,8 +1112,10 @@ void DepthBufferToRDRAM::Destroy() {
textureCache().removeFrameBufferTexture(m_pDepthTexture);
m_pDepthTexture = NULL;
}
glDeleteBuffers(1, &m_PBO);
m_PBO = 0;
if (m_PBO != 0) {
glDeleteBuffers(1, &m_PBO);
m_PBO = 0;
}
}

bool DepthBufferToRDRAM::CopyToRDRAM( u32 _address) {
@@ -1158,7 +1173,10 @@ bool DepthBufferToRDRAM::CopyToRDRAM( u32 _address) {
pDepthBuffer->m_cleared = false;
pBuffer = frameBufferList().findBuffer(pDepthBuffer->m_address);
if (pBuffer != NULL)
{
pBuffer->m_cleared = false;
pBuffer->m_fingerprint = false;
}

glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
@@ -1209,8 +1227,10 @@ void RDRAMtoFrameBuffer::Destroy()
m_pTexture = NULL;
}
#ifndef GLES2
glDeleteBuffers(1, &m_PBO);
m_PBO = 0;
if (m_PBO != 0) {
glDeleteBuffers(1, &m_PBO);
m_PBO = 0;
}
#endif
}

@@ -9,6 +9,8 @@
struct gDPTile;
struct DepthBuffer;

const int fingerprint[4] = { 2, 6, 4, 3 };

struct FrameBuffer
{
FrameBuffer();
@@ -26,6 +28,7 @@ struct FrameBuffer
u32 m_size, m_width, m_height, m_fillcolor, m_validityChecked;
float m_scaleX, m_scaleY;
bool m_copiedToRdram;
bool m_fingerprint;
bool m_cleared;
bool m_changed;
bool m_cfb;
@@ -40,6 +40,7 @@ SpecialMicrocodeInfo specialMicrocodes[] =
{ F3DSWSE, FALSE, 0x94c4c833, "RSP SW Version: 2.0D, 04-01-96" },
{ F3DEX, TRUE, 0x637b4b58, "RSP SW Version: 2.0D, 04-01-96" },
{ F3D, TRUE, 0x54c558ba, "RSP SW Version: 2.0D, 04-01-96" }, // Pilot Wings
{ F3D, TRUE, 0x302bca09, "RSP SW Version: 2.0G, 09-30-96" }, // GoldenEye

{ S2DEX, FALSE, 0x9df31081, "RSP Gfx ucode S2DEX 1.06 Yoshitaka Yasumoto Nintendo." },

@@ -508,6 +508,9 @@ void ShaderCombiner::updateAlphaTestInfo(bool _bForce) {
} else if (((gDP.otherMode.alphaCompare & G_AC_THRESHOLD) != 0) && (gDP.otherMode.alphaCvgSel == 0) && (gDP.otherMode.forceBlender == 0 || gDP.blendColor.a > 0)) {
m_uniforms.uEnableAlphaTest.set(1, _bForce);
m_uniforms.uAlphaTestValue.set(max(gDP.blendColor.a, 1.0f / 256.0f), _bForce);
} else if ((gDP.otherMode.alphaCompare == G_AC_DITHER) && (gDP.otherMode.alphaCvgSel == 0)) {
m_uniforms.uEnableAlphaTest.set(1, _bForce);
m_uniforms.uAlphaTestValue.set(0.0f, _bForce);
} else if (gDP.otherMode.cvgXAlpha != 0) {
m_uniforms.uEnableAlphaTest.set(1, _bForce);
m_uniforms.uAlphaTestValue.set(0.125f, _bForce);
@@ -82,6 +82,7 @@ typedef unsigned char boolean;
#define BRZ3X_ENHANCEMENT 0x00000900
#define BRZ4X_ENHANCEMENT 0x00000a00
#define BRZ5X_ENHANCEMENT 0x00000b00
#define BRZ6X_ENHANCEMENT 0x00000c00

#define HIRESTEXTURES_MASK 0x000f0000
#define NO_HIRESTEXTURES 0x00000000
@@ -678,17 +678,20 @@ void SmoothFilter_4444(uint16 *src, uint32 srcwidth, uint32 srcheight, uint16 *d
void filter_8888(uint32 *src, uint32 srcwidth, uint32 srcheight, uint32 *dest, uint32 filter) {
switch (filter & ENHANCEMENT_MASK) {
case BRZ2X_ENHANCEMENT:
xbrz::xbrz_scale(2, (const uint32_t *)const_cast<const uint32 *>(src), (uint32_t *)dest, srcwidth, srcheight, xbrz::ColorFormat::ABGR);
xbrz::scale(2, (const uint32_t *)const_cast<const uint32 *>(src), (uint32_t *)dest, srcwidth, srcheight, xbrz::ColorFormat::ABGR);
return;
case BRZ3X_ENHANCEMENT:
xbrz::xbrz_scale(3, (const uint32_t *)const_cast<const uint32 *>(src), (uint32_t *)dest, srcwidth, srcheight, xbrz::ColorFormat::ABGR);
xbrz::scale(3, (const uint32_t *)const_cast<const uint32 *>(src), (uint32_t *)dest, srcwidth, srcheight, xbrz::ColorFormat::ABGR);
return;
case BRZ4X_ENHANCEMENT:
xbrz::xbrz_scale(4, (const uint32_t *)const_cast<const uint32 *>(src), (uint32_t *)dest, srcwidth, srcheight, xbrz::ColorFormat::ABGR);
xbrz::scale(4, (const uint32_t *)const_cast<const uint32 *>(src), (uint32_t *)dest, srcwidth, srcheight, xbrz::ColorFormat::ABGR);
return;
case BRZ5X_ENHANCEMENT:
xbrz::xbrz_scale(5, (const uint32_t *)const_cast<const uint32 *>(src), (uint32_t *)dest, srcwidth, srcheight, xbrz::ColorFormat::ABGR);
xbrz::scale(5, (const uint32_t *)const_cast<const uint32 *>(src), (uint32_t *)dest, srcwidth, srcheight, xbrz::ColorFormat::ABGR);
return;
case BRZ6X_ENHANCEMENT:
xbrz::scale(6, (const uint32_t *)const_cast<const uint32 *>(src), (uint32_t *)dest, srcwidth, srcheight, xbrz::ColorFormat::ABGR);
return;
case HQ4X_ENHANCEMENT:
hq4x_8888((uint8*)src, (uint8*)dest, srcwidth, srcheight, srcwidth, (srcwidth << 4));
return;

0 comments on commit b8bc8a9

Please sign in to comment.