Dolphin, the GameCube and Wii emulator - Forums
[fix] Fragile (and maybe others), source included - Printable Version

+- Dolphin, the GameCube and Wii emulator - Forums (https://forums.dolphin-emu.org)
+-- Forum: Dolphin Emulator Discussion and Support (https://forums.dolphin-emu.org/Forum-dolphin-emulator-discussion-and-support)
+--- Forum: General Discussion (https://forums.dolphin-emu.org/Forum-general-discussion)
+--- Thread: [fix] Fragile (and maybe others), source included (/Thread-fix-fragile-and-maybe-others-source-included)

Pages: 1 2 3 4 5


[fix] Fragile (and maybe others), source included - orbb - 05-21-2009

Hi Smile

I played this morning with the sources of dolphin, and I managed to fix the screen flickering problem in Fragile :p

The basic idea is that I check before each frame is displayed if the frame is black, and I dont display it in this case.

the source included is really basic, it checks only for 5 pixels, it should check for the full screen normally, so some screen wont be displayed... anyway, this is just a fix suggestion, so the devs should try to implement this hack and optimise it Smile

This fix seems to slow the emulation a little, and may break other games...

Ok, here's how to implement it :

- Edit the file source\Plugins\Plugin_VideoOGL\Src\render.cpp

- find the line : OpenGL_SwapBuffers();

- replace it with this piece of code :

// [ fix for Fragile by kamui_kun ...
BYTE pixels [15] ;

glReadPixels(300, 200, 1, 1, GL_RED, GL_BYTE, &pixels[0]);
glReadPixels(300, 400, 1, 1, GL_RED, GL_BYTE, &pixels[1]);
glReadPixels(700, 200, 1, 1, GL_RED, GL_BYTE, &pixels[2]);
glReadPixels(700, 400, 1, 1, GL_RED, GL_BYTE, &pixels[3]);
glReadPixels(500, 300, 1, 1, GL_RED, GL_BYTE, &pixels[4]);
glReadPixels(300, 200, 1, 1, GL_GREEN, GL_BYTE, &pixels[5]);
glReadPixels(300, 400, 1, 1, GL_GREEN, GL_BYTE, &pixels[6]);
glReadPixels(700, 200, 1, 1, GL_GREEN, GL_BYTE, &pixels[7]);
glReadPixels(700, 400, 1, 1, GL_GREEN, GL_BYTE, &pixels[8]);
glReadPixels(500, 300, 1, 1, GL_GREEN, GL_BYTE, &pixels[9]);
glReadPixels(300, 200, 1, 1, GL_BLUE, GL_BYTE, &pixels[10]);
glReadPixels(300, 400, 1, 1, GL_BLUE, GL_BYTE, &pixels[11]);
glReadPixels(700, 200, 1, 1, GL_BLUE, GL_BYTE, &pixels[12]);
glReadPixels(700, 400, 1, 1, GL_BLUE, GL_BYTE, &pixels[13]);
glReadPixels(500, 300, 1, 1, GL_BLUE, GL_BYTE, &pixels[14]);

if((pixels[0] != 0) || (pixels[1] != 0) || (pixels[2] != 0) || (pixels[3] != 0) || (pixels[4] != 0)
|| (pixels[5] != 0) || (pixels[6] != 0) || (pixels[7] != 0) || (pixels[8] != 0) || (pixels[9] != 0)
|| (pixels[10] != 0) || (pixels[11] != 0) || (pixels[12] != 0) || (pixels[13] != 0) || (pixels[14] != 0)
) OpenGL_SwapBuffers();
// ... ]

- compile, and play Smile


RE: [fix] Fragile (and maybe others), source included - student1 - 05-22-2009

(05-21-2009, 09:18 PM)orbb Wrote: Hi Smile

I played this morning with the sources of dolphin, and I managed to fix the screen flickering problem in Fragile :p

The basic idea is that I check before each frame is displayed if the frame is black, and I dont display it in this case.

the source included is really basic, it checks only for 5 pixels, it should check for the full screen normally, so some screen wont be displayed... anyway, this is just a fix suggestion, so the devs should try to implement this hack and optimise it Smile

This fix seems to slow the emulation a little, and may break other games...

Ok, here's how to implement it :

- Edit the file source\Plugins\Plugin_VideoOGL\Src\render.cpp

- find the line : OpenGL_SwapBuffers();

- replace it with this piece of code :

// [ fix for Fragile by kamui_kun ...
BYTE pixels [15] ;

glReadPixels(300, 200, 1, 1, GL_RED, GL_BYTE, &pixels[0]);
glReadPixels(300, 400, 1, 1, GL_RED, GL_BYTE, &pixels[1]);
glReadPixels(700, 200, 1, 1, GL_RED, GL_BYTE, &pixels[2]);
glReadPixels(700, 400, 1, 1, GL_RED, GL_BYTE, &pixels[3]);
glReadPixels(500, 300, 1, 1, GL_RED, GL_BYTE, &pixels[4]);
glReadPixels(300, 200, 1, 1, GL_GREEN, GL_BYTE, &pixels[5]);
glReadPixels(300, 400, 1, 1, GL_GREEN, GL_BYTE, &pixels[6]);
glReadPixels(700, 200, 1, 1, GL_GREEN, GL_BYTE, &pixels[7]);
glReadPixels(700, 400, 1, 1, GL_GREEN, GL_BYTE, &pixels[8]);
glReadPixels(500, 300, 1, 1, GL_GREEN, GL_BYTE, &pixels[9]);
glReadPixels(300, 200, 1, 1, GL_BLUE, GL_BYTE, &pixels[10]);
glReadPixels(300, 400, 1, 1, GL_BLUE, GL_BYTE, &pixels[11]);
glReadPixels(700, 200, 1, 1, GL_BLUE, GL_BYTE, &pixels[12]);
glReadPixels(700, 400, 1, 1, GL_BLUE, GL_BYTE, &pixels[13]);
glReadPixels(500, 300, 1, 1, GL_BLUE, GL_BYTE, &pixels[14]);

if((pixels[0] != 0) || (pixels[1] != 0) || (pixels[2] != 0) || (pixels[3] != 0) || (pixels[4] != 0)
|| (pixels[5] != 0) || (pixels[6] != 0) || (pixels[7] != 0) || (pixels[8] != 0) || (pixels[9] != 0)
|| (pixels[10] != 0) || (pixels[11] != 0) || (pixels[12] != 0) || (pixels[13] != 0) || (pixels[14] != 0)
) OpenGL_SwapBuffers();
// ... ]

- compile, and play Smile


Nice thanks, this might actually also fix games like mega man 9 Smile! But i think it might be more used as a hack to fix the issue, like an extra option for flicker! Anyway great work Smile!


RE: [fix] Fragile (and maybe others), source included - orbb - 05-22-2009

no problem Smile and yes it could fix some other games, and break others :p
but it really needs to be optimised, by checking all the backbuffer pixels and not just five ...
anyway, it works fine with Fragile, and that was my goal Smile


RE: [fix] Fragile (and maybe others), source included - cmccmc - 05-22-2009

I think this could help digimon world 4's constant screen flickering. I'm gonna go check


RE: [fix] Fragile (and maybe others), source included - death-droid - 05-22-2009

I'll add this as one of the game hack...
Maybe....


RE: [fix] Fragile (and maybe others), source included - cmccmc - 05-22-2009

how about adding this as an option instead of a hack. You could call it something like remove flicker. Of course before you do that you should probably tweak it a bit


RE: [fix] Fragile (and maybe others), source included - deathtotheweird - 05-22-2009

This works just fine as long as the game is in full screen mode. Very nice find. Game runs better than expected too. Around 40-60fps at times.


RE: [fix] Fragile (and maybe others), source included - hakunushi - 05-22-2009

this should be added may fix mario party for nvidia users.


RE: [fix] Fragile (and maybe others), source included - death-droid - 05-22-2009

Ok Just editing the hack then i might implement it into the OpenGL plugin(As an option)

EDIT:


Just a little clean up Tongue
Need someone to make sure this works...

Woop's just relized the GL_RED stuff XD
Ok just need to make a quick fix for that Tongue

EDIT2:

Ok can someone try this out pls

Code:
BYTE pixels [14] ;
int  color[3];
color[GL_RED,GL_GREEN,GL_BLUE];

    for (int i = 0;i<14;i++)
    {
        for (int ii = 0;ii<3;i++)
        {
            if (i == 0||5||10)
                glReadPixels(300, 200, 1, 1, color[ii], GL_BYTE, &pixels[i]);

            if (i == 1||6||11)
                glReadPixels(300, 400, 1, 1, color[ii], GL_BYTE, &pixels[i]);

            if (i == 2||7||12)
                glReadPixels(700, 200, 1, 1, color[ii], GL_BYTE, &pixels[i]);
            
            if (i == 3||8||13)
                glReadPixels(700, 400, 1, 1, color[ii], GL_BYTE, &pixels[i]);

            if (i == 4||9||14)
                glReadPixels(500, 300, 1, 1, color[ii], GL_BYTE, &pixels[i]);
        }

        if(pixels[i]!=0)
        {
            OpenGL_SwapBuffers();
        }
    }



RE: [fix] Fragile (and maybe others), source included - deathtotheweird - 05-22-2009

Getting undeclared identifier from pixels. I'm no programmer so I have no idea how to fix this, or what it means.