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,032
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,032
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,594
Trophies
3
Age
24
XP
20,991
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,032
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,594
Trophies
3
Age
24
XP
20,991
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,032
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,594
Trophies
3
Age
24
XP
20,991
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
    S @ salazarcosplay: though if it s important to go online for a game I would much rather buy it