void gp2x_init(int ticks_per_second, int bpp, int rate, int bits, int stereo, int Hz) { if (!lib_inited ) { gp2x_ticks_per_second=1000; //gp2x_screen15=screenbuffer; //gp2x_screen8=(unsigned char *)screenbuffer; gp2x_nflip=0; gp2x_set_video_mode(bpp,320,240); gp2x_video_color8(0,0,0,0); gp2x_video_color8(255,255,255,255); gp2x_video_setpalette(); /* atexit(gp2x_deinit); */ //app_DemuteSound(); pthread_mutex_init (&mut,NULL); lib_inited = 1; } }
void gp2x_init(int ticks_per_second, int bpp, int rate, int bits, int stereo, int Hz) { static pthread_t main_tid; if (!lib_inited ) { gp2x_ticks_per_second=1000; //gp2x_screen15=screenbuffer; //gp2x_screen8=(unsigned char *)screenbuffer; gp2x_screen15=screenbuffer; gp2x_screen8=(unsigned char *)screenbuffer; initVideo_callback((void *)&screenbuffer); gp2x_nflip=0; gp2x_set_video_mode(bpp,320,240); gp2x_video_color8(0,0,0,0); gp2x_video_color8(255,255,255,255); gp2x_video_setpalette(); /* atexit(gp2x_deinit); */ //app_DemuteSound(); //int i = pthread_create(&main_tid, NULL, threaded_sound_play, NULL); //if(i!=0)__android_log_print(ANDROID_LOG_ERROR, "mame4all-jni", "Error setting creating pthread %d",i); pthread_mutex_init (&mut,NULL); lib_inited = 1; } }
void execute_game (char *playemu, char *playgame) { char *args[255]; char str[8][64]; int n=0; int i=0; /* executable */ args[n]=playemu; n++; /* playgame */ args[n]=playgame; n++; /* args[n]="-depth"; n++; if(!safe_render_path) args[n]="8"; else args[n]="16"; n++; */ /* gp2x_video_depth */ if (m4all_video_depth==8) { args[n]="-depth"; n++; args[n]="8"; n++; } if (m4all_video_depth==16) { args[n]="-depth"; n++; args[n]="16"; n++; } /* iOS_video_aspect */ m4all_aspectRatio = m4all_cropVideo = m4all_fixedRes = 0; if (m4all_video_aspect==0) { m4all_aspectRatio = 1; }else if(m4all_video_aspect==1){ m4all_cropVideo = 1; }else if(m4all_video_aspect==2){ m4all_cropVideo = 2; }else if(m4all_video_aspect==3){ m4all_fixedRes = 1; //printf("fixed %d,%d,%d\n",iOS_aspectRatio,iOS_cropVideo,iOS_320x240); }else if(m4all_video_aspect==4){ m4all_fixedRes = 2; }else if(m4all_video_aspect==5){ m4all_fixedRes = 3; }else if(m4all_video_aspect==6){ m4all_fixedRes = 4; } /* iOS_video_rotate */ if ((m4all_video_rotate>=1) && (m4all_video_rotate<=2)) { args[n]="-ror"; n++; } if ((m4all_video_rotate>=2) && (m4all_video_rotate<=2)) { args[n]="-rotatecontrols"; n++; } /* iOS_video_sync */ if (m4all_video_sync==1) { args[n]="-nodirty"; n++; } else if (m4all_video_sync==-1) { args[n]="-nothrottle"; n++; } /* iOS_frameskip */ if (m4all_frameskip>=0) { args[n]="-frameskip"; n++; sprintf(str[i],"%d",m4all_frameskip); args[n]=str[i]; i++; n++; } /* iOS_sound */ if (m4all_sound==0) { args[n]="-soundcard"; n++; args[n]="0"; n++; } if ((m4all_sound==1) || (m4all_sound==5) || (m4all_sound==9)) { args[n]="-samplerate"; n++; args[n]="11025"; n++; } if ((m4all_sound==2) || (m4all_sound==6) || (m4all_sound==10)) { args[n]="-samplerate"; n++; args[n]="22050"; n++; } if ((m4all_sound==3) || (m4all_sound==7) || (m4all_sound==11)) { args[n]="-samplerate"; n++; args[n]="32000"; n++; } if ((m4all_sound==4) || (m4all_sound==8) || (m4all_sound==12)) { args[n]="-samplerate"; n++; args[n]="44100"; n++; } if ((m4all_sound>=1) && (m4all_sound<=4)) { args[n]="-fastsound"; n++; } if (m4all_sound>=9) { args[n]="-stereo"; n++; } /* iOS_clock_cpu */ if (m4all_clock_cpu!=100) { args[n]="-uclock"; n++; sprintf(str[i],"%d",100-m4all_clock_cpu); args[n]=str[i]; i++; n++; } /* iOS_clock_sound */ if (m4all_clock_cpu!=100) { args[n]="-uclocks"; n++; sprintf(str[i],"%d",100-m4all_clock_sound); args[n]=str[i]; i++; n++; } __android_log_print(ANDROID_LOG_DEBUG, "libMAME4all.so", "ASM CORES %d %d\n",m4all_ASMCores,m4all_cpu_cores); /* cpu_cores */ if(m4all_ASMCores) { if ((m4all_cpu_cores==1) || (m4all_cpu_cores==3) || (m4all_cpu_cores==5) || (m4all_cpu_cores==6)) { args[n]="-cyclone"; n++; } if ((m4all_cpu_cores==2) || (m4all_cpu_cores==3) || (m4all_cpu_cores==6)) { args[n]="-drz80"; n++; } if ((m4all_cpu_cores==4) || (m4all_cpu_cores==5) || (m4all_cpu_cores==6)) { args[n]="-drz80_snd"; n++; } } if (m4all_cheat) { args[n]="-cheat"; n++; } if (0) { args[n]="-romdir"; n++; sprintf(str[i],"%s",get_documents_path("roms")); args[n]=str[i]; i++; n++; } args[n]=NULL; for (i=0; i<n; i++) { printf("%s ",args[i]); __android_log_print(ANDROID_LOG_DEBUG, "libMAME4all.so", "arg: %s\n",args[i]); } printf("\n"); m4all_inGame = 1; m4all_exitGame=0; m4all_hide_LR = m4all_buttons!=6; m4all_BplusX = m4all_buttons==3; m4all_landscape_buttons = m4all_buttons <= 3 ? m4all_buttons : (m4all_buttons - 1) ; //gp2x_set_video_mode(16,320,240); my_android_main(n, args); if(m4all_HiSpecs) m4all_buttons=2; else m4all_buttons=2; m4all_hide_LR = 0; m4all_BplusX = 0; m4all_exitGame=0; m4all_inGame = 0; m4all_landscape_buttons = 2; emulated_width = 320; emulated_height = 240; gp2x_set_video_mode(16,320,240); }
void execute_game (char *playemu, char *playgame) { char *args[255]; char str[8][64]; int n=0; int i=0; /* executable */ args[n]=playemu; n++; /* playgame */ args[n]=playgame; n++; /* args[n]="-depth"; n++; if(!safe_render_path) args[n]="8"; else args[n]="16"; n++; */ /* gp2x_video_depth */ if (iOS_video_depth==8) { args[n]="-depth"; n++; args[n]="8"; n++; } if (iOS_video_depth==16) { args[n]="-depth"; n++; args[n]="16"; n++; } /* iOS_video_aspect */ iOS_aspectRatio = iOS_cropVideo = iOS_fixedRes = 0; if (iOS_video_aspect==0) { iOS_aspectRatio = 1; }else if(iOS_video_aspect==1){ iOS_cropVideo = 1; }else if(iOS_video_aspect==2){ iOS_cropVideo = 2; }else if(iOS_video_aspect==3){ iOS_fixedRes = 1; //printf("fixed %d,%d,%d\n",iOS_aspectRatio,iOS_cropVideo,iOS_320x240); }else if(iOS_video_aspect==4){ iOS_fixedRes = 2; }else if(iOS_video_aspect==5){ iOS_fixedRes = 3; }else if(iOS_video_aspect==6){ iOS_fixedRes = 4; } /* iOS_video_rotate */ if ((iOS_video_rotate>=1) && (iOS_video_rotate<=2)) { args[n]="-ror"; n++; } if ((iOS_video_rotate>=2) && (iOS_video_rotate<=2)) { args[n]="-rotatecontrols"; n++; } /* iOS_video_sync */ if (iOS_video_sync==1) { args[n]="-nodirty"; n++; } else if (iOS_video_sync==-1) { args[n]="-nothrottle"; n++; } /* iOS_frameskip */ if (iOS_frameskip>=0) { args[n]="-frameskip"; n++; sprintf(str[i],"%d",iOS_frameskip); args[n]=str[i]; i++; n++; } /* iOS_sound */ if (iOS_sound==0) { args[n]="-soundcard"; n++; args[n]="0"; n++; } if ((iOS_sound==1) || (iOS_sound==5) || (iOS_sound==9)) { args[n]="-samplerate"; n++; args[n]="11025"; n++; } if ((iOS_sound==2) || (iOS_sound==6) || (iOS_sound==10)) { args[n]="-samplerate"; n++; args[n]="22050"; n++; } if ((iOS_sound==3) || (iOS_sound==7) || (iOS_sound==11)) { args[n]="-samplerate"; n++; args[n]="32000"; n++; } if ((iOS_sound==4) || (iOS_sound==8) || (iOS_sound==12)) { args[n]="-samplerate"; n++; args[n]="44100"; n++; } if ((iOS_sound>=1) && (iOS_sound<=4)) { args[n]="-fastsound"; n++; } if (iOS_sound>=9) { args[n]="-stereo"; n++; } /* iOS_clock_cpu */ if (iOS_clock_cpu!=100) { args[n]="-uclock"; n++; sprintf(str[i],"%d",100-iOS_clock_cpu); args[n]=str[i]; i++; n++; } /* iOS_clock_sound */ if (iOS_clock_cpu!=100) { args[n]="-uclocks"; n++; sprintf(str[i],"%d",100-iOS_clock_sound); args[n]=str[i]; i++; n++; } if (iOS_cheat) { args[n]="-cheat"; n++; } if (0) { args[n]="-romdir"; n++; sprintf(str[i],"%s",get_documents_path("roms")); args[n]=str[i]; i++; n++; } args[n]=NULL; for (i=0; i<n; i++) { printf("%s ",args[i]); } printf("\n"); iOS_inGame = 1; iOS_exitGame=0; iOS_hide_LR = iOS_buttons!=6; iOS_BplusX = iOS_buttons==3; iOS_landscape_buttons = iOS_buttons <= 3 ? iOS_buttons : (iOS_buttons - 1) ; //gp2x_set_video_mode(16,320,240); iphone_main(n, args); if(isIpad) iOS_buttons=2; else iOS_buttons=2; iOS_hide_LR = 0; iOS_BplusX = 0; iOS_exitGame=0; iOS_inGame = 0; iOS_landscape_buttons = 2; emulated_width = 320; emulated_height = 240; gp2x_set_video_mode(16,320,240); }
/* set the actual display screen but don't allocate the screen bitmap */ int osd_set_display(int width,int height,int depth,int attributes,int orientation) { int i; if (!gfx_height || !gfx_width) { printf("Please specify height AND width (e.g. -640x480)\n"); return 0; } /* Mark the dirty buffers as dirty */ if (use_dirty) { if (vector_game) /* vector games only use one dirty buffer */ init_dirty (0); else init_dirty(1); swap_dirty(); init_dirty(1); } if (dirtycolor) { for (i = 0;i < screen_colors;i++) dirtycolor[i] = 1; dirtypalette = 1; } /* Set video mode */ gp2x_set_video_mode(depth,gfx_width,gfx_height); vsync_frame_rate = video_fps; if (video_sync) { TICKER a,b; float rate; /* wait some time to let everything stabilize */ for (i = 0;i < 60;i++) { vsync(); a = ticker(); } /* small delay for really really fast machines */ for (i = 0;i < 100000;i++) ; vsync(); b = ticker(); rate = ((float)TICKS_PER_SEC)/(b-a); logerror("target frame rate = %ffps, video frame rate = %3.2fHz\n",video_fps,rate); /* don't allow more than 8% difference between target and actual frame rate */ while (rate > video_fps * 108 / 100) rate /= 2; if (rate < video_fps * 92 / 100) { osd_close_display(); logerror("-vsync option cannot be used with this display mode:\n" "video refresh frequency = %dHz, target frame rate = %ffps\n", (int)(TICKS_PER_SEC/(b-a)),video_fps); return 0; } logerror("adjusted video frame rate = %3.2fHz\n",rate); vsync_frame_rate = rate; if (Machine->sample_rate) { Machine->sample_rate = Machine->sample_rate * video_fps / rate; logerror("sample rate adjusted to match video freq: %d\n",Machine->sample_rate); } } return 1; }
/* * This function tries to find the best display mode. */ static void select_display_mode(int width,int height,int depth,int attributes,int orientation) { /* 16 bit color is supported only by VESA modes */ if (depth == 16 || depth == 32) { logerror("Game needs %d-bit colors.\n",depth); } emulated_width = width; emulated_height = height; if (!gfx_width && !gfx_height)//no aspect ratio { gfx_width = width; gfx_height = height; } if(iOS_fixedRes == 1) { gfx_width = 320; gfx_height = 240; emulated_width = 320; emulated_height = 240; } else if(iOS_fixedRes == 2) { gfx_width = 240; gfx_height = 320; emulated_width = 240; emulated_height = 320; }else if(iOS_fixedRes == 3) { gfx_width = 640; gfx_height = 480; emulated_width = 640; emulated_height = 480; }else if(iOS_fixedRes == 4) { gfx_width = 480; gfx_height = 640; emulated_width = 480; emulated_height = 640; } if(iOS_cropVideo) { gfx_width = width; gfx_height = height; int rx = iOS_cropVideo == 1 ? 4 : 3; int ry = iOS_cropVideo == 1 ? 3 : 4; //double ratio = 4.0/3.0; //printf("%d %d \n",width,height); int new_width = //gfx_height * ratio; ((((gfx_height*rx)/ry)+7)&~7); if(new_width>gfx_width) { gfx_height = //gfx_width / ratio; ((((gfx_width*ry)/rx)+7)&~7); } else gfx_width = new_width; emulated_width = gfx_width; emulated_height = gfx_height; //printf("%d %d\n",gfx_width,gfx_height); } /* if(iOS_aspectRatio)//aspect ratio { gfx_width = width; gfx_height = height; //double ratio = 4.0/3.0;//isIpad ? 1024.0/768.0 :480.0/320.0; //printf("%d %d %f\n",width,height,ratio); int done = 0; iOS_43 = width > height; int rx = iOS_43 ? 4 : 3; int ry = iOS_43 ? 3 : 4; // Try adjusting width to be proportional to height int newWidth = //(int) (ratio * gfx_height); ((((gfx_height*rx)/ry)+7)&~7); if (newWidth >= gfx_width) { gfx_width = newWidth; done = 1; } // Try adjusting height to be proportional to width if (!done) { int newHeight = //(int) (gfx_width / ratio); ((((gfx_width*ry)/rx)+7)&~7); if (newHeight >= gfx_height) { gfx_height = newHeight; } } //printf("%d %d\n",gfx_width,gfx_height); } */ /* Video hardware scaling */ if (video_scale) { gfx_width=width; gfx_height=height; } /* vector games use 640x480 as default */ if (vector_game && !iOS_fixedRes) { if(safe_render_path) { gfx_width = 640; gfx_height = 480; emulated_width = 640; emulated_height = 480; } else { gfx_width = 320; gfx_height = 240; emulated_width = 320; emulated_height = 240; } } gp2x_set_video_mode(16,gfx_width,gfx_height); }
void gp2x_frontend_init(void) { gp2x_set_video_mode( NULL, 16, 640, 480 ); }