#include "marquee.h" #include marquee_t make_marquee(char* str) { marquee_t marquee; marquee.textLength = strlen(str); marquee.text = malloc(sizeof(char) * (marquee.textLength + 1)); strcpy(marquee.text, str); marquee.scrolledBy = 0; int pixelLength = marquee.textLength * 21; marquee.scrollMax = 60 + pixelLength; marquee.doesScroll = pixelLength > 128; return marquee; } void scroll_marquee(marquee_t* marquee, int increment) { //define the wrap point //calculate the new scroll amount int newScroll = marquee->scrolledBy + increment; marquee->scrolledBy = newScroll <= marquee->scrollMax ? newScroll : 0; }