tfv: making engine generic

This commit is contained in:
Vince Weaver 2018-06-15 00:08:15 -04:00
parent 8225da796b
commit 0e0344fd0e
3 changed files with 51 additions and 20 deletions

View File

@ -46,13 +46,24 @@ struct location_type {
int type;
};
#define LAND_MOUNTAIN 0x01
#define LAND_GRASSLAND 0x02
#define LAND_FOREST 0x04
#define LAND_LEFT_BEACH 0x08
#define LAND_RIGHT_BEACH 0x10
#define LAND_NORTHSHORE 0x20
#define LAND_SOUTHSHORE 0x40
struct map_info_type {
char *name;
int land_type;
int num_locations;
struct location_type locations[6];
int ground_color;
int n_exit,s_exit,e_exit,w_exit;
int miny;
unsigned char *background_image;
};
extern struct map_info_type map_info[];

View File

@ -24,6 +24,8 @@ struct map_info_type map_info[16] = {
.e_exit=ARCTIC_WOODS,
.w_exit=NOEXIT,
.ground_color=(COLOR_WHITE|(COLOR_WHITE<<4)),
.land_type=LAND_LEFT_BEACH|LAND_NORTHSHORE,
.background_image=NULL,
},
{ // ARCTIC_WOODS
.name="Arctic Woods",
@ -32,6 +34,8 @@ struct map_info_type map_info[16] = {
.e_exit=ARCTIC_MOUNTAINS,
.w_exit=NORTH_BEACH,
.ground_color=(COLOR_WHITE|(COLOR_WHITE<<4)),
.land_type=LAND_GRASSLAND|LAND_NORTHSHORE,
.background_image=NULL,
},
{ // ARCTIC_MOUNTAINS
.name="Arctic Mountains",
@ -40,6 +44,8 @@ struct map_info_type map_info[16] = {
.e_exit=HARFORD_COUNTY,
.w_exit=ARCTIC_WOODS,
.ground_color=(COLOR_WHITE|(COLOR_WHITE<<4)),
.land_type=LAND_MOUNTAIN|LAND_NORTHSHORE,
.background_image=NULL,
},
{ // HARFORD_COUNTY
.name="Harford County",
@ -48,6 +54,7 @@ struct map_info_type map_info[16] = {
.e_exit=NOEXIT,
.w_exit=ARCTIC_MOUNTAINS,
.ground_color=(COLOR_WHITE|(COLOR_WHITE<<4)),
.background_image=harfco_rle,
},
{ // PINE_BEACH
.name="Pine Beach",
@ -56,6 +63,8 @@ struct map_info_type map_info[16] = {
.e_exit=LANDING_SITE,
.w_exit=NOEXIT,
.ground_color=(COLOR_LIGHTGREEN|(COLOR_LIGHTGREEN<<4)),
.land_type=LAND_LEFT_BEACH,
.background_image=NULL,
},
{ // LANDING_SITE
.name="Landing Site",
@ -67,46 +76,67 @@ struct map_info_type map_info[16] = {
.e_exit=NORTH_MOUNTAIN,
.w_exit=PINE_BEACH,
.miny=0,
.land_type=LAND_GRASSLAND,
.background_image=landing_rle,
},
{
.name="North Mountain",
.ground_color=(COLOR_LIGHTGREEN|(COLOR_LIGHTGREEN<<4)),
.land_type=LAND_MOUNTAIN,
.background_image=NULL,
},
{
.name="North Forest",
.ground_color=(COLOR_LIGHTGREEN|(COLOR_LIGHTGREEN<<4)),
.land_type=LAND_FOREST|LAND_RIGHT_BEACH,
.background_image=NULL,
},
{
.name="Palm Beach",
.ground_color=(COLOR_LIGHTGREEN|(COLOR_LIGHTGREEN<<4)),
.land_type=LAND_LEFT_BEACH,
.background_image=NULL,
},
{
.name="Grassland",
.ground_color=(COLOR_LIGHTGREEN|(COLOR_LIGHTGREEN<<4)),
.land_type=LAND_GRASSLAND,
.background_image=NULL,
},
{
.name="Moria",
.ground_color=(COLOR_LIGHTGREEN|(COLOR_LIGHTGREEN<<4)),
.land_type=LAND_MOUNTAIN,
.background_image=NULL,
},
{
.name="South Forest",
.ground_color=(COLOR_LIGHTGREEN|(COLOR_LIGHTGREEN<<4)),
.land_type=LAND_FOREST|LAND_RIGHT_BEACH,
.background_image=NULL,
},
{
.name="South Beach",
.ground_color=(COLOR_LIGHTGREEN|(COLOR_LIGHTGREEN<<4)),
.land_type=LAND_LEFT_BEACH|LAND_SOUTHSHORE,
.background_image=NULL,
},
{
.name="Cactus Ranch",
.ground_color=(COLOR_ORANGE|(COLOR_ORANGE<<4)),
.land_type=LAND_GRASSLAND|LAND_SOUTHSHORE,
.background_image=NULL,
},
{
.name="College Park",
.ground_color=(COLOR_LIGHTGREEN|(COLOR_LIGHTGREEN<<4)),
.background_image=collegep_rle,
},
{
.name="Ocean City",
.ground_color=(COLOR_LIGHTGREEN|(COLOR_LIGHTGREEN<<4)),
.land_type=LAND_RIGHT_BEACH|LAND_SOUTHSHORE,
.background_image=NULL,
},
};

View File

@ -42,22 +42,12 @@ static int load_map_bg(void) {
ground_color=map_info[map_location].ground_color;
if (map_location==HARFORD_COUNTY) {
grsim_unrle(harfco_rle,0xc00);
/* Load background image, if applicable */
if (map_info[map_location].background_image) {
grsim_unrle(map_info[map_location].background_image,0xc00);
return 0;
}
if (map_location==LANDING_SITE) {
grsim_unrle(landing_rle,0xc00);
return 0;
}
if (map_location==COLLEGE_PARK) {
grsim_unrle(collegep_rle,0xc00);
return 0;
}
/* Sky */
color_equals(COLOR_MEDIUMBLUE);
for(i=0;i<10;i+=2) {
@ -65,7 +55,7 @@ static int load_map_bg(void) {
}
/* grassland/sloped left beach */
if ((map_location&3)==0) {
if (map_info[map_location].land_type&LAND_LEFT_BEACH) {
for(i=10;i<40;i+=2) {
temp=4+(39-i)/8;
color_equals(COLOR_DARKBLUE);
@ -80,7 +70,7 @@ static int load_map_bg(void) {
}
/* Grassland */
if ((map_location&3)==1) {
if (map_info[map_location].land_type&LAND_GRASSLAND) {
for(i=10;i<40;i+=2) {
color_equals(ground_color);
hlin_double(PAGE2,0,39,i);
@ -88,7 +78,7 @@ static int load_map_bg(void) {
}
/* Mountain */
if ((map_location&3)==2) {
if (map_info[map_location].land_type&LAND_MOUNTAIN) {
for(i=10;i<40;i+=2) {
color_equals(ground_color);
hlin_double(PAGE2,0,39,i);
@ -96,7 +86,7 @@ static int load_map_bg(void) {
}
/* Right Beach */
if ((map_location&3)==3) {
if (map_info[map_location].land_type&LAND_RIGHT_BEACH) {
for(i=10;i<40;i+=2) {
temp=24+(i/4); /* 26 ... 33 */
color_equals(ground_color);
@ -112,13 +102,13 @@ static int load_map_bg(void) {
}
/* Draw north shore */
if (map_location<4) {
if (map_info[map_location].land_type&LAND_NORTHSHORE) {
color_equals(COLOR_DARKBLUE);
hlin_double(PAGE2,0,39,10);
}
/* Draw south shore */
if (map_location>=12) {
if (map_info[map_location].land_type&LAND_SOUTHSHORE) {
start=0; end=39;
color_equals(COLOR_DARKBLUE);
hlin_double(PAGE2,0,39,38);
@ -133,7 +123,7 @@ static int load_map_bg(void) {
}
/* Mountains */
if ((map_location&3)==2) {
if (map_info[map_location].land_type&LAND_MOUNTAIN) {
for(i=0;i<4;i++) {
grsim_put_sprite_page(PAGE2,mountain,10+(i%2)*5,(i*8)+2);
}