Mats Lidell | 36e935f | 2002-10-11 11:10:52 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
| 10 | * Copyright (C) 2002 by Alan Korr |
| 11 | * |
Daniel Stenberg | 2acc0ac | 2008-06-28 18:10:04 +0000 | [diff] [blame] | 12 | * 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 Lidell | 36e935f | 2002-10-11 11:10:52 +0000 | [diff] [blame] | 16 | * |
| 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 Lidell | 786d2c3 | 2002-10-18 09:20:48 +0000 | [diff] [blame] | 22 | #include "hwcompat.h" |
Mats Lidell | 36e935f | 2002-10-11 11:10:52 +0000 | [diff] [blame] | 23 | |
Mats Lidell | 36e935f | 2002-10-11 11:10:52 +0000 | [diff] [blame] | 24 | #include "lcd.h" |
Jens Arnold | 54ea2e4 | 2007-03-31 09:58:49 +0000 | [diff] [blame] | 25 | #include "lcd-charcell.h" |
Mats Lidell | 36e935f | 2002-10-11 11:10:52 +0000 | [diff] [blame] | 26 | #include "kernel.h" |
| 27 | #include "thread.h" |
| 28 | #include <string.h> |
| 29 | #include <stdlib.h> |
Mats Lidell | 36e935f | 2002-10-11 11:10:52 +0000 | [diff] [blame] | 30 | #include "debug.h" |
| 31 | #include "system.h" |
Kjell Ericson | ccfa848 | 2002-10-21 20:20:09 +0000 | [diff] [blame] | 32 | |
| 33 | #include "font-player.h" |
Kjell Ericson | 3262207 | 2002-10-28 20:00:19 +0000 | [diff] [blame] | 34 | #include "lcd-playersim.h" |
Mats Lidell | 36e935f | 2002-10-11 11:10:52 +0000 | [diff] [blame] | 35 | |
| 36 | /*** definitions ***/ |
| 37 | |
Jens Arnold | 54ea2e4 | 2007-03-31 09:58:49 +0000 | [diff] [blame] | 38 | bool sim_lcd_framebuffer[SIM_LCD_HEIGHT][SIM_LCD_WIDTH]; |
Mats Lidell | 36e935f | 2002-10-11 11:10:52 +0000 | [diff] [blame] | 39 | |
Jens Arnold | 54ea2e4 | 2007-03-31 09:58:49 +0000 | [diff] [blame] | 40 | static int double_height = 1; |
Mats Lidell | 36e935f | 2002-10-11 11:10:52 +0000 | [diff] [blame] | 41 | |
Kjell Ericson | ccfa848 | 2002-10-21 20:20:09 +0000 | [diff] [blame] | 42 | void lcd_print_icon(int x, int icon_line, bool enable, char **icon) |
| 43 | { |
Thomas Martitz | 91b52a1 | 2012-01-22 21:29:43 +0100 | [diff] [blame] | 44 | int row = 0, col = 0; /* shut up gcc */ |
Jens Arnold | 54ea2e4 | 2007-03-31 09:58:49 +0000 | [diff] [blame] | 45 | int y = (ICON_HEIGHT+(CHAR_HEIGHT*2+2)*CHAR_PIXEL) * icon_line; |
Kjell Ericson | 3262207 | 2002-10-28 20:00:19 +0000 | [diff] [blame] | 46 | |
Jens Arnold | 54ea2e4 | 2007-03-31 09:58:49 +0000 | [diff] [blame] | 47 | y += BORDER_MARGIN; |
| 48 | x += BORDER_MARGIN; |
Jens Arnold | 3e496e3 | 2006-02-20 00:31:10 +0000 | [diff] [blame] | 49 | |
Thomas Martitz | 91b52a1 | 2012-01-22 21:29:43 +0100 | [diff] [blame] | 50 | for (; icon[row]; row++) |
Jens Arnold | 54ea2e4 | 2007-03-31 09:58:49 +0000 | [diff] [blame] | 51 | { |
Szymon Dziok | 7038c55 | 2012-06-23 18:12:41 +0200 | [diff] [blame] | 52 | for (col = 0; icon[row][col]; col++) |
Jens Arnold | 54ea2e4 | 2007-03-31 09:58:49 +0000 | [diff] [blame] | 53 | { |
| 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 Ericson | 3262207 | 2002-10-28 20:00:19 +0000 | [diff] [blame] | 64 | } |
Kjell Ericson | ccfa848 | 2002-10-21 20:20:09 +0000 | [diff] [blame] | 65 | } |
Jens Arnold | 54ea2e4 | 2007-03-31 09:58:49 +0000 | [diff] [blame] | 66 | sim_lcd_update_rect(x, y, col, row); |
| 67 | /* icon drawing updates immediately */ |
Kjell Ericson | ccfa848 | 2002-10-21 20:20:09 +0000 | [diff] [blame] | 68 | } |
| 69 | |
Jens Arnold | 54ea2e4 | 2007-03-31 09:58:49 +0000 | [diff] [blame] | 70 | void lcd_print_char(int x, int y, unsigned char ch) |
Kjell Ericson | ccfa848 | 2002-10-21 20:20:09 +0000 | [diff] [blame] | 71 | { |
Jens Arnold | 54ea2e4 | 2007-03-31 09:58:49 +0000 | [diff] [blame] | 72 | int xpos = x * CHAR_WIDTH*CHAR_PIXEL; |
| 73 | int ypos = y * CHAR_HEIGHT*CHAR_PIXEL + ICON_HEIGHT; |
| 74 | int row, col, r, c; |
Kjell Ericson | 3262207 | 2002-10-28 20:00:19 +0000 | [diff] [blame] | 75 | |
Jens Arnold | 54ea2e4 | 2007-03-31 09:58:49 +0000 | [diff] [blame] | 76 | 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 Ericson | ccfa848 | 2002-10-21 20:20:09 +0000 | [diff] [blame] | 88 | |
Jens Arnold | 54ea2e4 | 2007-03-31 09:58:49 +0000 | [diff] [blame] | 89 | 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 Ericson | ffefc5d | 2003-06-05 08:29:21 +0000 | [diff] [blame] | 93 | } |
Kjell Ericson | ccfa848 | 2002-10-21 20:20:09 +0000 | [diff] [blame] | 94 | } |
Jens Arnold | 54ea2e4 | 2007-03-31 09:58:49 +0000 | [diff] [blame] | 95 | 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 Ericson | ccfa848 | 2002-10-21 20:20:09 +0000 | [diff] [blame] | 102 | } |
| 103 | |
Mats Lidell | 786d2c3 | 2002-10-18 09:20:48 +0000 | [diff] [blame] | 104 | void lcd_double_height(bool on) |
| 105 | { |
Jens Arnold | 54ea2e4 | 2007-03-31 09:58:49 +0000 | [diff] [blame] | 106 | int newval = (is_new_player() && on) ? 2 : 1; |
| 107 | |
| 108 | if (newval != double_height) |
Mats Lidell | 786d2c3 | 2002-10-18 09:20:48 +0000 | [diff] [blame] | 109 | { |
Jens Arnold | 54ea2e4 | 2007-03-31 09:58:49 +0000 | [diff] [blame] | 110 | double_height = newval; |
| 111 | lcd_update(); |
Mats Lidell | 786d2c3 | 2002-10-18 09:20:48 +0000 | [diff] [blame] | 112 | } |
| 113 | } |
| 114 | |
Jens Arnold | 54ea2e4 | 2007-03-31 09:58:49 +0000 | [diff] [blame] | 115 | void sim_lcd_define_pattern(int pat, const char *pattern) |
| 116 | { |
| 117 | if (pat < lcd_pattern_count) |
| 118 | memcpy((*font_player)[pat], pattern, 7); |
| 119 | } |