diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5c911bb9fe..74762470ce 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -55,6 +55,6 @@ set_target_properties(${PROJECT} PROPERTIES PREFIX "")
TARGET_LINK_LIBRARIES(${PROJECT} ${SDL2_LIBRARIES})
if (WIN32)
- target_link_libraries(${PROJECT} winmm.lib -limm32 -lversion)
+ target_link_libraries(${PROJECT} winmm.lib -limm32 -lversion -ldsound)
endif (WIN32)
diff --git a/projects/openrct2.vcxproj b/projects/openrct2.vcxproj
index 9c079203b5..3077811de3 100644
--- a/projects/openrct2.vcxproj
+++ b/projects/openrct2.vcxproj
@@ -201,7 +201,7 @@
true
- winmm.lib;sdl2.lib;%(AdditionalDependencies)
+ winmm.lib;sdl2.lib;Dsound.lib;%(AdditionalDependencies)
@@ -224,7 +224,7 @@
true
true
true
- winmm.lib;sdl2.lib;%(AdditionalDependencies)
+ winmm.lib;sdl2.lib;Dsound.lib;%(AdditionalDependencies)
xcopy /Y "$(ProjectDir)\..\Data\Language\*.*" "$(TargetDir)\Data\Language\"
diff --git a/src/addresses.h b/src/addresses.h
index 8b28dad719..7bef46848b 100644
--- a/src/addresses.h
+++ b/src/addresses.h
@@ -33,6 +33,7 @@
#define RCT2_CALLFUNC_3(address, returnType, a1, a2, a3, v1, v2, v3) (((returnType(*)(a1, a2, a3))(address))(v1, v2, v3))
#define RCT2_CALLFUNC_4(address, returnType, a1, a2, a3, a4, v1, v2, v3, v4) (((returnType(*)(a1, a2, a3, a4))(address))(v1, v2, v3, v4))
#define RCT2_CALLFUNC_5(address, returnType, a1, a2, a3, a4, a5, v1, v2, v3, v4, v5) (((returnType(*)(a1, a2, a3, a4, a5))(address))(v1, v2, v3, v4, v5))
+#define RCT2_CALLFUNC_6(address, returnType, a1, a2, a3, a4, a5, a6, v1, v2, v3, v4, v5, v6) (((returnType(*)(a1, a2, a3, a4, a5, a6))(address))(v1, v2, v3, v4, v5, v6))
#define RCT2_CALLPROC_1(address, a1, v1) RCT2_CALLFUNC_1(address, void, a1, v1)
#define RCT2_CALLPROC_2(address, a1, a2, v1, v2) RCT2_CALLFUNC_2(address, void, a1, a2, v1, v2)
@@ -106,6 +107,10 @@
#define RCT2_ADDRESS_INSTALLED_OBJECT_LIST 0x009ADAE8
+#define RCT2_ADDRESS_CURRENT_SOUND_DEVICE 0x009AF280
+
+#define RCT2_ADDRESS_VEHICLE_SOUND_LIST 0x009AF288
+
#define RCT2_ADDRESS_CURENT_CURSOR 0x009DE51C
#define RCT2_ADDRESS_INPUT_STATE 0x009DE51D
#define RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS 0x009DE51F
@@ -157,11 +162,17 @@
#define RCT2_ADDRESS_DSOUND_BUFFERS 0x009E1AB0
#define RCT2_ADDRESS_NUM_DSOUND_DEVICES 0x009E2B88
#define RCT2_ADDRESS_DSOUND_DEVICES 0x009E2B8C
+#define RCT2_ADDRESS_SOUND_INFO_LIST_MAPPING 0x009E2B94
#define RCT2_ADDRESS_SOUNDLIST_BEGIN 0x009E2B98
#define RCT2_ADDRESS_SOUNDLIST_END 0x009E2B9C
+#define RCT2_ADDRESS_DIRECTSOUND 0x009E2BA0
+#define RCT2_ADDRESS_DSOUND_DEVICES_COUNTER 0x009E2BAC
#define RCT2_ADDRESS_CMDLINE 0x009E2D98
+#define RCT2_ADDRESS_MOUSE_READ_INDEX 0x009E2DE8
+#define RCT2_ADDRESS_MOUSE_WRITE_INDEX 0x009E2DE4
+
#define RCT2_ADDRESS_LAND_RAISE_COST 0x009E2E1C
#define RCT2_ADDRESS_LAND_LOWER_COST 0x009E2E20
#define RCT2_ADDRESS_SELECTED_TERRAIN_EDGE 0x009E2E24
@@ -225,6 +236,7 @@
#define RCT2_ADDRESS_OBJECTIVE_CURRENCY 0x013580FC
#define RCT2_ADDRESS_OBJECTIVE_NUM_GUESTS 0x01358100
#define RCT2_ADDRESS_BALANCE_HISTORY 0x0135812C
+#define RCT2_ADDRESS_CURRENT_EXPENDITURE 0x0135832C
#define RCT2_ADDRESS_CURRENT_PROFIT 0x01358330
#define RCT2_ADDRESS_WEEKLY_PROFIT_HISTORY 0x0135833C
#define RCT2_ADDRESS_CURRENT_PARK_VALUE 0x0135853C
@@ -310,7 +322,9 @@
#define RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER 0x0141ED68
+#define RCT2_ADDRESS_AUDIO_INFO 0x01425B40
+#define RCT2_ADDRESS_SOUND_CHANNEL_LIST 0x014262E0
#define RCT2_ADDRESS_WATER_RAISE_COST 0x0141F738
#define RCT2_ADDRESS_WATER_LOWER_COST 0x0141F73C
@@ -395,6 +409,8 @@
#define RCT2_ADDRESS_SCREEN_CAP_BPP 0x01423C10
#define RCT2_ADDRESS_SCREEN_CAP_RASTER_STRETCH 0x01423C14
+#define RCT2_ADDRESS_INPUT_QUEUE 0x01424340
+
static void RCT2_CALLPROC_EBPSAFE(int address)
{
#ifdef _MSC_VER
diff --git a/src/audio.c b/src/audio.c
index 8f2d0cce27..6ad888b962 100644
--- a/src/audio.c
+++ b/src/audio.c
@@ -21,6 +21,7 @@
#include
#include "audio.h"
#include "addresses.h"
+#include "config.h"
#include "rct2.h"
int gAudioDeviceCount;
@@ -65,23 +66,1116 @@ void audio_get_devices()
}
}
+/**
+*
+* rct2: 0x00404BD2
+*/
+int audio_release()
+{
+ sound_stop_all();
+ if (RCT2_GLOBAL(0x009E2BA4, LPDIRECTSOUND3DBUFFER)) {
+ RCT2_GLOBAL(0x009E2BA4, LPDIRECTSOUND3DBUFFER)->lpVtbl->Release(RCT2_GLOBAL(0x009E2BA4, LPDIRECTSOUND3DBUFFER));
+ RCT2_GLOBAL(0x009E2BA4, LPDIRECTSOUND3DBUFFER) = 0;
+ }
+ if (RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER)) {
+ RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER)->lpVtbl->Release(RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER));
+ RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER) = 0;
+ }
+ int result = 0;
+ if (RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND)) {
+ result = RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND)->lpVtbl->Release(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND));
+ RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND) = 0;
+ }
+ return result;
+}
+
+/**
+*
+* rct2: 0x00404C45
+*/
+int unmap_sound_info()
+{
+ if (RCT2_GLOBAL(RCT2_ADDRESS_SOUND_INFO_LIST_MAPPING, LPVOID)) {
+ sound_stop_all();
+ unmap_file(RCT2_GLOBAL(RCT2_ADDRESS_SOUND_INFO_LIST_MAPPING, LPVOID));
+ RCT2_GLOBAL(RCT2_ADDRESS_SOUND_INFO_LIST_MAPPING, LPVOID) = 0;
+ return 1;
+ }
+ return 0;
+}
+
+/**
+*
+* rct2: 0x00404DF5
+*/
+int sound_stop_all()
+{
+ int result = 0;
+ while (RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_BEGIN, rct_sound*)) {
+ result = sound_stop(RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_BEGIN, rct_sound*));
+ }
+ return result;
+}
+
+/**
+*
+* rct2: 0x004068A0
+*/
+int unmap_file(LPCVOID base)
+{
+ if (base) {
+ return UnmapViewOfFile(base);
+ }
+ return 0;
+}
+
+/**
+*
+* rct2: 0x004018F0
+*/
+int audio_remove_timer()
+{
+ for (int i = 0; i < 4; i++) {
+ sound_channel_stop(i);
+ }
+ if (RCT2_GLOBAL(0x009E1AA4, int)) {
+ timeKillEvent(RCT2_GLOBAL(0x009E1AA0, MMRESULT));
+ timeEndPeriod(50);
+ while (_InterlockedExchange(&RCT2_GLOBAL(0x009E1AAC, LONG), 1) != 1) {
+ Sleep(100);
+ }
+ int result = _InterlockedExchange(&RCT2_GLOBAL(0x009E1AAC, LONG), 0);
+ RCT2_GLOBAL(0x009E1AA4, int) = 0;
+ return result;
+ }
+ return 0;
+}
+
+/**
+*
+* rct2: 0x006BAB21
+*/
+void audio_close()
+{
+ if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, uint32) != -1) {
+ stop_other_sounds();
+ stop_peep_sounds();
+ stop_title_music();
+ if (RCT2_GLOBAL(0x009AF284, uint32) & (1 << 0)) {
+ stop_ride_music();
+ RCT2_GLOBAL(0x014241BC, uint32) = 1;
+ audio_remove_timer();
+ RCT2_GLOBAL(0x014241BC, uint32) = 0;
+ }
+ RCT2_GLOBAL(0x014241BC, uint32) = 1;
+ unmap_sound_info();
+ audio_release();
+ RCT2_GLOBAL(0x014241BC, uint32) = 0;
+ RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, uint32) = -1;
+ }
+}
+
+/**
+*
+* rct2: 0x000404F28
+*/
+int sound_load3dparameters()
+{
+ if (SUCCEEDED(RCT2_GLOBAL(0x009E2BA4, LPDIRECTSOUND3DBUFFER)->lpVtbl->GetAllParameters(RCT2_GLOBAL(0x009E2BA4, LPDIRECTSOUND3DBUFFER), &RCT2_GLOBAL(0x009A6084, DS3DBUFFER)))) {
+ return 1;
+ }
+ return 0;
+}
+
+/**
+*
+* rct2: 0x00404F3F
+*/
+int sound_load3dposition()
+{
+ /*if (SUCCEEDED(RCT2_GLOBAL(0x009E2BA4, LPDIRECTSOUND3DBUFFER)->lpVtbl->GetPosition(RCT2_GLOBAL(0x009E2BA4, LPDIRECTSOUND3DBUFFER), &RCT2_GLOBAL(0x009A6084, DS3DBUFFER), 1))) {
+ return 1;
+ }*/
+ return 0;
+}
+
+/**
+*
+* rct2: 0x00404932
+*/
+int dsound_create_primary_buffer(int a, int device, int channels, int samples, int bits)
+{
+ rct_dsdevice* dsdevice = 0;
+ if (device) {
+ if (device > RCT2_GLOBAL(RCT2_ADDRESS_NUM_DSOUND_DEVICES, int)) {
+ return 0;
+ }
+ dsdevice = &RCT2_GLOBAL(RCT2_ADDRESS_DSOUND_DEVICES, rct_dsdevice*)[device];
+ }
+ memset(&RCT2_GLOBAL(RCT2_ADDRESS_AUDIO_INFO, rct_audio_info), 0, sizeof(rct_audio_info));
+ RCT2_GLOBAL(RCT2_ADDRESS_AUDIO_INFO, rct_audio_info).var_0 = 1;
+ RCT2_GLOBAL(RCT2_ADDRESS_AUDIO_INFO, rct_audio_info).channels = channels;
+ RCT2_GLOBAL(RCT2_ADDRESS_AUDIO_INFO, rct_audio_info).samples = samples;
+ RCT2_GLOBAL(RCT2_ADDRESS_AUDIO_INFO, rct_audio_info).var_8 = samples * RCT2_GLOBAL(0x01425B4C, uint16);
+ RCT2_GLOBAL(RCT2_ADDRESS_AUDIO_INFO, rct_audio_info).bytes = bits * channels / 8;
+ RCT2_GLOBAL(RCT2_ADDRESS_AUDIO_INFO, rct_audio_info).bits = bits;
+ RCT2_GLOBAL(RCT2_ADDRESS_AUDIO_INFO, rct_audio_info).var_E = 0;
+ DSBUFFERDESC bufferdesc;
+ memset(&bufferdesc, 0, sizeof(bufferdesc));
+ bufferdesc.dwSize = sizeof(bufferdesc);
+ if (a) {
+ if (a != 1) {
+ return 0;
+ }
+ bufferdesc.dwFlags = DSBCAPS_CTRL3D | DSBCAPS_PRIMARYBUFFER;
+ if (RCT2_GLOBAL(0x009E2B90, uint32)) {
+ bufferdesc.dwFlags = DSBCAPS_STICKYFOCUS | DSBCAPS_CTRL3D | DSBCAPS_PRIMARYBUFFER;
+ }
+ if (FAILED(DirectSoundCreate(&dsdevice->guid, &RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND), 0))) {
+ return 0;
+ }
+ if (FAILED(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND)->lpVtbl->SetCooperativeLevel(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND), RCT2_GLOBAL(0x009E2D70, HWND), DSSCL_NORMAL)) ||
+ FAILED(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND)->lpVtbl->CreateSoundBuffer(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND), &bufferdesc, &RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER), 0))) {
+ RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND)->lpVtbl->Release(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND));
+ RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND) = 0;
+ return 0;
+ }
+ if (SUCCEEDED(RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER)->lpVtbl->QueryInterface(RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER), &RCT2_GLOBAL(0x009A4444, IID) /* IID_IDirectSound3DBuffer */, (void**)&RCT2_GLOBAL(0x009E2BA4, LPDIRECTSOUND3DBUFFER)))) {
+ // doesn't seem to ever make it here, below doesn't make sense and is probably remnants of unused 3d sound tests
+ memset(&RCT2_GLOBAL(0x009A6084, DS3DBUFFER), 0, sizeof(RCT2_GLOBAL(0x009A6084, DS3DBUFFER)));
+ RCT2_GLOBAL(0x009A6084, DS3DBUFFER).dwSize = sizeof(RCT2_GLOBAL(0x009A6084, DS3DBUFFER));
+
+ if (sound_load3dparameters()) {
+ RCT2_GLOBAL(0x009A6084, DS3DBUFFER).vPosition.x = 0.0f;
+ }
+ RCT2_GLOBAL(0x009A6084, DS3DBUFFER).vPosition.y = 0.0f;
+ RCT2_GLOBAL(0x009A6084, DS3DBUFFER).vPosition.x = -1.0f;
+ RCT2_GLOBAL(0x009A6084, DS3DBUFFER).flMaxDistance = 9.8999996f;
+ RCT2_GLOBAL(0x009A6084, DS3DBUFFER).flMinDistance = 0.25f;
+ if (sound_load3dposition()) {
+ if (SUCCEEDED(RCT2_GLOBAL(0x009E2BA4, LPDIRECTSOUND3DBUFFER)->lpVtbl->SetMinDistance(RCT2_GLOBAL(0x009E2BA4, LPDIRECTSOUND3DBUFFER), RCT2_GLOBAL(0x009A6084, DS3DBUFFER).flMinDistance, 1))) {
+ if (sound_load3dparameters()) {
+ return 1;
+ }
+ }
+ }
+ RCT2_GLOBAL(0x009E2BA4, LPDIRECTSOUND3DBUFFER)->lpVtbl->Release(RCT2_GLOBAL(0x009E2BA4, LPDIRECTSOUND3DBUFFER));
+ RCT2_GLOBAL(0x009E2BA4, LPDIRECTSOUND3DBUFFER) = 0;
+ RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER)->lpVtbl->Release(RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER));
+ RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER) = 0;
+ RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND)->lpVtbl->Release(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND));
+ RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND) = 0;
+ } else {
+ RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER)->lpVtbl->Release(RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER));
+ RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER) = 0;
+ RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND)->lpVtbl->Release(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND));
+ RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND) = 0;
+ }
+ }
+ bufferdesc.dwFlags = DSBCAPS_PRIMARYBUFFER;
+ if (RCT2_GLOBAL(0x009E2B90, uint32)) {
+ bufferdesc.dwFlags = DSBCAPS_STICKYFOCUS | DSBCAPS_PRIMARYBUFFER;
+ }
+ if (FAILED(DirectSoundCreate(&dsdevice->guid, &RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND), 0))) {
+ return 0;
+ }
+ if (FAILED(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND)->lpVtbl->SetCooperativeLevel(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND), RCT2_GLOBAL(0x009E2D70, HWND), DSSCL_PRIORITY))) {
+ RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND)->lpVtbl->Release(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND));
+ RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND) = 0;
+ return 0;
+ }
+ RCT2_GLOBAL(0x01425B60, DSCAPS).dwSize = sizeof(DSCAPS);
+ RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND)->lpVtbl->GetCaps(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND), &RCT2_GLOBAL(0x01425B60, DSCAPS));
+ if (FAILED(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND)->lpVtbl->CreateSoundBuffer(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND), &bufferdesc, &RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER), 0))) {
+ RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER)->lpVtbl->Release(RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER));
+ RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER) = 0;
+ RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND)->lpVtbl->Release(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND));
+ RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND) = 0;
+ }
+ WAVEFORMATEX waveformat1, waveformat2;
+ RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER)->lpVtbl->GetFormat(RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER), &waveformat1, sizeof(WAVEFORMATEX), 0);
+ RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER)->lpVtbl->SetFormat(RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER), &RCT2_GLOBAL(RCT2_ADDRESS_AUDIO_INFO, WAVEFORMATEX));
+ RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER)->lpVtbl->GetFormat(RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER), &waveformat2, sizeof(WAVEFORMATEX), 0);
+ return 1;
+}
+
+/**
+*
+* rct2: 0x004067F9
+*/
+LPVOID map_file(LPCSTR lpFileName, DWORD dwCreationDisposition, DWORD dwNumberOfBytesToMap)
+{
+ DWORD dwDesiredAccess;
+ DWORD dwDesiredAccessmap;
+ DWORD flProtect;
+ HANDLE filehandle;
+ HANDLE filemaphandle;
+ LPVOID address = 0;
+ if (dwCreationDisposition) {
+ if (dwCreationDisposition == CREATE_NEW) {
+ dwDesiredAccess = GENERIC_READ | GENERIC_WRITE;
+ dwDesiredAccessmap = FILE_MAP_WRITE;
+ flProtect = PAGE_READWRITE;
+ dwCreationDisposition = OPEN_ALWAYS;
+ }
+ } else {
+ dwDesiredAccess = GENERIC_READ;
+ flProtect = PAGE_READONLY;
+ dwDesiredAccessmap = FILE_MAP_READ;
+ dwCreationDisposition = OPEN_EXISTING;
+ }
+ filehandle = CreateFileA(lpFileName, dwDesiredAccess, 0, 0, dwCreationDisposition, FILE_ATTRIBUTE_NORMAL, 0);
+ if (filehandle != INVALID_HANDLE_VALUE) {
+ filemaphandle = CreateFileMappingA(filehandle, 0, flProtect, 0, dwNumberOfBytesToMap, 0);
+ CloseHandle(filehandle);
+ if (filemaphandle) {
+ address = MapViewOfFile(filemaphandle, dwDesiredAccessmap, 0, 0, dwNumberOfBytesToMap);
+ CloseHandle(filemaphandle);
+ }
+ }
+ return address;
+}
+
+/**
+*
+* rct2: 0x00404C1A
+*/
+int map_sound_info(const char* filename)
+{
+ if (RCT2_GLOBAL(RCT2_ADDRESS_SOUND_INFO_LIST_MAPPING, LPVOID)) {
+ return 0;
+ } else {
+ RCT2_GLOBAL(RCT2_ADDRESS_SOUND_INFO_LIST_MAPPING, LPVOID) = map_file(filename, 0, 0);
+ return RCT2_GLOBAL(RCT2_ADDRESS_SOUND_INFO_LIST_MAPPING, LPVOID) != 0;
+ }
+}
+
+/**
+*
+* rct2: 0x00405383
+*/
+MMRESULT mmio_read(HMMIO hmmio, uint32 size, char* buffer, LPMMCKINFO mmckinfo, int* read)
+{
+ MMIOINFO mmioinfo;
+ MMRESULT result;
+ result = mmioGetInfo(hmmio, &mmioinfo, 0);
+ if (result != 0) {
+ *read = 0;
+ return 1;
+ }
+ int size2 = size;
+ if (size > mmckinfo->cksize) {
+ size2 = mmckinfo->cksize;
+ }
+ int v8 = 0;
+ mmckinfo->cksize -= size2;
+ if (size2) {
+ while (1) {
+ HPSTR p = mmioinfo.pchEndRead;
+ if (mmioinfo.pchNext == mmioinfo.pchEndRead) {
+ result = mmioAdvance(hmmio, &mmioinfo, 0);
+ if (result != 0) {
+ *read = 0;
+ return result;
+ }
+ p = mmioinfo.pchEndRead;
+ if (mmioinfo.pchNext == mmioinfo.pchEndRead) {
+ break;
+ }
+ }
+ int q = p - mmioinfo.pchNext;
+ if (size2 - v8 < p - mmioinfo.pchNext) {
+ q = size2 - v8;
+ }
+ memcpy(&buffer[v8], mmioinfo.pchNext, q);
+ mmioinfo.pchNext += q;
+ v8 += q;
+ if (v8 >= size2) {
+ result = mmioSetInfo(hmmio, &mmioinfo, 0);
+ if (result != 0) {
+ *read = 0;
+ return result;
+ } else {
+ *read = size2;
+ return result;
+ }
+ }
+ }
+ *read = 0;
+ return 57603;
+ }
+ result = mmioSetInfo(hmmio, &mmioinfo, 0);
+ if (result != 0) {
+ *read = 0;
+ return result;
+ } else {
+ *read = size2;
+ return result;
+ }
+}
+
+/**
+*
+* rct2: 0x00405465
+*/
+MMRESULT mmio_seek(HMMIO* hmmio, LPMMCKINFO mmckinfo1, LPMMCKINFO mmckinfo2, int offset)
+{
+ mmioSeek(*hmmio, mmckinfo2->dwDataOffset + 4, SEEK_SET);
+ mmckinfo1->ckid = 1635017060/*DATA*/;
+ MMRESULT result = mmioDescend(*hmmio, mmckinfo1, mmckinfo2, MMIO_FINDCHUNK);
+ if (!result) {
+ mmioSeek(*hmmio, offset, SEEK_CUR);
+ return 0;
+ }
+ return result;
+}
+
+/**
+*
+* rct2: 0x004015E7
+*/
+int sub_4015E7(int channel)
+{
+ char* buf1;
+ int buf1size;
+ char* buf2;
+ int buf2size;
+ int read;
+ int zero = 0;
+ rct_sound_channel* sound_channel = &RCT2_ADDRESS(0x014262E0, rct_sound_channel)[channel];
+ LPDIRECTSOUNDBUFFER dsbuffer = RCT2_ADDRESS(RCT2_ADDRESS_DSOUND_BUFFERS, LPDIRECTSOUNDBUFFER)[channel];
+ int result = dsbuffer->lpVtbl->Lock(dsbuffer, 0, sound_channel->var_150, (LPVOID*)&buf1, (LPDWORD)&buf1size, (LPVOID*)&buf2, (LPDWORD)&buf2size, 0);
+ if (SUCCEEDED(result)) {
+ if (buf1size) {
+ mmio_read(sound_channel->hmmio, buf1size, buf1, &sound_channel->mmckinfo1, &read);
+ int r = read;
+ if (read < buf1size) {
+ if (sound_channel->var_164) {
+ char* b = buf1;
+ int d = buf1size;
+ do {
+ d -= r;
+ b += r;
+ sub_40153B(channel);
+ mmio_read(sound_channel->hmmio, d, b, &sound_channel->mmckinfo1, &read);
+ r = read;
+ } while(read < d);
+ } else {
+ sound_channel->var_168 = 1;
+ sound_channel->var_15C = read;
+ rct_audio_info* audio_info = sound_channel->hmem;
+ uint16 v = ((audio_info->var_E != 8) - 1) & 0x80;
+ memset(&buf1[read], v, buf1size - r);
+ }
+ }
+ }
+ result = dsbuffer->lpVtbl->Unlock(dsbuffer, buf1, buf1size, buf2, zero);
+ sound_channel->var_158 = 0;
+ sound_channel->playpos = 0;
+ }
+ return result;
+}
+
+/**
+*
+* rct2: 0x004016FF
+*/
+int sound_channel_load_file(int channel, char* filename, int offset)
+{
+ rct_sound_channel* sound_channel = &RCT2_ADDRESS(0x014262E0, rct_sound_channel)[channel];
+ sound_channel->hmem;
+ sound_channel->hmmio;
+ if (mmio_open(filename, &sound_channel->hmmio, &sound_channel->hmem, &sound_channel->mmckinfo2)) {
+ return -100;
+ }
+ if (*(uint16*)sound_channel->hmem != 1) {
+ sound_channel_free(&sound_channel->hmmio, &sound_channel->hmem);
+ return -101;
+ }
+ if (mmio_seek(&sound_channel->hmmio, &sound_channel->mmckinfo1, &sound_channel->mmckinfo2, offset)) {
+ sound_channel_free(&sound_channel->hmmio, &sound_channel->hmem);
+ return -103;
+ }
+ sound_channel->var_150 = 120 * *((uint32*)sound_channel->hmem + 2) / 100;
+ DSBUFFERDESC bufferdesc;
+ memset(&bufferdesc, 0, sizeof(bufferdesc));
+ bufferdesc.dwFlags = RCT2_GLOBAL(0x009E1AA8, uint32) | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLPAN | DSBCAPS_CTRLFREQUENCY;
+ bufferdesc.dwBufferBytes = sound_channel->var_150;
+ bufferdesc.lpwfxFormat = sound_channel->hmem;
+ bufferdesc.dwSize = sizeof(bufferdesc);
+ int ret = RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND)->lpVtbl->CreateSoundBuffer(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND), &bufferdesc, &RCT2_ADDRESS(RCT2_ADDRESS_DSOUND_BUFFERS, LPDIRECTSOUNDBUFFER)[channel], 0);
+ if (FAILED(ret)) {
+ return -102;
+ }
+ sound_channel->dsbuffer = RCT2_ADDRESS(RCT2_ADDRESS_DSOUND_BUFFERS, LPDIRECTSOUNDBUFFER)[channel];
+ sound_channel->var_168 = 0;
+ sound_channel->var_15C = 0;
+ sound_channel->var_164 = 1;
+ sub_4015E7(channel);
+ sound_channel->var_158 = offset;
+ sound_channel->var_160 = 0;
+ return 0;
+}
+
+/**
+*
+* rct2: 0x00405222
+*/
+MMRESULT mmio_open(char* filename, HMMIO* hmmio, HGLOBAL* hmem, LPMMCKINFO mmckinfo)
+{
+ HGLOBAL* hmemold;
+ HGLOBAL hmemold2;
+ HMMIO hmmio1;
+ MMRESULT result;
+ MMCKINFO mmckinfo1;
+ rct_audio_info audio_info;
+
+ hmemold = hmem;
+ *hmem = 0;
+ hmmio1 = mmioOpenA(filename, 0, MMIO_ALLOCBUF);
+ if (hmmio1) {
+ result = mmioDescend(hmmio1, mmckinfo, 0, 0);
+ if (result != MMSYSERR_NOERROR) {
+ goto label20;
+ }
+ if (mmckinfo->ckid != 1179011410/*RIFF*/ || mmckinfo->fccType != 1163280727/*WAVE*/) {
+ result = 57601;
+ goto label20;
+ }
+ mmckinfo1.ckid = 544501094/*fmt*/;
+ result = mmioDescend(hmmio1, &mmckinfo1, mmckinfo, MMIO_FINDCHUNK);
+ if (result != MMSYSERR_NOERROR) {
+ goto label20;
+ }
+ if (mmckinfo1.cksize < 16) {
+ label19:
+ result = 57601;
+ goto label20;
+ }
+ if (mmioRead(hmmio1, (HPSTR)&audio_info, 16) == 16) {
+ if (audio_info.var_0 == 1) {
+ //strcpy(audio_info.var_0, "\x01");
+ hmem = 0;
+ label11:
+ hmemold2 = GlobalAlloc(0, (uint16)hmem + 18);
+ *hmemold = hmemold2;
+ if (!hmemold2) {
+ result = 57344;
+ goto label20;
+ }
+ memcpy(hmemold2, &audio_info, 16);
+ *((uint16*)*hmemold + 8) = (uint16)hmem;
+ if (!(uint16)hmem || mmioRead(hmmio1, (char*)*hmemold + 18, (uint16)hmem) == (uint16)hmem) {
+ result = mmioAscend(hmmio1, &mmckinfo1, 0);
+ if (!result) {
+ goto label24;
+ }
+ goto label20;
+ }
+ goto label19;
+ }
+ if (mmioRead(hmmio1, (HPSTR)&hmem, 2) == 2) {
+ goto label11;
+ }
+ }
+ result = 57602;
+ goto label20;
+ }
+ result = 57600;
+ label20:
+ if (*hmemold) {
+ GlobalFree(*hmemold);
+ *hmemold = 0;
+ }
+ if (hmmio1) {
+ mmioClose(hmmio1, 0);
+ hmmio1 = 0;
+ }
+ label24:
+ *hmmio = hmmio1;
+ return result;
+}
+
+/**
+*
+* rct2: 0x00401822
+*/
+int mmio_open_channel(int channel, char* filename, LONG offset)
+{
+ rct_sound_channel* sound_channel = &RCT2_ADDRESS(0x014262E0, rct_sound_channel)[channel];
+ LPMMCKINFO v4 = &sound_channel->mmckinfo2;
+ HMMIO* v5 = &sound_channel->hmmio;
+ if (mmio_open(filename, &sound_channel->hmmio, &sound_channel->hmem, &sound_channel->mmckinfo2)) {
+ return -100;
+ }
+ if (*(uint16*)sound_channel->hmem != 1) {
+ sound_channel_free(&sound_channel->hmmio, &sound_channel->hmem);
+ return -101;
+ }
+ if (mmio_seek(&sound_channel->hmmio, &sound_channel->mmckinfo1, &sound_channel->mmckinfo2, offset)) {
+ sound_channel_free(&sound_channel->hmmio, &sound_channel->hmem);
+ return -103;
+ }
+ sound_channel->var_158 = offset;
+ return 0;
+}
+
+/**
+*
+* rct2: 0x0040153B
+*/
+int sub_40153B(int channel)
+{
+ rct_sound_channel* sound_channel = &RCT2_ADDRESS(0x014262E0, rct_sound_channel)[channel];
+ if (sound_channel->var_4) {
+ if (sound_channel->hmmio) {
+ sound_channel_free(&sound_channel->hmmio, &sound_channel->hmem);
+ }
+ if (mmio_open_channel(channel, sound_channel->filename, sound_channel->var_110)) {
+ return 0;
+ }
+ sound_channel->var_164 = sound_channel->var_114;
+ sound_channel->var_118 = sound_channel->var_110;
+ sound_channel->var_4 = 0;
+ } else {
+ int result = mmio_seek(&sound_channel->hmmio, &sound_channel->mmckinfo1, &sound_channel->mmckinfo2, sound_channel->var_118);
+ sound_channel->var_158 = sound_channel->var_118;
+ if (result) {
+ return 0;
+ }
+ }
+ return 1;
+}
+
+/**
+*
+* rct2: 0x00401000
+*/
+void audio_timefunc(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2, int channel)
+{
+ rct_sound_channel* sound_channel = &RCT2_ADDRESS(0x014262E0, rct_sound_channel)[channel];
+ DWORD status;
+ DWORD dwCurrentPlayCursor;
+ DWORD dwCurrentWriteCursor;
+ uint32 var1;
+ int var2;
+ int bufferlost = 0;
+ char* buf1;
+ int buf1size;
+ char* buf2;
+ int buf2size;
+ sound_channel->dsbuffer->lpVtbl->GetStatus(sound_channel->dsbuffer, &status);
+ if (status & DSBSTATUS_BUFFERLOST) {
+ if (FAILED(sound_channel->dsbuffer->lpVtbl->Restore(sound_channel->dsbuffer))) {
+ return;
+ }
+ sound_channel->playpos = 0;
+ bufferlost = 1;
+ }
+ sound_channel->dsbuffer->lpVtbl->GetCurrentPosition(sound_channel->dsbuffer, &dwCurrentPlayCursor, &dwCurrentWriteCursor);
+ if (dwCurrentPlayCursor != sound_channel->playpos || bufferlost) {
+ if (sound_channel->var_168 && !sound_channel->var_15C) {
+ if (!sound_channel->var_160) {
+ sound_channel->var_160 = 1;
+ if (!sound_channel->var_4) {
+ LPDIRECTSOUNDBUFFER dsbuffer = RCT2_ADDRESS(RCT2_ADDRESS_DSOUND_BUFFERS, LPDIRECTSOUNDBUFFER)[channel];
+ sound_channel->var_0 = 0;
+ if (dsbuffer) {
+ dsbuffer->lpVtbl->Stop(dsbuffer);
+ dsbuffer->lpVtbl->Release(dsbuffer);
+ RCT2_ADDRESS(RCT2_ADDRESS_DSOUND_BUFFERS, LPDIRECTSOUNDBUFFER)[channel] = 0;
+ }
+ if (sound_channel->hmmio) {
+ sound_channel_free(&sound_channel->hmmio, &sound_channel->hmem);
+ }
+ }
+ }
+ return;
+ }
+ if (dwCurrentPlayCursor >= sound_channel->playpos) {
+ var1 = dwCurrentPlayCursor - sound_channel->playpos;
+ } else {
+ var1 = dwCurrentPlayCursor + sound_channel->var_150 - sound_channel->playpos;
+ }
+ if (bufferlost) {
+ var2 = 2 * sound_channel->var_150 / 6;
+ } else {
+ var2 = var1;
+ }
+ sound_channel->var_158 += var1;
+ if (sound_channel->var_168) {
+ uint32 var3 = sound_channel->var_15C;
+ uint32* var4 = &sound_channel->var_15C;
+ if (var3) {
+ if (var1 <= var3) {
+ *var4 = var3 - var1;
+ } else {
+ *var4 = 0;
+ }
+ if (SUCCEEDED(sound_channel->dsbuffer->lpVtbl->Lock(sound_channel->dsbuffer, sound_channel->playpos, var2, (LPVOID*)&buf1, (LPDWORD)&buf1size, (LPVOID*)&buf2, (LPDWORD)&buf2size, 0))) {
+ uint16 var5 = -(sound_channel->mmckinfo1.cksize != 8);
+ var5 &= 0x80;
+ memset(buf1, var5 + 128, buf1size);
+ if (buf2 && buf2size) {
+ uint16 var5 = -(sound_channel->mmckinfo1.cksize != 8);
+ var5 &= 0x80;
+ memset(buf2, var5 + 128, buf2size);
+ }
+ sound_channel->dsbuffer->lpVtbl->Unlock(sound_channel->dsbuffer, buf1, buf1size, buf2, buf2size);
+ sound_channel->playpos += var2;
+ if (sound_channel->playpos >= sound_channel->var_150) {
+ sound_channel->playpos = sound_channel->playpos - sound_channel->var_150;
+ }
+ return;
+ }
+ // TimeFunc() could not lock DirectSoundBuffer
+ return;
+ }
+ }
+ if (FAILED(sound_channel->dsbuffer->lpVtbl->Lock(sound_channel->dsbuffer, sound_channel->playpos, var2, (LPVOID*)&buf1, (LPDWORD)&buf1size, (LPVOID*)&buf2, &buf2size, 0))) {
+ // TimeFunc() could not lock DirectSoundBuffer
+ return;
+ }
+ if (buf1size) {
+ if (sound_channel->var_160) {
+ uint16 var5 = -(sound_channel->mmckinfo1.cksize != 8);
+ var5 &= 0x80;
+ memset(buf1, var5 + 128, buf1size);
+ goto label49;
+ }
+ }
+ int var7;
+ mmio_read(sound_channel->hmmio, buf1size, buf1, &sound_channel->mmckinfo1, &var7);
+ if (var7 < buf1size) {
+ if (!sound_channel->var_164) {
+ int s = sound_channel->mmckinfo1.cksize;
+ int t = buf1size - var7;
+ int v;
+ if (s == 8) {
+ v = 128;
+ } else {
+ if (s != 16) {
+ goto label42;
+ }
+ v = 0;
+ }
+ memset(&buf1[var7], v, t);
+ label42:
+ sound_channel->var_168 = 1;
+ if (dwCurrentPlayCursor <= sound_channel->playpos) {
+ sound_channel->var_15C = sound_channel->playpos - dwCurrentPlayCursor;
+ } else {
+ sound_channel->var_15C = sound_channel->playpos + sound_channel->var_150 - dwCurrentPlayCursor;
+ }
+ goto label49;
+ }
+ char* v21 = buf1;
+ int v38 = buf1size;
+ do {
+ v38 -= var7;
+ v21 += var7;
+ sub_40153B(channel);
+ mmio_read(sound_channel->hmmio, v38, v21, &sound_channel->mmckinfo1, &var7);
+ } while(var7 < v38);
+ }
+ label49:
+ if (buf2size == 0 || sound_channel->var_160 != 0) {
+ if(buf2 != 0 && buf2size != 0 && sound_channel->var_160 != 0) {
+ int var5 = -(sound_channel->mmckinfo1.cksize != 8);
+ var5 &= 0x80;
+ memset(buf2, var5 + 128, buf2size);
+ }
+ goto label68;
+ }
+ mmio_read(sound_channel->hmmio, buf2size, buf2, &sound_channel->mmckinfo1, &var7);
+ if (var7 >= buf2size) {
+ label68:
+ sound_channel->dsbuffer->lpVtbl->Unlock(sound_channel->dsbuffer, buf1, buf1size, buf2, buf2size);
+ sound_channel->playpos += var2;
+ if (sound_channel->playpos >= sound_channel->var_150) {
+ sound_channel->playpos -= sound_channel->var_150;
+ }
+ if (bufferlost != 0) {
+ sound_channel->dsbuffer->lpVtbl->Play(sound_channel->dsbuffer, 0, 0, DSBPLAY_LOOPING);
+ }
+ return;
+ }
+ if (sound_channel->var_164 != 0) {
+ char* v26 = buf2;
+ int v27 = buf2size;
+ do {
+ v26 += var7;
+ v27 -= var7;
+ sub_40153B(channel);
+ mmio_read(sound_channel->hmmio, v27, v26, &sound_channel->mmckinfo1, &var7);
+ } while(var7 < v27);
+ goto label68;
+ }
+ int s = buf2size - var7;
+ int v;
+ if (sound_channel->hmem == (HGLOBAL)8) {
+ v = 128;
+ } else {
+ if (sound_channel->hmem != (HGLOBAL)16) {
+ goto label58;
+ }
+ v = 0;
+ }
+ memset(&buf2[var7], v, s);
+ label58:
+ sound_channel->var_168 = 1;
+ if (dwCurrentPlayCursor <= sound_channel->playpos) {
+ sound_channel->var_15C = sound_channel->playpos - dwCurrentPlayCursor;
+ } else {
+ sound_channel->var_15C = sound_channel->playpos + sound_channel->var_150 - dwCurrentPlayCursor;
+ }
+ goto label68;
+ }
+}
+
+/**
+*
+* rct2: 0x004014DF
+*/
+int CALLBACK audio_timer_callback(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2)
+{
+ if (_InterlockedExchange(&RCT2_GLOBAL(0x009E1AAC, LONG), 1) == 0) {
+ for (int i = 0; i < 4; i++) {
+ rct_sound_channel* sound_channel = &RCT2_ADDRESS(RCT2_ADDRESS_SOUND_CHANNEL_LIST, rct_sound_channel)[i];
+ if(sound_channel->var_0){
+ audio_timefunc(uTimerID, uMsg, dwUser, dw1, dw2, i);
+ }
+ }
+ return _InterlockedExchange(&RCT2_GLOBAL(0x009E1AAC, LONG), 0);
+ }
+ return 0;
+}
+
+/**
+*
+* rct2: 0x004018A6
+*/
+int audio_create_timer()
+{
+ if (RCT2_GLOBAL(0x009E1AA4, int)) {
+ return 0;
+ }
+ for (int i = 0; i < 4; i++) {
+ rct_sound_channel* sound_channel = &RCT2_ADDRESS(RCT2_ADDRESS_SOUND_CHANNEL_LIST, rct_sound_channel)[i];
+ sound_channel->var_0 = 0;
+ }
+ RCT2_GLOBAL(0x009E1AA0, MMRESULT) = timeSetEvent(50, 10, (LPTIMECALLBACK)audio_timer_callback, 0, TIME_PERIODIC);
+ if (!RCT2_GLOBAL(0x009E1AA0, MMRESULT)) {
+ return 0;
+ }
+ RCT2_GLOBAL(0x009E1AA4, int) = 1;
+ return 1;
+}
+
+/**
+*
+* rct2: 0x006BA9B5
+*/
+void audio_init2(int device)
+{
+ audio_close();
+ for (int i = 0; i < 7; i++) {
+ rct_vehicle_sound* vehicle_sound = &RCT2_ADDRESS(RCT2_ADDRESS_VEHICLE_SOUND_LIST, rct_vehicle_sound)[i];
+ vehicle_sound->id = 0xFFFF;
+ }
+ for (int i = 0; i < 7; i++) {
+ rct_other_sound* other_sound = &RCT2_ADDRESS(0x009AF484, rct_other_sound)[i];
+ other_sound->id = 0xFFFF;
+ }
+ RCT2_GLOBAL(0x014241BC, uint32) = 1;
+ int successdsound = dsound_create_primary_buffer(0, device, 2, 22050, 16);
+ RCT2_GLOBAL(0x014241BC, uint32) = 0;
+ if (!successdsound) {
+ return;
+ }
+ const char * filepath = get_file_path(2);
+ RCT2_GLOBAL(0x014241BC, uint32) = 1;
+ int successmap = map_sound_info(filepath);
+ RCT2_GLOBAL(0x014241BC, uint32) = 0;
+ if (!successmap) {
+ RCT2_GLOBAL(0x014241BC, uint32) = 1;
+ audio_release();
+ RCT2_GLOBAL(0x014241BC, uint32) = 0;
+ return;
+ }
+ RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, uint32) = device;
+ rct_dsdevice dsdevice = RCT2_GLOBAL(RCT2_ADDRESS_DSOUND_DEVICES, rct_dsdevice*)[device];
+ RCT2_GLOBAL(0x009AAC5D, uint32) = dsdevice.guid.Data1;
+ RCT2_GLOBAL(0x009AAC61, uint32) = dsdevice.guid.Data2;
+ RCT2_GLOBAL(0x009AAC65, uint32) = dsdevice.guid.Data3;
+ RCT2_GLOBAL(0x009AAC69, uint32) = (uint32)dsdevice.guid.Data4;
+ RCT2_GLOBAL(0x009AAC5C, uint8) = 1;
+ config_save();
+ RCT2_GLOBAL(0x014241BC, uint32) = 1;
+ int successtimer = audio_create_timer();
+ RCT2_GLOBAL(0x014241BC, uint32) = 0;
+ if (successtimer) {
+ if ((RCT2_GLOBAL(0x009AF284, uint32) & (1 << 0))) {
+ for (int i = 0; i < 2; i++) {
+ RCT2_GLOBAL(0x009AF46C + (i * 8), uint8) = -1;
+ }
+ }
+ }
+ if (!(RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) & 1 << 4)) {
+ RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_SOUND_SW_BUFFER, uint32) = RCT2_GLOBAL(0x001425B74, uint32) != RCT2_GLOBAL(0x001425B78, uint32) || RCT2_GLOBAL(0x001425B74, uint32) != RCT2_GLOBAL(0x001425B7C, uint32);
+ RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) |= 1 << 4;
+ config_save();
+ }
+}
+
+/**
+*
+* rct2: 0x00404F85
+*/
+BOOL CALLBACK dsound_enum_callback_count(LPGUID lpGuid, LPCSTR lpcstrDescription, LPCSTR lpcstrModule, LPVOID lpContext)
+{
+ RCT2_GLOBAL(RCT2_ADDRESS_DSOUND_DEVICES_COUNTER, int)++;
+ return 1;
+}
+
+/**
+*
+* rct2: 0x00404F91
+*/
+int dsound_count_devices()
+{
+ RCT2_GLOBAL(RCT2_ADDRESS_DSOUND_DEVICES_COUNTER, int) = 0;
+ if (SUCCEEDED(DirectSoundEnumerate(dsound_enum_callback_count, 0))) {
+ return RCT2_GLOBAL(RCT2_ADDRESS_DSOUND_DEVICES_COUNTER, int);
+ }
+ return 0;
+}
+
+/**
+*
+* rct2: 0x00404FB1
+*/
+BOOL CALLBACK dsound_enum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription, LPCSTR lpcstrModule, LPVOID lpContext)
+{
+ if (lpGuid) {
+ memcpy(&RCT2_GLOBAL(RCT2_ADDRESS_DSOUND_DEVICES, rct_dsdevice*)[RCT2_GLOBAL(0x01425B54, int)].guid, lpGuid, sizeof(GUID));
+ } else {
+ memset(&RCT2_GLOBAL(RCT2_ADDRESS_DSOUND_DEVICES, rct_dsdevice*)[RCT2_GLOBAL(0x01425B54, int)].guid, 0, sizeof(GUID));
+ }
+ strcpy(RCT2_GLOBAL(RCT2_ADDRESS_DSOUND_DEVICES, rct_dsdevice*)[RCT2_GLOBAL(0x01425B54, int)].desc, lpcstrDescription);
+ strcpy(RCT2_GLOBAL(RCT2_ADDRESS_DSOUND_DEVICES, rct_dsdevice*)[RCT2_GLOBAL(0x01425B54, int)].drvname, lpcstrModule);
+ RCT2_GLOBAL(0x01425B54, int)++;
+ return 1;
+}
+
/**
*
* rct2: 0x0040502E
*/
-void get_dsound_devices()
+int get_dsound_devices()
{
- RCT2_CALLPROC(0x0040502E);
+ RCT2_GLOBAL(RCT2_ADDRESS_NUM_DSOUND_DEVICES, uint32) = dsound_count_devices();
+ RCT2_GLOBAL(RCT2_ADDRESS_DSOUND_DEVICES, rct_dsdevice*) = malloc(RCT2_GLOBAL(RCT2_ADDRESS_NUM_DSOUND_DEVICES, uint32) * sizeof(rct_dsdevice));
+ if (RCT2_GLOBAL(RCT2_ADDRESS_DSOUND_DEVICES, rct_dsdevice*)) {
+ RCT2_GLOBAL(0x01425B54, int) = 0;
+ DirectSoundEnumerate(dsound_enum_callback, 0);
+ return RCT2_GLOBAL(0x01425B54, int);
+ }
+ return 0;
}
-int sound_prepare(int sound_id, rct_sound *sound, int var_8, int var_c)
+/**
+*
+* rct2: 0x00404D99
+*/
+int sound_duplicate(rct_sound* newsound, rct_sound* sound)
{
- return RCT2_CALLFUNC_4(0x00404C6D, int, int, rct_sound*, int, int, sound_id, sound, var_8, var_c);
+ if (FAILED(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND)->lpVtbl->DuplicateSoundBuffer(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND), sound->dsbuffer, &newsound->dsbuffer))) {
+ return 0;
+ } else {
+ newsound->id = sound->id;
+ newsound->has_caps = sound->has_caps;
+ newsound->var_0C = sound->var_0C;
+ sound_add(newsound);
+ return 1;
+ }
}
-void sound_play_panned(int sound_id, int x)
+/**
+*
+* rct2: 0x00405103
+*/
+rct_sound* sound_begin()
{
- RCT2_CALLPROC_X(0x006BB76E, sound_id, x, 0, 0, 0, 0, 0);
+ return RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_BEGIN, rct_sound*);
+}
+
+/**
+*
+* rct2: 0x00405109
+*/
+rct_sound* sound_next(rct_sound* sound)
+{
+ if (RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_END, rct_sound*) == sound) {
+ return 0;
+ } else {
+ return sound->next;
+ }
+}
+
+/**
+*
+* rct2: 0x00405206
+*/
+rct_sound_info* sound_get_info(uint16 sound_id)
+{
+ if (RCT2_GLOBAL(RCT2_ADDRESS_SOUND_INFO_LIST_MAPPING, LPVOID) && sound_id < RCT2_GLOBAL(RCT2_ADDRESS_SOUND_INFO_LIST_MAPPING, uint32*)[0]) {
+ return (rct_sound_info*)(RCT2_GLOBAL(RCT2_ADDRESS_SOUND_INFO_LIST_MAPPING, int) + RCT2_GLOBAL(RCT2_ADDRESS_SOUND_INFO_LIST_MAPPING, uint32*)[sound_id + 1]);
+ }
+ return 0;
+}
+
+/**
+*
+* rct2: 0x00405054
+*/
+int sound_info_loadvars(rct_sound_info* sound_info, LPWAVEFORMATEX* waveformat, char** data, DWORD* buffersize)
+{
+ *buffersize = sound_info->size;
+ *waveformat = &sound_info->format;
+ *data = (char*)&sound_info->data;
+ return 1;
+}
+
+/**
+*
+* rct2: 0x00405076
+*/
+int sound_fill_buffer(LPDIRECTSOUNDBUFFER dsbuffer, char* src, DWORD size)
+{
+ LPVOID buf;
+ LPVOID buf2;
+ DWORD buf2size;
+ if (SUCCEEDED(dsbuffer->lpVtbl->Lock(dsbuffer, 0, size, &buf, &size, &buf2, &buf2size, 0))) {
+ memset(buf, 0, size);
+ memcpy(buf, src, size);
+ if (buf2size) {
+ memcpy(buf2, &src[size], buf2size);
+ }
+ dsbuffer->lpVtbl->Unlock(dsbuffer, buf, size, buf2, buf2size);
+ return 1;
+ }
+ return 0;
+}
+
+/**
+*
+* rct2: 0x00404C6D
+*/
+int sound_prepare(int sound_id, rct_sound *sound, int channels, int software)
+{
+ DSBUFFERDESC bufferdesc;
+ char* buffer = 0;
+ memset(&bufferdesc, 0, sizeof(bufferdesc));
+ bufferdesc.dwSize = sizeof(bufferdesc);
+ rct_sound* tempsound = sound_begin();
+ if (tempsound) {
+ int wasduplicated = 0;
+ while (!tempsound->dsbuffer || tempsound->id != sound_id || !sound_duplicate(sound, tempsound)) {
+ tempsound = sound_next(tempsound);
+ if (!tempsound) {
+ wasduplicated = 1;
+ break;
+ }
+ }
+ if (!wasduplicated) {
+ return 1;
+ }
+ }
+ rct_sound_info* sound_info = sound_get_info(sound_id);
+ if (sound_info) {
+ if (sound_info_loadvars(sound_info, &bufferdesc.lpwfxFormat, &buffer, &bufferdesc.dwBufferBytes)) {
+ bufferdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_STATIC;
+ if (channels) {
+ if (channels == 2) {
+ bufferdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRL3D | DSBCAPS_STATIC;
+ } else {
+ bufferdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLPAN | DSBCAPS_CTRLFREQUENCY | DSBCAPS_STATIC;
+ }
+ if (RCT2_GLOBAL(0x009E2B90, uint32)) {
+ bufferdesc.dwFlags |= DSBCAPS_CTRLPAN;
+ }
+ if (software) {
+ bufferdesc.dwFlags |= DSBCAPS_LOCSOFTWARE;
+ }
+ if (SUCCEEDED(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND)->lpVtbl->CreateSoundBuffer(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND), &bufferdesc, &sound->dsbuffer, 0))) {
+ if (sound_fill_buffer(sound->dsbuffer, buffer, bufferdesc.dwBufferBytes)) {
+ sound->id = sound_id;
+ DSBCAPS caps;
+ caps.dwSize = sizeof(caps);
+ sound->dsbuffer->lpVtbl->GetCaps(sound->dsbuffer, &caps);
+ sound->has_caps = caps.dwFlags;
+ sound_add(sound);
+ return 1;
+ }
+ sound->dsbuffer->lpVtbl->Release(sound->dsbuffer);
+ sound->dsbuffer = 0;
+ }
+ }
+ sound->dsbuffer = 0;
+ }
+ }
+ return 0;
+}
+
+/**
+*
+* rct2: 0x006BB76E
+*/
+int sound_play_panned(int sound_id, int x)
+{
+ //RCT2_CALLPROC_X(0x006BB76E, sound_id, x, 0, 0, 0, 0, 0);
+ // this function is not complete, need to add in volume adjust
+ int result = 0;
+ if (RCT2_GLOBAL(0x009AF59D, uint8) & 1) {
+ RCT2_GLOBAL(0x00F438AD, uint8) = 0;
+ int volume = 0;
+ if (x == 0x8001) {
+ // stuff to adjust volume
+ }
+ 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 (x == 0x8000) {
+ pan = 0;
+ } else {
+ int x2 = x << 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;
}
/**
@@ -90,14 +1184,15 @@ void sound_play_panned(int sound_id, int x)
*/
int sound_channel_play(int channel, int a2, int volume, int pan, int frequency)
{
- RCT2_GLOBAL(0x1426444 + (91 * channel * 4), uint32) = a2;
+ rct_sound_channel* sound_channel = &RCT2_ADDRESS(RCT2_ADDRESS_SOUND_CHANNEL_LIST, rct_sound_channel)[channel];
+ sound_channel->var_164 = a2;
sound_channel_set_frequency(channel, frequency);
sound_channel_set_pan(channel, pan);
sound_channel_set_volume(channel, volume);
LPDIRECTSOUNDBUFFER dsbuffer = RCT2_ADDRESS(RCT2_ADDRESS_DSOUND_BUFFERS, LPDIRECTSOUNDBUFFER)[channel];
dsbuffer->lpVtbl->SetCurrentPosition(dsbuffer, 0);
dsbuffer->lpVtbl->Play(dsbuffer, 0, 0, DSBPLAY_LOOPING);
- RCT2_GLOBAL(0x14262E0 + (91 * channel * 4), uint32) = 1;
+ sound_channel->var_0 = 1;
return 1;
}
@@ -152,7 +1247,7 @@ int sound_channel_set_volume(int channel, int volume)
*/
int sound_play(rct_sound* sound, int looping, int volume, int pan, int frequency)
{
- if (sound) {
+ if (sound->dsbuffer) {
sound_set_frequency(sound, frequency);
sound_set_pan(sound, pan);
sound_set_volume(sound, volume);
@@ -172,13 +1267,29 @@ int sound_play(rct_sound* sound, int looping, int volume, int pan, int frequency
return 0;
}
+/**
+*
+* rct2: 0x00404E53
+*/
+int sound_is_playing(rct_sound* sound){
+ if (sound->dsbuffer) {
+ DWORD status;
+ if (SUCCEEDED(sound->dsbuffer->lpVtbl->GetStatus(sound->dsbuffer, &status))) {
+ if (status & DSBSTATUS_PLAYING || status & DSBSTATUS_LOOPING)
+ return 1;
+
+ }
+ }
+ return 0;
+}
+
/**
*
* rct2: 0x00404ED7
*/
int sound_set_frequency(rct_sound* sound, int frequency)
{
- if (sound) {
+ if (sound->dsbuffer) {
if (SUCCEEDED(sound->dsbuffer->lpVtbl->SetFrequency(sound->dsbuffer, frequency)))
return 1;
@@ -192,7 +1303,7 @@ int sound_set_frequency(rct_sound* sound, int frequency)
*/
int sound_set_pan(rct_sound* sound, int pan)
{
- if (sound) {
+ if (sound->dsbuffer) {
if (SUCCEEDED(sound->dsbuffer->lpVtbl->SetPan(sound->dsbuffer, pan)))
return 1;
@@ -206,7 +1317,7 @@ int sound_set_pan(rct_sound* sound, int pan)
*/
int sound_set_volume(rct_sound* sound, int volume)
{
- if (sound) {
+ if (sound->dsbuffer) {
if (SUCCEEDED(sound->dsbuffer->lpVtbl->SetVolume(sound->dsbuffer, volume)))
return 1;
@@ -218,13 +1329,30 @@ int sound_set_volume(rct_sound* sound, int volume)
*
* rct2: 0x00404DD8
*/
-void sound_stop(rct_sound* sound)
+int sound_stop(rct_sound* sound)
{
if (sound->dsbuffer) {
sound->dsbuffer->lpVtbl->Release(sound->dsbuffer);
sound->dsbuffer = 0;
- sound_remove(sound);
+ return sound_remove(sound) ? 1 : 0;
}
+ return 0;
+}
+
+/**
+*
+* rct2: 0x0040511C
+*/
+rct_sound* sound_add(rct_sound* sound)
+{
+ if (RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_BEGIN, rct_sound*)) {
+ RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_END, rct_sound*)->next = sound;
+ } else {
+ RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_BEGIN, rct_sound*) = sound;
+ }
+ RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_END, rct_sound*) = sound;
+ sound->next = 0;
+ return sound;
}
/**
@@ -256,25 +1384,175 @@ rct_sound* sound_remove(rct_sound* sound)
return result;
}
+/**
+*
+* rct2: 0x00405436
+*/
+void sound_channel_free(HMMIO* hmmio, HGLOBAL* hmem)
+{
+ if(*hmem)
+ {
+ GlobalFree(*hmem);
+ *hmem = 0;
+ }
+ if(*hmmio)
+ {
+ mmioClose(*hmmio, 0);
+ *hmmio = 0;
+ }
+}
+
/**
*
* rct2: 0x006BABB4
*/
-void pause_sounds() {
+void pause_sounds()
+{
if (++RCT2_GLOBAL(0x009AF59C, uint8) == 1) {
- RCT2_CALLPROC_EBPSAFE(0x006BCAE5);
- RCT2_CALLPROC_EBPSAFE(0x006BABDF);
- RCT2_CALLPROC_EBPSAFE(0x006BCA9F);
- RCT2_CALLPROC_EBPSAFE(0x006BD07F);
+ stop_other_sounds();
+ stop_vehicle_sounds();
+ stop_ride_music();
+ stop_peep_sounds();
}
g_sounds_disabled = 1;
}
+/**
+*
+* rct2: 0x006BCAE5
+*/
+void stop_other_sounds()
+{
+ if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, uint32) != -1) {
+ if (RCT2_GLOBAL(0x009AF5A8, uint32) != 1) {
+ RCT2_GLOBAL(0x014241BC, uint32) = 1;
+ sound_stop(RCT2_GLOBAL(0x009AF5AC, rct_sound*));
+ RCT2_GLOBAL(0x014241BC, uint32) = 0;
+ RCT2_GLOBAL(0x009AF5A8, uint32) = 1;
+ }
+ if (RCT2_GLOBAL(0x009AF5C0, uint32) != 8) {
+ RCT2_GLOBAL(0x014241BC, uint32) = 1;
+ sound_stop(RCT2_GLOBAL(0x009AF5C4, rct_sound*));
+ RCT2_GLOBAL(0x014241BC, uint32) = 0;
+ RCT2_GLOBAL(0x009AF5C0, uint32) = 8;
+ }
+ if (RCT2_GLOBAL(0x009AF5D8, uint32) != 8) {
+ RCT2_GLOBAL(0x014241BC, uint32) = 1;
+ sound_stop(RCT2_GLOBAL(0x009AF5DC, rct_sound*));
+ RCT2_GLOBAL(0x014241BC, uint32) = 0;
+ RCT2_GLOBAL(0x009AF5D8, uint32) = 8;
+ }
+ }
+}
+
+/**
+*
+* rct2: 0x006BABDF
+*/
+void stop_vehicle_sounds()
+{
+ if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, sint32) != -1) {
+ for (int i = 0; i < 7; i++) {
+ rct_vehicle_sound* vehicle_sound = &RCT2_ADDRESS(RCT2_ADDRESS_VEHICLE_SOUND_LIST, rct_vehicle_sound)[i];
+ if (vehicle_sound->id != 0xFFFF) {
+ if (vehicle_sound->var_18 != 0xFFFF) {
+ RCT2_GLOBAL(0x014241BC, uint32) = 1;
+ sound_stop(&vehicle_sound->sound1);
+ RCT2_GLOBAL(0x014241BC, uint32) = 0;
+ }
+ if (vehicle_sound->var_34 != 0xFFFF) {
+ RCT2_GLOBAL(0x014241BC, uint32) = 1;
+ sound_stop(&vehicle_sound->sound2);
+ RCT2_GLOBAL(0x014241BC, uint32) = 0;
+ }
+ }
+ vehicle_sound->id = 0xFFFF;
+ }
+ }
+}
+
+/**
+*
+* rct2: 0x006BCA9F
+*/
+void stop_ride_music()
+{
+ if ((RCT2_GLOBAL(0x009AF284, uint32) & (1 << 0))) {
+ for (int i = 0; i < 2; i++) {
+ uint8 * data = RCT2_ADDRESS(0x009AF46C + (i * 8), uint8);
+ if (data[0] != 0xFF) {
+ RCT2_GLOBAL(0x014241BC, uint32) = 1;
+ sound_channel_stop(i);
+ RCT2_GLOBAL(0x014241BC, uint32) = 0;
+ data[0] = 0xFF;
+ }
+ }
+ }
+}
+
+/**
+*
+* rct2: 0x006BD07F
+*/
+void stop_peep_sounds()
+{
+ if ((RCT2_GLOBAL(0x009AF284, uint32) & (1 << 0))) {
+ if (RCT2_GLOBAL(0x009AF5FC, uint32) != 1) {
+ RCT2_GLOBAL(0x014241BC, uint32) = 1;
+ sound_channel_stop(2);
+ RCT2_GLOBAL(0x014241BC, uint32) = 0;
+ RCT2_GLOBAL(0x009AF5FC, uint32) = 1;
+ }
+ }
+}
+
+/**
+*
+* rct2: 0x006BD0BD
+*/
+void stop_title_music()
+{
+ if (RCT2_GLOBAL(0x009AF284, uint32) & (1 << 0)) {
+ if (RCT2_GLOBAL(0x009AF600, uint8) != 0) {
+ RCT2_GLOBAL(0x014241BC, uint32) = 1;
+ sound_channel_stop(3);
+ RCT2_GLOBAL(0x014241BC, uint32) = 0;
+ }
+ }
+}
+
+/**
+*
+* rct2: 0x00401A05
+*/
+int sound_channel_stop(int channel)
+{
+ rct_sound_channel* sound_channel = &RCT2_ADDRESS(RCT2_ADDRESS_SOUND_CHANNEL_LIST, rct_sound_channel)[channel];
+ sound_channel->var_0 = 0;
+ sound_channel->var_160 = 1;
+ while (_InterlockedExchange(&RCT2_GLOBAL(0x009E1AAC, LONG), 1) != 1) {
+ Sleep(10);
+ }
+ if (sound_channel->hmmio) {
+ sound_channel_free(&sound_channel->hmmio, &sound_channel->hmem);
+ }
+
+ LPDIRECTSOUNDBUFFER dsbuffer = RCT2_ADDRESS(RCT2_ADDRESS_DSOUND_BUFFERS, LPDIRECTSOUNDBUFFER)[channel];
+ if (dsbuffer) {
+ dsbuffer->lpVtbl->Stop(dsbuffer);
+ dsbuffer->lpVtbl->Release(dsbuffer);
+ RCT2_ADDRESS(RCT2_ADDRESS_DSOUND_BUFFERS, LPDIRECTSOUNDBUFFER)[channel] = 0;
+ }
+ _InterlockedExchange(&RCT2_GLOBAL(0x009E1AAC, LONG), 0);
+ return 1;
+}
+
/**
*
* rct2: 0x006BABD8
*/
-void unpause_sounds() {
+void unpause_sounds()
+{
RCT2_GLOBAL(0x009AF59C, uint8)--;
g_sounds_disabled = 0;
}
\ No newline at end of file
diff --git a/src/audio.h b/src/audio.h
index e40b1416f3..6da01639df 100644
--- a/src/audio.h
+++ b/src/audio.h
@@ -21,6 +21,8 @@
#ifndef _AUDIO_H_
#define _AUDIO_H_
+#include "rct2.h"
+
typedef struct {
char name[256];
} audio_device;
@@ -31,7 +33,7 @@ extern audio_device *gAudioDevices;
void audio_init();
void audio_quit();
void audio_get_devices();
-
+void audio_init2(int device);
#include
@@ -55,10 +57,76 @@ typedef struct rct_sound {
struct rct_sound* next;
} rct_sound;
-void get_dsound_devices();
-int sound_prepare(int sound_id, rct_sound *sound, int var_8, int var_c);
-void sound_play_panned(int sound_id, int x);
+typedef struct {
+ uint16 var_0;
+ uint16 channels;
+ uint32 samples;
+ uint32 var_8;
+ uint16 bytes;
+ uint16 bits;
+ uint16 var_E;
+} rct_audio_info;
+
+typedef struct {
+ uint32 var_0;
+ uint32 var_4;
+ char filename[0x108]; // 0x8
+ uint32 var_110;
+ uint32 var_114;
+ uint32 var_118;
+ HGLOBAL hmem; // 0x11C
+ HMMIO hmmio; // 0x120
+ MMCKINFO mmckinfo1; // 0x124
+ MMCKINFO mmckinfo2; // 0x138
+ LPDIRECTSOUNDBUFFER dsbuffer; // 0x14C
+ uint32 var_150;
+ uint32 playpos; // 0x154
+ uint32 var_158;
+ uint32 var_15C;
+ uint32 var_160;
+ uint32 var_164;
+ uint32 var_168;
+} rct_sound_channel;
+
+typedef struct {
+ uint32 size;
+ WAVEFORMATEX format;
+ char* data;
+} rct_sound_info;
+
+typedef struct {
+ uint16 id;
+ uint16 var_2;
+ rct_sound sound1; // 0x04
+ uint16 var_18;
+ uint8 pad_1A[0x06];
+ rct_sound sound2; // 0x20
+ uint16 var_34;
+ uint8 pad_36[0x06];
+} rct_vehicle_sound;
+
+typedef struct {
+ uint16 id;
+ rct_sound sound;
+} rct_other_sound;
+
+int get_dsound_devices();
+int dsound_create_primary_buffer(int a, int device, int channels, int samples, int bits);
+void audio_timefunc(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2, int channel);
+int audio_release();
+MMRESULT mmio_read(HMMIO hmmio, uint32 size, char* buffer, LPMMCKINFO mmckinfo, int* read);
+MMRESULT mmio_seek(HMMIO* hmmio, LPMMCKINFO mmckinfo1, LPMMCKINFO mmckinfo2, int offset);
+MMRESULT mmio_open(char* filename, HMMIO* hmmio, HGLOBAL* hmem, LPMMCKINFO mmckinfo);
+int sub_40153B(int channel);
+int sub_4015E7(int channel);
+int audio_remove_timer();
+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 x);
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);
int sound_set_pan(rct_sound* sound, int pan);
int sound_set_volume(rct_sound* sound, int volume);
@@ -66,9 +134,22 @@ int sound_channel_play(int channel, int a2, int volume, int pan, int frequency);
int sound_channel_set_frequency(int channel, int frequency);
int sound_channel_set_pan(int channel, int pan);
int sound_channel_set_volume(int channel, int volume);
-void sound_stop(rct_sound *sound);
+int sound_channel_load_file(int channel, char* filename, int offset);
+void sound_channel_free(HMMIO* hmmio, HGLOBAL* hmem);
+int sound_stop(rct_sound *sound);
+int sound_stop_all();
+int unmap_file(LPCVOID base);
+int sound_channel_stop(int channel);
+rct_sound* sound_add(rct_sound* sound);
rct_sound* sound_remove(rct_sound* sound);
+rct_sound* sound_begin();
+rct_sound* sound_next(rct_sound* sound);
void pause_sounds();
+void stop_other_sounds();
+void stop_vehicle_sounds();
+void stop_ride_music();
+void stop_peep_sounds();
+void stop_title_music();
void unpause_sounds();
// 0x009AF59C probably does the same job
diff --git a/src/award.c b/src/award.c
index 13b54ef5eb..e8449a55b3 100644
--- a/src/award.c
+++ b/src/award.c
@@ -155,7 +155,7 @@ static int award_is_deserved_best_value(int awardType, int activeAwardTypes)
return 0;
if (activeAwardTypes & (1 << PARK_AWARD_MOST_DISAPPOINTING))
return 0;
- if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & (PARK_FLAGS_11 | PARK_FLAGS_PARK_FREE_ENTRY))
+ if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & (PARK_FLAGS_NO_MONEY | PARK_FLAGS_PARK_FREE_ENTRY))
return 0;
if (RCT2_GLOBAL(RCT2_TOTAL_RIDE_VALUE, money16) < MONEY(10, 00))
return 0;
@@ -205,7 +205,7 @@ static int award_is_deserved_worse_value(int awardType, int activeAwardTypes)
{
if (activeAwardTypes & (1 << PARK_AWARD_BEST_VALUE))
return 0;
- if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_11)
+ if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY)
return 0;
if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_ENTRANCE_FEE, money16) == MONEY(0, 00))
return 0;
diff --git a/src/climate.c b/src/climate.c
index 5f1bf8902b..af633917fa 100644
--- a/src/climate.c
+++ b/src/climate.c
@@ -186,7 +186,7 @@ static void climate_determine_future_weather()
*/
void climate_update_sound()
{
- if (RCT2_GLOBAL(0x009AF280, uint32) == 0xFFFFFFFF)
+ if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, uint32) == 0xFFFFFFFF)
return;
if (RCT2_GLOBAL(0x009AF59C, uint8) != 0)
return;
@@ -210,13 +210,13 @@ static void climate_update_rain_sound()
} else {
// Increase rain sound
_rainVolume = min(-1400, _rainVolume + 80);
- RCT2_CALLPROC_2(0x00404F0D, rct_sound*, int, &_rainSoundInstance, _rainVolume);
+ sound_set_volume(&_rainSoundInstance, _rainVolume);
}
} else if (_rainVolume != 1) {
// Decrease rain sound
_rainVolume -= 80;
if (_rainVolume > -4000) {
- RCT2_CALLPROC_2(0x00404F0D, rct_sound*, int, &_rainSoundInstance, _rainVolume);
+ sound_set_volume(&_rainSoundInstance, _rainVolume);
} else {
sound_stop(&_rainSoundInstance);
_rainVolume = 1;
@@ -248,7 +248,7 @@ static void climate_update_thunder_sound()
if (_thunderStatus[i] == THUNDER_STATUS_NULL)
continue;
- if (!RCT2_CALLFUNC_1(0x00404E53, int, rct_sound*, &_thunderSoundInstance[i])) {
+ if (!sound_is_playing(&_thunderSoundInstance[i])) {
sound_stop(&_thunderSoundInstance[i]);
_thunderStatus[i] = THUNDER_STATUS_NULL;
}
diff --git a/src/finance.c b/src/finance.c
index 13144c338a..efedfdff63 100644
--- a/src/finance.c
+++ b/src/finance.c
@@ -57,7 +57,7 @@ void finance_payment(money32 amount, rct_expenditure_type type)
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint32) = ENCRYPT_MONEY(new_money);
RCT2_ADDRESS(RCT2_ADDRESS_EXPENDITURE_TABLE, money32)[type] -= amount;
if (RCT2_ADDRESS(0x00988E60, uint32)[type] & 1)
- RCT2_GLOBAL(0x0135832C, money32) -= amount;
+ RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_EXPENDITURE, money32) -= amount; // Cumulative amount of money spent this day
RCT2_GLOBAL(0x009A9804, uint32) |= 1; // money diry flag
@@ -74,7 +74,7 @@ void finance_pay_wages()
rct_peep* peep;
uint16 spriteIndex;
- if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_11)
+ if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY)
return;
FOR_ALL_STAFF(spriteIndex, peep)
@@ -89,7 +89,7 @@ void finance_pay_research()
{
uint8 level;
- if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & 0x800)
+ if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY)
return;
level = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_RESEARCH_LEVEL, uint8);
@@ -106,7 +106,7 @@ void finance_pay_interest()
sint16 current_interest = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_INTEREST_RATE, sint16);
money32 tempcost = (current_loan * 5 * current_interest) >> 14; // (5 * interest) / 2^14 is pretty close to
- if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & 0x800)
+ if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY)
return;
finance_payment(tempcost, RCT_EXPENDITURE_TYPE_INTEREST);
@@ -127,7 +127,7 @@ void finance_pay_ride_upkeep()
ride->var_196 = 25855; // durability?
}
- if (ride->status != RIDE_STATUS_CLOSED && !(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & 0x800)) {
+ if (ride->status != RIDE_STATUS_CLOSED && !(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY)) {
sint16 upkeep = ride->upkeep_cost;
if (upkeep != -1) {
ride->var_154 -= upkeep;
@@ -158,11 +158,10 @@ void finance_init() {
RCT2_ADDRESS(RCT2_ADDRESS_EXPENDITURE_TABLE, money32)[i] = 0;
}
- RCT2_GLOBAL(0x0135832C, uint32) = 0;
-
+ RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_EXPENDITURE, uint32) = 0;
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32) = 0;
- RCT2_GLOBAL(0x01358334, uint32) = 0;
+ RCT2_GLOBAL(0x01358334, money32) = 0;
RCT2_GLOBAL(0x01358338, uint16) = 0;
RCT2_GLOBAL(0x013573DC, money32) = MONEY(10000,00); // Cheat detection
@@ -185,6 +184,58 @@ void finance_init() {
sub_69E869();
}
+/**
+*
+* rct2: 0x0069E79A
+*/
+void finance_update_daily_profit()
+{
+ RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32) = 7 * RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_EXPENDITURE, money32);
+ RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_EXPENDITURE, money32) = 0; // Reset daily expenditure
+
+ money32 current_profit = 0;
+
+ if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY))
+ {
+ // Staff costs
+ uint16 sprite_index;
+ rct_peep *peep;
+
+ FOR_ALL_STAFF(sprite_index, peep) {
+ uint8 staff_type = peep->staff_type;
+ current_profit -= wage_table[peep->staff_type];
+ }
+
+ // Research costs
+ uint8 level = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_RESEARCH_LEVEL, uint8);
+ current_profit -= research_cost_table[level];
+
+ // Loan costs
+ money32 current_loan = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, money32);
+ current_profit -= current_loan / 600;
+
+ // Ride costs
+ rct_ride *ride;
+ int i;
+ FOR_ALL_RIDES(i, ride) {
+ if (ride->status != RIDE_STATUS_CLOSED && ride->upkeep_cost != -1) {
+ current_profit -= 2 * ride->upkeep_cost;
+ }
+ }
+ }
+
+ // This is not equivalent to / 4 due to rounding of negative numbers
+ current_profit = current_profit >> 2;
+
+ RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32) += current_profit;
+
+ // These are related to weekly profit graph
+ RCT2_GLOBAL(0x1358334, money32) += RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32);
+ RCT2_GLOBAL(0x1358338, uint16) += 1;
+
+ window_invalidate_by_id(WC_FINANCES, 0);
+}
+
void sub_69E869()
{
// This subroutine is loan related and is used for cheat detection
diff --git a/src/finance.h b/src/finance.h
index 02e0dc6aab..e839dd3914 100644
--- a/src/finance.h
+++ b/src/finance.h
@@ -41,6 +41,7 @@ void finance_pay_interest();
void finance_pay_ride_upkeep();
void finance_reset_history();
void finance_init();
+void finance_update_daily_profit();
void sub_69E869();
#endif
\ No newline at end of file
diff --git a/src/game.c b/src/game.c
index 1bafb3d29e..30f4df92b1 100644
--- a/src/game.c
+++ b/src/game.c
@@ -29,6 +29,7 @@
#include "news_item.h"
#include "object.h"
#include "osinterface.h"
+#include "park.h"
#include "peep.h"
#include "sawyercoding.h"
#include "scenario.h"
@@ -388,6 +389,8 @@ void game_logic_update()
news_item_update_current();
RCT2_CALLPROC_EBPSAFE(0x0067009A); // scenario editor opening of windows for a phase
+ RCT2_CALLPROC_EBPSAFE(0x006BB991); // removes other sounds that are no longer playing, this is normally called somewhere in rct2_init
+
// Update windows
window_dispatch_update_all();
@@ -940,7 +943,7 @@ static uint32 game_do_command_table[58] = {
0x006666E7,
0x00666A63,
0x006CD8CE,
- 0x00669E30,
+ (uint32)game_command_set_park_entrance_fee,
(uint32)game_command_update_staff_colour, // 40
0x006E519A,
0x006E5597,
diff --git a/src/game.h b/src/game.h
index 0e1a95035b..1f87d944c0 100644
--- a/src/game.h
+++ b/src/game.h
@@ -54,7 +54,7 @@ enum GAME_COMMAND {
GAME_COMMAND_HIRE_NEW_STAFF_MEMBER, // 29
GAME_COMMAND_30,
GAME_COMMAND_31,
- GAME_COMMAND_32,
+ GAME_COMMAND_SET_STAFF_ORDER,
GAME_COMMAND_33,
GAME_COMMAND_SET_PARK_OPEN, // 34
GAME_COMMAND_35,
diff --git a/src/gfx.c b/src/gfx.c
index 6e771560a4..fae14f1a7e 100644
--- a/src/gfx.c
+++ b/src/gfx.c
@@ -2276,7 +2276,7 @@ rct_drawpixelinfo* clip_drawpixelinfo(rct_drawpixelinfo* dpi, int left, int widt
}
int stickOutWidth = newDrawPixelInfo->x + newDrawPixelInfo->width - right;
- if (stickOutWidth < 0) {
+ if (stickOutWidth > 0) {
newDrawPixelInfo->width -= stickOutWidth;
newDrawPixelInfo->pitch += stickOutWidth;
}
@@ -2290,7 +2290,7 @@ rct_drawpixelinfo* clip_drawpixelinfo(rct_drawpixelinfo* dpi, int left, int widt
}
int bp = newDrawPixelInfo->y + newDrawPixelInfo->height - bottom;
- if (bp < 0) {
+ if (bp > 0) {
newDrawPixelInfo->height -= bp;
}
diff --git a/src/input.c b/src/input.c
index 1d10cc4e05..725b6e9eb9 100644
--- a/src/input.c
+++ b/src/input.c
@@ -36,6 +36,13 @@
POINT _dragPosition;
+typedef struct {
+ uint32 x, y;
+ uint32 state; //1 = LeftDown 2 = LeftUp 3 = RightDown 4 = RightUp
+} rct_mouse_data;
+
+rct_mouse_data* mouse_buffer = RCT2_ADDRESS(RCT2_ADDRESS_INPUT_QUEUE, rct_mouse_data);
+
static void game_get_next_input(int *x, int *y, int *state);
static void input_mouseover(int x, int y, rct_window *w, int widgetIndex);
static void input_mouseover_widget_check(rct_windowclass windowClass, rct_windownumber windowNumber, int widgetIndex);
@@ -43,6 +50,7 @@ static void input_mouseover_widget_flatbutton_invalidate();
void process_mouse_over(int x, int y);
void sub_6ED801(int x, int y);
void invalidate_scroll();
+static rct_mouse_data* get_mouse_input();
#pragma region Scroll bar input
@@ -522,11 +530,8 @@ static void input_leftmousedown(int x, int y, rct_window *w, int widgetIndex)
}
break;
default:
- // comment check as it disables the rotate station/building button in construction window
-// if (!widget_is_enabled(w, widgetIndex))
-// break;
- if (widget_is_disabled(w, widgetIndex))
- break;
+ if (!widget_is_enabled(w, widgetIndex))
+ break;
sound_play_panned(SOUND_CLICK_1, w->x + (widget->left + widget->right) / 2);
@@ -1298,7 +1303,7 @@ void handle_shortcut_command(int shortcutIndex)
break;
case SHORTCUT_SHOW_FINANCIAL_INFORMATION:
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C))
- if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & 0x800))
+ if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY))
window_finances_open();
break;
case SHORTCUT_SHOW_RESEARCH_INFORMATION:
@@ -1557,18 +1562,17 @@ void game_handle_input()
*/
static void game_get_next_input(int *x, int *y, int *state)
{
- int eax, ebx, ecx, edx, esi, edi, ebp;
- RCT2_CALLFUNC_X(0x00407074, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
- if (eax == 0) {
+ rct_mouse_data* eax = get_mouse_input();
+ if (eax == NULL) {
*x = gCursorState.x;
*y = gCursorState.y;
*state = 0;
return;
}
- *x = RCT2_GLOBAL(eax + 0, sint32);
- *y = RCT2_GLOBAL(eax + 4, sint32);
- *state = RCT2_GLOBAL(eax + 8, sint32);
+ *x = eax->x;
+ *y = eax->y;
+ *state = eax->state;
//int eax, ebx, ecx, edx, esi, edi, ebp;
//RCT2_CALLFUNC_X(0x006E83C7, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
@@ -1762,4 +1766,40 @@ void invalidate_scroll()
wind->scrolls[scroll_id / sizeof(rct_scroll)].flags &= 0xFF11;
window_invalidate_by_id(RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, uint8), RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, uint16));
-}
\ No newline at end of file
+}
+
+/**
+* rct2: 0x00406C96
+*/
+void store_mouse_input(int state)
+{
+ uint32 write_index = RCT2_GLOBAL(RCT2_ADDRESS_MOUSE_WRITE_INDEX, uint32);
+ uint32 next_write_index = (write_index + 1) % 64;
+
+ // check if the queue is full
+ if (next_write_index == RCT2_GLOBAL(RCT2_ADDRESS_MOUSE_READ_INDEX, uint32))
+ return;
+
+ rct_mouse_data* item = &mouse_buffer[write_index];
+ item->x = RCT2_GLOBAL(0x01424318, uint32);
+ item->y = RCT2_GLOBAL(0x0142431C, uint32);
+ item->state = state;
+
+ RCT2_GLOBAL(RCT2_ADDRESS_MOUSE_WRITE_INDEX, uint32) = next_write_index;
+}
+
+
+/**
+ * rct2: 0x00407074
+ */
+static rct_mouse_data* get_mouse_input()
+{
+ uint32 read_index = RCT2_GLOBAL(RCT2_ADDRESS_MOUSE_READ_INDEX, uint32);
+
+ // check if that location has been written to yet
+ if (read_index == RCT2_GLOBAL(RCT2_ADDRESS_MOUSE_WRITE_INDEX, uint32))
+ return NULL;
+
+ RCT2_GLOBAL(RCT2_ADDRESS_MOUSE_READ_INDEX, uint32) = (read_index + 1) % 64;
+ return &mouse_buffer[read_index];
+}
diff --git a/src/input.h b/src/input.h
index a7a1d8ebb6..dd1cc5b3fb 100644
--- a/src/input.h
+++ b/src/input.h
@@ -24,4 +24,6 @@
void game_handle_input();
void game_handle_keyboard_input();
+void store_mouse_input(int state);
+
#endif
\ No newline at end of file
diff --git a/src/intro.c b/src/intro.c
index 75f3c853cb..8b2ee2fdba 100644
--- a/src/intro.c
+++ b/src/intro.c
@@ -80,7 +80,7 @@ void intro_update()
// Chain lift sound
_sound_playing_flag = 0;
- if (RCT2_GLOBAL(0x009AF280, sint32) != -1) {
+ if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, sint32) != -1) {
// Prepare and play the sound
if (sound_prepare(SOUND_LIFT_7, &_prepared_sound, 0, 1))
if (sound_play(&_prepared_sound, 1, 0, 0, 0))
@@ -157,7 +157,7 @@ void intro_update()
}
// Play the track friction sound
- if (RCT2_GLOBAL(0x009AF280, sint32) != -1) {
+ if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, sint32) != -1) {
// Prepare and play the sound
if (sound_prepare(SOUND_TRACK_FRICTION_3, &_prepared_sound, 1, 1))
if (sound_play(&_prepared_sound, 1, -800, 0, 0x3A98))
@@ -188,7 +188,7 @@ void intro_update()
}
// Play long peep scream sound
- if (RCT2_GLOBAL(0x009AF280, sint32) != -1)
+ if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, sint32) != -1)
if (sound_prepare(SOUND_SCREAM_1, &_prepared_sound, 0, 1))
if (sound_play(&_prepared_sound, 0, 0, 0, 0))
_sound_playing_flag = 1;
diff --git a/src/news_item.c b/src/news_item.c
index e2053594e5..986502d1fe 100644
--- a/src/news_item.c
+++ b/src/news_item.c
@@ -264,7 +264,7 @@ void news_item_add_to_queue(uint8 type, rct_string_id string_id, uint32 assoc)
newsItem->assoc = assoc;
newsItem->ticks = 0;
newsItem->month_year = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, uint16);
- newsItem->day = (days_in_month[(newsItem->month_year & 7)] * RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16)) >> 16;
+ newsItem->day = ((days_in_month[(newsItem->month_year & 7)] * RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16)) >> 16) + 1;
format_string((char*)0x0141EF68, string_id, (void*)0x013CE952); // overflows possible?
newsItem->colour = ((char*)0x0141EF68)[0];
diff --git a/src/osinterface.c b/src/osinterface.c
index c86a3f792c..fd6aef4b17 100644
--- a/src/osinterface.c
+++ b/src/osinterface.c
@@ -28,6 +28,7 @@
#include "addresses.h"
#include "config.h"
#include "gfx.h"
+#include "input.h"
#include "osinterface.h"
#include "screenshot.h"
#include "window.h"
@@ -44,7 +45,6 @@ unsigned int gLastKeyPressed;
static void osinterface_create_window();
static void osinterface_close_window();
static void osinterface_resize(int width, int height);
-static void sub_406C96(int actionType);
static SDL_Window *_window;
static SDL_Surface *_surface;
@@ -350,7 +350,7 @@ void osinterface_process_messages()
RCT2_GLOBAL(0x0142431C, int) = e.button.y;
switch (e.button.button) {
case SDL_BUTTON_LEFT:
- sub_406C96(1); //RCT2_CALLPROC_1(0x00406C96, int, 1);
+ store_mouse_input(1);
gCursorState.left = CURSOR_PRESSED;
gCursorState.old = 1;
break;
@@ -358,7 +358,7 @@ void osinterface_process_messages()
gCursorState.middle = CURSOR_PRESSED;
break;
case SDL_BUTTON_RIGHT:
- sub_406C96(3); //RCT2_CALLPROC_1(0x00406C96, int, 3);
+ store_mouse_input(3);
gCursorState.right = CURSOR_PRESSED;
gCursorState.old = 2;
break;
@@ -369,7 +369,7 @@ void osinterface_process_messages()
RCT2_GLOBAL(0x0142431C, int) = e.button.y;
switch (e.button.button) {
case SDL_BUTTON_LEFT:
- sub_406C96(2); //RCT2_CALLPROC_1(0x00406C96, int, 2);
+ store_mouse_input(2);
gCursorState.left = CURSOR_RELEASED;
gCursorState.old = 3;
break;
@@ -377,7 +377,7 @@ void osinterface_process_messages()
gCursorState.middle = CURSOR_RELEASED;
break;
case SDL_BUTTON_RIGHT:
- sub_406C96(4); //RCT2_CALLPROC_1(0x00406C96, int, 4);
+ store_mouse_input(4);
gCursorState.right = CURSOR_RELEASED;
gCursorState.old = 4;
break;
@@ -452,6 +452,7 @@ int osinterface_open_common_file_dialog(int type, char *title, char *filename, c
OPENFILENAME openFileName;
BOOL result;
int tmp;
+ DWORD commonFlags;
// Get directory path from given filename
strcpy(initialDirectory, filename);
@@ -488,7 +489,7 @@ int osinterface_open_common_file_dialog(int type, char *title, char *filename, c
RCT2_GLOBAL(0x009E2C74, uint32) = 1;
// Open dialog
- DWORD commonFlags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_NOCHANGEDIR;
+ commonFlags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_NOCHANGEDIR;
if (type == 0) {
openFileName.Flags = commonFlags | OFN_CREATEPROMPT | OFN_OVERWRITEPROMPT;
result = GetSaveFileName(&openFileName);
@@ -596,24 +597,4 @@ int osinterface_ensure_directory_exists(const char *path)
char osinterface_get_path_separator()
{
return '\\';
-}
-
-void sub_406C96(int actionType)
-{
- int eax = RCT2_GLOBAL(0x009E2DE4, uint32);
- int ecx = eax + 1;
- ecx &= 0x3F; //Array of 64 point structs, loop around buffer?
- if (ecx != RCT2_GLOBAL(0x009E2DE8, uint32)) {
- int edx = RCT2_GLOBAL(0x01424318, uint32); // X
- //eax is a struct index here. Mutliplied by then and then 4 for the struct with 3 4 byte fields
- //Struct is {int x, int y, int actionType}
- eax = eax + eax*2;
- eax = 0x01424340 + eax * 4; //get base of struct, address is base of array
- *((uint32*)eax) = edx;
- edx = RCT2_GLOBAL(0x0142431C, uint32); // Y
- *((uint32*)eax + 1) = edx;
- edx = actionType;
- *((uint32*)eax + 2) = edx;
- RCT2_GLOBAL(0x009E2DE4, uint32) = ecx;
- }
-}
+}
\ No newline at end of file
diff --git a/src/park.c b/src/park.c
index 1779458712..3621c3db7f 100644
--- a/src/park.c
+++ b/src/park.c
@@ -90,7 +90,7 @@ void park_init()
RCT2_GLOBAL(RCT2_ADDRESS_PARK_ENTRANCE_FEE, money16) = MONEY(10, 00);
RCT2_GLOBAL(RCT2_ADDRESS_PEEP_SPAWNS, sint16) = -1;
RCT2_GLOBAL(0x013573F8, sint16) = -1;
- RCT2_GLOBAL(0x01357CF2, uint16) = 127;
+ RCT2_GLOBAL(RCT2_ADDRESS_ACTIVE_RESEARCH_TYPES, uint16) = 127;
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_RESEARCH_LEVEL, uint8) = 2;
RCT2_GLOBAL(RCT2_ADDRESS_GUEST_INITIAL_CASH, uint16) = MONEY(50,00); // Cash per guest (average)
@@ -103,7 +103,7 @@ void park_init()
RCT2_GLOBAL(RCT2_ADDRESS_LAND_COST, uint16) = MONEY(90, 00);
RCT2_GLOBAL(RCT2_ADDRESS_CONSTRUCTION_RIGHTS_COST, uint16) = MONEY(40,00);
RCT2_GLOBAL(0x01358774, uint16) = 0;
- RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) = PARK_FLAGS_11 | PARK_FLAGS_SHOW_REAL_GUEST_NAMES;
+ RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) = PARK_FLAGS_NO_MONEY | PARK_FLAGS_SHOW_REAL_GUEST_NAMES;
park_reset_history();
finance_reset_history();
award_reset();
@@ -427,7 +427,7 @@ static int park_calculate_guest_generation_probability()
probability /= 4;
// Check if money is enabled
- if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_11)) {
+ if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY)) {
// Penalty for overpriced entrance fee relative to total ride value
money16 entranceFee = RCT2_GLOBAL(RCT2_ADDRESS_PARK_ENTRANCE_FEE, money16);
if (entranceFee > totalRideValue) {
@@ -581,4 +581,40 @@ uint8 calculate_guest_initial_happiness(uint8 percentage) {
void park_update_histories()
{
RCT2_CALLPROC_EBPSAFE(0x0066A231);
+}
+
+/**
+*
+* rct2: 0x00669E30
+*/
+void game_command_set_park_entrance_fee()
+{
+ uint8 _bl;
+ uint16 new_fee;
+
+ #ifdef _MSC_VER
+ __asm mov _bl, bl
+ #else
+ __asm__("mov %[_bl], bl " : [_bl] "+m" (_bl));
+ #endif
+
+ #ifdef _MSC_VER
+ __asm mov new_fee, di
+ #else
+ __asm__("mov %[new_fee], di " : [new_fee] "+m" (new_fee));
+ #endif
+
+ RCT2_GLOBAL(0x0141F56C, uint8) = 0x10;
+
+ if (_bl & 1){
+ RCT2_GLOBAL(RCT2_ADDRESS_PARK_ENTRANCE_FEE, uint16) = new_fee;
+
+ window_invalidate_by_id(WC_PARK_INFORMATION, 0);
+ }
+
+ #ifdef _MSC_VER
+ __asm mov ebx, 0
+ #else
+ __asm__("mov ebx, 0 ");
+ #endif
}
\ No newline at end of file
diff --git a/src/park.h b/src/park.h
index bb7d823e86..8a27dfdc8d 100644
--- a/src/park.h
+++ b/src/park.h
@@ -35,11 +35,11 @@ enum {
PARK_FLAGS_PREF_LESS_INTENSE_RIDES = (1 << 6),
PARK_FLAGS_FORBID_MARKETING_CAMPAIGN = (1 << 7),
PARK_FLAGS_PREF_MORE_INTENSE_RIDES = (1 << 8),
- PARK_FLAGS_11 = (1 << 11), // appears to be a copy of PARK_FLAGS_NO_MONEY
+ PARK_FLAGS_NO_MONEY = (1 << 11),
PARK_FLAGS_DIFFICULT_GUEST_GENERATION = (1 << 12),
PARK_FLAGS_PARK_FREE_ENTRY = (1 << 13),
PARK_FLAGS_DIFFICULT_PARK_RATING = (1 << 14),
- PARK_FLAGS_NO_MONEY = (1 << 17),
+ PARK_FLAGS_NO_MONEY_SCENARIO = (1 << 17), // equivalent to PARK_FLAGS_NO_MONEY, but used in scenario editor
PARK_FLAGS_18 = (1 << 18)
};
@@ -59,4 +59,6 @@ void park_update_histories();
uint8 calculate_guest_initial_happiness(uint8 percentage);
+void game_command_set_park_entrance_fee();
+
#endif
diff --git a/src/peep.c b/src/peep.c
index caf4016fde..ea85a117e4 100644
--- a/src/peep.c
+++ b/src/peep.c
@@ -542,6 +542,44 @@ void get_arguments_from_action(rct_peep* peep, uint32 *argument_1, uint32* argum
}
+/**
+* rct2: 0x00698342
+* thought.item (eax)
+* thought.type (ebx)
+* argument_1 (esi & ebx)
+* argument_2 (esi+2)
+*/
+void get_arguments_from_thought(rct_peep_thought thought, uint32* argument_1, uint32* argument_2){
+ int esi = 0x9AC86C;
+
+ if ((RCT2_ADDRESS(0x981DB1, uint16)[thought.type] & 0xFF) & 1){
+ rct_ride* ride = &g_ride_list[thought.item];
+ esi = (int)(&(ride->var_04A));
+ }
+ else if ((RCT2_ADDRESS(0x981DB1, uint16)[thought.type] & 0xFF) & 2){
+ if (thought.item < 0x20){
+ RCT2_GLOBAL(0x9AC86C, uint16) = thought.item + STR_ITEM_START;
+ }
+ else{
+ RCT2_GLOBAL(0x9AC86C, uint16) = thought.item + STR_ITEM2_START;
+ }
+ }
+ else if ((RCT2_ADDRESS(0x981DB1, uint16)[thought.type] & 0xFF) & 4){
+ if (thought.item < 0x20){
+ RCT2_GLOBAL(0x9AC86C, uint16) = thought.item + STR_ITEM_SINGULAR_START;
+ }
+ else
+ {
+ RCT2_GLOBAL(0x9AC86C, uint16) = thought.item + STR_ITEM2_SINGULAR_START;
+ }
+ }
+ else{
+ esi = 0x9AC864; //No thought?
+ }
+ *argument_1 = ((thought.type + STR_THOUGHT_START) & 0xFFFF) | (*((uint16*)esi) << 16);
+ *argument_2 = *((uint32*)(esi + 2)); //Always 0 apart from on rides?
+}
+
/**
* rct2: 0x00698827
* returns 1 on pickup (CF not set)
diff --git a/src/peep.h b/src/peep.h
index 0ee2dc1d6d..3f18e5d587 100644
--- a/src/peep.h
+++ b/src/peep.h
@@ -444,5 +444,6 @@ void peep_update_crowd_noise();
void peep_applause();
rct_peep *peep_generate(int x, int y, int z);
void get_arguments_from_action(rct_peep* peep, uint32 *argument_1, uint32* argument_2);
+void get_arguments_from_thought(rct_peep_thought thought, uint32* argument_1, uint32* argument_2);
#endif
diff --git a/src/rct2.c b/src/rct2.c
index b413820fd9..29572477a3 100644
--- a/src/rct2.c
+++ b/src/rct2.c
@@ -84,7 +84,7 @@ __declspec(dllexport) int StartOpenRCT(HINSTANCE hInstance, HINSTANCE hPrevInsta
audio_init();
audio_get_devices();
- RCT2_CALLPROC(0x0040502E); // get_dsound_devices()
+ get_dsound_devices();
config_init();
language_open(gGeneral_config.language);
rct2_init();
diff --git a/src/scenario.c b/src/scenario.c
index a2884a39d0..9154ce9e81 100644
--- a/src/scenario.c
+++ b/src/scenario.c
@@ -139,10 +139,10 @@ void scenario_load(const char *path)
sawyercoding_read_chunk(file, (uint8*)RCT2_ADDRESS_CURRENT_PARK_RATING);
// Read ?
- sawyercoding_read_chunk(file, (uint8*)0x01357CF2);
+ sawyercoding_read_chunk(file, (uint8*)RCT2_ADDRESS_ACTIVE_RESEARCH_TYPES);
// Read ?
- sawyercoding_read_chunk(file, (uint8*)0x0135832C);
+ sawyercoding_read_chunk(file, (uint8*)RCT2_ADDRESS_CURRENT_EXPENDITURE);
// Read ?
sawyercoding_read_chunk(file, (uint8*)RCT2_ADDRESS_CURRENT_PARK_VALUE);
@@ -226,8 +226,8 @@ void scenario_load_and_play(const rct_scenario_basic *scenario)
RCT2_GLOBAL(0x009DEB7C, sint16) = 0;
RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, sint32) &= 0xFFFFF7FF;
- if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, sint32) & 0x20000)
- RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, sint32) |= 0x800;
+ if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, sint32) & PARK_FLAGS_NO_MONEY_SCENARIO)
+ RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, sint32) |= PARK_FLAGS_NO_MONEY;
RCT2_CALLPROC_EBPSAFE(0x00684AC3);
RCT2_CALLPROC_EBPSAFE(0x006DFEE4);
news_item_init_queue();
@@ -279,9 +279,9 @@ void scenario_load_and_play(const rct_scenario_basic *scenario)
strcat((char*)RCT2_ADDRESS_SAVED_GAMES_PATH_2, ".SV6");
memset((void*)0x001357848, 0, 56);
- RCT2_GLOBAL(0x0135832C, uint32) = 0;
- RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, sint32) = 0;
- RCT2_GLOBAL(0x01358334, uint32) = 0;
+ RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_EXPENDITURE, uint32) = 0;
+ RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32) = 0;
+ RCT2_GLOBAL(0x01358334, money32) = 0;
RCT2_GLOBAL(0x01358338, uint16) = 0;
RCT2_GLOBAL(RCT2_ADDRESS_COMPLETED_COMPANY_VALUE, uint32) = 0x80000000;
RCT2_GLOBAL(RCT2_ADDRESS_TOTAL_ADMISSIONS, uint32) = 0;
@@ -577,7 +577,7 @@ void scenario_update()
if ((current_days_in_month * next_month_tick) >> 16 != (current_days_in_month * month_tick) >> 16) {
// daily checks
- RCT2_CALLPROC_EBPSAFE(0x0069E79A); // daily profit update
+ finance_update_daily_profit(); // daily profit update
RCT2_CALLPROC_EBPSAFE(0x0069C35E); // some kind of peeps days_visited update loop
get_local_time();
RCT2_CALLPROC_EBPSAFE(0x0066A13C); // objective 6 dragging
diff --git a/src/scenario.h b/src/scenario.h
index 4ab1e2d2b2..cbd5b5d764 100644
--- a/src/scenario.h
+++ b/src/scenario.h
@@ -204,8 +204,8 @@ typedef struct {
money32 balance_history[128];
// SC6[11]
- uint32 dword_0135832C;
- uint32 current_profit;
+ money32 current_expenditure;
+ money32 current_profit;
uint32 dword_01358334;
uint16 word_01358338;
uint8 pad_0135833A[2];
diff --git a/src/title.c b/src/title.c
index 79a6aae429..adfb25e080 100644
--- a/src/title.c
+++ b/src/title.c
@@ -22,6 +22,7 @@
#include
#include
#include "addresses.h"
+#include "audio.h"
#include "config.h"
#include "climate.h"
#include "date.h"
@@ -309,7 +310,7 @@ static void title_play_music()
if (!(RCT2_GLOBAL(0x009AF284, uint32) & 1) || !(RCT2_GLOBAL(0x009AF59D, uint8) & 1)) {
if (RCT2_GLOBAL(0x009AF600, uint8) != 0)
- RCT2_CALLPROC_EBPSAFE(0x006BD0BD); // stop music
+ stop_title_music();
return;
}
diff --git a/src/viewport.c b/src/viewport.c
index b5de1c435e..4697b57df3 100644
--- a/src/viewport.c
+++ b/src/viewport.c
@@ -280,7 +280,7 @@ void viewport_update_position(rct_window *window)
if (window->viewport_target_sprite != -1){
rct_sprite* sprite = &g_sprite_list[window->viewport_target_sprite];
- int height = map_element_height(sprite->unknown.x, sprite->unknown.y) - 16;
+ int height = map_element_height(0xFFFF & sprite->unknown.x, 0xFFFF & sprite->unknown.y) - 16;
int underground = sprite->unknown.z < height;
RCT2_CALLPROC_X(0x6E7A15, sprite->unknown.x, sprite->unknown.y, sprite->unknown.z, underground, (int)window, (int)viewport, 0);
diff --git a/src/widget.c b/src/widget.c
index 1006ca3f13..22226cd78f 100644
--- a/src/widget.c
+++ b/src/widget.c
@@ -946,12 +946,12 @@ static void widget_draw_image(rct_drawpixelinfo *dpi, rct_window *w, int widgetI
int widget_is_enabled(rct_window *w, int widgetIndex)
{
- return w->enabled_widgets & (1LL << widgetIndex);
+ return (w->enabled_widgets & (1LL << widgetIndex)) ? 1 : 0;
}
int widget_is_disabled(rct_window *w, int widgetIndex)
{
- return w->disabled_widgets & (1LL << widgetIndex);
+ return (w->disabled_widgets & (1LL << widgetIndex)) ? 1 : 0;
}
int widget_is_pressed(rct_window *w, int widgetIndex)
diff --git a/src/window.c b/src/window.c
index da0de66626..355d5770bf 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1150,7 +1150,7 @@ void window_draw_widgets(rct_window *w, rct_drawpixelinfo *dpi)
if ((w->flags & WF_TRANSPARENT) && !(w->flags & WF_5))
gfx_fill_rect(dpi, w->x, w->y, w->x + w->width - 1, w->y + w->height - 1, 0x2000000 | 51);
- //some code missing here? Between 006EB18C and 006EB260
+ //todo: some code missing here? Between 006EB18C and 006EB260
widgetIndex = 0;
for (widget = w->widgets; widget->type != WWT_LAST; widget++) {
@@ -1162,7 +1162,7 @@ void window_draw_widgets(rct_window *w, rct_drawpixelinfo *dpi)
widgetIndex++;
}
- //something missing here too? Between 006EC32B and 006EC369
+ //todo: something missing here too? Between 006EC32B and 006EC369
if (w->flags & WF_WHITE_BORDER_MASK) {
gfx_fill_rect_inset(dpi, w->x, w->y, w->x + w->width - 1, w->y + w->height - 1, 2, 0x10);
@@ -1495,4 +1495,19 @@ void RCT2_CALLPROC_WE_MOUSE_DOWN(int address, int widgetIndex, rct_window*w, rc
" :[address] "+m" (address), [w] "+m" (w), [widget] "+m" (widget), [widgetIndex] "+m" (widgetIndex): : "eax", "esi", "edx", "edi"
);
#endif
-}
\ No newline at end of file
+}
+
+/* Based on rct2: 0x6987ED and another version from window_park */
+void window_align_tabs( rct_window *w, uint8 start_tab_id, uint8 end_tab_id )
+{
+ int x = w->widgets[start_tab_id].left;
+ int tab_width = w->widgets[start_tab_id].right - w->widgets[start_tab_id].left;
+
+ for (int i = start_tab_id; i < end_tab_id; ++i){
+ if ( !(w->disabled_widgets & (1LL << i)) ){
+ w->widgets[i].left = x;
+ w->widgets[i].right = x + tab_width;
+ x += tab_width + 1;
+ }
+ }
+}
diff --git a/src/window.h b/src/window.h
index f2adce2696..1098eba380 100644
--- a/src/window.h
+++ b/src/window.h
@@ -203,7 +203,7 @@ typedef struct rct_window {
sint16 page; // 0x48A
sint16 var_48C;
sint16 frame_no; // 0x48E updated every tic for motion in windows sprites
- uint16 list_information_type; // 0x490 0 for none
+ uint16 list_information_type; // 0x490 0 for none, Used as current position of marquee in window_peep
sint16 var_492;
uint32 var_494;
uint8 var_498[0x14];
@@ -340,6 +340,7 @@ enum {
WC_PEEP = 23,
WC_GUEST_LIST = 24,
WC_STAFF_LIST = 25,
+ WC_FIRE_PROMPT = 26,
WC_PARK_INFORMATION = 27,
WC_FINANCES = 28,
WC_TITLE_MENU = 29,
@@ -460,6 +461,8 @@ void window_guest_list_init_vars_a();
void window_guest_list_init_vars_b();
void window_bubble_list_item(rct_window* w, int item_position);
+void window_align_tabs( rct_window *w, uint8 start_tab_id, uint8 end_tab_id );
+
void window_new_ride_init_vars();
void window_staff_init_vars();
diff --git a/src/window_about.c b/src/window_about.c
index 6f968ada89..8cf3418380 100644
--- a/src/window_about.c
+++ b/src/window_about.c
@@ -125,10 +125,10 @@ static void window_about_mouseup()
window_close(w);
break;
case WIDX_MUSIC_CREDITS:
- RCT2_CALLPROC_EBPSAFE(0x0066D4EC);
+ RCT2_CALLPROC_EBPSAFE(0x0066D55B);
break;
case WIDX_PUBLISHER_CREDITS:
- RCT2_CALLPROC_EBPSAFE(0x0066D55B);
+ RCT2_CALLPROC_EBPSAFE(0x0066D4EC);
break;
}
}
@@ -193,4 +193,4 @@ static void window_about_paint()
// Licence
gfx_draw_string_left(dpi, STR_LICENSED_TO_INFOGRAMES_INTERACTIVE_INC, 0, 0, w->x + 157, w->y + 257);
-}
\ No newline at end of file
+}
diff --git a/src/window_game_bottom_toolbar.c b/src/window_game_bottom_toolbar.c
index 09bf115fe2..46e983865e 100644
--- a/src/window_game_bottom_toolbar.c
+++ b/src/window_game_bottom_toolbar.c
@@ -160,7 +160,7 @@ static void window_game_bottom_toolbar_mouseup()
switch (widgetIndex) {
case WIDX_LEFT_OUTSET:
case WIDX_MONEY:
- if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & 0x800))
+ if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY))
window_finances_open();
break;
case WIDX_GUESTS:
@@ -316,7 +316,7 @@ static void window_game_bottom_toolbar_invalidate()
}
// Hide money if there is no money
- if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & 0x800) {
+ if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY) {
window_game_bottom_toolbar_widgets[WIDX_MONEY].type = WWT_EMPTY;
window_game_bottom_toolbar_widgets[WIDX_GUESTS].top = 1;
window_game_bottom_toolbar_widgets[WIDX_GUESTS].bottom = 17;
@@ -399,7 +399,7 @@ static void window_game_bottom_toolbar_draw_left_panel(rct_drawpixelinfo *dpi, r
y = window_game_bottom_toolbar_widgets[WIDX_LEFT_OUTSET].top + w->y + 4;
// Draw money
- if (!(RCT2_GLOBAL(0x0013573E4, uint32) & 0x800)) {
+ if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY)) {
RCT2_GLOBAL(0x013CE952, int) = DECRYPT_MONEY(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint32));
gfx_draw_string_centred(
dpi,
diff --git a/src/window_game_top_toolbar.c b/src/window_game_top_toolbar.c
index b7f624a598..4825f55128 100644
--- a/src/window_game_top_toolbar.c
+++ b/src/window_game_top_toolbar.c
@@ -170,6 +170,7 @@ void window_game_top_toolbar_open()
(1 << WIDX_RIDES) |
(1 << WIDX_PARK) |
(1 << WIDX_STAFF) |
+ (1 << WIDX_GUESTS) |
(1 << WIDX_CLEAR_SCENERY) |
(1ULL << WIDX_FASTFORWARD) |
(1ULL << WIDX_RESEARCH);
diff --git a/src/window_guest_list.c b/src/window_guest_list.c
index a5953114be..217e7ebb26 100644
--- a/src/window_guest_list.c
+++ b/src/window_guest_list.c
@@ -135,7 +135,7 @@ static void window_guest_list_find_groups();
static int get_guest_face_sprite_small(rct_peep *peep);
static int get_guest_face_sprite_large(rct_peep *peep);
static void get_arguments_from_peep(rct_peep *peep, uint32 *argument_1, uint32* argument_2);
-void get_arguments_from_thought(rct_peep_thought thought, uint32* argument_1, uint32* argument_2);
+
/**
*
* rct2: 0x006992E3
@@ -730,44 +730,6 @@ static int window_guest_list_is_peep_in_filter(rct_peep* peep)
return 1;
}
-/**
- * rct2: 0x00698342
- * thought.item (eax)
- * thought.type (ebx)
- * argument_1 (esi & ebx)
- * argument_2 (esi+2)
- */
-void get_arguments_from_thought(rct_peep_thought thought, uint32* argument_1, uint32* argument_2){
- int esi = 0x9AC86C;
-
- if ((RCT2_ADDRESS(0x981DB1, uint16)[thought.type] & 0xFF) & 1){
- rct_ride* ride = &g_ride_list[thought.item];
- esi = (int)(&(ride->var_04A));
- }
- else if ((RCT2_ADDRESS(0x981DB1, uint16)[thought.type] & 0xFF) & 2){
- if (thought.item < 0x20){
- RCT2_GLOBAL(0x9AC86C, uint16) = thought.item + STR_ITEM_START;
- }
- else{
- RCT2_GLOBAL(0x9AC86C, uint16) = thought.item + STR_ITEM2_START;
- }
- }
- else if ((RCT2_ADDRESS(0x981DB1, uint16)[thought.type] & 0xFF) & 4){
- if (thought.item < 0x20){
- RCT2_GLOBAL(0x9AC86C, uint16) = thought.item + STR_ITEM_SINGULAR_START;
- }
- else
- {
- RCT2_GLOBAL(0x9AC86C, uint16) = thought.item + STR_ITEM2_SINGULAR_START;
- }
- }
- else{
- esi = 0x9AC864; //No thought?
- }
- *argument_1 = ((thought.type + STR_THOUGHT_START) & 0xFFFF) | (*((uint16*)esi) << 16);
- *argument_2 = *((uint32*)(esi+2)); //Always 0 apart from on rides?
-}
-
/**
* rct2:0x0069B7EA
* Calculates a hash value (arguments) for comparing peep actions/thoughts
diff --git a/src/window_new_campaign.c b/src/window_new_campaign.c
index 16cd807000..efe6ad5afd 100644
--- a/src/window_new_campaign.c
+++ b/src/window_new_campaign.c
@@ -174,7 +174,7 @@ void window_new_campaign_open(sint16 campaignType)
numApplicableRides = 0;
window_new_campaign_rides[0] = 255;
FOR_ALL_RIDES(i, ride) {
- if (!(RCT2_GLOBAL(0x0097CF40 + (ride->type * 8), uint32) & 0x03820000))
+ if (!(RCT2_GLOBAL(RCT2_ADDRESS_RIDE_FLAGS + (ride->type * 8), uint32) & 0x03820000))
window_new_campaign_rides[numApplicableRides++] = i;
}
window_new_campaign_rides[numApplicableRides] = 255;
diff --git a/src/window_new_ride.c b/src/window_new_ride.c
index 296aea59ce..9b061810f0 100644
--- a/src/window_new_ride.c
+++ b/src/window_new_ride.c
@@ -29,7 +29,7 @@
#include "widget.h"
#include "window.h"
-#define _window_new_ride_current_tab RCT2_GLOBAL(0x00F43824, uint8)
+#define _window_new_ride_current_tab RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_RIDE_LIST_SELECTED_TAB, uint8)
typedef struct {
uint8 type;
@@ -374,7 +374,7 @@ static void window_new_ride_scroll_to_focused_ride(rct_window *w)
// Find row index of the focused ride type
rct_widget *listWidget = &window_new_ride_widgets[WIDX_RIDE_LIST];
- int focusRideType = RCT2_ADDRESS(0x00F43825, uint16)[_window_new_ride_current_tab];
+ int focusRideType = RCT2_ADDRESS(RCT2_ADDRESS_WINDOW_RIDE_LIST_HIGHLIGHTED_ITEM, uint16)[_window_new_ride_current_tab];
int count = 0, row = 0;
ride_list_item *listItem = (ride_list_item*)0x00F43523;
while (listItem->type != 255 || listItem->entry_index != 255) {
@@ -436,7 +436,7 @@ void window_new_ride_open()
window_new_ride_populate_list();
- w->new_ride.highlighted_ride_id = RCT2_ADDRESS(0x00F43825, sint16)[_window_new_ride_current_tab];
+ w->new_ride.highlighted_ride_id = RCT2_ADDRESS(RCT2_ADDRESS_WINDOW_RIDE_LIST_HIGHLIGHTED_ITEM, sint16)[_window_new_ride_current_tab];
if (w->new_ride.highlighted_ride_id == -1)
w->new_ride.highlighted_ride_id = RCT2_GLOBAL(0x00F43523, sint16);
@@ -468,7 +468,7 @@ static void window_new_ride_refresh_widget_sizing(rct_window *w)
window_new_ride_widgets[WIDX_CURRENTLY_IN_DEVELOPMENT_GROUP].type = WWT_GROUPBOX;
window_new_ride_widgets[WIDX_LAST_DEVELOPMENT_GROUP].type = WWT_GROUPBOX;
window_new_ride_widgets[WIDX_LAST_DEVELOPMENT_BUTTON].type = WWT_FLATBTN;
- if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_11))
+ if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY))
window_new_ride_widgets[WIDX_RESEARCH_FUNDING_BUTTON].type = WWT_FLATBTN;
width = 300;
@@ -579,7 +579,7 @@ static void window_new_ride_mousedown(int widgetIndex, rct_window *w, rct_widget
w->new_ride.selected_ride_countdown = -1;
window_new_ride_populate_list();
if (page < WINDOW_NEW_RIDE_PAGE_RESEARCH) {
- w->new_ride.highlighted_ride_id = RCT2_ADDRESS(0x00F43825, sint16)[page];
+ w->new_ride.highlighted_ride_id = RCT2_ADDRESS(RCT2_ADDRESS_WINDOW_RIDE_LIST_HIGHLIGHTED_ITEM, sint16)[page];
if (w->new_ride.highlighted_ride_id == -1)
w->new_ride.highlighted_ride_id = RCT2_GLOBAL(0x00F43523, sint16);
}
@@ -654,7 +654,7 @@ static void window_new_ride_scrollmousedown()
if (item.type == 255 && item.entry_index == 255)
return;
- RCT2_ADDRESS(0x00F43825, ride_list_item)[_window_new_ride_current_tab] = item;
+ RCT2_ADDRESS(RCT2_ADDRESS_WINDOW_RIDE_LIST_HIGHLIGHTED_ITEM, ride_list_item)[_window_new_ride_current_tab] = item;
w->new_ride.selected_ride_id = *((sint16*)&item);
sound_play_panned(SOUND_CLICK_1, w->x + (w->width / 2));
@@ -683,7 +683,7 @@ static void window_new_ride_scrollmouseover()
return;
w->new_ride.highlighted_ride_id = *((sint16*)&item);
- RCT2_ADDRESS(0x00F43825, ride_list_item)[_window_new_ride_current_tab] = item;
+ RCT2_ADDRESS(RCT2_ADDRESS_WINDOW_RIDE_LIST_HIGHLIGHTED_ITEM, ride_list_item)[_window_new_ride_current_tab] = item;
window_invalidate(w);
}
@@ -715,7 +715,7 @@ static void window_new_ride_invalidate()
if (_window_new_ride_current_tab == WINDOW_NEW_RIDE_PAGE_RESEARCH) {
window_new_ride_widgets[WIDX_LAST_DEVELOPMENT_BUTTON].type = WWT_EMPTY;
- uint32 typeId = RCT2_GLOBAL(0x01357CF4, uint32);
+ uint32 typeId = RCT2_GLOBAL(RCT2_ADDRESS_LAST_RESEARCHED_ITEM_SUBJECT, uint32);
if (typeId != 0xFFFFFFFF) {
window_new_ride_widgets[WIDX_LAST_DEVELOPMENT_BUTTON].type = WWT_FLATBTN;
window_new_ride_widgets[WIDX_LAST_DEVELOPMENT_BUTTON].image = typeId >= 0x10000 ? 5189 : 5191;
@@ -790,7 +790,7 @@ static void window_new_ride_paint()
x = w->x + 10;
y = w->y + window_new_ride_widgets[WIDX_LAST_DEVELOPMENT_GROUP].top + 12;
- uint32 typeId = RCT2_GLOBAL(0x01357CF4, uint32);
+ uint32 typeId = RCT2_GLOBAL(RCT2_ADDRESS_LAST_RESEARCHED_ITEM_SUBJECT, uint32);
if (typeId != 0xFFFFFFFF) {
if (typeId >= 0x10000) {
rct_ride_type *rideEntry = RCT2_GLOBAL(0x009ACFA4 + (typeId & 0xFF) * 4, rct_ride_type*);
@@ -944,7 +944,7 @@ static void window_new_ride_paint_ride_information(rct_window *w, rct_drawpixeli
}
// Price
- if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_11)) {
+ if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY)) {
// Get price of ride
int unk2 = RCT2_GLOBAL(0x0097CC68 + (item.type * 2), uint8);
money32 price = RCT2_GLOBAL(0x0097DD78 + (item.type * 4), uint16);
diff --git a/src/window_options.c b/src/window_options.c
index 738fe92bdf..926b298c5b 100644
--- a/src/window_options.c
+++ b/src/window_options.c
@@ -230,6 +230,8 @@ void window_options_open()
(1ULL << WIDX_MUSIC_DROPDOWN) |
(1ULL << WIDX_SOUND_QUALITY) |
(1ULL << WIDX_SOUND_QUALITY_DROPDOWN) |
+ (1ULL << WIDX_LANGUAGE) |
+ (1ULL << WIDX_LANGUAGE_DROPDOWN) |
(1ULL << WIDX_CURRENCY) |
(1ULL << WIDX_CURRENCY_DROPDOWN) |
(1ULL << WIDX_DISTANCE) |
@@ -379,7 +381,7 @@ static void window_options_mousedown(int widgetIndex, rct_window*w, rct_widget*
window_options_show_dropdown(w, widget, gAudioDeviceCount);
- gDropdownItemsChecked |= (1 << RCT2_GLOBAL(0x9AF280, uint32));
+ gDropdownItemsChecked |= (1 << RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, uint32));
break;
case WIDX_HEIGHT_LABELS_DROPDOWN:
gDropdownItemsFormat[0] = 1142;
@@ -500,13 +502,15 @@ static void window_options_dropdown()
switch (widgetIndex) {
case WIDX_SOUND_DROPDOWN:
- #ifdef _MSC_VER
+ audio_init2(dropdownIndex);
+ /*#ifdef _MSC_VER
__asm movzx ax, dropdownIndex
#else
__asm__ ( "movzx ax, %[dropdownIndex] " : : [dropdownIndex] "g" ((char)dropdownIndex) );
#endif
// the switch replaces ax value
- RCT2_CALLPROC_EBPSAFE(0x006BA9B5); // part of init audio
+ RCT2_CALLPROC_EBPSAFE(0x006BA9B5); // part of init audio*/
+
window_invalidate(w);
break;
case WIDX_HEIGHT_LABELS_DROPDOWN:
@@ -670,7 +674,7 @@ static void window_options_invalidate()
window_options_widgets[WIDX_HEIGHT_LABELS_DROPDOWN].type = WWT_DROPDOWN_BUTTON;
break;
case WINDOW_OPTIONS_PAGE_AUDIO:
- currentSoundDevice = RCT2_GLOBAL(0x009AF280, sint32);
+ currentSoundDevice = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, sint32);
// sound devices
if (currentSoundDevice == -1 || gAudioDeviceCount == 0) {
diff --git a/src/window_park.c b/src/window_park.c
index 39b982ae1b..f32ecc823c 100644
--- a/src/window_park.c
+++ b/src/window_park.c
@@ -576,9 +576,9 @@ static uint32 window_park_page_enabled_widgets[] = {
static void window_park_init_viewport(rct_window *w);
static void window_park_set_page(rct_window *w, int page);
static void window_park_anchor_border_widgets(rct_window *w);
-static void window_park_align_tabs(rct_window *w);
static void window_park_set_pressed_tab(rct_window *w);
static void window_park_draw_tab_images(rct_drawpixelinfo *dpi, rct_window *w);
+static void window_park_set_disabled_tabs(rct_window *w);
/**
*
@@ -598,7 +598,7 @@ rct_window *window_park_open()
w->list_information_type = -1;
w->var_48C = -1;
w->var_492 = 0;
- RCT2_CALLPROC_X(0x00667F8B, 0, 0, 0, 0, (int)w, 0, 0);
+ window_park_set_disabled_tabs(w);
w->colours[0] = 1;
w->colours[1] = 19;
w->colours[2] = 19;
@@ -606,6 +606,16 @@ rct_window *window_park_open()
return w;
}
+/**
+ *
+ * rct2: 0x00667F8B
+ */
+void window_park_set_disabled_tabs(rct_window *w)
+{
+ // Disable price tab if money is disabled
+ w->disabled_widgets = (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY) ? (1 << WIDX_TAB_4) : 0;
+}
+
#pragma region Entrance page
/**
@@ -916,7 +926,7 @@ static void window_park_entrance_invalidate()
if (RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_TYPE, uint8) == OBJECTIVE_GUESTS_AND_RATING)
w->disabled_widgets |= (1 << WIDX_OPEN_OR_CLOSE);
- window_park_align_tabs(w);
+ window_align_tabs(w, WIDX_TAB_1, WIDX_TAB_7);
window_park_anchor_border_widgets(w);
// Anchor entrance page specific widgets
@@ -1149,7 +1159,7 @@ static void window_park_rating_invalidate()
RCT2_GLOBAL(0x013CE952, uint16) = RCT2_GLOBAL(0x013573D4, uint16);
RCT2_GLOBAL(0x013CE952 + 2, uint32) = RCT2_GLOBAL(0x013573D8, uint32);
- window_park_align_tabs(w);
+ window_align_tabs(w, WIDX_TAB_1, WIDX_TAB_7);
window_park_anchor_border_widgets(w);
}
@@ -1284,7 +1294,7 @@ static void window_park_guests_invalidate()
RCT2_GLOBAL(0x013CE952, uint16) = RCT2_GLOBAL(0x013573D4, uint16);
RCT2_GLOBAL(0x013CE952 + 2, uint32) = RCT2_GLOBAL(0x013573D8, uint32);
- window_park_align_tabs(w);
+ window_align_tabs(w, WIDX_TAB_1, WIDX_TAB_7);
window_park_anchor_border_widgets(w);
}
@@ -1434,7 +1444,7 @@ static void window_park_price_invalidate()
RCT2_GLOBAL(0x013CE952 + 6, uint32) = RCT2_GLOBAL(RCT2_ADDRESS_PARK_ENTRANCE_FEE, uint16);
window_park_price_widgets[WIDX_PRICE].image = RCT2_GLOBAL(RCT2_ADDRESS_PARK_ENTRANCE_FEE, uint16) == 0 ? STR_FREE : 1429;
- window_park_align_tabs(w);
+ window_align_tabs(w, WIDX_TAB_1, WIDX_TAB_7);
window_park_anchor_border_widgets(w);
}
@@ -1543,7 +1553,7 @@ static void window_park_stats_invalidate()
RCT2_GLOBAL(0x013CE952, uint16) = RCT2_GLOBAL(0x013573D4, uint16);
RCT2_GLOBAL(0x013CE952 + 2, uint32) = RCT2_GLOBAL(0x013573D8, uint32);
- window_park_align_tabs(w);
+ window_align_tabs(w, WIDX_TAB_1, WIDX_TAB_7);
window_park_anchor_border_widgets(w);
}
@@ -1705,7 +1715,7 @@ static void window_park_objective_invalidate()
else
window_park_objective_widgets[WIDX_ENTER_NAME].type = WWT_EMPTY;
- window_park_align_tabs(w);
+ window_align_tabs(w, WIDX_TAB_1, WIDX_TAB_7);
window_park_anchor_border_widgets(w);
}
@@ -1852,7 +1862,7 @@ static void window_park_awards_invalidate()
RCT2_GLOBAL(0x013CE952, uint16) = RCT2_GLOBAL(0x013573D4, uint16);
RCT2_GLOBAL(0x013CE952 + 2, uint32) = RCT2_GLOBAL(0x013573D8, uint32);
- window_park_align_tabs(w);
+ window_align_tabs(w, WIDX_TAB_1, WIDX_TAB_7);
window_park_anchor_border_widgets(w);
}
@@ -1925,7 +1935,7 @@ static void window_park_set_page(rct_window *w, int page)
w->var_020 = RCT2_GLOBAL(0x0097BAE0 + (page * 4), uint32);
w->event_handlers = window_park_page_events[page];
w->widgets = window_park_page_widgets[page];
- RCT2_CALLPROC_X(0x00667F8B, 0, 0, 0, 0, (int)w, 0, 0);
+ window_park_set_disabled_tabs(w);
window_invalidate(w);
RCT2_CALLPROC_X(w->event_handlers[WE_RESIZE], 0, 0, 0, 0, (int)w, 0, 0);
@@ -1945,21 +1955,6 @@ static void window_park_anchor_border_widgets(rct_window *w)
w->widgets[WIDX_CLOSE].right = w->width - 3;
}
-static void window_park_align_tabs(rct_window *w)
-{
- int i, x, tab_width;
-
- x = w->widgets[WIDX_TAB_1].left;
- tab_width = w->widgets[WIDX_TAB_1].right - w->widgets[WIDX_TAB_1].left;
- for (i = 0; i < 7; i++) {
- if (w->disabled_widgets & (1LL << (WIDX_TAB_1 + i)))
- continue;
- w->widgets[WIDX_TAB_1 + i].left = x;
- w->widgets[WIDX_TAB_1 + i].right = x + tab_width;
- x += tab_width + 1;
- }
-}
-
static void window_park_set_pressed_tab(rct_window *w)
{
int i;
diff --git a/src/window_peep.c b/src/window_peep.c
index 8c7ef1601a..a85331101c 100644
--- a/src/window_peep.c
+++ b/src/window_peep.c
@@ -58,7 +58,9 @@ enum WINDOW_PEEP_WIDGET_IDX {
WIDX_PICKUP,
WIDX_RENAME,
WIDX_LOCATE,
- WIDX_TRACK
+ WIDX_TRACK,
+
+ WIDX_RIDE_SCROLL = 10
};
void window_peep_emptysub(){};
@@ -77,21 +79,92 @@ rct_widget window_peep_overview_widgets[] = {
{ WWT_12, 1, 3, 166, 45, 56, 0x0FFFFFFFF, STR_NONE}, // Label Thought marquee
{ WWT_VIEWPORT, 1, 3, 166, 57, 143, 0x0FFFFFFFF, STR_NONE }, // Viewport
{ WWT_12, 1, 3, 166, 144, 154, 0x0FFFFFFFF, STR_NONE}, // Label Action
- { WWT_FLATBTN, 1, 167, 190, 45, 68, SPR_RENAME, 1706}, // Pickup Button
- { WWT_FLATBTN, 1, 167, 190, 69, 92, 0x1430, 1055}, // Rename Button
+ { WWT_FLATBTN, 1, 167, 190, 45, 68, 0x1436, 1706}, // Pickup Button
+ { WWT_FLATBTN, 1, 167, 190, 69, 92, SPR_RENAME, 1055}, // Rename Button
{ WWT_FLATBTN, 1, 167, 190, 93, 116, SPR_LOCATE, STR_LOCATE_SUBJECT_TIP},// Locate Button
{ WWT_FLATBTN, 1, 167, 190, 117, 140, SPR_TRACK_PEEP, 1930}, // Track Button
{ WIDGETS_END },
};
+rct_widget window_peep_stats_widgets[] = {
+ {WWT_FRAME, 0, 0, 191, 0, 156, -1, STR_NONE},
+ {WWT_CAPTION, 0, 1, 190, 1, 14, 865, STR_WINDOW_TITLE_TIP},
+ {WWT_CLOSEBOX, 0, 179, 189, 2, 13, 824, STR_CLOSE_WINDOW_TIP},
+ {WWT_RESIZE, 1, 0, 191, 43, 156, -1, STR_NONE},
+ {WWT_TAB, 1, 3, 33, 17, 43, 0x2000144E, 1938},
+ {WWT_TAB, 1, 34, 64, 17, 43, 0x2000144E, 1940},
+ {WWT_TAB, 1, 65, 95, 17, 43, 0x2000144E, 1941},
+ {WWT_TAB, 1, 96, 126, 17, 43, 0x2000144E, 1942},
+ {WWT_TAB, 1, 127, 157, 17, 43, 0x2000144E, 1943},
+ {WWT_TAB, 1, 158, 188, 17, 43, 0x2000144E, 1944},
+ {WIDGETS_END},
+};
+
+rct_widget window_peep_rides_widgets[] = {
+ {WWT_FRAME, 0, 0, 191, 0, 156, -1, STR_NONE},
+ {WWT_CAPTION, 0, 1, 190, 1, 14, 865, STR_WINDOW_TITLE_TIP},
+ {WWT_CLOSEBOX, 0, 179, 189, 2, 13, 824, STR_CLOSE_WINDOW_TIP},
+ {WWT_RESIZE, 1, 0, 191, 43, 156, -1, STR_NONE},
+ {WWT_TAB, 1, 3, 33, 17, 43, 0x2000144E, 1938},
+ {WWT_TAB, 1, 34, 64, 17, 43, 0x2000144E, 1940},
+ {WWT_TAB, 1, 65, 95, 17, 43, 0x2000144E, 1941},
+ {WWT_TAB, 1, 96, 126, 17, 43, 0x2000144E, 1942},
+ {WWT_TAB, 1, 127, 157, 17, 43, 0x2000144E, 1943},
+ {WWT_TAB, 1, 158, 188, 17, 43, 0x2000144E, 1944},
+ {WWT_SCROLL, 1, 3, 188, 57, 143, 2, STR_NONE},
+ {WIDGETS_END},
+};
+
+rct_widget window_peep_finance_widgets[] = {
+ {WWT_FRAME, 0, 0, 191, 0, 156, -1, STR_NONE},
+ {WWT_CAPTION, 0, 1, 190, 1, 14, 865, STR_WINDOW_TITLE_TIP},
+ {WWT_CLOSEBOX, 0, 179, 189, 2, 13, 824, STR_CLOSE_WINDOW_TIP},
+ {WWT_RESIZE, 1, 0, 191, 43, 156, -1, STR_NONE},
+ {WWT_TAB, 1, 3, 33, 17, 43, 0x2000144E, 1938},
+ {WWT_TAB, 1, 34, 64, 17, 43, 0x2000144E, 1940},
+ {WWT_TAB, 1, 65, 95, 17, 43, 0x2000144E, 1941},
+ {WWT_TAB, 1, 96, 126, 17, 43, 0x2000144E, 1942},
+ {WWT_TAB, 1, 127, 157, 17, 43, 0x2000144E, 1943},
+ {WWT_TAB, 1, 158, 188, 17, 43, 0x2000144E, 1944},
+ {WIDGETS_END},
+};
+
+rct_widget window_peep_thoughts_widgets[] = {
+ {WWT_FRAME, 0, 0, 191, 0, 156, -1, STR_NONE},
+ {WWT_CAPTION, 0, 1, 190, 1, 14, 865, STR_WINDOW_TITLE_TIP},
+ {WWT_CLOSEBOX, 0, 179, 189, 2, 13, 824, STR_CLOSE_WINDOW_TIP},
+ {WWT_RESIZE, 1, 0, 191, 43, 156, -1, STR_NONE},
+ {WWT_TAB, 1, 3, 33, 17, 43, 0x2000144E, 1938},
+ {WWT_TAB, 1, 34, 64, 17, 43, 0x2000144E, 1940},
+ {WWT_TAB, 1, 65, 95, 17, 43, 0x2000144E, 1941},
+ {WWT_TAB, 1, 96, 126, 17, 43, 0x2000144E, 1942},
+ {WWT_TAB, 1, 127, 157, 17, 43, 0x2000144E, 1943},
+ {WWT_TAB, 1, 158, 188, 17, 43, 0x2000144E, 1944},
+ {WIDGETS_END},
+};
+
+rct_widget window_peep_inventory_widgets[] = {
+ {WWT_FRAME, 0, 0, 191, 0, 156, -1, STR_NONE},
+ {WWT_CAPTION, 0, 1, 190, 1, 14, 865, STR_WINDOW_TITLE_TIP},
+ {WWT_CLOSEBOX, 0, 179, 189, 2, 13, 824, STR_CLOSE_WINDOW_TIP},
+ {WWT_RESIZE, 1, 0, 191, 43, 156, -1, STR_NONE},
+ {WWT_TAB, 1, 3, 33, 17, 43, 0x2000144E, 1938},
+ {WWT_TAB, 1, 34, 64, 17, 43, 0x2000144E, 1940},
+ {WWT_TAB, 1, 65, 95, 17, 43, 0x2000144E, 1941},
+ {WWT_TAB, 1, 96, 126, 17, 43, 0x2000144E, 1942},
+ {WWT_TAB, 1, 127, 157, 17, 43, 0x2000144E, 1943},
+ {WWT_TAB, 1, 158, 188, 17, 43, 0x2000144E, 1944},
+ {WIDGETS_END},
+};
+
//0x981D0C
rct_widget *window_peep_page_widgets[] = {
window_peep_overview_widgets,
- (rct_widget *)0x9AC45C,
- (rct_widget *)0x9ac500,
- (rct_widget *)0x9ac5b4,
- (rct_widget *)0x9ac658,
- (rct_widget *)0x9ac6FC
+ window_peep_stats_widgets,
+ window_peep_rides_widgets,
+ window_peep_finance_widgets,
+ window_peep_thoughts_widgets,
+ window_peep_inventory_widgets
};
void window_peep_set_page(rct_window* w, int page);
@@ -102,6 +175,8 @@ void window_peep_close();
void window_peep_resize();
void window_peep_overview_mouse_up();
void window_peep_overview_paint();
+void window_peep_overview_invalidate();
+void window_peep_overview_viewport_init_wrapper();
static void* window_peep_overview_events[] = {
window_peep_close,
@@ -124,24 +199,179 @@ static void* window_peep_overview_events[] = {
window_peep_emptysub,
window_peep_emptysub,
(void*)0x696A6A,
- (void*)0x697076,
+ window_peep_overview_viewport_init_wrapper,
window_peep_emptysub,
window_peep_emptysub,
window_peep_emptysub,
window_peep_emptysub,
- (void*)0x696749, //Invalidate
+ window_peep_overview_invalidate, //Invalidate
window_peep_overview_paint, //Paint
- (void*)0x69707C
+ window_peep_emptysub
+};
+
+static void* window_peep_stats_events[] = {
+ window_peep_emptysub,
+ (void*) 0x0069744F, //mouse_up
+ (void*) 0x00697488, //resize
+ window_peep_emptysub,
+ window_peep_emptysub,
+ (void*) 0x006974ED,
+ (void*) 0x0069746A,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ (void*) 0x0069707D, //invalidate
+ (void*) 0x0069711D, //paint
+ window_peep_emptysub
+};
+
+static void* window_peep_rides_events[] = {
+ window_peep_emptysub,
+ (void*) 0x00697795, //mouse_up
+ (void*) 0x006978F4, //resize
+ window_peep_emptysub,
+ window_peep_emptysub,
+ (void*) 0x00697959,
+ (void*) 0x006977B0,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ (void*) 0x0069784E,
+ (void*) 0x006978CC,
+ window_peep_emptysub,
+ (void*) 0x0069789C,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ (void*) 0x00697844,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ (void*) 0x0069757A, //invalidate
+ (void*) 0x00697637, //paint
+ (void*) 0x006976FC
+};
+
+static void* window_peep_finance_events[] = {
+ window_peep_emptysub,
+ (void*) 0x00697BDD, //mouse_up
+ (void*) 0x00697C16, //resize
+ window_peep_emptysub,
+ window_peep_emptysub,
+ (void*) 0x00697C7B,
+ (void*) 0x00697BF8,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ (void*) 0x00697968, //invalidate
+ (void*) 0x00697A08, //paint
+ window_peep_emptysub
+};
+
+static void* window_peep_thoughts_events[] = {
+ window_peep_emptysub,
+ (void*) 0x00697E18, //mouse_up
+ (void*) 0x00697E33, //resize
+ window_peep_emptysub,
+ window_peep_emptysub,
+ (void*) 0x00697ED2,
+ (void*) 0x00697EB4,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ (void*) 0x00697C8A, //invalidate
+ (void*) 0x00697D2A, //paint
+ window_peep_emptysub
+};
+
+static void* window_peep_inventory_events[] = {
+ window_peep_emptysub,
+ (void*) 0x00698279, //mouse_up
+ (void*) 0x00698294, //resize
+ window_peep_emptysub,
+ window_peep_emptysub,
+ (void*) 0x00698333,
+ (void*) 0x00698315,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ window_peep_emptysub,
+ (void*) 0x00697EE1, //invalidate
+ (void*) 0x00697F81, //paint
+ window_peep_emptysub
};
//0x981D24
void* window_peep_page_events[] = {
window_peep_overview_events,
- (void*)0x982468,
- (void*)0x9824d8,
- (void*)0x982548,
- (void*)0x9825b8,
- (void*)0x982628
+ window_peep_stats_events,
+ window_peep_rides_events,
+ window_peep_finance_events,
+ window_peep_thoughts_events,
+ window_peep_inventory_events
};
//0x981D3C
@@ -172,8 +402,8 @@ uint32 window_peep_page_enabled_widgets[] = {
(1 << WIDX_TAB_3) |
(1 << WIDX_TAB_4) |
(1 << WIDX_TAB_5) |
- (1 << WIDX_TAB_6), //|
- //(1 << WIDX_?),
+ (1 << WIDX_TAB_6) |
+ (1 << WIDX_RIDE_SCROLL),
(1 << WIDX_CLOSE) |
(1 << WIDX_TAB_1) |
@@ -270,7 +500,7 @@ void window_peep_disable_widgets(rct_window* w){
if (!(w->disabled_widgets & (1 << WIDX_PICKUP)))
window_invalidate(w);
}
- if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_11){
+ if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY){
disabled_widgets |= (1 << WIDX_TAB_4); //Disable finance tab if no money
}
w->disabled_widgets = disabled_widgets;
@@ -340,7 +570,6 @@ void window_peep_overview_mouse_up(){
window_peep_set_page(w, widgetIndex - WIDX_TAB_1);
break;
case WIDX_PICKUP:
- //696ba6
if (!peep_can_be_picked_up(peep)) {
return;
}
@@ -360,7 +589,6 @@ void window_peep_overview_mouse_up(){
RCT2_CALLPROC_X(0x0069A42F, 0, 0, 0, 0, (int)peep, 0, 0);
break;
case WIDX_RENAME:
- //696e4d
window_show_textinput(w, (int)widgetIndex, 0x5AC, 0x5AD, peep->name_string_idx);
break;
case WIDX_LOCATE:
@@ -415,6 +643,13 @@ void window_peep_set_page(rct_window* w, int page){
if (listen && w->viewport) w->viewport->flags |= VIEWPORT_FLAG_SOUND_ON;
}
+void window_peep_overview_viewport_init_wrapper(){
+ rct_window* w;
+ window_get_register(w);
+
+ window_peep_viewport_init(w);
+}
+
/* rct2: 0x0069883C */
void window_peep_viewport_init(rct_window* w){
if (w->page != WINDOW_PEEP_OVERVIEW) return;
@@ -534,7 +769,156 @@ void window_peep_overview_paint(){
//69861f
//69869b
//698661
+
+ // Draw the viewport no sound sprite
if (w->viewport){
window_draw_viewport(dpi, w);
+ rct_viewport* viewport = w->viewport;
+ if (viewport->flags & VIEWPORT_FLAG_SOUND_ON){
+ gfx_draw_sprite(dpi, SPR_HEARING_VIEWPORT, w->x + 2, w->y + 2, 0);
+ }
}
-}
\ No newline at end of file
+
+ // Draw the centered label
+ uint32 argument1, argument2;
+ rct_peep* peep = GET_PEEP(w->number);
+ get_arguments_from_action(peep, &argument1, &argument2);
+ RCT2_GLOBAL(0x13CE952, uint32) = argument1;
+ RCT2_GLOBAL(0x13CE952 + 4, uint32) = argument2;
+ rct_widget* widget = &w->widgets[WIDX_ACTION_LBL];
+ int x = (widget->left + widget->right) / 2 + w->x;
+ int y = w->y + widget->top - 1;
+ int width = widget->right - widget->left;
+ gfx_draw_string_centred_clipped(dpi, 1191, (void*)0x13CE952, 0, x, y, width);
+
+ // Draw the marquee thought
+ widget = &w->widgets[WIDX_MARQUEE];
+ width = widget->right - widget->left - 3;
+ int left = widget->left + 2 + w->x;
+ int top = widget->top + w->y;
+ int height = widget->bottom - widget->top;
+ rct_drawpixelinfo* dpi_marquee = clip_drawpixelinfo(dpi, left, width, top, height);
+
+ if (!dpi_marquee)return;
+ int i = 0;
+ for (; i < PEEP_MAX_THOUGHTS; ++i){
+ if (peep->thoughts[i].type == PEEP_THOUGHT_TYPE_NONE){
+ w->list_information_type = 0;
+ return;
+ }
+ if (peep->thoughts[i].var_2 == 1){ // If a fresh thought
+ break;
+ }
+ }
+ if (i == PEEP_MAX_THOUGHTS){
+ w->list_information_type = 0;
+ return;
+ }
+
+ get_arguments_from_thought(peep->thoughts[i], &argument1, &argument2);
+
+ RCT2_GLOBAL(0x13CE952, uint32) = argument1;
+ RCT2_GLOBAL(0x13CE952 + 4, uint32) = argument2;
+ RCT2_GLOBAL(0x13CE952 + 8, uint16) = 0;
+
+ x = widget->right - widget->left - w->list_information_type;
+ gfx_draw_string_left(dpi_marquee, 1193, (void*)0x13CE952, 0, x, 0);
+}
+
+/* rct2: 0x696749*/
+void window_peep_overview_invalidate(){
+ rct_window* w;
+ window_get_register(w);
+
+ if (window_peep_page_widgets[w->page] != w->widgets){
+ w->widgets = window_peep_page_widgets[w->page];
+ window_init_scroll_widgets(w);
+ }
+
+ w->pressed_widgets &= ~(WIDX_TAB_1 | WIDX_TAB_2 |WIDX_TAB_3 |WIDX_TAB_4 |WIDX_TAB_5 |WIDX_TAB_6);
+ w->pressed_widgets |= 1ULL << (w->page + WIDX_TAB_1);
+
+ rct_peep* peep = GET_PEEP(w->number);
+ RCT2_GLOBAL(0x13CE952,uint16) = peep->name_string_idx;
+ RCT2_GLOBAL(0x13CE954,uint32) = peep->id;
+
+ w->pressed_widgets &= ~(1<flags & 0x8){
+ w->pressed_widgets |= (1<width - 1;
+ window_peep_overview_widgets[WIDX_BACKGROUND].bottom = w->height - 1;
+
+ window_peep_overview_widgets[WIDX_PAGE_BACKGROUND].right =w->width - 1;
+ window_peep_overview_widgets[WIDX_PAGE_BACKGROUND].bottom = w->height - 1;
+
+ window_peep_overview_widgets[WIDX_TITLE].right = w->width - 2;
+
+ window_peep_overview_widgets[WIDX_CLOSE].left = w->width - 13;
+ window_peep_overview_widgets[WIDX_CLOSE].right = w->width - 3;
+
+ window_peep_overview_widgets[WIDX_VIEWPORT].right = w->width - 26;
+ window_peep_overview_widgets[WIDX_VIEWPORT].bottom = w->height - 14;
+
+ window_peep_overview_widgets[WIDX_ACTION_LBL].top = w->height - 12;
+ window_peep_overview_widgets[WIDX_ACTION_LBL].bottom = w->height - 3;
+ window_peep_overview_widgets[WIDX_ACTION_LBL].right = w->width - 24;
+
+ window_peep_overview_widgets[WIDX_MARQUEE].right = w->width - 24;
+
+ window_peep_overview_widgets[WIDX_PICKUP].right = w->width - 2;
+ window_peep_overview_widgets[WIDX_RENAME].right = w->width - 2;
+ window_peep_overview_widgets[WIDX_LOCATE].right = w->width - 2;
+ window_peep_overview_widgets[WIDX_TRACK].right = w->width - 2;
+
+ window_peep_overview_widgets[WIDX_PICKUP].left = w->width - 25;
+ window_peep_overview_widgets[WIDX_RENAME].left = w->width - 25;
+ window_peep_overview_widgets[WIDX_LOCATE].left = w->width - 25;
+ window_peep_overview_widgets[WIDX_TRACK].left = w->width - 25;
+
+ window_align_tabs(w, WIDX_TAB_1, WIDX_TAB_6);
+}
+
+void window_peep_overview_tab_paint( rct_window* w, rct_drawpixelinfo* dpi){
+
+ if ( w->disabled_widgets & (1ULL<widgets[WIDX_TAB_1].left + 1 + w->x;
+ //cx
+ int y = w->widgets[WIDX_TAB_1].top + 1 + w->y;
+ //bx
+ int width = w->widgets[WIDX_TAB_1].right - 1 - w->widgets[WIDX_TAB_1].left;
+ //dx
+ int height = w->widgets[WIDX_TAB_1].bottom - 1 - w->widgets[WIDX_TAB_1].top;
+
+ if (w->page == WINDOW_PEEP_OVERVIEW){
+ height++;
+ }
+
+ rct_drawpixelinfo* cliped_dpi = clip_drawpixelinfo( dpi, x, width, y, height );
+
+ if (!cliped_dpi) return;
+
+ int cx = 14;
+ int dx = 20;
+
+ //ebp
+ rct_peep* peep = GET_PEEP(w->number);
+
+
+ if (peep->type == 1 && peep->staff_type == 3)
+ dx++;
+ int eax = RCT2_GLOBAL(peep->sprite_type*8 + 0x982708, uint32);
+ int ebx = *(uint32*)eax;
+ ebx++;
+ eax = 0;
+
+ if (w->page == WINDOW_PEEP_OVERVIEW){
+ int ax = *((uint16*)w + 496 / 2);
+ ax &= ~((1<<0)|(1<<1));
+ }
+ ebx += eax;
+ //698474
+}
diff --git a/src/window_research.c b/src/window_research.c
index 0417db1afa..b65fc7dba4 100644
--- a/src/window_research.c
+++ b/src/window_research.c
@@ -310,7 +310,7 @@ static void window_research_development_invalidate()
window_research_set_pressed_tab(w);
window_research_development_widgets[WIDX_LAST_DEVELOPMENT_BUTTON].type = WWT_EMPTY;
- uint32 typeId = RCT2_GLOBAL(0x01357CF4, uint32);
+ uint32 typeId = RCT2_GLOBAL(RCT2_ADDRESS_LAST_RESEARCHED_ITEM_SUBJECT, uint32);
if (typeId != 0xFFFFFFFF) {
window_research_development_widgets[WIDX_LAST_DEVELOPMENT_BUTTON].type = WWT_FLATBTN;
window_research_development_widgets[WIDX_LAST_DEVELOPMENT_BUTTON].image = typeId >= 0x10000 ? 5189 : 5191;
@@ -377,7 +377,7 @@ static void window_research_development_paint()
x = w->x + 10;
y = w->y + window_research_development_widgets[WIDX_LAST_DEVELOPMENT_GROUP].top + 12;
- uint32 typeId = RCT2_GLOBAL(0x01357CF4, uint32);
+ uint32 typeId = RCT2_GLOBAL(RCT2_ADDRESS_LAST_RESEARCHED_ITEM_SUBJECT, uint32);
int lastDevelopmentFormat;
if (typeId != 0xFFFFFFFF) {
if (typeId >= 0x10000) {
diff --git a/src/window_ride.c b/src/window_ride.c
index c0caf24afe..1e52e3361c 100644
--- a/src/window_ride.c
+++ b/src/window_ride.c
@@ -304,6 +304,7 @@ rct_window *window_ride_open(int rideIndex)
ebx++;
}
RCT2_GLOBAL((int)w + 496, uint16) = ebx;
+ return w;
}
/**
@@ -635,4 +636,4 @@ static void window_ride_music_paint()
window_draw_widgets(w, dpi);
}
-#pragma endregion
\ No newline at end of file
+#pragma endregion
diff --git a/src/window_staff.c b/src/window_staff.c
index 650dd10dc7..217b58dc12 100644
--- a/src/window_staff.c
+++ b/src/window_staff.c
@@ -565,7 +565,7 @@ void window_staff_paint() {
rct2_free(sprite_dpi);
}
- if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_11)) {
+ if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY)) {
RCT2_GLOBAL(0x013CE952, uint32) = RCT2_ADDRESS(0x00992A00, uint16)[selectedTab];
gfx_draw_string_left(dpi, 1858, (void*)0x013CE952, 0, w->x + 0xA5, w->y + 0x20);
}
diff --git a/src/window_staff_peep.c b/src/window_staff_peep.c
index 8131d8bab9..555818c920 100644
--- a/src/window_staff_peep.c
+++ b/src/window_staff_peep.c
@@ -50,7 +50,14 @@ enum WINDOW_STAFF_PEEP_WIDGET_IDX {
WIDX_PATROL,
WIDX_RENAME,
WIDX_LOCATE,
- WIDX_FIRE
+ WIDX_FIRE,
+
+ WIDX_CHECKBOX_1 = 0x8,
+ WIDX_CHECKBOX_2,
+ WIDX_CHECKBOX_3,
+ WIDX_CHECKBOX_4,
+
+ WIDX_COSTUME = 0xD,
};
void window_staff_peep_emptysub(){};
@@ -83,18 +90,29 @@ rct_widget *window_staff_peep_page_widgets[] = {
void window_staff_peep_set_page(rct_window* w, int page);
void window_staff_peep_disable_widgets(rct_window* w);
-void window_staff_peep_close();
-void window_staff_peep_mouse_up();
+void window_staff_peep_overview_close();
+void window_staff_peep_overview_mouseup();
+void window_staff_peep_overview_resize();
+void window_staff_peep_overview_mousedown(int widgetIndex, rct_window* w, rct_widget* widget);
+void window_staff_peep_overview_dropdown();
+void window_staff_peep_overview_update(rct_window* w);
+
+void window_staff_peep_orders_mouseup();
+void window_staff_peep_orders_update(rct_window* w);
+
+void window_staff_peep_stats_mouseup();
+void window_staff_peep_stats_resize();
+void window_staff_peep_stats_update(rct_window* w);
// 0x992AEC
static void* window_staff_peep_overview_events[] = {
- window_staff_peep_close,
- window_staff_peep_mouse_up,
- (void*)0x6BE558,
- (void*)0x6BDF98,
- (void*)0x6BDFA3,
+ window_staff_peep_overview_close,
+ window_staff_peep_overview_mouseup,
+ window_staff_peep_overview_resize,
+ window_staff_peep_overview_mousedown,
+ window_staff_peep_overview_dropdown,
window_staff_peep_emptysub,
- (void*)0x6BE602,
+ window_staff_peep_overview_update,
window_staff_peep_emptysub,
window_staff_peep_emptysub,
(void*)0x6BDFD8,
@@ -115,13 +133,77 @@ static void* window_staff_peep_overview_events[] = {
window_staff_peep_emptysub,
(void*)0x6BDD91, //Invalidate
(void*)0x6BDEAF, //Paint
- (void*)0x6BE62A
+ window_staff_peep_emptysub
+};
+
+// 0x992B5C
+static void* window_staff_peep_orders_events[] = {
+ window_staff_peep_emptysub,
+ window_staff_peep_orders_mouseup,
+ window_staff_peep_stats_resize,
+ (void*)0x6BE802,
+ (void*)0x6BE809,
+ (void*)0x6BE9DA,
+ window_staff_peep_orders_update,
+ window_staff_peep_emptysub,
+ window_staff_peep_emptysub,
+ window_staff_peep_emptysub,
+ window_staff_peep_emptysub,
+ window_staff_peep_emptysub,
+ window_staff_peep_emptysub,
+ window_staff_peep_emptysub,
+ window_staff_peep_emptysub,
+ window_staff_peep_emptysub,
+ window_staff_peep_emptysub,
+ window_staff_peep_emptysub,
+ window_staff_peep_emptysub,
+ window_staff_peep_emptysub,
+ window_staff_peep_emptysub,
+ window_staff_peep_emptysub,
+ window_staff_peep_emptysub,
+ window_staff_peep_emptysub,
+ window_staff_peep_emptysub,
+ (void*)0x6BE62B, //Invalidate
+ (void*)0x6BE7C6, //Paint
+ window_staff_peep_emptysub
+};
+
+// 0x992BCC
+static void* window_staff_peep_stats_events[] = {
+ window_staff_peep_emptysub,
+ window_staff_peep_stats_mouseup,
+ window_staff_peep_stats_resize,
+ window_staff_peep_emptysub,
+ window_staff_peep_emptysub,
+ (void*)0x6BEC80,
+ window_staff_peep_stats_update,
+ window_staff_peep_emptysub,
+ window_staff_peep_emptysub,
+ window_staff_peep_emptysub,
+ window_staff_peep_emptysub,
+ window_staff_peep_emptysub,
+ window_staff_peep_emptysub,
+ window_staff_peep_emptysub,
+ window_staff_peep_emptysub,
+ window_staff_peep_emptysub,
+ window_staff_peep_emptysub,
+ window_staff_peep_emptysub,
+ window_staff_peep_emptysub,
+ window_staff_peep_emptysub,
+ window_staff_peep_emptysub,
+ window_staff_peep_emptysub,
+ window_staff_peep_emptysub,
+ window_staff_peep_emptysub,
+ window_staff_peep_emptysub,
+ (void*)0x6BE9E9, //Invalidate
+ (void*)0x6BEA86, //Paint
+ window_staff_peep_emptysub
};
void* window_staff_peep_page_events[] = {
window_staff_peep_overview_events,
- (void*)0x992B5C,
- (void*)0x992BCC
+ window_staff_peep_orders_events,
+ window_staff_peep_stats_events
};
uint32 window_staff_peep_page_enabled_widgets[] = {
@@ -138,7 +220,12 @@ uint32 window_staff_peep_page_enabled_widgets[] = {
(1 << WIDX_CLOSE) |
(1 << WIDX_TAB_1) |
(1 << WIDX_TAB_2) |
- (1 << WIDX_TAB_3),
+ (1 << WIDX_TAB_3) |
+ (1 << WIDX_CHECKBOX_1) |
+ (1 << WIDX_CHECKBOX_2) |
+ (1 << WIDX_CHECKBOX_3) |
+ (1 << WIDX_CHECKBOX_4) |
+ (1 << WIDX_COSTUME),
(1 << WIDX_CLOSE) |
(1 << WIDX_TAB_1) |
@@ -248,7 +335,7 @@ void window_staff_peep_disable_widgets(rct_window* w)
* Same as window_peep_close.
* rct2: 0x006BDFF8
*/
-void window_staff_peep_close()
+void window_staff_peep_overview_close()
{
rct_window* w;
@@ -264,7 +351,28 @@ void window_staff_peep_close()
/** rct2: 0x6C0A77 */
void window_staff_peep_fire(rct_window* w)
{
- RCT2_CALLPROC_X(0x6C0A77, 0, 0, 0, 0, (int)w, 0, 0);
+ // Check if the confirm window already exists.
+ if (window_bring_to_front_by_id(0x1A, w->number)) {
+ return;
+ }
+
+ // Find center of the screen.
+ int screen_height = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16);
+ int screen_width = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16);
+ int x = screen_width/2 - 100;
+ int y = screen_height/2 - 50;
+
+ rct_window* window_prompt = window_create(x, y, 200, 100, (uint32*)0x992C3C, 0x1A, 0);
+ window_prompt->widgets = (rct_widget*)0x9AFB4C;
+ window_prompt->enabled_widgets |= 0x4;
+ window_prompt->enabled_widgets |= 0x8;
+ window_prompt->enabled_widgets |= 0x10;
+
+ window_init_scroll_widgets(window_prompt);
+
+ window_prompt->flags |= 0x10;
+ window_prompt->number = w->number;
+ window_prompt->colours[0] = 0x9A;
}
/**
@@ -316,7 +424,7 @@ void window_staff_peep_set_page(rct_window* w, int page)
}
/** rct2: 0x006BDF55 */
-void window_staff_peep_mouse_up()
+void window_staff_peep_overview_mouseup()
{
short widgetIndex;
rct_window* w;
@@ -324,7 +432,6 @@ void window_staff_peep_mouse_up()
rct_peep* peep = GET_PEEP(w->number);
switch (widgetIndex) {
-
case WIDX_CLOSE:
window_close(w);
break;
@@ -360,4 +467,243 @@ void window_staff_peep_mouse_up()
window_show_textinput(w, (int)widgetIndex, 0xBA1, 0xBA2, peep->name_string_idx);
break;
}
+}
+
+/** rct2: 0x006BE558 */
+void window_staff_peep_overview_resize()
+{
+ rct_window* w;
+ window_get_register(w);
+
+ window_staff_peep_disable_widgets(w);
+
+ w->min_width = 190;
+ w->max_width = 500;
+ w->min_height = 180;
+ w->max_height = 450;
+
+ if (w->width < w->min_width) {
+ w->width = w->min_width;
+ window_invalidate(w);
+ }
+
+ if (w->width > w->max_width) {
+ window_invalidate(w);
+ w->width = w->max_width;
+ }
+
+ if (w->height < w->min_height) {
+ w->height = w->min_height;
+ window_invalidate(w);
+ }
+
+ if (w->height > w->max_height) {
+ window_invalidate(w);
+ w->height = w->max_height;
+ }
+
+ rct_viewport* viewport = w->viewport;
+
+ if (viewport) {
+ int new_width = w->width - 30;
+ int new_height = w->height - 62;
+
+ // Update the viewport size
+ if (viewport->width != new_width || viewport->height != new_height) {
+ viewport->width = new_width;
+ viewport->height = new_height;
+ viewport->view_width = new_width << viewport->zoom;
+ viewport->view_height = new_height << viewport->zoom;
+ }
+ }
+
+ RCT2_CALLPROC_X(0x006BEDA3, 0, 0, 0, 0, (int)w, 0, 0);
+}
+
+/**
+ * Handle the dropdown of patrol button.
+ * rct2: 0x006BDF98
+ */
+void window_staff_peep_overview_mousedown(int widgetIndex, rct_window* w, rct_widget* widget)
+{
+ if (widgetIndex != WIDX_PATROL) {
+ return;
+ }
+
+ // Dropdown names
+ gDropdownItemsFormat[0] = 0xD75;
+ gDropdownItemsFormat[1] = 0xD76;
+
+ int x = widget->left + w->x;
+ int y = widget->top + w->y;;
+ int extray = widget->bottom - widget->top + 1;
+ window_dropdown_show_text(x, y, extray, w->colours[1], 0, 2);
+ RCT2_GLOBAL(0x009DEBA2, sint16) = 0;
+
+ rct_peep* peep = GET_PEEP(w->number);
+
+ // Disable clear patrol area if no area is set.
+ if (!(RCT2_ADDRESS(0x013CA672, uint8)[peep->var_C5] & 2)) {
+ RCT2_GLOBAL(0x009DED34, sint32) |= 1 << 1;
+ }
+}
+
+/** rct2: 0x006BDFA3 */
+void window_staff_peep_overview_dropdown()
+{
+ short widgetIndex, dropdownIndex;
+ rct_window* w;
+
+ window_dropdown_get_registers(w, widgetIndex, dropdownIndex);
+
+ if (widgetIndex != WIDX_PATROL) {
+ return;
+ }
+
+ // Clear patrol
+ if (dropdownIndex == 1) {
+ rct_peep* peep = GET_PEEP(w->number);
+ int edi = peep->var_C5;
+ int ebx = edi << 9;
+
+ for (int i = 0; i < 128; i++)
+ {
+ RCT2_GLOBAL(0x13B0E72 + ebx + i * 4, uint32) = 0;
+ }
+ RCT2_GLOBAL(0x13CA672 + edi, uint16) &= 0xFD; // bug??
+
+ window_invalidate(w);
+ RCT2_CALLPROC_EBPSAFE(0x006C0C3F);
+ }
+ else {
+ if (!tool_set(w, widgetIndex, 22)) {
+ show_gridlines();
+ RCT2_GLOBAL(0x009DEA50, sint16) = w->number;
+ window_invalidate(w);
+ }
+ }
+}
+
+/**
+ * Update the animation frame of the tab icon.
+ * rct2: 0x6BE602
+ */
+void window_staff_peep_overview_update(rct_window* w)
+{
+ int var_496 = RCT2_GLOBAL((int)w + 0x496, uint16);
+ var_496++;
+ if (var_496 >= 24) {
+ var_496 = 0;
+ }
+ RCT2_GLOBAL((int)w + 0x496, uint16) = var_496;
+ window_invalidate_by_id(0x497, w->number);
+}
+
+/** rct2: 0x006BE814 */
+void window_staff_peep_set_order(rct_window* w, int order_id)
+{
+ int eax = 1 << order_id;
+
+ rct_peep* peep = GET_PEEP(w->number);
+
+ int ax = peep->var_C6 ^ eax;
+ int flags = (ax << 8) | 1;
+
+ game_do_command(peep->x, flags, peep->y, w->number, GAME_COMMAND_SET_STAFF_ORDER, (int)peep, 0);
+}
+
+/** rct2: 0x006BE7DB */
+void window_staff_peep_orders_mouseup()
+{
+ short widgetIndex;
+ rct_window* w;
+ window_widget_get_registers(w, widgetIndex);
+
+ switch (widgetIndex) {
+ case WIDX_CLOSE:
+ window_close(w);
+ break;
+ case WIDX_TAB_1:
+ case WIDX_TAB_2:
+ case WIDX_TAB_3:
+ window_staff_peep_set_page(w, widgetIndex - WIDX_TAB_1);
+ break;
+ case WIDX_CHECKBOX_1:
+ case WIDX_CHECKBOX_2:
+ case WIDX_CHECKBOX_3:
+ case WIDX_CHECKBOX_4:
+ window_staff_peep_set_order(w, widgetIndex - WIDX_CHECKBOX_1);
+ break;
+ }
+}
+
+/** rct2: 0x006BE960 */
+void window_staff_peep_orders_update(rct_window* w)
+{
+ w->frame_no++;
+ window_invalidate_by_id(0x597, w->number);
+}
+
+/** rct2: 0x006BEBCF */
+void window_staff_peep_stats_mouseup()
+{
+ short widgetIndex;
+ rct_window* w;
+ window_widget_get_registers(w, widgetIndex);
+
+ switch (widgetIndex) {
+ case WIDX_CLOSE:
+ window_close(w);
+ break;
+ case WIDX_TAB_1:
+ case WIDX_TAB_2:
+ case WIDX_TAB_3:
+ window_staff_peep_set_page(w, widgetIndex - WIDX_TAB_1);
+ break;
+ }
+}
+
+/** rct2: 0x006BEC1B and rct2: 0x006BE975 */
+void window_staff_peep_stats_resize()
+{
+ rct_window* w;
+ window_get_register(w);
+
+ w->min_width = 190;
+ w->max_width = 190;
+ w->min_height = 119;
+ w->max_height = 119;
+
+ if (w->width < w->min_width) {
+ w->width = w->min_width;
+ window_invalidate(w);
+ }
+
+ if (w->width > w->max_width) {
+ window_invalidate(w);
+ w->width = w->max_width;
+ }
+
+ if (w->height < w->min_height) {
+ w->height = w->min_height;
+ window_invalidate(w);
+ }
+
+ if (w->height > w->max_height) {
+ window_invalidate(w);
+ w->height = w->max_height;
+ }
+}
+
+/** rct2: 0x006BEBEA */
+void window_staff_peep_stats_update(rct_window* w)
+{
+ w->frame_no++;
+ window_invalidate_by_id(0x697, w->number);
+
+ rct_peep* peep = GET_PEEP(w->number);
+ if (peep->var_45 & 0x10) {
+ peep->var_45 &= 0xEF;
+ window_invalidate(w);
+ }
}
\ No newline at end of file