drawString F R E E Z E

Discussion in 'Wii U - Hacking & Backup Loaders' started by hugofestA, Feb 27, 2016.

  1. hugofestA
    OP

    hugofestA Advanced Member

    Newcomer
    52
    7
    Feb 10, 2016
    Hungary
    mast:3rw0rld
    Hi!
    I have problems with drawstring(yes, again).
    The problem is the same, so:
    Code:
    fillScreen(0,0,0,0);
    drawString(1, 1, "Hello World! we haxd u");
    flipBuffers();
    
    After running this code, Wii U freezes, the .mp4 loading icon freezes, and the GamePad freezes too.
    I tried with my custom library, same problem:
    Code:
    //flipBuffers(int bufferNum)
    //This is for "executing drawing to the screen"
    //Think about it like a piece of paper
    //The program writes it to the bottom of the paper, so you need to flip it to see it
    //There are 2 pieces of paper: 1 for the GamePad, 1 for the TV.
    //bufferNums:
    //TV: 0
    //GamePad: 1
    void flipBuffers(unsigned int bufferNum){
      //"Including" coreinit module
      unsigned int coreinit_handle;
    OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle);
      //Setting functions
      void(*DCFlushRange)(void *buffer, uint32_t length);
    unsigned int(*OSScreenFlipBuffersEx)(unsigned int bufferNum);
    OSDynLoad_FindExport(coreinit_handle, 0, "DCFlushRange", &DCFlushRange);
    OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenFlipBuffersEx", &OSScreenFlipBuffersEx);
    unsigned int(*OSScreenGetBufferSizeEx)(unsigned int bufferNum);
    OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenGetBufferSizeEx", &OSScreenGetBufferSizeEx);
      //Grabbing the buffer size for the screen in bufferNum
      int buf_size = OSScreenGetBufferSizeEx(bufferNum);
      //Flushing cache
      DCFlushRange((void *)0xF4000000, buf_size);
      //Flipping the buffer
      OSScreenFlipBuffersEx(bufferNum);
    }
    
    //drawstring(unsigned int bufferNum, int x, int line, char * string)
    //Drawing a string
    //bufferNum = buffer number of display
    //x = position on x axis
    //line = line on y axis
    //string = text to print
    void drawString(unsigned int bufferNum, int x, int line, char * string)
    {
      //"Including" coreinit module
    unsigned int coreinit_handle;
    OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle);
      //Setting functions
    unsigned int(*OSScreenPutFontEx)(unsigned int bufferNum, unsigned int posX, unsigned int line, void * buffer);
    OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenPutFontEx", &OSScreenPutFontEx);
      //Drawing the string
    OSScreenPutFontEx(bufferNum, x, line, string);
    }
    //fillScreen(unsigned int bufferNum, char r,char g,char b,char a)
    //Filling screen
    //bufferNum = buffer number of display
    //r = amount of red
    //g = amount of green
    //b = amount of blue
    //a = ???(maybe darkness)
    void fillScreen(unsigned int bufferNum, char r,char g,char b,char a)
    {
      //"Including" coreinit module
    unsigned int coreinit_handle;
    OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle);
      //Setting functions
    unsigned int(*OSScreenClearBufferEx)(unsigned int bufferNum, unsigned int temp);
    OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenClearBufferEx", &OSScreenClearBufferEx);
      //Crafting a number from r, g, b and a
    uint32_t num = (r << 24) | (g << 16) | (b << 8) | a;
      //Filling screen (clearing buffer "with" a custom color)
    OSScreenClearBufferEx(bufferNum, num);
    }
    
    Can somebody help?
    Thanks,
    hugo

    Edit: SOLVED!!!
     
    Last edited by hugofestA, Feb 27, 2016
  2. NWPlayer123

    NWPlayer123 GBAtemp Addict

    Member
    2,629
    6,226
    Feb 17, 2012
    United States
    The Everfree Forest
    Are you sure it's drawString? The best thing you can do is keep putting _Exit() or OSFatal() to see how far it actually gets until it breaks
     
    vgmoose likes this.
  3. hugofestA
    OP

    hugofestA Advanced Member

    Newcomer
    52
    7
    Feb 10, 2016
    Hungary
    mast:3rw0rld
    Thanks! I will try it and post the results!
     
  4. hugofestA
    OP

    hugofestA Advanced Member

    Newcomer
    52
    7
    Feb 10, 2016
    Hungary
    mast:3rw0rld
    I tested it. It's drawstring.
     
  5. NWPlayer123

    NWPlayer123 GBAtemp Addict

    Member
    2,629
    6,226
    Feb 17, 2012
    United States
    The Everfree Forest
    Oh, I found your error, not enough arguments. You forgot the bufferNum, drawString(0, 1, 1, "Hello World! we haxd u"); //TV, at pos 1, 1
    I'd also include types.h and update your drawString types
    http://wiiubrew.org/wiki/Coreinit.rpl#Screen
    Code:
    void drawString(int bufferNum, uint32_t posX, uint32_t posY, const char *string)
    {
        uint32_t coreinit_handle;
        OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle); //Get handle
        void (*OSScreenPutFontEx)(int bufferNum, uint32_t posX, uint32_t posY, const char *string); //Define
        OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenPutFontEx", &OSScreenPutFontEx); //Obtain
        OSScreenPutFontEx(bufferNum, posX, posY, string); //Call
    }
    
     
  6. hugofestA
    OP

    hugofestA Advanced Member

    Newcomer
    52
    7
    Feb 10, 2016
    Hungary
    mast:3rw0rld
    No:
    Code:
    void drawString(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);
     OSScreenPutFontEx(1, x, line, string);
    }
    
     
  7. NWPlayer123

    NWPlayer123 GBAtemp Addict

    Member
    2,629
    6,226
    Feb 17, 2012
    United States
    The Everfree Forest
    That's a different snippet than in the OP, but then I don't see what else is wrong :\
     
  8. hugofestA
    OP

    hugofestA Advanced Member

    Newcomer
    52
    7
    Feb 10, 2016
    Hungary
    mast:3rw0rld
    Here's some stuff... :(
     

    Attached Files:

  9. hugofestA
    OP

    hugofestA Advanced Member

    Newcomer
    52
    7
    Feb 10, 2016
    Hungary
    mast:3rw0rld
    Oh wait! It's flipBuffers!
     
    NWPlayer123 likes this.