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.c117
1 files changed, 117 insertions, 0 deletions
diff --git a/apps/plugins/rockboy/emu.c b/apps/plugins/rockboy/emu.c
new file mode 100644
index 0000000000..b6f2de779a
--- /dev/null
+++ b/apps/plugins/rockboy/emu.c
@@ -0,0 +1,117 @@
1
2
3
4#include "rockmacros.h"
5#include "defs.h"
6#include "regs.h"
7#include "hw.h"
8#include "cpu.h"
9#include "mem.h"
10#include "lcd.h"
11#include "rc.h"
12#include "sound.h"
13#include "rtc.h"
14
15static int framelen = 16743;
16static int framecount;
17
18rcvar_t emu_exports[] =
19{
20 RCV_INT("framelen", &framelen),
21 RCV_INT("framecount", &framecount),
22 RCV_END
23};
24
25
26
27
28
29
30
31void emu_init(void)
32{
33
34}
35
36
37/*
38 * emu_reset is called to initialize the state of the emulated
39 * system. It should set cpu registers, hardware registers, etc. to
40 * their appropriate values at powerup time.
41 */
42
43void emu_reset(void)
44{
45 hw_reset();
46 lcd_reset();
47 cpu_reset();
48 mbc_reset();
49 sound_reset();
50}
51
52
53
54
55
56void emu_step(void)
57{
58 cpu_emulate(cpu.lcdc);
59}
60
61
62
63/* This mess needs to be moved to another module; it's just here to
64 * make things work in the mean time. */
65
66void emu_run(void)
67{
68 void *timer = sys_timer();
69 char meow[500];
70 int delay;
71 int framecount=0;
72
73 vid_begin();
74 lcd_begin();
75 while(shut==0)
76 {
77 cpu_emulate(2280);
78 while (R_LY > 0 && R_LY < 144)
79 emu_step();
80
81 vid_end();
82 rtc_tick();
83 sound_mix();
84 if (!pcm_submit())
85 {
86 delay = framelen - sys_elapsed(timer);
87 sys_sleep(delay);
88 sys_elapsed(timer);
89 }
90 doevents();
91 vid_begin();
92// if (framecount) { if (!--framecount) die("finished\n"); }
93
94 if (!(R_LCDC & 0x80))
95 cpu_emulate(32832);
96
97 while (R_LY > 0) /* wait for next frame */
98 emu_step();
99 framecount++;
100 snprintf(meow,499,"%d",framecount);
101 rb->lcd_putsxy(0,0,meow);
102 rb->lcd_update_rect(0,0,LCD_WIDTH,8);
103 rb->yield();
104 }
105}
106
107
108
109
110
111
112
113
114
115
116
117