More changes
[uccvend-snackrom.git] / ROM2 / display.c
index da51973..b05d33a 100644 (file)
@@ -23,11 +23,9 @@ void display_send_byte(char c);
 void display_reset();
 void display_update();
 
-void set_msg(char* newmsg, u8 wrap) {
-       char* dest = current_message;
+void append_msg(char* newmsg, u8 wrap) {
+       char* dest = current_message[msg_length];
        /* equivalent of a string copy */
-       /* while (dest++ = newmsg++); */
-       msg_length = 0;
        while (newmsg) {
                dest = newmsg;
                dest++;
@@ -35,6 +33,11 @@ void set_msg(char* newmsg, u8 wrap) {
                msg_length++;
        }
        wrap_mode = wrap;
+}
+
+void set_msg(char* newmsg, u8 wrap) {
+       msg_length = 0;
+       append_msg(newmsg, wrap);
        scroll_point = 0;
        display_update();
 }
@@ -43,16 +46,11 @@ void display_shift() {
        /* update the display for WRAP_SCROLL or WRAP_ALTERNATE modes */
        switch (wrap_mode) {
                case WRAP_SCROLL:
+               case WRAP_ALTERNATE:
                        scroll_point++;
                        if (scroll_point >= msg_length) scroll_point = 0;
                        display_update();
                        break;
-               case WRAP_ALTERNATE:
-                       scroll_point += 10;
-                       if (scroll_point >= msg_length) scroll_point = 0;
-                       /* the above means that only sets of multiples of 10 characters
-                        * are shown (excess ones are not) */
-                       display_update();
        }
 }
 
@@ -90,7 +88,9 @@ void display_update() {
        u8 i;
 
        for (i=0; i < 10; i++) {
-               display_buffer[i] = current_message[(i+scroll_point)%msg_length];
+               display_buffer[i] = current_message[
+                       (i+(wrap_mode==WRAP_ALTERNATE?scroll_point/10:scroll_point))
+                       %msg_length];
        }
 
        /* hmmm, will this cause some flickering of the display? */

UCC git Repository :: git.ucc.asn.au