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; }
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; }