summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2016-03-14 23:01:38 +0100
committerDaniel Friesel <derf@finalrewind.org>2016-03-14 23:01:56 +0100
commite9d56db11660142304f3415a30ece02ae672d242 (patch)
treef48c76b14db4898f1aede2cdc9a9c3997d1959fe
parentd30204f17d8c7e295df17c290d9f690996e44556 (diff)
Fix scrolling with direction==1
-rw-r--r--src/display.cc71
-rw-r--r--src/display.h2
-rw-r--r--src/system.cc1
3 files changed, 54 insertions, 20 deletions
diff --git a/src/display.cc b/src/display.cc
index 025ebbf..f06b5e3 100644
--- a/src/display.cc
+++ b/src/display.cc
@@ -82,16 +82,16 @@ void Display::update() {
}
}
- if (current_anim->direction == 0)
- glyph_addr = (uint8_t *)pgm_read_ptr(&font[current_anim->data[str_pos]]);
- else
- glyph_addr = (uint8_t *)pgm_read_ptr(&font[current_anim->data[current_anim->length - 1 - str_pos]]); // XXX Broken by str_chunk changes, FIXME!
+ glyph_addr = (uint8_t *)pgm_read_ptr(&font[current_anim->data[str_pos]]);
glyph_len = pgm_read_byte(&glyph_addr[0]);
char_pos++;
if (char_pos > glyph_len) {
char_pos = 0;
- str_pos++;
+ if (current_anim->direction == 0)
+ str_pos++;
+ else
+ str_pos--;
}
if (current_anim->direction == 0) {
@@ -114,26 +114,52 @@ void Display::update() {
}
str_pos += 8;
}
- if ((current_anim->length >= 128) && (str_pos >= 128)) {
- str_pos = 0;
- str_chunk++;
- storage.loadChunk(str_chunk, current_anim->data);
- }
- if ((str_chunk == (current_anim->length / 128))
- && (str_pos >= (current_anim->length % 128))) {
- str_chunk = 0;
- str_pos = 0;
- if (current_anim->delay > 0) {
- status = PAUSED;
- }
- if (current_anim->length >= 128) {
+ if (current_anim->direction == 0) {
+ if ((current_anim->length > 128) && (str_pos >= 128)) {
+ str_pos = 0;
+ str_chunk++;
storage.loadChunk(str_chunk, current_anim->data);
}
+ if ((str_chunk == ((current_anim->length - 1) / 128))
+ && (str_pos > ((current_anim->length - 1) % 128))) {
+ str_chunk = 0;
+ str_pos = 0;
+ if (current_anim->delay > 0) {
+ status = PAUSED;
+ }
+ if (current_anim->length > 128) {
+ storage.loadChunk(str_chunk, current_anim->data);
+ }
+ }
+ } else {
+ if (str_pos >= 128) {
+ if (str_chunk == 0) {
+ if (current_anim->length > 128) {
+ str_chunk = (current_anim->length - 1) / 128;
+ storage.loadChunk(str_chunk, current_anim->data);
+ }
+ if (current_anim->delay > 0) {
+ str_pos = 0;
+ status = PAUSED;
+ } else {
+ str_pos = (current_anim->length - 1) % 128;
+ }
+ } else {
+ str_chunk--;
+ storage.loadChunk(str_chunk, current_anim->data);
+ str_pos = 127;
+ }
+ }
}
} else if (status == PAUSED) {
str_pos++;
if (str_pos >= current_anim->delay) {
- str_pos = 0;
+ if (current_anim->direction == 0)
+ str_pos = 0;
+ else if (current_anim->length <= 128)
+ str_pos = current_anim->length - 1;
+ else
+ str_pos = 127;
status = RUNNING;
}
}
@@ -155,6 +181,13 @@ void Display::show(animation_t *anim)
{
current_anim = anim;
reset();
+ if (current_anim->direction == 1) {
+ if (current_anim->length > 128) {
+ str_chunk = (current_anim->length - 1) / 128;
+ storage.loadChunk(str_chunk, current_anim->data);
+ }
+ str_pos = (current_anim->length - 1) % 128;
+ }
}
/*
diff --git a/src/display.h b/src/display.h
index b42c69e..a6c9024 100644
--- a/src/display.h
+++ b/src/display.h
@@ -48,7 +48,7 @@ struct animation {
uint8_t delay;
/**
- * Scroll mode / direction. Not yet supported.
+ * Scroll mode / direction. Must be set to 0 if type != TEXT.
*/
uint8_t direction;
diff --git a/src/system.cc b/src/system.cc
index bf18003..e0765c2 100644
--- a/src/system.cc
+++ b/src/system.cc
@@ -88,6 +88,7 @@ void System::loadPattern_buf(uint8_t *pattern)
} else if (active_anim.type == AnimationType::FRAMES) {
active_anim.speed = ((pattern[2] & 0x0f) << 4) + 15;
active_anim.delay = (pattern[3] & 0x0f) << 2;
+ active_anim.direction = 0;
}
active_anim.data = pattern + 4;