Homebrew [Q] Does an APT app jump exit the app that it's called from?

LeifEricson

Coming Soon™
OP
Member
Joined
Jun 22, 2012
Messages
234
Trophies
0
Age
27
Location
New York, USA
Website
www.youtube.com
XP
534
Country
United States
I'm trying to make an application that will run and be able to perform functions while the game in the gamecard slot is running. I've stumbled upon APT_DoAppJump as well as as the NS service's app launch (whose call I don't remember.)

Do either of these allow the original homebrew to continue running while the game is running after the function calls, or does it exit the original app? If not, would I have to do something like multi-threading to get that to work?
 

LeifEricson

Coming Soon™
OP
Member
Joined
Jun 22, 2012
Messages
234
Trophies
0
Age
27
Location
New York, USA
Website
www.youtube.com
XP
534
Country
United States
I wish i could give you the correct response. I am where wondering what you doing now... :P From the sounds of it you'd have to do ns services then doappjump after that. However don't quote be on that. Its just my common sense!

I'm trying to make a screen recorder by taking screenshots every frame (inefficient, slow, I know. I've considered all of the limitations).

Could you perhaps help me out and tell me what my code should look like?
 

cpasjuste

Well-Known Member
Member
Joined
Aug 27, 2015
Messages
1,108
Trophies
1
Age
44
XP
4,481
Country
France
I'm trying to make a screen recorder by taking screenshots every frame (inefficient, slow, I know. I've considered all of the limitations).

Could you perhaps help me out and tell me what my code should look like?

Hi,

I wanted to do something like this (for debugging purpose), I didn't investigate a lot but I think there's no know (public) way of doing that. I think for now your best option would be to write an ntr plugin (which isn't as easy as I think it need arm9 code).
 
Last edited by cpasjuste,

Rinnegatamante

Well-Known Member
Member
Joined
Nov 24, 2014
Messages
3,162
Trophies
2
Age
29
Location
Bologna
Website
rinnegatamante.it
XP
4,857
Country
Italy
I'm trying to make an application that will run and be able to perform functions while the game in the gamecard slot is running. I've stumbled upon APT_DoAppJump as well as as the NS service's app launch (whose call I don't remember.)

Do either of these allow the original homebrew to continue running while the game is running after the function calls, or does it exit the original app? If not, would I have to do something like multi-threading to get that to work?

When i was working on the launchGamecard for lpp-3ds, i noticed that the app jump takes at least some time when you can execute code after its execution. To "fix" it i added an infinite loop after the app jump call ( https://github.com/Rinnegatamante/lpp-3ds/blob/master/source/luaSystem.cpp#L1238 ).
Don't know if it's only a delay from APP service or if the program still runs in background but maybe it could help you understand how it works.
 

LeifEricson

Coming Soon™
OP
Member
Joined
Jun 22, 2012
Messages
234
Trophies
0
Age
27
Location
New York, USA
Website
www.youtube.com
XP
534
Country
United States
When i was working on the launchGamecard for lpp-3ds, i noticed that the app jump takes at least some time when you can execute code after its execution. To "fix" it i added an infinite loop after the app jump call ( https://github.com/Rinnegatamante/lpp-3ds/blob/master/source/luaSystem.cpp#L1238 ).
Don't know if it's only a delay from APP service or if the program still runs in background but maybe it could help you understand how it works.

Hey thanks, you're just the person I was hoping would see this. So, if I put an infinite loop after the app jump call, I can continue running code, or the loop prevents it? I want to be able to trigger the recording when wanted, because if it started running from launch it would lag unbearably.

Also, my app jump code is just causing a black screen anyways. Is there something I'm forgetting to do before/after the app jump call that I'm missing?

Code:
// Rinnegatamante's de-luafied launch card function
void startcard() {
    amInit();
    char product_id[16];
    AM_GetTitleProductCode(mediatype_GAMECARD, 0, product_id);
    amExit();
    if (product_id[0] == 'C' and product_id[1] == 'T' and product_id[2] == 'R'){
        u8 buf0[0x300];
        u8 buf1[0x20];
        memset(buf0, 0, 0x300);
        memset(buf1, 0, 0x20);
        aptOpenSession();
        APT_PrepareToDoAppJump(NULL, 0, 0, mediatype_GAMECARD);
        APT_DoAppJump(NULL, 0x300, 0x20, buf0, buf1);
        aptCloseSession();
    }else{
        nsInit();
        NS_RebootToTitle(mediatype_GAMECARD,0);
        nsExit();
    }
    for (;;){} // Does this loop *prevent* further code execution, or allow it?
}

int main() {
    srand(time(NULL));
    fsInit();
    gfxInitDefault();
    startcard(); //...Or does this need to be moved?

    while (aptMainLoop()) {
        gspWaitForVBlank();
        hidScanInput();
        keys_down = hidKeysDown();
        keys_up = hidKeysUp();

        if (keys_down & KEY_A & KEY_B & KEY_START) break;

        framebuf_top = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
        framebuf_bot = gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL);

        if (keys_down & KEY_UP & KEY_X & KEY_Y) {
            if (!recording) recording = true;
            else recording = false;
        }

        if (recording) {
            screenshot(frambuf_top, 0, 400, 240, frame);
            screenshot(framebuf_bot, 1, 320, 240, frame);
            ++frame;
        }

        startcard(); // I've also tried it here (but not both calls at the same time)

        gfxFlushBuffers();
        gfxSwapBuffers();
        ++sysframe;
    }
    gfxExit();
    fsExit();
    return 0;
}
 
Last edited by LeifEricson,

filfat

CTO @ Nordcom Group Inc.
Member
Joined
Nov 24, 2012
Messages
1,261
Trophies
1
Location
Gothenburg, Sweden
Website
www.sweetsideofsweden.com
XP
1,749
Country
Sweden
^ startcode(void) will never return since you for(;;) executes forever.
Maybe try and see if multithreading work, prehaps thread 2 won't get killed (don't know since I haven't test myself).

I'll see if I can get an example (if needed) , I don't prommise anything though :P
 

cpasjuste

Well-Known Member
Member
Joined
Aug 27, 2015
Messages
1,108
Trophies
1
Age
44
XP
4,481
Country
France
^ startcode(void) will never return since you for(;;) executes forever.
Maybe try and see if multithreading work, prehaps thread 2 won't get killed (don't know since I haven't test myself).

I'll see if I can get an example (if needed) , I don't prommise anything though :P

I tried that some time ago and all threads were killed too. But maybe i didn't did it right.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    K3Nv2 @ K3Nv2: The mutated Axolotl was awesome