2002-09-23 11:17:52 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 by Alan Korr
|
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2002-09-23 11:17:52 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2008-03-09 18:27:12 +00:00
|
|
|
|
2002-09-23 11:17:52 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "lcd.h"
|
|
|
|
#include "kernel.h"
|
|
|
|
#include "thread.h"
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "file.h"
|
|
|
|
#include "debug.h"
|
|
|
|
#include "system.h"
|
|
|
|
#include "font.h"
|
2005-12-06 13:27:15 +00:00
|
|
|
#include "rbunicode.h"
|
2005-08-08 19:23:28 +00:00
|
|
|
#include "bidi.h"
|
2007-07-28 08:12:05 +00:00
|
|
|
#include "scroll_engine.h"
|
2002-10-21 13:14:25 +00:00
|
|
|
|
2008-03-09 18:27:12 +00:00
|
|
|
#ifndef LCDFN /* Not compiling for remote - define macros for main LCD. */
|
|
|
|
#define LCDFN(fn) lcd_ ## fn
|
|
|
|
#define FBFN(fn) fb_ ## fn
|
2012-02-22 10:18:05 +00:00
|
|
|
#define FBSIZE FRAMEBUFFER_SIZE
|
2008-03-09 18:27:12 +00:00
|
|
|
#define LCDM(ma) LCD_ ## ma
|
2008-04-12 07:53:33 +00:00
|
|
|
#define LCDNAME "lcd_"
|
2012-02-22 10:18:05 +00:00
|
|
|
#define LCDFB(x,y) FBADDR(x, y)
|
2008-03-09 18:27:12 +00:00
|
|
|
#define MAIN_LCD
|
|
|
|
#endif
|
|
|
|
|
2020-10-07 06:01:35 +00:00
|
|
|
#ifdef MAIN_LCD
|
|
|
|
#define THIS_STRIDE STRIDE_MAIN
|
|
|
|
#else
|
|
|
|
#define THIS_STRIDE STRIDE_REMOTE
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define CURRENT_VP LCDFN(current_viewport)
|
2005-06-23 16:53:54 +00:00
|
|
|
/*** globals ***/
|
2020-10-07 06:01:35 +00:00
|
|
|
static FBFN(data) LCDFN(static_framebuffer)[LCDM(FBHEIGHT)][LCDM(FBWIDTH)] IRAM_LCDFRAMEBUFFER;
|
|
|
|
|
|
|
|
static void *LCDFN(frameaddress_default)(int x, int y);
|
|
|
|
|
|
|
|
/* shouldn't be changed unless you want system-wide framebuffer changes! */
|
|
|
|
struct frame_buffer_t LCDFN(framebuffer_default) =
|
|
|
|
{
|
|
|
|
.FBFN(ptr) = &LCDFN(static_framebuffer)[0][0],
|
|
|
|
.get_address_fn = &LCDFN(frameaddress_default),
|
|
|
|
.stride = THIS_STRIDE(LCDM(WIDTH), LCDM(HEIGHT)),
|
|
|
|
.elems = (LCDM(FBWIDTH)*LCDM(FBHEIGHT)),
|
|
|
|
};
|
2003-01-23 14:24:52 +00:00
|
|
|
|
2008-01-07 20:34:11 +00:00
|
|
|
static struct viewport default_vp =
|
|
|
|
{
|
|
|
|
.x = 0,
|
|
|
|
.y = 0,
|
2008-03-09 18:27:12 +00:00
|
|
|
.width = LCDM(WIDTH),
|
|
|
|
.height = LCDM(HEIGHT),
|
2022-04-17 14:36:33 +00:00
|
|
|
.flags = 0,
|
2008-01-07 20:34:11 +00:00
|
|
|
.font = FONT_SYSFIXED,
|
|
|
|
.drawmode = DRMODE_SOLID,
|
2021-03-24 18:44:35 +00:00
|
|
|
.buffer = NULL,
|
2008-01-07 20:34:11 +00:00
|
|
|
};
|
|
|
|
|
2021-03-24 18:44:35 +00:00
|
|
|
struct viewport* CURRENT_VP;
|
2020-10-07 06:01:35 +00:00
|
|
|
|
|
|
|
static void *LCDFN(frameaddress_default)(int x, int y)
|
|
|
|
{
|
|
|
|
/* the default expects a buffer the same size as the screen */
|
|
|
|
struct frame_buffer_t *fb = CURRENT_VP->buffer;
|
2022-09-30 09:49:39 +00:00
|
|
|
#if defined(MAIN_LCD) && LCD_STRIDEFORMAT == VERTICAL_STRIDE
|
2020-10-07 06:01:35 +00:00
|
|
|
size_t element = (x * LCDM(NATIVE_STRIDE)(fb->stride)) + y;
|
|
|
|
#else
|
|
|
|
size_t element = (y * LCDM(NATIVE_STRIDE)(fb->stride)) + x;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return fb->FBFN(ptr) + element;/*(element % fb->elems);*/
|
|
|
|
}
|
2008-01-07 20:34:11 +00:00
|
|
|
|
2022-09-26 07:37:00 +00:00
|
|
|
#include "lcd-bitmap-common.c"
|
|
|
|
|
2005-06-23 16:53:54 +00:00
|
|
|
/* LCD init */
|
2008-03-09 18:27:12 +00:00
|
|
|
void LCDFN(init)(void)
|
2002-09-23 11:17:52 +00:00
|
|
|
{
|
2021-03-24 18:44:35 +00:00
|
|
|
|
2020-10-07 06:01:35 +00:00
|
|
|
/* Initialize the viewport */
|
|
|
|
LCDFN(set_viewport)(NULL);
|
2008-03-09 18:27:12 +00:00
|
|
|
LCDFN(clear_display)();
|
|
|
|
LCDFN(init_device)();
|
|
|
|
#ifdef MAIN_LCD
|
2007-07-28 08:12:05 +00:00
|
|
|
scroll_init();
|
2008-03-09 18:27:12 +00:00
|
|
|
#endif
|
2020-10-07 06:01:35 +00:00
|
|
|
|
2002-09-23 11:17:52 +00:00
|
|
|
}
|
|
|
|
|
2005-06-24 22:33:21 +00:00
|
|
|
/*** low-level drawing functions ***/
|
2005-06-23 16:53:54 +00:00
|
|
|
|
2005-06-24 22:33:21 +00:00
|
|
|
static void setpixel(int x, int y)
|
2003-04-16 00:12:31 +00:00
|
|
|
{
|
2012-02-22 10:18:05 +00:00
|
|
|
*LCDFB(x,y>>3) |= BIT_N(y & 7);
|
2003-04-16 00:12:31 +00:00
|
|
|
}
|
|
|
|
|
2005-06-24 22:33:21 +00:00
|
|
|
static void clearpixel(int x, int y)
|
2002-09-23 11:17:52 +00:00
|
|
|
{
|
2012-02-22 10:18:05 +00:00
|
|
|
*LCDFB(x,y>>3) &= ~BIT_N(y & 7);
|
2005-06-23 16:53:54 +00:00
|
|
|
}
|
2002-09-23 11:17:52 +00:00
|
|
|
|
2005-06-24 22:33:21 +00:00
|
|
|
static void flippixel(int x, int y)
|
2005-06-23 16:53:54 +00:00
|
|
|
{
|
2012-02-22 10:18:05 +00:00
|
|
|
*LCDFB(x,y>>3) ^= BIT_N(y & 7);
|
2005-06-23 16:53:54 +00:00
|
|
|
}
|
2002-09-23 11:17:52 +00:00
|
|
|
|
2005-06-24 22:33:21 +00:00
|
|
|
static void nopixel(int x, int y)
|
2005-06-23 16:53:54 +00:00
|
|
|
{
|
2005-06-24 22:33:21 +00:00
|
|
|
(void)x;
|
|
|
|
(void)y;
|
2005-06-23 16:53:54 +00:00
|
|
|
}
|
2004-01-13 14:59:51 +00:00
|
|
|
|
2008-03-09 18:27:12 +00:00
|
|
|
LCDFN(pixelfunc_type)* const LCDFN(pixelfuncs)[8] = {
|
2005-06-28 23:15:47 +00:00
|
|
|
flippixel, nopixel, setpixel, setpixel,
|
|
|
|
nopixel, clearpixel, nopixel, clearpixel
|
|
|
|
};
|
2020-10-07 06:01:35 +00:00
|
|
|
|
2008-03-09 18:27:12 +00:00
|
|
|
static void ICODE_ATTR flipblock(FBFN(data) *address, unsigned mask,
|
|
|
|
unsigned bits)
|
2005-06-23 16:53:54 +00:00
|
|
|
{
|
2005-07-04 06:20:50 +00:00
|
|
|
*address ^= bits & mask;
|
2005-06-24 22:33:21 +00:00
|
|
|
}
|
2002-09-23 11:17:52 +00:00
|
|
|
|
2008-03-09 18:27:12 +00:00
|
|
|
static void ICODE_ATTR bgblock(FBFN(data) *address, unsigned mask,
|
|
|
|
unsigned bits)
|
2005-06-24 22:33:21 +00:00
|
|
|
{
|
2005-07-04 06:20:50 +00:00
|
|
|
*address &= bits | ~mask;
|
2005-06-24 22:33:21 +00:00
|
|
|
}
|
2002-09-23 11:17:52 +00:00
|
|
|
|
2008-03-09 18:27:12 +00:00
|
|
|
static void ICODE_ATTR fgblock(FBFN(data) *address, unsigned mask,
|
|
|
|
unsigned bits)
|
2005-06-24 22:33:21 +00:00
|
|
|
{
|
2005-07-04 06:20:50 +00:00
|
|
|
*address |= bits & mask;
|
2005-06-24 22:33:21 +00:00
|
|
|
}
|
2002-09-23 11:17:52 +00:00
|
|
|
|
2008-03-09 18:27:12 +00:00
|
|
|
static void ICODE_ATTR solidblock(FBFN(data) *address, unsigned mask,
|
|
|
|
unsigned bits)
|
2005-06-24 22:33:21 +00:00
|
|
|
{
|
2006-07-18 00:04:43 +00:00
|
|
|
unsigned data = *(char*)address;
|
|
|
|
|
|
|
|
bits ^= data;
|
|
|
|
*address = data ^ (bits & mask);
|
2005-06-24 22:33:21 +00:00
|
|
|
}
|
2002-09-23 11:17:52 +00:00
|
|
|
|
2008-03-09 18:27:12 +00:00
|
|
|
static void ICODE_ATTR flipinvblock(FBFN(data) *address, unsigned mask,
|
|
|
|
unsigned bits)
|
2005-06-28 23:15:47 +00:00
|
|
|
{
|
2005-07-04 06:20:50 +00:00
|
|
|
*address ^= ~bits & mask;
|
2005-06-28 23:15:47 +00:00
|
|
|
}
|
|
|
|
|
2008-03-09 18:27:12 +00:00
|
|
|
static void ICODE_ATTR bginvblock(FBFN(data) *address, unsigned mask,
|
|
|
|
unsigned bits)
|
2005-06-28 23:15:47 +00:00
|
|
|
{
|
|
|
|
*address &= ~(bits & mask);
|
|
|
|
}
|
|
|
|
|
2008-03-09 18:27:12 +00:00
|
|
|
static void ICODE_ATTR fginvblock(FBFN(data) *address, unsigned mask,
|
|
|
|
unsigned bits)
|
2005-06-28 23:15:47 +00:00
|
|
|
{
|
2005-07-04 06:20:50 +00:00
|
|
|
*address |= ~bits & mask;
|
2005-06-28 23:15:47 +00:00
|
|
|
}
|
|
|
|
|
2008-03-09 18:27:12 +00:00
|
|
|
static void ICODE_ATTR solidinvblock(FBFN(data) *address, unsigned mask,
|
|
|
|
unsigned bits)
|
2005-06-28 23:15:47 +00:00
|
|
|
{
|
2006-07-18 00:04:43 +00:00
|
|
|
unsigned data = *(char *)address;
|
2020-10-26 16:38:22 +00:00
|
|
|
|
2006-07-18 00:04:43 +00:00
|
|
|
bits = ~bits ^ data;
|
|
|
|
*address = data ^ (bits & mask);
|
2005-06-28 23:15:47 +00:00
|
|
|
}
|
|
|
|
|
2008-03-09 18:27:12 +00:00
|
|
|
LCDFN(blockfunc_type)* const LCDFN(blockfuncs)[8] = {
|
2005-06-28 23:15:47 +00:00
|
|
|
flipblock, bgblock, fgblock, solidblock,
|
|
|
|
flipinvblock, bginvblock, fginvblock, solidinvblock
|
|
|
|
};
|
2002-09-23 11:17:52 +00:00
|
|
|
|
2005-06-24 22:33:21 +00:00
|
|
|
/*** drawing functions ***/
|
2002-09-23 11:17:52 +00:00
|
|
|
|
2005-06-24 22:33:21 +00:00
|
|
|
/* Clear the whole display */
|
2008-03-09 18:27:12 +00:00
|
|
|
void LCDFN(clear_display)(void)
|
2005-06-24 22:33:21 +00:00
|
|
|
{
|
2020-10-07 06:01:35 +00:00
|
|
|
unsigned bits = (CURRENT_VP->drawmode & DRMODE_INVERSEVID) ? 0xFFu : 0;
|
2005-06-25 00:28:09 +00:00
|
|
|
|
2020-10-07 06:01:35 +00:00
|
|
|
memset(LCDFB(0, 0), bits, FBSIZE);
|
2022-10-02 00:35:06 +00:00
|
|
|
LCDFN(scroll_stop)();
|
2005-06-24 22:33:21 +00:00
|
|
|
}
|
2002-09-24 22:44:59 +00:00
|
|
|
|
2005-06-24 22:33:21 +00:00
|
|
|
/* Draw a horizontal line (optimised) */
|
2008-03-09 18:27:12 +00:00
|
|
|
void LCDFN(hline)(int x1, int x2, int y)
|
2002-09-24 22:44:59 +00:00
|
|
|
{
|
2022-10-01 23:54:11 +00:00
|
|
|
struct viewport *vp = CURRENT_VP;
|
2022-09-26 07:37:00 +00:00
|
|
|
int width;
|
2005-07-02 07:21:21 +00:00
|
|
|
unsigned char *dst, *dst_end;
|
2005-06-28 23:15:47 +00:00
|
|
|
unsigned mask;
|
2008-03-09 18:27:12 +00:00
|
|
|
LCDFN(blockfunc_type) *bfunc;
|
2005-06-23 16:53:54 +00:00
|
|
|
|
2022-10-01 23:54:31 +00:00
|
|
|
if (!clip_viewport_hline(vp, &x1, &x2, &y))
|
2020-10-26 16:38:22 +00:00
|
|
|
return;
|
|
|
|
|
2009-11-07 18:38:46 +00:00
|
|
|
width = x2 - x1 + 1;
|
2008-01-07 20:34:11 +00:00
|
|
|
|
2022-10-01 23:54:11 +00:00
|
|
|
bfunc = LCDFN(blockfuncs)[vp->drawmode];
|
2012-02-22 10:18:05 +00:00
|
|
|
dst = LCDFB(x1,y>>3);
|
2009-06-07 21:27:05 +00:00
|
|
|
mask = BIT_N(y & 7);
|
2005-06-23 16:53:54 +00:00
|
|
|
|
2008-03-09 18:27:12 +00:00
|
|
|
dst_end = dst + width;
|
2005-07-02 07:21:21 +00:00
|
|
|
do
|
2005-06-28 23:15:47 +00:00
|
|
|
bfunc(dst++, mask, 0xFFu);
|
2008-03-09 18:27:12 +00:00
|
|
|
while (dst < dst_end);
|
2005-06-24 22:33:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Draw a vertical line (optimised) */
|
2008-03-09 18:27:12 +00:00
|
|
|
void LCDFN(vline)(int x, int y1, int y2)
|
2005-06-24 22:33:21 +00:00
|
|
|
{
|
2022-10-01 23:54:11 +00:00
|
|
|
struct viewport *vp = CURRENT_VP;
|
2005-06-24 22:33:21 +00:00
|
|
|
int ny;
|
2008-03-09 18:27:12 +00:00
|
|
|
FBFN(data) *dst;
|
2020-10-07 06:01:35 +00:00
|
|
|
int stride_dst;
|
2005-06-28 23:15:47 +00:00
|
|
|
unsigned mask, mask_bottom;
|
2008-03-09 18:27:12 +00:00
|
|
|
LCDFN(blockfunc_type) *bfunc;
|
2005-06-23 16:53:54 +00:00
|
|
|
|
2022-10-01 23:54:31 +00:00
|
|
|
if (!clip_viewport_vline(vp, &x, &y1, &y2))
|
2020-10-26 16:38:22 +00:00
|
|
|
return;
|
|
|
|
|
2022-10-01 23:54:11 +00:00
|
|
|
bfunc = LCDFN(blockfuncs)[vp->drawmode];
|
2012-02-22 10:18:05 +00:00
|
|
|
dst = LCDFB(x,y1>>3);
|
2005-06-24 22:33:21 +00:00
|
|
|
ny = y2 - (y1 & ~7);
|
2005-06-28 23:15:47 +00:00
|
|
|
mask = 0xFFu << (y1 & 7);
|
2005-07-04 06:20:50 +00:00
|
|
|
mask_bottom = 0xFFu >> (~ny & 7);
|
2022-10-01 23:54:11 +00:00
|
|
|
stride_dst = vp->buffer->stride;
|
2005-06-28 23:15:47 +00:00
|
|
|
|
|
|
|
for (; ny >= 8; ny -= 8)
|
2005-06-24 22:33:21 +00:00
|
|
|
{
|
2005-06-28 23:15:47 +00:00
|
|
|
bfunc(dst, mask, 0xFFu);
|
2020-10-07 06:01:35 +00:00
|
|
|
dst += stride_dst;
|
2005-06-28 23:15:47 +00:00
|
|
|
mask = 0xFFu;
|
2005-06-23 16:53:54 +00:00
|
|
|
}
|
2005-06-30 18:42:24 +00:00
|
|
|
mask &= mask_bottom;
|
|
|
|
bfunc(dst, mask, 0xFFu);
|
2005-06-23 16:53:54 +00:00
|
|
|
}
|
|
|
|
|
2005-06-24 22:33:21 +00:00
|
|
|
/* Fill a rectangular area */
|
2008-03-09 18:27:12 +00:00
|
|
|
void LCDFN(fillrect)(int x, int y, int width, int height)
|
2005-06-23 16:53:54 +00:00
|
|
|
{
|
2022-10-01 23:54:11 +00:00
|
|
|
struct viewport *vp = CURRENT_VP;
|
2005-07-02 07:21:21 +00:00
|
|
|
int ny;
|
2008-03-09 18:27:12 +00:00
|
|
|
FBFN(data) *dst, *dst_end;
|
2020-10-07 06:01:35 +00:00
|
|
|
int stride_dst;
|
2005-06-28 23:15:47 +00:00
|
|
|
unsigned mask, mask_bottom;
|
2006-02-22 00:20:28 +00:00
|
|
|
unsigned bits = 0;
|
2008-03-09 18:27:12 +00:00
|
|
|
LCDFN(blockfunc_type) *bfunc;
|
2006-02-22 00:20:28 +00:00
|
|
|
bool fillopt = false;
|
2005-06-24 22:33:21 +00:00
|
|
|
|
2022-10-01 23:54:31 +00:00
|
|
|
if (!clip_viewport_rect(vp, &x, &y, &width, &height, NULL, NULL))
|
2005-06-23 16:53:54 +00:00
|
|
|
return;
|
|
|
|
|
2022-10-01 23:54:11 +00:00
|
|
|
if (vp->drawmode & DRMODE_INVERSEVID)
|
2006-02-22 00:20:28 +00:00
|
|
|
{
|
2022-10-01 23:54:11 +00:00
|
|
|
if (vp->drawmode & DRMODE_BG)
|
2006-02-22 00:20:28 +00:00
|
|
|
{
|
|
|
|
fillopt = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-10-01 23:54:11 +00:00
|
|
|
if (vp->drawmode & DRMODE_FG)
|
2006-02-22 00:20:28 +00:00
|
|
|
{
|
|
|
|
fillopt = true;
|
|
|
|
bits = 0xFFu;
|
|
|
|
}
|
|
|
|
}
|
2022-10-01 23:54:11 +00:00
|
|
|
bfunc = LCDFN(blockfuncs)[vp->drawmode];
|
2012-02-22 10:18:05 +00:00
|
|
|
dst = LCDFB(x,y>>3);
|
2005-06-24 22:33:21 +00:00
|
|
|
ny = height - 1 + (y & 7);
|
2005-06-28 23:15:47 +00:00
|
|
|
mask = 0xFFu << (y & 7);
|
2005-07-04 06:20:50 +00:00
|
|
|
mask_bottom = 0xFFu >> (~ny & 7);
|
2022-10-01 23:54:11 +00:00
|
|
|
stride_dst = vp->buffer->stride;
|
2005-06-24 22:33:21 +00:00
|
|
|
|
2005-06-28 23:15:47 +00:00
|
|
|
for (; ny >= 8; ny -= 8)
|
2005-06-24 22:33:21 +00:00
|
|
|
{
|
2005-06-28 23:15:47 +00:00
|
|
|
if (fillopt && (mask == 0xFFu))
|
2005-06-24 22:33:21 +00:00
|
|
|
memset(dst, bits, width);
|
|
|
|
else
|
|
|
|
{
|
2008-03-09 18:27:12 +00:00
|
|
|
FBFN(data) *dst_row = dst;
|
2005-06-28 23:15:47 +00:00
|
|
|
|
2005-07-02 07:21:21 +00:00
|
|
|
dst_end = dst_row + width;
|
|
|
|
do
|
2005-06-28 23:15:47 +00:00
|
|
|
bfunc(dst_row++, mask, 0xFFu);
|
2005-07-02 07:21:21 +00:00
|
|
|
while (dst_row < dst_end);
|
2005-06-24 22:33:21 +00:00
|
|
|
}
|
2005-06-28 23:15:47 +00:00
|
|
|
|
2020-10-07 06:01:35 +00:00
|
|
|
dst += stride_dst;
|
2005-06-28 23:15:47 +00:00
|
|
|
mask = 0xFFu;
|
2005-06-24 22:33:21 +00:00
|
|
|
}
|
2005-06-30 18:42:24 +00:00
|
|
|
mask &= mask_bottom;
|
2005-06-28 23:15:47 +00:00
|
|
|
|
2005-06-30 18:42:24 +00:00
|
|
|
if (fillopt && (mask == 0xFFu))
|
2005-06-24 22:33:21 +00:00
|
|
|
memset(dst, bits, width);
|
|
|
|
else
|
2005-06-28 23:15:47 +00:00
|
|
|
{
|
2005-07-02 07:21:21 +00:00
|
|
|
dst_end = dst + width;
|
|
|
|
do
|
2005-06-30 18:42:24 +00:00
|
|
|
bfunc(dst++, mask, 0xFFu);
|
2005-07-02 07:21:21 +00:00
|
|
|
while (dst < dst_end);
|
2005-06-28 23:15:47 +00:00
|
|
|
}
|
2005-06-23 16:53:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* About Rockbox' internal bitmap format:
|
2002-09-23 11:17:52 +00:00
|
|
|
*
|
2004-05-14 22:55:05 +00:00
|
|
|
* A bitmap contains one bit for every pixel that defines if that pixel is
|
|
|
|
* black (1) or white (0). Bits within a byte are arranged vertically, LSB
|
|
|
|
* at top.
|
|
|
|
* 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
|
|
|
|
* 0..7, the second row defines pixel row 8..15 etc.
|
2002-09-23 11:17:52 +00:00
|
|
|
*
|
2005-06-23 16:53:54 +00:00
|
|
|
* This is the same as the internal lcd hw format. */
|
|
|
|
|
2005-06-28 23:15:47 +00:00
|
|
|
/* Draw a partial bitmap */
|
2008-03-09 18:27:12 +00:00
|
|
|
void ICODE_ATTR LCDFN(bitmap_part)(const unsigned char *src, int src_x,
|
|
|
|
int src_y, int stride, int x, int y,
|
|
|
|
int width, int height)
|
2002-09-23 11:17:52 +00:00
|
|
|
{
|
2022-10-01 23:54:11 +00:00
|
|
|
struct viewport *vp = CURRENT_VP;
|
2005-07-02 07:21:21 +00:00
|
|
|
int shift, ny;
|
2008-03-09 18:27:12 +00:00
|
|
|
FBFN(data) *dst, *dst_end;
|
2020-10-07 06:01:35 +00:00
|
|
|
int stride_dst;
|
2005-06-28 23:15:47 +00:00
|
|
|
unsigned mask, mask_bottom;
|
2008-03-09 18:27:12 +00:00
|
|
|
LCDFN(blockfunc_type) *bfunc;
|
2002-09-23 11:17:52 +00:00
|
|
|
|
2022-10-01 23:54:31 +00:00
|
|
|
if (!clip_viewport_rect(vp, &x, &y, &width, &height, &src_x, &src_y))
|
2002-09-23 11:17:52 +00:00
|
|
|
return;
|
2020-10-26 16:38:22 +00:00
|
|
|
|
2005-06-28 23:15:47 +00:00
|
|
|
src += stride * (src_y >> 3) + src_x; /* move starting point */
|
|
|
|
src_y &= 7;
|
|
|
|
y -= src_y;
|
2012-02-22 10:18:05 +00:00
|
|
|
dst = LCDFB(x,y>>3);
|
2022-10-01 23:54:11 +00:00
|
|
|
stride_dst = vp->buffer->stride;
|
2005-06-28 23:15:47 +00:00
|
|
|
shift = y & 7;
|
|
|
|
ny = height - 1 + shift + src_y;
|
2003-12-23 23:41:45 +00:00
|
|
|
|
2022-10-01 23:54:11 +00:00
|
|
|
bfunc = LCDFN(blockfuncs)[vp->drawmode];
|
2005-06-28 23:15:47 +00:00
|
|
|
mask = 0xFFu << (shift + src_y);
|
2005-07-04 06:20:50 +00:00
|
|
|
mask_bottom = 0xFFu >> (~ny & 7);
|
2020-10-26 16:38:22 +00:00
|
|
|
|
2005-06-28 23:15:47 +00:00
|
|
|
if (shift == 0)
|
2003-12-23 23:41:45 +00:00
|
|
|
{
|
2022-10-01 23:54:11 +00:00
|
|
|
bool copyopt = (vp->drawmode == DRMODE_SOLID);
|
2005-06-28 23:15:47 +00:00
|
|
|
|
|
|
|
for (; ny >= 8; ny -= 8)
|
2004-05-14 23:08:08 +00:00
|
|
|
{
|
2005-06-28 23:15:47 +00:00
|
|
|
if (copyopt && (mask == 0xFFu))
|
|
|
|
memcpy(dst, src, width);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const unsigned char *src_row = src;
|
2008-03-09 18:27:12 +00:00
|
|
|
FBFN(data) *dst_row = dst;
|
2020-10-26 16:38:22 +00:00
|
|
|
|
2005-07-02 07:21:21 +00:00
|
|
|
dst_end = dst_row + width;
|
2020-10-26 16:38:22 +00:00
|
|
|
do
|
2005-06-28 23:15:47 +00:00
|
|
|
bfunc(dst_row++, mask, *src_row++);
|
2005-07-02 07:21:21 +00:00
|
|
|
while (dst_row < dst_end);
|
2005-06-28 23:15:47 +00:00
|
|
|
}
|
|
|
|
|
2004-05-14 23:08:08 +00:00
|
|
|
src += stride;
|
2020-10-07 06:01:35 +00:00
|
|
|
dst += stride_dst;
|
2005-06-28 23:15:47 +00:00
|
|
|
mask = 0xFFu;
|
2004-05-14 23:08:08 +00:00
|
|
|
}
|
2005-06-30 18:42:24 +00:00
|
|
|
mask &= mask_bottom;
|
2003-12-23 23:41:45 +00:00
|
|
|
|
2005-06-30 18:42:24 +00:00
|
|
|
if (copyopt && (mask == 0xFFu))
|
2005-06-28 23:15:47 +00:00
|
|
|
memcpy(dst, src, width);
|
|
|
|
else
|
|
|
|
{
|
2005-07-02 07:21:21 +00:00
|
|
|
dst_end = dst + width;
|
|
|
|
do
|
2005-06-30 18:42:24 +00:00
|
|
|
bfunc(dst++, mask, *src++);
|
2005-07-02 07:21:21 +00:00
|
|
|
while (dst < dst_end);
|
2005-06-28 23:15:47 +00:00
|
|
|
}
|
2002-09-23 11:17:52 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-07-02 07:21:21 +00:00
|
|
|
dst_end = dst + width;
|
|
|
|
do
|
2002-09-23 11:17:52 +00:00
|
|
|
{
|
2005-06-28 23:15:47 +00:00
|
|
|
const unsigned char *src_col = src++;
|
2008-03-09 18:27:12 +00:00
|
|
|
FBFN(data) *dst_col = dst++;
|
2005-06-28 23:15:47 +00:00
|
|
|
unsigned mask_col = mask;
|
|
|
|
unsigned data = 0;
|
2020-10-26 16:38:22 +00:00
|
|
|
|
2005-06-28 23:15:47 +00:00
|
|
|
for (y = ny; y >= 8; y -= 8)
|
2002-09-23 11:17:52 +00:00
|
|
|
{
|
2004-05-14 22:55:05 +00:00
|
|
|
data |= *src_col << shift;
|
2005-06-28 23:15:47 +00:00
|
|
|
|
|
|
|
if (mask_col & 0xFFu)
|
|
|
|
{
|
|
|
|
bfunc(dst_col, mask_col, data);
|
|
|
|
mask_col = 0xFFu;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
mask_col >>= 8;
|
|
|
|
|
2004-05-14 22:55:05 +00:00
|
|
|
src_col += stride;
|
2020-10-07 06:01:35 +00:00
|
|
|
dst_col += stride_dst;
|
2002-09-23 11:17:52 +00:00
|
|
|
data >>= 8;
|
|
|
|
}
|
2004-05-14 22:55:05 +00:00
|
|
|
data |= *src_col << shift;
|
2005-06-28 23:15:47 +00:00
|
|
|
bfunc(dst_col, mask_col & mask_bottom, data);
|
|
|
|
}
|
2005-07-02 07:21:21 +00:00
|
|
|
while (dst < dst_end);
|
2002-09-23 11:17:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-28 23:15:47 +00:00
|
|
|
/* Draw a full bitmap */
|
2008-03-09 18:27:12 +00:00
|
|
|
void LCDFN(bitmap)(const unsigned char *src, int x, int y, int width,
|
|
|
|
int height)
|
2005-06-28 23:15:47 +00:00
|
|
|
{
|
2008-03-09 18:27:12 +00:00
|
|
|
LCDFN(bitmap_part)(src, 0, 0, width, x, y, width, height);
|
2005-06-28 23:15:47 +00:00
|
|
|
}
|