Annotation of os2sdk/demos/apps/bigben/bigben.c, revision 1.1.1.2

1.1       root        1: /*
                      2:  * This example uses a few of the many VIO calls.
                      3:  * 
                      4:  * This example puts the time on the screen in large numbers.
1.1.1.2 ! root        5:  *
        !             6:  * Created by Microsoft Corp. 1986
1.1       root        7:  */
                      8: 
1.1.1.2 ! root        9: #include <os2def.h>
        !            10: #define INCL_DOSPROCESS
        !            11: #define INCL_DOSDATETIME
        !            12: #include <bsedos.h>
        !            13: #define INCL_SUB
        !            14: #include <bsesub.h>
1.1       root       15: #include <stdio.h>
                     16: 
                     17: #define        CHAR_WIDTH      8
                     18: #define        CHAR_HEIGHT     7
                     19: 
                     20: #define        CLOCK_ROW       10      /* row to start the clock */
                     21: #define        TOTAL_COLMS     80      /* screen size in colms */
                     22: #define        TOTAL_ROWS      24      /* screen size in rows */
                     23: 
                     24:        
                     25: char   BigChars[10][CHAR_HEIGHT][CHAR_WIDTH] = {
                     26: 
                     27: {
                     28:        "   00  ",
                     29:        "  0  0 ",
                     30:        " 0    0",
                     31:        " 0    0",
                     32:        " 0    0",
                     33:        "  0  0 ",
                     34:        "   00  "
                     35: },
                     36: {
                     37:        "   1   ",
                     38:        "   1   ",
                     39:        "   1   ",
                     40:        "   1   ",
                     41:        "   1   ",
                     42:        "   1   ",
                     43:        "   1   "
                     44: }, 
                     45: {
                     46:        "  2222 ",
                     47:        " 2    2",
                     48:        "      2",
                     49:        "     2 ",
                     50:        "   2   ",
                     51:        "  2    ",
                     52:        " 222222" 
                     53: },
                     54: {
                     55:        " 33333 ",
                     56:        "      3",
                     57:        "      3",
                     58:        "   333 ",
                     59:        "      3",
                     60:        "      3",
                     61:        " 33333 " 
                     62: },
                     63: {
                     64:        "    44 ",
                     65:        "   4 4 ",
                     66:        "  4  4 ",
                     67:        " 4   4 ",
                     68:        " 444444",
                     69:        "     4 ",
                     70:        "     4 " 
                     71: },
                     72: {
                     73:        " 555555",
                     74:        " 5     ",
                     75:        " 55555 ",
                     76:        "      5",
                     77:        "      5",
                     78:        " 5    5",
                     79:        "  5555 " 
                     80: },
                     81: {
                     82:        "    6  ",
                     83:        "   6   ",
                     84:        "  6    ",
                     85:        "  6666 ",
                     86:        " 6    6",
                     87:        " 6    6",
                     88:        "  6666 " 
                     89: },
                     90: {
                     91:        " 777777",
                     92:        "      7",
                     93:        "     7 ",
                     94:        "    7  ",
                     95:        "   7   ",
                     96:        "  7    ",
                     97:        " 7     "
                     98: },
                     99: {
                    100:        "  8888 ",
                    101:        " 8    8",
                    102:        " 8    8",
                    103:        "  8888 ",
                    104:        " 8    8",
                    105:        " 8    8",
                    106:        "  8888 "
                    107: },
                    108: {
                    109:        "  9999 ",
                    110:        " 9    9",
                    111:        " 9    9",
                    112:        "  9999 ",
                    113:        "    9  ",
                    114:        "   9   ",
                    115:        "  9    "
                    116: }
                    117: };
                    118: 
                    119: 
                    120: main(argc, argv)
                    121:        int     argc;
                    122:        char    *argv[];
                    123: {
                    124:        unsigned        rc;     /* return code */
1.1.1.2 ! root      125:        DATETIME Now;    /* time struct for DosGetDateTime */
1.1       root      126: 
                    127:        /* clear the screen */
                    128: 
1.1.1.2 ! root      129:        VioWrtNCell( " \07", TOTAL_ROWS * TOTAL_COLMS, 0, 0, 0 );
1.1       root      130: 
1.1.1.2 ! root      131:        /* paint separators between hours and minutes, and minutes and seconds*/
1.1       root      132: 
1.1.1.2 ! root      133:        VioWrtNCell( "|\07", 1, (CLOCK_ROW + 2), 27, 0 );
        !           134:        VioWrtNCell( "|\07", 1, (CLOCK_ROW + 5), 27, 0 );
        !           135:        VioWrtNCell( "|\07", 1, (CLOCK_ROW + 2), 52, 0 );
        !           136:        VioWrtNCell( "|\07", 1, (CLOCK_ROW + 5), 52, 0 );
1.1       root      137:         
                    138:        for (;;) {
                    139: 
                    140:            /* get the system time */
                    141: 
1.1.1.2 ! root      142:            if (rc = DosGetDateTime( &Now))  {
1.1       root      143: 
1.1.1.2 ! root      144:                printf("DosGetDateTime failed, error: %d\n", rc);
        !           145:                DosExit(EXIT_PROCESS, 0);
1.1       root      146:            }
                    147: 
                    148:            /* write the digits out to the screen */
                    149: 
1.1.1.2 ! root      150:            LoadNumber(Now.hours / 10, 5, CLOCK_ROW);
        !           151:            LoadNumber(Now.hours % 10, 15, CLOCK_ROW);
1.1       root      152:            LoadNumber(Now.minutes / 10, 30, CLOCK_ROW);
                    153:            LoadNumber(Now.minutes % 10, 40, CLOCK_ROW);
                    154:            LoadNumber(Now.seconds / 10, 55, CLOCK_ROW);
                    155:            LoadNumber(Now.seconds % 10, 65, CLOCK_ROW);
                    156: 
1.1.1.2 ! root      157:            DosSleep(900L);
1.1       root      158:        }
                    159: }
                    160: 
                    161: 
                    162: /* display the digit at the given coordinates */
                    163: 
                    164: LoadNumber( dig, x, y )
                    165:        unsigned        dig;
                    166:        unsigned        x;
                    167:        unsigned        y;
                    168: {
                    169:        int     i;
                    170: 
                    171:        /* write a list of char strings to make up a display number */
                    172: 
                    173:        for (i=0; (i < CHAR_HEIGHT); i++) 
                    174: 
                    175:            /* write a character string starting from the coordinates */
                    176: 
1.1.1.2 ! root      177:            VioWrtCharStr( BigChars[dig][i], CHAR_WIDTH, y++, x, 0);
1.1       root      178: } 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.