Mercurial > hg > early-roguelike
comparison xrogue/maze.c @ 220:f54901b9c39b
XRogue: convert to ANSI-style function declarations.
author | John "Elwin" Edwards |
---|---|
date | Wed, 02 Mar 2016 21:13:26 -0500 |
parents | e6179860cb76 |
children | 0250220d8cdd |
comparison
equal
deleted
inserted
replaced
219:f9ef86cf22b2 | 220:f54901b9c39b |
---|---|
25 struct cell conn[4]; /* the y,x position of above cell */ | 25 struct cell conn[4]; /* the y,x position of above cell */ |
26 } b_cells; | 26 } b_cells; |
27 | 27 |
28 static char *maze_frontier, *maze_bits; | 28 static char *maze_frontier, *maze_bits; |
29 static int maze_lines, maze_cols; | 29 static int maze_lines, maze_cols; |
30 static char *moffset(), *foffset(); | 30 static char *moffset(int y, int x); |
31 static int rmwall(),findcells(),crankout(),draw_maze(); | 31 static char *foffset(int y, int x); |
32 static void rmwall(int newy, int newx, int oldy, int oldx); | |
33 static void draw_maze(void); | |
34 static int findcells(int y, int x); | |
32 | 35 |
33 /* | 36 /* |
34 * crankout: | 37 * crankout: |
35 * Does actual drawing of maze to window | 38 * Does actual drawing of maze to window |
36 */ | 39 */ |
37 | 40 |
38 static | 41 static |
39 crankout() | 42 void |
43 crankout(void) | |
40 { | 44 { |
41 reg int x, y; | 45 reg int x, y; |
42 | 46 |
43 for (y = 0; y < lines - 3; y++) { | 47 for (y = 0; y < lines - 3; y++) { |
44 move(y + 1, 0); | 48 move(y + 1, 0); |
68 /* | 72 /* |
69 * domaze: | 73 * domaze: |
70 * Draw the maze on this level. | 74 * Draw the maze on this level. |
71 */ | 75 */ |
72 | 76 |
73 do_maze() | 77 void |
78 do_maze(void) | |
74 { | 79 { |
75 reg int least; | 80 reg int least; |
76 reg struct room *rp; | 81 reg struct room *rp; |
77 reg struct linked_list *item; | 82 reg struct linked_list *item; |
78 reg struct object *obj; | 83 reg struct object *obj; |
92 rp->r_max.y = lines - 3; | 97 rp->r_max.y = lines - 3; |
93 draw_maze(); /* put maze into window */ | 98 draw_maze(); /* put maze into window */ |
94 /* | 99 /* |
95 * add some gold to make it worth looking for | 100 * add some gold to make it worth looking for |
96 */ | 101 */ |
97 item = spec_item(GOLD, NULL, NULL, NULL); | 102 item = spec_item(GOLD, 0, 0, 0); |
98 obj = OBJPTR(item); | 103 obj = OBJPTR(item); |
99 obj->o_count *= (rnd(50) + 50); /* add in one large hunk */ | 104 obj->o_count *= (rnd(50) + 50); /* add in one large hunk */ |
100 attach(lvl_obj, item); | 105 attach(lvl_obj, item); |
101 cnt = 0; | 106 cnt = 0; |
102 do { | 107 do { |
105 mvaddch(tp.y, tp.x, GOLD); | 110 mvaddch(tp.y, tp.x, GOLD); |
106 obj->o_pos = tp; | 111 obj->o_pos = tp; |
107 /* | 112 /* |
108 * add in some food to make sure he has enough | 113 * add in some food to make sure he has enough |
109 */ | 114 */ |
110 item = spec_item(FOOD, NULL, NULL, NULL); | 115 item = spec_item(FOOD, 0, 0, 0); |
111 obj = OBJPTR(item); | 116 obj = OBJPTR(item); |
112 attach(lvl_obj, item); | 117 attach(lvl_obj, item); |
113 do { | 118 do { |
114 rnd_pos(rp, &tp); | 119 rnd_pos(rp, &tp); |
115 } until (mvinch(tp.y, tp.x) == FLOOR || cnt++ > 2500); | 120 } until (mvinch(tp.y, tp.x) == FLOOR || cnt++ > 2500); |
144 * draw_maze: | 149 * draw_maze: |
145 * Generate and draw the maze on the screen | 150 * Generate and draw the maze on the screen |
146 */ | 151 */ |
147 | 152 |
148 static | 153 static |
149 draw_maze() | 154 void |
155 draw_maze(void) | |
150 { | 156 { |
151 reg int i, j, more; | 157 reg int i, j, more; |
152 reg char *ptr; | 158 reg char *ptr; |
153 | 159 |
154 maze_lines = (lines - 3) / 2; | 160 maze_lines = (lines - 3) / 2; |
181 /* | 187 /* |
182 * findcells: | 188 * findcells: |
183 * Figure out cells to open up | 189 * Figure out cells to open up |
184 */ | 190 */ |
185 | 191 |
186 static findcells(y,x) | 192 static int |
187 reg int x, y; | 193 findcells(int y, int x) |
188 { | 194 { |
189 reg int rtpos, i; | 195 reg int rtpos, i; |
190 | 196 |
191 *foffset(y, x) = FALSE; | 197 *foffset(y, x) = FALSE; |
192 b_cells.num_pos = 0; | 198 b_cells.num_pos = 0; |
234 * foffset: | 240 * foffset: |
235 * Calculate memory address for frontier | 241 * Calculate memory address for frontier |
236 */ | 242 */ |
237 | 243 |
238 static char * | 244 static char * |
239 foffset(y, x) | 245 foffset(int y, int x) |
240 int y, x; | |
241 { | 246 { |
242 | 247 |
243 return (maze_frontier + (y * maze_cols) + x); | 248 return (maze_frontier + (y * maze_cols) + x); |
244 } | 249 } |
245 | 250 |
249 * Returns true if the player can see the specified location within | 254 * Returns true if the player can see the specified location within |
250 * the confines of a maze (within one column or row) | 255 * the confines of a maze (within one column or row) |
251 */ | 256 */ |
252 | 257 |
253 bool | 258 bool |
254 maze_view(y, x) | 259 maze_view(int y, int x) |
255 int y, x; | |
256 { | 260 { |
257 register int start, goal, delta, ycheck = 0, xcheck = 0, absy, absx, see_radius; | 261 register int start, goal, delta, ycheck = 0, xcheck = 0, absy, absx, see_radius; |
258 register bool row; | 262 register bool row; |
259 | 263 |
260 /* Get the absolute value of y and x differences */ | 264 /* Get the absolute value of y and x differences */ |
358 * moffset: | 362 * moffset: |
359 * Calculate memory address for bits | 363 * Calculate memory address for bits |
360 */ | 364 */ |
361 | 365 |
362 static char * | 366 static char * |
363 moffset(y, x) | 367 moffset(int y, int x) |
364 int y, x; | |
365 { | 368 { |
366 return (maze_bits + (y * (cols - 1)) + x); | 369 return (maze_bits + (y * (cols - 1)) + x); |
367 } | 370 } |
368 | 371 |
369 /* | 372 /* |
370 * rmwall: | 373 * rmwall: |
371 * Removes appropriate walls from the maze | 374 * Removes appropriate walls from the maze |
372 */ | 375 */ |
373 static | 376 static |
374 rmwall(newy, newx, oldy, oldx) | 377 void |
375 int newy, newx, oldy, oldx; | 378 rmwall(int newy, int newx, int oldy, int oldx) |
376 { | 379 { |
377 reg int xdif,ydif; | 380 reg int xdif,ydif; |
378 | 381 |
379 xdif = newx - oldx; | 382 xdif = newx - oldx; |
380 ydif = newy - oldy; | 383 ydif = newy - oldy; |