10 #define BG_FILENAME "data/grise.png"
12 static int init(void);
13 static void destroy(void);
14 static void start(long trans_time);
15 static void stop(long trans_time);
16 static void draw(void);
18 static void convert32To16(unsigned int *src32, unsigned short *dst16, unsigned int pixelCount);
20 static unsigned short *background = 0;
21 static unsigned int backgroundW = 0;
22 static unsigned int backgroundH = 0;
24 static struct screen scr = {
33 struct screen *mike_screen(void)
41 if (!(background = img_load_pixels(BG_FILENAME, &backgroundW, &backgroundH, IMG_FMT_RGBA32))) {
42 fprintf(stderr, "failed to load image " BG_FILENAME "\n");
46 /* Convert to 16bpp */
47 convert32To16((unsigned int*)background, background, backgroundW * backgroundH);
52 static void destroy(void)
54 img_free_pixels(background);
57 static void start(long trans_time)
62 static void stop(long trans_time)
66 static void draw(void)
68 unsigned short *pixels = fb_pixels;
71 for (j = 0; j < fb_height; j++) {
72 for (i = 0; i < fb_width; i++) {
77 memcpy(fb_pixels, background, backgroundW * backgroundH * 2);
80 /* src and dst can be the same */
81 static void convert32To16(unsigned int *src32, unsigned short *dst16, unsigned int pixelCount) {
85 *dst16++ = ((p << 8) & 0xF800) /* R */
86 | ((p >> 5) & 0x07E0) /* G */
87 | ((p >> 19) & 0x001F); /* B */