diff options
Diffstat (limited to 'apps/plugins/zxbox/zxvid_grey.c')
-rw-r--r-- | apps/plugins/zxbox/zxvid_grey.c | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/apps/plugins/zxbox/zxvid_grey.c b/apps/plugins/zxbox/zxvid_grey.c new file mode 100644 index 0000000000..8491e6bf18 --- /dev/null +++ b/apps/plugins/zxbox/zxvid_grey.c | |||
@@ -0,0 +1,97 @@ | |||
1 | #include "zxvid_com.h" | ||
2 | #if !defined HAVE_LCD_COLOR && defined USE_GRAY | ||
3 | /* | ||
4 | use for slightly different colors | ||
5 | #define N0 0x04 | ||
6 | #define N1 0x34 | ||
7 | |||
8 | #define B0 0x08 | ||
9 | #define B1 0x3F | ||
10 | */ | ||
11 | |||
12 | /* these ones are the same as for color targets ... may be tweak for greyscale? */ | ||
13 | #define N0 0x00 | ||
14 | #define N1 0xAA | ||
15 | |||
16 | #define B0 0x55 | ||
17 | #define B1 0xFF | ||
18 | static unsigned char graybuffer[LCD_HEIGHT*LCD_WIDTH] IBSS_ATTR; /* off screen buffer */ | ||
19 | |||
20 | struct rgb norm_colors[COLORNUM]={ | ||
21 | {0,0,0},{N0,N0,N1},{N1,N0,N0},{N1,N0,N1}, | ||
22 | {N0,N1,N0},{N0,N1,N1},{N1,N1,N0},{N1,N1,N1}, | ||
23 | |||
24 | {0x15,0x15,0x15},{B0,B0,B1},{B1,B0,B0},{B1,B0,B1}, | ||
25 | {B0,B1,B0},{B0,B1,B1},{B1,B1,B0},{B1,B1,B1} | ||
26 | }; | ||
27 | |||
28 | void init_spect_scr(void) | ||
29 | { | ||
30 | int i; | ||
31 | for(i = 0; i < 16; i++) | ||
32 | sp_colors[i] = 0.3*norm_colors[i].r + 0.59*norm_colors[i].g + 0.11*norm_colors[i].b; | ||
33 | if ( settings.invert_colors ){ | ||
34 | int i; | ||
35 | for ( i = 0 ; i < 16 ; i++ ) | ||
36 | sp_colors[i] = 255 - sp_colors[i]; | ||
37 | } | ||
38 | |||
39 | sp_image = (char *) &image_array; | ||
40 | spscr_init_mask_color(); | ||
41 | spscr_init_line_pointers(HEIGHT); | ||
42 | } | ||
43 | |||
44 | |||
45 | void update_screen(void) | ||
46 | { | ||
47 | char str[80]; | ||
48 | |||
49 | int y=0; | ||
50 | int x=0; | ||
51 | unsigned char* image; | ||
52 | int srcx, srcy=0; /* x / y coordinates in source image */ | ||
53 | image = sp_image + ( (Y_OFF)*(WIDTH) ) + X_OFF; | ||
54 | unsigned char* buf_ptr; | ||
55 | buf_ptr = (unsigned char*) &graybuffer; | ||
56 | for(y = 0; y < LCD_HEIGHT; y++) | ||
57 | { | ||
58 | srcx = 0; /* reset our x counter before each row... */ | ||
59 | for(x = 0; x < LCD_WIDTH; x++) | ||
60 | { | ||
61 | *buf_ptr=image[(srcx>>16)]; | ||
62 | srcx += X_STEP; /* move through source image */ | ||
63 | buf_ptr++; | ||
64 | } | ||
65 | srcy += Y_STEP; /* move through the source image... */ | ||
66 | image += (srcy>>16)*WIDTH; /* and possibly to the next row. */ | ||
67 | srcy &= 0xffff; /* set up the y-coordinate between 0 and 1 */ | ||
68 | } | ||
69 | |||
70 | #ifdef USE_BUFFERED_GRAY | ||
71 | gray_gray_bitmap(graybuffer, 0, 0, LCD_WIDTH, LCD_HEIGHT); | ||
72 | #endif | ||
73 | |||
74 | if ( settings.showfps ) { | ||
75 | int percent=0; | ||
76 | int TPF = HZ/50;/* ticks per frame */ | ||
77 | if ((*rb->current_tick-start_time) > TPF ) | ||
78 | percent = 100*video_frames/((*rb->current_tick-start_time)/TPF); | ||
79 | rb->snprintf(str,sizeof(str),"%d %%",percent); | ||
80 | #if defined USE_BUFFERED_GRAY | ||
81 | gray_putsxy(0,0,str); | ||
82 | #else | ||
83 | LOGF(str); | ||
84 | #endif | ||
85 | |||
86 | } | ||
87 | |||
88 | |||
89 | #if defined USE_BUFFERED_GRAY | ||
90 | gray_update(); | ||
91 | #else | ||
92 | gray_ub_gray_bitmap(graybuffer, 0, 0, LCD_WIDTH, LCD_HEIGHT); | ||
93 | #endif | ||
94 | |||
95 | } | ||
96 | |||
97 | #endif | ||