C++ Noob Here :P August 29, 2008 06:02AM | Registered: 16 years ago Posts: 15 |
Re: C++ Noob Here :P August 29, 2008 06:40AM | Registered: 16 years ago Posts: 83 |
Re: C++ Noob Here :P August 29, 2008 06:53AM | Registered: 16 years ago Posts: 211 |
Re: C++ Noob Here :P August 29, 2008 03:16PM | Admin Registered: 16 years ago Posts: 5,132 |
Re: C++ Noob Here :P August 29, 2008 04:48PM | Registered: 16 years ago Posts: 15 |
Re: C++ Noob Here :P August 29, 2008 06:34PM | Registered: 16 years ago Posts: 83 |
#include#include #include #include #include #include static void *xfb = NULL; static GXRModeObj *rmode = NULL; void *Initialise(); int main(int argc, char **argv) { xfb = Initialise(); printf("\nHello World!\n"); while(1) { VIDEO_WaitVSync(); PAD_ScanPads(); int buttonsDown = PAD_ButtonsDown(0); if( buttonsDown & PAD_BUTTON_A ) { printf("Button A pressed.\n"); } if (buttonsDown & PAD_BUTTON_START) { exit(0); } } return 0; } void * Initialise() { void *framebuffer; VIDEO_Init(); PAD_Init(); rmode = VIDEO_GetPreferredMode(NULL); framebuffer = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); console_init(framebuffer,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ); VIDEO_Configure(rmode); VIDEO_SetNextFramebuffer(framebuffer); VIDEO_SetBlack(FALSE); VIDEO_Flush(); VIDEO_WaitVSync(); if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync(); return framebuffer; }
Re: C++ Noob Here :P August 29, 2008 10:14PM | Admin Registered: 16 years ago Posts: 5,132 |
Re: C++ Noob Here :P August 30, 2008 04:29AM | Registered: 16 years ago Posts: 211 |
Quote
template
#include
#include
#include
#include
#include
static void *xfb = NULL;
static GXRModeObj *rmode = NULL;
//---------------------------------------------------------------------------------
int main(int argc, char **argv) {
//---------------------------------------------------------------------------------
// Initialise the video system
VIDEO_Init();
// This function initialises the attached controllers
WPAD_Init();
// Obtain the preferred video mode from the system
// This will correspond to the settings in the Wii menu
rmode = VIDEO_GetPreferredMode(NULL);
// Allocate memory for the display in the uncached region
xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
// Initialise the console, required for printf
console_init(xfb,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ);
// Set up the video registers with the chosen mode
VIDEO_Configure(rmode);
// Tell the video hardware where our display memory is
VIDEO_SetNextFramebuffer(xfb);
// Make the display visible
VIDEO_SetBlack(FALSE);
// Flush the video register changes to the hardware
VIDEO_Flush();
// Wait for Video setup to complete
VIDEO_WaitVSync();
if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();
std::cout << "\x1b[2;0H";
std::cout << "Hello World!" << std::endl;
while(1) {
// Call WPAD_ScanPads each loop, this reads the latest controller states
WPAD_ScanPads();
// WPAD_ButtonsDown tells us which buttons were pressed in this loop
// this is a "one shot" state which will not fire again until the button has been released
u32 pressed = WPAD_ButtonsDown(0);
// We return to the launcher application via exit
if ( pressed & WPAD_BUTTON_HOME ) exit(0);
// Wait for the next frame
VIDEO_WaitVSync();
}
return 0;
}