aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hw/arm/musicpal.c64
1 files changed, 24 insertions, 40 deletions
diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
index 6aec84aeed..9cebece2de 100644
--- a/hw/arm/musicpal.c
+++ b/hw/arm/musicpal.c
@@ -512,53 +512,37 @@ static uint8_t scale_lcd_color(musicpal_lcd_state *s, uint8_t col)
}
}
-#define SET_LCD_PIXEL(depth, type) \
-static inline void glue(set_lcd_pixel, depth) \
- (musicpal_lcd_state *s, int x, int y, type col) \
-{ \
- int dx, dy; \
- DisplaySurface *surface = qemu_console_surface(s->con); \
- type *pixel = &((type *) surface_data(surface))[(y * 128 * 3 + x) * 3]; \
-\
- for (dy = 0; dy < 3; dy++, pixel += 127 * 3) \
- for (dx = 0; dx < 3; dx++, pixel++) \
- *pixel = col; \
+static inline void set_lcd_pixel32(musicpal_lcd_state *s,
+ int x, int y, uint32_t col)
+{
+ int dx, dy;
+ DisplaySurface *surface = qemu_console_surface(s->con);
+ uint32_t *pixel =
+ &((uint32_t *) surface_data(surface))[(y * 128 * 3 + x) * 3];
+
+ for (dy = 0; dy < 3; dy++, pixel += 127 * 3) {
+ for (dx = 0; dx < 3; dx++, pixel++) {
+ *pixel = col;
+ }
+ }
}
-SET_LCD_PIXEL(8, uint8_t)
-SET_LCD_PIXEL(16, uint16_t)
-SET_LCD_PIXEL(32, uint32_t)
static void lcd_refresh(void *opaque)
{
musicpal_lcd_state *s = opaque;
- DisplaySurface *surface = qemu_console_surface(s->con);
int x, y, col;
- switch (surface_bits_per_pixel(surface)) {
- case 0:
- return;
-#define LCD_REFRESH(depth, func) \
- case depth: \
- col = func(scale_lcd_color(s, (MP_LCD_TEXTCOLOR >> 16) & 0xff), \
- scale_lcd_color(s, (MP_LCD_TEXTCOLOR >> 8) & 0xff), \
- scale_lcd_color(s, MP_LCD_TEXTCOLOR & 0xff)); \
- for (x = 0; x < 128; x++) { \
- for (y = 0; y < 64; y++) { \
- if (s->video_ram[x + (y/8)*128] & (1 << (y % 8))) { \
- glue(set_lcd_pixel, depth)(s, x, y, col); \
- } else { \
- glue(set_lcd_pixel, depth)(s, x, y, 0); \
- } \
- } \
- } \
- break;
- LCD_REFRESH(8, rgb_to_pixel8)
- LCD_REFRESH(16, rgb_to_pixel16)
- LCD_REFRESH(32, (is_surface_bgr(surface) ?
- rgb_to_pixel32bgr : rgb_to_pixel32))
- default:
- hw_error("unsupported colour depth %i\n",
- surface_bits_per_pixel(surface));
+ col = rgb_to_pixel32(scale_lcd_color(s, (MP_LCD_TEXTCOLOR >> 16) & 0xff),
+ scale_lcd_color(s, (MP_LCD_TEXTCOLOR >> 8) & 0xff),
+ scale_lcd_color(s, MP_LCD_TEXTCOLOR & 0xff));
+ for (x = 0; x < 128; x++) {
+ for (y = 0; y < 64; y++) {
+ if (s->video_ram[x + (y / 8) * 128] & (1 << (y % 8))) {
+ set_lcd_pixel32(s, x, y, col);
+ } else {
+ set_lcd_pixel32(s, x, y, 0);
+ }
+ }
}
dpy_gfx_update(s->con, 0, 0, 128*3, 64*3);