From 11c0849ffc030c501ad5559571cf0ef51f50a7a0 Mon Sep 17 00:00:00 2001 From: King_Hual Date: Fri, 12 Sep 2014 03:59:43 +0300 Subject: [PATCH] Added minimap window resizing - Identified some unknown methods and fields - process_mouse_tool, bufsize - Added map window events and methods - window_map_tooltip, window_map_set_bounds --- src/addresses.h | 2 ++ src/audio.c | 22 +++++++++++----------- src/audio.h | 2 +- src/input.c | 18 ++++++++++-------- src/window_map.c | 31 +++++++++++++++++++++++++++++-- 5 files changed, 53 insertions(+), 22 deletions(-) diff --git a/src/addresses.h b/src/addresses.h index 19263023c3..51fbda55ee 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -421,6 +421,8 @@ #define RCT2_ADDRESS_INPUT_QUEUE 0x01424340 +#define RCT2_ADDRESS_COMMON_FORMAT_ARGS 0x013CE952 + static void RCT2_CALLPROC_EBPSAFE(int address) { #ifdef _MSC_VER diff --git a/src/audio.c b/src/audio.c index fe46f41668..f250d956ea 100644 --- a/src/audio.c +++ b/src/audio.c @@ -447,7 +447,7 @@ int sub_4015E7(int channel) 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); + int result = dsbuffer->lpVtbl->Lock(dsbuffer, 0, sound_channel->bufsize, (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); @@ -499,11 +499,11 @@ int sound_channel_load_file(int channel, char* filename, int offset) sound_channel_free(&sound_channel->hmmio, &sound_channel->hmem); return -103; } - sound_channel->var_150 = 120 * *((uint32*)sound_channel->hmem + 2) / 100; + sound_channel->bufsize = 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.dwBufferBytes = sound_channel->bufsize; 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); @@ -698,10 +698,10 @@ void audio_timefunc(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, D if (dwCurrentPlayCursor >= sound_channel->playpos) { var1 = dwCurrentPlayCursor - sound_channel->playpos; } else { - var1 = dwCurrentPlayCursor + sound_channel->var_150 - sound_channel->playpos; + var1 = dwCurrentPlayCursor + sound_channel->bufsize - sound_channel->playpos; } if (bufferlost) { - var2 = 2 * sound_channel->var_150 / 6; + var2 = 2 * sound_channel->bufsize / 6; } else { var2 = var1; } @@ -726,8 +726,8 @@ void audio_timefunc(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, D } 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; + if (sound_channel->playpos >= sound_channel->bufsize) { + sound_channel->playpos = sound_channel->playpos - sound_channel->bufsize; } return; } @@ -768,7 +768,7 @@ void audio_timefunc(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, D 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; + sound_channel->var_15C = sound_channel->playpos + sound_channel->bufsize - dwCurrentPlayCursor; } goto label49; } @@ -795,8 +795,8 @@ void audio_timefunc(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, D 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 (sound_channel->playpos >= sound_channel->bufsize) { + sound_channel->playpos -= sound_channel->bufsize; } if (bufferlost != 0) { sound_channel->dsbuffer->lpVtbl->Play(sound_channel->dsbuffer, 0, 0, DSBPLAY_LOOPING); @@ -830,7 +830,7 @@ void audio_timefunc(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, D 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; + sound_channel->var_15C = sound_channel->playpos + sound_channel->bufsize - dwCurrentPlayCursor; } goto label68; } diff --git a/src/audio.h b/src/audio.h index c68b059e96..cb9ba496f5 100644 --- a/src/audio.h +++ b/src/audio.h @@ -81,7 +81,7 @@ typedef struct { MMCKINFO mmckinfo1; // 0x124 MMCKINFO mmckinfo2; // 0x138 LPDIRECTSOUNDBUFFER dsbuffer; // 0x14C - uint32 var_150; + uint32 bufsize; uint32 playpos; // 0x154 uint32 var_158; uint32 var_15C; diff --git a/src/input.c b/src/input.c index 725b6e9eb9..1fa02fbb77 100644 --- a/src/input.c +++ b/src/input.c @@ -48,7 +48,7 @@ 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); static void input_mouseover_widget_flatbutton_invalidate(); void process_mouse_over(int x, int y); -void sub_6ED801(int x, int y); +void process_mouse_tool(int x, int y); void invalidate_scroll(); static rct_mouse_data* get_mouse_input(); @@ -1546,7 +1546,7 @@ void game_handle_input() // RCT2_CALLPROC_X(0x006E8655, eax, ebx, 0, 0, 0, 0, 0); // window_process_mouse_input process_mouse_over(eax, ebx); //RCT2_CALLPROC_X(0x006ED833, eax, ebx, 0, 0, 0, 0, 0); - sub_6ED801(eax, ebx); + process_mouse_tool(eax, ebx); //RCT2_CALLPROC_EBPSAFE(0x006ED801); } } @@ -1601,15 +1601,17 @@ static void game_get_next_input(int *x, int *y, int *state) * * rct2: 0x006ED801 */ -void sub_6ED801(int x, int y){ - if (RCT2_GLOBAL(0x9DE518, uint32) & (1 << 3)){ +void process_mouse_tool(int x, int y) +{ + if (RCT2_GLOBAL(0x9DE518, uint32) & (1 << 3)) + { rct_window* w = window_find_by_id(RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, uint8), RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWNUMBER, uint16)); - if (w == NULL){ + + if (!w) tool_cancel(); - } - else{ + else RCT2_CALLPROC_X(w->event_handlers[WE_TOOL_UPDATE], x, y, 0, RCT2_GLOBAL(0x9DE546, uint16), (int)w, 0, 0); - } + } } diff --git a/src/window_map.c b/src/window_map.c index 9ac0b2e380..92b82dd1a1 100644 --- a/src/window_map.c +++ b/src/window_map.c @@ -84,6 +84,9 @@ static void window_map_scrollmousedown(); static void window_map_invalidate(); static void window_map_paint(); static void window_map_scrollpaint(); +static void window_map_tooltip(); + +static void window_map_set_bounds(rct_window* w); static void window_map_init_map(); static void sub_68C990(); @@ -111,7 +114,7 @@ static void* window_map_events[] = { window_map_emptysub, window_map_emptysub, window_map_emptysub, - (void*)0x0068D140, + window_map_tooltip, window_map_emptysub, window_map_emptysub, window_map_invalidate, @@ -160,8 +163,10 @@ void window_map_open() (1 << WIDX_ROTATE_90) | (1 << WIDX_PEOPLE_STARTING_POSITION); w->var_020 |= 0x300; - window_init_scroll_widgets(w); + + window_map_set_bounds(w); + w->map.rotation = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint16); window_map_init_map(); @@ -452,6 +457,15 @@ static void window_map_paint() gfx_draw_string_left(dpi, STR_MAP_SIZE, 0, 0, w->x + 4, w->y + w->widgets[WIDX_MAP_SIZE_SPINNER].top + 1); } +/* +* +* rct2: 0x0068D140 +*/ +static void window_map_tooltip() +{ + RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, short) = 0xC55; +} + /** * * rct2: 0x0068CF23 @@ -547,4 +561,17 @@ static void sub_68C990() w_map->scrolls[0].h_left = cx; w_map->scrolls[0].v_top = dx; widget_scroll_update_thumbs(w, WIDX_MAP); +} + +/** +* ref. by: window_map_scrollmousedown +* rct2: 0x0068D7DC +*/ +void window_map_set_bounds(rct_window* w) +{ + w->flags |= WF_RESIZABLE; // (1 << 8) + w->min_width = 245; + w->max_width = 800; + w->min_height = 259; + w->max_height = 560; } \ No newline at end of file