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
This commit is contained in:
Jens Arnold 2009-04-05 12:13:58 +00:00
parent a61e63cb41
commit bf6e0cd9d1
4 changed files with 58 additions and 81 deletions

View file

@ -27,6 +27,11 @@ z80_step.c
z80optab.c z80optab.c
zxbox.c zxbox.c
zxbox_keyb.c zxbox_keyb.c
#ifdef HAVE_LCD_COLOR
zxvid_16bpp.c zxvid_16bpp.c
zxvid_4bpp.c #else
#if LCD_DEPTH == 2
zxvid_2bpp.c
#endif
zxvid_grey.c zxvid_grey.c
#endif

View file

@ -1,48 +1,46 @@
#include "zxvid_com.h" #include "zxvid_com.h"
#if LCD_DEPTH > 4
/* screen routines for color targets */ /* 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 N0 0x00
#define N1 0xC0 #define N1 0xC0
#define B0 0x00 #define B0 0x00
#define B1 0xFF #define B1 0xFF
struct rgb norm_colors[COLORNUM]={ #define IN0 (0xFF-N0)
{0,0,0},{N0,N0,N1},{N1,N0,N0},{N1,N0,N1}, #define IN1 (0xFF-N1)
{N0,N1,N0},{N0,N1,N1},{N1,N1,N0},{N1,N1,N1}, #define IB0 (0xFF-B0)
#define IB1 (0xFF-B1)
{0,0,0},{B0,B0,B1},{B1,B0,B0},{B1,B0,B1}, static const fb_data _16bpp_colors[32] = {
{B0,B1,B0},{B0,B1,B1},{B1,B1,B0},{B1,B1,B1} /* 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) void init_spect_scr(void)
{ {
int i; int i;
int offset = settings.invert_colors ? 16 : 0;
for(i = 0; i < 16; i++) for(i = 0; i < 16; i++)
sp_colors[i] = i; sp_colors[i] = i + offset;
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_image = (char *) &image_array; sp_image = (char *) &image_array;
spscr_init_mask_color(); spscr_init_mask_color();
spscr_init_line_pointers(HEIGHT); spscr_init_line_pointers(HEIGHT);
@ -97,4 +95,3 @@ void update_screen(void)
} }
#endif /* HAVE_LCD_COLOR */

View file

@ -1,6 +1,6 @@
#include "zxvid_com.h" #include "zxvid_com.h"
#if !defined USE_GREY && LCD_DEPTH < 4 #ifndef USE_GREY
/* screen routines for greyscale targets not using greyscale lib */ /* screen routines for greyscale targets not using greyscale lib */
#if LCD_PIXELFORMAT == HORIZONTAL_PACKING #if LCD_PIXELFORMAT == HORIZONTAL_PACKING
@ -21,32 +21,19 @@ fb_data pixval[4] ICONST_ATTR = {
}; };
#endif #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) 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;
if ( !settings.invert_colors ){
int i; int i;
for ( i = 0 ; i < 16 ; i++ ) unsigned mask = settings.invert_colors ? 0 : 3;
sp_colors[i] = 3 - sp_colors[i];
} for(i = 0; i < 16; i++)
sp_colors[i] = graylevels[i] ^ mask;
sp_image = (char *) &image_array; sp_image = (char *) &image_array;
spscr_init_mask_color(); spscr_init_mask_color();
spscr_init_line_pointers(HEIGHT); spscr_init_line_pointers(HEIGHT);
@ -127,4 +114,4 @@ void update_screen(void)
rb -> lcd_update(); rb -> lcd_update();
} }
#endif #endif /* !USE_GREY */

View file

@ -1,40 +1,28 @@
#include "zxvid_com.h" #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 #ifdef USE_GREY
#define B1 0x3F
*/
/* these ones are the same as for color targets ... may be tweak for greyscale? */
#define N0 0x00 #define N0 0x00
#define N1 0xAA #define N1 0xC0
#define B0 0x00
#define B0 0x55
#define B1 0xFF #define B1 0xFF
static unsigned char graybuffer[LCD_HEIGHT*LCD_WIDTH] IBSS_ATTR; /* off screen buffer */ static unsigned char graybuffer[LCD_HEIGHT*LCD_WIDTH] IBSS_ATTR; /* off screen buffer */
struct rgb norm_colors[COLORNUM]={ static const unsigned char graylevels[16] = {
{0,0,0},{N0,N0,N1},{N1,N0,N0},{N1,N0,N1}, N0, (6*N0+1*N1)/7, (5*N0+2*N1)/7, (4*N0+3*N1)/7,
{N0,N1,N0},{N0,N1,N1},{N1,N1,N0},{N1,N1,N1}, (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,
{0x15,0x15,0x15},{B0,B0,B1},{B1,B0,B0},{B1,B0,B1}, (3*B0+4*B1)/7, (2*B0+5*B1)/7, (1*B0+6*B1)/7, B1
{B0,B1,B0},{B0,B1,B1},{B1,B1,B0},{B1,B1,B1}
}; };
void init_spect_scr(void) void init_spect_scr(void)
{ {
int i; int i;
unsigned mask = settings.invert_colors ? 0xFF : 0;
for(i = 0; i < 16; i++) 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; sp_colors[i] = graylevels[i] ^ mask;
if ( settings.invert_colors ){
int i;
for ( i = 0 ; i < 16 ; i++ )
sp_colors[i] = 255 - sp_colors[i];
}
sp_image = (char *) &image_array; sp_image = (char *) &image_array;
spscr_init_mask_color(); spscr_init_mask_color();
@ -52,7 +40,7 @@ void update_screen(void)
int srcx, srcy=0; /* x / y coordinates in source image */ int srcx, srcy=0; /* x / y coordinates in source image */
image = sp_image + ( (Y_OFF)*(WIDTH) ) + X_OFF; image = sp_image + ( (Y_OFF)*(WIDTH) ) + X_OFF;
unsigned char* buf_ptr; unsigned char* buf_ptr;
buf_ptr = (unsigned char*) &graybuffer; buf_ptr = graybuffer;
for(y = 0; y < LCD_HEIGHT; y++) for(y = 0; y < LCD_HEIGHT; y++)
{ {
srcx = 0; /* reset our x counter before each row... */ srcx = 0; /* reset our x counter before each row... */
@ -94,4 +82,4 @@ void update_screen(void)
} }
#endif #endif /* USE_GREY */