summaryrefslogtreecommitdiff
path: root/apps/plugins/rockboy/emu.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/rockboy/emu.c')
-rw-r--r--apps/plugins/rockboy/emu.c41
1 files changed, 32 insertions, 9 deletions
diff --git a/apps/plugins/rockboy/emu.c b/apps/plugins/rockboy/emu.c
index cf37d9b2b8..2af4e52d09 100644
--- a/apps/plugins/rockboy/emu.c
+++ b/apps/plugins/rockboy/emu.c
@@ -58,15 +58,16 @@ void emu_step(void)
58 cpu_emulate(cpu.lcdc); 58 cpu_emulate(cpu.lcdc);
59} 59}
60 60
61 61struct options options;
62 62
63/* This mess needs to be moved to another module; it's just here to 63/* This mess needs to be moved to another module; it's just here to
64 * make things work in the mean time. */ 64 * make things work in the mean time. */
65 65//extern struct plugin_api* rb;
66void emu_run(void) 66void emu_run(void)
67{ 67{
68 void *timer = sys_timer(); 68// void *timer = sys_timer();
69 int delay; 69 int framesin=0,frames=0,timeten=*rb->current_tick, timehun=*rb->current_tick;
70// int delay;
70 71
71 vid_begin(); 72 vid_begin();
72 lcd_begin(); 73 lcd_begin();
@@ -79,18 +80,17 @@ void emu_run(void)
79 while (R_LY > 0 && R_LY < 144) 80 while (R_LY > 0 && R_LY < 144)
80 emu_step(); 81 emu_step();
81 82
82 vid_end();
83 rtc_tick(); 83 rtc_tick();
84 sound_mix(); 84 sound_mix();
85 if (!pcm_submit()) 85 if (!pcm_submit())
86 { 86 {
87 delay = framelen - sys_elapsed(timer); 87/* delay = framelen - sys_elapsed(timer);
88 sys_sleep(delay); 88 sys_sleep(delay);
89 sys_elapsed(timer); 89 sys_elapsed(timer);*/
90 } 90 }
91
91 doevents(); 92 doevents();
92 vid_begin(); 93 vid_begin();
93// if (framecount) { if (!--framecount) die("finished\n"); }
94 94
95 if (!(R_LCDC & 0x80)) 95 if (!(R_LCDC & 0x80))
96 cpu_emulate(32832); 96 cpu_emulate(32832);
@@ -98,11 +98,34 @@ void emu_run(void)
98 while (R_LY > 0) /* wait for next frame */ 98 while (R_LY > 0) /* wait for next frame */
99 emu_step(); 99 emu_step();
100 rb->yield(); 100 rb->yield();
101
102 frames++;
103 framesin++;
104
105 if(*rb->current_tick-timeten>=20)
106 {
107 timeten=*rb->current_tick;
108 if(framesin<12) options.frameskip++;
109 if(framesin>12) options.frameskip--;
110 if(options.frameskip>options.maxskip) options.frameskip=options.maxskip;
111 if(options.frameskip<0) options.frameskip=0;
112 framesin=0;
101 } 113 }
114
115 if(options.showstats)
116 {
117 if(*rb->current_tick-timehun>=100) {
118 options.fps=frames;
119 frames=0;
120 timehun=*rb->current_tick;
121 }
122 }
123
124 }
125
102#if !defined(SIMULATOR) && defined(HAVE_ADJUSTABLE_CPU_FREQ) 126#if !defined(SIMULATOR) && defined(HAVE_ADJUSTABLE_CPU_FREQ)
103 rb->cpu_boost(false); 127 rb->cpu_boost(false);
104#endif 128#endif
105
106} 129}
107 130
108 131