Browse Source

src/scrolltext: fix codestyle

feature/2015
Nicolas Reinecke 10 years ago
parent
commit
b2dd959767
  1. 2
      src/scrolltext/scrolltext.h
  2. 110
      src/scrolltext/scrolltext3.c

2
src/scrolltext/scrolltext.h

@ -6,6 +6,6 @@
#define FONT_UNI53 3
#define FONT_C64 4
void scrolltext(char *str);
extern void scrolltext(char *str);
#endif /* SCROLLTEXT_H_ */

110
src/scrolltext/scrolltext3.c

@ -36,12 +36,12 @@
font fonts[MAX_FONTS];
#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, 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];
/* Konzept
@ -57,23 +57,24 @@ 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 ){
if(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];
}
}
static void clear_text_pixmap(){
static void clear_text_pixmap()
{
memset(text_pixmap, 0, NUM_ROWS * LINEBYTES);
}
static void update_pixmap(){
for(unsigned char p = NUMPLANE; p--;){
static void update_pixmap()
{
for (unsigned char p = NUMPLANE; p--;)
memcpy(&pixmap[p][0][0], text_pixmap, NUM_ROWS * LINEBYTES);
}
}
enum waitfor_e {
wait_new,
@ -124,7 +125,8 @@ typedef struct blob_t_struct{
/*
void showBlob(blob_t * blob){
void showBlob(blob_t *blob)
{
unsigned char *str = blob->str;
unsigned char tmp[200], x = 0;
while (*str) {
@ -152,7 +154,8 @@ void showBlob(blob_t * blob){
#define PW(a) pgm_read_word(&(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 int strLen = 0;
unsigned char *str = (unsigned char*) blob->str;
@ -167,7 +170,8 @@ static unsigned int getLen(blob_t *blob) {
}
static unsigned int getnum(blob_t * blob){
static unsigned int getnum(blob_t *blob)
{
unsigned int num = 0;
unsigned char gotnum = 0;
@ -178,14 +182,14 @@ static unsigned int getnum(blob_t * blob){
blob->commands++;
}
if(gotnum){
if (gotnum)
return num;
}else{
else
return 0xffff;
}
}
unsigned char blobNextCommand(blob_t * blob){
unsigned char blobNextCommand(blob_t *blob)
{
unsigned int tmp;
unsigned char retval = 0;
while (*blob->commands != 0) {
@ -264,7 +268,7 @@ unsigned char blobNextCommand(blob_t * blob){
blob->waitfor = wait_posy;
return retval;
break;
case 'p':
case 'p'://delay
blob->delayx_rld = 0;
blob->delayy_rld = 0;
if ((tmp = getnum(blob)) != 0xFFFF) {
@ -296,7 +300,8 @@ unsigned char blobNextCommand(blob_t * blob){
}
blob_t * setupBlob(char * str){
static blob_t *setupBlob(char *str)
{
static unsigned char chop_cnt;
static char *last; static char delim[] = "#";
static char *lastcommands;
@ -317,7 +322,8 @@ blob_t * setupBlob(char * str){
if (!chop_cnt) {
blob->commands = strtok_r(str, delim, &last);
if( blob->commands == 0) goto fail;
if (blob->commands == 0)
goto fail;
if ((tmp = getnum(blob)) != 0xFFFF) {
chop_cnt = tmp;
@ -332,7 +338,8 @@ blob_t * setupBlob(char * str){
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->fontData = fonts[0].fontData;
@ -356,22 +363,29 @@ blob_t * setupBlob(char * str){
blob->sizey = fonts[0].fontHeight;
blob->sizex = getLen(blob);
if(*blob->commands == '<'){
switch (*blob->commands) {
case '<':
blob->posx = 0;
blob->posy = (UNUM_ROWS - blob->sizey) / 2; //MARK
}else if(*blob->commands == '>'){
break;
case '>':
blob->posx = NUM_COLS + blob->sizex;
blob->posy = (UNUM_ROWS - blob->sizey) / 2; //MARK
}else if(*blob->commands == 'd'){
break;
case 'd':
blob->posy = -blob->sizey;
blob->posx = (UNUM_COLS - 2 + blob->sizex) / 2; //MARK
}else if(*blob->commands == 'u'){
break;
case 'u':
blob->posy = blob->sizey;
blob->posx = (UNUM_COLS - 2 + blob->sizex) / 2; //MARK
}else if(*blob->commands == 'x'){
break;
case 'x':
blob->posy = (UNUM_ROWS - blob->sizey) / 2; //MARK
}else if(*blob->commands == 'y'){
break;
case 'y':
blob->posx = (UNUM_COLS - 2 + blob->sizex) / 2; //MARK
break;
}
blob->delayx_rld = 0;
@ -388,8 +402,8 @@ fail:
}
unsigned char updateBlob(blob_t * blob){
unsigned char updateBlob(blob_t *blob)
{
if (blob->delayx_rld && (!(blob->delayx--))) {
blob->delayx = blob->delayx_rld;
(blob->direction & DIRECTION_RIGHT) ? blob->posx-- : blob->posx++;
@ -412,34 +426,35 @@ unsigned char updateBlob(blob_t * blob){
unsigned char done = 0;
switch (blob->waitfor) {
case wait_posy:
if (blob->posy == blob->toy)done = 1;
if (blob->posy == blob->toy)
done = 1;
break;
case wait_posx:
if (blob->posx == blob->tox)done = 1;
if (blob->posx == blob->tox)
done = 1;
break;
case wait_out:
if((blob->posx - blob->sizex) > NUM_COLS || blob->posx < 0) done = 1;
if((blob->posy) > NUM_ROWS || (blob->posy + blob->sizey) <0 ) done = 1;
if ((blob->posx - blob->sizex) > NUM_COLS || blob->posx < 0)
done = 1;
if ((blob->posy) > NUM_ROWS || (blob->posy + blob->sizey) < 0)
done = 1;
break;
case wait_timer:
if(0 == blob->timer--){
if (0 == blob->timer--)
done = 1;
}
break;
case wait_col_l:
if (blob->last) {
if((blob->last->posx - blob->last->sizex) == blob->posx){
if ((blob->last->posx - blob->last->sizex) == blob->posx)
done = 1;
}
} else {
done = 1;
}
break;
case wait_col_r:
if (blob->next) {
if(blob->next->posx == (blob->posx - blob->sizex)){
if (blob->next->posx == (blob->posx - blob->sizex))
done = 1;
}
} else {
done = 1;
}
@ -449,19 +464,21 @@ unsigned char updateBlob(blob_t * blob){
break;
}
if (done) {
return (blobNextCommand(blob));
return blobNextCommand(blob);
}
return 0;
}
void drawBlob(blob_t *blob) {
static void drawBlob(blob_t *blob)
{
char x, y;
unsigned char byte = 0, glyph, storebytes;
unsigned int charPos, charEnd;
unsigned int posx; unsigned char posy, toy;
if(!blob->visible) return;
if (!blob->visible)
return;
unsigned char *str = (unsigned char*) blob->str;
posx = blob->posx;
@ -479,7 +496,8 @@ void drawBlob(blob_t *blob) {
posx--;
} else {
posx -= blob->space + 1;
if (!(glyph = *++str)) return;
if (!(glyph = *++str))
return;
glyph -= 1;
charPos = PW(blob->fontIndex[glyph]);
charEnd = PW(blob->fontIndex[glyph + 1]);
@ -505,7 +523,8 @@ void drawBlob(blob_t *blob) {
if (charPos < charEnd) {
} else {
x -= blob->space;
if (!(glyph = *++str)) return;
if (!(glyph = *++str))
return;
glyph -= 1;
charPos = PW(blob->fontIndex[glyph]);
charEnd = PW(blob->fontIndex[glyph + 1]);
@ -515,7 +534,8 @@ void drawBlob(blob_t *blob) {
extern jmp_buf newmode_jmpbuf;
void scrolltext(char *str) {
void scrolltext(char *str)
{
jmp_buf tmp_jmpbuf;
char tmp_str[SCROLLTEXT_BUFFER_SIZE];
int ljmp_retval;

Loading…
Cancel
Save