diff options
author | Daniel Stenberg <daniel@haxx.se> | 2006-01-20 13:05:52 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2006-01-20 13:05:52 +0000 |
commit | 137fb6cb9f0478303610443b95ae0a106f0a17d1 (patch) | |
tree | 9ac6685589536bc7c84962db8398fddf9d2b3154 | |
parent | c05cd1676f323f1346099f436aaa0212fd18e178 (diff) | |
download | rockbox-137fb6cb9f0478303610443b95ae0a106f0a17d1.tar.gz rockbox-137fb6cb9f0478303610443b95ae0a106f0a17d1.zip |
Karl Kurbjun's patch #1407719:
Here's another patch for rockboy that adds automatic frameskip (it's pretty
rough as I haven't figured out an accurate timer), fullscreen support on the
H300, and a bit of assembly and some IRAM stuff. I'm not sure if I'm doing the
IRAM stuff correct though as it doesn't seem to make much of a difference if
any. I've also added a statistics option that will show how many frames per
second the gameboy is seeing (not what the player is getting) and what the
frameskip is at. When you enable stats sometimes you have to go back into the
menu and then come out to clear erronous values.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8397 a1c6a512-1295-4272-9138-f99709370657
27 files changed, 490 insertions, 213 deletions
diff --git a/apps/plugins/rockboy/Makefile b/apps/plugins/rockboy/Makefile index f0dbc55857..d9d310702f 100644 --- a/apps/plugins/rockboy/Makefile +++ b/apps/plugins/rockboy/Makefile | |||
@@ -9,8 +9,8 @@ | |||
9 | 9 | ||
10 | INCLUDES = -I$(APPSDIR) -I.. -I. -I$(FIRMDIR)/include -I$(FIRMDIR)/export \ | 10 | INCLUDES = -I$(APPSDIR) -I.. -I. -I$(FIRMDIR)/include -I$(FIRMDIR)/export \ |
11 | -I$(FIRMDIR)/common -I$(FIRMDIR)/drivers -I$(OUTDIR) -I$(BUILDDIR) | 11 | -I$(FIRMDIR)/common -I$(FIRMDIR)/drivers -I$(OUTDIR) -I$(BUILDDIR) |
12 | CFLAGS = $(GCCOPTS) -O3 $(INCLUDES) $(TARGET) $(EXTRA_DEFINES) \ | 12 | CFLAGS = $(GCCOPTS) -O2 $(INCLUDES) $(TARGET) $(EXTRA_DEFINES) \ |
13 | -DTARGET_ID=$(TARGET_ID) -DMEM=${MEMORYSIZE} -DPLUGIN | 13 | -DTARGET_ID=$(TARGET_ID) -DMEM=${MEMORYSIZE} -DPLUGIN -finline-functions |
14 | 14 | ||
15 | ifdef APPEXTRA | 15 | ifdef APPEXTRA |
16 | INCLUDES += $(patsubst %,-I$(APPSDIR)/%,$(subst :, ,$(APPEXTRA))) | 16 | INCLUDES += $(patsubst %,-I$(APPSDIR)/%,$(subst :, ,$(APPEXTRA))) |
@@ -48,7 +48,7 @@ all: $(OUTPUT) | |||
48 | ifndef SIMVER | 48 | ifndef SIMVER |
49 | $(OBJDIR)/rockboy.elf: $(OBJS) $(LINKFILE) | 49 | $(OBJDIR)/rockboy.elf: $(OBJS) $(LINKFILE) |
50 | @echo "LD "`basename $@` | 50 | @echo "LD "`basename $@` |
51 | @$(CC) $(GCCOPTS) -O -nostdlib -o $@ $(OBJS) -L$(BUILDDIR) -lplugin -lgcc \ | 51 | @$(CC) $(GCCOPTS) -O2 -nostdlib -o $@ $(OBJS) -L$(BUILDDIR) -lplugin -fast -lgcc \ |
52 | -T$(LINKFILE) -Wl,-Map,$(OBJDIR)/rockboy.map | 52 | -T$(LINKFILE) -Wl,-Map,$(OBJDIR)/rockboy.map |
53 | 53 | ||
54 | $(OUTPUT): $(OBJDIR)/rockboy.elf | 54 | $(OUTPUT): $(OBJDIR)/rockboy.elf |
diff --git a/apps/plugins/rockboy/cpu-gb.h b/apps/plugins/rockboy/cpu-gb.h index 937b477b53..dfb8734823 100644 --- a/apps/plugins/rockboy/cpu-gb.h +++ b/apps/plugins/rockboy/cpu-gb.h | |||
@@ -48,12 +48,12 @@ extern int blockclen; | |||
48 | #endif | 48 | #endif |
49 | 49 | ||
50 | void cpu_reset(void); | 50 | void cpu_reset(void); |
51 | void div_advance(int cnt); | 51 | void div_advance(int cnt) ICODE_ATTR; |
52 | void timer_advance(int cnt); | 52 | void timer_advance(int cnt) ICODE_ATTR; |
53 | void lcdc_advance(int cnt); | 53 | void lcdc_advance(int cnt) ICODE_ATTR; |
54 | void sound_advance(int cnt); | 54 | void sound_advance(int cnt) ICODE_ATTR; |
55 | void cpu_timers(int cnt); | 55 | void cpu_timers(int cnt) ICODE_ATTR; |
56 | int cpu_emulate(int cycles) ICODE_ATTR; | 56 | int cpu_emulate(int cycles) ICODE_ATTR; |
57 | int cpu_step(int max) ICODE_ATTR; | 57 | inline int cpu_step(int max); |
58 | 58 | ||
59 | #endif | 59 | #endif |
diff --git a/apps/plugins/rockboy/cpu.c b/apps/plugins/rockboy/cpu.c index 5c4abc519f..a09beafab6 100644 --- a/apps/plugins/rockboy/cpu.c +++ b/apps/plugins/rockboy/cpu.c | |||
@@ -1006,9 +1006,9 @@ next: | |||
1006 | 1006 | ||
1007 | #ifndef ASM_CPU_STEP | 1007 | #ifndef ASM_CPU_STEP |
1008 | 1008 | ||
1009 | int cpu_step(int max) | 1009 | inline int cpu_step(int max) |
1010 | { | 1010 | { |
1011 | int cnt; | 1011 | register int cnt; |
1012 | if ((cnt = cpu_idle(max))) return cnt; | 1012 | if ((cnt = cpu_idle(max))) return cnt; |
1013 | return cpu_emulate(1); | 1013 | return cpu_emulate(1); |
1014 | } | 1014 | } |
diff --git a/apps/plugins/rockboy/cpucore.h b/apps/plugins/rockboy/cpucore.h index 361c106dab..a0c6a12f63 100644 --- a/apps/plugins/rockboy/cpucore.h +++ b/apps/plugins/rockboy/cpucore.h | |||
@@ -2,7 +2,7 @@ | |||
2 | #include "defs.h" | 2 | #include "defs.h" |
3 | 3 | ||
4 | 4 | ||
5 | static const byte cycles_table[256] = | 5 | static const byte cycles_table[256]ICONST_ATTR = |
6 | { | 6 | { |
7 | 1, 3, 2, 2, 1, 1, 2, 1, 5, 2, 2, 2, 1, 1, 2, 1, | 7 | 1, 3, 2, 2, 1, 1, 2, 1, 5, 2, 2, 2, 1, 1, 2, 1, |
8 | 1, 3, 2, 2, 1, 1, 2, 1, 3, 2, 2, 2, 1, 1, 2, 1, | 8 | 1, 3, 2, 2, 1, 1, 2, 1, 3, 2, 2, 2, 1, 1, 2, 1, |
@@ -25,7 +25,7 @@ static const byte cycles_table[256] = | |||
25 | 3, 3, 2, 1, 0, 4, 2, 4, 3, 2, 4, 1, 0, 0, 2, 4, | 25 | 3, 3, 2, 1, 0, 4, 2, 4, 3, 2, 4, 1, 0, 0, 2, 4, |
26 | }; | 26 | }; |
27 | 27 | ||
28 | static const byte cb_cycles_table[256] = | 28 | static const byte cb_cycles_table[256] ICONST_ATTR = |
29 | { | 29 | { |
30 | 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 4, 2, | 30 | 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 4, 2, |
31 | 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 4, 2, | 31 | 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 4, 2, |
@@ -50,7 +50,7 @@ static const byte cb_cycles_table[256] = | |||
50 | 50 | ||
51 | 51 | ||
52 | 52 | ||
53 | static const byte zflag_table[256] = | 53 | static const byte zflag_table[256] ICONST_ATTR = |
54 | { | 54 | { |
55 | FZ, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 55 | FZ, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
56 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 56 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
@@ -70,7 +70,7 @@ static const byte zflag_table[256] = | |||
70 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | 70 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 |
71 | }; | 71 | }; |
72 | 72 | ||
73 | static const byte incflag_table[256] = | 73 | static const byte incflag_table[256] ICONST_ATTR = |
74 | { | 74 | { |
75 | FZ|FH, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 75 | FZ|FH, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
76 | FH, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 76 | FH, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
@@ -90,7 +90,7 @@ static const byte incflag_table[256] = | |||
90 | FH, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | 90 | FH, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 |
91 | }; | 91 | }; |
92 | 92 | ||
93 | static const byte decflag_table[256] = | 93 | static const byte decflag_table[256] ICONST_ATTR = |
94 | { | 94 | { |
95 | FZ|FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN|FH, | 95 | FZ|FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN|FH, |
96 | FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN|FH, | 96 | FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN|FH, |
@@ -110,7 +110,7 @@ static const byte decflag_table[256] = | |||
110 | FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN|FH | 110 | FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN|FH |
111 | }; | 111 | }; |
112 | 112 | ||
113 | static const byte swap_table[256] = | 113 | static const byte swap_table[256] ICONST_ATTR = |
114 | { | 114 | { |
115 | 0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0, | 115 | 0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0, |
116 | 0x01, 0x11, 0x21, 0x31, 0x41, 0x51, 0x61, 0x71, 0x81, 0x91, 0xA1, 0xB1, 0xC1, 0xD1, 0xE1, 0xF1, | 116 | 0x01, 0x11, 0x21, 0x31, 0x41, 0x51, 0x61, 0x71, 0x81, 0x91, 0xA1, 0xB1, 0xC1, 0xD1, 0xE1, 0xF1, |
@@ -130,7 +130,7 @@ static const byte swap_table[256] = | |||
130 | 0x0F, 0x1F, 0x2F, 0x3F, 0x4F, 0x5F, 0x6F, 0x7F, 0x8F, 0x9F, 0xAF, 0xBF, 0xCF, 0xDF, 0xEF, 0xFF, | 130 | 0x0F, 0x1F, 0x2F, 0x3F, 0x4F, 0x5F, 0x6F, 0x7F, 0x8F, 0x9F, 0xAF, 0xBF, 0xCF, 0xDF, 0xEF, 0xFF, |
131 | }; | 131 | }; |
132 | 132 | ||
133 | static const byte daa_table[4096] = | 133 | static const byte daa_table[4096] ICONST_ATTR= |
134 | { | 134 | { |
135 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, | 135 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, |
136 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, | 136 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, |
@@ -269,7 +269,7 @@ static const byte daa_table[4096] = | |||
269 | 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, | 269 | 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, |
270 | }; | 270 | }; |
271 | 271 | ||
272 | static const byte daa_carry_table[64] = | 272 | static const byte daa_carry_table[64] ICONST_ATTR = |
273 | { | 273 | { |
274 | 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, | 274 | 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, |
275 | 00, 00, 00, 00, 00, 00, 00, 00, FC, FC, 00, 00, 00, 00, 00, 00, | 275 | 00, 00, 00, 00, 00, 00, 00, 00, FC, FC, 00, 00, 00, 00, 00, 00, |
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 | 61 | struct 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; | |
66 | void emu_run(void) | 66 | void 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 | ||
diff --git a/apps/plugins/rockboy/fastmem.c b/apps/plugins/rockboy/fastmem.c index d883438ce1..7f5b0b445f 100644 --- a/apps/plugins/rockboy/fastmem.c +++ b/apps/plugins/rockboy/fastmem.c | |||
@@ -14,7 +14,7 @@ | |||
14 | 14 | ||
15 | const byte himask[256]; | 15 | const byte himask[256]; |
16 | 16 | ||
17 | const byte hi_rmap[256] = | 17 | const byte hi_rmap[256] ICONST_ATTR = |
18 | { | 18 | { |
19 | 0, 0, R, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 19 | 0, 0, R, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
20 | S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, | 20 | S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, |
@@ -26,7 +26,7 @@ const byte hi_rmap[256] = | |||
26 | C, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | 26 | C, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 |
27 | }; | 27 | }; |
28 | 28 | ||
29 | const byte hi_wmap[256] = | 29 | const byte hi_wmap[256] ICONST_ATTR = |
30 | { | 30 | { |
31 | R, R, R, R, R, R, R, R, R, R, R, R, R, R, R, R, | 31 | R, R, R, R, R, R, R, R, R, R, R, R, R, R, R, R, |
32 | S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, | 32 | S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, |
diff --git a/apps/plugins/rockboy/fastmem.h b/apps/plugins/rockboy/fastmem.h index 7ab447fd2a..e36eb2032a 100644 --- a/apps/plugins/rockboy/fastmem.h +++ b/apps/plugins/rockboy/fastmem.h | |||
@@ -7,12 +7,12 @@ | |||
7 | #include "mem.h" | 7 | #include "mem.h" |
8 | 8 | ||
9 | 9 | ||
10 | byte readb(int a); | 10 | byte readb(int a) ICODE_ATTR; |
11 | void writeb(int a, byte b); | 11 | void writeb(int a, byte b) ICODE_ATTR; |
12 | int readw(int a); | 12 | int readw(int a) ICODE_ATTR; |
13 | void writew(int a, int w); | 13 | void writew(int a, int w) ICODE_ATTR; |
14 | byte readhi(int a); | 14 | byte readhi(int a) ICODE_ATTR; |
15 | void writehi(int a, byte b); | 15 | void writehi(int a, byte b) ICODE_ATTR; |
16 | #if 0 | 16 | #if 0 |
17 | byte readhi(int a); | 17 | byte readhi(int a); |
18 | void writehi(int a, byte b); | 18 | void writehi(int a, byte b); |
diff --git a/apps/plugins/rockboy/fb.h b/apps/plugins/rockboy/fb.h index b569fb8569..d70708e13a 100644 --- a/apps/plugins/rockboy/fb.h +++ b/apps/plugins/rockboy/fb.h | |||
@@ -10,7 +10,7 @@ | |||
10 | 10 | ||
11 | struct fb | 11 | struct fb |
12 | { | 12 | { |
13 | byte *ptr; | 13 | fb_data *ptr; |
14 | int w, h; | 14 | int w, h; |
15 | int pelsize; | 15 | int pelsize; |
16 | int pitch; | 16 | int pitch; |
diff --git a/apps/plugins/rockboy/hw.h b/apps/plugins/rockboy/hw.h index d05fb51194..5bc1230b3e 100644 --- a/apps/plugins/rockboy/hw.h +++ b/apps/plugins/rockboy/hw.h | |||
@@ -34,14 +34,14 @@ struct hw | |||
34 | 34 | ||
35 | extern struct hw hw; | 35 | extern struct hw hw; |
36 | 36 | ||
37 | void hw_interrupt(byte i, byte mask); | 37 | void hw_interrupt(byte i, byte mask) ICODE_ATTR; |
38 | void hw_dma(byte b); | 38 | void hw_dma(byte b) ICODE_ATTR; |
39 | void hw_hdma_cmd(byte c); | 39 | void hw_hdma_cmd(byte c) ICODE_ATTR; |
40 | void hw_hdma(void); | 40 | void hw_hdma(void) ICODE_ATTR; |
41 | void pad_refresh(void); | 41 | void pad_refresh(void)ICODE_ATTR; |
42 | void pad_press(byte k); | 42 | void pad_press(byte k)ICODE_ATTR; |
43 | void pad_release(byte k); | 43 | void pad_release(byte k)ICODE_ATTR; |
44 | void pad_set(byte k, int st); | 44 | void pad_set(byte k, int st)ICODE_ATTR; |
45 | void hw_reset(void); | 45 | void hw_reset(void); |
46 | 46 | ||
47 | #endif | 47 | #endif |
diff --git a/apps/plugins/rockboy/input.h b/apps/plugins/rockboy/input.h index 8c5fdf9352..b57404908d 100644 --- a/apps/plugins/rockboy/input.h +++ b/apps/plugins/rockboy/input.h | |||
@@ -18,7 +18,7 @@ typedef struct event_s | |||
18 | #define EV_RELEASE 2 | 18 | #define EV_RELEASE 2 |
19 | #define EV_REPEAT 3 | 19 | #define EV_REPEAT 3 |
20 | 20 | ||
21 | int ev_postevent(event_t *ev); | 21 | int ev_postevent(event_t *ev) ICODE_ATTR; |
22 | int ev_getevent(event_t *ev); | 22 | int ev_getevent(event_t *ev) ICODE_ATTR; |
23 | 23 | ||
24 | 24 | ||
diff --git a/apps/plugins/rockboy/lcd-gb.h b/apps/plugins/rockboy/lcd-gb.h index 9f1b890c17..c02e670dd2 100644 --- a/apps/plugins/rockboy/lcd-gb.h +++ b/apps/plugins/rockboy/lcd-gb.h | |||
@@ -55,21 +55,21 @@ extern struct scan scan; | |||
55 | 55 | ||
56 | 56 | ||
57 | void updatepatpix(void) ICODE_ATTR; | 57 | void updatepatpix(void) ICODE_ATTR; |
58 | void tilebuf(void); | 58 | void tilebuf(void) ICODE_ATTR; |
59 | void bg_scan(void); | 59 | void bg_scan(void) ICODE_ATTR; |
60 | void wnd_scan(void); | 60 | void wnd_scan(void) ICODE_ATTR; |
61 | void bg_scan_pri(void); | 61 | void bg_scan_pri(void) ICODE_ATTR; |
62 | void wnd_scan_pri(void); | 62 | void wnd_scan_pri(void) ICODE_ATTR; |
63 | void spr_count(void); | 63 | void spr_count(void); |
64 | void spr_enum(void); | 64 | void spr_enum(void) ICODE_ATTR; |
65 | void spr_scan(void); | 65 | void spr_scan(void) ICODE_ATTR; |
66 | void lcd_begin(void); | 66 | void lcd_begin(void) ICODE_ATTR; |
67 | void lcd_refreshline(void); | 67 | void lcd_refreshline(void) ICODE_ATTR; |
68 | void pal_write(int i, byte b); | 68 | void pal_write(int i, byte b); |
69 | void pal_write_dmg(int i, int mapnum, byte d); | 69 | void pal_write_dmg(int i, int mapnum, byte d) ICODE_ATTR; |
70 | void vram_write(int a, byte b); | 70 | void vram_write(int a, byte b) ICODE_ATTR; |
71 | void vram_dirty(void); | 71 | void vram_dirty(void) ICODE_ATTR; |
72 | void pal_dirty(void); | 72 | void pal_dirty(void) ICODE_ATTR; |
73 | void lcd_reset(void); | 73 | void lcd_reset(void); |
74 | 74 | ||
75 | #endif | 75 | #endif |
diff --git a/apps/plugins/rockboy/lcd.c b/apps/plugins/rockboy/lcd.c index 4cd4ddc04c..c1a7a87b6b 100644 --- a/apps/plugins/rockboy/lcd.c +++ b/apps/plugins/rockboy/lcd.c | |||
@@ -94,7 +94,7 @@ rcvar_t lcd_exports[] = | |||
94 | RCV_END | 94 | RCV_END |
95 | }; | 95 | }; |
96 | 96 | ||
97 | static byte *vdest; | 97 | fb_data *vdest; |
98 | 98 | ||
99 | #ifdef ALLOW_UNALIGNED_IO /* long long is ok since this is i386-only anyway? */ | 99 | #ifdef ALLOW_UNALIGNED_IO /* long long is ok since this is i386-only anyway? */ |
100 | #define MEMCPY8(d, s) ((*(long long *)(d)) = (*(long long *)(s))) | 100 | #define MEMCPY8(d, s) ((*(long long *)(d)) = (*(long long *)(s))) |
@@ -532,9 +532,21 @@ void bg_scan(void) | |||
532 | if (cnt <= 0) return; | 532 | if (cnt <= 0) return; |
533 | while (cnt >= 8) | 533 | while (cnt >= 8) |
534 | { | 534 | { |
535 | #if CONFIG_CPU == MCF5249 && !defined(SIMULATOR) | ||
536 | asm volatile ( | ||
537 | "move.l (%1)+,(%0)+ \n" | ||
538 | "move.l (%1)+,(%0)+ \n" | ||
539 | : /*outputs*/ | ||
540 | : /*inputs*/ | ||
541 | /* %0 */ "a" (dest), | ||
542 | /* %1 */ "a" (patpix[*(tile++)][V]) | ||
543 | //: /* clobbers */ | ||
544 | ); | ||
545 | #else | ||
535 | src = patpix[*(tile++)][V]; | 546 | src = patpix[*(tile++)][V]; |
536 | MEMCPY8(dest, src); | 547 | MEMCPY8(dest, src); |
537 | dest += 8; | 548 | dest += 8; |
549 | #endif | ||
538 | cnt -= 8; | 550 | cnt -= 8; |
539 | } | 551 | } |
540 | src = patpix[*tile][V]; | 552 | src = patpix[*tile][V]; |
@@ -555,9 +567,21 @@ void wnd_scan(void) | |||
555 | 567 | ||
556 | while (cnt >= 8) | 568 | while (cnt >= 8) |
557 | { | 569 | { |
570 | #if CONFIG_CPU == MCF5249 && !defined(SIMULATOR) | ||
571 | asm volatile ( | ||
572 | "move.l (%1)+,(%0)+ \n" | ||
573 | "move.l (%1)+,(%0)+ \n" | ||
574 | : /*outputs*/ | ||
575 | : /*inputs*/ | ||
576 | /* %0 */ "a" (dest), | ||
577 | /* %1 */ "a" (patpix[*(tile++)][WV]) | ||
578 | //: /* clobbers */ | ||
579 | ); | ||
580 | #else | ||
558 | src = patpix[*(tile++)][WV]; | 581 | src = patpix[*(tile++)][WV]; |
559 | MEMCPY8(dest, src); | 582 | MEMCPY8(dest, src); |
560 | dest += 8; | 583 | dest += 8; |
584 | #endif | ||
561 | cnt -= 8; | 585 | cnt -= 8; |
562 | } | 586 | } |
563 | src = patpix[*tile][WV]; | 587 | src = patpix[*tile][WV]; |
@@ -651,8 +675,55 @@ void bg_scan_color(void) | |||
651 | while (cnt >= 8) | 675 | while (cnt >= 8) |
652 | { | 676 | { |
653 | src = patpix[*(tile++)][V]; | 677 | src = patpix[*(tile++)][V]; |
678 | #if CONFIG_CPU == MCF5249 && !defined(SIMULATOR) | ||
679 | asm volatile ( | ||
680 | "move.l (%2)+,%%d1 \n" | ||
681 | |||
682 | "move.b %%d1,%%d2 \n" | ||
683 | |||
684 | "move.b (%1)+,%%d0 \n" | ||
685 | "or.l %%d2,%%d0 \n" | ||
686 | "move.b %%d0,(%0)+ \n" | ||
687 | |||
688 | "move.b (%1)+,%%d0 \n" | ||
689 | "or.l %%d1,%%d0 \n" | ||
690 | "move.b %%d0,(%0)+ \n" | ||
691 | |||
692 | "move.b (%1)+,%%d0 \n" | ||
693 | "or.l %%d2,%%d0 \n" | ||
694 | "move.b %%d0,(%0)+ \n" | ||
695 | |||
696 | "move.b (%1)+,%%d0 \n" | ||
697 | "or.l %%d2,%%d0 \n" | ||
698 | "move.b %%d0,(%0)+ \n" | ||
699 | |||
700 | "move.b (%1)+,%%d0 \n" | ||
701 | "or.l %%d2,%%d0 \n" | ||
702 | "move.b %%d0,(%0)+ \n" | ||
703 | |||
704 | "move.b (%1)+,%%d0 \n" | ||
705 | "or.l %%d2,%%d0 \n" | ||
706 | "move.b %%d0,(%0)+ \n" | ||
707 | |||
708 | "move.b (%1)+,%%d0 \n" | ||
709 | "or.l %%d2,%%d0 \n" | ||
710 | "move.b %%d0,(%0)+ \n" | ||
711 | |||
712 | "move.b (%1)+,%%d0 \n" | ||
713 | "or.l %%d2,%%d0 \n" | ||
714 | "move.b %%d0,(%0)+ \n" | ||
715 | : /*outputs*/ | ||
716 | : /*inputs*/ | ||
717 | /* %0 */ "a" (dest), | ||
718 | /* %1 */ "a" (src), | ||
719 | /* %2 */ "a" (tile) | ||
720 | : /* clobbers */ | ||
721 | "d0", "d1", "d2" | ||
722 | ); | ||
723 | #else | ||
654 | blendcpy(dest, src, *(tile++), 8); | 724 | blendcpy(dest, src, *(tile++), 8); |
655 | dest += 8; | 725 | dest += 8; |
726 | #endif | ||
656 | cnt -= 8; | 727 | cnt -= 8; |
657 | } | 728 | } |
658 | src = patpix[*(tile++)][V]; | 729 | src = patpix[*(tile++)][V]; |
@@ -843,14 +914,21 @@ void lcd_begin(void) | |||
843 | else pal_expire(); | 914 | else pal_expire(); |
844 | } | 915 | } |
845 | while (scale * 160 > fb.w || scale * 144 > fb.h) scale--; */ | 916 | while (scale * 160 > fb.w || scale * 144 > fb.h) scale--; */ |
846 | vdest = fb.ptr + ((fb.w*fb.pelsize)>>1) | 917 | if(options.fullscreen) |
847 | - (80*fb.pelsize) | 918 | vdest = fb.ptr; |
848 | + ((fb.h>>1) - 72) * fb.pitch; | 919 | else |
920 | vdest = fb.ptr + ((LCD_HEIGHT-144)/2)*LCD_WIDTH + ((LCD_WIDTH-160)/2); | ||
921 | |||
849 | WY = R_WY; | 922 | WY = R_WY; |
850 | } | 923 | } |
851 | 924 | ||
925 | char frameout[25]; | ||
852 | void lcd_refreshline(void) | 926 | void lcd_refreshline(void) |
853 | { | 927 | { |
928 | #if LCD_HEIGHT>=144 | ||
929 | int cnt=0, two; | ||
930 | #endif | ||
931 | |||
854 | if (!fb.enabled) return; | 932 | if (!fb.enabled) return; |
855 | if(!insync) { | 933 | if(!insync) { |
856 | if(R_LY!=0) | 934 | if(R_LY!=0) |
@@ -924,7 +1002,32 @@ void lcd_refreshline(void) | |||
924 | else | 1002 | else |
925 | vid_update(L-((int)(L/9))); | 1003 | vid_update(L-((int)(L/9))); |
926 | #else | 1004 | #else |
927 | vid_update(L); | 1005 | |
1006 | for(two=0;two<( (options.showstats ? (L&0x07)==0x05 : (L&0x07)==0x05 || (L&0x0F)==0x08) && options.fullscreen)+1;two++) | ||
1007 | { | ||
1008 | while (cnt < 160) | ||
1009 | { | ||
1010 | *vdest++ = scan.pal2[scan.buf[cnt++]]; | ||
1011 | if( ((cnt&0x03)==0x03 || (cnt&0x07)==0x06) && options.fullscreen ) *vdest++ = scan.pal2[scan.buf[cnt]]; | ||
1012 | } | ||
1013 | |||
1014 | if(!options.fullscreen) | ||
1015 | vdest+=(LCD_WIDTH-160); | ||
1016 | cnt=0; | ||
1017 | } | ||
1018 | |||
1019 | if(L==143) | ||
1020 | { | ||
1021 | if(options.showstats) { | ||
1022 | snprintf(frameout,sizeof(frameout),"FPS: %d \t %d ",options.fps, options.frameskip); | ||
1023 | if(options.fullscreen) rb->lcd_putsxy(0,166,frameout); | ||
1024 | else rb->lcd_putsxy((LCD_WIDTH-160)/2,(LCD_HEIGHT-144)/2,frameout); | ||
1025 | } | ||
1026 | if(options.fullscreen) | ||
1027 | rb->lcd_update(); | ||
1028 | else | ||
1029 | rb->lcd_update_rect( (LCD_WIDTH-160)/2, (LCD_HEIGHT-144)/2, 160, 144 ); | ||
1030 | } | ||
928 | #endif | 1031 | #endif |
929 | } | 1032 | } |
930 | #if LCD_DEPTH == 1 | 1033 | #if LCD_DEPTH == 1 |
diff --git a/apps/plugins/rockboy/lcdc.h b/apps/plugins/rockboy/lcdc.h index c5edc6c065..d8cb282e5a 100644 --- a/apps/plugins/rockboy/lcdc.h +++ b/apps/plugins/rockboy/lcdc.h | |||
@@ -1,4 +1,4 @@ | |||
1 | void stat_trigger(void); | 1 | void stat_trigger(void) ICODE_ATTR; |
2 | void stat_write(byte b); | 2 | void stat_write(byte b)ICODE_ATTR; |
3 | void lcdc_change(byte b); | 3 | void lcdc_change(byte b)ICODE_ATTR; |
4 | void lcdc_trans(void); | 4 | void lcdc_trans(void)ICODE_ATTR; |
diff --git a/apps/plugins/rockboy/loader.c b/apps/plugins/rockboy/loader.c index 0a8eaba13f..1dd712f1e5 100644 --- a/apps/plugins/rockboy/loader.c +++ b/apps/plugins/rockboy/loader.c | |||
@@ -81,7 +81,6 @@ static char rtcfile[500]; | |||
81 | static char saveprefix[500]; | 81 | static char saveprefix[500]; |
82 | 82 | ||
83 | static char *savename; | 83 | static char *savename; |
84 | static char *savedir = "/.rockbox/rockboy"; | ||
85 | 84 | ||
86 | static int saveslot; | 85 | static int saveslot; |
87 | 86 | ||
@@ -332,14 +331,14 @@ void cleanup(void) | |||
332 | void loader_init(char *s) | 331 | void loader_init(char *s) |
333 | { | 332 | { |
334 | char *name; | 333 | char *name; |
335 | DIR* dir; | 334 | // DIR* dir; |
336 | 335 | ||
337 | // sys_checkdir(savedir, 1); /* needs to be writable */ | 336 | // sys_checkdir(savedir, 1); /* needs to be writable */ |
338 | dir=opendir(savedir); | 337 | /* dir=opendir(savedir); // should be handled when the program opens |
339 | if(!dir) | 338 | if(!dir) |
340 | mkdir(savedir,0); | 339 | mkdir(savedir,0); |
341 | else | 340 | else |
342 | closedir(dir); | 341 | closedir(dir);*/ |
343 | 342 | ||
344 | romfile = s; | 343 | romfile = s; |
345 | if(rom_load()) | 344 | if(rom_load()) |
diff --git a/apps/plugins/rockboy/main.c b/apps/plugins/rockboy/main.c index 5464d4961e..c9cbb76aaa 100644 --- a/apps/plugins/rockboy/main.c +++ b/apps/plugins/rockboy/main.c | |||
@@ -86,7 +86,7 @@ int gnuboy_main(char *rom) | |||
86 | PUTS("Emu run"); | 86 | PUTS("Emu run"); |
87 | #if (LCD_HEIGHT > 144) || (LCD_WIDTH > 160) | 87 | #if (LCD_HEIGHT > 144) || (LCD_WIDTH > 160) |
88 | rb->lcd_clear_display(); | 88 | rb->lcd_clear_display(); |
89 | rb->lcd_drawrect((LCD_WIDTH-160)/2-1, (LCD_HEIGHT-144)/2-1, 162, 146); | 89 | // rb->lcd_drawrect((LCD_WIDTH-160)/2-1, (LCD_HEIGHT-144)/2-1, 162, 146); |
90 | rb->lcd_update(); | 90 | rb->lcd_update(); |
91 | #endif | 91 | #endif |
92 | emu_run(); | 92 | emu_run(); |
diff --git a/apps/plugins/rockboy/mem.c b/apps/plugins/rockboy/mem.c index 6bfedcb6c8..01a05d09ea 100644 --- a/apps/plugins/rockboy/mem.c +++ b/apps/plugins/rockboy/mem.c | |||
@@ -11,7 +11,7 @@ | |||
11 | #include "lcdc.h" | 11 | #include "lcdc.h" |
12 | #include "sound.h" | 12 | #include "sound.h" |
13 | 13 | ||
14 | struct mbc mbc; | 14 | struct mbc mbc IBSS_ATTR; |
15 | struct rom rom; | 15 | struct rom rom; |
16 | struct ram ram; | 16 | struct ram ram; |
17 | 17 | ||
diff --git a/apps/plugins/rockboy/mem.h b/apps/plugins/rockboy/mem.h index 7926e2eda9..36ea26e9f3 100644 --- a/apps/plugins/rockboy/mem.h +++ b/apps/plugins/rockboy/mem.h | |||
@@ -52,11 +52,11 @@ extern struct ram ram; | |||
52 | 52 | ||
53 | 53 | ||
54 | 54 | ||
55 | void mem_updatemap(void); | 55 | void mem_updatemap(void) ICODE_ATTR; |
56 | void ioreg_write(byte r, byte b); | 56 | void ioreg_write(byte r, byte b) ICODE_ATTR; |
57 | void mbc_write(int a, byte b); | 57 | void mbc_write(int a, byte b) ICODE_ATTR; |
58 | void mem_write(int a, byte b); | 58 | void mem_write(int a, byte b) ICODE_ATTR; |
59 | byte mem_read(int a); | 59 | byte mem_read(int a) ICODE_ATTR; |
60 | void mbc_reset(void); | 60 | void mbc_reset(void); |
61 | 61 | ||
62 | 62 | ||
diff --git a/apps/plugins/rockboy/menu.c b/apps/plugins/rockboy/menu.c index 140e7a28b1..a22aef46f8 100644 --- a/apps/plugins/rockboy/menu.c +++ b/apps/plugins/rockboy/menu.c | |||
@@ -69,6 +69,9 @@ static const char *slot_menu[] = { | |||
69 | typedef enum { | 69 | typedef enum { |
70 | OM_ITEM_FS, | 70 | OM_ITEM_FS, |
71 | OM_ITEM_SOUND, | 71 | OM_ITEM_SOUND, |
72 | OM_ITEM_STATS, | ||
73 | OM_ITEM_FULLSCREEN, | ||
74 | OM_ITEM_KEYS, | ||
72 | OM_ITEM_BACK, | 75 | OM_ITEM_BACK, |
73 | OM_MENU_LAST | 76 | OM_MENU_LAST |
74 | } OptMenuItem; | 77 | } OptMenuItem; |
@@ -76,6 +79,9 @@ typedef enum { | |||
76 | static const char *opt_menu[] = { | 79 | static const char *opt_menu[] = { |
77 | "Frameskip", | 80 | "Frameskip", |
78 | "Sound ON/OFF", | 81 | "Sound ON/OFF", |
82 | "Stats ON/OFF", | ||
83 | "Fullscreen ON/OFF", | ||
84 | "Set Keys (BUGGY)", | ||
79 | "Previous Menu..." | 85 | "Previous Menu..." |
80 | }; | 86 | }; |
81 | 87 | ||
@@ -90,13 +96,50 @@ typedef enum { | |||
90 | } FSMenuItem; | 96 | } FSMenuItem; |
91 | 97 | ||
92 | static const char *fs_menu[] = { | 98 | static const char *fs_menu[] = { |
93 | "Skip 0 Frames", | 99 | "Frameskip 3 Max", |
94 | "Skip 1 Frames", | 100 | "Frameskip 4 Max", |
95 | "Skip 2 Frames", | 101 | "Frameskip 5 Max", |
96 | "Skip 3 Frames", | 102 | "Frameskip 7 Max", |
97 | "Previous Menu..." | 103 | "Previous Menu..." |
98 | }; | 104 | }; |
99 | 105 | ||
106 | int getbutton(char *text) | ||
107 | { | ||
108 | rb->lcd_putsxy(0, 0, text); | ||
109 | rb->lcd_update(); | ||
110 | rb->sleep(30); | ||
111 | while (rb->button_get(false) != BUTTON_NONE) | ||
112 | rb->yield(); | ||
113 | int button; | ||
114 | while(true){ | ||
115 | button = rb->button_get(true); | ||
116 | button=button&0x00000FFF; | ||
117 | switch(button) { | ||
118 | case BUTTON_LEFT: | ||
119 | case BUTTON_RIGHT: | ||
120 | case BUTTON_UP: | ||
121 | case BUTTON_DOWN: | ||
122 | break; | ||
123 | default: | ||
124 | return button; | ||
125 | break; | ||
126 | } | ||
127 | } | ||
128 | } | ||
129 | |||
130 | void setupkeys(void) | ||
131 | { | ||
132 | options.A=getbutton("Press A"); | ||
133 | |||
134 | options.B=getbutton("Press B"); | ||
135 | |||
136 | options.START=getbutton("Press Start"); | ||
137 | |||
138 | options.SELECT=getbutton("Press Select"); | ||
139 | |||
140 | options.MENU=getbutton("Press Menu"); | ||
141 | } | ||
142 | |||
100 | /* | 143 | /* |
101 | * do_user_menu - create the user menu on the screen. | 144 | * do_user_menu - create the user menu on the screen. |
102 | * | 145 | * |
@@ -144,6 +187,7 @@ int do_user_menu(void) { | |||
144 | } | 187 | } |
145 | } | 188 | } |
146 | rb->lcd_clear_display(); | 189 | rb->lcd_clear_display(); |
190 | rb->lcd_update(); | ||
147 | /* return somethin' */ | 191 | /* return somethin' */ |
148 | return ret; | 192 | return ret; |
149 | } | 193 | } |
@@ -359,16 +403,16 @@ static void do_fs_menu(void) { | |||
359 | done = true; | 403 | done = true; |
360 | break; | 404 | break; |
361 | case FS_ITEM_FS0: | 405 | case FS_ITEM_FS0: |
362 | frameskip=0; | 406 | options.maxskip=3; |
363 | break; | 407 | break; |
364 | case FS_ITEM_FS1: | 408 | case FS_ITEM_FS1: |
365 | frameskip=1; | 409 | options.maxskip=4; |
366 | break; | 410 | break; |
367 | case FS_ITEM_FS2: | 411 | case FS_ITEM_FS2: |
368 | frameskip=2; | 412 | options.maxskip=5; |
369 | break; | 413 | break; |
370 | case FS_ITEM_FS3: | 414 | case FS_ITEM_FS3: |
371 | frameskip=3; | 415 | options.maxskip=7; |
372 | break; | 416 | break; |
373 | } | 417 | } |
374 | } | 418 | } |
@@ -389,8 +433,17 @@ static void do_opt_menu(void) { | |||
389 | do_fs_menu(); | 433 | do_fs_menu(); |
390 | break; | 434 | break; |
391 | case OM_ITEM_SOUND: | 435 | case OM_ITEM_SOUND: |
392 | sound=!sound; | 436 | options.sound=!options.sound; |
437 | break; | ||
438 | case OM_ITEM_STATS: | ||
439 | options.showstats=!options.showstats; | ||
393 | break; | 440 | break; |
441 | case OM_ITEM_FULLSCREEN: | ||
442 | options.fullscreen=!options.fullscreen; | ||
443 | break; | ||
444 | case OM_ITEM_KEYS: | ||
445 | setupkeys(); | ||
446 | break; | ||
394 | case MENU_CANCEL: | 447 | case MENU_CANCEL: |
395 | case OM_ITEM_BACK: | 448 | case OM_ITEM_BACK: |
396 | done = true; | 449 | done = true; |
diff --git a/apps/plugins/rockboy/noise.h b/apps/plugins/rockboy/noise.h index 037499eef3..838cbe171c 100644 --- a/apps/plugins/rockboy/noise.h +++ b/apps/plugins/rockboy/noise.h | |||
@@ -5,13 +5,13 @@ | |||
5 | 5 | ||
6 | #include "defs.h" | 6 | #include "defs.h" |
7 | 7 | ||
8 | static byte noise7[] = | 8 | static byte noise7[] ICONST_ATTR = |
9 | { | 9 | { |
10 | 0xfd,0xf3,0xd7,0x0d,0xd3,0x15,0x82,0xf1, | 10 | 0xfd,0xf3,0xd7,0x0d,0xd3,0x15,0x82,0xf1, |
11 | 0xdb,0x25,0x21,0x39,0x68,0x8c,0xd5,0x00, | 11 | 0xdb,0x25,0x21,0x39,0x68,0x8c,0xd5,0x00, |
12 | }; | 12 | }; |
13 | 13 | ||
14 | static byte noise15[] = | 14 | static byte noise15[] ICONST_ATTR = |
15 | { | 15 | { |
16 | 0xff,0xfd,0xff,0xf3,0xff,0xd7,0xff,0x0f, | 16 | 0xff,0xfd,0xff,0xf3,0xff,0xd7,0xff,0x0f, |
17 | 0xfd,0xdf,0xf3,0x3f,0xd5,0x7f,0x00,0xfd, | 17 | 0xfd,0xdf,0xf3,0x3f,0xd5,0x7f,0x00,0xfd, |
diff --git a/apps/plugins/rockboy/palette.h b/apps/plugins/rockboy/palette.h index 05b093be77..94f660b71e 100644 --- a/apps/plugins/rockboy/palette.h +++ b/apps/plugins/rockboy/palette.h | |||
@@ -1,6 +1,6 @@ | |||
1 | void pal_lock(byte n); | 1 | void pal_lock(byte n) ICODE_ATTR; |
2 | byte pal_getcolor(int c, int r, int g, int b); | 2 | byte pal_getcolor(int c, int r, int g, int b) ICODE_ATTR; |
3 | void pal_release(byte n); | 3 | void pal_release(byte n) ICODE_ATTR; |
4 | void pal_expire(void); | 4 | void pal_expire(void) ICODE_ATTR; |
5 | void pal_set332(void); | 5 | void pal_set332(void) ICODE_ATTR; |
6 | void vid_setpal(int i, int r, int g, int b); | 6 | void vid_setpal(int i, int r, int g, int b) ICODE_ATTR; |
diff --git a/apps/plugins/rockboy/rbsound.c b/apps/plugins/rockboy/rbsound.c index b68a053f77..3eebea8bef 100644 --- a/apps/plugins/rockboy/rbsound.c +++ b/apps/plugins/rockboy/rbsound.c | |||
@@ -3,10 +3,18 @@ | |||
3 | #include "pcm.h" | 3 | #include "pcm.h" |
4 | #include "rc.h" | 4 | #include "rc.h" |
5 | 5 | ||
6 | struct pcm pcm; | 6 | //#define ONEBUF // Note: I think the single buffer implementation is more responsive with sound(less lag) |
7 | // but it creates more choppyness overall to the sound. 2 buffer's don't seem to make | ||
8 | // a difference, but 4 buffers is definately noticable | ||
9 | |||
10 | struct pcm pcm IBSS_ATTR; | ||
7 | 11 | ||
8 | bool sound = 1; | 12 | bool sound = 1; |
13 | #ifdef ONEBUF | ||
14 | #define N_BUFS 1 | ||
15 | #else | ||
9 | #define N_BUFS 4 | 16 | #define N_BUFS 4 |
17 | #endif | ||
10 | #define BUF_SIZE 1024 | 18 | #define BUF_SIZE 1024 |
11 | 19 | ||
12 | rcvar_t pcm_exports[] = | 20 | rcvar_t pcm_exports[] = |
@@ -16,48 +24,62 @@ rcvar_t pcm_exports[] = | |||
16 | 24 | ||
17 | #if CONFIG_CODEC == SWCODEC && !defined(SIMULATOR) | 25 | #if CONFIG_CODEC == SWCODEC && !defined(SIMULATOR) |
18 | 26 | ||
19 | static int curbuf,gmcurbuf; | 27 | #ifndef ONEBUF |
28 | static short curbuf,gmcurbuf; | ||
29 | #else | ||
30 | bool doneplay=0; | ||
31 | #endif | ||
20 | 32 | ||
21 | static byte *buf=0; | 33 | static unsigned char *buf=0; |
22 | static short *gmbuf; | 34 | static unsigned short *gmbuf; |
23 | 35 | ||
24 | static bool newly_started; | 36 | static bool newly_started; |
25 | 37 | ||
38 | void get_more(unsigned char** start, long* size) | ||
39 | { | ||
40 | #ifdef ONEBUF | ||
41 | doneplay=1; | ||
42 | *start = (unsigned char*)(gmbuf); | ||
43 | #else | ||
44 | *start = (unsigned char*)(&gmbuf[pcm.len*curbuf]); | ||
45 | #endif | ||
46 | *size = BUF_SIZE*sizeof(short); | ||
47 | } | ||
48 | |||
26 | void pcm_init(void) | 49 | void pcm_init(void) |
27 | { | 50 | { |
28 | if(!sound) return; | 51 | if(!sound) return; |
29 | 52 | ||
30 | newly_started = true; | 53 | newly_started = true; |
31 | 54 | ||
32 | pcm.hz = 11025; | 55 | pcm.hz = 11025; |
33 | pcm.stereo = 1; | 56 | pcm.stereo = 1; |
34 | 57 | ||
35 | pcm.len = BUF_SIZE; | 58 | pcm.len = BUF_SIZE; |
36 | if(!buf){ | 59 | if(!buf){ |
37 | buf = my_malloc(pcm.len * N_BUFS); | 60 | buf = my_malloc(pcm.len * N_BUFS); |
38 | gmbuf = my_malloc(pcm.len * N_BUFS*sizeof (short)); | 61 | gmbuf = my_malloc(pcm.len * N_BUFS*sizeof (short)); |
39 | pcm.buf = buf; | 62 | pcm.buf = buf; |
40 | pcm.pos = 0; | 63 | pcm.pos = 0; |
41 | curbuf = gmcurbuf= 0; | 64 | #ifndef ONEBUF |
65 | curbuf = gmcurbuf= 0; | ||
66 | #endif | ||
67 | memset(gmbuf, 0, pcm.len * N_BUFS *sizeof(short)); | ||
68 | memset(buf, 0, pcm.len * N_BUFS); | ||
42 | } | 69 | } |
43 | 70 | ||
44 | rb->pcm_play_stop(); | 71 | rb->pcm_play_stop(); |
45 | rb->pcm_set_frequency(11025); // 44100 22050 11025 | 72 | |
73 | rb->pcm_set_frequency(11025); // 44100 22050 11025 | ||
46 | } | 74 | } |
47 | 75 | ||
48 | void pcm_close(void) | 76 | void pcm_close(void) |
49 | { | 77 | { |
50 | memset(&pcm, 0, sizeof pcm); | 78 | memset(&pcm, 0, sizeof pcm); |
51 | newly_started = true; | 79 | newly_started = true; |
52 | rb->pcm_play_stop(); | 80 | rb->pcm_play_stop(); |
53 | rb->pcm_set_frequency(44100); | 81 | rb->pcm_set_frequency(44100); |
54 | } | 82 | } |
55 | |||
56 | void get_more(unsigned char** start, long* size) | ||
57 | { | ||
58 | *start = (unsigned char*)(&gmbuf[pcm.len*curbuf]); | ||
59 | *size = BUF_SIZE*sizeof(short); | ||
60 | } | ||
61 | 83 | ||
62 | int pcm_submit(void) | 84 | int pcm_submit(void) |
63 | { | 85 | { |
@@ -66,25 +88,36 @@ int pcm_submit(void) | |||
66 | if (!sound) { | 88 | if (!sound) { |
67 | pcm.pos = 0; | 89 | pcm.pos = 0; |
68 | return 0; | 90 | return 0; |
69 | } | 91 | } |
70 | 92 | ||
71 | if (pcm.pos >= pcm.len) { | 93 | if (pcm.pos < pcm.len) return 1; |
72 | curbuf = (curbuf + 1) % N_BUFS; | ||
73 | pcm.buf = buf + pcm.len * curbuf; | ||
74 | pcm.pos = 0; | ||
75 | 94 | ||
76 | // gotta convert the 8 bit buffer to 16 | 95 | #ifndef ONEBUF |
77 | for(i=0; i<pcm.len;i++) | 96 | curbuf = (curbuf + 1) % N_BUFS; |
78 | gmbuf[i+pcm.len*curbuf] = (pcm.buf[i]<<8)-0x8000; | 97 | pcm.buf = buf + pcm.len * curbuf; |
79 | } | 98 | #endif |
80 | 99 | pcm.pos = 0; | |
81 | if(newly_started) | 100 | |
82 | { | 101 | // gotta convert the 8 bit buffer to 16 |
83 | rb->pcm_play_data(&get_more); | 102 | for(i=0; i<pcm.len;i++) |
84 | newly_started = false; | 103 | #ifdef ONEBUF |
85 | } | 104 | gmbuf[i] = (pcm.buf[i]<<8)-0x8000; |
105 | #else | ||
106 | gmbuf[i+pcm.len*curbuf] = (pcm.buf[i]<<8)-0x8000; | ||
107 | #endif | ||
86 | 108 | ||
87 | return 1; | 109 | if(newly_started) |
110 | { | ||
111 | rb->pcm_play_data(&get_more); | ||
112 | newly_started = false; | ||
113 | } | ||
114 | |||
115 | // this while loop and done play are in place to make sure the sound timing is correct(although it's not) | ||
116 | #ifdef ONEBUF | ||
117 | while(doneplay==0) rb->yield(); | ||
118 | doneplay=0; | ||
119 | #endif | ||
120 | return 1; | ||
88 | } | 121 | } |
89 | #else | 122 | #else |
90 | static byte buf1_unal[(BUF_SIZE / sizeof(short)) + 2]; // to make sure 4 byte aligned | 123 | static byte buf1_unal[(BUF_SIZE / sizeof(short)) + 2]; // to make sure 4 byte aligned |
diff --git a/apps/plugins/rockboy/rockboy.c b/apps/plugins/rockboy/rockboy.c index a7e9bfb8f1..f6dea0eeea 100644 --- a/apps/plugins/rockboy/rockboy.c +++ b/apps/plugins/rockboy/rockboy.c | |||
@@ -39,6 +39,8 @@ char *errormsg; | |||
39 | int gnuboy_main(char *rom); | 39 | int gnuboy_main(char *rom); |
40 | void pcm_close(void); | 40 | void pcm_close(void); |
41 | 41 | ||
42 | #define optionname "options" | ||
43 | |||
42 | void die(char *message, ...) | 44 | void die(char *message, ...) |
43 | { | 45 | { |
44 | shut=1; | 46 | shut=1; |
@@ -74,6 +76,74 @@ void setmallocpos(void *pointer) | |||
74 | audio_buffer_free = audio_bufferpointer - audio_bufferbase; | 76 | audio_buffer_free = audio_bufferpointer - audio_bufferbase; |
75 | } | 77 | } |
76 | 78 | ||
79 | void setoptions (void) { | ||
80 | int fd; | ||
81 | DIR* dir; | ||
82 | char optionsave[sizeof(savedir)+sizeof(optionname)]; | ||
83 | |||
84 | dir=opendir(savedir); | ||
85 | if(!dir) | ||
86 | mkdir(savedir,0); | ||
87 | else | ||
88 | closedir(dir); | ||
89 | |||
90 | snprintf(optionsave, sizeof(optionsave), "%s/%s", savedir, optionname); | ||
91 | |||
92 | fd = open(optionsave, O_RDONLY); | ||
93 | if(fd < 0) // no options to read, set defaults | ||
94 | { | ||
95 | #if (CONFIG_KEYPAD == IRIVER_H100_PAD) | ||
96 | options.A=BUTTON_ON; | ||
97 | options.B=BUTTON_OFF; | ||
98 | options.START=BUTTON_REC; | ||
99 | options.SELECT=BUTTON_SELECT; | ||
100 | options.MENU=BUTTON_MODE; | ||
101 | |||
102 | #elif (CONFIG_KEYPAD == IRIVER_H300_PAD) | ||
103 | options.A=BUTTON_REC; | ||
104 | options.B=BUTTON_MODE; | ||
105 | options.START=BUTTON_ON; | ||
106 | options.SELECT=BUTTON_SELECT; | ||
107 | options.MENU=BUTTON_OFF; | ||
108 | |||
109 | #elif CONFIG_KEYPAD == RECORDER_PAD | ||
110 | options.A=BUTTON_F1; | ||
111 | options.B=BUTTON_F2; | ||
112 | options.START=BUTTON_F3; | ||
113 | options.SELECT=BUTTON_PLAY; | ||
114 | options.MENU=BUTTON_OFF; | ||
115 | |||
116 | #elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD | ||
117 | options.A=BUTTON_PLAY; | ||
118 | options.B=BUTTON_EQ; | ||
119 | options.START=BUTTON_MODE; | ||
120 | options.SELECT=(BUTTON_SELECT | BUTTON_REL); | ||
121 | options.MENU=(BUTTON_SELECT | BUTTON_REPEAT); | ||
122 | #endif | ||
123 | |||
124 | options.maxskip=4; | ||
125 | options.fps=0; | ||
126 | options.showstats=0; | ||
127 | options.fullscreen=1; | ||
128 | options.sound=1; | ||
129 | } | ||
130 | else | ||
131 | read(fd,&options, sizeof(options)); | ||
132 | |||
133 | close(fd); | ||
134 | } | ||
135 | |||
136 | void savesettings(void) | ||
137 | { | ||
138 | int fd; | ||
139 | char optionsave[sizeof(savedir)+sizeof(optionname)]; | ||
140 | |||
141 | snprintf(optionsave, sizeof(optionsave), "%s/%s", savedir, optionname); | ||
142 | fd = open(optionsave, O_WRONLY|O_CREAT|O_TRUNC); | ||
143 | write(fd,&options, sizeof(options)); | ||
144 | close(fd); | ||
145 | } | ||
146 | |||
77 | /* this is the plugin entry point */ | 147 | /* this is the plugin entry point */ |
78 | enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | 148 | enum plugin_status plugin_start(struct plugin_api* api, void* parameter) |
79 | { | 149 | { |
@@ -96,7 +166,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
96 | < audio_buffer_free) | 166 | < audio_buffer_free) |
97 | audio_buffer_free = plugin_start_addr - (unsigned char *)audio_bufferbase; | 167 | audio_buffer_free = plugin_start_addr - (unsigned char *)audio_bufferbase; |
98 | #endif | 168 | #endif |
99 | 169 | setoptions(); | |
100 | #ifdef USE_IRAM | 170 | #ifdef USE_IRAM |
101 | memcpy(iramstart, iramcopy, iramend-iramstart); | 171 | memcpy(iramstart, iramcopy, iramend-iramstart); |
102 | memset(iedata, 0, iend - iedata); | 172 | memset(iedata, 0, iend - iedata); |
@@ -110,11 +180,13 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
110 | gnuboy_main(parameter); | 180 | gnuboy_main(parameter); |
111 | 181 | ||
112 | if(shut&&!cleanshut) { | 182 | if(shut&&!cleanshut) { |
113 | rb->splash(HZ*2, true, errormsg); | 183 | rb->splash(HZ/2, true, errormsg); |
114 | return PLUGIN_ERROR; | 184 | return PLUGIN_ERROR; |
115 | } | 185 | } |
116 | pcm_close(); | 186 | pcm_close(); |
117 | rb->splash(HZ*2, true, "Shutting down.. byebye ^^"); | 187 | rb->splash(HZ/2, true, "Shutting down"); |
188 | |||
189 | savesettings(); | ||
118 | 190 | ||
119 | cleanup(); | 191 | cleanup(); |
120 | 192 | ||
diff --git a/apps/plugins/rockboy/rockmacros.h b/apps/plugins/rockboy/rockmacros.h index c68223d478..bc9a0e8014 100644 --- a/apps/plugins/rockboy/rockmacros.h +++ b/apps/plugins/rockboy/rockmacros.h | |||
@@ -16,6 +16,8 @@ | |||
16 | * KIND, either express or implied. | 16 | * KIND, either express or implied. |
17 | * | 17 | * |
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | #ifndef __ROCKMACROS_H__ | ||
20 | #define __ROCKMACROS_H__ | ||
19 | 21 | ||
20 | #include "plugin.h" | 22 | #include "plugin.h" |
21 | 23 | ||
@@ -28,7 +30,7 @@ extern struct plugin_api* rb; | |||
28 | extern int shut,cleanshut; | 30 | extern int shut,cleanshut; |
29 | void vid_update(int scanline); | 31 | void vid_update(int scanline); |
30 | void vid_init(void); | 32 | void vid_init(void); |
31 | void vid_begin(void); | 33 | inline void vid_begin(void); |
32 | void vid_end(void); | 34 | void vid_end(void); |
33 | void die(char *message, ...); | 35 | void die(char *message, ...); |
34 | void setmallocpos(void *pointer); | 36 | void setmallocpos(void *pointer); |
@@ -38,7 +40,7 @@ int sys_elapsed(long *oldtick); | |||
38 | void sys_sleep(int us); | 40 | void sys_sleep(int us); |
39 | int pcm_submit(void); | 41 | int pcm_submit(void); |
40 | void pcm_init(void); | 42 | void pcm_init(void); |
41 | void doevents(void); | 43 | void doevents(void) ICODE_ATTR; |
42 | void ev_poll(void); | 44 | void ev_poll(void); |
43 | int do_user_menu(void); | 45 | int do_user_menu(void); |
44 | void loadstate(int fd); | 46 | void loadstate(int fd); |
@@ -60,6 +62,8 @@ void savestate(int fd); | |||
60 | #define mkdir(a,b) rb->sim_mkdir((a),(b)) | 62 | #define mkdir(a,b) rb->sim_mkdir((a),(b)) |
61 | #undef open | 63 | #undef open |
62 | #define open(a,b) rb->sim_open((a),(b)) | 64 | #define open(a,b) rb->sim_open((a),(b)) |
65 | #undef close | ||
66 | #define close(a) rb->sim_close((a)) | ||
63 | #undef lseek | 67 | #undef lseek |
64 | #define lseek(a,b,c) rb->sim_lseek((a),(b),(c)) | 68 | #define lseek(a,b,c) rb->sim_lseek((a),(b),(c)) |
65 | #else /* !SIMULATOR */ | 69 | #else /* !SIMULATOR */ |
@@ -68,6 +72,7 @@ void savestate(int fd); | |||
68 | #define mkdir(a,b) rb->mkdir((a),(b)) | 72 | #define mkdir(a,b) rb->mkdir((a),(b)) |
69 | #define open(a,b) rb->open((a),(b)) | 73 | #define open(a,b) rb->open((a),(b)) |
70 | #define lseek(a,b,c) rb->lseek((a),(b),(c)) | 74 | #define lseek(a,b,c) rb->lseek((a),(b),(c)) |
75 | #define close(a) rb->close((a)) | ||
71 | #endif /* !SIMULATOR */ | 76 | #endif /* !SIMULATOR */ |
72 | 77 | ||
73 | #define strcat(a,b) rb->strcat((a),(b)) | 78 | #define strcat(a,b) rb->strcat((a),(b)) |
@@ -93,5 +98,13 @@ void savestate(int fd); | |||
93 | /* Using #define isn't enough with GCC 4.0.1 */ | 98 | /* Using #define isn't enough with GCC 4.0.1 */ |
94 | void* memcpy(void* dst, const void* src, size_t size); | 99 | void* memcpy(void* dst, const void* src, size_t size); |
95 | 100 | ||
96 | extern int frameskip; | 101 | struct options { |
97 | extern bool sound; | 102 | int A, B, START, SELECT, MENU; |
103 | int frameskip, fps, maxskip; | ||
104 | bool sound, fullscreen, showstats; | ||
105 | }; | ||
106 | |||
107 | extern struct options options; | ||
108 | #define savedir "/.rockbox/rockboy" | ||
109 | |||
110 | #endif | ||
diff --git a/apps/plugins/rockboy/rtc.c b/apps/plugins/rockboy/rtc.c index 51c641cdce..05ad69864a 100644 --- a/apps/plugins/rockboy/rtc.c +++ b/apps/plugins/rockboy/rtc.c | |||
@@ -9,7 +9,7 @@ | |||
9 | #include "rtc-gb.h" | 9 | #include "rtc-gb.h" |
10 | #include "rc.h" | 10 | #include "rc.h" |
11 | 11 | ||
12 | struct rtc rtc; | 12 | struct rtc rtc IBSS_ATTR; |
13 | 13 | ||
14 | static int syncrtc = 1; | 14 | static int syncrtc = 1; |
15 | 15 | ||
diff --git a/apps/plugins/rockboy/sound.c b/apps/plugins/rockboy/sound.c index 58cbe542f9..deeacc7bbf 100644 --- a/apps/plugins/rockboy/sound.c +++ b/apps/plugins/rockboy/sound.c | |||
@@ -49,7 +49,7 @@ static const int freqtab[8] = | |||
49 | (1<<14)/7 | 49 | (1<<14)/7 |
50 | }; | 50 | }; |
51 | 51 | ||
52 | struct snd snd; | 52 | struct snd snd IBSS_ATTR; |
53 | int pcm_submit(void); | 53 | int pcm_submit(void); |
54 | 54 | ||
55 | #define RATE (snd.rate) | 55 | #define RATE (snd.rate) |
@@ -161,7 +161,7 @@ void sound_reset(void) | |||
161 | void sound_mix(void) | 161 | void sound_mix(void) |
162 | { | 162 | { |
163 | 163 | ||
164 | if (!sound) return; | 164 | if (!options.sound) return; |
165 | int s, l, r, f, n; | 165 | int s, l, r, f, n; |
166 | 166 | ||
167 | if (!RATE || cpu.snd < RATE) return; | 167 | if (!RATE || cpu.snd < RATE) return; |
@@ -289,7 +289,7 @@ void sound_mix(void) | |||
289 | 289 | ||
290 | byte sound_read(byte r) | 290 | byte sound_read(byte r) |
291 | { | 291 | { |
292 | if(!sound) return 0; | 292 | if(!options.sound) return 0; |
293 | sound_mix(); | 293 | sound_mix(); |
294 | /* printf("read %02X: %02X\n", r, REG(r)); */ | 294 | /* printf("read %02X: %02X\n", r, REG(r)); */ |
295 | return REG(r); | 295 | return REG(r); |
@@ -346,7 +346,7 @@ void s4_init(void) | |||
346 | 346 | ||
347 | void sound_write(byte r, byte b) | 347 | void sound_write(byte r, byte b) |
348 | { | 348 | { |
349 | if(!sound) return; | 349 | if(!options.sound) return; |
350 | #if 0 | 350 | #if 0 |
351 | static void *timer; | 351 | static void *timer; |
352 | if (!timer) timer = sys_timer(); | 352 | if (!timer) timer = sys_timer(); |
diff --git a/apps/plugins/rockboy/sound.h b/apps/plugins/rockboy/sound.h index f4791127a8..18fb371580 100644 --- a/apps/plugins/rockboy/sound.h +++ b/apps/plugins/rockboy/sound.h | |||
@@ -27,12 +27,12 @@ struct snd | |||
27 | 27 | ||
28 | extern struct snd snd; | 28 | extern struct snd snd; |
29 | 29 | ||
30 | byte sound_read(byte r); | 30 | byte sound_read(byte r) ICODE_ATTR; |
31 | void sound_write(byte r, byte b); | 31 | void sound_write(byte r, byte b)ICODE_ATTR; |
32 | void sound_dirty(void); | 32 | void sound_dirty(void)ICODE_ATTR; |
33 | void sound_off(void); | 33 | void sound_off(void); |
34 | void sound_reset(void); | 34 | void sound_reset(void); |
35 | void sound_mix(void); | 35 | void sound_mix(void)ICODE_ATTR; |
36 | void s1_init(void); | 36 | void s1_init(void); |
37 | void s2_init(void); | 37 | void s2_init(void); |
38 | void s3_init(void); | 38 | void s3_init(void); |
diff --git a/apps/plugins/rockboy/sys_rockbox.c b/apps/plugins/rockboy/sys_rockbox.c index 53fe19b199..578a864ca0 100644 --- a/apps/plugins/rockboy/sys_rockbox.c +++ b/apps/plugins/rockboy/sys_rockbox.c | |||
@@ -25,8 +25,6 @@ | |||
25 | #include "hw.h" | 25 | #include "hw.h" |
26 | #include "config.h" | 26 | #include "config.h" |
27 | 27 | ||
28 | int frameskip; | ||
29 | |||
30 | rcvar_t joy_exports[] = | 28 | rcvar_t joy_exports[] = |
31 | { | 29 | { |
32 | RCV_END | 30 | RCV_END |
@@ -43,7 +41,7 @@ extern int debug_trace; | |||
43 | 41 | ||
44 | void vid_settitle(char *title) | 42 | void vid_settitle(char *title) |
45 | { | 43 | { |
46 | rb->splash(HZ*2, true, title); | 44 | rb->splash(HZ/2, true, title); |
47 | } | 45 | } |
48 | 46 | ||
49 | void joy_init(void) | 47 | void joy_init(void) |
@@ -54,36 +52,6 @@ void joy_close(void) | |||
54 | { | 52 | { |
55 | } | 53 | } |
56 | 54 | ||
57 | #if (CONFIG_KEYPAD == IRIVER_H100_PAD) | ||
58 | #define ROCKBOY_PAD_A BUTTON_ON | ||
59 | #define ROCKBOY_PAD_B BUTTON_OFF | ||
60 | #define ROCKBOY_PAD_START BUTTON_REC | ||
61 | #define ROCKBOY_PAD_SELECT BUTTON_SELECT | ||
62 | #define ROCKBOY_MENU BUTTON_MODE | ||
63 | |||
64 | #elif (CONFIG_KEYPAD == IRIVER_H300_PAD) | ||
65 | #define ROCKBOY_PAD_A BUTTON_REC | ||
66 | #define ROCKBOY_PAD_B BUTTON_MODE | ||
67 | #define ROCKBOY_PAD_START BUTTON_ON | ||
68 | #define ROCKBOY_PAD_SELECT BUTTON_SELECT | ||
69 | #define ROCKBOY_MENU BUTTON_OFF | ||
70 | |||
71 | #elif CONFIG_KEYPAD == RECORDER_PAD | ||
72 | #define ROCKBOY_PAD_A BUTTON_F1 | ||
73 | #define ROCKBOY_PAD_B BUTTON_F2 | ||
74 | #define ROCKBOY_PAD_START BUTTON_F3 | ||
75 | #define ROCKBOY_PAD_SELECT BUTTON_PLAY | ||
76 | #define ROCKBOY_MENU BUTTON_OFF | ||
77 | |||
78 | #elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD | ||
79 | #define ROCKBOY_PAD_A BUTTON_PLAY | ||
80 | #define ROCKBOY_PAD_B BUTTON_EQ | ||
81 | #define ROCKBOY_PAD_START BUTTON_MODE | ||
82 | #define ROCKBOY_PAD_SELECT (BUTTON_SELECT | BUTTON_REL) | ||
83 | #define ROCKBOY_MENU (BUTTON_SELECT | BUTTON_REPEAT) | ||
84 | |||
85 | #endif | ||
86 | |||
87 | unsigned int oldbuttonstate = 0, newbuttonstate,holdbutton; | 55 | unsigned int oldbuttonstate = 0, newbuttonstate,holdbutton; |
88 | 56 | ||
89 | int released, pressed; | 57 | int released, pressed; |
@@ -109,13 +77,13 @@ void ev_poll(void) | |||
109 | if(released & BUTTON_RIGHT) {ev.code=PAD_RIGHT; ev_postevent(&ev);} | 77 | if(released & BUTTON_RIGHT) {ev.code=PAD_RIGHT; ev_postevent(&ev);} |
110 | if(released & BUTTON_DOWN) { ev.code=PAD_DOWN; ev_postevent(&ev); } | 78 | if(released & BUTTON_DOWN) { ev.code=PAD_DOWN; ev_postevent(&ev); } |
111 | if(released & BUTTON_UP) { ev.code=PAD_UP; ev_postevent(&ev); } | 79 | if(released & BUTTON_UP) { ev.code=PAD_UP; ev_postevent(&ev); } |
112 | if(released & ROCKBOY_PAD_A) { ev.code=PAD_A; ev_postevent(&ev); } | 80 | if(released & options.A) { ev.code=PAD_A; ev_postevent(&ev); } |
113 | if(released & ROCKBOY_PAD_B) { ev.code=PAD_B; ev_postevent(&ev); } | 81 | if(released & options.B) { ev.code=PAD_B; ev_postevent(&ev); } |
114 | if(released & ROCKBOY_PAD_START) { | 82 | if(released & options.START) { |
115 | ev.code=PAD_START; | 83 | ev.code=PAD_START; |
116 | ev_postevent(&ev); | 84 | ev_postevent(&ev); |
117 | } | 85 | } |
118 | if(released & ROCKBOY_PAD_SELECT) { | 86 | if(released & options.SELECT) { |
119 | ev.code=PAD_SELECT; | 87 | ev.code=PAD_SELECT; |
120 | ev_postevent(&ev); | 88 | ev_postevent(&ev); |
121 | } | 89 | } |
@@ -126,17 +94,17 @@ void ev_poll(void) | |||
126 | if(pressed & BUTTON_RIGHT) { ev.code=PAD_RIGHT; ev_postevent(&ev);} | 94 | if(pressed & BUTTON_RIGHT) { ev.code=PAD_RIGHT; ev_postevent(&ev);} |
127 | if(pressed & BUTTON_DOWN) { ev.code=PAD_DOWN; ev_postevent(&ev); } | 95 | if(pressed & BUTTON_DOWN) { ev.code=PAD_DOWN; ev_postevent(&ev); } |
128 | if(pressed & BUTTON_UP) { ev.code=PAD_UP; ev_postevent(&ev); } | 96 | if(pressed & BUTTON_UP) { ev.code=PAD_UP; ev_postevent(&ev); } |
129 | if(pressed & ROCKBOY_PAD_A) { ev.code=PAD_A; ev_postevent(&ev); } | 97 | if(pressed & options.A) { ev.code=PAD_A; ev_postevent(&ev); } |
130 | if(pressed & ROCKBOY_PAD_B) { ev.code=PAD_B; ev_postevent(&ev); } | 98 | if(pressed & options.B) { ev.code=PAD_B; ev_postevent(&ev); } |
131 | if(pressed & ROCKBOY_PAD_START) { | 99 | if(pressed & options.START) { |
132 | ev.code=PAD_START; | 100 | ev.code=PAD_START; |
133 | ev_postevent(&ev); | 101 | ev_postevent(&ev); |
134 | } | 102 | } |
135 | if(pressed & ROCKBOY_PAD_SELECT) { | 103 | if(pressed & options.SELECT) { |
136 | ev.code=PAD_SELECT; | 104 | ev.code=PAD_SELECT; |
137 | ev_postevent(&ev); | 105 | ev_postevent(&ev); |
138 | } | 106 | } |
139 | if(pressed & ROCKBOY_MENU) { | 107 | if(pressed & options.MENU) { |
140 | #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD) | 108 | #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD) |
141 | if (do_user_menu() == USER_MENU_QUIT) | 109 | if (do_user_menu() == USER_MENU_QUIT) |
142 | #endif | 110 | #endif |
@@ -157,11 +125,17 @@ void vid_setpal(int i, int r, int g, int b) | |||
157 | (void)b; | 125 | (void)b; |
158 | } | 126 | } |
159 | 127 | ||
160 | void vid_begin(void) // This frameskip code is borrowed from the GNUboyCE project | 128 | inline void vid_begin(void) // New frameskip, makes more sense to me and performs as well |
161 | { | 129 | { |
162 | static int skip = 0; | 130 | static int skip = 0; |
163 | skip = (skip + 1) % (frameskip > 0 ? frameskip + 1 : 1); | 131 | if (skip<options.frameskip) { |
164 | fb.enabled = skip == 0; | 132 | skip++; |
133 | fb.enabled=0; | ||
134 | } | ||
135 | else { | ||
136 | skip=0; | ||
137 | fb.enabled=1; | ||
138 | } | ||
165 | } | 139 | } |
166 | 140 | ||
167 | void vid_init(void) | 141 | void vid_init(void) |
@@ -173,7 +147,7 @@ void vid_init(void) | |||
173 | fb.dirty=0; | 147 | fb.dirty=0; |
174 | fb.mode=3; | 148 | fb.mode=3; |
175 | 149 | ||
176 | frameskip=2; | 150 | fb.ptr=rb->lcd_framebuffer; |
177 | 151 | ||
178 | #if defined(HAVE_LCD_COLOR) | 152 | #if defined(HAVE_LCD_COLOR) |
179 | fb.pelsize=2; // 16 bit framebuffer | 153 | fb.pelsize=2; // 16 bit framebuffer |
@@ -193,13 +167,12 @@ void vid_init(void) | |||
193 | #endif | 167 | #endif |
194 | } | 168 | } |
195 | 169 | ||
170 | #if LCD_HEIGHT<144 | ||
196 | fb_data *frameb; | 171 | fb_data *frameb; |
197 | void vid_update(int scanline) | 172 | void vid_update(int scanline) |
198 | { | 173 | { |
199 | register int cnt=0; | 174 | register int cnt=0; |
200 | #if LCD_HEIGHT < 144 | ||
201 | int scanline_remapped; | 175 | int scanline_remapped; |
202 | #endif | ||
203 | #if (LCD_HEIGHT == 64) && (LCD_DEPTH == 1) /* Archos */ | 176 | #if (LCD_HEIGHT == 64) && (LCD_DEPTH == 1) /* Archos */ |
204 | int balance = 0; | 177 | int balance = 0; |
205 | if (fb.mode==1) | 178 | if (fb.mode==1) |
@@ -292,13 +265,10 @@ void vid_update(int scanline) | |||
292 | } | 265 | } |
293 | rb->lcd_update_rect(0, scanline & ~3, LCD_WIDTH, 4); | 266 | rb->lcd_update_rect(0, scanline & ~3, LCD_WIDTH, 4); |
294 | #elif (LCD_HEIGHT >= 144) && defined(HAVE_LCD_COLOR) /* iriver H3x0, colour iPod */ | 267 | #elif (LCD_HEIGHT >= 144) && defined(HAVE_LCD_COLOR) /* iriver H3x0, colour iPod */ |
295 | frameb = rb->lcd_framebuffer + (scanline + (LCD_HEIGHT-144)/2) * LCD_WIDTH + (LCD_WIDTH-160)/2;; | 268 | // handled in lcd.c now |
296 | while (cnt < 160) | ||
297 | *frameb++ = scan.pal2[scan.buf[cnt++]]; | ||
298 | if(scanline==143) | ||
299 | rb->lcd_update(); // this seems faster then doing individual scanlines | ||
300 | #endif /* LCD_HEIGHT */ | 269 | #endif /* LCD_HEIGHT */ |
301 | } | 270 | } |
271 | #endif | ||
302 | 272 | ||
303 | void vid_end(void) | 273 | void vid_end(void) |
304 | { | 274 | { |
@@ -307,19 +277,30 @@ void vid_end(void) | |||
307 | long timerresult; | 277 | long timerresult; |
308 | 278 | ||
309 | void *sys_timer(void) | 279 | void *sys_timer(void) |
310 | { | 280 | {/* |
311 | timerresult=*rb->current_tick; | 281 | timerresult=*rb->current_tick; |
312 | return &timerresult; | 282 | return &timerresult;*/ |
283 | return 0; | ||
313 | } | 284 | } |
314 | 285 | ||
315 | // returns microseconds passed since sys_timer | 286 | // returns microseconds passed since sys_timer |
316 | int sys_elapsed(long *oldtick) | 287 | int sys_elapsed(long *oldtick) |
317 | { | 288 | { |
318 | return ((*rb->current_tick-(*oldtick))*1000000)/HZ; | 289 | /* |
290 | int elap,mytime=microtick; | ||
291 | |||
292 | elap=mytime-*oldtick; | ||
293 | *oldtick=mytime; | ||
294 | return elap;*/ | ||
295 | // return ((*rb->current_tick-(*oldtick))*1000000)/HZ; | ||
296 | return *oldtick; | ||
319 | } | 297 | } |
320 | 298 | ||
321 | void sys_sleep(int us) | 299 | void sys_sleep(int us) |
322 | { | 300 | { |
323 | if (us <= 0) return; | 301 | if(us<=0) return; |
324 | // rb->sleep(HZ*us/1000000); | 302 | int i=0; |
303 | while(i< us*11) | ||
304 | i++; | ||
305 | // if (us <= 0) return; | ||
325 | } | 306 | } |