Exemple #1
0
int
main(int argc, char *argv[])
{
	InitVideo(); // Initialize video
	SetupPads(); // Initialize input
	//InitAudio(); // Initialize audio
	fatInitDefault(); // Initialize file system
	InitFreeType((u8*)font_ttf, font_ttf_size); // Initialize font system
	InitGUIThreads(); // Initialize GUI

	DefaultSettings();
	MainMenu(MENU_SETTINGS);
}
/****************************************************************************
 * MainMenu
 ***************************************************************************/
int MainMenu(int menu)
{
    currentMenu = menu;

    InitGUIThreads();

    InitProgressThread();
    InitNetworkThread();

    if (Settings.autonetwork)
        ResumeNetworkThread();

    btnSoundClick = new GuiSound(NULL, 0, Settings.sfxvolume);
    btnSoundClick->LoadSoundEffect(Resources::GetFile("button_click.wav"), Resources::GetFileSize("button_click.wav"));
    btnSoundClick2 = new GuiSound(NULL, 0, Settings.sfxvolume);
    btnSoundClick2->LoadSoundEffect(Resources::GetFile("button_click2.wav"), Resources::GetFileSize("button_click2.wav"));
    btnSoundOver = new GuiSound(NULL, 0, Settings.sfxvolume);
    btnSoundOver->LoadSoundEffect(Resources::GetFile("button_over.wav"), Resources::GetFileSize("button_over.wav"));

    pointer[0] = new WiiPointer("player1_point.png");
    pointer[1] = new WiiPointer("player2_point.png");
    pointer[2] = new WiiPointer("player3_point.png");
    pointer[3] = new WiiPointer("player4_point.png");

    mainWindow = new GuiWindow(screenwidth, screenheight);

    background = Resources::GetImageData(Settings.widescreen ? "wbackground.png" : "background.png");

    bgImg = new GuiImage(background);
    mainWindow->Append(bgImg);

    ResumeGui();

    bgMusic = new GuiBGM(Resources::GetFile("bg_music.ogg"), Resources::GetFileSize("bg_music.ogg"), Settings.volume);
    bgMusic->SetLoop(Settings.musicloopmode); //loop music
    bgMusic->Load(Settings.ogg_path);
    bgMusic->Play();

    MountGamePartition();

    while (currentMenu != MENU_EXIT)
    {
        bgMusic->SetVolume(Settings.volume);

        switch (currentMenu)
        {
        case MENU_SETTINGS:
            currentMenu = GlobalSettings::Execute();
            break;
        case MENU_THEMEMENU:
            currentMenu = ThemeMenu::Execute();
            break;
        //	case MENU_THEMEDOWNLOADER:
        //		currentMenu = ThemeDownloader::Execute();
        //		break;
        case MENU_HOMEBREWBROWSE:
            currentMenu = HomebrewBrowser::Execute();
            break;
        case MENU_DISCLIST:
        default: // unrecognized menu
            currentMenu = GameBrowseMenu::Execute();
            break;
        }
    }

    //! THIS SHOULD NEVER HAPPEN ANYMORE
    ExitApp();

    return -1;
}
Exemple #3
0
s32 main(s32 argc, const char* argv[])
{
    atexit(unload_modules);

    InitVideo(); // Initialize video
    SetupPads(); // Initialize input
#ifdef TOPORT
    InitAudio(); // Initialize audio
    fatInitDefault(); // Initialize file system
#endif
#ifdef TOPORT
    InitFreeType((u8*)font_ttf, font_ttf_size); // Initialize font system
    InitGUIThreads(); // Initialize GUI
    DefaultSettings();
    MainMenu(MENU_SETTINGS);
#endif

#ifdef PSL1GHT

    if(SysLoadModule(SYSMODULE_FS)!=0) return 0;
    else module_flag |=1;

    if(SysLoadModule(SYSMODULE_PNGDEC)!=0) return 0;
    else module_flag |=2;

#endif
    VideoModule * video = VideoModule::getVideoModule();

    InputPadModule * inpad = InputPadModule::getInputPadModule();

#ifdef PSL1GHT
    PngDatas png1;

    LoadPNG(&png1, (char *)"/dev_usb/PS3_GAME/ICON0.PNG");
#endif


    long frame = 0; // To keep track of how many frames we have rendered.

    int x = DEBUG_X, y = DEBUG_Y;


    // Ok, everything is setup. Now for the main loop.
    while(1) {
        char str [300];
        sprintf(str, "Pad number : %d, frame %d", (int) inpad->getPadNumber(),(int)frame);

        inpad->refreshPadConnections();
        // Check the pads.
        for( size_t i = 0; i < inpad->getPadNumber(); i++)
        {
            if( inpad->getPad(i)->isPressed( eAbsButUp) && y > 0)
                y--;
            if( inpad->getPad(i)->isPressed( eAbsButDown) && y < 1080)
                y++;
            if( inpad->getPad(i)->isPressed( eAbsButLeft) && x > 0)
                x--;
            if( inpad->getPad(i)->isPressed( eAbsButRight) && x > 0)
                x++;
            else if( inpad->getPad(i)->isPressed( eAbsButExecute))
                return 0;
        }
        sprintf(str, "Pad number : %d, frame %d", (int) inpad->getPadNumber(),(int)frame);

        video->waitFlip(); // Wait for the last flip to finish, so we can draw to the old buffer

#ifdef PSL1GHT
        drawFrame(video->getCurrentBuffer(), frame++); // Draw into the unused buffer

        if(png1.bmp_out) {
            video->displayBitmap( (u32 *)png1.bmp_out, png1.height, png1.width, png1.wpitch);
        }
#endif
        video->printf(x, y, str);

        video->flip(); // Flip buffer onto screen
    }

    return 0;
}
Exemple #4
0
int
main(int argc, char *argv[])
{
    setlocale(LC_ALL, "en.UTF-8");
    geckoinit = InitGecko();

    if (hbcStubAvailable() || geckoinit)
    {
        InitTextVideo();
    }

    //	DEBUG_Init(GDBSTUB_DEVICE_USB, 1);
    //_break();

    __exception_setreload(5);                     //auto reset code dump nobody gives us codedump info anyways.

    gprintf("\n\n------------------");
    gprintf("\nUSB Loader GX rev%s",GetRev());
    gprintf("\nmain(%d", argc);
    for (int i=0;i<argc;i++)
        gprintf(", %s",argv[i]?argv[i]:"<NULL>");
    gprintf(")");

    // This part is added, because we need a identify patched ios
//    printf("\n\tReloading into ios 236");
    if (IOS_ReloadIOSsafe(236) < 0)
    {
//        printf("\n\tIOS 236 not found, reloading into 36");
        IOS_ReloadIOSsafe(36);
    }

    printf("\n\tStarting up");

    MEM2_init(36);                                // Initialize 36 MB
    MEM2_takeBigOnes(true);

    s32 ret;
    bool startupproblem = false;

    bool bootDevice_found=false;
    if (argc >= 1)
    {
        if (!strncasecmp(argv[0], "usb:/", 5))
        {
            strcpy(bootDevice, "USB:");
            bootDevice_found = true;
        } else if (!strncasecmp(argv[0], "sd:/", 4))
        bootDevice_found = true;
    }

    printf("\n\tInitializing controllers");

    /** PAD_Init has to be before InitVideo don't move that **/
    PAD_Init();                                   // initialize PAD/WPAD

    printf("\n\tInitialize USB (wake up)");

    USBDevice_Init();                             // seems enough to wake up some HDDs if they are in sleep mode when the loader starts (tested with WD MyPassport Essential 2.5")

    gprintf("\n\tChecking for stub IOS");
    ios222rev = getIOSrev(0x00000001000000dell);
    ios249rev = getIOSrev(0x00000001000000f9ll);

    //if we don't like either of the cIOS then scram
    if (!(ios222rev==4 || ios222rev==5 || (ios249rev>=9 && ios249rev<65280)))
    {
        InitTextVideo();
        printf("\x1b[2J");
        if ((ios222rev < 0 && ios222rev != WII_EINSTALL) && (ios249rev < 0 && ios249rev != WII_EINSTALL))
        {
            printf("\n\n\n\tWARNING!");
            printf("\n\tUSB Loader GX needs unstubbed cIOS 222 v4 or 249 v9+");
            printf("\n\n\tWe cannot determine the versions on your system,\n\tsince you have no patched ios 36 or 236 installed.");
            printf("\n\tTherefor, if loading of USB Loader GX fails, you\n\tprobably have installed the 4.2 update,");
            printf("\n\tand you should go figure out how to get some cios action going on\n\tin your Wii.");
            printf("\n\n\tThis message will show every time.");
            sleep(5);
        }
        else
        {
            printf("\n\n\n\tERROR!");
            printf("\n\tUSB Loader GX needs unstubbed cIOS 222 v4 or 249 v9+");
            printf("\n\n\tI found \n\t\t222 = %d%s",ios222rev,ios222rev==65280?" (Stubbed by 4.2 update)":"");
            printf("\n\t\t249 = %d%s",ios249rev,ios249rev==65280?" (Stubbed by 4.2 update)":"");
            printf("\n\n\tGo figure out how to get some cIOS action going on\n\tin your Wii and come back and see me.");

            sleep(15);
            printf("\n\n\tBye");

            USBDevice_deInit();
            exit(0);
        }
    }

    printf("\n\tReloading ios 249...");
    ret = IOS_ReloadIOSsafe(249);

    printf("%d", ret);

    if (ret < 0)
    {
        printf("\n\tIOS 249 failed, reloading ios 222...");
        ret = IOS_ReloadIOSsafe(222);
        printf("%d", ret);

        if (ret < 0)
        {
            printf("\n\tIOS 222 failed, reloading ios 250...");
            ret = IOS_ReloadIOSsafe(250);
            printf("%d", ret);

            if(ret < 0)
            {
                printf("\n\tIOS 250 failed, reloading ios 223...");
                ret = IOS_ReloadIOSsafe(223);
                printf("%d", ret);

                if (ret < 0)
                {
                    printf("\n\tERROR: cIOS could not be loaded!\n");
                    sleep(5);
                    SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
                }
            }
        }
        printf("\n\tInitialize sd card");
        SDCard_Init();
        printf("\n\tLoad ehc module");
        load_ehc_module();
        printf("\n\tdeinit sd card");
        SDCard_deInit();
    }

    printf("\n\tInit wbfs...");
    ret = WBFS_Init(WBFS_DEVICE_USB);
    printf("%d", ret);

    if (ret < 0)
    {
        printf("\n\tYou have issues with a slow disc, or a difficult disc\n\tReloading 222...");
        ret = IOS_ReloadIOSsafe(222);
        printf("%d", ret);
        /*if(ret < 0) {
        //			printf("\n\tSleeping for 4 seconds");
        //			sleep(4);

            InitVideo(); // Initialise video
            Menu_Render();
            BootUpProblems();
            startupproblem = true;
            ret = 1;
        }*/
        printf("\n\tInitialize sd card");
        SDCard_Init();
        printf("\n\tLoad ehc module");
        load_ehc_module();
        printf("\n\tdeinit sd card");
        SDCard_deInit();

        printf("\n\tInitialize wbfs...");
        USBDevice_deInit();
        USBDevice_Init();
        ret = WBFS_Init(WBFS_DEVICE_USB);
        printf("%d", ret);

        if(ret < 0)
        {
            //			printf("\n\tSleeping for 4 seconds");
            //			sleep(4);
            InitVideo();                          // Initialise video
            Menu_Render();
            BootUpProblems();
            startupproblem = true;
            ret = 1;
        }
    }

    printf("\n\tInitialize sd card");
    SDCard_Init();                                // mount SD for loading cfg's

    //this should have already been done by now in order to WBFS_Init().
    printf("\n\tInitialize usb device");
    USBDevice_Init();                             // and mount USB:/

    if (!bootDevice_found)
    {
        printf("\n\tSearch for configuration file");

        //try USB
        //left in all the dol and elf files in this check in case this is the first time running the app and they dont have the config
        if (checkfile((char*) "USB:/config/GXglobal.cfg") || (checkfile((char*) "USB:/apps/usbloader_gx/boot.elf"))
            || checkfile((char*) "USB:/apps/usbloadergx/boot.dol") || (checkfile((char*) "USB:/apps/usbloadergx/boot.elf"))
            || checkfile((char*) "USB:/apps/usbloader_gx/boot.dol"))
            strcpy(bootDevice, "USB:");

        printf("\n\tConfiguration file is on %s", bootDevice);
    }

    // Try opening and closing the configuration file here
    // to prevent a crash dump later on - giantpune
    char GXGlobal_cfg[26];
    sprintf(GXGlobal_cfg, "%s/config/GXGlobal.cfg", bootDevice);
    FILE *fp = fopen(GXGlobal_cfg, "r");
    if (fp)
    {
        fclose(fp);
    }

    gettextCleanUp();
    printf("\n\tLoading configuration...");
    CFG_Load();
    printf("done");
    //	gprintf("\n\tbootDevice = %s",bootDevice);

    /* Load Custom IOS */
    if ((Settings.cios == ios222 && IOS_GetVersion() != 222) ||
        (Settings.cios == ios223 && IOS_GetVersion() != 223))
    {
        printf("\n\tReloading IOS to config setting (%d)...", Settings.cios == ios222 ? 222 : 223);
        SDCard_deInit();                          // unmount SD for reloading IOS
        USBDevice_deInit();                       // unmount USB for reloading IOS
        USBStorage2_Deinit();
        ret = IOS_ReloadIOSsafe(Settings.cios == ios222 ? 222 : 223);
        printf("%d", ret);
        SDCard_Init();
        load_ehc_module();
        if (ret < 0)
        {
            SDCard_deInit();
            Settings.cios = ios249;
            ret = IOS_ReloadIOSsafe(249);
            // now mount SD:/  //no need to keep mindlessly mounting and unmounting SD card
            SDCard_Init();
        }

        USBDevice_Init();                         // and mount USB:/
        WBFS_Init(WBFS_DEVICE_USB);
    } else if ((Settings.cios == ios249 && IOS_GetVersion() != 249) ||
        (Settings.cios == ios250 && IOS_GetVersion() != 250))
    {

        printf("\n\tReloading IOS to config setting (%d)...", ios249 ? 249 : 250);
        SDCard_deInit();                          // unmount SD for reloading IOS
        USBDevice_deInit();                       // unmount USB for reloading IOS
        USBStorage2_Deinit();
        ret = IOS_ReloadIOSsafe(ios249 ? 249 : 250);
        printf("%d", ret);
        if (ret < 0)
        {
            Settings.cios = ios222;
            ret = IOS_ReloadIOSsafe(222);
            SDCard_Init();
            load_ehc_module();
        }

        else SDCard_Init();                       // now mount SD:/  //no need to keep mindlessly mounting and unmounting SD card
        USBDevice_Init();                         // and mount USB:/
        WBFS_Init(WBFS_DEVICE_USB);
    }

    //	Partition_GetList(&partitions);

    if (ret < 0)
    {
        printf("\nERROR: cIOS could not be loaded!");
        sleep(5);
        exit(0);
        //SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
    }
    //gprintf("\n\tcIOS = %u (Rev %u)",IOS_GetVersion(), IOS_GetRevision());//don't need gprintf if sending console shit to gecko, too
    printf("\n\tcIOS = %u (Rev %u)",IOS_GetVersion(), IOS_GetRevision());

    //	printf("Sleeping for 5 seconds\n");
    //	sleep(5);

    //if a ID was passed via args copy it and try to boot it after the partition is mounted
    //its not really a headless mode.  more like hairless.
    if (argc > 1 && argv[1])
    {
        if (strlen(argv[1])==6)
            strncpy(headlessID, argv[1], sizeof(headlessID));
    }

    //! Init the rest of the System
    Sys_Init();
    Wpad_Init();
    if(!startupproblem)
        InitVideo();
    InitAudio();                                  // Initialize audio

    WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR);
    WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight);

    // load main font from file, or default to built-in font
    fontSystem = new FreeTypeGX();
    char *fontPath = NULL;
    asprintf(&fontPath, "%sfont.ttf", CFG.theme_path);
    fontSystem->loadFont(fontPath, font_ttf, font_ttf_size, 0);
    fontSystem->setCompatibilityMode(FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE);
    free(fontPath);

    fontClock = new FreeTypeGX();
    fontClock->loadFont(NULL, clock_ttf, clock_ttf_size, 0);
    fontClock->setCompatibilityMode(FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE);

    gprintf("\n\tEnd of Main()");
    InitGUIThreads();
    MainMenu(MENU_CHECK);
    return 0;
}