Homebrew Homebrew Development

Tjessx

Well-Known Member
Member
Joined
Dec 3, 2014
Messages
1,160
Trophies
0
Age
27
XP
952
Country
Belgium
At the end of the main loop ;)

main loop:
-Draw things
-Do things
-Flush and Swap
-Wait for vblank
Forgot to reuse
u8* gfxGetFramebuffer

--------------------- MERGED ---------------------------

Does it hangs at a certain point or it doesn't boot at all?
It has been fixed, it didnt boot at all
 

AlbertoSONIC

Pasta Team Member
Member
Joined
Jun 27, 2014
Messages
927
Trophies
0
Age
52
Website
www.albertosonic.com
XP
1,396
Country
Italy
you have to get framebuffer address every loop iteration?
does it move around on your system? that's pretty weird.
Mmmm actually, I've never noticed this thing. You're true, this is weird. I've been using this list of operations to do in main loop since my first 3ds homebrew and I brought this error with me for almost 1 year. :(

The correct thing is:

-GetFB

MAIN LOOP:
-Draw things
-Do things
-Flush and Swap FB
-Wait for VBlank
 
  • Like
Reactions: zoogie

Tjessx

Well-Known Member
Member
Joined
Dec 3, 2014
Messages
1,160
Trophies
0
Age
27
XP
952
Country
Belgium
Mmmm actually, I've never noticed this thing. You're true, this is weird. I've been using this list of operations to do in main loop since my first 3ds homebrew and I brought this error with me for almost 1 year. :(

The correct thing is:

-GetFB

MAIN LOOP:
-Draw things
-Do things
-Flush and Swap FB
-Wait for VBlank
IT doesn't matter if yo got a small app.
But in the end it really flickers
 

Tjessx

Well-Known Member
Member
Joined
Dec 3, 2014
Messages
1,160
Trophies
0
Age
27
XP
952
Country
Belgium
i'll post it in a minute

--------------------- MERGED ---------------------------

So you get FB before entering the main loop, right?

Code:
void get_buffers() {
    top = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
    bottom = gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL);
}

int main() {
    bool change = true;
  
    srvInit();
    aptInit();
    hidInit(NULL);
    gfxInitDefault();
    init();
  
    get_buffers();
    while (aptMainLoop())
    {
        gspWaitForVBlank();
        hidScanInput();
      
        u32 kDown;
        kDown = hidKeysDown();
      
        touchPosition touch;
        hidTouchRead(&touch);

        //should actually check keys here
      
        if(change == true || check_keyboard_click(touch)) {
            draw_keyboard(bottom);
            gfxFlushBuffers();
            change = true;
        }

        if(change) {
            draw_menu();
            gfxFlushBuffers();
            gfxSwapBuffers();
            get_buffers();
            change = false;
        }
      
        //check keys
      
        gfxFlushBuffers();
    }

    gfxExit();
    hidExit();
    aptExit();
    srvExit();
    return 0;
}

I'm going to place the //check keys part before the drawing, since everything would appear one tick earlier.

EDIT: Basicly i check if something changes, if it does, i redraw the necessary stuff, flush buffers, swap buffers, and get the buffers
 
Last edited by Tjessx,
  • Like
Reactions: AlbertoSONIC

AlbertoSONIC

Pasta Team Member
Member
Joined
Jun 27, 2014
Messages
927
Trophies
0
Age
52
Website
www.albertosonic.com
XP
1,396
Country
Italy
I don't understand a things in this piece of code:

Code:
if(change == true || check_keyboard_click(touch)) {
draw_keyboard(bottom);
gfxFlushBuffers();
change = true;
}

if(change) {
draw_menu();
gfxFlushBuffers();
gfxSwapBuffers();
get_buffers();
change = false;
}

If "check" is true, the 3ds executes the code inside both the "if":

draw_keyboard(bottom);
gfxFlushBuffers();
change = true; check is already true, otherwise we wouldn't be running this code
draw_menu();
gfxFlushBuffers(); you flush again? Just do it one time!
gfxSwapBuffers();
get_buffers();
change = false;

I don't have the full code but *i think* there's something wrong here...
 

Tjessx

Well-Known Member
Member
Joined
Dec 3, 2014
Messages
1,160
Trophies
0
Age
27
XP
952
Country
Belgium
I don't understand a things in this piece of code:

Code:
if(change == true || check_keyboard_click(touch)) {
draw_keyboard(bottom);
gfxFlushBuffers();
change = true;
}

if(change) {
draw_menu();
gfxFlushBuffers();
gfxSwapBuffers();
get_buffers();
change = false;
}

If "check" is true, the 3ds executes the code inside both the "if":

draw_keyboard(bottom);
gfxFlushBuffers();
change = true; check is already true, otherwise we wouldn't be running this code
draw_menu();
gfxFlushBuffers(); you flush again? Just do it one time!
gfxSwapBuffers();
get_buffers();
change = false;

I don't have the full code but *i think* there's something wrong here...

It's pretty simple actually,
But you don't have the full code,
Instead of the //check here for key presses part, i check if a key is pressed, and if it has been pressed then change = true;

Then, in the next frame.
If something changed (still only keypress), i want to redraw the keyboard, and the menu.

But if nothing changed, i'm gonna check if someone pressed the keyboard in a way something changed, if it does I need to redraw the keyboard + the menu


EDIT: It makes sense if you get the complete code, but the change variable has a wrong name,
 
  • Like
Reactions: AlbertoSONIC

AlbertoSONIC

Pasta Team Member
Member
Joined
Jun 27, 2014
Messages
927
Trophies
0
Age
52
Website
www.albertosonic.com
XP
1,396
Country
Italy
It's pretty simple actually,
But you don't have the full code,
Instead of the //check here for key presses part, i check if a key is pressed, and if it has been pressed then change = true;

Then, in the next frame.
If something changed (still only keypress), i want to redraw the keyboard, and the menu.

But if nothing changed, i'm gonna check if someone pressed the keyboard in a way something changed, if it does I need to redraw the keyboard + the menu


EDIT: It makes sense if you get the complete code, but the change variable has a wrong name,
Yeah I understood that but...

If change is true, it executes both the if.
If check_keyboard_click(touch) is true, it executes both the if.
If change is false, the two if's code won't get executed.
If check_keyboard_click(touch) is false, the two if's code won't get executed.

This means that those two "if" will behave the same, if one is executed, the other one is executed, if one isn't executed, the other one isn't executed. This means that those if can be merged in only one zip, with change || check_keyboard_click(touch) as condiction! ;)
 

Tjessx

Well-Known Member
Member
Joined
Dec 3, 2014
Messages
1,160
Trophies
0
Age
27
XP
952
Country
Belgium
Yeah I understood that but...

If change is true, it executes both the if.
If check_keyboard_click(touch) is true, it executes both the if.
If change is false, the two if's code won't get executed.
If check_keyboard_click(touch) is false, the two if's code won't get executed.

This means that those two "if" will behave the same, if one is executed, the other one is executed, if one isn't executed, the other one isn't executed. This means that those if can be merged in only one zip, with change || check_keyboard_click(touch) as condiction! ;)

Good point, I though of that, but it was late :P will change that, thanks :P
 
  • Like
Reactions: AlbertoSONIC

nop90

Well-Known Member
Member
Joined
Jan 11, 2014
Messages
1,556
Trophies
0
Location
Rome
XP
3,136
Country
Italy
I need help in setting up some libs in devkitpro.

I copied libz, libpng and other libs in devkitpro/portlibs/arm, but don't know what to to now to make them used by the #include <...> statement.

My os is win7

EDIT: solved with makefile on Xerpi github
 
Last edited by nop90,

Tjessx

Well-Known Member
Member
Joined
Dec 3, 2014
Messages
1,160
Trophies
0
Age
27
XP
952
Country
Belgium

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    BakerMan @ BakerMan: ... that's rough buddy