static void handle_keys() { #ifdef JOYSTICK_NUM uint8_t joy = joystick(JOYSTICK_NUM); #else uint8_t joy = readkeys(); #endif if ( joy & MOVE_LEFT ) { if ( cx > 0 ) { --cx; moved(); } } else if ( joy & MOVE_RIGHT ) { if ( cx < ARENA_W - 1 ) { ++cx; moved(); } } else if ( joy & MOVE_DOWN ) { if ( cy < ARENA_H - 1 ) { ++cy; moved(); } } else if ( joy & MOVE_UP ) { if ( cy > 0 ) { --cy; moved(); } } else if ( joy & MOVE_FIRE ) { if ( selected > 1 ) { score += (selected -2 ) * (selected -2); crunchy(); crunchx(); moved(); checkover(); } } }
/* Reads through all the given files for words, and buids an * uncompressed and disorganized dictionary graph, in which the nodes * are represented as linked lists of arcs. */ static int readwordlists(int filecount, char *files[], treearc *root) { treearc *tarc; char word[WORDBUFSIZ]; unsigned char *ltr; int clear = FALSE; long count = 0; int usestdin; int i, n; memset(frequencies, 0, sizeof frequencies); for (i = 0 ; i < filecount ; ++i) { usestdin = files[i][0] == '-' && files[i][1] == '\0'; if (usestdin) { currfilename = "standard input"; currfp = stdin; } else { currfilename = files[i]; if (!(currfp = fopen(files[i], "r"))) errfile(); } report("Reading words from %s ...\n", currfilename); while (fgets(word, sizeof word, currfp)) { n = checkover(word); if (n == sizeof word - 1) { fprintf(stderr, "Overlong word \"%s...\" rejected\n", word); clear = TRUE; continue; } if (clear || !n) { clear = FALSE; continue; } tarc = root; for (ltr = (unsigned char*)word ; *ltr ; ++ltr) ++frequencies[*ltr]; for (ltr = (unsigned char*)word ; *ltr ; ++ltr) { while (tarc->letter != *ltr && tarc->sibling) tarc = tarc->sibling; if (tarc->letter != *ltr) { if (tarc->letter) tarc = tarc->sibling = grabnewtreearc(*ltr, 0); else tarc->letter = *ltr; } if (!tarc->child) break; tarc = tarc->child; } while (*ltr++) { tarc->child = grabnewtreearc(*ltr, ++nodecount); tarc = tarc->child; } tarc->wordend = TRUE; ++count; } if (usestdin) { currfp = NULL; currfilename = NULL; } else closefile(); } if (!count) { fprintf(stderr, "No words found - nothing to build.\n"); return 0; } report("\n%d words, %d nodes, %d arcs\n", count, nodecount, arccount); return count; }