aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2012-04-22 20:18:31 +0000
committerDimitri Sokolyuk <demon@dim13.org>2012-04-22 20:18:31 +0000
commit7cf25684f35a805078bfe246bbeeff3299517921 (patch)
treed1e8f2e0f005a29588e7393e9f27655e14024099
parent5907729f75c49763d3950cd13c8ab43836b37279 (diff)
simplify
-rw-r--r--gui.c23
1 files changed, 8 insertions, 15 deletions
diff --git a/gui.c b/gui.c
index fe22b9f..1535c26 100644
--- a/gui.c
+++ b/gui.c
@@ -59,26 +59,26 @@ setpixel(SDL_Surface *s, int x, int y, Uint8 c)
}
void
-mkglyph(SDL_Surface *g, unsigned char ch, Uint8 fg, Uint8 bg, unsigned short *m)
+drawglyph(SDL_Surface *screen, SDL_Rect to,
+ unsigned char ch, Uint8 fg, Uint8 bg, unsigned short *m)
{
Uint8 c;
int i;
- ch &= 0x7f;
- ch <<= 1;
+ ch = (ch & 0x7f) << 1;
for (i = 0; i < 8; i++) {
c = m[CHARS + ch] & (0x0100 << i) ? fg : bg;
- setpixel(g, 0, i, c);
+ setpixel(screen, to.x + 0, to.y + i, c);
c = m[CHARS + ch] & (0x0001 << i) ? fg : bg;
- setpixel(g, 1, i, c);
+ setpixel(screen, to.x + 1, to.y + i, c);
c = m[CHARS + ch + 1] & (0x0100 << i) ? fg : bg;
- setpixel(g, 2, i, c);
+ setpixel(screen, to.x + 2, to.y + i, c);
c = m[CHARS + ch + 1] & (0x0001 << i) ? fg : bg;
- setpixel(g, 3, i, c);
+ setpixel(screen, to.x + 3, to.y + i, c);
}
}
@@ -123,7 +123,6 @@ setfont(unsigned short *m)
void
guiemu(unsigned short *m, unsigned short *r)
{
- SDL_Surface *glyph;
SDL_Rect to;
Uint8 fg, bg;
SDL_Event event;
@@ -132,9 +131,6 @@ guiemu(unsigned short *m, unsigned short *r)
screen = SDL_SetVideoMode(scr.w, scr.h, 8, SDL_HWSURFACE|SDL_HWPALETTE);
SDL_SetColors(screen, color, 0, 16);
- glyph = SDL_CreateRGBSurface(SDL_HWSURFACE|SDL_HWPALETTE, gl.w, gl.h, 8, 0, 0, 0, 0);
- SDL_SetColors(glyph, color, 0, 16);
-
setfont(m);
to.w = gl.w;
@@ -157,9 +153,7 @@ guiemu(unsigned short *m, unsigned short *r)
bg = (ch >> 8) & 0x0f;
fg = (ch >> 12) & 0x0f;
- mkglyph(glyph, ch, fg, bg, m);
-
- SDL_BlitSurface(glyph, &gl, screen, &to);
+ drawglyph(screen, to, ch, fg, bg, m);
}
}
@@ -197,6 +191,5 @@ guiemu(unsigned short *m, unsigned short *r)
}
leave:
- SDL_FreeSurface(glyph);
SDL_FreeSurface(screen);
}