mirror of https://github.com/OpenRCT2/OpenRCT2.git
start implementing ride_ratings_update_all
This commit is contained in:
parent
c628f6fea0
commit
4e827bb64e
|
@ -19,16 +19,261 @@
|
|||
*****************************************************************************/
|
||||
|
||||
#include "../addresses.h"
|
||||
#include "../world/map.h"
|
||||
#include "ride.h"
|
||||
#include "ride_data.h"
|
||||
#include "ride_ratings.h"
|
||||
|
||||
enum {
|
||||
RIDE_RATINGS_STATE_FIND_NEXT_RIDE,
|
||||
RIDE_RATINGS_STATE_INITIALISE
|
||||
};
|
||||
|
||||
#define _rideRatingsState RCT2_GLOBAL(0x0138B591, uint8)
|
||||
#define _rideRatingsCurrentRide RCT2_GLOBAL(0x00138B590, uint8)
|
||||
|
||||
static void ride_ratings_update_state_0();
|
||||
static void ride_ratings_update_state_1();
|
||||
static void ride_ratings_update_state_2();
|
||||
static void ride_ratings_update_state_3();
|
||||
static void ride_ratings_update_state_4();
|
||||
static void ride_ratings_update_state_5();
|
||||
static void loc_6B5BB2();
|
||||
|
||||
int sub_6C6402(rct_map_element *mapElement, int *x, int *y, int *z)
|
||||
{
|
||||
int eax, ebx, ecx, edx, esi, edi, ebp;
|
||||
|
||||
eax = *x;
|
||||
ecx = *y;
|
||||
esi = (int)mapElement;
|
||||
RCT2_CALLFUNC_X(0x006C6402, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
|
||||
*x = *((uint16*)&eax);
|
||||
*y = *((uint16*)&ecx);
|
||||
*z = *((uint8*)&edx);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006B5A2A
|
||||
*/
|
||||
void ride_ratings_update_all()
|
||||
{
|
||||
RCT2_CALLPROC_EBPSAFE(0x006B5A2A);
|
||||
// RCT2_CALLPROC_EBPSAFE(0x006B5A2A);
|
||||
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR)
|
||||
return;
|
||||
|
||||
switch (_rideRatingsState) {
|
||||
case RIDE_RATINGS_STATE_FIND_NEXT_RIDE:
|
||||
ride_ratings_update_state_0();
|
||||
break;
|
||||
case RIDE_RATINGS_STATE_INITIALISE:
|
||||
ride_ratings_update_state_1();
|
||||
break;
|
||||
case 2:
|
||||
ride_ratings_update_state_2();
|
||||
break;
|
||||
case 3:
|
||||
ride_ratings_update_state_3();
|
||||
break;
|
||||
case 4:
|
||||
ride_ratings_update_state_4();
|
||||
break;
|
||||
case 5:
|
||||
ride_ratings_update_state_5();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006B5A5C
|
||||
*/
|
||||
static void ride_ratings_update_state_0()
|
||||
{
|
||||
rct_ride *ride;
|
||||
|
||||
_rideRatingsCurrentRide += 1;
|
||||
if (_rideRatingsCurrentRide == 255)
|
||||
_rideRatingsCurrentRide = 0;
|
||||
|
||||
ride = GET_RIDE(_rideRatingsCurrentRide);
|
||||
if (ride->type != RIDE_TYPE_NULL && ride->status != RIDE_STATUS_CLOSED)
|
||||
_rideRatingsState = RIDE_RATINGS_STATE_INITIALISE;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006B5A94
|
||||
*/
|
||||
static void ride_ratings_update_state_1()
|
||||
{
|
||||
RCT2_GLOBAL(0x0138B594, uint16) = 0;
|
||||
RCT2_GLOBAL(0x0138B596, uint16) = 0;
|
||||
RCT2_GLOBAL(0x0138B598, uint16) = 0;
|
||||
RCT2_GLOBAL(0x0138B59A, uint16) = 0;
|
||||
RCT2_GLOBAL(0x0138B59C, uint16) = 0;
|
||||
RCT2_GLOBAL(0x0138B59E, uint16) = 0;
|
||||
RCT2_GLOBAL(0x0138B5A0, uint16) = 0;
|
||||
RCT2_GLOBAL(0x0138B5A2, uint16) = 0;
|
||||
RCT2_GLOBAL(0x0138B5A4, uint16) = 0;
|
||||
RCT2_GLOBAL(0x0138B5A6, uint16) = 0;
|
||||
RCT2_GLOBAL(0x0138B5A8, uint16) = 0;
|
||||
RCT2_GLOBAL(0x0138B5AA, uint16) = 0;
|
||||
RCT2_GLOBAL(0x0138B5AC, uint16) = 0;
|
||||
RCT2_GLOBAL(0x0138B5AE, uint16) = 0;
|
||||
RCT2_GLOBAL(0x0138B5B0, uint16) = 0;
|
||||
RCT2_GLOBAL(0x0138B5B2, uint16) = 0;
|
||||
RCT2_GLOBAL(0x0138B5B4, uint16) = 0;
|
||||
RCT2_GLOBAL(0x0138B5B6, uint16) = 0;
|
||||
RCT2_GLOBAL(0x0138B5B8, uint16) = 0;
|
||||
RCT2_GLOBAL(0x0138B5BA, uint16) = 0;
|
||||
RCT2_GLOBAL(0x0138B5BC, uint16) = 0;
|
||||
RCT2_GLOBAL(0x0138B5BE, uint16) = 0;
|
||||
RCT2_GLOBAL(0x0138B5C0, uint16) = 0;
|
||||
RCT2_GLOBAL(0x0138B5C2, uint16) = 0;
|
||||
RCT2_GLOBAL(0x0138B5C4, uint16) = 0;
|
||||
RCT2_GLOBAL(0x0138B5C6, uint16) = 0;
|
||||
RCT2_GLOBAL(0x0138B5C8, uint16) = 0;
|
||||
RCT2_GLOBAL(0x0138B5CA, uint16) = 0;
|
||||
RCT2_GLOBAL(0x0138B5CC, uint16) = 0;
|
||||
_rideRatingsState = 2;
|
||||
RCT2_GLOBAL(0x0138B5CE, uint16) = 0;
|
||||
loc_6B5BB2();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006B5BB2
|
||||
*/
|
||||
static void loc_6B5BB2()
|
||||
{
|
||||
rct_ride *ride;
|
||||
int i, x, y, z;
|
||||
|
||||
ride = GET_RIDE(_rideRatingsCurrentRide);
|
||||
if (ride->type == RIDE_TYPE_NULL || ride->status == RIDE_STATUS_CLOSED) {
|
||||
_rideRatingsState = RIDE_RATINGS_STATE_FIND_NEXT_RIDE;
|
||||
return;
|
||||
}
|
||||
|
||||
if (ride->type == RIDE_TYPE_MAZE) {
|
||||
_rideRatingsState = 3;
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (ride->station_starts[i] != 0xFFFF) {
|
||||
RCT2_GLOBAL(0x0138B5CE, uint16) &= ~1;
|
||||
if (ride->entrances[i] == 0xFFFF)
|
||||
RCT2_GLOBAL(0x0138B5CE, uint16) |= 1;
|
||||
|
||||
x = (ride->station_starts[i] & 0xFF) * 32;
|
||||
y = (ride->station_starts[i] >> 8) * 32;
|
||||
z = ride->station_heights[i] * 8;
|
||||
|
||||
RCT2_GLOBAL(0x0138B584, uint16) = x;
|
||||
RCT2_GLOBAL(0x0138B586, uint16) = y;
|
||||
RCT2_GLOBAL(0x0138B588, uint16) = z;
|
||||
RCT2_GLOBAL(0x0138B592, uint8) = 255;
|
||||
RCT2_GLOBAL(0x0138B58A, uint16) = x;
|
||||
RCT2_GLOBAL(0x0138B58C, uint16) = y;
|
||||
RCT2_GLOBAL(0x0138B58E, uint16) = z;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
_rideRatingsState = RIDE_RATINGS_STATE_FIND_NEXT_RIDE;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006B5C66
|
||||
*/
|
||||
static void ride_ratings_update_state_2()
|
||||
{
|
||||
RCT2_CALLPROC_EBPSAFE(0x006B5C66);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006B5E4D
|
||||
*/
|
||||
static void ride_ratings_update_state_3()
|
||||
{
|
||||
RCT2_CALLPROC_EBPSAFE(0x006B5E4D);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006B5BAB
|
||||
*/
|
||||
static void ride_ratings_update_state_4()
|
||||
{
|
||||
_rideRatingsState = 5;
|
||||
loc_6B5BB2();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006B5D72
|
||||
*/
|
||||
static void ride_ratings_update_state_5()
|
||||
{
|
||||
// sub_6C6402 returns a carry, CALLFUNC doesn't support this
|
||||
// so have to wait for sub_6C6402 to be decompiled
|
||||
RCT2_CALLPROC_EBPSAFE(0x006B5D72);
|
||||
return;
|
||||
|
||||
rct_ride *ride;
|
||||
rct_map_element *mapElement;
|
||||
int x, y, z, trackType;
|
||||
|
||||
ride = GET_RIDE(_rideRatingsCurrentRide);
|
||||
if (ride->type == RIDE_TYPE_NULL || ride->status == RIDE_STATUS_CLOSED) {
|
||||
_rideRatingsState = RIDE_RATINGS_STATE_FIND_NEXT_RIDE;
|
||||
return;
|
||||
}
|
||||
|
||||
x = RCT2_GLOBAL(0x0138B584, uint16) / 32;
|
||||
y = RCT2_GLOBAL(0x0138B586, uint16) / 32;
|
||||
z = RCT2_GLOBAL(0x0138B588, uint16) / 8;
|
||||
|
||||
mapElement = TILE_MAP_ELEMENT_POINTER(y * 256 + x);
|
||||
trackType = RCT2_GLOBAL(0x0138B592, uint8);
|
||||
|
||||
do {
|
||||
if ((mapElement->type & MAP_ELEMENT_TYPE_MASK) != MAP_ELEMENT_TYPE_TRACK)
|
||||
continue;
|
||||
if (mapElement->base_height != z)
|
||||
continue;
|
||||
|
||||
if (trackType == 255 || trackType == mapElement->properties.track.type) {
|
||||
RCT2_CALLPROC_X(0x006B5F9D, 0, 0, 0, 0, (int)mapElement, 0, 0);
|
||||
|
||||
x = RCT2_GLOBAL(0x0138B584, uint16);
|
||||
y = RCT2_GLOBAL(0x0138B586, uint16);
|
||||
if (!sub_6C6402(mapElement, &x, &y, &z)) {
|
||||
_rideRatingsState = 3;
|
||||
return;
|
||||
}
|
||||
|
||||
x >>= 16;
|
||||
y >>= 16;
|
||||
if (x == RCT2_GLOBAL(0x0138B58A, uint16) && y == RCT2_GLOBAL(0x0138B58C, uint16) && z == RCT2_GLOBAL(0x0138B58E, uint16)) {
|
||||
_rideRatingsState = 3;
|
||||
return;
|
||||
}
|
||||
RCT2_GLOBAL(0x0138B584, uint16) = x;
|
||||
RCT2_GLOBAL(0x0138B586, uint16) = y;
|
||||
RCT2_GLOBAL(0x0138B588, uint16) = z;
|
||||
RCT2_GLOBAL(0x0138B592, uint8) = mapElement->properties.track.type;
|
||||
}
|
||||
} while (!((mapElement++)->flags & MAP_ELEMENT_FLAG_LAST_TILE));
|
||||
|
||||
_rideRatingsState = RIDE_RATINGS_STATE_FIND_NEXT_RIDE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue