Homebrew Homebrew Development

nop90

Well-Known Member
Member
Joined
Jan 11, 2014
Messages
1,556
Trophies
0
Location
Rome
XP
3,136
Country
Italy
@umbjolt , this should work:

Code:
#define TICKS_PER_MSEC (268123.480)

void showRomPathMarquee(const int XposValue,int Ypos, std::string text) {
   std::string path = text;
 
   while(!(hidKeysDown() & KEY_UP)){
       std::string scrolled,temp,temp2;
       hidScanInput();
       sf2d_start_frame(GFX_TOP, GFX_LEFT);
       sf2d_start_frame(GFX_TOP, GFX_LEFT);      
       temp = path.substr(1,(path.length()));
       temp2 = path.substr(0,1);
       path = temp + temp2;
       if(path.length() + 1 == ' '){
           sftd_draw_textf(font, XposValue, Ypos, SET_ALPHA(color_data->color, 255), 12, "%s %s", temp.c_str(), temp2.c_str());
       }else{
           sftd_draw_textf(font, XposValue, Ypos, SET_ALPHA(color_data->color, 255), 12, "%s", path.c_str());
       }
       sf2d_end_frame();
       sf2d_swapbuffers();
       svcSleepThread(500000000 ); // sleep for 0,5 sec
   }
}

There is only the part "if(path.length() + 1 == ' ')" that I don't understand.
 
Last edited by nop90,
  • Like
Reactions: umbjolt

umbjolt

Wild jolteon
Member
Joined
Sep 15, 2016
Messages
558
Trophies
0
Age
27
Location
Magnolia, Fiore
XP
316
Country
@umbjolt , this should work:

Code:
#define TICKS_PER_MSEC (268123.480)

void showRomPathMarquee(const int XposValue,int Ypos, std::string text) {
   std::string path = text;
 
   while(!(hidKeysDown() & KEY_UP)){
       std::string scrolled,temp,temp2;
       hidScanInput();
       
       temp = path.substr(1,(path.length()));
       temp2 = path.substr(0,1);
       path = temp + temp2;
       if(path.length() + 1 == ' '){
           sftd_draw_textf(font, XposValue, Ypos, SET_ALPHA(color_data->color, 255), 12, "%s %s", temp.c_str(), temp2.c_str());
       }else{
           sftd_draw_textf(font, XposValue, Ypos, SET_ALPHA(color_data->color, 255), 12, "%s", path.c_str());
       }
       svcSleepThread(500 * TICKS_PER_MSEC ); // sleep for 0,5 sec
   }
}

There is only the part "if(path.length() + 1 == ' ')" that I don't understand.

Thanks you :) Later I'll test it ;)
Still no dice and freeze but after pressing UP a lot of times seems to "unfreeze" and let me press HOME but text is impossible to read neither :(
 
Last edited by umbjolt,

elhobbs

Well-Known Member
Member
Joined
Jul 28, 2008
Messages
1,044
Trophies
1
XP
3,034
Country
United States
Thanks you but again, still freeze :S
Not really familiar with sftd but if it is using hardware rendering than you are using it wrong. Also, as I already indicated, svcSleepThread expects time in nanoseconds - not ticks converted to milliseconds.
Likely your program is running briefly without updating the screen before overflowing the rendering command buffers and crashing.
 
  • Like
Reactions: umbjolt

nop90

Well-Known Member
Member
Joined
Jan 11, 2014
Messages
1,556
Trophies
0
Location
Rome
XP
3,136
Country
Italy
svcSleepThread expects time in nanoseconds - not ticks converted to milliseconds.

Is it changed in the last year? Maybe I remember wrong, but thought it used ticks. (Noe checked the documentantion and it says milliseconds)

@umbjolt the previous example miss some code for sf2d, like :

Code:
sf2d_start_frame(GFX_TOP, GFX_LEFT);
 ...
sf2d_end_frame();
sf2d_swapbuffers();

I edited the above code. But don't have time to test it for other missing things.
 
Last edited by nop90,
  • Like
Reactions: umbjolt

elhobbs

Well-Known Member
Member
Joined
Jul 28, 2008
Messages
1,044
Trophies
1
XP
3,034
Country
United States
Is it changed in the last year? Maybe I remember wrong, but thought it used ticks. (Noe checked the documentantion and it says milliseconds)

@umbjolt the previous example miss some code for sf2d, like :

Code:
sf2d_start_frame(GFX_TOP, GFX_LEFT);
 ...
sf2d_end_frame();
sf2d_swapbuffers();

I edited the above code. But don't have time to test it for other missing things.
That is odd. The note in the header file says nanoseconds.

/**
* @brief Puts the current thread to sleep.
* @param ns The minimum number of nanoseconds to sleep for.
*/
void svcSleepThread(s64 ns);
 

umbjolt

Wild jolteon
Member
Joined
Sep 15, 2016
Messages
558
Trophies
0
Age
27
Location
Magnolia, Fiore
XP
316
Country
Is it changed in the last year? Maybe I remember wrong, but thought it used ticks. (Noe checked the documentantion and it says milliseconds)

@umbjolt the previous example miss some code for sf2d, like :

Code:
sf2d_start_frame(GFX_TOP, GFX_LEFT);
 ...
sf2d_end_frame();
sf2d_swapbuffers();

I edited the above code. But don't have time to test it for other missing things.
Thanks again but still the fucking while loop freeze the console. I've tested without the while and it doesn't freeze at all. Also, pressing UP key doesn't break the while so maybe it's a limitation with the console?
 

nop90

Well-Known Member
Member
Joined
Jan 11, 2014
Messages
1,556
Trophies
0
Location
Rome
XP
3,136
Country
Italy
Hi, is there a way to get a sound (recorded from mic but it doesn't matter) frequency?
What do you mean with frequency? A sound sample has a frequency spectrum, not a single frequency value. If you're searching the fundamental frequency, like does a guitar tuner, you have to know a lot of math (there is a not working tuner for the 3ds on my github)
 

umbjolt

Wild jolteon
Member
Joined
Sep 15, 2016
Messages
558
Trophies
0
Age
27
Location
Magnolia, Fiore
XP
316
Country
I'm going to ask the most stupid question on the world.
-1 is true or false? I always get confused :rolleyes:
Because some languages 0 is true and others false but dunno what happen with negatives (in this case) ^^u
 

nop90

Well-Known Member
Member
Joined
Jan 11, 2014
Messages
1,556
Trophies
0
Location
Rome
XP
3,136
Country
Italy
I'm going to ask the most stupid question on the world.
-1 is true or false? I always get confused :rolleyes:
Because some languages 0 is true and others false but dunno what happen with negatives (in this case) ^^u

Don't know if it's standard C or if it is compiler dependant (should be ANSI C) , but usually false is 0, so that a NULL pointer (= 0 address) can be evaluated as false.

Any value !0 is evaluated to true.

To define a bool type with a conventional value for true, it s a good choice to select the value -1 defining the bool type as a signed numeral (usually s32), so it's easy to swap between true and false with the ~ operator (true == ~false only and only if true is a signed value set at -1, i.e. all bit set).
 
  • Like
Reactions: umbjolt

umbjolt

Wild jolteon
Member
Joined
Sep 15, 2016
Messages
558
Trophies
0
Age
27
Location
Magnolia, Fiore
XP
316
Country
Don't know if it's standard C or if it is compiler dependant (should be ANSI C) , but usually false is 0, so that a NULL pointer (= 0 address) can be evaluated as false.

Any value !0 is evaluated to true.

To define a bool type with a conventional value for true, it s a good choice to select the value -1 defining the bool type as a signed numeral (usually s32), so it's easy to swap between true and false with the ~ operator (true == ~false only and only if true is a signed value set at -1, i.e. all bit set).
I was trying yo remove the compiler warning (here) so, if I have understood you, I have to change "res == -1" to "res"?
 

RocketRobz

Stylish TWiLight Hero
Developer
Joined
Oct 1, 2010
Messages
16,648
Trophies
3
Age
24
XP
21,115
Country
United States
I removed sftdlib from TWLoader, and replaced it with citro3D for rendering text in the system font.
With citro, the text shows up just fine, but after a second, the text disappears.
Am I missing something?
 
Last edited by RocketRobz,

elhobbs

Well-Known Member
Member
Joined
Jul 28, 2008
Messages
1,044
Trophies
1
XP
3,034
Country
United States
I removed sftdlib from TWLoader, and replaced it with citro3D for rendering text in the system font.
With citro, the text shows up just fine, but after a second, the text disappears.
Am I missing something?
The text.
Seriously though - without some code no one will be able to help you. Because clearly you are doing something wrong.
 

RocketRobz

Stylish TWiLight Hero
Developer
Joined
Oct 1, 2010
Messages
16,648
Trophies
3
Age
24
XP
21,115
Country
United States
The text.
Seriously though - without some code no one will be able to help you. Because clearly you are doing something wrong.
There's this at the beginning of int main, which inits Citro3D.
Code:
    C3D_Init(C3D_DEFAULT_CMDBUF_SIZE);
    if (logEnabled)    LogFM("Main.C3D_Init", "Citro3D inited");

    // Initialize the render target
    C3D_RenderTarget* target = C3D_RenderTargetCreate(240, 400, GPU_RB_RGBA8, GPU_RB_DEPTH24_STENCIL8);
    C3D_RenderTargetSetClear(target, C3D_CLEAR_ALL, CLEAR_COLOR, 0);

    printf("System font example\n");
    Result res = fontEnsureMapped();

    if (R_FAILED(res))
        printf("fontEnsureMapped: %08lX\n", res);

    sceneInit();

And I replaced the sftd draw text functions with citro's renderText function, along with setTextColor, which sets the following text's color.
That's all I did.
 

elhobbs

Well-Known Member
Member
Joined
Jul 28, 2008
Messages
1,044
Trophies
1
XP
3,034
Country
United States
There's this at the beginning of int main, which inits Citro3D.
Code:
    C3D_Init(C3D_DEFAULT_CMDBUF_SIZE);
    if (logEnabled)    LogFM("Main.C3D_Init", "Citro3D inited");

    // Initialize the render target
    C3D_RenderTarget* target = C3D_RenderTargetCreate(240, 400, GPU_RB_RGBA8, GPU_RB_DEPTH24_STENCIL8);
    C3D_RenderTargetSetClear(target, C3D_CLEAR_ALL, CLEAR_COLOR, 0);

    printf("System font example\n");
    Result res = fontEnsureMapped();

    if (R_FAILED(res))
        printf("fontEnsureMapped: %08lX\n", res);

    sceneInit();

And I replaced the sftd draw text functions with citro's renderText function, along with setTextColor, which sets the following text's color.
That's all I did.
Which is why it does not work. Take a look at one of the minimal citro3d examples for the pieces you are missing. There are begin and end frame functions you need to be calling. https://github.com/devkitPro/3ds-examples/tree/master/graphics/gpu/simple_tri
 

RocketRobz

Stylish TWiLight Hero
Developer
Joined
Oct 1, 2010
Messages
16,648
Trophies
3
Age
24
XP
21,115
Country
United States
Which is why it does not work. Take a look at one of the minimal citro3d examples for the pieces you are missing. There are begin and end frame functions you need to be calling. https://github.com/devkitPro/3ds-examples/tree/master/graphics/gpu/simple_tri
Is this right?
Code:
                    C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
                    textVtxArrayPos = 0; // Clear the text vertex array
                    // Update the uniforms
                    C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, uLoc_projection, &projection);
                    sf2d_start_frame(GFX_TOP, (gfx3dSide_t)topfb);
                    // --> Draw textures and (by Citro3D) text <--
                    sf2d_end_frame();
                    C3D_FrameEnd(0);
Text still disappears. :(
I'm kinda new to using Citro with other graphic libs.
 
Last edited by RocketRobz,

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
  • BigOnYa @ BigOnYa:
    Biomutant looks cool tho, may have to try that
  • Quincy @ Quincy:
    Usually when such a big title leaks the Temp will be the first to report about it (going off of historical reports here, Pokemon SV being the latest one I can recall seeing pop up here)
  • K3Nv2 @ K3Nv2:
    I still like how a freaking mp3 file hacks webos all that security defeated by text yet again
  • BigOnYa @ BigOnYa:
    They have simulators for everything nowdays, cray cray. How about a sim that shows you playing the Switch.
  • K3Nv2 @ K3Nv2:
    That's called yuzu
    +1
  • BigOnYa @ BigOnYa:
    I want a 120hz 4k tv but crazy how more expensive the 120hz over the 60hz are. Or even more crazy is the price of 8k's.
  • K3Nv2 @ K3Nv2:
    No real point since movies are 30fps
  • BigOnYa @ BigOnYa:
    Not a big movie buff, more of a gamer tbh. And Series X is 120hz 8k ready, but yea only 120hz 4k games out right now, but thinking of in the future.
  • K3Nv2 @ K3Nv2:
    Mostly why you never see TV manufacturers going post 60hz
  • BigOnYa @ BigOnYa:
    I only watch tv when i goto bed, it puts me to sleep, and I have a nas drive filled w my fav shows so i can watch them in order, commercial free. I usually watch Married w Children, or South Park
  • K3Nv2 @ K3Nv2:
    Stremio ruined my need for nas
  • BigOnYa @ BigOnYa:
    I stream from Nas to firestick, one on every tv, and use Kodi. I'm happy w it, plays everything. (I pirate/torrent shows/movies on pc, and put on nas)
  • K3Nv2 @ K3Nv2:
    Kodi repost are still pretty popular
  • BigOnYa @ BigOnYa:
    What the hell is Kodi reposts? what do you mean, or "Wut?" -xdqwerty
  • K3Nv2 @ K3Nv2:
    Google them basically web crawlers to movie sites
  • BigOnYa @ BigOnYa:
    oh you mean the 3rd party apps on Kodi, yea i know what you mean, yea there are still a few cool ones, in fact watched the new planet of the apes movie other night w wifey thru one, was good pic surprisingly, not a cam
  • BigOnYa @ BigOnYa:
    Damn, only $2.06 and free shipping. Gotta cost more for them to ship than $2.06
  • BigOnYa @ BigOnYa:
    I got my Dad a firestick for Xmas and showed him those 3rd party sites on Kodi, he loves it, all he watches anymore. He said he has got 3 letters from AT&T already about pirating, but he says f them, let them shut my internet off (He wants out of his AT&T contract anyways)
  • K3Nv2 @ K3Nv2:
    That's where stremio comes to play never got a letter about it
  • BigOnYa @ BigOnYa:
    I just use a VPN, even give him my login and password so can use it also, and he refuses, he's funny.
  • BigOnYa @ BigOnYa:
    I had to find and get him an old style flip phone even without text, cause thats what he wanted. No text, no internet, only phone calls. Old, old school.
    K3Nv2 @ K3Nv2: @BigOnYa...