8 extern int view_x, view_y; /* VIEW AREA (UPPER LEFT CORNER) */
\r
9 extern int viewpage; /* CURRENTLY VIEWED PAGE */
\r
10 extern int startup_vmode; /* VIDEO MODE STARTUP SETTINGS, -1 IF NOT INIT */
\r
12 int far *topography; /* BACKGROUND TILE LIST (ARRAY) */
\r
13 int far *terrain; /* FOREGROUND TILE LIST (ARRAY) */
\r
14 int world_type=75; /* TENDENCY TO GRASS */
\r
15 int edgemode=1; /* BLOCKY GRASS/DIRT OR EDGED? */
\r
16 extern int frogmode;
\r
20 * Loads the world foreground tile list with roads.
\r
23 void init_foreground(void)
\r
25 register int x, tile, fails;
\r
27 /* INITIALIZE FOREGROUND */
\r
28 for (x=0; x<WORLD_TILES_TOTAL; x++)
\r
29 terrain[x]=EMPTY_TILE; /* FILL WITH EMPTY TILES */
\r
31 create_roads (); /* LAY DOWN SOME ROADS */
\r
33 /* ADD RANDOM TERRAIN */
\r
34 for (x=0; x<random(MAX_TERRAIN-MIN_TERRAIN)+MIN_TERRAIN; x++)
\r
38 /* ATTEMPT TO PLACE TERRAIN -- QUIT ON EXCESSIVE FAILURE */
\r
40 tile=random(WORLD_TILES_TOTAL);
\r
42 } while (terrain[tile]!=EMPTY_TILE && fails<MAX_FAILS);
\r
44 if (fails<MAX_FAILS)
\r
46 switch (random(12)+1)
\r
48 case 1: terrain[tile]=OBJ_SIGN; break;
\r
49 case 2: terrain[tile]=OBJ_FIRST_GEM+random(OBJ_TOTAL_GEM); break;
\r
50 case 3: terrain[tile]=ANM_URANIUM; break;
\r
52 case 5: terrain[tile]=ANM_FIRE; break;
\r
53 case 6: if (random(100)<50) terrain[tile]=ANM_WATER1;
\r
54 else terrain[tile]=ANM_WATER2; break;
\r
55 case 7: terrain[tile]=OBJ_ROCK1; break;
\r
56 case 8: terrain[tile]=OBJ_ROCK2; break;
\r
57 case 9: terrain[tile]=OBJ_ROCK3; break;
\r
60 case 12: terrain[tile]=OBJ_BUSHES; break;
\r
72 * Loads the world background tile list with grassy tiles.
\r
75 void init_background(void)
\r
77 register int x, y, landtype_left, landtype_up, landtype_here;
\r
79 /* INITIALIZE BACKGROUND BY RANDOMLY PICKING TILES */
\r
82 topography[0]=random(NUM_LAND_TILES)+FIRST_LAND_TILE;
\r
85 for (x=1; x<WORLD_WIDTH; x++)
\r
87 landtype_left=isdirt(topography[x-1]);
\r
88 landtype_here=landtype_left;
\r
89 if (random(100)>=CHANCE_LAND_GROUPING) /* NO GROUPING */
\r
91 if (random(100)>=world_type) landtype_here=1;
\r
92 else landtype_here=0;
\r
95 if (landtype_here==0) topography[x]=
\r
96 random (NUM_GRASS_TILES)+FIRST_GRASS_TILE; /* GRASS */
\r
98 random (NUM_DIRT_TILES)+FIRST_DIRT_TILE; /* DIRT */
\r
101 /* DO FIRST COLUMN */
\r
102 for (y=1; y<WORLD_HEIGHT; y++)
\r
104 landtype_up=isdirt(topography[WORLD_TILE(0,y-1)]);
\r
105 landtype_here=landtype_up;
\r
106 if (random(100)>=CHANCE_LAND_GROUPING) /* NO GROUPING */
\r
108 if (random(100)>=world_type) landtype_here=1;
\r
109 else landtype_here=0;
\r
112 if (landtype_here==0) topography[WORLD_TILE(0,y)]=
\r
113 random (NUM_GRASS_TILES)+FIRST_GRASS_TILE; /* GRASS */
\r
114 else topography[WORLD_TILE(0,y)]=
\r
115 random (NUM_DIRT_TILES)+FIRST_DIRT_TILE; /* DIRT */
\r
118 /* DO SUBSEQUENT ROWS */
\r
119 for (y=1; y<WORLD_HEIGHT; y++)
\r
120 for (x=1; x<WORLD_WIDTH; x++)
\r
122 landtype_left=isdirt(topography[WORLD_TILE(x-1,y)]);
\r
123 landtype_up=isdirt(topography[WORLD_TILE(x,y-1)]);
\r
124 landtype_here=landtype_left;
\r
126 if (random(100)>=CHANCE_LAND_GROUPING) /* UNGROUP */
\r
128 if (random(100)>=world_type) landtype_here=1;
\r
129 else landtype_here=0;
\r
131 else if (random(2)) landtype_here=landtype_up;
\r
133 if (landtype_here==0) topography[WORLD_TILE(x,y)]=
\r
134 random (NUM_GRASS_TILES)+FIRST_GRASS_TILE; /* GRASS */
\r
135 else topography[WORLD_TILE(x,y)]=
\r
136 random (NUM_DIRT_TILES)+FIRST_DIRT_TILE; /* DIRT */
\r
139 if (edgemode) add_dirt_edges ();
\r
144 * Initializes background and foreground tile lists.
\r
147 void init_world(void)
\r
151 view_x=random(WORLD_WIDTH-VIEW_WIDTH);
\r
152 view_y=random(WORLD_HEIGHT-VIEW_HEIGHT);
\r