Homebrew mGBA and blargSNES compile request

WiiUBricker

News Police
OP
Banned
Joined
Sep 19, 2009
Messages
7,827
Trophies
0
Location
Espresso
XP
7,485
Country
Argentina
After gfxInit or gfxInitDefault.
Thanks. There is only a gfxInit(GSP_BGR8_OES, GSP_BGR8_OES, false); in the main.c. I added
gfxInitDefault();
gfxSet3D(true);

after it and it enabled 3D mode. But something is off about the picture. While the pixels are now square, the 3D effect is a bit too intense.
 

hippy dave

BBMB
Member
Joined
Apr 30, 2012
Messages
9,870
Trophies
2
XP
29,143
Country
United Kingdom
Thanks. There is only a gfxInit(GSP_BGR8_OES, GSP_BGR8_OES, false); in the main.c. I added
gfxInitDefault();
gfxSet3D(true);

after it and it enabled 3D mode. But something is off about the picture. While the pixels are now square, the 3D effect is a bit too intense.
Get rid of that, it's not needed if gfxInit is already there.

e: what you're describing is probably because it's only drawing to one side/eye of the 3d display.
 
Last edited by hippy dave,

DiscostewSM

Well-Known Member
Member
Joined
Feb 10, 2009
Messages
5,484
Trophies
2
Location
Sacramento, California
Website
lazerlight.x10.mx
XP
5,488
Country
United States
Okay, I tried to compile mGBA and blargSNES, and I swear these are the two most uncompilable 3ds projects ever. I'm not a expert on compiling projects, but considering the cmakelists they provided doesn't work without modification, I gave up on mGBA (providing raw2c the makefile will not process the .raw file that it needs still, and the makefiles that cmake generates are not very easy to follow).

Compiling blargSNES requires nihstro which for the life of me I cannot compile either, because it was not meant to be used on newer boost library versions. All of the precompiled versions of nihstro I could find were for windows, and my devkitpro environment was linux, so it was a no-go.

Good luck to you man though, personally I just stick to retroarch.

The "veryhard" branch for blargSNES has defaulted to using picasso, which comes with the newest devkitpro. If you're updated on that and ctrulib, then it should compile.
 

DiscostewSM

Well-Known Member
Member
Joined
Feb 10, 2009
Messages
5,484
Trophies
2
Location
Sacramento, California
Website
lazerlight.x10.mx
XP
5,488
Country
United States
Any idea how to fix this?

If you just want to enable 3D, but have the display remain as 2D, then all you need to do is look into the code and find instances of where it does a GX_DisplayTransfer, but make sure that the destination (3rd parameter) is pointing to a function listed as "(u32*)gfxGetFramebuffer". Duplicate the line of code to follow immediately after the first one in each instance, but make a change from where you see "GFX_LEFT" following "GFX_TOP" in the duplicate, and change the LEFT to a RIGHT. That way, it copies the same buffer to both sides/eyes.

In blargSNES, there are only two calls that do that (that aren't commented).

edit:

Oh, in case the project is using citro3d, instead of looking for GX_DisplayTransfer, look for C3D_RenderBufTransfer. Make the same necessary changes as described above.
 
Last edited by DiscostewSM,
  • Like
Reactions: WiiUBricker

WiiUBricker

News Police
OP
Banned
Joined
Sep 19, 2009
Messages
7,827
Trophies
0
Location
Espresso
XP
7,485
Country
Argentina
Just a heads ups guys, if you want to check out the difference between the image quality of square pixels versus "scanlined pixels", download GameYob. It has proper 3D mode enabled by default via the citrus library. Slide the 3D slider all to the bottom to enable the scanline picture and slide it to the top to see square pixels. It's baffling to me why other emulator developers force those damn scanlines on us instead of giving us the choice of the image quality.
 

DarkMatterCore

Finding my light.
Developer
Joined
May 30, 2009
Messages
1,292
Trophies
1
Age
28
Location
Madrid, Spain
Website
github.com
XP
2,604
Country
Spain
I have already applied the changes suggested by DiscostewSM to the "veryhard" branch of blargSnes. So far, it seems the changes didn't break anything. Here's it in case you wanna try it out yourself.

I'll give mGBA a try.
 

Attachments

  • blargSnes-veryhard_3d-mod.rar
    152.2 KB · Views: 119
Last edited by DarkMatterCore,
  • Like
Reactions: zfreeman

WiiUBricker

News Police
OP
Banned
Joined
Sep 19, 2009
Messages
7,827
Trophies
0
Location
Espresso
XP
7,485
Country
Argentina
I have already applied the changes suggested by DiscostewSM to the "veryhard" branch of blargSnes. So far, it seems the changes didn't break anything. Here's it in case you wanna try it out yourself.

I'll give mGBA a try.
Thank you very much :) I will test this later as I'm going to get some sleep. Just one question though. What's the difference between the veryhard and the master branch?
 

DarkMatterCore

Finding my light.
Developer
Joined
May 30, 2009
Messages
1,292
Trophies
1
Age
28
Location
Madrid, Spain
Website
github.com
XP
2,604
Country
Spain
Thank you very much :) I will test this later as I'm going to get some sleep. Just one question though. What's the difference between the veryhard and the master branch?

There are quite a few changes, as already explained by DiscostewSM; but most importantly, it uses picasso instead of nihstro to compile the shaders. It's also updated to support the latest ctrulib. I don't know if it's me, but I can also notice a minor speed-up in some games (like Chrono Trigger).

I didn't have a single problem compiling it, unlike mGBA, which is giving me quite a hard time right now. :D
 

WiiUBricker

News Police
OP
Banned
Joined
Sep 19, 2009
Messages
7,827
Trophies
0
Location
Espresso
XP
7,485
Country
Argentina
I have already applied the changes suggested by DiscostewSM to the "veryhard" branch of blargSnes. So far, it seems the changes didn't break anything. Here's it in case you wanna try it out yourself.
It works and it looks gorgeous!. Thank you very much. Do you mind sharing your modified source code for this?

@DiscostewSM I duplicated this line of code:

Code:
GX_DisplayTransfer(gpuOut, 0x019000F0, (u32*)gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL), 0x019000F0, 0x00001000);

and changed GFX_LEFT to GFX_RIGHT:

Code:
GX_DisplayTransfer(gpuOut, 0x019000F0, (u32*)gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL), 0x019000F0, 0x00001000);
GX_DisplayTransfer(gpuOut, 0x019000F0, (u32*)gfxGetFramebuffer(GFX_TOP, GFX_RIGHT, NULL, NULL), 0x019000F0, 0x00001000);

On two instances in the main.c. It did compile, but 3D didn't work. What did I do wrong?

Edit: Nevermind, I forgot to set gfxSet3D to true. It's working now :grog:
 
Last edited by WiiUBricker,

WiiUBricker

News Police
OP
Banned
Joined
Sep 19, 2009
Messages
7,827
Trophies
0
Location
Espresso
XP
7,485
Country
Argentina
I have issues enabling 3D in mgba. I believe this is the section of the code that needs to be changed (main.c):

Code:
static void _drawEnd(void) {
    int screen = screenMode < SM_PA_TOP ? GFX_BOTTOM : GFX_TOP;
    u16 width = 0, height = 0;

    void* outputFramebuffer = gfxGetFramebuffer(screen, GFX_LEFT, &height, &width);
    ctrGpuEndFrame(screen, outputFramebuffer, width, height);

    if (screen != GFX_BOTTOM) {
        if (guiDrawn & (GUI_THIS_FRAME | GUI_ACTIVE)) {
            void* outputFramebuffer = gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, &height, &width);
            ctrGpuEndFrame(GFX_BOTTOM, outputFramebuffer, width, height);
        } else if (screenCleanup & SCREEN_CLEANUP_BOTTOM) {
            ctrGpuBeginFrame(GFX_BOTTOM);
            if (screenCleanup & SCREEN_CLEANUP_BOTTOM_1) {
                screenCleanup &= ~SCREEN_CLEANUP_BOTTOM_1;
            } else if (screenCleanup & SCREEN_CLEANUP_BOTTOM_2) {
                screenCleanup &= ~SCREEN_CLEANUP_BOTTOM_2;
            }
            void* outputFramebuffer = gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, &height, &width);
            ctrGpuEndFrame(GFX_BOTTOM, outputFramebuffer, width, height);
        }
    }

    if ((screenCleanup & SCREEN_CLEANUP_TOP) && screen != GFX_TOP) {
        ctrGpuBeginFrame(GFX_TOP);
        if (screenCleanup & SCREEN_CLEANUP_TOP_1) {
            screenCleanup &= ~SCREEN_CLEANUP_TOP_1;
        } else if (screenCleanup & SCREEN_CLEANUP_TOP_2) {
            screenCleanup &= ~SCREEN_CLEANUP_TOP_2;
        }
        void* outputFramebuffer = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, &height, &width);
        ctrGpuEndFrame(GFX_TOP, outputFramebuffer, width, height);
    }

    ctrGpuEndDrawing();
}

I tried duplicating the lines saying GFX_LEFT and changing GFX_LEFT to GFX_RIGHT, but it didn't compile. Any ideas?
 

norips

Active Member
Newcomer
Joined
Aug 13, 2012
Messages
32
Trophies
0
XP
162
Country
France
I have issues enabling 3D in mgba. I believe this is the section of the code that needs to be changed (main.c):

Code:
static void _drawEnd(void) {
    int screen = screenMode < SM_PA_TOP ? GFX_BOTTOM : GFX_TOP;
    u16 width = 0, height = 0;

    void* outputFramebuffer = gfxGetFramebuffer(screen, GFX_LEFT, &height, &width);
    ctrGpuEndFrame(screen, outputFramebuffer, width, height);

    if (screen != GFX_BOTTOM) {
        if (guiDrawn & (GUI_THIS_FRAME | GUI_ACTIVE)) {
            void* outputFramebuffer = gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, &height, &width);
            ctrGpuEndFrame(GFX_BOTTOM, outputFramebuffer, width, height);
        } else if (screenCleanup & SCREEN_CLEANUP_BOTTOM) {
            ctrGpuBeginFrame(GFX_BOTTOM);
            if (screenCleanup & SCREEN_CLEANUP_BOTTOM_1) {
                screenCleanup &= ~SCREEN_CLEANUP_BOTTOM_1;
            } else if (screenCleanup & SCREEN_CLEANUP_BOTTOM_2) {
                screenCleanup &= ~SCREEN_CLEANUP_BOTTOM_2;
            }
            void* outputFramebuffer = gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, &height, &width);
            ctrGpuEndFrame(GFX_BOTTOM, outputFramebuffer, width, height);
        }
    }

    if ((screenCleanup & SCREEN_CLEANUP_TOP) && screen != GFX_TOP) {
        ctrGpuBeginFrame(GFX_TOP);
        if (screenCleanup & SCREEN_CLEANUP_TOP_1) {
            screenCleanup &= ~SCREEN_CLEANUP_TOP_1;
        } else if (screenCleanup & SCREEN_CLEANUP_TOP_2) {
            screenCleanup &= ~SCREEN_CLEANUP_TOP_2;
        }
        void* outputFramebuffer = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, &height, &width);
        ctrGpuEndFrame(GFX_TOP, outputFramebuffer, width, height);
    }

    ctrGpuEndDrawing();
}

I tried duplicating the lines saying GFX_LEFT and changing GFX_LEFT to GFX_RIGHT, but it didn't compile. Any ideas?
Actually you can't set GFX_RIGHT for GFX_BOTTOM because GFX_BOTTOM only have 1 screen try modifying this line
Code:
void* outputFramebuffer = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, &height, &width);
with this
Code:
void* outputFramebuffer = gfxGetFramebuffer(GFX_TOP, GFX_RIGHT, &height, &width);
if you want to use the right screen.
But this will not create 3D by magic ! For enabling real 3D you need to offset the frame position postively or negatively depends on what you want (aka depth)
 
Last edited by norips,

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    AncientBoi @ AncientBoi: 9:02 am here