#include <stdlib.h>
#include "draw.h"


extern struct {unsigned char x, y;} xy_char[];
extern int xy_char_end[256];

char message[] = "Emergent Property: Unique properties that \"emerge\" when "
"component objects are joined together in constraining relations to "
"\"construct\" a higher level aggregate object. Emergent properties are the "
"inherent functional characteristics of an aggregate object. They are essence "
"of its existence -- without them, there is no aggregate object.";

int main(void) {
    xy_init();
    xy_factor = 125;
    int sz = strlen(message);
    while(1) {
        int d=0;
        int x=0, y=0;
        for(y=256-32; y>=0; y-=16) {
            for(x=0; x<256; x+=8) {
                int c = d < sz ? message[d] : ' ';
                int i = xy_char_end[c-1];
                int end = xy_char_end[c];
                // printf("%c %d %d\n", c, i, end);
                for(;i<end; i++) {
                    xy_draw_pixel(x + xy_char[i].x, y + xy_char[i].y);
                }
                d++;
            }
        }
        xy_flipscreen();
        sleep(1);
    }
}

