Annotation of 43BSDReno/games/warp/sm.c, revision 1.1

1.1     ! root        1: /* $Header: sm.c,v 7.0 86/10/08 15:13:35 lwall Exp $ */
        !             2: 
        !             3: /* $Log:       sm.c,v $
        !             4:  * Revision 7.0  86/10/08  15:13:35  lwall
        !             5:  * Split into separate files.  Added amoebas and pirates.
        !             6:  * 
        !             7:  */
        !             8: 
        !             9: #include <stdio.h>
        !            10: #include <ctype.h>
        !            11: #include "config.h"
        !            12: 
        !            13: main()
        !            14: {
        !            15:     char screen[23][90], buf[10];
        !            16:     Reg1 int y;
        !            17:     Reg2 int x;
        !            18:     int tmpy, tmpx;
        !            19: 
        !            20:     for (x=0; x<79; x++)
        !            21:        screen[0][x] = ' ';
        !            22:     screen[0][79] = '\0';
        !            23:     
        !            24:     fgets(screen[0],90,stdin);
        !            25:     if (isdigit(screen[0][0])) {
        !            26:        int numstars = atoi(screen[0]);
        !            27: 
        !            28:        for (y=0; y<23; y++) {
        !            29:            for (x=0; x<79; x++)
        !            30:                screen[y][x] = ' ';
        !            31:            screen[y][79] = '\0';
        !            32:        }
        !            33:        
        !            34:        for ( ; numstars; numstars--) {
        !            35:            scanf("%d %d\n",&tmpy,&tmpx);
        !            36:            y = tmpy;
        !            37:            x = tmpx;
        !            38:            screen[y][x+x] = '*';
        !            39:        }
        !            40: 
        !            41:        for (y=0; y<23; y++) {
        !            42:            printf("%s\n",screen[y]);
        !            43:        }
        !            44:     }
        !            45:     else {
        !            46:        Reg3 int numstars = 0;
        !            47: 
        !            48:        for (y=1; y<23; y++) {
        !            49:            for (x=0; x<79; x++)
        !            50:                screen[y][x] = ' ';
        !            51:            screen[y][79] = '\0';
        !            52:        }
        !            53:        
        !            54:        for (y=1; y<23; y++) {
        !            55:            fgets(screen[y],90,stdin);
        !            56:        }
        !            57: 
        !            58:        for (y=0; y<23; y++) {
        !            59:            for (x=0; x<80; x += 2) {
        !            60:                if (screen[y][x] == '*') {
        !            61:                    numstars++;
        !            62:                }
        !            63:                else if (screen[y][x] == '\t' || screen[y][x+1] == '\t') {
        !            64:                    fprintf(stderr,"Cannot have tabs in starmap--please expand.\n");
        !            65:                    exit(1);
        !            66:                }
        !            67:            }
        !            68:        }
        !            69: 
        !            70:        printf("%d\n",numstars);
        !            71: 
        !            72:        for (y=0; y<23; y++) {
        !            73:            for (x=0; x<80; x += 2) {
        !            74:                if (screen[y][x] == '*') {
        !            75:                    printf("%d %d\n",y,x/2);
        !            76:                }
        !            77:            }
        !            78:        }
        !            79:     }
        !            80:     exit(0);
        !            81: }

unix.superglobalmegacorp.com

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