10 #define BG_FILENAME "data/grise.png"
13 #define MAX_SCROLL (backgroundW - fb_width - MIN_SCROLL)
15 static int init(void);
16 static void destroy(void);
17 static void start(long trans_time);
18 static void stop(long trans_time);
19 static void draw(void);
21 static void convert32To16(unsigned int *src32, unsigned short *dst16, unsigned int pixelCount);
23 static unsigned short *background = 0;
24 static unsigned int backgroundW = 0;
25 static unsigned int backgroundH = 0;
27 static struct screen scr = {
36 struct screen *mike_screen(void)
44 if (!(background = img_load_pixels(BG_FILENAME, &backgroundW, &backgroundH, IMG_FMT_RGBA32))) {
45 fprintf(stderr, "failed to load image " BG_FILENAME "\n");
49 /* Convert to 16bpp */
50 convert32To16((unsigned int*)background, background, backgroundW * backgroundH);
55 static void destroy(void)
57 //img_free_pixels(background);
60 static void start(long trans_time)
65 static void stop(long trans_time)
69 static void draw(void)
71 int scroll = MIN_SCROLL + (MAX_SCROLL - MIN_SCROLL) * mouse_x / fb_width;
72 unsigned short *dst = fb_pixels;
73 unsigned short *src = background + 2 * scroll;
77 for (scanline = 0; scanline < fb_height; scanline++) {
78 memcpy(dst, src, fb_width * 2);
84 /* src and dst can be the same */
85 static void convert32To16(unsigned int *src32, unsigned short *dst16, unsigned int pixelCount) {
89 *dst16++ = ((p << 8) & 0xF800) /* R */
90 | ((p >> 5) & 0x07E0) /* G */
91 | ((p >> 19) & 0x001F); /* B */