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

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

unix.superglobalmegacorp.com

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