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

pengawill

Member
OP
Newcomer
Joined
Sep 15, 2015
Messages
10
Trophies
0
Age
27
XP
76
Country
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.
 

Attachments

  • It_Hurts.zip
    102.1 KB · Views: 176
Last edited by pengawill,

lolzvid

Well-Known Member
Member
Joined
Dec 26, 2014
Messages
148
Trophies
0
Age
22
XP
278
Country
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();
 

pengawill

Member
OP
Newcomer
Joined
Sep 15, 2015
Messages
10
Trophies
0
Age
27
XP
76
Country
United States
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();

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.
 

lolzvid

Well-Known Member
Member
Joined
Dec 26, 2014
Messages
148
Trophies
0
Age
22
XP
278
Country
Brazil
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.
I think you will need to do that, too.

Try doing some experiments with that and see what happens.
 

Giantblargg

Active Member
Newcomer
Joined
Nov 28, 2015
Messages
41
Trophies
0
Location
Behind you
XP
167
Country
Canada
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.
 
  • Like
Reactions: lolzvid

pengawill

Member
OP
Newcomer
Joined
Sep 15, 2015
Messages
10
Trophies
0
Age
27
XP
76
Country
United States
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.

Thank you godly man, placing this after each print to the console fixes the issue.

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

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?

This is the first string.
*Press A*
This is the second.
*Press A*
This is definitely the third string.
 

thatbooisaspy

Well-Known Member
Member
Joined
Oct 28, 2015
Messages
353
Trophies
0
XP
229
Country
Thank you godly man, placing this after each print to the console fixes the issue.

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

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?

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).
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    Psionic Roshambo @ Psionic Roshambo: LOL