Want to code something for Wii?

Chat about just about anything else
Forum rules
Do not post support questions here. Before you post read the forum rules. Topics in this forum are automatically closed 30 days after creation.
Locked
metroid_maniac

Want to code something for Wii?

Post by metroid_maniac »

http://www.wiibrew.org/wiki/Main_Page

It's all about running unlicensed software on the Wii. Anyone can code for it now. And what's more, it has a (rather crappy) Linux loading thingy. Check it out, it's quite interesting.
Last edited by LockBot on Wed Dec 07, 2022 4:01 am, edited 1 time in total.
Reason: Topic automatically closed 30 days after creation. New replies are no longer allowed.
piratesmack

Re: Want to code something for Wii?

Post by piratesmack »

:P http://gbatemp.net/index.php?showtopic= ... try2198999 :P

Code: Select all

#include <stdio.h>
#include <stdlib.h>
#include <gccore.h>
#include <wiiuse/wpad.h>
#include <time.h>

static void *xfb = NULL;
static GXRModeObj *rmode = NULL;

void random_seed(void) {
    srand((unsigned)time(NULL));
}

int randomz(void) {
    random_seed();
    int ret = rand();
    return ret;
}

//---------------------------------------------------------------------------------
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();


    // The console understands VT terminal escape codes
    // This positions the cursor on row 2, column 0
    // we can use variables for this with format codes too
    // e.g. printf ("\x1b[%d;%dH", row, column );
    printf("\x1b[2;0H");
    

    printf("Hmm... it seems to me that you are a pirate.\n");
    printf("Press Home to exit");

    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 ) break;

        // Wait for the next frame
        VIDEO_WaitVSync();
    }

    int x, random;
    
    for(x=0;x<1E6;x++) {
        random = randomz();
        printf("%d", random);
    }

    return 0;
}
metroid_maniac

Re: Want to code something for Wii?

Post by metroid_maniac »

I think it's cool that you can run Linux on the Wii, and it's going to be a whole lot more eficient with the release of MIKE
Locked

Return to “Open Chat”