Add .gitignore
[ztornado.git] / scores.inf
1 ! Z-Tornado - Two player weather action game
2 !
3 ! Tornado is copyright (C) 2000-2002  Oliver Feiler
4 ! http://www.lionking.org/~kiza/linux/tornado
5 ! Inform version copyright (c) 2003  Sophie Frühling (sfruehling@aon.at)
6
7 ! This program is free software; you can redistribute it and/or modify
8 ! it under the terms of the GNU General Public License as published by
9 ! the Free Software Foundation; either version 3 of the License, or
10 ! (at your option) any later version.
11 !
12 ! This program is distributed in the hope that it will be useful,
13 ! but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 ! GNU General Public License for more details.
16 !
17 ! You should have received a copy of the GNU General Public License
18 ! along with this program. If not, see <https://www.gnu.org/licenses/>.
19
20 Array hghscr_arr -> 7;
21 Array hghscr_tmparr -> 7;
22 [ InitHighScores  i j tmp;
23   print "^^[Trying to read highscore file]^";
24   @restore highscore_array 220 highscore_file -> i;
25   ! We couldn't read in the highscore file so we set up a new
26   ! highscore
27   if (i < 220) {
28     print "^[Couldn't read highscore file]^^";
29     print "[Please press a key]^"; Read();
30     tmp = 11000;
31     Nullify(hghscr_arr);
32     Nullify(hghscr_tmparr);
33     for (i = 0: i < 10: i++) {
34       for (j = i*22: j < i*22 + 15: j++)
35         highscore_array->j = '-';
36       tmp = tmp - 1000;
37       AddShort(hghscr_arr, hghscr_tmparr, tmp);
38       for (: j < (i+1)*22: j++)
39         highscore_array->j = hghscr_arr->(j - (i*22 + 15));
40     }
41   }
42 ];
43
44 Array tmp_hscr -> 7;
45 [ AddToHighScore player_name scr_arr  i;
46   for (i = 0: i < 10: i++) {
47     LookUpHighScore(tmp_hscr, i);
48     if (CompareLongs(scr_arr, tmp_hscr) > 0) {
49       InsertScoreTable(player_name, scr_arr, i);
50       rtrue;
51     }
52   }
53 ];
54
55 ! Copies the score at num into hs_array
56 [ LookUpHighScore hs_array num  i tmp;
57   tmp = num*22 + 15;
58   for (i = 0: i < 7: i++, tmp++)
59     hs_array->i = highscore_array->tmp;
60 ];
61
62 [ InsertScoreTable pl_nm scr_arr num  i tmp;
63   ! Shift all lower scores by 22
64   for (i = 219: i >= (num + 1)*22: i--)
65     highscore_array->i = highscore_array->(i - 22);
66   ! Insert the name
67   for (i = num*22, tmp = 2: tmp < 17: i++, tmp++)
68     highscore_array->i = pl_nm->tmp;
69   ! Insert the score
70   for (i = num*22 + 15, tmp = 0: tmp < 7: i++, tmp++)
71     highscore_array->i = scr_arr->tmp;
72 ];
73
74 [ ShowCurrentScores;
75   DrawCurrentScores();
76   DrawStatusLine();
77   Read();
78   ClearDialogWindow();
79   DrawSnowWorld();
80 ];
81
82 ! The high score window may overlap
83 ! with some part of a house or snow
84 [ ShowHighScores;
85   ClearHighScoreWindow();
86   DrawHighScores();
87   DrawStatusLine();
88   Read();
89   ClearHighScoreWindow();
90   DrawSnowWorld();
91 ];
92
93 [ PrintHighScoreName num  i;
94   for (i = num*22 : i < num*22 + 15: i++)
95     print (char) highscore_array->i;
96 ];
97
98 [ PrintHighScoreNumber num  i;
99   i = num*22 + 15;
100   ! Right-align numbers
101   while (i < (num+1)*22 - 1 && highscore_array->i == 0) {
102     print (char) ' '; i++;
103   }
104   for (: i < (num+1)*22: i++)
105     print highscore_array->i;
106 ];
107
108 !------------------ Numbers Juggling -----------------
109 ! Long numbers for calculating and printing out scores
110 ! The long numbers can have up to 7 digits.
111
112 [ Nullify num_array  i;
113   for (i = 0: i < 7: i++)
114     num_array->i = 0;
115 ];
116
117 [ CopyArray dest_array src_array  i;
118   for (i = 0: i < 7: i++)
119     dest_array->i = src_array->i;
120 ];
121
122 ! This appears not to work if dest_array is one of the source arrays
123 [ AddLongs dest_array array1 array2  i tmp plus;
124   for (i = 6, plus = 0: i >= 0: i--) {
125     tmp = array1->i + array2->i;
126     if (plus) tmp++;
127     if (tmp > 9) {
128       plus = 1;
129       tmp = tmp%10;
130     }
131     else plus = 0;
132     dest_array->i = tmp;
133   }
134 ];
135
136 Array short_array -> 7;
137 [ AddShort dest_array num_array num;
138   ShortToArray(short_array, num);
139   AddLongs(dest_array, num_array, short_array);
140 ];
141
142 [ ShortToArray num_array num  i tmp;
143   num_array->0 = 0;
144   num_array->1 = 0;
145   for (i = 2, tmp = 10000: i < 7: i++, tmp = tmp/10) {
146     num_array->i = num/tmp;
147     num = num%tmp;
148   }
149 ];
150
151 Array mult_array -> 7;
152 Array culm_array -> 7;
153 Array multitmp_array -> 7;
154 [ Multiply dest_array num_array num  i j tmp plus;
155   if (num == 0) {
156     Nullify(dest_array);
157     rtrue;
158   }
159   Nullify(culm_array);
160   ShortToArray(short_array, num);
161   i = 0;
162   while (short_array->i == 0) i++;
163   for (: i < 7: i++) {
164     Nullify(mult_array);
165     Nullify(multitmp_array);
166     for (j = 6: j >= 0: j--) {
167       tmp = num_array->j * short_array->i;
168       if (plus) tmp = tmp + plus;
169       if (tmp > 9) {
170         plus = tmp/10;
171         tmp = tmp%10;
172       }
173       else plus = 0;
174       mult_array->j = tmp;
175     }
176     Shift(mult_array, 6 - i);
177     AddLongs(multitmp_array, culm_array, mult_array);
178     Nullify(mult_array);
179     AddLongs(culm_array, multitmp_array, mult_array);
180   }
181   CopyArray(dest_array, culm_array);
182 ];
183
184 Array shift_array -> 7;
185 [ Shift the_array num  i;
186   Nullify(shift_array);
187   for (i = num: i < 7: i++)
188     shift_array->(i-num) = the_array->i;
189   CopyArray(the_array, shift_array);
190 ];
191  
192 [ CompareLongs array1 array2  i;
193   for (i = 0: i < 7: i++) {
194     if (array1->i < array2->i)
195       return -1;
196     if (array1->i > array2->i)
197       return 1;
198   }
199   return 0;
200 ];
201
202 [ longnr num_array  i;
203   i = 0;
204   ! Don't print out leading zeroes
205   while (i < 6 && num_array->i == 0)
206     i++;
207   for (: i < 7: i++)
208     print num_array->i;
209 ];
210