static void gp2x_exit(void) { remove("frontend/mame.lst"); sync(); gp2x_deinit(); chdir("/usr/gp2x"); /*go to menu*/ execl("gp2xmenu", "gp2xmenu", NULL); }
static void gp2x_exit(void) { remove("frontend/mame.lst"); sync(); gp2x_deinit(); deinit_SDL(); exit(0); }
int main(int argc, char *argv[]) { g_argv = argv; emu_ReadConfig(0, 0); gp2x_init(); if (currentConfig.EmuOpt&0x10) { int ret = mmuhack(); printf("squidge hack code finished and returned %i\n", ret); fflush(stdout); mmuhack_status = ret; } cpuctrl_init(); // Reset940(1); // Pause940(1); if (currentConfig.EmuOpt&0x100) { printf("setting RAM timings.. "); fflush(stdout); // craigix: --trc 6 --tras 4 --twr 1 --tmrd 1 --trfc 1 --trp 2 --trcd 2 set_RAM_Timings(6, 4, 1, 1, 1, 2, 2); printf("done.\n"); fflush(stdout); } emu_Init(); menu_init(); engineState = PGS_Menu; if (argc > 1) parse_cmd_line(argc, argv); for (;;) { switch (engineState) { case PGS_Menu: menu_loop(); break; case PGS_ReloadRom: if (emu_ReloadRom()) engineState = PGS_Running; else { printf("PGS_ReloadRom == 0\n"); engineState = PGS_Menu; } break; case PGS_RestartRun: engineState = PGS_Running; case PGS_Running: emu_Loop(); break; case PGS_Quit: goto endloop; default: printf("engine got into unknown state (%i), exitting\n", engineState); goto endloop; } } endloop: emu_Deinit(); cpuctrl_deinit(); gp2x_deinit(); if(mmuhack_status) mmuunhack(); return 0; }
u16 ReadZodKeys() { u16 pad_status = 0xffff; u32 keys = gp2x_joystick_read(); /* DEBUG */ #ifdef WITH_REG_STATS if( keys & GP2X_PUSH ) { int regcounter=0; for(regcounter = 0; regcounter < 32; regcounter++) { reg_count[regcounter] = 0; reg_mapped_count[regcounter] = 0; } } #endif //Read key state #ifndef IPHONE if ( keys & GP2X_L && keys & GP2X_R && keys & GP2X_A && keys & GP2X_B && keys & GP2X_X && keys & GP2X_Y ) { psx4all_prof_show(); psxShutdown(); CloseComponents(); gp2x_deinit(); exit(0); } #endif #if 0 if( keys & GP2X_SELECT ) { SkipReset = !SkipReset; gp2x_printf(NULL, 0, 0, "SkipReset %s ", SkipReset == 0 ? "OFF" : "ON" ); gp2x_video_flip(); gp2x_timer_delay(1000); } if( keys & GP2X_L ) { if( skipCount > 0 ) skipCount--; gp2x_printf(NULL, 0, 0, "skipCount %d ", skipCount); gp2x_video_flip(); gp2x_timer_delay(250); } if( keys & GP2X_R ) { skipCount++; gp2x_printf(NULL, 0, 0, "skipCount %d ", skipCount); gp2x_video_flip(); gp2x_timer_delay(250); } if( keys & GP2X_VOL_DOWN ) { if( skipRate > 0 ) skipRate--; gp2x_printf(NULL, 0, 0, "skipRate %d ", skipRate); gp2x_video_flip(); gp2x_timer_delay(250); } if( keys & GP2X_VOL_UP ) { skipRate++; gp2x_printf(NULL, 0, 0, "skipRate %d ", skipRate); gp2x_video_flip(); gp2x_timer_delay(250); } #endif if( keys & GP2X_VOL_DOWN && keys & GP2X_VOL_UP ) { #ifdef GP2X_SDL // Menu system u32 w = sdlscreen->w; u32 h = sdlscreen->h; gp2x_change_res(320, 240); #endif if( 0 != SelectGame() ) { psx4all_emulating=1; psx4all_prof_start(PROFILER_TOTAL); psxCpu->Execute(); psx4all_prof_end(PROFILER_TOTAL); psx4all_emulating=0; psx4all_prof_show(); } #ifdef GP2X_SDL gp2x_change_res(w, h); #endif } /* if( keys & GP2X_PUSH && displayVideoMemory) primitiveDebugMode = true; else primitiveDebugMode = false; */ if( keys & GP2X_R && keys & GP2X_VOL_DOWN ) { // Underclock u32 newClock = (PsxClockMult>2) ? (PsxClockMult-1) : PsxClockMult; UpdateClock (newClock); gp2x_printf(NULL, 0, 0, "PSX CLOCK %d %% ", newClock); gp2x_video_flip(); gp2x_timer_delay(250); } if( keys & GP2X_R && keys & GP2X_VOL_UP ) { // Overclock u32 newClock = (PsxClockMult<200) ? (PsxClockMult+1) : PsxClockMult; UpdateClock (newClock); gp2x_printf(NULL, 0, 0, "PSX CLOCK %d %% ", newClock); gp2x_video_flip(); gp2x_timer_delay(250); } if( keys & GP2X_L && keys & GP2X_VOL_DOWN ) { // Underclock PsxCycleMult = (PsxCycleMult>0.2) ? (PsxCycleMult-0.1) : PsxCycleMult; gp2x_printf(NULL, 0, 0, "PSX CYCLE %f ", PsxCycleMult); #ifdef DYNAREC psxCpu->Reset(); #endif gp2x_video_flip(); gp2x_timer_delay(250); } if( keys & GP2X_L && keys & GP2X_VOL_UP ) { // Overclock PsxCycleMult = (PsxCycleMult<10.0) ? (PsxCycleMult+0.1) : PsxCycleMult; gp2x_printf(NULL, 0, 0, "PSX CYCLE %f ", PsxCycleMult); #ifdef DYNAREC psxCpu->Reset(); #endif gp2x_video_flip(); gp2x_timer_delay(250); } if( keys & GP2X_VOL_DOWN ) // L2 { pad_status &= ~(1<<8); } if( keys & GP2X_VOL_UP ) // R2 { pad_status &= ~(1<<9); } if (keys & GP2X_UP) { pad_status &= ~(1<<4); } if (keys & GP2X_DOWN) { pad_status &= ~(1<<6); } if (keys & GP2X_LEFT) { pad_status &= ~(1<<7); } if (keys & GP2X_RIGHT) { pad_status &= ~(1<<5); } if (keys & GP2X_START) { pad_status &= ~(1<<3); } if (keys & GP2X_SELECT) { pad_status &= ~(1); } if (keys & GP2X_L) { pad_status &= ~(1<<10); // L ? } if (keys & GP2X_R) { pad_status &= ~(1<<11); // R ? } if (keys & GP2X_X) { pad_status &= ~(1<<14); } if (keys & GP2X_B) { pad_status &= ~(1<<13); } if (keys & GP2X_A) { pad_status &= ~(1<<15); } if (keys & GP2X_Y) { pad_status &= ~(1<<12); } return pad_status; }
s32 SelectGame() { u32 keys; s32 loadst = 0; s32 menu_state = 0; s32 menu_pos = 0; s8* newpackfile = NULL; gp2x_video_RGB_clearscreen16(); gp2x_video_flip(); #if 1 for(;;) { gp2x_video_RGB_clearscreen16(); backg(); //exems(); //gp2x_timer_delay(500000); keys = gp2x_joystick_read(); gp2x_printf(NULL, 10, (menu_pos * 10) + PSX4ALL_MENU_START_POS, PSX4ALL_ROW2); if( keys & GP2X_UP ) { if( menu_pos > 0 ) menu_pos--; } switch(menu_state) { case PSX4ALL_MENU_DEFAULT_STATE: if( keys & GP2X_DOWN ) { if (psx4all_emulating) { if( menu_pos < 4 ) menu_pos++; }else{ if( menu_pos < 3 ) menu_pos++; } } break; case PSX4ALL_MENU_OPTIONS_STATE: if( keys & GP2X_DOWN ) { if( menu_pos < 2 ) menu_pos++; } break; case PSX4ALL_MENU_GPU_STATE: if( keys & GP2X_DOWN ) { if( menu_pos < 15 ) menu_pos++; } break; case PSX4ALL_MENU_SPU_STATE: if( keys & GP2X_DOWN ) { if( menu_pos < 1 ) menu_pos++; } break; /*case PSX4ALL_MENU_ABOUT_STATE: if( keys & GP2X_B ) { if( menu_pos < 0 ) menu_pos++; } break;*/ case PSX4ALL_MENU_GAMESTATE_STATE: if( keys & GP2X_DOWN ) { if( menu_pos < 4 ) menu_pos++; } break; } switch(menu_state) { case PSX4ALL_MENU_DEFAULT_STATE: gp2x_printf(NULL, 100, PSX4ALL_MENU_START_POS + 0, PSX4ALL_OPT); gp2x_printf(NULL, 100, PSX4ALL_MENU_START_POS + 10, PSX4ALL_FO); gp2x_printf(NULL, 100, PSX4ALL_MENU_START_POS + 20, PSX4ALL_ABOUT); if (psx4all_emulating) { gp2x_printf(NULL, 100, PSX4ALL_MENU_START_POS + 30, PSX4ALL_RES); if(psx4all_emulating){ gp2x_printf(NULL, 100, PSX4ALL_MENU_START_POS + 40, PSX4ALL_QT); break; } }else { gp2x_printf(NULL, 100, PSX4ALL_MENU_START_POS + 30, PSX4ALL_QT); } break; case PSX4ALL_MENU_OPTIONS_STATE: gp2x_printf(NULL, 100, PSX4ALL_MENU_START_POS + 0, PSX4ALL_GS); gp2x_printf(NULL, 100, PSX4ALL_MENU_START_POS + 10, PSX4ALL_SS); gp2x_printf(NULL, 100, PSX4ALL_MENU_START_POS + 20, PSX4ALL_BK); break; case PSX4ALL_MENU_GPU_STATE: gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 0, PSX4ALL_FPS, (displayFrameInfo == false ? "OFF" : "ON")); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 10, PSX4ALL_GPU, (displayGpuStats == false ? "OFF" : "ON")); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 20, PSX4ALL_MEM, (displayVideoMemory == false ? "OFF" : "ON")); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 30, PSX4ALL_GPUS, (activeNullGPU == false ? "OFF" : "ON")); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 40, PSX4ALL_IC, linesInterlace_user ); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 50, PSX4ALL_FL, (enableFrameLimit == false ? "OFF" : "ON")); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 60, PSX4ALL_SKIP, skipCount, skipRate); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 70, PSX4ALL_HACK, (enableAbbeyHack == false ? "OFF" : "ON")); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 80, PSX4ALL_CM, PsxCycleMult); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 90, PSX4ALL_FRL, hardframeskip_line ? "ON" : "OFF"); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 100, PSX4ALL_FPL, hardframeskip_poly ? "ON" : "OFF"); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 110, PSX4ALL_FST, hardframeskip_sprite ? "ON" : "OFF"); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 120, PSX4ALL_FIM, hardframeskip_image ? "ON" : "OFF"); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 130, PSX4ALL_FBT, hardframeskip_blit ? "ON" : "OFF"); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 140, PSX4ALL_WTM, use_wall_clock_time ? "ON" : "OFF"); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 150, PSX4ALL_BK); break; case PSX4ALL_MENU_SPU_STATE: gp2x_printf(NULL, 100, PSX4ALL_MENU_START_POS + 0, PSX4ALL_SND, (iSoundMuted == 0 ? "ON" : "OFF")); gp2x_printf(NULL, 100, PSX4ALL_MENU_START_POS + 10, PSX4ALL_BK); break; case PSX4ALL_MENU_GAMESTATE_STATE: gp2x_printf(NULL, 100, PSX4ALL_MENU_START_POS + 0, PSX4ALL_SST); gp2x_printf(NULL, 100, PSX4ALL_MENU_START_POS + 10, PSX4ALL_LST); gp2x_printf(NULL, 100, PSX4ALL_MENU_START_POS + 20, PSX4ALL_LG); gp2x_printf(NULL, 100, PSX4ALL_MENU_START_POS + 30, PSX4ALL_LGW); gp2x_printf(NULL, 100, PSX4ALL_MENU_START_POS + 40, PSX4ALL_BK); break; case PSX4ALL_MENU_ABOUT_STATE: gp2x_printf(NULL, 0, 50, PSX4ALL_NAME " V " PSX4ALL_VERSION "." PSX4ALL_BUILD " By " PSX4ALL_BY); gp2x_printf(NULL, 0, 60, PSX4ALL_CREDITS); gp2x_printf(NULL, 0, 70, PSX4ALL_PORT); gp2x_printf(NULL, 0, 80, PSX4ALL_PTI " " PSX4ALL_PLAT); gp2x_printf(NULL, 0, 100, PSX4ALL_PRM); break; } switch(menu_state) { case PSX4ALL_MENU_DEFAULT_STATE: if (psx4all_emulating) { if( keys & GP2X_B ) { switch(menu_pos) { case 0: menu_state = PSX4ALL_MENU_OPTIONS_STATE; menu_pos = 0; break; case 1: menu_state = PSX4ALL_MENU_GAMESTATE_STATE; menu_pos = 0; break; case 2: menu_state = PSX4ALL_MENU_ABOUT_STATE; menu_pos = 0; break; case 3: gp2x_video_RGB_clearscreen16(); return 0; case 4: SDL_Quit(); default: break; } } }else{ if( keys & GP2X_B ) { switch(menu_pos) { case 0: menu_state = PSX4ALL_MENU_OPTIONS_STATE; menu_pos = 0; break; case 1: menu_state = PSX4ALL_MENU_GAMESTATE_STATE; menu_pos = 0; break; case 2: menu_state = PSX4ALL_MENU_ABOUT_STATE; menu_pos = 0; break; case 3: gp2x_video_RGB_clearscreen16(); return 0; default: break; } } } if (keys & GP2X_L && psx4all_emulating) { gp2x_video_RGB_clearscreen16(); return 0; } break; case PSX4ALL_MENU_OPTIONS_STATE: switch(menu_pos) { case 0: if (keys & GP2X_B){ menu_state = PSX4ALL_MENU_GPU_STATE; menu_pos = 0; }break; case 1: if( keys & GP2X_B){ menu_state = PSX4ALL_MENU_SPU_STATE; menu_pos = 0; } break; case 2: if( keys & GP2X_B ) { menu_state = PSX4ALL_MENU_DEFAULT_STATE; menu_pos = 0; } break; default: break; } if (keys & GP2X_L) { menu_state = PSX4ALL_MENU_DEFAULT_STATE; menu_pos = 0; } break; case PSX4ALL_MENU_GPU_STATE: switch(menu_pos) { case 0: if( keys & GP2X_B || keys & GP2X_LEFT || keys & GP2X_RIGHT ) { displayFrameInfo = !displayFrameInfo; } break; case 1: if( keys & GP2X_B || keys & GP2X_LEFT || keys & GP2X_RIGHT ) { displayGpuStats = !displayGpuStats; } break; case 2: if( keys & GP2X_B ) { displayVideoMemory = !displayVideoMemory; } break; case 3: if( keys & GP2X_B || keys & GP2X_LEFT || keys & GP2X_RIGHT ) { activeNullGPU = !activeNullGPU; } break; case 4: if ( keys & GP2X_LEFT && linesInterlace_user > 0) linesInterlace_user--; if ( keys & GP2X_RIGHT && linesInterlace_user < 7) linesInterlace_user++; break; case 5: if( keys & GP2X_B ) { enableFrameLimit = !enableFrameLimit; } break; case 6: if( keys & GP2X_LEFT ) { if( skipValue > 0 ) { skipValue--; skipCount = skipCountTable[skipValue]; skipRate = skipRateTable[skipValue]; } } if( keys & GP2X_RIGHT ) { if( skipValue < 8 ) { skipValue++; skipCount = skipCountTable[skipValue]; skipRate = skipRateTable[skipValue]; } } break; case 7: if( keys & GP2X_B || keys & GP2X_LEFT || keys & GP2X_RIGHT ) { enableAbbeyHack = !enableAbbeyHack; } break; case 8: if ( keys & GP2X_LEFT && PsxCycleMult > 1) PsxCycleMult--; if ( keys & GP2X_RIGHT && PsxCycleMult < 10) PsxCycleMult++; break; case 9: if( keys & GP2X_B || keys & GP2X_LEFT || keys & GP2X_RIGHT ) { hardframeskip_line = !hardframeskip_line; } break; case 10: if( keys & GP2X_B || keys & GP2X_LEFT || keys & GP2X_RIGHT ) { hardframeskip_poly = !hardframeskip_poly; } break; case 11: if( keys & GP2X_B || keys & GP2X_LEFT || keys & GP2X_RIGHT ) { hardframeskip_sprite = !hardframeskip_sprite; } break; case 12: if( keys & GP2X_B || keys & GP2X_LEFT || keys & GP2X_RIGHT ) { hardframeskip_image = !hardframeskip_image; } break; case 13: if( keys & GP2X_B || keys & GP2X_LEFT || keys & GP2X_RIGHT ) { hardframeskip_blit = !hardframeskip_blit; } break; case 14: if( keys & GP2X_B || keys & GP2X_LEFT || keys & GP2X_RIGHT ) { use_wall_clock_time = !use_wall_clock_time; } break; case 15: if( keys & GP2X_B ) { menu_state = PSX4ALL_MENU_OPTIONS_STATE; menu_pos = 0; } break; default: break; } if (keys & GP2X_L) { menu_state = PSX4ALL_MENU_OPTIONS_STATE; menu_pos = 0; } break; case PSX4ALL_MENU_SPU_STATE: switch(menu_pos) { case 0: if( keys & GP2X_B || keys & GP2X_LEFT || keys & GP2X_RIGHT ) { #ifndef NOSOUND iSoundMuted = !iSoundMuted; #endif } break; case 1: if( keys & GP2X_B ) { menu_state = PSX4ALL_MENU_OPTIONS_STATE; menu_pos = 0; } break; default: break; } if (keys & GP2X_L) { menu_state = PSX4ALL_MENU_OPTIONS_STATE; menu_pos = 0; } break; case PSX4ALL_MENU_GAMESTATE_STATE: switch(menu_pos) { case 0: if( keys & GP2X_B ) { #ifndef IPHONE if( 1 == psx4all_emulating ) { s32 ret; char buffer[360]; char filename[260]; struct stat s; for(int count = 1;; count++) { sprintf(filename, "%s-%04d.svs", packfile, count); if (stat(filename, &s)) break; } gp2x_printf(NULL, 100, 130, PSX4ALL_SV); gp2x_video_flip(); GPU_freeze(2, NULL); ret = SaveState(filename); if (ret == 0) sprintf(buffer, PSX4ALL_SVD); else sprintf(buffer, PSX4ALL_ESV); gp2x_printf(NULL, 100, 140, PSX4ALL_STR, buffer); gp2x_video_flip(); gp2x_timer_delay(900); } #endif } break; case 1: if( keys & GP2X_B ) { #ifndef IPHONE gp2x_timer_delay(500); newpackfile = FileReq(NULL, FORMAT_SV); #endif } break; case 2: if( keys & GP2X_B ) { #ifndef IPHONE Config.HLE = 0; gp2x_timer_delay(500); newpackfile = FileReq(NULL, NULL); #endif } break; case 3: if( keys & GP2X_B ) { #ifndef IPHONE Config.HLE = 1; gp2x_timer_delay(500); newpackfile = FileReq(NULL, NULL); #endif } break; case 4: if( keys & GP2X_B ) { menu_state = PSX4ALL_MENU_DEFAULT_STATE; menu_pos = 0; } break; default: break; } if (keys & GP2X_L) { menu_state = PSX4ALL_MENU_DEFAULT_STATE; menu_pos = 0; } break; case PSX4ALL_MENU_ABOUT_STATE: switch(menu_pos) { case 0: if( keys & GP2X_B ) { menu_state = PSX4ALL_MENU_DEFAULT_STATE; menu_pos = 0; } break; default: break; } if (keys & GP2X_L) { menu_state = PSX4ALL_MENU_DEFAULT_STATE; menu_pos = 0; } break; } if( newpackfile != NULL ) { break; } gp2x_video_flip(); gp2x_timer_delay(90); if(keys & (GP2X_A|GP2X_B|GP2X_X|GP2X_Y|GP2X_L|GP2X_R|GP2X_PUSH| GP2X_LEFT|GP2X_RIGHT|GP2X_UP|GP2X_DOWN) ) { gp2x_timer_delay(50); } } #else Config.HLE = 1; //newpackfile = "Cotton Jap.cbn"; #endif DEBUGF("loaded "PSX4ALL_STR, newpackfile); packfile = newpackfile; gp2x_video_RGB_clearscreen16(); keys = gp2x_joystick_read(); backg(); LoadCdBios = 0; if( (!strcasecmp(packfile + (strlen(packfile)-4), FORMAT_SV)) ) { char *pos; loadst = 1; sprintf(svsfilename, PSX4ALL_STR, packfile); pos = strrchr(packfile, '-'); if (pos) *pos = '\0'; } else { loadst = 0; } if( loadst > 0 ) { gp2x_printf(NULL, 120, 90, PSX4ALL_LDG); } else { gp2x_printf(NULL, 120, 90, PSX4ALL_LDB); } gp2x_video_flip(); if( 1 == psx4all_emulating ) { psxShutdown(); CloseComponents(); } if (SysInit() == -1) { gp2x_deinit(); return 0; } if (InitComponents() == -1) { gp2x_deinit(); return 0; } SysReset(); CheckCdrom(); if( Config.HLE ) { LoadCdBios = 0; if( LoadCdrom() == -1 ) { gp2x_printf(NULL, 120, 120, PSX4ALL_LDD); gp2x_video_flip(); gp2x_timer_delay(2000); gp2x_video_RGB_clearscreen16(); backg(); return 0; } } else { gp2x_printf(NULL, 120, 120, PSX4ALL_LDY); gp2x_video_flip(); gp2x_timer_delay(90); backg(); } if (loadst) { if( LoadState(svsfilename) == -1 ) { gp2x_printf(NULL, 120, 120, PSX4ALL_LSF); gp2x_video_flip(); gp2x_timer_delay(2000); gp2x_video_RGB_clearscreen16(); return 0; } } return 1; }
int main(int argc, char *argv[]) #endif { #ifndef IPHONE #if defined(ARM_ARCH) ChangeWorkingDirectory(argv[0]); getcwd(gamepath, 256); #else #if defined(__WIN32__) if(argc == 1) strncpy(gamepath,"E:\\ps1",256); else strncpy(gamepath,argv[1],256); #else strncpy(gamepath,ROM_PREFIX,256); #endif #endif #endif #ifdef PSP sprintf(gamepath,""); #endif #ifdef IPHONE sprintf(gamepath,""); #endif memset(&Config, 0, sizeof(PsxConfig)); Config.PsxAuto = 1; Config.Cdda = 1; Config.Xa = 0; #ifdef DYNAREC Config.Cpu = 0; #else Config.Cpu = 1; #endif #ifdef WITH_HLE Config.HLE = 1; #else Config.HLE = 0; #endif Config.Mdec = 0; Config.PsxOut = 0; Config.PsxType = 0; Config.QKeys = 0; Config.RCntFix = 0; Config.Sio = 0; Config.SpuIrq = 1; Config.VSyncWA = 0; #if defined(PSP) || defined(SDL) || defined(IPHONE) sprintf(Config.BiosDir, "%s/Media/ROMs/PSX/", appworkdir); sprintf(Config.Bios, "scph1001.bin"); sprintf(Config.Mcd1, "mcd001.mcr"); sprintf(Config.Mcd2, "mcd002.mcr"); #else sprintf(Config.BiosDir, PSX4ALL_STR, gamepath); sprintf(Config.Bios, "/bios/scph1000.bin"); sprintf(Config.Mcd1, "%s/memory_card/mcd001.mcr", gamepath); sprintf(Config.Mcd2, "%s/memory_card/mcd002.mcr", gamepath); #endif gp2x_init(900, 16, 11025, 16, 1, 60, 1); #ifndef GP2X gp2x_video_flip_single(); #endif #ifdef IPHONE u32 loadsvs = 0; linesInterlace_user = preferences.interlace; skipCount = skipCountTablePhone[preferences.frameSkip]; skipRate = skipRateTablePhone[preferences.frameSkip]; iSoundMuted = preferences.muted; Config.Cdda = preferences.muted; Config.Xa = preferences.muted; #ifdef WITH_HLE Config.HLE = !preferences.bios; #else Config.HLE = 0; #endif if( (!strcasecmp(filename + (strlen(filename)-4), FORMAT_SV )) ) { u32 pos; loadsvs = 1; sprintf(svsfilename, PSX4ALL_STR, filename); sprintf(iphonefile, PSX4ALL_STR, filename); pos = strlen(iphonefile)-18; iphonefile[pos] = '\0'; packfile = iphonefile; } else { loadsvs = 0; sprintf(iphonefile, PSX4ALL_STR, filename); packfile = iphonefile; } gp2x_video_RGB_clearscreen16(); LoadCdBios = 0; if (SysInit() == -1) { gp2x_deinit(); return 0; } if (InitComponents() == -1) { gp2x_deinit(); return 0; } SysReset(); CheckCdrom(); if( Config.HLE ) { LoadCdBios = 0; if( LoadCdrom() == -1 ) { gp2x_printf(NULL, 120, 120, PSX4ALL_LDD); gp2x_video_flip(); gp2x_timer_delay(2000); gp2x_video_RGB_clearscreen16(); return 0; } } if (loadsvs) { if( LoadState(svsfilename) == -1 ) { gp2x_printf(NULL, 120, 120, PSX4ALL_LSF); gp2x_video_flip(); gp2x_timer_delay(2000); gp2x_video_RGB_clearscreen16(); psxShutdown(); CloseComponents(); gp2x_deinit(); pthread_exit(NULL); } } psx4all_emulating=1; psx4all_prof_start(PROFILER_TOTAL); psxCpu->Execute(); psx4all_prof_end(PROFILER_TOTAL); psx4all_emulating=0; psx4all_prof_show(); #else if( 0 != SelectGame() ) { psx4all_emulating=1; psx4all_prof_start(PROFILER_TOTAL); psxCpu->Execute(); psx4all_prof_end(PROFILER_TOTAL); psx4all_emulating=0; psx4all_prof_show(); } #endif gp2x_deinit(); return 0; }
int main(int argc, char *argv[]) { gp2x_init(1000, 16, 11025,16,1,60, 1); gp2x_sound_volume(100,100); screen16 = (unsigned short *)gp2x_video_RGB[0].screen; int i,j; char temp[255]; FILE *in = NULL; if(argc <= 1) { printf("\nnot enough arguments\n"); //return(TRUE); } else { // the hard-core UI, a command line: for (i=0; (i < argc || argv[i] != NULL); i++) { if(strcmp(argv[i], "--double") == 0) { //screen_size = 1; } if(strcmp(argv[i], "--color white") == 0) { supervision_set_colour_scheme(COLOUR_SCHEME_DEFAULT); } if(strcmp(argv[i], "--color amber") == 0) { supervision_set_colour_scheme(COLOUR_SCHEME_AMBER); } if(strcmp(argv[i], "--color green") == 0) { supervision_set_colour_scheme(COLOUR_SCHEME_GREEN); } if(strcmp(argv[i], "--color blue") == 0) { supervision_set_colour_scheme(COLOUR_SCHEME_BLUE); } } romname = strdup(argv[1]); in = fopen(romname, "r"); if(in == NULL) { printf("The file %s doesn't exist.\n",romname); exit(0); } fflush(in); fclose(in); } supervision_init(); //Init the emulator getRunDir(); if(romname!=NULL){ loadROM(romname); supervision_load((u8*)buffer, (uint32)buffer_size); } else { handleFileMenu(); // File menu } emu_ReadConfig(); gp2x_sound_volume(255,255); gp2x_sound_pause(0); while(1) { CheckKeys(); while(!paused) { CheckKeys(); //key control controls_update(); switch(currentConfig.videoMode){ case 0: supervision_exec((int16*)screenbuffer,1); for(j=0; j < 160; j++) gp2x_memcpy(screen16+(80+(j+40)*320),screenbuffer+(j * 160),160*2); break; case 1: supervision_exec2((int16*)screen16,1); break; case 2: supervision_exec3((int16*)screen16,1); break; default: break; } /*gp2x_video_waitvsync(); sprintf(temp,"FPS: %3d", FPS); gp2x_printf(NULL,0,0,temp); ++svFrm;*/ gp2x_video_RGB_flip(0); controls_reset(); } } supervision_done(); //shutsdown the system gp2x_deinit(); }
static void controller_config(void) { unsigned long ExKey=0; int selected_option=0; int x_Pos = 41; int y_Pos = 48; int options_count = 18; char text[64]; int i; char* options[] = { "FIRE01 Auto = %s", "FIRE02 Auto = %s", "FIRE03 Auto = %s", "FIRE01 = %s", "FIRE02 = %s", "FIRE03 = %s", "FIRE04 = %s", "FIRE05 = %s", "FIRE06 = %s", "FIRE07 = %s", "FIRE08 = %s", "FIRE09 = %s", "FIRE10 = %s", "X Sensitivity = %s", "X Reversed = %s", "Y Sensitivity = %s", "Y Reversed = %s", "Back to Default Values"}; while (1) { /* Draw background image */ load_bmp_8bpp(gp2x_screen8,gp2xmenu_bmp); /* Draw the options */ gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+0,options[0],key_settings->JOY_FIRE1_AUTO?"ON\0":"OFF\0"); gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+8,options[1],key_settings->JOY_FIRE2_AUTO?"ON\0":"OFF\0"); gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+16,options[2],key_settings->JOY_FIRE3_AUTO?"ON\0":"OFF\0"); button_text(key_settings->JOY_FIRE1,text); gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+24,options[3],text); button_text(key_settings->JOY_FIRE2,text); gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+32,options[4],text); button_text(key_settings->JOY_FIRE3,text); gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+40,options[5],text); button_text(key_settings->JOY_FIRE4,text); gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+48,options[6],text); button_text(key_settings->JOY_FIRE5,text); gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+56,options[7],text); button_text(key_settings->JOY_FIRE6,text); gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+64,options[8],text); button_text(key_settings->JOY_FIRE7,text); gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+72,options[9],text); button_text(key_settings->JOY_FIRE8,text); gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+80,options[10],text); button_text(key_settings->JOY_FIRE9,text); gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+88,options[11],text); button_text(key_settings->JOY_FIRE10,text); gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+96,options[12],text); if (x_sensitivity!=-1) sprintf(text,"%d",x_sensitivity); else strcpy(text,"DEFAULT"); gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+104,options[13],text); if (x_reversed) strcpy(text,"ON"); else strcpy(text,"OFF"); gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+112,options[14],text); if (y_sensitivity!=-1) sprintf(text,"%d",y_sensitivity); else strcpy(text,"DEFAULT"); gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+120,options[15],text); if (y_reversed) strcpy(text,"ON"); else strcpy(text,"OFF"); gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+128,options[16],text); gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+136,options[17]); #ifdef PSP gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+152,"Press [] or O to confirm"); #else gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+152,"Press A or B to confirm"); #endif /* Show currently selected item */ gp2x_gamelist_text_out(x_Pos-16,y_Pos+(selected_option*8)," >"); gp2x_video_flip(); while(gp2x_joystick_read()&0x8c0ff55) { gp2x_timer_delay(150); } while(!(ExKey=gp2x_joystick_read()&0x8c0ff55)) { } if(ExKey & GP2X_DOWN){ selected_option++; selected_option = selected_option % options_count; } else if(ExKey & GP2X_UP){ selected_option--; if(selected_option<0) selected_option = options_count - 1; } #ifdef GP2X else if(ExKey & GP2X_R || ExKey & GP2X_L){ #else else if(ExKey & GP2X_RIGHT || ExKey & GP2X_LEFT){ #endif switch(selected_option) { case 0: key_settings->JOY_FIRE1_AUTO=key_settings->JOY_FIRE1_AUTO?0:1; break; case 1: key_settings->JOY_FIRE2_AUTO=key_settings->JOY_FIRE2_AUTO?0:1; break; case 2: key_settings->JOY_FIRE3_AUTO=key_settings->JOY_FIRE3_AUTO?0:1; break; case 3: key_settings->JOY_FIRE1=button_next((key_settings->JOY_FIRE1),(ExKey&GP2X_R)); break; case 4: key_settings->JOY_FIRE2=button_next((key_settings->JOY_FIRE2),(ExKey&GP2X_R)); break; case 5: key_settings->JOY_FIRE3=button_next((key_settings->JOY_FIRE3),(ExKey&GP2X_R)); break; case 6: key_settings->JOY_FIRE4=button_next((key_settings->JOY_FIRE4),(ExKey&GP2X_R)); break; case 7: key_settings->JOY_FIRE5=button_next((key_settings->JOY_FIRE5),(ExKey&GP2X_R)); break; case 8: key_settings->JOY_FIRE6=button_next((key_settings->JOY_FIRE6),(ExKey&GP2X_R)); break; case 9: key_settings->JOY_FIRE7=button_next((key_settings->JOY_FIRE7),(ExKey&GP2X_R)); break; case 10: key_settings->JOY_FIRE8=button_next((key_settings->JOY_FIRE8),(ExKey&GP2X_R)); break; case 11: key_settings->JOY_FIRE9=button_next((key_settings->JOY_FIRE9),(ExKey&GP2X_R)); break; case 12: key_settings->JOY_FIRE10=button_next((key_settings->JOY_FIRE10),(ExKey&GP2X_R)); break; case 13: /* X Sensitivity */ #ifdef GP2X if (ExKey & GP2X_R) { #else if (ExKey & GP2X_RIGHT) { #endif if (x_sensitivity!=-1) { x_sensitivity+=5; if (x_sensitivity>255) x_sensitivity=-1; } else x_sensitivity=0; } else { if (x_sensitivity!=-1) { x_sensitivity-=5; if (x_sensitivity<0) x_sensitivity=-1; } else x_sensitivity=255; } break; case 14: /* X Reversed */ x_reversed=!x_reversed; break; case 15: /* Y Sensitivity */ #ifdef GP2X if (ExKey & GP2X_R) { #else if (ExKey & GP2X_RIGHT) { #endif if (y_sensitivity!=-1) { y_sensitivity+=5; if (y_sensitivity>255) y_sensitivity=-1; } else y_sensitivity=0; } else { if (y_sensitivity!=-1) { y_sensitivity-=5; if (y_sensitivity<0) y_sensitivity=-1; } else y_sensitivity=255; } break; case 16: /* Y Reversed */ y_reversed=!y_reversed; break; case 17: /* Default Values */ key_settings->JOY_FIRE1=GP2X_B; key_settings->JOY_FIRE2=GP2X_X; key_settings->JOY_FIRE3=GP2X_A; key_settings->JOY_FIRE4=GP2X_Y; key_settings->JOY_FIRE5=GP2X_L; key_settings->JOY_FIRE6=GP2X_R; key_settings->JOY_FIRE7=GP2X_VOL_UP; key_settings->JOY_FIRE8=GP2X_VOL_DOWN; key_settings->JOY_FIRE9=GP2X_PUSH; key_settings->JOY_FIRE10=GP2X_START; key_settings->JOY_FIRE1_AUTO=0; key_settings->JOY_FIRE2_AUTO=0; key_settings->JOY_FIRE3_AUTO=0; x_sensitivity=-1; y_sensitivity=-1; x_reversed=0; y_reversed=0; break; } } if ((ExKey & GP2X_A) || (ExKey & GP2X_PUSH) || (ExKey & GP2X_START)) { return; } else if ((ExKey & GP2X_B) || (ExKey & GP2X_SELECT)){ return; } } } static void dipswitches_config(void) { struct InputPort *inp=NULL; /* input ports */ int i; /* Index into the input ports */ int x_Pos; /* Position X in the screen to print */ int y_Pos; /* Position Y in the screen to print */ int index=0; /* Index into the dipswitches to modify */ int num_items; /* Total number of dipswitches */ const char *name; /* Name of the dipswitch */ unsigned long ExKey=0; /* Key status */ unsigned short *value_change; /* Pointer of the value to be changed */ int value_count; /* Number of values */ unsigned short value_range[32]; /* Different values */ unsigned short value; /* Current value*/ unsigned short value_count_m; /* Fire values count */ /* Get input ports of the selected game */ index=0; for (i=0;i<game_num;i++) { if (game_avail[i]==1) { if(index==last_game_selected) { inp=drivers[i]->input_ports; } index++; } } if (!inp) return; i=0; index=0; while(1) { /* Draw background image */ load_bmp_8bpp(gp2x_screen8,gp2xmenu_bmp); i=0; x_Pos=41; y_Pos=48; num_items=0; /* Show currently selected item */ gp2x_gamelist_text_out(x_Pos-16,y_Pos+(index*8)," >"); /* Show Dipswitches configuration */ while (inp[i].type!= IPT_END) { /* Dipswitch Name */ if ( (inp[i].type & ~IPF_MASK) == IPT_DIPSWITCH_NAME && inp[i].name!=0 && (inp[i].type & IPF_UNUSED) == 0 ) { name=inp[i].name; value=inp[i].default_value; if (index==num_items) { value_change = &(inp[i].default_value); value_count=0; value_count_m=1; } else value_count_m=0; } /* Cheat Name */ if ( (inp[i].type & ~IPF_MASK) == (IPT_DIPSWITCH_NAME | IPF_CHEAT) && inp[i].name!=0 && (inp[i].type & IPF_UNUSED) == 0 ) { name=inp[i].name; value=inp[i].default_value; if (index==num_items) { value_change = &(inp[i].default_value); value_count=0; value_count_m=1; } else value_count_m=0; } /* Dipswitch Setting */ if ((inp[i].type & ~IPF_MASK) == IPT_DIPSWITCH_SETTING) { if (value_count_m) { value_range[value_count]=inp[i].default_value; value_count++; } if (value==inp[i].default_value) { /* printf("%s: %s\n",name,inp[i].name); */ gp2x_gamelist_text_out_fmt(x_Pos,y_Pos,"%s: %s",name,inp[i].name); y_Pos+=8; num_items++; } } i++; } #ifdef PSP gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+8,"Press [] or O to confirm"); #else gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+8,"Press A or B to confirm"); #endif gp2x_video_flip(); while(gp2x_joystick_read()&0x8c0ff55) { gp2x_timer_delay(150); } while(!(ExKey=gp2x_joystick_read()&0x8c0ff55)) { } if(ExKey & GP2X_DOWN){ index++; index = index % num_items; } else if(ExKey & GP2X_UP){ index--; if(index<0) index = num_items - 1; } #ifdef GP2X else if(ExKey & GP2X_R || ExKey & GP2X_L){ #else else if(ExKey & GP2X_RIGHT || ExKey & GP2X_LEFT){ #endif /* Modify dipswitch */ for(i=0;i<value_count;i++) { if (value_range[i]==*value_change) break; } if (i==value_count-1) *value_change=value_range[0]; if (i<value_count-1) *value_change=value_range[i+1]; } if ((ExKey & GP2X_A) || (ExKey & GP2X_PUSH) || (ExKey & GP2X_START)) { return; } else if ((ExKey & GP2X_B) || (ExKey & GP2X_SELECT)){ return; } } } #ifdef PSP #define SAVEDATASTRUCTURE "gp2x_freq=%d;gp2x_frameskip=%d;gp2x_frameskip_auto=%d;gp2x_clock_cpu=%d;gp2x_sound_enable=%d;gp2x_clock_sound=%d;key_setting=%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%d,%d,%d,%d;gp2x_double_buffer=%d;gp2x_rotate=%d;gp2x_vsync=%d;gp2x_autofire=%d,%d,%d;\0" #else #define SAVEDATASTRUCTURE "gp2x_freq=%d;gp3x_frameskip=%d;gp2x_frameskip_auto=%d;gp2x_clock_cpu=%d;gp2x_sound_enable=%d;gp2x_clock_sound=%d;key_setting=%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%d,%d,%d,%d;gp2x_double_buffer=%d;gp2x_rotate=%d;gp2x_vsync=%d;gp2x_autofire=%d,%d,%d;\0" #endif #define SAVEDATAFILEDEF "%scfg/mame.cfg\0" #define SAVEDATAFILECFG "%scfg/%s.cfg\0" /*static*/ int show_options(char *game) { unsigned long ExKey=0; int selected_option=0; int x_Pos = 41; int y_Pos = 58; #ifdef PSP int options_count = 10; #else int options_count = 9; #endif char text[256]; FILE *f; /* Load Configuration Files */ gp2x_save_config = 0; #ifdef PSP strcpy(gp2x_path_mame,""); #endif sprintf(text,SAVEDATAFILEDEF, gp2x_path_mame); f=fopen(text,"r"); if (f) { fscanf(f,SAVEDATASTRUCTURE, &gp2x_freq,&gp2x_frameskip,&gp2x_frameskip_auto,&gp2x_clock_cpu,&gp2x_sound_enable,&gp2x_clock_sound, &(key_settings->JOY_FIRE1),&(key_settings->JOY_FIRE2),&(key_settings->JOY_FIRE3),&(key_settings->JOY_FIRE4), &(key_settings->JOY_FIRE5),&(key_settings->JOY_FIRE6),&(key_settings->JOY_FIRE7),&(key_settings->JOY_FIRE8), &(key_settings->JOY_FIRE9),&(key_settings->JOY_FIRE10),&x_sensitivity,&x_reversed,&y_sensitivity,&y_reversed, &gp2x_double_buffer,&gp2x_vsync,&(key_settings->JOY_FIRE1_AUTO),&(key_settings->JOY_FIRE2_AUTO),&(key_settings->JOY_FIRE3_AUTO)); fclose(f); } sprintf(text,SAVEDATAFILECFG, gp2x_path_mame, game); f=fopen(text,"r"); if (f) { fscanf(f,SAVEDATASTRUCTURE, &gp2x_freq,&gp2x_frameskip,&gp2x_frameskip_auto,&gp2x_clock_cpu,&gp2x_sound_enable,&gp2x_clock_sound, &(key_settings->JOY_FIRE1),&(key_settings->JOY_FIRE2),&(key_settings->JOY_FIRE3),&(key_settings->JOY_FIRE4), &(key_settings->JOY_FIRE5),&(key_settings->JOY_FIRE6),&(key_settings->JOY_FIRE7),&(key_settings->JOY_FIRE8), &(key_settings->JOY_FIRE9),&(key_settings->JOY_FIRE10),&x_sensitivity,&x_reversed,&y_sensitivity,&y_reversed, &gp2x_double_buffer,&gp2x_vsync,&(key_settings->JOY_FIRE1_AUTO),&(key_settings->JOY_FIRE2_AUTO),&(key_settings->JOY_FIRE3_AUTO)); fclose(f); } while(1) { /* Draw background image */ load_bmp_8bpp(gp2x_screen8,gp2xmenu_bmp); /* Draw the options */ gp2x_gamelist_text_out(x_Pos,y_Pos,"Selected Game:\0"); fast_memcpy (text,game_list_description(last_game_selected),33); text[32]='\0'; gp2x_gamelist_text_out(x_Pos,y_Pos+10,text); /*gp2x_gamelist_text_out(x_Pos,y_Pos+10,game_list_description(last_game_selected));*/ #ifdef GP2X /* GP2X Clock*/ gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30, "GP2X Clock %d MHz", gp2x_freq); /* Frame-Skip */ if(gp2x_frameskip_auto && gp2x_frameskip!=0) { gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+40,"Frame-Skip %s %d %s","<=",gp2x_frameskip, "(Auto-skip)"); } else{ gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+40,"Frame-Skip %s %d %s","=",gp2x_frameskip,""); } #else #ifdef PSP switch (gp2x_rotate) { case 0: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video %s","Fixed"); break; case 1: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video %s","Fixed DIV2"); break; case 2: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video %s","SW Scaled"); break; default: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video %s","SW Streched"); break; } /* Frame-Skip */ if(gp2x_frameskip_auto && gp2x_frameskip!=0) { gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+40,"Frame-Skip %s %d %s","<=",gp2x_frameskip, "(Auto-skip)"); } else{ gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+40,"Frame-Skip %s %d %s","=",gp2x_frameskip,""); } #else switch (gp2x_rotate) { case 0: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video %s","Fixed"); break; case 1: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video %s","Fixed DIV2"); break; case 2: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video %s","SW Scaled"); break; default: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video %s","HW Scaled"); break; } if (gp2x_frameskip_auto) { gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+40,"Frame-Skip Auto"); gp2x_frameskip=-1; } else gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+40,"Frame-Skip = %d",gp2x_frameskip); #endif #endif /* Video Clock */ gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+50,"Video Clock %d%%",gp2x_clock_cpu); /* Video Sync */ #ifdef GP2X if (gp2x_double_buffer && gp2x_vsync==1) gp2x_gamelist_text_out(x_Pos,y_Pos+60,"Video Sync VSync+DblBuf"); else if (gp2x_double_buffer && gp2x_vsync==0) gp2x_gamelist_text_out(x_Pos,y_Pos+60,"Video Sync DblBuf"); else if (!gp2x_double_buffer && gp2x_vsync==1) gp2x_gamelist_text_out(x_Pos,y_Pos+60,"Video Sync VSync"); else if (gp2x_vsync==-1) gp2x_gamelist_text_out(x_Pos,y_Pos+60,"Video Sync Off"); else gp2x_gamelist_text_out(x_Pos,y_Pos+60,"Video Sync Normal"); #else if (gp2x_vsync) gp2x_gamelist_text_out(x_Pos,y_Pos+60,"Video Sync On"); else gp2x_gamelist_text_out(x_Pos,y_Pos+60,"Video Sync Off"); #endif /* Sound */ switch(gp2x_sound_enable) { case 0: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Sound %s","Sound OFF"); break; #ifdef GP2X case 1: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Sound %s","Sound ON (15 KHz)"); break; case 2: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Sound %s","Sound ON (22 KHz)"); break; case 3: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Sound %s","Sound ON (33 KHz)"); break; case 4: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Sound %s","Sound ON (44 KHz)"); break; case 5: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Sound %s","Sound ON (11 KHz)"); break; #else case 1: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Sound %s","Sound ON"); break; case 2: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Sound %s","Emulated but OFF"); break; case 3: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Sound %s","Accurate and ON"); break; #ifdef PSP case 4: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Sound %s","44k 16v"); break; case 5: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Sound %s","44k 8v"); break; case 6: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Sound %s","44k 4v"); break; case 7: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Sound %s","33k 16v"); break; case 8: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Sound %s","33k 8v"); break; case 9: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Sound %s","33k 4v"); break; #endif #endif } /* Audio Clock */ gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+80,"Audio Clock %d%%",gp2x_clock_sound); /* Controller Configuration */ gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+90,"Controller Configuration"); /* Controller Configuration */ gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+100,"Dipswitches Configuration"); /* Save Configuration */ switch(gp2x_save_config) { case 0: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+110,"No Save Configuration"); break; case 1: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+110,"Save Configuration"); break; case 2: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+110,"Save as Default"); break; } #ifdef PSP /* PSP Clock*/ gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+120, "PSP Clock %d MHz", gp2x_freq); gp2x_gamelist_text_out(x_Pos,y_Pos+130,"Press [] to confirm, X return\0"); #else gp2x_gamelist_text_out(x_Pos,y_Pos+130,"Press B to confirm, X to return\0"); #endif /* Show currently selected item */ gp2x_gamelist_text_out(x_Pos-16,y_Pos+(selected_option*10)+30," >"); gp2x_video_flip(); while(gp2x_joystick_read()&0x8c0ff55) { gp2x_timer_delay(150); } while(!(ExKey=gp2x_joystick_read()&0x8c0ff55)) { } if(ExKey & GP2X_DOWN){ selected_option++; selected_option = selected_option % options_count; } else if(ExKey & GP2X_UP){ selected_option--; if(selected_option<0) selected_option = options_count - 1; } #ifdef GP2X else if(ExKey & GP2X_R || ExKey & GP2X_L){ #else else if(ExKey & GP2X_RIGHT || ExKey & GP2X_LEFT){ #endif switch(selected_option) { case 0: #ifdef GP2X /* GP2X Clock */ if(ExKey & GP2X_R){ switch (gp2x_freq) { case 66: gp2x_freq=75;break; case 75: gp2x_freq=80;break; case 80: gp2x_freq=100;break; case 100: gp2x_freq=120;break; case 120: gp2x_freq=133;break; case 133: gp2x_freq=150;break; case 150: gp2x_freq=166;break; case 166: gp2x_freq=180;break; case 180: gp2x_freq=200;break; case 200: gp2x_freq=225;break; case 225: gp2x_freq=233;break; case 233: gp2x_freq=245;break; case 245: gp2x_freq=250;break; case 250: gp2x_freq=255;break; case 255: gp2x_freq=260;break; case 260: gp2x_freq=265;break; case 265: gp2x_freq=266;break; case 266: gp2x_freq=270;break; case 270: gp2x_freq=275;break; case 275: gp2x_freq=280;break; case 280: gp2x_freq=285;break; case 285: gp2x_freq=290;break; case 290: gp2x_freq=295;break; case 295: gp2x_freq=300;break; case 300: gp2x_freq=66;break; } } else { switch (gp2x_freq) { case 66: gp2x_freq=300;break; case 75: gp2x_freq=66;break; case 80: gp2x_freq=75;break; case 100: gp2x_freq=80;break; case 120: gp2x_freq=100;break; case 133: gp2x_freq=120;break; case 150: gp2x_freq=133;break; case 166: gp2x_freq=150;break; case 180: gp2x_freq=166;break; case 200: gp2x_freq=180;break; case 225: gp2x_freq=200;break; case 233: gp2x_freq=225;break; case 245: gp2x_freq=233;break; case 250: gp2x_freq=245;break; case 255: gp2x_freq=250;break; case 260: gp2x_freq=255;break; case 265: gp2x_freq=260;break; case 266: gp2x_freq=265;break; case 270: gp2x_freq=266;break; case 275: gp2x_freq=270;break; case 280: gp2x_freq=275;break; case 285: gp2x_freq=280;break; case 290: gp2x_freq=285;break; case 295: gp2x_freq=290;break; case 300: gp2x_freq=295;break; } } #else if (ExKey & GP2X_RIGHT) gp2x_rotate++; else if (ExKey & GP2X_LEFT) gp2x_rotate--; if (gp2x_rotate<0) gp2x_rotate=3; else if (gp2x_rotate>3) gp2x_rotate=0; #ifdef DREAMCAST if (gp2x_rotate==3) gp2x_vsync=1; #endif #endif break; case 1: /* "Frame-Skip" */ #ifdef GP2X if(ExKey & GP2X_R){ #else if(ExKey & GP2X_RIGHT){ #endif gp2x_frameskip ++; if (!gp2x_frameskip) gp2x_frameskip_auto=0; else if (gp2x_frameskip > 5) { #ifdef GP2X gp2x_frameskip = 0; gp2x_frameskip_auto=!gp2x_frameskip_auto; #else #ifdef PSP gp2x_frameskip = 0; gp2x_frameskip_auto=!gp2x_frameskip_auto; #else gp2x_frameskip = -1; gp2x_frameskip_auto = 1; #endif #endif } } else{ gp2x_frameskip--; #ifdef GP2X if (gp2x_frameskip < 0){ gp2x_frameskip = 5; gp2x_frameskip_auto=!gp2x_frameskip_auto; } #else #ifdef PSP if (gp2x_frameskip < 0){ gp2x_frameskip = 5; gp2x_frameskip_auto=!gp2x_frameskip_auto; } #else if (gp2x_frameskip==-1) gp2x_frameskip_auto=1; else if (gp2x_frameskip<-1) { gp2x_frameskip = 5; gp2x_frameskip_auto = 0; } #endif #endif } break; case 2: /* "Video Clock" */ #ifdef GP2X if(ExKey & GP2X_R){ #else if(ExKey & GP2X_RIGHT){ #endif gp2x_clock_cpu += 10; /* Add 10% */ if (gp2x_clock_cpu > 200) /* 200% is the max */ gp2x_clock_cpu = 200; } else{ gp2x_clock_cpu -= 10; /* Subtract 10% */ if (gp2x_clock_cpu < 10) /* 10% is the min */ gp2x_clock_cpu = 10; } break; case 3: /* Video Sync */ #ifdef GP2X if (!gp2x_double_buffer && gp2x_vsync==0) { gp2x_double_buffer=0; gp2x_vsync=-1; } else if (!gp2x_double_buffer && gp2x_vsync==-1) { gp2x_double_buffer=1; gp2x_vsync=0; } else if (gp2x_double_buffer && gp2x_vsync==0) { gp2x_double_buffer=0; gp2x_vsync=1; } else if (!gp2x_double_buffer && gp2x_vsync==1) { gp2x_double_buffer=1; gp2x_vsync=1; } else { gp2x_double_buffer=0; gp2x_vsync=0; } #else gp2x_vsync=(gp2x_vsync+1)&1; #endif break; case 4: #ifndef NOSOUND /* "Sound" */ #ifdef GP2X if(ExKey & GP2X_R){ #else if(ExKey & GP2X_RIGHT){ #endif gp2x_sound_enable++; #ifdef PSP if (gp2x_sound_enable>9) #else #ifdef GP2X if (gp2x_sound_enable>5) #else if (gp2x_sound_enable>3) #endif #endif gp2x_sound_enable=0; } else { gp2x_sound_enable--; if (gp2x_sound_enable<0) #ifdef PSP gp2x_sound_enable=9; #else #ifdef GP2X gp2x_sound_enable=5; #else gp2x_sound_enable=3; #endif #endif } #endif break; case 5: /* "Audio Clock" */ #ifdef GP2X if(ExKey & GP2X_R){ #else if(ExKey & GP2X_RIGHT){ #endif gp2x_clock_sound += 10; /* Add 10% */ if (gp2x_clock_sound > 200) /* 200% is the max */ gp2x_clock_sound = 200; } else{ gp2x_clock_sound -= 10; /* Subtract 10% */ if (gp2x_clock_sound < 10) /* 10% is the min */ gp2x_clock_sound = 10; } break; case 6: /* Controller Configuration */ controller_config(); break; case 7: /* Dipswitches Configuration */ dipswitches_config(); break; case 8: /* Save Configuration */ #ifdef GP2X if(ExKey & GP2X_R){ #else if(ExKey & GP2X_RIGHT){ #endif gp2x_save_config += 1; if (gp2x_save_config > 2) gp2x_save_config = 0; } else{ gp2x_save_config -= 1; if (gp2x_save_config < 0) gp2x_save_config = 2; } break; #ifdef PSP case 9: /* PSP Clock */ if(ExKey & GP2X_RIGHT){ switch (gp2x_freq) { case 133: gp2x_freq=166;break; case 166: gp2x_freq=200;break; case 200: gp2x_freq=222;break; case 222: gp2x_freq=266;break; case 266: gp2x_freq=300;break; case 300: gp2x_freq=333;break; case 333: gp2x_freq=133;break; } } else { switch (gp2x_freq) { case 133: gp2x_freq=333;break; case 166: gp2x_freq=133;break; case 200: gp2x_freq=166;break; case 222: gp2x_freq=200;break; case 266: gp2x_freq=222;break; case 300: gp2x_freq=266;break; case 333: gp2x_freq=300;break; } } break; #endif } } #ifndef GP2X if ((ExKey & GP2X_A) || (ExKey & GP2X_START)) { #else if ((ExKey & GP2X_A) || (ExKey & GP2X_B) || (ExKey & GP2X_PUSH) || (ExKey & GP2X_START)) { #endif /* Save Configuration Files */ if (gp2x_save_config>1) { sprintf(text,SAVEDATAFILEDEF, gp2x_path_mame); f=fopen(text,"w"); if (f) { fprintf(f,SAVEDATASTRUCTURE, gp2x_freq,gp2x_frameskip,gp2x_frameskip_auto,gp2x_clock_cpu,gp2x_sound_enable,gp2x_clock_sound, (key_settings->JOY_FIRE1),(key_settings->JOY_FIRE2),(key_settings->JOY_FIRE3),(key_settings->JOY_FIRE4), (key_settings->JOY_FIRE5),(key_settings->JOY_FIRE6),(key_settings->JOY_FIRE7),(key_settings->JOY_FIRE8), (key_settings->JOY_FIRE9),(key_settings->JOY_FIRE10),x_sensitivity,x_reversed,y_sensitivity,y_reversed, gp2x_double_buffer,gp2x_vsync,(key_settings->JOY_FIRE1_AUTO),(key_settings->JOY_FIRE2_AUTO),(key_settings->JOY_FIRE3_AUTO)); fclose(f); #ifdef GP2X sync(); #endif } } if (gp2x_save_config>0) { sprintf(text,SAVEDATAFILECFG, gp2x_path_mame, game); f=fopen(text,"w"); if (f) { fprintf(f,SAVEDATASTRUCTURE, gp2x_freq,gp2x_frameskip,gp2x_frameskip_auto,gp2x_clock_cpu,gp2x_sound_enable,gp2x_clock_sound, (key_settings->JOY_FIRE1),(key_settings->JOY_FIRE2),(key_settings->JOY_FIRE3),(key_settings->JOY_FIRE4), (key_settings->JOY_FIRE5),(key_settings->JOY_FIRE6),(key_settings->JOY_FIRE7),(key_settings->JOY_FIRE8), (key_settings->JOY_FIRE9),(key_settings->JOY_FIRE10),x_sensitivity,x_reversed,y_sensitivity,y_reversed, gp2x_rotate,gp2x_vsync,(key_settings->JOY_FIRE1_AUTO),(key_settings->JOY_FIRE2_AUTO),(key_settings->JOY_FIRE3_AUTO)); fclose(f); #ifdef GP2X sync(); #endif } } /* Selected game will be run */ return 1; } #ifndef GP2X else if ((ExKey & GP2X_X) || (ExKey & GP2X_PUSH) || (ExKey & GP2X_SELECT)){ #else else if ((ExKey & GP2X_X) || (ExKey & GP2X_Y) || (ExKey & GP2X_SELECT)){ #endif /* Return To Menu */ return 0; } } } void select_game(char *game) { unsigned long ExKey; int c; /* No Selected game */ strcpy(game,"builtinn"); /* Clean screen */ gp2x_video_flip(); /* enable extra PSP-2000 memory */ #ifdef PSP_2K psp2k_mem_init(); #endif /* Wait until no key pressed */ while(gp2x_joystick_read()&0x8c0ff55) gp2x_timer_delay(100); /* Available games? */ if(game_num_avail==0) { gp2x_mame_palette(); gp2x_text_out( 35, 110, "ERROR: NO AVAILABLE GAMES FOUND" ); gp2x_video_flip(); while(1) { if (gp2x_joystick_read()&GP2X_A) exit(0);} } #ifdef PSP SetGP2XClock(133); #else SetGP2XClock(66); #endif /* Wait until user selects a game */ while(1) { game_list_view(&last_game_selected); gp2x_video_flip(); #ifdef GP2X if( (gp2x_joystick_read()&0x8c0ff55)) gp2x_timer_delay(100); while(!(ExKey=gp2x_joystick_read()&0x8c0ff55)) { if ((ExKey & GP2X_L) && (ExKey & GP2X_R)) exit(0); } #else if( (gp2x_joystick_read()&0x8c0ff55)) gp2x_timer_delay(100); while(!(ExKey=gp2x_joystick_read()&0x8c0ff55)) gp2x_timer_delay(100); #endif if (ExKey & GP2X_UP) last_game_selected--; if (ExKey & GP2X_DOWN) last_game_selected++; if (ExKey & GP2X_L) last_game_selected-=21; if (ExKey & GP2X_R) last_game_selected+=21; if ((ExKey & GP2X_L) && (ExKey & GP2X_R)) exit(0); /* If Button A is pressed, or a rom name was passed to this application */ #ifndef GP2X { #ifdef DREAMCAST static int parasalir=0; if (ExKey & GP2X_PUSH) parasalir++; else parasalir=0; if (parasalir>8) gp2x_deinit(); #else if (ExKey & GP2X_PUSH) gp2x_deinit(); #endif } if ((ExKey & GP2X_A) || (ExKey & GP2X_START)) #else if ((ExKey & GP2X_A) || (ExKey & GP2X_B) || (ExKey & GP2X_PUSH) || (ExKey & GP2X_START)) #endif { /* Select the game */ game_list_select(last_game_selected, game); /* Emulation Options */ if(show_options(game)) { /* break out of the while(1) loop */ break; } } } SetGP2XClock(gp2x_freq); }
void exitMenu(void) { supervision_done(); //shutsdown the system gp2x_deinit(); exit(0); }
// read track // time : int 0 - minute ; int 1 - second ; int 2 - frame // uses int format s32 CDR_readTrack(u8 *time) { // check cache for current sector u32 curr_sector = MSF2SECT((time[0]), (time[1]), (time[2])); s32 i; u8 minute = (time[0]); if( curr_sector >= cdlastsector && curr_sector < cdlastsector + BUFFER_SECTORS ) { cdlastbuffer = (u8*)((u32)cdbuffer + ((curr_sector - cdlastsector) * CD_FRAMESIZE_RAW)); return 0; } // Not found in cache... cdlastsector = curr_sector; cdlastbuffer = cdbuffer; if (!fmode) { fseek(cdHandle, curr_sector * CD_FRAMESIZE_RAW, SEEK_SET); fread(cdlastbuffer, (CD_FRAMESIZE_RAW*BUFFER_SECTORS), 1, cdHandle); } else if (fmode == 1) { //.Z int ret; for(i = 0; i < BUFFER_SECTORS; i++) { u32 pos, p; u32 size; u8 Zbuf[CD_FRAMESIZE_RAW+256]; p = curr_sector + i; pos = (u32)(Ztable[p * 6] | (Ztable[p * 6 + 1] << 8) | (Ztable[p * 6 + 2] << 16) | (Ztable[p * 6 + 3] << 24)); fseek(cdHandle, pos, SEEK_SET); p = (u16)(Ztable[p * 6 + 4] | (Ztable[p * 6 + 4 + 1] << 8)); fread(Zbuf, p, 1, cdHandle); size = CD_FRAMESIZE_RAW; ret = uncompress(cdlastbuffer + (i * CD_FRAMESIZE_RAW), &size, Zbuf, p); if( ret != Z_OK ) { printf("uncompress error %d !\n", ret); gp2x_deinit(); } } } else if (fmode == 2) { // .bz SysPrintf("BZ FORMAT IS NOT SUPPORTED."); } else { // .ZNX for(i = 0; i < BUFFER_SECTORS; i++) { int ret; u32 pos, p; u32 size; u8 Zbuf[CD_FRAMESIZE_RAW+256]; p = curr_sector + i; pos = (u32)(Ztable[p * 10] | (Ztable[p * 10 + 1] << 8) | (Ztable[p * 10 + 2] << 16) | (Ztable[p * 10 + 3] << 24)); fseek(cdHandle, pos, SEEK_SET); p = (u16)(Ztable[p * 10 + 4] | (Ztable[p * 10 + 4 + 1] << 8)); fread(Zbuf, p, 1, cdHandle); size = CD_FRAMESIZE_RAW; ret = uncompress(cdlastbuffer + (i * CD_FRAMESIZE_RAW), &size, Zbuf, p); if( ret != Z_OK ) { printf("uncompress error %d !\n", ret); gp2x_deinit(); } } } return 0; }
int main (int argc, char **argv) { int res, i, j = 0, game_index; char *playbackname = NULL; char gamenameselection[32]; int use_cyclone=1; int use_drz80_save=0; int use_drz80_snd_save=1; int use_drz80; int use_drz80_snd; extern int video_scale; extern int video_border; extern int video_aspect; extern int throttle; extern int soundcard; int use_gui=0; int first_run=1; kiosk_mode=0; { char *abspath = (char*)malloc(PATH_MAX); if (!abspath) { logerror("Out of memory\n"); } realpath(argv[0], abspath); char *dirsep = strrchr(abspath, '/'); if( dirsep != 0 ) *dirsep = 0; chdir(abspath); free(abspath); } memset(&options,0,sizeof(options)); /* these two are not available in mame.cfg */ errorlog = 0; game_index = -1; soundcard=-1; for (i = 1;i < argc;i++) /* V.V_121997 */ { if (strcasecmp(argv[i],"-log") == 0) errorlog = fopen("error.log","wa"); if (strcasecmp(argv[i],"-nocyclone") == 0) use_cyclone=0; if (strcasecmp(argv[i],"-drz80") == 0) use_drz80_save=1; if (strcasecmp(argv[i],"-nodrz80_snd") == 0) use_drz80_snd_save=0; if (strcasecmp(argv[i],"-scale") == 0) video_scale=1; if (strcasecmp(argv[i],"-border") == 0) video_border=1; if (strcasecmp(argv[i],"-aspect") == 0) video_aspect=1; if (strcasecmp(argv[i],"-nothrottle") == 0) throttle=0; if (strcasecmp(argv[i],"-nosound") == 0) soundcard=0; if (strcasecmp(argv[i],"-playback") == 0) { i++; if (i < argc) /* point to inp file name */ playbackname = argv[i]; } } if (argc == 1) use_gui=1; /* check for frontend options */ if(!use_gui) { res = frontend_help (argc, argv); /* if frontend options were used, return to DOS with the error code */ if (res != 1234) { exit (res); } } for (j = 1; j < argc; j++) { if (argv[j][0] != '-') { strcpy(gamenameselection, argv[j]); break; } } if(init_SDL()==0) { exit(1); }; gui_loop: if(use_gui) { usleep(1000000/2); gp2x_joystick_clear(); //Normally read in the game start but we need some vars //setting for the frontend. parse_cmdline (argc, argv, 1); frontend_gui(gamenameselection, first_run); first_run=0; usleep(1000000/2); //Clear input queue gp2x_joystick_clear(); } /* handle playback which is not available in mame.cfg */ init_inpdir(); /* Init input directory for opening .inp for playback */ if (playbackname != NULL) options.playback = osd_fopen(playbackname,0,OSD_FILETYPE_INPUTLOG,0); /* check for game name embedded in .inp header */ if (options.playback) { INP_HEADER inp_header; /* read playback header */ osd_fread(options.playback, &inp_header, sizeof(INP_HEADER)); if (!isalnum(inp_header.name[0])) /* If first byte is not alpha-numeric */ osd_fseek(options.playback, 0, SEEK_SET); /* old .inp file - no header */ else { for (i = 0; (drivers[i] != 0); i++) /* find game and play it */ { if (strcmp(drivers[i]->name, inp_header.name) == 0) { game_index = i; printf("Playing back previously recorded game %s (%s) [press return]\n", drivers[game_index]->name,drivers[game_index]->description); getchar(); break; } } } } /* If not playing back a new .inp file */ if (game_index == -1) { /* do we have a driver for this? */ { for (i = 0; drivers[i] && (game_index == -1); i++) { if (strcasecmp(gamenameselection,drivers[i]->name) == 0) { game_index = i; break; } } } if (game_index == -1) { printf("Game \"%s\" not supported\n", argv[j]); return 1; } } /* parse generic (os-independent) options */ parse_cmdline (argc, argv, game_index); { /* Mish: I need sample rate initialised _before_ rom loading for optional rom regions */ extern int soundcard; if (soundcard == 0) { /* silence, this would be -1 if unknown in which case all roms are loaded */ Machine->sample_rate = 0; /* update the Machine structure to show that sound is disabled */ options.samplerate=0; } } /* handle record which is not available in mame.cfg */ for (i = 1; i < argc; i++) { if (strcasecmp(argv[i],"-record") == 0) { i++; if (i < argc) options.record = osd_fopen(argv[i],0,OSD_FILETYPE_INPUTLOG,1); } } if (options.record) { INP_HEADER inp_header; memset(&inp_header, '\0', sizeof(INP_HEADER)); strcpy(inp_header.name, drivers[game_index]->name); /* MAME32 stores the MAME version numbers at bytes 9 - 11 * MAME DOS keeps this information in a string, the * Windows code defines them in the Makefile. */ /* inp_header.version[0] = 0; inp_header.version[1] = VERSION; inp_header.version[2] = BETA_VERSION; */ osd_fwrite(options.record, &inp_header, sizeof(INP_HEADER)); } /* Replace M68000 by CYCLONE */ if (use_cyclone) { for (i=0;i<MAX_CPU;i++) { int *type=(int*)&(drivers[game_index]->drv->cpu[i].cpu_type); if (((*type)&0xff)==CPU_M68000 || ((*type)&0xff)==CPU_M68010 ) { *type=((*type)&(~0xff))|CPU_CYCLONE; } } } use_drz80_snd = use_drz80_snd_save; use_drz80 = use_drz80_save; // Do not use the DrZ80 core for games that are listed as not compatible // in the frontend list for (i=0;i<NUMGAMES;i++) { if (strcmp(drivers[game_index]->name,fe_drivers[i].name)==0) { /* ASM cores: 0=None,1=Cyclone,2=DrZ80,3=Cyclone+DrZ80,4=DrZ80(snd),5=Cyclone+DrZ80(snd) */ if(fe_drivers[i].cores == 0 || fe_drivers[i].cores == 1) { use_drz80_snd=0; use_drz80=0; break; } } } #if (HAS_DRZ80) /* Replace Z80 by DRZ80 */ if (use_drz80) { for (i=0;i<MAX_CPU;i++) { int *type=(int*)&(drivers[game_index]->drv->cpu[i].cpu_type); if (((*type)&0xff)==CPU_Z80) { *type=((*type)&(~0xff))|CPU_DRZ80; } } } /* Replace Z80 with DRZ80 only for sound CPUs */ if (use_drz80_snd) { for (i=0;i<MAX_CPU;i++) { int *type=(int*)&(drivers[game_index]->drv->cpu[i].cpu_type); if ((((*type)&0xff)==CPU_Z80) && ((*type)&CPU_AUDIO_CPU)) { *type=((*type)&(~0xff))|CPU_DRZ80; } } } #endif /* for (i=0;i<MAX_CPU;i++) { int *type=(int*)&(drivers[game_index]->drv->cpu[i].cpu_type); if (((*type)&0xff)==CPU_V30) { *type=((*type)&(~0xff))|CPU_ARMV30; } } for (i=0;i<MAX_CPU;i++) { int *type=(int*)&(drivers[game_index]->drv->cpu[i].cpu_type); if (((*type)&0xff)==CPU_V33) { *type=((*type)&(~0xff))|CPU_ARMV33; } } */ // Remove the mouse usage for certain games if ( (strcasecmp(drivers[game_index]->name,"hbarrel")==0) || (strcasecmp(drivers[game_index]->name,"hbarrelw")==0) || (strcasecmp(drivers[game_index]->name,"midres")==0) || (strcasecmp(drivers[game_index]->name,"midresu")==0) || (strcasecmp(drivers[game_index]->name,"midresj")==0) || (strcasecmp(drivers[game_index]->name,"tnk3")==0) || (strcasecmp(drivers[game_index]->name,"tnk3j")==0) || (strcasecmp(drivers[game_index]->name,"ikari")==0) || (strcasecmp(drivers[game_index]->name,"ikarijp")==0) || (strcasecmp(drivers[game_index]->name,"ikarijpb")==0) || (strcasecmp(drivers[game_index]->name,"victroad")==0) || (strcasecmp(drivers[game_index]->name,"dogosoke")==0) || (strcasecmp(drivers[game_index]->name,"gwar")==0) || (strcasecmp(drivers[game_index]->name,"gwarj")==0) || (strcasecmp(drivers[game_index]->name,"gwara")==0) || (strcasecmp(drivers[game_index]->name,"gwarb")==0) || (strcasecmp(drivers[game_index]->name,"bermudat")==0) || (strcasecmp(drivers[game_index]->name,"bermudaj")==0) || (strcasecmp(drivers[game_index]->name,"bermudaa")==0) || (strcasecmp(drivers[game_index]->name,"mplanets")==0) || (strcasecmp(drivers[game_index]->name,"forgottn")==0) || (strcasecmp(drivers[game_index]->name,"lostwrld")==0) || (strcasecmp(drivers[game_index]->name,"gondo")==0) || (strcasecmp(drivers[game_index]->name,"makyosen")==0) || (strcasecmp(drivers[game_index]->name,"topgunr")==0) || (strcasecmp(drivers[game_index]->name,"topgunbl")==0) || (strcasecmp(drivers[game_index]->name,"tron")==0) || (strcasecmp(drivers[game_index]->name,"tron2")==0) || (strcasecmp(drivers[game_index]->name,"kroozr")==0) ||(strcasecmp(drivers[game_index]->name,"crater")==0) || (strcasecmp(drivers[game_index]->name,"dotron")==0) || (strcasecmp(drivers[game_index]->name,"dotrone")==0) || (strcasecmp(drivers[game_index]->name,"zwackery")==0) || (strcasecmp(drivers[game_index]->name,"ikari3")==0) || (strcasecmp(drivers[game_index]->name,"searchar")==0) || (strcasecmp(drivers[game_index]->name,"sercharu")==0) || (strcasecmp(drivers[game_index]->name,"timesold")==0) || (strcasecmp(drivers[game_index]->name,"timesol1")==0) || (strcasecmp(drivers[game_index]->name,"btlfield")==0) || (strcasecmp(drivers[game_index]->name,"aztarac")==0)) { extern int use_mouse; use_mouse=0; } /* go for it */ printf ("%s (%s)...\n",drivers[game_index]->description,drivers[game_index]->name); res = run_game (game_index); /* close open files */ if (errorlog) fclose (errorlog); if (options.playback) osd_fclose (options.playback); if (options.record) osd_fclose (options.record); if (options.language_file) osd_fclose (options.language_file); gp2x_deinit(); game_index = -1; if(use_gui) goto gui_loop; deinit_SDL(); exit (res); }
s32 SelectGame() { u32 keys; s32 loadst = 0; s32 menu_state = 0; s32 menu_pos = 0; s8* newpackfile = NULL; gp2x_video_RGB_clearscreen16(); gp2x_video_flip(); #if 1 // pick a game for(;;) { gp2x_video_RGB_clearscreen16(); gp2x_printf(NULL, 0, 10, "psx4all http://github.com/uli/psx4all-dingoo"); gp2x_printf(NULL, 0, 20, "CREDITS: UNAI - ZODTTD - HLIDE - CHUI - TINNUS"); gp2x_printf(NULL, 0, 30, "Dingoo/MIPS port by Ulrich Hecht"); keys = gp2x_joystick_read(); // draw arrow gp2x_printf(NULL, 10, (menu_pos * 10) + PSX4ALL_MENU_START_POS, "----> "); // read key input for up and down for menu position if( keys & GP2X_UP ) { if( menu_pos > 0 ) menu_pos--; } switch(menu_state) { case PSX4ALL_MENU_DEFAULT_STATE: if( keys & GP2X_DOWN ) { if( menu_pos < 4 ) menu_pos++; } break; case PSX4ALL_MENU_GPU_STATE: if( keys & GP2X_DOWN ) { if( menu_pos < 15 ) menu_pos++; } break; case PSX4ALL_MENU_SPU_STATE: if( keys & GP2X_DOWN ) { if( menu_pos < 1 ) menu_pos++; } break; case PSX4ALL_MENU_BIOS_STATE: if( keys & GP2X_DOWN ) { if( menu_pos < 1 ) menu_pos++; } break; case PSX4ALL_MENU_GAMESTATE_STATE: if( keys & GP2X_DOWN ) { if( menu_pos < 4 ) menu_pos++; } break; } // text to display for each option switch(menu_state) { case PSX4ALL_MENU_DEFAULT_STATE: gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 0, "GRAPHICS OPTIONS"); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 10, "SOUND OPTIONS"); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 20, "BIOS OPTIONS"); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 30, "FILE OPTIONS"); if (psx4all_emulating) gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 40, "RESUME EMULATION"); else gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 40, "QUIT"); break; case PSX4ALL_MENU_GPU_STATE: gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 0, "Show FPS %s", (displayFrameInfo == false ? "OFF" : "ON")); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 10, "Show GPU Stats %s", (displayGpuStats == false ? "OFF" : "ON")); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 20, "Display Video Memory %s", (displayVideoMemory == false ? "OFF" : "ON")); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 30, "Set NULL GPU %s", (activeNullGPU == false ? "OFF" : "ON")); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 40, "Interlace Count %d", linesInterlace_user ); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 50, "Frame Limit %s", (enableFrameLimit == false ? "OFF" : "ON")); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 60, "Frame Skip %d/%d", skipCount, skipRate); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 70, "Abe's Oddysee Fix %s", (enableAbbeyHack == false ? "OFF" : "ON")); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 80, "Cycle Multiplier %d", PsxCycleMult); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 90, "Frameskip: Line %s", hardframeskip_line ? "ON" : "OFF"); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 100, "Frameskip: Poly %s", hardframeskip_poly ? "ON" : "OFF"); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 110, "Frameskip: Sprite %s", hardframeskip_sprite ? "ON" : "OFF"); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 120, "Frameskip: Image %s", hardframeskip_image ? "ON" : "OFF"); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 130, "Frameskip: Blit %s", hardframeskip_blit ? "ON" : "OFF"); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 140, "Wall Clock Timing %s", use_wall_clock_time ? "ON" : "OFF"); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 150, "<-Back"); break; case PSX4ALL_MENU_SPU_STATE: gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 0, "SOUND IS %s", (iSoundMuted == 0 ? "ON" : "OFF")); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 10, "BACK"); break; case PSX4ALL_MENU_BIOS_STATE: switch(biosVersion) { case 0: gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 0, "Bios file: scph1000 (Japanese)"); break; case 1: gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 0, "Bios file: scph1001 (North American)"); break; case 2: gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 0, "Bios file: scph1002 (European)"); break; case 3: gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 0, "Bios file: scph5500 (Japanese)"); break; case 4: gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 0, "Bios file: scph5501 (North American)"); break; case 5: gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 0, "Bios file: scph5502 (European)"); break; case 6: gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 0, "Bios file: scph7001 (North American)"); break; case 7: gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 0, "Bios file: scph7002 (European)"); break; case 8: gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 0, "Bios file: scph7003 (Asian)"); break; case 9: gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 0, "Bios file: scph7500 (Japanese)"); break; case 10: gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 0, "Bios file: scph7501 (North American)"); break; case 11: gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 0, "Bios file: scph7502 (European)"); break; case 12: gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 0, "Bios file: scph7503 (Japanese updated)"); break; default: break; } gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 10, "BACK"); break; case PSX4ALL_MENU_GAMESTATE_STATE: gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 0, "SAVE GAME STATE" ); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 10, "LOAD GAME STATE"); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 20, "LOAD A GAME"); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 30, "LOAD A GAME WITHOUT BIOS"); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 40, "BACK"); break; } // logic for each option switch(menu_state) { case PSX4ALL_MENU_DEFAULT_STATE: if( keys & GP2X_B ) { switch(menu_pos) { case 0: menu_state = PSX4ALL_MENU_GPU_STATE; menu_pos = 0; break; case 1: menu_state = PSX4ALL_MENU_SPU_STATE; menu_pos = 0; break; case 2: menu_state = PSX4ALL_MENU_BIOS_STATE; menu_pos = 0; break; case 3: menu_state = PSX4ALL_MENU_GAMESTATE_STATE; menu_pos = 0; break; case 4: // clear screen so interlaced screens look ok gp2x_video_RGB_clearscreen16(); return 0; default: break; } } if (keys & GP2X_L && psx4all_emulating) { gp2x_video_RGB_clearscreen16(); return 0; } break; case PSX4ALL_MENU_GPU_STATE: switch(menu_pos) { case 0: if( keys & GP2X_B || keys & GP2X_LEFT || keys & GP2X_RIGHT ) { displayFrameInfo = !displayFrameInfo; } break; case 1: if( keys & GP2X_B || keys & GP2X_LEFT || keys & GP2X_RIGHT ) { displayGpuStats = !displayGpuStats; } break; case 2: if( keys & GP2X_B ) { displayVideoMemory = !displayVideoMemory; } break; case 3: if( keys & GP2X_B ) { activeNullGPU = !activeNullGPU; } break; case 4: if( keys & GP2X_LEFT ) { switch( linesInterlace_user ) { case 0: linesInterlace_user = 7; break; case 1: linesInterlace_user = 0; break; case 3: linesInterlace_user = 1; break; case 7: linesInterlace_user = 3; break; } } if( keys & GP2X_RIGHT ) { switch( linesInterlace_user ) { case 0: linesInterlace_user = 1; break; case 1: linesInterlace_user = 3; break; case 3: linesInterlace_user = 7; break; case 7: linesInterlace_user = 0; break; } } break; case 5: if( keys & GP2X_B ) { enableFrameLimit = !enableFrameLimit; } break; case 6: if( keys & GP2X_LEFT ) { if( skipValue > 0 ) { skipValue--; skipCount = skipCountTable[skipValue]; skipRate = skipRateTable[skipValue]; } } if( keys & GP2X_RIGHT ) { if( skipValue < 8 ) { skipValue++; skipCount = skipCountTable[skipValue]; skipRate = skipRateTable[skipValue]; } } break; case 7: if( keys & GP2X_B ) { enableAbbeyHack = !enableAbbeyHack; } break; case 8: if (keys & GP2X_LEFT && PsxCycleMult > 1) PsxCycleMult--; if (keys & GP2X_RIGHT && PsxCycleMult < 10) PsxCycleMult++; break; case 9: if( keys & GP2X_B ) { hardframeskip_line = !hardframeskip_line; } break; case 10: if( keys & GP2X_B ) { hardframeskip_poly = !hardframeskip_poly; } break; case 11: if( keys & GP2X_B ) { hardframeskip_sprite = !hardframeskip_sprite; } break; case 12: if( keys & GP2X_B ) { hardframeskip_image = !hardframeskip_image; } break; case 13: if( keys & GP2X_B ) { hardframeskip_blit = !hardframeskip_blit; } break; case 14: if( keys & GP2X_B ) { use_wall_clock_time = !use_wall_clock_time; } break; case 15: if( keys & GP2X_B ) { menu_state = PSX4ALL_MENU_DEFAULT_STATE; menu_pos = 0; } break; default: break; } if (keys & GP2X_L) { menu_state = PSX4ALL_MENU_DEFAULT_STATE; menu_pos = 0; } break; case PSX4ALL_MENU_SPU_STATE: switch(menu_pos) { case 0: if( keys & GP2X_B || keys & GP2X_LEFT || keys & GP2X_RIGHT ) { #ifndef NOSOUND iSoundMuted = !iSoundMuted; #endif } break; case 1: if( keys & GP2X_B ) { menu_state = PSX4ALL_MENU_DEFAULT_STATE; menu_pos = 0; } break; } if (keys & GP2X_L) { menu_state = PSX4ALL_MENU_DEFAULT_STATE; menu_pos = 0; } break; case PSX4ALL_MENU_BIOS_STATE: switch(menu_pos) { case 0: if( keys & GP2X_B || keys & GP2X_RIGHT ) { biosVersion++; } else if( keys & GP2X_LEFT) { biosVersion--; } if(biosVersion < 0) biosVersion = 12; if(biosVersion > 12) biosVersion = 0; switch(biosVersion) { case 0: sprintf(Config.Bios, "/scph1000.bin"); break; case 1: sprintf(Config.Bios, "/scph1001.bin"); break; case 2: sprintf(Config.Bios, "/scph1002.bin"); break; case 3: sprintf(Config.Bios, "/scph5500.bin"); break; case 4: sprintf(Config.Bios, "/scph5501.bin"); break; case 5: sprintf(Config.Bios, "/scph5502.bin"); break; case 6: sprintf(Config.Bios, "/scph7001.bin"); break; case 7: sprintf(Config.Bios, "/scph7002.bin"); break; case 8: sprintf(Config.Bios, "/scph7003.bin"); break; case 9: sprintf(Config.Bios, "/scph7500.bin"); break; case 10: sprintf(Config.Bios, "/scph7501.bin"); break; case 11: sprintf(Config.Bios, "/scph7502.bin"); break; case 12: sprintf(Config.Bios, "/scph7503.bin"); break; default: break; } break; case 1: if( keys & GP2X_B ) { menu_state = PSX4ALL_MENU_DEFAULT_STATE; menu_pos = 0; } break; } if (keys & GP2X_L) { menu_state = PSX4ALL_MENU_DEFAULT_STATE; menu_pos = 0; } break; case PSX4ALL_MENU_GAMESTATE_STATE: switch(menu_pos) { case 0: if( keys & GP2X_B ) { #ifndef IPHONE if( 1 == psx4all_emulating ) { s32 ret; char buffer[360]; char filename[260]; struct stat s; for(int count = 1;; count++) { sprintf(filename, "%s-%04d.svs", packfile, count); if (stat(filename, &s)) break; } gp2x_printf(NULL, 80, 130, "Saving..."); gp2x_video_flip(); GPU_freeze(2, NULL); ret = SaveState(filename); if (ret == 0) sprintf(buffer, "Saved!"); else sprintf(buffer, "Error Saving!"); gp2x_printf(NULL, 80, 140, "%s", buffer); gp2x_video_flip(); gp2x_timer_delay(1000); } #endif } break; case 1: if( keys & GP2X_B ) { #ifndef IPHONE // pause so keys won't be accidently inputted in FileReq gp2x_timer_delay(500); newpackfile = FileReq(NULL, ".svs"); #endif } break; case 2: if( keys & GP2X_B ) { #ifndef IPHONE Config.HLE = 0; // pause so keys won't be accidently inputted in FileReq gp2x_timer_delay(500); newpackfile = FileReq(NULL, NULL); #endif } break; case 3: if( keys & GP2X_B ) { #ifndef IPHONE Config.HLE = 1; // pause so keys won't be accidently inputted in FileReq gp2x_timer_delay(500); newpackfile = FileReq(NULL, NULL); #endif } break; case 4: if( keys & GP2X_B ) { menu_state = PSX4ALL_MENU_DEFAULT_STATE; menu_pos = 0; } break; } if (keys & GP2X_L) { menu_state = PSX4ALL_MENU_DEFAULT_STATE; menu_pos = 0; } break; } if( newpackfile != NULL ) { break; } gp2x_video_flip(); gp2x_timer_delay(100); if(keys & (GP2X_A|GP2X_B|GP2X_X|GP2X_Y|GP2X_L|GP2X_R|GP2X_PUSH| GP2X_LEFT|GP2X_RIGHT|GP2X_UP|GP2X_DOWN) ) { //gp2x_video_flip(); gp2x_timer_delay(50); } } #else //newpackfile = "Einhander.bin"; //newpackfile = "Einhander.cbn"; Config.HLE = 1; //newpackfile = "Cotton Jap.bin"; newpackfile = "Cotton Jap.cbn"; #endif DEBUGF("loaded %s", newpackfile); packfile = newpackfile; // clear screen gp2x_video_RGB_clearscreen16(); keys = gp2x_joystick_read(); LoadCdBios = 0; if( (!strcasecmp(packfile + (strlen(packfile)-4), ".svs")) ) { char *pos; loadst = 1; sprintf(svsfilename, "%s", packfile); pos = strrchr(packfile, '-'); if (pos) *pos = '\0'; } else { loadst = 0; } if( loadst > 0 ) { gp2x_printf(NULL, 120, 100, "LOADING SAVE STATE"); } else { gp2x_printf(NULL, 120, 100, "LOADING BIOS"); } gp2x_video_flip(); if( 1 == psx4all_emulating ) { psxShutdown(); CloseComponents(); } if (SysInit() == -1) { gp2x_deinit(); return 0; } if (InitComponents() == -1) { gp2x_deinit(); return 0; } SysReset(); CheckCdrom(); if( Config.HLE ) { LoadCdBios = 0; if( LoadCdrom() == -1 ) { gp2x_printf(NULL, 120, 120, "LOAD FAILED"); gp2x_video_flip(); gp2x_timer_delay(2000); // clear screen gp2x_video_RGB_clearscreen16(); return 0; } } else { gp2x_printf(NULL, 120, 120, "LOADED!"); gp2x_video_flip(); gp2x_timer_delay(100); } if (loadst) { if( LoadState(svsfilename) == -1 ) { gp2x_printf(NULL, 120, 120, "LOAD SAVE FAILED"); gp2x_video_flip(); gp2x_timer_delay(2000); // clear screen gp2x_video_RGB_clearscreen16(); return 0; } } return 1; }
void gp2x_frontend_deinit(void) { gp2x_deinit(); }
void execute_game (char *playemu, char *playgame) { char *args[255]; char str[8][64]; int n=0; int i=0; /* executable */ args[n]=playemu; n++; /* playgame */ args[n]=playgame; n++; /* gp2x_freq */ args[n]="-clock"; n++; sprintf(str[i],"%d",gp2x_freq); args[n]=str[i]; i++; n++; /* gp2x_video_depth */ if (gp2x_video_depth==8) { args[n]="-depth"; n++; args[n]="8"; n++; } if (gp2x_video_depth==16) { args[n]="-depth"; n++; args[n]="16"; n++; } // //args[n]="-scale"; n++; // /* gp2x_video_aspect */ if ((gp2x_video_aspect==1) || (gp2x_video_aspect==3) || (gp2x_video_aspect==5) || (gp2x_video_aspect==7) || (gp2x_video_aspect==9) || (gp2x_video_aspect==11) || (gp2x_video_aspect==13) || (gp2x_video_aspect==15) || (gp2x_video_aspect==17) || (gp2x_video_aspect==19) || (gp2x_video_aspect==21) || (gp2x_video_aspect==23)) { args[n]="-scale"; n++; } if ((gp2x_video_aspect==2) || (gp2x_video_aspect==3) || (gp2x_video_aspect==6) || (gp2x_video_aspect==7) || (gp2x_video_aspect==10) || (gp2x_video_aspect==11) || (gp2x_video_aspect==14) || (gp2x_video_aspect==15) || (gp2x_video_aspect==18) || (gp2x_video_aspect==19) || (gp2x_video_aspect==22) || (gp2x_video_aspect==23)) { args[n]="-aspect"; n++; } if ((gp2x_video_aspect==4) || (gp2x_video_aspect==5) || (gp2x_video_aspect==6) || (gp2x_video_aspect==7) || (gp2x_video_aspect==12) || (gp2x_video_aspect==13) || (gp2x_video_aspect==14) || (gp2x_video_aspect==15) || (gp2x_video_aspect==20) || (gp2x_video_aspect==21) || (gp2x_video_aspect==22) || (gp2x_video_aspect==23)) { args[n]="-border"; n++; } if ((gp2x_video_aspect>=8) && (gp2x_video_aspect<=23)) { args[n]="-ror"; n++; } if ((gp2x_video_aspect>=8) && (gp2x_video_aspect<=15)) { args[n]="-rotatecontrols"; n++; } /* gp2x_video_sync */ if (gp2x_video_sync==1) { args[n]="-nodirty"; n++; args[n]="-waitvsync"; n++; } else if (gp2x_video_sync==2) { args[n]="-nodirty"; n++; } else if (gp2x_video_sync==-1) { args[n]="-nothrottle"; n++; } /* gp2x_frameskip */ if (gp2x_frameskip>=0) { args[n]="-frameskip"; n++; sprintf(str[i],"%d",gp2x_frameskip); args[n]=str[i]; i++; n++; } /* gp2x_sound */ if (gp2x_sound==0) { args[n]="-soundcard"; n++; args[n]="0"; n++; } if ((gp2x_sound==1) || (gp2x_sound==6) || (gp2x_sound==11)) { args[n]="-samplerate"; n++; args[n]="16000"; n++; } if ((gp2x_sound==2) || (gp2x_sound==7) || (gp2x_sound==12)) { args[n]="-samplerate"; n++; args[n]="22050"; n++; } if ((gp2x_sound==3) || (gp2x_sound==8) || (gp2x_sound==13)) { args[n]="-samplerate"; n++; args[n]="32000"; n++; } if ((gp2x_sound==4) || (gp2x_sound==9) || (gp2x_sound==14)) { args[n]="-samplerate"; n++; args[n]="44100"; n++; } if ((gp2x_sound==5) || (gp2x_sound==10) || (gp2x_sound==15)) { args[n]="-samplerate"; n++; args[n]="11025"; n++; } if ((gp2x_sound>=1) && (gp2x_sound<=5)) { args[n]="-fastsound"; n++; } if (gp2x_sound>=11) { args[n]="-stereo"; n++; } /* gp2x_clock_cpu */ if (gp2x_clock_cpu!=100) { args[n]="-uclock"; n++; sprintf(str[i],"%d",100-gp2x_clock_cpu); args[n]=str[i]; i++; n++; } /* gp2x_clock_sound */ if (gp2x_clock_cpu!=100) { args[n]="-uclocks"; n++; sprintf(str[i],"%d",100-gp2x_clock_sound); args[n]=str[i]; i++; n++; } /* gp2x_cpu_cores */ if ((gp2x_cpu_cores==1) || (gp2x_cpu_cores==3) || (gp2x_cpu_cores==5)) { args[n]="-cyclone"; n++; } if ((gp2x_cpu_cores==2) || (gp2x_cpu_cores==3)) { args[n]="-drz80"; n++; } if ((gp2x_cpu_cores==4) || (gp2x_cpu_cores==5)) { args[n]="-drz80_snd"; n++; } if (gp2x_ramtweaks) { args[n]="-ramtweaks"; n++; } if (gp2x_cheat) { args[n]="-cheat"; n++; } switch (gp2x_volume) { case 4: break; /* nothing, default to maximum volume */ case 3: args[n]="-volume"; n++; args[n]="-4"; n++; break; case 2: args[n]="-volume"; n++; args[n]="-8"; n++; break; case 1: args[n]="-volume"; n++; args[n]="-10"; n++; break; } args[n]=NULL; for (i=0; i<n; i++) { printf("%s ",args[i]); } printf("\n"); gp2x_deinit(); execv(args[0], args); }