int VideoInit() { BurnDrvGetFullSize(&VideoBufferWidth, &VideoBufferHeight); printf("w=%d h=%d\n",VideoBufferWidth, VideoBufferHeight); nBurnBpp = 2; BurnHighCol = myHighCol16; BurnRecalcPal(); nBurnPitch = VideoBufferWidth * 2; PhysicalBufferWidth = screen->w; BurnVideoBuffer = (unsigned short *)malloc(VideoBufferWidth * VideoBufferHeight * 2); BurnerVideoTrans = Blit_320x240_to_320x240; // default blit // if source buffer < screen buffer then set general blitting routine with centering if needed if(VideoBufferWidth <= screen->w && VideoBufferHeight <= screen->h) { p_offset = (screen->w - VideoBufferWidth)/2 + (screen->h - VideoBufferHeight)/2*screen->w; q_offset = VideoBufferWidth*VideoBufferHeight-1; if(BurnDrvGetFlags() & BDF_ORIENTATION_FLIPPED) BurnerVideoTrans = Blitf; else BurnerVideoTrans = Blit; } else { // if source buffer is bigger than screen buffer then find an appropriate downscaler for(int i = 0; blit_table[i].dst_w != 0; i++) { if(blit_table[i].dst_w == screen->w && blit_table[i].dst_h == screen->h && blit_table[i].src_w == VideoBufferWidth && blit_table[i].src_h == VideoBufferHeight) { if (BurnDrvGetFlags() & BDF_ORIENTATION_FLIPPED) BurnerVideoTrans = blit_table[i].blitf; else BurnerVideoTrans = blit_table[i].blit; break; } } } return 0; }
int VideoInit() { // Initialize SDL int flags = (options.vsync ? (SDL_HWSURFACE | #ifdef SDL_TRIPLEBUF SDL_TRIPLEBUF #else SDL_DOUBLEBUF #endif ) : SDL_SWSURFACE); if(!(SDL_WasInit(SDL_INIT_VIDEO) & SDL_INIT_VIDEO)) { SDL_InitSubSystem(SDL_INIT_VIDEO); } screen = SDL_SetVideoMode(320, 240, 16, flags); /*{ int i = 0; // 0 - 320x240, 1 - 400x240, 2 - 480x272 int surfacewidth, surfaceheight; #define NUMOFVIDEOMODES 3 struct { int x; int y; } vm[NUMOFVIDEOMODES] = { {320, 240}, {400, 240}, {480, 272} }; // check 3 videomodes: 480x272, 400x240, 320x240 for(i = NUMOFVIDEOMODES-1; i >= 0; i--) { if(SDL_VideoModeOK(vm[i].x, vm[i].y, 16, SDL_SWSURFACE) != 0) { surfacewidth = vm[i].x; surfaceheight = vm[i].y; break; } } screen = SDL_SetVideoMode(surfacewidth, surfaceheight, 16, SDL_SWSURFACE); }*/ if(!screen) { printf("SDL_SetVideoMode screen not initialised.\n"); } else { printf("SDL_SetVideoMode successful.\n"); } VideoBuffer = (unsigned short*)screen->pixels; SDL_ShowCursor(SDL_DISABLE); SDL_WM_SetCaption("Final Burn SDL", 0); BurnDrvGetFullSize(&VideoBufferWidth, &VideoBufferHeight); printf("w=%d h=%d\n",VideoBufferWidth, VideoBufferHeight); nBurnBpp = 2; BurnHighCol = myHighCol16; BurnRecalcPal(); nBurnPitch = VideoBufferWidth * 2; PhysicalBufferWidth = screen->w; BurnVideoBuffer = (unsigned short *)malloc(VideoBufferWidth * VideoBufferHeight * 2); memset(BurnVideoBuffer, 0, VideoBufferWidth * VideoBufferHeight * 2); BurnerVideoTrans = Blit_320x240_to_320x240; // default blit bool bVertical = options.rotate && (BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL); // if source buffer < screen buffer then set general blitting routine with centering if needed if(!bVertical && VideoBufferWidth <= screen->w && VideoBufferHeight <= screen->h) { if(BurnDrvGetFlags() & BDF_ORIENTATION_FLIPPED) BurnerVideoTrans = Blitf; else BurnerVideoTrans = Blit; } else if(bVertical && VideoBufferWidth <= screen->h && VideoBufferHeight <= screen->w) { if(BurnDrvGetFlags() & BDF_ORIENTATION_FLIPPED) BurnerVideoTrans = Blitrf; else BurnerVideoTrans = Blitr; } else { // if source buffer is bigger than screen buffer then find an appropriate downscaler for(int i = 0; blit_table[i].dst_w != 0; i++) { if(blit_table[i].dst_w == screen->w && blit_table[i].dst_h == screen->h && blit_table[i].src_w == VideoBufferWidth && blit_table[i].src_h == VideoBufferHeight) { if (bVertical && (BurnDrvGetFlags() & BDF_ORIENTATION_FLIPPED)) BurnerVideoTrans = blit_table[i].blitrf; else if (BurnDrvGetFlags() & BDF_ORIENTATION_FLIPPED) BurnerVideoTrans = blit_table[i].blitf; else if (bVertical) BurnerVideoTrans = blit_table[i].blitr; else BurnerVideoTrans = blit_table[i].blit; break; } } } if (BurnerVideoTrans == Blit || BurnerVideoTrans == Blitf || BurnerVideoTrans == Blitr || BurnerVideoTrans == Blitrf) { if (bVertical) { p_offset = ((screen->h - VideoBufferWidth)/2)*screen->w; r_offset = screen->w - VideoBufferHeight; } else { p_offset = (screen->w - VideoBufferWidth)/2 + (screen->h - VideoBufferHeight)/2*screen->w; q_offset = VideoBufferWidth*VideoBufferHeight-1; } } return 0; }
static void process_key( int key, int down, int repeat ) { if ( !down ) return ; switch( nGameStage ) { /* ---------------------------- Main Menu ---------------------------- */ case 1: //ui_mainmenu_select switch( key ) { case PSP_CTRL_UP: if (ui_mainmenu_select <= 0) break; ui_mainmenu_select--; draw_ui_main(); break; case PSP_CTRL_DOWN: if (ui_mainmenu_select >=9 ) break; ui_mainmenu_select++; draw_ui_main(); break; case PSP_CTRL_LEFT: switch(ui_mainmenu_select) { case 7: if ( cpu_speeds_select > 0 ) { cpu_speeds_select--; draw_ui_main(); } break; } break; case PSP_CTRL_RIGHT: switch(ui_mainmenu_select) { case 7: if ( cpu_speeds_select < 3 ) { cpu_speeds_select++; draw_ui_main(); } break; } break; case PSP_CTRL_CIRCLE: switch( ui_mainmenu_select ) { case 0: nGameStage = 2; strcpy(ui_current_path, szAppRomPath); //ui_current_path[strlen(ui_current_path)-1] = 0; draw_ui_browse(true); break; case 8: // Return to Game if ( nPrevGame < nBurnDrvCount ) { scePowerSetClockFrequency( cpu_speeds[cpu_speeds_select].cpu, cpu_speeds[cpu_speeds_select].cpu, cpu_speeds[cpu_speeds_select].bus ); nGameStage = 0; } break; case 9: // Exit bGameRunning = 0; break; } break; } break; /* ---------------------------- Rom Browse ---------------------------- */ case 2: switch( key ) { case PSP_CTRL_UP: if (find_rom_select == 0) break; if (find_rom_top >= find_rom_select) find_rom_top--; find_rom_select--; draw_ui_browse(false); break; case PSP_CTRL_DOWN: if ((find_rom_select+1) >= find_rom_count) break; find_rom_select++; if ((find_rom_top + find_rom_list_cnt) <= find_rom_select) find_rom_top++; draw_ui_browse(false); break; case PSP_CTRL_CIRCLE: switch( getRomsFileStat(find_rom_select) ) { case -1: // directry { // printf("change dir %s\n", getRomsFileName(find_rom_select) ); char * pn = getRomsFileName(find_rom_select); if ( strcmp("..", pn) ) { strcat(ui_current_path, getRomsFileName(find_rom_select)); strcat(ui_current_path, "/"); } else { if (strlen(strstr(ui_current_path, ":/")) == 2) break; // "ROOT:/" for(int l = strlen(ui_current_path)-1; l>1; l-- ) { ui_current_path[l] = 0; if (ui_current_path[l-1] == '/') break; } } //printf("change dir to %s\n", ui_current_path ); find_rom_count = 0; find_rom_select = 0; find_rom_top = 0; draw_ui_browse(true); } break; default: // rom zip file { nBurnDrvSelect = (unsigned int)getRomsFileStat( find_rom_select ); if (nBurnDrvSelect <= nBurnDrvCount && BurnDrvIsWorking() ) { if ( DrvInit( nBurnDrvSelect, false ) == 0 ) { BurnRecalcPal(); InpInit(); InpDIP(); scePowerSetClockFrequency( cpu_speeds[cpu_speeds_select].cpu, cpu_speeds[cpu_speeds_select].cpu, cpu_speeds[cpu_speeds_select].bus ); nGameStage = 0; } else nBurnDrvSelect = ~0U; } else nBurnDrvSelect = ~0U; nPrevGame = nBurnDrvSelect; //if (nBurnDrvSelect == ~0U) { // bprintf(0, "unkown rom %s", getRomsFileName(find_rom_select)); //} } } break; case PSP_CTRL_CROSS: // cancel nGameStage = 1; draw_ui_main(); break; } break; /* ---------------------------- DIP Setting ---------------------------- */ case 3: break; } }