aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2012-04-25 18:13:12 +0000
committerDimitri Sokolyuk <demon@dim13.org>2012-04-25 18:13:12 +0000
commit1b8f76879db1493df0a8f5db462cef8c895edec0 (patch)
tree1e520da447f6b9c9ec7b38cdb52af736d30e2176
parentbfef4245e3df75b6bde901d9abea8c45472d4dbd (diff)
add screen locking
-rw-r--r--gui.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/gui.c b/gui.c
index 9218480..cd98a38 100644
--- a/gui.c
+++ b/gui.c
@@ -96,18 +96,6 @@ drawglyph(SDL_Surface *s, int x, int y, unsigned short *m)
}
}
-void
-drawscreen(SDL_Surface *s, unsigned short *m)
-{
- int x, y;
-
- SDL_FillRect(s, &scr, m[BORDER] & 0x0f);
-
- for (x = 0; x < 32; x++)
- for (y = 0; y < 12; y++)
- drawglyph(s, x, y, m);
-}
-
int
keyboard(unsigned short *m)
{
@@ -186,7 +174,7 @@ loadfont(unsigned short *m, char *font)
void
guiemu(unsigned short *m, unsigned short *r)
{
- int c, n = 0;
+ int x, y, c, n = 0;
screen = SDL_SetVideoMode(real.w, real.h, 8, SDL_HWSURFACE|SDL_HWPALETTE);
SDL_SetColors(screen, color, 0, 16);
@@ -199,11 +187,23 @@ guiemu(unsigned short *m, unsigned short *r)
while ((c = step(m, r)) != -1) {
if ((n += c) < 100)
continue;
- drawscreen(scratch, m);
+
+ if (SDL_MUSTLOCK(screen) && SDL_LockSurface(screen))
+ continue;
+
+ SDL_FillRect(scratch, &scr, m[BORDER] & 0x0f);
+
+ for (x = 0; x < 32; x++)
+ for (y = 0; y < 12; y++)
+ drawglyph(scratch, x, y, m);
SDL_SoftStretch(scratch, &scr, screen, &real);
+
SDL_Flip(screen);
+ if (SDL_MUSTLOCK(screen))
+ SDL_UnlockSurface(screen);
+
n = 0;
if (keyboard(m) == -1)
break;