void flush_block (int ystart, int ystop) { uae4all_prof_start(13); #ifdef DEBUG_GFX dbgf("Function: flush_block %d %d\n", ystart, ystop); #endif //__android_log_print(ANDROID_LOG_INFO, "libSDL", "ystart: %d ystop: %d", ystart, ystop); #ifndef DREAMCAST SDL_UnlockSurface (prSDLScreen); #endif #if defined (GP2X) || defined (PSP) || defined (GIZMONDO) if (vkbd_mode) { vkbd_key=vkbd_process(); } if (show_inputmode) { inputmode_redraw(); } #ifdef GP2X else if (show_volumecontrol) { volumecontrol_redraw(); } #endif #endif #if !defined (DOUBLEBUFFER) SDL_UpdateRect(prSDLScreen, 0, ystart, current_width, ystop-ystart+1); #endif if (drawfinished) { drawfinished=0; #if !defined (GP2X) && !defined (PSP) && !defined (GIZMONDO) if (vkbd_mode) vkbd_key=vkbd_process(); #endif #ifdef DOUBLEBUFFER SDL_Flip(prSDLScreen); #endif } #ifndef DREAMCAST SDL_LockSurface (prSDLScreen); #endif uae4all_prof_end(13); }
void flush_screen (void) #endif { uae4all_prof_start(13); #if defined(USE_RASTER_DRAW) && defined(DEBUG_GFX) dbgf("Function: flush_block %d %d\n", ystart, ystop); #endif #ifdef SCALING unsigned x,y,n,m; unsigned short *gfx_mem_p, *gfx_mem_line; unsigned short *surface_p, *surface_line; unsigned width_px = (prSDLScreen->pitch) / (prSDLScreen->format->BytesPerPixel); #endif #ifndef DINGOO #ifndef DREAMCAST if (SDL_MUSTLOCK(prSDLScreen)) SDL_UnlockSurface (prSDLScreen); #endif #ifdef SCALING #if !defined(DREAMCAST) && !defined(DINGOO) if (SDL_MUSTLOCK(prSDLScreen)) SDL_LockSurface(prSDLScreen); #endif surface_line = (uae_u16 *)prSDLScreen->pixels; gfx_mem_p = (uae_u16 *)gfx_mem; for(y = 0; y < current_height; y++) { gfx_mem_line = gfx_mem_p; for(n = 0; n < uae4all_scalefactor; n++) { gfx_mem_p = gfx_mem_line; surface_p = surface_line; surface_line += width_px; for(x = 0; x < current_width; x++) { for(m = 0; m < uae4all_scalefactor; m++) { *surface_p = *gfx_mem_p; surface_p++; } gfx_mem_p++; } } } #if !defined(DREAMCAST) && !defined(DINGOO) if (SDL_MUSTLOCK(prSDLScreen)) SDL_UnlockSurface(prSDLScreen); #endif #endif #ifndef DOUBLEBUFFER #ifdef USE_RASTER_DRAW SDL_UpdateRect(prSDLScreen, 0, ystart, current_width, ystop-ystart+1); #else #ifdef SCALING SDL_UpdateRect(prSDLScreen, 0, 0, uae4all_scalefactor*320, uae4all_scalefactor*240); #else SDL_UpdateRect(prSDLScreen, 0, 0, 320, 240); #endif #endif #endif #endif #ifdef USE_RASTER_DRAW if (drawfinished) { drawfinished=0; #endif if (show_message) { show_message--; if (!show_message) { notice_screen_contents_lost(); } else { _write_text_inv_n(prSDLScreen,0,29,30,show_message_str); } } if (emulated_mouse) vkbd_mouse(); if (vkbd_mode) vkbd_key=vkbd_process(); #if defined(DOUBLEBUFFER) || defined(DINGOO) SDL_Flip(prSDLScreen); #endif #ifdef USE_RASTER_DRAW } #endif #if !defined(DREAMCAST) && !defined(DINGOO) if (SDL_MUSTLOCK(prSDLScreen)) SDL_LockSurface (prSDLScreen); #endif uae4all_prof_end(13); }
void update_audio (void) { unsigned long int n_cycles; uae4all_prof_start(4); n_cycles = get_cycles () - last_cycles; for (;;) { #ifdef __arm__ asm(".align 4"); #endif register unsigned long int best_evtime = n_cycles + 1; //int addr = (int)audio_channel_evtime; //AUDIO_PREFETCH(addr); // CHECK_STATE if (best_evtime > audio_channel_evtime[0]) best_evtime = audio_channel_evtime[0]; if (best_evtime > audio_channel_evtime[1]) best_evtime = audio_channel_evtime[1]; if (best_evtime > audio_channel_evtime[2]) best_evtime = audio_channel_evtime[2]; if (best_evtime > audio_channel_evtime[3]) best_evtime = audio_channel_evtime[3]; if (best_evtime > next_sample_evtime) best_evtime = next_sample_evtime; if (best_evtime > n_cycles) break; // SUB_EVTIME next_sample_evtime -= best_evtime; audio_channel_evtime[0] -= best_evtime; audio_channel_evtime[1] -= best_evtime; audio_channel_evtime[2] -= best_evtime; audio_channel_evtime[3] -= best_evtime; n_cycles -= best_evtime; /* addr = (int)&audio_channel_current_sample; AUDIO_PREFETCH(addr); addr = (int)&audio_channel_vol; AUDIO_PREFETCH(addr); addr = (int)&audio_channel_adk_mask; AUDIO_PREFETCH(addr); */ // IF_SAMPLE if (!next_sample_evtime) { next_sample_evtime = scaled_sample_evtime; register uae_u32 d0 = audio_channel_current_sample[0]; register uae_u32 d1 = audio_channel_current_sample[1]; register uae_u32 d2 = audio_channel_current_sample[2]; register uae_u32 d3 = audio_channel_current_sample[3]; d0 *= audio_channel_vol[0]; d1 *= audio_channel_vol[1]; d2 *= audio_channel_vol[2]; d3 *= audio_channel_vol[3]; d0 &= audio_channel_adk_mask[0]; d1 &= audio_channel_adk_mask[1]; d2 &= audio_channel_adk_mask[2]; d3 &= audio_channel_adk_mask[3]; *(uae_u16 *)sndbufpt = d0+d1+d2+d3; sndbufpt = (uae_u16 *)(((uae_u8 *)sndbufpt) + 2); if ((unsigned)sndbufpt - (unsigned)render_sndbuff >= SNDBUFFER_LEN) { finish_sound_buffer (); } } // RUN_HANDLERS for (int i=0; i < 4; i++) { if (!audio_channel_evtime[i]) audio_handler(i); } /* if (!audio_channel_evtime[0]) audio_handler_0(); if (!audio_channel_evtime[1]) audio_handler_1(); if (!audio_channel_evtime[2]) audio_handler_2(); if (!audio_channel_evtime[3]) audio_handler_3(); */ } last_cycles = get_cycles () - n_cycles; uae4all_prof_end(4); }
static void m68k_run (void) { uae4all_reset (); unsigned cycles, cycles_actual=M68KCONTEXT.cycles_counter; for (;;) { #ifdef DEBUG_M68K dbg_cycle(m68k_fetch(m68k_get_pc(),0)); m68k_emulate(1); #else uae4all_prof_start(0); cycles = nextevent - currcycle; switch (timeslice_mode) { case 3: cycles>>=6; break; case 2: cycles>>=7; break; case 1: cycles=(cycles>>8)+(cycles>>9); break; default: cycles>>=8; break; } #define NDEBUG_CYCLES #ifdef DEBUG_CYCLES static unsigned next_cycles = 60000000; if (M68KCONTEXT.cycles_counter > next_cycles) { next_cycles += 100000; printf("cycles=%9d|%03i|%03i, pc=%.6x\n", M68KCONTEXT.cycles_counter, cycles, IO_CYCLE, _68k_getpc()); } if (M68KCONTEXT.cycles_counter > 80000000) { // exit(0); } if (M68KCONTEXT.cycles_counter >= 500000000) { // do_debug = 1; } #endif #if defined(FAME_INTERRUPTS_SECURE_PATCH) && defined(FAME_INTERRUPTS_PATCH) if (uae4all_go_interrupt) m68k_emulate(FAME_INTERRUPTS_PATCH); else #endif m68k_emulate(cycles); uae4all_prof_end(0); #endif #if 0 // def FAME_INTERRUPTS_PATCH if (uae4all_go_interrupt) { /*if (verb)*/ printf("uae4all_go_interrupt: %02x\n", uae4all_go_interrupt); M68KCONTEXT.interrupts[0]=uae4all_go_interrupt; M68KCONTEXT.execinfo&=0xFF67; uae4all_go_interrupt=0; m68k_irq_update(0); } #endif uae4all_prof_start(1); cycles=(M68KCONTEXT.cycles_counter-cycles_actual) * cycles_factor; #ifdef DEBUG_INTERRUPTS dbgf("cycles=%i (%i) -> PC=%.6x\n",cycles>>8,nextevent - currcycle, _68k_getpc()); #endif #ifdef NO_SHORT_EVENTS #ifdef PROTECT_INFINITE unsigned cuentalo=0; #endif do { #endif do_cycles(cycles); if (mispcflags) if (do_specialties (cycles)) return; #ifndef DEBUG_M68K #ifdef NO_SHORT_EVENTS cycles=2048; #ifdef PROTECT_INFINITE cuentalo++; if (cuentalo>1024) { g_emulator.quit_program=RunStateReset; return; } #endif } while((nextevent - currcycle)<=2048); #endif cycles_actual=M68KCONTEXT.cycles_counter; #endif uae4all_prof_end(1); } }
static void m68k_run (void) { uae4all_reset (); unsigned cycles, cycles_actual=M68KCONTEXT.cycles_counter; for (;;) { while (pause_program > 0) { usleep(200000); } #ifdef DEBUG_M68K dbg_cycle(m68k_fetch(m68k_get_pc(),0)); m68k_emulate(1); #else uae4all_prof_start(0); cycles = nextevent - currcycle; switch (timeslice_mode) { case 3: cycles>>=6; break; case 2: cycles>>=7; break; case 1: cycles=(cycles>>8)+(cycles>>9); break; default: cycles>>=8; break; } #ifdef DEBUG_TIMESLICE unsigned ts=cycles; #endif #if defined(FAME_INTERRUPTS_SECURE_PATCH) && defined(FAME_INTERRUPTS_PATCH) if (uae4all_go_interrupt) m68k_emulate(FAME_INTERRUPTS_PATCH); else #endif m68k_emulate(cycles); uae4all_prof_end(0); #endif #if 0 // def FAME_INTERRUPTS_PATCH if (uae4all_go_interrupt) { /*if (verb)*/ printf("uae4all_go_interrupt: %02x\n", uae4all_go_interrupt); M68KCONTEXT.interrupts[0]=uae4all_go_interrupt; M68KCONTEXT.execinfo&=0xFF67; uae4all_go_interrupt=0; m68k_irq_update(0); } #endif #ifdef DEBUG_M68K if (M68KCONTEXT.execinfo & 0x0080) mispcflags|=SPCFLAG_STOP; #endif uae4all_prof_start(1); //cycles=((unsigned)(((double)(M68KCONTEXT.cycles_counter-cycles_actual))*cycles_factor))<<8; cycles=(M68KCONTEXT.cycles_counter-cycles_actual) * cycles_factor; #ifdef DEBUG_INTERRUPTS dbgf("cycles=%i (%i) -> PC=%.6x\n",cycles>>8,nextevent - currcycle, _68k_getpc()); #endif #ifdef NO_SHORT_EVENTS #ifdef PROTECT_INFINITE unsigned cuentalo=0; #endif do{ #endif do_cycles(cycles); if (mispcflags) if (do_specialties (cycles)) return; #ifndef DEBUG_M68K #ifdef NO_SHORT_EVENTS cycles=2048; #ifdef PROTECT_INFINITE cuentalo++; if (cuentalo>1024) { quit_program=2; return; } #endif }while((nextevent - currcycle)<=2048); #endif cycles_actual=M68KCONTEXT.cycles_counter; #endif uae4all_prof_end(1); } }