summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--glitchyclock.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/glitchyclock.c b/glitchyclock.c
index 8b3ca90..2a960fc 100644
--- a/glitchyclock.c
+++ b/glitchyclock.c
@@ -193,19 +193,23 @@ static gboolean draw_sig(GtkWidget *widget, cairo_t *cr, struct glitchyclock *gc
}
if ( cues[gc->cue].type == GLITCH_BACK ) {
- glitch = 1;
- duty = 0.5 + seconds_elapsed / 4;
- if ( duty > 1.0 ) {
- duty = 1.0;
- if ( !gc->flag ) {
- gc->base_minutes += cues[gc->cue].parameter;
- gc->base_hours += gc->base_minutes / 60;
- gc->base_minutes = gc->base_minutes % 60;
- gc->base_hours = gc->base_hours % 24;
+ if ( !gc->flag ) {
+ duty = 0.5 + seconds_elapsed / 4;
+ glitch = 1;
+ if ( duty > 1.0 ) {
+ duty = 1.0;
+ gc->real_time_last_reset += cues[gc->cue].parameter * 60;
+
+ /* The real_time_elapsed will now probably be
+ * negative (unless the clock glitched back by
+ * less than real_time_elapsed). To avoid
+ * negative numbers appearing, go back a whole
+ * day. Yes, I'm a dirty cheat. */
+ gc->real_time_last_reset -= 24*60*60;
gc->flag = 1;
- } else {
- glitch = 0;
}
+ } else {
+ glitch = 0;
}
}