GPGX_EX void gpgx_advance(void) { if (system_hw == SYSTEM_MCD) system_frame_scd(0); else if ((system_hw & SYSTEM_PBC) == SYSTEM_MD) system_frame_gen(0); else system_frame_sms(0); if (bitmap.viewport.changed & 1) { bitmap.viewport.changed &= ~1; update_viewport(); } nsamples = audio_update(soundbuffer); }
static void run_emulation(void) { int sync; /* main emulation loop */ while (1) { /* emulated system */ if (system_hw == SYSTEM_MCD) { /* 16-bit hardware + CD */ while (!ConfigRequested) { /* render frame */ system_frame_scd(0); /* audio/video sync */ sync = NO_SYNC; while (sync != (SYNC_VIDEO | SYNC_AUDIO)) { /* update video */ sync |= gx_video_Update(); /* update audio */ sync |= gx_audio_Update(); } /* check interlaced mode change */ if (bitmap.viewport.changed & 4) { /* VSYNC "original" mode */ if (!config.render && config.vsync && (gc_pal == vdp_pal)) { /* framerate has changed, reinitialize audio timings */ audio_init(SAMPLERATE_48KHZ, get_framerate()); } /* clear flag */ bitmap.viewport.changed &= ~4; } } } else if ((system_hw & SYSTEM_PBC) == SYSTEM_MD) { /* 16-bit hardware */ while (!ConfigRequested) { /* render frame */ system_frame_gen(0); /* audio/video sync */ sync = NO_SYNC; while (sync != (SYNC_VIDEO | SYNC_AUDIO)) { /* update video */ sync |= gx_video_Update(); /* update audio */ sync |= gx_audio_Update(); } /* check interlaced mode change */ if (bitmap.viewport.changed & 4) { /* VSYNC "original" mode */ if (!config.render && config.vsync && (gc_pal == vdp_pal)) { /* framerate has changed, reinitialize audio timings */ audio_init(SAMPLERATE_48KHZ, get_framerate()); } /* clear flag */ bitmap.viewport.changed &= ~4; } } } else { /* 8-bit hardware */ while (!ConfigRequested) { /* render frame */ system_frame_sms(0); /* audio/video sync */ sync = NO_SYNC; while (sync != (SYNC_VIDEO | SYNC_AUDIO)) { /* update video */ sync |= gx_video_Update(); /* update audio */ sync |= gx_audio_Update(); } /* check interlaced mode change (PBC mode only) */ if (bitmap.viewport.changed & 4) { /* "original" mode */ if (!config.render && config.vsync && (gc_pal == vdp_pal)) { /* framerate has changed, reinitialize audio timings */ audio_init(SAMPLERATE_48KHZ, get_framerate()); } /* clear flag */ bitmap.viewport.changed &= ~4; } } } /* stop video & audio */ gx_audio_Stop(); gx_video_Stop(); #ifdef LOG_TIMING if (system_hw) { FILE *f; char filename[64]; memset(filename, 0, 64); strcpy(filename,"timings-"); if (!config.vsync || (config.tv_mode == !vdp_pal)) { strcat(filename,"no_"); } else { if (gc_pal) { strcat(filename,"50hz_"); } else { strcat(filename,"60hz_"); } } strcat(filename,"vsync-"); if (vdp_pal) { strcat(filename,"pal-"); } else { strcat(filename,"ntsc-"); } if (config.render == 2) { strcat(filename,"prog.txt"); } else { if (!config.render && !interlaced) { strcat(filename,"no_"); } strcat(filename,"int.txt"); } f = fopen(filename,"a"); if (f != NULL) { int i; u32 min,max; double total = 0; double nsamples = 0; if (delta_time[LOGSIZE - 1] != 0) { frame_cnt = LOGSIZE; } min = max = delta_time[0]; for (i=0; i<frame_cnt; i++) { fprintf(f,"%d ns - %d samples (%5.8f samples/sec)\n", delta_time[i], delta_samp[i], 1000000000.0*(double)delta_samp[i]/(double)delta_time[i]/4.0); total += delta_time[i]; nsamples += delta_samp[i] / 4.0; if (min > delta_time[i]) min = delta_time[i]; if (max < delta_time[i]) max = delta_time[i]; } fprintf(f,"\n"); fprintf(f,"min = %d ns\n", min); fprintf(f,"max = %d ns\n", max); fprintf(f,"avg = %8.5f ns (%5.8f samples/sec, %5.8f samples/frame)\n\n\n", total/(double)i, nsamples/total*1000000000.0, nsamples/(double)i); fclose(f); } } memset(delta_time,0,LOGSIZE); memset(delta_samp,0,LOGSIZE); frame_cnt = prevtime = 0; #endif /* show menu */ ConfigRequested = 0; mainmenu(); /* restart video & audio */ gx_video_Start(); gx_audio_Start(); } }