summaryrefslogtreecommitdiff
path: root/uisimulator/common/lcd-playersim.c
blob: 1c877d44096e614e73411cbc7da81f25b74136ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/***************************************************************************
 *             __________               __   ___.
 *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
 *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
 *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
 *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
 *                     \/            \/     \/    \/            \/
 * $Id$
 *
 * Copyright (C) 2002 by Alan Korr
 *
 * 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.
 *
 ****************************************************************************/
#include "config.h"
#include "hwcompat.h"

#include "lcd.h"
#include "lcd-charcell.h"
#include "kernel.h"
#include "thread.h"
#include <string.h>
#include <stdlib.h>
#include "debug.h"
#include "system.h"

#include "font-player.h"
#include "lcd-playersim.h"

/*** definitions ***/

bool sim_lcd_framebuffer[SIM_LCD_HEIGHT][SIM_LCD_WIDTH];

static int double_height = 1;

void lcd_print_icon(int x, int icon_line, bool enable, char **icon)
{
    int row, col;
    int y = (ICON_HEIGHT+(CHAR_HEIGHT*2+2)*CHAR_PIXEL) * icon_line;

    y += BORDER_MARGIN;
    x += BORDER_MARGIN;

    for (row = 0; icon[row]; row++)
    {
        for (col = 0; icon[row][col]; col++)
        {
            switch (icon[row][col])
            {
              case '*':
                sim_lcd_framebuffer[y+row][x+col] = enable;
                break;

              case ' ':
                sim_lcd_framebuffer[y+row][x+col] = false;
                break;
            }
        }
    }
    sim_lcd_update_rect(x, y, col, row);
    /* icon drawing updates immediately */
}

void lcd_print_char(int x, int y, unsigned char ch)
{
    int xpos = x * CHAR_WIDTH*CHAR_PIXEL;
    int ypos = y * CHAR_HEIGHT*CHAR_PIXEL + ICON_HEIGHT;
    int row, col, r, c;

    if (double_height > 1 && y == 1)
        return;  /* only one row available if text is double height */
        
    for (row = 0; row < 7; row ++)
    {
        unsigned fontbitmap = (*font_player)[ch][row];
        int height = (row == 3) ? 1 : double_height;
        
        y = ypos + row * CHAR_PIXEL * double_height;
        for (col = 0; col < 5; col++)
        {
            bool fontbit = fontbitmap & (0x10 >> col);

            x = xpos + col * CHAR_PIXEL;
            for (r = 0; r < height * CHAR_PIXEL; r++)
                for (c = 0; c < CHAR_PIXEL; c++)
                    sim_lcd_framebuffer[y+r][x+c] = fontbit;
        }
    }
    if (double_height > 1)
    {
        y = ypos + 15*CHAR_PIXEL;
        for (r = 0; r < CHAR_PIXEL; r++)
            for (c = 0; c < 5*CHAR_PIXEL; c++)
                sim_lcd_framebuffer[y+r][xpos+c] = false;
    }
}

void lcd_double_height(bool on)
{
    int newval = (is_new_player() && on) ? 2 : 1;
    
    if (newval != double_height)
    {
        double_height = newval;
        lcd_update();
    }
}

void sim_lcd_define_pattern(int pat, const char *pattern)
{
    if (pat < lcd_pattern_count)
        memcpy((*font_player)[pat], pattern, 7);
}