Changeset 79ae36dd in mainline for uspace/app/tetris


Ignore:
Timestamp:
2011-06-08T19:01:55Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0eff68e
Parents:
764d71e
Message:

new async framework with integrated exchange tracking

  • strict isolation between low-level IPC and high-level async framework with integrated exchange tracking
    • each IPC connection is represented by an async_sess_t structure
    • each IPC exchange is represented by an async_exch_t structure
    • exchange management is either based on atomic messages (EXCHANGE_ATOMIC), locking (EXCHANGE_SERIALIZE) or connection cloning (EXCHANGE_CLONE)
  • async_obsolete: temporary compatibility layer to keep old async clients working (several pieces of code are currently broken, but only non-essential functionality)
  • IPC_M_PHONE_HANGUP is now method no. 0 (for elegant boolean evaluation)
  • IPC_M_DEBUG_ALL has been renamed to IPC_M_DEBUG
  • IPC_M_PING has been removed (VFS protocol now has VFS_IN_PING)
  • console routines in libc have been rewritten for better abstraction
  • additional use for libc-private header files (FILE structure opaque to the client)
  • various cstyle changes (typos, indentation, missing externs in header files, improved comments, etc.)
Location:
uspace/app/tetris
Files:
2 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/tetris/Makefile

    r764d71e r79ae36dd  
    3434        shapes.c \
    3535        scores.c \
    36         input.c \
    3736        tetris.c \
    3837        screen.c
  • uspace/app/tetris/scores.c

    r764d71e r79ae36dd  
    1 /*      $OpenBSD: scores.c,v 1.11 2006/04/20 03:25:36 ray Exp $ */
    2 /*      $NetBSD: scores.c,v 1.2 1995/04/22 07:42:38 cgd Exp $   */
    3 
    4 /*-
    5  * Copyright (c) 1992, 1993
    6  *      The Regents of the University of California.  All rights reserved.
    7  *
    8  * This code is derived from software contributed to Berkeley by
    9  * Chris Torek and Darren F. Provine.
     1/*
     2 * Copyright (c) 2011 Martin Decky
     3 * All rights reserved.
    104 *
    115 * Redistribution and use in source and binary forms, with or without
    126 * modification, are permitted provided that the following conditions
    137 * are met:
    14  * 1. Redistributions of source code must retain the above copyright
    15  *    notice, this list of conditions and the following disclaimer.
    16  * 2. Redistributions in binary form must reproduce the above copyright
    17  *    notice, this list of conditions and the following disclaimer in the
    18  *    documentation and/or other materials provided with the distribution.
    19  * 3. Neither the name of the University nor the names of its contributors
    20  *    may be used to endorse or promote products derived from this software
    21  *    without specific prior written permission.
    22  *
    23  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
    24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
    27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    33  * SUCH DAMAGE.
    34  *
    35  *      @(#)scores.c    8.1 (Berkeley) 5/31/93
     8 *
     9 * - Redistributions of source code must retain the above copyright
     10 *   notice, this list of conditions and the following disclaimer.
     11 * - Redistributions in binary form must reproduce the above copyright
     12 *   notice, this list of conditions and the following disclaimer in the
     13 *   documentation and/or other materials provided with the distribution.
     14 * - The name of the author may not be used to endorse or promote products
     15 *   derived from this software without specific prior written permission.
     16 *
     17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27 */
     28
     29/** Attributations
     30 *
     31 * scores.c 8.1 (Berkeley) 5/31/93
     32 * NetBSD: scores.c,v 1.2 1995/04/22 07:42:38 cgd
     33 * OpenBSD: scores.c,v 1.11 2006/04/20 03:25:36 ray
     34 *
     35 * Based upon BSD Tetris
     36 *
     37 * Copyright (c) 1992, 1993
     38 *      The Regents of the University of California.
     39 *      Distributed under BSD license.
     40 *
     41 * This code is derived from software contributed to Berkeley by
     42 * Chris Torek and Darren F. Provine.
     43 *
    3644 */
    3745
     
    6068#include <err.h>
    6169#include <time.h>
    62 
    6370#include "screen.h"
    6471#include "tetris.h"
     
    118125        int j;
    119126        size_t off;
    120         console_event_t ev;
     127        kbd_event_t ev;
    121128       
    122129        clear_screen();
     
    133140       
    134141        while (1) {
    135                 fflush(stdout);
    136                 if (!console_get_event(fphone(stdin), &ev))
     142                console_flush(console);
     143                if (!console_get_kbd_event(console, &ev))
    137144                        exit(1);
    138145               
  • uspace/app/tetris/scores.h

    r764d71e r79ae36dd  
    1 /*      $OpenBSD: scores.h,v 1.5 2003/06/03 03:01:41 millert Exp $      */
    2 /*      $NetBSD: scores.h,v 1.2 1995/04/22 07:42:40 cgd Exp $   */
     1/*
     2 * Copyright (c) 2011 Martin Decky
     3 * All rights reserved.
     4 *
     5 * Redistribution and use in source and binary forms, with or without
     6 * modification, are permitted provided that the following conditions
     7 * are met:
     8 *
     9 * - Redistributions of source code must retain the above copyright
     10 *   notice, this list of conditions and the following disclaimer.
     11 * - Redistributions in binary form must reproduce the above copyright
     12 *   notice, this list of conditions and the following disclaimer in the
     13 *   documentation and/or other materials provided with the distribution.
     14 * - The name of the author may not be used to endorse or promote products
     15 *   derived from this software without specific prior written permission.
     16 *
     17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27 */
    328
    4 /*-
     29/** Attributations
     30 *
     31 * scores.h 8.1 (Berkeley) 5/31/93
     32 * NetBSD: scores.h,v 1.2 1995/04/22 07:42:40 cgd
     33 * OpenBSD: scores.h,v 1.5 2003/06/03 03:01:41 millert
     34 *
     35 * Based upon BSD Tetris
     36 *
    537 * Copyright (c) 1992, 1993
    6  *      The Regents of the University of California.  All rights reserved.
     38 *      The Regents of the University of California.
     39 *      Distributed under BSD license.
    740 *
    841 * This code is derived from software contributed to Berkeley by
    942 * Chris Torek and Darren F. Provine.
    1043 *
    11  * Redistribution and use in source and binary forms, with or without
    12  * modification, are permitted provided that the following conditions
    13  * are met:
    14  * 1. Redistributions of source code must retain the above copyright
    15  *    notice, this list of conditions and the following disclaimer.
    16  * 2. Redistributions in binary form must reproduce the above copyright
    17  *    notice, this list of conditions and the following disclaimer in the
    18  *    documentation and/or other materials provided with the distribution.
    19  * 3. Neither the name of the University nor the names of its contributors
    20  *    may be used to endorse or promote products derived from this software
    21  *    without specific prior written permission.
    22  *
    23  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
    24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
    27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    33  * SUCH DAMAGE.
    34  *
    35  *      @(#)scores.h    8.1 (Berkeley) 5/31/93
    3644 */
    3745
     
    4149/** @file
    4250 */
    43 
    4451
    4552/*
  • uspace/app/tetris/screen.c

    r764d71e r79ae36dd  
    1 /*      $OpenBSD: screen.c,v 1.13 2006/04/20 03:25:36 ray Exp $ */
    2 /*      $NetBSD: screen.c,v 1.4 1995/04/29 01:11:36 mycroft Exp $       */
    3 
    4 /*-
    5  * Copyright (c) 1992, 1993
    6  *      The Regents of the University of California.  All rights reserved.
    7  *
    8  * This code is derived from software contributed to Berkeley by
    9  * Chris Torek and Darren F. Provine.
     1/*
     2 * Copyright (c) 2011 Martin Decky
     3 * All rights reserved.
    104 *
    115 * Redistribution and use in source and binary forms, with or without
    126 * modification, are permitted provided that the following conditions
    137 * are met:
    14  * 1. Redistributions of source code must retain the above copyright
    15  *    notice, this list of conditions and the following disclaimer.
    16  * 2. Redistributions in binary form must reproduce the above copyright
    17  *    notice, this list of conditions and the following disclaimer in the
    18  *    documentation and/or other materials provided with the distribution.
    19  * 3. Neither the name of the University nor the names of its contributors
    20  *    may be used to endorse or promote products derived from this software
    21  *    without specific prior written permission.
    22  *
    23  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
    24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
    27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    33  * SUCH DAMAGE.
    34  *
    35  *      @(#)screen.c    8.1 (Berkeley) 5/31/93
     8 *
     9 * - Redistributions of source code must retain the above copyright
     10 *   notice, this list of conditions and the following disclaimer.
     11 * - Redistributions in binary form must reproduce the above copyright
     12 *   notice, this list of conditions and the following disclaimer in the
     13 *   documentation and/or other materials provided with the distribution.
     14 * - The name of the author may not be used to endorse or promote products
     15 *   derived from this software without specific prior written permission.
     16 *
     17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27 */
     28
     29/** Attributations
     30 *
     31 * screen.c 8.1 (Berkeley) 5/31/93
     32 * NetBSD: screen.c,v 1.4 1995/04/29 01:11:36 mycroft
     33 * OpenBSD: screen.c,v 1.13 2006/04/20 03:25:36 ray
     34 *
     35 * Based upon BSD Tetris
     36 *
     37 * Copyright (c) 1992, 1993
     38 *      The Regents of the University of California.
     39 *      Distributed under BSD license.
     40 *
     41 * This code is derived from software contributed to Berkeley by
     42 * Chris Torek and Darren F. Provine.
     43 *
    3644 */
    3745
     
    6977static const struct shape *lastshape;
    7078
     79static suseconds_t timeleft = 0;
     80
     81console_ctrl_t *console;
     82
    7183
    7284/*
     
    8294static void start_standout(uint32_t color)
    8395{
    84         fflush(stdout);
    85         console_set_rgb_color(fphone(stdout), 0xffffff,
     96        console_flush(console);
     97        console_set_rgb_color(console, 0xffffff,
    8698            use_color ? color : 0x000000);
    8799}
     
    89101static void resume_normal(void)
    90102{
    91         fflush(stdout);
    92         console_set_style(fphone(stdout), STYLE_NORMAL);
     103        console_flush(console);
     104        console_set_style(console, STYLE_NORMAL);
    93105}
    94106
    95107void clear_screen(void)
    96108{
    97         console_clear(fphone(stdout));
     109        console_clear(console);
    98110        moveto(0, 0);
    99111}
     
    105117{
    106118        resume_normal();
    107         console_clear(fphone(stdout));
     119        console_clear(console);
    108120        curscore = -1;
    109121        memset(curscreen, 0, sizeof(curscreen));
     
    115127void scr_init(void)
    116128{
    117         console_cursor_visibility(fphone(stdout), 0);
     129        console_cursor_visibility(console, 0);
    118130        resume_normal();
    119131        scr_clear();
     
    122134void moveto(sysarg_t r, sysarg_t c)
    123135{
    124         fflush(stdout);
    125         console_set_pos(fphone(stdout), c, r);
     136        console_flush(console);
     137        console_set_pos(console, c, r);
    126138}
    127139
     
    130142static int get_display_size(winsize_t *ws)
    131143{
    132         return console_get_size(fphone(stdout), &ws->ws_col, &ws->ws_row);
     144        return console_get_size(console, &ws->ws_col, &ws->ws_row);
    133145}
    134146
     
    136148{
    137149        sysarg_t ccap;
    138         int rc = console_get_color_cap(fphone(stdout), &ccap);
     150        int rc = console_get_color_cap(console, &ccap);
    139151       
    140152        if (rc != 0)
     
    179191void scr_end(void)
    180192{
    181         console_cursor_visibility(fphone(stdout), 1);
     193        console_cursor_visibility(console, 1);
    182194}
    183195
     
    302314                resume_normal();
    303315       
    304         fflush(stdout);
     316        console_flush(console);
    305317}
    306318
     
    322334}
    323335
     336/** Sleep for the current turn time
     337 *
     338 * Eat any input that might be available.
     339 *
     340 */
     341void tsleep(void)
     342{
     343        suseconds_t timeout = fallrate;
     344       
     345        while (timeout > 0) {
     346                kbd_event_t event;
     347               
     348                if (!console_get_kbd_event_timeout(console, &event, &timeout))
     349                        break;
     350        }
     351}
     352
     353/** Get char with timeout
     354 *
     355 */
     356int tgetchar(void)
     357{
     358        /*
     359         * Reset timeleft to fallrate whenever it is not positive
     360         * and increase speed.
     361         */
     362       
     363        if (timeleft <= 0) {
     364                faster();
     365                timeleft = fallrate;
     366        }
     367       
     368        /*
     369         * Wait to see if there is any input. If so, take it and
     370         * update timeleft so that the next call to tgetchar()
     371         * will not wait as long. If there is no input,
     372         * make timeleft zero and return -1.
     373         */
     374       
     375        wchar_t c = 0;
     376       
     377        while (c == 0) {
     378                kbd_event_t event;
     379               
     380                if (!console_get_kbd_event_timeout(console, &event, &timeleft)) {
     381                        timeleft = 0;
     382                        return -1;
     383                }
     384               
     385                if (event.type == KEY_PRESS)
     386                        c = event.c;
     387        }
     388       
     389        return (int) c;
     390}
     391
     392/** Get char without timeout
     393 *
     394 */
     395int twait(void)
     396{
     397        wchar_t c = 0;
     398       
     399        while (c == 0) {
     400                kbd_event_t event;
     401               
     402                if (!console_get_kbd_event(console, &event))
     403                        return -1;
     404               
     405                if (event.type == KEY_PRESS)
     406                        c = event.c;
     407        }
     408       
     409        return (int) c;
     410}
     411
    324412/** @}
    325413 */
  • uspace/app/tetris/screen.h

    r764d71e r79ae36dd  
    1 /*      $OpenBSD: screen.h,v 1.5 2003/06/03 03:01:41 millert Exp $      */
    2 /*      $NetBSD: screen.h,v 1.2 1995/04/22 07:42:42 cgd Exp $   */
     1/*
     2 * Copyright (c) 2011 Martin Decky
     3 * All rights reserved.
     4 *
     5 * Redistribution and use in source and binary forms, with or without
     6 * modification, are permitted provided that the following conditions
     7 * are met:
     8 *
     9 * - Redistributions of source code must retain the above copyright
     10 *   notice, this list of conditions and the following disclaimer.
     11 * - Redistributions in binary form must reproduce the above copyright
     12 *   notice, this list of conditions and the following disclaimer in the
     13 *   documentation and/or other materials provided with the distribution.
     14 * - The name of the author may not be used to endorse or promote products
     15 *   derived from this software without specific prior written permission.
     16 *
     17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27 */
    328
    4 /*-
     29/** Attributations
     30 *
     31 * screen.h 8.1 (Berkeley) 5/31/93
     32 * NetBSD: screen.h,v 1.2 1995/04/22 07:42:42 cgd
     33 * OpenBSD: screen.h,v 1.5 2003/06/03 03:01:41 millert
     34 *
     35 * Based upon BSD Tetris
     36 *
    537 * Copyright (c) 1992, 1993
    6  *      The Regents of the University of California.  All rights reserved.
     38 *      The Regents of the University of California.
     39 *      Distributed under BSD license.
    740 *
    841 * This code is derived from software contributed to Berkeley by
    942 * Chris Torek and Darren F. Provine.
    1043 *
    11  * Redistribution and use in source and binary forms, with or without
    12  * modification, are permitted provided that the following conditions
    13  * are met:
    14  * 1. Redistributions of source code must retain the above copyright
    15  *    notice, this list of conditions and the following disclaimer.
    16  * 2. Redistributions in binary form must reproduce the above copyright
    17  *    notice, this list of conditions and the following disclaimer in the
    18  *    documentation and/or other materials provided with the distribution.
    19  * 3. Neither the name of the University nor the names of its contributors
    20  *    may be used to endorse or promote products derived from this software
    21  *    without specific prior written permission.
    22  *
    23  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
    24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
    27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    33  * SUCH DAMAGE.
    34  *
    35  *      @(#)screen.h    8.1 (Berkeley) 5/31/93
    3644 */
    3745
     
    4856
    4957#include <sys/types.h>
     58#include <io/console.h>
    5059#include <async.h>
    5160#include <bool.h>
     
    5665} winsize_t;
    5766
     67extern console_ctrl_t *console;
    5868extern winsize_t winsize;
    5969
     
    6171extern void clear_screen(void);
    6272
    63 /* just calls putchar; for tputs */
    6473extern int put(int);
    6574extern void scr_clear(void);
     
    7079extern void scr_update(void);
    7180
     81extern void tsleep(void);
     82extern int tgetchar(void);
     83extern int twait(void);
     84
    7285/** @}
    7386 */
  • uspace/app/tetris/shapes.c

    r764d71e r79ae36dd  
    1 /*      $OpenBSD: shapes.c,v 1.8 2004/07/10 07:26:24 deraadt Exp $      */
    2 /*      $NetBSD: shapes.c,v 1.2 1995/04/22 07:42:44 cgd Exp $   */
     1/*
     2 * Copyright (c) 2011 Martin Decky
     3 * All rights reserved.
     4 *
     5 * Redistribution and use in source and binary forms, with or without
     6 * modification, are permitted provided that the following conditions
     7 * are met:
     8 *
     9 * - Redistributions of source code must retain the above copyright
     10 *   notice, this list of conditions and the following disclaimer.
     11 * - Redistributions in binary form must reproduce the above copyright
     12 *   notice, this list of conditions and the following disclaimer in the
     13 *   documentation and/or other materials provided with the distribution.
     14 * - The name of the author may not be used to endorse or promote products
     15 *   derived from this software without specific prior written permission.
     16 *
     17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27 */
    328
    4 /*-
     29/** Attributations
     30 *
     31 * shapes.c 8.1 (Berkeley) 5/31/93
     32 * NetBSD: shapes.c,v 1.2 1995/04/22 07:42:44 cgd
     33 * OpenBSD: shapes.c,v 1.8 2004/07/10 07:26:24 deraadt
     34 *
     35 * Based upon BSD Tetris
     36 *
    537 * Copyright (c) 1992, 1993
    6  *      The Regents of the University of California.  All rights reserved.
     38 *      The Regents of the University of California.
     39 *      Distributed under BSD license.
    740 *
    841 * This code is derived from software contributed to Berkeley by
    942 * Chris Torek and Darren F. Provine.
    1043 *
    11  * Redistribution and use in source and binary forms, with or without
    12  * modification, are permitted provided that the following conditions
    13  * are met:
    14  * 1. Redistributions of source code must retain the above copyright
    15  *    notice, this list of conditions and the following disclaimer.
    16  * 2. Redistributions in binary form must reproduce the above copyright
    17  *    notice, this list of conditions and the following disclaimer in the
    18  *    documentation and/or other materials provided with the distribution.
    19  * 3. Neither the name of the University nor the names of its contributors
    20  *    may be used to endorse or promote products derived from this software
    21  *    without specific prior written permission.
    22  *
    23  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
    24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
    27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    33  * SUCH DAMAGE.
    34  *
    35  *      @(#)shapes.c    8.1 (Berkeley) 5/31/93
    3644 */
    3745
  • uspace/app/tetris/tetris.c

    r764d71e r79ae36dd  
    1 /*      $OpenBSD: tetris.c,v 1.21 2006/04/20 03:24:12 ray Exp $ */
    2 /*      $NetBSD: tetris.c,v 1.2 1995/04/22 07:42:47 cgd Exp $   */
    3 
    4 /*-
    5  * Copyright (c) 1992, 1993
    6  *      The Regents of the University of California.  All rights reserved.
    7  *
    8  * This code is derived from software contributed to Berkeley by
    9  * Chris Torek and Darren F. Provine.
     1/*
     2 * Copyright (c) 2011 Martin Decky
     3 * All rights reserved.
    104 *
    115 * Redistribution and use in source and binary forms, with or without
    126 * modification, are permitted provided that the following conditions
    137 * are met:
    14  * 1. Redistributions of source code must retain the above copyright
    15  *    notice, this list of conditions and the following disclaimer.
    16  * 2. Redistributions in binary form must reproduce the above copyright
    17  *    notice, this list of conditions and the following disclaimer in the
    18  *    documentation and/or other materials provided with the distribution.
    19  * 3. Neither the name of the University nor the names of its contributors
    20  *    may be used to endorse or promote products derived from this software
    21  *    without specific prior written permission.
    22  *
    23  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
    24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
    27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    33  * SUCH DAMAGE.
    34  *
    35  *      @(#)tetris.c    8.1 (Berkeley) 5/31/93
     8 *
     9 * - Redistributions of source code must retain the above copyright
     10 *   notice, this list of conditions and the following disclaimer.
     11 * - Redistributions in binary form must reproduce the above copyright
     12 *   notice, this list of conditions and the following disclaimer in the
     13 *   documentation and/or other materials provided with the distribution.
     14 * - The name of the author may not be used to endorse or promote products
     15 *   derived from this software without specific prior written permission.
     16 *
     17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27 */
     28
     29/** Attributations
     30 *
     31 * tetris.c 8.1 (Berkeley) 5/31/93
     32 * NetBSD: tetris.c,v 1.2 1995/04/22 07:42:47 cgd
     33 * OpenBSD: tetris.c,v 1.21 2006/04/20 03:24:12 ray
     34 *
     35 * Based upon BSD Tetris
     36 *
     37 * Copyright (c) 1992, 1993
     38 *      The Regents of the University of California.
     39 *      Distributed under BSD license.
     40 *
     41 * This code is derived from software contributed to Berkeley by
     42 * Chris Torek and Darren F. Provine.
     43 *
    3644 */
    3745
     
    5664#include <unistd.h>
    5765#include <getopt.h>
    58 
    59 #include "input.h"
    6066#include "scores.h"
    6167#include "screen.h"
     
    245251        int ch;
    246252       
     253        console = console_init(stdin, stdout);
     254       
    247255        keys = "jkl pq";
    248256       
    249257        classic = 0;
    250         showpreview = 1; 
     258        showpreview = 1;
    251259       
    252260        while ((ch = getopt(argc, argv, "ck:ps")) != -1)
     
    371379                                        scr_msg(key_msg, 0);
    372380                                        scr_msg(msg, 1);
    373                                         (void) fflush(stdout);
    374                                 } while (rwait((struct timeval *) NULL) == -1);
     381                                        console_flush(console);
     382                                } while (!twait());
    375383                               
    376384                                scr_msg(msg, 0);
  • uspace/app/tetris/tetris.h

    r764d71e r79ae36dd  
    1 /*      $OpenBSD: tetris.h,v 1.9 2003/06/03 03:01:41 millert Exp $      */
    2 /*      $NetBSD: tetris.h,v 1.2 1995/04/22 07:42:48 cgd Exp $   */
     1/*
     2 * Copyright (c) 2011 Martin Decky
     3 * All rights reserved.
     4 *
     5 * Redistribution and use in source and binary forms, with or without
     6 * modification, are permitted provided that the following conditions
     7 * are met:
     8 *
     9 * - Redistributions of source code must retain the above copyright
     10 *   notice, this list of conditions and the following disclaimer.
     11 * - Redistributions in binary form must reproduce the above copyright
     12 *   notice, this list of conditions and the following disclaimer in the
     13 *   documentation and/or other materials provided with the distribution.
     14 * - The name of the author may not be used to endorse or promote products
     15 *   derived from this software without specific prior written permission.
     16 *
     17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27 */
    328
    4 /*-
     29/** Attributations
     30 *
     31 * tetris.h 8.1 (Berkeley) 5/31/93
     32 * NetBSD: tetris.h,v 1.2 1995/04/22 07:42:48 cgd
     33 * OpenBSD: tetris.h,v 1.9 2003/06/03 03:01:41 millert
     34 *
     35 * Based upon BSD Tetris
     36 *
    537 * Copyright (c) 1992, 1993
    6  *      The Regents of the University of California.  All rights reserved.
     38 *      The Regents of the University of California.
     39 *      Distributed under BSD license.
    740 *
    841 * This code is derived from software contributed to Berkeley by
    942 * Chris Torek and Darren F. Provine.
    1043 *
    11  * Redistribution and use in source and binary forms, with or without
    12  * modification, are permitted provided that the following conditions
    13  * are met:
    14  * 1. Redistributions of source code must retain the above copyright
    15  *    notice, this list of conditions and the following disclaimer.
    16  * 2. Redistributions in binary form must reproduce the above copyright
    17  *    notice, this list of conditions and the following disclaimer in the
    18  *    documentation and/or other materials provided with the distribution.
    19  * 3. Neither the name of the University nor the names of its contributors
    20  *    may be used to endorse or promote products derived from this software
    21  *    without specific prior written permission.
    22  *
    23  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
    24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
    27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    33  * SUCH DAMAGE.
    34  *
    35  *      @(#)tetris.h    8.1 (Berkeley) 5/31/93
    3644 */
    3745
Note: See TracChangeset for help on using the changeset viewer.