aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2012-05-08 22:54:40 +0000
committerDimitri Sokolyuk <demon@dim13.org>2012-05-08 22:54:40 +0000
commit625200d796e6652e084ad44563234868a87b697e (patch)
treea9e7d35f28c69602b7f1b91259781ca392c0b92b
parentf953c1d4335dfc861d05b2287f228c9ac21f07f8 (diff)
add blinking text
-rw-r--r--gui.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/gui.c b/gui.c
index 8e6be46..9a4dd06 100644
--- a/gui.c
+++ b/gui.c
@@ -15,6 +15,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#include <sys/time.h>
#include <SDL.h>
#include <SDL_image.h>
#include <err.h>
@@ -67,18 +68,22 @@ getpixel(SDL_Surface *s, int x, int y)
}
void
-drawglyph(SDL_Surface *s, int x, int y, unsigned short *m)
+drawglyph(SDL_Surface *s, int x, int y, unsigned short *m, int usec)
{
SDL_Rect to;
Uint8 color[2], c, i;
- unsigned short ch, *p;
+ unsigned short ch, blink, *p;
ch = m[DISP + y * 32 + x];
color[0] = (ch >> 8) & 0x0f; /* bg */
color[1] = (ch >> 12) & 0x0f; /* fg */
+ blink = ch & 0x80;
ch = (ch & 0x7f) << 1;
p = &m[CHARS + ch];
+ if (blink && (usec / 500000) % 2)
+ color[1] = color[0];
+
to.w = gl.w;
to.h = gl.h;
to.x = draw.x + x * to.w;
@@ -175,6 +180,7 @@ void
guiemu(struct context *c)
{
int x, y, cnt, n = 0;
+ struct timeval tv;
screen = SDL_SetVideoMode(real.w, real.h, 8, SDL_HWSURFACE|SDL_HWPALETTE);
SDL_SetColors(screen, color, 0, 16);
@@ -190,6 +196,8 @@ guiemu(struct context *c)
if ((n += cnt) < 100)
continue;
+ gettimeofday(&tv, NULL);
+
n = 0;
if (SDL_MUSTLOCK(screen) && SDL_LockSurface(screen))
@@ -199,7 +207,7 @@ guiemu(struct context *c)
for (x = 0; x < 32; x++)
for (y = 0; y < 12; y++)
- drawglyph(scratch, x, y, c->mem);
+ drawglyph(scratch, x, y, c->mem, tv.tv_usec);
SDL_SoftStretch(scratch, &scr, screen, &real);