Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "coreinit.h"
- #define snprintf __os_snprintf
- struct vector2D {
- unsigned int x,y;
- };
- //Fills the screen with a flat blue colour
- void clearScreen(unsigned int core_handle) {
- unsigned int(*OSScreenClearBufferEx)(unsigned int bufferNum, unsigned int temp);
- OSDynLoad_FindExport(core_handle, 0, "OSScreenClearBufferEx", &OSScreenClearBufferEx);
- unsigned int colour = (37 << 24) | (164 << 16) | (214 << 8) | 255;
- OSScreenClearBufferEx(0, colour);
- OSScreenClearBufferEx(1, colour);
- }
- //Flip the buffers
- void flipBuffers(unsigned int core_handle) {
- /* taken from Relys's libwiiu as i'm go lazy to re-code it :P */
- void(*DCFlushRange)(void *buffer, unsigned int length);
- unsigned int(*OSScreenFlipBuffersEx)(unsigned int bufferNum);
- OSDynLoad_FindExport(core_handle, 0, "DCFlushRange", &DCFlushRange);
- OSDynLoad_FindExport(core_handle, 0, "OSScreenFlipBuffersEx", &OSScreenFlipBuffersEx);
- unsigned int(*OSScreenGetBufferSizeEx)(unsigned int bufferNum);
- OSDynLoad_FindExport(core_handle, 0, "OSScreenGetBufferSizeEx", &OSScreenGetBufferSizeEx);
- int buf0_size = OSScreenGetBufferSizeEx(0);
- int buf1_size = OSScreenGetBufferSizeEx(1);
- DCFlushRange((void *)0xF4000000 + buf0_size, buf1_size);
- DCFlushRange((void *)0xF4000000, buf0_size);
- OSScreenFlipBuffersEx(0);
- OSScreenFlipBuffersEx(1);
- }
- void exit(char* log);
- void console(unsigned int core_handle, char* output, char* consoleBuffer, struct vector2D consoleCursor);
- void _start() {
- /* Load a good stack */
- asm(
- "lis %r1, 0x1ab5 ;"
- "ori %r1, %r1, 0xd138 ;"
- );
- struct vector2D consoleCursor = {0,0};
- unsigned int net_handle;
- unsigned int core_handle;
- char consoleBuffer[20048];
- char debug[256];
- OSDynLoad_Acquire("nlibcurl.rpl", &net_handle);
- OSDynLoad_Acquire("coreinit.rpl", &core_handle);
- snprintf(debug, 255, "Console Demo By @filfat");
- console(core_handle, debug, consoleBuffer, consoleCursor);
- //CURL* (*curl_easy_init)(void);
- char* (*curl_version)(void);
- //OSDynLoad_FindExport(net_handle, 0, "curl_easy_init", &curl_easy_init);
- OSDynLoad_FindExport(net_handle, 0, "curl_version", &curl_version);
- snprintf(debug, 255, "The cURL version of this console is: %s\n", curl_version());
- console(core_handle, debug, consoleBuffer, consoleCursor);
- while(1){
- }
- exit("You shouldn't be here\nGo back to the loop gwad damn it! :P");
- }
- void console(unsigned int core_handle, char* output, char* consoleBuffer, struct vector2D consoleCursor) {
- flipBuffers(core_handle);
- clearScreen(core_handle);
- unsigned int (*OSScreenPutFontEx)(unsigned int bufferNum, unsigned int posX, unsigned int posY, void* buffer);
- OSDynLoad_FindExport(core_handle, 0, "OSScreenPutFontEx", &OSScreenPutFontEx);
- snprintf(consoleBuffer,20048,"%s%s",consoleBuffer, output);
- OSScreenPutFontEx(0, consoleCursor.x, consoleCursor.y, consoleBuffer);
- OSScreenPutFontEx(1, consoleCursor.x, consoleCursor.y, consoleBuffer);
- //consoleCursor.y += 25;
- }
- void exit(char* log) {
- //Let's Print the output and halt the system
- OSFatal(log);
- }
Advertisement
Add Comment
Please, Sign In to add comment