Ignore:
Timestamp:
2018-03-02T20:34:50Z (7 years ago)
Author:
GitHub <noreply@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a1a81f69, d5e5fd1
Parents:
3061bc1 (diff), 34e1206 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:34:50)
git-committer:
GitHub <noreply@…> (2018-03-02 20:34:50)
Message:

Remove all trailing whitespace, everywhere.

See individual commit messages for details.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/dist/src/c/demos/tetris/tetris.c

    r3061bc1 r8565a42  
    9898        int i;
    9999        cell *p = board;
    100        
     100
    101101        for (i = B_SIZE; i; i--)
    102102                *p++ = (i <= (2 * B_COLS) || (i % B_COLS) < 2) ? 0x0000ff : 0x000000;
     
    113113        int base;
    114114        cell *p;
    115        
     115
    116116        for (i = A_FIRST; i < A_LAST; i++) {
    117117                base = i * B_COLS + 1;
     
    122122                                rows++;
    123123                                memset(&board[base], 0, sizeof(cell) * (B_COLS - 2));
    124                                
     124
    125125                                scr_update();
    126126                                tsleep();
    127                                
     127
    128128                                while (--base != 0)
    129129                                        board[base + B_COLS] = board[base];
    130                                
     130
    131131                                scr_update();
    132132                                tsleep();
    133                                
     133
    134134                                break;
    135135                        }
    136136                }
    137137        }
    138        
     138
    139139        switch (rows) {
    140140        case 1:
     
    160160        int i;
    161161        int j = rand() % 4;
    162        
     162
    163163        for (i = 0; i < j; i++)
    164164                tmp = &shapes[classic ? tmp->rotc : tmp->rot];
    165        
     165
    166166        return (tmp);
    167167}
     
    170170{
    171171        struct timeval tv;
    172        
     172
    173173        gettimeofday(&tv, NULL);
    174174        srand(tv.tv_sec + tv.tv_usec / 100000);
     
    180180        moveto(5, 10);
    181181        puts("Tetris\n\n");
    182        
     182
    183183        moveto(8, 10);
    184184        printf("Level = %d (press keys 1 - 9 to change)", level);
     
    202202        while (1) {
    203203                int i = getchar();
    204                
     204
    205205                switch(i) {
    206206                        case 'p':
     
    249249        int j;
    250250        int ch;
    251        
     251
    252252        console = console_init(stdin, stdout);
    253        
     253
    254254        keys = "jkl pq";
    255        
     255
    256256        classic = 0;
    257257        showpreview = 1;
    258        
     258
    259259        while ((ch = getopt(argc, argv, "ck:ps")) != -1)
    260260                switch(ch) {
     
    280280                        usage();
    281281                }
    282        
     282
    283283        argc -= optind;
    284284        argv += optind;
    285        
     285
    286286        if (argc)
    287287                usage();
    288        
     288
    289289        for (i = 0; i <= 5; i++) {
    290290                for (j = i + 1; j <= 5; j++) {
     
    292292                                errx(1, "%s", "duplicate command keys specified.");
    293293                }
    294                
     294
    295295                if (keys[i] == ' ')
    296296                        str_cpy(key_write[i], sizeof(key_write[i]), "<space>");
     
    300300                }
    301301        }
    302        
     302
    303303        snprintf(key_msg, sizeof(key_msg),
    304304            "%s - left   %s - rotate   %s - right   %s - drop   %s - pause   %s - quit",
    305305            key_write[0], key_write[1], key_write[2], key_write[3],
    306306            key_write[4], key_write[5]);
    307        
     307
    308308        scr_init();
    309309        if (loadscores() != EOK)
     
    312312        while (tetris_menu(&level)) {
    313313                fallrate = 1000000 / level;
    314                
     314
    315315                scr_clear();
    316316                setup_board();
    317                
     317
    318318                srandomdev();
    319319                scr_set();
    320                
     320
    321321                pos = A_FIRST * B_COLS + (B_COLS / 2) - 1;
    322322                nextshape = randshape();
    323323                curshape = randshape();
    324                
     324
    325325                scr_msg(key_msg, 1);
    326                
     326
    327327                while (1) {
    328328                        place(curshape, pos, 1);
     
    338338                                        continue;
    339339                                }
    340                                
     340
    341341                                /*
    342342                                 * Put up the current shape `permanently',
     
    346346                                score++;
    347347                                elide();
    348                                
     348
    349349                                /*
    350350                                 * Choose a new shape.  If it does not fit,
     
    354354                                nextshape = randshape();
    355355                                pos = A_FIRST * B_COLS + (B_COLS / 2) - 1;
    356                                
     356
    357357                                if (!fits_in(curshape, pos))
    358358                                        break;
    359                                
    360                                 continue;
    361                         }
    362                        
     359
     360                                continue;
     361                        }
     362
    363363                        /*
    364364                         * Handle command keys.
     
    368368                                break;
    369369                        }
    370                        
     370
    371371                        if (c == keys[4]) {
    372372                                static char msg[] =
    373373                                    "paused - press RETURN to continue";
    374                                
     374
    375375                                place(curshape, pos, 1);
    376376                                do {
     
    380380                                        console_flush(console);
    381381                                } while (!twait());
    382                                
     382
    383383                                scr_msg(msg, 0);
    384384                                scr_msg(key_msg, 1);
     
    386386                                continue;
    387387                        }
    388                        
     388
    389389                        if (c == keys[0]) {
    390390                                /* move left */
     
    393393                                continue;
    394394                        }
    395                        
     395
    396396                        if (c == keys[1]) {
    397397                                /* turn */
    398398                                const struct shape *new =
    399399                                    &shapes[classic ? curshape->rotc : curshape->rot];
    400                                
     400
    401401                                if (fits_in(new, pos))
    402402                                        curshape = new;
    403403                                continue;
    404404                        }
    405                        
     405
    406406                        if (c == keys[2]) {
    407407                                /* move right */
     
    410410                                continue;
    411411                        }
    412                        
     412
    413413                        if (c == keys[3]) {
    414414                                /* move to bottom */
     
    419419                                continue;
    420420                        }
    421                        
     421
    422422                        if (c == '\f') {
    423423                                scr_clear();
     
    425425                        }
    426426                }
    427                
     427
    428428                scr_clear();
    429429                loadscores();
     
    432432                score = 0;
    433433        }
    434        
     434
    435435        scr_clear();
    436436        printf("\nGame over.\n");
    437437        scr_end();
    438        
     438
    439439        return 0;
    440440}
Note: See TracChangeset for help on using the changeset viewer.