Add helper functions for accessing data in var_0D5

This commit is contained in:
Kevin Burke 2015-03-30 21:07:06 -07:00
parent 1406002b60
commit 6f5bbe1588
3 changed files with 65 additions and 16 deletions

View File

@ -3590,3 +3590,32 @@ bool ride_type_has_flag(int rideType, int flag)
{
return (RCT2_GLOBAL(RCT2_ADDRESS_RIDE_FLAGS + (rideType * 8), uint32) & flag) != 0;
}
bool ride_has_spinning_tunnel(rct_ride *ride) {
return ride->special_track_elements & RIDE_ELEMENT_TUNNEL_SPLASH_OR_RAPIDS;
}
bool ride_has_water_splash(rct_ride *ride) {
return ride->special_track_elements & RIDE_ELEMENT_TUNNEL_SPLASH_OR_RAPIDS;
}
bool ride_has_rapids(rct_ride *ride) {
return ride->special_track_elements & RIDE_ELEMENT_TUNNEL_SPLASH_OR_RAPIDS;
}
bool ride_has_log_reverser(rct_ride *ride) {
return ride->special_track_elements & RIDE_ELEMENT_REVERSER_OR_WATERFALL;
}
bool ride_has_waterfall(rct_ride *ride) {
return ride->special_track_elements & RIDE_ELEMENT_REVERSER_OR_WATERFALL;
}
bool ride_has_whirlpool(rct_ride *ride) {
return ride->special_track_elements & RIDE_ELEMENT_WHIRLPOOL;
}
uint8 ride_get_helix_sections(rct_ride *ride) {
// Helix sections stored in the low 5 bits.
return ride->special_track_elements & 0x1F;
}

View File

@ -172,13 +172,17 @@ typedef struct {
};
uint8 pad_0D1[0x3];
uint8 measurement_index; // 0x0D4
uint8 var_0D5;
uint8 pad_0D6[0x2];
// bits 0 through 4 are the number of helix sections
// bit 5: spinning tunnel, water splash, or rapids
// bit 6: log reverser, waterfall
// bit 7: whirlpool
uint8 special_track_elements; // 0x0D5
uint8 pad_0D6[2];
// Divide this value by 29127 to get the human-readable max speed
// (in RCT2, display_speed = (max_speed * 9) >> 18)
sint32 max_speed; // 0x0D8
sint32 average_speed; // 0x0DC
uint8 pad_0E0[0x4];
uint8 pad_0E0[4];
sint32 length[4]; // 0x0E4
uint16 time[4]; // 0x0F4
fixed16_2dp max_positive_vertical_g; // 0x0FC
@ -646,6 +650,13 @@ enum {
RIDE_MEASUREMENT_FLAG_G_FORCES = 1 << 2
};
// Constants for ride->special_track_elements
enum {
RIDE_ELEMENT_TUNNEL_SPLASH_OR_RAPIDS = 1 << 5,
RIDE_ELEMENT_REVERSER_OR_WATERFALL = 1 << 6,
RIDE_ELEMENT_WHIRLPOOL = 1 << 7
};
enum {
RIDE_TYPE_FLAG_HAS_TRACK_COLOUR_MAIN = 1 << 0,
RIDE_TYPE_FLAG_HAS_TRACK_COLOUR_ADDITIONAL = 1 << 1,
@ -753,6 +764,14 @@ void ride_set_name(int rideIndex, const char *name);
void game_command_set_ride_name(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp);
void game_command_set_ride_setting(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp);
uint8 ride_get_helix_sections(rct_ride *ride);
bool ride_has_spinning_tunnel(rct_ride *ride);
bool ride_has_water_splash(rct_ride *ride);
bool ride_has_rapids(rct_ride *ride);
bool ride_has_log_reverser(rct_ride *ride);
bool ride_has_waterfall(rct_ride *ride);
bool ride_has_whirlpool(rct_ride *ride);
bool ride_type_has_flag(int rideType, int flag);
#endif

View File

@ -730,43 +730,44 @@ static rating_tuple get_inversions_ratings(uint8 inversions) {
/*
*
*/
static rating_tuple get_var_0D5_rating(uint8 type, uint8 var_0D5) {
static rating_tuple get_special_track_elements_rating(uint8 type, uint8 special_track_elements) {
int excitement = 0, intensity = 0, nausea = 0;
if (type == RIDE_TYPE_GHOST_TRAIN) {
if (var_0D5 & 0x20) {
if (special_track_elements & RIDE_ELEMENT_TUNNEL_SPLASH_OR_RAPIDS) {
excitement += 40;
intensity += 25;
nausea += 55;
}
} else if (type == RIDE_TYPE_LOG_FLUME) {
if (var_0D5 & 0x40) {
// Reverser for log flume
if (special_track_elements & RIDE_ELEMENT_REVERSER_OR_WATERFALL) {
excitement += 48;
intensity += 55;
nausea += 65;
}
} else {
if (var_0D5 & 0x20) {
if (special_track_elements & RIDE_ELEMENT_TUNNEL_SPLASH_OR_RAPIDS) {
excitement += 50;
intensity += 30;
nausea += 20;
}
if (var_0D5 & 0x40) {
if (special_track_elements & RIDE_ELEMENT_REVERSER_OR_WATERFALL) {
excitement += 55;
intensity += 30;
}
if (var_0D5 & 0x80) {
if (special_track_elements & RIDE_ELEMENT_WHIRLPOOL) {
excitement += 35;
intensity += 20;
nausea += 23;
}
}
int al = min(var_0D5, 9);
int al = min(special_track_elements, 9);
excitement += (al * 254862) >> 16;
al = min(var_0D5, 11);
al = min(special_track_elements, 11);
intensity += (al * 148945) >> 16;
al = max(var_0D5 - 5, 0);
al = max(special_track_elements - 5, 0);
al = min(al, 10);
nausea += (al * 1310720) >> 16;
@ -781,10 +782,10 @@ static rating_tuple sub_65DDD1(rct_ride *ride)
{
int excitement = 0, intensity = 0, nausea = 0;
rating_tuple var_0D5_rating = get_var_0D5_rating(ride->type, ride->var_0D5);
excitement += var_0D5_rating.excitement;
intensity += var_0D5_rating.intensity;
nausea += var_0D5_rating.nausea;
rating_tuple special_track_element_rating = get_special_track_elements_rating(ride->type, ride->special_track_elements);
excitement += special_track_element_rating.excitement;
intensity += special_track_element_rating.intensity;
nausea += special_track_element_rating.nausea;
rating_tuple var_10E_rating = get_var_10E_rating(ride->var_10E);
excitement += var_10E_rating.excitement;