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
26
Location
New York, USA
Website
www.youtube.com
XP
499
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
26
Location
New York, USA
Website
www.youtube.com
XP
499
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
43
XP
4,236
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
28
Location
Bologna
Website
rinnegatamante.it
XP
4,744
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
26
Location
New York, USA
Website
www.youtube.com
XP
499
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

Musician, Developer & Entrepreneur
Member
Joined
Nov 24, 2012
Messages
1,259
Trophies
0
Location
Göteborg
Website
spsgroup.se
XP
1,718
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
43
XP
4,236
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.
 
General chit-chat
Help Users
  • JuanMena @ JuanMena:
    Kissing random dudes choking in celery? Really? Need to study for that?
  • K3N1 @ K3N1:
    Yes it requires a degree
  • K3N1 @ K3N1:
    I could also yank out the rest of my teeth but theirs professionals for that
  • x65943 @ x65943:
    If your throat closes, putting oxygen in your mouth will not solve anything - as you will be introducing oxygen prior to the area of obstruction
  • JuanMena @ JuanMena:
    Just kiss me Kyle.
  • x65943 @ x65943:
    You either need to be intubated to bypass obstruction or create a stoma inferior to the the area of obstruction to survive
  • x65943 @ x65943:
    "Just kiss me Kyle." And I thought all the godreborn gay stuff was a smear campaign
  • JuanMena @ JuanMena:
    If I die, tell my momma I won't be carrying Baby Jesus this christmas :sad::cry:
  • K3N1 @ K3N1:
    Smear campaigns are in The political section now?
  • JuanMena @ JuanMena:
    Chary! Chary! Chary, Chary, Chary!
  • Sonic Angel Knight @ Sonic Angel Knight:
    Pork Provolone :P
  • Psionic Roshambo @ Psionic Roshambo:
    Sounds yummy
  • K3N1 @ K3N1:
    Sweet found my Wii u PSU right after I ordered a new one :tpi:
  • JuanMena @ JuanMena:
    It was waiting for you to order another one.
    Seems like, your PSU was waiting for a partner.
  • JuanMena @ JuanMena:
    Keep them both
    separated or you'll have more PSUs each year.
  • K3N1 @ K3N1:
    Well one you insert one PSU into the other one you get power
  • JuanMena @ JuanMena:
    It literally turns it on.
  • K3N1 @ K3N1:
    Yeah power supplies are filthy perverts
  • K3N1 @ K3N1:
    @Psionic Roshambo has a new friend
    +1
  • JuanMena @ JuanMena:
    It's Kyle, the guy that went to school to be a Certified man Kisser.
  • Psionic Roshambo @ Psionic Roshambo:
    Cartmans hand has taco flavored kisses
  • A @ abraarukuk:
    hi guys
  • Iron_Masuku @ Iron_Masuku:
    Hello
    Skelletonike @ Skelletonike: hmm