filfat

WiiU console output

Apr 8th, 2015
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.64 KB | None | 0 0
  1. #include "coreinit.h"
  2. #define snprintf __os_snprintf
  3.  
  4. struct vector2D {
  5.     int x,y;
  6. };
  7.  
  8. struct vector2D consoleCursor = {0,0};
  9.  
  10. unsigned int net_handle;
  11. unsigned int core_handle;
  12. char consoleOutput[20048];
  13.  
  14. void clearScreen() {
  15.     unsigned int(*OSScreenClearBufferEx)(unsigned int bufferNum, unsigned int temp);
  16.     OSDynLoad_FindExport(core_handle, 0, "OSScreenClearBufferEx", &OSScreenClearBufferEx);
  17.     unsigned int colour = (37 << 24) | (164 << 16) | (214 << 8) | 255;
  18.     OSScreenClearBufferEx(0, colour);
  19.     OSScreenClearBufferEx(1, colour);
  20. }
  21.  
  22. void flipBuffers() {
  23.     void(*DCFlushRange)(void *buffer, unsigned int length);
  24.     unsigned int(*OSScreenFlipBuffersEx)(unsigned int bufferNum);
  25.     OSDynLoad_FindExport(core_handle, 0, "DCFlushRange", &DCFlushRange);
  26.     OSDynLoad_FindExport(core_handle, 0, "OSScreenFlipBuffersEx", &OSScreenFlipBuffersEx);
  27.     unsigned int(*OSScreenGetBufferSizeEx)(unsigned int bufferNum);
  28.     OSDynLoad_FindExport(core_handle, 0, "OSScreenGetBufferSizeEx", &OSScreenGetBufferSizeEx);
  29.     //Grab the buffer size for each screen (TV and gamepad)
  30.     int buf0_size = OSScreenGetBufferSizeEx(0);
  31.     int buf1_size = OSScreenGetBufferSizeEx(1);
  32.     //Flush the caches
  33.     DCFlushRange((void *)0xF4000000 + buf0_size, buf1_size);
  34.     DCFlushRange((void *)0xF4000000, buf0_size);
  35.     //Flip the buffers
  36.     OSScreenFlipBuffersEx(0);
  37.     OSScreenFlipBuffersEx(1);
  38. }
  39.  
  40. void exit(char* log);
  41. void _start();
  42. void console(char* output);
  43.  
  44. void _start() {
  45.    
  46.     /* Load a good stack */
  47.       asm(
  48.           "lis %r1, 0x1ab5 ;"
  49.           "ori %r1, %r1, 0xd138 ;"
  50.       );
  51.      
  52.     char debug[256];
  53.     OSDynLoad_Acquire("nlibcurl.rpl", &net_handle);
  54.     OSDynLoad_Acquire("coreinit.rpl", &core_handle);
  55.    
  56.     snprintf(debug, 255, "Console Demo By @filfat");
  57.     console(debug);
  58.    
  59.     //CURL* (*curl_easy_init)(void);
  60.     char* (*curl_version)(void);
  61.    
  62.     //OSDynLoad_FindExport(net_handle, 0, "curl_easy_init", &curl_easy_init);
  63.     OSDynLoad_FindExport(net_handle, 0, "curl_version", &curl_version);
  64.    
  65.     snprintf(debug, 255, "The cURL version of this console is: %s\n", curl_version());
  66.     console(debug);
  67.    
  68.     while(1){}
  69. }
  70.  
  71. void console(char* output) {
  72.     flipBuffers();
  73.     clearScreen();
  74.     unsigned int (*OSScreenPutFontEx)(unsigned int bufferNum, unsigned int posX, unsigned int posY, void* buffer);
  75.     OSDynLoad_FindExport(core_handle, 0, "OSScreenPutFontEx", &OSScreenPutFontEx);
  76.     snprintf(consoleOutput,20048,"%s%s",consoleOutput, output);
  77.     OSScreenPutFontEx(0, consoleCursor.x, consoleCursor.y, consoleOutput);
  78.     OSScreenPutFontEx(1, consoleCursor.x, consoleCursor.y, consoleOutput);
  79.     consoleCursor.y += 25;
  80. }
  81.  
  82. void exit(char* log) {
  83.     //Let's Print the output and halt the system
  84.     OSFatal(log);
  85. }
Advertisement
Add Comment
Please, Sign In to add comment