1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-18 20:43:04 +01:00

0x0069A5A0, 0x006AC988, couple fixes

This commit is contained in:
zsilencer
2014-09-18 20:48:04 -06:00
parent d276e40b7f
commit 961e151232
11 changed files with 176 additions and 67 deletions

View File

@@ -41,6 +41,8 @@
#define RCT2_CALLPROC_4(address, a1, a2, a3, a4, v1, v2, v3, v4) RCT2_CALLFUNC_4(address, void, a1, a2, a3, a4, v1, v2, v3, v4)
#define RCT2_CALLPROC_5(address, a1, a2, a3, a4, a5, v1, v2, v3, v4, v5) RCT2_CALLFUNC_5(address, void, a1, a2, a3, a4, a5, v1, v2, v3, v4, v5)
#define RCT2_ADDRESS_EASTEREGG_NAMES 0x00988C20
#define RCT2_ADDRESS_RIDE_PROPERTIES 0x00997C9D
#define RCT2_ADDRESS_LAND_TOOL_SIZE 0x009A9800
#define RCT2_ADDRESS_SAVE_PROMPT_MODE 0x009A9802

View File

@@ -577,15 +577,15 @@ MMRESULT mmio_open(const char* filename, HMMIO* hmmio, HGLOBAL* hmem, LPMMCKINFO
//strcpy(audio_info.var_0, "\x01");
hmem = 0;
label11:
hmemold2 = GlobalAlloc(0, (uint16)hmem + 18);
hmemold2 = GlobalAlloc(0, hmem + 18);
*hmemold = hmemold2;
if (!hmemold2) {
result = 57344;
goto label20;
}
memcpy(hmemold2, &waveformat, 16);
*((uint16*)*hmemold + 8) = (uint16)hmem;
if (!(uint16)hmem || mmioRead(hmmio1, (char*)*hmemold + 18, (uint16)hmem) == (uint16)hmem) {
*((uint16*)*hmemold + 8) = hmem;
if (!hmem || mmioRead(hmmio1, (char*)*hmemold + 18, hmem) == hmem) {
result = mmioAscend(hmmio1, &mmckinfo1, 0);
if (!result) {
goto label24;
@@ -1151,16 +1151,22 @@ int sound_prepare(int sound_id, rct_sound *sound, int channels, int software)
/**
*
* rct2: 0x006BB76E
*
* @param sound_id (eax)
* @param ebx (ebx)
* @param x (cx)
* @param y (dx)
* @param z (bp)
*/
int sound_play_panned(int sound_id, int ebx, uint16 x, uint16 y, uint16 z)
int sound_play_panned(int sound_id, int ebx, sint16 x, sint16 y, sint16 z)
{
int result = 0;
if (RCT2_GLOBAL(0x009AF59D, uint8) & 1) {
RCT2_GLOBAL(0x00F438AD, uint8) = 0;
int volume = 0;
if (ebx == 0x8001) {
uint16 x2 = x & 0xFFE0; // round by 32
uint16 y2 = y & 0xFFE0;
sint16 x2 = x & 0xFFE0; // round by 32
sint16 y2 = y & 0xFFE0;
if (x2 < 0x1FFF && y2 < 0x1FFF) {
rct_map_element* mapelement = RCT2_ADDRESS(RCT2_ADDRESS_TILE_MAP_ELEMENT_POINTERS, rct_map_element*)[((y2 * 256 + x2) & 0xFFFF) / 8];
while (mapelement->type & MAP_ELEMENT_TYPE_MASK) {
@@ -1170,76 +1176,75 @@ int sound_play_panned(int sound_id, int ebx, uint16 x, uint16 y, uint16 z)
RCT2_GLOBAL(0x00F438AD, uint8) = 10;
}
}
uint16 v11;
uint16 v12;
sint16 v11;
sint16 v12;
switch (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)) {
case MAP_ELEMENT_DIRECTION_WEST:
v11 = x - y;
v11 = y - x;
v12 = ((y + x) / 2) - z;
break;
case MAP_ELEMENT_DIRECTION_NORTH:
v11 = -y - x;
v12 = ((x - y) / 2) - z;
v11 = -x - y;
v12 = ((y - x) / 2) - z;
break;
case MAP_ELEMENT_DIRECTION_EAST:
v11 = y - x;
v12 = ((-x - y) / 2) - z;
v11 = x - y;
v12 = ((-y - x) / 2) - z;
break;
case MAP_ELEMENT_DIRECTION_SOUTH:
v11 = x + y;
v12 = ((y - x) / 2) - z;
v11 = y + x;
v12 = ((x - y) / 2) - z;
break;
}
rct_window* window = RCT2_GLOBAL(RCT2_ADDRESS_NEW_WINDOW_PTR, rct_window*);
while (1) {
window--;
if (window < RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_LIST, rct_window*)) {
if (window < RCT2_ADDRESS(RCT2_ADDRESS_WINDOW_LIST, rct_window)) {
break;
}
rct_viewport* viewport = window->viewport;
if (viewport && viewport->flags & VIEWPORT_FLAG_SOUND_ON) {
uint16 v15 = v12 - viewport->view_y;
uint16 v16 = v11 - viewport->view_x;
int x = viewport->x + (v16 / viewport->zoom);
volume = RCT2_GLOBAL(0x0099282C, int*)[sound_id] + ((-1024 * viewport->zoom - 1) << RCT2_GLOBAL(0x00F438AD, uint8)) + 1;
sint16 v15 = v12 - viewport->view_y;
sint16 v16 = v11 - viewport->view_x;
ebx = viewport->x + (v16 >> viewport->zoom);
volume = RCT2_ADDRESS(0x0099282C, int)[sound_id] + ((-1024 * viewport->zoom - 1) << RCT2_GLOBAL(0x00F438AD, uint8)) + 1;
if (v15 < 0 || v15 >= viewport->view_height || v16 < 0 || v16 >= viewport->view_width || volume < -10000) {
return sound_id;
}
}
}
} else {
int i = 0;
rct_other_sound* other_sound = &RCT2_ADDRESS(0x009AF484, rct_other_sound)[i];
while (other_sound->id != 0xFFFF) {
i++;
other_sound = &RCT2_ADDRESS(0x009AF484, rct_other_sound)[i];
if (i > RCT2_GLOBAL(0x009AAC76, uint8)) { // too many sounds playing
return sound_id;
}
}
other_sound->id = sound_id;
int pan;
if (ebx == 0x8000) {
pan = 0;
} else {
int x2 = ebx << 16;
uint16 screenwidth = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16);
if (screenwidth < 64) {
screenwidth = 64;
}
pan = ((x2 / screenwidth) - 0x8000) >> 4;
}
if (!RCT2_GLOBAL(0x009AAC6D, uint8)) {
pan = 0;
}
RCT2_GLOBAL(0x014241BC, uint32) = 1;
sound_prepare(sound_id, &other_sound->sound, 1, RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_SOUND_SW_BUFFER, uint32));
RCT2_GLOBAL(0x014241BC, uint32) = 0;
RCT2_GLOBAL(0x014241BC, uint32) = 1;
result = sound_play(&other_sound->sound, 0, volume, pan, 0);
RCT2_GLOBAL(0x014241BC, uint32) = 0;
}
int i = 0;
rct_other_sound* other_sound = &RCT2_ADDRESS(0x009AF484, rct_other_sound)[i];
while (other_sound->id != 0xFFFF) {
i++;
other_sound = &RCT2_ADDRESS(0x009AF484, rct_other_sound)[i];
if (i > RCT2_GLOBAL(0x009AAC76, uint8)) { // too many sounds playing
return sound_id;
}
}
other_sound->id = sound_id;
int pan;
if (ebx == 0x8000) {
pan = 0;
} else {
int x2 = ebx << 16;
uint16 screenwidth = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16);
if (screenwidth < 64) {
screenwidth = 64;
}
pan = ((x2 / screenwidth) - 0x8000) >> 4;
}
if (!RCT2_GLOBAL(0x009AAC6D, uint8)) {
pan = 0;
}
RCT2_GLOBAL(0x014241BC, uint32) = 1;
sound_prepare(sound_id, &other_sound->sound, 1, RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_SOUND_SW_BUFFER, uint32));
RCT2_GLOBAL(0x014241BC, uint32) = 0;
RCT2_GLOBAL(0x014241BC, uint32) = 1;
result = sound_play(&other_sound->sound, 0, volume, pan, 0);
RCT2_GLOBAL(0x014241BC, uint32) = 0;
}
return result;
}

View File

@@ -157,7 +157,7 @@ void audio_close();
LPVOID map_file(LPCSTR lpFileName, DWORD dwCreationDisposition, DWORD dwNumberOfBytesToMap);
int unmap_sound_info();
int sound_prepare(int sound_id, rct_sound *sound, int channels, int software);
int sound_play_panned(int sound_id, int ebx, uint16 x, uint16 y, uint16 z);
int sound_play_panned(int sound_id, int ebx, sint16 x, sint16 y, sint16 z);
int sound_play(rct_sound* sound, int looping, int volume, int pan, int frequency);
int sound_is_playing(rct_sound* sound);
int sound_set_frequency(rct_sound* sound, int frequency);

View File

@@ -205,7 +205,7 @@ Channel::~Channel()
}
}
void Channel::Play(Stream& stream, int loop = 0)
void Channel::Play(Stream& stream, int loop = MIXER_LOOP_NONE)
{
Channel::stream = &stream;
Channel::loop = loop;

View File

@@ -23,6 +23,9 @@
#include "rct2.h"
#define MIXER_LOOP_NONE 0
#define MIXER_LOOP_INFINITE -1
#ifdef __cplusplus
extern "C" {

View File

@@ -682,3 +682,37 @@ int get_peep_face_sprite_small(rct_peep *peep){
int get_peep_face_sprite_large(rct_peep *peep){
return face_sprite_large[get_face_sprite_offset(peep)];
}
/**
*
* rct2: 0x0069A5A0
* tests if a peep's name matches a cheat code, normally returns using a register flag
* @param index (eax)
* @param ride (esi)
*/
int peep_check_cheatcode(int index, rct_peep *peep)
{
char* str = RCT2_ADDRESS(RCT2_ADDRESS_EASTEREGG_NAMES, char*)[index];
char* dst = (char*)RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER;
format_string(dst, peep->name_string_idx, &peep->id);
// strtoupper:
int i = 0;
while(dst[i]) {
if (dst[i] >= 0x61 && dst[i] <= 0x7A) {
dst[i] -= 0x20;
}
i++;
}
// check for match, characters are -1 to obfuscate the cheat codes
i = 0;
while(str[i] + 1) {
if (str[i] + 1 != dst[i]) {
return 0;
}
i++;
}
return 1;
}

View File

@@ -449,6 +449,7 @@ void get_arguments_from_action(rct_peep* peep, uint32 *argument_1, uint32* argum
void get_arguments_from_thought(rct_peep_thought thought, uint32* argument_1, uint32* argument_2);
int get_peep_face_sprite_small(rct_peep *peep);
int get_peep_face_sprite_large(rct_peep *peep);
int peep_check_cheatcode(int index, rct_peep *peep);
#endif

View File

@@ -25,6 +25,7 @@
#include "news_item.h"
#include "sprite.h"
#include "ride.h"
#include "scenario.h"
#include "sprite.h"
#include "peep.h"
#include "window.h"
@@ -474,3 +475,51 @@ int ride_try_construct(rct_map_element *trackMapElement)
RCT2_CALLPROC_X(0x006CC056, 0, 0, 0, (int)trackMapElement, 0, 0, 0);
return 1;
}
/**
*
* rct2: 0x006AC988
* set the speed of the gokart type vehicle at the start to a random value or alter if peep name is a cheat code
* @param ride (esi)
*/
void ride_init_vehicle_speed(rct_ride *ride)
{
int ecx = -1;
while (1) {
ecx++;
if (ecx >= ride->var_0C8) {
break;
}
rct_vehicle *vehicle = &g_sprite_list[ride->train_car_map[ecx]].vehicle;
vehicle->var_48 &= (1 << 6);
uint8 r = scenario_rand();
r = 0xC;
r &= 0xF;
r -= 8;
int testaddr = (vehicle->var_31 * 0x65);
testaddr += (int)RCT2_ADDRESS(0x009ACFA4, rct_ride_type*)[vehicle->var_D6];
uint8 test = ((uint8*)testaddr)[0x76];
r += test;
vehicle->speed = r;
if (vehicle->var_B3) {
rct_peep *peep = &g_sprite_list[vehicle->peep].peep;
if (peep_check_cheatcode(0, peep)) { // MICHAEL SCHUMACHER
vehicle->speed += 35;
}
if (peep_check_cheatcode(1, peep)) { // JACQUES VILLENEUVE
vehicle->speed += 25;
}
if (peep_check_cheatcode(2, peep)) { // DAMON HILL
vehicle->speed += 55;
}
if (peep_check_cheatcode(4, peep)) { // CHRIS SAWYER
vehicle->speed += 14;
}
if (peep_check_cheatcode(3, peep)) { // MR BEAN
vehicle->speed = 9;
}
}
}
}

View File

@@ -81,7 +81,9 @@ typedef struct {
uint16 overall_view; // 0x050 00XX = X, XX00 = Y (* 32 + 16)
uint16 station_starts[4]; // 0x052
uint8 station_heights[4]; // 0x05A
uint8 pad_05E[0xC];
uint8 pad_05E[4];
uint8 var_62[4];
uint8 pad_66[4];
uint16 entrances[4]; // 0x06A
uint16 exits[4]; // 0x072
uint8 pad_07A[0x0C];
@@ -90,11 +92,12 @@ typedef struct {
// Not sure if these should be uint or sint.
uint8 var_0C7;
uint8 var_0C8;
uint8 var_0C8; // Number of train cars?
uint8 var_0C9;
uint8 pad_0CA[0x1A];
uint8 pad_0CA[0x06];
uint8 var_0D0;
uint8 pad_0D1[0x13];
sint32 var_0E4;
sint32 var_0E8;
sint32 var_0EC;
@@ -147,7 +150,9 @@ typedef struct {
sint32 profit; // 0x1B4
uint8 queue_time[4]; // 0x1B8
uint8 var_1BC;
uint8 pad_1BD[0x10];
uint8 pad_1BD[0xD];
uint16 var_1CA;
uint8 var_1CC;
uint8 var_1CD;
uint16 guests_favourite; // 0x1CE
uint32 lifecycle_flags; // 0x1D0
@@ -389,5 +394,6 @@ rct_map_element *sub_6CAF80(int rideIndex, int *outX, int *outY);
rct_map_element *ride_find_track_gap(rct_map_element *startTrackElement, int *outX, int *outY);
void ride_construct_new(int list_item);
int ride_try_construct(rct_map_element *trackMapElement);
void ride_init_vehicle_speed(rct_ride *ride);
#endif

View File

@@ -259,9 +259,10 @@ void vehicle_sounds_update()
if (LOBYTE(result) >= HIBYTE(result)) {
result = MAKEWORD(HIBYTE(result), HIBYTE(result));
}
result = MAKEWORD(LOBYTE(result) - RCT2_GLOBAL(0x00F438AC, uint8), HIBYTE(result));
if (!LOBYTE(result)) {
if (LOBYTE(result) < RCT2_GLOBAL(0x00F438AC, uint8)) {
result = MAKEWORD(0, HIBYTE(result));
} else {
result = MAKEWORD(LOBYTE(result) - RCT2_GLOBAL(0x00F438AC, uint8), HIBYTE(result));
}
rct_vehicle_sound* vehicle_sound = &RCT2_GLOBAL(RCT2_ADDRESS_VEHICLE_SOUND_LIST, rct_vehicle_sound);
@@ -296,9 +297,10 @@ void vehicle_sounds_update()
}
}
vehicle_sound->var_2 = v22;
result = MAKEWORD(LOBYTE(result) - v22, HIBYTE(result));
if (!result) {
if (LOBYTE(result) < v22) {
result = MAKEWORD(0, HIBYTE(result));
} else {
result = MAKEWORD(LOBYTE(result) - v22, HIBYTE(result));
}
// do sound1 stuff, track noise
RCT2_ADDRESS_SPRITE_LIST;

View File

@@ -63,17 +63,24 @@ typedef struct {
uint8 pad_4A[0x06];
uint8 var_50;
uint8 var_51;
uint8 pad_52[0x2E];
uint16 peep; // 0x52
uint8 pad_54[0x2C];
uint16 var_80;
uint8 pad_82[0x39];
uint8 pad_82[0x31];
uint8 var_B3;
uint8 pad_B4[0x07];
uint8 var_BB;
uint8 var_BC;
uint8 var_BD;
uint8 var_BE;
sint8 var_BF;
uint8 pad_C0[0x0C];
uint8 pad_C0[0x02];
uint8 speed; // 0xC2
uint8 pad_C3[0x09];
uint8 var_CC;
uint8 pad_CD[0x09];
uint8 var_CD;
uint8 var_CE;
uint8 pad_CF[0x07];
uint8 var_D6;
} rct_vehicle;