1
0
Fork 0
forked from len0rd/rockbox

Const policed the grayscale lib & plugin

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4985 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jens Arnold 2004-08-03 20:57:06 +00:00
parent 0830339e2f
commit 85890b88df
9 changed files with 27 additions and 25 deletions

View file

@ -42,7 +42,7 @@ int main(void)
int button, scroll_amount; int button, scroll_amount;
bool black_border; bool black_border;
static unsigned char rockbox[] = { static const unsigned char rockbox[] = {
/* ........................................... /* ...........................................
* .####...###...###..#...#.####...###..#...#. * .####...###...###..#...#.####...###..#...#.
* .#...#.#...#.#...#.#..#..#...#.#...#..#.#.. * .#...#.#...#.#...#.#..#..#...#.#...#..#.#..
@ -59,7 +59,7 @@ int main(void)
0x14, 0x22, 0x00 0x14, 0x22, 0x00
}; };
static unsigned char showing[] = { static const unsigned char showing[] = {
/* ....................................... /* .......................................
* ..####.#...#..###..#...#.#.#...#..####. * ..####.#...#..###..#...#.#.#...#..####.
* .#.....#...#.#...#.#...#.#.##..#.#..... * .#.....#...#.#...#.#...#.#.##..#.#.....
@ -75,7 +75,7 @@ int main(void)
0x10, 0x3E, 0x00, 0x1C, 0x22, 0x22, 0x2A, 0x3A, 0x00 0x10, 0x3E, 0x00, 0x1C, 0x22, 0x22, 0x2A, 0x3A, 0x00
}; };
static unsigned char grayscale_gray[] = { static const unsigned char grayscale_gray[] = {
/* ....................................................... /* .......................................................
* ..####.####...###..#...#..####..###...###..#.....#####. * ..####.####...###..#...#..####..###...###..#.....#####.
* .#.....#...#.#...#.#...#.#.....#...#.#...#.#.....#..... * .#.....#...#.#...#.#...#.#.....#...#.#...#.#.....#.....

View file

@ -362,7 +362,7 @@ void gray_fillrect(int x, int y, int nx, int ny);
This is the only drawing function NOT using the drawinfo. This is the only drawing function NOT using the drawinfo.
*/ */
void gray_drawgraymap(unsigned char *src, int x, int y, int nx, int ny, void gray_drawgraymap(const unsigned char *src, int x, int y, int nx, int ny,
int stride); int stride);
/*--------------------------------------------------------------------------- /*---------------------------------------------------------------------------
@ -384,7 +384,7 @@ void gray_drawgraymap(unsigned char *src, int x, int y, int nx, int ny,
The <stride> parameter is useful if you want to show only a part of a The <stride> parameter is useful if you want to show only a part of a
bitmap. It should always be set to the "row length" of the bitmap. bitmap. It should always be set to the "row length" of the bitmap.
*/ */
void gray_drawbitmap(unsigned char *src, int x, int y, int nx, int ny, void gray_drawbitmap(const unsigned char *src, int x, int y, int nx, int ny,
int stride); int stride);
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@ -409,14 +409,14 @@ void gray_setfont(int newfont);
This works exactly the same way as the core lcd_getstringsize(), only that This works exactly the same way as the core lcd_getstringsize(), only that
it uses the selected font for grayscale. it uses the selected font for grayscale.
*/ */
int gray_getstringsize(unsigned char *str, int *w, int *h); int gray_getstringsize(const unsigned char *str, int *w, int *h);
/*--------------------------------------------------------------------------- /*---------------------------------------------------------------------------
Display text starting at (x, y) with the current font and drawinfo Display text starting at (x, y) with the current font and drawinfo
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
The drawmode is used as described for gray_set_drawmode() The drawmode is used as described for gray_set_drawmode()
*/ */
void gray_putsxy(int x, int y, unsigned char *str); void gray_putsxy(int x, int y, const unsigned char *str);
/*=========================================================================== /*===========================================================================
Private functions and definitions, for use within the grayscale core only Private functions and definitions, for use within the grayscale core only
@ -458,8 +458,8 @@ extern _tGraybuf *_graybuf;
extern short _gray_random_buffer; extern short _gray_random_buffer;
/* Global function pointers */ /* Global function pointers */
extern void (*_gray_pixelfuncs[4])(int x, int y, unsigned long pattern); extern void (* const _gray_pixelfuncs[4])(int x, int y, unsigned long pattern);
extern void (*_gray_blockfuncs[4])(unsigned char *address, unsigned mask, extern void (* const _gray_blockfuncs[4])(unsigned char *address, unsigned mask,
unsigned bits); unsigned bits);
#endif /* HAVE_LCD_BITMAP */ #endif /* HAVE_LCD_BITMAP */

View file

@ -36,7 +36,7 @@ static void _writeblockfg(unsigned char *address, unsigned mask, unsigned bits);
static void _writeblockbg(unsigned char *address, unsigned mask, unsigned bits); static void _writeblockbg(unsigned char *address, unsigned mask, unsigned bits);
/* Block function pointer array */ /* Block function pointer array */
void (*_gray_blockfuncs[4])(unsigned char *address, unsigned mask, void (* const _gray_blockfuncs[4])(unsigned char *address, unsigned mask,
unsigned bits) = { unsigned bits) = {
_invertblock, _writeblockfg, _writeblockbg, _writeblock _invertblock, _writeblockfg, _writeblockbg, _writeblock
}; };

View file

@ -48,12 +48,13 @@
The <stride> parameter is useful if you want to show only a part of a The <stride> parameter is useful if you want to show only a part of a
bitmap. It should always be set to the "row length" of the bitmap. bitmap. It should always be set to the "row length" of the bitmap.
*/ */
void gray_drawbitmap(unsigned char *src, int x, int y, int nx, int ny, void gray_drawbitmap(const unsigned char *src, int x, int y, int nx, int ny,
int stride) int stride)
{ {
int shift; int shift;
unsigned bits, mask_top, mask_bottom; unsigned bits, mask_top, mask_bottom;
unsigned char *src_col, *dst, *dst_col; const unsigned char *src_col;
unsigned char *dst, *dst_col;
void (*blockfunc)(unsigned char *address, unsigned mask, unsigned bits); void (*blockfunc)(unsigned char *address, unsigned mask, unsigned bits);
if ((unsigned) x >= (unsigned) _graybuf->width if ((unsigned) x >= (unsigned) _graybuf->width

View file

@ -30,16 +30,16 @@
#include "gray.h" #include "gray.h"
/* Prototypes */ /* Prototypes */
static void _writearray(unsigned char *address, unsigned char *src, int stride, static void _writearray(unsigned char *address, const unsigned char *src,
unsigned mask); int stride, unsigned mask);
/* Write an 8-pixel block, defined by their brightnesses in a graymap. /* Write an 8-pixel block, defined by their brightnesses in a graymap.
* Address is the byte in the first bitplane, src is the graymap start address, * Address is the byte in the first bitplane, src is the graymap start address,
* stride is the increment for the graymap to get to the next pixel, mask * stride is the increment for the graymap to get to the next pixel, mask
* determines which pixels of the destination block are changed. For "0" bits, * determines which pixels of the destination block are changed. For "0" bits,
* the src address is not incremented! */ * the src address is not incremented! */
static void _writearray(unsigned char *address, unsigned char *src, int stride, static void _writearray(unsigned char *address, const unsigned char *src,
unsigned mask) int stride, unsigned mask)
{ {
unsigned long pat_stack[8]; unsigned long pat_stack[8];
register unsigned char *end_addr; register unsigned char *end_addr;
@ -217,12 +217,13 @@ asm (
This is the only drawing function NOT using the drawinfo. This is the only drawing function NOT using the drawinfo.
*/ */
void gray_drawgraymap(unsigned char *src, int x, int y, int nx, int ny, void gray_drawgraymap(const unsigned char *src, int x, int y, int nx, int ny,
int stride) int stride)
{ {
int shift; int shift;
unsigned mask_top, mask_bottom; unsigned mask_top, mask_bottom;
unsigned char *src_row, *dst, *dst_row; const unsigned char *src_row;
unsigned char *dst, *dst_row;
if ((unsigned) x >= (unsigned) _graybuf->width if ((unsigned) x >= (unsigned) _graybuf->width
|| (unsigned) y >= (unsigned) _graybuf->height) || (unsigned) y >= (unsigned) _graybuf->height)

View file

@ -36,7 +36,7 @@
This works exactly the same way as the core lcd_getstringsize(), only that This works exactly the same way as the core lcd_getstringsize(), only that
it uses the selected font for grayscale. it uses the selected font for grayscale.
*/ */
int gray_getstringsize(unsigned char *str, int *w, int *h) int gray_getstringsize(const unsigned char *str, int *w, int *h)
{ {
int ch; int ch;
int width = 0; int width = 0;

View file

@ -34,7 +34,7 @@ static void _writepixel(int x, int y, unsigned long pattern);
static void _invertpixel(int x, int y, unsigned long pattern); static void _invertpixel(int x, int y, unsigned long pattern);
/* function pointer array */ /* function pointer array */
void (*_gray_pixelfuncs[4])(int x, int y, unsigned long pattern) = { void (* const _gray_pixelfuncs[4])(int x, int y, unsigned long pattern) = {
_invertpixel, _writepixel, _writepixel, _writepixel _invertpixel, _writepixel, _writepixel, _writepixel
}; };

View file

@ -34,7 +34,7 @@
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
The drawmode is used as described for gray_set_drawmode() The drawmode is used as described for gray_set_drawmode()
*/ */
void gray_putsxy(int x, int y, unsigned char *str) void gray_putsxy(int x, int y, const unsigned char *str)
{ {
int ch, width; int ch, width;
bitmap_t *bits; bitmap_t *bits;
@ -56,7 +56,7 @@ void gray_putsxy(int x, int y, unsigned char *str)
bits = pf->bits + (pf->offset ? pf->offset[ch] bits = pf->bits + (pf->offset ? pf->offset[ch]
: MULU16(pf->height, ch)); : MULU16(pf->height, ch));
gray_drawbitmap((unsigned char*) bits, x, y, width, pf->height, gray_drawbitmap((const unsigned char*) bits, x, y, width, pf->height,
width); width);
x += width; x += width;
} }

View file

@ -29,7 +29,7 @@
#ifdef HAVE_LCD_BITMAP /* and also not for the Player */ #ifdef HAVE_LCD_BITMAP /* and also not for the Player */
#include "gray.h" #include "gray.h"
static unsigned char bmpheader[] = static const unsigned char bmpheader[] =
{ {
0x42, 0x4d, 0xba, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xba, 0x00, 0x42, 0x4d, 0xba, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xba, 0x00,
0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x40, 0x00,