void clock_poll(void) { switch (state) { case S_STANDBY: clear_display(); if (sw_a_read()) { ticks = TICK_COUNT; show_time(); state = S_TIME; countdown = TIME_TIMEOUT; } else if (sw_b_read()) { show_voltage(); state = S_BATT_DEBOUNCE; countdown = BATT_TIMEOUT; } break; case S_TIME: if (countdown == 0) state = S_STANDBY; break; case S_BATT_DEBOUNCE: if (!sw_b_read()) state = S_BATT; break; case S_BATT: if (sw_b_read()) { usb_toggle(); show_voltage(); state = S_BATT_DEBOUNCE; countdown = BATT_TIMEOUT; } if (countdown == 0) state = S_STANDBY; break; } if (state != S_STANDBY || chg_read()) { refresh_running = 1; PRR &= ~_BV(PRTIM0); /* start refresh timer */ } else { refresh_running = 0; } /* battery charging indicator */ if (state == S_STANDBY && chg_read()) { switch (time % 5) { case 4: digits[3] = LCD_DOT; case 3: digits[2] = LCD_DOT; case 2: digits[1] = LCD_DOT; case 1: digits[0] = LCD_DOT; } } }
static int selectmedia() { SceCtrlData pad; static int highlight = 0; int highlightold; int finished = 0; int count; int x, y; u32 buttonsold = 0; int basepos; if (forceskip != 0) { // we are forcing a skip if (forceskip == 1) { // previous tune if (highlight != 0) highlight--; } else if (forceskip == 2) { // next tune if (highlight < (files_infonum - 1)) highlight++; else highlight = 0; // move back to top of list } forceskip = 0; return highlight; } printf("Select media to play:\n\n"); // Save screen position x = pspDebugScreenGetX(); y = pspDebugScreenGetY(); sceCtrlReadBufferPositive(&pad, 1); buttonsold = pad.Buttons; pspDebugScreenSetXY(0, 32); printf("Up/Down = Move cursor. X = Select. SELECT = Exit.\n"); #ifdef USB_ENABLED printf("SQUARE = Toggle USB."); #endif highlightold = -1; while (finished == 0) { // Draw the menu firstly sceDisplayWaitVblankStart(); // Show loop status pspDebugScreenSetXY(58, 1); if (loopmode == 0) { printf(" LOOP "); } else { printf("ADVANCE"); } if (highlightold != highlight) { // Calc position in the list, given number of files and highlight position if (highlight < 11) basepos = 0; else // we must scroll basepos = highlight - 11; pspDebugScreenSetXY(x, y); for (count = basepos; count < basepos + 22; count++) { if (count >= files_infonum) printf("\n"); else { if (highlight == count) printf("-> %02d - %-50s \n", count, files_info[count].filename); else printf(" %02d - %-50s \n", count, files_info[count].filename); } } } highlightold = highlight; // Now read the keys and act appropriately sceCtrlReadBufferPositive(&pad, 1); if (buttonsold != pad.Buttons) { if (pad.Buttons & PSP_CTRL_RIGHT) if (highlight < (files_infonum - 11)) highlight += 10; else highlight = files_infonum - 1; if (pad.Buttons & PSP_CTRL_LEFT) if (highlight >= 10) highlight -= 10; else highlight = 0; if (pad.Buttons & PSP_CTRL_UP) if (highlight >= 1) highlight--; if (pad.Buttons & PSP_CTRL_DOWN) if (highlight < (files_infonum - 1)) highlight++; if (pad.Buttons & PSP_CTRL_TRIANGLE) loopmode = !loopmode; #ifdef USB_ENABLED if (pad.Buttons & PSP_CTRL_SQUARE) usb_toggle(); #endif if (pad.Buttons & PSP_CTRL_CROSS) return highlight; if (pad.Buttons & PSP_CTRL_SELECT) return -1; } buttonsold = pad.Buttons; } }