Hacking Gamepad drawString problems

  • Thread starter Thread starter hugofestA
  • Start date Start date
  • Views Views 1,849
  • Replies Replies 16
You're missing flipBuffers() that's the problem.
Code:
void _start()
{
   fillScreenTV(0,0,0,0);
   drawStringTV(0, 0, "Restart your Wii U.\n\n\n\n\nSorry.")
   flipBuffers();
}
 
Oh freak. Thanks.
1. What does flipBuffers do?
2. What if I want it to be on the gamepad?
I don't know the technical reason why you need flipBuffers(), but it's always required when drawing stuff. Take a look at some source code of other apps and study how the program actually works. It will give you a good steady boost of knowledge of how to actually code a homebrew app.
 
I don't know the technical reason why you need flipBuffers(), but it's always required when drawing stuff. Take a look at some source code of other apps and study how the program actually works. It will give you a good steady boost of knowledge of how to actually code a homebrew app.
What if I want it to be on the gamepad?
Just change drawStringTV and fillScreenTV to drawString and fillScreen?
 
What if I want it to be on the gamepad?
Just change drawStringTV and fillScreenTV to drawString and fillScreen?
Oh god, I forgot. I'm using my own custom drawing library so it wouldn't be like that. It'd just be drawString in your average libwiiu. :wink:

for you, I'd add this code into draw.c in libwiiu/src/draw.c if you want to just draw a string to the GamePad:

Code:
void drawStringGamePad(int x, int line, char * string)
{
   unsigned int coreinit_handle;
   OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle);
   unsigned int(*OSScreenPutFontEx)(unsigned int bufferNum, unsigned int posX, unsigned int line, void * buffer);
   OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenPutFontEx", &OSScreenPutFontEx);
   OSScreenPutFontEx(1, x, line, string);
}
 
Oh god, I forgot. I'm using my own custom drawing library so it wouldn't be like that. It'd just be drawString in your average libwiiu. :wink:

for you, I'd add this code into draw.c in libwiiu/src/draw.c if you want to just draw a string to the GamePad:

Code:
void drawStringGamePad(int x, int line, char * string)
{
   unsigned int coreinit_handle;
   OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle);
   unsigned int(*OSScreenPutFontEx)(unsigned int bufferNum, unsigned int posX, unsigned int line, void * buffer);
   OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenPutFontEx", &OSScreenPutFontEx);
   OSScreenPutFontEx(1, x, line, string);
}
And for the TV? :3
 
I think you can't to that whith os_screen functions. You have to use GX2 lib if you want to draw something different on tv and gamepad.
 
And for the TV? :3
Code:
void drawStringTV(int x, int line, char * string)
{
   unsigned int coreinit_handle;
   OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle);
   unsigned int(*OSScreenPutFontEx)(unsigned int bufferNum, unsigned int posX, unsigned int line, void * buffer);
   OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenPutFontEx", &OSScreenPutFontEx);
   OSScreenPutFontEx(0, x, line, string);
}

Notice any difference between the two functions?
 
Code:
void drawStringTV(int x, int line, char * string)
{
   unsigned int coreinit_handle;
   OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle);
   unsigned int(*OSScreenPutFontEx)(unsigned int bufferNum, unsigned int posX, unsigned int line, void * buffer);
   OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenPutFontEx", &OSScreenPutFontEx);
   OSScreenPutFontEx(0, x, line, string);
}

Notice any difference between the two functions?
Yes, for TV it's:
Code:
OSScreenPutFontEx(0, x, line, string);
And for gamepad it's:
Code:
OSScreenPutFontEx(1, x, line, string);
:)
 
  • Like
Reactions: Deleted User
But why it's called bufferNum, if it's changing the display? :gun::yayu:

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

Can somebody tell it?
It's "double buffered", 0 is TV and 1 is Gamepad, think of it like a piece of paper, the program writes it on the bottom and you have to flip it over to see it. There's 2 pieces of paper, one for TV and one for Gamepad.
 
Oh god, I forgot. I'm using my own custom drawing library so it wouldn't be like that. It'd just be drawString in your average libwiiu. :wink:

for you, I'd add this code into draw.c in libwiiu/src/draw.c if you want to just draw a string to the GamePad:

Code:
void drawStringGamePad(int x, int line, char * string)
{
   unsigned int coreinit_handle;
   OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle);
   unsigned int(*OSScreenPutFontEx)(unsigned int bufferNum, unsigned int posX, unsigned int line, void * buffer);
   OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenPutFontEx", &OSScreenPutFontEx);
   OSScreenPutFontEx(1, x, line, string);
}
And for fillScreenTV and fillScreenGamePad?

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

And for fillScreenTV and fillScreenGamePad?
Oh! I figured it out! I just need to call OSClearBufferEx with 0 or 1 bufferNum!
 
Last edited by hugofestA,
You're missing flipBuffers() that's the problem.
Code:
void _start()
{
   fillScreenTV(0,0,0,0);
   drawStringTV(0, 0, "Restart your Wii U.\n\n\n\n\nSorry.")
   flipBuffers();
}
Do I need to run this in a loop, like this?
Code:
void _start()
{
    while(1){
        fillScreenTV(0,0,0,0);
        drawStringTV(0, 0, "Restart your Wii U.\n\n\n\n\nSorry.");
        flipBuffers();
    }
}

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

:gun::insert emoji of my profile picture here:
I'm so stupid.
Can somebody lock/delete these threads?
P.S.: Nobody said there's an osscreentemplates folder...
 
Last edited by hugofestA,
Do I need to run this in a loop, like this?
Code:
void _start()
{
    while(1){
        fillScreenTV(0,0,0,0);
        drawStringTV(0, 0, "Restart your Wii U.\n\n\n\n\nSorry.");
        flipBuffers();
    }
}

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

:gun::insert emoji of my profile picture here:
I'm so stupid.
Can somebody lock/delete these threads?
P.S.: Nobody said there's an osscreentemplates folder...
Nah, only need to call it once, the back buffer and front buffer won't change unless you run code to, that's just doing unnecessary work for the same result. and yeah, OSScreenTemplates is also pretty helpful. I should commit my old Mario sprite test there
 
  • Like
Reactions: hugofestA

Site & Scene News

Popular threads in this forum