1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-17 03:53:07 +01:00
This commit is contained in:
hexdec
2014-08-29 14:56:57 +02:00
13 changed files with 442 additions and 57 deletions

View File

@@ -170,6 +170,9 @@
#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
@@ -405,6 +408,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

View File

@@ -187,6 +187,18 @@ int sound_load3dparameters()
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
@@ -240,7 +252,7 @@ int dsound_create_primary_buffer(int a, int device, int channels, int samples, i
RCT2_GLOBAL(0x009A6084, DS3DBUFFER).vPosition.x = -1.0f;
RCT2_GLOBAL(0x009A6084, DS3DBUFFER).flMaxDistance = 9.8999996f;
RCT2_GLOBAL(0x009A6084, DS3DBUFFER).flMinDistance = 0.25f;
if (RCT2_CALLFUNC(0x00404F3F, int)) {
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;
@@ -282,7 +294,7 @@ int dsound_create_primary_buffer(int a, int device, int channels, int samples, i
}
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(0x01425B40, WAVEFORMATEX));
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;
}
@@ -338,13 +350,305 @@ int map_sound_info(const char* filename)
}
}
/**
*
* rct2: 0x00405383
*/
MMRESULT sub_405383(HMMIO hmmio, uint32 size, char* buffer, LPMMCKINFO a4, int* read)
{
MMIOINFO mmioinfo;
MMRESULT result;
result = mmioGetInfo(hmmio, &mmioinfo, 0);
if (result != 0) {
*read = 0;
return 1;
}
int size2 = size;
if (size > a4->cksize) {
size2 = a4->cksize;
}
int v8 = 0;
a4->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: 0x00401822
*/
int sub_401822(int channel, HMMIO* hmmio, 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 (RCT2_CALLFUNC_4(0x00405222, int, HMMIO*, HMMIO*, HGLOBAL*, LPMMCKINFO, hmmio, &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 (RCT2_CALLFUNC_4(0x00405465, int, HMMIO*, LPMMCKINFO, LPMMCKINFO, int, &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 (sub_401822(channel, (HMMIO*)&sound_channel->var_8, 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 = RCT2_CALLFUNC_4(0x00405465, int, HMMIO*, LPMMCKINFO, LPMMCKINFO, int, &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 sub_401000(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2, int channel)
{
RCT2_CALLFUNC_6(0x00401000, void, UINT, UINT, DWORD_PTR, DWORD_PTR, DWORD_PTR, int, uTimerID, uMsg, dwUser, dw1, dw2, 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;
sub_405383(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);//RCT2_CALLFUNC_1(0x0040153B, int, int, channel);
sub_405383(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;
}
sub_405383(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);//RCT2_CALLFUNC_1(0x0040153B, int, int, channel);
sub_405383(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;
}
}
/**
@@ -435,7 +739,7 @@ void audio_init2(int device)
}
}
}
if (!RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) & 1 << 4) {
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();
@@ -683,7 +987,7 @@ int sound_play_panned(int sound_id, int x)
}
RCT2_GLOBAL(0x014241BC, uint32) = 1;
sound_prepare(sound_id, &other_sound->sound, 1, RCT2_GLOBAL(0x009AAC6E, uint32));
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);
@@ -1047,7 +1351,7 @@ int sound_channel_stop(int channel)
while (_InterlockedExchange(&RCT2_GLOBAL(0x009E1AAC, LONG), 1) != 1) {
Sleep(10);
}
if (sound_channel->hmem) {
if (sound_channel->hmmio) {
sound_channel_free(&sound_channel->hmmio, &sound_channel->hmem);
}

View File

@@ -69,10 +69,21 @@ typedef struct {
typedef struct {
uint32 var_0;
uint8 pad_4[0x118];
HMMIO hmmio;
HGLOBAL hmem;
uint8 pad_124[0x3C];
uint32 var_4;
uint32 var_8;
uint8 pad_C[0x104];
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;
@@ -112,6 +123,7 @@ 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_channel_free(HMMIO* hmmio, HGLOBAL* hmem);
int sound_stop(rct_sound *sound);
int sound_stop_all();
int unmap_file(LPCVOID base);

View File

@@ -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"
@@ -942,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,

View File

@@ -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
@@ -1557,18 +1565,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 +1769,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));
}
}
/**
* 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];
}

View File

@@ -24,4 +24,6 @@
void game_handle_input();
void game_handle_keyboard_input();
void store_mouse_input(int state);
#endif

View File

@@ -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;
@@ -597,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;
}
}
}

View File

@@ -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)
@@ -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
}

View File

@@ -59,4 +59,6 @@ void park_update_histories();
uint8 calculate_guest_initial_happiness(uint8 percentage);
void game_command_set_park_entrance_fee();
#endif

View File

@@ -139,7 +139,7 @@ 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);

View File

@@ -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;

View File

@@ -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);
@@ -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*);

View File

@@ -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) {