Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "coreinit.h"
- #define snprintf __os_snprintf
- struct vector2D {
- int x,y;
- };
- struct vector2D consoleCursor = {0,0};
- unsigned int net_handle;
- unsigned int core_handle;
- char consoleOutput[20048];
- void clearScreen() {
- 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);
- }
- void flipBuffers() {
- 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);
- //Grab the buffer size for each screen (TV and gamepad)
- int buf0_size = OSScreenGetBufferSizeEx(0);
- int buf1_size = OSScreenGetBufferSizeEx(1);
- //Flush the caches
- DCFlushRange((void *)0xF4000000 + buf0_size, buf1_size);
- DCFlushRange((void *)0xF4000000, buf0_size);
- //Flip the buffers
- OSScreenFlipBuffersEx(0);
- OSScreenFlipBuffersEx(1);
- }
- void exit(char* log);
- void _start();
- void console(char* output);
- void _start() {
- /* Load a good stack */
- asm(
- "lis %r1, 0x1ab5 ;"
- "ori %r1, %r1, 0xd138 ;"
- );
- char debug[256];
- OSDynLoad_Acquire("nlibcurl.rpl", &net_handle);
- OSDynLoad_Acquire("coreinit.rpl", &core_handle);
- snprintf(debug, 255, "Console Demo By @filfat");
- console(debug);
- //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(debug);
- while(1){}
- }
- void console(char* output) {
- flipBuffers();
- clearScreen();
- unsigned int (*OSScreenPutFontEx)(unsigned int bufferNum, unsigned int posX, unsigned int posY, void* buffer);
- OSDynLoad_FindExport(core_handle, 0, "OSScreenPutFontEx", &OSScreenPutFontEx);
- snprintf(consoleOutput,20048,"%s%s",consoleOutput, output);
- OSScreenPutFontEx(0, consoleCursor.x, consoleCursor.y, consoleOutput);
- OSScreenPutFontEx(1, consoleCursor.x, consoleCursor.y, consoleOutput);
- 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