2002-03-26 10:06:28 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 by Daniel Stenberg <daniel@haxx.se>
|
|
|
|
*
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2002-03-26 10:59:39 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
#include "screenhack.h"
|
|
|
|
|
2002-03-26 10:06:28 +00:00
|
|
|
/*
|
2002-03-26 10:59:39 +00:00
|
|
|
* Specific implementations for X11, using the generic LCD API and data.
|
2002-03-26 10:06:28 +00:00
|
|
|
*/
|
|
|
|
|
2002-03-26 14:27:03 +00:00
|
|
|
#include "lcd-x11.h"
|
2002-03-26 10:59:39 +00:00
|
|
|
|
2002-08-07 10:35:26 +00:00
|
|
|
extern unsigned char lcd_framebuffer[LCD_WIDTH][LCD_HEIGHT/8];
|
2002-04-19 12:55:12 +00:00
|
|
|
extern void screen_resized(int width, int height);
|
|
|
|
extern Display *dpy;
|
2002-03-26 10:59:39 +00:00
|
|
|
|
2002-08-07 10:35:26 +00:00
|
|
|
unsigned char lcd_framebuffer_copy[LCD_WIDTH][LCD_HEIGHT/8];
|
2002-04-27 23:41:41 +00:00
|
|
|
|
2002-06-14 11:00:13 +00:00
|
|
|
/* this is in uibasic.c */
|
|
|
|
extern void drawdots(int color, XPoint *points, int count);
|
|
|
|
|
2002-03-26 10:59:39 +00:00
|
|
|
void lcd_update (void)
|
|
|
|
{
|
2002-04-19 12:55:12 +00:00
|
|
|
int x, y;
|
|
|
|
int p=0;
|
|
|
|
int bit;
|
|
|
|
XPoint points[LCD_WIDTH * LCD_HEIGHT];
|
2002-04-27 23:41:41 +00:00
|
|
|
int cp=0;
|
|
|
|
XPoint clearpoints[LCD_WIDTH * LCD_HEIGHT];
|
2002-03-26 10:59:39 +00:00
|
|
|
|
2002-04-19 12:55:12 +00:00
|
|
|
for(y=0; y<LCD_HEIGHT; y+=8) {
|
|
|
|
for(x=0; x<LCD_WIDTH; x++) {
|
2002-09-10 07:07:44 +00:00
|
|
|
if(lcd_framebuffer[x][y/8] || lcd_framebuffer_copy[x][y/8]) {
|
|
|
|
/* one or more bits/pixels are changed */
|
|
|
|
unsigned char diff =
|
|
|
|
lcd_framebuffer[x][y/8] ^ lcd_framebuffer_copy[x][y/8];
|
|
|
|
|
2002-04-19 12:55:12 +00:00
|
|
|
for(bit=0; bit<8; bit++) {
|
2002-08-07 10:35:26 +00:00
|
|
|
if(lcd_framebuffer[x][y/8]&(1<<bit)) {
|
2002-09-10 07:07:44 +00:00
|
|
|
/* set a dot */
|
2002-04-19 12:55:12 +00:00
|
|
|
points[p].x = x + MARGIN_X;
|
|
|
|
points[p].y = y+bit + MARGIN_Y;
|
|
|
|
p++; /* increase the point counter */
|
|
|
|
}
|
2002-09-10 07:07:44 +00:00
|
|
|
else if(diff &(1<<bit)) {
|
|
|
|
/* clear a dot */
|
|
|
|
clearpoints[cp].x = x + MARGIN_X;
|
|
|
|
clearpoints[cp].y = y+bit + MARGIN_Y;
|
|
|
|
cp++; /* increase the point counter */
|
|
|
|
}
|
2002-04-19 12:55:12 +00:00
|
|
|
}
|
|
|
|
}
|
2002-03-26 10:59:39 +00:00
|
|
|
}
|
|
|
|
}
|
2002-09-10 07:07:44 +00:00
|
|
|
|
|
|
|
/* copy a huge block */
|
|
|
|
memcpy(lcd_framebuffer_copy, lcd_framebuffer, sizeof(lcd_framebuffer));
|
|
|
|
|
|
|
|
drawdots(0, &clearpoints[0], cp);
|
|
|
|
drawdots(1, &points[0], p);
|
|
|
|
/* Logf("lcd_update: Draws %d pixels, clears %d pixels", p, cp);*/
|
|
|
|
XSync(dpy,False);
|
|
|
|
}
|
|
|
|
|
|
|
|
void lcd_update_rect(int x_start, int y_start,
|
|
|
|
int width, int height)
|
|
|
|
{
|
|
|
|
int x;
|
|
|
|
int yline=y_start;
|
|
|
|
int y;
|
|
|
|
int p=0;
|
|
|
|
int bit;
|
|
|
|
int cp=0;
|
|
|
|
int xmax;
|
|
|
|
int ymax;
|
|
|
|
XPoint points[LCD_WIDTH * LCD_HEIGHT];
|
|
|
|
XPoint clearpoints[LCD_WIDTH * LCD_HEIGHT];
|
|
|
|
|
|
|
|
/* The Y coordinates have to work on even 8 pixel rows */
|
|
|
|
ymax = (yline + height)/8;
|
|
|
|
yline /= 8;
|
|
|
|
|
|
|
|
xmax = x_start + width;
|
|
|
|
|
|
|
|
if(xmax > LCD_WIDTH)
|
|
|
|
xmax = LCD_WIDTH;
|
|
|
|
if(ymax >= LCD_HEIGHT/8)
|
|
|
|
ymax = LCD_HEIGHT/8-1;
|
|
|
|
|
|
|
|
for(; yline<ymax; yline++) {
|
|
|
|
y = yline * 8;
|
|
|
|
for(x=x_start; x<xmax; x++) {
|
|
|
|
if(lcd_framebuffer[x][yline] || lcd_framebuffer_copy[x][yline]) {
|
2002-04-27 23:41:41 +00:00
|
|
|
/* one or more bits/pixels are changed */
|
|
|
|
unsigned char diff =
|
2002-09-10 07:07:44 +00:00
|
|
|
lcd_framebuffer[x][yline] ^ lcd_framebuffer_copy[x][yline];
|
2002-04-27 23:41:41 +00:00
|
|
|
|
|
|
|
for(bit=0; bit<8; bit++) {
|
2002-09-10 07:07:44 +00:00
|
|
|
if(lcd_framebuffer[x][yline]&(1<<bit)) {
|
2002-04-27 23:41:41 +00:00
|
|
|
/* set a dot */
|
|
|
|
points[p].x = x + MARGIN_X;
|
|
|
|
points[p].y = y+bit + MARGIN_Y;
|
|
|
|
p++; /* increase the point counter */
|
|
|
|
}
|
|
|
|
else if(diff &(1<<bit)) {
|
|
|
|
/* clear a dot */
|
|
|
|
clearpoints[cp].x = x + MARGIN_X;
|
|
|
|
clearpoints[cp].y = y+bit + MARGIN_Y;
|
|
|
|
cp++; /* increase the point counter */
|
|
|
|
}
|
|
|
|
}
|
2002-09-10 07:07:44 +00:00
|
|
|
|
|
|
|
/* update the copy */
|
|
|
|
lcd_framebuffer_copy[x][yline] = lcd_framebuffer[x][yline];
|
2002-04-27 23:41:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
drawdots(0, &clearpoints[0], cp);
|
2002-04-30 13:29:08 +00:00
|
|
|
drawdots(1, &points[0], p);
|
2002-05-03 06:54:41 +00:00
|
|
|
/* Logf("lcd_update: Draws %d pixels, clears %d pixels", p, cp);*/
|
2002-04-19 12:55:12 +00:00
|
|
|
XSync(dpy,False);
|
2002-03-26 10:59:39 +00:00
|
|
|
}
|
2002-09-10 07:07:44 +00:00
|
|
|
|
|
|
|
/* -----------------------------------------------------------------
|
|
|
|
* local variables:
|
|
|
|
* eval: (load-file "../../firmware/rockbox-mode.el")
|
|
|
|
* end:
|
|
|
|
*/
|