summaryrefslogtreecommitdiffstats
path: root/apps/plugins/rockboy
diff options
context:
space:
mode:
authorTom Ross <midgey@rockbox.org>2007-10-16 18:16:22 +0000
committerTom Ross <midgey@rockbox.org>2007-10-16 18:16:22 +0000
commit437c3e40ca7579acc20b648319447045649b0873 (patch)
tree5504a232c510dff3f3872d8c7dee388fcbfafeb5 /apps/plugins/rockboy
parent0b911fefea7615105244098da1baf4655fa1e721 (diff)
downloadrockbox-437c3e40ca7579acc20b648319447045649b0873.tar.gz
rockbox-437c3e40ca7579acc20b648319447045649b0873.tar.bz2
rockbox-437c3e40ca7579acc20b648319447045649b0873.zip
Code police and clean up for rockboy.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15144 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/rockboy')
-rw-r--r--apps/plugins/rockboy/Makefile2
-rw-r--r--apps/plugins/rockboy/cpu-gb.h12
-rw-r--r--apps/plugins/rockboy/cpu.c62
-rw-r--r--apps/plugins/rockboy/emu.c3
-rw-r--r--apps/plugins/rockboy/fb.h6
-rw-r--r--apps/plugins/rockboy/hw.c18
-rw-r--r--apps/plugins/rockboy/hw.h2
-rw-r--r--apps/plugins/rockboy/lcd-gb.h11
-rw-r--r--apps/plugins/rockboy/lcd.c95
-rw-r--r--apps/plugins/rockboy/lcdc.c3
-rw-r--r--apps/plugins/rockboy/loader.c71
-rw-r--r--apps/plugins/rockboy/loader.h17
-rw-r--r--apps/plugins/rockboy/main.c41
-rw-r--r--apps/plugins/rockboy/mem.c10
-rw-r--r--apps/plugins/rockboy/mem.h2
-rw-r--r--apps/plugins/rockboy/menu.c15
-rw-r--r--apps/plugins/rockboy/palette-presets.h2
-rw-r--r--apps/plugins/rockboy/pcm.h3
-rw-r--r--apps/plugins/rockboy/rbsound.c2
-rw-r--r--apps/plugins/rockboy/rockboy.c54
-rw-r--r--apps/plugins/rockboy/rockmacros.h11
-rw-r--r--apps/plugins/rockboy/rtc.c2
-rw-r--r--apps/plugins/rockboy/save.c19
-rw-r--r--apps/plugins/rockboy/save.h2
-rw-r--r--apps/plugins/rockboy/sound.c6
-rw-r--r--apps/plugins/rockboy/sys_rockbox.c5
26 files changed, 167 insertions, 309 deletions
diff --git a/apps/plugins/rockboy/Makefile b/apps/plugins/rockboy/Makefile
index 65170bb6fd..2a372ef0c0 100644
--- a/apps/plugins/rockboy/Makefile
+++ b/apps/plugins/rockboy/Makefile
@@ -18,7 +18,7 @@ endif
LINKFILE := $(OBJDIR)/link.lds
DEPFILE = $(OBJDIR)/dep-rockboy
-SRC = cpu.c emu.c events.c fastmem.c hw.c lcd.c lcdc.c loader.c main.c \
+SRC = cpu.c emu.c events.c fastmem.c hw.c lcd.c lcdc.c loader.c \
mem.c menu.c rbsound.c rockboy.c rtc.c save.c sound.c sys_rockbox.c \
../../../firmware/common/sscanf.c
diff --git a/apps/plugins/rockboy/cpu-gb.h b/apps/plugins/rockboy/cpu-gb.h
index bbd6c84e59..d82185e479 100644
--- a/apps/plugins/rockboy/cpu-gb.h
+++ b/apps/plugins/rockboy/cpu-gb.h
@@ -23,9 +23,10 @@ struct cpu
union reg pc, sp, bc, de, hl, af;
#endif
int ime, ima;
- int speed;
- int halt;
- int div, tim;
+ unsigned int speed;
+ unsigned int halt;
+ unsigned int div;
+ int tim;
int lcdc;
int snd;
};
@@ -48,12 +49,7 @@ extern int blockclen;
#endif
void cpu_reset(void);
-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;
-inline int cpu_step(int max) ICODE_ATTR;
#endif
diff --git a/apps/plugins/rockboy/cpu.c b/apps/plugins/rockboy/cpu.c
index 2bf9e90d2b..1aca06f337 100644
--- a/apps/plugins/rockboy/cpu.c
+++ b/apps/plugins/rockboy/cpu.c
@@ -37,14 +37,14 @@ F = (F & (FL|FC)) | decflag_table[(r)]; }
#define DECW(r) ( (r)-- )
#define ADD(n) { \
-W(acc) = (un16)A + (un16)(n); \
+W(acc) = (un32)A + (un32)(n); \
F = (ZFLAG(LB(acc))) \
| (FH & ((A ^ (n) ^ LB(acc)) << 1)) \
| (HB(acc) << 4); \
A = LB(acc); }
#define ADC(n) { \
-W(acc) = (un16)A + (un16)(n) + (un16)((F&FC)>>4); \
+W(acc) = (un32)A + (un32)(n) + (un32)((F&FC)>>4); \
F = (ZFLAG(LB(acc))) \
| (FH & ((A ^ (n) ^ LB(acc)) << 1)) \
| (HB(acc) << 4); \
@@ -70,7 +70,7 @@ F = (FH & (((SP>>8) ^ ((n)>>8) ^ HB(acc)) << 1)) \
HL = W(acc); }
#define CP(n) { \
-W(acc) = (un16)A - (un16)(n); \
+W(acc) = (un32)A - (un32)(n); \
F = FN \
| (ZFLAG(LB(acc))) \
| (FH & ((A ^ (n) ^ LB(acc)) << 1)) \
@@ -79,7 +79,7 @@ F = FN \
#define SUB(n) { CP((n)); A = LB(acc); }
#define SBC(n) { \
-W(acc) = (un16)A - (un16)(n) - (un16)((F&FC)>>4); \
+W(acc) = (un32)A - (un32)(n) - (un32)((F&FC)>>4); \
F = FN \
| (ZFLAG((n8)LB(acc))) \
| (FH & ((A ^ (n) ^ LB(acc)) << 1)) \
@@ -273,18 +273,19 @@ void cpu_reset(void)
#endif
}
-
-void div_advance(int cnt)
+static void div_advance(int cnt) ICODE_ATTR;
+static void div_advance(int cnt)
{
cpu.div += (cnt<<1);
- if (cpu.div >= 256)
+ if (cpu.div >> 8)
{
R_DIV += (cpu.div >> 8);
cpu.div &= 0xff;
}
}
-void timer_advance(int cnt)
+static void timer_advance(int cnt) ICODE_ATTR;
+static void timer_advance(int cnt)
{
int unit, tima;
@@ -293,28 +294,30 @@ void timer_advance(int cnt)
unit = ((-R_TAC) & 3) << 1;
cpu.tim += (cnt<<unit);
- if (cpu.tim >= 512)
+ if (cpu.tim >> 9)
{
tima = R_TIMA + (cpu.tim >> 9);
cpu.tim &= 0x1ff;
- if (tima >= 256)
+ if (tima >> 8)
{
hw_interrupt(IF_TIMER, IF_TIMER);
hw_interrupt(0, IF_TIMER);
}
- while (tima >= 256)
+ while (tima >> 8)
tima = tima - 256 + R_TMA;
R_TIMA = tima;
}
}
-void lcdc_advance(int cnt)
+static void lcdc_advance(int cnt) ICODE_ATTR;
+static void lcdc_advance(int cnt)
{
cpu.lcdc -= cnt;
if (cpu.lcdc <= 0) lcdc_trans();
}
-void sound_advance(int cnt)
+static void sound_advance(int cnt) ICODE_ATTR;
+static void sound_advance(int cnt)
{
cpu.snd += cnt;
}
@@ -328,11 +331,16 @@ void cpu_timers(int cnt)
sound_advance(cnt);
}
-int cpu_idle(int max)
+static int cpu_idle(int max)
{
int cnt, unit;
if (!(cpu.halt && IME)) return 0;
+ if (R_IF & R_IE)
+ {
+ cpu.halt = 0;
+ return 0;
+ }
/* Make sure we don't miss lcdc status events! */
if ((R_IE & (IF_VBLANK | IF_STAT)) && (max > cpu.lcdc))
@@ -878,7 +886,7 @@ next:
PC++;
if (R_KEY1 & 1)
{
- cpu.speed = cpu.speed ^ 1;
+ cpu.speed ^= 1;
R_KEY1 = (R_KEY1 & 0x7E) | (cpu.speed << 7);
break;
}
@@ -996,27 +1004,3 @@ next:
}
#endif /* ASM_CPU_EMULATE */
-
-
-#ifndef ASM_CPU_STEP
-
-inline int cpu_step(int max)
-{
- register int cnt;
- if ((cnt = cpu_idle(max))) return cnt;
- return cpu_emulate(1);
-}
-
-#endif /* ASM_CPU_STEP */
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/apps/plugins/rockboy/emu.c b/apps/plugins/rockboy/emu.c
index d04fa9a0fb..8b75211ab0 100644
--- a/apps/plugins/rockboy/emu.c
+++ b/apps/plugins/rockboy/emu.c
@@ -7,6 +7,7 @@
#include "lcd-gb.h"
#include "sound.h"
#include "rtc-gb.h"
+#include "pcm.h"
/*
* emu_reset is called to initialize the state of the emulated
@@ -23,7 +24,7 @@ void emu_reset(void)
sound_reset();
}
-void emu_step(void)
+static void emu_step(void)
{
cpu_emulate(cpu.lcdc);
}
diff --git a/apps/plugins/rockboy/fb.h b/apps/plugins/rockboy/fb.h
index 97aeb425a0..96de665d14 100644
--- a/apps/plugins/rockboy/fb.h
+++ b/apps/plugins/rockboy/fb.h
@@ -10,15 +10,15 @@
struct fb
{
- fb_data *ptr;
+#ifdef HAVE_LCD_COLOR
struct
{
int l, r;
} cc[3];
- int enabled;
-#if !defined(HAVE_LCD_COLOR)
+#else
int mode;
#endif
+ int enabled;
};
diff --git a/apps/plugins/rockboy/hw.c b/apps/plugins/rockboy/hw.c
index 05cdfbc156..10193c0d1d 100644
--- a/apps/plugins/rockboy/hw.c
+++ b/apps/plugins/rockboy/hw.c
@@ -63,8 +63,7 @@ void hw_hdma(void)
sa = ((addr)R_HDMA1 << 8) | (R_HDMA2&0xf0);
da = 0x8000 | ((int)(R_HDMA3&0x1f) << 8) | (R_HDMA4&0xf0);
- cnt = 16;
- while (cnt--)
+ for (cnt=16; cnt>0; cnt--)
writeb(da++, readb(sa++));
cpu_timers(16);
R_HDMA1 = sa >> 8;
@@ -93,12 +92,11 @@ void hw_hdma_cmd(byte c)
/* Perform GDMA */
sa = ((addr)R_HDMA1 << 8) | (R_HDMA2&0xf0);
da = 0x8000 | ((int)(R_HDMA3&0x1f) << 8) | (R_HDMA4&0xf0);
- cnt = ((int)c)+1;
+ cnt = (((int)c)+1) << 4;
/* FIXME - this should use cpu time! */
/*cpu_timers(102 * cnt);*/
- cpu_timers((460>>cpu.speed)+cnt*16); /*dalias*/
+ cpu_timers((460>>cpu.speed)+cnt); /*dalias*/
/*cpu_timers(228 + (16*cnt));*/ /* this should be right according to no$ */
- cnt <<= 4;
while (cnt--)
writeb(da++, readb(sa++));
R_HDMA1 = sa >> 8;
@@ -115,7 +113,7 @@ void hw_hdma_cmd(byte c)
* interrupt line) if a transition has been made.
*/
-void pad_refresh()
+void pad_refresh(void)
{
byte oldp1;
oldp1 = R_P1;
@@ -139,7 +137,8 @@ void pad_refresh()
* pad.
*/
-void pad_press(byte k)
+static void pad_press(byte k) ICODE_ATTR;
+static void pad_press(byte k)
{
if (hw.pad & k)
return;
@@ -147,7 +146,8 @@ void pad_press(byte k)
pad_refresh();
}
-void pad_release(byte k)
+static void pad_release(byte k) ICODE_ATTR;
+static void pad_release(byte k)
{
if (!(hw.pad & k))
return;
@@ -160,7 +160,7 @@ void pad_set(byte k, int st)
st ? pad_press(k) : pad_release(k);
}
-void hw_reset()
+void hw_reset(void)
{
hw.ilines = hw.pad = 0;
diff --git a/apps/plugins/rockboy/hw.h b/apps/plugins/rockboy/hw.h
index 297eba30fe..67ffd9cf18 100644
--- a/apps/plugins/rockboy/hw.h
+++ b/apps/plugins/rockboy/hw.h
@@ -39,8 +39,6 @@ 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);
diff --git a/apps/plugins/rockboy/lcd-gb.h b/apps/plugins/rockboy/lcd-gb.h
index 91f2487462..36b971a88b 100644
--- a/apps/plugins/rockboy/lcd-gb.h
+++ b/apps/plugins/rockboy/lcd-gb.h
@@ -9,7 +9,7 @@ struct vissprite
{
byte *buf;
int x;
- byte pal, pri, pad[6];
+ byte pal, pri;
};
struct scan
@@ -51,15 +51,6 @@ struct lcd
extern struct lcd lcd;
extern struct scan scan;
-
-void updatepatpix(void) ICODE_ATTR;
-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_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) ICODE_ATTR;
diff --git a/apps/plugins/rockboy/lcd.c b/apps/plugins/rockboy/lcd.c
index 494160dc85..da3b138e51 100644
--- a/apps/plugins/rockboy/lcd.c
+++ b/apps/plugins/rockboy/lcd.c
@@ -5,7 +5,9 @@
#include "mem.h"
#include "lcd-gb.h"
#include "fb.h"
+#ifdef HAVE_LCD_COLOR
#include "palette-presets.h"
+#endif
#ifdef USE_ASM
#include "asm.h"
#endif
@@ -59,7 +61,8 @@ static int dmg_pal[4][4];
fb_data *vdest;
#ifndef ASM_UPDATEPATPIX
-void updatepatpix(void)
+static void updatepatpix(void) ICODE_ATTR;
+static void updatepatpix(void)
{
int i, j;
#if ((CONFIG_CPU != SH7034) && !defined(CPU_COLDFIRE))
@@ -366,7 +369,8 @@ void updatepatpix(void)
-void tilebuf(void)
+static void tilebuf(void) ICODE_ATTR;
+static void tilebuf(void)
{
int i, cnt;
int base;
@@ -468,7 +472,8 @@ void tilebuf(void)
* WX = WND start (if 0, no need to do anything) -> WY
* U = start...something...thingy... 7 at most
*/
-void bg_scan(void)
+static void bg_scan(void) ICODE_ATTR;
+static void bg_scan(void)
{
int cnt;
byte *src, *dest;
@@ -508,7 +513,8 @@ void bg_scan(void)
*(dest++) = *(src++);
}
-void wnd_scan(void)
+static void wnd_scan(void) ICODE_ATTR;
+static void wnd_scan(void)
{
int cnt;
byte *src, *dest;
@@ -554,7 +560,8 @@ static int priused(void *attr)
return (int)((a[0]|a[1]|a[2]|a[3]|a[4]|a[5]|a[6]|a[7])&0x80808080);
}
-void bg_scan_pri(void)
+static void bg_scan_pri(void) ICODE_ATTR;
+static void bg_scan_pri(void)
{
int cnt, i;
byte *src, *dest;
@@ -584,7 +591,8 @@ void bg_scan_pri(void)
memset(dest, src[i&31]&128, cnt);
}
-void wnd_scan_pri(void)
+static void wnd_scan_pri(void) ICODE_ATTR;
+static void wnd_scan_pri(void)
{
int cnt, i;
byte *src, *dest;
@@ -610,7 +618,7 @@ void wnd_scan_pri(void)
memset(dest, src[i]&128, cnt);
}
-void bg_scan_color(void)
+static void bg_scan_color(void)
{
int cnt;
byte *src, *dest;
@@ -684,7 +692,7 @@ void bg_scan_color(void)
blendcpy(dest, src, *(tile++), cnt);
}
-void wnd_scan_color(void)
+static void wnd_scan_color(void)
{
int cnt;
byte *src, *dest;
@@ -706,12 +714,8 @@ void wnd_scan_color(void)
blendcpy(dest, src, *(tile++), cnt);
}
-static void recolor(byte *buf, byte fill, int cnt)
-{
- while (cnt--) *(buf++) |= fill;
-}
-
-void spr_enum(void)
+static void spr_enum(void) ICODE_ATTR;
+static void spr_enum(void)
{
int i, j;
struct obj *o;
@@ -764,14 +768,15 @@ void spr_enum(void)
if (VS[i].x > VS[j].x)
{
ts = VS[i];
- VS[i] = VS[j];
- VS[j] = ts;
+ VS[i] = VS[j];
+ VS[j] = ts;
}
}
}
}
-void spr_scan(void)
+static void spr_scan(void) ICODE_ATTR;
+static void spr_scan(void)
{
int i, x;
byte pal, b, ns = NS;
@@ -874,26 +879,27 @@ void lcd_begin(void)
#define S3R ((LCD_HEIGHT-((160*DXR)>>16))/2)*LCD_WIDTH+LCD_WIDTH-1
#endif
- set_pal();
-
+ vdest=rb->lcd_framebuffer;
#ifdef HAVE_LCD_COLOR
+ set_pal();
+
if(options.rotate)
{
- if(options.fullscreen == 0)
- vdest=fb.ptr+S2R;
- else if (options.fullscreen == 1)
- vdest=fb.ptr+S3R;
+ if(options.scaling == 0)
+ vdest+=+S2R;
+ else if (options.scaling == 1)
+ vdest+=S3R;
else
- vdest=fb.ptr+S1R;
+ vdest+=S1R;
}
else
{
- if(options.fullscreen == 0)
- vdest=fb.ptr+S2;
- else if (options.fullscreen == 1)
- vdest=fb.ptr+S3;
+ if(options.scaling == 0)
+ vdest+=S2;
+ else if (options.scaling == 1)
+ vdest+=S3;
else
- vdest=fb.ptr+S1;
+ vdest+=S1;
}
#endif
WY = R_WY;
@@ -911,7 +917,7 @@ int sremain IDATA_ATTR=LCD_WIDTH-160;
void setvidmode(void)
{
#ifdef HAVE_LCD_COLOR
- switch(options.fullscreen)
+ switch(options.scaling)
{
case 0:
if(options.rotate)
@@ -1036,7 +1042,6 @@ void lcd_refreshline(void)
bg_scan();
wnd_scan();
- recolor(BUF+WX, 0x04, 160-WX);
}
spr_scan();
@@ -1097,13 +1102,13 @@ void lcd_refreshline(void)
#endif
}
+#ifdef HAVE_LCD_COLOR
void set_pal(void)
{
- memcpy(dmg_pal,palettes[options.pal], sizeof dmg_pal);
+ memcpy(dmg_pal,palettes[options.pal], sizeof(dmg_pal));
pal_dirty();
}
-#ifdef HAVE_LCD_COLOR
static void updatepalette(int i)
{
int c, r, g, b;
@@ -1127,13 +1132,13 @@ static void updatepalette(int i)
#endif
PAL[i] = c;
}
-#endif
+#endif /* HAVE_LCD_COLOR */
void pal_write(int i, byte b)
{
if (lcd.pal[i] == b) return;
lcd.pal[i] = b;
-#if LCD_DEPTH ==16
+#ifdef HAVE_LCD_COLOR
updatepalette(i>>1);
#endif
}
@@ -1175,7 +1180,7 @@ void vram_dirty(void)
void pal_dirty(void)
{
-#if LCD_DEPTH ==16
+#ifdef HAVE_LCD_COLOR
int i;
#endif
if (!hw.cgb)
@@ -1186,7 +1191,7 @@ void pal_dirty(void)
pal_write_dmg(64, 2, R_OBP0);
pal_write_dmg(72, 3, R_OBP1);
}
-#if LCD_DEPTH ==16
+#ifdef HAVE_LCD_COLOR
for (i = 0; i < 64; i++)
updatepalette(i);
#endif
@@ -1198,19 +1203,3 @@ void lcd_reset(void)
lcd_begin();
vram_dirty();
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/apps/plugins/rockboy/lcdc.c b/apps/plugins/rockboy/lcdc.c
index 90575bbef8..2a1b094929 100644
--- a/apps/plugins/rockboy/lcdc.c
+++ b/apps/plugins/rockboy/lcdc.c
@@ -47,9 +47,8 @@ void stat_trigger(void)
* update the STAT interrupt line.
*/
-static void stat_change(int stat)
+static void stat_change(unsigned int stat)
{
- stat &= 3;
R_STAT = (R_STAT & 0x7C) | stat;
if (stat != 1) hw_interrupt(0, IF_VBLANK);
diff --git a/apps/plugins/rockboy/loader.c b/apps/plugins/rockboy/loader.c
index bdccb2e7e1..d48a06957e 100644
--- a/apps/plugins/rockboy/loader.c
+++ b/apps/plugins/rockboy/loader.c
@@ -26,7 +26,7 @@
* 11 - ROM+MBC3
*/
-static int mbc_table[256] =
+static const int mbc_table[256] =
{
MBC_NONE,
MBC_MBC1,
@@ -81,7 +81,7 @@ static int mbc_table[256] =
MBC_HUC1
};
-static unsigned short romsize_table[56] =
+static const unsigned short romsize_table[56] =
{
2, 4, 8, 16, 32, 64, 128, 256,
512, 0, 0, 0, 0, 0, 0, 0,
@@ -94,7 +94,7 @@ static unsigned short romsize_table[56] =
};
/* Ram size should be no larger then 16 banks 1Mbit */
-static unsigned char ramsize_table[5] =
+static const unsigned char ramsize_table[5] =
{
0, 1, 1, 4, 16
};
@@ -104,8 +104,6 @@ static char sramfile[500];
static char rtcfile[500];
static char saveprefix[500];
-static int saveslot;
-
static int forcebatt, nobatt;
static int forcedmg;
@@ -142,7 +140,7 @@ static byte *loadfile(int fd, int *len)
return d;
}
-int rom_load(void)
+static int rom_load(void)
{
int fd;
byte c, *data, *header;
@@ -220,7 +218,7 @@ int rom_load(void)
return 0;
}
-int sram_load(void)
+static int sram_load(void)
{
int fd;
char meow[500];
@@ -243,7 +241,7 @@ int sram_load(void)
}
-int sram_save(void)
+static int sram_save(void)
{
int fd;
char meow[500];
@@ -261,45 +259,7 @@ int sram_save(void)
return 0;
}
-
-void state_save(int n)
-{
- int fd;
- char name[500];
-
- if (n < 0) n = saveslot;
- if (n < 0) n = 0;
- snprintf(name, 499,"%s.%03d", saveprefix, n);
-
- if ((fd = open(name, O_WRONLY|O_CREAT|O_TRUNC)>=0))
- {
- savestate(fd);
- close(fd);
- }
-}
-
-
-void state_load(int n)
-{
- int fd;
- char name[500];
-
- if (n < 0) n = saveslot;
- if (n < 0) n = 0;
- snprintf(name, 499, "%s.%03d", saveprefix, n);
-
- if ((fd = open(name, O_RDONLY)>=0))
- {
- loadstate(fd);
- close(fd);
- vram_dirty();
- pal_dirty();
- sound_dirty();
- mem_updatemap();
- }
-}
-
-void rtc_save(void)
+static void rtc_save(void)
{
int fd;
if (!rtc.batt) return;
@@ -308,7 +268,7 @@ void rtc_save(void)
close(fd);
}
-void rtc_load(void)
+static void rtc_load(void)
{
int fd;
if (!rtc.batt) return;
@@ -317,21 +277,6 @@ void rtc_load(void)
close(fd);
}
-
-void loader_unload(void)
-{
- sram_save();
- /* if (romfile) free(romfile);
- if (sramfile) free(sramfile);
- if (saveprefix) free(saveprefix);
- if (rom.bank) free(rom.bank);
- if (ram.sbank) free(ram.sbank); */
- romfile = 0;
- rom.bank = 0;
- ram.sbank = 0;
- mbc.type = mbc.romsize = mbc.ramsize = mbc.batt = 0;
-}
-
void cleanup(void)
{
sram_save();
diff --git a/apps/plugins/rockboy/loader.h b/apps/plugins/rockboy/loader.h
index 2eeb469403..33217d55f3 100644
--- a/apps/plugins/rockboy/loader.h
+++ b/apps/plugins/rockboy/loader.h
@@ -3,23 +3,6 @@
#ifndef __LOADER_H__
#define __LOADER_H__
-
-typedef struct loader_s
-{
- char *rom;
- char *base;
- char *sram;
- char *state;
- int ramloaded;
-} loader_t;
-
-
-extern loader_t loader;
-
-
-int rom_load(void);
-int sram_load(void);
-int sram_save(void);
void loader_init(char *s);
void cleanup(void);
diff --git a/apps/plugins/rockboy/main.c b/apps/plugins/rockboy/main.c
deleted file mode 100644
index bb6b6bd2d7..0000000000
--- a/apps/plugins/rockboy/main.c
+++ /dev/null
@@ -1,41 +0,0 @@
-#include "rockmacros.h"
-#include "input.h"
-#include "emu.h"
-#include "loader.h"
-#include "hw.h"
-
-void doevents()
-{
- event_t ev;
- int st;
-
- ev_poll();
- while (ev_getevent(&ev))
- {
- if (ev.type != EV_PRESS && ev.type != EV_RELEASE)
- continue;
- st = (ev.type != EV_RELEASE);
- pad_set(ev.code, st);
- }
-}
-
-int gnuboy_main(char *rom)
-{
- rb->lcd_puts(0,0,"Init video");
- vid_init();
- rb->lcd_puts(0,1,"Init sound");
- pcm_init();
- rb->lcd_puts(0,2,"Loading rom");
- loader_init(rom);
- if(shut)
- return PLUGIN_ERROR;
- rb->lcd_puts(0,3,"Emu reset");
- emu_reset();
- rb->lcd_puts(0,4,"Emu run");
- rb->lcd_clear_display();
- rb->lcd_update();
- emu_run();
-
- /* never reached */
- return PLUGIN_OK;
-}
diff --git a/apps/plugins/rockboy/mem.c b/apps/plugins/rockboy/mem.c
index 6811fd5f81..93072f5d51 100644
--- a/apps/plugins/rockboy/mem.c
+++ b/apps/plugins/rockboy/mem.c
@@ -28,7 +28,7 @@ struct ram ram;
* make the old maps potentially invalid.
*/
-void mem_updatemap()
+void mem_updatemap(void)
{
int n;
static byte **map;
@@ -93,7 +93,8 @@ void mem_updatemap()
* byte value to be written.
*/
-void ioreg_write(byte r, byte b)
+static void ioreg_write(byte r, byte b) ICODE_ATTR;
+static void ioreg_write(byte r, byte b)
{
if (!hw.cgb)
{
@@ -225,7 +226,7 @@ void ioreg_write(byte r, byte b)
}
-byte ioreg_read(byte r)
+static byte ioreg_read(byte r)
{
switch(r)
{
@@ -282,7 +283,8 @@ byte ioreg_read(byte r)
* and a byte value written to the address.
*/
-void mbc_write(int a, byte b)
+static void mbc_write(int a, byte b) ICODE_ATTR;
+static void mbc_write(int a, byte b)
{
byte ha = (a>>12);
diff --git a/apps/plugins/rockboy/mem.h b/apps/plugins/rockboy/mem.h
index 338fd98bf0..d4097eff6d 100644
--- a/apps/plugins/rockboy/mem.h
+++ b/apps/plugins/rockboy/mem.h
@@ -46,8 +46,6 @@ extern struct rom rom;
extern struct ram ram;
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 e896e26c20..eead812b61 100644
--- a/apps/plugins/rockboy/menu.c
+++ b/apps/plugins/rockboy/menu.c
@@ -7,16 +7,17 @@
#include "button.h"
#include "rockmacros.h"
#include "mem.h"
+#include "save.h"
#include "lib/oldmenuapi.h"
#include "rtc-gb.h"
-#if (CONFIG_KEYPAD == IPOD_4G_PAD)
+#if CONFIG_KEYPAD == IPOD_4G_PAD
#define MENU_BUTTON_UP BUTTON_SCROLL_BACK
#define MENU_BUTTON_DOWN BUTTON_SCROLL_FWD
#define MENU_BUTTON_LEFT BUTTON_LEFT
#define MENU_BUTTON_RIGHT BUTTON_RIGHT
-#elif (CONFIG_KEYPAD == IRIVER_H10_PAD)
+#elif CONFIG_KEYPAD == IRIVER_H10_PAD
#define MENU_BUTTON_UP BUTTON_SCROLL_UP
#define MENU_BUTTON_DOWN BUTTON_SCROLL_DOWN
#define MENU_BUTTON_LEFT BUTTON_LEFT
@@ -37,7 +38,7 @@ static void munge_name(char *buf, size_t bufsiz);
/* directory ROM save slots belong in */
#define STATE_DIR ROCKBOX_DIR "/rockboy"
-int getbutton(char *text)
+static int getbutton(char *text)
{
int fw, fh;
rb->lcd_clear_display();
@@ -59,7 +60,7 @@ int getbutton(char *text)
}
}
-void setupkeys(void)
+static void setupkeys(void)
{
options.UP=getbutton ("Press Up");
options.DOWN=getbutton ("Press Down");
@@ -348,7 +349,7 @@ static void do_opt_menu(void)
};
#ifdef HAVE_LCD_COLOR
- static const struct opt_items fullscreen[]= {
+ static const struct opt_items scaling[]= {
{ "Scaled", -1 },
{ "Scaled - Maintain Ratio", -1 },
#if (LCD_WIDTH>=160) && (LCD_HEIGHT>=144)
@@ -417,8 +418,8 @@ static void do_opt_menu(void)
break;
#ifdef HAVE_LCD_COLOR
case 4: /* Screen Size */
- rb->set_option(items[4].desc, &options.fullscreen, INT, fullscreen,
- sizeof(fullscreen)/sizeof(*fullscreen), NULL );
+ rb->set_option(items[4].desc, &options.scaling, INT, scaling,
+ sizeof(scaling)/sizeof(*scaling), NULL );
setvidmode();
break;
case 5: /* Screen rotate */
diff --git a/apps/plugins/rockboy/palette-presets.h b/apps/plugins/rockboy/palette-presets.h
index 86c3898e06..9be79f6901 100644
--- a/apps/plugins/rockboy/palette-presets.h
+++ b/apps/plugins/rockboy/palette-presets.h
@@ -5,7 +5,7 @@
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
- * $Id: palette-presets.h $
+ * $Id$
*
* All files in this archive are subject to the GNU General Public License.
* See the file COPYING in the source tree root for full license agreement.
diff --git a/apps/plugins/rockboy/pcm.h b/apps/plugins/rockboy/pcm.h
index f009f5708c..b90bba087f 100644
--- a/apps/plugins/rockboy/pcm.h
+++ b/apps/plugins/rockboy/pcm.h
@@ -15,6 +15,9 @@ struct pcm
extern struct pcm pcm;
+void pcm_init(void);
+int pcm_submit(void);
+void pcm_close(void);
#endif
diff --git a/apps/plugins/rockboy/rbsound.c b/apps/plugins/rockboy/rbsound.c
index b5cfc96fa4..ac5a29c517 100644
--- a/apps/plugins/rockboy/rbsound.c
+++ b/apps/plugins/rockboy/rbsound.c
@@ -16,7 +16,7 @@ static unsigned short *buf=0, *hwbuf=0;
static bool newly_started;
-void get_more(unsigned char** start, size_t* size)
+static void get_more(unsigned char** start, size_t* size)
{
memcpy(hwbuf, &buf[pcm.len*doneplay], BUF_SIZE*sizeof(short));
*start = (unsigned char*)(hwbuf);
diff --git a/apps/plugins/rockboy/rockboy.c b/apps/plugins/rockboy/rockboy.c
index a72a3a9e32..1cf4b7134b 100644
--- a/apps/plugins/rockboy/rockboy.c
+++ b/apps/plugins/rockboy/rockboy.c
@@ -19,6 +19,10 @@
#include "plugin.h"
#include "loader.h"
#include "rockmacros.h"
+#include "input.h"
+#include "emu.h"
+#include "hw.h"
+#include "pcm.h"
PLUGIN_HEADER
PLUGIN_IRAM_DECLARE
@@ -29,8 +33,6 @@ PLUGIN_IRAM_DECLARE
struct plugin_api* rb;
int shut,cleanshut;
char *errormsg;
-int gnuboy_main(char *rom);
-void pcm_close(void);
#define optionname "options"
@@ -65,7 +67,7 @@ void* memcpy(void* dst, const void* src, size_t size)
return rb->memcpy(dst, src, size);
}
-void setoptions (void)
+static void setoptions (void)
{
int fd;
DIR* dir;
@@ -85,7 +87,7 @@ void setoptions (void)
options.LEFT=BUTTON_LEFT;
options.RIGHT=BUTTON_RIGHT;
-#if (CONFIG_KEYPAD == IRIVER_H100_PAD)
+#if CONFIG_KEYPAD == IRIVER_H100_PAD
options.UP=BUTTON_UP;
options.DOWN=BUTTON_DOWN;
@@ -95,7 +97,7 @@ void setoptions (void)
options.SELECT=BUTTON_SELECT;
options.MENU=BUTTON_MODE;
-#elif (CONFIG_KEYPAD == IRIVER_H300_PAD)
+#elif CONFIG_KEYPAD == IRIVER_H300_PAD
options.UP=BUTTON_UP;
options.DOWN=BUTTON_DOWN;
@@ -190,9 +192,9 @@ void setoptions (void)
options.fps=0;
options.showstats=0;
#if (LCD_WIDTH>=160) && (LCD_HEIGHT>=144)
- options.fullscreen=0;
+ options.scaling=0;
#else
- options.fullscreen=1;
+ options.scaling=1;
#endif
options.sound=1;
options.pal=0;
@@ -203,7 +205,7 @@ void setoptions (void)
close(fd);
}
-void savesettings(void)
+static void savesettings(void)
{
int fd;
char optionsave[sizeof(savedir)+sizeof(optionname)];
@@ -218,6 +220,42 @@ void savesettings(void)
}
}
+void doevents(void)
+{
+ event_t ev;
+ int st;
+
+ ev_poll();
+ while (ev_getevent(&ev))
+ {
+ if (ev.type != EV_PRESS && ev.type != EV_RELEASE)
+ continue;
+ st = (ev.type != EV_RELEASE);
+ pad_set(ev.code, st);
+ }
+}
+
+static int gnuboy_main(char *rom)
+{
+ rb->lcd_puts(0,0,"Init video");
+ vid_init();
+ rb->lcd_puts(0,1,"Init sound");
+ pcm_init();
+ rb->lcd_puts(0,2,"Loading rom");
+ loader_init(rom);
+ if(shut)
+ return PLUGIN_ERROR;
+ rb->lcd_puts(0,3,"Emu reset");
+ emu_reset();
+ rb->lcd_puts(0,4,"Emu run");
+ rb->lcd_clear_display();
+ rb->lcd_update();
+ emu_run();
+
+ /* never reached */
+ return PLUGIN_OK;
+}
+
/* this is the plugin entry point */
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{
diff --git a/apps/plugins/rockboy/rockmacros.h b/apps/plugins/rockboy/rockmacros.h
index a138fae2dd..89cb845ec2 100644
--- a/apps/plugins/rockboy/rockmacros.h
+++ b/apps/plugins/rockboy/rockmacros.h
@@ -31,18 +31,13 @@ extern int shut,cleanshut;
void vid_init(void);
inline void vid_begin(void);
void die(char *message, ...);
-void *sys_timer(void);
-int sys_elapsed(long *oldtick);
-int pcm_submit(void);
-void pcm_init(void);
void doevents(void) ICODE_ATTR;
void ev_poll(void);
int do_user_menu(void);
-void loadstate(int fd);
-void savestate(int fd);
void setvidmode(void);
+#if defined(HAVE_LCD_COLOR)
void set_pal(void);
-#if !defined(HAVE_LCD_COLOR)
+#else
void vid_update(int scanline);
#endif
#ifdef DYNAREC
@@ -106,7 +101,7 @@ struct options {
int A, B, START, SELECT, MENU;
int UP, DOWN, LEFT, RIGHT;
int frameskip, fps, maxskip;
- int sound, fullscreen, showstats;
+ int sound, scaling, showstats;
int rotate;
int pal;
int dirty;
diff --git a/apps/plugins/rockboy/rtc.c b/apps/plugins/rockboy/rtc.c
index 17b2853fce..6f33bc4f9d 100644
--- a/apps/plugins/rockboy/rtc.c
+++ b/apps/plugins/rockboy/rtc.c
@@ -58,7 +58,7 @@ void rtc_write(byte b)
}
}
-void rtc_tick()
+void rtc_tick(void)
{
if (rtc.stop) return;
if (++rtc.t == 60)
diff --git a/apps/plugins/rockboy/save.c b/apps/plugins/rockboy/save.c
index 3f6c179beb..4211ceb77f 100644
--- a/apps/plugins/rockboy/save.c
+++ b/apps/plugins/rockboy/save.c
@@ -274,22 +274,3 @@ void savestate(int fd)
lseek(fd, base_offset + (sramblock << 12), SEEK_SET);
write(fd,ram.sbank, 4096*srl);
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/apps/plugins/rockboy/save.h b/apps/plugins/rockboy/save.h
index 01b3b14f05..8c1041038b 100644
--- a/apps/plugins/rockboy/save.h
+++ b/apps/plugins/rockboy/save.h
@@ -1,4 +1,2 @@
void loadstate(int fd);
void savestate(int fd);
-void state_save(int n);
-void state_load(int n);
diff --git a/apps/plugins/rockboy/sound.c b/apps/plugins/rockboy/sound.c
index c5621d343a..175260b590 100644
--- a/apps/plugins/rockboy/sound.c
+++ b/apps/plugins/rockboy/sound.c
@@ -302,7 +302,7 @@ static void gbSoundChannel3(int *r, int *l)
}
}
-void gbSoundChannel4(int *r, int *l)
+static void gbSoundChannel4(int *r, int *l)
{
int vol = S4.envol;
@@ -669,7 +669,7 @@ void sound_write(byte r, byte b)
snd.gbDigitalSound = false;
}
-void sound_reset()
+void sound_reset(void)
{
snd.level1 = 7;
snd.level2 = 7;
@@ -737,7 +737,7 @@ void sound_reset()
else snd.rate = 0;
}
-void sound_dirty()
+void sound_dirty(void)
{
sound_write(RI_NR10, R_NR10);
sound_write(RI_NR11, R_NR11);
diff --git a/apps/plugins/rockboy/sys_rockbox.c b/apps/plugins/rockboy/sys_rockbox.c
index fe3326737d..313e8ae46b 100644
--- a/apps/plugins/rockboy/sys_rockbox.c
+++ b/apps/plugins/rockboy/sys_rockbox.c
@@ -24,12 +24,10 @@
#include "hw.h"
#include "config.h"
-#if (CONFIG_KEYPAD == SANSA_E200_PAD)
-
+#if CONFIG_KEYPAD == SANSA_E200_PAD
#define ROCKBOY_SCROLLWHEEL
#define ROCKBOY_SCROLLWHEEL_CC BUTTON_SCROLL_UP
#define ROCKBOY_SCROLLWHEEL_CW BUTTON_SCROLL_DOWN
-
#endif
struct fb fb IBSS_ATTR;
@@ -210,7 +208,6 @@ inline void vid_begin(void)
void vid_init(void)
{
fb.enabled=1;
- fb.ptr=rb->lcd_framebuffer;
#if defined(HAVE_LCD_COLOR)
fb.cc[0].r = 3; /* 8-5 (wasted bits on red) */