Rearange menu of mpegplayer. Add new menu with "settings" and "quit", and remove...
[kugel-rb.git] / apps / plugins / zxbox / zxvid_2bpp.c
blob0a4519e0ace7022405479d5af326b722f84c0ac5
1 #include "zxvid_com.h"
3 #ifndef USE_GREY
4 /* screen routines for greyscale targets not using greyscale lib */
6 #if LCD_PIXELFORMAT == HORIZONTAL_PACKING
7 #define FB_WIDTH ((LCD_WIDTH+3)/4)
8 fb_data pixmask[4] ICONST_ATTR = {
9 0xC0, 0x30, 0x0C, 0x03
11 #elif LCD_PIXELFORMAT == VERTICAL_PACKING
12 fb_data pixmask[4] ICONST_ATTR = {
13 0x03, 0x0C, 0x30, 0xC0
15 #elif LCD_PIXELFORMAT == VERTICAL_INTERLEAVED
16 fb_data pixmask[8] ICONST_ATTR = {
17 0x0101, 0x0202, 0x0404, 0x0808, 0x1010, 0x2020, 0x4040, 0x8080
19 fb_data pixval[4] ICONST_ATTR = {
20 0x0000, 0x0001, 0x0100, 0x0101
22 #endif
24 static const unsigned char graylevels[16] = {
25 0, 1, 1, 1, 2, 2, 3, 3,
26 0, 1, 1, 1, 2, 2, 3, 3
29 void init_spect_scr(void)
31 int i;
32 unsigned mask = settings.invert_colors ? 0 : 3;
34 for(i = 0; i < 16; i++)
35 sp_colors[i] = graylevels[i] ^ mask;
37 sp_image = (char *) &image_array;
38 spscr_init_mask_color();
39 spscr_init_line_pointers(HEIGHT);
42 void update_screen(void)
44 char str[80];
46 fb_data *frameb;
47 int y=0;
48 int x=0;
49 unsigned char* image;
50 int srcx, srcy=0; /* x / y coordinates in source image */
51 image = sp_image + ( (Y_OFF)*(WIDTH) ) + X_OFF;
52 unsigned mask;
53 #if LCD_PIXELFORMAT == HORIZONTAL_PACKING
54 for(y = 0; y < LCD_HEIGHT; y++)
56 frameb = rb->lcd_framebuffer + (y) * FB_WIDTH;
57 srcx = 0; /* reset our x counter before each row... */
58 for(x = 0; x < LCD_WIDTH; x++)
60 mask = ~pixmask[x & 3];
61 frameb[x >> 2] = (frameb[x >> 2] & mask) | ((image[(srcx>>16)]&0x3) << ((3-(x & 3 )) * 2 ));
62 srcx += X_STEP; /* move through source image */
64 srcy += Y_STEP; /* move through the source image... */
65 image += (srcy>>16)*WIDTH; /* and possibly to the next row. */
66 srcy &= 0xffff; /* set up the y-coordinate between 0 and 1 */
68 #elif LCD_PIXELFORMAT == VERTICAL_PACKING
69 int shift;
70 for(y = 0; y < LCD_HEIGHT; y++)
72 frameb = rb->lcd_framebuffer + (y/4) * LCD_WIDTH;
73 srcx = 0; /* reset our x counter before each row... */
74 shift = ((y & 3 ) * 2 );
75 mask = ~pixmask[y & 3];
76 for(x = 0; x < LCD_WIDTH; x++)
78 frameb[x] = (frameb[x] & mask) | ((image[(srcx>>16)]&0x3) << shift );
79 srcx += X_STEP; /* move through source image */
81 srcy += Y_STEP; /* move through the source image... */
82 image += (srcy>>16)*WIDTH; /* and possibly to the next row. */
83 srcy &= 0xffff; /* set up the y-coordinate between 0 and 1 */
85 #elif LCD_PIXELFORMAT == VERTICAL_INTERLEAVED
86 int shift;
87 for(y = 0; y < LCD_HEIGHT; y++)
89 frameb = rb->lcd_framebuffer + (y/8) * LCD_WIDTH;
90 srcx = 0; /* reset our x counter before each row... */
91 shift = (y & 7);
92 mask = ~pixmask[y & 7];
93 for(x = 0; x < LCD_WIDTH; x++)
95 frameb[x] = (frameb[x] & mask) | (pixval[image[(srcx>>16)]&0x3] << shift );
96 srcx += X_STEP; /* move through source image */
98 srcy += Y_STEP; /* move through the source image... */
99 image += (srcy>>16)*WIDTH; /* and possibly to the next row. */
100 srcy &= 0xffff; /* set up the y-coordinate between 0 and 1 */
102 #endif
104 if ( settings.showfps ) {
105 int percent=0;
106 int TPF = HZ/50;/* ticks per frame */
107 if ((*rb->current_tick-start_time) > TPF )
108 percent = 100*video_frames/((*rb->current_tick-start_time)/TPF);
109 rb->snprintf(str,sizeof(str),"%d %%",percent);
110 rb->lcd_putsxy(0,0,str);
114 rb -> lcd_update();
117 #endif /* !USE_GREY */