aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2012-04-23 21:34:49 +0000
committerDimitri Sokolyuk <demon@dim13.org>2012-04-23 21:34:49 +0000
commitf92bb441463c201e605c737fb1a6203ce7daaf57 (patch)
treeccd96ade3546b4c48d5c3e448efea8dbe68c71eb
parent84686e20760914f5156ffc43f79efa284bfbe076 (diff)
less branches, update screen at least all 100 cycles
-rw-r--r--emu.c10
-rw-r--r--gui.c7
2 files changed, 9 insertions, 8 deletions
diff --git a/emu.c b/emu.c
index 8f1f773..8ec00dc 100644
--- a/emu.c
+++ b/emu.c
@@ -190,28 +190,28 @@ void
ife(unsigned short *a, unsigned short *b)
{
skip = !(*a == *b);
- cycle += skip ? 3 : 2;
+ cycle += 2 + skip;
}
void
ifn(unsigned short *a, unsigned short *b)
{
skip = !(*a != *b);
- cycle += skip ? 3 : 2;
+ cycle += 2 + skip;
}
void
ifg(unsigned short *a, unsigned short *b)
{
skip = !(*a > *b);
- cycle += skip ? 3 : 2;
+ cycle += 2 + skip;
}
void
ifb(unsigned short *a, unsigned short *b)
{
skip = !(*a & *b);
- cycle += skip ? 3 : 2;
+ cycle += 2 + skip;
}
void
@@ -325,5 +325,5 @@ step(unsigned short *m, unsigned short *r)
usleep(10 * cycle); /* 100kHz */
- return 0;
+ return cycle;
}
diff --git a/gui.c b/gui.c
index 1eff06b..c1376ba 100644
--- a/gui.c
+++ b/gui.c
@@ -196,17 +196,18 @@ setfont(unsigned short *m)
void
guiemu(unsigned short *m, unsigned short *r)
{
- int n = 0;
+ int c, n = 0;
screen = SDL_SetVideoMode(scr.w, scr.h, 8, SDL_HWSURFACE|SDL_HWPALETTE);
SDL_SetColors(screen, color, 0, 16);
setfont(m);
- while (step(m, r) != -1) {
- if (++n % 100)
+ while ((c = step(m, r)) != -1) {
+ if ((n += c) < 100)
continue;
drawscreen(screen, m);
+ n = 0;
if (keyboard(m) == -1)
break;
}