static void gp2x_intro_screen(void) { char name[256]; FILE *f; gp2x_video_flip(); sprintf(name,get_documents_path("skins/splash.bmp")); f=fopen(name,"rb"); if (f) { fread(gp2xsplash_bmp,1,77878,f); fclose(f); } while(1) { load_bmp_8bpp(gp2x_screen8,gp2xsplash_bmp); gp2x_video_flip(); int ExKey=gp2x_joystick_read(0); if(ExKey!=0)break; gp2x_timer_delay(50); } sprintf(name,get_documents_path("skins/menu.bmp")); f=fopen(name,"rb"); if (f) { fread(gp2xmenu_bmp,1,77878,f); fclose(f); } }
static void gp2x_intro_screen(void) { char name[1024]; FILE *f; gp2x_video_flip(); sprintf(name,get_resource_path("skins/iOSsplash.bmp")); f=fopen(name,"rb"); if (f) { fread(gp2xsplash_bmp,1,77878,f); fclose(f); } while(1) { load_bmp_8bpp(gp2x_screen8,gp2xsplash_bmp); gp2x_video_flip(); int ExKey=gp2x_joystick_read(0); if(ExKey!=0)break; usleep(50000); } sprintf(name,get_resource_path("skins/iOSmenu.bmp")); f=fopen(name,"rb"); if (f) { fread(gp2xmenu_bmp,1,77878,f); fclose(f); } }
static void select_game(char *emu, char *game) { unsigned long ExKey; /* No Selected game */ strcpy(game,"builtinn"); /* Clean screen */ gp2x_video_flip(); /* Wait until user selects a game */ while(1) { game_list_view(&last_game_selected); gp2x_video_flip(); if( (gp2x_joystick_read(0)&0x8c0ff55)) gp2x_timer_delay(100); while(!(ExKey=gp2x_joystick_read(0)&0x8c0ff55)) { if ((ExKey & GP2X_L) && (ExKey & GP2X_R)) { gp2x_exit(); } } 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)) gp2x_exit(); if ((ExKey & GP2X_A) || (ExKey & GP2X_B) || (ExKey & GP2X_PUSH) || (ExKey & GP2X_START)) { /* Select the game */ game_list_select(last_game_selected, game, emu); /* Emulation Options */ if(show_options(game)) { break; } } } }
static void poll_joystick(void) { extern int num_of_joys; switch (num_of_joys) { case 4: ExKey4=gp2x_joystick_read(3); case 3: ExKey3=gp2x_joystick_read(2); case 2: ExKey2=gp2x_joystick_read(1); case 1: ExKey1=gp2x_joystick_read(0); break; default: ExKey1=gp2x_joystick_read(0); ExKey2=ExKey1; if(ExKey2&GP2X_START) ExKey2^=GP2X_START; if(ExKey2&GP2X_SELECT) ExKey2^=GP2X_SELECT; ExKey3=ExKey2; ExKey4=ExKey2; break; } }
unsigned long gp2x_joystick_press (int n) { unsigned long ExKey=0; /* while(gp2x_joystick_read(n)&0x8c0ff55) { gp2x_timer_delay(150); } while(!(ExKey=gp2x_joystick_read(n)&0x8c0ff55)) { } */ while(gp2x_joystick_read(n)==0) { gp2x_timer_delay(150); } //while(!(ExKey=gp2x_joystick_read(n))) { } //while(!(ExKey & (JOY_BUTTON_X|JOY_BUTTON_B))) {nKeys = joystick_read();gp2x_timer_delay(150);} // para quieto!! //while(ExKey & (JOY_BUTTON_X|JOY_BUTTON_B)) {nKeys = joystick_read(); gp2x_timer_delay(150);} // para quieto!! return ExKey; }
void CheckKeys(void) { unsigned long pad=gp2x_joystick_read(0); if(pad & GP2X_VOL_DOWN) if(pad & GP2X_START) { supervision_done(); //shutsdown the system //gp2x_deinit(); exit(0); } if(pad & GP2X_L) if(pad & GP2X_R) //Checks if L and R are pushed supervision_reset(); //Reset emulator if(pad & GP2X_L) if(pad & GP2X_LEFT) //Checks if L and LEFT pushed supervision_set_colour_scheme(COLOUR_SCHEME_DEFAULT); //Changes the color scheme if(pad & GP2X_L) if(pad & GP2X_RIGHT) //Checks if L and RIGHT are pushed supervision_set_colour_scheme(COLOUR_SCHEME_AMBER); //Changes the color scheme if(pad & GP2X_L) if(pad & GP2X_UP) //Checks if L and UP pushed supervision_set_colour_scheme(COLOUR_SCHEME_GREEN); //Changes the color scheme if(pad & GP2X_L) if(pad & GP2X_DOWN) //Checks if L and DOWN pushed supervision_set_colour_scheme(COLOUR_SCHEME_BLUE); //Changes the color scheme if(pad & GP2X_Y) { paused=TRUE; textClear(); handleMainMenu(); // File menu paused=FALSE;} if (pad & (GP2X_VOL_UP|GP2X_VOL_DOWN)) { int vol = currentConfig.volume; if (pad & GP2X_VOL_UP) { if (vol < 255) vol++; } else { if (vol > 0) vol--; } gp2x_sound_volume(vol, vol); currentConfig.volume = vol; } }
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; }
char *FileReq(char *dir, const char *ext) { static s8 *cwd=NULL; static s32 cursor_pos=1; static s32 first_visible; static s32 num_items=0; DIR *dirstream; struct dirent *direntry; s8 *path; struct stat item; static s32 row; s32 pathlength; s8 tmp_string[32]; s8 *selected; u32 keys; #define MENU_Y 90 #define MENU_LS MENU_Y+10 #define MENU_HEIGHT 12 if(dir!=NULL) cwd=dir; if(cwd==NULL) { sprintf(filereq_fullgamepath, "%s/", gamepath); cwd=filereq_fullgamepath; } for(;;) { keys = gp2x_joystick_read(); gp2x_video_RGB_clearscreen16(); backg(); //exems(); //gp2x_timer_delay(500000); //gp2x_printf(NULL, 0, 10, PSX4ALL_NAME " V " PSX4ALL_VERSION "." PSX4ALL_BUILD " By " PSX4ALL_BY); //gp2x_printf(NULL, 0, 20, PSX4ALL_CREDITS); //gp2x_printf(NULL, 0, 30, PSX4ALL_PORT); //gp2x_printf(NULL, 0, 40, PSX4ALL_OR); if( keys & GP2X_L ) { for(int i=0; i<num_items; i++) if (filereq_dir_items[i].name) { free(filereq_dir_items[i].name); filereq_dir_items[i].name = NULL; } num_items=0; gp2x_timer_delay(90); return NULL; } if(num_items==0) { s32 i2; dirstream=opendir(cwd); if(dirstream==NULL) { gp2x_printf(NULL, 0, 20, PSX4ALL_ER); return NULL; } while((direntry=readdir(dirstream))) { if( (ext == NULL && ((NULL == strstr(direntry->d_name, ".")) || (strlen(direntry->d_name) > 1 && 0 == strnicmp(direntry->d_name, "..", 2)) || (strlen(direntry->d_name) > 2 && 0 == strnicmp(direntry->d_name+(strlen(direntry->d_name)-2), ".z", 2)) || (strlen(direntry->d_name) > 4 && 0 == strnicmp(direntry->d_name+(strlen(direntry->d_name)-4), ".iso", 4)) || (strlen(direntry->d_name) > 4 && 0 == strnicmp(direntry->d_name+(strlen(direntry->d_name)-4), ".bin", 4)) || (strlen(direntry->d_name) > 4 && 0 == strnicmp(direntry->d_name+(strlen(direntry->d_name)-4), ".img", 4)) || (strlen(direntry->d_name) > 4 && 0 == strnicmp(direntry->d_name+(strlen(direntry->d_name)-4), ".znx", 4)) || (strlen(direntry->d_name) > 4 && 0 == strnicmp(direntry->d_name+(strlen(direntry->d_name)-4), ".cbn", 4)) || (strlen(direntry->d_name) > 4 && 0 == strnicmp(direntry->d_name+(strlen(direntry->d_name)-4), ".pbp", 4)) || (strlen(direntry->d_name) > 4 && 0 == strnicmp(direntry->d_name+(strlen(direntry->d_name)-4), ".cue", 4)) || (strlen(direntry->d_name) > 4 && 0 == strnicmp(direntry->d_name+(strlen(direntry->d_name)-4), ".psx", 4)) || (strlen(direntry->d_name) > 4 && 0 == strnicmp(direntry->d_name+(strlen(direntry->d_name)-4), ".zip", 4)) || (strlen(direntry->d_name) > 4 && 0 == strnicmp(direntry->d_name+(strlen(direntry->d_name)-4), ".mdf", 4))) ) || (ext != NULL && (strlen(direntry->d_name) > 4 && 0 == strnicmp(direntry->d_name+(strlen(direntry->d_name)-strlen(ext)), ext, strlen(ext)))) ) { filereq_dir_items[num_items].name=(s8 *)malloc(strlen(direntry->d_name)+1); strcpy(filereq_dir_items[num_items].name, direntry->d_name); num_items++; if(num_items>1024) break; } } closedir(dirstream); for(i2=0; i2<num_items; i2++) { path=(s8 *)malloc(strlen(cwd)+strlen(filereq_dir_items[i2].name)+2); sprintf(path, PSX4ALL_SSR, cwd, filereq_dir_items[i2].name); if(!stat(path, &item)) { if(S_ISDIR(item.st_mode)) { filereq_dir_items[i2].type=0; } else { s32 len = strlen(filereq_dir_items[i2].name); filereq_dir_items[i2].type = 2; if (len >= 4) { if (!strnicmp(filereq_dir_items[i2].name+(len-2), ".Z", 2)) { filereq_dir_items[i2].type = 1; } if (!strnicmp(filereq_dir_items[i2].name+(len-4), ".bin", 4)) { filereq_dir_items[i2].type = 1; } if (!strnicmp(filereq_dir_items[i2].name+(len-4), ".ZNX", 4)) { filereq_dir_items[i2].type = 1; } } } } else { filereq_dir_items[i2].type=0; } free(path); } sort_dir(filereq_dir_items, num_items, 1); cursor_pos=0; first_visible=0; } gp2x_printf(NULL, 90, MENU_Y, cwd); if(keys & GP2X_DOWN) { if(cursor_pos<(num_items-1)) cursor_pos++; if((cursor_pos-first_visible)>=MENU_HEIGHT) first_visible++; } else if(keys & GP2X_UP) { if(cursor_pos>0) cursor_pos--; if(cursor_pos<first_visible) first_visible--; } else if(keys & GP2X_LEFT) { if(cursor_pos>=10) cursor_pos-=10; else cursor_pos=0; if(cursor_pos<first_visible) first_visible=cursor_pos; } else if(keys & GP2X_RIGHT) { if(cursor_pos<(num_items-11)) cursor_pos+=10; else cursor_pos=num_items-1; if((cursor_pos-first_visible)>=MENU_HEIGHT) first_visible=cursor_pos-(MENU_HEIGHT-1); } else if(keys & GP2X_B) { path=(s8 *)malloc(strlen(cwd) +strlen(filereq_dir_items[cursor_pos].name) +2); sprintf(path, PSX4ALL_SSR, cwd, filereq_dir_items[cursor_pos].name); for(int i=0; i<num_items; i++) if (filereq_dir_items[i].name) { free(filereq_dir_items[i].name); filereq_dir_items[i].name = NULL; } num_items=0; if(filereq_dir_items[cursor_pos].type==0) { pathlength=strlen(path); if( path[pathlength-1]=='.' && path[pathlength-2]=='/') { path[pathlength-2]='\0'; cwd=path; } else if(path[pathlength-1]=='.' && path[pathlength-2]=='.' && path[pathlength-3]=='/' ) { if( pathlength > 4 ) { s8* p = strrchr(path, '/'); p[0] = '\0'; p = strrchr(path, '/'); p[0] = '\0'; p = strrchr(path, '/'); p[1] = '\0'; cwd=path; } } else { if( path[0] == '/' && path[1] == '/' ) { cwd = path + 1; } else { cwd = path; } } } else { //gp2x_video_RGB_clearscreen16(); gp2x_printf(NULL, 10, 120, PSX4ALL_SL); gp2x_printf(NULL, 10, 130, PSX4ALL_STR, path); gp2x_printf(NULL, 10, 140, PSX4ALL_YN); gp2x_video_flip(); for(;;) { u32 keys = gp2x_joystick_read(); if( keys & GP2X_SELECT ) { return NULL; } if( keys & GP2X_START ) { char* p = strrchr(path, '/'); if( p != NULL ) { sprintf(CdromLabel, "%10.10s", p + 1); } return path; } gp2x_timer_delay(90); } } } row=0; while(row<num_items && row<MENU_HEIGHT) { if(row==(cursor_pos-first_visible)) { gp2x_printf(NULL, 90, MENU_LS+(10*row), PSX4ALL_ROW); selected=filereq_dir_items[row+first_visible].name; } if(filereq_dir_items[row+first_visible].type==0) { gp2x_printf(NULL, 90, MENU_LS+(10*row), "DIR "); } snprintf(tmp_string, 30, PSX4ALL_STR, filereq_dir_items[row+first_visible].name); gp2x_printf(NULL, 90+(10*6), MENU_LS+(10*row), tmp_string); row++; } while(row<MENU_HEIGHT) { row++; } gp2x_video_flip(); gp2x_timer_delay(75); 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); } } return NULL; }
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); }
char *FileReq(char *dir, const char *ext) { static s8 *cwd=NULL; static s32 cursor_pos=1; static s32 first_visible; static s32 num_items=0; DIR *dirstream; struct dirent *direntry; s8 *path; struct stat item; static s32 row; s32 pathlength; s8 tmp_string[32]; s8 *selected; u32 keys; #define MENU_Y 90 #define MENU_LS MENU_Y+10 #define MENU_HEIGHT 12 if(dir!=NULL) cwd=dir; if(cwd==NULL) { sprintf(filereq_fullgamepath, "%s/", gamepath); cwd=filereq_fullgamepath; } for(;;) { keys = gp2x_joystick_read(); gp2x_video_RGB_clearscreen16(); gp2x_printf(NULL, 0, 10, "psx4all-dingoo 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"); gp2x_printf(NULL, 0, 40, "CHOOSE A GAME OR PRESS L TO EXIT"); if( keys & GP2X_L ) { for(int i=0; i<num_items; i++) if (filereq_dir_items[i].name) { free(filereq_dir_items[i].name); filereq_dir_items[i].name = NULL; } num_items=0; gp2x_timer_delay(100); return NULL; } if(num_items==0) { s32 i2; dirstream=opendir(cwd); if(dirstream==NULL) { gp2x_printf(NULL, 0, 20, "error opening directory"); return NULL; } // read directory entries while((direntry=readdir(dirstream))) { // this is a very ugly way of only accepting a certain extension if( (ext == NULL && ((NULL == strstr(direntry->d_name, ".")) || (strlen(direntry->d_name) > 1 && 0 == strnicmp(direntry->d_name, "..", 2)) || (strlen(direntry->d_name) > 2 && 0 == strnicmp(direntry->d_name+(strlen(direntry->d_name)-2), ".z", 2)) || (strlen(direntry->d_name) > 4 && 0 == strnicmp(direntry->d_name+(strlen(direntry->d_name)-4), ".iso", 4)) || (strlen(direntry->d_name) > 4 && 0 == strnicmp(direntry->d_name+(strlen(direntry->d_name)-4), ".bin", 4)) || (strlen(direntry->d_name) > 4 && 0 == strnicmp(direntry->d_name+(strlen(direntry->d_name)-4), ".img", 4)) || (strlen(direntry->d_name) > 4 && 0 == strnicmp(direntry->d_name+(strlen(direntry->d_name)-4), ".znx", 4)) || (strlen(direntry->d_name) > 4 && 0 == strnicmp(direntry->d_name+(strlen(direntry->d_name)-4), ".cbn", 4))) ) || (ext != NULL && (strlen(direntry->d_name) > 4 && 0 == strnicmp(direntry->d_name+(strlen(direntry->d_name)-strlen(ext)), ext, strlen(ext)))) ) { filereq_dir_items[num_items].name=(s8 *)malloc(strlen(direntry->d_name)+1); strcpy(filereq_dir_items[num_items].name, direntry->d_name); num_items++; if(num_items>1024) break; } } closedir(dirstream); // get entry types for(i2=0; i2<num_items; i2++) { path=(s8 *)malloc(strlen(cwd)+strlen(filereq_dir_items[i2].name)+2); sprintf(path, "%s/%s", cwd, filereq_dir_items[i2].name); if(!stat(path, &item)) { if(S_ISDIR(item.st_mode)) { filereq_dir_items[i2].type=0; } else { s32 len = strlen(filereq_dir_items[i2].name); filereq_dir_items[i2].type = 2; /* Not Used */ if (len >= 4) { if (!strnicmp(filereq_dir_items[i2].name+(len-2), ".Z", 2)) { filereq_dir_items[i2].type = 1; } if (!strnicmp(filereq_dir_items[i2].name+(len-4), ".bin", 4)) { filereq_dir_items[i2].type = 1; } if (!strnicmp(filereq_dir_items[i2].name+(len-4), ".ZNX", 4)) { filereq_dir_items[i2].type = 1; } } } } else { filereq_dir_items[i2].type=0; } free(path); } sort_dir(filereq_dir_items, num_items, 1); cursor_pos=0; first_visible=0; } // display current directory gp2x_printf(NULL, 80, MENU_Y, cwd); if(keys & GP2X_DOWN) { //down if(cursor_pos<(num_items-1)) cursor_pos++; if((cursor_pos-first_visible)>=MENU_HEIGHT) first_visible++; } else if(keys & GP2X_UP) { // up if(cursor_pos>0) cursor_pos--; if(cursor_pos<first_visible) first_visible--; } else if(keys & GP2X_LEFT) { //left if(cursor_pos>=10) cursor_pos-=10; else cursor_pos=0; if(cursor_pos<first_visible) first_visible=cursor_pos; } else if(keys & GP2X_RIGHT) { //right if(cursor_pos<(num_items-11)) cursor_pos+=10; else cursor_pos=num_items-1; if((cursor_pos-first_visible)>=MENU_HEIGHT) first_visible=cursor_pos-(MENU_HEIGHT-1); } else if(keys & GP2X_B) // button 1 { //s32 i; path=(s8 *)malloc(strlen(cwd) +strlen(filereq_dir_items[cursor_pos].name) +2); sprintf(path, "%s/%s", cwd, filereq_dir_items[cursor_pos].name); for(int i=0; i<num_items; i++) if (filereq_dir_items[i].name) { free(filereq_dir_items[i].name); filereq_dir_items[i].name = NULL; } num_items=0; if(filereq_dir_items[cursor_pos].type==0) { // directory selected pathlength=strlen(path); if( path[pathlength-1]=='.' && path[pathlength-2]=='/') // check for . selected { path[pathlength-2]='\0'; cwd=path; } else if(path[pathlength-1]=='.' && path[pathlength-2]=='.' && path[pathlength-3]=='/' ) // check for .. selected { if( pathlength > 4 ) { s8* p = strrchr(path, '/'); // PATH: /x/y/z/..[/] p[0] = '\0'; p = strrchr(path, '/'); // PATH: /x/y/z[/]../ p[0] = '\0'; p = strrchr(path, '/'); // PATH: /x/y[/]z/../ p[1] = '\0'; // PATH: /x/y/ cwd=path; } } else { // dirty fix if( path[0] == '/' && path[1] == '/' ) { cwd = path + 1; // Add 1 to ignore the first slash. This occurs when traversing to root dir. } else { cwd = path; } } } else { gp2x_video_RGB_clearscreen16(); gp2x_printf(NULL, 10, 120, "ARE YOU SURE YOU WANT TO SELECT..."); gp2x_printf(NULL, 10, 130, "%s", path); gp2x_printf(NULL, 10, 140, "PRESS START FOR YES OR SELECT FOR NO"); gp2x_video_flip(); // file selected check if it was intended for(;;) { u32 keys = gp2x_joystick_read(); if( keys & GP2X_SELECT ) { return NULL; } if( keys & GP2X_START ) { /* Store the 10 character filename in CdromLabel so save states work */ char* p = strrchr(path, '/'); if( p != NULL ) { sprintf(CdromLabel, "%10.10s", p + 1); } return path; } gp2x_timer_delay(100); } } } // display directory contents row=0; while(row<num_items && row<MENU_HEIGHT) { if(row==(cursor_pos-first_visible)) { // draw cursor gp2x_printf(NULL, 80, MENU_LS+(10*row), "------>"); selected=filereq_dir_items[row+first_visible].name; } if(filereq_dir_items[row+first_visible].type==0) { gp2x_printf(NULL, 80, MENU_LS+(10*row), "DIR "); } snprintf(tmp_string, 30, "%s", filereq_dir_items[row+first_visible].name); gp2x_printf(NULL, 80+(10*6), MENU_LS+(10*row), tmp_string); row++; } while(row<MENU_HEIGHT) { row++; } gp2x_video_flip(); gp2x_timer_delay(75); 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); } } return NULL; }
static void select_game(char *emu, char *game) { extern int kiosk_mode; unsigned long keytimer=0; int keydirection=0, last_keydirection=0; /* No Selected game */ strcpy(game,"builtinn"); /* Clean screen */ FE_DisplayScreen(); gp2x_joystick_clear(); /* Wait until user selects a game */ while(1) { game_list_view(&last_game_selected); FE_DisplayScreen(); gp2x_timer_delay(70000); while(1) { usleep(10000); gp2x_joystick_read(); last_keydirection=keydirection; keydirection=0; //Any keyboard key pressed? if(osd_is_sdlkey_pressed(pi_key[LEFT_1]) || osd_is_sdlkey_pressed(pi_key[RIGHT_1]) || osd_is_sdlkey_pressed(pi_key[UP_1]) || osd_is_sdlkey_pressed(pi_key[DOWN_1]) ) { keydirection=1; break; } if(osd_is_sdlkey_pressed(pi_key[START_1]) || osd_is_sdlkey_pressed(pi_key[A_1]) || osd_is_sdlkey_pressed(pi_key[QUIT]) || osd_is_sdlkey_pressed(pi_key[SELECT_1]) ) { break; } //Any stick direction? if(is_joy_axis_pressed (joyaxis_LR, 1, 0) || is_joy_axis_pressed (joyaxis_LR, 2, 0) || is_joy_axis_pressed (joyaxis_UD, 1, 0) || is_joy_axis_pressed (joyaxis_UD, 2, 0) ) { keydirection=1; break; } //Any joy buttons pressed? if (ExKey1) { break; } //Used to delay the initial key press, but //once pressed and held the delay will clear keytimer = gp2x_timer_read() + (TICKS_PER_SEC/2); } //Key delay if(keydirection && last_keydirection && gp2x_timer_read() < keytimer) { continue; } int updown=0; if(is_joy_axis_pressed (joyaxis_UD, 1, 0)) {last_game_selected--; updown=1;}; if(is_joy_axis_pressed (joyaxis_UD, 2, 0)) {last_game_selected++; updown=1;}; // Stop diagonals on game selection if(!updown) { if(is_joy_axis_pressed (joyaxis_LR, 1, 0)) last_game_selected-=21; if(is_joy_axis_pressed (joyaxis_LR, 2, 0)) last_game_selected+=21; } if (osd_is_sdlkey_pressed(pi_key[UP_1])) last_game_selected--; if (osd_is_sdlkey_pressed(pi_key[DOWN_1])) last_game_selected++; if (osd_is_sdlkey_pressed(pi_key[LEFT_1])) last_game_selected-=21; if (osd_is_sdlkey_pressed(pi_key[RIGHT_1])) last_game_selected+=21; if (!kiosk_mode) { if( osd_is_sdlkey_pressed(pi_key[QUIT]) || (is_joy_button_pressed(pi_joy[START_1], ExKey1) && is_joy_button_pressed(pi_joy[SELECT_1], ExKey1)) ) { gp2x_exit(); } } if (is_joy_button_pressed(pi_joy[A_1], ExKey1) || osd_is_sdlkey_pressed(pi_key[A_1]) || osd_is_sdlkey_pressed(pi_key[START_1]) ) { /* Select the game */ game_list_select(last_game_selected, game, emu); break; } if (is_joy_button_pressed(pi_joy[SELECT_1], ExKey1) || osd_is_sdlkey_pressed(pi_key[SELECT_1]) ) { //Check if the game is already a favorite game_list_select(last_game_selected, game, emu); int foundfav=0; int counter=0; while(true) { if (favarray[counter][0] == '\0') break; //Null is the array terminator if (strcasecmp(favarray[counter], game) == 0) { foundfav=1; break; } counter++; } if(foundfav) { favorites_remove(game); } else { favorites_add(game); } //Redraw and pause slightly game_list_view(&last_game_selected); FE_DisplayScreen(); usleep(300000); gp2x_joystick_clear(); } } }
static void select_game(char *emu, char *game) { unsigned long ExKey; /* No Selected game */ strcpy(game,"builtinn"); /* Clean screen */ gp2x_video_flip(); while(ExKey=gp2x_joystick_read(0)&0x8c0ff55){ gp2x_video_flip(); gp2x_timer_delay(1); }; /* Wait until user selects a game */ while(1) { game_list_view(&last_game_selected); gp2x_video_flip(); gp2x_timer_delay(100); ExKey=gp2x_joystick_read(0); if (ExKey & GP2X_UP) last_game_selected--; else if (ExKey & GP2X_DOWN) last_game_selected++; else if ((ExKey & GP2X_L) || ExKey & GP2X_LEFT) last_game_selected-=21; else if ((ExKey & GP2X_R) || ExKey & GP2X_RIGHT) last_game_selected+=21; //if ((ExKey & GP2X_L) && (ExKey & GP2X_R)) gp2x_exit(); if (((ExKey & GP2X_A) || (ExKey & GP2X_B) || (ExKey & GP2X_PUSH) || (ExKey & GP2X_START)) && game_num_avail!=0) { /* Select the game */ game_list_select(last_game_selected, game, emu); /* Emulation Options */ //defaults! m4all_video_aspect=0; m4all_video_rotate=0; m4all_video_sync=0; m4all_frameskip=-1; m4all_cheat=0; m4all_waysStick = 8; m4all_sound = 4; m4all_video_depth=16; if(m4all_HiSpecs) { m4all_clock_cpu= 100; m4all_clock_sound= 100; m4all_buttons=2; m4all_sound=12; } else { m4all_clock_cpu= 80; m4all_clock_sound= 80; m4all_buttons=2; } if(show_options(game)) { break; } } } }
void handleOptionsMenu(void) { BOOL isSelected = FALSE; int menuOption = 0; emu_ReadConfig(); gp2x_video_RGB_setscaling(320, 240); textClear(); while(!isSelected) { int clock = currentConfig.CPUclock; int frameskip = currentConfig.Frameskip; int videomode = currentConfig.videoMode; int vol = currentConfig.volume; unsigned long pad = gp2x_joystick_read(0); gp2x_printf(0, 1, 1, "Potator2x 1.0 by Normmatt\n\n"); gp2x_printf(0, 15, 15 + 2*8, "videoMode %s",videoMode); gp2x_printf(0, 15, 15 + 3*8, "show_fps %d",currentConfig.show_fps); gp2x_printf(0, 15, 15 + 4*8, "enable_sound %d",currentConfig.enable_sound); gp2x_printf(0, 15, 15 + 5*8, "SoundRate %d",currentConfig.SoundRate); gp2x_printf(0, 15, 15 + 6*8, "Frameskip %d",currentConfig.Frameskip); gp2x_printf(0, 15, 15 + 7*8, "CPUclock %d",clocklist[currentConfig.CPUclock]); gp2x_printf(0, 15, 15 + 8*8, "volume %d",currentConfig.volume); gp2x_printf(0, 15, 15 + 9*8, "Save and Exit"); gp2x_printf(0, 15, 15 + 10*8, "Exit"); gp2x_printf(0, 170, 1, "MenuOption = %d",menuOption); gp2x_printf(0, 0, (31 + (menuOption*8)), "->"); gp2x_video_RGB_flip(0); if(pad & GP2X_RIGHT) { if(menuOption == OPTION_VIDEOMODE) if(videomode < 2) currentConfig.videoMode++; if(menuOption == OPTION_SHOWFPS) if(currentConfig.show_fps==0) currentConfig.show_fps=1; else currentConfig.show_fps=0; if(menuOption == OPTION_ENABLESOUND) if(currentConfig.enable_sound==0) currentConfig.enable_sound=1; else currentConfig.enable_sound=0; if(menuOption == OPTION_SOUNDRATE) currentConfig.SoundRate*=2; if(menuOption == OPTION_FRAMESKIP) if (frameskip < 9) frameskip++; if(menuOption == OPTION_CPUCLOCK) if(clock < sizeof(clocklist)) clock++; if(menuOption == OPTION_VOLUME) if (vol < 255) vol+= (pad & GP2X_RIGHT) ? 1 : 0; } if(pad & GP2X_LEFT) { if(menuOption == OPTION_VIDEOMODE) if(videomode > 0) currentConfig.videoMode--; if(menuOption == OPTION_SHOWFPS) if(currentConfig.show_fps==0) currentConfig.show_fps=1; else currentConfig.show_fps=0; if(menuOption == OPTION_ENABLESOUND) if(currentConfig.enable_sound==0) currentConfig.enable_sound=1; else currentConfig.enable_sound=0; if(menuOption == OPTION_SOUNDRATE) currentConfig.SoundRate/=2; if(menuOption == OPTION_FRAMESKIP) if (frameskip > 0) frameskip--; if(menuOption == OPTION_CPUCLOCK) if(clock > 0) clock--; if(menuOption == OPTION_VOLUME) if (vol > 0) vol-= (pad & GP2X_LEFT) ? 1 : 0; } if(pad & GP2X_DOWN) { menuOption++; textClear(); } if(pad & GP2X_UP) { menuOption--; textClear(); } if(pad & GP2X_VOL_DOWN) if(pad & GP2X_START) exitMenu(); if(pad & GP2X_X) { switch(menuOption){ case OPTION_SAVEEXIT: emu_WriteConfig(); return; case OPTION_EXIT: //gp2x_sound_rate(currentConfig.SoundRate); return; default: break; } } switch(currentConfig.videoMode) { case 0: sprintf(videoMode,"Slow"); break; case 1: sprintf(videoMode,"Quick"); break; case 2: sprintf(videoMode,"Full Screen"); break; default: sprintf(videoMode,""); break; } if(currentConfig.SoundRate <= 11025) currentConfig.SoundRate = 11025; if(currentConfig.SoundRate >= 44100) currentConfig.SoundRate = 44100; currentConfig.Frameskip = frameskip; currentConfig.CPUclock = clock; currentConfig.volume = vol; if(menuOption < 0) menuOption = 0; if(menuOption > 8) menuOption = 8; while(pad == gp2x_joystick_read(0)); pad = gp2x_joystick_read(0); textClear(); } }
void handleFileMenu(void) { BOOL isSelected = FALSE; s32 curFile = 0; int virtualFile = 0; fillList(); textClear(); while(!isSelected) { unsigned long pad = gp2x_joystick_read(0); printList(curFile); gp2x_printf(0, 170, 1, "VirtualFile = %d",virtualFile); gp2x_printf(0, 170, 10, "File Count = %d",fileCounter); if(FileList[virtualFile].isRunable){ gp2x_default_font.fg = 0x6700; gp2x_printf(NULL, 0, (33 + (virtualFile*8)), "->"); } else { gp2x_default_font.fg = 0xFFFF; gp2x_printf(NULL, 0, (33 + (virtualFile*8)), "->"); } gp2x_default_font.fg = 0xFFFF; if(curFile) gp2x_printf(NULL, 200, 22, "^\n|"); if((curFile + 18 != fileCounter) && fileCounter > 19) gp2x_printf(NULL, 200, 200, "|\nv"); gp2x_video_RGB_flip(0); if(pad & GP2X_RIGHT) { virtualFile += 5; if(virtualFile > 18) curFile += virtualFile - 18; textClear(); } if(pad & GP2X_LEFT) { virtualFile -= 5; if(virtualFile < 0) curFile += virtualFile; textClear(); } if(pad & GP2X_DOWN) { virtualFile++; textClear(); } if(pad & GP2X_UP) { virtualFile--; textClear(); } if(pad & GP2X_VOL_DOWN) if(pad & GP2X_START) exitMenu(); if(pad & GP2X_X) { if(FileList[curFile + virtualFile].fType == FT_DIR) { chdir(FileList[curFile + virtualFile].fName); fillList(); virtualFile = curFile = 0; } else if(FileList[curFile + virtualFile].isRunable) { //textClear(); //gp2x_printf(0, 1, 1, "Loading...\n\n%s", FileList[curFile + virtualFile].fName); //gp2x_video_RGB_flip(0); RESIZE(); loadROM(FileList[curFile + virtualFile].fName); textClear(); supervision_load((u8*)buffer, (uint32)buffer_size); textClear(); return; } } //if(pad & GP2X_A) return; if(virtualFile < 0) { virtualFile = 0; --curFile; if(curFile < 0) curFile = 0; } if(fileCounter < 19) { if(virtualFile >= fileCounter) virtualFile = fileCounter-1; } else { if(virtualFile > 18) { virtualFile = 18; ++curFile; if(curFile + 18 > fileCounter) curFile = fileCounter - 19; } } while(pad == gp2x_joystick_read(0)); pad = gp2x_joystick_read(0); textClear(); } }
u16 ReadZodKeys() { u16 pad_status = 0xffff; u32 keys = gp2x_joystick_read(); #ifdef PANDORA if( keys & GP2X_PUSH && keys & GP2X_L ) // L2 { keys |= GP2X_VOL_DOWN; } if( keys & GP2X_PUSH && keys & GP2X_R ) // R2 { keys |= GP2X_VOL_UP; } #endif if( keys & GP2X_VOL_DOWN ) // L2 { pad_status &= ~(1<<8); } if (keys & GP2X_L) { pad_status &= ~(1<<10); // L ? } if( keys & GP2X_VOL_UP ) // R2 { pad_status &= ~(1<<9); } if (keys & GP2X_R) { pad_status &= ~(1<<11); // R ? } 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_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); } #if !defined(IPHONE) && !defined(ANDROID) if( (keys & GP2X_L) && (keys & GP2X_R) && (keys & GP2X_X) && (keys & GP2X_Y) && (keys & GP2X_A) && (keys & GP2X_B) ) { SysClose(); } if( keys == GP2X_PUSH ) { // Menu system u32 w = gp2xscreen_width; u32 h = gp2xscreen_height; u32 isRGB24; gp2x_change_res(320, 240, 16); gp2x_sound_thread_mute(); if( 0 != SelectOptions() ) { GPU_force_res_change = 1; psx4all_emulating=1; psxCpu->Execute(); psx4all_emulating=0; } #if !defined(ANDROID) gp2x_sound_thread_play(NULL); #endif isRGB24 = (GPU_GP1 & 0x00200000 ? 32 : 0); gp2x_change_res(w, h, isRGB24 ? 24 : 16); } #endif return pad_status; }
void gp2x_poll_input(void) { static int stats_button; static int prefs_button; static int vkeyb_button; static int joy_time = 0; static unsigned int a_held = 0; static unsigned int x_held = 0; unsigned int i; unsigned int joy_state = gp2x_joystick_read(0); /* start */ if (joy_state&GP2X_START) { input_start = 1; } /* prefs */ if (!(joy_state & GP2X_SELECT)) { prefs_button = 0; } if (joy_state & GP2X_SELECT && !prefs_button) { prefs_open = ~prefs_open; prefs_button = 1; } /* vkeyb */ if (!(joy_state & GP2X_L)) { vkeyb_button = 0; } if (joy_state & GP2X_L && !vkeyb_button) { vkeyb_open = ~vkeyb_open; vkeyb_button = 1; } if (prefs_open || vkeyb_open) { int rrate; resources_get_int("RefreshRate", &rrate); if (!rrate) { rrate++; } if (joy_state & (GP2X_UP | GP2X_DOWN | GP2X_LEFT | GP2X_RIGHT)) { joy_time += rrate; } else { joy_time = 0; } if (joy_time == rrate || (joy_time > 6)) { if (joy_time > 4) { joy_time = rrate; } input_up = joy_state & GP2X_UP; input_down = joy_state & GP2X_DOWN; input_select = joy_state & GP2X_SELECT; input_left = joy_state & GP2X_LEFT; input_right = joy_state & GP2X_RIGHT; } /* B button */ if ((joy_state & (GP2X_B | GP2X_PUSH)) != input_b_last) { input_b = joy_state & (GP2X_B | GP2X_PUSH); input_b_last = input_b; } /* A button */ if ((joy_state & GP2X_A) != input_a_last) { input_a = joy_state & GP2X_A; input_a_last = input_a; } /* X button */ if ((joy_state & GP2X_X) != input_x_last) { input_x = joy_state & GP2X_X; input_x_last = input_x; } /* Y button */ if (!(joy_state & GP2X_Y)) { input_y = 0; } if ((joy_state & GP2X_Y) && !input_y) { input_y = 1; } } /* stats */ if (!(joy_state & GP2X_R)) { stats_button = 0; } if (joy_state & GP2X_R && !stats_button) { stats_open = ~stats_open; stats_button = 1; } /* A */ if (mapped_key_a) { if ((joy_state & GP2X_A) && (!a_held)) { a_held = 1; keyboard_set_keyarr(mapped_key_a_row, mapped_key_a_col, 1); } else if (a_held && (!(joy_state & GP2X_A))) { a_held = 0; keyboard_set_keyarr(mapped_key_a_row, mapped_key_a_col, 0); } } /* X */ if (mapped_key_x) { if ((joy_state & GP2X_X) && (!x_held)) { x_held = 1; keyboard_set_keyarr(mapped_key_x_row, mapped_key_x_col, 1); } else if (x_held && (!(joy_state & GP2X_X))) { x_held = 0; keyboard_set_keyarr(mapped_key_x_row, mapped_key_x_col, 0); } } //volume if (gp2x_joystick_read(0) & GP2X_VOL_UP) { volume_up(); } else if (gp2x_joystick_read(0) & GP2X_VOL_DOWN) { volume_down(); } if (prefs_open || vkeyb_open) { return; } //gp2x joystick BYTE j = joystick_value[cur_port]; if (joy_state & GP2X_UP) { j |= 0x01; } else { j &= ~0x01; } if (joy_state & GP2X_DOWN) { j |= 0x02; } else { j &= ~0x02; } if (joy_state & GP2X_LEFT) { j |= 0x04; } else { j &=~ 0x04; } if (joy_state & GP2X_RIGHT) { j |= 0x08; } else { j &= ~0x08; } if (joy_state & (GP2X_B | GP2X_PUSH)) { j |= 0x10; } else { j &= ~0x10; } joystick_value[cur_port] = j; //mapped if (mapped_up) { if (joy_state & mapped_up) { j |= 0x01; joystick_value[cur_port] = j; } } if (mapped_down) { if (joy_state & mapped_down) { j |= 0x02; joystick_value[cur_port] = j; } } if (mapped_left) { if (joy_state & mapped_left) { j |= 0x04; joystick_value[cur_port] = j; } } if (mapped_right) { if (joy_state&mapped_right) { j |= 0x08; joystick_value[cur_port] = j; } } gp2x_poll_usb_input(); }
BOOL controls_update(void) { controls_state = 0; #ifdef GP2X unsigned long pad=gp2x_joystick_read(0); if (pad & GP2X_UP) controls_state|=0x08; if (pad & GP2X_RIGHT) controls_state|=0x01; if (pad & GP2X_LEFT) controls_state|=0x02; if (pad & GP2X_DOWN) controls_state|=0x04; if (pad & GP2X_UP) controls_state|=0x08; if (pad & GP2X_X) controls_state|=0x10; if (pad & GP2X_B) controls_state|=0x20; if (pad & GP2X_START) controls_state|=0x80; if (pad & GP2X_SELECT) controls_state|=0x40; #endif #ifdef NDS if (!(REG_KEYINPUT & KEY_RIGHT)) controls_state|=0x01; if (!(REG_KEYINPUT & KEY_LEFT)) controls_state|=0x02; if (!(REG_KEYINPUT & KEY_DOWN)) controls_state|=0x04; if (!(REG_KEYINPUT & KEY_UP)) controls_state|=0x08; if (!(REG_KEYINPUT & KEY_A)) controls_state|=0x10; if (!(REG_KEYINPUT & KEY_B)) controls_state|=0x20; if (!(REG_KEYINPUT & KEY_SELECT)) controls_state|=0x40; if (!(REG_KEYINPUT & KEY_START)) controls_state|=0x80; #endif /*#ifdef _SDL_ uint8 *keystate = SDL_GetKeyState(NULL); if (keystate[SDLK_RIGHT]) controls_state|=0x01; if (keystate[SDLK_LEFT]) controls_state|=0x02; if (keystate[SDLK_DOWN]) controls_state|=0x04; if (keystate[SDLK_UP]) controls_state|=0x08; if (keystate[SDLK_x]) controls_state|=0x10; if (keystate[SDLK_c]) controls_state|=0x20; if (keystate[SDLK_F1]) controls_state|=0x80; if (keystate[SDLK_F2]) controls_state|=0x40; #endif*/ #ifdef _SDL_ SDL_Event event; // Check for events while( SDL_PollEvent( &event ) ) { switch( event.type ) { case SDL_KEYDOWN: switch( event.key.keysym.sym ) { case SDLK_RIGHT: controls_state|=0x01; break; case SDLK_LEFT: controls_state|=0x02; break; case SDLK_DOWN: controls_state|=0x04; break; case SDLK_UP: controls_state|=0x08; break; case SDLK_x: controls_state|=0x10; break; case SDLK_c: controls_state|=0x20; break; case SDLK_F1: controls_state|=0x40; break; case SDLK_F2: controls_state|=0x80; break; default: break; } break; } } #endif return(TRUE); }
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; }
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; }
static int menuLoadLoop(char *curr_path) { char *ret = NULL, *fname = NULL; struct dirent **namelist; DIR *dir; int n, sel = 0; unsigned long inp = 0; min_in_dir=0; max_in_dir=SHOW_MAX_FILES; // is this a dir or a full path? if ((dir = opendir(curr_path))) closedir(dir); else { char *p; for (p = curr_path + strlen(curr_path) - 1; p > curr_path && *p != '/'; p--); *p = 0; fname = p+1; } n = scandir(curr_path, &namelist, scandir_filter, scandir_cmp); if (n < 0) { // try root n = scandir("/", &namelist, scandir_filter, scandir_cmp); if (n < 0) { // oops, we failed printf("dir: "); printf(curr_path); printf("\n"); perror("scandir"); return 0; } } if (n<10) usleep(70*1024); else usleep(40*1024); // try to find sel if (fname != NULL) { //SDL_GP2X_VSync(); int i; for (i = 1; i < n; i++) { if (strcmp(namelist[i]->d_name, fname) == 0) { sel = i - 1; break; } } } int loaded=0; int delay=0; for (;;) { unsigned long keys; draw_dirlist(curr_path, namelist, n, sel); delay ++; if (delay>3) { delay=0; keys = gp2x_joystick_read(0); } else keys=0; if(keys&GP2X_UP) { sel--; if (sel < 0) sel = n-2; /*usleep(10*1024);*/ } if(keys&GP2X_DOWN) { sel++; if (sel > n-2) sel = 0;/*usleep(10*1024);*/} if(keys&GP2X_LEFT) { sel-=10; if (sel < 0) sel = 0;/*usleep(10*1024);*/} if(keys&GP2X_L) { sel-=24; if (sel < 0) sel = 0;/*usleep(10*1024);*/} if(keys&GP2X_RIGHT) { sel+=10; if (sel > n-2) sel = n-2;/*usleep(10*1024);*/} if(keys&GP2X_R) { sel+=24; if (sel > n-2) sel = n-2;/*usleep(10*1024);*/} #if !defined(GCW0) if(keys&GP2X_SELECT) { run_menuFileinfo(namelist[sel+1]->d_name);} #endif if(keys&GP2X_B || ((keys&GP2X_Y) && nr_drives>1) || ((keys&GP2X_A) && nr_drives>2) || ((keys&GP2X_X && nr_drives==4))) { if (namelist[sel+1]->d_type == DT_REG) { int df; int newlen = strlen(curr_path) + strlen(namelist[sel+1]->d_name) + 2; char *p; char *filename; filename=(char*)malloc(newlen); strcpy(filename, curr_path); p = filename + strlen(filename) - 1; while (*p == '/' && p >= filename) *p-- = 0; strcat(filename, "/"); strcat(filename, namelist[sel+1]->d_name); printf("Selecting file %s\n",filename); if (keys&GP2X_B){strcpy(uae4all_image_file0,filename);df=0;} else if(keys&GP2X_Y) {strcpy(uae4all_image_file1,filename);df=1;} else if(keys&GP2X_A) {strcpy(uae4all_image_file2,filename);df=2;} else if(keys&GP2X_X) {strcpy(uae4all_image_file3,filename);df=3;} printf("DF0 %s\n",uae4all_image_file0); loaded=1; strcpy(currentDir,filename); free(filename); break; } else if (namelist[sel+1]->d_type == DT_DIR) { int newlen = strlen(curr_path) + strlen(namelist[sel+1]->d_name) + 2; char *p; char *newdir; newdir=(char*)malloc(newlen); if (strcmp(namelist[sel+1]->d_name, "..") == 0) { char *start = curr_path; p = start + strlen(start) - 1; while (*p == '/' && p > start) p--; while (*p != '/' && p > start) p--; if (p <= start) strcpy(newdir, "/"); else { strncpy(newdir, start, p-start); newdir[p-start] = 0; } } else { strcpy(newdir, curr_path); p = newdir + strlen(newdir) - 1; while (*p == '/' && p >= newdir) *p-- = 0; strcat(newdir, "/"); strcat(newdir, namelist[sel+1]->d_name); } strcpy(currentDir,newdir); loaded = menuLoadLoop(newdir); free(newdir); break; } } if(keys&GP2X_START) break; } if (n > 0) { while(n--) free(namelist[n]); free(namelist); } return loaded; }
static int show_options(char *game) { unsigned long ExKey=0; int selected_option=0; int x_Pos = 41; int y_Pos = 43; int options_count = 12; char text[256]; FILE *f; int i=0; while(ExKey=gp2x_joystick_read(0)&0x8c0ff55){ gp2x_video_flip(); gp2x_timer_delay(1); }; /* Read game configuration */ sprintf(text,get_documents_path("frontend/%s_v5.cfg"),game); f=fopen(text,"r"); if (f) { fscanf(f,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&m4all_video_aspect,&m4all_video_rotate,&m4all_video_sync, &m4all_frameskip,&m4all_sound,&m4all_buttons,&m4all_clock_cpu,&m4all_clock_sound,&i,&m4all_cheat,&m4all_video_depth,&m4all_waysStick,&m4all_cpu_cores); 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"); strncpy (text,game_list_description(last_game_selected),33); text[32]='\0'; gp2x_gamelist_text_out(x_Pos,y_Pos+10,text); /* (1) Video Aspect */ switch (m4all_video_aspect) { case 0: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect Original"); break; /* case 1: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect Ratio Not Kept"); break; */ case 1: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect Cropping 4/3"); break; case 2: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect Cropping 3/4"); break; case 3: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect Fixed 320x240"); break; case 4: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect Fixed 240x320"); break; case 5: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect Fixed 640x480"); break; case 6: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect Fixed 480x640"); break; } /* (2) Video Rotation */ switch (m4all_video_rotate) { case 0: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+40,"Video Rotate No"); break; case 1: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+40,"Video Rotate Yes"); break; case 2: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+40,"Video Rotate TATE"); break; } /* (3) Video Depth */ switch (m4all_video_depth) { case -1: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+50,"Video Depth Auto"); break; case 8: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+50,"Video Depth 8 bit"); break; case 16: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+50,"Video Depth 16 bit"); break; } /* (4) Video Sync */ switch (m4all_video_sync) { case 0: gp2x_gamelist_text_out(x_Pos,y_Pos+60, "Video Sync Normal"); break; case 1: gp2x_gamelist_text_out(x_Pos,y_Pos+60, "Video Sync DblBuf"); break; case -1: gp2x_gamelist_text_out(x_Pos,y_Pos+60,"Video Sync OFF"); break; } /* (5) Frame-Skip */ if(m4all_frameskip==-1) { gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70, "Frame-Skip Auto"); } else{ gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Frame-Skip %d",m4all_frameskip); } /* (6) Sound */ switch(m4all_sound) { case 0: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+80,"Sound %s","OFF"); break; case 1: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+80,"Sound %s","ON (11 KHz fast)"); break; case 2: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+80,"Sound %s","ON (22 KHz fast)"); break; case 3: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+80,"Sound %s","ON (33 KHz fast)"); break; case 4: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+80,"Sound %s","ON (44 KHz fast)"); break; case 5: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+80,"Sound %s","ON (11 KHz)"); break; case 6: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+80,"Sound %s","ON (22 KHz)"); break; case 7: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+80,"Sound %s","ON (33 KHz)"); break; case 8: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+80,"Sound %s","ON (44 KHz)"); break; case 9: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+80,"Sound %s","ON (11 KHz stereo)"); break; case 10: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+80,"Sound %s","ON (22 KHz stereo)"); break; case 11: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+80,"Sound %s","ON (33 KHz stereo)"); break; case 12: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+80,"Sound %s","ON (44 KHz stereo)"); break; } /* (7) Landscape Num Buttons */ switch (m4all_waysStick) { case 8: gp2x_gamelist_text_out(x_Pos,y_Pos+90, "Stick 8-way"); break; case 4: gp2x_gamelist_text_out(x_Pos,y_Pos+90, "Stick 4-way"); break; case 2: gp2x_gamelist_text_out(x_Pos,y_Pos+90, "Stick 2-way"); break; } /* (8) Landscape Num Buttons */ switch (m4all_buttons) { case 0: gp2x_gamelist_text_out(x_Pos,y_Pos+100, "Num Buttons 0 Button"); break; case 1: gp2x_gamelist_text_out(x_Pos,y_Pos+100, "Num Buttons 1 Button"); break; case 2: gp2x_gamelist_text_out(x_Pos,y_Pos+100, "Num Buttons 2 Buttons"); break; case 3: gp2x_gamelist_text_out(x_Pos,y_Pos+100, "Num Buttons 3 Buttons (A=B+X)"); break; case 4: gp2x_gamelist_text_out(x_Pos,y_Pos+100, "Num Buttons 3 Buttons"); break; case 5: gp2x_gamelist_text_out(x_Pos,y_Pos+100, "Num Buttons 4 Buttons"); break; case 6: gp2x_gamelist_text_out(x_Pos,y_Pos+100, "Num Buttons All Buttons"); break; } /* (9) CPU Clock */ gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+110,"CPU Clock %d%%",m4all_clock_cpu); /* (10) Audio Clock */ gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+120,"Audio Clock %d%%",m4all_clock_sound); /* (11) CPU ASM Cores */ if(m4all_ASMCores) { switch (m4all_cpu_cores) { case 0: gp2x_gamelist_text_out(x_Pos,y_Pos+130, "CPU ASM cores None"); break; case 1: gp2x_gamelist_text_out(x_Pos,y_Pos+130, "CPU ASM cores Cyclone"); break; case 2: gp2x_gamelist_text_out(x_Pos,y_Pos+130, "CPU ASM cores DrZ80"); break; case 3: gp2x_gamelist_text_out(x_Pos,y_Pos+130, "CPU ASM cores Cyclone+DrZ80"); break; case 4: gp2x_gamelist_text_out(x_Pos,y_Pos+130, "CPU ASM cores DrZ80(snd)"); break; case 5: gp2x_gamelist_text_out(x_Pos,y_Pos+130, "CPU ASM cores Cyclone+DrZ80(snd)"); break; case 6: gp2x_gamelist_text_out(x_Pos,y_Pos+130, "CPU ASM cores All"); break; } } else { gp2x_gamelist_text_out(x_Pos,y_Pos+130, "CPU ASM cores None"); } /* (12) Cheats */ if (m4all_cheat) gp2x_gamelist_text_out(x_Pos,y_Pos+140,"Cheats ON"); else gp2x_gamelist_text_out(x_Pos,y_Pos+140,"Cheats OFF"); gp2x_gamelist_text_out(x_Pos,y_Pos+160,"Press B to confirm, X to return\0"); /* Show currently selected item */ gp2x_gamelist_text_out(x_Pos-16,y_Pos+(selected_option*10)+30," >"); gp2x_video_flip(); gp2x_timer_delay(150); ExKey=gp2x_joystick_read(0)&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; } else if(ExKey & GP2X_R || ExKey & GP2X_L || ExKey & GP2X_RIGHT || ExKey & GP2X_LEFT) { switch(selected_option) { case 0: if((ExKey & GP2X_R) || (ExKey & GP2X_RIGHT)) { m4all_video_aspect++; if (m4all_video_aspect>6) m4all_video_aspect=0; } else { m4all_video_aspect--; if (m4all_video_aspect<0) m4all_video_aspect=6; } break; case 1: if((ExKey & GP2X_R) || (ExKey & GP2X_RIGHT)) { m4all_video_rotate++; if (m4all_video_rotate>2) m4all_video_rotate=0; } else { m4all_video_rotate--; if (m4all_video_rotate<0) m4all_video_rotate=2; } break; case 2: switch (m4all_video_depth) { case -1: m4all_video_depth=8; break; case 8: m4all_video_depth=16; break; case 16: m4all_video_depth=-1; break; } break; case 3: m4all_video_sync=m4all_video_sync+1; if (m4all_video_sync>1) m4all_video_sync=-1; break; case 4: /* "Frame-Skip" */ if(ExKey & GP2X_R || ExKey & GP2X_RIGHT ) { m4all_frameskip ++; if (m4all_frameskip>11) m4all_frameskip=-1; } else { m4all_frameskip--; if (m4all_frameskip<-1) m4all_frameskip=11; } break; case 5: if(ExKey & GP2X_R || ExKey & GP2X_RIGHT) { m4all_sound ++; if (m4all_sound>12) m4all_sound=0; } else { m4all_sound--; if (m4all_sound<0) m4all_sound=12; } break; case 6: switch (m4all_waysStick) { case 8: m4all_waysStick=4; break; case 4: m4all_waysStick=2; break; case 2: m4all_waysStick=8; break; } break; case 7: if(ExKey & GP2X_R || ExKey & GP2X_RIGHT) { m4all_buttons ++; if (m4all_buttons>6) m4all_buttons=0; } else { m4all_buttons--; if (m4all_buttons<0) m4all_buttons=6; } break; case 8: /* "CPU Clock" */ if(ExKey & GP2X_R || ExKey & GP2X_RIGHT) { m4all_clock_cpu += 10; /* Add 10% */ if (m4all_clock_cpu > 200) /* 200% is the max */ m4all_clock_cpu = 200; } else { m4all_clock_cpu -= 10; /* Subtract 10% */ if (m4all_clock_cpu < 10) /* 10% is the min */ m4all_clock_cpu = 10; } break; case 9: /* "Audio Clock" */ if(ExKey & GP2X_R || ExKey & GP2X_RIGHT) { m4all_clock_sound += 10; /* Add 10% */ if (m4all_clock_sound > 200) /* 200% is the max */ m4all_clock_sound = 200; } else{ m4all_clock_sound -= 10; /* Subtract 10% */ if (m4all_clock_sound < 10) /* 10% is the min */ m4all_clock_sound = 10; } break; case 10: m4all_cpu_cores=(m4all_cpu_cores+1)%7; break; case 11: m4all_cheat=!m4all_cheat; break; } } if ((ExKey & GP2X_A) || (ExKey & GP2X_B) || (ExKey & GP2X_PUSH) || (ExKey & GP2X_START)) { /* Write game configuration */ sprintf(text,get_documents_path("frontend/%s_v5.cfg"),game); f=fopen(text,"w"); if (f) { fprintf(f,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",m4all_video_aspect,m4all_video_rotate,m4all_video_sync, m4all_frameskip,m4all_sound,m4all_buttons,m4all_clock_cpu,m4all_clock_sound,i,m4all_cheat,m4all_video_depth,m4all_waysStick,m4all_cpu_cores); fclose(f); sync(); } /* Selected game will be run */ return 1; } else if ((ExKey & GP2X_X) || (ExKey & GP2X_Y) || (ExKey & GP2X_SELECT)) { /* Return To Menu */ return 0; } } }
static int show_options(char *game) { unsigned long ExKey=0; int selected_option=0; int x_Pos = 41; int y_Pos = 58; int options_count = 12; char text[256]; FILE *f; int i=0; /* Read game configuration */ sprintf(text,"frontend/%s.cfg",game); f=fopen(text,"r"); if (f) { fscanf(f,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&gp2x_freq,&gp2x_video_depth,&gp2x_video_aspect,&gp2x_video_sync, &gp2x_frameskip,&gp2x_sound,&gp2x_clock_cpu,&gp2x_clock_sound,&gp2x_cpu_cores,&gp2x_ramtweaks,&i,&gp2x_cheat,&gp2x_volume); fclose(f); } while(1) { /* Draw background image */ load_bmp_8bpp(gp2x_screen8,gp2xmenu_bmp); /* Draw the options */ strncpy (text,game_list_description(last_game_selected),33); text[32]='\0'; gp2x_gamelist_text_out(x_Pos,y_Pos-10,text); /* (0) GP2X Clock */ gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+10, "GP2X Clock %d MHz", gp2x_freq); /* (1) Video Depth */ switch (gp2x_video_depth) { case -1: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+20,"Video Depth Auto"); break; case 8: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+20,"Video Depth 8 bit"); break; case 16: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+20,"Video Depth 16 bit"); break; } /* (2) Video Aspect */ switch (gp2x_video_aspect) { case 0: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect Normal"); break; case 1: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect Scale"); break; case 2: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect 4:3"); break; case 3: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect Scale 4:3"); break; case 4: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect Border"); break; case 5: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect Border Scale"); break; case 6: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect Border 4:3"); break; case 7: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect Border Scale 4:3"); break; case 8: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect Rotate"); break; case 9: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect Rotate Scale"); break; case 10: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect Rotate 4:3"); break; case 11: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect Rotate Scale 4:3"); break; case 12: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect Rotate Border"); break; case 13: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect Rotate Border Scale"); break; case 14: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect Rotate Border 4:3"); break; case 15: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect Rotate Border S4:3"); break; case 16: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect TATE"); break; case 17: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect TATE Scale"); break; case 18: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect TATE 4:3"); break; case 19: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect TATE Scale 4:3"); break; case 20: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect TATE Border"); break; case 21: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect TATE Border Scale"); break; case 22: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect TATE Border 4:3"); break; case 23: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect TATE Border S4:3"); break; } /* (3) Video Sync */ switch (gp2x_video_sync) { case 1: gp2x_gamelist_text_out(x_Pos,y_Pos+40, "Video Sync VSync"); break; case 0: gp2x_gamelist_text_out(x_Pos,y_Pos+40, "Video Sync Normal"); break; case 2: gp2x_gamelist_text_out(x_Pos,y_Pos+40, "Video Sync DblBuf"); break; case -1: gp2x_gamelist_text_out(x_Pos,y_Pos+40,"Video Sync OFF"); break; } /* (4) Frame-Skip */ if ((gp2x_video_sync==-1) && (gp2x_frameskip==-1)) gp2x_frameskip=0; if(gp2x_frameskip==-1) { gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+50, "Frame-Skip Auto"); } else{ gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+50,"Frame-Skip %d",gp2x_frameskip); } /* (5) Sound */ switch(gp2x_sound) { case 0: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+60,"Sound %s","OFF"); break; case 1: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+60,"Sound %s","ON (15 KHz fast)"); break; case 2: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+60,"Sound %s","ON (22 KHz fast)"); break; case 3: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+60,"Sound %s","ON (33 KHz fast)"); break; case 4: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+60,"Sound %s","ON (44 KHz fast)"); break; case 5: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+60,"Sound %s","ON (11 KHz fast)"); break; case 6: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+60,"Sound %s","ON (15 KHz)"); break; case 7: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+60,"Sound %s","ON (22 KHz)"); break; case 8: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+60,"Sound %s","ON (33 KHz)"); break; case 9: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+60,"Sound %s","ON (44 KHz)"); break; case 10: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+60,"Sound %s","ON (11 KHz)"); break; case 11: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+60,"Sound %s","ON (15 KHz stereo)"); break; case 12: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+60,"Sound %s","ON (22 KHz stereo)"); break; case 13: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+60,"Sound %s","ON (33 KHz stereo)"); break; case 14: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+60,"Sound %s","ON (44 KHz stereo)"); break; case 15: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+60,"Sound %s","ON (11 KHz stereo)"); break; } /* (6) CPU Clock */ gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"CPU Clock %d%%",gp2x_clock_cpu); /* (7) Audio Clock */ gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+80,"Audio Clock %d%%",gp2x_clock_sound); /* (8) CPU cores */ switch (gp2x_cpu_cores) { case 0: gp2x_gamelist_text_out(x_Pos,y_Pos+90, "CPU ASM cores None"); break; case 1: gp2x_gamelist_text_out(x_Pos,y_Pos+90, "CPU ASM cores Cyclone"); break; case 2: gp2x_gamelist_text_out(x_Pos,y_Pos+90, "CPU ASM cores DrZ80"); break; case 3: gp2x_gamelist_text_out(x_Pos,y_Pos+90, "CPU ASM cores Cyclone+DrZ80"); break; case 4: gp2x_gamelist_text_out(x_Pos,y_Pos+90, "CPU ASM cores DrZ80(snd)"); break; case 5: gp2x_gamelist_text_out(x_Pos,y_Pos+90, "CPU ASM cores Cyclone+DrZ80(snd)"); break; } /* (9) RAM Tweaks */ if (gp2x_ramtweaks) gp2x_gamelist_text_out(x_Pos,y_Pos+100,"RAM Tweaks ON"); else gp2x_gamelist_text_out(x_Pos,y_Pos+100,"RAM Tweaks OFF"); /* (10) Cheats */ if (gp2x_cheat) gp2x_gamelist_text_out(x_Pos,y_Pos+110,"Cheats ON"); else gp2x_gamelist_text_out(x_Pos,y_Pos+110,"Cheats OFF"); /* (11) Volume */ if (gp2x_sound == 0) { gp2x_gamelist_text_out(x_Pos,y_Pos+120,"Volume Disabled"); } else { switch (gp2x_volume) { case 1: gp2x_gamelist_text_out(x_Pos,y_Pos+120,"Volume Quiet"); break; case 2: gp2x_gamelist_text_out(x_Pos,y_Pos+120,"Volume Low"); break; case 3: gp2x_gamelist_text_out(x_Pos,y_Pos+120,"Volume Medium"); break; case 4: gp2x_gamelist_text_out(x_Pos,y_Pos+120,"Volume Maximum"); break; } } gp2x_gamelist_text_out(x_Pos,y_Pos+140,"Press B to confirm, X to return\0"); /* Show currently selected item */ gp2x_gamelist_text_out(x_Pos-16,y_Pos+(selected_option*10)+10," >"); gp2x_video_flip(); while(gp2x_joystick_read(0)&0x8c0ff55) { gp2x_timer_delay(150); } while(!(ExKey=gp2x_joystick_read(0)&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; } else if(ExKey & GP2X_R || ExKey & GP2X_L) { switch(selected_option) { case 0: /* 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; } } break; case 1: switch (gp2x_video_depth) { case -1: gp2x_video_depth=8; break; case 8: gp2x_video_depth=16; break; case 16: gp2x_video_depth=-1; break; } break; case 2: if(ExKey & GP2X_R) { gp2x_video_aspect++; if (gp2x_video_aspect>23) gp2x_video_aspect=0; } else { gp2x_video_aspect--; if (gp2x_video_aspect<0) gp2x_video_aspect=23; } break; case 3: gp2x_video_sync=gp2x_video_sync+1; if (gp2x_video_sync>2) gp2x_video_sync=-1; break; case 4: /* "Frame-Skip" */ if(ExKey & GP2X_R) { gp2x_frameskip ++; if (gp2x_frameskip>11) gp2x_frameskip=-1; } else { gp2x_frameskip--; if (gp2x_frameskip<-1) gp2x_frameskip=11; } break; case 5: if(ExKey & GP2X_R) { gp2x_sound ++; if (gp2x_sound>15) gp2x_sound=0; } else { gp2x_sound--; if (gp2x_sound<0) gp2x_sound=15; } break; case 6: /* "CPU Clock" */ if(ExKey & GP2X_R) { 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 7: /* "Audio Clock" */ if(ExKey & GP2X_R) { 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 8: gp2x_cpu_cores=(gp2x_cpu_cores+1)%6; break; case 9: gp2x_ramtweaks=!gp2x_ramtweaks; break; case 10: gp2x_cheat=!gp2x_cheat; break; case 11: /* Volume */ if(ExKey & GP2X_R) { gp2x_volume++; if (gp2x_volume > 4) gp2x_volume = 1; } else { gp2x_volume--; if (gp2x_volume < 1) gp2x_volume = 4; } break; } } if ((ExKey & GP2X_A) || (ExKey & GP2X_B) || (ExKey & GP2X_PUSH) || (ExKey & GP2X_START)) { /* Write game configuration */ sprintf(text,"frontend/%s.cfg",game); f=fopen(text,"w"); if (f) { fprintf(f,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",gp2x_freq,gp2x_video_depth,gp2x_video_aspect,gp2x_video_sync, gp2x_frameskip,gp2x_sound,gp2x_clock_cpu,gp2x_clock_sound,gp2x_cpu_cores,gp2x_ramtweaks,i,gp2x_cheat,gp2x_volume); fclose(f); sync(); } /* Selected game will be run */ return 1; } else if ((ExKey & GP2X_X) || (ExKey & GP2X_Y) || (ExKey & GP2X_SELECT)) { /* Return To Menu */ return 0; } } }
static int show_options(char *game) { unsigned long ExKey=0; int selected_option=0; int x_Pos = 41; int y_Pos = 58; int options_count = 9; char text[256]; FILE *f; int i=0; if(!safe_render_path) while(ExKey=gp2x_joystick_read(0)&0x8c0ff55){}; /* Read game configuration */ sprintf(text,get_documents_path("iOS/%s_v2.cfg"),game); f=fopen(text,"r"); if (f) { fscanf(f,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&iOS_video_aspect,&iOS_video_rotate,&iOS_video_sync, &iOS_frameskip,&iOS_sound,&iOS_landscape_buttons,&iOS_clock_cpu,&iOS_clock_sound,&i,&iOS_cheat); fclose(f); } if(!safe_render_path) { iOS_video_aspect=3; } 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"); strncpy (text,game_list_description(last_game_selected),33); text[32]='\0'; gp2x_gamelist_text_out(x_Pos,y_Pos+10,text); /* (1) Video Aspect */ switch (iOS_video_aspect) { case 0: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect Original"); break; case 1: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect Ratio Not Kept"); break; case 2: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect With Cropping"); break; case 3: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect Fixed 320x240"); break; } /* (2) Video Rotation */ switch (iOS_video_rotate) { case 0: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+40,"Video Rotate No"); break; case 1: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+40,"Video Rotate Yes"); break; case 2: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+40,"Video Rotate TATE"); break; } /* (3) Video Sync */ switch (iOS_video_sync) { case 0: gp2x_gamelist_text_out(x_Pos,y_Pos+50, "Video Sync Normal"); break; case 1: gp2x_gamelist_text_out(x_Pos,y_Pos+50, "Video Sync DblBuf"); break; case -1: gp2x_gamelist_text_out(x_Pos,y_Pos+50,"Video Sync OFF"); break; } /* (4) Frame-Skip */ if(iOS_frameskip==-1) { gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+60, "Frame-Skip Auto"); } else{ gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+60,"Frame-Skip %d",iOS_frameskip); } /* (5) Sound */ switch(iOS_sound) { case 0: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Sound %s","OFF"); break; case 1: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Sound %s","ON (11 KHz fast)"); break; case 2: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Sound %s","ON (22 KHz fast)"); break; case 3: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Sound %s","ON (33 KHz fast)"); break; case 4: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Sound %s","ON (44 KHz fast)"); break; case 5: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Sound %s","ON (11 KHz)"); break; case 6: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Sound %s","ON (22 KHz)"); break; case 7: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Sound %s","ON (33 KHz)"); break; case 8: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Sound %s","ON (44 KHz)"); break; case 9: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Sound %s","ON (11 KHz stereo)"); break; case 10: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Sound %s","ON (22 KHz stereo)"); break; case 11: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Sound %s","ON (33 KHz stereo)"); break; case 12: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Sound %s","ON (44 KHz stereo)"); break; } /* (6) Landscape Num Buttons */ switch (iOS_landscape_buttons) { case 1: gp2x_gamelist_text_out(x_Pos,y_Pos+80, "Landscape 1 Button"); break; case 2: gp2x_gamelist_text_out(x_Pos,y_Pos+80, "Landscape 2 Buttons"); break; case 3: gp2x_gamelist_text_out(x_Pos,y_Pos+80, "Landscape 3 Buttons"); break; case 4: gp2x_gamelist_text_out(x_Pos,y_Pos+80, "Landscape 4 Buttons"); break; } /* (7) CPU Clock */ gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+90,"CPU Clock %d%%",iOS_clock_cpu); /* (8) Audio Clock */ gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+100,"Audio Clock %d%%",iOS_clock_sound); /* (9) Cheats */ if (iOS_cheat) gp2x_gamelist_text_out(x_Pos,y_Pos+110,"Cheats ON"); else gp2x_gamelist_text_out(x_Pos,y_Pos+110,"Cheats OFF"); gp2x_gamelist_text_out(x_Pos,y_Pos+140,"Press B to confirm, X to return\0"); /* Show currently selected item */ gp2x_gamelist_text_out(x_Pos-16,y_Pos+(selected_option*10)+30," >"); gp2x_video_flip(); if(safe_render_path) { while(gp2x_joystick_read(0)&0x8c0ff55) { gp2x_timer_delay(150); } while(!(ExKey=gp2x_joystick_read(0)&0x8c0ff55)) { } } else { //ExKey=gp2x_joystick_read(0); //gp2x_timer_delay(150); gp2x_timer_delay(150); ExKey=gp2x_joystick_read(0)&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; } else if(ExKey & GP2X_R || ExKey & GP2X_L || ExKey & GP2X_RIGHT || ExKey & GP2X_LEFT) { switch(selected_option) { case 0: if(!safe_render_path) { iOS_video_aspect=3; break; } if((ExKey & GP2X_R) || (ExKey & GP2X_RIGHT)) { iOS_video_aspect++; if (iOS_video_aspect>3) iOS_video_aspect=0; } else { iOS_video_aspect--; if (iOS_video_aspect<0) iOS_video_aspect=3; } break; case 1: if((ExKey & GP2X_R) || (ExKey & GP2X_RIGHT)) { iOS_video_rotate++; if (iOS_video_rotate>2) iOS_video_rotate=0; } else { iOS_video_rotate--; if (iOS_video_rotate<0) iOS_video_rotate=2; } break; case 2: iOS_video_sync=iOS_video_sync+1; if (iOS_video_sync>1) iOS_video_sync=-1; break; case 3: /* "Frame-Skip" */ if(ExKey & GP2X_R || ExKey & GP2X_RIGHT ) { iOS_frameskip ++; if (iOS_frameskip>11) iOS_frameskip=-1; } else { iOS_frameskip--; if (iOS_frameskip<-1) iOS_frameskip=11; } break; case 4: if(ExKey & GP2X_R || ExKey & GP2X_RIGHT) { iOS_sound ++; if (iOS_sound>12) iOS_sound=0; } else { iOS_sound--; if (iOS_sound<0) iOS_sound=12; } break; case 5: if(ExKey & GP2X_R || ExKey & GP2X_RIGHT) { iOS_landscape_buttons ++; if (iOS_landscape_buttons>4) iOS_landscape_buttons=1; } else { iOS_landscape_buttons--; if (iOS_landscape_buttons<1) iOS_landscape_buttons=4; } break; case 6: /* "CPU Clock" */ if(ExKey & GP2X_R || ExKey & GP2X_RIGHT) { iOS_clock_cpu += 10; /* Add 10% */ if (iOS_clock_cpu > 200) /* 200% is the max */ iOS_clock_cpu = 200; } else { iOS_clock_cpu -= 10; /* Subtract 10% */ if (iOS_clock_cpu < 10) /* 10% is the min */ iOS_clock_cpu = 10; } break; case 7: /* "Audio Clock" */ if(ExKey & GP2X_R || ExKey & GP2X_RIGHT) { iOS_clock_sound += 10; /* Add 10% */ if (iOS_clock_sound > 200) /* 200% is the max */ iOS_clock_sound = 200; } else{ iOS_clock_sound -= 10; /* Subtract 10% */ if (iOS_clock_sound < 10) /* 10% is the min */ iOS_clock_sound = 10; } break; case 8: iOS_cheat=!iOS_cheat; break; } } if ((ExKey & GP2X_A) || (ExKey & GP2X_B) || (ExKey & GP2X_PUSH) || (ExKey & GP2X_START)) { /* Write game configuration */ sprintf(text,get_documents_path("iOS/%s_v2.cfg"),game); f=fopen(text,"w"); if (f) { fprintf(f,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",iOS_video_aspect,iOS_video_rotate,iOS_video_sync, iOS_frameskip,iOS_sound,iOS_landscape_buttons,iOS_clock_cpu,iOS_clock_sound,i,iOS_cheat); fclose(f); sync(); } /* Selected game will be run */ return 1; } else if ((ExKey & GP2X_X) || (ExKey & GP2X_Y) || (ExKey & GP2X_SELECT)) { /* Return To Menu */ return 0; } } }
static void select_game(char *emu, char *game) { unsigned long ExKey=0; int keydelay=0; /* No Selected game */ strcpy(game,"builtinn"); /* Clean screen */ gp2x_video_flip(); if(!safe_render_path) while(ExKey=gp2x_joystick_read(0)&0x8c0ff55){usleep(1000);}; /* Wait until user selects a game */ while(1) { if(local_manufacturer != global_manufacturer || local_clones != global_clones || local_filter != global_filter || local_category != global_category || local_year != global_year || local_game_list_num != game_list_num) { game_list_init(); last_game_selected=0; local_manufacturer = global_manufacturer; local_clones = global_clones; local_filter = global_filter; local_category = global_category; local_year = global_year; } game_list_view(&last_game_selected); gp2x_video_flip(); if(keydelay) { usleep(400000); keydelay=0; } if(safe_render_path) { if( (gp2x_joystick_read(0)&0x8c0ff55)) { usleep(100000); } while(!(ExKey=gp2x_joystick_read(0)&0x8c0ff55) && local_manufacturer == global_manufacturer && local_clones == global_clones && local_filter == global_filter && local_category == global_category && local_year == global_year && local_game_list_num == game_list_num) { keydelay=1; usleep(1000); } } else { usleep(100000); ExKey=gp2x_joystick_read(0); } if (ExKey & GP2X_UP) last_game_selected--; else if (ExKey & GP2X_DOWN) last_game_selected++; else if ((ExKey & GP2X_L) || ExKey & GP2X_LEFT) last_game_selected-=21; else if ((ExKey & GP2X_R) || ExKey & GP2X_RIGHT) last_game_selected+=21; //if ((ExKey & GP2X_L) && (ExKey & GP2X_R)) gp2x_exit(); //Set or clear favorite setting for this game if (ExKey & GP2X_SELECT) { //Check if the game is already a favorite game_list_select(last_game_selected, game, emu); int foundfav=0; int counter=0; while(true) { if (favarray[counter][0] == '\0') break; //Null is the array terminator if (strcasecmp(favarray[counter], game) == 0) { foundfav=1; break; } counter++; } if(foundfav) { favorites_remove(game); } else { favorites_add(game); } } if (((ExKey & GP2X_A) || (ExKey & GP2X_B) || (ExKey & GP2X_PUSH) || (ExKey & GP2X_START)) && game_num_avail!=0) { /* Select the game */ game_list_select(last_game_selected, game, emu); /* Emulation Options */ //defaults! iOS_video_aspect=0; iOS_video_rotate=0; iOS_video_sync=0; iOS_frameskip=-1; iOS_cheat=0; iOS_waysStick = 8; if(!safe_render_path) { iOS_sound = global_sound; iOS_video_depth=8; } else { iOS_sound = global_sound; iOS_video_depth=16; } if(isIpad) { iOS_clock_cpu= 100; iOS_clock_sound= 100; iOS_buttons=2; iOS_sound=global_sound; } else { iOS_clock_cpu= 80; iOS_clock_sound= 80; iOS_buttons=2; } if(show_options(game)) { break; } } } }
void handleMainMenu(void) { BOOL isSelected = FALSE; int menuOption = 0; textClear(); gp2x_video_RGB_setscaling(320, 240); while(!isSelected) { unsigned long pad = gp2x_joystick_read(0); printMenuOptions(); gp2x_printf(0, 170, 1, "MenuOption = %d",menuOption); gp2x_printf(0, 0, (31 + (menuOption*8)), "->"); gp2x_video_RGB_flip(0); if(pad & GP2X_RIGHT) { if((menuOption == MMOPTION_SAVESTATE) || (menuOption == MMOPTION_LOADSTATE)) saveSlot++; } if(pad & GP2X_LEFT) { if((menuOption == MMOPTION_SAVESTATE) || (menuOption == MMOPTION_LOADSTATE)) saveSlot--; } if(pad & GP2X_DOWN) { menuOption++; textClear(); } if(pad & GP2X_UP) { menuOption--; textClear(); } if(pad & GP2X_VOL_DOWN) if(pad & GP2X_START) exitMenu(); if(pad & GP2X_X) { switch(menuOption){ case MMOPTION_CONTINUE: RESIZE(); textClear(); return; case MMOPTION_RESTART: RESIZE(); supervision_reset(); textClear(); return; case MMOPTION_SELECTOR: handleFileMenu(); return; case MMOPTION_OPTIONS: handleOptionsMenu(); textClear(); return; case MMOPTION_SAVESTATE: sv_saveState(romname,saveSlot); textClear();return; case MMOPTION_LOADSTATE: sv_loadState(romname,saveSlot); textClear();return; case MMOPTION_EXIT: exitMenu(); break; default: return; } } /*if(pad & GP2X_B) { textClear(); return; }*/ if(menuOption < 0) menuOption = 0; if(menuOption > 6) menuOption = 6; if(saveSlot < 0) saveSlot = 0; if(saveSlot > 9) saveSlot = 9; while(pad == gp2x_joystick_read(0)); pad = gp2x_joystick_read(0); textClear(); } }
static void select_game(char *emu, char *game) { unsigned long ExKey; /* No Selected game */ strcpy(game,"builtinn"); /* Clean screen */ gp2x_video_flip(); if(!safe_render_path) while(ExKey=gp2x_joystick_read(0)&0x8c0ff55){}; /* Wait until user selects a game */ while(1) { game_list_view(&last_game_selected); gp2x_video_flip(); if(safe_render_path) { if( (gp2x_joystick_read(0)&0x8c0ff55)) gp2x_timer_delay(100); while(!(ExKey=gp2x_joystick_read(0)&0x8c0ff55)) { if ((ExKey & GP2X_L) && (ExKey & GP2X_R)) { gp2x_exit(); } } } else { gp2x_timer_delay(100); ExKey=gp2x_joystick_read(0); } if (ExKey & GP2X_UP) last_game_selected--; else if (ExKey & GP2X_DOWN) last_game_selected++; else if ((ExKey & GP2X_L) || ExKey & GP2X_LEFT) last_game_selected-=21; else if ((ExKey & GP2X_R) || ExKey & GP2X_RIGHT) last_game_selected+=21; //if ((ExKey & GP2X_L) && (ExKey & GP2X_R)) gp2x_exit(); if (((ExKey & GP2X_A) || (ExKey & GP2X_B) || (ExKey & GP2X_PUSH) || (ExKey & GP2X_START)) && game_num_avail!=0) { /* Select the game */ game_list_select(last_game_selected, game, emu); /* Emulation Options */ //defaults! iOS_video_aspect=0; iOS_video_rotate=0; iOS_video_sync=0; iOS_frameskip=-1; iOS_cheat=0; if(!safe_render_path) iOS_sound = 1; else iOS_sound = 4; if(isIpad) { iOS_clock_cpu= 100; iOS_clock_sound= 100; iOS_landscape_buttons=2; } else { iOS_clock_cpu= 80; iOS_clock_sound= 80; iOS_landscape_buttons=2; } if(show_options(game)) { break; } } } }
void gp2x_poll_usb_input(void) { static int stats_button; static int prefs_button; static int vkeyb_button; static int joy_time = 0; static unsigned int a_held = 0; static unsigned int x_held = 0; unsigned int i; unsigned int j; unsigned int joy_state = gp2x_joystick_read(0); //usb joysticks if (gp2x_usbjoys > 0) { joy_state = gp2x_joystick_read(1); j = joystick_value[cur_portusb1]; if (joy_state & GP2X_UP) { j |= 0x01; } else { j &= ~0x01; } if (joy_state & GP2X_DOWN) { j |= 0x02; } else { j &= ~0x02; } if (joy_state & GP2X_LEFT) { j |= 0x04; } else { j &= ~0x04; } if (joy_state & GP2X_RIGHT) { j |= 0x08; } else { j &= ~0x08; } if (joy_state & (GP2X_B | GP2X_PUSH)) { j |= 0x10; } else { j &= ~0x10; } joystick_value[cur_portusb1] = j; if (gp2x_usbjoys > 1) { joy_state = gp2x_joystick_read(2); j = joystick_value[cur_portusb2]; if (joy_state & GP2X_UP) { j |= 0x01; } else { j &= ~0x01; } if (joy_state & GP2X_DOWN) { j |= 0x02; } else { j &= ~0x02; } if (joy_state & GP2X_LEFT) { j |= 0x04; } else { j &= ~0x04; } if (joy_state & GP2X_RIGHT) { j |= 0x08; } else { j &= ~0x08; } if (joy_state & (GP2X_B | GP2X_PUSH)) { j |= 0x10; } else { j &= ~0x10; } joystick_value[cur_portusb2]=j; } } //usb keyboard for (i = 0; i < gp2x_keyboard_readext(); ++i) { int keycode = keybuffer[i]; if (keycode & 0x80) { keycode &= 0x7f; // Remove release bit keyboard_key_released((signed long)keycode); } else { keyboard_key_pressed((signed long)keycode); } } }
int main(int argc,char **argv) { #ifdef PSP pspDebugScreenInit(); #ifdef PSP_USERMODE SetupCallbacks(); #endif #ifdef WIFI net_io_init(); #endif #endif char text[64]; int res, i, game_index; /* GP2X Video Init */ gp2x_video_init(); #ifdef GP2X { /* Border TV-Out */ #define BORDERTVOUTSTRUCTURE "--border_tvout %d --border_tvout_width %d --border_tvout_height %d" extern char gp2x_path_mame[24]; extern int gp2x_bordertvout; extern int gp2x_bordertvout_width; extern int gp2x_bordertvout_height; char name[256]; FILE *f; sprintf(name,"%scfg/mame_tvout.cfg",gp2x_path_mame); f=fopen(name,"rb"); if (f) { fscanf(f,BORDERTVOUTSTRUCTURE,&gp2x_bordertvout,&gp2x_bordertvout_width,&gp2x_bordertvout_height); fclose(f); if (gp2x_bordertvout) { printf("Border TV-Out Activated\r\n"); } else { printf("Border TV-Out Disabled\r\n"); } } } #endif /* Set Video Mode */ #ifdef PSP_RES SetVideoScaling(480,480,272); #else SetVideoScaling(320,320,240); #endif #ifdef GP2X /* Zaq121 07/05/2006 Alternative frontend support -> */ /* Check for command line arguments */ parse_cmdline (argc, argv, &options, game_index); if (no_selector==0) /* <- end mod */ #endif /* Intro screen */ gp2x_intro_screen(); /* Initialize Game Listings */ game_list_init(); while(1) { #ifdef GP2X /* Disable Scaling / Stretching */ { extern int gp2x_text_width; gp2x_text_width=320; } SetVideoScaling(320,320,240); gp2x_rotate=0; /* Mute Sound */ gp2x_sound_thread_mute(); #endif #ifdef GP2X /* Zaq121 07/05/2006 Alternative frontend support -> */ if (no_selector==0) /* <- end mod */ #endif /* Select Game */ select_game(playgame); #ifdef GP2X /* Zaq121 07/05/2006 Alternative frontend support -> */ else { extern int gp2x_freq; /* 9/5/06 Zaq, clock speed was never getting set */ int show_options(char *game); int set_last_game_selected(char *game); if(set_last_game_selected(playgame) == -1) break; /* game not available */ if(!show_options(playgame)) break; /* return back to external menu */ SetGP2XClock(gp2x_freq); /* 9/5/06 Zaq, clock speed was never getting set */ } /* <- end mod */ #endif /* Initialize the audio library */ msdos_init_seal(); /* Restore MAME Palette */ gp2x_mame_palette(); /* Set Log Messages start at row 0 */ gp2x_gamelist_zero(); /* Single Video Buffer for Log Messages */ gp2x_clear_screen(); game_index = -1; /* do we have a driver for this? */ for (i = 0; drivers[i] && (game_index == -1); i++) { if (strcasecmp(playgame,drivers[i]->name) == 0) { game_index = i; break; } } if (game_index == -1) { sprintf(text,"Game \"%s\" not supported\0",playgame); gp2x_text_log(text); while(1); /* MAME never ends xD */ } /* parse generic (os-independent) options */ parse_cmdline (argc, argv, &options, 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; } } sprintf(text,"Loading \"%s\"...",drivers[game_index]->description); gp2x_text_log(text); /* go for it */ filecache_init(); res = run_game (game_index , &options); #if !defined(GP2X) && defined(USE_FILECACHE) if ( res != 0) { gp2x_text_log("Retrying without filecache..."); filecache_disable(); res = run_game (game_index , &options); } #endif /* Error? */ if( res != 0 ) { #ifdef PSP gp2x_text_log("LOAD FAILED: Press [] button..."); #else gp2x_text_log("LOAD FAILED: Press A button..."); #endif while (!(gp2x_joystick_read()&GP2X_A)); while ((gp2x_joystick_read()&GP2X_A)); } #ifdef GP2X /* Zaq121 07/05/2006 Alternative frontend support -> */ if(no_selector) break; /* <- end mod */ #endif } /* MAME never ends xD */ }