forked from len0rd/rockbox
Grayscale library ported to the grayscale iPods, first version. Added C reference versions of gray_update_rect() for both horizontal and vertical pixel packing. gray_update_rect() and gray_ub_gray_bitmap_part() not yet assembler optimised. Grayscale screendump doesn't work yet. * Fixed button assignments for iPod in grayscale.c
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10468 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
5375e26e51
commit
c214e7bb0c
20 changed files with 1360 additions and 232 deletions
|
@ -27,12 +27,11 @@ dice.c
|
||||||
#ifdef HAVE_LCD_BITMAP /* Not for the Player */
|
#ifdef HAVE_LCD_BITMAP /* Not for the Player */
|
||||||
text_editor.c
|
text_editor.c
|
||||||
|
|
||||||
#if CONFIG_LCD != LCD_IPOD2BPP /* Plugins needing the grayscale lib */
|
/* Plugins needing the grayscale lib on low-depth LCDs */
|
||||||
fire.c
|
fire.c
|
||||||
jpeg.c
|
jpeg.c
|
||||||
mandelbrot.c
|
mandelbrot.c
|
||||||
plasma.c
|
plasma.c
|
||||||
#endif
|
|
||||||
|
|
||||||
bounce.c
|
bounce.c
|
||||||
bubbles.c
|
bubbles.c
|
||||||
|
|
|
@ -28,7 +28,7 @@ pacbox
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* For all the color targets apart from the Gigabeat */
|
/* For all the color targets apart from the Gigabeat */
|
||||||
#if defined(HAVE_LCD_COLOR) && !defined(TOSHIBA_GIGABEAT_F) || defined(IRIVER_H100_SERIES)
|
#if (defined(HAVE_LCD_COLOR) && !defined(TOSHIBA_GIGABEAT_F)) || (LCD_DEPTH == 2)
|
||||||
doom
|
doom
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -547,7 +547,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
||||||
xlcd_init(rb);
|
xlcd_init(rb);
|
||||||
#elif defined(USE_GSLIB)
|
#elif defined(USE_GSLIB)
|
||||||
gbuf = (unsigned char *)rb->plugin_get_buffer(&gbuf_size);
|
gbuf = (unsigned char *)rb->plugin_get_buffer(&gbuf_size);
|
||||||
if (gray_init(rb, gbuf, gbuf_size, true, LCD_WIDTH, LCD_HEIGHT/8, 3, 0, NULL)
|
if (gray_init(rb, gbuf, gbuf_size, true, LCD_WIDTH, LCD_HEIGHT, 3, 0, NULL)
|
||||||
!= 3)
|
!= 3)
|
||||||
{
|
{
|
||||||
rb->splash(HZ, true, "Couldn't get grayscale buffer");
|
rb->splash(HZ, true, "Couldn't get grayscale buffer");
|
||||||
|
|
|
@ -16,7 +16,10 @@
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* $Log$
|
* $Log$
|
||||||
* Revision 1.19 2006/08/03 20:17:22 bagder
|
* Revision 1.20 2006/08/07 01:46:41 amiconn
|
||||||
|
* Grayscale library ported to the grayscale iPods, first version. Added C reference versions of gray_update_rect() for both horizontal and vertical pixel packing. gray_update_rect() and gray_ub_gray_bitmap_part() not yet assembler optimised. Grayscale screendump doesn't work yet. * Fixed button assignments for iPod in grayscale.c
|
||||||
|
*
|
||||||
|
* Revision 1.19 2006-08-03 20:17:22 bagder
|
||||||
* Barry Wardell's keymappings for H10
|
* Barry Wardell's keymappings for H10
|
||||||
*
|
*
|
||||||
* Revision 1.18 2006-08-02 00:21:59 amiconn
|
* Revision 1.18 2006-08-02 00:21:59 amiconn
|
||||||
|
@ -500,7 +503,7 @@ void I_InitGraphics(void)
|
||||||
|
|
||||||
#ifndef HAVE_LCD_COLOR
|
#ifndef HAVE_LCD_COLOR
|
||||||
gbuf=malloc(GRAYBUFSIZE);
|
gbuf=malloc(GRAYBUFSIZE);
|
||||||
gray_init(rb, gbuf, GRAYBUFSIZE, false, LCD_WIDTH, LCD_HEIGHT/8, 32,
|
gray_init(rb, gbuf, GRAYBUFSIZE, false, LCD_WIDTH, LCD_HEIGHT, 32,
|
||||||
3<<7 /* 1.5 */, NULL);
|
3<<7 /* 1.5 */, NULL);
|
||||||
/* switch on grayscale overlay */
|
/* switch on grayscale overlay */
|
||||||
gray_show(true);
|
gray_show(true);
|
||||||
|
|
|
@ -338,7 +338,7 @@ int main(void)
|
||||||
#ifdef HAVE_LCD_COLOR
|
#ifdef HAVE_LCD_COLOR
|
||||||
shades = 256;
|
shades = 256;
|
||||||
#else
|
#else
|
||||||
shades = gray_init(rb, gbuf, gbuf_size, false, LCD_WIDTH, LCD_HEIGHT/8,
|
shades = gray_init(rb, gbuf, gbuf_size, false, LCD_WIDTH, LCD_HEIGHT,
|
||||||
32, 2<<8, NULL) + 1;
|
32, 2<<8, NULL) + 1;
|
||||||
if(shades <= 1)
|
if(shades <= 1)
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
#include "plugin.h"
|
#include "plugin.h"
|
||||||
|
|
||||||
#if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH < 4) && (CONFIG_LCD != LCD_IPOD2BPP)
|
#if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH < 4)
|
||||||
#include "gray.h"
|
#include "gray.h"
|
||||||
|
|
||||||
PLUGIN_HEADER
|
PLUGIN_HEADER
|
||||||
|
@ -54,12 +54,12 @@ PLUGIN_HEADER
|
||||||
#define GRAYSCALE_RC_OFF BUTTON_RC_STOP
|
#define GRAYSCALE_RC_OFF BUTTON_RC_STOP
|
||||||
|
|
||||||
#elif (CONFIG_KEYPAD == IPOD_3G_PAD) || (CONFIG_KEYPAD == IPOD_4G_PAD)
|
#elif (CONFIG_KEYPAD == IPOD_3G_PAD) || (CONFIG_KEYPAD == IPOD_4G_PAD)
|
||||||
#define GRAYSCALE_SHIFT (BUTTON_SELECT | BUTTON_REL)
|
#define GRAYSCALE_SHIFT BUTTON_SELECT
|
||||||
#define GRAYSCALE_UP BUTTON_MENU
|
#define GRAYSCALE_UP BUTTON_SCROLL_BACK
|
||||||
#define GRAYSCALE_DOWN BUTTON_PLAY
|
#define GRAYSCALE_DOWN BUTTON_SCROLL_FWD
|
||||||
#define GRAYSCALE_LEFT BUTTON_LEFT
|
#define GRAYSCALE_LEFT BUTTON_LEFT
|
||||||
#define GRAYSCALE_RIGHT BUTTON_RIGHT
|
#define GRAYSCALE_RIGHT BUTTON_RIGHT
|
||||||
#define GRAYSCALE_OFF (BUTTON_SELECT | BUTTON_MENU)
|
#define GRAYSCALE_OFF BUTTON_MENU
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define GFX_HEIGHT (LCD_HEIGHT-8)
|
#define GFX_HEIGHT (LCD_HEIGHT-8)
|
||||||
|
@ -182,11 +182,11 @@ int main(void)
|
||||||
32 bitplanes for 33 shades of grey.
|
32 bitplanes for 33 shades of grey.
|
||||||
H1x0: 160 pixels wide, 30 rows (120 pixels) high, (try to) reserve
|
H1x0: 160 pixels wide, 30 rows (120 pixels) high, (try to) reserve
|
||||||
32 bitplanes for 33 shades of grey. */
|
32 bitplanes for 33 shades of grey. */
|
||||||
shades = gray_init(rb, gbuf, gbuf_size, true, LCD_WIDTH, GFX_HEIGHT/8,
|
shades = gray_init(rb, gbuf, gbuf_size, true, LCD_WIDTH, GFX_HEIGHT,
|
||||||
32, 0, NULL) + 1;
|
32, 0, NULL) + 1;
|
||||||
|
|
||||||
/* place greyscale overlay 1 row down */
|
/* place greyscale overlay 1 row down */
|
||||||
gray_set_position(0, 1);
|
gray_set_position(0, 8);
|
||||||
|
|
||||||
rb->snprintf(pbuf, sizeof(pbuf), "Shades: %d", shades);
|
rb->snprintf(pbuf, sizeof(pbuf), "Shades: %d", shades);
|
||||||
rb->lcd_puts(0, 0, pbuf);
|
rb->lcd_puts(0, 0, pbuf);
|
||||||
|
|
|
@ -2783,7 +2783,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
||||||
|
|
||||||
#ifdef USEGSLIB
|
#ifdef USEGSLIB
|
||||||
/* initialize the grayscale buffer: 32 bitplanes for 33 shades of gray. */
|
/* initialize the grayscale buffer: 32 bitplanes for 33 shades of gray. */
|
||||||
grayscales = gray_init(rb, buf, buf_size, false, LCD_WIDTH, LCD_HEIGHT/8,
|
grayscales = gray_init(rb, buf, buf_size, false, LCD_WIDTH, LCD_HEIGHT,
|
||||||
32, 2<<8, &graysize) + 1;
|
32, 2<<8, &graysize) + 1;
|
||||||
buf += graysize;
|
buf += graysize;
|
||||||
buf_size -= graysize;
|
buf_size -= graysize;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
configfile.c
|
configfile.c
|
||||||
playback_control.c
|
playback_control.c
|
||||||
rgb_hsv.c
|
rgb_hsv.c
|
||||||
#if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH < 4) && (CONFIG_LCD != LCD_IPOD2BPP)
|
#if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH < 4)
|
||||||
gray_core.c
|
gray_core.c
|
||||||
gray_draw.c
|
gray_draw.c
|
||||||
gray_parm.c
|
gray_parm.c
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
#include "plugin.h"
|
#include "plugin.h"
|
||||||
|
|
||||||
#ifdef HAVE_LCD_BITMAP /* and also not for the Player */
|
#ifdef HAVE_LCD_BITMAP /* not for the Player */
|
||||||
|
|
||||||
#define GRAY_BRIGHTNESS(y) (y)
|
#define GRAY_BRIGHTNESS(y) (y)
|
||||||
|
|
||||||
|
@ -109,9 +109,6 @@ void gray_ub_scroll_down(int count);
|
||||||
|
|
||||||
/*** Internal stuff ***/
|
/*** Internal stuff ***/
|
||||||
|
|
||||||
#define _PBLOCK_EXP 3
|
|
||||||
#define _PBLOCK (1 << _PBLOCK_EXP)
|
|
||||||
|
|
||||||
/* flag definitions */
|
/* flag definitions */
|
||||||
#define _GRAY_RUNNING 0x0001 /* greyscale overlay is running */
|
#define _GRAY_RUNNING 0x0001 /* greyscale overlay is running */
|
||||||
#define _GRAY_DEFERRED_UPDATE 0x0002 /* lcd_update() requested */
|
#define _GRAY_DEFERRED_UPDATE 0x0002 /* lcd_update() requested */
|
||||||
|
@ -124,10 +121,16 @@ void gray_ub_scroll_down(int count);
|
||||||
struct _gray_info
|
struct _gray_info
|
||||||
{
|
{
|
||||||
int x;
|
int x;
|
||||||
int by; /* 8-pixel units */
|
int y;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
|
#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
|
||||||
|
int bx; /* 8-pixel units */
|
||||||
|
int bwidth; /* 8-pixel units */
|
||||||
|
#else /* vertical packing */
|
||||||
|
int by; /* 8-pixel units */
|
||||||
int bheight; /* 8-pixel units */
|
int bheight; /* 8-pixel units */
|
||||||
|
#endif
|
||||||
int depth; /* number_of_bitplanes = (number_of_grayscales - 1) */
|
int depth; /* number_of_bitplanes = (number_of_grayscales - 1) */
|
||||||
unsigned long flags; /* various flags, see #defines */
|
unsigned long flags; /* various flags, see #defines */
|
||||||
#ifndef SIMULATOR
|
#ifndef SIMULATOR
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
* Core & miscellaneous functions
|
* Core & miscellaneous functions
|
||||||
*
|
*
|
||||||
* This is a generic framework to display up to 33 shades of grey
|
* This is a generic framework to display up to 33 shades of grey
|
||||||
* on low-depth bitmap LCDs (Archos b&w, Iriver 4-grey) within plugins.
|
* on low-depth bitmap LCDs (Archos b&w, Iriver 4-grey, iPod 4-grey)
|
||||||
|
* within plugins.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2004-2006 Jens Arnold
|
* Copyright (C) 2004-2006 Jens Arnold
|
||||||
*
|
*
|
||||||
|
@ -28,9 +29,14 @@
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
#include "gray.h"
|
#include "gray.h"
|
||||||
|
|
||||||
|
#ifdef CPU_PP
|
||||||
|
#define NEED_BOOST
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Global variables */
|
/* Global variables */
|
||||||
struct plugin_api *_gray_rb = NULL; /* global api struct pointer */
|
struct plugin_api *_gray_rb = NULL; /* global api struct pointer */
|
||||||
struct _gray_info _gray_info; /* global info structure */
|
struct _gray_info _gray_info; /* global info structure */
|
||||||
|
|
||||||
#ifndef SIMULATOR
|
#ifndef SIMULATOR
|
||||||
short _gray_random_buffer; /* buffer for random number generator */
|
short _gray_random_buffer; /* buffer for random number generator */
|
||||||
|
|
||||||
|
@ -106,6 +112,43 @@ static const unsigned char lcdlinear[256] = {
|
||||||
227, 228, 230, 232, 233, 235, 237, 239,
|
227, 228, 230, 232, 233, 235, 237, 239,
|
||||||
241, 243, 245, 247, 249, 251, 253, 255
|
241, 243, 245, 247, 249, 251, 253, 255
|
||||||
};
|
};
|
||||||
|
#elif (CONFIG_LCD == LCD_IPOD2BPP) || (CONFIG_LCD == LCD_IPODMINI)
|
||||||
|
/* measured and interpolated curve for mini LCD */
|
||||||
|
/* TODO: verify this curve on the fullsize greyscale LCD */
|
||||||
|
static const unsigned char lcdlinear[256] = {
|
||||||
|
0, 3, 6, 8, 11, 14, 17, 19,
|
||||||
|
22, 24, 27, 29, 32, 34, 36, 38,
|
||||||
|
40, 42, 44, 45, 47, 48, 50, 51,
|
||||||
|
52, 54, 55, 56, 57, 58, 58, 59,
|
||||||
|
60, 61, 62, 62, 63, 64, 64, 65,
|
||||||
|
66, 66, 67, 67, 68, 68, 69, 69,
|
||||||
|
70, 70, 70, 71, 71, 71, 72, 72,
|
||||||
|
73, 73, 73, 74, 74, 74, 74, 75,
|
||||||
|
75, 75, 76, 76, 76, 77, 77, 77,
|
||||||
|
78, 78, 78, 79, 79, 79, 80, 80,
|
||||||
|
80, 80, 81, 81, 81, 82, 82, 82,
|
||||||
|
83, 83, 83, 84, 84, 84, 85, 85,
|
||||||
|
85, 85, 86, 86, 86, 87, 87, 87,
|
||||||
|
87, 88, 88, 88, 89, 89, 89, 89,
|
||||||
|
90, 90, 90, 91, 91, 91, 92, 92,
|
||||||
|
92, 93, 93, 93, 94, 94, 94, 95,
|
||||||
|
95, 96, 96, 96, 97, 97, 98, 98,
|
||||||
|
99, 99, 99, 100, 100, 101, 101, 102,
|
||||||
|
102, 103, 103, 104, 104, 105, 105, 106,
|
||||||
|
106, 107, 107, 108, 108, 109, 109, 110,
|
||||||
|
110, 111, 111, 112, 113, 113, 114, 114,
|
||||||
|
115, 115, 116, 117, 117, 118, 118, 119,
|
||||||
|
120, 120, 121, 122, 122, 123, 124, 124,
|
||||||
|
125, 126, 126, 127, 128, 128, 129, 130,
|
||||||
|
131, 131, 132, 133, 134, 134, 135, 136,
|
||||||
|
137, 138, 139, 140, 141, 142, 143, 144,
|
||||||
|
145, 146, 147, 148, 149, 150, 152, 153,
|
||||||
|
154, 156, 157, 159, 160, 162, 163, 165,
|
||||||
|
167, 168, 170, 172, 174, 176, 178, 180,
|
||||||
|
182, 184, 187, 189, 192, 194, 197, 200,
|
||||||
|
203, 206, 209, 212, 215, 219, 222, 226,
|
||||||
|
229, 233, 236, 240, 244, 248, 251, 255
|
||||||
|
};
|
||||||
#endif
|
#endif
|
||||||
#else /* SIMULATOR */
|
#else /* SIMULATOR */
|
||||||
/* undo a (generic) PC display gamma of 2.0 to simulate target behaviour */
|
/* undo a (generic) PC display gamma of 2.0 to simulate target behaviour */
|
||||||
|
@ -147,20 +190,22 @@ static const unsigned char lcdlinear[256] = {
|
||||||
|
|
||||||
/* Prototypes */
|
/* Prototypes */
|
||||||
static inline void _deferred_update(void) __attribute__ ((always_inline));
|
static inline void _deferred_update(void) __attribute__ ((always_inline));
|
||||||
|
static int exp_s16p16(int x);
|
||||||
|
static int log_s16p16(int x);
|
||||||
|
static void gray_screendump_hook(int fd);
|
||||||
#ifdef SIMULATOR
|
#ifdef SIMULATOR
|
||||||
static unsigned long _gray_get_pixel(int x, int y);
|
static unsigned long _gray_get_pixel(int x, int y);
|
||||||
#else
|
#else
|
||||||
static void _timer_isr(void);
|
static void _timer_isr(void);
|
||||||
#endif
|
#endif
|
||||||
static void gray_screendump_hook(int fd);
|
|
||||||
|
|
||||||
/* Update LCD areas not covered by the greyscale overlay */
|
/* Update LCD areas not covered by the greyscale overlay */
|
||||||
static inline void _deferred_update(void)
|
static inline void _deferred_update(void)
|
||||||
{
|
{
|
||||||
int x1 = MAX(_gray_info.x, 0);
|
int x1 = MAX(_gray_info.x, 0);
|
||||||
int x2 = MIN(_gray_info.x + _gray_info.width, LCD_WIDTH);
|
int x2 = MIN(_gray_info.x + _gray_info.width, LCD_WIDTH);
|
||||||
int y1 = MAX(_gray_info.by << _PBLOCK_EXP, 0);
|
int y1 = MAX(_gray_info.y, 0);
|
||||||
int y2 = MIN((_gray_info.by << _PBLOCK_EXP) + _gray_info.height, LCD_HEIGHT);
|
int y2 = MIN(_gray_info.y + _gray_info.height, LCD_HEIGHT);
|
||||||
|
|
||||||
if (y1 > 0) /* refresh part above overlay, full width */
|
if (y1 > 0) /* refresh part above overlay, full width */
|
||||||
_gray_rb->lcd_update_rect(0, 0, LCD_WIDTH, y1);
|
_gray_rb->lcd_update_rect(0, 0, LCD_WIDTH, y1);
|
||||||
|
@ -179,9 +224,15 @@ static inline void _deferred_update(void)
|
||||||
/* Timer interrupt handler: display next bitplane */
|
/* Timer interrupt handler: display next bitplane */
|
||||||
static void _timer_isr(void)
|
static void _timer_isr(void)
|
||||||
{
|
{
|
||||||
|
#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
|
||||||
|
_gray_rb->lcd_blit(_gray_info.plane_data + MULU16(_gray_info.plane_size,
|
||||||
|
_gray_info.cur_plane), _gray_info.bx, _gray_info.y,
|
||||||
|
_gray_info.bwidth, _gray_info.height, _gray_info.bwidth);
|
||||||
|
#else
|
||||||
_gray_rb->lcd_blit(_gray_info.plane_data + MULU16(_gray_info.plane_size,
|
_gray_rb->lcd_blit(_gray_info.plane_data + MULU16(_gray_info.plane_size,
|
||||||
_gray_info.cur_plane), _gray_info.x, _gray_info.by,
|
_gray_info.cur_plane), _gray_info.x, _gray_info.by,
|
||||||
_gray_info.width, _gray_info.bheight, _gray_info.width);
|
_gray_info.width, _gray_info.bheight, _gray_info.width);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (++_gray_info.cur_plane >= _gray_info.depth)
|
if (++_gray_info.cur_plane >= _gray_info.depth)
|
||||||
_gray_info.cur_plane = 0;
|
_gray_info.cur_plane = 0;
|
||||||
|
@ -200,7 +251,7 @@ static int exp_s16p16(int x)
|
||||||
int t;
|
int t;
|
||||||
int y = 0x00010000;
|
int y = 0x00010000;
|
||||||
|
|
||||||
if (x < 0) x += 0xb1721, y >>= 16;
|
if (x < 0) x += 0xb1721, y >>= 16;
|
||||||
t = x - 0x58b91; if (t >= 0) x = t, y <<= 8;
|
t = x - 0x58b91; if (t >= 0) x = t, y <<= 8;
|
||||||
t = x - 0x2c5c8; if (t >= 0) x = t, y <<= 4;
|
t = x - 0x2c5c8; if (t >= 0) x = t, y <<= 4;
|
||||||
t = x - 0x162e4; if (t >= 0) x = t, y <<= 2;
|
t = x - 0x162e4; if (t >= 0) x = t, y <<= 2;
|
||||||
|
@ -218,7 +269,7 @@ static int exp_s16p16(int x)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* fixed point log() */
|
/* fixed point log() */
|
||||||
int log_s16p16(int x)
|
static int log_s16p16(int x)
|
||||||
{
|
{
|
||||||
int t;
|
int t;
|
||||||
int y = 0xa65af;
|
int y = 0xa65af;
|
||||||
|
@ -252,7 +303,9 @@ int log_s16p16(int x)
|
||||||
memory. Unbuffered operation provides only a subset of
|
memory. Unbuffered operation provides only a subset of
|
||||||
drawing functions. (only gray_bitmap drawing and scrolling)
|
drawing functions. (only gray_bitmap drawing and scrolling)
|
||||||
width = width in pixels (1..LCD_WIDTH)
|
width = width in pixels (1..LCD_WIDTH)
|
||||||
bheight = height in LCD pixel-block units (8 pixels) (1..LCD_HEIGHT/8)
|
height = height in pixels (1..LCD_HEIGHT)
|
||||||
|
Note that depending on the target LCD, either height or
|
||||||
|
width are rounded up to a multiple of 8.
|
||||||
depth = number of bitplanes to use (1..32).
|
depth = number of bitplanes to use (1..32).
|
||||||
gamma = gamma value as s8p8 fixed point. gamma <= 0 means no
|
gamma = gamma value as s8p8 fixed point. gamma <= 0 means no
|
||||||
correction at all, i.e. no LCD linearisation as well.
|
correction at all, i.e. no LCD linearisation as well.
|
||||||
|
@ -277,20 +330,21 @@ int log_s16p16(int x)
|
||||||
used. The total memory needed can be calculated as follows:
|
used. The total memory needed can be calculated as follows:
|
||||||
total_mem =
|
total_mem =
|
||||||
shades * sizeof(long) (bitpatterns)
|
shades * sizeof(long) (bitpatterns)
|
||||||
+ (width * bheight) * depth (bitplane data)
|
+ [horizontal_packing] ? (bitplane data)
|
||||||
|
((width + 7) / 8) * height * depth : width * ((height + 7) / 8) * depth
|
||||||
+ buffered ? (chunky front- & backbuffer)
|
+ buffered ? (chunky front- & backbuffer)
|
||||||
(width * bheight * 8 * 2) : 0
|
(width * height * 2) : 0
|
||||||
+ 0..3 (longword alignment)
|
+ 0..3 (longword alignment)
|
||||||
|
|
||||||
The function tries to be as authentic as possible regarding memory usage on
|
The function tries to be as authentic as possible regarding memory usage on
|
||||||
the simulator, even if it doesn't use all of the allocated memory. There's
|
the simulator, even if it doesn't use all of the allocated memory. There's
|
||||||
one situation where it will consume more memory on the sim than on the
|
one situation where it will consume more memory on the sim than on the
|
||||||
target: if you're allocating a low depth (< 8) without buffering. */
|
target: if you're allocating a low depth (< 8) without buffering. */
|
||||||
int gray_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size,
|
int gray_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size,
|
||||||
bool buffered, int width, int bheight, int depth, int gamma,
|
bool buffered, int width, int height, int depth, int gamma,
|
||||||
long *buf_taken)
|
long *buf_taken)
|
||||||
{
|
{
|
||||||
int possible_depth, i;
|
int possible_depth, bdim, i;
|
||||||
long plane_size, buftaken;
|
long plane_size, buftaken;
|
||||||
unsigned data;
|
unsigned data;
|
||||||
#ifndef SIMULATOR
|
#ifndef SIMULATOR
|
||||||
|
@ -300,10 +354,18 @@ int gray_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size,
|
||||||
_gray_rb = newrb;
|
_gray_rb = newrb;
|
||||||
|
|
||||||
if ((unsigned) width > LCD_WIDTH
|
if ((unsigned) width > LCD_WIDTH
|
||||||
|| (unsigned) bheight > (LCD_HEIGHT/_PBLOCK)
|
|| (unsigned) height > LCD_HEIGHT
|
||||||
|| depth < 1)
|
|| depth < 1)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
|
||||||
|
bdim = (width + 7) >> 3;
|
||||||
|
width = bdim << 3;
|
||||||
|
#else
|
||||||
|
bdim = (height + 7) >> 3;
|
||||||
|
height = bdim << 3;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* the buffer has to be long aligned */
|
/* the buffer has to be long aligned */
|
||||||
buftaken = (-(long)gbuf) & 3;
|
buftaken = (-(long)gbuf) & 3;
|
||||||
gbuf += buftaken;
|
gbuf += buftaken;
|
||||||
|
@ -311,7 +373,7 @@ int gray_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size,
|
||||||
/* chunky front- & backbuffer */
|
/* chunky front- & backbuffer */
|
||||||
if (buffered)
|
if (buffered)
|
||||||
{
|
{
|
||||||
plane_size = MULU16(width, bheight << _PBLOCK_EXP);
|
plane_size = MULU16(width, height);
|
||||||
buftaken += 2 * plane_size;
|
buftaken += 2 * plane_size;
|
||||||
if (buftaken > gbuf_size)
|
if (buftaken > gbuf_size)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -324,7 +386,11 @@ int gray_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size,
|
||||||
gbuf += plane_size;
|
gbuf += plane_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
plane_size = MULU16(width, bheight);
|
#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
|
||||||
|
plane_size = MULU16(bdim, height);
|
||||||
|
#else
|
||||||
|
plane_size = MULU16(width, bdim);
|
||||||
|
#endif
|
||||||
possible_depth = (gbuf_size - buftaken - sizeof(long))
|
possible_depth = (gbuf_size - buftaken - sizeof(long))
|
||||||
/ (plane_size + sizeof(long));
|
/ (plane_size + sizeof(long));
|
||||||
|
|
||||||
|
@ -339,7 +405,7 @@ int gray_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size,
|
||||||
{
|
{
|
||||||
long orig_size = depth * plane_size + (depth + 1) * sizeof(long);
|
long orig_size = depth * plane_size + (depth + 1) * sizeof(long);
|
||||||
|
|
||||||
plane_size = MULU16(width, bheight << _PBLOCK_EXP);
|
plane_size = MULU16(width, height);
|
||||||
if (plane_size > orig_size)
|
if (plane_size > orig_size)
|
||||||
{
|
{
|
||||||
buftaken += plane_size;
|
buftaken += plane_size;
|
||||||
|
@ -357,10 +423,16 @@ int gray_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size,
|
||||||
buftaken += depth * plane_size + (depth + 1) * sizeof(long);
|
buftaken += depth * plane_size + (depth + 1) * sizeof(long);
|
||||||
|
|
||||||
_gray_info.x = 0;
|
_gray_info.x = 0;
|
||||||
_gray_info.by = 0;
|
_gray_info.y = 0;
|
||||||
_gray_info.width = width;
|
_gray_info.width = width;
|
||||||
_gray_info.height = bheight << _PBLOCK_EXP;
|
_gray_info.height = height;
|
||||||
_gray_info.bheight = bheight;
|
#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
|
||||||
|
_gray_info.bx = 0;
|
||||||
|
_gray_info.bwidth = bdim;
|
||||||
|
#else
|
||||||
|
_gray_info.by = 0;
|
||||||
|
_gray_info.bheight = bdim;
|
||||||
|
#endif
|
||||||
_gray_info.depth = depth;
|
_gray_info.depth = depth;
|
||||||
_gray_info.flags = 0;
|
_gray_info.flags = 0;
|
||||||
#ifndef SIMULATOR
|
#ifndef SIMULATOR
|
||||||
|
@ -463,13 +535,20 @@ void gray_show(bool enable)
|
||||||
_gray_rb->sim_lcd_ex_init(_gray_info.depth + 1, _gray_get_pixel);
|
_gray_rb->sim_lcd_ex_init(_gray_info.depth + 1, _gray_get_pixel);
|
||||||
gray_update();
|
gray_update();
|
||||||
#else /* !SIMULATOR */
|
#else /* !SIMULATOR */
|
||||||
|
#ifdef NEED_BOOST
|
||||||
|
_gray_rb->cpu_boost(true);
|
||||||
|
#endif
|
||||||
#if CONFIG_LCD == LCD_SSD1815
|
#if CONFIG_LCD == LCD_SSD1815
|
||||||
_gray_rb->timer_register(1, NULL, TIMER_FREQ / 67, 1, _timer_isr);
|
_gray_rb->timer_register(1, NULL, TIMER_FREQ / 67, 1, _timer_isr);
|
||||||
#elif CONFIG_LCD == LCD_S1D15E06
|
#elif CONFIG_LCD == LCD_S1D15E06
|
||||||
_gray_rb->timer_register(1, NULL, TIMER_FREQ / 70, 1, _timer_isr);
|
_gray_rb->timer_register(1, NULL, TIMER_FREQ / 70, 1, _timer_isr);
|
||||||
|
#elif CONFIG_LCD == LCD_IPOD2BPP
|
||||||
|
/* FIXME: verify value */
|
||||||
|
_gray_rb->timer_register(1, NULL, TIMER_FREQ / 40, 1, _timer_isr);
|
||||||
|
#elif CONFIG_LCD == LCD_IPODMINI
|
||||||
|
_gray_rb->timer_register(1, NULL, TIMER_FREQ / 44, 1, _timer_isr);
|
||||||
#elif CONFIG_LCD == LCD_IFP7XX
|
#elif CONFIG_LCD == LCD_IFP7XX
|
||||||
/* TODO: implement for iFP */
|
(void)_timer_isr; /* TODO: implement for iFP */
|
||||||
(void)_timer_isr;
|
|
||||||
#endif /* CONFIG_LCD */
|
#endif /* CONFIG_LCD */
|
||||||
#endif /* !SIMULATOR */
|
#endif /* !SIMULATOR */
|
||||||
_gray_rb->screen_dump_set_hook(gray_screendump_hook);
|
_gray_rb->screen_dump_set_hook(gray_screendump_hook);
|
||||||
|
@ -480,6 +559,9 @@ void gray_show(bool enable)
|
||||||
_gray_rb->sim_lcd_ex_init(0, NULL);
|
_gray_rb->sim_lcd_ex_init(0, NULL);
|
||||||
#else
|
#else
|
||||||
_gray_rb->timer_unregister();
|
_gray_rb->timer_unregister();
|
||||||
|
#ifdef NEED_BOOST
|
||||||
|
_gray_rb->cpu_boost(false);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
_gray_info.flags &= ~_GRAY_RUNNING;
|
_gray_info.flags &= ~_GRAY_RUNNING;
|
||||||
_gray_rb->screen_dump_set_hook(NULL);
|
_gray_rb->screen_dump_set_hook(NULL);
|
||||||
|
@ -492,9 +574,15 @@ void gray_show(bool enable)
|
||||||
Note that x and y are in LCD coordinates, not graybuffer coordinates! */
|
Note that x and y are in LCD coordinates, not graybuffer coordinates! */
|
||||||
static unsigned long _gray_get_pixel(int x, int y)
|
static unsigned long _gray_get_pixel(int x, int y)
|
||||||
{
|
{
|
||||||
return _gray_info.cur_buffer[MULU16(x - _gray_info.x, _gray_info.height)
|
#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
|
||||||
+ y - (_gray_info.by << _PBLOCK_EXP)]
|
return _gray_info.cur_buffer[MULU16(y - _gray_info.y, _gray_info.width)
|
||||||
|
+ x - _gray_info.x]
|
||||||
+ (1 << LCD_DEPTH);
|
+ (1 << LCD_DEPTH);
|
||||||
|
#else
|
||||||
|
return _gray_info.cur_buffer[MULU16(x - _gray_info.x, _gray_info.height)
|
||||||
|
+ y - _gray_info.y]
|
||||||
|
+ (1 << LCD_DEPTH);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update a rectangular area of the greyscale overlay */
|
/* Update a rectangular area of the greyscale overlay */
|
||||||
|
@ -506,7 +594,7 @@ void gray_update_rect(int x, int y, int width, int height)
|
||||||
height = _gray_info.height - y;
|
height = _gray_info.height - y;
|
||||||
|
|
||||||
x += _gray_info.x;
|
x += _gray_info.x;
|
||||||
y += _gray_info.by << _PBLOCK_EXP;
|
y += _gray_info.y;
|
||||||
|
|
||||||
if (x + width > LCD_WIDTH)
|
if (x + width > LCD_WIDTH)
|
||||||
width = LCD_WIDTH - x;
|
width = LCD_WIDTH - x;
|
||||||
|
@ -517,38 +605,41 @@ void gray_update_rect(int x, int y, int width, int height)
|
||||||
}
|
}
|
||||||
|
|
||||||
#else /* !SIMULATOR */
|
#else /* !SIMULATOR */
|
||||||
|
|
||||||
|
#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
|
||||||
|
|
||||||
/* Update a rectangular area of the greyscale overlay */
|
/* Update a rectangular area of the greyscale overlay */
|
||||||
void gray_update_rect(int x, int y, int width, int height)
|
void gray_update_rect(int x, int y, int width, int height)
|
||||||
{
|
{
|
||||||
int ymax;
|
int xmax, bwidth;
|
||||||
long srcofs;
|
long srcofs;
|
||||||
unsigned char *dst;
|
unsigned char *dst;
|
||||||
|
|
||||||
if (width <= 0)
|
if ((width <= 0) || (height <= 0))
|
||||||
return; /* nothing to do */
|
return; /* nothing to do */
|
||||||
|
|
||||||
/* The Y coordinates have to work on whole pixel block rows */
|
/* The X coordinates have to work on whole pixel block columns */
|
||||||
ymax = (y + height - 1) >> _PBLOCK_EXP;
|
xmax = (x + width - 1) >> 3;
|
||||||
y >>= _PBLOCK_EXP;
|
x >>= 3;
|
||||||
|
|
||||||
if (x + width > _gray_info.width)
|
if (y + height > _gray_info.height)
|
||||||
width = _gray_info.width - x;
|
height = _gray_info.height - y;
|
||||||
if (ymax >= _gray_info.bheight)
|
if (xmax >= _gray_info.bwidth)
|
||||||
ymax = _gray_info.bheight - 1;
|
xmax = _gray_info.bwidth - 1;
|
||||||
|
bwidth = xmax - x + 1;
|
||||||
|
|
||||||
srcofs = (y << _PBLOCK_EXP) + MULU16(_gray_info.height, x);
|
srcofs = MULU16(_gray_info.width, y) + (x << 3);
|
||||||
dst = _gray_info.plane_data + MULU16(_gray_info.width, y) + x;
|
dst = _gray_info.plane_data + MULU16(_gray_info.bwidth, y) + x;
|
||||||
|
|
||||||
/* Copy specified rectange bitmap to hardware */
|
/* Copy specified rectangle bitmap to hardware */
|
||||||
for (; y <= ymax; y++)
|
for (; height > 0; height--)
|
||||||
{
|
{
|
||||||
long srcofs_row = srcofs;
|
long srcofs_row = srcofs;
|
||||||
unsigned char *dst_row = dst;
|
unsigned char *dst_row = dst;
|
||||||
unsigned char *dst_end = dst_row + width;
|
unsigned char *dst_end = dst_row + bwidth;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
#if (CONFIG_CPU == SH7034) && (LCD_DEPTH == 1)
|
|
||||||
unsigned long pat_stack[8];
|
unsigned long pat_stack[8];
|
||||||
unsigned long *pat_ptr;
|
unsigned long *pat_ptr;
|
||||||
unsigned char *cbuf, *bbuf;
|
unsigned char *cbuf, *bbuf;
|
||||||
|
@ -557,6 +648,145 @@ void gray_update_rect(int x, int y, int width, int height)
|
||||||
cbuf = _gray_info.cur_buffer + srcofs_row;
|
cbuf = _gray_info.cur_buffer + srcofs_row;
|
||||||
bbuf = _gray_info.back_buffer + srcofs_row;
|
bbuf = _gray_info.back_buffer + srcofs_row;
|
||||||
|
|
||||||
|
#if 0 /* CPU specific asm versions will go here */
|
||||||
|
#else /* C version, for reference*/
|
||||||
|
(void)pat_ptr;
|
||||||
|
/* check whether anything changed in the 8-pixel block */
|
||||||
|
change = *(uint32_t *)cbuf ^ *(uint32_t *)bbuf;
|
||||||
|
cbuf += sizeof(uint32_t);
|
||||||
|
bbuf += sizeof(uint32_t);
|
||||||
|
change |= *(uint32_t *)cbuf ^ *(uint32_t *)bbuf;
|
||||||
|
|
||||||
|
if (change != 0)
|
||||||
|
{
|
||||||
|
unsigned char *addr, *end;
|
||||||
|
unsigned mask = 0;
|
||||||
|
unsigned test = 1;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
cbuf = _gray_info.cur_buffer + srcofs_row;
|
||||||
|
bbuf = _gray_info.back_buffer + srcofs_row;
|
||||||
|
|
||||||
|
/* precalculate the bit patterns with random shifts
|
||||||
|
* for all 8 pixels and put them on an extra "stack" */
|
||||||
|
for (i = 7; i >= 0; i--)
|
||||||
|
{
|
||||||
|
unsigned pat = 0;
|
||||||
|
unsigned char cur = *cbuf++;
|
||||||
|
unsigned char back = *bbuf;
|
||||||
|
|
||||||
|
*bbuf++ = cur;
|
||||||
|
|
||||||
|
mask <<= 1;
|
||||||
|
if (cur != back)
|
||||||
|
{
|
||||||
|
int shift;
|
||||||
|
|
||||||
|
pat = _gray_info.bitpattern[cur];
|
||||||
|
|
||||||
|
/* shift pattern pseudo-random, simple & fast PRNG */
|
||||||
|
_gray_random_buffer = 75 * _gray_random_buffer + 74;
|
||||||
|
shift = (_gray_random_buffer >> 8) & _gray_info.randmask;
|
||||||
|
if (shift >= _gray_info.depth)
|
||||||
|
shift -= _gray_info.depth;
|
||||||
|
|
||||||
|
pat = (pat << shift) | (pat >> (_gray_info.depth - shift));
|
||||||
|
|
||||||
|
mask |= 1;
|
||||||
|
}
|
||||||
|
pat_stack[i] = pat;
|
||||||
|
}
|
||||||
|
|
||||||
|
addr = dst_row;
|
||||||
|
end = addr + MULU16(_gray_info.depth, _gray_info.plane_size);
|
||||||
|
|
||||||
|
/* set the bits for all 8 pixels in all bytes according to the
|
||||||
|
* precalculated patterns on the pattern stack */
|
||||||
|
mask = (~mask & 0xff);
|
||||||
|
if (mask == 0)
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
unsigned data = 0;
|
||||||
|
|
||||||
|
for (i = 7; i >= 0; i--)
|
||||||
|
data = (data << 1) | ((pat_stack[i] & test) ? 1 : 0);
|
||||||
|
|
||||||
|
*addr = data;
|
||||||
|
addr += _gray_info.plane_size;
|
||||||
|
test <<= 1;
|
||||||
|
}
|
||||||
|
while (addr < end);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
unsigned data = 0;
|
||||||
|
|
||||||
|
for (i = 7; i >= 0; i--)
|
||||||
|
data = (data << 1) | ((pat_stack[i] & test) ? 1 : 0);
|
||||||
|
|
||||||
|
*addr = (*addr & mask) | data;
|
||||||
|
addr += _gray_info.plane_size;
|
||||||
|
test <<= 1;
|
||||||
|
}
|
||||||
|
while (addr < end);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_CPU */
|
||||||
|
srcofs_row += 8;
|
||||||
|
dst_row++;
|
||||||
|
}
|
||||||
|
while (dst_row < dst_end);
|
||||||
|
|
||||||
|
srcofs += _gray_info.width;
|
||||||
|
dst += _gray_info.bwidth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else /* LCD_PIXELFORMAT == VERTICAL_PACKING */
|
||||||
|
|
||||||
|
/* Update a rectangular area of the greyscale overlay */
|
||||||
|
void gray_update_rect(int x, int y, int width, int height)
|
||||||
|
{
|
||||||
|
int ymax;
|
||||||
|
long srcofs;
|
||||||
|
unsigned char *dst;
|
||||||
|
|
||||||
|
if ((width <= 0) || (height <= 0))
|
||||||
|
return; /* nothing to do */
|
||||||
|
|
||||||
|
/* The Y coordinates have to work on whole pixel block rows */
|
||||||
|
ymax = (y + height - 1) >> 3;
|
||||||
|
y >>= 3;
|
||||||
|
|
||||||
|
if (x + width > _gray_info.width)
|
||||||
|
width = _gray_info.width - x;
|
||||||
|
if (ymax >= _gray_info.bheight)
|
||||||
|
ymax = _gray_info.bheight - 1;
|
||||||
|
|
||||||
|
srcofs = (y << 3) + MULU16(_gray_info.height, x);
|
||||||
|
dst = _gray_info.plane_data + MULU16(_gray_info.width, y) + x;
|
||||||
|
|
||||||
|
/* Copy specified rectangle bitmap to hardware */
|
||||||
|
for (; y <= ymax; y++)
|
||||||
|
{
|
||||||
|
long srcofs_row = srcofs;
|
||||||
|
unsigned char *dst_row = dst;
|
||||||
|
unsigned char *dst_end = dst_row + width;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
unsigned long pat_stack[8];
|
||||||
|
unsigned long *pat_ptr;
|
||||||
|
unsigned char *cbuf, *bbuf;
|
||||||
|
unsigned change;
|
||||||
|
|
||||||
|
cbuf = _gray_info.cur_buffer + srcofs_row;
|
||||||
|
bbuf = _gray_info.back_buffer + srcofs_row;
|
||||||
|
|
||||||
|
#if CONFIG_CPU == SH7034
|
||||||
asm volatile (
|
asm volatile (
|
||||||
"mov.l @%[cbuf]+,r1 \n"
|
"mov.l @%[cbuf]+,r1 \n"
|
||||||
"mov.l @%[bbuf]+,r2 \n"
|
"mov.l @%[bbuf]+,r2 \n"
|
||||||
|
@ -738,15 +968,7 @@ void gray_update_rect(int x, int y, int width, int height)
|
||||||
"r0", "r1", "r2", "r3", "r6", "r7", "r8", "r9", "r10"
|
"r0", "r1", "r2", "r3", "r6", "r7", "r8", "r9", "r10"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
#elif defined(CPU_COLDFIRE) && (LCD_DEPTH == 2)
|
#elif defined(CPU_COLDFIRE)
|
||||||
unsigned long pat_stack[8];
|
|
||||||
unsigned long *pat_ptr;
|
|
||||||
unsigned char *cbuf, *bbuf;
|
|
||||||
unsigned change;
|
|
||||||
|
|
||||||
cbuf = _gray_info.cur_buffer + srcofs_row;
|
|
||||||
bbuf = _gray_info.back_buffer + srcofs_row;
|
|
||||||
|
|
||||||
asm volatile (
|
asm volatile (
|
||||||
"move.l (%[cbuf])+,%%d0 \n"
|
"move.l (%[cbuf])+,%%d0 \n"
|
||||||
"move.l (%[bbuf])+,%%d1 \n"
|
"move.l (%[bbuf])+,%%d1 \n"
|
||||||
|
@ -924,16 +1146,105 @@ void gray_update_rect(int x, int y, int width, int height)
|
||||||
"d0", "d1", "d2", "d3", "d4", "d5", "d6", "a0", "a1"
|
"d0", "d1", "d2", "d3", "d4", "d5", "d6", "a0", "a1"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_CPU, LCD_DEPTH */
|
#else /* C version, for reference*/
|
||||||
|
#warning C version of gray_update_rect() used
|
||||||
|
(void)pat_ptr;
|
||||||
|
/* check whether anything changed in the 8-pixel block */
|
||||||
|
change = *(uint32_t *)cbuf ^ *(uint32_t *)bbuf;
|
||||||
|
cbuf += sizeof(uint32_t);
|
||||||
|
bbuf += sizeof(uint32_t);
|
||||||
|
change |= *(uint32_t *)cbuf ^ *(uint32_t *)bbuf;
|
||||||
|
|
||||||
|
if (change != 0)
|
||||||
|
{
|
||||||
|
unsigned char *addr, *end;
|
||||||
|
unsigned mask = 0;
|
||||||
|
unsigned test = 1;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
cbuf = _gray_info.cur_buffer + srcofs_row;
|
||||||
|
bbuf = _gray_info.back_buffer + srcofs_row;
|
||||||
|
|
||||||
|
/* precalculate the bit patterns with random shifts
|
||||||
|
* for all 8 pixels and put them on an extra "stack" */
|
||||||
|
for (i = 0; i < 8; i++)
|
||||||
|
{
|
||||||
|
unsigned pat = 0;
|
||||||
|
unsigned char cur = *cbuf++;
|
||||||
|
unsigned char back = *bbuf;
|
||||||
|
|
||||||
|
*bbuf++ = cur;
|
||||||
|
|
||||||
|
if (cur != back)
|
||||||
|
{
|
||||||
|
int shift;
|
||||||
|
|
||||||
|
pat = _gray_info.bitpattern[cur];
|
||||||
|
|
||||||
|
/* shift pattern pseudo-random, simple & fast PRNG */
|
||||||
|
_gray_random_buffer = 75 * _gray_random_buffer + 74;
|
||||||
|
shift = (_gray_random_buffer >> 8) & _gray_info.randmask;
|
||||||
|
if (shift >= _gray_info.depth)
|
||||||
|
shift -= _gray_info.depth;
|
||||||
|
|
||||||
|
pat = (pat << shift) | (pat >> (_gray_info.depth - shift));
|
||||||
|
|
||||||
|
mask |= 0x100;
|
||||||
|
}
|
||||||
|
mask >>= 1;
|
||||||
|
pat_stack[i] = pat;
|
||||||
|
}
|
||||||
|
|
||||||
|
addr = dst_row;
|
||||||
|
end = addr + MULU16(_gray_info.depth, _gray_info.plane_size);
|
||||||
|
|
||||||
|
/* set the bits for all 8 pixels in all bytes according to the
|
||||||
|
* precalculated patterns on the pattern stack */
|
||||||
|
mask = (~mask & 0xff);
|
||||||
|
if (mask == 0)
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
unsigned data = 0;
|
||||||
|
|
||||||
|
for (i = 7; i >= 0; i--)
|
||||||
|
data = (data << 1) | ((pat_stack[i] & test) ? 1 : 0);
|
||||||
|
|
||||||
|
*addr = data;
|
||||||
|
addr += _gray_info.plane_size;
|
||||||
|
test <<= 1;
|
||||||
|
}
|
||||||
|
while (addr < end);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
unsigned data = 0;
|
||||||
|
|
||||||
|
for (i = 7; i >= 0; i--)
|
||||||
|
data = (data << 1) | ((pat_stack[i] & test) ? 1 : 0);
|
||||||
|
|
||||||
|
*addr = (*addr & mask) | data;
|
||||||
|
addr += _gray_info.plane_size;
|
||||||
|
test <<= 1;
|
||||||
|
}
|
||||||
|
while (addr < end);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_CPU */
|
||||||
srcofs_row += _gray_info.height;
|
srcofs_row += _gray_info.height;
|
||||||
dst_row++;
|
dst_row++;
|
||||||
}
|
}
|
||||||
while (dst_row < dst_end);
|
while (dst_row < dst_end);
|
||||||
|
|
||||||
srcofs += _PBLOCK;
|
srcofs += 8;
|
||||||
dst += _gray_info.width;
|
dst += _gray_info.width;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif /* LCD_PIXELFORMAT */
|
||||||
|
|
||||||
#endif /* !SIMULATOR */
|
#endif /* !SIMULATOR */
|
||||||
|
|
||||||
/* Update the whole greyscale overlay */
|
/* Update the whole greyscale overlay */
|
||||||
|
@ -1047,10 +1358,10 @@ static void gray_screendump_hook(int fd)
|
||||||
{
|
{
|
||||||
_gray_rb->memset(linebuf, 0, BMP_LINESIZE);
|
_gray_rb->memset(linebuf, 0, BMP_LINESIZE);
|
||||||
|
|
||||||
gy = y - (_gray_info.by << _PBLOCK_EXP);
|
gy = y - _gray_info.y;
|
||||||
#if LCD_DEPTH == 1
|
#if LCD_DEPTH == 1
|
||||||
mask = 1 << (y & (_PBLOCK-1));
|
mask = 1 << (y & 7);
|
||||||
by = y >> _PBLOCK_EXP;
|
by = y >> 3;
|
||||||
lcdptr = _gray_rb->lcd_framebuffer + MULU16(LCD_WIDTH, by);
|
lcdptr = _gray_rb->lcd_framebuffer + MULU16(LCD_WIDTH, by);
|
||||||
|
|
||||||
if ((unsigned) gy < (unsigned) _gray_info.height)
|
if ((unsigned) gy < (unsigned) _gray_info.height)
|
||||||
|
@ -1058,7 +1369,7 @@ static void gray_screendump_hook(int fd)
|
||||||
/* line contains greyscale (and maybe b&w) graphics */
|
/* line contains greyscale (and maybe b&w) graphics */
|
||||||
#ifndef SIMULATOR
|
#ifndef SIMULATOR
|
||||||
unsigned char *grayptr = _gray_info.plane_data
|
unsigned char *grayptr = _gray_info.plane_data
|
||||||
+ MULU16(_gray_info.width, gy >> _PBLOCK_EXP);
|
+ MULU16(_gray_info.width, gy >> 3);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (x = 0; x < LCD_WIDTH; x++)
|
for (x = 0; x < LCD_WIDTH; x++)
|
||||||
|
@ -1108,8 +1419,8 @@ static void gray_screendump_hook(int fd)
|
||||||
(void)mask;
|
(void)mask;
|
||||||
#else
|
#else
|
||||||
unsigned char *grayptr = _gray_info.plane_data
|
unsigned char *grayptr = _gray_info.plane_data
|
||||||
+ MULU16(_gray_info.width, gy >> _PBLOCK_EXP);
|
+ MULU16(_gray_info.width, gy >> 3);
|
||||||
mask = 1 << (gy & (_PBLOCK-1));
|
mask = 1 << (gy & 7);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (x = 0; x < LCD_WIDTH; x++)
|
for (x = 0; x < LCD_WIDTH; x++)
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
* Drawing functions
|
* Drawing functions
|
||||||
*
|
*
|
||||||
* This is a generic framework to display up to 33 shades of grey
|
* This is a generic framework to display up to 33 shades of grey
|
||||||
* on low-depth bitmap LCDs (Archos b&w, Iriver 4-grey) within plugins.
|
* on low-depth bitmap LCDs (Archos b&w, Iriver 4-grey, iPod 4-grey)
|
||||||
|
* within plugins.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2004-2006 Jens Arnold
|
* Copyright (C) 2004-2006 Jens Arnold
|
||||||
*
|
*
|
||||||
|
@ -72,8 +73,13 @@ void gray_drawpixel(int x, int y)
|
||||||
{
|
{
|
||||||
if (((unsigned)x < (unsigned)_gray_info.width)
|
if (((unsigned)x < (unsigned)_gray_info.width)
|
||||||
&& ((unsigned)y < (unsigned)_gray_info.height))
|
&& ((unsigned)y < (unsigned)_gray_info.height))
|
||||||
|
#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
|
||||||
|
_gray_pixelfuncs[_gray_info.drawmode](&_gray_info.cur_buffer[MULU16(y,
|
||||||
|
_gray_info.width) + x]);
|
||||||
|
#else
|
||||||
_gray_pixelfuncs[_gray_info.drawmode](&_gray_info.cur_buffer[MULU16(x,
|
_gray_pixelfuncs[_gray_info.drawmode](&_gray_info.cur_buffer[MULU16(x,
|
||||||
_gray_info.height) + y]);
|
_gray_info.height) + y]);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Draw a line */
|
/* Draw a line */
|
||||||
|
@ -131,7 +137,11 @@ void gray_drawline(int x1, int y1, int x2, int y2)
|
||||||
{
|
{
|
||||||
if (((unsigned)x < (unsigned)_gray_info.width)
|
if (((unsigned)x < (unsigned)_gray_info.width)
|
||||||
&& ((unsigned)y < (unsigned)_gray_info.height))
|
&& ((unsigned)y < (unsigned)_gray_info.height))
|
||||||
|
#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
|
||||||
|
pfunc(&_gray_info.cur_buffer[MULU16(y, _gray_info.width) + x]);
|
||||||
|
#else
|
||||||
pfunc(&_gray_info.cur_buffer[MULU16(x, _gray_info.height) + y]);
|
pfunc(&_gray_info.cur_buffer[MULU16(x, _gray_info.height) + y]);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (d < 0)
|
if (d < 0)
|
||||||
{
|
{
|
||||||
|
@ -148,6 +158,175 @@ void gray_drawline(int x1, int y1, int x2, int y2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
|
||||||
|
|
||||||
|
/* Draw a horizontal line (optimised) */
|
||||||
|
void gray_hline(int x1, int x2, int y)
|
||||||
|
{
|
||||||
|
int x;
|
||||||
|
int bits = 0;
|
||||||
|
unsigned char *dst;
|
||||||
|
bool fillopt = false;
|
||||||
|
void (*pfunc)(unsigned char *address);
|
||||||
|
|
||||||
|
/* direction flip */
|
||||||
|
if (x2 < x1)
|
||||||
|
{
|
||||||
|
x = x1;
|
||||||
|
x1 = x2;
|
||||||
|
x2 = x;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* nothing to draw? */
|
||||||
|
if (((unsigned)y >= (unsigned)_gray_info.height)
|
||||||
|
|| (x1 >= _gray_info.width) || (x2 < 0))
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* clipping */
|
||||||
|
if (x1 < 0)
|
||||||
|
x1 = 0;
|
||||||
|
if (x2 >= _gray_info.width)
|
||||||
|
x2 = _gray_info.width - 1;
|
||||||
|
|
||||||
|
if (_gray_info.drawmode & DRMODE_INVERSEVID)
|
||||||
|
{
|
||||||
|
if (_gray_info.drawmode & DRMODE_BG)
|
||||||
|
{
|
||||||
|
fillopt = true;
|
||||||
|
bits = _gray_info.bg_index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_gray_info.drawmode & DRMODE_FG)
|
||||||
|
{
|
||||||
|
fillopt = true;
|
||||||
|
bits = _gray_info.fg_index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pfunc = _gray_pixelfuncs[_gray_info.drawmode];
|
||||||
|
dst = &_gray_info.cur_buffer[MULU16(y, _gray_info.width) + x1];
|
||||||
|
|
||||||
|
if (fillopt)
|
||||||
|
_gray_rb->memset(dst, bits, x2 - x1 + 1);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
unsigned char *dst_end = dst + x2 - x1;
|
||||||
|
do
|
||||||
|
pfunc(dst++);
|
||||||
|
while (dst <= dst_end);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Draw a vertical line (optimised) */
|
||||||
|
void gray_vline(int x, int y1, int y2)
|
||||||
|
{
|
||||||
|
int y;
|
||||||
|
unsigned char *dst, *dst_end;
|
||||||
|
void (*pfunc)(unsigned char *address);
|
||||||
|
|
||||||
|
/* direction flip */
|
||||||
|
if (y2 < y1)
|
||||||
|
{
|
||||||
|
y = y1;
|
||||||
|
y1 = y2;
|
||||||
|
y2 = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* nothing to draw? */
|
||||||
|
if (((unsigned)x >= (unsigned)_gray_info.width)
|
||||||
|
|| (y1 >= _gray_info.height) || (y2 < 0))
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* clipping */
|
||||||
|
if (y1 < 0)
|
||||||
|
y1 = 0;
|
||||||
|
if (y2 >= _gray_info.height)
|
||||||
|
y2 = _gray_info.height - 1;
|
||||||
|
|
||||||
|
pfunc = _gray_pixelfuncs[_gray_info.drawmode];
|
||||||
|
dst = &_gray_info.cur_buffer[MULU16(y1, _gray_info.width) + x];
|
||||||
|
|
||||||
|
dst_end = dst + MULU16(y2 - y1, _gray_info.width);
|
||||||
|
do
|
||||||
|
{
|
||||||
|
pfunc(dst);
|
||||||
|
dst += _gray_info.width;
|
||||||
|
}
|
||||||
|
while (dst <= dst_end);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Draw a filled triangle */
|
||||||
|
void gray_filltriangle(int x1, int y1, int x2, int y2, int x3, int y3)
|
||||||
|
{
|
||||||
|
int x, y;
|
||||||
|
long fp_x1, fp_x2, fp_dx1, fp_dx2;
|
||||||
|
|
||||||
|
/* sort vertices by increasing y value */
|
||||||
|
if (y1 > y3)
|
||||||
|
{
|
||||||
|
if (y2 < y3) /* y2 < y3 < y1 */
|
||||||
|
{
|
||||||
|
x = x1; x1 = x2; x2 = x3; x3 = x;
|
||||||
|
y = y1; y1 = y2; y2 = y3; y3 = y;
|
||||||
|
}
|
||||||
|
else if (y2 > y1) /* y3 < y1 < y2 */
|
||||||
|
{
|
||||||
|
x = x1; x1 = x3; x3 = x2; x2 = x;
|
||||||
|
y = y1; y1 = y3; y3 = y2; y2 = y;
|
||||||
|
}
|
||||||
|
else /* y3 <= y2 <= y1 */
|
||||||
|
{
|
||||||
|
x = x1; x1 = x3; x3 = x;
|
||||||
|
y = y1; y1 = y3; y3 = y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (y2 < y1) /* y2 < y1 <= y3 */
|
||||||
|
{
|
||||||
|
x = x1; x1 = x2; x2 = x;
|
||||||
|
y = y1; y1 = y2; y2 = y;
|
||||||
|
}
|
||||||
|
else if (y2 > y3) /* y1 <= y3 < y2 */
|
||||||
|
{
|
||||||
|
x = x2; x2 = x3; x3 = x;
|
||||||
|
y = y2; y2 = y3; y3 = y;
|
||||||
|
}
|
||||||
|
/* else already sorted */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (y1 < y3) /* draw */
|
||||||
|
{
|
||||||
|
fp_dx1 = ((x3 - x1) << 16) / (y3 - y1);
|
||||||
|
fp_x1 = (x1 << 16) + (1<<15) + (fp_dx1 >> 1);
|
||||||
|
|
||||||
|
if (y1 < y2) /* first part */
|
||||||
|
{
|
||||||
|
fp_dx2 = ((x2 - x1) << 16) / (y2 - y1);
|
||||||
|
fp_x2 = (x1 << 16) + (1<<15) + (fp_dx2 >> 1);
|
||||||
|
for (y = y1; y < y2; y++)
|
||||||
|
{
|
||||||
|
gray_hline(fp_x1 >> 16, fp_x2 >> 16, y);
|
||||||
|
fp_x1 += fp_dx1;
|
||||||
|
fp_x2 += fp_dx2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (y2 < y3) /* second part */
|
||||||
|
{
|
||||||
|
fp_dx2 = ((x3 - x2) << 16) / (y3 - y2);
|
||||||
|
fp_x2 = (x2 << 16) + (1<<15) + (fp_dx2 >> 1);
|
||||||
|
for (y = y2; y < y3; y++)
|
||||||
|
{
|
||||||
|
gray_hline(fp_x1 >> 16, fp_x2 >> 16, y);
|
||||||
|
fp_x1 += fp_dx1;
|
||||||
|
fp_x2 += fp_dx2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else /* LCD_PIXELFORMAT == VERTICAL_PACKING */
|
||||||
|
|
||||||
/* Draw a horizontal line (optimised) */
|
/* Draw a horizontal line (optimised) */
|
||||||
void gray_hline(int x1, int x2, int y)
|
void gray_hline(int x1, int x2, int y)
|
||||||
{
|
{
|
||||||
|
@ -244,88 +423,6 @@ void gray_vline(int x, int y1, int y2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Draw a rectangular box */
|
|
||||||
void gray_drawrect(int x, int y, int width, int height)
|
|
||||||
{
|
|
||||||
if ((width <= 0) || (height <= 0))
|
|
||||||
return;
|
|
||||||
|
|
||||||
int x2 = x + width - 1;
|
|
||||||
int y2 = y + height - 1;
|
|
||||||
|
|
||||||
gray_vline(x, y, y2);
|
|
||||||
gray_vline(x2, y, y2);
|
|
||||||
gray_hline(x, x2, y);
|
|
||||||
gray_hline(x, x2, y2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Fill a rectangular area */
|
|
||||||
void gray_fillrect(int x, int y, int width, int height)
|
|
||||||
{
|
|
||||||
int bits = 0;
|
|
||||||
unsigned char *dst, *dst_end;
|
|
||||||
bool fillopt = false;
|
|
||||||
void (*pfunc)(unsigned char *address);
|
|
||||||
|
|
||||||
/* nothing to draw? */
|
|
||||||
if ((width <= 0) || (height <= 0) || (x >= _gray_info.width)
|
|
||||||
|| (y >= _gray_info.height) || (x + width <= 0) || (y + height <= 0))
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* clipping */
|
|
||||||
if (x < 0)
|
|
||||||
{
|
|
||||||
width += x;
|
|
||||||
x = 0;
|
|
||||||
}
|
|
||||||
if (y < 0)
|
|
||||||
{
|
|
||||||
height += y;
|
|
||||||
y = 0;
|
|
||||||
}
|
|
||||||
if (x + width > _gray_info.width)
|
|
||||||
width = _gray_info.width - x;
|
|
||||||
if (y + height > _gray_info.height)
|
|
||||||
height = _gray_info.height - y;
|
|
||||||
|
|
||||||
if (_gray_info.drawmode & DRMODE_INVERSEVID)
|
|
||||||
{
|
|
||||||
if (_gray_info.drawmode & DRMODE_BG)
|
|
||||||
{
|
|
||||||
fillopt = true;
|
|
||||||
bits = _gray_info.bg_index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (_gray_info.drawmode & DRMODE_FG)
|
|
||||||
{
|
|
||||||
fillopt = true;
|
|
||||||
bits = _gray_info.fg_index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pfunc = _gray_pixelfuncs[_gray_info.drawmode];
|
|
||||||
dst = &_gray_info.cur_buffer[MULU16(x, _gray_info.height) + y];
|
|
||||||
dst_end = dst + MULU16(width, _gray_info.height);
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
if (fillopt)
|
|
||||||
_gray_rb->memset(dst, bits, height);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
unsigned char *dst_col = dst;
|
|
||||||
unsigned char *col_end = dst_col + height;
|
|
||||||
|
|
||||||
do
|
|
||||||
pfunc(dst_col++);
|
|
||||||
while (dst_col < col_end);
|
|
||||||
}
|
|
||||||
dst += _gray_info.height;
|
|
||||||
}
|
|
||||||
while (dst < dst_end);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Draw a filled triangle */
|
/* Draw a filled triangle */
|
||||||
void gray_filltriangle(int x1, int y1, int x2, int y2, int x3, int y3)
|
void gray_filltriangle(int x1, int y1, int x2, int y2, int x3, int y3)
|
||||||
{
|
{
|
||||||
|
@ -395,6 +492,111 @@ void gray_filltriangle(int x1, int y1, int x2, int y2, int x3, int y3)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif /* LCD_PIXELFORMAT */
|
||||||
|
|
||||||
|
/* Draw a rectangular box */
|
||||||
|
void gray_drawrect(int x, int y, int width, int height)
|
||||||
|
{
|
||||||
|
if ((width <= 0) || (height <= 0))
|
||||||
|
return;
|
||||||
|
|
||||||
|
int x2 = x + width - 1;
|
||||||
|
int y2 = y + height - 1;
|
||||||
|
|
||||||
|
gray_vline(x, y, y2);
|
||||||
|
gray_vline(x2, y, y2);
|
||||||
|
gray_hline(x, x2, y);
|
||||||
|
gray_hline(x, x2, y2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fill a rectangular area */
|
||||||
|
void gray_fillrect(int x, int y, int width, int height)
|
||||||
|
{
|
||||||
|
int bits = 0;
|
||||||
|
unsigned char *dst, *dst_end;
|
||||||
|
bool fillopt = false;
|
||||||
|
void (*pfunc)(unsigned char *address);
|
||||||
|
|
||||||
|
/* nothing to draw? */
|
||||||
|
if ((width <= 0) || (height <= 0) || (x >= _gray_info.width)
|
||||||
|
|| (y >= _gray_info.height) || (x + width <= 0) || (y + height <= 0))
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* clipping */
|
||||||
|
if (x < 0)
|
||||||
|
{
|
||||||
|
width += x;
|
||||||
|
x = 0;
|
||||||
|
}
|
||||||
|
if (y < 0)
|
||||||
|
{
|
||||||
|
height += y;
|
||||||
|
y = 0;
|
||||||
|
}
|
||||||
|
if (x + width > _gray_info.width)
|
||||||
|
width = _gray_info.width - x;
|
||||||
|
if (y + height > _gray_info.height)
|
||||||
|
height = _gray_info.height - y;
|
||||||
|
|
||||||
|
if (_gray_info.drawmode & DRMODE_INVERSEVID)
|
||||||
|
{
|
||||||
|
if (_gray_info.drawmode & DRMODE_BG)
|
||||||
|
{
|
||||||
|
fillopt = true;
|
||||||
|
bits = _gray_info.bg_index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_gray_info.drawmode & DRMODE_FG)
|
||||||
|
{
|
||||||
|
fillopt = true;
|
||||||
|
bits = _gray_info.fg_index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pfunc = _gray_pixelfuncs[_gray_info.drawmode];
|
||||||
|
#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
|
||||||
|
dst = &_gray_info.cur_buffer[MULU16(y, _gray_info.width) + x];
|
||||||
|
dst_end = dst + MULU16(height, _gray_info.width);
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (fillopt)
|
||||||
|
_gray_rb->memset(dst, bits, width);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
unsigned char *dst_row = dst;
|
||||||
|
unsigned char *row_end = dst_row + width;
|
||||||
|
|
||||||
|
do
|
||||||
|
pfunc(dst_row++);
|
||||||
|
while (dst_row < row_end);
|
||||||
|
}
|
||||||
|
dst += _gray_info.width;
|
||||||
|
}
|
||||||
|
while (dst < dst_end);
|
||||||
|
#else
|
||||||
|
dst = &_gray_info.cur_buffer[MULU16(x, _gray_info.height) + y];
|
||||||
|
dst_end = dst + MULU16(width, _gray_info.height);
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (fillopt)
|
||||||
|
_gray_rb->memset(dst, bits, height);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
unsigned char *dst_col = dst;
|
||||||
|
unsigned char *col_end = dst_col + height;
|
||||||
|
|
||||||
|
do
|
||||||
|
pfunc(dst_col++);
|
||||||
|
while (dst_col < col_end);
|
||||||
|
}
|
||||||
|
dst += _gray_info.height;
|
||||||
|
}
|
||||||
|
while (dst < dst_end);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/* About Rockbox' internal monochrome bitmap format:
|
/* About Rockbox' internal monochrome bitmap format:
|
||||||
*
|
*
|
||||||
|
@ -403,9 +605,7 @@ void gray_filltriangle(int x1, int y1, int x2, int y2, int x3, int y3)
|
||||||
* vertically, LSB at top.
|
* vertically, LSB at top.
|
||||||
* The bytes are stored in row-major order, with byte 0 being top left,
|
* The bytes are stored in row-major order, with byte 0 being top left,
|
||||||
* byte 1 2nd from left etc. The first row of bytes defines pixel rows
|
* byte 1 2nd from left etc. The first row of bytes defines pixel rows
|
||||||
* 0..7, the second row defines pixel row 8..15 etc.
|
* 0..7, the second row defines pixel row 8..15 etc. */
|
||||||
*
|
|
||||||
* This is similar to the internal lcd hw format. */
|
|
||||||
|
|
||||||
/* Draw a partial monochrome bitmap */
|
/* Draw a partial monochrome bitmap */
|
||||||
void gray_mono_bitmap_part(const unsigned char *src, int src_x, int src_y,
|
void gray_mono_bitmap_part(const unsigned char *src, int src_x, int src_y,
|
||||||
|
@ -443,9 +643,41 @@ void gray_mono_bitmap_part(const unsigned char *src, int src_x, int src_y,
|
||||||
src_y &= 7;
|
src_y &= 7;
|
||||||
src_end = src + width;
|
src_end = src + width;
|
||||||
|
|
||||||
dst = &_gray_info.cur_buffer[MULU16(x, _gray_info.height) + y];
|
|
||||||
fgfunc = _gray_pixelfuncs[_gray_info.drawmode];
|
fgfunc = _gray_pixelfuncs[_gray_info.drawmode];
|
||||||
bgfunc = _gray_pixelfuncs[_gray_info.drawmode ^ DRMODE_INVERSEVID];
|
bgfunc = _gray_pixelfuncs[_gray_info.drawmode ^ DRMODE_INVERSEVID];
|
||||||
|
#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
|
||||||
|
dst = &_gray_info.cur_buffer[MULU16(y, _gray_info.width) + x];
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
const unsigned char *src_col = src++;
|
||||||
|
unsigned char *dst_col = dst++;
|
||||||
|
unsigned data = *src_col >> src_y;
|
||||||
|
int numbits = 8 - src_y;
|
||||||
|
|
||||||
|
dst_end = dst_col + MULU16(height, _gray_info.width);
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (data & 0x01)
|
||||||
|
fgfunc(dst_col);
|
||||||
|
else
|
||||||
|
bgfunc(dst_col);
|
||||||
|
|
||||||
|
dst_col += _gray_info.width;
|
||||||
|
|
||||||
|
data >>= 1;
|
||||||
|
if (--numbits == 0)
|
||||||
|
{
|
||||||
|
src_col += stride;
|
||||||
|
data = *src_col;
|
||||||
|
numbits = 8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (dst_col < dst_end);
|
||||||
|
}
|
||||||
|
while (src < src_end);
|
||||||
|
#else /* LCD_PIXELFORMAT == VERTICAL_PACKING */
|
||||||
|
dst = &_gray_info.cur_buffer[MULU16(x, _gray_info.height) + y];
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@ -475,6 +707,7 @@ void gray_mono_bitmap_part(const unsigned char *src, int src_x, int src_y,
|
||||||
dst += _gray_info.height;
|
dst += _gray_info.height;
|
||||||
}
|
}
|
||||||
while (src < src_end);
|
while (src < src_end);
|
||||||
|
#endif /* LCD_PIXELFORMAT */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Draw a full monochrome bitmap */
|
/* Draw a full monochrome bitmap */
|
||||||
|
@ -487,7 +720,6 @@ void gray_mono_bitmap(const unsigned char *src, int x, int y, int width, int hei
|
||||||
void gray_gray_bitmap_part(const unsigned char *src, int src_x, int src_y,
|
void gray_gray_bitmap_part(const unsigned char *src, int src_x, int src_y,
|
||||||
int stride, int x, int y, int width, int height)
|
int stride, int x, int y, int width, int height)
|
||||||
{
|
{
|
||||||
const unsigned char *src_end;
|
|
||||||
unsigned char *dst, *dst_end;
|
unsigned char *dst, *dst_end;
|
||||||
|
|
||||||
/* nothing to draw? */
|
/* nothing to draw? */
|
||||||
|
@ -514,25 +746,45 @@ void gray_gray_bitmap_part(const unsigned char *src, int src_x, int src_y,
|
||||||
height = _gray_info.height - y;
|
height = _gray_info.height - y;
|
||||||
|
|
||||||
src += MULU16(stride, src_y) + src_x; /* move starting point */
|
src += MULU16(stride, src_y) + src_x; /* move starting point */
|
||||||
src_end = src + width;
|
#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
|
||||||
dst = &_gray_info.cur_buffer[MULU16(x, _gray_info.height) + y];
|
dst = &_gray_info.cur_buffer[MULU16(y, _gray_info.width) + x];
|
||||||
|
dst_end = dst + MULU16(height, _gray_info.width);
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
const unsigned char *src_col = src++;
|
const unsigned char *src_row = src;
|
||||||
unsigned char *dst_col = dst;
|
unsigned char *dst_row = dst;
|
||||||
|
unsigned char *row_end = dst_row + width;
|
||||||
|
|
||||||
|
do
|
||||||
|
*dst_row++ = _gray_info.idxtable[*src_row++];
|
||||||
|
while (dst_row < row_end);
|
||||||
|
|
||||||
|
src += stride;
|
||||||
|
dst += _gray_info.width;
|
||||||
|
}
|
||||||
|
while (dst < dst_end);
|
||||||
|
#else /* LCD_PIXELFORMAT == VERTICAL_PACKING */
|
||||||
|
dst = &_gray_info.cur_buffer[MULU16(x, _gray_info.height) + y];
|
||||||
|
dst_end = dst + height;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
const unsigned char *src_row = src;
|
||||||
|
unsigned char *dst_row = dst++;
|
||||||
|
unsigned char *row_end = dst_row + MULU16(width, _gray_info.height);
|
||||||
|
|
||||||
dst_end = dst_col + height;
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
*dst_col++ = _gray_info.idxtable[*src_col];
|
*dst_row = _gray_info.idxtable[*src_row++];
|
||||||
src_col += stride;
|
dst_row += _gray_info.height;
|
||||||
}
|
}
|
||||||
while (dst_col < dst_end);
|
while (dst_row < row_end);
|
||||||
|
|
||||||
dst += _gray_info.height;
|
src += stride;
|
||||||
}
|
}
|
||||||
while (src < src_end);
|
while (dst < dst_end);
|
||||||
|
#endif /* LCD_PIXELFORMAT */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Draw a full greyscale bitmap, canonical format */
|
/* Draw a full greyscale bitmap, canonical format */
|
||||||
|
@ -612,6 +864,149 @@ void gray_ub_clear_display(void)
|
||||||
_gray_info.plane_size));
|
_gray_info.plane_size));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
|
||||||
|
|
||||||
|
/* Write a pixel block, defined by their brightnesses in a greymap.
|
||||||
|
Address is the byte in the first bitplane, src is the greymap start address,
|
||||||
|
stride is the increment for the greymap to get to the next pixel, mask
|
||||||
|
determines which pixels of the destination block are changed. */
|
||||||
|
static void _writearray(unsigned char *address, const unsigned char *src,
|
||||||
|
unsigned mask)
|
||||||
|
{
|
||||||
|
unsigned long pat_stack[8];
|
||||||
|
unsigned long *pat_ptr = &pat_stack[8];
|
||||||
|
unsigned char *addr, *end;
|
||||||
|
#if 0 /* CPU specific asm versions will go here */
|
||||||
|
#else /* C version, for reference*/
|
||||||
|
unsigned test = 0x80;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* precalculate the bit patterns with random shifts
|
||||||
|
* for all 8 pixels and put them on an extra "stack" */
|
||||||
|
for (i = 7; i >= 0; i--)
|
||||||
|
{
|
||||||
|
unsigned pat = 0;
|
||||||
|
|
||||||
|
if (mask & test)
|
||||||
|
{
|
||||||
|
int shift;
|
||||||
|
|
||||||
|
pat = _gray_info.bitpattern[_gray_info.idxtable[*src]];
|
||||||
|
|
||||||
|
/* shift pattern pseudo-random, simple & fast PRNG */
|
||||||
|
_gray_random_buffer = 75 * _gray_random_buffer + 74;
|
||||||
|
shift = (_gray_random_buffer >> 8) & _gray_info.randmask;
|
||||||
|
if (shift >= _gray_info.depth)
|
||||||
|
shift -= _gray_info.depth;
|
||||||
|
|
||||||
|
pat = (pat << shift) | (pat >> (_gray_info.depth - shift));
|
||||||
|
}
|
||||||
|
*(--pat_ptr) = pat;
|
||||||
|
src++;
|
||||||
|
test >>= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
addr = address;
|
||||||
|
end = addr + MULU16(_gray_info.depth, _gray_info.plane_size);
|
||||||
|
|
||||||
|
/* set the bits for all 8 pixels in all bytes according to the
|
||||||
|
* precalculated patterns on the pattern stack */
|
||||||
|
test = 1;
|
||||||
|
mask = (~mask & 0xff);
|
||||||
|
if (mask == 0)
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
unsigned data = 0;
|
||||||
|
|
||||||
|
for (i = 7; i >= 0; i--)
|
||||||
|
data = (data << 1) | ((pat_stack[i] & test) ? 1 : 0);
|
||||||
|
|
||||||
|
*addr = data;
|
||||||
|
addr += _gray_info.plane_size;
|
||||||
|
test <<= 1;
|
||||||
|
}
|
||||||
|
while (addr < end);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
unsigned data = 0;
|
||||||
|
|
||||||
|
for (i = 7; i >= 0; i--)
|
||||||
|
data = (data << 1) | ((pat_stack[i] & test) ? 1 : 0);
|
||||||
|
|
||||||
|
*addr = (*addr & mask) | data;
|
||||||
|
addr += _gray_info.plane_size;
|
||||||
|
test <<= 1;
|
||||||
|
}
|
||||||
|
while (addr < end);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Draw a partial greyscale bitmap, canonical format */
|
||||||
|
void gray_ub_gray_bitmap_part(const unsigned char *src, int src_x, int src_y,
|
||||||
|
int stride, int x, int y, int width, int height)
|
||||||
|
{
|
||||||
|
int shift, nx;
|
||||||
|
unsigned char *dst, *dst_end;
|
||||||
|
unsigned mask, mask_right;
|
||||||
|
|
||||||
|
/* nothing to draw? */
|
||||||
|
if ((width <= 0) || (height <= 0) || (x >= _gray_info.width)
|
||||||
|
|| (y >= _gray_info.height) || (x + width <= 0) || (y + height <= 0))
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* clipping */
|
||||||
|
if (x < 0)
|
||||||
|
{
|
||||||
|
width += x;
|
||||||
|
src_x -= x;
|
||||||
|
x = 0;
|
||||||
|
}
|
||||||
|
if (y < 0)
|
||||||
|
{
|
||||||
|
height += y;
|
||||||
|
src_y -= y;
|
||||||
|
y = 0;
|
||||||
|
}
|
||||||
|
if (x + width > _gray_info.width)
|
||||||
|
width = _gray_info.width - x;
|
||||||
|
if (y + height > _gray_info.height)
|
||||||
|
height = _gray_info.height - y;
|
||||||
|
|
||||||
|
shift = x & 7;
|
||||||
|
src += MULU16(stride, src_y) + src_x - shift;
|
||||||
|
dst = _gray_info.plane_data + (x >> 3) + MULU16(_gray_info.bwidth, y);
|
||||||
|
nx = width - 1 + shift;
|
||||||
|
|
||||||
|
mask = 0xFFu >> shift;
|
||||||
|
mask_right = 0xFFu << (~nx & 7);
|
||||||
|
|
||||||
|
dst_end = dst + MULU16(_gray_info.bwidth, height);
|
||||||
|
do
|
||||||
|
{
|
||||||
|
const unsigned char *src_row = src;
|
||||||
|
unsigned char *dst_row = dst;
|
||||||
|
unsigned mask_row = mask;
|
||||||
|
|
||||||
|
for (x = nx; x >= 8; x -= 8)
|
||||||
|
{
|
||||||
|
_writearray(dst_row++, src_row, mask_row);
|
||||||
|
src_row += 8;
|
||||||
|
mask_row = 0xFFu;
|
||||||
|
}
|
||||||
|
_writearray(dst_row, src_row, mask_row & mask_right);
|
||||||
|
|
||||||
|
src += stride;
|
||||||
|
dst += _gray_info.bwidth;
|
||||||
|
}
|
||||||
|
while (dst < dst_end);
|
||||||
|
}
|
||||||
|
#else /* LCD_PIXELFORMAT == VERTICAL_PACKING */
|
||||||
|
|
||||||
/* Write a pixel block, defined by their brightnesses in a greymap.
|
/* Write a pixel block, defined by their brightnesses in a greymap.
|
||||||
Address is the byte in the first bitplane, src is the greymap start address,
|
Address is the byte in the first bitplane, src is the greymap start address,
|
||||||
stride is the increment for the greymap to get to the next pixel, mask
|
stride is the increment for the greymap to get to the next pixel, mask
|
||||||
|
@ -619,17 +1014,17 @@ void gray_ub_clear_display(void)
|
||||||
static void _writearray(unsigned char *address, const unsigned char *src,
|
static void _writearray(unsigned char *address, const unsigned char *src,
|
||||||
int stride, unsigned mask)
|
int stride, unsigned mask)
|
||||||
{
|
{
|
||||||
#if (CONFIG_CPU == SH7034) && (LCD_DEPTH == 1)
|
|
||||||
unsigned long pat_stack[8];
|
unsigned long pat_stack[8];
|
||||||
unsigned long *pat_ptr = &pat_stack[8];
|
unsigned long *pat_ptr = &pat_stack[8];
|
||||||
|
unsigned char *addr, *end;
|
||||||
|
#if CONFIG_CPU == SH7034
|
||||||
const unsigned char *_src;
|
const unsigned char *_src;
|
||||||
unsigned char *addr, *end;
|
|
||||||
unsigned _mask, trash;
|
unsigned _mask, trash;
|
||||||
|
|
||||||
_mask = mask;
|
_mask = mask;
|
||||||
_src = src;
|
_src = src;
|
||||||
|
|
||||||
/* precalculate the bit patterns with random shifts
|
/* precalculate the bit patterns with random shifts
|
||||||
for all 8 pixels and put them on an extra "stack" */
|
for all 8 pixels and put them on an extra "stack" */
|
||||||
asm volatile (
|
asm volatile (
|
||||||
"mov #8,r3 \n" /* loop count in r3: 8 pixels */
|
"mov #8,r3 \n" /* loop count in r3: 8 pixels */
|
||||||
|
@ -784,11 +1179,8 @@ static void _writearray(unsigned char *address, const unsigned char *src,
|
||||||
: /* clobbers */
|
: /* clobbers */
|
||||||
"r0", "r1", "r2", "r3", "r6", "r7", "r8", "r9", "r10"
|
"r0", "r1", "r2", "r3", "r6", "r7", "r8", "r9", "r10"
|
||||||
);
|
);
|
||||||
#elif defined(CPU_COLDFIRE) && (LCD_DEPTH == 2)
|
#elif defined(CPU_COLDFIRE)
|
||||||
unsigned long pat_stack[8];
|
|
||||||
unsigned long *pat_ptr = &pat_stack[8];
|
|
||||||
const unsigned char *_src;
|
const unsigned char *_src;
|
||||||
unsigned char *addr, *end;
|
|
||||||
unsigned _mask, trash;
|
unsigned _mask, trash;
|
||||||
|
|
||||||
_mask = mask;
|
_mask = mask;
|
||||||
|
@ -941,12 +1333,73 @@ static void _writearray(unsigned char *address, const unsigned char *src,
|
||||||
: /* clobbers */
|
: /* clobbers */
|
||||||
"d0", "d1", "d2", "d3", "d4", "d5", "d6", "a0", "a1"
|
"d0", "d1", "d2", "d3", "d4", "d5", "d6", "a0", "a1"
|
||||||
);
|
);
|
||||||
#elif defined(CPU_ARM) && (LCD_DEPTH == 1)
|
#else /* C version, for reference*/
|
||||||
/* TODO: implement for iFP */
|
#warning C version of _writearray() used
|
||||||
(void)address;
|
unsigned test = 1;
|
||||||
(void)src;
|
int i;
|
||||||
(void)stride;
|
|
||||||
(void)mask;
|
/* precalculate the bit patterns with random shifts
|
||||||
|
* for all 8 pixels and put them on an extra "stack" */
|
||||||
|
for (i = 7; i >= 0; i--)
|
||||||
|
{
|
||||||
|
unsigned pat = 0;
|
||||||
|
|
||||||
|
if (mask & test)
|
||||||
|
{
|
||||||
|
int shift;
|
||||||
|
|
||||||
|
pat = _gray_info.bitpattern[_gray_info.idxtable[*src]];
|
||||||
|
|
||||||
|
/* shift pattern pseudo-random, simple & fast PRNG */
|
||||||
|
_gray_random_buffer = 75 * _gray_random_buffer + 74;
|
||||||
|
shift = (_gray_random_buffer >> 8) & _gray_info.randmask;
|
||||||
|
if (shift >= _gray_info.depth)
|
||||||
|
shift -= _gray_info.depth;
|
||||||
|
|
||||||
|
pat = (pat << shift) | (pat >> (_gray_info.depth - shift));
|
||||||
|
}
|
||||||
|
*(--pat_ptr) = pat;
|
||||||
|
src += stride;
|
||||||
|
test <<= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
addr = address;
|
||||||
|
end = addr + MULU16(_gray_info.depth, _gray_info.plane_size);
|
||||||
|
|
||||||
|
/* set the bits for all 8 pixels in all bytes according to the
|
||||||
|
* precalculated patterns on the pattern stack */
|
||||||
|
test = 1;
|
||||||
|
mask = (~mask & 0xff);
|
||||||
|
if (mask == 0)
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
unsigned data = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < 8; i++)
|
||||||
|
data = (data << 1) | ((pat_stack[i] & test) ? 1 : 0);
|
||||||
|
|
||||||
|
*addr = data;
|
||||||
|
addr += _gray_info.plane_size;
|
||||||
|
test <<= 1;
|
||||||
|
}
|
||||||
|
while (addr < end);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
unsigned data = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < 8; i++)
|
||||||
|
data = (data << 1) | ((pat_stack[i] & test) ? 1 : 0);
|
||||||
|
|
||||||
|
*addr = (*addr & mask) | data;
|
||||||
|
addr += _gray_info.plane_size;
|
||||||
|
test <<= 1;
|
||||||
|
}
|
||||||
|
while (addr < end);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -981,16 +1434,16 @@ void gray_ub_gray_bitmap_part(const unsigned char *src, int src_x, int src_y,
|
||||||
if (y + height > _gray_info.height)
|
if (y + height > _gray_info.height)
|
||||||
height = _gray_info.height - y;
|
height = _gray_info.height - y;
|
||||||
|
|
||||||
shift = y & (_PBLOCK-1);
|
shift = y & 7;
|
||||||
src += MULU16(stride, src_y) + src_x - MULU16(stride, shift);
|
src += MULU16(stride, src_y) + src_x - MULU16(stride, shift);
|
||||||
dst = _gray_info.plane_data + x
|
dst = _gray_info.plane_data + x
|
||||||
+ MULU16(_gray_info.width, y >> _PBLOCK_EXP);
|
+ MULU16(_gray_info.width, y >> 3);
|
||||||
ny = height - 1 + shift;
|
ny = height - 1 + shift;
|
||||||
|
|
||||||
mask = 0xFFu << shift;
|
mask = 0xFFu << shift;
|
||||||
mask_bottom = 0xFFu >> (~ny & (_PBLOCK-1));
|
mask_bottom = 0xFFu >> (~ny & 7);
|
||||||
|
|
||||||
for (; ny >= _PBLOCK; ny -= _PBLOCK)
|
for (; ny >= 8; ny -= 8)
|
||||||
{
|
{
|
||||||
const unsigned char *src_row = src;
|
const unsigned char *src_row = src;
|
||||||
unsigned char *dst_row = dst;
|
unsigned char *dst_row = dst;
|
||||||
|
@ -1000,7 +1453,7 @@ void gray_ub_gray_bitmap_part(const unsigned char *src, int src_x, int src_y,
|
||||||
_writearray(dst_row++, src_row++, stride, mask);
|
_writearray(dst_row++, src_row++, stride, mask);
|
||||||
while (dst_row < dst_end);
|
while (dst_row < dst_end);
|
||||||
|
|
||||||
src += stride << _PBLOCK_EXP;
|
src += stride << 3;
|
||||||
dst += _gray_info.width;
|
dst += _gray_info.width;
|
||||||
mask = 0xFFu;
|
mask = 0xFFu;
|
||||||
}
|
}
|
||||||
|
@ -1010,6 +1463,7 @@ void gray_ub_gray_bitmap_part(const unsigned char *src, int src_x, int src_y,
|
||||||
_writearray(dst++, src++, stride, mask);
|
_writearray(dst++, src++, stride, mask);
|
||||||
while (dst < dst_end);
|
while (dst < dst_end);
|
||||||
}
|
}
|
||||||
|
#endif /* LCD_PIXELFORMAT */
|
||||||
|
|
||||||
#endif /* !SIMULATOR */
|
#endif /* !SIMULATOR */
|
||||||
|
|
||||||
|
@ -1020,6 +1474,4 @@ void gray_ub_gray_bitmap(const unsigned char *src, int x, int y, int width,
|
||||||
gray_ub_gray_bitmap_part(src, 0, 0, width, x, y, width, height);
|
gray_ub_gray_bitmap_part(src, 0, 0, width, x, y, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif /* HAVE_LCD_BITMAP */
|
#endif /* HAVE_LCD_BITMAP */
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
* Parameter handling
|
* Parameter handling
|
||||||
*
|
*
|
||||||
* This is a generic framework to display up to 33 shades of grey
|
* This is a generic framework to display up to 33 shades of grey
|
||||||
* on low-depth bitmap LCDs (Archos b&w, Iriver 4-grey) within plugins.
|
* on low-depth bitmap LCDs (Archos b&w, Iriver 4-grey, iPod 4-grey)
|
||||||
|
* within plugins.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2004-2006 Jens Arnold
|
* Copyright (C) 2004-2006 Jens Arnold
|
||||||
*
|
*
|
||||||
|
@ -29,11 +30,19 @@
|
||||||
#include "gray.h"
|
#include "gray.h"
|
||||||
|
|
||||||
/* Set position of the top left corner of the greyscale overlay
|
/* Set position of the top left corner of the greyscale overlay
|
||||||
Note that by is in pixel-block units (8 pixels) */
|
Note that depending on the target LCD, either x or y gets rounded
|
||||||
void gray_set_position(int x, int by)
|
to the nearest multiple of 8 */
|
||||||
|
void gray_set_position(int x, int y)
|
||||||
{
|
{
|
||||||
|
#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
|
||||||
|
_gray_info.bx = (x + 3) / 8;
|
||||||
|
x = 8 * _gray_info.bx;
|
||||||
|
#else
|
||||||
|
_gray_info.by = (y + 3) / 8;
|
||||||
|
y = 8 * _gray_info.by;
|
||||||
|
#endif
|
||||||
_gray_info.x = x;
|
_gray_info.x = x;
|
||||||
_gray_info.by = by;
|
_gray_info.y = y;
|
||||||
|
|
||||||
if (_gray_info.flags & _GRAY_RUNNING)
|
if (_gray_info.flags & _GRAY_RUNNING)
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
* Scrolling routines
|
* Scrolling routines
|
||||||
*
|
*
|
||||||
* This is a generic framework to display up to 33 shades of grey
|
* This is a generic framework to display up to 33 shades of grey
|
||||||
* on low-depth bitmap LCDs (Archos b&w, Iriver 4-grey) within plugins.
|
* on low-depth bitmap LCDs (Archos b&w, Iriver 4-grey, iPod 4-grey)
|
||||||
|
* within plugins.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2004-2006 Jens Arnold
|
* Copyright (C) 2004-2006 Jens Arnold
|
||||||
*
|
*
|
||||||
|
@ -30,6 +31,96 @@
|
||||||
|
|
||||||
/*** Scrolling ***/
|
/*** Scrolling ***/
|
||||||
|
|
||||||
|
#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
|
||||||
|
|
||||||
|
/* Scroll left */
|
||||||
|
void gray_scroll_left(int count)
|
||||||
|
{
|
||||||
|
unsigned char *data, *data_end;
|
||||||
|
int length, blank;
|
||||||
|
|
||||||
|
if ((unsigned)count >= (unsigned)_gray_info.width)
|
||||||
|
return;
|
||||||
|
|
||||||
|
data = _gray_info.cur_buffer;
|
||||||
|
data_end = data + MULU16(_gray_info.width, _gray_info.height);
|
||||||
|
length = _gray_info.width - count;
|
||||||
|
blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ?
|
||||||
|
_gray_info.fg_index : _gray_info.bg_index;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
_gray_rb->memmove(data, data + count, length);
|
||||||
|
_gray_rb->memset(data + length, blank, count);
|
||||||
|
data += _gray_info.width;
|
||||||
|
}
|
||||||
|
while (data < data_end);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Scroll right */
|
||||||
|
void gray_scroll_right(int count)
|
||||||
|
{
|
||||||
|
unsigned char *data, *data_end;
|
||||||
|
int length, blank;
|
||||||
|
|
||||||
|
if ((unsigned)count >= (unsigned)_gray_info.width)
|
||||||
|
return;
|
||||||
|
|
||||||
|
data = _gray_info.cur_buffer;
|
||||||
|
data_end = data + MULU16(_gray_info.width, _gray_info.height);
|
||||||
|
length = _gray_info.width - count;
|
||||||
|
blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ?
|
||||||
|
_gray_info.fg_index : _gray_info.bg_index;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
_gray_rb->memmove(data + count, data, length);
|
||||||
|
_gray_rb->memset(data, blank, count);
|
||||||
|
data += _gray_info.width;
|
||||||
|
}
|
||||||
|
while (data < data_end);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Scroll up */
|
||||||
|
void gray_scroll_up(int count)
|
||||||
|
{
|
||||||
|
long shift, length;
|
||||||
|
int blank;
|
||||||
|
|
||||||
|
if ((unsigned)count >= (unsigned)_gray_info.height)
|
||||||
|
return;
|
||||||
|
|
||||||
|
shift = MULU16(_gray_info.width, count);
|
||||||
|
length = MULU16(_gray_info.width, _gray_info.height - count);
|
||||||
|
blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ?
|
||||||
|
_gray_info.fg_index : _gray_info.bg_index;
|
||||||
|
|
||||||
|
_gray_rb->memmove(_gray_info.cur_buffer, _gray_info.cur_buffer + shift,
|
||||||
|
length);
|
||||||
|
_gray_rb->memset(_gray_info.cur_buffer + length, blank, shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Scroll down */
|
||||||
|
void gray_scroll_down(int count)
|
||||||
|
{
|
||||||
|
long shift, length;
|
||||||
|
int blank;
|
||||||
|
|
||||||
|
if ((unsigned)count >= (unsigned)_gray_info.height)
|
||||||
|
return;
|
||||||
|
|
||||||
|
shift = MULU16(_gray_info.width, count);
|
||||||
|
length = MULU16(_gray_info.width, _gray_info.height - count);
|
||||||
|
blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ?
|
||||||
|
_gray_info.fg_index : _gray_info.bg_index;
|
||||||
|
|
||||||
|
_gray_rb->memmove(_gray_info.cur_buffer + shift, _gray_info.cur_buffer,
|
||||||
|
length);
|
||||||
|
_gray_rb->memset(_gray_info.cur_buffer, blank, shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else /* LCD_PIXELFORMAT == VERTICAL_PACKING */
|
||||||
|
|
||||||
/* Scroll left */
|
/* Scroll left */
|
||||||
void gray_scroll_left(int count)
|
void gray_scroll_left(int count)
|
||||||
{
|
{
|
||||||
|
@ -44,7 +135,8 @@ void gray_scroll_left(int count)
|
||||||
blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ?
|
blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ?
|
||||||
_gray_info.fg_index : _gray_info.bg_index;
|
_gray_info.fg_index : _gray_info.bg_index;
|
||||||
|
|
||||||
_gray_rb->memmove(_gray_info.cur_buffer, _gray_info.cur_buffer + shift, length);
|
_gray_rb->memmove(_gray_info.cur_buffer, _gray_info.cur_buffer + shift,
|
||||||
|
length);
|
||||||
_gray_rb->memset(_gray_info.cur_buffer + length, blank, shift);
|
_gray_rb->memset(_gray_info.cur_buffer + length, blank, shift);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +154,8 @@ void gray_scroll_right(int count)
|
||||||
blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ?
|
blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ?
|
||||||
_gray_info.fg_index : _gray_info.bg_index;
|
_gray_info.fg_index : _gray_info.bg_index;
|
||||||
|
|
||||||
_gray_rb->memmove(_gray_info.cur_buffer + shift, _gray_info.cur_buffer, length);
|
_gray_rb->memmove(_gray_info.cur_buffer + shift, _gray_info.cur_buffer,
|
||||||
|
length);
|
||||||
_gray_rb->memset(_gray_info.cur_buffer, blank, shift);
|
_gray_rb->memset(_gray_info.cur_buffer, blank, shift);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,6 +206,7 @@ void gray_scroll_down(int count)
|
||||||
}
|
}
|
||||||
while (data < data_end);
|
while (data < data_end);
|
||||||
}
|
}
|
||||||
|
#endif /* LCD_PIXELFORMAT */
|
||||||
|
|
||||||
/*** Unbuffered scrolling functions ***/
|
/*** Unbuffered scrolling functions ***/
|
||||||
|
|
||||||
|
@ -148,6 +242,260 @@ void gray_ub_scroll_down(int count)
|
||||||
|
|
||||||
#else /* !SIMULATOR */
|
#else /* !SIMULATOR */
|
||||||
|
|
||||||
|
#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
|
||||||
|
|
||||||
|
/* Scroll left */
|
||||||
|
void gray_ub_scroll_left(int count)
|
||||||
|
{
|
||||||
|
int shift, length;
|
||||||
|
unsigned char *ptr, *ptr_end;
|
||||||
|
|
||||||
|
if ((unsigned) count >= (unsigned) _gray_info.width)
|
||||||
|
return;
|
||||||
|
|
||||||
|
shift = count >> 3;
|
||||||
|
count &= 7;
|
||||||
|
|
||||||
|
if (shift)
|
||||||
|
{
|
||||||
|
length = _gray_info.bwidth - shift;
|
||||||
|
ptr = _gray_info.plane_data;
|
||||||
|
ptr_end = ptr + _gray_info.plane_size;
|
||||||
|
|
||||||
|
/* Scroll row by row to minimize flicker */
|
||||||
|
do
|
||||||
|
{
|
||||||
|
unsigned char *ptr_row = ptr;
|
||||||
|
unsigned char *row_end = ptr_row
|
||||||
|
+ MULU16(_gray_info.plane_size, _gray_info.depth);
|
||||||
|
do
|
||||||
|
{
|
||||||
|
_gray_rb->memmove(ptr_row, ptr_row + shift, length);
|
||||||
|
_gray_rb->memset(ptr_row + length, 0, shift);
|
||||||
|
ptr_row += _gray_info.plane_size;
|
||||||
|
}
|
||||||
|
while (ptr_row < row_end);
|
||||||
|
|
||||||
|
ptr += _gray_info.bwidth;
|
||||||
|
}
|
||||||
|
while (ptr < ptr_end);
|
||||||
|
}
|
||||||
|
if (count)
|
||||||
|
{
|
||||||
|
asm (
|
||||||
|
"mov r4, %[high] \n"
|
||||||
|
|
||||||
|
".sl_rloop: \n"
|
||||||
|
"mov r5, %[addr] \n"
|
||||||
|
"mov r2, %[dpth] \n"
|
||||||
|
|
||||||
|
".sl_oloop: \n"
|
||||||
|
"mov r6, r5 \n"
|
||||||
|
"mov r3, %[cols] \n"
|
||||||
|
"mov r1, #0 \n"
|
||||||
|
|
||||||
|
".sl_iloop: \n"
|
||||||
|
"mov r1, r1, lsr #8 \n"
|
||||||
|
"ldrb r0, [r6, #-1]! \n"
|
||||||
|
"orr r1, r1, r0, lsl %[cnt] \n"
|
||||||
|
"strb r1, [r6] \n"
|
||||||
|
|
||||||
|
"subs r3, r3, #1 \n"
|
||||||
|
"bne .sl_iloop \n"
|
||||||
|
|
||||||
|
"add r5, r5, %[psiz] \n"
|
||||||
|
"subs r2, r2, #1 \n"
|
||||||
|
"bne .sl_oloop \n"
|
||||||
|
|
||||||
|
"add %[addr],%[addr],%[bwid] \n"
|
||||||
|
"subs r4, r4, #1 \n"
|
||||||
|
"bne .sl_rloop \n"
|
||||||
|
: /* outputs */
|
||||||
|
: /* inputs */
|
||||||
|
[dpth]"r"(_gray_info.depth),
|
||||||
|
[high]"r"(_gray_info.height),
|
||||||
|
[bwid]"r"(_gray_info.bwidth),
|
||||||
|
[cols]"r"(_gray_info.bwidth - shift),
|
||||||
|
[psiz]"r"(_gray_info.plane_size),
|
||||||
|
[addr]"r"(_gray_info.plane_data + _gray_info.bwidth - shift),
|
||||||
|
[cnt] "r"(count)
|
||||||
|
: /* clobbers */
|
||||||
|
"r0", "r1", "r2", "r3", "r4", "r5", "r6"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Scroll right */
|
||||||
|
void gray_ub_scroll_right(int count)
|
||||||
|
{
|
||||||
|
int shift, length;
|
||||||
|
unsigned char *ptr, *ptr_end;
|
||||||
|
|
||||||
|
if ((unsigned) count >= (unsigned) _gray_info.width)
|
||||||
|
return;
|
||||||
|
|
||||||
|
shift = count >> 3;
|
||||||
|
count &= 7;
|
||||||
|
|
||||||
|
if (shift)
|
||||||
|
{
|
||||||
|
length = _gray_info.bwidth - shift;
|
||||||
|
ptr = _gray_info.plane_data;
|
||||||
|
ptr_end = ptr + _gray_info.plane_size;
|
||||||
|
|
||||||
|
/* Scroll row by row to minimize flicker */
|
||||||
|
do
|
||||||
|
{
|
||||||
|
unsigned char *ptr_row = ptr;
|
||||||
|
unsigned char *row_end = ptr_row
|
||||||
|
+ MULU16(_gray_info.plane_size, _gray_info.depth);
|
||||||
|
do
|
||||||
|
{
|
||||||
|
_gray_rb->memmove(ptr_row + shift, ptr_row, length);
|
||||||
|
_gray_rb->memset(ptr_row, 0, shift);
|
||||||
|
ptr_row += _gray_info.plane_size;
|
||||||
|
}
|
||||||
|
while (ptr_row < row_end);
|
||||||
|
|
||||||
|
ptr += _gray_info.bwidth;
|
||||||
|
}
|
||||||
|
while (ptr < ptr_end);
|
||||||
|
}
|
||||||
|
if (count)
|
||||||
|
{
|
||||||
|
asm (
|
||||||
|
"mov r4, %[high] \n"
|
||||||
|
|
||||||
|
".sr_rloop: \n"
|
||||||
|
"mov r5, %[addr] \n"
|
||||||
|
"mov r2, %[dpth] \n"
|
||||||
|
|
||||||
|
".sr_oloop: \n"
|
||||||
|
"mov r6, r5 \n"
|
||||||
|
"mov r3, %[cols] \n"
|
||||||
|
"mov r1, #0 \n"
|
||||||
|
|
||||||
|
".sr_iloop: \n"
|
||||||
|
"ldrb r0, [r6] \n"
|
||||||
|
"orr r1, r0, r1, lsl #8 \n"
|
||||||
|
"mov r0, r1, lsr %[cnt] \n"
|
||||||
|
"strb r0, [r6], #1 \n"
|
||||||
|
|
||||||
|
"subs r3, r3, #1 \n"
|
||||||
|
"bne .sr_iloop \n"
|
||||||
|
|
||||||
|
"add r5, r5, %[psiz] \n"
|
||||||
|
"subs r2, r2, #1 \n"
|
||||||
|
"bne .sr_oloop \n"
|
||||||
|
|
||||||
|
"add %[addr],%[addr],%[bwid] \n"
|
||||||
|
"subs r4, r4, #1 \n"
|
||||||
|
"bne .sr_rloop \n"
|
||||||
|
: /* outputs */
|
||||||
|
: /* inputs */
|
||||||
|
[dpth]"r"(_gray_info.depth),
|
||||||
|
[high]"r"(_gray_info.height),
|
||||||
|
[bwid]"r"(_gray_info.bwidth),
|
||||||
|
[cols]"r"(_gray_info.bwidth - shift),
|
||||||
|
[psiz]"r"(_gray_info.plane_size),
|
||||||
|
[addr]"r"(_gray_info.plane_data + shift),
|
||||||
|
[cnt] "r"(count)
|
||||||
|
: /* clobbers */
|
||||||
|
"r0", "r1", "r2", "r3", "r4", "r5", "r6"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Scroll up */
|
||||||
|
void gray_ub_scroll_up(int count)
|
||||||
|
{
|
||||||
|
long blockshift;
|
||||||
|
unsigned char *ptr, *ptr_end1, *ptr_end2;
|
||||||
|
|
||||||
|
if ((unsigned) count >= (unsigned) _gray_info.height)
|
||||||
|
return;
|
||||||
|
|
||||||
|
blockshift = MULU16(_gray_info.bwidth, count);
|
||||||
|
ptr = _gray_info.plane_data;
|
||||||
|
ptr_end2 = ptr + _gray_info.plane_size;
|
||||||
|
ptr_end1 = ptr_end2 - blockshift;
|
||||||
|
/* Scroll row by row to minimize flicker */
|
||||||
|
do
|
||||||
|
{
|
||||||
|
unsigned char *ptr_row = ptr;
|
||||||
|
unsigned char *row_end = ptr_row
|
||||||
|
+ MULU16(_gray_info.plane_size, _gray_info.depth);
|
||||||
|
if (ptr < ptr_end1)
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
_gray_rb->memcpy(ptr_row, ptr_row + blockshift,
|
||||||
|
_gray_info.bwidth);
|
||||||
|
ptr_row += _gray_info.plane_size;
|
||||||
|
}
|
||||||
|
while (ptr_row < row_end);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
_gray_rb->memset(ptr_row, 0, _gray_info.bwidth);
|
||||||
|
ptr_row += _gray_info.plane_size;
|
||||||
|
}
|
||||||
|
while (ptr_row < row_end);
|
||||||
|
}
|
||||||
|
|
||||||
|
ptr += _gray_info.bwidth;
|
||||||
|
}
|
||||||
|
while (ptr < ptr_end2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Scroll down */
|
||||||
|
void gray_ub_scroll_down(int count)
|
||||||
|
{
|
||||||
|
long blockshift;
|
||||||
|
unsigned char *ptr, *ptr_end1, *ptr_end2;
|
||||||
|
|
||||||
|
if ((unsigned) count >= (unsigned) _gray_info.height)
|
||||||
|
return;
|
||||||
|
|
||||||
|
blockshift = MULU16(_gray_info.bwidth, count);
|
||||||
|
ptr_end2 = _gray_info.plane_data;
|
||||||
|
ptr_end1 = ptr_end2 + blockshift;
|
||||||
|
ptr = ptr_end2 + _gray_info.plane_size;
|
||||||
|
/* Scroll row by row to minimize flicker */
|
||||||
|
do
|
||||||
|
{
|
||||||
|
unsigned char *ptr_row, *row_end;
|
||||||
|
|
||||||
|
ptr -= _gray_info.bwidth;
|
||||||
|
ptr_row = ptr;
|
||||||
|
row_end = ptr_row + MULU16(_gray_info.plane_size, _gray_info.depth);
|
||||||
|
|
||||||
|
if (ptr >= ptr_end1)
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
_gray_rb->memcpy(ptr_row, ptr_row - blockshift,
|
||||||
|
_gray_info.bwidth);
|
||||||
|
ptr_row += _gray_info.plane_size;
|
||||||
|
}
|
||||||
|
while (ptr_row < row_end);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
_gray_rb->memset(ptr_row, 0, _gray_info.bwidth);
|
||||||
|
ptr_row += _gray_info.plane_size;
|
||||||
|
}
|
||||||
|
while (ptr_row < row_end);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (ptr > ptr_end2);
|
||||||
|
}
|
||||||
|
#else /* LCD_PIXELFORMAT == VERTICAL_PACKING */
|
||||||
|
|
||||||
/* Scroll left */
|
/* Scroll left */
|
||||||
void gray_ub_scroll_left(int count)
|
void gray_ub_scroll_left(int count)
|
||||||
{
|
{
|
||||||
|
@ -156,17 +504,17 @@ void gray_ub_scroll_left(int count)
|
||||||
|
|
||||||
if ((unsigned) count >= (unsigned) _gray_info.width)
|
if ((unsigned) count >= (unsigned) _gray_info.width)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
length = _gray_info.width - count;
|
length = _gray_info.width - count;
|
||||||
ptr = _gray_info.plane_data;
|
ptr = _gray_info.plane_data;
|
||||||
ptr_end = ptr + _gray_info.plane_size;
|
ptr_end = ptr + _gray_info.plane_size;
|
||||||
|
|
||||||
/* Scroll row by row to minimize flicker (pixel block rows) */
|
/* Scroll row by row to minimize flicker (pixel block rows) */
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
unsigned char *ptr_row = ptr;
|
unsigned char *ptr_row = ptr;
|
||||||
unsigned char *row_end = ptr_row
|
unsigned char *row_end = ptr_row
|
||||||
+ MULU16(_gray_info.plane_size, _gray_info.depth);
|
+ MULU16(_gray_info.plane_size, _gray_info.depth);
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
_gray_rb->memmove(ptr_row, ptr_row + count, length);
|
_gray_rb->memmove(ptr_row, ptr_row + count, length);
|
||||||
|
@ -188,17 +536,17 @@ void gray_ub_scroll_right(int count)
|
||||||
|
|
||||||
if ((unsigned) count >= (unsigned) _gray_info.width)
|
if ((unsigned) count >= (unsigned) _gray_info.width)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
length = _gray_info.width - count;
|
length = _gray_info.width - count;
|
||||||
ptr = _gray_info.plane_data;
|
ptr = _gray_info.plane_data;
|
||||||
ptr_end = ptr + _gray_info.plane_size;
|
ptr_end = ptr + _gray_info.plane_size;
|
||||||
|
|
||||||
/* Scroll row by row to minimize flicker (pixel block rows) */
|
/* Scroll row by row to minimize flicker (pixel block rows) */
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
unsigned char *ptr_row = ptr;
|
unsigned char *ptr_row = ptr;
|
||||||
unsigned char *row_end = ptr_row
|
unsigned char *row_end = ptr_row
|
||||||
+ MULU16(_gray_info.plane_size, _gray_info.depth);
|
+ MULU16(_gray_info.plane_size, _gray_info.depth);
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
_gray_rb->memmove(ptr_row + count, ptr_row, length);
|
_gray_rb->memmove(ptr_row + count, ptr_row, length);
|
||||||
|
@ -221,10 +569,10 @@ void gray_ub_scroll_up(int count)
|
||||||
|
|
||||||
if ((unsigned) count >= (unsigned) _gray_info.height)
|
if ((unsigned) count >= (unsigned) _gray_info.height)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
shift = count >> _PBLOCK_EXP;
|
shift = count >> 3;
|
||||||
count &= (_PBLOCK-1);
|
count &= 7;
|
||||||
|
|
||||||
if (shift)
|
if (shift)
|
||||||
{
|
{
|
||||||
blockshift = MULU16(_gray_info.width, shift);
|
blockshift = MULU16(_gray_info.width, shift);
|
||||||
|
@ -235,7 +583,7 @@ void gray_ub_scroll_up(int count)
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
unsigned char *ptr_row = ptr;
|
unsigned char *ptr_row = ptr;
|
||||||
unsigned char *row_end = ptr_row
|
unsigned char *row_end = ptr_row
|
||||||
+ MULU16(_gray_info.plane_size, _gray_info.depth);
|
+ MULU16(_gray_info.plane_size, _gray_info.depth);
|
||||||
if (ptr < ptr_end1)
|
if (ptr < ptr_end1)
|
||||||
{
|
{
|
||||||
|
@ -263,7 +611,7 @@ void gray_ub_scroll_up(int count)
|
||||||
}
|
}
|
||||||
if (count)
|
if (count)
|
||||||
{
|
{
|
||||||
#if (CONFIG_CPU == SH7034) && (LCD_DEPTH == 1)
|
#if CONFIG_CPU == SH7034
|
||||||
/* scroll column by column to minimize flicker */
|
/* scroll column by column to minimize flicker */
|
||||||
asm (
|
asm (
|
||||||
"mov #0,r6 \n" /* x = 0 */
|
"mov #0,r6 \n" /* x = 0 */
|
||||||
|
@ -345,7 +693,7 @@ void gray_ub_scroll_up(int count)
|
||||||
: /* clobbers */
|
: /* clobbers */
|
||||||
"r0", "r1", "r2", "r3", "r4", "r5", "r6"
|
"r0", "r1", "r2", "r3", "r4", "r5", "r6"
|
||||||
);
|
);
|
||||||
#elif defined(CPU_COLDFIRE) && (LCD_DEPTH == 2)
|
#elif defined(CPU_COLDFIRE)
|
||||||
/* scroll column by column to minimize flicker */
|
/* scroll column by column to minimize flicker */
|
||||||
asm (
|
asm (
|
||||||
"move.l %[wide],%%d4\n" /* columns = width */
|
"move.l %[wide],%%d4\n" /* columns = width */
|
||||||
|
@ -406,9 +754,9 @@ void gray_ub_scroll_down(int count)
|
||||||
if ((unsigned) count >= (unsigned) _gray_info.height)
|
if ((unsigned) count >= (unsigned) _gray_info.height)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
shift = count >> _PBLOCK_EXP;
|
shift = count >> 3;
|
||||||
count &= (_PBLOCK-1);
|
count &= 7;
|
||||||
|
|
||||||
if (shift)
|
if (shift)
|
||||||
{
|
{
|
||||||
blockshift = MULU16(_gray_info.width, shift);
|
blockshift = MULU16(_gray_info.width, shift);
|
||||||
|
@ -448,7 +796,7 @@ void gray_ub_scroll_down(int count)
|
||||||
}
|
}
|
||||||
if (count)
|
if (count)
|
||||||
{
|
{
|
||||||
#if (CONFIG_CPU == SH7034) && (LCD_DEPTH == 1)
|
#if CONFIG_CPU == SH7034
|
||||||
/* scroll column by column to minimize flicker */
|
/* scroll column by column to minimize flicker */
|
||||||
asm (
|
asm (
|
||||||
"mov #0,r6 \n" /* x = 0 */
|
"mov #0,r6 \n" /* x = 0 */
|
||||||
|
@ -529,7 +877,7 @@ void gray_ub_scroll_down(int count)
|
||||||
: /* clobbers */
|
: /* clobbers */
|
||||||
"r0", "r1", "r2", "r3", "r4", "r5", "r6"
|
"r0", "r1", "r2", "r3", "r4", "r5", "r6"
|
||||||
);
|
);
|
||||||
#elif defined(CPU_COLDFIRE) && (LCD_DEPTH == 2)
|
#elif defined(CPU_COLDFIRE)
|
||||||
/* scroll column by column to minimize flicker */
|
/* scroll column by column to minimize flicker */
|
||||||
asm (
|
asm (
|
||||||
"move.l %[wide],%%d4\n" /* columns = width */
|
"move.l %[wide],%%d4\n" /* columns = width */
|
||||||
|
@ -576,7 +924,8 @@ void gray_ub_scroll_down(int count)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif /* LCD_PIXELFORMAT */
|
||||||
|
|
||||||
#endif /* !SIMULATOR */
|
#endif /* !SIMULATOR */
|
||||||
|
|
||||||
#endif /* HAVE_LCD_BITMAP */
|
#endif /* HAVE_LCD_BITMAP */
|
||||||
|
|
||||||
|
|
|
@ -487,7 +487,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
||||||
|
|
||||||
/* initialize the grayscale buffer:
|
/* initialize the grayscale buffer:
|
||||||
* 8 bitplanes for 9 shades of gray.*/
|
* 8 bitplanes for 9 shades of gray.*/
|
||||||
grayscales = gray_init(rb, gbuf, gbuf_size, false, LCD_WIDTH, LCD_HEIGHT/8,
|
grayscales = gray_init(rb, gbuf, gbuf_size, false, LCD_WIDTH, LCD_HEIGHT,
|
||||||
8, 0, NULL) + 1;
|
8, 0, NULL) + 1;
|
||||||
if (grayscales != 9) {
|
if (grayscales != 9) {
|
||||||
rb->snprintf(buff, sizeof(buff), "%d", grayscales);
|
rb->snprintf(buff, sizeof(buff), "%d", grayscales);
|
||||||
|
|
|
@ -243,7 +243,7 @@ int main(void)
|
||||||
/* get the remainder of the plugin buffer */
|
/* get the remainder of the plugin buffer */
|
||||||
gbuf = (unsigned char *) rb->plugin_get_buffer(&gbuf_size);
|
gbuf = (unsigned char *) rb->plugin_get_buffer(&gbuf_size);
|
||||||
|
|
||||||
gray_init(rb, gbuf, gbuf_size, false, LCD_WIDTH, LCD_HEIGHT/8, 32, 2<<8, NULL);
|
gray_init(rb, gbuf, gbuf_size, false, LCD_WIDTH, LCD_HEIGHT, 32, 2<<8, NULL);
|
||||||
/* switch on grayscale overlay */
|
/* switch on grayscale overlay */
|
||||||
gray_show(true);
|
gray_show(true);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -87,7 +87,8 @@ drivers/lcd-h100-remote.c
|
||||||
drivers/lcd-remote-2bit-vi.c
|
drivers/lcd-remote-2bit-vi.c
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if CONFIG_LCD==LCD_IPODNANO || CONFIG_LCD==LCD_IPODCOLOR || CONFIG_LCD == LCD_IPOD2BPP
|
#if CONFIG_LCD==LCD_IPODNANO || CONFIG_LCD==LCD_IPODCOLOR \
|
||||||
|
|| CONFIG_LCD == LCD_IPOD2BPP || CONFIG_LCD == LCD_IPODMINI
|
||||||
drivers/lcd-ipod.c
|
drivers/lcd-ipod.c
|
||||||
#endif
|
#endif
|
||||||
#if CONFIG_LCD==LCD_IPODVIDEO
|
#if CONFIG_LCD==LCD_IPODVIDEO
|
||||||
|
|
|
@ -36,7 +36,7 @@ static inline bool timer_check(int clock_start, int usecs)
|
||||||
return ((int)(USEC_TIMER - clock_start)) >= usecs;
|
return ((int)(USEC_TIMER - clock_start)) >= usecs;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (CONFIG_LCD == LCD_IPOD2BPP)
|
#if (CONFIG_LCD == LCD_IPOD2BPP) || (CONFIG_LCD == LCD_IPODMINI)
|
||||||
|
|
||||||
/*** hardware configuration ***/
|
/*** hardware configuration ***/
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@
|
||||||
/* Define this to the CPU frequency */
|
/* Define this to the CPU frequency */
|
||||||
#define CPU_FREQ 11289600
|
#define CPU_FREQ 11289600
|
||||||
|
|
||||||
#define CONFIG_LCD LCD_IPOD2BPP
|
#define CONFIG_LCD LCD_IPODMINI
|
||||||
|
|
||||||
/* Offset ( in the firmware file's header ) to the file length */
|
/* Offset ( in the firmware file's header ) to the file length */
|
||||||
#define FIRMWARE_OFFSET_FILE_LENGTH 0
|
#define FIRMWARE_OFFSET_FILE_LENGTH 0
|
||||||
|
|
|
@ -85,7 +85,7 @@
|
||||||
/* Define this to the CPU frequency */
|
/* Define this to the CPU frequency */
|
||||||
#define CPU_FREQ 11289600
|
#define CPU_FREQ 11289600
|
||||||
|
|
||||||
#define CONFIG_LCD LCD_IPOD2BPP
|
#define CONFIG_LCD LCD_IPODMINI
|
||||||
|
|
||||||
/* Offset ( in the firmware file's header ) to the file length */
|
/* Offset ( in the firmware file's header ) to the file length */
|
||||||
#define FIRMWARE_OFFSET_FILE_LENGTH 0
|
#define FIRMWARE_OFFSET_FILE_LENGTH 0
|
||||||
|
|
|
@ -89,9 +89,10 @@
|
||||||
#define LCD_IPODCOLOR 6 /* as used by iPod Color/Photo */
|
#define LCD_IPODCOLOR 6 /* as used by iPod Color/Photo */
|
||||||
#define LCD_IPODNANO 7 /* as used by iPod Nano */
|
#define LCD_IPODNANO 7 /* as used by iPod Nano */
|
||||||
#define LCD_IPODVIDEO 8 /* as used by iPod Video */
|
#define LCD_IPODVIDEO 8 /* as used by iPod Video */
|
||||||
#define LCD_IPOD2BPP 9 /* as used by all greyscale iPods */
|
#define LCD_IPOD2BPP 9 /* as used by all fullsize greyscale iPods */
|
||||||
#define LCD_IFP7XX 10 /* as used by iRiver iFP 7xx/8xx */
|
#define LCD_IPODMINI 10 /* as used by iPod Mini g1/g2 */
|
||||||
#define LCD_GIGABEAT 11
|
#define LCD_IFP7XX 11 /* as used by iRiver iFP 7xx/8xx */
|
||||||
|
#define LCD_GIGABEAT 12
|
||||||
|
|
||||||
/* LCD_PIXELFORMAT */
|
/* LCD_PIXELFORMAT */
|
||||||
#define HORIZONTAL_PACKING 1
|
#define HORIZONTAL_PACKING 1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue