int main() { InputEvent ev; Input static const buttons[] = { BUTTON1, BUTTON2, BUTTON3, BUTTON4, LROCKER_LEFT, LROCKER_RIGHT, RROCKER_LEFT, RROCKER_RIGHT}; __Set( BEEP_VOLUME, 0); //chosen_slot = UNDEFINED; //chosen_page = UNDEFINED; render_slot_buttons(); render_slots(); while( true) { check_event( &ev); if ( INPUT_PRESSED == ev.state) { // The four buttons and both directions of both rockers make up eight // buttons numbered 0..7. Work out which ( if any) were pressed: Input button_pressed = UNDEFINED; int i; for ( i = 0; i < ITEMS_IN_ARRAY(buttons); i += 1) { if ( buttons[i] == ev.input) { button_pressed = i; break; } } // If the slot has not yet been chosen.. if ( UNDEFINED == chosen_slot) { if ( button_pressed != UNDEFINED && button_pressed < 4) { chosen_slot = button_pressed; render_page_buttons(); render_slots(); } } // Otherwise the slot *has* been chosen and all that it left is to choose // the page within the slot else { if ( button_pressed != UNDEFINED) { chosen_page = 8 * chosen_slot + button_pressed; VoidFunction **reset_vector = (VoidFunction**)( FIRST_PAGE + (PAGE_SIZE * chosen_page) + 0x4); (*reset_vector)(); } } } // Go to sleep until it's time to check the buttons again __WFE(); } }
void static initial_render() { __Clear_Screen( BACKGROUND_COLOR); // The first of these labels is at the bottom char static const *label[] = {"Reset", "Address", "Slot"}; int i; for ( i = 0; i < ITEMS_IN_ARRAY(label); i += 1) { __Display_Str( LABEL_LEFT, BOTTOM+FONT_HEIGHT*i, LABEL_COLOR, 0, label[i] ); } }
/** * Show and process the window dialog. */ void Dialog_WindowDlg(void) { int deskw, deskh, but, skip = 0; unsigned int i; SDLGui_CenterDlg(windowdlg); /* Set up general window options in the dialog from actual values: */ if (ConfigureParams.Screen.bFullScreen) windowdlg[DLGSCRN_FULLSCRN].state |= SG_SELECTED; else windowdlg[DLGSCRN_FULLSCRN].state &= ~SG_SELECTED; if (ConfigureParams.Screen.bKeepResolution) windowdlg[DLGSCRN_KEEP_RES].state |= SG_SELECTED; else windowdlg[DLGSCRN_KEEP_RES].state &= ~SG_SELECTED; if (ConfigureParams.Screen.bKeepResolutionST) windowdlg[DLGSCRN_KEEP_RES_ST].state |= SG_SELECTED; else windowdlg[DLGSCRN_KEEP_RES_ST].state &= ~SG_SELECTED; windowdlg[DLGSCRN_STATUSBAR].state &= ~SG_SELECTED; windowdlg[DLGSCRN_DRIVELED].state &= ~SG_SELECTED; windowdlg[DLGSCRN_NONE].state &= ~SG_SELECTED; if (ConfigureParams.Screen.bShowStatusbar) windowdlg[DLGSCRN_STATUSBAR].state |= SG_SELECTED; else if (ConfigureParams.Screen.bShowDriveLed) windowdlg[DLGSCRN_DRIVELED].state |= SG_SELECTED; else windowdlg[DLGSCRN_NONE].state |= SG_SELECTED; for (i = 0; i < ITEMS_IN_ARRAY(skip_frames); i++) { if (ConfigureParams.Screen.nFrameSkips >= skip_frames[i]) skip = i; windowdlg[i+DLGSCRN_SKIP0].state &= ~SG_SELECTED; } windowdlg[DLGSCRN_SKIP0+skip].state |= SG_SELECTED; Resolution_GetDesktopSize(&deskw, &deskh); sprintf(sMaxWidth, "%4i", ConfigureParams.Screen.nMaxWidth); sprintf(sMaxHeight, "%4i", ConfigureParams.Screen.nMaxHeight); /* Initialize window capture options: */ if (ConfigureParams.Screen.bCrop) windowdlg[DLGSCRN_CROP].state |= SG_SELECTED; else windowdlg[DLGSCRN_CROP].state &= ~SG_SELECTED; if (Avi_AreWeRecording()) windowdlg[DLGSCRN_RECANIM].txt = RECORD_STOP; else windowdlg[DLGSCRN_RECANIM].txt = RECORD_START; /* The window dialog main loop */ do { but = SDLGui_DoDialog(windowdlg, NULL); switch (but) { case DLGSCRN_MAX_WLESS: ConfigureParams.Screen.nMaxWidth = VDI_Limit(ConfigureParams.Screen.nMaxWidth - MAX_SIZE_STEP, MAX_SIZE_STEP, MIN_VDI_WIDTH, deskw); sprintf(sMaxWidth, "%4i", ConfigureParams.Screen.nMaxWidth); break; case DLGSCRN_MAX_WMORE: ConfigureParams.Screen.nMaxWidth = VDI_Limit(ConfigureParams.Screen.nMaxWidth + MAX_SIZE_STEP, MAX_SIZE_STEP, MIN_VDI_WIDTH, deskw); sprintf(sMaxWidth, "%4i", ConfigureParams.Screen.nMaxWidth); break; case DLGSCRN_MAX_HLESS: ConfigureParams.Screen.nMaxHeight = VDI_Limit(ConfigureParams.Screen.nMaxHeight - MAX_SIZE_STEP, MAX_SIZE_STEP, MIN_VDI_HEIGHT, deskh); sprintf(sMaxHeight, "%4i", ConfigureParams.Screen.nMaxHeight); break; case DLGSCRN_MAX_HMORE: ConfigureParams.Screen.nMaxHeight = VDI_Limit(ConfigureParams.Screen.nMaxHeight + MAX_SIZE_STEP, MAX_SIZE_STEP, MIN_VDI_HEIGHT, deskh); sprintf(sMaxHeight, "%4i", ConfigureParams.Screen.nMaxHeight); break; case DLGSCRN_CAPTURE: SDL_UpdateRect(sdlscrn, 0,0,0,0); ConfigureParams.Screen.bCrop = (windowdlg[DLGSCRN_CROP].state & SG_SELECTED); ScreenSnapShot_SaveScreen(); break; case DLGSCRN_RECANIM: if (Avi_AreWeRecording()) { /* AVI indexing can take a while for larger files */ Statusbar_AddMessage("Finishing AVI file...", 100); Statusbar_Update(sdlscrn, true); Avi_StopRecording(); windowdlg[DLGSCRN_RECANIM].txt = RECORD_START; Statusbar_AddMessage("Emulation paused", 100); Statusbar_Update(sdlscrn, true); } else { ConfigureParams.Screen.bCrop = (windowdlg[DLGSCRN_CROP].state & SG_SELECTED); Avi_StartRecording ( ConfigureParams.Video.AviRecordFile , ConfigureParams.Screen.bCrop , ConfigureParams.Video.AviRecordFps == 0 ? ClocksTimings_GetVBLPerSec ( ConfigureParams.System.nMachineType , nScreenRefreshRate ) : (Uint32)ConfigureParams.Video.AviRecordFps << CLOCKS_TIMINGS_SHIFT_VBL , 1 << CLOCKS_TIMINGS_SHIFT_VBL , ConfigureParams.Video.AviRecordVcodec ); windowdlg[DLGSCRN_RECANIM].txt = RECORD_STOP; } break; } } while (but != DLGSCRN_EXIT_WINDOW && but != SDLGUI_QUIT && but != SDLGUI_ERROR && !bQuitProgram); /* Read new values from dialog: */ ConfigureParams.Screen.bFullScreen = (windowdlg[DLGSCRN_FULLSCRN].state & SG_SELECTED); ConfigureParams.Screen.bKeepResolution = (windowdlg[DLGSCRN_KEEP_RES].state & SG_SELECTED); ConfigureParams.Screen.bKeepResolutionST = (windowdlg[DLGSCRN_KEEP_RES_ST].state & SG_SELECTED); ConfigureParams.Screen.bShowStatusbar = false; ConfigureParams.Screen.bShowDriveLed = false; if (windowdlg[DLGSCRN_STATUSBAR].state & SG_SELECTED) ConfigureParams.Screen.bShowStatusbar = true; else if (windowdlg[DLGSCRN_DRIVELED].state & SG_SELECTED) ConfigureParams.Screen.bShowDriveLed = true; for (i = DLGSCRN_SKIP0; i <= DLGSCRN_SKIP4; i++) { if (windowdlg[i].state & SG_SELECTED) { ConfigureParams.Screen.nFrameSkips = skip_frames[i-DLGSCRN_SKIP0]; break; } } ConfigureParams.Screen.bCrop = (windowdlg[DLGSCRN_CROP].state & SG_SELECTED); }
// Provides the index in received.byte that should be used after the specified // index. // u8 static advanced( u8 index) { // NOTE: ITEMS_IN_ARRAY(..) must be an integer power of two return (index + 1) & (ITEMS_IN_ARRAY(received.byte) - 1); }