blob: 14efded5d478a4d9548049a3bfb928f8f96e685f [file] [log] [blame]
Mats Lidell36e935f2002-10-11 11:10:52 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Alan Korr
11 *
Daniel Stenberg2acc0ac2008-06-28 18:10:04 +000012 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
Mats Lidell36e935f2002-10-11 11:10:52 +000016 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#include "config.h"
Mats Lidell786d2c32002-10-18 09:20:48 +000022#include "hwcompat.h"
Mats Lidell36e935f2002-10-11 11:10:52 +000023
Mats Lidell36e935f2002-10-11 11:10:52 +000024#include "lcd.h"
Jens Arnold54ea2e42007-03-31 09:58:49 +000025#include "lcd-charcell.h"
Mats Lidell36e935f2002-10-11 11:10:52 +000026#include "kernel.h"
27#include "thread.h"
28#include <string.h>
29#include <stdlib.h>
Mats Lidell36e935f2002-10-11 11:10:52 +000030#include "debug.h"
31#include "system.h"
Kjell Ericsonccfa8482002-10-21 20:20:09 +000032
33#include "font-player.h"
Kjell Ericson32622072002-10-28 20:00:19 +000034#include "lcd-playersim.h"
Mats Lidell36e935f2002-10-11 11:10:52 +000035
36/*** definitions ***/
37
Jens Arnold54ea2e42007-03-31 09:58:49 +000038bool sim_lcd_framebuffer[SIM_LCD_HEIGHT][SIM_LCD_WIDTH];
Mats Lidell36e935f2002-10-11 11:10:52 +000039
Jens Arnold54ea2e42007-03-31 09:58:49 +000040static int double_height = 1;
Mats Lidell36e935f2002-10-11 11:10:52 +000041
Kjell Ericsonccfa8482002-10-21 20:20:09 +000042void lcd_print_icon(int x, int icon_line, bool enable, char **icon)
43{
Thomas Martitz91b52a12012-01-22 21:29:43 +010044 int row = 0, col = 0; /* shut up gcc */
Jens Arnold54ea2e42007-03-31 09:58:49 +000045 int y = (ICON_HEIGHT+(CHAR_HEIGHT*2+2)*CHAR_PIXEL) * icon_line;
Kjell Ericson32622072002-10-28 20:00:19 +000046
Jens Arnold54ea2e42007-03-31 09:58:49 +000047 y += BORDER_MARGIN;
48 x += BORDER_MARGIN;
Jens Arnold3e496e32006-02-20 00:31:10 +000049
Thomas Martitz91b52a12012-01-22 21:29:43 +010050 for (; icon[row]; row++)
Jens Arnold54ea2e42007-03-31 09:58:49 +000051 {
Szymon Dziok7038c552012-06-23 18:12:41 +020052 for (col = 0; icon[row][col]; col++)
Jens Arnold54ea2e42007-03-31 09:58:49 +000053 {
54 switch (icon[row][col])
55 {
56 case '*':
57 sim_lcd_framebuffer[y+row][x+col] = enable;
58 break;
59
60 case ' ':
61 sim_lcd_framebuffer[y+row][x+col] = false;
62 break;
63 }
Kjell Ericson32622072002-10-28 20:00:19 +000064 }
Kjell Ericsonccfa8482002-10-21 20:20:09 +000065 }
Jens Arnold54ea2e42007-03-31 09:58:49 +000066 sim_lcd_update_rect(x, y, col, row);
67 /* icon drawing updates immediately */
Kjell Ericsonccfa8482002-10-21 20:20:09 +000068}
69
Jens Arnold54ea2e42007-03-31 09:58:49 +000070void lcd_print_char(int x, int y, unsigned char ch)
Kjell Ericsonccfa8482002-10-21 20:20:09 +000071{
Jens Arnold54ea2e42007-03-31 09:58:49 +000072 int xpos = x * CHAR_WIDTH*CHAR_PIXEL;
73 int ypos = y * CHAR_HEIGHT*CHAR_PIXEL + ICON_HEIGHT;
74 int row, col, r, c;
Kjell Ericson32622072002-10-28 20:00:19 +000075
Jens Arnold54ea2e42007-03-31 09:58:49 +000076 if (double_height > 1 && y == 1)
77 return; /* only one row available if text is double height */
78
79 for (row = 0; row < 7; row ++)
80 {
81 unsigned fontbitmap = (*font_player)[ch][row];
82 int height = (row == 3) ? 1 : double_height;
83
84 y = ypos + row * CHAR_PIXEL * double_height;
85 for (col = 0; col < 5; col++)
86 {
87 bool fontbit = fontbitmap & (0x10 >> col);
Kjell Ericsonccfa8482002-10-21 20:20:09 +000088
Jens Arnold54ea2e42007-03-31 09:58:49 +000089 x = xpos + col * CHAR_PIXEL;
90 for (r = 0; r < height * CHAR_PIXEL; r++)
91 for (c = 0; c < CHAR_PIXEL; c++)
92 sim_lcd_framebuffer[y+r][x+c] = fontbit;
Kjell Ericsonffefc5d2003-06-05 08:29:21 +000093 }
Kjell Ericsonccfa8482002-10-21 20:20:09 +000094 }
Jens Arnold54ea2e42007-03-31 09:58:49 +000095 if (double_height > 1)
96 {
97 y = ypos + 15*CHAR_PIXEL;
98 for (r = 0; r < CHAR_PIXEL; r++)
99 for (c = 0; c < 5*CHAR_PIXEL; c++)
100 sim_lcd_framebuffer[y+r][xpos+c] = false;
101 }
Kjell Ericsonccfa8482002-10-21 20:20:09 +0000102}
103
Mats Lidell786d2c32002-10-18 09:20:48 +0000104void lcd_double_height(bool on)
105{
Jens Arnold54ea2e42007-03-31 09:58:49 +0000106 int newval = (is_new_player() && on) ? 2 : 1;
107
108 if (newval != double_height)
Mats Lidell786d2c32002-10-18 09:20:48 +0000109 {
Jens Arnold54ea2e42007-03-31 09:58:49 +0000110 double_height = newval;
111 lcd_update();
Mats Lidell786d2c32002-10-18 09:20:48 +0000112 }
113}
114
Jens Arnold54ea2e42007-03-31 09:58:49 +0000115void sim_lcd_define_pattern(int pat, const char *pattern)
116{
117 if (pat < lcd_pattern_count)
118 memcpy((*font_player)[pat], pattern, 7);
119}