diff options
Diffstat (limited to 'apps/plugins/rockboy/emu.c')
-rw-r--r-- | apps/plugins/rockboy/emu.c | 146 |
1 files changed, 57 insertions, 89 deletions
diff --git a/apps/plugins/rockboy/emu.c b/apps/plugins/rockboy/emu.c index b398bf497e..f639a62772 100644 --- a/apps/plugins/rockboy/emu.c +++ b/apps/plugins/rockboy/emu.c @@ -1,6 +1,3 @@ - - - #include "rockmacros.h" #include "defs.h" #include "regs.h" @@ -17,23 +14,15 @@ static int framecount; rcvar_t emu_exports[] = { - RCV_INT("framelen", &framelen), - RCV_INT("framecount", &framecount), - RCV_END + RCV_INT("framelen", &framelen), + RCV_INT("framecount", &framecount), + RCV_END }; - - - - - - void emu_init(void) { - } - /* * emu_reset is called to initialize the state of the emulated * system. It should set cpu registers, hardware registers, etc. to @@ -42,100 +31,79 @@ void emu_init(void) void emu_reset(void) { - hw_reset(); - lcd_reset(); - cpu_reset(); - mbc_reset(); - sound_reset(); + hw_reset(); + lcd_reset(); + cpu_reset(); + mbc_reset(); + sound_reset(); } - - - - void emu_step(void) { - cpu_emulate(cpu.lcdc); + cpu_emulate(cpu.lcdc); } -struct options options; - /* This mess needs to be moved to another module; it's just here to * make things work in the mean time. */ -//extern struct plugin_api* rb; void emu_run(void) { // void *timer = sys_timer(); - int framesin=0,frames=0,timeten=*rb->current_tick, timehun=*rb->current_tick; + int framesin=0,frames=0,timeten=*rb->current_tick, timehun=*rb->current_tick; // int delay; - vid_begin(); - lcd_begin(); + vid_begin(); + lcd_begin(); #ifdef HAVE_ADJUSTABLE_CPU_FREQ - rb->cpu_boost(true); + rb->cpu_boost(true); #endif - while(!shut) - { - cpu_emulate(2280); - while (R_LY > 0 && R_LY < 144) - emu_step(); - - rtc_tick(); - sound_mix(); - if (!pcm_submit()) - { -/* delay = framelen - sys_elapsed(timer); - sys_sleep(delay); - sys_elapsed(timer);*/ - } - - doevents(); - vid_begin(); + while(!shut) + { + cpu_emulate(2280); + while (R_LY > 0 && R_LY < 144) + emu_step(); + + rtc_tick(); + sound_mix(); + if (!pcm_submit()) + { +/* delay = framelen - sys_elapsed(timer); + sys_sleep(delay); + sys_elapsed(timer);*/ + } + + doevents(); + vid_begin(); - if (!(R_LCDC & 0x80)) - cpu_emulate(32832); + if (!(R_LCDC & 0x80)) + cpu_emulate(32832); - while (R_LY > 0) /* wait for next frame */ - emu_step(); - rb->yield(); - - frames++; - framesin++; - - if(*rb->current_tick-timeten>=20) - { - timeten=*rb->current_tick; - if(framesin<12) options.frameskip++; - if(framesin>12) options.frameskip--; - if(options.frameskip>options.maxskip) options.frameskip=options.maxskip; - if(options.frameskip<0) options.frameskip=0; - framesin=0; - } - - if(options.showstats) - { - if(*rb->current_tick-timehun>=100) { - options.fps=frames; - frames=0; - timehun=*rb->current_tick; - } - } - - } + while (R_LY > 0) /* wait for next frame */ + emu_step(); + rb->yield(); + + frames++; + framesin++; + + if(*rb->current_tick-timeten>=20) + { + timeten=*rb->current_tick; + if(framesin<12) options.frameskip++; + if(framesin>12) options.frameskip--; + if(options.frameskip>options.maxskip) options.frameskip=options.maxskip; + if(options.frameskip<0) options.frameskip=0; + framesin=0; + } + + if(options.showstats) + if(*rb->current_tick-timehun>=100) + { + options.fps=frames; + frames=0; + timehun=*rb->current_tick; + } + } #ifdef HAVE_ADJUSTABLE_CPU_FREQ rb->cpu_boost(false); #endif } - - - - - - - - - - - - |