• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

oga's tools


Commit MetaInfo

修訂6846bdb3682d352dd20597ee14c3f3e3f74d1de1 (tree)
時間2013-12-31 13:57:33
作者oga <oga@mxg....>
Commiteroga

Log Message

2013/12/12 fix galaxian prob. (no env, rnd() is always 0)

Change Summary

差異

--- a/galaxian.c
+++ b/galaxian.c
@@ -9,6 +9,7 @@
99 * 1995.08.21 Ver 1.04 high score support
1010 * 1995.08.23 Ver 1.05 star support
1111 * 2003.05.23 Ver 1.06 use usleep
12+ * 2013.12.31 Ver 1.07 fix noenv, rnd() prob
1213 */
1314
1415 #include <stdio.h>
@@ -80,7 +81,7 @@ int wait = 10; /* game speed 0.2 sec */
8081 int wait = 40; /* game speed */
8182 #endif /* X68000 */
8283
83-int xmin = 2, xmax, ymax;
84+int xmin = 2, xmax = 0, ymax = 0; /* V1.07-C */
8485 int sc = 0, stage = 0, typ = 0; /* score, stage, alien_type */
8586 int hisc = 0; /* high score */
8687 char hinm[100]; /* high name */
@@ -114,13 +115,16 @@ char *b[];
114115 /* INITIALIZE */
115116 for (i = 1; i<a ; i++) {
116117 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");
118122 exit(1);
119123 } else if (!strcmp(b[i],"-n")) {
120124 starf = 0;
121125 } else {
122126 wait = atoi(b[1]);
123- printf("speed = %d\n",wait);
127+ printf("wait = %d\n",wait);
124128 }
125129 }
126130 #ifdef X3050RX
@@ -131,8 +135,12 @@ char *b[];
131135 alien[1]="v VXOOX\n";
132136 #endif /* X68000 */
133137 #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+ }
136144 if (xmax == 0)
137145 xmax = 80-RSPACE;
138146 if (ymax == 0)
@@ -487,7 +495,14 @@ struct al_loc *alp;
487495 rnd(n)
488496 int n;
489497 {
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);
491506 }
492507
493508 /* DISPLAY SCORE */