Fix the pitch detector plugin for iaudioM3
[kugel-rb.git] / uisimulator / sdl / lcd-remote-bitmap.c
blobecb9904a40f412b3b45c8a7a9de5cc4f41b0f6ac
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2006 Dan Everton
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #include "uisdl.h"
23 #include "lcd-sdl.h"
24 #include "lcd-remote-bitmap.h"
25 #include "screendump.h"
27 SDL_Surface *remote_surface;
29 SDL_Color remote_bl_color_dark = {RED_CMP(LCD_REMOTE_BL_DARKCOLOR),
30 GREEN_CMP(LCD_REMOTE_BL_DARKCOLOR),
31 BLUE_CMP(LCD_REMOTE_BL_DARKCOLOR), 0};
32 SDL_Color remote_bl_color_bright = {RED_CMP(LCD_REMOTE_BL_BRIGHTCOLOR),
33 GREEN_CMP(LCD_REMOTE_BL_BRIGHTCOLOR),
34 BLUE_CMP(LCD_REMOTE_BL_BRIGHTCOLOR), 0};
35 SDL_Color remote_color_dark = {RED_CMP(LCD_REMOTE_DARKCOLOR),
36 GREEN_CMP(LCD_REMOTE_DARKCOLOR),
37 BLUE_CMP(LCD_REMOTE_DARKCOLOR), 0};
38 SDL_Color remote_color_bright = {RED_CMP(LCD_REMOTE_BRIGHTCOLOR),
39 GREEN_CMP(LCD_REMOTE_BRIGHTCOLOR),
40 BLUE_CMP(LCD_REMOTE_BRIGHTCOLOR), 0};
42 #define NUM_SHADES 129
44 #if LCD_REMOTE_DEPTH == 2
45 /* Only defined for positive, non-split LCD for now */
46 static const unsigned char colorindex[4] = {128, 85, 43, 0};
47 #endif
49 static unsigned long get_lcd_remote_pixel(int x, int y)
51 #if LCD_REMOTE_DEPTH == 1
52 return lcd_remote_framebuffer[y/8][x] & (1 << (y & 7)) ? 0 : (NUM_SHADES-1);
53 #elif LCD_REMOTE_DEPTH == 2
54 #if LCD_REMOTE_PIXELFORMAT == VERTICAL_INTERLEAVED
55 unsigned bits = (lcd_remote_framebuffer[y/8][x] >> (y & 7)) & 0x0101;
56 return colorindex[(bits | (bits >> 7)) & 3];
57 #endif
58 #endif
61 void lcd_remote_update (void)
63 lcd_remote_update_rect(0, 0, LCD_REMOTE_WIDTH, LCD_REMOTE_HEIGHT);
66 void lcd_remote_update_rect(int x_start, int y_start, int width, int height)
68 sdl_update_rect(remote_surface, x_start, y_start, width, height,
69 LCD_REMOTE_WIDTH, LCD_REMOTE_HEIGHT, get_lcd_remote_pixel);
70 sdl_gui_update(remote_surface, x_start, y_start, width, height,
71 LCD_REMOTE_WIDTH, LCD_REMOTE_HEIGHT, background ? UI_REMOTE_POSX : 0,
72 background ? UI_REMOTE_POSY : LCD_HEIGHT);
75 void sim_remote_backlight(int value)
77 if (value > 0) {
78 sdl_set_gradient(remote_surface, &remote_bl_color_dark,
79 &remote_bl_color_bright, 0, NUM_SHADES);
80 } else {
81 sdl_set_gradient(remote_surface, &remote_color_dark,
82 &remote_color_bright, 0, NUM_SHADES);
85 sdl_gui_update(remote_surface, 0, 0, LCD_REMOTE_WIDTH, LCD_REMOTE_HEIGHT,
86 LCD_REMOTE_WIDTH, LCD_REMOTE_HEIGHT,
87 background ? UI_REMOTE_POSX : 0,
88 background? UI_REMOTE_POSY : LCD_HEIGHT);
91 /* initialise simulator lcd remote driver */
92 void sim_lcd_remote_init(void)
94 remote_surface = SDL_CreateRGBSurface(SDL_SWSURFACE,
95 LCD_REMOTE_WIDTH * display_zoom,
96 LCD_REMOTE_HEIGHT * display_zoom,
97 8, 0, 0, 0, 0);
99 sdl_set_gradient(remote_surface, &remote_bl_color_dark,
100 &remote_bl_color_bright, 0, NUM_SHADES);