ZXBox: Clean up display init. Saves ~1KB on colour targets, and 4KB (coldfire).....
[kugel-rb.git] / apps / plugins / zxbox / zxvid_grey.c
blobd713eba4b5587886b43ac79c10ef80734db9edaf
1 #include "zxvid_com.h"
3 #ifdef USE_GREY
5 #define N0 0x00
6 #define N1 0xC0
7 #define B0 0x00
8 #define B1 0xFF
10 static unsigned char graybuffer[LCD_HEIGHT*LCD_WIDTH] IBSS_ATTR; /* off screen buffer */
12 static const unsigned char graylevels[16] = {
13 N0, (6*N0+1*N1)/7, (5*N0+2*N1)/7, (4*N0+3*N1)/7,
14 (3*N0+4*N1)/7, (2*N0+5*N1)/7, (1*N0+6*N1)/7, N1,
15 B0, (6*B0+1*B1)/7, (5*B0+2*B1)/7, (4*B0+3*B1)/7,
16 (3*B0+4*B1)/7, (2*B0+5*B1)/7, (1*B0+6*B1)/7, B1
19 void init_spect_scr(void)
21 int i;
22 unsigned mask = settings.invert_colors ? 0xFF : 0;
24 for(i = 0; i < 16; i++)
25 sp_colors[i] = graylevels[i] ^ mask;
27 sp_image = (char *) &image_array;
28 spscr_init_mask_color();
29 spscr_init_line_pointers(HEIGHT);
33 void update_screen(void)
35 char str[80];
37 int y=0;
38 int x=0;
39 unsigned char* image;
40 int srcx, srcy=0; /* x / y coordinates in source image */
41 image = sp_image + ( (Y_OFF)*(WIDTH) ) + X_OFF;
42 unsigned char* buf_ptr;
43 buf_ptr = graybuffer;
44 for(y = 0; y < LCD_HEIGHT; y++)
46 srcx = 0; /* reset our x counter before each row... */
47 for(x = 0; x < LCD_WIDTH; x++)
49 *buf_ptr=image[(srcx>>16)];
50 srcx += X_STEP; /* move through source image */
51 buf_ptr++;
53 srcy += Y_STEP; /* move through the source image... */
54 image += (srcy>>16)*WIDTH; /* and possibly to the next row. */
55 srcy &= 0xffff; /* set up the y-coordinate between 0 and 1 */
58 #ifdef USE_BUFFERED_GREY
59 grey_gray_bitmap(graybuffer, 0, 0, LCD_WIDTH, LCD_HEIGHT);
60 #endif
62 if ( settings.showfps ) {
63 int percent=0;
64 int TPF = HZ/50;/* ticks per frame */
65 if ((*rb->current_tick-start_time) > TPF )
66 percent = 100*video_frames/((*rb->current_tick-start_time)/TPF);
67 rb->snprintf(str,sizeof(str),"%d %%",percent);
68 #if defined USE_BUFFERED_GREY
69 grey_putsxy(0,0,str);
70 #else
71 LOGF(str);
72 #endif
77 #if defined USE_BUFFERED_GREY
78 grey_update();
79 #else
80 grey_ub_gray_bitmap(graybuffer, 0, 0, LCD_WIDTH, LCD_HEIGHT);
81 #endif
85 #endif /* USE_GREY */