summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl Kurbjun <kkurbjun@gmail.com>2009-08-09 03:20:55 +0000
committerKarl Kurbjun <kkurbjun@gmail.com>2009-08-09 03:20:55 +0000
commit4cded9c7b96957afe596f6647c52b7e9d07c3b1b (patch)
tree3dfeac6cf3815850e42f7699d99cc77ea5581ba2
parent7f971e017670880685be276898ec80189ee0940b (diff)
downloadrockbox-4cded9c7b96957afe596f6647c52b7e9d07c3b1b.tar.gz
rockbox-4cded9c7b96957afe596f6647c52b7e9d07c3b1b.zip
Rockboy: Significantly reduce the number of palette updates, add support for hardware palette mode, screen can now be rotated left or right.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22214 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/rockboy/emu.c1
-rw-r--r--apps/plugins/rockboy/lcd.c91
-rw-r--r--apps/plugins/rockboy/mem.c8
-rw-r--r--apps/plugins/rockboy/menu.c36
-rw-r--r--apps/plugins/rockboy/rockboy.c9
5 files changed, 102 insertions, 43 deletions
diff --git a/apps/plugins/rockboy/emu.c b/apps/plugins/rockboy/emu.c
index 8b75211ab0..1e171cbae2 100644
--- a/apps/plugins/rockboy/emu.c
+++ b/apps/plugins/rockboy/emu.c
@@ -41,6 +41,7 @@ void emu_run(void)
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
rb->cpu_boost(true);
#endif
+ set_pal();
while(!shut)
{
diff --git a/apps/plugins/rockboy/lcd.c b/apps/plugins/rockboy/lcd.c
index 372e9e0736..0da9fc7e9d 100644
--- a/apps/plugins/rockboy/lcd.c
+++ b/apps/plugins/rockboy/lcd.c
@@ -58,7 +58,11 @@ static int scanline_ind=0;
static int dmg_pal[4][4];
+#if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256)
+unsigned char *vdest;
+#else
fb_data *vdest;
+#endif
#ifndef ASM_UPDATEPATPIX
static void updatepatpix(void) ICODE_ATTR;
@@ -843,9 +847,12 @@ static void spr_scan(void)
#define DYR ((LCD_HEIGHT<<16) / 160)
#define DYIR ((160<<16) / LCD_HEIGHT)
-void lcd_begin(void)
-{
-
+/* Defines for scale offsets:
+ * S2 is for scaled
+ * S3 if scaled and maintain ratio
+ * S1 is unscaled
+ * R's are the rotated defines
+ */
#if (LCD_WIDTH>=160) && (LCD_HEIGHT>=144)
#define S1 ((LCD_HEIGHT-144)/2)*LCD_WIDTH + ((LCD_WIDTH-160)/2)
#define S2 0
@@ -879,21 +886,31 @@ void lcd_begin(void)
#define S3R ((LCD_HEIGHT-((160*DXR)>>16))/2)*LCD_WIDTH+LCD_WIDTH-1
#endif
+void lcd_begin(void)
+{
+#if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256)
+ vdest=(unsigned char*)rb->lcd_framebuffer;
+#else
vdest=rb->lcd_framebuffer;
+#endif
+
#ifdef HAVE_LCD_COLOR
- set_pal();
- if(options.rotate)
- {
+ if(options.rotate==1) {
if(options.scaling == 0)
- vdest+=+S2R;
+ vdest+=S2R;
else if (options.scaling == 1)
vdest+=S3R;
else
vdest+=S1R;
- }
- else
- {
+ } else if(options.rotate==2) {
+ if(options.scaling == 0)
+ vdest+=(LCD_WIDTH*LCD_HEIGHT)-S2R;
+ else if (options.scaling == 1)
+ vdest+=(LCD_WIDTH*LCD_HEIGHT)-S3R;
+ else
+ vdest+=(LCD_WIDTH*LCD_HEIGHT)-S1R-144;
+ } else {
if(options.scaling == 0)
vdest+=S2;
else if (options.scaling == 1)
@@ -916,6 +933,7 @@ int sremain IDATA_ATTR=LCD_WIDTH-160;
void setvidmode(void)
{
+
#ifdef HAVE_LCD_COLOR
switch(options.scaling)
{
@@ -977,12 +995,15 @@ void setvidmode(void)
SCALEHL=1<<16;
SCALEHS=1<<16;
}
- swidth=(160*SCALEWL)>>16;
+ swidth=((160*SCALEWL)>>16);
- if(options.rotate)
+ if(options.rotate==1) {
sremain=-(((160*SCALEWL)>>16)*LCD_WIDTH+1);
- else
+ } else if(options.rotate==2) {
+ sremain=(((160*SCALEWL)>>16)*LCD_WIDTH+1);
+ } else {
sremain=LCD_WIDTH-swidth;
+ }
#endif
}
@@ -1067,18 +1088,24 @@ void lcd_refreshline(void)
hpt+=SCALEHS;
register unsigned int srcpt=0x8000;
register unsigned int wcount=swidth;
- register unsigned int remain=sremain;
while(wcount--)
{
+#if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256)
+ *vdest = BUF[srcpt>>16];
+#else
*vdest = PAL[BUF[srcpt>>16]];
- if (options.rotate)
+#endif
+ if (options.rotate == 1) {
vdest+=LCD_WIDTH;
- else
+ } else if (options.rotate == 2) {
+ vdest-=LCD_WIDTH;
+ } else {
vdest++;
+ }
srcpt+=SCALEWS;
}
- vdest+=remain;
+ vdest+=sremain;
}
if(L==143)
@@ -1087,10 +1114,24 @@ void lcd_refreshline(void)
{
snprintf(frameout,sizeof(frameout),"FPS: %d Frameskip: %d ",options.fps, options.frameskip);
rb->lcd_putsxy(0,LCD_HEIGHT-10,frameout);
+ rb->lcd_update_rect(0,LCD_HEIGHT-10, LCD_WIDTH, 10);
}
hpt=0x8000;
- rb->lcd_update();
+
+#if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256)
+ if(options.scaling==3) {
+ rb->lcd_blit_pal256((unsigned char*)rb->lcd_framebuffer,(LCD_WIDTH-160)/2, (LCD_HEIGHT-144)/2, (LCD_WIDTH-160)/2, (LCD_HEIGHT-144)/2, 160, 144);
+ } else {
+ rb->lcd_blit_pal256((unsigned char*)rb->lcd_framebuffer,0,0,0,0,LCD_WIDTH,LCD_HEIGHT);
+ }
+#else
+ if(options.scaling==3) {
+ rb->lcd_update_rect( (LCD_WIDTH-160)/2, (LCD_HEIGHT-144)/2, 160, 144);
+ } else {
+ rb->lcd_update();
+ }
+#endif
}
#endif
@@ -1130,7 +1171,17 @@ static void updatepalette(int i)
#elif LCD_PIXELFORMAT == RGB565SWAPPED
c = swap16(r|g|b);
#endif
- PAL[i] = c;
+
+ /* updatepalette might get called, but the pallete does not necessarily
+ * need to be updated.
+ */
+ if(PAL[i]!=c)
+ {
+ PAL[i] = c;
+#if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256)
+ rb->lcd_pal256_update_pal(PAL);
+#endif
+ }
}
#endif /* HAVE_LCD_COLOR */
@@ -1170,6 +1221,7 @@ void vram_write(addr a, byte b)
if (a >= 0x1800) return;
patdirty[((R_VBK&1)<<9)+(a>>4)] = 1;
anydirty = 1;
+ pal_dirty();
}
void vram_dirty(void)
@@ -1203,3 +1255,4 @@ void lcd_reset(void)
lcd_begin();
vram_dirty();
}
+
diff --git a/apps/plugins/rockboy/mem.c b/apps/plugins/rockboy/mem.c
index 93072f5d51..e00dadfa3c 100644
--- a/apps/plugins/rockboy/mem.c
+++ b/apps/plugins/rockboy/mem.c
@@ -129,18 +129,18 @@ static void ioreg_write(byte r, byte b)
break;
case RI_BGP:
if (R_BGP == b) break;
- /* pal_write_dmg(0, 0, b); */ /*Disabled in iBoy and WAC-gnuboyCE */
- /* pal_write_dmg(8, 1, b); */ /*Disabled in iBoy and WAC-gnuboyCE */
+ pal_write_dmg(0, 0, b);
+ pal_write_dmg(8, 1, b);
R_BGP = b;
break;
case RI_OBP0:
if (R_OBP0 == b) break;
- /* pal_write_dmg(64, 2, b); */ /*Disabled in iBoy and WAC-gnuboyCE */
+ pal_write_dmg(64, 2, b);
R_OBP0 = b;
break;
case RI_OBP1:
if (R_OBP1 == b) break;
- /* pal_write_dmg(72, 3, b); */ /*Disabled in iBoy and WAC-gnuboyCE */
+ pal_write_dmg(72, 3, b);
R_OBP1 = b;
break;
case RI_IF:
diff --git a/apps/plugins/rockboy/menu.c b/apps/plugins/rockboy/menu.c
index 76de224294..cc12e8e67a 100644
--- a/apps/plugins/rockboy/menu.c
+++ b/apps/plugins/rockboy/menu.c
@@ -11,25 +11,6 @@
#include "rtc-gb.h"
#include "pcm.h"
-#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
-#define MENU_BUTTON_UP BUTTON_SCROLL_UP
-#define MENU_BUTTON_DOWN BUTTON_SCROLL_DOWN
-#define MENU_BUTTON_LEFT BUTTON_LEFT
-#define MENU_BUTTON_RIGHT BUTTON_RIGHT
-
-#else
-#define MENU_BUTTON_UP BUTTON_UP
-#define MENU_BUTTON_DOWN BUTTON_DOWN
-#define MENU_BUTTON_LEFT BUTTON_LEFT
-#define MENU_BUTTON_RIGHT BUTTON_RIGHT
-#endif
-
/* load/save state function declarations */
static void do_opt_menu(void);
static void do_slot_menu(bool is_load);
@@ -92,6 +73,10 @@ int do_user_menu(void) {
time = rb->mktime(rb->get_time());
#endif
+#if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256)
+ rb->lcd_set_mode(LCD_MODE_RGB565);
+#endif
+
/* Clean out the button Queue */
while (rb->button_get(false) != BUTTON_NONE)
rb->yield();
@@ -136,6 +121,10 @@ int do_user_menu(void) {
#endif
while (time-- > 0) rtc_tick();
+#if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256)
+ rb->lcd_set_mode(LCD_MODE_PAL256);
+#endif
+
return ret;
}
@@ -344,6 +333,12 @@ static void do_opt_menu(void)
{ "On" , -1 },
};
+ static const struct opt_items rotate[] = {
+ { "No rotation", -1 },
+ { "Rotate Right" , -1 },
+ { "Rotate Left" , -1 },
+ };
+
static const struct opt_items frameskip[]= {
{ "0 Max", -1 },
{ "1 Max", -1 },
@@ -421,7 +416,8 @@ static void do_opt_menu(void)
setvidmode();
break;
case 5: /* Screen rotate */
- rb->set_option("Screen Rotate", &options.rotate, INT, onoff, 2, NULL );
+ rb->set_option("Screen Rotate", &options.rotate, INT, rotate,
+ sizeof(rotate)/sizeof(*rotate), NULL );
setvidmode();
break;
case 6: /* Palette */
diff --git a/apps/plugins/rockboy/rockboy.c b/apps/plugins/rockboy/rockboy.c
index ed75fb7d17..d073f9306f 100644
--- a/apps/plugins/rockboy/rockboy.c
+++ b/apps/plugins/rockboy/rockboy.c
@@ -385,12 +385,20 @@ enum plugin_status plugin_start(const void* parameter)
rb->wheel_send_events(false);
#endif
+#if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256)
+ rb->lcd_set_mode(LCD_MODE_PAL256);
+#endif
+
gnuboy_main(parameter);
#ifdef HAVE_WHEEL_POSITION
rb->wheel_send_events(true);
#endif
+#if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256)
+ rb->lcd_set_mode(LCD_MODE_RGB565);
+#endif
+
if(shut&&!cleanshut)
{
rb->splash(HZ/2, errormsg);
@@ -398,6 +406,7 @@ enum plugin_status plugin_start(const void* parameter)
}
if(!rb->audio_status())
pcm_close();
+
rb->splash(HZ/2, "Closing Rockboy");
savesettings();