summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2009-04-05 12:13:58 +0000
committerJens Arnold <amiconn@rockbox.org>2009-04-05 12:13:58 +0000
commitbf6e0cd9d1b9b45d1ae0c2e48ac666aecc2fcf4a (patch)
tree4230d7fc9b60cc97b3061573b4782604a9377df3
parenta61e63cb41c9994a8f16635344ca22ed4b4be736 (diff)
downloadrockbox-bf6e0cd9d1b9b45d1ae0c2e48ac666aecc2fcf4a.tar.gz
rockbox-bf6e0cd9d1b9b45d1ae0c2e48ac666aecc2fcf4a.tar.bz2
rockbox-bf6e0cd9d1b9b45d1ae0c2e48ac666aecc2fcf4a.zip
ZXBox: Clean up display init. Saves ~1KB on colour targets, and 4KB (coldfire)... >6KB (SH1) for greyscale targets, due to no longer using floating point math. * Name the 2bpp display routines correctly.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20621 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/zxbox/SOURCES7
-rw-r--r--apps/plugins/zxbox/zxvid_16bpp.c57
-rw-r--r--apps/plugins/zxbox/zxvid_2bpp.c (renamed from apps/plugins/zxbox/zxvid_4bpp.c)37
-rw-r--r--apps/plugins/zxbox/zxvid_grey.c40
4 files changed, 59 insertions, 82 deletions
diff --git a/apps/plugins/zxbox/SOURCES b/apps/plugins/zxbox/SOURCES
index ae0307135f..489a3c0613 100644
--- a/apps/plugins/zxbox/SOURCES
+++ b/apps/plugins/zxbox/SOURCES
@@ -27,6 +27,11 @@ z80_step.c
z80optab.c
zxbox.c
zxbox_keyb.c
+#ifdef HAVE_LCD_COLOR
zxvid_16bpp.c
-zxvid_4bpp.c
+#else
+#if LCD_DEPTH == 2
+zxvid_2bpp.c
+#endif
zxvid_grey.c
+#endif
diff --git a/apps/plugins/zxbox/zxvid_16bpp.c b/apps/plugins/zxbox/zxvid_16bpp.c
index 336e1c2447..4a05c69f97 100644
--- a/apps/plugins/zxbox/zxvid_16bpp.c
+++ b/apps/plugins/zxbox/zxvid_16bpp.c
@@ -1,48 +1,46 @@
#include "zxvid_com.h"
-#if LCD_DEPTH > 4
/* screen routines for color targets */
-/*
-use for slightly different colors
-#define N0 0x04
-#define N1 0x34
-
-#define B0 0x08
-#define B1 0x3F
-*/
-
#define N0 0x00
#define N1 0xC0
-
#define B0 0x00
#define B1 0xFF
-struct rgb norm_colors[COLORNUM]={
- {0,0,0},{N0,N0,N1},{N1,N0,N0},{N1,N0,N1},
- {N0,N1,N0},{N0,N1,N1},{N1,N1,N0},{N1,N1,N1},
-
- {0,0,0},{B0,B0,B1},{B1,B0,B0},{B1,B0,B1},
- {B0,B1,B0},{B0,B1,B1},{B1,B1,B0},{B1,B1,B1}
+#define IN0 (0xFF-N0)
+#define IN1 (0xFF-N1)
+#define IB0 (0xFF-B0)
+#define IB1 (0xFF-B1)
+
+static const fb_data _16bpp_colors[32] = {
+ /* normal */
+ LCD_RGBPACK(N0, N0, N0), LCD_RGBPACK(N0, N0, N1),
+ LCD_RGBPACK(N1, N0, N0), LCD_RGBPACK(N1, N0, N1),
+ LCD_RGBPACK(N0, N1, N0), LCD_RGBPACK(N0, N1, N1),
+ LCD_RGBPACK(N1, N1, N0), LCD_RGBPACK(N1, N1, N1),
+ LCD_RGBPACK(B0, B0, B0), LCD_RGBPACK(B0, B0, B1),
+ LCD_RGBPACK(B1, B0, B0), LCD_RGBPACK(B1, B0, B1),
+ LCD_RGBPACK(B0, B1, B0), LCD_RGBPACK(B0, B1, B1),
+ LCD_RGBPACK(B1, B1, B0), LCD_RGBPACK(B1, B1, B1),
+ /* inverted */
+ LCD_RGBPACK(IN0, IN0, IN0), LCD_RGBPACK(IN0, IN0, IN1),
+ LCD_RGBPACK(IN1, IN0, IN0), LCD_RGBPACK(IN1, IN0, IN1),
+ LCD_RGBPACK(IN0, IN1, IN0), LCD_RGBPACK(IN0, IN1, IN1),
+ LCD_RGBPACK(IN1, IN1, IN0), LCD_RGBPACK(IN1, IN1, IN1),
+ LCD_RGBPACK(IB0, IB0, IB0), LCD_RGBPACK(IB0, IB0, IB1),
+ LCD_RGBPACK(IB1, IB0, IB0), LCD_RGBPACK(IB1, IB0, IB1),
+ LCD_RGBPACK(IB0, IB1, IB0), LCD_RGBPACK(IB0, IB1, IB1),
+ LCD_RGBPACK(IB1, IB1, IB0), LCD_RGBPACK(IB1, IB1, IB1),
};
-
-/* since emulator uses array of bytes for screen representation
- * short 16b colors won't fit there */
-short _16bpp_colors[16] IBSS_ATTR;
-
void init_spect_scr(void)
{
int i;
+ int offset = settings.invert_colors ? 16 : 0;
for(i = 0; i < 16; i++)
- sp_colors[i] = i;
- for(i = 0; i < 16; i++)
- _16bpp_colors[i] = LCD_RGBPACK(norm_colors[i].r,norm_colors[i].g,norm_colors[i].b);
- if ( settings.invert_colors ){
- for ( i = 0 ; i < 16 ; i++ )
- _16bpp_colors[i] = 0xFFFFFF - _16bpp_colors[i];
- }
+ sp_colors[i] = i + offset;
+
sp_image = (char *) &image_array;
spscr_init_mask_color();
spscr_init_line_pointers(HEIGHT);
@@ -97,4 +95,3 @@ void update_screen(void)
}
-#endif /* HAVE_LCD_COLOR */
diff --git a/apps/plugins/zxbox/zxvid_4bpp.c b/apps/plugins/zxbox/zxvid_2bpp.c
index 1d9902e125..0a4519e0ac 100644
--- a/apps/plugins/zxbox/zxvid_4bpp.c
+++ b/apps/plugins/zxbox/zxvid_2bpp.c
@@ -1,6 +1,6 @@
#include "zxvid_com.h"
-#if !defined USE_GREY && LCD_DEPTH < 4
+#ifndef USE_GREY
/* screen routines for greyscale targets not using greyscale lib */
#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
@@ -21,32 +21,19 @@ fb_data pixval[4] ICONST_ATTR = {
};
#endif
+static const unsigned char graylevels[16] = {
+ 0, 1, 1, 1, 2, 2, 3, 3,
+ 0, 1, 1, 1, 2, 2, 3, 3
+};
+
void init_spect_scr(void)
{
- sp_colors[0] = 0;/* BLACK ? */
- sp_colors[1] = 1;/* BLUE ? */
- sp_colors[2] = 1;/* RED ? */
- sp_colors[3] = 1;/* MAGENTA ? */
- sp_colors[4] = 2;/* GREEN ? */
- sp_colors[5] = 2;/* CYAN ? */
- sp_colors[6] = 3;/* YELLOW ? */
- sp_colors[7] = 3;/* WHITE ? */
-
- /* same but 'light/bright' colors */
- sp_colors[8] = 0;
- sp_colors[9] = 1;
- sp_colors[10] = 1;
- sp_colors[11] = 1;
- sp_colors[12] = 2;
- sp_colors[13] = 2;
- sp_colors[14] = 3;
- sp_colors[15] = 3;
+ int i;
+ unsigned mask = settings.invert_colors ? 0 : 3;
+
+ for(i = 0; i < 16; i++)
+ sp_colors[i] = graylevels[i] ^ mask;
- if ( !settings.invert_colors ){
- int i;
- for ( i = 0 ; i < 16 ; i++ )
- sp_colors[i] = 3 - sp_colors[i];
- }
sp_image = (char *) &image_array;
spscr_init_mask_color();
spscr_init_line_pointers(HEIGHT);
@@ -127,4 +114,4 @@ void update_screen(void)
rb -> lcd_update();
}
-#endif
+#endif /* !USE_GREY */
diff --git a/apps/plugins/zxbox/zxvid_grey.c b/apps/plugins/zxbox/zxvid_grey.c
index de9cd97874..d713eba4b5 100644
--- a/apps/plugins/zxbox/zxvid_grey.c
+++ b/apps/plugins/zxbox/zxvid_grey.c
@@ -1,40 +1,28 @@
#include "zxvid_com.h"
-#if !defined HAVE_LCD_COLOR && defined USE_GREY
-/*
-use for slightly different colors
-#define N0 0x04
-#define N1 0x34
-#define B0 0x08
-#define B1 0x3F
-*/
+#ifdef USE_GREY
-/* these ones are the same as for color targets ... may be tweak for greyscale? */
#define N0 0x00
-#define N1 0xAA
-
-#define B0 0x55
+#define N1 0xC0
+#define B0 0x00
#define B1 0xFF
-static unsigned char graybuffer[LCD_HEIGHT*LCD_WIDTH] IBSS_ATTR; /* off screen buffer */
-struct rgb norm_colors[COLORNUM]={
- {0,0,0},{N0,N0,N1},{N1,N0,N0},{N1,N0,N1},
- {N0,N1,N0},{N0,N1,N1},{N1,N1,N0},{N1,N1,N1},
+static unsigned char graybuffer[LCD_HEIGHT*LCD_WIDTH] IBSS_ATTR; /* off screen buffer */
- {0x15,0x15,0x15},{B0,B0,B1},{B1,B0,B0},{B1,B0,B1},
- {B0,B1,B0},{B0,B1,B1},{B1,B1,B0},{B1,B1,B1}
+static const unsigned char graylevels[16] = {
+ N0, (6*N0+1*N1)/7, (5*N0+2*N1)/7, (4*N0+3*N1)/7,
+ (3*N0+4*N1)/7, (2*N0+5*N1)/7, (1*N0+6*N1)/7, N1,
+ B0, (6*B0+1*B1)/7, (5*B0+2*B1)/7, (4*B0+3*B1)/7,
+ (3*B0+4*B1)/7, (2*B0+5*B1)/7, (1*B0+6*B1)/7, B1
};
void init_spect_scr(void)
{
int i;
+ unsigned mask = settings.invert_colors ? 0xFF : 0;
+
for(i = 0; i < 16; i++)
- sp_colors[i] = 0.3*norm_colors[i].r + 0.59*norm_colors[i].g + 0.11*norm_colors[i].b;
- if ( settings.invert_colors ){
- int i;
- for ( i = 0 ; i < 16 ; i++ )
- sp_colors[i] = 255 - sp_colors[i];
- }
+ sp_colors[i] = graylevels[i] ^ mask;
sp_image = (char *) &image_array;
spscr_init_mask_color();
@@ -52,7 +40,7 @@ void update_screen(void)
int srcx, srcy=0; /* x / y coordinates in source image */
image = sp_image + ( (Y_OFF)*(WIDTH) ) + X_OFF;
unsigned char* buf_ptr;
- buf_ptr = (unsigned char*) &graybuffer;
+ buf_ptr = graybuffer;
for(y = 0; y < LCD_HEIGHT; y++)
{
srcx = 0; /* reset our x counter before each row... */
@@ -94,4 +82,4 @@ void update_screen(void)
}
-#endif
+#endif /* USE_GREY */