Exemplo n.º 1
0
void updateScreens(bool waitToFinish) {
    if (!gbsMode && !isMenuOn() && !isFileChooserOn() && scaleMode != 0) {
        // Manage screens in the case that scaling is enabled:
        sharedData->scalingOn = 1;

        // The VRAM used for the console will be overwritten, so...
        consoleInitialized = false;


        doAtVBlank(setupScaledScreens1);

        if (waitToFinish) {
            swiWaitForVBlank();
            swiWaitForVBlank();
        }
    }
    else {
        // Manage screens normally
        sharedData->scalingOn = 0;

        doAtVBlank(setupUnscaledScreens);
        if (waitToFinish)
            swiWaitForVBlank();
    }
}
Exemplo n.º 2
0
// 1 frame delay
void setupScaledScreens1() {
    powerOff(backlights[consoleScreen]);
    REG_DISPCNT_SUB &= ~(3<<16); // Disable sub display (for 1 frame. Gotta hide the ugliness...)

    // By next vblank, the scaled image will be ready.
    doAtVBlank(setupScaledScreens2);
}
Exemplo n.º 3
0
void setScaleModeFunc(int value) {
    scaleMode = value;
    if (!isMenuOn()) {
        updateScreens();
    }
    if (value == 0) {
        doAtVBlank(checkBorder);
        enableMenuOption("Console Output");
    }
    else {
        disableMenuOption("Console Output");
    }
}
Exemplo n.º 4
0
void setupUnscaledScreens() {
    int screensToSet[2];

    REG_DISPCNT &= ~(3<<16);
    REG_DISPCNT |= 1<<16; // Enable main display

    if (!consoleInitialized) {
        consoleDemoInit(); // Or, consoleInit(menuConsole, ...)
        setPrintConsole(menuConsole);
        BG_PALETTE_SUB[8*16 - 1] = RGB15(17,17,17); // Grey (replaces a color established in consoleDemoInit)
        consoleInitialized = true;
    }
    if (consoleScreen == 0)
        lcdMainOnBottom();
    else
        lcdMainOnTop();

    screensToSet[!consoleScreen] = true;

    if (!(fpsOutput || timeOutput || consoleDebugOutput || isMenuOn() || isFileChooserOn())) {
        screensToSet[consoleScreen] = false;
        REG_DISPCNT_SUB &= ~(3<<16); // Disable sub display
    }
    else {
        screensToSet[consoleScreen] = true;
        REG_DISPCNT_SUB &= ~(3<<16);
        REG_DISPCNT_SUB |= 1<<16; // Enable sub display
    }

    for (int i=0; i<2; i++) {
        if (screensToSet[i]) {
            if (i == consoleScreen)
                doAtVBlank(enableConsoleBacklight);
            else
                powerOn(backlights[i]);
        }
        else
            powerOff(backlights[i]);
    }
}
Exemplo n.º 5
0
void enableConsoleBacklight() {
    // For some reason, waiting 2 frames helps eliminate a white flash.
    doAtVBlank(enableConsoleBacklight2);
}
Exemplo n.º 6
0
void closeSubMenu() {
    subMenuUpdateFunc = NULL;
    doAtVBlank(redrawMenu);
}
Exemplo n.º 7
0
// Called each vblank while the menu is on
void updateMenu() {
    if (subMenuUpdateFunc != 0) {
        subMenuUpdateFunc();
        return;
    }

    bool redraw = false;
    // Get input
    if (keyPressedAutoRepeat(KEY_UP)) {
        option--;
        if (option < -1)
            option = menuList[menu].numOptions-1;
        redraw = true;
    }
    else if (keyPressedAutoRepeat(KEY_DOWN)) {
        option++;
        if (option >= menuList[menu].numOptions)
            option = -1;
        redraw = true;
    }
    else if (keyPressedAutoRepeat(KEY_LEFT)) {
        if (option == -1) {
            menu--;
            if (menu < 0)
                menu = numMenus-1;
        }
        else if (menuList[menu].options[option].numValues != 0 && menuList[menu].options[option].enabled) {
            int selection = menuList[menu].options[option].selection-1;
            if (selection < 0)
                selection = menuList[menu].options[option].numValues-1;
            menuList[menu].options[option].selection = selection;
            menuList[menu].options[option].function(selection);
        }
        redraw = true;
    }
    else if (keyPressedAutoRepeat(KEY_RIGHT)) {
        if (option == -1) {
            menu++;
            if (menu >= numMenus)
                menu = 0;
        }
        else if (menuList[menu].options[option].numValues != 0 && menuList[menu].options[option].enabled) {
            int selection = menuList[menu].options[option].selection+1;
            if (selection >= menuList[menu].options[option].numValues)
                selection = 0;
            menuList[menu].options[option].selection = selection;
            menuList[menu].options[option].function(selection);
        }
        redraw = true;
    }
    else if (keyJustPressed(KEY_A)) {
        forceReleaseKey(KEY_A);
        if (option >= 0 && menuList[menu].options[option].numValues == 0 && menuList[menu].options[option].enabled) {
            menuList[menu].options[option].function(menuList[menu].options[option].selection);
        }
        redraw = true;
    }
    else if (keyJustPressed(KEY_B)) {
        forceReleaseKey(KEY_B);
        closeMenu();
        updateScreens();
    }
    else if (keyJustPressed(KEY_L)) {
        menu--;
        if (menu < 0)
            menu = numMenus-1;
        if (option >= menuList[menu].numOptions)
            option = menuList[menu].numOptions-1;
        redraw = true;
    }
    else if (keyJustPressed(KEY_R)) {
        menu++;
        if (menu >= numMenus)
            menu = 0;
        if (option >= menuList[menu].numOptions)
            option = menuList[menu].numOptions-1;
        redraw = true;
    }
    if (redraw && subMenuUpdateFunc == 0 &&
            isMenuOn()) // The menu may have been closed by an option
        doAtVBlank(redrawMenu);
}
Exemplo n.º 8
0
void updateKeyConfigChooser() {
    bool redraw = false;

    int& option = keyConfigChooser_option;
    KeyConfig* config = &keyConfigs[selectedKeyConfig];

    if (keyJustPressed(KEY_B)) {
        loadKeyConfig();
        closeSubMenu();
    }
    else if (keyJustPressed(KEY_X)) {
        keyConfigs.push_back(KeyConfig(*config));
        selectedKeyConfig = keyConfigs.size()-1;
        char name[32];
        sprintf(name, "Custom %d", keyConfigs.size()-1);
        strcpy(keyConfigs.back().name, name);
        option = -1;
        redraw = true;
    }
    else if (keyJustPressed(KEY_Y)) {
        if (selectedKeyConfig != 0) /* can't erase the default */ {
            keyConfigs.erase(keyConfigs.begin() + selectedKeyConfig);
            if (selectedKeyConfig >= keyConfigs.size())
                selectedKeyConfig = keyConfigs.size() - 1;
            redraw = true;
        }
    }
    else if (keyPressedAutoRepeat(KEY_DOWN)) {
        if (option == NUM_BINDABLE_BUTTONS-1)
            option = -1;
#if defined(_3DS)
        else if(option == 11) //Skip nonexistant keys
            option = 14;
        else if(option == 15)
            option = 24;
#endif
        else
            option++;
        redraw = true;
    }
    else if (keyPressedAutoRepeat(KEY_UP)) {
        if (option == -1)
            option = NUM_BINDABLE_BUTTONS-1;
#if defined(_3DS)
        else if(option == 14) //Skip nonexistant keys
            option = 11;
        else if(option == 24)
            option = 15;
#endif
        else
            option--;
        redraw = true;
    }
    else if (keyPressedAutoRepeat(KEY_LEFT)) {
        if (option == -1) {
            if (selectedKeyConfig == 0)
                selectedKeyConfig = keyConfigs.size()-1;
            else
                selectedKeyConfig--;
        }
        else {
            config->funcKeys[option]--;
            if (config->funcKeys[option] < 0)
                config->funcKeys[option] = NUM_FUNC_KEYS-1;
        }
        redraw = true;
    }
    else if (keyPressedAutoRepeat(KEY_RIGHT)) {
        if (option == -1) {
            selectedKeyConfig++;
            if (selectedKeyConfig >= keyConfigs.size())
                selectedKeyConfig = 0;
        }
        else {
            config->funcKeys[option]++;
            if (config->funcKeys[option] >= NUM_FUNC_KEYS)
                config->funcKeys[option] = 0;
        }
        redraw = true;
    }
    if (redraw)
        doAtVBlank(redrawKeyConfigChooser);
}