Application problems? I believe it might be a memory issue?

Discussion in '3DS - Homebrew Development and Emulators' started by pengawill, Nov 29, 2015.

  1. pengawill
    OP

    pengawill Member

    Newcomer
    10
    2
    Sep 15, 2015
    United States
    Like the title says, I'm having a problem in a C app I'm making where in the console, there's a small bit of tearing on the letters when they're typed to the console in certain situations, and only on an actual 3DS. I have an original 3DSXL, so there you go. Most of the top screen is dominated by an upper window with a pixel image I've custom made using console commands (I think it may be taking up too many resources), so I thought that may have been the problem. But all tries to reduce the image's size and content haven't fixed anything. In the zip below, I've included the application files and the source code. Select (Or N if you're using Citra) will advance the text a single time.

    If anyone could be of any service, I would greatly appreciate it!

    EDIT: This has been fixed, but I posted a second question below.
     

    Attached Files:

    Last edited by pengawill, Nov 29, 2015
  2. pengawill
    OP

    pengawill Member

    Newcomer
    10
    2
    Sep 15, 2015
    United States
    Bump? I could really really use some help.
     
  3. lolzvid

    lolzvid GBAtemp Regular

    Member
    148
    116
    Dec 26, 2014
    Brazil
    I think the way that you're initializing the console is the problem (two top screens and one bottom screen in a row?).

    Try using them only when you need, with something like this:

    Code:
    consoleInit(GFX_TOP, NULL);
    faceSmile();
    
     
  4. pengawill
    OP

    pengawill Member

    Newcomer
    10
    2
    Sep 15, 2015
    United States
    While doing this, I'm assuming I'll have to set the dimensions of each window after the window is initialized, each time?

    After using consoleInit(GFX_TOP, &TopBot); I'll have to put consoleSetWindow(&TopTop, 1, 1, 48, 19); whenever I need to use it?

    Also, very sorry If I'm completely wrong. I'm just now learning C and programming in general.
     
  5. lolzvid

    lolzvid GBAtemp Regular

    Member
    148
    116
    Dec 26, 2014
    Brazil
    I think you will need to do that, too.

    Try doing some experiments with that and see what happens.
     
  6. Giantblargg

    Giantblargg Member

    Newcomer
    41
    36
    Nov 28, 2015
    Canada
    Behind you
    I haven't tested your code but just looking at it, it seems similar to a problem I had

    You need to call
    Code:
    gfxFlushBuffers();
    gfxSwapBuffers();
    every time you write to the console.
     
    lolzvid likes this.
  7. pengawill
    OP

    pengawill Member

    Newcomer
    10
    2
    Sep 15, 2015
    United States
    Thank you godly man, placing this after each print to the console fixes the issue.

    — Posts automatically merged - Please don't double post! —

    I hope if anyone has the time, another question.

    Would anyone know how display a few strings of text in a sequence? As in, have the program wait for user input (probably via the A button) and display the next string?

     
  8. thatbooisaspy

    thatbooisaspy GBAtemp Fan

    Member
    367
    151
    Oct 28, 2015
    I don't know the best C way to go about this, but since this is just a simple conditional statement:
    Code:
    kDown & KEY_START
    Couldn't you do some hacky thing like this?
    Code:
    print_or_whatever_man("This is the first string.");
    while(!(kDown & KEY_START)) { 
        wait here...
    }
    print_or_whatever_man("This is a second string");
    ...
    
    Again, libctru has no wait() function (nor do i think newlib) so this is as far as I would know. In normal C/C++ you would use something like getchar() or system("sleep") but since ctrulib doesn't capture stdout it isn't possible here. Note that this stops the entire main loop if you do it this way.

    Another solution is this (and again in psuedocode):
    Code:
    mainloop() {
        getuserinput();
    
        if(!keydown) {
           clearConsole();
           print("This is the first string.");
        } else {
            if(!keydown2) {
               clearConsole();
               printf("This is a second string.");
            }
        }
    }
    
    However it isn't really pretty, or the most efficient way (try to not depend on huge state machines, if possible). Just keep doing research, i'm sure someone else had to encounter this problem where getchar() wasn't the answer. Hope this helps (or gives you some ideas).