oga's tools
Revision | 6846bdb3682d352dd20597ee14c3f3e3f74d1de1 (tree) |
---|---|
Zeit | 2013-12-31 13:57:33 |
Autor | oga <oga@mxg....> |
Commiter | oga |
2013/12/12 fix galaxian prob. (no env, rnd() is always 0)
@@ -9,6 +9,7 @@ | ||
9 | 9 | * 1995.08.21 Ver 1.04 high score support |
10 | 10 | * 1995.08.23 Ver 1.05 star support |
11 | 11 | * 2003.05.23 Ver 1.06 use usleep |
12 | + * 2013.12.31 Ver 1.07 fix noenv, rnd() prob | |
12 | 13 | */ |
13 | 14 | |
14 | 15 | #include <stdio.h> |
@@ -80,7 +81,7 @@ int wait = 10; /* game speed 0.2 sec */ | ||
80 | 81 | int wait = 40; /* game speed */ |
81 | 82 | #endif /* X68000 */ |
82 | 83 | |
83 | -int xmin = 2, xmax, ymax; | |
84 | +int xmin = 2, xmax = 0, ymax = 0; /* V1.07-C */ | |
84 | 85 | int sc = 0, stage = 0, typ = 0; /* score, stage, alien_type */ |
85 | 86 | int hisc = 0; /* high score */ |
86 | 87 | char hinm[100]; /* high name */ |
@@ -114,13 +115,16 @@ char *b[]; | ||
114 | 115 | /* INITIALIZE */ |
115 | 116 | for (i = 1; i<a ; i++) { |
116 | 117 | if (!strcmp(b[i],"-h")) { |
117 | - printf("usage : galaxian [speed<%d>] [-n]\n",wait); | |
118 | + printf("usage : galaxian [<wait(%d)>] [-n]\n",wait); | |
119 | + printf(" <wait> : wait <wait> x 1/100sec\n"); | |
120 | + printf(" -n : no star\n"); | |
121 | + printf(" move ship : [J]<=>[L]\n"); | |
118 | 122 | exit(1); |
119 | 123 | } else if (!strcmp(b[i],"-n")) { |
120 | 124 | starf = 0; |
121 | 125 | } else { |
122 | 126 | wait = atoi(b[1]); |
123 | - printf("speed = %d\n",wait); | |
127 | + printf("wait = %d\n",wait); | |
124 | 128 | } |
125 | 129 | } |
126 | 130 | #ifdef X3050RX |
@@ -131,8 +135,12 @@ char *b[]; | ||
131 | 135 | alien[1]="[37mv V[1B[36mXOOX\n"; |
132 | 136 | #endif /* X68000 */ |
133 | 137 | #ifdef X3050RX |
134 | - xmax = atoi(getenv("COLUMNS"))-RSPACE; | |
135 | - ymax = atoi(getenv("LINES"))-1; | |
138 | + if (getenv("COLUMNS")) { /* V1.07-A */ | |
139 | + xmax = atoi(getenv("COLUMNS"))-RSPACE; | |
140 | + } | |
141 | + if (getenv("LINES")) { /* V1.07-A */ | |
142 | + ymax = atoi(getenv("LINES"))-1; | |
143 | + } | |
136 | 144 | if (xmax == 0) |
137 | 145 | xmax = 80-RSPACE; |
138 | 146 | if (ymax == 0) |
@@ -487,7 +495,14 @@ struct al_loc *alp; | ||
487 | 495 | rnd(n) |
488 | 496 | int n; |
489 | 497 | { |
490 | - return(rand()*n/RAND_MAX); | |
498 | + int val; | |
499 | + int max = RAND_MAX; | |
500 | + | |
501 | + if (max > 0xffff) { | |
502 | + max = 0xffff; | |
503 | + } | |
504 | + /* return(rand()*n/RAND_MAX); */ | |
505 | + return((rand() & max)*n/max); | |
491 | 506 | } |
492 | 507 | |
493 | 508 | /* DISPLAY SCORE */ |