diff options
Diffstat (limited to 'apps/plugins/zxbox/zxvid_2bpp.c')
-rw-r--r-- | apps/plugins/zxbox/zxvid_2bpp.c | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/apps/plugins/zxbox/zxvid_2bpp.c b/apps/plugins/zxbox/zxvid_2bpp.c new file mode 100644 index 0000000000..0a4519e0ac --- /dev/null +++ b/apps/plugins/zxbox/zxvid_2bpp.c | |||
@@ -0,0 +1,117 @@ | |||
1 | #include "zxvid_com.h" | ||
2 | |||
3 | #ifndef USE_GREY | ||
4 | /* screen routines for greyscale targets not using greyscale lib */ | ||
5 | |||
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 | ||
10 | }; | ||
11 | #elif LCD_PIXELFORMAT == VERTICAL_PACKING | ||
12 | fb_data pixmask[4] ICONST_ATTR = { | ||
13 | 0x03, 0x0C, 0x30, 0xC0 | ||
14 | }; | ||
15 | #elif LCD_PIXELFORMAT == VERTICAL_INTERLEAVED | ||
16 | fb_data pixmask[8] ICONST_ATTR = { | ||
17 | 0x0101, 0x0202, 0x0404, 0x0808, 0x1010, 0x2020, 0x4040, 0x8080 | ||
18 | }; | ||
19 | fb_data pixval[4] ICONST_ATTR = { | ||
20 | 0x0000, 0x0001, 0x0100, 0x0101 | ||
21 | }; | ||
22 | #endif | ||
23 | |||
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 | ||
27 | }; | ||
28 | |||
29 | void init_spect_scr(void) | ||
30 | { | ||
31 | int i; | ||
32 | unsigned mask = settings.invert_colors ? 0 : 3; | ||
33 | |||
34 | for(i = 0; i < 16; i++) | ||
35 | sp_colors[i] = graylevels[i] ^ mask; | ||
36 | |||
37 | sp_image = (char *) &image_array; | ||
38 | spscr_init_mask_color(); | ||
39 | spscr_init_line_pointers(HEIGHT); | ||
40 | |||
41 | } | ||
42 | void update_screen(void) | ||
43 | { | ||
44 | char str[80]; | ||
45 | |||
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++) | ||
55 | { | ||
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++) | ||
59 | { | ||
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 */ | ||
63 | } | ||
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 */ | ||
67 | } | ||
68 | #elif LCD_PIXELFORMAT == VERTICAL_PACKING | ||
69 | int shift; | ||
70 | for(y = 0; y < LCD_HEIGHT; y++) | ||
71 | { | ||
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++) | ||
77 | { | ||
78 | frameb[x] = (frameb[x] & mask) | ((image[(srcx>>16)]&0x3) << shift ); | ||
79 | srcx += X_STEP; /* move through source image */ | ||
80 | } | ||
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 */ | ||
84 | } | ||
85 | #elif LCD_PIXELFORMAT == VERTICAL_INTERLEAVED | ||
86 | int shift; | ||
87 | for(y = 0; y < LCD_HEIGHT; y++) | ||
88 | { | ||
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++) | ||
94 | { | ||
95 | frameb[x] = (frameb[x] & mask) | (pixval[image[(srcx>>16)]&0x3] << shift ); | ||
96 | srcx += X_STEP; /* move through source image */ | ||
97 | } | ||
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 */ | ||
101 | } | ||
102 | #endif | ||
103 | |||
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); | ||
111 | } | ||
112 | |||
113 | |||
114 | rb -> lcd_update(); | ||
115 | } | ||
116 | |||
117 | #endif /* !USE_GREY */ | ||