summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2011-01-04 06:01:42 (GMT)
committerH. Peter Anvin <hpa@zytor.com>2011-01-04 06:01:42 (GMT)
commitc9686ce42cce59b4622370a3a5a0adc8673ab58a (patch)
treefa32de4bfd150ff530374950c3600a1d57b685dc
parentf253e8480fb27e48b66a1730eac29cf0653eafb8 (diff)
downloadgrv-c9686ce42cce59b4622370a3a5a0adc8673ab58a.zip
grv-c9686ce42cce59b4622370a3a5a0adc8673ab58a.tar.gz
grv-c9686ce42cce59b4622370a3a5a0adc8673ab58a.tar.bz2
grv-c9686ce42cce59b4622370a3a5a0adc8673ab58a.tar.xz
graphics.c: handle the pitch correctly, fix signedness errors
Use the pitch specified by the surface; don't just assume that we got what we wanted. Fix a few warnings.
-rw-r--r--graphics.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/graphics.c b/graphics.c
index aec7eec..519c06c 100644
--- a/graphics.c
+++ b/graphics.c
@@ -122,7 +122,7 @@ static void put_screen(int tx, int ty)
{
font_t *fontp;
font_t v;
- uint32_t *pixelp, fgp, bgp;
+ uint32_t *pixelp, *pixelr, fgp, bgp;
int x, y, z;
int attr;
int pxwid = current.dwidth + 1;
@@ -134,18 +134,22 @@ static void put_screen(int tx, int ty)
bgp = colors[(attr >> 4) & 7];
fgp = (bmask & attr) ? bgp : colors[attr & 15];
- pixelp = ((uint32_t *) rscreen->pixels) +
- ty*(FONT_XSIZE*FONT_YSIZE*TS_WIDTH) +
+ /*
+ * This assumes that either unaligned references are okay, or
+ * pitch will be a multiple of 4.
+ */
+ pixelr = ((uint32_t *) ((char *)rscreen->pixels + ty*rscreen->pitch)) +
tx*FONT_XSIZE;
-
+
for ( y = 0 ; y < FONT_YSIZE ; y++ ) {
+ pixelp = pixelr;
v = fontp[y];
for ( x = 0 ; x < FONT_XSIZE ; x++ ) {
for ( z = 0 ; z < pxwid ; z++ )
*pixelp++ = v & ((font_t)1 << (FONT_XSIZE-1)) ? fgp : bgp;
v <<= 1;
}
- pixelp += PX_WIDTH-pxwid*FONT_XSIZE;
+ pixelr = (uint32_t *)((char *)pixelr + rscreen->pitch);
}
}
@@ -249,7 +253,7 @@ void print(const char *str)
*/
void gprintf(const char *fmt, ...)
{
- unsigned char buffer[4096];
+ char buffer[4096];
va_list ap;
va_start(ap, fmt);
@@ -272,7 +276,7 @@ void lprint(int r, int c, const char *str)
*/
void lprintf(int r, int c, const char *fmt, ...)
{
- unsigned char buffer[4096];
+ char buffer[4096];
va_list ap;
locate(r,c);