|
@ -36,12 +36,12 @@ |
|
|
font fonts[MAX_FONTS]; |
|
|
font fonts[MAX_FONTS]; |
|
|
#define MAX_SPECIALCOLORS 3 |
|
|
#define MAX_SPECIALCOLORS 3 |
|
|
|
|
|
|
|
|
unsigned const char PROGMEM colorTable[MAX_SPECIALCOLORS*NUM_ROWS] = {1, 1, 2, 3, 3, 2, 1, 1, |
|
|
static const unsigned char PROGMEM colorTable[MAX_SPECIALCOLORS * NUM_ROWS] = {1, 1, 2, 3, 3, 2, 1, 1, |
|
|
3, 3, 2, 1, 1, 2, 3, 3, |
|
|
3, 3, 2, 1, 1, 2, 3, 3, |
|
|
3, 3, 2, 2, 3, 3, 2, 2 |
|
|
3, 3, 2, 2, 3, 3, 2, 2 |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
const char default_text[] PROGMEM = SCROLLTEXT_TEXT; |
|
|
static const char default_text[] PROGMEM = SCROLLTEXT_TEXT; |
|
|
char scrolltext_text[SCROLLTEXT_BUFFER_SIZE]; |
|
|
char scrolltext_text[SCROLLTEXT_BUFFER_SIZE]; |
|
|
|
|
|
|
|
|
/* Konzept
|
|
|
/* Konzept
|
|
@ -57,25 +57,26 @@ Wenn der Command abgearbeitet ist wird automatisch das nächste Token eingelesen |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unsigned char (*text_pixmap)[NUM_ROWS][LINEBYTES]; |
|
|
static unsigned char (*text_pixmap)[NUM_ROWS][LINEBYTES]; |
|
|
|
|
|
|
|
|
static void text_setpixel(pixel p, unsigned char value ){ |
|
|
static void text_setpixel(pixel p, unsigned char value) |
|
|
if(value){ |
|
|
{ |
|
|
(*text_pixmap)[p.y%NUM_ROWS][p.x/8] |= shl_table[p.x%8]; |
|
|
if (value) |
|
|
} |
|
|
(*text_pixmap)[p.y % NUM_ROWS][p.x / 8] |= shl_table[p.x % 8]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static void clear_text_pixmap(){ |
|
|
static void clear_text_pixmap() |
|
|
|
|
|
{ |
|
|
memset(text_pixmap, 0, NUM_ROWS * LINEBYTES); |
|
|
memset(text_pixmap, 0, NUM_ROWS * LINEBYTES); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static void update_pixmap(){ |
|
|
static void update_pixmap() |
|
|
for(unsigned char p = NUMPLANE; p--;){ |
|
|
{ |
|
|
|
|
|
for (unsigned char p = NUMPLANE; p--;) |
|
|
memcpy(&pixmap[p][0][0], text_pixmap, NUM_ROWS * LINEBYTES); |
|
|
memcpy(&pixmap[p][0][0], text_pixmap, NUM_ROWS * LINEBYTES); |
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
enum waitfor_e{ |
|
|
enum waitfor_e { |
|
|
wait_new, |
|
|
wait_new, |
|
|
wait_posy, |
|
|
wait_posy, |
|
|
wait_posx, |
|
|
wait_posx, |
|
@ -92,11 +93,11 @@ enum waitfor_e{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define DIRECTION_RIGHT 0x01 |
|
|
#define DIRECTION_RIGHT 0x01 |
|
|
#define DIRECTION_DOWN 0x02 |
|
|
#define DIRECTION_DOWN 0x02 |
|
|
|
|
|
|
|
|
struct blob_t_struct; |
|
|
struct blob_t_struct; |
|
|
typedef struct blob_t_struct{ |
|
|
typedef struct blob_t_struct { |
|
|
struct blob_t_struct * next, * last; |
|
|
struct blob_t_struct *next, *last; |
|
|
char *str; |
|
|
char *str; |
|
|
char *commands; |
|
|
char *commands; |
|
|
waitfor_e_t waitfor; |
|
|
waitfor_e_t waitfor; |
|
@ -113,37 +114,38 @@ typedef struct blob_t_struct{ |
|
|
unsigned char direction; |
|
|
unsigned char direction; |
|
|
unsigned int timer; |
|
|
unsigned int timer; |
|
|
|
|
|
|
|
|
const unsigned int* fontIndex; |
|
|
const unsigned int *fontIndex; |
|
|
const unsigned char* fontData; |
|
|
const unsigned char *fontData; |
|
|
unsigned char font_storebytes;/*bytes per char*/ |
|
|
unsigned char font_storebytes;/*bytes per char*/ |
|
|
unsigned char space; |
|
|
unsigned char space; |
|
|
#ifndef AVR |
|
|
#ifndef AVR |
|
|
char scrolltextBuffer[SCROLLTEXT_BUFFER_SIZE]; |
|
|
char scrolltextBuffer[SCROLLTEXT_BUFFER_SIZE]; |
|
|
#endif |
|
|
#endif |
|
|
}blob_t; |
|
|
} blob_t; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
/*
|
|
|
void showBlob(blob_t * blob){ |
|
|
void showBlob(blob_t *blob) |
|
|
unsigned char * str = blob->str; |
|
|
{ |
|
|
unsigned char tmp[200], x=0; |
|
|
unsigned char *str = blob->str; |
|
|
while(*str){ |
|
|
unsigned char tmp[200], x = 0; |
|
|
|
|
|
while (*str) { |
|
|
tmp[x++] = (*str++) + ' ' -1; |
|
|
tmp[x++] = (*str++) + ' ' -1; |
|
|
} |
|
|
} |
|
|
tmp[x] = 0; |
|
|
tmp[x] = 0; |
|
|
printf("this:\t%x\n",blob); |
|
|
printf("this:\t%x\n", blob); |
|
|
printf("last:\t%x\n",blob->last); |
|
|
printf("last:\t%x\n", blob->last); |
|
|
printf("next:\t%x\n",blob->next); |
|
|
printf("next:\t%x\n", blob->next); |
|
|
printf("str:\t%s\n",tmp); |
|
|
printf("str:\t%s\n", tmp); |
|
|
printf("cmd:\t%s\n",blob->commands); |
|
|
printf("cmd:\t%s\n", blob->commands); |
|
|
printf("sizex\t%d\n",blob->sizex); |
|
|
printf("sizex\t%d\n", blob->sizex); |
|
|
printf("posx\t%d\n",blob->posx); |
|
|
printf("posx\t%d\n", blob->posx); |
|
|
printf("posy\t%d\n",blob->posy); |
|
|
printf("posy\t%d\n", blob->posy); |
|
|
printf("tox\t%d\n",blob->tox); |
|
|
printf("tox\t%d\n", blob->tox); |
|
|
printf("toy\t%d\n",blob->toy); |
|
|
printf("toy\t%d\n", blob->toy); |
|
|
printf("delayy_rld\t%d\n",blob->delayx_rld); |
|
|
printf("delayy_rld\t%d\n", blob->delayx_rld); |
|
|
printf("delayx_rld\t%d\n",blob->delayy_rld); |
|
|
printf("delayx_rld\t%d\n", blob->delayy_rld); |
|
|
printf("timer\t%d\n",blob->timer); |
|
|
printf("timer\t%d\n", blob->timer); |
|
|
printf("\n"); |
|
|
printf("\n"); |
|
|
} |
|
|
} |
|
|
*/ |
|
|
*/ |
|
@ -152,125 +154,127 @@ void showBlob(blob_t * blob){ |
|
|
#define PW(a) pgm_read_word(&(a)) |
|
|
#define PW(a) pgm_read_word(&(a)) |
|
|
#define PB(a) pgm_read_byte(&(a)) |
|
|
#define PB(a) pgm_read_byte(&(a)) |
|
|
|
|
|
|
|
|
static unsigned int getLen(blob_t *blob) { |
|
|
static unsigned int getLen(blob_t *blob) |
|
|
|
|
|
{ |
|
|
unsigned char glyph; |
|
|
unsigned char glyph; |
|
|
unsigned int strLen = 0; |
|
|
unsigned int strLen = 0; |
|
|
unsigned char * str = (unsigned char*)blob->str; |
|
|
unsigned char *str = (unsigned char*) blob->str; |
|
|
uint8_t space = blob->space * blob->font_storebytes; |
|
|
uint8_t space = blob->space *blob->font_storebytes; |
|
|
|
|
|
|
|
|
while ((glyph = *str++)) { |
|
|
while ((glyph = *str++)) { |
|
|
glyph -= 1; |
|
|
glyph -= 1; |
|
|
strLen += PW(blob->fontIndex[glyph+1]) - PW(blob->fontIndex[glyph]); |
|
|
strLen += PW(blob->fontIndex[glyph + 1]) - PW(blob->fontIndex[glyph]); |
|
|
strLen += space; |
|
|
strLen += space; |
|
|
} |
|
|
} |
|
|
return strLen/blob->font_storebytes; |
|
|
return strLen / blob->font_storebytes; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static unsigned int getnum(blob_t * blob){ |
|
|
static unsigned int getnum(blob_t *blob) |
|
|
unsigned int num=0; |
|
|
{ |
|
|
|
|
|
unsigned int num = 0; |
|
|
unsigned char gotnum = 0; |
|
|
unsigned char gotnum = 0; |
|
|
|
|
|
|
|
|
while( (*blob->commands >= '0') && (*blob->commands <='9') ){ |
|
|
while ((*blob->commands >= '0') && (*blob->commands <= '9')) { |
|
|
gotnum = 1; |
|
|
gotnum = 1; |
|
|
num *= 10; |
|
|
num *= 10; |
|
|
num += *blob->commands - '0'; |
|
|
num += *blob->commands - '0'; |
|
|
blob->commands++; |
|
|
blob->commands++; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if(gotnum){ |
|
|
if (gotnum) |
|
|
return num; |
|
|
return num; |
|
|
}else{ |
|
|
else |
|
|
return 0xffff; |
|
|
return 0xffff; |
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
unsigned char blobNextCommand(blob_t * blob){ |
|
|
unsigned char blobNextCommand(blob_t *blob) |
|
|
|
|
|
{ |
|
|
unsigned int tmp; |
|
|
unsigned int tmp; |
|
|
unsigned char retval = 0; |
|
|
unsigned char retval = 0; |
|
|
while(*blob->commands != 0){ |
|
|
while (*blob->commands != 0) { |
|
|
switch (*blob->commands++){ |
|
|
switch (*blob->commands++) { |
|
|
case '<': |
|
|
case '<': |
|
|
blob->direction &= ~DIRECTION_RIGHT; |
|
|
blob->direction &= ~DIRECTION_RIGHT; |
|
|
if((tmp = getnum(blob)) != 0xFFFF){ |
|
|
if ((tmp = getnum(blob)) != 0xFFFF) { |
|
|
blob->delayx_rld = tmp; |
|
|
blob->delayx_rld = tmp; |
|
|
}else{ |
|
|
} else { |
|
|
blob->delayx_rld = SCROLL_X_SPEED; |
|
|
blob->delayx_rld = SCROLL_X_SPEED; |
|
|
} |
|
|
} |
|
|
blob->delayx = blob->delayx_rld; |
|
|
blob->delayx = blob->delayx_rld; |
|
|
break; |
|
|
break; |
|
|
case '>': |
|
|
case '>': |
|
|
blob->direction |= DIRECTION_RIGHT; |
|
|
blob->direction |= DIRECTION_RIGHT; |
|
|
if((tmp = getnum(blob)) != 0xFFFF){ |
|
|
if ((tmp = getnum(blob)) != 0xFFFF) { |
|
|
blob->delayx_rld = tmp; |
|
|
blob->delayx_rld = tmp; |
|
|
}else{ |
|
|
} else { |
|
|
blob->delayx_rld = SCROLL_X_SPEED; |
|
|
blob->delayx_rld = SCROLL_X_SPEED; |
|
|
} |
|
|
} |
|
|
blob->delayx = blob->delayx_rld; |
|
|
blob->delayx = blob->delayx_rld; |
|
|
break; |
|
|
break; |
|
|
case 'd': |
|
|
case 'd': |
|
|
blob->direction |= DIRECTION_DOWN; |
|
|
blob->direction |= DIRECTION_DOWN; |
|
|
if((tmp = getnum(blob)) != 0xFFFF){ |
|
|
if ((tmp = getnum(blob)) != 0xFFFF) { |
|
|
blob->delayy_rld = tmp; |
|
|
blob->delayy_rld = tmp; |
|
|
}else{ |
|
|
} else { |
|
|
blob->delayy_rld = SCROLL_Y_SPEED; |
|
|
blob->delayy_rld = SCROLL_Y_SPEED; |
|
|
} |
|
|
} |
|
|
blob->delayy = blob->delayy_rld; |
|
|
blob->delayy = blob->delayy_rld; |
|
|
break; |
|
|
break; |
|
|
case 'u': |
|
|
case 'u': |
|
|
blob->direction &= ~DIRECTION_DOWN; |
|
|
blob->direction &= ~DIRECTION_DOWN; |
|
|
if((tmp = getnum(blob)) != 0xFFFF){ |
|
|
if ((tmp = getnum(blob)) != 0xFFFF) { |
|
|
blob->delayy_rld = tmp; |
|
|
blob->delayy_rld = tmp; |
|
|
}else{ |
|
|
} else { |
|
|
blob->delayy_rld = SCROLL_Y_SPEED; |
|
|
blob->delayy_rld = SCROLL_Y_SPEED; |
|
|
} |
|
|
} |
|
|
blob->delayy = blob->delayy_rld; |
|
|
blob->delayy = blob->delayy_rld; |
|
|
break; |
|
|
break; |
|
|
case 'x'://Place string at this x Position
|
|
|
case 'x'://Place string at this x Position
|
|
|
if((tmp = getnum(blob)) != 0xFFFF){ |
|
|
if ((tmp = getnum(blob)) != 0xFFFF) { |
|
|
blob->posx = tmp; |
|
|
blob->posx = tmp; |
|
|
}else{ |
|
|
} else { |
|
|
blob->posx = NUM_COLS/2 + blob->sizex/2; |
|
|
blob->posx = NUM_COLS / 2 + blob->sizex / 2; |
|
|
} |
|
|
} |
|
|
break; |
|
|
break; |
|
|
case 'y'://Place string at this y Position
|
|
|
case 'y'://Place string at this y Position
|
|
|
if((tmp = getnum(blob)) != 0xFFFF){ |
|
|
if ((tmp = getnum(blob)) != 0xFFFF) { |
|
|
blob->posy = tmp - blob->sizey; |
|
|
blob->posy = tmp - blob->sizey; |
|
|
} |
|
|
} |
|
|
break; |
|
|
break; |
|
|
case 'b'://blink blob
|
|
|
case 'b'://blink blob
|
|
|
if((tmp = getnum(blob)) != 0xFFFF){ |
|
|
if ((tmp = getnum(blob)) != 0xFFFF) { |
|
|
blob->delayb_rld = tmp; |
|
|
blob->delayb_rld = tmp; |
|
|
}else{ |
|
|
} else { |
|
|
blob->delayb_rld = 50; |
|
|
blob->delayb_rld = 50; |
|
|
} |
|
|
} |
|
|
blob->delayb = blob->delayb_rld; |
|
|
blob->delayb = blob->delayb_rld; |
|
|
break; |
|
|
break; |
|
|
case '|': |
|
|
case '|': |
|
|
if((tmp = getnum(blob)) != 0xFFFF){ |
|
|
if ((tmp = getnum(blob)) != 0xFFFF) { |
|
|
blob->tox = tmp; |
|
|
blob->tox = tmp; |
|
|
}else{ |
|
|
} else { |
|
|
blob->tox = (NUM_COLS - 2 + blob->sizex)/2; |
|
|
blob->tox = (NUM_COLS - 2 + blob->sizex) / 2; |
|
|
} |
|
|
} |
|
|
blob->waitfor = wait_posx; |
|
|
blob->waitfor = wait_posx; |
|
|
return retval; |
|
|
return retval; |
|
|
break; |
|
|
break; |
|
|
case '-': |
|
|
case '-': |
|
|
if((tmp = getnum(blob)) != 0xFFFF){ |
|
|
if ((tmp = getnum(blob)) != 0xFFFF) { |
|
|
blob->toy = tmp; |
|
|
blob->toy = tmp; |
|
|
}else{ |
|
|
} else { |
|
|
blob->toy = (UNUM_ROWS-blob->sizey) / 2; //MARK
|
|
|
blob->toy = (UNUM_ROWS-blob->sizey) / 2; //MARK
|
|
|
} |
|
|
} |
|
|
blob->waitfor = wait_posy; |
|
|
blob->waitfor = wait_posy; |
|
|
return retval; |
|
|
return retval; |
|
|
break; |
|
|
break; |
|
|
case 'p': |
|
|
case 'p'://delay
|
|
|
blob->delayx_rld = 0; |
|
|
blob->delayx_rld = 0; |
|
|
blob->delayy_rld = 0; |
|
|
blob->delayy_rld = 0; |
|
|
if((tmp = getnum(blob)) != 0xFFFF){ |
|
|
if ((tmp = getnum(blob)) != 0xFFFF) { |
|
|
blob->timer = tmp*64; |
|
|
blob->timer = tmp * 64; |
|
|
}else{ |
|
|
} else { |
|
|
blob->timer = 30*64; |
|
|
blob->timer = 30 * 64; |
|
|
} |
|
|
} |
|
|
blob->waitfor = wait_timer; |
|
|
blob->waitfor = wait_timer; |
|
|
return retval; |
|
|
return retval; |
|
@ -296,57 +300,60 @@ unsigned char blobNextCommand(blob_t * blob){ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
blob_t * setupBlob(char * str){ |
|
|
static blob_t *setupBlob(char *str) |
|
|
|
|
|
{ |
|
|
static unsigned char chop_cnt; |
|
|
static unsigned char chop_cnt; |
|
|
static char *last; static char delim[] = "#"; |
|
|
static char *last; static char delim[] = "#"; |
|
|
static char *lastcommands; |
|
|
static char *lastcommands; |
|
|
unsigned int tmp; |
|
|
unsigned int tmp; |
|
|
|
|
|
|
|
|
blob_t *blob = malloc(sizeof (blob_t)); |
|
|
blob_t *blob = malloc(sizeof(blob_t)); |
|
|
|
|
|
|
|
|
if(str){ |
|
|
if (str) { |
|
|
#ifndef AVR |
|
|
#ifndef AVR |
|
|
// on non-AVR archs strtok_r fails for some reason if it operates on a
|
|
|
// on non-AVR archs strtok_r fails for some reason if it operates on a
|
|
|
// string which is located on another stack frame, so we need our own copy
|
|
|
// string which is located on another stack frame, so we need our own copy
|
|
|
memcpy (blob->scrolltextBuffer, str, SCROLLTEXT_BUFFER_SIZE); |
|
|
memcpy(blob->scrolltextBuffer, str, SCROLLTEXT_BUFFER_SIZE); |
|
|
str = blob->scrolltextBuffer; |
|
|
str = blob->scrolltextBuffer; |
|
|
#endif |
|
|
#endif |
|
|
chop_cnt = 0; |
|
|
chop_cnt = 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if(!chop_cnt){ |
|
|
if (!chop_cnt) { |
|
|
blob->commands = strtok_r (str, delim, &last); |
|
|
blob->commands = strtok_r(str, delim, &last); |
|
|
|
|
|
|
|
|
if( blob->commands == 0) goto fail; |
|
|
if (blob->commands == 0) |
|
|
|
|
|
goto fail; |
|
|
|
|
|
|
|
|
if((tmp = getnum(blob)) != 0xFFFF){ |
|
|
if ((tmp = getnum(blob)) != 0xFFFF) { |
|
|
chop_cnt = tmp; |
|
|
chop_cnt = tmp; |
|
|
lastcommands = blob->commands; |
|
|
lastcommands = blob->commands; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if(chop_cnt){ |
|
|
if (chop_cnt) { |
|
|
chop_cnt--; |
|
|
chop_cnt--; |
|
|
blob->commands = lastcommands; |
|
|
blob->commands = lastcommands; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
blob->str = strtok_r (NULL, delim, &last); |
|
|
blob->str = strtok_r(NULL, delim, &last); |
|
|
|
|
|
|
|
|
if ( blob->str == 0) goto fail; |
|
|
if (blob->str == 0) |
|
|
|
|
|
goto fail; |
|
|
|
|
|
|
|
|
blob->fontIndex = fonts[0].fontIndex; |
|
|
blob->fontIndex = fonts[0].fontIndex; |
|
|
blob->fontData = fonts[0].fontData; |
|
|
blob->fontData = fonts[0].fontData; |
|
|
blob->font_storebytes = fonts[0].storebytes; |
|
|
blob->font_storebytes = fonts[0].storebytes; |
|
|
|
|
|
|
|
|
unsigned char tmp1, *strg = (unsigned char*)blob->str; |
|
|
unsigned char tmp1, *strg = (unsigned char*) blob->str; |
|
|
unsigned char glyph_beg = fonts[0].glyph_beg; |
|
|
unsigned char glyph_beg = fonts[0].glyph_beg; |
|
|
unsigned char glyph_end = fonts[0].glyph_end; |
|
|
unsigned char glyph_end = fonts[0].glyph_end; |
|
|
|
|
|
|
|
|
//translate the string: subtract 1 to get offset in Table
|
|
|
//translate the string: subtract 1 to get offset in Table
|
|
|
while((tmp1 = *strg)){ |
|
|
while ((tmp1 = *strg)) { |
|
|
if((tmp1>=glyph_beg) && (tmp1<glyph_end)){ |
|
|
if ((tmp1 >= glyph_beg) && (tmp1 < glyph_end)) { |
|
|
*strg = 1 + tmp1 - glyph_beg; |
|
|
*strg = 1 + tmp1 - glyph_beg; |
|
|
}else{ |
|
|
} else { |
|
|
*strg = 1; |
|
|
*strg = 1; |
|
|
} |
|
|
} |
|
|
strg++; |
|
|
strg++; |
|
@ -356,22 +363,29 @@ blob_t * setupBlob(char * str){ |
|
|
|
|
|
|
|
|
blob->sizey = fonts[0].fontHeight; |
|
|
blob->sizey = fonts[0].fontHeight; |
|
|
blob->sizex = getLen(blob); |
|
|
blob->sizex = getLen(blob); |
|
|
if(*blob->commands == '<'){ |
|
|
switch (*blob->commands) { |
|
|
blob->posx = 0; |
|
|
case '<': |
|
|
blob->posy = (UNUM_ROWS-blob->sizey)/2; //MARK
|
|
|
blob->posx = 0; |
|
|
}else if(*blob->commands == '>'){ |
|
|
blob->posy = (UNUM_ROWS - blob->sizey) / 2; //MARK
|
|
|
blob->posx = NUM_COLS+blob->sizex; |
|
|
break; |
|
|
blob->posy = (UNUM_ROWS-blob->sizey)/2; //MARK
|
|
|
case '>': |
|
|
}else if(*blob->commands == 'd'){ |
|
|
blob->posx = NUM_COLS + blob->sizex; |
|
|
blob->posy = -blob->sizey; |
|
|
blob->posy = (UNUM_ROWS - blob->sizey) / 2; //MARK
|
|
|
blob->posx = (UNUM_COLS - 2 + blob->sizex)/2; //MARK
|
|
|
break; |
|
|
}else if(*blob->commands == 'u'){ |
|
|
case 'd': |
|
|
blob->posy = blob->sizey; |
|
|
blob->posy = -blob->sizey; |
|
|
blob->posx = (UNUM_COLS - 2 + blob->sizex)/2; //MARK
|
|
|
blob->posx = (UNUM_COLS - 2 + blob->sizex) / 2; //MARK
|
|
|
}else if(*blob->commands == 'x'){ |
|
|
break; |
|
|
blob->posy = (UNUM_ROWS-blob->sizey)/2; //MARK
|
|
|
case 'u': |
|
|
}else if(*blob->commands == 'y'){ |
|
|
blob->posy = blob->sizey; |
|
|
blob->posx = (UNUM_COLS - 2 + blob->sizex)/2; //MARK
|
|
|
blob->posx = (UNUM_COLS - 2 + blob->sizex) / 2; //MARK
|
|
|
|
|
|
break; |
|
|
|
|
|
case 'x': |
|
|
|
|
|
blob->posy = (UNUM_ROWS - blob->sizey) / 2; //MARK
|
|
|
|
|
|
break; |
|
|
|
|
|
case 'y': |
|
|
|
|
|
blob->posx = (UNUM_COLS - 2 + blob->sizex) / 2; //MARK
|
|
|
|
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
blob->delayx_rld = 0; |
|
|
blob->delayx_rld = 0; |
|
@ -388,59 +402,60 @@ fail: |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unsigned char updateBlob(blob_t * blob){ |
|
|
unsigned char updateBlob(blob_t *blob) |
|
|
|
|
|
{ |
|
|
if(blob->delayx_rld && (!(blob->delayx--))){ |
|
|
if (blob->delayx_rld && (!(blob->delayx--))) { |
|
|
blob->delayx = blob->delayx_rld; |
|
|
blob->delayx = blob->delayx_rld; |
|
|
(blob->direction & DIRECTION_RIGHT)?blob->posx--:blob->posx++; |
|
|
(blob->direction & DIRECTION_RIGHT) ? blob->posx-- : blob->posx++; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if(blob->delayy_rld && (!(blob->delayy--))){ |
|
|
if (blob->delayy_rld && (!(blob->delayy--))) { |
|
|
blob->delayy = blob->delayy_rld; |
|
|
blob->delayy = blob->delayy_rld; |
|
|
(blob->direction & DIRECTION_DOWN)?blob->posy++:blob->posy--; |
|
|
(blob->direction & DIRECTION_DOWN) ? blob->posy++ : blob->posy--; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if(blob->delayb_rld){ |
|
|
if (blob->delayb_rld) { |
|
|
if(!(blob->delayb--)){ |
|
|
if (!(blob->delayb--)) { |
|
|
blob->delayb = blob->delayb_rld; |
|
|
blob->delayb = blob->delayb_rld; |
|
|
blob->visible ^= 1; |
|
|
blob->visible ^= 1; |
|
|
} |
|
|
} |
|
|
}else{ |
|
|
} else { |
|
|
blob->visible = 1; |
|
|
blob->visible = 1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
unsigned char done=0; |
|
|
unsigned char done = 0; |
|
|
switch (blob->waitfor){ |
|
|
switch (blob->waitfor) { |
|
|
case wait_posy: |
|
|
case wait_posy: |
|
|
if (blob->posy == blob->toy)done = 1; |
|
|
if (blob->posy == blob->toy) |
|
|
|
|
|
done = 1; |
|
|
break; |
|
|
break; |
|
|
case wait_posx: |
|
|
case wait_posx: |
|
|
if (blob->posx == blob->tox)done = 1; |
|
|
if (blob->posx == blob->tox) |
|
|
|
|
|
done = 1; |
|
|
break; |
|
|
break; |
|
|
case wait_out: |
|
|
case wait_out: |
|
|
if((blob->posx - blob->sizex) > NUM_COLS || blob->posx < 0) done = 1; |
|
|
if ((blob->posx - blob->sizex) > NUM_COLS || blob->posx < 0) |
|
|
if((blob->posy) > NUM_ROWS || (blob->posy + blob->sizey) <0 ) done = 1; |
|
|
done = 1; |
|
|
|
|
|
if ((blob->posy) > NUM_ROWS || (blob->posy + blob->sizey) < 0) |
|
|
|
|
|
done = 1; |
|
|
break; |
|
|
break; |
|
|
case wait_timer: |
|
|
case wait_timer: |
|
|
if(0 == blob->timer--){ |
|
|
if (0 == blob->timer--) |
|
|
done = 1; |
|
|
done = 1; |
|
|
} |
|
|
|
|
|
break; |
|
|
break; |
|
|
case wait_col_l: |
|
|
case wait_col_l: |
|
|
if(blob->last){ |
|
|
if (blob->last) { |
|
|
if((blob->last->posx - blob->last->sizex) == blob->posx){ |
|
|
if ((blob->last->posx - blob->last->sizex) == blob->posx) |
|
|
done=1; |
|
|
done = 1; |
|
|
} |
|
|
} else { |
|
|
}else{ |
|
|
|
|
|
done = 1; |
|
|
done = 1; |
|
|
} |
|
|
} |
|
|
break; |
|
|
break; |
|
|
case wait_col_r: |
|
|
case wait_col_r: |
|
|
if(blob->next){ |
|
|
if (blob->next) { |
|
|
if(blob->next->posx == (blob->posx - blob->sizex)){ |
|
|
if (blob->next->posx == (blob->posx - blob->sizex)) |
|
|
done=1; |
|
|
done = 1; |
|
|
} |
|
|
} else { |
|
|
}else{ |
|
|
|
|
|
done = 1; |
|
|
done = 1; |
|
|
} |
|
|
} |
|
|
break; |
|
|
break; |
|
@ -448,41 +463,44 @@ unsigned char updateBlob(blob_t * blob){ |
|
|
done = 1; |
|
|
done = 1; |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
if(done){ |
|
|
if (done) { |
|
|
return (blobNextCommand(blob)); |
|
|
return blobNextCommand(blob); |
|
|
} |
|
|
} |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void drawBlob(blob_t *blob) { |
|
|
static void drawBlob(blob_t *blob) |
|
|
|
|
|
{ |
|
|
char x, y; |
|
|
char x, y; |
|
|
unsigned char byte=0, glyph, storebytes; |
|
|
unsigned char byte = 0, glyph, storebytes; |
|
|
unsigned int charPos, charEnd; |
|
|
unsigned int charPos, charEnd; |
|
|
|
|
|
|
|
|
unsigned int posx; unsigned char posy, toy; |
|
|
unsigned int posx; unsigned char posy, toy; |
|
|
|
|
|
|
|
|
if(!blob->visible) return; |
|
|
if (!blob->visible) |
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
unsigned char * str = (unsigned char*)blob->str; |
|
|
unsigned char *str = (unsigned char*) blob->str; |
|
|
posx = blob->posx; |
|
|
posx = blob->posx; |
|
|
posy = blob->posy; |
|
|
posy = blob->posy; |
|
|
toy = posy + blob->sizey; |
|
|
toy = posy + blob->sizey; |
|
|
storebytes = blob->font_storebytes; |
|
|
storebytes = blob->font_storebytes; |
|
|
|
|
|
|
|
|
glyph = (*blob->str)-1; |
|
|
glyph = (*blob->str) - 1; |
|
|
charPos = PW(blob->fontIndex[glyph]); |
|
|
charPos = PW(blob->fontIndex[glyph]); |
|
|
charEnd = PW(blob->fontIndex[glyph+1]); |
|
|
charEnd = PW(blob->fontIndex[glyph + 1]); |
|
|
|
|
|
|
|
|
while (posx >= NUM_COLS) { |
|
|
while (posx >= NUM_COLS) { |
|
|
charPos += storebytes; |
|
|
charPos += storebytes; |
|
|
if (charPos < charEnd) { |
|
|
if (charPos < charEnd) { |
|
|
posx--; |
|
|
posx--; |
|
|
}else{ |
|
|
} else { |
|
|
posx -= blob->space + 1; |
|
|
posx -= blob->space + 1; |
|
|
if (!(glyph = *++str)) return; |
|
|
if (!(glyph = *++str)) |
|
|
|
|
|
return; |
|
|
glyph -= 1; |
|
|
glyph -= 1; |
|
|
charPos = PW(blob->fontIndex[glyph]); |
|
|
charPos = PW(blob->fontIndex[glyph]); |
|
|
charEnd = PW(blob->fontIndex[glyph+1]); |
|
|
charEnd = PW(blob->fontIndex[glyph + 1]); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
for (x = posx; x >= 0; x-- ) { |
|
|
for (x = posx; x >= 0; x-- ) { |
|
@ -492,30 +510,32 @@ void drawBlob(blob_t *blob) { |
|
|
|
|
|
|
|
|
for (y = posy; (y < NUM_ROWS) && (y < toy); y++) { |
|
|
for (y = posy; (y < NUM_ROWS) && (y < toy); y++) { |
|
|
|
|
|
|
|
|
if((mask<<=1) == 0){ |
|
|
if ((mask <<= 1) == 0) { |
|
|
mask = 0x01; |
|
|
mask = 0x01; |
|
|
byte = PB(blob->fontData[datpos++]); |
|
|
byte = PB(blob->fontData[datpos++]); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if ((byte & mask) && y >= 0 ) { |
|
|
if ((byte & mask) && y >= 0 ) { |
|
|
text_setpixel((pixel){x, y},1); |
|
|
text_setpixel((pixel) {x, y}, 1); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
charPos += storebytes; |
|
|
charPos += storebytes; |
|
|
if (charPos < charEnd) { |
|
|
if (charPos < charEnd) { |
|
|
}else{ |
|
|
} else { |
|
|
x -= blob->space; |
|
|
x -= blob->space; |
|
|
if (!(glyph = *++str)) return; |
|
|
if (!(glyph = *++str)) |
|
|
|
|
|
return; |
|
|
glyph -= 1; |
|
|
glyph -= 1; |
|
|
charPos = PW(blob->fontIndex[glyph]); |
|
|
charPos = PW(blob->fontIndex[glyph]); |
|
|
charEnd = PW(blob->fontIndex[glyph+1]); |
|
|
charEnd = PW(blob->fontIndex[glyph + 1]); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
extern jmp_buf newmode_jmpbuf; |
|
|
extern jmp_buf newmode_jmpbuf; |
|
|
|
|
|
|
|
|
void scrolltext(char *str) { |
|
|
void scrolltext(char *str) |
|
|
|
|
|
{ |
|
|
jmp_buf tmp_jmpbuf; |
|
|
jmp_buf tmp_jmpbuf; |
|
|
char tmp_str[SCROLLTEXT_BUFFER_SIZE]; |
|
|
char tmp_str[SCROLLTEXT_BUFFER_SIZE]; |
|
|
int ljmp_retval; |
|
|
int ljmp_retval; |
|
@ -525,55 +545,55 @@ void scrolltext(char *str) { |
|
|
unsigned char auto_pixmap[NUM_ROWS][LINEBYTES]; |
|
|
unsigned char auto_pixmap[NUM_ROWS][LINEBYTES]; |
|
|
text_pixmap = &auto_pixmap; |
|
|
text_pixmap = &auto_pixmap; |
|
|
|
|
|
|
|
|
if(scrolltext_text[0] == 0){ |
|
|
if (scrolltext_text[0] == 0) { |
|
|
strcpy_P(scrolltext_text, default_text); |
|
|
strcpy_P(scrolltext_text, default_text); |
|
|
} |
|
|
} |
|
|
memcpy(tmp_str, str, SCROLLTEXT_BUFFER_SIZE); |
|
|
memcpy(tmp_str, str, SCROLLTEXT_BUFFER_SIZE); |
|
|
|
|
|
|
|
|
blob_t *startblob=0, *aktblob, *nextblob=0; |
|
|
blob_t *startblob = 0, *aktblob, *nextblob = 0; |
|
|
|
|
|
|
|
|
memcpy (tmp_jmpbuf, newmode_jmpbuf, sizeof(jmp_buf)); |
|
|
memcpy(tmp_jmpbuf, newmode_jmpbuf, sizeof(jmp_buf)); |
|
|
if((ljmp_retval = setjmp(newmode_jmpbuf))){ |
|
|
if ((ljmp_retval = setjmp(newmode_jmpbuf))) { |
|
|
while(startblob){ |
|
|
while (startblob) { |
|
|
aktblob = startblob; |
|
|
aktblob = startblob; |
|
|
startblob = aktblob->next; |
|
|
startblob = aktblob->next; |
|
|
free(aktblob); |
|
|
free(aktblob); |
|
|
} |
|
|
} |
|
|
memcpy (newmode_jmpbuf, tmp_jmpbuf, sizeof(jmp_buf)); |
|
|
memcpy(newmode_jmpbuf, tmp_jmpbuf, sizeof(jmp_buf)); |
|
|
longjmp(newmode_jmpbuf, ljmp_retval); |
|
|
longjmp(newmode_jmpbuf, ljmp_retval); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (!(startblob = setupBlob(tmp_str))){ |
|
|
if (!(startblob = setupBlob(tmp_str))) { |
|
|
goto exit; |
|
|
goto exit; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
unsigned char retval; |
|
|
unsigned char retval; |
|
|
do{ |
|
|
do { |
|
|
startblob->next = 0; |
|
|
startblob->next = 0; |
|
|
startblob->last = 0; |
|
|
startblob->last = 0; |
|
|
while(startblob){ |
|
|
while (startblob) { |
|
|
aktblob = startblob; |
|
|
aktblob = startblob; |
|
|
while(aktblob){ |
|
|
while (aktblob) { |
|
|
retval = updateBlob(aktblob); |
|
|
retval = updateBlob(aktblob); |
|
|
if(!retval){ |
|
|
if (!retval) { |
|
|
nextblob = aktblob->next; |
|
|
nextblob = aktblob->next; |
|
|
}else if(retval == 1){ |
|
|
} else if (retval == 1) { |
|
|
if(aktblob == startblob){ |
|
|
if (aktblob == startblob) { |
|
|
startblob = aktblob->next; |
|
|
startblob = aktblob->next; |
|
|
}else{ |
|
|
} else { |
|
|
aktblob->last->next = aktblob->next; |
|
|
aktblob->last->next = aktblob->next; |
|
|
} |
|
|
} |
|
|
if(aktblob->next){ |
|
|
if (aktblob->next) { |
|
|
aktblob->next->last = aktblob->last; |
|
|
aktblob->next->last = aktblob->last; |
|
|
} |
|
|
} |
|
|
nextblob = aktblob->next; |
|
|
nextblob = aktblob->next; |
|
|
free(aktblob); |
|
|
free(aktblob); |
|
|
}else if(retval == 2){ |
|
|
} else if (retval == 2) { |
|
|
blob_t * newblob = setupBlob(0); |
|
|
blob_t *newblob = setupBlob(0); |
|
|
if (newblob){ |
|
|
if (newblob) { |
|
|
newblob->last = aktblob; |
|
|
newblob->last = aktblob; |
|
|
newblob->next = aktblob->next; |
|
|
newblob->next = aktblob->next; |
|
|
if(aktblob->next){ |
|
|
if (aktblob->next) { |
|
|
aktblob->next->last = newblob; |
|
|
aktblob->next->last = newblob; |
|
|
} |
|
|
} |
|
|
aktblob->next = newblob; |
|
|
aktblob->next = newblob; |
|
@ -585,7 +605,7 @@ void scrolltext(char *str) { |
|
|
|
|
|
|
|
|
aktblob = startblob; |
|
|
aktblob = startblob; |
|
|
clear_text_pixmap(); |
|
|
clear_text_pixmap(); |
|
|
while(aktblob){ |
|
|
while (aktblob) { |
|
|
drawBlob(aktblob); |
|
|
drawBlob(aktblob); |
|
|
aktblob = aktblob->next; |
|
|
aktblob = aktblob->next; |
|
|
} |
|
|
} |
|
@ -594,8 +614,8 @@ void scrolltext(char *str) { |
|
|
}; |
|
|
}; |
|
|
startblob = setupBlob(0); |
|
|
startblob = setupBlob(0); |
|
|
//showBlob(startblob);
|
|
|
//showBlob(startblob);
|
|
|
}while(startblob); |
|
|
} while (startblob); |
|
|
|
|
|
|
|
|
exit: |
|
|
exit: |
|
|
memcpy (newmode_jmpbuf, tmp_jmpbuf, sizeof(jmp_buf)); |
|
|
memcpy(newmode_jmpbuf, tmp_jmpbuf, sizeof(jmp_buf)); |
|
|
} |
|
|
} |
|
|