Beispiel #1
0
u32 ProcessEntry(MenuEntry* entry)
{
    bool emunand    = entry->param & N_EMUNAND;
    bool nand_force = entry->param & N_FORCEEMU;
    bool nand_write = entry->param & N_NANDWRITE;
    bool a9lh_write = (entry->param & N_A9LHWRITE) && ((*(u32*) 0x101401C0) == 0);
    
    u32 pad_state;
    u32 res = 0;
    
    // unlock sequence for dangerous features
    if (nand_write || a9lh_write) {
        const u32 unlockSequences[3][5] = {
            { BUTTON_LEFT , BUTTON_RIGHT, BUTTON_DOWN , BUTTON_UP   , BUTTON_A }, // EmuNAND
            { BUTTON_LEFT , BUTTON_UP   , BUTTON_RIGHT, BUTTON_UP   , BUTTON_A }, // SysNAND
            { BUTTON_RIGHT, BUTTON_DOWN , BUTTON_LEFT , BUTTON_DOWN , BUTTON_A }  // A9LH
        };
        const u32 unlockLvlMax = 5;
        u32* unlockSequence = (u32*) &(unlockSequences[(emunand) ? 0 : (a9lh_write) ? 2 : 1]);
        u32 warnColor = (emunand) ? COLOR_YELLOW : COLOR_RED;
        u32 unlockLvl = 0;
        #ifdef USE_THEME
        LoadThemeGfx((emunand) ? GFX_DANGER_E : GFX_DANGER_S, false);
        #endif
        DebugClear();
        Debug("You selected [%s].", entry->name);
        Debug("");
        if (!a9lh_write) {
            DebugColor(warnColor, "This feature writes to the %s.", (emunand) ? "EmuNAND" : "SysNAND");
            DebugColor(warnColor, "This may overwrite important data!");
        } else {
            DebugColor(warnColor, "!!! THIS WILL OVERWRITE THE A9LH !!!");
            DebugColor(warnColor, "!!! INSTALLATION IN YOUR SYSNAND !!!");
        }
        Debug("");
        Debug("If you wish to proceed, enter:");
        Debug((emunand) ? "<Left>, <Right>, <Down>, <Up>, <A>" : (a9lh_write) ? "<Right>, <Down>, <Left>, <Down>, <A>" : 
            "<Left>, <Up>, <Right>, <Up>, <A>");
        Debug("");
        Debug("(B to return, START to reboot)");
        while (true) {
            ShowProgress(unlockLvl, unlockLvlMax);
            if (unlockLvl == unlockLvlMax)
                break;
            pad_state = InputWait();
            if (!(pad_state & BUTTON_ANY))
                continue;
            else if (pad_state & unlockSequence[unlockLvl])
                unlockLvl++;
            else if (pad_state & (BUTTON_B | BUTTON_START))
                break;
            else if (unlockLvl == 0 || !(pad_state & unlockSequence[unlockLvl-1]))
                unlockLvl = 0;
        }
        ShowProgress(0, 0);
        if (unlockLvl < unlockLvlMax)
            return pad_state;
    }
    
    // execute this entries function
    #ifdef USE_THEME
    LoadThemeGfx(GFX_PROGRESS, false);
    #endif
    DebugClear();
    Debug("Selected: [%s]", entry->name);
    res = (SetNand(emunand, nand_force) == 0) ? (*(entry->function))(entry->param) : 1;
    DebugColor((res == 0) ? COLOR_GREEN : COLOR_RED, "%s: %s!", entry->name, (res == 0) ? "succeeded" : "failed");
    Debug("");
    Debug("Press B to return, START to reboot.");
    #ifdef USE_THEME
    LoadThemeGfx((res == 0) ? GFX_DONE : GFX_FAILED, false);
    #endif
    while(!((pad_state = InputWait()) & (BUTTON_B | BUTTON_START))) {
        if (pad_state & BUTTON_X) Screenshot(NULL);
        #ifdef LOG_FILE
        else if (pad_state & BUTTON_UP) {
            pad_state = ScrollOutput();
            break;
        }
        #endif
    }
    
    // returns the last known pad_state
    return pad_state;
}
Beispiel #2
0
u32 ProcessEntry(MenuEntry* entry)
{
    bool emunand    = entry->param & N_EMUNAND;
    bool nand_force = entry->param & N_FORCEEMU;
    bool nand_write = entry->param & N_NANDWRITE;
    bool a9lh_write = (entry->param & N_A9LHWRITE) && ((*(u32*) 0x101401C0) == 0);

    u32 pad_state;
    u32 res = 0;

    // unlock sequence for dangerous features
    if (nand_write || a9lh_write) {
        const u32 unlockSequences[3][5] = {
            { BUTTON_LEFT , BUTTON_RIGHT, BUTTON_DOWN , BUTTON_UP   , BUTTON_A }, // EmuNAND
            { BUTTON_LEFT , BUTTON_UP   , BUTTON_RIGHT, BUTTON_UP   , BUTTON_A }, // SysNAND
            { BUTTON_RIGHT, BUTTON_DOWN , BUTTON_LEFT , BUTTON_DOWN , BUTTON_A }  // A9LH
        };
        const u32 unlockLvlMax = 5;
        u32* unlockSequence = (u32*) &(unlockSequences[(emunand) ? 0 : (a9lh_write) ? 2 : 1]);
        u32 warnColor = (emunand) ? COLOR_YELLOW : COLOR_RED;
        u32 unlockLvl = 0;
        #ifdef USE_THEME
        LoadThemeGfx((emunand) ? GFX_DANGER_E : GFX_DANGER_S, false);
        #endif
        DebugClear();
        Debug("Has seleccionado [%s].", entry->name);
        Debug("");
        if (!a9lh_write) {
            DebugColor(warnColor, "Esta operacion escribira datos en %s.", (emunand) ? "EmuNAND" : "SysNAND");
            DebugColor(warnColor, "¡Esto puede sobreescribir datos importantes!");
        } else {
            DebugColor(warnColor, "ESTO SOBREESCRIBIRA LA INSTALACION!!!");
            DebugColor(warnColor, "DE A9LH EN TU SYSNAND!!!");
        }
        Debug("");
        Debug("Si decides continuar, presiona los siguientes botones:");
        Debug((emunand) ? "<Izquierda>, <Derecha>, <Abajo>, <Arriba>, <A>" : (a9lh_write) ? "<Derecha>, <Abajo>, <Izquierda>, <Abajo>, <A>" :
            "<Izquierda>, <Arriba>, <Derecha>, <Arriba>, <A>");
        Debug("");
        Debug("(B para volver, START para reiniciar)");
        while (true) {
            ShowProgress(unlockLvl, unlockLvlMax);
            if (unlockLvl == unlockLvlMax)
                break;
            pad_state = InputWait();
            if (!(pad_state & BUTTON_ANY))
                continue;
            else if (pad_state & unlockSequence[unlockLvl])
                unlockLvl++;
            else if (pad_state & (BUTTON_B | BUTTON_START))
                break;
            else if (unlockLvl == 0 || !(pad_state & unlockSequence[unlockLvl-1]))
                unlockLvl = 0;
        }
        ShowProgress(0, 0);
        if (unlockLvl < unlockLvlMax)
            return pad_state;
    }

    // execute this entries function
    #ifdef USE_THEME
    LoadThemeGfx(GFX_PROGRESS, false);
    #endif
    DebugClear();
    Debug("Seleccionado: [%s]", entry->name);
    res = (SetNand(emunand, nand_force) == 0) ? (*(entry->function))(entry->param) : 1;
    DebugColor((res == 0) ? COLOR_GREEN : COLOR_RED, "%s: %s!", entry->name, (res == 0) ? "succeeded" : "failed");
    Debug("");
    Debug("B para volver, START para reiniciar.");
    #ifdef USE_THEME
    LoadThemeGfx((res == 0) ? GFX_DONE : GFX_FAILED, false);
    #endif
    while(!((pad_state = InputWait()) & (BUTTON_B | BUTTON_START))) {
        if (pad_state & BUTTON_X) Screenshot(NULL);
        #ifdef LOG_FILE
        else if (pad_state & BUTTON_UP) {
            pad_state = ScrollOutput();
            break;
        }
        #endif
    }

    // returns the last known pad_state
    return pad_state;
}