1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Daniel Stenberg 2006-01-20 13:05:52 +00:00
parent c05cd1676f
commit 137fb6cb9f
27 changed files with 490 additions and 213 deletions

View file

@ -9,8 +9,8 @@
INCLUDES = -I$(APPSDIR) -I.. -I. -I$(FIRMDIR)/include -I$(FIRMDIR)/export \ INCLUDES = -I$(APPSDIR) -I.. -I. -I$(FIRMDIR)/include -I$(FIRMDIR)/export \
-I$(FIRMDIR)/common -I$(FIRMDIR)/drivers -I$(OUTDIR) -I$(BUILDDIR) -I$(FIRMDIR)/common -I$(FIRMDIR)/drivers -I$(OUTDIR) -I$(BUILDDIR)
CFLAGS = $(GCCOPTS) -O3 $(INCLUDES) $(TARGET) $(EXTRA_DEFINES) \ CFLAGS = $(GCCOPTS) -O2 $(INCLUDES) $(TARGET) $(EXTRA_DEFINES) \
-DTARGET_ID=$(TARGET_ID) -DMEM=${MEMORYSIZE} -DPLUGIN -DTARGET_ID=$(TARGET_ID) -DMEM=${MEMORYSIZE} -DPLUGIN -finline-functions
ifdef APPEXTRA ifdef APPEXTRA
INCLUDES += $(patsubst %,-I$(APPSDIR)/%,$(subst :, ,$(APPEXTRA))) INCLUDES += $(patsubst %,-I$(APPSDIR)/%,$(subst :, ,$(APPEXTRA)))
@ -48,7 +48,7 @@ all: $(OUTPUT)
ifndef SIMVER ifndef SIMVER
$(OBJDIR)/rockboy.elf: $(OBJS) $(LINKFILE) $(OBJDIR)/rockboy.elf: $(OBJS) $(LINKFILE)
@echo "LD "`basename $@` @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 -T$(LINKFILE) -Wl,-Map,$(OBJDIR)/rockboy.map
$(OUTPUT): $(OBJDIR)/rockboy.elf $(OUTPUT): $(OBJDIR)/rockboy.elf

View file

@ -48,12 +48,12 @@ extern int blockclen;
#endif #endif
void cpu_reset(void); void cpu_reset(void);
void div_advance(int cnt); void div_advance(int cnt) ICODE_ATTR;
void timer_advance(int cnt); void timer_advance(int cnt) ICODE_ATTR;
void lcdc_advance(int cnt); void lcdc_advance(int cnt) ICODE_ATTR;
void sound_advance(int cnt); void sound_advance(int cnt) ICODE_ATTR;
void cpu_timers(int cnt); void cpu_timers(int cnt) ICODE_ATTR;
int cpu_emulate(int cycles) ICODE_ATTR; int cpu_emulate(int cycles) ICODE_ATTR;
int cpu_step(int max) ICODE_ATTR; inline int cpu_step(int max);
#endif #endif

View file

@ -1006,9 +1006,9 @@ next:
#ifndef ASM_CPU_STEP #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; if ((cnt = cpu_idle(max))) return cnt;
return cpu_emulate(1); return cpu_emulate(1);
} }

View file

@ -2,7 +2,7 @@
#include "defs.h" #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, 5, 2, 2, 2, 1, 1, 2, 1,
1, 3, 2, 2, 1, 1, 2, 1, 3, 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, 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,
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, 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, 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 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, 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, 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 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, 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, 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 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, 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, 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, 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,
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, 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, 00, 00, 00, 00, 00, 00, 00, 00,
00, 00, 00, 00, 00, 00, 00, 00, FC, FC, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, FC, FC, 00, 00, 00, 00, 00, 00,

View file

@ -58,15 +58,16 @@ void emu_step(void)
cpu_emulate(cpu.lcdc); cpu_emulate(cpu.lcdc);
} }
struct options options;
/* This mess needs to be moved to another module; it's just here to /* This mess needs to be moved to another module; it's just here to
* make things work in the mean time. */ * make things work in the mean time. */
//extern struct plugin_api* rb;
void emu_run(void) void emu_run(void)
{ {
void *timer = sys_timer(); // void *timer = sys_timer();
int delay; int framesin=0,frames=0,timeten=*rb->current_tick, timehun=*rb->current_tick;
// int delay;
vid_begin(); vid_begin();
lcd_begin(); lcd_begin();
@ -79,18 +80,17 @@ void emu_run(void)
while (R_LY > 0 && R_LY < 144) while (R_LY > 0 && R_LY < 144)
emu_step(); emu_step();
vid_end();
rtc_tick(); rtc_tick();
sound_mix(); sound_mix();
if (!pcm_submit()) if (!pcm_submit())
{ {
delay = framelen - sys_elapsed(timer); /* delay = framelen - sys_elapsed(timer);
sys_sleep(delay); sys_sleep(delay);
sys_elapsed(timer); sys_elapsed(timer);*/
} }
doevents(); doevents();
vid_begin(); vid_begin();
// if (framecount) { if (!--framecount) die("finished\n"); }
if (!(R_LCDC & 0x80)) if (!(R_LCDC & 0x80))
cpu_emulate(32832); cpu_emulate(32832);
@ -98,11 +98,34 @@ void emu_run(void)
while (R_LY > 0) /* wait for next frame */ while (R_LY > 0) /* wait for next frame */
emu_step(); emu_step();
rb->yield(); 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) #if !defined(SIMULATOR) && defined(HAVE_ADJUSTABLE_CPU_FREQ)
rb->cpu_boost(false); rb->cpu_boost(false);
#endif #endif
} }

View file

@ -14,7 +14,7 @@
const byte himask[256]; 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, 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, 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 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, 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, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S,

View file

@ -7,12 +7,12 @@
#include "mem.h" #include "mem.h"
byte readb(int a); byte readb(int a) ICODE_ATTR;
void writeb(int a, byte b); void writeb(int a, byte b) ICODE_ATTR;
int readw(int a); int readw(int a) ICODE_ATTR;
void writew(int a, int w); void writew(int a, int w) ICODE_ATTR;
byte readhi(int a); byte readhi(int a) ICODE_ATTR;
void writehi(int a, byte b); void writehi(int a, byte b) ICODE_ATTR;
#if 0 #if 0
byte readhi(int a); byte readhi(int a);
void writehi(int a, byte b); void writehi(int a, byte b);

View file

@ -10,7 +10,7 @@
struct fb struct fb
{ {
byte *ptr; fb_data *ptr;
int w, h; int w, h;
int pelsize; int pelsize;
int pitch; int pitch;

View file

@ -34,14 +34,14 @@ struct hw
extern struct hw hw; extern struct hw hw;
void hw_interrupt(byte i, byte mask); void hw_interrupt(byte i, byte mask) ICODE_ATTR;
void hw_dma(byte b); void hw_dma(byte b) ICODE_ATTR;
void hw_hdma_cmd(byte c); void hw_hdma_cmd(byte c) ICODE_ATTR;
void hw_hdma(void); void hw_hdma(void) ICODE_ATTR;
void pad_refresh(void); void pad_refresh(void)ICODE_ATTR;
void pad_press(byte k); void pad_press(byte k)ICODE_ATTR;
void pad_release(byte k); void pad_release(byte k)ICODE_ATTR;
void pad_set(byte k, int st); void pad_set(byte k, int st)ICODE_ATTR;
void hw_reset(void); void hw_reset(void);
#endif #endif

View file

@ -18,7 +18,7 @@ typedef struct event_s
#define EV_RELEASE 2 #define EV_RELEASE 2
#define EV_REPEAT 3 #define EV_REPEAT 3
int ev_postevent(event_t *ev); int ev_postevent(event_t *ev) ICODE_ATTR;
int ev_getevent(event_t *ev); int ev_getevent(event_t *ev) ICODE_ATTR;

View file

@ -55,21 +55,21 @@ extern struct scan scan;
void updatepatpix(void) ICODE_ATTR; void updatepatpix(void) ICODE_ATTR;
void tilebuf(void); void tilebuf(void) ICODE_ATTR;
void bg_scan(void); void bg_scan(void) ICODE_ATTR;
void wnd_scan(void); void wnd_scan(void) ICODE_ATTR;
void bg_scan_pri(void); void bg_scan_pri(void) ICODE_ATTR;
void wnd_scan_pri(void); void wnd_scan_pri(void) ICODE_ATTR;
void spr_count(void); void spr_count(void);
void spr_enum(void); void spr_enum(void) ICODE_ATTR;
void spr_scan(void); void spr_scan(void) ICODE_ATTR;
void lcd_begin(void); void lcd_begin(void) ICODE_ATTR;
void lcd_refreshline(void); void lcd_refreshline(void) ICODE_ATTR;
void pal_write(int i, byte b); void pal_write(int i, byte b);
void pal_write_dmg(int i, int mapnum, byte d); void pal_write_dmg(int i, int mapnum, byte d) ICODE_ATTR;
void vram_write(int a, byte b); void vram_write(int a, byte b) ICODE_ATTR;
void vram_dirty(void); void vram_dirty(void) ICODE_ATTR;
void pal_dirty(void); void pal_dirty(void) ICODE_ATTR;
void lcd_reset(void); void lcd_reset(void);
#endif #endif

View file

@ -94,7 +94,7 @@ rcvar_t lcd_exports[] =
RCV_END RCV_END
}; };
static byte *vdest; fb_data *vdest;
#ifdef ALLOW_UNALIGNED_IO /* long long is ok since this is i386-only anyway? */ #ifdef ALLOW_UNALIGNED_IO /* long long is ok since this is i386-only anyway? */
#define MEMCPY8(d, s) ((*(long long *)(d)) = (*(long long *)(s))) #define MEMCPY8(d, s) ((*(long long *)(d)) = (*(long long *)(s)))
@ -532,9 +532,21 @@ void bg_scan(void)
if (cnt <= 0) return; if (cnt <= 0) return;
while (cnt >= 8) 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]; src = patpix[*(tile++)][V];
MEMCPY8(dest, src); MEMCPY8(dest, src);
dest += 8; dest += 8;
#endif
cnt -= 8; cnt -= 8;
} }
src = patpix[*tile][V]; src = patpix[*tile][V];
@ -555,9 +567,21 @@ void wnd_scan(void)
while (cnt >= 8) 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]; src = patpix[*(tile++)][WV];
MEMCPY8(dest, src); MEMCPY8(dest, src);
dest += 8; dest += 8;
#endif
cnt -= 8; cnt -= 8;
} }
src = patpix[*tile][WV]; src = patpix[*tile][WV];
@ -651,8 +675,55 @@ void bg_scan_color(void)
while (cnt >= 8) while (cnt >= 8)
{ {
src = patpix[*(tile++)][V]; 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); blendcpy(dest, src, *(tile++), 8);
dest += 8; dest += 8;
#endif
cnt -= 8; cnt -= 8;
} }
src = patpix[*(tile++)][V]; src = patpix[*(tile++)][V];
@ -843,14 +914,21 @@ void lcd_begin(void)
else pal_expire(); else pal_expire();
} }
while (scale * 160 > fb.w || scale * 144 > fb.h) scale--; */ while (scale * 160 > fb.w || scale * 144 > fb.h) scale--; */
vdest = fb.ptr + ((fb.w*fb.pelsize)>>1) if(options.fullscreen)
- (80*fb.pelsize) vdest = fb.ptr;
+ ((fb.h>>1) - 72) * fb.pitch; else
vdest = fb.ptr + ((LCD_HEIGHT-144)/2)*LCD_WIDTH + ((LCD_WIDTH-160)/2);
WY = R_WY; WY = R_WY;
} }
char frameout[25];
void lcd_refreshline(void) void lcd_refreshline(void)
{ {
#if LCD_HEIGHT>=144
int cnt=0, two;
#endif
if (!fb.enabled) return; if (!fb.enabled) return;
if(!insync) { if(!insync) {
if(R_LY!=0) if(R_LY!=0)
@ -924,7 +1002,32 @@ void lcd_refreshline(void)
else else
vid_update(L-((int)(L/9))); vid_update(L-((int)(L/9)));
#else #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 #endif
} }
#if LCD_DEPTH == 1 #if LCD_DEPTH == 1

View file

@ -1,4 +1,4 @@
void stat_trigger(void); void stat_trigger(void) ICODE_ATTR;
void stat_write(byte b); void stat_write(byte b)ICODE_ATTR;
void lcdc_change(byte b); void lcdc_change(byte b)ICODE_ATTR;
void lcdc_trans(void); void lcdc_trans(void)ICODE_ATTR;

View file

@ -81,7 +81,6 @@ static char rtcfile[500];
static char saveprefix[500]; static char saveprefix[500];
static char *savename; static char *savename;
static char *savedir = "/.rockbox/rockboy";
static int saveslot; static int saveslot;
@ -332,14 +331,14 @@ void cleanup(void)
void loader_init(char *s) void loader_init(char *s)
{ {
char *name; char *name;
DIR* dir; // DIR* dir;
// sys_checkdir(savedir, 1); /* needs to be writable */ // sys_checkdir(savedir, 1); /* needs to be writable */
dir=opendir(savedir); /* dir=opendir(savedir); // should be handled when the program opens
if(!dir) if(!dir)
mkdir(savedir,0); mkdir(savedir,0);
else else
closedir(dir); closedir(dir);*/
romfile = s; romfile = s;
if(rom_load()) if(rom_load())

View file

@ -86,7 +86,7 @@ int gnuboy_main(char *rom)
PUTS("Emu run"); PUTS("Emu run");
#if (LCD_HEIGHT > 144) || (LCD_WIDTH > 160) #if (LCD_HEIGHT > 144) || (LCD_WIDTH > 160)
rb->lcd_clear_display(); 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(); rb->lcd_update();
#endif #endif
emu_run(); emu_run();

View file

@ -11,7 +11,7 @@
#include "lcdc.h" #include "lcdc.h"
#include "sound.h" #include "sound.h"
struct mbc mbc; struct mbc mbc IBSS_ATTR;
struct rom rom; struct rom rom;
struct ram ram; struct ram ram;

View file

@ -52,11 +52,11 @@ extern struct ram ram;
void mem_updatemap(void); void mem_updatemap(void) ICODE_ATTR;
void ioreg_write(byte r, byte b); void ioreg_write(byte r, byte b) ICODE_ATTR;
void mbc_write(int a, byte b); void mbc_write(int a, byte b) ICODE_ATTR;
void mem_write(int a, byte b); void mem_write(int a, byte b) ICODE_ATTR;
byte mem_read(int a); byte mem_read(int a) ICODE_ATTR;
void mbc_reset(void); void mbc_reset(void);

View file

@ -69,6 +69,9 @@ static const char *slot_menu[] = {
typedef enum { typedef enum {
OM_ITEM_FS, OM_ITEM_FS,
OM_ITEM_SOUND, OM_ITEM_SOUND,
OM_ITEM_STATS,
OM_ITEM_FULLSCREEN,
OM_ITEM_KEYS,
OM_ITEM_BACK, OM_ITEM_BACK,
OM_MENU_LAST OM_MENU_LAST
} OptMenuItem; } OptMenuItem;
@ -76,6 +79,9 @@ typedef enum {
static const char *opt_menu[] = { static const char *opt_menu[] = {
"Frameskip", "Frameskip",
"Sound ON/OFF", "Sound ON/OFF",
"Stats ON/OFF",
"Fullscreen ON/OFF",
"Set Keys (BUGGY)",
"Previous Menu..." "Previous Menu..."
}; };
@ -90,13 +96,50 @@ typedef enum {
} FSMenuItem; } FSMenuItem;
static const char *fs_menu[] = { static const char *fs_menu[] = {
"Skip 0 Frames", "Frameskip 3 Max",
"Skip 1 Frames", "Frameskip 4 Max",
"Skip 2 Frames", "Frameskip 5 Max",
"Skip 3 Frames", "Frameskip 7 Max",
"Previous Menu..." "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. * 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_clear_display();
rb->lcd_update();
/* return somethin' */ /* return somethin' */
return ret; return ret;
} }
@ -359,16 +403,16 @@ static void do_fs_menu(void) {
done = true; done = true;
break; break;
case FS_ITEM_FS0: case FS_ITEM_FS0:
frameskip=0; options.maxskip=3;
break; break;
case FS_ITEM_FS1: case FS_ITEM_FS1:
frameskip=1; options.maxskip=4;
break; break;
case FS_ITEM_FS2: case FS_ITEM_FS2:
frameskip=2; options.maxskip=5;
break; break;
case FS_ITEM_FS3: case FS_ITEM_FS3:
frameskip=3; options.maxskip=7;
break; break;
} }
} }
@ -389,7 +433,16 @@ static void do_opt_menu(void) {
do_fs_menu(); do_fs_menu();
break; break;
case OM_ITEM_SOUND: 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; break;
case MENU_CANCEL: case MENU_CANCEL:
case OM_ITEM_BACK: case OM_ITEM_BACK:

View file

@ -5,13 +5,13 @@
#include "defs.h" #include "defs.h"
static byte noise7[] = static byte noise7[] ICONST_ATTR =
{ {
0xfd,0xf3,0xd7,0x0d,0xd3,0x15,0x82,0xf1, 0xfd,0xf3,0xd7,0x0d,0xd3,0x15,0x82,0xf1,
0xdb,0x25,0x21,0x39,0x68,0x8c,0xd5,0x00, 0xdb,0x25,0x21,0x39,0x68,0x8c,0xd5,0x00,
}; };
static byte noise15[] = static byte noise15[] ICONST_ATTR =
{ {
0xff,0xfd,0xff,0xf3,0xff,0xd7,0xff,0x0f, 0xff,0xfd,0xff,0xf3,0xff,0xd7,0xff,0x0f,
0xfd,0xdf,0xf3,0x3f,0xd5,0x7f,0x00,0xfd, 0xfd,0xdf,0xf3,0x3f,0xd5,0x7f,0x00,0xfd,

View file

@ -1,6 +1,6 @@
void pal_lock(byte n); void pal_lock(byte n) ICODE_ATTR;
byte pal_getcolor(int c, int r, int g, int b); byte pal_getcolor(int c, int r, int g, int b) ICODE_ATTR;
void pal_release(byte n); void pal_release(byte n) ICODE_ATTR;
void pal_expire(void); void pal_expire(void) ICODE_ATTR;
void pal_set332(void); void pal_set332(void) ICODE_ATTR;
void vid_setpal(int i, int r, int g, int b); void vid_setpal(int i, int r, int g, int b) ICODE_ATTR;

View file

@ -3,10 +3,18 @@
#include "pcm.h" #include "pcm.h"
#include "rc.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; bool sound = 1;
#ifdef ONEBUF
#define N_BUFS 1
#else
#define N_BUFS 4 #define N_BUFS 4
#endif
#define BUF_SIZE 1024 #define BUF_SIZE 1024
rcvar_t pcm_exports[] = rcvar_t pcm_exports[] =
@ -16,13 +24,28 @@ rcvar_t pcm_exports[] =
#if CONFIG_CODEC == SWCODEC && !defined(SIMULATOR) #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 unsigned char *buf=0;
static short *gmbuf; static unsigned short *gmbuf;
static bool newly_started; 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) void pcm_init(void)
{ {
if(!sound) return; if(!sound) return;
@ -38,10 +61,15 @@ void pcm_init(void)
gmbuf = my_malloc(pcm.len * N_BUFS*sizeof (short)); gmbuf = my_malloc(pcm.len * N_BUFS*sizeof (short));
pcm.buf = buf; pcm.buf = buf;
pcm.pos = 0; pcm.pos = 0;
#ifndef ONEBUF
curbuf = gmcurbuf= 0; 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_play_stop();
rb->pcm_set_frequency(11025); // 44100 22050 11025 rb->pcm_set_frequency(11025); // 44100 22050 11025
} }
@ -53,12 +81,6 @@ void pcm_close(void)
rb->pcm_set_frequency(44100); 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) int pcm_submit(void)
{ {
register int i; register int i;
@ -68,15 +90,21 @@ int pcm_submit(void)
return 0; return 0;
} }
if (pcm.pos >= pcm.len) { if (pcm.pos < pcm.len) return 1;
#ifndef ONEBUF
curbuf = (curbuf + 1) % N_BUFS; curbuf = (curbuf + 1) % N_BUFS;
pcm.buf = buf + pcm.len * curbuf; pcm.buf = buf + pcm.len * curbuf;
#endif
pcm.pos = 0; pcm.pos = 0;
// gotta convert the 8 bit buffer to 16 // gotta convert the 8 bit buffer to 16
for(i=0; i<pcm.len;i++) 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; gmbuf[i+pcm.len*curbuf] = (pcm.buf[i]<<8)-0x8000;
} #endif
if(newly_started) if(newly_started)
{ {
@ -84,6 +112,11 @@ int pcm_submit(void)
newly_started = false; 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; return 1;
} }
#else #else

View file

@ -39,6 +39,8 @@ char *errormsg;
int gnuboy_main(char *rom); int gnuboy_main(char *rom);
void pcm_close(void); void pcm_close(void);
#define optionname "options"
void die(char *message, ...) void die(char *message, ...)
{ {
shut=1; shut=1;
@ -74,6 +76,74 @@ void setmallocpos(void *pointer)
audio_buffer_free = audio_bufferpointer - audio_bufferbase; 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 */ /* this is the plugin entry point */
enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 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)
audio_buffer_free = plugin_start_addr - (unsigned char *)audio_bufferbase; audio_buffer_free = plugin_start_addr - (unsigned char *)audio_bufferbase;
#endif #endif
setoptions();
#ifdef USE_IRAM #ifdef USE_IRAM
memcpy(iramstart, iramcopy, iramend-iramstart); memcpy(iramstart, iramcopy, iramend-iramstart);
memset(iedata, 0, iend - iedata); memset(iedata, 0, iend - iedata);
@ -110,11 +180,13 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
gnuboy_main(parameter); gnuboy_main(parameter);
if(shut&&!cleanshut) { if(shut&&!cleanshut) {
rb->splash(HZ*2, true, errormsg); rb->splash(HZ/2, true, errormsg);
return PLUGIN_ERROR; return PLUGIN_ERROR;
} }
pcm_close(); pcm_close();
rb->splash(HZ*2, true, "Shutting down.. byebye ^^"); rb->splash(HZ/2, true, "Shutting down");
savesettings();
cleanup(); cleanup();

View file

@ -16,6 +16,8 @@
* KIND, either express or implied. * KIND, either express or implied.
* *
****************************************************************************/ ****************************************************************************/
#ifndef __ROCKMACROS_H__
#define __ROCKMACROS_H__
#include "plugin.h" #include "plugin.h"
@ -28,7 +30,7 @@ extern struct plugin_api* rb;
extern int shut,cleanshut; extern int shut,cleanshut;
void vid_update(int scanline); void vid_update(int scanline);
void vid_init(void); void vid_init(void);
void vid_begin(void); inline void vid_begin(void);
void vid_end(void); void vid_end(void);
void die(char *message, ...); void die(char *message, ...);
void setmallocpos(void *pointer); void setmallocpos(void *pointer);
@ -38,7 +40,7 @@ int sys_elapsed(long *oldtick);
void sys_sleep(int us); void sys_sleep(int us);
int pcm_submit(void); int pcm_submit(void);
void pcm_init(void); void pcm_init(void);
void doevents(void); void doevents(void) ICODE_ATTR;
void ev_poll(void); void ev_poll(void);
int do_user_menu(void); int do_user_menu(void);
void loadstate(int fd); void loadstate(int fd);
@ -60,6 +62,8 @@ void savestate(int fd);
#define mkdir(a,b) rb->sim_mkdir((a),(b)) #define mkdir(a,b) rb->sim_mkdir((a),(b))
#undef open #undef open
#define open(a,b) rb->sim_open((a),(b)) #define open(a,b) rb->sim_open((a),(b))
#undef close
#define close(a) rb->sim_close((a))
#undef lseek #undef lseek
#define lseek(a,b,c) rb->sim_lseek((a),(b),(c)) #define lseek(a,b,c) rb->sim_lseek((a),(b),(c))
#else /* !SIMULATOR */ #else /* !SIMULATOR */
@ -68,6 +72,7 @@ void savestate(int fd);
#define mkdir(a,b) rb->mkdir((a),(b)) #define mkdir(a,b) rb->mkdir((a),(b))
#define open(a,b) rb->open((a),(b)) #define open(a,b) rb->open((a),(b))
#define lseek(a,b,c) rb->lseek((a),(b),(c)) #define lseek(a,b,c) rb->lseek((a),(b),(c))
#define close(a) rb->close((a))
#endif /* !SIMULATOR */ #endif /* !SIMULATOR */
#define strcat(a,b) rb->strcat((a),(b)) #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 */ /* Using #define isn't enough with GCC 4.0.1 */
void* memcpy(void* dst, const void* src, size_t size); void* memcpy(void* dst, const void* src, size_t size);
extern int frameskip; struct options {
extern bool sound; int A, B, START, SELECT, MENU;
int frameskip, fps, maxskip;
bool sound, fullscreen, showstats;
};
extern struct options options;
#define savedir "/.rockbox/rockboy"
#endif

View file

@ -9,7 +9,7 @@
#include "rtc-gb.h" #include "rtc-gb.h"
#include "rc.h" #include "rc.h"
struct rtc rtc; struct rtc rtc IBSS_ATTR;
static int syncrtc = 1; static int syncrtc = 1;

View file

@ -49,7 +49,7 @@ static const int freqtab[8] =
(1<<14)/7 (1<<14)/7
}; };
struct snd snd; struct snd snd IBSS_ATTR;
int pcm_submit(void); int pcm_submit(void);
#define RATE (snd.rate) #define RATE (snd.rate)
@ -161,7 +161,7 @@ void sound_reset(void)
void sound_mix(void) void sound_mix(void)
{ {
if (!sound) return; if (!options.sound) return;
int s, l, r, f, n; int s, l, r, f, n;
if (!RATE || cpu.snd < RATE) return; if (!RATE || cpu.snd < RATE) return;
@ -289,7 +289,7 @@ void sound_mix(void)
byte sound_read(byte r) byte sound_read(byte r)
{ {
if(!sound) return 0; if(!options.sound) return 0;
sound_mix(); sound_mix();
/* printf("read %02X: %02X\n", r, REG(r)); */ /* printf("read %02X: %02X\n", r, REG(r)); */
return REG(r); return REG(r);
@ -346,7 +346,7 @@ void s4_init(void)
void sound_write(byte r, byte b) void sound_write(byte r, byte b)
{ {
if(!sound) return; if(!options.sound) return;
#if 0 #if 0
static void *timer; static void *timer;
if (!timer) timer = sys_timer(); if (!timer) timer = sys_timer();

View file

@ -27,12 +27,12 @@ struct snd
extern struct snd snd; extern struct snd snd;
byte sound_read(byte r); byte sound_read(byte r) ICODE_ATTR;
void sound_write(byte r, byte b); void sound_write(byte r, byte b)ICODE_ATTR;
void sound_dirty(void); void sound_dirty(void)ICODE_ATTR;
void sound_off(void); void sound_off(void);
void sound_reset(void); void sound_reset(void);
void sound_mix(void); void sound_mix(void)ICODE_ATTR;
void s1_init(void); void s1_init(void);
void s2_init(void); void s2_init(void);
void s3_init(void); void s3_init(void);

View file

@ -25,8 +25,6 @@
#include "hw.h" #include "hw.h"
#include "config.h" #include "config.h"
int frameskip;
rcvar_t joy_exports[] = rcvar_t joy_exports[] =
{ {
RCV_END RCV_END
@ -43,7 +41,7 @@ extern int debug_trace;
void vid_settitle(char *title) void vid_settitle(char *title)
{ {
rb->splash(HZ*2, true, title); rb->splash(HZ/2, true, title);
} }
void joy_init(void) 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; unsigned int oldbuttonstate = 0, newbuttonstate,holdbutton;
int released, pressed; 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_RIGHT) {ev.code=PAD_RIGHT; ev_postevent(&ev);}
if(released & BUTTON_DOWN) { ev.code=PAD_DOWN; 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 & BUTTON_UP) { ev.code=PAD_UP; ev_postevent(&ev); }
if(released & ROCKBOY_PAD_A) { ev.code=PAD_A; ev_postevent(&ev); } if(released & options.A) { ev.code=PAD_A; ev_postevent(&ev); }
if(released & ROCKBOY_PAD_B) { ev.code=PAD_B; ev_postevent(&ev); } if(released & options.B) { ev.code=PAD_B; ev_postevent(&ev); }
if(released & ROCKBOY_PAD_START) { if(released & options.START) {
ev.code=PAD_START; ev.code=PAD_START;
ev_postevent(&ev); ev_postevent(&ev);
} }
if(released & ROCKBOY_PAD_SELECT) { if(released & options.SELECT) {
ev.code=PAD_SELECT; ev.code=PAD_SELECT;
ev_postevent(&ev); 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_RIGHT) { ev.code=PAD_RIGHT; ev_postevent(&ev);}
if(pressed & BUTTON_DOWN) { ev.code=PAD_DOWN; 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 & BUTTON_UP) { ev.code=PAD_UP; ev_postevent(&ev); }
if(pressed & ROCKBOY_PAD_A) { ev.code=PAD_A; ev_postevent(&ev); } if(pressed & options.A) { ev.code=PAD_A; ev_postevent(&ev); }
if(pressed & ROCKBOY_PAD_B) { ev.code=PAD_B; ev_postevent(&ev); } if(pressed & options.B) { ev.code=PAD_B; ev_postevent(&ev); }
if(pressed & ROCKBOY_PAD_START) { if(pressed & options.START) {
ev.code=PAD_START; ev.code=PAD_START;
ev_postevent(&ev); ev_postevent(&ev);
} }
if(pressed & ROCKBOY_PAD_SELECT) { if(pressed & options.SELECT) {
ev.code=PAD_SELECT; ev.code=PAD_SELECT;
ev_postevent(&ev); ev_postevent(&ev);
} }
if(pressed & ROCKBOY_MENU) { if(pressed & options.MENU) {
#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD) #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
if (do_user_menu() == USER_MENU_QUIT) if (do_user_menu() == USER_MENU_QUIT)
#endif #endif
@ -157,11 +125,17 @@ void vid_setpal(int i, int r, int g, int b)
(void)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; static int skip = 0;
skip = (skip + 1) % (frameskip > 0 ? frameskip + 1 : 1); if (skip<options.frameskip) {
fb.enabled = skip == 0; skip++;
fb.enabled=0;
}
else {
skip=0;
fb.enabled=1;
}
} }
void vid_init(void) void vid_init(void)
@ -173,7 +147,7 @@ void vid_init(void)
fb.dirty=0; fb.dirty=0;
fb.mode=3; fb.mode=3;
frameskip=2; fb.ptr=rb->lcd_framebuffer;
#if defined(HAVE_LCD_COLOR) #if defined(HAVE_LCD_COLOR)
fb.pelsize=2; // 16 bit framebuffer fb.pelsize=2; // 16 bit framebuffer
@ -193,13 +167,12 @@ void vid_init(void)
#endif #endif
} }
#if LCD_HEIGHT<144
fb_data *frameb; fb_data *frameb;
void vid_update(int scanline) void vid_update(int scanline)
{ {
register int cnt=0; register int cnt=0;
#if LCD_HEIGHT < 144
int scanline_remapped; int scanline_remapped;
#endif
#if (LCD_HEIGHT == 64) && (LCD_DEPTH == 1) /* Archos */ #if (LCD_HEIGHT == 64) && (LCD_DEPTH == 1) /* Archos */
int balance = 0; int balance = 0;
if (fb.mode==1) if (fb.mode==1)
@ -292,13 +265,10 @@ void vid_update(int scanline)
} }
rb->lcd_update_rect(0, scanline & ~3, LCD_WIDTH, 4); rb->lcd_update_rect(0, scanline & ~3, LCD_WIDTH, 4);
#elif (LCD_HEIGHT >= 144) && defined(HAVE_LCD_COLOR) /* iriver H3x0, colour iPod */ #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;; // handled in lcd.c now
while (cnt < 160)
*frameb++ = scan.pal2[scan.buf[cnt++]];
if(scanline==143)
rb->lcd_update(); // this seems faster then doing individual scanlines
#endif /* LCD_HEIGHT */ #endif /* LCD_HEIGHT */
} }
#endif
void vid_end(void) void vid_end(void)
{ {
@ -307,19 +277,30 @@ void vid_end(void)
long timerresult; long timerresult;
void *sys_timer(void) void *sys_timer(void)
{ {/*
timerresult=*rb->current_tick; timerresult=*rb->current_tick;
return &timerresult; return &timerresult;*/
return 0;
} }
// returns microseconds passed since sys_timer // returns microseconds passed since sys_timer
int sys_elapsed(long *oldtick) 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) void sys_sleep(int us)
{ {
if(us<=0) return; if(us<=0) return;
// rb->sleep(HZ*us/1000000); int i=0;
while(i< us*11)
i++;
// if (us <= 0) return;
} }