From: Andrzej Zaborowski <balrogg@gmail.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [4252] Fix MusicPal LCD on non-32 bpp displays or with -nographic.
Date: Fri, 25 Apr 2008 00:59:43 +0000 [thread overview]
Message-ID: <E1JpCHv-0001dL-SZ@cvs.savannah.gnu.org> (raw)
Revision: 4252
http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4252
Author: balrog
Date: 2008-04-25 00:59:43 +0000 (Fri, 25 Apr 2008)
Log Message:
-----------
Fix MusicPal LCD on non-32 bpp displays or with -nographic.
Prevents an immediate segfault.
Modified Paths:
--------------
trunk/hw/musicpal.c
Modified: trunk/hw/musicpal.c
===================================================================
--- trunk/hw/musicpal.c 2008-04-24 23:40:55 UTC (rev 4251)
+++ trunk/hw/musicpal.c 2008-04-25 00:59:43 UTC (rev 4252)
@@ -759,32 +759,50 @@
}
}
-static void set_lcd_pixel(musicpal_lcd_state *s, int x, int y, int col)
-{
- int dx, dy;
-
- for (dy = 0; dy < 3; dy++)
- for (dx = 0; dx < 3; dx++) {
- s->ds->data[(x*3 + dx + (y*3 + dy) * 128*3) * 4 + 0] =
- scale_lcd_color(col);
- s->ds->data[(x*3 + dx + (y*3 + dy) * 128*3) * 4 + 1] =
- scale_lcd_color(col >> 8);
- s->ds->data[(x*3 + dx + (y*3 + dy) * 128*3) * 4 + 2] =
- scale_lcd_color(col >> 16);
- }
+#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; \
+ type *pixel = &((type *) s->ds->data)[(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)
+#include "pixel_ops.h"
+
static void lcd_refresh(void *opaque)
{
musicpal_lcd_state *s = opaque;
- int x, y;
+ int x, y, col;
- 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_pixel(s, x, y, MP_LCD_TEXTCOLOR);
- else
- set_lcd_pixel(s, x, y, 0);
+ switch (s->ds->depth) {
+ case 0:
+ return;
+#define LCD_REFRESH(depth, func) \
+ case depth: \
+ col = func(scale_lcd_color((MP_LCD_TEXTCOLOR >> 16) & 0xff), \
+ scale_lcd_color((MP_LCD_TEXTCOLOR >> 8) & 0xff), \
+ scale_lcd_color(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, (s->ds->bgr ? rgb_to_pixel32bgr : rgb_to_pixel32))
+ default:
+ cpu_abort(cpu_single_env, "unsupported colour depth %i\n",
+ s->ds->depth);
+ }
dpy_update(s->ds, 0, 0, 128*3, 64*3);
}
reply other threads:[~2008-04-25 0:59 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1JpCHv-0001dL-SZ@cvs.savannah.gnu.org \
--to=balrogg@gmail.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).