diff options
Diffstat (limited to 'apps/plugins/zxbox/zxvid_16bpp.c')
-rw-r--r-- | apps/plugins/zxbox/zxvid_16bpp.c | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/apps/plugins/zxbox/zxvid_16bpp.c b/apps/plugins/zxbox/zxvid_16bpp.c new file mode 100644 index 0000000000..235efcbcb2 --- /dev/null +++ b/apps/plugins/zxbox/zxvid_16bpp.c | |||
@@ -0,0 +1,99 @@ | |||
1 | #include "zxvid_com.h" | ||
2 | |||
3 | #if LCD_DEPTH > 4 | ||
4 | /* screen routines for color targets */ | ||
5 | |||
6 | /* | ||
7 | use for slightly different colors | ||
8 | #define N0 0x04 | ||
9 | #define N1 0x34 | ||
10 | |||
11 | #define B0 0x08 | ||
12 | #define B1 0x3F | ||
13 | */ | ||
14 | |||
15 | #define N0 0x00 | ||
16 | #define N1 0xAA | ||
17 | |||
18 | #define B0 0x55 | ||
19 | #define B1 0xFF | ||
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 | |||
29 | /* since emulator uses array of bytes for screen representation | ||
30 | * short 16b colors won't fit there */ | ||
31 | short _16bpp_colors[16] IBSS_ATTR; | ||
32 | |||
33 | void init_spect_scr(void) | ||
34 | { | ||
35 | int i; | ||
36 | |||
37 | for(i = 0; i < 16; i++) | ||
38 | sp_colors[i] = i; | ||
39 | for(i = 0; i < 16; i++) | ||
40 | _16bpp_colors[i] = LCD_RGBPACK(norm_colors[i].r,norm_colors[i].g,norm_colors[i].b); | ||
41 | if ( settings.invert_colors ){ | ||
42 | for ( i = 0 ; i < 16 ; i++ ) | ||
43 | _16bpp_colors[i] = 0xFFFFFF - _16bpp_colors[i]; | ||
44 | } | ||
45 | sp_image = (char *) &image_array; | ||
46 | spscr_init_mask_color(); | ||
47 | spscr_init_line_pointers(HEIGHT); | ||
48 | |||
49 | } | ||
50 | |||
51 | void update_screen(void) | ||
52 | { | ||
53 | char str[80]; | ||
54 | fb_data *frameb; | ||
55 | |||
56 | int y=0; | ||
57 | |||
58 | #if LCD_HEIGHT >= ZX_HEIGHT && LCD_WIDTH >= ZX_WIDTH | ||
59 | byte *scrptr; | ||
60 | scrptr = (byte *) SPNM(image); | ||
61 | frameb = rb->lcd_framebuffer; | ||
62 | for ( y = 0 ; y < HEIGHT*WIDTH; y++ ){ | ||
63 | frameb[y] = _16bpp_colors[(unsigned)sp_image[y]]; | ||
64 | } | ||
65 | |||
66 | #else | ||
67 | int x=0; | ||
68 | int srcx, srcy=0; /* x / y coordinates in source image */ | ||
69 | unsigned char* image; | ||
70 | image = sp_image + ( (Y_OFF)*(WIDTH) ) + X_OFF; | ||
71 | frameb = rb->lcd_framebuffer; | ||
72 | for(y = 0; y < LCD_HEIGHT; y++) | ||
73 | { | ||
74 | srcx = 0; /* reset our x counter before each row... */ | ||
75 | for(x = 0; x < LCD_WIDTH; x++) | ||
76 | { | ||
77 | *frameb = _16bpp_colors[image[srcx>>16]]; | ||
78 | srcx += X_STEP; /* move through source image */ | ||
79 | frameb++; | ||
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 | |||
86 | #endif | ||
87 | if ( settings.showfps ) { | ||
88 | int percent=0; | ||
89 | int TPF = HZ/50;/* ticks per frame */ | ||
90 | if ((*rb->current_tick-start_time) > TPF ) | ||
91 | percent = 100*video_frames/((*rb->current_tick-start_time)/TPF); | ||
92 | rb->snprintf(str,sizeof(str),"%d %%",percent); | ||
93 | rb->lcd_putsxy(0,0,str); | ||
94 | } | ||
95 | rb -> lcd_update(); | ||
96 | } | ||
97 | |||
98 | |||
99 | #endif /* HAVE_LCD_COLOR */ | ||