sm.c revision 1.1 1 /* $Header: /tank/opengrok/rsync2/NetBSD/src/games/warp/sm.c,v 1.1 2020/11/09 23:37:05 kamil Exp $ */
2
3 /* $Log: sm.c,v $
4 /* Revision 1.1 2020/11/09 23:37:05 kamil
5 /* Add Warp Kit, Version 7.0 by Larry Wall
6 /*
7 /* Warp is a real-time space war game that doesn't get boring very quickly.
8 /* Read warp.doc and the manual page for more information.
9 /*
10 /* games/warp originally distributed with 4.3BSD-Reno, is back to the BSD
11 /* world via NetBSD. Its remnants were still mentioned in games/Makefile.
12 /*
13 /* Larry Wall, the original author and the copyright holder, generously
14 /* donated the game and copyright to The NetBSD Foundation, Inc.
15 /*
16 /* Import the game sources as-is from 4.3BSD-Reno, with the cession
17 /* of the copyright and license to BSD-2-clause NetBSD-style.
18 /*
19 /* Signed-off-by: Larry Wall <larry (at) wall.org>
20 /* Signed-off-by: Kamil Rytarowski <kamil (at) netbsd.org>
21 /*
22 * Revision 7.0 86/10/08 15:13:35 lwall
23 * Split into separate files. Added amoebas and pirates.
24 *
25 */
26
27 #include <stdio.h>
28 #include <ctype.h>
29 #include "config.h"
30
31 main()
32 {
33 char screen[23][90], buf[10];
34 Reg1 int y;
35 Reg2 int x;
36 int tmpy, tmpx;
37
38 for (x=0; x<79; x++)
39 screen[0][x] = ' ';
40 screen[0][79] = '\0';
41
42 fgets(screen[0],90,stdin);
43 if (isdigit(screen[0][0])) {
44 int numstars = atoi(screen[0]);
45
46 for (y=0; y<23; y++) {
47 for (x=0; x<79; x++)
48 screen[y][x] = ' ';
49 screen[y][79] = '\0';
50 }
51
52 for ( ; numstars; numstars--) {
53 scanf("%d %d\n",&tmpy,&tmpx);
54 y = tmpy;
55 x = tmpx;
56 screen[y][x+x] = '*';
57 }
58
59 for (y=0; y<23; y++) {
60 printf("%s\n",screen[y]);
61 }
62 }
63 else {
64 Reg3 int numstars = 0;
65
66 for (y=1; y<23; y++) {
67 for (x=0; x<79; x++)
68 screen[y][x] = ' ';
69 screen[y][79] = '\0';
70 }
71
72 for (y=1; y<23; y++) {
73 fgets(screen[y],90,stdin);
74 }
75
76 for (y=0; y<23; y++) {
77 for (x=0; x<80; x += 2) {
78 if (screen[y][x] == '*') {
79 numstars++;
80 }
81 else if (screen[y][x] == '\t' || screen[y][x+1] == '\t') {
82 fprintf(stderr,"Cannot have tabs in starmap--please expand.\n");
83 exit(1);
84 }
85 }
86 }
87
88 printf("%d\n",numstars);
89
90 for (y=0; y<23; y++) {
91 for (x=0; x<80; x += 2) {
92 if (screen[y][x] == '*') {
93 printf("%d %d\n",y,x/2);
94 }
95 }
96 }
97 }
98 exit(0);
99 }
100