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),
|
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;
|
|
|
|
#if defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE
|
|
|
|
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
|
|
|
|
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-23 16:53:54 +00:00
|
|
|
/*** parameter handling ***/
|
2002-09-23 11:17:52 +00:00
|
|
|
|
2008-03-09 18:27:12 +00:00
|
|
|
void LCDFN(set_drawmode)(int mode)
|
2005-06-24 22:33:21 +00:00
|
|
|
{
|
2020-10-07 06:01:35 +00:00
|
|
|
CURRENT_VP->drawmode = mode & (DRMODE_SOLID|DRMODE_INVERSEVID);
|
2005-06-24 22:33:21 +00:00
|
|
|
}
|
|
|
|
|
2008-03-09 18:27:12 +00:00
|
|
|
int LCDFN(get_drawmode)(void)
|
2005-06-24 22:33:21 +00:00
|
|
|
{
|
2020-10-07 06:01:35 +00:00
|
|
|
return CURRENT_VP->drawmode;
|
2005-06-24 22:33:21 +00:00
|
|
|
}
|
|
|
|
|
2008-03-09 18:27:12 +00:00
|
|
|
int LCDFN(getwidth)(void)
|
2008-01-07 20:34:11 +00:00
|
|
|
{
|
2020-10-07 06:01:35 +00:00
|
|
|
return CURRENT_VP->width;
|
2008-01-07 20:34:11 +00:00
|
|
|
}
|
|
|
|
|
2008-03-09 18:27:12 +00:00
|
|
|
int LCDFN(getheight)(void)
|
2008-01-07 20:34:11 +00:00
|
|
|
{
|
2020-10-07 06:01:35 +00:00
|
|
|
return CURRENT_VP->height;
|
2002-09-23 11:17:52 +00:00
|
|
|
}
|
|
|
|
|
2008-03-09 18:27:12 +00:00
|
|
|
void LCDFN(setfont)(int newfont)
|
2002-09-23 11:17:52 +00:00
|
|
|
{
|
2020-10-07 06:01:35 +00:00
|
|
|
CURRENT_VP->font = newfont;
|
2002-09-23 11:17:52 +00:00
|
|
|
}
|
|
|
|
|
2008-03-09 18:27:12 +00:00
|
|
|
int LCDFN(getfont)(void)
|
2008-01-08 01:22:14 +00:00
|
|
|
{
|
2020-10-07 06:01:35 +00:00
|
|
|
return CURRENT_VP->font;
|
2008-01-08 01:22:14 +00:00
|
|
|
}
|
|
|
|
|
2008-03-09 18:27:12 +00:00
|
|
|
int LCDFN(getstringsize)(const unsigned char *str, int *w, int *h)
|
2002-09-23 11:17:52 +00:00
|
|
|
{
|
2020-10-07 06:01:35 +00:00
|
|
|
return font_getstringsize(str, w, h, CURRENT_VP->font);
|
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);
|
2008-03-09 18:27:12 +00:00
|
|
|
LCDFN(scroll_info).lines = 0;
|
2005-06-24 22:33:21 +00:00
|
|
|
}
|
2002-09-24 22:44:59 +00:00
|
|
|
|
2008-03-09 18:27:12 +00:00
|
|
|
/* Clear the current viewport */
|
|
|
|
void LCDFN(clear_viewport)(void)
|
2008-01-07 20:34:11 +00:00
|
|
|
{
|
|
|
|
int oldmode;
|
|
|
|
|
2020-10-07 06:01:35 +00:00
|
|
|
if (CURRENT_VP == &default_vp &&
|
|
|
|
default_vp.buffer == &LCDFN(framebuffer_default))
|
2008-01-07 20:34:11 +00:00
|
|
|
{
|
2008-03-09 18:27:12 +00:00
|
|
|
LCDFN(clear_display)();
|
2008-01-07 20:34:11 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-10-07 06:01:35 +00:00
|
|
|
oldmode = CURRENT_VP->drawmode;
|
2008-01-07 20:34:11 +00:00
|
|
|
|
|
|
|
/* Invert the INVERSEVID bit and set basic mode to SOLID */
|
2020-10-26 16:38:22 +00:00
|
|
|
CURRENT_VP->drawmode = (~CURRENT_VP->drawmode & DRMODE_INVERSEVID) |
|
2008-01-07 20:34:11 +00:00
|
|
|
DRMODE_SOLID;
|
|
|
|
|
2020-10-07 06:01:35 +00:00
|
|
|
LCDFN(fillrect)(0, 0, CURRENT_VP->width, CURRENT_VP->height);
|
2008-01-07 20:34:11 +00:00
|
|
|
|
2020-10-07 06:01:35 +00:00
|
|
|
CURRENT_VP->drawmode = oldmode;
|
2008-01-07 20:34:11 +00:00
|
|
|
|
2020-10-07 06:01:35 +00:00
|
|
|
LCDFN(scroll_stop_viewport)(CURRENT_VP);
|
2008-01-07 20:34:11 +00:00
|
|
|
}
|
2020-10-07 06:01:35 +00:00
|
|
|
|
|
|
|
CURRENT_VP->flags &= ~(VP_FLAG_VP_SET_CLEAN);
|
2008-01-07 20:34:11 +00:00
|
|
|
}
|
|
|
|
|
2005-06-24 22:33:21 +00:00
|
|
|
/* Set a single pixel */
|
2008-03-09 18:27:12 +00:00
|
|
|
void LCDFN(drawpixel)(int x, int y)
|
2005-06-24 22:33:21 +00:00
|
|
|
{
|
2020-10-26 16:38:22 +00:00
|
|
|
if ( ((unsigned)x < (unsigned)CURRENT_VP->width)
|
2020-10-07 06:01:35 +00:00
|
|
|
&& ((unsigned)y < (unsigned)CURRENT_VP->height)
|
2009-11-07 18:38:46 +00:00
|
|
|
#if defined(HAVE_VIEWPORT_CLIP)
|
|
|
|
&& ((unsigned)x < (unsigned)LCDM(WIDTH))
|
|
|
|
&& ((unsigned)y < (unsigned)LCDM(HEIGHT))
|
|
|
|
#endif
|
|
|
|
)
|
2020-10-07 06:01:35 +00:00
|
|
|
LCDFN(pixelfuncs)[CURRENT_VP->drawmode](CURRENT_VP->x + x, CURRENT_VP->y + y);
|
2005-06-23 16:53:54 +00:00
|
|
|
}
|
2004-05-14 23:53:25 +00:00
|
|
|
|
2005-06-24 22:33:21 +00:00
|
|
|
/* Draw a line */
|
2008-03-09 18:27:12 +00:00
|
|
|
void LCDFN(drawline)(int x1, int y1, int x2, int y2)
|
2005-06-23 16:53:54 +00:00
|
|
|
{
|
|
|
|
int numpixels;
|
|
|
|
int i;
|
|
|
|
int deltax, deltay;
|
|
|
|
int d, dinc1, dinc2;
|
|
|
|
int x, xinc1, xinc2;
|
|
|
|
int y, yinc1, yinc2;
|
2020-10-07 06:01:35 +00:00
|
|
|
LCDFN(pixelfunc_type) *pfunc = LCDFN(pixelfuncs)[CURRENT_VP->drawmode];
|
2005-06-23 16:53:54 +00:00
|
|
|
|
|
|
|
deltax = abs(x2 - x1);
|
2008-04-12 07:53:33 +00:00
|
|
|
if (deltax == 0)
|
|
|
|
{
|
2010-02-20 06:42:45 +00:00
|
|
|
/* DEBUGF(LCDNAME "drawline() called for vertical line - optimisation.\n"); */
|
2008-04-12 07:53:33 +00:00
|
|
|
LCDFN(vline)(x1, y1, y2);
|
|
|
|
return;
|
|
|
|
}
|
2005-06-23 16:53:54 +00:00
|
|
|
deltay = abs(y2 - y1);
|
2008-04-12 07:53:33 +00:00
|
|
|
if (deltay == 0)
|
|
|
|
{
|
2010-02-20 06:42:45 +00:00
|
|
|
/* DEBUGF(LCDNAME "drawline() called for horizontal line - optimisation.\n"); */
|
2008-04-12 07:53:33 +00:00
|
|
|
LCDFN(hline)(x1, x2, y1);
|
|
|
|
return;
|
|
|
|
}
|
2005-06-24 22:33:21 +00:00
|
|
|
xinc2 = 1;
|
|
|
|
yinc2 = 1;
|
2005-06-23 16:53:54 +00:00
|
|
|
|
2005-06-24 22:33:21 +00:00
|
|
|
if (deltax >= deltay)
|
2005-06-23 16:53:54 +00:00
|
|
|
{
|
|
|
|
numpixels = deltax;
|
|
|
|
d = 2 * deltay - deltax;
|
|
|
|
dinc1 = deltay * 2;
|
|
|
|
dinc2 = (deltay - deltax) * 2;
|
|
|
|
xinc1 = 1;
|
|
|
|
yinc1 = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
numpixels = deltay;
|
|
|
|
d = 2 * deltax - deltay;
|
|
|
|
dinc1 = deltax * 2;
|
|
|
|
dinc2 = (deltax - deltay) * 2;
|
|
|
|
xinc1 = 0;
|
|
|
|
yinc1 = 1;
|
|
|
|
}
|
|
|
|
numpixels++; /* include endpoints */
|
|
|
|
|
2005-06-24 22:33:21 +00:00
|
|
|
if (x1 > x2)
|
2005-06-23 16:53:54 +00:00
|
|
|
{
|
|
|
|
xinc1 = -xinc1;
|
|
|
|
xinc2 = -xinc2;
|
|
|
|
}
|
|
|
|
|
2005-06-24 22:33:21 +00:00
|
|
|
if (y1 > y2)
|
2005-06-23 16:53:54 +00:00
|
|
|
{
|
|
|
|
yinc1 = -yinc1;
|
|
|
|
yinc2 = -yinc2;
|
|
|
|
}
|
|
|
|
|
|
|
|
x = x1;
|
|
|
|
y = y1;
|
|
|
|
|
2005-06-24 22:33:21 +00:00
|
|
|
for (i = 0; i < numpixels; i++)
|
2005-06-23 16:53:54 +00:00
|
|
|
{
|
2020-10-07 06:01:35 +00:00
|
|
|
if ( ((unsigned)x < (unsigned)CURRENT_VP->width)
|
|
|
|
&& ((unsigned)y < (unsigned)CURRENT_VP->height)
|
2009-11-07 18:38:46 +00:00
|
|
|
#if defined(HAVE_VIEWPORT_CLIP)
|
|
|
|
&& ((unsigned)x < (unsigned)LCDM(WIDTH))
|
|
|
|
&& ((unsigned)y < (unsigned)LCDM(HEIGHT))
|
|
|
|
#endif
|
|
|
|
)
|
2020-10-07 06:01:35 +00:00
|
|
|
pfunc(CURRENT_VP->x + x, CURRENT_VP->y + y);
|
2005-06-23 16:53:54 +00:00
|
|
|
|
2005-06-24 22:33:21 +00:00
|
|
|
if (d < 0)
|
2005-06-23 16:53:54 +00:00
|
|
|
{
|
|
|
|
d += dinc1;
|
|
|
|
x += xinc1;
|
|
|
|
y += yinc1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
d += dinc2;
|
|
|
|
x += xinc2;
|
|
|
|
y += yinc2;
|
2002-09-24 22:44:59 +00:00
|
|
|
}
|
2002-09-23 11:17:52 +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
|
|
|
{
|
2008-03-09 18:27:12 +00:00
|
|
|
int x, 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
|
|
|
|
2005-06-24 22:33:21 +00:00
|
|
|
/* direction flip */
|
|
|
|
if (x2 < x1)
|
|
|
|
{
|
|
|
|
x = x1;
|
|
|
|
x1 = x2;
|
|
|
|
x2 = x;
|
|
|
|
}
|
2020-10-26 16:38:22 +00:00
|
|
|
|
2009-11-07 18:38:46 +00:00
|
|
|
/******************** In viewport clipping **********************/
|
2005-06-24 22:33:21 +00:00
|
|
|
/* nothing to draw? */
|
2020-10-07 06:01:35 +00:00
|
|
|
if (((unsigned)y >= (unsigned)CURRENT_VP->height) || (x1 >= CURRENT_VP->width)
|
2008-01-07 20:34:11 +00:00
|
|
|
|| (x2 < 0))
|
2020-10-26 16:38:22 +00:00
|
|
|
return;
|
|
|
|
|
2005-06-24 22:33:21 +00:00
|
|
|
if (x1 < 0)
|
|
|
|
x1 = 0;
|
2020-10-07 06:01:35 +00:00
|
|
|
if (x2 >= CURRENT_VP->width)
|
|
|
|
x2 = CURRENT_VP->width-1;
|
2020-10-26 16:38:22 +00:00
|
|
|
|
2008-03-09 18:27:12 +00:00
|
|
|
/* adjust to viewport */
|
2020-10-07 06:01:35 +00:00
|
|
|
x1 += CURRENT_VP->x;
|
|
|
|
x2 += CURRENT_VP->x;
|
|
|
|
y += CURRENT_VP->y;
|
2020-10-26 16:38:22 +00:00
|
|
|
|
2009-11-07 18:38:46 +00:00
|
|
|
#if defined(HAVE_VIEWPORT_CLIP)
|
|
|
|
/********************* Viewport on screen clipping ********************/
|
|
|
|
/* nothing to draw? */
|
|
|
|
if (((unsigned)y >= (unsigned) LCDM(HEIGHT)) || (x1 >= LCDM(WIDTH))
|
|
|
|
|| (x2 < 0))
|
2020-10-26 16:38:22 +00:00
|
|
|
return;
|
|
|
|
|
2009-11-07 18:38:46 +00:00
|
|
|
/* clipping */
|
|
|
|
if (x1 < 0)
|
|
|
|
x1 = 0;
|
|
|
|
if (x2 >= LCDM(WIDTH))
|
|
|
|
x2 = LCDM(WIDTH)-1;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
width = x2 - x1 + 1;
|
2008-01-07 20:34:11 +00:00
|
|
|
|
2020-10-07 06:01:35 +00:00
|
|
|
bfunc = LCDFN(blockfuncs)[CURRENT_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
|
|
|
{
|
|
|
|
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
|
|
|
|
2005-06-24 22:33:21 +00:00
|
|
|
/* direction flip */
|
|
|
|
if (y2 < y1)
|
|
|
|
{
|
|
|
|
ny = y1;
|
|
|
|
y1 = y2;
|
|
|
|
y2 = ny;
|
2005-06-23 16:53:54 +00:00
|
|
|
}
|
|
|
|
|
2009-11-07 18:38:46 +00:00
|
|
|
/******************** In viewport clipping **********************/
|
2005-06-24 22:33:21 +00:00
|
|
|
/* nothing to draw? */
|
2020-10-07 06:01:35 +00:00
|
|
|
if (((unsigned)x >= (unsigned)CURRENT_VP->width) || (y1 >= CURRENT_VP->height)
|
2008-01-07 20:34:11 +00:00
|
|
|
|| (y2 < 0))
|
2020-10-26 16:38:22 +00:00
|
|
|
return;
|
|
|
|
|
2005-06-24 22:33:21 +00:00
|
|
|
if (y1 < 0)
|
|
|
|
y1 = 0;
|
2020-10-07 06:01:35 +00:00
|
|
|
if (y2 >= CURRENT_VP->height)
|
|
|
|
y2 = CURRENT_VP->height-1;
|
2020-10-26 16:38:22 +00:00
|
|
|
|
2008-01-07 20:34:11 +00:00
|
|
|
/* adjust for viewport */
|
2020-10-07 06:01:35 +00:00
|
|
|
y1 += CURRENT_VP->y;
|
|
|
|
y2 += CURRENT_VP->y;
|
|
|
|
x += CURRENT_VP->x;
|
2020-10-26 16:38:22 +00:00
|
|
|
|
2009-11-07 18:38:46 +00:00
|
|
|
#if defined(HAVE_VIEWPORT_CLIP)
|
|
|
|
/********************* Viewport on screen clipping ********************/
|
|
|
|
/* nothing to draw? */
|
2020-10-26 16:38:22 +00:00
|
|
|
if (( (unsigned) x >= (unsigned)LCDM(WIDTH)) || (y1 >= LCDM(HEIGHT))
|
2009-11-07 18:38:46 +00:00
|
|
|
|| (y2 < 0))
|
|
|
|
return;
|
2020-10-26 16:38:22 +00:00
|
|
|
|
2009-11-07 18:38:46 +00:00
|
|
|
/* clipping */
|
|
|
|
if (y1 < 0)
|
|
|
|
y1 = 0;
|
|
|
|
if (y2 >= LCDM(HEIGHT))
|
|
|
|
y2 = LCDM(HEIGHT)-1;
|
|
|
|
#endif
|
2008-01-07 20:34:11 +00:00
|
|
|
|
2020-10-07 06:01:35 +00:00
|
|
|
bfunc = LCDFN(blockfuncs)[CURRENT_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);
|
2020-10-07 06:01:35 +00:00
|
|
|
stride_dst = CURRENT_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
|
|
|
/* Draw a rectangular box */
|
2008-03-09 18:27:12 +00:00
|
|
|
void LCDFN(drawrect)(int x, int y, int width, int height)
|
2005-06-23 16:53:54 +00:00
|
|
|
{
|
2005-06-24 22:33:21 +00:00
|
|
|
if ((width <= 0) || (height <= 0))
|
|
|
|
return;
|
|
|
|
|
|
|
|
int x2 = x + width - 1;
|
|
|
|
int y2 = y + height - 1;
|
|
|
|
|
2008-03-09 18:27:12 +00:00
|
|
|
LCDFN(vline)(x, y, y2);
|
|
|
|
LCDFN(vline)(x2, y, y2);
|
|
|
|
LCDFN(hline)(x, x2, y);
|
|
|
|
LCDFN(hline)(x, x2, y2);
|
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
|
|
|
{
|
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
|
|
|
|
2009-11-07 18:38:46 +00:00
|
|
|
/******************** In viewport clipping **********************/
|
2005-06-24 22:33:21 +00:00
|
|
|
/* nothing to draw? */
|
2020-10-07 06:01:35 +00:00
|
|
|
if ((width <= 0) || (height <= 0) || (x >= CURRENT_VP->width)
|
|
|
|
|| (y >= CURRENT_VP->height) || (x + width <= 0) || (y + height <= 0))
|
2005-06-23 16:53:54 +00:00
|
|
|
return;
|
|
|
|
|
2005-06-24 22:33:21 +00:00
|
|
|
if (x < 0)
|
|
|
|
{
|
|
|
|
width += x;
|
|
|
|
x = 0;
|
|
|
|
}
|
|
|
|
if (y < 0)
|
|
|
|
{
|
|
|
|
height += y;
|
|
|
|
y = 0;
|
|
|
|
}
|
2020-10-07 06:01:35 +00:00
|
|
|
if (x + width > CURRENT_VP->width)
|
|
|
|
width = CURRENT_VP->width - x;
|
|
|
|
if (y + height > CURRENT_VP->height)
|
|
|
|
height = CURRENT_VP->height - y;
|
2020-10-26 16:38:22 +00:00
|
|
|
|
2008-01-07 20:34:11 +00:00
|
|
|
/* adjust for viewport */
|
2020-10-07 06:01:35 +00:00
|
|
|
x += CURRENT_VP->x;
|
|
|
|
y += CURRENT_VP->y;
|
2020-10-26 16:38:22 +00:00
|
|
|
|
2009-11-07 18:38:46 +00:00
|
|
|
#if defined(HAVE_VIEWPORT_CLIP)
|
|
|
|
/********************* Viewport on screen clipping ********************/
|
|
|
|
/* nothing to draw? */
|
2020-10-26 16:38:22 +00:00
|
|
|
if ((x >= LCDM(WIDTH)) || (y >= LCDM(HEIGHT))
|
2009-11-07 18:38:46 +00:00
|
|
|
|| (x + width <= 0) || (y + height <= 0))
|
|
|
|
return;
|
2020-10-26 16:38:22 +00:00
|
|
|
|
2009-11-07 18:38:46 +00:00
|
|
|
/* clip image in viewport in screen */
|
|
|
|
if (x < 0)
|
|
|
|
{
|
|
|
|
width += x;
|
|
|
|
x = 0;
|
|
|
|
}
|
|
|
|
if (y < 0)
|
|
|
|
{
|
|
|
|
height += y;
|
|
|
|
y = 0;
|
|
|
|
}
|
|
|
|
if (x + width > LCDM(WIDTH))
|
|
|
|
width = LCDM(WIDTH) - x;
|
|
|
|
if (y + height > LCDM(HEIGHT))
|
|
|
|
height = LCDM(HEIGHT) - y;
|
|
|
|
#endif
|
2008-01-07 20:34:11 +00:00
|
|
|
|
2020-10-07 06:01:35 +00:00
|
|
|
if (CURRENT_VP->drawmode & DRMODE_INVERSEVID)
|
2006-02-22 00:20:28 +00:00
|
|
|
{
|
2020-10-07 06:01:35 +00:00
|
|
|
if (CURRENT_VP->drawmode & DRMODE_BG)
|
2006-02-22 00:20:28 +00:00
|
|
|
{
|
|
|
|
fillopt = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-10-07 06:01:35 +00:00
|
|
|
if (CURRENT_VP->drawmode & DRMODE_FG)
|
2006-02-22 00:20:28 +00:00
|
|
|
{
|
|
|
|
fillopt = true;
|
|
|
|
bits = 0xFFu;
|
|
|
|
}
|
|
|
|
}
|
2020-10-07 06:01:35 +00:00
|
|
|
bfunc = LCDFN(blockfuncs)[CURRENT_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);
|
2020-10-07 06:01:35 +00:00
|
|
|
stride_dst = CURRENT_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
|
|
|
{
|
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
|
|
|
|
2009-11-07 18:38:46 +00:00
|
|
|
/******************** Image in viewport clipping **********************/
|
2005-06-28 23:15:47 +00:00
|
|
|
/* nothing to draw? */
|
2020-10-07 06:01:35 +00:00
|
|
|
if ((width <= 0) || (height <= 0) || (x >= CURRENT_VP->width)
|
|
|
|
|| (y >= CURRENT_VP->height) || (x + width <= 0) || (y + height <= 0))
|
2002-09-23 11:17:52 +00:00
|
|
|
return;
|
2020-10-26 16:38:22 +00:00
|
|
|
|
2009-11-07 18:38:46 +00:00
|
|
|
/* clip image in viewport */
|
2005-06-28 23:15:47 +00:00
|
|
|
if (x < 0)
|
|
|
|
{
|
|
|
|
width += x;
|
|
|
|
src_x -= x;
|
|
|
|
x = 0;
|
|
|
|
}
|
|
|
|
if (y < 0)
|
|
|
|
{
|
|
|
|
height += y;
|
|
|
|
src_y -= y;
|
|
|
|
y = 0;
|
|
|
|
}
|
2020-10-07 06:01:35 +00:00
|
|
|
if (x + width > CURRENT_VP->width)
|
|
|
|
width = CURRENT_VP->width - x;
|
|
|
|
if (y + height > CURRENT_VP->height)
|
|
|
|
height = CURRENT_VP->height - y;
|
2008-01-07 20:34:11 +00:00
|
|
|
|
|
|
|
/* adjust for viewport */
|
2020-10-07 06:01:35 +00:00
|
|
|
x += CURRENT_VP->x;
|
|
|
|
y += CURRENT_VP->y;
|
2020-10-26 16:38:22 +00:00
|
|
|
|
2009-11-07 18:38:46 +00:00
|
|
|
#if defined(HAVE_VIEWPORT_CLIP)
|
|
|
|
/********************* Viewport on screen clipping ********************/
|
|
|
|
/* nothing to draw? */
|
2020-10-26 16:38:22 +00:00
|
|
|
if ((x >= LCDM(WIDTH)) || (y >= LCDM(HEIGHT))
|
2009-11-07 18:38:46 +00:00
|
|
|
|| (x + width <= 0) || (y + height <= 0))
|
|
|
|
return;
|
2020-10-26 16:38:22 +00:00
|
|
|
|
2009-11-07 18:38:46 +00:00
|
|
|
/* clip image in viewport in screen */
|
|
|
|
if (x < 0)
|
|
|
|
{
|
|
|
|
width += x;
|
|
|
|
src_x -= x;
|
|
|
|
x = 0;
|
|
|
|
}
|
|
|
|
if (y < 0)
|
|
|
|
{
|
|
|
|
height += y;
|
|
|
|
src_y -= y;
|
|
|
|
y = 0;
|
|
|
|
}
|
|
|
|
if (x + width > LCDM(WIDTH))
|
|
|
|
width = LCDM(WIDTH) - x;
|
|
|
|
if (y + height > LCDM(HEIGHT))
|
|
|
|
height = LCDM(HEIGHT) - y;
|
|
|
|
#endif
|
2002-09-23 11:17:52 +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);
|
2020-10-07 06:01:35 +00:00
|
|
|
stride_dst = CURRENT_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
|
|
|
|
2020-10-07 06:01:35 +00:00
|
|
|
bfunc = LCDFN(blockfuncs)[CURRENT_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
|
|
|
{
|
2020-10-07 06:01:35 +00:00
|
|
|
bool copyopt = (CURRENT_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
|
|
|
}
|
|
|
|
|
2009-08-13 08:02:29 +00:00
|
|
|
#include "lcd-bitmap-common.c"
|