comparison arogue7/maze.c @ 219:f9ef86cf22b2

Advanced Rogue 7: convert to ANSI-style function declarations. Almost 1500 lines of compiler warnings remain, and the GCC developers are already working on a new version with even more warnings turned on by default.
author John "Elwin" Edwards
date Fri, 19 Feb 2016 21:02:28 -0500
parents adfa37e67084
children 0250220d8cdd
comparison
equal deleted inserted replaced
218:56e748983fa8 219:f9ef86cf22b2
28 28
29 static char *frontier, 29 static char *frontier,
30 *bits; 30 *bits;
31 static int maze_lines, 31 static int maze_lines,
32 maze_cols; 32 maze_cols;
33 char *moffset(), 33
34 *foffset(); 34 void draw_maze(void);
35 int findcells(int y, int x);
36 char *foffset(int y, int x);
37 char *moffset(int y, int x);
38 void rmwall(int newy, int newx, int oldy, int oldx);
35 39
36 40
37 /* 41 /*
38 * crankout: 42 * crankout:
39 * Does actual drawing of maze to window 43 * Does actual drawing of maze to window
40 */ 44 */
41 crankout() 45 void
46 crankout(void)
42 { 47 {
43 reg int x, y; 48 reg int x, y;
44 49
45 for (y = 0; y < lines - 3; y++) { 50 for (y = 0; y < lines - 3; y++) {
46 move(y + 1, 0); 51 move(y + 1, 0);
69 74
70 /* 75 /*
71 * domaze: 76 * domaze:
72 * Draw the maze on this level. 77 * Draw the maze on this level.
73 */ 78 */
74 do_maze() 79 void
80 do_maze(void)
75 { 81 {
76 reg int least; 82 reg int least;
77 reg struct room *rp; 83 reg struct room *rp;
78 reg struct linked_list *item; 84 reg struct linked_list *item;
79 reg struct object *obj; 85 reg struct object *obj;
93 rp->r_max.y = lines - 3; 99 rp->r_max.y = lines - 3;
94 draw_maze(); /* put maze into window */ 100 draw_maze(); /* put maze into window */
95 /* 101 /*
96 * add some gold to make it worth looking for 102 * add some gold to make it worth looking for
97 */ 103 */
98 item = spec_item(GOLD, NULL, NULL, NULL); 104 item = spec_item(GOLD, 0, 0, 0);
99 obj = OBJPTR(item); 105 obj = OBJPTR(item);
100 obj->o_count *= (rnd(5) + 5); /* add in one large hunk */ 106 obj->o_count *= (rnd(5) + 5); /* add in one large hunk */
101 attach(lvl_obj, item); 107 attach(lvl_obj, item);
102 cnt = 0; 108 cnt = 0;
103 do { 109 do {
106 mvaddch(tp.y, tp.x, GOLD); 112 mvaddch(tp.y, tp.x, GOLD);
107 obj->o_pos = tp; 113 obj->o_pos = tp;
108 /* 114 /*
109 * add in some food to make sure he has enough 115 * add in some food to make sure he has enough
110 */ 116 */
111 item = spec_item(FOOD, NULL, NULL, NULL); 117 item = spec_item(FOOD, 0, 0, 0);
112 obj = OBJPTR(item); 118 obj = OBJPTR(item);
113 attach(lvl_obj, item); 119 attach(lvl_obj, item);
114 do { 120 do {
115 rnd_pos(rp, &tp); 121 rnd_pos(rp, &tp);
116 } until (mvinch(tp.y, tp.x) == FLOOR || cnt++ > 5000); 122 } until (mvinch(tp.y, tp.x) == FLOOR || cnt++ > 5000);
131 137
132 /* 138 /*
133 * draw_maze: 139 * draw_maze:
134 * Generate and draw the maze on the screen 140 * Generate and draw the maze on the screen
135 */ 141 */
136 draw_maze() 142 void
143 draw_maze(void)
137 { 144 {
138 reg int i, j, more; 145 reg int i, j, more;
139 reg char *ptr; 146 reg char *ptr;
140 147
141 maze_lines = (lines - 3) / 2; 148 maze_lines = (lines - 3) / 2;
167 174
168 /* 175 /*
169 * findcells: 176 * findcells:
170 * Figure out cells to open up 177 * Figure out cells to open up
171 */ 178 */
172 findcells(y,x) 179 int
173 reg int x, y; 180 findcells(int y, int x)
174 { 181 {
175 reg int rtpos, i; 182 reg int rtpos, i;
176 183
177 *foffset(y, x) = FALSE; 184 *foffset(y, x) = FALSE;
178 border_cells.num_pos = 0; 185 border_cells.num_pos = 0;
219 /* 226 /*
220 * foffset: 227 * foffset:
221 * Calculate memory address for frontier 228 * Calculate memory address for frontier
222 */ 229 */
223 char * 230 char *
224 foffset(y, x) 231 foffset(int y, int x)
225 int y, x;
226 { 232 {
227 233
228 return (frontier + (y * maze_cols) + x); 234 return (frontier + (y * maze_cols) + x);
229 } 235 }
230 236
234 * Returns true if the player can see the specified location within 240 * Returns true if the player can see the specified location within
235 * the confines of a maze (within one column or row) 241 * the confines of a maze (within one column or row)
236 */ 242 */
237 243
238 bool 244 bool
239 maze_view(y, x) 245 maze_view(int y, int x)
240 int y, x;
241 { 246 {
242 register int start, goal, delta, ycheck, xcheck, absy, absx, see_radius; 247 register int start, goal, delta, ycheck, xcheck, absy, absx, see_radius;
243 register bool row; 248 register bool row;
244 249
245 /* Get the absolute value of y and x differences */ 250 /* Get the absolute value of y and x differences */
339 /* 344 /*
340 * moffset: 345 * moffset:
341 * Calculate memory address for bits 346 * Calculate memory address for bits
342 */ 347 */
343 char * 348 char *
344 moffset(y, x) 349 moffset(int y, int x)
345 int y, x;
346 { 350 {
347 351
348 return (bits + (y * (cols - 1)) + x); 352 return (bits + (y * (cols - 1)) + x);
349 } 353 }
350 354
353 357
354 /* 358 /*
355 * rmwall: 359 * rmwall:
356 * Removes appropriate walls from the maze 360 * Removes appropriate walls from the maze
357 */ 361 */
358 rmwall(newy, newx, oldy, oldx) 362 void
359 int newy, newx, oldy, oldx; 363 rmwall(int newy, int newx, int oldy, int oldx)
360 { 364 {
361 reg int xdif,ydif; 365 reg int xdif,ydif;
362 366
363 xdif = newx - oldx; 367 xdif = newx - oldx;
364 ydif = newy - oldy; 368 ydif = newy - oldy;