summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2006-01-20 13:05:52 +0000
committerDaniel Stenberg <daniel@haxx.se>2006-01-20 13:05:52 +0000
commit137fb6cb9f0478303610443b95ae0a106f0a17d1 (patch)
tree9ac6685589536bc7c84962db8398fddf9d2b3154 /apps/plugins
parentc05cd1676f323f1346099f436aaa0212fd18e178 (diff)
downloadrockbox-137fb6cb9f0478303610443b95ae0a106f0a17d1.zip
rockbox-137fb6cb9f0478303610443b95ae0a106f0a17d1.tar.gz
rockbox-137fb6cb9f0478303610443b95ae0a106f0a17d1.tar.bz2
rockbox-137fb6cb9f0478303610443b95ae0a106f0a17d1.tar.xz
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
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/rockboy/Makefile6
-rw-r--r--apps/plugins/rockboy/cpu-gb.h12
-rw-r--r--apps/plugins/rockboy/cpu.c4
-rw-r--r--apps/plugins/rockboy/cpucore.h16
-rw-r--r--apps/plugins/rockboy/emu.c41
-rw-r--r--apps/plugins/rockboy/fastmem.c4
-rw-r--r--apps/plugins/rockboy/fastmem.h12
-rw-r--r--apps/plugins/rockboy/fb.h2
-rw-r--r--apps/plugins/rockboy/hw.h16
-rw-r--r--apps/plugins/rockboy/input.h4
-rw-r--r--apps/plugins/rockboy/lcd-gb.h26
-rw-r--r--apps/plugins/rockboy/lcd.c113
-rw-r--r--apps/plugins/rockboy/lcdc.h8
-rw-r--r--apps/plugins/rockboy/loader.c7
-rw-r--r--apps/plugins/rockboy/main.c2
-rw-r--r--apps/plugins/rockboy/mem.c2
-rw-r--r--apps/plugins/rockboy/mem.h10
-rw-r--r--apps/plugins/rockboy/menu.c71
-rw-r--r--apps/plugins/rockboy/noise.h4
-rw-r--r--apps/plugins/rockboy/palette.h12
-rw-r--r--apps/plugins/rockboy/rbsound.c113
-rw-r--r--apps/plugins/rockboy/rockboy.c78
-rw-r--r--apps/plugins/rockboy/rockmacros.h21
-rw-r--r--apps/plugins/rockboy/rtc.c2
-rw-r--r--apps/plugins/rockboy/sound.c8
-rw-r--r--apps/plugins/rockboy/sound.h8
-rw-r--r--apps/plugins/rockboy/sys_rockbox.c101
27 files changed, 490 insertions, 213 deletions
diff --git a/apps/plugins/rockboy/Makefile b/apps/plugins/rockboy/Makefile
index f0dbc55..d9d3107 100644
--- a/apps/plugins/rockboy/Makefile
+++ b/apps/plugins/rockboy/Makefile
@@ -9,8 +9,8 @@
INCLUDES = -I$(APPSDIR) -I.. -I. -I$(FIRMDIR)/include -I$(FIRMDIR)/export \
-I$(FIRMDIR)/common -I$(FIRMDIR)/drivers -I$(OUTDIR) -I$(BUILDDIR)
-CFLAGS = $(GCCOPTS) -O3 $(INCLUDES) $(TARGET) $(EXTRA_DEFINES) \
- -DTARGET_ID=$(TARGET_ID) -DMEM=${MEMORYSIZE} -DPLUGIN
+CFLAGS = $(GCCOPTS) -O2 $(INCLUDES) $(TARGET) $(EXTRA_DEFINES) \
+ -DTARGET_ID=$(TARGET_ID) -DMEM=${MEMORYSIZE} -DPLUGIN -finline-functions
ifdef APPEXTRA
INCLUDES += $(patsubst %,-I$(APPSDIR)/%,$(subst :, ,$(APPEXTRA)))
@@ -48,7 +48,7 @@ all: $(OUTPUT)
ifndef SIMVER
$(OBJDIR)/rockboy.elf: $(OBJS) $(LINKFILE)
@echo "LD "`basename $@`
- @$(CC) $(GCCOPTS) -O -nostdlib -o $@ $(OBJS) -L$(BUILDDIR) -lplugin -lgcc \
+ @$(CC) $(GCCOPTS) -O2 -nostdlib -o $@ $(OBJS) -L$(BUILDDIR) -lplugin -fast -lgcc \
-T$(LINKFILE) -Wl,-Map,$(OBJDIR)/rockboy.map
$(OUTPUT): $(OBJDIR)/rockboy.elf
diff --git a/apps/plugins/rockboy/cpu-gb.h b/apps/plugins/rockboy/cpu-gb.h
index 937b477..dfb8734 100644
--- a/apps/plugins/rockboy/cpu-gb.h
+++ b/apps/plugins/rockboy/cpu-gb.h
@@ -48,12 +48,12 @@ extern int blockclen;
#endif
void cpu_reset(void);
-void div_advance(int cnt);
-void timer_advance(int cnt);
-void lcdc_advance(int cnt);
-void sound_advance(int cnt);
-void cpu_timers(int cnt);
+void div_advance(int cnt) ICODE_ATTR;
+void timer_advance(int cnt) ICODE_ATTR;
+void lcdc_advance(int cnt) ICODE_ATTR;
+void sound_advance(int cnt) ICODE_ATTR;
+void cpu_timers(int cnt) ICODE_ATTR;
int cpu_emulate(int cycles) ICODE_ATTR;
-int cpu_step(int max) ICODE_ATTR;
+inline int cpu_step(int max);
#endif
diff --git a/apps/plugins/rockboy/cpu.c b/apps/plugins/rockboy/cpu.c
index 5c4abc5..a09beaf 100644
--- a/apps/plugins/rockboy/cpu.c
+++ b/apps/plugins/rockboy/cpu.c
@@ -1006,9 +1006,9 @@ next:
#ifndef ASM_CPU_STEP
-int cpu_step(int max)
+inline int cpu_step(int max)
{
- int cnt;
+ register int cnt;
if ((cnt = cpu_idle(max))) return cnt;
return cpu_emulate(1);
}
diff --git a/apps/plugins/rockboy/cpucore.h b/apps/plugins/rockboy/cpucore.h
index 361c106..a0c6a12 100644
--- a/apps/plugins/rockboy/cpucore.h
+++ b/apps/plugins/rockboy/cpucore.h
@@ -2,7 +2,7 @@
#include "defs.h"
-static const byte cycles_table[256] =
+static const byte cycles_table[256]ICONST_ATTR =
{
1, 3, 2, 2, 1, 1, 2, 1, 5, 2, 2, 2, 1, 1, 2, 1,
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] =
3, 3, 2, 1, 0, 4, 2, 4, 3, 2, 4, 1, 0, 0, 2, 4,
};
-static const byte cb_cycles_table[256] =
+static const byte cb_cycles_table[256] ICONST_ATTR =
{
2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 4, 2,
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] =
-static const byte zflag_table[256] =
+static const byte zflag_table[256] ICONST_ATTR =
{
FZ, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
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] =
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
-static const byte incflag_table[256] =
+static const byte incflag_table[256] ICONST_ATTR =
{
FZ|FH, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
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] =
FH, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
-static const byte decflag_table[256] =
+static const byte decflag_table[256] ICONST_ATTR =
{
FZ|FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN|FH,
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] =
FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN, FN|FH
};
-static const byte swap_table[256] =
+static const byte swap_table[256] ICONST_ATTR =
{
0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0,
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] =
0x0F, 0x1F, 0x2F, 0x3F, 0x4F, 0x5F, 0x6F, 0x7F, 0x8F, 0x9F, 0xAF, 0xBF, 0xCF, 0xDF, 0xEF, 0xFF,
};
-static const byte daa_table[4096] =
+static const byte daa_table[4096] ICONST_ATTR=
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
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] =
0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A,
};
-static const byte daa_carry_table[64] =
+static const byte daa_carry_table[64] ICONST_ATTR =
{
00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00,
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 cf37d9b..2af4e52 100644
--- a/apps/plugins/rockboy/emu.c
+++ b/apps/plugins/rockboy/emu.c
@@ -58,15 +58,16 @@ void emu_step(void)
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 delay;
+// void *timer = sys_timer();
+ int framesin=0,frames=0,timeten=*rb->current_tick, timehun=*rb->current_tick;
+// int delay;
vid_begin();
lcd_begin();
@@ -79,18 +80,17 @@ void emu_run(void)
while (R_LY > 0 && R_LY < 144)
emu_step();
- vid_end();
rtc_tick();
sound_mix();
if (!pcm_submit())
{
- delay = framelen - sys_elapsed(timer);
+/* delay = framelen - sys_elapsed(timer);
sys_sleep(delay);
- sys_elapsed(timer);
+ sys_elapsed(timer);*/
}
+
doevents();
vid_begin();
-// if (framecount) { if (!--framecount) die("finished\n"); }
if (!(R_LCDC & 0x80))
cpu_emulate(32832);
@@ -98,11 +98,34 @@ void emu_run(void)
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;
+ }
+ }
+
+ }
+
#if !defined(SIMULATOR) && defined(HAVE_ADJUSTABLE_CPU_FREQ)
rb->cpu_boost(false);
#endif
-
}
diff --git a/apps/plugins/rockboy/fastmem.c b/apps/plugins/rockboy/fastmem.c
index d883438..7f5b0b4 100644
--- a/apps/plugins/rockboy/fastmem.c
+++ b/apps/plugins/rockboy/fastmem.c
@@ -14,7 +14,7 @@
const byte himask[256];
-const byte hi_rmap[256] =
+const byte hi_rmap[256] ICONST_ATTR =
{
0, 0, R, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
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] =
C, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
-const byte hi_wmap[256] =
+const byte hi_wmap[256] ICONST_ATTR =
{
R, R, R, R, R, R, R, R, R, R, R, R, R, R, R, R,
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 7ab447f..e36eb20 100644
--- a/apps/plugins/rockboy/fastmem.h
+++ b/apps/plugins/rockboy/fastmem.h
@@ -7,12 +7,12 @@
#include "mem.h"
-byte readb(int a);
-void writeb(int a, byte b);
-int readw(int a);
-void writew(int a, int w);
-byte readhi(int a);
-void writehi(int a, byte b);
+byte readb(int a) ICODE_ATTR;
+void writeb(int a, byte b) ICODE_ATTR;
+int readw(int a) ICODE_ATTR;
+void writew(int a, int w) ICODE_ATTR;
+byte readhi(int a) ICODE_ATTR;
+void writehi(int a, byte b) ICODE_ATTR;
#if 0
byte readhi(int a);
void writehi(int a, byte b);
diff --git a/apps/plugins/rockboy/fb.h b/apps/plugins/rockboy/fb.h
index b569fb8..d70708e 100644
--- a/apps/plugins/rockboy/fb.h
+++ b/apps/plugins/rockboy/fb.h
@@ -10,7 +10,7 @@
struct fb
{
- byte *ptr;
+ fb_data *ptr;
int w, h;
int pelsize;
int pitch;
diff --git a/apps/plugins/rockboy/hw.h b/apps/plugins/rockboy/hw.h
index d05fb51..5bc1230 100644
--- a/apps/plugins/rockboy/hw.h
+++ b/apps/plugins/rockboy/hw.h
@@ -34,14 +34,14 @@ struct hw
extern struct hw hw;
-void hw_interrupt(byte i, byte mask);
-void hw_dma(byte b);
-void hw_hdma_cmd(byte c);
-void hw_hdma(void);
-void pad_refresh(void);
-void pad_press(byte k);
-void pad_release(byte k);
-void pad_set(byte k, int st);
+void hw_interrupt(byte i, byte mask) ICODE_ATTR;
+void hw_dma(byte b) ICODE_ATTR;
+void hw_hdma_cmd(byte c) ICODE_ATTR;
+void hw_hdma(void) ICODE_ATTR;
+void pad_refresh(void)ICODE_ATTR;
+void pad_press(byte k)ICODE_ATTR;
+void pad_release(byte k)ICODE_ATTR;
+void pad_set(byte k, int st)ICODE_ATTR;
void hw_reset(void);
#endif
diff --git a/apps/plugins/rockboy/input.h b/apps/plugins/rockboy/input.h
index 8c5fdf9..b574049 100644
--- a/apps/plugins/rockboy/input.h
+++ b/apps/plugins/rockboy/input.h
@@ -18,7 +18,7 @@ typedef struct event_s
#define EV_RELEASE 2
#define EV_REPEAT 3
-int ev_postevent(event_t *ev);
-int ev_getevent(event_t *ev);
+int ev_postevent(event_t *ev) ICODE_ATTR;
+int ev_getevent(event_t *ev) ICODE_ATTR;
diff --git a/apps/plugins/rockboy/lcd-gb.h b/apps/plugins/rockboy/lcd-gb.h
index 9f1b890..c02e670 100644
--- a/apps/plugins/rockboy/lcd-gb.h
+++ b/apps/plugins/rockboy/lcd-gb.h
@@ -55,21 +55,21 @@ extern struct scan scan;
void updatepatpix(void) ICODE_ATTR;
-void tilebuf(void);
-void bg_scan(void);
-void wnd_scan(void);
-void bg_scan_pri(void);
-void wnd_scan_pri(void);
+void tilebuf(void) ICODE_ATTR;
+void bg_scan(void) ICODE_ATTR;
+void wnd_scan(void) ICODE_ATTR;
+void bg_scan_pri(void) ICODE_ATTR;
+void wnd_scan_pri(void) ICODE_ATTR;
void spr_count(void);
-void spr_enum(void);
-void spr_scan(void);
-void lcd_begin(void);
-void lcd_refreshline(void);
+void spr_enum(void) ICODE_ATTR;
+void spr_scan(void) ICODE_ATTR;
+void lcd_begin(void) ICODE_ATTR;
+void lcd_refreshline(void) ICODE_ATTR;
void pal_write(int i, byte b);
-void pal_write_dmg(int i, int mapnum, byte d);
-void vram_write(int a, byte b);
-void vram_dirty(void);
-void pal_dirty(void);
+void pal_write_dmg(int i, int mapnum, byte d) ICODE_ATTR;
+void vram_write(int a, byte b) ICODE_ATTR;
+void vram_dirty(void) ICODE_ATTR;
+void pal_dirty(void) ICODE_ATTR;
void lcd_reset(void);
#endif
diff --git a/apps/plugins/rockboy/lcd.c b/apps/plugins/rockboy/lcd.c
index 4cd4ddc..c1a7a87 100644
--- a/apps/plugins/rockboy/lcd.c
+++ b/apps/plugins/rockboy/lcd.c
@@ -94,7 +94,7 @@ rcvar_t lcd_exports[] =
RCV_END
};
-static byte *vdest;
+fb_data *vdest;
#ifdef ALLOW_UNALIGNED_IO /* long long is ok since this is i386-only anyway? */
#define MEMCPY8(d, s) ((*(long long *)(d)) = (*(long long *)(s)))
@@ -532,9 +532,21 @@ void bg_scan(void)
if (cnt <= 0) return;
while (cnt >= 8)
{
+#if CONFIG_CPU == MCF5249 && !defined(SIMULATOR)
+ asm volatile (
+ "move.l (%1)+,(%0)+ \n"
+ "move.l (%1)+,(%0)+ \n"
+ : /*outputs*/
+ : /*inputs*/
+ /* %0 */ "a" (dest),
+ /* %1 */ "a" (patpix[*(tile++)][V])
+ //: /* clobbers */
+ );
+#else
src = patpix[*(tile++)][V];
MEMCPY8(dest, src);
dest += 8;
+#endif
cnt -= 8;
}
src = patpix[*tile][V];
@@ -555,9 +567,21 @@ void wnd_scan(void)
while (cnt >= 8)
{
+#if CONFIG_CPU == MCF5249 && !defined(SIMULATOR)
+ asm volatile (
+ "move.l (%1)+,(%0)+ \n"
+ "move.l (%1)+,(%0)+ \n"
+ : /*outputs*/
+ : /*inputs*/
+ /* %0 */ "a" (dest),
+ /* %1 */ "a" (patpix[*(tile++)][WV])
+ //: /* clobbers */
+ );
+#else
src = patpix[*(tile++)][WV];
MEMCPY8(dest, src);
dest += 8;
+#endif
cnt -= 8;
}
src = patpix[*tile][WV];
@@ -651,8 +675,55 @@ void bg_scan_color(void)
while (cnt >= 8)
{
src = patpix[*(tile++)][V];
+#if CONFIG_CPU == MCF5249 && !defined(SIMULATOR)
+ asm volatile (
+ "move.l (%2)+,%%d1 \n"
+
+ "move.b %%d1,%%d2 \n"
+
+ "move.b (%1)+,%%d0 \n"
+ "or.l %%d2,%%d0 \n"
+ "move.b %%d0,(%0)+ \n"
+
+ "move.b (%1)+,%%d0 \n"
+ "or.l %%d1,%%d0 \n"
+ "move.b %%d0,(%0)+ \n"
+
+ "move.b (%1)+,%%d0 \n"
+ "or.l %%d2,%%d0 \n"
+ "move.b %%d0,(%0)+ \n"
+
+ "move.b (%1)+,%%d0 \n"
+ "or.l %%d2,%%d0 \n"
+ "move.b %%d0,(%0)+ \n"
+
+ "move.b (%1)+,%%d0 \n"
+ "or.l %%d2,%%d0 \n"
+ "move.b %%d0,(%0)+ \n"
+
+ "move.b (%1)+,%%d0 \n"
+ "or.l %%d2,%%d0 \n"
+ "move.b %%d0,(%0)+ \n"
+
+ "move.b (%1)+,%%d0 \n"
+ "or.l %%d2,%%d0 \n"
+ "move.b %%d0,(%0)+ \n"
+
+ "move.b (%1)+,%%d0 \n"
+ "or.l %%d2,%%d0 \n"
+ "move.b %%d0,(%0)+ \n"
+ : /*outputs*/
+ : /*inputs*/
+ /* %0 */ "a" (dest),
+ /* %1 */ "a" (src),
+ /* %2 */ "a" (tile)
+ : /* clobbers */
+ "d0", "d1", "d2"
+);
+#else
blendcpy(dest, src, *(tile++), 8);
dest += 8;
+#endif
cnt -= 8;
}
src = patpix[*(tile++)][V];
@@ -843,14 +914,21 @@ void lcd_begin(void)
else pal_expire();
}
while (scale * 160 > fb.w || scale * 144 > fb.h) scale--; */
- vdest = fb.ptr + ((fb.w*fb.pelsize)>>1)
- - (80*fb.pelsize)
- + ((fb.h>>1) - 72) * fb.pitch;
+ if(options.fullscreen)
+ vdest = fb.ptr;
+ else
+ vdest = fb.ptr + ((LCD_HEIGHT-144)/2)*LCD_WIDTH + ((LCD_WIDTH-160)/2);
+
WY = R_WY;
}
+char frameout[25];
void lcd_refreshline(void)
{
+#if LCD_HEIGHT>=144
+ int cnt=0, two;
+#endif
+
if (!fb.enabled) return;
if(!insync) {
if(R_LY!=0)
@@ -924,7 +1002,32 @@ void lcd_refreshline(void)
else
vid_update(L-((int)(L/9)));
#else
- vid_update(L);
+
+ for(two=0;two<( (options.showstats ? (L&0x07)==0x05 : (L&0x07)==0x05 || (L&0x0F)==0x08) && options.fullscreen)+1;two++)
+ {
+ while (cnt < 160)
+ {
+ *vdest++ = scan.pal2[scan.buf[cnt++]];
+ if( ((cnt&0x03)==0x03 || (cnt&0x07)==0x06) && options.fullscreen ) *vdest++ = scan.pal2[scan.buf[cnt]];
+ }
+
+ if(!options.fullscreen)
+ vdest+=(LCD_WIDTH-160);
+ cnt=0;
+ }
+
+ if(L==143)
+ {
+ if(options.showstats) {
+ snprintf(frameout,sizeof(frameout),"FPS: %d \t %d ",options.fps, options.frameskip);
+ if(options.fullscreen) rb->lcd_putsxy(0,166,frameout);
+ else rb->lcd_putsxy((LCD_WIDTH-160)/2,(LCD_HEIGHT-144)/2,frameout);
+ }
+ if(options.fullscreen)
+ rb->lcd_update();
+ else
+ rb->lcd_update_rect( (LCD_WIDTH-160)/2, (LCD_HEIGHT-144)/2, 160, 144 );
+ }
#endif
}
#if LCD_DEPTH == 1
diff --git a/apps/plugins/rockboy/lcdc.h b/apps/plugins/rockboy/lcdc.h
index c5edc6c..d8cb282 100644
--- a/apps/plugins/rockboy/lcdc.h
+++ b/apps/plugins/rockboy/lcdc.h
@@ -1,4 +1,4 @@
-void stat_trigger(void);
-void stat_write(byte b);
-void lcdc_change(byte b);
-void lcdc_trans(void);
+void stat_trigger(void) ICODE_ATTR;
+void stat_write(byte b)ICODE_ATTR;
+void lcdc_change(byte b)ICODE_ATTR;
+void lcdc_trans(void)ICODE_ATTR;
diff --git a/apps/plugins/rockboy/loader.c b/apps/plugins/rockboy/loader.c
index 0a8eaba..1dd712f 100644
--- a/apps/plugins/rockboy/loader.c
+++ b/apps/plugins/rockboy/loader.c
@@ -81,7 +81,6 @@ static char rtcfile[500];
static char saveprefix[500];
static char *savename;
-static char *savedir = "/.rockbox/rockboy";
static int saveslot;
@@ -332,14 +331,14 @@ void cleanup(void)
void loader_init(char *s)
{
char *name;
- DIR* dir;
+// DIR* dir;
// sys_checkdir(savedir, 1); /* needs to be writable */
- dir=opendir(savedir);
+/* dir=opendir(savedir); // should be handled when the program opens
if(!dir)
mkdir(savedir,0);
else
- closedir(dir);
+ closedir(dir);*/
romfile = s;
if(rom_load())
diff --git a/apps/plugins/rockboy/main.c b/apps/plugins/rockboy/main.c
index 5464d49..c9cbb76 100644
--- a/apps/plugins/rockboy/main.c
+++ b/apps/plugins/rockboy/main.c
@@ -86,7 +86,7 @@ int gnuboy_main(char *rom)
PUTS("Emu run");
#if (LCD_HEIGHT > 144) || (LCD_WIDTH > 160)
rb->lcd_clear_display();
- rb->lcd_drawrect((LCD_WIDTH-160)/2-1, (LCD_HEIGHT-144)/2-1, 162, 146);
+// rb->lcd_drawrect((LCD_WIDTH-160)/2-1, (LCD_HEIGHT-144)/2-1, 162, 146);
rb->lcd_update();
#endif
emu_run();
diff --git a/apps/plugins/rockboy/mem.c b/apps/plugins/rockboy/mem.c
index 6bfedcb..01a05d0 100644
--- a/apps/plugins/rockboy/mem.c
+++ b/apps/plugins/rockboy/mem.c
@@ -11,7 +11,7 @@
#include "lcdc.h"
#include "sound.h"
-struct mbc mbc;
+struct mbc mbc IBSS_ATTR;
struct rom rom;
struct ram ram;
diff --git a/apps/plugins/rockboy/mem.h b/apps/plugins/rockboy/mem.h
index 7926e2e..36ea26e 100644
--- a/apps/plugins/rockboy/mem.h
+++ b/apps/plugins/rockboy/mem.h
@@ -52,11 +52,11 @@ extern struct ram ram;
-void mem_updatemap(void);
-void ioreg_write(byte r, byte b);
-void mbc_write(int a, byte b);
-void mem_write(int a, byte b);
-byte mem_read(int a);
+void mem_updatemap(void) ICODE_ATTR;
+void ioreg_write(byte r, byte b) ICODE_ATTR;
+void mbc_write(int a, byte b) ICODE_ATTR;
+void mem_write(int a, byte b) ICODE_ATTR;
+byte mem_read(int a) ICODE_ATTR;
void mbc_reset(void);
diff --git a/apps/plugins/rockboy/menu.c b/apps/plugins/rockboy/menu.c
index 140e7a2..a22aef4 100644
--- a/apps/plugins/rockboy/menu.c
+++ b/apps/plugins/rockboy/menu.c
@@ -69,6 +69,9 @@ static const char *slot_menu[] = {
typedef enum {
OM_ITEM_FS,
OM_ITEM_SOUND,
+ OM_ITEM_STATS,
+ OM_ITEM_FULLSCREEN,
+ OM_ITEM_KEYS,
OM_ITEM_BACK,
OM_MENU_LAST
} OptMenuItem;
@@ -76,6 +79,9 @@ typedef enum {
static const char *opt_menu[] = {
"Frameskip",
"Sound ON/OFF",
+ "Stats ON/OFF",
+ "Fullscreen ON/OFF",
+ "Set Keys (BUGGY)",
"Previous Menu..."
};
@@ -90,13 +96,50 @@ typedef enum {
} FSMenuItem;
static const char *fs_menu[] = {
- "Skip 0 Frames",
- "Skip 1 Frames",
- "Skip 2 Frames",
- "Skip 3 Frames",
+ "Frameskip 3 Max",
+ "Frameskip 4 Max",
+ "Frameskip 5 Max",
+ "Frameskip 7 Max",
"Previous Menu..."
};
+int getbutton(char *text)
+{
+ rb->lcd_putsxy(0, 0, text);
+ rb->lcd_update();
+ rb->sleep(30);
+ while (rb->button_get(false) != BUTTON_NONE)
+ rb->yield();
+ int button;
+ while(true){
+ button = rb->button_get(true);
+ button=button&0x00000FFF;
+ switch(button) {
+ case BUTTON_LEFT:
+ case BUTTON_RIGHT:
+ case BUTTON_UP:
+ case BUTTON_DOWN:
+ break;
+ default:
+ return button;
+ break;
+ }
+ }
+}
+
+void setupkeys(void)
+{
+ options.A=getbutton("Press A");
+
+ options.B=getbutton("Press B");
+
+ options.START=getbutton("Press Start");
+
+ options.SELECT=getbutton("Press Select");
+
+ options.MENU=getbutton("Press Menu");
+}
+
/*
* do_user_menu - create the user menu on the screen.
*
@@ -144,6 +187,7 @@ int do_user_menu(void) {
}
}
rb->lcd_clear_display();
+ rb->lcd_update();
/* return somethin' */
return ret;
}
@@ -359,16 +403,16 @@ static void do_fs_menu(void) {
done = true;
break;
case FS_ITEM_FS0:
- frameskip=0;
+ options.maxskip=3;
break;
case FS_ITEM_FS1:
- frameskip=1;
+ options.maxskip=4;
break;
case FS_ITEM_FS2:
- frameskip=2;
+ options.maxskip=5;
break;
case FS_ITEM_FS3:
- frameskip=3;
+ options.maxskip=7;
break;
}
}
@@ -389,8 +433,17 @@ static void do_opt_menu(void) {
do_fs_menu();
break;
case OM_ITEM_SOUND:
- sound=!sound;
+ options.sound=!options.sound;
+ break;
+ case OM_ITEM_STATS:
+ options.showstats=!options.showstats;
break;
+ case OM_ITEM_FULLSCREEN:
+ options.fullscreen=!options.fullscreen;
+ break;
+ case OM_ITEM_KEYS:
+ setupkeys();
+ break;
case MENU_CANCEL:
case OM_ITEM_BACK:
done = true;
diff --git a/apps/plugins/rockboy/noise.h b/apps/plugins/rockboy/noise.h
index 037499e..838cbe1 100644
--- a/apps/plugins/rockboy/noise.h
+++ b/apps/plugins/rockboy/noise.h
@@ -5,13 +5,13 @@
#include "defs.h"
-static byte noise7[] =
+static byte noise7[] ICONST_ATTR =
{
0xfd,0xf3,0xd7,0x0d,0xd3,0x15,0x82,0xf1,
0xdb,0x25,0x21,0x39,0x68,0x8c,0xd5,0x00,
};
-static byte noise15[] =
+static byte noise15[] ICONST_ATTR =
{
0xff,0xfd,0xff,0xf3,0xff,0xd7,0xff,0x0f,
0xfd,0xdf,0xf3,0x3f,0xd5,0x7f,0x00,0xfd,
diff --git a/apps/plugins/rockboy/palette.h b/apps/plugins/rockboy/palette.h
index 05b093b..94f660b 100644
--- a/apps/plugins/rockboy/palette.h
+++ b/apps/plugins/rockboy/palette.h
@@ -1,6 +1,6 @@
-void pal_lock(byte n);
-byte pal_getcolor(int c, int r, int g, int b);
-void pal_release(byte n);
-void pal_expire(void);
-void pal_set332(void);
-void vid_setpal(int i, int r, int g, int b);
+void pal_lock(byte n) ICODE_ATTR;
+byte pal_getcolor(int c, int r, int g, int b) ICODE_ATTR;
+void pal_release(byte n) ICODE_ATTR;
+void pal_expire(void) ICODE_ATTR;
+void pal_set332(void) ICODE_ATTR;
+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 b68a053..3eebea8 100644
--- a/apps/plugins/rockboy/rbsound.c
+++ b/apps/plugins/rockboy/rbsound.c
@@ -3,10 +3,18 @@
#include "pcm.h"
#include "rc.h"
-struct pcm pcm;
+//#define ONEBUF // Note: I think the single buffer implementation is more responsive with sound(less lag)
+ // but it creates more choppyness overall to the sound. 2 buffer's don't seem to make
+ // a difference, but 4 buffers is definately noticable
+
+struct pcm pcm IBSS_ATTR;
bool sound = 1;
+#ifdef ONEBUF
+#define N_BUFS 1
+#else
#define N_BUFS 4
+#endif
#define BUF_SIZE 1024
rcvar_t pcm_exports[] =
@@ -16,48 +24,62 @@ rcvar_t pcm_exports[] =
#if CONFIG_CODEC == SWCODEC && !defined(SIMULATOR)
-static int curbuf,gmcurbuf;
+#ifndef ONEBUF
+static short curbuf,gmcurbuf;
+#else
+bool doneplay=0;
+#endif
-static byte *buf=0;
-static short *gmbuf;
+static unsigned char *buf=0;
+static unsigned short *gmbuf;
static bool newly_started;
+void get_more(unsigned char** start, long* size)
+{
+#ifdef ONEBUF
+ doneplay=1;
+ *start = (unsigned char*)(gmbuf);
+#else
+ *start = (unsigned char*)(&gmbuf[pcm.len*curbuf]);
+#endif
+ *size = BUF_SIZE*sizeof(short);
+}
+
void pcm_init(void)
{
if(!sound) return;
- newly_started = true;
+ newly_started = true;
- pcm.hz = 11025;
- pcm.stereo = 1;
+ pcm.hz = 11025;
+ pcm.stereo = 1;
pcm.len = BUF_SIZE;
if(!buf){
- buf = my_malloc(pcm.len * N_BUFS);
- gmbuf = my_malloc(pcm.len * N_BUFS*sizeof (short));
- pcm.buf = buf;
- pcm.pos = 0;
- curbuf = gmcurbuf= 0;
+ buf = my_malloc(pcm.len * N_BUFS);
+ gmbuf = my_malloc(pcm.len * N_BUFS*sizeof (short));
+ pcm.buf = buf;
+ pcm.pos = 0;
+#ifndef ONEBUF
+ curbuf = gmcurbuf= 0;
+#endif
+ memset(gmbuf, 0, pcm.len * N_BUFS *sizeof(short));
+ memset(buf, 0, pcm.len * N_BUFS);
}
-
- rb->pcm_play_stop();
- rb->pcm_set_frequency(11025); // 44100 22050 11025
+
+ rb->pcm_play_stop();
+
+ rb->pcm_set_frequency(11025); // 44100 22050 11025
}
void pcm_close(void)
{
- memset(&pcm, 0, sizeof pcm);
- newly_started = true;
- rb->pcm_play_stop();
+ memset(&pcm, 0, sizeof pcm);
+ newly_started = true;
+ rb->pcm_play_stop();
rb->pcm_set_frequency(44100);
}
-
-void get_more(unsigned char** start, long* size)
-{
- *start = (unsigned char*)(&gmbuf[pcm.len*curbuf]);
- *size = BUF_SIZE*sizeof(short);
-}
int pcm_submit(void)
{
@@ -66,25 +88,36 @@ int pcm_submit(void)
if (!sound) {
pcm.pos = 0;
return 0;
- }
+ }
- if (pcm.pos >= pcm.len) {
- curbuf = (curbuf + 1) % N_BUFS;
- pcm.buf = buf + pcm.len * curbuf;
- pcm.pos = 0;
+ if (pcm.pos < pcm.len) return 1;
- // gotta convert the 8 bit buffer to 16
- for(i=0; i<pcm.len;i++)
- gmbuf[i+pcm.len*curbuf] = (pcm.buf[i]<<8)-0x8000;
- }
-
- if(newly_started)
- {
- rb->pcm_play_data(&get_more);
- newly_started = false;
- }
+#ifndef ONEBUF
+ curbuf = (curbuf + 1) % N_BUFS;
+ pcm.buf = buf + pcm.len * curbuf;
+#endif
+ pcm.pos = 0;
+
+ // gotta convert the 8 bit buffer to 16
+ for(i=0; i<pcm.len;i++)
+#ifdef ONEBUF
+ gmbuf[i] = (pcm.buf[i]<<8)-0x8000;
+#else
+ gmbuf[i+pcm.len*curbuf] = (pcm.buf[i]<<8)-0x8000;
+#endif
- return 1;
+ if(newly_started)
+ {
+ rb->pcm_play_data(&get_more);
+ newly_started = false;
+ }
+
+ // this while loop and done play are in place to make sure the sound timing is correct(although it's not)
+#ifdef ONEBUF
+ while(doneplay==0) rb->yield();
+ doneplay=0;
+#endif
+ return 1;
}
#else
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 a7e9bfb..f6dea0e 100644
--- a/apps/plugins/rockboy/rockboy.c
+++ b/apps/plugins/rockboy/rockboy.c
@@ -39,6 +39,8 @@ char *errormsg;
int gnuboy_main(char *rom);
void pcm_close(void);
+#define optionname "options"
+
void die(char *message, ...)
{
shut=1;
@@ -74,6 +76,74 @@ void setmallocpos(void *pointer)
audio_buffer_free = audio_bufferpointer - audio_bufferbase;
}
+void setoptions (void) {
+ int fd;
+ DIR* dir;
+ char optionsave[sizeof(savedir)+sizeof(optionname)];
+
+ dir=opendir(savedir);
+ if(!dir)
+ mkdir(savedir,0);
+ else
+ closedir(dir);
+
+ snprintf(optionsave, sizeof(optionsave), "%s/%s", savedir, optionname);
+
+ fd = open(optionsave, O_RDONLY);
+ if(fd < 0) // no options to read, set defaults
+ {
+#if (CONFIG_KEYPAD == IRIVER_H100_PAD)
+ options.A=BUTTON_ON;
+ options.B=BUTTON_OFF;
+ options.START=BUTTON_REC;
+ options.SELECT=BUTTON_SELECT;
+ options.MENU=BUTTON_MODE;
+
+#elif (CONFIG_KEYPAD == IRIVER_H300_PAD)
+ options.A=BUTTON_REC;
+ options.B=BUTTON_MODE;
+ options.START=BUTTON_ON;
+ options.SELECT=BUTTON_SELECT;
+ options.MENU=BUTTON_OFF;
+
+#elif CONFIG_KEYPAD == RECORDER_PAD
+ options.A=BUTTON_F1;
+ options.B=BUTTON_F2;
+ options.START=BUTTON_F3;
+ options.SELECT=BUTTON_PLAY;
+ options.MENU=BUTTON_OFF;
+
+#elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD
+ options.A=BUTTON_PLAY;
+ options.B=BUTTON_EQ;
+ options.START=BUTTON_MODE;
+ options.SELECT=(BUTTON_SELECT | BUTTON_REL);
+ options.MENU=(BUTTON_SELECT | BUTTON_REPEAT);
+#endif
+
+ options.maxskip=4;
+ options.fps=0;
+ options.showstats=0;
+ options.fullscreen=1;
+ options.sound=1;
+ }
+ else
+ read(fd,&options, sizeof(options));
+
+ close(fd);
+}
+
+void savesettings(void)
+{
+ int fd;
+ char optionsave[sizeof(savedir)+sizeof(optionname)];
+
+ snprintf(optionsave, sizeof(optionsave), "%s/%s", savedir, optionname);
+ fd = open(optionsave, O_WRONLY|O_CREAT|O_TRUNC);
+ write(fd,&options, sizeof(options));
+ close(fd);
+}
+
/* this is the plugin entry point */
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{
@@ -96,7 +166,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
< audio_buffer_free)
audio_buffer_free = plugin_start_addr - (unsigned char *)audio_bufferbase;
#endif
-
+ setoptions();
#ifdef USE_IRAM
memcpy(iramstart, iramcopy, iramend-iramstart);
memset(iedata, 0, iend - iedata);
@@ -110,11 +180,13 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
gnuboy_main(parameter);
if(shut&&!cleanshut) {
- rb->splash(HZ*2, true, errormsg);
+ rb->splash(HZ/2, true, errormsg);
return PLUGIN_ERROR;
}
pcm_close();
- rb->splash(HZ*2, true, "Shutting down.. byebye ^^");
+ rb->splash(HZ/2, true, "Shutting down");
+
+ savesettings();
cleanup();
diff --git a/apps/plugins/rockboy/rockmacros.h b/apps/plugins/rockboy/rockmacros.h
index c68223d..bc9a0e8 100644
--- a/apps/plugins/rockboy/rockmacros.h
+++ b/apps/plugins/rockboy/rockmacros.h
@@ -16,6 +16,8 @@
* KIND, either express or implied.
*
****************************************************************************/
+#ifndef __ROCKMACROS_H__
+#define __ROCKMACROS_H__
#include "plugin.h"
@@ -28,7 +30,7 @@ extern struct plugin_api* rb;
extern int shut,cleanshut;
void vid_update(int scanline);
void vid_init(void);
-void vid_begin(void);
+inline void vid_begin(void);
void vid_end(void);
void die(char *message, ...);
void setmallocpos(void *pointer);
@@ -38,7 +40,7 @@ int sys_elapsed(long *oldtick);
void sys_sleep(int us);
int pcm_submit(void);
void pcm_init(void);
-void doevents(void);
+void doevents(void) ICODE_ATTR;
void ev_poll(void);
int do_user_menu(void);
void loadstate(int fd);
@@ -60,6 +62,8 @@ void savestate(int fd);
#define mkdir(a,b) rb->sim_mkdir((a),(b))
#undef open
#define open(a,b) rb->sim_open((a),(b))
+#undef close
+#define close(a) rb->sim_close((a))
#undef lseek
#define lseek(a,b,c) rb->sim_lseek((a),(b),(c))
#else /* !SIMULATOR */
@@ -68,6 +72,7 @@ void savestate(int fd);
#define mkdir(a,b) rb->mkdir((a),(b))
#define open(a,b) rb->open((a),(b))
#define lseek(a,b,c) rb->lseek((a),(b),(c))
+#define close(a) rb->close((a))
#endif /* !SIMULATOR */
#define strcat(a,b) rb->strcat((a),(b))
@@ -93,5 +98,13 @@ void savestate(int fd);
/* Using #define isn't enough with GCC 4.0.1 */
void* memcpy(void* dst, const void* src, size_t size);
-extern int frameskip;
-extern bool sound;
+struct options {
+ int A, B, START, SELECT, MENU;
+ int frameskip, fps, maxskip;
+ bool sound, fullscreen, showstats;
+};
+
+extern struct options options;
+#define savedir "/.rockbox/rockboy"
+
+#endif
diff --git a/apps/plugins/rockboy/rtc.c b/apps/plugins/rockboy/rtc.c
index 51c641c..05ad698 100644
--- a/apps/plugins/rockboy/rtc.c
+++ b/apps/plugins/rockboy/rtc.c
@@ -9,7 +9,7 @@
#include "rtc-gb.h"
#include "rc.h"
-struct rtc rtc;
+struct rtc rtc IBSS_ATTR;
static int syncrtc = 1;
diff --git a/apps/plugins/rockboy/sound.c b/apps/plugins/rockboy/sound.c
index 58cbe54..deeacc7 100644
--- a/apps/plugins/rockboy/sound.c
+++ b/apps/plugins/rockboy/sound.c
@@ -49,7 +49,7 @@ static const int freqtab[8] =
(1<<14)/7
};
-struct snd snd;
+struct snd snd IBSS_ATTR;
int pcm_submit(void);
#define RATE (snd.rate)
@@ -161,7 +161,7 @@ void sound_reset(void)
void sound_mix(void)
{
- if (!sound) return;
+ if (!options.sound) return;
int s, l, r, f, n;
if (!RATE || cpu.snd < RATE) return;
@@ -289,7 +289,7 @@ void sound_mix(void)
byte sound_read(byte r)
{
- if(!sound) return 0;
+ if(!options.sound) return 0;
sound_mix();
/* printf("read %02X: %02X\n", r, REG(r)); */
return REG(r);
@@ -346,7 +346,7 @@ void s4_init(void)
void sound_write(byte r, byte b)
{
- if(!sound) return;
+ if(!options.sound) return;
#if 0
static void *timer;
if (!timer) timer = sys_timer();
diff --git a/apps/plugins/rockboy/sound.h b/apps/plugins/rockboy/sound.h
index f479112..18fb371 100644
--- a/apps/plugins/rockboy/sound.h
+++ b/apps/plugins/rockboy/sound.h
@@ -27,12 +27,12 @@ struct snd
extern struct snd snd;
-byte sound_read(byte r);
-void sound_write(byte r, byte b);
-void sound_dirty(void);
+byte sound_read(byte r) ICODE_ATTR;
+void sound_write(byte r, byte b)ICODE_ATTR;
+void sound_dirty(void)ICODE_ATTR;
void sound_off(void);
void sound_reset(void);
-void sound_mix(void);
+void sound_mix(void)ICODE_ATTR;
void s1_init(void);
void s2_init(void);
void s3_init(void);
diff --git a/apps/plugins/rockboy/sys_rockbox.c b/apps/plugins/rockboy/sys_rockbox.c
index 53fe19b..578a864 100644
--- a/apps/plugins/rockboy/sys_rockbox.c
+++ b/apps/plugins/rockboy/sys_rockbox.c
@@ -25,8 +25,6 @@
#include "hw.h"
#include "config.h"
-int frameskip;
-
rcvar_t joy_exports[] =
{
RCV_END
@@ -43,7 +41,7 @@ extern int debug_trace;
void vid_settitle(char *title)
{
- rb->splash(HZ*2, true, title);
+ rb->splash(HZ/2, true, title);
}
void joy_init(void)
@@ -54,36 +52,6 @@ void joy_close(void)
{
}
-#if (CONFIG_KEYPAD == IRIVER_H100_PAD)
-#define ROCKBOY_PAD_A BUTTON_ON
-#define ROCKBOY_PAD_B BUTTON_OFF
-#define ROCKBOY_PAD_START BUTTON_REC
-#define ROCKBOY_PAD_SELECT BUTTON_SELECT
-#define ROCKBOY_MENU BUTTON_MODE
-
-#elif (CONFIG_KEYPAD == IRIVER_H300_PAD)
-#define ROCKBOY_PAD_A BUTTON_REC
-#define ROCKBOY_PAD_B BUTTON_MODE
-#define ROCKBOY_PAD_START BUTTON_ON
-#define ROCKBOY_PAD_SELECT BUTTON_SELECT
-#define ROCKBOY_MENU BUTTON_OFF
-
-#elif CONFIG_KEYPAD == RECORDER_PAD
-#define ROCKBOY_PAD_A BUTTON_F1
-#define ROCKBOY_PAD_B BUTTON_F2
-#define ROCKBOY_PAD_START BUTTON_F3
-#define ROCKBOY_PAD_SELECT BUTTON_PLAY
-#define ROCKBOY_MENU BUTTON_OFF
-
-#elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD
-#define ROCKBOY_PAD_A BUTTON_PLAY
-#define ROCKBOY_PAD_B BUTTON_EQ
-#define ROCKBOY_PAD_START BUTTON_MODE
-#define ROCKBOY_PAD_SELECT (BUTTON_SELECT | BUTTON_REL)
-#define ROCKBOY_MENU (BUTTON_SELECT | BUTTON_REPEAT)
-
-#endif
-
unsigned int oldbuttonstate = 0, newbuttonstate,holdbutton;
int released, pressed;
@@ -109,13 +77,13 @@ void ev_poll(void)
if(released & BUTTON_RIGHT) {ev.code=PAD_RIGHT; ev_postevent(&ev);}
if(released & BUTTON_DOWN) { ev.code=PAD_DOWN; ev_postevent(&ev); }
if(released & BUTTON_UP) { ev.code=PAD_UP; ev_postevent(&ev); }
- if(released & ROCKBOY_PAD_A) { ev.code=PAD_A; ev_postevent(&ev); }
- if(released & ROCKBOY_PAD_B) { ev.code=PAD_B; ev_postevent(&ev); }
- if(released & ROCKBOY_PAD_START) {
+ if(released & options.A) { ev.code=PAD_A; ev_postevent(&ev); }
+ if(released & options.B) { ev.code=PAD_B; ev_postevent(&ev); }
+ if(released & options.START) {
ev.code=PAD_START;
ev_postevent(&ev);
}
- if(released & ROCKBOY_PAD_SELECT) {
+ if(released & options.SELECT) {
ev.code=PAD_SELECT;
ev_postevent(&ev);
}
@@ -126,17 +94,17 @@ void ev_poll(void)
if(pressed & BUTTON_RIGHT) { ev.code=PAD_RIGHT; ev_postevent(&ev);}
if(pressed & BUTTON_DOWN) { ev.code=PAD_DOWN; ev_postevent(&ev); }
if(pressed & BUTTON_UP) { ev.code=PAD_UP; ev_postevent(&ev); }
- if(pressed & ROCKBOY_PAD_A) { ev.code=PAD_A; ev_postevent(&ev); }
- if(pressed & ROCKBOY_PAD_B) { ev.code=PAD_B; ev_postevent(&ev); }
- if(pressed & ROCKBOY_PAD_START) {
+ if(pressed & options.A) { ev.code=PAD_A; ev_postevent(&ev); }
+ if(pressed & options.B) { ev.code=PAD_B; ev_postevent(&ev); }
+ if(pressed & options.START) {
ev.code=PAD_START;
ev_postevent(&ev);
}
- if(pressed & ROCKBOY_PAD_SELECT) {
+ if(pressed & options.SELECT) {
ev.code=PAD_SELECT;
ev_postevent(&ev);
}
- if(pressed & ROCKBOY_MENU) {
+ if(pressed & options.MENU) {
#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
if (do_user_menu() == USER_MENU_QUIT)
#endif
@@ -157,11 +125,17 @@ void vid_setpal(int i, int r, int g, int b)
(void)b;
}
-void vid_begin(void) // This frameskip code is borrowed from the GNUboyCE project
+inline void vid_begin(void) // New frameskip, makes more sense to me and performs as well
{
static int skip = 0;
- skip = (skip + 1) % (frameskip > 0 ? frameskip + 1 : 1);
- fb.enabled = skip == 0;
+ if (skip<options.frameskip) {
+ skip++;
+ fb.enabled=0;
+ }
+ else {
+ skip=0;
+ fb.enabled=1;
+ }
}
void vid_init(void)
@@ -173,7 +147,7 @@ void vid_init(void)
fb.dirty=0;
fb.mode=3;
- frameskip=2;
+ fb.ptr=rb->lcd_framebuffer;
#if defined(HAVE_LCD_COLOR)
fb.pelsize=2; // 16 bit framebuffer
@@ -193,13 +167,12 @@ void vid_init(void)
#endif
}
+#if LCD_HEIGHT<144
fb_data *frameb;
void vid_update(int scanline)
-{
- register int cnt=0;
-#if LCD_HEIGHT < 144
+{
+ register int cnt=0;
int scanline_remapped;
-#endif
#if (LCD_HEIGHT == 64) && (LCD_DEPTH == 1) /* Archos */
int balance = 0;
if (fb.mode==1)
@@ -292,13 +265,10 @@ void vid_update(int scanline)
}
rb->lcd_update_rect(0, scanline & ~3, LCD_WIDTH, 4);
#elif (LCD_HEIGHT >= 144) && defined(HAVE_LCD_COLOR) /* iriver H3x0, colour iPod */
- frameb = rb->lcd_framebuffer + (scanline + (LCD_HEIGHT-144)/2) * LCD_WIDTH + (LCD_WIDTH-160)/2;;
- while (cnt < 160)
- *frameb++ = scan.pal2[scan.buf[cnt++]];
- if(scanline==143)
- rb->lcd_update(); // this seems faster then doing individual scanlines
+ // handled in lcd.c now
#endif /* LCD_HEIGHT */
}
+#endif
void vid_end(void)
{
@@ -307,19 +277,30 @@ void vid_end(void)
long timerresult;
void *sys_timer(void)
-{
+{/*
timerresult=*rb->current_tick;
- return &timerresult;
+ return &timerresult;*/
+ return 0;
}
// returns microseconds passed since sys_timer
int sys_elapsed(long *oldtick)
{
- return ((*rb->current_tick-(*oldtick))*1000000)/HZ;
+/*
+ int elap,mytime=microtick;
+
+ elap=mytime-*oldtick;
+ *oldtick=mytime;
+ return elap;*/
+// return ((*rb->current_tick-(*oldtick))*1000000)/HZ;
+ return *oldtick;
}
void sys_sleep(int us)
{
- if (us <= 0) return;
-// rb->sleep(HZ*us/1000000);
+ if(us<=0) return;
+ int i=0;
+ while(i< us*11)
+ i++;
+// if (us <= 0) return;
}